diff --git a/dist/game/eMath.game.js b/dist/game/eMath.game.js index 6335ca7..7abb426 100644 --- a/dist/game/eMath.game.js +++ b/dist/game/eMath.game.js @@ -6899,7 +6899,10 @@ var DataManager = class { constructor(gameRef) { /** The current game data. */ this.data = {}; - /** The static game data. */ + /** + * The static game data. + * @deprecated Static data is basically useless and should not be used. Use variables in local scope instead. + */ this.static = {}; /** A queue of functions to call when the game data is loaded. */ this.eventsOnLoad = []; @@ -6958,11 +6961,13 @@ var DataManager = class { /** * Sets the static data for the given key. * This data is not affected by data loading and saving, and is mainly used internally. + * @deprecated Static data is basically useless and should not be used. Use variables in local scope instead. * @param key - The key to set the static data for. * @param value - The value to set the static data to. * @returns A getter for the static data. */ setStatic(key, value) { + console.warn("setStatic: Static data is basically useless and should not be used. Use variables in local scope instead."); if (typeof this.static[key] === "undefined" && this.normalData) { console.warn("After initializing data, you should not add new properties to staticData."); } @@ -6971,11 +6976,12 @@ var DataManager = class { } /** * Gets the static data for the given key. - * @deprecated Set the return value of {@link setStatic} to a variable instead, as that is a getter and provides type checking. + * @deprecated Set the return value of {@link setStatic} to a variable instead, as that is a getter and provides type checking. Also, static data is basically useless and should not be used. Use variables in local scope instead. * @param key - The key to get the static data for. * @returns The static data for the given key. */ getStatic(key) { + console.warn("getStatic: Static data is basically useless and should not be used. Use variables in local scope instead."); return this.static[key]; } /** @@ -7204,69 +7210,67 @@ var DataManager = class { }; // src/game/GameCurrency.ts -var GameCurrency = class { - /** @returns The data for the currency. */ +var GameCurrency = class extends CurrencyStatic { + /** + * @returns The data for the currency. + * @deprecated Use {@link pointer} instead. This property is only here for backwards compatibility. + */ get data() { - return this.dataPointer(); + return this.pointer; } - /** @returns The static data for the currency. */ + /** + * @returns The static data for the currency. + * @deprecated Use this class as a static class as it now has all the properties of {@link CurrencyStatic}. This property is only here for backwards compatibility. + */ get static() { - return this.staticPointer(); + return this; } /** * Creates a new instance of the game class. - * @param currencyPointer - A function that returns the current currency value. - * @param staticPointer - A function that returns the static data for the game. + * @param currencyStaticParams - The parameters for the currency static class. * @param gamePointer A pointer to the game instance. * @param name - The name of the currency. This is optional, and you can use it for display purposes. */ - constructor(currencyPointer, staticPointer, gamePointer, name) { - this.dataPointer = typeof currencyPointer === "function" ? currencyPointer : () => currencyPointer; - this.staticPointer = typeof staticPointer === "function" ? staticPointer : () => staticPointer; + constructor(currencyStaticParams, gamePointer, name) { + if (typeof currencyStaticParams === "function") { + throw new Error("GameCurrency constructor does not accept a function as the first parameter. Use the .addCurrency method instead."); + } + super(...currencyStaticParams); this.game = gamePointer; this.name = name; this.game.dataManager.addEventOnLoad(() => { this.static.onLoadData(); }); } - /** - * Gets the value of the game currency. - * Note: There is no setter for this property. To change the value of the currency, use the corresponding methods in the static class. - * @returns The value of the game currency. - */ - get value() { - return this.data.value; - } }; // src/game/GameAttribute.ts -var GameAttribute = class { +var GameAttribute = class extends AttributeStatic { /** - * Creates a new instance of the attribute class. - * @param attributePointer - A function that returns the current attribute value. - * @param staticPointer - A function that returns the static data for the attribute. - * @param gamePointer A pointer to the game instance. + * @returns The data for the attribute. + * @deprecated Use {@link pointer} instead. This property is only here for backwards compatibility. */ - constructor(attributePointer, staticPointer, gamePointer) { - this.data = typeof attributePointer === "function" ? attributePointer() : attributePointer; - this.static = typeof staticPointer === "function" ? staticPointer() : staticPointer; - this.game = gamePointer; + get data() { + return this.pointer; } /** - * Gets the value of the attribute. - * NOTE: This getter is sometimes inaccurate. - * @returns The value of the attribute. + * @returns The static data for the attribute. + * @deprecated Use this class as a static. This property is only here for backwards compatibility. */ - get value() { - return this.static.value; + get static() { + return this; } /** - * Sets the value of the attribute. - * NOTE: This setter should not be used when boost is enabled. - * @param value - The value to set the attribute to. + * Creates a new instance of the attribute class. + * @param attributeStaticParams - The parameters for the attribute static class. + * @param gamePointer A pointer to the game instance. */ - set value(value) { - this.data.value = value; + constructor(attributeStaticParams, gamePointer) { + if (typeof attributeStaticParams === "function") { + throw new Error("GameAttribute constructor does not accept a function as the first parameter. Use the .addAttribute method instead."); + } + super(...attributeStaticParams); + this.game = gamePointer; } }; @@ -7399,12 +7403,8 @@ var Game = class _Game { this.dataManager.setData(name, { currency: new Currency() }); - this.dataManager.setStatic(name, { - currency: new CurrencyStatic(() => this.dataManager.getData(name).currency, upgrades) - }); const classInstance = new GameCurrency( - () => this.dataManager.getData(name).currency, - () => this.dataManager.getStatic(name).currency, + [() => this.dataManager.getData(name).currency, upgrades], this, name ); @@ -7422,8 +7422,10 @@ var Game = class _Game { */ addAttribute(name, useBoost = true, initial = 0) { this.dataManager.setData(name, new Attribute(initial)); - this.dataManager.setStatic(name, new AttributeStatic(this.dataManager.getData(name), useBoost, initial)); - const classInstance = new GameAttribute(this.dataManager.getData(name), this.dataManager.getStatic(name), this); + const classInstance = new GameAttribute( + [this.dataManager.getData(name), useBoost, initial], + this + ); return classInstance; } /** diff --git a/dist/game/eMath.game.min.js b/dist/game/eMath.game.min.js index 608aa16..1186786 100644 --- a/dist/game/eMath.game.min.js +++ b/dist/game/eMath.game.min.js @@ -1,4 +1,4 @@ -"use strict";(function(Ot,ut){var Ft=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],ut);else if(typeof module=="object"&&module.exports)module.exports=ut();else{var ct=ut(),Pt=Ft?exports:Ot;for(var Tt in ct)Pt[Tt]=ct[Tt]}})(typeof self<"u"?self:exports,()=>{var Ot={},ut={exports:Ot},Ft=Object.create,ct=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Tt=Object.getOwnPropertyNames,We=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty,bt=(t,e)=>function(){return e||(0,t[Tt(t)[0]])((e={exports:{}}).exports,e),e.exports},Ut=(t,e)=>{for(var r in e)ct(t,r,{get:e[r],enumerable:!0})},oe=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Tt(e))!Xe.call(t,n)&&n!==r&&ct(t,n,{get:()=>e[n],enumerable:!(i=Pt(e,n))||i.enumerable});return t},ot=(t,e,r)=>(r=t!=null?Ft(We(t)):{},oe(e||!t||!t.__esModule?ct(r,"default",{value:t,enumerable:!0}):r,t)),Je=t=>oe(ct({},"__esModule",{value:!0}),t),st=(t,e,r,i)=>{for(var n=i>1?void 0:i?Pt(e,r):e,o=t.length-1,f;o>=0;o--)(f=t[o])&&(n=(i?f(e,r,n):f(n))||n);return i&&n&&ct(e,r,n),n},ft=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: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(u,v){return function(c,l){Object.defineProperty(u,c,{configurable:!0,writable:!0,value:l}),v&&v(c,l)}}function f(){try{return Function("return this;")()}catch{}}function m(){try{return(0,eval)("(function() { return this; })()")}catch{}}function g(){return f()||m()}})(function(r,i){var n=Object.prototype.hasOwnProperty,o=typeof Symbol=="function",f=o&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",m=o&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",g=typeof Object.create=="function",u={__proto__:[]}instanceof Array,v=!g&&!u,c={create:g?function(){return ie(Object.create(null))}:u?function(){return ie({__proto__:null})}:function(){return ie({})},has:v?function(N,b){return n.call(N,b)}:function(N,b){return b in N},get:v?function(N,b){return n.call(N,b)?N[b]:void 0}:function(N,b){return N[b]}},l=Object.getPrototypeOf(Function),h=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Yr(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:zr(),d=typeof WeakMap=="function"?WeakMap:Vr(),O=o?Symbol.for("@reflect-metadata:registry"):void 0,C=Gr(),x=Zr(C);function a(N,b,A,E){if(j(A)){if(!qe(N))throw new TypeError;if(!De(b))throw new TypeError;return K(N,b)}else{if(!qe(N))throw new TypeError;if(!X(b))throw new TypeError;if(!X(E)&&!j(E)&&!It(E))throw new TypeError;return It(E)&&(E=void 0),A=lt(A),nt(N,b,A,E)}}r("decorate",a);function S(N,b){function A(E,U){if(!X(E))throw new TypeError;if(!j(U)&&!jr(U))throw new TypeError;qt(N,b,E,U)}return A}r("metadata",S);function y(N,b,A,E){if(!X(A))throw new TypeError;return j(E)||(E=lt(E)),qt(N,b,A,E)}r("defineMetadata",y);function I(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),H(N,b,A)}r("hasMetadata",I);function _(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),Y(N,b,A)}r("hasOwnMetadata",_);function M(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),W(N,b,A)}r("getMetadata",M);function F(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),pt(N,b,A)}r("getOwnMetadata",F);function P(N,b){if(!X(N))throw new TypeError;return j(b)||(b=lt(b)),Dt(N,b)}r("getMetadataKeys",P);function R(N,b){if(!X(N))throw new TypeError;return j(b)||(b=lt(b)),Bt(N,b)}r("getOwnMetadataKeys",R);function z(N,b,A){if(!X(b))throw new TypeError;if(j(A)||(A=lt(A)),!X(b))throw new TypeError;j(A)||(A=lt(A));var E=Et(b,A,!1);return j(E)?!1:E.OrdinaryDeleteMetadata(N,b,A)}r("deleteMetadata",z);function K(N,b){for(var A=N.length-1;A>=0;--A){var E=N[A],U=E(b);if(!j(U)&&!It(U)){if(!De(U))throw new TypeError;b=U}}return b}function nt(N,b,A,E){for(var U=N.length-1;U>=0;--U){var J=N[U],tt=J(b,A,E);if(!j(tt)&&!It(tt)){if(!X(tt))throw new TypeError;E=tt}}return E}function H(N,b,A){var E=Y(N,b,A);if(E)return!0;var U=re(b);return It(U)?!1:H(N,U,A)}function Y(N,b,A){var E=Et(b,A,!1);return j(E)?!1:ke(E.OrdinaryHasOwnMetadata(N,b,A))}function W(N,b,A){var E=Y(N,b,A);if(E)return pt(N,b,A);var U=re(b);if(!It(U))return W(N,U,A)}function pt(N,b,A){var E=Et(b,A,!1);if(!j(E))return E.OrdinaryGetOwnMetadata(N,b,A)}function qt(N,b,A,E){var U=Et(A,E,!0);U.OrdinaryDefineOwnMetadata(N,b,A,E)}function Dt(N,b){var A=Bt(N,b),E=re(N);if(E===null)return A;var U=Dt(E,b);if(U.length<=0)return A;if(A.length<=0)return U;for(var J=new p,tt=[],Z=0,L=A;Z=0&&L=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:k,done:!1}}return{value:void 0,done:!0}},Z.prototype.throw=function(L){throw this._index>=0&&(this._index=-1,this._keys=b,this._values=b),L},Z.prototype.return=function(L){return this._index>=0&&(this._index=-1,this._keys=b,this._values=b),{value:L,done:!0}},Z}(),E=function(){function Z(){this._keys=[],this._values=[],this._cacheKey=N,this._cacheIndex=-2}return Object.defineProperty(Z.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Z.prototype.has=function(L){return this._find(L,!1)>=0},Z.prototype.get=function(L){var k=this._find(L,!1);return k>=0?this._values[k]:void 0},Z.prototype.set=function(L,k){var q=this._find(L,!0);return this._values[q]=k,this},Z.prototype.delete=function(L){var k=this._find(L,!1);if(k>=0){for(var q=this._keys.length,D=k+1;D>>8,c[l*2+1]=p%256}return c},decompressFromUint8Array:function(u){if(u==null)return g.decompress(u);for(var v=new Array(u.length/2),c=0,l=v.length;c>1}else{for(h=1,l=0;l>1}a--,a==0&&(a=Math.pow(2,y),y++),delete d[x]}else for(h=p[x],l=0;l>1;a--,a==0&&(a=Math.pow(2,y),y++),p[C]=S++,x=String(O)}if(x!==""){if(Object.prototype.hasOwnProperty.call(d,x)){if(x.charCodeAt(0)<256){for(l=0;l>1}else{for(h=1,l=0;l>1}a--,a==0&&(a=Math.pow(2,y),y++),delete d[x]}else for(h=p[x],l=0;l>1;a--,a==0&&(a=Math.pow(2,y),y++)}for(h=2,l=0;l>1;for(;;)if(_=_<<1,M==v-1){I.push(c(_));break}else M++;return I.join("")},decompress:function(u){return u==null?"":u==""?null:g._decompress(u.length,32768,function(v){return u.charCodeAt(v)})},_decompress:function(u,v,c){var l=[],h,p=4,d=4,O=3,C="",x=[],a,S,y,I,_,M,F,P={val:c(0),position:v,index:1};for(a=0;a<3;a+=1)l[a]=a;for(y=0,_=Math.pow(2,2),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;switch(h=y){case 0:for(y=0,_=Math.pow(2,8),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;F=i(y);break;case 1:for(y=0,_=Math.pow(2,16),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;F=i(y);break;case 2:return""}for(l[3]=F,S=F,x.push(F);;){if(P.index>u)return"";for(y=0,_=Math.pow(2,O),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;switch(F=y){case 0:for(y=0,_=Math.pow(2,8),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;l[d++]=i(y),F=d-1,p--;break;case 1:for(y=0,_=Math.pow(2,16),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;l[d++]=i(y),F=d-1,p--;break;case 2:return x.join("")}if(p==0&&(p=Math.pow(2,O),O++),l[F])C=l[F];else if(F===d)C=S+S.charAt(0);else return null;x.push(C),l[d++]=S+C.charAt(0),p--,S=C,p==0&&(p=Math.pow(2,O),O++)}}};return g}();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})}}),Ke=bt({"node_modules/crypt/crypt.js"(t,e){(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i={rotl:function(n,o){return n<>>32-o},rotr:function(n,o){return n<<32-o|n>>>o},endian:function(n){if(n.constructor==Number)return i.rotl(n,8)&16711935|i.rotl(n,24)&4278255360;for(var o=0;o0;n--)o.push(Math.floor(Math.random()*256));return o},bytesToWords:function(n){for(var o=[],f=0,m=0;f>>5]|=n[f]<<24-m%32;return o},wordsToBytes:function(n){for(var o=[],f=0;f>>5]>>>24-f%32&255);return o},bytesToHex:function(n){for(var o=[],f=0;f>>4).toString(16)),o.push((n[f]&15).toString(16));return o.join("")},hexToBytes:function(n){for(var o=[],f=0;f>>6*(3-g)&63)):o.push("=");return o.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var o=[],f=0,m=0;f>>6-m*2);return o}};e.exports=i})()}}),ae=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=[],o=0;o>>24)&16711935|(u[d]<<24|u[d]>>>8)&4278255360;u[v>>>5]|=128<>>9<<4)+14]=v;for(var O=f._ff,C=f._gg,x=f._hh,a=f._ii,d=0;d>>0,l=l+y>>>0,h=h+I>>>0,p=p+_>>>0}return r.endian([c,l,h,p])};f._ff=function(m,g,u,v,c,l,h){var p=m+(g&u|~g&v)+(c>>>0)+h;return(p<>>32-l)+g},f._gg=function(m,g,u,v,c,l,h){var p=m+(g&v|u&~v)+(c>>>0)+h;return(p<>>32-l)+g},f._hh=function(m,g,u,v,c,l,h){var p=m+(g^u^v)+(c>>>0)+h;return(p<>>32-l)+g},f._ii=function(m,g,u,v,c,l,h){var p=m+(u^(g|~v))+(c>>>0)+h;return(p<>>32-l)+g},f._blocksize=16,f._digestsize=16,e.exports=function(m,g){if(m==null)throw new Error("Illegal argument "+m);var u=r.wordsToBytes(f(m,g));return g&&g.asBytes?u:g&&g.asString?o.bytesToString(u):r.bytesToHex(u)}})()}}),ue={};Ut(ue,{default:()=>Lr}),ut.exports=Je(ue);var Xr=ot(ft()),Jr=ot(ft()),le={};Ut(le,{Attribute:()=>Lt,AttributeStatic:()=>_e,Boost:()=>zt,BoostObject:()=>St,Currency:()=>gt,CurrencyStatic:()=>Me,DEFAULT_ITERATIONS:()=>xt,Decimal:()=>s,E:()=>Or,FORMATS:()=>_r,FormatTypeList:()=>ur,Grid:()=>Qt,GridCell:()=>Se,GridCellCollection:()=>rt,Item:()=>we,ItemData:()=>vt,LRUCache:()=>jt,ListNode:()=>fe,ST_NAMES:()=>ht,UpgradeData:()=>yt,UpgradeStatic:()=>Jt,calculateItem:()=>be,calculateSum:()=>Xt,calculateSumApprox:()=>Ne,calculateSumLoop:()=>pe,calculateUpgrade:()=>ye,decimalToJSONString:()=>ve,equalsTolerance:()=>Ht,formats:()=>dt,inverseFunctionApprox:()=>Wt,roundingBase:()=>Ir,upgradeToCacheNameEL:()=>Ar});var Qr=ot(ft()),jt=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 fe(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}}},fe=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},G;(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"})(G||(G={}));var rr=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===G.CLASS_TO_CLASS||i===G.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?i===G.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===G.CLASS_TO_CLASS||r===G.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===G.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===G.CLASS_TO_CLASS||r===G.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===G.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(c){return c.propertyName!==void 0}));for(var o=[],f=0,m=this.getAncestors(r);f0&&(f=f.filter(function(c){return!u.includes(c)})),this.options.version!==void 0&&(f=f.filter(function(c){var l=et.findExposeMetadata(e,c);return!l||!l.options?!0:n.checkVersion(l.options.since,l.options.until)})),this.options.groups&&this.options.groups.length?f=f.filter(function(c){var l=et.findExposeMetadata(e,c);return!l||!l.options?!0:n.checkGroups(l.options.groups)}):f=f.filter(function(c){var l=et.findExposeMetadata(e,c);return!l||!l.options||!l.options.groups||!l.options.groups.length})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(f=f.filter(function(v){return n.options.excludePrefixes.every(function(c){return v.substr(0,c.length)!==c})})),f=f.filter(function(v,c,l){return l.indexOf(v)===c}),f},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)&&(I="\u03C9");let M=t.log(a,8e3).toNumber();if(y.equals(0))return I;if(y.gt(0)&&y.lte(3)){let R=[];for(let z=0;zNumber.MAX_SAFE_INTEGER)&&(I="\u03C9");let M=t.log(a,8e3).toNumber();if(y.equals(0))return I;if(y.gt(0)&&y.lte(2)){let R=[];for(let z=0;z118?e.elemental.beyondOg(_):e.elemental.config.element_lists[a-1][I]},beyondOg(a){let S=Math.floor(Math.log10(a)),y=["n","u","b","t","q","p","h","s","o","e"],I="";for(let _=S;_>=0;_--){let M=Math.floor(a/Math.pow(10,_))%10;I==""?I=y[M].toUpperCase():I+=y[M]}return I},abbreviationLength(a){return a==1?1:Math.pow(Math.floor(a/2)+1,2)*2},getAbbreviationAndValue(a){let S=a.log(118).toNumber(),y=Math.floor(S)+1,I=e.elemental.abbreviationLength(y),_=S-y+1,M=Math.floor(_*I),F=e.elemental.getAbbreviation(y,_),P=new t(118).pow(y+M/I-1);return[F,P]},formatElementalPart(a,S){return S.eq(1)?a:`${S.toString()} ${a}`},format(a,S=2){if(a.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(a.log10(),S);let y=a.log(118),_=y.log(118).log(118).toNumber(),M=Math.max(4-_*2,1),F=[];for(;y.gte(1)&&F.length=M)return F.map(R=>e.elemental.formatElementalPart(R[0],R[1])).join(" + ");let P=new t(118).pow(y).toFixed(F.length===1?3:S);return F.length===0?P:F.length===1?`${P} \xD7 ${e.elemental.formatElementalPart(F[0][0],F[0][1])}`:`${P} \xD7 (${F.map(R=>e.elemental.formatElementalPart(R[0],R[1])).join(" + ")})`}},old_sc:{format(a,S){a=new t(a);let y=a.log10().floor();if(y.lt(9))return y.lt(3)?a.toFixed(S):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let _=a.slog();return(_.gte(1e9)?"":t.dTen.pow(_.sub(_.floor())).toFixed(4))+"F"+e.old_sc.format(_.floor(),0)}let I=a.div(t.dTen.pow(y));return(y.log10().gte(9)?"":I.toFixed(4))+"e"+e.old_sc.format(y,0)}}},eng:{format(a,S=2){a=new t(a);let y=a.log10().floor();if(y.lt(9))return y.lt(3)?a.toFixed(S):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let _=a.slog();return(_.gte(1e9)?"":t.dTen.pow(_.sub(_.floor())).toFixed(4))+"F"+e.eng.format(_.floor(),0)}let I=a.div(new t(1e3).pow(y.div(3).floor()));return(y.log10().gte(9)?"":I.toFixed(new t(4).sub(y.sub(y.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(y.div(3).floor().mul(3),0)}}},mixed_sc:{format(a,S,y=9){a=new t(a);let I=a.log10().floor();return I.lt(303)&&I.gte(y)?g(a,S,y,"st"):g(a,S,y,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(a,S=2,y){a=new t(a);let I=a.max(1).log10().max(1).log(r.log10()).floor();if(I.lte(0))return g(a,S,y,"sc");a=t.dTen.pow(a.max(1).log10().div(r.log10().pow(I)).sub(I.gte(1)?1:0));let _=I.div(10).floor(),M=I.toNumber()%10-1;return g(a,Math.max(4,S),y,"sc")+" "+(_.gte(1)?"meta"+(_.gte(2)?"^"+g(_,0,y,"sc"):"")+"-":"")+(isNaN(M)?"nanity":e.layer.layers[M])}},standard:{tier1(a){return ht[0][0][a%10]+ht[0][1][Math.floor(a/10)%10]+ht[0][2][Math.floor(a/100)]},tier2(a){let S=a%10,y=Math.floor(a/10)%10,I=Math.floor(a/100)%10,_="";return a<10?ht[1][0][a]:(y==1&&S==0?_+="Vec":_+=ht[1][1][S]+ht[1][2][y],_+=ht[1][3][I],_)}},inf:{format(a,S,y){a=new t(a);let I=0,_=new t(Number.MAX_VALUE),M=["","\u221E","\u03A9","\u03A8","\u028A"],F=["","","m","mm","mmm"];for(;a.gte(_);)a=a.log(_),I++;return I==0?g(a,S,y,"sc"):a.gte(3)?F[I]+M[I]+"\u03C9^"+g(a.sub(1),S,y,"sc"):a.gte(2)?F[I]+"\u03C9"+M[I]+"-"+g(_.pow(a.sub(2)),S,y,"sc"):F[I]+M[I]+"-"+g(_.pow(a.sub(1)),S,y,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(a,S=new t(1e15),y=!1,I=9){if(a=new t(a),S=new t(S).div(1e3),a.lt(S.mul(1e3)))return"";let{alphabet:_}=e.alphabet.config,M=_.length,F=a.log(1e3).sub(S.log(1e3)).floor(),P=F.add(1).log(M+1).ceil(),R="",z=(K,nt)=>{let H=K,Y="";for(let W=0;W=M)return"\u03C9";Y=_[pt]+Y,H=H.sub(1).div(M).floor()}return Y};if(P.lt(I))R=z(F,P);else{let K=P.sub(I).add(1),nt=F.div(t.pow(M+1,K.sub(1))).floor();R=`${z(nt,new t(I))}(${K.gt("1e9")?K.format():K.format(0)})`}return R},format(a,S=2,y=9,I="mixed_sc",_=new t(1e15),M=!1,F){if(a=new t(a),_=new t(_).div(1e3),a.lt(_.mul(1e3)))return g(a,S,y,I);let P=e.alphabet.getAbbreviation(a,_,M,F),R=a.div(t.pow(1e3,a.log(1e3).floor()));return`${P.length>(F??9)+2?"":R.toFixed(S)+" "}${P}`}}},r=t.dTwo.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(S=>S==="-"?"\u208B":i[parseInt(S,10)]).join("")}function f(a){return a.toFixed(0).split("").map(S=>S==="-"?"\u208B":n[parseInt(S,10)]).join("")}function m(a,S=2,y=9,I="st"){return g(a,S,y,I)}function g(a,S=2,y=9,I="mixed_sc"){a=new t(a);let _=a.lt(0)?"-":"";if(a.mag==1/0)return _+"Infinity";if(Number.isNaN(a.mag))return _+"NaN";if(a.lt(0)&&(a=a.mul(-1)),a.eq(0))return a.toFixed(S);let M=a.log10().floor();switch(I){case"sc":case"scientific":if(a.log10().lt(Math.min(-S,0))&&S>1){let F=a.log10().ceil(),P=a.div(F.eq(-1)?new t(.1):t.dTen.pow(F)),R=F.mul(-1).max(1).log10().gte(9);return _+(R?"":P.toFixed(2))+"e"+g(F,0,y,"mixed_sc")}else if(M.lt(y)){let F=Math.max(Math.min(S-M.toNumber(),S),0);return _+(F>0?a.toFixed(F):a.toFixed(F).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(a.gte("eeee10")){let R=a.slog();return(R.gte(1e9)?"":t.dTen.pow(R.sub(R.floor())).toFixed(2))+"F"+g(R.floor(),0)}let F=a.div(t.dTen.pow(M)),P=M.log10().gte(9);return _+(P?"":F.toFixed(2))+"e"+g(M,0,y,"mixed_sc")}case"st":case"standard":{let F=a.log(1e3).floor();if(F.lt(1))return _+a.toFixed(Math.max(Math.min(S-M.toNumber(),S),0));let P=F.mul(3),R=F.log10().floor();if(R.gte(3e3))return"e"+g(M,S,y,"st");let z="";if(F.lt(4))z=["","K","M","B"][Math.round(F.toNumber())];else{let H=Math.floor(F.log(1e3).toNumber());for(H<100&&(H=Math.max(H-1,0)),F=F.sub(1).div(t.dTen.pow(H*3));F.gt(0);){let Y=F.div(1e3).floor(),W=F.sub(Y.mul(1e3)).floor().toNumber();W>0&&(W==1&&!H&&(z="U"),H&&(z=e.standard.tier2(H)+(z?"-"+z:"")),W>1&&(z=e.standard.tier1(W)+z)),F=Y,H++}}let K=a.div(t.dTen.pow(P)),nt=S===2?t.dTwo.sub(M.sub(P)).add(1).toNumber():S;return _+(R.gte(10)?"":K.toFixed(nt)+" ")+z}default:return e[I]||console.error('Invalid format type "',I,'"'),_+e[I].format(a,S,y)}}function u(a,S,y="mixed_sc",I,_){a=new t(a),S=new t(S);let M=a.add(S),F,P=M.div(a);return P.gte(10)&&a.gte(1e100)?(P=P.log10().mul(20),F="(+"+g(P,I,_,y)+" OoMs/sec)"):F="(+"+g(S,I,_,y)+"/sec)",F}function v(a,S=2,y="s"){return a=new t(a),a.gte(86400)?g(a.div(86400).floor(),0,12,"sc")+":"+v(a.mod(86400),S,"d"):a.gte(3600)||y=="d"?(a.div(3600).gte(10)||y!="d"?"":"0")+g(a.div(3600).floor(),0,12,"sc")+":"+v(a.mod(3600),S,"h"):a.gte(60)||y=="h"?(a.div(60).gte(10)||y!="h"?"":"0")+g(a.div(60).floor(),0,12,"sc")+":"+v(a.mod(60),S,"m"):(a.gte(10)||y!="m"?"":"0")+g(a,S,12,"sc")}function c(a,S=!1,y=0,I=9,_="mixed_sc"){let M=Bt=>g(Bt,y,I,_);a=new t(a);let F=a.mul(1e3).mod(1e3).floor(),P=a.mod(60).floor(),R=a.div(60).mod(60).floor(),z=a.div(3600).mod(24).floor(),K=a.div(86400).mod(365.2425).floor(),nt=a.div(31556952).floor(),H=nt.eq(1)?" year":" years",Y=K.eq(1)?" day":" days",W=z.eq(1)?" hour":" hours",pt=R.eq(1)?" minute":" minutes",qt=P.eq(1)?" second":" seconds",Dt=F.eq(1)?" millisecond":" milliseconds";return`${nt.gt(0)?M(nt)+H+", ":""}${K.gt(0)?M(K)+Y+", ":""}${z.gt(0)?M(z)+W+", ":""}${R.gt(0)?M(R)+pt+", ":""}${P.gt(0)?M(P)+qt+",":""}${S&&F.gt(0)?" "+M(F)+Dt:""}`.replace(/,([^,]*)$/,"$1").trim()}function l(a){return a=new t(a),g(t.dOne.sub(a).mul(100))+"%"}function h(a){return a=new t(a),g(a.mul(100))+"%"}function p(a,S=2){return a=new t(a),a.gte(1)?"\xD7"+a.format(S):"/"+a.pow(-1).format(S)}function d(a,S,y=10){return t.gte(a,10)?t.pow(y,t.log(a,y).pow(S)):new t(a)}function O(a,S=0){a=new t(a);let y=(F=>F.map((P,R)=>({name:P.name,altName:P.altName,value:t.pow(1e3,new t(R).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"Decimal",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),I="",_=a.lte(0)?0:t.min(t.log(a,1e3).sub(1),y.length-1).floor().toNumber(),M=y[_];if(_===0)switch(S){case 1:I="";break;case 2:case 0:default:I=a.format();break}switch(S){case 1:I=M.name;break;case 2:I=a.divide(M.value).format();break;case 3:I=M.altName;break;case 0:default:I=`${a.divide(M.value).format()} ${M.name}`;break}return I}function C(a,S=!1){return`${O(a,2)} ${O(a,1)}eV${S?"/c^2":""}`}let x={...e,toSubscript:o,toSuperscript:f,formatST:m,format:g,formatGain:u,formatTime:v,formatTimeLong:c,formatReduction:l,formatPercent:h,formatMult:p,expMult:d,metric:O,ev:C};return{FORMATS:e,formats:x}}var Zt=17,fr=9e15,cr=Math.log10(9e15),hr=1/9e15,mr=308,dr=-324,me=5,gr=1023,pr=!0,Nr=!1,yr=function(){let t=[];for(let r=dr+1;r<=mr;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),Nt=[2,Math.E,3,4,5,6,7,8,9,10],vr=[[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]],br=[[-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]],w=function(e){return s.fromValue_noAlloc(e)},B=function(t,e,r){return s.fromComponents(t,e,r)},T=function(e,r,i){return s.fromComponents_noNormalize(e,r,i)},mt=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)))},$t=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},wr=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},Mr=.36787944117144233,de=.5671432904097838,Yt=function(t,e=1e-10,r=!0){let i,n;if(!Number.isFinite(t))return t;if(r){if(t===0)return t;if(t===1)return de;t<10?i=0:i=Math.log(t)-Math.log(Math.log(t))}else{if(t===0)return-1/0;t<=-.1?i=-2:i=Math.log(-t)-Math.log(-Math.log(-t))}for(let o=0;o<100;++o){if(n=(t*Math.exp(-i)+i*i)/(i+1),Math.abs(n-i).5?1:-1;if(Math.random()*20<1)return T(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)),B(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)),f=o.pow(2);return o.neg().add(f.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.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY,this;if(this.layer===0&&this.mag=fr)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);pr?t=t.replace(",",""):Nr&&(t=t.replace(",","."));let n=t.split("^^^");if(n.length===2){let d=parseFloat(n[0]),O=parseFloat(n[1]),C=n[1].split(";"),x=1;if(C.length===2&&(x=parseFloat(C[1]),isFinite(x)||(x=1)),isFinite(d)&&isFinite(O)){let a=s.pentate(d,O,x,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 d=parseFloat(o[0]),O=parseFloat(o[1]),C=o[1].split(";"),x=1;if(C.length===2&&(x=parseFloat(C[1]),isFinite(x)||(x=1)),isFinite(d)&&isFinite(O)){let a=s.tetrate(d,O,x,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 f=t.split("^");if(f.length===2){let d=parseFloat(f[0]),O=parseFloat(f[1]);if(isFinite(d)&&isFinite(O)){let C=s.pow(d,O);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}}t=t.trim().toLowerCase();let m,g,u=t.split("pt");if(u.length===2){m=10;let d=!1;u[0].startsWith("-")&&(d=!0,u[0]=u[0].slice(1)),g=parseFloat(u[0]),u[1]=u[1].replace("(",""),u[1]=u[1].replace(")","");let O=parseFloat(u[1]);if(isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let C=s.tetrate(m,g,O,e);return this.sign=C.sign,this.layer=C.layer,this.mag=C.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}if(u=t.split("p"),u.length===2){m=10;let d=!1;u[0].startsWith("-")&&(d=!0,u[0]=u[0].slice(1)),g=parseFloat(u[0]),u[1]=u[1].replace("(",""),u[1]=u[1].replace(")","");let O=parseFloat(u[1]);if(isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let C=s.tetrate(m,g,O,e);return this.sign=C.sign,this.layer=C.layer,this.mag=C.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}if(u=t.split("f"),u.length===2){m=10;let d=!1;u[0].startsWith("-")&&(d=!0,u[0]=u[0].slice(1)),u[0]=u[0].replace("(",""),u[0]=u[0].replace(")","");let O=parseFloat(u[0]);if(u[1]=u[1].replace("(",""),u[1]=u[1].replace(")",""),g=parseFloat(u[1]),isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let C=s.tetrate(m,g,O,e);return this.sign=C.sign,this.layer=C.layer,this.mag=C.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}let v=t.split("e"),c=v.length-1;if(c===0){let d=parseFloat(t);if(isFinite(d))return this.fromNumber(d),s.fromStringCache.size>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else if(c===1){let d=parseFloat(t);if(isFinite(d)&&d!==0)return this.fromNumber(d),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}let l=t.split("e^");if(l.length===2){this.sign=1,l[0].startsWith("-")&&(this.sign=-1);let d="";for(let O=0;O=43&&C<=57||C===101)d+=l[1].charAt(O);else return this.layer=parseFloat(d),this.mag=parseFloat(l[1].substr(O+1)),this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(c<1)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let h=parseFloat(v[0]);if(h===0)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let p=parseFloat(v[v.length-1]);if(c>=2){let d=parseFloat(v[v.length-2]);isFinite(d)&&(p*=Math.sign(d),p+=$t(d))}if(!isFinite(h))this.sign=v[0]==="-"?-1:1,this.layer=c,this.mag=p;else if(c===1)this.sign=Math.sign(h),this.layer=1,this.mag=p+Math.log10(Math.abs(h));else if(this.sign=Math.sign(h),this.layer=c,c===2){let d=s.mul(B(1,2,p),w(h));return this.sign=d.sign,this.layer=d.layer,this.mag=d.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else this.mag=p;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.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_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:mt(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:mt(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.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<=me?(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):mt(this.m,t)+"e"+mt(this.e,t):this.layer===1?mt(this.m,t)+"e"+mt(this.e,t):this.layer<=me?(this.sign===-1?"-":"")+"e".repeat(this.layer)+mt(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+mt(this.mag,t)}abs(){return T(this.sign===0?0:1,this.layer,this.mag)}neg(){return T(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?T(0,0,0):this.layer===0?B(this.sign,0,Math.round(this.mag)):new s(this)}floor(){return this.mag<0?this.sign===-1?T(-1,0,1):T(0,0,0):this.sign===-1?this.neg().ceil().neg():this.layer===0?B(this.sign,0,Math.floor(this.mag)):new s(this)}ceil(){return this.mag<0?this.sign===1?T(1,0,1):T(0,0,0):this.sign===-1?this.neg().floor().neg():this.layer===0?B(this.sign,0,Math.ceil(this.mag)):new s(this)}trunc(){return this.mag<0?T(0,0,0):this.layer===0?B(this.sign,0,Math.trunc(this.mag)):new s(this)}add(t){let e=w(t);if(this.eq(s.dInf)&&e.eq(s.dNegInf)||this.eq(s.dNegInf)&&e.eq(s.dInf))return T(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new s(this);if(!Number.isFinite(e.layer))return new s(e);if(this.sign===0)return new s(e);if(e.sign===0)return new s(this);if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return T(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(s.cmpabs(this,e)>0?(r=new s(this),i=new s(e)):(r=new s(e),i=new s(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))>Zt)return r;{let f=Math.pow(10,Math.log10(r.mag)-i.mag),m=i.sign+r.sign*f;return B(Math.sign(m),1,i.mag+Math.log10(Math.abs(m)))}}if(n===1&&o===0){if(Math.abs(r.mag-Math.log10(i.mag))>Zt)return r;{let f=Math.pow(10,r.mag-Math.log10(i.mag)),m=i.sign+r.sign*f;return B(Math.sign(m),1,Math.log10(i.mag)+Math.log10(Math.abs(m)))}}if(Math.abs(r.mag-i.mag)>Zt)return r;{let f=Math.pow(10,r.mag-i.mag),m=i.sign+r.sign*f;return B(Math.sign(m),1,i.mag+Math.log10(Math.abs(m)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(w(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=w(t);if(this.eq(s.dInf)&&e.eq(s.dNegInf)||this.eq(s.dNegInf)&&e.eq(s.dInf))return T(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.mag==Number.POSITIVE_INFINITY&&e.eq(s.dZero)||this.eq(s.dZero)&&this.mag==Number.POSITIVE_INFINITY)return T(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new s(this);if(!Number.isFinite(e.layer))return new s(e);if(this.sign===0||e.sign===0)return T(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return T(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=new s(this),i=new s(e)):(r=new s(e),i=new s(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 B(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return B(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return B(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let n=B(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(B(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return B(r.sign*i.sign,n.layer+1,n.sign*n.mag)}if(r.layer===2&&i.layer===2){let n=B(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(B(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return B(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=w(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?T(Number.NaN,Number.NaN,Number.NaN):this.mag===Number.POSITIVE_INFINITY?T(0,0,0):this.layer===0?B(this.sign,0,1/this.mag):B(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=w(t).abs();if(e.eq(s.dZero))return T(0,0,0);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)?T(0,0,0):e.sub(this).eq(e)?new s(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=w(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?new s(e):new s(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=w(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=w(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=$t(n)),this.layer0?B(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):B(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?T(Number.NaN,Number.NaN,Number.NaN):this.layer>0?B(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):B(this.sign,0,Math.log10(this.mag))}log(t){return t=w(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?T(Number.NaN,Number.NaN,Number.NaN):this.layer===0&&t.layer===0?B(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):s.div(this.log10(),t.log10())}log2(){return this.sign<=0?T(Number.NaN,Number.NaN,Number.NaN):this.layer===0?B(this.sign,0,Math.log2(this.mag)):this.layer===1?B(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?B(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):B(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?T(Number.NaN,Number.NaN,Number.NaN):this.layer===0?B(this.sign,0,Math.log(this.mag)):this.layer===1?B(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?B(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):B(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=w(t),r=new s(this),i=new s(e);if(r.sign===0)return i.eq(0)?T(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return T(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:T(Number.NaN,Number.NaN,Number.NaN):n}pow10(){if(this.eq(s.dInf))return T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.eq(s.dNegInf))return T(0,0,0);if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return T(Number.NaN,Number.NaN,Number.NaN);let t=new s(this);if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return B(1,0,e);if(t.sign===0)return T(1,0,1);t=T(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?B(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?B(-t.sign,t.layer+1,-t.mag):T(1,0,1)}pow_base(t){return w(t).pow(this)}root(t){let e=w(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(T(1,0,24)))return s.fromNumber(wr(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,f=e+o;if(f===e||(e=f,i=i*r,n=360*i,o=1/n,f=e-o,f===e))return s.exp(e);e=f,i=i*r,n=1260*i;let m=1/n;return e=e+m,i=i*r,n=1680*i,m=1/n,e=e-m,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?T(1,0,1):this.layer===0&&this.mag<=709.7?s.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?B(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?B(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):B(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 B(1,2,Math.log10(this.mag)-.3010299956639812);{let t=s.div(T(this.sign,this.layer-1,this.mag),T(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=T(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 T(1,0,1);if(this.eq(-1))return s.pow(this,e);if(t===Number.POSITIVE_INFINITY){let o=this.toNumber();if(o<=1.444667861009766&&o>=.06598803584531254){let f=s.ln(this).neg(),m=f.lambertw().div(f);if(o<1)return m;let g=f.lambertw(!1).div(f);return o>1.444667861009099&&(m=g=s.fromNumber(Math.E)),e=w(e),e.eq(g)?g:e.lt(g)?m:T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}else return o>1.444667861009766?T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY):T(Number.NaN,Number.NaN,Number.NaN)}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=new s(e);let i=t;t=Math.trunc(t);let n=i-t;if(this.gt(s.dZero)&&(this.lt(1)||this.lte(1.444667861009766)&&e.lte(s.ln(this).neg().lambertw(!1).div(s.ln(this).neg())))&&(i>1e4||!r)){let o=Math.min(1e4,t);e.eq(s.dOne)?e=this.pow(n):this.lt(1)?e=e.pow(1-n).mul(this.pow(e).pow(n)):e=e.layeradd(n,this);for(let f=0;f1e4&&Math.ceil(i)%2==1?this.pow(e):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):this.lt(1)?e=e.pow(1-n).mul(this.pow(e).pow(n)):e=e.layeradd(n,this,r));for(let o=0;o3)return T(e.sign,e.layer+(t-o-1),e.mag);if(o>1e4)return e}return e}iteratedexp(t=2,e=T(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=w(t);let i=s.fromDecimal(this),n=e;e=Math.trunc(e);let o=n-e;if(i.layer-t.layer>3){let f=Math.min(e,i.layer-t.layer-3);e-=f,i.layer-=f}for(let f=0;f1e4)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,f=this.slog_internal(t,r).toNumber();for(let m=1;m1&&o!=u&&(n=!0),o=u,n?i/=2:i*=2,i=Math.abs(i)*(u?-1:1),f+=i,i===0)break}return s.fromNumber(f)}slog_internal(t=10,e=!1){if(t=w(t),t.lte(s.dZero)||t.eq(s.dOne))return T(Number.NaN,Number.NaN,Number.NaN);if(t.lt(s.dOne))return this.eq(s.dOne)?T(0,0,0):this.eq(s.dZero)?T(-1,0,1):T(Number.NaN,Number.NaN,Number.NaN);if(this.mag<0||this.eq(s.dZero))return T(-1,0,1);if(t.lt(1.444667861009766)){let n=s.ln(t).neg(),o=n.lambertw().div(n);if(this.eq(o))return T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.gt(o))return T(Number.NaN,Number.NaN,Number.NaN)}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,br)}static tetrate_critical(t,e){return s.critical_section(t,e,vr)}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 m=0;mt){let g=(t-Nt[m])/(Nt[m+1]-Nt[m]);n=r[m][Math.floor(e)]*(1-g)+r[m+1][Math.floor(e)]*g,o=r[m][Math.ceil(e)]*(1-g)+r[m+1][Math.ceil(e)]*g;break}let f=e-Math.floor(e);return n<=0||o<=0?n*(1-f)+o*f:Math.pow(t,Math.log(n)/Math.log(t)*(1-f)+Math.log(o)/Math.log(t)*f)}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 i=w(e);if(i.gt(1)&&i.lte(1.444667861009766)){let f=s.excess_slog(this,e,r),m=f[0].toNumber(),g=f[1],u=m+t,v=s.ln(e).neg(),c=v.lambertw().div(v),l=v.lambertw(!1).div(v),h=s.dOne;g==1?h=c.mul(l).sqrt():g==2&&(h=l.mul(2));let p=i.pow(h),d=Math.floor(u),O=u-d,C=h.pow(1-O).mul(p.pow(O));return s.tetrate(i,d,C,r)}let o=this.slog(e,100,r).toNumber()+t;return o>=0?s.tetrate(e,o,s.dOne,r):Number.isFinite(o)?o>=-1?s.log(s.tetrate(e,o+1,s.dOne,r),e):s.log(s.log(s.tetrate(e,o+2,s.dOne,r),e),e):T(Number.NaN,Number.NaN,Number.NaN)}static excess_slog(t,e,r=!1){t=w(t),e=w(e);let i=e;if(e=e.toNumber(),e==1||e<=0)return[T(Number.NaN,Number.NaN,Number.NaN),0];if(e>1.444667861009766)return[t.slog(e,100,r),0];let n=s.ln(e).neg(),o=n.lambertw().div(n),f=s.dInf;if(e>1&&(f=n.lambertw(!1).div(n)),e>1.444667861009099&&(o=f=s.fromNumber(Math.E)),t.lt(o))return[t.slog(e,100,r),0];if(t.eq(o))return[T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),0];if(t.eq(f))return[T(1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),2];if(t.gt(f)){let m=f.mul(2),g=i.pow(m),u=0;if(t.gte(m)&&t.lt(g))u=0;else if(t.gte(g)){let d=g;for(u=1;d.lt(t);)if(d=i.pow(d),u=u+1,d.layer>3){let O=Math.floor(t.layer-d.layer+1);d=i.iteratedexp(O,d,r),u=u+O}d.gt(t)&&(d=d.log(e),u=u-1)}else if(t.lt(m)){let d=m;for(u=0;d.gt(t);)d=d.log(e),u=u-1}let v=0,c=0,l=.5,h=m,p=s.dZero;for(;l>1e-16;){if(c=v+l,h=m.pow(1-c).mul(g.pow(c)),p=s.iteratedexp(e,u,h),p.eq(t))return[new s(u+c),2];p.lt(t)&&(v+=l),l/=2}return p.neq_tolerance(t,1e-7)?[T(Number.NaN,Number.NaN,Number.NaN),0]:[new s(u+v),2]}if(t.lt(f)&&t.gt(o)){let m=o.mul(f).sqrt(),g=i.pow(m),u=0;if(t.lte(m)&&t.gt(g))u=0;else if(t.lte(g)){let d=g;for(u=1;d.gt(t);)d=i.pow(d),u=u+1;d.lt(t)&&(d=d.log(e),u=u-1)}else if(t.gt(m)){let d=m;for(u=0;d.lt(t);)d=d.log(e),u=u-1}let v=0,c=0,l=.5,h=m,p=s.dZero;for(;l>1e-16;){if(c=v+l,h=m.pow(1-c).mul(g.pow(c)),p=s.iteratedexp(e,u,h),p.eq(t))return[new s(u+c),1];p.gt(t)&&(v+=l),l/=2}return p.neq_tolerance(t,1e-7)?[T(Number.NaN,Number.NaN,Number.NaN),0]:[new s(u+v),1]}throw new Error("Unhandled behavior in excess_slog")}lambertw(t=!0){return this.lt(-.3678794411710499)?T(Number.NaN,Number.NaN,Number.NaN):t?this.abs().lt("1e-300")?new s(this):this.mag<0?s.fromNumber(Yt(this.toNumber())):this.layer===0?s.fromNumber(Yt(this.sign*this.mag)):this.lt("eee15")?ge(this):this.ln():this.sign===1?T(Number.NaN,Number.NaN,Number.NaN):this.layer===0?s.fromNumber(Yt(this.sign*this.mag,1e-10,!1)):this.layer==1?ge(this,1e-10,!1):this.neg().recip().lambertw().neg()}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(s.dInf))return T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(!this.isFinite())return T(Number.NaN,Number.NaN,Number.NaN);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 T(Number.NaN,Number.NaN,Number.NaN);if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return eMr?this.pow(this.recip()):T(Number.NaN,Number.NaN,Number.NaN)}if(this.eq(1))return T(1,0,1);if(this.lt(0))return T(Number.NaN,Number.NaN,Number.NaN);if(this.lte("1ee-16"))return t%2==1?new s(this):T(Number.NaN,Number.NaN,Number.NaN);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,f=n.div(2),m=!0;for(;m;)f=r.add(n).div(2),s.iteratedexp(10,i,f,!0).tetrate(t,1,!0).gt(this)?n=f:r=f,f.eq(o)?m=!1:o=f;return s.iteratedexp(10,i,f,!0)}else{let e=1,r=B(1,10,1),i=B(1,10,1),n=B(1,10,1),o=B(1,1,-16),f=s.dZero,m=B(1,10,1),g=o.pow10().recip(),u=s.dZero,v=g,c=g,l=Math.ceil(t)%2==0,h=0,p=B(1,10,1),d=!1,O=s.dZero,C=!1;for(;e<4;){if(e==2){if(l)break;n=B(1,10,1),o=r,e=3,m=B(1,10,1),p=B(1,10,1)}for(d=!1;o.neq(n);){if(O=o,o.pow10().recip().tetrate(t,1,!0).eq(1)&&o.pow10().recip().lt(.4))g=o.pow10().recip(),v=o.pow10().recip(),c=o.pow10().recip(),u=s.dZero,h=-1,e==3&&(p=o);else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip())&&!l&&o.pow10().recip().lt(.4))g=o.pow10().recip(),v=o.pow10().recip(),c=o.pow10().recip(),u=s.dZero,h=0;else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip().mul(2).tetrate(t,1,!0)))g=o.pow10().recip(),v=s.dZero,c=g.mul(2),u=g,l?h=-1:h=0;else{for(f=o.mul(12e-17),g=o.pow10().recip(),v=o.add(f).pow10().recip(),u=g.sub(v),c=g.add(u);v.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||c.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||v.gte(g)||c.lte(g);)f=f.mul(2),v=o.add(f).pow10().recip(),u=g.sub(v),c=g.add(u);if((e==1&&c.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))&&v.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))||e==3&&c.tetrate(t,1,!0).lt(g.tetrate(t,1,!0))&&v.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))&&(p=o),c.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))h=-1;else if(l)h=1;else if(e==3&&o.gt_tolerance(r,1e-8))h=0;else{for(;v.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||c.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||v.gte(g)||c.lte(g);)f=f.mul(2),v=o.add(f).pow10().recip(),u=g.sub(v),c=g.add(u);c.tetrate(t,1,!0).sub(g.tetrate(t,1,!0)).lt(g.tetrate(t,1,!0).sub(v.tetrate(t,1,!0)))?h=0:h=1}}if(h==-1&&(C=!0),e==1&&h==1||e==3&&h!=0)if(n.eq(B(1,10,1)))o=o.mul(2);else{let y=!1;if(d&&(h==1&&e==1||h==-1&&e==3)&&(y=!0),o=o.add(n).div(2),y)break}else if(n.eq(B(1,10,1)))n=o,o=o.div(2);else{let y=!1;if(d&&(h==1&&e==1||h==-1&&e==3)&&(y=!0),n=n.sub(m),o=o.sub(m),y)break}if(n.sub(o).div(2).abs().gt(m.mul(1.5))&&(d=!0),m=n.sub(o).div(2).abs(),o.gt("1e18")||o.eq(O))break}if(o.gt("1e18")||!C||p==B(1,10,1))break;e==1?r=p:e==3&&(i=p),e++}n=r,o=B(1,1,-18);let x=o,a=s.dZero,S=!0;for(;S;)if(n.eq(B(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(x)?S=!1:x=a,o.gt("1e18"))return T(Number.NaN,Number.NaN,Number.NaN);if(a.eq_tolerance(r,1e-15)){if(i.eq(B(1,10,1)))return T(Number.NaN,Number.NaN,Number.NaN);for(n=B(1,10,1),o=i,x=o,a=s.dZero,S=!0;S;)if(n.eq(B(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(x)?S=!1:x=a,o.gt("1e18"))return T(Number.NaN,Number.NaN,Number.NaN);return a.pow10().recip()}else return a.pow10().recip()}}pentate(t=2,e=T(1,0,1),r=!1){e=new s(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?new s(this):this.layer===0?s.fromNumber(Math.sin(this.sign*this.mag)):T(0,0,0)}cos(){return this.mag<0?T(1,0,1):this.layer===0?s.fromNumber(Math.cos(this.sign*this.mag)):T(0,0,0)}tan(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.tan(this.sign*this.mag)):T(0,0,0)}asin(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.asin(this.sign*this.mag)):T(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)):T(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?new s(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)?T(Number.NaN,Number.NaN,Number.NaN):s.ln(this.add(1).div(s.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?new s(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 dt.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return dt.format(new s(t),e,r,i)}formatST(t=2,e=9,r="st"){return dt.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return dt.format(new s(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return dt.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,n){return dt.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 f=Math.floor(r/i[o]);r-=f*i[o],n+=o.repeat(f)}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=T(0,0,0),s.dOne=T(1,0,1),s.dNegOne=T(-1,0,1),s.dTwo=T(1,0,2),s.dTen=T(1,0,10),s.dNaN=T(Number.NaN,Number.NaN,Number.NaN),s.dInf=T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNegInf=T(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNumberMax=B(1,0,Number.MAX_VALUE),s.dNumberMin=B(1,0,Number.MIN_VALUE),s.fromStringCache=new jt(gr),st([Ct()],s.prototype,"sign",2),st([Ct()],s.prototype,"mag",2),st([Ct()],s.prototype,"layer",2),s=st([ar()],s);var{formats:dt,FORMATS:_r}=lr(s);s.formats=dt;var St=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.value=t.value,this.order=t.order??99,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>""}},zt=class{constructor(t=1,e){this.addBoost=this.setBoost.bind(this),e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=new s(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new St(r))})}getBoosts(t,e){let r=[],i=[];for(let n=0;nc),u=n,v=this.getBoosts(o,!0);v[0][0]?this.boostArray[v[1][0]]=new St({id:o,name:f,description:m,value:g,order:u}):this.boostArray.push(new St({id:o,name:f,description:m,value:g,order:u}))}else{t=Array.isArray(t)?t:[t];for(let o of t){let f=this.getBoosts(o.id,!0);f[0][0]?this.boostArray[f[1][0]]=new St(o):this.boostArray.push(new St(o))}}}calculate(t=this.baseEffect){let e=new s(t),r=this.boostArray;r=r.sort((i,n)=>i.order-n.order);for(let i of r)e=i.value(e);return e}},Kr=ot(ft()),xt=30,Vt=.001;function Sr(t,e,r="geometric"){switch(t=new s(t),e=new s(e),r){case"arithmetic":case 1:return t.add(e).div(2);case"geometric":case 2:default:return t.mul(e).sqrt();case"harmonic":case 3:return s.dTwo.div(t.reciprocal().add(e.reciprocal()))}}function Ht(t,e,r,i){i=Object.assign({},{verbose:!1,mode:"geometric"},i),t=new s(t),e=new s(e),r=new s(r);let n,o;return i.mode==="geometric"?(n=t.sub(e).abs().div(t.abs().add(e.abs()).div(2)),o=n.lte(r)):(n=t.sub(e).abs(),o=n.lte(r)),(i.verbose===!0||i.verbose==="onlyOnFail"&&!o)&&console.log({a:t,b:e,tolerance:r,config:i,diff:n,result:o}),o}function Wt(t,e,r="geometric",i=xt,n=Vt){let o=s.dOne,f=new s(e);if(t(f).eq(0))return{value:s.dZero,lowerBound:s.dZero,upperBound:s.dZero};if(t(f).lt(e))return console.warn("The function is not monotonically increasing. (f(n) < n)"),{value:f,lowerBound:f,upperBound:f};for(let g=0;g=0;m--){let g=r.add(f.mul(m)),u=r.add(f.mul(m+1)),v=o;if(o=o.add(t(g).add(t(u)).div(2).mul(f)),Ht(v,o,n,{verbose:!1,mode:"geometric"}))break}return o}function Xt(t,e,r=0,i,n){return r=new s(r),e=new s(e),e.sub(r).lte(xt)?pe(t,e,r,i):Ne(t,e,r,n)}function Ir(t,e=10,r=0,i=1e3){if(t=new s(t),t.gte(s.pow(e,i)))return t;let n=s.floor(s.log(t,e)),o=t.div(s.pow(e,n));return o=o.mul(s.pow(e,r)).round(),o=o.div(s.pow(e,r)),o=o.mul(s.pow(e,n)),o}function ye(t,e,r,i=s.dInf,n,o,f=!1){t=new s(t),r=new s(r??e.level),i=new s(i);let m=i.sub(r);if(m.lt(0))return console.warn("calculateUpgrade: Invalid target: ",m),[s.dZero,s.dZero];if(f=(typeof e.el=="function"?e.el():e.el)??f,m.eq(1)){let c=e.cost(e.level),l=t.gte(c),h=[s.dZero,s.dZero];return f?(h[0]=l?s.dOne:s.dZero,h):(h=[l?s.dOne:s.dZero,l?c:s.dZero],h)}if(e.costBulk){let[c,l]=e.costBulk(t,e.level,m),h=t.gte(l);return[h?c:s.dZero,h&&!f?l:s.dZero]}if(f){let c=p=>e.cost(p.add(r)),l=s.min(i,Wt(c,t,n,o).value.floor()),h=s.dZero;return[l,h]}let g=Wt(c=>Xt(e.cost,c,r),t,n,o).value.floor().min(r.add(m).sub(1)),u=Xt(e.cost,g,r);return[g.sub(r).add(1).max(0),u]}function ve(t){return t=new s(t),`${t.sign}/${t.mag}/${t.layer}`}function Ar(t){return`el/${ve(t)}`}var yt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?new s(t.level):s.dOne}};st([Ct()],yt.prototype,"id",2),st([_t(()=>s)],yt.prototype,"level",2);var Jt=class $e{static{this.cacheSize=15}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.level,this,this.currencyPointerFn())}set description(e){this.descriptionFn=typeof e=="function"?e:()=>e}get level(){return((this??{data:{level:s.dOne}}).data??{level:s.dOne}).level}set level(e){this.data.level=new s(e)}constructor(e,r,i,n){let o=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>o,this.currencyPointerFn=typeof i=="function"?i:()=>i,this.cache=new jt(n??$e.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,this.defaultLevel=e.level??s.dOne}},ti=ot(ft());function be(t,e,r=s.dInf){if(t=new s(t),r=new s(r),r.lt(0))return console.warn("calculateItem: Invalid target: ",r),[s.dZero,s.dZero];if(r.eq(1)){let o=e.cost();return[t.gte(o)?s.dOne:s.dZero,t.gte(o)?o:s.dZero]}let i=t.div(e.cost()).floor().min(r),n=e.cost().mul(i);return[i,n]}var we=class{constructor(t,e,r){this.defaultAmount=s.dZero;let i=typeof e=="function"?e():e;this.dataPointerFn=typeof e=="function"?e:()=>i,this.currencyPointerFn=typeof r=="function"?r:()=>r,this.id=t.id,this.name=t.name??t.id,this.cost=t.cost,this.effect=t.effect,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.defaultAmount=t.amount??s.dZero}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.amount,this,this.currencyPointerFn())}set description(t){this.descriptionFn=typeof t=="function"?t:()=>t}get amount(){return((this??{data:{amount:s.dOne}}).data??{amount:s.dOne}).amount}set amount(t){this.data.amount=new s(t)}},vt=class{constructor(t){t=t??{},this.id=t.id,this.amount=t.amount??s.dZero}};st([Ct()],vt.prototype,"id",2),st([_t(()=>s)],vt.prototype,"amount",2);var ei=ot(ft()),gt=class{constructor(){this.value=s.dZero,this.upgrades={},this.items={}}};st([_t(()=>s)],gt.prototype,"value",2),st([_t(()=>yt)],gt.prototype,"upgrades",2),st([_t(()=>vt)],gt.prototype,"items",2);var Me=class{constructor(t=new gt,e,r={defaultVal:s.dZero,defaultBoost:s.dOne}){this.items={},this.defaultVal=r.defaultVal,this.defaultBoost=r.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new zt(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e)}get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}onLoadData(){for(let t of Object.values(this.upgrades))this.runUpgradeEffect(t)}reset(t,e,r){let i={resetCurrency:!0,resetUpgradeLevels:!0,resetItemAmounts:!0,runUpgradeEffect:!0};if(typeof t=="object"?Object.assign(i,t):Object.assign(i,{resetCurrency:t,resetUpgradeLevels:e,runUpgradeEffect:r}),i.resetCurrency&&(this.value=this.defaultVal),i.resetUpgradeLevels)for(let n of Object.values(this.upgrades))n.level=new s(n.defaultLevel),i.runUpgradeEffect&&this.runUpgradeEffect(n);if(i.resetItemAmounts)for(let n of Object.values(this.items))n.amount=new s(n.defaultAmount),i.runUpgradeEffect&&this.runUpgradeEffect(n)}gain(t=1e3){let e=this.boost.calculate().mul(new s(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new yt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}queryUpgrade(t){let e=Object.keys(this.upgrades);if(t instanceof RegExp){let i=t;return e.filter(o=>i.test(o)).map(o=>this.upgrades[o])}return typeof t=="string"&&(t=[t]),e.filter(i=>t.includes(i)).map(i=>this.upgrades[i])}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r=[];for(let i of t){this.pointerAddUpgrade(i);let n=new Jt(i,()=>this.pointerGetUpgrade(i.id),()=>this);e&&this.runUpgradeEffect(n),this.upgrades[i.id]=n,r.push(n)}return r}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&Object.assign(r,e)}runUpgradeEffect(t){t instanceof Jt?t.effect?.(t.level,t,this):t.effect?.(t.amount,t,this)}calculateUpgrade(t,e=1/0,r,i){let n=this.getUpgrade(t);return n===null?(console.warn(`Upgrade "${t}" not found.`),[s.dZero,s.dZero]):(e=n.level.add(e),n.maxLevel!==void 0&&(e=s.min(e,n.maxLevel)),ye(this.value,n,n.level,e,r,i))}getNextCost(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),s.dZero;let o=this.calculateUpgrade(t,e,r,i)[0];return n.cost(n.level.add(o))}getNextCostMax(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),s.dZero;let o=this.calculateUpgrade(t,e,r,i);return n.cost(n.level.add(o[0])).add(o[1])}buyUpgrade(t,e,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),!1;let[o,f]=this.calculateUpgrade(t,e,r,i);return o.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(f),n.level=n.level.add(o),this.runUpgradeEffect(n),!0)}pointerAddItem(t){let e=new vt(t);return this.pointer.items[t.id]=e,e}pointerGetItem(t){return this.pointer.items[t]??null}addItem(t,e=!0){Array.isArray(t)||(t=[t]);for(let r of t){this.pointerAddItem(r);let i=new we(r,()=>this.pointerGetItem(r.id),()=>this);e&&this.runUpgradeEffect(i),this.items[r.id]=i}}getItem(t){return this.items[t]??null}calculateItem(t,e=1/0){let r=this.getItem(t);return r===null?(console.warn(`Item "${t}" not found.`),[s.dZero,s.dZero]):be(this.value,r,e)}buyItem(t,e){let r=this.getItem(t);if(r===null)return console.warn(`Item "${t}" not found.`),!1;let[i,n]=this.calculateItem(t,e);return i.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(n),r.amount=r.amount.add(i),this.runUpgradeEffect(r),!0)}},ri=ot(ft()),Lt=class{constructor(t=0){this.value=new s(t)}};st([_t(()=>s)],Lt.prototype,"value",2);var _e=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=new s(r),t??=new Lt(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new zt(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}},Se=class{constructor(t,e,r={},i){this.setValue=this.set.bind(this),this.getValue=this.get.bind(this),this.x=t,this.y=e,this.properties=typeof r=="function"?{...r(this)}:{...r},this.gridSymbol=i}get grid(){return Qt.getInstance(this.gridSymbol)}set(t,e){return this.properties[t]=e,e}get(t){return this.properties[t]}translate(t=0,e=0){return Qt.getInstance(this.gridSymbol).getCell(this.x+t,this.y+e)}direction(t,e=1,r){let i=this.grid;return(()=>{switch(t){case"up":return i.getCell(this.x,this.y-e);case"right":return i.getCell(this.x+e,this.y);case"down":return i.getCell(this.x,this.y+e);case"left":return i.getCell(this.x-e,this.y);case"adjacent":return i.getAdjacent(this.x,this.y,e,r);case"diagonal":return i.getDiagonal(this.x,this.y,e,r);case"encircling":return i.getEncircling(this.x,this.y,e,r);default:throw new Error("Invalid direction")}})()}up(t=1){return this.direction("up",t)}right(t=1){return this.direction("right",t)}down(t=1){return this.direction("down",t)}left(t=1){return this.direction("left",t)}},rt=class ne extends Array{constructor(e){e=Array.isArray(e)?e:[e],e=e.filter(r=>r!==void 0),super(...e),this.removeDuplicates()}removeDuplicates(){let e=[];this.forEach((r,i)=>{this.indexOf(r)!==i&&e.push(i)}),e.forEach(r=>this.splice(r,1))}translate(e=0,r=0){return new ne(this.map(i=>i.translate(e,r)))}direction(e,r,i){return new ne(this.flatMap(n=>n.direction(e,r,i)))}up(e){return this.direction("up",e)}right(e){return this.direction("right",e)}down(e){return this.direction("down",e)}left(e){return this.direction("left",e)}adjacent(e,r){return this.direction("adjacent",e,r)}diagonal(e,r){return this.direction("diagonal",e,r)}encircling(e,r){return this.direction("encircling",e,r)}},Qt=class se{constructor(e,r,i){this.cells=[],this.gridSymbol=Symbol(),this.all=this.getAll.bind(this),this.allX=this.getAllX.bind(this),this.allY=this.getAllY.bind(this),this.get=this.getCell.bind(this),this.set=this.setCell.bind(this),se.instances[this.gridSymbol]=this,this.xSize=e,this.ySize=r??e;for(let n=0;n{let t=!1,e=r=>(t||(console.warn("The E function is deprecated. Use the Decimal class directly."),t=!0),new s(r));return Object.getOwnPropertyNames(s).filter(r=>!Object.getOwnPropertyNames(class{}).includes(r)).forEach(r=>{e[r]=s[r]}),e})(),Tr=le,Ie={};Ut(Ie,{ConfigManager:()=>kt,DataManager:()=>Ee,EventManager:()=>Te,EventTypes:()=>Oe,Game:()=>Pr,GameAttribute:()=>Pe,GameCurrency:()=>Fe,GameReset:()=>te,KeyManager:()=>Ae,gameDefaultConfig:()=>xe,keys:()=>Er});var ii=ot(ft()),kt=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}},Cr={autoAddInterval:!0,fps:30},Er="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ".split("").concat(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),Ae=class Ye{constructor(e){if(this.addKeys=this.addKey.bind(this),this.keysPressed=[],this.binds=[],this.tickers=[],this.config=Ye.configManager.parse(e),this.config.autoAddInterval){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)(typeof i.onDownContinuous<"u"||typeof i.fn<"u")&&this.isPressing(i.id)&&(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 kt(Cr)}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))}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)if(i.key===r)switch(e){case"down":i.onDown?.();break;case"press":default:i.onPress?.();break;case"up":i.onUp?.();break}}isPressing(e){for(let r of this.binds)if(r.id===e)return this.keysPressed.includes(r.key);return!1}getBind(e){return this.binds.find(r=>r.id===e)}addKey(e,r,i){e=typeof e=="string"?[{id:e,name:e,key:r??"",fn:i}]:e,e=Array.isArray(e)?e:[e];for(let n of e){n.id=n.id??n.name;let o=this.getBind(n.id);if(o){Object.assign(o,n);continue}this.binds.push(n)}}},Oe=(t=>(t.interval="interval",t.timeout="timeout",t))(Oe||{}),Fr={autoAddInterval:!0,fps:30},Te=class ze{constructor(e){if(this.addEvent=this.setEvent.bind(this),this.config=ze.configManager.parse(e),this.events={},this.config.autoAddInterval){let r=this.config.fps??30;this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/r)}}static{this.configManager=new kt(Fr)}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))}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]}},ni=ot(ft()),Ce=ot(Qe()),Kt=ot(er()),Ee=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=Rt(this.data)}compileDataRaw(t=this.data){let e=Rt(t),r=(0,Kt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(e)}`),i;try{i="9.2.0"}catch{i="8.3.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,Ce.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,Ce.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,Kt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`)===e;let i=e.hash,n=(0,Kt.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(c){return typeof c=="object"&&c?.constructor===Object}let n=(c,l)=>Object.prototype.hasOwnProperty.call(c,l);function o(c,l,h){if(!c||!l||!h)throw new Error("dataManager.deepMerge(): Missing arguments.");let p=h;for(let d in c)if(n(c,d)&&!n(h,d)&&(p[d]=c[d]),l[d]instanceof gt){let O=c[d],C=h[d];if(Array.isArray(C.upgrades)){let x=C.upgrades;C.upgrades={};for(let a of x)C.upgrades[a.id]=a}C.upgrades={...O.upgrades,...C.upgrades},p[d]=C,C.items={...O.items,...C.items}}else i(c[d])&&i(h[d])&&(p[d]=o(c[d],l[d],h[d]));return p}let f=e?o(this.normalDataPlain,this.normalData,r):r,m=Object.getOwnPropertyNames(new yt({id:"",level:s.dZero})),g=Object.getOwnPropertyNames(new vt({id:"",amount:s.dZero}));function u(c,l){let h=Gt(c,l);if(h instanceof gt){for(let p in h.upgrades){let d=h.upgrades[p];if(!d||!m.every(O=>Object.getOwnPropertyNames(d).includes(O))){delete h.upgrades[p];continue}h.upgrades[p]=Gt(yt,d)}for(let p in h.items){let d=h.items[p];if(!d||!g.every(O=>Object.getOwnPropertyNames(d).includes(O))){delete h.items[p];continue}h.items[p]=Gt(vt,d)}}if(!h)throw new Error(`Failed to convert ${c.name} to class instance.`);return h}function v(c,l){if(!c||!l)throw new Error("dataManager.plainToInstanceRecursive(): Missing arguments.");let h=l;for(let p in c){if(l[p]===void 0){console.warn(`Missing property "${p}" in loaded data.`);continue}if(!i(l[p]))continue;let d=c[p].constructor;if(d===Object){h[p]=v(c[p],l[p]);continue}h[p]=u(d,l[p])}return h}return f=v(this.normalData,f),f}loadData(t=this.decompileData()){if(t=typeof t=="string"?this.decompileData(t):t,!t)return null;let e=this.validateData([t[0],Rt(t[1])]),r=this.parseData(t);if(!r)return null;this.data=r;for(let i of this.eventsOnLoad)i();return e}},Fe=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}},Pe=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}},te=class Ve{static fromObject(e){return new Ve(e.currenciesToReset,e.extender,e.onReset,e.condition)}constructor(e,r,i,n){this.currenciesToReset=Array.isArray(e)?e:[e],this.extender=Array.isArray(r)?r:r?[r]:[],this.onReset=i,this.condition=n,this.id=Symbol()}reset(e=!1,r=!0,i=new Set){if(e||(typeof this.condition=="function"?!this.condition(this):!this.condition)&&typeof this.condition<"u")return;let n=()=>{this.onReset?.(this),this.currenciesToReset.forEach(o=>{o.static.reset()})};if(this.extender.length===0){n();return}this.extender.forEach(o=>{i.has(o.id)||(i.add(o.id),o.reset(r||e,r,i))}),n()}},xe={mode:"production",name:{title:"",id:"",version:"0.0.0"},settings:{framerate:30},initIntervalBasedManagers:!0},Pr=class He{static{this.configManager=new kt(xe)}constructor(e){this.config=He.configManager.parse(e),this.dataManager=new Ee(this),this.keyManager=new Ae({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.eventManager=new Te({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,r=[]){return this.dataManager.setData(e,{currency:new gt}),this.dataManager.setStatic(e,{currency:new Me(()=>this.dataManager.getData(e).currency,r)}),new Fe(()=>this.dataManager.getData(e).currency,()=>this.dataManager.getStatic(e).currency,this,e)}addAttribute(e,r=!0,i=0){return this.dataManager.setData(e,new Lt(i)),this.dataManager.setStatic(e,new _e(this.dataManager.getData(e),r,i)),new Pe(this.dataManager.getData(e),this.dataManager.getStatic(e),this)}addReset(...e){return new te(...e)}addResetFromObject(e){return te.fromObject(e)}},xr={...Tr,...Ie},Lr=xr;if(typeof ut.exports=="object"&&typeof Ot=="object"){var kr=(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};ut.exports=kr(ut.exports,Ot)}return ut.exports}); +"use strict";(function(Ot,ut){var Ft=typeof exports=="object";if(typeof define=="function"&&define.amd)define([],ut);else if(typeof module=="object"&&module.exports)module.exports=ut();else{var ct=ut(),Pt=Ft?exports:Ot;for(var Tt in ct)Pt[Tt]=ct[Tt]}})(typeof self<"u"?self:exports,()=>{var Ot={},ut={exports:Ot},Ft=Object.create,ct=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Tt=Object.getOwnPropertyNames,We=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty,bt=(t,e)=>function(){return e||(0,t[Tt(t)[0]])((e={exports:{}}).exports,e),e.exports},Ut=(t,e)=>{for(var r in e)ct(t,r,{get:e[r],enumerable:!0})},oe=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Tt(e))!Xe.call(t,n)&&n!==r&&ct(t,n,{get:()=>e[n],enumerable:!(i=Pt(e,n))||i.enumerable});return t},ot=(t,e,r)=>(r=t!=null?Ft(We(t)):{},oe(e||!t||!t.__esModule?ct(r,"default",{value:t,enumerable:!0}):r,t)),Je=t=>oe(ct({},"__esModule",{value:!0}),t),st=(t,e,r,i)=>{for(var n=i>1?void 0:i?Pt(e,r):e,o=t.length-1,f;o>=0;o--)(f=t[o])&&(n=(i?f(e,r,n):f(n))||n);return i&&n&&ct(e,r,n),n},ft=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: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(u,v){return function(c,l){Object.defineProperty(u,c,{configurable:!0,writable:!0,value:l}),v&&v(c,l)}}function f(){try{return Function("return this;")()}catch{}}function m(){try{return(0,eval)("(function() { return this; })()")}catch{}}function g(){return f()||m()}})(function(r,i){var n=Object.prototype.hasOwnProperty,o=typeof Symbol=="function",f=o&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",m=o&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",g=typeof Object.create=="function",u={__proto__:[]}instanceof Array,v=!g&&!u,c={create:g?function(){return ie(Object.create(null))}:u?function(){return ie({__proto__:null})}:function(){return ie({})},has:v?function(N,b){return n.call(N,b)}:function(N,b){return b in N},get:v?function(N,b){return n.call(N,b)?N[b]:void 0}:function(N,b){return N[b]}},l=Object.getPrototypeOf(Function),h=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:Yr(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:zr(),d=typeof WeakMap=="function"?WeakMap:Vr(),O=o?Symbol.for("@reflect-metadata:registry"):void 0,C=Gr(),x=Zr(C);function a(N,b,A,E){if(j(A)){if(!qe(N))throw new TypeError;if(!De(b))throw new TypeError;return K(N,b)}else{if(!qe(N))throw new TypeError;if(!X(b))throw new TypeError;if(!X(E)&&!j(E)&&!It(E))throw new TypeError;return It(E)&&(E=void 0),A=lt(A),nt(N,b,A,E)}}r("decorate",a);function S(N,b){function A(E,U){if(!X(E))throw new TypeError;if(!j(U)&&!jr(U))throw new TypeError;qt(N,b,E,U)}return A}r("metadata",S);function y(N,b,A,E){if(!X(A))throw new TypeError;return j(E)||(E=lt(E)),qt(N,b,A,E)}r("defineMetadata",y);function I(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),H(N,b,A)}r("hasMetadata",I);function _(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),Y(N,b,A)}r("hasOwnMetadata",_);function M(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),W(N,b,A)}r("getMetadata",M);function F(N,b,A){if(!X(b))throw new TypeError;return j(A)||(A=lt(A)),pt(N,b,A)}r("getOwnMetadata",F);function P(N,b){if(!X(N))throw new TypeError;return j(b)||(b=lt(b)),Dt(N,b)}r("getMetadataKeys",P);function R(N,b){if(!X(N))throw new TypeError;return j(b)||(b=lt(b)),Bt(N,b)}r("getOwnMetadataKeys",R);function z(N,b,A){if(!X(b))throw new TypeError;if(j(A)||(A=lt(A)),!X(b))throw new TypeError;j(A)||(A=lt(A));var E=Et(b,A,!1);return j(E)?!1:E.OrdinaryDeleteMetadata(N,b,A)}r("deleteMetadata",z);function K(N,b){for(var A=N.length-1;A>=0;--A){var E=N[A],U=E(b);if(!j(U)&&!It(U)){if(!De(U))throw new TypeError;b=U}}return b}function nt(N,b,A,E){for(var U=N.length-1;U>=0;--U){var J=N[U],tt=J(b,A,E);if(!j(tt)&&!It(tt)){if(!X(tt))throw new TypeError;E=tt}}return E}function H(N,b,A){var E=Y(N,b,A);if(E)return!0;var U=re(b);return It(U)?!1:H(N,U,A)}function Y(N,b,A){var E=Et(b,A,!1);return j(E)?!1:ke(E.OrdinaryHasOwnMetadata(N,b,A))}function W(N,b,A){var E=Y(N,b,A);if(E)return pt(N,b,A);var U=re(b);if(!It(U))return W(N,U,A)}function pt(N,b,A){var E=Et(b,A,!1);if(!j(E))return E.OrdinaryGetOwnMetadata(N,b,A)}function qt(N,b,A,E){var U=Et(A,E,!0);U.OrdinaryDefineOwnMetadata(N,b,A,E)}function Dt(N,b){var A=Bt(N,b),E=re(N);if(E===null)return A;var U=Dt(E,b);if(U.length<=0)return A;if(A.length<=0)return U;for(var J=new p,tt=[],Z=0,L=A;Z=0&&L=this._keys.length?(this._index=-1,this._keys=b,this._values=b):this._index++,{value:k,done:!1}}return{value:void 0,done:!0}},Z.prototype.throw=function(L){throw this._index>=0&&(this._index=-1,this._keys=b,this._values=b),L},Z.prototype.return=function(L){return this._index>=0&&(this._index=-1,this._keys=b,this._values=b),{value:L,done:!0}},Z}(),E=function(){function Z(){this._keys=[],this._values=[],this._cacheKey=N,this._cacheIndex=-2}return Object.defineProperty(Z.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Z.prototype.has=function(L){return this._find(L,!1)>=0},Z.prototype.get=function(L){var k=this._find(L,!1);return k>=0?this._values[k]:void 0},Z.prototype.set=function(L,k){var q=this._find(L,!0);return this._values[q]=k,this},Z.prototype.delete=function(L){var k=this._find(L,!1);if(k>=0){for(var q=this._keys.length,D=k+1;D>>8,c[l*2+1]=p%256}return c},decompressFromUint8Array:function(u){if(u==null)return g.decompress(u);for(var v=new Array(u.length/2),c=0,l=v.length;c>1}else{for(h=1,l=0;l>1}a--,a==0&&(a=Math.pow(2,y),y++),delete d[x]}else for(h=p[x],l=0;l>1;a--,a==0&&(a=Math.pow(2,y),y++),p[C]=S++,x=String(O)}if(x!==""){if(Object.prototype.hasOwnProperty.call(d,x)){if(x.charCodeAt(0)<256){for(l=0;l>1}else{for(h=1,l=0;l>1}a--,a==0&&(a=Math.pow(2,y),y++),delete d[x]}else for(h=p[x],l=0;l>1;a--,a==0&&(a=Math.pow(2,y),y++)}for(h=2,l=0;l>1;for(;;)if(_=_<<1,M==v-1){I.push(c(_));break}else M++;return I.join("")},decompress:function(u){return u==null?"":u==""?null:g._decompress(u.length,32768,function(v){return u.charCodeAt(v)})},_decompress:function(u,v,c){var l=[],h,p=4,d=4,O=3,C="",x=[],a,S,y,I,_,M,F,P={val:c(0),position:v,index:1};for(a=0;a<3;a+=1)l[a]=a;for(y=0,_=Math.pow(2,2),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;switch(h=y){case 0:for(y=0,_=Math.pow(2,8),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;F=i(y);break;case 1:for(y=0,_=Math.pow(2,16),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;F=i(y);break;case 2:return""}for(l[3]=F,S=F,x.push(F);;){if(P.index>u)return"";for(y=0,_=Math.pow(2,O),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;switch(F=y){case 0:for(y=0,_=Math.pow(2,8),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;l[d++]=i(y),F=d-1,p--;break;case 1:for(y=0,_=Math.pow(2,16),M=1;M!=_;)I=P.val&P.position,P.position>>=1,P.position==0&&(P.position=v,P.val=c(P.index++)),y|=(I>0?1:0)*M,M<<=1;l[d++]=i(y),F=d-1,p--;break;case 2:return x.join("")}if(p==0&&(p=Math.pow(2,O),O++),l[F])C=l[F];else if(F===d)C=S+S.charAt(0);else return null;x.push(C),l[d++]=S+C.charAt(0),p--,S=C,p==0&&(p=Math.pow(2,O),O++)}}};return g}();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})}}),Ke=bt({"node_modules/crypt/crypt.js"(t,e){(function(){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i={rotl:function(n,o){return n<>>32-o},rotr:function(n,o){return n<<32-o|n>>>o},endian:function(n){if(n.constructor==Number)return i.rotl(n,8)&16711935|i.rotl(n,24)&4278255360;for(var o=0;o0;n--)o.push(Math.floor(Math.random()*256));return o},bytesToWords:function(n){for(var o=[],f=0,m=0;f>>5]|=n[f]<<24-m%32;return o},wordsToBytes:function(n){for(var o=[],f=0;f>>5]>>>24-f%32&255);return o},bytesToHex:function(n){for(var o=[],f=0;f>>4).toString(16)),o.push((n[f]&15).toString(16));return o.join("")},hexToBytes:function(n){for(var o=[],f=0;f>>6*(3-g)&63)):o.push("=");return o.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var o=[],f=0,m=0;f>>6-m*2);return o}};e.exports=i})()}}),ae=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=[],o=0;o>>24)&16711935|(u[d]<<24|u[d]>>>8)&4278255360;u[v>>>5]|=128<>>9<<4)+14]=v;for(var O=f._ff,C=f._gg,x=f._hh,a=f._ii,d=0;d>>0,l=l+y>>>0,h=h+I>>>0,p=p+_>>>0}return r.endian([c,l,h,p])};f._ff=function(m,g,u,v,c,l,h){var p=m+(g&u|~g&v)+(c>>>0)+h;return(p<>>32-l)+g},f._gg=function(m,g,u,v,c,l,h){var p=m+(g&v|u&~v)+(c>>>0)+h;return(p<>>32-l)+g},f._hh=function(m,g,u,v,c,l,h){var p=m+(g^u^v)+(c>>>0)+h;return(p<>>32-l)+g},f._ii=function(m,g,u,v,c,l,h){var p=m+(u^(g|~v))+(c>>>0)+h;return(p<>>32-l)+g},f._blocksize=16,f._digestsize=16,e.exports=function(m,g){if(m==null)throw new Error("Illegal argument "+m);var u=r.wordsToBytes(f(m,g));return g&&g.asBytes?u:g&&g.asString?o.bytesToString(u):r.bytesToHex(u)}})()}}),ue={};Ut(ue,{default:()=>Lr}),ut.exports=Je(ue);var Xr=ot(ft()),Jr=ot(ft()),le={};Ut(le,{Attribute:()=>Lt,AttributeStatic:()=>_e,Boost:()=>zt,BoostObject:()=>St,Currency:()=>gt,CurrencyStatic:()=>Me,DEFAULT_ITERATIONS:()=>xt,Decimal:()=>s,E:()=>Or,FORMATS:()=>_r,FormatTypeList:()=>ur,Grid:()=>Qt,GridCell:()=>Se,GridCellCollection:()=>rt,Item:()=>we,ItemData:()=>vt,LRUCache:()=>jt,ListNode:()=>fe,ST_NAMES:()=>ht,UpgradeData:()=>yt,UpgradeStatic:()=>Jt,calculateItem:()=>be,calculateSum:()=>Xt,calculateSumApprox:()=>Ne,calculateSumLoop:()=>pe,calculateUpgrade:()=>ye,decimalToJSONString:()=>ve,equalsTolerance:()=>Ht,formats:()=>dt,inverseFunctionApprox:()=>Wt,roundingBase:()=>Ir,upgradeToCacheNameEL:()=>Ar});var Qr=ot(ft()),jt=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 fe(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}}},fe=class{constructor(t,e){this.next=void 0,this.prev=void 0,this.key=t,this.value=e}},G;(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"})(G||(G={}));var rr=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===G.CLASS_TO_CLASS||i===G.PLAIN_TO_CLASS:n.options.toPlainOnly===!0?i===G.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===G.CLASS_TO_CLASS||r===G.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===G.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===G.CLASS_TO_CLASS||r===G.PLAIN_TO_CLASS:i.options.toPlainOnly===!0?r===G.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(c){return c.propertyName!==void 0}));for(var o=[],f=0,m=this.getAncestors(r);f0&&(f=f.filter(function(c){return!u.includes(c)})),this.options.version!==void 0&&(f=f.filter(function(c){var l=et.findExposeMetadata(e,c);return!l||!l.options?!0:n.checkVersion(l.options.since,l.options.until)})),this.options.groups&&this.options.groups.length?f=f.filter(function(c){var l=et.findExposeMetadata(e,c);return!l||!l.options?!0:n.checkGroups(l.options.groups)}):f=f.filter(function(c){var l=et.findExposeMetadata(e,c);return!l||!l.options||!l.options.groups||!l.options.groups.length})}return this.options.excludePrefixes&&this.options.excludePrefixes.length&&(f=f.filter(function(v){return n.options.excludePrefixes.every(function(c){return v.substr(0,c.length)!==c})})),f=f.filter(function(v,c,l){return l.indexOf(v)===c}),f},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)&&(I="\u03C9");let M=t.log(a,8e3).toNumber();if(y.equals(0))return I;if(y.gt(0)&&y.lte(3)){let R=[];for(let z=0;zNumber.MAX_SAFE_INTEGER)&&(I="\u03C9");let M=t.log(a,8e3).toNumber();if(y.equals(0))return I;if(y.gt(0)&&y.lte(2)){let R=[];for(let z=0;z118?e.elemental.beyondOg(_):e.elemental.config.element_lists[a-1][I]},beyondOg(a){let S=Math.floor(Math.log10(a)),y=["n","u","b","t","q","p","h","s","o","e"],I="";for(let _=S;_>=0;_--){let M=Math.floor(a/Math.pow(10,_))%10;I==""?I=y[M].toUpperCase():I+=y[M]}return I},abbreviationLength(a){return a==1?1:Math.pow(Math.floor(a/2)+1,2)*2},getAbbreviationAndValue(a){let S=a.log(118).toNumber(),y=Math.floor(S)+1,I=e.elemental.abbreviationLength(y),_=S-y+1,M=Math.floor(_*I),F=e.elemental.getAbbreviation(y,_),P=new t(118).pow(y+M/I-1);return[F,P]},formatElementalPart(a,S){return S.eq(1)?a:`${S.toString()} ${a}`},format(a,S=2){if(a.gt(new t(118).pow(new t(118).pow(new t(118).pow(4)))))return"e"+e.elemental.format(a.log10(),S);let y=a.log(118),_=y.log(118).log(118).toNumber(),M=Math.max(4-_*2,1),F=[];for(;y.gte(1)&&F.length=M)return F.map(R=>e.elemental.formatElementalPart(R[0],R[1])).join(" + ");let P=new t(118).pow(y).toFixed(F.length===1?3:S);return F.length===0?P:F.length===1?`${P} \xD7 ${e.elemental.formatElementalPart(F[0][0],F[0][1])}`:`${P} \xD7 (${F.map(R=>e.elemental.formatElementalPart(R[0],R[1])).join(" + ")})`}},old_sc:{format(a,S){a=new t(a);let y=a.log10().floor();if(y.lt(9))return y.lt(3)?a.toFixed(S):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let _=a.slog();return(_.gte(1e9)?"":t.dTen.pow(_.sub(_.floor())).toFixed(4))+"F"+e.old_sc.format(_.floor(),0)}let I=a.div(t.dTen.pow(y));return(y.log10().gte(9)?"":I.toFixed(4))+"e"+e.old_sc.format(y,0)}}},eng:{format(a,S=2){a=new t(a);let y=a.log10().floor();if(y.lt(9))return y.lt(3)?a.toFixed(S):a.floor().toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,");{if(a.gte("eeee10")){let _=a.slog();return(_.gte(1e9)?"":t.dTen.pow(_.sub(_.floor())).toFixed(4))+"F"+e.eng.format(_.floor(),0)}let I=a.div(new t(1e3).pow(y.div(3).floor()));return(y.log10().gte(9)?"":I.toFixed(new t(4).sub(y.sub(y.div(3).floor().mul(3))).toNumber()))+"e"+e.eng.format(y.div(3).floor().mul(3),0)}}},mixed_sc:{format(a,S,y=9){a=new t(a);let I=a.log10().floor();return I.lt(303)&&I.gte(y)?g(a,S,y,"st"):g(a,S,y,"sc")}},layer:{layers:["infinity","eternity","reality","equality","affinity","celerity","identity","vitality","immunity","atrocity"],format(a,S=2,y){a=new t(a);let I=a.max(1).log10().max(1).log(r.log10()).floor();if(I.lte(0))return g(a,S,y,"sc");a=t.dTen.pow(a.max(1).log10().div(r.log10().pow(I)).sub(I.gte(1)?1:0));let _=I.div(10).floor(),M=I.toNumber()%10-1;return g(a,Math.max(4,S),y,"sc")+" "+(_.gte(1)?"meta"+(_.gte(2)?"^"+g(_,0,y,"sc"):"")+"-":"")+(isNaN(M)?"nanity":e.layer.layers[M])}},standard:{tier1(a){return ht[0][0][a%10]+ht[0][1][Math.floor(a/10)%10]+ht[0][2][Math.floor(a/100)]},tier2(a){let S=a%10,y=Math.floor(a/10)%10,I=Math.floor(a/100)%10,_="";return a<10?ht[1][0][a]:(y==1&&S==0?_+="Vec":_+=ht[1][1][S]+ht[1][2][y],_+=ht[1][3][I],_)}},inf:{format(a,S,y){a=new t(a);let I=0,_=new t(Number.MAX_VALUE),M=["","\u221E","\u03A9","\u03A8","\u028A"],F=["","","m","mm","mmm"];for(;a.gte(_);)a=a.log(_),I++;return I==0?g(a,S,y,"sc"):a.gte(3)?F[I]+M[I]+"\u03C9^"+g(a.sub(1),S,y,"sc"):a.gte(2)?F[I]+"\u03C9"+M[I]+"-"+g(_.pow(a.sub(2)),S,y,"sc"):F[I]+M[I]+"-"+g(_.pow(a.sub(1)),S,y,"sc")}},alphabet:{config:{alphabet:"abcdefghijklmnopqrstuvwxyz"},getAbbreviation(a,S=new t(1e15),y=!1,I=9){if(a=new t(a),S=new t(S).div(1e3),a.lt(S.mul(1e3)))return"";let{alphabet:_}=e.alphabet.config,M=_.length,F=a.log(1e3).sub(S.log(1e3)).floor(),P=F.add(1).log(M+1).ceil(),R="",z=(K,nt)=>{let H=K,Y="";for(let W=0;W=M)return"\u03C9";Y=_[pt]+Y,H=H.sub(1).div(M).floor()}return Y};if(P.lt(I))R=z(F,P);else{let K=P.sub(I).add(1),nt=F.div(t.pow(M+1,K.sub(1))).floor();R=`${z(nt,new t(I))}(${K.gt("1e9")?K.format():K.format(0)})`}return R},format(a,S=2,y=9,I="mixed_sc",_=new t(1e15),M=!1,F){if(a=new t(a),_=new t(_).div(1e3),a.lt(_.mul(1e3)))return g(a,S,y,I);let P=e.alphabet.getAbbreviation(a,_,M,F),R=a.div(t.pow(1e3,a.log(1e3).floor()));return`${P.length>(F??9)+2?"":R.toFixed(S)+" "}${P}`}}},r=t.dTwo.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(S=>S==="-"?"\u208B":i[parseInt(S,10)]).join("")}function f(a){return a.toFixed(0).split("").map(S=>S==="-"?"\u208B":n[parseInt(S,10)]).join("")}function m(a,S=2,y=9,I="st"){return g(a,S,y,I)}function g(a,S=2,y=9,I="mixed_sc"){a=new t(a);let _=a.lt(0)?"-":"";if(a.mag==1/0)return _+"Infinity";if(Number.isNaN(a.mag))return _+"NaN";if(a.lt(0)&&(a=a.mul(-1)),a.eq(0))return a.toFixed(S);let M=a.log10().floor();switch(I){case"sc":case"scientific":if(a.log10().lt(Math.min(-S,0))&&S>1){let F=a.log10().ceil(),P=a.div(F.eq(-1)?new t(.1):t.dTen.pow(F)),R=F.mul(-1).max(1).log10().gte(9);return _+(R?"":P.toFixed(2))+"e"+g(F,0,y,"mixed_sc")}else if(M.lt(y)){let F=Math.max(Math.min(S-M.toNumber(),S),0);return _+(F>0?a.toFixed(F):a.toFixed(F).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,"))}else{if(a.gte("eeee10")){let R=a.slog();return(R.gte(1e9)?"":t.dTen.pow(R.sub(R.floor())).toFixed(2))+"F"+g(R.floor(),0)}let F=a.div(t.dTen.pow(M)),P=M.log10().gte(9);return _+(P?"":F.toFixed(2))+"e"+g(M,0,y,"mixed_sc")}case"st":case"standard":{let F=a.log(1e3).floor();if(F.lt(1))return _+a.toFixed(Math.max(Math.min(S-M.toNumber(),S),0));let P=F.mul(3),R=F.log10().floor();if(R.gte(3e3))return"e"+g(M,S,y,"st");let z="";if(F.lt(4))z=["","K","M","B"][Math.round(F.toNumber())];else{let H=Math.floor(F.log(1e3).toNumber());for(H<100&&(H=Math.max(H-1,0)),F=F.sub(1).div(t.dTen.pow(H*3));F.gt(0);){let Y=F.div(1e3).floor(),W=F.sub(Y.mul(1e3)).floor().toNumber();W>0&&(W==1&&!H&&(z="U"),H&&(z=e.standard.tier2(H)+(z?"-"+z:"")),W>1&&(z=e.standard.tier1(W)+z)),F=Y,H++}}let K=a.div(t.dTen.pow(P)),nt=S===2?t.dTwo.sub(M.sub(P)).add(1).toNumber():S;return _+(R.gte(10)?"":K.toFixed(nt)+" ")+z}default:return e[I]||console.error('Invalid format type "',I,'"'),_+e[I].format(a,S,y)}}function u(a,S,y="mixed_sc",I,_){a=new t(a),S=new t(S);let M=a.add(S),F,P=M.div(a);return P.gte(10)&&a.gte(1e100)?(P=P.log10().mul(20),F="(+"+g(P,I,_,y)+" OoMs/sec)"):F="(+"+g(S,I,_,y)+"/sec)",F}function v(a,S=2,y="s"){return a=new t(a),a.gte(86400)?g(a.div(86400).floor(),0,12,"sc")+":"+v(a.mod(86400),S,"d"):a.gte(3600)||y=="d"?(a.div(3600).gte(10)||y!="d"?"":"0")+g(a.div(3600).floor(),0,12,"sc")+":"+v(a.mod(3600),S,"h"):a.gte(60)||y=="h"?(a.div(60).gte(10)||y!="h"?"":"0")+g(a.div(60).floor(),0,12,"sc")+":"+v(a.mod(60),S,"m"):(a.gte(10)||y!="m"?"":"0")+g(a,S,12,"sc")}function c(a,S=!1,y=0,I=9,_="mixed_sc"){let M=Bt=>g(Bt,y,I,_);a=new t(a);let F=a.mul(1e3).mod(1e3).floor(),P=a.mod(60).floor(),R=a.div(60).mod(60).floor(),z=a.div(3600).mod(24).floor(),K=a.div(86400).mod(365.2425).floor(),nt=a.div(31556952).floor(),H=nt.eq(1)?" year":" years",Y=K.eq(1)?" day":" days",W=z.eq(1)?" hour":" hours",pt=R.eq(1)?" minute":" minutes",qt=P.eq(1)?" second":" seconds",Dt=F.eq(1)?" millisecond":" milliseconds";return`${nt.gt(0)?M(nt)+H+", ":""}${K.gt(0)?M(K)+Y+", ":""}${z.gt(0)?M(z)+W+", ":""}${R.gt(0)?M(R)+pt+", ":""}${P.gt(0)?M(P)+qt+",":""}${S&&F.gt(0)?" "+M(F)+Dt:""}`.replace(/,([^,]*)$/,"$1").trim()}function l(a){return a=new t(a),g(t.dOne.sub(a).mul(100))+"%"}function h(a){return a=new t(a),g(a.mul(100))+"%"}function p(a,S=2){return a=new t(a),a.gte(1)?"\xD7"+a.format(S):"/"+a.pow(-1).format(S)}function d(a,S,y=10){return t.gte(a,10)?t.pow(y,t.log(a,y).pow(S)):new t(a)}function O(a,S=0){a=new t(a);let y=(F=>F.map((P,R)=>({name:P.name,altName:P.altName,value:t.pow(1e3,new t(R).add(1))})))([{name:"K",altName:"Kilo"},{name:"M",altName:"Mega"},{name:"G",altName:"Giga"},{name:"T",altName:"Tera"},{name:"P",altName:"Peta"},{name:"Decimal",altName:"Exa"},{name:"Z",altName:"Zetta"},{name:"Y",altName:"Yotta"},{name:"R",altName:"Ronna"},{name:"Q",altName:"Quetta"}]),I="",_=a.lte(0)?0:t.min(t.log(a,1e3).sub(1),y.length-1).floor().toNumber(),M=y[_];if(_===0)switch(S){case 1:I="";break;case 2:case 0:default:I=a.format();break}switch(S){case 1:I=M.name;break;case 2:I=a.divide(M.value).format();break;case 3:I=M.altName;break;case 0:default:I=`${a.divide(M.value).format()} ${M.name}`;break}return I}function C(a,S=!1){return`${O(a,2)} ${O(a,1)}eV${S?"/c^2":""}`}let x={...e,toSubscript:o,toSuperscript:f,formatST:m,format:g,formatGain:u,formatTime:v,formatTimeLong:c,formatReduction:l,formatPercent:h,formatMult:p,expMult:d,metric:O,ev:C};return{FORMATS:e,formats:x}}var Zt=17,fr=9e15,cr=Math.log10(9e15),hr=1/9e15,mr=308,dr=-324,me=5,gr=1023,pr=!0,Nr=!1,yr=function(){let t=[];for(let r=dr+1;r<=mr;r++)t.push(+("1e"+r));let e=323;return function(r){return t[r+e]}}(),Nt=[2,Math.E,3,4,5,6,7,8,9,10],vr=[[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]],br=[[-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]],w=function(e){return s.fromValue_noAlloc(e)},B=function(t,e,r){return s.fromComponents(t,e,r)},T=function(e,r,i){return s.fromComponents_noNormalize(e,r,i)},mt=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)))},$t=function(t){return Math.sign(t)*Math.log10(Math.abs(t))},wr=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},Mr=.36787944117144233,de=.5671432904097838,Yt=function(t,e=1e-10,r=!0){let i,n;if(!Number.isFinite(t))return t;if(r){if(t===0)return t;if(t===1)return de;t<10?i=0:i=Math.log(t)-Math.log(Math.log(t))}else{if(t===0)return-1/0;t<=-.1?i=-2:i=Math.log(-t)-Math.log(-Math.log(-t))}for(let o=0;o<100;++o){if(n=(t*Math.exp(-i)+i*i)/(i+1),Math.abs(n-i).5?1:-1;if(Math.random()*20<1)return T(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)),B(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)),f=o.pow(2);return o.neg().add(f.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.mag=Number.POSITIVE_INFINITY,this.layer=Number.POSITIVE_INFINITY,this;if(this.layer===0&&this.mag=fr)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);pr?t=t.replace(",",""):Nr&&(t=t.replace(",","."));let n=t.split("^^^");if(n.length===2){let d=parseFloat(n[0]),O=parseFloat(n[1]),C=n[1].split(";"),x=1;if(C.length===2&&(x=parseFloat(C[1]),isFinite(x)||(x=1)),isFinite(d)&&isFinite(O)){let a=s.pentate(d,O,x,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 d=parseFloat(o[0]),O=parseFloat(o[1]),C=o[1].split(";"),x=1;if(C.length===2&&(x=parseFloat(C[1]),isFinite(x)||(x=1)),isFinite(d)&&isFinite(O)){let a=s.tetrate(d,O,x,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 f=t.split("^");if(f.length===2){let d=parseFloat(f[0]),O=parseFloat(f[1]);if(isFinite(d)&&isFinite(O)){let C=s.pow(d,O);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}}t=t.trim().toLowerCase();let m,g,u=t.split("pt");if(u.length===2){m=10;let d=!1;u[0].startsWith("-")&&(d=!0,u[0]=u[0].slice(1)),g=parseFloat(u[0]),u[1]=u[1].replace("(",""),u[1]=u[1].replace(")","");let O=parseFloat(u[1]);if(isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let C=s.tetrate(m,g,O,e);return this.sign=C.sign,this.layer=C.layer,this.mag=C.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}if(u=t.split("p"),u.length===2){m=10;let d=!1;u[0].startsWith("-")&&(d=!0,u[0]=u[0].slice(1)),g=parseFloat(u[0]),u[1]=u[1].replace("(",""),u[1]=u[1].replace(")","");let O=parseFloat(u[1]);if(isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let C=s.tetrate(m,g,O,e);return this.sign=C.sign,this.layer=C.layer,this.mag=C.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}if(u=t.split("f"),u.length===2){m=10;let d=!1;u[0].startsWith("-")&&(d=!0,u[0]=u[0].slice(1)),u[0]=u[0].replace("(",""),u[0]=u[0].replace(")","");let O=parseFloat(u[0]);if(u[1]=u[1].replace("(",""),u[1]=u[1].replace(")",""),g=parseFloat(u[1]),isFinite(O)||(O=1),isFinite(m)&&isFinite(g)){let C=s.tetrate(m,g,O,e);return this.sign=C.sign,this.layer=C.layer,this.mag=C.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),d&&(this.sign*=-1),this}}let v=t.split("e"),c=v.length-1;if(c===0){let d=parseFloat(t);if(isFinite(d))return this.fromNumber(d),s.fromStringCache.size>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else if(c===1){let d=parseFloat(t);if(isFinite(d)&&d!==0)return this.fromNumber(d),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}let l=t.split("e^");if(l.length===2){this.sign=1,l[0].startsWith("-")&&(this.sign=-1);let d="";for(let O=0;O=43&&C<=57||C===101)d+=l[1].charAt(O);else return this.layer=parseFloat(d),this.mag=parseFloat(l[1].substr(O+1)),this.normalize(),s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}}if(c<1)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let h=parseFloat(v[0]);if(h===0)return this.sign=0,this.layer=0,this.mag=0,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this;let p=parseFloat(v[v.length-1]);if(c>=2){let d=parseFloat(v[v.length-2]);isFinite(d)&&(p*=Math.sign(d),p+=$t(d))}if(!isFinite(h))this.sign=v[0]==="-"?-1:1,this.layer=c,this.mag=p;else if(c===1)this.sign=Math.sign(h),this.layer=1,this.mag=p+Math.log10(Math.abs(h));else if(this.sign=Math.sign(h),this.layer=c,c===2){let d=s.mul(B(1,2,p),w(h));return this.sign=d.sign,this.layer=d.layer,this.mag=d.mag,s.fromStringCache.maxSize>=1&&s.fromStringCache.set(r,s.fromDecimal(this)),this}else this.mag=p;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.POSITIVE_INFINITY&&this.layer===Number.POSITIVE_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:mt(this.m,t)}magnitudeWithDecimalPlaces(t){return isNaN(this.mag)?Number.NaN:this.mag===0?0:mt(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.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<=me?(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):mt(this.m,t)+"e"+mt(this.e,t):this.layer===1?mt(this.m,t)+"e"+mt(this.e,t):this.layer<=me?(this.sign===-1?"-":"")+"e".repeat(this.layer)+mt(this.mag,t):(this.sign===-1?"-":"")+"(e^"+this.layer+")"+mt(this.mag,t)}abs(){return T(this.sign===0?0:1,this.layer,this.mag)}neg(){return T(-this.sign,this.layer,this.mag)}negate(){return this.neg()}negated(){return this.neg()}sgn(){return this.sign}round(){return this.mag<0?T(0,0,0):this.layer===0?B(this.sign,0,Math.round(this.mag)):new s(this)}floor(){return this.mag<0?this.sign===-1?T(-1,0,1):T(0,0,0):this.sign===-1?this.neg().ceil().neg():this.layer===0?B(this.sign,0,Math.floor(this.mag)):new s(this)}ceil(){return this.mag<0?this.sign===1?T(1,0,1):T(0,0,0):this.sign===-1?this.neg().floor().neg():this.layer===0?B(this.sign,0,Math.ceil(this.mag)):new s(this)}trunc(){return this.mag<0?T(0,0,0):this.layer===0?B(this.sign,0,Math.trunc(this.mag)):new s(this)}add(t){let e=w(t);if(this.eq(s.dInf)&&e.eq(s.dNegInf)||this.eq(s.dNegInf)&&e.eq(s.dInf))return T(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new s(this);if(!Number.isFinite(e.layer))return new s(e);if(this.sign===0)return new s(e);if(e.sign===0)return new s(this);if(this.sign===-e.sign&&this.layer===e.layer&&this.mag===e.mag)return T(0,0,0);let r,i;if(this.layer>=2||e.layer>=2)return this.maxabs(e);if(s.cmpabs(this,e)>0?(r=new s(this),i=new s(e)):(r=new s(e),i=new s(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))>Zt)return r;{let f=Math.pow(10,Math.log10(r.mag)-i.mag),m=i.sign+r.sign*f;return B(Math.sign(m),1,i.mag+Math.log10(Math.abs(m)))}}if(n===1&&o===0){if(Math.abs(r.mag-Math.log10(i.mag))>Zt)return r;{let f=Math.pow(10,r.mag-Math.log10(i.mag)),m=i.sign+r.sign*f;return B(Math.sign(m),1,Math.log10(i.mag)+Math.log10(Math.abs(m)))}}if(Math.abs(r.mag-i.mag)>Zt)return r;{let f=Math.pow(10,r.mag-i.mag),m=i.sign+r.sign*f;return B(Math.sign(m),1,i.mag+Math.log10(Math.abs(m)))}throw Error("Bad arguments to add: "+this+", "+t)}plus(t){return this.add(t)}sub(t){return this.add(w(t).neg())}subtract(t){return this.sub(t)}minus(t){return this.sub(t)}mul(t){let e=w(t);if(this.eq(s.dInf)&&e.eq(s.dNegInf)||this.eq(s.dNegInf)&&e.eq(s.dInf))return T(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.mag==Number.POSITIVE_INFINITY&&e.eq(s.dZero)||this.eq(s.dZero)&&this.mag==Number.POSITIVE_INFINITY)return T(Number.NaN,Number.NaN,Number.NaN);if(!Number.isFinite(this.layer))return new s(this);if(!Number.isFinite(e.layer))return new s(e);if(this.sign===0||e.sign===0)return T(0,0,0);if(this.layer===e.layer&&this.mag===-e.mag)return T(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=new s(this),i=new s(e)):(r=new s(e),i=new s(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 B(r.sign*i.sign,r.layer,r.mag);if(r.layer===1&&i.layer===0)return B(r.sign*i.sign,1,r.mag+Math.log10(i.mag));if(r.layer===1&&i.layer===1)return B(r.sign*i.sign,1,r.mag+i.mag);if(r.layer===2&&i.layer===1){let n=B(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(B(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return B(r.sign*i.sign,n.layer+1,n.sign*n.mag)}if(r.layer===2&&i.layer===2){let n=B(Math.sign(r.mag),r.layer-1,Math.abs(r.mag)).add(B(Math.sign(i.mag),i.layer-1,Math.abs(i.mag)));return B(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=w(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?T(Number.NaN,Number.NaN,Number.NaN):this.mag===Number.POSITIVE_INFINITY?T(0,0,0):this.layer===0?B(this.sign,0,1/this.mag):B(this.sign,this.layer,-this.mag)}reciprocal(){return this.recip()}reciprocate(){return this.recip()}mod(t){let e=w(t).abs();if(e.eq(s.dZero))return T(0,0,0);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)?T(0,0,0):e.sub(this).eq(e)?new s(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=w(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?new s(e):new s(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=w(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=w(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=$t(n)),this.layer0?B(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):B(1,0,Math.log10(this.mag))}log10(){return this.sign<=0?T(Number.NaN,Number.NaN,Number.NaN):this.layer>0?B(Math.sign(this.mag),this.layer-1,Math.abs(this.mag)):B(this.sign,0,Math.log10(this.mag))}log(t){return t=w(t),this.sign<=0||t.sign<=0||t.sign===1&&t.layer===0&&t.mag===1?T(Number.NaN,Number.NaN,Number.NaN):this.layer===0&&t.layer===0?B(this.sign,0,Math.log(this.mag)/Math.log(t.mag)):s.div(this.log10(),t.log10())}log2(){return this.sign<=0?T(Number.NaN,Number.NaN,Number.NaN):this.layer===0?B(this.sign,0,Math.log2(this.mag)):this.layer===1?B(Math.sign(this.mag),0,Math.abs(this.mag)*3.321928094887362):this.layer===2?B(Math.sign(this.mag),1,Math.abs(this.mag)+.5213902276543247):B(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}ln(){return this.sign<=0?T(Number.NaN,Number.NaN,Number.NaN):this.layer===0?B(this.sign,0,Math.log(this.mag)):this.layer===1?B(Math.sign(this.mag),0,Math.abs(this.mag)*2.302585092994046):this.layer===2?B(Math.sign(this.mag),1,Math.abs(this.mag)+.36221568869946325):B(Math.sign(this.mag),this.layer-1,Math.abs(this.mag))}logarithm(t){return this.log(t)}pow(t){let e=w(t),r=new s(this),i=new s(e);if(r.sign===0)return i.eq(0)?T(1,0,1):r;if(r.sign===1&&r.layer===0&&r.mag===1)return r;if(i.sign===0)return T(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:T(Number.NaN,Number.NaN,Number.NaN):n}pow10(){if(this.eq(s.dInf))return T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.eq(s.dNegInf))return T(0,0,0);if(!Number.isFinite(this.layer)||!Number.isFinite(this.mag))return T(Number.NaN,Number.NaN,Number.NaN);let t=new s(this);if(t.layer===0){let e=Math.pow(10,t.sign*t.mag);if(Number.isFinite(e)&&Math.abs(e)>=.1)return B(1,0,e);if(t.sign===0)return T(1,0,1);t=T(t.sign,t.layer+1,Math.log10(t.mag))}return t.sign>0&&t.mag>=0?B(t.sign,t.layer+1,t.mag):t.sign<0&&t.mag>=0?B(-t.sign,t.layer+1,-t.mag):T(1,0,1)}pow_base(t){return w(t).pow(this)}root(t){let e=w(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(T(1,0,24)))return s.fromNumber(wr(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,f=e+o;if(f===e||(e=f,i=i*r,n=360*i,o=1/n,f=e-o,f===e))return s.exp(e);e=f,i=i*r,n=1260*i;let m=1/n;return e=e+m,i=i*r,n=1680*i,m=1/n,e=e-m,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?T(1,0,1):this.layer===0&&this.mag<=709.7?s.fromNumber(Math.exp(this.sign*this.mag)):this.layer===0?B(1,1,this.sign*Math.log10(Math.E)*this.mag):this.layer===1?B(1,2,this.sign*(Math.log10(.4342944819032518)+this.mag)):B(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 B(1,2,Math.log10(this.mag)-.3010299956639812);{let t=s.div(T(this.sign,this.layer-1,this.mag),T(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=T(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 T(1,0,1);if(this.eq(-1))return s.pow(this,e);if(t===Number.POSITIVE_INFINITY){let o=this.toNumber();if(o<=1.444667861009766&&o>=.06598803584531254){let f=s.ln(this).neg(),m=f.lambertw().div(f);if(o<1)return m;let g=f.lambertw(!1).div(f);return o>1.444667861009099&&(m=g=s.fromNumber(Math.E)),e=w(e),e.eq(g)?g:e.lt(g)?m:T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}else return o>1.444667861009766?T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY):T(Number.NaN,Number.NaN,Number.NaN)}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=new s(e);let i=t;t=Math.trunc(t);let n=i-t;if(this.gt(s.dZero)&&(this.lt(1)||this.lte(1.444667861009766)&&e.lte(s.ln(this).neg().lambertw(!1).div(s.ln(this).neg())))&&(i>1e4||!r)){let o=Math.min(1e4,t);e.eq(s.dOne)?e=this.pow(n):this.lt(1)?e=e.pow(1-n).mul(this.pow(e).pow(n)):e=e.layeradd(n,this);for(let f=0;f1e4&&Math.ceil(i)%2==1?this.pow(e):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):this.lt(1)?e=e.pow(1-n).mul(this.pow(e).pow(n)):e=e.layeradd(n,this,r));for(let o=0;o3)return T(e.sign,e.layer+(t-o-1),e.mag);if(o>1e4)return e}return e}iteratedexp(t=2,e=T(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=w(t);let i=s.fromDecimal(this),n=e;e=Math.trunc(e);let o=n-e;if(i.layer-t.layer>3){let f=Math.min(e,i.layer-t.layer-3);e-=f,i.layer-=f}for(let f=0;f1e4)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,f=this.slog_internal(t,r).toNumber();for(let m=1;m1&&o!=u&&(n=!0),o=u,n?i/=2:i*=2,i=Math.abs(i)*(u?-1:1),f+=i,i===0)break}return s.fromNumber(f)}slog_internal(t=10,e=!1){if(t=w(t),t.lte(s.dZero)||t.eq(s.dOne))return T(Number.NaN,Number.NaN,Number.NaN);if(t.lt(s.dOne))return this.eq(s.dOne)?T(0,0,0):this.eq(s.dZero)?T(-1,0,1):T(Number.NaN,Number.NaN,Number.NaN);if(this.mag<0||this.eq(s.dZero))return T(-1,0,1);if(t.lt(1.444667861009766)){let n=s.ln(t).neg(),o=n.lambertw().div(n);if(this.eq(o))return T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(this.gt(o))return T(Number.NaN,Number.NaN,Number.NaN)}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,br)}static tetrate_critical(t,e){return s.critical_section(t,e,vr)}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 m=0;mt){let g=(t-Nt[m])/(Nt[m+1]-Nt[m]);n=r[m][Math.floor(e)]*(1-g)+r[m+1][Math.floor(e)]*g,o=r[m][Math.ceil(e)]*(1-g)+r[m+1][Math.ceil(e)]*g;break}let f=e-Math.floor(e);return n<=0||o<=0?n*(1-f)+o*f:Math.pow(t,Math.log(n)/Math.log(t)*(1-f)+Math.log(o)/Math.log(t)*f)}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 i=w(e);if(i.gt(1)&&i.lte(1.444667861009766)){let f=s.excess_slog(this,e,r),m=f[0].toNumber(),g=f[1],u=m+t,v=s.ln(e).neg(),c=v.lambertw().div(v),l=v.lambertw(!1).div(v),h=s.dOne;g==1?h=c.mul(l).sqrt():g==2&&(h=l.mul(2));let p=i.pow(h),d=Math.floor(u),O=u-d,C=h.pow(1-O).mul(p.pow(O));return s.tetrate(i,d,C,r)}let o=this.slog(e,100,r).toNumber()+t;return o>=0?s.tetrate(e,o,s.dOne,r):Number.isFinite(o)?o>=-1?s.log(s.tetrate(e,o+1,s.dOne,r),e):s.log(s.log(s.tetrate(e,o+2,s.dOne,r),e),e):T(Number.NaN,Number.NaN,Number.NaN)}static excess_slog(t,e,r=!1){t=w(t),e=w(e);let i=e;if(e=e.toNumber(),e==1||e<=0)return[T(Number.NaN,Number.NaN,Number.NaN),0];if(e>1.444667861009766)return[t.slog(e,100,r),0];let n=s.ln(e).neg(),o=n.lambertw().div(n),f=s.dInf;if(e>1&&(f=n.lambertw(!1).div(n)),e>1.444667861009099&&(o=f=s.fromNumber(Math.E)),t.lt(o))return[t.slog(e,100,r),0];if(t.eq(o))return[T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),0];if(t.eq(f))return[T(1,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),2];if(t.gt(f)){let m=f.mul(2),g=i.pow(m),u=0;if(t.gte(m)&&t.lt(g))u=0;else if(t.gte(g)){let d=g;for(u=1;d.lt(t);)if(d=i.pow(d),u=u+1,d.layer>3){let O=Math.floor(t.layer-d.layer+1);d=i.iteratedexp(O,d,r),u=u+O}d.gt(t)&&(d=d.log(e),u=u-1)}else if(t.lt(m)){let d=m;for(u=0;d.gt(t);)d=d.log(e),u=u-1}let v=0,c=0,l=.5,h=m,p=s.dZero;for(;l>1e-16;){if(c=v+l,h=m.pow(1-c).mul(g.pow(c)),p=s.iteratedexp(e,u,h),p.eq(t))return[new s(u+c),2];p.lt(t)&&(v+=l),l/=2}return p.neq_tolerance(t,1e-7)?[T(Number.NaN,Number.NaN,Number.NaN),0]:[new s(u+v),2]}if(t.lt(f)&&t.gt(o)){let m=o.mul(f).sqrt(),g=i.pow(m),u=0;if(t.lte(m)&&t.gt(g))u=0;else if(t.lte(g)){let d=g;for(u=1;d.gt(t);)d=i.pow(d),u=u+1;d.lt(t)&&(d=d.log(e),u=u-1)}else if(t.gt(m)){let d=m;for(u=0;d.lt(t);)d=d.log(e),u=u-1}let v=0,c=0,l=.5,h=m,p=s.dZero;for(;l>1e-16;){if(c=v+l,h=m.pow(1-c).mul(g.pow(c)),p=s.iteratedexp(e,u,h),p.eq(t))return[new s(u+c),1];p.gt(t)&&(v+=l),l/=2}return p.neq_tolerance(t,1e-7)?[T(Number.NaN,Number.NaN,Number.NaN),0]:[new s(u+v),1]}throw new Error("Unhandled behavior in excess_slog")}lambertw(t=!0){return this.lt(-.3678794411710499)?T(Number.NaN,Number.NaN,Number.NaN):t?this.abs().lt("1e-300")?new s(this):this.mag<0?s.fromNumber(Yt(this.toNumber())):this.layer===0?s.fromNumber(Yt(this.sign*this.mag)):this.lt("eee15")?ge(this):this.ln():this.sign===1?T(Number.NaN,Number.NaN,Number.NaN):this.layer===0?s.fromNumber(Yt(this.sign*this.mag,1e-10,!1)):this.layer==1?ge(this,1e-10,!1):this.neg().recip().lambertw().neg()}ssqrt(){return this.linear_sroot(2)}linear_sroot(t){if(t==1)return this;if(this.eq(s.dInf))return T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);if(!this.isFinite())return T(Number.NaN,Number.NaN,Number.NaN);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 T(Number.NaN,Number.NaN,Number.NaN);if(t==Number.POSITIVE_INFINITY){let e=this.toNumber();return eMr?this.pow(this.recip()):T(Number.NaN,Number.NaN,Number.NaN)}if(this.eq(1))return T(1,0,1);if(this.lt(0))return T(Number.NaN,Number.NaN,Number.NaN);if(this.lte("1ee-16"))return t%2==1?new s(this):T(Number.NaN,Number.NaN,Number.NaN);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,f=n.div(2),m=!0;for(;m;)f=r.add(n).div(2),s.iteratedexp(10,i,f,!0).tetrate(t,1,!0).gt(this)?n=f:r=f,f.eq(o)?m=!1:o=f;return s.iteratedexp(10,i,f,!0)}else{let e=1,r=B(1,10,1),i=B(1,10,1),n=B(1,10,1),o=B(1,1,-16),f=s.dZero,m=B(1,10,1),g=o.pow10().recip(),u=s.dZero,v=g,c=g,l=Math.ceil(t)%2==0,h=0,p=B(1,10,1),d=!1,O=s.dZero,C=!1;for(;e<4;){if(e==2){if(l)break;n=B(1,10,1),o=r,e=3,m=B(1,10,1),p=B(1,10,1)}for(d=!1;o.neq(n);){if(O=o,o.pow10().recip().tetrate(t,1,!0).eq(1)&&o.pow10().recip().lt(.4))g=o.pow10().recip(),v=o.pow10().recip(),c=o.pow10().recip(),u=s.dZero,h=-1,e==3&&(p=o);else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip())&&!l&&o.pow10().recip().lt(.4))g=o.pow10().recip(),v=o.pow10().recip(),c=o.pow10().recip(),u=s.dZero,h=0;else if(o.pow10().recip().tetrate(t,1,!0).eq(o.pow10().recip().mul(2).tetrate(t,1,!0)))g=o.pow10().recip(),v=s.dZero,c=g.mul(2),u=g,l?h=-1:h=0;else{for(f=o.mul(12e-17),g=o.pow10().recip(),v=o.add(f).pow10().recip(),u=g.sub(v),c=g.add(u);v.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||c.tetrate(t,1,!0).eq(g.tetrate(t,1,!0))||v.gte(g)||c.lte(g);)f=f.mul(2),v=o.add(f).pow10().recip(),u=g.sub(v),c=g.add(u);if((e==1&&c.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))&&v.tetrate(t,1,!0).gt(g.tetrate(t,1,!0))||e==3&&c.tetrate(t,1,!0).lt(g.tetrate(t,1,!0))&&v.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))&&(p=o),c.tetrate(t,1,!0).lt(g.tetrate(t,1,!0)))h=-1;else if(l)h=1;else if(e==3&&o.gt_tolerance(r,1e-8))h=0;else{for(;v.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||c.tetrate(t,1,!0).eq_tolerance(g.tetrate(t,1,!0),1e-8)||v.gte(g)||c.lte(g);)f=f.mul(2),v=o.add(f).pow10().recip(),u=g.sub(v),c=g.add(u);c.tetrate(t,1,!0).sub(g.tetrate(t,1,!0)).lt(g.tetrate(t,1,!0).sub(v.tetrate(t,1,!0)))?h=0:h=1}}if(h==-1&&(C=!0),e==1&&h==1||e==3&&h!=0)if(n.eq(B(1,10,1)))o=o.mul(2);else{let y=!1;if(d&&(h==1&&e==1||h==-1&&e==3)&&(y=!0),o=o.add(n).div(2),y)break}else if(n.eq(B(1,10,1)))n=o,o=o.div(2);else{let y=!1;if(d&&(h==1&&e==1||h==-1&&e==3)&&(y=!0),n=n.sub(m),o=o.sub(m),y)break}if(n.sub(o).div(2).abs().gt(m.mul(1.5))&&(d=!0),m=n.sub(o).div(2).abs(),o.gt("1e18")||o.eq(O))break}if(o.gt("1e18")||!C||p==B(1,10,1))break;e==1?r=p:e==3&&(i=p),e++}n=r,o=B(1,1,-18);let x=o,a=s.dZero,S=!0;for(;S;)if(n.eq(B(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(x)?S=!1:x=a,o.gt("1e18"))return T(Number.NaN,Number.NaN,Number.NaN);if(a.eq_tolerance(r,1e-15)){if(i.eq(B(1,10,1)))return T(Number.NaN,Number.NaN,Number.NaN);for(n=B(1,10,1),o=i,x=o,a=s.dZero,S=!0;S;)if(n.eq(B(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(x)?S=!1:x=a,o.gt("1e18"))return T(Number.NaN,Number.NaN,Number.NaN);return a.pow10().recip()}else return a.pow10().recip()}}pentate(t=2,e=T(1,0,1),r=!1){e=new s(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?new s(this):this.layer===0?s.fromNumber(Math.sin(this.sign*this.mag)):T(0,0,0)}cos(){return this.mag<0?T(1,0,1):this.layer===0?s.fromNumber(Math.cos(this.sign*this.mag)):T(0,0,0)}tan(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.tan(this.sign*this.mag)):T(0,0,0)}asin(){return this.mag<0?new s(this):this.layer===0?s.fromNumber(Math.asin(this.sign*this.mag)):T(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)):T(Number.NaN,Number.NaN,Number.NaN)}atan(){return this.mag<0?new s(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)?T(Number.NaN,Number.NaN,Number.NaN):s.ln(this.add(1).div(s.fromNumber(1).sub(this))).div(2)}ascensionPenalty(t){return t===0?new s(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 dt.format(this.clone(),t,e,r)}static format(t,e=2,r=9,i="mixed_sc"){return dt.format(new s(t),e,r,i)}formatST(t=2,e=9,r="st"){return dt.format(this.clone(),t,e,r)}static formatST(t,e=2,r=9,i="st"){return dt.format(new s(t),e,r,i)}formatGain(t,e="mixed_sc",r,i){return dt.formatGain(this.clone(),t,e,r,i)}static formatGain(t,e,r="mixed_sc",i,n){return dt.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 f=Math.floor(r/i[o]);r-=f*i[o],n+=o.repeat(f)}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=T(0,0,0),s.dOne=T(1,0,1),s.dNegOne=T(-1,0,1),s.dTwo=T(1,0,2),s.dTen=T(1,0,10),s.dNaN=T(Number.NaN,Number.NaN,Number.NaN),s.dInf=T(1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNegInf=T(-1,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s.dNumberMax=B(1,0,Number.MAX_VALUE),s.dNumberMin=B(1,0,Number.MIN_VALUE),s.fromStringCache=new jt(gr),st([Ct()],s.prototype,"sign",2),st([Ct()],s.prototype,"mag",2),st([Ct()],s.prototype,"layer",2),s=st([ar()],s);var{formats:dt,FORMATS:_r}=lr(s);s.formats=dt;var St=class{get desc(){return this.description}get description(){return this.descriptionFn()}constructor(t){this.id=t.id,this.name=t.name??"",this.value=t.value,this.order=t.order??99,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>""}},zt=class{constructor(t=1,e){this.addBoost=this.setBoost.bind(this),e=e?Array.isArray(e)?e:[e]:void 0,this.baseEffect=new s(t),this.boostArray=[],e&&e.forEach(r=>{this.boostArray.push(new St(r))})}getBoosts(t,e){let r=[],i=[];for(let n=0;nc),u=n,v=this.getBoosts(o,!0);v[0][0]?this.boostArray[v[1][0]]=new St({id:o,name:f,description:m,value:g,order:u}):this.boostArray.push(new St({id:o,name:f,description:m,value:g,order:u}))}else{t=Array.isArray(t)?t:[t];for(let o of t){let f=this.getBoosts(o.id,!0);f[0][0]?this.boostArray[f[1][0]]=new St(o):this.boostArray.push(new St(o))}}}calculate(t=this.baseEffect){let e=new s(t),r=this.boostArray;r=r.sort((i,n)=>i.order-n.order);for(let i of r)e=i.value(e);return e}},Kr=ot(ft()),xt=30,Vt=.001;function Sr(t,e,r="geometric"){switch(t=new s(t),e=new s(e),r){case"arithmetic":case 1:return t.add(e).div(2);case"geometric":case 2:default:return t.mul(e).sqrt();case"harmonic":case 3:return s.dTwo.div(t.reciprocal().add(e.reciprocal()))}}function Ht(t,e,r,i){i=Object.assign({},{verbose:!1,mode:"geometric"},i),t=new s(t),e=new s(e),r=new s(r);let n,o;return i.mode==="geometric"?(n=t.sub(e).abs().div(t.abs().add(e.abs()).div(2)),o=n.lte(r)):(n=t.sub(e).abs(),o=n.lte(r)),(i.verbose===!0||i.verbose==="onlyOnFail"&&!o)&&console.log({a:t,b:e,tolerance:r,config:i,diff:n,result:o}),o}function Wt(t,e,r="geometric",i=xt,n=Vt){let o=s.dOne,f=new s(e);if(t(f).eq(0))return{value:s.dZero,lowerBound:s.dZero,upperBound:s.dZero};if(t(f).lt(e))return console.warn("The function is not monotonically increasing. (f(n) < n)"),{value:f,lowerBound:f,upperBound:f};for(let g=0;g=0;m--){let g=r.add(f.mul(m)),u=r.add(f.mul(m+1)),v=o;if(o=o.add(t(g).add(t(u)).div(2).mul(f)),Ht(v,o,n,{verbose:!1,mode:"geometric"}))break}return o}function Xt(t,e,r=0,i,n){return r=new s(r),e=new s(e),e.sub(r).lte(xt)?pe(t,e,r,i):Ne(t,e,r,n)}function Ir(t,e=10,r=0,i=1e3){if(t=new s(t),t.gte(s.pow(e,i)))return t;let n=s.floor(s.log(t,e)),o=t.div(s.pow(e,n));return o=o.mul(s.pow(e,r)).round(),o=o.div(s.pow(e,r)),o=o.mul(s.pow(e,n)),o}function ye(t,e,r,i=s.dInf,n,o,f=!1){t=new s(t),r=new s(r??e.level),i=new s(i);let m=i.sub(r);if(m.lt(0))return console.warn("calculateUpgrade: Invalid target: ",m),[s.dZero,s.dZero];if(f=(typeof e.el=="function"?e.el():e.el)??f,m.eq(1)){let c=e.cost(e.level),l=t.gte(c),h=[s.dZero,s.dZero];return f?(h[0]=l?s.dOne:s.dZero,h):(h=[l?s.dOne:s.dZero,l?c:s.dZero],h)}if(e.costBulk){let[c,l]=e.costBulk(t,e.level,m),h=t.gte(l);return[h?c:s.dZero,h&&!f?l:s.dZero]}if(f){let c=p=>e.cost(p.add(r)),l=s.min(i,Wt(c,t,n,o).value.floor()),h=s.dZero;return[l,h]}let g=Wt(c=>Xt(e.cost,c,r),t,n,o).value.floor().min(r.add(m).sub(1)),u=Xt(e.cost,g,r);return[g.sub(r).add(1).max(0),u]}function ve(t){return t=new s(t),`${t.sign}/${t.mag}/${t.layer}`}function Ar(t){return`el/${ve(t)}`}var yt=class{constructor(t){t=t??{},this.id=t.id,this.level=t.level?new s(t.level):s.dOne}};st([Ct()],yt.prototype,"id",2),st([_t(()=>s)],yt.prototype,"level",2);var Jt=class $e{static{this.cacheSize=15}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.level,this,this.currencyPointerFn())}set description(e){this.descriptionFn=typeof e=="function"?e:()=>e}get level(){return((this??{data:{level:s.dOne}}).data??{level:s.dOne}).level}set level(e){this.data.level=new s(e)}constructor(e,r,i,n){let o=typeof r=="function"?r():r;this.dataPointerFn=typeof r=="function"?r:()=>o,this.currencyPointerFn=typeof i=="function"?i:()=>i,this.cache=new jt(n??$e.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,this.defaultLevel=e.level??s.dOne}},ti=ot(ft());function be(t,e,r=s.dInf){if(t=new s(t),r=new s(r),r.lt(0))return console.warn("calculateItem: Invalid target: ",r),[s.dZero,s.dZero];if(r.eq(1)){let o=e.cost();return[t.gte(o)?s.dOne:s.dZero,t.gte(o)?o:s.dZero]}let i=t.div(e.cost()).floor().min(r),n=e.cost().mul(i);return[i,n]}var we=class{constructor(t,e,r){this.defaultAmount=s.dZero;let i=typeof e=="function"?e():e;this.dataPointerFn=typeof e=="function"?e:()=>i,this.currencyPointerFn=typeof r=="function"?r:()=>r,this.id=t.id,this.name=t.name??t.id,this.cost=t.cost,this.effect=t.effect,this.descriptionFn=t.description?typeof t.description=="function"?t.description:()=>t.description:()=>"",this.defaultAmount=t.amount??s.dZero}get data(){return this.dataPointerFn()}get description(){return this.descriptionFn(this.amount,this,this.currencyPointerFn())}set description(t){this.descriptionFn=typeof t=="function"?t:()=>t}get amount(){return((this??{data:{amount:s.dOne}}).data??{amount:s.dOne}).amount}set amount(t){this.data.amount=new s(t)}},vt=class{constructor(t){t=t??{},this.id=t.id,this.amount=t.amount??s.dZero}};st([Ct()],vt.prototype,"id",2),st([_t(()=>s)],vt.prototype,"amount",2);var ei=ot(ft()),gt=class{constructor(){this.value=s.dZero,this.upgrades={},this.items={}}};st([_t(()=>s)],gt.prototype,"value",2),st([_t(()=>yt)],gt.prototype,"upgrades",2),st([_t(()=>vt)],gt.prototype,"items",2);var Me=class{constructor(t=new gt,e,r={defaultVal:s.dZero,defaultBoost:s.dOne}){this.items={},this.defaultVal=r.defaultVal,this.defaultBoost=r.defaultBoost,this.pointerFn=typeof t=="function"?t:()=>t,this.boost=new zt(this.defaultBoost),this.pointer.value=this.defaultVal,this.upgrades={},e&&this.addUpgrade(e)}get pointer(){return this.pointerFn()}get value(){return this.pointer.value}set value(t){this.pointer.value=t}onLoadData(){for(let t of Object.values(this.upgrades))this.runUpgradeEffect(t)}reset(t,e,r){let i={resetCurrency:!0,resetUpgradeLevels:!0,resetItemAmounts:!0,runUpgradeEffect:!0};if(typeof t=="object"?Object.assign(i,t):Object.assign(i,{resetCurrency:t,resetUpgradeLevels:e,runUpgradeEffect:r}),i.resetCurrency&&(this.value=this.defaultVal),i.resetUpgradeLevels)for(let n of Object.values(this.upgrades))n.level=new s(n.defaultLevel),i.runUpgradeEffect&&this.runUpgradeEffect(n);if(i.resetItemAmounts)for(let n of Object.values(this.items))n.amount=new s(n.defaultAmount),i.runUpgradeEffect&&this.runUpgradeEffect(n)}gain(t=1e3){let e=this.boost.calculate().mul(new s(t).div(1e3));return this.pointer.value=this.pointer.value.add(e),e}pointerAddUpgrade(t){let e=new yt(t);return this.pointer.upgrades[e.id]=e,e}pointerGetUpgrade(t){return this.pointer.upgrades[t]??null}getUpgrade(t){return this.upgrades[t]??null}queryUpgrade(t){let e=Object.keys(this.upgrades);if(t instanceof RegExp){let i=t;return e.filter(o=>i.test(o)).map(o=>this.upgrades[o])}return typeof t=="string"&&(t=[t]),e.filter(i=>t.includes(i)).map(i=>this.upgrades[i])}addUpgrade(t,e=!0){Array.isArray(t)||(t=[t]);let r=[];for(let i of t){this.pointerAddUpgrade(i);let n=new Jt(i,()=>this.pointerGetUpgrade(i.id),()=>this);e&&this.runUpgradeEffect(n),this.upgrades[i.id]=n,r.push(n)}return r}updateUpgrade(t,e){let r=this.getUpgrade(t);r!==null&&Object.assign(r,e)}runUpgradeEffect(t){t instanceof Jt?t.effect?.(t.level,t,this):t.effect?.(t.amount,t,this)}calculateUpgrade(t,e=1/0,r,i){let n=this.getUpgrade(t);return n===null?(console.warn(`Upgrade "${t}" not found.`),[s.dZero,s.dZero]):(e=n.level.add(e),n.maxLevel!==void 0&&(e=s.min(e,n.maxLevel)),ye(this.value,n,n.level,e,r,i))}getNextCost(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),s.dZero;let o=this.calculateUpgrade(t,e,r,i)[0];return n.cost(n.level.add(o))}getNextCostMax(t,e=1,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),s.dZero;let o=this.calculateUpgrade(t,e,r,i);return n.cost(n.level.add(o[0])).add(o[1])}buyUpgrade(t,e,r,i){let n=this.getUpgrade(t);if(n===null)return console.warn(`Upgrade "${t}" not found.`),!1;let[o,f]=this.calculateUpgrade(t,e,r,i);return o.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(f),n.level=n.level.add(o),this.runUpgradeEffect(n),!0)}pointerAddItem(t){let e=new vt(t);return this.pointer.items[t.id]=e,e}pointerGetItem(t){return this.pointer.items[t]??null}addItem(t,e=!0){Array.isArray(t)||(t=[t]);for(let r of t){this.pointerAddItem(r);let i=new we(r,()=>this.pointerGetItem(r.id),()=>this);e&&this.runUpgradeEffect(i),this.items[r.id]=i}}getItem(t){return this.items[t]??null}calculateItem(t,e=1/0){let r=this.getItem(t);return r===null?(console.warn(`Item "${t}" not found.`),[s.dZero,s.dZero]):be(this.value,r,e)}buyItem(t,e){let r=this.getItem(t);if(r===null)return console.warn(`Item "${t}" not found.`),!1;let[i,n]=this.calculateItem(t,e);return i.lte(0)?!1:(this.pointer.value=this.pointer.value.sub(n),r.amount=r.amount.add(i),this.runUpgradeEffect(r),!0)}},ri=ot(ft()),Lt=class{constructor(t=0){this.value=new s(t)}};st([_t(()=>s)],Lt.prototype,"value",2);var _e=class{get pointer(){return this.pointerFn()}constructor(t,e=!0,r=0){this.initial=new s(r),t??=new Lt(this.initial),this.pointerFn=typeof t=="function"?t:()=>t,this.boost=e?new zt(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}},Se=class{constructor(t,e,r={},i){this.setValue=this.set.bind(this),this.getValue=this.get.bind(this),this.x=t,this.y=e,this.properties=typeof r=="function"?{...r(this)}:{...r},this.gridSymbol=i}get grid(){return Qt.getInstance(this.gridSymbol)}set(t,e){return this.properties[t]=e,e}get(t){return this.properties[t]}translate(t=0,e=0){return Qt.getInstance(this.gridSymbol).getCell(this.x+t,this.y+e)}direction(t,e=1,r){let i=this.grid;return(()=>{switch(t){case"up":return i.getCell(this.x,this.y-e);case"right":return i.getCell(this.x+e,this.y);case"down":return i.getCell(this.x,this.y+e);case"left":return i.getCell(this.x-e,this.y);case"adjacent":return i.getAdjacent(this.x,this.y,e,r);case"diagonal":return i.getDiagonal(this.x,this.y,e,r);case"encircling":return i.getEncircling(this.x,this.y,e,r);default:throw new Error("Invalid direction")}})()}up(t=1){return this.direction("up",t)}right(t=1){return this.direction("right",t)}down(t=1){return this.direction("down",t)}left(t=1){return this.direction("left",t)}},rt=class ne extends Array{constructor(e){e=Array.isArray(e)?e:[e],e=e.filter(r=>r!==void 0),super(...e),this.removeDuplicates()}removeDuplicates(){let e=[];this.forEach((r,i)=>{this.indexOf(r)!==i&&e.push(i)}),e.forEach(r=>this.splice(r,1))}translate(e=0,r=0){return new ne(this.map(i=>i.translate(e,r)))}direction(e,r,i){return new ne(this.flatMap(n=>n.direction(e,r,i)))}up(e){return this.direction("up",e)}right(e){return this.direction("right",e)}down(e){return this.direction("down",e)}left(e){return this.direction("left",e)}adjacent(e,r){return this.direction("adjacent",e,r)}diagonal(e,r){return this.direction("diagonal",e,r)}encircling(e,r){return this.direction("encircling",e,r)}},Qt=class se{constructor(e,r,i){this.cells=[],this.gridSymbol=Symbol(),this.all=this.getAll.bind(this),this.allX=this.getAllX.bind(this),this.allY=this.getAllY.bind(this),this.get=this.getCell.bind(this),this.set=this.setCell.bind(this),se.instances[this.gridSymbol]=this,this.xSize=e,this.ySize=r??e;for(let n=0;n{let t=!1,e=r=>(t||(console.warn("The E function is deprecated. Use the Decimal class directly."),t=!0),new s(r));return Object.getOwnPropertyNames(s).filter(r=>!Object.getOwnPropertyNames(class{}).includes(r)).forEach(r=>{e[r]=s[r]}),e})(),Tr=le,Ie={};Ut(Ie,{ConfigManager:()=>kt,DataManager:()=>Ee,EventManager:()=>Te,EventTypes:()=>Oe,Game:()=>Pr,GameAttribute:()=>Pe,GameCurrency:()=>Fe,GameReset:()=>te,KeyManager:()=>Ae,gameDefaultConfig:()=>xe,keys:()=>Er});var ii=ot(ft()),kt=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}},Cr={autoAddInterval:!0,fps:30},Er="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 ".split("").concat(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]),Ae=class Ye{constructor(e){if(this.addKeys=this.addKey.bind(this),this.keysPressed=[],this.binds=[],this.tickers=[],this.config=Ye.configManager.parse(e),this.config.autoAddInterval){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)(typeof i.onDownContinuous<"u"||typeof i.fn<"u")&&this.isPressing(i.id)&&(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 kt(Cr)}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))}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)if(i.key===r)switch(e){case"down":i.onDown?.();break;case"press":default:i.onPress?.();break;case"up":i.onUp?.();break}}isPressing(e){for(let r of this.binds)if(r.id===e)return this.keysPressed.includes(r.key);return!1}getBind(e){return this.binds.find(r=>r.id===e)}addKey(e,r,i){e=typeof e=="string"?[{id:e,name:e,key:r??"",fn:i}]:e,e=Array.isArray(e)?e:[e];for(let n of e){n.id=n.id??n.name;let o=this.getBind(n.id);if(o){Object.assign(o,n);continue}this.binds.push(n)}}},Oe=(t=>(t.interval="interval",t.timeout="timeout",t))(Oe||{}),Fr={autoAddInterval:!0,fps:30},Te=class ze{constructor(e){if(this.addEvent=this.setEvent.bind(this),this.config=ze.configManager.parse(e),this.events={},this.config.autoAddInterval){let r=this.config.fps??30;this.tickerInterval=setInterval(()=>{this.tickerFunction()},1e3/r)}}static{this.configManager=new kt(Fr)}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))}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]}},ni=ot(ft()),Ce=ot(Qe()),Kt=ot(er()),Ee=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 console.warn("setStatic: Static data is basically useless and should not be used. Use variables in local scope instead."),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 console.warn("getStatic: Static data is basically useless and should not be used. Use variables in local scope instead."),this.static[t]}init(){this.normalData=this.data,this.normalDataPlain=Rt(this.data)}compileDataRaw(t=this.data){let e=Rt(t),r=(0,Kt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(e)}`),i;try{i="9.2.0"}catch{i="8.3.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,Ce.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,Ce.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,Kt.default)(`${this.gameRef.config.name.id}/${JSON.stringify(r)}`)===e;let i=e.hash,n=(0,Kt.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(c){return typeof c=="object"&&c?.constructor===Object}let n=(c,l)=>Object.prototype.hasOwnProperty.call(c,l);function o(c,l,h){if(!c||!l||!h)throw new Error("dataManager.deepMerge(): Missing arguments.");let p=h;for(let d in c)if(n(c,d)&&!n(h,d)&&(p[d]=c[d]),l[d]instanceof gt){let O=c[d],C=h[d];if(Array.isArray(C.upgrades)){let x=C.upgrades;C.upgrades={};for(let a of x)C.upgrades[a.id]=a}C.upgrades={...O.upgrades,...C.upgrades},p[d]=C,C.items={...O.items,...C.items}}else i(c[d])&&i(h[d])&&(p[d]=o(c[d],l[d],h[d]));return p}let f=e?o(this.normalDataPlain,this.normalData,r):r,m=Object.getOwnPropertyNames(new yt({id:"",level:s.dZero})),g=Object.getOwnPropertyNames(new vt({id:"",amount:s.dZero}));function u(c,l){let h=Gt(c,l);if(h instanceof gt){for(let p in h.upgrades){let d=h.upgrades[p];if(!d||!m.every(O=>Object.getOwnPropertyNames(d).includes(O))){delete h.upgrades[p];continue}h.upgrades[p]=Gt(yt,d)}for(let p in h.items){let d=h.items[p];if(!d||!g.every(O=>Object.getOwnPropertyNames(d).includes(O))){delete h.items[p];continue}h.items[p]=Gt(vt,d)}}if(!h)throw new Error(`Failed to convert ${c.name} to class instance.`);return h}function v(c,l){if(!c||!l)throw new Error("dataManager.plainToInstanceRecursive(): Missing arguments.");let h=l;for(let p in c){if(l[p]===void 0){console.warn(`Missing property "${p}" in loaded data.`);continue}if(!i(l[p]))continue;let d=c[p].constructor;if(d===Object){h[p]=v(c[p],l[p]);continue}h[p]=u(d,l[p])}return h}return f=v(this.normalData,f),f}loadData(t=this.decompileData()){if(t=typeof t=="string"?this.decompileData(t):t,!t)return null;let e=this.validateData([t[0],Rt(t[1])]),r=this.parseData(t);if(!r)return null;this.data=r;for(let i of this.eventsOnLoad)i();return e}},Fe=class extends Me{get data(){return this.pointer}get static(){return this}constructor(t,e,r){if(typeof t=="function")throw new Error("GameCurrency constructor does not accept a function as the first parameter. Use the .addCurrency method instead.");super(...t),this.game=e,this.name=r,this.game.dataManager.addEventOnLoad(()=>{this.static.onLoadData()})}},Pe=class extends _e{get data(){return this.pointer}get static(){return this}constructor(t,e){if(typeof t=="function")throw new Error("GameAttribute constructor does not accept a function as the first parameter. Use the .addAttribute method instead.");super(...t),this.game=e}},te=class Ve{static fromObject(e){return new Ve(e.currenciesToReset,e.extender,e.onReset,e.condition)}constructor(e,r,i,n){this.currenciesToReset=Array.isArray(e)?e:[e],this.extender=Array.isArray(r)?r:r?[r]:[],this.onReset=i,this.condition=n,this.id=Symbol()}reset(e=!1,r=!0,i=new Set){if(e||(typeof this.condition=="function"?!this.condition(this):!this.condition)&&typeof this.condition<"u")return;let n=()=>{this.onReset?.(this),this.currenciesToReset.forEach(o=>{o.static.reset()})};if(this.extender.length===0){n();return}this.extender.forEach(o=>{i.has(o.id)||(i.add(o.id),o.reset(r||e,r,i))}),n()}},xe={mode:"production",name:{title:"",id:"",version:"0.0.0"},settings:{framerate:30},initIntervalBasedManagers:!0},Pr=class He{static{this.configManager=new kt(xe)}constructor(e){this.config=He.configManager.parse(e),this.dataManager=new Ee(this),this.keyManager=new Ae({autoAddInterval:this.config.initIntervalBasedManagers,fps:this.config.settings.framerate}),this.eventManager=new Te({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,r=[]){return this.dataManager.setData(e,{currency:new gt}),new Fe([()=>this.dataManager.getData(e).currency,r],this,e)}addAttribute(e,r=!0,i=0){return this.dataManager.setData(e,new Lt(i)),new Pe([this.dataManager.getData(e),r,i],this)}addReset(...e){return new te(...e)}addResetFromObject(e){return te.fromObject(e)}},xr={...Tr,...Ie},Lr=xr;if(typeof ut.exports=="object"&&typeof Ot=="object"){var kr=(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};ut.exports=kr(ut.exports,Ot)}return ut.exports}); /*! Bundled license information: reflect-metadata/Reflect.js: diff --git a/dist/game/eMath.game.mjs b/dist/game/eMath.game.mjs index 30bb0e6..a9932ac 100644 --- a/dist/game/eMath.game.mjs +++ b/dist/game/eMath.game.mjs @@ -6865,7 +6865,10 @@ var DataManager = class { constructor(gameRef) { /** The current game data. */ this.data = {}; - /** The static game data. */ + /** + * The static game data. + * @deprecated Static data is basically useless and should not be used. Use variables in local scope instead. + */ this.static = {}; /** A queue of functions to call when the game data is loaded. */ this.eventsOnLoad = []; @@ -6924,11 +6927,13 @@ var DataManager = class { /** * Sets the static data for the given key. * This data is not affected by data loading and saving, and is mainly used internally. + * @deprecated Static data is basically useless and should not be used. Use variables in local scope instead. * @param key - The key to set the static data for. * @param value - The value to set the static data to. * @returns A getter for the static data. */ setStatic(key, value) { + console.warn("setStatic: Static data is basically useless and should not be used. Use variables in local scope instead."); if (typeof this.static[key] === "undefined" && this.normalData) { console.warn("After initializing data, you should not add new properties to staticData."); } @@ -6937,11 +6942,12 @@ var DataManager = class { } /** * Gets the static data for the given key. - * @deprecated Set the return value of {@link setStatic} to a variable instead, as that is a getter and provides type checking. + * @deprecated Set the return value of {@link setStatic} to a variable instead, as that is a getter and provides type checking. Also, static data is basically useless and should not be used. Use variables in local scope instead. * @param key - The key to get the static data for. * @returns The static data for the given key. */ getStatic(key) { + console.warn("getStatic: Static data is basically useless and should not be used. Use variables in local scope instead."); return this.static[key]; } /** @@ -7170,69 +7176,67 @@ var DataManager = class { }; // src/game/GameCurrency.ts -var GameCurrency = class { - /** @returns The data for the currency. */ +var GameCurrency = class extends CurrencyStatic { + /** + * @returns The data for the currency. + * @deprecated Use {@link pointer} instead. This property is only here for backwards compatibility. + */ get data() { - return this.dataPointer(); + return this.pointer; } - /** @returns The static data for the currency. */ + /** + * @returns The static data for the currency. + * @deprecated Use this class as a static class as it now has all the properties of {@link CurrencyStatic}. This property is only here for backwards compatibility. + */ get static() { - return this.staticPointer(); + return this; } /** * Creates a new instance of the game class. - * @param currencyPointer - A function that returns the current currency value. - * @param staticPointer - A function that returns the static data for the game. + * @param currencyStaticParams - The parameters for the currency static class. * @param gamePointer A pointer to the game instance. * @param name - The name of the currency. This is optional, and you can use it for display purposes. */ - constructor(currencyPointer, staticPointer, gamePointer, name) { - this.dataPointer = typeof currencyPointer === "function" ? currencyPointer : () => currencyPointer; - this.staticPointer = typeof staticPointer === "function" ? staticPointer : () => staticPointer; + constructor(currencyStaticParams, gamePointer, name) { + if (typeof currencyStaticParams === "function") { + throw new Error("GameCurrency constructor does not accept a function as the first parameter. Use the .addCurrency method instead."); + } + super(...currencyStaticParams); this.game = gamePointer; this.name = name; this.game.dataManager.addEventOnLoad(() => { this.static.onLoadData(); }); } - /** - * Gets the value of the game currency. - * Note: There is no setter for this property. To change the value of the currency, use the corresponding methods in the static class. - * @returns The value of the game currency. - */ - get value() { - return this.data.value; - } }; // src/game/GameAttribute.ts -var GameAttribute = class { +var GameAttribute = class extends AttributeStatic { /** - * Creates a new instance of the attribute class. - * @param attributePointer - A function that returns the current attribute value. - * @param staticPointer - A function that returns the static data for the attribute. - * @param gamePointer A pointer to the game instance. + * @returns The data for the attribute. + * @deprecated Use {@link pointer} instead. This property is only here for backwards compatibility. */ - constructor(attributePointer, staticPointer, gamePointer) { - this.data = typeof attributePointer === "function" ? attributePointer() : attributePointer; - this.static = typeof staticPointer === "function" ? staticPointer() : staticPointer; - this.game = gamePointer; + get data() { + return this.pointer; } /** - * Gets the value of the attribute. - * NOTE: This getter is sometimes inaccurate. - * @returns The value of the attribute. + * @returns The static data for the attribute. + * @deprecated Use this class as a static. This property is only here for backwards compatibility. */ - get value() { - return this.static.value; + get static() { + return this; } /** - * Sets the value of the attribute. - * NOTE: This setter should not be used when boost is enabled. - * @param value - The value to set the attribute to. + * Creates a new instance of the attribute class. + * @param attributeStaticParams - The parameters for the attribute static class. + * @param gamePointer A pointer to the game instance. */ - set value(value) { - this.data.value = value; + constructor(attributeStaticParams, gamePointer) { + if (typeof attributeStaticParams === "function") { + throw new Error("GameAttribute constructor does not accept a function as the first parameter. Use the .addAttribute method instead."); + } + super(...attributeStaticParams); + this.game = gamePointer; } }; @@ -7365,12 +7369,8 @@ var Game = class _Game { this.dataManager.setData(name, { currency: new Currency() }); - this.dataManager.setStatic(name, { - currency: new CurrencyStatic(() => this.dataManager.getData(name).currency, upgrades) - }); const classInstance = new GameCurrency( - () => this.dataManager.getData(name).currency, - () => this.dataManager.getStatic(name).currency, + [() => this.dataManager.getData(name).currency, upgrades], this, name ); @@ -7388,8 +7388,10 @@ var Game = class _Game { */ addAttribute(name, useBoost = true, initial = 0) { this.dataManager.setData(name, new Attribute(initial)); - this.dataManager.setStatic(name, new AttributeStatic(this.dataManager.getData(name), useBoost, initial)); - const classInstance = new GameAttribute(this.dataManager.getData(name), this.dataManager.getStatic(name), this); + const classInstance = new GameAttribute( + [this.dataManager.getData(name), useBoost, initial], + this + ); return classInstance; } /** diff --git a/dist/types/game/GameAttribute.d.ts b/dist/types/game/GameAttribute.d.ts index f491873..28b6064 100644 --- a/dist/types/game/GameAttribute.d.ts +++ b/dist/types/game/GameAttribute.d.ts @@ -1,38 +1,32 @@ /** * @file Declares the game currency class. */ -import type { Decimal } from "../E/e"; -import type { Attribute, AttributeStatic } from "../classes/Attribute"; +import type { Attribute } from "../classes/Attribute"; +import { AttributeStatic } from "../classes/Attribute"; import type { Game } from "./Game"; -import type { Pointer } from "../common/types"; /** * Represents a game attribute. {@link Attribute} is the data class and {@link AttributeStatic} is the static class where all the useful functions are. * To use, destruct the `data` and `static` properties from the class. - * WIP, not fully implemented. * @template B - Indicates whether the boost is enabled. Defaults to true. */ -declare class GameAttribute { - data: Attribute; - static: AttributeStatic; - game?: Game; +declare class GameAttribute extends AttributeStatic { /** - * Creates a new instance of the attribute class. - * @param attributePointer - A function that returns the current attribute value. - * @param staticPointer - A function that returns the static data for the attribute. - * @param gamePointer A pointer to the game instance. + * @returns The data for the attribute. + * @deprecated Use {@link pointer} instead. This property is only here for backwards compatibility. */ - constructor(attributePointer: Pointer, staticPointer: Pointer>, gamePointer?: Game); + get data(): Attribute; /** - * Gets the value of the attribute. - * NOTE: This getter is sometimes inaccurate. - * @returns The value of the attribute. + * @returns The static data for the attribute. + * @deprecated Use this class as a static. This property is only here for backwards compatibility. */ - get value(): Decimal; + get static(): this; + /** The game pointer/reference */ + game?: Game; /** - * Sets the value of the attribute. - * NOTE: This setter should not be used when boost is enabled. - * @param value - The value to set the attribute to. + * Creates a new instance of the attribute class. + * @param attributeStaticParams - The parameters for the attribute static class. + * @param gamePointer A pointer to the game instance. */ - set value(value: Decimal); + constructor(attributeStaticParams: ConstructorParameters>, gamePointer?: Game); } export { GameAttribute }; diff --git a/dist/types/game/GameCurrency.d.ts b/dist/types/game/GameCurrency.d.ts index 8bc082e..506194c 100644 --- a/dist/types/game/GameCurrency.d.ts +++ b/dist/types/game/GameCurrency.d.ts @@ -1,43 +1,41 @@ -/** - * @file Declares the game currency class. - */ -import type { Decimal } from "../E/e"; -import type { Currency, CurrencyStatic } from "../classes/Currency"; +import { CurrencyStatic } from "../classes/Currency"; +import type { Currency } from "../classes/Currency"; import type { UpgradeInit } from "../classes/Upgrade"; import type { Game } from "./Game"; -import type { Pointer } from "../common/types"; /** - * Represents a game currency. {@link Currency} is the data class and {@link CurrencyStatic} is the static class where all the useful functions are. - * To use, destruct the `data` and `static` properties from the class. + * Represents a game currency. {@link Currency} is the data class. This class extends {@link CurrencyStatic} and adds additional functionality for {@link Game}. * @template N - The name of the currency. This is optional, and you can use it for display purposes. - * @template U - The upgrade names for the currency. See {@link CurrencyStatic} for more information. + * @template U - The upgrade names for the currency. See CurrencyStatic for more information. */ -declare class GameCurrency { - /** A function that returns the data for the currency. */ - protected readonly dataPointer: () => Currency; - /** A function that returns the static data for the currency. */ - protected readonly staticPointer: () => CurrencyStatic; +declare class GameCurrency extends CurrencyStatic { + /** + * A function that returns the data for the currency. + * @deprecated Use {@link pointerFn} instead. This property is only here for backwards compatibility. + */ + /** + * A function that returns the static data for the currency. + * @deprecated Use this class as a static class as it now has all the properties of {@link CurrencyStatic}. This property is only here for backwards compatibility. + */ /** The name of the currency. This is optional, and you can use it for display purposes. */ readonly name: N; - /** @returns The data for the currency. */ + /** + * @returns The data for the currency. + * @deprecated Use {@link pointer} instead. This property is only here for backwards compatibility. + */ get data(): Currency; - /** @returns The static data for the currency. */ - get static(): CurrencyStatic; + /** + * @returns The static data for the currency. + * @deprecated Use this class as a static class as it now has all the properties of {@link CurrencyStatic}. This property is only here for backwards compatibility. + */ + get static(): this; /** The game pointer/reference */ readonly game?: Game; /** * Creates a new instance of the game class. - * @param currencyPointer - A function that returns the current currency value. - * @param staticPointer - A function that returns the static data for the game. + * @param currencyStaticParams - The parameters for the currency static class. * @param gamePointer A pointer to the game instance. * @param name - The name of the currency. This is optional, and you can use it for display purposes. */ - constructor(currencyPointer: Pointer, staticPointer: Pointer>, gamePointer: Game, name: N); - /** - * Gets the value of the game currency. - * Note: There is no setter for this property. To change the value of the currency, use the corresponding methods in the static class. - * @returns The value of the game currency. - */ - get value(): Decimal; + constructor(currencyStaticParams: ConstructorParameters>, gamePointer: Game, name: N); } export { GameCurrency }; diff --git a/dist/types/game/managers/DataManager.d.ts b/dist/types/game/managers/DataManager.d.ts index dc6b60e..19d419c 100644 --- a/dist/types/game/managers/DataManager.d.ts +++ b/dist/types/game/managers/DataManager.d.ts @@ -39,7 +39,10 @@ declare class DataManager { private normalDataPlain?; /** The current game data. */ private data; - /** The static game data. */ + /** + * The static game data. + * @deprecated Static data is basically useless and should not be used. Use variables in local scope instead. + */ private static; /** A reference to the game instance. */ private readonly gameRef; @@ -86,6 +89,7 @@ declare class DataManager { /** * Sets the static data for the given key. * This data is not affected by data loading and saving, and is mainly used internally. + * @deprecated Static data is basically useless and should not be used. Use variables in local scope instead. * @param key - The key to set the static data for. * @param value - The value to set the static data to. * @returns A getter for the static data. @@ -93,7 +97,7 @@ declare class DataManager { setStatic(key: string, value: t): t; /** * Gets the static data for the given key. - * @deprecated Set the return value of {@link setStatic} to a variable instead, as that is a getter and provides type checking. + * @deprecated Set the return value of {@link setStatic} to a variable instead, as that is a getter and provides type checking. Also, static data is basically useless and should not be used. Use variables in local scope instead. * @param key - The key to get the static data for. * @returns The static data for the given key. */ diff --git a/src/game/Game.ts b/src/game/Game.ts index 78b36e4..2e06d19 100644 --- a/src/game/Game.ts +++ b/src/game/Game.ts @@ -3,8 +3,10 @@ */ import type { DecimalSource } from "../E/e"; -import { Currency, CurrencyStatic } from "../classes/Currency"; -import { Attribute, AttributeStatic } from "../classes/Attribute"; +import type { CurrencyStatic } from "../classes/Currency"; +import { Currency } from "../classes/Currency"; +import type { AttributeStatic } from "../classes/Attribute"; +import { Attribute } from "../classes/Attribute"; import { KeyManager } from "./managers/KeyManager"; import { EventManager } from "./managers/EventManager"; import { DataManager } from "./managers/DataManager"; @@ -150,14 +152,10 @@ class Game { this.dataManager.setData(name, { currency: new Currency(), }); - this.dataManager.setStatic(name, { - currency: new CurrencyStatic(() => (this.dataManager.getData(name) as { currency: Currency }).currency, upgrades), - }); // Create the class instance const classInstance = new GameCurrency( - () => (this.dataManager.getData(name) as { currency: Currency }).currency, - () => (this.dataManager.getStatic(name) as { currency: CurrencyStatic }).currency, + [(): Currency => (this.dataManager.getData(name) as { currency: Currency }).currency, upgrades] as ConstructorParameters, this, name, ); @@ -177,9 +175,11 @@ class Game { */ public addAttribute (name: string, useBoost: B = true as B, initial: DecimalSource = 0): GameAttribute { this.dataManager.setData(name, new Attribute(initial)); - this.dataManager.setStatic(name, new AttributeStatic(this.dataManager.getData(name) as Attribute, useBoost, initial)); - const classInstance = new GameAttribute(this.dataManager.getData(name) as Attribute, this.dataManager.getStatic(name) as AttributeStatic, this); + const classInstance = new GameAttribute( + [this.dataManager.getData(name) as Attribute, useBoost, initial] as ConstructorParameters, + this, + ); return classInstance; } diff --git a/src/game/GameAttribute.ts b/src/game/GameAttribute.ts index 3362d6f..d262a07 100644 --- a/src/game/GameAttribute.ts +++ b/src/game/GameAttribute.ts @@ -1,53 +1,49 @@ /** * @file Declares the game currency class. */ - -import type { Decimal } from "../E/e"; -import type { Attribute, AttributeStatic } from "../classes/Attribute"; +import type { Attribute} from "../classes/Attribute"; +import { AttributeStatic } from "../classes/Attribute"; import type { Game } from "./Game"; -import type { Pointer } from "../common/types"; /** * Represents a game attribute. {@link Attribute} is the data class and {@link AttributeStatic} is the static class where all the useful functions are. * To use, destruct the `data` and `static` properties from the class. - * WIP, not fully implemented. * @template B - Indicates whether the boost is enabled. Defaults to true. */ -class GameAttribute { - public data: Attribute; - public static: AttributeStatic; - - public game?: Game; - +class GameAttribute extends AttributeStatic { /** - * Creates a new instance of the attribute class. - * @param attributePointer - A function that returns the current attribute value. - * @param staticPointer - A function that returns the static data for the attribute. - * @param gamePointer A pointer to the game instance. + * @returns The data for the attribute. + * @deprecated Use {@link pointer} instead. This property is only here for backwards compatibility. */ - constructor (attributePointer: Pointer, staticPointer: Pointer>, gamePointer?: Game) { - this.data = typeof attributePointer === "function" ? attributePointer() : attributePointer; - this.static = typeof staticPointer === "function" ? staticPointer() : staticPointer; - - this.game = gamePointer; + public get data (): Attribute { + return this.pointer; } /** - * Gets the value of the attribute. - * NOTE: This getter is sometimes inaccurate. - * @returns The value of the attribute. + * @returns The static data for the attribute. + * @deprecated Use this class as a static. This property is only here for backwards compatibility. */ - get value (): Decimal { - return this.static.value; + public get static (): this { + return this; } + /** The game pointer/reference */ + public game?: Game; + /** - * Sets the value of the attribute. - * NOTE: This setter should not be used when boost is enabled. - * @param value - The value to set the attribute to. + * Creates a new instance of the attribute class. + * @param attributeStaticParams - The parameters for the attribute static class. + * @param gamePointer A pointer to the game instance. */ - set value (value: Decimal) { - this.data.value = value; + constructor (attributeStaticParams: ConstructorParameters>, gamePointer?: Game) { + // "backwards compatibility" lol + if (typeof attributeStaticParams === "function") { + throw new Error("GameAttribute constructor does not accept a function as the first parameter. Use the .addAttribute method instead."); + } + + super(...attributeStaticParams); + + this.game = gamePointer; } } diff --git a/src/game/GameCurrency.ts b/src/game/GameCurrency.ts index 3fb2120..96c749d 100644 --- a/src/game/GameCurrency.ts +++ b/src/game/GameCurrency.ts @@ -2,35 +2,47 @@ * @file Declares the game currency class. */ import type { Decimal } from "../E/e"; -import type { Currency, CurrencyStatic } from "../classes/Currency"; +import { CurrencyStatic } from "../classes/Currency"; +import type { Currency } from "../classes/Currency"; import type { UpgradeInit } from "../classes/Upgrade"; import type { Game } from "./Game"; import type { Pointer } from "../common/types"; /** - * Represents a game currency. {@link Currency} is the data class and {@link CurrencyStatic} is the static class where all the useful functions are. - * To use, destruct the `data` and `static` properties from the class. + * Represents a game currency. {@link Currency} is the data class. This class extends {@link CurrencyStatic} and adds additional functionality for {@link Game}. * @template N - The name of the currency. This is optional, and you can use it for display purposes. - * @template U - The upgrade names for the currency. See {@link CurrencyStatic} for more information. + * @template U - The upgrade names for the currency. See CurrencyStatic for more information. */ -class GameCurrency { - /** A function that returns the data for the currency. */ - protected readonly dataPointer: () => Currency; +class GameCurrency extends CurrencyStatic { + /** + * A function that returns the data for the currency. + * @deprecated Use {@link pointerFn} instead. This property is only here for backwards compatibility. + */ + // private readonly dataPointer: never; - /** A function that returns the static data for the currency. */ - protected readonly staticPointer: () => CurrencyStatic; + /** + * A function that returns the static data for the currency. + * @deprecated Use this class as a static class as it now has all the properties of {@link CurrencyStatic}. This property is only here for backwards compatibility. + */ + // private readonly staticPointer: never; /** The name of the currency. This is optional, and you can use it for display purposes. */ public readonly name: N; - /** @returns The data for the currency. */ + /** + * @returns The data for the currency. + * @deprecated Use {@link pointer} instead. This property is only here for backwards compatibility. + */ get data (): Currency { - return this.dataPointer(); + return this.pointer; } - /** @returns The static data for the currency. */ - get static (): CurrencyStatic { - return this.staticPointer(); + /** + * @returns The static data for the currency. + * @deprecated Use this class as a static class as it now has all the properties of {@link CurrencyStatic}. This property is only here for backwards compatibility. + */ + get static (): this { + return this; } /** The game pointer/reference */ @@ -38,15 +50,18 @@ class GameCurrency { /** * Creates a new instance of the game class. - * @param currencyPointer - A function that returns the current currency value. - * @param staticPointer - A function that returns the static data for the game. + * @param currencyStaticParams - The parameters for the currency static class. * @param gamePointer A pointer to the game instance. * @param name - The name of the currency. This is optional, and you can use it for display purposes. */ - constructor (currencyPointer: Pointer, staticPointer: Pointer>, gamePointer: Game, name: N) { - // Set the data and static pointers - this.dataPointer = typeof currencyPointer === "function" ? currencyPointer : (): Currency => currencyPointer; - this.staticPointer = typeof staticPointer === "function" ? staticPointer : (): CurrencyStatic => staticPointer; + constructor (currencyStaticParams: ConstructorParameters>, gamePointer: Game, name: N) { + // "backwards compatibility" lol + if (typeof currencyStaticParams === "function") { + throw new Error("GameCurrency constructor does not accept a function as the first parameter. Use the .addCurrency method instead."); + } + + // Call the parent constructor + super(...currencyStaticParams); this.game = gamePointer; this.name = name; @@ -56,15 +71,6 @@ class GameCurrency { this.static.onLoadData(); }); } - - /** - * Gets the value of the game currency. - * Note: There is no setter for this property. To change the value of the currency, use the corresponding methods in the static class. - * @returns The value of the game currency. - */ - get value (): Decimal { - return this.data.value; - } } export { GameCurrency }; diff --git a/src/game/managers/DataManager.ts b/src/game/managers/DataManager.ts index 8b94bbd..197c952 100644 --- a/src/game/managers/DataManager.ts +++ b/src/game/managers/DataManager.ts @@ -56,7 +56,10 @@ class DataManager { /** The current game data. */ private data: UnknownObject = {}; - /** The static game data. */ + /** + * The static game data. + * @deprecated Static data is basically useless and should not be used. Use variables in local scope instead. + */ private static: UnknownObject = {}; /** A reference to the game instance. */ @@ -140,11 +143,14 @@ class DataManager { /** * Sets the static data for the given key. * This data is not affected by data loading and saving, and is mainly used internally. + * @deprecated Static data is basically useless and should not be used. Use variables in local scope instead. * @param key - The key to set the static data for. * @param value - The value to set the static data to. * @returns A getter for the static data. */ public setStatic (key: string, value: t): t { + console.warn("setStatic: Static data is basically useless and should not be used. Use variables in local scope instead."); + if (typeof this.static[key] === "undefined" && this.normalData) { console.warn("After initializing data, you should not add new properties to staticData."); } @@ -154,11 +160,13 @@ class DataManager { /** * Gets the static data for the given key. - * @deprecated Set the return value of {@link setStatic} to a variable instead, as that is a getter and provides type checking. + * @deprecated Set the return value of {@link setStatic} to a variable instead, as that is a getter and provides type checking. Also, static data is basically useless and should not be used. Use variables in local scope instead. * @param key - The key to get the static data for. * @returns The static data for the given key. */ public getStatic (key: string): unknown { + console.warn("getStatic: Static data is basically useless and should not be used. Use variables in local scope instead."); + return this.static[key]; }