Planar-Pioneers/assets/index.b751e4e6.js

18 lines
216 KiB
JavaScript

/* empty css */import"./vue.c16a309b.js";import{_ as C,C as s,l as Ae,q as gn,t as L,b2 as gt,ab as X,aF as M,a1 as P,a2 as N,aL as Tt,G as ge,aD as _r,w as mt,b3 as kt,a9 as f,O as ne,ap as fa,az as pi,as as jt,aH as ti,A as Ee,$ as ee,b7 as W,b9 as Bi,ar as zt,bv as En,a8 as E,bt as ga,bc as Dn,T as ma,u as Li,j as va,bw as At,aM as St,a0 as j,aO as He,J as se,I as qe,aI as vn,aG as hn,z as Qt,bo as ha,bs as ba,aK as Pn,bd as sr,am as ai,H as ya,bx as wa,bf as _a}from"./@vue.6b211d3c.js";import{c as Nr}from"./nanoevents.1080beb7.js";import{L as Xt}from"./lz-string.dccec454.js";import{Y as Na}from"./vue-next-select.ded54c4a.js";import{D as Ca}from"./vuedraggable.1879de79.js";import{p as ka}from"./vue-textarea-autosize.35804eaf.js";import{P as Ma}from"./vue-panzoom.8ce6f9b1.js";import{s as Sa,u as fi}from"./vue-toastification.9c2dad53.js";import"./amator.1e5a40c8.js";import"./bezier-easing.a990b400.js";import"./sortablejs.a0f68e5e.js";import"./panzoom.30c56ba6.js";import"./wheel.f2ae740f.js";import"./ngraph.events.083734c6.js";const Ia=function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerpolicy&&(a.referrerPolicy=r.referrerpolicy),r.crossorigin==="use-credentials"?a.credentials="include":r.crossorigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}};Ia();const xa="modulepreload",or={},$a="./",zn=function(t,n){return!n||n.length===0?t():Promise.all(n.map(i=>{if(i=`${$a}${i}`,i in or)return;or[i]=!0;const r=i.endsWith(".css"),a=r?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${i}"]${a}`))return;const l=document.createElement("link");if(l.rel=r?"stylesheet":xa,r||(l.as="script",l.crossOrigin=""),l.href=i,document.head.appendChild(l),r)return new Promise((u,c)=>{l.addEventListener("load",u),l.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>t())},Ea="./projInfo-schema.json",Da="Planar Pioneers",Pa="A game about controlling and exploiting planes!",Ta="planar-pioneers",Aa="thepaperpilot",Fa="",Oa="",Ra="0.0",qa="Initial Commit",Va=!1,Ba=!1,La=2,ja=!0,za=null,Ua="",Ga=["main"],Wa=3600,Ha=0,Za=!0,Ya="base64";var pe={$schema:Ea,title:Da,description:Pa,id:Ta,author:Aa,discordName:Fa,discordLink:Oa,versionNumber:Ra,versionTitle:qa,allowGoBack:Va,defaultShowSmall:Ba,defaultDecimalsShown:La,useHeader:ja,banner:za,logo:Ua,initialTabs:Ga,maxTickLength:Wa,offlineLimit:Ha,enablePausing:Za,exportEncoding:Ya};class Xa{constructor(t){this.map=new Map,this.first=void 0,this.last=void 0,this.maxSize=t}get size(){return this.map.size}get(t){const n=this.map.get(t);if(n!==void 0)return n!==this.first&&(n===this.last?(this.last=n.prev,this.last.next=void 0):(n.prev.next=n.next,n.next.prev=n.prev),n.next=this.first,this.first.prev=n,this.first=n),n.value}set(t,n){if(this.maxSize<1)return;if(this.map.has(t))throw new Error("Cannot update existing keys in the cache");const i=new Ja(t,n);for(this.first===void 0?(this.first=i,this.last=i):(i.next=this.first,this.first.prev=i,this.first=i),this.map.set(t,i);this.map.size>this.maxSize;){const r=this.last;this.map.delete(r.key),this.last=r.prev,this.last.next=void 0}}}class Ja{constructor(t,n){this.next=void 0,this.prev=void 0,this.key=t,this.value=n}}const Ei=17,Ka=9e15,Qa=Math.log10(9e15),es=1/9e15,ts=308,ns=-324,lr=5,is=(1<<10)-1,rs=function(){const e=[];for(let n=ns+1;n<=ts;n++)e.push(Number("1e"+n));const t=323;return function(n){return e[n+t]}}(),an=[2,Math.E,3,4,5,6,7,8,9,10],as=[[1,1.0891180521811203,1.1789767925673957,1.2701455431742086,1.3632090180450092,1.4587818160364217,1.5575237916251419,1.6601571006859253,1.767485818836978,1.8804192098842727,2],[1,1.1121114330934079,1.231038924931609,1.3583836963111375,1.4960519303993531,1.6463542337511945,1.8121385357018724,1.996971324618307,2.2053895545527546,2.4432574483385254,Math.E],[1,1.1187738849693603,1.2464963939368214,1.38527004705667,1.5376664685821402,1.7068895236551784,1.897001227148399,2.1132403089001035,2.362480153784171,2.6539010333870774,3],[1,1.1367350847096405,1.2889510672956703,1.4606478703324786,1.6570295196661111,1.8850062585672889,2.1539465047453485,2.476829779693097,2.872061932789197,3.3664204535587183,4],[1,1.1494592900767588,1.319708228183931,1.5166291280087583,1.748171114438024,2.0253263297298045,2.3636668498288547,2.7858359149579424,3.3257226212448145,4.035730287722532,5],[1,1.159225940787673,1.343712473580932,1.5611293155111927,1.8221199554561318,2.14183924486326,2.542468319282638,3.0574682501653316,3.7390572020926873,4.6719550537360774,6],[1,1.1670905356972596,1.3632807444991446,1.5979222279405536,1.8842640123816674,2.2416069644878687,2.69893426559423,3.3012632110403577,4.121250340630164,5.281493033448316,7],[1,1.1736630594087796,1.379783782386201,1.6292821855668218,1.9378971836180754,2.3289975651071977,2.8384347394720835,3.5232708454565906,4.478242031114584,5.868592169644505,8],[1,1.1793017514670474,1.394054150657457,1.65664127441059,1.985170999970283,2.4069682290577457,2.9647310119960752,3.7278665320924946,4.814462547283592,6.436522247411611,9],[1,1.1840100246247336,1.4061375836156955,1.6802272208863964,2.026757028388619,2.4770056063449646,3.080525271755482,3.9191964192627284,5.135152840833187,6.989961179534715,10]],ss=[[-1,-.9194161097107025,-.8335625019330468,-.7425599821143978,-.6466611521029437,-.5462617907227869,-.4419033816638769,-.3342645487554494,-.224140440909962,-.11241087890006762,0],[-1,-.90603157029014,-.80786507256596,-.7064666939634,-.60294836853664,-.49849837513117,-.39430303318768,-.29147201034755,-.19097820800866,-.09361896280296,0],[-1,-.9021579584316141,-.8005762598234203,-.6964780623319391,-.5911906810998454,-.486050182576545,-.3823089430815083,-.28106046722897615,-.1831906535795894,-.08935809204418144,0],[-1,-.8917227442365535,-.781258746326964,-.6705130326902455,-.5612813129406509,-.4551067709033134,-.35319256652135966,-.2563741554088552,-.1651412821106526,-.0796919581982668,0],[-1,-.8843387974366064,-.7678744063886243,-.6529563724510552,-.5415870994657841,-.4352842206588936,-.33504449124791424,-.24138853420685147,-.15445285440944467,-.07409659641336663,0],[-1,-.8786709358426346,-.7577735191184886,-.6399546189952064,-.527284921869926,-.4211627631006314,-.3223479611761232,-.23107655627789858,-.1472057700818259,-.07035171210706326,0],[-1,-.8740862815291583,-.7497032990976209,-.6297119746181752,-.5161838335958787,-.41036238255751956,-.31277212146489963,-.2233976621705518,-.1418697367979619,-.06762117662323441,0],[-1,-.8702632331800649,-.7430366914122081,-.6213373075161548,-.5072025698095242,-.40171437727184167,-.30517930701410456,-.21736343968190863,-.137710238299109,-.06550774483471955,0],[-1,-.8670016295947213,-.7373984232432306,-.6143173985094293,-.49973884395492807,-.394584953527678,-.2989649949848695,-.21245647317021688,-.13434688362382652,-.0638072667348083,0],[-1,-.8641642839543857,-.732534623168535,-.6083127477059322,-.4934049257184696,-.3885773075899922,-.29376029055315767,-.2083678561173622,-.13155653399373268,-.062401588652553186,0]];let k=function(t){return o.fromValue_noAlloc(t)},Y=function(e,t,n){return o.fromComponents(e,t,n)},te=function(t,n,i){return o.fromComponents_noNormalize(t,n,i)};const Zt=function(t,n){const i=n+1,r=Math.ceil(Math.log10(Math.abs(t))),a=Math.round(t*Math.pow(10,i-r))*Math.pow(10,r-i);return parseFloat(a.toFixed(Math.max(i-r,0)))},Di=function(e){return Math.sign(e)*Math.log10(Math.abs(e))},os=function(e){if(!isFinite(e))return e;if(e<-50)return e===Math.trunc(e)?Number.NEGATIVE_INFINITY:0;let t=1;for(;e<10;)t=t*e,++e;e-=1;let n=.9189385332046727;n=n+(e+.5)*Math.log(e),n=n-e;const i=e*e;let r=e;return n=n+1/(12*r),r=r*i,n=n+1/(360*r),r=r*i,n=n+1/(1260*r),r=r*i,n=n+1/(1680*r),r=r*i,n=n+1/(1188*r),r=r*i,n=n+691/(360360*r),r=r*i,n=n+7/(1092*r),r=r*i,n=n+3617/(122400*r),Math.exp(n)/t},Cr=.5671432904097838,ur=function(e,t=1e-10){let n,i;if(!Number.isFinite(e)||e===0)return e;if(e===1)return Cr;e<10?n=0:n=Math.log(e)-Math.log(Math.log(e));for(let r=0;r<100;++r){if(i=(e*Math.exp(-n)+n*n)/(n+1),Math.abs(i-n)<t*Math.abs(i))return i;n=i}throw Error(`Iteration failed to converge: ${e.toString()}`)};function cr(e,t=1e-10){let n,i,r,a;if(!Number.isFinite(e.mag)||e.eq(o.dZero))return e;if(e.eq(o.dOne))return o.fromNumber(Cr);n=o.ln(e);for(let l=0;l<100;++l){if(i=n.neg().exp(),r=n.sub(e.mul(i)),a=n.sub(r.div(n.add(1).sub(n.add(2).mul(r).div(o.mul(2,n).add(2))))),o.abs(a.sub(n)).lt(o.abs(a).mul(t)))return a;n=a}throw Error(`Iteration failed to converge: ${e.toString()}`)}const y=class{constructor(e){this.sign=0,this.mag=0,this.layer=0,e instanceof y?this.fromDecimal(e):typeof e=="number"?this.fromNumber(e):typeof e=="string"&&this.fromString(e)}get m(){if(this.sign===0)return 0;if(this.layer===0){const e=Math.floor(Math.log10(this.mag));let t;return this.mag===5e-324?t=5:t=this.mag/rs(e),this.sign*t}else if(this.layer===1){const e=this.mag-Math.floor(this.mag);return this.sign*Math.pow(10,e)}else return this.sign}set m(e){this.layer<=2?this.fromMantissaExponent(e,this.e):(this.sign=Math.sign(e),this.sign===0&&(this.layer=0,this.exponent=0))}get e(){return this.sign===0?0:this.layer===0?Math.floor(Math.log10(this.mag)):this.layer===1?Math.floor(this.mag):this.layer===2?Math.floor(Math.sign(this.mag)*Math.pow(10,Math.abs(this.mag))):this.mag*Number.POSITIVE_INFINITY}set e(e){this.fromMantissaExponent(this.m,e)}get s(){return this.sign}set s(e){e===0?(this.sign=0,this.layer=0,this.mag=0):this.sign=e}get mantissa(){return this.m}set mantissa(e){this.m=e}get exponent(){return this.e}set exponent(e){this.e=e}static fromComponents(e,t,n){return new y().fromComponents(e,t,n)}static fromComponents_noNormalize(e,t,n){return new y().fromComponents_noNormalize(e,t,n)}static fromMantissaExponent(e,t){return new y().fromMantissaExponent(e,t)}static fromMantissaExponent_noNormalize(e,t){return new y().fromMantissaExponent_noNormalize(e,t)}static fromDecimal(e){return new y().fromDecimal(e)}static fromNumber(e){return new y().fromNumber(e)}static fromString(e){return new y().fromString(e)}static fromValue(e){return new y().fromValue(e)}static fromValue_noAlloc(e){if(e instanceof y)return e;if(typeof e=="string"){const t=y.fromStringCache.get(e);return t!==void 0?t:y.fromString(e)}else return typeof e=="number"?y.fromNumber(e):y.dZero}static abs(e){return k(e).abs()}static neg(e){return k(e).neg()}static negate(e){return k(e).neg()}static negated(e){return k(e).neg()}static sign(e){return k(e).sign}static sgn(e){return k(e).sign}static round(e){return k(e).round()}static floor(e){return k(e).floor()}static ceil(e){return k(e).ceil()}static trunc(e){return k(e).trunc()}static add(e,t){return k(e).add(t)}static plus(e,t){return k(e).add(t)}static sub(e,t){return k(e).sub(t)}static subtract(e,t){return k(e).sub(t)}static minus(e,t){return k(e).sub(t)}static mul(e,t){return k(e).mul(t)}static multiply(e,t){return k(e).mul(t)}static times(e,t){return k(e).mul(t)}static div(e,t){return k(e).div(t)}static divide(e,t){return k(e).div(t)}static recip(e){return k(e).recip()}static reciprocal(e){return k(e).recip()}static reciprocate(e){return k(e).reciprocate()}static cmp(e,t){return k(e).cmp(t)}static cmpabs(e,t){return k(e).cmpabs(t)}static compare(e,t){return k(e).cmp(t)}static isNaN(e){return e=k(e),isNaN(e.sign)||isNaN(e.layer)||isNaN(e.mag)}static isFinite(e){return e=k(e),isFinite(e.sign)&&isFinite(e.layer)&&isFinite(e.mag)}static eq(e,t){return k(e).eq(t)}static equals(e,t){return k(e).eq(t)}static neq(e,t){return k(e).neq(t)}static notEquals(e,t){return k(e).notEquals(t)}static lt(e,t){return k(e).lt(t)}static lte(e,t){return k(e).lte(t)}static gt(e,t){return k(e).gt(t)}static gte(e,t){return k(e).gte(t)}static max(e,t){return k(e).max(t)}static min(e,t){return k(e).min(t)}static minabs(e,t){return k(e).minabs(t)}static maxabs(e,t){return k(e).maxabs(t)}static clamp(e,t,n){return k(e).clamp(t,n)}static clampMin(e,t){return k(e).clampMin(t)}static clampMax(e,t){return k(e).clampMax(t)}static cmp_tolerance(e,t,n){return k(e).cmp_tolerance(t,n)}static compare_tolerance(e,t,n){return k(e).cmp_tolerance(t,n)}static eq_tolerance(e,t,n){return k(e).eq_tolerance(t,n)}static equals_tolerance(e,t,n){return k(e).eq_tolerance(t,n)}static neq_tolerance(e,t,n){return k(e).neq_tolerance(t,n)}static notEquals_tolerance(e,t,n){return k(e).notEquals_tolerance(t,n)}static lt_tolerance(e,t,n){return k(e).lt_tolerance(t,n)}static lte_tolerance(e,t,n){return k(e).lte_tolerance(t,n)}static gt_tolerance(e,t,n){return k(e).gt_tolerance(t,n)}static gte_tolerance(e,t,n){return k(e).gte_tolerance(t,n)}static pLog10(e){return k(e).pLog10()}static absLog10(e){return k(e).absLog10()}static log10(e){return k(e).log10()}static log(e,t){return k(e).log(t)}static log2(e){return k(e).log2()}static ln(e){return k(e).ln()}static logarithm(e,t){return k(e).logarithm(t)}static pow(e,t){return k(e).pow(t)}static pow10(e){return k(e).pow10()}static pow_base(e,t){return k(e).pow_base(t)}static root(e,t){return k(e).root(t)}static factorial(e,t){return k(e).factorial()}static gamma(e,t){return k(e).gamma()}static lngamma(e,t){return k(e).lngamma()}static exp(e){return k(e).exp()}static sqr(e){return k(e).sqr()}static sqrt(e){return k(e).sqrt()}static cube(e){return k(e).cube()}static cbrt(e){return k(e).cbrt()}static tetrate(e,t=2,n=te(1,0,1)){return k(e).tetrate(t,n)}static iteratedexp(e,t=2,n=te(1,0,1)){return k(e).iteratedexp(t,n)}static iteratedlog(e,t=10,n=1){return k(e).iteratedlog(t,n)}static layeradd10(e,t){return k(e).layeradd10(t)}static layeradd(e,t,n=10){return k(e).layeradd(t,n)}static slog(e,t=10){return k(e).slog(t)}static lambertw(e){return k(e).lambertw()}static ssqrt(e){return k(e).ssqrt()}static pentate(e,t=2,n=te(1,0,1)){return k(e).pentate(t,n)}static sin(e){return k(e).sin()}static cos(e){return k(e).cos()}static tan(e){return k(e).tan()}static asin(e){return k(e).asin()}static acos(e){return k(e).acos()}static atan(e){return k(e).atan()}static sinh(e){return k(e).sinh()}static cosh(e){return k(e).cosh()}static tanh(e){return k(e).tanh()}static asinh(e){return k(e).asinh()}static acosh(e){return k(e).acosh()}static atanh(e){return k(e).atanh()}static affordGeometricSeries(e,t,n,i){return this.affordGeometricSeries_core(k(e),k(t),k(n),i)}static sumGeometricSeries(e,t,n,i){return this.sumGeometricSeries_core(e,k(t),k(n),i)}static affordArithmeticSeries(e,t,n,i){return this.affordArithmeticSeries_core(k(e),k(t),k(n),k(i))}static sumArithmeticSeries(e,t,n,i){return this.sumArithmeticSeries_core(k(e),k(t),k(n),k(i))}static efficiencyOfPurchase(e,t,n){return this.efficiencyOfPurchase_core(k(e),k(t),k(n))}static randomDecimalForTesting(e){if(Math.random()*20<1)return te(0,0,0);const t=Math.random()>.5?1:-1;if(Math.random()*20<1)return te(t,0,1);const n=Math.floor(Math.random()*(e+1));let i=n===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let r=Math.pow(10,i);return Math.random()>.9&&(r=Math.trunc(r)),Y(t,n,r)}static affordGeometricSeries_core(e,t,n,i){const r=t.mul(n.pow(i));return y.floor(e.div(r).mul(n.sub(1)).add(1).log10().div(n.log10()))}static sumGeometricSeries_core(e,t,n,i){return t.mul(n.pow(i)).mul(y.sub(1,n.pow(e))).div(y.sub(1,n))}static affordArithmeticSeries_core(e,t,n,i){const a=t.add(i.mul(n)).sub(n.div(2)),l=a.pow(2);return a.neg().add(l.add(n.mul(e).mul(2)).sqrt()).div(n).floor()}static sumArithmeticSeries_core(e,t,n,i){const r=t.add(i.mul(n));return e.div(2).mul(r.mul(2).plus(e.sub(1).mul(n)))}static efficiencyOfPurchase_core(e,t,n){return e.div(t).add(e.div(n))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0)return this.sign=0,this.mag=0,this.layer=0,this;if(this.layer===0&&this.mag<0&&(this.mag=-this.mag,this.sign=-this.sign),this.layer===0&&this.mag<es)return this.layer+=1,this.mag=Math.log10(this.mag),this;let e=Math.abs(this.mag),t=Math.sign(this.mag);if(e>=Ka)return this.layer+=1,this.mag=t*Math.log10(e),this;for(;e<Qa&&this.layer>0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=t*Math.pow(10,e),e=Math.abs(this.mag),t=Math.sign(this.mag));return this.layer===0&&(this.mag<0?(this.mag=-this.mag,this.sign=-this.sign):this.mag===0&&(this.sign=0)),this}fromComponents(e,t,n){return this.sign=e,this.layer=t,this.mag=n,this.normalize(),this}fromComponents_noNormalize(e,t,n){return this.sign=e,this.layer=t,this.mag=n,this}fromMantissaExponent(e,t){return this.layer=1,this.sign=Math.sign(e),e=Math.abs(e),this.mag=t+Math.log10(e),this.normalize(),this}fromMantissaExponent_noNormalize(e,t){return this.fromMantissaExponent(e,t),this}fromDecimal(e){return this.sign=e.sign,this.layer=e.layer,this.mag=e.mag,this}fromNumber(e){return this.mag=Math.abs(e),this.sign=Math.sign(e),this.layer=0,this.normalize(),this}fromString(e){const t=e,n=y.fromStringCache.get(t);if(n!==void 0)return this.fromDecimal(n);e=e.replace(",","");const i=e.split("^^^");if(i.length===2){const b=parseFloat(i[0]),v=parseFloat(i[1]),I=i[1].split(";");let F=1;if(I.length===2&&(F=parseFloat(I[1]),isFinite(F)||(F=1)),isFinite(b)&&isFinite(v)){const S=y.pentate(b,v,F);return this.sign=S.sign,this.layer=S.layer,this.mag=S.mag,y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this}}const r=e.split("^^");if(r.length===2){const b=parseFloat(r[0]),v=parseFloat(r[1]),I=r[1].split(";");let F=1;if(I.length===2&&(F=parseFloat(I[1]),isFinite(F)||(F=1)),isFinite(b)&&isFinite(v)){const S=y.tetrate(b,v,F);return this.sign=S.sign,this.layer=S.layer,this.mag=S.mag,y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this}}const a=e.split("^");if(a.length===2){const b=parseFloat(a[0]),v=parseFloat(a[1]);if(isFinite(b)&&isFinite(v)){const I=y.pow(b,v);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this}}e=e.trim().toLowerCase();let l,u,c=e.split("pt");if(c.length===2){l=10,u=parseFloat(c[0]),c[1]=c[1].replace("(",""),c[1]=c[1].replace(")","");let b=parseFloat(c[1]);if(isFinite(b)||(b=1),isFinite(l)&&isFinite(u)){const v=y.tetrate(l,u,b);return this.sign=v.sign,this.layer=v.layer,this.mag=v.mag,y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this}}if(c=e.split("p"),c.length===2){l=10,u=parseFloat(c[0]),c[1]=c[1].replace("(",""),c[1]=c[1].replace(")","");let b=parseFloat(c[1]);if(isFinite(b)||(b=1),isFinite(l)&&isFinite(u)){const v=y.tetrate(l,u,b);return this.sign=v.sign,this.layer=v.layer,this.mag=v.mag,y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this}}const d=e.split("e"),m=d.length-1;if(m===0){const b=parseFloat(e);if(isFinite(b))return this.fromNumber(b),y.fromStringCache.size>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this}else if(m===1){const b=parseFloat(e);if(isFinite(b)&&b!==0)return this.fromNumber(b),y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this}const p=e.split("e^");if(p.length===2){this.sign=1,p[0].charAt(0)=="-"&&(this.sign=-1);let b="";for(let v=0;v<p[1].length;++v){const I=p[1].charCodeAt(v);if(I>=43&&I<=57||I===101)b+=p[1].charAt(v);else return this.layer=parseFloat(b),this.mag=parseFloat(p[1].substr(v+1)),this.normalize(),y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this}}if(m<1)return this.sign=0,this.layer=0,this.mag=0,y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this;const h=parseFloat(d[0]);if(h===0)return this.sign=0,this.layer=0,this.mag=0,y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this;let w=parseFloat(d[d.length-1]);if(m>=2){const b=parseFloat(d[d.length-2]);isFinite(b)&&(w*=Math.sign(b),w+=Di(b))}if(!isFinite(h))this.sign=d[0]==="-"?-1:1,this.layer=m,this.mag=w;else if(m===1)this.sign=Math.sign(h),this.layer=1,this.mag=w+Math.log10(Math.abs(h));else if(this.sign=Math.sign(h),this.layer=m,m===2){const b=y.mul(Y(1,2,w),k(h));return this.sign=b.sign,this.layer=b.layer,this.mag=b.mag,y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this}else this.mag=w;return this.normalize(),y.fromStringCache.maxSize>=1&&y.fromStringCache.set(t,y.fromDecimal(this)),this}fromValue(e){return e instanceof y?this.fromDecimal(e):typeof e=="number"?this.fromNumber(e):typeof e=="string"?this.fromString(e):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return Number.isFinite(this.layer)?this.layer===0?this.sign*this.mag:this.layer===1?this.sign*Math.pow(10,this.mag):this.mag>0?this.sign>0?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:0:Number.NaN}mantissaWithDecimalPlaces(e){return isNaN(this.m)?Number.NaN:this.m===0?0:Zt(this.m,e)}magnitudeWithDecimalPlaces(e){return isNaN(this.mag)?Number.NaN:this.mag===0?0:Zt(this.mag,e)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY?this.sign===1?"Infinity":"-Infinity":this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toString():this.m+"e"+this.e:this.layer===1?this.m+"e"+this.e:this.layer<=lr?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(e){return this.layer===0?(this.sign*this.mag).toExponential(e):this.toStringWithDecimalPlaces(e)}toFixed(e){return this.layer===0?(this.sign*this.mag).toFixed(e):this.toStringWithDecimalPlaces(e)}toPrecision(e){return this.e<=-7?this.toExponential(e-1):e>this.e?this.toFixed(e-this.exponent-1):this.toExponential(e-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(e){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(e):Zt(this.m,e)+"e"+Zt(this.e,e):this.layer===1?Zt(this.m,e)+"e"+Zt(this.e,e):this.layer<=lr?(this.sign===-1?"-":"")+"e".repeat(this.layer)+Zt(this.mag,e):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+Zt(this.mag,e)}abs(){return te(this.sign===0?0:1,this.layer,this.mag)}neg(){return te(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?y.dZero:this.layer===0?Y(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?y.dZero:this.layer===0?Y(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?y.dZero:this.layer===0?Y(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?y.dZero:this.layer===0?Y(this.sign,0,Math.trunc(this.mag)):this}add(e){const t=k(e);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(t.layer)||this.sign===0)return t;if(t.sign===0)return this;if(this.sign===-t.sign&&this.layer===t.layer&&this.mag===t.mag)return te(0,0,0);let n,i;if(this.layer>=2||t.layer>=2)return this.maxabs(t);if(y.cmpabs(this,t)>0?(n=this,i=t):(n=t,i=this),n.layer===0&&i.layer===0)return y.fromNumber(n.sign*n.mag+i.sign*i.mag);const r=n.layer*Math.sign(n.mag),a=i.layer*Math.sign(i.mag);if(r-a>=2)return n;if(r===0&&a===-1){if(Math.abs(i.mag-Math.log10(n.mag))>Ei)return n;{const l=Math.pow(10,Math.log10(n.mag)-i.mag),u=i.sign+n.sign*l;return Y(Math.sign(u),1,i.mag+Math.log10(Math.abs(u)))}}if(r===1&&a===0){if(Math.abs(n.mag-Math.log10(i.mag))>Ei)return n;{const l=Math.pow(10,n.mag-Math.log10(i.mag)),u=i.sign+n.sign*l;return Y(Math.sign(u),1,Math.log10(i.mag)+Math.log10(Math.abs(u)))}}if(Math.abs(n.mag-i.mag)>Ei)return n;{const l=Math.pow(10,n.mag-i.mag),u=i.sign+n.sign*l;return Y(Math.sign(u),1,i.mag+Math.log10(Math.abs(u)))}}plus(e){return this.add(e)}sub(e){return this.add(k(e).neg())}subtract(e){return this.sub(e)}minus(e){return this.sub(e)}mul(e){const t=k(e);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(t.layer))return t;if(this.sign===0||t.sign===0)return te(0,0,0);if(this.layer===t.layer&&this.mag===-t.mag)return te(this.sign*t.sign,0,1);let n,i;if(this.layer>t.layer||this.layer==t.layer&&Math.abs(this.mag)>Math.abs(t.mag)?(n=this,i=t):(n=t,i=this),n.layer===0&&i.layer===0)return y.fromNumber(n.sign*i.sign*n.mag*i.mag);if(n.layer>=3||n.layer-i.layer>=2)return Y(n.sign*i.sign,n.layer,n.mag);if(n.layer===1&&i.layer===0)return Y(n.sign*i.sign,1,n.mag+Math.log10(i.mag));if(n.layer===1&&i.layer===1)return Y(n.sign*i.sign,1,n.mag+i.mag);if(n.layer===2&&i.layer===1){const r=Y(Math.sign(n.mag),n.layer-1,Math.abs(n.mag)).add(Y(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return Y(n.sign*i.sign,r.layer+1,r.sign*r.mag)}if(n.layer===2&&i.layer===2){const r=Y(Math.sign(n.mag),n.layer-1,Math.abs(n.mag)).add(Y(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return Y(n.sign*i.sign,r.layer+1,r.sign*r.mag)}throw Error("Bad arguments to mul: "+this+", "+e)}multiply(e){return this.mul(e)}times(e){return this.mul(e)}div(e){const t=k(e);return this.mul(t.recip())}divide(e){return this.div(e)}divideBy(e){return this.div(e)}dividedBy(e){return this.div(e)}recip(){return this.mag===0?y.dNaN:this.layer===0?Y(this.sign,0,1/this.mag):Y(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}cmp(e){const t=k(e);return this.sign>t.sign?1:this.sign<t.sign?-1:this.sign*this.cmpabs(e)}cmpabs(e){const t=k(e),n=this.mag>0?this.layer:-this.layer,i=t.mag>0?t.layer:-t.layer;return n>i?1:n<i?-1:this.mag>t.mag?1:this.mag<t.mag?-1:0}compare(e){return this.cmp(e)}isNan(){return isNaN(this.sign)||isNaN(this.layer)||isNaN(this.mag)}isFinite(){return isFinite(this.sign)&&isFinite(this.layer)&&isFinite(this.mag)}eq(e){const t=k(e);return this.sign===t.sign&&this.layer===t.layer&&this.mag===t.mag}equals(e){return this.eq(e)}neq(e){return!this.eq(e)}notEquals(e){return this.neq(e)}lt(e){return this.cmp(e)===-1}lte(e){return!this.gt(e)}gt(e){return this.cmp(e)===1}gte(e){return!this.lt(e)}max(e){const t=k(e);return this.lt(t)?t:this}min(e){const t=k(e);return this.gt(t)?t:this}maxabs(e){const t=k(e);return this.cmpabs(t)<0?t:this}minabs(e){const t=k(e);return this.cmpabs(t)>0?t:this}clamp(e,t){return this.max(e).min(t)}clampMin(e){return this.max(e)}clampMax(e){return this.min(e)}cmp_tolerance(e,t){const n=k(e);return this.eq_tolerance(n,t)?0:this.cmp(n)}compare_tolerance(e,t){return this.cmp_tolerance(e,t)}eq_tolerance(e,t){const n=k(e);if(t==null&&(t=1e-7),this.sign!==n.sign||Math.abs(this.layer-n.layer)>1)return!1;let i=this.mag,r=n.mag;return this.layer>n.layer&&(r=Di(r)),this.layer<n.layer&&(i=Di(i)),Math.abs(i-r)<=t*Math.max(Math.abs(i),Math.abs(r))}equals_tolerance(e,t){return this.eq_tolerance(e,t)}neq_tolerance(e,t){return!this.eq_tolerance(e,t)}notEquals_tolerance(e,t){return this.neq_tolerance(e,t)}lt_tolerance(e,t){const n=k(e);return!this.eq_tolerance(n,t)&&this.lt(n)}lte_tolerance(e,t){const n=k(e);return this.eq_tolerance(n,t)||this.lt(n)}gt_tolerance(e,t){const n=k(e);return!this.eq_tolerance(n,t)&&this.gt(n)}gte_tolerance(e,t){const n=k(e);return this.eq_tolerance(n,t)||this.gt(n)}pLog10(){return this.lt(y.dZero)?y.dZero:this.log10()}absLog10(){return this.sign===0?y.dNaN:this.layer>0?Y(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):Y(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?y.dNaN:this.layer>0?Y(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):Y(this.sign,0,Math.log10(this.mag))}log(e){return e=k(e),this.sign<=0||e.sign<=0||e.sign===1&&e.layer===0&&e.mag===1?y.dNaN:this.layer===0&&e.layer===0?Y(this.sign,0,Math.log(this.mag)/Math.log(e.mag)):y.div(this.log10(),e.log10())}log2(){return this.sign<=0?y.dNaN:this.layer===0?Y(this.sign,0,Math.log2(this.mag)):this.layer===1?Y(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?Y(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):Y(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?y.dNaN:this.layer===0?Y(this.sign,0,Math.log(this.mag)):this.layer===1?Y(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?Y(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):Y(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(e){return this.log(e)}pow(e){const t=k(e),n=this,i=t;if(n.sign===0)return i.eq(0)?te(1,0,1):n;if(n.sign===1&&n.layer===0&&n.mag===1)return n;if(i.sign===0)return te(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return n;const r=n.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?r.neg():Math.abs(i.toNumber()%2)%2===0?r:y.dNaN:r}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return y.dNaN;let e=this;if(e.layer===0){const t=Math.pow(10,e.sign*e.mag);if(Number.isFinite(t)&&Math.abs(t)>=.1)return Y(1,0,t);if(e.sign===0)return y.dOne;e=te(e.sign,e.layer+1,Math.log10(e.mag))}return e.sign>0&&e.mag>=0?Y(e.sign,e.layer+1,e.mag):e.sign<0&&e.mag>=0?Y(-e.sign,e.layer+1,-e.mag):y.dOne}pow_base(e){return k(e).pow(this)}root(e){const t=k(e);return this.pow(t.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?y.exp(y.mul(this,y.ln(this).sub(1))):y.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(te(1,0,24)))return y.fromNumber(os(this.sign*this.mag));const e=this.mag-1;let t=.9189385332046727;t=t+(e+.5)*Math.log(e),t=t-e;const n=e*e;let i=e,r=12*i,a=1/r,l=t+a;if(l===t||(t=l,i=i*n,r=360*i,a=1/r,l=t-a,l===t))return y.exp(t);t=l,i=i*n,r=1260*i;let u=1/r;return t=t+u,i=i*n,r=1680*i,u=1/r,t=t-u,y.exp(t)}else return this.layer===1?y.exp(y.mul(this,y.ln(this).sub(1))):y.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?y.dOne:this.layer===0&&this.mag<=709.7?y.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?Y(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?Y(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):Y(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return y.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return Y(1,2,Math.log10(this.mag)-.3010299956639812);{const e=y.div(te(this.sign,this.layer-1,this.mag),te(1,0,2));return e.layer+=1,e.normalize(),e}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(e=2,t=te(1,0,1)){if(e===1)return y.pow(this,t);if(e===0)return new y(t);if(this.eq(y.dOne))return y.dOne;if(this.eq(-1))return y.pow(this,t);if(e===Number.POSITIVE_INFINITY){const r=this.toNumber();if(r<=1.444667861009766&&r>=.06598803584531254){if(r>1.444667861009099)return y.fromNumber(Math.E);const a=y.ln(this).neg();return a.lambertw().div(a)}else return r>1.444667861009766?y.fromNumber(Number.POSITIVE_INFINITY):y.dNaN}if(this.eq(y.dZero)){let r=Math.abs((e+1)%2);return r>1&&(r=2-r),y.fromNumber(r)}if(e<0)return y.iteratedlog(t,this,-e);t=k(t);const n=e;e=Math.trunc(e);const i=n-e;if(this.gt(y.dZero)&&this.lte(1.444667861009766)){e=Math.min(1e4,e);for(let r=0;r<e;++r){const a=t;if(t=this.pow(t),a.eq(t))return t}if(i!=0){const r=this.pow(t);return t.mul(1-i).add(r.mul(i))}return t}i!==0&&(t.eq(y.dOne)?this.gt(10)?t=this.pow(i):(t=y.fromNumber(y.tetrate_critical(this.toNumber(),i)),this.lt(2)&&(t=t.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?t=t.layeradd10(i):t=t.layeradd(i,this));for(let r=0;r<e;++r){if(t=this.pow(t),!isFinite(t.layer)||!isFinite(t.mag))return t.normalize();if(t.layer-this.layer>3)return te(t.sign,t.layer+(e-r-1),t.mag);if(r>1e4)return t}return t}iteratedexp(e=2,t=te(1,0,1)){return this.tetrate(e,t)}iteratedlog(e=10,t=1){if(t<0)return y.tetrate(e,-t,this);e=k(e);let n=y.fromDecimal(this);const i=t;t=Math.trunc(t);const r=i-t;if(n.layer-e.layer>3){const a=Math.min(t,n.layer-e.layer-3);t-=a,n.layer-=a}for(let a=0;a<t;++a){if(n=n.log(e),!isFinite(n.layer)||!isFinite(n.mag))return n.normalize();if(a>1e4)return n}return r>0&&r<1&&(e.eq(10)?n=n.layeradd10(-r):n=n.layeradd(-r,e)),n}slog(e=10,t=100){let n=.001,i=!1,r=!1,a=this.slog_internal(e).toNumber();for(let l=1;l<t;++l){const c=new y(e).tetrate(a).gt(this);if(l>1&&r!=c&&(i=!0),r=c,i?n/=2:n*=2,n=Math.abs(n)*(c?-1:1),a+=n,n===0)break}return y.fromNumber(a)}slog_internal(e=10){if(e=k(e),e.lte(y.dZero)||e.eq(y.dOne))return y.dNaN;if(e.lt(y.dOne))return this.eq(y.dOne)?y.dZero:this.eq(y.dZero)?y.dNegOne:y.dNaN;if(this.mag<0||this.eq(y.dZero))return y.dNegOne;let t=0,n=y.fromDecimal(this);if(n.layer-e.layer>3){const i=n.layer-e.layer-3;t+=i,n.layer-=i}for(let i=0;i<100;++i)if(n.lt(y.dZero))n=y.pow(e,n),t-=1;else{if(n.lte(y.dOne))return y.fromNumber(t+y.slog_critical(e.toNumber(),n.toNumber()));t+=1,n=y.log(n,e)}return y.fromNumber(t)}static slog_critical(e,t){return e>10?t-1:y.critical_section(e,t,ss)}static tetrate_critical(e,t){return y.critical_section(e,t,as)}static critical_section(e,t,n){t*=10,t<0&&(t=0),t>10&&(t=10),e<2&&(e=2),e>10&&(e=10);let i=0,r=0;for(let l=0;l<an.length;++l)if(an[l]==e){i=n[l][Math.floor(t)],r=n[l][Math.ceil(t)];break}else if(an[l]<e&&an[l+1]>e){const u=(e-an[l])/(an[l+1]-an[l]);i=n[l][Math.floor(t)]*(1-u)+n[l+1][Math.floor(t)]*u,r=n[l][Math.ceil(t)]*(1-u)+n[l+1][Math.ceil(t)]*u;break}const a=t-Math.floor(t);return i<=0||r<=0?i*(1-a)+r*a:Math.pow(e,Math.log(i)/Math.log(e)*(1-a)+Math.log(r)/Math.log(e)*a)}layeradd10(e){e=y.fromValue_noAlloc(e).toNumber();const t=y.fromDecimal(this);if(e>=1){t.mag<0&&t.layer>0?(t.sign=0,t.mag=0,t.layer=0):t.sign===-1&&t.layer==0&&(t.sign=1,t.mag=-t.mag);const n=Math.trunc(e);e-=n,t.layer+=n}if(e<=-1){const n=Math.trunc(e);if(e-=n,t.layer+=n,t.layer<0)for(let i=0;i<100;++i){if(t.layer++,t.mag=Math.log10(t.mag),!isFinite(t.mag))return t.sign===0&&(t.sign=1),t.layer<0&&(t.layer=0),t.normalize();if(t.layer>=0)break}}for(;t.layer<0;)t.layer++,t.mag=Math.log10(t.mag);return t.sign===0&&(t.sign=1,t.mag===0&&t.layer>=1&&(t.layer-=1,t.mag=1)),t.normalize(),e!==0?t.layeradd(e,10):t}layeradd(e,t){const i=this.slog(t).toNumber()+e;return i>=0?y.tetrate(t,i):Number.isFinite(i)?i>=-1?y.log(y.tetrate(t,i+1),t):y.log(y.log(y.tetrate(t,i+2),t),t):y.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return y.fromNumber(ur(this.toNumber()));if(this.layer===0)return y.fromNumber(ur(this.sign*this.mag));if(this.layer===1)return cr(this);if(this.layer===2)return cr(this);if(this.layer>=3)return te(this.sign,this.layer-1,this.mag);throw new Error("Unhandled behavior in lambertw()")}ssqrt(){if(this.sign==1&&this.layer>=3)return te(this.sign,this.layer-1,this.mag);const e=this.ln();return e.div(e.lambertw())}pentate(e=2,t=te(1,0,1)){t=k(t);const n=e;e=Math.trunc(e);const i=n-e;i!==0&&(t.eq(y.dOne)?(++e,t=y.fromNumber(i)):this.eq(10)?t=t.layeradd10(i):t=t.layeradd(i,this));for(let r=0;r<e;++r){if(t=this.tetrate(t.toNumber()),!isFinite(t.layer)||!isFinite(t.mag))return t.normalize();if(r>10)return t}return t}sin(){return this.mag<0?this:this.layer===0?y.fromNumber(Math.sin(this.sign*this.mag)):te(0,0,0)}cos(){return this.mag<0?y.dOne:this.layer===0?y.fromNumber(Math.cos(this.sign*this.mag)):te(0,0,0)}tan(){return this.mag<0?this:this.layer===0?y.fromNumber(Math.tan(this.sign*this.mag)):te(0,0,0)}asin(){return this.mag<0?this:this.layer===0?y.fromNumber(Math.asin(this.sign*this.mag)):te(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?y.fromNumber(Math.acos(this.toNumber())):this.layer===0?y.fromNumber(Math.acos(this.sign*this.mag)):te(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?y.fromNumber(Math.atan(this.sign*this.mag)):y.fromNumber(Math.atan(this.sign*(1/0)))}sinh(){return this.exp().sub(this.negate().exp()).div(2)}cosh(){return this.exp().add(this.negate().exp()).div(2)}tanh(){return this.sinh().div(this.cosh())}asinh(){return y.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return y.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?te(Number.NaN,Number.NaN,Number.NaN):y.ln(this.add(1).div(y.fromNumber(1).sub(this))).div(2)}ascensionPenalty(e){return e===0?this:this.root(y.pow(10,e))}egg(){return this.add(9)}lessThanOrEqualTo(e){return this.cmp(e)<1}lessThan(e){return this.cmp(e)<0}greaterThanOrEqualTo(e){return this.cmp(e)>-1}greaterThan(e){return this.cmp(e)>0}};let o=y;o.fromStringCache=new Xa(is);o.dZero=te(0,0,0);o.dOne=te(1,0,1);o.dNegOne=te(-1,0,1);o.dTwo=te(1,0,2);o.dTen=te(1,0,10);o.dNaN=te(Number.NaN,Number.NaN,Number.NaN);o.dInf=te(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);o.dNegInf=te(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);o.dNumberMax=Y(1,0,Number.MAX_VALUE);o.dNumberMin=Y(1,0,Number.MIN_VALUE);k=o.fromValue_noAlloc;Y=o.fromComponents;te=o.fromComponents_noNormalize;o.fromMantissaExponent;o.fromMantissaExponent_noNormalize;const ls=new o(1);function qn(e,t,n=!0){let i=o.log10(e).floor(),r=o.div(e,o.pow(10,i));r.toStringWithDecimalPlaces(t)==="10"&&(r=ls,i=i.add(1));const a=i.gte(1e9)?vt(i,Math.max(Math.max(t,3),pe.defaultDecimalsShown)):i.gte(1e4)?si(i,0):i.toStringWithDecimalPlaces(0);return n?r.toStringWithDecimalPlaces(t)+"e"+a:"e"+a}function si(e,t){if(e==null)return"NaN";if(e=new o(e),e.mag<.001)return 0 .toFixed(t);const i=e.toStringWithDecimalPlaces(t).split(".");return i[0]=i[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1,"),i.length==1?i[0]:i[0]+"."+i[1]}function kr(e,t){return e==null?"NaN":(e=new o(e),e.mag<1e-4?0 .toFixed(t):(e.mag<.1&&t!==0&&(t=Math.max(Math.max(t,e.log10().negate().ceil().toNumber()),pe.defaultDecimalsShown)),e.toStringWithDecimalPlaces(t)))}const us=new o("eeee1000"),cs=new o("e100000"),dr=new o("e1000"),Mr=new o(1e9),ds=new o(1e6),ps=new o(1e3),fs=new o(.98),gs=new o(.001),Sr=new o(0);function vt(e,t,n){if(t==null&&(t=pe.defaultDecimalsShown),n=n!=null?n:pe.defaultShowSmall,e=new o(e),isNaN(e.sign)||isNaN(e.layer)||isNaN(e.mag))return"NaN";if(e.sign<0)return"-"+vt(e.neg(),t);if(e.mag===Number.POSITIVE_INFINITY)return"Infinity";if(e.gte(us)){const i=e.slog();return i.gte(ds)?"F"+vt(i.floor()):o.pow(10,i.sub(i.floor())).toStringWithDecimalPlaces(3)+"F"+si(i.floor(),0)}else{if(e.gte(cs))return qn(e,0,!1);if(e.gte(dr))return qn(e,0);if(e.gte(Mr))return qn(e,t);if(e.gte(ps))return si(e,0);if(e.gte(gs)||!n)return kr(e,t);if(e.eq(Sr))return 0 .toFixed(t)}return e=xr(e),e.lt(dr)?qn(e,t).replace(/([^(?:e|F)]*)$/,"-$1"):vt(e,t)+"\u207B\xB9"}function Je(e){return e=new o(e),e.sign<0?"-"+Je(e.neg()):e.gte(Mr)||e.lte(fs)&&!e.eq(Sr)?vt(e):vt(e,0)}function Ir(e){return o.lt(e,0)?"-"+Ir(o.neg(e)):o.gt(e,2**51)?vt(o.div(e,31536e3))+"y":(e=new o(e).toNumber(),e<60?vt(e)+"s":e<3600?Je(Math.floor(e/60))+"m "+vt(e%60)+"s":e<86400?Je(Math.floor(e/3600))+"h "+Je(Math.floor(e/60)%60)+"m "+Je(e%60)+"s":e<31536e3?Je(Math.floor(e/84600)%365)+"d "+Je(Math.floor(e/3600)%24)+"h "+Je(Math.floor(e/60)%60)+"m":Je(Math.floor(e/31536e3))+"y "+Je(Math.floor(e/84600)%365)+"d "+Je(Math.floor(e/3600)%24)+"h")}function ms(e,t,n){e=new o(e);let i=e.toStringWithDecimalPlaces(t);return new o(i).gte(n)&&(i=o.sub(n,Math.pow(.1,t)).toStringWithDecimalPlaces(t)),i}function vs(e,t){return vt(e,t,!0)}function xr(e){let t=o.log10(e).ceil();const n=o.div(e,o.pow(10,t));return t=t.neg(),e=new o(10).pow(t).times(n),e}var hs=Object.freeze(Object.defineProperty({__proto__:null,default:o,exponentialFormat:qn,commaFormat:si,regularFormat:kr,format:vt,formatWhole:Je,formatTime:Ir,toPlaces:ms,formatSmall:vs,invertOOM:xr},Symbol.toStringTag,{value:"Module"}));const{exponentialFormat:bs,commaFormat:ys,regularFormat:ws,format:he,formatWhole:ht,formatTime:gi,toPlaces:_s,formatSmall:Jt,invertOOM:Ns}=hs;window.Decimal=o;window.exponentialFormat=bs;window.commaFormat=ys;window.regularFormat=ws;window.format=he;window.formatWhole=ht;window.formatTime=gi;window.toPlaces=_s;window.formatSmall=Jt;window.invertOOM=Ns;function tt(e){let t=e.replace(/([A-Z])/g," $1");return t=t.charAt(0).toUpperCase()+t.slice(1),t}function Un(e){return typeof e=="function"}var U=(e=>(e.Up="Up",e.Down="Down",e.Left="Left",e.Right="Right",e.Default="Up",e))(U||{});const Gn=Symbol("DoNotCache");function x(e,t){const n=e[t];Un(n)&&n.length===0&&!n[Gn]?e[t]=C(n.bind(e)):Un(n)&&(e[t]=n.bind(e),e[t][Gn]=!0)}function fe(e){return Un(e)&&!e[Gn]&&(e=C(e)),e}const bt=Symbol("Component"),lt=Symbol("GatherProps");let Cs=0;function tn(e="feature-"){return e+Cs++}var ye=(e=>(e[e.Visible=0]="Visible",e[e.Hidden=1]="Hidden",e[e.None=2]="None",e))(ye||{});function Le(e){const t=s(e);return t!==2&&t!==!1}function bn(e){return s(e)===1}function K(e){return e[Gn]=!0,e}function ie(e,t,n){e[t]===void 0&&n!=null&&(e[t]=n)}function Wn(e,...t){const n=[],i=r=>{Object.keys(r).forEach(a=>{const l=r[a];l!=null&&typeof l=="object"&&(t.includes(l.type)?n.push(l):!(l instanceof o)&&!Ae(l)&&i(l))})};return i(e),n}const sn={variables:{"--foreground":"#dfdfdf","--background":"#0f0f0f","--feature-foreground":"#0f0f0f","--tooltip-background":"rgba(0, 0, 0, 0.75)","--raised-background":"#0f0f0f","--points":"#ffffff","--locked":"#bf8f8f","--highlighted":"#333","--bought":"#77bf5f","--danger":"rgb(220, 53, 69)","--link":"#02f2f2","--outline":"#dfdfdf","--accent1":"#627a82","--accent2":"#658262","--accent3":"#7c6282","--border-radius":"15px","--modal-border":"solid 2px var(--color)","--feature-margin":"0px"},floatingTabs:!0,mergeAdjacent:!0,showPin:!0};var ji=(e=>(e.Classic="classic",e.Paper="paper",e.Nordic="nordic",e.Aqua="aqua",e))(ji||{}),Ct={classic:sn,paper:{...sn,variables:{...sn.variables,"--background":"#2a323d","--feature-foreground":"#000","--raised-background":"#333c4a","--locked":"#3a3e45","--bought":"#5C8A58","--outline":"#333c4a","--border-radius":"4px","--modal-border":"","--feature-margin":"5px"},floatingTabs:!1},nordic:{...sn,variables:{...sn.variables,"--foreground":"#D8DEE9","--background":"#2E3440","--feature-foreground":"#000","--raised-background":"#3B4252","--points":"#E5E9F0","--locked":"#4c566a","--highlighted":"#434c5e","--bought":"#8FBCBB","--danger":"#D08770","--link":"#88C0D0","--outline":"#3B4252","--accent1":"#B48EAD","--accent2":"#A3BE8C","--accent3":"#EBCB8B","--border-radius":"4px","--modal-border":"solid 2px #3B4252","--feature-margin":"5px"},floatingTabs:!1},aqua:{...sn,variables:{...sn.variables,"--foreground":"#bfdfff","--background":"#001f3f","--tooltip-background":"rgba(0, 15, 31, 0.75)","--raised-background":"#001f3f","--points":"#dfefff","--locked":"#c4a7b3","--outline":"#bfdfff"}}};const Ze=Nr();"fonts"in document&&(document.fonts.onloadingdone=()=>Ze.emit("fontsLoaded"));var ks=Object.freeze(Object.defineProperty({__proto__:null,globalBus:Ze},Symbol.toStringTag,{value:"Module"}));const Ms=gn({id:"",devSpeed:null,name:"",tabs:[],time:-1,autosave:!0,offlineProd:!0,offlineTime:null,timePlayed:0,keepGoing:!1,modID:"",modVersion:"",layers:{}});var Q=window.player=Ms;function $r(e){return JSON.stringify(e,(t,n)=>s(n))}function Er(e={}){return Object.assign({id:`${pe.id}-0`,name:"Default Save",tabs:pe.initialTabs.slice(),time:Date.now(),autosave:!0,offlineProd:!0,offlineTime:0,timePlayed:0,keepGoing:!1,modID:pe.id,modVersion:pe.versionNumber,layers:{}},e)}function pt(e){const t=Xt.compressToUTF16($r(e!=null?e:Q));return localStorage.setItem((e!=null?e:Q).id,t),t}async function Ss(){$s();try{let e=localStorage.getItem(ae.active);if(e==null){await cn($n());return}if(e[0]!=="{")if(e[0]==="e")e=decodeURIComponent(escape(atob(e)));else if(e[0]==="\u1BE1")e=Xt.decompressFromUTF16(e);else throw"Unable to determine save encoding";const t=JSON.parse(e);if(t.modID!==pe.id){await cn($n());return}t.id=ae.active,await cn(t)}catch(e){console.error(`Failed to load save. Falling back to new save.
`,e),await cn($n())}}function $n(){const e=ri(),t=Er({id:e});return pt(t),ae.saves.push(e),t}function ri(){let e,t=0;do e=`${pe.id}-${t++}`;while(localStorage.getItem(e)!=null);return e}const Is=L(!1);async function cn(e){console.info("Loading save",e),Is.value=!0;const{layers:t,removeLayer:n,addLayer:i}=await zn(()=>Promise.resolve().then(function(){return Js}),void 0),{fixOldSave:r,getInitialLayers:a}=await zn(()=>Promise.resolve().then(function(){return _p}),void 0);for(const l in t){const u=t[l];u&&n(u)}a(e).forEach(l=>i(l,e)),e=Er(e),e.offlineProd&&e.time!=null&&e.time&&e.devSpeed!==0&&(e.offlineTime==null&&(e.offlineTime=0),e.offlineTime+=Math.min(e.offlineTime+(Date.now()-e.time)/1e3,pe.offlineLimit*3600)),e.time=Date.now(),e.modVersion!==pe.versionNumber&&(r(e.modVersion,e),e.modVersion=pe.versionNumber),Object.assign(Q,e),ae.active=Q.id,Ze.emit("onLoad")}setInterval(()=>{Q.autosave&&pt()},1e3);window.onbeforeunload=()=>{Q.autosave&&pt()};window.save=pt;const xs=window.hardReset=async()=>{await cn($n())};window.deleteLowerSaves=()=>{const e=Object.values(ae.saves).indexOf(Q.id)+1;Object.values(ae.saves).slice(e).forEach(t=>localStorage.removeItem(t)),ae.saves=ae.saves.slice(0,e)};const Hn=gn({active:"",saves:[],showTPS:!0,theme:ji.Nordic,unthrottled:!1,alignUnits:!1});gt(Hn,e=>{const t=Xt.compressToUTF16(JSON.stringify(e));localStorage.setItem(pe.id,t)},{deep:!0});var ae=window.settings=Hn;window.hardResetSettings=()=>{const e={active:"",saves:[],showTPS:!0,theme:ji.Nordic,alignUnits:!1};Ze.emit("loadSettings",e),Object.assign(Hn,e),xs()};function $s(){try{let e=localStorage.getItem(pe.id);if(e!=null&&e!==""){if(e[0]!=="{")if(e[0]==="e")e=decodeURIComponent(escape(atob(e)));else if(e[0]==="\u1BE1")e=Xt.decompressFromUTF16(e);else{console.warn("Unable to determine settings encoding",e);return}const t=JSON.parse(e);typeof t=="object"&&Object.assign(Hn,t)}Ze.emit("loadSettings",Hn)}catch{}}const Dr=gn([]);function Es(e){Dr.push(e)}const Ds=gn([]),Ps=gn([]),Ts={class:"table"},As=X({__name:"Column",setup(e){const t=C(()=>Ct[ae.theme].mergeAdjacent);return(n,i)=>(M(),P("div",Ts,[N("div",{class:ge(["col",{mergeAdjacent:s(t)}])},[Tt(n.$slots,"default")],2)]))}}),Fs={class:"table"},Os=X({__name:"Row",setup(e){const t=C(()=>Ct[ae.theme].mergeAdjacent);return(n,i)=>(M(),P("div",Fs,[N("div",{class:ge(["row",{mergeAdjacent:s(t)}])},[Tt(n.$slots,"default")],2)]))}});function Pr(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!fa(e)}function oe(e,t="span"){return typeof e=="function"?X({render:e}):typeof e=="string"?e.length>0?(e=e.trim(),e.charAt(0)!=="<"&&(e=`<${t}>${e}</${t}>`),X({template:e})):X({render:()=>({})}):e}function nt(e){if(xt(e))return typeof e=="function"?e():oe(e);const t=e[bt];return f(t,e[lt](),null)}function Pi(...e){let t;return f(Os,null,Pr(t=e.map(nt))?t:{default:()=>[t]})}function Rs(...e){let t;return f(As,null,Pr(t=e.map(nt))?t:{default:()=>[t]})}function Mt(e){if(xt(e))return typeof e=="function"?e():typeof e=="string"?f(ne,null,[e]):f(e,null,null);const t=e[bt];return f(t,e[lt](),null)}function pr(e,t){return e.reduce((n,i)=>f(ne,null,[n,t,i]))}function xt(e){return typeof e=="string"?!0:typeof e=="object"?e==null?!1:"render"in e||"component"in e:typeof e=="function"&&e[Gn]===!0}function Tr(e,t){const n=L(null),i=L(void 0);function r(u){n.value||(n.value=setInterval(l,250)),i.value=u}function a(){n.value&&(clearInterval(n.value),n.value=null)}function l(){t&&t.value?t.value():e&&e.value&&e.value(i.value)}return _r(a),{start:r,stop:a,handleHolding:l}}function Ar(e,t="div"){const n=mt();return kt(()=>{n.value=oe(Se(e),t)}),n}function Tn(e,t="div"){const n=mt(null);return kt(()=>{const i=Se(e);n.value=i==""||i==null?null:oe(i,t)}),n}function Se(e){return s(s(e))}function R(...e){return e.includes(Object)||e.push(Object),e}function fr(e){const t=L(!1),n=e[lt].bind(e);return e[lt]=()=>({...n(),onPointerenter:()=>t.value=!0,onPointerleave:()=>t.value=!1}),t}var ue=(e,t)=>{const n=e.__vccOpts||e;for(const[i,r]of t)n[i]=r;return n};const qs=X({__name:"Context",emits:["updateNodes"],setup(e,{emit:t}){var m;const n=L({}),i=new ResizeObserver(u),r=L(null);pi(()=>{const p=r.value;p!=null&&i.observe(p)});let a=!0,l=L((m=r.value)==null?void 0:m.getBoundingClientRect());function u(){a&&(a=!1,jt(()=>{var p;l.value=(p=r.value)==null?void 0:p.getBoundingClientRect(),Object.values(n.value).filter(h=>h).forEach(h=>h.rect=h.element.getBoundingClientRect()),t("updateNodes",n.value),a=!0}))}Ze.on("fontsLoaded",u);const c={attributes:!1,childList:!0,subtree:!1};ti(zi,(p,h)=>{const w=new MutationObserver(()=>d(p));w.observe(h,c),n.value[p]={element:h,observer:w,rect:h.getBoundingClientRect()},u()}),ti(Ui,p=>{var h;(h=n.value[p])==null||h.observer.disconnect(),n.value[p]=void 0,u()}),ti(Gi,n),ti(Wi,l);function d(p){const h=n.value[p];h!=null&&(h.rect=h.element.getBoundingClientRect(),t("updateNodes",n.value))}return(p,h)=>(M(),P(ne,null,[Tt(p.$slots,"default",{},void 0,!0),N("div",{ref_key:"resizeListener",ref:r,class:"resize-listener"},null,512)],64))}});var Fr=ue(qs,[["__scopeId","data-v-2b1dc1bc"]]);const Vs=["onPointerdown"],Bs={class:"modal-wrapper"},Ls={class:"modal-container"},js={class:"modal-header"},zs={class:"modal-body"},Us={class:"modal-footer"},Gs=N("div",{class:"modal-default-flex-grow"},null,-1),Ut=X({__name:"Modal",props:{modelValue:{type:Boolean}},emits:["update:modelValue"],setup(e,{expose:t,emit:n}){const r=Ee(e),a=C(()=>s(r.modelValue)||u.value);function l(){n("update:modelValue",!1)}const u=L(!1),c=L(null),d=C(()=>{var m,p;return(p=(m=c.value)==null?void 0:m.nodes)!=null?p:null});return t({isOpen:a,nodes:d}),(m,p)=>(M(),ee(ma,{to:"#modal-root"},[f(Dn,{name:"modal",onBeforeEnter:p[0]||(p[0]=h=>u.value=!0),onAfterLeave:p[1]||(p[1]=h=>u.value=!1)},{default:W(()=>[Bi(N("div",zt({class:"modal-mask",onPointerdown:En(l,["self"])},m.$attrs),[N("div",Bs,[N("div",Ls,[N("div",js,[Tt(m.$slots,"header",{shown:s(a)},()=>[E(" default header ")])]),N("div",zs,[f(Fr,{ref_key:"contextRef",ref:c},{default:W(()=>[Tt(m.$slots,"body",{shown:s(a)},()=>[E(" default body ")])]),_:3},512)]),N("div",Us,[Tt(m.$slots,"footer",{shown:s(a)},()=>[N("div",{class:"modal-default-footer"},[Gs,N("button",{class:"button modal-default-button",onClick:l}," Close ")])])])])])],16,Vs),[[ga,e.modelValue]])]),_:3})]))}}),Yt=Symbol("ProxyState");function Ye(e,t={}){const n=t;let i=!1;function r(){return i||(Object.assign(n,e.call(n,n)),i=!0),n}return new Proxy(n,{get(a,l){if(l===Yt)return r();const u=r()[l];return u!=null&&typeof u=="object"&&Pt in u?u[Pt]:u},set(a,l,u){return r()[l]=u,!0},has(a,l){return l===Yt?!0:Reflect.has(r(),l)},ownKeys(){return Reflect.ownKeys(r())},getOwnPropertyDescriptor(a,l){return i||(Object.assign(n,e.call(n,n)),i=!0),Object.getOwnPropertyDescriptor(a,l)}})}var Be=window.state=Li({lastTenTicks:[],hasNaN:!1,NaNPath:[]});const Kt=Symbol("PersistentState"),en=Symbol("DefaultValue"),oi=Symbol("StackTrace"),li=Symbol("Deleted"),Pt=Symbol("NonPersistent"),dn=Symbol("SaveDataPath"),Vi=Symbol("SkipPersistence");function Ws(){var e,t;return(t=(e=new Error().stack)==null?void 0:e.split(`
`).slice(3,5).map(n=>n.trim()).join(`
`))!=null?t:""}function gr(e,t){var n;if(o.isNaN(t))throw Be.hasNaN||(Q.autosave=!1,Be.hasNaN=!0,Be.NaNPath=e[dn],Be.NaNPersistent=e),console.error("Attempted to save NaN value to",(n=e[dn])==null?void 0:n.join("."),e),new Error("Attempted to set NaN value. See above for details");e[Kt].value=t}function ft(e,t=!0){const n=Ae(e)?e:L(e);Ae(e)&&(e=e.value);const i=C({get(){return n.value},set(a){t?gr(r,a):r[Kt].value=a}});i[en]=e;const r={get value(){return n.value},set value(a){t?gr(r,a):r[Kt].value=a},__v_isRef:!0,[Kt]:n,[en]:e,[oi]:Ws(),[li]:!1,[Pt]:i,[dn]:void 0};return ot.length===0?console.warn("Creating a persistent ref outside of a layer. This is not officially supported",r,`
Created at:
`+r[oi]):fn[ot[ot.length-1]].add(r),r}function Hs(e){return e!=null&&typeof e=="object"&&Kt in e}function Mn(e){return!(Yt in e)&&Pt in e?e[Pt]:new Proxy(e,{get(t,n){if(n!==Kt)return n===Vi?!0:t[n]},set(t,n,i){return t[n]=i,!0},has(t,n){return n===Kt?!1:n==Vi?!0:Reflect.has(t,n)}})}function Or(e){ot.length===0?console.warn("Deleting a persistent ref outside of a layer. Ignoring...",e):fn[ot[ot.length-1]].delete(e),e[li]=!0}Ze.on("addLayer",(e,t)=>{const n=[],i=(r,a=[])=>{let l=!1;return Object.keys(r).forEach(u=>{let c=r[u];if(c!=null&&typeof c=="object"){if(c[Vi]===!0)return;if(Yt in c&&(c=c[Yt]),Hs(c)){if(l=!0,c[li]){console.warn("Deleted persistent ref present in returned object. Ignoring...",c,`
Created at:
`+c[oi]);return}fn[e.id].delete(c);const d=[e.id,...a,u];c[dn]!=null&&JSON.stringify(d)!==JSON.stringify(c[dn])&&console.error(`Persistent ref is being saved to \`${d.join(".")}\` when it's already present at \`${c[dn].join(".")}\`. This can cause unexpected behavior when loading saves between updates.`,c),c[dn]=d;const m=a.reduce((h,w)=>(w in h||(h[w]={}),h[w]),t),p=m[u];m[u]=c[Kt],va(m)?p!=null?m[u]=p:m[u]=c[en]:p!=null?m[u].value=p:m[u].value=c[en]}else!(c instanceof o)&&!Ae(c)&&!n.includes(c)&&(typeof c.type=="symbol"&&n.push(c),i(c,[...a,u])&&(At(c)&&!At(r)?console.warn("Found array that contains persistent values when adding layer. Keep in mind changing the order of elements in the array will mess with existing player saves.",Yt in r?r[Yt]:r,u):l=!0))}}),l};i(e[Yt]),fn[e.id].forEach(r=>{r[li]||console.error(`Created persistent ref in ${e.id} without registering it to the layer! Make sure to include everything persistent in the returned object`,r,`
Created at:
`+r[oi])}),fn[e.id].clear()});const zi=Symbol("RegisterNode"),Ui=Symbol("UnregisterNode"),Gi=Symbol("Nodes"),Wi=Symbol("Bounds"),be=Li({});window.layers=be;const fn={},ot=[];function Hi(e,t){return Ye(()=>{const n={},i=n.emitter=Nr();if(n.on=i.on.bind(i),n.emit=i.emit.bind(i),n.nodes=L({}),n.id=e,ot.push(e),fn[e]=new Set,n.minimized=ft(!1,!1),Object.assign(n,t.call(n,n)),ot[ot.length-1]==null||ot[ot.length-1]!==e)throw`Adding layers stack in invalid state. This should not happen
Stack: ${ot}
Trying to pop ${n.id}`;ot.pop(),x(n,"color"),x(n,"display"),x(n,"classes"),x(n,"style"),x(n,"name"),ie(n,"name",n.id),x(n,"minWidth"),ie(n,"minWidth",600),x(n,"minimizable"),ie(n,"minimizable",!0),x(n,"minimizedDisplay");const r=n.style;return n.style=C(()=>{var l,u;let a=s(n.minWidth);return(typeof a=="number"||!Number.isNaN(parseInt(a)))&&(a=a+"px"),[(l=s(r))!=null?l:"",(u=n.minimized)!=null&&u.value?{flexGrow:"0",flexShrink:"0",width:"60px",minWidth:"",flexBasis:"",margin:"0"}:{flexGrow:"",flexShrink:"",width:"",minWidth:a,flexBasis:a,margin:""}]}),n})}function Zi(e,t){if(console.info("Adding layer",e.id),be[e.id]){console.error("Attempted to add layer with same ID as existing layer",e.id,be[e.id]);return}ie(t,"layers",{}),t.layers[e.id]==null&&(t.layers[e.id]={}),be[e.id]=e,Ze.emit("addLayer",e,t.layers[e.id])}function Zs(e){return be[e]}function Rr(e){console.info("Removing layer",e.id),Ze.emit("removeLayer",e),be[e.id]=void 0}function Ys(e){Rr(e),Zi(e,Q)}function Xs(e){const t=L(!1);return{openModal:()=>t.value=!0,modal:K(()=>f(Ut,{modelValue:t.value,"onUpdate:modelValue":n=>t.value=n},{header:()=>f("h2",null,[s(e.name)]),body:s(e.display)}))}}Ze.on("update",function(t){Object.values(be).forEach(n=>{n==null||n.emit("preUpdate",t)}),Object.values(be).forEach(n=>{n==null||n.emit("update",t)}),Object.values(be).forEach(n=>{n==null||n.emit("postUpdate",t)})});var Js=Object.freeze(Object.defineProperty({__proto__:null,RegisterNodeInjectionKey:zi,UnregisterNodeInjectionKey:Ui,NodesInjectionKey:Gi,BoundsInjectionKey:Wi,layers:be,persistentRefs:fn,addingLayers:ot,createLayer:Hi,addLayer:Zi,getLayer:Zs,removeLayer:Rr,reloadLayer:Ys,setupLayerModal:Xs},Symbol.toStringTag,{value:"Module"}));const Ks=X({components:{Context:Fr},props:{index:{type:Number,required:!0},display:{type:R(Object,String,Function),required:!0},minimizedDisplay:R(Object,String,Function),minimized:{type:Object,required:!0},name:{type:R(String),required:!0},color:R(String),minimizable:R(Boolean),nodes:{type:Object,required:!0}},emits:["setMinimized"],setup(e){const{display:t,index:n,minimized:i,minimizedDisplay:r}=Ee(e),a=Ar(t),l=Tn(r),u=C(()=>pe.allowGoBack&&n.value>0&&!Se(i));function c(){Q.tabs.splice(s(e.index),1/0)}function d(m){e.nodes.value=m}return{component:a,minimizedComponent:l,showGoBack:u,updateNodes:d,unref:s,goBack:c}}}),Qs={key:1};function eo(e,t,n,i,r,a){const l=St("Context");return M(),P("div",{class:"layer-container",style:qe({"--layer-color":e.unref(e.color)})},[e.showGoBack?(M(),P("button",{key:0,class:"goBack",onClick:t[0]||(t[0]=(...u)=>e.goBack&&e.goBack(...u))},"\u274C")):j("",!0),e.unref(e.minimized)?(M(),P("button",{key:1,class:"layer-tab minimized",onClick:t[1]||(t[1]=u=>e.$emit("setMinimized",!1))},[e.minimizedComponent?(M(),ee(He(e.minimizedComponent),{key:0})):(M(),P("div",Qs,se(e.unref(e.name)),1))])):(M(),P("div",{key:2,class:ge(["layer-tab",{showGoBack:e.showGoBack}])},[f(l,{onUpdateNodes:e.updateNodes},{default:W(()=>[(M(),ee(He(e.component)))]),_:1},8,["onUpdateNodes"])],2)),e.unref(e.minimizable)?(M(),P("button",{key:3,class:"minimize",onClick:t[2]||(t[2]=u=>e.$emit("setMinimized",!0))}," \u25BC ")):j("",!0)],4)}var to=ue(Ks,[["render",eo],["__scopeId","data-v-72dd78b1"]]);const qr=e=>(vn("data-v-4b4bda40"),e=e(),hn(),e),no=qr(()=>N("h2",null,"Changelog",-1)),io=qr(()=>N("details",{open:""},[N("summary",null,[E("v0.0 Initial Commit - "),N("time",null,"2021-09-04")]),E(" This is the first release :D "),N("ul",null,[N("li",{class:"feature"},"Did everything"),N("li",{class:"fix"},"Had some fun"),N("li",{class:"breaking"},"Removed everything"),N("li",{class:"balancing"},"Created some bugs to fix later")])],-1)),ro=X({__name:"Changelog",setup(e,{expose:t}){const n=L(!1);return t({open(){n.value=!0}}),(i,r)=>(M(),ee(Ut,{modelValue:n.value,"onUpdate:modelValue":r[0]||(r[0]=a=>n.value=a)},{header:W(()=>[no]),body:W(()=>[io]),_:1},8,["modelValue"]))}});var ao=ue(ro,[["__scopeId","data-v-4b4bda40"]]),so=X({props:{element:Object,display:{type:R(Object,String,Function),required:!0},style:R(Object,String,Array),classes:R(Object),direction:R(String),xoffset:R(String),yoffset:R(String),pinned:Object},setup(e){const{element:t,display:n,pinned:i}=Ee(e),r=L(!1),a=C(()=>(Se(i)||r.value)&&l.value),l=Tn(n),u=mt(oe(K(()=>{const m=Se(t);return m==null?"":Mt(m)})));function c(m){const p=i;m.shiftKey&&p&&(p.value=!p.value,m.stopPropagation(),m.preventDefault())}const d=C(()=>Se(i)&&Ct[ae.theme].showPin);return{Direction:U,isHovered:r,isShown:a,comp:l,elementComp:u,unref:s,togglePinned:c,showPin:d}}});const oo={key:0,class:"material-icons pinned"};function lo(e,t,n,i,r,a){return M(),P("div",{class:ge(["tooltip-container",{shown:e.isShown}]),onMouseenter:t[0]||(t[0]=l=>e.isHovered=!0),onMouseleave:t[1]||(t[1]=l=>e.isHovered=!1),onClickCapture:t[2]||(t[2]=(...l)=>e.togglePinned&&e.togglePinned(...l))},[Tt(e.$slots,"default",{},void 0,!0),e.elementComp?(M(),ee(He(e.elementComp),{key:0})):j("",!0),f(Dn,{name:"fade"},{default:W(()=>{var l;return[e.isShown?(M(),P("div",{key:0,class:ge(["tooltip",{top:e.unref(e.direction)===e.Direction.Up,left:e.unref(e.direction)===e.Direction.Left,right:e.unref(e.direction)===e.Direction.Right,bottom:e.unref(e.direction)===e.Direction.Down,...e.unref(e.classes)}]),style:qe([{"--xoffset":e.unref(e.xoffset)||"0px","--yoffset":e.unref(e.yoffset)||"0px"},(l=e.unref(e.style))!=null?l:{}])},[e.showPin?(M(),P("span",oo,"push_pin")):j("",!0),e.comp?(M(),ee(He(e.comp),{key:1})):j("",!0)],6)):j("",!0)]}),_:1})],34)}var Pe=ue(so,[["render",lo],["__scopeId","data-v-6102fa3a"]]);const yn=e=>(vn("data-v-4f97aa40"),e=e(),hn(),e),uo={class:"info-modal-header"},co=["src","alt"],po={class:"info-modal-title"},fo={key:0},go={key:0},mo={key:0},vo=yn(()=>N("div",null," Made in Profectus, by thepaperpilot with inspiration from Acameada and Jacorb ",-1)),ho=yn(()=>N("br",null,null,-1)),bo=yn(()=>N("br",null,null,-1)),yo=["href"],wo=yn(()=>N("span",{class:"material-icons info-modal-discord"},"discord",-1)),_o=yn(()=>N("div",null,[N("a",{href:"https://discord.gg/yJ4fjnjU54",class:"info-modal-discord-link",target:"_blank"},[N("span",{class:"material-icons info-modal-discord"},"discord"),E(" The Paper Pilot Community ")])],-1)),No=yn(()=>N("div",null,[N("a",{href:"https://discord.gg/F3xveHV",class:"info-modal-discord-link",target:"_blank"},[N("span",{class:"material-icons info-modal-discord"},"discord"),E(" The Modding Tree ")])],-1)),Co=yn(()=>N("br",null,null,-1));var ko=X({__name:"Info",props:{changelog:null},setup(e,{expose:t}){const n=e,{title:i,logo:r,author:a,discordName:l,discordLink:u,versionNumber:c,versionTitle:d}=pe,m=Ee(n),p=L(!1),h=C(()=>gi(Q.timePlayed)),w=C(()=>oe(K(()=>f(ne,null,[Ds.map(nt)]))));t({open(){p.value=!0}});function b(){var v;(v=s(m.changelog))==null||v.open()}return(v,I)=>(M(),ee(Ut,{modelValue:p.value,"onUpdate:modelValue":I[0]||(I[0]=F=>p.value=F)},{header:W(()=>[N("div",uo,[s(r)?(M(),P("img",{key:0,class:"info-modal-logo",src:s(r),alt:s(i)},null,8,co)):j("",!0),N("div",po,[N("h2",null,se(s(i)),1),N("h4",null,[E(" v"+se(s(c)),1),s(d)?(M(),P("span",fo,": "+se(s(d)),1)):j("",!0)])])])]),body:W(({shown:F})=>[F?(M(),P("div",go,[s(a)?(M(),P("div",mo,"By "+se(s(a)),1)):j("",!0),vo,ho,N("div",{class:"link",onClick:b},"Changelog"),bo,N("div",null,[s(u)?(M(),P("a",{key:0,href:s(u),class:"info-modal-discord-link",target:"_blank"},[wo,E(" "+se(s(l)),1)],8,yo)):j("",!0)]),_o,No,Co,N("div",null,"Time Played: "+se(s(h)),1),(M(),ee(He(s(w))))])):j("",!0)]),_:1},8,["modelValue"]))}});var Mo=ue(ko,[["__scopeId","data-v-4f97aa40"]]);const So={class:"field"},Io={key:0,class:"field-title"},Yi=X({__name:"Select",props:{title:null,modelValue:null,options:null,placeholder:null,closeOnSelect:{type:Boolean}},emits:["update:modelValue"],setup(e,{emit:t}){var l;const n=e,i=Tn(Qt(n,"title"),"span"),r=L((l=n.options.find(u=>u.value===n.modelValue))!=null?l:null);gt(Qt(n,"modelValue"),u=>{var c;Se(r)!==u&&(r.value=(c=n.options.find(d=>d.value===u))!=null?c:null)});function a(u){t("update:modelValue",u.value)}return(u,c)=>(M(),P("div",So,[s(i)?(M(),P("span",Io,[(M(),ee(He(s(i))))])):j("",!0),f(s(Na),{options:e.options,modelValue:r.value,"onUpdate:modelValue":[c[0]||(c[0]=d=>r.value=d),a],min:1,"label-by":"label",placeholder:e.placeholder,"close-on-select":e.closeOnSelect},null,8,["options","modelValue","placeholder","close-on-select"])]))}});const xo={class:"field"},$o=X({__name:"Toggle",props:{title:null,modelValue:{type:Boolean}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,i=C(()=>{var a;return oe((a=s(n.title))!=null?a:"<span></span>","span")}),r=C({get(){return!!n.modelValue},set(a){t("update:modelValue",a)}});return(a,l)=>(M(),P("label",xo,[Bi(N("input",{type:"checkbox",class:"toggle","onUpdate:modelValue":l[0]||(l[0]=u=>Ae(r)?r.value=u:null)},null,512),[[ha,s(r)]]),(M(),ee(He(s(i))))]))}});var Bt=ue($o,[["__scopeId","data-v-11046116"]]);const Eo=["onClick"],Do=X({__name:"FeedbackButton",props:{left:{type:Boolean}},emits:["click"],setup(e,{emit:t}){const n=L(!1),i=L(null);function r(){t("click"),i.value&&clearTimeout(i.value),n.value=!1,jt(()=>{n.value=!0,i.value=setTimeout(()=>n.value=!1,500)})}return(a,l)=>(M(),P("button",{onClick:En(r,["stop"]),class:ge(["feedback",{activated:n.value,left:e.left}])},[Tt(a.$slots,"default",{},void 0,!0)],10,Eo))}});var Vr=ue(Do,[["__scopeId","data-v-01a1b95c"]]);const Po={class:"header"},To=N("h2",null,"Settings",-1),Ao={class:"option-tabs"},Fo={key:0},Oo={key:1};var Ro=X({__name:"Options",setup(e,{expose:t}){const n=L(!1),i=L("behaviour");function r(Z){return Z==i.value}function a(Z){i.value=Z}t({isTab:r,setTab:a,save:pt,open(){n.value=!0}});const l=Object.keys(Ct).map(Z=>({label:tt(Z),value:Z})),u=C(()=>oe(K(()=>f(ne,null,[Dr.map(nt)])))),{showTPS:c,theme:d,unthrottled:m,alignUnits:p}=Ee(ae),{autosave:h,offlineProd:w}=Ee(Q),b=C({get(){return Q.devSpeed===0},set(Z){Q.devSpeed=Z?0:null}}),v=K(()=>f("span",{class:"option-title"},[E("Unthrottled"),f("desc",null,[E("Allow the game to run as fast as possible. Not battery friendly.")])])),I=K(()=>f("span",{class:"option-title"},[E("Offline Production"),f(Pe,{display:"Save-specific",direction:U.Right},{default:()=>[E("*")]}),f("desc",null,[E("Simulate production that occurs while the game is closed.")])])),F=K(()=>f("span",{class:"option-title"},[E("Autosave"),f(Pe,{display:"Save-specific",direction:U.Right},{default:()=>[E("*")]}),f("desc",null,[E("Automatically save the game every second or when the game is closed.")])])),S=K(()=>f("span",{class:"option-title"},[E("Pause game"),f(Pe,{display:"Save-specific",direction:U.Right},{default:()=>[E("*")]}),f("desc",null,[E("Stop everything from moving.")])])),D=K(()=>f("span",{class:"option-title"},[E("Theme"),f("desc",null,[E("How the game looks.")])])),V=K(()=>f("span",{class:"option-title"},[E("Show TPS"),f("desc",null,[E("Show TPS meter at the bottom-left corner of the page.")])])),re=K(()=>f("span",{class:"option-title"},[E("Align modifier units"),f("desc",null,[E("Align numbers to the beginning of the unit in modifier view.")])]));return(Z,z)=>(M(),ee(Ut,{modelValue:n.value,"onUpdate:modelValue":z[10]||(z[10]=G=>n.value=G)},{header:W(()=>[N("div",Po,[To,N("div",Ao,[N("button",{class:ge({selected:r("behaviour")}),onClick:z[0]||(z[0]=G=>a("behaviour"))},"Behaviour",2),N("button",{class:ge({selected:r("appearance")}),onClick:z[1]||(z[1]=G=>a("appearance"))},"Appearance",2)])])]),body:W(()=>[r("behaviour")?(M(),P("div",Fo,[f(Bt,{title:s(v),modelValue:s(m),"onUpdate:modelValue":z[2]||(z[2]=G=>Ae(m)?m.value=G:null)},null,8,["title","modelValue"]),s(pe).enablePausing?(M(),ee(Bt,{key:0,title:s(S),modelValue:s(b),"onUpdate:modelValue":z[3]||(z[3]=G=>Ae(b)?b.value=G:null)},null,8,["title","modelValue"])):j("",!0),f(Bt,{title:s(I),modelValue:s(w),"onUpdate:modelValue":z[4]||(z[4]=G=>Ae(w)?w.value=G:null)},null,8,["title","modelValue"]),f(Bt,{title:s(F),modelValue:s(h),"onUpdate:modelValue":z[5]||(z[5]=G=>Ae(h)?h.value=G:null)},null,8,["title","modelValue"]),s(h)?j("",!0):(M(),ee(Vr,{key:1,class:"button save-button",onClick:z[6]||(z[6]=G=>s(pt)())},{default:W(()=>[E("Manually save")]),_:1}))])):j("",!0),r("appearance")?(M(),P("div",Oo,[f(Yi,{title:s(D),options:s(l),modelValue:s(d),"onUpdate:modelValue":z[7]||(z[7]=G=>Ae(d)?d.value=G:null)},null,8,["title","options","modelValue"]),(M(),ee(He(s(u)))),f(Bt,{title:s(V),modelValue:s(c),"onUpdate:modelValue":z[8]||(z[8]=G=>Ae(c)?c.value=G:null)},null,8,["title","modelValue"]),f(Bt,{title:s(re),modelValue:s(p),"onUpdate:modelValue":z[9]||(z[9]=G=>Ae(p)?p.value=G:null)},null,8,["title","modelValue"])])):j("",!0)]),_:1},8,["modelValue"]))}});const qo=["onSubmit"],Vo={class:"field"},Bo={key:0,class:"field-title"},Lo=["placeholder"],jo=X({__name:"Text",props:{title:null,modelValue:null,textArea:{type:Boolean},placeholder:null,maxHeight:null,submitOnBlur:{type:Boolean}},emits:["update:modelValue","submit","cancel"],setup(e,{emit:t}){const n=e,i=Tn(Qt(n,"title"),"span"),r=mt(null);pi(()=>{var c;(c=r.value)==null||c.focus()});const a=C({get(){var c;return(c=s(n.modelValue))!=null?c:""},set(c){t("update:modelValue",c)}});function l(){t("submit")}function u(){n.submitOnBlur!==!1?t("submit"):t("cancel")}return(c,d)=>(M(),P("form",{onSubmit:En(l,["prevent"])},[N("div",Vo,[s(i)?(M(),P("span",Bo,[(M(),ee(He(s(i))))])):j("",!0),e.textArea?(M(),ee(s(ka),{key:1,modelValue:s(a),"onUpdate:modelValue":d[0]||(d[0]=m=>Ae(a)?a.value=m:null),placeholder:e.placeholder,maxHeight:e.maxHeight,onBlur:u,ref_key:"field",ref:r},null,8,["modelValue","placeholder","maxHeight"])):Bi((M(),P("input",{key:2,type:"text","onUpdate:modelValue":d[1]||(d[1]=m=>Ae(a)?a.value=m:null),placeholder:e.placeholder,class:ge({fullWidth:!e.title}),onBlur:u,ref_key:"field",ref:r},null,42,Lo)),[[ba,s(a)]])])],40,qo))}});var Br=ue(jo,[["__scopeId","data-v-90bd4994"]]);const zo={key:0},Uo=["onClick","disabled"],Go={key:0},Wo=["onClick"],Ho=X({__name:"DangerButton",props:{disabled:{type:Boolean},skipConfirm:{type:Boolean}},emits:["click","confirmingChanged"],setup(e,{emit:t}){const i=Ee(e),r=L(!1);gt(r,u=>{t("confirmingChanged",u)});function a(){if(s(i.skipConfirm)){t("click");return}r.value&&t("click"),r.value=!r.value}function l(){r.value=!1}return(u,c)=>(M(),P("span",{class:ge(["container",{confirming:r.value}])},[r.value?(M(),P("span",zo,"Are you sure?")):j("",!0),N("button",{onClick:En(a,["stop"]),class:"button danger",disabled:e.disabled},[r.value?(M(),P("span",Go,"Yes")):Tt(u.$slots,"default",{key:1},void 0,!0)],8,Uo),r.value?(M(),P("button",{key:1,class:"button",onClick:En(l,["stop"])},"No",8,Wo)):j("",!0)],2))}});var Zo=ue(Ho,[["__scopeId","data-v-2f8ef34c"]]);const Gt=e=>(vn("data-v-32313015"),e=e(),hn(),e),Yo=Gt(()=>N("div",{class:"handle material-icons"},"drag_handle",-1)),Xo={key:0,class:"actions"},Jo=Gt(()=>N("span",{class:"material-icons"},"content_paste",-1)),Ko=Gt(()=>N("span",{class:"material-icons"},"content_copy",-1)),Qo=Gt(()=>N("span",{class:"material-icons"},"edit",-1)),el=Gt(()=>N("span",{class:"material-icons",style:{margin:"-2px"}},"delete",-1)),tl={key:1,class:"actions"},nl=Gt(()=>N("span",{class:"material-icons"},"check",-1)),il=Gt(()=>N("span",{class:"material-icons"},"close",-1)),rl={key:2,class:"details"},al={class:"save-version"},sl=Gt(()=>N("br",null,null,-1)),ol={key:0},ll={key:3,class:"details"},ul={key:4,class:"details error"},cl=Gt(()=>N("br",null,null,-1)),dl=X({__name:"Save",props:{save:null},emits:["export","open","duplicate","delete","editName"],setup(e,{emit:t}){const n=e,{save:i}=Ee(n),r=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),a=L(!1),l=L(!1),u=L("");gt(a,()=>{var p;return u.value=(p=i.value.name)!=null?p:""});const c=C(()=>i.value!=null&&i.value.id===Q.id),d=C(()=>{var p;return c.value?Q.time:(p=i.value!=null&&i.value.time)!=null?p:0});function m(){t("editName",u.value),a.value=!1}return(p,h)=>(M(),P("div",{class:ge(["save",{active:s(c)}])},[Yo,a.value?(M(),P("div",tl,[N("button",{onClick:m,class:"button"},[f(Pe,{display:"Save",direction:s(U).Left,class:"info"},{default:W(()=>[nl]),_:1},8,["direction"])]),N("button",{onClick:h[5]||(h[5]=w=>a.value=!a.value),class:"button"},[f(Pe,{display:"Cancel",direction:s(U).Left,class:"info"},{default:W(()=>[il]),_:1},8,["direction"])])])):(M(),P("div",Xo,[s(i).error==null&&!l.value?(M(),ee(Vr,{key:0,onClick:h[0]||(h[0]=w=>t("export")),class:"button",left:""},{default:W(()=>[f(Pe,{display:"Export",direction:s(U).Left,class:"info"},{default:W(()=>[Jo]),_:1},8,["direction"])]),_:1})):j("",!0),s(i).error==null&&!l.value?(M(),P("button",{key:1,onClick:h[1]||(h[1]=w=>t("duplicate")),class:"button"},[f(Pe,{display:"Duplicate",direction:s(U).Left,class:"info"},{default:W(()=>[Ko]),_:1},8,["direction"])])):j("",!0),s(i).error==null&&!l.value?(M(),P("button",{key:2,onClick:h[2]||(h[2]=w=>a.value=!a.value),class:"button"},[f(Pe,{display:"Edit Name",direction:s(U).Left,class:"info"},{default:W(()=>[Qo]),_:1},8,["direction"])])):j("",!0),f(Zo,{disabled:s(c),onClick:h[3]||(h[3]=w=>t("delete")),onConfirmingChanged:h[4]||(h[4]=w=>l.value=w)},{default:W(()=>[f(Pe,{display:"Delete",direction:s(U).Left,class:"info"},{default:W(()=>[el]),_:1},8,["direction"])]),_:1},8,["disabled"])])),s(i).error==null&&!a.value?(M(),P("div",rl,[N("button",{class:"button open",onClick:h[6]||(h[6]=w=>t("open"))},[N("h3",null,se(s(i).name),1)]),N("span",al,"v"+se(s(i).modVersion),1),sl,s(d)?(M(),P("div",ol,"Last played "+se(s(r).format(s(d))),1)):j("",!0)])):s(i).error==null&&a.value?(M(),P("div",ll,[f(Br,{modelValue:u.value,"onUpdate:modelValue":h[7]||(h[7]=w=>u.value=w),class:"editname",onSubmit:m},null,8,["modelValue"])])):(M(),P("div",ul,[E(" Error: Failed to load save with id "+se(s(i).id),1),cl,E(se(s(i).error),1)]))],2))}});var pl=ue(dl,[["__scopeId","data-v-32313015"]]);const Xi=e=>(vn("data-v-2a4275be"),e=e(),hn(),e),fl=Xi(()=>N("h2",null,"Saves Manager",-1)),gl={class:"modal-footer"},ml={class:"field"},vl=Xi(()=>N("span",{class:"field-title"},"Create Save",-1)),hl={class:"field-buttons"},bl={class:"footer"},yl=Xi(()=>N("div",{style:{"flex-grow":"1"}},null,-1)),wl=X({__name:"SavesManager",setup(e,{expose:t}){const n=L(!1),i=L(null);t({open(){n.value=!0}});const r=L(!1),a=L(""),l=L(null);gt(a,S=>{S?jt(()=>{try{if(S[0]!=="{")if(S[0]==="e")S=decodeURIComponent(escape(atob(S)));else if(S[0]==="\u1BE1")S=Xt.decompressFromUTF16(S);else{console.warn("Unable to determine preset encoding",S),r.value=!0;return}const D=JSON.parse(S);if(typeof D!="object"){r.value=!0;return}const V=ri();D.id=V,pt(D),a.value="",r.value=!1,ae.saves.push(V)}catch{r.value=!0}}):r.value=!1});let u={},c=L(Object.keys(u).reduce((S,D)=>(S.push({label:D.split("/").slice(-1)[0].slice(0,-4),value:u[D]}),S),[]));const d=Li({});function m(S){if(d[S]==null){let D=localStorage.getItem(S);if(D==null)d[S]={error:"Save doesn't exist in localStorage",id:S};else if(D==="dW5kZWZpbmVk")d[S]={error:"Save is undefined",id:S};else try{if(D[0]!=="{")if(D[0]==="e")D=decodeURIComponent(escape(atob(D)));else if(D[0]==="\u1BE1")D=Xt.decompressFromUTF16(D);else return console.warn("Unable to determine preset encoding",D),r.value=!0,d[S]={error:"Unable to determine preset encoding",id:S},d[S];d[S]={...JSON.parse(D),id:S}}catch(V){d[S]={error:V,id:S},console.warn(`SavesManager: Failed to load info about save with id ${S}:
${V}
${D}`)}}return d[S]}gt(n,S=>{S&&Object.keys(d).forEach(D=>delete d[D])});const p=C(()=>ae.saves.reduce((S,D)=>(S[D]=m(D),S),{}));function h(S){let D;switch(Q.id===S?D=$r(Q):D=JSON.stringify(p.value[S]),pe.exportEncoding){default:console.warn(`Unknown save encoding: ${pe.exportEncoding}. Defaulting to lz`);case"lz":D=Xt.compressToUTF16(D);break;case"base64":D=btoa(unescape(encodeURIComponent(D)));break;case"plain":break}const V=document.createElement("textarea");V.value=D,document.body.appendChild(V),V.select(),V.setSelectionRange(0,99999),document.execCommand("copy"),document.body.removeChild(V)}function w(S){Q.id===S&&pt();const D={...p.value[S],id:ri()};pt(D),ae.saves.push(D.id)}function b(S){ae.saves=ae.saves.filter(D=>D!==S),localStorage.removeItem(S),d[S]=void 0}function v(S){p.value[Q.id].time=Q.time,pt(),d[Q.id]=void 0,cn(p.value[S]),d[S]=void 0}function I(S){if(l.value=S,jt(()=>{l.value=null}),S[0]!=="{")if(S[0]==="e")S=decodeURIComponent(escape(atob(S)));else if(S[0]==="\u1BE1")S=Xt.decompressFromUTF16(S);else{console.warn("Unable to determine preset encoding",S);return}const D=JSON.parse(S);D.id=ri(),pt(D),ae.saves.push(D.id),v(D.id)}function F(S,D){const V=p.value[S];V!=null&&(V.name=D,Q.id===S?(Q.name=D,pt()):(pt(V),d[S]=void 0))}return(S,D)=>(M(),ee(Ut,{modelValue:n.value,"onUpdate:modelValue":D[4]||(D[4]=V=>n.value=V),ref_key:"modal",ref:i},{header:W(()=>[fl]),body:W(({shown:V})=>[V?(M(),ee(s(Ca),{key:0,list:s(ae).saves,handle:".handle",itemKey:re=>re},{item:W(({element:re})=>[f(pl,{save:s(p)[re],onOpen:Z=>v(re),onExport:Z=>h(re),onEditName:Z=>F(re,Z),onDuplicate:Z=>w(re),onDelete:Z=>b(re)},null,8,["save","onOpen","onExport","onEditName","onDuplicate","onDelete"])]),_:1},8,["list","itemKey"])):j("",!0)]),footer:W(()=>[N("div",gl,[f(Br,{modelValue:a.value,"onUpdate:modelValue":D[0]||(D[0]=V=>a.value=V),title:"Import Save",placeholder:"Paste your save here!",class:ge({importingFailed:r.value})},null,8,["modelValue","class"]),N("div",ml,[vl,N("div",hl,[N("button",{class:"button",onClick:D[1]||(D[1]=V=>v(s($n)().id))},"New Game"),Object.keys(s(c)).length>0?(M(),ee(Yi,{key:0,options:s(c),modelValue:l.value,"onUpdate:modelValue":D[2]||(D[2]=V=>I(V)),closeOnSelect:"",placeholder:"Select preset",class:"presets"},null,8,["options","modelValue"])):j("",!0)])]),N("div",bl,[yl,N("button",{class:"button modal-default-button",onClick:D[3]||(D[3]=V=>n.value=!1)}," Close ")])])]),_:1},8,["modelValue"]))}});var Lr=ue(wl,[["__scopeId","data-v-2a4275be"]]);const yt=e=>(vn("data-v-318a1c31"),e=e(),hn(),e),_l=["src","alt"],Nl={key:1,class:"title"},Cl=yt(()=>N("div",{style:{"flex-grow":"1",cursor:"unset"}},null,-1)),kl={class:"discord"},Ml={class:"discord-links"},Sl={key:0},Il=["href"],xl=yt(()=>N("li",null,[N("a",{href:"https://discord.gg/yJ4fjnjU54",target:"_blank"},"The Paper Pilot Community")],-1)),$l=yt(()=>N("li",null,[N("a",{href:"https://discord.gg/F3xveHV",target:"_blank"},"The Modding Tree")],-1)),El={href:"https://forums.moddingtree.com/",target:"_blank"},Dl=yt(()=>N("span",{class:"material-icons"},"forum",-1)),Pl=yt(()=>N("span",{class:"material-icons"},"info",-1)),Tl=yt(()=>N("span",{class:"material-icons"},"library_books",-1)),Al=yt(()=>N("span",{class:"material-icons"},"settings",-1)),Fl=yt(()=>N("span",{class:"material-icons"},"library_books",-1)),Ol=yt(()=>N("span",{class:"material-icons"},"settings",-1)),Rl=yt(()=>N("span",{class:"material-icons"},"info",-1)),ql={href:"https://forums.moddingtree.com/",target:"_blank"},Vl=yt(()=>N("span",{class:"material-icons"},"forum",-1)),Bl={class:"discord"},Ll={class:"discord-links"},jl={key:0},zl=["href"],Ul=yt(()=>N("li",null,[N("a",{href:"https://discord.gg/yJ4fjnjU54",target:"_blank"},"The Paper Pilot Community")],-1)),Gl=yt(()=>N("li",null,[N("a",{href:"https://discord.gg/F3xveHV",target:"_blank"},"The Modding Tree")],-1)),Wl=X({__name:"Nav",setup(e){const t=L(null),n=L(null),i=L(null),r=L(null),{useHeader:a,banner:l,title:u,discordName:c,discordLink:d,versionNumber:m}=pe;function p(){window.open(d,"mywindow")}return(h,w)=>(M(),P(ne,null,[s(a)?(M(),P("div",zt({key:0,class:"nav"},h.$attrs),[s(l)?(M(),P("img",{key:0,src:s(l),class:"banner",alt:s(u)},null,8,_l)):(M(),P("div",Nl,se(s(u)),1)),N("div",{onClick:w[0]||(w[0]=b=>{var v;return(v=r.value)==null?void 0:v.open()}),class:"version-container"},[f(Pe,{display:"Changelog",direction:s(U).Down,class:"version"},{default:W(()=>[N("span",null,"v"+se(s(m)),1)]),_:1},8,["direction"])]),Cl,N("div",kl,[N("span",{onClick:p,class:"material-icons"},"discord"),N("ul",Ml,[s(d)?(M(),P("li",Sl,[N("a",{href:s(d),target:"_blank"},se(s(c)),9,Il)])):j("",!0),xl,$l])]),N("div",null,[N("a",El,[f(Pe,{display:"Forums",direction:s(U).Down,yoffset:"5px"},{default:W(()=>[Dl]),_:1},8,["direction"])])]),N("div",{onClick:w[1]||(w[1]=b=>{var v;return(v=t.value)==null?void 0:v.open()})},[f(Pe,{display:"Info",direction:s(U).Down,class:"info"},{default:W(()=>[Pl]),_:1},8,["direction"])]),N("div",{onClick:w[2]||(w[2]=b=>{var v;return(v=n.value)==null?void 0:v.open()})},[f(Pe,{display:"Saves",direction:s(U).Down,xoffset:"-20px"},{default:W(()=>[Tl]),_:1},8,["direction"])]),N("div",{onClick:w[3]||(w[3]=b=>{var v;return(v=i.value)==null?void 0:v.open()})},[f(Pe,{display:"Settings",direction:s(U).Down,xoffset:"-66px"},{default:W(()=>[Al]),_:1},8,["direction"])])],16)):(M(),P("div",zt({key:1,class:"overlay-nav"},h.$attrs),[N("div",{onClick:w[4]||(w[4]=b=>{var v;return(v=r.value)==null?void 0:v.open()}),class:"version-container"},[f(Pe,{display:"Changelog",direction:s(U).Right,xoffset:"25%",class:"version"},{default:W(()=>[N("span",null,"v"+se(s(m)),1)]),_:1},8,["direction"])]),N("div",{onClick:w[5]||(w[5]=b=>{var v;return(v=n.value)==null?void 0:v.open()})},[f(Pe,{display:"Saves",direction:s(U).Right},{default:W(()=>[Fl]),_:1},8,["direction"])]),N("div",{onClick:w[6]||(w[6]=b=>{var v;return(v=i.value)==null?void 0:v.open()})},[f(Pe,{display:"Settings",direction:s(U).Right},{default:W(()=>[Ol]),_:1},8,["direction"])]),N("div",{onClick:w[7]||(w[7]=b=>{var v;return(v=t.value)==null?void 0:v.open()})},[f(Pe,{display:"Info",direction:s(U).Right},{default:W(()=>[Rl]),_:1},8,["direction"])]),N("div",null,[N("a",ql,[f(Pe,{display:"Forums",direction:s(U).Right,xoffset:"7px"},{default:W(()=>[Vl]),_:1},8,["direction"])])]),N("div",Bl,[N("span",{onClick:p,class:"material-icons"},"discord"),N("ul",Ll,[s(d)?(M(),P("li",jl,[N("a",{href:s(d),target:"_blank"},se(s(c)),9,zl)])):j("",!0),Ul,Gl])])],16)),f(Mo,{ref_key:"info",ref:t,changelog:r.value},null,8,["changelog"]),f(Lr,{ref_key:"savesManager",ref:n},null,512),f(Ro,{ref_key:"options",ref:i},null,512),f(ao,{ref_key:"changelog",ref:r},null,512)],64))}});var jr=ue(Wl,[["__scopeId","data-v-318a1c31"]]);const Hl={class:"inner-tab"},Zl=X({__name:"Game",setup(e){const t=Qt(Q,"tabs"),n=C(()=>Object.keys(be)),i=pe.useHeader;function r(a){const{display:l,minimized:u,name:c,color:d,minimizable:m,nodes:p,minimizedDisplay:h}=a;return{display:l,minimized:u,name:c,color:d,minimizable:m,nodes:p,minimizedDisplay:h}}return(a,l)=>(M(),P("div",{class:ge(["tabs-container",{useHeader:s(i)}])},[(M(!0),P(ne,null,Pn(s(t),(u,c)=>{var d,m;return M(),P("div",{key:c,class:ge(["tab",s((d=s(be)[u])==null?void 0:d.classes)]),style:qe(s((m=s(be)[u])==null?void 0:m.style))},[c===0&&!s(i)?(M(),ee(jr,{key:0})):j("",!0),N("div",Hl,[s(n).includes(u)?(M(),ee(to,zt({key:0},r(s(be)[u]),{index:c,onSetMinimized:p=>s(be)[u].minimized.value=p}),null,16,["index","onSetMinimized"])):(M(),ee(He(u),{key:1,index:c},null,8,["index"]))])],6)}),128))],2))}});var Yl=ue(Zl,[["__scopeId","data-v-dcd207b4"]]);const Xl=X({__name:"Sticky",setup(e){const t=L("0"),n=new ResizeObserver(r),i=mt(null);function r(){let a=i.value;if(a==null)return;let l=0;for(;a.previousSibling;){const u=a.previousSibling;u.dataset&&"vSticky"in u.dataset&&(l+=u.offsetHeight),a=u}t.value=l+"px"}return jt(r),document.fonts.ready.then(r),pi(()=>{var l;const a=(l=i.value)==null?void 0:l.parentElement;a&&n.observe(a)}),(a,l)=>(M(),P("div",{class:"sticky",style:qe({top:t.value}),ref_key:"element",ref:i,"data-v-sticky":""},[Tt(a.$slots,"default",{},void 0,!0)],4))}});var ui=ue(Xl,[["__scopeId","data-v-cccac690"]]);const Jl=["x1","y1","x2","y2"],Kl=X({__name:"BoardLink",props:{link:null},setup(e){const n=Ee(e),i=C(()=>{const a=n.link.value.startNode.position;return n.link.value.offsetStart&&(a.x+=s(n.link.value.offsetStart).x,a.y+=s(n.link.value.offsetStart).y),a}),r=C(()=>{const a=n.link.value.endNode.position;return n.link.value.offsetEnd&&(a.x+=s(n.link.value.offsetEnd).x,a.y+=s(n.link.value.offsetEnd).y),a});return(a,l)=>(M(),P("line",zt({class:"link"},e.link,{class:{pulsing:e.link.pulsing},x1:s(i).x,y1:s(i).y,x2:s(r).x,y2:s(r).y}),null,16,Jl))}});var Ql=ue(Kl,[["__scopeId","data-v-57c4970a"]]);const eu={key:0},tu=["transform","onMousedown","onTouchstart","onMouseup","onTouchend"],nu=["fill","stroke-width","stroke"],iu=["fill"],ru=X({__name:"BoardNodeAction",props:{node:null,nodeType:null,actions:null,isSelected:{type:Boolean},selectedAction:null},emits:["clickAction"],setup(e,{emit:t}){const i=Ee(e),r=C(()=>de(i.nodeType.value.size,s(i.node))),a=C(()=>{var m;return(m=de(i.nodeType.value.outlineColor,s(i.node)))!=null?m:Ct[ae.theme].variables["--outline"]}),l=C(()=>{var m;return(m=de(i.nodeType.value.titleColor,s(i.node)))!=null?m:Ct[ae.theme].variables["--foreground"]}),u=C(()=>de(i.nodeType.value.actionDistance,s(i.node)));function c(m,p){t("clickAction",p.id),m.preventDefault(),m.stopPropagation()}function d(m,p){var h;((h=s(i.selectedAction))==null?void 0:h.id)===p.id&&(m.preventDefault(),m.stopPropagation())}return(m,p)=>(M(),ee(Dn,{name:"actions",appear:""},{default:W(()=>[e.isSelected&&e.actions?(M(),P("g",eu,[(M(!0),P(ne,null,Pn(e.actions,(h,w)=>{var b,v;return M(),P("g",{key:h.id,class:ge(["action",{selected:((b=e.selectedAction)==null?void 0:b.id)===h.id}]),transform:`translate(
${(-s(r)-30)*Math.sin(((e.actions.length-1)/2-w)*s(u))},
${(s(r)+30)*Math.cos(((e.actions.length-1)/2-w)*s(u))}
)`,onMousedown:I=>c(I,h),onTouchstart:I=>c(I,h),onMouseup:I=>d(I,h),onTouchend:En(I=>d(I,h),["stop"])},[N("circle",{fill:s(de)(h.fillColor,e.node),r:"20","stroke-width":((v=e.selectedAction)==null?void 0:v.id)===h.id?4:0,stroke:s(a)},null,8,nu),N("text",{fill:s(l),class:"material-icons"},se(s(de)(h.icon,e.node)),9,iu)],42,tu)}),128))])):j("",!0)]),_:1}))}});var au=ue(ru,[["__scopeId","data-v-9efb2a56"]]);const su=["transform"],ou={key:0},lu=["r","fill","stroke"],uu=["r","fill","stroke"],cu=["r","fill"],du=["r","stroke-dasharray","stroke-dashoffset","stroke"],pu={key:1,transform:"rotate(45, 0, 0)"},fu=["width","height","transform","fill","stroke"],gu=["width","height","transform","fill","stroke"],mu=["width","height","transform","fill"],vu=["width","height","transform","stroke-dasharray","stroke-dashoffset","stroke"],hu=["fill","y"],bu=["fill"],yu={key:0},wu=["fill","y"],_u=["fill","y"],Nu=X({__name:"BoardNode",props:{node:null,nodeType:null,dragging:null,dragged:null,hasDragged:{type:Boolean},receivingNode:{type:Boolean},selectedNode:null,selectedAction:null},emits:["mouseDown","endDragging","clickAction"],setup(e,{emit:t}){const n=e,i=Math.sqrt(2),r=Ee(n),a=C(()=>s(r.selectedNode)===s(r.node)),l=C(()=>de(r.nodeType.value.draggable,s(r.node)));gt(l,H=>{const _e=s(r.node);s(r.dragging)===_e&&!H&&t("endDragging",_e)});const u=C(()=>{var _e;const H=s(r.node);return(_e=de(r.nodeType.value.actions,H))==null?void 0:_e.filter(Ke=>Le(de(Ke.visibility,H)))}),c=C(()=>{var _e;const H=s(r.node);if(de(r.nodeType.value.draggable,H)&&((_e=s(r.dragging))==null?void 0:_e.id)===H.id&&s(r.dragged)!=null){const{x:Ke,y:wt}=s(r.dragged);return{x:H.position.x+Math.round(Ke/25)*25,y:H.position.y+Math.round(wt/25)*25}}return H.position}),d=C(()=>de(r.nodeType.value.shape,s(r.node))),m=C(()=>de(r.nodeType.value.title,s(r.node))),p=C(()=>de(r.nodeType.value.subtitle,s(r.node))),h=C(()=>{var H;return(H=a.value?s(r.selectedAction)&&de(s(r.selectedAction).tooltip,s(r.node)):null)!=null?H:de(r.nodeType.value.label,s(r.node))}),w=C(()=>{var H,_e;return de((_e=(H=s(r.selectedAction))==null?void 0:H.confirmationLabel)!=null?_e:{text:"Tap again to confirm"},s(r.node))}),b=C(()=>de(r.nodeType.value.size,s(r.node))),v=C(()=>{var H;return(H=de(r.nodeType.value.progress,s(r.node)))!=null?H:0}),I=C(()=>Ct[ae.theme].variables["--background"]),F=C(()=>{var H;return(H=de(r.nodeType.value.outlineColor,s(r.node)))!=null?H:Ct[ae.theme].variables["--outline"]}),S=C(()=>{var H;return(H=de(r.nodeType.value.fillColor,s(r.node)))!=null?H:Ct[ae.theme].variables["--raised-background"]}),D=C(()=>de(r.nodeType.value.progressColor,s(r.node))),V=C(()=>{var H;return(H=de(r.nodeType.value.titleColor,s(r.node)))!=null?H:Ct[ae.theme].variables["--foreground"]}),re=C(()=>de(r.nodeType.value.progressDisplay,s(r.node))),Z=C(()=>r.dragging.value!=null&&s(r.hasDragged)&&de(r.nodeType.value.canAccept,s(r.node),r.dragging.value)),z=C(()=>de(r.nodeType.value.style,s(r.node))),G=C(()=>de(r.nodeType.value.classes,s(r.node)));function xe(H){t("mouseDown",H,r.node.value,l.value)}function it(H){var _e,Ke,wt;(_e=r.hasDragged)!=null&&_e.value||(t("endDragging",r.node.value),(wt=(Ke=r.nodeType.value).onClick)==null||wt.call(Ke,r.node.value),H.stopPropagation())}return(H,_e)=>{var Ke,wt,nn;return M(),P("g",{class:ge(["boardnode",{[e.node.type]:!0,isSelected:s(a),isDraggable:s(l),...s(G)}]),style:qe([{opacity:((Ke=e.dragging)==null?void 0:Ke.id)===e.node.id&&e.hasDragged?.5:1},(wt=s(z))!=null?wt:[]]),transform:`translate(${s(c).x},${s(c).y})${s(a)?" scale(1.2)":""}`},[f(au,{actions:(nn=s(u))!=null?nn:[],"is-selected":s(a),node:e.node,"node-type":e.nodeType,"selected-action":e.selectedAction,onClickAction:_e[0]||(_e[0]=Ue=>t("clickAction",Ue))},null,8,["actions","is-selected","node","node-type","selected-action"]),N("g",{class:"node-container",onMousedown:xe,onTouchstartPassive:xe,onMouseup:it,onTouchendPassive:it},[s(d)===s(je).Circle?(M(),P("g",ou,[s(Z)?(M(),P("circle",{key:0,class:"receiver",r:s(b)+8,fill:s(I),stroke:e.receivingNode?"#0F0":"#0F03","stroke-width":2},null,8,lu)):j("",!0),N("circle",{class:"body",r:s(b),fill:s(S),stroke:s(F),"stroke-width":4},null,8,uu),s(re)===s(mn).Fill?(M(),P("circle",{key:1,class:"progress progressFill",r:Math.max(s(b)*s(v)-2,0),fill:s(D)},null,8,cu)):(M(),P("circle",{key:2,r:s(b)+4.5,class:"progress progressRing",fill:"transparent","stroke-dasharray":(s(b)+4.5)*2*Math.PI,"stroke-width":5,"stroke-dashoffset":(s(b)+4.5)*2*Math.PI-s(v)*(s(b)+4.5)*2*Math.PI,stroke:s(D)},null,8,du))])):s(d)===s(je).Diamond?(M(),P("g",pu,[s(Z)?(M(),P("rect",{key:0,class:"receiver",width:s(b)*s(i)+16,height:s(b)*s(i)+16,transform:`translate(${-(s(b)*s(i)+16)/2}, ${-(s(b)*s(i)+16)/2})`,fill:s(I),stroke:e.receivingNode?"#0F0":"#0F03","stroke-width":2},null,8,fu)):j("",!0),N("rect",{class:"body",width:s(b)*s(i),height:s(b)*s(i),transform:`translate(${-s(b)*s(i)/2}, ${-s(b)*s(i)/2})`,fill:s(S),stroke:s(F),"stroke-width":4},null,8,gu),s(re)===s(mn).Fill?(M(),P("rect",{key:1,class:"progress progressFill",width:Math.max(s(b)*s(i)*s(v)-2,0),height:Math.max(s(b)*s(i)*s(v)-2,0),transform:`translate(${-Math.max(s(b)*s(i)*s(v)-2,0)/2}, ${-Math.max(s(b)*s(i)*s(v)-2,0)/2})`,fill:s(D)},null,8,mu)):(M(),P("rect",{key:2,class:"progress progressDiamond",width:s(b)*s(i)+9,height:s(b)*s(i)+9,transform:`translate(${-(s(b)*s(i)+9)/2}, ${-(s(b)*s(i)+9)/2})`,fill:"transparent","stroke-dasharray":(s(b)*s(i)+9)*4,"stroke-width":5,"stroke-dashoffset":(s(b)*s(i)+9)*4-s(v)*(s(b)*s(i)+9)*4,stroke:s(D)},null,8,vu))])):j("",!0),N("text",{fill:s(V),class:"node-title",y:s(p)?10:0},se(s(m)),9,hu),s(p)?(M(),P("text",{key:2,fill:s(V),class:"node-subtitle",y:"-15"},se(s(p)),9,bu)):j("",!0)],32),f(Dn,{name:"fade",appear:""},{default:W(()=>{var Ue;return[s(h)?(M(),P("g",yu,[N("text",{fill:(Ue=s(h).color)!=null?Ue:s(V),class:ge(["node-title",{pulsing:s(h).pulsing}]),y:-s(b)-20},se(s(h).text),11,wu)])):j("",!0)]}),_:1}),f(Dn,{name:"fade",appear:""},{default:W(()=>{var Ue;return[s(a)&&e.selectedAction?(M(),P("text",{key:0,fill:(Ue=s(w).color)!=null?Ue:s(V),class:ge(["node-title",{pulsing:s(w).pulsing}]),y:s(b)+75},se(s(w).text),11,_u)):j("",!0)]}),_:1})],14,su)}}});var Cu=ue(Nu,[["__scopeId","data-v-4654be02"]]);const ku={class:"stage",width:"100%",height:"100%"},Mu={class:"g1"},Su=X({__name:"Board",props:{nodes:null,types:null,state:null,visibility:null,width:null,height:null,style:null,classes:null,links:null,selectedAction:null,selectedNode:null,draggingNode:null,receivingNode:null,mousePosition:null,setReceivingNode:{type:Function},setDraggingNode:{type:Function}},setup(e){const n=Ee(e),i=L({x:0,y:0}),r=L({x:0,y:0}),a=L(!1),l=L(null),u=C(()=>{const w=n.nodes.value.slice();if(n.draggingNode.value){const b=w.splice(w.indexOf(n.draggingNode.value),1)[0];w.push(b)}return w});kt(()=>{const w=n.draggingNode.value;if(w==null)return null;const b={x:w.position.x+r.value.x,y:w.position.y+r.value.y};let v=Number.MAX_VALUE;n.setReceivingNode.value(n.nodes.value.reduce((I,F)=>{if(F.id===w.id)return I;const S=n.types.value[F.type];if(!de(S.canAccept,F,w))return I;const V=Math.pow(b.x-F.position.x,2)+Math.pow(b.y-F.position.y,2);let re=de(S.size,F);return V>v||V>re*re?I:(v=V,F)},null))});function c(w){w.setTransformOrigin(null),w.moveTo(l.value.$el.clientWidth/2,l.value.$el.clientHeight/2)}function d(w,b=null,v=!1){if(n.draggingNode.value==null){w.preventDefault(),w.stopPropagation();let I,F;if("touches"in w)if(w.touches.length===1)I=w.touches[0].clientX,F=w.touches[0].clientY;else return;else I=w.clientX,F=w.clientY;i.value={x:I,y:F},r.value={x:0,y:0},a.value=!1,v&&n.setDraggingNode.value(b)}b!=null&&(n.state.value.selectedNode=null,n.state.value.selectedAction=null)}function m(w){const{x:b,y:v,scale:I}=l.value.panZoomInstance.getTransform();let F,S;if("touches"in w)if(w.touches.length===1)F=w.touches[0].clientX,S=w.touches[0].clientY;else{p(n.draggingNode.value),n.mousePosition.value=null;return}else F=w.clientX,S=w.clientY;n.mousePosition.value={x:(F-b)/I,y:(S-v)/I},r.value={x:r.value.x+(F-i.value.x)/I,y:r.value.y+(S-i.value.y)/I},i.value={x:F,y:S},(Math.abs(r.value.x)>10||Math.abs(r.value.y)>10)&&(a.value=!0),n.draggingNode.value!=null&&(w.preventDefault(),w.stopPropagation())}function p(w,b=!1){var v,I;if(n.draggingNode.value!=null&&n.draggingNode.value===w){n.receivingNode.value==null&&(n.draggingNode.value.position.x+=Math.round(r.value.x/25)*25,n.draggingNode.value.position.y+=Math.round(r.value.y/25)*25);const F=n.nodes.value;F.push(F.splice(F.indexOf(n.draggingNode.value),1)[0]),n.receivingNode.value&&((I=(v=n.types.value[n.receivingNode.value.type]).onDrop)==null||I.call(v,n.receivingNode.value,n.draggingNode.value)),n.setDraggingNode.value(null)}else!a.value&&!b&&(n.state.value.selectedNode=null,n.state.value.selectedAction=null)}function h(w,b){n.state.value.selectedAction===b?s(n.selectedAction).onClick(s(n.selectedNode)):n.state.value={...n.state.value,selectedAction:b}}return(w,b)=>{const v=St("panZoom");return s(Le)(e.visibility)?(M(),ee(v,{key:0,style:qe([{width:e.width,height:e.height},e.style]),class:ge(e.classes),selector:".g1",options:{initialZoom:1,minZoom:.1,maxZoom:10,zoomDoubleClickSpeed:1},ref_key:"stage",ref:l,onInit:c,onMousemove:m,onTouchmove:m,onMousedown:b[0]||(b[0]=I=>d(I)),onTouchstart:b[1]||(b[1]=I=>d(I)),onMouseup:b[2]||(b[2]=()=>p(s(e.draggingNode))),onTouchendPassive:b[3]||(b[3]=()=>p(s(e.draggingNode))),onMouseleave:b[4]||(b[4]=()=>p(s(e.draggingNode),!0))},{default:W(()=>[(M(),P("svg",ku,[N("g",Mu,[f(sr,{name:"link",appear:""},{default:W(()=>[(M(!0),P(ne,null,Pn(s(e.links)||[],I=>(M(),P("g",{key:`${I.startNode.id}-${I.endNode.id}`},[f(Ql,{link:I},null,8,["link"])]))),128))]),_:1}),f(sr,{name:"grow",duration:500,appear:""},{default:W(()=>[(M(!0),P(ne,null,Pn(s(u),I=>{var F;return M(),P("g",{key:I.id,style:{"transition-duration":"0s"}},[f(Cu,{node:I,nodeType:e.types[I.type],dragging:s(e.draggingNode),dragged:s(e.draggingNode)===I?r.value:void 0,hasDragged:a.value,receivingNode:((F=s(e.receivingNode))==null?void 0:F.id)===I.id,selectedNode:s(e.selectedNode),selectedAction:s(e.selectedAction),onMouseDown:d,onEndDragging:p,onClickAction:S=>h(I,S)},null,8,["node","nodeType","dragging","dragged","hasDragged","receivingNode","selectedNode","selectedAction","onClickAction"])])}),128))]),_:1})])]))]),_:1},8,["style","class","options"])):j("",!0)}}});Ze.on("setupVue",e=>Ma.install(e));const zr=Symbol("Board");var mn=(e=>(e.Outline="Outline",e.Fill="Fill",e))(mn||{}),je=(e=>(e.Circle="Circle",e.Diamond="Triangle",e))(je||{});function Iu(e){const t=ft({nodes:[],selectedNode:null,selectedAction:null},!1);return Ye(n=>{const i=e.call(n,n);i.id=tn("board-"),i.type=zr,i[bt]=Su,i.state?(Or(t),x(i,"state")):(t[en]={nodes:i.startNodes().map((u,c)=>(u.id=c,u)),selectedNode:null,selectedAction:null},i.state=t),i.nodes=C(()=>s(l.state).nodes),i.selectedNode=C({get(){return l.nodes.value.find(u=>u.id===s(l.state).selectedNode)||null},set(u){var c,d;Ae(l.state)?l.state.value={...l.state.value,selectedNode:(c=u==null?void 0:u.id)!=null?c:null}:l.state.selectedNode=(d=u==null?void 0:u.id)!=null?d:null}}),i.selectedAction=C({get(){const u=l.selectedNode.value;if(u==null)return null;const c=l.types[u.type];return c.actions==null?null:c.actions.find(d=>d.id===s(l.state).selectedAction)||null},set(u){var c,d;Ae(l.state)?l.state.value={...l.state.value,selectedAction:(c=u==null?void 0:u.id)!=null?c:null}:l.state.selectedAction=(d=u==null?void 0:u.id)!=null?d:null}}),i.mousePosition=L(null),i.links?x(i,"links"):i.links=C(()=>l.selectedAction.value==null?null:l.selectedAction.value.links&&l.selectedNode.value?de(l.selectedAction.value.links,l.selectedNode.value):null),i.draggingNode=L(null),i.receivingNode=L(null),x(i,"visibility"),ie(i,"visibility",ye.Visible),x(i,"width"),ie(i,"width","100%"),x(i,"height"),ie(i,"height","100%"),x(i,"classes"),x(i,"style");for(const u in i.types){const c=i.types[u];if(x(c,"title"),x(c,"subtitle"),x(c,"label"),x(c,"size"),ie(c,"size",50),x(c,"style"),x(c,"classes"),x(c,"draggable"),ie(c,"draggable",!1),x(c,"shape"),ie(c,"shape","Circle"),x(c,"canAccept"),ie(c,"canAccept",!1),x(c,"progress"),x(c,"progressDisplay"),ie(c,"progressDisplay","Fill"),x(c,"progressColor"),ie(c,"progressColor","none"),x(c,"fillColor"),x(c,"outlineColor"),x(c,"titleColor"),x(c,"actionDistance"),ie(c,"actionDistance",Math.PI/6),c.nodes=C(()=>s(l.state).nodes.filter(d=>d.type===u)),ie(c,"onClick",function(d){s(l.state).selectedNode=d.id}),c.actions)for(const d of c.actions)x(d,"visibility"),ie(d,"visibility",ye.Visible),x(d,"icon"),x(d,"fillColor"),x(d,"tooltip"),x(d,"confirmationLabel"),ie(d,"confirmationLabel",{text:"Tap again to confirm"}),x(d,"links")}function r(u){i.draggingNode.value=u}function a(u){i.receivingNode.value=u}i.placeInAvailableSpace=function(u,c=100,d=U.Right){const m=l.nodes.value.slice().filter(p=>p===u||(d===U.Down||d===U.Up)&&Math.abs(p.position.x-u.position.x)>c||(d===U.Left||d===U.Right)&&Math.abs(p.position.y-u.position.y)>c?!1:!(d===U.Right&&p.position.x<u.position.x-c||d===U.Left&&p.position.x>u.position.x+c||d===U.Up&&p.position.y>u.position.y+c||d===U.Down&&p.position.y<u.position.y-c)).sort(d===U.Right?(p,h)=>p.position.x-h.position.x:d===U.Left?(p,h)=>h.position.x-p.position.x:d===U.Up?(p,h)=>h.position.y-p.position.y:(p,h)=>p.position.y-h.position.y);for(let p=0;p<m.length;p++){const h=m[p],w=d===U.Right||d===U.Left?Math.abs(u.position.x-h.position.x):Math.abs(u.position.y-h.position.y);if(w<c)d===U.Right?u.position.x=h.position.x+c:d===U.Left?u.position.x=h.position.x-c:d===U.Up?u.position.y=h.position.y-c:d===U.Down&&(u.position.y=h.position.y+c);else if(p>0&&w>c)break}},i[lt]=function(){const{nodes:u,types:c,state:d,visibility:m,width:p,height:h,style:w,classes:b,links:v,selectedAction:I,selectedNode:F,mousePosition:S,draggingNode:D,receivingNode:V}=this;return{nodes:u,types:c,state:d,visibility:m,width:p,height:h,style:s(w),classes:b,links:v,selectedAction:I,selectedNode:F,mousePosition:S,draggingNode:D,receivingNode:V,setDraggingNode:r,setReceivingNode:a}};const l=i;return l})}function de(e,t,...n){return Un(e)?e(t,...n):s(e)}function Zn(e){let t=0;return e.nodes.value.forEach(n=>{n.id>=t&&(t=n.id+1)}),t}const Vn={};Ze.on("addLayer",e=>{const t=Wn(e,zr);Vn[e.id]=e.on("postUpdate",n=>{t.forEach(i=>{Object.values(i.types).forEach(r=>r.nodes.value.forEach(a=>{var l;return(l=r.update)==null?void 0:l.call(r,a,n)}))})})});Ze.on("removeLayer",e=>{var t;(t=Vn[e.id])==null||t.call(Vn),Vn[e.id]=void 0});function In(e,t="points",n=0,i=void 0){const r=Ae(e)?e:ft(e);if(r.displayName=t,r.precision=n,r.small=i,!Ae(e)){const a=r[Pt];a.displayName=t,a.precision=n,a.small=i}return r}new o("10^^8");new o("1e100");function ci(e,t){const n=t!=null?t:e.value;return o.eq(e.precision,0)?ht(e.small?n:o.floor(n)):he(n,e.precision,e.small)}Ze.on("setupVue",e=>e.use(Sa));function xu(e="white",t="8px"){return{transform:"scale(1.05, 1.05)",borderColor:"rgba(0, 0, 0, 0.125)",boxShadow:`-4px -4px 4px rgba(0, 0, 0, 0.25) inset, 0 0 ${t} ${e}`,zIndex:1}}const $u=X({props:{visibility:{type:R(Number,Boolean),required:!0},display:{type:R(Object,String,Function),required:!0},style:R(String,Object,Array),classes:R(Object),glowColor:R(String),active:Boolean,floating:Boolean},emits:["selectTab"],setup(e,{emit:t}){const{display:n,glowColor:i,floating:r}=Ee(e),a=Ar(n),l=C(()=>{const c=Se(i);return c==null||c===""?{}:s(r)?xu(c):{boxShadow:`0px 9px 5px -6px ${c}`}});function u(){t("selectTab")}return{selectTab:u,component:a,glowColorStyle:l,unref:s,Visibility:ye,isVisible:Le,isHidden:bn}}});function Eu(e,t,n,i,r,a){var l;return e.isVisible(e.visibility)?(M(),P("button",{key:0,onClick:t[0]||(t[0]=(...u)=>e.selectTab&&e.selectTab(...u)),class:ge(["tabButton",{active:e.active,...e.unref(e.classes)}]),style:qe([{visibility:e.isHidden(e.visibility)?"hidden":void 0},e.glowColorStyle,(l=e.unref(e.style))!=null?l:{}])},[(M(),ee(He(e.component)))],6)):j("",!0)}var Ur=ue($u,[["render",Eu],["__scopeId","data-v-21427abb"]]);const Du=X({props:{visibility:{type:R(Number,Boolean),required:!0},activeTab:{type:R(Object),required:!0},selected:{type:Object,required:!0},tabs:{type:R(Object),required:!0},style:R(String,Object,Array),classes:R(Object),buttonContainerStyle:R(String,Object,Array),buttonContainerClasses:R(Object)},components:{Sticky:ui,TabButton:Ur},setup(e){const{activeTab:t}=Ee(e),n=C(()=>Ct[ae.theme].floatingTabs),i=mt("");kt(()=>{const u=Se(t);if(u==null){i.value="";return}if(xt(u)){i.value=oe(u);return}i.value=oe(s(u.display))});const r=C(()=>{const u=Se(t);return xt(u)||!u?void 0:s(u.classes)}),a=C(()=>{const u=Se(t);return xt(u)||!u?void 0:s(u.style)});function l(u){const{display:c,style:d,classes:m,glowColor:p,visibility:h}=u;return{display:c,style:s(d),classes:m,glowColor:p,visibility:h}}return{floating:n,tabClasses:r,tabStyle:a,Visibility:ye,component:i,gatherButtonProps:l,unref:s,isVisible:Le,isHidden:bn}}});function Pu(e,t,n,i,r,a){var c,d;const l=St("TabButton"),u=St("Sticky");return e.isVisible(e.visibility)?(M(),P("div",{key:0,class:ge(["tab-family-container",{...e.unref(e.classes),...e.tabClasses}]),style:qe([{visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:[],(d=e.tabStyle)!=null?d:[]])},[f(u,{class:ge(["tab-buttons-container",e.unref(e.buttonContainerClasses)]),style:qe(e.unref(e.buttonContainerStyle))},{default:W(()=>[N("div",{class:ge(["tab-buttons",{floating:e.floating}])},[(M(!0),P(ne,null,Pn(e.unref(e.tabs),(m,p)=>(M(),ee(l,zt({onSelectTab:h=>e.selected.value=p,floating:e.floating,key:p,active:e.unref(m.tab)===e.unref(e.activeTab)},e.gatherButtonProps(m)),null,16,["onSelectTab","floating","active"]))),128))],2)]),_:1},8,["class","style"]),e.unref(e.activeTab)?(M(),ee(He(e.unref(e.component)),{key:0})):j("",!0)],6)):j("",!0)}var Tu=ue(Du,[["render",Pu],["__scopeId","data-v-58dbf83a"]]);const Au=Symbol("TabButton"),Fu=Symbol("TabFamily");function Ou(e,t){if(Object.keys(e).length===0)throw console.warn("Cannot create tab family with 0 tabs"),new Error("Cannot create tab family with 0 tabs");const n=ft(Object.keys(e)[0],!1);return Ye(i=>{var l;const r=(l=t==null?void 0:t.call(i,i))!=null?l:{};r.id=tn("tabFamily-"),r.type=Fu,r[bt]=Tu,r.tabs=Object.keys(e).reduce((u,c)=>{const d=e[c]();return d.type=Au,d[bt]=Ur,x(d,"visibility"),ie(d,"visibility",ye.Visible),x(d,"tab"),x(d,"display"),x(d,"classes"),x(d,"style"),x(d,"glowColor"),u[c]=d,u},{}),r.selected=n,r.activeTab=C(()=>{const u=s(a.tabs);if(n.value in u&&Le(u[n.value].visibility))return s(u[n.value].tab);const c=Object.values(u).find(d=>Le(d.visibility));return c?s(c.tab):null}),x(r,"visibility"),ie(r,"visibility",ye.Visible),x(r,"classes"),x(r,"style"),x(r,"buttonContainerClasses"),x(r,"buttonContainerStyle"),r[lt]=function(){const{visibility:u,activeTab:c,selected:d,tabs:m,style:p,classes:h,buttonContainerClasses:w,buttonContainerStyle:b}=this;return{visibility:u,activeTab:c,selected:d,tabs:m,style:s(p),classes:h,buttonContainerClasses:w,buttonContainerStyle:b}};const a=r;return a})}const Gr=o.ln(10);function Bn(e){return e}function Ru(e,t){if(A(t))return t.invert(o.neg(e));throw new Error("Could not invert due to no input being a variable")}function qu(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return g.neg(t.getIntegralFormula(e))}throw new Error("Could not integrate due to no input being a variable")}function Vu(e){return g.neg(e)}function Bu(e,t,n){if(A(t))return t.invert(o.sub(e,we(n)));if(A(n))return n.invert(o.sub(e,we(t)));throw new Error("Could not invert due to no input being a variable")}function Lu(e,t,n){var i,r;if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const a=t.getIntegralFormula(e);return g.times(n,(i=t.innermostVariable)!=null?i:0).add(a)}else if(A(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const a=n.getIntegralFormula(e);return g.times(t,(r=n.innermostVariable)!=null?r:0).add(a)}throw new Error("Could not integrate due to no input being a variable")}function ju(e,t,n){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.add(i,n)}else if(A(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e);return g.add(i,t)}throw new Error("Could not integrate due to no input being a variable")}function zu(e,t,n){if(A(t))return t.invert(o.add(e,we(n)));if(A(n))return n.invert(o.sub(we(t),e));throw new Error("Could not invert due to no input being a variable")}function Uu(e,t,n){var i,r;if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const a=t.getIntegralFormula(e);return g.sub(a,g.times(n,(i=t.innermostVariable)!=null?i:0))}else if(A(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const a=n.getIntegralFormula(e);return g.times(t,(r=n.innermostVariable)!=null?r:0).sub(a)}throw new Error("Could not integrate due to no input being a variable")}function Gu(e,t,n){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.sub(i,n)}else if(A(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e);return g.sub(i,t)}throw new Error("Could not integrate due to no input being a variable")}function Wu(e,t,n){if(A(t))return t.invert(o.div(e,we(n)));if(A(n))return n.invert(o.div(e,we(t)));throw new Error("Could not invert due to no input being a variable")}function Hu(e,t,n){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.times(i,n)}else if(A(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e);return g.times(i,t)}throw new Error("Could not integrate due to no input being a variable")}function Zu(e,t,n){if(A(t))return g.div(e,n);if(A(n))return g.div(e,t);throw new Error("Could not apply substitution due to no input being a variable")}function Yu(e,t,n){if(A(t))return t.invert(o.mul(e,we(n)));if(A(n))return n.invert(o.div(we(t),e));throw new Error("Could not invert due to no input being a variable")}function Xu(e,t,n){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.div(i,n)}else if(A(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e);return g.div(t,i)}throw new Error("Could not integrate due to no input being a variable")}function Ju(e,t,n){if(A(t))return g.mul(e,n);if(A(n))return g.mul(e,t);throw new Error("Could not apply substitution due to no input being a variable")}function Ku(e,t){if(A(t))return t.invert(o.recip(e));throw new Error("Could not invert due to no input being a variable")}function Qu(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.ln(n)}throw new Error("Could not integrate due to no input being a variable")}function ec(e,t){if(A(t))return t.invert(o.pow10(e));throw new Error("Could not invert due to no input being a variable")}function tc(e){return o.ln(e).sub(1).times(e).div(Gr)}function nc(e,t){if(A(t)){const n=Gr.times(e);return t.invert(n.div(n.div(Math.E).lambertw()))}throw new Error("Could not invert due to no input being a variable")}function ic(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e)],evaluate:tc,invert:nc})}throw new Error("Could not integrate due to no input being a variable")}function rc(e,t,n){if(A(t))return t.invert(o.pow(we(n),e));if(A(n))return n.invert(o.root(we(t),e));throw new Error("Could not invert due to no input being a variable")}function ac(e,t){return o.ln(e).sub(1).times(e).div(o.ln(t))}function sc(e,t,n){if(A(t)){const i=o.ln(we(n)).times(e);return t.invert(i.div(i.div(Math.E).lambertw()))}throw new Error("Could not invert due to no input being a variable")}function oc(e,t,n){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e),n],evaluate:ac,invert:sc})}throw new Error("Could not integrate due to no input being a variable")}function lc(e,t){if(A(t))return t.invert(o.pow(2,e));throw new Error("Could not invert due to no input being a variable")}function uc(e){return o.ln(e).sub(1).times(e).div(o.ln(2))}function cc(e,t){if(A(t)){const n=o.ln(2).times(e);return t.invert(n.div(n.div(Math.E).lambertw()))}throw new Error("Could not invert due to no input being a variable")}function dc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e)],evaluate:uc,invert:cc})}throw new Error("Could not integrate due to no input being a variable")}function pc(e,t){if(A(t))return t.invert(o.exp(e));throw new Error("Could not invert due to no input being a variable")}function fc(e){return o.ln(e).sub(1).times(e)}function gc(e,t){if(A(t))return t.invert(o.div(e,o.div(e,Math.E).lambertw()));throw new Error("Could not invert due to no input being a variable")}function mc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e)],evaluate:fc,invert:gc})}throw new Error("Could not integrate due to no input being a variable")}function vc(e,t,n){if(A(t))return t.invert(o.root(e,we(n)));if(A(n))return n.invert(o.ln(e).div(o.ln(we(t))));throw new Error("Could not invert due to no input being a variable")}function hc(e,t,n){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e),r=g.add(n,1);return g.pow(i,r).div(r)}else if(A(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e);return g.pow(t,i).div(g.ln(t))}throw new Error("Could not integrate due to no input being a variable")}function bc(e,t){if(A(t))return t.invert(o.root(e,10));throw new Error("Could not invert due to no input being a variable")}function yc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.pow10(n).div(g.ln(10))}throw new Error("Could not integrate due to no input being a variable")}function wc(e,t,n){if(A(t))return t.invert(o.ln(e).div(we(n)));if(A(n))return n.invert(o.root(we(t),e));throw new Error("Could not invert due to no input being a variable")}function _c(e,t,n){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.pow(n,i).div(g.ln(n))}else if(A(n)){if(!n.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=n.getIntegralFormula(e),r=g.add(t,1);return g.pow(i,r).div(r)}throw new Error("Could not integrate due to no input being a variable")}function Nc(e,t,n){if(A(t))return t.invert(o.root(e,o.recip(we(n))));if(A(n))return n.invert(o.ln(we(t)).div(o.ln(e)));throw new Error("Could not invert due to no input being a variable")}function Cc(e,t,n){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const i=t.getIntegralFormula(e);return g.pow(i,g.recip(n).add(1)).times(n).div(g.add(n,1))}throw new Error("Could not integrate due to no input being a variable")}function kc(e,t){if(A(t))return t.invert(o.ln(e));throw new Error("Could not invert due to no input being a variable")}function Mc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.exp(n)}throw new Error("Could not integrate due to no input being a variable")}function Sc(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){const i=o.minabs(t,1e308).toNumber();return o.tetrate(e,i,n)}function Ic(e,t,n,i){if(A(t))return t.invert(o.ssqrt(e));throw new Error("Could not invert due to no input being a variable")}function xc(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){const i=o.minabs(t,1e308).toNumber();return o.iteratedexp(e,i,new o(n))}function $c(e,t,n,i){if(A(t))return t.invert(o.iteratedlog(e,Math.E,o.minabs(1e308,we(n)).toNumber()));throw new Error("Could not invert due to no input being a variable")}function Ec(e,t=10,n=2){const i=o.minabs(n,1e308).toNumber();return o.iteratedlog(e,t,i)}function Dc(e,t=10){const n=o.minabs(t,1e308).toNumber();return o.slog(e,n)}function Pc(e,t,n){if(A(t))return t.invert(o.tetrate(e,o.minabs(1e308,we(n)).toNumber()));throw new Error("Could not invert due to no input being a variable")}function Tc(e,t,n){const i=o.minabs(t,1e308).toNumber();return o.layeradd(e,i,n)}function Ac(e,t,n,i){if(A(t))return t.invert(o.layeradd(e,o.minabs(1e308,we(n)).negate().toNumber()));throw new Error("Could not invert due to no input being a variable")}function Fc(e,t){if(A(t))return t.invert(o.pow(Math.E,e).times(e));throw new Error("Could not invert due to no input being a variable")}function Oc(e,t){if(A(t))return t.invert(o.tetrate(e,2));throw new Error("Could not invert due to no input being a variable")}function Rc(e,t,n){const i=o.minabs(t,1e308).toNumber();return o.pentate(e,i,n)}function qc(e,t){if(A(t))return t.invert(o.asin(e));throw new Error("Could not invert due to no input being a variable")}function Vc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.cos(n).neg()}throw new Error("Could not integrate due to no input being a variable")}function Bc(e,t){if(A(t))return t.invert(o.acos(e));throw new Error("Could not invert due to no input being a variable")}function Lc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.sin(n)}throw new Error("Could not integrate due to no input being a variable")}function jc(e,t){if(A(t))return t.invert(o.atan(e));throw new Error("Could not invert due to no input being a variable")}function zc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.cos(n).ln().neg()}throw new Error("Could not integrate due to no input being a variable")}function Uc(e,t){if(A(t))return t.invert(o.sin(e));throw new Error("Could not invert due to no input being a variable")}function Gc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.asin(n).times(n).add(g.sqrt(g.sub(1,g.pow(n,2))))}throw new Error("Could not integrate due to no input being a variable")}function Wc(e,t){if(A(t))return t.invert(o.cos(e));throw new Error("Could not invert due to no input being a variable")}function Hc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.acos(n).times(n).sub(g.sqrt(g.sub(1,g.pow(n,2))))}throw new Error("Could not integrate due to no input being a variable")}function Zc(e,t){if(A(t))return t.invert(o.tan(e));throw new Error("Could not invert due to no input being a variable")}function Yc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.atan(n).times(n).sub(g.ln(g.pow(n,2).add(1)).div(2))}throw new Error("Could not integrate due to no input being a variable")}function Xc(e,t){if(A(t))return t.invert(o.asinh(e));throw new Error("Could not invert due to no input being a variable")}function Jc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.cosh(n)}throw new Error("Could not integrate due to no input being a variable")}function Kc(e,t){if(A(t))return t.invert(o.acosh(e));throw new Error("Could not invert due to no input being a variable")}function Qc(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.sinh(n)}throw new Error("Could not integrate due to no input being a variable")}function ed(e,t){if(A(t))return t.invert(o.atanh(e));throw new Error("Could not invert due to no input being a variable")}function td(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.cosh(n).ln()}throw new Error("Could not integrate due to no input being a variable")}function nd(e,t){if(A(t))return t.invert(o.sinh(e));throw new Error("Could not invert due to no input being a variable")}function id(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.asinh(n).times(n).sub(g.pow(n,2).add(1).sqrt())}throw new Error("Could not integrate due to no input being a variable")}function rd(e,t){if(A(t))return t.invert(o.cosh(e));throw new Error("Could not invert due to no input being a variable")}function ad(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.acosh(n).times(n).sub(g.add(n,1).sqrt().times(g.sub(n,1).sqrt()))}throw new Error("Could not integrate due to no input being a variable")}function sd(e,t){if(A(t))return t.invert(o.tanh(e));throw new Error("Could not invert due to no input being a variable")}function od(e,t){if(A(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");const n=t.getIntegralFormula(e);return g.atanh(n).times(n).add(g.sub(1,g.pow(n,2)).ln().div(2))}throw new Error("Could not integrate due to no input being a variable")}function An(e){return(t,n)=>new g({inputs:[t,n],evaluate:e,invert:Bn})}function A(e){return e instanceof Ie&&e.hasVariable()}function we(e,t){return e instanceof Ie?e.evaluate(t):s(e)}function ld(){return g.pow(this,2).div(2)}function ud(){return this}const Fe=class{constructor(e){this.negate=this.neg,this.negated=this.neg,this.sgn=this.sign,this.plus=this.add,this.subtract=this.sub,this.minus=this.sub,this.multiply=this.mul,this.times=this.mul,this.divide=this.div,this.divideBy=this.div,this.dividedBy=this.div,this.reciprocal=this.recip,this.reciprocate=this.recip,this.logarithm=this.log;let t;"inputs"in e&&(e.inputs=e.inputs.map(n=>typeof n=="object"&&Pt in n?n[Pt]:n)),"variable"in e?(typeof e.variable=="object"&&Pt in e.variable&&(e.variable=e.variable[Pt]),t=this.setupVariable(e)):"evaluate"in e?t=this.setupFormula(e):t=this.setupConstant(e),this.inputs=t.inputs,this.internalVariables=t.internalVariables,this.innermostVariable=t.innermostVariable,this.internalEvaluate=t.internalEvaluate,this.internalInvert=t.internalInvert,this.internalIntegrate=t.internalIntegrate,this.internalIntegrateInner=t.internalIntegrateInner,this.applySubstitution=t.applySubstitution}setupVariable({variable:e}){return{inputs:[e],internalVariables:1,innermostVariable:e,internalIntegrate:ld,internalIntegrateInner:ud,applySubstitution:Bn}}setupConstant({inputs:e}){if(e.length!==1)throw new Error("Evaluate function is required if inputs is not length 1");return{inputs:e,internalVariables:0}}setupFormula(e){var h,w;const{inputs:t,evaluate:n,invert:i,integrate:r,integrateInner:a,applySubstitution:l}=e,u=t.reduce((b,v)=>b+(v instanceof Fe?v.internalVariables:0),0),c=t.find(b=>b instanceof Fe&&b.hasVariable()),d=u===1?c==null?void 0:c.innermostVariable:void 0,m=(h=c==null?void 0:c.isInvertible())!=null?h:!1,p=(w=c==null?void 0:c.isIntegrable())!=null?w:!1;return{inputs:t,internalEvaluate:n,internalInvert:m?i:void 0,internalIntegrate:p?r:void 0,internalIntegrateInner:a,applySubstitution:l,innermostVariable:d,internalVariables:u}}isInvertible(){return this.hasVariable()&&(this.internalInvert!=null||this.internalEvaluate==null)}isIntegrable(){return this.hasVariable()&&this.internalIntegrate!=null}isIntegralInvertible(){return this.isIntegrable()?this.getIntegralFormula().isInvertible():!1}hasVariable(){return this.internalVariables===1}evaluate(e){var t,n,i;return(i=(n=(t=this.internalEvaluate)==null?void 0:t.call(this,...this.inputs.map(r=>we(r,e))))!=null?n:this.hasVariable()?e:null)!=null?i:we(this.inputs[0])}equals(e){return this.inputs.length===e.inputs.length&&this.inputs.every((t,n)=>t instanceof Fe&&e.inputs[n]instanceof Fe?t.equals(e.inputs[n]):!(t instanceof Fe)&&!(e.inputs[n]instanceof Fe)&&o.eq(s(t),s(e.inputs[n])))&&this.internalEvaluate===e.internalEvaluate&&this.internalInvert===e.internalInvert&&this.internalIntegrate===e.internalIntegrate&&this.internalVariables===e.internalVariables}static constant(e){return new g({inputs:[e]})}static variable(e){return new g({variable:e})}static step(e,t,n){const i=L(0),r=n(g.variable(i)),a=fe(t);function l(c){return o.lt(c,s(a))?c:(i.value=o.sub(c,s(a)),o.add(r.evaluate(),s(a)))}function u(c,d){if(A(d)&&r.isInvertible())return o.gt(c,s(a))&&(c=o.add(r.invert(o.sub(c,s(a))),s(a))),d.invert(c);throw new Error("Could not invert due to no input being a variable")}return new g({inputs:[e],evaluate:l,invert:r.isInvertible()&&r.hasVariable()?u:void 0})}static if(e,t,n,i){const r=L(0),a=g.variable(r),l=n(a),u=i==null?void 0:i(a),c=fe(t);function d(p){return s(c)?(r.value=p,l.evaluate()):u?(r.value=p,u.evaluate()):p}function m(p,h){if(!A(h)||!l.isInvertible()||u!=null&&!u.isInvertible())throw new Error("Could not invert due to no input being a variable");return s(c)?h.invert(l.invert(p)):u?h.invert(u.invert(p)):h.invert(p)}return new g({inputs:[e],evaluate:d,invert:l.isInvertible()&&l.hasVariable()?m:void 0})}static conditional(e,t,n,i){return g.if(e,t,n,i)}static abs(e){return new g({inputs:[e],evaluate:o.abs})}static neg(e){return new g({inputs:[e],evaluate:o.neg,invert:Ru,applySubstitution:Vu,integrate:qu})}static sign(e){return new g({inputs:[e],evaluate:o.sign})}static round(e){return new g({inputs:[e],evaluate:o.round})}static floor(e){return new g({inputs:[e],evaluate:o.floor})}static ceil(e){return new g({inputs:[e],evaluate:o.ceil})}static trunc(e){return new g({inputs:[e],evaluate:o.trunc})}static add(e,t){return new g({inputs:[e,t],evaluate:o.add,invert:Bu,integrate:Lu,integrateInner:ju,applySubstitution:Bn})}static sub(e,t){return new g({inputs:[e,t],evaluate:o.sub,invert:zu,integrate:Uu,integrateInner:Gu,applySubstitution:Bn})}static mul(e,t){return new g({inputs:[e,t],evaluate:o.mul,invert:Wu,integrate:Hu,applySubstitution:Zu})}static div(e,t){return new g({inputs:[e,t],evaluate:o.div,invert:Yu,integrate:Xu,applySubstitution:Ju})}static recip(e){return new g({inputs:[e],evaluate:o.recip,invert:Ku,integrate:Qu})}static clamp(e,t,n){return new g({inputs:[e,t,n],evaluate:o.clamp,invert:Bn})}static pLog10(e){return new g({inputs:[e],evaluate:o.pLog10})}static absLog10(e){return new g({inputs:[e],evaluate:o.absLog10})}static log10(e){return new g({inputs:[e],evaluate:o.log10,invert:ec,integrate:ic})}static log(e,t){return new g({inputs:[e,t],evaluate:o.log,invert:rc,integrate:oc})}static log2(e){return new g({inputs:[e],evaluate:o.log2,invert:lc,integrate:dc})}static ln(e){return new g({inputs:[e],evaluate:o.ln,invert:pc,integrate:mc})}static pow(e,t){return new g({inputs:[e,t],evaluate:o.pow,invert:vc,integrate:hc})}static pow10(e){return new g({inputs:[e],evaluate:o.pow10,invert:bc,integrate:yc})}static pow_base(e,t){return new g({inputs:[e,t],evaluate:o.pow_base,invert:wc,integrate:_c})}static root(e,t){return new g({inputs:[e,t],evaluate:o.root,invert:Nc,integrate:Cc})}static factorial(e){return new g({inputs:[e],evaluate:o.factorial})}static gamma(e){return new g({inputs:[e],evaluate:o.gamma})}static lngamma(e){return new g({inputs:[e],evaluate:o.lngamma})}static exp(e){return new g({inputs:[e],evaluate:o.exp,invert:kc,integrate:Mc})}static sqr(e){return g.pow(e,2)}static sqrt(e){return g.root(e,2)}static cube(e){return g.pow(e,3)}static cbrt(e){return g.root(e,3)}static tetrate(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){return new g({inputs:[e,t,n],evaluate:Sc,invert:Ic})}static iteratedexp(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){return new g({inputs:[e,t,n],evaluate:xc,invert:$c})}static iteratedlog(e,t=10,n=1){return new g({inputs:[e,t,n],evaluate:Ec})}static slog(e,t=10){return new g({inputs:[e,t],evaluate:Dc,invert:Pc})}static layeradd10(e,t){return new g({inputs:[e,t],evaluate:o.layeradd10})}static layeradd(e,t,n=10){return new g({inputs:[e,t,n],evaluate:Tc,invert:Ac})}static lambertw(e){return new g({inputs:[e],evaluate:o.lambertw,invert:Fc})}static ssqrt(e){return new g({inputs:[e],evaluate:o.ssqrt,invert:Oc})}static pentate(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){return new g({inputs:[e,t,n],evaluate:Rc})}static sin(e){return new g({inputs:[e],evaluate:o.sin,invert:Uc,integrate:Vc})}static cos(e){return new g({inputs:[e],evaluate:o.cos,invert:Wc,integrate:Lc})}static tan(e){return new g({inputs:[e],evaluate:o.tan,invert:Zc,integrate:zc})}static asin(e){return new g({inputs:[e],evaluate:o.asin,invert:qc,integrate:Gc})}static acos(e){return new g({inputs:[e],evaluate:o.acos,invert:Bc,integrate:Hc})}static atan(e){return new g({inputs:[e],evaluate:o.atan,invert:jc,integrate:Yc})}static sinh(e){return new g({inputs:[e],evaluate:o.sinh,invert:nd,integrate:Jc})}static cosh(e){return new g({inputs:[e],evaluate:o.cosh,invert:rd,integrate:Qc})}static tanh(e){return new g({inputs:[e],evaluate:o.tanh,invert:sd,integrate:td})}static asinh(e){return new g({inputs:[e],evaluate:o.asinh,invert:Xc,integrate:id})}static acosh(e){return new g({inputs:[e],evaluate:o.acosh,invert:Kc,integrate:ad})}static atanh(e){return new g({inputs:[e],evaluate:o.atanh,invert:ed,integrate:od})}step(e,t){return g.step(this,e,t)}if(e,t){return g.if(this,e,t)}conditional(e,t){return g.if(this,e,t)}abs(){return g.abs(this)}neg(){return g.neg(this)}sign(){return g.sign(this)}round(){return g.round(this)}floor(){return g.floor(this)}ceil(){return g.ceil(this)}trunc(){return g.trunc(this)}add(e){return g.add(this,e)}sub(e){return g.sub(this,e)}mul(e){return g.mul(this,e)}div(e){return g.div(this,e)}recip(){return g.recip(this)}max(e){return g.max(this,e)}min(e){return g.min(this,e)}maxabs(e){return g.maxabs(this,e)}minabs(e){return g.minabs(this,e)}clamp(e,t){return g.clamp(this,e,t)}clampMin(e){return g.clampMin(this,e)}clampMax(e){return g.clampMax(this,e)}pLog10(){return g.pLog10(this)}absLog10(){return g.absLog10(this)}log10(){return g.log10(this)}log(e){return g.log(this,e)}log2(){return g.log2(this)}ln(){return g.ln(this)}pow(e){return g.pow(this,e)}pow10(){return g.pow10(this)}pow_base(e){return g.pow_base(this,e)}root(e){return g.root(this,e)}factorial(){return g.factorial(this)}gamma(){return g.gamma(this)}lngamma(){return g.lngamma(this)}exp(){return g.exp(this)}sqr(){return g.pow(this,2)}sqrt(){return g.root(this,2)}cube(){return g.pow(this,3)}cbrt(){return g.root(this,3)}tetrate(e=2,t=o.fromComponents_noNormalize(1,0,1)){return g.tetrate(this,e,t)}iteratedexp(e=2,t=o.fromComponents_noNormalize(1,0,1)){return g.iteratedexp(this,e,t)}iteratedlog(e=10,t=1){return g.iteratedlog(this,e,t)}slog(e=10){return g.slog(this,e)}layeradd10(e){return g.layeradd10(this,e)}layeradd(e,t){return g.layeradd(this,e,t)}lambertw(){return g.lambertw(this)}ssqrt(){return g.ssqrt(this)}pentate(e=2,t=o.fromComponents_noNormalize(1,0,1)){return g.pentate(this,e,t)}sin(){return g.sin(this)}cos(){return g.cos(this)}tan(){return g.tan(this)}asin(){return g.asin(this)}acos(){return g.acos(this)}atan(){return g.atan(this)}sinh(){return g.sinh(this)}cosh(){return g.cosh(this)}tanh(){return g.tanh(this)}asinh(){return g.asinh(this)}acosh(){return g.acosh(this)}atanh(){return g.atanh(this)}};let Ie=Fe;Ie.negate=Fe.neg;Ie.negated=Fe.neg;Ie.sgn=Fe.sign;Ie.plus=Fe.add;Ie.subtract=Fe.sub;Ie.minus=Fe.sub;Ie.multiply=Fe.mul;Ie.times=Fe.mul;Ie.divide=Fe.div;Ie.divideBy=Fe.div;Ie.dividedBy=Fe.div;Ie.reciprocal=Fe.recip;Ie.reciprocate=Fe.recip;Ie.max=An(o.max);Ie.min=An(o.min);Ie.minabs=An(o.minabs);Ie.maxabs=An(o.maxabs);Ie.clampMin=An(o.clampMin);Ie.clampMax=An(o.clampMax);Ie.logarithm=Fe.log;class g extends Ie{invert(t){if(this.internalInvert&&this.hasVariable())return this.internalInvert.call(this,t,...this.inputs);if(this.inputs.length===1&&this.hasVariable())return t;throw new Error("Cannot invert non-invertible formula")}evaluateIntegral(t){if(!this.isIntegrable())throw new Error("Cannot evaluate integral of formula without integral");return this.getIntegralFormula().evaluate(t)}invertIntegral(t){if(!this.isIntegrable()||!this.getIntegralFormula().isInvertible())throw new Error("Cannot invert integral of formula without invertible integral");return this.getIntegralFormula().invert(t)}calculateConstantOfIntegration(){const t=this.getIntegralFormula().evaluate(1),n=o.add(this.evaluate(0),this.evaluate(1)).div(2);return o.sub(n,t)}getIntegralFormula(t){if(this.integralFormula!=null&&t==null)return this.integralFormula;if(t==null){if(this.applySubstitution==null){if(t=[],this.internalIntegrate==null)throw new Error("Cannot integrate formula with non-integrable operation");let n=this.internalIntegrate.call(this,t,...this.inputs);t.forEach(i=>n=i(n)),this.integralFormula=n}else if(this.internalIntegrate)this.integralFormula=this.internalIntegrate.call(this,void 0,...this.inputs);else if(this.inputs.length===1&&this.internalEvaluate==null&&this.hasVariable())this.integralFormula=this;else throw new Error("Cannot integrate formula without variable");return this.integralFormula}else{if(this.applySubstitution==null)throw new Error("Cannot have two complex operations in an integrable formula");if(t.push(n=>this.applySubstitution.call(this,n,...this.inputs)),this.internalIntegrateInner)return this.internalIntegrateInner.call(this,t,...this.inputs);if(this.internalIntegrate)return this.internalIntegrate.call(this,t,...this.inputs);if(this.inputs.length===1&&this.internalEvaluate==null&&this.hasVariable())return this;throw new Error("Cannot integrate formula without variable")}}}function Wr(e,t,n=!0,i,r=o.dInf){const a=fe(n),l=fe(i),u=fe(r);return C(()=>{var h,w,b,v;const c=s(u);if(o.eq(c,1))return o.gte(t.value,e.evaluate())?o.dOne:o.dZero;const d=s(a),m=(h=s(l))!=null?h:d?10:0;let p=0;if(o.gt(c,m)){if(!e.isInvertible())throw new Error("Cannot calculate max affordable of non-invertible formula with more maxBulkAmount than directSum");if(d){if(!e.isIntegralInvertible())throw new Error("Cannot calculate max affordable of formula with non-invertible integral");p=o.floor(e.invertIntegral(o.add(t.value,e.evaluateIntegral()))).sub((w=s(e.innermostVariable))!=null?w:0)}else p=o.floor(e.invert(t.value))}if(p=o.clampMax(p,c),m>0){p=o.sub(p,m).clampMin(0);let I;for(d?I=Lt(e,p,!0,0):I=e.evaluate(o.add((b=s(e.innermostVariable))!=null?b:0,p));o.lt(p,c)&&o.lt(p,Number.MAX_SAFE_INTEGER);){const F=e.evaluate(p.add((v=s(e.innermostVariable))!=null?v:0));if(o.add(I,F).lte(t.value))p=p.add(1),I=o.add(I,F);else break}}return p})}function Lt(e,t,n=!0,i){var c;if(o.eq(t,1))return e.evaluate();const r=(c=s(e.innermostVariable))!=null?c:0;let a=o.add(t,r);const l=a;i!=null||(i=n?10:0),a=a.sub(i).clampMin(r);let u=0;if(o.gt(t,i)){if(!e.isInvertible())throw new Error("Cannot calculate cost with indirect sum of non-invertible formula");if(n){if(!e.isIntegrable())throw new Error("Cannot calculate cost with cumulative cost of non-integrable formula");if(u=o.sub(e.evaluateIntegral(a),e.evaluateIntegral()),l.gt(1e308))return o.add(u,o.sub(l,a).times(e.evaluate(a)))}else if(u=e.evaluate(a),a=a.add(1),l.gt(1e308))return o.sub(l,a).add(1).times(u)}for(let d=a.toNumber();d<l.toNumber();d++)u=o.add(u,e.evaluate(d));return u}function pn(e){return Ye(t=>{const{addend:n,description:i,enabled:r,smallerIsBetter:a}=e.call(t,t),l=fe(n),u=fe(i),c=r==null?void 0:fe(r);return{apply:d=>o.add(d,s(l)),invert:d=>o.sub(d,s(l)),getFormula:d=>g.add(d,l),enabled:c,description:i==null?void 0:K(()=>f("div",{class:"modifier-container"},[s(u)!=null?f("span",{class:"modifier-description"},[Mt(s(u))]):null,f("span",{class:"modifier-amount",style:(a===!0?o.gt(s(l),0):o.lt(s(l),0))?"color: var(--danger)":""},[o.gte(s(l),0)?"+":"",Jt(s(l))])]))}})}function Re(e){return Ye(t=>{const{multiplier:n,description:i,enabled:r,smallerIsBetter:a}=e.call(t,t),l=fe(n),u=fe(i),c=r==null?void 0:fe(r);return{apply:d=>o.times(d,s(l)),invert:d=>o.div(d,s(l)),getFormula:d=>g.times(d,l),enabled:c,description:i==null?void 0:K(()=>f("div",{class:"modifier-container"},[s(u)!=null?f("span",{class:"modifier-description"},[Mt(s(u))]):null,f("span",{class:"modifier-amount",style:(a===!0?o.gt(s(l),1):o.lt(s(l),1))?"color: var(--danger)":""},[E("\xD7"),Jt(s(l))])]))}})}function Ti(e){return Ye(t=>{const{exponent:n,description:i,enabled:r,supportLowNumbers:a,smallerIsBetter:l}=e.call(t,t),u=fe(n),c=fe(i),d=r==null?void 0:fe(r);return{apply:m=>{let p=m;return a&&(p=o.add(p,1)),p=o.pow(p,s(u)),a&&(p=o.sub(p,1)),p},invert:m=>{let p=m;return a&&(p=o.add(p,1)),p=o.root(p,s(u)),a&&(p=o.sub(p,1)),p},getFormula:m=>a?g.add(m,1).pow(u).sub(1):g.pow(m,u),enabled:d,description:i==null?void 0:K(()=>f("div",{class:"modifier-container"},[s(c)!=null?f("span",{class:"modifier-description"},[Mt(s(c)),a?" (+1 effective)":null]):null,f("span",{class:"modifier-amount",style:(l===!0?o.gt(s(u),1):o.lt(s(u),1))?"color: var(--danger)":""},[E("^"),Jt(s(u))])]))}})}function Dt(e){return Ye(()=>{const t=e();return{apply:n=>t.filter(i=>s(i.enabled)!==!1).reduce((i,r)=>r.apply(i),n),invert:t.every(n=>n.invert!=null)?n=>t.filter(i=>s(i.enabled)!==!1).reduceRight((i,r)=>r.invert(i),n):void 0,getFormula:t.every(n=>n.getFormula!=null)?n=>t.filter(i=>s(i.enabled)!==!1).reduce((i,r)=>r.getFormula(i),n):void 0,enabled:t.some(n=>n.enabled!=null)?C(()=>t.filter(n=>s(n.enabled)!==!1).length>0):void 0,description:t.some(n=>n.description!=null)?K(()=>f(ne,null,[t.filter(n=>s(n.enabled)!==!1).map(n=>s(n.description)).filter(n=>n).map(Mt)])):void 0}})}const jn=g.variable(0).add(1),mi={id:"deselect",icon:"close",tooltip:e=>({text:"tools"in e.state?"Disconnect tools":"Disconnect resources"}),onClick(e){var t;Array.isArray((t=e.state)==null?void 0:t.data)?e.state={...e.state,data:[]}:"resources"in e.state?e.state={...e.state,resources:[]}:"tools"in e.state&&(e.state={...e.state,tools:[]}),_.board.selectedAction.value=null,_.board.selectedNode.value=null},visibility:e=>{var t;return Array.isArray((t=e.state)==null?void 0:t.data)?e.state.data.length>0:"resources"in e.state?e.state.resources.length>0:"tools"in e.state?e.state.tools.length>0:!1}},Ft={id:"toggle",icon:"bolt",tooltip:e=>({text:e.state.powered?"Turn Off":`Turn On - Always runs for ${ht(_.nextPowerCost.value)} energy/s`}),onClick(e){e.state={...e.state,powered:!e.state.powered},_.board.selectedAction.value=null},fillColor:e=>e.state.powered?"var(--accent1)":"var(--locked)"};function wn(e,t=1/0){const n=e(g.variable(0));return{id:"moreConnections",icon:"hub",formula:n,tooltip(i){return{text:`Increase Connections - ${ht(n.evaluate(i.state.maxConnections))} energy`}},confirmationLabel:i=>o.gte(_.energy.value,n.evaluate(i.state.maxConnections))?{text:"Tap again to confirm"}:{text:"Cannot afford",color:"var(--danger)"},onClick(i){const r=n.evaluate(i.state.maxConnections);o.gte(_.energy.value,r)&&(_.energy.value=o.sub(_.energy.value,r)),i.state={...i.state,maxConnections:o.add(i.state.maxConnections,1)},_.board.selectedAction.value=null},visibility:i=>o.add(i.state.maxConnections,_.computedBonusConnectionsModifier.value).lt(t)}}function Hr(e,t){var n,i;if(((n=_.board.draggingNode.value)==null?void 0:n.type)==="resource"){const r=((i=_.board.draggingNode.value)==null?void 0:i.state).type,{maxConnections:a,resources:l}=e.state;return l.includes(r)?{text:"Disconnect",color:"var(--accent2)"}:o.add(a,_.computedBonusConnectionsModifier.value).lte(l.length)?{text:"Max connections",color:"var(--danger)"}:{text:t(r),color:"var(--accent2)"}}return null}function cd(e,t){var n,i;if(((n=_.board.draggingNode.value)==null?void 0:n.type)==="passive"){const r=(i=_.board.draggingNode.value)==null?void 0:i.state,{maxConnections:a,tools:l}=e.state;return l.includes(r)?{text:"Disconnect",color:"var(--accent2)"}:o.add(a,_.computedBonusConnectionsModifier.value).lte(l.length)?{text:"Max connections",color:"var(--danger)"}:{text:t(r),color:"var(--accent2)"}}return null}function vi(e,t){var n,i;if(((n=_.board.draggingNode.value)==null?void 0:n.type)==="portal"){const r=((i=_.board.draggingNode.value)==null?void 0:i.state).id,{maxConnections:a,portals:l}=e.state;return l.includes(r)?{text:"Disconnect",color:"var(--accent2)"}:o.add(a,_.computedBonusConnectionsModifier.value).lte(l.length)?{text:"Max connections",color:"var(--danger)"}:{text:t(r),color:"var(--accent2)"}}return null}function Zr(e,t){if(t.type!=="resource")return!1;const n=t.state.type,{maxConnections:i,resources:r}=e.state;return r.includes(n)?!0:!o.add(i,_.computedBonusConnectionsModifier.value).lte(r.length)}function Yr(e,t){if(t.type!=="resource")return;const n=t.state.type,i=e.state.resources;i.includes(n)?e.state={...e.state,resources:i.filter(r=>r!==n)}:e.state={...e.state,resources:[...i,n]},_.board.selectedNode.value=e}function dd(e,t){if(t.type!=="passive")return!1;const n=t.state,{maxConnections:i,tools:r}=e.state;return r.includes(n)?!0:!o.add(i,_.computedBonusConnectionsModifier.value).lte(r.length)}function pd(e,t){if(t.type!=="passive")return;const n=t.state,i=e.state.tools;i.includes(n)?e.state={...e.state,tools:i.filter(r=>r!==n)}:e.state={...e.state,tools:[...i,n]},_.board.selectedNode.value=e}function hi(e,t){if(t.type!=="portal")return!1;const n=t.state.id,{maxConnections:i,portals:r}=e.state;return r.includes(n)?!0:!o.add(i,_.computedBonusConnectionsModifier.value).lte(r.length)}function bi(e,t){if(t.type!=="portal")return;const n=t.state.id,{portals:i}=e.state;i.includes(n)?e.state={...e.state,portals:i.filter(r=>r!==n)}:e.state={...e.state,portals:[...i,n]},_.board.selectedNode.value=e}function ve(e){return e===_.board.selectedNode.value||e.state.powered}function dt(e){return _.empowerer.value!=null&&ve(_.empowerer.value)&&_.empowerer.value.state.tools.includes(e)}function fd(e){var a,l,u;const t=(u=(l=(a=_.resourceNodes.value[e])==null?void 0:a.state)==null?void 0:l.amount)!=null?u:0,n=_.resourceLevels.value[e],i=Lt(jn,n,!0),r=Lt(jn,o.add(n,1),!0);return o.sub(t,i).max(0).div(o.sub(r,i)).toNumber()}function on(e,t,n){if(t.value){const i=t.value.state,r=i[n],a=i.maxConnections;o.gt(r.length,o.add(a,e))&&(t.value.state={...t.value.state,[n]:r.slice(0,o.add(a,e).toNumber())})}}const gd={key:0},md={key:0,class:"mark star"},vd=["src"],hd=X({__name:"MarkNode",props:{mark:{type:[Boolean,String]}},setup(e){return(t,n)=>e.mark?(M(),P("div",gd,[e.mark===!0?(M(),P("div",md)):(M(),P("img",{key:1,class:"mark",src:e.mark},null,8,vd))])):j("",!0)}});var Yn=ue(hd,[["__scopeId","data-v-2207999f"]]);const bd=X({__name:"Node",props:{id:null},setup(e){const n=Ee(e),i=ai(zi,()=>{}),r=ai(Ui,()=>{}),a=mt(null),l=C(()=>a.value&&a.value.parentElement);return gt([l,n.id],([u,c],[d,m])=>{d&&r(s(m)),u&&i(c,u)}),_r(()=>r(s(n.id))),(u,c)=>(M(),P("div",{class:"node",ref_key:"node",ref:a},null,512))}});var Xn=ue(bd,[["__scopeId","data-v-a48cb382"]]),yd=X({props:{display:{type:R(Object,String,Function),required:!0},visibility:{type:R(Number,Boolean),required:!0},style:R(Object,String,Array),classes:R(Object),onClick:Function,onHold:Function,canClick:{type:R(Boolean),required:!0},small:Boolean,mark:R(Boolean,String),id:{type:String,required:!0}},components:{Node:Xn,MarkNode:Yn},setup(e){const{display:t,onClick:n,onHold:i}=Ee(e),r=mt("");kt(()=>{var m;const u=Se(t);if(u==null){r.value="";return}if(xt(u)){r.value=oe(u);return}const c=oe((m=u.title)!=null?m:"","h3"),d=oe(u.description,"div");r.value=oe(K(()=>f("span",null,[u.title!=null?f("div",null,[f(c,null,null)]):null,f(d,null,null)])))});const{start:a,stop:l}=Tr(n,i);return{start:a,stop:l,comp:r,Visibility:ye,isVisible:Le,isHidden:bn,unref:s}}});function wd(e,t,n,i,r,a){var c;const l=St("MarkNode"),u=St("Node");return e.isVisible(e.visibility)?(M(),P("button",{key:0,style:qe([{visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:[]]),onClick:t[0]||(t[0]=(...d)=>e.onClick&&e.onClick(...d)),onMousedown:t[1]||(t[1]=(...d)=>e.start&&e.start(...d)),onMouseleave:t[2]||(t[2]=(...d)=>e.stop&&e.stop(...d)),onMouseup:t[3]||(t[3]=(...d)=>e.stop&&e.stop(...d)),onTouchstartPassive:t[4]||(t[4]=(...d)=>e.start&&e.start(...d)),onTouchendPassive:t[5]||(t[5]=(...d)=>e.stop&&e.stop(...d)),onTouchcancelPassive:t[6]||(t[6]=(...d)=>e.stop&&e.stop(...d)),class:ge({feature:!0,clickable:!0,can:e.unref(e.canClick),locked:!e.unref(e.canClick),small:e.small,...e.unref(e.classes)})},[e.unref(e.comp)?(M(),ee(He(e.unref(e.comp)),{key:0})):j("",!0),f(l,{mark:e.unref(e.mark)},null,8,["mark"]),f(u,{id:e.id},null,8,["id"])],38)):j("",!0)}var Xr=ue(yd,[["render",wd],["__scopeId","data-v-211328c0"]]);const Jr=Symbol("Clickable");function _d(e,...t){const n=t.reduce((i,r)=>{var a;return Object.assign(i,(a=r.getPersistentData)==null?void 0:a.call(r))},{});return Ye(i=>{var l,u,c;const r=(l=e==null?void 0:e.call(i,i))!=null?l:{};r.id=tn("clickable-"),r.type=Jr,r[bt]=Xr;for(const d of t)(u=d.preConstruct)==null||u.call(d,r);if(Object.assign(r,n),x(r,"visibility"),ie(r,"visibility",ye.Visible),x(r,"canClick"),ie(r,"canClick",!0),x(r,"classes"),x(r,"style"),x(r,"mark"),x(r,"display"),r.onClick){const d=r.onClick.bind(r);r.onClick=function(m){s(r.canClick)!==!1&&d(m)}}if(r.onHold){const d=r.onHold.bind(r);r.onHold=function(){s(r.canClick)!==!1&&d()}}for(const d of t)(c=d.postConstruct)==null||c.call(d,r);const a=t.reduce((d,m)=>{var p;return Object.assign(d,(p=m.getGatheredProps)==null?void 0:p.call(m,r))},{});return r[lt]=function(){const{display:d,visibility:m,style:p,classes:h,onClick:w,onHold:b,canClick:v,small:I,mark:F,id:S}=this;return{display:d,visibility:m,style:s(p),classes:h,onClick:w,onHold:b,canClick:v,small:I,mark:F,id:S,...a}},r})}function Nd(e,t,n=[]){n=n.length===0?Wn(e,Jr):n;const i=typeof t=="function"?C(t):t;return e.on("update",()=>{s(i)&&n.filter(r=>s(r.canClick)).forEach(r=>{var a;return(a=r.onClick)==null?void 0:a.call(r)})})}const Cd=["x1","y1","x2","y2"],kd=X({__name:"Link",props:{link:null,startNode:null,endNode:null,boundingRect:null},setup(e){const n=Ee(e),i=C(()=>{const a=n.startNode.value.rect,l=n.boundingRect.value,u=l?{x:a.x+a.width/2-l.x,y:a.y+a.height/2-l.y}:{x:0,y:0};return n.link.value.offsetStart&&(u.x+=n.link.value.offsetStart.x,u.y+=n.link.value.offsetStart.y),u}),r=C(()=>{const a=n.endNode.value.rect,l=n.boundingRect.value,u=l?{x:a.x+a.width/2-l.x,y:a.y+a.height/2-l.y}:{x:0,y:0};return n.link.value.offsetEnd&&(u.x+=n.link.value.offsetEnd.x,u.y+=n.link.value.offsetEnd.y),u});return(a,l)=>(M(),P("line",zt({"stroke-width":"15px",stroke:"white"},e.link,{x1:s(i).x,y1:s(i).y,x2:s(r).x,y2:s(r).y}),null,16,Cd))}});const Md=X({__name:"Links",props:{links:null},setup(e){var c;const n=Qt(e,"links"),i=L(null),r=ai(Gi,L({})),a=ai(Wi,L(void 0)),l=L((c=i.value)==null?void 0:c.getBoundingClientRect());gt(a,()=>{var d;return l.value=(d=i.value)==null?void 0:d.getBoundingClientRect()}),pi(()=>{var d;return l.value=(d=i.value)==null?void 0:d.getBoundingClientRect()});const u=C(()=>{var m,p;const d=r.value;return(p=(m=n.value)==null?void 0:m.filter(h=>{var w,b;return((w=d[h.startNode.id])==null?void 0:w.rect)&&((b=d[h.startNode.id])==null?void 0:b.rect)}))!=null?p:[]});return(d,m)=>(M(),P(ne,null,[s(u)?(M(),P("svg",ya(zt({key:0},d.$attrs)),[(M(!0),P(ne,null,Pn(s(u),(p,h)=>(M(),ee(kd,{key:h,link:p,boundingRect:l.value,startNode:s(r)[p.startNode.id],endNode:s(r)[p.endNode.id]},null,8,["link","boundingRect","startNode","endNode"]))),128))],16)):j("",!0),N("div",{ref_key:"resizeListener",ref:i,class:"resize-listener"},null,512)],64))}});var Sd=ue(Md,[["__scopeId","data-v-063f6d6b"]]);X({props:{nodes:{type:R(Array),required:!0},leftSideNodes:R(Array),rightSideNodes:R(Array),branches:R(Array)},components:{Links:Sd},setup(e){const{nodes:t,leftSideNodes:n,rightSideNodes:i}=Ee(e),r=mt();kt(()=>{const u=Se(t);r.value=oe(K(()=>f(ne,null,[u.map(c=>f("span",{class:"row tree-row",style:"margin: 50px auto;"},[c.map(Mt)]))])))});const a=mt();kt(()=>{const u=Se(n);a.value=u?oe(K(()=>f("span",{class:"left-side-nodes small"},[u.map(Mt)]))):""});const l=mt();return kt(()=>{const u=Se(i);l.value=u?oe(K(()=>f("span",{class:"side-nodes small"},[u.map(Mt)]))):""}),{unref:s,nodesComp:r,leftNodesComp:a,rightNodesComp:l}}});X({props:{display:R(Object,String,Function),visibility:{type:R(Number,Boolean),required:!0},style:R(String,Object,Array),classes:R(Object),onClick:Function,onHold:Function,color:R(String),glowColor:R(String),canClick:{type:R(Boolean),required:!0},mark:R(Boolean,String),id:{type:String,required:!0}},components:{MarkNode:Yn,Node:Xn},setup(e){const{onClick:t,onHold:n,display:i}=Ee(e),r=Tn(i),{start:a,stop:l}=Tr(t,n);return{start:a,stop:l,comp:r,unref:s,Visibility:ye,isCoercableComponent:xt,isVisible:Le,isHidden:bn}}});function Ln(e){const t=[],n={};let i=!1;function r(){return i||(t.push(...e()),n.base=t.map(u=>fe(u.base)),n.baseText=t.map(u=>fe(u.baseText)),n.visible=t.map(u=>fe(u.visible)),n.title=t.map(u=>fe(u.title)),n.subtitle=t.map(u=>fe(u.subtitle)),i=!0),t}const a=ft({},!1);return[K(()=>{const u=r();let c=!0;const d=u.map((m,p)=>{var F,S,D;if(s(n.visible[p])===!1)return null;const h=f("h3",{onClick:()=>a.value[p]=!a.value[p],style:"cursor: pointer"},[f("span",{class:"modifier-toggle"+(s(a.value[p])?" collapsed":"")},[E("\u25BC")]),s(n.title[p]),s(n.subtitle[p])!=null?f("span",{class:"subtitle"},[E(" ("),s(n.subtitle[p]),E(")")]):null]),w=s(a.value[p])?null:f(ne,null,[f("div",{class:"modifier-container"},[f("span",{class:"modifier-description"},[Mt((F=s(n.baseText[p]))!=null?F:"Base")]),f("span",{class:"modifier-amount"},[he((S=s(n.base[p]))!=null?S:1),m.unit])]),m.modifier.description==null?null:Mt(s(m.modifier.description))]),b=!c;c=!1;const v=(D=s(n.base[p]))!=null?D:1,I=m.modifier.apply(v);return f(ne,null,[b?f("br",null,null):null,f("div",{style:{"--unit":ae.alignUnits&&m.unit!=null?"'"+m.unit+"'":""}},[h,f("br",null,null),w,f("hr",null,null),f("div",{class:"modifier-container"},[f("span",{class:"modifier-description"},[E("Total")]),f("span",{class:"modifier-amount",style:(m.smallerIsBetter===!0?o.gt(I,v!=null?v:1):o.lt(I,v!=null?v:1))?"color: var(--danger)":""},[Jt(I),m.unit])])])])});return f(ne,null,[d])}),a]}function Ai(e,t,n){const i=fe(t),r=fe(n);return C(()=>{const a=s(i),l=s(r);return o.gte(e.value,l)?"Now":o.lte(a,0)?"Never":gi(o.sub(l,e.value).div(a))})}function un(e,t,n=1){const i=fe(t),r=fe(n);if(!e.hasVariable())throw new Error("Cannot create formula preview if the formula does not have a variable");return K(()=>{var a;if(s(i)){const l=Jt(e.evaluate()),u=Jt(e.evaluate(o.add(s((a=e.innermostVariable)!=null?a:0),s(r))));return f(ne,null,[f("b",null,[f("i",null,[l,E(" \u2192 "),u])])])}return f(ne,null,[Jt(e.evaluate())])})}const It={dirt:120,sand:60,gravel:40,wood:30,stone:24,coal:20,copper:15,iron:12,silver:10,gold:8,emerald:6,platinum:5,diamond:4,berylium:3,unobtainium:2,ultimatum:1},ln=Object.keys(It),Te={dirt:{cost:1e3,name:"Pickaxe",type:"passive",state:"dirt"},sand:{cost:1e4,name:"Dowsing Rod",type:"dowsing",state:{resources:[],maxConnections:1,powered:!1}},gravel:{cost:1e5,name:"Ore Processor",type:"passive",state:"gravel"},wood:{cost:1e6,name:"Quarry",type:"quarry",state:{resources:[],maxConnections:1,powered:!1,progress:0}},stone:{cost:1e7,name:"Energizer",type:"passive",state:"stone"},coal:{cost:1e8,name:"Tool Empowerer",type:"empowerer",state:{tools:[],maxConnections:1,powered:!1}},copper:{cost:1e9,name:"Book",type:"passive",state:"copper"},iron:{cost:1e10,name:"Portal Generator",type:"portalGenerator",state:{tier:void 0,influences:[]}},silver:{cost:1e12,name:"Robotics",type:"passive",state:"silver"},gold:{cost:1e15,name:"Booster",type:"booster",state:{portals:[],maxConnections:1,powered:!1,level:1}},emerald:{cost:1e19,name:"Artificial Intelligence",type:"passive",state:"emerald"},platinum:{cost:1e24,name:"Upgrader",type:"upgrader",state:{portals:[],maxConnections:1,powered:!1}},diamond:{cost:1e30,name:"Machine Learning",type:"passive",state:"diamond"},berylium:{cost:1e37,name:"Automator",type:"automator",state:{portals:[],maxConnections:1,powered:!1}},unobtainium:{cost:1e45,name:"National Grid",type:"passive",state:"unobtainium"},ultimatum:{cost:1e54,name:"Investments",type:"investments",state:{portals:[],maxConnections:1,powered:!1}}},di={dirt:"Replicator",sand:"Metal Detector",gravel:"Neural Networks",wood:"Mining Laser",stone:"BOGO Coupon",coal:"Planar Intelligence",copper:"Efficient Code",iron:"Trade Agreements",silver:"Machine Synergizer",gold:"XP Market",emerald:"Efficient Portals",platinum:"Time Dilation",diamond:"Paypal",berylium:"Tiered Mining",unobtainium:"Overclocked Portals",ultimatum:"Rebates"},Id={dirt:{description:e=>e?"Quadruples mining speed":"Doubles mining speed"},gravel:{description:e=>e?"Quadruples mine ore drops":"Doubles mine ore drops"},stone:{description:e=>e?"Quadruples energy gain":"Doubles energy gain"},copper:{description:e=>e?"Material level is 20% stronger":"Material level is 10% stronger"},silver:{description:e=>e?"Quadruples each plane's resource gain":"Doubles each plane's resource gain"},diamond:{description:e=>e?"+20% plane's resource gain per upgrade bought":"+10% plane's resource gain per upgrade bought"},emerald:{description:e=>e?"+2% plane's resource gain per minute active":"+1% plane's resource gain per minute active"},unobtainium:{description:e=>e?"+2 max connections per machine":"+1 max connections per machine"},dirtRelic:{description:e=>e?"Upgrades apply thrice":"Upgrades apply twice"},sandRelic:{description:e=>e?"Treasure's 2 tiers stronger":"Treasure's 1 tier stronger"},gravelRelic:{description:e=>e?"+2% plane's resource gain per repeatable purchase":"+1% plane's resource gain per repeatable purchase"},woodRelic:{description:e=>e?"(Relics)^2 boost mine speed":"Relics boost mine speed"},stoneRelic:{description:e=>e?"2 free levels for repeatables":"1 free level for repeatables"},coalRelic:{description:e=>e?"(Treasures)^2 boost planar speed":"Treasures boost planar speed"},copperRelic:{description:e=>e?"Power 2 machines free":"Power 1 machine free"},ironRelic:{description:e=>e?"Conversions give triple output":"Conversions give double output"},silverRelic:{description:e=>e?"(Power machines)^2 boost ore dropped":"Power machines boost ore dropped"},goldRelic:{description:e=>e?"Each treasure quadruples XP gain":"Each treasure doubles XP gain"},emeraldRelic:{description:e=>e?"Creating portals costs a third the energy":"Creating portals costs half the energy"},platinumRelic:{description:e=>e?"Triple dimensions' tick rate":"Double dimensions' tick rate"},diamondRelic:{description:e=>e?"Repeatables/dimensions buy max at once":"Repeatables buy max at once"},beryliumRelic:{description:e=>e?"ln(energy) boosts planar speed":"log(energy) boosts planar speed"},unobtainiumRelic:{description:e=>e?"Upgrades/repeatables/dimensions/prestige no longer spend on purchase":"Upgrades/repeatables no longer spend on purchase"}},Vt={increaseResources:{display:"+resource",description:e=>{const t=e.data;return t.length===0?"Increase resource odds - Drag a resource to me!":t.length===1?`Increase ${t[0]}'s odds`:`Increase ${t.length} resources' odds`},cost:2,initialData:[]},decreaseResources:{display:"-resource",description:e=>{const t=e.data;return t.length===0?"Decrease resource odds - Drag a resource to me!":t.length===1?`Decrease ${t[0]}'s odds`:`Decrease ${t.length} resources' odds`},cost:2,initialData:[]},increaseLength:{display:"+length",description:"Increase length",cost:100,initialData:void 0},increaseCaches:{display:"+caches",description:"Increase caches odds",cost:10,initialData:void 0},increaseGens:{display:"+gens",description:"Increase generators odds",cost:10,initialData:void 0},increaseInfluences:{display:"+influences",description:"Increase influences odds",cost:10,initialData:void 0},increaseEnergyMults:{display:"+energy mults",description:"Increase energy mults odds",cost:10,initialData:void 0},increaseResourceMults:{display:"+resource mults",description:"Increase resource mults odds",cost:10,initialData:void 0},increaseDiff:{display:"+diff",description:"Increase difficulty/rewards odds",cost:10,initialData:void 0},decreaseDiff:{display:"-diff",description:"Decrease difficulty/rewards odds",cost:10,initialData:void 0},increaseRewards:{display:"+rewards",description:"Increase rewards level",cost:1e4,initialData:void 0},relic:{display:"+relic",description:"Max length/difficulty, add tier-unique relic",cost:1e6,initialData:void 0}},Fi=g.variable(0).add(8).times(2).pow10();const xd=X({__name:"Spacer",props:{width:{default:"8px"},height:{default:"17px"}},setup(e){return(t,n)=>(M(),P("div",{style:qe({width:e.width,height:e.height})},null,4))}});function On(e){return Ye(t=>{var i;const n=e.call(t,t);return n.partialDisplay=r=>f("span",{style:s(n.requirementMet)?"":"color: var(--danger)"},[ci(n.resource,n.cost instanceof g?Lt(n.cost,r!=null?r:1,s(n.cumulativeCost),s(n.directSum)):s(n.cost))," ",n.resource.displayName]),n.display=r=>f("div",null,[s(n.requiresPay)?"Costs: ":"Requires: ",ci(n.resource,n.cost instanceof g?Lt(n.cost,r!=null?r:1,s(n.cumulativeCost),s(n.directSum)):s(n.cost))," ",n.resource.displayName]),x(n,"visibility"),ie(n,"visibility",ye.Visible),x(n,"cost"),x(n,"requiresPay"),ie(n,"requiresPay",!0),x(n,"cumulativeCost"),ie(n,"cumulativeCost",!0),x(n,"maxBulkAmount"),ie(n,"maxBulkAmount",1),x(n,"directSum"),ie(n,"pay",function(r){const a=n.cost instanceof g?Lt(n.cost,r!=null?r:1,s(n.cumulativeCost),s(n.directSum)):s(n.cost);n.resource.value=o.sub(n.resource.value,a).max(0)}),n.canMaximize=C(()=>{var u;if(!(n.cost instanceof g))return!1;const r=s(n.maxBulkAmount);if(o.lte(r,1))return!1;const a=s(n.cumulativeCost),l=(u=s(n.directSum))!=null?u:a?10:0;return o.lte(r,l)?!0:!(!n.cost.isInvertible()||a===!0&&!n.cost.isIntegrable())}),n.cost instanceof g?n.requirementMet=Wr(n.cost,n.resource,(i=n.cumulativeCost)!=null?i:!0,n.directSum,n.maxBulkAmount):n.requirementMet=C(()=>o.gte(n.resource.value,s(n.cost))),n})}function Ji(e){return Ye(()=>({requirementMet:C(()=>Le(e.visibility)),visibility:ye.None,requiresPay:!1}))}function $d(e,t){return Ye(()=>({requirementMet:fe(e),partialDisplay:t==null?void 0:K(()=>Mt(t)),display:t==null?void 0:K(()=>f(ne,null,[E("Req: "),Mt(t)])),visibility:t==null?ye.None:ye.Visible,requiresPay:!1}))}function yi(e){if(At(e))return e.every(yi);const t=s(e.requirementMet);return typeof t=="boolean"?t:o.gt(t,0)}function Kr(e){if(At(e))return e.map(Kr).reduce(o.min);const t=s(e.requirementMet);return typeof t=="boolean"?t?o.dInf:0:o.gt(t,1)&&s(e.canMaximize)!==!0?1:t}function wi(e,t=1){var n,i;if(At(e)&&(e=e.filter(r=>Le(r.visibility)),e.length===1&&(e=e[0])),At(e)){e=e.filter(l=>"partialDisplay"in l);const r=e.filter(l=>s(l.requiresPay)),a=e.filter(l=>!s(l.requiresPay));return f(ne,null,[r.length>0?f("div",null,[E("Costs:")," ",pr(r.map(l=>l.partialDisplay(t)),f(ne,null,[E(", ")]))]):null,a.length>0?f("div",null,[E("Requires:")," ",pr(a.map(l=>l.partialDisplay(t)),f(ne,null,[E(", ")]))]):null])}return(i=(n=e.display)==null?void 0:n.call(e))!=null?i:f(ne,null,null)}function Qr(e,t=1){var n;At(e)?e.filter(i=>s(i.requiresPay)).forEach(i=>{var r;return(r=i.pay)==null?void 0:r.call(i,t)}):s(e.requiresPay)&&((n=e.pay)==null||n.call(e,t))}var Ed=X({props:{visibility:{type:R(Number,Boolean),required:!0},display:R(Object,String,Function),earned:{type:R(Boolean),required:!0},requirements:R(Object,Array),image:R(String),style:R(String,Object,Array),classes:R(Object),mark:R(Boolean,String),small:R(Boolean),id:{type:String,required:!0}},components:{Node:Xn,MarkNode:Yn},setup(e){const{display:t,requirements:n,earned:i}=Ee(e),r=mt("");return kt(()=>{const a=Se(t);if(a==null){r.value="";return}if(xt(a)){r.value=oe(a);return}const l=oe(a.requirement?a.requirement:K(()=>{var d;return wi((d=Se(n))!=null?d:[])}),"h3"),u=oe(a.effectDisplay||"","b"),c=Se(i)?oe(a.optionsDisplay||"","span"):"";r.value=oe(K(()=>f("span",null,[f(l,null,null),a.effectDisplay!=null?f("div",null,[f(u,null,null)]):null,a.optionsDisplay!=null?f("div",{class:"equal-spaced"},[f(c,null,null)]):null])))}),{comp:r,unref:s,Visibility:ye,isVisible:Le,isHidden:bn}}});function Dd(e,t,n,i,r,a){var c;const l=St("MarkNode"),u=St("Node");return e.isVisible(e.visibility)?(M(),P("div",{key:0,style:qe([{visibility:e.isHidden(e.visibility)?"hidden":void 0,backgroundImage:e.earned&&e.image&&`url(${e.image})`||""},(c=e.unref(e.style))!=null?c:[]]),class:ge({feature:!0,achievement:!0,locked:!e.unref(e.earned),done:e.unref(e.earned),small:e.unref(e.small),...e.unref(e.classes)})},[e.comp?(M(),ee(He(e.comp),{key:0})):j("",!0),f(l,{mark:e.unref(e.mark)},null,8,["mark"]),f(u,{id:e.id},null,8,["id"])],6)):j("",!0)}var Pd=ue(Ed,[["render",Dd],["__scopeId","data-v-5673325a"]]);const Td=fi(),Ad=Symbol("Achievement");let xn=function(e){return e.All="all",e.Configurable="configurable",e.Incomplete="incomplete",e.None="none",e}({});function Fd(e,...t){const n=ft(!1,!1),i=t.reduce((r,a)=>{var l;return Object.assign(r,(l=a.getPersistentData)==null?void 0:l.call(a))},{});return Ye(r=>{var c,d,m;const a=(c=e==null?void 0:e.call(r,r))!=null?c:{};a.id=tn("achievement-"),a.type=Ad,a[bt]=Pd;for(const p of t)(d=p.preConstruct)==null||d.call(p,a);a.earned=n,a.complete=function(){var h,w;n.value=!0;const p=a;if((h=p.onComplete)==null||h.call(p),p.display!=null&&s(p.showPopups)===!0){const b=s(p.display);let v;xt(b)?v=oe(b):b.requirement!=null?v=oe(b.requirement):v=wi((w=p.requirements)!=null?w:[]),Td.info(f("div",null,[f("h3",null,[E("Achievement earned!")]),f("div",null,[f(v,null,null)])]))}},Object.assign(a,i),x(a,"visibility"),ie(a,"visibility",ye.Visible);const l=a.visibility;a.visibility=wa(()=>{const p=s(a.display);switch(ae.msDisplay){default:case xn.All:return s(l);case xn.Configurable:return s(a.earned)&&!(p!=null&&typeof p=="object"&&"optionsDisplay"in p)?ye.None:s(l);case xn.Incomplete:return s(a.earned)?ye.None:s(l);case xn.None:return ye.None}}),x(a,"display"),x(a,"mark"),x(a,"small"),x(a,"image"),x(a,"style"),x(a,"classes"),x(a,"showPopups"),ie(a,"showPopups",!0);for(const p of t)(m=p.postConstruct)==null||m.call(p,a);const u=t.reduce((p,h)=>{var w;return Object.assign(p,(w=h.getGatheredProps)==null?void 0:w.call(h,a))},{});if(a[lt]=function(){const{visibility:p,display:h,requirements:w,earned:b,image:v,style:I,classes:F,mark:S,small:D,id:V}=this;return{visibility:p,display:h,requirements:w,earned:b,image:v,style:s(I),classes:F,mark:S,small:D,id:V,...u}},a.requirements){const p=a,h=[Ji(p),$d(()=>!p.earned.value),...At(a.requirements)?a.requirements:[a.requirements]];kt(()=>{ae.active===Q.id&&yi(h)&&p.complete()})}return a})}Ze.on("loadSettings",e=>{ie(e,"msDisplay",xn.All)});const Od=Object.values(xn).map(e=>({label:tt(e),value:e}));Es(K(()=>f(Yi,{title:K(()=>f("span",{class:"option-title"},[E("Show achievements"),f("desc",null,[E("Select which achievements to display based on criterias.")])])),options:Od,"onUpdate:modelValue":e=>ae.msDisplay=e,modelValue:ae.msDisplay},null)));const Rd=X({props:{progress:{type:R(String,Object,Number),required:!0},width:{type:R(Number),required:!0},height:{type:R(Number),required:!0},direction:{type:R(String),required:!0},display:R(Object,String,Function),visibility:{type:R(Number,Boolean),required:!0},style:R(Object,String,Array),classes:R(Object),borderStyle:R(Object,String,Array),textStyle:R(Object,String,Array),baseStyle:R(Object,String,Array),fillStyle:R(Object,String,Array),mark:R(Boolean,String),id:{type:String,required:!0}},components:{MarkNode:Yn,Node:Xn},setup(e){const{progress:t,width:n,height:i,direction:r,display:a}=Ee(e),l=C(()=>{let d=t.value instanceof o?t.value.toNumber():Number(t.value);return(1-Math.min(Math.max(d,0),1))*100}),u=C(()=>{const d={width:Se(n)+.5+"px",height:Se(i)+.5+"px"};switch(s(r)){case U.Up:d.clipPath=`inset(${l.value}% 0% 0% 0%)`,d.width=Se(n)+1+"px";break;case U.Down:d.clipPath=`inset(0% 0% ${l.value}% 0%)`,d.width=Se(n)+1+"px";break;case U.Right:d.clipPath=`inset(0% ${l.value}% 0% 0%)`;break;case U.Left:d.clipPath=`inset(0% 0% 0% ${l.value} + '%)`;break;case U.Default:d.clipPath="inset(0% 50% 0% 0%)";break}return d}),c=Tn(a);return{normalizedProgress:l,barStyle:u,component:c,unref:s,Visibility:ye,isVisible:Le,isHidden:bn}}});function qd(e,t,n,i,r,a){var c,d,m,p,h,w,b;const l=St("MarkNode"),u=St("Node");return e.isVisible(e.visibility)?(M(),P("div",{key:0,style:qe([{width:e.unref(e.width)+"px",height:e.unref(e.height)+"px",visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:{}]),class:ge({bar:!0,...e.unref(e.classes)})},[N("div",{class:"overlayTextContainer border",style:qe([{width:e.unref(e.width)+"px",height:e.unref(e.height)+"px"},(d=e.unref(e.borderStyle))!=null?d:{}])},[e.component?(M(),P("span",{key:0,class:"overlayText",style:qe(e.unref(e.textStyle))},[(M(),ee(He(e.component)))],4)):j("",!0)],4),N("div",{class:"border",style:qe([{width:e.unref(e.width)+"px",height:e.unref(e.height)+"px"},(m=e.unref(e.style))!=null?m:{},(p=e.unref(e.baseStyle))!=null?p:{},(h=e.unref(e.borderStyle))!=null?h:{}])},[N("div",{class:"fill",style:qe([e.barStyle,(w=e.unref(e.style))!=null?w:{},(b=e.unref(e.fillStyle))!=null?b:{}])},null,4)],4),f(l,{mark:e.unref(e.mark)},null,8,["mark"]),f(u,{id:e.id},null,8,["id"])],6)):j("",!0)}var Vd=ue(Rd,[["render",qd],["__scopeId","data-v-6bd06b56"]]);const Bd=Symbol("Bar");function Ld(e,...t){const n=t.reduce((i,r)=>{var a;return Object.assign(i,(a=r.getPersistentData)==null?void 0:a.call(r))},{});return Ye(i=>{var l,u;const r=e.call(i,i);r.id=tn("bar-"),r.type=Bd,r[bt]=Vd;for(const c of t)(l=c.preConstruct)==null||l.call(c,r);Object.assign(r,n),x(r,"visibility"),ie(r,"visibility",ye.Visible),x(r,"width"),x(r,"height"),x(r,"direction"),x(r,"style"),x(r,"classes"),x(r,"borderStyle"),x(r,"baseStyle"),x(r,"textStyle"),x(r,"fillStyle"),x(r,"progress"),x(r,"display"),x(r,"mark");for(const c of t)(u=c.postConstruct)==null||u.call(c,r);const a=t.reduce((c,d)=>{var m;return Object.assign(c,(m=d.getGatheredProps)==null?void 0:m.call(d,r))},{});return r[lt]=function(){const{progress:c,width:d,height:m,direction:p,display:h,visibility:w,style:b,classes:v,borderStyle:I,textStyle:F,baseStyle:S,fillStyle:D,mark:V,id:re}=this;return{progress:c,width:d,height:m,direction:p,display:h,visibility:w,style:s(b),classes:v,borderStyle:I,textStyle:F,baseStyle:S,fillStyle:D,mark:V,id:re,...a}},r})}function jd(e,...t){return Ye(n=>{var r,a;const i=e.call(n,n);for(const l of t)(r=l.preConstruct)==null||r.call(l,i);i.formula=i.formula(g.variable(i.baseResource)),i.currentGain==null&&(i.currentGain=C(()=>{let l=o.floor(i.formula.evaluate(i.baseResource.value)).max(0);return s(i.buyMax)===!1&&(l=l.min(1)),l})),i.actualGain==null&&(i.actualGain=i.currentGain),i.currentAt==null&&(i.currentAt=C(()=>i.formula.invert(o.floor(s(i.currentGain))))),i.nextAt==null&&(i.nextAt=C(()=>i.formula.invert(o.floor(s(i.currentGain)).add(1)))),i.convert==null&&(i.convert=function(){var u;const l=s(i.currentGain);i.gainResource.value=o.add(i.gainResource.value,l),i.spend(l),(u=i.onConvert)==null||u.call(i,l)}),i.spend==null&&(i.spend=function(){i.baseResource.value=0}),x(i,"currentGain"),x(i,"actualGain"),x(i,"currentAt"),x(i,"nextAt"),x(i,"buyMax"),ie(i,"buyMax",!0);for(const l of t)(a=l.postConstruct)==null||a.call(l,i);return i})}function zd(e){return jd(e)}function Ud(e,t,n=1,i=o.dInf){const r=fe(n),a=fe(i);e.on("preUpdate",l=>{const u=s(r);o.neq(u,0)&&(t.gainResource.value=o.add(t.gainResource.value,o.times(u,l).times(o.ceil(s(t.actualGain)))).min(s(a)).max(t.gainResource.value))})}const ea=Symbol("Repeatable");function mr(e,...t){const n=ft(0),i=t.reduce((r,a)=>{var l;return Object.assign(r,(l=a.getPersistentData)==null?void 0:l.call(a))},{});return Ye(r=>{var h,w,b;const a=e.call(r,r);a.id=tn("repeatable-"),a.type=ea,a[bt]=Xr;for(const v of t)(h=v.preConstruct)==null||h.call(v,a);a.amount=n,a.amount[en]=(w=a.initialAmount)!=null?w:0,Object.assign(a,i);const l={requirementMet:C(()=>o.sub(s(a.limit),a.amount.value)),requiresPay:!1,visibility:ye.None},u=Ji(a);At(a.requirements)?(a.requirements.unshift(u),a.requirements.push(l)):a.requirements=[u,a.requirements,l],a.maxed=C(()=>o.gte(a.amount.value,s(a.limit))),x(a,"classes");const c=a.classes;a.classes=C(()=>{const v=s(c)||{};return a.maxed.value&&(v.bought=!0),v}),a.amountToIncrease=C(()=>o.clampMin(Kr(a.requirements),1)),a.canClick=C(()=>yi(a.requirements));const d=a.onClick;a.onClick=function(v){const I=a;!s(I.canClick)||(Qr(a.requirements,s(a.amountToIncrease)),I.amount.value=o.add(I.amount.value,1),d==null||d(v))},x(a,"display");const m=a.display;a.display=K(()=>{var I,F,S;const v=s(m);if(xt(v)){const D=oe(v);return f(D,null,null)}if(v!=null){const D=a,V=oe((I=v.title)!=null?I:"","h3"),re=oe((F=v.description)!=null?F:""),Z=oe((S=v.effectDisplay)!=null?S:"");return f("span",null,[v.title==null?null:f("div",null,[f(V,null,null)]),v.description==null?null:f(re,null,null),v.showAmount===!1?null:f("div",null,[f("br",null,null),f(ne,null,[E("Amount: "),ht(D.amount.value)]),o.isFinite(s(D.limit))?f(ne,null,[E(" / "),ht(s(D.limit))]):void 0]),v.effectDisplay==null?null:f("div",null,[f("br",null,null),E("Currently: "),f(Z,null,null)]),D.maxed.value?null:f("div",null,[f("br",null,null),wi(D.requirements,s(a.amountToIncrease))])])}return""}),x(a,"visibility"),ie(a,"visibility",ye.Visible),x(a,"limit"),ie(a,"limit",o.dInf),x(a,"style"),x(a,"mark"),x(a,"small");for(const v of t)(b=v.postConstruct)==null||b.call(v,a);const p=t.reduce((v,I)=>{var F;return Object.assign(v,(F=I.getGatheredProps)==null?void 0:F.call(I,a))},{});return a[lt]=function(){const{display:v,visibility:I,style:F,classes:S,onClick:D,canClick:V,small:re,mark:Z,id:z}=this;return{display:v,visibility:I,style:s(F),classes:S,onClick:D,canClick:V,small:re,mark:Z,id:z,...p}},a})}const Gd=Symbol("Reset");function Wd(e){return Ye(t=>{const n=e.call(t,t);return n.id=tn("reset-"),n.type=Gd,n.reset=function(){var r;const i=a=>{if(a!=null&&typeof a=="object")if(en in a){const l=a;l.value=l[en]}else!(a instanceof o)&&!Ae(a)&&Object.values(a).forEach(l=>i(l))};s(n.thingsToReset).forEach(i),Ze.emit("reset",n),(r=n.onReset)==null||r.call(n)},x(n,"thingsToReset"),n})}const ni={};Ze.on("removeLayer",e=>{var t;(t=ni[e.id])==null||t.call(ni),ni[e.id]=void 0});function Oi(e,t){return x(t,"display"),x(t,"classes"),x(t,"style"),x(t,"direction"),ie(t,"direction",U.Up),x(t,"xoffset"),x(t,"yoffset"),t.pinnable&&(t.pinned=ft(!1,!1)),jt(()=>{t.pinnable&&("pinned"in e?(console.error("Cannot add pinnable tooltip to element that already has a property called 'pinned'"),t.pinnable=!1,Or(t.pinned)):e.pinned=t.pinned);const n=e[bt];e[bt]=Pe;const i=e[lt].bind(e);e[lt]=function(){const{display:a,classes:l,style:u,direction:c,xoffset:d,yoffset:m,pinned:p}=this;return{element:{[bt]:n,[lt]:i},display:a,classes:l,style:s(u),direction:c,xoffset:d,yoffset:m,pinned:p}}.bind(t)}),t}var Hd=X({props:{display:{type:R(String,Object,Function),required:!0},visibility:{type:R(Number,Boolean),required:!0},style:R(String,Object,Array),classes:R(Object),requirements:{type:Object,required:!0},canPurchase:{type:R(Boolean),required:!0},bought:{type:R(Boolean),required:!0},mark:R(Boolean,String),id:{type:String,required:!0},purchase:{type:Function,required:!0}},components:{Node:Xn,MarkNode:Yn},setup(e){const{display:t,requirements:n,bought:i}=Ee(e),r=mt("");return kt(()=>{const a=Se(t);if(a==null){r.value="";return}if(xt(a)){r.value=oe(a);return}const l=oe(a.title||"","h3"),u=oe(a.description,"div"),c=oe(a.effectDisplay||"");r.value=oe(K(()=>f("span",null,[a.title!=null?f("div",null,[f(l,null,null)]):null,f(u,null,null),a.effectDisplay!=null?f("div",null,[E("Currently: "),f(c,null,null)]):null,i.value?null:f(ne,null,[f("br",null,null),wi(n.value)])])))}),{component:r,unref:s,Visibility:ye,isVisible:Le,isHidden:bn}}});const Zd=["disabled"];function Yd(e,t,n,i,r,a){var c;const l=St("MarkNode"),u=St("Node");return e.isVisible(e.visibility)?(M(),P("button",{key:0,style:qe([{visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:{}]),onClick:t[0]||(t[0]=(...d)=>e.purchase&&e.purchase(...d)),class:ge({feature:!0,upgrade:!0,can:e.unref(e.canPurchase),locked:!e.unref(e.canPurchase),bought:e.unref(e.bought),...e.unref(e.classes)}),disabled:!e.unref(e.canPurchase)},[e.unref(e.component)?(M(),ee(He(e.unref(e.component)),{key:0})):j("",!0),f(l,{mark:e.unref(e.mark)},null,8,["mark"]),f(u,{id:e.id},null,8,["id"])],14,Zd)):j("",!0)}var Xd=ue(Hd,[["render",Yd],["__scopeId","data-v-9be6bac0"]]);const Ki=Symbol("Upgrade");function vr(e,...t){const n=ft(!1,!1),i=t.reduce((r,a)=>{var l;return Object.assign(r,(l=a.getPersistentData)==null?void 0:l.call(a))},{});return Ye(r=>{var c,d;const a=e.call(r,r);a.id=tn("upgrade-"),a.type=Ki,a[bt]=Xd;for(const m of t)(c=m.preConstruct)==null||c.call(m,a);a.bought=n,Object.assign(a,i),a.canPurchase=C(()=>!n.value&&yi(a.requirements)),a.purchase=function(){var p;const m=a;!s(m.canPurchase)||(Qr(a.requirements),n.value=!0,(p=m.onPurchase)==null||p.call(m))};const l=Ji(a);At(a.requirements)?a.requirements.unshift(l):a.requirements=[l,a.requirements],x(a,"visibility"),ie(a,"visibility",ye.Visible),x(a,"classes"),x(a,"style"),x(a,"display"),x(a,"mark");for(const m of t)(d=m.postConstruct)==null||d.call(m,a);const u=t.reduce((m,p)=>{var h;return Object.assign(m,(h=p.getGatheredProps)==null?void 0:h.call(p,a))},{});return a[lt]=function(){const{display:m,visibility:p,style:h,classes:w,requirements:b,canPurchase:v,bought:I,mark:F,id:S,purchase:D}=this;return{display:m,visibility:p,style:s(h),classes:w,requirements:b,canPurchase:v,bought:I,mark:F,id:S,purchase:D,...u}},a})}function Jd(e,t,n=[]){n=n.length===0?Wn(e,Ki):n;const i=Un(t)?C(t):t;e.on("update",()=>{s(i)&&n.forEach(r=>r.purchase())})}function Kd(e,t,n,i){return function(){e>>>=0,t>>>=0,n>>>=0,i>>>=0;let r=e+t|0;return e=t^t>>>9,t=n+(n<<3)|0,n=n<<21|n>>>11,i=i+1|0,r=r+i|0,n=n+r|0,(r>>>0)/4294967296}}const Qd={1:["b","c","d","f","g","h","i","j","k","l","m","n","p","q","r","s","t","v","w","x","y","z"],2:["a","e","o","u"],3:["br","cr","dr","fr","gr","pr","str","tr","bl","cl","fl","gl","pl","sl","sc","sk","sm","sn","sp","st","sw","ch","sh","th","wh"],4:["ae","ai","ao","au","a","ay","ea","ei","eo","eu","e","ey","ua","ue","ui","uo","u","uy","ia","ie","iu","io","iy","oa","oe","ou","oi","o","oy"],5:["turn","ter","nus","rus","tania","hiri","hines","gawa","nides","carro","rilia","stea","lia","lea","ria","nov","phus","mia","nerth","wei","ruta","tov","zuno","vis","lara","nia","liv","tera","gantu","yama","tune","ter","nus","cury","bos","pra","thea","nope","tis","clite"],6:["una","ion","iea","iri","illes","ides","agua","olla","inda","eshan","oria","ilia","erth","arth","orth","oth","illon","ichi","ov","arvis","ara","ars","yke","yria","onoe","ippe","osie","one","ore","ade","adus","urn","ypso","ora","iuq","orix","apus","ion","eon","eron","ao","omia"]},hr=[[1,2,5],[2,3,6],[3,4,5],[4,3,6],[3,4,2,5],[2,1,3,6],[3,4,2,5],[4,3,1,6],[3,4,1,4,5],[4,1,4,3,6]];function Ri(e){const t=hr[Math.floor(e()*hr.length)];let n="";for(let i=0;i<t.length;i++){const r=Qd[t[i]];n+=r[Math.floor(e()*r.length)]}return tt(n)}const ep={1:["a","e","i","o","u"],2:["ph","th","ch","sh","br","cr","dr","fr","gr","pr","tr","str","sc","sk","sm","sn","sp","st","sw"],3:["ae","ai","ao","au","ay","ea","ei","eo","eu","ey","ua","ue","ui","uo","uy","ia","ie","iu","io","iy","oa","oe","ou","oi","oy"],4:["morp","flux","syn","void","rift","dyn","nov","chron","lum","par","ter","psy","phan","man","grav","pyr","cry","hydr","elec","kin","nan","omni"],5:["ance","ation","esis","ergy","tide","al","ism","ity","mancy","urgy","pathy","port","shift","burst","pulse","wave","field","storm","force","blade"]},br=[[1,2,1,4,5],[1,4,5],[2,1,4,5],[1,2,3,4,5],[3,4,5]];function Sn(e){const t=br[Math.floor(e()*br.length)];let n="";for(let i=0;i<t.length;i++){const r=ep[t[i]];n+=r[Math.floor(e()*r.length)]}return tt(n)}function Rn(e,t){const[n,i,r]=tp(...e),[a,l,u]=np(Math.floor(t()*360),i,r);return`rgb(${a*255}, ${l*255}, ${u*255})`}function tp(e,t,n){const i=Math.max(e,t,n),r=i-Math.min(e,t,n),a=r&&(i==e?(t-n)/r:i==t?2+(n-e)/r:4+(e-t)/r);return[60*(a<0?a+6:a),i&&r/i,i]}function np(e,t,n){const i=(r,a=(r+e/60)%6)=>n-n*t*Math.max(Math.min(a,4-a,1),0);return[i(5),i(3),i(1)]}const yr=fi();function ta(e,t,n,i){return Hi(e,function(){const r=Kd(0,n>>0,n>>32,1);for(let O=0;O<12;O++)r();const a=Ri(r),l=Rn([.64,.75,.55],r),u=Rn([.18,.2,.25],r),c=In(0,Ri(r)),d=ft(0),m=ln.indexOf(t);let p=r();const h=i.reduce((O,B)=>(O[B.type]=B.data,O),{});"increaseDiff"in h&&(p=p/2+.5),"decreaseDiff"in h&&(p=p/2),"relic"in h&&(p=1);const w=p+m+1,b="increaseRewards"in h?w+1:w;let v="relic"in h?m+2:Math.ceil(r()*(m+2));"increaseLength"in h&&v++;const I=[],F=Dt(()=>[...I,Re(()=>({multiplier:()=>_.isEmpowered("silver")?4:2,description:()=>(_.isEmpowered("silver")?"Empowered ":"")+Te.silver.name,enabled:()=>_.toolNodes.value.silver!=null})),Re(()=>({multiplier:()=>(_.isEmpowered("diamond")?2:1)*Ke.filter(O=>O.bought.value).length/10,description:()=>(_.isEmpowered("diamond")?"Empowered ":"")+Te.diamond.name,enabled:()=>_.toolNodes.value.diamond!=null})),Re(()=>({multiplier:()=>o.div(d.value,6e3).times(_.isEmpowered("emerald")?2:1).add(1),description:()=>(_.isEmpowered("emerald")?"Empowered ":"")+Te.emerald.name,enabled:()=>_.toolNodes.value.emerald!=null}))]),S=C(()=>F.apply(0)),D=[],V={};function re({feature:O,canClick:B,modifier:Ne,cost:Ge,previewModifier:Cn,showETA:Qe,previewCost:Ht}){B=fe(B),Qe=fe(Qe);const $t=fr(O);D.push({shouldShowPreview:C(()=>s(B)&&$t.value),modifier:Dt(()=>{const q=I.slice();return q.splice(q.indexOf(Ne),1,Cn),q}),cost:Ht!=null?Ht:Ge}),I.push(Ne);const T=Ai(c,S,()=>we(Ge)),$=Oi(O,{display:Qe==null?T:()=>s(Qe)?T.value:"",direction:U.Down});return{isHovering:$t,eta:T,tooltip:$}}const Z=[],z=L(0);let G=g.variable(z).times(0);const xe={};let it=!0;const H=C(()=>o.add(w,r()-.5).pow_base(2).times(10).times(G.evaluate())),_e=[];for(let O=0;O<v;O++){const B={upgrades:32,repeatables:O<=1?0:16,conversion:O<=3?0:8,xp:O<=5?0:4,dimensions:O<=7?0:2,prestige:O<=7||O>=v-1?0:1};switch(ii(B,r)){case"upgrades":const _t=[];for(let Ce=0;Ce<4;Ce++){const ct=ii({add:1,mult:O===0&&Ce===0?0:1,pow:O===0?0:.5},r),Xe=H.value,et=Sn(r);let st="",De,$e;const ke=z.value;switch(ct){case"add":{const le=o.add(Xe,10).pow(r()/4+.875);st=`Gain ${he(le)} ${c.displayName}/s`,G=G.add(le),De=pn(()=>({addend:le,description:et,enabled:Ve.bought})),$e=pn(()=>({addend:le}));break}case"mult":{const le=r()*5+1;st=`Multiply previous ${c.displayName} gain by x${he(le)}.`,G=G.add(o.sub(le,1).times(xe[ke-1])),De=Re(()=>({multiplier:le,description:et,enabled:Ve.bought})),$e=Re(()=>({multiplier:le}));break}case"pow":{const le=r()/10+1.05;st=`Raise previous ${c.displayName} gain to the ^${he(le)}`,G=G.add(o.pow(xe[ke-1],le)).sub(xe[ke-1]),De=Ti(()=>({exponent:le,description:et,enabled:Ve.bought})),$e=Ti(()=>({exponent:le}))}}xe[z.value]=G.evaluate(),z.value++;const ze=it,Ve=vr(()=>({requirements:On(()=>({resource:Mn(c),cost:Xe})),display:{title:et,description:st},visibility:ze}));re({feature:Ve,canClick:()=>Ve.canPurchase.value,modifier:De,cost:Xe,showETA:()=>!Ve.bought.value,previewModifier:$e}),_t.push(Ve)}Z.push(_t);break;case"repeatables":const ut=[];for(let Ce=0;Ce<3;Ce++){const ct=ii({add:1.5,mult:3},r),Xe=z.value,et=H.value,st=Sn(r);let De="",$e,ke,ze,Ve;const le=g.variable(C(()=>We.amount.value)).times(2);switch(ct){case"add":{const Me=o.add(et,10).times(r()+.5);De=`Gain ${he(Me)} ${c.displayName}/s`,Ve=le.add(1).times(et),G=G.add(C(()=>o.sub(z.value,Xe).add(1).times(5).times(Me))),$e=C(()=>he(o.times(Me,We.amount.value))+"/s"),ke=pn(()=>({addend:()=>o.times(Me,We.amount.value),description:st,enabled:()=>o.gt(We.amount.value,0)})),ze=pn(()=>({addend:()=>o.add(We.amount.value,1).times(Me)}));break}case"mult":{const Me=r()*.75+1.25;De=`Multiply previous ${c.displayName} gain by x${he(Me)}.`,Ve=le.pow_base(Me).times(et),G=G.add(C(()=>o.sub(z.value,Xe).add(1).times(5).pow_base(Me).sub(1).times(xe[Xe-1]))),$e=C(()=>"x"+he(o.pow(Me,We.amount.value))),ke=Re(()=>({multiplier:()=>o.pow(Me,We.amount.value),description:st,enabled:()=>o.gt(We.amount.value,0)})),ze=Re(()=>({multiplier:()=>o.add(We.amount.value,1).pow_base(Me)}));break}}xe[z.value]=G.evaluate(),z.value++;const qt=it,We=mr(()=>({requirements:On(()=>({resource:Mn(c),cost:Ve})),display:()=>({title:st,description:De,effectDisplay:s($e)}),visibility:qt}));re({feature:We,canClick:()=>s(We.canClick),modifier:ke,cost:Ve,previewModifier:ze}),ut.push(We)}Z.push(ut);break;case"conversion":const Oe=In(0,Ri(r)),Rt=Rn([.64,.75,.55],r),Fn=H.value,na=r()/2+.25,er=r()/2+.25,tr=z.value;G=G.add(C(()=>o.sub(z.value,tr).add(1).pow_base(5).pow(er).times(xe[tr-1])));const Et=zd(()=>({baseResource:Mn(c),gainResource:Oe,formula:Ce=>Ce.div(Fn).pow(na),spend(){c.value=0}}));xe[z.value]=G.evaluate(),z.value+=2;const ia=it,nr=Sn(r),xi=g.variable(Oe).pow(er).add(1),ra=Re(()=>({multiplier:()=>xi.evaluate(),description:nr,enabled:()=>o.gt(Oe.value,0)})),aa=Re(()=>({multiplier:()=>xi.evaluate(o.add(Oe.value,Et.actualGain.value))})),kn=_d(()=>({display:{title:nr,description:K(()=>f("span",null,[E("Reset "),c.displayName,E(" for")," ",ci(Oe,o.clampMin(Et.actualGain.value,1))," ",Oe.displayName,f("br",null,null),f("div",null,[E("Next:")," ",ci(c,o.lt(Et.actualGain.value,1)?Et.currentAt.value:Et.nextAt.value)," ",c.displayName])]))},style:{width:"200px",minHeight:"100px"},canClick:()=>o.gte(Et.actualGain.value,1),prestigeResource:Oe,onClick:Et.convert,visibility:ia})),{isHovering:sa}=re({feature:kn,canClick:()=>s(kn.canClick),modifier:ra,cost:Fn,previewCost:c,previewModifier:aa}),ir=C(()=>sa.value&&kn.canClick.value);Z.push([kn]);const oa=un(g.variable(Oe),ir,Et.actualGain),la=un(xi,ir,Et.actualGain);V[O*2]=K(()=>f(ne,null,[Le(kn.visibility)?f("div",{style:"margin: 10px"},[E("You have")," ",f("h2",{style:{color:Rt,textShadow:`0px 0px 10px ${Rt}`}},[oa()])," ",Oe.displayName,E(","),f("br",null,null),E("providing a "),la(),E("x multiplier to previous")," ",c.displayName,E(" gain")]):null,Pi(kn)])),Ud(this,Et,()=>rt.value.length<v&&_.investments.value!=null&&ve(_.investments.value)&&_.investments.value.state.portals.includes(e)?.01:0);break;case"xp":{const Ce=In(0),at=it,ct=z.value,Xe=Sn(r),et=o.add(w,r()-.5).pow_base(2).times(10),st=r()/4+1.125,De=r()/2+1.25,$e=g.variable(0).pow(st).times(et),ke=Wr($e,Ce,!0,10,o.dInf),ze=C(()=>Lt($e,ke.value,!0,10)),Ve=C(()=>Lt($e,o.add(ke.value,1),!0,10)),le=C(()=>o.pow(De,ke.value)),qt=Re(()=>({multiplier:le,description:Xe,enabled:()=>Le(Me.visibility)}));G=G.add(C(()=>o.sub(z.value,ct).add(1).sqrt().times(3).pow(De).times(xe[ct-1]))),xe[z.value]=G.evaluate(),z.value+=2;const We=Rn([.18,.2,.25],r),Me=Ld(()=>({direction:U.Right,width:300,height:20,progress:()=>o.sub(Ce.value,ze.value).div(o.sub(Ve.value,ze.value)).toNumber(),visibility:at,xp:Ce,display:K(()=>f("span",null,[he(Ce.value),E("/"),he(Ve.value)])),fillStyle:`background-color: ${We}`}));this.on("preUpdate",$i=>{if(rt.value.length<v&&_.activePortals.value.some(Nt=>Nt.state.id===e)&&Le(Me.visibility)){const Nt=o.times(Ue.value,$i);Ce.value=o.add(Nt,Ce.value)}}),I.push(qt),Z.push([Me]),V[O*2]=K(()=>f(ne,null,[Le(Me.visibility)?f("div",{style:"margin: 10px"},[E("You have "),f("h3",null,[Xe]),E(" Lv. "),ht(ke.value),E(","),f("br",null,null),E("providing a "),he(le.value),E("x multiplier to previous")," ",c.displayName,E(" gain"),f("br",null,null)]):null,Pi(Me)]));break}case"dimensions":{const Ce=Sn(r),at=In(0,Ce+" energy"),ct=Rn([.64,.75,.55],r),Xe=z.value;G=G.add(C(()=>o.sub(z.value,Xe).add(1).pow_base(32).add(1).log2().add(1).times(xe[Xe-1])));const et=C(()=>o.add(at.value,1).log2().add(1)),st=Re(()=>({multiplier:et,description:Ce,enabled:()=>o.gt(at.value,0)}));I.push(st);const De=it,$e=[];for(let ke=0;ke<4;ke++){const ze=o.add(w,r()-.5).pow_base(2).times(10).recip(),Ve=H.value,le=g.variable(C(()=>Nt.amount.value)),qt=le.pow_base(o.pow10(ke+1)).times(Ve),We=["First","Second","Third","Fourth"][ke]+" "+Ce+" Dimension",Me=In(0,We),$i=le.sub(1).pow_base(2).times(ze).times(C(()=>o.add(Nt.amount.value,Me.value))),Nt=mr(()=>({display:{title:We,description:K(()=>f("div",null,[f("div",null,[E("Amount:")," ",he(o.add(Me.value,Nt.amount.value))," ",E("["),ht(Nt.amount.value),E("]")])])),effectDisplay:K(()=>f("span",null,[da()," ",ke===0?at.displayName:["First","Second","Third","Fourth"][ke-1]+" "+Ce+" Dimension",E("/s")])),showAmount:!1},style:{width:"400px"},effect:$i,dimensions:Me,energy:ke===0?at:void 0,requirements:On(()=>({resource:Mn(c),cost:qt})),visibility:De}));$e.push(Nt);const ua=fr(Nt),rr=C(()=>s(Nt.canClick)&&ua.value),ca=new g({inputs:[le],evaluate(ar){return o.sub(ar,1).pow_base(2).times(ze).times(o.add(ar,Me.value))}}),da=un(ca,rr);D.push({shouldShowPreview:rr,cost:qt});const pa=Ai(c,S,()=>we(qt));Oi(Nt,{display:pa,direction:U.Down}),xe[z.value]=G.evaluate(),z.value++}this.on("preUpdate",ke=>{if(rt.value.length<v&&_.activePortals.value.some(ze=>ze.state.id===e)&&Le(De)){const ze=o.times(Ue.value,ke),Ve=$e[0].effect.evaluate();at.value=o.times(Ve,ze).add(at.value);for(let le=1;le<4;le++){const qt=$e[le].effect.evaluate();$e[le-1].dimensions.value=o.times(qt,ze).add($e[le-1].dimensions.value)}}}),Z.push($e),V[O*2]=K(()=>f(ne,null,[Le(De)?f("div",{style:"margin: 10px"},[E("You have")," ",f("h2",{style:{color:ct,textShadow:`0px 0px 10px ${ct}`}},[he(at.value)])," ",at.displayName,E(","),f("br",null,null),E("providing a "),he(et.value),E("x multiplier to previous")," ",c.displayName,E(" gain")]):null,Rs(...$e)]));break}case"prestige":{const Ce=Sn(r),at=it,ct=r()/2+1.25,Xe=H.value;G=G.pow(ct);const et=Ti(()=>({exponent:ct,description:Ce,enabled:De.bought}));xe[z.value]=G.evaluate(),z.value++;const st=Wd(()=>({thingsToReset:Z.filter((ke,ze)=>ze%2===0),onReset(){c.value=0}})),De=vr(()=>({display:{title:Ce,description:`Reset all previous ${a} content to raise all previous ${c.displayName} gain to the ^${he(ct)}`},style:{width:"200px",minHeight:"100px"},onPurchase:st.reset,visibility:at,requirements:On(()=>({resource:Mn(c),cost:Xe}))})),$e=Re(()=>({multiplier:0}));re({feature:De,canClick:()=>s(De.canPurchase),modifier:et,cost:Xe,previewCost:c,previewModifier:$e,showETA:()=>!s(De.bought)}),Z.push([De]);break}}const Ge={cache:"increaseCaches"in h?10:1,generation:"increaseGens"in h?10:1,resourceMulti:"increaseResourceMults"in h?10:1,energyMulti:"increaseEnergyMults"in h?2.5:.25,influences:Object.keys(_.influenceNodes.value).length+_e.length===Object.keys(Vt).length?0:"increaseInfluences"in h?20:2,relic:0};let Cn=ii(Ge,r);O===v-1&&"relic"in h&&(Cn="relic");let Qe="",Ht,$t,T,$,q,J;switch(Cn){case"cache":$=qi(r,i),Qe=`Gain ${he(b)}x your current ${$}.`,$t=()=>{var Oe,Rt,Fn;return _.grantResource($,o.times((Fn=(Rt=(Oe=_.resourceNodes.value[$])==null?void 0:Oe.state)==null?void 0:Rt.amount)!=null?Fn:0,b))};break;case"generation":$=qi(r,i);const _t=o.div(b,120).times(It[$]);Qe=`Gain ${he(_t)} ${$}/s while plane is active.`,Ht=Oe=>_.grantResource($,o.times(Oe,_t)),T=C(()=>_.resourceNodes.value[$]);break;case"resourceMulti":q=$=qi(r,i),J=o.div(b,17).pow_base(2),Qe=`Gain ${he(J)}x ${$} while plane is active.`;break;case"energyMulti":q="energy",J=o.div(b,17).add(1),Qe=`Gain ${he(J)}x energy while plane is active.`;break;case"influences":const ut=Object.keys(Vt)[Math.floor(r()*Object.keys(Vt).length)];_e.push(ut),Qe=`Gain a new portal influence (${Vt[ut].display})`,$t=()=>{if(ut in _.influenceNodes.value){yr.warning(`Error: ignoring duplicate portal influence (${Vt[ut].display})`);return}const Oe={id:Zn(_.board),position:{..._.board.types.portal.nodes.value.find(Rt=>Rt.state.id===e).position},type:"influence",state:{type:ut,data:Vt[ut].initialData}};_.board.placeInAvailableSpace(Oe),_.board.nodes.value.push(Oe)};break;case"relic":Qe=t==="ultimatum"?"Win the game!":`Gain the ${t}-tier planar relic (${di[t]})`,$t=()=>{if(t==="ultimatum"){Qi.value=!0;return}if(`${t}Relic`in _.toolNodes.value)yr.warning(`Error: ignoring duplicate relic (${di[t]})`);else{const Oe={id:Zn(_.board),position:{..._.board.types.portal.nodes.value.find(Rt=>Rt.state.id===e).position},type:"passive",state:`${t}Relic`};_.board.placeInAvailableSpace(Oe),_.board.nodes.value.push(Oe)}}}const me=it,ce=H.value,Ot=Fd(()=>({requirements:On(()=>({resource:Mn(c),cost:ce})),visibility:me,display:{requirement:`${he(ce)} ${c.displayName}`,effectDisplay:Qe},style:"width: 100%",classes:{final:O===v-1},update:Ht,onComplete:$t,link:T,effectedResource:q,resourceMulti:J})),rn=Ai(c,S,ce);Oi(Ot,{display:()=>Ot.earned.value?"":rn.value,direction:U.Down}),Z.push([Ot]),it=Ot.earned}const Ke=Wn(Z,Ki),wt=Wn(Z,ea),nn=Dt(()=>[Re(()=>({multiplier:()=>{var O,B,Ne;return o.add((Ne=(B=(O=_.board.types.booster.nodes.value[0])==null?void 0:O.state)==null?void 0:B.level)!=null?Ne:0,1)},description:"Booster",enabled:()=>{var O,B,Ne;return(Ne=(B=(O=_.board.types.booster.nodes.value[0])==null?void 0:O.state)==null?void 0:B.portals.includes(e))!=null?Ne:!1}}))]),Ue=C(()=>nn.apply(1)),[Kn,Qn]=Ln(()=>[{title:`${tt(c.displayName)} Gain`,modifier:F,base:0,unit:"/s"},{title:`${tt(c.displayName)} Time Speed`,modifier:nn,base:1,visible:()=>o.gt(Ue.value,1)}]),_n=L(!1),Wt=K(()=>f(Ut,{modelValue:_n.value,"onUpdate:modelValue":O=>_n.value=O},{header:()=>f("h2",null,[E("Modifiers")]),body:()=>nt(Kn)}));this.on("preUpdate",O=>{if(!_.activePortals.value.some(Ne=>Ne.state.id===e))return;const B=o.times(Ue.value,O);d.value=o.add(d.value,B),rt.value.length<v&&(c.value=o.times(S.value,B).add(c.value)),rt.value.forEach(Ne=>{var Ge;(Ge=Ne.update)==null||Ge.call(Ne,B)})}),Jd(this,()=>rt.value.length<v&&_.upgrader.value!=null&&ve(_.upgrader.value)&&_.upgrader.value.state.portals.includes(e),Ke),Nd(this,()=>rt.value.length<v&&_.automator.value!=null&&ve(_.automator.value)&&_.automator.value.state.portals.includes(e),wt);const Nn=C(()=>{const O=D.find(B=>B.shouldShowPreview.value);return O?o.neg(we(O.cost)):0}),ei=C(()=>{const O=D.find(B=>B.shouldShowPreview.value);return O&&O.modifier?o.sub(O.modifier.apply(0),S.value):0}),Ni=un(g.variable(0).add(c),()=>o.neq(Nn.value,0),Nn),Ci=un(g.variable(0).add(S),()=>o.neq(ei.value,0),ei),ki=C(()=>{const O=[];return rt.value.forEach(B=>{B.link&&O.push(B.link)}),O}),Mi=C(()=>{const O={};return rt.value.forEach(B=>{B.effectedResource!=null&&B.resourceMulti!=null&&(O[B.effectedResource]!=null?O[B.effectedResource]=o.times(O[B.effectedResource],B.resourceMulti):O[B.effectedResource]=B.resourceMulti)}),O}),rt=C(()=>{const O=[];for(let B=1;B<Z.length;B+=2){const Ne=Z[B][0];Ne.earned.value&&O.push(Ne)}return O}),Si=C(()=>o.lt(rt.value.length,v)&&Z.some(O=>O.some(B=>"earned"in B&&s(B.earned)||"bought"in B&&s(B.bought)?!1:("canClick"in B&&s(B.canClick)||"canPurchase"in B&&s(B.canPurchase),!0)))),Ii=C(()=>{const O=Z.findIndex((Ne,Ge)=>Ge>0&&Ge%2===0&&!Z[Ge-1][0].earned.value);let B;return O===-1?B=Z:B=Z.slice(0,O),B.map((Ne,Ge)=>Ge in V?nt(V[Ge]):Pi(...Ne))});return{tier:ft(t),seed:ft(n),influences:ft(i),name:a,color:l,resource:c,background:u,style:{background:u,"--background":u},features:Z,resourceTabCollapsed:Qn,links:ki,resourceMultis:Mi,earnedTreasures:rt,showNotif:Si,timeActive:d,display:K(()=>f(ne,null,[f(ui,{class:"nav-container",style:"z-index: 5"},{default:()=>[f("span",{class:"nav-segment"},[f("h2",null,[a])]),f("span",{class:"nav-segment"},[f("h3",null,[t,E("-tier")])]),i.length===0?null:f("span",{class:"nav-segment"},[f(Pe,{display:i.map(O=>{const B=Vt[O.type].description;return typeof B=="function"?B(O):B}).join("<br/>"),direction:U.Down,style:"width: 300px"},{default:()=>[f("h3",null,[i.length,E(" influences")])]})]),f("span",{class:"nav-segment"},[f("button",{class:"button",style:"display: inline",onClick:()=>_n.value=!0},[E("modifiers")])])]}),f(ui,{class:"nav-container"},{default:()=>[f("span",{class:"nav-segment"},[f("h3",{style:`color: ${l}; text-shadow: 0px 0px 10px ${l};`},[nt(Ni)])," ",c.displayName]),f("span",{class:"nav-segment"},[E("("),f("h3",{style:`color: ${l}; text-shadow: 0px 0px 10px ${l};`},[o.gt(S.value,0)?"+":"",nt(Ci)]),E("/s)")]),o.neq(Ue.value,1)?f("span",{class:"nav-segment"},[E("Speed: "),he(Ue.value),E("x")]):null]}),f(xd,{height:"60px"},null),Ii.value,nt(Wt)])),minimizedDisplay:K(()=>f("div",null,[f("span",null,[a]),f("span",{style:"font-size: large; vertical-align: sub;"},[" ",rt.value.length,E("/"),v,E(" treasures")])]))}})}function qi(e,t){t=t.filter(u=>u.type==="increaseResources"||u.type==="decreaseResources");const n=Object.keys(It).reduce((u,c)=>{let d=It[c];return t.filter(m=>m.data===c).forEach(m=>{m.type==="increaseResources"?d*=1e3:d/=1e3}),u+d},0),i=Object.keys(It),r=Math.floor(e()*n);let a=0,l;for(let u=0;u<i.length;u++){const c=i[u];if(a+=It[c],r<a){l=c;break}}return l}function ii(e,t){const n=Object.values(e).reduce((u,c)=>u+c),i=Object.keys(e);let r=0,a=null;const l=t()*n;for(let u=0;u<i.length;u++){const c=i[u];if(r+=e[c],l<r){a=c;break}}if(a==null)throw new Error("Failed to pick random. This should not happen");return a}const ip={shape:je.Diamond,size:50,title:"\u{1FAA8}",label:e=>e===_.board.selectedNode.value?{text:"Mining"}:Object.keys(_.resourceNodes.value).length===0?{text:"Click me!"}:null,actionDistance:Math.PI/4,actions:[Ft],progress:e=>ve(e)?new o(e.state.progress).toNumber():0,progressDisplay:mn.Outline,progressColor:"var(--accent2)",classes:e=>({running:ve(e)}),draggable:!0},rp={shape:je.Diamond,size:50,title:"\u{1F6E0}\uFE0F",label:e=>e===_.board.selectedNode.value?{text:"Broken Forge"}:null,actionDistance:Math.PI/4,actions:[{id:"repair",icon:"build",tooltip:{text:"Repair - 100 energy"},onClick(e){o.gte(_.energy.value,100)&&(e.type="factory",_.energy.value=o.sub(_.energy.value,100))},confirmationLabel:()=>o.gte(_.energy.value,1e3)?{text:"Tap again to confirm"}:{text:"Cannot afford",color:"var(--danger)"}}],draggable:!0},ap={shape:je.Diamond,size:50,title:"\u{1F6E0}\uFE0F",label:e=>{var t,n;if(e===_.board.selectedNode.value)return{text:e.state==null?"Forge - Drag a resource to me!":`Forging ${Te[e.state].name}`};if(((t=_.board.draggingNode.value)==null?void 0:t.type)==="resource"){const i=((n=_.board.draggingNode.value)==null?void 0:n.state).type,r=e.state===i?"Disconnect":Te[i].name,a=e.state===i||o.gte(_.energy.value,Te[i].cost)&&_.toolNodes.value[i]==null?"var(--accent2)":"var(--danger)";return{text:r,color:a}}return null},actionDistance:Math.PI/4,actions:[{id:"deselect",icon:"close",tooltip:{text:"Disconnect resource"},onClick(e){e.state=void 0,_.board.selectedAction.value=null,_.board.selectedNode.value=null},visibility:e=>e.state!=null},{id:"craft",icon:"done",tooltip:e=>({text:`Forge ${Te[e.state].name} - ${Je(Te[e.state].cost)} energy`}),onClick(e){const t=Te[e.state];if(o.gte(_.energy.value,t.cost)&&_.toolNodes.value[e.state]==null){_.energy.value=o.sub(_.energy.value,t.cost);const n={id:Zn(_.board),position:{...e.position},type:t.type,state:"state"in t?t.state:void 0};_.board.placeInAvailableSpace(n),_.board.nodes.value.push(n),_.board.selectedAction.value=null,_.board.selectedNode.value=null,e.state=void 0}},fillColor:e=>o.gte(_.energy.value,Te[e.state].cost)&&_.toolNodes.value[e.state]==null?"var(--accent2)":"var(--danger)",visibility:e=>e.state!=null,confirmationLabel:e=>o.gte(_.energy.value,Te[e.state].cost)?_.toolNodes.value[e.state]==null?{text:"Tap again to confirm"}:{text:"Already crafted",color:"var(--danger)"}:{text:"Cannot afford",color:"var(--danger)"}}],progress:e=>e.state==null||_.toolNodes.value[e.state]!=null?0:o.div(_.energy.value,Te[e.state].cost).clampMax(1).toNumber(),progressDisplay:mn.Fill,progressColor:e=>e.state!=null&&o.gte(_.energy.value,Te[e.state].cost)?"var(--accent2)":"var(--foreground)",canAccept(e,t){return t.type==="resource"},onDrop(e,t){const n=t.state.type;e.state===n?e.state=void 0:e.state=n,_.board.selectedNode.value=e},draggable:!0},sp={shape:je.Circle,size:50,title:e=>tt(e.state.type),subtitle:e=>Je(e.state.amount),progress:e=>fd(e.state.type),onClick(){},progressDisplay:mn.Outline,progressColor:"var(--accent3)",classes:e=>{var t;return{"affected-node":_.dowsing.value!=null&&ve(_.dowsing.value)&&_.dowsing.value.state.resources.includes(e.state.type)||o.neq((t=_.planarMultis.value[e.state.type])!=null?t:1,1)}},draggable:!0},op={shape:je.Circle,size:50,title:e=>{const t=e.state;return t.includes("Relic")?di[t.slice(0,-5)]:Te[t].name},label:e=>e===_.board.selectedNode.value?{text:Id[e.state].description(dt(e.state))}:null,outlineColor:"var(--bought)",classes:e=>({"affected-node":dt(e.state)}),draggable:!0},lp={shape:je.Diamond,size:50,title:"\u{1F962}",label:e=>e===_.board.selectedNode.value?{text:e.state.resources.length===0?"Dowsing - Drag a resource to me!":`Dowsing (${e.state.resources.length}/${o.add(e.state.maxConnections,_.computedBonusConnectionsModifier.value)})`}:Hr(e,t=>`Double ${t} odds`),actionDistance:Math.PI/4,actions:[mi,wn(e=>e.add(2).pow_base(100),16),Ft],classes:e=>({running:ve(e)}),canAccept:Zr,onDrop:Yr,draggable:!0},up={shape:je.Diamond,size:50,title:"\u26CF\uFE0F",label:e=>e===_.board.selectedNode.value?{text:e.state.resources.length===0?"Quarry - Drag a resource to me!":`Quarrying (${e.state.resources.length}/${o.add(e.state.maxConnections,_.computedBonusConnectionsModifier.value)})`}:Hr(e,t=>`Gather ${vt(o.div(_.dropRates[t].computedModifier.value,100))} ${t}/s`),actionDistance:Math.PI/4,actions:[mi,wn(e=>e.add(2).pow_base(1e4),16),Ft],progress:e=>ve(e)?o.eq(_.quarryProgressRequired.value,0)?0:new o(e.state.progress).div(_.quarryProgressRequired.value).toNumber():0,progressDisplay:mn.Outline,progressColor:"var(--accent2)",canAccept:Zr,onDrop:Yr,classes:e=>({running:ve(e)}),draggable:!0},cp={shape:je.Diamond,size:50,title:"\u{1F50C}",label:e=>e===_.board.selectedNode.value?{text:e.state.tools.length===0?"Empowerer - Drag a tool to me!":`Empowering (${e.state.tools.length}/${o.add(e.state.maxConnections,_.computedBonusConnectionsModifier.value)})`}:cd(e,t=>t.includes("Relic")?`Double ${di[t.slice(0,-5)]}'s effect`:`Double ${Te[t].name}'s effect`),actionDistance:Math.PI/4,actions:[mi,wn(e=>e.add(3).pow_base(1e3),16),Ft],canAccept:dd,onDrop:pd,classes:e=>({running:ve(e)}),draggable:!0},dp={shape:je.Diamond,size:50,title:"\u26E9\uFE0F",label:e=>{if(e===_.board.selectedNode.value)return{text:e.state.tier==null?"Portal Spawner - Drag a resource to me!":`Spawning ${e.state.tier}-tier portal`};const t=_.board.draggingNode.value;if((t==null?void 0:t.type)==="resource"){const n=t.state.type;return{text:e.state.tier===n?"Disconnect":`${tt(n)}-tier Portal`,color:"var(--accent2)"}}else if((t==null?void 0:t.type)==="influence"){const n=t.state.type,{influences:i}=e.state;return i.includes(n)?{text:"Disconnect",color:"var(--accent2)"}:{text:"Add influence",color:"var(--accent2)"}}return null},actionDistance:Math.PI/4,actions:[{id:"deselect",icon:"close",tooltip:{text:"Disconnect all"},onClick(e){e.state={...e.state,tier:void 0,influences:[]},_.board.selectedAction.value=null,_.board.selectedNode.value=null},visibility:e=>{const{tier:t,influences:n}=e.state;return t!=null||n.length>0}},{id:"makePortal",icon:"done",tooltip:e=>({text:`Spawn ${e.state.tier}-tier portal`}),onClick(e){let t=0;for(;`portal-${t}`in be;)t++;const{tier:n,influences:i}=e.state;Zi(ta(`portal-${t}`,n,Math.floor(Math.random()*4294967296),i.map(a=>_.influenceNodes.value[a].state)),Q);const r={id:Zn(_.board),position:{...e.position},type:"portal",state:{id:`portal-${t}`,powered:!1}};_.board.placeInAvailableSpace(r),_.board.nodes.value.push(r),_.board.selectedAction.value=null,_.board.selectedNode.value=null,e.state={tier:void 0,influences:[]}},visibility:e=>e.state.tier!=null}],canAccept(e,t){return t.type==="resource"||t.type==="influence"},onDrop(e,t){if(t.type==="resource"){const n=t.state.type,i=e.state.tier;e.state={...e.state,tier:n===i?void 0:n}}else if(t.type==="influence"){const n=t.state.type,i=e.state.influences;i.includes(n)?e.state={...e.state,influences:i.filter(r=>r!==n)}:e.state={...e.state,influences:[...i,n]}}_.board.selectedNode.value=e},draggable:!0},pp={shape:je.Diamond,size:50,title:"\u{1F300}",label:e=>e===_.board.selectedNode.value?{text:`Portal to ${be[e.state.id].name}`,color:be[e.state.id].color}:null,actionDistance:Math.PI/4,actions:[Ft],classes:e=>({running:ve(e),showNotif:be[e.state.id].showNotif.value,"affected-node":_.booster.value!=null&&ve(_.booster.value)&&_.booster.value.state.portals.includes(e.state.id)}),outlineColor:e=>be[e.state.id].background,draggable:!0},fp={shape:e=>e.state.type==="increaseResources"||e.state.type==="decreaseResources"?je.Diamond:je.Circle,size:50,title:e=>Vt[e.state.type].display,label:e=>{if(e===_.board.selectedNode.value){const n=e.state,i=Vt[n.type].description;return{text:typeof i=="function"?i(n):i}}const t=_.board.draggingNode.value;if((t==null?void 0:t.type)==="resource"){const n=t.state.type,{type:i,data:r}=e.state;let a;if(Array.isArray(r)&&r.includes(n))a="Disconnect";else if(i==="increaseResources")a=`Increase ${tt(n)} odds`;else if(i==="decreaseResources")a=`Decrease ${tt(n)} odds`;else return null;return{text:a,color:"var(--accent2)"}}return null},actionDistance:Math.PI/4,actions:[mi],canAccept:(e,t)=>t.type!=="resource"?!1:Array.isArray(e.state.data),onDrop:(e,t)=>{if(t.type!=="resource")return;const n=t.state.type,i=e.state.data;i!=null&&(i.includes(n)?e.state={...e.state,data:i.filter(r=>r!==n)}:e.state={...e.state,data:[...i,n]},_.board.selectedNode.value=e)},outlineColor:"var(--danger)",draggable:!0},gp={shape:je.Diamond,size:50,title:"\u231B",label:e=>e===_.board.selectedNode.value?{text:e.state.portals.length===0?"Booster - Drag a portal to me!":`Boosting by ${Je(o.add(1,e.state.level))}x (${e.state.portals.length}/${o.add(e.state.maxConnections,_.computedBonusConnectionsModifier.value)})`}:vi(e,t=>`Boost ${be[t].name}'s speed`),actionDistance:Math.PI/4,actions:[{id:"deselect",icon:"close",tooltip:{text:"Disconnect portals"},onClick(e){e.state={...e.state,portals:[]},_.board.selectedAction.value=null,_.board.selectedNode.value=null},visibility:e=>{var t,n;return(n=(t=e.state)==null?void 0:t.portals.length)!=null?n:0>0}},wn(e=>e.add(6).pow_base(1e3)),{id:"increaseBoost",icon:"arrow_upward",tooltip(e){return{text:`Increase boost - ${Je(Fi.evaluate(e.state.level))} energy`}},confirmationLabel(e){return o.gte(_.energy.value,Fi.evaluate(e.state.level))?{text:"Tap again to confirm"}:{text:"Cannot afford",color:"var(--danger)"}},onClick(e){const t=Fi.evaluate(e.state.level);o.gte(_.energy.value,t)&&(_.energy.value=o.sub(_.energy.value,t)),e.state={...e.state,level:o.add(e.state.level,1)},_.board.selectedAction.value=null}},Ft],canAccept:hi,onDrop:bi,classes:e=>({running:ve(e)}),draggable:!0},mp={shape:je.Diamond,size:50,title:"\u{1F916}",label:e=>e===_.board.selectedNode.value?{text:e.state.portals.length===0?"Upgrader - Drag a portal to me!":`Auto-Upgrading (${e.state.portals.length}/${o.add(e.state.maxConnections,_.computedBonusConnectionsModifier.value)})`}:vi(e,t=>`Auto-buy ${be[t].name}'s upgrades and prestiges`),actionDistance:Math.PI/4,actions:[{id:"deselect",icon:"close",tooltip:{text:"Disconnect portals"},onClick(e){e.state={...e.state,portals:[]},_.board.selectedAction.value=null,_.board.selectedNode.value=null},visibility:e=>{var t,n;return(n=(t=e.state)==null?void 0:t.portals.length)!=null?n:0>0}},wn(e=>e.add(4).pow_base(1e6)),Ft],canAccept:hi,onDrop:bi,classes:e=>({running:ve(e)}),draggable:!0},vp={shape:je.Diamond,size:50,title:"\u{1F9BE}",label:e=>e===_.board.selectedNode.value?{text:e.state.portals.length===0?"Automator - Drag a portal to me!":`Automatating (${e.state.portals.length}/${o.add(e.state.maxConnections,_.computedBonusConnectionsModifier.value)})`}:vi(e,t=>`Auto-buy ${be[t].name}'s repeatables and dimensions`),actionDistance:Math.PI/4,actions:[{id:"deselect",icon:"close",tooltip:{text:"Disconnect portals"},onClick(e){e.state={...e.state,portals:[]},_.board.selectedAction.value=null,_.board.selectedNode.value=null},visibility:e=>{var t,n;return(n=(t=e.state)==null?void 0:t.portals.length)!=null?n:0>0}},wn(e=>e.add(4).pow_base(1e6)),Ft],canAccept:hi,onDrop:bi,classes:e=>({running:ve(e)}),draggable:!0},hp={shape:je.Diamond,size:50,title:"\u{1F4B1}",label:e=>e===_.board.selectedNode.value?{text:e.state.portals.length===0?"Investments - Drag a portal to me!":`Investing (${e.state.portals.length}/${o.add(e.state.maxConnections,_.computedBonusConnectionsModifier.value)})`}:vi(e,t=>`Auto-buy ${be[t].name}'s repeatables and dimensions`),actionDistance:Math.PI/4,actions:[{id:"deselect",icon:"close",tooltip:{text:"Disconnect portals"},onClick(e){e.state={...e.state,portals:[]},_.board.selectedAction.value=null,_.board.selectedNode.value=null},visibility:e=>{var t,n;return(n=(t=e.state)==null?void 0:t.portals.length)!=null?n:0>0}},wn(e=>e.add(3).pow_base(1e8)),Ft],canAccept:hi,onDrop:bi,classes:e=>({running:ve(e)}),draggable:!0},wr=fi(),bp={mine:ip,brokenFactory:rp,factory:ap,resource:sp,passive:op,dowsing:lp,quarry:up,empowerer:cp,portalGenerator:dp,portal:pp,influence:fp,booster:gp,upgrader:mp,automator:vp,investments:hp},_=Hi("main",function(){const e=In(0,"energy"),t=C(()=>p.types.resource.nodes.value.reduce((T,$)=>(T[$.state.type]=$,T),{})),n=C(()=>({...p.types.passive.nodes.value.reduce((T,$)=>(T[$.state]=$,T),{}),sand:p.types.dowsing.nodes.value[0],wood:p.types.quarry.nodes.value[0],coal:p.types.empowerer.nodes.value[0],iron:p.types.portalGenerator.nodes.value[0],gold:p.types.booster.nodes.value[0],platinum:p.types.upgrader.nodes.value[0],berylium:p.types.automator.nodes.value[0],ultimatum:p.types.investments.nodes.value[0]})),i=C(()=>({...p.types.influence.nodes.value.reduce((T,$)=>(T[$.state.type]=$,T),{})})),r=C(()=>({...p.types.portal.nodes.value.reduce((T,$)=>(T[$.state.id]=$,T),{})})),a=C(()=>ln.reduce((T,$)=>{var ce,Ot,rn;const q=(rn=(Ot=(ce=t.value[$])==null?void 0:ce.state)==null?void 0:Ot.amount)!=null?rn:0;let J=o.floor(jn.invertIntegral(q)).sub(10).clampMin(0),me=Lt(jn,J,!0,0);for(;;){const _t=jn.evaluate(J);if(o.add(me,_t).lte(q))J=J.add(1),me=o.add(me,_t);else break}return T[$]=J,T},{})),l=gn({}),u=gn({});jt(()=>{ln.forEach(T=>{gt(()=>a.value[T],($,q)=>{o.gt($,q)&&ae.active===Q.id&&o.lte($,100)&&wr.info(f("div",null,[f("h3",null,[o.eq($,1)?`${tt(T)} discovered`:`${tt(T)} is now Level ${ht($)}`,E("!")]),f("div",null,[E("Energy gain is now 1.01x higher.")])]))})})});const c=C(()=>Z.filter(T=>{var $,q;return(q=($=T.value)==null?void 0:$.state)==null?void 0:q.powered}).length+p.types.portal.nodes.value.filter(T=>T.state.powered).length),d=C(()=>o.eq(c.value,0)?10:o.add(c.value,1).pow_base(100).div(10).times(.99)),m=C(()=>v.value==null?0:v.value.state.resources.reduce(($,q)=>o.div(100,Wt[q].computedModifier.value).add($),o.dZero)),p=Iu(T=>({startNodes:()=>[{position:{x:0,y:0},type:"mine",state:{progress:0,powered:!1}},{position:{x:0,y:-200},type:"brokenFactory"}],types:bp,style:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden"},links(){const $=[];if($.push(...Object.keys(l).map(q=>({startNode:h.value,endNode:t.value[q],stroke:"var(--accent3)",strokeWidth:5}))),w.value!=null&&w.value.state!=null&&$.push({startNode:w.value,endNode:t.value[w.value.state],stroke:"var(--foreground)",strokeWidth:4}),b.value!=null&&b.value.state.resources.forEach(q=>{$.push({startNode:b.value,endNode:t.value[q],stroke:ve(b.value)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),v.value!=null&&v.value.state.resources.forEach(q=>{$.push({startNode:v.value,endNode:t.value[q],stroke:"var(--foreground)",strokeWidth:4})}),$.push(...Object.keys(u).map(q=>({startNode:v.value,endNode:t.value[q],stroke:"var(--accent3)",strokeWidth:5}))),I.value!=null&&I.value.state.tools.forEach(q=>{$.push({startNode:I.value,endNode:n.value[q],stroke:ve(I.value)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),F.value!=null){const q=F.value.state;q.tier!=null&&$.push({startNode:F.value,endNode:t.value[q.tier],stroke:"var(--foreground)",strokeWidth:4}),q.influences.forEach(J=>{$.push({startNode:F.value,endNode:i.value[J],stroke:"var(--foreground)",strokeWidth:4})}),T.types.portal.nodes.value.forEach(J=>{const me=be[J.state.id];return me.links.value.forEach(ce=>{ce.value!=null&&$.push({startNode:J,endNode:ce.value,stroke:ve(J)?"var(--accent3)":"var(--foreground)",strokeWidth:4})}),Object.keys(me.resourceMultis.value).forEach(ce=>{ce!=="energy"&&ce in t.value&&$.push({startNode:J,endNode:t.value[ce],stroke:ve(J)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),$})}return S.value!=null&&S.value.state.portals.forEach(q=>{$.push({startNode:S.value,endNode:r.value[q],stroke:ve(S.value)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),D.value!=null&&D.value.state.portals.forEach(q=>{$.push({startNode:D.value,endNode:r.value[q],stroke:"var(--foreground)",strokeWidth:4})}),V.value!=null&&V.value.state.portals.forEach(q=>{$.push({startNode:V.value,endNode:r.value[q],stroke:"var(--foreground)",strokeWidth:4})}),re.value!=null&&re.value.state.portals.forEach(q=>{$.push({startNode:re.value,endNode:r.value[q],stroke:"var(--foreground)",strokeWidth:4})}),Object.values(i.value).forEach(q=>{const J=q.state;(J.type==="increaseResources"||J.type==="decreaseResources")&&J.data.forEach(me=>{$.push({startNode:q,endNode:t.value[me],stroke:"var(--foreground)",strokeWidth:4})})}),$}})),h=C(()=>p.types.mine.nodes.value[0]),w=C(()=>p.types.factory.nodes.value[0]),b=C(()=>n.value.sand),v=C(()=>n.value.wood),I=C(()=>n.value.coal),F=C(()=>n.value.iron),S=C(()=>n.value.gold),D=C(()=>n.value.platinum),V=C(()=>n.value.berylium),re=C(()=>n.value.ultimatum),Z=[h,b,v,I,S,D,V,re];function z(T,$){let q=t.value[T];if($=o.times($,Nn[T].computedModifier.value),q==null)q={id:Zn(p),position:{...h.value.position},type:"resource",state:{type:T,amount:$}},p.placeInAvailableSpace(q),p.nodes.value.push(q);else{const J=q.state;q.state={...J,amount:o.add(J.amount,$)}}}const G=C(()=>Object.keys(It).reduce((T,$)=>T+new o(Wt[$].computedModifier.value).toNumber(),0)),xe=C(()=>{const T={};return p.types.portal.nodes.value.forEach($=>{if(!ve($))return;const J=be[$.state.id].resourceMultis.value;Object.keys(J).forEach(me=>{T[me]!=null?T[me]=o.times(T[me],J[me]):T[me]=J[me]})}),T}),it=Dt(()=>[...ln.map(T=>Re(()=>({description:()=>`${tt(T)} (Lv. ${ht(a.value[T])}) (${he(_n.value)}x per level)`,multiplier:()=>o.pow(_n.value,a.value[T]),enabled:()=>{var $,q;return T in t.value&&o.gt((q=($=t.value[T].state)==null?void 0:$.amount)!=null?q:0,0)}}))),Re(()=>({multiplier:()=>dt("stone")?4:2,description:()=>(dt("stone")?"Empowered ":"")+Te.stone.name,enabled:()=>n.value.stone!=null})),Re(()=>({multiplier:()=>{var T;return(T=xe.value.energy)!=null?T:1},description:"Planar Treasures",enabled:()=>{var T;return o.neq((T=xe.value.energy)!=null?T:1,1)}})),pn(()=>({addend:()=>o.pow(100,c.value).div(10).neg(),description:"Powered Machines (100^n/10 energy/s)",enabled:()=>o.gt(c.value,0)}))]),H=C(()=>it.apply(1)),_e=Dt(()=>[pn(()=>({addend:()=>dt("unobtainium")?2:1,description:()=>(dt("unobtainium")?"Empowered ":"")+Te.unobtainium.name,enabled:()=>n.value.unobtainium!=null}))]),Ke=C(()=>_e.apply(0)),wt=Dt(()=>[Re(()=>({multiplier:()=>dt("dirt")?4:2,description:()=>(dt("dirt")?"Empowered ":"")+Te.dirt.name,enabled:()=>n.value.dirt!=null}))]),nn=C(()=>wt.apply(1)),Ue=Dt(()=>[Re(()=>({multiplier:()=>dt("gravel")?4:2,description:()=>(dt("gravel")?"Empowered ":"")+Te.gravel.name,enabled:()=>n.value.gravel!=null}))]),Kn=C(()=>Ue.apply(1)),Qn=Dt(()=>[pn(()=>({addend:()=>dt("copper")?.002:.001,description:()=>(dt("copper")?"Empowered ":"")+Te.copper.name,enabled:()=>n.value.copper!=null}))]),_n=C(()=>Qn.apply(1.01)),Wt=Object.keys(It).reduce((T,$)=>{const q=Dt(()=>[Re(()=>({multiplier:2,description:"Dowsing",enabled:()=>b.value!=null&&ve(b.value)&&b.value.state.resources.includes($)}))]),J=C(()=>q.apply(It[$])),me={title:`${tt($)} Drop Rate`,modifier:q,base:It[$]};return T[$]={modifier:q,computedModifier:J,section:me},T},{}),Nn=Object.keys(It).reduce((T,$)=>{const q=Dt(()=>[Re(()=>({multiplier:()=>{var ce;return(ce=xe.value[$])!=null?ce:1},description:"Planar Treasures",enabled:()=>{var ce;return o.neq((ce=xe.value[$])!=null?ce:1,1)}}))]),J=C(()=>q.apply(1)),me={title:`${tt($)} Gain`,modifier:q};return T[$]={modifier:q,computedModifier:J,section:me},T},{}),[ei,Ni]=Ln(()=>[{title:"Energy Gain",modifier:it,base:1,unit:"/s"},{title:"Bonus Connections",modifier:_e,base:0}]),[Ci,ki]=Ln(()=>[{title:"Mining Speed",modifier:wt,base:1,unit:"/s",visible:()=>n.value.dirt!=null},{title:"Ore Dropped",modifier:Ue,base:1,visible:()=>n.value.gravel!=null},{title:"Material Level Effect",modifier:Qn,base:1.01,visible:()=>n.value.copper!=null}]),[Mi,rt]=Ln(()=>Object.values(Wt).map(T=>T.section)),[Si,Ii]=Ln(()=>Object.values(Nn).map(T=>T.section)),O=Ou({general:()=>({display:"General",glowColor(){return O.activeTab.value===this.tab?"white":""},tab:ei,energyTabCollapsed:Ni}),mining:()=>({display:"Mine",glowColor(){return O.activeTab.value===this.tab?"white":""},visibility:()=>Object.keys(n.value).length>0,tab:Ci,miningTabCollapsed:ki}),resources:()=>({display:"Mine Rates",glowColor(){return O.activeTab.value===this.tab?"white":""},visibility:()=>b.value!=null,tab:Mi,resourcesCollapsed:rt}),resourcesGain:()=>({display:"Resource Gain",glowColor(){return O.activeTab.value===this.tab?"white":""},visibility:()=>Object.values(Nn).some(T=>o.neq(T.computedModifier.value,1)),tab:Si,resourceGainCollapsed:Ii})}),B=L(!1),Ne=K(()=>f(Ut,{modelValue:B.value,"onUpdate:modelValue":T=>B.value=T},{header:()=>f("h2",null,[E("Modifiers")]),body:()=>nt(O)}));this.on("preUpdate",T=>{if(Object.keys(l).forEach($=>{l[$]-=T,l[$]<=0&&delete l[$]}),Object.keys(u).forEach($=>{u[$]-=T,u[$]<=0&&delete u[$]}),ve(h.value)){const $=o.add(h.value.state.progress,o.times(nn.value,T)),q=$.floor();h.value.state={...h.value.state,progress:o.sub($,q)};const J=q.div(G.value).floor();J.gt(0)&&ln.forEach(ce=>{z(ce,o.times(new o(Wt[ce].computedModifier.value).toNumber(),J).times(Kn.value)),l[ce]=.3});const me=o.sub(q,J).toNumber();for(let ce=0;ce<me;ce++){const Ot=Math.floor(Math.random()*G.value);let rn=0;for(let _t=0;_t<ln.length;_t++){const ut=ln[_t];if(rn+=new o(Wt[ut].computedModifier.value).toNumber(),Ot<rn){z(ut,Kn.value),l[ut]=.3;break}}}}if(v.value!=null&&ve(v.value)){const{progress:$,resources:q}=v.value.state;if(q.length>0){let J=o.add($,T);const me=o.div($,m.value).floor();J=o.sub(J,o.times(me,m.value)),v.value.state={...v.value.state,progress:J},o.gt(me,0)&&q.forEach(ce=>{z(ce,me),u[ce]=.3})}}e.value=o.add(e.value,o.times(H.value,T)),o.lt(e.value,0)&&(e.value=0,h.value.state={...h.value.state,powered:!1},wr.warning(f("div",null,[f("h3",null,[E("Ran out of energy!")]),f("div",null,[E("All machines have been turned off.")])])))});const Ge=C(()=>{var T,$;return p.selectedAction.value===p.types.brokenFactory.actions[0]?-100:p.selectedAction.value===p.types.factory.actions[1]?o.neg(Te[p.selectedNode.value.state].cost):((T=p.selectedAction.value)==null?void 0:T.id)==="moreConnections"?o.neg(p.selectedAction.value.formula.evaluate((($=p.selectedNode.value)==null?void 0:$.state).maxConnections)):0}),Cn=un(g.variable(0).add(e),()=>o.neq(Ge.value,0),Ge),Qe=C(()=>{var T;return p.selectedAction.value===Ft?((T=p.selectedNode.value)==null?void 0:T.state).powered?o.eq(c.value,1)?10:o.pow(100,c.value).div(10).times(.99):o.neg(d.value):0}),Ht=un(g.variable(0).add(H),()=>o.neq(Qe.value,0),Qe),$t=C(()=>p.types.portal.nodes.value.filter(T=>ve(T)));return gt($t,T=>{jt(()=>{Q.tabs=["main",...T.map($=>$.state.id)]})}),gt(Ke,(T,$)=>{o.lt(T,$)&&(on(T,b,"resources"),on(T,v,"resources"),on(T,I,"tools"),on(T,S,"portals"),on(T,D,"portals"),on(T,V,"portals"),on(T,re,"portals"))}),{name:"World",board:p,energy:e,modifierTabs:O,resourceNodes:t,toolNodes:n,influenceNodes:i,grantResource:z,activePortals:$t,isEmpowered:dt,nextPowerCost:d,computedBonusConnectionsModifier:Ke,quarryProgressRequired:m,dropRates:Wt,dowsing:b,empowerer:I,booster:S,upgrader:D,automator:V,investments:re,resourceLevels:a,planarMultis:xe,display:K(()=>f(ne,null,[f(ui,{class:"nav-container"},{default:()=>[f("span",{class:"nav-segment"},[f("h2",{style:"color: white; text-shadow: 0px 0px 10px white;"},[nt(Cn)])," ",E("energy")]),f("span",{class:"nav-segment"},[E("("),f("h3",{style:"color: white; text-shadow: 0px 0px 10px white;"},[o.gt(H.value,0)?"+":"",nt(Ht)]),E("/s)")]),o.gt(c.value,0)?f("span",{class:"nav-segment"},[f("h3",{style:"color: var(--accent1); text-shadow: 0px 0px 10px var(--accent1);"},[ht(c.value)])," ",E("machines powered")]):null,f("span",{class:"nav-segment"},[f("button",{class:"button",style:"display: inline",onClick:()=>B.value=!0},[E("modifiers")])]),Q.devSpeed===0?f("span",{class:"nav-segment"},[E("Game Paused")]):Q.devSpeed!=null&&Q.devSpeed!==1?f("span",{class:"nav-segment"},[E("Dev Speed: "),he(Q.devSpeed),E("x")]):null]}),nt(p),nt(Ne)]))}}),yp=e=>{var i,r,a,l,u;const t=[_];let n=0;for(;`portal-${n}`in((i=e.layers)!=null?i:{});){const c=(r=e.layers)==null?void 0:r[`portal-${n}`];t.push(ta(`portal-${n}`,(a=c.tier)!=null?a:"dirt",(l=c.seed)!=null?l:Math.floor(Math.random()*4294967296),(u=c.influences)!=null?u:[])),n++}return t},Qi=L(!1);function wp(e,t){}var _p=Object.freeze(Object.defineProperty({__proto__:null,main:_,getInitialLayers:yp,hasWon:Qi,fixOldSave:wp},Symbol.toStringTag,{value:"Module"}));const Jn=e=>(vn("data-v-4a50ce42"),e=e(),hn(),e),Np={class:"game-over-modal-header"},Cp=["src","alt"],kp={class:"game-over-modal-title"},Mp=Jn(()=>N("h2",null,"Congratulations!",-1)),Sp={key:0},Ip=Jn(()=>N("br",null,null,-1)),xp=Jn(()=>N("div",null," Please check the Discord to discuss the game or to check for new content updates! ",-1)),$p=Jn(()=>N("br",null,null,-1)),Ep=["href"],Dp=Jn(()=>N("span",{class:"material-icons game-over-modal-discord"},"discord",-1)),Pp=X({__name:"GameOverScreen",setup(e){const{title:t,logo:n,discordName:i,discordLink:r,versionNumber:a,versionTitle:l}=pe,u=C(()=>gi(Q.timePlayed)),c=C(()=>Qi.value&&!Q.keepGoing),d=Qt(Q,"autosave");function m(){Q.keepGoing=!0}function p(){cn($n())}return(h,w)=>(M(),ee(Ut,{"model-value":s(c)},{header:W(()=>[N("div",Np,[s(n)?(M(),P("img",{key:0,class:"game-over-modal-logo",src:s(n),alt:s(t)},null,8,Cp)):j("",!0),N("div",kp,[Mp,N("h4",null,"You've beaten "+se(s(t))+" v"+se(s(a))+": "+se(s(l)),1)])])]),body:W(({shown:b})=>[b?(M(),P("div",Sp,[N("div",null,"It took you "+se(s(u))+" to beat the game.",1),Ip,xp,$p,N("div",null,[N("a",{href:s(r),class:"game-over-modal-discord-link"},[Dp,E(" "+se(s(i)),1)],8,Ep)]),f(Bt,{title:"Autosave",modelValue:s(d),"onUpdate:modelValue":w[0]||(w[0]=v=>Ae(d)?d.value=v:null)},null,8,["modelValue"])])):j("",!0)]),footer:W(()=>[N("div",{class:"game-over-footer"},[N("button",{onClick:m,class:"button"},"Keep Going"),N("button",{onClick:p,class:"button danger"},"Play Again")])]),_:1},8,["model-value"]))}});var Tp=ue(Pp,[["__scopeId","data-v-4a50ce42"]]);const _i=e=>(vn("data-v-2776d67d"),e=e(),hn(),e),Ap=_i(()=>N("div",{class:"nan-modal-header"},[N("h2",null,"NaN value detected!")],-1)),Fp={key:0},Op=_i(()=>N("br",null,null,-1)),Rp=["href"],qp=_i(()=>N("span",{class:"material-icons nan-modal-discord"},"discord",-1)),Vp=_i(()=>N("br",null,null,-1)),Bp={class:"nan-footer"},Lp=X({__name:"NaNScreen",setup(e){const{discordName:t,discordLink:n}=pe,i=L(!0),r=L(!0),a=Qt(Be,"hasNaN"),l=L(null);gt(a,h=>{h?(i.value=Q.autosave,r.value=Q.devSpeed===0):(Q.autosave=i.value,Q.devSpeed=r.value?0:null)});const u=C(()=>{var h;return(h=Be.NaNPath)==null?void 0:h.join(".")}),c=C(()=>Be.NaNPersistent!=null?Be.NaNPersistent.value:null);function d(){Be.NaNPersistent!=null&&(Be.NaNPersistent.value=new o(0),Be.hasNaN=!1)}function m(){Be.NaNPersistent&&(Be.NaNPersistent.value=new o(1),Be.hasNaN=!1)}function p(){Be.NaNPersistent&&(Be.NaNPersistent.value=new o(NaN),Be.hasNaN=!1)}return(h,w)=>(M(),P(ne,null,[f(Ut,zt({modelValue:s(a),"onUpdate:modelValue":w[4]||(w[4]=b=>Ae(a)?a.value=b:null)},h.$attrs),{header:W(()=>[Ap]),body:W(()=>[N("div",null,[E(' Attempted to assign "'+se(s(u))+'" to NaN',1),s(c)?(M(),P("span",Fp,se(" ")+"(previously "+se(s(he)(s(c)))+")",1)):j("",!0),E(". Auto-saving has been "+se(i.value?"enabled":"disabled")+". Check the console for more details, and consider sharing it with the developers on discord. ",1)]),Op,N("div",null,[N("a",{href:s(n)||"https://discord.gg/yJ4fjnjU54",class:"nan-modal-discord-link"},[qp,E(" "+se(s(t)||"The Paper Pilot Community"),1)],8,Rp)]),Vp,f(Bt,{title:"Autosave",modelValue:i.value,"onUpdate:modelValue":w[0]||(w[0]=b=>i.value=b)},null,8,["modelValue"]),s(pe).enablePausing?(M(),ee(Bt,{key:0,title:"Pause game",modelValue:r.value,"onUpdate:modelValue":w[1]||(w[1]=b=>r.value=b)},null,8,["modelValue"])):j("",!0)]),footer:W(()=>[N("div",Bp,[N("button",{onClick:w[2]||(w[2]=b=>{var v;return(v=l.value)==null?void 0:v.open()}),class:"button"},"Open Saves Manager"),N("button",{onClick:d,class:"button"},"Set to 0"),N("button",{onClick:m,class:"button"},"Set to 1"),s(c)&&s(o).neq(s(c),0)&&s(o).neq(s(c),1)?(M(),P("button",{key:0,onClick:w[3]||(w[3]=b=>a.value=!1),class:"button"}," Set to previous ")):j("",!0),N("button",{onClick:p,class:"button danger"},"Ignore")])]),_:1},16,["modelValue"]),f(Lr,{ref_key:"savesManager",ref:l},null,512)],64))}});var jp=ue(Lp,[["__scopeId","data-v-2776d67d"]]);const zp={key:0,class:"tpsDisplay"},Up={key:0,class:"low"},Gp=X({__name:"TPS",setup(e){const t=C(()=>o.div(Be.lastTenTicks.length,Be.lastTenTicks.reduce((a,l)=>a+l,0))),n=L([]);kt(()=>{n.value.push(Math.round(t.value.toNumber())),n.value.length>10&&(n.value=n.value.slice(1))});const i=C(()=>n.value.reduce((a,l)=>o.max(a,l),0)),r=C(()=>o.sub(t.value,i.value).gt(1));return(a,l)=>s(t).isNan()?j("",!0):(M(),P("div",zp,[E(" TPS: "+se(s(ht)(s(t)))+" ",1),f(Dn,{name:"fade"},{default:W(()=>[s(r)?(M(),P("span",Up,se(s(ht)(s(i))),1)):j("",!0)]),_:1})]))}});var Wp=ue(Gp,[["__scopeId","data-v-46a3ed5b"]]);var Hp=X({__name:"App",setup(e){const t=pe.useHeader,n=C(()=>Ct[ae.theme].variables),i=Qt(ae,"showTPS"),r=C(()=>oe(K(()=>f(ne,null,[Ps.map(nt)]))));return(a,l)=>(M(),P(ne,null,[N("div",{id:"modal-root",style:qe(s(n))},null,4),N("div",{class:ge(["app",{useHeader:s(t)}]),style:qe(s(n))},[s(t)?(M(),ee(jr,{key:0})):j("",!0),f(Yl),s(s(i))?(M(),ee(Wp,{key:1})):j("",!0),f(Tp),f(jp),(M(),ee(He(s(r))))],6)],64))}});var Zp=ue(Hp,[["__scopeId","data-v-41d15e5e"]]);function Yp(e={}){const{immediate:t=!1,onNeedRefresh:n,onOfflineReady:i,onRegistered:r,onRegisteredSW:a,onRegisterError:l}=e;let u,c,d,m;const p=async(w=!0)=>{await d,w&&(u==null||u.addEventListener("controlling",b=>{b.isUpdate&&window.location.reload()})),await(m==null?void 0:m())};async function h(){if("serviceWorker"in navigator){const{Workbox:w,messageSW:b}=await zn(()=>import("./workbox-window.4a8794bb.js"),[]);m=async()=>{c&&c.waiting&&await b(c.waiting,{type:"SKIP_WAITING"})},u=new w("./sw.js",{scope:"./",type:"classic"}),u.addEventListener("activated",v=>{v.isUpdate||i==null||i()});{const v=()=>{n==null||n()};u.addEventListener("waiting",v),u.addEventListener("externalwaiting",v)}u.register({immediate:t}).then(v=>{c=v,a?a("./sw.js",v):r==null||r(v)}).catch(v=>{l==null||l(v)})}}return d=h(),p}function Xp(e={}){const{immediate:t=!0,onNeedRefresh:n,onOfflineReady:i,onRegistered:r,onRegisteredSW:a,onRegisterError:l}=e,u=L(!1),c=L(!1);return{updateServiceWorker:Yp({immediate:t,onNeedRefresh(){u.value=!0,n==null||n()},onOfflineReady(){c.value=!0,i==null||i()},onRegistered:r,onRegisteredSW:a,onRegisterError:l}),offlineReady:c,needRefresh:u}}document.title=pe.title;window.projInfo=pe;if(pe.id==="")throw new Error("Project ID is empty! Please select a unique ID for this project in /src/data/projInfo.json");requestAnimationFrame(async()=>{console.log(`%cMade in Profectus%c
Learn more at www.moddingtree.com`,"font-weight: bold; font-size: 24px; color: #A3BE8C; background: #2E3440; padding: 4px 8px; border-radius: 8px;","padding: 4px;"),await Ss();const{globalBus:e}=await zn(()=>Promise.resolve().then(function(){return ks}),void 0),{startGameLoop:t}=await zn(()=>import("./gameLoop.e224c036.js"),["assets/gameLoop.e224c036.js","assets/@fontsource.f66d05e7.css","assets/vue.c16a309b.js","assets/amator.1e5a40c8.js","assets/bezier-easing.a990b400.js","assets/@vue.6b211d3c.js","assets/nanoevents.1080beb7.js","assets/lz-string.dccec454.js","assets/vue-next-select.ded54c4a.js","assets/vue-next-select.9e6f4164.css","assets/vuedraggable.1879de79.js","assets/sortablejs.a0f68e5e.js","assets/vue-textarea-autosize.35804eaf.js","assets/vue-panzoom.8ce6f9b1.js","assets/panzoom.30c56ba6.js","assets/wheel.f2ae740f.js","assets/ngraph.events.083734c6.js","assets/vue-toastification.9c2dad53.js","assets/vue-toastification.4b5f8ac8.css"]),n=window.vue=_a(Zp);e.emit("setupVue",n),n.mount("#app"),jt(()=>{const i=fi(),{updateServiceWorker:r}=Xp({onNeedRefresh(){i.info("New content available, click here to update.",{timeout:!1,closeOnClick:!1,draggable:!1,icon:{iconClass:"material-icons",iconChildren:"refresh",iconTag:"i"},rtl:!1,onClick(){r()}})},onOfflineReady(){i.info("App ready to work offline")},onRegisterError:console.warn,onRegistered(a){a&&setInterval(()=>a.update(),60*60*1e3)}})}),t()});export{o as D,zn as _,Be as a,pe as b,_p as c,Ze as g,Is as l,Q as p,ae as s};