@raydium-io/raydium-sdk-v2
Version:
An SDK for building applications on top of Raydium.
1 lines • 82.2 kB
JavaScript
var Pn=Object.create;var Ve=Object.defineProperty,xn=Object.defineProperties,Sn=Object.getOwnPropertyDescriptor,kn=Object.getOwnPropertyDescriptors,Ln=Object.getOwnPropertyNames,or=Object.getOwnPropertySymbols,An=Object.getPrototypeOf,ar=Object.prototype.hasOwnProperty,In=Object.prototype.propertyIsEnumerable;var sr=(e,t,r)=>t in e?Ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,q=(e,t)=>{for(var r in t||(t={}))ar.call(t,r)&&sr(e,r,t[r]);if(or)for(var r of or(t))In.call(t,r)&&sr(e,r,t[r]);return e},X=(e,t)=>xn(e,kn(t));var Rn=(e,t)=>{for(var r in t)Ve(e,r,{get:t[r],enumerable:!0})},ur=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ln(t))!ar.call(e,i)&&i!==r&&Ve(e,i,{get:()=>t[i],enumerable:!(n=Sn(t,i))||n.enumerable});return e};var j=(e,t,r)=>(r=e!=null?Pn(An(e)):{},ur(t||!e||!e.__esModule?Ve(r,"default",{value:e,enumerable:!0}):r,e)),Bn=e=>ur(Ve({},"__esModule",{value:!0}),e);var bo={};Rn(bo,{DEV_FARM_LOCK_MINT:()=>vn,DEV_FARM_LOCK_VAULT:()=>Vn,FARM_LOCK_MINT:()=>Kn,FARM_LOCK_VAULT:()=>Fn,FARM_PROGRAM_TO_VERSION:()=>Dn,FARM_VERSION_TO_LEDGER_LAYOUT:()=>Kt,FARM_VERSION_TO_STATE_LAYOUT:()=>_t,Voter:()=>Wt,VoterDepositEntry:()=>Ar,VoterLockup:()=>Lr,VoterRegistrar:()=>Dt,VoterVotingMintConfig:()=>kr,associatedLedgerAccountLayout:()=>$e,calFarmRewardAmount:()=>Qi,createAssociatedLedgerAccountInstruction:()=>ro,dwLayout:()=>Y,farmAddRewardLayout:()=>nt,farmLedgerLayoutV3_1:()=>On,farmLedgerLayoutV3_2:()=>Re,farmLedgerLayoutV5_1:()=>Un,farmLedgerLayoutV5_2:()=>Mt,farmLedgerLayoutV6_1:()=>Et,farmRewardInfoToConfig:()=>Xi,farmRewardLayout:()=>tt,farmRewardRestartLayout:()=>rt,farmRewardTimeInfoLayout:()=>Sr,farmStateV3Layout:()=>Ft,farmStateV5Layout:()=>vt,farmStateV6Layout:()=>Vt,fetchMultipleFarmInfoAndUpdate:()=>$i,getAssociatedAuthority:()=>Ji,getAssociatedLedgerAccount:()=>te,getAssociatedLedgerPoolAccount:()=>zi,getDepositEntryIndex:()=>Tt,getFarmLedgerLayout:()=>dn,getFarmStateLayout:()=>pn,getRegistrarAddress:()=>Pt,getTokenOwnerRecordAddress:()=>At,getVoterAddress:()=>kt,getVoterWeightRecordAddress:()=>Lt,getVotingMintAuthority:()=>St,getVotingTokenMint:()=>xt,governanceCreateTokenOwnerRecord:()=>bn,isValidFarmVersion:()=>Mn,judgeFarmType:()=>eo,makeAddNewRewardInstruction:()=>uo,makeCreateFarmInstruction:()=>no,makeCreatorWithdrawFarmRewardInstruction:()=>io,makeDepositInstructionV3:()=>go,makeDepositInstructionV5:()=>yo,makeDepositInstructionV6:()=>ho,makeDepositTokenInstruction:()=>oo,makeDepositWithdrawInstruction:()=>co,makeRestartRewardInstruction:()=>ao,makeWithdrawInstructionV3:()=>mo,makeWithdrawInstructionV4:()=>po,makeWithdrawInstructionV5:()=>fo,makeWithdrawInstructionV6:()=>lo,makeWithdrawTokenInstruction:()=>so,poolTypeV6:()=>he,realFarmStateV3Layout:()=>Tr,realFarmStateV5Layout:()=>Pr,realFarmV6Layout:()=>xr,updateFarmPoolInfo:()=>mn,validateFarmRewards:()=>En,voterStakeRegistryCreateDepositEntry:()=>Tn,voterStakeRegistryCreateVoter:()=>wn,voterStakeRegistryDeposit:()=>gn,voterStakeRegistryUpdateVoterWeightRecord:()=>yn,voterStakeRegistryWithdraw:()=>hn,withdrawRewardLayout:()=>et});module.exports=Bn(bo);var dr=require("@solana/web3.js"),Le=j(require("bn.js"));var x=require("@solana/buffer-layout"),Rt=x.Layout,cr=x.Structure;var Bt=x.UInt;var lr=x.u8;var fr=x.seq;var ye=x.blob;var Ae=class extends Rt{constructor(r,n,i){super(r,i);this.blob=ye(r),this.signed=n}decode(r,n=0){let i=new Le.default(this.blob.decode(r,n),10,"le");return this.signed?i.fromTwos(this.span*8).clone():i}encode(r,n,i=0){return typeof r=="number"&&(r=new Le.default(r)),this.signed&&(r=r.toTwos(this.span*8)),this.blob.encode(r.toArrayLike(Buffer,"le",this.span),n,i)}};function _(e){return new Bt(1,e)}function Ie(e){return new Bt(4,e)}function h(e){return new Ae(8,!1,e)}function se(e){return new Ae(16,!1,e)}function pr(e){return new Ae(1,!0,e)}function Xe(e){return new Ae(8,!0,e)}var Je=class extends Rt{constructor(r,n,i,o){super(r.span,o);this.layout=r,this.decoder=n,this.encoder=i}decode(r,n){return this.decoder(this.layout.decode(r,n))}encode(r,n,i){return this.layout.encode(this.encoder(r),n,i)}getSpan(r,n){return this.layout.getSpan(r,n)}};function I(e){return new Je(ye(32),t=>new dr.PublicKey(t),t=>t.toBuffer(),e)}function Me(e){return new Je(lr(),Cn,Nn,e)}function Cn(e){if(e===0)return!1;if(e===1)return!0;throw new Error("Invalid bool: "+e)}function Nn(e){return e?1:0}var Ct=class extends cr{decode(t,r){return super.decode(t,r)}};function N(e,t,r){return new Ct(e,t,r)}function E(e,t,r){let n,i=typeof t=="number"?t:(0,Le.isBN)(t)?t.toNumber():new Proxy(t,{get(o,s){if(!n){let a=Reflect.get(o,"count");n=(0,Le.isBN)(a)?a.toNumber():a,Reflect.set(o,"count",n)}return Reflect.get(o,s)},set(o,s,a){return s==="count"&&(n=a),Reflect.set(o,s,a)}});return fr(e,i,r)}var Qe=require("@solana/web3.js");var Ee=require("lodash");var Nt=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 r=t.map(n=>typeof n=="object"?JSON.stringify(n):n).join(", ");throw new Error(r)}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}},mr={},_n={};function W(e){let t=(0,Ee.get)(mr,e);if(!t){let r=(0,Ee.get)(_n,e);t=new Nt({name:e,logLevel:r}),(0,Ee.set)(mr,e,t)}return t}var T=require("@solana/web3.js"),gr=new T.PublicKey("EhhTKczWMGQt46ynNeRX1WfeagwwJd7ufHvCDjRxjo5Q"),yr=new T.PublicKey("CBuCnLe26faBpcBP2fktp4rp8abpcAnTWft6ZrP5Q4T"),hr=new T.PublicKey("9KEPoZmtHUrBbhWN1v1KWLMkkvwY6WLtAVUCPRtRjP4z"),br=new T.PublicKey("FarmqiPv5eAj3j1GMdMCMUGXqPUvmquZtMy86QH6rzhG"),No=new T.PublicKey("CLaimxFqjHzgTJtAGHU47NPhg6qrc5sCnpC4tBLyABQS"),_o=new T.PublicKey("srmqPvymJeFKQ4zGQed1GFppgkRHL9kaELCbyksJtPX"),Ko=new T.PublicKey("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin"),Fo=new T.PublicKey("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"),vo=new T.PublicKey("5quBtoiQqxF9Jv6KYKctB59NT3gtJD2Y65kdnB1Uev3h"),Vo=new T.PublicKey("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Mo=new T.PublicKey("CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK"),Eo=new T.PublicKey("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Do=new T.PublicKey("kN1kEznaF5Xbd8LYuqtEFcxzWSBk5Fv6ygX6SqEGJVy"),Wo=new T.PublicKey("CDSr3ssLcRB6XYPJwAfFt18MZvEZp4LjHcvzBVZ45duo"),Oo=new T.PublicKey("routeUGWgWzqBWFcrCfv8tritsqukccJPu3q5GPP3xS"),Uo=new T.PublicKey("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5"),qo=new T.PublicKey("6FJon3QE27qgPVggARueB22hLvoh22VzJpXv4rBEoSLF"),Go=new T.PublicKey("CC12se5To1CdEuw7fDS27B7Geo5jJyL7t5UK2B44NgiH"),Ho=new T.PublicKey("9HzJyW1qZsEiSfMUf6L2jo3CcTKAyBmSyKdwQeYisHrC"),jo=new T.PublicKey("DropEU8AvevN3UrXWXTMuz3rqnMczQVNjq3kcSdW2SQi"),Yo=new T.PublicKey("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C"),Zo=new T.PublicKey("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL"),zo=new T.PublicKey("DNXgeM9EiiaAbaWvwjHj9fQQLAX5ZsfHyvmYUNRAdNC8"),Jo=new T.PublicKey("LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE"),Xo=new T.PublicKey("3f7GcQFG397GAaEnv51zR6tsTVihYRydnydDD1cXekxH"),Qo=new T.PublicKey("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj"),$o=new T.PublicKey("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh"),es=new T.PublicKey("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),ts=new T.PublicKey("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),rs=new T.PublicKey("4Bu96XjU84XjPDSpveTVf6LYGCkfW5FK7SNkREWcEfV4"),ns=new T.PublicKey("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");var De={OPEN_BOOK_PROGRAM:new T.PublicKey("EoTcMgcDRTJVZDMZWBoU6rhYHZfkNTVEAfz3uUJRcYGj"),SERUM_PROGRAM_ID_V3:new T.PublicKey("Ray1111111111111111111111111111111111111111"),AMM_V4:new T.PublicKey("DRaya7Kj3aMWQSy19kSjvmuwq9docCHofyP9kanQGaav"),AMM_STABLE:new T.PublicKey("DRayDdXc1NZQ9C3hRWmoSf8zK4iapgMnjdNZWrfwsP8m"),CLMM_PROGRAM_ID:new T.PublicKey("DRayAUgENGQBKVaX8owNhgzkEDyoHTGVEGHVJT1E9pfH"),CLMM_LOCK_PROGRAM_ID:new T.PublicKey("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),CLMM_LOCK_AUTH_ID:new T.PublicKey("6Aoh8h2Lw2m5UGxYR8AdAL87jTWYeKoxM52mJRzfYwN"),CREATE_CPMM_POOL_PROGRAM:new T.PublicKey("DRaycpLY18LhpbydsBWbVJtxpNv9oXPgjRSfpF2bWpYb"),CREATE_CPMM_POOL_AUTH:new T.PublicKey("CXniRufdq5xL8t8jZAPxsPZDpuudwuJSPWnbcD5Y5Nxq"),CREATE_CPMM_POOL_FEE_ACC:new T.PublicKey("3oE58BKVt8KuYkGxx8zBojugnymWmBiyafWgMrnb6eYy"),LOCK_CPMM_PROGRAM:new T.PublicKey("DRay25Usp3YJAi7beckgpGUC7mGJ2cR1AVPxhYfwVCUX"),LOCK_CPMM_AUTH:new T.PublicKey("7qWVV8UY2bRJfDLP4s37YzBPKUkVB46DStYJBpYbQzu3"),UTIL1216:T.PublicKey.default,Router:new T.PublicKey("DRaybByLpbUL57LJARs3j8BitTxVfzBg351EaMr5UTCd"),FARM_PROGRAM_ID_V3:new T.PublicKey("DRayWyrLmEW5KEeqs8kdTMMaBabapqagaBC7KWpGtJeZ"),FARM_PROGRAM_ID_V4:new T.PublicKey("Ray1111111111111111111111111111111111111111"),FARM_PROGRAM_ID_V5:new T.PublicKey("DRayiCGSZgku1GTK6rXD6mVDdingXy6APAH1R6R5L2LC"),FARM_PROGRAM_ID_V6:new T.PublicKey("DRayzbYakXs45ELHkzH6vC3fuhQqTAnv5A68gdFuvZyZ"),LAUNCHPAD_PROGRAM:new T.PublicKey("DRay6fNdQ5J82H7xV6uq2aV3mNrUZ1J4PgSKsWgptcm6"),LAUNCHPAD_AUTH:new T.PublicKey("5xqNaZXX5eUi4p5HU4oz9i5QnwRNT2y6oN7yyn4qENeq"),LAUNCHPAD_PLATFORM:new T.PublicKey("2Jx4KTDrVSdWNazuGpcA8n3ZLTRGGBDxAWhuKe2Xcj2a"),LAUNCHPAD_CONFIG:new T.PublicKey("7ZR4zD7PYfY2XxoG1Gxcy2EgEeGYrpxrwzPuwdUBssEt"),FEE_DESTINATION_ID:new T.PublicKey("9y8ENuuZ3b19quffx9hQvRVygG5ky6snHfRvGpuSfeJy"),MODEL_DATA_PUBKEY:new T.PublicKey("Ray1111111111111111111111111111111111111111")};var wr=require("@solana/spl-token"),ls=W("Raydium_farm_config"),Kn=new Qe.PublicKey("4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"),Fn=new Qe.PublicKey("FrspKwj8i3pNmKwXreTveC4fu7KL5ZbGeXdZBe2XViu1"),vn=wr.NATIVE_MINT,Vn=new Qe.PublicKey("3TRTX4dXUpp2eqxi3tvQDFYUV7SdDJjcPE3Y4mbtftaX"),_t={3:Ft,5:vt,6:Vt},Kt={3:Re,5:Mt,6:Et},Mn=e=>[3,4,5,6].indexOf(e)!==-1,En=e=>{var s;let{version:t,rewardInfos:r,rewardTokenAccountsPublicKeys:n}=e,i=`rewardInfo:${JSON.stringify(r)}, rewardAccount:${JSON.stringify(n)}`,o={3:()=>{if(r.length!==1||n.length!==1)return`rewardInfos or rewardTokenAccounts lengths not equal 1: ${i}`},5:()=>{if(r.length!==n.length)return`rewardInfos and rewardTokenAccounts lengths not equal: ${i}`},6:()=>{if(!n.length||r.length!==n.length)return`no rewardTokenAccounts or rewardInfos and rewardTokenAccounts lengths not equal: ${i}`}};return(s=o[t])==null?void 0:s.call(o)},he={"Standard SPL":0,"Option tokens":1},Dn={[gr.toString()]:3,[yr.toString()]:4,[hr.toString()]:5,[br.toString()]:6,[De.FARM_PROGRAM_ID_V3.toString()]:3,[De.FARM_PROGRAM_ID_V4.toString()]:4,[De.FARM_PROGRAM_ID_V5.toString()]:5,[De.FARM_PROGRAM_ID_V6.toString()]:6};var $e=N([_("instruction")]),et=N([_("instruction")]),Wn=N([h("rewardState"),h("rewardOpenTime"),h("rewardEndTime"),h("rewardLastUpdateTime"),h("totalReward"),h("totalRewardEmissioned"),h("rewardClaimed"),h("rewardPerSecond"),se("accRewardPerShare"),I("rewardVault"),I("rewardMint"),I("rewardSender"),h("rewardType"),E(h(),15,"padding")]),Tr=N([h("state"),h("nonce"),I("lpVault"),I("rewardVault"),I(),I(),h(),h(),h("totalReward"),se("perShareReward"),h("lastSlot"),h("perSlotReward")]),Pr=N([h("state"),h("nonce"),I("lpVault"),I("rewardVaultA"),h("totalRewardA"),se("perShareRewardA"),h("perSlotRewardA"),_("option"),I("rewardVaultB"),ye(7),h("totalRewardB"),se("perShareRewardB"),h("perSlotRewardB"),h("lastSlot"),I()]),xr=N([h(),h("state"),h("nonce"),h("validRewardTokenNum"),se("rewardMultiplier"),h("rewardPeriodMax"),h("rewardPeriodMin"),h("rewardPeriodExtend"),I("lpMint"),I("lpVault"),E(Wn,5,"rewardInfos"),I("creator"),I(),E(h(),32,"padding")]),Ft=new Proxy(Tr,{get(e,t,r){return t==="decode"?(...n)=>{let i=e.decode(...n);return X(q({},i),{version:3,rewardInfos:[{rewardVault:i.rewardVault,totalReward:i.totalReward,perSlotReward:i.perSlotReward,perShareReward:i.perShareReward}]})}:Reflect.get(e,t,r)}}),vt=new Proxy(Pr,{get(e,t,r){return t==="decode"?(...n)=>{let i=e.decode(...n);return X(q({},i),{version:5,rewardInfos:[{rewardVault:i.rewardVaultA,totalReward:i.totalRewardA,perSlotReward:i.perSlotRewardA,perShareReward:i.perShareRewardA},{rewardVault:i.rewardVaultB,totalReward:i.totalRewardB,perSlotReward:i.perSlotRewardB,perShareReward:i.perShareRewardB}]})}:Reflect.get(e,t,r)}}),Vt=new Proxy(xr,{get(e,t,r){return t==="decode"?(...n)=>{let i=e.decode(...n);return X(q({},i),{version:6,rewardInfos:i.rewardInfos.map(o=>{var s;return X(q({},o),{rewardType:((s=Object.entries(he).find(a=>String(a[1])===o.rewardType.toString()))!=null?s:["Standard SPL"])[0]})})})}:Reflect.get(e,t,r)}}),Sr=N([h("isSet"),h("rewardPerSecond"),h("rewardOpenTime"),h("rewardEndTime"),h("rewardType")]),tt=N([_("instruction"),h("nonce"),E(Sr,5,"rewardTimeInfo")]),rt=N([_("instruction"),h("rewardReopenTime"),h("rewardEndTime"),h("rewardPerSecond")]),nt=N([_("instruction"),h("isSet"),h("rewardPerSecond"),h("rewardOpenTime"),h("rewardEndTime"),h("rewardType")]),On=N([h("state"),I("id"),I("owner"),h("deposited"),E(h(),1,"rewardDebts")]),Re=N([h("state"),I("id"),I("owner"),h("deposited"),E(se(),1,"rewardDebts"),h(""),h("voteLockedBalance"),E(h(),15)]),Un=N([h("state"),I("id"),I("owner"),h("deposited"),E(h(),2,"rewardDebts")]),Mt=N([h("state"),I("id"),I("owner"),h("deposited"),E(se(),2,"rewardDebts"),E(h(),17)]),Et=N([h(),h("state"),I("id"),I("owner"),h("deposited"),E(se(),5,"rewardDebts"),E(h(),16)]),Y=N([_("instruction"),h("amount")]),kr=N([I("mint"),I("grantAuthority"),h("baselineVoteWeightScaledFactor"),h("maxExtraLockupVoteWeightScaledFactor"),h("lockupSaturationSecs"),pr("digitShift"),E(_(),7,"reserved1"),E(h(),7,"reserved2")]),Dt=N([ye(8),I("governanceProgramId"),I("realm"),I("realmGoverningTokenMint"),I("realmAuthority"),E(_(),32,"reserved1"),E(kr,4,"votingMints"),Xe("timeOffset"),_("bump"),E(_(),7,"reserved2"),E(h(),11,"reserved3")]),Lr=N([Xe("startTime"),Xe("endTime"),_("kind"),E(_(),15,"reserved")]),Ar=N([E(Lr,1,"lockup"),h("amountDeposited_native"),h("amountInitiallyLockedNative"),Me("isUsed"),Me("allowClawback"),_("votingMintConfigIdx"),E(_(),29,"reserved")]),Wt=N([ye(8),I("voterAuthority"),I("registrar"),E(Ar,32,"deposits"),_("voterBump"),_("voterWweightRecordBump"),E(_(),94,"reserved")]);var J=j(require("bn.js"));var Ir=require("@solana/web3.js");var it=require("@solana/spl-token"),Ot=W("Raydium_accountInfo_util");async function Rr(e,t,r){let{batchRequest:n,commitment:i="confirmed",chunkCount:o=100}=q({batchRequest:!1},r),s=Ut(t,o),a=new Array(s.length).fill([]);if(n){let c=s.map(f=>{let d=e._buildArgs([f.map(m=>m.toBase58())],i,"base64");return{methodName:"getMultipleAccounts",args:d}}),u=Ut(c,10);a=(await(await Promise.all(u.map(async f=>await e._rpcBatchRequest(f)))).flat()).map(f=>(f.error&&Ot.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${f.error.message}`),f.result.value.map(d=>{if(d){let{data:m,executable:w,lamports:b,owner:k,rentEpoch:A}=d;return m.length!==2&&m[1]!=="base64"&&Ot.logWithError("info must be base64 encoded, RPC_ERROR"),{data:Buffer.from(m[0],"base64"),executable:w,lamports:b,owner:new Ir.PublicKey(k),rentEpoch:A}}return null})))}else try{a=await Promise.all(s.map(c=>e.getMultipleAccountsInfo(c,i)))}catch(c){c instanceof Error&&Ot.logWithError(`failed to get info for multiple accounts, RPC_ERROR, ${c.message}`)}return a.flat()}async function Br(e,t,r){let n=await Rr(e,t.map(i=>i.pubkey),r);return t.map((i,o)=>X(q({},i),{accountInfo:n[o]}))}var oe=j(require("bn.js"));var Be=9e15,me=1e9,Gt="0123456789abcdef",at="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ut="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ht={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Be,maxE:Be,crypto:!1},Kr,ae,L=!0,lt="[DecimalError] ",pe=lt+"Invalid argument: ",Fr=lt+"Precision limit exceeded",vr=lt+"crypto unavailable",Vr="[object Decimal]",Z=Math.floor,O=Math.pow,qn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Gn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Hn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Mr=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,re=1e7,S=7,jn=9007199254740991,Yn=at.length-1,jt=ut.length-1,g={toStringTag:Vr};g.absoluteValue=g.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),P(e)};g.ceil=function(){return P(new this.constructor(this),this.e+1,2)};g.clampedTo=g.clamp=function(e,t){var r,n=this,i=n.constructor;if(e=new i(e),t=new i(t),!e.s||!t.s)return new i(NaN);if(e.gt(t))throw Error(pe+t);return r=n.cmp(e),r<0?e:n.cmp(t)>0?t:new i(n)};g.comparedTo=g.cmp=function(e){var t,r,n,i,o=this,s=o.d,a=(e=new o.constructor(e)).d,c=o.s,u=e.s;if(!s||!a)return!c||!u?NaN:c!==u?c:s===a?0:!s^c<0?1:-1;if(!s[0]||!a[0])return s[0]?c:a[0]?-u:0;if(c!==u)return c;if(o.e!==e.e)return o.e>e.e^c<0?1:-1;for(n=s.length,i=a.length,t=0,r=n<i?n:i;t<r;++t)if(s[t]!==a[t])return s[t]>a[t]^c<0?1:-1;return n===i?0:n>i^c<0?1:-1};g.cosine=g.cos=function(){var e,t,r=this,n=r.constructor;return r.d?r.d[0]?(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+S,n.rounding=1,r=Zn(n,Ur(n,r)),n.precision=e,n.rounding=t,P(ae==2||ae==3?r.neg():r,e,t,!0)):new n(1):new n(NaN)};g.cubeRoot=g.cbrt=function(){var e,t,r,n,i,o,s,a,c,u,l=this,f=l.constructor;if(!l.isFinite()||l.isZero())return new f(l);for(L=!1,o=l.s*O(l.s*l,1/3),!o||Math.abs(o)==1/0?(r=G(l.d),e=l.e,(o=(e-r.length+1)%3)&&(r+=o==1||o==-2?"0":"00"),o=O(r,1/3),e=Z((e+1)/3)-(e%3==(e<0?-1:2)),o==1/0?r="5e"+e:(r=o.toExponential(),r=r.slice(0,r.indexOf("e")+1)+e),n=new f(r),n.s=l.s):n=new f(o.toString()),s=(e=f.precision)+3;;)if(a=n,c=a.times(a).times(a),u=c.plus(l),n=v(u.plus(l).times(a),u.plus(c),s+2,1),G(a.d).slice(0,s)===(r=G(n.d)).slice(0,s))if(r=r.slice(s-3,s+1),r=="9999"||!i&&r=="4999"){if(!i&&(P(a,e+1,0),a.times(a).times(a).eq(l))){n=a;break}s+=4,i=1}else{(!+r||!+r.slice(1)&&r.charAt(0)=="5")&&(P(n,e+1,1),t=!n.times(n).times(n).eq(l));break}return L=!0,P(n,e,f.rounding,t)};g.decimalPlaces=g.dp=function(){var e,t=this.d,r=NaN;if(t){if(e=t.length-1,r=(e-Z(this.e/S))*S,e=t[e],e)for(;e%10==0;e/=10)r--;r<0&&(r=0)}return r};g.dividedBy=g.div=function(e){return v(this,new this.constructor(e))};g.dividedToIntegerBy=g.divToInt=function(e){var t=this,r=t.constructor;return P(v(t,new r(e),0,1,1),r.precision,r.rounding)};g.equals=g.eq=function(e){return this.cmp(e)===0};g.floor=function(){return P(new this.constructor(this),this.e+1,3)};g.greaterThan=g.gt=function(e){return this.cmp(e)>0};g.greaterThanOrEqualTo=g.gte=function(e){var t=this.cmp(e);return t==1||t===0};g.hyperbolicCosine=g.cosh=function(){var e,t,r,n,i,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;r=s.precision,n=s.rounding,s.precision=r+Math.max(o.e,o.sd())+4,s.rounding=1,i=o.d.length,i<32?(e=Math.ceil(i/3),t=(1/dt(4,e)).toString()):(e=16,t="2.3283064365386962890625e-10"),o=Ce(s,1,o.times(t),new s(1),!0);for(var c,u=e,l=new s(8);u--;)c=o.times(o),o=a.minus(c.times(l.minus(c.times(l))));return P(o,s.precision=r,s.rounding=n,!0)};g.hyperbolicSine=g.sinh=function(){var e,t,r,n,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(t=o.precision,r=o.rounding,o.precision=t+Math.max(i.e,i.sd())+4,o.rounding=1,n=i.d.length,n<3)i=Ce(o,2,i,i,!0);else{e=1.4*Math.sqrt(n),e=e>16?16:e|0,i=i.times(1/dt(5,e)),i=Ce(o,2,i,i,!0);for(var s,a=new o(5),c=new o(16),u=new o(20);e--;)s=i.times(i),i=i.times(a.plus(s.times(c.times(s).plus(u))))}return o.precision=t,o.rounding=r,P(i,t,r,!0)};g.hyperbolicTangent=g.tanh=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+7,n.rounding=1,v(r.sinh(),r.cosh(),n.precision=e,n.rounding=t)):new n(r.s)};g.inverseCosine=g.acos=function(){var e=this,t=e.constructor,r=e.abs().cmp(1),n=t.precision,i=t.rounding;return r!==-1?r===0?e.isNeg()?ne(t,n,i):new t(0):new t(NaN):e.isZero()?ne(t,n+4,i).times(.5):(t.precision=n+6,t.rounding=1,e=new t(1).minus(e).div(e.plus(1)).sqrt().atan(),t.precision=n,t.rounding=i,e.times(2))};g.inverseHyperbolicCosine=g.acosh=function(){var e,t,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(e=n.precision,t=n.rounding,n.precision=e+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,L=!1,r=r.times(r).minus(1).sqrt().plus(r),L=!0,n.precision=e,n.rounding=t,r.ln()):new n(r)};g.inverseHyperbolicSine=g.asinh=function(){var e,t,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,L=!1,r=r.times(r).plus(1).sqrt().plus(r),L=!0,n.precision=e,n.rounding=t,r.ln())};g.inverseHyperbolicTangent=g.atanh=function(){var e,t,r,n,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=o.precision,t=o.rounding,n=i.sd(),Math.max(n,e)<2*-i.e-1?P(new o(i),e,t,!0):(o.precision=r=n-i.e,i=v(i.plus(1),new o(1).minus(i),r+e,1),o.precision=e+4,o.rounding=1,i=i.ln(),o.precision=e,o.rounding=t,i.times(.5))):new o(NaN)};g.inverseSine=g.asin=function(){var e,t,r,n,i=this,o=i.constructor;return i.isZero()?new o(i):(t=i.abs().cmp(1),r=o.precision,n=o.rounding,t!==-1?t===0?(e=ne(o,r+4,n).times(.5),e.s=i.s,e):new o(NaN):(o.precision=r+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=r,o.rounding=n,i.times(2)))};g.inverseTangent=g.atan=function(){var e,t,r,n,i,o,s,a,c,u=this,l=u.constructor,f=l.precision,d=l.rounding;if(u.isFinite()){if(u.isZero())return new l(u);if(u.abs().eq(1)&&f+4<=jt)return s=ne(l,f+4,d).times(.25),s.s=u.s,s}else{if(!u.s)return new l(NaN);if(f+4<=jt)return s=ne(l,f+4,d).times(.5),s.s=u.s,s}for(l.precision=a=f+10,l.rounding=1,r=Math.min(28,a/S+2|0),e=r;e;--e)u=u.div(u.times(u).plus(1).sqrt().plus(1));for(L=!1,t=Math.ceil(a/S),n=1,c=u.times(u),s=new l(u),i=u;e!==-1;)if(i=i.times(c),o=s.minus(i.div(n+=2)),i=i.times(c),s=o.plus(i.div(n+=2)),s.d[t]!==void 0)for(e=t;s.d[e]===o.d[e]&&e--;);return r&&(s=s.times(2<<r-1)),L=!0,P(s,l.precision=f,l.rounding=d,!0)};g.isFinite=function(){return!!this.d};g.isInteger=g.isInt=function(){return!!this.d&&Z(this.e/S)>this.d.length-2};g.isNaN=function(){return!this.s};g.isNegative=g.isNeg=function(){return this.s<0};g.isPositive=g.isPos=function(){return this.s>0};g.isZero=function(){return!!this.d&&this.d[0]===0};g.lessThan=g.lt=function(e){return this.cmp(e)<0};g.lessThanOrEqualTo=g.lte=function(e){return this.cmp(e)<1};g.logarithm=g.log=function(e){var t,r,n,i,o,s,a,c,u=this,l=u.constructor,f=l.precision,d=l.rounding,m=5;if(e==null)e=new l(10),t=!0;else{if(e=new l(e),r=e.d,e.s<0||!r||!r[0]||e.eq(1))return new l(NaN);t=e.eq(10)}if(r=u.d,u.s<0||!r||!r[0]||u.eq(1))return new l(r&&!r[0]?-1/0:u.s!=1?NaN:r?0:1/0);if(t)if(r.length>1)o=!0;else{for(i=r[0];i%10===0;)i/=10;o=i!==1}if(L=!1,a=f+m,s=de(u,a),n=t?ct(l,a+10):de(e,a),c=v(s,n,a,1),We(c.d,i=f,d))do if(a+=10,s=de(u,a),n=t?ct(l,a+10):de(e,a),c=v(s,n,a,1),!o){+G(c.d).slice(i+1,i+15)+1==1e14&&(c=P(c,f+1,0));break}while(We(c.d,i+=10,d));return L=!0,P(c,f,d)};g.minus=g.sub=function(e){var t,r,n,i,o,s,a,c,u,l,f,d,m=this,w=m.constructor;if(e=new w(e),!m.d||!e.d)return!m.s||!e.s?e=new w(NaN):m.d?e.s=-e.s:e=new w(e.d||m.s!==e.s?m:NaN),e;if(m.s!=e.s)return e.s=-e.s,m.plus(e);if(u=m.d,d=e.d,a=w.precision,c=w.rounding,!u[0]||!d[0]){if(d[0])e.s=-e.s;else if(u[0])e=new w(m);else return new w(c===3?-0:0);return L?P(e,a,c):e}if(r=Z(e.e/S),l=Z(m.e/S),u=u.slice(),o=l-r,o){for(f=o<0,f?(t=u,o=-o,s=d.length):(t=d,r=l,s=u.length),n=Math.max(Math.ceil(a/S),s)+2,o>n&&(o=n,t.length=1),t.reverse(),n=o;n--;)t.push(0);t.reverse()}else{for(n=u.length,s=d.length,f=n<s,f&&(s=n),n=0;n<s;n++)if(u[n]!=d[n]){f=u[n]<d[n];break}o=0}for(f&&(t=u,u=d,d=t,e.s=-e.s),s=u.length,n=d.length-s;n>0;--n)u[s++]=0;for(n=d.length;n>o;){if(u[--n]<d[n]){for(i=n;i&&u[--i]===0;)u[i]=re-1;--u[i],u[n]+=re}u[n]-=d[n]}for(;u[--s]===0;)u.pop();for(;u[0]===0;u.shift())--r;return u[0]?(e.d=u,e.e=ft(u,r),L?P(e,a,c):e):new w(c===3?-0:0)};g.modulo=g.mod=function(e){var t,r=this,n=r.constructor;return e=new n(e),!r.d||!e.s||e.d&&!e.d[0]?new n(NaN):!e.d||r.d&&!r.d[0]?P(new n(r),n.precision,n.rounding):(L=!1,n.modulo==9?(t=v(r,e.abs(),0,3,1),t.s*=e.s):t=v(r,e,0,n.modulo,1),t=t.times(e),L=!0,r.minus(t))};g.naturalExponential=g.exp=function(){return Yt(this)};g.naturalLogarithm=g.ln=function(){return de(this)};g.negated=g.neg=function(){var e=new this.constructor(this);return e.s=-e.s,P(e)};g.plus=g.add=function(e){var t,r,n,i,o,s,a,c,u,l,f=this,d=f.constructor;if(e=new d(e),!f.d||!e.d)return!f.s||!e.s?e=new d(NaN):f.d||(e=new d(e.d||f.s===e.s?f:NaN)),e;if(f.s!=e.s)return e.s=-e.s,f.minus(e);if(u=f.d,l=e.d,a=d.precision,c=d.rounding,!u[0]||!l[0])return l[0]||(e=new d(f)),L?P(e,a,c):e;if(o=Z(f.e/S),n=Z(e.e/S),u=u.slice(),i=o-n,i){for(i<0?(r=u,i=-i,s=l.length):(r=l,n=o,s=u.length),o=Math.ceil(a/S),s=o>s?o+1:s+1,i>s&&(i=s,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for(s=u.length,i=l.length,s-i<0&&(i=s,r=l,l=u,u=r),t=0;i;)t=(u[--i]=u[i]+l[i]+t)/re|0,u[i]%=re;for(t&&(u.unshift(t),++n),s=u.length;u[--s]==0;)u.pop();return e.d=u,e.e=ft(u,n),L?P(e,a,c):e};g.precision=g.sd=function(e){var t,r=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(pe+e);return r.d?(t=Er(r.d),e&&r.e+1>t&&(t=r.e+1)):t=NaN,t};g.round=function(){var e=this,t=e.constructor;return P(new t(e),e.e+1,t.rounding)};g.sine=g.sin=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+Math.max(r.e,r.sd())+S,n.rounding=1,r=Jn(n,Ur(n,r)),n.precision=e,n.rounding=t,P(ae>2?r.neg():r,e,t,!0)):new n(NaN)};g.squareRoot=g.sqrt=function(){var e,t,r,n,i,o,s=this,a=s.d,c=s.e,u=s.s,l=s.constructor;if(u!==1||!a||!a[0])return new l(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);for(L=!1,u=Math.sqrt(+s),u==0||u==1/0?(t=G(a),(t.length+c)%2==0&&(t+="0"),u=Math.sqrt(t),c=Z((c+1)/2)-(c<0||c%2),u==1/0?t="5e"+c:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+c),n=new l(t)):n=new l(u.toString()),r=(c=l.precision)+3;;)if(o=n,n=o.plus(v(s,o,r+2,1)).times(.5),G(o.d).slice(0,r)===(t=G(n.d)).slice(0,r))if(t=t.slice(r-3,r+1),t=="9999"||!i&&t=="4999"){if(!i&&(P(o,c+1,0),o.times(o).eq(s))){n=o;break}r+=4,i=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(P(n,c+1,1),e=!n.times(n).eq(s));break}return L=!0,P(n,c,l.rounding,e)};g.tangent=g.tan=function(){var e,t,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(e=n.precision,t=n.rounding,n.precision=e+10,n.rounding=1,r=r.sin(),r.s=1,r=v(r,new n(1).minus(r.times(r)).sqrt(),e+10,0),n.precision=e,n.rounding=t,P(ae==2||ae==4?r.neg():r,e,t,!0)):new n(NaN)};g.times=g.mul=function(e){var t,r,n,i,o,s,a,c,u,l=this,f=l.constructor,d=l.d,m=(e=new f(e)).d;if(e.s*=l.s,!d||!d[0]||!m||!m[0])return new f(!e.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:!d||!m?e.s/0:e.s*0);for(r=Z(l.e/S)+Z(e.e/S),c=d.length,u=m.length,c<u&&(o=d,d=m,m=o,s=c,c=u,u=s),o=[],s=c+u,n=s;n--;)o.push(0);for(n=u;--n>=0;){for(t=0,i=c+n;i>n;)a=o[i]+m[n]*d[i-n-1]+t,o[i--]=a%re|0,t=a/re|0;o[i]=(o[i]+t)%re|0}for(;!o[--s];)o.pop();return t?++r:o.shift(),e.d=o,e.e=ft(o,r),L?P(e,f.precision,f.rounding):e};g.toBinary=function(e,t){return Zt(this,2,e,t)};g.toDecimalPlaces=g.toDP=function(e,t){var r=this,n=r.constructor;return r=new n(r),e===void 0?r:(Q(e,0,me),t===void 0?t=n.rounding:Q(t,0,8),P(r,e+r.e+1,t))};g.toExponential=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=ie(n,!0):(Q(e,0,me),t===void 0?t=i.rounding:Q(t,0,8),n=P(new i(n),e+1,t),r=ie(n,!0,e+1)),n.isNeg()&&!n.isZero()?"-"+r:r};g.toFixed=function(e,t){var r,n,i=this,o=i.constructor;return e===void 0?r=ie(i):(Q(e,0,me),t===void 0?t=o.rounding:Q(t,0,8),n=P(new o(i),e+i.e+1,t),r=ie(n,!1,e+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r};g.toFraction=function(e){var t,r,n,i,o,s,a,c,u,l,f,d,m=this,w=m.d,b=m.constructor;if(!w)return new b(m);if(u=r=new b(1),n=c=new b(0),t=new b(n),o=t.e=Er(w)-m.e-1,s=o%S,t.d[0]=O(10,s<0?S+s:s),e==null)e=o>0?t:u;else{if(a=new b(e),!a.isInt()||a.lt(u))throw Error(pe+a);e=a.gt(t)?o>0?t:u:a}for(L=!1,a=new b(G(w)),l=b.precision,b.precision=o=w.length*S*2;f=v(a,t,0,1,1),i=r.plus(f.times(n)),i.cmp(e)!=1;)r=n,n=i,i=u,u=c.plus(f.times(i)),c=i,i=t,t=a.minus(f.times(i)),a=i;return i=v(e.minus(r),n,0,1,1),c=c.plus(i.times(u)),r=r.plus(i.times(n)),c.s=u.s=m.s,d=v(u,n,o,1).minus(m).abs().cmp(v(c,r,o,1).minus(m).abs())<1?[u,n]:[c,r],b.precision=l,L=!0,d};g.toHexadecimal=g.toHex=function(e,t){return Zt(this,16,e,t)};g.toNearest=function(e,t){var r=this,n=r.constructor;if(r=new n(r),e==null){if(!r.d)return r;e=new n(1),t=n.rounding}else{if(e=new n(e),t===void 0?t=n.rounding:Q(t,0,8),!r.d)return e.s?r:e;if(!e.d)return e.s&&(e.s=r.s),e}return e.d[0]?(L=!1,r=v(r,e,0,t,1).times(e),L=!0,P(r)):(e.s=r.s,r=e),r};g.toNumber=function(){return+this};g.toOctal=function(e,t){return Zt(this,8,e,t)};g.toPower=g.pow=function(e){var t,r,n,i,o,s,a=this,c=a.constructor,u=+(e=new c(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new c(O(+a,u));if(a=new c(a),a.eq(1))return a;if(n=c.precision,o=c.rounding,e.eq(1))return P(a,n,o);if(t=Z(e.e/S),t>=e.d.length-1&&(r=u<0?-u:u)<=jn)return i=Dr(c,a,r,n),e.s<0?new c(1).div(i):P(i,n,o);if(s=a.s,s<0){if(t<e.d.length-1)return new c(NaN);if((e.d[t]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return r=O(+a,u),t=r==0||!isFinite(r)?Z(u*(Math.log("0."+G(a.d))/Math.LN10+a.e+1)):new c(r+"").e,t>c.maxE+1||t<c.minE-1?new c(t>0?s/0:0):(L=!1,c.rounding=a.s=1,r=Math.min(12,(t+"").length),i=Yt(e.times(de(a,n+r)),n),i.d&&(i=P(i,n+5,1),We(i.d,n,o)&&(t=n+10,i=P(Yt(e.times(de(a,t+r)),t),t+5,1),+G(i.d).slice(n+1,n+15)+1==1e14&&(i=P(i,n+1,0)))),i.s=s,L=!0,c.rounding=o,P(i,n,o))};g.toPrecision=function(e,t){var r,n=this,i=n.constructor;return e===void 0?r=ie(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(Q(e,1,me),t===void 0?t=i.rounding:Q(t,0,8),n=P(new i(n),e,t),r=ie(n,e<=n.e||n.e<=i.toExpNeg,e)),n.isNeg()&&!n.isZero()?"-"+r:r};g.toSignificantDigits=g.toSD=function(e,t){var r=this,n=r.constructor;return e===void 0?(e=n.precision,t=n.rounding):(Q(e,1,me),t===void 0?t=n.rounding:Q(t,0,8)),P(new n(r),e,t)};g.toString=function(){var e=this,t=e.constructor,r=ie(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+r:r};g.truncated=g.trunc=function(){return P(new this.constructor(this),this.e+1,1)};g.valueOf=g.toJSON=function(){var e=this,t=e.constructor,r=ie(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+r:r};function G(e){var t,r,n,i=e.length-1,o="",s=e[0];if(i>0){for(o+=s,t=1;t<i;t++)n=e[t]+"",r=S-n.length,r&&(o+=fe(r)),o+=n;s=e[t],n=s+"",r=S-n.length,r&&(o+=fe(r))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function Q(e,t,r){if(e!==~~e||e<t||e>r)throw Error(pe+e)}function We(e,t,r,n){var i,o,s,a;for(o=e[0];o>=10;o/=10)--t;return--t<0?(t+=S,i=0):(i=Math.ceil((t+1)/S),t%=S),o=O(10,S-t),a=e[i]%o|0,n==null?t<3?(t==0?a=a/100|0:t==1&&(a=a/10|0),s=r<4&&a==99999||r>3&&a==49999||a==5e4||a==0):s=(r<4&&a+1==o||r>3&&a+1==o/2)&&(e[i+1]/o/100|0)==O(10,t-2)-1||(a==o/2||a==0)&&(e[i+1]/o/100|0)==0:t<4?(t==0?a=a/1e3|0:t==1?a=a/100|0:t==2&&(a=a/10|0),s=(n||r<4)&&a==9999||!n&&r>3&&a==4999):s=((n||r<4)&&a+1==o||!n&&r>3&&a+1==o/2)&&(e[i+1]/o/1e3|0)==O(10,t-3)-1,s}function ot(e,t,r){for(var n,i=[0],o,s=0,a=e.length;s<a;){for(o=i.length;o--;)i[o]*=t;for(i[0]+=Gt.indexOf(e.charAt(s++)),n=0;n<i.length;n++)i[n]>r-1&&(i[n+1]===void 0&&(i[n+1]=0),i[n+1]+=i[n]/r|0,i[n]%=r)}return i.reverse()}function Zn(e,t){var r,n,i;if(t.isZero())return t;n=t.d.length,n<32?(r=Math.ceil(n/3),i=(1/dt(4,r)).toString()):(r=16,i="2.3283064365386962890625e-10"),e.precision+=r,t=Ce(e,1,t.times(i),new e(1));for(var o=r;o--;){var s=t.times(t);t=s.times(s).minus(s).times(8).plus(1)}return e.precision-=r,t}var v=function(){function e(n,i,o){var s,a=0,c=n.length;for(n=n.slice();c--;)s=n[c]*i+a,n[c]=s%o|0,a=s/o|0;return a&&n.unshift(a),n}function t(n,i,o,s){var a,c;if(o!=s)c=o>s?1:-1;else for(a=c=0;a<o;a++)if(n[a]!=i[a]){c=n[a]>i[a]?1:-1;break}return c}function r(n,i,o,s){for(var a=0;o--;)n[o]-=a,a=n[o]<i[o]?1:0,n[o]=a*s+n[o]-i[o];for(;!n[0]&&n.length>1;)n.shift()}return function(n,i,o,s,a,c){var u,l,f,d,m,w,b,k,A,V,B,D,le,z,ge,ve,xe,Se,$,ke,ze=n.constructor,It=n.s==i.s?1:-1,H=n.d,M=i.d;if(!H||!H[0]||!M||!M[0])return new ze(!n.s||!i.s||(H?M&&H[0]==M[0]:!M)?NaN:H&&H[0]==0||!M?It*0:It/0);for(c?(m=1,l=n.e-i.e):(c=re,m=S,l=Z(n.e/m)-Z(i.e/m)),$=M.length,xe=H.length,A=new ze(It),V=A.d=[],f=0;M[f]==(H[f]||0);f++);if(M[f]>(H[f]||0)&&l--,o==null?(z=o=ze.precision,s=ze.rounding):a?z=o+(n.e-i.e)+1:z=o,z<0)V.push(1),w=!0;else{if(z=z/m+2|0,f=0,$==1){for(d=0,M=M[0],z++;(f<xe||d)&&z--;f++)ge=d*c+(H[f]||0),V[f]=ge/M|0,d=ge%M|0;w=d||f<xe}else{for(d=c/(M[0]+1)|0,d>1&&(M=e(M,d,c),H=e(H,d,c),$=M.length,xe=H.length),ve=$,B=H.slice(0,$),D=B.length;D<$;)B[D++]=0;ke=M.slice(),ke.unshift(0),Se=M[0],M[1]>=c/2&&++Se;do d=0,u=t(M,B,$,D),u<0?(le=B[0],$!=D&&(le=le*c+(B[1]||0)),d=le/Se|0,d>1?(d>=c&&(d=c-1),b=e(M,d,c),k=b.length,D=B.length,u=t(b,B,k,D),u==1&&(d--,r(b,$<k?ke:M,k,c))):(d==0&&(u=d=1),b=M.slice()),k=b.length,k<D&&b.unshift(0),r(B,b,D,c),u==-1&&(D=B.length,u=t(M,B,$,D),u<1&&(d++,r(B,$<D?ke:M,D,c))),D=B.length):u===0&&(d++,B=[0]),V[f++]=d,u&&B[0]?B[D++]=H[ve]||0:(B=[H[ve]],D=1);while((ve++<xe||B[0]!==void 0)&&z--);w=B[0]!==void 0}V[0]||V.shift()}if(m==1)A.e=l,Kr=w;else{for(f=1,d=V[0];d>=10;d/=10)f++;A.e=f+l*m-1,P(A,a?o+A.e+1:o,s,w)}return A}}();function P(e,t,r,n){var i,o,s,a,c,u,l,f,d,m=e.constructor;e:if(t!=null){if(f=e.d,!f)return e;for(i=1,a=f[0];a>=10;a/=10)i++;if(o=t-i,o<0)o+=S,s=t,l=f[d=0],c=l/O(10,i-s-1)%10|0;else if(d=Math.ceil((o+1)/S),a=f.length,d>=a)if(n){for(;a++<=d;)f.push(0);l=c=0,i=1,o%=S,s=o-S+1}else break e;else{for(l=a=f[d],i=1;a>=10;a/=10)i++;o%=S,s=o-S+i,c=s<0?0:l/O(10,i-s-1)%10|0}if(n=n||t<0||f[d+1]!==void 0||(s<0?l:l%O(10,i-s-1)),u=r<4?(c||n)&&(r==0||r==(e.s<0?3:2)):c>5||c==5&&(r==4||n||r==6&&(o>0?s>0?l/O(10,i-s):0:f[d-1])%10&1||r==(e.s<0?8:7)),t<1||!f[0])return f.length=0,u?(t-=e.e+1,f[0]=O(10,(S-t%S)%S),e.e=-t||0):f[0]=e.e=0,e;if(o==0?(f.length=d,a=1,d--):(f.length=d+1,a=O(10,S-o),f[d]=s>0?(l/O(10,i-s)%O(10,s)|0)*a:0),u)for(;;)if(d==0){for(o=1,s=f[0];s>=10;s/=10)o++;for(s=f[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(e.e++,f[0]==re&&(f[0]=1));break}else{if(f[d]+=a,f[d]!=re)break;f[d--]=0,a=1}for(o=f.length;f[--o]===0;)f.pop()}return L&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e<m.minE&&(e.e=0,e.d=[0])),e}function ie(e,t,r){if(!e.isFinite())return Or(e);var n,i=e.e,o=G(e.d),s=o.length;return t?(r&&(n=r-s)>0?o=o.charAt(0)+"."+o.slice(1)+fe(n):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(e.e<0?"e":"e+")+e.e):i<0?(o="0."+fe(-i-1)+o,r&&(n=r-s)>0&&(o+=fe(n))):i>=s?(o+=fe(i+1-s),r&&(n=r-i-1)>0&&(o=o+"."+fe(n))):((n=i+1)<s&&(o=o.slice(0,n)+"."+o.slice(n)),r&&(n=r-s)>0&&(i+1===s&&(o+="."),o+=fe(n))),o}function ft(e,t){var r=e[0];for(t*=S;r>=10;r/=10)t++;return t}function ct(e,t,r){if(t>Yn)throw L=!0,r&&(e.precision=r),Error(Fr);return P(new e(at),t,1,!0)}function ne(e,t,r){if(t>jt)throw Error(Fr);return P(new e(ut),t,r,!0)}function Er(e){var t=e.length-1,r=t*S+1;if(t=e[t],t){for(;t%10==0;t/=10)r--;for(t=e[0];t>=10;t/=10)r++}return r}function fe(e){for(var t="";e--;)t+="0";return t}function Dr(e,t,r,n){var i,o=new e(1),s=Math.ceil(n/S+4);for(L=!1;;){if(r%2&&(o=o.times(t),Nr(o.d,s)&&(i=!0)),r=Z(r/2),r===0){r=o.d.length-1,i&&o.d[r]===0&&++o.d[r];break}t=t.times(t),Nr(t.d,s)}return L=!0,o}function Cr(e){return e.d[e.d.length-1]&1}function Wr(e,t,r){for(var n,i,o=new e(t[0]),s=0;++s<t.length;){if(i=new e(t[s]),!i.s){o=i;break}n=o.cmp(i),(n===r||n===0&&o.s===r)&&(o=i)}return o}function Yt(e,t){var r,n,i,o,s,a,c,u=0,l=0,f=0,d=e.constructor,m=d.rounding,w=d.precision;if(!e.d||!e.d[0]||e.e>17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);for(t==null?(L=!1,c=w):c=t,a=new d(.03125);e.e>-2;)e=e.times(a),f+=5;for(n=Math.log(O(2,f))/Math.LN10*2+5|0,c+=n,r=o=s=new d(1),d.precision=c;;){if(o=P(o.times(e),c,1),r=r.times(++l),a=s.plus(v(o,r,c,1)),G(a.d).slice(0,c)===G(s.d).slice(0,c)){for(i=f;i--;)s=P(s.times(s),c,1);if(t==null)if(u<3&&We(s.d,c-n,m,u))d.precision=c+=10,r=o=a=new d(1),l=0,u++;else return P(s,d.precision=w,m,L=!0);else return d.precision=w,s}s=a}}function de(e,t){var r,n,i,o,s,a,c,u,l,f,d,m=1,w=10,b=e,k=b.d,A=b.constructor,V=A.rounding,B=A.precision;if(b.s<0||!k||!k[0]||!b.e&&k[0]==1&&k.length==1)return new A(k&&!k[0]?-1/0:b.s!=1?NaN:k?0:b);if(t==null?(L=!1,l=B):l=t,A.precision=l+=w,r=G(k),n=r.charAt(0),Math.abs(o=b.e)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)b=b.times(e),r=G(b.d),n=r.charAt(0),m++;o=b.e,n>1?(b=new A("0."+r),o++):b=new A(n+"."+r.slice(1))}else return u=ct(A,l+2,B).times(o+""),b=de(new A(n+"."+r.slice(1)),l-w).plus(u),A.precision=B,t==null?P(b,B,V,L=!0):b;for(f=b,c=s=b=v(b.minus(1),b.plus(1),l,1),d=P(b.times(b),l,1),i=3;;){if(s=P(s.times(d),l,1),u=c.plus(v(s,new A(i),l,1)),G(u.d).slice(0,l)===G(c.d).slice(0,l))if(c=c.times(2),o!==0&&(c=c.plus(ct(A,l+2,B).times(o+""))),c=v(c,new A(m),l,1),t==null)if(We(c.d,l-w,V,a))A.precision=l+=w,u=s=b=v(f.minus(1),f.plus(1),l,1),d=P(b.times(b),l,1),i=a=1;else return P(c,A.precision=B,V,L=!0);else return A.precision=B,c;c=u,i+=2}}function Or(e){return String(e.s*e.s/0)}function st(e,t){var r,n,i;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(n=t.search(/e/i))>0?(r<0&&(r=n),r+=+t.slice(n+1),t=t.substring(0,n)):r<0&&(r=t.length),n=0;t.charCodeAt(n)===48;n++);for(i=t.length;t.charCodeAt(i-1)===48;--i);if(t=t.slice(n,i),t){if(i-=n,e.e=r=r-n-1,e.d=[],n=(r+1)%S,r<0&&(n+=S),n<i){for(n&&e.d.push(+t.slice(0,n)),i-=S;n<i;)e.d.push(+t.slice(n,n+=S));t=t.slice(n),n=S-t.length}else n-=i;for(;n--;)t+="0";e.d.push(+t),L&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function zn(e,t){var r,n,i,o,s,a,c,u,l;if(t.indexOf("_")>-1){if(t=t.replace(/(\d)_(?=\d)/g,"$1"),Mr.test(t))return st(e,t)}else if(t==="Infinity"||t==="NaN")return+t||(e.s=NaN),e.e=NaN,e.d=null,e;if(Gn.test(t))r=16,t=t.toLowerCase();else if(qn.test(t))r=2;else if(Hn.test(t))r=8;else throw Error(pe+t);for(o=t.search(/p/i),o>0?(c=+t.slice(o+1),t=t.substring(2,o)):t=t.slice(2),o=t.indexOf("."),s=o>=0,n=e.constructor,s&&(t=t.replace(".",""),a=t.length,o=a-o,i=Dr(n,new n(r),o,o*2)),u=ot(t,r,re),l=u.length-1,o=l;u[o]===0;--o)u.pop();return o<0?new n(e.s*0):(e.e=ft(u,l),e.d=u,L=!1,s&&(e=v(e,i,a*4)),c&&(e=e.times(Math.abs(c)<54?O(2,c):pt.pow(2,c))),L=!0,e)}function Jn(e,t){var r,n=t.d.length;if(n<3)return t.isZero()?t:Ce(e,2,t,t);r=1.4*Math.sqrt(n),r=r>16?16:r|0,t=t.times(1/dt(5,r)),t=Ce(e,2,t,t);for(var i,o=new e(5),s=new e(16),a=new e(20);r--;)i=t.times(t),t=t.times(o.plus(i.times(s.times(i).minus(a))));return t}function Ce(e,t,r,n,i){var o,s,a,c,u=1,l=e.precision,f=Math.ceil(l/S);for(L=!1,c=r.times(r),a=new e(n);;){if(s=v(a.times(c),new e(t++*t++),l,1),a=i?n.plus(s):n.minus(s),n=v(s.times(c),new e(t++*t++),l,1),s=a.plus(n),s.d[f]!==void 0){for(o=f;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=n,n=s,s=o,u++}return L=!0,s.d.length=f+1,s}function dt(e,t){for(var r=e;--t;)r*=e;return r}function Ur(e,t){var r,n=t.s<0,i=ne(e,e.precision,1),o=i.times(.5);if(t=t.abs(),t.lte(o))return ae=n?4:1,t;if(r=t.divToInt(i),r.isZero())ae=n?3:2;else{if(t=t.minus(r.times(i)),t.lte(o))return ae=Cr(r)?n?2:3:n?4:1,t;ae=Cr(r)?n?1:4:n?3:2}return t.minus(i).abs()}function Zt(e,t,r,n){var i,o,s,a,c,u,l,f,d,m=e.constructor,w=r!==void 0;if(w?(Q(r,1,me),n===void 0?n=m.rounding:Q(n,0,8)):(r=m.precision,n=m.rounding),!e.isFinite())l=Or(e);else{for(l=ie(e),s=l.indexOf("."),w?(i=2,t==16?r=r*4-3:t==8&&(r=r*3-2)):i=t,s>=0&&(l=l.replace(".",""),d=new m(1),d.e=l.length-s,d.d=ot(ie(d),10,i),d.e=d.d.length),f=ot(l,10,i),o=c=f.length;f[--c]==0;)f.pop();if(!f[0])l=w?"0p+0":"0";else{if(s<0?o--:(e=new m(e),e.d=f,e.e=o,e=v(e,d,r,n,0,i),f=e.d,o=e.e,u=Kr),s=f[r],a=i/2,u=u||f[r+1]!==void 0,u=n<4?(s!==void 0||u)&&(n===0||n===(e.s<0?3:2)):s>a||s===a&&(n===4||u||n===6&&f[r-1]&1||n===(e.s<0?8:7)),f.length=r,u)for(;++f[--r]>i-1;)f[r]=0,r||(++o,f.unshift(1));for(c=f.length;!f[c-1];--c);for(s=0,l="";s<c;s++)l+=Gt.charAt(f[s]);if(w){if(c>1)if(t==16||t==8){for(s=t==16?4:3,--c;c%s;c++)l+="0";for(f=ot(l,i,t),c=f.length;!f[c-1];--c);for(s=1,l="1.";s<c;s++)l+=Gt.charAt(f[s])}else l=l.charAt(0)+"."+l.slice(1);l=l+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)l="0"+l;l="0."+l}else if(++o>c)for(o-=c;o--;)l+="0";else o<c&&(l=l.slice(0,o)+"."+l.slice(o))}l=(t==16?"0x":t==2?"0b":t==8?"0o":"")+l}return e.s<0?"-"+l:l}function Nr(e,t){if(e.length>t)return e.length=t,!0}function Xn(e){return new this(e).abs()}function Qn(e){return new this(e).acos()}function $n(e){return new this(e).acosh()}function ei(e,t){return new this(e).plus(t)}function ti(e){return new this(e).asin()}function ri(e){return new this(e).asinh()}function ni(e){return new this(e).atan()}function ii(e){return new this(e).atanh()}function oi(e,t){e=new this(e),t=new this(t);var r,n=this.precision,i=this.rounding,o=n+4;return!e.s||!t.s?r=new this(NaN):!e.d&&!t.d?(r=ne(this,o,1).times(t.s>0?.25:.75),r.s=e.s):!t.d||e.isZero()?(r=t.s<0?ne(this,n,i):new this(0),r.s=e.s):!e.d||t.isZero()?(r=ne(this,o,1).times(.5),r.s=e.s):t.s<0?(this.precision=o,this.rounding=1,r=this.atan(v(e,t,o,1)),t=ne(this,o,1),this.precision=n,this.rounding=i,r=e.s<0?r.minus(t):r.plus(t)):r=this.atan(v(e,t,o,1)),r}function si(e){return new this(e).cbrt()}function ai(e){return P(e=new this(e),e.e+1,2)}function ui(e,t,r){return new this(e).clamp(t,r)}function ci(e){if(!e||typeof e!="object")throw Error(lt+"Object expected");var t,r,n,i=e.defaults===!0,o=["precision",1,me,"rounding",0,8,"toExpNeg",-Be,0,"toExpPos",0,Be,"maxE",0,Be,"minE",-Be,0,"modulo",0,9];for(t=0;t<o.length;t+=3)if(r=o[t],i&&(this[r]=Ht[r]),(n=e[r])!==void 0)if(Z(n)===n&&n>=o[t+1]&&n<=o[t+2])this[r]=n;else throw Error(pe+r+": "+n);if(r="crypto",i&&(this[r]=Ht[r]),(n=e[r])!==void 0)if(n===!0||n===!1||n===0||n===1)if(n)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[r]=!0;else throw Error(vr);else this[r]=!1;else throw Error(pe+r+": "+n);return this}function li(e){return new this(e).cos()}function fi(e){return new this(e).cosh()}function qr(e){var t,r,n;function i(o){var s,a,c,u=this;if(!(u instanceof i))return new i(o);if(u.constructor=i,_r(o)){u.s=o.s,L?!o.d||o.e>i.maxE?(u.e=NaN,u.d=null):o.e<i.minE?(u.e=0,u.d=[0]):(u.e=o.e,u.d=o.d.slice()):(u.e=o.e,u.d=o.d?o.d.slice():o.d);return}if(c=typeof o,c==="number"){if(o===0){u.s=1/o<0?-1:1,u.e=0,u.d=[0];return}if(o<0?(o=-o,u.s=-1):u.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;L?s>i.maxE?(u.e=NaN,u.d=null):s<i.minE?(u.e=0,u.d=[0]):(u.e=s,u.d=[o]):(u.e=s,u.d=[o]);return}if(o*0!==0){o||(u.s=NaN),u.e=NaN,u.d=null;return}return st(u,o.toString())}if(c==="string")return(a=o.charCodeAt(0))===45?(o=o.slice(1),u.s=-1):(a===43&&(o=o.slice(1)),u.s=1),Mr.test(o)?st(u,o):zn(u,o);if(c==="bigint")return o<0?(o=-o,u.s=-1):u.s=1,st(u,o.toString());throw Error(pe+o)}if(i.prototype=g,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=ci,i.clone=qr,i.isDecimal=_r,i.abs=Xn,i.acos=Qn,i.acosh=$n,i.add=ei,i.asin=ti,i.asinh=ri,i.atan=ni,i.atanh=ii,i.atan2=oi,i.cbrt=si,i.ceil=ai,i.clamp=ui,i.cos=li,i.cosh=fi,i.div=di,i.exp=pi,i.floor=mi,i.hypot=gi,i.ln=yi,i.log=hi,i.log10=wi,i.log2=bi,i.max=Ti,i.min=Pi,i.mod=xi,i.mul=Si,i.pow=ki,i.random=Li,i.round=Ai,i.sign=Ii,i.sin=Ri,i.sinh=Bi,i.sqrt=Ci,i.sub=Ni,i.sum=_i,i.tan=Ki,i.tanh=Fi,i.trunc=vi,e===void 0&&(e={}),e&&e.defaults!==!0)for(n=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],t=0;t<n.length;)e.hasOwnProperty(r=n[t++])||(e[r]=this[r]);return i.config(e),i}function di(e,t){return new this(e).div(t)}function pi(e){return new this(e).exp()}function mi(e){return P(e=new this(e),e.e+1,3)}function gi(){var e,t,r=new this(0);for(L=!1,e=0;e<arguments.length;)if(t=new this(arguments[e++]),t.d)r.d&&(r=r.plus(t.times(t)));else{if(t.s)return L=!0,new this(1/0);r=t}return L=!0,r.sqrt()}function _r(e){return e instanceof pt||e&&e.toStringTag===Vr||!1}function yi(e){return new this(e).ln()}function hi(e,t){return new this(e).log(t)}function bi(e){return new this(e).log(2)}function wi(e){return new this(e).log(10)}function Ti(){return Wr(this,arguments,-1)}function Pi(){return Wr(this,arguments,1)}function xi(e,t){return new this(e).mod(t)}function Si(e,t){return new this(e).mul(t)}function ki(e,t){return new this(e).pow(t)}function Li(e){var t,r,n,i,o=0,s=new this(1),a=[];if(e===void 0?e=this.precision:Q(e,1,me),n=Math.ceil(e/S),this.crypto)if(crypto.getRandomValues)for(t=crypto.getRandomValues(new Uint32Array(n));o<n;)i=t[o],i>=429e7?t[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=i%1e7;else if(crypto.randomBytes){for(t=crypto.randomBytes(n*=4);o<n;)i=t[o]+(t[o+1]<<8)+(t[o+2]<<16)+((t[o+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(t,o):(a.push(i%1e7),o+=4);o=n/4}else throw Error(vr);else for(;o<n;)a[o++]=Math.random()*1e7|0;for(n=a[--o],e%=S,n&&e&&(i=O(10,S-e),a[o]=(n/i|0)*i);a[o]===0;o--)a.pop();if(o<0)r=0,a=[0];else{for(r=-1;a[0]===0;r-=S)a.shift();for(n=1,i=a[0];i>=10;i/=10)n++;n<S&&(r-=S-n)}return s.e=r,s.d=a,s}function Ai(e){return P(e=new this(e),e.e+1,this.rounding)}function Ii(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function Ri(e){return new this(e).sin()}function Bi(e){return new this(e).sinh()}function Ci(e){return new this(e).sqrt()}function Ni(e,t){return new this(e).sub(t)}function _i(){var e=0,t=arguments,r=new this(t[e]);for(L=!1;r.s&&++e<t.length;)r=r.plus(t[e]);return L=!0,P(r,this.precision,this.rounding)}function Ki(e){return new this(e).tan()}function Fi(e){return new this(e).tanh()}function vi(e){return P(e=new this(e),e.e+1,1)}g[Symbol.for("nodejs.util.inspect.custom")]=g.toString;g[Symbol.toStringTag]="Decimal";var pt=g.constructor=qr(Ht);at=new pt(at);ut=new pt(ut);var zr=j(require("big.js")),Ge=j(require("bn.js"));var Gr=j(require("toformat")),Vi=Gr.default,Oe=Vi;var Ue=j(require("big.js")),jr=j(require("bn.js")),Yr=j(require("decimal.js-light"));var Ne=j(require("bn.js"));var Hr=9007199254740991;function C(e){let t=W("Raydium_parseBigNumberish");if(e instanceof Ne.default)return e;if(typeof e=="string"){if(e.match(/^-?[0-9]+$/))return new Ne.default(e);t.logWithError(`invalid BigNumberish string: ${e}`)}return typeof e=="number"?(e%1&&t.logWithError(`BigNumberish number underflow: ${e}`),(e>=Hr||e<=-Hr)&&t.logWithError(`BigNumberish number overflow: ${e}`),new Ne.default(String(e))):typeof e=="bigint"?new Ne.default(e.toString()):(t.error(`invalid BigNumberish value: ${e}`),new Ne.default(0))}var mt=W("module/fraction"),zt=Oe(Ue.default),qe=Oe(Yr.default),Ei={[0]:qe.ROUND_DOWN,[1]:qe.ROUND_HALF_UP,[2]:qe.ROUND_UP},Di={[0]:Ue.default.roundDown,[1]:Ue.default.roundHalfUp,[2]:Ue.default.roundUp},K=class{constructor(t,r=new jr.default(1)){this.numerator=C(t),this.denominator=C(r)}get quotient(){return this.numerator.div(this.denominator)}invert(){return new K(this.denominator,this.numerator)}add(t){let r=t instanceof K?t:new K(C(t));return this.denominator.eq(r.denominator)?new K(this.numerator.add(r.numerator),this.denominator):new K(this.numerator.mul(r.denominator).add(r.numerator.mul(this.denominator)),this.denominator.mul(r.denominator))}sub(t){let r=t instanceof K?t:new K(C(t));return this.denominator.eq(r.denominator)?new K(this.numerator.sub(r.numerator),this.denominator):new K(this.numerator.mul(r.denominator).sub(r.numerator.mul(this.denominator)),this.denominator.mul(r.denominator))}mul(t){let r=t instanceof K?t:new K(C(t));return new K(this.numerator.mul(r.numerator),this.denominator.mul(r.denominator))}div(t){let r=t instanceof K?t:new K(C(t));return new K(this.numerator.mul(r.denominator),this.denominator.mul(r.numerator))}toSignificant(t,r={groupSeparator:""},n=1){Number.isInteger(t)||mt.logWithError(`${t} is not an integer.`),t<=0&&mt.logWithError(`${t} is not positive.`),qe.set({precision:t+1,rounding:Ei[n]});let i=new qe(this.numerator.toString()).div(this.denominator.toString