@betorigami/game-calculations 8.0.1 → 8.1.0

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 Kr=Object.create;var{getPrototypeOf:vr,defineProperty:Q,getOwnPropertyNames:Ra,getOwnPropertyDescriptor:to}=Object,_a=Object.prototype.hasOwnProperty;var O=(t,a,r)=>{r=t!=null?Kr(vr(t)):{};let o=a||!t||!t.__esModule?Q(r,"default",{value:t,enumerable:!0}):r;for(let n of Ra(t))if(!_a.call(o,n))Q(o,n,{get:()=>t[n],enumerable:!0});return o},Ta=new WeakMap,ao=(t)=>{var a=Ta.get(t),r;if(a)return a;if(a=Q({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")Ra(t).map((o)=>!_a.call(a,o)&&Q(a,o,{get:()=>t[o],enumerable:!(r=to(t,o))||r.enumerable}));return Ta.set(t,a),a};var ro=(t,a)=>{for(var r in a)Q(t,r,{get:a[r],enumerable:!0,configurable:!0,set:(o)=>a[r]=()=>o})};var nn={};ro(nn,{validateRouletteGameInputs:()=>Da,validateAdvancedDiceInputs:()=>co,sumPayout:()=>b,rtp99Multipliers:()=>Tr,rtp98Multipliers:()=>Rr,rtp97Multipliers:()=>_r,rtp96Multipliers:()=>Nr,rtp92Multipliers:()=>wr,plinkoMultipliers:()=>sa,nCr:()=>Nt,kenoMultipliers:()=>ia,isTileCount:()=>ca,hasDiceWon:()=>Pr,hasBlitzWon:()=>Br,getMaxMultiplierForDifficulty:()=>jo,getBlitzDefaults:()=>Oo,diamondsMultipliers:()=>Hr,calculateRouletteBetAmount:()=>Ko,calculateDiceWinChance:()=>xr,calculateBlitzWinChance:()=>mr,calculateBaccaratBetAmount:()=>Ft,calculateAdvancedDiceWinChance:()=>Gt,bigMin:()=>da,bigMax:()=>la,advancedDiceIsWithinBoundsInclusive:()=>Ia,advancedDiceIsWithinBoundsExclusive:()=>At,advancedDiceGetInclusiveBoundsRange:()=>Za,advancedDiceGetExclusiveBoundsRange:()=>pt,WheelSegments:()=>X,WheelRiskLevel:()=>q,Wheel:()=>Wr,WIN_MULTIPLIER:()=>Wa,VALID_SUITS:()=>io,VALID_RANKS:()=>lo,VALID_EUROPEAN_STREETS:()=>ma,VALID_EUROPEAN_STRAIGHTS:()=>wt,VALID_EUROPEAN_SPLITS:()=>pa,VALID_EUROPEAN_DOUBLE_STREETS:()=>Sa,VALID_EUROPEAN_CORNERS:()=>ya,VALID_AMERICAN_STREETS:()=>Ea,VALID_AMERICAN_STRAIGHTS:()=>Aa,VALID_AMERICAN_SPLITS:()=>Ba,VALID_AMERICAN_DOUBLE_STREETS:()=>Ha,VALID_AMERICAN_CORNERS:()=>fa,ThreeCardBonusType:()=>Ht,TOP_COLUMN:()=>Fr,TILE_COUNTS:()=>jr,THREE_CARD_BONUS_PAYOUTS:()=>zt,SingleActionGame:()=>B,SPLIT_BET_SIZE_FACTOR:()=>w,RouletteType:()=>Vt,Roulette:()=>Pa,RollType:()=>ka,RandomValuePool:()=>ot,RED_NUMBERS:()=>$r,RANDOM_MIN_VALUE:()=>W,RANDOM_MAX_VALUE:()=>g,PlinkoRiskLevel:()=>ua,Plinko:()=>Gr,Parity:()=>I,PairBonusType:()=>St,PUSH_MULTIPLIER:()=>ga,PLINKO_ROW_COUNTS:()=>Zo,PAYOUT_MULTIPLIERS:()=>Mr,PAIR_BONUS_PAYOUTS:()=>$t,OrigamiGame:()=>y,MultiplierCalculator:()=>C,MultiActionGame:()=>Pt,Mines:()=>Zr,MIN_WIN_CHANCE:()=>Va,MIDDLE_COLUMN:()=>Jr,MAX_WIN_CHANCE:()=>Ua,MAX_CARDS_PER_ROUND:()=>ht,Limbo:()=>Ir,LOSE_MULTIPLIER:()=>La,KenoRiskLevel:()=>ea,Keno:()=>Ur,InsuranceOutcome:()=>ft,INSURANCE_WIN_PAYOUT:()=>Ct,INSURANCE_BET_SIZE_FACTOR:()=>F,INSURANCE_BET_MULTIPLIER:()=>po,Half:()=>k,GameErrorCode:()=>Na,GameError:()=>l,FACE_CARD_VALUE:()=>Yt,EuropeanRoulette:()=>Ca,EUROPEAN_HOUSE_EDGE:()=>$,EFFECTIVE_RANGE:()=>Zt,Dozen:()=>M,DiceDirection:()=>hr,Dice:()=>br,DiamondsResultType:()=>Sr,Diamonds:()=>Dr,Darts:()=>fr,DOUBLE_DOWN_BET_SIZE_FACTOR:()=>j,DICE_MIN_ROLL:()=>na,DICE_MAX_ROLL:()=>_t,DICE_EFFECTIVE_RANGE:()=>Cr,DEALER_STAND_VALUE:()=>Jt,DARTS_MIN_VALUE:()=>aa,DARTS_MAX_VALUE:()=>jt,DARTS_DIFFICULTY_LEVEL:()=>ra,DARTS_BOARD_CONFIGS:()=>Tt,Column:()=>G,Color:()=>Z,CARDS_PER_SUIT:()=>Bo,Blitz:()=>Er,BlackjackOutcome:()=>yt,BlackjackActionType:()=>Ot,Blackjack:()=>pr,BaccaratOutcome:()=>za,BaccaratBetType:()=>qa,Baccarat:()=>Xa,BUST_VALUE:()=>Dt,BOTTOM_COLUMN:()=>Yr,BLITZ_RANDOM_NUMBER_COUNT:()=>vt,BLITZ_MIN_CARD_RANGE:()=>Lt,BLITZ_MAX_CARD_RANGE:()=>Kt,BLITZ_CARD_COUNT:()=>J,BLACK_NUMBERS:()=>zr,BLACKJACK_VALUE:()=>D,BLACKJACK_MULTIPLIER:()=>Qa,BASE_PAYOUT_MULTIPLIERS:()=>K,AmericanRoulette:()=>xa,AdvancedDice:()=>Ga,AMERICAN_HOUSE_EDGE:()=>z,AMERICAN_BASKET:()=>Oa,ACE_SOFT_BONUS:()=>xt});module.exports=ao(nn);var Na;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(Na||={});class l extends Error{static createUnsupportedEdgeError(t){return new l("UNSUPPORTED_EDGE",t)}static createValidationError(t){return new l("INPUT_VALIDATION_ERROR",t)}static isGameError(t){return t instanceof l}errorCode;constructor(t,a){super(a);this.errorCode=t}}var y;((p)=>{p.DICE="DICE";p.MINES="MINES";p.KENO="KENO";p.LIMBO="LIMBO";p.ADVANCED_DICE="ADVANCED_DICE";p.BACCARAT="BACCARAT";p.DIAMONDS="DIAMONDS";p.PLINKO="PLINKO";p.ROULETTE="ROULETTE";p.WHEEL="WHEEL";p.BLACKJACK="BLACKJACK";p.BLITZ="BLITZ";p.DARTS="DARTS"})(y||={});var wa=require("@betorigami/guard");class B{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return wa.Guard.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}var kt=require("big.js");var ut=O(require("big.js"));class C{static withMultiplier(t,a){return new ut.default(t).times(new ut.default(100-a).div(100))}static withWinChance(t,a){return ut.default(100-t).div(a)}}var W=0,g=1e4,Zt=g-W+1,Va=0.01,Ua=98,oo=(t)=>{if(t<W)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${W}`)},no=(t)=>{if(t>g)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${g}`)},st=(t)=>{if(oo(t.lower),no(t.upper),t.lower>=t.upper)throw l.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},eo=(t,a)=>{let[r,o]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>o.lower)throw l.createValidationError("Bounds must not overlap")},Ia=(t,a)=>a>=t.lower&&a<=t.upper,Za=(t)=>t.upper-t.lower+1,At=(t,a)=>a>t.lower&&a<t.upper,pt=(t)=>t.upper-t.lower-1,ka;((o)=>{o.ROLL_BETWEEN="ROLL_BETWEEN";o.ROLL_OUTSIDE="ROLL_OUTSIDE";o.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(ka||={});var Gt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return st(t.bounds),pt(t.bounds);case"ROLL_OUTSIDE":return st(t.bounds),Zt-Za(t.bounds);case"ROLL_BETWEEN_TWO":return st(t.firstBounds),st(t.secondBounds),eo(t.firstBounds,t.secondBounds),pt(t.firstBounds)+pt(t.secondBounds)}})(),o=kt.Big(r).div(Zt).mul(100);if(o.lt(Va))throw l.createValidationError("Win chance too low");if(o.gt(Ua))throw l.createValidationError("Win chance too high");return o},co=(t)=>{Gt(t)};class Ga extends B{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let o=Gt(r),n=t.getRandomInt({min:W,max:g}),e=n.value,i=(()=>{switch(r.mode){case"ROLL_BETWEEN":return At(r.bounds,e);case"ROLL_OUTSIDE":return!Ia(r.bounds,e);case"ROLL_BETWEEN_TWO":return At(r.firstBounds,e)||At(r.secondBounds,e)}})()?C.withWinChance(a,o):new kt.Big(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:n.values},randomValues:n}}}var L=O(require("big.js"));var Et=require("@betorigami/guard");var Ma=0,Fa=51,Bt=Array.from({length:52},(t,a)=>a),Ja=["Spades","Hearts","Diamonds","Clubs"],mt=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Ya=["Jack","Queen","King"],Mt={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};class N{value;constructor(t){let a=Bt[t];Et.Guard.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=Ja[t];return Et.Guard.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=mt[t];return Et.Guard.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}var $a=O(require("big.js")),b=(t)=>t.legs.reduce((a,r)=>a.add(r.amount),new $a.default("0"));var io=["Clubs","Diamonds","Hearts","Spades"],lo=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],uo={Ace:"Ace",Two:"2",Three:"3",Four:"4",Five:"5",Six:"6",Seven:"7",Eight:"8",Nine:"9",Ten:"10",Jack:"Jack",Queen:"Queen",King:"King"},za;((o)=>{o.PLAYER_WIN="PLAYER_WIN";o.TIE="TIE";o.BANKER_WIN="BANKER_WIN"})(za||={});var qa;((o)=>{o.PLAYER="PLAYER";o.TIE="TIE";o.BANKER="BANKER"})(qa||={});var so={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Ft=(t)=>{return new L.default(0).add(t.bets.reduce((r,o)=>r.add(o.amount),new L.default(0)))},Ao=(t,a)=>t==="TIE"&&(a==="PLAYER"||a==="BANKER");class Xa extends B{constructor(){super("BACCARAT")}get supportedEdgeConfigurations(){return[1]}getBetAmount(t){return Ft(t)}determineGameResult({generator:t,gameInputs:a}){this.validateGameInputs(a);let r=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),o=r.values,n=o.slice(0,3),e=o.slice(3,6),c=[],i=0;for(let H of n.slice(0,2)){let _=this.mapRandomValueToCard(H),dt=this.mapRandomValueToCardValue(H);c.push(_),i=(i+dt)%10}let u=[],d=0;for(let H of e.slice(0,2)){let _=this.mapRandomValueToCard(H),dt=this.mapRandomValueToCardValue(H);u.push(_),d=(d+dt)%10}if(!this.isNaturalWin(i,d)){let H=this.shouldDrawThirdPlayerCard(i),_=null;if(H)_=this.mapRandomValueToCardValue(n[2]),c.push(this.mapRandomValueToCard(n[2])),i=(i+_)%10;if(this.shouldDrawThirdBankerCard(d,_))u.push(this.mapRandomValueToCard(e[2])),d=(d+this.mapRandomValueToCardValue(e[2]))%10}let s;if(i===d)s="TIE";else s=i>d?"PLAYER_WIN":"BANKER_WIN";let A=Ft(a),{betType:m,multiplier:p}=so[s],ja={legs:a.bets.map((H)=>{if(H.type===m)return{amount:H.amount.mul(p)};return{amount:Ao(s,H.type)?H.amount:new L.default("0")}})},gr=b(ja),Lr=A.gt(0)?gr.div(A):new L.default(0);return{isFinished:!0,payout:ja,payoutMultiplier:Lr,outputs:{playerCards:c,playerHandValue:i,bankerCards:u,bankerHandValue:d,gameOutcome:s,result:r.values},randomValues:r}}validateGameInputs(t){if(t.bets.length===0)throw new Error("Must place at least a single bet.");if(!t.bets.every((a)=>a.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(t){let a=new N(t);return{suit:a.suit,rank:uo[a.rank]}}isNaturalWin(t,a){let r=[8,9];return r.includes(t)||r.includes(a)}mapRandomValueToCardValue(t){let a=t%13;if(a===0)return 1;if(a>=10)return 10;return a+1}shouldDrawThirdPlayerCard(t){return t<=5}shouldDrawThirdBankerCard(t,a){if(a===null)return t<=5;if(t<=2)return!0;if(t===3)return a!==8;if(t===4)return[2,3,4,5,6,7].includes(a);if(t===5)return[4,5,6,7].includes(a);if(t===6)return[6,7].includes(a);return!1}}var yt;((n)=>{n.WIN="WIN";n.LOSE="LOSE";n.PUSH="PUSH";n.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(yt||={});var ft;((r)=>{r.WON="WON";r.LOST="LOST"})(ft||={});var Ot;((i)=>{i.START="START";i.HIT="BLACKJACK_HIT";i.STAND="BLACKJACK_STAND";i.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";i.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";i.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";i.SPLIT="BLACKJACK_SPLIT"})(Ot||={});var St;((n)=>{n.EXACT_PAIR="EXACT_PAIR";n.COLORED_PAIR="COLORED_PAIR";n.MIXED_PAIR="MIXED_PAIR";n.LOSS="LOSS"})(St||={});var Ht;((c)=>{c.SUITED_TRIPS="SUITED_TRIPS";c.STRAIGHT_FLUSH="STRAIGHT_FLUSH";c.THREE_OF_A_KIND="THREE_OF_A_KIND";c.STRAIGHT="STRAIGHT";c.FLUSH="FLUSH";c.LOSS="LOSS"})(Ht||={});var Qa=2.5,Wa=2,ga=1,La=0,Jt=17,Dt=21,D=21,ht=63,po=1.5,F=0.5,Ct=1.5,j=1,w=1,Bo=13,xt=10,Yt=10,K={PLAYER_BLACKJACK:Qa,WIN:Wa,PUSH:ga,LOSE:La},$t={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},zt={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var R=O(require("big.js")),E=require("@betorigami/guard"),sr=require("@xstate/store");var Ka=require("@betorigami/guard");class f extends N{get numericRank(){if(Ya.includes(this.rank))return Yt;return mt.indexOf(this.rank)+1}static fromValue(t){return Ka.Guard.against(!Bt.includes(t),`Invalid card value: ${t}`),new f(t)}}class v{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,o)=>r+o.numericRank,0),t.some((r)=>r.rank==="Ace")&&this.hardHandValue+xt<=Dt)this.softHandValue=this.hardHandValue+xt}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>Dt}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===D}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class tt{cards;value;constructor(t){this.cards=t.map((a)=>f.fromValue(a)),this.value=new v(this.cards)}get isBusted(){return this.value.isBusted}get isBlackjack(){return this.value.isBlackjack}get highestHandValue(){return this.value.highestHandValue}get rawValues(){return this.cards.map((t)=>t.value)}toDto(){return{cards:this.cards.map((t)=>t.toDto()),value:this.highestHandValue}}}class at extends tt{otherCards;upCard;holeCard;constructor(t,a,r=[]){super([t,a,...r]);this.otherCards=r;this.upCard=f.fromValue(t),this.holeCard=f.fromValue(a)}static withInitialDeal(t){return new at(t.upCard,t.holeCard)}addDrawnCards(t){return new at(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new v([this.upCard]).highestHandValue}}}class V extends tt{static withInitialDeal(t){return new V(t)}addDrawnCards(t){return new V([...this.rawValues,...t])}}var rt=require("@betorigami/guard");class ot{source;index=0;constructor(t){this.source=t}static from(t,a){return rt.Guard.against(a<=0,`Count must be positive, got ${a}`),rt.Guard.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new ot(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return rt.Guard.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){rt.Guard.against(this.index+t>this.source.values.length,`RandomValuePool exhausted: requested ${t} but only ${this.source.values.length-this.index} remain`);let a=this.source.values.slice(this.index,this.index+t);return this.index+=t,a}}var qt=require("@betorigami/guard"),va=O(require("fast-deep-equal"));class Pt{gameId;edge;constructor(t,a){this.gameId=t;this.edge=a;this.validateEdge(a)}play(t,a,r=[]){let o=this.createGameStore(),n=this.generateRandomValues(t),e=n.toMultipleRandomValues();for(let u of r)o.send({...u.playerArgument,randomValuePool:n});let c=r[r.length-1];if(c)qt.Guard.against(!va.default(c.state,this.toExternalState(o.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");o.send({...a,randomValuePool:n});let i=o.getSnapshot().context;return{playerArgument:i.playerArgument,state:this.toExternalState(i.state),config:i.config,additionalBetAmount:i.additionalBetAmount,proof:{proofHash:e.proofHash,proofString:e.proofString}}}validateEdge(t){let a=this.supportedEdgeConfigurations.includes(t);qt.Guard.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}}var x=O(require("big.js"));var bt=require("@betorigami/guard");var tr=(t)=>{let a=t.pairBonus!==null?{amount:x.default(t.pairBonus.betAmount).mul(t.pairBonus.payoutMultiplier)}:null,r=t.threeCardBonus!==null?{amount:x.default(t.threeCardBonus.betAmount).mul(t.threeCardBonus.payoutMultiplier)}:null;return[a,r].filter((o)=>o!==null)},ar=(t)=>{let a=t.betAmounts.mainBetAmount,o=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(j):x.default(0),n=t.insuranceOutcome!==void 0?a.mul(F):x.default(0),e=a.plus(o).mul(K[t.outcome]),c=t.insuranceOutcome==="WON"?a.mul(Ct):x.default(0),i=tr(t.sideBetResults),u=[{amount:e},...t.insuranceOutcome!==void 0?[{amount:c}]:[],...i],d=b({legs:u}),s=a.plus(n).plus(o).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);bt.Guard.against(s.eq(0),"Total bet amount cannot be zero");let A=d.div(s);bt.Guard.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let m;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":m=o;break;case"BLACKJACK_BUY_INSURANCE":m=n;break;case"BLACKJACK_SPLIT":m=a.mul(w);break}return{payouts:u,totalBetAmount:s,multiplier:A,additionalBetAmount:m}},rr=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(j):x.default(0),o=t.splitHandDoubledDown?a.mul(j):x.default(0),n=t.insuranceOutcome!==void 0?a.mul(F):x.default(0),e=a.plus(r).mul(K[t.mainOutcome]),c=a.plus(o).mul(K[t.splitOutcome]),i=t.insuranceOutcome==="WON"?a.mul(Ct):x.default(0),u=tr(t.sideBetResults),d=[{amount:e},{amount:c},...t.insuranceOutcome!==void 0?[{amount:i}]:[],...u],s=b({legs:d}),A=a.plus(a).plus(n).plus(r).plus(o).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);bt.Guard.against(A.eq(0),"Total bet amount cannot be zero");let m=s.div(A),p;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":p=a.mul(j);break;case"BLACKJACK_SPLIT":p=a.mul(w);break}return{payouts:d,totalBetAmount:A,multiplier:m,additionalBetAmount:p}};var nr=require("@betorigami/guard"),Xt=(t)=>t.every((a)=>a===t[0]),or=(t)=>{let a=[...t].sort((r,o)=>r-o);return a.every((r,o)=>{let n=a[o-1];if(o===0)return!0;return nr.Guard.againstUndefined(n,"Previous value cannot be undefined"),r===n+1})},er={Ace:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9,Ten:10,Jack:11,Queen:12,King:13},mo={...er,Ace:14},Eo=(t)=>or(t.map((a)=>er[a]))||or(t.map((a)=>mo[a])),cr=(t,a)=>{let r=f.fromValue(t),o=f.fromValue(a);if(r.rank!==o.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(Mt[r.suit]===Mt[o.suit])return"COLORED_PAIR";return"MIXED_PAIR"},ir=(t,a)=>({betAmount:t,result:a,payoutMultiplier:$t[a]}),lr=(t,a,r)=>{let o=f.fromValue(t),n=f.fromValue(a),e=f.fromValue(r),c=[o.rank,n.rank,e.rank],i=Xt([o.suit,n.suit,e.suit]),u=Xt(c),d=Eo(c);if(Xt([t,a,r]))return"SUITED_TRIPS";if(i&&d)return"STRAIGHT_FLUSH";if(u)return"THREE_OF_A_KIND";if(d)return"STRAIGHT";if(i)return"FLUSH";return"LOSS"},dr=(t,a)=>({betAmount:t,result:a,payoutMultiplier:zt[a]});var yo={state:{isFinished:!1,phase:"uninitialised",multiplier:R.default(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},S=(t)=>f.fromValue(t).value;function fo(t){E.Guard.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function ur(t){E.Guard.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function Qt(t){E.Guard.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var Ar=(t,a)=>{let r=a;while(r.highestHandValue<Jt)r=r.addDrawnCards([S(t.takeOne())]);return r},gt=(t,a)=>{if(t.isBusted)return"LOSE";if(a.isBusted)return"WIN";let r=t.highestHandValue,o=a.highestHandValue;if(r>o)return"WIN";if(r<o)return"LOSE";return"PUSH"},h=(t)=>{let{payouts:a,multiplier:r,additionalBetAmount:o}=ar({outcome:t.outcome,insuranceOutcome:t.insuranceOutcome,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"finished",playerHand:t.playerHand,dealerHand:t.dealerHand,outcome:t.outcome,payout:{legs:a},multiplier:r,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:o}},Wt=(t)=>{let a=Ar(t.randomValuePool,t.dealerHand),r=gt(t.playerHand,a);return h({...t,dealerHand:a,outcome:r})},T=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:Ar(t.randomValuePool,t.dealerHand),o=gt(t.mainHand,r),n=gt(t.splitHand,r),{payouts:e,multiplier:c,additionalBetAmount:i}=rr({hasSplit:!0,mainOutcome:o,splitOutcome:n,insuranceOutcome:t.insuranceOutcome,mainHandDoubledDown:t.mainHandDoubledDown,splitHandDoubledDown:t.splitHandDoubledDown,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"split-finished",mainHand:t.mainHand,splitHand:t.splitHand,dealerHand:r,mainOutcome:o,splitOutcome:n,payout:{legs:e},multiplier:c,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:i}};class pr extends Pt{constructor(t){super("BLACKJACK",t)}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return ot.from(t.getRandomIntsWithReplacement({min:Ma,max:Fa,count:ht}),ht)}toExternalState(t){let a=t.phase;switch(a){case"awaiting-insurance":return{isFinished:!1,phase:"awaiting-insurance",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"in-progress":return{isFinished:!1,phase:"player-turn",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-main-hand":return{isFinished:!1,phase:"playing-main-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-split-hand":return{isFinished:!1,phase:"playing-split-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"finished":return{isFinished:!0,payout:t.payout,multiplier:t.multiplier,randomValues:t.randomValues,outcome:t.outcome,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"split-finished":return{isFinished:!0,payout:t.payout,multiplier:t.multiplier,randomValues:t.randomValues,mainOutcome:t.mainOutcome,splitOutcome:t.splitOutcome,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"uninitialised":throw new Error("Cannot convert uninitialised state to external state");default:E.Guard.againstNever(a,"Invalid state received")}}createGameStore(){return sr.createStore({context:yo,on:{START:(t,a)=>{let{state:r}=t;E.Guard.against(r.phase!=="uninitialised","START action requires a fresh game");let o=S(a.randomValuePool.takeOne()),n=S(a.randomValuePool.takeOne()),e=S(a.randomValuePool.takeOne()),c=S(a.randomValuePool.takeOne()),i=V.withInitialDeal([o,n]),u=at.withInitialDeal({upCard:e,holeCard:c}),d={mainBetAmount:R.default(a.mainBetAmount),pairBonusAmount:R.default(a.pairBonusAmount),threeCardBonusAmount:R.default(a.threeCardBonusAmount)},s={pairBonus:R.default(a.pairBonusAmount).gt(0)?ir(a.pairBonusAmount,cr(o,n)):null,threeCardBonus:R.default(a.threeCardBonusAmount).gt(0)?dr(a.threeCardBonusAmount,lr(o,n,e)):null},A={type:"START",mainBetAmount:a.mainBetAmount,pairBonusAmount:a.pairBonusAmount,threeCardBonusAmount:a.threeCardBonusAmount};if(u.upCard.rank==="Ace")return{state:{...r,isFinished:!1,phase:"awaiting-insurance",playerHand:i,dealerHand:u,betAmounts:d,sideBetResults:s},config:{},playerArgument:A};let m={playerHand:i,dealerHand:u,randomValuePool:a.randomValuePool,playerArgument:A,betAmounts:d,sideBetResults:s};if(i.isBlackjack&&u.isBlackjack)return h({...m,outcome:"PUSH"});if(i.isBlackjack)return h({...m,outcome:"PLAYER_BLACKJACK"});if(u.isBlackjack)return h({...m,outcome:"LOSE"});return{state:{...r,isFinished:!1,phase:"in-progress",playerHand:i,dealerHand:u,insuranceOutcome:void 0,betAmounts:d,sideBetResults:s},config:{},playerArgument:A}},BLACKJACK_BUY_INSURANCE:(t,a)=>{let{state:r}=t;ur(r);let{playerHand:o,dealerHand:n,betAmounts:e,sideBetResults:c}=r,i={...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:e,sideBetResults:c};if(o.isBlackjack&&n.isBlackjack)return h({...i,outcome:"PUSH",insuranceOutcome:"WON"});if(o.isBlackjack)return h({...i,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(n.isBlackjack)return h({...i,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...r,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:e.mainBetAmount.mul(F)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;ur(r);let{playerHand:o,dealerHand:n,betAmounts:e,sideBetResults:c}=r,i={playerHand:o,dealerHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:e,sideBetResults:c};if(o.isBlackjack&&n.isBlackjack)return h({...i,outcome:"PUSH"});if(o.isBlackjack)return h({...i,outcome:"PLAYER_BLACKJACK"});if(n.isBlackjack)return h({...i,outcome:"LOSE"});return{state:{...r,phase:"in-progress",insuranceOutcome:void 0},config:{},playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"}}},BLACKJACK_HIT:(t,a)=>{let{state:r}=t;switch(Qt(r),r.phase){case"playing-main-hand":{let o=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(o.isBusted||o.highestHandValue===D){if(r.splitHand.highestHandValue===D)return T({...r,mainHand:o,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"playing-split-hand",mainHand:o,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...r,mainHand:o},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let o=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(o.isBusted||o.highestHandValue===D)return T({...r,splitHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,splitHand:o},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let o=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(o.isBusted)return h({...r,playerHand:o,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(o.highestHandValue===D)return Wt({...r,playerHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"in-progress",playerHand:o},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:E.Guard.againstNever(r,"Invalid phase for HIT action")}},BLACKJACK_STAND:(t,a)=>{let{state:r}=t;switch(Qt(r),r.phase){case"playing-main-hand":{if(r.splitHand.highestHandValue===D)return T({...r,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});return{state:{...r,phase:"playing-split-hand",splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_STAND"}}}case"playing-split-hand":return T({...r,splitHandDoubledDown:r.splitHandDoubledDown,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});case"in-progress":return Wt({...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});default:E.Guard.againstNever(r,"Invalid phase for STAND action")}},BLACKJACK_DOUBLE_DOWN:(t,a)=>{let{state:r}=t;switch(Qt(r),r.phase){case"playing-main-hand":{E.Guard.against(r.mainHand.cards.length!==2,"Double down is only allowed as the first action");let o=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]),{betAmounts:n}=r;if(r.splitHand.highestHandValue===D)return T({...r,mainHand:o,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...r,phase:"playing-split-hand",mainHand:o,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:n.mainBetAmount.mul(j)}}case"playing-split-hand":{E.Guard.against(r.splitHand.cards.length!==2,"Double down is only allowed as the first action");let o=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);return T({...r,splitHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{E.Guard.against(r.playerHand.cards.length!==2,"Double down is only allowed as the first action");let o=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(o.isBusted)return h({...r,playerHand:o,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return Wt({...r,playerHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:E.Guard.againstNever(r,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(t,a)=>{let{state:r}=t;fo(r);let{playerHand:o,betAmounts:n,sideBetResults:e}=r;E.Guard.against(o.cards.length!==2,"Split is only allowed with exactly 2 cards");let c=o.cards[0],i=o.cards[1];E.Guard.againstUndefined(c,"First card is missing"),E.Guard.againstUndefined(i,"Second card is missing"),E.Guard.against(c.rank!==i.rank,"Split requires two cards of the same rank");let u=S(a.randomValuePool.takeOne()),d=S(a.randomValuePool.takeOne()),s=V.withInitialDeal([c.value,u]),A=V.withInitialDeal([i.value,d]);if(c.rank==="Ace")return T({...r,mainHand:s,splitHand:A,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let p=s.highestHandValue===D,ba=A.highestHandValue===D;if(p&&ba)return T({mainHand:s,splitHand:A,dealerHand:r.dealerHand,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:r.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:n,sideBetResults:e});if(p)return{state:{...r,phase:"playing-split-hand",mainHand:s,splitHand:A,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(w)};return{state:{...r,phase:"playing-main-hand",multiplier:R.default(0),mainHand:s,splitHand:A,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(w)}}}})}getValidNextActionTypes(t){if(t.isFinished)return[];switch(t.phase){case"awaiting-insurance":return["BLACKJACK_BUY_INSURANCE","BLACKJACK_REJECT_INSURANCE"];case"playing-main-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.mainHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"playing-split-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.splitHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"player-turn":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.playerHand.cards.length===2){a.push("BLACKJACK_DOUBLE_DOWN");let r=t.playerHand.cards[0],o=t.playerHand.cards[1];if(E.Guard.againstUndefined(r,"First player card is missing"),E.Guard.againstUndefined(o,"Second player card is missing"),r.rank===o.rank)a.push("BLACKJACK_SPLIT")}return a}default:E.Guard.againstNever(t,"Invalid phase for getting valid actions")}}}var Y=O(require("big.js")),ta=require("@betorigami/guard");var Lt=0,Kt=51,J=52,vt=52;var Oo=()=>({minPicks:5,maxPicks:36}),Br=(t)=>t.length===new Set(t).size,mr=(t)=>{let a=Y.default(1),r=Y.default(J);for(let o=0;o<t;o+=1)a=a.mul(Y.default(J-o).div(r));return a};class Er extends B{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){ta.Guard.against(a.pickCount<1||a.pickCount>J,`pickCount must be between 1 and ${J}`),ta.Guard.againstNonInteger(a.pickCount,"pickCount must be an integer");let o=t.getRandomIntsWithReplacement({min:Lt,max:Kt,count:vt}),n=o.values.slice(0,a.pickCount),e=Br(n),c=mr(a.pickCount),i=e?C.withMultiplier(Y.default(1).div(c),r):Y.default(0);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:o.values,cards:n.map((u)=>new N(u).toDto())},randomValues:o}}}var aa=0,jt=4294967295,ra;((n)=>{n.EASY="EASY";n.MEDIUM="MEDIUM";n.HARD="HARD";n.EXPERT="EXPERT"})(ra||={});var So=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Ho={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:0.5,ringTwo:0.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:0.5},segments:So},Do=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],ho={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:0.4,ringTwo:0.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:0.4},segments:Do},Co=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],xo={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:0.2,ringTwo:0.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:0.2},segments:Co},Po=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],bo={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:0.1,ringTwo:0.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:0.1},segments:Po},jo=(t)=>{let a=Tt[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((o,n)=>n>o?n:o)},Tt={EASY:Ho,MEDIUM:ho,HARD:xo,EXPERT:bo};var Rt=require("@betorigami/guard"),yr=O(require("big.js"));class fr extends B{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:aa,max:jt,count:2}),o=r.values[0],n=r.values[1];Rt.Guard.againstUndefined(o,"Random number generator returned no value for clockWiseRotation"),Rt.Guard.againstUndefined(n,"Random number generator returned no value for distanceFromCentre");let e=a.difficultyLevel,c=yr.default(To(e,o,n));return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:r.values},randomValues:r}}}var To=(t,a,r)=>{let o=Tt[t],{distanceBoundaries:n,multipliers:e}=o;if(r<n.bullseye)return e.bullseye;if(r<n.ringOne)return e.ringOne;if(r<n.ringTwo)return e.ringTwo;if(r<n.ringThree)return Ro(o,a);return e.ringFour},Ro=(t,a)=>{let r=t.segments.length,o=Math.floor(a/(jt+1)*r),n=t.segments[o];return Rt.Guard.againstUndefined(n,`Segment index ${o} out of bounds`),t.multipliers.ringThree[n]};var Or=O(require("big.js"));class P{multipliers;constructor(t){this.multipliers=t}getMultipliers(t){let a=this.multipliers.get(t);if(a===void 0)throw new Error(`Multipliers for ${t} not found`);return a}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([t,a])=>({edge:t,multipliers:a}))}}var Sr;((c)=>{c.PAIR="PAIR";c.TWO_PAIR="TWO_PAIR";c.THREE_OF_A_KIND="THREE_OF_A_KIND";c.FULL_HOUSE="FULL_HOUSE";c.FOUR_OF_A_KIND="FOUR_OF_A_KIND";c.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(Sr||={});var _o={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},No={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},wo={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},Vo={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},Uo={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},Hr=new P(new Map([[1,_o],[2,No],[3,wo],[4,Vo],[8,Uo]])),Io={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Dr extends B{constructor(){super("DIAMONDS")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let o=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),n=Hr.getMultipliers(a),e=o.values,c=Or.default(this.calculatePayoutMultiplier(n,e));return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:o.values},randomValues:o}}calculatePayoutMultiplier(t,a){let r=new Map;for(let e of a){let c=r.get(e)||0;r.set(e,c+1)}let o=[...r.values()].filter((e)=>e>1),n=this.classifyResult(o);return n===null?0:t[n]}classifyResult(t){if(t.length>2)throw new Error(`Unexpected number of repeats ${t.length}`);let[a,r]=t;if(a===void 0)return null;if(r===void 0){let o=Io[a];if(o===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return o}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}var oa=O(require("big.js"));var hr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(hr||={});var na=0,_t=1e4,Cr=_t-na+1,xr=(t)=>{let a=t.direction==="ABOVE"?_t-t.selectedValue:t.selectedValue;return new oa.default(a).div(Cr).mul(100)},Pr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class br extends B{constructor(){super("DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let o=t.getRandomInt({min:na,max:_t}),n=xr(r),c=Pr(r,o.value)?C.withWinChance(a,n):new oa.default(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:o.values},randomValues:o}}}var Vr=O(require("big.js"));var nt=require("@betorigami/guard");var ea;((n)=>{n.CLASSIC="CLASSIC";n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(ea||={});var jr=[1,2,3,4,5,6,7,8,9,10],ca=(t)=>{return jr.includes(t)};var Tr={[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]}},Rr={[1]:{CLASSIC:[0,3.92],LOW_RISK:[0.7,1.82],MEDIUM_RISK:[0.4,2.72],HIGH_RISK:[0,3.92]},[2]:{CLASSIC:[0,1.9,4.32],LOW_RISK:[0,2,3.65],MEDIUM_RISK:[0,1.8,5],HIGH_RISK:[0,0,17]},[3]:{CLASSIC:[0,1,3,10.7],LOW_RISK:[0,1.1,1.3,26.2],MEDIUM_RISK:[0,0,2.7,50.3],HIGH_RISK:[0,0,0,80.7]},[4]:{CLASSIC:[0,0.8,1.8,4.75,22.5],LOW_RISK:[0,0,2.2,7.65,90],MEDIUM_RISK:[0,0,1.7,9.8,100],HIGH_RISK:[0,0,0,9.75,259]},[5]:{CLASSIC:[0,0.2,1.4,4.25,16.4,36],LOW_RISK:[0,0,1.5,4.1,12.9,300],MEDIUM_RISK:[0,0,1.4,3.9,13.9,390],HIGH_RISK:[0,0,0,4.5,47,450]},[6]:{CLASSIC:[0,0,1,3.6,7,17,40],LOW_RISK:[0,0,1.1,2,5.8,100,700],MEDIUM_RISK:[0,0,0,3,8.6,180,710],HIGH_RISK:[0,0,0,0,10.6,350,710]},[7]:{CLASSIC:[0,0,0.5,3,4.1,13.7,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,13.5,225,700],MEDIUM_RISK:[0,0,0,2,6.9,29.2,400,800],HIGH_RISK:[0,0,0,0,6.9,89.1,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,12.2,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,4.8,38,100,800],MEDIUM_RISK:[0,0,0,2,4,10.4,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.8,270,600,900]},[9]:{CLASSIC:[0,0,0,1.5,3,8.1,15,45,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.1,7.4,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1000],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.5,7.6,16,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.6,3.7,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1000]}},_r={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.7,1.78],MEDIUM_RISK:[0.4,2.68],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,2,3.48],MEDIUM_RISK:[0,1.8,4.8],HIGH_RISK:[0,0,16.8]},[3]:{CLASSIC:[0,1,3,9.9],LOW_RISK:[0,1.1,1.2,26.5],MEDIUM_RISK:[0,0,2.65,50],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.7,5,23],LOW_RISK:[0,0,2.1,7.95,90],MEDIUM_RISK:[0,0,1.7,9.55,100],HIGH_RISK:[0,0,0,9.5,259]},[5]:{CLASSIC:[0,0.2,1.4,4.1,16.6,36],LOW_RISK:[0,0,1.5,4,12.7,300],MEDIUM_RISK:[0,0,1.4,3.8,13.7,390],HIGH_RISK:[0,0,0,4.4,46.9,450]},[6]:{CLASSIC:[0,0,1,3.6,6.6,16.5,40],LOW_RISK:[0,0,1.1,1.9,5.9,100,700],MEDIUM_RISK:[0,0,0,2.9,8.7,180,710],HIGH_RISK:[0,0,0,0,10.8,342,710]},[7]:{CLASSIC:[0,0,0.5,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.1,1.6,3.1,14.8,225,700],MEDIUM_RISK:[0,0,0,2,6.7,29,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.8,12.7,21,54,70],LOW_RISK:[0,0,1.1,1.5,1.8,5.2,38,100,800],MEDIUM_RISK:[0,0,0,2,3.8,10.8,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.5,265,600,900]},[9]:{CLASSIC:[0,0,0,1.5,2.9,8.2,15,43,60,85],LOW_RISK:[0,0,1.1,1.3,1.6,2.1,7.7,49,250,1000],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.2,8,16.7,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.5,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1000]}},Nr={[1]:{CLASSIC:[0,3.84],LOW_RISK:[0.69,1.77],MEDIUM_RISK:[0.38,2.7],HIGH_RISK:[0,3.84]},[2]:{CLASSIC:[0,1.83,4.44],LOW_RISK:[0,1.98,3.44],MEDIUM_RISK:[0,1.78,4.77],HIGH_RISK:[0,0,16.64]},[3]:{CLASSIC:[0,0.98,3,9.8],LOW_RISK:[0,1.09,1.19,26.15],MEDIUM_RISK:[0,0,2.6,49.8],HIGH_RISK:[0,0,0,79]},[4]:{CLASSIC:[0,0.79,1.68,5,22.7],LOW_RISK:[0,0,2.1,7.8,88.3],MEDIUM_RISK:[0,0,1.66,9.5,100],HIGH_RISK:[0,0,0,9.25,259]},[5]:{CLASSIC:[0,0.19,1.39,4.1,16.3,35.5],LOW_RISK:[0,0,1.47,4,12.5,300],MEDIUM_RISK:[0,0,1.37,3.8,13.5,390],HIGH_RISK:[0,0,0,4.3,46.6,450]},[6]:{CLASSIC:[0,0,0.98,3.6,6.5,15.9,39.9],LOW_RISK:[0,0,1.08,1.89,5.8,100,700],MEDIUM_RISK:[0,0,0,2.9,8.35,180,710],HIGH_RISK:[0,0,0,0,10.4,342,710]},[7]:{CLASSIC:[0,0,0.47,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.08,1.59,3.1,14.6,225,700],MEDIUM_RISK:[0,0,0,1.98,6.6,28.7,400,800],HIGH_RISK:[0,0,0,0,6.7,87.3,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.7,12.5,21,54,70],LOW_RISK:[0,0,1.09,1.49,1.77,5.1,37.5,100,800],MEDIUM_RISK:[0,0,0,1.96,3.8,10.7,65.8,400,900],HIGH_RISK:[0,0,0,0,4.9,18.8,265,600,900]},[9]:{CLASSIC:[0,0,0,1.47,2.9,8.1,14.9,43,60,85],LOW_RISK:[0,0,1.09,1.28,1.59,2.1,7.6,48.4,250,1000],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1000],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.2,7.8,16.5,49.2,80,100],LOW_RISK:[0,0,1.08,1.19,1.3,1.47,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1000]}},wr={[1]:{CLASSIC:[0,3.68],LOW_RISK:[0.7,1.58],MEDIUM_RISK:[0.4,2.48],HIGH_RISK:[0,3.68]},[2]:{CLASSIC:[0,1.72,4.48],LOW_RISK:[0,1.9,3.28],MEDIUM_RISK:[0,1.7,4.62],HIGH_RISK:[0,0,15.95]},[3]:{CLASSIC:[0,0.9,2.95,9.9],LOW_RISK:[0,1,1.2,26],MEDIUM_RISK:[0,0,2.29,50],HIGH_RISK:[0,0,0,75.7]},[4]:{CLASSIC:[0,0.8,1.6,4.4,21],LOW_RISK:[0,0,2,7.5,86],MEDIUM_RISK:[0,0,1.5,9.5,98],HIGH_RISK:[0,0,0,9,246]},[5]:{CLASSIC:[0,0.2,1.2,4.2,16.3,37],LOW_RISK:[0,0,1.4,3.8,12,300],MEDIUM_RISK:[0,0,1.3,3.5,14,385],HIGH_RISK:[0,0,0,4,45,450]},[6]:{CLASSIC:[0,0,1,3.3,6.2,15,40],LOW_RISK:[0,0,1.1,1.7,4.9,99,700],MEDIUM_RISK:[0,0,0,2.6,8.5,177,705],HIGH_RISK:[0,0,0,0,10,327,710]},[7]:{CLASSIC:[0,0,0.4,2.8,4.2,14.5,30,60],LOW_RISK:[0,0,1.1,1.4,3,14,210,700],MEDIUM_RISK:[0,0,0,1.8,6.4,29,400,800],HIGH_RISK:[0,0,0,0,6.1,85,400,800]},[8]:{CLASSIC:[0,0,0,2,3.7,13,20,50,70],LOW_RISK:[0,0,1.1,1.4,1.6,4.6,35,90,800],MEDIUM_RISK:[0,0,0,1.9,3.5,10.5,65,400,900],HIGH_RISK:[0,0,0,0,4.5,18,265,600,900]},[9]:{CLASSIC:[0,0,0,1.4,2.6,9,11.5,40,60,85],LOW_RISK:[0,0,1,1.3,1.5,2,7,45,250,1000],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.3,2,4.4,8,16.7,50,80,100],LOW_RISK:[0,0,1,1.2,1.25,1.4,2,10,50,250,1000],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1000],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1000]}},ia=new P(new Map([[1,Tr],[2,Rr],[3,_r],[4,Nr],[8,wr]]));class Ur extends B{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){nt.Guard.againstEmptyArray(r.selectedNumbers,()=>l.createValidationError("No numbers selected")),nt.Guard.against(r.selectedNumbers.length>10,()=>l.createValidationError("Maximum of 10 numbers can be selected"));for(let A of r.selectedNumbers)nt.Guard.againstNonInteger(A,()=>l.createValidationError("Only integers can be selected")),nt.Guard.against(A<0||A>39,()=>l.createValidationError("Invalid number selected"));let o=t.getUniqueRandomInts({min:0,max:39,count:10}),n=r.selectedNumbers.filter((A)=>o.values.includes(A)),e=r.selectedNumbers.length;if(!ca(e))throw new Error(`Invalid tile count: ${e}`);let d=ia.getMultipliers(a)[e][r.riskLevel][n.length];if(d===void 0)throw new Error(`No multiplier found for matching tile count ${n.length}`);let s=new Vr.default(d);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:o.values},randomValues:o}}}var U=O(require("big.js"));var la=(t,a)=>{return t.gt(a)?t:a};var da=(t,a)=>{return t.lt(a)?t:a};class Ir extends B{constructor(){super("LIMBO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let o=t.getRandomInt({min:1,max:4294967295}),n=o.max,e=new U.default(16777216),c=new U.default(1),i=new U.default(1e6),u=o.value,d=new U.default(u-1).div(n),s=(100-a)/100,A=e.div(d.mul(e).plus(1)).mul(s),m=la(c,da(A,i)),p=m.gte(r.targetMultiplier)?new U.default(r.targetMultiplier):new U.default(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(p)}]},payoutMultiplier:p,outputs:{randomMultiplier:m,result:o.values},randomValues:o}}}var et=O(require("big.js"));var Nt=(t,a)=>{if(a<0||t<0||a>t)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(a>t-a)a=t-a;let r=1;for(let o=1;o<=a;o++)r=r*(t-o+1)/o;return r};class Zr extends B{constructor(){super("MINES")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){if(r.minesCount<=0||r.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(r.selectedTiles.length>25-r.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let c=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),i=c.values.some((p)=>r.selectedTiles.includes(p)),u=r.hasCashedOut||i,d=(100-a)/100,s=new et.default(Nt(25-r.minesCount,r.selectedTiles.length)).div(new et.default(Nt(25,r.selectedTiles.length))),m=r.hasCashedOut&&!i?new et.default(d).div(s):new et.default(0);return{isFinished:u,payout:{legs:[{amount:r.betAmount.mul(m)}]},payoutMultiplier:m,outputs:{result:c.values},randomValues:c}}}var kr=require("big.js");var ua;((o)=>{o.LOW_RISK="LOW_RISK";o.MEDIUM_RISK="MEDIUM_RISK";o.HIGH_RISK="HIGH_RISK"})(ua||={});var Zo=[8,9,10,11,12,13,14,15,16],ko={LOW_RISK:{8:[6,2.1,1.1,1,0.5,1,1.1,2.1,6],9:[6,2,1.6,1,0.7,0.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],16:[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:{8:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],9:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],10:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],11:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],12:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,0.3,0.2,0.3,1.5,4,29],9:[43,7,2,0.6,0.2,0.2,0.6,2,7,43],10:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76],11:[120,13.9,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,0.2,0.2,0.2,0.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,82.8,620],16:[1000,129.9,26.1,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26.1,129.9,1000]}},Go={LOW_RISK:{8:[6,1.9,1.1,1,0.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,0.7,0.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,0.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,0.7,0.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,0.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,0.9,0.7,0.7,0.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,0.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,0.7,0.7,1,1.1,1.4,2,2.8,7.6,15],16:[16,9,1.7,1.2,1.3,1.2,1.1,1,0.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,0.6,0.4,0.6,1.4,3.2,13],9:[18,3.7,1.7,0.9,0.5,0.5,0.9,1.7,3.7,18],10:[22,5,1.9,1.4,0.6,0.4,0.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,0.7,0.5,0.5,0.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,0.6,0.3,0.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,0.5,0.2,0.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,0.5,0.3,0.3,0.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,0.5,0.3,0.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,0.3,0.2,0.3,1.5,3.8,29],9:[43,7.1,1.9,0.6,0.2,0.2,0.6,1.9,7.1,43],10:[76,9.9,2.9,0.9,0.3,0.2,0.3,0.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,0.4,0.2,0.2,0.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,0.7,0.2,0.2,0.2,0.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,0.2,0.2,0.2,0.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,0.3,0.2,0.2,0.2,0.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,0.5,0.2,0.2,0.2,0.2,0.5,3,7.7,26.8,82.3,620],16:[1000,129.8,25.2,8.6,4,2,0.2,0.2,0.2,0.2,0.2,2,4,8.6,25.2,129.8,1000]}},Mo={LOW_RISK:{8:[6,2.2,1.1,1,0.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,0.7,0.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,0.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,0.7,0.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,0.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,0.9,0.7,0.7,0.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,0.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,0.7,0.7,1,1.1,1.3,2,2.5,7.9,15],16:[16,8.9,1.9,1.4,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,0.7,0.3,0.7,1.2,3.5,13],9:[18,3.8,1.6,0.9,0.5,0.5,0.9,1.6,3.8,18],10:[22,5.2,2,1.3,0.6,0.4,0.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,0.7,0.5,0.5,0.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,0.6,0.3,0.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,0.5,0.2,0.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,0.5,0.3,0.3,0.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,0.5,0.3,0.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,0.3,0.2,0.3,1.4,4,29],9:[43,7.3,2,0.5,0.2,0.2,0.5,2,7.3,43],10:[76,9.8,2.8,0.9,0.3,0.2,0.3,0.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,0.4,0.2,0.2,0.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,0.2,0.2,0.2,0.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,0.5,0.2,0.2,0.2,0.2,0.5,2.9,7.7,26.6,81.9,620],16:[1000,130,24.9,8.4,3.9,2,0.2,0.2,0.2,0.2,0.2,2,3.9,8.4,24.9,130,1000]}},Fo={LOW_RISK:{8:[6,2,1.1,1,0.4,1,1.1,2,6],9:[6,1.9,1.4,1,0.7,0.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,0.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,0.7,0.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,0.9,0.6,0.6,0.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,0.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,0.6,0.6,1,1.2,1.4,2,2.9,8,15],16:[16,9.1,2.2,1.4,1.2,1.2,1.1,1,0.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,0.7,0.4,0.7,1.2,2.9,13],9:[18,3.5,1.6,0.9,0.5,0.5,0.9,1.6,3.5,18],10:[22,4.7,2,1.3,0.6,0.4,0.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,0.7,0.5,0.5,0.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,0.6,0.3,0.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,0.7,0.4,0.4,0.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,0.5,0.2,0.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,0.5,0.3,0.3,0.5,1.3,2.7,4.9,10.7,17.7,88],16:[110,39.7,9.6,4.8,2.8,1.4,1,0.5,0.3,0.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,0.3,0.2,0.3,1.4,3.9,29],9:[43,6.9,1.8,0.6,0.2,0.2,0.6,1.8,6.9,43],10:[76,9.8,2.7,0.9,0.3,0.2,0.3,0.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,0.4,0.2,0.2,0.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,0.2,0.2,0.2,0.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,0.5,0.2,0.2,0.2,0.2,0.5,2.8,7.8,26.1,80.6,620],16:[1000,129.7,24.7,8.2,3.8,2,0.2,0.2,0.2,0.2,0.2,2,3.8,8.2,24.7,129.7,1000]}},Jo={LOW_RISK:{8:[5,1.8,1,1,0.4,1,1,1.8,5],9:[5,1.7,1.2,1,0.7,0.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,0.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,0.7,0.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,0.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,0.9,0.6,0.6,0.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,0.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,0.6,0.6,1,1,1.4,1.9,2.9,7.3,15],16:[16,8.7,2,1.5,1.3,1,1.1,1,0.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,0.7,0.4,0.7,1.1,2.6,13],9:[17,3.3,1.4,0.9,0.5,0.5,0.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,0.6,0.4,0.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,0.7,0.5,0.5,0.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,0.6,0.2,0.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,0.7,0.4,0.4,0.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,0.5,0.2,0.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,0.5,0.3,0.3,0.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,0.5,0.3,0.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,0.3,0.2,0.3,1.4,3.3,28],9:[42,6.7,1.6,0.6,0.2,0.2,0.6,1.6,6.7,42],10:[74,9.6,2.6,0.9,0.3,0.1,0.3,0.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,0.4,0.2,0.2,0.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,0.7,0.2,0.2,0.2,0.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,0.2,0.2,0.2,0.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,0.3,0.2,0.2,0.2,0.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,0.5,0.2,0.2,0.2,0.2,0.5,2.6,7.4,24.9,76.9,600],16:[1000,122,24.5,8,3.7,1.8,0.2,0.2,0.2,0.2,0.2,1.8,3.7,8,24.5,122,1000]}},sa=new P(new Map([[1,ko],[2,Go],[3,Mo],[4,Fo],[8,Jo]]));class Gr extends B{constructor(){super("PLINKO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){if(a.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(a.numberOfRows<8||a.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let o=a.numberOfRows,c=sa.getMultipliers(r)[a.riskLevel][o],i=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),d=i.values.reduce((m,p)=>m+p,0),s=c[d];if(s===void 0)throw new Error(`No payout found for end position ${d}`);let A=kr.Big(s);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(A)}]},payoutMultiplier:A,outputs:{result:i.values},randomValues:i}}}var lt=require("big.js");var wt=[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],Aa=[37,...wt],pa=[[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]],Ba=[[0,1],[0,37],[3,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]],ma=[[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]],Ea=[[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]],ya=[[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]],fa=[[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]],Oa=[0,1,2,3,37],Sa=[[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]],Ha=[[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]],I;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(I||={});var Z;((r)=>{r.RED="RED";r.BLACK="BLACK"})(Z||={});var k;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(k||={});var G;((o)=>{o.TOP="TOP";o.MIDDLE="MIDDLE";o.BOTTOM="BOTTOM"})(G||={});var M;((o)=>{o.FIRST="FIRST";o.SECOND="SECOND";o.THIRD="THIRD"})(M||={});var Vt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Vt||={});var $=2.7,z=5.3;var Ut=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&ct(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Yo(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&$o(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&zo(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&qo(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},ct=(t)=>{return wt.includes(t)},Yo=(t)=>{if(t.length!==2)return!1;if(!t.every(ct))return!1;return pa.some(([a,r])=>a===t[0]&&r===t[1])},$o=(t)=>{if(t.length!==3)return!1;if(!t.every(ct))return!1;return ma.some(([a,r,o])=>a===t[0]&&r===t[1]&&o===t[2])},zo=(t)=>{if(t.length!==4)return!1;if(!t.every(ct))return!1;return ya.some(([a,r,o,n])=>a===t[0]&&r===t[1]&&o===t[2]&&n===t[3])},qo=(t)=>{if(t.length!==6)return!1;if(!t.every(ct))return!1;return Sa.some(([a,r,o,n,e,c])=>a===t[0]&&r===t[1]&&o===t[2]&&n===t[3]&&e===t[4]&&c===t[5])};var It=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.basketBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&it(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Xo(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Qo(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Wo(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.basketBets.every((a)=>a.amount.gte(0)))throw l.createValidationError("Invalid basket bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&go(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},it=(t)=>{return Aa.includes(t)};function Xo(t){if(t.length!==2)return!1;if(!t.every(it))return!1;return Ba.some(([a,r])=>a===t[0]&&r===t[1])}var Qo=(t)=>{if(t.length!==3)return!1;if(!t.every(it))return!1;return Ea.some(([a,r,o])=>a===t[0]&&r===t[1]&&o===t[2])},Wo=(t)=>{if(t.length!==4)return!1;if(!t.every(it))return!1;return fa.some(([a,r,o,n])=>a===t[0]&&r===t[1]&&o===t[2]&&n===t[3])},go=(t)=>{if(t.length!==6)return!1;if(!t.every(it))return!1;return Ha.some(([a,r,o,n,e,c])=>a===t[0]&&r===t[1]&&o===t[2]&&n===t[3]&&e===t[4]&&c===t[5])};var Lo=(t,a)=>{let r=a===$&&t.type==="EUROPEAN",o=a===z&&t.type==="AMERICAN";if(!r&&!o)throw l.createValidationError(`Attempted to play ${t.type} roulette on edge ${a}`)},Da=(t,a)=>{if(Lo(t,a),t.type==="EUROPEAN")Ut(t.inputs);else It(t.inputs)};var Mr={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Fr=[3,6,9,12,15,18,21,24,27,30,33,36],Jr=[2,5,8,11,14,17,20,23,26,29,32,35],Yr=[1,4,7,10,13,16,19,22,25,28,31,34],$r=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],zr=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];class ha extends B{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),o=r.value,n=this.determineBetOutcomes(a,o),{payoutMultiplier:e,payout:c}=this.getPayoutDetails(a,o);return{outputs:{betOutcomes:n,result:r.values},payout:c,payoutMultiplier:e,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.getBetTotals(t),o=this.calculateTotalBetAmount(r),n={legs:this.calculatePayoutLegs(t,a)},e=b(n);return{payoutMultiplier:o.gt(0)?e.div(o):new lt.Big(0),payout:n}}determineBetOutcomes(t,a){let r={},o={};for(let n of Object.keys(t)){let e=t[n],c=this.betPredicates[n],{winning:i,losing:u}=this.partitionBets(e,c,a);r[n]=i,o[n]=u}return{winningBets:r,losingBets:o}}calculateTotalAmount(t){return t.reduce((a,r)=>a.plus(r.amount),new lt.Big(0))}isWinningStraightBet(t,a){return t.value===a}isWinningSplitBet(t,a){return t.values.some((r)=>r===a)}isWinningStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningCornerBet(t,a){return t.values.some((r)=>r===a)}isWinningDoubleStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningColorBet(t,a){let r=t;return $r.includes(a)&&r.color==="RED"||zr.includes(a)&&r.color==="BLACK"}isWinningHalfBet(t,a){let r=t;if(a>0&&a<=18&&r.half==="LOW")return!0;if(a>18&&a<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(t,a){let r=t;return Fr.includes(a)&&r.column==="TOP"||Jr.includes(a)&&r.column==="MIDDLE"||Yr.includes(a)&&r.column==="BOTTOM"}isWinningDozenBet(t,a){let r=t;if(a>0&&a<=12&&r.dozen==="FIRST")return!0;if(a>12&&a<=24&&r.dozen==="SECOND")return!0;if(a>24&&a<=36&&r.dozen==="THIRD")return!0;return!1}isWinningParityBet(t,a){let r=t;if(a===0||a===37)return!1;let o=a%2===0?"EVEN":"ODD";return r.parity===o}getBetTotals(t){let a={};for(let r of Object.keys(t))a[r]=this.calculateTotalAmount(t[r]);return a}calculateTotalBetAmount(t){return Object.values(t).reduce((a,r)=>a.plus(r),new lt.Big(0))}partitionBets(t,a,r){return{winning:t.filter((o)=>a(o,r)),losing:t.filter((o)=>!a(o,r))}}calculatePayoutLegs(t,a){return Object.keys(t).flatMap((r)=>{let o=Mr[r],n=this.betPredicates[r];return t[r].map((e)=>{if(!n(e,a))return{amount:new lt.Big("0")};return{amount:e.amount.mul(o||0)}})})}}class Ca extends ha{maxNumber=36;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[$]}validateInputs(t){Ut(t)}}class xa extends ha{maxNumber=37;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,basketBets:this.isWinningBasketBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[z]}validateInputs(t){It(t)}isWinningBasketBet(t,a){return Oa.some((r)=>r===a)}}class Pa extends B{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Ca,this.americanGame=new xa}get supportedEdgeConfigurations(){return[$,z]}getBetAmount(t){switch(t.type){case"AMERICAN":return this.americanGame.getBetAmount(t.inputs);case"EUROPEAN":return this.europeanGame.getBetAmount(t.inputs);default:throw new Error("Unhandled roulette type")}}determineGameResult(t){let{gameInputs:a,...r}=t;if(Da(a,t.edge),a.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:c,result:e.outputs.result}}}let o=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:n}=o.outputs;return{...o,outputs:{type:"american",betOutcomes:n,result:o.outputs.result}}}}var Ko=(t)=>{return new Pa().getBetAmount(t)};var Qr=require("big.js");var q;((o)=>{o.LOW_RISK="LOW_RISK";o.MEDIUM_RISK="MEDIUM_RISK";o.HIGH_RISK="HIGH_RISK"})(q||={});var X;((e)=>{e[e.TEN=10]="TEN";e[e.TWENTY=20]="TWENTY";e[e.THIRTY=30]="THIRTY";e[e.FORTY=40]="FORTY";e[e.FIFTY=50]="FIFTY"})(X||={});var vo={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}}},tn={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}}},an={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}}},rn={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}}},on={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,vo],[2,tn],[3,an],[4,rn],[8,on]]));var Xr={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 Wr extends B{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(X).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(q).includes(a.riskLevel))throw new Error("Invalid risk level");let n=qr.getMultipliers(r)[a.riskLevel];if(n===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let e=n[a.segments];if(e===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let c=Xr[a.riskLevel];if(c===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let i=c[a.segments];if(i===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let u=t.getRandomInt({min:0,max:i.length-1}),d=i[u.value];if(d===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${u.value}`);let s=e[d];if(s===void 0)throw new Error(`No payout found for picked segment ${d}`);let A=new Qr.Big(s);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(A)}]},payoutMultiplier:A,outputs:{result:u.values},randomValues:u}}}
1
+ var Lr=Object.create;var{getPrototypeOf:Kr,defineProperty:Q,getOwnPropertyNames:Ta,getOwnPropertyDescriptor:vr}=Object,Ra=Object.prototype.hasOwnProperty;var O=(t,a,r)=>{r=t!=null?Lr(Kr(t)):{};let n=a||!t||!t.__esModule?Q(r,"default",{value:t,enumerable:!0}):r;for(let e of Ta(t))if(!Ra.call(n,e))Q(n,e,{get:()=>t[e],enumerable:!0});return n},ja=new WeakMap,tn=(t)=>{var a=ja.get(t),r;if(a)return a;if(a=Q({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")Ta(t).map((n)=>!Ra.call(a,n)&&Q(a,n,{get:()=>t[n],enumerable:!(r=vr(t,n))||r.enumerable}));return ja.set(t,a),a};var an=(t,a)=>{for(var r in a)Q(t,r,{get:a[r],enumerable:!0,configurable:!0,set:(n)=>a[r]=()=>n})};var ee={};an(ee,{validateRouletteGameInputs:()=>ha,validateAdvancedDiceInputs:()=>on,sumPayout:()=>T,rtp99Multipliers:()=>Rr,rtp98Multipliers:()=>_r,rtp97Multipliers:()=>Nr,rtp96Multipliers:()=>wr,rtp92Multipliers:()=>Vr,plinkoMultipliers:()=>Aa,nCr:()=>Vt,kenoMultipliers:()=>ua,isTileCount:()=>ia,hasDiceWon:()=>br,hasBlitzWon:()=>mr,getMaxMultiplierForDifficulty:()=>jn,getBlitzDefaults:()=>Sn,diamondsMultipliers:()=>Dr,calculateRouletteBetAmount:()=>Kn,calculateDiceWinChance:()=>Pr,calculateBlitzWinChance:()=>Er,calculateBaccaratBetAmount:()=>Yt,calculateAdvancedDiceWinChance:()=>Ft,bigMin:()=>da,bigMax:()=>la,advancedDiceIsWithinBoundsInclusive:()=>ka,advancedDiceIsWithinBoundsExclusive:()=>pt,advancedDiceGetInclusiveBoundsRange:()=>Ia,advancedDiceGetExclusiveBoundsRange:()=>Bt,WheelSegments:()=>X,WheelRiskLevel:()=>q,Wheel:()=>gr,WIN_MULTIPLIER:()=>Qa,VALID_SUITS:()=>cn,VALID_RANKS:()=>un,VALID_EUROPEAN_STREETS:()=>Ea,VALID_EUROPEAN_STRAIGHTS:()=>kt,VALID_EUROPEAN_SPLITS:()=>Ba,VALID_EUROPEAN_DOUBLE_STREETS:()=>Ha,VALID_EUROPEAN_CORNERS:()=>fa,VALID_AMERICAN_STREETS:()=>ya,VALID_AMERICAN_STRAIGHTS:()=>pa,VALID_AMERICAN_SPLITS:()=>ma,VALID_AMERICAN_DOUBLE_STREETS:()=>Da,VALID_AMERICAN_CORNERS:()=>Sa,ThreeCardBonusType:()=>Dt,TOP_COLUMN:()=>Jr,TILE_COUNTS:()=>Tr,THREE_CARD_BONUS_PAYOUTS:()=>Xt,SingleActionGame:()=>B,SPLIT_BET_SIZE_FACTOR:()=>w,RouletteType:()=>It,Roulette:()=>ba,RollType:()=>Ua,RandomValuePool:()=>nt,RED_NUMBERS:()=>zr,RANDOM_MIN_VALUE:()=>W,RANDOM_MAX_VALUE:()=>g,PlinkoRiskLevel:()=>sa,Plinko:()=>Mr,Parity:()=>I,PairBonusType:()=>Ht,PUSH_MULTIPLIER:()=>Wa,PLINKO_ROW_COUNTS:()=>Un,PAYOUT_MULTIPLIERS:()=>Fr,PAIR_BONUS_PAYOUTS:()=>qt,OrigamiGame:()=>y,MultiplierCalculator:()=>x,MultiActionGame:()=>jt,Mines:()=>Zr,MIN_WIN_CHANCE:()=>wa,MIDDLE_COLUMN:()=>Yr,MAX_WIN_CHANCE:()=>Va,MAX_CARDS_PER_ROUND:()=>Ct,Limbo:()=>Ur,LOSE_MULTIPLIER:()=>ga,KenoRiskLevel:()=>ca,Keno:()=>Ir,InsuranceOutcome:()=>St,INSURANCE_WIN_MULTIPLIER:()=>Pt,INSURANCE_BET_SIZE_FACTOR:()=>xt,Half:()=>Z,GameErrorCode:()=>_a,GameError:()=>u,FACE_CARD_VALUE:()=>zt,EuropeanRoulette:()=>xa,EUROPEAN_HOUSE_EDGE:()=>$,EFFECTIVE_RANGE:()=>Gt,Dozen:()=>M,DiceDirection:()=>Cr,Dice:()=>jr,DiamondsResultType:()=>Hr,Diamonds:()=>hr,Darts:()=>Sr,DOUBLE_DOWN_BET_SIZE_FACTOR:()=>R,DICE_MIN_ROLL:()=>oa,DICE_MAX_ROLL:()=>wt,DICE_EFFECTIVE_RANGE:()=>xr,DEALER_STAND_VALUE:()=>$t,DARTS_MIN_VALUE:()=>ra,DARTS_MAX_VALUE:()=>Rt,DARTS_DIFFICULTY_LEVEL:()=>na,DARTS_BOARD_CONFIGS:()=>_t,Column:()=>G,Color:()=>U,CARDS_PER_SUIT:()=>An,Blitz:()=>yr,BlackjackOutcome:()=>ft,BlackjackActionType:()=>Ot,Blackjack:()=>Br,BaccaratOutcome:()=>$a,BaccaratBetType:()=>za,Baccarat:()=>qa,BUST_VALUE:()=>ht,BOTTOM_COLUMN:()=>$r,BLITZ_RANDOM_NUMBER_COUNT:()=>ta,BLITZ_MIN_CARD_RANGE:()=>Kt,BLITZ_MAX_CARD_RANGE:()=>vt,BLITZ_CARD_COUNT:()=>J,BLACK_NUMBERS:()=>qr,BLACKJACK_VALUE:()=>h,BLACKJACK_MULTIPLIER:()=>Xa,BASE_PAYOUT_MULTIPLIERS:()=>K,AmericanRoulette:()=>Pa,AdvancedDice:()=>Za,AMERICAN_HOUSE_EDGE:()=>z,AMERICAN_BASKET:()=>Oa,ACE_SOFT_BONUS:()=>bt});module.exports=tn(ee);var _a;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(_a||={});class u extends Error{static createUnsupportedEdgeError(t){return new u("UNSUPPORTED_EDGE",t)}static createValidationError(t){return new u("INPUT_VALIDATION_ERROR",t)}static isGameError(t){return t instanceof u}errorCode;constructor(t,a){super(a);this.errorCode=t}}var y;((p)=>{p.DICE="DICE";p.MINES="MINES";p.KENO="KENO";p.LIMBO="LIMBO";p.ADVANCED_DICE="ADVANCED_DICE";p.BACCARAT="BACCARAT";p.DIAMONDS="DIAMONDS";p.PLINKO="PLINKO";p.ROULETTE="ROULETTE";p.WHEEL="WHEEL";p.BLACKJACK="BLACKJACK";p.BLITZ="BLITZ";p.DARTS="DARTS"})(y||={});var Na=require("@betorigami/guard");class B{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return Na.Guard.against(!a,()=>u.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}var Mt=require("big.js");var st=O(require("big.js"));class x{static withMultiplier(t,a){return new st.default(t).times(new st.default(100-a).div(100))}static withWinChance(t,a){return st.default(100-t).div(a)}}var W=0,g=1e4,Gt=g-W+1,wa=0.01,Va=98,rn=(t)=>{if(t<W)throw u.createValidationError(`Lower bound ${t} is below minimum allowed value ${W}`)},nn=(t)=>{if(t>g)throw u.createValidationError(`Upper bound ${t} is above maximum allowed value ${g}`)},At=(t)=>{if(rn(t.lower),nn(t.upper),t.lower>=t.upper)throw u.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},en=(t,a)=>{let[r,n]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>n.lower)throw u.createValidationError("Bounds must not overlap")},ka=(t,a)=>a>=t.lower&&a<=t.upper,Ia=(t)=>t.upper-t.lower+1,pt=(t,a)=>a>t.lower&&a<t.upper,Bt=(t)=>t.upper-t.lower-1,Ua;((n)=>{n.ROLL_BETWEEN="ROLL_BETWEEN";n.ROLL_OUTSIDE="ROLL_OUTSIDE";n.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Ua||={});var Ft=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return At(t.bounds),Bt(t.bounds);case"ROLL_OUTSIDE":return At(t.bounds),Gt-Ia(t.bounds);case"ROLL_BETWEEN_TWO":return At(t.firstBounds),At(t.secondBounds),en(t.firstBounds,t.secondBounds),Bt(t.firstBounds)+Bt(t.secondBounds)}})(),n=Mt.Big(r).div(Gt).mul(100);if(n.lt(wa))throw u.createValidationError("Win chance too low");if(n.gt(Va))throw u.createValidationError("Win chance too high");return n},on=(t)=>{Ft(t)};class Za extends B{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=Ft(r),e=t.getRandomInt({min:W,max:g}),c=e.value,i=(()=>{switch(r.mode){case"ROLL_BETWEEN":return pt(r.bounds,c);case"ROLL_OUTSIDE":return!ka(r.bounds,c);case"ROLL_BETWEEN_TWO":return pt(r.firstBounds,c)||pt(r.secondBounds,c)}})()?x.withWinChance(a,n):new Mt.Big(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:e.values},randomValues:e}}}var L=O(require("big.js"));var yt=require("@betorigami/guard");var Ga=0,Ma=51,mt=Array.from({length:52},(t,a)=>a),Fa=["Spades","Hearts","Diamonds","Clubs"],Et=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Ja=["Jack","Queen","King"],Jt={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};class N{value;constructor(t){let a=mt[t];yt.Guard.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=Fa[t];return yt.Guard.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=Et[t];return yt.Guard.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}var Ya=O(require("big.js")),T=(t)=>t.legs.reduce((a,r)=>a.add(r.amount),new Ya.default("0"));var cn=["Clubs","Diamonds","Hearts","Spades"],un=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],ln={Ace:"Ace",Two:"2",Three:"3",Four:"4",Five:"5",Six:"6",Seven:"7",Eight:"8",Nine:"9",Ten:"10",Jack:"Jack",Queen:"Queen",King:"King"},$a;((n)=>{n.PLAYER_WIN="PLAYER_WIN";n.TIE="TIE";n.BANKER_WIN="BANKER_WIN"})($a||={});var za;((n)=>{n.PLAYER="PLAYER";n.TIE="TIE";n.BANKER="BANKER"})(za||={});var dn={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Yt=(t)=>{return new L.default(0).add(t.bets.reduce((r,n)=>r.add(n.amount),new L.default(0)))},sn=(t,a)=>t==="TIE"&&(a==="PLAYER"||a==="BANKER");class qa extends B{constructor(){super("BACCARAT")}get supportedEdgeConfigurations(){return[1]}getBetAmount(t){return Yt(t)}determineGameResult({generator:t,gameInputs:a}){this.validateGameInputs(a);let r=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),n=r.values,e=n.slice(0,3),c=n.slice(3,6),o=[],i=0;for(let S of e.slice(0,2)){let _=this.mapRandomValueToCard(S),dt=this.mapRandomValueToCardValue(S);o.push(_),i=(i+dt)%10}let l=[],d=0;for(let S of c.slice(0,2)){let _=this.mapRandomValueToCard(S),dt=this.mapRandomValueToCardValue(S);l.push(_),d=(d+dt)%10}if(!this.isNaturalWin(i,d)){let S=this.shouldDrawThirdPlayerCard(i),_=null;if(S)_=this.mapRandomValueToCardValue(e[2]),o.push(this.mapRandomValueToCard(e[2])),i=(i+_)%10;if(this.shouldDrawThirdBankerCard(d,_))l.push(this.mapRandomValueToCard(c[2])),d=(d+this.mapRandomValueToCardValue(c[2]))%10}let A;if(i===d)A="TIE";else A=i>d?"PLAYER_WIN":"BANKER_WIN";let s=Yt(a),{betType:m,multiplier:p}=dn[A],D={legs:a.bets.map((S)=>{if(S.type===m)return{amount:S.amount.mul(p)};return{amount:sn(A,S.type)?S.amount:new L.default("0")}})},F=T(D),lt=s.gt(0)?F.div(s):new L.default(0);return{isFinished:!0,payout:D,payoutMultiplier:lt,outputs:{playerCards:o,playerHandValue:i,bankerCards:l,bankerHandValue:d,gameOutcome:A,result:r.values},randomValues:r}}validateGameInputs(t){if(t.bets.length===0)throw new Error("Must place at least a single bet.");if(!t.bets.every((a)=>a.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(t){let a=new N(t);return{suit:a.suit,rank:ln[a.rank]}}isNaturalWin(t,a){let r=[8,9];return r.includes(t)||r.includes(a)}mapRandomValueToCardValue(t){let a=t%13;if(a===0)return 1;if(a>=10)return 10;return a+1}shouldDrawThirdPlayerCard(t){return t<=5}shouldDrawThirdBankerCard(t,a){if(a===null)return t<=5;if(t<=2)return!0;if(t===3)return a!==8;if(t===4)return[2,3,4,5,6,7].includes(a);if(t===5)return[4,5,6,7].includes(a);if(t===6)return[6,7].includes(a);return!1}}var ft;((e)=>{e.WIN="WIN";e.LOSE="LOSE";e.PUSH="PUSH";e.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(ft||={});var St;((r)=>{r.WON="WON";r.LOST="LOST"})(St||={});var Ot;((i)=>{i.START="START";i.HIT="BLACKJACK_HIT";i.STAND="BLACKJACK_STAND";i.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";i.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";i.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";i.SPLIT="BLACKJACK_SPLIT"})(Ot||={});var Ht;((e)=>{e.EXACT_PAIR="EXACT_PAIR";e.COLORED_PAIR="COLORED_PAIR";e.MIXED_PAIR="MIXED_PAIR";e.LOSS="LOSS"})(Ht||={});var Dt;((o)=>{o.SUITED_TRIPS="SUITED_TRIPS";o.STRAIGHT_FLUSH="STRAIGHT_FLUSH";o.THREE_OF_A_KIND="THREE_OF_A_KIND";o.STRAIGHT="STRAIGHT";o.FLUSH="FLUSH";o.LOSS="LOSS"})(Dt||={});var Xa=2.5,Qa=2,Wa=1,ga=0,$t=17,ht=21,h=21,Ct=63,xt=0.5,Pt=3,R=1,w=1,An=13,bt=10,zt=10,K={PLAYER_BLACKJACK:Xa,WIN:Qa,PUSH:Wa,LOSE:ga},qt={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},Xt={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var b=O(require("big.js")),E=require("@betorigami/guard"),dr=require("@xstate/store");var La=require("@betorigami/guard");class f extends N{get numericRank(){if(Ja.includes(this.rank))return zt;return Et.indexOf(this.rank)+1}static fromValue(t){return La.Guard.against(!mt.includes(t),`Invalid card value: ${t}`),new f(t)}}class v{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,n)=>r+n.numericRank,0),t.some((r)=>r.rank==="Ace")&&this.hardHandValue+bt<=ht)this.softHandValue=this.hardHandValue+bt}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>ht}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===h}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class tt{cards;value;constructor(t){this.cards=t.map((a)=>f.fromValue(a)),this.value=new v(this.cards)}get isBusted(){return this.value.isBusted}get isBlackjack(){return this.value.isBlackjack}get highestHandValue(){return this.value.highestHandValue}get rawValues(){return this.cards.map((t)=>t.value)}toDto(){return{cards:this.cards.map((t)=>t.toDto()),value:this.highestHandValue}}}class at extends tt{otherCards;upCard;holeCard;constructor(t,a,r=[]){super([t,a,...r]);this.otherCards=r;this.upCard=f.fromValue(t),this.holeCard=f.fromValue(a)}static withInitialDeal(t){return new at(t.upCard,t.holeCard)}addDrawnCards(t){return new at(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new v([this.upCard]).highestHandValue}}}class V extends tt{static withInitialDeal(t){return new V(t)}addDrawnCards(t){return new V([...this.rawValues,...t])}}var rt=require("@betorigami/guard");class nt{source;index=0;constructor(t){this.source=t}static from(t,a){return rt.Guard.against(a<=0,`Count must be positive, got ${a}`),rt.Guard.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new nt(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return rt.Guard.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){rt.Guard.against(this.index+t>this.source.values.length,`RandomValuePool exhausted: requested ${t} but only ${this.source.values.length-this.index} remain`);let a=this.source.values.slice(this.index,this.index+t);return this.index+=t,a}}var Qt=require("@betorigami/guard"),Ka=O(require("fast-deep-equal"));class jt{gameId;edge;constructor(t,a){this.gameId=t;this.edge=a;this.validateEdge(a)}play(t,a,r=[]){let n=this.createGameStore(),e=this.generateRandomValues(t),c=e.toMultipleRandomValues();for(let l of r)n.send({...l.playerArgument,randomValuePool:e});let o=r[r.length-1];if(o)Qt.Guard.against(!Ka.default(o.state,this.toExternalState(n.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");n.send({...a,randomValuePool:e});let i=n.getSnapshot().context;return{playerArgument:i.playerArgument,state:this.toExternalState(i.state),config:i.config,additionalBetAmount:i.additionalBetAmount,proof:{proofHash:c.proofHash,proofString:c.proofString}}}validateEdge(t){let a=this.supportedEdgeConfigurations.includes(t);Qt.Guard.against(!a,()=>u.createUnsupportedEdgeError(`${this.gameId} does not support ${t}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}}var P=O(require("big.js"));var Tt=require("@betorigami/guard");var va=(t)=>{let a=t.pairBonus!==null?{amount:P.default(t.pairBonus.betAmount).mul(t.pairBonus.payoutMultiplier)}:null,r=t.threeCardBonus!==null?{amount:P.default(t.threeCardBonus.betAmount).mul(t.threeCardBonus.payoutMultiplier)}:null;return[a,r].filter((n)=>n!==null)},tr=(t)=>{let a=t.betAmounts.mainBetAmount,n=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(R):P.default(0),e=t.insuranceOutcome!==void 0?t.insuranceStake:P.default(0),c=a.plus(n).mul(K[t.outcome]),o=t.insuranceOutcome==="WON"?e.mul(Pt):P.default(0),i=va(t.sideBetResults),l=[{amount:c},...t.insuranceOutcome!==void 0?[{amount:o}]:[],...i],d=T({legs:l}),A=a.plus(e).plus(n).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);Tt.Guard.against(A.eq(0),"Total bet amount cannot be zero");let s=d.div(A);Tt.Guard.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let m;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":m=n;break;case"BLACKJACK_BUY_INSURANCE":m=t.insuranceStake;break;case"BLACKJACK_SPLIT":m=a.mul(w);break}return{payouts:l,totalBetAmount:A,multiplier:s,additionalBetAmount:m}},ar=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(R):P.default(0),n=t.splitHandDoubledDown?a.mul(R):P.default(0),e=t.insuranceOutcome!==void 0?t.insuranceStake:P.default(0),c=a.plus(r).mul(K[t.mainOutcome]),o=a.plus(n).mul(K[t.splitOutcome]),i=t.insuranceOutcome==="WON"?e.mul(Pt):P.default(0),l=va(t.sideBetResults),d=[{amount:c},{amount:o},...t.insuranceOutcome!==void 0?[{amount:i}]:[],...l],A=T({legs:d}),s=a.plus(a).plus(e).plus(r).plus(n).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);Tt.Guard.against(s.eq(0),"Total bet amount cannot be zero");let m=A.div(s),p;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":p=a.mul(R);break;case"BLACKJACK_SPLIT":p=a.mul(w);break}return{payouts:d,totalBetAmount:s,multiplier:m,additionalBetAmount:p}};var nr=require("@betorigami/guard"),Wt=(t)=>t.every((a)=>a===t[0]),rr=(t)=>{let a=[...t].sort((r,n)=>r-n);return a.every((r,n)=>{let e=a[n-1];if(n===0)return!0;return nr.Guard.againstUndefined(e,"Previous value cannot be undefined"),r===e+1})},er={Ace:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9,Ten:10,Jack:11,Queen:12,King:13},pn={...er,Ace:14},Bn=(t)=>rr(t.map((a)=>er[a]))||rr(t.map((a)=>pn[a])),or=(t,a)=>{let r=f.fromValue(t),n=f.fromValue(a);if(r.rank!==n.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(Jt[r.suit]===Jt[n.suit])return"COLORED_PAIR";return"MIXED_PAIR"},cr=(t,a)=>({betAmount:t,result:a,payoutMultiplier:qt[a]}),ir=(t,a,r)=>{let n=f.fromValue(t),e=f.fromValue(a),c=f.fromValue(r),o=[n.rank,e.rank,c.rank],i=Wt([n.suit,e.suit,c.suit]),l=Wt(o),d=Bn(o);if(Wt([t,a,r]))return"SUITED_TRIPS";if(i&&d)return"STRAIGHT_FLUSH";if(l)return"THREE_OF_A_KIND";if(d)return"STRAIGHT";if(i)return"FLUSH";return"LOSS"},ur=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Xt[a]});var mn={state:{isFinished:!1,phase:"uninitialised",multiplier:b.default(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},H=(t)=>f.fromValue(t).value;function En(t){E.Guard.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function lr(t){E.Guard.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function gt(t){E.Guard.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var sr=(t,a)=>{let r=a;while(r.highestHandValue<$t)r=r.addDrawnCards([H(t.takeOne())]);return r},Lt=(t,a)=>{if(t.isBusted)return"LOSE";if(a.isBusted)return"WIN";let r=t.highestHandValue,n=a.highestHandValue;if(r>n)return"WIN";if(r<n)return"LOSE";return"PUSH"},Ar=(t)=>t.insuranceOutcome===void 0?b.default(0):t.roundInsuranceStake(t.betAmounts.mainBetAmount.mul(xt)),pr=(t)=>{let{payouts:a,multiplier:r,additionalBetAmount:n}=tr({outcome:t.outcome,insuranceOutcome:t.insuranceOutcome,insuranceStake:Ar(t),actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"finished",playerHand:t.playerHand,dealerHand:t.dealerHand,outcome:t.outcome,payout:{legs:a},multiplier:r,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:n}},yn=(t)=>{let a=sr(t.randomValuePool,t.dealerHand),r=Lt(t.playerHand,a);return pr({...t,dealerHand:a,outcome:r})},fn=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:sr(t.randomValuePool,t.dealerHand),n=Lt(t.mainHand,r),e=Lt(t.splitHand,r),{payouts:c,multiplier:o,additionalBetAmount:i}=ar({hasSplit:!0,mainOutcome:n,splitOutcome:e,insuranceOutcome:t.insuranceOutcome,insuranceStake:Ar(t),mainHandDoubledDown:t.mainHandDoubledDown,splitHandDoubledDown:t.splitHandDoubledDown,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"split-finished",mainHand:t.mainHand,splitHand:t.splitHand,dealerHand:r,mainOutcome:n,splitOutcome:e,payout:{legs:c},multiplier:o,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:i}};class Br extends jt{roundInsuranceStake;constructor(t,a){super("BLACKJACK",t);this.roundInsuranceStake=a}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return nt.from(t.getRandomIntsWithReplacement({min:Ga,max:Ma,count:Ct}),Ct)}toExternalState(t){let a=t.phase;switch(a){case"awaiting-insurance":return{isFinished:!1,phase:"awaiting-insurance",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"in-progress":return{isFinished:!1,phase:"player-turn",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-main-hand":return{isFinished:!1,phase:"playing-main-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-split-hand":return{isFinished:!1,phase:"playing-split-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"finished":return{isFinished:!0,payout:t.payout,multiplier:t.multiplier,randomValues:t.randomValues,outcome:t.outcome,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"split-finished":return{isFinished:!0,payout:t.payout,multiplier:t.multiplier,randomValues:t.randomValues,mainOutcome:t.mainOutcome,splitOutcome:t.splitOutcome,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"uninitialised":throw new Error("Cannot convert uninitialised state to external state");default:E.Guard.againstNever(a,"Invalid state received")}}createGameStore(){let t=(e)=>{if(this.roundInsuranceStake===void 0)return e;let c=this.roundInsuranceStake(e);return E.Guard.against(e.gt(0)&&c.eq(0),"Insurance stake rounds below the smallest unit this currency supports"),c},a=(e)=>pr({...e,roundInsuranceStake:t}),r=(e)=>yn({...e,roundInsuranceStake:t}),n=(e)=>fn({...e,roundInsuranceStake:t});return dr.createStore({context:mn,on:{START:(e,c)=>{let{state:o}=e;E.Guard.against(o.phase!=="uninitialised","START action requires a fresh game");let i=H(c.randomValuePool.takeOne()),l=H(c.randomValuePool.takeOne()),d=H(c.randomValuePool.takeOne()),A=H(c.randomValuePool.takeOne()),s=V.withInitialDeal([i,l]),m=at.withInitialDeal({upCard:d,holeCard:A}),p={mainBetAmount:b.default(c.mainBetAmount),pairBonusAmount:b.default(c.pairBonusAmount),threeCardBonusAmount:b.default(c.threeCardBonusAmount)},C={pairBonus:b.default(c.pairBonusAmount).gt(0)?cr(c.pairBonusAmount,or(i,l)):null,threeCardBonus:b.default(c.threeCardBonusAmount).gt(0)?ur(c.threeCardBonusAmount,ir(i,l,d)):null},D={type:"START",mainBetAmount:c.mainBetAmount,pairBonusAmount:c.pairBonusAmount,threeCardBonusAmount:c.threeCardBonusAmount};if(m.upCard.rank==="Ace")return{state:{...o,isFinished:!1,phase:"awaiting-insurance",playerHand:s,dealerHand:m,betAmounts:p,sideBetResults:C},config:{},playerArgument:D};let F={playerHand:s,dealerHand:m,randomValuePool:c.randomValuePool,playerArgument:D,betAmounts:p,sideBetResults:C};if(s.isBlackjack&&m.isBlackjack)return a({...F,outcome:"PUSH"});if(s.isBlackjack)return a({...F,outcome:"PLAYER_BLACKJACK"});if(m.isBlackjack)return a({...F,outcome:"LOSE"});return{state:{...o,isFinished:!1,phase:"in-progress",playerHand:s,dealerHand:m,insuranceOutcome:void 0,betAmounts:p,sideBetResults:C},config:{},playerArgument:D}},BLACKJACK_BUY_INSURANCE:(e,c)=>{let{state:o}=e;lr(o);let{playerHand:i,dealerHand:l,betAmounts:d,sideBetResults:A}=o,s={...o,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:d,sideBetResults:A};if(i.isBlackjack&&l.isBlackjack)return a({...s,outcome:"PUSH",insuranceOutcome:"WON"});if(i.isBlackjack)return a({...s,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(l.isBlackjack)return a({...s,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...o,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:t(d.mainBetAmount.mul(xt))}},BLACKJACK_REJECT_INSURANCE:(e,c)=>{let{state:o}=e;lr(o);let{playerHand:i,dealerHand:l,betAmounts:d,sideBetResults:A}=o,s={playerHand:i,dealerHand:l,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:d,sideBetResults:A};if(i.isBlackjack&&l.isBlackjack)return a({...s,outcome:"PUSH"});if(i.isBlackjack)return a({...s,outcome:"PLAYER_BLACKJACK"});if(l.isBlackjack)return a({...s,outcome:"LOSE"});return{state:{...o,phase:"in-progress",insuranceOutcome:void 0},config:{},playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"}}},BLACKJACK_HIT:(e,c)=>{let{state:o}=e;switch(gt(o),o.phase){case"playing-main-hand":{let i=o.mainHand.addDrawnCards([H(c.randomValuePool.takeOne())]);if(i.isBusted||i.highestHandValue===h){if(o.splitHand.highestHandValue===h)return n({...o,mainHand:i,splitHandDoubledDown:!1,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...o,phase:"playing-split-hand",mainHand:i,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...o,mainHand:i},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let i=o.splitHand.addDrawnCards([H(c.randomValuePool.takeOne())]);if(i.isBusted||i.highestHandValue===h)return n({...o,splitHand:i,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...o,splitHand:i},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let i=o.playerHand.addDrawnCards([H(c.randomValuePool.takeOne())]);if(i.isBusted)return a({...o,playerHand:i,outcome:"LOSE",randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(i.highestHandValue===h)return r({...o,playerHand:i,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...o,phase:"in-progress",playerHand:i},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:E.Guard.againstNever(o,"Invalid phase for HIT action")}},BLACKJACK_STAND:(e,c)=>{let{state:o}=e;switch(gt(o),o.phase){case"playing-main-hand":{if(o.splitHand.highestHandValue===h)return n({...o,splitHandDoubledDown:!1,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});return{state:{...o,phase:"playing-split-hand",splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_STAND"}}}case"playing-split-hand":return n({...o,splitHandDoubledDown:o.splitHandDoubledDown,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});case"in-progress":return r({...o,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});default:E.Guard.againstNever(o,"Invalid phase for STAND action")}},BLACKJACK_DOUBLE_DOWN:(e,c)=>{let{state:o}=e;switch(gt(o),o.phase){case"playing-main-hand":{E.Guard.against(o.mainHand.cards.length!==2,"Double down is only allowed as the first action");let i=o.mainHand.addDrawnCards([H(c.randomValuePool.takeOne())]),{betAmounts:l}=o;if(o.splitHand.highestHandValue===h)return n({...o,mainHand:i,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...o,phase:"playing-split-hand",mainHand:i,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:l.mainBetAmount.mul(R)}}case"playing-split-hand":{E.Guard.against(o.splitHand.cards.length!==2,"Double down is only allowed as the first action");let i=o.splitHand.addDrawnCards([H(c.randomValuePool.takeOne())]);return n({...o,splitHand:i,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{E.Guard.against(o.playerHand.cards.length!==2,"Double down is only allowed as the first action");let i=o.playerHand.addDrawnCards([H(c.randomValuePool.takeOne())]);if(i.isBusted)return a({...o,playerHand:i,outcome:"LOSE",randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return r({...o,playerHand:i,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:E.Guard.againstNever(o,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(e,c)=>{let{state:o}=e;En(o);let{playerHand:i,betAmounts:l,sideBetResults:d}=o;E.Guard.against(i.cards.length!==2,"Split is only allowed with exactly 2 cards");let A=i.cards[0],s=i.cards[1];E.Guard.againstUndefined(A,"First card is missing"),E.Guard.againstUndefined(s,"Second card is missing"),E.Guard.against(A.rank!==s.rank,"Split requires two cards of the same rank");let m=H(c.randomValuePool.takeOne()),p=H(c.randomValuePool.takeOne()),C=V.withInitialDeal([A.value,m]),D=V.withInitialDeal([s.value,p]);if(A.rank==="Ace")return n({...o,mainHand:C,splitHand:D,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let lt=C.highestHandValue===h,S=D.highestHandValue===h;if(lt&&S)return n({mainHand:C,splitHand:D,dealerHand:o.dealerHand,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:o.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:l,sideBetResults:d});if(lt)return{state:{...o,phase:"playing-split-hand",mainHand:C,splitHand:D,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:l.mainBetAmount.mul(w)};return{state:{...o,phase:"playing-main-hand",multiplier:b.default(0),mainHand:C,splitHand:D,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:l.mainBetAmount.mul(w)}}}})}getValidNextActionTypes(t){if(t.isFinished)return[];switch(t.phase){case"awaiting-insurance":return["BLACKJACK_BUY_INSURANCE","BLACKJACK_REJECT_INSURANCE"];case"playing-main-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.mainHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"playing-split-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.splitHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"player-turn":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.playerHand.cards.length===2){a.push("BLACKJACK_DOUBLE_DOWN");let r=t.playerHand.cards[0],n=t.playerHand.cards[1];if(E.Guard.againstUndefined(r,"First player card is missing"),E.Guard.againstUndefined(n,"Second player card is missing"),r.rank===n.rank)a.push("BLACKJACK_SPLIT")}return a}default:E.Guard.againstNever(t,"Invalid phase for getting valid actions")}}}var Y=O(require("big.js")),aa=require("@betorigami/guard");var Kt=0,vt=51,J=52,ta=52;var Sn=()=>({minPicks:5,maxPicks:36}),mr=(t)=>t.length===new Set(t).size,Er=(t)=>{let a=Y.default(1),r=Y.default(J);for(let n=0;n<t;n+=1)a=a.mul(Y.default(J-n).div(r));return a};class yr extends B{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){aa.Guard.against(a.pickCount<1||a.pickCount>J,`pickCount must be between 1 and ${J}`),aa.Guard.againstNonInteger(a.pickCount,"pickCount must be an integer");let n=t.getRandomIntsWithReplacement({min:Kt,max:vt,count:ta}),e=n.values.slice(0,a.pickCount),c=mr(e),o=Er(a.pickCount),i=c?x.withMultiplier(Y.default(1).div(o),r):Y.default(0);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:n.values,cards:e.map((l)=>new N(l).toDto())},randomValues:n}}}var ra=0,Rt=4294967295,na;((e)=>{e.EASY="EASY";e.MEDIUM="MEDIUM";e.HARD="HARD";e.EXPERT="EXPERT"})(na||={});var On=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Hn={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:0.5,ringTwo:0.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:0.5},segments:On},Dn=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],hn={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:0.4,ringTwo:0.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:0.4},segments:Dn},Cn=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],xn={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:0.2,ringTwo:0.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:0.2},segments:Cn},Pn=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],bn={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:0.1,ringTwo:0.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:0.1},segments:Pn},jn=(t)=>{let a=_t[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((n,e)=>e>n?e:n)},_t={EASY:Hn,MEDIUM:hn,HARD:xn,EXPERT:bn};var Nt=require("@betorigami/guard"),fr=O(require("big.js"));class Sr extends B{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:ra,max:Rt,count:2}),n=r.values[0],e=r.values[1];Nt.Guard.againstUndefined(n,"Random number generator returned no value for clockWiseRotation"),Nt.Guard.againstUndefined(e,"Random number generator returned no value for distanceFromCentre");let c=a.difficultyLevel,o=fr.default(Tn(c,n,e));return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:r.values},randomValues:r}}}var Tn=(t,a,r)=>{let n=_t[t],{distanceBoundaries:e,multipliers:c}=n;if(r<e.bullseye)return c.bullseye;if(r<e.ringOne)return c.ringOne;if(r<e.ringTwo)return c.ringTwo;if(r<e.ringThree)return Rn(n,a);return c.ringFour},Rn=(t,a)=>{let r=t.segments.length,n=Math.floor(a/(Rt+1)*r),e=t.segments[n];return Nt.Guard.againstUndefined(e,`Segment index ${n} out of bounds`),t.multipliers.ringThree[e]};var Or=O(require("big.js"));class j{multipliers;constructor(t){this.multipliers=t}getMultipliers(t){let a=this.multipliers.get(t);if(a===void 0)throw new Error(`Multipliers for ${t} not found`);return a}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([t,a])=>({edge:t,multipliers:a}))}}var Hr;((o)=>{o.PAIR="PAIR";o.TWO_PAIR="TWO_PAIR";o.THREE_OF_A_KIND="THREE_OF_A_KIND";o.FULL_HOUSE="FULL_HOUSE";o.FOUR_OF_A_KIND="FOUR_OF_A_KIND";o.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(Hr||={});var _n={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},Nn={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},wn={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},Vn={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},kn={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},Dr=new j(new Map([[1,_n],[2,Nn],[3,wn],[4,Vn],[8,kn]])),In={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class hr extends B{constructor(){super("DIAMONDS")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=Dr.getMultipliers(a),c=n.values,o=Or.default(this.calculatePayoutMultiplier(e,c));return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:n.values},randomValues:n}}calculatePayoutMultiplier(t,a){let r=new Map;for(let c of a){let o=r.get(c)||0;r.set(c,o+1)}let n=[...r.values()].filter((c)=>c>1),e=this.classifyResult(n);return e===null?0:t[e]}classifyResult(t){if(t.length>2)throw new Error(`Unexpected number of repeats ${t.length}`);let[a,r]=t;if(a===void 0)return null;if(r===void 0){let n=In[a];if(n===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return n}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}var ea=O(require("big.js"));var Cr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Cr||={});var oa=0,wt=1e4,xr=wt-oa+1,Pr=(t)=>{let a=t.direction==="ABOVE"?wt-t.selectedValue:t.selectedValue;return new ea.default(a).div(xr).mul(100)},br=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class jr extends B{constructor(){super("DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomInt({min:oa,max:wt}),e=Pr(r),o=br(r,n.value)?x.withWinChance(a,e):new ea.default(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:n.values},randomValues:n}}}var kr=O(require("big.js"));var et=require("@betorigami/guard");var ca;((e)=>{e.CLASSIC="CLASSIC";e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(ca||={});var Tr=[1,2,3,4,5,6,7,8,9,10],ia=(t)=>{return Tr.includes(t)};var Rr={[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]}},_r={[1]:{CLASSIC:[0,3.92],LOW_RISK:[0.7,1.82],MEDIUM_RISK:[0.4,2.72],HIGH_RISK:[0,3.92]},[2]:{CLASSIC:[0,1.9,4.32],LOW_RISK:[0,2,3.65],MEDIUM_RISK:[0,1.8,5],HIGH_RISK:[0,0,17]},[3]:{CLASSIC:[0,1,3,10.7],LOW_RISK:[0,1.1,1.3,26.2],MEDIUM_RISK:[0,0,2.7,50.3],HIGH_RISK:[0,0,0,80.7]},[4]:{CLASSIC:[0,0.8,1.8,4.75,22.5],LOW_RISK:[0,0,2.2,7.65,90],MEDIUM_RISK:[0,0,1.7,9.8,100],HIGH_RISK:[0,0,0,9.75,259]},[5]:{CLASSIC:[0,0.2,1.4,4.25,16.4,36],LOW_RISK:[0,0,1.5,4.1,12.9,300],MEDIUM_RISK:[0,0,1.4,3.9,13.9,390],HIGH_RISK:[0,0,0,4.5,47,450]},[6]:{CLASSIC:[0,0,1,3.6,7,17,40],LOW_RISK:[0,0,1.1,2,5.8,100,700],MEDIUM_RISK:[0,0,0,3,8.6,180,710],HIGH_RISK:[0,0,0,0,10.6,350,710]},[7]:{CLASSIC:[0,0,0.5,3,4.1,13.7,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,13.5,225,700],MEDIUM_RISK:[0,0,0,2,6.9,29.2,400,800],HIGH_RISK:[0,0,0,0,6.9,89.1,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,12.2,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,4.8,38,100,800],MEDIUM_RISK:[0,0,0,2,4,10.4,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.8,270,600,900]},[9]:{CLASSIC:[0,0,0,1.5,3,8.1,15,45,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.1,7.4,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1000],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.5,7.6,16,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.6,3.7,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1000]}},Nr={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.7,1.78],MEDIUM_RISK:[0.4,2.68],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,2,3.48],MEDIUM_RISK:[0,1.8,4.8],HIGH_RISK:[0,0,16.8]},[3]:{CLASSIC:[0,1,3,9.9],LOW_RISK:[0,1.1,1.2,26.5],MEDIUM_RISK:[0,0,2.65,50],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.7,5,23],LOW_RISK:[0,0,2.1,7.95,90],MEDIUM_RISK:[0,0,1.7,9.55,100],HIGH_RISK:[0,0,0,9.5,259]},[5]:{CLASSIC:[0,0.2,1.4,4.1,16.6,36],LOW_RISK:[0,0,1.5,4,12.7,300],MEDIUM_RISK:[0,0,1.4,3.8,13.7,390],HIGH_RISK:[0,0,0,4.4,46.9,450]},[6]:{CLASSIC:[0,0,1,3.6,6.6,16.5,40],LOW_RISK:[0,0,1.1,1.9,5.9,100,700],MEDIUM_RISK:[0,0,0,2.9,8.7,180,710],HIGH_RISK:[0,0,0,0,10.8,342,710]},[7]:{CLASSIC:[0,0,0.5,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.1,1.6,3.1,14.8,225,700],MEDIUM_RISK:[0,0,0,2,6.7,29,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.8,12.7,21,54,70],LOW_RISK:[0,0,1.1,1.5,1.8,5.2,38,100,800],MEDIUM_RISK:[0,0,0,2,3.8,10.8,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.5,265,600,900]},[9]:{CLASSIC:[0,0,0,1.5,2.9,8.2,15,43,60,85],LOW_RISK:[0,0,1.1,1.3,1.6,2.1,7.7,49,250,1000],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.2,8,16.7,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.5,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1000]}},wr={[1]:{CLASSIC:[0,3.84],LOW_RISK:[0.69,1.77],MEDIUM_RISK:[0.38,2.7],HIGH_RISK:[0,3.84]},[2]:{CLASSIC:[0,1.83,4.44],LOW_RISK:[0,1.98,3.44],MEDIUM_RISK:[0,1.78,4.77],HIGH_RISK:[0,0,16.64]},[3]:{CLASSIC:[0,0.98,3,9.8],LOW_RISK:[0,1.09,1.19,26.15],MEDIUM_RISK:[0,0,2.6,49.8],HIGH_RISK:[0,0,0,79]},[4]:{CLASSIC:[0,0.79,1.68,5,22.7],LOW_RISK:[0,0,2.1,7.8,88.3],MEDIUM_RISK:[0,0,1.66,9.5,100],HIGH_RISK:[0,0,0,9.25,259]},[5]:{CLASSIC:[0,0.19,1.39,4.1,16.3,35.5],LOW_RISK:[0,0,1.47,4,12.5,300],MEDIUM_RISK:[0,0,1.37,3.8,13.5,390],HIGH_RISK:[0,0,0,4.3,46.6,450]},[6]:{CLASSIC:[0,0,0.98,3.6,6.5,15.9,39.9],LOW_RISK:[0,0,1.08,1.89,5.8,100,700],MEDIUM_RISK:[0,0,0,2.9,8.35,180,710],HIGH_RISK:[0,0,0,0,10.4,342,710]},[7]:{CLASSIC:[0,0,0.47,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.08,1.59,3.1,14.6,225,700],MEDIUM_RISK:[0,0,0,1.98,6.6,28.7,400,800],HIGH_RISK:[0,0,0,0,6.7,87.3,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.7,12.5,21,54,70],LOW_RISK:[0,0,1.09,1.49,1.77,5.1,37.5,100,800],MEDIUM_RISK:[0,0,0,1.96,3.8,10.7,65.8,400,900],HIGH_RISK:[0,0,0,0,4.9,18.8,265,600,900]},[9]:{CLASSIC:[0,0,0,1.47,2.9,8.1,14.9,43,60,85],LOW_RISK:[0,0,1.09,1.28,1.59,2.1,7.6,48.4,250,1000],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1000],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.2,7.8,16.5,49.2,80,100],LOW_RISK:[0,0,1.08,1.19,1.3,1.47,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1000]}},Vr={[1]:{CLASSIC:[0,3.68],LOW_RISK:[0.7,1.58],MEDIUM_RISK:[0.4,2.48],HIGH_RISK:[0,3.68]},[2]:{CLASSIC:[0,1.72,4.48],LOW_RISK:[0,1.9,3.28],MEDIUM_RISK:[0,1.7,4.62],HIGH_RISK:[0,0,15.95]},[3]:{CLASSIC:[0,0.9,2.95,9.9],LOW_RISK:[0,1,1.2,26],MEDIUM_RISK:[0,0,2.29,50],HIGH_RISK:[0,0,0,75.7]},[4]:{CLASSIC:[0,0.8,1.6,4.4,21],LOW_RISK:[0,0,2,7.5,86],MEDIUM_RISK:[0,0,1.5,9.5,98],HIGH_RISK:[0,0,0,9,246]},[5]:{CLASSIC:[0,0.2,1.2,4.2,16.3,37],LOW_RISK:[0,0,1.4,3.8,12,300],MEDIUM_RISK:[0,0,1.3,3.5,14,385],HIGH_RISK:[0,0,0,4,45,450]},[6]:{CLASSIC:[0,0,1,3.3,6.2,15,40],LOW_RISK:[0,0,1.1,1.7,4.9,99,700],MEDIUM_RISK:[0,0,0,2.6,8.5,177,705],HIGH_RISK:[0,0,0,0,10,327,710]},[7]:{CLASSIC:[0,0,0.4,2.8,4.2,14.5,30,60],LOW_RISK:[0,0,1.1,1.4,3,14,210,700],MEDIUM_RISK:[0,0,0,1.8,6.4,29,400,800],HIGH_RISK:[0,0,0,0,6.1,85,400,800]},[8]:{CLASSIC:[0,0,0,2,3.7,13,20,50,70],LOW_RISK:[0,0,1.1,1.4,1.6,4.6,35,90,800],MEDIUM_RISK:[0,0,0,1.9,3.5,10.5,65,400,900],HIGH_RISK:[0,0,0,0,4.5,18,265,600,900]},[9]:{CLASSIC:[0,0,0,1.4,2.6,9,11.5,40,60,85],LOW_RISK:[0,0,1,1.3,1.5,2,7,45,250,1000],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.3,2,4.4,8,16.7,50,80,100],LOW_RISK:[0,0,1,1.2,1.25,1.4,2,10,50,250,1000],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1000],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1000]}},ua=new j(new Map([[1,Rr],[2,_r],[3,Nr],[4,wr],[8,Vr]]));class Ir extends B{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){et.Guard.againstEmptyArray(r.selectedNumbers,()=>u.createValidationError("No numbers selected")),et.Guard.against(r.selectedNumbers.length>10,()=>u.createValidationError("Maximum of 10 numbers can be selected"));for(let s of r.selectedNumbers)et.Guard.againstNonInteger(s,()=>u.createValidationError("Only integers can be selected")),et.Guard.against(s<0||s>39,()=>u.createValidationError("Invalid number selected"));let n=t.getUniqueRandomInts({min:0,max:39,count:10}),e=r.selectedNumbers.filter((s)=>n.values.includes(s)),c=r.selectedNumbers.length;if(!ia(c))throw new Error(`Invalid tile count: ${c}`);let d=ua.getMultipliers(a)[c][r.riskLevel][e.length];if(d===void 0)throw new Error(`No multiplier found for matching tile count ${e.length}`);let A=new kr.default(d);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(A)}]},payoutMultiplier:A,outputs:{result:n.values},randomValues:n}}}var k=O(require("big.js"));var la=(t,a)=>{return t.gt(a)?t:a};var da=(t,a)=>{return t.lt(a)?t:a};class Ur extends B{constructor(){super("LIMBO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomInt({min:1,max:4294967295}),e=n.max,c=new k.default(16777216),o=new k.default(1),i=new k.default(1e6),l=n.value,d=new k.default(l-1).div(e),A=(100-a)/100,s=c.div(d.mul(c).plus(1)).mul(A),m=la(o,da(s,i)),p=m.gte(r.targetMultiplier)?new k.default(r.targetMultiplier):new k.default(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(p)}]},payoutMultiplier:p,outputs:{randomMultiplier:m,result:n.values},randomValues:n}}}var ot=O(require("big.js"));var Vt=(t,a)=>{if(a<0||t<0||a>t)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(a>t-a)a=t-a;let r=1;for(let n=1;n<=a;n++)r=r*(t-n+1)/n;return r};class Zr extends B{constructor(){super("MINES")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){if(r.minesCount<=0||r.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(r.selectedTiles.length>25-r.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let o=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),i=o.values.some((p)=>r.selectedTiles.includes(p)),l=r.hasCashedOut||i,d=(100-a)/100,A=new ot.default(Vt(25-r.minesCount,r.selectedTiles.length)).div(new ot.default(Vt(25,r.selectedTiles.length))),m=r.hasCashedOut&&!i?new ot.default(d).div(A):new ot.default(0);return{isFinished:l,payout:{legs:[{amount:r.betAmount.mul(m)}]},payoutMultiplier:m,outputs:{result:o.values},randomValues:o}}}var Gr=require("big.js");var sa;((n)=>{n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(sa||={});var Un=[8,9,10,11,12,13,14,15,16],Zn={LOW_RISK:{8:[6,2.1,1.1,1,0.5,1,1.1,2.1,6],9:[6,2,1.6,1,0.7,0.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],16:[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:{8:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],9:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],10:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],11:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],12:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,0.3,0.2,0.3,1.5,4,29],9:[43,7,2,0.6,0.2,0.2,0.6,2,7,43],10:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76],11:[120,13.9,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,0.2,0.2,0.2,0.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,82.8,620],16:[1000,129.9,26.1,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26.1,129.9,1000]}},Gn={LOW_RISK:{8:[6,1.9,1.1,1,0.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,0.7,0.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,0.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,0.7,0.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,0.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,0.9,0.7,0.7,0.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,0.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,0.7,0.7,1,1.1,1.4,2,2.8,7.6,15],16:[16,9,1.7,1.2,1.3,1.2,1.1,1,0.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,0.6,0.4,0.6,1.4,3.2,13],9:[18,3.7,1.7,0.9,0.5,0.5,0.9,1.7,3.7,18],10:[22,5,1.9,1.4,0.6,0.4,0.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,0.7,0.5,0.5,0.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,0.6,0.3,0.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,0.5,0.2,0.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,0.5,0.3,0.3,0.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,0.5,0.3,0.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,0.3,0.2,0.3,1.5,3.8,29],9:[43,7.1,1.9,0.6,0.2,0.2,0.6,1.9,7.1,43],10:[76,9.9,2.9,0.9,0.3,0.2,0.3,0.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,0.4,0.2,0.2,0.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,0.7,0.2,0.2,0.2,0.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,0.2,0.2,0.2,0.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,0.3,0.2,0.2,0.2,0.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,0.5,0.2,0.2,0.2,0.2,0.5,3,7.7,26.8,82.3,620],16:[1000,129.8,25.2,8.6,4,2,0.2,0.2,0.2,0.2,0.2,2,4,8.6,25.2,129.8,1000]}},Mn={LOW_RISK:{8:[6,2.2,1.1,1,0.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,0.7,0.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,0.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,0.7,0.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,0.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,0.9,0.7,0.7,0.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,0.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,0.7,0.7,1,1.1,1.3,2,2.5,7.9,15],16:[16,8.9,1.9,1.4,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,0.7,0.3,0.7,1.2,3.5,13],9:[18,3.8,1.6,0.9,0.5,0.5,0.9,1.6,3.8,18],10:[22,5.2,2,1.3,0.6,0.4,0.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,0.7,0.5,0.5,0.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,0.6,0.3,0.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,0.5,0.2,0.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,0.5,0.3,0.3,0.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,0.5,0.3,0.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,0.3,0.2,0.3,1.4,4,29],9:[43,7.3,2,0.5,0.2,0.2,0.5,2,7.3,43],10:[76,9.8,2.8,0.9,0.3,0.2,0.3,0.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,0.4,0.2,0.2,0.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,0.2,0.2,0.2,0.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,0.5,0.2,0.2,0.2,0.2,0.5,2.9,7.7,26.6,81.9,620],16:[1000,130,24.9,8.4,3.9,2,0.2,0.2,0.2,0.2,0.2,2,3.9,8.4,24.9,130,1000]}},Fn={LOW_RISK:{8:[6,2,1.1,1,0.4,1,1.1,2,6],9:[6,1.9,1.4,1,0.7,0.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,0.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,0.7,0.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,0.9,0.6,0.6,0.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,0.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,0.6,0.6,1,1.2,1.4,2,2.9,8,15],16:[16,9.1,2.2,1.4,1.2,1.2,1.1,1,0.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,0.7,0.4,0.7,1.2,2.9,13],9:[18,3.5,1.6,0.9,0.5,0.5,0.9,1.6,3.5,18],10:[22,4.7,2,1.3,0.6,0.4,0.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,0.7,0.5,0.5,0.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,0.6,0.3,0.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,0.7,0.4,0.4,0.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,0.5,0.2,0.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,0.5,0.3,0.3,0.5,1.3,2.7,4.9,10.7,17.7,88],16:[110,39.7,9.6,4.8,2.8,1.4,1,0.5,0.3,0.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,0.3,0.2,0.3,1.4,3.9,29],9:[43,6.9,1.8,0.6,0.2,0.2,0.6,1.8,6.9,43],10:[76,9.8,2.7,0.9,0.3,0.2,0.3,0.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,0.4,0.2,0.2,0.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,0.2,0.2,0.2,0.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,0.5,0.2,0.2,0.2,0.2,0.5,2.8,7.8,26.1,80.6,620],16:[1000,129.7,24.7,8.2,3.8,2,0.2,0.2,0.2,0.2,0.2,2,3.8,8.2,24.7,129.7,1000]}},Jn={LOW_RISK:{8:[5,1.8,1,1,0.4,1,1,1.8,5],9:[5,1.7,1.2,1,0.7,0.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,0.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,0.7,0.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,0.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,0.9,0.6,0.6,0.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,0.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,0.6,0.6,1,1,1.4,1.9,2.9,7.3,15],16:[16,8.7,2,1.5,1.3,1,1.1,1,0.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,0.7,0.4,0.7,1.1,2.6,13],9:[17,3.3,1.4,0.9,0.5,0.5,0.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,0.6,0.4,0.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,0.7,0.5,0.5,0.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,0.6,0.2,0.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,0.7,0.4,0.4,0.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,0.5,0.2,0.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,0.5,0.3,0.3,0.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,0.5,0.3,0.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,0.3,0.2,0.3,1.4,3.3,28],9:[42,6.7,1.6,0.6,0.2,0.2,0.6,1.6,6.7,42],10:[74,9.6,2.6,0.9,0.3,0.1,0.3,0.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,0.4,0.2,0.2,0.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,0.7,0.2,0.2,0.2,0.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,0.2,0.2,0.2,0.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,0.3,0.2,0.2,0.2,0.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,0.5,0.2,0.2,0.2,0.2,0.5,2.6,7.4,24.9,76.9,600],16:[1000,122,24.5,8,3.7,1.8,0.2,0.2,0.2,0.2,0.2,1.8,3.7,8,24.5,122,1000]}},Aa=new j(new Map([[1,Zn],[2,Gn],[3,Mn],[4,Fn],[8,Jn]]));class Mr extends B{constructor(){super("PLINKO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){if(a.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(a.numberOfRows<8||a.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let n=a.numberOfRows,o=Aa.getMultipliers(r)[a.riskLevel][n],i=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),d=i.values.reduce((m,p)=>m+p,0),A=o[d];if(A===void 0)throw new Error(`No payout found for end position ${d}`);let s=Gr.Big(A);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:i.values},randomValues:i}}}var ut=require("big.js");var kt=[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],pa=[37,...kt],Ba=[[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]],ma=[[0,1],[0,37],[3,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]],Ea=[[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]],ya=[[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]],fa=[[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]],Sa=[[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]],Oa=[0,1,2,3,37],Ha=[[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]],Da=[[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]],I;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(I||={});var U;((r)=>{r.RED="RED";r.BLACK="BLACK"})(U||={});var Z;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(Z||={});var G;((n)=>{n.TOP="TOP";n.MIDDLE="MIDDLE";n.BOTTOM="BOTTOM"})(G||={});var M;((n)=>{n.FIRST="FIRST";n.SECOND="SECOND";n.THIRD="THIRD"})(M||={});var It;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(It||={});var $=2.7,z=5.3;var Ut=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw u.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&ct(a.value)))throw u.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Yn(a.values)))throw u.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&$n(a.values)))throw u.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&zn(a.values)))throw u.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&qn(a.values)))throw u.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.parity)))throw u.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.color)))throw u.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.half)))throw u.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.column)))throw u.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.dozen)))throw u.createValidationError("Invalid dozen bet.")},ct=(t)=>{return kt.includes(t)},Yn=(t)=>{if(t.length!==2)return!1;if(!t.every(ct))return!1;return Ba.some(([a,r])=>a===t[0]&&r===t[1])},$n=(t)=>{if(t.length!==3)return!1;if(!t.every(ct))return!1;return Ea.some(([a,r,n])=>a===t[0]&&r===t[1]&&n===t[2])},zn=(t)=>{if(t.length!==4)return!1;if(!t.every(ct))return!1;return fa.some(([a,r,n,e])=>a===t[0]&&r===t[1]&&n===t[2]&&e===t[3])},qn=(t)=>{if(t.length!==6)return!1;if(!t.every(ct))return!1;return Ha.some(([a,r,n,e,c,o])=>a===t[0]&&r===t[1]&&n===t[2]&&e===t[3]&&c===t[4]&&o===t[5])};var Zt=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.basketBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw u.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&it(a.value)))throw u.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Xn(a.values)))throw u.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Qn(a.values)))throw u.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Wn(a.values)))throw u.createValidationError("Invalid corner bet.");if(!t.basketBets.every((a)=>a.amount.gte(0)))throw u.createValidationError("Invalid basket bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&gn(a.values)))throw u.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.parity)))throw u.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.color)))throw u.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.half)))throw u.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.column)))throw u.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.dozen)))throw u.createValidationError("Invalid dozen bet.")},it=(t)=>{return pa.includes(t)};function Xn(t){if(t.length!==2)return!1;if(!t.every(it))return!1;return ma.some(([a,r])=>a===t[0]&&r===t[1])}var Qn=(t)=>{if(t.length!==3)return!1;if(!t.every(it))return!1;return ya.some(([a,r,n])=>a===t[0]&&r===t[1]&&n===t[2])},Wn=(t)=>{if(t.length!==4)return!1;if(!t.every(it))return!1;return Sa.some(([a,r,n,e])=>a===t[0]&&r===t[1]&&n===t[2]&&e===t[3])},gn=(t)=>{if(t.length!==6)return!1;if(!t.every(it))return!1;return Da.some(([a,r,n,e,c,o])=>a===t[0]&&r===t[1]&&n===t[2]&&e===t[3]&&c===t[4]&&o===t[5])};var Ln=(t,a)=>{let r=a===$&&t.type==="EUROPEAN",n=a===z&&t.type==="AMERICAN";if(!r&&!n)throw u.createValidationError(`Attempted to play ${t.type} roulette on edge ${a}`)},ha=(t,a)=>{if(Ln(t,a),t.type==="EUROPEAN")Ut(t.inputs);else Zt(t.inputs)};var Fr={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Jr=[3,6,9,12,15,18,21,24,27,30,33,36],Yr=[2,5,8,11,14,17,20,23,26,29,32,35],$r=[1,4,7,10,13,16,19,22,25,28,31,34],zr=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],qr=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];class Ca extends B{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),n=r.value,e=this.determineBetOutcomes(a,n),{payoutMultiplier:c,payout:o}=this.getPayoutDetails(a,n);return{outputs:{betOutcomes:e,result:r.values},payout:o,payoutMultiplier:c,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.getBetTotals(t),n=this.calculateTotalBetAmount(r),e={legs:this.calculatePayoutLegs(t,a)},c=T(e);return{payoutMultiplier:n.gt(0)?c.div(n):new ut.Big(0),payout:e}}determineBetOutcomes(t,a){let r={},n={};for(let e of Object.keys(t)){let c=t[e],o=this.betPredicates[e],{winning:i,losing:l}=this.partitionBets(c,o,a);r[e]=i,n[e]=l}return{winningBets:r,losingBets:n}}calculateTotalAmount(t){return t.reduce((a,r)=>a.plus(r.amount),new ut.Big(0))}isWinningStraightBet(t,a){return t.value===a}isWinningSplitBet(t,a){return t.values.some((r)=>r===a)}isWinningStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningCornerBet(t,a){return t.values.some((r)=>r===a)}isWinningDoubleStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningColorBet(t,a){let r=t;return zr.includes(a)&&r.color==="RED"||qr.includes(a)&&r.color==="BLACK"}isWinningHalfBet(t,a){let r=t;if(a>0&&a<=18&&r.half==="LOW")return!0;if(a>18&&a<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(t,a){let r=t;return Jr.includes(a)&&r.column==="TOP"||Yr.includes(a)&&r.column==="MIDDLE"||$r.includes(a)&&r.column==="BOTTOM"}isWinningDozenBet(t,a){let r=t;if(a>0&&a<=12&&r.dozen==="FIRST")return!0;if(a>12&&a<=24&&r.dozen==="SECOND")return!0;if(a>24&&a<=36&&r.dozen==="THIRD")return!0;return!1}isWinningParityBet(t,a){let r=t;if(a===0||a===37)return!1;let n=a%2===0?"EVEN":"ODD";return r.parity===n}getBetTotals(t){let a={};for(let r of Object.keys(t))a[r]=this.calculateTotalAmount(t[r]);return a}calculateTotalBetAmount(t){return Object.values(t).reduce((a,r)=>a.plus(r),new ut.Big(0))}partitionBets(t,a,r){return{winning:t.filter((n)=>a(n,r)),losing:t.filter((n)=>!a(n,r))}}calculatePayoutLegs(t,a){return Object.keys(t).flatMap((r)=>{let n=Fr[r],e=this.betPredicates[r];return t[r].map((c)=>{if(!e(c,a))return{amount:new ut.Big("0")};return{amount:c.amount.mul(n||0)}})})}}class xa extends Ca{maxNumber=36;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[$]}validateInputs(t){Ut(t)}}class Pa extends Ca{maxNumber=37;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,basketBets:this.isWinningBasketBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[z]}validateInputs(t){Zt(t)}isWinningBasketBet(t,a){return Oa.some((r)=>r===a)}}class ba extends B{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new xa,this.americanGame=new Pa}get supportedEdgeConfigurations(){return[$,z]}getBetAmount(t){switch(t.type){case"AMERICAN":return this.americanGame.getBetAmount(t.inputs);case"EUROPEAN":return this.europeanGame.getBetAmount(t.inputs);default:throw new Error("Unhandled roulette type")}}determineGameResult(t){let{gameInputs:a,...r}=t;if(ha(a,t.edge),a.type==="EUROPEAN"){let c=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:o}=c.outputs;return{...c,outputs:{type:"european",betOutcomes:o,result:c.outputs.result}}}let n=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:e}=n.outputs;return{...n,outputs:{type:"american",betOutcomes:e,result:n.outputs.result}}}}var Kn=(t)=>{return new ba().getBetAmount(t)};var Wr=require("big.js");var q;((n)=>{n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(q||={});var X;((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"})(X||={});var vn={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}}},te={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}}},ae={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}}},re={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}}},ne={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}}},Xr=new j(new Map([[1,vn],[2,te],[3,ae],[4,re],[8,ne]]));var Qr={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 gr extends B{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(X).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(q).includes(a.riskLevel))throw new Error("Invalid risk level");let e=Xr.getMultipliers(r)[a.riskLevel];if(e===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let c=e[a.segments];if(c===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let o=Qr[a.riskLevel];if(o===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let i=o[a.segments];if(i===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let l=t.getRandomInt({min:0,max:i.length-1}),d=i[l.value];if(d===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${l.value}`);let A=c[d];if(A===void 0)throw new Error(`No payout found for picked segment ${d}`);let s=new Wr.Big(A);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:l.values},randomValues:l}}}
package/dist/index.d.ts CHANGED
@@ -333,9 +333,8 @@ export declare const DEALER_STAND_VALUE = 17;
333
333
  export declare const BUST_VALUE = 21;
334
334
  export declare const BLACKJACK_VALUE = 21;
335
335
  export declare const MAX_CARDS_PER_ROUND = 63;
336
- export declare const INSURANCE_BET_MULTIPLIER = 1.5;
337
336
  export declare const INSURANCE_BET_SIZE_FACTOR = 0.5;
338
- export declare const INSURANCE_WIN_PAYOUT = 1.5;
337
+ export declare const INSURANCE_WIN_MULTIPLIER = 3;
339
338
  export declare const DOUBLE_DOWN_BET_SIZE_FACTOR = 1;
340
339
  export declare const SPLIT_BET_SIZE_FACTOR = 1;
341
340
  export declare const CARDS_PER_SUIT = 13;
@@ -576,9 +575,11 @@ export type BlackjackInternalSplitFinishedState = BaseFinishedState & {
576
575
  readonly sideBetResults: SideBetResults;
577
576
  };
578
577
  export type BlackjackInternalState = BlackjackInternalUninitialisedState | BlackjackInternalAwaitingInsuranceState | BlackjackInternalInProgressState | BlackjackInternalPlayingMainHandState | BlackjackInternalPlayingSplitHandState | BlackjackInternalFinishedState | BlackjackInternalSplitFinishedState;
578
+ export type RoundInsuranceStake = (unroundedStake: Big$1) => Big$1;
579
579
  export type BlackjackGameContext = GameContext<BlackjackAction, BlackjackState, BlackjackConfig>;
580
580
  export declare class Blackjack extends MultiActionGame<BlackjackInternalState, BlackjackState, BlackjackAction, BlackjackConfig> {
581
- constructor(edge: number);
581
+ private readonly roundInsuranceStake;
582
+ constructor(edge: number, roundInsuranceStake?: RoundInsuranceStake);
582
583
  get supportedEdgeConfigurations(): [
583
584
  number,
584
585
  ...number[]
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var qa;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(qa||={});class l extends Error{static createUnsupportedEdgeError(t){return new l("UNSUPPORTED_EDGE",t)}static createValidationError(t){return new l("INPUT_VALIDATION_ERROR",t)}static isGameError(t){return t instanceof l}errorCode;constructor(t,a){super(a);this.errorCode=t}}var f;((p)=>{p.DICE="DICE";p.MINES="MINES";p.KENO="KENO";p.LIMBO="LIMBO";p.ADVANCED_DICE="ADVANCED_DICE";p.BACCARAT="BACCARAT";p.DIAMONDS="DIAMONDS";p.PLINKO="PLINKO";p.ROULETTE="ROULETTE";p.WHEEL="WHEEL";p.BLACKJACK="BLACKJACK";p.BLITZ="BLITZ";p.DARTS="DARTS"})(f||={});import{Guard as Xa}from"@betorigami/guard";class B{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return Xa.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}import{Big as $t}from"big.js";import pt from"big.js";class h{static withMultiplier(t,a){return new pt(t).times(new pt(100-a).div(100))}static withWinChance(t,a){return pt(100-t).div(a)}}var tt=0,at=1e4,Yt=at-tt+1,Qa=0.01,Wa=98,ga=(t)=>{if(t<tt)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${tt}`)},La=(t)=>{if(t>at)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${at}`)},v=(t)=>{if(ga(t.lower),La(t.upper),t.lower>=t.upper)throw l.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},Ka=(t,a)=>{let[r,o]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>o.lower)throw l.createValidationError("Bounds must not overlap")},va=(t,a)=>a>=t.lower&&a<=t.upper,tr=(t)=>t.upper-t.lower+1,Bt=(t,a)=>a>t.lower&&a<t.upper,mt=(t)=>t.upper-t.lower-1,ar;((o)=>{o.ROLL_BETWEEN="ROLL_BETWEEN";o.ROLL_OUTSIDE="ROLL_OUTSIDE";o.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(ar||={});var zt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return v(t.bounds),mt(t.bounds);case"ROLL_OUTSIDE":return v(t.bounds),Yt-tr(t.bounds);case"ROLL_BETWEEN_TWO":return v(t.firstBounds),v(t.secondBounds),Ka(t.firstBounds,t.secondBounds),mt(t.firstBounds)+mt(t.secondBounds)}})(),o=$t(r).div(Yt).mul(100);if(o.lt(Qa))throw l.createValidationError("Win chance too low");if(o.gt(Wa))throw l.createValidationError("Win chance too high");return o},vo=(t)=>{zt(t)};class rr extends B{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let o=zt(r),n=t.getRandomInt({min:tt,max:at}),e=n.value,i=(()=>{switch(r.mode){case"ROLL_BETWEEN":return Bt(r.bounds,e);case"ROLL_OUTSIDE":return!va(r.bounds,e);case"ROLL_BETWEEN_TWO":return Bt(r.firstBounds,e)||Bt(r.secondBounds,e)}})()?h.withWinChance(a,o):new $t(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:n.values},randomValues:n}}}import nt from"big.js";import{Guard as yt}from"@betorigami/guard";var qt=0,Xt=51,rt=Array.from({length:52},(t,a)=>a),Qt=["Spades","Hearts","Diamonds","Clubs"],ot=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Wt=["Jack","Queen","King"],Et={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};class j{value;constructor(t){let a=rt[t];yt.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=Qt[t];return yt.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=ot[t];return yt.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}import or from"big.js";var T=(t)=>t.legs.reduce((a,r)=>a.add(r.amount),new or("0"));var mn=["Clubs","Diamonds","Hearts","Spades"],En=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],nr={Ace:"Ace",Two:"2",Three:"3",Four:"4",Five:"5",Six:"6",Seven:"7",Eight:"8",Nine:"9",Ten:"10",Jack:"Jack",Queen:"Queen",King:"King"},er;((o)=>{o.PLAYER_WIN="PLAYER_WIN";o.TIE="TIE";o.BANKER_WIN="BANKER_WIN"})(er||={});var cr;((o)=>{o.PLAYER="PLAYER";o.TIE="TIE";o.BANKER="BANKER"})(cr||={});var ir={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},gt=(t)=>{return new nt(0).add(t.bets.reduce((r,o)=>r.add(o.amount),new nt(0)))},lr=(t,a)=>t==="TIE"&&(a==="PLAYER"||a==="BANKER");class dr extends B{constructor(){super("BACCARAT")}get supportedEdgeConfigurations(){return[1]}getBetAmount(t){return gt(t)}determineGameResult({generator:t,gameInputs:a}){this.validateGameInputs(a);let r=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),o=r.values,n=o.slice(0,3),e=o.slice(3,6),c=[],i=0;for(let S of n.slice(0,2)){let b=this.mapRandomValueToCard(S),K=this.mapRandomValueToCardValue(S);c.push(b),i=(i+K)%10}let u=[],d=0;for(let S of e.slice(0,2)){let b=this.mapRandomValueToCard(S),K=this.mapRandomValueToCardValue(S);u.push(b),d=(d+K)%10}if(!this.isNaturalWin(i,d)){let S=this.shouldDrawThirdPlayerCard(i),b=null;if(S)b=this.mapRandomValueToCardValue(n[2]),c.push(this.mapRandomValueToCard(n[2])),i=(i+b)%10;if(this.shouldDrawThirdBankerCard(d,b))u.push(this.mapRandomValueToCard(e[2])),d=(d+this.mapRandomValueToCardValue(e[2]))%10}let s;if(i===d)s="TIE";else s=i>d?"PLAYER_WIN":"BANKER_WIN";let A=gt(a),{betType:m,multiplier:p}=ir[s],Jt={legs:a.bets.map((S)=>{if(S.type===m)return{amount:S.amount.mul(p)};return{amount:lr(s,S.type)?S.amount:new nt("0")}})},$a=T(Jt),za=A.gt(0)?$a.div(A):new nt(0);return{isFinished:!0,payout:Jt,payoutMultiplier:za,outputs:{playerCards:c,playerHandValue:i,bankerCards:u,bankerHandValue:d,gameOutcome:s,result:r.values},randomValues:r}}validateGameInputs(t){if(t.bets.length===0)throw new Error("Must place at least a single bet.");if(!t.bets.every((a)=>a.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(t){let a=new j(t);return{suit:a.suit,rank:nr[a.rank]}}isNaturalWin(t,a){let r=[8,9];return r.includes(t)||r.includes(a)}mapRandomValueToCardValue(t){let a=t%13;if(a===0)return 1;if(a>=10)return 10;return a+1}shouldDrawThirdPlayerCard(t){return t<=5}shouldDrawThirdBankerCard(t,a){if(a===null)return t<=5;if(t<=2)return!0;if(t===3)return a!==8;if(t===4)return[2,3,4,5,6,7].includes(a);if(t===5)return[4,5,6,7].includes(a);if(t===6)return[6,7].includes(a);return!1}}var ft;((n)=>{n.WIN="WIN";n.LOSE="LOSE";n.PUSH="PUSH";n.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(ft||={});var Ot;((r)=>{r.WON="WON";r.LOST="LOST"})(Ot||={});var St;((i)=>{i.START="START";i.HIT="BLACKJACK_HIT";i.STAND="BLACKJACK_STAND";i.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";i.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";i.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";i.SPLIT="BLACKJACK_SPLIT"})(St||={});var Ht;((n)=>{n.EXACT_PAIR="EXACT_PAIR";n.COLORED_PAIR="COLORED_PAIR";n.MIXED_PAIR="MIXED_PAIR";n.LOSS="LOSS"})(Ht||={});var Dt;((c)=>{c.SUITED_TRIPS="SUITED_TRIPS";c.STRAIGHT_FLUSH="STRAIGHT_FLUSH";c.THREE_OF_A_KIND="THREE_OF_A_KIND";c.STRAIGHT="STRAIGHT";c.FLUSH="FLUSH";c.LOSS="LOSS"})(Dt||={});var ur=2.5,sr=2,Ar=1,pr=0,Lt=17,ht=21,D=21,Ct=63,Dn=1.5,M=0.5,xt=1.5,R=1,w=1,hn=13,Pt=10,Kt=10,et={PLAYER_BLACKJACK:ur,WIN:sr,PUSH:Ar,LOSE:pr},vt={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},ta={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};import N from"big.js";import{Guard as E}from"@betorigami/guard";import{createStore as Or}from"@xstate/store";import{Guard as Br}from"@betorigami/guard";class y extends j{get numericRank(){if(Wt.includes(this.rank))return Kt;return ot.indexOf(this.rank)+1}static fromValue(t){return Br.against(!rt.includes(t),`Invalid card value: ${t}`),new y(t)}}class F{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,o)=>r+o.numericRank,0),t.some((r)=>r.rank==="Ace")&&this.hardHandValue+Pt<=ht)this.softHandValue=this.hardHandValue+Pt}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>ht}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===D}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class J{cards;value;constructor(t){this.cards=t.map((a)=>y.fromValue(a)),this.value=new F(this.cards)}get isBusted(){return this.value.isBusted}get isBlackjack(){return this.value.isBlackjack}get highestHandValue(){return this.value.highestHandValue}get rawValues(){return this.cards.map((t)=>t.value)}toDto(){return{cards:this.cards.map((t)=>t.toDto()),value:this.highestHandValue}}}class Y extends J{otherCards;upCard;holeCard;constructor(t,a,r=[]){super([t,a,...r]);this.otherCards=r;this.upCard=y.fromValue(t),this.holeCard=y.fromValue(a)}static withInitialDeal(t){return new Y(t.upCard,t.holeCard)}addDrawnCards(t){return new Y(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new F([this.upCard]).highestHandValue}}}class _ extends J{static withInitialDeal(t){return new _(t)}addDrawnCards(t){return new _([...this.rawValues,...t])}}import{Guard as ct}from"@betorigami/guard";class it{source;index=0;constructor(t){this.source=t}static from(t,a){return ct.against(a<=0,`Count must be positive, got ${a}`),ct.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new it(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return ct.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){ct.against(this.index+t>this.source.values.length,`RandomValuePool exhausted: requested ${t} but only ${this.source.values.length-this.index} remain`);let a=this.source.values.slice(this.index,this.index+t);return this.index+=t,a}}import{Guard as aa}from"@betorigami/guard";import mr from"fast-deep-equal";class bt{gameId;edge;constructor(t,a){this.gameId=t;this.edge=a;this.validateEdge(a)}play(t,a,r=[]){let o=this.createGameStore(),n=this.generateRandomValues(t),e=n.toMultipleRandomValues();for(let u of r)o.send({...u.playerArgument,randomValuePool:n});let c=r[r.length-1];if(c)aa.against(!mr(c.state,this.toExternalState(o.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");o.send({...a,randomValuePool:n});let i=o.getSnapshot().context;return{playerArgument:i.playerArgument,state:this.toExternalState(i.state),config:i.config,additionalBetAmount:i.additionalBetAmount,proof:{proofHash:e.proofHash,proofString:e.proofString}}}validateEdge(t){let a=this.supportedEdgeConfigurations.includes(t);aa.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}}import C from"big.js";import{Guard as jt}from"@betorigami/guard";var ra=(t)=>{let a=t.pairBonus!==null?{amount:C(t.pairBonus.betAmount).mul(t.pairBonus.payoutMultiplier)}:null,r=t.threeCardBonus!==null?{amount:C(t.threeCardBonus.betAmount).mul(t.threeCardBonus.payoutMultiplier)}:null;return[a,r].filter((o)=>o!==null)},oa=(t)=>{let a=t.betAmounts.mainBetAmount,o=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(R):C(0),n=t.insuranceOutcome!==void 0?a.mul(M):C(0),e=a.plus(o).mul(et[t.outcome]),c=t.insuranceOutcome==="WON"?a.mul(xt):C(0),i=ra(t.sideBetResults),u=[{amount:e},...t.insuranceOutcome!==void 0?[{amount:c}]:[],...i],d=T({legs:u}),s=a.plus(n).plus(o).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);jt.against(s.eq(0),"Total bet amount cannot be zero");let A=d.div(s);jt.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let m;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":m=o;break;case"BLACKJACK_BUY_INSURANCE":m=n;break;case"BLACKJACK_SPLIT":m=a.mul(w);break}return{payouts:u,totalBetAmount:s,multiplier:A,additionalBetAmount:m}},na=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(R):C(0),o=t.splitHandDoubledDown?a.mul(R):C(0),n=t.insuranceOutcome!==void 0?a.mul(M):C(0),e=a.plus(r).mul(et[t.mainOutcome]),c=a.plus(o).mul(et[t.splitOutcome]),i=t.insuranceOutcome==="WON"?a.mul(xt):C(0),u=ra(t.sideBetResults),d=[{amount:e},{amount:c},...t.insuranceOutcome!==void 0?[{amount:i}]:[],...u],s=T({legs:d}),A=a.plus(a).plus(n).plus(r).plus(o).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);jt.against(A.eq(0),"Total bet amount cannot be zero");let m=s.div(A),p;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":p=a.mul(R);break;case"BLACKJACK_SPLIT":p=a.mul(w);break}return{payouts:d,totalBetAmount:A,multiplier:m,additionalBetAmount:p}};import{Guard as Er}from"@betorigami/guard";var Tt=(t)=>t.every((a)=>a===t[0]),ea=(t)=>{let a=[...t].sort((r,o)=>r-o);return a.every((r,o)=>{let n=a[o-1];if(o===0)return!0;return Er.againstUndefined(n,"Previous value cannot be undefined"),r===n+1})},ca={Ace:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9,Ten:10,Jack:11,Queen:12,King:13},yr={...ca,Ace:14},fr=(t)=>ea(t.map((a)=>ca[a]))||ea(t.map((a)=>yr[a])),ia=(t,a)=>{let r=y.fromValue(t),o=y.fromValue(a);if(r.rank!==o.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(Et[r.suit]===Et[o.suit])return"COLORED_PAIR";return"MIXED_PAIR"},la=(t,a)=>({betAmount:t,result:a,payoutMultiplier:vt[a]}),da=(t,a,r)=>{let o=y.fromValue(t),n=y.fromValue(a),e=y.fromValue(r),c=[o.rank,n.rank,e.rank],i=Tt([o.suit,n.suit,e.suit]),u=Tt(c),d=fr(c);if(Tt([t,a,r]))return"SUITED_TRIPS";if(i&&d)return"STRAIGHT_FLUSH";if(u)return"THREE_OF_A_KIND";if(d)return"STRAIGHT";if(i)return"FLUSH";return"LOSS"},ua=(t,a)=>({betAmount:t,result:a,payoutMultiplier:ta[a]});var Sr={state:{isFinished:!1,phase:"uninitialised",multiplier:N(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},O=(t)=>y.fromValue(t).value;function Hr(t){E.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function sa(t){E.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function Rt(t){E.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var Aa=(t,a)=>{let r=a;while(r.highestHandValue<Lt)r=r.addDrawnCards([O(t.takeOne())]);return r},Nt=(t,a)=>{if(t.isBusted)return"LOSE";if(a.isBusted)return"WIN";let r=t.highestHandValue,o=a.highestHandValue;if(r>o)return"WIN";if(r<o)return"LOSE";return"PUSH"},H=(t)=>{let{payouts:a,multiplier:r,additionalBetAmount:o}=oa({outcome:t.outcome,insuranceOutcome:t.insuranceOutcome,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"finished",playerHand:t.playerHand,dealerHand:t.dealerHand,outcome:t.outcome,payout:{legs:a},multiplier:r,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:o}},_t=(t)=>{let a=Aa(t.randomValuePool,t.dealerHand),r=Nt(t.playerHand,a);return H({...t,dealerHand:a,outcome:r})},P=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:Aa(t.randomValuePool,t.dealerHand),o=Nt(t.mainHand,r),n=Nt(t.splitHand,r),{payouts:e,multiplier:c,additionalBetAmount:i}=na({hasSplit:!0,mainOutcome:o,splitOutcome:n,insuranceOutcome:t.insuranceOutcome,mainHandDoubledDown:t.mainHandDoubledDown,splitHandDoubledDown:t.splitHandDoubledDown,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"split-finished",mainHand:t.mainHand,splitHand:t.splitHand,dealerHand:r,mainOutcome:o,splitOutcome:n,payout:{legs:e},multiplier:c,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:i}};class Dr extends bt{constructor(t){super("BLACKJACK",t)}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return it.from(t.getRandomIntsWithReplacement({min:qt,max:Xt,count:Ct}),Ct)}toExternalState(t){let a=t.phase;switch(a){case"awaiting-insurance":return{isFinished:!1,phase:"awaiting-insurance",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"in-progress":return{isFinished:!1,phase:"player-turn",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-main-hand":return{isFinished:!1,phase:"playing-main-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-split-hand":return{isFinished:!1,phase:"playing-split-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"finished":return{isFinished:!0,payout:t.payout,multiplier:t.multiplier,randomValues:t.randomValues,outcome:t.outcome,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"split-finished":return{isFinished:!0,payout:t.payout,multiplier:t.multiplier,randomValues:t.randomValues,mainOutcome:t.mainOutcome,splitOutcome:t.splitOutcome,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"uninitialised":throw new Error("Cannot convert uninitialised state to external state");default:E.againstNever(a,"Invalid state received")}}createGameStore(){return Or({context:Sr,on:{START:(t,a)=>{let{state:r}=t;E.against(r.phase!=="uninitialised","START action requires a fresh game");let o=O(a.randomValuePool.takeOne()),n=O(a.randomValuePool.takeOne()),e=O(a.randomValuePool.takeOne()),c=O(a.randomValuePool.takeOne()),i=_.withInitialDeal([o,n]),u=Y.withInitialDeal({upCard:e,holeCard:c}),d={mainBetAmount:N(a.mainBetAmount),pairBonusAmount:N(a.pairBonusAmount),threeCardBonusAmount:N(a.threeCardBonusAmount)},s={pairBonus:N(a.pairBonusAmount).gt(0)?la(a.pairBonusAmount,ia(o,n)):null,threeCardBonus:N(a.threeCardBonusAmount).gt(0)?ua(a.threeCardBonusAmount,da(o,n,e)):null},A={type:"START",mainBetAmount:a.mainBetAmount,pairBonusAmount:a.pairBonusAmount,threeCardBonusAmount:a.threeCardBonusAmount};if(u.upCard.rank==="Ace")return{state:{...r,isFinished:!1,phase:"awaiting-insurance",playerHand:i,dealerHand:u,betAmounts:d,sideBetResults:s},config:{},playerArgument:A};let m={playerHand:i,dealerHand:u,randomValuePool:a.randomValuePool,playerArgument:A,betAmounts:d,sideBetResults:s};if(i.isBlackjack&&u.isBlackjack)return H({...m,outcome:"PUSH"});if(i.isBlackjack)return H({...m,outcome:"PLAYER_BLACKJACK"});if(u.isBlackjack)return H({...m,outcome:"LOSE"});return{state:{...r,isFinished:!1,phase:"in-progress",playerHand:i,dealerHand:u,insuranceOutcome:void 0,betAmounts:d,sideBetResults:s},config:{},playerArgument:A}},BLACKJACK_BUY_INSURANCE:(t,a)=>{let{state:r}=t;sa(r);let{playerHand:o,dealerHand:n,betAmounts:e,sideBetResults:c}=r,i={...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:e,sideBetResults:c};if(o.isBlackjack&&n.isBlackjack)return H({...i,outcome:"PUSH",insuranceOutcome:"WON"});if(o.isBlackjack)return H({...i,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(n.isBlackjack)return H({...i,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...r,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:e.mainBetAmount.mul(M)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;sa(r);let{playerHand:o,dealerHand:n,betAmounts:e,sideBetResults:c}=r,i={playerHand:o,dealerHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:e,sideBetResults:c};if(o.isBlackjack&&n.isBlackjack)return H({...i,outcome:"PUSH"});if(o.isBlackjack)return H({...i,outcome:"PLAYER_BLACKJACK"});if(n.isBlackjack)return H({...i,outcome:"LOSE"});return{state:{...r,phase:"in-progress",insuranceOutcome:void 0},config:{},playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"}}},BLACKJACK_HIT:(t,a)=>{let{state:r}=t;switch(Rt(r),r.phase){case"playing-main-hand":{let o=r.mainHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(o.isBusted||o.highestHandValue===D){if(r.splitHand.highestHandValue===D)return P({...r,mainHand:o,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"playing-split-hand",mainHand:o,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...r,mainHand:o},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let o=r.splitHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(o.isBusted||o.highestHandValue===D)return P({...r,splitHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,splitHand:o},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let o=r.playerHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(o.isBusted)return H({...r,playerHand:o,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(o.highestHandValue===D)return _t({...r,playerHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"in-progress",playerHand:o},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:E.againstNever(r,"Invalid phase for HIT action")}},BLACKJACK_STAND:(t,a)=>{let{state:r}=t;switch(Rt(r),r.phase){case"playing-main-hand":{if(r.splitHand.highestHandValue===D)return P({...r,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});return{state:{...r,phase:"playing-split-hand",splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_STAND"}}}case"playing-split-hand":return P({...r,splitHandDoubledDown:r.splitHandDoubledDown,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});case"in-progress":return _t({...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});default:E.againstNever(r,"Invalid phase for STAND action")}},BLACKJACK_DOUBLE_DOWN:(t,a)=>{let{state:r}=t;switch(Rt(r),r.phase){case"playing-main-hand":{E.against(r.mainHand.cards.length!==2,"Double down is only allowed as the first action");let o=r.mainHand.addDrawnCards([O(a.randomValuePool.takeOne())]),{betAmounts:n}=r;if(r.splitHand.highestHandValue===D)return P({...r,mainHand:o,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...r,phase:"playing-split-hand",mainHand:o,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:n.mainBetAmount.mul(R)}}case"playing-split-hand":{E.against(r.splitHand.cards.length!==2,"Double down is only allowed as the first action");let o=r.splitHand.addDrawnCards([O(a.randomValuePool.takeOne())]);return P({...r,splitHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{E.against(r.playerHand.cards.length!==2,"Double down is only allowed as the first action");let o=r.playerHand.addDrawnCards([O(a.randomValuePool.takeOne())]);if(o.isBusted)return H({...r,playerHand:o,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return _t({...r,playerHand:o,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:E.againstNever(r,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(t,a)=>{let{state:r}=t;Hr(r);let{playerHand:o,betAmounts:n,sideBetResults:e}=r;E.against(o.cards.length!==2,"Split is only allowed with exactly 2 cards");let c=o.cards[0],i=o.cards[1];E.againstUndefined(c,"First card is missing"),E.againstUndefined(i,"Second card is missing"),E.against(c.rank!==i.rank,"Split requires two cards of the same rank");let u=O(a.randomValuePool.takeOne()),d=O(a.randomValuePool.takeOne()),s=_.withInitialDeal([c.value,u]),A=_.withInitialDeal([i.value,d]);if(c.rank==="Ace")return P({...r,mainHand:s,splitHand:A,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let p=s.highestHandValue===D,Ft=A.highestHandValue===D;if(p&&Ft)return P({mainHand:s,splitHand:A,dealerHand:r.dealerHand,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:r.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:n,sideBetResults:e});if(p)return{state:{...r,phase:"playing-split-hand",mainHand:s,splitHand:A,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(w)};return{state:{...r,phase:"playing-main-hand",multiplier:N(0),mainHand:s,splitHand:A,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(w)}}}})}getValidNextActionTypes(t){if(t.isFinished)return[];switch(t.phase){case"awaiting-insurance":return["BLACKJACK_BUY_INSURANCE","BLACKJACK_REJECT_INSURANCE"];case"playing-main-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.mainHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"playing-split-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.splitHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"player-turn":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.playerHand.cards.length===2){a.push("BLACKJACK_DOUBLE_DOWN");let r=t.playerHand.cards[0],o=t.playerHand.cards[1];if(E.againstUndefined(r,"First player card is missing"),E.againstUndefined(o,"Second player card is missing"),r.rank===o.rank)a.push("BLACKJACK_SPLIT")}return a}default:E.againstNever(t,"Invalid phase for getting valid actions")}}}import z from"big.js";import{Guard as Ea}from"@betorigami/guard";var pa=0,Ba=51,$=52,ma=52;var Ne=()=>({minPicks:5,maxPicks:36}),hr=(t)=>t.length===new Set(t).size,Cr=(t)=>{let a=z(1),r=z($);for(let o=0;o<t;o+=1)a=a.mul(z($-o).div(r));return a};class xr extends B{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){Ea.against(a.pickCount<1||a.pickCount>$,`pickCount must be between 1 and ${$}`),Ea.againstNonInteger(a.pickCount,"pickCount must be an integer");let o=t.getRandomIntsWithReplacement({min:pa,max:Ba,count:ma}),n=o.values.slice(0,a.pickCount),e=hr(n),c=Cr(a.pickCount),i=e?h.withMultiplier(z(1).div(c),r):z(0);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:o.values,cards:n.map((u)=>new j(u).toDto())},randomValues:o}}}var ya=0,wt=4294967295,fa;((n)=>{n.EASY="EASY";n.MEDIUM="MEDIUM";n.HARD="HARD";n.EXPERT="EXPERT"})(fa||={});var Pr=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],br={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:0.5,ringTwo:0.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:0.5},segments:Pr},jr=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Tr={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:0.4,ringTwo:0.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:0.4},segments:jr},Rr=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],_r={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:0.2,ringTwo:0.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:0.2},segments:Rr},Nr=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],wr={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:0.1,ringTwo:0.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:0.1},segments:Nr},Ge=(t)=>{let a=Vt[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((o,n)=>n>o?n:o)},Vt={EASY:br,MEDIUM:Tr,HARD:_r,EXPERT:wr};import{Guard as Ut}from"@betorigami/guard";import Vr from"big.js";class Ur extends B{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:ya,max:wt,count:2}),o=r.values[0],n=r.values[1];Ut.againstUndefined(o,"Random number generator returned no value for clockWiseRotation"),Ut.againstUndefined(n,"Random number generator returned no value for distanceFromCentre");let e=a.difficultyLevel,c=Vr(Ir(e,o,n));return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:r.values},randomValues:r}}}var Ir=(t,a,r)=>{let o=Vt[t],{distanceBoundaries:n,multipliers:e}=o;if(r<n.bullseye)return e.bullseye;if(r<n.ringOne)return e.ringOne;if(r<n.ringTwo)return e.ringTwo;if(r<n.ringThree)return Zr(o,a);return e.ringFour},Zr=(t,a)=>{let r=t.segments.length,o=Math.floor(a/(wt+1)*r),n=t.segments[o];return Ut.againstUndefined(n,`Segment index ${o} out of bounds`),t.multipliers.ringThree[n]};import kr from"big.js";class x{multipliers;constructor(t){this.multipliers=t}getMultipliers(t){let a=this.multipliers.get(t);if(a===void 0)throw new Error(`Multipliers for ${t} not found`);return a}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([t,a])=>({edge:t,multipliers:a}))}}var Gr;((c)=>{c.PAIR="PAIR";c.TWO_PAIR="TWO_PAIR";c.THREE_OF_A_KIND="THREE_OF_A_KIND";c.FULL_HOUSE="FULL_HOUSE";c.FOUR_OF_A_KIND="FOUR_OF_A_KIND";c.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(Gr||={});var Mr={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},Fr={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},Jr={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},Yr={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},$r={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 x(new Map([[1,Mr],[2,Fr],[3,Jr],[4,Yr],[8,$r]])),qr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Xr extends B{constructor(){super("DIAMONDS")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let o=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),n=zr.getMultipliers(a),e=o.values,c=kr(this.calculatePayoutMultiplier(n,e));return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:o.values},randomValues:o}}calculatePayoutMultiplier(t,a){let r=new Map;for(let e of a){let c=r.get(e)||0;r.set(e,c+1)}let o=[...r.values()].filter((e)=>e>1),n=this.classifyResult(o);return n===null?0:t[n]}classifyResult(t){if(t.length>2)throw new Error(`Unexpected number of repeats ${t.length}`);let[a,r]=t;if(a===void 0)return null;if(r===void 0){let o=qr[a];if(o===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return o}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}import Oa from"big.js";var Qr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Qr||={});var Sa=0,It=1e4,Wr=It-Sa+1,gr=(t)=>{let a=t.direction==="ABOVE"?It-t.selectedValue:t.selectedValue;return new Oa(a).div(Wr).mul(100)},Lr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class Kr extends B{constructor(){super("DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let o=t.getRandomInt({min:Sa,max:It}),n=gr(r),c=Lr(r,o.value)?h.withWinChance(a,n):new Oa(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:o.values},randomValues:o}}}import eo from"big.js";import{Guard as lt}from"@betorigami/guard";var Ha;((n)=>{n.CLASSIC="CLASSIC";n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(Ha||={});var vr=[1,2,3,4,5,6,7,8,9,10],Da=(t)=>{return vr.includes(t)};var to={[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]}},ao={[1]:{CLASSIC:[0,3.92],LOW_RISK:[0.7,1.82],MEDIUM_RISK:[0.4,2.72],HIGH_RISK:[0,3.92]},[2]:{CLASSIC:[0,1.9,4.32],LOW_RISK:[0,2,3.65],MEDIUM_RISK:[0,1.8,5],HIGH_RISK:[0,0,17]},[3]:{CLASSIC:[0,1,3,10.7],LOW_RISK:[0,1.1,1.3,26.2],MEDIUM_RISK:[0,0,2.7,50.3],HIGH_RISK:[0,0,0,80.7]},[4]:{CLASSIC:[0,0.8,1.8,4.75,22.5],LOW_RISK:[0,0,2.2,7.65,90],MEDIUM_RISK:[0,0,1.7,9.8,100],HIGH_RISK:[0,0,0,9.75,259]},[5]:{CLASSIC:[0,0.2,1.4,4.25,16.4,36],LOW_RISK:[0,0,1.5,4.1,12.9,300],MEDIUM_RISK:[0,0,1.4,3.9,13.9,390],HIGH_RISK:[0,0,0,4.5,47,450]},[6]:{CLASSIC:[0,0,1,3.6,7,17,40],LOW_RISK:[0,0,1.1,2,5.8,100,700],MEDIUM_RISK:[0,0,0,3,8.6,180,710],HIGH_RISK:[0,0,0,0,10.6,350,710]},[7]:{CLASSIC:[0,0,0.5,3,4.1,13.7,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,13.5,225,700],MEDIUM_RISK:[0,0,0,2,6.9,29.2,400,800],HIGH_RISK:[0,0,0,0,6.9,89.1,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,12.2,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,4.8,38,100,800],MEDIUM_RISK:[0,0,0,2,4,10.4,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.8,270,600,900]},[9]:{CLASSIC:[0,0,0,1.5,3,8.1,15,45,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.1,7.4,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1000],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.5,7.6,16,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.6,3.7,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1000]}},ro={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.7,1.78],MEDIUM_RISK:[0.4,2.68],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,2,3.48],MEDIUM_RISK:[0,1.8,4.8],HIGH_RISK:[0,0,16.8]},[3]:{CLASSIC:[0,1,3,9.9],LOW_RISK:[0,1.1,1.2,26.5],MEDIUM_RISK:[0,0,2.65,50],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.7,5,23],LOW_RISK:[0,0,2.1,7.95,90],MEDIUM_RISK:[0,0,1.7,9.55,100],HIGH_RISK:[0,0,0,9.5,259]},[5]:{CLASSIC:[0,0.2,1.4,4.1,16.6,36],LOW_RISK:[0,0,1.5,4,12.7,300],MEDIUM_RISK:[0,0,1.4,3.8,13.7,390],HIGH_RISK:[0,0,0,4.4,46.9,450]},[6]:{CLASSIC:[0,0,1,3.6,6.6,16.5,40],LOW_RISK:[0,0,1.1,1.9,5.9,100,700],MEDIUM_RISK:[0,0,0,2.9,8.7,180,710],HIGH_RISK:[0,0,0,0,10.8,342,710]},[7]:{CLASSIC:[0,0,0.5,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.1,1.6,3.1,14.8,225,700],MEDIUM_RISK:[0,0,0,2,6.7,29,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.8,12.7,21,54,70],LOW_RISK:[0,0,1.1,1.5,1.8,5.2,38,100,800],MEDIUM_RISK:[0,0,0,2,3.8,10.8,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.5,265,600,900]},[9]:{CLASSIC:[0,0,0,1.5,2.9,8.2,15,43,60,85],LOW_RISK:[0,0,1.1,1.3,1.6,2.1,7.7,49,250,1000],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.2,8,16.7,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.5,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1000]}},oo={[1]:{CLASSIC:[0,3.84],LOW_RISK:[0.69,1.77],MEDIUM_RISK:[0.38,2.7],HIGH_RISK:[0,3.84]},[2]:{CLASSIC:[0,1.83,4.44],LOW_RISK:[0,1.98,3.44],MEDIUM_RISK:[0,1.78,4.77],HIGH_RISK:[0,0,16.64]},[3]:{CLASSIC:[0,0.98,3,9.8],LOW_RISK:[0,1.09,1.19,26.15],MEDIUM_RISK:[0,0,2.6,49.8],HIGH_RISK:[0,0,0,79]},[4]:{CLASSIC:[0,0.79,1.68,5,22.7],LOW_RISK:[0,0,2.1,7.8,88.3],MEDIUM_RISK:[0,0,1.66,9.5,100],HIGH_RISK:[0,0,0,9.25,259]},[5]:{CLASSIC:[0,0.19,1.39,4.1,16.3,35.5],LOW_RISK:[0,0,1.47,4,12.5,300],MEDIUM_RISK:[0,0,1.37,3.8,13.5,390],HIGH_RISK:[0,0,0,4.3,46.6,450]},[6]:{CLASSIC:[0,0,0.98,3.6,6.5,15.9,39.9],LOW_RISK:[0,0,1.08,1.89,5.8,100,700],MEDIUM_RISK:[0,0,0,2.9,8.35,180,710],HIGH_RISK:[0,0,0,0,10.4,342,710]},[7]:{CLASSIC:[0,0,0.47,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.08,1.59,3.1,14.6,225,700],MEDIUM_RISK:[0,0,0,1.98,6.6,28.7,400,800],HIGH_RISK:[0,0,0,0,6.7,87.3,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.7,12.5,21,54,70],LOW_RISK:[0,0,1.09,1.49,1.77,5.1,37.5,100,800],MEDIUM_RISK:[0,0,0,1.96,3.8,10.7,65.8,400,900],HIGH_RISK:[0,0,0,0,4.9,18.8,265,600,900]},[9]:{CLASSIC:[0,0,0,1.47,2.9,8.1,14.9,43,60,85],LOW_RISK:[0,0,1.09,1.28,1.59,2.1,7.6,48.4,250,1000],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1000],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.2,7.8,16.5,49.2,80,100],LOW_RISK:[0,0,1.08,1.19,1.3,1.47,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1000]}},no={[1]:{CLASSIC:[0,3.68],LOW_RISK:[0.7,1.58],MEDIUM_RISK:[0.4,2.48],HIGH_RISK:[0,3.68]},[2]:{CLASSIC:[0,1.72,4.48],LOW_RISK:[0,1.9,3.28],MEDIUM_RISK:[0,1.7,4.62],HIGH_RISK:[0,0,15.95]},[3]:{CLASSIC:[0,0.9,2.95,9.9],LOW_RISK:[0,1,1.2,26],MEDIUM_RISK:[0,0,2.29,50],HIGH_RISK:[0,0,0,75.7]},[4]:{CLASSIC:[0,0.8,1.6,4.4,21],LOW_RISK:[0,0,2,7.5,86],MEDIUM_RISK:[0,0,1.5,9.5,98],HIGH_RISK:[0,0,0,9,246]},[5]:{CLASSIC:[0,0.2,1.2,4.2,16.3,37],LOW_RISK:[0,0,1.4,3.8,12,300],MEDIUM_RISK:[0,0,1.3,3.5,14,385],HIGH_RISK:[0,0,0,4,45,450]},[6]:{CLASSIC:[0,0,1,3.3,6.2,15,40],LOW_RISK:[0,0,1.1,1.7,4.9,99,700],MEDIUM_RISK:[0,0,0,2.6,8.5,177,705],HIGH_RISK:[0,0,0,0,10,327,710]},[7]:{CLASSIC:[0,0,0.4,2.8,4.2,14.5,30,60],LOW_RISK:[0,0,1.1,1.4,3,14,210,700],MEDIUM_RISK:[0,0,0,1.8,6.4,29,400,800],HIGH_RISK:[0,0,0,0,6.1,85,400,800]},[8]:{CLASSIC:[0,0,0,2,3.7,13,20,50,70],LOW_RISK:[0,0,1.1,1.4,1.6,4.6,35,90,800],MEDIUM_RISK:[0,0,0,1.9,3.5,10.5,65,400,900],HIGH_RISK:[0,0,0,0,4.5,18,265,600,900]},[9]:{CLASSIC:[0,0,0,1.4,2.6,9,11.5,40,60,85],LOW_RISK:[0,0,1,1.3,1.5,2,7,45,250,1000],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.3,2,4.4,8,16.7,50,80,100],LOW_RISK:[0,0,1,1.2,1.25,1.4,2,10,50,250,1000],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1000],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1000]}},ha=new x(new Map([[1,to],[2,ao],[3,ro],[4,oo],[8,no]]));class co extends B{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){lt.againstEmptyArray(r.selectedNumbers,()=>l.createValidationError("No numbers selected")),lt.against(r.selectedNumbers.length>10,()=>l.createValidationError("Maximum of 10 numbers can be selected"));for(let A of r.selectedNumbers)lt.againstNonInteger(A,()=>l.createValidationError("Only integers can be selected")),lt.against(A<0||A>39,()=>l.createValidationError("Invalid number selected"));let o=t.getUniqueRandomInts({min:0,max:39,count:10}),n=r.selectedNumbers.filter((A)=>o.values.includes(A)),e=r.selectedNumbers.length;if(!Da(e))throw new Error(`Invalid tile count: ${e}`);let d=ha.getMultipliers(a)[e][r.riskLevel][n.length];if(d===void 0)throw new Error(`No multiplier found for matching tile count ${n.length}`);let s=new eo(d);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:o.values},randomValues:o}}}import V from"big.js";var Ca=(t,a)=>{return t.gt(a)?t:a};var xa=(t,a)=>{return t.lt(a)?t:a};class io extends B{constructor(){super("LIMBO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let o=t.getRandomInt({min:1,max:4294967295}),n=o.max,e=new V(16777216),c=new V(1),i=new V(1e6),u=o.value,d=new V(u-1).div(n),s=(100-a)/100,A=e.div(d.mul(e).plus(1)).mul(s),m=Ca(c,xa(A,i)),p=m.gte(r.targetMultiplier)?new V(r.targetMultiplier):new V(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(p)}]},payoutMultiplier:p,outputs:{randomMultiplier:m,result:o.values},randomValues:o}}}import dt from"big.js";var Zt=(t,a)=>{if(a<0||t<0||a>t)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(a>t-a)a=t-a;let r=1;for(let o=1;o<=a;o++)r=r*(t-o+1)/o;return r};class lo extends B{constructor(){super("MINES")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){if(r.minesCount<=0||r.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(r.selectedTiles.length>25-r.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let c=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),i=c.values.some((p)=>r.selectedTiles.includes(p)),u=r.hasCashedOut||i,d=(100-a)/100,s=new dt(Zt(25-r.minesCount,r.selectedTiles.length)).div(new dt(Zt(25,r.selectedTiles.length))),m=r.hasCashedOut&&!i?new dt(d).div(s):new dt(0);return{isFinished:u,payout:{legs:[{amount:r.betAmount.mul(m)}]},payoutMultiplier:m,outputs:{result:c.values},randomValues:c}}}import{Big as mo}from"big.js";var Pa;((o)=>{o.LOW_RISK="LOW_RISK";o.MEDIUM_RISK="MEDIUM_RISK";o.HIGH_RISK="HIGH_RISK"})(Pa||={});var Lc=[8,9,10,11,12,13,14,15,16],uo={LOW_RISK:{8:[6,2.1,1.1,1,0.5,1,1.1,2.1,6],9:[6,2,1.6,1,0.7,0.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],16:[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:{8:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],9:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],10:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],11:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],12:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,0.3,0.2,0.3,1.5,4,29],9:[43,7,2,0.6,0.2,0.2,0.6,2,7,43],10:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76],11:[120,13.9,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,0.2,0.2,0.2,0.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,82.8,620],16:[1000,129.9,26.1,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26.1,129.9,1000]}},so={LOW_RISK:{8:[6,1.9,1.1,1,0.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,0.7,0.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,0.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,0.7,0.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,0.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,0.9,0.7,0.7,0.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,0.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,0.7,0.7,1,1.1,1.4,2,2.8,7.6,15],16:[16,9,1.7,1.2,1.3,1.2,1.1,1,0.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,0.6,0.4,0.6,1.4,3.2,13],9:[18,3.7,1.7,0.9,0.5,0.5,0.9,1.7,3.7,18],10:[22,5,1.9,1.4,0.6,0.4,0.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,0.7,0.5,0.5,0.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,0.6,0.3,0.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,0.5,0.2,0.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,0.5,0.3,0.3,0.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,0.5,0.3,0.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,0.3,0.2,0.3,1.5,3.8,29],9:[43,7.1,1.9,0.6,0.2,0.2,0.6,1.9,7.1,43],10:[76,9.9,2.9,0.9,0.3,0.2,0.3,0.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,0.4,0.2,0.2,0.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,0.7,0.2,0.2,0.2,0.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,0.2,0.2,0.2,0.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,0.3,0.2,0.2,0.2,0.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,0.5,0.2,0.2,0.2,0.2,0.5,3,7.7,26.8,82.3,620],16:[1000,129.8,25.2,8.6,4,2,0.2,0.2,0.2,0.2,0.2,2,4,8.6,25.2,129.8,1000]}},Ao={LOW_RISK:{8:[6,2.2,1.1,1,0.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,0.7,0.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,0.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,0.7,0.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,0.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,0.9,0.7,0.7,0.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,0.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,0.7,0.7,1,1.1,1.3,2,2.5,7.9,15],16:[16,8.9,1.9,1.4,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,0.7,0.3,0.7,1.2,3.5,13],9:[18,3.8,1.6,0.9,0.5,0.5,0.9,1.6,3.8,18],10:[22,5.2,2,1.3,0.6,0.4,0.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,0.7,0.5,0.5,0.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,0.6,0.3,0.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,0.5,0.2,0.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,0.5,0.3,0.3,0.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,0.5,0.3,0.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,0.3,0.2,0.3,1.4,4,29],9:[43,7.3,2,0.5,0.2,0.2,0.5,2,7.3,43],10:[76,9.8,2.8,0.9,0.3,0.2,0.3,0.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,0.4,0.2,0.2,0.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,0.2,0.2,0.2,0.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,0.5,0.2,0.2,0.2,0.2,0.5,2.9,7.7,26.6,81.9,620],16:[1000,130,24.9,8.4,3.9,2,0.2,0.2,0.2,0.2,0.2,2,3.9,8.4,24.9,130,1000]}},po={LOW_RISK:{8:[6,2,1.1,1,0.4,1,1.1,2,6],9:[6,1.9,1.4,1,0.7,0.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,0.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,0.7,0.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,0.9,0.6,0.6,0.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,0.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,0.6,0.6,1,1.2,1.4,2,2.9,8,15],16:[16,9.1,2.2,1.4,1.2,1.2,1.1,1,0.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,0.7,0.4,0.7,1.2,2.9,13],9:[18,3.5,1.6,0.9,0.5,0.5,0.9,1.6,3.5,18],10:[22,4.7,2,1.3,0.6,0.4,0.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,0.7,0.5,0.5,0.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,0.6,0.3,0.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,0.7,0.4,0.4,0.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,0.5,0.2,0.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,0.5,0.3,0.3,0.5,1.3,2.7,4.9,10.7,17.7,88],16:[110,39.7,9.6,4.8,2.8,1.4,1,0.5,0.3,0.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,0.3,0.2,0.3,1.4,3.9,29],9:[43,6.9,1.8,0.6,0.2,0.2,0.6,1.8,6.9,43],10:[76,9.8,2.7,0.9,0.3,0.2,0.3,0.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,0.4,0.2,0.2,0.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,0.2,0.2,0.2,0.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,0.5,0.2,0.2,0.2,0.2,0.5,2.8,7.8,26.1,80.6,620],16:[1000,129.7,24.7,8.2,3.8,2,0.2,0.2,0.2,0.2,0.2,2,3.8,8.2,24.7,129.7,1000]}},Bo={LOW_RISK:{8:[5,1.8,1,1,0.4,1,1,1.8,5],9:[5,1.7,1.2,1,0.7,0.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,0.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,0.7,0.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,0.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,0.9,0.6,0.6,0.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,0.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,0.6,0.6,1,1,1.4,1.9,2.9,7.3,15],16:[16,8.7,2,1.5,1.3,1,1.1,1,0.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,0.7,0.4,0.7,1.1,2.6,13],9:[17,3.3,1.4,0.9,0.5,0.5,0.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,0.6,0.4,0.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,0.7,0.5,0.5,0.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,0.6,0.2,0.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,0.7,0.4,0.4,0.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,0.5,0.2,0.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,0.5,0.3,0.3,0.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,0.5,0.3,0.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,0.3,0.2,0.3,1.4,3.3,28],9:[42,6.7,1.6,0.6,0.2,0.2,0.6,1.6,6.7,42],10:[74,9.6,2.6,0.9,0.3,0.1,0.3,0.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,0.4,0.2,0.2,0.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,0.7,0.2,0.2,0.2,0.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,0.2,0.2,0.2,0.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,0.3,0.2,0.2,0.2,0.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,0.5,0.2,0.2,0.2,0.2,0.5,2.6,7.4,24.9,76.9,600],16:[1000,122,24.5,8,3.7,1.8,0.2,0.2,0.2,0.2,0.2,1.8,3.7,8,24.5,122,1000]}},ba=new x(new Map([[1,uo],[2,so],[3,Ao],[4,po],[8,Bo]]));class Eo extends B{constructor(){super("PLINKO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){if(a.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(a.numberOfRows<8||a.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let o=a.numberOfRows,c=ba.getMultipliers(r)[a.riskLevel][o],i=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),d=i.values.reduce((m,p)=>m+p,0),s=c[d];if(s===void 0)throw new Error(`No payout found for end position ${d}`);let A=mo(s);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(A)}]},payoutMultiplier:A,outputs:{result:i.values},randomValues:i}}}import{Big as At}from"big.js";var kt=[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],ja=[37,...kt],Ta=[[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]],Ra=[[0,1],[0,37],[3,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]],_a=[[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]],Na=[[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]],wa=[[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]],Va=[[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]],Ua=[0,1,2,3,37],Ia=[[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]],Za=[[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]],U;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(U||={});var I;((r)=>{r.RED="RED";r.BLACK="BLACK"})(I||={});var Z;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(Z||={});var k;((o)=>{o.TOP="TOP";o.MIDDLE="MIDDLE";o.BOTTOM="BOTTOM"})(k||={});var G;((o)=>{o.FIRST="FIRST";o.SECOND="SECOND";o.THIRD="THIRD"})(G||={});var Gt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Gt||={});var q=2.7,X=5.3;var ut=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&Q(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&yo(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&fo(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Oo(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&So(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},Q=(t)=>{return kt.includes(t)},yo=(t)=>{if(t.length!==2)return!1;if(!t.every(Q))return!1;return Ta.some(([a,r])=>a===t[0]&&r===t[1])},fo=(t)=>{if(t.length!==3)return!1;if(!t.every(Q))return!1;return _a.some(([a,r,o])=>a===t[0]&&r===t[1]&&o===t[2])},Oo=(t)=>{if(t.length!==4)return!1;if(!t.every(Q))return!1;return wa.some(([a,r,o,n])=>a===t[0]&&r===t[1]&&o===t[2]&&n===t[3])},So=(t)=>{if(t.length!==6)return!1;if(!t.every(Q))return!1;return Ia.some(([a,r,o,n,e,c])=>a===t[0]&&r===t[1]&&o===t[2]&&n===t[3]&&e===t[4]&&c===t[5])};var st=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.basketBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw l.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&W(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Ho(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Do(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&ho(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.basketBets.every((a)=>a.amount.gte(0)))throw l.createValidationError("Invalid basket bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Co(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},W=(t)=>{return ja.includes(t)};function Ho(t){if(t.length!==2)return!1;if(!t.every(W))return!1;return Ra.some(([a,r])=>a===t[0]&&r===t[1])}var Do=(t)=>{if(t.length!==3)return!1;if(!t.every(W))return!1;return Na.some(([a,r,o])=>a===t[0]&&r===t[1]&&o===t[2])},ho=(t)=>{if(t.length!==4)return!1;if(!t.every(W))return!1;return Va.some(([a,r,o,n])=>a===t[0]&&r===t[1]&&o===t[2]&&n===t[3])},Co=(t)=>{if(t.length!==6)return!1;if(!t.every(W))return!1;return Za.some(([a,r,o,n,e,c])=>a===t[0]&&r===t[1]&&o===t[2]&&n===t[3]&&e===t[4]&&c===t[5])};var xo=(t,a)=>{let r=a===q&&t.type==="EUROPEAN",o=a===X&&t.type==="AMERICAN";if(!r&&!o)throw l.createValidationError(`Attempted to play ${t.type} roulette on edge ${a}`)},ka=(t,a)=>{if(xo(t,a),t.type==="EUROPEAN")ut(t.inputs);else st(t.inputs)};var Po={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},bo=[3,6,9,12,15,18,21,24,27,30,33,36],jo=[2,5,8,11,14,17,20,23,26,29,32,35],To=[1,4,7,10,13,16,19,22,25,28,31,34],Ro=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],_o=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];class Mt extends B{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),o=r.value,n=this.determineBetOutcomes(a,o),{payoutMultiplier:e,payout:c}=this.getPayoutDetails(a,o);return{outputs:{betOutcomes:n,result:r.values},payout:c,payoutMultiplier:e,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.getBetTotals(t),o=this.calculateTotalBetAmount(r),n={legs:this.calculatePayoutLegs(t,a)},e=T(n);return{payoutMultiplier:o.gt(0)?e.div(o):new At(0),payout:n}}determineBetOutcomes(t,a){let r={},o={};for(let n of Object.keys(t)){let e=t[n],c=this.betPredicates[n],{winning:i,losing:u}=this.partitionBets(e,c,a);r[n]=i,o[n]=u}return{winningBets:r,losingBets:o}}calculateTotalAmount(t){return t.reduce((a,r)=>a.plus(r.amount),new At(0))}isWinningStraightBet(t,a){return t.value===a}isWinningSplitBet(t,a){return t.values.some((r)=>r===a)}isWinningStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningCornerBet(t,a){return t.values.some((r)=>r===a)}isWinningDoubleStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningColorBet(t,a){let r=t;return Ro.includes(a)&&r.color==="RED"||_o.includes(a)&&r.color==="BLACK"}isWinningHalfBet(t,a){let r=t;if(a>0&&a<=18&&r.half==="LOW")return!0;if(a>18&&a<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(t,a){let r=t;return bo.includes(a)&&r.column==="TOP"||jo.includes(a)&&r.column==="MIDDLE"||To.includes(a)&&r.column==="BOTTOM"}isWinningDozenBet(t,a){let r=t;if(a>0&&a<=12&&r.dozen==="FIRST")return!0;if(a>12&&a<=24&&r.dozen==="SECOND")return!0;if(a>24&&a<=36&&r.dozen==="THIRD")return!0;return!1}isWinningParityBet(t,a){let r=t;if(a===0||a===37)return!1;let o=a%2===0?"EVEN":"ODD";return r.parity===o}getBetTotals(t){let a={};for(let r of Object.keys(t))a[r]=this.calculateTotalAmount(t[r]);return a}calculateTotalBetAmount(t){return Object.values(t).reduce((a,r)=>a.plus(r),new At(0))}partitionBets(t,a,r){return{winning:t.filter((o)=>a(o,r)),losing:t.filter((o)=>!a(o,r))}}calculatePayoutLegs(t,a){return Object.keys(t).flatMap((r)=>{let o=Po[r],n=this.betPredicates[r];return t[r].map((e)=>{if(!n(e,a))return{amount:new At("0")};return{amount:e.amount.mul(o||0)}})})}}class Ga extends Mt{maxNumber=36;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[q]}validateInputs(t){ut(t)}}class Ma extends Mt{maxNumber=37;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,basketBets:this.isWinningBasketBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[X]}validateInputs(t){st(t)}isWinningBasketBet(t,a){return Ua.some((r)=>r===a)}}class Fa extends B{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Ga,this.americanGame=new Ma}get supportedEdgeConfigurations(){return[q,X]}getBetAmount(t){switch(t.type){case"AMERICAN":return this.americanGame.getBetAmount(t.inputs);case"EUROPEAN":return this.europeanGame.getBetAmount(t.inputs);default:throw new Error("Unhandled roulette type")}}determineGameResult(t){let{gameInputs:a,...r}=t;if(ka(a,t.edge),a.type==="EUROPEAN"){let e=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:c}=e.outputs;return{...e,outputs:{type:"european",betOutcomes:c,result:e.outputs.result}}}let o=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:n}=o.outputs;return{...o,outputs:{type:"american",betOutcomes:n,result:o.outputs.result}}}}var ji=(t)=>{return new Fa().getBetAmount(t)};import{Big as Zo}from"big.js";var g;((o)=>{o.LOW_RISK="LOW_RISK";o.MEDIUM_RISK="MEDIUM_RISK";o.HIGH_RISK="HIGH_RISK"})(g||={});var L;((e)=>{e[e.TEN=10]="TEN";e[e.TWENTY=20]="TWENTY";e[e.THIRTY=30]="THIRTY";e[e.FORTY=40]="FORTY";e[e.FIFTY=50]="FIFTY"})(L||={});var No={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}}},wo={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}}},Vo={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}}},Uo={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}}},Io={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}}},Ja=new x(new Map([[1,No],[2,wo],[3,Vo],[4,Uo],[8,Io]]));var Ya={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 ko extends B{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(L).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(g).includes(a.riskLevel))throw new Error("Invalid risk level");let n=Ja.getMultipliers(r)[a.riskLevel];if(n===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let e=n[a.segments];if(e===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let c=Ya[a.riskLevel];if(c===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let i=c[a.segments];if(i===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let u=t.getRandomInt({min:0,max:i.length-1}),d=i[u.value];if(d===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${u.value}`);let s=e[d];if(s===void 0)throw new Error(`No payout found for picked segment ${d}`);let A=new Zo(s);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(A)}]},payoutMultiplier:A,outputs:{result:u.values},randomValues:u}}}export{ka as validateRouletteGameInputs,vo as validateAdvancedDiceInputs,T as sumPayout,to as rtp99Multipliers,ao as rtp98Multipliers,ro as rtp97Multipliers,oo as rtp96Multipliers,no as rtp92Multipliers,ba as plinkoMultipliers,Zt as nCr,ha as kenoMultipliers,Da as isTileCount,Lr as hasDiceWon,hr as hasBlitzWon,Ge as getMaxMultiplierForDifficulty,Ne as getBlitzDefaults,zr as diamondsMultipliers,ji as calculateRouletteBetAmount,gr as calculateDiceWinChance,Cr as calculateBlitzWinChance,gt as calculateBaccaratBetAmount,zt as calculateAdvancedDiceWinChance,xa as bigMin,Ca as bigMax,va as advancedDiceIsWithinBoundsInclusive,Bt as advancedDiceIsWithinBoundsExclusive,tr as advancedDiceGetInclusiveBoundsRange,mt as advancedDiceGetExclusiveBoundsRange,L as WheelSegments,g as WheelRiskLevel,ko as Wheel,sr as WIN_MULTIPLIER,mn as VALID_SUITS,En as VALID_RANKS,_a as VALID_EUROPEAN_STREETS,kt as VALID_EUROPEAN_STRAIGHTS,Ta as VALID_EUROPEAN_SPLITS,Ia as VALID_EUROPEAN_DOUBLE_STREETS,wa as VALID_EUROPEAN_CORNERS,Na as VALID_AMERICAN_STREETS,ja as VALID_AMERICAN_STRAIGHTS,Ra as VALID_AMERICAN_SPLITS,Za as VALID_AMERICAN_DOUBLE_STREETS,Va as VALID_AMERICAN_CORNERS,Dt as ThreeCardBonusType,bo as TOP_COLUMN,vr as TILE_COUNTS,ta as THREE_CARD_BONUS_PAYOUTS,B as SingleActionGame,w as SPLIT_BET_SIZE_FACTOR,Gt as RouletteType,Fa as Roulette,ar as RollType,it as RandomValuePool,Ro as RED_NUMBERS,tt as RANDOM_MIN_VALUE,at as RANDOM_MAX_VALUE,Pa as PlinkoRiskLevel,Eo as Plinko,U as Parity,Ht as PairBonusType,Ar as PUSH_MULTIPLIER,Lc as PLINKO_ROW_COUNTS,Po as PAYOUT_MULTIPLIERS,vt as PAIR_BONUS_PAYOUTS,f as OrigamiGame,h as MultiplierCalculator,bt as MultiActionGame,lo as Mines,Qa as MIN_WIN_CHANCE,jo as MIDDLE_COLUMN,Wa as MAX_WIN_CHANCE,Ct as MAX_CARDS_PER_ROUND,io as Limbo,pr as LOSE_MULTIPLIER,Ha as KenoRiskLevel,co as Keno,Ot as InsuranceOutcome,xt as INSURANCE_WIN_PAYOUT,M as INSURANCE_BET_SIZE_FACTOR,Dn as INSURANCE_BET_MULTIPLIER,Z as Half,qa as GameErrorCode,l as GameError,Kt as FACE_CARD_VALUE,Ga as EuropeanRoulette,q as EUROPEAN_HOUSE_EDGE,Yt as EFFECTIVE_RANGE,G as Dozen,Qr as DiceDirection,Kr as Dice,Gr as DiamondsResultType,Xr as Diamonds,Ur as Darts,R as DOUBLE_DOWN_BET_SIZE_FACTOR,Sa as DICE_MIN_ROLL,It as DICE_MAX_ROLL,Wr as DICE_EFFECTIVE_RANGE,Lt as DEALER_STAND_VALUE,ya as DARTS_MIN_VALUE,wt as DARTS_MAX_VALUE,fa as DARTS_DIFFICULTY_LEVEL,Vt as DARTS_BOARD_CONFIGS,k as Column,I as Color,hn as CARDS_PER_SUIT,xr as Blitz,ft as BlackjackOutcome,St as BlackjackActionType,Dr as Blackjack,er as BaccaratOutcome,cr as BaccaratBetType,dr as Baccarat,ht as BUST_VALUE,To as BOTTOM_COLUMN,ma as BLITZ_RANDOM_NUMBER_COUNT,pa as BLITZ_MIN_CARD_RANGE,Ba as BLITZ_MAX_CARD_RANGE,$ as BLITZ_CARD_COUNT,_o as BLACK_NUMBERS,D as BLACKJACK_VALUE,ur as BLACKJACK_MULTIPLIER,et as BASE_PAYOUT_MULTIPLIERS,Ma as AmericanRoulette,rr as AdvancedDice,X as AMERICAN_HOUSE_EDGE,Ua as AMERICAN_BASKET,Pt as ACE_SOFT_BONUS};
1
+ var za;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(za||={});class u extends Error{static createUnsupportedEdgeError(t){return new u("UNSUPPORTED_EDGE",t)}static createValidationError(t){return new u("INPUT_VALIDATION_ERROR",t)}static isGameError(t){return t instanceof u}errorCode;constructor(t,a){super(a);this.errorCode=t}}var S;((p)=>{p.DICE="DICE";p.MINES="MINES";p.KENO="KENO";p.LIMBO="LIMBO";p.ADVANCED_DICE="ADVANCED_DICE";p.BACCARAT="BACCARAT";p.DIAMONDS="DIAMONDS";p.PLINKO="PLINKO";p.ROULETTE="ROULETTE";p.WHEEL="WHEEL";p.BLACKJACK="BLACKJACK";p.BLITZ="BLITZ";p.DARTS="DARTS"})(S||={});import{Guard as qa}from"@betorigami/guard";class B{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return qa.against(!a,()=>u.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}import{Big as Yt}from"big.js";import Bt from"big.js";class C{static withMultiplier(t,a){return new Bt(t).times(new Bt(100-a).div(100))}static withWinChance(t,a){return Bt(100-t).div(a)}}var at=0,rt=1e4,Jt=rt-at+1,Xa=0.01,Qa=98,Wa=(t)=>{if(t<at)throw u.createValidationError(`Lower bound ${t} is below minimum allowed value ${at}`)},ga=(t)=>{if(t>rt)throw u.createValidationError(`Upper bound ${t} is above maximum allowed value ${rt}`)},tt=(t)=>{if(Wa(t.lower),ga(t.upper),t.lower>=t.upper)throw u.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},La=(t,a)=>{let[r,n]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>n.lower)throw u.createValidationError("Bounds must not overlap")},Ka=(t,a)=>a>=t.lower&&a<=t.upper,va=(t)=>t.upper-t.lower+1,mt=(t,a)=>a>t.lower&&a<t.upper,Et=(t)=>t.upper-t.lower-1,tr;((n)=>{n.ROLL_BETWEEN="ROLL_BETWEEN";n.ROLL_OUTSIDE="ROLL_OUTSIDE";n.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(tr||={});var $t=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return tt(t.bounds),Et(t.bounds);case"ROLL_OUTSIDE":return tt(t.bounds),Jt-va(t.bounds);case"ROLL_BETWEEN_TWO":return tt(t.firstBounds),tt(t.secondBounds),La(t.firstBounds,t.secondBounds),Et(t.firstBounds)+Et(t.secondBounds)}})(),n=Yt(r).div(Jt).mul(100);if(n.lt(Xa))throw u.createValidationError("Win chance too low");if(n.gt(Qa))throw u.createValidationError("Win chance too high");return n},te=(t)=>{$t(t)};class ar extends B{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=$t(r),o=t.getRandomInt({min:at,max:rt}),c=o.value,i=(()=>{switch(r.mode){case"ROLL_BETWEEN":return mt(r.bounds,c);case"ROLL_OUTSIDE":return!Ka(r.bounds,c);case"ROLL_BETWEEN_TWO":return mt(r.firstBounds,c)||mt(r.secondBounds,c)}})()?C.withWinChance(a,n):new Yt(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:o.values},randomValues:o}}}import ot from"big.js";import{Guard as ft}from"@betorigami/guard";var zt=0,qt=51,nt=Array.from({length:52},(t,a)=>a),Xt=["Spades","Hearts","Diamonds","Clubs"],et=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Qt=["Jack","Queen","King"],yt={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};class T{value;constructor(t){let a=nt[t];ft.againstNullOrUndefined(a,`Invalid card value: ${t}`),this.value=a}get suit(){let t=Math.floor(this.value/13),a=Xt[t];return ft.againstNullOrUndefined(a,`Invalid suit index: ${t}`),a}get rank(){let t=this.value%13,a=et[t];return ft.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}import rr from"big.js";var R=(t)=>t.legs.reduce((a,r)=>a.add(r.amount),new rr("0"));var me=["Clubs","Diamonds","Hearts","Spades"],Ee=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],nr={Ace:"Ace",Two:"2",Three:"3",Four:"4",Five:"5",Six:"6",Seven:"7",Eight:"8",Nine:"9",Ten:"10",Jack:"Jack",Queen:"Queen",King:"King"},er;((n)=>{n.PLAYER_WIN="PLAYER_WIN";n.TIE="TIE";n.BANKER_WIN="BANKER_WIN"})(er||={});var or;((n)=>{n.PLAYER="PLAYER";n.TIE="TIE";n.BANKER="BANKER"})(or||={});var cr={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Wt=(t)=>{return new ot(0).add(t.bets.reduce((r,n)=>r.add(n.amount),new ot(0)))},ir=(t,a)=>t==="TIE"&&(a==="PLAYER"||a==="BANKER");class ur extends B{constructor(){super("BACCARAT")}get supportedEdgeConfigurations(){return[1]}getBetAmount(t){return Wt(t)}determineGameResult({generator:t,gameInputs:a}){this.validateGameInputs(a);let r=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),n=r.values,o=n.slice(0,3),c=n.slice(3,6),e=[],i=0;for(let f of o.slice(0,2)){let j=this.mapRandomValueToCard(f),v=this.mapRandomValueToCardValue(f);e.push(j),i=(i+v)%10}let l=[],d=0;for(let f of c.slice(0,2)){let j=this.mapRandomValueToCard(f),v=this.mapRandomValueToCardValue(f);l.push(j),d=(d+v)%10}if(!this.isNaturalWin(i,d)){let f=this.shouldDrawThirdPlayerCard(i),j=null;if(f)j=this.mapRandomValueToCardValue(o[2]),e.push(this.mapRandomValueToCard(o[2])),i=(i+j)%10;if(this.shouldDrawThirdBankerCard(d,j))l.push(this.mapRandomValueToCard(c[2])),d=(d+this.mapRandomValueToCardValue(c[2]))%10}let A;if(i===d)A="TIE";else A=i>d?"PLAYER_WIN":"BANKER_WIN";let s=Wt(a),{betType:m,multiplier:p}=cr[A],H={legs:a.bets.map((f)=>{if(f.type===m)return{amount:f.amount.mul(p)};return{amount:ir(A,f.type)?f.amount:new ot("0")}})},w=R(H),K=s.gt(0)?w.div(s):new ot(0);return{isFinished:!0,payout:H,payoutMultiplier:K,outputs:{playerCards:e,playerHandValue:i,bankerCards:l,bankerHandValue:d,gameOutcome:A,result:r.values},randomValues:r}}validateGameInputs(t){if(t.bets.length===0)throw new Error("Must place at least a single bet.");if(!t.bets.every((a)=>a.amount.gte(0)))throw new Error("Invalid bet.")}mapRandomValueToCard(t){let a=new T(t);return{suit:a.suit,rank:nr[a.rank]}}isNaturalWin(t,a){let r=[8,9];return r.includes(t)||r.includes(a)}mapRandomValueToCardValue(t){let a=t%13;if(a===0)return 1;if(a>=10)return 10;return a+1}shouldDrawThirdPlayerCard(t){return t<=5}shouldDrawThirdBankerCard(t,a){if(a===null)return t<=5;if(t<=2)return!0;if(t===3)return a!==8;if(t===4)return[2,3,4,5,6,7].includes(a);if(t===5)return[4,5,6,7].includes(a);if(t===6)return[6,7].includes(a);return!1}}var St;((o)=>{o.WIN="WIN";o.LOSE="LOSE";o.PUSH="PUSH";o.PLAYER_BLACKJACK="PLAYER_BLACKJACK"})(St||={});var Ot;((r)=>{r.WON="WON";r.LOST="LOST"})(Ot||={});var Ht;((i)=>{i.START="START";i.HIT="BLACKJACK_HIT";i.STAND="BLACKJACK_STAND";i.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";i.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";i.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";i.SPLIT="BLACKJACK_SPLIT"})(Ht||={});var Dt;((o)=>{o.EXACT_PAIR="EXACT_PAIR";o.COLORED_PAIR="COLORED_PAIR";o.MIXED_PAIR="MIXED_PAIR";o.LOSS="LOSS"})(Dt||={});var ht;((e)=>{e.SUITED_TRIPS="SUITED_TRIPS";e.STRAIGHT_FLUSH="STRAIGHT_FLUSH";e.THREE_OF_A_KIND="THREE_OF_A_KIND";e.STRAIGHT="STRAIGHT";e.FLUSH="FLUSH";e.LOSS="LOSS"})(ht||={});var lr=2.5,dr=2,sr=1,Ar=0,gt=17,Ct=21,D=21,xt=63,Pt=0.5,bt=3,_=1,V=1,De=13,jt=10,Lt=10,ct={PLAYER_BLACKJACK:lr,WIN:dr,PUSH:sr,LOSE:Ar},Kt={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},vt={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};import b from"big.js";import{Guard as E}from"@betorigami/guard";import{createStore as fr}from"@xstate/store";import{Guard as pr}from"@betorigami/guard";class y extends T{get numericRank(){if(Qt.includes(this.rank))return Lt;return et.indexOf(this.rank)+1}static fromValue(t){return pr.against(!nt.includes(t),`Invalid card value: ${t}`),new y(t)}}class F{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,n)=>r+n.numericRank,0),t.some((r)=>r.rank==="Ace")&&this.hardHandValue+jt<=Ct)this.softHandValue=this.hardHandValue+jt}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>Ct}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===D}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class J{cards;value;constructor(t){this.cards=t.map((a)=>y.fromValue(a)),this.value=new F(this.cards)}get isBusted(){return this.value.isBusted}get isBlackjack(){return this.value.isBlackjack}get highestHandValue(){return this.value.highestHandValue}get rawValues(){return this.cards.map((t)=>t.value)}toDto(){return{cards:this.cards.map((t)=>t.toDto()),value:this.highestHandValue}}}class Y extends J{otherCards;upCard;holeCard;constructor(t,a,r=[]){super([t,a,...r]);this.otherCards=r;this.upCard=y.fromValue(t),this.holeCard=y.fromValue(a)}static withInitialDeal(t){return new Y(t.upCard,t.holeCard)}addDrawnCards(t){return new Y(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new F([this.upCard]).highestHandValue}}}class N extends J{static withInitialDeal(t){return new N(t)}addDrawnCards(t){return new N([...this.rawValues,...t])}}import{Guard as it}from"@betorigami/guard";class ut{source;index=0;constructor(t){this.source=t}static from(t,a){return it.against(a<=0,`Count must be positive, got ${a}`),it.against(t.values.length!==a,`Expected ${a} values, got ${t.values.length}`),new ut(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return it.againstUndefined(t,"RandomValuePool exhausted"),this.index+=1,t}take(t){it.against(this.index+t>this.source.values.length,`RandomValuePool exhausted: requested ${t} but only ${this.source.values.length-this.index} remain`);let a=this.source.values.slice(this.index,this.index+t);return this.index+=t,a}}import{Guard as ta}from"@betorigami/guard";import Br from"fast-deep-equal";class Tt{gameId;edge;constructor(t,a){this.gameId=t;this.edge=a;this.validateEdge(a)}play(t,a,r=[]){let n=this.createGameStore(),o=this.generateRandomValues(t),c=o.toMultipleRandomValues();for(let l of r)n.send({...l.playerArgument,randomValuePool:o});let e=r[r.length-1];if(e)ta.against(!Br(e.state,this.toExternalState(n.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");n.send({...a,randomValuePool:o});let i=n.getSnapshot().context;return{playerArgument:i.playerArgument,state:this.toExternalState(i.state),config:i.config,additionalBetAmount:i.additionalBetAmount,proof:{proofHash:c.proofHash,proofString:c.proofString}}}validateEdge(t){let a=this.supportedEdgeConfigurations.includes(t);ta.against(!a,()=>u.createUnsupportedEdgeError(`${this.gameId} does not support ${t}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}}import x from"big.js";import{Guard as Rt}from"@betorigami/guard";var aa=(t)=>{let a=t.pairBonus!==null?{amount:x(t.pairBonus.betAmount).mul(t.pairBonus.payoutMultiplier)}:null,r=t.threeCardBonus!==null?{amount:x(t.threeCardBonus.betAmount).mul(t.threeCardBonus.payoutMultiplier)}:null;return[a,r].filter((n)=>n!==null)},ra=(t)=>{let a=t.betAmounts.mainBetAmount,n=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(_):x(0),o=t.insuranceOutcome!==void 0?t.insuranceStake:x(0),c=a.plus(n).mul(ct[t.outcome]),e=t.insuranceOutcome==="WON"?o.mul(bt):x(0),i=aa(t.sideBetResults),l=[{amount:c},...t.insuranceOutcome!==void 0?[{amount:e}]:[],...i],d=R({legs:l}),A=a.plus(o).plus(n).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);Rt.against(A.eq(0),"Total bet amount cannot be zero");let s=d.div(A);Rt.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let m;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":m=n;break;case"BLACKJACK_BUY_INSURANCE":m=t.insuranceStake;break;case"BLACKJACK_SPLIT":m=a.mul(V);break}return{payouts:l,totalBetAmount:A,multiplier:s,additionalBetAmount:m}},na=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(_):x(0),n=t.splitHandDoubledDown?a.mul(_):x(0),o=t.insuranceOutcome!==void 0?t.insuranceStake:x(0),c=a.plus(r).mul(ct[t.mainOutcome]),e=a.plus(n).mul(ct[t.splitOutcome]),i=t.insuranceOutcome==="WON"?o.mul(bt):x(0),l=aa(t.sideBetResults),d=[{amount:c},{amount:e},...t.insuranceOutcome!==void 0?[{amount:i}]:[],...l],A=R({legs:d}),s=a.plus(a).plus(o).plus(r).plus(n).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);Rt.against(s.eq(0),"Total bet amount cannot be zero");let m=A.div(s),p;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":p=a.mul(_);break;case"BLACKJACK_SPLIT":p=a.mul(V);break}return{payouts:d,totalBetAmount:s,multiplier:m,additionalBetAmount:p}};import{Guard as mr}from"@betorigami/guard";var _t=(t)=>t.every((a)=>a===t[0]),ea=(t)=>{let a=[...t].sort((r,n)=>r-n);return a.every((r,n)=>{let o=a[n-1];if(n===0)return!0;return mr.againstUndefined(o,"Previous value cannot be undefined"),r===o+1})},oa={Ace:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9,Ten:10,Jack:11,Queen:12,King:13},Er={...oa,Ace:14},yr=(t)=>ea(t.map((a)=>oa[a]))||ea(t.map((a)=>Er[a])),ca=(t,a)=>{let r=y.fromValue(t),n=y.fromValue(a);if(r.rank!==n.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(yt[r.suit]===yt[n.suit])return"COLORED_PAIR";return"MIXED_PAIR"},ia=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Kt[a]}),ua=(t,a,r)=>{let n=y.fromValue(t),o=y.fromValue(a),c=y.fromValue(r),e=[n.rank,o.rank,c.rank],i=_t([n.suit,o.suit,c.suit]),l=_t(e),d=yr(e);if(_t([t,a,r]))return"SUITED_TRIPS";if(i&&d)return"STRAIGHT_FLUSH";if(l)return"THREE_OF_A_KIND";if(d)return"STRAIGHT";if(i)return"FLUSH";return"LOSS"},la=(t,a)=>({betAmount:t,result:a,payoutMultiplier:vt[a]});var Sr={state:{isFinished:!1,phase:"uninitialised",multiplier:b(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},O=(t)=>y.fromValue(t).value;function Or(t){E.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function da(t){E.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function Nt(t){E.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var sa=(t,a)=>{let r=a;while(r.highestHandValue<gt)r=r.addDrawnCards([O(t.takeOne())]);return r},wt=(t,a)=>{if(t.isBusted)return"LOSE";if(a.isBusted)return"WIN";let r=t.highestHandValue,n=a.highestHandValue;if(r>n)return"WIN";if(r<n)return"LOSE";return"PUSH"},Aa=(t)=>t.insuranceOutcome===void 0?b(0):t.roundInsuranceStake(t.betAmounts.mainBetAmount.mul(Pt)),pa=(t)=>{let{payouts:a,multiplier:r,additionalBetAmount:n}=ra({outcome:t.outcome,insuranceOutcome:t.insuranceOutcome,insuranceStake:Aa(t),actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"finished",playerHand:t.playerHand,dealerHand:t.dealerHand,outcome:t.outcome,payout:{legs:a},multiplier:r,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:n}},Hr=(t)=>{let a=sa(t.randomValuePool,t.dealerHand),r=wt(t.playerHand,a);return pa({...t,dealerHand:a,outcome:r})},Dr=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:sa(t.randomValuePool,t.dealerHand),n=wt(t.mainHand,r),o=wt(t.splitHand,r),{payouts:c,multiplier:e,additionalBetAmount:i}=na({hasSplit:!0,mainOutcome:n,splitOutcome:o,insuranceOutcome:t.insuranceOutcome,insuranceStake:Aa(t),mainHandDoubledDown:t.mainHandDoubledDown,splitHandDoubledDown:t.splitHandDoubledDown,actionType:t.playerArgument.type,betAmounts:t.betAmounts,sideBetResults:t.sideBetResults});return{state:{isFinished:!0,phase:"split-finished",mainHand:t.mainHand,splitHand:t.splitHand,dealerHand:r,mainOutcome:n,splitOutcome:o,payout:{legs:c},multiplier:e,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:i}};class hr extends Tt{roundInsuranceStake;constructor(t,a){super("BLACKJACK",t);this.roundInsuranceStake=a}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return ut.from(t.getRandomIntsWithReplacement({min:zt,max:qt,count:xt}),xt)}toExternalState(t){let a=t.phase;switch(a){case"awaiting-insurance":return{isFinished:!1,phase:"awaiting-insurance",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"in-progress":return{isFinished:!1,phase:"player-turn",multiplier:t.multiplier,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-main-hand":return{isFinished:!1,phase:"playing-main-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"playing-split-hand":return{isFinished:!1,phase:"playing-split-hand",multiplier:t.multiplier,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!1),sideBetResults:t.sideBetResults};case"finished":return{isFinished:!0,payout:t.payout,multiplier:t.multiplier,randomValues:t.randomValues,outcome:t.outcome,playerHand:t.playerHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"split-finished":return{isFinished:!0,payout:t.payout,multiplier:t.multiplier,randomValues:t.randomValues,mainOutcome:t.mainOutcome,splitOutcome:t.splitOutcome,mainHand:t.mainHand.toDto(),splitHand:t.splitHand.toDto(),dealerHand:t.dealerHand.toDto(!0),sideBetResults:t.sideBetResults,...t.insuranceOutcome!==void 0&&{insuranceOutcome:t.insuranceOutcome}};case"uninitialised":throw new Error("Cannot convert uninitialised state to external state");default:E.againstNever(a,"Invalid state received")}}createGameStore(){let t=(o)=>{if(this.roundInsuranceStake===void 0)return o;let c=this.roundInsuranceStake(o);return E.against(o.gt(0)&&c.eq(0),"Insurance stake rounds below the smallest unit this currency supports"),c},a=(o)=>pa({...o,roundInsuranceStake:t}),r=(o)=>Hr({...o,roundInsuranceStake:t}),n=(o)=>Dr({...o,roundInsuranceStake:t});return fr({context:Sr,on:{START:(o,c)=>{let{state:e}=o;E.against(e.phase!=="uninitialised","START action requires a fresh game");let i=O(c.randomValuePool.takeOne()),l=O(c.randomValuePool.takeOne()),d=O(c.randomValuePool.takeOne()),A=O(c.randomValuePool.takeOne()),s=N.withInitialDeal([i,l]),m=Y.withInitialDeal({upCard:d,holeCard:A}),p={mainBetAmount:b(c.mainBetAmount),pairBonusAmount:b(c.pairBonusAmount),threeCardBonusAmount:b(c.threeCardBonusAmount)},h={pairBonus:b(c.pairBonusAmount).gt(0)?ia(c.pairBonusAmount,ca(i,l)):null,threeCardBonus:b(c.threeCardBonusAmount).gt(0)?la(c.threeCardBonusAmount,ua(i,l,d)):null},H={type:"START",mainBetAmount:c.mainBetAmount,pairBonusAmount:c.pairBonusAmount,threeCardBonusAmount:c.threeCardBonusAmount};if(m.upCard.rank==="Ace")return{state:{...e,isFinished:!1,phase:"awaiting-insurance",playerHand:s,dealerHand:m,betAmounts:p,sideBetResults:h},config:{},playerArgument:H};let w={playerHand:s,dealerHand:m,randomValuePool:c.randomValuePool,playerArgument:H,betAmounts:p,sideBetResults:h};if(s.isBlackjack&&m.isBlackjack)return a({...w,outcome:"PUSH"});if(s.isBlackjack)return a({...w,outcome:"PLAYER_BLACKJACK"});if(m.isBlackjack)return a({...w,outcome:"LOSE"});return{state:{...e,isFinished:!1,phase:"in-progress",playerHand:s,dealerHand:m,insuranceOutcome:void 0,betAmounts:p,sideBetResults:h},config:{},playerArgument:H}},BLACKJACK_BUY_INSURANCE:(o,c)=>{let{state:e}=o;da(e);let{playerHand:i,dealerHand:l,betAmounts:d,sideBetResults:A}=e,s={...e,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:d,sideBetResults:A};if(i.isBlackjack&&l.isBlackjack)return a({...s,outcome:"PUSH",insuranceOutcome:"WON"});if(i.isBlackjack)return a({...s,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(l.isBlackjack)return a({...s,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...e,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:t(d.mainBetAmount.mul(Pt))}},BLACKJACK_REJECT_INSURANCE:(o,c)=>{let{state:e}=o;da(e);let{playerHand:i,dealerHand:l,betAmounts:d,sideBetResults:A}=e,s={playerHand:i,dealerHand:l,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:d,sideBetResults:A};if(i.isBlackjack&&l.isBlackjack)return a({...s,outcome:"PUSH"});if(i.isBlackjack)return a({...s,outcome:"PLAYER_BLACKJACK"});if(l.isBlackjack)return a({...s,outcome:"LOSE"});return{state:{...e,phase:"in-progress",insuranceOutcome:void 0},config:{},playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"}}},BLACKJACK_HIT:(o,c)=>{let{state:e}=o;switch(Nt(e),e.phase){case"playing-main-hand":{let i=e.mainHand.addDrawnCards([O(c.randomValuePool.takeOne())]);if(i.isBusted||i.highestHandValue===D){if(e.splitHand.highestHandValue===D)return n({...e,mainHand:i,splitHandDoubledDown:!1,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...e,phase:"playing-split-hand",mainHand:i,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...e,mainHand:i},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let i=e.splitHand.addDrawnCards([O(c.randomValuePool.takeOne())]);if(i.isBusted||i.highestHandValue===D)return n({...e,splitHand:i,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...e,splitHand:i},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let i=e.playerHand.addDrawnCards([O(c.randomValuePool.takeOne())]);if(i.isBusted)return a({...e,playerHand:i,outcome:"LOSE",randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(i.highestHandValue===D)return r({...e,playerHand:i,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...e,phase:"in-progress",playerHand:i},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:E.againstNever(e,"Invalid phase for HIT action")}},BLACKJACK_STAND:(o,c)=>{let{state:e}=o;switch(Nt(e),e.phase){case"playing-main-hand":{if(e.splitHand.highestHandValue===D)return n({...e,splitHandDoubledDown:!1,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});return{state:{...e,phase:"playing-split-hand",splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_STAND"}}}case"playing-split-hand":return n({...e,splitHandDoubledDown:e.splitHandDoubledDown,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});case"in-progress":return r({...e,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});default:E.againstNever(e,"Invalid phase for STAND action")}},BLACKJACK_DOUBLE_DOWN:(o,c)=>{let{state:e}=o;switch(Nt(e),e.phase){case"playing-main-hand":{E.against(e.mainHand.cards.length!==2,"Double down is only allowed as the first action");let i=e.mainHand.addDrawnCards([O(c.randomValuePool.takeOne())]),{betAmounts:l}=e;if(e.splitHand.highestHandValue===D)return n({...e,mainHand:i,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...e,phase:"playing-split-hand",mainHand:i,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:l.mainBetAmount.mul(_)}}case"playing-split-hand":{E.against(e.splitHand.cards.length!==2,"Double down is only allowed as the first action");let i=e.splitHand.addDrawnCards([O(c.randomValuePool.takeOne())]);return n({...e,splitHand:i,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{E.against(e.playerHand.cards.length!==2,"Double down is only allowed as the first action");let i=e.playerHand.addDrawnCards([O(c.randomValuePool.takeOne())]);if(i.isBusted)return a({...e,playerHand:i,outcome:"LOSE",randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return r({...e,playerHand:i,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:E.againstNever(e,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(o,c)=>{let{state:e}=o;Or(e);let{playerHand:i,betAmounts:l,sideBetResults:d}=e;E.against(i.cards.length!==2,"Split is only allowed with exactly 2 cards");let A=i.cards[0],s=i.cards[1];E.againstUndefined(A,"First card is missing"),E.againstUndefined(s,"Second card is missing"),E.against(A.rank!==s.rank,"Split requires two cards of the same rank");let m=O(c.randomValuePool.takeOne()),p=O(c.randomValuePool.takeOne()),h=N.withInitialDeal([A.value,m]),H=N.withInitialDeal([s.value,p]);if(A.rank==="Ace")return n({...e,mainHand:h,splitHand:H,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let K=h.highestHandValue===D,f=H.highestHandValue===D;if(K&&f)return n({mainHand:h,splitHand:H,dealerHand:e.dealerHand,randomValuePool:c.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:e.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:l,sideBetResults:d});if(K)return{state:{...e,phase:"playing-split-hand",mainHand:h,splitHand:H,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:l.mainBetAmount.mul(V)};return{state:{...e,phase:"playing-main-hand",multiplier:b(0),mainHand:h,splitHand:H,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:l.mainBetAmount.mul(V)}}}})}getValidNextActionTypes(t){if(t.isFinished)return[];switch(t.phase){case"awaiting-insurance":return["BLACKJACK_BUY_INSURANCE","BLACKJACK_REJECT_INSURANCE"];case"playing-main-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.mainHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"playing-split-hand":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.splitHand.cards.length===2)a.push("BLACKJACK_DOUBLE_DOWN");return a}case"player-turn":{let a=["BLACKJACK_HIT","BLACKJACK_STAND"];if(t.playerHand.cards.length===2){a.push("BLACKJACK_DOUBLE_DOWN");let r=t.playerHand.cards[0],n=t.playerHand.cards[1];if(E.againstUndefined(r,"First player card is missing"),E.againstUndefined(n,"Second player card is missing"),r.rank===n.rank)a.push("BLACKJACK_SPLIT")}return a}default:E.againstNever(t,"Invalid phase for getting valid actions")}}}import z from"big.js";import{Guard as ya}from"@betorigami/guard";var Ba=0,ma=51,$=52,Ea=52;var No=()=>({minPicks:5,maxPicks:36}),Cr=(t)=>t.length===new Set(t).size,xr=(t)=>{let a=z(1),r=z($);for(let n=0;n<t;n+=1)a=a.mul(z($-n).div(r));return a};class Pr extends B{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){ya.against(a.pickCount<1||a.pickCount>$,`pickCount must be between 1 and ${$}`),ya.againstNonInteger(a.pickCount,"pickCount must be an integer");let n=t.getRandomIntsWithReplacement({min:Ba,max:ma,count:Ea}),o=n.values.slice(0,a.pickCount),c=Cr(o),e=xr(a.pickCount),i=c?C.withMultiplier(z(1).div(e),r):z(0);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(i)}]},payoutMultiplier:i,outputs:{result:n.values,cards:o.map((l)=>new T(l).toDto())},randomValues:n}}}var fa=0,Vt=4294967295,Sa;((o)=>{o.EASY="EASY";o.MEDIUM="MEDIUM";o.HARD="HARD";o.EXPERT="EXPERT"})(Sa||={});var br=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],jr={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:0.5,ringTwo:0.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:0.5},segments:br},Tr=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Rr={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:0.4,ringTwo:0.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:0.4},segments:Tr},_r=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Nr={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:0.2,ringTwo:0.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:0.2},segments:_r},wr=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],Vr={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:0.1,ringTwo:0.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:0.1},segments:wr},Go=(t)=>{let a=kt[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((n,o)=>o>n?o:n)},kt={EASY:jr,MEDIUM:Rr,HARD:Nr,EXPERT:Vr};import{Guard as It}from"@betorigami/guard";import kr from"big.js";class Ir extends B{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:fa,max:Vt,count:2}),n=r.values[0],o=r.values[1];It.againstUndefined(n,"Random number generator returned no value for clockWiseRotation"),It.againstUndefined(o,"Random number generator returned no value for distanceFromCentre");let c=a.difficultyLevel,e=kr(Ur(c,n,o));return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(e)}]},payoutMultiplier:e,outputs:{result:r.values},randomValues:r}}}var Ur=(t,a,r)=>{let n=kt[t],{distanceBoundaries:o,multipliers:c}=n;if(r<o.bullseye)return c.bullseye;if(r<o.ringOne)return c.ringOne;if(r<o.ringTwo)return c.ringTwo;if(r<o.ringThree)return Zr(n,a);return c.ringFour},Zr=(t,a)=>{let r=t.segments.length,n=Math.floor(a/(Vt+1)*r),o=t.segments[n];return It.againstUndefined(o,`Segment index ${n} out of bounds`),t.multipliers.ringThree[o]};import Gr from"big.js";class P{multipliers;constructor(t){this.multipliers=t}getMultipliers(t){let a=this.multipliers.get(t);if(a===void 0)throw new Error(`Multipliers for ${t} not found`);return a}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([t,a])=>({edge:t,multipliers:a}))}}var Mr;((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"})(Mr||={});var Fr={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},Jr={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},Yr={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},$r={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},zr={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},qr=new P(new Map([[1,Fr],[2,Jr],[3,Yr],[4,$r],[8,zr]])),Xr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Qr extends B{constructor(){super("DIAMONDS")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),o=qr.getMultipliers(a),c=n.values,e=Gr(this.calculatePayoutMultiplier(o,c));return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(e)}]},payoutMultiplier:e,outputs:{result:n.values},randomValues:n}}calculatePayoutMultiplier(t,a){let r=new Map;for(let c of a){let e=r.get(c)||0;r.set(c,e+1)}let n=[...r.values()].filter((c)=>c>1),o=this.classifyResult(n);return o===null?0:t[o]}classifyResult(t){if(t.length>2)throw new Error(`Unexpected number of repeats ${t.length}`);let[a,r]=t;if(a===void 0)return null;if(r===void 0){let n=Xr[a];if(n===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return n}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}import Oa from"big.js";var Wr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Wr||={});var Ha=0,Ut=1e4,gr=Ut-Ha+1,Lr=(t)=>{let a=t.direction==="ABOVE"?Ut-t.selectedValue:t.selectedValue;return new Oa(a).div(gr).mul(100)},Kr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class vr extends B{constructor(){super("DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomInt({min:Ha,max:Ut}),o=Lr(r),e=Kr(r,n.value)?C.withWinChance(a,o):new Oa(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(e)}]},payoutMultiplier:e,outputs:{result:n.values},randomValues:n}}}import cn from"big.js";import{Guard as lt}from"@betorigami/guard";var Da;((o)=>{o.CLASSIC="CLASSIC";o.LOW_RISK="LOW_RISK";o.MEDIUM_RISK="MEDIUM_RISK";o.HIGH_RISK="HIGH_RISK"})(Da||={});var tn=[1,2,3,4,5,6,7,8,9,10],ha=(t)=>{return tn.includes(t)};var an={[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]}},rn={[1]:{CLASSIC:[0,3.92],LOW_RISK:[0.7,1.82],MEDIUM_RISK:[0.4,2.72],HIGH_RISK:[0,3.92]},[2]:{CLASSIC:[0,1.9,4.32],LOW_RISK:[0,2,3.65],MEDIUM_RISK:[0,1.8,5],HIGH_RISK:[0,0,17]},[3]:{CLASSIC:[0,1,3,10.7],LOW_RISK:[0,1.1,1.3,26.2],MEDIUM_RISK:[0,0,2.7,50.3],HIGH_RISK:[0,0,0,80.7]},[4]:{CLASSIC:[0,0.8,1.8,4.75,22.5],LOW_RISK:[0,0,2.2,7.65,90],MEDIUM_RISK:[0,0,1.7,9.8,100],HIGH_RISK:[0,0,0,9.75,259]},[5]:{CLASSIC:[0,0.2,1.4,4.25,16.4,36],LOW_RISK:[0,0,1.5,4.1,12.9,300],MEDIUM_RISK:[0,0,1.4,3.9,13.9,390],HIGH_RISK:[0,0,0,4.5,47,450]},[6]:{CLASSIC:[0,0,1,3.6,7,17,40],LOW_RISK:[0,0,1.1,2,5.8,100,700],MEDIUM_RISK:[0,0,0,3,8.6,180,710],HIGH_RISK:[0,0,0,0,10.6,350,710]},[7]:{CLASSIC:[0,0,0.5,3,4.1,13.7,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,13.5,225,700],MEDIUM_RISK:[0,0,0,2,6.9,29.2,400,800],HIGH_RISK:[0,0,0,0,6.9,89.1,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,12.2,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,4.8,38,100,800],MEDIUM_RISK:[0,0,0,2,4,10.4,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.8,270,600,900]},[9]:{CLASSIC:[0,0,0,1.5,3,8.1,15,45,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.1,7.4,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1000],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.5,7.6,16,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.6,3.7,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1000]}},nn={[1]:{CLASSIC:[0,3.88],LOW_RISK:[0.7,1.78],MEDIUM_RISK:[0.4,2.68],HIGH_RISK:[0,3.88]},[2]:{CLASSIC:[0,1.85,4.48],LOW_RISK:[0,2,3.48],MEDIUM_RISK:[0,1.8,4.8],HIGH_RISK:[0,0,16.8]},[3]:{CLASSIC:[0,1,3,9.9],LOW_RISK:[0,1.1,1.2,26.5],MEDIUM_RISK:[0,0,2.65,50],HIGH_RISK:[0,0,0,79.9]},[4]:{CLASSIC:[0,0.8,1.7,5,23],LOW_RISK:[0,0,2.1,7.95,90],MEDIUM_RISK:[0,0,1.7,9.55,100],HIGH_RISK:[0,0,0,9.5,259]},[5]:{CLASSIC:[0,0.2,1.4,4.1,16.6,36],LOW_RISK:[0,0,1.5,4,12.7,300],MEDIUM_RISK:[0,0,1.4,3.8,13.7,390],HIGH_RISK:[0,0,0,4.4,46.9,450]},[6]:{CLASSIC:[0,0,1,3.6,6.6,16.5,40],LOW_RISK:[0,0,1.1,1.9,5.9,100,700],MEDIUM_RISK:[0,0,0,2.9,8.7,180,710],HIGH_RISK:[0,0,0,0,10.8,342,710]},[7]:{CLASSIC:[0,0,0.5,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.1,1.6,3.1,14.8,225,700],MEDIUM_RISK:[0,0,0,2,6.7,29,400,800],HIGH_RISK:[0,0,0,0,6.8,88.2,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.8,12.7,21,54,70],LOW_RISK:[0,0,1.1,1.5,1.8,5.2,38,100,800],MEDIUM_RISK:[0,0,0,2,3.8,10.8,66,400,900],HIGH_RISK:[0,0,0,0,4.9,19.5,265,600,900]},[9]:{CLASSIC:[0,0,0,1.5,2.9,8.2,15,43,60,85],LOW_RISK:[0,0,1.1,1.3,1.6,2.1,7.7,49,250,1000],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.2,4.2,8,16.7,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.5,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1000]}},en={[1]:{CLASSIC:[0,3.84],LOW_RISK:[0.69,1.77],MEDIUM_RISK:[0.38,2.7],HIGH_RISK:[0,3.84]},[2]:{CLASSIC:[0,1.83,4.44],LOW_RISK:[0,1.98,3.44],MEDIUM_RISK:[0,1.78,4.77],HIGH_RISK:[0,0,16.64]},[3]:{CLASSIC:[0,0.98,3,9.8],LOW_RISK:[0,1.09,1.19,26.15],MEDIUM_RISK:[0,0,2.6,49.8],HIGH_RISK:[0,0,0,79]},[4]:{CLASSIC:[0,0.79,1.68,5,22.7],LOW_RISK:[0,0,2.1,7.8,88.3],MEDIUM_RISK:[0,0,1.66,9.5,100],HIGH_RISK:[0,0,0,9.25,259]},[5]:{CLASSIC:[0,0.19,1.39,4.1,16.3,35.5],LOW_RISK:[0,0,1.47,4,12.5,300],MEDIUM_RISK:[0,0,1.37,3.8,13.5,390],HIGH_RISK:[0,0,0,4.3,46.6,450]},[6]:{CLASSIC:[0,0,0.98,3.6,6.5,15.9,39.9],LOW_RISK:[0,0,1.08,1.89,5.8,100,700],MEDIUM_RISK:[0,0,0,2.9,8.35,180,710],HIGH_RISK:[0,0,0,0,10.4,342,710]},[7]:{CLASSIC:[0,0,0.47,2.9,4.3,13.5,30.4,60],LOW_RISK:[0,0,1.08,1.59,3.1,14.6,225,700],MEDIUM_RISK:[0,0,0,1.98,6.6,28.7,400,800],HIGH_RISK:[0,0,0,0,6.7,87.3,400,800]},[8]:{CLASSIC:[0,0,0,2.2,3.7,12.5,21,54,70],LOW_RISK:[0,0,1.09,1.49,1.77,5.1,37.5,100,800],MEDIUM_RISK:[0,0,0,1.96,3.8,10.7,65.8,400,900],HIGH_RISK:[0,0,0,0,4.9,18.8,265,600,900]},[9]:{CLASSIC:[0,0,0,1.47,2.9,8.1,14.9,43,60,85],LOW_RISK:[0,0,1.09,1.28,1.59,2.1,7.6,48.4,250,1000],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1000],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.37,2.2,4.2,7.8,16.5,49.2,80,100],LOW_RISK:[0,0,1.08,1.19,1.3,1.47,2.9,12,50,250,1000],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1000]}},on={[1]:{CLASSIC:[0,3.68],LOW_RISK:[0.7,1.58],MEDIUM_RISK:[0.4,2.48],HIGH_RISK:[0,3.68]},[2]:{CLASSIC:[0,1.72,4.48],LOW_RISK:[0,1.9,3.28],MEDIUM_RISK:[0,1.7,4.62],HIGH_RISK:[0,0,15.95]},[3]:{CLASSIC:[0,0.9,2.95,9.9],LOW_RISK:[0,1,1.2,26],MEDIUM_RISK:[0,0,2.29,50],HIGH_RISK:[0,0,0,75.7]},[4]:{CLASSIC:[0,0.8,1.6,4.4,21],LOW_RISK:[0,0,2,7.5,86],MEDIUM_RISK:[0,0,1.5,9.5,98],HIGH_RISK:[0,0,0,9,246]},[5]:{CLASSIC:[0,0.2,1.2,4.2,16.3,37],LOW_RISK:[0,0,1.4,3.8,12,300],MEDIUM_RISK:[0,0,1.3,3.5,14,385],HIGH_RISK:[0,0,0,4,45,450]},[6]:{CLASSIC:[0,0,1,3.3,6.2,15,40],LOW_RISK:[0,0,1.1,1.7,4.9,99,700],MEDIUM_RISK:[0,0,0,2.6,8.5,177,705],HIGH_RISK:[0,0,0,0,10,327,710]},[7]:{CLASSIC:[0,0,0.4,2.8,4.2,14.5,30,60],LOW_RISK:[0,0,1.1,1.4,3,14,210,700],MEDIUM_RISK:[0,0,0,1.8,6.4,29,400,800],HIGH_RISK:[0,0,0,0,6.1,85,400,800]},[8]:{CLASSIC:[0,0,0,2,3.7,13,20,50,70],LOW_RISK:[0,0,1.1,1.4,1.6,4.6,35,90,800],MEDIUM_RISK:[0,0,0,1.9,3.5,10.5,65,400,900],HIGH_RISK:[0,0,0,0,4.5,18,265,600,900]},[9]:{CLASSIC:[0,0,0,1.4,2.6,9,11.5,40,60,85],LOW_RISK:[0,0,1,1.3,1.5,2,7,45,250,1000],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1000],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.3,2,4.4,8,16.7,50,80,100],LOW_RISK:[0,0,1,1.2,1.25,1.4,2,10,50,250,1000],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1000],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1000]}},Ca=new P(new Map([[1,an],[2,rn],[3,nn],[4,en],[8,on]]));class un extends B{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){lt.againstEmptyArray(r.selectedNumbers,()=>u.createValidationError("No numbers selected")),lt.against(r.selectedNumbers.length>10,()=>u.createValidationError("Maximum of 10 numbers can be selected"));for(let s of r.selectedNumbers)lt.againstNonInteger(s,()=>u.createValidationError("Only integers can be selected")),lt.against(s<0||s>39,()=>u.createValidationError("Invalid number selected"));let n=t.getUniqueRandomInts({min:0,max:39,count:10}),o=r.selectedNumbers.filter((s)=>n.values.includes(s)),c=r.selectedNumbers.length;if(!ha(c))throw new Error(`Invalid tile count: ${c}`);let d=Ca.getMultipliers(a)[c][r.riskLevel][o.length];if(d===void 0)throw new Error(`No multiplier found for matching tile count ${o.length}`);let A=new cn(d);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(A)}]},payoutMultiplier:A,outputs:{result:n.values},randomValues:n}}}import k from"big.js";var xa=(t,a)=>{return t.gt(a)?t:a};var Pa=(t,a)=>{return t.lt(a)?t:a};class ln extends B{constructor(){super("LIMBO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){let n=t.getRandomInt({min:1,max:4294967295}),o=n.max,c=new k(16777216),e=new k(1),i=new k(1e6),l=n.value,d=new k(l-1).div(o),A=(100-a)/100,s=c.div(d.mul(c).plus(1)).mul(A),m=xa(e,Pa(s,i)),p=m.gte(r.targetMultiplier)?new k(r.targetMultiplier):new k(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(p)}]},payoutMultiplier:p,outputs:{randomMultiplier:m,result:n.values},randomValues:n}}}import dt from"big.js";var Zt=(t,a)=>{if(a<0||t<0||a>t)throw new Error("Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.");if(a>t-a)a=t-a;let r=1;for(let n=1;n<=a;n++)r=r*(t-n+1)/n;return r};class dn extends B{constructor(){super("MINES")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,edge:a,gameInputs:r}){if(r.minesCount<=0||r.minesCount>24)throw new Error("Must select between 1 and 24 mines.");if(r.selectedTiles.length>25-r.minesCount)throw new Error("Cannot select more tiles than available safe tiles (total tiles minus mines).");let e=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),i=e.values.some((p)=>r.selectedTiles.includes(p)),l=r.hasCashedOut||i,d=(100-a)/100,A=new dt(Zt(25-r.minesCount,r.selectedTiles.length)).div(new dt(Zt(25,r.selectedTiles.length))),m=r.hasCashedOut&&!i?new dt(d).div(A):new dt(0);return{isFinished:l,payout:{legs:[{amount:r.betAmount.mul(m)}]},payoutMultiplier:m,outputs:{result:e.values},randomValues:e}}}import{Big as En}from"big.js";var ba;((n)=>{n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(ba||={});var Lc=[8,9,10,11,12,13,14,15,16],sn={LOW_RISK:{8:[6,2.1,1.1,1,0.5,1,1.1,2.1,6],9:[6,2,1.6,1,0.7,0.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,0.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,0.7,0.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,0.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,0.9,0.7,0.7,0.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,0.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,0.7,0.7,1,1.1,1.5,2,3,8,15],16:[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:{8:[13,3,1.3,0.7,0.4,0.7,1.3,3,13],9:[18,4,1.7,0.9,0.5,0.5,0.9,1.7,4,18],10:[22,5,2,1.4,0.6,0.4,0.6,1.4,2,5,22],11:[24,6,3,1.8,0.7,0.5,0.5,0.7,1.8,3,6,24],12:[33,11,4,2,1.1,0.6,0.3,0.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,0.7,0.4,0.4,0.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,0.5,0.2,0.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,0.5,0.3,0.3,0.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,0.5,0.3,0.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,0.3,0.2,0.3,1.5,4,29],9:[43,7,2,0.6,0.2,0.2,0.6,2,7,43],10:[76,10,3,0.9,0.3,0.2,0.3,0.9,3,10,76],11:[120,13.9,5.2,1.4,0.4,0.2,0.2,0.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,0.7,0.2,0.2,0.2,0.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,0.2,0.2,0.2,0.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,0.3,0.2,0.2,0.2,0.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,0.5,0.2,0.2,0.2,0.2,0.5,3,8,27,82.8,620],16:[1000,129.9,26.1,9,4,2,0.2,0.2,0.2,0.2,0.2,2,4,9,26.1,129.9,1000]}},An={LOW_RISK:{8:[6,1.9,1.1,1,0.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,0.7,0.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,0.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,0.7,0.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,0.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,0.9,0.7,0.7,0.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,0.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,0.7,0.7,1,1.1,1.4,2,2.8,7.6,15],16:[16,9,1.7,1.2,1.3,1.2,1.1,1,0.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,0.6,0.4,0.6,1.4,3.2,13],9:[18,3.7,1.7,0.9,0.5,0.5,0.9,1.7,3.7,18],10:[22,5,1.9,1.4,0.6,0.4,0.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,0.7,0.5,0.5,0.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,0.6,0.3,0.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,0.5,0.2,0.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,0.5,0.3,0.3,0.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,0.5,0.3,0.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,0.3,0.2,0.3,1.5,3.8,29],9:[43,7.1,1.9,0.6,0.2,0.2,0.6,1.9,7.1,43],10:[76,9.9,2.9,0.9,0.3,0.2,0.3,0.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,0.4,0.2,0.2,0.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,0.7,0.2,0.2,0.2,0.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,0.2,0.2,0.2,0.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,0.3,0.2,0.2,0.2,0.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,0.5,0.2,0.2,0.2,0.2,0.5,3,7.7,26.8,82.3,620],16:[1000,129.8,25.2,8.6,4,2,0.2,0.2,0.2,0.2,0.2,2,4,8.6,25.2,129.8,1000]}},pn={LOW_RISK:{8:[6,2.2,1.1,1,0.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,0.7,0.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,0.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,0.7,0.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,0.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,0.9,0.7,0.7,0.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,0.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,0.7,0.7,1,1.1,1.3,2,2.5,7.9,15],16:[16,8.9,1.9,1.4,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,0.7,0.3,0.7,1.2,3.5,13],9:[18,3.8,1.6,0.9,0.5,0.5,0.9,1.6,3.8,18],10:[22,5.2,2,1.3,0.6,0.4,0.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,0.7,0.5,0.5,0.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,0.6,0.3,0.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,0.7,0.4,0.4,0.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,0.5,0.2,0.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,0.5,0.3,0.3,0.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,0.5,0.3,0.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,0.3,0.2,0.3,1.4,4,29],9:[43,7.3,2,0.5,0.2,0.2,0.5,2,7.3,43],10:[76,9.8,2.8,0.9,0.3,0.2,0.3,0.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,0.4,0.2,0.2,0.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,0.2,0.2,0.2,0.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,0.5,0.2,0.2,0.2,0.2,0.5,2.9,7.7,26.6,81.9,620],16:[1000,130,24.9,8.4,3.9,2,0.2,0.2,0.2,0.2,0.2,2,3.9,8.4,24.9,130,1000]}},Bn={LOW_RISK:{8:[6,2,1.1,1,0.4,1,1.1,2,6],9:[6,1.9,1.4,1,0.7,0.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,0.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,0.7,0.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,0.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,0.9,0.6,0.6,0.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,0.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,0.6,0.6,1,1.2,1.4,2,2.9,8,15],16:[16,9.1,2.2,1.4,1.2,1.2,1.1,1,0.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,0.7,0.4,0.7,1.2,2.9,13],9:[18,3.5,1.6,0.9,0.5,0.5,0.9,1.6,3.5,18],10:[22,4.7,2,1.3,0.6,0.4,0.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,0.7,0.5,0.5,0.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,0.6,0.3,0.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,0.7,0.4,0.4,0.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,0.5,0.2,0.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,0.5,0.3,0.3,0.5,1.3,2.7,4.9,10.7,17.7,88],16:[110,39.7,9.6,4.8,2.8,1.4,1,0.5,0.3,0.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,0.3,0.2,0.3,1.4,3.9,29],9:[43,6.9,1.8,0.6,0.2,0.2,0.6,1.8,6.9,43],10:[76,9.8,2.7,0.9,0.3,0.2,0.3,0.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,0.4,0.2,0.2,0.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,0.7,0.2,0.2,0.2,0.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,0.2,0.2,0.2,0.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,0.3,0.2,0.2,0.2,0.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,0.5,0.2,0.2,0.2,0.2,0.5,2.8,7.8,26.1,80.6,620],16:[1000,129.7,24.7,8.2,3.8,2,0.2,0.2,0.2,0.2,0.2,2,3.8,8.2,24.7,129.7,1000]}},mn={LOW_RISK:{8:[5,1.8,1,1,0.4,1,1,1.8,5],9:[5,1.7,1.2,1,0.7,0.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,0.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,0.7,0.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,0.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,0.9,0.6,0.6,0.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,0.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,0.6,0.6,1,1,1.4,1.9,2.9,7.3,15],16:[16,8.7,2,1.5,1.3,1,1.1,1,0.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,0.7,0.4,0.7,1.1,2.6,13],9:[17,3.3,1.4,0.9,0.5,0.5,0.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,0.6,0.4,0.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,0.7,0.5,0.5,0.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,0.6,0.2,0.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,0.7,0.4,0.4,0.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,0.5,0.2,0.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,0.5,0.3,0.3,0.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,0.5,0.3,0.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,0.3,0.2,0.3,1.4,3.3,28],9:[42,6.7,1.6,0.6,0.2,0.2,0.6,1.6,6.7,42],10:[74,9.6,2.6,0.9,0.3,0.1,0.3,0.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,0.4,0.2,0.2,0.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,0.7,0.2,0.2,0.2,0.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,0.2,0.2,0.2,0.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,0.3,0.2,0.2,0.2,0.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,0.5,0.2,0.2,0.2,0.2,0.5,2.6,7.4,24.9,76.9,600],16:[1000,122,24.5,8,3.7,1.8,0.2,0.2,0.2,0.2,0.2,1.8,3.7,8,24.5,122,1000]}},ja=new P(new Map([[1,sn],[2,An],[3,pn],[4,Bn],[8,mn]]));class yn extends B{constructor(){super("PLINKO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){if(a.numberOfRows%1>0)throw new Error("Number of rows must be an integer");if(a.numberOfRows<8||a.numberOfRows>16)throw new Error("Number of rows must be between 8 and 16");let n=a.numberOfRows,e=ja.getMultipliers(r)[a.riskLevel][n],i=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),d=i.values.reduce((m,p)=>m+p,0),A=e[d];if(A===void 0)throw new Error(`No payout found for end position ${d}`);let s=En(A);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:i.values},randomValues:i}}}import{Big as pt}from"big.js";var Gt=[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],Ta=[37,...Gt],Ra=[[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]],_a=[[0,1],[0,37],[3,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]],Na=[[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]],wa=[[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]],Va=[[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]],ka=[[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]],Ia=[0,1,2,3,37],Ua=[[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]],Za=[[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]],I;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(I||={});var U;((r)=>{r.RED="RED";r.BLACK="BLACK"})(U||={});var Z;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(Z||={});var G;((n)=>{n.TOP="TOP";n.MIDDLE="MIDDLE";n.BOTTOM="BOTTOM"})(G||={});var M;((n)=>{n.FIRST="FIRST";n.SECOND="SECOND";n.THIRD="THIRD"})(M||={});var Mt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Mt||={});var q=2.7,X=5.3;var st=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw u.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&Q(a.value)))throw u.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&fn(a.values)))throw u.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Sn(a.values)))throw u.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&On(a.values)))throw u.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Hn(a.values)))throw u.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.parity)))throw u.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.color)))throw u.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.half)))throw u.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.column)))throw u.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.dozen)))throw u.createValidationError("Invalid dozen bet.")},Q=(t)=>{return Gt.includes(t)},fn=(t)=>{if(t.length!==2)return!1;if(!t.every(Q))return!1;return Ra.some(([a,r])=>a===t[0]&&r===t[1])},Sn=(t)=>{if(t.length!==3)return!1;if(!t.every(Q))return!1;return Na.some(([a,r,n])=>a===t[0]&&r===t[1]&&n===t[2])},On=(t)=>{if(t.length!==4)return!1;if(!t.every(Q))return!1;return Va.some(([a,r,n,o])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3])},Hn=(t)=>{if(t.length!==6)return!1;if(!t.every(Q))return!1;return Ua.some(([a,r,n,o,c,e])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3]&&c===t[4]&&e===t[5])};var At=(t)=>{if(t.straightBets.length===0&&t.splitBets.length===0&&t.streetBets.length===0&&t.cornerBets.length===0&&t.basketBets.length===0&&t.doubleStreetBets.length===0&&t.parityBets.length===0&&t.colorBets.length===0&&t.halfBets.length===0&&t.columnBets.length===0&&t.dozenBets.length===0)throw u.createValidationError("Must place at least a single bet.");if(!t.straightBets.every((a)=>a.amount.gte(0)&&W(a.value)))throw u.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Dn(a.values)))throw u.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&hn(a.values)))throw u.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Cn(a.values)))throw u.createValidationError("Invalid corner bet.");if(!t.basketBets.every((a)=>a.amount.gte(0)))throw u.createValidationError("Invalid basket bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&xn(a.values)))throw u.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(I).includes(a.parity)))throw u.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(U).includes(a.color)))throw u.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.half)))throw u.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.column)))throw u.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.dozen)))throw u.createValidationError("Invalid dozen bet.")},W=(t)=>{return Ta.includes(t)};function Dn(t){if(t.length!==2)return!1;if(!t.every(W))return!1;return _a.some(([a,r])=>a===t[0]&&r===t[1])}var hn=(t)=>{if(t.length!==3)return!1;if(!t.every(W))return!1;return wa.some(([a,r,n])=>a===t[0]&&r===t[1]&&n===t[2])},Cn=(t)=>{if(t.length!==4)return!1;if(!t.every(W))return!1;return ka.some(([a,r,n,o])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3])},xn=(t)=>{if(t.length!==6)return!1;if(!t.every(W))return!1;return Za.some(([a,r,n,o,c,e])=>a===t[0]&&r===t[1]&&n===t[2]&&o===t[3]&&c===t[4]&&e===t[5])};var Pn=(t,a)=>{let r=a===q&&t.type==="EUROPEAN",n=a===X&&t.type==="AMERICAN";if(!r&&!n)throw u.createValidationError(`Attempted to play ${t.type} roulette on edge ${a}`)},Ga=(t,a)=>{if(Pn(t,a),t.type==="EUROPEAN")st(t.inputs);else At(t.inputs)};var bn={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},jn=[3,6,9,12,15,18,21,24,27,30,33,36],Tn=[2,5,8,11,14,17,20,23,26,29,32,35],Rn=[1,4,7,10,13,16,19,22,25,28,31,34],_n=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Nn=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];class Ft extends B{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),n=r.value,o=this.determineBetOutcomes(a,n),{payoutMultiplier:c,payout:e}=this.getPayoutDetails(a,n);return{outputs:{betOutcomes:o,result:r.values},payout:e,payoutMultiplier:c,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.getBetTotals(t),n=this.calculateTotalBetAmount(r),o={legs:this.calculatePayoutLegs(t,a)},c=R(o);return{payoutMultiplier:n.gt(0)?c.div(n):new pt(0),payout:o}}determineBetOutcomes(t,a){let r={},n={};for(let o of Object.keys(t)){let c=t[o],e=this.betPredicates[o],{winning:i,losing:l}=this.partitionBets(c,e,a);r[o]=i,n[o]=l}return{winningBets:r,losingBets:n}}calculateTotalAmount(t){return t.reduce((a,r)=>a.plus(r.amount),new pt(0))}isWinningStraightBet(t,a){return t.value===a}isWinningSplitBet(t,a){return t.values.some((r)=>r===a)}isWinningStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningCornerBet(t,a){return t.values.some((r)=>r===a)}isWinningDoubleStreetBet(t,a){return t.values.some((r)=>r===a)}isWinningColorBet(t,a){let r=t;return _n.includes(a)&&r.color==="RED"||Nn.includes(a)&&r.color==="BLACK"}isWinningHalfBet(t,a){let r=t;if(a>0&&a<=18&&r.half==="LOW")return!0;if(a>18&&a<=36&&r.half==="HIGH")return!0;return!1}isWinningColumnBet(t,a){let r=t;return jn.includes(a)&&r.column==="TOP"||Tn.includes(a)&&r.column==="MIDDLE"||Rn.includes(a)&&r.column==="BOTTOM"}isWinningDozenBet(t,a){let r=t;if(a>0&&a<=12&&r.dozen==="FIRST")return!0;if(a>12&&a<=24&&r.dozen==="SECOND")return!0;if(a>24&&a<=36&&r.dozen==="THIRD")return!0;return!1}isWinningParityBet(t,a){let r=t;if(a===0||a===37)return!1;let n=a%2===0?"EVEN":"ODD";return r.parity===n}getBetTotals(t){let a={};for(let r of Object.keys(t))a[r]=this.calculateTotalAmount(t[r]);return a}calculateTotalBetAmount(t){return Object.values(t).reduce((a,r)=>a.plus(r),new pt(0))}partitionBets(t,a,r){return{winning:t.filter((n)=>a(n,r)),losing:t.filter((n)=>!a(n,r))}}calculatePayoutLegs(t,a){return Object.keys(t).flatMap((r)=>{let n=bn[r],o=this.betPredicates[r];return t[r].map((c)=>{if(!o(c,a))return{amount:new pt("0")};return{amount:c.amount.mul(n||0)}})})}}class Ma extends Ft{maxNumber=36;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[q]}validateInputs(t){st(t)}}class Fa extends Ft{maxNumber=37;betPredicates={straightBets:this.isWinningStraightBet,splitBets:this.isWinningSplitBet,streetBets:this.isWinningStreetBet,cornerBets:this.isWinningCornerBet,basketBets:this.isWinningBasketBet,doubleStreetBets:this.isWinningDoubleStreetBet,parityBets:this.isWinningParityBet,colorBets:this.isWinningColorBet,halfBets:this.isWinningHalfBet,columnBets:this.isWinningColumnBet,dozenBets:this.isWinningDozenBet};get supportedEdgeConfigurations(){return[X]}validateInputs(t){At(t)}isWinningBasketBet(t,a){return Ia.some((r)=>r===a)}}class Ja extends B{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Ma,this.americanGame=new Fa}get supportedEdgeConfigurations(){return[q,X]}getBetAmount(t){switch(t.type){case"AMERICAN":return this.americanGame.getBetAmount(t.inputs);case"EUROPEAN":return this.europeanGame.getBetAmount(t.inputs);default:throw new Error("Unhandled roulette type")}}determineGameResult(t){let{gameInputs:a,...r}=t;if(Ga(a,t.edge),a.type==="EUROPEAN"){let c=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:e}=c.outputs;return{...c,outputs:{type:"european",betOutcomes:e,result:c.outputs.result}}}let n=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:o}=n.outputs;return{...n,outputs:{type:"american",betOutcomes:o,result:n.outputs.result}}}}var ji=(t)=>{return new Ja().getBetAmount(t)};import{Big as Zn}from"big.js";var g;((n)=>{n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(g||={});var L;((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"})(L||={});var wn={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}}},Vn={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}}},kn={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}}},In={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}}},Un={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}}},Ya=new P(new Map([[1,wn],[2,Vn],[3,kn],[4,In],[8,Un]]));var $a={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 Gn extends B{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(t){return t.betAmount}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(L).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(g).includes(a.riskLevel))throw new Error("Invalid risk level");let o=Ya.getMultipliers(r)[a.riskLevel];if(o===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let c=o[a.segments];if(c===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let e=$a[a.riskLevel];if(e===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let i=e[a.segments];if(i===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let l=t.getRandomInt({min:0,max:i.length-1}),d=i[l.value];if(d===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${l.value}`);let A=c[d];if(A===void 0)throw new Error(`No payout found for picked segment ${d}`);let s=new Zn(A);return{isFinished:!0,payout:{legs:[{amount:a.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:l.values},randomValues:l}}}export{Ga as validateRouletteGameInputs,te as validateAdvancedDiceInputs,R as sumPayout,an as rtp99Multipliers,rn as rtp98Multipliers,nn as rtp97Multipliers,en as rtp96Multipliers,on as rtp92Multipliers,ja as plinkoMultipliers,Zt as nCr,Ca as kenoMultipliers,ha as isTileCount,Kr as hasDiceWon,Cr as hasBlitzWon,Go as getMaxMultiplierForDifficulty,No as getBlitzDefaults,qr as diamondsMultipliers,ji as calculateRouletteBetAmount,Lr as calculateDiceWinChance,xr as calculateBlitzWinChance,Wt as calculateBaccaratBetAmount,$t as calculateAdvancedDiceWinChance,Pa as bigMin,xa as bigMax,Ka as advancedDiceIsWithinBoundsInclusive,mt as advancedDiceIsWithinBoundsExclusive,va as advancedDiceGetInclusiveBoundsRange,Et as advancedDiceGetExclusiveBoundsRange,L as WheelSegments,g as WheelRiskLevel,Gn as Wheel,dr as WIN_MULTIPLIER,me as VALID_SUITS,Ee as VALID_RANKS,Na as VALID_EUROPEAN_STREETS,Gt as VALID_EUROPEAN_STRAIGHTS,Ra as VALID_EUROPEAN_SPLITS,Ua as VALID_EUROPEAN_DOUBLE_STREETS,Va as VALID_EUROPEAN_CORNERS,wa as VALID_AMERICAN_STREETS,Ta as VALID_AMERICAN_STRAIGHTS,_a as VALID_AMERICAN_SPLITS,Za as VALID_AMERICAN_DOUBLE_STREETS,ka as VALID_AMERICAN_CORNERS,ht as ThreeCardBonusType,jn as TOP_COLUMN,tn as TILE_COUNTS,vt as THREE_CARD_BONUS_PAYOUTS,B as SingleActionGame,V as SPLIT_BET_SIZE_FACTOR,Mt as RouletteType,Ja as Roulette,tr as RollType,ut as RandomValuePool,_n as RED_NUMBERS,at as RANDOM_MIN_VALUE,rt as RANDOM_MAX_VALUE,ba as PlinkoRiskLevel,yn as Plinko,I as Parity,Dt as PairBonusType,sr as PUSH_MULTIPLIER,Lc as PLINKO_ROW_COUNTS,bn as PAYOUT_MULTIPLIERS,Kt as PAIR_BONUS_PAYOUTS,S as OrigamiGame,C as MultiplierCalculator,Tt as MultiActionGame,dn as Mines,Xa as MIN_WIN_CHANCE,Tn as MIDDLE_COLUMN,Qa as MAX_WIN_CHANCE,xt as MAX_CARDS_PER_ROUND,ln as Limbo,Ar as LOSE_MULTIPLIER,Da as KenoRiskLevel,un as Keno,Ot as InsuranceOutcome,bt as INSURANCE_WIN_MULTIPLIER,Pt as INSURANCE_BET_SIZE_FACTOR,Z as Half,za as GameErrorCode,u as GameError,Lt as FACE_CARD_VALUE,Ma as EuropeanRoulette,q as EUROPEAN_HOUSE_EDGE,Jt as EFFECTIVE_RANGE,M as Dozen,Wr as DiceDirection,vr as Dice,Mr as DiamondsResultType,Qr as Diamonds,Ir as Darts,_ as DOUBLE_DOWN_BET_SIZE_FACTOR,Ha as DICE_MIN_ROLL,Ut as DICE_MAX_ROLL,gr as DICE_EFFECTIVE_RANGE,gt as DEALER_STAND_VALUE,fa as DARTS_MIN_VALUE,Vt as DARTS_MAX_VALUE,Sa as DARTS_DIFFICULTY_LEVEL,kt as DARTS_BOARD_CONFIGS,G as Column,U as Color,De as CARDS_PER_SUIT,Pr as Blitz,St as BlackjackOutcome,Ht as BlackjackActionType,hr as Blackjack,er as BaccaratOutcome,or as BaccaratBetType,ur as Baccarat,Ct as BUST_VALUE,Rn as BOTTOM_COLUMN,Ea as BLITZ_RANDOM_NUMBER_COUNT,Ba as BLITZ_MIN_CARD_RANGE,ma as BLITZ_MAX_CARD_RANGE,$ as BLITZ_CARD_COUNT,Nn as BLACK_NUMBERS,D as BLACKJACK_VALUE,lr as BLACKJACK_MULTIPLIER,ct as BASE_PAYOUT_MULTIPLIERS,Fa as AmericanRoulette,ar as AdvancedDice,X as AMERICAN_HOUSE_EDGE,Ia as AMERICAN_BASKET,jt as ACE_SOFT_BONUS};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betorigami/game-calculations",
3
- "version": "8.0.1",
3
+ "version": "8.1.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",