goosefx-amm-sdk
Version:
SDK for the GooseFx AMM
1 lines • 244 kB
JavaScript
"use strict";var Zr=Object.create;var Ut=Object.defineProperty;var Xr=Object.getOwnPropertyDescriptor;var Yr=Object.getOwnPropertyNames;var Jr=Object.getPrototypeOf,Qr=Object.prototype.hasOwnProperty;var $r=(n,t)=>{for(var e in t)Ut(n,e,{get:t[e],enumerable:!0})},Co=(n,t,e,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Yr(t))!Qr.call(n,r)&&r!==e&&Ut(n,r,{get:()=>t[r],enumerable:!(o=Xr(t,r))||o.enumerable});return n};var V=(n,t,e)=>(e=n!=null?Zr(Jr(n)):{},Co(t||!n||!n.__esModule?Ut(e,"default",{value:n,enumerable:!0}):e,n)),ei=n=>Co(Ut({},"__esModule",{value:!0}),n);var js={};$r(js,{ACCOUNT_TYPE_SIZE:()=>za,ALL_PROGRAM_ID:()=>es,ANAMint:()=>Ii,API_URLS:()=>ke,AccountType:()=>mr,Api:()=>Ct,BNDivCeil:()=>Ye,BN_100:()=>ai,BN_1000:()=>si,BN_10000:()=>ui,BN_FIVE:()=>ii,BN_ONE:()=>ni,BN_TEN:()=>Se,BN_THREE:()=>ri,BN_TWO:()=>oi,BN_ZERO:()=>ge,CLOCK_PROGRAM_ID:()=>yi,CREATE_CPMM_POOL_AUTH:()=>fr,CREATE_CPMM_POOL_FEE_ACC:()=>gr,CREATE_CPMM_POOL_PROGRAM:()=>pr,ConstantProductCurve:()=>ve,CpmmCoder:()=>zr,Currency:()=>it,CurrencyAmount:()=>Le,CurveCalculator:()=>Te,DEVNET_PROGRAM_ID:()=>ts,DEV_API_URLS:()=>rs,DEV_CREATE_CPMM_POOL_AUTH:()=>yr,DEV_CREATE_CPMM_POOL_FEE_ACC:()=>br,DEV_CREATE_CPMM_POOL_PROGRAM:()=>hr,DynamicFee:()=>ze,ETHMint:()=>Mi,FEE_DESTINATION_ID:()=>$a,FEE_RATE_DENOMINATOR_VALUE:()=>le,Fraction:()=>I,GfxCpmmClient:()=>Ft,INSTRUCTION_PROGRAM_ID:()=>wi,InstructionType:()=>U,LOOKUP_TABLE_CACHE:()=>xt,LogLevel:()=>Io,Logger:()=>Wt,MAX_BASE64_SIZE:()=>Hn,MEMO_PROGRAM_ID:()=>fi,MEMO_PROGRAM_ID2:()=>gi,METADATA_PROGRAM_ID:()=>bi,NRVMint:()=>Ci,ONE_BASIS_POINT:()=>Lr,OracleBasedCurveCalculator:()=>ot,Owner:()=>ye,PAIMint:()=>Ti,Percent:()=>oe,PoolFetchTypeEnum:()=>Pr,Price:()=>ce,RAYMint:()=>_i,RENT_PROGRAM_ID:()=>hi,RoundDirection:()=>Tn,Rounding:()=>Vt,SESSION_KEY:()=>$n,SOLMint:()=>rt,SOL_INFO:()=>ue,SRMMint:()=>Pi,STORAGE_KEY:()=>ln,SYSTEM_PROGRAM_ID:()=>ki,TOKEN_WSOL:()=>de,Token:()=>te,TokenAmount:()=>se,TxBuilder:()=>vt,TxVersion:()=>Gn,USDCMint:()=>Ai,USDHMint:()=>Bi,USDTMint:()=>xi,WSOLMint:()=>ee,_100_PERCENT:()=>Kn,accountMeta:()=>jt,add:()=>Oa,addComputeBudget:()=>At,checkLegacyTxSize:()=>ut,checkV0TxSize:()=>ct,chunkArray:()=>un,closeAccountInstruction:()=>dt,commonSystemAccountMeta:()=>pi,createLogger:()=>W,createWSolAccountInstructions:()=>kn,currencyEquals:()=>Ki,decimalToFraction:()=>ir,div:()=>Ka,divCeil:()=>Ea,endlessRetry:()=>is,eq:()=>nr,fetchMultipleMintInfos:()=>Yn,findProgramAddress:()=>he,forecastTransactionSize:()=>zn,generatePubKey:()=>Kt,getATAAddress:()=>St,getCpmmPdaAmmConfigId:()=>Ts,getCpmmPdaPoolId:()=>Or,getCreatePoolKeys:()=>po,getDate:()=>Qn,getEpochInfo:()=>Ga,getMax:()=>La,getMultipleAccountsInfo:()=>cn,getMultipleAccountsInfoWithCustomFlags:()=>cr,getMultipleLookupTableInfo:()=>mn,getPdaLpMint:()=>Ps,getPdaObservationId:()=>tt,getPdaPoolAuthority:()=>pt,getPdaPoolPartners:()=>An,getPdaUserLiquidity:()=>Pn,getPdaVault:()=>lo,getRecentBlockHash:()=>Xe,getSessionKey:()=>_r,getTime:()=>dr,getTimestamp:()=>Ri,getTransferAmountFee:()=>ns,getTransferAmountFeeV2:()=>Je,gt:()=>tr,gte:()=>Ma,initTokenAccountInstruction:()=>wn,intersection:()=>ja,isDateAfter:()=>Ja,isDateBefore:()=>Ya,isDecimal:()=>ar,isMeaningfulNumber:()=>Ra,isNumber:()=>Jn,jsonInfo2PoolKeys:()=>Nn,lt:()=>Ca,lte:()=>Ia,mSOLMint:()=>vi,makeAddPartnerInstruction:()=>To,makeCalculatePartnerFeesInstruction:()=>Is,makeCalculateRewardsInstruction:()=>Bs,makeClaimPartnerFeesInstruction:()=>Ms,makeClaimRewardsInstruction:()=>Ss,makeCreateCpmmPoolInInstruction:()=>go,makeCreateRewardsInstruction:()=>vs,makeDepositCpmmInInstruction:()=>ho,makeInitUserPoolLiquidityInstruction:()=>fo,makeInitializePartnerInstruction:()=>_o,makeSwapCpmmBaseInInstruction:()=>bo,makeSwapCpmmBaseOutInstruction:()=>wo,makeSwapCpmmOracleBaseInInstruction:()=>ko,makeTransferInstruction:()=>ao,makeUpdatePartnerInstruction:()=>Cs,makeWithdrawCpmmInInstruction:()=>yo,minExpirationTime:()=>os,mul:()=>an,notInnerObject:()=>Jt,offsetDateTime:()=>Qa,parseBigNumberish:()=>Q,parseNumberInfo:()=>qe,parseSimulateLogToJson:()=>Wa,parseSimulateValue:()=>Va,parseTokenAccountResp:()=>io,parseTokenInfo:()=>Ks,printSimulate:()=>Ue,recursivelyDecimalToFraction:()=>Wn,setLoggerLevel:()=>ti,shakeFractionDecimal:()=>or,simulateMultipleInstruction:()=>Ua,simulateTransaction:()=>ur,sleep:()=>Rn,solToWSol:()=>Ce,solToWSolToken:()=>Os,splAccountLayout:()=>lt,splitNumber:()=>Bn,stSOLMint:()=>Si,sub:()=>Na,tenExponential:()=>Gt,toBN:()=>rr,toBuffer:()=>jn,toFeeConfig:()=>gt,toFraction:()=>Vn,toFractionWithDecimals:()=>Ba,toGammaApiToken:()=>ft,toPercent:()=>Fa,toToken:()=>Rs,toTokenAmount:()=>Ls,toTokenInfo:()=>Ns,toTokenPrice:()=>Da,toTotalPrice:()=>qa,toUsdCurrency:()=>Un,transformTxToBase64:()=>Ha,tryParsePublicKey:()=>Xt,unionArr:()=>zs,uniq:()=>Xa,updateReqHistory:()=>Bt,validateAndParsePublicKey:()=>Zt,wSolToSolToken:()=>Es,xor:()=>Za});module.exports=ei(js);var Tr=V(require("axios"));var Ze=require("lodash"),Io=(r=>(r[r.Error=0]="Error",r[r.Warning=1]="Warning",r[r.Info=2]="Info",r[r.Debug=3]="Debug",r))(Io||{}),Wt=class{constructor(t){this.logLevel=t.logLevel!==void 0?t.logLevel:0,this.name=t.name}set level(t){this.logLevel=t}get time(){return Date.now().toString()}get moduleName(){return this.name}isLogLevel(t){return t<=this.logLevel}error(...t){return this.isLogLevel(0)?(console.error(this.time,this.name,"sdk logger error",...t),this):this}logWithError(...t){let e=t.map(o=>typeof o=="object"?JSON.stringify(o):o).join(", ");throw new Error(e)}warning(...t){return this.isLogLevel(1)?(console.warn(this.time,this.name,"sdk logger warning",...t),this):this}info(...t){return this.isLogLevel(2)?(console.info(this.time,this.name,"sdk logger info",...t),this):this}debug(...t){return this.isLogLevel(3)?(console.debug(this.time,this.name,"sdk logger debug",...t),this):this}},vn={},Mo={};function W(n){let t=(0,Ze.get)(vn,n);if(!t){let e=(0,Ze.get)(Mo,n);t=new Wt({name:n,logLevel:e}),(0,Ze.set)(vn,n,t)}return t}function ti(n,t){(0,Ze.set)(Mo,n,t);let e=(0,Ze.get)(vn,n);e&&(e.level=t)}var Do=require("@solana/web3.js"),qo=V(require("bn.js"));var Oo=V(require("big.js")),Be=V(require("bn.js"));var ae=V(require("bn.js"));var Vt=(o=>(o[o.ROUND_DOWN=0]="ROUND_DOWN",o[o.ROUND_HALF_UP=1]="ROUND_HALF_UP",o[o.ROUND_UP=2]="ROUND_UP",o))(Vt||{}),ge=new ae.default(0),ni=new ae.default(1),oi=new ae.default(2),ri=new ae.default(3),ii=new ae.default(5),Se=new ae.default(10),ai=new ae.default(100),si=new ae.default(1e3),ui=new ae.default(1e4),Ko=9007199254740991;function Q(n){let t=W("Gfx_parseBigNumberish");if(n instanceof ae.default)return n;if(typeof n=="string"){if(n.match(/^-?[0-9]+$/))return new ae.default(n);t.logWithError(`invalid BigNumberish string: ${n}`)}return typeof n=="number"?(n%1&&t.logWithError(`BigNumberish number underflow: ${n}`),(n>=Ko||n<=-Ko)&&t.logWithError(`BigNumberish number overflow: ${n}`),new ae.default(String(n))):typeof n=="bigint"?new ae.default(n.toString()):(t.error(`invalid BigNumberish value: ${n}`),new ae.default(0))}function Gt(n){return Se.pow(Q(n))}var No=V(require("toformat")),ci=No.default,wt=ci;var kt=V(require("big.js")),Ro=V(require("bn.js")),Lo=V(require("decimal.js-light"));var Ht=W("module/fraction"),Sn=wt(kt.default),_t=wt(Lo.default),mi={[0]:_t.ROUND_DOWN,[1]:_t.ROUND_HALF_UP,[2]:_t.ROUND_UP},li={[0]:kt.default.roundDown,[1]:kt.default.roundHalfUp,[2]:kt.default.roundUp},I=class{constructor(t,e=new Ro.default(1)){this.numerator=Q(t),this.denominator=Q(e)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new I(this.denominator,this.numerator)}add(t){let e=t instanceof I?t:new I(Q(t));return this.denominator.eq(e.denominator)?new I(this.numerator.add(e.numerator),this.denominator):new I(this.numerator.mul(e.denominator).add(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}sub(t){let e=t instanceof I?t:new I(Q(t));return this.denominator.eq(e.denominator)?new I(this.numerator.sub(e.numerator),this.denominator):new I(this.numerator.mul(e.denominator).sub(e.numerator.mul(this.denominator)),this.denominator.mul(e.denominator))}mul(t){let e=t instanceof I?t:new I(Q(t));return new I(this.numerator.mul(e.numerator),this.denominator.mul(e.denominator))}div(t){let e=t instanceof I?t:new I(Q(t));return new I(this.numerator.mul(e.denominator),this.denominator.mul(e.numerator))}toSignificant(t,e={groupSeparator:""},o=1){Number.isInteger(t)||Ht.logWithError(`${t} is not an integer.`),t<=0&&Ht.logWithError(`${t} is not positive.`),_t.set({precision:t+1,rounding:mi[o]});let r=new _t(this.numerator.toString()).div(this.denominator.toString()).toSignificantDigits(t);return r.toFormat(r.decimalPlaces(),e)}toFixed(t,e={groupSeparator:""},o=1){return Number.isInteger(t)||Ht.logWithError(`${t} is not an integer.`),t<0&&Ht.logWithError(`${t} is negative.`),Sn.DP=t,Sn.RM=li[o]||1,new Sn(this.numerator.toString()).div(this.denominator.toString()).toFormat(t,e)}isZero(){return this.numerator.isZero()}};var di=W("Gfx_amount"),zt=wt(Oo.default);function Bn(n,t){let e="0",o="0";if(n.includes(".")){let r=n.split(".");r.length===2?([e,o]=r,o=o.padEnd(t,"0")):di.logWithError(`invalid number string, num: ${n}`)}else e=n;return[e,o.slice(0,t)||o]}var se=class extends I{constructor(e,o,r=!0,i){let a=new Be.default(0),s=Se.pow(new Be.default(e.decimals));if(r)a=Q(o);else{let u=new Be.default(0),c=new Be.default(0);if(typeof o=="string"||typeof o=="number"||typeof o=="bigint"){let[m,l]=Bn(o.toString(),e.decimals);u=Q(m),c=Q(l)}u=u.mul(s),a=u.add(c)}super(a,s);this.logger=W(i||"TokenAmount"),this.token=e}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(e){return this.token.equals(e.token)||this.logger.logWithError("gt token not equals"),this.raw.gt(e.raw)}lt(e){return this.token.equals(e.token)||this.logger.logWithError("lt token not equals"),this.raw.lt(e.raw)}add(e){return this.token.equals(e.token)||this.logger.logWithError("add token not equals"),new se(this.token,this.raw.add(e.raw))}subtract(e){return this.token.equals(e.token)||this.logger.logWithError("sub token not equals"),new se(this.token,this.raw.sub(e.raw))}toSignificant(e=this.token.decimals,o,r=0){return super.toSignificant(e,o,r)}toFixed(e=this.token.decimals,o,r=0){return e>this.token.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(e,o,r)}toExact(e={groupSeparator:""}){return zt.DP=this.token.decimals,new zt(this.numerator.toString()).div(this.denominator.toString()).toFormat(e)}},Le=class extends I{constructor(e,o,r=!0,i){let a=new Be.default(0),s=Se.pow(new Be.default(e.decimals));if(r)a=Q(o);else{let u=new Be.default(0),c=new Be.default(0);if(typeof o=="string"||typeof o=="number"||typeof o=="bigint"){let[m,l]=Bn(o.toString(),e.decimals);u=Q(m),c=Q(l)}u=u.mul(s),a=u.add(c)}super(a,s);this.logger=W(i||"TokenAmount"),this.currency=e}get raw(){return this.numerator}isZero(){return this.raw.isZero()}gt(e){return this.currency.equals(e.currency)||this.logger.logWithError("gt currency not equals"),this.raw.gt(e.raw)}lt(e){return this.currency.equals(e.currency)||this.logger.logWithError("lt currency not equals"),this.raw.lt(e.raw)}add(e){return this.currency.equals(e.currency)||this.logger.logWithError("add currency not equals"),new Le(this.currency,this.raw.add(e.raw))}sub(e){return this.currency.equals(e.currency)||this.logger.logWithError("sub currency not equals"),new Le(this.currency,this.raw.sub(e.raw))}toSignificant(e=this.currency.decimals,o,r=0){return super.toSignificant(e,o,r)}toFixed(e=this.currency.decimals,o,r=0){return e>this.currency.decimals&&this.logger.logWithError("decimals overflow"),super.toFixed(e,o,r)}toExact(e={groupSeparator:""}){return zt.DP=this.currency.decimals,new zt(this.numerator.toString()).div(this.denominator.toString()).toFormat(e)}};var Cn=require("@solana/spl-token"),ue={address:"So11111111111111111111111111111111111111112",programId:Cn.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"SOL",name:"solana",logoURI:"",tags:[],priority:2,type:"goose-fx",extensions:{coingeckoId:"solana"}},de={address:"So11111111111111111111111111111111111111112",programId:Cn.TOKEN_PROGRAM_ID.toBase58(),decimals:9,symbol:"WSOL",name:"Wrapped SOL",logoURI:"",tags:[],priority:2,type:"goose-fx",extensions:{coingeckoId:"solana"}};var Yt=require("@solana/web3.js");var Eo=require("@solana/spl-token"),O=require("@solana/web3.js");function jt({pubkey:n,isSigner:t=!1,isWritable:e=!0}){return{pubkey:n,isWritable:e,isSigner:t}}var pi=[jt({pubkey:Eo.TOKEN_PROGRAM_ID,isWritable:!1}),jt({pubkey:O.SystemProgram.programId,isWritable:!1}),jt({pubkey:O.SYSVAR_RENT_PUBKEY,isWritable:!1})];function Zt({publicKey:n,transformSol:t}){let e=Xt(n.toString());if(e instanceof O.PublicKey)return t&&e.equals(rt)?ee:e;if(t&&e.toString()===rt.toBase58())return ee;if(typeof e=="string"){if(e===O.PublicKey.default.toBase58())return O.PublicKey.default;try{return new O.PublicKey(e)}catch{throw new Error("invalid public key")}}throw new Error("invalid public key")}function Xt(n){try{return new O.PublicKey(n)}catch{return n}}var fi=new O.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),gi=new O.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),hi=new O.PublicKey("SysvarRent111111111111111111111111111111111"),yi=new O.PublicKey("SysvarC1ock11111111111111111111111111111111"),bi=new O.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),wi=new O.PublicKey("Sysvar1nstructions1111111111111111111111111"),ki=O.SystemProgram.programId,_i=new O.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Ti=new O.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),Pi=new O.PublicKey("SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt"),Ai=new O.PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),xi=new O.PublicKey("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"),vi=new O.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"),Si=new O.PublicKey("7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj"),Bi=new O.PublicKey("USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX"),Ci=new O.PublicKey("NRVwhjBQiUPYtfDT5zRBVJajzFQHaBUNtC7SNVvqRFa"),Ii=new O.PublicKey("ANAxByE6G2WjFp7A4NqtWYXb3mgruyzZYg3spfxe6Lbo"),Mi=new O.PublicKey("7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs"),ee=new O.PublicKey("So11111111111111111111111111111111111111112"),rt=O.PublicKey.default;function Ce(n){return Zt({publicKey:n,transformSol:!0})}var In=class{constructor({mint:t,decimals:e,symbol:o,name:r,skipMint:i=!1,isToken2022:a=!1}){if(t===rt.toBase58()||t instanceof Yt.PublicKey&&rt.equals(t)){this.decimals=de.decimals,this.symbol=de.symbol,this.name=de.name,this.mint=new Yt.PublicKey(de.address),this.isToken2022=!1;return}this.decimals=e,this.symbol=o||t.toString().substring(0,6),this.name=r||t.toString().substring(0,6),this.mint=i?Yt.PublicKey.default:Zt({publicKey:t}),this.isToken2022=a}equals(t){return this===t?!0:this.mint.equals(t.mint)}},te=In;te.WSOL=new In({...de,mint:de.address});var Mn=class{constructor({decimals:t,symbol:e="UNKNOWN",name:o="UNKNOWN"}){this.decimals=t,this.symbol=e,this.name=o}equals(t){return this===t}},it=Mn;it.SOL=new Mn(ue);function Ki(n,t){return n instanceof te&&t instanceof te?n.equals(t):n instanceof te||t instanceof te?!1:n===t}var Fo=V(require("bn.js"));var Kn=new I(new Fo.default(100)),oe=class extends I{toSignificant(t=5,e,o){return this.mul(Kn).toSignificant(t,e,o)}toFixed(t=2,e,o){return this.mul(Kn).toFixed(t,e,o)}};var Ni=W("Ray_price"),ce=class extends I{constructor(e){let{baseToken:o,quoteToken:r,numerator:i,denominator:a}=e;super(i,a);this.baseToken=o,this.quoteToken=r,this.scalar=new I(Gt(o.decimals),Gt(r.decimals))}get raw(){return new I(this.numerator,this.denominator)}get adjusted(){return super.mul(this.scalar)}invert(){return new ce({baseToken:this.quoteToken,quoteToken:this.baseToken,denominator:this.numerator,numerator:this.denominator})}mul(e){this.quoteToken!==e.baseToken&&Ni.logWithError("mul token not equals");let o=super.mul(e);return new ce({baseToken:this.baseToken,quoteToken:e.quoteToken,denominator:o.denominator,numerator:o.numerator})}toSignificant(e=this.quoteToken.decimals,o,r){return this.adjusted.toSignificant(e,o,r)}toFixed(e=this.quoteToken.decimals,o,r){return this.adjusted.toFixed(e,o,r)}};async function Rn(n){new Promise(t=>setTimeout(t,n))}function Ri(){return new Date().getTime()}function Jt(n){return typeof n=="object"&&n!==null&&![te,se,Do.PublicKey,I,qo.default,ce,oe].some(t=>typeof t=="object"&&n instanceof t)}function Nn(n){return typeof n=="string"?Xt(n):Array.isArray(n)?n.map(t=>Nn(t)):Jt(n)?Object.fromEntries(Object.entries(n).map(([t,e])=>[t,Nn(e)])):n}var pe=V(require("bn.js"));var at=9e15,De=1e9,Ln="0123456789abcdef",$t="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",en="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",On={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-at,maxE:at,crypto:!1},Go,Ie,M=!0,nn="[DecimalError] ",Fe=nn+"Invalid argument: ",Ho=nn+"Precision limit exceeded",zo=nn+"crypto unavailable",jo="[object Decimal]",re=Math.floor,Y=Math.pow,Li=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Oi=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ei=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Zo=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,we=1e7,C=7,Fi=9007199254740991,Di=$t.length-1,En=en.length-1,k={toStringTag:jo};k.absoluteValue=k.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),S(n)};k.ceil=function(){return S(new this.constructor(this),this.e+1,2)};k.clampedTo=k.clamp=function(n,t){var e,o=this,r=o.constructor;if(n=new r(n),t=new r(t),!n.s||!t.s)return new r(NaN);if(n.gt(t))throw Error(Fe+t);return e=o.cmp(n),e<0?n:o.cmp(t)>0?t:new r(o)};k.comparedTo=k.cmp=function(n){var t,e,o,r,i=this,a=i.d,s=(n=new i.constructor(n)).d,u=i.s,c=n.s;if(!a||!s)return!u||!c?NaN:u!==c?u:a===s?0:!a^u<0?1:-1;if(!a[0]||!s[0])return a[0]?u:s[0]?-c:0;if(u!==c)return u;if(i.e!==n.e)return i.e>n.e^u<0?1:-1;for(o=a.length,r=s.length,t=0,e=o<r?o:r;t<e;++t)if(a[t]!==s[t])return a[t]>s[t]^u<0?1:-1;return o===r?0:o>r^u<0?1:-1};k.cosine=k.cos=function(){var n,t,e=this,o=e.constructor;return e.d?e.d[0]?(n=o.precision,t=o.rounding,o.precision=n+Math.max(e.e,e.sd())+C,o.rounding=1,e=qi(o,$o(o,e)),o.precision=n,o.rounding=t,S(Ie==2||Ie==3?e.neg():e,n,t,!0)):new o(1):new o(NaN)};k.cubeRoot=k.cbrt=function(){var n,t,e,o,r,i,a,s,u,c,m=this,l=m.constructor;if(!m.isFinite()||m.isZero())return new l(m);for(M=!1,i=m.s*Y(m.s*m,1/3),!i||Math.abs(i)==1/0?(e=ne(m.d),n=m.e,(i=(n-e.length+1)%3)&&(e+=i==1||i==-2?"0":"00"),i=Y(e,1/3),n=re((n+1)/3)-(n%3==(n<0?-1:2)),i==1/0?e="5e"+n:(e=i.toExponential(),e=e.slice(0,e.indexOf("e")+1)+n),o=new l(e),o.s=m.s):o=new l(i.toString()),a=(n=l.precision)+3;;)if(s=o,u=s.times(s).times(s),c=u.plus(m),o=q(c.plus(m).times(s),c.plus(u),a+2,1),ne(s.d).slice(0,a)===(e=ne(o.d)).slice(0,a))if(e=e.slice(a-3,a+1),e=="9999"||!r&&e=="4999"){if(!r&&(S(s,n+1,0),s.times(s).times(s).eq(m))){o=s;break}a+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(S(o,n+1,1),t=!o.times(o).times(o).eq(m));break}return M=!0,S(o,n,l.rounding,t)};k.decimalPlaces=k.dp=function(){var n,t=this.d,e=NaN;if(t){if(n=t.length-1,e=(n-re(this.e/C))*C,n=t[n],n)for(;n%10==0;n/=10)e--;e<0&&(e=0)}return e};k.dividedBy=k.div=function(n){return q(this,new this.constructor(n))};k.dividedToIntegerBy=k.divToInt=function(n){var t=this,e=t.constructor;return S(q(t,new e(n),0,1,1),e.precision,e.rounding)};k.equals=k.eq=function(n){return this.cmp(n)===0};k.floor=function(){return S(new this.constructor(this),this.e+1,3)};k.greaterThan=k.gt=function(n){return this.cmp(n)>0};k.greaterThanOrEqualTo=k.gte=function(n){var t=this.cmp(n);return t==1||t===0};k.hyperbolicCosine=k.cosh=function(){var n,t,e,o,r,i=this,a=i.constructor,s=new a(1);if(!i.isFinite())return new a(i.s?1/0:NaN);if(i.isZero())return s;e=a.precision,o=a.rounding,a.precision=e+Math.max(i.e,i.sd())+4,a.rounding=1,r=i.d.length,r<32?(n=Math.ceil(r/3),t=(1/rn(4,n)).toString()):(n=16,t="2.3283064365386962890625e-10"),i=st(a,1,i.times(t),new a(1),!0);for(var u,c=n,m=new a(8);c--;)u=i.times(i),i=s.minus(u.times(m.minus(u.times(m))));return S(i,a.precision=e,a.rounding=o,!0)};k.hyperbolicSine=k.sinh=function(){var n,t,e,o,r=this,i=r.constructor;if(!r.isFinite()||r.isZero())return new i(r);if(t=i.precision,e=i.rounding,i.precision=t+Math.max(r.e,r.sd())+4,i.rounding=1,o=r.d.length,o<3)r=st(i,2,r,r,!0);else{n=1.4*Math.sqrt(o),n=n>16?16:n|0,r=r.times(1/rn(5,n)),r=st(i,2,r,r,!0);for(var a,s=new i(5),u=new i(16),c=new i(20);n--;)a=r.times(r),r=r.times(s.plus(a.times(u.times(a).plus(c))))}return i.precision=t,i.rounding=e,S(r,t,e,!0)};k.hyperbolicTangent=k.tanh=function(){var n,t,e=this,o=e.constructor;return e.isFinite()?e.isZero()?new o(e):(n=o.precision,t=o.rounding,o.precision=n+7,o.rounding=1,q(e.sinh(),e.cosh(),o.precision=n,o.rounding=t)):new o(e.s)};k.inverseCosine=k.acos=function(){var n,t=this,e=t.constructor,o=t.abs().cmp(1),r=e.precision,i=e.rounding;return o!==-1?o===0?t.isNeg()?be(e,r,i):new e(0):new e(NaN):t.isZero()?be(e,r+4,i).times(.5):(e.precision=r+6,e.rounding=1,t=t.asin(),n=be(e,r+4,i).times(.5),e.precision=r,e.rounding=i,n.minus(t))};k.inverseHyperbolicCosine=k.acosh=function(){var n,t,e=this,o=e.constructor;return e.lte(1)?new o(e.eq(1)?0:NaN):e.isFinite()?(n=o.precision,t=o.rounding,o.precision=n+Math.max(Math.abs(e.e),e.sd())+4,o.rounding=1,M=!1,e=e.times(e).minus(1).sqrt().plus(e),M=!0,o.precision=n,o.rounding=t,e.ln()):new o(e)};k.inverseHyperbolicSine=k.asinh=function(){var n,t,e=this,o=e.constructor;return!e.isFinite()||e.isZero()?new o(e):(n=o.precision,t=o.rounding,o.precision=n+2*Math.max(Math.abs(e.e),e.sd())+6,o.rounding=1,M=!1,e=e.times(e).plus(1).sqrt().plus(e),M=!0,o.precision=n,o.rounding=t,e.ln())};k.inverseHyperbolicTangent=k.atanh=function(){var n,t,e,o,r=this,i=r.constructor;return r.isFinite()?r.e>=0?new i(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=i.precision,t=i.rounding,o=r.sd(),Math.max(o,n)<2*-r.e-1?S(new i(r),n,t,!0):(i.precision=e=o-r.e,r=q(r.plus(1),new i(1).minus(r),e+n,1),i.precision=n+4,i.rounding=1,r=r.ln(),i.precision=n,i.rounding=t,r.times(.5))):new i(NaN)};k.inverseSine=k.asin=function(){var n,t,e,o,r=this,i=r.constructor;return r.isZero()?new i(r):(t=r.abs().cmp(1),e=i.precision,o=i.rounding,t!==-1?t===0?(n=be(i,e+4,o).times(.5),n.s=r.s,n):new i(NaN):(i.precision=e+6,i.rounding=1,r=r.div(new i(1).minus(r.times(r)).sqrt().plus(1)).atan(),i.precision=e,i.rounding=o,r.times(2)))};k.inverseTangent=k.atan=function(){var n,t,e,o,r,i,a,s,u,c=this,m=c.constructor,l=m.precision,d=m.rounding;if(c.isFinite()){if(c.isZero())return new m(c);if(c.abs().eq(1)&&l+4<=En)return a=be(m,l+4,d).times(.25),a.s=c.s,a}else{if(!c.s)return new m(NaN);if(l+4<=En)return a=be(m,l+4,d).times(.5),a.s=c.s,a}for(m.precision=s=l+10,m.rounding=1,e=Math.min(28,s/C+2|0),n=e;n;--n)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(M=!1,t=Math.ceil(s/C),o=1,u=c.times(c),a=new m(c),r=c;n!==-1;)if(r=r.times(u),i=a.minus(r.div(o+=2)),r=r.times(u),a=i.plus(r.div(o+=2)),a.d[t]!==void 0)for(n=t;a.d[n]===i.d[n]&&n--;);return e&&(a=a.times(2<<e-1)),M=!0,S(a,m.precision=l,m.rounding=d,!0)};k.isFinite=function(){return!!this.d};k.isInteger=k.isInt=function(){return!!this.d&&re(this.e/C)>this.d.length-2};k.isNaN=function(){return!this.s};k.isNegative=k.isNeg=function(){return this.s<0};k.isPositive=k.isPos=function(){return this.s>0};k.isZero=function(){return!!this.d&&this.d[0]===0};k.lessThan=k.lt=function(n){return this.cmp(n)<0};k.lessThanOrEqualTo=k.lte=function(n){return this.cmp(n)<1};k.logarithm=k.log=function(n){var t,e,o,r,i,a,s,u,c=this,m=c.constructor,l=m.precision,d=m.rounding,p=5;if(n==null)n=new m(10),t=!0;else{if(n=new m(n),e=n.d,n.s<0||!e||!e[0]||n.eq(1))return new m(NaN);t=n.eq(10)}if(e=c.d,c.s<0||!e||!e[0]||c.eq(1))return new m(e&&!e[0]?-1/0:c.s!=1?NaN:e?0:1/0);if(t)if(e.length>1)i=!0;else{for(r=e[0];r%10===0;)r/=10;i=r!==1}if(M=!1,s=l+p,a=Ee(c,s),o=t?tn(m,s+10):Ee(n,s),u=q(a,o,s,1),Tt(u.d,r=l,d))do if(s+=10,a=Ee(c,s),o=t?tn(m,s+10):Ee(n,s),u=q(a,o,s,1),!i){+ne(u.d).slice(r+1,r+15)+1==1e14&&(u=S(u,l+1,0));break}while(Tt(u.d,r+=10,d));return M=!0,S(u,l,d)};k.minus=k.sub=function(n){var t,e,o,r,i,a,s,u,c,m,l,d,p=this,h=p.constructor;if(n=new h(n),!p.d||!n.d)return!p.s||!n.s?n=new h(NaN):p.d?n.s=-n.s:n=new h(n.d||p.s!==n.s?p:NaN),n;if(p.s!=n.s)return n.s=-n.s,p.plus(n);if(c=p.d,d=n.d,s=h.precision,u=h.rounding,!c[0]||!d[0]){if(d[0])n.s=-n.s;else if(c[0])n=new h(p);else return new h(u===3?-0:0);return M?S(n,s,u):n}if(e=re(n.e/C),m=re(p.e/C),c=c.slice(),i=m-e,i){for(l=i<0,l?(t=c,i=-i,a=d.length):(t=d,e=m,a=c.length),o=Math.max(Math.ceil(s/C),a)+2,i>o&&(i=o,t.length=1),t.reverse(),o=i;o--;)t.push(0);t.reverse()}else{for(o=c.length,a=d.length,l=o<a,l&&(a=o),o=0;o<a;o++)if(c[o]!=d[o]){l=c[o]<d[o];break}i=0}for(l&&(t=c,c=d,d=t,n.s=-n.s),a=c.length,o=d.length-a;o>0;--o)c[a++]=0;for(o=d.length;o>i;){if(c[--o]<d[o]){for(r=o;r&&c[--r]===0;)c[r]=we-1;--c[r],c[o]+=we}c[o]-=d[o]}for(;c[--a]===0;)c.pop();for(;c[0]===0;c.shift())--e;return c[0]?(n.d=c,n.e=on(c,e),M?S(n,s,u):n):new h(u===3?-0:0)};k.modulo=k.mod=function(n){var t,e=this,o=e.constructor;return n=new o(n),!e.d||!n.s||n.d&&!n.d[0]?new o(NaN):!n.d||e.d&&!e.d[0]?S(new o(e),o.precision,o.rounding):(M=!1,o.modulo==9?(t=q(e,n.abs(),0,3,1),t.s*=n.s):t=q(e,n,0,o.modulo,1),t=t.times(n),M=!0,e.minus(t))};k.naturalExponential=k.exp=function(){return Fn(this)};k.naturalLogarithm=k.ln=function(){return Ee(this)};k.negated=k.neg=function(){var n=new this.constructor(this);return n.s=-n.s,S(n)};k.plus=k.add=function(n){var t,e,o,r,i,a,s,u,c,m,l=this,d=l.constructor;if(n=new d(n),!l.d||!n.d)return!l.s||!n.s?n=new d(NaN):l.d||(n=new d(n.d||l.s===n.s?l:NaN)),n;if(l.s!=n.s)return n.s=-n.s,l.minus(n);if(c=l.d,m=n.d,s=d.precision,u=d.rounding,!c[0]||!m[0])return m[0]||(n=new d(l)),M?S(n,s,u):n;if(i=re(l.e/C),o=re(n.e/C),c=c.slice(),r=i-o,r){for(r<0?(e=c,r=-r,a=m.length):(e=m,o=i,a=c.length),i=Math.ceil(s/C),a=i>a?i+1:a+1,r>a&&(r=a,e.length=1),e.reverse();r--;)e.push(0);e.reverse()}for(a=c.length,r=m.length,a-r<0&&(r=a,e=m,m=c,c=e),t=0;r;)t=(c[--r]=c[r]+m[r]+t)/we|0,c[r]%=we;for(t&&(c.unshift(t),++o),a=c.length;c[--a]==0;)c.pop();return n.d=c,n.e=on(c,o),M?S(n,s,u):n};k.precision=k.sd=function(n){var t,e=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(Fe+n);return e.d?(t=Xo(e.d),n&&e.e+1>t&&(t=e.e+1)):t=NaN,t};k.round=function(){var n=this,t=n.constructor;return S(new t(n),n.e+1,t.rounding)};k.sine=k.sin=function(){var n,t,e=this,o=e.constructor;return e.isFinite()?e.isZero()?new o(e):(n=o.precision,t=o.rounding,o.precision=n+Math.max(e.e,e.sd())+C,o.rounding=1,e=Wi(o,$o(o,e)),o.precision=n,o.rounding=t,S(Ie>2?e.neg():e,n,t,!0)):new o(NaN)};k.squareRoot=k.sqrt=function(){var n,t,e,o,r,i,a=this,s=a.d,u=a.e,c=a.s,m=a.constructor;if(c!==1||!s||!s[0])return new m(!c||c<0&&(!s||s[0])?NaN:s?a:1/0);for(M=!1,c=Math.sqrt(+a),c==0||c==1/0?(t=ne(s),(t.length+u)%2==0&&(t+="0"),c=Math.sqrt(t),u=re((u+1)/2)-(u<0||u%2),c==1/0?t="5e"+u:(t=c.toExponential(),t=t.slice(0,t.indexOf("e")+1)+u),o=new m(t)):o=new m(c.toString()),e=(u=m.precision)+3;;)if(i=o,o=i.plus(q(a,i,e+2,1)).times(.5),ne(i.d).slice(0,e)===(t=ne(o.d)).slice(0,e))if(t=t.slice(e-3,e+1),t=="9999"||!r&&t=="4999"){if(!r&&(S(i,u+1,0),i.times(i).eq(a))){o=i;break}e+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(S(o,u+1,1),n=!o.times(o).eq(a));break}return M=!0,S(o,u,m.rounding,n)};k.tangent=k.tan=function(){var n,t,e=this,o=e.constructor;return e.isFinite()?e.isZero()?new o(e):(n=o.precision,t=o.rounding,o.precision=n+10,o.rounding=1,e=e.sin(),e.s=1,e=q(e,new o(1).minus(e.times(e)).sqrt(),n+10,0),o.precision=n,o.rounding=t,S(Ie==2||Ie==4?e.neg():e,n,t,!0)):new o(NaN)};k.times=k.mul=function(n){var t,e,o,r,i,a,s,u,c,m=this,l=m.constructor,d=m.d,p=(n=new l(n)).d;if(n.s*=m.s,!d||!d[0]||!p||!p[0])return new l(!n.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?n.s/0:n.s*0);for(e=re(m.e/C)+re(n.e/C),u=d.length,c=p.length,u<c&&(i=d,d=p,p=i,a=u,u=c,c=a),i=[],a=u+c,o=a;o--;)i.push(0);for(o=c;--o>=0;){for(t=0,r=u+o;r>o;)s=i[r]+p[o]*d[r-o-1]+t,i[r--]=s%we|0,t=s/we|0;i[r]=(i[r]+t)%we|0}for(;!i[--a];)i.pop();return t?++e:i.shift(),n.d=i,n.e=on(i,e),M?S(n,l.precision,l.rounding):n};k.toBinary=function(n,t){return qn(this,2,n,t)};k.toDecimalPlaces=k.toDP=function(n,t){var e=this,o=e.constructor;return e=new o(e),n===void 0?e:(me(n,0,De),t===void 0?t=o.rounding:me(t,0,8),S(e,n+e.e+1,t))};k.toExponential=function(n,t){var e,o=this,r=o.constructor;return n===void 0?e=Ae(o,!0):(me(n,0,De),t===void 0?t=r.rounding:me(t,0,8),o=S(new r(o),n+1,t),e=Ae(o,!0,n+1)),o.isNeg()&&!o.isZero()?"-"+e:e};k.toFixed=function(n,t){var e,o,r=this,i=r.constructor;return n===void 0?e=Ae(r):(me(n,0,De),t===void 0?t=i.rounding:me(t,0,8),o=S(new i(r),n+r.e+1,t),e=Ae(o,!1,n+o.e+1)),r.isNeg()&&!r.isZero()?"-"+e:e};k.toFraction=function(n){var t,e,o,r,i,a,s,u,c,m,l,d,p=this,h=p.d,f=p.constructor;if(!h)return new f(p);if(c=e=new f(1),o=u=new f(0),t=new f(o),i=t.e=Xo(h)-p.e-1,a=i%C,t.d[0]=Y(10,a<0?C+a:a),n==null)n=i>0?t:c;else{if(s=new f(n),!s.isInt()||s.lt(c))throw Error(Fe+s);n=s.gt(t)?i>0?t:c:s}for(M=!1,s=new f(ne(h)),m=f.precision,f.precision=i=h.length*C*2;l=q(s,t,0,1,1),r=e.plus(l.times(o)),r.cmp(n)!=1;)e=o,o=r,r=c,c=u.plus(l.times(r)),u=r,r=t,t=s.minus(l.times(r)),s=r;return r=q(n.minus(e),o,0,1,1),u=u.plus(r.times(c)),e=e.plus(r.times(o)),u.s=c.s=p.s,d=q(c,o,i,1).minus(p).abs().cmp(q(u,e,i,1).minus(p).abs())<1?[c,o]:[u,e],f.precision=m,M=!0,d};k.toHexadecimal=k.toHex=function(n,t){return qn(this,16,n,t)};k.toNearest=function(n,t){var e=this,o=e.constructor;if(e=new o(e),n==null){if(!e.d)return e;n=new o(1),t=o.rounding}else{if(n=new o(n),t===void 0?t=o.rounding:me(t,0,8),!e.d)return n.s?e:n;if(!n.d)return n.s&&(n.s=e.s),n}return n.d[0]?(M=!1,e=q(e,n,0,t,1).times(n),M=!0,S(e)):(n.s=e.s,e=n),e};k.toNumber=function(){return+this};k.toOctal=function(n,t){return qn(this,8,n,t)};k.toPower=k.pow=function(n){var t,e,o,r,i,a,s=this,u=s.constructor,c=+(n=new u(n));if(!s.d||!n.d||!s.d[0]||!n.d[0])return new u(Y(+s,c));if(s=new u(s),s.eq(1))return s;if(o=u.precision,i=u.rounding,n.eq(1))return S(s,o,i);if(t=re(n.e/C),t>=n.d.length-1&&(e=c<0?-c:c)<=Fi)return r=Yo(u,s,e,o),n.s<0?new u(1).div(r):S(r,o,i);if(a=s.s,a<0){if(t<n.d.length-1)return new u(NaN);if((n.d[t]&1)==0&&(a=1),s.e==0&&s.d[0]==1&&s.d.length==1)return s.s=a,s}return e=Y(+s,c),t=e==0||!isFinite(e)?re(c*(Math.log("0."+ne(s.d))/Math.LN10+s.e+1)):new u(e+"").e,t>u.maxE+1||t<u.minE-1?new u(t>0?a/0:0):(M=!1,u.rounding=s.s=1,e=Math.min(12,(t+"").length),r=Fn(n.times(Ee(s,o+e)),o),r.d&&(r=S(r,o+5,1),Tt(r.d,o,i)&&(t=o+10,r=S(Fn(n.times(Ee(s,t+e)),t),t+5,1),+ne(r.d).slice(o+1,o+15)+1==1e14&&(r=S(r,o+1,0)))),r.s=a,M=!0,u.rounding=i,S(r,o,i))};k.toPrecision=function(n,t){var e,o=this,r=o.constructor;return n===void 0?e=Ae(o,o.e<=r.toExpNeg||o.e>=r.toExpPos):(me(n,1,De),t===void 0?t=r.rounding:me(t,0,8),o=S(new r(o),n,t),e=Ae(o,n<=o.e||o.e<=r.toExpNeg,n)),o.isNeg()&&!o.isZero()?"-"+e:e};k.toSignificantDigits=k.toSD=function(n,t){var e=this,o=e.constructor;return n===void 0?(n=o.precision,t=o.rounding):(me(n,1,De),t===void 0?t=o.rounding:me(t,0,8)),S(new o(e),n,t)};k.toString=function(){var n=this,t=n.constructor,e=Ae(n,n.e<=t.toExpNeg||n.e>=t.toExpPos);return n.isNeg()&&!n.isZero()?"-"+e:e};k.truncated=k.trunc=function(){return S(new this.constructor(this),this.e+1,1)};k.valueOf=k.toJSON=function(){var n=this,t=n.constructor,e=Ae(n,n.e<=t.toExpNeg||n.e>=t.toExpPos);return n.isNeg()?"-"+e:e};function ne(n){var t,e,o,r=n.length-1,i="",a=n[0];if(r>0){for(i+=a,t=1;t<r;t++)o=n[t]+"",e=C-o.length,e&&(i+=Oe(e)),i+=o;a=n[t],o=a+"",e=C-o.length,e&&(i+=Oe(e))}else if(a===0)return"0";for(;a%10===0;)a/=10;return i+a}function me(n,t,e){if(n!==~~n||n<t||n>e)throw Error(Fe+n)}function Tt(n,t,e,o){var r,i,a,s;for(i=n[0];i>=10;i/=10)--t;return--t<0?(t+=C,r=0):(r=Math.ceil((t+1)/C),t%=C),i=Y(10,C-t),s=n[r]%i|0,o==null?t<3?(t==0?s=s/100|0:t==1&&(s=s/10|0),a=e<4&&s==99999||e>3&&s==49999||s==5e4||s==0):a=(e<4&&s+1==i||e>3&&s+1==i/2)&&(n[r+1]/i/100|0)==Y(10,t-2)-1||(s==i/2||s==0)&&(n[r+1]/i/100|0)==0:t<4?(t==0?s=s/1e3|0:t==1?s=s/100|0:t==2&&(s=s/10|0),a=(o||e<4)&&s==9999||!o&&e>3&&s==4999):a=((o||e<4)&&s+1==i||!o&&e>3&&s+1==i/2)&&(n[r+1]/i/1e3|0)==Y(10,t-3)-1,a}function Qt(n,t,e){for(var o,r=[0],i,a=0,s=n.length;a<s;){for(i=r.length;i--;)r[i]*=t;for(r[0]+=Ln.indexOf(n.charAt(a++)),o=0;o<r.length;o++)r[o]>e-1&&(r[o+1]===void 0&&(r[o+1]=0),r[o+1]+=r[o]/e|0,r[o]%=e)}return r.reverse()}function qi(n,t){var e,o,r;if(t.isZero())return t;o=t.d.length,o<32?(e=Math.ceil(o/3),r=(1/rn(4,e)).toString()):(e=16,r="2.3283064365386962890625e-10"),n.precision+=e,t=st(n,1,t.times(r),new n(1));for(var i=e;i--;){var a=t.times(t);t=a.times(a).minus(a).times(8).plus(1)}return n.precision-=e,t}var q=function(){function n(o,r,i){var a,s=0,u=o.length;for(o=o.slice();u--;)a=o[u]*r+s,o[u]=a%i|0,s=a/i|0;return s&&o.unshift(s),o}function t(o,r,i,a){var s,u;if(i!=a)u=i>a?1:-1;else for(s=u=0;s<i;s++)if(o[s]!=r[s]){u=o[s]>r[s]?1:-1;break}return u}function e(o,r,i,a){for(var s=0;i--;)o[i]-=s,s=o[i]<r[i]?1:0,o[i]=s*a+o[i]-r[i];for(;!o[0]&&o.length>1;)o.shift()}return function(o,r,i,a,s,u){var c,m,l,d,p,h,f,w,y,b,g,_,P,x,v,B,K,E,N,X,H=o.constructor,J=o.s==r.s?1:-1,F=o.d,L=r.d;if(!F||!F[0]||!L||!L[0])return new H(!o.s||!r.s||(F?L&&F[0]==L[0]:!L)?NaN:F&&F[0]==0||!L?J*0:J/0);for(u?(p=1,m=o.e-r.e):(u=we,p=C,m=re(o.e/p)-re(r.e/p)),N=L.length,K=F.length,y=new H(J),b=y.d=[],l=0;L[l]==(F[l]||0);l++);if(L[l]>(F[l]||0)&&m--,i==null?(x=i=H.precision,a=H.rounding):s?x=i+(o.e-r.e)+1:x=i,x<0)b.push(1),h=!0;else{if(x=x/p+2|0,l=0,N==1){for(d=0,L=L[0],x++;(l<K||d)&&x--;l++)v=d*u+(F[l]||0),b[l]=v/L|0,d=v%L|0;h=d||l<K}else{for(d=u/(L[0]+1)|0,d>1&&(L=n(L,d,u),F=n(F,d,u),N=L.length,K=F.length),B=N,g=F.slice(0,N),_=g.length;_<N;)g[_++]=0;X=L.slice(),X.unshift(0),E=L[0],L[1]>=u/2&&++E;do d=0,c=t(L,g,N,_),c<0?(P=g[0],N!=_&&(P=P*u+(g[1]||0)),d=P/E|0,d>1?(d>=u&&(d=u-1),f=n(L,d,u),w=f.length,_=g.length,c=t(f,g,w,_),c==1&&(d--,e(f,N<w?X:L,w,u))):(d==0&&(c=d=1),f=L.slice()),w=f.length,w<_&&f.unshift(0),e(g,f,_,u),c==-1&&(_=g.length,c=t(L,g,N,_),c<1&&(d++,e(g,N<_?X:L,_,u))),_=g.length):c===0&&(d++,g=[0]),b[l++]=d,c&&g[0]?g[_++]=F[B]||0:(g=[F[B]],_=1);while((B++<K||g[0]!==void 0)&&x--);h=g[0]!==void 0}b[0]||b.shift()}if(p==1)y.e=m,Go=h;else{for(l=1,d=b[0];d>=10;d/=10)l++;y.e=l+m*p-1,S(y,s?i+y.e+1:i,a,h)}return y}}();function S(n,t,e,o){var r,i,a,s,u,c,m,l,d,p=n.constructor;e:if(t!=null){if(l=n.d,!l)return n;for(r=1,s=l[0];s>=10;s/=10)r++;if(i=t-r,i<0)i+=C,a=t,m=l[d=0],u=m/Y(10,r-a-1)%10|0;else if(d=Math.ceil((i+1)/C),s=l.length,d>=s)if(o){for(;s++<=d;)l.push(0);m=u=0,r=1,i%=C,a=i-C+1}else break e;else{for(m=s=l[d],r=1;s>=10;s/=10)r++;i%=C,a=i-C+r,u=a<0?0:m/Y(10,r-a-1)%10|0}if(o=o||t<0||l[d+1]!==void 0||(a<0?m:m%Y(10,r-a-1)),c=e<4?(u||o)&&(e==0||e==(n.s<0?3:2)):u>5||u==5&&(e==4||o||e==6&&(i>0?a>0?m/Y(10,r-a):0:l[d-1])%10&1||e==(n.s<0?8:7)),t<1||!l[0])return l.length=0,c?(t-=n.e+1,l[0]=Y(10,(C-t%C)%C),n.e=-t||0):l[0]=n.e=0,n;if(i==0?(l.length=d,s=1,d--):(l.length=d+1,s=Y(10,C-i),l[d]=a>0?(m/Y(10,r-a)%Y(10,a)|0)*s:0),c)for(;;)if(d==0){for(i=1,a=l[0];a>=10;a/=10)i++;for(a=l[0]+=s,s=1;a>=10;a/=10)s++;i!=s&&(n.e++,l[0]==we&&(l[0]=1));break}else{if(l[d]+=s,l[d]!=we)break;l[d--]=0,s=1}for(i=l.length;l[--i]===0;)l.pop()}return M&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function Ae(n,t,e){if(!n.isFinite())return Qo(n);var o,r=n.e,i=ne(n.d),a=i.length;return t?(e&&(o=e-a)>0?i=i.charAt(0)+"."+i.slice(1)+Oe(o):a>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(n.e<0?"e":"e+")+n.e):r<0?(i="0."+Oe(-r-1)+i,e&&(o=e-a)>0&&(i+=Oe(o))):r>=a?(i+=Oe(r+1-a),e&&(o=e-r-1)>0&&(i=i+"."+Oe(o))):((o=r+1)<a&&(i=i.slice(0,o)+"."+i.slice(o)),e&&(o=e-a)>0&&(r+1===a&&(i+="."),i+=Oe(o))),i}function on(n,t){var e=n[0];for(t*=C;e>=10;e/=10)t++;return t}function tn(n,t,e){if(t>Di)throw M=!0,e&&(n.precision=e),Error(Ho);return S(new n($t),t,1,!0)}function be(n,t,e){if(t>En)throw Error(Ho);return S(new n(en),t,e,!0)}function Xo(n){var t=n.length-1,e=t*C+1;if(t=n[t],t){for(;t%10==0;t/=10)e--;for(t=n[0];t>=10;t/=10)e++}return e}function Oe(n){for(var t="";n--;)t+="0";return t}function Yo(n,t,e,o){var r,i=new n(1),a=Math.ceil(o/C+4);for(M=!1;;){if(e%2&&(i=i.times(t),Wo(i.d,a)&&(r=!0)),e=re(e/2),e===0){e=i.d.length-1,r&&i.d[e]===0&&++i.d[e];break}t=t.times(t),Wo(t.d,a)}return M=!0,i}function Uo(n){return n.d[n.d.length-1]&1}function Jo(n,t,e){for(var o,r=new n(t[0]),i=0;++i<t.length;)if(o=new n(t[i]),o.s)r[e](o)&&(r=o);else{r=o;break}return r}function Fn(n,t){var e,o,r,i,a,s,u,c=0,m=0,l=0,d=n.constructor,p=d.rounding,h=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:0/0);for(t==null?(M=!1,u=h):u=t,s=new d(.03125);n.e>-2;)n=n.times(s),l+=5;for(o=Math.log(Y(2,l))/Math.LN10*2+5|0,u+=o,e=i=a=new d(1),d.precision=u;;){if(i=S(i.times(n),u,1),e=e.times(++m),s=a.plus(q(i,e,u,1)),ne(s.d).slice(0,u)===ne(a.d).slice(0,u)){for(r=l;r--;)a=S(a.times(a),u,1);if(t==null)if(c<3&&Tt(a.d,u-o,p,c))d.precision=u+=10,e=i=s=new d(1),m=0,c++;else return S(a,d.precision=h,p,M=!0);else return d.precision=h,a}a=s}}function Ee(n,t){var e,o,r,i,a,s,u,c,m,l,d,p=1,h=10,f=n,w=f.d,y=f.constructor,b=y.rounding,g=y.precision;if(f.s<0||!w||!w[0]||!f.e&&w[0]==1&&w.length==1)return new y(w&&!w[0]?-1/0:f.s!=1?NaN:w?0:f);if(t==null?(M=!1,m=g):m=t,y.precision=m+=h,e=ne(w),o=e.charAt(0),Math.abs(i=f.e)<15e14){for(;o<7&&o!=1||o==1&&e.charAt(1)>3;)f=f.times(n),e=ne(f.d),o=e.charAt(0),p++;i=f.e,o>1?(f=new y("0."+e),i++):f=new y(o+"."+e.slice(1))}else return c=tn(y,m+2,g).times(i+""),f=Ee(new y(o+"."+e.slice(1)),m-h).plus(c),y.precision=g,t==null?S(f,g,b,M=!0):f;for(l=f,u=a=f=q(f.minus(1),f.plus(1),m,1),d=S(f.times(f),m,1),r=3;;){if(a=S(a.times(d),m,1),c=u.plus(q(a,new y(r),m,1)),ne(c.d).slice(0,m)===ne(u.d).slice(0,m))if(u=u.times(2),i!==0&&(u=u.plus(tn(y,m+2,g).times(i+""))),u=q(u,new y(p),m,1),t==null)if(Tt(u.d,m-h,b,s))y.precision=m+=h,c=a=f=q(l.minus(1),l.plus(1),m,1),d=S(f.times(f),m,1),r=s=1;else return S(u,y.precision=g,b,M=!0);else return y.precision=g,u;u=c,r+=2}}function Qo(n){return String(n.s*n.s/0)}function Dn(n,t){var e,o,r;for((e=t.indexOf("."))>-1&&(t=t.replace(".","")),(o=t.search(/e/i))>0?(e<0&&(e=o),e+=+t.slice(o+1),t=t.substring(0,o)):e<0&&(e=t.length),o=0;t.charCodeAt(o)===48;o++);for(r=t.length;t.charCodeAt(r-1)===48;--r);if(t=t.slice(o,r),t){if(r-=o,n.e=e=e-o-1,n.d=[],o=(e+1)%C,e<0&&(o+=C),o<r){for(o&&n.d.push(+t.slice(0,o)),r-=C;o<r;)n.d.push(+t.slice(o,o+=C));t=t.slice(o),o=C-t.length}else o-=r;for(;o--;)t+="0";n.d.push(+t),M&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function Ui(n,t){var e,o,r,i,a,s,u,c,m;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Zo.test(t))return Dn(n,t)}else if(t==="Infinity"||t==="NaN")return+t||(n.s=NaN),n.e=NaN,n.d=null,n;if(Oi.test(t))e=16,t=t.toLowerCase();else if(Li.test(t))e=2;else if(Ei.test(t))e=8;else throw Error(Fe+t);for(i=t.search(/p/i),i>0?(u=+t.slice(i+1),t=t.substring(2,i)):t=t.slice(2),i=t.indexOf("."),a=i>=0,o=n.constructor,a&&(t=t.replace(".",""),s=t.length,i=s-i,r=Yo(o,new o(e),i,i*2)),c=Qt(t,e,we),m=c.length-1,i=m;c[i]===0;--i)c.pop();return i<0?new o(n.s*0):(n.e=on(c,m),n.d=c,M=!1,a&&(n=q(n,r,s*4)),u&&(n=n.times(Math.abs(u)<54?Y(2,u):Pt.pow(2,u))),M=!0,n)}function Wi(n,t){var e,o=t.d.length;if(o<3)return t.isZero()?t:st(n,2,t,t);e=1.4*Math.sqrt(o),e=e>16?16:e|0,t=t.times(1/rn(5,e)),t=st(n,2,t,t);for(var r,i=new n(5),a=new n(16),s=new n(20);e--;)r=t.times(t),t=t.times(i.plus(r.times(a.times(r).minus(s))));return t}function st(n,t,e,o,r){var i,a,s,u,c=1,m=n.precision,l=Math.ceil(m/C);for(M=!1,u=e.times(e),s=new n(o);;){if(a=q(s.times(u),new n(t++*t++),m,1),s=r?o.plus(a):o.minus(a),o=q(a.times(u),new n(t++*t++),m,1),a=s.plus(o),a.d[l]!==void 0){for(i=l;a.d[i]===s.d[i]&&i--;);if(i==-1)break}i=s,s=o,o=a,a=i,c++}return M=!0,a.d.length=l+1,a}function rn(n,t){for(var e=n;--t;)e*=n;return e}function $o(n,t){var e,o=t.s<0,r=be(n,n.precision,1),i=r.times(.5);if(t=t.abs(),t.lte(i))return Ie=o?4:1,t;if(e=t.divToInt(r),e.isZero())Ie=o?3:2;else{if(t=t.minus(e.times(r)),t.lte(i))return Ie=Uo(e)?o?2:3:o?4:1,t;Ie=Uo(e)?o?1:4:o?3:2}return t.minus(r).abs()}function qn(n,t,e,o){var r,i,a,s,u,c,m,l,d,p=n.constructor,h=e!==void 0;if(h?(me(e,1,De),o===void 0?o=p.rounding:me(o,0,8)):(e=p.precision,o=p.rounding),!n.isFinite())m=Qo(n);else{for(m=Ae(n),a=m.indexOf("."),h?(r=2,t==16?e=e*4-3:t==8&&(e=e*3-2)):r=t,a>=0&&(m=m.replace(".",""),d=new p(1),d.e=m.length-a,d.d=Qt(Ae(d),10,r),d.e=d.d.length),l=Qt(m,10,r),i=u=l.length;l[--u]==0;)l.pop();if(!l[0])m=h?"0p+0":"0";else{if(a<0?i--:(n=new p(n),n.d=l,n.e=i,n=q(n,d,e,o,0,r),l=n.d,i=n.e,c=Go),a=l[e],s=r/2,c=c||l[e+1]!==void 0,c=o<4?(a!==void 0||c)&&(o===0||o===(n.s<0?3:2)):a>s||a===s&&(o===4||c||o===6&&l[e-1]&1||o===(n.s<0?8:7)),l.length=e,c)for(;++l[--e]>r-1;)l[e]=0,e||(++i,l.unshift(1));for(u=l.length;!l[u-1];--u);for(a=0,m="";a<u;a++)m+=Ln.charAt(l[a]);if(h){if(u>1)if(t==16||t==8){for(a=t==16?4:3,--u;u%a;u++)m+="0";for(l=Qt(m,r,t),u=l.length;!l[u-1];--u);for(a=1,m="1.";a<u;a++)m+=Ln.charAt(l[a])}else m=m.charAt(0)+"."+m.slice(1);m=m+(i<0?"p":"p+")+i}else if(i<0){for(;++i;)m="0"+m;m="0."+m}else if(++i>u)for(i-=u;i--;)m+="0";else i<u&&(m=m.slice(0,i)+"."+m.slice(i))}m=(t==16?"0x":t==2?"0b":t==8?"0o":"")+m}return n.s<0?"-"+m:m}function Wo(n,t){if(n.length>t)return n.length=t,!0}function Vi(n){return new this(n).abs()}function Gi(n){return new this(n).acos()}function Hi(n){return new this(n).acosh()}function zi(n,t){return new this(n).plus(t)}function ji(n){return new this(n).asin()}function Zi(n){return new this(n).asinh()}function Xi(n){return new this(n).atan()}function Yi(n){return new this(n).atanh()}function Ji(n,t){n=new this(n),t=new this(t);var e,o=this.precision,r=this.rounding,i=o+4;return!n.s||!t.s?e=new this(NaN):!n.d&&!t.d?(e=be(this,i,1).times(t.s>0?.25:.75),e.s=n.s):!t.d||n.isZero()?(e=t.s<0?be(this,o,r):new this(0),e.s=n.s):!n.d||t.isZero()?(e=be(this,i,1).times(.5),e.s=n.s):t.s<0?(this.precision=i,this.rounding=1,e=this.atan(q(n,t,i,1)),t=be(this,i,1),this.precision=o,this.rounding=r,e=n.s<0?e.minus(t):e.plus(t)):e=this.atan(q(n,t,i,1)),e}function Qi(n){return new this(n).cbrt()}function $i(n){return S(n=new this(n),n.e+1,2)}function ea(n,t,e){return new this(n).clamp(t,e)}function ta(n){if(!n||typeof n!="object")throw Error(nn+"Object expected");var t,e,o,r=n.defaults===!0,i=["precision",1,De,"rounding",0,8,"toExpNeg",-at,0,"toExpPos",0,at,"maxE",0,at,"minE",-at,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(e=i[t],r&&(this[e]=On[e]),(o=n[e])!==void 0)if(re(o)===o&&o>=i[t+1]&&o<=i[t+2])this[e]=o;else throw Error(Fe+e+": "+o);if(e="crypto",r&&(this[e]=On[e]),(o=n[e])!==void 0)if(o===!0||o===!1||o===0||o===1)if(o)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[e]=!0;else throw Error(zo);else this[e]=!1;else throw Error(Fe+e+": "+o);return this}function na(n){return new this(n).cos()}function oa(n){return new this(n).cosh()}function er(n){var t,e,o;function r(i){var a,s,u,c=this;if(!(c instanceof r))return new r(i);if(c.constructor=r,Vo(i)){c.s=i.s,M?!i.d||i.e>r.maxE?(c.e=NaN,c.d=null):i.e<r.minE?(c.e=0,c.d=[0]):(c.e=i.e,c.d=i.d.slice()):(c.e=i.e,c.d=i.d?i.d.slice():i.d);return}if(u=typeof i,u==="number"){if(i===0){c.s=1/i<0?-1:1,c.e=0,c.d=[0];return}if(i<0?(i=-i,c.s=-1):c.s=1,i===~~i&&i<1e7){for(a=0,s=i;s>=10;s/=10)a++;M?a>r.maxE?(c.e=NaN,c.d=null):a<r.minE?(c.e=0,c.d=[0]):(c.e=a,c.d=[i]):(c.e=a,c.d=[i]);return}else if(i*0!==0){i||(c.s=NaN),c.e=NaN,c.d=null;return}return Dn(c,i.toString())}else if(u!=="string")throw Error(Fe+i);return(s=i.charCodeAt(0))===45?(i=i.slice(1),c.s=-1):(s===43&&(i=i.slice(1)),c.s=1),Zo.test(i)?Dn(c,i):Ui(c,i)}if(r.prototype=k,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=ta,r.clone=er,r.isDecimal=Vo,r.abs=Vi,r.acos=Gi,r.acosh=Hi,r.add=zi,r.asin=ji,r.asinh=Zi,r.atan=Xi,r.atanh=Yi,r.atan2=Ji,r.cbrt=Qi,r.ceil=$i,r.clamp=ea,r.cos=na,r.cosh=oa,r.div=ra,r.exp=ia,r.floor=aa,r.hypot=sa,r.ln=ua,r.log=ca,r.log10=la,r.log2=ma,r.max=da,r.min=pa,r.mod=fa,r.mul=ga,r.pow=ha,r.random=ya,r.round=ba,r.sign=wa,r.sin=ka,r.sinh=_a,r.sqrt=Ta,r.sub=Pa,r.sum=Aa,r.tan=xa,r.tanh=va,r.trunc=Sa,n===void 0&&(n={}),n&&n.defaults!==!0)for(o=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<o.length;)n.hasOwnProperty(e=o[t++])||(n[e]=this[e]);return r.config(n),r}function ra(n,t){return new this(n).div(t)}function ia(n){return new this(n).exp()}function aa(n){return S(n=new this(n),n.e+1,3)}function sa(){var n,t,e=new this(0);for(M=!1,n=0;n<arguments.length;)if(t=new this(arguments[n++]),t.d)e.d&&(e=e.plus(t.times(t)));else{if(t.s)return M=!0,new this(1/0);e=t}return M=!0,e.sqrt()}function Vo(n){return n instanceof Pt||n&&n.toStringTag===jo||!1}function ua(n){return new this(n).ln()}function ca(n,t){return new this(n).log(t)}function ma(n){return new this(n).log(2)}function la(n){return new this(n).log(10)}function da(){return Jo(this,arguments,"lt")}function pa(){return Jo(this,arguments,"gt")}function fa(n,t){return new this(n).mod(t)}function ga(n,t){return new this(n).mul(t)}function ha(n,t){return new this(n).pow(t)}function ya(n){var t,e,o,r,i=0,a=new this(1),s=[];if(n===void 0?n=this.precision:me(n,1,De),o=Math.ceil(n/C),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(o));i<o;)r=t[i],r>=429e7?t[i]=crypto.getRandomValues(new Uint32Array(1))[0]:s[i++]=r%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(o*=4);i<o;)r=t[i]+(t[i+1]<<8)+(t[i+2]<<16)+((t[i+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(t,i):(s.push(r%1e7),i+=4);i=o/4}else throw Error(zo);else for(;i<o;)s[i++]=Math.random()*1e7|0;for(o=s[--i],n%=C,o&&n&&(r=Y(10,C-n),s[i]=(o/r|0)*r);s[i]===0;i--)s.pop();if(i<0)e=0,s=[0];else{for(e=-1;s[0]===0;e-=C)s.shift();for(o=1,r=s[0];r>=10;r/=10)o++;o<C&&(e-=C-o)}return a.e=e,a.d=s,a}function ba(n){return S(n=new this(n),n.e+1,this.rounding)}function wa(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function ka(n){return new this(n).sin()}function _a(n){return new this(n).sinh()}function Ta(n){return new this(n).sqrt()}function Pa(n,t){return new this(n).sub(t)}function Aa(){var n=0,t=arguments,e=new this(t[n]);for(M=!1;e.s&&++n<t.length;)e=e.plus(t[n]);return M=!0,S(e,this.precision,this.rounding)}function xa(n){return new this(n).tan()}function va(n){return new this(n).tanh()}function Sa(n){return S(n=new this(n),n.e+1,1)}k[Symbol.for("nodejs.util.inspect.custom")]=k.toString;k[Symbol.toStringTag]="Decimal";var Pt=k.constructor=er(On);$t=new Pt($t);en=new Pt(en);var ie=Pt;function z(n){if(n instanceof oe)return new I(n.numerator,n.denominator);if(n instanceof ce)return n.adjusted;if(n instanceof se)try{return z(n.toExact())}catch{return new I(ge)}if(n instanceof I)return n;let t=String(n),e=qe(t);return new I(e.numerator,e.denominator)}function Ba(n){var o;if(n instanceof oe)return{fr:new I(n.numerator,n.denominator)};if(n instanceof ce)return{fr:n.adjusted};if(n instanceof se)return{fr:z(n.toExact()),decimals:n.token.decimals};if(n instanceof I)return{fr:n};let t=String(n),e=qe(t);return{fr:new I(e.numerator,e.denominator),decimals:(o=e.dec)==null?void 0:o.length}}function Ca(n,t){if(n==null||t==null)return!1;let e=z(n),o=z(t);return e.sub(o).numerator,e.sub(o).numerator.lt(ge)}function tr(n,t){if(n==null||t==null)return!1;let e=z(n),o=z(t);return e.sub(o).numerator.gt(ge)}function Ia(n,t){if(n==null||t==null)return!1;let e=z(n),o=z(t);return e.sub(o).numerator.lte(ge)}function Ma(n,t){if(n==null||t==null)return!1;let e=z(n),o=z(t);return e.sub(o).numerator.gte(ge)}function nr(n,t){if(n==null||t==null)return!1;let e=z(n),o=z(t);return e.sub(o).numerator.eq(ge)}function Ka(n,t){if(n==null||t==null)return;let e=z(n),o=z(t);try{return e.div(o)}catch{return e}}function Na(n,t){if(n==null||t==null)return;let e=z(n),o=z(t);return e.sub(o)}function Ra(n