@betorigami/game-calculations 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- var Zr=Object.create;var{getPrototypeOf:Xr,defineProperty:w,getOwnPropertyNames:Er,getOwnPropertyDescriptor:Ir}=Object,Sr=Object.prototype.hasOwnProperty;var N=(r,i,o)=>{o=r!=null?Zr(Xr(r)):{};let e=i||!r||!r.__esModule?w(o,"default",{value:r,enumerable:!0}):o;for(let c of Er(r))if(!Sr.call(e,c))w(e,c,{get:()=>r[c],enumerable:!0});return e},tr=new WeakMap,sr=(r)=>{var i=tr.get(r),o;if(i)return i;if(i=w({},"__esModule",{value:!0}),r&&typeof r==="object"||typeof r==="function")Er(r).map((e)=>!Sr.call(i,e)&&w(i,e,{get:()=>r[e],enumerable:!(o=Ir(r,e))||o.enumerable}));return tr.set(r,i),i};var br=(r,i)=>{for(var o in i)w(r,o,{get:i[o],enumerable:!0,configurable:!0,set:(e)=>i[o]=()=>e})};var Gi={};br(Gi,{wheelMultipliers:()=>zr,validateRouletteGameInputs:()=>_i,validateAdvancedDiceInputs:()=>oi,plinkoMultipliers:()=>Pr,calculateRouletteBetAmount:()=>yi,calculateBaccaratBetAmount:()=>Tr,WheelSegments:()=>nr,WheelRiskLevel:()=>cr,Wheel:()=>Wr,VALID_SUITS:()=>hr,VALID_RANKS:()=>xr,VALID_EUROPEAN_STREETS:()=>m,VALID_EUROPEAN_STRAIGHTS:()=>Y,VALID_EUROPEAN_SPLITS:()=>b,VALID_EUROPEAN_DOUBLE_STREETS:()=>or,VALID_EUROPEAN_CORNERS:()=>rr,VALID_AMERICAN_STREETS:()=>g,VALID_AMERICAN_STRAIGHTS:()=>s,VALID_AMERICAN_SPLITS:()=>u,VALID_AMERICAN_DOUBLE_STREETS:()=>er,VALID_AMERICAN_CORNERS:()=>ir,RouletteType:()=>F,Roulette:()=>$r,RollType:()=>Lr,RANDOM_MIN_VALUE:()=>a,RANDOM_MAX_VALUE:()=>j,PlinkoRiskLevel:()=>Hr,Plinko:()=>Ur,Parity:()=>K,OrigamiGame:()=>d,Mines:()=>vr,MIN_WIN_CHANCE:()=>Ar,MAX_WIN_CHANCE:()=>lr,Limbo:()=>Rr,KenoRiskLevel:()=>Nr,Keno:()=>Vr,Half:()=>D,GameErrorCode:()=>fr,GameError:()=>S,Game:()=>A,EFFECTIVE_RANGE:()=>Z,Dozen:()=>M,DiceDirection:()=>pr,Dice:()=>Mr,DiamondsResultType:()=>Cr,Diamonds:()=>Dr,Column:()=>p,Color:()=>C,BaccaratOutcome:()=>yr,BaccaratBetType:()=>_r,Baccarat:()=>Gr,AdvancedDice:()=>Br,AMERICAN_BASKET:()=>$});module.exports=sr(Gi);var d;((f)=>{f.DICE="DICE";f.MINES="MINES";f.KENO="KENO";f.LIMBO="LIMBO";f.ADVANCED_DICE="ADVANCED_DICE";f.BACCARAT="BACCARAT";f.DIAMONDS="DIAMONDS";f.PLINKO="PLINKO";f.ROULETTE="ROULETTE";f.WHEEL="WHEEL"})(d||={});class A{gameId;constructor(r){this.gameId=r}getGameResult(r){return this.determineGameResult(r)}}var U=require("big.js");var fr;((i)=>i.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR")(fr||={});class S extends Error{static createValidationError(r){return new S("INPUT_VALIDATION_ERROR",r)}static isGameError(r){return r instanceof S}errorCode;constructor(r,i){super(i);this.errorCode=r}}var a=0,j=1e4,Z=10001,Ar=0.01,lr=98,ur=(r)=>{if(r<a)throw S.createValidationError(`Lower bound ${r} is below minimum allowed value ${a}`)},mr=(r)=>{if(r>j)throw S.createValidationError(`Upper bound ${r} is above maximum allowed value ${j}`)},P=(r)=>{if(ur(r.lower),mr(r.upper),r.lower>=r.upper)throw S.createValidationError(`Lower bound ${r.lower} must be less than ${r.upper}`)},gr=(r,i)=>{let[o,e]=r.lower<=i.lower?[r,i]:[i,r];if(o.upper>e.lower)throw S.createValidationError("Bounds must not overlap")},ri=(r,i)=>i>=r.lower&&i<=r.upper,ii=(r)=>r.upper-r.lower+1,J=(r,i)=>i>r.lower&&i<r.upper,Q=(r)=>r.upper-r.lower-1,Lr;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Lr||={});var dr=(r)=>{let o=(()=>{switch(r.mode){case"ROLL_BETWEEN":return P(r.bounds),Q(r.bounds);case"ROLL_OUTSIDE":return P(r.bounds),Z-ii(r.bounds);case"ROLL_BETWEEN_TWO":return P(r.firstBounds),P(r.secondBounds),gr(r.firstBounds,r.secondBounds),Q(r.firstBounds)+Q(r.secondBounds)}})(),e=U.Big(o).div(Z).mul(100);if(e.lt(Ar))throw S.createValidationError("Win chance too low");if(e.gt(lr))throw S.createValidationError("Win chance too high");return e},oi=(r)=>{dr(r)};class Br extends A{constructor(){super("ADVANCED_DICE")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=dr(o),c=r.getRandomInt({min:a,max:j}),n=c.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(o.mode){case"ROLL_BETWEEN":return J(o.bounds,n);case"ROLL_OUTSIDE":return!ri(o.bounds,n);case"ROLL_BETWEEN_TWO":return J(o.firstBounds,n)||J(o.secondBounds,n)}})()?new U.Big(100-i).div(e):new U.Big(0),outputs:{result:c.values},randomValues:c}}}var V=N(require("big.js"));var hr=["Clubs","Diamonds","Hearts","Spades"],xr=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],yr;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(yr||={});var _r;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(_r||={});var ei={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:8},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Tr=(r)=>{return new V.default(0).add(r.bets.reduce((o,e)=>o.add(e.amount),new V.default(0)))};class Gr extends A{constructor(){super("BACCARAT")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(o!==1)throw new Error("Baccarat is only available at 1% edge.");this.validateGameInputs(i);let e=r.getRandomIntsWithReplacement({min:0,max:51,count:6}),c=e.values,n=c.slice(0,3),E=c.slice(3,6),L=[],l=0;for(let h of n.slice(0,2)){let x=this.mapRandomValueToCard(h),H=this.mapRandomValueToCardValue(h);L.push(x),l=(l+H)%10}let B=[],f=0;for(let h of E.slice(0,2)){let x=this.mapRandomValueToCard(h),H=this.mapRandomValueToCardValue(h);B.push(x),f=(f+H)%10}if(!this.isNaturalWin(l,f)){let h=this.shouldDrawThirdPlayerCard(l),x=null;if(h)x=this.mapRandomValueToCardValue(n[2]),L.push(this.mapRandomValueToCard(n[2])),l=(l+x)%10;if(this.shouldDrawThirdBankerCard(f,x))B.push(this.mapRandomValueToCard(E[2])),f=(f+this.mapRandomValueToCardValue(E[2]))%10}let y;if(l===f)y="TIE";else y=l>f?"PLAYER_WIN":"BANKER_WIN";let _=Tr(i),{betType:k,multiplier:Jr}=ei[y],Qr=new V.default(0).add(i.bets.filter((h)=>h.type===k).reduce((h,x)=>h.add(x.amount.mul(Jr)),new V.default(0)));return{isFinished:!0,payoutMultiplier:_.gt(0)?Qr.div(_):new V.default(0),outputs:{playerCards:L,playerHandValue:l,bankerCards:B,bankerHandValue:f,gameOutcome:y,result:e.values},randomValues:e}}validateGameInputs(r){if(r.bets.length===0)throw new Error("Must place at least a single bet.");if(!r.bets.every((i)=>i.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(r){let i=hr[Math.floor(r/13)],o=xr[r%13];return{suit:i,rank:o}}isNaturalWin(r,i){let o=[8,9];return o.includes(r)||o.includes(i)}mapRandomValueToCardValue(r){let i=r%13;if(i===0)return 1;if(i>=10)return 10;return i+1}shouldDrawThirdPlayerCard(r){return r<=5}shouldDrawThirdBankerCard(r,i){if(i===null)return r<=5;if(r<=2)return!0;if(r===3)return i!==8;if(r===4)return[2,3,4,5,6,7].includes(i);if(r===5)return[4,5,6,7].includes(i);if(r===6)return[6,7].includes(i);return!1}}var Kr=N(require("big.js"));class T{multipliers;constructor(r){this.multipliers=r}getMultipliers(r){let i=this.multipliers.get(r);if(i===void 0)throw new Error(`Multipliers for ${r} not found`);return i}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([r,i])=>({edge:r,multipliers:i}))}}var Cr;((E)=>{E.PAIR="PAIR";E.TWO_PAIR="TWO_PAIR";E.THREE_OF_A_KIND="THREE_OF_A_KIND";E.FULL_HOUSE="FULL_HOUSE";E.FOUR_OF_A_KIND="FOUR_OF_A_KIND";E.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(Cr||={});var ci={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},ni=new T(new Map([[2,ci]])),ti={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Dr extends A{constructor(){super("DIAMONDS")}determineGameResult({generator:r,edge:i}){let o=r.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=ni.getMultipliers(i),c=o.values,n=this.calculatePayoutMultiplier(e,c);return{isFinished:!0,payoutMultiplier:Kr.default(n),outputs:{result:o.values},randomValues:o}}calculatePayoutMultiplier(r,i){let o=new Map;for(let n of i){let E=o.get(n)||0;o.set(n,E+1)}let e=[...o.values()].filter((n)=>n>1),c=this.classifyResult(e);return c===null?0:r[c]}classifyResult(r){if(r.length>2)throw new Error(`Unexpected number of repeats ${r.length}`);let[i,o]=r;if(i===void 0)return null;if(o===void 0){let e=ti[i];if(e===void 0)throw new Error(`Unexpected single diamond repeat count: ${i}`);return e}return i===3||o===3?"FULL_HOUSE":"TWO_PAIR"}}var q=N(require("big.js"));var pr;((o)=>{o.ABOVE="ABOVE";o.BELOW="BELOW"})(pr||={});class Mr extends A{constructor(){super("DICE")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=r.getRandomInt({min:0,max:1e4}),c=e.min,L=e.max-c+1-1,l=o.direction==="ABOVE"?L-o.selectedValue:o.selectedValue,B=new q.default(l).div(L).mul(100);return{isFinished:!0,payoutMultiplier:(o.direction==="ABOVE"?e.value>o.selectedValue:e.value<o.selectedValue)?new q.default(100-i).div(B):new q.default(0),outputs:{result:e.values},randomValues:e}}}var X=N(require("big.js"));var Nr;((c)=>{c.CLASSIC="CLASSIC";c.LOW_RISK="LOW_RISK";c.MEDIUM_RISK="MEDIUM_RISK";c.HIGH_RISK="HIGH_RISK"})(Nr||={});var Ei={[1]:{["CLASSIC"]:[0,3.96],["LOW_RISK"]:[0.7,1.85],["MEDIUM_RISK"]:[0.4,2.75],["HIGH_RISK"]:[0,3.96]},[2]:{["CLASSIC"]:[0,1.9,4.5],["LOW_RISK"]:[0,2,3.8],["MEDIUM_RISK"]:[0,1.8,5.1],["HIGH_RISK"]:[0,0,17.1]},[3]:{["CLASSIC"]:[0,1,3.1,10.4],["LOW_RISK"]:[0,1.1,1.38,26],["MEDIUM_RISK"]:[0,0,2.8,50],["HIGH_RISK"]:[0,0,0,81.5]},[4]:{["CLASSIC"]:[0,0.8,1.8,5,22.5],["LOW_RISK"]:[0,0,2.2,7.9,90],["MEDIUM_RISK"]:[0,0,1.7,10,100],["HIGH_RISK"]:[0,0,0,10,259]},[5]:{["CLASSIC"]:[0,0.25,1.4,4.1,16.5,36],["LOW_RISK"]:[0,0,1.5,4.2,13,300],["MEDIUM_RISK"]:[0,0,1.4,4,14,390],["HIGH_RISK"]:[0,0,0,4.5,48,450]},[6]:{["CLASSIC"]:[0,0,1,3.68,7,16.5,40],["LOW_RISK"]:[0,0,1.1,2,6.2,100,700],["MEDIUM_RISK"]:[0,0,0,3,9,180,710],["HIGH_RISK"]:[0,0,0,0,11,350,710]},[7]:{["CLASSIC"]:[0,0,0.47,3,4.5,14,31,60],["LOW_RISK"]:[0,0,1.1,1.6,3.5,15,225,700],["MEDIUM_RISK"]:[0,0,0,2,7,30,400,800],["HIGH_RISK"]:[0,0,0,0,7,90,400,800]},[8]:{["CLASSIC"]:[0,0,0,2.2,4,13,22,55,70],["LOW_RISK"]:[0,0,1.1,1.5,2,5.5,39,100,800],["MEDIUM_RISK"]:[0,0,0,2,4,11,67,400,900],["HIGH_RISK"]:[0,0,0,0,5,20,270,600,900]},[9]:{["CLASSIC"]:[0,0,0,1.55,3,8,15,44,60,85],["LOW_RISK"]:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],["MEDIUM_RISK"]:[0,0,0,2,2.5,5,15,100,500,1000],["HIGH_RISK"]:[0,0,0,0,4,11,56,500,800,1000]},[10]:{["CLASSIC"]:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],["LOW_RISK"]:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],["MEDIUM_RISK"]:[0,0,0,1.6,2,4,7,26,100,500,1000],["HIGH_RISK"]:[0,0,0,0,3.5,8,13,63,500,800,1000]}};class Vr extends A{multiplierOverrides;get multipliers(){return this.multiplierOverrides??Ei}constructor(r){super("KENO");this.multiplierOverrides=r;if(r)this.validateMultiplierOverrides(r)}determineGameResult({generator:r,edge:i,gameInputs:o}){if(i!==1&&!this.multiplierOverrides)throw new Error("Multiplier overrides must be specified if an edge of 1% is not desirable");if(o.selectedNumbers.length===0)throw new Error("No numbers selected");if(o.selectedNumbers.length>10)throw new Error("Maximum of 10 numbers can be selected");for(let E of o.selectedNumbers){if(E%1!==0)throw new Error("Only integers can be selected");if(E<0||E>39)throw new Error("Invalid number selected")}let e=r.getUniqueRandomInts({min:0,max:39,count:10}),c=o.selectedNumbers.filter((E)=>e.values.includes(E));return{isFinished:!0,payoutMultiplier:c.length>0?new X.default(this.multipliers[o.selectedNumbers.length][o.riskLevel][c.length]??0):new X.default(0),outputs:{result:e.values},randomValues:e}}validateMultiplierOverrides(r){for(let[i,o]of Object.entries(r)){let e=Number(i);for(let[c,n]of Object.entries(o))if(n.length!==e+1)throw new Error(`Invalid count of multipliers for tiles ${e} and risk level ${c}. Expected ${e+1}, but got ${n.length}`)}}}var G=N(require("big.js"));var wr=(r,i)=>{return r.gt(i)?r:i};var Or=(r,i)=>{return r.lt(i)?r:i};class Rr extends A{constructor(){super("LIMBO")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=r.getRandomInt({min:1,max:4294967295}),c=e.max,n=new G.default(16777216),E=new G.default(1),L=new G.default(1e6),l=e.value,B=new G.default(l-1).div(c),f=(100-i)/100,y=n.div(B.mul(n).plus(1)).mul(f),_=wr(E,Or(y,L));return{isFinished:!0,payoutMultiplier:_.gte(o.targetMultiplier)?new G.default(o.targetMultiplier):new G.default(0),outputs:{randomMultiplier:_,result:e.values},randomValues:e}}}var O=N(require("big.js"));var I=(r,i)=>{if(i<0||r<0||i>r)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(i>r-i)i=r-i;let o=1;for(let e=1;e<=i;e++)o=o*(r-e+1)/e;return o};class vr extends A{constructor(){super("MINES")}determineGameResult({generator:r,edge:i,gameInputs:o}){if(o.minesCount<=0||o.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(o.selectedTiles.length>25-o.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let E=r.getUniqueRandomInts({min:1,max:25,count:o.minesCount}),L=E.values.some((k)=>o.selectedTiles.includes(k)),l=o.hasCashedOut||L,B=(100-i)/100,f=new O.default(I(25-o.minesCount,o.selectedTiles.length)).div(new O.default(I(25,o.selectedTiles.length))),_=o.hasCashedOut&&!L?new O.default(B).div(f):new O.default(0);return{isFinished:l,payoutMultiplier:_,outputs:{result:E.values},randomValues:E}}}var kr=require("big.js");var Hr;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(Hr||={});var Si=[{rows:8,payout:{["LOW_RISK"]:[5.6,2.1,1.1,1,0.5,1,1.1,2.1,5.6],["MEDIUM_RISK"]:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],["HIGH_RISK"]:[29,4,1.5,0.3,0.2,0.3,1.5,4,29]}},{rows:9,payout:{["LOW_RISK"]:[5.6,2,1.6,1,0.7,0.7,1,1.6,2,5.6],["MEDIUM_RISK"]:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],["HIGH_RISK"]:[43,7,2,0.6,0.2,0.2,0.6,2,7,43]}},{rows:10,payout:{["LOW_RISK"]:[8.9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,8.9],["MEDIUM_RISK"]:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],["HIGH_RISK"]:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76]}},{rows:11,payout:{["LOW_RISK"]:[8.4,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8.4],["MEDIUM_RISK"]:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],["HIGH_RISK"]:[120,14,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,14,120]}},{rows:12,payout:{["LOW_RISK"]:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],["MEDIUM_RISK"]:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],["HIGH_RISK"]:[170,24,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,24,170]}},{rows:13,payout:{["LOW_RISK"]:[8.1,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8.1],["MEDIUM_RISK"]:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],["HIGH_RISK"]:[260,37,11,4,1,0.2,0.2,0.2,0.2,1,4,11,37,260]}},{rows:14,payout:{["LOW_RISK"]:[7.1,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7.1],["MEDIUM_RISK"]:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],["HIGH_RISK"]:[420,56,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56,420]}},{rows:15,payout:{["LOW_RISK"]:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],["MEDIUM_RISK"]:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],["HIGH_RISK"]:[620,83,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,83,620]}},{rows:16,payout:{["LOW_RISK"]:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16],["MEDIUM_RISK"]:[110,41,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41,110],["HIGH_RISK"]:[1000,130,26,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26,130,1000]}}],Pr=new T(new Map([[1,Si]]));class Ur extends A{constructor(){super("PLINKO")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(i.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(i.numberOfRows<8||i.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let e=Pr.getMultipliers(o),c=r.getRandomIntsWithReplacement({min:0,max:1,count:i.numberOfRows}),E=c.values.reduce((l,B)=>l+B,0);return{isFinished:!0,payoutMultiplier:new kr.Big(e.find((l)=>l.rows===i.numberOfRows)?.payout[i.riskLevel][E]??0),outputs:{result:c.values},randomValues:c}}}var t=require("big.js");var Y=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],s=[37,...Y],b=[[0,1],[0,2],[0,3],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],u=[[0,1],[0,3],[0,37],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],m=[[0,1,2],[0,2,3],[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],g=[[0,1,2],[0,2,37],[1,2,3],[2,3,37],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],rr=[[0,1,2,3],[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],ir=[[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],$=[0,1,2,3,37],or=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],er=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],K;((o)=>{o.EVEN="EVEN";o.ODD="ODD"})(K||={});var C;((o)=>{o.RED="RED";o.BLACK="BLACK"})(C||={});var D;((o)=>{o.LOW="LOW";o.HIGH="HIGH"})(D||={});var p;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(p||={});var M;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(M||={});var F;((o)=>{o.AMERICAN="AMERICAN";o.EUROPEAN="EUROPEAN"})(F||={});var z=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw S.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((i)=>i.amount.gte(0)&&R(i.value)))throw S.createValidationError("Invalid straight bet.");if(!r.splitBets.every((i)=>i.amount.gte(0)&&fi(i.values)))throw S.createValidationError("Invalid split bet.");if(!r.streetBets.every((i)=>i.amount.gte(0)&&Ai(i.values)))throw S.createValidationError("Invalid street bet.");if(!r.cornerBets.every((i)=>i.amount.gte(0)&&li(i.values)))throw S.createValidationError("Invalid corner bet.");if(!r.doubleStreetBets.every((i)=>i.amount.gte(0)&&Li(i.values)))throw S.createValidationError("Invalid double street bet.");if(!r.parityBets.every((i)=>i.amount.gte(0)&&Object.values(K).includes(i.parity)))throw S.createValidationError("Invalid parity bet.");if(!r.colorBets.every((i)=>i.amount.gte(0)&&Object.values(C).includes(i.color)))throw S.createValidationError("Invalid color bet.");if(!r.halfBets.every((i)=>i.amount.gte(0)&&Object.values(D).includes(i.half)))throw S.createValidationError("Invalid half bet.");if(!r.columnBets.every((i)=>i.amount.gte(0)&&Object.values(p).includes(i.column)))throw S.createValidationError("Invalid column bet.");if(!r.dozenBets.every((i)=>i.amount.gte(0)&&Object.values(M).includes(i.dozen)))throw S.createValidationError("Invalid dozen bet.")},R=(r)=>{return Y.includes(r)},fi=(r)=>{if(r.length!==2)return!1;if(!r.every(R))return!1;return b.some(([i,o])=>i===r[0]&&o===r[1])},Ai=(r)=>{if(r.length!==3)return!1;if(!r.every(R))return!1;return m.some(([i,o,e])=>i===r[0]&&o===r[1]&&e===r[2])},li=(r)=>{if(r.length!==4)return!1;if(!r.every(R))return!1;return rr.some(([i,o,e,c])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3])},Li=(r)=>{if(r.length!==6)return!1;if(!r.every(R))return!1;return or.some(([i,o,e,c,n,E])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3]&&n===r[4]&&E===r[5])};var W=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.basketBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw S.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((i)=>i.amount.gte(0)&&v(i.value)))throw S.createValidationError("Invalid straight bet.");if(!r.splitBets.every((i)=>i.amount.gte(0)&&di(i.values)))throw S.createValidationError("Invalid split bet.");if(!r.streetBets.every((i)=>i.amount.gte(0)&&Bi(i.values)))throw S.createValidationError("Invalid street bet.");if(!r.cornerBets.every((i)=>i.amount.gte(0)&&hi(i.values)))throw S.createValidationError("Invalid corner bet.");if(!r.basketBets.every((i)=>i.amount.gte(0)))throw S.createValidationError("Invalid basket bet.");if(!r.doubleStreetBets.every((i)=>i.amount.gte(0)&&xi(i.values)))throw S.createValidationError("Invalid double street bet.");if(!r.parityBets.every((i)=>i.amount.gte(0)&&Object.values(K).includes(i.parity)))throw S.createValidationError("Invalid parity bet.");if(!r.colorBets.every((i)=>i.amount.gte(0)&&Object.values(C).includes(i.color)))throw S.createValidationError("Invalid color bet.");if(!r.halfBets.every((i)=>i.amount.gte(0)&&Object.values(D).includes(i.half)))throw S.createValidationError("Invalid half bet.");if(!r.columnBets.every((i)=>i.amount.gte(0)&&Object.values(p).includes(i.column)))throw S.createValidationError("Invalid column bet.");if(!r.dozenBets.every((i)=>i.amount.gte(0)&&Object.values(M).includes(i.dozen)))throw S.createValidationError("Invalid dozen bet.")},v=(r)=>{return s.includes(r)};function di(r){if(r.length!==2)return!1;if(!r.every(v))return!1;return u.some(([i,o])=>i===r[0]&&o===r[1])}var Bi=(r)=>{if(r.length!==3)return!1;if(!r.every(v))return!1;return g.some(([i,o,e])=>i===r[0]&&o===r[1]&&e===r[2])},hi=(r)=>{if(r.length!==4)return!1;if(!r.every(v))return!1;return ir.some(([i,o,e,c])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3])},xi=(r)=>{if(r.length!==6)return!1;if(!r.every(v))return!1;return er.some(([i,o,e,c,n,E])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3]&&n===r[4]&&E===r[5])};var ar=(r)=>{return new t.Big(0).add(r.straightBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.splitBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.streetBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.cornerBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.doubleStreetBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.parityBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.colorBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.halfBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.columnBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.dozenBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0)))},jr=(r)=>{return new t.Big(0).add(r.straightBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.splitBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.streetBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.cornerBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.basketBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.doubleStreetBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.parityBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.colorBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.halfBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.columnBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0))).add(r.dozenBets.reduce((i,o)=>i.plus(o.amount),new t.Big(0)))},yi=(r)=>{return r.type==="EUROPEAN"?ar(r.inputs):jr(r.inputs)};class qr extends A{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:i}){z(i);let o=r.getRandomInt({min:0,max:36}),e=o.value,c=this.determineBetOutcomes(i,e),n=ar(i),E=this.calculateTotalPayoutAmount(c),L=n.gt(0)?E.div(n):new t.Big(0);return{outputs:{betOutcomes:c,result:o.values},payoutMultiplier:L,isFinished:!0,randomValues:o}}determineBetOutcomes(r,i){return{winningBets:{straightBets:r.straightBets.filter((o)=>o.value===i),splitBets:r.splitBets.filter((o)=>o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>o.values.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>this.isWinningDozenBet(o,i))},losingBets:{straightBets:r.straightBets.filter((o)=>o.value!==i),splitBets:r.splitBets.filter((o)=>!o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>!o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>!o.values.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>!o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>!this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>!this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>!this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>!this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>!this.isWinningDozenBet(o,i))}}}isWinningParityBet(r,i){if(i===0)return!1;let o=i%2===0?"EVEN":"ODD";return r.parity===o}isWinningColorBet(r,i){let o=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],e=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(o.includes(i)&&r.color==="RED")return!0;if(e.includes(i)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,i){if(i>0&&i<=18&&r.half==="LOW")return!0;if(i>18&&i<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,i){let o=[3,6,9,12,15,18,21,24,27,30,33,36],e=[2,5,8,11,14,17,20,23,26,29,32,35],c=[1,4,7,10,13,16,19,22,25,28,31,34];if(o.includes(i)&&r.column==="TOP")return!0;if(e.includes(i)&&r.column==="MIDDLE")return!0;if(c.includes(i)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,i){if(i>0&&i<=12&&r.dozen==="FIRST")return!0;if(i>12&&i<=24&&r.dozen==="SECOND")return!0;if(i>24&&i<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new t.Big(0).add(r.winningBets.straightBets.reduce((i,o)=>i.plus(o.amount.mul(36)),new t.Big(0))).add(r.winningBets.splitBets.reduce((i,o)=>i.plus(o.amount.mul(18)),new t.Big(0))).add(r.winningBets.streetBets.reduce((i,o)=>i.plus(o.amount.mul(12)),new t.Big(0))).add(r.winningBets.cornerBets.reduce((i,o)=>i.plus(o.amount.mul(9)),new t.Big(0))).add(r.winningBets.doubleStreetBets.reduce((i,o)=>i.plus(o.amount.mul(6)),new t.Big(0))).add(r.winningBets.parityBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.colorBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.halfBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.columnBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t.Big(0))).add(r.winningBets.dozenBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t.Big(0)))}}class Yr extends A{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:i}){W(i);let o=r.getRandomInt({min:0,max:37}),e=o.value,c=this.determineBetOutcomes(i,e),n=jr(i),E=this.calculateTotalPayoutAmount(c),L=n.gt(0)?E.div(n):new t.Big(0);return{outputs:{betOutcomes:c,result:o.values},payoutMultiplier:L,isFinished:!0,randomValues:o}}determineBetOutcomes(r,i){return{winningBets:{straightBets:r.straightBets.filter((o)=>o.value===i),splitBets:r.splitBets.filter((o)=>o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>o.values.some((e)=>e===i)),basketBets:r.basketBets.filter((o)=>$.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>this.isWinningDozenBet(o,i))},losingBets:{straightBets:r.straightBets.filter((o)=>o.value!==i),splitBets:r.splitBets.filter((o)=>!o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>!o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>!o.values.some((e)=>e===i)),basketBets:r.basketBets.filter((o)=>!$.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>!o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>!this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>!this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>!this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>!this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>!this.isWinningDozenBet(o,i))}}}isWinningParityBet(r,i){if(i===0||i===37)return!1;let o=i%2===0?"EVEN":"ODD";return r.parity===o}isWinningColorBet(r,i){let o=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],e=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(o.includes(i)&&r.color==="RED")return!0;if(e.includes(i)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,i){if(i>0&&i<=18&&r.half==="LOW")return!0;if(i>18&&i<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,i){let o=[3,6,9,12,15,18,21,24,27,30,33,36],e=[2,5,8,11,14,17,20,23,26,29,32,35],c=[1,4,7,10,13,16,19,22,25,28,31,34];if(o.includes(i)&&r.column==="TOP")return!0;if(e.includes(i)&&r.column==="MIDDLE")return!0;if(c.includes(i)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,i){if(i>0&&i<=12&&r.dozen==="FIRST")return!0;if(i>12&&i<=24&&r.dozen==="SECOND")return!0;if(i>24&&i<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new t.Big(0).add(r.winningBets.straightBets.reduce((i,o)=>i.plus(o.amount.mul(36)),new t.Big(0))).add(r.winningBets.splitBets.reduce((i,o)=>i.plus(o.amount.mul(18)),new t.Big(0))).add(r.winningBets.streetBets.reduce((i,o)=>i.plus(o.amount.mul(12)),new t.Big(0))).add(r.winningBets.cornerBets.reduce((i,o)=>i.plus(o.amount.mul(9)),new t.Big(0))).add(r.winningBets.basketBets.reduce((i,o)=>i.plus(o.amount.mul(7)),new t.Big(0))).add(r.winningBets.doubleStreetBets.reduce((i,o)=>i.plus(o.amount.mul(6)),new t.Big(0))).add(r.winningBets.parityBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.colorBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.halfBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t.Big(0))).add(r.winningBets.columnBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t.Big(0))).add(r.winningBets.dozenBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t.Big(0)))}}class $r extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new qr,this.americanGame=new Yr}determineGameResult(r){let{gameInputs:i,...o}=r;if(r.edge===2.7&&i.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...o,gameInputs:i.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:c,result:e.outputs.result}}}if(r.edge===5.3&&i.type==="AMERICAN"){let e=this.americanGame.determineGameResult({...o,gameInputs:i.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:c,result:e.outputs.result}}}throw new Error("Only European & American Roulette games are supported")}}var _i=(r)=>{if(r.type==="EUROPEAN")z(r.inputs);else W(r.inputs)};var Fr=require("big.js");var cr;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(cr||={});var nr;((n)=>{n[n.TEN=10]="TEN";n[n.TWENTY=20]="TWENTY";n[n.THIRTY=30]="THIRTY";n[n.FORTY=40]="FORTY";n[n.FIFTY=50]="FIFTY"})(nr||={});var Ti=[{segments:10,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[0,1.9,0,1.5,0,2,0,1.5,0,3],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,9.9]}},{segments:20,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.8,0,2,0,2,0,1.5,0,2,0,2,0,3,0,2,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19.8]}},{segments:30,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.5,0,2,0,3,0,1.7,0,1.5,0,2,0,1.5,0,2,0,1.5,0,2,0,4,0,1.5,0,2,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,29.7]}},{segments:40,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[2,0,1.5,0,3,0,2,0,1.5,0,2,0,1.5,0,3,0,2,0,1.5,0,1.6,0,1.5,0,3,0,2,0,1.5,0,2,0,1.5,0,3,0,2,0,1.5,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,39.6]}},{segments:50,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,5,0,1.5,0,2,0,1.5,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49.5]}}],zr=new T(new Map([[1,Ti]]));class Wr extends A{constructor(){super("WHEEL")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(!Object.values(nr).includes(i.segments))throw new Error("Invalid segments value");if(!Object.values(cr).includes(i.riskLevel))throw new Error("Invalid risk level");let e=zr.getMultipliers(o).find((L)=>L.segments===i.segments);if(e===void 0)throw new Error(`Multiplier not found for segment ${i.segments}`);let c=r.getRandomInt({min:0,max:i.segments-1}),n=e.payout[i.riskLevel][c.value];if(n===void 0)throw new Error(`Payout not found for risk ${i.riskLevel} and value ${c.value}`);return{isFinished:!0,payoutMultiplier:new Fr.Big(n),outputs:{result:c.values},randomValues:c}}}
1
+ var ur=Object.create;var{getPrototypeOf:Wr,defineProperty:w,getOwnPropertyNames:er,getOwnPropertyDescriptor:sr}=Object,tr=Object.prototype.hasOwnProperty;var D=(r,o,i)=>{i=r!=null?ur(Wr(r)):{};let E=o||!r||!r.__esModule?w(i,"default",{value:r,enumerable:!0}):i;for(let A of er(r))if(!tr.call(E,A))w(E,A,{get:()=>r[A],enumerable:!0});return E},nr=new WeakMap,br=(r)=>{var o=nr.get(r),i;if(o)return o;if(o=w({},"__esModule",{value:!0}),r&&typeof r==="object"||typeof r==="function")er(r).map((E)=>!tr.call(o,E)&&w(o,E,{get:()=>r[E],enumerable:!(i=sr(r,E))||i.enumerable}));return nr.set(r,o),o};var mr=(r,o)=>{for(var i in o)w(r,i,{get:o[i],enumerable:!0,configurable:!0,set:(E)=>o[i]=()=>E})};var wo={};mr(wo,{validateRouletteGameInputs:()=>Ko,validateAdvancedDiceInputs:()=>Ao,plinkoMultipliers:()=>kr,diamondsMultipliers:()=>Zr,calculateRouletteBetAmount:()=>Zo,calculateBaccaratBetAmount:()=>pr,WheelSegments:()=>M,WheelRiskLevel:()=>N,Wheel:()=>Qr,VALID_SUITS:()=>Lr,VALID_RANKS:()=>Sr,VALID_EUROPEAN_STREETS:()=>rr,VALID_EUROPEAN_STRAIGHTS:()=>$,VALID_EUROPEAN_SPLITS:()=>m,VALID_EUROPEAN_DOUBLE_STREETS:()=>Ar,VALID_EUROPEAN_CORNERS:()=>ir,VALID_AMERICAN_STREETS:()=>or,VALID_AMERICAN_STRAIGHTS:()=>b,VALID_AMERICAN_SPLITS:()=>g,VALID_AMERICAN_DOUBLE_STREETS:()=>cr,VALID_AMERICAN_CORNERS:()=>Er,RouletteType:()=>z,Roulette:()=>$r,RollType:()=>dr,RANDOM_MIN_VALUE:()=>F,RANDOM_MAX_VALUE:()=>Y,PlinkoRiskLevel:()=>Hr,Plinko:()=>Pr,Parity:()=>G,OrigamiGame:()=>T,Mines:()=>vr,MIN_WIN_CHANCE:()=>Rr,MAX_WIN_CHANCE:()=>Or,Limbo:()=>Vr,KenoRiskLevel:()=>ar,Keno:()=>Nr,Half:()=>Z,GameErrorCode:()=>fr,GameError:()=>t,Game:()=>O,EFFECTIVE_RANGE:()=>u,Dozen:()=>_,DiceDirection:()=>_r,Dice:()=>Dr,DiamondsResultType:()=>Cr,Diamonds:()=>Kr,Column:()=>K,Color:()=>C,BaccaratOutcome:()=>xr,BaccaratBetType:()=>lr,Baccarat:()=>yr,AdvancedDice:()=>Tr,AMERICAN_BASKET:()=>q});module.exports=br(wo);var T;((f)=>{f.DICE="DICE";f.MINES="MINES";f.KENO="KENO";f.LIMBO="LIMBO";f.ADVANCED_DICE="ADVANCED_DICE";f.BACCARAT="BACCARAT";f.DIAMONDS="DIAMONDS";f.PLINKO="PLINKO";f.ROULETTE="ROULETTE";f.WHEEL="WHEEL"})(T||={});class O{gameId;constructor(r){this.gameId=r}getGameResult(r){return this.determineGameResult(r)}}var U=require("big.js");var fr;((o)=>o.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR")(fr||={});class t extends Error{static createValidationError(r){return new t("INPUT_VALIDATION_ERROR",r)}static isGameError(r){return r instanceof t}errorCode;constructor(r,o){super(o);this.errorCode=r}}var F=0,Y=1e4,u=10001,Rr=0.01,Or=98,gr=(r)=>{if(r<F)throw t.createValidationError(`Lower bound ${r} is below minimum allowed value ${F}`)},ro=(r)=>{if(r>Y)throw t.createValidationError(`Upper bound ${r} is above maximum allowed value ${Y}`)},P=(r)=>{if(gr(r.lower),ro(r.upper),r.lower>=r.upper)throw t.createValidationError(`Lower bound ${r.lower} must be less than ${r.upper}`)},oo=(r,o)=>{let[i,E]=r.lower<=o.lower?[r,o]:[o,r];if(i.upper>E.lower)throw t.createValidationError("Bounds must not overlap")},io=(r,o)=>o>=r.lower&&o<=r.upper,Eo=(r)=>r.upper-r.lower+1,X=(r,o)=>o>r.lower&&o<r.upper,I=(r)=>r.upper-r.lower-1,dr;((E)=>{E.ROLL_BETWEEN="ROLL_BETWEEN";E.ROLL_OUTSIDE="ROLL_OUTSIDE";E.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(dr||={});var Br=(r)=>{let i=(()=>{switch(r.mode){case"ROLL_BETWEEN":return P(r.bounds),I(r.bounds);case"ROLL_OUTSIDE":return P(r.bounds),u-Eo(r.bounds);case"ROLL_BETWEEN_TWO":return P(r.firstBounds),P(r.secondBounds),oo(r.firstBounds,r.secondBounds),I(r.firstBounds)+I(r.secondBounds)}})(),E=U.Big(i).div(u).mul(100);if(E.lt(Rr))throw t.createValidationError("Win chance too low");if(E.gt(Or))throw t.createValidationError("Win chance too high");return E},Ao=(r)=>{Br(r)};class Tr extends O{constructor(){super("ADVANCED_DICE")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=Br(i),A=r.getRandomInt({min:F,max:Y}),c=A.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(i.mode){case"ROLL_BETWEEN":return X(i.bounds,c);case"ROLL_OUTSIDE":return!io(i.bounds,c);case"ROLL_BETWEEN_TWO":return X(i.firstBounds,c)||X(i.secondBounds,c)}})()?new U.Big(100-o).div(E):new U.Big(0),outputs:{result:A.values},randomValues:A}}}var a=D(require("big.js"));var Lr=["Clubs","Diamonds","Hearts","Spades"],Sr=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],xr;((E)=>{E.PLAYER_WIN="PLAYER_WIN";E.TIE="TIE";E.BANKER_WIN="BANKER_WIN"})(xr||={});var lr;((E)=>{E.PLAYER="PLAYER";E.TIE="TIE";E.BANKER="BANKER"})(lr||={});var co={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:8},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},pr=(r)=>{return new a.default(0).add(r.bets.reduce((i,E)=>i.add(E.amount),new a.default(0)))};class yr extends O{constructor(){super("BACCARAT")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(i!==1)throw new Error("Baccarat is only available at 1% edge.");this.validateGameInputs(o);let E=r.getRandomIntsWithReplacement({min:0,max:51,count:6}),A=E.values,c=A.slice(0,3),e=A.slice(3,6),d=[],R=0;for(let L of c.slice(0,2)){let x=this.mapRandomValueToCard(L),k=this.mapRandomValueToCardValue(L);d.push(x),R=(R+k)%10}let B=[],f=0;for(let L of e.slice(0,2)){let x=this.mapRandomValueToCard(L),k=this.mapRandomValueToCardValue(L);B.push(x),f=(f+k)%10}if(!this.isNaturalWin(R,f)){let L=this.shouldDrawThirdPlayerCard(R),x=null;if(L)x=this.mapRandomValueToCardValue(c[2]),d.push(this.mapRandomValueToCard(c[2])),R=(R+x)%10;if(this.shouldDrawThirdBankerCard(f,x))B.push(this.mapRandomValueToCard(e[2])),f=(f+this.mapRandomValueToCardValue(e[2]))%10}let S;if(R===f)S="TIE";else S=R>f?"PLAYER_WIN":"BANKER_WIN";let l=pr(o),{betType:H,multiplier:Xr}=co[S],Ir=new a.default(0).add(o.bets.filter((L)=>L.type===H).reduce((L,x)=>L.add(x.amount.mul(Xr)),new a.default(0)));return{isFinished:!0,payoutMultiplier:l.gt(0)?Ir.div(l):new a.default(0),outputs:{playerCards:d,playerHandValue:R,bankerCards:B,bankerHandValue:f,gameOutcome:S,result:E.values},randomValues:E}}validateGameInputs(r){if(r.bets.length===0)throw new Error("Must place at least a single bet.");if(!r.bets.every((o)=>o.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(r){let o=Lr[Math.floor(r/13)],i=Sr[r%13];return{suit:o,rank:i}}isNaturalWin(r,o){let i=[8,9];return i.includes(r)||i.includes(o)}mapRandomValueToCardValue(r){let o=r%13;if(o===0)return 1;if(o>=10)return 10;return o+1}shouldDrawThirdPlayerCard(r){return r<=5}shouldDrawThirdBankerCard(r,o){if(o===null)return r<=5;if(r<=2)return!0;if(r===3)return o!==8;if(r===4)return[2,3,4,5,6,7].includes(o);if(r===5)return[4,5,6,7].includes(o);if(r===6)return[6,7].includes(o);return!1}}var Gr=D(require("big.js"));class p{multipliers;constructor(r){this.multipliers=r}getMultipliers(r){let o=this.multipliers.get(r);if(o===void 0)throw new Error(`Multipliers for ${r} not found`);return o}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([r,o])=>({edge:r,multipliers:o}))}}var Cr;((e)=>{e.PAIR="PAIR";e.TWO_PAIR="TWO_PAIR";e.THREE_OF_A_KIND="THREE_OF_A_KIND";e.FULL_HOUSE="FULL_HOUSE";e.FOUR_OF_A_KIND="FOUR_OF_A_KIND";e.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(Cr||={});var no={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50},eo={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},to={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50},fo={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50},Ro={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:2.8,FULL_HOUSE:3.2,FOUR_OF_A_KIND:3.6,FIVE_OF_A_KIND:50},Zr=new p(new Map([[1,no],[2,eo],[3,to],[4,fo],[8,Ro]])),Oo={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Kr extends O{constructor(){super("DIAMONDS")}determineGameResult({generator:r,edge:o}){let i=r.getRandomIntsWithReplacement({min:0,max:6,count:5}),E=Zr.getMultipliers(o),A=i.values,c=this.calculatePayoutMultiplier(E,A);return{isFinished:!0,payoutMultiplier:Gr.default(c),outputs:{result:i.values},randomValues:i}}calculatePayoutMultiplier(r,o){let i=new Map;for(let c of o){let e=i.get(c)||0;i.set(c,e+1)}let E=[...i.values()].filter((c)=>c>1),A=this.classifyResult(E);return A===null?0:r[A]}classifyResult(r){if(r.length>2)throw new Error(`Unexpected number of repeats ${r.length}`);let[o,i]=r;if(o===void 0)return null;if(i===void 0){let E=Oo[o];if(E===void 0)throw new Error(`Unexpected single diamond repeat count: ${o}`);return E}return o===3||i===3?"FULL_HOUSE":"TWO_PAIR"}}var j=D(require("big.js"));var _r;((i)=>{i.ABOVE="ABOVE";i.BELOW="BELOW"})(_r||={});class Dr extends O{constructor(){super("DICE")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=r.getRandomInt({min:0,max:1e4}),A=E.min,d=E.max-A+1-1,R=i.direction==="ABOVE"?d-i.selectedValue:i.selectedValue,B=new j.default(R).div(d).mul(100);return{isFinished:!0,payoutMultiplier:(i.direction==="ABOVE"?E.value>i.selectedValue:E.value<i.selectedValue)?new j.default(100-o).div(B):new j.default(0),outputs:{result:E.values},randomValues:E}}}var W=D(require("big.js"));var ar;((A)=>{A.CLASSIC="CLASSIC";A.LOW_RISK="LOW_RISK";A.MEDIUM_RISK="MEDIUM_RISK";A.HIGH_RISK="HIGH_RISK"})(ar||={});var Bo={[1]:{["CLASSIC"]:[0,3.96],["LOW_RISK"]:[0.7,1.85],["MEDIUM_RISK"]:[0.4,2.75],["HIGH_RISK"]:[0,3.96]},[2]:{["CLASSIC"]:[0,1.9,4.5],["LOW_RISK"]:[0,2,3.8],["MEDIUM_RISK"]:[0,1.8,5.1],["HIGH_RISK"]:[0,0,17.1]},[3]:{["CLASSIC"]:[0,1,3.1,10.4],["LOW_RISK"]:[0,1.1,1.38,26],["MEDIUM_RISK"]:[0,0,2.8,50],["HIGH_RISK"]:[0,0,0,81.5]},[4]:{["CLASSIC"]:[0,0.8,1.8,5,22.5],["LOW_RISK"]:[0,0,2.2,7.9,90],["MEDIUM_RISK"]:[0,0,1.7,10,100],["HIGH_RISK"]:[0,0,0,10,259]},[5]:{["CLASSIC"]:[0,0.25,1.4,4.1,16.5,36],["LOW_RISK"]:[0,0,1.5,4.2,13,300],["MEDIUM_RISK"]:[0,0,1.4,4,14,390],["HIGH_RISK"]:[0,0,0,4.5,48,450]},[6]:{["CLASSIC"]:[0,0,1,3.68,7,16.5,40],["LOW_RISK"]:[0,0,1.1,2,6.2,100,700],["MEDIUM_RISK"]:[0,0,0,3,9,180,710],["HIGH_RISK"]:[0,0,0,0,11,350,710]},[7]:{["CLASSIC"]:[0,0,0.47,3,4.5,14,31,60],["LOW_RISK"]:[0,0,1.1,1.6,3.5,15,225,700],["MEDIUM_RISK"]:[0,0,0,2,7,30,400,800],["HIGH_RISK"]:[0,0,0,0,7,90,400,800]},[8]:{["CLASSIC"]:[0,0,0,2.2,4,13,22,55,70],["LOW_RISK"]:[0,0,1.1,1.5,2,5.5,39,100,800],["MEDIUM_RISK"]:[0,0,0,2,4,11,67,400,900],["HIGH_RISK"]:[0,0,0,0,5,20,270,600,900]},[9]:{["CLASSIC"]:[0,0,0,1.55,3,8,15,44,60,85],["LOW_RISK"]:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],["MEDIUM_RISK"]:[0,0,0,2,2.5,5,15,100,500,1000],["HIGH_RISK"]:[0,0,0,0,4,11,56,500,800,1000]},[10]:{["CLASSIC"]:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],["LOW_RISK"]:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],["MEDIUM_RISK"]:[0,0,0,1.6,2,4,7,26,100,500,1000],["HIGH_RISK"]:[0,0,0,0,3.5,8,13,63,500,800,1000]}};class Nr extends O{multiplierOverrides;get multipliers(){return this.multiplierOverrides??Bo}constructor(r){super("KENO");this.multiplierOverrides=r;if(r)this.validateMultiplierOverrides(r)}determineGameResult({generator:r,edge:o,gameInputs:i}){if(o!==1&&!this.multiplierOverrides)throw new Error("Multiplier overrides must be specified if an edge of 1% is not desirable");if(i.selectedNumbers.length===0)throw new Error("No numbers selected");if(i.selectedNumbers.length>10)throw new Error("Maximum of 10 numbers can be selected");for(let e of i.selectedNumbers){if(e%1!==0)throw new Error("Only integers can be selected");if(e<0||e>39)throw new Error("Invalid number selected")}let E=r.getUniqueRandomInts({min:0,max:39,count:10}),A=i.selectedNumbers.filter((e)=>E.values.includes(e));return{isFinished:!0,payoutMultiplier:A.length>0?new W.default(this.multipliers[i.selectedNumbers.length][i.riskLevel][A.length]??0):new W.default(0),outputs:{result:E.values},randomValues:E}}validateMultiplierOverrides(r){for(let[o,i]of Object.entries(r)){let E=Number(o);for(let[A,c]of Object.entries(i))if(c.length!==E+1)throw new Error(`Invalid count of multipliers for tiles ${E} and risk level ${A}. Expected ${E+1}, but got ${c.length}`)}}}var y=D(require("big.js"));var Mr=(r,o)=>{return r.gt(o)?r:o};var wr=(r,o)=>{return r.lt(o)?r:o};class Vr extends O{constructor(){super("LIMBO")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=r.getRandomInt({min:1,max:4294967295}),A=E.max,c=new y.default(16777216),e=new y.default(1),d=new y.default(1e6),R=E.value,B=new y.default(R-1).div(A),f=(100-o)/100,S=c.div(B.mul(c).plus(1)).mul(f),l=Mr(e,wr(S,d));return{isFinished:!0,payoutMultiplier:l.gte(i.targetMultiplier)?new y.default(i.targetMultiplier):new y.default(0),outputs:{randomMultiplier:l,result:E.values},randomValues:E}}}var V=D(require("big.js"));var s=(r,o)=>{if(o<0||r<0||o>r)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(o>r-o)o=r-o;let i=1;for(let E=1;E<=o;E++)i=i*(r-E+1)/E;return i};class vr extends O{constructor(){super("MINES")}determineGameResult({generator:r,edge:o,gameInputs:i}){if(i.minesCount<=0||i.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(i.selectedTiles.length>25-i.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let e=r.getUniqueRandomInts({min:1,max:25,count:i.minesCount}),d=e.values.some((H)=>i.selectedTiles.includes(H)),R=i.hasCashedOut||d,B=(100-o)/100,f=new V.default(s(25-i.minesCount,i.selectedTiles.length)).div(new V.default(s(25,i.selectedTiles.length))),l=i.hasCashedOut&&!d?new V.default(B).div(f):new V.default(0);return{isFinished:R,payoutMultiplier:l,outputs:{result:e.values},randomValues:e}}}var hr=require("big.js");var Hr;((E)=>{E.LOW_RISK="LOW_RISK";E.MEDIUM_RISK="MEDIUM_RISK";E.HIGH_RISK="HIGH_RISK"})(Hr||={});var To=[{rows:8,payout:{["LOW_RISK"]:[5.6,2.1,1.1,1,0.5,1,1.1,2.1,5.6],["MEDIUM_RISK"]:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],["HIGH_RISK"]:[29,4,1.5,0.3,0.2,0.3,1.5,4,29]}},{rows:9,payout:{["LOW_RISK"]:[5.6,2,1.6,1,0.7,0.7,1,1.6,2,5.6],["MEDIUM_RISK"]:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],["HIGH_RISK"]:[43,7,2,0.6,0.2,0.2,0.6,2,7,43]}},{rows:10,payout:{["LOW_RISK"]:[8.9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,8.9],["MEDIUM_RISK"]:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],["HIGH_RISK"]:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76]}},{rows:11,payout:{["LOW_RISK"]:[8.4,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8.4],["MEDIUM_RISK"]:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],["HIGH_RISK"]:[120,14,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,14,120]}},{rows:12,payout:{["LOW_RISK"]:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],["MEDIUM_RISK"]:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],["HIGH_RISK"]:[170,24,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,24,170]}},{rows:13,payout:{["LOW_RISK"]:[8.1,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8.1],["MEDIUM_RISK"]:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],["HIGH_RISK"]:[260,37,11,4,1,0.2,0.2,0.2,0.2,1,4,11,37,260]}},{rows:14,payout:{["LOW_RISK"]:[7.1,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7.1],["MEDIUM_RISK"]:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],["HIGH_RISK"]:[420,56,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56,420]}},{rows:15,payout:{["LOW_RISK"]:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],["MEDIUM_RISK"]:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],["HIGH_RISK"]:[620,83,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,83,620]}},{rows:16,payout:{["LOW_RISK"]:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16],["MEDIUM_RISK"]:[110,41,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41,110],["HIGH_RISK"]:[1000,130,26,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26,130,1000]}}],kr=new p(new Map([[1,To]]));class Pr extends O{constructor(){super("PLINKO")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(o.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(o.numberOfRows<8||o.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let E=kr.getMultipliers(i),A=r.getRandomIntsWithReplacement({min:0,max:1,count:o.numberOfRows}),e=A.values.reduce((R,B)=>R+B,0);return{isFinished:!0,payoutMultiplier:new hr.Big(E.find((R)=>R.rows===o.numberOfRows)?.payout[o.riskLevel][e]??0),outputs:{result:A.values},randomValues:A}}}var n=require("big.js");var $=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],b=[37,...$],m=[[0,1],[0,2],[0,3],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],g=[[0,1],[0,3],[0,37],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],rr=[[0,1,2],[0,2,3],[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],or=[[0,1,2],[0,2,37],[1,2,3],[2,3,37],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],ir=[[0,1,2,3],[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],Er=[[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],q=[0,1,2,3,37],Ar=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],cr=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],G;((i)=>{i.EVEN="EVEN";i.ODD="ODD"})(G||={});var C;((i)=>{i.RED="RED";i.BLACK="BLACK"})(C||={});var Z;((i)=>{i.LOW="LOW";i.HIGH="HIGH"})(Z||={});var K;((E)=>{E.TOP="TOP";E.MIDDLE="MIDDLE";E.BOTTOM="BOTTOM"})(K||={});var _;((E)=>{E.FIRST="FIRST";E.SECOND="SECOND";E.THIRD="THIRD"})(_||={});var z;((i)=>{i.AMERICAN="AMERICAN";i.EUROPEAN="EUROPEAN"})(z||={});var J=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw t.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((o)=>o.amount.gte(0)&&v(o.value)))throw t.createValidationError("Invalid straight bet.");if(!r.splitBets.every((o)=>o.amount.gte(0)&&Lo(o.values)))throw t.createValidationError("Invalid split bet.");if(!r.streetBets.every((o)=>o.amount.gte(0)&&So(o.values)))throw t.createValidationError("Invalid street bet.");if(!r.cornerBets.every((o)=>o.amount.gte(0)&&xo(o.values)))throw t.createValidationError("Invalid corner bet.");if(!r.doubleStreetBets.every((o)=>o.amount.gte(0)&&lo(o.values)))throw t.createValidationError("Invalid double street bet.");if(!r.parityBets.every((o)=>o.amount.gte(0)&&Object.values(G).includes(o.parity)))throw t.createValidationError("Invalid parity bet.");if(!r.colorBets.every((o)=>o.amount.gte(0)&&Object.values(C).includes(o.color)))throw t.createValidationError("Invalid color bet.");if(!r.halfBets.every((o)=>o.amount.gte(0)&&Object.values(Z).includes(o.half)))throw t.createValidationError("Invalid half bet.");if(!r.columnBets.every((o)=>o.amount.gte(0)&&Object.values(K).includes(o.column)))throw t.createValidationError("Invalid column bet.");if(!r.dozenBets.every((o)=>o.amount.gte(0)&&Object.values(_).includes(o.dozen)))throw t.createValidationError("Invalid dozen bet.")},v=(r)=>{return $.includes(r)},Lo=(r)=>{if(r.length!==2)return!1;if(!r.every(v))return!1;return m.some(([o,i])=>o===r[0]&&i===r[1])},So=(r)=>{if(r.length!==3)return!1;if(!r.every(v))return!1;return rr.some(([o,i,E])=>o===r[0]&&i===r[1]&&E===r[2])},xo=(r)=>{if(r.length!==4)return!1;if(!r.every(v))return!1;return ir.some(([o,i,E,A])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3])},lo=(r)=>{if(r.length!==6)return!1;if(!r.every(v))return!1;return Ar.some(([o,i,E,A,c,e])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3]&&c===r[4]&&e===r[5])};var Q=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.basketBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw t.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((o)=>o.amount.gte(0)&&h(o.value)))throw t.createValidationError("Invalid straight bet.");if(!r.splitBets.every((o)=>o.amount.gte(0)&&po(o.values)))throw t.createValidationError("Invalid split bet.");if(!r.streetBets.every((o)=>o.amount.gte(0)&&yo(o.values)))throw t.createValidationError("Invalid street bet.");if(!r.cornerBets.every((o)=>o.amount.gte(0)&&Go(o.values)))throw t.createValidationError("Invalid corner bet.");if(!r.basketBets.every((o)=>o.amount.gte(0)))throw t.createValidationError("Invalid basket bet.");if(!r.doubleStreetBets.every((o)=>o.amount.gte(0)&&Co(o.values)))throw t.createValidationError("Invalid double street bet.");if(!r.parityBets.every((o)=>o.amount.gte(0)&&Object.values(G).includes(o.parity)))throw t.createValidationError("Invalid parity bet.");if(!r.colorBets.every((o)=>o.amount.gte(0)&&Object.values(C).includes(o.color)))throw t.createValidationError("Invalid color bet.");if(!r.halfBets.every((o)=>o.amount.gte(0)&&Object.values(Z).includes(o.half)))throw t.createValidationError("Invalid half bet.");if(!r.columnBets.every((o)=>o.amount.gte(0)&&Object.values(K).includes(o.column)))throw t.createValidationError("Invalid column bet.");if(!r.dozenBets.every((o)=>o.amount.gte(0)&&Object.values(_).includes(o.dozen)))throw t.createValidationError("Invalid dozen bet.")},h=(r)=>{return b.includes(r)};function po(r){if(r.length!==2)return!1;if(!r.every(h))return!1;return g.some(([o,i])=>o===r[0]&&i===r[1])}var yo=(r)=>{if(r.length!==3)return!1;if(!r.every(h))return!1;return or.some(([o,i,E])=>o===r[0]&&i===r[1]&&E===r[2])},Go=(r)=>{if(r.length!==4)return!1;if(!r.every(h))return!1;return Er.some(([o,i,E,A])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3])},Co=(r)=>{if(r.length!==6)return!1;if(!r.every(h))return!1;return cr.some(([o,i,E,A,c,e])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3]&&c===r[4]&&e===r[5])};var Ur=(r)=>{return new n.Big(0).add(r.straightBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.splitBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.streetBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.cornerBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.doubleStreetBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.parityBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.colorBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.halfBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.columnBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.dozenBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0)))},Fr=(r)=>{return new n.Big(0).add(r.straightBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.splitBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.streetBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.cornerBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.basketBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.doubleStreetBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.parityBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.colorBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.halfBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.columnBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0))).add(r.dozenBets.reduce((o,i)=>o.plus(i.amount),new n.Big(0)))},Zo=(r)=>{return r.type==="EUROPEAN"?Ur(r.inputs):Fr(r.inputs)};class Yr extends O{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:o}){J(o);let i=r.getRandomInt({min:0,max:36}),E=i.value,A=this.determineBetOutcomes(o,E),c=Ur(o),e=this.calculateTotalPayoutAmount(A),d=c.gt(0)?e.div(c):new n.Big(0);return{outputs:{betOutcomes:A,result:i.values},payoutMultiplier:d,isFinished:!0,randomValues:i}}determineBetOutcomes(r,o){return{winningBets:{straightBets:r.straightBets.filter((i)=>i.value===o),splitBets:r.splitBets.filter((i)=>i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>i.values.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>this.isWinningDozenBet(i,o))},losingBets:{straightBets:r.straightBets.filter((i)=>i.value!==o),splitBets:r.splitBets.filter((i)=>!i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>!i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>!i.values.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>!i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>!this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>!this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>!this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>!this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>!this.isWinningDozenBet(i,o))}}}isWinningParityBet(r,o){if(o===0)return!1;let i=o%2===0?"EVEN":"ODD";return r.parity===i}isWinningColorBet(r,o){let i=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],E=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(i.includes(o)&&r.color==="RED")return!0;if(E.includes(o)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,o){if(o>0&&o<=18&&r.half==="LOW")return!0;if(o>18&&o<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,o){let i=[3,6,9,12,15,18,21,24,27,30,33,36],E=[2,5,8,11,14,17,20,23,26,29,32,35],A=[1,4,7,10,13,16,19,22,25,28,31,34];if(i.includes(o)&&r.column==="TOP")return!0;if(E.includes(o)&&r.column==="MIDDLE")return!0;if(A.includes(o)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,o){if(o>0&&o<=12&&r.dozen==="FIRST")return!0;if(o>12&&o<=24&&r.dozen==="SECOND")return!0;if(o>24&&o<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new n.Big(0).add(r.winningBets.straightBets.reduce((o,i)=>o.plus(i.amount.mul(36)),new n.Big(0))).add(r.winningBets.splitBets.reduce((o,i)=>o.plus(i.amount.mul(18)),new n.Big(0))).add(r.winningBets.streetBets.reduce((o,i)=>o.plus(i.amount.mul(12)),new n.Big(0))).add(r.winningBets.cornerBets.reduce((o,i)=>o.plus(i.amount.mul(9)),new n.Big(0))).add(r.winningBets.doubleStreetBets.reduce((o,i)=>o.plus(i.amount.mul(6)),new n.Big(0))).add(r.winningBets.parityBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.colorBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.halfBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.columnBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n.Big(0))).add(r.winningBets.dozenBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n.Big(0)))}}class jr extends O{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:o}){Q(o);let i=r.getRandomInt({min:0,max:37}),E=i.value,A=this.determineBetOutcomes(o,E),c=Fr(o),e=this.calculateTotalPayoutAmount(A),d=c.gt(0)?e.div(c):new n.Big(0);return{outputs:{betOutcomes:A,result:i.values},payoutMultiplier:d,isFinished:!0,randomValues:i}}determineBetOutcomes(r,o){return{winningBets:{straightBets:r.straightBets.filter((i)=>i.value===o),splitBets:r.splitBets.filter((i)=>i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>i.values.some((E)=>E===o)),basketBets:r.basketBets.filter((i)=>q.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>this.isWinningDozenBet(i,o))},losingBets:{straightBets:r.straightBets.filter((i)=>i.value!==o),splitBets:r.splitBets.filter((i)=>!i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>!i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>!i.values.some((E)=>E===o)),basketBets:r.basketBets.filter((i)=>!q.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>!i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>!this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>!this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>!this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>!this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>!this.isWinningDozenBet(i,o))}}}isWinningParityBet(r,o){if(o===0||o===37)return!1;let i=o%2===0?"EVEN":"ODD";return r.parity===i}isWinningColorBet(r,o){let i=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],E=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(i.includes(o)&&r.color==="RED")return!0;if(E.includes(o)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,o){if(o>0&&o<=18&&r.half==="LOW")return!0;if(o>18&&o<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,o){let i=[3,6,9,12,15,18,21,24,27,30,33,36],E=[2,5,8,11,14,17,20,23,26,29,32,35],A=[1,4,7,10,13,16,19,22,25,28,31,34];if(i.includes(o)&&r.column==="TOP")return!0;if(E.includes(o)&&r.column==="MIDDLE")return!0;if(A.includes(o)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,o){if(o>0&&o<=12&&r.dozen==="FIRST")return!0;if(o>12&&o<=24&&r.dozen==="SECOND")return!0;if(o>24&&o<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new n.Big(0).add(r.winningBets.straightBets.reduce((o,i)=>o.plus(i.amount.mul(36)),new n.Big(0))).add(r.winningBets.splitBets.reduce((o,i)=>o.plus(i.amount.mul(18)),new n.Big(0))).add(r.winningBets.streetBets.reduce((o,i)=>o.plus(i.amount.mul(12)),new n.Big(0))).add(r.winningBets.cornerBets.reduce((o,i)=>o.plus(i.amount.mul(9)),new n.Big(0))).add(r.winningBets.basketBets.reduce((o,i)=>o.plus(i.amount.mul(7)),new n.Big(0))).add(r.winningBets.doubleStreetBets.reduce((o,i)=>o.plus(i.amount.mul(6)),new n.Big(0))).add(r.winningBets.parityBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.colorBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.halfBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n.Big(0))).add(r.winningBets.columnBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n.Big(0))).add(r.winningBets.dozenBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n.Big(0)))}}class $r extends O{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Yr,this.americanGame=new jr}determineGameResult(r){let{gameInputs:o,...i}=r;if(r.edge===2.7&&o.type==="EUROPEAN"){let E=this.europeanGame.determineGameResult({...i,gameInputs:o.inputs}),{betOutcomes:A}=E.outputs;return{...E,outputs:{type:"european",betOutcomes:A,result:E.outputs.result}}}if(r.edge===5.3&&o.type==="AMERICAN"){let E=this.americanGame.determineGameResult({...i,gameInputs:o.inputs}),{betOutcomes:A}=E.outputs;return{...E,outputs:{type:"american",betOutcomes:A,result:E.outputs.result}}}throw new Error("Only European & American Roulette games are supported")}}var Ko=(r)=>{if(r.type==="EUROPEAN")J(r.inputs);else Q(r.inputs)};var Jr=require("big.js");var N;((E)=>{E.LOW_RISK="LOW_RISK";E.MEDIUM_RISK="MEDIUM_RISK";E.HIGH_RISK="HIGH_RISK"})(N||={});var M;((c)=>{c[c.TEN=10]="TEN";c[c.TWENTY=20]="TWENTY";c[c.THIRTY=30]="THIRTY";c[c.FORTY=40]="FORTY";c[c.FIFTY=50]="FIFTY"})(M||={});var _o={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.5},20:{ZERO:0,A:1.2,B:1.5},30:{ZERO:0,A:1.2,B:1.5},40:{ZERO:0,A:1.2,B:1.5},50:{ZERO:0,A:1.2,B:1.5}},MEDIUM_RISK:{10:{ZERO:0,A:1.5,B:1.9,C:2,D:3},20:{ZERO:0,A:1.5,B:1.8,C:2,D:3},30:{ZERO:0,A:1.5,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:3},50:{ZERO:0,A:1.5,B:2,C:3,D:5}},HIGH_RISK:{10:{ZERO:0,A:9.9},20:{ZERO:0,A:19.8},30:{ZERO:0,A:29.7},40:{ZERO:0,A:39.6},50:{ZERO:0,A:49.5}}},Do={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.4},20:{ZERO:0,A:1.2,B:1.4},30:{ZERO:0,A:1.2,B:1.4},40:{ZERO:0,A:1.2,B:1.4},50:{ZERO:0,A:1.2,B:1.4}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3.1},20:{ZERO:0,A:1.5,B:1.8,C:1.9,D:3.4},30:{ZERO:0,A:1.5,B:1.7,C:1.9,D:3,E:4.3},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.9},50:{ZERO:0,A:1.5,B:2,C:3,D:4.5}},HIGH_RISK:{10:{ZERO:0,A:9.8},20:{ZERO:0,A:19.6},30:{ZERO:0,A:29.4},40:{ZERO:0,A:39.2},50:{ZERO:0,A:49}}},ao={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.65},20:{ZERO:0,A:1.15,B:1.65},30:{ZERO:0,A:1.15,B:1.65},40:{ZERO:0,A:1.15,B:1.65},50:{ZERO:0,A:1.15,B:1.65}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3},20:{ZERO:0,A:1.4,B:1.6,C:2,D:3},30:{ZERO:0,A:1.4,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.8},50:{ZERO:0,A:1.5,B:2,C:2.7,D:4.9}},HIGH_RISK:{10:{ZERO:0,A:9.7},20:{ZERO:0,A:19.4},30:{ZERO:0,A:29.1},40:{ZERO:0,A:38.8},50:{ZERO:0,A:48.5}}},No={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.55},20:{ZERO:0,A:1.15,B:1.55},30:{ZERO:0,A:1.15,B:1.55},40:{ZERO:0,A:1.15,B:1.55},50:{ZERO:0,A:1.15,B:1.55}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.8,C:2,D:3},20:{ZERO:0,A:1.3,B:1.5,C:2,D:3},30:{ZERO:0,A:1.4,B:1.6,C:2,D:2.9,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.7},50:{ZERO:0,A:1.5,B:2,C:2.6,D:4.8}},HIGH_RISK:{10:{ZERO:0,A:9.6},20:{ZERO:0,A:19.2},30:{ZERO:0,A:28.8},40:{ZERO:0,A:38.4},50:{ZERO:0,A:48}}},Mo={LOW_RISK:{10:{ZERO:0,A:1.1,B:1.5},20:{ZERO:0,A:1.1,B:1.5},30:{ZERO:0,A:1.1,B:1.45},40:{ZERO:0,A:1.1,B:1.45},50:{ZERO:0,A:1.1,B:1.45}},MEDIUM_RISK:{10:{ZERO:0,A:1.3,B:1.7,C:1.9,D:3},20:{ZERO:0,A:1.3,B:1.4,C:1.9,D:3},30:{ZERO:0,A:1.3,B:1.7,C:1.9,D:2.8,E:3.8},40:{ZERO:0,A:1.4,B:1.8,C:1.9,D:2.6},50:{ZERO:0,A:1.4,B:1.9,C:2.6,D:4.6}},HIGH_RISK:{10:{ZERO:0,A:9.2},20:{ZERO:0,A:18.4},30:{ZERO:0,A:27.6},40:{ZERO:0,A:36.8},50:{ZERO:0,A:46}}},qr=new p(new Map([[1,_o],[2,Do],[3,ao],[4,No],[8,Mo]]));var zr={LOW_RISK:{10:["B","A","A","A","ZERO","A","A","A","A","ZERO"],20:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],30:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],40:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],50:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"]},MEDIUM_RISK:{10:["ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","D"],20:["A","ZERO","C","ZERO","B","ZERO","C","ZERO","C","ZERO","A","ZERO","C","ZERO","C","ZERO","D","ZERO","C","ZERO"],30:["A","ZERO","C","ZERO","A","ZERO","C","ZERO","D","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","E","ZERO","A","ZERO","C","ZERO"],40:["C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO"],50:["A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","A","ZERO","B","ZERO","A","ZERO"]},HIGH_RISK:{10:[...Array(9).fill("ZERO"),"A"],20:[...Array(19).fill("ZERO"),"A"],30:[...Array(29).fill("ZERO"),"A"],40:[...Array(39).fill("ZERO"),"A"],50:[...Array(49).fill("ZERO"),"A"]}};class Qr extends O{constructor(){super("WHEEL")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(!Object.values(M).includes(o.segments))throw new Error("Invalid segments value");if(!Object.values(N).includes(o.riskLevel))throw new Error("Invalid risk level");let A=qr.getMultipliers(i)[o.riskLevel];if(A===void 0)throw new Error(`No multipliers found for risk level ${o.riskLevel}`);let c=A[o.segments];if(c===void 0)throw new Error(`No multipliers found for segment ${o.segments}`);let e=zr[o.riskLevel];if(e===void 0)throw new Error(`No patterns found for risk level ${o.riskLevel}`);let d=e[o.segments];if(d===void 0)throw new Error(`No patterns found for segment ${o.segments}`);let R=r.getRandomInt({min:0,max:d.length-1}),B=d[R.value];if(B===void 0)throw new Error(`No pattern found for segment ${o.segments} and value ${R.value}`);let f=c[B];if(f===void 0)throw new Error(`No payout found for picked segment ${B}`);return{isFinished:!0,payoutMultiplier:new Jr.Big(f),outputs:{result:R.values},randomValues:R}}}
package/dist/index.d.ts CHANGED
@@ -163,6 +163,15 @@ export declare class Baccarat extends Game<BaccaratGameInputs, BaccaratGameOutpu
163
163
  private shouldDrawThirdPlayerCard;
164
164
  private shouldDrawThirdBankerCard;
165
165
  }
166
+ declare class MultiplierContainer<TMultipliers> {
167
+ readonly multipliers: Map<number, TMultipliers>;
168
+ constructor(multipliers: Map<number, TMultipliers>);
169
+ getMultipliers(edge: number): TMultipliers;
170
+ getAllMultipliers(): {
171
+ edge: number;
172
+ multipliers: TMultipliers;
173
+ }[];
174
+ }
166
175
  export interface DiamondsGameInputs {
167
176
  }
168
177
  export declare enum DiamondsResultType {
@@ -174,6 +183,7 @@ export declare enum DiamondsResultType {
174
183
  FIVE_OF_A_KIND = "FIVE_OF_A_KIND"
175
184
  }
176
185
  export type DiamondsMultipliers = Record<keyof typeof DiamondsResultType, number>;
186
+ export declare const diamondsMultipliers: MultiplierContainer<DiamondsMultipliers>;
177
187
  export declare class Diamonds extends Game<DiamondsGameInputs> {
178
188
  constructor();
179
189
  protected determineGameResult({ generator, edge }: GetGameResultRequest<DiamondsGameInputs>): GameResult;
@@ -230,15 +240,6 @@ export declare class Mines extends Game<MinesGameInputs> {
230
240
  constructor();
231
241
  protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<MinesGameInputs>): GameResult;
232
242
  }
233
- declare class MultiplierContainer<TMultipliers> {
234
- readonly multipliers: Map<number, TMultipliers>;
235
- constructor(multipliers: Map<number, TMultipliers>);
236
- getMultipliers(edge: number): TMultipliers;
237
- getAllMultipliers(): {
238
- edge: number;
239
- multipliers: TMultipliers;
240
- }[];
241
- }
242
243
  export declare enum PlinkoRiskLevel {
243
244
  LOW_RISK = "LOW_RISK",
244
245
  MEDIUM_RISK = "MEDIUM_RISK",
@@ -1606,11 +1607,6 @@ export interface WheelGameInputs {
1606
1607
  segments: WheelSegments;
1607
1608
  riskLevel: WheelRiskLevel;
1608
1609
  }
1609
- export interface WheelMultipliers {
1610
- segments: WheelSegments;
1611
- payout: Record<WheelRiskLevel, number[]>;
1612
- }
1613
- export declare const wheelMultipliers: MultiplierContainer<WheelMultipliers[]>;
1614
1610
  export declare class Wheel extends Game<WheelGameInputs> {
1615
1611
  constructor();
1616
1612
  protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<WheelGameInputs>): GameResult;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var h;((f)=>{f.DICE="DICE";f.MINES="MINES";f.KENO="KENO";f.LIMBO="LIMBO";f.ADVANCED_DICE="ADVANCED_DICE";f.BACCARAT="BACCARAT";f.DIAMONDS="DIAMONDS";f.PLINKO="PLINKO";f.ROULETTE="ROULETTE";f.WHEEL="WHEEL"})(h||={});class A{gameId;constructor(r){this.gameId=r}getGameResult(r){return this.determineGameResult(r)}}import{Big as j}from"big.js";var dr;((i)=>i.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR")(dr||={});class S extends Error{static createValidationError(r){return new S("INPUT_VALIDATION_ERROR",r)}static isGameError(r){return r instanceof S}errorCode;constructor(r,i){super(i);this.errorCode=r}}var q=0,Y=1e4,Q=10001,Br=0.01,hr=98,xr=(r)=>{if(r<q)throw S.createValidationError(`Lower bound ${r} is below minimum allowed value ${q}`)},yr=(r)=>{if(r>Y)throw S.createValidationError(`Upper bound ${r} is above maximum allowed value ${Y}`)},v=(r)=>{if(xr(r.lower),yr(r.upper),r.lower>=r.upper)throw S.createValidationError(`Lower bound ${r.lower} must be less than ${r.upper}`)},_r=(r,i)=>{let[o,e]=r.lower<=i.lower?[r,i]:[i,r];if(o.upper>e.lower)throw S.createValidationError("Bounds must not overlap")},Tr=(r,i)=>i>=r.lower&&i<=r.upper,Gr=(r)=>r.upper-r.lower+1,U=(r,i)=>i>r.lower&&i<r.upper,a=(r)=>r.upper-r.lower-1,Kr;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Kr||={});var Z=(r)=>{let o=(()=>{switch(r.mode){case"ROLL_BETWEEN":return v(r.bounds),a(r.bounds);case"ROLL_OUTSIDE":return v(r.bounds),Q-Gr(r.bounds);case"ROLL_BETWEEN_TWO":return v(r.firstBounds),v(r.secondBounds),_r(r.firstBounds,r.secondBounds),a(r.firstBounds)+a(r.secondBounds)}})(),e=j(o).div(Q).mul(100);if(e.lt(Br))throw S.createValidationError("Win chance too low");if(e.gt(hr))throw S.createValidationError("Win chance too high");return e},hi=(r)=>{Z(r)};class Cr extends A{constructor(){super("ADVANCED_DICE")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=Z(o),c=r.getRandomInt({min:q,max:Y}),n=c.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(o.mode){case"ROLL_BETWEEN":return U(o.bounds,n);case"ROLL_OUTSIDE":return!Tr(o.bounds,n);case"ROLL_BETWEEN_TWO":return U(o.firstBounds,n)||U(o.secondBounds,n)}})()?new j(100-i).div(e):new j(0),outputs:{result:c.values},randomValues:c}}}import N from"big.js";var Dr=["Clubs","Diamonds","Hearts","Spades"],pr=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],Mr;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(Mr||={});var Nr;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(Nr||={});var Vr={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:8},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},wr=(r)=>{return new N(0).add(r.bets.reduce((o,e)=>o.add(e.amount),new N(0)))};class Or extends A{constructor(){super("BACCARAT")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(o!==1)throw new Error("Baccarat is only available at 1% edge.");this.validateGameInputs(i);let e=r.getRandomIntsWithReplacement({min:0,max:51,count:6}),c=e.values,n=c.slice(0,3),E=c.slice(3,6),L=[],l=0;for(let B of n.slice(0,2)){let x=this.mapRandomValueToCard(B),R=this.mapRandomValueToCardValue(B);L.push(x),l=(l+R)%10}let d=[],f=0;for(let B of E.slice(0,2)){let x=this.mapRandomValueToCard(B),R=this.mapRandomValueToCardValue(B);d.push(x),f=(f+R)%10}if(!this.isNaturalWin(l,f)){let B=this.shouldDrawThirdPlayerCard(l),x=null;if(B)x=this.mapRandomValueToCardValue(n[2]),L.push(this.mapRandomValueToCard(n[2])),l=(l+x)%10;if(this.shouldDrawThirdBankerCard(f,x))d.push(this.mapRandomValueToCard(E[2])),f=(f+this.mapRandomValueToCardValue(E[2]))%10}let y;if(l===f)y="TIE";else y=l>f?"PLAYER_WIN":"BANKER_WIN";let _=wr(i),{betType:O,multiplier:lr}=Vr[y],Lr=new N(0).add(i.bets.filter((B)=>B.type===O).reduce((B,x)=>B.add(x.amount.mul(lr)),new N(0)));return{isFinished:!0,payoutMultiplier:_.gt(0)?Lr.div(_):new N(0),outputs:{playerCards:L,playerHandValue:l,bankerCards:d,bankerHandValue:f,gameOutcome:y,result:e.values},randomValues:e}}validateGameInputs(r){if(r.bets.length===0)throw new Error("Must place at least a single bet.");if(!r.bets.every((i)=>i.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(r){let i=Dr[Math.floor(r/13)],o=pr[r%13];return{suit:i,rank:o}}isNaturalWin(r,i){let o=[8,9];return o.includes(r)||o.includes(i)}mapRandomValueToCardValue(r){let i=r%13;if(i===0)return 1;if(i>=10)return 10;return i+1}shouldDrawThirdPlayerCard(r){return r<=5}shouldDrawThirdBankerCard(r,i){if(i===null)return r<=5;if(r<=2)return!0;if(r===3)return i!==8;if(r===4)return[2,3,4,5,6,7].includes(i);if(r===5)return[4,5,6,7].includes(i);if(r===6)return[6,7].includes(i);return!1}}import Rr from"big.js";class T{multipliers;constructor(r){this.multipliers=r}getMultipliers(r){let i=this.multipliers.get(r);if(i===void 0)throw new Error(`Multipliers for ${r} not found`);return i}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([r,i])=>({edge:r,multipliers:i}))}}var vr;((E)=>{E.PAIR="PAIR";E.TWO_PAIR="TWO_PAIR";E.THREE_OF_A_KIND="THREE_OF_A_KIND";E.FULL_HOUSE="FULL_HOUSE";E.FOUR_OF_A_KIND="FOUR_OF_A_KIND";E.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(vr||={});var kr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},Hr=new T(new Map([[2,kr]])),Pr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Ur extends A{constructor(){super("DIAMONDS")}determineGameResult({generator:r,edge:i}){let o=r.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=Hr.getMultipliers(i),c=o.values,n=this.calculatePayoutMultiplier(e,c);return{isFinished:!0,payoutMultiplier:Rr(n),outputs:{result:o.values},randomValues:o}}calculatePayoutMultiplier(r,i){let o=new Map;for(let n of i){let E=o.get(n)||0;o.set(n,E+1)}let e=[...o.values()].filter((n)=>n>1),c=this.classifyResult(e);return c===null?0:r[c]}classifyResult(r){if(r.length>2)throw new Error(`Unexpected number of repeats ${r.length}`);let[i,o]=r;if(i===void 0)return null;if(o===void 0){let e=Pr[i];if(e===void 0)throw new Error(`Unexpected single diamond repeat count: ${i}`);return e}return i===3||o===3?"FULL_HOUSE":"TWO_PAIR"}}import $ from"big.js";var ar;((o)=>{o.ABOVE="ABOVE";o.BELOW="BELOW"})(ar||={});class jr extends A{constructor(){super("DICE")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=r.getRandomInt({min:0,max:1e4}),c=e.min,L=e.max-c+1-1,l=o.direction==="ABOVE"?L-o.selectedValue:o.selectedValue,d=new $(l).div(L).mul(100);return{isFinished:!0,payoutMultiplier:(o.direction==="ABOVE"?e.value>o.selectedValue:e.value<o.selectedValue)?new $(100-i).div(d):new $(0),outputs:{result:e.values},randomValues:e}}}import X from"big.js";var qr;((c)=>{c.CLASSIC="CLASSIC";c.LOW_RISK="LOW_RISK";c.MEDIUM_RISK="MEDIUM_RISK";c.HIGH_RISK="HIGH_RISK"})(qr||={});var Yr={[1]:{["CLASSIC"]:[0,3.96],["LOW_RISK"]:[0.7,1.85],["MEDIUM_RISK"]:[0.4,2.75],["HIGH_RISK"]:[0,3.96]},[2]:{["CLASSIC"]:[0,1.9,4.5],["LOW_RISK"]:[0,2,3.8],["MEDIUM_RISK"]:[0,1.8,5.1],["HIGH_RISK"]:[0,0,17.1]},[3]:{["CLASSIC"]:[0,1,3.1,10.4],["LOW_RISK"]:[0,1.1,1.38,26],["MEDIUM_RISK"]:[0,0,2.8,50],["HIGH_RISK"]:[0,0,0,81.5]},[4]:{["CLASSIC"]:[0,0.8,1.8,5,22.5],["LOW_RISK"]:[0,0,2.2,7.9,90],["MEDIUM_RISK"]:[0,0,1.7,10,100],["HIGH_RISK"]:[0,0,0,10,259]},[5]:{["CLASSIC"]:[0,0.25,1.4,4.1,16.5,36],["LOW_RISK"]:[0,0,1.5,4.2,13,300],["MEDIUM_RISK"]:[0,0,1.4,4,14,390],["HIGH_RISK"]:[0,0,0,4.5,48,450]},[6]:{["CLASSIC"]:[0,0,1,3.68,7,16.5,40],["LOW_RISK"]:[0,0,1.1,2,6.2,100,700],["MEDIUM_RISK"]:[0,0,0,3,9,180,710],["HIGH_RISK"]:[0,0,0,0,11,350,710]},[7]:{["CLASSIC"]:[0,0,0.47,3,4.5,14,31,60],["LOW_RISK"]:[0,0,1.1,1.6,3.5,15,225,700],["MEDIUM_RISK"]:[0,0,0,2,7,30,400,800],["HIGH_RISK"]:[0,0,0,0,7,90,400,800]},[8]:{["CLASSIC"]:[0,0,0,2.2,4,13,22,55,70],["LOW_RISK"]:[0,0,1.1,1.5,2,5.5,39,100,800],["MEDIUM_RISK"]:[0,0,0,2,4,11,67,400,900],["HIGH_RISK"]:[0,0,0,0,5,20,270,600,900]},[9]:{["CLASSIC"]:[0,0,0,1.55,3,8,15,44,60,85],["LOW_RISK"]:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],["MEDIUM_RISK"]:[0,0,0,2,2.5,5,15,100,500,1000],["HIGH_RISK"]:[0,0,0,0,4,11,56,500,800,1000]},[10]:{["CLASSIC"]:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],["LOW_RISK"]:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],["MEDIUM_RISK"]:[0,0,0,1.6,2,4,7,26,100,500,1000],["HIGH_RISK"]:[0,0,0,0,3.5,8,13,63,500,800,1000]}};class $r extends A{multiplierOverrides;get multipliers(){return this.multiplierOverrides??Yr}constructor(r){super("KENO");this.multiplierOverrides=r;if(r)this.validateMultiplierOverrides(r)}determineGameResult({generator:r,edge:i,gameInputs:o}){if(i!==1&&!this.multiplierOverrides)throw new Error("Multiplier overrides must be specified if an edge of 1% is not desirable");if(o.selectedNumbers.length===0)throw new Error("No numbers selected");if(o.selectedNumbers.length>10)throw new Error("Maximum of 10 numbers can be selected");for(let E of o.selectedNumbers){if(E%1!==0)throw new Error("Only integers can be selected");if(E<0||E>39)throw new Error("Invalid number selected")}let e=r.getUniqueRandomInts({min:0,max:39,count:10}),c=o.selectedNumbers.filter((E)=>e.values.includes(E));return{isFinished:!0,payoutMultiplier:c.length>0?new X(this.multipliers[o.selectedNumbers.length][o.riskLevel][c.length]??0):new X(0),outputs:{result:e.values},randomValues:e}}validateMultiplierOverrides(r){for(let[i,o]of Object.entries(r)){let e=Number(i);for(let[c,n]of Object.entries(o))if(n.length!==e+1)throw new Error(`Invalid count of multipliers for tiles ${e} and risk level ${c}. Expected ${e+1}, but got ${n.length}`)}}}import G from"big.js";var I=(r,i)=>{return r.gt(i)?r:i};var s=(r,i)=>{return r.lt(i)?r:i};class Fr extends A{constructor(){super("LIMBO")}determineGameResult({generator:r,edge:i,gameInputs:o}){let e=r.getRandomInt({min:1,max:4294967295}),c=e.max,n=new G(16777216),E=new G(1),L=new G(1e6),l=e.value,d=new G(l-1).div(c),f=(100-i)/100,y=n.div(d.mul(n).plus(1)).mul(f),_=I(E,s(y,L));return{isFinished:!0,payoutMultiplier:_.gte(o.targetMultiplier)?new G(o.targetMultiplier):new G(0),outputs:{randomMultiplier:_,result:e.values},randomValues:e}}}import k from"big.js";var F=(r,i)=>{if(i<0||r<0||i>r)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(i>r-i)i=r-i;let o=1;for(let e=1;e<=i;e++)o=o*(r-e+1)/e;return o};class zr extends A{constructor(){super("MINES")}determineGameResult({generator:r,edge:i,gameInputs:o}){if(o.minesCount<=0||o.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(o.selectedTiles.length>25-o.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let E=r.getUniqueRandomInts({min:1,max:25,count:o.minesCount}),L=E.values.some((O)=>o.selectedTiles.includes(O)),l=o.hasCashedOut||L,d=(100-i)/100,f=new k(F(25-o.minesCount,o.selectedTiles.length)).div(new k(F(25,o.selectedTiles.length))),_=o.hasCashedOut&&!L?new k(d).div(f):new k(0);return{isFinished:l,payoutMultiplier:_,outputs:{result:E.values},randomValues:E}}}import{Big as Wr}from"big.js";var Jr;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(Jr||={});var Qr=[{rows:8,payout:{["LOW_RISK"]:[5.6,2.1,1.1,1,0.5,1,1.1,2.1,5.6],["MEDIUM_RISK"]:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],["HIGH_RISK"]:[29,4,1.5,0.3,0.2,0.3,1.5,4,29]}},{rows:9,payout:{["LOW_RISK"]:[5.6,2,1.6,1,0.7,0.7,1,1.6,2,5.6],["MEDIUM_RISK"]:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],["HIGH_RISK"]:[43,7,2,0.6,0.2,0.2,0.6,2,7,43]}},{rows:10,payout:{["LOW_RISK"]:[8.9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,8.9],["MEDIUM_RISK"]:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],["HIGH_RISK"]:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76]}},{rows:11,payout:{["LOW_RISK"]:[8.4,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8.4],["MEDIUM_RISK"]:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],["HIGH_RISK"]:[120,14,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,14,120]}},{rows:12,payout:{["LOW_RISK"]:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],["MEDIUM_RISK"]:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],["HIGH_RISK"]:[170,24,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,24,170]}},{rows:13,payout:{["LOW_RISK"]:[8.1,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8.1],["MEDIUM_RISK"]:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],["HIGH_RISK"]:[260,37,11,4,1,0.2,0.2,0.2,0.2,1,4,11,37,260]}},{rows:14,payout:{["LOW_RISK"]:[7.1,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7.1],["MEDIUM_RISK"]:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],["HIGH_RISK"]:[420,56,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56,420]}},{rows:15,payout:{["LOW_RISK"]:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],["MEDIUM_RISK"]:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],["HIGH_RISK"]:[620,83,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,83,620]}},{rows:16,payout:{["LOW_RISK"]:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16],["MEDIUM_RISK"]:[110,41,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41,110],["HIGH_RISK"]:[1000,130,26,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26,130,1000]}}],Zr=new T(new Map([[1,Qr]]));class Xr extends A{constructor(){super("PLINKO")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(i.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(i.numberOfRows<8||i.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let e=Zr.getMultipliers(o),c=r.getRandomIntsWithReplacement({min:0,max:1,count:i.numberOfRows}),E=c.values.reduce((l,d)=>l+d,0);return{isFinished:!0,payoutMultiplier:new Wr(e.find((l)=>l.rows===i.numberOfRows)?.payout[i.riskLevel][E]??0),outputs:{result:c.values},randomValues:c}}}import{Big as t}from"big.js";var z=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],b=[37,...z],u=[[0,1],[0,2],[0,3],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],m=[[0,1],[0,3],[0,37],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],g=[[0,1,2],[0,2,3],[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],rr=[[0,1,2],[0,2,37],[1,2,3],[2,3,37],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],ir=[[0,1,2,3],[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],or=[[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],W=[0,1,2,3,37],er=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],cr=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],K;((o)=>{o.EVEN="EVEN";o.ODD="ODD"})(K||={});var C;((o)=>{o.RED="RED";o.BLACK="BLACK"})(C||={});var D;((o)=>{o.LOW="LOW";o.HIGH="HIGH"})(D||={});var p;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(p||={});var M;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(M||={});var J;((o)=>{o.AMERICAN="AMERICAN";o.EUROPEAN="EUROPEAN"})(J||={});var H=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw S.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((i)=>i.amount.gte(0)&&V(i.value)))throw S.createValidationError("Invalid straight bet.");if(!r.splitBets.every((i)=>i.amount.gte(0)&&Ir(i.values)))throw S.createValidationError("Invalid split bet.");if(!r.streetBets.every((i)=>i.amount.gte(0)&&sr(i.values)))throw S.createValidationError("Invalid street bet.");if(!r.cornerBets.every((i)=>i.amount.gte(0)&&br(i.values)))throw S.createValidationError("Invalid corner bet.");if(!r.doubleStreetBets.every((i)=>i.amount.gte(0)&&ur(i.values)))throw S.createValidationError("Invalid double street bet.");if(!r.parityBets.every((i)=>i.amount.gte(0)&&Object.values(K).includes(i.parity)))throw S.createValidationError("Invalid parity bet.");if(!r.colorBets.every((i)=>i.amount.gte(0)&&Object.values(C).includes(i.color)))throw S.createValidationError("Invalid color bet.");if(!r.halfBets.every((i)=>i.amount.gte(0)&&Object.values(D).includes(i.half)))throw S.createValidationError("Invalid half bet.");if(!r.columnBets.every((i)=>i.amount.gte(0)&&Object.values(p).includes(i.column)))throw S.createValidationError("Invalid column bet.");if(!r.dozenBets.every((i)=>i.amount.gte(0)&&Object.values(M).includes(i.dozen)))throw S.createValidationError("Invalid dozen bet.")},V=(r)=>{return z.includes(r)},Ir=(r)=>{if(r.length!==2)return!1;if(!r.every(V))return!1;return u.some(([i,o])=>i===r[0]&&o===r[1])},sr=(r)=>{if(r.length!==3)return!1;if(!r.every(V))return!1;return g.some(([i,o,e])=>i===r[0]&&o===r[1]&&e===r[2])},br=(r)=>{if(r.length!==4)return!1;if(!r.every(V))return!1;return ir.some(([i,o,e,c])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3])},ur=(r)=>{if(r.length!==6)return!1;if(!r.every(V))return!1;return er.some(([i,o,e,c,n,E])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3]&&n===r[4]&&E===r[5])};var P=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.basketBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw S.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((i)=>i.amount.gte(0)&&w(i.value)))throw S.createValidationError("Invalid straight bet.");if(!r.splitBets.every((i)=>i.amount.gte(0)&&mr(i.values)))throw S.createValidationError("Invalid split bet.");if(!r.streetBets.every((i)=>i.amount.gte(0)&&gr(i.values)))throw S.createValidationError("Invalid street bet.");if(!r.cornerBets.every((i)=>i.amount.gte(0)&&ri(i.values)))throw S.createValidationError("Invalid corner bet.");if(!r.basketBets.every((i)=>i.amount.gte(0)))throw S.createValidationError("Invalid basket bet.");if(!r.doubleStreetBets.every((i)=>i.amount.gte(0)&&ii(i.values)))throw S.createValidationError("Invalid double street bet.");if(!r.parityBets.every((i)=>i.amount.gte(0)&&Object.values(K).includes(i.parity)))throw S.createValidationError("Invalid parity bet.");if(!r.colorBets.every((i)=>i.amount.gte(0)&&Object.values(C).includes(i.color)))throw S.createValidationError("Invalid color bet.");if(!r.halfBets.every((i)=>i.amount.gte(0)&&Object.values(D).includes(i.half)))throw S.createValidationError("Invalid half bet.");if(!r.columnBets.every((i)=>i.amount.gte(0)&&Object.values(p).includes(i.column)))throw S.createValidationError("Invalid column bet.");if(!r.dozenBets.every((i)=>i.amount.gte(0)&&Object.values(M).includes(i.dozen)))throw S.createValidationError("Invalid dozen bet.")},w=(r)=>{return b.includes(r)};function mr(r){if(r.length!==2)return!1;if(!r.every(w))return!1;return m.some(([i,o])=>i===r[0]&&o===r[1])}var gr=(r)=>{if(r.length!==3)return!1;if(!r.every(w))return!1;return rr.some(([i,o,e])=>i===r[0]&&o===r[1]&&e===r[2])},ri=(r)=>{if(r.length!==4)return!1;if(!r.every(w))return!1;return or.some(([i,o,e,c])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3])},ii=(r)=>{if(r.length!==6)return!1;if(!r.every(w))return!1;return cr.some(([i,o,e,c,n,E])=>i===r[0]&&o===r[1]&&e===r[2]&&c===r[3]&&n===r[4]&&E===r[5])};var nr=(r)=>{return new t(0).add(r.straightBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.splitBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.streetBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.cornerBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.doubleStreetBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.parityBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.colorBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.halfBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.columnBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.dozenBets.reduce((i,o)=>i.plus(o.amount),new t(0)))},tr=(r)=>{return new t(0).add(r.straightBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.splitBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.streetBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.cornerBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.basketBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.doubleStreetBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.parityBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.colorBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.halfBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.columnBets.reduce((i,o)=>i.plus(o.amount),new t(0))).add(r.dozenBets.reduce((i,o)=>i.plus(o.amount),new t(0)))},no=(r)=>{return r.type==="EUROPEAN"?nr(r.inputs):tr(r.inputs)};class Er extends A{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:i}){H(i);let o=r.getRandomInt({min:0,max:36}),e=o.value,c=this.determineBetOutcomes(i,e),n=nr(i),E=this.calculateTotalPayoutAmount(c),L=n.gt(0)?E.div(n):new t(0);return{outputs:{betOutcomes:c,result:o.values},payoutMultiplier:L,isFinished:!0,randomValues:o}}determineBetOutcomes(r,i){return{winningBets:{straightBets:r.straightBets.filter((o)=>o.value===i),splitBets:r.splitBets.filter((o)=>o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>o.values.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>this.isWinningDozenBet(o,i))},losingBets:{straightBets:r.straightBets.filter((o)=>o.value!==i),splitBets:r.splitBets.filter((o)=>!o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>!o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>!o.values.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>!o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>!this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>!this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>!this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>!this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>!this.isWinningDozenBet(o,i))}}}isWinningParityBet(r,i){if(i===0)return!1;let o=i%2===0?"EVEN":"ODD";return r.parity===o}isWinningColorBet(r,i){let o=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],e=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(o.includes(i)&&r.color==="RED")return!0;if(e.includes(i)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,i){if(i>0&&i<=18&&r.half==="LOW")return!0;if(i>18&&i<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,i){let o=[3,6,9,12,15,18,21,24,27,30,33,36],e=[2,5,8,11,14,17,20,23,26,29,32,35],c=[1,4,7,10,13,16,19,22,25,28,31,34];if(o.includes(i)&&r.column==="TOP")return!0;if(e.includes(i)&&r.column==="MIDDLE")return!0;if(c.includes(i)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,i){if(i>0&&i<=12&&r.dozen==="FIRST")return!0;if(i>12&&i<=24&&r.dozen==="SECOND")return!0;if(i>24&&i<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new t(0).add(r.winningBets.straightBets.reduce((i,o)=>i.plus(o.amount.mul(36)),new t(0))).add(r.winningBets.splitBets.reduce((i,o)=>i.plus(o.amount.mul(18)),new t(0))).add(r.winningBets.streetBets.reduce((i,o)=>i.plus(o.amount.mul(12)),new t(0))).add(r.winningBets.cornerBets.reduce((i,o)=>i.plus(o.amount.mul(9)),new t(0))).add(r.winningBets.doubleStreetBets.reduce((i,o)=>i.plus(o.amount.mul(6)),new t(0))).add(r.winningBets.parityBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.colorBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.halfBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.columnBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t(0))).add(r.winningBets.dozenBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t(0)))}}class Sr extends A{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:i}){P(i);let o=r.getRandomInt({min:0,max:37}),e=o.value,c=this.determineBetOutcomes(i,e),n=tr(i),E=this.calculateTotalPayoutAmount(c),L=n.gt(0)?E.div(n):new t(0);return{outputs:{betOutcomes:c,result:o.values},payoutMultiplier:L,isFinished:!0,randomValues:o}}determineBetOutcomes(r,i){return{winningBets:{straightBets:r.straightBets.filter((o)=>o.value===i),splitBets:r.splitBets.filter((o)=>o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>o.values.some((e)=>e===i)),basketBets:r.basketBets.filter((o)=>W.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>this.isWinningDozenBet(o,i))},losingBets:{straightBets:r.straightBets.filter((o)=>o.value!==i),splitBets:r.splitBets.filter((o)=>!o.values.some((e)=>e===i)),streetBets:r.streetBets.filter((o)=>!o.values.some((e)=>e===i)),cornerBets:r.cornerBets.filter((o)=>!o.values.some((e)=>e===i)),basketBets:r.basketBets.filter((o)=>!W.some((e)=>e===i)),doubleStreetBets:r.doubleStreetBets.filter((o)=>!o.values.some((e)=>e===i)),parityBets:r.parityBets.filter((o)=>!this.isWinningParityBet(o,i)),colorBets:r.colorBets.filter((o)=>!this.isWinningColorBet(o,i)),halfBets:r.halfBets.filter((o)=>!this.isWinningHalfBet(o,i)),columnBets:r.columnBets.filter((o)=>!this.isWinningColumnBet(o,i)),dozenBets:r.dozenBets.filter((o)=>!this.isWinningDozenBet(o,i))}}}isWinningParityBet(r,i){if(i===0||i===37)return!1;let o=i%2===0?"EVEN":"ODD";return r.parity===o}isWinningColorBet(r,i){let o=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],e=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(o.includes(i)&&r.color==="RED")return!0;if(e.includes(i)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,i){if(i>0&&i<=18&&r.half==="LOW")return!0;if(i>18&&i<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,i){let o=[3,6,9,12,15,18,21,24,27,30,33,36],e=[2,5,8,11,14,17,20,23,26,29,32,35],c=[1,4,7,10,13,16,19,22,25,28,31,34];if(o.includes(i)&&r.column==="TOP")return!0;if(e.includes(i)&&r.column==="MIDDLE")return!0;if(c.includes(i)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,i){if(i>0&&i<=12&&r.dozen==="FIRST")return!0;if(i>12&&i<=24&&r.dozen==="SECOND")return!0;if(i>24&&i<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new t(0).add(r.winningBets.straightBets.reduce((i,o)=>i.plus(o.amount.mul(36)),new t(0))).add(r.winningBets.splitBets.reduce((i,o)=>i.plus(o.amount.mul(18)),new t(0))).add(r.winningBets.streetBets.reduce((i,o)=>i.plus(o.amount.mul(12)),new t(0))).add(r.winningBets.cornerBets.reduce((i,o)=>i.plus(o.amount.mul(9)),new t(0))).add(r.winningBets.basketBets.reduce((i,o)=>i.plus(o.amount.mul(7)),new t(0))).add(r.winningBets.doubleStreetBets.reduce((i,o)=>i.plus(o.amount.mul(6)),new t(0))).add(r.winningBets.parityBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.colorBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.halfBets.reduce((i,o)=>i.plus(o.amount.mul(2)),new t(0))).add(r.winningBets.columnBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t(0))).add(r.winningBets.dozenBets.reduce((i,o)=>i.plus(o.amount.mul(3)),new t(0)))}}class oi extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Er,this.americanGame=new Sr}determineGameResult(r){let{gameInputs:i,...o}=r;if(r.edge===2.7&&i.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...o,gameInputs:i.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:c,result:e.outputs.result}}}if(r.edge===5.3&&i.type==="AMERICAN"){let e=this.americanGame.determineGameResult({...o,gameInputs:i.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:c,result:e.outputs.result}}}throw new Error("Only European & American Roulette games are supported")}}var Ao=(r)=>{if(r.type==="EUROPEAN")H(r.inputs);else P(r.inputs)};import{Big as ei}from"big.js";var fr;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(fr||={});var Ar;((n)=>{n[n.TEN=10]="TEN";n[n.TWENTY=20]="TWENTY";n[n.THIRTY=30]="THIRTY";n[n.FORTY=40]="FORTY";n[n.FIFTY=50]="FIFTY"})(Ar||={});var ci=[{segments:10,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[0,1.9,0,1.5,0,2,0,1.5,0,3],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,9.9]}},{segments:20,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.8,0,2,0,2,0,1.5,0,2,0,2,0,3,0,2,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19.8]}},{segments:30,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.5,0,2,0,3,0,1.7,0,1.5,0,2,0,1.5,0,2,0,1.5,0,2,0,4,0,1.5,0,2,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,29.7]}},{segments:40,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[2,0,1.5,0,3,0,2,0,1.5,0,2,0,1.5,0,3,0,2,0,1.5,0,1.6,0,1.5,0,3,0,2,0,1.5,0,2,0,1.5,0,3,0,2,0,1.5,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,39.6]}},{segments:50,payout:{["LOW_RISK"]:[1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0,1.5,1.2,1.2,1.2,0,1.2,1.2,1.2,1.2,0],["MEDIUM_RISK"]:[1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,3,0,1.5,0,2,0,1.5,0,2,0,1.5,0,5,0,1.5,0,2,0,1.5,0],["HIGH_RISK"]:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49.5]}}],ni=new T(new Map([[1,ci]]));class ti extends A{constructor(){super("WHEEL")}determineGameResult({generator:r,gameInputs:i,edge:o}){if(!Object.values(Ar).includes(i.segments))throw new Error("Invalid segments value");if(!Object.values(fr).includes(i.riskLevel))throw new Error("Invalid risk level");let e=ni.getMultipliers(o).find((L)=>L.segments===i.segments);if(e===void 0)throw new Error(`Multiplier not found for segment ${i.segments}`);let c=r.getRandomInt({min:0,max:i.segments-1}),n=e.payout[i.riskLevel][c.value];if(n===void 0)throw new Error(`Payout not found for risk ${i.riskLevel} and value ${c.value}`);return{isFinished:!0,payoutMultiplier:new ei(n),outputs:{result:c.values},randomValues:c}}}export{ni as wheelMultipliers,Ao as validateRouletteGameInputs,hi as validateAdvancedDiceInputs,Zr as plinkoMultipliers,no as calculateRouletteBetAmount,wr as calculateBaccaratBetAmount,Ar as WheelSegments,fr as WheelRiskLevel,ti as Wheel,Dr as VALID_SUITS,pr as VALID_RANKS,g as VALID_EUROPEAN_STREETS,z as VALID_EUROPEAN_STRAIGHTS,u as VALID_EUROPEAN_SPLITS,er as VALID_EUROPEAN_DOUBLE_STREETS,ir as VALID_EUROPEAN_CORNERS,rr as VALID_AMERICAN_STREETS,b as VALID_AMERICAN_STRAIGHTS,m as VALID_AMERICAN_SPLITS,cr as VALID_AMERICAN_DOUBLE_STREETS,or as VALID_AMERICAN_CORNERS,J as RouletteType,oi as Roulette,Kr as RollType,q as RANDOM_MIN_VALUE,Y as RANDOM_MAX_VALUE,Jr as PlinkoRiskLevel,Xr as Plinko,K as Parity,h as OrigamiGame,zr as Mines,Br as MIN_WIN_CHANCE,hr as MAX_WIN_CHANCE,Fr as Limbo,qr as KenoRiskLevel,$r as Keno,D as Half,dr as GameErrorCode,S as GameError,A as Game,Q as EFFECTIVE_RANGE,M as Dozen,ar as DiceDirection,jr as Dice,vr as DiamondsResultType,Ur as Diamonds,p as Column,C as Color,Mr as BaccaratOutcome,Nr as BaccaratBetType,Or as Baccarat,Cr as AdvancedDice,W as AMERICAN_BASKET};
1
+ var L;((f)=>{f.DICE="DICE";f.MINES="MINES";f.KENO="KENO";f.LIMBO="LIMBO";f.ADVANCED_DICE="ADVANCED_DICE";f.BACCARAT="BACCARAT";f.DIAMONDS="DIAMONDS";f.PLINKO="PLINKO";f.ROULETTE="ROULETTE";f.WHEEL="WHEEL"})(L||={});class O{gameId;constructor(r){this.gameId=r}getGameResult(r){return this.determineGameResult(r)}}import{Big as Y}from"big.js";var Lr;((o)=>o.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR")(Lr||={});class t extends Error{static createValidationError(r){return new t("INPUT_VALIDATION_ERROR",r)}static isGameError(r){return r instanceof t}errorCode;constructor(r,o){super(o);this.errorCode=r}}var j=0,$=1e4,I=10001,Sr=0.01,xr=98,lr=(r)=>{if(r<j)throw t.createValidationError(`Lower bound ${r} is below minimum allowed value ${j}`)},pr=(r)=>{if(r>$)throw t.createValidationError(`Upper bound ${r} is above maximum allowed value ${$}`)},h=(r)=>{if(lr(r.lower),pr(r.upper),r.lower>=r.upper)throw t.createValidationError(`Lower bound ${r.lower} must be less than ${r.upper}`)},yr=(r,o)=>{let[i,E]=r.lower<=o.lower?[r,o]:[o,r];if(i.upper>E.lower)throw t.createValidationError("Bounds must not overlap")},Gr=(r,o)=>o>=r.lower&&o<=r.upper,Cr=(r)=>r.upper-r.lower+1,U=(r,o)=>o>r.lower&&o<r.upper,F=(r)=>r.upper-r.lower-1,Zr;((E)=>{E.ROLL_BETWEEN="ROLL_BETWEEN";E.ROLL_OUTSIDE="ROLL_OUTSIDE";E.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Zr||={});var u=(r)=>{let i=(()=>{switch(r.mode){case"ROLL_BETWEEN":return h(r.bounds),F(r.bounds);case"ROLL_OUTSIDE":return h(r.bounds),I-Cr(r.bounds);case"ROLL_BETWEEN_TWO":return h(r.firstBounds),h(r.secondBounds),yr(r.firstBounds,r.secondBounds),F(r.firstBounds)+F(r.secondBounds)}})(),E=Y(i).div(I).mul(100);if(E.lt(Sr))throw t.createValidationError("Win chance too low");if(E.gt(xr))throw t.createValidationError("Win chance too high");return E},_o=(r)=>{u(r)};class Kr extends O{constructor(){super("ADVANCED_DICE")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=u(i),A=r.getRandomInt({min:j,max:$}),c=A.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(i.mode){case"ROLL_BETWEEN":return U(i.bounds,c);case"ROLL_OUTSIDE":return!Gr(i.bounds,c);case"ROLL_BETWEEN_TWO":return U(i.firstBounds,c)||U(i.secondBounds,c)}})()?new Y(100-o).div(E):new Y(0),outputs:{result:A.values},randomValues:A}}}import D from"big.js";var _r=["Clubs","Diamonds","Hearts","Spades"],Dr=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],ar;((E)=>{E.PLAYER_WIN="PLAYER_WIN";E.TIE="TIE";E.BANKER_WIN="BANKER_WIN"})(ar||={});var Nr;((E)=>{E.PLAYER="PLAYER";E.TIE="TIE";E.BANKER="BANKER"})(Nr||={});var Mr={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:8},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},wr=(r)=>{return new D(0).add(r.bets.reduce((i,E)=>i.add(E.amount),new D(0)))};class Vr extends O{constructor(){super("BACCARAT")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(i!==1)throw new Error("Baccarat is only available at 1% edge.");this.validateGameInputs(o);let E=r.getRandomIntsWithReplacement({min:0,max:51,count:6}),A=E.values,c=A.slice(0,3),e=A.slice(3,6),d=[],R=0;for(let T of c.slice(0,2)){let x=this.mapRandomValueToCard(T),v=this.mapRandomValueToCardValue(T);d.push(x),R=(R+v)%10}let B=[],f=0;for(let T of e.slice(0,2)){let x=this.mapRandomValueToCard(T),v=this.mapRandomValueToCardValue(T);B.push(x),f=(f+v)%10}if(!this.isNaturalWin(R,f)){let T=this.shouldDrawThirdPlayerCard(R),x=null;if(T)x=this.mapRandomValueToCardValue(c[2]),d.push(this.mapRandomValueToCard(c[2])),R=(R+x)%10;if(this.shouldDrawThirdBankerCard(f,x))B.push(this.mapRandomValueToCard(e[2])),f=(f+this.mapRandomValueToCardValue(e[2]))%10}let S;if(R===f)S="TIE";else S=R>f?"PLAYER_WIN":"BANKER_WIN";let l=wr(o),{betType:V,multiplier:Br}=Mr[S],Tr=new D(0).add(o.bets.filter((T)=>T.type===V).reduce((T,x)=>T.add(x.amount.mul(Br)),new D(0)));return{isFinished:!0,payoutMultiplier:l.gt(0)?Tr.div(l):new D(0),outputs:{playerCards:d,playerHandValue:R,bankerCards:B,bankerHandValue:f,gameOutcome:S,result:E.values},randomValues:E}}validateGameInputs(r){if(r.bets.length===0)throw new Error("Must place at least a single bet.");if(!r.bets.every((o)=>o.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(r){let o=_r[Math.floor(r/13)],i=Dr[r%13];return{suit:o,rank:i}}isNaturalWin(r,o){let i=[8,9];return i.includes(r)||i.includes(o)}mapRandomValueToCardValue(r){let o=r%13;if(o===0)return 1;if(o>=10)return 10;return o+1}shouldDrawThirdPlayerCard(r){return r<=5}shouldDrawThirdBankerCard(r,o){if(o===null)return r<=5;if(r<=2)return!0;if(r===3)return o!==8;if(r===4)return[2,3,4,5,6,7].includes(o);if(r===5)return[4,5,6,7].includes(o);if(r===6)return[6,7].includes(o);return!1}}import vr from"big.js";class p{multipliers;constructor(r){this.multipliers=r}getMultipliers(r){let o=this.multipliers.get(r);if(o===void 0)throw new Error(`Multipliers for ${r} not found`);return o}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([r,o])=>({edge:r,multipliers:o}))}}var hr;((e)=>{e.PAIR="PAIR";e.TWO_PAIR="TWO_PAIR";e.THREE_OF_A_KIND="THREE_OF_A_KIND";e.FULL_HOUSE="FULL_HOUSE";e.FOUR_OF_A_KIND="FOUR_OF_A_KIND";e.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(hr||={});var Hr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50},kr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50},Pr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50},Ur={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50},Fr={PAIR:0.1,TWO_PAIR:2,THREE_OF_A_KIND:2.8,FULL_HOUSE:3.2,FOUR_OF_A_KIND:3.6,FIVE_OF_A_KIND:50},Yr=new p(new Map([[1,Hr],[2,kr],[3,Pr],[4,Ur],[8,Fr]])),jr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class $r extends O{constructor(){super("DIAMONDS")}determineGameResult({generator:r,edge:o}){let i=r.getRandomIntsWithReplacement({min:0,max:6,count:5}),E=Yr.getMultipliers(o),A=i.values,c=this.calculatePayoutMultiplier(E,A);return{isFinished:!0,payoutMultiplier:vr(c),outputs:{result:i.values},randomValues:i}}calculatePayoutMultiplier(r,o){let i=new Map;for(let c of o){let e=i.get(c)||0;i.set(c,e+1)}let E=[...i.values()].filter((c)=>c>1),A=this.classifyResult(E);return A===null?0:r[A]}classifyResult(r){if(r.length>2)throw new Error(`Unexpected number of repeats ${r.length}`);let[o,i]=r;if(o===void 0)return null;if(i===void 0){let E=jr[o];if(E===void 0)throw new Error(`Unexpected single diamond repeat count: ${o}`);return E}return o===3||i===3?"FULL_HOUSE":"TWO_PAIR"}}import q from"big.js";var qr;((i)=>{i.ABOVE="ABOVE";i.BELOW="BELOW"})(qr||={});class zr extends O{constructor(){super("DICE")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=r.getRandomInt({min:0,max:1e4}),A=E.min,d=E.max-A+1-1,R=i.direction==="ABOVE"?d-i.selectedValue:i.selectedValue,B=new q(R).div(d).mul(100);return{isFinished:!0,payoutMultiplier:(i.direction==="ABOVE"?E.value>i.selectedValue:E.value<i.selectedValue)?new q(100-o).div(B):new q(0),outputs:{result:E.values},randomValues:E}}}import W from"big.js";var Jr;((A)=>{A.CLASSIC="CLASSIC";A.LOW_RISK="LOW_RISK";A.MEDIUM_RISK="MEDIUM_RISK";A.HIGH_RISK="HIGH_RISK"})(Jr||={});var Qr={[1]:{["CLASSIC"]:[0,3.96],["LOW_RISK"]:[0.7,1.85],["MEDIUM_RISK"]:[0.4,2.75],["HIGH_RISK"]:[0,3.96]},[2]:{["CLASSIC"]:[0,1.9,4.5],["LOW_RISK"]:[0,2,3.8],["MEDIUM_RISK"]:[0,1.8,5.1],["HIGH_RISK"]:[0,0,17.1]},[3]:{["CLASSIC"]:[0,1,3.1,10.4],["LOW_RISK"]:[0,1.1,1.38,26],["MEDIUM_RISK"]:[0,0,2.8,50],["HIGH_RISK"]:[0,0,0,81.5]},[4]:{["CLASSIC"]:[0,0.8,1.8,5,22.5],["LOW_RISK"]:[0,0,2.2,7.9,90],["MEDIUM_RISK"]:[0,0,1.7,10,100],["HIGH_RISK"]:[0,0,0,10,259]},[5]:{["CLASSIC"]:[0,0.25,1.4,4.1,16.5,36],["LOW_RISK"]:[0,0,1.5,4.2,13,300],["MEDIUM_RISK"]:[0,0,1.4,4,14,390],["HIGH_RISK"]:[0,0,0,4.5,48,450]},[6]:{["CLASSIC"]:[0,0,1,3.68,7,16.5,40],["LOW_RISK"]:[0,0,1.1,2,6.2,100,700],["MEDIUM_RISK"]:[0,0,0,3,9,180,710],["HIGH_RISK"]:[0,0,0,0,11,350,710]},[7]:{["CLASSIC"]:[0,0,0.47,3,4.5,14,31,60],["LOW_RISK"]:[0,0,1.1,1.6,3.5,15,225,700],["MEDIUM_RISK"]:[0,0,0,2,7,30,400,800],["HIGH_RISK"]:[0,0,0,0,7,90,400,800]},[8]:{["CLASSIC"]:[0,0,0,2.2,4,13,22,55,70],["LOW_RISK"]:[0,0,1.1,1.5,2,5.5,39,100,800],["MEDIUM_RISK"]:[0,0,0,2,4,11,67,400,900],["HIGH_RISK"]:[0,0,0,0,5,20,270,600,900]},[9]:{["CLASSIC"]:[0,0,0,1.55,3,8,15,44,60,85],["LOW_RISK"]:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],["MEDIUM_RISK"]:[0,0,0,2,2.5,5,15,100,500,1000],["HIGH_RISK"]:[0,0,0,0,4,11,56,500,800,1000]},[10]:{["CLASSIC"]:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],["LOW_RISK"]:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],["MEDIUM_RISK"]:[0,0,0,1.6,2,4,7,26,100,500,1000],["HIGH_RISK"]:[0,0,0,0,3.5,8,13,63,500,800,1000]}};class Xr extends O{multiplierOverrides;get multipliers(){return this.multiplierOverrides??Qr}constructor(r){super("KENO");this.multiplierOverrides=r;if(r)this.validateMultiplierOverrides(r)}determineGameResult({generator:r,edge:o,gameInputs:i}){if(o!==1&&!this.multiplierOverrides)throw new Error("Multiplier overrides must be specified if an edge of 1% is not desirable");if(i.selectedNumbers.length===0)throw new Error("No numbers selected");if(i.selectedNumbers.length>10)throw new Error("Maximum of 10 numbers can be selected");for(let e of i.selectedNumbers){if(e%1!==0)throw new Error("Only integers can be selected");if(e<0||e>39)throw new Error("Invalid number selected")}let E=r.getUniqueRandomInts({min:0,max:39,count:10}),A=i.selectedNumbers.filter((e)=>E.values.includes(e));return{isFinished:!0,payoutMultiplier:A.length>0?new W(this.multipliers[i.selectedNumbers.length][i.riskLevel][A.length]??0):new W(0),outputs:{result:E.values},randomValues:E}}validateMultiplierOverrides(r){for(let[o,i]of Object.entries(r)){let E=Number(o);for(let[A,c]of Object.entries(i))if(c.length!==E+1)throw new Error(`Invalid count of multipliers for tiles ${E} and risk level ${A}. Expected ${E+1}, but got ${c.length}`)}}}import y from"big.js";var s=(r,o)=>{return r.gt(o)?r:o};var b=(r,o)=>{return r.lt(o)?r:o};class Ir extends O{constructor(){super("LIMBO")}determineGameResult({generator:r,edge:o,gameInputs:i}){let E=r.getRandomInt({min:1,max:4294967295}),A=E.max,c=new y(16777216),e=new y(1),d=new y(1e6),R=E.value,B=new y(R-1).div(A),f=(100-o)/100,S=c.div(B.mul(c).plus(1)).mul(f),l=s(e,b(S,d));return{isFinished:!0,payoutMultiplier:l.gte(i.targetMultiplier)?new y(i.targetMultiplier):new y(0),outputs:{randomMultiplier:l,result:E.values},randomValues:E}}}import H from"big.js";var z=(r,o)=>{if(o<0||r<0||o>r)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(o>r-o)o=r-o;let i=1;for(let E=1;E<=o;E++)i=i*(r-E+1)/E;return i};class ur extends O{constructor(){super("MINES")}determineGameResult({generator:r,edge:o,gameInputs:i}){if(i.minesCount<=0||i.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(i.selectedTiles.length>25-i.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let e=r.getUniqueRandomInts({min:1,max:25,count:i.minesCount}),d=e.values.some((V)=>i.selectedTiles.includes(V)),R=i.hasCashedOut||d,B=(100-o)/100,f=new H(z(25-i.minesCount,i.selectedTiles.length)).div(new H(z(25,i.selectedTiles.length))),l=i.hasCashedOut&&!d?new H(B).div(f):new H(0);return{isFinished:R,payoutMultiplier:l,outputs:{result:e.values},randomValues:e}}}import{Big as Wr}from"big.js";var sr;((E)=>{E.LOW_RISK="LOW_RISK";E.MEDIUM_RISK="MEDIUM_RISK";E.HIGH_RISK="HIGH_RISK"})(sr||={});var br=[{rows:8,payout:{["LOW_RISK"]:[5.6,2.1,1.1,1,0.5,1,1.1,2.1,5.6],["MEDIUM_RISK"]:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],["HIGH_RISK"]:[29,4,1.5,0.3,0.2,0.3,1.5,4,29]}},{rows:9,payout:{["LOW_RISK"]:[5.6,2,1.6,1,0.7,0.7,1,1.6,2,5.6],["MEDIUM_RISK"]:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],["HIGH_RISK"]:[43,7,2,0.6,0.2,0.2,0.6,2,7,43]}},{rows:10,payout:{["LOW_RISK"]:[8.9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,8.9],["MEDIUM_RISK"]:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],["HIGH_RISK"]:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76]}},{rows:11,payout:{["LOW_RISK"]:[8.4,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8.4],["MEDIUM_RISK"]:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],["HIGH_RISK"]:[120,14,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,14,120]}},{rows:12,payout:{["LOW_RISK"]:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],["MEDIUM_RISK"]:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],["HIGH_RISK"]:[170,24,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,24,170]}},{rows:13,payout:{["LOW_RISK"]:[8.1,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8.1],["MEDIUM_RISK"]:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],["HIGH_RISK"]:[260,37,11,4,1,0.2,0.2,0.2,0.2,1,4,11,37,260]}},{rows:14,payout:{["LOW_RISK"]:[7.1,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7.1],["MEDIUM_RISK"]:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],["HIGH_RISK"]:[420,56,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56,420]}},{rows:15,payout:{["LOW_RISK"]:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],["MEDIUM_RISK"]:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],["HIGH_RISK"]:[620,83,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,83,620]}},{rows:16,payout:{["LOW_RISK"]:[16,9,2,1.4,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,1.4,2,9,16],["MEDIUM_RISK"]:[110,41,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41,110],["HIGH_RISK"]:[1000,130,26,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26,130,1000]}}],mr=new p(new Map([[1,br]]));class gr extends O{constructor(){super("PLINKO")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(o.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(o.numberOfRows<8||o.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let E=mr.getMultipliers(i),A=r.getRandomIntsWithReplacement({min:0,max:1,count:o.numberOfRows}),e=A.values.reduce((R,B)=>R+B,0);return{isFinished:!0,payoutMultiplier:new Wr(E.find((R)=>R.rows===o.numberOfRows)?.payout[o.riskLevel][e]??0),outputs:{result:A.values},randomValues:A}}}import{Big as n}from"big.js";var J=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],m=[37,...J],g=[[0,1],[0,2],[0,3],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],rr=[[0,1],[0,3],[0,37],[1,2],[1,4],[2,3],[2,5],[3,6],[4,5],[4,7],[5,6],[5,8],[6,9],[7,8],[7,10],[8,9],[8,11],[9,12],[10,11],[10,13],[11,12],[11,14],[12,15],[13,14],[13,16],[14,15],[14,17],[15,18],[16,17],[16,19],[17,18],[17,20],[18,21],[19,20],[19,22],[20,21],[20,23],[21,24],[22,23],[22,25],[23,24],[23,26],[24,27],[25,26],[25,28],[26,27],[26,29],[27,30],[28,29],[28,31],[29,30],[29,32],[30,33],[31,32],[31,34],[32,33],[32,35],[33,36],[34,35],[35,36]],or=[[0,1,2],[0,2,3],[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],ir=[[0,1,2],[0,2,37],[1,2,3],[2,3,37],[4,5,6],[7,8,9],[10,11,12],[13,14,15],[16,17,18],[19,20,21],[22,23,24],[25,26,27],[28,29,30],[31,32,33],[34,35,36]],Er=[[0,1,2,3],[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],Ar=[[1,2,4,5],[2,3,5,6],[4,5,7,8],[5,6,8,9],[7,8,10,11],[8,9,11,12],[10,11,13,14],[11,12,14,15],[13,14,16,17],[14,15,17,18],[16,17,19,20],[17,18,20,21],[19,20,22,23],[20,21,23,24],[22,23,25,26],[23,24,26,27],[25,26,28,29],[26,27,29,30],[28,29,31,32],[29,30,32,33],[31,32,34,35],[32,33,35,36]],Q=[0,1,2,3,37],cr=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],nr=[[1,2,3,4,5,6],[4,5,6,7,8,9],[7,8,9,10,11,12],[10,11,12,13,14,15],[13,14,15,16,17,18],[16,17,18,19,20,21],[19,20,21,22,23,24],[22,23,24,25,26,27],[25,26,27,28,29,30],[28,29,30,31,32,33],[31,32,33,34,35,36]],G;((i)=>{i.EVEN="EVEN";i.ODD="ODD"})(G||={});var C;((i)=>{i.RED="RED";i.BLACK="BLACK"})(C||={});var Z;((i)=>{i.LOW="LOW";i.HIGH="HIGH"})(Z||={});var K;((E)=>{E.TOP="TOP";E.MIDDLE="MIDDLE";E.BOTTOM="BOTTOM"})(K||={});var _;((E)=>{E.FIRST="FIRST";E.SECOND="SECOND";E.THIRD="THIRD"})(_||={});var X;((i)=>{i.AMERICAN="AMERICAN";i.EUROPEAN="EUROPEAN"})(X||={});var k=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw t.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((o)=>o.amount.gte(0)&&a(o.value)))throw t.createValidationError("Invalid straight bet.");if(!r.splitBets.every((o)=>o.amount.gte(0)&&ro(o.values)))throw t.createValidationError("Invalid split bet.");if(!r.streetBets.every((o)=>o.amount.gte(0)&&oo(o.values)))throw t.createValidationError("Invalid street bet.");if(!r.cornerBets.every((o)=>o.amount.gte(0)&&io(o.values)))throw t.createValidationError("Invalid corner bet.");if(!r.doubleStreetBets.every((o)=>o.amount.gte(0)&&Eo(o.values)))throw t.createValidationError("Invalid double street bet.");if(!r.parityBets.every((o)=>o.amount.gte(0)&&Object.values(G).includes(o.parity)))throw t.createValidationError("Invalid parity bet.");if(!r.colorBets.every((o)=>o.amount.gte(0)&&Object.values(C).includes(o.color)))throw t.createValidationError("Invalid color bet.");if(!r.halfBets.every((o)=>o.amount.gte(0)&&Object.values(Z).includes(o.half)))throw t.createValidationError("Invalid half bet.");if(!r.columnBets.every((o)=>o.amount.gte(0)&&Object.values(K).includes(o.column)))throw t.createValidationError("Invalid column bet.");if(!r.dozenBets.every((o)=>o.amount.gte(0)&&Object.values(_).includes(o.dozen)))throw t.createValidationError("Invalid dozen bet.")},a=(r)=>{return J.includes(r)},ro=(r)=>{if(r.length!==2)return!1;if(!r.every(a))return!1;return g.some(([o,i])=>o===r[0]&&i===r[1])},oo=(r)=>{if(r.length!==3)return!1;if(!r.every(a))return!1;return or.some(([o,i,E])=>o===r[0]&&i===r[1]&&E===r[2])},io=(r)=>{if(r.length!==4)return!1;if(!r.every(a))return!1;return Er.some(([o,i,E,A])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3])},Eo=(r)=>{if(r.length!==6)return!1;if(!r.every(a))return!1;return cr.some(([o,i,E,A,c,e])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3]&&c===r[4]&&e===r[5])};var P=(r)=>{if(r.straightBets.length===0&&r.splitBets.length===0&&r.streetBets.length===0&&r.cornerBets.length===0&&r.basketBets.length===0&&r.doubleStreetBets.length===0&&r.parityBets.length===0&&r.colorBets.length===0&&r.halfBets.length===0&&r.columnBets.length===0&&r.dozenBets.length===0)throw t.createValidationError("Must place at least a single bet.");if(!r.straightBets.every((o)=>o.amount.gte(0)&&N(o.value)))throw t.createValidationError("Invalid straight bet.");if(!r.splitBets.every((o)=>o.amount.gte(0)&&Ao(o.values)))throw t.createValidationError("Invalid split bet.");if(!r.streetBets.every((o)=>o.amount.gte(0)&&co(o.values)))throw t.createValidationError("Invalid street bet.");if(!r.cornerBets.every((o)=>o.amount.gte(0)&&no(o.values)))throw t.createValidationError("Invalid corner bet.");if(!r.basketBets.every((o)=>o.amount.gte(0)))throw t.createValidationError("Invalid basket bet.");if(!r.doubleStreetBets.every((o)=>o.amount.gte(0)&&eo(o.values)))throw t.createValidationError("Invalid double street bet.");if(!r.parityBets.every((o)=>o.amount.gte(0)&&Object.values(G).includes(o.parity)))throw t.createValidationError("Invalid parity bet.");if(!r.colorBets.every((o)=>o.amount.gte(0)&&Object.values(C).includes(o.color)))throw t.createValidationError("Invalid color bet.");if(!r.halfBets.every((o)=>o.amount.gte(0)&&Object.values(Z).includes(o.half)))throw t.createValidationError("Invalid half bet.");if(!r.columnBets.every((o)=>o.amount.gte(0)&&Object.values(K).includes(o.column)))throw t.createValidationError("Invalid column bet.");if(!r.dozenBets.every((o)=>o.amount.gte(0)&&Object.values(_).includes(o.dozen)))throw t.createValidationError("Invalid dozen bet.")},N=(r)=>{return m.includes(r)};function Ao(r){if(r.length!==2)return!1;if(!r.every(N))return!1;return rr.some(([o,i])=>o===r[0]&&i===r[1])}var co=(r)=>{if(r.length!==3)return!1;if(!r.every(N))return!1;return ir.some(([o,i,E])=>o===r[0]&&i===r[1]&&E===r[2])},no=(r)=>{if(r.length!==4)return!1;if(!r.every(N))return!1;return Ar.some(([o,i,E,A])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3])},eo=(r)=>{if(r.length!==6)return!1;if(!r.every(N))return!1;return nr.some(([o,i,E,A,c,e])=>o===r[0]&&i===r[1]&&E===r[2]&&A===r[3]&&c===r[4]&&e===r[5])};var er=(r)=>{return new n(0).add(r.straightBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.splitBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.streetBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.cornerBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.doubleStreetBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.parityBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.colorBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.halfBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.columnBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.dozenBets.reduce((o,i)=>o.plus(i.amount),new n(0)))},tr=(r)=>{return new n(0).add(r.straightBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.splitBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.streetBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.cornerBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.basketBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.doubleStreetBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.parityBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.colorBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.halfBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.columnBets.reduce((o,i)=>o.plus(i.amount),new n(0))).add(r.dozenBets.reduce((o,i)=>o.plus(i.amount),new n(0)))},Li=(r)=>{return r.type==="EUROPEAN"?er(r.inputs):tr(r.inputs)};class fr extends O{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:o}){k(o);let i=r.getRandomInt({min:0,max:36}),E=i.value,A=this.determineBetOutcomes(o,E),c=er(o),e=this.calculateTotalPayoutAmount(A),d=c.gt(0)?e.div(c):new n(0);return{outputs:{betOutcomes:A,result:i.values},payoutMultiplier:d,isFinished:!0,randomValues:i}}determineBetOutcomes(r,o){return{winningBets:{straightBets:r.straightBets.filter((i)=>i.value===o),splitBets:r.splitBets.filter((i)=>i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>i.values.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>this.isWinningDozenBet(i,o))},losingBets:{straightBets:r.straightBets.filter((i)=>i.value!==o),splitBets:r.splitBets.filter((i)=>!i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>!i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>!i.values.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>!i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>!this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>!this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>!this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>!this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>!this.isWinningDozenBet(i,o))}}}isWinningParityBet(r,o){if(o===0)return!1;let i=o%2===0?"EVEN":"ODD";return r.parity===i}isWinningColorBet(r,o){let i=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],E=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(i.includes(o)&&r.color==="RED")return!0;if(E.includes(o)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,o){if(o>0&&o<=18&&r.half==="LOW")return!0;if(o>18&&o<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,o){let i=[3,6,9,12,15,18,21,24,27,30,33,36],E=[2,5,8,11,14,17,20,23,26,29,32,35],A=[1,4,7,10,13,16,19,22,25,28,31,34];if(i.includes(o)&&r.column==="TOP")return!0;if(E.includes(o)&&r.column==="MIDDLE")return!0;if(A.includes(o)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,o){if(o>0&&o<=12&&r.dozen==="FIRST")return!0;if(o>12&&o<=24&&r.dozen==="SECOND")return!0;if(o>24&&o<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new n(0).add(r.winningBets.straightBets.reduce((o,i)=>o.plus(i.amount.mul(36)),new n(0))).add(r.winningBets.splitBets.reduce((o,i)=>o.plus(i.amount.mul(18)),new n(0))).add(r.winningBets.streetBets.reduce((o,i)=>o.plus(i.amount.mul(12)),new n(0))).add(r.winningBets.cornerBets.reduce((o,i)=>o.plus(i.amount.mul(9)),new n(0))).add(r.winningBets.doubleStreetBets.reduce((o,i)=>o.plus(i.amount.mul(6)),new n(0))).add(r.winningBets.parityBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.colorBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.halfBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.columnBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n(0))).add(r.winningBets.dozenBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n(0)))}}class Rr extends O{constructor(){super("ROULETTE")}determineGameResult({generator:r,gameInputs:o}){P(o);let i=r.getRandomInt({min:0,max:37}),E=i.value,A=this.determineBetOutcomes(o,E),c=tr(o),e=this.calculateTotalPayoutAmount(A),d=c.gt(0)?e.div(c):new n(0);return{outputs:{betOutcomes:A,result:i.values},payoutMultiplier:d,isFinished:!0,randomValues:i}}determineBetOutcomes(r,o){return{winningBets:{straightBets:r.straightBets.filter((i)=>i.value===o),splitBets:r.splitBets.filter((i)=>i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>i.values.some((E)=>E===o)),basketBets:r.basketBets.filter((i)=>Q.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>this.isWinningDozenBet(i,o))},losingBets:{straightBets:r.straightBets.filter((i)=>i.value!==o),splitBets:r.splitBets.filter((i)=>!i.values.some((E)=>E===o)),streetBets:r.streetBets.filter((i)=>!i.values.some((E)=>E===o)),cornerBets:r.cornerBets.filter((i)=>!i.values.some((E)=>E===o)),basketBets:r.basketBets.filter((i)=>!Q.some((E)=>E===o)),doubleStreetBets:r.doubleStreetBets.filter((i)=>!i.values.some((E)=>E===o)),parityBets:r.parityBets.filter((i)=>!this.isWinningParityBet(i,o)),colorBets:r.colorBets.filter((i)=>!this.isWinningColorBet(i,o)),halfBets:r.halfBets.filter((i)=>!this.isWinningHalfBet(i,o)),columnBets:r.columnBets.filter((i)=>!this.isWinningColumnBet(i,o)),dozenBets:r.dozenBets.filter((i)=>!this.isWinningDozenBet(i,o))}}}isWinningParityBet(r,o){if(o===0||o===37)return!1;let i=o%2===0?"EVEN":"ODD";return r.parity===i}isWinningColorBet(r,o){let i=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],E=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];if(i.includes(o)&&r.color==="RED")return!0;if(E.includes(o)&&r.color==="BLACK")return!0;return!1}isWinningHalfBet(r,o){if(o>0&&o<=18&&r.half==="LOW")return!0;if(o>18&&o<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(r,o){let i=[3,6,9,12,15,18,21,24,27,30,33,36],E=[2,5,8,11,14,17,20,23,26,29,32,35],A=[1,4,7,10,13,16,19,22,25,28,31,34];if(i.includes(o)&&r.column==="TOP")return!0;if(E.includes(o)&&r.column==="MIDDLE")return!0;if(A.includes(o)&&r.column==="BOTTOM")return!0;return!1}isWinningDozenBet(r,o){if(o>0&&o<=12&&r.dozen==="FIRST")return!0;if(o>12&&o<=24&&r.dozen==="SECOND")return!0;if(o>24&&o<=36&&r.dozen==="THIRD")return!0;return!1}calculateTotalPayoutAmount(r){return new n(0).add(r.winningBets.straightBets.reduce((o,i)=>o.plus(i.amount.mul(36)),new n(0))).add(r.winningBets.splitBets.reduce((o,i)=>o.plus(i.amount.mul(18)),new n(0))).add(r.winningBets.streetBets.reduce((o,i)=>o.plus(i.amount.mul(12)),new n(0))).add(r.winningBets.cornerBets.reduce((o,i)=>o.plus(i.amount.mul(9)),new n(0))).add(r.winningBets.basketBets.reduce((o,i)=>o.plus(i.amount.mul(7)),new n(0))).add(r.winningBets.doubleStreetBets.reduce((o,i)=>o.plus(i.amount.mul(6)),new n(0))).add(r.winningBets.parityBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.colorBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.halfBets.reduce((o,i)=>o.plus(i.amount.mul(2)),new n(0))).add(r.winningBets.columnBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n(0))).add(r.winningBets.dozenBets.reduce((o,i)=>o.plus(i.amount.mul(3)),new n(0)))}}class to extends O{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new fr,this.americanGame=new Rr}determineGameResult(r){let{gameInputs:o,...i}=r;if(r.edge===2.7&&o.type==="EUROPEAN"){let E=this.europeanGame.determineGameResult({...i,gameInputs:o.inputs}),{betOutcomes:A}=E.outputs;return{...E,outputs:{type:"european",betOutcomes:A,result:E.outputs.result}}}if(r.edge===5.3&&o.type==="AMERICAN"){let E=this.americanGame.determineGameResult({...i,gameInputs:o.inputs}),{betOutcomes:A}=E.outputs;return{...E,outputs:{type:"american",betOutcomes:A,result:E.outputs.result}}}throw new Error("Only European & American Roulette games are supported")}}var yi=(r)=>{if(r.type==="EUROPEAN")k(r.inputs);else P(r.inputs)};import{Big as Lo}from"big.js";var M;((E)=>{E.LOW_RISK="LOW_RISK";E.MEDIUM_RISK="MEDIUM_RISK";E.HIGH_RISK="HIGH_RISK"})(M||={});var w;((c)=>{c[c.TEN=10]="TEN";c[c.TWENTY=20]="TWENTY";c[c.THIRTY=30]="THIRTY";c[c.FORTY=40]="FORTY";c[c.FIFTY=50]="FIFTY"})(w||={});var fo={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.5},20:{ZERO:0,A:1.2,B:1.5},30:{ZERO:0,A:1.2,B:1.5},40:{ZERO:0,A:1.2,B:1.5},50:{ZERO:0,A:1.2,B:1.5}},MEDIUM_RISK:{10:{ZERO:0,A:1.5,B:1.9,C:2,D:3},20:{ZERO:0,A:1.5,B:1.8,C:2,D:3},30:{ZERO:0,A:1.5,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:3},50:{ZERO:0,A:1.5,B:2,C:3,D:5}},HIGH_RISK:{10:{ZERO:0,A:9.9},20:{ZERO:0,A:19.8},30:{ZERO:0,A:29.7},40:{ZERO:0,A:39.6},50:{ZERO:0,A:49.5}}},Ro={LOW_RISK:{10:{ZERO:0,A:1.2,B:1.4},20:{ZERO:0,A:1.2,B:1.4},30:{ZERO:0,A:1.2,B:1.4},40:{ZERO:0,A:1.2,B:1.4},50:{ZERO:0,A:1.2,B:1.4}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3.1},20:{ZERO:0,A:1.5,B:1.8,C:1.9,D:3.4},30:{ZERO:0,A:1.5,B:1.7,C:1.9,D:3,E:4.3},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.9},50:{ZERO:0,A:1.5,B:2,C:3,D:4.5}},HIGH_RISK:{10:{ZERO:0,A:9.8},20:{ZERO:0,A:19.6},30:{ZERO:0,A:29.4},40:{ZERO:0,A:39.2},50:{ZERO:0,A:49}}},Oo={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.65},20:{ZERO:0,A:1.15,B:1.65},30:{ZERO:0,A:1.15,B:1.65},40:{ZERO:0,A:1.15,B:1.65},50:{ZERO:0,A:1.15,B:1.65}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.9,C:2,D:3},20:{ZERO:0,A:1.4,B:1.6,C:2,D:3},30:{ZERO:0,A:1.4,B:1.7,C:2,D:3,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.8},50:{ZERO:0,A:1.5,B:2,C:2.7,D:4.9}},HIGH_RISK:{10:{ZERO:0,A:9.7},20:{ZERO:0,A:19.4},30:{ZERO:0,A:29.1},40:{ZERO:0,A:38.8},50:{ZERO:0,A:48.5}}},Bo={LOW_RISK:{10:{ZERO:0,A:1.15,B:1.55},20:{ZERO:0,A:1.15,B:1.55},30:{ZERO:0,A:1.15,B:1.55},40:{ZERO:0,A:1.15,B:1.55},50:{ZERO:0,A:1.15,B:1.55}},MEDIUM_RISK:{10:{ZERO:0,A:1.4,B:1.8,C:2,D:3},20:{ZERO:0,A:1.3,B:1.5,C:2,D:3},30:{ZERO:0,A:1.4,B:1.6,C:2,D:2.9,E:4},40:{ZERO:0,A:1.5,B:1.6,C:2,D:2.7},50:{ZERO:0,A:1.5,B:2,C:2.6,D:4.8}},HIGH_RISK:{10:{ZERO:0,A:9.6},20:{ZERO:0,A:19.2},30:{ZERO:0,A:28.8},40:{ZERO:0,A:38.4},50:{ZERO:0,A:48}}},To={LOW_RISK:{10:{ZERO:0,A:1.1,B:1.5},20:{ZERO:0,A:1.1,B:1.5},30:{ZERO:0,A:1.1,B:1.45},40:{ZERO:0,A:1.1,B:1.45},50:{ZERO:0,A:1.1,B:1.45}},MEDIUM_RISK:{10:{ZERO:0,A:1.3,B:1.7,C:1.9,D:3},20:{ZERO:0,A:1.3,B:1.4,C:1.9,D:3},30:{ZERO:0,A:1.3,B:1.7,C:1.9,D:2.8,E:3.8},40:{ZERO:0,A:1.4,B:1.8,C:1.9,D:2.6},50:{ZERO:0,A:1.4,B:1.9,C:2.6,D:4.6}},HIGH_RISK:{10:{ZERO:0,A:9.2},20:{ZERO:0,A:18.4},30:{ZERO:0,A:27.6},40:{ZERO:0,A:36.8},50:{ZERO:0,A:46}}},Or=new p(new Map([[1,fo],[2,Ro],[3,Oo],[4,Bo],[8,To]]));var dr={LOW_RISK:{10:["B","A","A","A","ZERO","A","A","A","A","ZERO"],20:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],30:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],40:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],50:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"]},MEDIUM_RISK:{10:["ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","D"],20:["A","ZERO","C","ZERO","B","ZERO","C","ZERO","C","ZERO","A","ZERO","C","ZERO","C","ZERO","D","ZERO","C","ZERO"],30:["A","ZERO","C","ZERO","A","ZERO","C","ZERO","D","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","E","ZERO","A","ZERO","C","ZERO"],40:["C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO"],50:["A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","A","ZERO","B","ZERO","A","ZERO"]},HIGH_RISK:{10:[...Array(9).fill("ZERO"),"A"],20:[...Array(19).fill("ZERO"),"A"],30:[...Array(29).fill("ZERO"),"A"],40:[...Array(39).fill("ZERO"),"A"],50:[...Array(49).fill("ZERO"),"A"]}};class So extends O{constructor(){super("WHEEL")}determineGameResult({generator:r,gameInputs:o,edge:i}){if(!Object.values(w).includes(o.segments))throw new Error("Invalid segments value");if(!Object.values(M).includes(o.riskLevel))throw new Error("Invalid risk level");let A=Or.getMultipliers(i)[o.riskLevel];if(A===void 0)throw new Error(`No multipliers found for risk level ${o.riskLevel}`);let c=A[o.segments];if(c===void 0)throw new Error(`No multipliers found for segment ${o.segments}`);let e=dr[o.riskLevel];if(e===void 0)throw new Error(`No patterns found for risk level ${o.riskLevel}`);let d=e[o.segments];if(d===void 0)throw new Error(`No patterns found for segment ${o.segments}`);let R=r.getRandomInt({min:0,max:d.length-1}),B=d[R.value];if(B===void 0)throw new Error(`No pattern found for segment ${o.segments} and value ${R.value}`);let f=c[B];if(f===void 0)throw new Error(`No payout found for picked segment ${B}`);return{isFinished:!0,payoutMultiplier:new Lo(f),outputs:{result:R.values},randomValues:R}}}export{yi as validateRouletteGameInputs,_o as validateAdvancedDiceInputs,mr as plinkoMultipliers,Yr as diamondsMultipliers,Li as calculateRouletteBetAmount,wr as calculateBaccaratBetAmount,w as WheelSegments,M as WheelRiskLevel,So as Wheel,_r as VALID_SUITS,Dr as VALID_RANKS,or as VALID_EUROPEAN_STREETS,J as VALID_EUROPEAN_STRAIGHTS,g as VALID_EUROPEAN_SPLITS,cr as VALID_EUROPEAN_DOUBLE_STREETS,Er as VALID_EUROPEAN_CORNERS,ir as VALID_AMERICAN_STREETS,m as VALID_AMERICAN_STRAIGHTS,rr as VALID_AMERICAN_SPLITS,nr as VALID_AMERICAN_DOUBLE_STREETS,Ar as VALID_AMERICAN_CORNERS,X as RouletteType,to as Roulette,Zr as RollType,j as RANDOM_MIN_VALUE,$ as RANDOM_MAX_VALUE,sr as PlinkoRiskLevel,gr as Plinko,G as Parity,L as OrigamiGame,ur as Mines,Sr as MIN_WIN_CHANCE,xr as MAX_WIN_CHANCE,Ir as Limbo,Jr as KenoRiskLevel,Xr as Keno,Z as Half,Lr as GameErrorCode,t as GameError,O as Game,I as EFFECTIVE_RANGE,_ as Dozen,qr as DiceDirection,zr as Dice,hr as DiamondsResultType,$r as Diamonds,K as Column,C as Color,ar as BaccaratOutcome,Nr as BaccaratBetType,Vr as Baccarat,Kr as AdvancedDice,Q as AMERICAN_BASKET};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betorigami/game-calculations",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",