diff --git a/.eslintrc.json b/.eslintrc.json index d0a9695e..a75770d3 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,7 +3,7 @@ "eslint:recommended", "prettier", "plugin:jsdoc/recommended-typescript", - "plugin:@typescript-eslint/recommended" + "plugin:@typescript-eslint/strict-type-checked" ], "env": { "node": true, @@ -12,7 +12,8 @@ }, "parserOptions": { "sourceType": "module", - "ecmaVersion": "latest" + "ecmaVersion": "latest", + "project": "./tsconfig.json" }, "parser": "@typescript-eslint/parser", "rules": { @@ -53,6 +54,8 @@ "@typescript-eslint/no-explicit-any": "warn", "@typescript-eslint/ban-ts-comment": "warn", "@typescript-eslint/member-delimiter-style": "warn", + "@typescript-eslint/explicit-function-return-type": "warn", + "@typescript-eslint/restrict-template-expressions": ["warn", { "allowNumber": true, "allowBoolean": true }], "jsdoc/require-param-type": "off", "jsdoc/require-returns-type": "off", diff --git a/dist/game/eMath.game.js b/dist/game/eMath.game.js index d1b45699..6d444183 100644 --- a/dist/game/eMath.game.js +++ b/dist/game/eMath.game.js @@ -1481,7 +1481,7 @@ function decimalFormatGenerator(Decimal2) { default: if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); - return neg + FORMATS2[type]?.format(ex, acc, max); + return neg + FORMATS2[type].format(ex, acc, max); } } function formatGain(amt, gain, type = "mixed_sc", acc, max) { @@ -1611,7 +1611,7 @@ function decimalFormatGenerator(Decimal2) { output = abbMax["name"]; break; case 2: - output = `${num.divide(abbMax["value"]).format()}`; + output = num.divide(abbMax["value"]).format(); break; case 3: output = abbMax["altName"]; @@ -5510,7 +5510,7 @@ var Boost = class { * @alias setBoost * @deprecated Use {@link setBoost} instead. */ - this.addBoost = this.setBoost; + this.addBoost = this.setBoost.bind(this); boosts = boosts ? Array.isArray(boosts) ? boosts : [boosts] : void 0; this.baseEffect = E(baseEffect); this.boostArray = []; @@ -5810,7 +5810,7 @@ var UpgradeStatic = class _UpgradeStatic { } getCached(type, start, end) { if (type === "sum") { - return this.cache.get(upgradeToCacheNameSum(start, end)); + return this.cache.get(upgradeToCacheNameSum(start, end ?? E(0))); } else { return this.cache.get(upgradeToCacheNameEL(start)); } @@ -5893,7 +5893,6 @@ var CurrencyStatic = class { }; if (upgrades) this.addUpgrade(upgrades); - this.upgrades = this.upgrades; } /** * Updates / applies effects to the currency on load. @@ -6216,7 +6215,7 @@ var KeyManager = class _KeyManager { */ constructor(config) { /** @deprecated Use {@link addKey} instead. */ - this.addKeys = this.addKey; + this.addKeys = this.addKey.bind(this); this.keysPressed = []; this.binds = []; this.tickers = []; @@ -6369,7 +6368,7 @@ var EventManager = class _EventManager { * @deprecated Use {@link EventManager.setEvent} instead. * @alias eventManager.setEvent */ - this.addEvent = this.setEvent; + this.addEvent = this.setEvent.bind(this); this.config = _EventManager.configManager.parse(config); this.events = {}; if (this.config.autoAddInterval) { @@ -6395,18 +6394,27 @@ var EventManager = class _EventManager { tickerFunction() { const currentTime = Date.now(); for (const event of Object.values(this.events)) { - if (event.type === "interval") { - if (currentTime - event.intervalLast >= event.delay) { - const dt = currentTime - event.intervalLast; - event.callbackFn(dt); - event.intervalLast = currentTime; - } - } else if (event.type === "timeout") { - const dt = currentTime - event.timeCreated; - if (currentTime - event.timeCreated >= event.delay) { - event.callbackFn(dt); - delete this.events[event.name]; - } + switch (event.type) { + case "interval" /* interval */: + { + if (currentTime - event.intervalLast >= event.delay) { + const dt = currentTime - event.intervalLast; + event.callbackFn(dt); + event.intervalLast = currentTime; + } + } + ; + break; + case "timeout" /* timeout */: + { + const dt = currentTime - event.timeCreated; + if (currentTime - event.timeCreated >= event.delay) { + event.callbackFn(dt); + delete this.events[event.name]; + } + } + ; + break; } } } @@ -6431,11 +6439,19 @@ var EventManager = class _EventManager { */ timeWarp(dt) { for (const event of Object.values(this.events)) { - if (event.type === "interval") { - event.intervalLast -= dt; - } - if (event.type === "timeout") { - event.timeCreated -= dt; + switch (event.type) { + case "interval" /* interval */: + { + event.intervalLast -= dt; + } + ; + break; + case "timeout" /* timeout */: + { + event.timeCreated -= dt; + } + ; + break; } } } @@ -6643,7 +6659,7 @@ var DataManager = class { * @param data - The data to decompile. If not provided, it will be fetched from localStorage using the key `${game.config.name.id}-data`. * @returns The decompiled object, or null if the data is empty or invalid. */ - decompileData(data = window?.localStorage.getItem(`${this.gameRef.config.name.id}-data`)) { + decompileData(data = window.localStorage.getItem(`${this.gameRef.config.name.id}-data`)) { if (!data) return null; let parsedData; @@ -6683,7 +6699,7 @@ var DataManager = class { this.data = this.normalData; this.saveData(); if (reload) - window?.location.reload(); + window.location.reload(); } /** * Saves the game data to local storage under the key `${game.config.name.id}-data`. @@ -6722,7 +6738,7 @@ var DataManager = class { * @returns The loaded data. */ parseData(dataToParse = this.decompileData(), mergeData = true) { - if (mergeData && (!this.normalData || !this.normalDataPlain)) + if ((!this.normalData || !this.normalDataPlain) && mergeData) throw new Error("dataManager.parseData(): You must call init() before writing to data."); if (!dataToParse) return null; @@ -6744,7 +6760,7 @@ var DataManager = class { const upgrades = targetCurrency.upgrades; targetCurrency.upgrades = {}; for (const upgrade of upgrades) { - targetCurrency.upgrades[upgrade.id] = upgrade.level; + targetCurrency.upgrades[upgrade.id] = upgrade; } } targetCurrency.upgrades = { ...sourceCurrency.upgrades, ...targetCurrency.upgrades }; @@ -6837,7 +6853,7 @@ var GameCurrency = class { this.staticPointer = typeof staticPointer === "function" ? staticPointer : () => staticPointer; this.game = gamePointer; this.name = name; - this.game?.dataManager.addEventOnLoad(() => { + this.game.dataManager.addEventOnLoad(() => { this.static.onLoadData(); }); } @@ -6910,7 +6926,7 @@ var GameReset = class { currency.static.reset(); }); this.extender.forEach((extender) => { - if (extender && extender.id !== this.id) { + if (extender.id !== this.id) { extender.reset(); } }); diff --git a/dist/game/eMath.game.min.js b/dist/game/eMath.game.min.js index 831c2d14..c6f1c4b3 100644 --- a/dist/game/eMath.game.min.js +++ b/dist/game/eMath.game.min.js @@ -1,4 +1,4 @@ -"use strict";(function(At,ot){var Ct=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],ot);else if(typeof module=="object"&&module.exports)module.exports=ot();else{var lt=ot(),Et=Ct?exports:At;for(var Ot in lt)Et[Ot]=lt[Ot]}})(typeof self<"u"?self:exports,()=>{var At={},ot={exports:At},Ct=Object.create,lt=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Ot=Object.getOwnPropertyNames,Ue=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty,bt=(t,e)=>function(){return e||(0,t[Ot(t)[0]])((e={exports:{}}).exports,e),e.exports},Dt=(t,e)=>{for(var r in e)lt(t,r,{get:e[r],enumerable:!0})},Kt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ot(e))!$e.call(t,n)&&n!==r&<(t,n,{get:()=>e[n],enumerable:!(i=Et(e,n))||i.enumerable});return t},at=(t,e,r)=>(r=t!=null?Ct(Ue(t)):{},Kt(e||!t||!t.__esModule?lt(r,"default",{value:t,enumerable:!0}):r,t)),ze=t=>Kt(lt({},"__esModule",{value:!0}),t),ft=(t,e,r,i)=>{for(var n=i>1?void 0:i?Et(e,r):e,s=t.length-1,h;s>=0;s--)(h=t[s])&&(n=(i?h(e,r,n):h(n))||n);return i&&n&<(e,r,n),n},ct=bt({"node_modules/reflect-metadata/Reflect.js"(){var t;(function(e){(function(r){var i=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:d(),n=s(e);typeof i.Reflect<"u"&&(n=s(i.Reflect,n)),r(n,i),typeof i.Reflect>"u"&&(i.Reflect=e);function s(f,y){return function(l,u){Object.defineProperty(f,l,{configurable:!0,writable:!0,value:u}),y&&y(l,u)}}function h(){try{return Function("return this;")()}catch{}}function v(){try{return(0,eval)("(function() { return this; })()")}catch{}}function d(){return h()||v()}})(function(r,i){var n=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",h=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",v=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",d=typeof Object.create=="function",f={__proto__:[]}instanceof Array,y=!d&&!f,l={create:d?function(){return Qt(Object.create(null))}:f?function(){return Qt({__proto__:null})}:function(){return Qt({})},has:y?function(m,b){return n.call(m,b)}:function(m,b){return b in m},get:y?function(m,b){return n.call(m,b)?m[b]:void 0}:function(m,b){return m[b]}},u=Object.getPrototypeOf(Function),c=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Lr(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Pr(),w=typeof WeakMap=="function"?WeakMap:qr(),I=s?Symbol.for("@reflect-metadata:registry"):void 0,k=Fr(),F=xr(k);function o(m,b,O,C){if(j(O)){if(!Te(m))throw new TypeError;if(!Fe(b))throw new TypeError;return tt(m,b)}else{if(!Te(m))throw new TypeError;if(!J(b))throw new TypeError;if(!J(C)&&!j(C)&&!_t(C))throw new TypeError;return _t(C)&&(C=void 0),O=ut(O),nt(m,b,O,C)}}r("decorate",o);function S(m,b){function O(C,R){if(!J(C))throw new TypeError;if(!j(R)&&!Er(R))throw new TypeError;Pt(m,b,C,R)}return O}r("metadata",S);function g(m,b,O,C){if(!J(O))throw new TypeError;return j(C)||(C=ut(C)),Pt(m,b,O,C)}r("defineMetadata",g);function A(m,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),W(m,b,O)}r("hasMetadata",A);function _(m,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),Z(m,b,O)}r("hasOwnMetadata",_);function M(m,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),X(m,b,O)}r("getMetadata",M);function E(m,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),dt(m,b,O)}r("getOwnMetadata",E);function T(m,b){if(!J(m))throw new TypeError;return j(b)||(b=ut(b)),qt(m,b)}r("getMetadataKeys",T);function G(m,b){if(!J(m))throw new TypeError;return j(b)||(b=ut(b)),Bt(m,b)}r("getOwnMetadataKeys",G);function H(m,b,O){if(!J(b))throw new TypeError;if(j(O)||(O=ut(O)),!J(b))throw new TypeError;j(O)||(O=ut(O));var C=It(b,O,!1);return j(C)?!1:C.OrdinaryDeleteMetadata(m,b,O)}r("deleteMetadata",H);function tt(m,b){for(var O=m.length-1;O>=0;--O){var C=m[O],R=C(b);if(!j(R)&&!_t(R)){if(!Fe(R))throw new TypeError;b=R}}return b}function nt(m,b,O,C){for(var R=m.length-1;R>=0;--R){var Q=m[R],et=Q(b,O,C);if(!j(et)&&!_t(et)){if(!J(et))throw new TypeError;C=et}}return C}function W(m,b,O){var C=Z(m,b,O);if(C)return!0;var R=Jt(b);return _t(R)?!1:W(m,R,O)}function Z(m,b,O){var C=It(b,O,!1);return j(C)?!1:Ee(C.OrdinaryHasOwnMetadata(m,b,O))}function X(m,b,O){var C=Z(m,b,O);if(C)return dt(m,b,O);var R=Jt(b);if(!_t(R))return X(m,R,O)}function dt(m,b,O){var C=It(b,O,!1);if(!j(C))return C.OrdinaryGetOwnMetadata(m,b,O)}function Pt(m,b,O,C){var R=It(O,C,!0);R.OrdinaryDefineOwnMetadata(m,b,O,C)}function qt(m,b){var O=Bt(m,b),C=Jt(m);if(C===null)return O;var R=qt(C,b);if(R.length<=0)return O;if(O.length<=0)return R;for(var Q=new p,et=[],$=0,x=O;$=0&&x=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:L,done:!1}}return{value:void 0,done:!0}},$.prototype.throw=function(x){throw this._index>=0&&(this._index=-1,this._keys=b,this._values=b),x},$.prototype.return=function(x){return this._index>=0&&(this._index=-1,this._keys=b,this._values=b),{value:x,done:!0}},$}(),C=function(){function $(){this._keys=[],this._values=[],this._cacheKey=m,this._cacheIndex=-2}return Object.defineProperty($.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),$.prototype.has=function(x){return this._find(x,!1)>=0},$.prototype.get=function(x){var L=this._find(x,!1);return L>=0?this._values[L]:void 0},$.prototype.set=function(x,L){var q=this._find(x,!0);return this._values[q]=L,this},$.prototype.delete=function(x){var L=this._find(x,!1);if(L>=0){for(var q=this._keys.length,B=L+1;B>>8,l[u*2+1]=p%256}return l},decompressFromUint8Array:function(f){if(f==null)return d.decompress(f);for(var y=new Array(f.length/2),l=0,u=y.length;l>1}else{for(c=1,u=0;u>1}o--,o==0&&(o=Math.pow(2,g),g++),delete w[F]}else for(c=p[F],u=0;u>1;o--,o==0&&(o=Math.pow(2,g),g++),p[k]=S++,F=String(I)}if(F!==""){if(Object.prototype.hasOwnProperty.call(w,F)){if(F.charCodeAt(0)<256){for(u=0;u>1}else{for(c=1,u=0;u>1}o--,o==0&&(o=Math.pow(2,g),g++),delete w[F]}else for(c=p[F],u=0;u>1;o--,o==0&&(o=Math.pow(2,g),g++)}for(c=2,u=0;u>1;for(;;)if(_=_<<1,M==y-1){A.push(l(_));break}else M++;return A.join("")},decompress:function(f){return f==null?"":f==""?null:d._decompress(f.length,32768,function(y){return f.charCodeAt(y)})},_decompress:function(f,y,l){var u=[],c,p=4,w=4,I=3,k="",F=[],o,S,g,A,_,M,E,T={val:l(0),position:y,index:1};for(o=0;o<3;o+=1)u[o]=o;for(g=0,_=Math.pow(2,2),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),g|=(A>0?1:0)*M,M<<=1;switch(c=g){case 0:for(g=0,_=Math.pow(2,8),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),g|=(A>0?1:0)*M,M<<=1;E=i(g);break;case 1:for(g=0,_=Math.pow(2,16),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),g|=(A>0?1:0)*M,M<<=1;E=i(g);break;case 2:return""}for(u[3]=E,S=E,F.push(E);;){if(T.index>f)return"";for(g=0,_=Math.pow(2,I),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),g|=(A>0?1:0)*M,M<<=1;switch(E=g){case 0:for(g=0,_=Math.pow(2,8),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),g|=(A>0?1:0)*M,M<<=1;u[w++]=i(g),E=w-1,p--;break;case 1:for(g=0,_=Math.pow(2,16),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=l(T.index++)),g|=(A>0?1:0)*M,M<<=1;u[w++]=i(g),E=w-1,p--;break;case 2:return F.join("")}if(p==0&&(p=Math.pow(2,I),I++),u[E])k=u[E];else if(E===w)k=S+S.charAt(0);else return null;F.push(k),u[w++]=S+k.charAt(0),p--,S=k,p==0&&(p=Math.pow(2,I),I++)}}};return d}();typeof define=="function"&&define.amd?define(function(){return r}):typeof e<"u"&&e!=null?e.exports=r:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return r})}}),Ze=bt({"node_modules/crypt/crypt.js"(t,e){(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i={rotl:function(n,s){return n<>>32-s},rotr:function(n,s){return n<<32-s|n>>>s},endian:function(n){if(n.constructor==Number)return i.rotl(n,8)&16711935|i.rotl(n,24)&4278255360;for(var s=0;s0;n--)s.push(Math.floor(Math.random()*256));return s},bytesToWords:function(n){for(var s=[],h=0,v=0;h>>5]|=n[h]<<24-v%32;return s},wordsToBytes:function(n){for(var s=[],h=0;h>>5]>>>24-h%32&255);return s},bytesToHex:function(n){for(var s=[],h=0;h>>4).toString(16)),s.push((n[h]&15).toString(16));return s.join("")},hexToBytes:function(n){for(var s=[],h=0;h>>6*(3-d)&63)):s.push("=");return s.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var s=[],h=0,v=0;h>>6-v*2);return s}};e.exports=i})()}}),te=bt({"node_modules/charenc/charenc.js"(t,e){var r={utf8:{stringToBytes:function(i){return r.bin.stringToBytes(unescape(encodeURIComponent(i)))},bytesToString:function(i){return decodeURIComponent(escape(r.bin.bytesToString(i)))}},bin:{stringToBytes:function(i){for(var n=[],s=0;s>>24)&16711935|(f[w]<<24|f[w]>>>8)&4278255360;f[y>>>5]|=128<>>9<<4)+14]=y;for(var I=h._ff,k=h._gg,F=h._hh,o=h._ii,w=0;w>>0,u=u+g>>>0,c=c+A>>>0,p=p+_>>>0}return r.endian([l,u,c,p])};h._ff=function(v,d,f,y,l,u,c){var p=v+(d&f|~d&y)+(l>>>0)+c;return(p<>>32-u)+d},h._gg=function(v,d,f,y,l,u,c){var p=v+(d&y|f&~y)+(l>>>0)+c;return(p<>>32-u)+d},h._hh=function(v,d,f,y,l,u,c){var p=v+(d^f^y)+(l>>>0)+c;return(p<>>32-u)+d},h._ii=function(v,d,f,y,l,u,c){var p=v+(f^(d|~y))+(l>>>0)+c;return(p<>>32-u)+d},h._blocksize=16,h._digestsize=16,e.exports=function(v,d){if(v==null)throw new Error("Illegal argument "+v);var f=r.wordsToBytes(h(v,d));return d&&d.asBytes?f:d&&d.asString?s.bytesToString(f):r.bytesToHex(f)}})()}}),ee={};Dt(ee,{eMath:()=>_r}),ot.exports=ze(ee);var Rr=at(ct()),jr=at(ct()),re={};Dt(re,{Attribute:()=>Lt,AttributeStatic:()=>pe,Boost:()=>$t,BoostObject:()=>Nt,Currency:()=>yt,CurrencyStatic:()=>ge,DEFAULT_ITERATIONS:()=>xt,E:()=>P,FORMATS:()=>pr,FormatTypeList:()=>er,Grid:()=>yr,GridCell:()=>ve,LRUCache:()=>Rt,ListNode:()=>ie,UpgradeData:()=>vt,UpgradeStatic:()=>me,calculateSum:()=>Yt,calculateSumApprox:()=>he,calculateSumLoop:()=>ce,calculateUpgrade:()=>Zt,decimalToJSONString:()=>kt,inverseFunctionApprox:()=>zt,roundingBase:()=>vr,upgradeToCacheNameEL:()=>Ht});var Gr=at(ct()),Rt=class{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){let e=this.map.get(t);if(e!==void 0)return e!==this.first&&(e===this.last?(this.last=e.prev,this.last.next=void 0):(e.prev.next=e.next,e.next.prev=e.prev),e.next=this.first,this.first.prev=e,this.first=e),e.value}set(t,e){if(this.maxSize<1)return;if(this.map.has(t))throw new Error("Cannot update existing keys in the cache");let r=new ie(t,e);for(this.first===void 0?(this.first=r,this.last=r):(r.next=this.first,this.first.prev=r,this.first=r),this.map.set(t,r);this.map.size>this.maxSize;){let i=this.last;this.map.delete(i.key),this.last=i.prev,this.last.next=void 0}}},ie=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},U;(function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(U||(U={}));var We=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},t.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.findTransformMetadatas=function(e,r,i){return this.findMetadatas(this._transformMetadatas,e,r).filter(function(n){return!n.options||n.options.toClassOnly===!0&&n.options.toPlainOnly===!0?!0:n.options.toClassOnly===!0?i===U.CLASS_TO_CLASS||i===U.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?i===U.CLASS_TO_PLAIN:!0})},t.prototype.findExcludeMetadata=function(e,r){return this.findMetadata(this._excludeMetadatas,e,r)},t.prototype.findExposeMetadata=function(e,r){return this.findMetadata(this._exposeMetadatas,e,r)},t.prototype.findExposeMetadataByCustomName=function(e,r){return this.getExposedMetadatas(e).find(function(i){return i.options&&i.options.name===r})},t.prototype.findTypeMetadata=function(e,r){return this.findMetadata(this._typeMetadatas,e,r)},t.prototype.getStrategy=function(e){var r=this._excludeMetadatas.get(e),i=r&&r.get(void 0),n=this._exposeMetadatas.get(e),s=n&&n.get(void 0);return i&&s||!i&&!s?"none":i?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},t.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},t.prototype.getExposedProperties=function(e,r){return this.getExposedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===U.CLASS_TO_CLASS||r===U.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===U.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.getExcludedProperties=function(e,r){return this.getExcludedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===U.CLASS_TO_CLASS||r===U.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===U.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(e,r){var i=e.get(r),n;i&&(n=Array.from(i.values()).filter(function(l){return l.propertyName!==void 0}));for(var s=[],h=0,v=this.getAncestors(r);h0&&(h=h.filter(function(l){return!f.includes(l)})),this.options.version!==void 0&&(h=h.filter(function(l){var u=rt.findExposeMetadata(e,l);return!u||!u.options?!0:n.checkVersion(u.options.since,u.options.until)})),this.options.groups&&this.options.groups.length?h=h.filter(function(l){var u=rt.findExposeMetadata(e,l);return!u||!u.options?!0:n.checkGroups(u.options.groups)}):h=h.filter(function(l){var u=rt.findExposeMetadata(e,l);return!u||!u.options||!u.options.groups||!u.options.groups.length})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(h=h.filter(function(y){return n.options.excludePrefixes.every(function(l){return y.substr(0,l.length)!==l})})),h=h.filter(function(y,l,u){return u.indexOf(y)===l}),h},t.prototype.checkVersion=function(e,r){var i=!0;return i&&e&&(i=this.options.version>=e),i&&r&&(i=this.options.versionNumber.MAX_SAFE_INTEGER)&&(A="\u03C9");let M=t.log(o,8e3).toNumber();if(g.equals(0))return A;if(g.gt(0)&&g.lte(3)){let G=[];for(let H=0;HNumber.MAX_SAFE_INTEGER)&&(A="\u03C9");let M=t.log(o,8e3).toNumber();if(g.equals(0))return A;if(g.gt(0)&&g.lte(2)){let G=[];for(let H=0;H118?e.elemental.beyondOg(_):e.elemental.config.element_lists[o-1][A]},beyondOg(o){let S=Math.floor(Math.log10(o)),g=["n","u","b","t","q","p","h","s","o","e"],A="";for(let _=S;_>=0;_--){let M=Math.floor(o/Math.pow(10,_))%10;A==""?A=g[M].toUpperCase():A+=g[M]}return A},abbreviationLength(o){return o==1?1:Math.pow(Math.floor(o/2)+1,2)*2},getAbbreviationAndValue(o){let S=o.log(118).toNumber(),g=Math.floor(S)+1,A=e.elemental.abbreviationLength(g),_=S-g+1,M=Math.floor(_*A),E=e.elemental.getAbbreviation(g,_),T=new t(118).pow(g+M/A-1);return[E,T]},formatElementalPart(o,S){return S.eq(1)?o:`${S} ${o}`},format(o,S=2){if(o.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(o.log10(),S);let g=o.log(118),_=g.log(118).log(118).toNumber(),M=Math.max(4-_*2,1),E=[];for(;g.gte(1)&&E.length=M)return E.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ");let T=new t(118).pow(g).toFixed(E.length===1?3:S);return E.length===0?T:E.length===1?`${T} \xD7 ${e.elemental.formatElementalPart(E[0][0],E[0][1])}`:`${T} \xD7 (${E.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ")})`}},old_sc:{format(o,S){o=new t(o);let g=o.log10().floor();if(g.lt(9))return g.lt(3)?o.toFixed(S):o.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(o.gte("eeee10")){let _=o.slog();return(_.gte(1e9)?"":new t(10).pow(_.sub(_.floor())).toFixed(4))+"F"+e.old_sc.format(_.floor(),0)}let A=o.div(new t(10).pow(g));return(g.log10().gte(9)?"":A.toFixed(4))+"e"+e.old_sc.format(g,0)}}},eng:{format(o,S=2){o=new t(o);let g=o.log10().floor();if(g.lt(9))return g.lt(3)?o.toFixed(S):o.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(o.gte("eeee10")){let _=o.slog();return(_.gte(1e9)?"":new t(10).pow(_.sub(_.floor())).toFixed(4))+"F"+e.eng.format(_.floor(),0)}let A=o.div(new t(1e3).pow(g.div(3).floor()));return(g.log10().gte(9)?"":A.toFixed(new t(4).sub(g.sub(g.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(g.div(3).floor().mul(3),0)}}},mixed_sc:{format(o,S,g=9){o=new t(o);let A=o.log10().floor();return A.lt(303)&&A.gte(g)?d(o,S,g,"st"):d(o,S,g,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(o,S=2,g){o=new t(o);let A=o.max(1).log10().max(1).log(r.log10()).floor();if(A.lte(0))return d(o,S,g,"sc");o=new t(10).pow(o.max(1).log10().div(r.log10().pow(A)).sub(A.gte(1)?1:0));let _=A.div(10).floor(),M=A.toNumber()%10-1;return d(o,Math.max(4,S),g,"sc")+" "+(_.gte(1)?"meta"+(_.gte(2)?"^"+d(_,0,g,"sc"):"")+"-":"")+(isNaN(M)?"nanity":e.layer.layers[M])}},standard:{tier1(o){return mt[0][0][o%10]+mt[0][1][Math.floor(o/10)%10]+mt[0][2][Math.floor(o/100)]},tier2(o){let S=o%10,g=Math.floor(o/10)%10,A=Math.floor(o/100)%10,_="";return o<10?mt[1][0][o]:(g==1&&S==0?_+="Vec":_+=mt[1][1][S]+mt[1][2][g],_+=mt[1][3][A],_)}},inf:{format(o,S,g){o=new t(o);let A=0,_=new t(Number.MAX_VALUE),M=["","\u221E","\u03A9","\u03A8","\u028A"],E=["","","m","mm","mmm"];for(;o.gte(_);)o=o.log(_),A++;return A==0?d(o,S,g,"sc"):o.gte(3)?E[A]+M[A]+"\u03C9^"+d(o.sub(1),S,g,"sc"):o.gte(2)?E[A]+"\u03C9"+M[A]+"-"+d(_.pow(o.sub(2)),S,g,"sc"):E[A]+M[A]+"-"+d(_.pow(o.sub(1)),S,g,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(o,S=new t(1e15),g=!1,A=9){if(o=new t(o),S=new t(S).div(1e3),o.lt(S.mul(1e3)))return"";let{alphabet:_}=e.alphabet.config,M=_.length,E=o.log(1e3).sub(S.log(1e3)).floor(),T=E.add(1).log(M+1).ceil(),G="",H=(tt,nt)=>{let W=tt,Z="";for(let X=0;X=M)return"\u03C9";Z=_[dt]+Z,W=W.sub(1).div(M).floor()}return Z};if(T.lt(A))G=H(E,T);else{let tt=T.sub(A).add(1),nt=E.div(t.pow(M+1,tt.sub(1))).floor();G=`${H(nt,new t(A))}(${tt.gt("1e9")?tt.format():tt.format(0)})`}return G},format(o,S=2,g=9,A="mixed_sc",_=new t(1e15),M=!1,E){if(o=new t(o),_=new t(_).div(1e3),o.lt(_.mul(1e3)))return d(o,S,g,A);let T=e.alphabet.getAbbreviation(o,_,M,E),G=o.div(t.pow(1e3,o.log(1e3).floor()));return`${T.length>(E??9)+2?"":G.toFixed(S)+" "}${T}`}}},r=new t(2).pow(1024),i="\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089",n="\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079";function s(o){return o.toFixed(0).split("").map(S=>S==="-"?"\u208B":i[parseInt(S,10)]).join("")}function h(o){return o.toFixed(0).split("").map(S=>S==="-"?"\u208B":n[parseInt(S,10)]).join("")}function v(o,S=2,g=9,A="st"){return d(o,S,g,A)}function d(o,S=2,g=9,A="mixed_sc"){o=new t(o);let _=o.lt(0)?"-":"";if(o.mag==1/0)return _+"Infinity";if(Number.isNaN(o.mag))return _+"NaN";if(o.lt(0)&&(o=o.mul(-1)),o.eq(0))return o.toFixed(S);let M=o.log10().floor();switch(A){case"sc":case"scientific":if(o.log10().lt(Math.min(-S,0))&&S>1){let E=o.log10().ceil(),T=o.div(E.eq(-1)?new t(.1):new t(10).pow(E)),G=E.mul(-1).max(1).log10().gte(9);return _+(G?"":T.toFixed(2))+"e"+d(E,0,g,"mixed_sc")}else if(M.lt(g)){let E=Math.max(Math.min(S-M.toNumber(),S),0);return _+(E>0?o.toFixed(E):o.toFixed(E).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(o.gte("eeee10")){let G=o.slog();return(G.gte(1e9)?"":new t(10).pow(G.sub(G.floor())).toFixed(2))+"F"+d(G.floor(),0)}let E=o.div(new t(10).pow(M)),T=M.log10().gte(9);return _+(T?"":E.toFixed(2))+"e"+d(M,0,g,"mixed_sc")}case"st":case"standard":{let E=o.log(1e3).floor();if(E.lt(1))return _+o.toFixed(Math.max(Math.min(S-M.toNumber(),S),0));let T=E.mul(3),G=E.log10().floor();if(G.gte(3e3))return"e"+d(M,S,g,"st");let H="";if(E.lt(4))H=["","K","M","B"][Math.round(E.toNumber())];else{let W=Math.floor(E.log(1e3).toNumber());for(W<100&&(W=Math.max(W-1,0)),E=E.sub(1).div(new t(10).pow(W*3));E.gt(0);){let Z=E.div(1e3).floor(),X=E.sub(Z.mul(1e3)).floor().toNumber();X>0&&(X==1&&!W&&(H="U"),W&&(H=e.standard.tier2(W)+(H?"-"+H:"")),X>1&&(H=e.standard.tier1(X)+H)),E=Z,W++}}let tt=o.div(new t(10).pow(T)),nt=S===2?new t(2).sub(M.sub(T)).add(1).toNumber():S;return _+(G.gte(10)?"":tt.toFixed(nt)+" ")+H}default:return e[A]||console.error('Invalid format type "',A,'"'),_+e[A]?.format(o,S,g)}}function f(o,S,g="mixed_sc",A,_){o=new t(o),S=new t(S);let M=o.add(S),E,T=M.div(o);return T.gte(10)&&o.gte(1e100)?(T=T.log10().mul(20),E="(+"+d(T,A,_,g)+" OoMs/sec)"):E="(+"+d(S,A,_,g)+"/sec)",E}function y(o,S=2,g="s"){return o=new t(o),o.gte(86400)?d(o.div(86400).floor(),0,12,"sc")+":"+y(o.mod(86400),S,"d"):o.gte(3600)||g=="d"?(o.div(3600).gte(10)||g!="d"?"":"0")+d(o.div(3600).floor(),0,12,"sc")+":"+y(o.mod(3600),S,"h"):o.gte(60)||g=="h"?(o.div(60).gte(10)||g!="h"?"":"0")+d(o.div(60).floor(),0,12,"sc")+":"+y(o.mod(60),S,"m"):(o.gte(10)||g!="m"?"":"0")+d(o,S,12,"sc")}function l(o,S=!1,g=0,A=9,_="mixed_sc"){let M=Bt=>d(Bt,g,A,_);o=new t(o);let E=o.mul(1e3).mod(1e3).floor(),T=o.mod(60).floor(),G=o.div(60).mod(60).floor(),H=o.div(3600).mod(24).floor(),tt=o.div(86400).mod(365.2425).floor(),nt=o.div(31556952).floor(),W=nt.eq(1)?" year":" years",Z=tt.eq(1)?" day":" days",X=H.eq(1)?" hour":" hours",dt=G.eq(1)?" minute":" minutes",Pt=T.eq(1)?" second":" seconds",qt=E.eq(1)?" millisecond":" milliseconds";return`${nt.gt(0)?M(nt)+W+", ":""}${tt.gt(0)?M(tt)+Z+", ":""}${H.gt(0)?M(H)+X+", ":""}${G.gt(0)?M(G)+dt+", ":""}${T.gt(0)?M(T)+Pt+",":""}${S&&E.gt(0)?" "+M(E)+qt:""}`.replace(/,([^,]*)$/,"$1").trim()}function u(o){return o=new t(o),d(new t(1).sub(o).mul(100))+"%"}function c(o){return o=new t(o),d(o.mul(100))+"%"}function p(o,S=2){return o=new t(o),o.gte(1)?"\xD7"+o.format(S):"/"+o.pow(-1).format(S)}function w(o,S,g=10){return t.gte(o,10)?t.pow(g,t.log(o,g).pow(S)):new t(o)}function I(o,S=0){o=new t(o);let g=(E=>E.map((T,G)=>({name:T.name,altName:T.altName,value:t.pow(1e3,new t(G).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"E",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),A="",_=o.lte(0)?0:t.min(t.log(o,1e3).sub(1),g.length-1).floor().toNumber(),M=g[_];if(_===0)switch(S){case 1:A="";break;case 2:case 0:default:A=o.format();break}switch(S){case 1:A=M.name;break;case 2:A=`${o.divide(M.value).format()}`;break;case 3:A=M.altName;break;case 0:default:A=`${o.divide(M.value).format()} ${M.name}`;break}return A}function k(o,S=!1){return`${I(o,2)} ${I(o,1)}eV${S?"/c^2":""}`}let F={...e,toSubscript:s,toSuperscript:h,formatST:v,format:d,formatGain:f,formatTime:y,formatTimeLong:l,formatReduction:u,formatPercent:c,formatMult:p,expMult:w,metric:I,ev:k};return{FORMATS:e,formats:F}}var Gt=17,ir=9e15,nr=Math.log10(9e15),sr=1/9e15,or=308,ar=-324,ae=5,ur=1023,fr=!0,lr=!1,cr=function(){let t=[];for(let r=ar+1;r<=or;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),gt=[2,Math.E,3,4,5,6,7,8,9,10],hr=[[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]],dr=[[-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]],N=function(e){return a.fromValue_noAlloc(e)},D=function(t,e,r){return a.fromComponents(t,e,r)},Y=function(e,r,i){return a.fromComponents_noNormalize(e,r,i)},ht=function(e,r){let i=r+1,n=Math.ceil(Math.log10(Math.abs(e))),s=Math.round(e*Math.pow(10,i-n))*Math.pow(10,n-i);return parseFloat(s.toFixed(Math.max(i-n,0)))},Ut=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},mr=function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;let e=1;for(;t<10;)e=e*t,++t;t-=1;let r=.9189385332046727;r=r+(t+.5)*Math.log(t),r=r-t;let i=t*t,n=t;return r=r+1/(12*n),n=n*i,r=r+1/(360*n),n=n*i,r=r+1/(1260*n),n=n*i,r=r+1/(1680*n),n=n*i,r=r+1/(1188*n),n=n*i,r=r+691/(360360*n),n=n*i,r=r+7/(1092*n),n=n*i,r=r+3617/(122400*n),Math.exp(r)/e},gr=.36787944117144233,ue=.5671432904097838,fe=function(t,e=1e-10){let r,i;if(!Number.isFinite(t)||t===0)return t;if(t===1)return ue;t<10?r=0:r=Math.log(t)-Math.log(Math.log(t));for(let n=0;n<100;++n){if(i=(t*Math.exp(-r)+r*r)/(r+1),Math.abs(i-r).5?1:-1;if(Math.random()*20<1)return Y(e,0,1);let r=Math.floor(Math.random()*(t+1)),i=r===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let n=Math.pow(10,i);return Math.random()>.9&&(n=Math.trunc(n)),D(e,r,n)}static affordGeometricSeries_core(t,e,r,i){let n=e.mul(r.pow(i));return a.floor(t.div(n).mul(r.sub(1)).add(1).log10().div(r.log10()))}static sumGeometricSeries_core(t,e,r,i){return e.mul(r.pow(i)).mul(a.sub(1,r.pow(t))).div(a.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let s=e.add(i.mul(r)).sub(r.div(2)),h=s.pow(2);return s.neg().add(h.add(r.mul(t).mul(2)).sqrt()).div(r).floor()}static sumArithmeticSeries_core(t,e,r,i){let n=e.add(i.mul(r));return t.div(2).mul(n.mul(2).plus(t.sub(1).mul(r)))}static efficiencyOfPurchase_core(t,e,r){return t.div(e).add(t.div(r))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0||this.mag===Number.NEGATIVE_INFINITY&&this.layer>0&&Number.isFinite(this.layer))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.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_INFINITY)return this.sign==1?(this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY):this.sign==-1&&(this.mag=Number.NEGATIVE_INFINITY,this.layer=Number.NEGATIVE_INFINITY),this;if(this.layer===0&&this.mag=ir)return this.layer+=1,this.mag=e*Math.log10(t),this;for(;t0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=e*Math.pow(10,t),t=Math.abs(this.mag),e=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)),(Number.isNaN(this.sign)||Number.isNaN(this.layer)||Number.isNaN(this.mag))&&(this.sign=Number.NaN,this.layer=Number.NaN,this.mag=Number.NaN),this}fromComponents(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this.normalize(),this}fromComponents_noNormalize(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this}fromMantissaExponent(t,e){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=e+Math.log10(t),this.normalize(),this}fromMantissaExponent_noNormalize(t,e){return this.fromMantissaExponent(t,e),this}fromDecimal(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this}fromNumber(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this}fromString(t,e=!1){let r=t,i=a.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);fr?t=t.replace(",",""):lr&&(t=t.replace(",","."));let n=t.split("^^^");if(n.length===2){let w=parseFloat(n[0]),I=parseFloat(n[1]),k=n[1].split(";"),F=1;if(k.length===2&&(F=parseFloat(k[1]),isFinite(F)||(F=1)),isFinite(w)&&isFinite(I)){let o=a.pentate(w,I,F,e);return this.sign=o.sign,this.layer=o.layer,this.mag=o.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}let s=t.split("^^");if(s.length===2){let w=parseFloat(s[0]),I=parseFloat(s[1]),k=s[1].split(";"),F=1;if(k.length===2&&(F=parseFloat(k[1]),isFinite(F)||(F=1)),isFinite(w)&&isFinite(I)){let o=a.tetrate(w,I,F,e);return this.sign=o.sign,this.layer=o.layer,this.mag=o.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}let h=t.split("^");if(h.length===2){let w=parseFloat(h[0]),I=parseFloat(h[1]);if(isFinite(w)&&isFinite(I)){let k=a.pow(w,I);return this.sign=k.sign,this.layer=k.layer,this.mag=k.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}t=t.trim().toLowerCase();let v,d,f=t.split("pt");if(f.length===2){v=10,d=parseFloat(f[0]),f[1]=f[1].replace("(",""),f[1]=f[1].replace(")","");let w=parseFloat(f[1]);if(isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=a.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}if(f=t.split("p"),f.length===2){v=10,d=parseFloat(f[0]),f[1]=f[1].replace("(",""),f[1]=f[1].replace(")","");let w=parseFloat(f[1]);if(isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=a.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}if(f=t.split("f"),f.length===2){v=10,f[0]=f[0].replace("(",""),f[0]=f[0].replace(")","");let w=parseFloat(f[0]);if(f[1]=f[1].replace("(",""),f[1]=f[1].replace(")",""),d=parseFloat(f[1]),isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=a.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}let y=t.split("e"),l=y.length-1;if(l===0){let w=parseFloat(t);if(isFinite(w))return this.fromNumber(w),a.fromStringCache.size>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}else if(l===1){let w=parseFloat(t);if(isFinite(w)&&w!==0)return this.fromNumber(w),a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}let u=t.split("e^");if(u.length===2){this.sign=1,u[0].charAt(0)=="-"&&(this.sign=-1);let w="";for(let I=0;I=43&&k<=57||k===101)w+=u[1].charAt(I);else return this.layer=parseFloat(w),this.mag=parseFloat(u[1].substr(I+1)),this.normalize(),a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}if(l<1)return this.sign=0,this.layer=0,this.mag=0,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this;let c=parseFloat(y[0]);if(c===0)return this.sign=0,this.layer=0,this.mag=0,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this;let p=parseFloat(y[y.length-1]);if(l>=2){let w=parseFloat(y[y.length-2]);isFinite(w)&&(p*=Math.sign(w),p+=Ut(w))}if(!isFinite(c))this.sign=y[0]==="-"?-1:1,this.layer=l,this.mag=p;else if(l===1)this.sign=Math.sign(c),this.layer=1,this.mag=p+Math.log10(Math.abs(c));else if(this.sign=Math.sign(c),this.layer=l,l===2){let w=a.mul(D(1,2,p),N(c));return this.sign=w.sign,this.layer=w.layer,this.mag=w.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}else this.mag=p;return this.normalize(),a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}fromValue(t){return t instanceof a?this.fromDecimal(t):typeof t=="number"?this.fromNumber(t):typeof t=="string"?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===1?Number.POSITIVE_INFINITY:this.mag===Number.NEGATIVE_INFINITY&&this.layer===Number.NEGATIVE_INFINITY&&this.sign===-1?Number.NEGATIVE_INFINITY: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(t){return isNaN(this.m)?Number.NaN:this.m===0?0:ht(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:ht(this.mag,t)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_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<=ae?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(t){return this.layer===0?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)}toFixed(t){return this.layer===0?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)}toPrecision(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(t){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(t):ht(this.m,t)+"e"+ht(this.e,t):this.layer===1?ht(this.m,t)+"e"+ht(this.e,t):this.layer<=ae?(this.sign===-1?"-":"")+"e".repeat(this.layer)+ht(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+ht(this.mag,t)}abs(){return Y(this.sign===0?0:1,this.layer,this.mag)}neg(){return Y(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?a.dZero:this.layer===0?D(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?this.sign===-1?a.dNegOne:a.dZero:this.sign===-1?this.neg().ceil().neg():this.layer===0?D(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?this.sign===1?a.dOne:a.dZero:this.sign===-1?this.neg().floor().neg():this.layer===0?D(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?a.dZero:this.layer===0?D(this.sign,0,Math.trunc(this.mag)):this}add(t){let e=N(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer)||this.sign===0)return e;if(e.sign===0)return this;if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return Y(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(a.cmpabs(this,e)>0?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return a.fromNumber(r.sign*r.mag+i.sign*i.mag);let n=r.layer*Math.sign(r.mag),s=i.layer*Math.sign(i.mag);if(n-s>=2)return r;if(n===0&&s===-1){if(Math.abs(i.mag-Math.log10(r.mag))>Gt)return r;{let h=Math.pow(10,Math.log10(r.mag)-i.mag),v=i.sign+r.sign*h;return D(Math.sign(v),1,i.mag+Math.log10(Math.abs(v)))}}if(n===1&&s===0){if(Math.abs(r.mag-Math.log10(i.mag))>Gt)return r;{let h=Math.pow(10,r.mag-Math.log10(i.mag)),v=i.sign+r.sign*h;return D(Math.sign(v),1,Math.log10(i.mag)+Math.log10(Math.abs(v)))}}if(Math.abs(r.mag-i.mag)>Gt)return r;{let h=Math.pow(10,r.mag-i.mag),v=i.sign+r.sign*h;return D(Math.sign(v),1,i.mag+Math.log10(Math.abs(v)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(N(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=N(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer))return e;if(this.sign===0||e.sign===0)return Y(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return Y(this.sign*e.sign,0,1);let r,i;if(this.layer>e.layer||this.layer==e.layer&&Math.abs(this.mag)>Math.abs(e.mag)?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return a.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return D(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return D(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return D(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let n=D(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(D(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return D(r.sign*i.sign,n.layer+1,n.sign*n.mag)}if(r.layer===2&&i.layer===2){let n=D(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(D(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return D(r.sign*i.sign,n.layer+1,n.sign*n.mag)}throw Error("Bad arguments to mul: "+this+", "+t)}multiply(t){return this.mul(t)}times(t){return this.mul(t)}div(t){let e=N(t);return this.mul(e.recip())}divide(t){return this.div(t)}divideBy(t){return this.div(t)}dividedBy(t){return this.div(t)}recip(){return this.mag===0?a.dNaN:this.layer===0?D(this.sign,0,1/this.mag):D(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=N(t).abs();if(e.eq(a.dZero))return a.dZero;let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new a(r%i):this.sub(e).eq(this)?a.dZero:e.sub(this).eq(e)?this:this.sign==-1?this.abs().mod(e).neg():this.sub(this.div(e).floor().mul(e))}modulo(t){return this.mod(t)}modular(t){return this.mod(t)}cmp(t){let e=N(t);return this.sign>e.sign?1:this.sign0?this.layer:-this.layer,i=e.mag>0?e.layer:-e.layer;return r>i?1:re.mag?1:this.mag0?e:this}clamp(t,e){return this.max(t).min(e)}clampMin(t){return this.max(t)}clampMax(t){return this.min(t)}cmp_tolerance(t,e){let r=N(t);return this.eq_tolerance(r,e)?0:this.cmp(r)}compare_tolerance(t,e){return this.cmp_tolerance(t,e)}eq_tolerance(t,e){let r=N(t);if(e==null&&(e=1e-7),this.sign!==r.sign||Math.abs(this.layer-r.layer)>1)return!1;let i=this.mag,n=r.mag;return this.layer>r.layer&&(n=Ut(n)),this.layer0?D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):D(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?a.dNaN:this.layer>0?D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):D(this.sign,0,Math.log10(this.mag))}log(t){return t=N(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?a.dNaN:this.layer===0&&t.layer===0?D(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):a.div(this.log10(),t.log10())}log2(){return this.sign<=0?a.dNaN:this.layer===0?D(this.sign,0,Math.log2(this.mag)):this.layer===1?D(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?D(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?a.dNaN:this.layer===0?D(this.sign,0,Math.log(this.mag)):this.layer===1?D(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?D(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=N(t),r=this,i=e;if(r.sign===0)return i.eq(0)?Y(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return Y(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return r;let n=r.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?n.neg():Math.abs(i.toNumber()%2)%2===0?n:a.dNaN:n}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return a.dNaN;let t=this;if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return D(1,0,e);if(t.sign===0)return a.dOne;t=Y(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?D(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?D(-t.sign,t.layer+1,-t.mag):a.dOne}pow_base(t){return N(t).pow(this)}root(t){let e=N(t);return this.pow(e.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?a.exp(a.mul(this,a.ln(this).sub(1))):a.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(Y(1,0,24)))return a.fromNumber(mr(this.sign*this.mag));let t=this.mag-1,e=.9189385332046727;e=e+(t+.5)*Math.log(t),e=e-t;let r=t*t,i=t,n=12*i,s=1/n,h=e+s;if(h===e||(e=h,i=i*r,n=360*i,s=1/n,h=e-s,h===e))return a.exp(e);e=h,i=i*r,n=1260*i;let v=1/n;return e=e+v,i=i*r,n=1680*i,v=1/n,e=e-v,a.exp(e)}else return this.layer===1?a.exp(a.mul(this,a.ln(this).sub(1))):a.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?a.dOne:this.layer===0&&this.mag<=709.7?a.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?D(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?D(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):D(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return a.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return D(1,2,Math.log10(this.mag)-.3010299956639812);{let t=a.div(Y(this.sign,this.layer-1,this.mag),Y(1,0,2));return t.layer+=1,t.normalize(),t}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(t=2,e=Y(1,0,1),r=!1){if(t===1)return a.pow(this,e);if(t===0)return new a(e);if(this.eq(a.dOne))return a.dOne;if(this.eq(-1))return a.pow(this,e);if(t===Number.POSITIVE_INFINITY){let s=this.toNumber();if(s<=1.444667861009766&&s>=.06598803584531254){if(s>1.444667861009099)return a.fromNumber(Math.E);let h=a.ln(this).neg();return h.lambertw().div(h)}else return s>1.444667861009766?a.fromNumber(Number.POSITIVE_INFINITY):a.dNaN}if(this.eq(a.dZero)){let s=Math.abs((t+1)%2);return s>1&&(s=2-s),a.fromNumber(s)}if(t<0)return a.iteratedlog(e,this,-t,r);e=N(e);let i=t;t=Math.trunc(t);let n=i-t;if(this.gt(a.dZero)&&this.lte(1.444667861009766)&&(i>1e4||!r)){t=Math.min(1e4,t);for(let s=0;s1e4){let s=this.pow(e);return i<=1e4||Math.ceil(i)%2==0?e.mul(1-n).add(s.mul(n)):e.mul(n).add(s.mul(1-n))}return e}n!==0&&(e.eq(a.dOne)?this.gt(10)||r?e=this.pow(n):(e=a.fromNumber(a.tetrate_critical(this.toNumber(),n)),this.lt(2)&&(e=e.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let s=0;s3)return Y(e.sign,e.layer+(t-s-1),e.mag);if(s>1e4)return e}return e}iteratedexp(t=2,e=Y(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return a.tetrate(t,-e,this,r);t=N(t);let i=a.fromDecimal(this),n=e;e=Math.trunc(e);let s=n-e;if(i.layer-t.layer>3){let h=Math.min(e,i.layer-t.layer-3);e-=h,i.layer-=h}for(let h=0;h1e4)return i}return s>0&&s<1&&(t.eq(10)?i=i.layeradd10(-s,r):i=i.layeradd(-s,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,n=!1,s=!1,h=this.slog_internal(t,r).toNumber();for(let v=1;v1&&s!=f&&(n=!0),s=f,n?i/=2:i*=2,i=Math.abs(i)*(f?-1:1),h+=i,i===0)break}return a.fromNumber(h)}slog_internal(t=10,e=!1){if(t=N(t),t.lte(a.dZero)||t.eq(a.dOne))return a.dNaN;if(t.lt(a.dOne))return this.eq(a.dOne)?a.dZero:this.eq(a.dZero)?a.dNegOne:a.dNaN;if(this.mag<0||this.eq(a.dZero))return a.dNegOne;let r=0,i=a.fromDecimal(this);if(i.layer-t.layer>3){let n=i.layer-t.layer-3;r+=n,i.layer-=n}for(let n=0;n<100;++n)if(i.lt(a.dZero))i=a.pow(t,i),r-=1;else{if(i.lte(a.dOne))return e?a.fromNumber(r+i.toNumber()-1):a.fromNumber(r+a.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=a.log(i,t)}return a.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:a.critical_section(t,e,dr)}static tetrate_critical(t,e){return a.critical_section(t,e,hr)}static critical_section(t,e,r,i=!1){e*=10,e<0&&(e=0),e>10&&(e=10),t<2&&(t=2),t>10&&(t=10);let n=0,s=0;for(let v=0;vt){let d=(t-gt[v])/(gt[v+1]-gt[v]);n=r[v][Math.floor(e)]*(1-d)+r[v+1][Math.floor(e)]*d,s=r[v][Math.ceil(e)]*(1-d)+r[v+1][Math.ceil(e)]*d;break}let h=e-Math.floor(e);return n<=0||s<=0?n*(1-h)+s*h:Math.pow(t,Math.log(n)/Math.log(t)*(1-h)+Math.log(s)/Math.log(t)*h)}layeradd10(t,e=!1){t=a.fromValue_noAlloc(t).toNumber();let r=a.fromDecimal(this);if(t>=1){r.mag<0&&r.layer>0?(r.sign=0,r.mag=0,r.layer=0):r.sign===-1&&r.layer==0&&(r.sign=1,r.mag=-r.mag);let i=Math.trunc(t);t-=i,r.layer+=i}if(t<=-1){let i=Math.trunc(t);if(t-=i,r.layer+=i,r.layer<0)for(let n=0;n<100;++n){if(r.layer++,r.mag=Math.log10(r.mag),!isFinite(r.mag))return r.sign===0&&(r.sign=1),r.layer<0&&(r.layer=0),r.normalize();if(r.layer>=0)break}}for(;r.layer<0;)r.layer++,r.mag=Math.log10(r.mag);return r.sign===0&&(r.sign=1,r.mag===0&&r.layer>=1&&(r.layer-=1,r.mag=1)),r.normalize(),t!==0?r.layeradd(t,10,e):r}layeradd(t,e,r=!1){let n=this.slog(e).toNumber()+t;return n>=0?a.tetrate(e,n,a.dOne,r):Number.isFinite(n)?n>=-1?a.log(a.tetrate(e,n+1,a.dOne,r),e):a.log(a.log(a.tetrate(e,n+2,a.dOne,r),e),e):a.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return a.fromNumber(fe(this.toNumber()));if(this.layer===0)return a.fromNumber(fe(this.sign*this.mag));if(this.layer===1)return le(this);if(this.layer===2)return le(this);if(this.layer>=3)return Y(this.sign,this.layer-1,this.mag);throw"Unhandled behavior in lambertw()"}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(a.dInf))return a.dInf;if(!this.isFinite())return a.dNaN;if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return a.fromNumber(t).add(2).pow(this.recip());if(t<=0)return a.dNaN;if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return egr?this.pow(this.recip()):a.dNaN}if(this.eq(1))return a.dOne;if(this.lt(0))return a.dNaN;if(this.lte("1ee-16"))return t%2==1?this:a.dNaN;if(this.gt(1)){let e=a.dTen;this.gte(a.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=a.dZero,i=e.layer,n=e.iteratedlog(10,i,!0),s=n,h=n.div(2),v=!0;for(;v;)h=r.add(n).div(2),a.iteratedexp(10,i,h,!0).tetrate(t,1,!0).gt(this)?n=h:r=h,h.eq(s)?v=!1:s=h;return a.iteratedexp(10,i,h,!0)}else{let e=1,r=D(1,10,1),i=D(1,10,1),n=D(1,10,1),s=D(1,1,-16),h=a.dZero,v=D(1,10,1),d=s.pow10().recip(),f=a.dZero,y=d,l=d,u=Math.ceil(t)%2==0,c=0,p=D(1,10,1),w=!1,I=a.dZero,k=!1;for(;e<4;){if(e==2){if(u)break;n=D(1,10,1),s=r,e=3,v=D(1,10,1),p=D(1,10,1)}for(w=!1;s.neq(n);){if(I=s,s.pow10().recip().tetrate(t,1,!0).eq(1)&&s.pow10().recip().lt(.4))d=s.pow10().recip(),y=s.pow10().recip(),l=s.pow10().recip(),f=a.dZero,c=-1,e==3&&(p=s);else if(s.pow10().recip().tetrate(t,1,!0).eq(s.pow10().recip())&&!u&&s.pow10().recip().lt(.4))d=s.pow10().recip(),y=s.pow10().recip(),l=s.pow10().recip(),f=a.dZero,c=0;else if(s.pow10().recip().tetrate(t,1,!0).eq(s.pow10().recip().mul(2).tetrate(t,1,!0)))d=s.pow10().recip(),y=a.dZero,l=d.mul(2),f=d,u?c=-1:c=0;else{for(h=s.mul(12e-17),d=s.pow10().recip(),y=s.add(h).pow10().recip(),f=d.sub(y),l=d.add(f);y.tetrate(t,1,!0).eq(d.tetrate(t,1,!0))||l.tetrate(t,1,!0).eq(d.tetrate(t,1,!0))||y.gte(d)||l.lte(d);)h=h.mul(2),y=s.add(h).pow10().recip(),f=d.sub(y),l=d.add(f);if((e==1&&l.tetrate(t,1,!0).gt(d.tetrate(t,1,!0))&&y.tetrate(t,1,!0).gt(d.tetrate(t,1,!0))||e==3&&l.tetrate(t,1,!0).lt(d.tetrate(t,1,!0))&&y.tetrate(t,1,!0).lt(d.tetrate(t,1,!0)))&&(p=s),l.tetrate(t,1,!0).lt(d.tetrate(t,1,!0)))c=-1;else if(u)c=1;else if(e==3&&s.gt_tolerance(r,1e-8))c=0;else{for(;y.tetrate(t,1,!0).eq_tolerance(d.tetrate(t,1,!0),1e-8)||l.tetrate(t,1,!0).eq_tolerance(d.tetrate(t,1,!0),1e-8)||y.gte(d)||l.lte(d);)h=h.mul(2),y=s.add(h).pow10().recip(),f=d.sub(y),l=d.add(f);l.tetrate(t,1,!0).sub(d.tetrate(t,1,!0)).lt(d.tetrate(t,1,!0).sub(y.tetrate(t,1,!0)))?c=0:c=1}}if(c==-1&&(k=!0),e==1&&c==1||e==3&&c!=0)if(n.eq(D(1,10,1)))s=s.mul(2);else{let g=!1;if(w&&(c==1&&e==1||c==-1&&e==3)&&(g=!0),s=s.add(n).div(2),g)break}else if(n.eq(D(1,10,1)))n=s,s=s.div(2);else{let g=!1;if(w&&(c==1&&e==1||c==-1&&e==3)&&(g=!0),n=n.sub(v),s=s.sub(v),g)break}if(n.sub(s).div(2).abs().gt(v.mul(1.5))&&(w=!0),v=n.sub(s).div(2).abs(),s.gt("1e18")||s.eq(I))break}if(s.gt("1e18")||!k||p==D(1,10,1))break;e==1?r=p:e==3&&(i=p),e++}n=r,s=D(1,1,-18);let F=s,o=a.dZero,S=!0;for(;S;)if(n.eq(D(1,10,1))?o=s.mul(2):o=n.add(s).div(2),a.pow(10,o).recip().tetrate(t,1,!0).gt(this)?s=o:n=o,o.eq(F)?S=!1:F=o,s.gt("1e18"))return a.dNaN;if(o.eq_tolerance(r,1e-15)){if(i.eq(D(1,10,1)))return a.dNaN;for(n=D(1,10,1),s=i,F=s,o=a.dZero,S=!0;S;)if(n.eq(D(1,10,1))?o=s.mul(2):o=n.add(s).div(2),a.pow(10,o).recip().tetrate(t,1,!0).gt(this)?s=o:n=o,o.eq(F)?S=!1:F=o,s.gt("1e18"))return a.dNaN;return o.pow10().recip()}else return o.pow10().recip()}}pentate(t=2,e=Y(1,0,1),r=!1){e=N(e);let i=t;t=Math.trunc(t);let n=i-t;n!==0&&(e.eq(a.dOne)?(++t,e=a.fromNumber(n)):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let s=0;s10)return e}return e}sin(){return this.mag<0?this:this.layer===0?a.fromNumber(Math.sin(this.sign*this.mag)):Y(0,0,0)}cos(){return this.mag<0?a.dOne:this.layer===0?a.fromNumber(Math.cos(this.sign*this.mag)):Y(0,0,0)}tan(){return this.mag<0?this:this.layer===0?a.fromNumber(Math.tan(this.sign*this.mag)):Y(0,0,0)}asin(){return this.mag<0?this:this.layer===0?a.fromNumber(Math.asin(this.sign*this.mag)):Y(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?a.fromNumber(Math.acos(this.toNumber())):this.layer===0?a.fromNumber(Math.acos(this.sign*this.mag)):Y(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?a.fromNumber(Math.atan(this.sign*this.mag)):a.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 a.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return a.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?Y(Number.NaN,Number.NaN,Number.NaN):a.ln(this.add(1).div(a.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?this:this.root(a.pow(10,t))}egg(){return this.add(9)}lessThanOrEqualTo(t){return this.cmp(t)<1}lessThan(t){return this.cmp(t)<0}greaterThanOrEqualTo(t){return this.cmp(t)>-1}greaterThan(t){return this.cmp(t)>0}static smoothDamp(t,e,r,i){return new a(t).add(new a(e).minus(new a(t)).times(new a(r)).times(new a(i)))}clone(){return this}static clone(t){return a.fromComponents(t.sign,t.layer,t.mag)}softcap(t,e,r){let i=this.clone();return i.gte(t)&&([0,"pow"].includes(r)&&(i=i.div(t).pow(e).mul(t)),[1,"mul"].includes(r)&&(i=i.sub(t).div(e).add(t))),i}static softcap(t,e,r,i){return new a(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new a(t),e=new a(e);let n=this.clone();return n.gte(t)&&([0,"pow"].includes(r)&&(n=i?n.mul(t.pow(e.sub(1))).root(e):n.pow(e).div(t.pow(e.sub(1)))),[1,"exp"].includes(r)&&(n=i?n.div(t).max(1).log(e).add(t):a.pow(e,n.sub(t)).mul(t))),n}static scale(t,e,r,i,n=!1){return new a(t).scale(e,r,i,n)}format(t=2,e=9,r="mixed_sc"){return pt.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return pt.format(new a(t),e,r,i)}formatST(t=2,e=9,r="st"){return pt.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return pt.format(new a(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return pt.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,n){return pt.formatGain(new a(t),e,r,i,n)}toRoman(t=5e3){t=new a(t);let e=this.clone();if(e.gte(t)||e.lt(1))return e;let r=e.toNumber(),i={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},n="";for(let s of Object.keys(i)){let h=Math.floor(r/i[s]);r-=h*i[s],n+=s.repeat(h)}return n}static toRoman(t,e){return new a(t).toRoman(e)}static random(t=0,e=1){return t=new a(t),e=new a(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new a(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new a(Math.random()).lt(t)}};a.dZero=Y(0,0,0),a.dOne=Y(1,0,1),a.dNegOne=Y(-1,0,1),a.dTwo=Y(1,0,2),a.dTen=Y(1,0,10),a.dNaN=Y(Number.NaN,Number.NaN,Number.NaN),a.dInf=Y(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),a.dNegInf=Y(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),a.dNumberMax=D(1,0,Number.MAX_VALUE),a.dNumberMin=D(1,0,Number.MIN_VALUE),a.fromStringCache=new Rt(ur),ft([Tt()],a.prototype,"sign",2),ft([Tt()],a.prototype,"mag",2),ft([Tt()],a.prototype,"layer",2),a=ft([tr()],a);var{formats:pt,FORMATS:pr}=rr(a);a.formats=pt;var P=(()=>{let t=e=>new a(e);return Object.getOwnPropertyNames(a).filter(e=>!Object.getOwnPropertyNames(class{}).includes(e)).forEach(e=>{t[e]=a[e]}),t})(),Nt=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.value=t.value,this.order=t.order??99}},$t=class{constructor(t=1,e){this.addBoost=this.setBoost,e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=P(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new Nt(r))})}getBoosts(t,e){let r=[],i=[];for(let n=0;nl),f=n,y=this.getBoosts(s,!0);y[0][0]?this.boostArray[y[1][0]]=new Nt({id:s,name:h,description:v,value:d,order:f}):this.boostArray.push(new Nt({id:s,name:h,description:v,value:d,order:f}))}else{t=Array.isArray(t)?t:[t];for(let s=0;si.order-n.order);for(let i=0;ie.cost(p.add(r)),u=P.min(i,zt(l,t,n,s).value.floor()),c=P(0);return[u,c]}let d=zt(l=>Yt(e.cost,l,r),t,n,s).value.floor().min(r.add(v).sub(1)),f=Yt(e.cost,d,r);return[d.sub(r).add(1).max(0),f]}function kt(t){return t=P(t),`${t.sign}/${t.mag}/${t.layer}`}function de(t,e){return`sum/${kt(t)}/${kt(e)}}`}function Ht(t){return`el/${kt(t)}`}var vt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?P(t.level):P(1)}};ft([Tt()],vt.prototype,"id",2),ft([Ft(()=>a)],vt.prototype,"level",2);var me=class De{static{this.cacheSize=63}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn()}get level(){return((this??{data:{level:P(1)}}).data??{level:P(1)}).level}set level(e){this.data.level=P(e)}constructor(e,r,i){let n=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>n,this.cache=new Rt(i??De.cacheSize),this.id=e.id,this.name=e.name??e.id,this.descriptionFn=e.description?typeof e.description=="function"?e.description:()=>e.description:()=>"",this.cost=e.cost,this.costBulk=e.costBulk,this.maxLevel=e.maxLevel,this.effect=e.effect,this.el=e.el}getCached(e,r,i){return e==="sum"?this.cache.get(de(r,i)):this.cache.get(Ht(r))}setCached(e,r,i,n){let s=e==="sum"?{id:this.id,el:!1,start:P(r),end:P(i),cost:P(n)}:{id:this.id,el:!0,level:P(r),cost:P(i)};return e==="sum"?this.cache.set(de(r,i),s):this.cache.set(Ht(r),s),s}},$r=at(ct()),yt=class{constructor(){this.value=P(0),this.upgrades={}}};ft([Ft(()=>a)],yt.prototype,"value",2),ft([Ft(()=>vt)],yt.prototype,"upgrades",2);var ge=class{get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}constructor(t=new yt,e,r={defaultVal:P(0),defaultBoost:P(1)}){this.defaultVal=r.defaultVal,this.defaultBoost=r.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new $t(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e),this.upgrades=this.upgrades}onLoadData(){for(let t of Object.values(this.upgrades))t.effect?.(t.level,t)}reset(t=!0,e=!0){if(t&&(this.value=this.defaultVal),e)for(let r of Object.values(this.upgrades))r.level=P(0)}gain(t=1e3){let e=this.boost.calculate().mul(P(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new vt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r={};for(let i of t){let n=this.pointerAddUpgrade(i),s=new me(i,()=>this.pointerGetUpgrade(i.id));s.effect&&e&&s.effect(s.level,s),r[i.id]=s,this.upgrades[i.id]=s}return Object.values(r)}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&(r.name=e.name??r.name,r.cost=e.cost??r.cost,r.maxLevel=e.maxLevel??r.maxLevel,r.effect=e.effect??r.effect)}calculateUpgrade(t,e,r,i){let n=this.getUpgrade(t);return n===null?(console.warn(`Upgrade "${t}" not found.`),[P(0),P(0)]):Zt(this.value,n,n.level,e?n.level.add(e):void 0,r,i)}getNextCost(t,e=0,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),P(0);let s=Zt(this.value,n,n.level,n.level.add(e),r,i)[1];return n.cost(n.level.add(s))}buyUpgrade(t,e,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),!1;let[s,h]=this.calculateUpgrade(t,e,r,i);return s.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(h),n.level=n.level.add(s),n.effect?.(n.level,n),!0)}},zr=at(ct()),Lt=class{constructor(t=0){this.value=P(t)}};ft([Ft(()=>a)],Lt.prototype,"value",2);var pe=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=P(r),t??=new Lt(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new $t(this.initial):null}update(){console.warn("AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed."),this.boost&&(this.pointer.value=this.boost.calculate())}get value(){return this.boost&&(this.pointer.value=this.boost.calculate()),this.pointer.value}set value(t){if(this.boost)throw new Error("Cannot set value of attributeStatic when boost is enabled.");this.pointer.value=t}},ve=class{constructor(t,e,r){this.x=t,this.y=e,this.properties=r??{}}setValue(t,e){return this.properties[t]=e,e}getValue(t){return this.properties[t]}},yr=class{constructor(t,e,r){this.xSize=t,this.ySize=e,this.cells=[];for(let i=0;i_e,EventManager:()=>Me,EventTypes:()=>we,Game:()=>Nr,GameAttribute:()=>Ae,GameCurrency:()=>Se,GameReset:()=>Oe,KeyManager:()=>be,gameDefaultConfig:()=>Ie,keys:()=>wr});var Yr=at(ct()),Vt=class{constructor(t){this.configOptionTemplate=t}parse(t){if(typeof t>"u")return this.configOptionTemplate;function e(r,i){for(let n in i)typeof r[n]>"u"?r[n]=i[n]:typeof r[n]=="object"&&typeof i[n]=="object"&&!Array.isArray(r[n])&&!Array.isArray(i[n])&&(r[n]=e(r[n],i[n]));return r}return e(t,this.configOptionTemplate)}get options(){return this.configOptionTemplate}},br={autoAddInterval:!0,fps:30,pixiApp:void 0},wr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ".split("").concat(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),be=class Re{constructor(e){if(this.addKeys=this.addKey,this.keysPressed=[],this.binds=[],this.tickers=[],this.config=Re.configManager.parse(e),this.config.autoAddInterval)if(this.config.pixiApp)this.config.pixiApp.ticker.add(r=>{for(let i of this.tickers)i(r)});else{let r=this.config.fps?this.config.fps:30;this.tickerInterval=setInterval(()=>{for(let i of this.tickers)i(1e3/r)},1e3/r)}typeof document>"u"||(this.tickers.push(r=>{for(let i of this.binds)(i.onDownContinuous||i.fn)&&this.isPressing(i.name)&&(i.onDownContinuous?.(r),i.fn?.(r))}),document.addEventListener("keydown",r=>{this.logKey(r,!0),this.onAll("down",r.key)}),document.addEventListener("keyup",r=>{this.logKey(r,!1),this.onAll("up",r.key)}),document.addEventListener("keypress",r=>{this.onAll("press",r.key)}))}static{this.configManager=new Vt(br)}changeFps(e){this.config.fps=e,this.tickerInterval?(clearInterval(this.tickerInterval),this.tickerInterval=setInterval(()=>{for(let r of this.tickers)r(1e3/e)},1e3/e)):this.config.pixiApp&&(this.config.pixiApp.ticker.maxFPS=e)}logKey(e,r){let i=e.key;r&&!this.keysPressed.includes(i)?this.keysPressed.push(i):!r&&this.keysPressed.includes(i)&&this.keysPressed.splice(this.keysPressed.indexOf(i),1)}onAll(e,r){for(let i of this.binds)e==="down"&&i.key===r&&i.onDown&&i.onDown(),e==="press"&&i.key===r&&i.onPress&&i.onPress(),e==="up"&&i.key===r&&i.onUp&&i.onUp()}isPressing(e){for(let r=0;rr.name===e)}addKey(e,r,i){e=typeof e=="string"?[{name:e,key:r,fn:i}]:e,e=Array.isArray(e)?e:[e];for(let n of e){let s=this.getBind(n.name);if(s){Object.assign(s,n);continue}this.binds.push(n)}}},we=(t=>(t.interval="interval",t.timeout="timeout",t))(we||{}),Mr={autoAddInterval:!0,fps:30,pixiApp:void 0},Me=class je{constructor(e){if(this.addEvent=this.setEvent,this.config=je.configManager.parse(e),this.events={},this.config.autoAddInterval)if(this.config.pixiApp)this.config.pixiApp.ticker.add(()=>{this.tickerFunction()});else{let r=this.config.fps??30;this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/r)}}static{this.configManager=new Vt(Mr)}tickerFunction(){let e=Date.now();for(let r of Object.values(this.events))if(r.type==="interval"){if(e-r.intervalLast>=r.delay){let i=e-r.intervalLast;r.callbackFn(i),r.intervalLast=e}}else if(r.type==="timeout"){let i=e-r.timeCreated;e-r.timeCreated>=r.delay&&(r.callbackFn(i),delete this.events[r.name])}}changeFps(e){this.config.fps=e,this.tickerInterval?(clearInterval(this.tickerInterval),this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/e)):this.config.pixiApp&&(this.config.pixiApp.ticker.maxFPS=e)}timeWarp(e){for(let r of Object.values(this.events))r.type==="interval"&&(r.intervalLast-=e),r.type==="timeout"&&(r.timeCreated-=e)}setEvent(e,r,i,n){this.events[e]=(()=>{switch(r){case"interval":return{name:e,type:r,delay:typeof i=="number"?i:i.toNumber(),callbackFn:n,timeCreated:Date.now(),intervalLast:Date.now()};case"timeout":default:return{name:e,type:r,delay:typeof i=="number"?i:i.toNumber(),callbackFn:n,timeCreated:Date.now()}}})()}removeEvent(e){delete this.events[e]}},Zr=at(ct()),Ne=at(Ye()),Wt=at(Ve()),_e=class{constructor(t){this.data={},this.static={},this.eventsOnLoad=[],this.gameRef=typeof t=="function"?t():t}addEventOnLoad(t){this.eventsOnLoad.push(t)}setData(t,e){typeof this.data[t]>"u"&&this.normalData&&console.warn("After initializing data, you should not add new properties to data."),this.data[t]=e;let r=()=>this.data;return{get value(){return r()[t]},set value(i){r()[t]=i},setValue(i){r()[t]=i}}}getData(t){return this.data[t]}setStatic(t,e){return typeof this.static[t]>"u"&&this.normalData&&console.warn("After initializing data, you should not add new properties to staticData."),this.static[t]=e,this.static[t]}getStatic(t){return this.static[t]}init(){this.normalData=this.data,this.normalDataPlain=jt(this.data)}compileDataRaw(t=this.data){let e=jt(t),r=(0,Wt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(e)}`),i;try{i="8.1.0"}catch{i="8.0.0"}return[{hash:r,game:{title:this.gameRef.config.name.title,id:this.gameRef.config.name.id,version:this.gameRef.config.name.version},emath:{version:i}},e]}compileData(t=this.data){let e=JSON.stringify(this.compileDataRaw(t));return(0,Ne.compressToBase64)(e)}decompileData(t=window?.localStorage.getItem(`${this.gameRef.config.name.id}-data`)){if(!t)return null;let e;try{return e=JSON.parse((0,Ne.decompressFromBase64)(t)),e}catch(r){if(r instanceof SyntaxError)console.error(`Failed to decompile data (corrupted) "${t}":`,r);else throw r;return null}}validateData(t){let[e,r]=t;if(typeof e=="string")return(0,Wt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`)===e;let i=e.hash,n=(0,Wt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`);return i===n}resetData(t=!1){if(!this.normalData)throw new Error("dataManager.resetData(): You must call init() before writing to data.");this.data=this.normalData,this.saveData(),t&&window?.location.reload()}saveData(t=this.compileData()){if(!t)throw new Error("dataManager.saveData(): Data to save is empty.");if(!window.localStorage)throw new Error("dataManager.saveData(): Local storage is not supported. You can use compileData() instead to implement a custom save system.");window.localStorage.setItem(`${this.gameRef.config.name.id}-data`,t)}exportData(){let t=this.compileData();if(prompt("Download save data?:",t)!=null){let e=new Blob([t],{type:"text/plain"}),r=document.createElement("a");r.href=URL.createObjectURL(e),r.download=`${this.gameRef.config.name.id}-data.txt`,r.textContent=`Download ${this.gameRef.config.name.id}-data.txt file`,document.body.appendChild(r),r.click(),document.body.removeChild(r)}}parseData(t=this.decompileData(),e=!0){if(e&&(!this.normalData||!this.normalDataPlain))throw new Error("dataManager.parseData(): You must call init() before writing to data.");if(!t)return null;let[,r]=t;function i(y){return typeof y=="object"&&y?.constructor===Object}let n=(y,l)=>Object.prototype.hasOwnProperty.call(y,l);function s(y,l,u){let c=u;for(let p in y)if(n(y,p)&&!n(u,p)&&(c[p]=y[p]),l[p]instanceof yt){let w=y[p],I=u[p];if(Array.isArray(I.upgrades)){let k=I.upgrades;I.upgrades={};for(let F of k)I.upgrades[F.id]=F.level}I.upgrades={...w.upgrades,...I.upgrades},c[p]=I}else i(y[p])&&i(u[p])&&(c[p]=s(y[p],l[p],u[p]));return c}let h=e?s(this.normalDataPlain,this.normalData,r):r,v=Object.getOwnPropertyNames(new vt({id:"",level:P(0)}));function d(y,l){let u=oe(y,l);if(u instanceof yt)for(let c in u.upgrades){let p=u.upgrades[c];if(!p||!v.every(w=>Object.getOwnPropertyNames(p).includes(w))){delete u.upgrades[c];continue}u.upgrades[c]=oe(vt,p)}if(!u)throw new Error(`Failed to convert ${y.name} to class instance.`);return u}function f(y,l){let u=l;for(let c in y){if(!l[c]){console.warn(`Missing property "${c}" in loaded data.`);continue}if(!i(l[c]))continue;let p=y[c].constructor;if(p===Object){u[c]=f(y[c],l[c]);continue}u[c]=d(p,l[c])}return u}return h=f(this.normalData,h),h}loadData(t=this.decompileData()){if(t=typeof t=="string"?this.decompileData(t):t,!t)return null;let e=this.validateData([t[0],jt(t[1])]),r=this.parseData(t);if(!r)return null;this.data=r;for(let i of this.eventsOnLoad)i();return e}},Se=class{get data(){return this.dataPointer()}get static(){return this.staticPointer()}constructor(t,e,r,i){this.dataPointer=typeof t=="function"?t:()=>t,this.staticPointer=typeof e=="function"?e:()=>e,this.game=r,this.name=i,this.game?.dataManager.addEventOnLoad(()=>{this.static.onLoadData()})}get value(){return this.data.value}},Ae=class{constructor(t,e,r){this.data=typeof t=="function"?t():t,this.static=typeof e=="function"?e():e,this.game=r}get value(){return this.static.value}set value(t){this.data.value=t}},Oe=class{constructor(t,e){this.currenciesToReset=Array.isArray(t)?t:[t],this.extender=Array.isArray(e)?e:e?[e]:[],this.id=Symbol()}reset(){this.onReset?.(),this.currenciesToReset.forEach(t=>{t.static.reset()}),this.extender.forEach(t=>{t&&t.id!==this.id&&t.reset()})}},Ie={mode:"production",name:{title:"",id:"",version:"0.0.0"},settings:{framerate:30},initIntervalBasedManagers:!0},Nr=class Ge{static{this.configManager=new Vt(Ie)}constructor(e){this.config=Ge.configManager.parse(e),this.dataManager=new _e(this),this.keyManager=new be({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.eventManager=new Me({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.tickers=[]}init(){this.dataManager.init()}changeFps(e){this.keyManager.changeFps(e),this.eventManager.changeFps(e)}addCurrency(e){return this.dataManager.setData(e,{currency:new yt}),this.dataManager.setStatic(e,{currency:new ge(()=>this.dataManager.getData(e).currency)}),new Se(()=>this.dataManager.getData(e).currency,()=>this.dataManager.getStatic(e).currency,this,e)}addAttribute(e,r=!0,i=0){let n=this.dataManager.setData(e,new Lt(i)),s=this.dataManager.setStatic(e,new pe(this.dataManager.getData(e),r,i));return new Ae(this.dataManager.getData(e),this.dataManager.getStatic(e),this)}addReset(e,r){return new Oe(e,r)}},_r={...re,...ye};if(typeof ot.exports=="object"&&typeof At=="object"){var Sr=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Object.getOwnPropertyNames(e))!Object.prototype.hasOwnProperty.call(t,n)&&n!==r&&Object.defineProperty(t,n,{get:()=>e[n],enumerable:!(i=Object.getOwnPropertyDescriptor(e,n))||i.enumerable});return t};ot.exports=Sr(ot.exports,At)}return ot.exports}); +"use strict";(function(At,ot){var Ct=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],ot);else if(typeof module=="object"&&module.exports)module.exports=ot();else{var ft=ot(),Et=Ct?exports:At;for(var Ot in ft)Et[Ot]=ft[Ot]}})(typeof self<"u"?self:exports,()=>{var At={},ot={exports:At},Ct=Object.create,ft=Object.defineProperty,Et=Object.getOwnPropertyDescriptor,Ot=Object.getOwnPropertyNames,Ue=Object.getPrototypeOf,$e=Object.prototype.hasOwnProperty,bt=(t,e)=>function(){return e||(0,t[Ot(t)[0]])((e={exports:{}}).exports,e),e.exports},Dt=(t,e)=>{for(var r in e)ft(t,r,{get:e[r],enumerable:!0})},Kt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ot(e))!$e.call(t,n)&&n!==r&&ft(t,n,{get:()=>e[n],enumerable:!(i=Et(e,n))||i.enumerable});return t},at=(t,e,r)=>(r=t!=null?Ct(Ue(t)):{},Kt(e||!t||!t.__esModule?ft(r,"default",{value:t,enumerable:!0}):r,t)),ze=t=>Kt(ft({},"__esModule",{value:!0}),t),lt=(t,e,r,i)=>{for(var n=i>1?void 0:i?Et(e,r):e,s=t.length-1,h;s>=0;s--)(h=t[s])&&(n=(i?h(e,r,n):h(n))||n);return i&&n&&ft(e,r,n),n},ct=bt({"node_modules/reflect-metadata/Reflect.js"(){var t;(function(e){(function(r){var i=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:d(),n=s(e);typeof i.Reflect<"u"&&(n=s(i.Reflect,n)),r(n,i),typeof i.Reflect>"u"&&(i.Reflect=e);function s(l,y){return function(f,u){Object.defineProperty(l,f,{configurable:!0,writable:!0,value:u}),y&&y(f,u)}}function h(){try{return Function("return this;")()}catch{}}function v(){try{return(0,eval)("(function() { return this; })()")}catch{}}function d(){return h()||v()}})(function(r,i){var n=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",h=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",v=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",d=typeof Object.create=="function",l={__proto__:[]}instanceof Array,y=!d&&!l,f={create:d?function(){return Qt(Object.create(null))}:l?function(){return Qt({__proto__:null})}:function(){return Qt({})},has:y?function(m,b){return n.call(m,b)}:function(m,b){return b in m},get:y?function(m,b){return n.call(m,b)?m[b]:void 0}:function(m,b){return m[b]}},u=Object.getPrototypeOf(Function),c=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Lr(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Pr(),w=typeof WeakMap=="function"?WeakMap:qr(),I=s?Symbol.for("@reflect-metadata:registry"):void 0,k=Fr(),F=xr(k);function o(m,b,O,C){if(j(O)){if(!Te(m))throw new TypeError;if(!Fe(b))throw new TypeError;return tt(m,b)}else{if(!Te(m))throw new TypeError;if(!J(b))throw new TypeError;if(!J(C)&&!j(C)&&!_t(C))throw new TypeError;return _t(C)&&(C=void 0),O=ut(O),nt(m,b,O,C)}}r("decorate",o);function S(m,b){function O(C,R){if(!J(C))throw new TypeError;if(!j(R)&&!Er(R))throw new TypeError;Pt(m,b,C,R)}return O}r("metadata",S);function g(m,b,O,C){if(!J(O))throw new TypeError;return j(C)||(C=ut(C)),Pt(m,b,O,C)}r("defineMetadata",g);function A(m,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),W(m,b,O)}r("hasMetadata",A);function _(m,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),Z(m,b,O)}r("hasOwnMetadata",_);function M(m,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),X(m,b,O)}r("getMetadata",M);function E(m,b,O){if(!J(b))throw new TypeError;return j(O)||(O=ut(O)),dt(m,b,O)}r("getOwnMetadata",E);function T(m,b){if(!J(m))throw new TypeError;return j(b)||(b=ut(b)),qt(m,b)}r("getMetadataKeys",T);function G(m,b){if(!J(m))throw new TypeError;return j(b)||(b=ut(b)),Bt(m,b)}r("getOwnMetadataKeys",G);function H(m,b,O){if(!J(b))throw new TypeError;if(j(O)||(O=ut(O)),!J(b))throw new TypeError;j(O)||(O=ut(O));var C=It(b,O,!1);return j(C)?!1:C.OrdinaryDeleteMetadata(m,b,O)}r("deleteMetadata",H);function tt(m,b){for(var O=m.length-1;O>=0;--O){var C=m[O],R=C(b);if(!j(R)&&!_t(R)){if(!Fe(R))throw new TypeError;b=R}}return b}function nt(m,b,O,C){for(var R=m.length-1;R>=0;--R){var Q=m[R],et=Q(b,O,C);if(!j(et)&&!_t(et)){if(!J(et))throw new TypeError;C=et}}return C}function W(m,b,O){var C=Z(m,b,O);if(C)return!0;var R=Jt(b);return _t(R)?!1:W(m,R,O)}function Z(m,b,O){var C=It(b,O,!1);return j(C)?!1:Ee(C.OrdinaryHasOwnMetadata(m,b,O))}function X(m,b,O){var C=Z(m,b,O);if(C)return dt(m,b,O);var R=Jt(b);if(!_t(R))return X(m,R,O)}function dt(m,b,O){var C=It(b,O,!1);if(!j(C))return C.OrdinaryGetOwnMetadata(m,b,O)}function Pt(m,b,O,C){var R=It(O,C,!0);R.OrdinaryDefineOwnMetadata(m,b,O,C)}function qt(m,b){var O=Bt(m,b),C=Jt(m);if(C===null)return O;var R=qt(C,b);if(R.length<=0)return O;if(O.length<=0)return R;for(var Q=new p,et=[],$=0,x=O;$=0&&x=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:L,done:!1}}return{value:void 0,done:!0}},$.prototype.throw=function(x){throw this._index>=0&&(this._index=-1,this._keys=b,this._values=b),x},$.prototype.return=function(x){return this._index>=0&&(this._index=-1,this._keys=b,this._values=b),{value:x,done:!0}},$}(),C=function(){function $(){this._keys=[],this._values=[],this._cacheKey=m,this._cacheIndex=-2}return Object.defineProperty($.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),$.prototype.has=function(x){return this._find(x,!1)>=0},$.prototype.get=function(x){var L=this._find(x,!1);return L>=0?this._values[L]:void 0},$.prototype.set=function(x,L){var q=this._find(x,!0);return this._values[q]=L,this},$.prototype.delete=function(x){var L=this._find(x,!1);if(L>=0){for(var q=this._keys.length,B=L+1;B>>8,f[u*2+1]=p%256}return f},decompressFromUint8Array:function(l){if(l==null)return d.decompress(l);for(var y=new Array(l.length/2),f=0,u=y.length;f>1}else{for(c=1,u=0;u>1}o--,o==0&&(o=Math.pow(2,g),g++),delete w[F]}else for(c=p[F],u=0;u>1;o--,o==0&&(o=Math.pow(2,g),g++),p[k]=S++,F=String(I)}if(F!==""){if(Object.prototype.hasOwnProperty.call(w,F)){if(F.charCodeAt(0)<256){for(u=0;u>1}else{for(c=1,u=0;u>1}o--,o==0&&(o=Math.pow(2,g),g++),delete w[F]}else for(c=p[F],u=0;u>1;o--,o==0&&(o=Math.pow(2,g),g++)}for(c=2,u=0;u>1;for(;;)if(_=_<<1,M==y-1){A.push(f(_));break}else M++;return A.join("")},decompress:function(l){return l==null?"":l==""?null:d._decompress(l.length,32768,function(y){return l.charCodeAt(y)})},_decompress:function(l,y,f){var u=[],c,p=4,w=4,I=3,k="",F=[],o,S,g,A,_,M,E,T={val:f(0),position:y,index:1};for(o=0;o<3;o+=1)u[o]=o;for(g=0,_=Math.pow(2,2),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=f(T.index++)),g|=(A>0?1:0)*M,M<<=1;switch(c=g){case 0:for(g=0,_=Math.pow(2,8),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=f(T.index++)),g|=(A>0?1:0)*M,M<<=1;E=i(g);break;case 1:for(g=0,_=Math.pow(2,16),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=f(T.index++)),g|=(A>0?1:0)*M,M<<=1;E=i(g);break;case 2:return""}for(u[3]=E,S=E,F.push(E);;){if(T.index>l)return"";for(g=0,_=Math.pow(2,I),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=f(T.index++)),g|=(A>0?1:0)*M,M<<=1;switch(E=g){case 0:for(g=0,_=Math.pow(2,8),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=f(T.index++)),g|=(A>0?1:0)*M,M<<=1;u[w++]=i(g),E=w-1,p--;break;case 1:for(g=0,_=Math.pow(2,16),M=1;M!=_;)A=T.val&T.position,T.position>>=1,T.position==0&&(T.position=y,T.val=f(T.index++)),g|=(A>0?1:0)*M,M<<=1;u[w++]=i(g),E=w-1,p--;break;case 2:return F.join("")}if(p==0&&(p=Math.pow(2,I),I++),u[E])k=u[E];else if(E===w)k=S+S.charAt(0);else return null;F.push(k),u[w++]=S+k.charAt(0),p--,S=k,p==0&&(p=Math.pow(2,I),I++)}}};return d}();typeof define=="function"&&define.amd?define(function(){return r}):typeof e<"u"&&e!=null?e.exports=r:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return r})}}),Ze=bt({"node_modules/crypt/crypt.js"(t,e){(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i={rotl:function(n,s){return n<>>32-s},rotr:function(n,s){return n<<32-s|n>>>s},endian:function(n){if(n.constructor==Number)return i.rotl(n,8)&16711935|i.rotl(n,24)&4278255360;for(var s=0;s0;n--)s.push(Math.floor(Math.random()*256));return s},bytesToWords:function(n){for(var s=[],h=0,v=0;h>>5]|=n[h]<<24-v%32;return s},wordsToBytes:function(n){for(var s=[],h=0;h>>5]>>>24-h%32&255);return s},bytesToHex:function(n){for(var s=[],h=0;h>>4).toString(16)),s.push((n[h]&15).toString(16));return s.join("")},hexToBytes:function(n){for(var s=[],h=0;h>>6*(3-d)&63)):s.push("=");return s.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var s=[],h=0,v=0;h>>6-v*2);return s}};e.exports=i})()}}),te=bt({"node_modules/charenc/charenc.js"(t,e){var r={utf8:{stringToBytes:function(i){return r.bin.stringToBytes(unescape(encodeURIComponent(i)))},bytesToString:function(i){return decodeURIComponent(escape(r.bin.bytesToString(i)))}},bin:{stringToBytes:function(i){for(var n=[],s=0;s>>24)&16711935|(l[w]<<24|l[w]>>>8)&4278255360;l[y>>>5]|=128<>>9<<4)+14]=y;for(var I=h._ff,k=h._gg,F=h._hh,o=h._ii,w=0;w>>0,u=u+g>>>0,c=c+A>>>0,p=p+_>>>0}return r.endian([f,u,c,p])};h._ff=function(v,d,l,y,f,u,c){var p=v+(d&l|~d&y)+(f>>>0)+c;return(p<>>32-u)+d},h._gg=function(v,d,l,y,f,u,c){var p=v+(d&y|l&~y)+(f>>>0)+c;return(p<>>32-u)+d},h._hh=function(v,d,l,y,f,u,c){var p=v+(d^l^y)+(f>>>0)+c;return(p<>>32-u)+d},h._ii=function(v,d,l,y,f,u,c){var p=v+(l^(d|~y))+(f>>>0)+c;return(p<>>32-u)+d},h._blocksize=16,h._digestsize=16,e.exports=function(v,d){if(v==null)throw new Error("Illegal argument "+v);var l=r.wordsToBytes(h(v,d));return d&&d.asBytes?l:d&&d.asString?s.bytesToString(l):r.bytesToHex(l)}})()}}),ee={};Dt(ee,{eMath:()=>_r}),ot.exports=ze(ee);var Rr=at(ct()),jr=at(ct()),re={};Dt(re,{Attribute:()=>Lt,AttributeStatic:()=>pe,Boost:()=>$t,BoostObject:()=>Nt,Currency:()=>yt,CurrencyStatic:()=>ge,DEFAULT_ITERATIONS:()=>xt,E:()=>P,FORMATS:()=>pr,FormatTypeList:()=>er,Grid:()=>yr,GridCell:()=>ve,LRUCache:()=>Rt,ListNode:()=>ie,UpgradeData:()=>vt,UpgradeStatic:()=>me,calculateSum:()=>Yt,calculateSumApprox:()=>he,calculateSumLoop:()=>ce,calculateUpgrade:()=>Zt,decimalToJSONString:()=>kt,inverseFunctionApprox:()=>zt,roundingBase:()=>vr,upgradeToCacheNameEL:()=>Ht});var Gr=at(ct()),Rt=class{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){let e=this.map.get(t);if(e!==void 0)return e!==this.first&&(e===this.last?(this.last=e.prev,this.last.next=void 0):(e.prev.next=e.next,e.next.prev=e.prev),e.next=this.first,this.first.prev=e,this.first=e),e.value}set(t,e){if(this.maxSize<1)return;if(this.map.has(t))throw new Error("Cannot update existing keys in the cache");let r=new ie(t,e);for(this.first===void 0?(this.first=r,this.last=r):(r.next=this.first,this.first.prev=r,this.first=r),this.map.set(t,r);this.map.size>this.maxSize;){let i=this.last;this.map.delete(i.key),this.last=i.prev,this.last.next=void 0}}},ie=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},U;(function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(U||(U={}));var We=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},t.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.findTransformMetadatas=function(e,r,i){return this.findMetadatas(this._transformMetadatas,e,r).filter(function(n){return!n.options||n.options.toClassOnly===!0&&n.options.toPlainOnly===!0?!0:n.options.toClassOnly===!0?i===U.CLASS_TO_CLASS||i===U.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?i===U.CLASS_TO_PLAIN:!0})},t.prototype.findExcludeMetadata=function(e,r){return this.findMetadata(this._excludeMetadatas,e,r)},t.prototype.findExposeMetadata=function(e,r){return this.findMetadata(this._exposeMetadatas,e,r)},t.prototype.findExposeMetadataByCustomName=function(e,r){return this.getExposedMetadatas(e).find(function(i){return i.options&&i.options.name===r})},t.prototype.findTypeMetadata=function(e,r){return this.findMetadata(this._typeMetadatas,e,r)},t.prototype.getStrategy=function(e){var r=this._excludeMetadatas.get(e),i=r&&r.get(void 0),n=this._exposeMetadatas.get(e),s=n&&n.get(void 0);return i&&s||!i&&!s?"none":i?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},t.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},t.prototype.getExposedProperties=function(e,r){return this.getExposedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===U.CLASS_TO_CLASS||r===U.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===U.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.getExcludedProperties=function(e,r){return this.getExcludedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===U.CLASS_TO_CLASS||r===U.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===U.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(e,r){var i=e.get(r),n;i&&(n=Array.from(i.values()).filter(function(f){return f.propertyName!==void 0}));for(var s=[],h=0,v=this.getAncestors(r);h0&&(h=h.filter(function(f){return!l.includes(f)})),this.options.version!==void 0&&(h=h.filter(function(f){var u=rt.findExposeMetadata(e,f);return!u||!u.options?!0:n.checkVersion(u.options.since,u.options.until)})),this.options.groups&&this.options.groups.length?h=h.filter(function(f){var u=rt.findExposeMetadata(e,f);return!u||!u.options?!0:n.checkGroups(u.options.groups)}):h=h.filter(function(f){var u=rt.findExposeMetadata(e,f);return!u||!u.options||!u.options.groups||!u.options.groups.length})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(h=h.filter(function(y){return n.options.excludePrefixes.every(function(f){return y.substr(0,f.length)!==f})})),h=h.filter(function(y,f,u){return u.indexOf(y)===f}),h},t.prototype.checkVersion=function(e,r){var i=!0;return i&&e&&(i=this.options.version>=e),i&&r&&(i=this.options.versionNumber.MAX_SAFE_INTEGER)&&(A="\u03C9");let M=t.log(o,8e3).toNumber();if(g.equals(0))return A;if(g.gt(0)&&g.lte(3)){let G=[];for(let H=0;HNumber.MAX_SAFE_INTEGER)&&(A="\u03C9");let M=t.log(o,8e3).toNumber();if(g.equals(0))return A;if(g.gt(0)&&g.lte(2)){let G=[];for(let H=0;H118?e.elemental.beyondOg(_):e.elemental.config.element_lists[o-1][A]},beyondOg(o){let S=Math.floor(Math.log10(o)),g=["n","u","b","t","q","p","h","s","o","e"],A="";for(let _=S;_>=0;_--){let M=Math.floor(o/Math.pow(10,_))%10;A==""?A=g[M].toUpperCase():A+=g[M]}return A},abbreviationLength(o){return o==1?1:Math.pow(Math.floor(o/2)+1,2)*2},getAbbreviationAndValue(o){let S=o.log(118).toNumber(),g=Math.floor(S)+1,A=e.elemental.abbreviationLength(g),_=S-g+1,M=Math.floor(_*A),E=e.elemental.getAbbreviation(g,_),T=new t(118).pow(g+M/A-1);return[E,T]},formatElementalPart(o,S){return S.eq(1)?o:`${S} ${o}`},format(o,S=2){if(o.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(o.log10(),S);let g=o.log(118),_=g.log(118).log(118).toNumber(),M=Math.max(4-_*2,1),E=[];for(;g.gte(1)&&E.length=M)return E.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ");let T=new t(118).pow(g).toFixed(E.length===1?3:S);return E.length===0?T:E.length===1?`${T} \xD7 ${e.elemental.formatElementalPart(E[0][0],E[0][1])}`:`${T} \xD7 (${E.map(G=>e.elemental.formatElementalPart(G[0],G[1])).join(" + ")})`}},old_sc:{format(o,S){o=new t(o);let g=o.log10().floor();if(g.lt(9))return g.lt(3)?o.toFixed(S):o.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(o.gte("eeee10")){let _=o.slog();return(_.gte(1e9)?"":new t(10).pow(_.sub(_.floor())).toFixed(4))+"F"+e.old_sc.format(_.floor(),0)}let A=o.div(new t(10).pow(g));return(g.log10().gte(9)?"":A.toFixed(4))+"e"+e.old_sc.format(g,0)}}},eng:{format(o,S=2){o=new t(o);let g=o.log10().floor();if(g.lt(9))return g.lt(3)?o.toFixed(S):o.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(o.gte("eeee10")){let _=o.slog();return(_.gte(1e9)?"":new t(10).pow(_.sub(_.floor())).toFixed(4))+"F"+e.eng.format(_.floor(),0)}let A=o.div(new t(1e3).pow(g.div(3).floor()));return(g.log10().gte(9)?"":A.toFixed(new t(4).sub(g.sub(g.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(g.div(3).floor().mul(3),0)}}},mixed_sc:{format(o,S,g=9){o=new t(o);let A=o.log10().floor();return A.lt(303)&&A.gte(g)?d(o,S,g,"st"):d(o,S,g,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(o,S=2,g){o=new t(o);let A=o.max(1).log10().max(1).log(r.log10()).floor();if(A.lte(0))return d(o,S,g,"sc");o=new t(10).pow(o.max(1).log10().div(r.log10().pow(A)).sub(A.gte(1)?1:0));let _=A.div(10).floor(),M=A.toNumber()%10-1;return d(o,Math.max(4,S),g,"sc")+" "+(_.gte(1)?"meta"+(_.gte(2)?"^"+d(_,0,g,"sc"):"")+"-":"")+(isNaN(M)?"nanity":e.layer.layers[M])}},standard:{tier1(o){return mt[0][0][o%10]+mt[0][1][Math.floor(o/10)%10]+mt[0][2][Math.floor(o/100)]},tier2(o){let S=o%10,g=Math.floor(o/10)%10,A=Math.floor(o/100)%10,_="";return o<10?mt[1][0][o]:(g==1&&S==0?_+="Vec":_+=mt[1][1][S]+mt[1][2][g],_+=mt[1][3][A],_)}},inf:{format(o,S,g){o=new t(o);let A=0,_=new t(Number.MAX_VALUE),M=["","\u221E","\u03A9","\u03A8","\u028A"],E=["","","m","mm","mmm"];for(;o.gte(_);)o=o.log(_),A++;return A==0?d(o,S,g,"sc"):o.gte(3)?E[A]+M[A]+"\u03C9^"+d(o.sub(1),S,g,"sc"):o.gte(2)?E[A]+"\u03C9"+M[A]+"-"+d(_.pow(o.sub(2)),S,g,"sc"):E[A]+M[A]+"-"+d(_.pow(o.sub(1)),S,g,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(o,S=new t(1e15),g=!1,A=9){if(o=new t(o),S=new t(S).div(1e3),o.lt(S.mul(1e3)))return"";let{alphabet:_}=e.alphabet.config,M=_.length,E=o.log(1e3).sub(S.log(1e3)).floor(),T=E.add(1).log(M+1).ceil(),G="",H=(tt,nt)=>{let W=tt,Z="";for(let X=0;X=M)return"\u03C9";Z=_[dt]+Z,W=W.sub(1).div(M).floor()}return Z};if(T.lt(A))G=H(E,T);else{let tt=T.sub(A).add(1),nt=E.div(t.pow(M+1,tt.sub(1))).floor();G=`${H(nt,new t(A))}(${tt.gt("1e9")?tt.format():tt.format(0)})`}return G},format(o,S=2,g=9,A="mixed_sc",_=new t(1e15),M=!1,E){if(o=new t(o),_=new t(_).div(1e3),o.lt(_.mul(1e3)))return d(o,S,g,A);let T=e.alphabet.getAbbreviation(o,_,M,E),G=o.div(t.pow(1e3,o.log(1e3).floor()));return`${T.length>(E??9)+2?"":G.toFixed(S)+" "}${T}`}}},r=new t(2).pow(1024),i="\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089",n="\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079";function s(o){return o.toFixed(0).split("").map(S=>S==="-"?"\u208B":i[parseInt(S,10)]).join("")}function h(o){return o.toFixed(0).split("").map(S=>S==="-"?"\u208B":n[parseInt(S,10)]).join("")}function v(o,S=2,g=9,A="st"){return d(o,S,g,A)}function d(o,S=2,g=9,A="mixed_sc"){o=new t(o);let _=o.lt(0)?"-":"";if(o.mag==1/0)return _+"Infinity";if(Number.isNaN(o.mag))return _+"NaN";if(o.lt(0)&&(o=o.mul(-1)),o.eq(0))return o.toFixed(S);let M=o.log10().floor();switch(A){case"sc":case"scientific":if(o.log10().lt(Math.min(-S,0))&&S>1){let E=o.log10().ceil(),T=o.div(E.eq(-1)?new t(.1):new t(10).pow(E)),G=E.mul(-1).max(1).log10().gte(9);return _+(G?"":T.toFixed(2))+"e"+d(E,0,g,"mixed_sc")}else if(M.lt(g)){let E=Math.max(Math.min(S-M.toNumber(),S),0);return _+(E>0?o.toFixed(E):o.toFixed(E).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(o.gte("eeee10")){let G=o.slog();return(G.gte(1e9)?"":new t(10).pow(G.sub(G.floor())).toFixed(2))+"F"+d(G.floor(),0)}let E=o.div(new t(10).pow(M)),T=M.log10().gte(9);return _+(T?"":E.toFixed(2))+"e"+d(M,0,g,"mixed_sc")}case"st":case"standard":{let E=o.log(1e3).floor();if(E.lt(1))return _+o.toFixed(Math.max(Math.min(S-M.toNumber(),S),0));let T=E.mul(3),G=E.log10().floor();if(G.gte(3e3))return"e"+d(M,S,g,"st");let H="";if(E.lt(4))H=["","K","M","B"][Math.round(E.toNumber())];else{let W=Math.floor(E.log(1e3).toNumber());for(W<100&&(W=Math.max(W-1,0)),E=E.sub(1).div(new t(10).pow(W*3));E.gt(0);){let Z=E.div(1e3).floor(),X=E.sub(Z.mul(1e3)).floor().toNumber();X>0&&(X==1&&!W&&(H="U"),W&&(H=e.standard.tier2(W)+(H?"-"+H:"")),X>1&&(H=e.standard.tier1(X)+H)),E=Z,W++}}let tt=o.div(new t(10).pow(T)),nt=S===2?new t(2).sub(M.sub(T)).add(1).toNumber():S;return _+(G.gte(10)?"":tt.toFixed(nt)+" ")+H}default:return e[A]||console.error('Invalid format type "',A,'"'),_+e[A].format(o,S,g)}}function l(o,S,g="mixed_sc",A,_){o=new t(o),S=new t(S);let M=o.add(S),E,T=M.div(o);return T.gte(10)&&o.gte(1e100)?(T=T.log10().mul(20),E="(+"+d(T,A,_,g)+" OoMs/sec)"):E="(+"+d(S,A,_,g)+"/sec)",E}function y(o,S=2,g="s"){return o=new t(o),o.gte(86400)?d(o.div(86400).floor(),0,12,"sc")+":"+y(o.mod(86400),S,"d"):o.gte(3600)||g=="d"?(o.div(3600).gte(10)||g!="d"?"":"0")+d(o.div(3600).floor(),0,12,"sc")+":"+y(o.mod(3600),S,"h"):o.gte(60)||g=="h"?(o.div(60).gte(10)||g!="h"?"":"0")+d(o.div(60).floor(),0,12,"sc")+":"+y(o.mod(60),S,"m"):(o.gte(10)||g!="m"?"":"0")+d(o,S,12,"sc")}function f(o,S=!1,g=0,A=9,_="mixed_sc"){let M=Bt=>d(Bt,g,A,_);o=new t(o);let E=o.mul(1e3).mod(1e3).floor(),T=o.mod(60).floor(),G=o.div(60).mod(60).floor(),H=o.div(3600).mod(24).floor(),tt=o.div(86400).mod(365.2425).floor(),nt=o.div(31556952).floor(),W=nt.eq(1)?" year":" years",Z=tt.eq(1)?" day":" days",X=H.eq(1)?" hour":" hours",dt=G.eq(1)?" minute":" minutes",Pt=T.eq(1)?" second":" seconds",qt=E.eq(1)?" millisecond":" milliseconds";return`${nt.gt(0)?M(nt)+W+", ":""}${tt.gt(0)?M(tt)+Z+", ":""}${H.gt(0)?M(H)+X+", ":""}${G.gt(0)?M(G)+dt+", ":""}${T.gt(0)?M(T)+Pt+",":""}${S&&E.gt(0)?" "+M(E)+qt:""}`.replace(/,([^,]*)$/,"$1").trim()}function u(o){return o=new t(o),d(new t(1).sub(o).mul(100))+"%"}function c(o){return o=new t(o),d(o.mul(100))+"%"}function p(o,S=2){return o=new t(o),o.gte(1)?"\xD7"+o.format(S):"/"+o.pow(-1).format(S)}function w(o,S,g=10){return t.gte(o,10)?t.pow(g,t.log(o,g).pow(S)):new t(o)}function I(o,S=0){o=new t(o);let g=(E=>E.map((T,G)=>({name:T.name,altName:T.altName,value:t.pow(1e3,new t(G).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"E",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),A="",_=o.lte(0)?0:t.min(t.log(o,1e3).sub(1),g.length-1).floor().toNumber(),M=g[_];if(_===0)switch(S){case 1:A="";break;case 2:case 0:default:A=o.format();break}switch(S){case 1:A=M.name;break;case 2:A=o.divide(M.value).format();break;case 3:A=M.altName;break;case 0:default:A=`${o.divide(M.value).format()} ${M.name}`;break}return A}function k(o,S=!1){return`${I(o,2)} ${I(o,1)}eV${S?"/c^2":""}`}let F={...e,toSubscript:s,toSuperscript:h,formatST:v,format:d,formatGain:l,formatTime:y,formatTimeLong:f,formatReduction:u,formatPercent:c,formatMult:p,expMult:w,metric:I,ev:k};return{FORMATS:e,formats:F}}var Gt=17,ir=9e15,nr=Math.log10(9e15),sr=1/9e15,or=308,ar=-324,ae=5,ur=1023,lr=!0,fr=!1,cr=function(){let t=[];for(let r=ar+1;r<=or;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),gt=[2,Math.E,3,4,5,6,7,8,9,10],hr=[[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]],dr=[[-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]],N=function(e){return a.fromValue_noAlloc(e)},D=function(t,e,r){return a.fromComponents(t,e,r)},Y=function(e,r,i){return a.fromComponents_noNormalize(e,r,i)},ht=function(e,r){let i=r+1,n=Math.ceil(Math.log10(Math.abs(e))),s=Math.round(e*Math.pow(10,i-n))*Math.pow(10,n-i);return parseFloat(s.toFixed(Math.max(i-n,0)))},Ut=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},mr=function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;let e=1;for(;t<10;)e=e*t,++t;t-=1;let r=.9189385332046727;r=r+(t+.5)*Math.log(t),r=r-t;let i=t*t,n=t;return r=r+1/(12*n),n=n*i,r=r+1/(360*n),n=n*i,r=r+1/(1260*n),n=n*i,r=r+1/(1680*n),n=n*i,r=r+1/(1188*n),n=n*i,r=r+691/(360360*n),n=n*i,r=r+7/(1092*n),n=n*i,r=r+3617/(122400*n),Math.exp(r)/e},gr=.36787944117144233,ue=.5671432904097838,le=function(t,e=1e-10){let r,i;if(!Number.isFinite(t)||t===0)return t;if(t===1)return ue;t<10?r=0:r=Math.log(t)-Math.log(Math.log(t));for(let n=0;n<100;++n){if(i=(t*Math.exp(-r)+r*r)/(r+1),Math.abs(i-r).5?1:-1;if(Math.random()*20<1)return Y(e,0,1);let r=Math.floor(Math.random()*(t+1)),i=r===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let n=Math.pow(10,i);return Math.random()>.9&&(n=Math.trunc(n)),D(e,r,n)}static affordGeometricSeries_core(t,e,r,i){let n=e.mul(r.pow(i));return a.floor(t.div(n).mul(r.sub(1)).add(1).log10().div(r.log10()))}static sumGeometricSeries_core(t,e,r,i){return e.mul(r.pow(i)).mul(a.sub(1,r.pow(t))).div(a.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let s=e.add(i.mul(r)).sub(r.div(2)),h=s.pow(2);return s.neg().add(h.add(r.mul(t).mul(2)).sqrt()).div(r).floor()}static sumArithmeticSeries_core(t,e,r,i){let n=e.add(i.mul(r));return t.div(2).mul(n.mul(2).plus(t.sub(1).mul(r)))}static efficiencyOfPurchase_core(t,e,r){return t.div(e).add(t.div(r))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0||this.mag===Number.NEGATIVE_INFINITY&&this.layer>0&&Number.isFinite(this.layer))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.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_INFINITY)return this.sign==1?(this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY):this.sign==-1&&(this.mag=Number.NEGATIVE_INFINITY,this.layer=Number.NEGATIVE_INFINITY),this;if(this.layer===0&&this.mag=ir)return this.layer+=1,this.mag=e*Math.log10(t),this;for(;t0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=e*Math.pow(10,t),t=Math.abs(this.mag),e=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)),(Number.isNaN(this.sign)||Number.isNaN(this.layer)||Number.isNaN(this.mag))&&(this.sign=Number.NaN,this.layer=Number.NaN,this.mag=Number.NaN),this}fromComponents(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this.normalize(),this}fromComponents_noNormalize(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this}fromMantissaExponent(t,e){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=e+Math.log10(t),this.normalize(),this}fromMantissaExponent_noNormalize(t,e){return this.fromMantissaExponent(t,e),this}fromDecimal(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this}fromNumber(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this}fromString(t,e=!1){let r=t,i=a.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);lr?t=t.replace(",",""):fr&&(t=t.replace(",","."));let n=t.split("^^^");if(n.length===2){let w=parseFloat(n[0]),I=parseFloat(n[1]),k=n[1].split(";"),F=1;if(k.length===2&&(F=parseFloat(k[1]),isFinite(F)||(F=1)),isFinite(w)&&isFinite(I)){let o=a.pentate(w,I,F,e);return this.sign=o.sign,this.layer=o.layer,this.mag=o.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}let s=t.split("^^");if(s.length===2){let w=parseFloat(s[0]),I=parseFloat(s[1]),k=s[1].split(";"),F=1;if(k.length===2&&(F=parseFloat(k[1]),isFinite(F)||(F=1)),isFinite(w)&&isFinite(I)){let o=a.tetrate(w,I,F,e);return this.sign=o.sign,this.layer=o.layer,this.mag=o.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}let h=t.split("^");if(h.length===2){let w=parseFloat(h[0]),I=parseFloat(h[1]);if(isFinite(w)&&isFinite(I)){let k=a.pow(w,I);return this.sign=k.sign,this.layer=k.layer,this.mag=k.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}t=t.trim().toLowerCase();let v,d,l=t.split("pt");if(l.length===2){v=10,d=parseFloat(l[0]),l[1]=l[1].replace("(",""),l[1]=l[1].replace(")","");let w=parseFloat(l[1]);if(isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=a.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}if(l=t.split("p"),l.length===2){v=10,d=parseFloat(l[0]),l[1]=l[1].replace("(",""),l[1]=l[1].replace(")","");let w=parseFloat(l[1]);if(isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=a.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}if(l=t.split("f"),l.length===2){v=10,l[0]=l[0].replace("(",""),l[0]=l[0].replace(")","");let w=parseFloat(l[0]);if(l[1]=l[1].replace("(",""),l[1]=l[1].replace(")",""),d=parseFloat(l[1]),isFinite(w)||(w=1),isFinite(v)&&isFinite(d)){let I=a.tetrate(v,d,w,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}let y=t.split("e"),f=y.length-1;if(f===0){let w=parseFloat(t);if(isFinite(w))return this.fromNumber(w),a.fromStringCache.size>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}else if(f===1){let w=parseFloat(t);if(isFinite(w)&&w!==0)return this.fromNumber(w),a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}let u=t.split("e^");if(u.length===2){this.sign=1,u[0].charAt(0)=="-"&&(this.sign=-1);let w="";for(let I=0;I=43&&k<=57||k===101)w+=u[1].charAt(I);else return this.layer=parseFloat(w),this.mag=parseFloat(u[1].substr(I+1)),this.normalize(),a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}}if(f<1)return this.sign=0,this.layer=0,this.mag=0,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this;let c=parseFloat(y[0]);if(c===0)return this.sign=0,this.layer=0,this.mag=0,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this;let p=parseFloat(y[y.length-1]);if(f>=2){let w=parseFloat(y[y.length-2]);isFinite(w)&&(p*=Math.sign(w),p+=Ut(w))}if(!isFinite(c))this.sign=y[0]==="-"?-1:1,this.layer=f,this.mag=p;else if(f===1)this.sign=Math.sign(c),this.layer=1,this.mag=p+Math.log10(Math.abs(c));else if(this.sign=Math.sign(c),this.layer=f,f===2){let w=a.mul(D(1,2,p),N(c));return this.sign=w.sign,this.layer=w.layer,this.mag=w.mag,a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}else this.mag=p;return this.normalize(),a.fromStringCache.maxSize>=1&&a.fromStringCache.set(r,a.fromDecimal(this)),this}fromValue(t){return t instanceof a?this.fromDecimal(t):typeof t=="number"?this.fromNumber(t):typeof t=="string"?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===1?Number.POSITIVE_INFINITY:this.mag===Number.NEGATIVE_INFINITY&&this.layer===Number.NEGATIVE_INFINITY&&this.sign===-1?Number.NEGATIVE_INFINITY: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(t){return isNaN(this.m)?Number.NaN:this.m===0?0:ht(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:ht(this.mag,t)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_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<=ae?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(t){return this.layer===0?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)}toFixed(t){return this.layer===0?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)}toPrecision(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(t){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(t):ht(this.m,t)+"e"+ht(this.e,t):this.layer===1?ht(this.m,t)+"e"+ht(this.e,t):this.layer<=ae?(this.sign===-1?"-":"")+"e".repeat(this.layer)+ht(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+ht(this.mag,t)}abs(){return Y(this.sign===0?0:1,this.layer,this.mag)}neg(){return Y(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?a.dZero:this.layer===0?D(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?this.sign===-1?a.dNegOne:a.dZero:this.sign===-1?this.neg().ceil().neg():this.layer===0?D(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?this.sign===1?a.dOne:a.dZero:this.sign===-1?this.neg().floor().neg():this.layer===0?D(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?a.dZero:this.layer===0?D(this.sign,0,Math.trunc(this.mag)):this}add(t){let e=N(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer)||this.sign===0)return e;if(e.sign===0)return this;if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return Y(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(a.cmpabs(this,e)>0?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return a.fromNumber(r.sign*r.mag+i.sign*i.mag);let n=r.layer*Math.sign(r.mag),s=i.layer*Math.sign(i.mag);if(n-s>=2)return r;if(n===0&&s===-1){if(Math.abs(i.mag-Math.log10(r.mag))>Gt)return r;{let h=Math.pow(10,Math.log10(r.mag)-i.mag),v=i.sign+r.sign*h;return D(Math.sign(v),1,i.mag+Math.log10(Math.abs(v)))}}if(n===1&&s===0){if(Math.abs(r.mag-Math.log10(i.mag))>Gt)return r;{let h=Math.pow(10,r.mag-Math.log10(i.mag)),v=i.sign+r.sign*h;return D(Math.sign(v),1,Math.log10(i.mag)+Math.log10(Math.abs(v)))}}if(Math.abs(r.mag-i.mag)>Gt)return r;{let h=Math.pow(10,r.mag-i.mag),v=i.sign+r.sign*h;return D(Math.sign(v),1,i.mag+Math.log10(Math.abs(v)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(N(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=N(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer))return e;if(this.sign===0||e.sign===0)return Y(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return Y(this.sign*e.sign,0,1);let r,i;if(this.layer>e.layer||this.layer==e.layer&&Math.abs(this.mag)>Math.abs(e.mag)?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return a.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return D(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return D(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return D(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let n=D(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(D(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return D(r.sign*i.sign,n.layer+1,n.sign*n.mag)}if(r.layer===2&&i.layer===2){let n=D(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(D(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return D(r.sign*i.sign,n.layer+1,n.sign*n.mag)}throw Error("Bad arguments to mul: "+this+", "+t)}multiply(t){return this.mul(t)}times(t){return this.mul(t)}div(t){let e=N(t);return this.mul(e.recip())}divide(t){return this.div(t)}divideBy(t){return this.div(t)}dividedBy(t){return this.div(t)}recip(){return this.mag===0?a.dNaN:this.layer===0?D(this.sign,0,1/this.mag):D(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=N(t).abs();if(e.eq(a.dZero))return a.dZero;let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new a(r%i):this.sub(e).eq(this)?a.dZero:e.sub(this).eq(e)?this:this.sign==-1?this.abs().mod(e).neg():this.sub(this.div(e).floor().mul(e))}modulo(t){return this.mod(t)}modular(t){return this.mod(t)}cmp(t){let e=N(t);return this.sign>e.sign?1:this.sign0?this.layer:-this.layer,i=e.mag>0?e.layer:-e.layer;return r>i?1:re.mag?1:this.mag0?e:this}clamp(t,e){return this.max(t).min(e)}clampMin(t){return this.max(t)}clampMax(t){return this.min(t)}cmp_tolerance(t,e){let r=N(t);return this.eq_tolerance(r,e)?0:this.cmp(r)}compare_tolerance(t,e){return this.cmp_tolerance(t,e)}eq_tolerance(t,e){let r=N(t);if(e==null&&(e=1e-7),this.sign!==r.sign||Math.abs(this.layer-r.layer)>1)return!1;let i=this.mag,n=r.mag;return this.layer>r.layer&&(n=Ut(n)),this.layer0?D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):D(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?a.dNaN:this.layer>0?D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):D(this.sign,0,Math.log10(this.mag))}log(t){return t=N(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?a.dNaN:this.layer===0&&t.layer===0?D(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):a.div(this.log10(),t.log10())}log2(){return this.sign<=0?a.dNaN:this.layer===0?D(this.sign,0,Math.log2(this.mag)):this.layer===1?D(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?D(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?a.dNaN:this.layer===0?D(this.sign,0,Math.log(this.mag)):this.layer===1?D(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?D(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):D(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=N(t),r=this,i=e;if(r.sign===0)return i.eq(0)?Y(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return Y(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return r;let n=r.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?n.neg():Math.abs(i.toNumber()%2)%2===0?n:a.dNaN:n}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return a.dNaN;let t=this;if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return D(1,0,e);if(t.sign===0)return a.dOne;t=Y(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?D(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?D(-t.sign,t.layer+1,-t.mag):a.dOne}pow_base(t){return N(t).pow(this)}root(t){let e=N(t);return this.pow(e.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?a.exp(a.mul(this,a.ln(this).sub(1))):a.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(Y(1,0,24)))return a.fromNumber(mr(this.sign*this.mag));let t=this.mag-1,e=.9189385332046727;e=e+(t+.5)*Math.log(t),e=e-t;let r=t*t,i=t,n=12*i,s=1/n,h=e+s;if(h===e||(e=h,i=i*r,n=360*i,s=1/n,h=e-s,h===e))return a.exp(e);e=h,i=i*r,n=1260*i;let v=1/n;return e=e+v,i=i*r,n=1680*i,v=1/n,e=e-v,a.exp(e)}else return this.layer===1?a.exp(a.mul(this,a.ln(this).sub(1))):a.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?a.dOne:this.layer===0&&this.mag<=709.7?a.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?D(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?D(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):D(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return a.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return D(1,2,Math.log10(this.mag)-.3010299956639812);{let t=a.div(Y(this.sign,this.layer-1,this.mag),Y(1,0,2));return t.layer+=1,t.normalize(),t}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(t=2,e=Y(1,0,1),r=!1){if(t===1)return a.pow(this,e);if(t===0)return new a(e);if(this.eq(a.dOne))return a.dOne;if(this.eq(-1))return a.pow(this,e);if(t===Number.POSITIVE_INFINITY){let s=this.toNumber();if(s<=1.444667861009766&&s>=.06598803584531254){if(s>1.444667861009099)return a.fromNumber(Math.E);let h=a.ln(this).neg();return h.lambertw().div(h)}else return s>1.444667861009766?a.fromNumber(Number.POSITIVE_INFINITY):a.dNaN}if(this.eq(a.dZero)){let s=Math.abs((t+1)%2);return s>1&&(s=2-s),a.fromNumber(s)}if(t<0)return a.iteratedlog(e,this,-t,r);e=N(e);let i=t;t=Math.trunc(t);let n=i-t;if(this.gt(a.dZero)&&this.lte(1.444667861009766)&&(i>1e4||!r)){t=Math.min(1e4,t);for(let s=0;s1e4){let s=this.pow(e);return i<=1e4||Math.ceil(i)%2==0?e.mul(1-n).add(s.mul(n)):e.mul(n).add(s.mul(1-n))}return e}n!==0&&(e.eq(a.dOne)?this.gt(10)||r?e=this.pow(n):(e=a.fromNumber(a.tetrate_critical(this.toNumber(),n)),this.lt(2)&&(e=e.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let s=0;s3)return Y(e.sign,e.layer+(t-s-1),e.mag);if(s>1e4)return e}return e}iteratedexp(t=2,e=Y(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return a.tetrate(t,-e,this,r);t=N(t);let i=a.fromDecimal(this),n=e;e=Math.trunc(e);let s=n-e;if(i.layer-t.layer>3){let h=Math.min(e,i.layer-t.layer-3);e-=h,i.layer-=h}for(let h=0;h1e4)return i}return s>0&&s<1&&(t.eq(10)?i=i.layeradd10(-s,r):i=i.layeradd(-s,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,n=!1,s=!1,h=this.slog_internal(t,r).toNumber();for(let v=1;v1&&s!=l&&(n=!0),s=l,n?i/=2:i*=2,i=Math.abs(i)*(l?-1:1),h+=i,i===0)break}return a.fromNumber(h)}slog_internal(t=10,e=!1){if(t=N(t),t.lte(a.dZero)||t.eq(a.dOne))return a.dNaN;if(t.lt(a.dOne))return this.eq(a.dOne)?a.dZero:this.eq(a.dZero)?a.dNegOne:a.dNaN;if(this.mag<0||this.eq(a.dZero))return a.dNegOne;let r=0,i=a.fromDecimal(this);if(i.layer-t.layer>3){let n=i.layer-t.layer-3;r+=n,i.layer-=n}for(let n=0;n<100;++n)if(i.lt(a.dZero))i=a.pow(t,i),r-=1;else{if(i.lte(a.dOne))return e?a.fromNumber(r+i.toNumber()-1):a.fromNumber(r+a.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=a.log(i,t)}return a.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:a.critical_section(t,e,dr)}static tetrate_critical(t,e){return a.critical_section(t,e,hr)}static critical_section(t,e,r,i=!1){e*=10,e<0&&(e=0),e>10&&(e=10),t<2&&(t=2),t>10&&(t=10);let n=0,s=0;for(let v=0;vt){let d=(t-gt[v])/(gt[v+1]-gt[v]);n=r[v][Math.floor(e)]*(1-d)+r[v+1][Math.floor(e)]*d,s=r[v][Math.ceil(e)]*(1-d)+r[v+1][Math.ceil(e)]*d;break}let h=e-Math.floor(e);return n<=0||s<=0?n*(1-h)+s*h:Math.pow(t,Math.log(n)/Math.log(t)*(1-h)+Math.log(s)/Math.log(t)*h)}layeradd10(t,e=!1){t=a.fromValue_noAlloc(t).toNumber();let r=a.fromDecimal(this);if(t>=1){r.mag<0&&r.layer>0?(r.sign=0,r.mag=0,r.layer=0):r.sign===-1&&r.layer==0&&(r.sign=1,r.mag=-r.mag);let i=Math.trunc(t);t-=i,r.layer+=i}if(t<=-1){let i=Math.trunc(t);if(t-=i,r.layer+=i,r.layer<0)for(let n=0;n<100;++n){if(r.layer++,r.mag=Math.log10(r.mag),!isFinite(r.mag))return r.sign===0&&(r.sign=1),r.layer<0&&(r.layer=0),r.normalize();if(r.layer>=0)break}}for(;r.layer<0;)r.layer++,r.mag=Math.log10(r.mag);return r.sign===0&&(r.sign=1,r.mag===0&&r.layer>=1&&(r.layer-=1,r.mag=1)),r.normalize(),t!==0?r.layeradd(t,10,e):r}layeradd(t,e,r=!1){let n=this.slog(e).toNumber()+t;return n>=0?a.tetrate(e,n,a.dOne,r):Number.isFinite(n)?n>=-1?a.log(a.tetrate(e,n+1,a.dOne,r),e):a.log(a.log(a.tetrate(e,n+2,a.dOne,r),e),e):a.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return a.fromNumber(le(this.toNumber()));if(this.layer===0)return a.fromNumber(le(this.sign*this.mag));if(this.layer===1)return fe(this);if(this.layer===2)return fe(this);if(this.layer>=3)return Y(this.sign,this.layer-1,this.mag);throw"Unhandled behavior in lambertw()"}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(a.dInf))return a.dInf;if(!this.isFinite())return a.dNaN;if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return a.fromNumber(t).add(2).pow(this.recip());if(t<=0)return a.dNaN;if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return egr?this.pow(this.recip()):a.dNaN}if(this.eq(1))return a.dOne;if(this.lt(0))return a.dNaN;if(this.lte("1ee-16"))return t%2==1?this:a.dNaN;if(this.gt(1)){let e=a.dTen;this.gte(a.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=a.dZero,i=e.layer,n=e.iteratedlog(10,i,!0),s=n,h=n.div(2),v=!0;for(;v;)h=r.add(n).div(2),a.iteratedexp(10,i,h,!0).tetrate(t,1,!0).gt(this)?n=h:r=h,h.eq(s)?v=!1:s=h;return a.iteratedexp(10,i,h,!0)}else{let e=1,r=D(1,10,1),i=D(1,10,1),n=D(1,10,1),s=D(1,1,-16),h=a.dZero,v=D(1,10,1),d=s.pow10().recip(),l=a.dZero,y=d,f=d,u=Math.ceil(t)%2==0,c=0,p=D(1,10,1),w=!1,I=a.dZero,k=!1;for(;e<4;){if(e==2){if(u)break;n=D(1,10,1),s=r,e=3,v=D(1,10,1),p=D(1,10,1)}for(w=!1;s.neq(n);){if(I=s,s.pow10().recip().tetrate(t,1,!0).eq(1)&&s.pow10().recip().lt(.4))d=s.pow10().recip(),y=s.pow10().recip(),f=s.pow10().recip(),l=a.dZero,c=-1,e==3&&(p=s);else if(s.pow10().recip().tetrate(t,1,!0).eq(s.pow10().recip())&&!u&&s.pow10().recip().lt(.4))d=s.pow10().recip(),y=s.pow10().recip(),f=s.pow10().recip(),l=a.dZero,c=0;else if(s.pow10().recip().tetrate(t,1,!0).eq(s.pow10().recip().mul(2).tetrate(t,1,!0)))d=s.pow10().recip(),y=a.dZero,f=d.mul(2),l=d,u?c=-1:c=0;else{for(h=s.mul(12e-17),d=s.pow10().recip(),y=s.add(h).pow10().recip(),l=d.sub(y),f=d.add(l);y.tetrate(t,1,!0).eq(d.tetrate(t,1,!0))||f.tetrate(t,1,!0).eq(d.tetrate(t,1,!0))||y.gte(d)||f.lte(d);)h=h.mul(2),y=s.add(h).pow10().recip(),l=d.sub(y),f=d.add(l);if((e==1&&f.tetrate(t,1,!0).gt(d.tetrate(t,1,!0))&&y.tetrate(t,1,!0).gt(d.tetrate(t,1,!0))||e==3&&f.tetrate(t,1,!0).lt(d.tetrate(t,1,!0))&&y.tetrate(t,1,!0).lt(d.tetrate(t,1,!0)))&&(p=s),f.tetrate(t,1,!0).lt(d.tetrate(t,1,!0)))c=-1;else if(u)c=1;else if(e==3&&s.gt_tolerance(r,1e-8))c=0;else{for(;y.tetrate(t,1,!0).eq_tolerance(d.tetrate(t,1,!0),1e-8)||f.tetrate(t,1,!0).eq_tolerance(d.tetrate(t,1,!0),1e-8)||y.gte(d)||f.lte(d);)h=h.mul(2),y=s.add(h).pow10().recip(),l=d.sub(y),f=d.add(l);f.tetrate(t,1,!0).sub(d.tetrate(t,1,!0)).lt(d.tetrate(t,1,!0).sub(y.tetrate(t,1,!0)))?c=0:c=1}}if(c==-1&&(k=!0),e==1&&c==1||e==3&&c!=0)if(n.eq(D(1,10,1)))s=s.mul(2);else{let g=!1;if(w&&(c==1&&e==1||c==-1&&e==3)&&(g=!0),s=s.add(n).div(2),g)break}else if(n.eq(D(1,10,1)))n=s,s=s.div(2);else{let g=!1;if(w&&(c==1&&e==1||c==-1&&e==3)&&(g=!0),n=n.sub(v),s=s.sub(v),g)break}if(n.sub(s).div(2).abs().gt(v.mul(1.5))&&(w=!0),v=n.sub(s).div(2).abs(),s.gt("1e18")||s.eq(I))break}if(s.gt("1e18")||!k||p==D(1,10,1))break;e==1?r=p:e==3&&(i=p),e++}n=r,s=D(1,1,-18);let F=s,o=a.dZero,S=!0;for(;S;)if(n.eq(D(1,10,1))?o=s.mul(2):o=n.add(s).div(2),a.pow(10,o).recip().tetrate(t,1,!0).gt(this)?s=o:n=o,o.eq(F)?S=!1:F=o,s.gt("1e18"))return a.dNaN;if(o.eq_tolerance(r,1e-15)){if(i.eq(D(1,10,1)))return a.dNaN;for(n=D(1,10,1),s=i,F=s,o=a.dZero,S=!0;S;)if(n.eq(D(1,10,1))?o=s.mul(2):o=n.add(s).div(2),a.pow(10,o).recip().tetrate(t,1,!0).gt(this)?s=o:n=o,o.eq(F)?S=!1:F=o,s.gt("1e18"))return a.dNaN;return o.pow10().recip()}else return o.pow10().recip()}}pentate(t=2,e=Y(1,0,1),r=!1){e=N(e);let i=t;t=Math.trunc(t);let n=i-t;n!==0&&(e.eq(a.dOne)?(++t,e=a.fromNumber(n)):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let s=0;s10)return e}return e}sin(){return this.mag<0?this:this.layer===0?a.fromNumber(Math.sin(this.sign*this.mag)):Y(0,0,0)}cos(){return this.mag<0?a.dOne:this.layer===0?a.fromNumber(Math.cos(this.sign*this.mag)):Y(0,0,0)}tan(){return this.mag<0?this:this.layer===0?a.fromNumber(Math.tan(this.sign*this.mag)):Y(0,0,0)}asin(){return this.mag<0?this:this.layer===0?a.fromNumber(Math.asin(this.sign*this.mag)):Y(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?a.fromNumber(Math.acos(this.toNumber())):this.layer===0?a.fromNumber(Math.acos(this.sign*this.mag)):Y(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?a.fromNumber(Math.atan(this.sign*this.mag)):a.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 a.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return a.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?Y(Number.NaN,Number.NaN,Number.NaN):a.ln(this.add(1).div(a.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?this:this.root(a.pow(10,t))}egg(){return this.add(9)}lessThanOrEqualTo(t){return this.cmp(t)<1}lessThan(t){return this.cmp(t)<0}greaterThanOrEqualTo(t){return this.cmp(t)>-1}greaterThan(t){return this.cmp(t)>0}static smoothDamp(t,e,r,i){return new a(t).add(new a(e).minus(new a(t)).times(new a(r)).times(new a(i)))}clone(){return this}static clone(t){return a.fromComponents(t.sign,t.layer,t.mag)}softcap(t,e,r){let i=this.clone();return i.gte(t)&&([0,"pow"].includes(r)&&(i=i.div(t).pow(e).mul(t)),[1,"mul"].includes(r)&&(i=i.sub(t).div(e).add(t))),i}static softcap(t,e,r,i){return new a(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new a(t),e=new a(e);let n=this.clone();return n.gte(t)&&([0,"pow"].includes(r)&&(n=i?n.mul(t.pow(e.sub(1))).root(e):n.pow(e).div(t.pow(e.sub(1)))),[1,"exp"].includes(r)&&(n=i?n.div(t).max(1).log(e).add(t):a.pow(e,n.sub(t)).mul(t))),n}static scale(t,e,r,i,n=!1){return new a(t).scale(e,r,i,n)}format(t=2,e=9,r="mixed_sc"){return pt.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return pt.format(new a(t),e,r,i)}formatST(t=2,e=9,r="st"){return pt.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return pt.format(new a(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return pt.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,n){return pt.formatGain(new a(t),e,r,i,n)}toRoman(t=5e3){t=new a(t);let e=this.clone();if(e.gte(t)||e.lt(1))return e;let r=e.toNumber(),i={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},n="";for(let s of Object.keys(i)){let h=Math.floor(r/i[s]);r-=h*i[s],n+=s.repeat(h)}return n}static toRoman(t,e){return new a(t).toRoman(e)}static random(t=0,e=1){return t=new a(t),e=new a(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new a(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new a(Math.random()).lt(t)}};a.dZero=Y(0,0,0),a.dOne=Y(1,0,1),a.dNegOne=Y(-1,0,1),a.dTwo=Y(1,0,2),a.dTen=Y(1,0,10),a.dNaN=Y(Number.NaN,Number.NaN,Number.NaN),a.dInf=Y(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),a.dNegInf=Y(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),a.dNumberMax=D(1,0,Number.MAX_VALUE),a.dNumberMin=D(1,0,Number.MIN_VALUE),a.fromStringCache=new Rt(ur),lt([Tt()],a.prototype,"sign",2),lt([Tt()],a.prototype,"mag",2),lt([Tt()],a.prototype,"layer",2),a=lt([tr()],a);var{formats:pt,FORMATS:pr}=rr(a);a.formats=pt;var P=(()=>{let t=e=>new a(e);return Object.getOwnPropertyNames(a).filter(e=>!Object.getOwnPropertyNames(class{}).includes(e)).forEach(e=>{t[e]=a[e]}),t})(),Nt=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.value=t.value,this.order=t.order??99}},$t=class{constructor(t=1,e){this.addBoost=this.setBoost.bind(this),e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=P(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new Nt(r))})}getBoosts(t,e){let r=[],i=[];for(let n=0;nf),l=n,y=this.getBoosts(s,!0);y[0][0]?this.boostArray[y[1][0]]=new Nt({id:s,name:h,description:v,value:d,order:l}):this.boostArray.push(new Nt({id:s,name:h,description:v,value:d,order:l}))}else{t=Array.isArray(t)?t:[t];for(let s=0;si.order-n.order);for(let i=0;ie.cost(p.add(r)),u=P.min(i,zt(f,t,n,s).value.floor()),c=P(0);return[u,c]}let d=zt(f=>Yt(e.cost,f,r),t,n,s).value.floor().min(r.add(v).sub(1)),l=Yt(e.cost,d,r);return[d.sub(r).add(1).max(0),l]}function kt(t){return t=P(t),`${t.sign}/${t.mag}/${t.layer}`}function de(t,e){return`sum/${kt(t)}/${kt(e)}}`}function Ht(t){return`el/${kt(t)}`}var vt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?P(t.level):P(1)}};lt([Tt()],vt.prototype,"id",2),lt([Ft(()=>a)],vt.prototype,"level",2);var me=class De{static{this.cacheSize=63}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn()}get level(){return((this??{data:{level:P(1)}}).data??{level:P(1)}).level}set level(e){this.data.level=P(e)}constructor(e,r,i){let n=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>n,this.cache=new Rt(i??De.cacheSize),this.id=e.id,this.name=e.name??e.id,this.descriptionFn=e.description?typeof e.description=="function"?e.description:()=>e.description:()=>"",this.cost=e.cost,this.costBulk=e.costBulk,this.maxLevel=e.maxLevel,this.effect=e.effect,this.el=e.el}getCached(e,r,i){return e==="sum"?this.cache.get(de(r,i??P(0))):this.cache.get(Ht(r))}setCached(e,r,i,n){let s=e==="sum"?{id:this.id,el:!1,start:P(r),end:P(i),cost:P(n)}:{id:this.id,el:!0,level:P(r),cost:P(i)};return e==="sum"?this.cache.set(de(r,i),s):this.cache.set(Ht(r),s),s}},$r=at(ct()),yt=class{constructor(){this.value=P(0),this.upgrades={}}};lt([Ft(()=>a)],yt.prototype,"value",2),lt([Ft(()=>vt)],yt.prototype,"upgrades",2);var ge=class{get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}constructor(t=new yt,e,r={defaultVal:P(0),defaultBoost:P(1)}){this.defaultVal=r.defaultVal,this.defaultBoost=r.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new $t(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e)}onLoadData(){for(let t of Object.values(this.upgrades))t.effect?.(t.level,t)}reset(t=!0,e=!0){if(t&&(this.value=this.defaultVal),e)for(let r of Object.values(this.upgrades))r.level=P(0)}gain(t=1e3){let e=this.boost.calculate().mul(P(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new vt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r={};for(let i of t){let n=this.pointerAddUpgrade(i),s=new me(i,()=>this.pointerGetUpgrade(i.id));s.effect&&e&&s.effect(s.level,s),r[i.id]=s,this.upgrades[i.id]=s}return Object.values(r)}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&(r.name=e.name??r.name,r.cost=e.cost??r.cost,r.maxLevel=e.maxLevel??r.maxLevel,r.effect=e.effect??r.effect)}calculateUpgrade(t,e,r,i){let n=this.getUpgrade(t);return n===null?(console.warn(`Upgrade "${t}" not found.`),[P(0),P(0)]):Zt(this.value,n,n.level,e?n.level.add(e):void 0,r,i)}getNextCost(t,e=0,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),P(0);let s=Zt(this.value,n,n.level,n.level.add(e),r,i)[1];return n.cost(n.level.add(s))}buyUpgrade(t,e,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),!1;let[s,h]=this.calculateUpgrade(t,e,r,i);return s.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(h),n.level=n.level.add(s),n.effect?.(n.level,n),!0)}},zr=at(ct()),Lt=class{constructor(t=0){this.value=P(t)}};lt([Ft(()=>a)],Lt.prototype,"value",2);var pe=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=P(r),t??=new Lt(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new $t(this.initial):null}update(){console.warn("AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed."),this.boost&&(this.pointer.value=this.boost.calculate())}get value(){return this.boost&&(this.pointer.value=this.boost.calculate()),this.pointer.value}set value(t){if(this.boost)throw new Error("Cannot set value of attributeStatic when boost is enabled.");this.pointer.value=t}},ve=class{constructor(t,e,r){this.x=t,this.y=e,this.properties=r??{}}setValue(t,e){return this.properties[t]=e,e}getValue(t){return this.properties[t]}},yr=class{constructor(t,e,r){this.xSize=t,this.ySize=e,this.cells=[];for(let i=0;i_e,EventManager:()=>Me,EventTypes:()=>we,Game:()=>Nr,GameAttribute:()=>Ae,GameCurrency:()=>Se,GameReset:()=>Oe,KeyManager:()=>be,gameDefaultConfig:()=>Ie,keys:()=>wr});var Yr=at(ct()),Vt=class{constructor(t){this.configOptionTemplate=t}parse(t){if(typeof t>"u")return this.configOptionTemplate;function e(r,i){for(let n in i)typeof r[n]>"u"?r[n]=i[n]:typeof r[n]=="object"&&typeof i[n]=="object"&&!Array.isArray(r[n])&&!Array.isArray(i[n])&&(r[n]=e(r[n],i[n]));return r}return e(t,this.configOptionTemplate)}get options(){return this.configOptionTemplate}},br={autoAddInterval:!0,fps:30,pixiApp:void 0},wr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ".split("").concat(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),be=class Re{constructor(e){if(this.addKeys=this.addKey.bind(this),this.keysPressed=[],this.binds=[],this.tickers=[],this.config=Re.configManager.parse(e),this.config.autoAddInterval)if(this.config.pixiApp)this.config.pixiApp.ticker.add(r=>{for(let i of this.tickers)i(r)});else{let r=this.config.fps?this.config.fps:30;this.tickerInterval=setInterval(()=>{for(let i of this.tickers)i(1e3/r)},1e3/r)}typeof document>"u"||(this.tickers.push(r=>{for(let i of this.binds)(i.onDownContinuous||i.fn)&&this.isPressing(i.name)&&(i.onDownContinuous?.(r),i.fn?.(r))}),document.addEventListener("keydown",r=>{this.logKey(r,!0),this.onAll("down",r.key)}),document.addEventListener("keyup",r=>{this.logKey(r,!1),this.onAll("up",r.key)}),document.addEventListener("keypress",r=>{this.onAll("press",r.key)}))}static{this.configManager=new Vt(br)}changeFps(e){this.config.fps=e,this.tickerInterval?(clearInterval(this.tickerInterval),this.tickerInterval=setInterval(()=>{for(let r of this.tickers)r(1e3/e)},1e3/e)):this.config.pixiApp&&(this.config.pixiApp.ticker.maxFPS=e)}logKey(e,r){let i=e.key;r&&!this.keysPressed.includes(i)?this.keysPressed.push(i):!r&&this.keysPressed.includes(i)&&this.keysPressed.splice(this.keysPressed.indexOf(i),1)}onAll(e,r){for(let i of this.binds)e==="down"&&i.key===r&&i.onDown&&i.onDown(),e==="press"&&i.key===r&&i.onPress&&i.onPress(),e==="up"&&i.key===r&&i.onUp&&i.onUp()}isPressing(e){for(let r=0;rr.name===e)}addKey(e,r,i){e=typeof e=="string"?[{name:e,key:r,fn:i}]:e,e=Array.isArray(e)?e:[e];for(let n of e){let s=this.getBind(n.name);if(s){Object.assign(s,n);continue}this.binds.push(n)}}},we=(t=>(t.interval="interval",t.timeout="timeout",t))(we||{}),Mr={autoAddInterval:!0,fps:30,pixiApp:void 0},Me=class je{constructor(e){if(this.addEvent=this.setEvent.bind(this),this.config=je.configManager.parse(e),this.events={},this.config.autoAddInterval)if(this.config.pixiApp)this.config.pixiApp.ticker.add(()=>{this.tickerFunction()});else{let r=this.config.fps??30;this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/r)}}static{this.configManager=new Vt(Mr)}tickerFunction(){let e=Date.now();for(let r of Object.values(this.events))switch(r.type){case"interval":if(e-r.intervalLast>=r.delay){let i=e-r.intervalLast;r.callbackFn(i),r.intervalLast=e}break;case"timeout":{let i=e-r.timeCreated;e-r.timeCreated>=r.delay&&(r.callbackFn(i),delete this.events[r.name])}break}}changeFps(e){this.config.fps=e,this.tickerInterval?(clearInterval(this.tickerInterval),this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/e)):this.config.pixiApp&&(this.config.pixiApp.ticker.maxFPS=e)}timeWarp(e){for(let r of Object.values(this.events))switch(r.type){case"interval":r.intervalLast-=e;break;case"timeout":r.timeCreated-=e;break}}setEvent(e,r,i,n){this.events[e]=(()=>{switch(r){case"interval":return{name:e,type:r,delay:typeof i=="number"?i:i.toNumber(),callbackFn:n,timeCreated:Date.now(),intervalLast:Date.now()};case"timeout":default:return{name:e,type:r,delay:typeof i=="number"?i:i.toNumber(),callbackFn:n,timeCreated:Date.now()}}})()}removeEvent(e){delete this.events[e]}},Zr=at(ct()),Ne=at(Ye()),Wt=at(Ve()),_e=class{constructor(t){this.data={},this.static={},this.eventsOnLoad=[],this.gameRef=typeof t=="function"?t():t}addEventOnLoad(t){this.eventsOnLoad.push(t)}setData(t,e){typeof this.data[t]>"u"&&this.normalData&&console.warn("After initializing data, you should not add new properties to data."),this.data[t]=e;let r=()=>this.data;return{get value(){return r()[t]},set value(i){r()[t]=i},setValue(i){r()[t]=i}}}getData(t){return this.data[t]}setStatic(t,e){return typeof this.static[t]>"u"&&this.normalData&&console.warn("After initializing data, you should not add new properties to staticData."),this.static[t]=e,this.static[t]}getStatic(t){return this.static[t]}init(){this.normalData=this.data,this.normalDataPlain=jt(this.data)}compileDataRaw(t=this.data){let e=jt(t),r=(0,Wt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(e)}`),i;try{i="8.1.0"}catch{i="8.0.0"}return[{hash:r,game:{title:this.gameRef.config.name.title,id:this.gameRef.config.name.id,version:this.gameRef.config.name.version},emath:{version:i}},e]}compileData(t=this.data){let e=JSON.stringify(this.compileDataRaw(t));return(0,Ne.compressToBase64)(e)}decompileData(t=window.localStorage.getItem(`${this.gameRef.config.name.id}-data`)){if(!t)return null;let e;try{return e=JSON.parse((0,Ne.decompressFromBase64)(t)),e}catch(r){if(r instanceof SyntaxError)console.error(`Failed to decompile data (corrupted) "${t}":`,r);else throw r;return null}}validateData(t){let[e,r]=t;if(typeof e=="string")return(0,Wt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`)===e;let i=e.hash,n=(0,Wt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`);return i===n}resetData(t=!1){if(!this.normalData)throw new Error("dataManager.resetData(): You must call init() before writing to data.");this.data=this.normalData,this.saveData(),t&&window.location.reload()}saveData(t=this.compileData()){if(!t)throw new Error("dataManager.saveData(): Data to save is empty.");if(!window.localStorage)throw new Error("dataManager.saveData(): Local storage is not supported. You can use compileData() instead to implement a custom save system.");window.localStorage.setItem(`${this.gameRef.config.name.id}-data`,t)}exportData(){let t=this.compileData();if(prompt("Download save data?:",t)!=null){let e=new Blob([t],{type:"text/plain"}),r=document.createElement("a");r.href=URL.createObjectURL(e),r.download=`${this.gameRef.config.name.id}-data.txt`,r.textContent=`Download ${this.gameRef.config.name.id}-data.txt file`,document.body.appendChild(r),r.click(),document.body.removeChild(r)}}parseData(t=this.decompileData(),e=!0){if((!this.normalData||!this.normalDataPlain)&&e)throw new Error("dataManager.parseData(): You must call init() before writing to data.");if(!t)return null;let[,r]=t;function i(y){return typeof y=="object"&&y?.constructor===Object}let n=(y,f)=>Object.prototype.hasOwnProperty.call(y,f);function s(y,f,u){let c=u;for(let p in y)if(n(y,p)&&!n(u,p)&&(c[p]=y[p]),f[p]instanceof yt){let w=y[p],I=u[p];if(Array.isArray(I.upgrades)){let k=I.upgrades;I.upgrades={};for(let F of k)I.upgrades[F.id]=F}I.upgrades={...w.upgrades,...I.upgrades},c[p]=I}else i(y[p])&&i(u[p])&&(c[p]=s(y[p],f[p],u[p]));return c}let h=e?s(this.normalDataPlain,this.normalData,r):r,v=Object.getOwnPropertyNames(new vt({id:"",level:P(0)}));function d(y,f){let u=oe(y,f);if(u instanceof yt)for(let c in u.upgrades){let p=u.upgrades[c];if(!p||!v.every(w=>Object.getOwnPropertyNames(p).includes(w))){delete u.upgrades[c];continue}u.upgrades[c]=oe(vt,p)}if(!u)throw new Error(`Failed to convert ${y.name} to class instance.`);return u}function l(y,f){let u=f;for(let c in y){if(!f[c]){console.warn(`Missing property "${c}" in loaded data.`);continue}if(!i(f[c]))continue;let p=y[c].constructor;if(p===Object){u[c]=l(y[c],f[c]);continue}u[c]=d(p,f[c])}return u}return h=l(this.normalData,h),h}loadData(t=this.decompileData()){if(t=typeof t=="string"?this.decompileData(t):t,!t)return null;let e=this.validateData([t[0],jt(t[1])]),r=this.parseData(t);if(!r)return null;this.data=r;for(let i of this.eventsOnLoad)i();return e}},Se=class{get data(){return this.dataPointer()}get static(){return this.staticPointer()}constructor(t,e,r,i){this.dataPointer=typeof t=="function"?t:()=>t,this.staticPointer=typeof e=="function"?e:()=>e,this.game=r,this.name=i,this.game.dataManager.addEventOnLoad(()=>{this.static.onLoadData()})}get value(){return this.data.value}},Ae=class{constructor(t,e,r){this.data=typeof t=="function"?t():t,this.static=typeof e=="function"?e():e,this.game=r}get value(){return this.static.value}set value(t){this.data.value=t}},Oe=class{constructor(t,e){this.currenciesToReset=Array.isArray(t)?t:[t],this.extender=Array.isArray(e)?e:e?[e]:[],this.id=Symbol()}reset(){this.onReset?.(),this.currenciesToReset.forEach(t=>{t.static.reset()}),this.extender.forEach(t=>{t.id!==this.id&&t.reset()})}},Ie={mode:"production",name:{title:"",id:"",version:"0.0.0"},settings:{framerate:30},initIntervalBasedManagers:!0},Nr=class Ge{static{this.configManager=new Vt(Ie)}constructor(e){this.config=Ge.configManager.parse(e),this.dataManager=new _e(this),this.keyManager=new be({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.eventManager=new Me({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.tickers=[]}init(){this.dataManager.init()}changeFps(e){this.keyManager.changeFps(e),this.eventManager.changeFps(e)}addCurrency(e){return this.dataManager.setData(e,{currency:new yt}),this.dataManager.setStatic(e,{currency:new ge(()=>this.dataManager.getData(e).currency)}),new Se(()=>this.dataManager.getData(e).currency,()=>this.dataManager.getStatic(e).currency,this,e)}addAttribute(e,r=!0,i=0){let n=this.dataManager.setData(e,new Lt(i)),s=this.dataManager.setStatic(e,new pe(this.dataManager.getData(e),r,i));return new Ae(this.dataManager.getData(e),this.dataManager.getStatic(e),this)}addReset(e,r){return new Oe(e,r)}},_r={...re,...ye};if(typeof ot.exports=="object"&&typeof At=="object"){var Sr=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Object.getOwnPropertyNames(e))!Object.prototype.hasOwnProperty.call(t,n)&&n!==r&&Object.defineProperty(t,n,{get:()=>e[n],enumerable:!(i=Object.getOwnPropertyDescriptor(e,n))||i.enumerable});return t};ot.exports=Sr(ot.exports,At)}return ot.exports}); /*! Bundled license information: reflect-metadata/Reflect.js: diff --git a/dist/game/eMath.game.mjs b/dist/game/eMath.game.mjs index 1ff51d89..01ff0ca5 100644 --- a/dist/game/eMath.game.mjs +++ b/dist/game/eMath.game.mjs @@ -1448,7 +1448,7 @@ function decimalFormatGenerator(Decimal2) { default: if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); - return neg + FORMATS2[type]?.format(ex, acc, max); + return neg + FORMATS2[type].format(ex, acc, max); } } function formatGain(amt, gain, type = "mixed_sc", acc, max) { @@ -1578,7 +1578,7 @@ function decimalFormatGenerator(Decimal2) { output = abbMax["name"]; break; case 2: - output = `${num.divide(abbMax["value"]).format()}`; + output = num.divide(abbMax["value"]).format(); break; case 3: output = abbMax["altName"]; @@ -5477,7 +5477,7 @@ var Boost = class { * @alias setBoost * @deprecated Use {@link setBoost} instead. */ - this.addBoost = this.setBoost; + this.addBoost = this.setBoost.bind(this); boosts = boosts ? Array.isArray(boosts) ? boosts : [boosts] : void 0; this.baseEffect = E(baseEffect); this.boostArray = []; @@ -5777,7 +5777,7 @@ var UpgradeStatic = class _UpgradeStatic { } getCached(type, start, end) { if (type === "sum") { - return this.cache.get(upgradeToCacheNameSum(start, end)); + return this.cache.get(upgradeToCacheNameSum(start, end ?? E(0))); } else { return this.cache.get(upgradeToCacheNameEL(start)); } @@ -5860,7 +5860,6 @@ var CurrencyStatic = class { }; if (upgrades) this.addUpgrade(upgrades); - this.upgrades = this.upgrades; } /** * Updates / applies effects to the currency on load. @@ -6183,7 +6182,7 @@ var KeyManager = class _KeyManager { */ constructor(config) { /** @deprecated Use {@link addKey} instead. */ - this.addKeys = this.addKey; + this.addKeys = this.addKey.bind(this); this.keysPressed = []; this.binds = []; this.tickers = []; @@ -6336,7 +6335,7 @@ var EventManager = class _EventManager { * @deprecated Use {@link EventManager.setEvent} instead. * @alias eventManager.setEvent */ - this.addEvent = this.setEvent; + this.addEvent = this.setEvent.bind(this); this.config = _EventManager.configManager.parse(config); this.events = {}; if (this.config.autoAddInterval) { @@ -6362,18 +6361,27 @@ var EventManager = class _EventManager { tickerFunction() { const currentTime = Date.now(); for (const event of Object.values(this.events)) { - if (event.type === "interval") { - if (currentTime - event.intervalLast >= event.delay) { - const dt = currentTime - event.intervalLast; - event.callbackFn(dt); - event.intervalLast = currentTime; - } - } else if (event.type === "timeout") { - const dt = currentTime - event.timeCreated; - if (currentTime - event.timeCreated >= event.delay) { - event.callbackFn(dt); - delete this.events[event.name]; - } + switch (event.type) { + case "interval" /* interval */: + { + if (currentTime - event.intervalLast >= event.delay) { + const dt = currentTime - event.intervalLast; + event.callbackFn(dt); + event.intervalLast = currentTime; + } + } + ; + break; + case "timeout" /* timeout */: + { + const dt = currentTime - event.timeCreated; + if (currentTime - event.timeCreated >= event.delay) { + event.callbackFn(dt); + delete this.events[event.name]; + } + } + ; + break; } } } @@ -6398,11 +6406,19 @@ var EventManager = class _EventManager { */ timeWarp(dt) { for (const event of Object.values(this.events)) { - if (event.type === "interval") { - event.intervalLast -= dt; - } - if (event.type === "timeout") { - event.timeCreated -= dt; + switch (event.type) { + case "interval" /* interval */: + { + event.intervalLast -= dt; + } + ; + break; + case "timeout" /* timeout */: + { + event.timeCreated -= dt; + } + ; + break; } } } @@ -6610,7 +6626,7 @@ var DataManager = class { * @param data - The data to decompile. If not provided, it will be fetched from localStorage using the key `${game.config.name.id}-data`. * @returns The decompiled object, or null if the data is empty or invalid. */ - decompileData(data = window?.localStorage.getItem(`${this.gameRef.config.name.id}-data`)) { + decompileData(data = window.localStorage.getItem(`${this.gameRef.config.name.id}-data`)) { if (!data) return null; let parsedData; @@ -6650,7 +6666,7 @@ var DataManager = class { this.data = this.normalData; this.saveData(); if (reload) - window?.location.reload(); + window.location.reload(); } /** * Saves the game data to local storage under the key `${game.config.name.id}-data`. @@ -6689,7 +6705,7 @@ var DataManager = class { * @returns The loaded data. */ parseData(dataToParse = this.decompileData(), mergeData = true) { - if (mergeData && (!this.normalData || !this.normalDataPlain)) + if ((!this.normalData || !this.normalDataPlain) && mergeData) throw new Error("dataManager.parseData(): You must call init() before writing to data."); if (!dataToParse) return null; @@ -6711,7 +6727,7 @@ var DataManager = class { const upgrades = targetCurrency.upgrades; targetCurrency.upgrades = {}; for (const upgrade of upgrades) { - targetCurrency.upgrades[upgrade.id] = upgrade.level; + targetCurrency.upgrades[upgrade.id] = upgrade; } } targetCurrency.upgrades = { ...sourceCurrency.upgrades, ...targetCurrency.upgrades }; @@ -6804,7 +6820,7 @@ var GameCurrency = class { this.staticPointer = typeof staticPointer === "function" ? staticPointer : () => staticPointer; this.game = gamePointer; this.name = name; - this.game?.dataManager.addEventOnLoad(() => { + this.game.dataManager.addEventOnLoad(() => { this.static.onLoadData(); }); } @@ -6877,7 +6893,7 @@ var GameReset = class { currency.static.reset(); }); this.extender.forEach((extender) => { - if (extender && extender.id !== this.id) { + if (extender.id !== this.id) { extender.reset(); } }); diff --git a/dist/main/eMath.js b/dist/main/eMath.js index e863e7bb..a9aa5c8d 100644 --- a/dist/main/eMath.js +++ b/dist/main/eMath.js @@ -762,7 +762,7 @@ function decimalFormatGenerator(Decimal2) { default: if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); - return neg + FORMATS2[type]?.format(ex, acc, max); + return neg + FORMATS2[type].format(ex, acc, max); } } function formatGain(amt, gain, type = "mixed_sc", acc, max) { @@ -892,7 +892,7 @@ function decimalFormatGenerator(Decimal2) { output = abbMax["name"]; break; case 2: - output = `${num.divide(abbMax["value"]).format()}`; + output = num.divide(abbMax["value"]).format(); break; case 3: output = abbMax["altName"]; @@ -4787,7 +4787,7 @@ var Boost = class { * @alias setBoost * @deprecated Use {@link setBoost} instead. */ - this.addBoost = this.setBoost; + this.addBoost = this.setBoost.bind(this); boosts = boosts ? Array.isArray(boosts) ? boosts : [boosts] : void 0; this.baseEffect = E(baseEffect); this.boostArray = []; @@ -5098,7 +5098,7 @@ var UpgradeStatic = class _UpgradeStatic { } getCached(type, start, end) { if (type === "sum") { - return this.cache.get(upgradeToCacheNameSum(start, end)); + return this.cache.get(upgradeToCacheNameSum(start, end ?? E(0))); } else { return this.cache.get(upgradeToCacheNameEL(start)); } @@ -5183,7 +5183,6 @@ var CurrencyStatic = class { }; if (upgrades) this.addUpgrade(upgrades); - this.upgrades = this.upgrades; } /** * Updates / applies effects to the currency on load. diff --git a/dist/main/eMath.min.js b/dist/main/eMath.min.js index 9ead4ec0..fb25493b 100644 --- a/dist/main/eMath.min.js +++ b/dist/main/eMath.min.js @@ -1,4 +1,4 @@ -"use strict";(function(pt,nt){var wt=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],nt);else if(typeof module=="object"&&module.exports)module.exports=nt();else{var ot=nt(),_t=wt?exports:pt;for(var yt in ot)_t[yt]=ot[yt]}})(typeof self<"u"?self:exports,()=>{var pt={},nt={exports:pt},wt=Object.create,ot=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,yt=Object.getOwnPropertyNames,pe=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty,be=(t,e)=>function(){return e||(0,t[yt(t)[0]])((e={exports:{}}).exports,e),e.exports},Zt=(t,e)=>{for(var r in e)ot(t,r,{get:e[r],enumerable:!0})},zt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of yt(e))!ye.call(t,n)&&n!==r&&ot(t,n,{get:()=>e[n],enumerable:!(i=_t(e,n))||i.enumerable});return t},bt=(t,e,r)=>(r=t!=null?wt(pe(t)):{},zt(e||!t||!t.__esModule?ot(r,"default",{value:t,enumerable:!0}):r,t)),ve=t=>zt(ot({},"__esModule",{value:!0}),t),at=(t,e,r,i)=>{for(var n=i>1?void 0:i?_t(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&ot(e,r,n),n},vt=be({"node_modules/reflect-metadata/Reflect.js"(){var t;(function(e){(function(r){var i=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:g(),n=o(e);typeof i.Reflect<"u"&&(n=o(i.Reflect,n)),r(n,i),typeof i.Reflect>"u"&&(i.Reflect=e);function o(N,P){return function(T,U){Object.defineProperty(N,T,{configurable:!0,writable:!0,value:U}),P&&P(T,U)}}function c(){try{return Function("return this;")()}catch{}}function p(){try{return(0,eval)("(function() { return this; })()")}catch{}}function g(){return c()||p()}})(function(r,i){var n=Object.prototype.hasOwnProperty,o=typeof Symbol=="function",c=o&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",p=o&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",g=typeof Object.create=="function",N={__proto__:[]}instanceof Array,P=!g&&!N,T={create:g?function(){return Yt(Object.create(null))}:N?function(){return Yt({__proto__:null})}:function(){return Yt({})},has:P?function(u,l){return n.call(u,l)}:function(u,l){return l in u},get:P?function(u,l){return n.call(u,l)?u[l]:void 0}:function(u,l){return u[l]}},U=Object.getPrototypeOf(Function),x=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Je(),Z=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Ke(),C=typeof WeakMap=="function"?WeakMap:tr(),k=o?Symbol.for("@reflect-metadata:registry"):void 0,Y=We(),W=De(Y);function a(u,l,h,y){if(q(h)){if(!oe(u))throw new TypeError;if(!ue(l))throw new TypeError;return J(u,l)}else{if(!oe(u))throw new TypeError;if(!z(l))throw new TypeError;if(!z(y)&&!q(y)&&!gt(y))throw new TypeError;return gt(y)&&(y=void 0),h=st(h),rt(u,l,h,y)}}r("decorate",a);function d(u,l){function h(y,E){if(!z(y))throw new TypeError;if(!q(E)&&!He(E))throw new TypeError;Et(u,l,y,E)}return h}r("metadata",d);function m(u,l,h,y){if(!z(h))throw new TypeError;return q(y)||(y=st(y)),Et(u,l,h,y)}r("defineMetadata",m);function b(u,l,h){if(!z(l))throw new TypeError;return q(h)||(h=st(h)),Q(u,l,h)}r("hasMetadata",b);function w(u,l,h){if(!z(l))throw new TypeError;return q(h)||(h=st(h)),K(u,l,h)}r("hasOwnMetadata",w);function O(u,l,h){if(!z(l))throw new TypeError;return q(h)||(h=st(h)),tt(u,l,h)}r("getMetadata",O);function _(u,l,h){if(!z(l))throw new TypeError;return q(h)||(h=st(h)),lt(u,l,h)}r("getOwnMetadata",_);function R(u,l){if(!z(u))throw new TypeError;return q(l)||(l=st(l)),Tt(u,l)}r("getMetadataKeys",R);function L(u,l){if(!z(u))throw new TypeError;return q(l)||(l=st(l)),Ct(u,l)}r("getOwnMetadataKeys",L);function j(u,l,h){if(!z(l))throw new TypeError;if(q(h)||(h=st(h)),!z(l))throw new TypeError;q(h)||(h=st(h));var y=Mt(l,h,!1);return q(y)?!1:y.OrdinaryDeleteMetadata(u,l,h)}r("deleteMetadata",j);function J(u,l){for(var h=u.length-1;h>=0;--h){var y=u[h],E=y(l);if(!q(E)&&!gt(E)){if(!ue(E))throw new TypeError;l=E}}return l}function rt(u,l,h,y){for(var E=u.length-1;E>=0;--E){var H=u[E],D=H(l,h,y);if(!q(D)&&!gt(D)){if(!z(D))throw new TypeError;y=D}}return y}function Q(u,l,h){var y=K(u,l,h);if(y)return!0;var E=$t(l);return gt(E)?!1:Q(u,E,h)}function K(u,l,h){var y=Mt(l,h,!1);return q(y)?!1:ae(y.OrdinaryHasOwnMetadata(u,l,h))}function tt(u,l,h){var y=K(u,l,h);if(y)return lt(u,l,h);var E=$t(l);if(!gt(E))return tt(u,E,h)}function lt(u,l,h){var y=Mt(l,h,!1);if(!q(y))return y.OrdinaryGetOwnMetadata(u,l,h)}function Et(u,l,h,y){var E=Mt(h,y,!0);E.OrdinaryDefineOwnMetadata(u,l,h,y)}function Tt(u,l){var h=Ct(u,l),y=$t(u);if(y===null)return h;var E=Tt(y,l);if(E.length<=0)return h;if(h.length<=0)return E;for(var H=new Z,D=[],B=0,v=h;B=0&&v=this._keys.length?(this._index=-1,this._keys=l,this._values=l):this._index++,{value:M,done:!1}}return{value:void 0,done:!0}},B.prototype.throw=function(v){throw this._index>=0&&(this._index=-1,this._keys=l,this._values=l),v},B.prototype.return=function(v){return this._index>=0&&(this._index=-1,this._keys=l,this._values=l),{value:v,done:!0}},B}(),y=function(){function B(){this._keys=[],this._values=[],this._cacheKey=u,this._cacheIndex=-2}return Object.defineProperty(B.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),B.prototype.has=function(v){return this._find(v,!1)>=0},B.prototype.get=function(v){var M=this._find(v,!1);return M>=0?this._values[M]:void 0},B.prototype.set=function(v,M){var S=this._find(v,!0);return this._values[S]=M,this},B.prototype.delete=function(v){var M=this._find(v,!1);if(M>=0){for(var S=this._keys.length,F=M+1;FXt}),nt.exports=ve(Ht);var ir=bt(vt()),Xt={};Zt(Xt,{Attribute:()=>Ut,AttributeStatic:()=>Re,Boost:()=>Lt,BoostObject:()=>mt,Currency:()=>At,CurrencyStatic:()=>Ve,DEFAULT_ITERATIONS:()=>Ot,E:()=>I,FORMATS:()=>Be,FormatTypeList:()=>we,Grid:()=>Ue,GridCell:()=>ne,LRUCache:()=>Pt,ListNode:()=>Wt,UpgradeData:()=>Nt,UpgradeStatic:()=>ie,calculateSum:()=>Gt,calculateSumApprox:()=>ee,calculateSumLoop:()=>te,calculateUpgrade:()=>Vt,decimalToJSONString:()=>Ft,inverseFunctionApprox:()=>Bt,roundingBase:()=>Ge,upgradeToCacheNameEL:()=>Rt});var nr=bt(vt()),Pt=class{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){let e=this.map.get(t);if(e!==void 0)return e!==this.first&&(e===this.last?(this.last=e.prev,this.last.next=void 0):(e.prev.next=e.next,e.next.prev=e.prev),e.next=this.first,this.first.prev=e,this.first=e),e.value}set(t,e){if(this.maxSize<1)return;if(this.map.has(t))throw new Error("Cannot update existing keys in the cache");let r=new Wt(t,e);for(this.first===void 0?(this.first=r,this.last=r):(r.next=this.first,this.first.prev=r,this.first=r),this.map.set(t,r);this.map.size>this.maxSize;){let i=this.last;this.map.delete(i.key),this.last=i.prev,this.last.next=void 0}}},Wt=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},et;(function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(et||(et={}));var Ne=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},t.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.findTransformMetadatas=function(e,r,i){return this.findMetadatas(this._transformMetadatas,e,r).filter(function(n){return!n.options||n.options.toClassOnly===!0&&n.options.toPlainOnly===!0?!0:n.options.toClassOnly===!0?i===et.CLASS_TO_CLASS||i===et.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?i===et.CLASS_TO_PLAIN:!0})},t.prototype.findExcludeMetadata=function(e,r){return this.findMetadata(this._excludeMetadatas,e,r)},t.prototype.findExposeMetadata=function(e,r){return this.findMetadata(this._exposeMetadatas,e,r)},t.prototype.findExposeMetadataByCustomName=function(e,r){return this.getExposedMetadatas(e).find(function(i){return i.options&&i.options.name===r})},t.prototype.findTypeMetadata=function(e,r){return this.findMetadata(this._typeMetadatas,e,r)},t.prototype.getStrategy=function(e){var r=this._excludeMetadatas.get(e),i=r&&r.get(void 0),n=this._exposeMetadatas.get(e),o=n&&n.get(void 0);return i&&o||!i&&!o?"none":i?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},t.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},t.prototype.getExposedProperties=function(e,r){return this.getExposedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===et.CLASS_TO_CLASS||r===et.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===et.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.getExcludedProperties=function(e,r){return this.getExcludedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===et.CLASS_TO_CLASS||r===et.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===et.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(e,r){var i=e.get(r),n;i&&(n=Array.from(i.values()).filter(function(T){return T.propertyName!==void 0}));for(var o=[],c=0,p=this.getAncestors(r);cNumber.MAX_SAFE_INTEGER)&&(b="\u03C9");let O=t.log(a,8e3).toNumber();if(m.equals(0))return b;if(m.gt(0)&&m.lte(3)){let L=[];for(let j=0;jNumber.MAX_SAFE_INTEGER)&&(b="\u03C9");let O=t.log(a,8e3).toNumber();if(m.equals(0))return b;if(m.gt(0)&&m.lte(2)){let L=[];for(let j=0;j118?e.elemental.beyondOg(w):e.elemental.config.element_lists[a-1][b]},beyondOg(a){let d=Math.floor(Math.log10(a)),m=["n","u","b","t","q","p","h","s","o","e"],b="";for(let w=d;w>=0;w--){let O=Math.floor(a/Math.pow(10,w))%10;b==""?b=m[O].toUpperCase():b+=m[O]}return b},abbreviationLength(a){return a==1?1:Math.pow(Math.floor(a/2)+1,2)*2},getAbbreviationAndValue(a){let d=a.log(118).toNumber(),m=Math.floor(d)+1,b=e.elemental.abbreviationLength(m),w=d-m+1,O=Math.floor(w*b),_=e.elemental.getAbbreviation(m,w),R=new t(118).pow(m+O/b-1);return[_,R]},formatElementalPart(a,d){return d.eq(1)?a:`${d} ${a}`},format(a,d=2){if(a.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(a.log10(),d);let m=a.log(118),w=m.log(118).log(118).toNumber(),O=Math.max(4-w*2,1),_=[];for(;m.gte(1)&&_.length=O)return _.map(L=>e.elemental.formatElementalPart(L[0],L[1])).join(" + ");let R=new t(118).pow(m).toFixed(_.length===1?3:d);return _.length===0?R:_.length===1?`${R} \xD7 ${e.elemental.formatElementalPart(_[0][0],_[0][1])}`:`${R} \xD7 (${_.map(L=>e.elemental.formatElementalPart(L[0],L[1])).join(" + ")})`}},old_sc:{format(a,d){a=new t(a);let m=a.log10().floor();if(m.lt(9))return m.lt(3)?a.toFixed(d):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let w=a.slog();return(w.gte(1e9)?"":new t(10).pow(w.sub(w.floor())).toFixed(4))+"F"+e.old_sc.format(w.floor(),0)}let b=a.div(new t(10).pow(m));return(m.log10().gte(9)?"":b.toFixed(4))+"e"+e.old_sc.format(m,0)}}},eng:{format(a,d=2){a=new t(a);let m=a.log10().floor();if(m.lt(9))return m.lt(3)?a.toFixed(d):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let w=a.slog();return(w.gte(1e9)?"":new t(10).pow(w.sub(w.floor())).toFixed(4))+"F"+e.eng.format(w.floor(),0)}let b=a.div(new t(1e3).pow(m.div(3).floor()));return(m.log10().gte(9)?"":b.toFixed(new t(4).sub(m.sub(m.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(m.div(3).floor().mul(3),0)}}},mixed_sc:{format(a,d,m=9){a=new t(a);let b=a.log10().floor();return b.lt(303)&&b.gte(m)?g(a,d,m,"st"):g(a,d,m,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(a,d=2,m){a=new t(a);let b=a.max(1).log10().max(1).log(r.log10()).floor();if(b.lte(0))return g(a,d,m,"sc");a=new t(10).pow(a.max(1).log10().div(r.log10().pow(b)).sub(b.gte(1)?1:0));let w=b.div(10).floor(),O=b.toNumber()%10-1;return g(a,Math.max(4,d),m,"sc")+" "+(w.gte(1)?"meta"+(w.gte(2)?"^"+g(w,0,m,"sc"):"")+"-":"")+(isNaN(O)?"nanity":e.layer.layers[O])}},standard:{tier1(a){return ft[0][0][a%10]+ft[0][1][Math.floor(a/10)%10]+ft[0][2][Math.floor(a/100)]},tier2(a){let d=a%10,m=Math.floor(a/10)%10,b=Math.floor(a/100)%10,w="";return a<10?ft[1][0][a]:(m==1&&d==0?w+="Vec":w+=ft[1][1][d]+ft[1][2][m],w+=ft[1][3][b],w)}},inf:{format(a,d,m){a=new t(a);let b=0,w=new t(Number.MAX_VALUE),O=["","\u221E","\u03A9","\u03A8","\u028A"],_=["","","m","mm","mmm"];for(;a.gte(w);)a=a.log(w),b++;return b==0?g(a,d,m,"sc"):a.gte(3)?_[b]+O[b]+"\u03C9^"+g(a.sub(1),d,m,"sc"):a.gte(2)?_[b]+"\u03C9"+O[b]+"-"+g(w.pow(a.sub(2)),d,m,"sc"):_[b]+O[b]+"-"+g(w.pow(a.sub(1)),d,m,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(a,d=new t(1e15),m=!1,b=9){if(a=new t(a),d=new t(d).div(1e3),a.lt(d.mul(1e3)))return"";let{alphabet:w}=e.alphabet.config,O=w.length,_=a.log(1e3).sub(d.log(1e3)).floor(),R=_.add(1).log(O+1).ceil(),L="",j=(J,rt)=>{let Q=J,K="";for(let tt=0;tt=O)return"\u03C9";K=w[lt]+K,Q=Q.sub(1).div(O).floor()}return K};if(R.lt(b))L=j(_,R);else{let J=R.sub(b).add(1),rt=_.div(t.pow(O+1,J.sub(1))).floor();L=`${j(rt,new t(b))}(${J.gt("1e9")?J.format():J.format(0)})`}return L},format(a,d=2,m=9,b="mixed_sc",w=new t(1e15),O=!1,_){if(a=new t(a),w=new t(w).div(1e3),a.lt(w.mul(1e3)))return g(a,d,m,b);let R=e.alphabet.getAbbreviation(a,w,O,_),L=a.div(t.pow(1e3,a.log(1e3).floor()));return`${R.length>(_??9)+2?"":L.toFixed(d)+" "}${R}`}}},r=new t(2).pow(1024),i="\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089",n="\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079";function o(a){return a.toFixed(0).split("").map(d=>d==="-"?"\u208B":i[parseInt(d,10)]).join("")}function c(a){return a.toFixed(0).split("").map(d=>d==="-"?"\u208B":n[parseInt(d,10)]).join("")}function p(a,d=2,m=9,b="st"){return g(a,d,m,b)}function g(a,d=2,m=9,b="mixed_sc"){a=new t(a);let w=a.lt(0)?"-":"";if(a.mag==1/0)return w+"Infinity";if(Number.isNaN(a.mag))return w+"NaN";if(a.lt(0)&&(a=a.mul(-1)),a.eq(0))return a.toFixed(d);let O=a.log10().floor();switch(b){case"sc":case"scientific":if(a.log10().lt(Math.min(-d,0))&&d>1){let _=a.log10().ceil(),R=a.div(_.eq(-1)?new t(.1):new t(10).pow(_)),L=_.mul(-1).max(1).log10().gte(9);return w+(L?"":R.toFixed(2))+"e"+g(_,0,m,"mixed_sc")}else if(O.lt(m)){let _=Math.max(Math.min(d-O.toNumber(),d),0);return w+(_>0?a.toFixed(_):a.toFixed(_).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(a.gte("eeee10")){let L=a.slog();return(L.gte(1e9)?"":new t(10).pow(L.sub(L.floor())).toFixed(2))+"F"+g(L.floor(),0)}let _=a.div(new t(10).pow(O)),R=O.log10().gte(9);return w+(R?"":_.toFixed(2))+"e"+g(O,0,m,"mixed_sc")}case"st":case"standard":{let _=a.log(1e3).floor();if(_.lt(1))return w+a.toFixed(Math.max(Math.min(d-O.toNumber(),d),0));let R=_.mul(3),L=_.log10().floor();if(L.gte(3e3))return"e"+g(O,d,m,"st");let j="";if(_.lt(4))j=["","K","M","B"][Math.round(_.toNumber())];else{let Q=Math.floor(_.log(1e3).toNumber());for(Q<100&&(Q=Math.max(Q-1,0)),_=_.sub(1).div(new t(10).pow(Q*3));_.gt(0);){let K=_.div(1e3).floor(),tt=_.sub(K.mul(1e3)).floor().toNumber();tt>0&&(tt==1&&!Q&&(j="U"),Q&&(j=e.standard.tier2(Q)+(j?"-"+j:"")),tt>1&&(j=e.standard.tier1(tt)+j)),_=K,Q++}}let J=a.div(new t(10).pow(R)),rt=d===2?new t(2).sub(O.sub(R)).add(1).toNumber():d;return w+(L.gte(10)?"":J.toFixed(rt)+" ")+j}default:return e[b]||console.error('Invalid format type "',b,'"'),w+e[b]?.format(a,d,m)}}function N(a,d,m="mixed_sc",b,w){a=new t(a),d=new t(d);let O=a.add(d),_,R=O.div(a);return R.gte(10)&&a.gte(1e100)?(R=R.log10().mul(20),_="(+"+g(R,b,w,m)+" OoMs/sec)"):_="(+"+g(d,b,w,m)+"/sec)",_}function P(a,d=2,m="s"){return a=new t(a),a.gte(86400)?g(a.div(86400).floor(),0,12,"sc")+":"+P(a.mod(86400),d,"d"):a.gte(3600)||m=="d"?(a.div(3600).gte(10)||m!="d"?"":"0")+g(a.div(3600).floor(),0,12,"sc")+":"+P(a.mod(3600),d,"h"):a.gte(60)||m=="h"?(a.div(60).gte(10)||m!="h"?"":"0")+g(a.div(60).floor(),0,12,"sc")+":"+P(a.mod(60),d,"m"):(a.gte(10)||m!="m"?"":"0")+g(a,d,12,"sc")}function T(a,d=!1,m=0,b=9,w="mixed_sc"){let O=Ct=>g(Ct,m,b,w);a=new t(a);let _=a.mul(1e3).mod(1e3).floor(),R=a.mod(60).floor(),L=a.div(60).mod(60).floor(),j=a.div(3600).mod(24).floor(),J=a.div(86400).mod(365.2425).floor(),rt=a.div(31556952).floor(),Q=rt.eq(1)?" year":" years",K=J.eq(1)?" day":" days",tt=j.eq(1)?" hour":" hours",lt=L.eq(1)?" minute":" minutes",Et=R.eq(1)?" second":" seconds",Tt=_.eq(1)?" millisecond":" milliseconds";return`${rt.gt(0)?O(rt)+Q+", ":""}${J.gt(0)?O(J)+K+", ":""}${j.gt(0)?O(j)+tt+", ":""}${L.gt(0)?O(L)+lt+", ":""}${R.gt(0)?O(R)+Et+",":""}${d&&_.gt(0)?" "+O(_)+Tt:""}`.replace(/,([^,]*)$/,"$1").trim()}function U(a){return a=new t(a),g(new t(1).sub(a).mul(100))+"%"}function x(a){return a=new t(a),g(a.mul(100))+"%"}function Z(a,d=2){return a=new t(a),a.gte(1)?"\xD7"+a.format(d):"/"+a.pow(-1).format(d)}function C(a,d,m=10){return t.gte(a,10)?t.pow(m,t.log(a,m).pow(d)):new t(a)}function k(a,d=0){a=new t(a);let m=(_=>_.map((R,L)=>({name:R.name,altName:R.altName,value:t.pow(1e3,new t(L).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"E",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),b="",w=a.lte(0)?0:t.min(t.log(a,1e3).sub(1),m.length-1).floor().toNumber(),O=m[w];if(w===0)switch(d){case 1:b="";break;case 2:case 0:default:b=a.format();break}switch(d){case 1:b=O.name;break;case 2:b=`${a.divide(O.value).format()}`;break;case 3:b=O.altName;break;case 0:default:b=`${a.divide(O.value).format()} ${O.name}`;break}return b}function Y(a,d=!1){return`${k(a,2)} ${k(a,1)}eV${d?"/c^2":""}`}let W={...e,toSubscript:o,toSuperscript:c,formatST:p,format:g,formatGain:N,formatTime:P,formatTimeLong:T,formatReduction:U,formatPercent:x,formatMult:Z,expMult:C,metric:k,ev:Y};return{FORMATS:e,formats:W}}var xt=17,Se=9e15,Ie=Math.log10(9e15),Oe=1/9e15,Fe=308,Ae=-324,Dt=5,Ee=1023,Te=!0,Ce=!1,Pe=function(){let t=[];for(let r=Ae+1;r<=Fe;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),ht=[2,Math.E,3,4,5,6,7,8,9,10],qe=[[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]],xe=[[-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]],f=function(e){return s.fromValue_noAlloc(e)},A=function(t,e,r){return s.fromComponents(t,e,r)},V=function(e,r,i){return s.fromComponents_noNormalize(e,r,i)},ut=function(e,r){let i=r+1,n=Math.ceil(Math.log10(Math.abs(e))),o=Math.round(e*Math.pow(10,i-n))*Math.pow(10,n-i);return parseFloat(o.toFixed(Math.max(i-n,0)))},kt=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},ke=function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;let e=1;for(;t<10;)e=e*t,++t;t-=1;let r=.9189385332046727;r=r+(t+.5)*Math.log(t),r=r-t;let i=t*t,n=t;return r=r+1/(12*n),n=n*i,r=r+1/(360*n),n=n*i,r=r+1/(1260*n),n=n*i,r=r+1/(1680*n),n=n*i,r=r+1/(1188*n),n=n*i,r=r+691/(360360*n),n=n*i,r=r+7/(1092*n),n=n*i,r=r+3617/(122400*n),Math.exp(r)/e},Le=.36787944117144233,Qt=.5671432904097838,Jt=function(t,e=1e-10){let r,i;if(!Number.isFinite(t)||t===0)return t;if(t===1)return Qt;t<10?r=0:r=Math.log(t)-Math.log(Math.log(t));for(let n=0;n<100;++n){if(i=(t*Math.exp(-r)+r*r)/(r+1),Math.abs(i-r).5?1:-1;if(Math.random()*20<1)return V(e,0,1);let r=Math.floor(Math.random()*(t+1)),i=r===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let n=Math.pow(10,i);return Math.random()>.9&&(n=Math.trunc(n)),A(e,r,n)}static affordGeometricSeries_core(t,e,r,i){let n=e.mul(r.pow(i));return s.floor(t.div(n).mul(r.sub(1)).add(1).log10().div(r.log10()))}static sumGeometricSeries_core(t,e,r,i){return e.mul(r.pow(i)).mul(s.sub(1,r.pow(t))).div(s.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let o=e.add(i.mul(r)).sub(r.div(2)),c=o.pow(2);return o.neg().add(c.add(r.mul(t).mul(2)).sqrt()).div(r).floor()}static sumArithmeticSeries_core(t,e,r,i){let n=e.add(i.mul(r));return t.div(2).mul(n.mul(2).plus(t.sub(1).mul(r)))}static efficiencyOfPurchase_core(t,e,r){return t.div(e).add(t.div(r))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0||this.mag===Number.NEGATIVE_INFINITY&&this.layer>0&&Number.isFinite(this.layer))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.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_INFINITY)return this.sign==1?(this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY):this.sign==-1&&(this.mag=Number.NEGATIVE_INFINITY,this.layer=Number.NEGATIVE_INFINITY),this;if(this.layer===0&&this.mag=Se)return this.layer+=1,this.mag=e*Math.log10(t),this;for(;t0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=e*Math.pow(10,t),t=Math.abs(this.mag),e=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)),(Number.isNaN(this.sign)||Number.isNaN(this.layer)||Number.isNaN(this.mag))&&(this.sign=Number.NaN,this.layer=Number.NaN,this.mag=Number.NaN),this}fromComponents(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this.normalize(),this}fromComponents_noNormalize(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this}fromMantissaExponent(t,e){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=e+Math.log10(t),this.normalize(),this}fromMantissaExponent_noNormalize(t,e){return this.fromMantissaExponent(t,e),this}fromDecimal(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this}fromNumber(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this}fromString(t,e=!1){let r=t,i=s.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);Te?t=t.replace(",",""):Ce&&(t=t.replace(",","."));let n=t.split("^^^");if(n.length===2){let C=parseFloat(n[0]),k=parseFloat(n[1]),Y=n[1].split(";"),W=1;if(Y.length===2&&(W=parseFloat(Y[1]),isFinite(W)||(W=1)),isFinite(C)&&isFinite(k)){let a=s.pentate(C,k,W,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let o=t.split("^^");if(o.length===2){let C=parseFloat(o[0]),k=parseFloat(o[1]),Y=o[1].split(";"),W=1;if(Y.length===2&&(W=parseFloat(Y[1]),isFinite(W)||(W=1)),isFinite(C)&&isFinite(k)){let a=s.tetrate(C,k,W,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let c=t.split("^");if(c.length===2){let C=parseFloat(c[0]),k=parseFloat(c[1]);if(isFinite(C)&&isFinite(k)){let Y=s.pow(C,k);return this.sign=Y.sign,this.layer=Y.layer,this.mag=Y.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}t=t.trim().toLowerCase();let p,g,N=t.split("pt");if(N.length===2){p=10,g=parseFloat(N[0]),N[1]=N[1].replace("(",""),N[1]=N[1].replace(")","");let C=parseFloat(N[1]);if(isFinite(C)||(C=1),isFinite(p)&&isFinite(g)){let k=s.tetrate(p,g,C,e);return this.sign=k.sign,this.layer=k.layer,this.mag=k.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(N=t.split("p"),N.length===2){p=10,g=parseFloat(N[0]),N[1]=N[1].replace("(",""),N[1]=N[1].replace(")","");let C=parseFloat(N[1]);if(isFinite(C)||(C=1),isFinite(p)&&isFinite(g)){let k=s.tetrate(p,g,C,e);return this.sign=k.sign,this.layer=k.layer,this.mag=k.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(N=t.split("f"),N.length===2){p=10,N[0]=N[0].replace("(",""),N[0]=N[0].replace(")","");let C=parseFloat(N[0]);if(N[1]=N[1].replace("(",""),N[1]=N[1].replace(")",""),g=parseFloat(N[1]),isFinite(C)||(C=1),isFinite(p)&&isFinite(g)){let k=s.tetrate(p,g,C,e);return this.sign=k.sign,this.layer=k.layer,this.mag=k.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let P=t.split("e"),T=P.length-1;if(T===0){let C=parseFloat(t);if(isFinite(C))return this.fromNumber(C),s.fromStringCache.size>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else if(T===1){let C=parseFloat(t);if(isFinite(C)&&C!==0)return this.fromNumber(C),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}let U=t.split("e^");if(U.length===2){this.sign=1,U[0].charAt(0)=="-"&&(this.sign=-1);let C="";for(let k=0;k=43&&Y<=57||Y===101)C+=U[1].charAt(k);else return this.layer=parseFloat(C),this.mag=parseFloat(U[1].substr(k+1)),this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(T<1)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let x=parseFloat(P[0]);if(x===0)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let Z=parseFloat(P[P.length-1]);if(T>=2){let C=parseFloat(P[P.length-2]);isFinite(C)&&(Z*=Math.sign(C),Z+=kt(C))}if(!isFinite(x))this.sign=P[0]==="-"?-1:1,this.layer=T,this.mag=Z;else if(T===1)this.sign=Math.sign(x),this.layer=1,this.mag=Z+Math.log10(Math.abs(x));else if(this.sign=Math.sign(x),this.layer=T,T===2){let C=s.mul(A(1,2,Z),f(x));return this.sign=C.sign,this.layer=C.layer,this.mag=C.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else this.mag=Z;return this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}fromValue(t){return t instanceof s?this.fromDecimal(t):typeof t=="number"?this.fromNumber(t):typeof t=="string"?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===1?Number.POSITIVE_INFINITY:this.mag===Number.NEGATIVE_INFINITY&&this.layer===Number.NEGATIVE_INFINITY&&this.sign===-1?Number.NEGATIVE_INFINITY: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(t){return isNaN(this.m)?Number.NaN:this.m===0?0:ut(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:ut(this.mag,t)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_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<=Dt?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(t){return this.layer===0?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)}toFixed(t){return this.layer===0?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)}toPrecision(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(t){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(t):ut(this.m,t)+"e"+ut(this.e,t):this.layer===1?ut(this.m,t)+"e"+ut(this.e,t):this.layer<=Dt?(this.sign===-1?"-":"")+"e".repeat(this.layer)+ut(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+ut(this.mag,t)}abs(){return V(this.sign===0?0:1,this.layer,this.mag)}neg(){return V(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?s.dZero:this.layer===0?A(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?this.sign===-1?s.dNegOne:s.dZero:this.sign===-1?this.neg().ceil().neg():this.layer===0?A(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?this.sign===1?s.dOne:s.dZero:this.sign===-1?this.neg().floor().neg():this.layer===0?A(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?s.dZero:this.layer===0?A(this.sign,0,Math.trunc(this.mag)):this}add(t){let e=f(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer)||this.sign===0)return e;if(e.sign===0)return this;if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return V(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(s.cmpabs(this,e)>0?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*r.mag+i.sign*i.mag);let n=r.layer*Math.sign(r.mag),o=i.layer*Math.sign(i.mag);if(n-o>=2)return r;if(n===0&&o===-1){if(Math.abs(i.mag-Math.log10(r.mag))>xt)return r;{let c=Math.pow(10,Math.log10(r.mag)-i.mag),p=i.sign+r.sign*c;return A(Math.sign(p),1,i.mag+Math.log10(Math.abs(p)))}}if(n===1&&o===0){if(Math.abs(r.mag-Math.log10(i.mag))>xt)return r;{let c=Math.pow(10,r.mag-Math.log10(i.mag)),p=i.sign+r.sign*c;return A(Math.sign(p),1,Math.log10(i.mag)+Math.log10(Math.abs(p)))}}if(Math.abs(r.mag-i.mag)>xt)return r;{let c=Math.pow(10,r.mag-i.mag),p=i.sign+r.sign*c;return A(Math.sign(p),1,i.mag+Math.log10(Math.abs(p)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(f(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=f(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer))return e;if(this.sign===0||e.sign===0)return V(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return V(this.sign*e.sign,0,1);let r,i;if(this.layer>e.layer||this.layer==e.layer&&Math.abs(this.mag)>Math.abs(e.mag)?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return A(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return A(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return A(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let n=A(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(A(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return A(r.sign*i.sign,n.layer+1,n.sign*n.mag)}if(r.layer===2&&i.layer===2){let n=A(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(A(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return A(r.sign*i.sign,n.layer+1,n.sign*n.mag)}throw Error("Bad arguments to mul: "+this+", "+t)}multiply(t){return this.mul(t)}times(t){return this.mul(t)}div(t){let e=f(t);return this.mul(e.recip())}divide(t){return this.div(t)}divideBy(t){return this.div(t)}dividedBy(t){return this.div(t)}recip(){return this.mag===0?s.dNaN:this.layer===0?A(this.sign,0,1/this.mag):A(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=f(t).abs();if(e.eq(s.dZero))return s.dZero;let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new s(r%i):this.sub(e).eq(this)?s.dZero:e.sub(this).eq(e)?this:this.sign==-1?this.abs().mod(e).neg():this.sub(this.div(e).floor().mul(e))}modulo(t){return this.mod(t)}modular(t){return this.mod(t)}cmp(t){let e=f(t);return this.sign>e.sign?1:this.sign0?this.layer:-this.layer,i=e.mag>0?e.layer:-e.layer;return r>i?1:re.mag?1:this.mag0?e:this}clamp(t,e){return this.max(t).min(e)}clampMin(t){return this.max(t)}clampMax(t){return this.min(t)}cmp_tolerance(t,e){let r=f(t);return this.eq_tolerance(r,e)?0:this.cmp(r)}compare_tolerance(t,e){return this.cmp_tolerance(t,e)}eq_tolerance(t,e){let r=f(t);if(e==null&&(e=1e-7),this.sign!==r.sign||Math.abs(this.layer-r.layer)>1)return!1;let i=this.mag,n=r.mag;return this.layer>r.layer&&(n=kt(n)),this.layer0?A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):A(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?s.dNaN:this.layer>0?A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):A(this.sign,0,Math.log10(this.mag))}log(t){return t=f(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?s.dNaN:this.layer===0&&t.layer===0?A(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):s.div(this.log10(),t.log10())}log2(){return this.sign<=0?s.dNaN:this.layer===0?A(this.sign,0,Math.log2(this.mag)):this.layer===1?A(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?A(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?s.dNaN:this.layer===0?A(this.sign,0,Math.log(this.mag)):this.layer===1?A(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?A(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=f(t),r=this,i=e;if(r.sign===0)return i.eq(0)?V(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return V(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return r;let n=r.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?n.neg():Math.abs(i.toNumber()%2)%2===0?n:s.dNaN:n}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return s.dNaN;let t=this;if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return A(1,0,e);if(t.sign===0)return s.dOne;t=V(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?A(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?A(-t.sign,t.layer+1,-t.mag):s.dOne}pow_base(t){return f(t).pow(this)}root(t){let e=f(t);return this.pow(e.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(V(1,0,24)))return s.fromNumber(ke(this.sign*this.mag));let t=this.mag-1,e=.9189385332046727;e=e+(t+.5)*Math.log(t),e=e-t;let r=t*t,i=t,n=12*i,o=1/n,c=e+o;if(c===e||(e=c,i=i*r,n=360*i,o=1/n,c=e-o,c===e))return s.exp(e);e=c,i=i*r,n=1260*i;let p=1/n;return e=e+p,i=i*r,n=1680*i,p=1/n,e=e-p,s.exp(e)}else return this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?s.dOne:this.layer===0&&this.mag<=709.7?s.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?A(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?A(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):A(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return s.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return A(1,2,Math.log10(this.mag)-.3010299956639812);{let t=s.div(V(this.sign,this.layer-1,this.mag),V(1,0,2));return t.layer+=1,t.normalize(),t}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(t=2,e=V(1,0,1),r=!1){if(t===1)return s.pow(this,e);if(t===0)return new s(e);if(this.eq(s.dOne))return s.dOne;if(this.eq(-1))return s.pow(this,e);if(t===Number.POSITIVE_INFINITY){let o=this.toNumber();if(o<=1.444667861009766&&o>=.06598803584531254){if(o>1.444667861009099)return s.fromNumber(Math.E);let c=s.ln(this).neg();return c.lambertw().div(c)}else return o>1.444667861009766?s.fromNumber(Number.POSITIVE_INFINITY):s.dNaN}if(this.eq(s.dZero)){let o=Math.abs((t+1)%2);return o>1&&(o=2-o),s.fromNumber(o)}if(t<0)return s.iteratedlog(e,this,-t,r);e=f(e);let i=t;t=Math.trunc(t);let n=i-t;if(this.gt(s.dZero)&&this.lte(1.444667861009766)&&(i>1e4||!r)){t=Math.min(1e4,t);for(let o=0;o1e4){let o=this.pow(e);return i<=1e4||Math.ceil(i)%2==0?e.mul(1-n).add(o.mul(n)):e.mul(n).add(o.mul(1-n))}return e}n!==0&&(e.eq(s.dOne)?this.gt(10)||r?e=this.pow(n):(e=s.fromNumber(s.tetrate_critical(this.toNumber(),n)),this.lt(2)&&(e=e.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let o=0;o3)return V(e.sign,e.layer+(t-o-1),e.mag);if(o>1e4)return e}return e}iteratedexp(t=2,e=V(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return s.tetrate(t,-e,this,r);t=f(t);let i=s.fromDecimal(this),n=e;e=Math.trunc(e);let o=n-e;if(i.layer-t.layer>3){let c=Math.min(e,i.layer-t.layer-3);e-=c,i.layer-=c}for(let c=0;c1e4)return i}return o>0&&o<1&&(t.eq(10)?i=i.layeradd10(-o,r):i=i.layeradd(-o,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,n=!1,o=!1,c=this.slog_internal(t,r).toNumber();for(let p=1;p1&&o!=N&&(n=!0),o=N,n?i/=2:i*=2,i=Math.abs(i)*(N?-1:1),c+=i,i===0)break}return s.fromNumber(c)}slog_internal(t=10,e=!1){if(t=f(t),t.lte(s.dZero)||t.eq(s.dOne))return s.dNaN;if(t.lt(s.dOne))return this.eq(s.dOne)?s.dZero:this.eq(s.dZero)?s.dNegOne:s.dNaN;if(this.mag<0||this.eq(s.dZero))return s.dNegOne;let r=0,i=s.fromDecimal(this);if(i.layer-t.layer>3){let n=i.layer-t.layer-3;r+=n,i.layer-=n}for(let n=0;n<100;++n)if(i.lt(s.dZero))i=s.pow(t,i),r-=1;else{if(i.lte(s.dOne))return e?s.fromNumber(r+i.toNumber()-1):s.fromNumber(r+s.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=s.log(i,t)}return s.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:s.critical_section(t,e,xe)}static tetrate_critical(t,e){return s.critical_section(t,e,qe)}static critical_section(t,e,r,i=!1){e*=10,e<0&&(e=0),e>10&&(e=10),t<2&&(t=2),t>10&&(t=10);let n=0,o=0;for(let p=0;pt){let g=(t-ht[p])/(ht[p+1]-ht[p]);n=r[p][Math.floor(e)]*(1-g)+r[p+1][Math.floor(e)]*g,o=r[p][Math.ceil(e)]*(1-g)+r[p+1][Math.ceil(e)]*g;break}let c=e-Math.floor(e);return n<=0||o<=0?n*(1-c)+o*c:Math.pow(t,Math.log(n)/Math.log(t)*(1-c)+Math.log(o)/Math.log(t)*c)}layeradd10(t,e=!1){t=s.fromValue_noAlloc(t).toNumber();let r=s.fromDecimal(this);if(t>=1){r.mag<0&&r.layer>0?(r.sign=0,r.mag=0,r.layer=0):r.sign===-1&&r.layer==0&&(r.sign=1,r.mag=-r.mag);let i=Math.trunc(t);t-=i,r.layer+=i}if(t<=-1){let i=Math.trunc(t);if(t-=i,r.layer+=i,r.layer<0)for(let n=0;n<100;++n){if(r.layer++,r.mag=Math.log10(r.mag),!isFinite(r.mag))return r.sign===0&&(r.sign=1),r.layer<0&&(r.layer=0),r.normalize();if(r.layer>=0)break}}for(;r.layer<0;)r.layer++,r.mag=Math.log10(r.mag);return r.sign===0&&(r.sign=1,r.mag===0&&r.layer>=1&&(r.layer-=1,r.mag=1)),r.normalize(),t!==0?r.layeradd(t,10,e):r}layeradd(t,e,r=!1){let n=this.slog(e).toNumber()+t;return n>=0?s.tetrate(e,n,s.dOne,r):Number.isFinite(n)?n>=-1?s.log(s.tetrate(e,n+1,s.dOne,r),e):s.log(s.log(s.tetrate(e,n+2,s.dOne,r),e),e):s.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return s.fromNumber(Jt(this.toNumber()));if(this.layer===0)return s.fromNumber(Jt(this.sign*this.mag));if(this.layer===1)return Kt(this);if(this.layer===2)return Kt(this);if(this.layer>=3)return V(this.sign,this.layer-1,this.mag);throw"Unhandled behavior in lambertw()"}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(s.dInf))return s.dInf;if(!this.isFinite())return s.dNaN;if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return s.fromNumber(t).add(2).pow(this.recip());if(t<=0)return s.dNaN;if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return eLe?this.pow(this.recip()):s.dNaN}if(this.eq(1))return s.dOne;if(this.lt(0))return s.dNaN;if(this.lte("1ee-16"))return t%2==1?this:s.dNaN;if(this.gt(1)){let e=s.dTen;this.gte(s.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=s.dZero,i=e.layer,n=e.iteratedlog(10,i,!0),o=n,c=n.div(2),p=!0;for(;p;)c=r.add(n).div(2),s.iteratedexp(10,i,c,!0).tetrate(t,1,!0).gt(this)?n=c:r=c,c.eq(o)?p=!1:o=c;return s.iteratedexp(10,i,c,!0)}else{let e=1,r=A(1,10,1),i=A(1,10,1),n=A(1,10,1),o=A(1,1,-16),c=s.dZero,p=A(1,10,1),g=o.pow10().recip(),N=s.dZero,P=g,T=g,U=Math.ceil(t)%2==0,x=0,Z=A(1,10,1),C=!1,k=s.dZero,Y=!1;for(;e<4;){if(e==2){if(U)break;n=A(1,10,1),o=r,e=3,p=A(1,10,1),Z=A(1,10,1)}for(C=!1;o.neq(n);){if(k=o,o.pow10().recip().tetrate(t,1,!0).eq(1)&&o.pow10().recip().lt(.4))g=o.pow10().recip(),P=o.pow10().recip(),T=o.pow10().recip(),N=s.dZero,x=-1,e==3&&(Z=o);else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip())&&!U&&o.pow10().recip().lt(.4))g=o.pow10().recip(),P=o.pow10().recip(),T=o.pow10().recip(),N=s.dZero,x=0;else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip().mul(2).tetrate(t,1,!0)))g=o.pow10().recip(),P=s.dZero,T=g.mul(2),N=g,U?x=-1:x=0;else{for(c=o.mul(12e-17),g=o.pow10().recip(),P=o.add(c).pow10().recip(),N=g.sub(P),T=g.add(N);P.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||T.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||P.gte(g)||T.lte(g);)c=c.mul(2),P=o.add(c).pow10().recip(),N=g.sub(P),T=g.add(N);if((e==1&&T.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))&&P.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))||e==3&&T.tetrate(t,1,!0).lt(g.tetrate(t,1,!0))&&P.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))&&(Z=o),T.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))x=-1;else if(U)x=1;else if(e==3&&o.gt_tolerance(r,1e-8))x=0;else{for(;P.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||T.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||P.gte(g)||T.lte(g);)c=c.mul(2),P=o.add(c).pow10().recip(),N=g.sub(P),T=g.add(N);T.tetrate(t,1,!0).sub(g.tetrate(t,1,!0)).lt(g.tetrate(t,1,!0).sub(P.tetrate(t,1,!0)))?x=0:x=1}}if(x==-1&&(Y=!0),e==1&&x==1||e==3&&x!=0)if(n.eq(A(1,10,1)))o=o.mul(2);else{let m=!1;if(C&&(x==1&&e==1||x==-1&&e==3)&&(m=!0),o=o.add(n).div(2),m)break}else if(n.eq(A(1,10,1)))n=o,o=o.div(2);else{let m=!1;if(C&&(x==1&&e==1||x==-1&&e==3)&&(m=!0),n=n.sub(p),o=o.sub(p),m)break}if(n.sub(o).div(2).abs().gt(p.mul(1.5))&&(C=!0),p=n.sub(o).div(2).abs(),o.gt("1e18")||o.eq(k))break}if(o.gt("1e18")||!Y||Z==A(1,10,1))break;e==1?r=Z:e==3&&(i=Z),e++}n=r,o=A(1,1,-18);let W=o,a=s.dZero,d=!0;for(;d;)if(n.eq(A(1,10,1))?a=o.mul(2):a=n.add(o).div(2),s.pow(10,a).recip().tetrate(t,1,!0).gt(this)?o=a:n=a,a.eq(W)?d=!1:W=a,o.gt("1e18"))return s.dNaN;if(a.eq_tolerance(r,1e-15)){if(i.eq(A(1,10,1)))return s.dNaN;for(n=A(1,10,1),o=i,W=o,a=s.dZero,d=!0;d;)if(n.eq(A(1,10,1))?a=o.mul(2):a=n.add(o).div(2),s.pow(10,a).recip().tetrate(t,1,!0).gt(this)?o=a:n=a,a.eq(W)?d=!1:W=a,o.gt("1e18"))return s.dNaN;return a.pow10().recip()}else return a.pow10().recip()}}pentate(t=2,e=V(1,0,1),r=!1){e=f(e);let i=t;t=Math.trunc(t);let n=i-t;n!==0&&(e.eq(s.dOne)?(++t,e=s.fromNumber(n)):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let o=0;o10)return e}return e}sin(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.sin(this.sign*this.mag)):V(0,0,0)}cos(){return this.mag<0?s.dOne:this.layer===0?s.fromNumber(Math.cos(this.sign*this.mag)):V(0,0,0)}tan(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.tan(this.sign*this.mag)):V(0,0,0)}asin(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.asin(this.sign*this.mag)):V(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?s.fromNumber(Math.acos(this.toNumber())):this.layer===0?s.fromNumber(Math.acos(this.sign*this.mag)):V(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.atan(this.sign*this.mag)):s.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 s.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return s.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?V(Number.NaN,Number.NaN,Number.NaN):s.ln(this.add(1).div(s.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?this:this.root(s.pow(10,t))}egg(){return this.add(9)}lessThanOrEqualTo(t){return this.cmp(t)<1}lessThan(t){return this.cmp(t)<0}greaterThanOrEqualTo(t){return this.cmp(t)>-1}greaterThan(t){return this.cmp(t)>0}static smoothDamp(t,e,r,i){return new s(t).add(new s(e).minus(new s(t)).times(new s(r)).times(new s(i)))}clone(){return this}static clone(t){return s.fromComponents(t.sign,t.layer,t.mag)}softcap(t,e,r){let i=this.clone();return i.gte(t)&&([0,"pow"].includes(r)&&(i=i.div(t).pow(e).mul(t)),[1,"mul"].includes(r)&&(i=i.sub(t).div(e).add(t))),i}static softcap(t,e,r,i){return new s(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new s(t),e=new s(e);let n=this.clone();return n.gte(t)&&([0,"pow"].includes(r)&&(n=i?n.mul(t.pow(e.sub(1))).root(e):n.pow(e).div(t.pow(e.sub(1)))),[1,"exp"].includes(r)&&(n=i?n.div(t).max(1).log(e).add(t):s.pow(e,n.sub(t)).mul(t))),n}static scale(t,e,r,i,n=!1){return new s(t).scale(e,r,i,n)}format(t=2,e=9,r="mixed_sc"){return ct.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return ct.format(new s(t),e,r,i)}formatST(t=2,e=9,r="st"){return ct.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return ct.format(new s(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return ct.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,n){return ct.formatGain(new s(t),e,r,i,n)}toRoman(t=5e3){t=new s(t);let e=this.clone();if(e.gte(t)||e.lt(1))return e;let r=e.toNumber(),i={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},n="";for(let o of Object.keys(i)){let c=Math.floor(r/i[o]);r-=c*i[o],n+=o.repeat(c)}return n}static toRoman(t,e){return new s(t).toRoman(e)}static random(t=0,e=1){return t=new s(t),e=new s(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new s(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new s(Math.random()).lt(t)}};s.dZero=V(0,0,0),s.dOne=V(1,0,1),s.dNegOne=V(-1,0,1),s.dTwo=V(1,0,2),s.dTen=V(1,0,10),s.dNaN=V(Number.NaN,Number.NaN,Number.NaN),s.dInf=V(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNegInf=V(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),s.dNumberMax=A(1,0,Number.MAX_VALUE),s.dNumberMin=A(1,0,Number.MIN_VALUE),s.fromStringCache=new Pt(Ee),at([St()],s.prototype,"sign",2),at([St()],s.prototype,"mag",2),at([St()],s.prototype,"layer",2),s=at([Me()],s);var{formats:ct,FORMATS:Be}=_e(s);s.formats=ct;var I=(()=>{let t=e=>new s(e);return Object.getOwnPropertyNames(s).filter(e=>!Object.getOwnPropertyNames(class{}).includes(e)).forEach(e=>{t[e]=s[e]}),t})(),mt=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.value=t.value,this.order=t.order??99}},Lt=class{constructor(t=1,e){this.addBoost=this.setBoost,e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=I(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new mt(r))})}getBoosts(t,e){let r=[],i=[];for(let n=0;nT),N=n,P=this.getBoosts(o,!0);P[0][0]?this.boostArray[P[1][0]]=new mt({id:o,name:c,description:p,value:g,order:N}):this.boostArray.push(new mt({id:o,name:c,description:p,value:g,order:N}))}else{t=Array.isArray(t)?t:[t];for(let o=0;oi.order-n.order);for(let i=0;ie.cost(Z.add(r)),U=I.min(i,Bt(T,t,n,o).value.floor()),x=I(0);return[U,x]}let g=Bt(T=>Gt(e.cost,T,r),t,n,o).value.floor().min(r.add(p).sub(1)),N=Gt(e.cost,g,r);return[g.sub(r).add(1).max(0),N]}function Ft(t){return t=I(t),`${t.sign}/${t.mag}/${t.layer}`}function re(t,e){return`sum/${Ft(t)}/${Ft(e)}}`}function Rt(t){return`el/${Ft(t)}`}var Nt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?I(t.level):I(1)}};at([St()],Nt.prototype,"id",2),at([It(()=>s)],Nt.prototype,"level",2);var ie=class de{static{this.cacheSize=63}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn()}get level(){return((this??{data:{level:I(1)}}).data??{level:I(1)}).level}set level(e){this.data.level=I(e)}constructor(e,r,i){let n=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>n,this.cache=new Pt(i??de.cacheSize),this.id=e.id,this.name=e.name??e.id,this.descriptionFn=e.description?typeof e.description=="function"?e.description:()=>e.description:()=>"",this.cost=e.cost,this.costBulk=e.costBulk,this.maxLevel=e.maxLevel,this.effect=e.effect,this.el=e.el}getCached(e,r,i){return e==="sum"?this.cache.get(re(r,i)):this.cache.get(Rt(r))}setCached(e,r,i,n){let o=e==="sum"?{id:this.id,el:!1,start:I(r),end:I(i),cost:I(n)}:{id:this.id,el:!0,level:I(r),cost:I(i)};return e==="sum"?this.cache.set(re(r,i),o):this.cache.set(Rt(r),o),o}},ar=bt(vt()),At=class{constructor(){this.value=I(0),this.upgrades={}}};at([It(()=>s)],At.prototype,"value",2),at([It(()=>Nt)],At.prototype,"upgrades",2);var Ve=class{get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}constructor(t=new At,e,r={defaultVal:I(0),defaultBoost:I(1)}){this.defaultVal=r.defaultVal,this.defaultBoost=r.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new Lt(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e),this.upgrades=this.upgrades}onLoadData(){for(let t of Object.values(this.upgrades))t.effect?.(t.level,t)}reset(t=!0,e=!0){if(t&&(this.value=this.defaultVal),e)for(let r of Object.values(this.upgrades))r.level=I(0)}gain(t=1e3){let e=this.boost.calculate().mul(I(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new Nt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r={};for(let i of t){let n=this.pointerAddUpgrade(i),o=new ie(i,()=>this.pointerGetUpgrade(i.id));o.effect&&e&&o.effect(o.level,o),r[i.id]=o,this.upgrades[i.id]=o}return Object.values(r)}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&(r.name=e.name??r.name,r.cost=e.cost??r.cost,r.maxLevel=e.maxLevel??r.maxLevel,r.effect=e.effect??r.effect)}calculateUpgrade(t,e,r,i){let n=this.getUpgrade(t);return n===null?(console.warn(`Upgrade "${t}" not found.`),[I(0),I(0)]):Vt(this.value,n,n.level,e?n.level.add(e):void 0,r,i)}getNextCost(t,e=0,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),I(0);let o=Vt(this.value,n,n.level,n.level.add(e),r,i)[1];return n.cost(n.level.add(o))}buyUpgrade(t,e,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),!1;let[o,c]=this.calculateUpgrade(t,e,r,i);return o.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(c),n.level=n.level.add(o),n.effect?.(n.level,n),!0)}},or=bt(vt()),Ut=class{constructor(t=0){this.value=I(t)}};at([It(()=>s)],Ut.prototype,"value",2);var Re=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=I(r),t??=new Ut(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new Lt(this.initial):null}update(){console.warn("AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed."),this.boost&&(this.pointer.value=this.boost.calculate())}get value(){return this.boost&&(this.pointer.value=this.boost.calculate()),this.pointer.value}set value(t){if(this.boost)throw new Error("Cannot set value of attributeStatic when boost is enabled.");this.pointer.value=t}},ne=class{constructor(t,e,r){this.x=t,this.y=e,this.properties=r??{}}setValue(t,e){return this.properties[t]=e,e}getValue(t){return this.properties[t]}},Ue=class{constructor(t,e,r){this.xSize=t,this.ySize=e,this.cells=[];for(let i=0;i{if(e&&typeof e=="object"||typeof e=="function")for(let n of Object.getOwnPropertyNames(e))!Object.prototype.hasOwnProperty.call(t,n)&&n!==r&&Object.defineProperty(t,n,{get:()=>e[n],enumerable:!(i=Object.getOwnPropertyDescriptor(e,n))||i.enumerable});return t};nt.exports=je(nt.exports,pt)}return nt.exports}); +"use strict";(function(pt,nt){var wt=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],nt);else if(typeof module=="object"&&module.exports)module.exports=nt();else{var ot=nt(),_t=wt?exports:pt;for(var yt in ot)_t[yt]=ot[yt]}})(typeof self<"u"?self:exports,()=>{var pt={},nt={exports:pt},wt=Object.create,ot=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,yt=Object.getOwnPropertyNames,pe=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty,be=(t,e)=>function(){return e||(0,t[yt(t)[0]])((e={exports:{}}).exports,e),e.exports},Zt=(t,e)=>{for(var r in e)ot(t,r,{get:e[r],enumerable:!0})},zt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of yt(e))!ye.call(t,n)&&n!==r&&ot(t,n,{get:()=>e[n],enumerable:!(i=_t(e,n))||i.enumerable});return t},bt=(t,e,r)=>(r=t!=null?wt(pe(t)):{},zt(e||!t||!t.__esModule?ot(r,"default",{value:t,enumerable:!0}):r,t)),ve=t=>zt(ot({},"__esModule",{value:!0}),t),at=(t,e,r,i)=>{for(var n=i>1?void 0:i?_t(e,r):e,o=t.length-1,c;o>=0;o--)(c=t[o])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&ot(e,r,n),n},vt=be({"node_modules/reflect-metadata/Reflect.js"(){var t;(function(e){(function(r){var i=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:g(),n=o(e);typeof i.Reflect<"u"&&(n=o(i.Reflect,n)),r(n,i),typeof i.Reflect>"u"&&(i.Reflect=e);function o(N,P){return function(T,U){Object.defineProperty(N,T,{configurable:!0,writable:!0,value:U}),P&&P(T,U)}}function c(){try{return Function("return this;")()}catch{}}function p(){try{return(0,eval)("(function() { return this; })()")}catch{}}function g(){return c()||p()}})(function(r,i){var n=Object.prototype.hasOwnProperty,o=typeof Symbol=="function",c=o&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",p=o&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",g=typeof Object.create=="function",N={__proto__:[]}instanceof Array,P=!g&&!N,T={create:g?function(){return Yt(Object.create(null))}:N?function(){return Yt({__proto__:null})}:function(){return Yt({})},has:P?function(u,l){return n.call(u,l)}:function(u,l){return l in u},get:P?function(u,l){return n.call(u,l)?u[l]:void 0}:function(u,l){return u[l]}},U=Object.getPrototypeOf(Function),x=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Je(),Z=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:Ke(),C=typeof WeakMap=="function"?WeakMap:tr(),k=o?Symbol.for("@reflect-metadata:registry"):void 0,Y=We(),W=De(Y);function a(u,l,h,y){if(q(h)){if(!oe(u))throw new TypeError;if(!ue(l))throw new TypeError;return J(u,l)}else{if(!oe(u))throw new TypeError;if(!z(l))throw new TypeError;if(!z(y)&&!q(y)&&!gt(y))throw new TypeError;return gt(y)&&(y=void 0),h=st(h),rt(u,l,h,y)}}r("decorate",a);function d(u,l){function h(y,E){if(!z(y))throw new TypeError;if(!q(E)&&!He(E))throw new TypeError;Et(u,l,y,E)}return h}r("metadata",d);function m(u,l,h,y){if(!z(h))throw new TypeError;return q(y)||(y=st(y)),Et(u,l,h,y)}r("defineMetadata",m);function b(u,l,h){if(!z(l))throw new TypeError;return q(h)||(h=st(h)),Q(u,l,h)}r("hasMetadata",b);function w(u,l,h){if(!z(l))throw new TypeError;return q(h)||(h=st(h)),K(u,l,h)}r("hasOwnMetadata",w);function O(u,l,h){if(!z(l))throw new TypeError;return q(h)||(h=st(h)),tt(u,l,h)}r("getMetadata",O);function S(u,l,h){if(!z(l))throw new TypeError;return q(h)||(h=st(h)),lt(u,l,h)}r("getOwnMetadata",S);function R(u,l){if(!z(u))throw new TypeError;return q(l)||(l=st(l)),Tt(u,l)}r("getMetadataKeys",R);function L(u,l){if(!z(u))throw new TypeError;return q(l)||(l=st(l)),Ct(u,l)}r("getOwnMetadataKeys",L);function j(u,l,h){if(!z(l))throw new TypeError;if(q(h)||(h=st(h)),!z(l))throw new TypeError;q(h)||(h=st(h));var y=Mt(l,h,!1);return q(y)?!1:y.OrdinaryDeleteMetadata(u,l,h)}r("deleteMetadata",j);function J(u,l){for(var h=u.length-1;h>=0;--h){var y=u[h],E=y(l);if(!q(E)&&!gt(E)){if(!ue(E))throw new TypeError;l=E}}return l}function rt(u,l,h,y){for(var E=u.length-1;E>=0;--E){var H=u[E],D=H(l,h,y);if(!q(D)&&!gt(D)){if(!z(D))throw new TypeError;y=D}}return y}function Q(u,l,h){var y=K(u,l,h);if(y)return!0;var E=$t(l);return gt(E)?!1:Q(u,E,h)}function K(u,l,h){var y=Mt(l,h,!1);return q(y)?!1:ae(y.OrdinaryHasOwnMetadata(u,l,h))}function tt(u,l,h){var y=K(u,l,h);if(y)return lt(u,l,h);var E=$t(l);if(!gt(E))return tt(u,E,h)}function lt(u,l,h){var y=Mt(l,h,!1);if(!q(y))return y.OrdinaryGetOwnMetadata(u,l,h)}function Et(u,l,h,y){var E=Mt(h,y,!0);E.OrdinaryDefineOwnMetadata(u,l,h,y)}function Tt(u,l){var h=Ct(u,l),y=$t(u);if(y===null)return h;var E=Tt(y,l);if(E.length<=0)return h;if(h.length<=0)return E;for(var H=new Z,D=[],B=0,v=h;B=0&&v=this._keys.length?(this._index=-1,this._keys=l,this._values=l):this._index++,{value:M,done:!1}}return{value:void 0,done:!0}},B.prototype.throw=function(v){throw this._index>=0&&(this._index=-1,this._keys=l,this._values=l),v},B.prototype.return=function(v){return this._index>=0&&(this._index=-1,this._keys=l,this._values=l),{value:v,done:!0}},B}(),y=function(){function B(){this._keys=[],this._values=[],this._cacheKey=u,this._cacheIndex=-2}return Object.defineProperty(B.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),B.prototype.has=function(v){return this._find(v,!1)>=0},B.prototype.get=function(v){var M=this._find(v,!1);return M>=0?this._values[M]:void 0},B.prototype.set=function(v,M){var I=this._find(v,!0);return this._values[I]=M,this},B.prototype.delete=function(v){var M=this._find(v,!1);if(M>=0){for(var I=this._keys.length,F=M+1;FXt}),nt.exports=ve(Ht);var ir=bt(vt()),Xt={};Zt(Xt,{Attribute:()=>Ut,AttributeStatic:()=>Re,Boost:()=>Lt,BoostObject:()=>mt,Currency:()=>At,CurrencyStatic:()=>Ve,DEFAULT_ITERATIONS:()=>Ot,E:()=>_,FORMATS:()=>Be,FormatTypeList:()=>we,Grid:()=>Ue,GridCell:()=>ne,LRUCache:()=>Pt,ListNode:()=>Wt,UpgradeData:()=>Nt,UpgradeStatic:()=>ie,calculateSum:()=>Gt,calculateSumApprox:()=>ee,calculateSumLoop:()=>te,calculateUpgrade:()=>Vt,decimalToJSONString:()=>Ft,inverseFunctionApprox:()=>Bt,roundingBase:()=>Ge,upgradeToCacheNameEL:()=>Rt});var nr=bt(vt()),Pt=class{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){let e=this.map.get(t);if(e!==void 0)return e!==this.first&&(e===this.last?(this.last=e.prev,this.last.next=void 0):(e.prev.next=e.next,e.next.prev=e.prev),e.next=this.first,this.first.prev=e,this.first=e),e.value}set(t,e){if(this.maxSize<1)return;if(this.map.has(t))throw new Error("Cannot update existing keys in the cache");let r=new Wt(t,e);for(this.first===void 0?(this.first=r,this.last=r):(r.next=this.first,this.first.prev=r,this.first=r),this.map.set(t,r);this.map.size>this.maxSize;){let i=this.last;this.map.delete(i.key),this.last=i.prev,this.last.next=void 0}}},Wt=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},et;(function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(et||(et={}));var Ne=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},t.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.findTransformMetadatas=function(e,r,i){return this.findMetadatas(this._transformMetadatas,e,r).filter(function(n){return!n.options||n.options.toClassOnly===!0&&n.options.toPlainOnly===!0?!0:n.options.toClassOnly===!0?i===et.CLASS_TO_CLASS||i===et.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?i===et.CLASS_TO_PLAIN:!0})},t.prototype.findExcludeMetadata=function(e,r){return this.findMetadata(this._excludeMetadatas,e,r)},t.prototype.findExposeMetadata=function(e,r){return this.findMetadata(this._exposeMetadatas,e,r)},t.prototype.findExposeMetadataByCustomName=function(e,r){return this.getExposedMetadatas(e).find(function(i){return i.options&&i.options.name===r})},t.prototype.findTypeMetadata=function(e,r){return this.findMetadata(this._typeMetadatas,e,r)},t.prototype.getStrategy=function(e){var r=this._excludeMetadatas.get(e),i=r&&r.get(void 0),n=this._exposeMetadatas.get(e),o=n&&n.get(void 0);return i&&o||!i&&!o?"none":i?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},t.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},t.prototype.getExposedProperties=function(e,r){return this.getExposedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===et.CLASS_TO_CLASS||r===et.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===et.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.getExcludedProperties=function(e,r){return this.getExcludedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===et.CLASS_TO_CLASS||r===et.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===et.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(e,r){var i=e.get(r),n;i&&(n=Array.from(i.values()).filter(function(T){return T.propertyName!==void 0}));for(var o=[],c=0,p=this.getAncestors(r);cNumber.MAX_SAFE_INTEGER)&&(b="\u03C9");let O=t.log(a,8e3).toNumber();if(m.equals(0))return b;if(m.gt(0)&&m.lte(3)){let L=[];for(let j=0;jNumber.MAX_SAFE_INTEGER)&&(b="\u03C9");let O=t.log(a,8e3).toNumber();if(m.equals(0))return b;if(m.gt(0)&&m.lte(2)){let L=[];for(let j=0;j118?e.elemental.beyondOg(w):e.elemental.config.element_lists[a-1][b]},beyondOg(a){let d=Math.floor(Math.log10(a)),m=["n","u","b","t","q","p","h","s","o","e"],b="";for(let w=d;w>=0;w--){let O=Math.floor(a/Math.pow(10,w))%10;b==""?b=m[O].toUpperCase():b+=m[O]}return b},abbreviationLength(a){return a==1?1:Math.pow(Math.floor(a/2)+1,2)*2},getAbbreviationAndValue(a){let d=a.log(118).toNumber(),m=Math.floor(d)+1,b=e.elemental.abbreviationLength(m),w=d-m+1,O=Math.floor(w*b),S=e.elemental.getAbbreviation(m,w),R=new t(118).pow(m+O/b-1);return[S,R]},formatElementalPart(a,d){return d.eq(1)?a:`${d} ${a}`},format(a,d=2){if(a.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(a.log10(),d);let m=a.log(118),w=m.log(118).log(118).toNumber(),O=Math.max(4-w*2,1),S=[];for(;m.gte(1)&&S.length=O)return S.map(L=>e.elemental.formatElementalPart(L[0],L[1])).join(" + ");let R=new t(118).pow(m).toFixed(S.length===1?3:d);return S.length===0?R:S.length===1?`${R} \xD7 ${e.elemental.formatElementalPart(S[0][0],S[0][1])}`:`${R} \xD7 (${S.map(L=>e.elemental.formatElementalPart(L[0],L[1])).join(" + ")})`}},old_sc:{format(a,d){a=new t(a);let m=a.log10().floor();if(m.lt(9))return m.lt(3)?a.toFixed(d):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let w=a.slog();return(w.gte(1e9)?"":new t(10).pow(w.sub(w.floor())).toFixed(4))+"F"+e.old_sc.format(w.floor(),0)}let b=a.div(new t(10).pow(m));return(m.log10().gte(9)?"":b.toFixed(4))+"e"+e.old_sc.format(m,0)}}},eng:{format(a,d=2){a=new t(a);let m=a.log10().floor();if(m.lt(9))return m.lt(3)?a.toFixed(d):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let w=a.slog();return(w.gte(1e9)?"":new t(10).pow(w.sub(w.floor())).toFixed(4))+"F"+e.eng.format(w.floor(),0)}let b=a.div(new t(1e3).pow(m.div(3).floor()));return(m.log10().gte(9)?"":b.toFixed(new t(4).sub(m.sub(m.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(m.div(3).floor().mul(3),0)}}},mixed_sc:{format(a,d,m=9){a=new t(a);let b=a.log10().floor();return b.lt(303)&&b.gte(m)?g(a,d,m,"st"):g(a,d,m,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(a,d=2,m){a=new t(a);let b=a.max(1).log10().max(1).log(r.log10()).floor();if(b.lte(0))return g(a,d,m,"sc");a=new t(10).pow(a.max(1).log10().div(r.log10().pow(b)).sub(b.gte(1)?1:0));let w=b.div(10).floor(),O=b.toNumber()%10-1;return g(a,Math.max(4,d),m,"sc")+" "+(w.gte(1)?"meta"+(w.gte(2)?"^"+g(w,0,m,"sc"):"")+"-":"")+(isNaN(O)?"nanity":e.layer.layers[O])}},standard:{tier1(a){return ft[0][0][a%10]+ft[0][1][Math.floor(a/10)%10]+ft[0][2][Math.floor(a/100)]},tier2(a){let d=a%10,m=Math.floor(a/10)%10,b=Math.floor(a/100)%10,w="";return a<10?ft[1][0][a]:(m==1&&d==0?w+="Vec":w+=ft[1][1][d]+ft[1][2][m],w+=ft[1][3][b],w)}},inf:{format(a,d,m){a=new t(a);let b=0,w=new t(Number.MAX_VALUE),O=["","\u221E","\u03A9","\u03A8","\u028A"],S=["","","m","mm","mmm"];for(;a.gte(w);)a=a.log(w),b++;return b==0?g(a,d,m,"sc"):a.gte(3)?S[b]+O[b]+"\u03C9^"+g(a.sub(1),d,m,"sc"):a.gte(2)?S[b]+"\u03C9"+O[b]+"-"+g(w.pow(a.sub(2)),d,m,"sc"):S[b]+O[b]+"-"+g(w.pow(a.sub(1)),d,m,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(a,d=new t(1e15),m=!1,b=9){if(a=new t(a),d=new t(d).div(1e3),a.lt(d.mul(1e3)))return"";let{alphabet:w}=e.alphabet.config,O=w.length,S=a.log(1e3).sub(d.log(1e3)).floor(),R=S.add(1).log(O+1).ceil(),L="",j=(J,rt)=>{let Q=J,K="";for(let tt=0;tt=O)return"\u03C9";K=w[lt]+K,Q=Q.sub(1).div(O).floor()}return K};if(R.lt(b))L=j(S,R);else{let J=R.sub(b).add(1),rt=S.div(t.pow(O+1,J.sub(1))).floor();L=`${j(rt,new t(b))}(${J.gt("1e9")?J.format():J.format(0)})`}return L},format(a,d=2,m=9,b="mixed_sc",w=new t(1e15),O=!1,S){if(a=new t(a),w=new t(w).div(1e3),a.lt(w.mul(1e3)))return g(a,d,m,b);let R=e.alphabet.getAbbreviation(a,w,O,S),L=a.div(t.pow(1e3,a.log(1e3).floor()));return`${R.length>(S??9)+2?"":L.toFixed(d)+" "}${R}`}}},r=new t(2).pow(1024),i="\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089",n="\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079";function o(a){return a.toFixed(0).split("").map(d=>d==="-"?"\u208B":i[parseInt(d,10)]).join("")}function c(a){return a.toFixed(0).split("").map(d=>d==="-"?"\u208B":n[parseInt(d,10)]).join("")}function p(a,d=2,m=9,b="st"){return g(a,d,m,b)}function g(a,d=2,m=9,b="mixed_sc"){a=new t(a);let w=a.lt(0)?"-":"";if(a.mag==1/0)return w+"Infinity";if(Number.isNaN(a.mag))return w+"NaN";if(a.lt(0)&&(a=a.mul(-1)),a.eq(0))return a.toFixed(d);let O=a.log10().floor();switch(b){case"sc":case"scientific":if(a.log10().lt(Math.min(-d,0))&&d>1){let S=a.log10().ceil(),R=a.div(S.eq(-1)?new t(.1):new t(10).pow(S)),L=S.mul(-1).max(1).log10().gte(9);return w+(L?"":R.toFixed(2))+"e"+g(S,0,m,"mixed_sc")}else if(O.lt(m)){let S=Math.max(Math.min(d-O.toNumber(),d),0);return w+(S>0?a.toFixed(S):a.toFixed(S).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(a.gte("eeee10")){let L=a.slog();return(L.gte(1e9)?"":new t(10).pow(L.sub(L.floor())).toFixed(2))+"F"+g(L.floor(),0)}let S=a.div(new t(10).pow(O)),R=O.log10().gte(9);return w+(R?"":S.toFixed(2))+"e"+g(O,0,m,"mixed_sc")}case"st":case"standard":{let S=a.log(1e3).floor();if(S.lt(1))return w+a.toFixed(Math.max(Math.min(d-O.toNumber(),d),0));let R=S.mul(3),L=S.log10().floor();if(L.gte(3e3))return"e"+g(O,d,m,"st");let j="";if(S.lt(4))j=["","K","M","B"][Math.round(S.toNumber())];else{let Q=Math.floor(S.log(1e3).toNumber());for(Q<100&&(Q=Math.max(Q-1,0)),S=S.sub(1).div(new t(10).pow(Q*3));S.gt(0);){let K=S.div(1e3).floor(),tt=S.sub(K.mul(1e3)).floor().toNumber();tt>0&&(tt==1&&!Q&&(j="U"),Q&&(j=e.standard.tier2(Q)+(j?"-"+j:"")),tt>1&&(j=e.standard.tier1(tt)+j)),S=K,Q++}}let J=a.div(new t(10).pow(R)),rt=d===2?new t(2).sub(O.sub(R)).add(1).toNumber():d;return w+(L.gte(10)?"":J.toFixed(rt)+" ")+j}default:return e[b]||console.error('Invalid format type "',b,'"'),w+e[b].format(a,d,m)}}function N(a,d,m="mixed_sc",b,w){a=new t(a),d=new t(d);let O=a.add(d),S,R=O.div(a);return R.gte(10)&&a.gte(1e100)?(R=R.log10().mul(20),S="(+"+g(R,b,w,m)+" OoMs/sec)"):S="(+"+g(d,b,w,m)+"/sec)",S}function P(a,d=2,m="s"){return a=new t(a),a.gte(86400)?g(a.div(86400).floor(),0,12,"sc")+":"+P(a.mod(86400),d,"d"):a.gte(3600)||m=="d"?(a.div(3600).gte(10)||m!="d"?"":"0")+g(a.div(3600).floor(),0,12,"sc")+":"+P(a.mod(3600),d,"h"):a.gte(60)||m=="h"?(a.div(60).gte(10)||m!="h"?"":"0")+g(a.div(60).floor(),0,12,"sc")+":"+P(a.mod(60),d,"m"):(a.gte(10)||m!="m"?"":"0")+g(a,d,12,"sc")}function T(a,d=!1,m=0,b=9,w="mixed_sc"){let O=Ct=>g(Ct,m,b,w);a=new t(a);let S=a.mul(1e3).mod(1e3).floor(),R=a.mod(60).floor(),L=a.div(60).mod(60).floor(),j=a.div(3600).mod(24).floor(),J=a.div(86400).mod(365.2425).floor(),rt=a.div(31556952).floor(),Q=rt.eq(1)?" year":" years",K=J.eq(1)?" day":" days",tt=j.eq(1)?" hour":" hours",lt=L.eq(1)?" minute":" minutes",Et=R.eq(1)?" second":" seconds",Tt=S.eq(1)?" millisecond":" milliseconds";return`${rt.gt(0)?O(rt)+Q+", ":""}${J.gt(0)?O(J)+K+", ":""}${j.gt(0)?O(j)+tt+", ":""}${L.gt(0)?O(L)+lt+", ":""}${R.gt(0)?O(R)+Et+",":""}${d&&S.gt(0)?" "+O(S)+Tt:""}`.replace(/,([^,]*)$/,"$1").trim()}function U(a){return a=new t(a),g(new t(1).sub(a).mul(100))+"%"}function x(a){return a=new t(a),g(a.mul(100))+"%"}function Z(a,d=2){return a=new t(a),a.gte(1)?"\xD7"+a.format(d):"/"+a.pow(-1).format(d)}function C(a,d,m=10){return t.gte(a,10)?t.pow(m,t.log(a,m).pow(d)):new t(a)}function k(a,d=0){a=new t(a);let m=(S=>S.map((R,L)=>({name:R.name,altName:R.altName,value:t.pow(1e3,new t(L).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"E",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),b="",w=a.lte(0)?0:t.min(t.log(a,1e3).sub(1),m.length-1).floor().toNumber(),O=m[w];if(w===0)switch(d){case 1:b="";break;case 2:case 0:default:b=a.format();break}switch(d){case 1:b=O.name;break;case 2:b=a.divide(O.value).format();break;case 3:b=O.altName;break;case 0:default:b=`${a.divide(O.value).format()} ${O.name}`;break}return b}function Y(a,d=!1){return`${k(a,2)} ${k(a,1)}eV${d?"/c^2":""}`}let W={...e,toSubscript:o,toSuperscript:c,formatST:p,format:g,formatGain:N,formatTime:P,formatTimeLong:T,formatReduction:U,formatPercent:x,formatMult:Z,expMult:C,metric:k,ev:Y};return{FORMATS:e,formats:W}}var xt=17,Se=9e15,Ie=Math.log10(9e15),Oe=1/9e15,Fe=308,Ae=-324,Dt=5,Ee=1023,Te=!0,Ce=!1,Pe=function(){let t=[];for(let r=Ae+1;r<=Fe;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),ht=[2,Math.E,3,4,5,6,7,8,9,10],qe=[[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]],xe=[[-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]],f=function(e){return s.fromValue_noAlloc(e)},A=function(t,e,r){return s.fromComponents(t,e,r)},V=function(e,r,i){return s.fromComponents_noNormalize(e,r,i)},ut=function(e,r){let i=r+1,n=Math.ceil(Math.log10(Math.abs(e))),o=Math.round(e*Math.pow(10,i-n))*Math.pow(10,n-i);return parseFloat(o.toFixed(Math.max(i-n,0)))},kt=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},ke=function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;let e=1;for(;t<10;)e=e*t,++t;t-=1;let r=.9189385332046727;r=r+(t+.5)*Math.log(t),r=r-t;let i=t*t,n=t;return r=r+1/(12*n),n=n*i,r=r+1/(360*n),n=n*i,r=r+1/(1260*n),n=n*i,r=r+1/(1680*n),n=n*i,r=r+1/(1188*n),n=n*i,r=r+691/(360360*n),n=n*i,r=r+7/(1092*n),n=n*i,r=r+3617/(122400*n),Math.exp(r)/e},Le=.36787944117144233,Qt=.5671432904097838,Jt=function(t,e=1e-10){let r,i;if(!Number.isFinite(t)||t===0)return t;if(t===1)return Qt;t<10?r=0:r=Math.log(t)-Math.log(Math.log(t));for(let n=0;n<100;++n){if(i=(t*Math.exp(-r)+r*r)/(r+1),Math.abs(i-r).5?1:-1;if(Math.random()*20<1)return V(e,0,1);let r=Math.floor(Math.random()*(t+1)),i=r===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let n=Math.pow(10,i);return Math.random()>.9&&(n=Math.trunc(n)),A(e,r,n)}static affordGeometricSeries_core(t,e,r,i){let n=e.mul(r.pow(i));return s.floor(t.div(n).mul(r.sub(1)).add(1).log10().div(r.log10()))}static sumGeometricSeries_core(t,e,r,i){return e.mul(r.pow(i)).mul(s.sub(1,r.pow(t))).div(s.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let o=e.add(i.mul(r)).sub(r.div(2)),c=o.pow(2);return o.neg().add(c.add(r.mul(t).mul(2)).sqrt()).div(r).floor()}static sumArithmeticSeries_core(t,e,r,i){let n=e.add(i.mul(r));return t.div(2).mul(n.mul(2).plus(t.sub(1).mul(r)))}static efficiencyOfPurchase_core(t,e,r){return t.div(e).add(t.div(r))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0||this.mag===Number.NEGATIVE_INFINITY&&this.layer>0&&Number.isFinite(this.layer))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.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_INFINITY)return this.sign==1?(this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY):this.sign==-1&&(this.mag=Number.NEGATIVE_INFINITY,this.layer=Number.NEGATIVE_INFINITY),this;if(this.layer===0&&this.mag=Se)return this.layer+=1,this.mag=e*Math.log10(t),this;for(;t0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=e*Math.pow(10,t),t=Math.abs(this.mag),e=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)),(Number.isNaN(this.sign)||Number.isNaN(this.layer)||Number.isNaN(this.mag))&&(this.sign=Number.NaN,this.layer=Number.NaN,this.mag=Number.NaN),this}fromComponents(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this.normalize(),this}fromComponents_noNormalize(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this}fromMantissaExponent(t,e){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=e+Math.log10(t),this.normalize(),this}fromMantissaExponent_noNormalize(t,e){return this.fromMantissaExponent(t,e),this}fromDecimal(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this}fromNumber(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this}fromString(t,e=!1){let r=t,i=s.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);Te?t=t.replace(",",""):Ce&&(t=t.replace(",","."));let n=t.split("^^^");if(n.length===2){let C=parseFloat(n[0]),k=parseFloat(n[1]),Y=n[1].split(";"),W=1;if(Y.length===2&&(W=parseFloat(Y[1]),isFinite(W)||(W=1)),isFinite(C)&&isFinite(k)){let a=s.pentate(C,k,W,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let o=t.split("^^");if(o.length===2){let C=parseFloat(o[0]),k=parseFloat(o[1]),Y=o[1].split(";"),W=1;if(Y.length===2&&(W=parseFloat(Y[1]),isFinite(W)||(W=1)),isFinite(C)&&isFinite(k)){let a=s.tetrate(C,k,W,e);return this.sign=a.sign,this.layer=a.layer,this.mag=a.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let c=t.split("^");if(c.length===2){let C=parseFloat(c[0]),k=parseFloat(c[1]);if(isFinite(C)&&isFinite(k)){let Y=s.pow(C,k);return this.sign=Y.sign,this.layer=Y.layer,this.mag=Y.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}t=t.trim().toLowerCase();let p,g,N=t.split("pt");if(N.length===2){p=10,g=parseFloat(N[0]),N[1]=N[1].replace("(",""),N[1]=N[1].replace(")","");let C=parseFloat(N[1]);if(isFinite(C)||(C=1),isFinite(p)&&isFinite(g)){let k=s.tetrate(p,g,C,e);return this.sign=k.sign,this.layer=k.layer,this.mag=k.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(N=t.split("p"),N.length===2){p=10,g=parseFloat(N[0]),N[1]=N[1].replace("(",""),N[1]=N[1].replace(")","");let C=parseFloat(N[1]);if(isFinite(C)||(C=1),isFinite(p)&&isFinite(g)){let k=s.tetrate(p,g,C,e);return this.sign=k.sign,this.layer=k.layer,this.mag=k.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(N=t.split("f"),N.length===2){p=10,N[0]=N[0].replace("(",""),N[0]=N[0].replace(")","");let C=parseFloat(N[0]);if(N[1]=N[1].replace("(",""),N[1]=N[1].replace(")",""),g=parseFloat(N[1]),isFinite(C)||(C=1),isFinite(p)&&isFinite(g)){let k=s.tetrate(p,g,C,e);return this.sign=k.sign,this.layer=k.layer,this.mag=k.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let P=t.split("e"),T=P.length-1;if(T===0){let C=parseFloat(t);if(isFinite(C))return this.fromNumber(C),s.fromStringCache.size>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else if(T===1){let C=parseFloat(t);if(isFinite(C)&&C!==0)return this.fromNumber(C),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}let U=t.split("e^");if(U.length===2){this.sign=1,U[0].charAt(0)=="-"&&(this.sign=-1);let C="";for(let k=0;k=43&&Y<=57||Y===101)C+=U[1].charAt(k);else return this.layer=parseFloat(C),this.mag=parseFloat(U[1].substr(k+1)),this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(T<1)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let x=parseFloat(P[0]);if(x===0)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let Z=parseFloat(P[P.length-1]);if(T>=2){let C=parseFloat(P[P.length-2]);isFinite(C)&&(Z*=Math.sign(C),Z+=kt(C))}if(!isFinite(x))this.sign=P[0]==="-"?-1:1,this.layer=T,this.mag=Z;else if(T===1)this.sign=Math.sign(x),this.layer=1,this.mag=Z+Math.log10(Math.abs(x));else if(this.sign=Math.sign(x),this.layer=T,T===2){let C=s.mul(A(1,2,Z),f(x));return this.sign=C.sign,this.layer=C.layer,this.mag=C.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else this.mag=Z;return this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}fromValue(t){return t instanceof s?this.fromDecimal(t):typeof t=="number"?this.fromNumber(t):typeof t=="string"?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===1?Number.POSITIVE_INFINITY:this.mag===Number.NEGATIVE_INFINITY&&this.layer===Number.NEGATIVE_INFINITY&&this.sign===-1?Number.NEGATIVE_INFINITY: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(t){return isNaN(this.m)?Number.NaN:this.m===0?0:ut(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:ut(this.mag,t)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_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<=Dt?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(t){return this.layer===0?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)}toFixed(t){return this.layer===0?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)}toPrecision(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(t){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(t):ut(this.m,t)+"e"+ut(this.e,t):this.layer===1?ut(this.m,t)+"e"+ut(this.e,t):this.layer<=Dt?(this.sign===-1?"-":"")+"e".repeat(this.layer)+ut(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+ut(this.mag,t)}abs(){return V(this.sign===0?0:1,this.layer,this.mag)}neg(){return V(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?s.dZero:this.layer===0?A(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?this.sign===-1?s.dNegOne:s.dZero:this.sign===-1?this.neg().ceil().neg():this.layer===0?A(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?this.sign===1?s.dOne:s.dZero:this.sign===-1?this.neg().floor().neg():this.layer===0?A(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?s.dZero:this.layer===0?A(this.sign,0,Math.trunc(this.mag)):this}add(t){let e=f(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer)||this.sign===0)return e;if(e.sign===0)return this;if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return V(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(s.cmpabs(this,e)>0?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*r.mag+i.sign*i.mag);let n=r.layer*Math.sign(r.mag),o=i.layer*Math.sign(i.mag);if(n-o>=2)return r;if(n===0&&o===-1){if(Math.abs(i.mag-Math.log10(r.mag))>xt)return r;{let c=Math.pow(10,Math.log10(r.mag)-i.mag),p=i.sign+r.sign*c;return A(Math.sign(p),1,i.mag+Math.log10(Math.abs(p)))}}if(n===1&&o===0){if(Math.abs(r.mag-Math.log10(i.mag))>xt)return r;{let c=Math.pow(10,r.mag-Math.log10(i.mag)),p=i.sign+r.sign*c;return A(Math.sign(p),1,Math.log10(i.mag)+Math.log10(Math.abs(p)))}}if(Math.abs(r.mag-i.mag)>xt)return r;{let c=Math.pow(10,r.mag-i.mag),p=i.sign+r.sign*c;return A(Math.sign(p),1,i.mag+Math.log10(Math.abs(p)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(f(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=f(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer))return e;if(this.sign===0||e.sign===0)return V(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return V(this.sign*e.sign,0,1);let r,i;if(this.layer>e.layer||this.layer==e.layer&&Math.abs(this.mag)>Math.abs(e.mag)?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return A(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return A(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return A(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let n=A(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(A(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return A(r.sign*i.sign,n.layer+1,n.sign*n.mag)}if(r.layer===2&&i.layer===2){let n=A(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(A(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return A(r.sign*i.sign,n.layer+1,n.sign*n.mag)}throw Error("Bad arguments to mul: "+this+", "+t)}multiply(t){return this.mul(t)}times(t){return this.mul(t)}div(t){let e=f(t);return this.mul(e.recip())}divide(t){return this.div(t)}divideBy(t){return this.div(t)}dividedBy(t){return this.div(t)}recip(){return this.mag===0?s.dNaN:this.layer===0?A(this.sign,0,1/this.mag):A(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=f(t).abs();if(e.eq(s.dZero))return s.dZero;let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new s(r%i):this.sub(e).eq(this)?s.dZero:e.sub(this).eq(e)?this:this.sign==-1?this.abs().mod(e).neg():this.sub(this.div(e).floor().mul(e))}modulo(t){return this.mod(t)}modular(t){return this.mod(t)}cmp(t){let e=f(t);return this.sign>e.sign?1:this.sign0?this.layer:-this.layer,i=e.mag>0?e.layer:-e.layer;return r>i?1:re.mag?1:this.mag0?e:this}clamp(t,e){return this.max(t).min(e)}clampMin(t){return this.max(t)}clampMax(t){return this.min(t)}cmp_tolerance(t,e){let r=f(t);return this.eq_tolerance(r,e)?0:this.cmp(r)}compare_tolerance(t,e){return this.cmp_tolerance(t,e)}eq_tolerance(t,e){let r=f(t);if(e==null&&(e=1e-7),this.sign!==r.sign||Math.abs(this.layer-r.layer)>1)return!1;let i=this.mag,n=r.mag;return this.layer>r.layer&&(n=kt(n)),this.layer0?A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):A(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?s.dNaN:this.layer>0?A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):A(this.sign,0,Math.log10(this.mag))}log(t){return t=f(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?s.dNaN:this.layer===0&&t.layer===0?A(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):s.div(this.log10(),t.log10())}log2(){return this.sign<=0?s.dNaN:this.layer===0?A(this.sign,0,Math.log2(this.mag)):this.layer===1?A(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?A(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?s.dNaN:this.layer===0?A(this.sign,0,Math.log(this.mag)):this.layer===1?A(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?A(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):A(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=f(t),r=this,i=e;if(r.sign===0)return i.eq(0)?V(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return V(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return r;let n=r.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?n.neg():Math.abs(i.toNumber()%2)%2===0?n:s.dNaN:n}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return s.dNaN;let t=this;if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return A(1,0,e);if(t.sign===0)return s.dOne;t=V(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?A(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?A(-t.sign,t.layer+1,-t.mag):s.dOne}pow_base(t){return f(t).pow(this)}root(t){let e=f(t);return this.pow(e.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(V(1,0,24)))return s.fromNumber(ke(this.sign*this.mag));let t=this.mag-1,e=.9189385332046727;e=e+(t+.5)*Math.log(t),e=e-t;let r=t*t,i=t,n=12*i,o=1/n,c=e+o;if(c===e||(e=c,i=i*r,n=360*i,o=1/n,c=e-o,c===e))return s.exp(e);e=c,i=i*r,n=1260*i;let p=1/n;return e=e+p,i=i*r,n=1680*i,p=1/n,e=e-p,s.exp(e)}else return this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?s.dOne:this.layer===0&&this.mag<=709.7?s.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?A(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?A(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):A(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return s.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return A(1,2,Math.log10(this.mag)-.3010299956639812);{let t=s.div(V(this.sign,this.layer-1,this.mag),V(1,0,2));return t.layer+=1,t.normalize(),t}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(t=2,e=V(1,0,1),r=!1){if(t===1)return s.pow(this,e);if(t===0)return new s(e);if(this.eq(s.dOne))return s.dOne;if(this.eq(-1))return s.pow(this,e);if(t===Number.POSITIVE_INFINITY){let o=this.toNumber();if(o<=1.444667861009766&&o>=.06598803584531254){if(o>1.444667861009099)return s.fromNumber(Math.E);let c=s.ln(this).neg();return c.lambertw().div(c)}else return o>1.444667861009766?s.fromNumber(Number.POSITIVE_INFINITY):s.dNaN}if(this.eq(s.dZero)){let o=Math.abs((t+1)%2);return o>1&&(o=2-o),s.fromNumber(o)}if(t<0)return s.iteratedlog(e,this,-t,r);e=f(e);let i=t;t=Math.trunc(t);let n=i-t;if(this.gt(s.dZero)&&this.lte(1.444667861009766)&&(i>1e4||!r)){t=Math.min(1e4,t);for(let o=0;o1e4){let o=this.pow(e);return i<=1e4||Math.ceil(i)%2==0?e.mul(1-n).add(o.mul(n)):e.mul(n).add(o.mul(1-n))}return e}n!==0&&(e.eq(s.dOne)?this.gt(10)||r?e=this.pow(n):(e=s.fromNumber(s.tetrate_critical(this.toNumber(),n)),this.lt(2)&&(e=e.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let o=0;o3)return V(e.sign,e.layer+(t-o-1),e.mag);if(o>1e4)return e}return e}iteratedexp(t=2,e=V(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return s.tetrate(t,-e,this,r);t=f(t);let i=s.fromDecimal(this),n=e;e=Math.trunc(e);let o=n-e;if(i.layer-t.layer>3){let c=Math.min(e,i.layer-t.layer-3);e-=c,i.layer-=c}for(let c=0;c1e4)return i}return o>0&&o<1&&(t.eq(10)?i=i.layeradd10(-o,r):i=i.layeradd(-o,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,n=!1,o=!1,c=this.slog_internal(t,r).toNumber();for(let p=1;p1&&o!=N&&(n=!0),o=N,n?i/=2:i*=2,i=Math.abs(i)*(N?-1:1),c+=i,i===0)break}return s.fromNumber(c)}slog_internal(t=10,e=!1){if(t=f(t),t.lte(s.dZero)||t.eq(s.dOne))return s.dNaN;if(t.lt(s.dOne))return this.eq(s.dOne)?s.dZero:this.eq(s.dZero)?s.dNegOne:s.dNaN;if(this.mag<0||this.eq(s.dZero))return s.dNegOne;let r=0,i=s.fromDecimal(this);if(i.layer-t.layer>3){let n=i.layer-t.layer-3;r+=n,i.layer-=n}for(let n=0;n<100;++n)if(i.lt(s.dZero))i=s.pow(t,i),r-=1;else{if(i.lte(s.dOne))return e?s.fromNumber(r+i.toNumber()-1):s.fromNumber(r+s.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=s.log(i,t)}return s.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:s.critical_section(t,e,xe)}static tetrate_critical(t,e){return s.critical_section(t,e,qe)}static critical_section(t,e,r,i=!1){e*=10,e<0&&(e=0),e>10&&(e=10),t<2&&(t=2),t>10&&(t=10);let n=0,o=0;for(let p=0;pt){let g=(t-ht[p])/(ht[p+1]-ht[p]);n=r[p][Math.floor(e)]*(1-g)+r[p+1][Math.floor(e)]*g,o=r[p][Math.ceil(e)]*(1-g)+r[p+1][Math.ceil(e)]*g;break}let c=e-Math.floor(e);return n<=0||o<=0?n*(1-c)+o*c:Math.pow(t,Math.log(n)/Math.log(t)*(1-c)+Math.log(o)/Math.log(t)*c)}layeradd10(t,e=!1){t=s.fromValue_noAlloc(t).toNumber();let r=s.fromDecimal(this);if(t>=1){r.mag<0&&r.layer>0?(r.sign=0,r.mag=0,r.layer=0):r.sign===-1&&r.layer==0&&(r.sign=1,r.mag=-r.mag);let i=Math.trunc(t);t-=i,r.layer+=i}if(t<=-1){let i=Math.trunc(t);if(t-=i,r.layer+=i,r.layer<0)for(let n=0;n<100;++n){if(r.layer++,r.mag=Math.log10(r.mag),!isFinite(r.mag))return r.sign===0&&(r.sign=1),r.layer<0&&(r.layer=0),r.normalize();if(r.layer>=0)break}}for(;r.layer<0;)r.layer++,r.mag=Math.log10(r.mag);return r.sign===0&&(r.sign=1,r.mag===0&&r.layer>=1&&(r.layer-=1,r.mag=1)),r.normalize(),t!==0?r.layeradd(t,10,e):r}layeradd(t,e,r=!1){let n=this.slog(e).toNumber()+t;return n>=0?s.tetrate(e,n,s.dOne,r):Number.isFinite(n)?n>=-1?s.log(s.tetrate(e,n+1,s.dOne,r),e):s.log(s.log(s.tetrate(e,n+2,s.dOne,r),e),e):s.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return s.fromNumber(Jt(this.toNumber()));if(this.layer===0)return s.fromNumber(Jt(this.sign*this.mag));if(this.layer===1)return Kt(this);if(this.layer===2)return Kt(this);if(this.layer>=3)return V(this.sign,this.layer-1,this.mag);throw"Unhandled behavior in lambertw()"}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(s.dInf))return s.dInf;if(!this.isFinite())return s.dNaN;if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return s.fromNumber(t).add(2).pow(this.recip());if(t<=0)return s.dNaN;if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return eLe?this.pow(this.recip()):s.dNaN}if(this.eq(1))return s.dOne;if(this.lt(0))return s.dNaN;if(this.lte("1ee-16"))return t%2==1?this:s.dNaN;if(this.gt(1)){let e=s.dTen;this.gte(s.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=s.dZero,i=e.layer,n=e.iteratedlog(10,i,!0),o=n,c=n.div(2),p=!0;for(;p;)c=r.add(n).div(2),s.iteratedexp(10,i,c,!0).tetrate(t,1,!0).gt(this)?n=c:r=c,c.eq(o)?p=!1:o=c;return s.iteratedexp(10,i,c,!0)}else{let e=1,r=A(1,10,1),i=A(1,10,1),n=A(1,10,1),o=A(1,1,-16),c=s.dZero,p=A(1,10,1),g=o.pow10().recip(),N=s.dZero,P=g,T=g,U=Math.ceil(t)%2==0,x=0,Z=A(1,10,1),C=!1,k=s.dZero,Y=!1;for(;e<4;){if(e==2){if(U)break;n=A(1,10,1),o=r,e=3,p=A(1,10,1),Z=A(1,10,1)}for(C=!1;o.neq(n);){if(k=o,o.pow10().recip().tetrate(t,1,!0).eq(1)&&o.pow10().recip().lt(.4))g=o.pow10().recip(),P=o.pow10().recip(),T=o.pow10().recip(),N=s.dZero,x=-1,e==3&&(Z=o);else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip())&&!U&&o.pow10().recip().lt(.4))g=o.pow10().recip(),P=o.pow10().recip(),T=o.pow10().recip(),N=s.dZero,x=0;else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip().mul(2).tetrate(t,1,!0)))g=o.pow10().recip(),P=s.dZero,T=g.mul(2),N=g,U?x=-1:x=0;else{for(c=o.mul(12e-17),g=o.pow10().recip(),P=o.add(c).pow10().recip(),N=g.sub(P),T=g.add(N);P.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||T.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||P.gte(g)||T.lte(g);)c=c.mul(2),P=o.add(c).pow10().recip(),N=g.sub(P),T=g.add(N);if((e==1&&T.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))&&P.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))||e==3&&T.tetrate(t,1,!0).lt(g.tetrate(t,1,!0))&&P.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))&&(Z=o),T.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))x=-1;else if(U)x=1;else if(e==3&&o.gt_tolerance(r,1e-8))x=0;else{for(;P.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||T.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||P.gte(g)||T.lte(g);)c=c.mul(2),P=o.add(c).pow10().recip(),N=g.sub(P),T=g.add(N);T.tetrate(t,1,!0).sub(g.tetrate(t,1,!0)).lt(g.tetrate(t,1,!0).sub(P.tetrate(t,1,!0)))?x=0:x=1}}if(x==-1&&(Y=!0),e==1&&x==1||e==3&&x!=0)if(n.eq(A(1,10,1)))o=o.mul(2);else{let m=!1;if(C&&(x==1&&e==1||x==-1&&e==3)&&(m=!0),o=o.add(n).div(2),m)break}else if(n.eq(A(1,10,1)))n=o,o=o.div(2);else{let m=!1;if(C&&(x==1&&e==1||x==-1&&e==3)&&(m=!0),n=n.sub(p),o=o.sub(p),m)break}if(n.sub(o).div(2).abs().gt(p.mul(1.5))&&(C=!0),p=n.sub(o).div(2).abs(),o.gt("1e18")||o.eq(k))break}if(o.gt("1e18")||!Y||Z==A(1,10,1))break;e==1?r=Z:e==3&&(i=Z),e++}n=r,o=A(1,1,-18);let W=o,a=s.dZero,d=!0;for(;d;)if(n.eq(A(1,10,1))?a=o.mul(2):a=n.add(o).div(2),s.pow(10,a).recip().tetrate(t,1,!0).gt(this)?o=a:n=a,a.eq(W)?d=!1:W=a,o.gt("1e18"))return s.dNaN;if(a.eq_tolerance(r,1e-15)){if(i.eq(A(1,10,1)))return s.dNaN;for(n=A(1,10,1),o=i,W=o,a=s.dZero,d=!0;d;)if(n.eq(A(1,10,1))?a=o.mul(2):a=n.add(o).div(2),s.pow(10,a).recip().tetrate(t,1,!0).gt(this)?o=a:n=a,a.eq(W)?d=!1:W=a,o.gt("1e18"))return s.dNaN;return a.pow10().recip()}else return a.pow10().recip()}}pentate(t=2,e=V(1,0,1),r=!1){e=f(e);let i=t;t=Math.trunc(t);let n=i-t;n!==0&&(e.eq(s.dOne)?(++t,e=s.fromNumber(n)):this.eq(10)?e=e.layeradd10(n,r):e=e.layeradd(n,this,r));for(let o=0;o10)return e}return e}sin(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.sin(this.sign*this.mag)):V(0,0,0)}cos(){return this.mag<0?s.dOne:this.layer===0?s.fromNumber(Math.cos(this.sign*this.mag)):V(0,0,0)}tan(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.tan(this.sign*this.mag)):V(0,0,0)}asin(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.asin(this.sign*this.mag)):V(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?s.fromNumber(Math.acos(this.toNumber())):this.layer===0?s.fromNumber(Math.acos(this.sign*this.mag)):V(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.atan(this.sign*this.mag)):s.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 s.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return s.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?V(Number.NaN,Number.NaN,Number.NaN):s.ln(this.add(1).div(s.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?this:this.root(s.pow(10,t))}egg(){return this.add(9)}lessThanOrEqualTo(t){return this.cmp(t)<1}lessThan(t){return this.cmp(t)<0}greaterThanOrEqualTo(t){return this.cmp(t)>-1}greaterThan(t){return this.cmp(t)>0}static smoothDamp(t,e,r,i){return new s(t).add(new s(e).minus(new s(t)).times(new s(r)).times(new s(i)))}clone(){return this}static clone(t){return s.fromComponents(t.sign,t.layer,t.mag)}softcap(t,e,r){let i=this.clone();return i.gte(t)&&([0,"pow"].includes(r)&&(i=i.div(t).pow(e).mul(t)),[1,"mul"].includes(r)&&(i=i.sub(t).div(e).add(t))),i}static softcap(t,e,r,i){return new s(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new s(t),e=new s(e);let n=this.clone();return n.gte(t)&&([0,"pow"].includes(r)&&(n=i?n.mul(t.pow(e.sub(1))).root(e):n.pow(e).div(t.pow(e.sub(1)))),[1,"exp"].includes(r)&&(n=i?n.div(t).max(1).log(e).add(t):s.pow(e,n.sub(t)).mul(t))),n}static scale(t,e,r,i,n=!1){return new s(t).scale(e,r,i,n)}format(t=2,e=9,r="mixed_sc"){return ct.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return ct.format(new s(t),e,r,i)}formatST(t=2,e=9,r="st"){return ct.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return ct.format(new s(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return ct.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,n){return ct.formatGain(new s(t),e,r,i,n)}toRoman(t=5e3){t=new s(t);let e=this.clone();if(e.gte(t)||e.lt(1))return e;let r=e.toNumber(),i={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},n="";for(let o of Object.keys(i)){let c=Math.floor(r/i[o]);r-=c*i[o],n+=o.repeat(c)}return n}static toRoman(t,e){return new s(t).toRoman(e)}static random(t=0,e=1){return t=new s(t),e=new s(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new s(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new s(Math.random()).lt(t)}};s.dZero=V(0,0,0),s.dOne=V(1,0,1),s.dNegOne=V(-1,0,1),s.dTwo=V(1,0,2),s.dTen=V(1,0,10),s.dNaN=V(Number.NaN,Number.NaN,Number.NaN),s.dInf=V(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNegInf=V(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),s.dNumberMax=A(1,0,Number.MAX_VALUE),s.dNumberMin=A(1,0,Number.MIN_VALUE),s.fromStringCache=new Pt(Ee),at([St()],s.prototype,"sign",2),at([St()],s.prototype,"mag",2),at([St()],s.prototype,"layer",2),s=at([Me()],s);var{formats:ct,FORMATS:Be}=_e(s);s.formats=ct;var _=(()=>{let t=e=>new s(e);return Object.getOwnPropertyNames(s).filter(e=>!Object.getOwnPropertyNames(class{}).includes(e)).forEach(e=>{t[e]=s[e]}),t})(),mt=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.value=t.value,this.order=t.order??99}},Lt=class{constructor(t=1,e){this.addBoost=this.setBoost.bind(this),e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=_(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new mt(r))})}getBoosts(t,e){let r=[],i=[];for(let n=0;nT),N=n,P=this.getBoosts(o,!0);P[0][0]?this.boostArray[P[1][0]]=new mt({id:o,name:c,description:p,value:g,order:N}):this.boostArray.push(new mt({id:o,name:c,description:p,value:g,order:N}))}else{t=Array.isArray(t)?t:[t];for(let o=0;oi.order-n.order);for(let i=0;ie.cost(Z.add(r)),U=_.min(i,Bt(T,t,n,o).value.floor()),x=_(0);return[U,x]}let g=Bt(T=>Gt(e.cost,T,r),t,n,o).value.floor().min(r.add(p).sub(1)),N=Gt(e.cost,g,r);return[g.sub(r).add(1).max(0),N]}function Ft(t){return t=_(t),`${t.sign}/${t.mag}/${t.layer}`}function re(t,e){return`sum/${Ft(t)}/${Ft(e)}}`}function Rt(t){return`el/${Ft(t)}`}var Nt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?_(t.level):_(1)}};at([St()],Nt.prototype,"id",2),at([It(()=>s)],Nt.prototype,"level",2);var ie=class de{static{this.cacheSize=63}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn()}get level(){return((this??{data:{level:_(1)}}).data??{level:_(1)}).level}set level(e){this.data.level=_(e)}constructor(e,r,i){let n=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>n,this.cache=new Pt(i??de.cacheSize),this.id=e.id,this.name=e.name??e.id,this.descriptionFn=e.description?typeof e.description=="function"?e.description:()=>e.description:()=>"",this.cost=e.cost,this.costBulk=e.costBulk,this.maxLevel=e.maxLevel,this.effect=e.effect,this.el=e.el}getCached(e,r,i){return e==="sum"?this.cache.get(re(r,i??_(0))):this.cache.get(Rt(r))}setCached(e,r,i,n){let o=e==="sum"?{id:this.id,el:!1,start:_(r),end:_(i),cost:_(n)}:{id:this.id,el:!0,level:_(r),cost:_(i)};return e==="sum"?this.cache.set(re(r,i),o):this.cache.set(Rt(r),o),o}},ar=bt(vt()),At=class{constructor(){this.value=_(0),this.upgrades={}}};at([It(()=>s)],At.prototype,"value",2),at([It(()=>Nt)],At.prototype,"upgrades",2);var Ve=class{get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}constructor(t=new At,e,r={defaultVal:_(0),defaultBoost:_(1)}){this.defaultVal=r.defaultVal,this.defaultBoost=r.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new Lt(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e)}onLoadData(){for(let t of Object.values(this.upgrades))t.effect?.(t.level,t)}reset(t=!0,e=!0){if(t&&(this.value=this.defaultVal),e)for(let r of Object.values(this.upgrades))r.level=_(0)}gain(t=1e3){let e=this.boost.calculate().mul(_(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new Nt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r={};for(let i of t){let n=this.pointerAddUpgrade(i),o=new ie(i,()=>this.pointerGetUpgrade(i.id));o.effect&&e&&o.effect(o.level,o),r[i.id]=o,this.upgrades[i.id]=o}return Object.values(r)}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&(r.name=e.name??r.name,r.cost=e.cost??r.cost,r.maxLevel=e.maxLevel??r.maxLevel,r.effect=e.effect??r.effect)}calculateUpgrade(t,e,r,i){let n=this.getUpgrade(t);return n===null?(console.warn(`Upgrade "${t}" not found.`),[_(0),_(0)]):Vt(this.value,n,n.level,e?n.level.add(e):void 0,r,i)}getNextCost(t,e=0,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),_(0);let o=Vt(this.value,n,n.level,n.level.add(e),r,i)[1];return n.cost(n.level.add(o))}buyUpgrade(t,e,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),!1;let[o,c]=this.calculateUpgrade(t,e,r,i);return o.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(c),n.level=n.level.add(o),n.effect?.(n.level,n),!0)}},or=bt(vt()),Ut=class{constructor(t=0){this.value=_(t)}};at([It(()=>s)],Ut.prototype,"value",2);var Re=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=_(r),t??=new Ut(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new Lt(this.initial):null}update(){console.warn("AttributeStatic.update is deprecated and will be removed in the future. The value is automatically updated when accessed."),this.boost&&(this.pointer.value=this.boost.calculate())}get value(){return this.boost&&(this.pointer.value=this.boost.calculate()),this.pointer.value}set value(t){if(this.boost)throw new Error("Cannot set value of attributeStatic when boost is enabled.");this.pointer.value=t}},ne=class{constructor(t,e,r){this.x=t,this.y=e,this.properties=r??{}}setValue(t,e){return this.properties[t]=e,e}getValue(t){return this.properties[t]}},Ue=class{constructor(t,e,r){this.xSize=t,this.ySize=e,this.cells=[];for(let i=0;i{if(e&&typeof e=="object"||typeof e=="function")for(let n of Object.getOwnPropertyNames(e))!Object.prototype.hasOwnProperty.call(t,n)&&n!==r&&Object.defineProperty(t,n,{get:()=>e[n],enumerable:!(i=Object.getOwnPropertyDescriptor(e,n))||i.enumerable});return t};nt.exports=je(nt.exports,pt)}return nt.exports}); /*! Bundled license information: reflect-metadata/Reflect.js: diff --git a/dist/main/eMath.mjs b/dist/main/eMath.mjs index 75faa958..c16d6669 100644 --- a/dist/main/eMath.mjs +++ b/dist/main/eMath.mjs @@ -705,7 +705,7 @@ function decimalFormatGenerator(Decimal2) { default: if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); - return neg + FORMATS2[type]?.format(ex, acc, max); + return neg + FORMATS2[type].format(ex, acc, max); } } function formatGain(amt, gain, type = "mixed_sc", acc, max) { @@ -835,7 +835,7 @@ function decimalFormatGenerator(Decimal2) { output = abbMax["name"]; break; case 2: - output = `${num.divide(abbMax["value"]).format()}`; + output = num.divide(abbMax["value"]).format(); break; case 3: output = abbMax["altName"]; @@ -4730,7 +4730,7 @@ var Boost = class { * @alias setBoost * @deprecated Use {@link setBoost} instead. */ - this.addBoost = this.setBoost; + this.addBoost = this.setBoost.bind(this); boosts = boosts ? Array.isArray(boosts) ? boosts : [boosts] : void 0; this.baseEffect = E(baseEffect); this.boostArray = []; @@ -5041,7 +5041,7 @@ var UpgradeStatic = class _UpgradeStatic { } getCached(type, start, end) { if (type === "sum") { - return this.cache.get(upgradeToCacheNameSum(start, end)); + return this.cache.get(upgradeToCacheNameSum(start, end ?? E(0))); } else { return this.cache.get(upgradeToCacheNameEL(start)); } @@ -5126,7 +5126,6 @@ var CurrencyStatic = class { }; if (upgrades) this.addUpgrade(upgrades); - this.upgrades = this.upgrades; } /** * Updates / applies effects to the currency on load. diff --git a/dist/pixiGame/eMath.pixiGame.js b/dist/pixiGame/eMath.pixiGame.js index 8f98827c..8577582a 100644 --- a/dist/pixiGame/eMath.pixiGame.js +++ b/dist/pixiGame/eMath.pixiGame.js @@ -1489,7 +1489,7 @@ function decimalFormatGenerator(Decimal2) { default: if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); - return neg + FORMATS2[type]?.format(ex, acc, max); + return neg + FORMATS2[type].format(ex, acc, max); } } function formatGain(amt, gain, type = "mixed_sc", acc, max) { @@ -1619,7 +1619,7 @@ function decimalFormatGenerator(Decimal2) { output = abbMax["name"]; break; case 2: - output = `${num.divide(abbMax["value"]).format()}`; + output = num.divide(abbMax["value"]).format(); break; case 3: output = abbMax["altName"]; @@ -5514,7 +5514,7 @@ var Boost = class { * @alias setBoost * @deprecated Use {@link setBoost} instead. */ - this.addBoost = this.setBoost; + this.addBoost = this.setBoost.bind(this); boosts = boosts ? Array.isArray(boosts) ? boosts : [boosts] : void 0; this.baseEffect = E(baseEffect); this.boostArray = []; @@ -5814,7 +5814,7 @@ var UpgradeStatic = class _UpgradeStatic { } getCached(type, start, end) { if (type === "sum") { - return this.cache.get(upgradeToCacheNameSum(start, end)); + return this.cache.get(upgradeToCacheNameSum(start, end ?? E(0))); } else { return this.cache.get(upgradeToCacheNameEL(start)); } @@ -5897,7 +5897,6 @@ var CurrencyStatic = class { }; if (upgrades) this.addUpgrade(upgrades); - this.upgrades = this.upgrades; } /** * Updates / applies effects to the currency on load. @@ -6220,7 +6219,7 @@ var KeyManager = class _KeyManager { */ constructor(config) { /** @deprecated Use {@link addKey} instead. */ - this.addKeys = this.addKey; + this.addKeys = this.addKey.bind(this); this.keysPressed = []; this.binds = []; this.tickers = []; @@ -6368,7 +6367,7 @@ var EventManager = class _EventManager { * @deprecated Use {@link EventManager.setEvent} instead. * @alias eventManager.setEvent */ - this.addEvent = this.setEvent; + this.addEvent = this.setEvent.bind(this); this.config = _EventManager.configManager.parse(config); this.events = {}; if (this.config.autoAddInterval) { @@ -6394,18 +6393,27 @@ var EventManager = class _EventManager { tickerFunction() { const currentTime = Date.now(); for (const event of Object.values(this.events)) { - if (event.type === "interval") { - if (currentTime - event.intervalLast >= event.delay) { - const dt = currentTime - event.intervalLast; - event.callbackFn(dt); - event.intervalLast = currentTime; - } - } else if (event.type === "timeout") { - const dt = currentTime - event.timeCreated; - if (currentTime - event.timeCreated >= event.delay) { - event.callbackFn(dt); - delete this.events[event.name]; - } + switch (event.type) { + case "interval" /* interval */: + { + if (currentTime - event.intervalLast >= event.delay) { + const dt = currentTime - event.intervalLast; + event.callbackFn(dt); + event.intervalLast = currentTime; + } + } + ; + break; + case "timeout" /* timeout */: + { + const dt = currentTime - event.timeCreated; + if (currentTime - event.timeCreated >= event.delay) { + event.callbackFn(dt); + delete this.events[event.name]; + } + } + ; + break; } } } @@ -6430,11 +6438,19 @@ var EventManager = class _EventManager { */ timeWarp(dt) { for (const event of Object.values(this.events)) { - if (event.type === "interval") { - event.intervalLast -= dt; - } - if (event.type === "timeout") { - event.timeCreated -= dt; + switch (event.type) { + case "interval" /* interval */: + { + event.intervalLast -= dt; + } + ; + break; + case "timeout" /* timeout */: + { + event.timeCreated -= dt; + } + ; + break; } } } @@ -6642,7 +6658,7 @@ var DataManager = class { * @param data - The data to decompile. If not provided, it will be fetched from localStorage using the key `${game.config.name.id}-data`. * @returns The decompiled object, or null if the data is empty or invalid. */ - decompileData(data = window?.localStorage.getItem(`${this.gameRef.config.name.id}-data`)) { + decompileData(data = window.localStorage.getItem(`${this.gameRef.config.name.id}-data`)) { if (!data) return null; let parsedData; @@ -6682,7 +6698,7 @@ var DataManager = class { this.data = this.normalData; this.saveData(); if (reload) - window?.location.reload(); + window.location.reload(); } /** * Saves the game data to local storage under the key `${game.config.name.id}-data`. @@ -6721,7 +6737,7 @@ var DataManager = class { * @returns The loaded data. */ parseData(dataToParse = this.decompileData(), mergeData = true) { - if (mergeData && (!this.normalData || !this.normalDataPlain)) + if ((!this.normalData || !this.normalDataPlain) && mergeData) throw new Error("dataManager.parseData(): You must call init() before writing to data."); if (!dataToParse) return null; @@ -6743,7 +6759,7 @@ var DataManager = class { const upgrades = targetCurrency.upgrades; targetCurrency.upgrades = {}; for (const upgrade of upgrades) { - targetCurrency.upgrades[upgrade.id] = upgrade.level; + targetCurrency.upgrades[upgrade.id] = upgrade; } } targetCurrency.upgrades = { ...sourceCurrency.upgrades, ...targetCurrency.upgrades }; @@ -6836,7 +6852,7 @@ var GameCurrency = class { this.staticPointer = typeof staticPointer === "function" ? staticPointer : () => staticPointer; this.game = gamePointer; this.name = name; - this.game?.dataManager.addEventOnLoad(() => { + this.game.dataManager.addEventOnLoad(() => { this.static.onLoadData(); }); } @@ -6909,7 +6925,7 @@ var GameReset = class { currency.static.reset(); }); this.extender.forEach((extender) => { - if (extender && extender.id !== this.id) { + if (extender.id !== this.id) { extender.reset(); } }); @@ -7506,8 +7522,11 @@ var GameSprite = class { this.y = this.sprite.y; this.collisionShape = collisionShape; this.intersects = new pixi_intersects_default[this.collisionShape](this.sprite); - this.gameRef.PIXI.app.ticker.add(this.tickerFn, this); + this.gameRef.PIXI.app.ticker.add(this.tickerFn.bind(this), this); } + /** + * The ticker function for the sprite, used to offset the sprite by the camera. + */ tickerFn() { this.sprite.x = this.x - this.gameRef.PIXI.camera.x; this.sprite.y = this.y - this.gameRef.PIXI.camera.y; diff --git a/dist/pixiGame/eMath.pixiGame.mjs b/dist/pixiGame/eMath.pixiGame.mjs index d84d3591..177b7b8a 100644 --- a/dist/pixiGame/eMath.pixiGame.mjs +++ b/dist/pixiGame/eMath.pixiGame.mjs @@ -1461,7 +1461,7 @@ function decimalFormatGenerator(Decimal2) { default: if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); - return neg + FORMATS2[type]?.format(ex, acc, max); + return neg + FORMATS2[type].format(ex, acc, max); } } function formatGain(amt, gain, type = "mixed_sc", acc, max) { @@ -1591,7 +1591,7 @@ function decimalFormatGenerator(Decimal2) { output = abbMax["name"]; break; case 2: - output = `${num.divide(abbMax["value"]).format()}`; + output = num.divide(abbMax["value"]).format(); break; case 3: output = abbMax["altName"]; @@ -5486,7 +5486,7 @@ var Boost = class { * @alias setBoost * @deprecated Use {@link setBoost} instead. */ - this.addBoost = this.setBoost; + this.addBoost = this.setBoost.bind(this); boosts = boosts ? Array.isArray(boosts) ? boosts : [boosts] : void 0; this.baseEffect = E(baseEffect); this.boostArray = []; @@ -5786,7 +5786,7 @@ var UpgradeStatic = class _UpgradeStatic { } getCached(type, start, end) { if (type === "sum") { - return this.cache.get(upgradeToCacheNameSum(start, end)); + return this.cache.get(upgradeToCacheNameSum(start, end ?? E(0))); } else { return this.cache.get(upgradeToCacheNameEL(start)); } @@ -5869,7 +5869,6 @@ var CurrencyStatic = class { }; if (upgrades) this.addUpgrade(upgrades); - this.upgrades = this.upgrades; } /** * Updates / applies effects to the currency on load. @@ -6192,7 +6191,7 @@ var KeyManager = class _KeyManager { */ constructor(config) { /** @deprecated Use {@link addKey} instead. */ - this.addKeys = this.addKey; + this.addKeys = this.addKey.bind(this); this.keysPressed = []; this.binds = []; this.tickers = []; @@ -6340,7 +6339,7 @@ var EventManager = class _EventManager { * @deprecated Use {@link EventManager.setEvent} instead. * @alias eventManager.setEvent */ - this.addEvent = this.setEvent; + this.addEvent = this.setEvent.bind(this); this.config = _EventManager.configManager.parse(config); this.events = {}; if (this.config.autoAddInterval) { @@ -6366,18 +6365,27 @@ var EventManager = class _EventManager { tickerFunction() { const currentTime = Date.now(); for (const event of Object.values(this.events)) { - if (event.type === "interval") { - if (currentTime - event.intervalLast >= event.delay) { - const dt = currentTime - event.intervalLast; - event.callbackFn(dt); - event.intervalLast = currentTime; - } - } else if (event.type === "timeout") { - const dt = currentTime - event.timeCreated; - if (currentTime - event.timeCreated >= event.delay) { - event.callbackFn(dt); - delete this.events[event.name]; - } + switch (event.type) { + case "interval" /* interval */: + { + if (currentTime - event.intervalLast >= event.delay) { + const dt = currentTime - event.intervalLast; + event.callbackFn(dt); + event.intervalLast = currentTime; + } + } + ; + break; + case "timeout" /* timeout */: + { + const dt = currentTime - event.timeCreated; + if (currentTime - event.timeCreated >= event.delay) { + event.callbackFn(dt); + delete this.events[event.name]; + } + } + ; + break; } } } @@ -6402,11 +6410,19 @@ var EventManager = class _EventManager { */ timeWarp(dt) { for (const event of Object.values(this.events)) { - if (event.type === "interval") { - event.intervalLast -= dt; - } - if (event.type === "timeout") { - event.timeCreated -= dt; + switch (event.type) { + case "interval" /* interval */: + { + event.intervalLast -= dt; + } + ; + break; + case "timeout" /* timeout */: + { + event.timeCreated -= dt; + } + ; + break; } } } @@ -6614,7 +6630,7 @@ var DataManager = class { * @param data - The data to decompile. If not provided, it will be fetched from localStorage using the key `${game.config.name.id}-data`. * @returns The decompiled object, or null if the data is empty or invalid. */ - decompileData(data = window?.localStorage.getItem(`${this.gameRef.config.name.id}-data`)) { + decompileData(data = window.localStorage.getItem(`${this.gameRef.config.name.id}-data`)) { if (!data) return null; let parsedData; @@ -6654,7 +6670,7 @@ var DataManager = class { this.data = this.normalData; this.saveData(); if (reload) - window?.location.reload(); + window.location.reload(); } /** * Saves the game data to local storage under the key `${game.config.name.id}-data`. @@ -6693,7 +6709,7 @@ var DataManager = class { * @returns The loaded data. */ parseData(dataToParse = this.decompileData(), mergeData = true) { - if (mergeData && (!this.normalData || !this.normalDataPlain)) + if ((!this.normalData || !this.normalDataPlain) && mergeData) throw new Error("dataManager.parseData(): You must call init() before writing to data."); if (!dataToParse) return null; @@ -6715,7 +6731,7 @@ var DataManager = class { const upgrades = targetCurrency.upgrades; targetCurrency.upgrades = {}; for (const upgrade of upgrades) { - targetCurrency.upgrades[upgrade.id] = upgrade.level; + targetCurrency.upgrades[upgrade.id] = upgrade; } } targetCurrency.upgrades = { ...sourceCurrency.upgrades, ...targetCurrency.upgrades }; @@ -6808,7 +6824,7 @@ var GameCurrency = class { this.staticPointer = typeof staticPointer === "function" ? staticPointer : () => staticPointer; this.game = gamePointer; this.name = name; - this.game?.dataManager.addEventOnLoad(() => { + this.game.dataManager.addEventOnLoad(() => { this.static.onLoadData(); }); } @@ -6881,7 +6897,7 @@ var GameReset = class { currency.static.reset(); }); this.extender.forEach((extender) => { - if (extender && extender.id !== this.id) { + if (extender.id !== this.id) { extender.reset(); } }); @@ -7478,8 +7494,11 @@ var GameSprite = class { this.y = this.sprite.y; this.collisionShape = collisionShape; this.intersects = new pixi_intersects_default[this.collisionShape](this.sprite); - this.gameRef.PIXI.app.ticker.add(this.tickerFn, this); + this.gameRef.PIXI.app.ticker.add(this.tickerFn.bind(this), this); } + /** + * The ticker function for the sprite, used to offset the sprite by the camera. + */ tickerFn() { this.sprite.x = this.x - this.gameRef.PIXI.camera.x; this.sprite.y = this.y - this.gameRef.PIXI.camera.y; diff --git a/dist/presets/eMath.presets.js b/dist/presets/eMath.presets.js index cde957cd..27d17996 100644 --- a/dist/presets/eMath.presets.js +++ b/dist/presets/eMath.presets.js @@ -741,7 +741,7 @@ function decimalFormatGenerator(Decimal2) { default: if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); - return neg + FORMATS2[type]?.format(ex, acc, max); + return neg + FORMATS2[type].format(ex, acc, max); } } function formatGain(amt, gain, type = "mixed_sc", acc, max) { @@ -871,7 +871,7 @@ function decimalFormatGenerator(Decimal2) { output = abbMax["name"]; break; case 2: - output = `${num.divide(abbMax["value"]).format()}`; + output = num.divide(abbMax["value"]).format(); break; case 3: output = abbMax["altName"]; diff --git a/dist/presets/eMath.presets.min.js b/dist/presets/eMath.presets.min.js index bbe89533..edc58fa2 100644 --- a/dist/presets/eMath.presets.min.js +++ b/dist/presets/eMath.presets.min.js @@ -1 +1 @@ -"use strict";(function(j,G){var k=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],G);else if(typeof module=="object"&&module.exports)module.exports=G();else{var H=G(),J=k?exports:j;for(var Q in H)J[Q]=H[Q]}})(typeof self<"u"?self:exports,()=>{var j={},G={exports:j},k=Object.defineProperty,H=Object.getOwnPropertyDescriptor,J=Object.getOwnPropertyNames,Q=Object.prototype.hasOwnProperty,rt=(t,e)=>{for(var r in e)k(t,r,{get:e[r],enumerable:!0})},mt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of J(e))!Q.call(t,a)&&a!==r&&k(t,a,{get:()=>e[a],enumerable:!(i=H(e,a))||i.enumerable});return t},ft=t=>mt(k({},"__esModule",{value:!0}),t),W=(t,e,r,i)=>{for(var a=i>1?void 0:i?H(e,r):e,o=t.length-1,m;o>=0;o--)(m=t[o])&&(a=(i?m(e,r,a):m(a))||a);return i&&a&&k(e,r,a),a},it={};rt(it,{emathPresets:()=>st}),G.exports=ft(it);var st={};rt(st,{GameFormatClass:()=>Ct,formatOptions:()=>qt,formatTimeOptions:()=>Pt,gameFormat:()=>K,gameFormatGain:()=>ht});var L;(function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(L||(L={}));var gt=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},t.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.findTransformMetadatas=function(e,r,i){return this.findMetadatas(this._transformMetadatas,e,r).filter(function(a){return!a.options||a.options.toClassOnly===!0&&a.options.toPlainOnly===!0?!0:a.options.toClassOnly===!0?i===L.CLASS_TO_CLASS||i===L.PLAIN_TO_CLASS:a.options.toPlainOnly===!0?i===L.CLASS_TO_PLAIN:!0})},t.prototype.findExcludeMetadata=function(e,r){return this.findMetadata(this._excludeMetadatas,e,r)},t.prototype.findExposeMetadata=function(e,r){return this.findMetadata(this._exposeMetadatas,e,r)},t.prototype.findExposeMetadataByCustomName=function(e,r){return this.getExposedMetadatas(e).find(function(i){return i.options&&i.options.name===r})},t.prototype.findTypeMetadata=function(e,r){return this.findMetadata(this._typeMetadatas,e,r)},t.prototype.getStrategy=function(e){var r=this._excludeMetadatas.get(e),i=r&&r.get(void 0),a=this._exposeMetadatas.get(e),o=a&&a.get(void 0);return i&&o||!i&&!o?"none":i?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},t.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},t.prototype.getExposedProperties=function(e,r){return this.getExposedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===L.CLASS_TO_CLASS||r===L.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===L.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.getExcludedProperties=function(e,r){return this.getExcludedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===L.CLASS_TO_CLASS||r===L.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===L.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(e,r){var i=e.get(r),a;i&&(a=Array.from(i.values()).filter(function(F){return F.propertyName!==void 0}));for(var o=[],m=0,c=this.getAncestors(r);mthis.maxSize;){let i=this.last;this.map.delete(i.key),this.last=i.prev,this.last.next=void 0}}},pt=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},Z=[[["","U","D","T","Qa","Qt","Sx","Sp","Oc","No"],["","Dc","Vg","Tg","Qag","Qtg","Sxg","Spg","Ocg","Nog"],["","Ce","De","Te","Qae","Qte","Sxe","Spe","Oce","Noe"]],[["","Mi","Mc","Na","Pc","Fm","At","Zp","Yc","Xn"],["","Me","Du","Tr","Te","Pe","He","Hp","Ot","En"],["","c","Ic","TCn","TeC","PCn","HCn","HpC","OCn","ECn"],["","Hc","DHe","THt","TeH","PHc","HHe","HpH","OHt","EHc"]]];function Nt(t){let e={omega:{config:{greek:"\u03B2\u03B6\u03BB\u03C8\u03A3\u0398\u03A8\u03C9",infinity:"\u03A9"},format(n){n=new t(n);let h=t.floor(n.div(1e3)),u=t.floor(h.div(e.omega.config.greek.length)),g=e.omega.config.greek[h.toNumber()%e.omega.config.greek.length]+o(n.toNumber()%1e3);(e.omega.config.greek[h.toNumber()%e.omega.config.greek.length]===void 0||h.toNumber()>Number.MAX_SAFE_INTEGER)&&(g="\u03C9");let b=t.log(n,8e3).toNumber();if(u.equals(0))return g;if(u.gt(0)&&u.lte(3)){let S=[];for(let E=0;ENumber.MAX_SAFE_INTEGER)&&(g="\u03C9");let b=t.log(n,8e3).toNumber();if(u.equals(0))return g;if(u.gt(0)&&u.lte(2)){let S=[];for(let E=0;E118?e.elemental.beyondOg(d):e.elemental.config.element_lists[n-1][g]},beyondOg(n){let h=Math.floor(Math.log10(n)),u=["n","u","b","t","q","p","h","s","o","e"],g="";for(let d=h;d>=0;d--){let b=Math.floor(n/Math.pow(10,d))%10;g==""?g=u[b].toUpperCase():g+=u[b]}return g},abbreviationLength(n){return n==1?1:Math.pow(Math.floor(n/2)+1,2)*2},getAbbreviationAndValue(n){let h=n.log(118).toNumber(),u=Math.floor(h)+1,g=e.elemental.abbreviationLength(u),d=h-u+1,b=Math.floor(d*g),p=e.elemental.getAbbreviation(u,d),v=new t(118).pow(u+b/g-1);return[p,v]},formatElementalPart(n,h){return h.eq(1)?n:`${h} ${n}`},format(n,h=2){if(n.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(n.log10(),h);let u=n.log(118),d=u.log(118).log(118).toNumber(),b=Math.max(4-d*2,1),p=[];for(;u.gte(1)&&p.length=b)return p.map(S=>e.elemental.formatElementalPart(S[0],S[1])).join(" + ");let v=new t(118).pow(u).toFixed(p.length===1?3:h);return p.length===0?v:p.length===1?`${v} \xD7 ${e.elemental.formatElementalPart(p[0][0],p[0][1])}`:`${v} \xD7 (${p.map(S=>e.elemental.formatElementalPart(S[0],S[1])).join(" + ")})`}},old_sc:{format(n,h){n=new t(n);let u=n.log10().floor();if(u.lt(9))return u.lt(3)?n.toFixed(h):n.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(n.gte("eeee10")){let d=n.slog();return(d.gte(1e9)?"":new t(10).pow(d.sub(d.floor())).toFixed(4))+"F"+e.old_sc.format(d.floor(),0)}let g=n.div(new t(10).pow(u));return(u.log10().gte(9)?"":g.toFixed(4))+"e"+e.old_sc.format(u,0)}}},eng:{format(n,h=2){n=new t(n);let u=n.log10().floor();if(u.lt(9))return u.lt(3)?n.toFixed(h):n.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(n.gte("eeee10")){let d=n.slog();return(d.gte(1e9)?"":new t(10).pow(d.sub(d.floor())).toFixed(4))+"F"+e.eng.format(d.floor(),0)}let g=n.div(new t(1e3).pow(u.div(3).floor()));return(u.log10().gte(9)?"":g.toFixed(new t(4).sub(u.sub(u.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(u.div(3).floor().mul(3),0)}}},mixed_sc:{format(n,h,u=9){n=new t(n);let g=n.log10().floor();return g.lt(303)&&g.gte(u)?f(n,h,u,"st"):f(n,h,u,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(n,h=2,u){n=new t(n);let g=n.max(1).log10().max(1).log(r.log10()).floor();if(g.lte(0))return f(n,h,u,"sc");n=new t(10).pow(n.max(1).log10().div(r.log10().pow(g)).sub(g.gte(1)?1:0));let d=g.div(10).floor(),b=g.toNumber()%10-1;return f(n,Math.max(4,h),u,"sc")+" "+(d.gte(1)?"meta"+(d.gte(2)?"^"+f(d,0,u,"sc"):"")+"-":"")+(isNaN(b)?"nanity":e.layer.layers[b])}},standard:{tier1(n){return Z[0][0][n%10]+Z[0][1][Math.floor(n/10)%10]+Z[0][2][Math.floor(n/100)]},tier2(n){let h=n%10,u=Math.floor(n/10)%10,g=Math.floor(n/100)%10,d="";return n<10?Z[1][0][n]:(u==1&&h==0?d+="Vec":d+=Z[1][1][h]+Z[1][2][u],d+=Z[1][3][g],d)}},inf:{format(n,h,u){n=new t(n);let g=0,d=new t(Number.MAX_VALUE),b=["","\u221E","\u03A9","\u03A8","\u028A"],p=["","","m","mm","mmm"];for(;n.gte(d);)n=n.log(d),g++;return g==0?f(n,h,u,"sc"):n.gte(3)?p[g]+b[g]+"\u03C9^"+f(n.sub(1),h,u,"sc"):n.gte(2)?p[g]+"\u03C9"+b[g]+"-"+f(d.pow(n.sub(2)),h,u,"sc"):p[g]+b[g]+"-"+f(d.pow(n.sub(1)),h,u,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(n,h=new t(1e15),u=!1,g=9){if(n=new t(n),h=new t(h).div(1e3),n.lt(h.mul(1e3)))return"";let{alphabet:d}=e.alphabet.config,b=d.length,p=n.log(1e3).sub(h.log(1e3)).floor(),v=p.add(1).log(b+1).ceil(),S="",E=(q,V)=>{let P=q,Y="";for(let $=0;$=b)return"\u03C9";Y=d[X]+Y,P=P.sub(1).div(b).floor()}return Y};if(v.lt(g))S=E(p,v);else{let q=v.sub(g).add(1),V=p.div(t.pow(b+1,q.sub(1))).floor();S=`${E(V,new t(g))}(${q.gt("1e9")?q.format():q.format(0)})`}return S},format(n,h=2,u=9,g="mixed_sc",d=new t(1e15),b=!1,p){if(n=new t(n),d=new t(d).div(1e3),n.lt(d.mul(1e3)))return f(n,h,u,g);let v=e.alphabet.getAbbreviation(n,d,b,p),S=n.div(t.pow(1e3,n.log(1e3).floor()));return`${v.length>(p??9)+2?"":S.toFixed(h)+" "}${v}`}}},r=new t(2).pow(1024),i="\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089",a="\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079";function o(n){return n.toFixed(0).split("").map(h=>h==="-"?"\u208B":i[parseInt(h,10)]).join("")}function m(n){return n.toFixed(0).split("").map(h=>h==="-"?"\u208B":a[parseInt(h,10)]).join("")}function c(n,h=2,u=9,g="st"){return f(n,h,u,g)}function f(n,h=2,u=9,g="mixed_sc"){n=new t(n);let d=n.lt(0)?"-":"";if(n.mag==1/0)return d+"Infinity";if(Number.isNaN(n.mag))return d+"NaN";if(n.lt(0)&&(n=n.mul(-1)),n.eq(0))return n.toFixed(h);let b=n.log10().floor();switch(g){case"sc":case"scientific":if(n.log10().lt(Math.min(-h,0))&&h>1){let p=n.log10().ceil(),v=n.div(p.eq(-1)?new t(.1):new t(10).pow(p)),S=p.mul(-1).max(1).log10().gte(9);return d+(S?"":v.toFixed(2))+"e"+f(p,0,u,"mixed_sc")}else if(b.lt(u)){let p=Math.max(Math.min(h-b.toNumber(),h),0);return d+(p>0?n.toFixed(p):n.toFixed(p).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(n.gte("eeee10")){let S=n.slog();return(S.gte(1e9)?"":new t(10).pow(S.sub(S.floor())).toFixed(2))+"F"+f(S.floor(),0)}let p=n.div(new t(10).pow(b)),v=b.log10().gte(9);return d+(v?"":p.toFixed(2))+"e"+f(b,0,u,"mixed_sc")}case"st":case"standard":{let p=n.log(1e3).floor();if(p.lt(1))return d+n.toFixed(Math.max(Math.min(h-b.toNumber(),h),0));let v=p.mul(3),S=p.log10().floor();if(S.gte(3e3))return"e"+f(b,h,u,"st");let E="";if(p.lt(4))E=["","K","M","B"][Math.round(p.toNumber())];else{let P=Math.floor(p.log(1e3).toNumber());for(P<100&&(P=Math.max(P-1,0)),p=p.sub(1).div(new t(10).pow(P*3));p.gt(0);){let Y=p.div(1e3).floor(),$=p.sub(Y.mul(1e3)).floor().toNumber();$>0&&($==1&&!P&&(E="U"),P&&(E=e.standard.tier2(P)+(E?"-"+E:"")),$>1&&(E=e.standard.tier1($)+E)),p=Y,P++}}let q=n.div(new t(10).pow(v)),V=h===2?new t(2).sub(b.sub(v)).add(1).toNumber():h;return d+(S.gte(10)?"":q.toFixed(V)+" ")+E}default:return e[g]||console.error('Invalid format type "',g,'"'),d+e[g]?.format(n,h,u)}}function M(n,h,u="mixed_sc",g,d){n=new t(n),h=new t(h);let b=n.add(h),p,v=b.div(n);return v.gte(10)&&n.gte(1e100)?(v=v.log10().mul(20),p="(+"+f(v,g,d,u)+" OoMs/sec)"):p="(+"+f(h,g,d,u)+"/sec)",p}function _(n,h=2,u="s"){return n=new t(n),n.gte(86400)?f(n.div(86400).floor(),0,12,"sc")+":"+_(n.mod(86400),h,"d"):n.gte(3600)||u=="d"?(n.div(3600).gte(10)||u!="d"?"":"0")+f(n.div(3600).floor(),0,12,"sc")+":"+_(n.mod(3600),h,"h"):n.gte(60)||u=="h"?(n.div(60).gte(10)||u!="h"?"":"0")+f(n.div(60).floor(),0,12,"sc")+":"+_(n.mod(60),h,"m"):(n.gte(10)||u!="m"?"":"0")+f(n,h,12,"sc")}function F(n,h=!1,u=0,g=9,d="mixed_sc"){let b=Vt=>f(Vt,u,g,d);n=new t(n);let p=n.mul(1e3).mod(1e3).floor(),v=n.mod(60).floor(),S=n.div(60).mod(60).floor(),E=n.div(3600).mod(24).floor(),q=n.div(86400).mod(365.2425).floor(),V=n.div(31556952).floor(),P=V.eq(1)?" year":" years",Y=q.eq(1)?" day":" days",$=E.eq(1)?" hour":" hours",X=S.eq(1)?" minute":" minutes",Lt=v.eq(1)?" second":" seconds",Gt=p.eq(1)?" millisecond":" milliseconds";return`${V.gt(0)?b(V)+P+", ":""}${q.gt(0)?b(q)+Y+", ":""}${E.gt(0)?b(E)+$+", ":""}${S.gt(0)?b(S)+X+", ":""}${v.gt(0)?b(v)+Lt+",":""}${h&&p.gt(0)?" "+b(p)+Gt:""}`.replace(/,([^,]*)$/,"$1").trim()}function x(n){return n=new t(n),f(new t(1).sub(n).mul(100))+"%"}function O(n){return n=new t(n),f(n.mul(100))+"%"}function C(n,h=2){return n=new t(n),n.gte(1)?"\xD7"+n.format(h):"/"+n.pow(-1).format(h)}function y(n,h,u=10){return t.gte(n,10)?t.pow(u,t.log(n,u).pow(h)):new t(n)}function I(n,h=0){n=new t(n);let u=(p=>p.map((v,S)=>({name:v.name,altName:v.altName,value:t.pow(1e3,new t(S).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"E",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),g="",d=n.lte(0)?0:t.min(t.log(n,1e3).sub(1),u.length-1).floor().toNumber(),b=u[d];if(d===0)switch(h){case 1:g="";break;case 2:case 0:default:g=n.format();break}switch(h){case 1:g=b.name;break;case 2:g=`${n.divide(b.value).format()}`;break;case 3:g=b.altName;break;case 0:default:g=`${n.divide(b.value).format()} ${b.name}`;break}return g}function T(n,h=!1){return`${I(n,2)} ${I(n,1)}eV${h?"/c^2":""}`}let A={...e,toSubscript:o,toSuperscript:m,formatST:c,format:f,formatGain:M,formatTime:_,formatTimeLong:F,formatReduction:x,formatPercent:O,formatMult:C,expMult:y,metric:I,ev:T};return{FORMATS:e,formats:A}}var tt=17,bt=9e15,Mt=Math.log10(9e15),yt=1/9e15,_t=308,wt=-324,at=5,St=1023,It=!0,vt=!1,Ft=function(){let t=[];for(let r=wt+1;r<=_t;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),R=[2,Math.E,3,4,5,6,7,8,9,10],Ot=[[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]],Et=[[-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]],l=function(e){return s.fromValue_noAlloc(e)},N=function(t,e,r){return s.fromComponents(t,e,r)},w=function(e,r,i){return s.fromComponents_noNormalize(e,r,i)},B=function(e,r){let i=r+1,a=Math.ceil(Math.log10(Math.abs(e))),o=Math.round(e*Math.pow(10,i-a))*Math.pow(10,a-i);return parseFloat(o.toFixed(Math.max(i-a,0)))},et=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},Tt=function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;let e=1;for(;t<10;)e=e*t,++t;t-=1;let r=.9189385332046727;r=r+(t+.5)*Math.log(t),r=r-t;let i=t*t,a=t;return r=r+1/(12*a),a=a*i,r=r+1/(360*a),a=a*i,r=r+1/(1260*a),a=a*i,r=r+1/(1680*a),a=a*i,r=r+1/(1188*a),a=a*i,r=r+691/(360360*a),a=a*i,r=r+7/(1092*a),a=a*i,r=r+3617/(122400*a),Math.exp(r)/e},At=.36787944117144233,ot=.5671432904097838,lt=function(t,e=1e-10){let r,i;if(!Number.isFinite(t)||t===0)return t;if(t===1)return ot;t<10?r=0:r=Math.log(t)-Math.log(Math.log(t));for(let a=0;a<100;++a){if(i=(t*Math.exp(-r)+r*r)/(r+1),Math.abs(i-r).5?1:-1;if(Math.random()*20<1)return w(e,0,1);let r=Math.floor(Math.random()*(t+1)),i=r===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let a=Math.pow(10,i);return Math.random()>.9&&(a=Math.trunc(a)),N(e,r,a)}static affordGeometricSeries_core(t,e,r,i){let a=e.mul(r.pow(i));return s.floor(t.div(a).mul(r.sub(1)).add(1).log10().div(r.log10()))}static sumGeometricSeries_core(t,e,r,i){return e.mul(r.pow(i)).mul(s.sub(1,r.pow(t))).div(s.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let o=e.add(i.mul(r)).sub(r.div(2)),m=o.pow(2);return o.neg().add(m.add(r.mul(t).mul(2)).sqrt()).div(r).floor()}static sumArithmeticSeries_core(t,e,r,i){let a=e.add(i.mul(r));return t.div(2).mul(a.mul(2).plus(t.sub(1).mul(r)))}static efficiencyOfPurchase_core(t,e,r){return t.div(e).add(t.div(r))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0||this.mag===Number.NEGATIVE_INFINITY&&this.layer>0&&Number.isFinite(this.layer))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.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_INFINITY)return this.sign==1?(this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY):this.sign==-1&&(this.mag=Number.NEGATIVE_INFINITY,this.layer=Number.NEGATIVE_INFINITY),this;if(this.layer===0&&this.mag=bt)return this.layer+=1,this.mag=e*Math.log10(t),this;for(;t0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=e*Math.pow(10,t),t=Math.abs(this.mag),e=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)),(Number.isNaN(this.sign)||Number.isNaN(this.layer)||Number.isNaN(this.mag))&&(this.sign=Number.NaN,this.layer=Number.NaN,this.mag=Number.NaN),this}fromComponents(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this.normalize(),this}fromComponents_noNormalize(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this}fromMantissaExponent(t,e){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=e+Math.log10(t),this.normalize(),this}fromMantissaExponent_noNormalize(t,e){return this.fromMantissaExponent(t,e),this}fromDecimal(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this}fromNumber(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this}fromString(t,e=!1){let r=t,i=s.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);It?t=t.replace(",",""):vt&&(t=t.replace(",","."));let a=t.split("^^^");if(a.length===2){let y=parseFloat(a[0]),I=parseFloat(a[1]),T=a[1].split(";"),A=1;if(T.length===2&&(A=parseFloat(T[1]),isFinite(A)||(A=1)),isFinite(y)&&isFinite(I)){let n=s.pentate(y,I,A,e);return this.sign=n.sign,this.layer=n.layer,this.mag=n.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let o=t.split("^^");if(o.length===2){let y=parseFloat(o[0]),I=parseFloat(o[1]),T=o[1].split(";"),A=1;if(T.length===2&&(A=parseFloat(T[1]),isFinite(A)||(A=1)),isFinite(y)&&isFinite(I)){let n=s.tetrate(y,I,A,e);return this.sign=n.sign,this.layer=n.layer,this.mag=n.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let m=t.split("^");if(m.length===2){let y=parseFloat(m[0]),I=parseFloat(m[1]);if(isFinite(y)&&isFinite(I)){let T=s.pow(y,I);return this.sign=T.sign,this.layer=T.layer,this.mag=T.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}t=t.trim().toLowerCase();let c,f,M=t.split("pt");if(M.length===2){c=10,f=parseFloat(M[0]),M[1]=M[1].replace("(",""),M[1]=M[1].replace(")","");let y=parseFloat(M[1]);if(isFinite(y)||(y=1),isFinite(c)&&isFinite(f)){let I=s.tetrate(c,f,y,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(M=t.split("p"),M.length===2){c=10,f=parseFloat(M[0]),M[1]=M[1].replace("(",""),M[1]=M[1].replace(")","");let y=parseFloat(M[1]);if(isFinite(y)||(y=1),isFinite(c)&&isFinite(f)){let I=s.tetrate(c,f,y,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(M=t.split("f"),M.length===2){c=10,M[0]=M[0].replace("(",""),M[0]=M[0].replace(")","");let y=parseFloat(M[0]);if(M[1]=M[1].replace("(",""),M[1]=M[1].replace(")",""),f=parseFloat(M[1]),isFinite(y)||(y=1),isFinite(c)&&isFinite(f)){let I=s.tetrate(c,f,y,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let _=t.split("e"),F=_.length-1;if(F===0){let y=parseFloat(t);if(isFinite(y))return this.fromNumber(y),s.fromStringCache.size>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else if(F===1){let y=parseFloat(t);if(isFinite(y)&&y!==0)return this.fromNumber(y),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}let x=t.split("e^");if(x.length===2){this.sign=1,x[0].charAt(0)=="-"&&(this.sign=-1);let y="";for(let I=0;I=43&&T<=57||T===101)y+=x[1].charAt(I);else return this.layer=parseFloat(y),this.mag=parseFloat(x[1].substr(I+1)),this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(F<1)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let O=parseFloat(_[0]);if(O===0)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let C=parseFloat(_[_.length-1]);if(F>=2){let y=parseFloat(_[_.length-2]);isFinite(y)&&(C*=Math.sign(y),C+=et(y))}if(!isFinite(O))this.sign=_[0]==="-"?-1:1,this.layer=F,this.mag=C;else if(F===1)this.sign=Math.sign(O),this.layer=1,this.mag=C+Math.log10(Math.abs(O));else if(this.sign=Math.sign(O),this.layer=F,F===2){let y=s.mul(N(1,2,C),l(O));return this.sign=y.sign,this.layer=y.layer,this.mag=y.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else this.mag=C;return this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}fromValue(t){return t instanceof s?this.fromDecimal(t):typeof t=="number"?this.fromNumber(t):typeof t=="string"?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===1?Number.POSITIVE_INFINITY:this.mag===Number.NEGATIVE_INFINITY&&this.layer===Number.NEGATIVE_INFINITY&&this.sign===-1?Number.NEGATIVE_INFINITY: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(t){return isNaN(this.m)?Number.NaN:this.m===0?0:B(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:B(this.mag,t)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_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<=at?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(t){return this.layer===0?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)}toFixed(t){return this.layer===0?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)}toPrecision(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(t){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(t):B(this.m,t)+"e"+B(this.e,t):this.layer===1?B(this.m,t)+"e"+B(this.e,t):this.layer<=at?(this.sign===-1?"-":"")+"e".repeat(this.layer)+B(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+B(this.mag,t)}abs(){return w(this.sign===0?0:1,this.layer,this.mag)}neg(){return w(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?s.dZero:this.layer===0?N(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?this.sign===-1?s.dNegOne:s.dZero:this.sign===-1?this.neg().ceil().neg():this.layer===0?N(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?this.sign===1?s.dOne:s.dZero:this.sign===-1?this.neg().floor().neg():this.layer===0?N(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?s.dZero:this.layer===0?N(this.sign,0,Math.trunc(this.mag)):this}add(t){let e=l(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer)||this.sign===0)return e;if(e.sign===0)return this;if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return w(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(s.cmpabs(this,e)>0?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*r.mag+i.sign*i.mag);let a=r.layer*Math.sign(r.mag),o=i.layer*Math.sign(i.mag);if(a-o>=2)return r;if(a===0&&o===-1){if(Math.abs(i.mag-Math.log10(r.mag))>tt)return r;{let m=Math.pow(10,Math.log10(r.mag)-i.mag),c=i.sign+r.sign*m;return N(Math.sign(c),1,i.mag+Math.log10(Math.abs(c)))}}if(a===1&&o===0){if(Math.abs(r.mag-Math.log10(i.mag))>tt)return r;{let m=Math.pow(10,r.mag-Math.log10(i.mag)),c=i.sign+r.sign*m;return N(Math.sign(c),1,Math.log10(i.mag)+Math.log10(Math.abs(c)))}}if(Math.abs(r.mag-i.mag)>tt)return r;{let m=Math.pow(10,r.mag-i.mag),c=i.sign+r.sign*m;return N(Math.sign(c),1,i.mag+Math.log10(Math.abs(c)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(l(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=l(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer))return e;if(this.sign===0||e.sign===0)return w(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return w(this.sign*e.sign,0,1);let r,i;if(this.layer>e.layer||this.layer==e.layer&&Math.abs(this.mag)>Math.abs(e.mag)?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return N(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return N(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return N(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let a=N(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(N(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return N(r.sign*i.sign,a.layer+1,a.sign*a.mag)}if(r.layer===2&&i.layer===2){let a=N(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(N(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return N(r.sign*i.sign,a.layer+1,a.sign*a.mag)}throw Error("Bad arguments to mul: "+this+", "+t)}multiply(t){return this.mul(t)}times(t){return this.mul(t)}div(t){let e=l(t);return this.mul(e.recip())}divide(t){return this.div(t)}divideBy(t){return this.div(t)}dividedBy(t){return this.div(t)}recip(){return this.mag===0?s.dNaN:this.layer===0?N(this.sign,0,1/this.mag):N(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=l(t).abs();if(e.eq(s.dZero))return s.dZero;let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new s(r%i):this.sub(e).eq(this)?s.dZero:e.sub(this).eq(e)?this:this.sign==-1?this.abs().mod(e).neg():this.sub(this.div(e).floor().mul(e))}modulo(t){return this.mod(t)}modular(t){return this.mod(t)}cmp(t){let e=l(t);return this.sign>e.sign?1:this.sign0?this.layer:-this.layer,i=e.mag>0?e.layer:-e.layer;return r>i?1:re.mag?1:this.mag0?e:this}clamp(t,e){return this.max(t).min(e)}clampMin(t){return this.max(t)}clampMax(t){return this.min(t)}cmp_tolerance(t,e){let r=l(t);return this.eq_tolerance(r,e)?0:this.cmp(r)}compare_tolerance(t,e){return this.cmp_tolerance(t,e)}eq_tolerance(t,e){let r=l(t);if(e==null&&(e=1e-7),this.sign!==r.sign||Math.abs(this.layer-r.layer)>1)return!1;let i=this.mag,a=r.mag;return this.layer>r.layer&&(a=et(a)),this.layer0?N(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):N(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?s.dNaN:this.layer>0?N(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):N(this.sign,0,Math.log10(this.mag))}log(t){return t=l(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?s.dNaN:this.layer===0&&t.layer===0?N(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):s.div(this.log10(),t.log10())}log2(){return this.sign<=0?s.dNaN:this.layer===0?N(this.sign,0,Math.log2(this.mag)):this.layer===1?N(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?N(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):N(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?s.dNaN:this.layer===0?N(this.sign,0,Math.log(this.mag)):this.layer===1?N(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?N(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):N(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=l(t),r=this,i=e;if(r.sign===0)return i.eq(0)?w(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return w(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return r;let a=r.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?a.neg():Math.abs(i.toNumber()%2)%2===0?a:s.dNaN:a}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return s.dNaN;let t=this;if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return N(1,0,e);if(t.sign===0)return s.dOne;t=w(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?N(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?N(-t.sign,t.layer+1,-t.mag):s.dOne}pow_base(t){return l(t).pow(this)}root(t){let e=l(t);return this.pow(e.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(w(1,0,24)))return s.fromNumber(Tt(this.sign*this.mag));let t=this.mag-1,e=.9189385332046727;e=e+(t+.5)*Math.log(t),e=e-t;let r=t*t,i=t,a=12*i,o=1/a,m=e+o;if(m===e||(e=m,i=i*r,a=360*i,o=1/a,m=e-o,m===e))return s.exp(e);e=m,i=i*r,a=1260*i;let c=1/a;return e=e+c,i=i*r,a=1680*i,c=1/a,e=e-c,s.exp(e)}else return this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?s.dOne:this.layer===0&&this.mag<=709.7?s.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?N(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?N(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):N(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return s.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return N(1,2,Math.log10(this.mag)-.3010299956639812);{let t=s.div(w(this.sign,this.layer-1,this.mag),w(1,0,2));return t.layer+=1,t.normalize(),t}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(t=2,e=w(1,0,1),r=!1){if(t===1)return s.pow(this,e);if(t===0)return new s(e);if(this.eq(s.dOne))return s.dOne;if(this.eq(-1))return s.pow(this,e);if(t===Number.POSITIVE_INFINITY){let o=this.toNumber();if(o<=1.444667861009766&&o>=.06598803584531254){if(o>1.444667861009099)return s.fromNumber(Math.E);let m=s.ln(this).neg();return m.lambertw().div(m)}else return o>1.444667861009766?s.fromNumber(Number.POSITIVE_INFINITY):s.dNaN}if(this.eq(s.dZero)){let o=Math.abs((t+1)%2);return o>1&&(o=2-o),s.fromNumber(o)}if(t<0)return s.iteratedlog(e,this,-t,r);e=l(e);let i=t;t=Math.trunc(t);let a=i-t;if(this.gt(s.dZero)&&this.lte(1.444667861009766)&&(i>1e4||!r)){t=Math.min(1e4,t);for(let o=0;o1e4){let o=this.pow(e);return i<=1e4||Math.ceil(i)%2==0?e.mul(1-a).add(o.mul(a)):e.mul(a).add(o.mul(1-a))}return e}a!==0&&(e.eq(s.dOne)?this.gt(10)||r?e=this.pow(a):(e=s.fromNumber(s.tetrate_critical(this.toNumber(),a)),this.lt(2)&&(e=e.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?e=e.layeradd10(a,r):e=e.layeradd(a,this,r));for(let o=0;o3)return w(e.sign,e.layer+(t-o-1),e.mag);if(o>1e4)return e}return e}iteratedexp(t=2,e=w(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return s.tetrate(t,-e,this,r);t=l(t);let i=s.fromDecimal(this),a=e;e=Math.trunc(e);let o=a-e;if(i.layer-t.layer>3){let m=Math.min(e,i.layer-t.layer-3);e-=m,i.layer-=m}for(let m=0;m1e4)return i}return o>0&&o<1&&(t.eq(10)?i=i.layeradd10(-o,r):i=i.layeradd(-o,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,a=!1,o=!1,m=this.slog_internal(t,r).toNumber();for(let c=1;c1&&o!=M&&(a=!0),o=M,a?i/=2:i*=2,i=Math.abs(i)*(M?-1:1),m+=i,i===0)break}return s.fromNumber(m)}slog_internal(t=10,e=!1){if(t=l(t),t.lte(s.dZero)||t.eq(s.dOne))return s.dNaN;if(t.lt(s.dOne))return this.eq(s.dOne)?s.dZero:this.eq(s.dZero)?s.dNegOne:s.dNaN;if(this.mag<0||this.eq(s.dZero))return s.dNegOne;let r=0,i=s.fromDecimal(this);if(i.layer-t.layer>3){let a=i.layer-t.layer-3;r+=a,i.layer-=a}for(let a=0;a<100;++a)if(i.lt(s.dZero))i=s.pow(t,i),r-=1;else{if(i.lte(s.dOne))return e?s.fromNumber(r+i.toNumber()-1):s.fromNumber(r+s.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=s.log(i,t)}return s.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:s.critical_section(t,e,Et)}static tetrate_critical(t,e){return s.critical_section(t,e,Ot)}static critical_section(t,e,r,i=!1){e*=10,e<0&&(e=0),e>10&&(e=10),t<2&&(t=2),t>10&&(t=10);let a=0,o=0;for(let c=0;ct){let f=(t-R[c])/(R[c+1]-R[c]);a=r[c][Math.floor(e)]*(1-f)+r[c+1][Math.floor(e)]*f,o=r[c][Math.ceil(e)]*(1-f)+r[c+1][Math.ceil(e)]*f;break}let m=e-Math.floor(e);return a<=0||o<=0?a*(1-m)+o*m:Math.pow(t,Math.log(a)/Math.log(t)*(1-m)+Math.log(o)/Math.log(t)*m)}layeradd10(t,e=!1){t=s.fromValue_noAlloc(t).toNumber();let r=s.fromDecimal(this);if(t>=1){r.mag<0&&r.layer>0?(r.sign=0,r.mag=0,r.layer=0):r.sign===-1&&r.layer==0&&(r.sign=1,r.mag=-r.mag);let i=Math.trunc(t);t-=i,r.layer+=i}if(t<=-1){let i=Math.trunc(t);if(t-=i,r.layer+=i,r.layer<0)for(let a=0;a<100;++a){if(r.layer++,r.mag=Math.log10(r.mag),!isFinite(r.mag))return r.sign===0&&(r.sign=1),r.layer<0&&(r.layer=0),r.normalize();if(r.layer>=0)break}}for(;r.layer<0;)r.layer++,r.mag=Math.log10(r.mag);return r.sign===0&&(r.sign=1,r.mag===0&&r.layer>=1&&(r.layer-=1,r.mag=1)),r.normalize(),t!==0?r.layeradd(t,10,e):r}layeradd(t,e,r=!1){let a=this.slog(e).toNumber()+t;return a>=0?s.tetrate(e,a,s.dOne,r):Number.isFinite(a)?a>=-1?s.log(s.tetrate(e,a+1,s.dOne,r),e):s.log(s.log(s.tetrate(e,a+2,s.dOne,r),e),e):s.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return s.fromNumber(lt(this.toNumber()));if(this.layer===0)return s.fromNumber(lt(this.sign*this.mag));if(this.layer===1)return ut(this);if(this.layer===2)return ut(this);if(this.layer>=3)return w(this.sign,this.layer-1,this.mag);throw"Unhandled behavior in lambertw()"}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(s.dInf))return s.dInf;if(!this.isFinite())return s.dNaN;if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return s.fromNumber(t).add(2).pow(this.recip());if(t<=0)return s.dNaN;if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return eAt?this.pow(this.recip()):s.dNaN}if(this.eq(1))return s.dOne;if(this.lt(0))return s.dNaN;if(this.lte("1ee-16"))return t%2==1?this:s.dNaN;if(this.gt(1)){let e=s.dTen;this.gte(s.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=s.dZero,i=e.layer,a=e.iteratedlog(10,i,!0),o=a,m=a.div(2),c=!0;for(;c;)m=r.add(a).div(2),s.iteratedexp(10,i,m,!0).tetrate(t,1,!0).gt(this)?a=m:r=m,m.eq(o)?c=!1:o=m;return s.iteratedexp(10,i,m,!0)}else{let e=1,r=N(1,10,1),i=N(1,10,1),a=N(1,10,1),o=N(1,1,-16),m=s.dZero,c=N(1,10,1),f=o.pow10().recip(),M=s.dZero,_=f,F=f,x=Math.ceil(t)%2==0,O=0,C=N(1,10,1),y=!1,I=s.dZero,T=!1;for(;e<4;){if(e==2){if(x)break;a=N(1,10,1),o=r,e=3,c=N(1,10,1),C=N(1,10,1)}for(y=!1;o.neq(a);){if(I=o,o.pow10().recip().tetrate(t,1,!0).eq(1)&&o.pow10().recip().lt(.4))f=o.pow10().recip(),_=o.pow10().recip(),F=o.pow10().recip(),M=s.dZero,O=-1,e==3&&(C=o);else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip())&&!x&&o.pow10().recip().lt(.4))f=o.pow10().recip(),_=o.pow10().recip(),F=o.pow10().recip(),M=s.dZero,O=0;else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip().mul(2).tetrate(t,1,!0)))f=o.pow10().recip(),_=s.dZero,F=f.mul(2),M=f,x?O=-1:O=0;else{for(m=o.mul(12e-17),f=o.pow10().recip(),_=o.add(m).pow10().recip(),M=f.sub(_),F=f.add(M);_.tetrate(t,1,!0).eq(f.tetrate(t,1,!0))||F.tetrate(t,1,!0).eq(f.tetrate(t,1,!0))||_.gte(f)||F.lte(f);)m=m.mul(2),_=o.add(m).pow10().recip(),M=f.sub(_),F=f.add(M);if((e==1&&F.tetrate(t,1,!0).gt(f.tetrate(t,1,!0))&&_.tetrate(t,1,!0).gt(f.tetrate(t,1,!0))||e==3&&F.tetrate(t,1,!0).lt(f.tetrate(t,1,!0))&&_.tetrate(t,1,!0).lt(f.tetrate(t,1,!0)))&&(C=o),F.tetrate(t,1,!0).lt(f.tetrate(t,1,!0)))O=-1;else if(x)O=1;else if(e==3&&o.gt_tolerance(r,1e-8))O=0;else{for(;_.tetrate(t,1,!0).eq_tolerance(f.tetrate(t,1,!0),1e-8)||F.tetrate(t,1,!0).eq_tolerance(f.tetrate(t,1,!0),1e-8)||_.gte(f)||F.lte(f);)m=m.mul(2),_=o.add(m).pow10().recip(),M=f.sub(_),F=f.add(M);F.tetrate(t,1,!0).sub(f.tetrate(t,1,!0)).lt(f.tetrate(t,1,!0).sub(_.tetrate(t,1,!0)))?O=0:O=1}}if(O==-1&&(T=!0),e==1&&O==1||e==3&&O!=0)if(a.eq(N(1,10,1)))o=o.mul(2);else{let u=!1;if(y&&(O==1&&e==1||O==-1&&e==3)&&(u=!0),o=o.add(a).div(2),u)break}else if(a.eq(N(1,10,1)))a=o,o=o.div(2);else{let u=!1;if(y&&(O==1&&e==1||O==-1&&e==3)&&(u=!0),a=a.sub(c),o=o.sub(c),u)break}if(a.sub(o).div(2).abs().gt(c.mul(1.5))&&(y=!0),c=a.sub(o).div(2).abs(),o.gt("1e18")||o.eq(I))break}if(o.gt("1e18")||!T||C==N(1,10,1))break;e==1?r=C:e==3&&(i=C),e++}a=r,o=N(1,1,-18);let A=o,n=s.dZero,h=!0;for(;h;)if(a.eq(N(1,10,1))?n=o.mul(2):n=a.add(o).div(2),s.pow(10,n).recip().tetrate(t,1,!0).gt(this)?o=n:a=n,n.eq(A)?h=!1:A=n,o.gt("1e18"))return s.dNaN;if(n.eq_tolerance(r,1e-15)){if(i.eq(N(1,10,1)))return s.dNaN;for(a=N(1,10,1),o=i,A=o,n=s.dZero,h=!0;h;)if(a.eq(N(1,10,1))?n=o.mul(2):n=a.add(o).div(2),s.pow(10,n).recip().tetrate(t,1,!0).gt(this)?o=n:a=n,n.eq(A)?h=!1:A=n,o.gt("1e18"))return s.dNaN;return n.pow10().recip()}else return n.pow10().recip()}}pentate(t=2,e=w(1,0,1),r=!1){e=l(e);let i=t;t=Math.trunc(t);let a=i-t;a!==0&&(e.eq(s.dOne)?(++t,e=s.fromNumber(a)):this.eq(10)?e=e.layeradd10(a,r):e=e.layeradd(a,this,r));for(let o=0;o10)return e}return e}sin(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.sin(this.sign*this.mag)):w(0,0,0)}cos(){return this.mag<0?s.dOne:this.layer===0?s.fromNumber(Math.cos(this.sign*this.mag)):w(0,0,0)}tan(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.tan(this.sign*this.mag)):w(0,0,0)}asin(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.asin(this.sign*this.mag)):w(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?s.fromNumber(Math.acos(this.toNumber())):this.layer===0?s.fromNumber(Math.acos(this.sign*this.mag)):w(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.atan(this.sign*this.mag)):s.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 s.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return s.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?w(Number.NaN,Number.NaN,Number.NaN):s.ln(this.add(1).div(s.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?this:this.root(s.pow(10,t))}egg(){return this.add(9)}lessThanOrEqualTo(t){return this.cmp(t)<1}lessThan(t){return this.cmp(t)<0}greaterThanOrEqualTo(t){return this.cmp(t)>-1}greaterThan(t){return this.cmp(t)>0}static smoothDamp(t,e,r,i){return new s(t).add(new s(e).minus(new s(t)).times(new s(r)).times(new s(i)))}clone(){return this}static clone(t){return s.fromComponents(t.sign,t.layer,t.mag)}softcap(t,e,r){let i=this.clone();return i.gte(t)&&([0,"pow"].includes(r)&&(i=i.div(t).pow(e).mul(t)),[1,"mul"].includes(r)&&(i=i.sub(t).div(e).add(t))),i}static softcap(t,e,r,i){return new s(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new s(t),e=new s(e);let a=this.clone();return a.gte(t)&&([0,"pow"].includes(r)&&(a=i?a.mul(t.pow(e.sub(1))).root(e):a.pow(e).div(t.pow(e.sub(1)))),[1,"exp"].includes(r)&&(a=i?a.div(t).max(1).log(e).add(t):s.pow(e,a.sub(t)).mul(t))),a}static scale(t,e,r,i,a=!1){return new s(t).scale(e,r,i,a)}format(t=2,e=9,r="mixed_sc"){return z.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return z.format(new s(t),e,r,i)}formatST(t=2,e=9,r="st"){return z.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return z.format(new s(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return z.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,a){return z.formatGain(new s(t),e,r,i,a)}toRoman(t=5e3){t=new s(t);let e=this.clone();if(e.gte(t)||e.lt(1))return e;let r=e.toNumber(),i={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},a="";for(let o of Object.keys(i)){let m=Math.floor(r/i[o]);r-=m*i[o],a+=o.repeat(m)}return a}static toRoman(t,e){return new s(t).toRoman(e)}static random(t=0,e=1){return t=new s(t),e=new s(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new s(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new s(Math.random()).lt(t)}};s.dZero=w(0,0,0),s.dOne=w(1,0,1),s.dNegOne=w(-1,0,1),s.dTwo=w(1,0,2),s.dTen=w(1,0,10),s.dNaN=w(Number.NaN,Number.NaN,Number.NaN),s.dInf=w(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNegInf=w(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),s.dNumberMax=N(1,0,Number.MAX_VALUE),s.dNumberMin=N(1,0,Number.MIN_VALUE),s.fromStringCache=new dt(St),W([D()],s.prototype,"sign",2),W([D()],s.prototype,"mag",2),W([D()],s.prototype,"layer",2),s=W([ct()],s);var{formats:z,FORMATS:$t}=Nt(s);s.formats=z;var U=(()=>{let t=e=>new s(e);return Object.getOwnPropertyNames(s).filter(e=>!Object.getOwnPropertyNames(class{}).includes(e)).forEach(e=>{t[e]=s[e]}),t})();function K(t,e){e=Object.assign({formatType:"mixed_sc",acc:2,max:9},e);let{formatType:r,acc:i,max:a,time:o,multi:m,formatTimeType:c}=e;if(o)switch(c){case"short":return U.formats.formatTime(t,i,r);case"long":return U.formats.formatTimeLong(t,!0,0,a,r)}return m?U.formats.formatMult(t,i):U.format(t,i,a,r)}function ht(t,e,r){let{formatType:i,acc:a,max:o}=r;return U.formatGain(t,e,i,a,o)}var Ct=class{constructor(t){this.format=e=>K(e,this.settings),this.gain=(e,r)=>ht(e,r,this.settings),this.time=e=>K(e,{...this.settings,time:!0}),this.multi=e=>K(e,{...this.settings,multi:!0}),this.settingsFn=typeof t=="function"?t:()=>t}get settings(){return this.settingsFn()}},qt=[{name:"Standard",value:"standard"},{name:"Scientific",value:"scientific"},{name:"Mixed Scientific (default)",value:"mixed_sc"},{name:"Old Scientific",value:"old_sc"},{name:"Engineering",value:"eng"},{name:"Infinity",value:"inf"},{name:"Omega",value:"omega"},{name:"Omega Short",value:"omega_short"},{name:"Elemental",value:"elemental"},{name:"Layer",value:"layer"}].sort((t,e)=>t.name.localeCompare(e.name)),Pt=[{name:"Short (default)",value:"short"},{name:"Long",value:"long"}].sort((t,e)=>t.name.localeCompare(e.name));if(typeof G.exports=="object"&&typeof j=="object"){var xt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Object.getOwnPropertyNames(e))!Object.prototype.hasOwnProperty.call(t,a)&&a!==r&&Object.defineProperty(t,a,{get:()=>e[a],enumerable:!(i=Object.getOwnPropertyDescriptor(e,a))||i.enumerable});return t};G.exports=xt(G.exports,j)}return G.exports}); +"use strict";(function(j,G){var k=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],G);else if(typeof module=="object"&&module.exports)module.exports=G();else{var H=G(),J=k?exports:j;for(var Q in H)J[Q]=H[Q]}})(typeof self<"u"?self:exports,()=>{var j={},G={exports:j},k=Object.defineProperty,H=Object.getOwnPropertyDescriptor,J=Object.getOwnPropertyNames,Q=Object.prototype.hasOwnProperty,rt=(t,e)=>{for(var r in e)k(t,r,{get:e[r],enumerable:!0})},mt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of J(e))!Q.call(t,a)&&a!==r&&k(t,a,{get:()=>e[a],enumerable:!(i=H(e,a))||i.enumerable});return t},ft=t=>mt(k({},"__esModule",{value:!0}),t),W=(t,e,r,i)=>{for(var a=i>1?void 0:i?H(e,r):e,o=t.length-1,m;o>=0;o--)(m=t[o])&&(a=(i?m(e,r,a):m(a))||a);return i&&a&&k(e,r,a),a},it={};rt(it,{emathPresets:()=>st}),G.exports=ft(it);var st={};rt(st,{GameFormatClass:()=>Ct,formatOptions:()=>qt,formatTimeOptions:()=>Pt,gameFormat:()=>K,gameFormatGain:()=>ht});var L;(function(t){t[t.PLAIN_TO_CLASS=0]="PLAIN_TO_CLASS",t[t.CLASS_TO_PLAIN=1]="CLASS_TO_PLAIN",t[t.CLASS_TO_CLASS=2]="CLASS_TO_CLASS"})(L||(L={}));var gt=function(){function t(){this._typeMetadatas=new Map,this._transformMetadatas=new Map,this._exposeMetadatas=new Map,this._excludeMetadatas=new Map,this._ancestorsMap=new Map}return t.prototype.addTypeMetadata=function(e){this._typeMetadatas.has(e.target)||this._typeMetadatas.set(e.target,new Map),this._typeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addTransformMetadata=function(e){this._transformMetadatas.has(e.target)||this._transformMetadatas.set(e.target,new Map),this._transformMetadatas.get(e.target).has(e.propertyName)||this._transformMetadatas.get(e.target).set(e.propertyName,[]),this._transformMetadatas.get(e.target).get(e.propertyName).push(e)},t.prototype.addExposeMetadata=function(e){this._exposeMetadatas.has(e.target)||this._exposeMetadatas.set(e.target,new Map),this._exposeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.addExcludeMetadata=function(e){this._excludeMetadatas.has(e.target)||this._excludeMetadatas.set(e.target,new Map),this._excludeMetadatas.get(e.target).set(e.propertyName,e)},t.prototype.findTransformMetadatas=function(e,r,i){return this.findMetadatas(this._transformMetadatas,e,r).filter(function(a){return!a.options||a.options.toClassOnly===!0&&a.options.toPlainOnly===!0?!0:a.options.toClassOnly===!0?i===L.CLASS_TO_CLASS||i===L.PLAIN_TO_CLASS:a.options.toPlainOnly===!0?i===L.CLASS_TO_PLAIN:!0})},t.prototype.findExcludeMetadata=function(e,r){return this.findMetadata(this._excludeMetadatas,e,r)},t.prototype.findExposeMetadata=function(e,r){return this.findMetadata(this._exposeMetadatas,e,r)},t.prototype.findExposeMetadataByCustomName=function(e,r){return this.getExposedMetadatas(e).find(function(i){return i.options&&i.options.name===r})},t.prototype.findTypeMetadata=function(e,r){return this.findMetadata(this._typeMetadatas,e,r)},t.prototype.getStrategy=function(e){var r=this._excludeMetadatas.get(e),i=r&&r.get(void 0),a=this._exposeMetadatas.get(e),o=a&&a.get(void 0);return i&&o||!i&&!o?"none":i?"excludeAll":"exposeAll"},t.prototype.getExposedMetadatas=function(e){return this.getMetadata(this._exposeMetadatas,e)},t.prototype.getExcludedMetadatas=function(e){return this.getMetadata(this._excludeMetadatas,e)},t.prototype.getExposedProperties=function(e,r){return this.getExposedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===L.CLASS_TO_CLASS||r===L.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===L.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.getExcludedProperties=function(e,r){return this.getExcludedMetadatas(e).filter(function(i){return!i.options||i.options.toClassOnly===!0&&i.options.toPlainOnly===!0?!0:i.options.toClassOnly===!0?r===L.CLASS_TO_CLASS||r===L.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===L.CLASS_TO_PLAIN:!0}).map(function(i){return i.propertyName})},t.prototype.clear=function(){this._typeMetadatas.clear(),this._exposeMetadatas.clear(),this._excludeMetadatas.clear(),this._ancestorsMap.clear()},t.prototype.getMetadata=function(e,r){var i=e.get(r),a;i&&(a=Array.from(i.values()).filter(function(F){return F.propertyName!==void 0}));for(var o=[],m=0,c=this.getAncestors(r);mthis.maxSize;){let i=this.last;this.map.delete(i.key),this.last=i.prev,this.last.next=void 0}}},pt=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},Z=[[["","U","D","T","Qa","Qt","Sx","Sp","Oc","No"],["","Dc","Vg","Tg","Qag","Qtg","Sxg","Spg","Ocg","Nog"],["","Ce","De","Te","Qae","Qte","Sxe","Spe","Oce","Noe"]],[["","Mi","Mc","Na","Pc","Fm","At","Zp","Yc","Xn"],["","Me","Du","Tr","Te","Pe","He","Hp","Ot","En"],["","c","Ic","TCn","TeC","PCn","HCn","HpC","OCn","ECn"],["","Hc","DHe","THt","TeH","PHc","HHe","HpH","OHt","EHc"]]];function Nt(t){let e={omega:{config:{greek:"\u03B2\u03B6\u03BB\u03C8\u03A3\u0398\u03A8\u03C9",infinity:"\u03A9"},format(n){n=new t(n);let h=t.floor(n.div(1e3)),u=t.floor(h.div(e.omega.config.greek.length)),g=e.omega.config.greek[h.toNumber()%e.omega.config.greek.length]+o(n.toNumber()%1e3);(e.omega.config.greek[h.toNumber()%e.omega.config.greek.length]===void 0||h.toNumber()>Number.MAX_SAFE_INTEGER)&&(g="\u03C9");let b=t.log(n,8e3).toNumber();if(u.equals(0))return g;if(u.gt(0)&&u.lte(3)){let S=[];for(let E=0;ENumber.MAX_SAFE_INTEGER)&&(g="\u03C9");let b=t.log(n,8e3).toNumber();if(u.equals(0))return g;if(u.gt(0)&&u.lte(2)){let S=[];for(let E=0;E118?e.elemental.beyondOg(d):e.elemental.config.element_lists[n-1][g]},beyondOg(n){let h=Math.floor(Math.log10(n)),u=["n","u","b","t","q","p","h","s","o","e"],g="";for(let d=h;d>=0;d--){let b=Math.floor(n/Math.pow(10,d))%10;g==""?g=u[b].toUpperCase():g+=u[b]}return g},abbreviationLength(n){return n==1?1:Math.pow(Math.floor(n/2)+1,2)*2},getAbbreviationAndValue(n){let h=n.log(118).toNumber(),u=Math.floor(h)+1,g=e.elemental.abbreviationLength(u),d=h-u+1,b=Math.floor(d*g),p=e.elemental.getAbbreviation(u,d),v=new t(118).pow(u+b/g-1);return[p,v]},formatElementalPart(n,h){return h.eq(1)?n:`${h} ${n}`},format(n,h=2){if(n.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(n.log10(),h);let u=n.log(118),d=u.log(118).log(118).toNumber(),b=Math.max(4-d*2,1),p=[];for(;u.gte(1)&&p.length=b)return p.map(S=>e.elemental.formatElementalPart(S[0],S[1])).join(" + ");let v=new t(118).pow(u).toFixed(p.length===1?3:h);return p.length===0?v:p.length===1?`${v} \xD7 ${e.elemental.formatElementalPart(p[0][0],p[0][1])}`:`${v} \xD7 (${p.map(S=>e.elemental.formatElementalPart(S[0],S[1])).join(" + ")})`}},old_sc:{format(n,h){n=new t(n);let u=n.log10().floor();if(u.lt(9))return u.lt(3)?n.toFixed(h):n.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(n.gte("eeee10")){let d=n.slog();return(d.gte(1e9)?"":new t(10).pow(d.sub(d.floor())).toFixed(4))+"F"+e.old_sc.format(d.floor(),0)}let g=n.div(new t(10).pow(u));return(u.log10().gte(9)?"":g.toFixed(4))+"e"+e.old_sc.format(u,0)}}},eng:{format(n,h=2){n=new t(n);let u=n.log10().floor();if(u.lt(9))return u.lt(3)?n.toFixed(h):n.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(n.gte("eeee10")){let d=n.slog();return(d.gte(1e9)?"":new t(10).pow(d.sub(d.floor())).toFixed(4))+"F"+e.eng.format(d.floor(),0)}let g=n.div(new t(1e3).pow(u.div(3).floor()));return(u.log10().gte(9)?"":g.toFixed(new t(4).sub(u.sub(u.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(u.div(3).floor().mul(3),0)}}},mixed_sc:{format(n,h,u=9){n=new t(n);let g=n.log10().floor();return g.lt(303)&&g.gte(u)?f(n,h,u,"st"):f(n,h,u,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(n,h=2,u){n=new t(n);let g=n.max(1).log10().max(1).log(r.log10()).floor();if(g.lte(0))return f(n,h,u,"sc");n=new t(10).pow(n.max(1).log10().div(r.log10().pow(g)).sub(g.gte(1)?1:0));let d=g.div(10).floor(),b=g.toNumber()%10-1;return f(n,Math.max(4,h),u,"sc")+" "+(d.gte(1)?"meta"+(d.gte(2)?"^"+f(d,0,u,"sc"):"")+"-":"")+(isNaN(b)?"nanity":e.layer.layers[b])}},standard:{tier1(n){return Z[0][0][n%10]+Z[0][1][Math.floor(n/10)%10]+Z[0][2][Math.floor(n/100)]},tier2(n){let h=n%10,u=Math.floor(n/10)%10,g=Math.floor(n/100)%10,d="";return n<10?Z[1][0][n]:(u==1&&h==0?d+="Vec":d+=Z[1][1][h]+Z[1][2][u],d+=Z[1][3][g],d)}},inf:{format(n,h,u){n=new t(n);let g=0,d=new t(Number.MAX_VALUE),b=["","\u221E","\u03A9","\u03A8","\u028A"],p=["","","m","mm","mmm"];for(;n.gte(d);)n=n.log(d),g++;return g==0?f(n,h,u,"sc"):n.gte(3)?p[g]+b[g]+"\u03C9^"+f(n.sub(1),h,u,"sc"):n.gte(2)?p[g]+"\u03C9"+b[g]+"-"+f(d.pow(n.sub(2)),h,u,"sc"):p[g]+b[g]+"-"+f(d.pow(n.sub(1)),h,u,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(n,h=new t(1e15),u=!1,g=9){if(n=new t(n),h=new t(h).div(1e3),n.lt(h.mul(1e3)))return"";let{alphabet:d}=e.alphabet.config,b=d.length,p=n.log(1e3).sub(h.log(1e3)).floor(),v=p.add(1).log(b+1).ceil(),S="",E=(q,V)=>{let P=q,Y="";for(let $=0;$=b)return"\u03C9";Y=d[X]+Y,P=P.sub(1).div(b).floor()}return Y};if(v.lt(g))S=E(p,v);else{let q=v.sub(g).add(1),V=p.div(t.pow(b+1,q.sub(1))).floor();S=`${E(V,new t(g))}(${q.gt("1e9")?q.format():q.format(0)})`}return S},format(n,h=2,u=9,g="mixed_sc",d=new t(1e15),b=!1,p){if(n=new t(n),d=new t(d).div(1e3),n.lt(d.mul(1e3)))return f(n,h,u,g);let v=e.alphabet.getAbbreviation(n,d,b,p),S=n.div(t.pow(1e3,n.log(1e3).floor()));return`${v.length>(p??9)+2?"":S.toFixed(h)+" "}${v}`}}},r=new t(2).pow(1024),i="\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089",a="\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079";function o(n){return n.toFixed(0).split("").map(h=>h==="-"?"\u208B":i[parseInt(h,10)]).join("")}function m(n){return n.toFixed(0).split("").map(h=>h==="-"?"\u208B":a[parseInt(h,10)]).join("")}function c(n,h=2,u=9,g="st"){return f(n,h,u,g)}function f(n,h=2,u=9,g="mixed_sc"){n=new t(n);let d=n.lt(0)?"-":"";if(n.mag==1/0)return d+"Infinity";if(Number.isNaN(n.mag))return d+"NaN";if(n.lt(0)&&(n=n.mul(-1)),n.eq(0))return n.toFixed(h);let b=n.log10().floor();switch(g){case"sc":case"scientific":if(n.log10().lt(Math.min(-h,0))&&h>1){let p=n.log10().ceil(),v=n.div(p.eq(-1)?new t(.1):new t(10).pow(p)),S=p.mul(-1).max(1).log10().gte(9);return d+(S?"":v.toFixed(2))+"e"+f(p,0,u,"mixed_sc")}else if(b.lt(u)){let p=Math.max(Math.min(h-b.toNumber(),h),0);return d+(p>0?n.toFixed(p):n.toFixed(p).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(n.gte("eeee10")){let S=n.slog();return(S.gte(1e9)?"":new t(10).pow(S.sub(S.floor())).toFixed(2))+"F"+f(S.floor(),0)}let p=n.div(new t(10).pow(b)),v=b.log10().gte(9);return d+(v?"":p.toFixed(2))+"e"+f(b,0,u,"mixed_sc")}case"st":case"standard":{let p=n.log(1e3).floor();if(p.lt(1))return d+n.toFixed(Math.max(Math.min(h-b.toNumber(),h),0));let v=p.mul(3),S=p.log10().floor();if(S.gte(3e3))return"e"+f(b,h,u,"st");let E="";if(p.lt(4))E=["","K","M","B"][Math.round(p.toNumber())];else{let P=Math.floor(p.log(1e3).toNumber());for(P<100&&(P=Math.max(P-1,0)),p=p.sub(1).div(new t(10).pow(P*3));p.gt(0);){let Y=p.div(1e3).floor(),$=p.sub(Y.mul(1e3)).floor().toNumber();$>0&&($==1&&!P&&(E="U"),P&&(E=e.standard.tier2(P)+(E?"-"+E:"")),$>1&&(E=e.standard.tier1($)+E)),p=Y,P++}}let q=n.div(new t(10).pow(v)),V=h===2?new t(2).sub(b.sub(v)).add(1).toNumber():h;return d+(S.gte(10)?"":q.toFixed(V)+" ")+E}default:return e[g]||console.error('Invalid format type "',g,'"'),d+e[g].format(n,h,u)}}function M(n,h,u="mixed_sc",g,d){n=new t(n),h=new t(h);let b=n.add(h),p,v=b.div(n);return v.gte(10)&&n.gte(1e100)?(v=v.log10().mul(20),p="(+"+f(v,g,d,u)+" OoMs/sec)"):p="(+"+f(h,g,d,u)+"/sec)",p}function _(n,h=2,u="s"){return n=new t(n),n.gte(86400)?f(n.div(86400).floor(),0,12,"sc")+":"+_(n.mod(86400),h,"d"):n.gte(3600)||u=="d"?(n.div(3600).gte(10)||u!="d"?"":"0")+f(n.div(3600).floor(),0,12,"sc")+":"+_(n.mod(3600),h,"h"):n.gte(60)||u=="h"?(n.div(60).gte(10)||u!="h"?"":"0")+f(n.div(60).floor(),0,12,"sc")+":"+_(n.mod(60),h,"m"):(n.gte(10)||u!="m"?"":"0")+f(n,h,12,"sc")}function F(n,h=!1,u=0,g=9,d="mixed_sc"){let b=Vt=>f(Vt,u,g,d);n=new t(n);let p=n.mul(1e3).mod(1e3).floor(),v=n.mod(60).floor(),S=n.div(60).mod(60).floor(),E=n.div(3600).mod(24).floor(),q=n.div(86400).mod(365.2425).floor(),V=n.div(31556952).floor(),P=V.eq(1)?" year":" years",Y=q.eq(1)?" day":" days",$=E.eq(1)?" hour":" hours",X=S.eq(1)?" minute":" minutes",Lt=v.eq(1)?" second":" seconds",Gt=p.eq(1)?" millisecond":" milliseconds";return`${V.gt(0)?b(V)+P+", ":""}${q.gt(0)?b(q)+Y+", ":""}${E.gt(0)?b(E)+$+", ":""}${S.gt(0)?b(S)+X+", ":""}${v.gt(0)?b(v)+Lt+",":""}${h&&p.gt(0)?" "+b(p)+Gt:""}`.replace(/,([^,]*)$/,"$1").trim()}function x(n){return n=new t(n),f(new t(1).sub(n).mul(100))+"%"}function O(n){return n=new t(n),f(n.mul(100))+"%"}function C(n,h=2){return n=new t(n),n.gte(1)?"\xD7"+n.format(h):"/"+n.pow(-1).format(h)}function y(n,h,u=10){return t.gte(n,10)?t.pow(u,t.log(n,u).pow(h)):new t(n)}function I(n,h=0){n=new t(n);let u=(p=>p.map((v,S)=>({name:v.name,altName:v.altName,value:t.pow(1e3,new t(S).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"E",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),g="",d=n.lte(0)?0:t.min(t.log(n,1e3).sub(1),u.length-1).floor().toNumber(),b=u[d];if(d===0)switch(h){case 1:g="";break;case 2:case 0:default:g=n.format();break}switch(h){case 1:g=b.name;break;case 2:g=n.divide(b.value).format();break;case 3:g=b.altName;break;case 0:default:g=`${n.divide(b.value).format()} ${b.name}`;break}return g}function T(n,h=!1){return`${I(n,2)} ${I(n,1)}eV${h?"/c^2":""}`}let A={...e,toSubscript:o,toSuperscript:m,formatST:c,format:f,formatGain:M,formatTime:_,formatTimeLong:F,formatReduction:x,formatPercent:O,formatMult:C,expMult:y,metric:I,ev:T};return{FORMATS:e,formats:A}}var tt=17,bt=9e15,Mt=Math.log10(9e15),yt=1/9e15,_t=308,wt=-324,at=5,St=1023,It=!0,vt=!1,Ft=function(){let t=[];for(let r=wt+1;r<=_t;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),R=[2,Math.E,3,4,5,6,7,8,9,10],Ot=[[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]],Et=[[-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]],l=function(e){return s.fromValue_noAlloc(e)},N=function(t,e,r){return s.fromComponents(t,e,r)},w=function(e,r,i){return s.fromComponents_noNormalize(e,r,i)},B=function(e,r){let i=r+1,a=Math.ceil(Math.log10(Math.abs(e))),o=Math.round(e*Math.pow(10,i-a))*Math.pow(10,a-i);return parseFloat(o.toFixed(Math.max(i-a,0)))},et=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},Tt=function(t){if(!isFinite(t))return t;if(t<-50)return t===Math.trunc(t)?Number.NEGATIVE_INFINITY:0;let e=1;for(;t<10;)e=e*t,++t;t-=1;let r=.9189385332046727;r=r+(t+.5)*Math.log(t),r=r-t;let i=t*t,a=t;return r=r+1/(12*a),a=a*i,r=r+1/(360*a),a=a*i,r=r+1/(1260*a),a=a*i,r=r+1/(1680*a),a=a*i,r=r+1/(1188*a),a=a*i,r=r+691/(360360*a),a=a*i,r=r+7/(1092*a),a=a*i,r=r+3617/(122400*a),Math.exp(r)/e},At=.36787944117144233,ot=.5671432904097838,lt=function(t,e=1e-10){let r,i;if(!Number.isFinite(t)||t===0)return t;if(t===1)return ot;t<10?r=0:r=Math.log(t)-Math.log(Math.log(t));for(let a=0;a<100;++a){if(i=(t*Math.exp(-r)+r*r)/(r+1),Math.abs(i-r).5?1:-1;if(Math.random()*20<1)return w(e,0,1);let r=Math.floor(Math.random()*(t+1)),i=r===0?Math.random()*616-308:Math.random()*16;Math.random()>.9&&(i=Math.trunc(i));let a=Math.pow(10,i);return Math.random()>.9&&(a=Math.trunc(a)),N(e,r,a)}static affordGeometricSeries_core(t,e,r,i){let a=e.mul(r.pow(i));return s.floor(t.div(a).mul(r.sub(1)).add(1).log10().div(r.log10()))}static sumGeometricSeries_core(t,e,r,i){return e.mul(r.pow(i)).mul(s.sub(1,r.pow(t))).div(s.sub(1,r))}static affordArithmeticSeries_core(t,e,r,i){let o=e.add(i.mul(r)).sub(r.div(2)),m=o.pow(2);return o.neg().add(m.add(r.mul(t).mul(2)).sqrt()).div(r).floor()}static sumArithmeticSeries_core(t,e,r,i){let a=e.add(i.mul(r));return t.div(2).mul(a.mul(2).plus(t.sub(1).mul(r)))}static efficiencyOfPurchase_core(t,e,r){return t.div(e).add(t.div(r))}normalize(){if(this.sign===0||this.mag===0&&this.layer===0||this.mag===Number.NEGATIVE_INFINITY&&this.layer>0&&Number.isFinite(this.layer))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.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_INFINITY)return this.sign==1?(this.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY):this.sign==-1&&(this.mag=Number.NEGATIVE_INFINITY,this.layer=Number.NEGATIVE_INFINITY),this;if(this.layer===0&&this.mag=bt)return this.layer+=1,this.mag=e*Math.log10(t),this;for(;t0;)this.layer-=1,this.layer===0?this.mag=Math.pow(10,this.mag):(this.mag=e*Math.pow(10,t),t=Math.abs(this.mag),e=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)),(Number.isNaN(this.sign)||Number.isNaN(this.layer)||Number.isNaN(this.mag))&&(this.sign=Number.NaN,this.layer=Number.NaN,this.mag=Number.NaN),this}fromComponents(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this.normalize(),this}fromComponents_noNormalize(t,e,r){return this.sign=t,this.layer=e,this.mag=r,this}fromMantissaExponent(t,e){return this.layer=1,this.sign=Math.sign(t),t=Math.abs(t),this.mag=e+Math.log10(t),this.normalize(),this}fromMantissaExponent_noNormalize(t,e){return this.fromMantissaExponent(t,e),this}fromDecimal(t){return this.sign=t.sign,this.layer=t.layer,this.mag=t.mag,this}fromNumber(t){return this.mag=Math.abs(t),this.sign=Math.sign(t),this.layer=0,this.normalize(),this}fromString(t,e=!1){let r=t,i=s.fromStringCache.get(r);if(i!==void 0)return this.fromDecimal(i);It?t=t.replace(",",""):vt&&(t=t.replace(",","."));let a=t.split("^^^");if(a.length===2){let y=parseFloat(a[0]),I=parseFloat(a[1]),T=a[1].split(";"),A=1;if(T.length===2&&(A=parseFloat(T[1]),isFinite(A)||(A=1)),isFinite(y)&&isFinite(I)){let n=s.pentate(y,I,A,e);return this.sign=n.sign,this.layer=n.layer,this.mag=n.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let o=t.split("^^");if(o.length===2){let y=parseFloat(o[0]),I=parseFloat(o[1]),T=o[1].split(";"),A=1;if(T.length===2&&(A=parseFloat(T[1]),isFinite(A)||(A=1)),isFinite(y)&&isFinite(I)){let n=s.tetrate(y,I,A,e);return this.sign=n.sign,this.layer=n.layer,this.mag=n.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let m=t.split("^");if(m.length===2){let y=parseFloat(m[0]),I=parseFloat(m[1]);if(isFinite(y)&&isFinite(I)){let T=s.pow(y,I);return this.sign=T.sign,this.layer=T.layer,this.mag=T.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}t=t.trim().toLowerCase();let c,f,M=t.split("pt");if(M.length===2){c=10,f=parseFloat(M[0]),M[1]=M[1].replace("(",""),M[1]=M[1].replace(")","");let y=parseFloat(M[1]);if(isFinite(y)||(y=1),isFinite(c)&&isFinite(f)){let I=s.tetrate(c,f,y,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(M=t.split("p"),M.length===2){c=10,f=parseFloat(M[0]),M[1]=M[1].replace("(",""),M[1]=M[1].replace(")","");let y=parseFloat(M[1]);if(isFinite(y)||(y=1),isFinite(c)&&isFinite(f)){let I=s.tetrate(c,f,y,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(M=t.split("f"),M.length===2){c=10,M[0]=M[0].replace("(",""),M[0]=M[0].replace(")","");let y=parseFloat(M[0]);if(M[1]=M[1].replace("(",""),M[1]=M[1].replace(")",""),f=parseFloat(M[1]),isFinite(y)||(y=1),isFinite(c)&&isFinite(f)){let I=s.tetrate(c,f,y,e);return this.sign=I.sign,this.layer=I.layer,this.mag=I.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}let _=t.split("e"),F=_.length-1;if(F===0){let y=parseFloat(t);if(isFinite(y))return this.fromNumber(y),s.fromStringCache.size>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else if(F===1){let y=parseFloat(t);if(isFinite(y)&&y!==0)return this.fromNumber(y),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}let x=t.split("e^");if(x.length===2){this.sign=1,x[0].charAt(0)=="-"&&(this.sign=-1);let y="";for(let I=0;I=43&&T<=57||T===101)y+=x[1].charAt(I);else return this.layer=parseFloat(y),this.mag=parseFloat(x[1].substr(I+1)),this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(F<1)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let O=parseFloat(_[0]);if(O===0)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let C=parseFloat(_[_.length-1]);if(F>=2){let y=parseFloat(_[_.length-2]);isFinite(y)&&(C*=Math.sign(y),C+=et(y))}if(!isFinite(O))this.sign=_[0]==="-"?-1:1,this.layer=F,this.mag=C;else if(F===1)this.sign=Math.sign(O),this.layer=1,this.mag=C+Math.log10(Math.abs(O));else if(this.sign=Math.sign(O),this.layer=F,F===2){let y=s.mul(N(1,2,C),l(O));return this.sign=y.sign,this.layer=y.layer,this.mag=y.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else this.mag=C;return this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}fromValue(t){return t instanceof s?this.fromDecimal(t):typeof t=="number"?this.fromNumber(t):typeof t=="string"?this.fromString(t):(this.sign=0,this.layer=0,this.mag=0,this)}toNumber(){return this.mag===Number.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_INFINITY&&this.sign===1?Number.POSITIVE_INFINITY:this.mag===Number.NEGATIVE_INFINITY&&this.layer===Number.NEGATIVE_INFINITY&&this.sign===-1?Number.NEGATIVE_INFINITY: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(t){return isNaN(this.m)?Number.NaN:this.m===0?0:B(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:B(this.mag,t)}toString(){return isNaN(this.layer)||isNaN(this.sign)||isNaN(this.mag)?"NaN":this.mag===Number.POSITIVE_INFINITY||this.layer===Number.POSITIVE_INFINITY||this.mag===Number.NEGATIVE_INFINITY||this.layer===Number.NEGATIVE_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<=at?(this.sign===-1?"-":"")+"e".repeat(this.layer)+this.mag:(this.sign===-1?"-":"")+"(e^"+this.layer+")"+this.mag}toExponential(t){return this.layer===0?(this.sign*this.mag).toExponential(t):this.toStringWithDecimalPlaces(t)}toFixed(t){return this.layer===0?(this.sign*this.mag).toFixed(t):this.toStringWithDecimalPlaces(t)}toPrecision(t){return this.e<=-7?this.toExponential(t-1):t>this.e?this.toFixed(t-this.exponent-1):this.toExponential(t-1)}valueOf(){return this.toString()}toJSON(){return this.toString()}toStringWithDecimalPlaces(t){return this.layer===0?this.mag<1e21&&this.mag>1e-7||this.mag===0?(this.sign*this.mag).toFixed(t):B(this.m,t)+"e"+B(this.e,t):this.layer===1?B(this.m,t)+"e"+B(this.e,t):this.layer<=at?(this.sign===-1?"-":"")+"e".repeat(this.layer)+B(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+B(this.mag,t)}abs(){return w(this.sign===0?0:1,this.layer,this.mag)}neg(){return w(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?s.dZero:this.layer===0?N(this.sign,0,Math.round(this.mag)):this}floor(){return this.mag<0?this.sign===-1?s.dNegOne:s.dZero:this.sign===-1?this.neg().ceil().neg():this.layer===0?N(this.sign,0,Math.floor(this.mag)):this}ceil(){return this.mag<0?this.sign===1?s.dOne:s.dZero:this.sign===-1?this.neg().floor().neg():this.layer===0?N(this.sign,0,Math.ceil(this.mag)):this}trunc(){return this.mag<0?s.dZero:this.layer===0?N(this.sign,0,Math.trunc(this.mag)):this}add(t){let e=l(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer)||this.sign===0)return e;if(e.sign===0)return this;if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return w(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(s.cmpabs(this,e)>0?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*r.mag+i.sign*i.mag);let a=r.layer*Math.sign(r.mag),o=i.layer*Math.sign(i.mag);if(a-o>=2)return r;if(a===0&&o===-1){if(Math.abs(i.mag-Math.log10(r.mag))>tt)return r;{let m=Math.pow(10,Math.log10(r.mag)-i.mag),c=i.sign+r.sign*m;return N(Math.sign(c),1,i.mag+Math.log10(Math.abs(c)))}}if(a===1&&o===0){if(Math.abs(r.mag-Math.log10(i.mag))>tt)return r;{let m=Math.pow(10,r.mag-Math.log10(i.mag)),c=i.sign+r.sign*m;return N(Math.sign(c),1,Math.log10(i.mag)+Math.log10(Math.abs(c)))}}if(Math.abs(r.mag-i.mag)>tt)return r;{let m=Math.pow(10,r.mag-i.mag),c=i.sign+r.sign*m;return N(Math.sign(c),1,i.mag+Math.log10(Math.abs(c)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(l(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=l(t);if(!Number.isFinite(this.layer))return this;if(!Number.isFinite(e.layer))return e;if(this.sign===0||e.sign===0)return w(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return w(this.sign*e.sign,0,1);let r,i;if(this.layer>e.layer||this.layer==e.layer&&Math.abs(this.mag)>Math.abs(e.mag)?(r=this,i=e):(r=e,i=this),r.layer===0&&i.layer===0)return s.fromNumber(r.sign*i.sign*r.mag*i.mag);if(r.layer>=3||r.layer-i.layer>=2)return N(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return N(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return N(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let a=N(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(N(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return N(r.sign*i.sign,a.layer+1,a.sign*a.mag)}if(r.layer===2&&i.layer===2){let a=N(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(N(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return N(r.sign*i.sign,a.layer+1,a.sign*a.mag)}throw Error("Bad arguments to mul: "+this+", "+t)}multiply(t){return this.mul(t)}times(t){return this.mul(t)}div(t){let e=l(t);return this.mul(e.recip())}divide(t){return this.div(t)}divideBy(t){return this.div(t)}dividedBy(t){return this.div(t)}recip(){return this.mag===0?s.dNaN:this.layer===0?N(this.sign,0,1/this.mag):N(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=l(t).abs();if(e.eq(s.dZero))return s.dZero;let r=this.toNumber(),i=e.toNumber();return isFinite(r)&&isFinite(i)&&r!=0&&i!=0?new s(r%i):this.sub(e).eq(this)?s.dZero:e.sub(this).eq(e)?this:this.sign==-1?this.abs().mod(e).neg():this.sub(this.div(e).floor().mul(e))}modulo(t){return this.mod(t)}modular(t){return this.mod(t)}cmp(t){let e=l(t);return this.sign>e.sign?1:this.sign0?this.layer:-this.layer,i=e.mag>0?e.layer:-e.layer;return r>i?1:re.mag?1:this.mag0?e:this}clamp(t,e){return this.max(t).min(e)}clampMin(t){return this.max(t)}clampMax(t){return this.min(t)}cmp_tolerance(t,e){let r=l(t);return this.eq_tolerance(r,e)?0:this.cmp(r)}compare_tolerance(t,e){return this.cmp_tolerance(t,e)}eq_tolerance(t,e){let r=l(t);if(e==null&&(e=1e-7),this.sign!==r.sign||Math.abs(this.layer-r.layer)>1)return!1;let i=this.mag,a=r.mag;return this.layer>r.layer&&(a=et(a)),this.layer0?N(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):N(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?s.dNaN:this.layer>0?N(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):N(this.sign,0,Math.log10(this.mag))}log(t){return t=l(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?s.dNaN:this.layer===0&&t.layer===0?N(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):s.div(this.log10(),t.log10())}log2(){return this.sign<=0?s.dNaN:this.layer===0?N(this.sign,0,Math.log2(this.mag)):this.layer===1?N(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?N(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):N(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?s.dNaN:this.layer===0?N(this.sign,0,Math.log(this.mag)):this.layer===1?N(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?N(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):N(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=l(t),r=this,i=e;if(r.sign===0)return i.eq(0)?w(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return w(1,0,1);if(i.sign===1&&i.layer===0&&i.mag===1)return r;let a=r.absLog10().mul(i).pow10();return this.sign===-1?Math.abs(i.toNumber()%2)%2===1?a.neg():Math.abs(i.toNumber()%2)%2===0?a:s.dNaN:a}pow10(){if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return s.dNaN;let t=this;if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return N(1,0,e);if(t.sign===0)return s.dOne;t=w(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?N(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?N(-t.sign,t.layer+1,-t.mag):s.dOne}pow_base(t){return l(t).pow(this)}root(t){let e=l(t);return this.pow(e.recip())}factorial(){return this.mag<0?this.add(1).gamma():this.layer===0?this.add(1).gamma():this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}gamma(){if(this.mag<0)return this.recip();if(this.layer===0){if(this.lt(w(1,0,24)))return s.fromNumber(Tt(this.sign*this.mag));let t=this.mag-1,e=.9189385332046727;e=e+(t+.5)*Math.log(t),e=e-t;let r=t*t,i=t,a=12*i,o=1/a,m=e+o;if(m===e||(e=m,i=i*r,a=360*i,o=1/a,m=e-o,m===e))return s.exp(e);e=m,i=i*r,a=1260*i;let c=1/a;return e=e+c,i=i*r,a=1680*i,c=1/a,e=e-c,s.exp(e)}else return this.layer===1?s.exp(s.mul(this,s.ln(this).sub(1))):s.exp(this)}lngamma(){return this.gamma().ln()}exp(){return this.mag<0?s.dOne:this.layer===0&&this.mag<=709.7?s.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?N(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?N(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):N(1,this.layer+1,this.sign*this.mag)}sqr(){return this.pow(2)}sqrt(){if(this.layer===0)return s.fromNumber(Math.sqrt(this.sign*this.mag));if(this.layer===1)return N(1,2,Math.log10(this.mag)-.3010299956639812);{let t=s.div(w(this.sign,this.layer-1,this.mag),w(1,0,2));return t.layer+=1,t.normalize(),t}}cube(){return this.pow(3)}cbrt(){return this.pow(1/3)}tetrate(t=2,e=w(1,0,1),r=!1){if(t===1)return s.pow(this,e);if(t===0)return new s(e);if(this.eq(s.dOne))return s.dOne;if(this.eq(-1))return s.pow(this,e);if(t===Number.POSITIVE_INFINITY){let o=this.toNumber();if(o<=1.444667861009766&&o>=.06598803584531254){if(o>1.444667861009099)return s.fromNumber(Math.E);let m=s.ln(this).neg();return m.lambertw().div(m)}else return o>1.444667861009766?s.fromNumber(Number.POSITIVE_INFINITY):s.dNaN}if(this.eq(s.dZero)){let o=Math.abs((t+1)%2);return o>1&&(o=2-o),s.fromNumber(o)}if(t<0)return s.iteratedlog(e,this,-t,r);e=l(e);let i=t;t=Math.trunc(t);let a=i-t;if(this.gt(s.dZero)&&this.lte(1.444667861009766)&&(i>1e4||!r)){t=Math.min(1e4,t);for(let o=0;o1e4){let o=this.pow(e);return i<=1e4||Math.ceil(i)%2==0?e.mul(1-a).add(o.mul(a)):e.mul(a).add(o.mul(1-a))}return e}a!==0&&(e.eq(s.dOne)?this.gt(10)||r?e=this.pow(a):(e=s.fromNumber(s.tetrate_critical(this.toNumber(),a)),this.lt(2)&&(e=e.sub(1).mul(this.minus(1)).plus(1))):this.eq(10)?e=e.layeradd10(a,r):e=e.layeradd(a,this,r));for(let o=0;o3)return w(e.sign,e.layer+(t-o-1),e.mag);if(o>1e4)return e}return e}iteratedexp(t=2,e=w(1,0,1),r=!1){return this.tetrate(t,e,r)}iteratedlog(t=10,e=1,r=!1){if(e<0)return s.tetrate(t,-e,this,r);t=l(t);let i=s.fromDecimal(this),a=e;e=Math.trunc(e);let o=a-e;if(i.layer-t.layer>3){let m=Math.min(e,i.layer-t.layer-3);e-=m,i.layer-=m}for(let m=0;m1e4)return i}return o>0&&o<1&&(t.eq(10)?i=i.layeradd10(-o,r):i=i.layeradd(-o,t,r)),i}slog(t=10,e=100,r=!1){let i=.001,a=!1,o=!1,m=this.slog_internal(t,r).toNumber();for(let c=1;c1&&o!=M&&(a=!0),o=M,a?i/=2:i*=2,i=Math.abs(i)*(M?-1:1),m+=i,i===0)break}return s.fromNumber(m)}slog_internal(t=10,e=!1){if(t=l(t),t.lte(s.dZero)||t.eq(s.dOne))return s.dNaN;if(t.lt(s.dOne))return this.eq(s.dOne)?s.dZero:this.eq(s.dZero)?s.dNegOne:s.dNaN;if(this.mag<0||this.eq(s.dZero))return s.dNegOne;let r=0,i=s.fromDecimal(this);if(i.layer-t.layer>3){let a=i.layer-t.layer-3;r+=a,i.layer-=a}for(let a=0;a<100;++a)if(i.lt(s.dZero))i=s.pow(t,i),r-=1;else{if(i.lte(s.dOne))return e?s.fromNumber(r+i.toNumber()-1):s.fromNumber(r+s.slog_critical(t.toNumber(),i.toNumber()));r+=1,i=s.log(i,t)}return s.fromNumber(r)}static slog_critical(t,e){return t>10?e-1:s.critical_section(t,e,Et)}static tetrate_critical(t,e){return s.critical_section(t,e,Ot)}static critical_section(t,e,r,i=!1){e*=10,e<0&&(e=0),e>10&&(e=10),t<2&&(t=2),t>10&&(t=10);let a=0,o=0;for(let c=0;ct){let f=(t-R[c])/(R[c+1]-R[c]);a=r[c][Math.floor(e)]*(1-f)+r[c+1][Math.floor(e)]*f,o=r[c][Math.ceil(e)]*(1-f)+r[c+1][Math.ceil(e)]*f;break}let m=e-Math.floor(e);return a<=0||o<=0?a*(1-m)+o*m:Math.pow(t,Math.log(a)/Math.log(t)*(1-m)+Math.log(o)/Math.log(t)*m)}layeradd10(t,e=!1){t=s.fromValue_noAlloc(t).toNumber();let r=s.fromDecimal(this);if(t>=1){r.mag<0&&r.layer>0?(r.sign=0,r.mag=0,r.layer=0):r.sign===-1&&r.layer==0&&(r.sign=1,r.mag=-r.mag);let i=Math.trunc(t);t-=i,r.layer+=i}if(t<=-1){let i=Math.trunc(t);if(t-=i,r.layer+=i,r.layer<0)for(let a=0;a<100;++a){if(r.layer++,r.mag=Math.log10(r.mag),!isFinite(r.mag))return r.sign===0&&(r.sign=1),r.layer<0&&(r.layer=0),r.normalize();if(r.layer>=0)break}}for(;r.layer<0;)r.layer++,r.mag=Math.log10(r.mag);return r.sign===0&&(r.sign=1,r.mag===0&&r.layer>=1&&(r.layer-=1,r.mag=1)),r.normalize(),t!==0?r.layeradd(t,10,e):r}layeradd(t,e,r=!1){let a=this.slog(e).toNumber()+t;return a>=0?s.tetrate(e,a,s.dOne,r):Number.isFinite(a)?a>=-1?s.log(s.tetrate(e,a+1,s.dOne,r),e):s.log(s.log(s.tetrate(e,a+2,s.dOne,r),e),e):s.dNaN}lambertw(){if(this.lt(-.3678794411710499))throw Error("lambertw is unimplemented for results less than -1, sorry!");if(this.mag<0)return s.fromNumber(lt(this.toNumber()));if(this.layer===0)return s.fromNumber(lt(this.sign*this.mag));if(this.layer===1)return ut(this);if(this.layer===2)return ut(this);if(this.layer>=3)return w(this.sign,this.layer-1,this.mag);throw"Unhandled behavior in lambertw()"}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(s.dInf))return s.dInf;if(!this.isFinite())return s.dNaN;if(t>0&&t<1)return this.root(t);if(t>-2&&t<-1)return s.fromNumber(t).add(2).pow(this.recip());if(t<=0)return s.dNaN;if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return eAt?this.pow(this.recip()):s.dNaN}if(this.eq(1))return s.dOne;if(this.lt(0))return s.dNaN;if(this.lte("1ee-16"))return t%2==1?this:s.dNaN;if(this.gt(1)){let e=s.dTen;this.gte(s.tetrate(10,t,1,!0))&&(e=this.iteratedlog(10,t-1,!0)),t<=1&&(e=this.root(t));let r=s.dZero,i=e.layer,a=e.iteratedlog(10,i,!0),o=a,m=a.div(2),c=!0;for(;c;)m=r.add(a).div(2),s.iteratedexp(10,i,m,!0).tetrate(t,1,!0).gt(this)?a=m:r=m,m.eq(o)?c=!1:o=m;return s.iteratedexp(10,i,m,!0)}else{let e=1,r=N(1,10,1),i=N(1,10,1),a=N(1,10,1),o=N(1,1,-16),m=s.dZero,c=N(1,10,1),f=o.pow10().recip(),M=s.dZero,_=f,F=f,x=Math.ceil(t)%2==0,O=0,C=N(1,10,1),y=!1,I=s.dZero,T=!1;for(;e<4;){if(e==2){if(x)break;a=N(1,10,1),o=r,e=3,c=N(1,10,1),C=N(1,10,1)}for(y=!1;o.neq(a);){if(I=o,o.pow10().recip().tetrate(t,1,!0).eq(1)&&o.pow10().recip().lt(.4))f=o.pow10().recip(),_=o.pow10().recip(),F=o.pow10().recip(),M=s.dZero,O=-1,e==3&&(C=o);else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip())&&!x&&o.pow10().recip().lt(.4))f=o.pow10().recip(),_=o.pow10().recip(),F=o.pow10().recip(),M=s.dZero,O=0;else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip().mul(2).tetrate(t,1,!0)))f=o.pow10().recip(),_=s.dZero,F=f.mul(2),M=f,x?O=-1:O=0;else{for(m=o.mul(12e-17),f=o.pow10().recip(),_=o.add(m).pow10().recip(),M=f.sub(_),F=f.add(M);_.tetrate(t,1,!0).eq(f.tetrate(t,1,!0))||F.tetrate(t,1,!0).eq(f.tetrate(t,1,!0))||_.gte(f)||F.lte(f);)m=m.mul(2),_=o.add(m).pow10().recip(),M=f.sub(_),F=f.add(M);if((e==1&&F.tetrate(t,1,!0).gt(f.tetrate(t,1,!0))&&_.tetrate(t,1,!0).gt(f.tetrate(t,1,!0))||e==3&&F.tetrate(t,1,!0).lt(f.tetrate(t,1,!0))&&_.tetrate(t,1,!0).lt(f.tetrate(t,1,!0)))&&(C=o),F.tetrate(t,1,!0).lt(f.tetrate(t,1,!0)))O=-1;else if(x)O=1;else if(e==3&&o.gt_tolerance(r,1e-8))O=0;else{for(;_.tetrate(t,1,!0).eq_tolerance(f.tetrate(t,1,!0),1e-8)||F.tetrate(t,1,!0).eq_tolerance(f.tetrate(t,1,!0),1e-8)||_.gte(f)||F.lte(f);)m=m.mul(2),_=o.add(m).pow10().recip(),M=f.sub(_),F=f.add(M);F.tetrate(t,1,!0).sub(f.tetrate(t,1,!0)).lt(f.tetrate(t,1,!0).sub(_.tetrate(t,1,!0)))?O=0:O=1}}if(O==-1&&(T=!0),e==1&&O==1||e==3&&O!=0)if(a.eq(N(1,10,1)))o=o.mul(2);else{let u=!1;if(y&&(O==1&&e==1||O==-1&&e==3)&&(u=!0),o=o.add(a).div(2),u)break}else if(a.eq(N(1,10,1)))a=o,o=o.div(2);else{let u=!1;if(y&&(O==1&&e==1||O==-1&&e==3)&&(u=!0),a=a.sub(c),o=o.sub(c),u)break}if(a.sub(o).div(2).abs().gt(c.mul(1.5))&&(y=!0),c=a.sub(o).div(2).abs(),o.gt("1e18")||o.eq(I))break}if(o.gt("1e18")||!T||C==N(1,10,1))break;e==1?r=C:e==3&&(i=C),e++}a=r,o=N(1,1,-18);let A=o,n=s.dZero,h=!0;for(;h;)if(a.eq(N(1,10,1))?n=o.mul(2):n=a.add(o).div(2),s.pow(10,n).recip().tetrate(t,1,!0).gt(this)?o=n:a=n,n.eq(A)?h=!1:A=n,o.gt("1e18"))return s.dNaN;if(n.eq_tolerance(r,1e-15)){if(i.eq(N(1,10,1)))return s.dNaN;for(a=N(1,10,1),o=i,A=o,n=s.dZero,h=!0;h;)if(a.eq(N(1,10,1))?n=o.mul(2):n=a.add(o).div(2),s.pow(10,n).recip().tetrate(t,1,!0).gt(this)?o=n:a=n,n.eq(A)?h=!1:A=n,o.gt("1e18"))return s.dNaN;return n.pow10().recip()}else return n.pow10().recip()}}pentate(t=2,e=w(1,0,1),r=!1){e=l(e);let i=t;t=Math.trunc(t);let a=i-t;a!==0&&(e.eq(s.dOne)?(++t,e=s.fromNumber(a)):this.eq(10)?e=e.layeradd10(a,r):e=e.layeradd(a,this,r));for(let o=0;o10)return e}return e}sin(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.sin(this.sign*this.mag)):w(0,0,0)}cos(){return this.mag<0?s.dOne:this.layer===0?s.fromNumber(Math.cos(this.sign*this.mag)):w(0,0,0)}tan(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.tan(this.sign*this.mag)):w(0,0,0)}asin(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.asin(this.sign*this.mag)):w(Number.NaN,Number.NaN,Number.NaN)}acos(){return this.mag<0?s.fromNumber(Math.acos(this.toNumber())):this.layer===0?s.fromNumber(Math.acos(this.sign*this.mag)):w(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?this:this.layer===0?s.fromNumber(Math.atan(this.sign*this.mag)):s.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 s.ln(this.add(this.sqr().add(1).sqrt()))}acosh(){return s.ln(this.add(this.sqr().sub(1).sqrt()))}atanh(){return this.abs().gte(1)?w(Number.NaN,Number.NaN,Number.NaN):s.ln(this.add(1).div(s.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?this:this.root(s.pow(10,t))}egg(){return this.add(9)}lessThanOrEqualTo(t){return this.cmp(t)<1}lessThan(t){return this.cmp(t)<0}greaterThanOrEqualTo(t){return this.cmp(t)>-1}greaterThan(t){return this.cmp(t)>0}static smoothDamp(t,e,r,i){return new s(t).add(new s(e).minus(new s(t)).times(new s(r)).times(new s(i)))}clone(){return this}static clone(t){return s.fromComponents(t.sign,t.layer,t.mag)}softcap(t,e,r){let i=this.clone();return i.gte(t)&&([0,"pow"].includes(r)&&(i=i.div(t).pow(e).mul(t)),[1,"mul"].includes(r)&&(i=i.sub(t).div(e).add(t))),i}static softcap(t,e,r,i){return new s(t).softcap(e,r,i)}scale(t,e,r,i=!1){t=new s(t),e=new s(e);let a=this.clone();return a.gte(t)&&([0,"pow"].includes(r)&&(a=i?a.mul(t.pow(e.sub(1))).root(e):a.pow(e).div(t.pow(e.sub(1)))),[1,"exp"].includes(r)&&(a=i?a.div(t).max(1).log(e).add(t):s.pow(e,a.sub(t)).mul(t))),a}static scale(t,e,r,i,a=!1){return new s(t).scale(e,r,i,a)}format(t=2,e=9,r="mixed_sc"){return z.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return z.format(new s(t),e,r,i)}formatST(t=2,e=9,r="st"){return z.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return z.format(new s(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return z.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,a){return z.formatGain(new s(t),e,r,i,a)}toRoman(t=5e3){t=new s(t);let e=this.clone();if(e.gte(t)||e.lt(1))return e;let r=e.toNumber(),i={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1},a="";for(let o of Object.keys(i)){let m=Math.floor(r/i[o]);r-=m*i[o],a+=o.repeat(m)}return a}static toRoman(t,e){return new s(t).toRoman(e)}static random(t=0,e=1){return t=new s(t),e=new s(e),t=t.lt(e)?t:e,e=e.gt(t)?e:t,new s(Math.random()).mul(e.sub(t)).add(t)}static randomProb(t){return new s(Math.random()).lt(t)}};s.dZero=w(0,0,0),s.dOne=w(1,0,1),s.dNegOne=w(-1,0,1),s.dTwo=w(1,0,2),s.dTen=w(1,0,10),s.dNaN=w(Number.NaN,Number.NaN,Number.NaN),s.dInf=w(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNegInf=w(-1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),s.dNumberMax=N(1,0,Number.MAX_VALUE),s.dNumberMin=N(1,0,Number.MIN_VALUE),s.fromStringCache=new dt(St),W([D()],s.prototype,"sign",2),W([D()],s.prototype,"mag",2),W([D()],s.prototype,"layer",2),s=W([ct()],s);var{formats:z,FORMATS:$t}=Nt(s);s.formats=z;var U=(()=>{let t=e=>new s(e);return Object.getOwnPropertyNames(s).filter(e=>!Object.getOwnPropertyNames(class{}).includes(e)).forEach(e=>{t[e]=s[e]}),t})();function K(t,e){e=Object.assign({formatType:"mixed_sc",acc:2,max:9},e);let{formatType:r,acc:i,max:a,time:o,multi:m,formatTimeType:c}=e;if(o)switch(c){case"short":return U.formats.formatTime(t,i,r);case"long":return U.formats.formatTimeLong(t,!0,0,a,r)}return m?U.formats.formatMult(t,i):U.format(t,i,a,r)}function ht(t,e,r){let{formatType:i,acc:a,max:o}=r;return U.formatGain(t,e,i,a,o)}var Ct=class{constructor(t){this.format=e=>K(e,this.settings),this.gain=(e,r)=>ht(e,r,this.settings),this.time=e=>K(e,{...this.settings,time:!0}),this.multi=e=>K(e,{...this.settings,multi:!0}),this.settingsFn=typeof t=="function"?t:()=>t}get settings(){return this.settingsFn()}},qt=[{name:"Standard",value:"standard"},{name:"Scientific",value:"scientific"},{name:"Mixed Scientific (default)",value:"mixed_sc"},{name:"Old Scientific",value:"old_sc"},{name:"Engineering",value:"eng"},{name:"Infinity",value:"inf"},{name:"Omega",value:"omega"},{name:"Omega Short",value:"omega_short"},{name:"Elemental",value:"elemental"},{name:"Layer",value:"layer"}].sort((t,e)=>t.name.localeCompare(e.name)),Pt=[{name:"Short (default)",value:"short"},{name:"Long",value:"long"}].sort((t,e)=>t.name.localeCompare(e.name));if(typeof G.exports=="object"&&typeof j=="object"){var xt=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Object.getOwnPropertyNames(e))!Object.prototype.hasOwnProperty.call(t,a)&&a!==r&&Object.defineProperty(t,a,{get:()=>e[a],enumerable:!(i=Object.getOwnPropertyDescriptor(e,a))||i.enumerable});return t};G.exports=xt(G.exports,j)}return G.exports}); diff --git a/dist/presets/eMath.presets.mjs b/dist/presets/eMath.presets.mjs index fb689f6c..bcefbb6a 100644 --- a/dist/presets/eMath.presets.mjs +++ b/dist/presets/eMath.presets.mjs @@ -701,7 +701,7 @@ function decimalFormatGenerator(Decimal2) { default: if (!FORMATS2[type]) console.error(`Invalid format type "`, type, `"`); - return neg + FORMATS2[type]?.format(ex, acc, max); + return neg + FORMATS2[type].format(ex, acc, max); } } function formatGain(amt, gain, type = "mixed_sc", acc, max) { @@ -831,7 +831,7 @@ function decimalFormatGenerator(Decimal2) { output = abbMax["name"]; break; case 2: - output = `${num.divide(abbMax["value"]).format()}`; + output = num.divide(abbMax["value"]).format(); break; case 3: output = abbMax["altName"]; diff --git a/dist/types/E/e.d.ts b/dist/types/E/e.d.ts index 258cb8a8..cf5ae299 100644 --- a/dist/types/E/e.d.ts +++ b/dist/types/E/e.d.ts @@ -644,13 +644,13 @@ declare class Decimal { * * Note: this function mutates the Decimal it is called on. */ - fromString(value: string, linearhyper4?: boolean): Decimal; + fromString(value: string, linearhyper4?: boolean): this; /** * The function used by new Decimal() to create a new Decimal. Accepts a DecimalSource: uses fromNumber if given a number, uses fromString if given a string, and uses fromDecimal if given a Decimal. * * Note: this function mutates the Decimal it is called on. */ - fromValue(value: DecimalSource): Decimal; + fromValue(value: DecimalSource): this; /** * Returns the numeric value of the Decimal it's called on. Will return Infinity (or -Infinity for negatives) for Decimals that are larger than Number.MAX_VALUE. */ @@ -1191,7 +1191,7 @@ declare class Decimal { * @deprecated * @returns A EClone instance that is a clone of the original. */ - clone(): Decimal; + clone(): this; /** * Creates a clone of the E instance. Helps with a webpack(?) bug * @alias Decimal.normalizeFromComponents @@ -1207,7 +1207,7 @@ declare class Decimal { * or "exp" for exponential soft cap. * @returns - The DecimalClone value after applying the soft cap. */ - softcap(start: DecimalSource, power: number, mode: string): Decimal; + softcap(start: DecimalSource, power: number, mode: string): this; static softcap(value: DecimalSource, start: DecimalSource, power: number, mode: string): Decimal; /** * Scales a currency value using a specified scaling function. @@ -1217,7 +1217,7 @@ declare class Decimal { * @param [rev] - Whether to reverse the scaling operation (unscaling). * @returns - The scaled currency value. */ - scale(s: DecimalSource, p: DecimalSource, mode: string | number, rev?: boolean): Decimal; + scale(s: DecimalSource, p: DecimalSource, mode: string | number, rev?: boolean): this; static scale(value: DecimalSource, s: DecimalSource, p: DecimalSource, mode: string | number, rev?: boolean): Decimal; /** * Formats the E instance with a specified accuracy and maximum decimal places. @@ -1298,7 +1298,8 @@ declare const formats: { formatTimeLong: (ex: DecimalSource, ms?: boolean, acc?: number, max?: number, type?: FormatType) => string; formatReduction: (ex: DecimalSource) => string; formatPercent: (ex: DecimalSource) => string; - formatMult: (ex: DecimalSource, acc?: number) => string; /** + formatMult: (ex: DecimalSource, acc?: number) => string; + /** * Returns true if 'value' is greater than or equal to 'other'. * However, the two Decimals are considered equal if they're approximately equal up to a certain tolerance. * Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments. diff --git a/dist/types/classes/Currency.d.ts b/dist/types/classes/Currency.d.ts index 4f9a14ac..a19612c0 100644 --- a/dist/types/classes/Currency.d.ts +++ b/dist/types/classes/Currency.d.ts @@ -16,7 +16,7 @@ declare class Currency { /** The current value of the currency. */ value: E; /** An array that represents upgrades and their levels. */ - upgrades: Record>; + upgrades: Record; /** * Constructs a new currency object with an initial value of 0. */ @@ -129,7 +129,7 @@ declare class CurrencyStatic { * } * }); */ - addUpgrade(upgrades: UpgradeInit | UpgradeInit[], runEffectInstantly?: boolean): UpgradeStatic[]; + addUpgrade(upgrades: UpgradeInit | UpgradeInit[], runEffectInstantly?: boolean): UpgradeStatic[]; /** * Updates an upgrade. To create an upgrade, use {@link addUpgrade} instead. * @param id - The id of the upgrade to update. @@ -144,7 +144,7 @@ declare class CurrencyStatic { * } * }); */ - updateUpgrade(id: string, upgrade: UpgradeInit): void; + updateUpgrade(id: string, upgrade: Partial): void; /** * Calculates the cost and how many upgrades you can buy. * See {@link calculateUpgrade} for more information. diff --git a/dist/types/classes/Upgrade.d.ts b/dist/types/classes/Upgrade.d.ts index 5c71daac..bebbc573 100644 --- a/dist/types/classes/Upgrade.d.ts +++ b/dist/types/classes/Upgrade.d.ts @@ -20,7 +20,7 @@ import { MeanMode } from "./numericalAnalysis"; * @param el - ie Endless: Flag to exclude the sum calculation and only perform binary search. (DEPRECATED, use `el` in the upgrade object instead) * @returns [amount, cost] - Returns the amount of upgrades you can buy and the cost of the upgrades. If you can't afford any, it returns [E(0), E(0)]. */ -declare function calculateUpgrade(value: ESource, upgrade: UpgradeStatic, start?: ESource, end?: ESource, mode?: MeanMode, iterations?: number, el?: boolean): [amount: E, cost: E]; +declare function calculateUpgrade(value: ESource, upgrade: UpgradeStatic, start?: ESource, end?: ESource, mode?: MeanMode, iterations?: number, el?: boolean): [amount: E, cost: E]; /** * Interface for initializing an upgrade. * @template N - The ID of the upgrade. @@ -68,8 +68,8 @@ interface UpgradeInit { * EL is automatically applied to the cost. * WARNING: In v8.x.x and above, the return order is [amount, cost] instead of [cost, amount]. * @param level - The current level of the upgrade. - * @param target - The target level of the upgrade. - * @returns [cost, amount] - The cost of the upgrades and the amount of upgrades you can buy. If you can't afford any, it returns [E(0), E(0)]. + * @param target - The target level of the upgrade. If you want to buy the maximum amount of upgrades possible, this will be `Infinity`. + * @returns [amount, cost] - The cost of the upgrades and the amount of upgrades you can buy. If you can't afford any, it returns [E(0), E(0)]. * @example * // A cost function that returns the sum of the levels and the target. * // In this example, the cost function is twice the level. The cost bulk function is the sum of the levels and the target. @@ -166,7 +166,7 @@ interface UpgradeCachedEL extends UpgradeCached, Pick { +interface UpgradeCachedSum extends UpgradeCached { start: E; end: E; /** diff --git a/dist/types/classes/numericalAnalysis.d.ts b/dist/types/classes/numericalAnalysis.d.ts index a83e5883..b5a68b44 100644 --- a/dist/types/classes/numericalAnalysis.d.ts +++ b/dist/types/classes/numericalAnalysis.d.ts @@ -36,9 +36,9 @@ type MeanMode = "arithmetic" | "geometric" | 1 | 2; * console.log(inverse.value); // ~3.9999999999999996 */ declare function inverseFunctionApprox(f: (x: E) => E, n: ESource, mode?: MeanMode, iterations?: number): { - value: import("../E/e").Decimal; - lowerBound: import("../E/e").Decimal; - upperBound: import("../E/e").Decimal; + value: E; + lowerBound: E; + upperBound: E; }; /** * Calculates the sum of `f(n)` from `a` to `b` using a basic loop until the sum is less than or equal to `epsilon` geometrically. @@ -87,5 +87,5 @@ declare function calculateSum(f: (n: E) => E, b: ESource, a?: ESource, epsilon?: * console.log(roundingBase(123456789, 10, 2, 10)); // 123460000 * console.log(roundingBase(245, 2, 0, 10)); // 256 */ -declare function roundingBase(x: ESource, acc?: ESource, sig?: ESource, max?: ESource): import("../E/e").Decimal; +declare function roundingBase(x: ESource, acc?: ESource, sig?: ESource, max?: ESource): E; export { inverseFunctionApprox, calculateSumLoop, calculateSumApprox, calculateSum, roundingBase, MeanMode, DEFAULT_ITERATIONS }; diff --git a/dist/types/game/Game.d.ts b/dist/types/game/Game.d.ts index b1baec2c..d25ae066 100644 --- a/dist/types/game/Game.d.ts +++ b/dist/types/game/Game.d.ts @@ -110,6 +110,6 @@ declare class Game { * @param extender - An optional object to extend the game reset object with. * @returns The newly created game reset object. */ - addReset(currenciesToReset: GameCurrency | GameCurrency[], extender?: GameReset): GameReset; + addReset(currenciesToReset: GameCurrency | GameCurrency[], extender?: GameReset): GameReset; } export { Game, GameConfigOptions, gameDefaultConfig, Pointer }; diff --git a/dist/types/game/ResetLayer.d.ts b/dist/types/game/ResetLayer.d.ts index 8394873c..93f2abc9 100644 --- a/dist/types/game/ResetLayer.d.ts +++ b/dist/types/game/ResetLayer.d.ts @@ -9,7 +9,7 @@ declare class GameReset { /** The unique identifier for the game reset to prevent infinite loops. */ private readonly id; /** The currencies to reset. */ - readonly currenciesToReset: GameCurrency[]; + readonly currenciesToReset: GameCurrency[]; /** The extender for the game reset. */ readonly extender: GameReset[]; /** Custom code to run after {@link reset} is called but BEFORE the currencies are reset */ @@ -19,7 +19,7 @@ declare class GameReset { * @param currenciesToReset The currencies to reset. * @param extender The extender for the game reset. WARNING: Do not set this to the same object, as it will cause an infinite loop. */ - constructor(currenciesToReset: GameCurrency | GameCurrency[], extender?: GameReset | GameReset[]); + constructor(currenciesToReset: GameCurrency | GameCurrency[], extender?: GameReset | GameReset[]); /** * Resets a currency to its default value, and runs the extender's reset function if it exists (recursively). */ diff --git a/dist/types/game/managers/DataManager.d.ts b/dist/types/game/managers/DataManager.d.ts index dba5dac4..0434ae1c 100644 --- a/dist/types/game/managers/DataManager.d.ts +++ b/dist/types/game/managers/DataManager.d.ts @@ -85,7 +85,7 @@ declare class DataManager { * @param key - The key to get the data for. * @returns The data for the given key. */ - getData(key: string): unknown | undefined; + getData(key: string): unknown; /** * Sets the static data for the given key. * This data is not affected by data loading and saving, and is mainly used internally. @@ -100,7 +100,7 @@ declare class DataManager { * @param key - The key to get the static data for. * @returns The static data for the given key. */ - getStatic(key: string): unknown | undefined; + getStatic(key: string): unknown; /** * Initializes / sets data that is unmodified by the player. * This is used to merge the loaded data with the default data. diff --git a/dist/types/pixiGame/Sprite.d.ts b/dist/types/pixiGame/Sprite.d.ts index 11071421..d0f54b72 100644 --- a/dist/types/pixiGame/Sprite.d.ts +++ b/dist/types/pixiGame/Sprite.d.ts @@ -5,10 +5,10 @@ * created from a PIXI.Sprite. It provides functionality for managing sprite properties, collision * detection, and rendering offset by the camera. */ -import { Shape, Rectangle, Polygon, Circle } from "./pixi-intersects.js"; +import Intersects, { Shape, Rectangle, Polygon, Circle } from "./pixi-intersects.js"; import type { PixiGame } from "./PixiGame.js"; import type { Sprite, Graphics } from "pixi.js"; -type CollisionShapeType = "Circle" | "Polygon" | "Rectangle" | "Line"; +type CollisionShapeType = Exclude; /** * Represents a game sprite */ @@ -34,6 +34,9 @@ declare class GameSprite { * Allowed values: "Circle", "Polygon", "Rectangle", "Shape", "Line". */ constructor(gameRef: PixiGame, spr: Sprite | Graphics, collisionShape?: CollisionShapeType); + /** + * The ticker function for the sprite, used to offset the sprite by the camera. + */ private tickerFn; /** * Checks if this sprite collides with another sprite. diff --git a/package.json b/package.json index 5d05cce6..09af8d04 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,8 @@ "build:main:watch": "node bin/build/build.js", "build:types": "tsc --emitDeclarationOnly -outdir dist/types", "doc": "typedoc --options typedoc.config.json", - "lint": "eslint src/**/*.ts test/**/*.ts", - "lint:fix": "eslint --fix src/**/*.ts test/**/*.ts", + "lint": "eslint src/**/*.ts", + "lint:fix": "eslint --fix src/**/*.ts", "test": "cd test && npm run test && cd ..", "build-and-test": "node bin/build/build.js && cd test && npm run test && cd ..", "build-and-build-and-test": "echo \"worst script name\" && concurrently \"node bin/build/build.js\" \"cd test && npm run build && cd ..\" && cd test && npm run test && cd .." diff --git a/src/E/e.ts b/src/E/e.ts index 955aacd8..e1a7b350 100644 --- a/src/E/e.ts +++ b/src/E/e.ts @@ -1753,7 +1753,7 @@ class Decimal { * * Note: this function mutates the Decimal it is called on. */ - public fromString (value: string, linearhyper4: boolean = false): Decimal { + public fromString (value: string, linearhyper4: boolean = false): this { const originalValue = value; const cached = Decimal.fromStringCache.get(originalValue); if (cached !== undefined) { @@ -2032,7 +2032,7 @@ class Decimal { * * Note: this function mutates the Decimal it is called on. */ - public fromValue (value: DecimalSource): Decimal { + public fromValue (value: DecimalSource): this { if (value instanceof Decimal) { return this.fromDecimal(value); } @@ -4227,7 +4227,7 @@ class Decimal { * @deprecated * @returns A EClone instance that is a clone of the original. */ - public clone (): Decimal { + public clone (): this { return this; } @@ -4249,11 +4249,11 @@ class Decimal { * or "exp" for exponential soft cap. * @returns - The DecimalClone value after applying the soft cap. */ - public softcap (start: DecimalSource, power: number, mode: string): Decimal { + public softcap (start: DecimalSource, power: number, mode: string): this { let x = this.clone(); if (x.gte(start)) { - if ([0, "pow"].includes(mode)) x = x.div(start).pow(power).mul(start); - if ([1, "mul"].includes(mode)) x = x.sub(start).div(power).add(start); + if ([0, "pow"].includes(mode)) (x as Decimal) = x.div(start).pow(power).mul(start); + if ([1, "mul"].includes(mode)) (x as Decimal) = x.sub(start).div(power).add(start); // if ([2, "exp"].includes(mode)) x = expMult(x.div(start), power).mul(start); } return x; @@ -4270,15 +4270,15 @@ class Decimal { * @param [rev] - Whether to reverse the scaling operation (unscaling). * @returns - The scaled currency value. */ - public scale (s: DecimalSource, p: DecimalSource, mode: string | number, rev: boolean = false): Decimal { + public scale (s: DecimalSource, p: DecimalSource, mode: string | number, rev: boolean = false): this { s = new Decimal(s); p = new Decimal(p); let x = this.clone(); if (x.gte(s)) { - if ([0, "pow"].includes(mode)) {x = rev ? + if ([0, "pow"].includes(mode)) {(x as Decimal) = rev ? x.mul(s.pow(p.sub(1))).root(p) : // (x * s^(p - 1))^(1 / p) x.pow(p).div(s.pow(p.sub(1)));} // x^p / s^(p - 1) - if ([1, "exp"].includes(mode)) {x = rev ? + if ([1, "exp"].includes(mode)) {(x as Decimal) = rev ? x.div(s).max(1).log(p).add(s) : // log_p((x / s).max(1)) + s Decimal.pow(p, x.sub(s)).mul(s);} // p^(x - s) * s } diff --git a/src/E/eMain.ts b/src/E/eMain.ts index aee7a4b7..2939a850 100644 --- a/src/E/eMain.ts +++ b/src/E/eMain.ts @@ -17,7 +17,7 @@ const E: ((x?: DecimalSource) => Decimal) & typeof Decimal = (() => { const out = (x?: DecimalSource) => new Decimal(x); // Copy properties from Decimal to E - (Object.getOwnPropertyNames(Decimal).filter((b) => !Object.getOwnPropertyNames(class {}).includes(b)) as string[]).forEach((prop) => { + (Object.getOwnPropertyNames(Decimal).filter((b) => !Object.getOwnPropertyNames(class {}).includes(b))).forEach((prop) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any (out as any)[prop] = (Decimal as any)[prop]; }); diff --git a/src/E/format.ts b/src/E/format.ts index d2ce32b2..a8350a0d 100644 --- a/src/E/format.ts +++ b/src/E/format.ts @@ -568,7 +568,7 @@ function decimalFormatGenerator (Decimal: typeof DecimalType) { default: // Other formats if (!FORMATS[type]) console.error(`Invalid format type "`, type, `"`); - return neg + FORMATS[type]?.format(ex, acc, max); + return neg + FORMATS[type].format(ex, acc, max); } } @@ -775,7 +775,7 @@ function decimalFormatGenerator (Decimal: typeof DecimalType) { output = abbMax["name"]; break; case 2: - output = `${num.divide(abbMax["value"]).format()}`; + output = num.divide(abbMax["value"]).format(); break; case 3: output = abbMax["altName"]; diff --git a/src/E/new/eMain.ts b/src/E/new/eMain.ts index 06f45333..e0490006 100644 --- a/src/E/new/eMain.ts +++ b/src/E/new/eMain.ts @@ -174,7 +174,7 @@ const DecimalAddedMethods: DecimalAddedMethodsInterface = { function addMethods (obj: Record, methods: Record): void { for (const key in methods) { // (obj as any)[key] = (methods[key as keyof typeof methods] as (...args: any[]) => any).bind(obj); - (obj as any)[key] = methods[key as keyof typeof methods]; + (obj as any)[key] = methods[key]; } } addMethods(Decimal.prototype, DecimalAddedMethods); @@ -346,7 +346,7 @@ const E: ((x?: DecimalSource) => Decimal) & typeof Decimal & typeof DecimalAdded const out = (x?: DecimalSource) => new Decimal(x); // Copy properties from Decimal to E - (Object.getOwnPropertyNames(Decimal).filter((b) => ![...Object.getOwnPropertyNames(class {}), "arguments", "caller", "callee"].includes(b)) as string[]).forEach((prop) => { + (Object.getOwnPropertyNames(Decimal).filter((b) => ![...Object.getOwnPropertyNames(class {}), "arguments", "caller", "callee"].includes(b))).forEach((prop) => { // console.log(prop); // eslint-disable-next-line @typescript-eslint/no-explicit-any (out as any)[prop] = (Decimal as any)[prop]; diff --git a/src/classes/Attribute.ts b/src/classes/Attribute.ts index 0eee5831..547ba476 100644 --- a/src/classes/Attribute.ts +++ b/src/classes/Attribute.ts @@ -43,7 +43,7 @@ class AttributeStatic { protected readonly pointerFn: (() => Attribute); /** @returns The data for the attribute. */ - public get pointer () { + public get pointer (): Attribute { return this.pointerFn(); } @@ -65,7 +65,7 @@ class AttributeStatic { constructor (pointer?: Pointer, useBoost: B = true as B, initial: ESource = 0) { this.initial = E(initial); pointer ??= new Attribute(this.initial); - this.pointerFn = (typeof pointer === "function" ? pointer : () => pointer); + this.pointerFn = (typeof pointer === "function" ? pointer : (): Attribute => pointer); this.boost = (useBoost ? new Boost(this.initial) : null) as typeof this.boost; } diff --git a/src/classes/Boost.ts b/src/classes/Boost.ts index f741876c..75e5ad25 100644 --- a/src/classes/Boost.ts +++ b/src/classes/Boost.ts @@ -75,7 +75,7 @@ class BoostObject implements BoostsObjectInit { this.id = init.id; this.name = init.name ?? ""; // this.desc = init.desc ?? ""; - this.descriptionFn = init.description ? (typeof init.description === "function" ? init.description : () => init.description as string) : () => ""; + this.descriptionFn = init.description ? (typeof init.description === "function" ? init.description : (): string => init.description as string) : (): string => ""; // this.descriptionFn = init.description || init.desc ? // (init.description ? (typeof init.description === "function" ? init.description : () => init.description as string) : ( // init.desc ? (typeof init.desc === "function" ? init.desc : () => init.desc as string) : () => "" @@ -205,7 +205,7 @@ class Boost { const id = arg1; const name = arg2 ?? ""; const description = arg3 ?? ""; - const value = arg4 ?? ((e) => e); + const value = arg4 ?? ((e): E => e); const order = arg5; const bCheck = this.getBoosts(id, true); @@ -232,7 +232,7 @@ class Boost { * @alias setBoost * @deprecated Use {@link setBoost} instead. */ - public addBoost = this.setBoost; + public addBoost = this.setBoost.bind(this); /** * Calculates the cumulative effect of all boosts on the base effect. diff --git a/src/classes/Currency.ts b/src/classes/Currency.ts index 2ad83b5f..882aaf5f 100644 --- a/src/classes/Currency.ts +++ b/src/classes/Currency.ts @@ -22,7 +22,7 @@ class Currency { /** An array that represents upgrades and their levels. */ @Type(() => UpgradeData) - public upgrades: Record>; + public upgrades: Record; // public upgrades: UpgradeData[]; // /** A boost object that affects the currency gain. */ @@ -62,7 +62,9 @@ class CurrencyStatic { protected readonly pointerFn: (() => Currency); /** @returns The pointer of the data. */ - protected get pointer () { return this.pointerFn(); } + protected get pointer (): Currency { + return this.pointerFn(); + } /** A boost object that affects the currency gain. */ public readonly boost: Boost; @@ -96,7 +98,7 @@ class CurrencyStatic { this.defaultVal = defaults.defaultVal; this.defaultBoost = defaults.defaultBoost; - this.pointerFn = typeof pointer === "function" ? pointer : () => pointer; + this.pointerFn = typeof pointer === "function" ? pointer : (): Currency => pointer; this.boost = new Boost(this.defaultBoost); // this.upgradeCache = new LRUCache(CurrencyStatic.cacheSize); @@ -114,13 +116,13 @@ class CurrencyStatic { if (upgrades) this.addUpgrade(upgrades); - this.upgrades = this.upgrades as Record>; + // this.upgrades = this.upgrades; } /** * Updates / applies effects to the currency on load. */ - public onLoadData () { + public onLoadData (): void { for (const upgrade of Object.values(this.upgrades)) { upgrade.effect?.(upgrade.level, upgrade); } @@ -178,7 +180,7 @@ class CurrencyStatic { * @param id - The id of the upgrade to retrieve. * @returns The upgrade object if found, otherwise null. */ - private pointerGetUpgrade (id: string): UpgradeData | null { + private pointerGetUpgrade (id: string): UpgradeData | null { // console.log("pointerGet", { id, upgrades: this.pointer }); return this.pointer.upgrades[id] ?? null; } @@ -222,19 +224,19 @@ class CurrencyStatic { * } * }); */ - public addUpgrade (upgrades: UpgradeInit | UpgradeInit[], runEffectInstantly: boolean = true): UpgradeStatic[] { + public addUpgrade (upgrades: UpgradeInit | UpgradeInit[], runEffectInstantly: boolean = true): UpgradeStatic[] { if (!Array.isArray(upgrades)) upgrades = [upgrades]; // console.log({ upgrades }); // Adds standard (object instead of array) - const addedUpgradeList: Record> = {}; + const addedUpgradeList: Record = {}; for (const upgrade of upgrades) { // console.log(upgrade.id); const addedUpgradeData = this.pointerAddUpgrade(upgrade); // const addedUpgradeStatic = new UpgradeStatic(upgrade, () => addedUpgradeData); - const addedUpgradeStatic = new UpgradeStatic(upgrade, () => this.pointerGetUpgrade(upgrade.id)!); + const addedUpgradeStatic = new UpgradeStatic(upgrade, () => this.pointerGetUpgrade(upgrade.id) as UpgradeData); if (addedUpgradeStatic.effect && runEffectInstantly) addedUpgradeStatic.effect(addedUpgradeStatic.level, addedUpgradeStatic); addedUpgradeList[upgrade.id] = addedUpgradeStatic; @@ -261,7 +263,7 @@ class CurrencyStatic { * } * }); */ - public updateUpgrade (id: string, upgrade: UpgradeInit): void { + public updateUpgrade (id: string, upgrade: Partial): void { const upgrade1 = this.getUpgrade(id); if (upgrade1 === null) return; diff --git a/src/classes/Upgrade.ts b/src/classes/Upgrade.ts index a0e923c3..ffdf982c 100644 --- a/src/classes/Upgrade.ts +++ b/src/classes/Upgrade.ts @@ -22,7 +22,7 @@ import { MeanMode, inverseFunctionApprox, calculateSum } from "./numericalAnalys * @param el - ie Endless: Flag to exclude the sum calculation and only perform binary search. (DEPRECATED, use `el` in the upgrade object instead) * @returns [amount, cost] - Returns the amount of upgrades you can buy and the cost of the upgrades. If you can't afford any, it returns [E(0), E(0)]. */ -function calculateUpgrade (value: ESource, upgrade: UpgradeStatic, start?: ESource, end?: ESource, mode?: MeanMode, iterations?: number, el: boolean = false): [amount: E, cost: E] { +function calculateUpgrade (value: ESource, upgrade: UpgradeStatic, start?: ESource, end?: ESource, mode?: MeanMode, iterations?: number, el: boolean = false): [amount: E, cost: E] { value = E(value); start = E(start ?? upgrade.level); end = E(end ?? Infinity); @@ -96,7 +96,7 @@ function calculateUpgrade (value: ESource, upgrade: UpgradeStatic, start // Special case for endless upgrades if (el) { // console.log("el"); - const costTargetFn = (level: E) => upgrade.cost(level.add(start!)); + const costTargetFn = (level: E): E => upgrade.cost(level.add(start)); const maxLevelAffordable = E.min(end, inverseFunctionApprox(costTargetFn, value, mode, iterations).value.floor()); // const cost = upgrade.cost(maxLevelAffordable); const cost = E(0); @@ -269,7 +269,7 @@ type UpgradeCachedSumName = `sum/${DecimalJSONString}/${DecimalJSONString}`; */ function decimalToJSONString (n: ESource): DecimalJSONString { n = E(n); - return `${n.sign}/${n.mag}/${n.layer}` as DecimalJSONString; + return `${n.sign}/${n.mag}/${n.layer}`; } /** @@ -292,7 +292,7 @@ function upgradeToCacheNameSum (start: ESource, end: ESource): UpgradeCachedSumN */ function upgradeToCacheNameEL (level: ESource): UpgradeCachedELName { // return `${upgrade.id}/el/${level.toString()}` as UpgradeCachedELName; - return `el/${decimalToJSONString(level)}` as UpgradeCachedELName; + return `el/${decimalToJSONString(level)}`; } /** @@ -312,7 +312,7 @@ interface UpgradeCachedEL extends UpgradeCached, Pick { +interface UpgradeCachedSum extends UpgradeCached { start: E; end: E; @@ -335,6 +335,7 @@ class UpgradeData implements IUpgradeData { * @param init - The upgrade object to initialize. */ constructor (init: Pick, "id" | "level">) { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition init = init ?? {}; // class-transformer bug this.id = init.id; this.level = init.level ? E(init.level) : E(1); @@ -372,6 +373,7 @@ class UpgradeStatic implements IUpgradeStatic { */ get level (): E { // many fallbacks for some reason + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition return ((this ?? { data: { level: E(1) } }).data ?? { level: E(1) }).level; } set level (n: ESource) { @@ -386,11 +388,11 @@ class UpgradeStatic implements IUpgradeStatic { */ constructor (init: UpgradeInit, dataPointer: Pointer>, cacheSize?: number) { const data = (typeof dataPointer === "function" ? dataPointer() : dataPointer); - this.dataPointerFn = typeof dataPointer === "function" ? dataPointer : () => data; + this.dataPointerFn = typeof dataPointer === "function" ? dataPointer : (): UpgradeData => data; this.cache = new LRUCache(cacheSize ?? UpgradeStatic.cacheSize); this.id = init.id; this.name = init.name ?? init.id; - this.descriptionFn = init.description ? (typeof init.description === "function" ? init.description : () => init.description as string) : () => ""; + this.descriptionFn = init.description ? (typeof init.description === "function" ? init.description : (): string => init.description as string) : (): string => ""; this.cost = init.cost; this.costBulk = init.costBulk; this.maxLevel = init.maxLevel; @@ -407,9 +409,9 @@ class UpgradeStatic implements IUpgradeStatic { */ public getCached (type: "sum", start: ESource, end: ESource): UpgradeCachedSum | undefined; public getCached (type: "el", start: ESource): UpgradeCachedEL | undefined; - public getCached (type: "sum" | "el", start: ESource, end?: ESource) { + public getCached (type: "sum" | "el", start: ESource, end?: ESource): UpgradeCachedEL | UpgradeCachedSum | undefined { if (type === "sum") { - return this.cache.get(upgradeToCacheNameSum(start, end!)); + return this.cache.get(upgradeToCacheNameSum(start, end ?? E(0))); } else { return this.cache.get(upgradeToCacheNameEL(start)); } @@ -424,7 +426,7 @@ class UpgradeStatic implements IUpgradeStatic { */ public setCached(type: "sum", start: ESource, end: ESource, cost: ESource): UpgradeCachedSum; public setCached(type: "el", level: ESource, cost: ESource): UpgradeCachedEL; - public setCached (type: "sum" | "el", start: ESource, endOrStart: ESource, costSum?: ESource) { + public setCached (type: "sum" | "el", start: ESource, endOrStart: ESource, costSum?: ESource): UpgradeCachedEL | UpgradeCachedSum { const data = type === "sum" ? { id: this.id, el: false, @@ -439,7 +441,7 @@ class UpgradeStatic implements IUpgradeStatic { }; if (type === "sum") { - this.cache.set(upgradeToCacheNameSum(start, endOrStart!), data as UpgradeCachedSum); + this.cache.set(upgradeToCacheNameSum(start, endOrStart), data as UpgradeCachedSum); } else { this.cache.set(upgradeToCacheNameEL(start), data as UpgradeCachedEL); } diff --git a/src/classes/numericalAnalysis.ts b/src/classes/numericalAnalysis.ts index 0546f30a..73340cec 100644 --- a/src/classes/numericalAnalysis.ts +++ b/src/classes/numericalAnalysis.ts @@ -38,7 +38,7 @@ type MeanMode = "arithmetic" | "geometric" | 1 | 2; * const inverse = inverseFunctionApprox(f, 16); * console.log(inverse.value); // ~3.9999999999999996 */ -function inverseFunctionApprox (f: (x: E) => E, n: ESource, mode: MeanMode = "geometric", iterations = DEFAULT_ITERATIONS) { +function inverseFunctionApprox (f: (x: E) => E, n: ESource, mode: MeanMode = "geometric", iterations = DEFAULT_ITERATIONS): { value: E; lowerBound: E; upperBound: E } { // Set the initial bounds let lowerBound = E(1); // let upperBound = E(n); @@ -195,7 +195,7 @@ function calculateSum (f: (n: E) => E, b: ESource, a: ESource = 0, epsilon?: ESo * console.log(roundingBase(123456789, 10, 2, 10)); // 123460000 * console.log(roundingBase(245, 2, 0, 10)); // 256 */ -function roundingBase (x: ESource, acc: ESource = 10, sig: ESource = 0, max: ESource = 1000) { +function roundingBase (x: ESource, acc: ESource = 10, sig: ESource = 0, max: ESource = 1000): E { x = E(x); // If the number is too large, don't round it if (x.gte(E.pow(acc, max))) return x; diff --git a/src/game/Game.ts b/src/game/Game.ts index 5ed07630..13d0dfc5 100644 --- a/src/game/Game.ts +++ b/src/game/Game.ts @@ -145,12 +145,12 @@ class Game { }); this.dataManager.setStatic(name, { // @ts-expect-error - fix this - currency: new CurrencyStatic(() => this.dataManager.getData(name).currency), + currency: new CurrencyStatic(() => this.dataManager.getData(name).currency as Currency), // attributes: {}, }); // @ts-expect-error - fix this - const classInstance = new GameCurrency(() => this.dataManager.getData(name).currency, () => this.dataManager.getStatic(name).currency, this, name); + const classInstance = new GameCurrency(() => this.dataManager.getData(name).currency as Currency, () => this.dataManager.getStatic(name).currency as Currency, this, name); // const dataRef = this.dataManager.setData(name, { @@ -193,7 +193,7 @@ class Game { * @param extender - An optional object to extend the game reset object with. * @returns The newly created game reset object. */ - public addReset (currenciesToReset: GameCurrency | GameCurrency[], extender?: GameReset): GameReset { + public addReset (currenciesToReset: GameCurrency | GameCurrency[], extender?: GameReset): GameReset { const reset = new GameReset(currenciesToReset, extender); return reset; } diff --git a/src/game/GameCurrency.ts b/src/game/GameCurrency.ts index fa8b6e38..a980c424 100644 --- a/src/game/GameCurrency.ts +++ b/src/game/GameCurrency.ts @@ -47,15 +47,15 @@ class GameCurrency { // this.data = typeof currencyPointer === "function" ? currencyPointer() : currencyPointer; // this.static = typeof staticPointer === "function" ? staticPointer() : staticPointer; - this.dataPointer = typeof currencyPointer === "function" ? currencyPointer : () => currencyPointer; - this.staticPointer = typeof staticPointer === "function" ? staticPointer : () => staticPointer; + this.dataPointer = typeof currencyPointer === "function" ? currencyPointer : (): Currency => currencyPointer; + this.staticPointer = typeof staticPointer === "function" ? staticPointer : (): CurrencyStatic => staticPointer; this.game = gamePointer; this.name = name; // Add an event on load to update upgrade effects - this.game?.dataManager.addEventOnLoad(() => { + this.game.dataManager.addEventOnLoad(() => { this.static.onLoadData(); }); } diff --git a/src/game/ResetLayer.ts b/src/game/ResetLayer.ts index 4129fcdc..c798c6c9 100644 --- a/src/game/ResetLayer.ts +++ b/src/game/ResetLayer.ts @@ -13,7 +13,7 @@ class GameReset { private readonly id: symbol; /** The currencies to reset. */ - public readonly currenciesToReset: GameCurrency[]; + public readonly currenciesToReset: GameCurrency[]; /** The extender for the game reset. */ public readonly extender: GameReset[]; @@ -26,7 +26,7 @@ class GameReset { * @param currenciesToReset The currencies to reset. * @param extender The extender for the game reset. WARNING: Do not set this to the same object, as it will cause an infinite loop. */ - constructor (currenciesToReset: GameCurrency | GameCurrency[], extender?: GameReset | GameReset[]) { + constructor (currenciesToReset: GameCurrency | GameCurrency[], extender?: GameReset | GameReset[]) { this.currenciesToReset = Array.isArray(currenciesToReset) ? currenciesToReset : [currenciesToReset]; this.extender = Array.isArray(extender) ? extender : extender ? [extender] : []; this.id = Symbol(); @@ -44,7 +44,7 @@ class GameReset { // this.extender?.reset(); this.extender.forEach((extender) => { - if (extender && extender.id !== this.id) { + if (extender.id !== this.id) { extender.reset(); } }); diff --git a/src/game/managers/ConfigManager.ts b/src/game/managers/ConfigManager.ts index 7f72fce3..b39080fe 100644 --- a/src/game/managers/ConfigManager.ts +++ b/src/game/managers/ConfigManager.ts @@ -35,7 +35,7 @@ class ConfigManager { * @param template - The template to use for default values. * @returns A new object with default values for any missing options. */ - function parseObject (obj: UnknownObject, template: UnknownObject) { + function parseObject (obj: UnknownObject, template: UnknownObject): UnknownObject { for (const key in template) { if (typeof obj[key] === "undefined") { obj[key] = template[key]; diff --git a/src/game/managers/DataManager.ts b/src/game/managers/DataManager.ts index 6b2f3365..93977faa 100644 --- a/src/game/managers/DataManager.ts +++ b/src/game/managers/DataManager.ts @@ -115,7 +115,7 @@ class DataManager { console.warn("After initializing data, you should not add new properties to data."); } this.data[key] = value; - const thisData = () => this.data; + const thisData = (): UnknownObject => this.data; return { get value (): T { @@ -139,7 +139,7 @@ class DataManager { * @param key - The key to get the data for. * @returns The data for the given key. */ - public getData (key: string): unknown | undefined { + public getData (key: string): unknown { return this.data[key]; } @@ -164,7 +164,7 @@ class DataManager { * @param key - The key to get the static data for. * @returns The static data for the given key. */ - public getStatic (key: string): unknown | undefined { + public getStatic (key: string): unknown { return this.static[key]; } @@ -193,7 +193,7 @@ class DataManager { let version: string; try { // @ts-expect-error - Replaced by esbuild - version = PKG_VERSION; + version = PKG_VERSION as string; } catch (error) { version = "8.0.0"; } @@ -228,7 +228,7 @@ class DataManager { * @param data - The data to decompile. If not provided, it will be fetched from localStorage using the key `${game.config.name.id}-data`. * @returns The decompiled object, or null if the data is empty or invalid. */ - public decompileData (data: string | null = window?.localStorage.getItem(`${this.gameRef.config.name.id}-data`)): [SaveMetadata, UnknownObject] | null { + public decompileData (data: string | null = window.localStorage.getItem(`${this.gameRef.config.name.id}-data`)): [SaveMetadata, UnknownObject] | null { // If the data is empty, return null if (!data) return null; @@ -236,7 +236,7 @@ class DataManager { try { // Decompress the data - parsedData = JSON.parse(decompressFromBase64(data)); + parsedData = JSON.parse(decompressFromBase64(data)) as [SaveMetadata, UnknownObject]; return parsedData; } catch (error) { // If the data is corrupted, return null @@ -276,7 +276,7 @@ class DataManager { if (!this.normalData) throw new Error("dataManager.resetData(): You must call init() before writing to data."); this.data = this.normalData; this.saveData(); - if (reload) window?.location.reload(); + if (reload) window.location.reload(); }; /** @@ -286,6 +286,7 @@ class DataManager { */ public saveData (dataToSave = this.compileData()): void { if (!dataToSave) throw new Error("dataManager.saveData(): Data to save is empty."); + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!window.localStorage) throw new Error("dataManager.saveData(): Local storage is not supported. You can use compileData() instead to implement a custom save system."); window.localStorage.setItem(`${this.gameRef.config.name.id}-data`, dataToSave); }; @@ -322,7 +323,7 @@ class DataManager { */ public parseData (dataToParse = this.decompileData(), mergeData = true): UnknownObject | null { // If the normal data is not set, throw an error - if (mergeData && (!this.normalData || !this.normalDataPlain)) throw new Error("dataManager.parseData(): You must call init() before writing to data."); + if ((!this.normalData || !this.normalDataPlain) && mergeData) throw new Error("dataManager.parseData(): You must call init() before writing to data."); // If the data is empty, return null if (!dataToParse) return null; @@ -366,7 +367,8 @@ class DataManager { const upgrades = targetCurrency.upgrades; targetCurrency.upgrades = {}; for (const upgrade of upgrades) { - targetCurrency.upgrades[upgrade.id] = upgrade.level; + // ! warning: might not work + targetCurrency.upgrades[(upgrade as UpgradeData).id] = (upgrade as UpgradeData); } } @@ -381,7 +383,7 @@ class DataManager { return out; } - let loadedDataProcessed = !mergeData ? loadedData : deepMerge(this.normalDataPlain!, this.normalData!, loadedData); // TODO: Fix this + let loadedDataProcessed = !mergeData ? loadedData : deepMerge(this.normalDataPlain as UnknownObject, this.normalData as UnknownObject, loadedData); // TODO: Fix this // Convert plain object to class instance (recursive) @@ -395,20 +397,23 @@ class DataManager { */ function convertTemplateClass (templateClassToConvert: ClassType, plain: UnknownObject): ClassType { // Convert the object - const out = plainToInstance(templateClassToConvert, plain); + const out = plainToInstance(templateClassToConvert, plain) as ClassType; // Special case for Currency.upgrades if (out instanceof Currency) { for (const upgradeName in out.upgrades) { const upgrade = out.upgrades[upgradeName]; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!upgrade || !upgradeDataProperties.every((prop) => Object.getOwnPropertyNames(upgrade).includes(prop))) { // Delete the upgrade if it's invalid (extraneous properties, etc.) + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete delete out.upgrades[upgradeName]; continue; } out.upgrades[upgradeName] = plainToInstance(UpgradeData, upgrade); } } + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!out) throw new Error(`Failed to convert ${templateClassToConvert.name} to class instance.`); return out; } @@ -446,7 +451,7 @@ class DataManager { return out; } - loadedDataProcessed = plainToInstanceRecursive(this.normalData!, loadedDataProcessed); + loadedDataProcessed = plainToInstanceRecursive(this.normalData as UnknownObject, loadedDataProcessed); return loadedDataProcessed; } diff --git a/src/game/managers/EventManager.ts b/src/game/managers/EventManager.ts index 97dac8e2..2c729ba1 100644 --- a/src/game/managers/EventManager.ts +++ b/src/game/managers/EventManager.ts @@ -112,26 +112,31 @@ class EventManager { /** * The function that is called every frame, executes all events. */ - protected tickerFunction () { + protected tickerFunction (): void { const currentTime = Date.now(); for (const event of Object.values(this.events)) { // const event = this.events[i]; - if (event.type === "interval") { + + switch (event.type) { + case EventTypes.interval: { // If interval if (currentTime - (event as IntervalEvent).intervalLast >= event.delay) { const dt = currentTime - (event as IntervalEvent).intervalLast; event.callbackFn(dt); (event as IntervalEvent).intervalLast = currentTime; } - } else if (event.type === "timeout") { + }; break; + case EventTypes.timeout: { const dt = currentTime - event.timeCreated; // If timeout if (currentTime - event.timeCreated >= event.delay) { event.callbackFn(dt); + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete delete this.events[event.name]; // this.events.splice(i, 1); // i--; } + }; break; } } } @@ -158,12 +163,15 @@ class EventManager { */ public timeWarp (dt: number): void { for (const event of Object.values(this.events)) { - if (event.type === "interval") { + switch (event.type) { + case EventTypes.interval: { (event as IntervalEvent).intervalLast -= dt; - } - if (event.type === "timeout") { + }; break; + case EventTypes.timeout: { // ! might cause issues + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion (event as TimeoutEvent).timeCreated -= dt; + }; break; } } } @@ -186,8 +194,8 @@ class EventManager { * console.log("Timeout event executed."); * }); */ - public setEvent (name: string, type: EventTypes | "interval" | "timeout", delay: number | E, callbackFn: (dt: number) => void) { - this.events[name] = (() => { + public setEvent (name: string, type: EventTypes | "interval" | "timeout", delay: number | E, callbackFn: (dt: number) => void): void { + this.events[name] = ((): IntervalEvent | TimeoutEvent => { switch (type) { case "interval": { const event: IntervalEvent = { @@ -221,7 +229,7 @@ class EventManager { * @deprecated Use {@link EventManager.setEvent} instead. * @alias eventManager.setEvent */ - public addEvent = this.setEvent; + public addEvent = this.setEvent.bind(this); /** * Removes an event from the event system. @@ -229,7 +237,8 @@ class EventManager { * @example * myEventManger.removeEvent("IntervalEvent"); // Removes the interval event with the name "IntervalEvent". */ - public removeEvent (name: string) { + public removeEvent (name: string): void { + // eslint-disable-next-line @typescript-eslint/no-dynamic-delete delete this.events[name]; } }; diff --git a/src/game/managers/KeyManager.ts b/src/game/managers/KeyManager.ts index 2e9c1764..cd456eba 100644 --- a/src/game/managers/KeyManager.ts +++ b/src/game/managers/KeyManager.ts @@ -270,7 +270,7 @@ class KeyManager { } /** @deprecated Use {@link addKey} instead. */ - public addKeys = this.addKey; + public addKeys = this.addKey.bind(this); }; // keys.addKey("Debug - Reload", "`", () => window.location.reload()); diff --git a/src/pixiGame/Sprite.ts b/src/pixiGame/Sprite.ts index 126c9346..4c43a3c3 100644 --- a/src/pixiGame/Sprite.ts +++ b/src/pixiGame/Sprite.ts @@ -13,7 +13,7 @@ import Intersects, { Shape, Rectangle, Polygon, Circle } from "./pixi-intersects import type { PixiGame } from "./PixiGame.js"; import type { Sprite, Graphics } from "pixi.js"; -type CollisionShapeType = "Circle" | "Polygon" | "Rectangle" | "Line"; +type CollisionShapeType = Exclude; /** * Represents a game sprite @@ -51,9 +51,13 @@ class GameSprite { this.intersects = new Intersects[this.collisionShape](this.sprite); // Offset by camera - this.gameRef.PIXI.app.ticker.add(this.tickerFn, this); + this.gameRef.PIXI.app.ticker.add(this.tickerFn.bind(this), this); } - private tickerFn () { + + /** + * The ticker function for the sprite, used to offset the sprite by the camera. + */ + private tickerFn (): void { this.sprite.x = this.x - this.gameRef.PIXI.camera.x; this.sprite.y = this.y - this.gameRef.PIXI.camera.y; } diff --git a/src/pixiGame/hookPixiGame.ts b/src/pixiGame/hookPixiGame.ts index a1e2c08d..bac7873c 100644 --- a/src/pixiGame/hookPixiGame.ts +++ b/src/pixiGame/hookPixiGame.ts @@ -10,11 +10,11 @@ * Hooks the pixiGame package into the eMath.js game package. */ export function hookPixiGame () { - if (!(typeof process! !== "object" && typeof window! !== "undefined")) { + if (!(typeof process !== "object" && typeof window !== "undefined")) { // Environment is not a browser. return; } - if (typeof process! !== "undefined") { + if (typeof process !== "undefined") { // Environment is not a browser AND is not node. console.error("eMath.js/pixiGame is not supported in browser environments. \n This requirement might be removed in the future."); return; diff --git a/src/presets/GameFormats.ts b/src/presets/GameFormats.ts index 7b504044..370ea245 100644 --- a/src/presets/GameFormats.ts +++ b/src/presets/GameFormats.ts @@ -93,7 +93,7 @@ class GameFormatClass { } constructor (settings: Pointer) { // this.settings = settings; - this.settingsFn = typeof settings === "function" ? settings : () => settings; + this.settingsFn = typeof settings === "function" ? settings : (): FormatSettings => settings; } /** @@ -101,7 +101,7 @@ class GameFormatClass { * @param x - The value to format. * @returns The formatted value as a string. */ - public format = (x: ESource) => gameFormat(x, this.settings); + public format = (x: ESource): string => gameFormat(x, this.settings); /** * Formats the gain of a game format based on the provided settings. @@ -109,21 +109,21 @@ class GameFormatClass { * @param gain - The gain to apply. * @returns The formatted gain as a string. */ - public gain = (x: ESource, gain: ESource) => gameFormatGain(x, gain, this.settings); + public gain = (x: ESource, gain: ESource): string => gameFormatGain(x, gain, this.settings); /** * Formats a game value as a time based on the settings. * @param x - The value to format. * @returns The formatted value as a string. */ - public time = (x: ESource) => gameFormat(x, { ...this.settings, time: true }); + public time = (x: ESource): string => gameFormat(x, { ...this.settings, time: true }); /** * Formats a game value as a multiplier based on the settings. * @param x - The value to format. * @returns The formatted value as a string. */ - public multi = (x: ESource) => gameFormat(x, { ...this.settings, multi: true }); + public multi = (x: ESource): string => gameFormat(x, { ...this.settings, multi: true }); } /**