mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-25 17:59:59 +00:00
18 lines
218 KiB
JavaScript
18 lines
218 KiB
JavaScript
/* empty css */import"./vue.c16a309b.js";import{_ as C,C as s,l as qe,q as mn,t as z,b2 as vt,ab as Y,aF as M,a1 as D,a2 as N,aL as Ft,G as ve,aD as Cr,w as ht,b3 as Et,a9 as f,O as te,ap as ma,az as gi,as as Wt,aH as ii,A as Te,$ as K,b7 as W,b9 as ji,ar as Ht,bv as Pn,a8 as E,bt as va,bc as jn,T as ha,u as zi,j as ba,bw as Rt,aM as It,a0 as j,aO as Xe,J as se,I as Le,aI as hn,aG as bn,z as an,bo as ya,bs as wa,aK as Dn,bd as lr,am as oi,H as _a,bx as Na,bf as Ca}from"./@vue.6b211d3c.js";import{c as kr}from"./nanoevents.1080beb7.js";import{L as nn}from"./lz-string.dccec454.js";import{Y as ka}from"./vue-next-select.ded54c4a.js";import{D as Ma}from"./vuedraggable.1879de79.js";import{p as Sa}from"./vue-textarea-autosize.35804eaf.js";import{P as Ia}from"./vue-panzoom.8ce6f9b1.js";import{s as xa,u as mi}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 $a=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)}};$a();const Ea="modulepreload",ur={},Pa="./",zn=function(t,n){return!n||n.length===0?t():Promise.all(n.map(i=>{if(i=`${Pa}${i}`,i in ur)return;ur[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":Ea,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())},Da="./projInfo-schema.json",Ta="Planar Pioneers",Aa="A game about controlling and exploiting planes!",Fa="planar-pioneers",Ra="thepaperpilot",Oa="",qa="",Va="0.0",Ba="Initial Commit",La=!1,ja=!1,za=2,Ua=!0,Ga=null,Wa="",Ha=["main"],Za=3600,Ya=0,Xa=!0,Ja="base64";var ge={$schema:Da,title:Ta,description:Aa,id:Fa,author:Ra,discordName:Oa,discordLink:qa,versionNumber:Va,versionTitle:Ba,allowGoBack:La,defaultShowSmall:ja,defaultDecimalsShown:za,useHeader:Ua,banner:Ga,logo:Wa,initialTabs:Ha,maxTickLength:Za,offlineLimit:Ya,enablePausing:Xa,exportEncoding:Ja};class Ka{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 Qa(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 Qa{constructor(t,n){this.next=void 0,this.prev=void 0,this.key=t,this.value=n}}const Pi=17,es=9e15,ts=Math.log10(9e15),ns=1/9e15,is=308,rs=-324,cr=5,as=(1<<10)-1,ss=function(){const e=[];for(let n=rs+1;n<=is;n++)e.push(Number("1e"+n));const t=323;return function(n){return e[n+t]}}(),ln=[2,Math.E,3,4,5,6,7,8,9,10],os=[[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]],ls=[[-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)},Z=function(e,t,n){return o.fromComponents(e,t,n)},Q=function(t,n,i){return o.fromComponents_noNormalize(t,n,i)};const Qt=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))},us=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},Mr=.5671432904097838,dr=function(e,t=1e-10){let n,i;if(!Number.isFinite(e)||e===0)return e;if(e===1)return Mr;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 pr(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(Mr);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 b=class{constructor(e){this.sign=0,this.mag=0,this.layer=0,e instanceof b?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/ss(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 b().fromComponents(e,t,n)}static fromComponents_noNormalize(e,t,n){return new b().fromComponents_noNormalize(e,t,n)}static fromMantissaExponent(e,t){return new b().fromMantissaExponent(e,t)}static fromMantissaExponent_noNormalize(e,t){return new b().fromMantissaExponent_noNormalize(e,t)}static fromDecimal(e){return new b().fromDecimal(e)}static fromNumber(e){return new b().fromNumber(e)}static fromString(e){return new b().fromString(e)}static fromValue(e){return new b().fromValue(e)}static fromValue_noAlloc(e){if(e instanceof b)return e;if(typeof e=="string"){const t=b.fromStringCache.get(e);return t!==void 0?t:b.fromString(e)}else return typeof e=="number"?b.fromNumber(e):b.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=Q(1,0,1)){return k(e).tetrate(t,n)}static iteratedexp(e,t=2,n=Q(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=Q(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 Q(0,0,0);const t=Math.random()>.5?1:-1;if(Math.random()*20<1)return Q(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)),Z(t,n,r)}static affordGeometricSeries_core(e,t,n,i){const r=t.mul(n.pow(i));return b.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(b.sub(1,n.pow(e))).div(b.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<ns)return this.layer+=1,this.mag=Math.log10(this.mag),this;let e=Math.abs(this.mag),t=Math.sign(this.mag);if(e>=es)return this.layer+=1,this.mag=t*Math.log10(e),this;for(;e<ts&&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=b.fromStringCache.get(t);if(n!==void 0)return this.fromDecimal(n);e=e.replace(",","");const i=e.split("^^^");if(i.length===2){const _=parseFloat(i[0]),y=parseFloat(i[1]),I=i[1].split(";");let A=1;if(I.length===2&&(A=parseFloat(I[1]),isFinite(A)||(A=1)),isFinite(_)&&isFinite(y)){const S=b.pentate(_,y,A);return this.sign=S.sign,this.layer=S.layer,this.mag=S.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}}const r=e.split("^^");if(r.length===2){const _=parseFloat(r[0]),y=parseFloat(r[1]),I=r[1].split(";");let A=1;if(I.length===2&&(A=parseFloat(I[1]),isFinite(A)||(A=1)),isFinite(_)&&isFinite(y)){const S=b.tetrate(_,y,A);return this.sign=S.sign,this.layer=S.layer,this.mag=S.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}}const a=e.split("^");if(a.length===2){const _=parseFloat(a[0]),y=parseFloat(a[1]);if(isFinite(_)&&isFinite(y)){const I=b.pow(_,y);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.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 _=parseFloat(c[1]);if(isFinite(_)||(_=1),isFinite(l)&&isFinite(u)){const y=b.tetrate(l,u,_);return this.sign=y.sign,this.layer=y.layer,this.mag=y.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.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 _=parseFloat(c[1]);if(isFinite(_)||(_=1),isFinite(l)&&isFinite(u)){const y=b.tetrate(l,u,_);return this.sign=y.sign,this.layer=y.layer,this.mag=y.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}}const p=e.split("e"),v=p.length-1;if(v===0){const _=parseFloat(e);if(isFinite(_))return this.fromNumber(_),b.fromStringCache.size>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}else if(v===1){const _=parseFloat(e);if(isFinite(_)&&_!==0)return this.fromNumber(_),b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}const d=e.split("e^");if(d.length===2){this.sign=1,d[0].charAt(0)=="-"&&(this.sign=-1);let _="";for(let y=0;y<d[1].length;++y){const I=d[1].charCodeAt(y);if(I>=43&&I<=57||I===101)_+=d[1].charAt(y);else return this.layer=parseFloat(_),this.mag=parseFloat(d[1].substr(y+1)),this.normalize(),b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}}if(v<1)return this.sign=0,this.layer=0,this.mag=0,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this;const h=parseFloat(p[0]);if(h===0)return this.sign=0,this.layer=0,this.mag=0,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this;let m=parseFloat(p[p.length-1]);if(v>=2){const _=parseFloat(p[p.length-2]);isFinite(_)&&(m*=Math.sign(_),m+=Di(_))}if(!isFinite(h))this.sign=p[0]==="-"?-1:1,this.layer=v,this.mag=m;else if(v===1)this.sign=Math.sign(h),this.layer=1,this.mag=m+Math.log10(Math.abs(h));else if(this.sign=Math.sign(h),this.layer=v,v===2){const _=b.mul(Z(1,2,m),k(h));return this.sign=_.sign,this.layer=_.layer,this.mag=_.mag,b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}else this.mag=m;return this.normalize(),b.fromStringCache.maxSize>=1&&b.fromStringCache.set(t,b.fromDecimal(this)),this}fromValue(e){return e instanceof b?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:Qt(this.m,e)}magnitudeWithDecimalPlaces(e){return isNaN(this.mag)?Number.NaN:this.mag===0?0:Qt(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<=cr?(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):Qt(this.m,e)+"e"+Qt(this.e,e):this.layer===1?Qt(this.m,e)+"e"+Qt(this.e,e):this.layer<=cr?(this.sign===-1?"-":"")+"e".repeat(this.layer)+Qt(this.mag,e):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+Qt(this.mag,e)}abs(){return Q(this.sign===0?0:1,this.layer,this.mag)}neg(){return Q(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?b.dZero:this.layer===0?Z(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?b.dZero:this.layer===0?Z(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?b.dZero:this.layer===0?Z(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?b.dZero:this.layer===0?Z(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 Q(0,0,0);let n,i;if(this.layer>=2||t.layer>=2)return this.maxabs(t);if(b.cmpabs(this,t)>0?(n=this,i=t):(n=t,i=this),n.layer===0&&i.layer===0)return b.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))>Pi)return n;{const l=Math.pow(10,Math.log10(n.mag)-i.mag),u=i.sign+n.sign*l;return Z(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))>Pi)return n;{const l=Math.pow(10,n.mag-Math.log10(i.mag)),u=i.sign+n.sign*l;return Z(Math.sign(u),1,Math.log10(i.mag)+Math.log10(Math.abs(u)))}}if(Math.abs(n.mag-i.mag)>Pi)return n;{const l=Math.pow(10,n.mag-i.mag),u=i.sign+n.sign*l;return Z(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 Q(0,0,0);if(this.layer===t.layer&&this.mag===-t.mag)return Q(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 b.fromNumber(n.sign*i.sign*n.mag*i.mag);if(n.layer>=3||n.layer-i.layer>=2)return Z(n.sign*i.sign,n.layer,n.mag);if(n.layer===1&&i.layer===0)return Z(n.sign*i.sign,1,n.mag+Math.log10(i.mag));if(n.layer===1&&i.layer===1)return Z(n.sign*i.sign,1,n.mag+i.mag);if(n.layer===2&&i.layer===1){const r=Z(Math.sign(n.mag),n.layer-1,Math.abs(n.mag)).add(Z(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return Z(n.sign*i.sign,r.layer+1,r.sign*r.mag)}if(n.layer===2&&i.layer===2){const r=Z(Math.sign(n.mag),n.layer-1,Math.abs(n.mag)).add(Z(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return Z(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?b.dNaN:this.layer===0?Z(this.sign,0,1/this.mag):Z(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(b.dZero)?b.dZero:this.log10()}absLog10(){return this.sign===0?b.dNaN:this.layer>0?Z(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):Z(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?b.dNaN:this.layer>0?Z(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):Z(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?b.dNaN:this.layer===0&&e.layer===0?Z(this.sign,0,Math.log(this.mag)/Math.log(e.mag)):b.div(this.log10(),e.log10())}log2(){return this.sign<=0?b.dNaN:this.layer===0?Z(this.sign,0,Math.log2(this.mag)):this.layer===1?Z(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?Z(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):Z(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?b.dNaN:this.layer===0?Z(this.sign,0,Math.log(this.mag)):this.layer===1?Z(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?Z(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):Z(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)?Q(1,0,1):n;if(n.sign===1&&n.layer===0&&n.mag===1)return n;if(i.sign===0)return Q(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:b.dNaN:r}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return b.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 Z(1,0,t);if(e.sign===0)return b.dOne;e=Q(e.sign,e.layer+1,Math.log10(e.mag))}return e.sign>0&&e.mag>=0?Z(e.sign,e.layer+1,e.mag):e.sign<0&&e.mag>=0?Z(-e.sign,e.layer+1,-e.mag):b.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?b.exp(b.mul(this,b.ln(this).sub(1))):b.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(Q(1,0,24)))return b.fromNumber(us(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 b.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,b.exp(t)}else return this.layer===1?b.exp(b.mul(this,b.ln(this).sub(1))):b.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?b.dOne:this.layer===0&&this.mag<=709.7?b.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?Z(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?Z(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):Z(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return b.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return Z(1,2,Math.log10(this.mag)-.3010299956639812);{const e=b.div(Q(this.sign,this.layer-1,this.mag),Q(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=Q(1,0,1)){if(e===1)return b.pow(this,t);if(e===0)return new b(t);if(this.eq(b.dOne))return b.dOne;if(this.eq(-1))return b.pow(this,t);if(e===Number.POSITIVE_INFINITY){const r=this.toNumber();if(r<=1.444667861009766&&r>=.06598803584531254){if(r>1.444667861009099)return b.fromNumber(Math.E);const a=b.ln(this).neg();return a.lambertw().div(a)}else return r>1.444667861009766?b.fromNumber(Number.POSITIVE_INFINITY):b.dNaN}if(this.eq(b.dZero)){let r=Math.abs((e+1)%2);return r>1&&(r=2-r),b.fromNumber(r)}if(e<0)return b.iteratedlog(t,this,-e);t=k(t);const n=e;e=Math.trunc(e);const i=n-e;if(this.gt(b.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(b.dOne)?this.gt(10)?t=this.pow(i):(t=b.fromNumber(b.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 Q(t.sign,t.layer+(e-r-1),t.mag);if(r>1e4)return t}return t}iteratedexp(e=2,t=Q(1,0,1)){return this.tetrate(e,t)}iteratedlog(e=10,t=1){if(t<0)return b.tetrate(e,-t,this);e=k(e);let n=b.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 b(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 b.fromNumber(a)}slog_internal(e=10){if(e=k(e),e.lte(b.dZero)||e.eq(b.dOne))return b.dNaN;if(e.lt(b.dOne))return this.eq(b.dOne)?b.dZero:this.eq(b.dZero)?b.dNegOne:b.dNaN;if(this.mag<0||this.eq(b.dZero))return b.dNegOne;let t=0,n=b.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(b.dZero))n=b.pow(e,n),t-=1;else{if(n.lte(b.dOne))return b.fromNumber(t+b.slog_critical(e.toNumber(),n.toNumber()));t+=1,n=b.log(n,e)}return b.fromNumber(t)}static slog_critical(e,t){return e>10?t-1:b.critical_section(e,t,ls)}static tetrate_critical(e,t){return b.critical_section(e,t,os)}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<ln.length;++l)if(ln[l]==e){i=n[l][Math.floor(t)],r=n[l][Math.ceil(t)];break}else if(ln[l]<e&&ln[l+1]>e){const u=(e-ln[l])/(ln[l+1]-ln[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=b.fromValue_noAlloc(e).toNumber();const t=b.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?b.tetrate(t,i):Number.isFinite(i)?i>=-1?b.log(b.tetrate(t,i+1),t):b.log(b.log(b.tetrate(t,i+2),t),t):b.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return b.fromNumber(dr(this.toNumber()));if(this.layer===0)return b.fromNumber(dr(this.sign*this.mag));if(this.layer===1)return pr(this);if(this.layer===2)return pr(this);if(this.layer>=3)return Q(this.sign,this.layer-1,this.mag);throw new Error("Unhandled behavior in lambertw()")}ssqrt(){if(this.sign==1&&this.layer>=3)return Q(this.sign,this.layer-1,this.mag);const e=this.ln();return e.div(e.lambertw())}pentate(e=2,t=Q(1,0,1)){t=k(t);const n=e;e=Math.trunc(e);const i=n-e;i!==0&&(t.eq(b.dOne)?(++e,t=b.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?b.fromNumber(Math.sin(this.sign*this.mag)):Q(0,0,0)}cos(){return this.mag<0?b.dOne:this.layer===0?b.fromNumber(Math.cos(this.sign*this.mag)):Q(0,0,0)}tan(){return this.mag<0?this:this.layer===0?b.fromNumber(Math.tan(this.sign*this.mag)):Q(0,0,0)}asin(){return this.mag<0?this:this.layer===0?b.fromNumber(Math.asin(this.sign*this.mag)):Q(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?b.fromNumber(Math.acos(this.toNumber())):this.layer===0?b.fromNumber(Math.acos(this.sign*this.mag)):Q(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?b.fromNumber(Math.atan(this.sign*this.mag)):b.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 b.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return b.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?Q(Number.NaN,Number.NaN,Number.NaN):b.ln(this.add(1).div(b.fromNumber(1).sub(this))).div(2)}ascensionPenalty(e){return e===0?this:this.root(b.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=b;o.fromStringCache=new Ka(as);o.dZero=Q(0,0,0);o.dOne=Q(1,0,1);o.dNegOne=Q(-1,0,1);o.dTwo=Q(1,0,2);o.dTen=Q(1,0,10);o.dNaN=Q(Number.NaN,Number.NaN,Number.NaN);o.dInf=Q(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);o.dNegInf=Q(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);o.dNumberMax=Z(1,0,Number.MAX_VALUE);o.dNumberMin=Z(1,0,Number.MIN_VALUE);k=o.fromValue_noAlloc;Z=o.fromComponents;Q=o.fromComponents_noNormalize;o.fromMantissaExponent;o.fromMantissaExponent_noNormalize;const cs=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=cs,i=i.add(1));const a=i.gte(1e9)?bt(i,Math.max(Math.max(t,3),ge.defaultDecimalsShown)):i.gte(1e4)?li(i,0):i.toStringWithDecimalPlaces(0);return n?r.toStringWithDecimalPlaces(t)+"e"+a:"e"+a}function li(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 Sr(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()),ge.defaultDecimalsShown)),e.toStringWithDecimalPlaces(t)))}const ds=new o("eeee1000"),ps=new o("e100000"),fr=new o("e1000"),Ir=new o(1e9),fs=new o(1e6),gs=new o(1e3),ms=new o(.98),vs=new o(.001),xr=new o(0);function bt(e,t,n){if(t==null&&(t=ge.defaultDecimalsShown),n=n!=null?n:ge.defaultShowSmall,e=new o(e),isNaN(e.sign)||isNaN(e.layer)||isNaN(e.mag))return"NaN";if(e.sign<0)return"-"+bt(e.neg(),t);if(e.mag===Number.POSITIVE_INFINITY)return"Infinity";if(e.gte(ds)){const i=e.slog();return i.gte(fs)?"F"+bt(i.floor()):o.pow(10,i.sub(i.floor())).toStringWithDecimalPlaces(3)+"F"+li(i.floor(),0)}else{if(e.gte(ps))return qn(e,0,!1);if(e.gte(fr))return qn(e,0);if(e.gte(Ir))return qn(e,t);if(e.gte(gs))return li(e,0);if(e.gte(vs)||!n)return Sr(e,t);if(e.eq(xr))return 0 .toFixed(t)}return e=Er(e),e.lt(fr)?qn(e,t).replace(/([^(?:e|F)]*)$/,"-$1"):bt(e,t)+"\u207B\xB9"}function Ye(e){return e=new o(e),e.sign<0?"-"+Ye(e.neg()):e.gte(Ir)||e.lte(ms)&&!e.eq(xr)?bt(e):bt(e,0)}function $r(e){return o.lt(e,0)?"-"+$r(o.neg(e)):o.gt(e,2**51)?bt(o.div(e,31536e3))+"y":(e=new o(e).toNumber(),e<60?bt(e)+"s":e<3600?Ye(Math.floor(e/60))+"m "+bt(e%60)+"s":e<86400?Ye(Math.floor(e/3600))+"h "+Ye(Math.floor(e/60)%60)+"m "+Ye(e%60)+"s":e<31536e3?Ye(Math.floor(e/84600)%365)+"d "+Ye(Math.floor(e/3600)%24)+"h "+Ye(Math.floor(e/60)%60)+"m":Ye(Math.floor(e/31536e3))+"y "+Ye(Math.floor(e/84600)%365)+"d "+Ye(Math.floor(e/3600)%24)+"h")}function hs(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 bs(e,t){return bt(e,t,!0)}function Er(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 ys=Object.freeze(Object.defineProperty({__proto__:null,default:o,exponentialFormat:qn,commaFormat:li,regularFormat:Sr,format:bt,formatWhole:Ye,formatTime:$r,toPlaces:hs,formatSmall:bs,invertOOM:Er},Symbol.toStringTag,{value:"Module"}));const{exponentialFormat:ws,commaFormat:_s,regularFormat:Ns,format:we,formatWhole:Mt,formatTime:vi,toPlaces:Cs,formatSmall:Gt,invertOOM:ks}=ys;window.Decimal=o;window.exponentialFormat=ws;window.commaFormat=_s;window.regularFormat=Ns;window.format=we;window.formatWhole=Mt;window.formatTime=vi;window.toPlaces=Cs;window.formatSmall=Gt;window.invertOOM=ks;function et(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 me(e){return Un(e)&&!e[Gn]&&(e=C(e)),e}const yt=Symbol("Component"),pt=Symbol("GatherProps");let Ms=0;function on(e="feature-"){return e+Ms++}var _e=(e=>(e[e.Visible=0]="Visible",e[e.Hidden=1]="Hidden",e[e.None=2]="None",e))(_e||{});function ze(e){const t=s(e);return t!==2&&t!==!1}function yn(e){return s(e)===1}function X(e){return e[Gn]=!0,e}function ne(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)&&!qe(l)&&i(l))})};return i(e),n}const un={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 Ui=(e=>(e.Classic="classic",e.Paper="paper",e.Nordic="nordic",e.Aqua="aqua",e))(Ui||{}),kt={classic:un,paper:{...un,variables:{...un.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:{...un,variables:{...un.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:{...un,variables:{...un.variables,"--foreground":"#bfdfff","--background":"#001f3f","--tooltip-background":"rgba(0, 15, 31, 0.75)","--raised-background":"#001f3f","--points":"#dfefff","--locked":"#c4a7b3","--outline":"#bfdfff"}}};const Je=kr();"fonts"in document&&(document.fonts.onloadingdone=()=>Je.emit("fontsLoaded"));var Ss=Object.freeze(Object.defineProperty({__proto__:null,globalBus:Je},Symbol.toStringTag,{value:"Module"}));const Is=mn({id:"",devSpeed:null,name:"",tabs:[],time:-1,autosave:!0,offlineProd:!0,offlineTime:null,timePlayed:0,keepGoing:!1,modID:"",modVersion:"",layers:{}});var J=window.player=Is;function Pr(e){return JSON.stringify(e,(t,n)=>s(n))}function Dr(e={}){return Object.assign({id:`${ge.id}-0`,name:"Default Save",tabs:ge.initialTabs.slice(),time:Date.now(),autosave:!0,offlineProd:!0,offlineTime:0,timePlayed:0,keepGoing:!1,modID:ge.id,modVersion:ge.versionNumber,layers:{}},e)}function mt(e){const t=nn.compressToUTF16(Pr(e!=null?e:J));return localStorage.setItem((e!=null?e:J).id,t),t}async function xs(){Ps();try{let e=localStorage.getItem(ae.active);if(e==null){await pn($n());return}if(e[0]!=="{")if(e[0]==="e")e=decodeURIComponent(escape(atob(e)));else if(e[0]==="\u1BE1")e=nn.decompressFromUTF16(e);else throw"Unable to determine save encoding";const t=JSON.parse(e);if(t.modID!==ge.id){await pn($n());return}t.id=ae.active,await pn(t)}catch(e){console.error(`Failed to load save. Falling back to new save.
|
|
`,e),await pn($n())}}function $n(){const e=si(),t=Dr({id:e});return mt(t),ae.saves.push(e),t}function si(){let e,t=0;do e=`${ge.id}-${t++}`;while(localStorage.getItem(e)!=null);return e}const $s=z(!1);async function pn(e){console.info("Loading save",e),$s.value=!0;const{layers:t,removeLayer:n,addLayer:i}=await zn(()=>Promise.resolve().then(function(){return Qs}),void 0),{fixOldSave:r,getInitialLayers:a}=await zn(()=>Promise.resolve().then(function(){return Cp}),void 0);for(const l in t){const u=t[l];u&&n(u)}a(e).forEach(l=>i(l,e)),e=Dr(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,ge.offlineLimit*3600)),e.time=Date.now(),e.modVersion!==ge.versionNumber&&(r(e.modVersion,e),e.modVersion=ge.versionNumber),Object.assign(J,e),ae.active=J.id,Je.emit("onLoad")}setInterval(()=>{J.autosave&&mt()},1e3);window.onbeforeunload=()=>{J.autosave&&mt()};window.save=mt;const Es=window.hardReset=async()=>{await pn($n())};window.deleteLowerSaves=()=>{const e=Object.values(ae.saves).indexOf(J.id)+1;Object.values(ae.saves).slice(e).forEach(t=>localStorage.removeItem(t)),ae.saves=ae.saves.slice(0,e)};const Hn=mn({active:"",saves:[],showTPS:!0,theme:Ui.Nordic,unthrottled:!1,alignUnits:!1});vt(Hn,e=>{const t=nn.compressToUTF16(JSON.stringify(e));localStorage.setItem(ge.id,t)},{deep:!0});var ae=window.settings=Hn;window.hardResetSettings=()=>{const e={active:"",saves:[],showTPS:!0,theme:Ui.Nordic,alignUnits:!1};Je.emit("loadSettings",e),Object.assign(Hn,e),Es()};function Ps(){try{let e=localStorage.getItem(ge.id);if(e!=null&&e!==""){if(e[0]!=="{")if(e[0]==="e")e=decodeURIComponent(escape(atob(e)));else if(e[0]==="\u1BE1")e=nn.decompressFromUTF16(e);else{console.warn("Unable to determine settings encoding",e);return}const t=JSON.parse(e);typeof t=="object"&&Object.assign(Hn,t)}Je.emit("loadSettings",Hn)}catch{}}const Tr=mn([]);function Ds(e){Tr.push(e)}const Ts=mn([]),As=mn([]),Fs={class:"table"},Rs=Y({__name:"Column",setup(e){const t=C(()=>kt[ae.theme].mergeAdjacent);return(n,i)=>(M(),D("div",Fs,[N("div",{class:ve(["col",{mergeAdjacent:s(t)}])},[Ft(n.$slots,"default")],2)]))}}),Os={class:"table"},qs=Y({__name:"Row",setup(e){const t=C(()=>kt[ae.theme].mergeAdjacent);return(n,i)=>(M(),D("div",Os,[N("div",{class:ve(["row",{mergeAdjacent:s(t)}])},[Ft(n.$slots,"default")],2)]))}});function Ar(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!ma(e)}function oe(e,t="span"){return typeof e=="function"?Y({render:e}):typeof e=="string"?e.length>0?(e=e.trim(),e.charAt(0)!=="<"&&(e=`<${t}>${e}</${t}>`),Y({template:e})):Y({render:()=>({})}):e}function rt(e){if(Pt(e))return typeof e=="function"?e():oe(e);const t=e[yt];return f(t,e[pt](),null)}function Ti(...e){let t;return f(qs,null,Ar(t=e.map(rt))?t:{default:()=>[t]})}function Vs(...e){let t;return f(Rs,null,Ar(t=e.map(rt))?t:{default:()=>[t]})}function St(e){if(Pt(e))return typeof e=="function"?e():typeof e=="string"?f(te,null,[e]):f(e,null,null);const t=e[yt];return f(t,e[pt](),null)}function gr(e,t){return e.reduce((n,i)=>f(te,null,[n,t,i]))}function Pt(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 Fr(e,t){const n=z(null),i=z(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 Cr(a),{start:r,stop:a,handleHolding:l}}function Rr(e,t="div"){const n=ht();return Et(()=>{n.value=oe($e(e),t)}),n}function Tn(e,t="div"){const n=ht(null);return Et(()=>{const i=$e(e);n.value=i==""||i==null?null:oe(i,t)}),n}function $e(e){return s(s(e))}function R(...e){return e.includes(Object)||e.push(Object),e}function mr(e){const t=z(!1),n=e[pt].bind(e);return e[pt]=()=>({...n(),onPointerenter:()=>t.value=!0,onPointerleave:()=>t.value=!1}),t}var de=(e,t)=>{const n=e.__vccOpts||e;for(const[i,r]of t)n[i]=r;return n};const Bs=Y({__name:"Context",emits:["updateNodes"],setup(e,{emit:t}){var v;const n=z({}),i=new ResizeObserver(u),r=z(null);gi(()=>{const d=r.value;d!=null&&i.observe(d)});let a=!0,l=z((v=r.value)==null?void 0:v.getBoundingClientRect());function u(){a&&(a=!1,Wt(()=>{var d;l.value=(d=r.value)==null?void 0:d.getBoundingClientRect(),Object.values(n.value).filter(h=>h).forEach(h=>h.rect=h.element.getBoundingClientRect()),t("updateNodes",n.value),a=!0}))}Je.on("fontsLoaded",u);const c={attributes:!1,childList:!0,subtree:!1};ii(Gi,(d,h)=>{const m=new MutationObserver(()=>p(d));m.observe(h,c),n.value[d]={element:h,observer:m,rect:h.getBoundingClientRect()},u()}),ii(Wi,d=>{var h;(h=n.value[d])==null||h.observer.disconnect(),n.value[d]=void 0,u()}),ii(Hi,n),ii(Zi,l);function p(d){const h=n.value[d];h!=null&&(h.rect=h.element.getBoundingClientRect(),t("updateNodes",n.value))}return(d,h)=>(M(),D(te,null,[Ft(d.$slots,"default",{},void 0,!0),N("div",{ref_key:"resizeListener",ref:r,class:"resize-listener"},null,512)],64))}});var Or=de(Bs,[["__scopeId","data-v-2b1dc1bc"]]);const Ls=["onPointerdown"],js={class:"modal-wrapper"},zs={class:"modal-container"},Us={class:"modal-header"},Gs={class:"modal-body"},Ws={class:"modal-footer"},Hs=N("div",{class:"modal-default-flex-grow"},null,-1),Zt=Y({__name:"Modal",props:{modelValue:{type:Boolean}},emits:["update:modelValue"],setup(e,{expose:t,emit:n}){const r=Te(e),a=C(()=>s(r.modelValue)||u.value);function l(){n("update:modelValue",!1)}const u=z(!1),c=z(null),p=C(()=>{var v,d;return(d=(v=c.value)==null?void 0:v.nodes)!=null?d:null});return t({isOpen:a,nodes:p}),(v,d)=>(M(),K(ha,{to:"#modal-root"},[f(jn,{name:"modal",onBeforeEnter:d[0]||(d[0]=h=>u.value=!0),onAfterLeave:d[1]||(d[1]=h=>u.value=!1)},{default:W(()=>[ji(N("div",Ht({class:"modal-mask",onPointerdown:Pn(l,["self"])},v.$attrs),[N("div",js,[N("div",zs,[N("div",Us,[Ft(v.$slots,"header",{shown:s(a)},()=>[E(" default header ")])]),N("div",Gs,[f(Or,{ref_key:"contextRef",ref:c},{default:W(()=>[Ft(v.$slots,"body",{shown:s(a)},()=>[E(" default body ")])]),_:3},512)]),N("div",Ws,[Ft(v.$slots,"footer",{shown:s(a)},()=>[N("div",{class:"modal-default-footer"},[Hs,N("button",{class:"button modal-default-button",onClick:l}," Close ")])])])])])],16,Ls),[[va,e.modelValue]])]),_:3})]))}}),tn=Symbol("ProxyState");function Ke(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===tn)return r();const u=r()[l];return u!=null&&typeof u=="object"&&At in u?u[At]:u},set(a,l,u){return r()[l]=u,!0},has(a,l){return l===tn?!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 je=window.state=zi({lastTenTicks:[],hasNaN:!1,NaNPath:[]});const rn=Symbol("PersistentState"),sn=Symbol("DefaultValue"),ui=Symbol("StackTrace"),ci=Symbol("Deleted"),At=Symbol("NonPersistent"),fn=Symbol("SaveDataPath"),Bi=Symbol("SkipPersistence");function Zs(){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 vr(e,t){var n;if(o.isNaN(t))throw je.hasNaN||(J.autosave=!1,je.hasNaN=!0,je.NaNPath=e[fn],je.NaNPersistent=e),console.error("Attempted to save NaN value to",(n=e[fn])==null?void 0:n.join("."),e),new Error("Attempted to set NaN value. See above for details");e[rn].value=t}function dt(e,t=!0){const n=qe(e)?e:z(e);qe(e)&&(e=e.value);const i=C({get(){return n.value},set(a){t?vr(r,a):r[rn].value=a}});i[sn]=e;const r={get value(){return n.value},set value(a){t?vr(r,a):r[rn].value=a},__v_isRef:!0,[rn]:n,[sn]:e,[ui]:Zs(),[ci]:!1,[At]:i,[fn]:void 0};return ct.length===0?console.warn("Creating a persistent ref outside of a layer. This is not officially supported",r,`
|
|
Created at:
|
|
`+r[ui]):gn[ct[ct.length-1]].add(r),r}function Ys(e){return e!=null&&typeof e=="object"&&rn in e}function Mn(e){return!(tn in e)&&At in e?e[At]:new Proxy(e,{get(t,n){if(n!==rn)return n===Bi?!0:t[n]},set(t,n,i){return t[n]=i,!0},has(t,n){return n===rn?!1:n==Bi?!0:Reflect.has(t,n)}})}function qr(e){ct.length===0?console.warn("Deleting a persistent ref outside of a layer. Ignoring...",e):gn[ct[ct.length-1]].delete(e),e[ci]=!0}Je.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[Bi]===!0)return;if(tn in c&&(c=c[tn]),Ys(c)){if(l=!0,c[ci]){console.warn("Deleted persistent ref present in returned object. Ignoring...",c,`
|
|
Created at:
|
|
`+c[ui]);return}gn[e.id].delete(c);const p=[e.id,...a,u];c[fn]!=null&&JSON.stringify(p)!==JSON.stringify(c[fn])&&console.error(`Persistent ref is being saved to \`${p.join(".")}\` when it's already present at \`${c[fn].join(".")}\`. This can cause unexpected behavior when loading saves between updates.`,c),c[fn]=p;const v=a.reduce((h,m)=>(m in h||(h[m]={}),h[m]),t),d=v[u];v[u]=c[rn],ba(v)?d!=null?v[u]=d:v[u]=c[sn]:d!=null?v[u].value=d:v[u].value=c[sn]}else!(c instanceof o)&&!qe(c)&&!n.includes(c)&&(typeof c.type=="symbol"&&n.push(c),i(c,[...a,u])&&(Rt(c)&&!Rt(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.",tn in r?r[tn]:r,u):l=!0))}}),l};i(e[tn]),gn[e.id].forEach(r=>{r[ci]||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[ui])}),gn[e.id].clear()});const Gi=Symbol("RegisterNode"),Wi=Symbol("UnregisterNode"),Hi=Symbol("Nodes"),Zi=Symbol("Bounds"),ye=zi({});window.layers=ye;const gn={},ct=[];function Yi(e,t){return Ke(()=>{const n={},i=n.emitter=kr();if(n.on=i.on.bind(i),n.emit=i.emit.bind(i),n.nodes=z({}),n.id=e,ct.push(e),gn[e]=new Set,n.minimized=dt(!1,!1),Object.assign(n,t.call(n,n)),ct[ct.length-1]==null||ct[ct.length-1]!==e)throw`Adding layers stack in invalid state. This should not happen
|
|
Stack: ${ct}
|
|
Trying to pop ${n.id}`;ct.pop(),x(n,"color"),x(n,"display"),x(n,"classes"),x(n,"style"),x(n,"name"),ne(n,"name",n.id),x(n,"minWidth"),ne(n,"minWidth",600),x(n,"minimizable"),ne(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 Xi(e,t){if(console.info("Adding layer",e.id),ye[e.id]){console.error("Attempted to add layer with same ID as existing layer",e.id,ye[e.id]);return}ne(t,"layers",{}),t.layers[e.id]==null&&(t.layers[e.id]={}),ye[e.id]=e,Je.emit("addLayer",e,t.layers[e.id])}function Xs(e){return ye[e]}function Vr(e){console.info("Removing layer",e.id),Je.emit("removeLayer",e),ye[e.id]=void 0}function Js(e){Vr(e),Xi(e,J)}function Ks(e){const t=z(!1);return{openModal:()=>t.value=!0,modal:X(()=>f(Zt,{modelValue:t.value,"onUpdate:modelValue":n=>t.value=n},{header:()=>f("h2",null,[s(e.name)]),body:s(e.display)}))}}Je.on("update",function(t){Object.values(ye).forEach(n=>{n==null||n.emit("preUpdate",t)}),Object.values(ye).forEach(n=>{n==null||n.emit("update",t)}),Object.values(ye).forEach(n=>{n==null||n.emit("postUpdate",t)})});var Qs=Object.freeze(Object.defineProperty({__proto__:null,RegisterNodeInjectionKey:Gi,UnregisterNodeInjectionKey:Wi,NodesInjectionKey:Hi,BoundsInjectionKey:Zi,layers:ye,persistentRefs:gn,addingLayers:ct,createLayer:Yi,addLayer:Xi,getLayer:Xs,removeLayer:Vr,reloadLayer:Js,setupLayerModal:Ks},Symbol.toStringTag,{value:"Module"}));const eo=Y({components:{Context:Or},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}=Te(e),a=Rr(t),l=Tn(r),u=C(()=>ge.allowGoBack&&n.value>0&&!$e(i));function c(){J.tabs.splice(s(e.index),1/0)}function p(v){e.nodes.value=v}return{component:a,minimizedComponent:l,showGoBack:u,updateNodes:p,unref:s,goBack:c}}}),to={key:1};function no(e,t,n,i,r,a){const l=It("Context");return M(),D("div",{class:"layer-container",style:Le({"--layer-color":e.unref(e.color)})},[e.showGoBack?(M(),D("button",{key:0,class:"goBack",onClick:t[0]||(t[0]=(...u)=>e.goBack&&e.goBack(...u))},"\u274C")):j("",!0),e.unref(e.minimized)?(M(),D("button",{key:1,class:"layer-tab minimized",onClick:t[1]||(t[1]=u=>e.$emit("setMinimized",!1))},[e.minimizedComponent?(M(),K(Xe(e.minimizedComponent),{key:0})):(M(),D("div",to,se(e.unref(e.name)),1))])):(M(),D("div",{key:2,class:ve(["layer-tab",{showGoBack:e.showGoBack}])},[f(l,{onUpdateNodes:e.updateNodes},{default:W(()=>[(M(),K(Xe(e.component)))]),_:1},8,["onUpdateNodes"])],2)),e.unref(e.minimizable)?(M(),D("button",{key:3,class:"minimize",onClick:t[2]||(t[2]=u=>e.$emit("setMinimized",!0))}," \u25BC ")):j("",!0)],4)}var io=de(eo,[["render",no],["__scopeId","data-v-72dd78b1"]]);const Br=e=>(hn("data-v-4b4bda40"),e=e(),bn(),e),ro=Br(()=>N("h2",null,"Changelog",-1)),ao=Br(()=>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)),so=Y({__name:"Changelog",setup(e,{expose:t}){const n=z(!1);return t({open(){n.value=!0}}),(i,r)=>(M(),K(Zt,{modelValue:n.value,"onUpdate:modelValue":r[0]||(r[0]=a=>n.value=a)},{header:W(()=>[ro]),body:W(()=>[ao]),_:1},8,["modelValue"]))}});var oo=de(so,[["__scopeId","data-v-4b4bda40"]]),lo=Y({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}=Te(e),r=z(!1),a=C(()=>($e(i)||r.value)&&l.value),l=Tn(n),u=ht(oe(X(()=>{const v=$e(t);return v==null?"":St(v)})));function c(v){const d=i;v.shiftKey&&d&&(d.value=!d.value,v.stopPropagation(),v.preventDefault())}const p=C(()=>$e(i)&&kt[ae.theme].showPin);return{Direction:U,isHovered:r,isShown:a,comp:l,elementComp:u,unref:s,togglePinned:c,showPin:p}}});const uo={key:0,class:"material-icons pinned"};function co(e,t,n,i,r,a){return M(),D("div",{class:ve(["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))},[Ft(e.$slots,"default",{},void 0,!0),e.elementComp?(M(),K(Xe(e.elementComp),{key:0})):j("",!0),f(jn,{name:"fade"},{default:W(()=>{var l;return[e.isShown?(M(),D("div",{key:0,class:ve(["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:Le([{"--xoffset":e.unref(e.xoffset)||"0px","--yoffset":e.unref(e.yoffset)||"0px"},(l=e.unref(e.style))!=null?l:{}])},[e.showPin?(M(),D("span",uo,"push_pin")):j("",!0),e.comp?(M(),K(Xe(e.comp),{key:1})):j("",!0)],6)):j("",!0)]}),_:1})],34)}var Oe=de(lo,[["render",co],["__scopeId","data-v-6102fa3a"]]);const wn=e=>(hn("data-v-4f97aa40"),e=e(),bn(),e),po={class:"info-modal-header"},fo=["src","alt"],go={class:"info-modal-title"},mo={key:0},vo={key:0},ho={key:0},bo=wn(()=>N("div",null," Made in Profectus, by thepaperpilot with inspiration from Acameada and Jacorb ",-1)),yo=wn(()=>N("br",null,null,-1)),wo=wn(()=>N("br",null,null,-1)),_o=["href"],No=wn(()=>N("span",{class:"material-icons info-modal-discord"},"discord",-1)),Co=wn(()=>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)),ko=wn(()=>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)),Mo=wn(()=>N("br",null,null,-1));var So=Y({__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:p}=ge,v=Te(n),d=z(!1),h=C(()=>vi(J.timePlayed)),m=C(()=>oe(X(()=>f(te,null,[Ts.map(rt)]))));t({open(){d.value=!0}});function _(){var y;(y=s(v.changelog))==null||y.open()}return(y,I)=>(M(),K(Zt,{modelValue:d.value,"onUpdate:modelValue":I[0]||(I[0]=A=>d.value=A)},{header:W(()=>[N("div",po,[s(r)?(M(),D("img",{key:0,class:"info-modal-logo",src:s(r),alt:s(i)},null,8,fo)):j("",!0),N("div",go,[N("h2",null,se(s(i)),1),N("h4",null,[E(" v"+se(s(c)),1),s(p)?(M(),D("span",mo,": "+se(s(p)),1)):j("",!0)])])])]),body:W(({shown:A})=>[A?(M(),D("div",vo,[s(a)?(M(),D("div",ho,"By "+se(s(a)),1)):j("",!0),bo,yo,N("div",{class:"link",onClick:_},"Changelog"),wo,N("div",null,[s(u)?(M(),D("a",{key:0,href:s(u),class:"info-modal-discord-link",target:"_blank"},[No,E(" "+se(s(l)),1)],8,_o)):j("",!0)]),Co,ko,Mo,N("div",null,"Time Played: "+se(s(h)),1),(M(),K(Xe(s(m))))])):j("",!0)]),_:1},8,["modelValue"]))}});var Io=de(So,[["__scopeId","data-v-4f97aa40"]]);const xo={class:"field"},$o={key:0,class:"field-title"},Ji=Y({__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(an(n,"title"),"span"),r=z((l=n.options.find(u=>u.value===n.modelValue))!=null?l:null);vt(an(n,"modelValue"),u=>{var c;$e(r)!==u&&(r.value=(c=n.options.find(p=>p.value===u))!=null?c:null)});function a(u){t("update:modelValue",u.value)}return(u,c)=>(M(),D("div",xo,[s(i)?(M(),D("span",$o,[(M(),K(Xe(s(i))))])):j("",!0),f(s(ka),{options:e.options,modelValue:r.value,"onUpdate:modelValue":[c[0]||(c[0]=p=>r.value=p),a],min:1,"label-by":"label",placeholder:e.placeholder,"close-on-select":e.closeOnSelect},null,8,["options","modelValue","placeholder","close-on-select"])]))}});const Eo={class:"field"},Po=Y({__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(),D("label",Eo,[ji(N("input",{type:"checkbox",class:"toggle","onUpdate:modelValue":l[0]||(l[0]=u=>qe(r)?r.value=u:null)},null,512),[[ya,s(r)]]),(M(),K(Xe(s(i))))]))}});var zt=de(Po,[["__scopeId","data-v-11046116"]]);const Do=["onClick"],To=Y({__name:"FeedbackButton",props:{left:{type:Boolean}},emits:["click"],setup(e,{emit:t}){const n=z(!1),i=z(null);function r(){t("click"),i.value&&clearTimeout(i.value),n.value=!1,Wt(()=>{n.value=!0,i.value=setTimeout(()=>n.value=!1,500)})}return(a,l)=>(M(),D("button",{onClick:Pn(r,["stop"]),class:ve(["feedback",{activated:n.value,left:e.left}])},[Ft(a.$slots,"default",{},void 0,!0)],10,Do))}});var Lr=de(To,[["__scopeId","data-v-01a1b95c"]]);const Ao={class:"header"},Fo=N("h2",null,"Settings",-1),Ro={class:"option-tabs"},Oo={key:0},qo={key:1};var Vo=Y({__name:"Options",setup(e,{expose:t}){const n=z(!1),i=z("behaviour");function r(pe){return pe==i.value}function a(pe){i.value=pe}t({isTab:r,setTab:a,save:mt,open(){n.value=!0}});const l=Object.keys(kt).map(pe=>({label:et(pe),value:pe})),u=C(()=>oe(X(()=>f(te,null,[Tr.map(rt)])))),{showTPS:c,theme:p,unthrottled:v,alignUnits:d}=Te(ae),{autosave:h,offlineProd:m}=Te(J),_=C({get(){return J.devSpeed===0},set(pe){J.devSpeed=pe?0:null}}),y=X(()=>f("span",{class:"option-title"},[E("Unthrottled"),f("desc",null,[E("Allow the game to run as fast as possible. Not battery friendly.")])])),I=X(()=>f("span",{class:"option-title"},[E("Offline Production"),f(Oe,{display:"Save-specific",direction:U.Right},{default:()=>[E("*")]}),f("desc",null,[E("Simulate production that occurs while the game is closed.")])])),A=X(()=>f("span",{class:"option-title"},[E("Autosave"),f(Oe,{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=X(()=>f("span",{class:"option-title"},[E("Pause game"),f(Oe,{display:"Save-specific",direction:U.Right},{default:()=>[E("*")]}),f("desc",null,[E("Stop everything from moving.")])])),P=X(()=>f("span",{class:"option-title"},[E("Theme"),f("desc",null,[E("How the game looks.")])])),B=X(()=>f("span",{class:"option-title"},[E("Show TPS"),f("desc",null,[E("Show TPS meter at the bottom-left corner of the page.")])])),ie=X(()=>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(pe,ee)=>(M(),K(Zt,{modelValue:n.value,"onUpdate:modelValue":ee[10]||(ee[10]=H=>n.value=H)},{header:W(()=>[N("div",Ao,[Fo,N("div",Ro,[N("button",{class:ve({selected:r("behaviour")}),onClick:ee[0]||(ee[0]=H=>a("behaviour"))},"Behaviour",2),N("button",{class:ve({selected:r("appearance")}),onClick:ee[1]||(ee[1]=H=>a("appearance"))},"Appearance",2)])])]),body:W(()=>[r("behaviour")?(M(),D("div",Oo,[f(zt,{title:s(y),modelValue:s(v),"onUpdate:modelValue":ee[2]||(ee[2]=H=>qe(v)?v.value=H:null)},null,8,["title","modelValue"]),s(ge).enablePausing?(M(),K(zt,{key:0,title:s(S),modelValue:s(_),"onUpdate:modelValue":ee[3]||(ee[3]=H=>qe(_)?_.value=H:null)},null,8,["title","modelValue"])):j("",!0),f(zt,{title:s(I),modelValue:s(m),"onUpdate:modelValue":ee[4]||(ee[4]=H=>qe(m)?m.value=H:null)},null,8,["title","modelValue"]),f(zt,{title:s(A),modelValue:s(h),"onUpdate:modelValue":ee[5]||(ee[5]=H=>qe(h)?h.value=H:null)},null,8,["title","modelValue"]),s(h)?j("",!0):(M(),K(Lr,{key:1,class:"button save-button",onClick:ee[6]||(ee[6]=H=>s(mt)())},{default:W(()=>[E("Manually save")]),_:1}))])):j("",!0),r("appearance")?(M(),D("div",qo,[f(Ji,{title:s(P),options:s(l),modelValue:s(p),"onUpdate:modelValue":ee[7]||(ee[7]=H=>qe(p)?p.value=H:null)},null,8,["title","options","modelValue"]),(M(),K(Xe(s(u)))),f(zt,{title:s(B),modelValue:s(c),"onUpdate:modelValue":ee[8]||(ee[8]=H=>qe(c)?c.value=H:null)},null,8,["title","modelValue"]),f(zt,{title:s(ie),modelValue:s(d),"onUpdate:modelValue":ee[9]||(ee[9]=H=>qe(d)?d.value=H:null)},null,8,["title","modelValue"])])):j("",!0)]),_:1},8,["modelValue"]))}});const Bo=["onSubmit"],Lo={class:"field"},jo={key:0,class:"field-title"},zo=["placeholder"],Uo=Y({__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(an(n,"title"),"span"),r=ht(null);gi(()=>{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,p)=>(M(),D("form",{onSubmit:Pn(l,["prevent"])},[N("div",Lo,[s(i)?(M(),D("span",jo,[(M(),K(Xe(s(i))))])):j("",!0),e.textArea?(M(),K(s(Sa),{key:1,modelValue:s(a),"onUpdate:modelValue":p[0]||(p[0]=v=>qe(a)?a.value=v:null),placeholder:e.placeholder,maxHeight:e.maxHeight,onBlur:u,ref_key:"field",ref:r},null,8,["modelValue","placeholder","maxHeight"])):ji((M(),D("input",{key:2,type:"text","onUpdate:modelValue":p[1]||(p[1]=v=>qe(a)?a.value=v:null),placeholder:e.placeholder,class:ve({fullWidth:!e.title}),onBlur:u,ref_key:"field",ref:r},null,42,zo)),[[wa,s(a)]])])],40,Bo))}});var jr=de(Uo,[["__scopeId","data-v-90bd4994"]]);const Go={key:0},Wo=["onClick","disabled"],Ho={key:0},Zo=["onClick"],Yo=Y({__name:"DangerButton",props:{disabled:{type:Boolean},skipConfirm:{type:Boolean}},emits:["click","confirmingChanged"],setup(e,{emit:t}){const i=Te(e),r=z(!1);vt(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(),D("span",{class:ve(["container",{confirming:r.value}])},[r.value?(M(),D("span",Go,"Are you sure?")):j("",!0),N("button",{onClick:Pn(a,["stop"]),class:"button danger",disabled:e.disabled},[r.value?(M(),D("span",Ho,"Yes")):Ft(u.$slots,"default",{key:1},void 0,!0)],8,Wo),r.value?(M(),D("button",{key:1,class:"button",onClick:Pn(l,["stop"])},"No",8,Zo)):j("",!0)],2))}});var Xo=de(Yo,[["__scopeId","data-v-2f8ef34c"]]);const Yt=e=>(hn("data-v-32313015"),e=e(),bn(),e),Jo=Yt(()=>N("div",{class:"handle material-icons"},"drag_handle",-1)),Ko={key:0,class:"actions"},Qo=Yt(()=>N("span",{class:"material-icons"},"content_paste",-1)),el=Yt(()=>N("span",{class:"material-icons"},"content_copy",-1)),tl=Yt(()=>N("span",{class:"material-icons"},"edit",-1)),nl=Yt(()=>N("span",{class:"material-icons",style:{margin:"-2px"}},"delete",-1)),il={key:1,class:"actions"},rl=Yt(()=>N("span",{class:"material-icons"},"check",-1)),al=Yt(()=>N("span",{class:"material-icons"},"close",-1)),sl={key:2,class:"details"},ol={class:"save-version"},ll=Yt(()=>N("br",null,null,-1)),ul={key:0},cl={key:3,class:"details"},dl={key:4,class:"details error"},pl=Yt(()=>N("br",null,null,-1)),fl=Y({__name:"Save",props:{save:null},emits:["export","open","duplicate","delete","editName"],setup(e,{emit:t}){const n=e,{save:i}=Te(n),r=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}),a=z(!1),l=z(!1),u=z("");vt(a,()=>{var d;return u.value=(d=i.value.name)!=null?d:""});const c=C(()=>i.value!=null&&i.value.id===J.id),p=C(()=>{var d;return c.value?J.time:(d=i.value!=null&&i.value.time)!=null?d:0});function v(){t("editName",u.value),a.value=!1}return(d,h)=>(M(),D("div",{class:ve(["save",{active:s(c)}])},[Jo,a.value?(M(),D("div",il,[N("button",{onClick:v,class:"button"},[f(Oe,{display:"Save",direction:s(U).Left,class:"info"},{default:W(()=>[rl]),_:1},8,["direction"])]),N("button",{onClick:h[5]||(h[5]=m=>a.value=!a.value),class:"button"},[f(Oe,{display:"Cancel",direction:s(U).Left,class:"info"},{default:W(()=>[al]),_:1},8,["direction"])])])):(M(),D("div",Ko,[s(i).error==null&&!l.value?(M(),K(Lr,{key:0,onClick:h[0]||(h[0]=m=>t("export")),class:"button",left:""},{default:W(()=>[f(Oe,{display:"Export",direction:s(U).Left,class:"info"},{default:W(()=>[Qo]),_:1},8,["direction"])]),_:1})):j("",!0),s(i).error==null&&!l.value?(M(),D("button",{key:1,onClick:h[1]||(h[1]=m=>t("duplicate")),class:"button"},[f(Oe,{display:"Duplicate",direction:s(U).Left,class:"info"},{default:W(()=>[el]),_:1},8,["direction"])])):j("",!0),s(i).error==null&&!l.value?(M(),D("button",{key:2,onClick:h[2]||(h[2]=m=>a.value=!a.value),class:"button"},[f(Oe,{display:"Edit Name",direction:s(U).Left,class:"info"},{default:W(()=>[tl]),_:1},8,["direction"])])):j("",!0),f(Xo,{disabled:s(c),onClick:h[3]||(h[3]=m=>t("delete")),onConfirmingChanged:h[4]||(h[4]=m=>l.value=m)},{default:W(()=>[f(Oe,{display:"Delete",direction:s(U).Left,class:"info"},{default:W(()=>[nl]),_:1},8,["direction"])]),_:1},8,["disabled"])])),s(i).error==null&&!a.value?(M(),D("div",sl,[N("button",{class:"button open",onClick:h[6]||(h[6]=m=>t("open"))},[N("h3",null,se(s(i).name),1)]),N("span",ol,"v"+se(s(i).modVersion),1),ll,s(p)?(M(),D("div",ul,"Last played "+se(s(r).format(s(p))),1)):j("",!0)])):s(i).error==null&&a.value?(M(),D("div",cl,[f(jr,{modelValue:u.value,"onUpdate:modelValue":h[7]||(h[7]=m=>u.value=m),class:"editname",onSubmit:v},null,8,["modelValue"])])):(M(),D("div",dl,[E(" Error: Failed to load save with id "+se(s(i).id),1),pl,E(se(s(i).error),1)]))],2))}});var gl=de(fl,[["__scopeId","data-v-32313015"]]);const Ki=e=>(hn("data-v-2a4275be"),e=e(),bn(),e),ml=Ki(()=>N("h2",null,"Saves Manager",-1)),vl={class:"modal-footer"},hl={class:"field"},bl=Ki(()=>N("span",{class:"field-title"},"Create Save",-1)),yl={class:"field-buttons"},wl={class:"footer"},_l=Ki(()=>N("div",{style:{"flex-grow":"1"}},null,-1)),Nl=Y({__name:"SavesManager",setup(e,{expose:t}){const n=z(!1),i=z(null);t({open(){n.value=!0}});const r=z(!1),a=z(""),l=z(null);vt(a,S=>{S?Wt(()=>{try{if(S[0]!=="{")if(S[0]==="e")S=decodeURIComponent(escape(atob(S)));else if(S[0]==="\u1BE1")S=nn.decompressFromUTF16(S);else{console.warn("Unable to determine preset encoding",S),r.value=!0;return}const P=JSON.parse(S);if(typeof P!="object"){r.value=!0;return}const B=si();P.id=B,mt(P),a.value="",r.value=!1,ae.saves.push(B)}catch{r.value=!0}}):r.value=!1});let u={},c=z(Object.keys(u).reduce((S,P)=>(S.push({label:P.split("/").slice(-1)[0].slice(0,-4),value:u[P]}),S),[]));const p=zi({});function v(S){if(p[S]==null){let P=localStorage.getItem(S);if(P==null)p[S]={error:"Save doesn't exist in localStorage",id:S};else if(P==="dW5kZWZpbmVk")p[S]={error:"Save is undefined",id:S};else try{if(P[0]!=="{")if(P[0]==="e")P=decodeURIComponent(escape(atob(P)));else if(P[0]==="\u1BE1")P=nn.decompressFromUTF16(P);else return console.warn("Unable to determine preset encoding",P),r.value=!0,p[S]={error:"Unable to determine preset encoding",id:S},p[S];p[S]={...JSON.parse(P),id:S}}catch(B){p[S]={error:B,id:S},console.warn(`SavesManager: Failed to load info about save with id ${S}:
|
|
${B}
|
|
${P}`)}}return p[S]}vt(n,S=>{S&&Object.keys(p).forEach(P=>delete p[P])});const d=C(()=>ae.saves.reduce((S,P)=>(S[P]=v(P),S),{}));function h(S){let P;switch(J.id===S?P=Pr(J):P=JSON.stringify(d.value[S]),ge.exportEncoding){default:console.warn(`Unknown save encoding: ${ge.exportEncoding}. Defaulting to lz`);case"lz":P=nn.compressToUTF16(P);break;case"base64":P=btoa(unescape(encodeURIComponent(P)));break;case"plain":break}const B=document.createElement("textarea");B.value=P,document.body.appendChild(B),B.select(),B.setSelectionRange(0,99999),document.execCommand("copy"),document.body.removeChild(B)}function m(S){J.id===S&&mt();const P={...d.value[S],id:si()};mt(P),ae.saves.push(P.id)}function _(S){ae.saves=ae.saves.filter(P=>P!==S),localStorage.removeItem(S),p[S]=void 0}function y(S){d.value[J.id].time=J.time,mt(),p[J.id]=void 0,pn(d.value[S]),p[S]=void 0}function I(S){if(l.value=S,Wt(()=>{l.value=null}),S[0]!=="{")if(S[0]==="e")S=decodeURIComponent(escape(atob(S)));else if(S[0]==="\u1BE1")S=nn.decompressFromUTF16(S);else{console.warn("Unable to determine preset encoding",S);return}const P=JSON.parse(S);P.id=si(),mt(P),ae.saves.push(P.id),y(P.id)}function A(S,P){const B=d.value[S];B!=null&&(B.name=P,J.id===S?(J.name=P,mt()):(mt(B),p[S]=void 0))}return(S,P)=>(M(),K(Zt,{modelValue:n.value,"onUpdate:modelValue":P[4]||(P[4]=B=>n.value=B),ref_key:"modal",ref:i},{header:W(()=>[ml]),body:W(({shown:B})=>[B?(M(),K(s(Ma),{key:0,list:s(ae).saves,handle:".handle",itemKey:ie=>ie},{item:W(({element:ie})=>[f(gl,{save:s(d)[ie],onOpen:pe=>y(ie),onExport:pe=>h(ie),onEditName:pe=>A(ie,pe),onDuplicate:pe=>m(ie),onDelete:pe=>_(ie)},null,8,["save","onOpen","onExport","onEditName","onDuplicate","onDelete"])]),_:1},8,["list","itemKey"])):j("",!0)]),footer:W(()=>[N("div",vl,[f(jr,{modelValue:a.value,"onUpdate:modelValue":P[0]||(P[0]=B=>a.value=B),title:"Import Save",placeholder:"Paste your save here!",class:ve({importingFailed:r.value})},null,8,["modelValue","class"]),N("div",hl,[bl,N("div",yl,[N("button",{class:"button",onClick:P[1]||(P[1]=B=>y(s($n)().id))},"New Game"),Object.keys(s(c)).length>0?(M(),K(Ji,{key:0,options:s(c),modelValue:l.value,"onUpdate:modelValue":P[2]||(P[2]=B=>I(B)),closeOnSelect:"",placeholder:"Select preset",class:"presets"},null,8,["options","modelValue"])):j("",!0)])]),N("div",wl,[_l,N("button",{class:"button modal-default-button",onClick:P[3]||(P[3]=B=>n.value=!1)}," Close ")])])]),_:1},8,["modelValue"]))}});var zr=de(Nl,[["__scopeId","data-v-2a4275be"]]);const wt=e=>(hn("data-v-318a1c31"),e=e(),bn(),e),Cl=["src","alt"],kl={key:1,class:"title"},Ml=wt(()=>N("div",{style:{"flex-grow":"1",cursor:"unset"}},null,-1)),Sl={class:"discord"},Il={class:"discord-links"},xl={key:0},$l=["href"],El=wt(()=>N("li",null,[N("a",{href:"https://discord.gg/yJ4fjnjU54",target:"_blank"},"The Paper Pilot Community")],-1)),Pl=wt(()=>N("li",null,[N("a",{href:"https://discord.gg/F3xveHV",target:"_blank"},"The Modding Tree")],-1)),Dl={href:"https://forums.moddingtree.com/",target:"_blank"},Tl=wt(()=>N("span",{class:"material-icons"},"forum",-1)),Al=wt(()=>N("span",{class:"material-icons"},"info",-1)),Fl=wt(()=>N("span",{class:"material-icons"},"library_books",-1)),Rl=wt(()=>N("span",{class:"material-icons"},"settings",-1)),Ol=wt(()=>N("span",{class:"material-icons"},"library_books",-1)),ql=wt(()=>N("span",{class:"material-icons"},"settings",-1)),Vl=wt(()=>N("span",{class:"material-icons"},"info",-1)),Bl={href:"https://forums.moddingtree.com/",target:"_blank"},Ll=wt(()=>N("span",{class:"material-icons"},"forum",-1)),jl={class:"discord"},zl={class:"discord-links"},Ul={key:0},Gl=["href"],Wl=wt(()=>N("li",null,[N("a",{href:"https://discord.gg/yJ4fjnjU54",target:"_blank"},"The Paper Pilot Community")],-1)),Hl=wt(()=>N("li",null,[N("a",{href:"https://discord.gg/F3xveHV",target:"_blank"},"The Modding Tree")],-1)),Zl=Y({__name:"Nav",setup(e){const t=z(null),n=z(null),i=z(null),r=z(null),{useHeader:a,banner:l,title:u,discordName:c,discordLink:p,versionNumber:v}=ge;function d(){window.open(p,"mywindow")}return(h,m)=>(M(),D(te,null,[s(a)?(M(),D("div",Ht({key:0,class:"nav"},h.$attrs),[s(l)?(M(),D("img",{key:0,src:s(l),class:"banner",alt:s(u)},null,8,Cl)):(M(),D("div",kl,se(s(u)),1)),N("div",{onClick:m[0]||(m[0]=_=>{var y;return(y=r.value)==null?void 0:y.open()}),class:"version-container"},[f(Oe,{display:"Changelog",direction:s(U).Down,class:"version"},{default:W(()=>[N("span",null,"v"+se(s(v)),1)]),_:1},8,["direction"])]),Ml,N("div",Sl,[N("span",{onClick:d,class:"material-icons"},"discord"),N("ul",Il,[s(p)?(M(),D("li",xl,[N("a",{href:s(p),target:"_blank"},se(s(c)),9,$l)])):j("",!0),El,Pl])]),N("div",null,[N("a",Dl,[f(Oe,{display:"Forums",direction:s(U).Down,yoffset:"5px"},{default:W(()=>[Tl]),_:1},8,["direction"])])]),N("div",{onClick:m[1]||(m[1]=_=>{var y;return(y=t.value)==null?void 0:y.open()})},[f(Oe,{display:"Info",direction:s(U).Down,class:"info"},{default:W(()=>[Al]),_:1},8,["direction"])]),N("div",{onClick:m[2]||(m[2]=_=>{var y;return(y=n.value)==null?void 0:y.open()})},[f(Oe,{display:"Saves",direction:s(U).Down,xoffset:"-20px"},{default:W(()=>[Fl]),_:1},8,["direction"])]),N("div",{onClick:m[3]||(m[3]=_=>{var y;return(y=i.value)==null?void 0:y.open()})},[f(Oe,{display:"Settings",direction:s(U).Down,xoffset:"-66px"},{default:W(()=>[Rl]),_:1},8,["direction"])])],16)):(M(),D("div",Ht({key:1,class:"overlay-nav"},h.$attrs),[N("div",{onClick:m[4]||(m[4]=_=>{var y;return(y=r.value)==null?void 0:y.open()}),class:"version-container"},[f(Oe,{display:"Changelog",direction:s(U).Right,xoffset:"25%",class:"version"},{default:W(()=>[N("span",null,"v"+se(s(v)),1)]),_:1},8,["direction"])]),N("div",{onClick:m[5]||(m[5]=_=>{var y;return(y=n.value)==null?void 0:y.open()})},[f(Oe,{display:"Saves",direction:s(U).Right},{default:W(()=>[Ol]),_:1},8,["direction"])]),N("div",{onClick:m[6]||(m[6]=_=>{var y;return(y=i.value)==null?void 0:y.open()})},[f(Oe,{display:"Settings",direction:s(U).Right},{default:W(()=>[ql]),_:1},8,["direction"])]),N("div",{onClick:m[7]||(m[7]=_=>{var y;return(y=t.value)==null?void 0:y.open()})},[f(Oe,{display:"Info",direction:s(U).Right},{default:W(()=>[Vl]),_:1},8,["direction"])]),N("div",null,[N("a",Bl,[f(Oe,{display:"Forums",direction:s(U).Right,xoffset:"7px"},{default:W(()=>[Ll]),_:1},8,["direction"])])]),N("div",jl,[N("span",{onClick:d,class:"material-icons"},"discord"),N("ul",zl,[s(p)?(M(),D("li",Ul,[N("a",{href:s(p),target:"_blank"},se(s(c)),9,Gl)])):j("",!0),Wl,Hl])])],16)),f(Io,{ref_key:"info",ref:t,changelog:r.value},null,8,["changelog"]),f(zr,{ref_key:"savesManager",ref:n},null,512),f(Vo,{ref_key:"options",ref:i},null,512),f(oo,{ref_key:"changelog",ref:r},null,512)],64))}});var Ur=de(Zl,[["__scopeId","data-v-318a1c31"]]);const Yl={class:"inner-tab"},Xl=Y({__name:"Game",setup(e){const t=an(J,"tabs"),n=C(()=>Object.keys(ye)),i=ge.useHeader;function r(a){const{display:l,minimized:u,name:c,color:p,minimizable:v,nodes:d,minimizedDisplay:h}=a;return{display:l,minimized:u,name:c,color:p,minimizable:v,nodes:d,minimizedDisplay:h}}return(a,l)=>(M(),D("div",{class:ve(["tabs-container",{useHeader:s(i)}])},[(M(!0),D(te,null,Dn(s(t),(u,c)=>{var p,v;return M(),D("div",{key:c,class:ve(["tab",s((p=s(ye)[u])==null?void 0:p.classes)]),style:Le(s((v=s(ye)[u])==null?void 0:v.style))},[c===0&&!s(i)?(M(),K(Ur,{key:0})):j("",!0),N("div",Yl,[s(n).includes(u)?(M(),K(io,Ht({key:0},r(s(ye)[u]),{index:c,onSetMinimized:d=>s(ye)[u].minimized.value=d}),null,16,["index","onSetMinimized"])):(M(),K(Xe(u),{key:1,index:c},null,8,["index"]))])],6)}),128))],2))}});var Jl=de(Xl,[["__scopeId","data-v-dcd207b4"]]);const Kl=Y({__name:"Sticky",setup(e){const t=z("0"),n=new ResizeObserver(r),i=ht(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 Wt(r),document.fonts.ready.then(r),gi(()=>{var l;const a=(l=i.value)==null?void 0:l.parentElement;a&&n.observe(a)}),(a,l)=>(M(),D("div",{class:"sticky",style:Le({top:t.value}),ref_key:"element",ref:i,"data-v-sticky":""},[Ft(a.$slots,"default",{},void 0,!0)],4))}});var di=de(Kl,[["__scopeId","data-v-cccac690"]]);const Ql=["x1","y1","x2","y2"],eu=Y({__name:"BoardLink",props:{link:null},setup(e){const n=Te(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(),D("line",Ht({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,Ql))}});var tu=de(eu,[["__scopeId","data-v-57c4970a"]]);const nu={key:0},iu=["transform","onMousedown","onTouchstart","onMouseup","onTouchend"],ru=["fill","stroke-width","stroke"],au=["fill"],su=Y({__name:"BoardNodeAction",props:{node:null,nodeType:null,actions:null,isSelected:{type:Boolean},selectedAction:null},emits:["clickAction"],setup(e,{emit:t}){const i=Te(e),r=C(()=>fe(i.nodeType.value.size,s(i.node))),a=C(()=>{var v;return(v=fe(i.nodeType.value.outlineColor,s(i.node)))!=null?v:kt[ae.theme].variables["--outline"]}),l=C(()=>{var v;return(v=fe(i.nodeType.value.titleColor,s(i.node)))!=null?v:kt[ae.theme].variables["--foreground"]}),u=C(()=>fe(i.nodeType.value.actionDistance,s(i.node)));function c(v,d){t("clickAction",d.id),v.preventDefault(),v.stopPropagation()}function p(v,d){var h;((h=s(i.selectedAction))==null?void 0:h.id)===d.id&&(v.preventDefault(),v.stopPropagation())}return(v,d)=>(M(),K(jn,{name:"actions",appear:""},{default:W(()=>[e.isSelected&&e.actions?(M(),D("g",nu,[(M(!0),D(te,null,Dn(e.actions,(h,m)=>{var _,y;return M(),D("g",{key:h.id,class:ve(["action",{selected:((_=e.selectedAction)==null?void 0:_.id)===h.id}]),transform:`translate(
|
|
${(-s(r)-30)*Math.sin(((e.actions.length-1)/2-m)*s(u))},
|
|
${(s(r)+30)*Math.cos(((e.actions.length-1)/2-m)*s(u))}
|
|
)`,onMousedown:I=>c(I,h),onTouchstart:I=>c(I,h),onMouseup:I=>p(I,h),onTouchend:Pn(I=>p(I,h),["stop"])},[N("circle",{fill:s(fe)(h.fillColor,e.node),r:"20","stroke-width":((y=e.selectedAction)==null?void 0:y.id)===h.id?4:0,stroke:s(a)},null,8,ru),N("text",{fill:s(l),class:"material-icons"},se(s(fe)(h.icon,e.node)),9,au)],42,iu)}),128))])):j("",!0)]),_:1}))}});var ou=de(su,[["__scopeId","data-v-9efb2a56"]]);const lu=["transform"],uu={key:0},cu=["r","fill","stroke"],du=["r","fill","stroke"],pu=["r","fill"],fu=["r","stroke-dasharray","stroke-dashoffset","stroke"],gu={key:1,transform:"rotate(45, 0, 0)"},mu=["width","height","transform","fill","stroke"],vu=["width","height","transform","fill","stroke"],hu=["width","height","transform","fill"],bu=["width","height","transform","stroke-dasharray","stroke-dashoffset","stroke"],yu=["fill","y"],wu=["fill"],_u={key:0},Nu=["fill","y"],Cu=["fill","y"],ku=Y({__name:"BoardNode",props:{node:null,nodeType:null,dragging:null,dragged:null,hasDragged:{type:Boolean},receivingNode:{type:Boolean},isSelected:{type:Boolean},selectedAction:null},emits:["mouseDown","endDragging","clickAction"],setup(e,{emit:t}){const n=e,i=Math.sqrt(2),r=Te(n),a=C(()=>fe(r.nodeType.value.draggable,s(r.node)));vt(a,V=>{const re=s(r.node);s(r.dragging)===re&&!V&&t("endDragging",re)});const l=C(()=>{var re;const V=s(r.node);return(re=fe(r.nodeType.value.actions,V))==null?void 0:re.filter(Ae=>ze(fe(Ae.visibility,V)))}),u=C(()=>{var re;const V=s(r.node);if(fe(r.nodeType.value.draggable,V)&&((re=s(r.dragging))==null?void 0:re.id)===V.id&&s(r.dragged)!=null){const{x:Ae,y:Ge}=s(r.dragged);return{x:V.position.x+Math.round(Ae/25)*25,y:V.position.y+Math.round(Ge/25)*25}}return V.position}),c=C(()=>fe(r.nodeType.value.shape,s(r.node))),p=C(()=>fe(r.nodeType.value.title,s(r.node))),v=C(()=>fe(r.nodeType.value.subtitle,s(r.node))),d=C(()=>{var V;return(V=r.isSelected.value?s(r.selectedAction)&&fe(s(r.selectedAction).tooltip,s(r.node)):null)!=null?V:fe(r.nodeType.value.label,s(r.node))}),h=C(()=>{var V,re;return fe((re=(V=s(r.selectedAction))==null?void 0:V.confirmationLabel)!=null?re:{text:"Tap again to confirm"},s(r.node))}),m=C(()=>fe(r.nodeType.value.size,s(r.node))),_=C(()=>{var V;return(V=fe(r.nodeType.value.progress,s(r.node)))!=null?V:0}),y=C(()=>kt[ae.theme].variables["--background"]),I=C(()=>{var V;return(V=fe(r.nodeType.value.outlineColor,s(r.node)))!=null?V:kt[ae.theme].variables["--outline"]}),A=C(()=>{var V;return(V=fe(r.nodeType.value.fillColor,s(r.node)))!=null?V:kt[ae.theme].variables["--raised-background"]}),S=C(()=>fe(r.nodeType.value.progressColor,s(r.node))),P=C(()=>{var V;return(V=fe(r.nodeType.value.titleColor,s(r.node)))!=null?V:kt[ae.theme].variables["--foreground"]}),B=C(()=>fe(r.nodeType.value.progressDisplay,s(r.node))),ie=C(()=>r.dragging.value!=null&&s(r.hasDragged)&&fe(r.nodeType.value.canAccept,s(r.node),r.dragging.value)),pe=C(()=>fe(r.nodeType.value.style,s(r.node))),ee=C(()=>fe(r.nodeType.value.classes,s(r.node)));function H(V){t("mouseDown",V,r.node.value,a.value)}function le(V){var re,Ae,Ge;(re=r.hasDragged)!=null&&re.value||(t("endDragging",r.node.value),(Ge=(Ae=r.nodeType.value).onClick)==null||Ge.call(Ae,r.node.value),V.stopPropagation())}return(V,re)=>{var Ae,Ge,Xt;return M(),D("g",{class:ve(["boardnode",{[e.node.type]:!0,isSelected:e.isSelected,isDraggable:s(a),...s(ee)}]),style:Le([{opacity:((Ae=e.dragging)==null?void 0:Ae.id)===e.node.id&&e.hasDragged?.5:1},(Ge=s(pe))!=null?Ge:[]]),transform:`translate(${s(u).x},${s(u).y})${e.isSelected?" scale(1.2)":""}`},[f(ou,{actions:(Xt=s(l))!=null?Xt:[],"is-selected":e.isSelected,node:e.node,"node-type":e.nodeType,"selected-action":e.selectedAction,onClickAction:re[0]||(re[0]=at=>t("clickAction",at))},null,8,["actions","is-selected","node","node-type","selected-action"]),N("g",{class:"node-container",onMousedown:H,onTouchstartPassive:H,onMouseup:le,onTouchendPassive:le},[s(c)===s(Ue).Circle?(M(),D("g",uu,[s(ie)?(M(),D("circle",{key:0,class:"receiver",r:s(m)+8,fill:s(y),stroke:e.receivingNode?"#0F0":"#0F03","stroke-width":2},null,8,cu)):j("",!0),N("circle",{class:"body",r:s(m),fill:s(A),stroke:s(I),"stroke-width":4},null,8,du),s(B)===s(vn).Fill?(M(),D("circle",{key:1,class:"progress progressFill",r:Math.max(s(m)*s(_)-2,0),fill:s(S)},null,8,pu)):(M(),D("circle",{key:2,r:s(m)+4.5,class:"progress progressRing",fill:"transparent","stroke-dasharray":(s(m)+4.5)*2*Math.PI,"stroke-width":5,"stroke-dashoffset":(s(m)+4.5)*2*Math.PI-s(_)*(s(m)+4.5)*2*Math.PI,stroke:s(S)},null,8,fu))])):s(c)===s(Ue).Diamond?(M(),D("g",gu,[s(ie)?(M(),D("rect",{key:0,class:"receiver",width:s(m)*s(i)+16,height:s(m)*s(i)+16,transform:`translate(${-(s(m)*s(i)+16)/2}, ${-(s(m)*s(i)+16)/2})`,fill:s(y),stroke:e.receivingNode?"#0F0":"#0F03","stroke-width":2},null,8,mu)):j("",!0),N("rect",{class:"body",width:s(m)*s(i),height:s(m)*s(i),transform:`translate(${-s(m)*s(i)/2}, ${-s(m)*s(i)/2})`,fill:s(A),stroke:s(I),"stroke-width":4},null,8,vu),s(B)===s(vn).Fill?(M(),D("rect",{key:1,class:"progress progressFill",width:Math.max(s(m)*s(i)*s(_)-2,0),height:Math.max(s(m)*s(i)*s(_)-2,0),transform:`translate(${-Math.max(s(m)*s(i)*s(_)-2,0)/2}, ${-Math.max(s(m)*s(i)*s(_)-2,0)/2})`,fill:s(S)},null,8,hu)):(M(),D("rect",{key:2,class:"progress progressDiamond",width:s(m)*s(i)+9,height:s(m)*s(i)+9,transform:`translate(${-(s(m)*s(i)+9)/2}, ${-(s(m)*s(i)+9)/2})`,fill:"transparent","stroke-dasharray":(s(m)*s(i)+9)*4,"stroke-width":5,"stroke-dashoffset":(s(m)*s(i)+9)*4-s(_)*(s(m)*s(i)+9)*4,stroke:s(S)},null,8,bu))])):j("",!0),N("text",{fill:s(P),class:"node-title",y:s(v)?10:0},se(s(p)),9,yu),s(v)?(M(),D("text",{key:2,fill:s(P),class:"node-subtitle",y:"-15"},se(s(v)),9,wu)):j("",!0)],32),f(jn,{name:"fade",appear:""},{default:W(()=>{var at;return[s(d)?(M(),D("g",_u,[N("text",{fill:(at=s(d).color)!=null?at:s(P),class:ve(["node-title",{pulsing:s(d).pulsing}]),y:-s(m)-20},se(s(d).text),11,Nu)])):j("",!0)]}),_:1}),f(jn,{name:"fade",appear:""},{default:W(()=>{var at;return[e.isSelected&&e.selectedAction?(M(),D("text",{key:0,fill:(at=s(h).color)!=null?at:s(P),class:ve(["node-title",{pulsing:s(h).pulsing}]),y:s(m)+75},se(s(h).text),11,Cu)):j("",!0)]}),_:1})],14,lu)}}});var Mu=de(ku,[["__scopeId","data-v-518d7a7f"]]);const Su={class:"stage",width:"100%",height:"100%"},Iu={class:"g1"},xu=Y({__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=Te(e),i=z({x:0,y:0}),r=z({x:0,y:0}),a=z(!1),l=z(null),u=C(()=>{const m=n.nodes.value.slice();if(n.selectedNode.value){const _=m.splice(m.indexOf(n.selectedNode.value),1)[0];m.push(_)}if(n.draggingNode.value){const _=m.splice(m.indexOf(n.draggingNode.value),1)[0];m.push(_)}return m});Et(()=>{const m=n.draggingNode.value;if(m==null)return null;const _={x:m.position.x+r.value.x,y:m.position.y+r.value.y};let y=Number.MAX_VALUE;n.setReceivingNode.value(n.nodes.value.reduce((I,A)=>{if(A.id===m.id)return I;const S=n.types.value[A.type];if(!fe(S.canAccept,A,m))return I;const B=Math.pow(_.x-A.position.x,2)+Math.pow(_.y-A.position.y,2);let ie=fe(S.size,A);return B>y||B>ie*ie?I:(y=B,A)},null))});function c(m){m.setTransformOrigin(null),m.moveTo(l.value.$el.clientWidth/2,l.value.$el.clientHeight/2)}function p(m,_=null,y=!1){if(n.draggingNode.value==null){m.preventDefault(),m.stopPropagation();let I,A;if("touches"in m)if(m.touches.length===1)I=m.touches[0].clientX,A=m.touches[0].clientY;else return;else I=m.clientX,A=m.clientY;i.value={x:I,y:A},r.value={x:0,y:0},a.value=!1,y&&n.setDraggingNode.value(_)}_!=null&&(n.state.value.selectedNode=null,n.state.value.selectedAction=null)}function v(m){const{x:_,y,scale:I}=l.value.panZoomInstance.getTransform();let A,S;if("touches"in m)if(m.touches.length===1)A=m.touches[0].clientX,S=m.touches[0].clientY;else{d(n.draggingNode.value),n.mousePosition.value=null;return}else A=m.clientX,S=m.clientY;n.mousePosition.value={x:(A-_)/I,y:(S-y)/I},r.value={x:r.value.x+(A-i.value.x)/I,y:r.value.y+(S-i.value.y)/I},i.value={x:A,y:S},(Math.abs(r.value.x)>10||Math.abs(r.value.y)>10)&&(a.value=!0),n.draggingNode.value!=null&&(m.preventDefault(),m.stopPropagation())}function d(m,_=!1){var y,I;if(n.draggingNode.value!=null&&n.draggingNode.value===m){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 A=n.nodes.value;A.push(A.splice(A.indexOf(n.draggingNode.value),1)[0]),n.receivingNode.value&&((I=(y=n.types.value[n.receivingNode.value.type]).onDrop)==null||I.call(y,n.receivingNode.value,n.draggingNode.value)),n.setDraggingNode.value(null)}else!a.value&&!_&&(n.state.value.selectedNode=null,n.state.value.selectedAction=null)}function h(m,_){n.state.value.selectedAction===_?s(n.selectedAction).onClick(s(n.selectedNode)):n.state.value={...n.state.value,selectedAction:_}}return(m,_)=>{const y=It("panZoom");return s(ze)(e.visibility)?(M(),K(y,{key:0,style:Le([{width:e.width,height:e.height},e.style]),class:ve(e.classes),selector:".g1",options:{initialZoom:1,minZoom:.1,maxZoom:10,zoomDoubleClickSpeed:1},ref_key:"stage",ref:l,onInit:c,onMousemove:v,onTouchmove:v,onMousedown:_[0]||(_[0]=I=>p(I)),onTouchstart:_[1]||(_[1]=I=>p(I)),onMouseup:_[2]||(_[2]=()=>d(s(e.draggingNode))),onTouchendPassive:_[3]||(_[3]=()=>d(s(e.draggingNode))),onMouseleave:_[4]||(_[4]=()=>d(s(e.draggingNode),!0))},{default:W(()=>[(M(),D("svg",Su,[N("g",Iu,[f(lr,{name:"link",appear:""},{default:W(()=>[(M(!0),D(te,null,Dn(s(e.links)||[],I=>(M(),D("g",{key:`${I.startNode.id}-${I.endNode.id}`},[f(tu,{link:I},null,8,["link"])]))),128))]),_:1}),f(lr,{name:"grow",duration:500,appear:""},{default:W(()=>[(M(!0),D(te,null,Dn(s(u),I=>(M(),D("g",{key:I.id,style:{"transition-duration":"0s"}},[f(Mu,{node:I,nodeType:e.types[I.type],dragging:s(e.draggingNode),dragged:s(e.draggingNode)===I?r.value:void 0,hasDragged:s(e.draggingNode)==null?!1:a.value,receivingNode:s(e.receivingNode)===I,isSelected:s(e.selectedNode)===I,selectedAction:s(e.selectedNode)===I?s(e.selectedAction):null,onMouseDown:p,onEndDragging:d,onClickAction:A=>h(I,A)},null,8,["node","nodeType","dragging","dragged","hasDragged","receivingNode","isSelected","selectedAction","onClickAction"])]))),128))]),_:1})])]))]),_:1},8,["style","class","options"])):j("",!0)}}});Je.on("setupVue",e=>Ia.install(e));const Gr=Symbol("Board");var vn=(e=>(e.Outline="Outline",e.Fill="Fill",e))(vn||{}),Ue=(e=>(e.Circle="Circle",e.Diamond="Triangle",e))(Ue||{});function $u(e){const t=dt({nodes:[],selectedNode:null,selectedAction:null},!1);return Ke(n=>{const i=e.call(n,n);i.id=on("board-"),i.type=Gr,i[yt]=xu,i.state?(qr(t),x(i,"state")):(t[sn]={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,p;qe(l.state)?l.state.value={...l.state.value,selectedNode:(c=u==null?void 0:u.id)!=null?c:null}:l.state.selectedNode=(p=u==null?void 0:u.id)!=null?p: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(p=>p.id===s(l.state).selectedAction)||null},set(u){var c,p;qe(l.state)?l.state.value={...l.state.value,selectedAction:(c=u==null?void 0:u.id)!=null?c:null}:l.state.selectedAction=(p=u==null?void 0:u.id)!=null?p:null}}),i.mousePosition=z(null),i.links?x(i,"links"):i.links=C(()=>l.selectedAction.value==null?null:l.selectedAction.value.links&&l.selectedNode.value?fe(l.selectedAction.value.links,l.selectedNode.value):null),i.draggingNode=z(null),i.receivingNode=z(null),x(i,"visibility"),ne(i,"visibility",_e.Visible),x(i,"width"),ne(i,"width","100%"),x(i,"height"),ne(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"),ne(c,"size",50),x(c,"style"),x(c,"classes"),x(c,"draggable"),ne(c,"draggable",!1),x(c,"shape"),ne(c,"shape","Circle"),x(c,"canAccept"),ne(c,"canAccept",!1),x(c,"progress"),x(c,"progressDisplay"),ne(c,"progressDisplay","Fill"),x(c,"progressColor"),ne(c,"progressColor","none"),x(c,"fillColor"),x(c,"outlineColor"),x(c,"titleColor"),x(c,"actionDistance"),ne(c,"actionDistance",Math.PI/6),c.nodes=C(()=>s(l.state).nodes.filter(p=>p.type===u)),ne(c,"onClick",function(p){s(l.state).selectedNode=p.id}),c.actions)for(const p of c.actions)x(p,"visibility"),ne(p,"visibility",_e.Visible),x(p,"icon"),x(p,"fillColor"),x(p,"tooltip"),x(p,"confirmationLabel"),ne(p,"confirmationLabel",{text:"Tap again to confirm"}),x(p,"links")}function r(u){i.draggingNode.value=u}function a(u){i.receivingNode.value=u}i.placeInAvailableSpace=function(u,c=100,p=U.Right){const v=l.nodes.value.slice().filter(d=>d===u||(p===U.Down||p===U.Up)&&Math.abs(d.position.x-u.position.x)>c||(p===U.Left||p===U.Right)&&Math.abs(d.position.y-u.position.y)>c?!1:!(p===U.Right&&d.position.x<u.position.x-c||p===U.Left&&d.position.x>u.position.x+c||p===U.Up&&d.position.y>u.position.y+c||p===U.Down&&d.position.y<u.position.y-c)).sort(p===U.Right?(d,h)=>d.position.x-h.position.x:p===U.Left?(d,h)=>h.position.x-d.position.x:p===U.Up?(d,h)=>h.position.y-d.position.y:(d,h)=>d.position.y-h.position.y);for(let d=0;d<v.length;d++){const h=v[d],m=p===U.Right||p===U.Left?Math.abs(u.position.x-h.position.x):Math.abs(u.position.y-h.position.y);if(m<c)p===U.Right?u.position.x=h.position.x+c:p===U.Left?u.position.x=h.position.x-c:p===U.Up?u.position.y=h.position.y-c:p===U.Down&&(u.position.y=h.position.y+c);else if(d>0&&m>c)break}},i[pt]=function(){const{nodes:u,types:c,state:p,visibility:v,width:d,height:h,style:m,classes:_,links:y,selectedAction:I,selectedNode:A,mousePosition:S,draggingNode:P,receivingNode:B}=this;return{nodes:u,types:c,state:p,visibility:v,width:d,height:h,style:s(m),classes:_,links:y,selectedAction:I,selectedNode:A,mousePosition:S,draggingNode:P,receivingNode:B,setDraggingNode:r,setReceivingNode:a}};const l=i;return l})}function fe(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={};Je.on("addLayer",e=>{const t=Wn(e,Gr);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)}))})})});Je.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=qe(e)?e:dt(e);if(r.displayName=t,r.precision=n,r.small=i,!qe(e)){const a=r[At];a.displayName=t,a.precision=n,a.small=i}return r}new o("10^^8");new o("1e100");function pi(e,t){const n=t!=null?t:e.value;return o.eq(e.precision,0)?Mt(e.small?n:o.floor(n)):we(n,e.precision,e.small)}Je.on("setupVue",e=>e.use(xa));function Eu(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 Pu=Y({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}=Te(e),a=Rr(n),l=C(()=>{const c=$e(i);return c==null||c===""?{}:s(r)?Eu(c):{boxShadow:`0px 9px 5px -6px ${c}`}});function u(){t("selectTab")}return{selectTab:u,component:a,glowColorStyle:l,unref:s,Visibility:_e,isVisible:ze,isHidden:yn}}});function Du(e,t,n,i,r,a){var l;return e.isVisible(e.visibility)?(M(),D("button",{key:0,onClick:t[0]||(t[0]=(...u)=>e.selectTab&&e.selectTab(...u)),class:ve(["tabButton",{active:e.active,...e.unref(e.classes)}]),style:Le([{visibility:e.isHidden(e.visibility)?"hidden":void 0},e.glowColorStyle,(l=e.unref(e.style))!=null?l:{}])},[(M(),K(Xe(e.component)))],6)):j("",!0)}var Wr=de(Pu,[["render",Du],["__scopeId","data-v-21427abb"]]);const Tu=Y({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:di,TabButton:Wr},setup(e){const{activeTab:t}=Te(e),n=C(()=>kt[ae.theme].floatingTabs),i=ht("");Et(()=>{const u=$e(t);if(u==null){i.value="";return}if(Pt(u)){i.value=oe(u);return}i.value=oe(s(u.display))});const r=C(()=>{const u=$e(t);return Pt(u)||!u?void 0:s(u.classes)}),a=C(()=>{const u=$e(t);return Pt(u)||!u?void 0:s(u.style)});function l(u){const{display:c,style:p,classes:v,glowColor:d,visibility:h}=u;return{display:c,style:s(p),classes:v,glowColor:d,visibility:h}}return{floating:n,tabClasses:r,tabStyle:a,Visibility:_e,component:i,gatherButtonProps:l,unref:s,isVisible:ze,isHidden:yn}}});function Au(e,t,n,i,r,a){var c,p;const l=It("TabButton"),u=It("Sticky");return e.isVisible(e.visibility)?(M(),D("div",{key:0,class:ve(["tab-family-container",{...e.unref(e.classes),...e.tabClasses}]),style:Le([{visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:[],(p=e.tabStyle)!=null?p:[]])},[f(u,{class:ve(["tab-buttons-container",e.unref(e.buttonContainerClasses)]),style:Le(e.unref(e.buttonContainerStyle))},{default:W(()=>[N("div",{class:ve(["tab-buttons",{floating:e.floating}])},[(M(!0),D(te,null,Dn(e.unref(e.tabs),(v,d)=>(M(),K(l,Ht({onSelectTab:h=>e.selected.value=d,floating:e.floating,key:d,active:e.unref(v.tab)===e.unref(e.activeTab)},e.gatherButtonProps(v)),null,16,["onSelectTab","floating","active"]))),128))],2)]),_:1},8,["class","style"]),e.unref(e.activeTab)?(M(),K(Xe(e.unref(e.component)),{key:0})):j("",!0)],6)):j("",!0)}var Fu=de(Tu,[["render",Au],["__scopeId","data-v-58dbf83a"]]);const Ru=Symbol("TabButton"),Ou=Symbol("TabFamily");function qu(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=dt(Object.keys(e)[0],!1);return Ke(i=>{var l;const r=(l=t==null?void 0:t.call(i,i))!=null?l:{};r.id=on("tabFamily-"),r.type=Ou,r[yt]=Fu,r.tabs=Object.keys(e).reduce((u,c)=>{const p=e[c]();return p.type=Ru,p[yt]=Wr,x(p,"visibility"),ne(p,"visibility",_e.Visible),x(p,"tab"),x(p,"display"),x(p,"classes"),x(p,"style"),x(p,"glowColor"),u[c]=p,u},{}),r.selected=n,r.activeTab=C(()=>{const u=s(a.tabs);if(n.value in u&&ze(u[n.value].visibility))return s(u[n.value].tab);const c=Object.values(u).find(p=>ze(p.visibility));return c?s(c.tab):null}),x(r,"visibility"),ne(r,"visibility",_e.Visible),x(r,"classes"),x(r,"style"),x(r,"buttonContainerClasses"),x(r,"buttonContainerStyle"),r[pt]=function(){const{visibility:u,activeTab:c,selected:p,tabs:v,style:d,classes:h,buttonContainerClasses:m,buttonContainerStyle:_}=this;return{visibility:u,activeTab:c,selected:p,tabs:v,style:s(d),classes:h,buttonContainerClasses:m,buttonContainerStyle:_}};const a=r;return a})}const Hr=o.ln(10);function Bn(e){return e}function Vu(e,t){if(F(t))return t.invert(o.neg(e));throw new Error("Could not invert due to no input being a variable")}function Bu(e,t){if(F(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 Lu(e){return g.neg(e)}function ju(e,t,n){if(F(t))return t.invert(o.sub(e,Ne(n)));if(F(n))return n.invert(o.sub(e,Ne(t)));throw new Error("Could not invert due to no input being a variable")}function zu(e,t,n){var i,r;if(F(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(F(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 Uu(e,t,n){if(F(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(F(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 Gu(e,t,n){if(F(t))return t.invert(o.add(e,Ne(n)));if(F(n))return n.invert(o.sub(Ne(t),e));throw new Error("Could not invert due to no input being a variable")}function Wu(e,t,n){var i,r;if(F(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(F(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 Hu(e,t,n){if(F(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(F(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 Zu(e,t,n){if(F(t))return t.invert(o.div(e,Ne(n)));if(F(n))return n.invert(o.div(e,Ne(t)));throw new Error("Could not invert due to no input being a variable")}function Yu(e,t,n){if(F(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(F(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 Xu(e,t,n){if(F(t))return g.div(e,n);if(F(n))return g.div(e,t);throw new Error("Could not apply substitution due to no input being a variable")}function Ju(e,t,n){if(F(t))return t.invert(o.mul(e,Ne(n)));if(F(n))return n.invert(o.div(Ne(t),e));throw new Error("Could not invert due to no input being a variable")}function Ku(e,t,n){if(F(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(F(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 Qu(e,t,n){if(F(t))return g.mul(e,n);if(F(n))return g.mul(e,t);throw new Error("Could not apply substitution due to no input being a variable")}function ec(e,t){if(F(t))return t.invert(o.recip(e));throw new Error("Could not invert due to no input being a variable")}function tc(e,t){if(F(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 nc(e,t){if(F(t))return t.invert(o.pow10(e));throw new Error("Could not invert due to no input being a variable")}function ic(e){return o.ln(e).sub(1).times(e).div(Hr)}function rc(e,t){if(F(t)){const n=Hr.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 ac(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e)],evaluate:ic,invert:rc})}throw new Error("Could not integrate due to no input being a variable")}function sc(e,t,n){if(F(t))return t.invert(o.pow(Ne(n),e));if(F(n))return n.invert(o.root(Ne(t),e));throw new Error("Could not invert due to no input being a variable")}function oc(e,t){return o.ln(e).sub(1).times(e).div(o.ln(t))}function lc(e,t,n){if(F(t)){const i=o.ln(Ne(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 uc(e,t,n){if(F(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:oc,invert:lc})}throw new Error("Could not integrate due to no input being a variable")}function cc(e,t){if(F(t))return t.invert(o.pow(2,e));throw new Error("Could not invert due to no input being a variable")}function dc(e){return o.ln(e).sub(1).times(e).div(o.ln(2))}function pc(e,t){if(F(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 fc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e)],evaluate:dc,invert:pc})}throw new Error("Could not integrate due to no input being a variable")}function gc(e,t){if(F(t))return t.invert(o.exp(e));throw new Error("Could not invert due to no input being a variable")}function mc(e){return o.ln(e).sub(1).times(e)}function vc(e,t){if(F(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 hc(e,t){if(F(t)){if(!t.isIntegrable())throw new Error("Could not integrate due to variable not being integrable");return new g({inputs:[t.getIntegralFormula(e)],evaluate:mc,invert:vc})}throw new Error("Could not integrate due to no input being a variable")}function bc(e,t,n){if(F(t))return t.invert(o.root(e,Ne(n)));if(F(n))return n.invert(o.ln(e).div(o.ln(Ne(t))));throw new Error("Could not invert due to no input being a variable")}function yc(e,t,n){if(F(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(F(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 wc(e,t){if(F(t))return t.invert(o.root(e,10));throw new Error("Could not invert due to no input being a variable")}function _c(e,t){if(F(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 Nc(e,t,n){if(F(t))return t.invert(o.ln(e).div(o.ln(Ne(n))));if(F(n))return n.invert(o.root(Ne(t),e));throw new Error("Could not invert due to no input being a variable")}function Cc(e,t,n){if(F(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(F(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 kc(e,t,n){if(F(t))return t.invert(o.root(e,o.recip(Ne(n))));if(F(n))return n.invert(o.ln(Ne(t)).div(o.ln(e)));throw new Error("Could not invert due to no input being a variable")}function Mc(e,t,n){if(F(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 Sc(e,t){if(F(t))return t.invert(o.ln(e));throw new Error("Could not invert due to no input being a variable")}function Ic(e,t){if(F(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 xc(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){const i=o.minabs(t,1e308).toNumber();return o.tetrate(e,i,n)}function $c(e,t,n,i){if(F(t))return t.invert(o.ssqrt(e));throw new Error("Could not invert due to no input being a variable")}function Ec(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 Pc(e,t,n,i){if(F(t))return t.invert(o.iteratedlog(e,Math.E,o.minabs(1e308,Ne(n)).toNumber()));throw new Error("Could not invert due to no input being a variable")}function Dc(e,t=10,n=2){const i=o.minabs(n,1e308).toNumber();return o.iteratedlog(e,t,i)}function Tc(e,t=10){const n=o.minabs(t,1e308).toNumber();return o.slog(e,n)}function Ac(e,t,n){if(F(t))return t.invert(o.tetrate(e,o.minabs(1e308,Ne(n)).toNumber()));throw new Error("Could not invert due to no input being a variable")}function Fc(e,t,n){const i=o.minabs(t,1e308).toNumber();return o.layeradd(e,i,n)}function Rc(e,t,n,i){if(F(t))return t.invert(o.layeradd(e,o.minabs(1e308,Ne(n)).negate().toNumber()));throw new Error("Could not invert due to no input being a variable")}function Oc(e,t){if(F(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 qc(e,t){if(F(t))return t.invert(o.tetrate(e,2));throw new Error("Could not invert due to no input being a variable")}function Vc(e,t,n){const i=o.minabs(t,1e308).toNumber();return o.pentate(e,i,n)}function Bc(e,t){if(F(t))return t.invert(o.asin(e));throw new Error("Could not invert due to no input being a variable")}function Lc(e,t){if(F(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 jc(e,t){if(F(t))return t.invert(o.acos(e));throw new Error("Could not invert due to no input being a variable")}function zc(e,t){if(F(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 Uc(e,t){if(F(t))return t.invert(o.atan(e));throw new Error("Could not invert due to no input being a variable")}function Gc(e,t){if(F(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 Wc(e,t){if(F(t))return t.invert(o.sin(e));throw new Error("Could not invert due to no input being a variable")}function Hc(e,t){if(F(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 Zc(e,t){if(F(t))return t.invert(o.cos(e));throw new Error("Could not invert due to no input being a variable")}function Yc(e,t){if(F(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 Xc(e,t){if(F(t))return t.invert(o.tan(e));throw new Error("Could not invert due to no input being a variable")}function Jc(e,t){if(F(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 Kc(e,t){if(F(t))return t.invert(o.asinh(e));throw new Error("Could not invert due to no input being a variable")}function Qc(e,t){if(F(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 ed(e,t){if(F(t))return t.invert(o.acosh(e));throw new Error("Could not invert due to no input being a variable")}function td(e,t){if(F(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 nd(e,t){if(F(t))return t.invert(o.atanh(e));throw new Error("Could not invert due to no input being a variable")}function id(e,t){if(F(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 rd(e,t){if(F(t))return t.invert(o.sinh(e));throw new Error("Could not invert due to no input being a variable")}function ad(e,t){if(F(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 sd(e,t){if(F(t))return t.invert(o.cosh(e));throw new Error("Could not invert due to no input being a variable")}function od(e,t){if(F(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 ld(e,t){if(F(t))return t.invert(o.tanh(e));throw new Error("Could not invert due to no input being a variable")}function ud(e,t){if(F(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 F(e){return e instanceof Ee&&e.hasVariable()}function Ne(e,t){return e instanceof Ee?e.evaluate(t):s(e)}function cd(){return g.pow(this,2).div(2)}function dd(){return this}const Ve=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"&&At in n?n[At]:n)),"variable"in e?(typeof e.variable=="object"&&At in e.variable&&(e.variable=e.variable[At]),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:cd,internalIntegrateInner:dd,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,m;const{inputs:t,evaluate:n,invert:i,integrate:r,integrateInner:a,applySubstitution:l}=e,u=t.reduce((_,y)=>_+(y instanceof Ve?y.internalVariables:0),0),c=t.find(_=>_ instanceof Ve&&_.hasVariable()),p=u===1?c==null?void 0:c.innermostVariable:void 0,v=(h=c==null?void 0:c.isInvertible())!=null?h:!1,d=(m=c==null?void 0:c.isIntegrable())!=null?m:!1;return{inputs:t,internalEvaluate:n,internalInvert:v?i:void 0,internalIntegrate:d?r:void 0,internalIntegrateInner:a,applySubstitution:l,innermostVariable:p,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=>Ne(r,e))))!=null?n:this.hasVariable()?e:null)!=null?i:Ne(this.inputs[0])}equals(e){return this.inputs.length===e.inputs.length&&this.inputs.every((t,n)=>t instanceof Ve&&e.inputs[n]instanceof Ve?t.equals(e.inputs[n]):!(t instanceof Ve)&&!(e.inputs[n]instanceof Ve)&&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=n(g.variable(0)),r=me(t);function a(u){return o.lt(u,s(r))?u:o.add(i.evaluate(o.sub(u,s(r))),s(r))}function l(u,c){if(F(c)&&i.isInvertible())return o.gt(u,s(r))&&(u=o.add(i.invert(o.sub(u,s(r))),s(r))),c.invert(u);throw new Error("Could not invert due to no input being a variable")}return new g({inputs:[e],evaluate:a,invert:i.isInvertible()&&i.hasVariable()?l:void 0})}static if(e,t,n,i){const r=z(0),a=g.variable(r),l=n(a),u=i==null?void 0:i(a),c=me(t);function p(d){return s(c)?(r.value=d,l.evaluate()):u?(r.value=d,u.evaluate()):d}function v(d,h){if(!F(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(d)):u?h.invert(u.invert(d)):h.invert(d)}return new g({inputs:[e],evaluate:p,invert:l.isInvertible()&&l.hasVariable()?v: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:Vu,applySubstitution:Lu,integrate:Bu})}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:ju,integrate:zu,integrateInner:Uu,applySubstitution:Bn})}static sub(e,t){return new g({inputs:[e,t],evaluate:o.sub,invert:Gu,integrate:Wu,integrateInner:Hu,applySubstitution:Bn})}static mul(e,t){return new g({inputs:[e,t],evaluate:o.mul,invert:Zu,integrate:Yu,applySubstitution:Xu})}static div(e,t){return new g({inputs:[e,t],evaluate:o.div,invert:Ju,integrate:Ku,applySubstitution:Qu})}static recip(e){return new g({inputs:[e],evaluate:o.recip,invert:ec,integrate:tc})}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:nc,integrate:ac})}static log(e,t){return new g({inputs:[e,t],evaluate:o.log,invert:sc,integrate:uc})}static log2(e){return new g({inputs:[e],evaluate:o.log2,invert:cc,integrate:fc})}static ln(e){return new g({inputs:[e],evaluate:o.ln,invert:gc,integrate:hc})}static pow(e,t){return new g({inputs:[e,t],evaluate:o.pow,invert:bc,integrate:yc})}static pow10(e){return new g({inputs:[e],evaluate:o.pow10,invert:wc,integrate:_c})}static pow_base(e,t){return new g({inputs:[e,t],evaluate:o.pow_base,invert:Nc,integrate:Cc})}static root(e,t){return new g({inputs:[e,t],evaluate:o.root,invert:kc,integrate:Mc})}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:Sc,integrate:Ic})}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:xc,invert:$c})}static iteratedexp(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){return new g({inputs:[e,t,n],evaluate:Ec,invert:Pc})}static iteratedlog(e,t=10,n=1){return new g({inputs:[e,t,n],evaluate:Dc})}static slog(e,t=10){return new g({inputs:[e,t],evaluate:Tc,invert:Ac})}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:Fc,invert:Rc})}static lambertw(e){return new g({inputs:[e],evaluate:o.lambertw,invert:Oc})}static ssqrt(e){return new g({inputs:[e],evaluate:o.ssqrt,invert:qc})}static pentate(e,t=2,n=o.fromComponents_noNormalize(1,0,1)){return new g({inputs:[e,t,n],evaluate:Vc})}static sin(e){return new g({inputs:[e],evaluate:o.sin,invert:Wc,integrate:Lc})}static cos(e){return new g({inputs:[e],evaluate:o.cos,invert:Zc,integrate:zc})}static tan(e){return new g({inputs:[e],evaluate:o.tan,invert:Xc,integrate:Gc})}static asin(e){return new g({inputs:[e],evaluate:o.asin,invert:Bc,integrate:Hc})}static acos(e){return new g({inputs:[e],evaluate:o.acos,invert:jc,integrate:Yc})}static atan(e){return new g({inputs:[e],evaluate:o.atan,invert:Uc,integrate:Jc})}static sinh(e){return new g({inputs:[e],evaluate:o.sinh,invert:rd,integrate:Qc})}static cosh(e){return new g({inputs:[e],evaluate:o.cosh,invert:sd,integrate:td})}static tanh(e){return new g({inputs:[e],evaluate:o.tanh,invert:ld,integrate:id})}static asinh(e){return new g({inputs:[e],evaluate:o.asinh,invert:Kc,integrate:ad})}static acosh(e){return new g({inputs:[e],evaluate:o.acosh,invert:ed,integrate:od})}static atanh(e){return new g({inputs:[e],evaluate:o.atanh,invert:nd,integrate:ud})}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 Ee=Ve;Ee.negate=Ve.neg;Ee.negated=Ve.neg;Ee.sgn=Ve.sign;Ee.plus=Ve.add;Ee.subtract=Ve.sub;Ee.minus=Ve.sub;Ee.multiply=Ve.mul;Ee.times=Ve.mul;Ee.divide=Ve.div;Ee.divideBy=Ve.div;Ee.dividedBy=Ve.div;Ee.reciprocal=Ve.recip;Ee.reciprocate=Ve.recip;Ee.max=An(o.max);Ee.min=An(o.min);Ee.minabs=An(o.minabs);Ee.maxabs=An(o.maxabs);Ee.clampMin=An(o.clampMin);Ee.clampMax=An(o.clampMax);Ee.logarithm=Ve.log;class g extends Ee{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 Zr(e,t,n=!0,i,r=o.dInf){const a=me(n),l=me(i),u=me(r);return C(()=>{var h,m,_,y;const c=s(u);if(o.eq(c,1))return o.gte(t.value,e.evaluate())?o.dOne:o.dZero;const p=s(a),v=(h=s(l))!=null?h:p?10:0;let d=0;if(o.gt(c,v)){if(!e.isInvertible())throw new Error("Cannot calculate max affordable of non-invertible formula with more maxBulkAmount than directSum");if(p){if(!e.isIntegralInvertible())throw new Error("Cannot calculate max affordable of formula with non-invertible integral");d=o.floor(e.invertIntegral(o.add(t.value,e.evaluateIntegral()))).sub((m=s(e.innermostVariable))!=null?m:0)}else d=o.floor(e.invert(t.value))}if(d=o.clampMax(d,c),v>0){d=o.sub(d,v).clampMin(0);let I;for(p?I=En(e,d,!0,0):I=e.evaluate(o.add((_=s(e.innermostVariable))!=null?_:0,d));o.lt(d,c)&&o.lt(d,Number.MAX_SAFE_INTEGER);){const A=e.evaluate(d.add((y=s(e.innermostVariable))!=null?y:0));if(o.add(I,A).lte(t.value))d=d.add(1),I=o.add(I,A);else break}}return d})}function En(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 p=a.toNumber();p<l.toNumber();p++)u=o.add(u,e.evaluate(p));return u}function Ut(e){return Ke(t=>{const{addend:n,description:i,enabled:r,smallerIsBetter:a}=e.call(t,t),l=me(n),u=me(i),c=r==null?void 0:me(r);return{apply:p=>o.add(p,s(l)),invert:p=>o.sub(p,s(l)),getFormula:p=>g.add(p,l),enabled:c,description:i==null?void 0:X(()=>f("div",{class:"modifier-container"},[s(u)!=null?f("span",{class:"modifier-description"},[St(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)?"+":"",Gt(s(l))])]))}})}function Re(e){return Ke(t=>{const{multiplier:n,description:i,enabled:r,smallerIsBetter:a}=e.call(t,t),l=me(n),u=me(i),c=r==null?void 0:me(r);return{apply:p=>o.times(p,s(l)),invert:p=>o.div(p,s(l)),getFormula:p=>g.times(p,l),enabled:c,description:i==null?void 0:X(()=>f("div",{class:"modifier-container"},[s(u)!=null?f("span",{class:"modifier-description"},[St(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"),Gt(s(l))])]))}})}function Ai(e){return Ke(t=>{const{exponent:n,description:i,enabled:r,supportLowNumbers:a,smallerIsBetter:l}=e.call(t,t),u=me(n),c=me(i),p=r==null?void 0:me(r);return{apply:v=>{let d=v;return a&&(d=o.add(d,1)),d=o.pow(d,s(u)),a&&(d=o.sub(d,1)),d},invert:v=>{let d=v;return a&&(d=o.add(d,1)),d=o.root(d,s(u)),a&&(d=o.sub(d,1)),d},getFormula:v=>a?g.add(v,1).pow(u).sub(1):g.pow(v,u),enabled:p,description:i==null?void 0:X(()=>f("div",{class:"modifier-container"},[s(c)!=null?f("span",{class:"modifier-description"},[St(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("^"),Gt(s(u))])]))}})}function Nt(e){return Ke(()=>{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)?X(()=>f(te,null,[t.filter(n=>s(n.enabled)!==!1).map(n=>s(n.description)).filter(n=>n).map(St)])):void 0}})}const Li=g.variable(0).step(100,e=>e.pow(1.5)).step(o.pow(900,1.5).add(100),e=>e.pow(1.5)).pow(1.5),hi={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:[]}),w.board.selectedAction.value=null,w.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}},Ot={id:"toggle",icon:"bolt",tooltip:e=>({text:e.state.powered?"Turn Off":`Turn On - Always runs for ${Mt(w.nextPowerCost.value)} energy/s`}),onClick(e){e.state={...e.state,powered:!e.state.powered},w.board.selectedAction.value=null},fillColor:e=>e.state.powered?"var(--accent1)":"var(--locked)"};function _n(e,t=1/0){const n=e(g.variable(0));return{id:"moreConnections",icon:"hub",formula:n,tooltip(i){return{text:`Increase Connections - ${Mt(n.evaluate(i.state.maxConnections))} energy`}},confirmationLabel:i=>o.gte(w.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(w.energy.value,r)&&(w.energy.value=o.sub(w.energy.value,r)),i.state={...i.state,maxConnections:o.add(i.state.maxConnections,1)},w.board.selectedAction.value=null},visibility:i=>o.add(i.state.maxConnections,w.computedBonusConnectionsModifier.value).lt(t)}}function Yr(e,t){var n,i;if(((n=w.board.draggingNode.value)==null?void 0:n.type)==="resource"){const r=((i=w.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,w.computedBonusConnectionsModifier.value).lte(l.length)?{text:"Max connections",color:"var(--danger)"}:{text:t(r),color:"var(--accent2)"}}return null}function pd(e,t){var n,i;if(((n=w.board.draggingNode.value)==null?void 0:n.type)==="passive"){const r=(i=w.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,w.computedBonusConnectionsModifier.value).lte(l.length)?{text:"Max connections",color:"var(--danger)"}:{text:t(r),color:"var(--accent2)"}}return null}function bi(e,t){var n,i;if(((n=w.board.draggingNode.value)==null?void 0:n.type)==="portal"){const r=((i=w.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,w.computedBonusConnectionsModifier.value).lte(l.length)?{text:"Max connections",color:"var(--danger)"}:{text:t(r),color:"var(--accent2)"}}return null}function Xr(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,w.computedBonusConnectionsModifier.value).lte(r.length)}function Jr(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]},w.board.selectedNode.value=e}function fd(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,w.computedBonusConnectionsModifier.value).lte(r.length)}function gd(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]},w.board.selectedNode.value=e}function yi(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,w.computedBonusConnectionsModifier.value).lte(r.length)}function wi(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]},w.board.selectedNode.value=e}function he(e){return e===w.board.selectedNode.value||e.state.powered}function it(e){return w.empowerer.value!=null&&he(w.empowerer.value)&&w.empowerer.value.state.tools.includes(e)}function md(e){var a,l,u;const t=(u=(l=(a=w.resourceNodes.value[e])==null?void 0:a.state)==null?void 0:l.amount)!=null?u:0,n=w.resourceLevels.value[e],i=Li.evaluate(n),r=Li.evaluate(o.add(n,1));return o.sub(t,i).max(0).div(o.sub(r,i)).toNumber()}function cn(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 vd={key:0},hd={key:0,class:"mark star"},bd=["src"],yd=Y({__name:"MarkNode",props:{mark:{type:[Boolean,String]}},setup(e){return(t,n)=>e.mark?(M(),D("div",vd,[e.mark===!0?(M(),D("div",hd)):(M(),D("img",{key:1,class:"mark",src:e.mark},null,8,bd))])):j("",!0)}});var Yn=de(yd,[["__scopeId","data-v-2207999f"]]);const wd=Y({__name:"Node",props:{id:null},setup(e){const n=Te(e),i=oi(Gi,()=>{}),r=oi(Wi,()=>{}),a=ht(null),l=C(()=>a.value&&a.value.parentElement);return vt([l,n.id],([u,c],[p,v])=>{p&&r(s(v)),u&&i(c,u)}),Cr(()=>r(s(n.id))),(u,c)=>(M(),D("div",{class:"node",ref_key:"node",ref:a},null,512))}});var Xn=de(wd,[["__scopeId","data-v-a48cb382"]]),_d=Y({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}=Te(e),r=ht("");Et(()=>{var v;const u=$e(t);if(u==null){r.value="";return}if(Pt(u)){r.value=oe(u);return}const c=oe((v=u.title)!=null?v:"","h3"),p=oe(u.description,"div");r.value=oe(X(()=>f("span",null,[u.title!=null?f("div",null,[f(c,null,null)]):null,f(p,null,null)])))});const{start:a,stop:l}=Fr(n,i);return{start:a,stop:l,comp:r,Visibility:_e,isVisible:ze,isHidden:yn,unref:s}}});function Nd(e,t,n,i,r,a){var c;const l=It("MarkNode"),u=It("Node");return e.isVisible(e.visibility)?(M(),D("button",{key:0,style:Le([{visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:[]]),onClick:t[0]||(t[0]=(...p)=>e.onClick&&e.onClick(...p)),onMousedown:t[1]||(t[1]=(...p)=>e.start&&e.start(...p)),onMouseleave:t[2]||(t[2]=(...p)=>e.stop&&e.stop(...p)),onMouseup:t[3]||(t[3]=(...p)=>e.stop&&e.stop(...p)),onTouchstartPassive:t[4]||(t[4]=(...p)=>e.start&&e.start(...p)),onTouchendPassive:t[5]||(t[5]=(...p)=>e.stop&&e.stop(...p)),onTouchcancelPassive:t[6]||(t[6]=(...p)=>e.stop&&e.stop(...p)),class:ve({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(),K(Xe(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 Kr=de(_d,[["render",Nd],["__scopeId","data-v-211328c0"]]);const Qr=Symbol("Clickable");function Cd(e,...t){const n=t.reduce((i,r)=>{var a;return Object.assign(i,(a=r.getPersistentData)==null?void 0:a.call(r))},{});return Ke(i=>{var l,u,c;const r=(l=e==null?void 0:e.call(i,i))!=null?l:{};r.id=on("clickable-"),r.type=Qr,r[yt]=Kr;for(const p of t)(u=p.preConstruct)==null||u.call(p,r);if(Object.assign(r,n),x(r,"visibility"),ne(r,"visibility",_e.Visible),x(r,"canClick"),ne(r,"canClick",!0),x(r,"classes"),x(r,"style"),x(r,"mark"),x(r,"display"),r.onClick){const p=r.onClick.bind(r);r.onClick=function(v){s(r.canClick)!==!1&&p(v)}}if(r.onHold){const p=r.onHold.bind(r);r.onHold=function(){s(r.canClick)!==!1&&p()}}for(const p of t)(c=p.postConstruct)==null||c.call(p,r);const a=t.reduce((p,v)=>{var d;return Object.assign(p,(d=v.getGatheredProps)==null?void 0:d.call(v,r))},{});return r[pt]=function(){const{display:p,visibility:v,style:d,classes:h,onClick:m,onHold:_,canClick:y,small:I,mark:A,id:S}=this;return{display:p,visibility:v,style:s(d),classes:h,onClick:m,onHold:_,canClick:y,small:I,mark:A,id:S,...a}},r})}function kd(e,t,n=[]){n=n.length===0?Wn(e,Qr):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 Md=["x1","y1","x2","y2"],Sd=Y({__name:"Link",props:{link:null,startNode:null,endNode:null,boundingRect:null},setup(e){const n=Te(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(),D("line",Ht({"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,Md))}});const Id=Y({__name:"Links",props:{links:null},setup(e){var c;const n=an(e,"links"),i=z(null),r=oi(Hi,z({})),a=oi(Zi,z(void 0)),l=z((c=i.value)==null?void 0:c.getBoundingClientRect());vt(a,()=>{var p;return l.value=(p=i.value)==null?void 0:p.getBoundingClientRect()}),gi(()=>{var p;return l.value=(p=i.value)==null?void 0:p.getBoundingClientRect()});const u=C(()=>{var v,d;const p=r.value;return(d=(v=n.value)==null?void 0:v.filter(h=>{var m,_;return((m=p[h.startNode.id])==null?void 0:m.rect)&&((_=p[h.startNode.id])==null?void 0:_.rect)}))!=null?d:[]});return(p,v)=>(M(),D(te,null,[s(u)?(M(),D("svg",_a(Ht({key:0},p.$attrs)),[(M(!0),D(te,null,Dn(s(u),(d,h)=>(M(),K(Sd,{key:h,link:d,boundingRect:l.value,startNode:s(r)[d.startNode.id],endNode:s(r)[d.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 xd=de(Id,[["__scopeId","data-v-063f6d6b"]]);Y({props:{nodes:{type:R(Array),required:!0},leftSideNodes:R(Array),rightSideNodes:R(Array),branches:R(Array)},components:{Links:xd},setup(e){const{nodes:t,leftSideNodes:n,rightSideNodes:i}=Te(e),r=ht();Et(()=>{const u=$e(t);r.value=oe(X(()=>f(te,null,[u.map(c=>f("span",{class:"row tree-row",style:"margin: 50px auto;"},[c.map(St)]))])))});const a=ht();Et(()=>{const u=$e(n);a.value=u?oe(X(()=>f("span",{class:"left-side-nodes small"},[u.map(St)]))):""});const l=ht();return Et(()=>{const u=$e(i);l.value=u?oe(X(()=>f("span",{class:"side-nodes small"},[u.map(St)]))):""}),{unref:s,nodesComp:r,leftNodesComp:a,rightNodesComp:l}}});Y({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}=Te(e),r=Tn(i),{start:a,stop:l}=Fr(t,n);return{start:a,stop:l,comp:r,unref:s,Visibility:_e,isCoercableComponent:Pt,isVisible:ze,isHidden:yn}}});function Ln(e){const t=[],n={};let i=!1;function r(){return i||(t.push(...e()),n.base=t.map(u=>me(u.base)),n.baseText=t.map(u=>me(u.baseText)),n.visible=t.map(u=>me(u.visible)),n.title=t.map(u=>me(u.title)),n.subtitle=t.map(u=>me(u.subtitle)),i=!0),t}const a=dt({},!1);return[X(()=>{const u=r();let c=!0;const p=u.map((v,d)=>{var A,S,P;if(s(n.visible[d])===!1)return null;const h=f("h3",{onClick:()=>a.value[d]=!a.value[d],style:"cursor: pointer"},[f("span",{class:"modifier-toggle"+(s(a.value[d])?" collapsed":"")},[E("\u25BC")]),s(n.title[d]),s(n.subtitle[d])!=null?f("span",{class:"subtitle"},[E(" ("),s(n.subtitle[d]),E(")")]):null]),m=s(a.value[d])?null:f(te,null,[f("div",{class:"modifier-container"},[f("span",{class:"modifier-description"},[St((A=s(n.baseText[d]))!=null?A:"Base")]),f("span",{class:"modifier-amount"},[we((S=s(n.base[d]))!=null?S:1),v.unit])]),v.modifier.description==null?null:St(s(v.modifier.description))]),_=!c;c=!1;const y=(P=s(n.base[d]))!=null?P:1,I=v.modifier.apply(y);return f(te,null,[_?f("br",null,null):null,f("div",{style:{"--unit":ae.alignUnits&&v.unit!=null?"'"+v.unit+"'":""}},[h,f("br",null,null),m,f("hr",null,null),f("div",{class:"modifier-container"},[f("span",{class:"modifier-description"},[E("Total")]),f("span",{class:"modifier-amount",style:(v.smallerIsBetter===!0?o.gt(I,y!=null?y:1):o.lt(I,y!=null?y:1))?"color: var(--danger)":""},[Gt(I),v.unit])])])])});return f(te,null,[p])}),a]}function Fi(e,t,n){const i=me(t),r=me(n);return C(()=>{const a=s(i),l=s(r);return o.gte(e.value,l)?"Now":o.lte(a,0)?"Never":vi(o.sub(l,e.value).div(a))})}function dn(e,t,n=1){const i=me(t),r=me(n);if(!e.hasVariable())throw new Error("Cannot create formula preview if the formula does not have a variable");return X(()=>{var a;if(s(i)){const l=Gt(e.evaluate()),u=Gt(e.evaluate(o.add(s((a=e.innermostVariable)!=null?a:0),s(r))));return f(te,null,[f("b",null,[f("i",null,[l,E(" \u2192 "),u])])])}return f(te,null,[Gt(e.evaluate())])})}const $t={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},en=Object.keys($t),Be={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}}},fi={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"},$d={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"}},Ct={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}},Ri=g.variable(0).add(8).times(2).pow10();const Ed=Y({__name:"Spacer",props:{width:{default:"8px"},height:{default:"17px"}},setup(e){return(t,n)=>(M(),D("div",{style:Le({width:e.width,height:e.height})},null,4))}});function Rn(e){return Ke(t=>{var i;const n=e.call(t,t);return n.partialDisplay=r=>f("span",{style:s(n.requirementMet)?"":"color: var(--danger)"},[pi(n.resource,n.cost instanceof g?En(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: ",pi(n.resource,n.cost instanceof g?En(n.cost,r!=null?r:1,s(n.cumulativeCost),s(n.directSum)):s(n.cost))," ",n.resource.displayName]),x(n,"visibility"),ne(n,"visibility",_e.Visible),x(n,"cost"),x(n,"requiresPay"),ne(n,"requiresPay",!0),x(n,"cumulativeCost"),ne(n,"cumulativeCost",!0),x(n,"maxBulkAmount"),ne(n,"maxBulkAmount",1),x(n,"directSum"),ne(n,"pay",function(r){const a=n.cost instanceof g?En(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=Zr(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 Qi(e){return Ke(()=>({requirementMet:C(()=>ze(e.visibility)),visibility:_e.None,requiresPay:!1}))}function Pd(e,t){return Ke(()=>({requirementMet:me(e),partialDisplay:t==null?void 0:X(()=>St(t)),display:t==null?void 0:X(()=>f(te,null,[E("Req: "),St(t)])),visibility:t==null?_e.None:_e.Visible,requiresPay:!1}))}function _i(e){if(Rt(e))return e.every(_i);const t=s(e.requirementMet);return typeof t=="boolean"?t:o.gt(t,0)}function ea(e){if(Rt(e))return e.map(ea).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 Ni(e,t=1){var n,i;if(Rt(e)&&(e=e.filter(r=>ze(r.visibility)),e.length===1&&(e=e[0])),Rt(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(te,null,[r.length>0?f("div",null,[E("Costs:")," ",gr(r.map(l=>l.partialDisplay(t)),f(te,null,[E(", ")]))]):null,a.length>0?f("div",null,[E("Requires:")," ",gr(a.map(l=>l.partialDisplay(t)),f(te,null,[E(", ")]))]):null])}return(i=(n=e.display)==null?void 0:n.call(e))!=null?i:f(te,null,null)}function ta(e,t=1){var n;Rt(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 Dd=Y({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}=Te(e),r=ht("");return Et(()=>{const a=$e(t);if(a==null){r.value="";return}if(Pt(a)){r.value=oe(a);return}const l=oe(a.requirement?a.requirement:X(()=>{var p;return Ni((p=$e(n))!=null?p:[])}),"h3"),u=oe(a.effectDisplay||"","b"),c=$e(i)?oe(a.optionsDisplay||"","span"):"";r.value=oe(X(()=>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:_e,isVisible:ze,isHidden:yn}}});function Td(e,t,n,i,r,a){var c;const l=It("MarkNode"),u=It("Node");return e.isVisible(e.visibility)?(M(),D("div",{key:0,style:Le([{visibility:e.isHidden(e.visibility)?"hidden":void 0,backgroundImage:e.earned&&e.image&&`url(${e.image})`||""},(c=e.unref(e.style))!=null?c:[]]),class:ve({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(),K(Xe(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 Ad=de(Dd,[["render",Td],["__scopeId","data-v-5673325a"]]);const Fd=mi(),Rd=Symbol("Achievement");let xn=function(e){return e.All="all",e.Configurable="configurable",e.Incomplete="incomplete",e.None="none",e}({});function Od(e,...t){const n=dt(!1,!1),i=t.reduce((r,a)=>{var l;return Object.assign(r,(l=a.getPersistentData)==null?void 0:l.call(a))},{});return Ke(r=>{var c,p,v;const a=(c=e==null?void 0:e.call(r,r))!=null?c:{};a.id=on("achievement-"),a.type=Rd,a[yt]=Ad;for(const d of t)(p=d.preConstruct)==null||p.call(d,a);a.earned=n,a.complete=function(){var h,m;n.value=!0;const d=a;if((h=d.onComplete)==null||h.call(d),d.display!=null&&s(d.showPopups)===!0){const _=s(d.display);let y;Pt(_)?y=oe(_):_.requirement!=null?y=oe(_.requirement):y=Ni((m=d.requirements)!=null?m:[]),Fd.info(f("div",null,[f("h3",null,[E("Achievement earned!")]),f("div",null,[f(y,null,null)])]))}},Object.assign(a,i),x(a,"visibility"),ne(a,"visibility",_e.Visible);const l=a.visibility;a.visibility=Na(()=>{const d=s(a.display);switch(ae.msDisplay){default:case xn.All:return s(l);case xn.Configurable:return s(a.earned)&&!(d!=null&&typeof d=="object"&&"optionsDisplay"in d)?_e.None:s(l);case xn.Incomplete:return s(a.earned)?_e.None:s(l);case xn.None:return _e.None}}),x(a,"display"),x(a,"mark"),x(a,"small"),x(a,"image"),x(a,"style"),x(a,"classes"),x(a,"showPopups"),ne(a,"showPopups",!0);for(const d of t)(v=d.postConstruct)==null||v.call(d,a);const u=t.reduce((d,h)=>{var m;return Object.assign(d,(m=h.getGatheredProps)==null?void 0:m.call(h,a))},{});if(a[pt]=function(){const{visibility:d,display:h,requirements:m,earned:_,image:y,style:I,classes:A,mark:S,small:P,id:B}=this;return{visibility:d,display:h,requirements:m,earned:_,image:y,style:s(I),classes:A,mark:S,small:P,id:B,...u}},a.requirements){const d=a,h=[Qi(d),Pd(()=>!d.earned.value),...Rt(a.requirements)?a.requirements:[a.requirements]];Et(()=>{ae.active===J.id&&_i(h)&&d.complete()})}return a})}Je.on("loadSettings",e=>{ne(e,"msDisplay",xn.All)});const qd=Object.values(xn).map(e=>({label:et(e),value:e}));Ds(X(()=>f(Ji,{title:X(()=>f("span",{class:"option-title"},[E("Show achievements"),f("desc",null,[E("Select which achievements to display based on criterias.")])])),options:qd,"onUpdate:modelValue":e=>ae.msDisplay=e,modelValue:ae.msDisplay},null)));const Vd=Y({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}=Te(e),l=C(()=>{let p=t.value instanceof o?t.value.toNumber():Number(t.value);return(1-Math.min(Math.max(p,0),1))*100}),u=C(()=>{const p={width:$e(n)+.5+"px",height:$e(i)+.5+"px"};switch(s(r)){case U.Up:p.clipPath=`inset(${l.value}% 0% 0% 0%)`,p.width=$e(n)+1+"px";break;case U.Down:p.clipPath=`inset(0% 0% ${l.value}% 0%)`,p.width=$e(n)+1+"px";break;case U.Right:p.clipPath=`inset(0% ${l.value}% 0% 0%)`;break;case U.Left:p.clipPath=`inset(0% 0% 0% ${l.value} + '%)`;break;case U.Default:p.clipPath="inset(0% 50% 0% 0%)";break}return p}),c=Tn(a);return{normalizedProgress:l,barStyle:u,component:c,unref:s,Visibility:_e,isVisible:ze,isHidden:yn}}});function Bd(e,t,n,i,r,a){var c,p,v,d,h,m,_;const l=It("MarkNode"),u=It("Node");return e.isVisible(e.visibility)?(M(),D("div",{key:0,style:Le([{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:ve({bar:!0,...e.unref(e.classes)})},[N("div",{class:"overlayTextContainer border",style:Le([{width:e.unref(e.width)+"px",height:e.unref(e.height)+"px"},(p=e.unref(e.borderStyle))!=null?p:{}])},[e.component?(M(),D("span",{key:0,class:"overlayText",style:Le(e.unref(e.textStyle))},[(M(),K(Xe(e.component)))],4)):j("",!0)],4),N("div",{class:"border",style:Le([{width:e.unref(e.width)+"px",height:e.unref(e.height)+"px"},(v=e.unref(e.style))!=null?v:{},(d=e.unref(e.baseStyle))!=null?d:{},(h=e.unref(e.borderStyle))!=null?h:{}])},[N("div",{class:"fill",style:Le([e.barStyle,(m=e.unref(e.style))!=null?m:{},(_=e.unref(e.fillStyle))!=null?_:{}])},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 Ld=de(Vd,[["render",Bd],["__scopeId","data-v-6bd06b56"]]);const jd=Symbol("Bar");function zd(e,...t){const n=t.reduce((i,r)=>{var a;return Object.assign(i,(a=r.getPersistentData)==null?void 0:a.call(r))},{});return Ke(i=>{var l,u;const r=e.call(i,i);r.id=on("bar-"),r.type=jd,r[yt]=Ld;for(const c of t)(l=c.preConstruct)==null||l.call(c,r);Object.assign(r,n),x(r,"visibility"),ne(r,"visibility",_e.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,p)=>{var v;return Object.assign(c,(v=p.getGatheredProps)==null?void 0:v.call(p,r))},{});return r[pt]=function(){const{progress:c,width:p,height:v,direction:d,display:h,visibility:m,style:_,classes:y,borderStyle:I,textStyle:A,baseStyle:S,fillStyle:P,mark:B,id:ie}=this;return{progress:c,width:p,height:v,direction:d,display:h,visibility:m,style:s(_),classes:y,borderStyle:I,textStyle:A,baseStyle:S,fillStyle:P,mark:B,id:ie,...a}},r})}function Ud(e,...t){return Ke(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"),ne(i,"buyMax",!0);for(const l of t)(a=l.postConstruct)==null||a.call(l,i);return i})}function Gd(e){return Ud(e)}function Wd(e,t,n=1,i=o.dInf){const r=me(n),a=me(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 na=Symbol("Repeatable");function hr(e,...t){const n=dt(0),i=t.reduce((r,a)=>{var l;return Object.assign(r,(l=a.getPersistentData)==null?void 0:l.call(a))},{});return Ke(r=>{var h,m,_;const a=e.call(r,r);a.id=on("repeatable-"),a.type=na,a[yt]=Kr;for(const y of t)(h=y.preConstruct)==null||h.call(y,a);a.amount=n,a.amount[sn]=(m=a.initialAmount)!=null?m:0,Object.assign(a,i);const l={requirementMet:C(()=>o.sub(s(a.limit),a.amount.value)),requiresPay:!1,visibility:_e.None},u=Qi(a);Rt(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 y=s(c)||{};return a.maxed.value&&(y.bought=!0),y}),a.amountToIncrease=C(()=>o.clampMin(ea(a.requirements),1)),a.canClick=C(()=>_i(a.requirements));const p=a.onClick;a.onClick=function(y){const I=a;!s(I.canClick)||(ta(a.requirements,s(a.amountToIncrease)),I.amount.value=o.add(I.amount.value,1),p==null||p(y))},x(a,"display");const v=a.display;a.display=X(()=>{var I,A,S;const y=s(v);if(Pt(y)){const P=oe(y);return f(P,null,null)}if(y!=null){const P=a,B=oe((I=y.title)!=null?I:"","h3"),ie=oe((A=y.description)!=null?A:""),pe=oe((S=y.effectDisplay)!=null?S:"");return f("span",null,[y.title==null?null:f("div",null,[f(B,null,null)]),y.description==null?null:f(ie,null,null),y.showAmount===!1?null:f("div",null,[f("br",null,null),f(te,null,[E("Amount: "),Mt(P.amount.value)]),o.isFinite(s(P.limit))?f(te,null,[E(" / "),Mt(s(P.limit))]):void 0]),y.effectDisplay==null?null:f("div",null,[f("br",null,null),E("Currently: "),f(pe,null,null)]),P.maxed.value?null:f("div",null,[f("br",null,null),Ni(P.requirements,s(a.amountToIncrease))])])}return""}),x(a,"visibility"),ne(a,"visibility",_e.Visible),x(a,"limit"),ne(a,"limit",o.dInf),x(a,"style"),x(a,"mark"),x(a,"small");for(const y of t)(_=y.postConstruct)==null||_.call(y,a);const d=t.reduce((y,I)=>{var A;return Object.assign(y,(A=I.getGatheredProps)==null?void 0:A.call(I,a))},{});return a[pt]=function(){const{display:y,visibility:I,style:A,classes:S,onClick:P,canClick:B,small:ie,mark:pe,id:ee}=this;return{display:y,visibility:I,style:s(A),classes:S,onClick:P,canClick:B,small:ie,mark:pe,id:ee,...d}},a})}const Hd=Symbol("Reset");function Zd(e){return Ke(t=>{const n=e.call(t,t);return n.id=on("reset-"),n.type=Hd,n.reset=function(){var r;const i=a=>{if(a!=null&&typeof a=="object")if(sn in a){const l=a;l.value=l[sn]}else!(a instanceof o)&&!qe(a)&&Object.values(a).forEach(l=>i(l))};s(n.thingsToReset).forEach(i),Je.emit("reset",n),(r=n.onReset)==null||r.call(n)},x(n,"thingsToReset"),n})}const ri={};Je.on("removeLayer",e=>{var t;(t=ri[e.id])==null||t.call(ri),ri[e.id]=void 0});function Oi(e,t){return x(t,"display"),x(t,"classes"),x(t,"style"),x(t,"direction"),ne(t,"direction",U.Up),x(t,"xoffset"),x(t,"yoffset"),t.pinnable&&(t.pinned=dt(!1,!1)),Wt(()=>{t.pinnable&&("pinned"in e?(console.error("Cannot add pinnable tooltip to element that already has a property called 'pinned'"),t.pinnable=!1,qr(t.pinned)):e.pinned=t.pinned);const n=e[yt];e[yt]=Oe;const i=e[pt].bind(e);e[pt]=function(){const{display:a,classes:l,style:u,direction:c,xoffset:p,yoffset:v,pinned:d}=this;return{element:{[yt]:n,[pt]:i},display:a,classes:l,style:s(u),direction:c,xoffset:p,yoffset:v,pinned:d}}.bind(t)}),t}var Yd=Y({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}=Te(e),r=ht("");return Et(()=>{const a=$e(t);if(a==null){r.value="";return}if(Pt(a)){r.value=oe(a);return}const l=oe(a.title||"","h3"),u=oe(a.description,"div"),c=oe(a.effectDisplay||"");r.value=oe(X(()=>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(te,null,[f("br",null,null),Ni(n.value)])])))}),{component:r,unref:s,Visibility:_e,isVisible:ze,isHidden:yn}}});const Xd=["disabled"];function Jd(e,t,n,i,r,a){var c;const l=It("MarkNode"),u=It("Node");return e.isVisible(e.visibility)?(M(),D("button",{key:0,style:Le([{visibility:e.isHidden(e.visibility)?"hidden":void 0},(c=e.unref(e.style))!=null?c:{}]),onClick:t[0]||(t[0]=(...p)=>e.purchase&&e.purchase(...p)),class:ve({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(),K(Xe(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,Xd)):j("",!0)}var Kd=de(Yd,[["render",Jd],["__scopeId","data-v-9be6bac0"]]);const er=Symbol("Upgrade");function br(e,...t){const n=dt(!1,!1),i=t.reduce((r,a)=>{var l;return Object.assign(r,(l=a.getPersistentData)==null?void 0:l.call(a))},{});return Ke(r=>{var c,p;const a=e.call(r,r);a.id=on("upgrade-"),a.type=er,a[yt]=Kd;for(const v of t)(c=v.preConstruct)==null||c.call(v,a);a.bought=n,Object.assign(a,i),a.canPurchase=C(()=>!n.value&&_i(a.requirements)),a.purchase=function(){var d;const v=a;!s(v.canPurchase)||(ta(a.requirements),n.value=!0,(d=v.onPurchase)==null||d.call(v))};const l=Qi(a);Rt(a.requirements)?a.requirements.unshift(l):a.requirements=[l,a.requirements],x(a,"visibility"),ne(a,"visibility",_e.Visible),x(a,"classes"),x(a,"style"),x(a,"display"),x(a,"mark");for(const v of t)(p=v.postConstruct)==null||p.call(v,a);const u=t.reduce((v,d)=>{var h;return Object.assign(v,(h=d.getGatheredProps)==null?void 0:h.call(d,a))},{});return a[pt]=function(){const{display:v,visibility:d,style:h,classes:m,requirements:_,canPurchase:y,bought:I,mark:A,id:S,purchase:P}=this;return{display:v,visibility:d,style:s(h),classes:m,requirements:_,canPurchase:y,bought:I,mark:A,id:S,purchase:P,...u}},a})}function Qd(e,t,n=[]){n=n.length===0?Wn(e,er):n;const i=Un(t)?C(t):t;e.on("update",()=>{s(i)&&n.forEach(r=>r.purchase())})}function ep(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 tp={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"]},yr=[[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 qi(e){const t=yr[Math.floor(e()*yr.length)];let n="";for(let i=0;i<t.length;i++){const r=tp[t[i]];n+=r[Math.floor(e()*r.length)]}return et(n)}const np={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"]},wr=[[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=wr[Math.floor(e()*wr.length)];let n="";for(let i=0;i<t.length;i++){const r=np[t[i]];n+=r[Math.floor(e()*r.length)]}return et(n)}function On(e,t){const[n,i,r]=ip(...e),[a,l,u]=rp(Math.floor(t()*360),i,r);return`rgb(${a*255}, ${l*255}, ${u*255})`}function ip(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 rp(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 _r=mi();function ia(e,t,n,i){return Yi(e,function(){const r=ep(0,n>>0,n>>32,1);for(let q=0;q<12;q++)r();const a=qi(r),l=On([.64,.75,.55],r),u=On([.18,.2,.25],r),c=In(0,qi(r)),p=dt(0),v=en.indexOf(t);let d=r();const h=i.reduce((q,L)=>(q[L.type]=L.data,q),{});"increaseDiff"in h&&(d=d/2+.5),"decreaseDiff"in h&&(d=d/2),"relic"in h&&(d=1);const m=d+v+1,_=w.toolNodes.value.sandRelic!=null?it("sandRelic")?2:1:0,y=dt(_),I=C(()=>("increaseRewards"in h?m+1:m)+y.value);let A="relic"in h?v+2:Math.ceil(r()*(v+2));"increaseLength"in h&&A++;const S=[],P=Nt(()=>[...S,Re(()=>({multiplier:()=>w.isEmpowered("silver")?4:2,description:()=>(w.isEmpowered("silver")?"Empowered ":"")+Be.silver.name,enabled:()=>w.toolNodes.value.silver!=null})),Re(()=>({multiplier:()=>(w.isEmpowered("diamond")?2:1)*at.filter(q=>q.bought.value).length/10,description:()=>(w.isEmpowered("diamond")?"Empowered ":"")+Be.diamond.name,enabled:()=>w.toolNodes.value.diamond!=null})),Re(()=>({multiplier:()=>o.div(p.value,6e3).times(w.isEmpowered("emerald")?2:1).add(1),description:()=>(w.isEmpowered("emerald")?"Empowered ":"")+Be.emerald.name,enabled:()=>w.toolNodes.value.emerald!=null}))]),B=C(()=>P.apply(0)),ie=[],pe={};function ee({feature:q,canClick:L,modifier:Ce,cost:Fe,previewModifier:Kt,showETA:ot,previewCost:Vt}){L=me(L),ot=me(ot);const Bt=mr(q);ie.push({shouldShowPreview:C(()=>s(L)&&Bt.value),modifier:Nt(()=>{const Dt=S.slice();return Dt.splice(Dt.indexOf(Ce),1,Kt),Dt}),cost:Vt!=null?Vt:Fe}),S.push(Ce);const Lt=Fi(c,B,()=>Ne(Fe)),tt=Oi(q,{display:ot==null?Lt:()=>s(ot)?Lt.value:"",direction:U.Down});return{isHovering:Bt,eta:Lt,tooltip:tt}}const H=[],le=z(0);let V=g.variable(le).times(0);const re={};let Ae=!0;const Ge=C(()=>o.add(m,r()-.5).pow_base(2).times(10).times(V.evaluate())),Xt=[];for(let q=0;q<A;q++){const L={upgrades:32,repeatables:q<=1?0:16,conversion:q<=3?0:8,xp:q<=5?0:4,dimensions:q<=7?0:2,prestige:q<=7||q>=A-1?0:1};switch(ai(L,r)){case"upgrades":const ue=[];for(let Me=0;Me<4;Me++){const gt=ai({add:1,mult:q===0&&Me===0?0:1,pow:q===0?0:.5},r),Qe=Ge.value,nt=Sn(r);let ut="",Se,Pe;const Ie=le.value;switch(gt){case"add":{const ce=o.add(Qe,10).pow(r()/4+.875);ut=`Gain ${we(ce)} ${c.displayName}/s`,V=V.add(ce),Se=He=>Ut(()=>({addend:ce,description:nt,enabled:He==null?De.bought:()=>He()&&De.bought.value})),Pe=Ut(()=>({addend:ce}));break}case"mult":{const ce=r()*5+1;ut=`Multiply previous ${c.displayName} gain by x${we(ce)}.`,V=V.add(o.sub(ce,1).times(re[Ie-1])),Se=He=>Re(()=>({multiplier:ce,description:nt,enabled:He==null?De.bought:()=>He()&&De.bought.value})),Pe=Re(()=>({multiplier:ce}));break}case"pow":{const ce=r()/10+1.05;ut=`Raise previous ${c.displayName} gain to the ^${we(ce)}`,V=V.add(o.pow(re[Ie-1],ce)).sub(re[Ie-1]),Se=He=>Ai(()=>({exponent:ce,description:nt,enabled:He==null?De.bought:()=>He()&&De.bought.value})),Pe=Ai(()=>({exponent:ce}))}}re[le.value]=V.evaluate(),le.value++;const We=Ae,De=br(()=>({requirements:Rn(()=>({resource:Mn(c),cost:Qe})),display:{title:nt,description:ut},visibility:We}));ee({feature:De,canClick:()=>De.canPurchase.value,modifier:Se(),cost:Qe,showETA:()=>!De.bought.value,previewModifier:Pe}),S.push(Se(()=>w.toolNodes.value.dirtRelic!=null)),S.push(Se(()=>it("dirtRelic"))),ue.push(De)}H.push(ue);break;case"repeatables":const xt=[];for(let Me=0;Me<3;Me++){const gt=ai({add:1.5,mult:3},r),Qe=le.value,nt=Ge.value,ut=Sn(r);let Se="",Pe,Ie,We,De;const ce=g.variable(C(()=>Ze.amount.value)).times(2);switch(gt){case"add":{const xe=o.add(nt,10).times(r()+.5);Se=`Gain ${we(xe)} ${c.displayName}/s`,De=ce.add(1).times(nt),V=V.add(C(()=>o.sub(le.value,Qe).add(1).times(5).times(xe))),Pe=C(()=>we(o.times(xe,Ze.amount.value))+"/s"),Ie=Ut(()=>({addend:()=>o.times(xe,Ze.amount.value),description:ut,enabled:()=>o.gt(Ze.amount.value,0)})),We=Ut(()=>({addend:()=>o.add(Ze.amount.value,1).times(xe)}));break}case"mult":{const xe=r()*.75+1.25;Se=`Multiply previous ${c.displayName} gain by x${we(xe)}.`,De=ce.pow_base(xe).times(nt),V=V.add(C(()=>o.sub(le.value,Qe).add(1).times(5).pow_base(xe).sub(1).times(re[Qe-1]))),Pe=C(()=>"x"+we(o.pow(xe,Ze.amount.value))),Ie=Re(()=>({multiplier:()=>o.pow(xe,Ze.amount.value),description:ut,enabled:()=>o.gt(Ze.amount.value,0)})),We=Re(()=>({multiplier:()=>o.add(Ze.amount.value,1).pow_base(xe)}));break}}re[le.value]=V.evaluate(),le.value++;const He=Ae,Ze=hr(()=>({requirements:Rn(()=>({resource:Mn(c),cost:De})),display:()=>({title:ut,description:Se,effectDisplay:s(Pe)}),visibility:He}));ee({feature:Ze,canClick:()=>s(Ze.canClick),modifier:Ie,cost:De,previewModifier:We}),xt.push(Ze)}H.push(xt);break;case"conversion":const ke=In(0,qi(r)),ft=On([.64,.75,.55],r),jt=Ge.value,ra=r()/2+.25,nr=r()/2+.25,ir=le.value;V=V.add(C(()=>o.sub(le.value,ir).add(1).pow_base(5).pow(nr).times(re[ir-1])));const Tt=Gd(()=>({baseResource:Mn(c),gainResource:ke,formula:Me=>Me.div(jt).pow(ra),spend(){c.value=0}}));re[le.value]=V.evaluate(),le.value+=2;const aa=Ae,rr=Sn(r),$i=g.variable(ke).pow(nr).add(1),sa=Re(()=>({multiplier:()=>$i.evaluate(),description:rr,enabled:()=>o.gt(ke.value,0)})),oa=Re(()=>({multiplier:()=>$i.evaluate(o.add(ke.value,Tt.actualGain.value))})),kn=Cd(()=>({display:{title:rr,description:X(()=>f("span",null,[E("Reset "),c.displayName,E(" for")," ",pi(ke,o.clampMin(Tt.actualGain.value,1))," ",ke.displayName,f("br",null,null),f("div",null,[E("Next:")," ",pi(c,o.lt(Tt.actualGain.value,1)?Tt.currentAt.value:Tt.nextAt.value)," ",c.displayName])]))},style:{width:"200px",minHeight:"100px"},canClick:()=>o.gte(Tt.actualGain.value,1),prestigeResource:ke,onClick:Tt.convert,visibility:aa})),{isHovering:la}=ee({feature:kn,canClick:()=>s(kn.canClick),modifier:sa,cost:jt,previewCost:c,previewModifier:oa}),ar=C(()=>la.value&&kn.canClick.value);H.push([kn]);const ua=dn(g.variable(ke),ar,Tt.actualGain),ca=dn($i,ar,Tt.actualGain);pe[q*2]=X(()=>f(te,null,[ze(kn.visibility)?f("div",{style:"margin: 10px"},[E("You have")," ",f("h2",{style:{color:ft,textShadow:`0px 0px 10px ${ft}`}},[ua()])," ",ke.displayName,E(","),f("br",null,null),E("providing a "),ca(),E("x multiplier to previous")," ",c.displayName,E(" gain")]):null,Ti(kn)])),Wd(this,Tt,()=>st.value.length<A&&w.investments.value!=null&&he(w.investments.value)&&w.investments.value.state.portals.includes(e)?.01:0);break;case"xp":{const Me=In(0),lt=Ae,gt=le.value,Qe=Sn(r),nt=o.add(m,r()-.5).pow_base(2).times(10),ut=r()/4+1.125,Se=r()/2+1.25,Pe=g.variable(0).pow(ut).times(nt),Ie=Zr(Pe,Me,!0,10,o.dInf),We=C(()=>En(Pe,Ie.value,!0,10)),De=C(()=>En(Pe,o.add(Ie.value,1),!0,10)),ce=C(()=>o.pow(Se,Ie.value)),He=Re(()=>({multiplier:ce,description:Qe,enabled:()=>ze(xe.visibility)}));V=V.add(C(()=>o.sub(le.value,gt).add(1).sqrt().times(3).pow(Se).times(re[gt-1]))),re[le.value]=V.evaluate(),le.value+=2;const Ze=On([.18,.2,.25],r),xe=zd(()=>({direction:U.Right,width:300,height:20,progress:()=>o.sub(Me.value,We.value).div(o.sub(De.value,We.value)).toNumber(),visibility:lt,xp:Me,display:X(()=>f("span",null,[we(Me.value),E("/"),we(De.value)])),fillStyle:`background-color: ${Ze}`}));this.on("preUpdate",Ei=>{if(st.value.length<A&&w.activePortals.value.some(_t=>_t.state.id===e)&&ze(xe.visibility)){const _t=o.times(qt.value,Ei);Me.value=o.add(_t,Me.value)}}),S.push(He),H.push([xe]),pe[q*2]=X(()=>f(te,null,[ze(xe.visibility)?f("div",{style:"margin: 10px"},[E("You have "),f("h3",null,[Qe]),E(" Lv. "),Mt(Ie.value),E(","),f("br",null,null),E("providing a "),we(ce.value),E("x multiplier to previous")," ",c.displayName,E(" gain"),f("br",null,null)]):null,Ti(xe)]));break}case"dimensions":{const Me=Sn(r),lt=In(0,Me+" energy"),gt=On([.64,.75,.55],r),Qe=le.value;V=V.add(C(()=>o.sub(le.value,Qe).add(1).pow_base(32).add(1).log2().add(1).times(re[Qe-1])));const nt=C(()=>o.add(lt.value,1).log2().add(1)),ut=Re(()=>({multiplier:nt,description:Me,enabled:()=>o.gt(lt.value,0)}));S.push(ut);const Se=Ae,Pe=[];for(let Ie=0;Ie<4;Ie++){const We=o.add(m,r()-.5).pow_base(2).times(10).recip(),De=Ge.value,ce=g.variable(C(()=>_t.amount.value)),He=ce.pow_base(o.pow10(Ie+1)).times(De),Ze=["First","Second","Third","Fourth"][Ie]+" "+Me+" Dimension",xe=In(0,Ze),Ei=ce.sub(1).pow_base(2).times(We).times(C(()=>o.add(_t.amount.value,xe.value))),_t=hr(()=>({display:{title:Ze,description:X(()=>f("div",null,[f("div",null,[E("Amount:")," ",we(o.add(xe.value,_t.amount.value))," ",E("["),Mt(_t.amount.value),E("]")])])),effectDisplay:X(()=>f("span",null,[fa()," ",Ie===0?lt.displayName:["First","Second","Third","Fourth"][Ie-1]+" "+Me+" Dimension",E("/s")])),showAmount:!1},style:{width:"400px"},effect:Ei,dimensions:xe,energy:Ie===0?lt:void 0,requirements:Rn(()=>({resource:Mn(c),cost:He})),visibility:Se}));Pe.push(_t);const da=mr(_t),sr=C(()=>s(_t.canClick)&&da.value),pa=new g({inputs:[ce],evaluate(or){return o.sub(or,1).pow_base(2).times(We).times(o.add(or,xe.value))}}),fa=dn(pa,sr);ie.push({shouldShowPreview:sr,cost:He});const ga=Fi(c,B,()=>Ne(He));Oi(_t,{display:ga,direction:U.Down}),re[le.value]=V.evaluate(),le.value++}this.on("preUpdate",Ie=>{if(st.value.length<A&&w.activePortals.value.some(We=>We.state.id===e)&&ze(Se)){const We=o.times(qt.value,Ie),De=Pe[0].effect.evaluate();lt.value=o.times(De,We).add(lt.value);for(let ce=1;ce<4;ce++){const He=Pe[ce].effect.evaluate();Pe[ce-1].dimensions.value=o.times(He,We).add(Pe[ce-1].dimensions.value)}}}),H.push(Pe),pe[q*2]=X(()=>f(te,null,[ze(Se)?f("div",{style:"margin: 10px"},[E("You have")," ",f("h2",{style:{color:gt,textShadow:`0px 0px 10px ${gt}`}},[we(lt.value)])," ",lt.displayName,E(","),f("br",null,null),E("providing a "),we(nt.value),E("x multiplier to previous")," ",c.displayName,E(" gain")]):null,Vs(...Pe)]));break}case"prestige":{const Me=Sn(r),lt=Ae,gt=r()/2+1.25,Qe=Ge.value;V=V.pow(gt);const nt=Ai(()=>({exponent:gt,description:Me,enabled:Se.bought}));re[le.value]=V.evaluate(),le.value++;const ut=Zd(()=>({thingsToReset:H.filter((Ie,We)=>We%2===0),onReset(){c.value=0}})),Se=br(()=>({display:{title:Me,description:`Reset all previous ${a} content to raise all previous ${c.displayName} gain to the ^${we(gt)}`},style:{width:"200px",minHeight:"100px"},onPurchase:ut.reset,visibility:lt,requirements:Rn(()=>({resource:Mn(c),cost:Qe}))})),Pe=Re(()=>({multiplier:0}));ee({feature:Se,canClick:()=>s(Se.canPurchase),modifier:nt,cost:Qe,previewCost:c,previewModifier:Pe,showETA:()=>!s(Se.bought)}),H.push([Se]);break}}const Fe={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(w.influenceNodes.value).length+Xt.length===Object.keys(Ct).length?0:"increaseInfluences"in h?20:2,relic:0};let Kt=ai(Fe,r);q===A-1&&"relic"in h&&(Kt="relic");let ot="",Vt,Bt,Lt,tt,Dt,$;switch(Kt){case"cache":tt=Vi(r,i),ot=`Gain ${we(o.div(I.value,12))}x your current ${tt}.`,Bt=()=>{var ke,ft,jt;return w.grantResource(tt,o.times((jt=(ft=(ke=w.resourceNodes.value[tt])==null?void 0:ke.state)==null?void 0:ft.amount)!=null?jt:0,o.div(I.value,12)))};break;case"generation":tt=Vi(r,i);const ue=o.div(I.value,40).times($t[tt]);ot=`Gain ${we(ue)} ${tt}/s while plane is active.`,Vt=ke=>w.grantResource(tt,o.times(ke,ue)),Lt=C(()=>w.resourceNodes.value[tt]);break;case"resourceMulti":Dt=tt=Vi(r,i),$=o.div(I.value,10).pow_base(2),ot=`Gain ${we($)}x ${tt} while plane is active.`;break;case"energyMulti":Dt="energy",$=o.div(I.value,8).add(1),ot=`Gain ${we($)}x energy while plane is active.`;break;case"influences":const xt=Object.keys(Ct)[Math.floor(r()*Object.keys(Ct).length)];Xt.push(xt),ot=`Gain a new portal influence (${Ct[xt].display})`,Bt=()=>{if(xt in w.influenceNodes.value){_r.warning(`Error: ignoring duplicate portal influence (${Ct[xt].display})`);return}const ke={id:Zn(w.board),position:{...w.board.types.portal.nodes.value.find(ft=>ft.state.id===e).position},type:"influence",state:{type:xt,data:Ct[xt].initialData}};w.board.placeInAvailableSpace(ke),w.board.nodes.value.push(ke)};break;case"relic":ot=t==="ultimatum"?"Win the game!":`Gain the ${t}-tier planar relic (${fi[t]})`,Bt=()=>{if(t==="ultimatum"){tr.value=!0;return}if(`${t}Relic`in w.toolNodes.value)_r.warning(`Error: ignoring duplicate relic (${fi[t]})`);else{const ke={id:Zn(w.board),position:{...w.board.types.portal.nodes.value.find(ft=>ft.state.id===e).position},type:"passive",state:`${t}Relic`};w.board.placeInAvailableSpace(ke),w.board.nodes.value.push(ke)}}}const T=Ae,O=Ge.value,G=Od(()=>({requirements:Rn(()=>({resource:Mn(c),cost:O})),visibility:T,display:{requirement:`${we(O)} ${c.displayName}`,effectDisplay:ot},style:"width: 100%",classes:{final:q===A-1},update:Vt,onComplete:Bt,link:Lt,effectedResource:Dt,resourceMulti:$})),be=Fi(c,B,O);Oi(G,{display:()=>G.earned.value?"":be.value,direction:U.Down}),H.push([G]),Ae=G.earned}const at=Wn(H,er),Kn=Wn(H,na),Qn=Nt(()=>[Re(()=>({multiplier:()=>{var q,L,Ce;return o.add((Ce=(L=(q=w.board.types.booster.nodes.value[0])==null?void 0:q.state)==null?void 0:L.level)!=null?Ce:0,1)},description:"Booster",enabled:()=>{var q,L,Ce;return(Ce=(L=(q=w.board.types.booster.nodes.value[0])==null?void 0:q.state)==null?void 0:L.portals.includes(e))!=null?Ce:!1}}))]),qt=C(()=>Qn.apply(1)),[ei,ti]=Ln(()=>[{title:`${et(c.displayName)} Gain`,modifier:P,base:0,unit:"/s"},{title:`${et(c.displayName)} Time Speed`,modifier:Qn,base:1,visible:()=>o.gt(qt.value,1)}]),Nn=z(!1),Jt=X(()=>f(Zt,{modelValue:Nn.value,"onUpdate:modelValue":q=>Nn.value=q},{header:()=>f("h2",null,[E("Modifiers")]),body:()=>rt(ei)}));this.on("preUpdate",q=>{if(!w.activePortals.value.some(Ce=>Ce.state.id===e))return;const L=o.times(qt.value,q);p.value=o.add(p.value,L),st.value.length<A&&(c.value=o.times(B.value,L).add(c.value)),st.value.forEach(Ce=>{var Fe;(Fe=Ce.update)==null||Fe.call(Ce,L)})}),Qd(this,()=>st.value.length<A&&w.upgrader.value!=null&&he(w.upgrader.value)&&w.upgrader.value.state.portals.includes(e),at),kd(this,()=>st.value.length<A&&w.automator.value!=null&&he(w.automator.value)&&w.automator.value.state.portals.includes(e),Kn);const Cn=C(()=>{const q=ie.find(L=>L.shouldShowPreview.value);return q?o.neg(Ne(q.cost)):0}),Fn=C(()=>{const q=ie.find(L=>L.shouldShowPreview.value);return q&&q.modifier?o.sub(q.modifier.apply(0),B.value):0}),ni=dn(g.variable(0).add(c),()=>o.neq(Cn.value,0),Cn),ki=dn(g.variable(0).add(B),()=>o.neq(Fn.value,0),Fn),Mi=C(()=>{const q=[];return st.value.forEach(L=>{L.link&&q.push(L.link)}),q}),Si=C(()=>{const q={};return st.value.forEach(L=>{L.effectedResource!=null&&L.resourceMulti!=null&&(q[L.effectedResource]!=null?q[L.effectedResource]=o.times(q[L.effectedResource],L.resourceMulti):q[L.effectedResource]=L.resourceMulti)}),q}),st=C(()=>{const q=[];for(let L=1;L<H.length;L+=2){const Ce=H[L][0];Ce.earned.value&&q.push(Ce)}return q}),Ii=C(()=>o.lt(st.value.length,A)&&H.some(q=>q.some(L=>"earned"in L&&s(L.earned)||"bought"in L&&s(L.bought)?!1:("canClick"in L&&s(L.canClick)||"canPurchase"in L&&s(L.canPurchase),!0)))),xi=C(()=>{const q=H.findIndex((Ce,Fe)=>Fe>0&&Fe%2===0&&!H[Fe-1][0].earned.value);let L;return q===-1?L=H:L=H.slice(0,q),L.map((Ce,Fe)=>Fe in pe?rt(pe[Fe]):Ti(...Ce))});return{tier:dt(t),seed:dt(n),influences:dt(i),name:a,color:l,resource:c,background:u,style:{background:u,"--background":u},features:H,resourceTabCollapsed:ti,links:Mi,resourceMultis:Si,earnedTreasures:st,showNotif:Ii,timeActive:p,bonusRewardsLevel:y,display:X(()=>f(te,null,[f(di,{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(Oe,{display:i.map(q=>{const L=Ct[q.type].description;return typeof L=="function"?L(q):L}).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:()=>Nn.value=!0},[E("modifiers")])])]}),f(di,{class:"nav-container"},{default:()=>[f("span",{class:"nav-segment"},[f("h3",{style:`color: ${l}; text-shadow: 0px 0px 10px ${l};`},[rt(ni)])," ",c.displayName]),f("span",{class:"nav-segment"},[E("("),f("h3",{style:`color: ${l}; text-shadow: 0px 0px 10px ${l};`},[o.gt(B.value,0)?"+":"",rt(ki)]),E("/s)")]),o.neq(qt.value,1)?f("span",{class:"nav-segment"},[E("Speed: "),we(qt.value),E("x")]):null]}),f(Ed,{height:"60px"},null),xi.value,rt(Jt)])),minimizedDisplay:X(()=>f("div",null,[f("span",null,[a]),f("span",{style:"font-size: large; vertical-align: sub;"},[" ",st.value.length,E("/"),A,E(" treasures")])]))}})}function Vi(e,t){t=t.filter(u=>u.type==="increaseResources"||u.type==="decreaseResources");const n=Object.keys($t).reduce((u,c)=>{let p=$t[c];return t.filter(v=>v.data===c).forEach(v=>{v.type==="increaseResources"?p*=1e3:p/=1e3}),u+p},0),i=Object.keys($t),r=Math.floor(e()*n);let a=0,l;for(let u=0;u<i.length;u++){const c=i[u];if(a+=$t[c],r<a){l=c;break}}return l}function ai(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 ap={shape:Ue.Diamond,size:50,title:"\u{1FAA8}",label:e=>e===w.board.selectedNode.value?{text:"Mining"}:Object.keys(w.resourceNodes.value).length===0?{text:"Click me!"}:null,actionDistance:Math.PI/4,actions:[Ot],progress:e=>he(e)?new o(e.state.progress).toNumber():0,progressDisplay:vn.Outline,progressColor:"var(--accent2)",classes:e=>({running:he(e)}),draggable:!0},sp={shape:Ue.Diamond,size:50,title:"\u{1F6E0}\uFE0F",label:e=>e===w.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(w.energy.value,100)&&(e.type="factory",w.energy.value=o.sub(w.energy.value,100))},confirmationLabel:()=>o.gte(w.energy.value,1e3)?{text:"Tap again to confirm"}:{text:"Cannot afford",color:"var(--danger)"}}],draggable:!0},op={shape:Ue.Diamond,size:50,title:"\u{1F6E0}\uFE0F",label:e=>{var t,n;if(e===w.board.selectedNode.value)return{text:e.state==null?"Forge - Drag a resource to me!":`Forging ${Be[e.state].name}`};if(((t=w.board.draggingNode.value)==null?void 0:t.type)==="resource"){const i=((n=w.board.draggingNode.value)==null?void 0:n.state).type,r=e.state===i?"Disconnect":Be[i].name,a=e.state===i||w.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,w.board.selectedAction.value=null,w.board.selectedNode.value=null},visibility:e=>e.state!=null},{id:"craft",icon:"done",tooltip:e=>({text:`Forge ${Be[e.state].name} - ${Ye(Be[e.state].cost)} energy`}),onClick(e){const t=Be[e.state];if(o.gte(w.energy.value,t.cost)&&w.toolNodes.value[e.state]==null){w.energy.value=o.sub(w.energy.value,t.cost);const n={id:Zn(w.board),position:{...e.position},type:t.type,state:"state"in t?t.state:void 0};w.board.placeInAvailableSpace(n),w.board.nodes.value.push(n),w.board.selectedAction.value=null,w.board.selectedNode.value=null,e.state=void 0}},fillColor:e=>o.gte(w.energy.value,Be[e.state].cost)&&w.toolNodes.value[e.state]==null?"var(--accent2)":"var(--danger)",visibility:e=>e.state!=null,confirmationLabel:e=>o.gte(w.energy.value,Be[e.state].cost)?w.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||w.toolNodes.value[e.state]!=null?0:o.div(o.sqrt(w.energy.value),o.sqrt(Be[e.state].cost)).clampMax(1).toNumber(),progressDisplay:vn.Fill,progressColor:e=>e.state!=null&&o.gte(w.energy.value,Be[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,w.board.selectedNode.value=e},draggable:!0},lp={shape:Ue.Circle,size:50,title:e=>et(e.state.type),subtitle:e=>Ye(e.state.amount),progress:e=>md(e.state.type),onClick(){},progressDisplay:vn.Outline,progressColor:"var(--accent3)",classes:e=>{var t;return{"affected-node":w.dowsing.value!=null&&he(w.dowsing.value)&&w.dowsing.value.state.resources.includes(e.state.type)||o.neq((t=w.planarMultis.value[e.state.type])!=null?t:1,1)}},draggable:!0},up={shape:Ue.Circle,size:50,title:e=>{const t=e.state;return t.includes("Relic")?fi[t.slice(0,-5)]:Be[t].name},label:e=>e===w.board.selectedNode.value?{text:$d[e.state].description(it(e.state))}:null,outlineColor:"var(--bought)",classes:e=>({"affected-node":it(e.state)}),draggable:!0},cp={shape:Ue.Diamond,size:50,title:"\u{1F962}",label:e=>e===w.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,w.computedBonusConnectionsModifier.value)})`}:Yr(e,t=>`Double ${t} odds`),actionDistance:Math.PI/4,actions:[hi,_n(e=>e.add(2).pow_base(100),16),Ot],classes:e=>({running:he(e)}),canAccept:Xr,onDrop:Jr,draggable:!0},dp={shape:Ue.Diamond,size:50,title:"\u26CF\uFE0F",label:e=>e===w.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,w.computedBonusConnectionsModifier.value)})`}:Yr(e,t=>`Gather ${bt(o.div(w.dropRates[t].computedModifier.value,100))} ${t}/s`),actionDistance:Math.PI/4,actions:[hi,_n(e=>e.add(2).pow_base(1e4),16),Ot],progress:e=>he(e)?o.eq(w.quarryProgressRequired.value,0)?0:new o(e.state.progress).div(w.quarryProgressRequired.value).toNumber():0,progressDisplay:vn.Outline,progressColor:"var(--accent2)",canAccept:Xr,onDrop:Jr,classes:e=>({running:he(e)}),draggable:!0},pp={shape:Ue.Diamond,size:50,title:"\u{1F50C}",label:e=>e===w.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,w.computedBonusConnectionsModifier.value)})`}:pd(e,t=>t.includes("Relic")?`Double ${fi[t.slice(0,-5)]}'s effect`:`Double ${Be[t].name}'s effect`),actionDistance:Math.PI/4,actions:[hi,_n(e=>e.add(3).pow_base(1e3),16),Ot],canAccept:fd,onDrop:gd,classes:e=>({running:he(e)}),draggable:!0},fp={shape:Ue.Diamond,size:50,title:"\u26E9\uFE0F",label:e=>{if(e===w.board.selectedNode.value)return{text:e.state.tier==null?"Portal Spawner - Drag a resource to me!":`Spawning ${e.state.tier}-tier portal`};const t=w.board.draggingNode.value;if((t==null?void 0:t.type)==="resource"){const n=t.state.type;return{text:e.state.tier===n?"Disconnect":`${et(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:[]},w.board.selectedAction.value=null,w.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 - ${Ye(w.computedPortalCost.value)} energy`}),fillColor:()=>o.gte(w.energy.value,w.computedPortalCost.value)?"var(--accent2)":"var(--danger)",confirmationLabel:()=>o.gte(w.energy.value,w.computedPortalCost.value)?{text:"Tap again to confirm"}:{text:"Cannot afford",color:"var(--danger)"},onClick(e){let t=0;for(;`portal-${t}`in ye;)t++;w.energy.value=o.sub(w.energy.value,w.computedPortalCost.value);const{tier:n,influences:i}=e.state;Xi(ia(`portal-${t}`,n,Math.floor(Math.random()*4294967296),i.map(a=>w.influenceNodes.value[a].state)),J);const r={id:Zn(w.board),position:{...e.position},type:"portal",state:{id:`portal-${t}`,powered:!1}};w.board.placeInAvailableSpace(r),w.board.nodes.value.push(r),w.board.selectedAction.value=null,w.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]}}w.board.selectedNode.value=e},draggable:!0},gp={shape:Ue.Diamond,size:50,title:"\u{1F300}",label:e=>e===w.board.selectedNode.value?{text:`Portal to ${ye[e.state.id].name}`,color:ye[e.state.id].color}:null,actionDistance:Math.PI/4,actions:[Ot],classes:e=>({running:he(e),showNotif:ye[e.state.id].showNotif.value,"affected-node":w.booster.value!=null&&he(w.booster.value)&&w.booster.value.state.portals.includes(e.state.id)}),outlineColor:e=>ye[e.state.id].background,draggable:!0},mp={shape:e=>e.state.type==="increaseResources"||e.state.type==="decreaseResources"?Ue.Diamond:Ue.Circle,size:50,title:e=>Ct[e.state.type].display,label:e=>{if(e===w.board.selectedNode.value){const n=e.state,i=Ct[n.type].description;return{text:typeof i=="function"?i(n):i}}const t=w.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 ${et(n)} odds`;else if(i==="decreaseResources")a=`Decrease ${et(n)} odds`;else return null;return{text:a,color:"var(--accent2)"}}return null},actionDistance:Math.PI/4,actions:[hi],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]},w.board.selectedNode.value=e)},outlineColor:"var(--danger)",draggable:!0},vp={shape:Ue.Diamond,size:50,title:"\u231B",label:e=>e===w.board.selectedNode.value?{text:e.state.portals.length===0?"Booster - Drag a portal to me!":`Boosting by ${Ye(o.add(1,e.state.level))}x (${e.state.portals.length}/${o.add(e.state.maxConnections,w.computedBonusConnectionsModifier.value)})`}:bi(e,t=>`Boost ${ye[t].name}'s speed`),actionDistance:Math.PI/4,actions:[{id:"deselect",icon:"close",tooltip:{text:"Disconnect portals"},onClick(e){e.state={...e.state,portals:[]},w.board.selectedAction.value=null,w.board.selectedNode.value=null},visibility:e=>{var t,n;return(n=(t=e.state)==null?void 0:t.portals.length)!=null?n:0>0}},_n(e=>e.add(6).pow_base(1e3)),{id:"increaseBoost",icon:"arrow_upward",tooltip(e){return{text:`Increase boost - ${Ye(Ri.evaluate(e.state.level))} energy`}},confirmationLabel(e){return o.gte(w.energy.value,Ri.evaluate(e.state.level))?{text:"Tap again to confirm"}:{text:"Cannot afford",color:"var(--danger)"}},onClick(e){const t=Ri.evaluate(e.state.level);o.gte(w.energy.value,t)&&(w.energy.value=o.sub(w.energy.value,t)),e.state={...e.state,level:o.add(e.state.level,1)},w.board.selectedAction.value=null}},Ot],canAccept:yi,onDrop:wi,classes:e=>({running:he(e)}),draggable:!0},hp={shape:Ue.Diamond,size:50,title:"\u{1F916}",label:e=>e===w.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,w.computedBonusConnectionsModifier.value)})`}:bi(e,t=>`Auto-buy ${ye[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:[]},w.board.selectedAction.value=null,w.board.selectedNode.value=null},visibility:e=>{var t,n;return(n=(t=e.state)==null?void 0:t.portals.length)!=null?n:0>0}},_n(e=>e.add(4).pow_base(1e6)),Ot],canAccept:yi,onDrop:wi,classes:e=>({running:he(e)}),draggable:!0},bp={shape:Ue.Diamond,size:50,title:"\u{1F9BE}",label:e=>e===w.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,w.computedBonusConnectionsModifier.value)})`}:bi(e,t=>`Auto-buy ${ye[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:[]},w.board.selectedAction.value=null,w.board.selectedNode.value=null},visibility:e=>{var t,n;return(n=(t=e.state)==null?void 0:t.portals.length)!=null?n:0>0}},_n(e=>e.add(4).pow_base(1e6)),Ot],canAccept:yi,onDrop:wi,classes:e=>({running:he(e)}),draggable:!0},yp={shape:Ue.Diamond,size:50,title:"\u{1F4B1}",label:e=>e===w.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,w.computedBonusConnectionsModifier.value)})`}:bi(e,t=>`Auto-buy ${ye[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:[]},w.board.selectedAction.value=null,w.board.selectedNode.value=null},visibility:e=>{var t,n;return(n=(t=e.state)==null?void 0:t.portals.length)!=null?n:0>0}},_n(e=>e.add(3).pow_base(1e8)),Ot],canAccept:yi,onDrop:wi,classes:e=>({running:he(e)}),draggable:!0},Nr=mi(),wp={mine:ap,brokenFactory:sp,factory:op,resource:lp,passive:up,dowsing:cp,quarry:dp,empowerer:pp,portalGenerator:fp,portal:gp,influence:mp,booster:vp,upgrader:hp,automator:bp,investments:yp},w=Yi("main",function(){const e=In(0,"energy"),t=C(()=>d.types.resource.nodes.value.reduce(($,T)=>($[T.state.type]=T,$),{})),n=C(()=>({...d.types.passive.nodes.value.reduce(($,T)=>($[T.state]=T,$),{}),sand:d.types.dowsing.nodes.value[0],wood:d.types.quarry.nodes.value[0],coal:d.types.empowerer.nodes.value[0],iron:d.types.portalGenerator.nodes.value[0],gold:d.types.booster.nodes.value[0],platinum:d.types.upgrader.nodes.value[0],berylium:d.types.automator.nodes.value[0],ultimatum:d.types.investments.nodes.value[0]})),i=C(()=>({...d.types.influence.nodes.value.reduce(($,T)=>($[T.state.type]=T,$),{})})),r=C(()=>({...d.types.portal.nodes.value.reduce(($,T)=>($[T.state.id]=T,$),{})})),a=C(()=>en.reduce(($,T)=>{var G,be,ue;const O=(ue=(be=(G=t.value[T])==null?void 0:G.state)==null?void 0:be.amount)!=null?ue:0;return $[T]=o.floor(Li.invert(O)),$},{})),l=mn({}),u=mn({});Wt(()=>{en.forEach($=>{vt(()=>a.value[$],(T,O)=>{const G=o.sub(T,O);o.gt(G,0)&&ae.active===J.id&&Nr.info(f("div",null,[f("h3",null,[o.eq(T,1)?`${et($)} discovered`:`${et($)} is now Level ${Mt(T)}`,E("!")]),o.gt(G,1)?f("div",null,[E("Gained "),Mt(G),E(" levels")]):null]))})})});const c=C(()=>pe.filter($=>{var T,O;return(O=(T=$.value)==null?void 0:T.state)==null?void 0:O.powered}).length+d.types.portal.nodes.value.filter($=>$.state.powered).length),p=C(()=>o.eq(c.value,0)?10:o.add(c.value,1).pow_base(100).div(10).times(.99)),v=C(()=>y.value==null?0:y.value.state.resources.reduce((T,O)=>o.div(100,Jt[O].computedModifier.value).add(T),o.dZero)),d=$u($=>({startNodes:()=>[{position:{x:0,y:0},type:"mine",state:{progress:0,powered:!1}},{position:{x:0,y:-200},type:"brokenFactory"}],types:wp,style:{position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden"},links(){const T=[];if(T.push(...Object.keys(l).map(O=>({startNode:h.value,endNode:t.value[O],stroke:"var(--accent3)",strokeWidth:5}))),m.value!=null&&m.value.state!=null&&T.push({startNode:m.value,endNode:t.value[m.value.state],stroke:"var(--foreground)",strokeWidth:4}),_.value!=null&&_.value.state.resources.forEach(O=>{T.push({startNode:_.value,endNode:t.value[O],stroke:he(_.value)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),y.value!=null&&y.value.state.resources.forEach(O=>{T.push({startNode:y.value,endNode:t.value[O],stroke:"var(--foreground)",strokeWidth:4})}),T.push(...Object.keys(u).map(O=>({startNode:y.value,endNode:t.value[O],stroke:"var(--accent3)",strokeWidth:5}))),I.value!=null&&I.value.state.tools.forEach(O=>{T.push({startNode:I.value,endNode:n.value[O],stroke:he(I.value)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),A.value!=null){const O=A.value.state;O.tier!=null&&T.push({startNode:A.value,endNode:t.value[O.tier],stroke:"var(--foreground)",strokeWidth:4}),O.influences.forEach(G=>{T.push({startNode:A.value,endNode:i.value[G],stroke:"var(--foreground)",strokeWidth:4})}),$.types.portal.nodes.value.forEach(G=>{const be=ye[G.state.id];return be.links.value.forEach(ue=>{ue.value!=null&&T.push({startNode:G,endNode:ue.value,stroke:he(G)?"var(--accent3)":"var(--foreground)",strokeWidth:4})}),Object.keys(be.resourceMultis.value).forEach(ue=>{ue!=="energy"&&ue in t.value&&T.push({startNode:G,endNode:t.value[ue],stroke:he(G)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),T})}return S.value!=null&&S.value.state.portals.forEach(O=>{T.push({startNode:S.value,endNode:r.value[O],stroke:he(S.value)?"var(--accent1)":"var(--foreground)",strokeWidth:4})}),P.value!=null&&P.value.state.portals.forEach(O=>{T.push({startNode:P.value,endNode:r.value[O],stroke:"var(--foreground)",strokeWidth:4})}),B.value!=null&&B.value.state.portals.forEach(O=>{T.push({startNode:B.value,endNode:r.value[O],stroke:"var(--foreground)",strokeWidth:4})}),ie.value!=null&&ie.value.state.portals.forEach(O=>{T.push({startNode:ie.value,endNode:r.value[O],stroke:"var(--foreground)",strokeWidth:4})}),Object.values(i.value).forEach(O=>{const G=O.state;(G.type==="increaseResources"||G.type==="decreaseResources")&&G.data.forEach(be=>{T.push({startNode:O,endNode:t.value[be],stroke:"var(--foreground)",strokeWidth:4})})}),T}})),h=C(()=>d.types.mine.nodes.value[0]),m=C(()=>d.types.factory.nodes.value[0]),_=C(()=>n.value.sand),y=C(()=>n.value.wood),I=C(()=>n.value.coal),A=C(()=>n.value.iron),S=C(()=>n.value.gold),P=C(()=>n.value.platinum),B=C(()=>n.value.berylium),ie=C(()=>n.value.ultimatum),pe=[h,_,y,I,S,P,B,ie];function ee($,T){let O=t.value[$];if(T=o.times(T,Cn[$].computedModifier.value),O==null)O={id:Zn(d),position:{...h.value.position},type:"resource",state:{type:$,amount:T}},d.placeInAvailableSpace(O),d.nodes.value.push(O);else{const G=O.state;O.state={...G,amount:o.add(G.amount,T)}}}const H=C(()=>Object.keys($t).reduce(($,T)=>$+new o(Jt[T].computedModifier.value).toNumber(),0)),le=C(()=>{const $={};return d.types.portal.nodes.value.forEach(T=>{if(!he(T))return;const G=ye[T.state.id].resourceMultis.value;Object.keys(G).forEach(be=>{$[be]!=null?$[be]=o.times($[be],G[be]):$[be]=G[be]})}),$}),V=Nt(()=>en.map($=>Ut(()=>({description:()=>et($),addend:()=>a.value[$],enabled:()=>o.gt(a.value[$],0)})))),re=C(()=>V.apply(0)),Ae=Nt(()=>[Ut(()=>({addend:re,description:"Resource Levels"})),Re(()=>({multiplier:()=>o.pow(Nn.value,re.value),description:()=>`${Gt(Nn.value,3)}x per Resource Level`})),Re(()=>({multiplier:()=>it("stone")?4:2,description:()=>(it("stone")?"Empowered ":"")+Be.stone.name,enabled:()=>n.value.stone!=null})),Re(()=>({multiplier:()=>{var $;return($=le.value.energy)!=null?$:1},description:"Planar Treasures",enabled:()=>{var $;return o.neq(($=le.value.energy)!=null?$:1,1)}})),Ut(()=>({addend:()=>o.pow(100,c.value).div(10).neg(),description:"Powered Machines (100^n/10 energy/s)",enabled:()=>o.gt(c.value,0)}))]),Ge=C(()=>Ae.apply(0)),Xt=Nt(()=>[Ut(()=>({addend:()=>it("unobtainium")?2:1,description:()=>(it("unobtainium")?"Empowered ":"")+Be.unobtainium.name,enabled:()=>n.value.unobtainium!=null}))]),at=C(()=>Xt.apply(0)),Kn=Nt(()=>[Re(()=>({multiplier:()=>it("dirt")?4:2,description:()=>(it("dirt")?"Empowered ":"")+Be.dirt.name,enabled:()=>n.value.dirt!=null}))]),Qn=C(()=>Kn.apply(1)),qt=Nt(()=>[Re(()=>({multiplier:()=>it("gravel")?4:2,description:()=>(it("gravel")?"Empowered ":"")+Be.gravel.name,enabled:()=>n.value.gravel!=null}))]),ei=C(()=>qt.apply(1)),ti=Nt(()=>[Ut(()=>({addend:()=>it("copper")?.002:.001,description:()=>(it("copper")?"Empowered ":"")+Be.copper.name,enabled:()=>n.value.copper!=null}))]),Nn=C(()=>ti.apply(1.01)),Jt=Object.keys($t).reduce(($,T)=>{const O=Nt(()=>[Re(()=>({multiplier:2,description:"Dowsing",enabled:()=>_.value!=null&&he(_.value)&&_.value.state.resources.includes(T)}))]),G=C(()=>O.apply($t[T])),be={title:`${et(T)} Drop Rate`,modifier:O,base:$t[T]};return $[T]={modifier:O,computedModifier:G,section:be},$},{}),Cn=Object.keys($t).reduce(($,T)=>{const O=Nt(()=>[Re(()=>({multiplier:()=>{var ue;return(ue=le.value[T])!=null?ue:1},description:"Planar Treasures",enabled:()=>{var ue;return o.neq((ue=le.value[T])!=null?ue:1,1)}}))]),G=C(()=>O.apply(1)),be={title:`${et(T)} Gain`,modifier:O};return $[T]={modifier:O,computedModifier:G,section:be},$},{}),Fn=C(()=>{var T,O,G;const $=en.indexOf((G=(O=(T=A.value)==null?void 0:T.state)==null?void 0:O.tier)!=null?G:"dirt");return o.add($,1).times($).div(2).add(9).pow10()}),ni=Nt(()=>Object.keys(Ct).map($=>Re(()=>({multiplier:Ct[$].cost,description:Ct[$].display,enabled:()=>{var T,O,G;return(G=(O=(T=A.value)==null?void 0:T.state)==null?void 0:O.influences.includes($))!=null?G:!1}})))),ki=C(()=>ni.apply(Fn.value)),[Mi,Si]=Ln(()=>[{title:"Resource Levels",modifier:V,base:0},{title:"Energy Gain",modifier:Ae,base:0,unit:"/s"},{title:"Portal Cost",modifier:ni,base:Fn,unit:" energy",baseText:()=>{var $,T,O;return`${et((O=(T=($=A.value)==null?void 0:$.state)==null?void 0:T.tier)!=null?O:"dirt")}-tier Base Cost`},visible:()=>A.value!=null},{title:"Bonus Connections",modifier:Xt,base:0,visible:()=>o.gt(at.value,0)}]),[st,Ii]=Ln(()=>[{title:"Mining Speed",modifier:Kn,base:1,unit:"/s",visible:()=>n.value.dirt!=null},{title:"Ore Dropped",modifier:qt,base:1,visible:()=>n.value.gravel!=null},{title:"Material Level Effect",modifier:ti,base:1.01,visible:()=>n.value.copper!=null}]),[xi,q]=Ln(()=>Object.values(Jt).map($=>$.section)),[L,Ce]=Ln(()=>Object.values(Cn).map($=>$.section)),Fe=qu({general:()=>({display:"General",glowColor(){return Fe.activeTab.value===this.tab?"white":""},tab:Mi,energyTabCollapsed:Si}),mining:()=>({display:"Mine",glowColor(){return Fe.activeTab.value===this.tab?"white":""},visibility:()=>Object.keys(n.value).length>0,tab:st,miningTabCollapsed:Ii}),resources:()=>({display:"Mine Rates",glowColor(){return Fe.activeTab.value===this.tab?"white":""},visibility:()=>_.value!=null,tab:xi,resourcesCollapsed:q}),resourcesGain:()=>({display:"Resource Gain",glowColor(){return Fe.activeTab.value===this.tab?"white":""},visibility:()=>Object.values(Cn).some($=>o.neq($.computedModifier.value,1)),tab:L,resourceGainCollapsed:Ce})}),Kt=z(!1),ot=X(()=>f(Zt,{modelValue:Kt.value,"onUpdate:modelValue":$=>Kt.value=$},{header:()=>f("h2",null,[E("Modifiers")]),body:()=>rt(Fe)}));this.on("preUpdate",$=>{if(Object.keys(l).forEach(T=>{l[T]-=$,l[T]<=0&&delete l[T]}),Object.keys(u).forEach(T=>{u[T]-=$,u[T]<=0&&delete u[T]}),he(h.value)){const T=o.add(h.value.state.progress,o.times(Qn.value,$)),O=T.floor();h.value.state={...h.value.state,progress:o.sub(T,O)};const G=O.div(H.value).floor();G.gt(0)&&en.forEach(ue=>{ee(ue,o.times(new o(Jt[ue].computedModifier.value).toNumber(),G).times(ei.value)),l[ue]=.3});const be=o.sub(O,G).toNumber();for(let ue=0;ue<be;ue++){const xt=Math.floor(Math.random()*H.value);let ke=0;for(let ft=0;ft<en.length;ft++){const jt=en[ft];if(ke+=new o(Jt[jt].computedModifier.value).toNumber(),xt<ke){ee(jt,ei.value),l[jt]=.3;break}}}}if(y.value!=null&&he(y.value)){const{progress:T,resources:O}=y.value.state;if(O.length>0){let G=o.add(T,$);const be=o.div(T,v.value).floor();G=o.sub(G,o.times(be,v.value)),y.value.state={...y.value.state,progress:G},o.gt(be,0)&&O.forEach(ue=>{ee(ue,be),u[ue]=.3})}}e.value=o.add(e.value,o.times(Ge.value,$)),o.lt(e.value,0)&&(e.value=0,h.value.state={...h.value.state,powered:!1},Nr.warning(f("div",null,[f("h3",null,[E("Ran out of energy!")]),f("div",null,[E("All machines have been turned off.")])])))});const Vt=C(()=>{var $,T;return d.selectedAction.value===d.types.brokenFactory.actions[0]?-100:d.selectedAction.value===d.types.factory.actions[1]?o.neg(Be[d.selectedNode.value.state].cost):(($=d.selectedAction.value)==null?void 0:$.id)==="moreConnections"?o.neg(d.selectedAction.value.formula.evaluate(((T=d.selectedNode.value)==null?void 0:T.state).maxConnections)):0}),Bt=dn(g.variable(0).add(e),()=>o.neq(Vt.value,0),Vt),Lt=C(()=>{var $;return d.selectedAction.value===Ot?(($=d.selectedNode.value)==null?void 0:$.state).powered?o.eq(c.value,1)?10:o.pow(100,c.value).div(10).times(.99):o.neg(p.value):0}),tt=dn(g.variable(0).add(Ge),()=>o.neq(Lt.value,0),Lt),Dt=C(()=>d.types.portal.nodes.value.filter($=>he($)));return vt(Dt,$=>{Wt(()=>{J.tabs=["main",...$.map(T=>T.state.id)]})}),vt(at,($,T)=>{o.lt($,T)&&(cn($,_,"resources"),cn($,y,"resources"),cn($,I,"tools"),cn($,S,"portals"),cn($,P,"portals"),cn($,B,"portals"),cn($,ie,"portals"))}),{name:"World",board:d,energy:e,modifierTabs:Fe,resourceNodes:t,toolNodes:n,influenceNodes:i,grantResource:ee,activePortals:Dt,isEmpowered:it,nextPowerCost:p,computedBonusConnectionsModifier:at,quarryProgressRequired:v,dropRates:Jt,dowsing:_,empowerer:I,booster:S,upgrader:P,automator:B,investments:ie,resourceLevels:a,planarMultis:le,computedPortalCost:ki,display:X(()=>f(te,null,[f(di,{class:"nav-container"},{default:()=>[f("span",{class:"nav-segment"},[f("h2",{style:"color: white; text-shadow: 0px 0px 10px white;"},[rt(Bt)])," ",E("energy")]),f("span",{class:"nav-segment"},[E("("),f("h3",{style:"color: white; text-shadow: 0px 0px 10px white;"},[o.gt(Ge.value,0)?"+":"",rt(tt)]),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);"},[Mt(c.value)])," ",E("machines powered")]):null,f("span",{class:"nav-segment"},[f("button",{class:"button",style:"display: inline",onClick:()=>Kt.value=!0},[E("modifiers")])]),J.devSpeed===0?f("span",{class:"nav-segment"},[E("Game Paused")]):J.devSpeed!=null&&J.devSpeed!==1?f("span",{class:"nav-segment"},[E("Dev Speed: "),we(J.devSpeed),E("x")]):null]}),rt(d),rt(ot)]))}}),_p=e=>{var i,r,a,l,u;const t=[w];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(ia(`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},tr=z(!1);function Np(e,t){}var Cp=Object.freeze(Object.defineProperty({__proto__:null,main:w,getInitialLayers:_p,hasWon:tr,fixOldSave:Np},Symbol.toStringTag,{value:"Module"}));const Jn=e=>(hn("data-v-4a50ce42"),e=e(),bn(),e),kp={class:"game-over-modal-header"},Mp=["src","alt"],Sp={class:"game-over-modal-title"},Ip=Jn(()=>N("h2",null,"Congratulations!",-1)),xp={key:0},$p=Jn(()=>N("br",null,null,-1)),Ep=Jn(()=>N("div",null," Please check the Discord to discuss the game or to check for new content updates! ",-1)),Pp=Jn(()=>N("br",null,null,-1)),Dp=["href"],Tp=Jn(()=>N("span",{class:"material-icons game-over-modal-discord"},"discord",-1)),Ap=Y({__name:"GameOverScreen",setup(e){const{title:t,logo:n,discordName:i,discordLink:r,versionNumber:a,versionTitle:l}=ge,u=C(()=>vi(J.timePlayed)),c=C(()=>tr.value&&!J.keepGoing),p=an(J,"autosave");function v(){J.keepGoing=!0}function d(){pn($n())}return(h,m)=>(M(),K(Zt,{"model-value":s(c)},{header:W(()=>[N("div",kp,[s(n)?(M(),D("img",{key:0,class:"game-over-modal-logo",src:s(n),alt:s(t)},null,8,Mp)):j("",!0),N("div",Sp,[Ip,N("h4",null,"You've beaten "+se(s(t))+" v"+se(s(a))+": "+se(s(l)),1)])])]),body:W(({shown:_})=>[_?(M(),D("div",xp,[N("div",null,"It took you "+se(s(u))+" to beat the game.",1),$p,Ep,Pp,N("div",null,[N("a",{href:s(r),class:"game-over-modal-discord-link"},[Tp,E(" "+se(s(i)),1)],8,Dp)]),f(zt,{title:"Autosave",modelValue:s(p),"onUpdate:modelValue":m[0]||(m[0]=y=>qe(p)?p.value=y:null)},null,8,["modelValue"])])):j("",!0)]),footer:W(()=>[N("div",{class:"game-over-footer"},[N("button",{onClick:v,class:"button"},"Keep Going"),N("button",{onClick:d,class:"button danger"},"Play Again")])]),_:1},8,["model-value"]))}});var Fp=de(Ap,[["__scopeId","data-v-4a50ce42"]]);const Ci=e=>(hn("data-v-2776d67d"),e=e(),bn(),e),Rp=Ci(()=>N("div",{class:"nan-modal-header"},[N("h2",null,"NaN value detected!")],-1)),Op={key:0},qp=Ci(()=>N("br",null,null,-1)),Vp=["href"],Bp=Ci(()=>N("span",{class:"material-icons nan-modal-discord"},"discord",-1)),Lp=Ci(()=>N("br",null,null,-1)),jp={class:"nan-footer"},zp=Y({__name:"NaNScreen",setup(e){const{discordName:t,discordLink:n}=ge,i=z(!0),r=z(!0),a=an(je,"hasNaN"),l=z(null);vt(a,h=>{h?(i.value=J.autosave,r.value=J.devSpeed===0):(J.autosave=i.value,J.devSpeed=r.value?0:null)});const u=C(()=>{var h;return(h=je.NaNPath)==null?void 0:h.join(".")}),c=C(()=>je.NaNPersistent!=null?je.NaNPersistent.value:null);function p(){je.NaNPersistent!=null&&(je.NaNPersistent.value=new o(0),je.hasNaN=!1)}function v(){je.NaNPersistent&&(je.NaNPersistent.value=new o(1),je.hasNaN=!1)}function d(){je.NaNPersistent&&(je.NaNPersistent.value=new o(NaN),je.hasNaN=!1)}return(h,m)=>(M(),D(te,null,[f(Zt,Ht({modelValue:s(a),"onUpdate:modelValue":m[4]||(m[4]=_=>qe(a)?a.value=_:null)},h.$attrs),{header:W(()=>[Rp]),body:W(()=>[N("div",null,[E(' Attempted to assign "'+se(s(u))+'" to NaN',1),s(c)?(M(),D("span",Op,se(" ")+"(previously "+se(s(we)(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)]),qp,N("div",null,[N("a",{href:s(n)||"https://discord.gg/yJ4fjnjU54",class:"nan-modal-discord-link"},[Bp,E(" "+se(s(t)||"The Paper Pilot Community"),1)],8,Vp)]),Lp,f(zt,{title:"Autosave",modelValue:i.value,"onUpdate:modelValue":m[0]||(m[0]=_=>i.value=_)},null,8,["modelValue"]),s(ge).enablePausing?(M(),K(zt,{key:0,title:"Pause game",modelValue:r.value,"onUpdate:modelValue":m[1]||(m[1]=_=>r.value=_)},null,8,["modelValue"])):j("",!0)]),footer:W(()=>[N("div",jp,[N("button",{onClick:m[2]||(m[2]=_=>{var y;return(y=l.value)==null?void 0:y.open()}),class:"button"},"Open Saves Manager"),N("button",{onClick:p,class:"button"},"Set to 0"),N("button",{onClick:v,class:"button"},"Set to 1"),s(c)&&s(o).neq(s(c),0)&&s(o).neq(s(c),1)?(M(),D("button",{key:0,onClick:m[3]||(m[3]=_=>a.value=!1),class:"button"}," Set to previous ")):j("",!0),N("button",{onClick:d,class:"button danger"},"Ignore")])]),_:1},16,["modelValue"]),f(zr,{ref_key:"savesManager",ref:l},null,512)],64))}});var Up=de(zp,[["__scopeId","data-v-2776d67d"]]);const Gp={key:0,class:"tpsDisplay"},Wp=Y({__name:"TPS",setup(e){const t=C(()=>o.div(je.lastTenTicks.length,je.lastTenTicks.reduce((n,i)=>n+i,0)));return(n,i)=>s(t).isNan()?j("",!0):(M(),D("div",Gp,"TPS: "+se(s(Mt)(s(t))),1))}});var Hp=de(Wp,[["__scopeId","data-v-89b89152"]]);var Zp=Y({__name:"App",setup(e){const t=ge.useHeader,n=C(()=>kt[ae.theme].variables),i=an(ae,"showTPS"),r=C(()=>oe(X(()=>f(te,null,[As.map(rt)]))));return(a,l)=>(M(),D(te,null,[N("div",{id:"modal-root",style:Le(s(n))},null,4),N("div",{class:ve(["app",{useHeader:s(t)}]),style:Le(s(n))},[s(t)?(M(),K(Ur,{key:0})):j("",!0),f(Jl),s(s(i))?(M(),K(Hp,{key:1})):j("",!0),f(Fp),f(Up),(M(),K(Xe(s(r))))],6)],64))}});var Yp=de(Zp,[["__scopeId","data-v-41d15e5e"]]);function Xp(e={}){const{immediate:t=!1,onNeedRefresh:n,onOfflineReady:i,onRegistered:r,onRegisteredSW:a,onRegisterError:l}=e;let u,c,p,v;const d=async(m=!0)=>{await p,m&&(u==null||u.addEventListener("controlling",_=>{_.isUpdate&&window.location.reload()})),await(v==null?void 0:v())};async function h(){if("serviceWorker"in navigator){const{Workbox:m,messageSW:_}=await zn(()=>import("./workbox-window.4a8794bb.js"),[]);v=async()=>{c&&c.waiting&&await _(c.waiting,{type:"SKIP_WAITING"})},u=new m("./sw.js",{scope:"./",type:"classic"}),u.addEventListener("activated",y=>{y.isUpdate||i==null||i()});{const y=()=>{n==null||n()};u.addEventListener("waiting",y),u.addEventListener("externalwaiting",y)}u.register({immediate:t}).then(y=>{c=y,a?a("./sw.js",y):r==null||r(y)}).catch(y=>{l==null||l(y)})}}return p=h(),d}function Jp(e={}){const{immediate:t=!0,onNeedRefresh:n,onOfflineReady:i,onRegistered:r,onRegisteredSW:a,onRegisterError:l}=e,u=z(!1),c=z(!1);return{updateServiceWorker:Xp({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=ge.title;window.projInfo=ge;if(ge.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 xs();const{globalBus:e}=await zn(()=>Promise.resolve().then(function(){return Ss}),void 0),{startGameLoop:t}=await zn(()=>import("./gameLoop.b6cb677f.js"),["assets/gameLoop.b6cb677f.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=Ca(Yp);e.emit("setupVue",n),n.mount("#app"),Wt(()=>{const i=mi(),{updateServiceWorker:r}=Jp({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 _,je as a,ge as b,Cp as c,Je as g,$s as l,J as p,ae as s};
|