@betorigami/game-calculations 6.0.2 → 8.0.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 +1 -1
- package/dist/index.d.ts +69 -8
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Xr=Object.create;var{getPrototypeOf:Qr,defineProperty:g,getOwnPropertyNames:ba,getOwnPropertyDescriptor:gr}=Object,ja=Object.prototype.hasOwnProperty;var H=(t,a,r)=>{r=t!=null?Xr(Qr(t)):{};let e=a||!t||!t.__esModule?g(r,"default",{value:t,enumerable:!0}):r;for(let n of ba(t))if(!ja.call(e,n))g(e,n,{get:()=>t[n],enumerable:!0});return e},Pa=new WeakMap,Wr=(t)=>{var a=Pa.get(t),r;if(a)return a;if(a=g({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function")ba(t).map((e)=>!ja.call(a,e)&&g(a,e,{get:()=>t[e],enumerable:!(r=gr(t,e))||r.enumerable}));return Pa.set(t,a),a};var Lr=(t,a)=>{for(var r in a)g(t,r,{get:a[r],enumerable:!0,configurable:!0,set:(e)=>a[r]=()=>e})};var Le={};Lr(Le,{validateRouletteGameInputs:()=>Ha,validateAdvancedDiceInputs:()=>ae,rtp99Multipliers:()=>Pr,rtp98Multipliers:()=>br,rtp97Multipliers:()=>jr,rtp96Multipliers:()=>Tr,rtp92Multipliers:()=>Rr,plinkoMultipliers:()=>ua,nCr:()=>Nt,kenoMultipliers:()=>ia,isTileCount:()=>oa,hasDiceWon:()=>hr,hasBlitzWon:()=>sr,getMaxMultiplierForDifficulty:()=>He,getBlitzDefaults:()=>pe,diamondsMultipliers:()=>fr,calculateRouletteBetAmount:()=>ze,calculateDiceWinChance:()=>Dr,calculateBlitzWinChance:()=>pr,calculateBaccaratBetAmount:()=>Ya,calculateAdvancedDiceWinChance:()=>Gt,bigMin:()=>la,bigMax:()=>ca,advancedDiceIsWithinBoundsInclusive:()=>wa,advancedDiceIsWithinBoundsExclusive:()=>pt,advancedDiceGetInclusiveBoundsRange:()=>Va,advancedDiceGetExclusiveBoundsRange:()=>At,WheelSegments:()=>Q,WheelRiskLevel:()=>X,Wheel:()=>qr,WIN_MULTIPLIER:()=>qa,VALID_SUITS:()=>re,VALID_RANKS:()=>ee,VALID_EUROPEAN_STREETS:()=>Ba,VALID_EUROPEAN_STRAIGHTS:()=>wt,VALID_EUROPEAN_SPLITS:()=>pa,VALID_EUROPEAN_DOUBLE_STREETS:()=>Oa,VALID_EUROPEAN_CORNERS:()=>Ea,VALID_AMERICAN_STREETS:()=>ma,VALID_AMERICAN_STRAIGHTS:()=>sa,VALID_AMERICAN_SPLITS:()=>Aa,VALID_AMERICAN_DOUBLE_STREETS:()=>Sa,VALID_AMERICAN_CORNERS:()=>ya,ThreeCardBonusType:()=>Ht,TOP_COLUMN:()=>kr,TILE_COUNTS:()=>xr,THREE_CARD_BONUS_PAYOUTS:()=>$t,SingleActionGame:()=>A,SPLIT_BET_SIZE_FACTOR:()=>V,RouletteType:()=>Vt,Roulette:()=>xa,RollType:()=>Ia,RandomValuePool:()=>et,RED_NUMBERS:()=>Fr,RANDOM_MIN_VALUE:()=>W,RANDOM_MAX_VALUE:()=>L,PlinkoRiskLevel:()=>da,Plinko:()=>Ur,Parity:()=>Z,PairBonusType:()=>St,PUSH_MULTIPLIER:()=>Xa,PLINKO_ROW_COUNTS:()=>Re,PAYOUT_MULTIPLIERS:()=>Zr,PAIR_BONUS_PAYOUTS:()=>Yt,OrigamiGame:()=>f,MultiplierCalculator:()=>P,MultiActionGame:()=>Pt,Mines:()=>Vr,MIN_WIN_CHANCE:()=>_a,MIDDLE_COLUMN:()=>Gr,MAX_WIN_CHANCE:()=>Na,MAX_CARDS_PER_ROUND:()=>ht,Limbo:()=>wr,LOSE_MULTIPLIER:()=>Qa,KenoRiskLevel:()=>na,Keno:()=>Nr,InsuranceOutcome:()=>ft,INSURANCE_WIN_PAYOUT:()=>Ct,INSURANCE_BET_SIZE_FACTOR:()=>J,INSURANCE_BET_MULTIPLIER:()=>ie,Half:()=>G,GameErrorCode:()=>Ta,GameError:()=>l,FACE_CARD_VALUE:()=>Jt,EuropeanRoulette:()=>ha,EUROPEAN_HOUSE_EDGE:()=>z,EFFECTIVE_RANGE:()=>Zt,Dozen:()=>F,DiceDirection:()=>Sr,Dice:()=>Cr,DiamondsResultType:()=>yr,Diamonds:()=>Or,Darts:()=>mr,DOUBLE_DOWN_BET_SIZE_FACTOR:()=>j,DICE_MIN_ROLL:()=>ea,DICE_MAX_ROLL:()=>_t,DICE_EFFECTIVE_RANGE:()=>Hr,DEALER_STAND_VALUE:()=>Ft,DARTS_MIN_VALUE:()=>ta,DARTS_MAX_VALUE:()=>jt,DARTS_DIFFICULTY_LEVEL:()=>aa,DARTS_BOARD_CONFIGS:()=>Tt,Column:()=>M,Color:()=>k,CARDS_PER_SUIT:()=>ce,Blitz:()=>Ar,BlackjackOutcome:()=>yt,BlackjackActionType:()=>Ot,Blackjack:()=>ur,BaccaratOutcome:()=>Fa,BaccaratBetType:()=>Ja,Baccarat:()=>$a,BUST_VALUE:()=>Dt,BOTTOM_COLUMN:()=>Mr,BLITZ_RANDOM_NUMBER_COUNT:()=>Kt,BLITZ_MIN_CARD_RANGE:()=>Wt,BLITZ_MAX_CARD_RANGE:()=>Lt,BLITZ_CARD_COUNT:()=>Y,BLACK_NUMBERS:()=>Jr,BLACKJACK_VALUE:()=>D,BLACKJACK_MULTIPLIER:()=>za,BASE_PAYOUT_MULTIPLIERS:()=>K,AmericanRoulette:()=>Ca,AdvancedDice:()=>Ua,AMERICAN_HOUSE_EDGE:()=>q,AMERICAN_BASKET:()=>fa,ACE_SOFT_BONUS:()=>xt});module.exports=Wr(Le);var Ta;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(Ta||={});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;((B)=>{B.DICE="DICE";B.MINES="MINES";B.KENO="KENO";B.LIMBO="LIMBO";B.ADVANCED_DICE="ADVANCED_DICE";B.BACCARAT="BACCARAT";B.DIAMONDS="DIAMONDS";B.PLINKO="PLINKO";B.ROULETTE="ROULETTE";B.WHEEL="WHEEL";B.BLACKJACK="BLACKJACK";B.BLITZ="BLITZ";B.DARTS="DARTS"})(f||={});var Ra=require("@betorigami/guard");class A{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return Ra.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=H(require("big.js"));class P{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,L=1e4,Zt=L-W+1,_a=0.01,Na=98,Kr=(t)=>{if(t<W)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${W}`)},vr=(t)=>{if(t>L)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${L}`)},st=(t)=>{if(Kr(t.lower),vr(t.upper),t.lower>=t.upper)throw l.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},te=(t,a)=>{let[r,e]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>e.lower)throw l.createValidationError("Bounds must not overlap")},wa=(t,a)=>a>=t.lower&&a<=t.upper,Va=(t)=>t.upper-t.lower+1,pt=(t,a)=>a>t.lower&&a<t.upper,At=(t)=>t.upper-t.lower-1,Ia;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Ia||={});var Gt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return st(t.bounds),At(t.bounds);case"ROLL_OUTSIDE":return st(t.bounds),Zt-Va(t.bounds);case"ROLL_BETWEEN_TWO":return st(t.firstBounds),st(t.secondBounds),te(t.firstBounds,t.secondBounds),At(t.firstBounds)+At(t.secondBounds)}})(),e=kt.Big(r).div(Zt).mul(100);if(e.lt(_a))throw l.createValidationError("Win chance too low");if(e.gt(Na))throw l.createValidationError("Win chance too high");return e},ae=(t)=>{Gt(t)};class Ua extends A{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=Gt(r),n=t.getRandomInt({min:W,max:L}),o=n.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(r.mode){case"ROLL_BETWEEN":return pt(r.bounds,o);case"ROLL_OUTSIDE":return!wa(r.bounds,o);case"ROLL_BETWEEN_TWO":return pt(r.firstBounds,o)||pt(r.secondBounds,o)}})()?P.withWinChance(a,e):new kt.Big(0),outputs:{result:n.values},randomValues:n}}}var w=H(require("big.js"));var Et=require("@betorigami/guard");var Za=0,ka=51,Bt=Array.from({length:52},(t,a)=>a),Ga=["Spades","Hearts","Diamonds","Clubs"],mt=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Ma=["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=Ga[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 re=["Clubs","Diamonds","Hearts","Spades"],ee=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],ne={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"},Fa;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(Fa||={});var Ja;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(Ja||={});var oe={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},Ya=(t)=>{return new w.default(0).add(t.bets.reduce((r,e)=>r.add(e.amount),new w.default(0)))};class $a extends A{constructor(){super("BACCARAT")}get supportedEdgeConfigurations(){return[1]}determineGameResult({generator:t,gameInputs:a}){this.validateGameInputs(a);let r=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),e=r.values,n=e.slice(0,3),o=e.slice(3,6),i=[],c=0;for(let y of n.slice(0,2)){let x=this.mapRandomValueToCard(y),dt=this.mapRandomValueToCardValue(y);i.push(x),c=(c+dt)%10}let u=[],d=0;for(let y of o.slice(0,2)){let x=this.mapRandomValueToCard(y),dt=this.mapRandomValueToCardValue(y);u.push(x),d=(d+dt)%10}if(!this.isNaturalWin(c,d)){let y=this.shouldDrawThirdPlayerCard(c),x=null;if(y)x=this.mapRandomValueToCardValue(n[2]),i.push(this.mapRandomValueToCard(n[2])),c=(c+x)%10;if(this.shouldDrawThirdBankerCard(d,x))u.push(this.mapRandomValueToCard(o[2])),d=(d+this.mapRandomValueToCardValue(o[2]))%10}let s;if(c===d)s="TIE";else s=c>d?"PLAYER_WIN":"BANKER_WIN";let p=Ya(a),{betType:E,multiplier:B}=oe[s],_=new w.default(0);if(_=_.add(a.bets.filter((y)=>y.type===E).reduce((y,x)=>y.add(x.amount.mul(B)),new w.default(0))),s==="TIE")_=_.add(a.bets.filter((y)=>y.type==="PLAYER"||y.type==="BANKER").reduce((y,x)=>y.add(x.amount),new w.default(0)));return{isFinished:!0,payoutMultiplier:p.gt(0)?_.div(p):new w.default(0),outputs:{playerCards:i,playerHandValue:c,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:ne[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;((c)=>{c.START="START";c.HIT="BLACKJACK_HIT";c.STAND="BLACKJACK_STAND";c.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";c.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";c.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";c.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;((i)=>{i.SUITED_TRIPS="SUITED_TRIPS";i.STRAIGHT_FLUSH="STRAIGHT_FLUSH";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.STRAIGHT="STRAIGHT";i.FLUSH="FLUSH";i.LOSS="LOSS"})(Ht||={});var za=2.5,qa=2,Xa=1,Qa=0,Ft=17,Dt=21,D=21,ht=63,ie=1.5,J=0.5,Ct=1.5,j=1,V=1,ce=13,xt=10,Jt=10,K={PLAYER_BLACKJACK:za,WIN:qa,PUSH:Xa,LOSE:Qa},Yt={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},$t={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var R=H(require("big.js")),m=require("@betorigami/guard"),lr=require("@xstate/store");var ga=require("@betorigami/guard");class O extends N{get numericRank(){if(Ma.includes(this.rank))return Jt;return mt.indexOf(this.rank)+1}static fromValue(t){return ga.Guard.against(!Bt.includes(t),`Invalid card value: ${t}`),new O(t)}}class v{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,e)=>r+e.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)=>O.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=O.fromValue(t),this.holeCard=O.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 I extends tt{static withInitialDeal(t){return new I(t)}addDrawnCards(t){return new I([...this.rawValues,...t])}}var rt=require("@betorigami/guard");class et{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 et(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 zt=require("@betorigami/guard"),Wa=H(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 e=this.createGameStore(),n=this.generateRandomValues(t),o=n.toMultipleRandomValues();for(let u of r)e.send({...u.playerArgument,randomValuePool:n});let i=r[r.length-1];if(i)zt.Guard.against(!Wa.default(i.state,this.toExternalState(e.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");e.send({...a,randomValuePool:n});let c=e.getSnapshot().context;return{playerArgument:c.playerArgument,state:this.toExternalState(c.state),config:c.config,additionalBetAmount:c.additionalBetAmount,proof:{proofHash:o.proofHash,proofString:o.proofString}}}validateEdge(t){let a=this.supportedEdgeConfigurations.includes(t);zt.Guard.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}}var h=H(require("big.js"));var bt=require("@betorigami/guard");var La=(t)=>{let a=t.pairBonus!==null?h.default(t.pairBonus.betAmount).mul(t.pairBonus.payoutMultiplier):h.default(0),r=t.threeCardBonus!==null?h.default(t.threeCardBonus.betAmount).mul(t.threeCardBonus.payoutMultiplier):h.default(0);return a.plus(r)},Ka=(t)=>{let a=t.betAmounts.mainBetAmount,e=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(j):h.default(0),n=t.insuranceOutcome!==void 0?a.mul(J):h.default(0),o=a.plus(e).mul(K[t.outcome]),i=t.insuranceOutcome==="WON"?a.mul(Ct):h.default(0),c=La(t.sideBetResults),u=o.plus(i).plus(c),d=a.plus(n).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);bt.Guard.against(d.eq(0),"Total bet amount cannot be zero");let s=u.div(d);bt.Guard.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let p;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":p=e;break;case"BLACKJACK_BUY_INSURANCE":p=n;break;case"BLACKJACK_SPLIT":p=a.mul(V);break}return{multiplier:s,additionalBetAmount:p}},va=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(j):h.default(0),e=t.splitHandDoubledDown?a.mul(j):h.default(0),n=t.insuranceOutcome!==void 0?a.mul(J):h.default(0),o=a.plus(r).mul(K[t.mainOutcome]),i=a.plus(e).mul(K[t.splitOutcome]),c=t.insuranceOutcome==="WON"?a.mul(Ct):h.default(0),u=La(t.sideBetResults),d=o.plus(i).plus(c).plus(u),s=a.plus(a).plus(n).plus(r).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);bt.Guard.against(s.eq(0),"Total bet amount cannot be zero");let p=d.div(s),E;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":E=a.mul(j);break;case"BLACKJACK_SPLIT":E=a.mul(V);break}return{multiplier:p,additionalBetAmount:E}};var ar=require("@betorigami/guard"),qt=(t)=>t.every((a)=>a===t[0]),tr=(t)=>{let a=[...t].sort((r,e)=>r-e);return a.every((r,e)=>{let n=a[e-1];if(e===0)return!0;return ar.Guard.againstUndefined(n,"Previous value cannot be undefined"),r===n+1})},rr={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},le={...rr,Ace:14},de=(t)=>tr(t.map((a)=>rr[a]))||tr(t.map((a)=>le[a])),er=(t,a)=>{let r=O.fromValue(t),e=O.fromValue(a);if(r.rank!==e.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(Mt[r.suit]===Mt[e.suit])return"COLORED_PAIR";return"MIXED_PAIR"},nr=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Yt[a]}),or=(t,a,r)=>{let e=O.fromValue(t),n=O.fromValue(a),o=O.fromValue(r),i=[e.rank,n.rank,o.rank],c=qt([e.suit,n.suit,o.suit]),u=qt(i),d=de(i);if(qt([t,a,r]))return"SUITED_TRIPS";if(c&&d)return"STRAIGHT_FLUSH";if(u)return"THREE_OF_A_KIND";if(d)return"STRAIGHT";if(c)return"FLUSH";return"LOSS"},ir=(t,a)=>({betAmount:t,result:a,payoutMultiplier:$t[a]});var ue={state:{isFinished:!1,phase:"uninitialised",multiplier:R.default(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},S=(t)=>O.fromValue(t).value;function se(t){m.Guard.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function cr(t){m.Guard.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function Xt(t){m.Guard.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var dr=(t,a)=>{let r=a;while(r.highestHandValue<Ft)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,e=a.highestHandValue;if(r>e)return"WIN";if(r<e)return"LOSE";return"PUSH"},C=(t)=>{let{multiplier:a,additionalBetAmount:r}=Ka({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,multiplier:a,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:r}},Qt=(t)=>{let a=dr(t.randomValuePool,t.dealerHand),r=gt(t.playerHand,a);return C({...t,dealerHand:a,outcome:r})},T=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:dr(t.randomValuePool,t.dealerHand),e=gt(t.mainHand,r),n=gt(t.splitHand,r),{multiplier:o,additionalBetAmount:i}=va({hasSplit:!0,mainOutcome:e,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:e,splitOutcome:n,multiplier:o,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:i}};class ur extends Pt{constructor(t){super("BLACKJACK",t)}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return et.from(t.getRandomIntsWithReplacement({min:Za,max:ka,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,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,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:m.Guard.againstNever(a,"Invalid state received")}}createGameStore(){return lr.createStore({context:ue,on:{START:(t,a)=>{let{state:r}=t;m.Guard.against(r.phase!=="uninitialised","START action requires a fresh game");let e=S(a.randomValuePool.takeOne()),n=S(a.randomValuePool.takeOne()),o=S(a.randomValuePool.takeOne()),i=S(a.randomValuePool.takeOne()),c=I.withInitialDeal([e,n]),u=at.withInitialDeal({upCard:o,holeCard:i}),d={mainBetAmount:R.default(a.mainBetAmount),pairBonusAmount:R.default(a.pairBonusAmount),threeCardBonusAmount:R.default(a.threeCardBonusAmount)},s={pairBonus:R.default(a.pairBonusAmount).gt(0)?nr(a.pairBonusAmount,er(e,n)):null,threeCardBonus:R.default(a.threeCardBonusAmount).gt(0)?ir(a.threeCardBonusAmount,or(e,n,o)):null},p={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:c,dealerHand:u,betAmounts:d,sideBetResults:s},config:{},playerArgument:p};let E={playerHand:c,dealerHand:u,randomValuePool:a.randomValuePool,playerArgument:p,betAmounts:d,sideBetResults:s};if(c.isBlackjack&&u.isBlackjack)return C({...E,outcome:"PUSH"});if(c.isBlackjack)return C({...E,outcome:"PLAYER_BLACKJACK"});if(u.isBlackjack)return C({...E,outcome:"LOSE"});return{state:{...r,isFinished:!1,phase:"in-progress",playerHand:c,dealerHand:u,insuranceOutcome:void 0,betAmounts:d,sideBetResults:s},config:{},playerArgument:p}},BLACKJACK_BUY_INSURANCE:(t,a)=>{let{state:r}=t;cr(r);let{playerHand:e,dealerHand:n,betAmounts:o,sideBetResults:i}=r,c={...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:o,sideBetResults:i};if(e.isBlackjack&&n.isBlackjack)return C({...c,outcome:"PUSH",insuranceOutcome:"WON"});if(e.isBlackjack)return C({...c,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(n.isBlackjack)return C({...c,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...r,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:o.mainBetAmount.mul(J)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;cr(r);let{playerHand:e,dealerHand:n,betAmounts:o,sideBetResults:i}=r,c={playerHand:e,dealerHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:o,sideBetResults:i};if(e.isBlackjack&&n.isBlackjack)return C({...c,outcome:"PUSH"});if(e.isBlackjack)return C({...c,outcome:"PLAYER_BLACKJACK"});if(n.isBlackjack)return C({...c,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(Xt(r),r.phase){case"playing-main-hand":{let e=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===D){if(r.splitHand.highestHandValue===D)return T({...r,mainHand:e,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...r,mainHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let e=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===D)return T({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,splitHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let e=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted)return C({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(e.highestHandValue===D)return Qt({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"in-progress",playerHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:m.Guard.againstNever(r,"Invalid phase for HIT action")}},BLACKJACK_STAND:(t,a)=>{let{state:r}=t;switch(Xt(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 Qt({...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_STAND"}});default:m.Guard.againstNever(r,"Invalid phase for STAND action")}},BLACKJACK_DOUBLE_DOWN:(t,a)=>{let{state:r}=t;switch(Xt(r),r.phase){case"playing-main-hand":{m.Guard.against(r.mainHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]),{betAmounts:n}=r;if(r.splitHand.highestHandValue===D)return T({...r,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:n.mainBetAmount.mul(j)}}case"playing-split-hand":{m.Guard.against(r.splitHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);return T({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{m.Guard.against(r.playerHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted)return C({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return Qt({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:m.Guard.againstNever(r,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(t,a)=>{let{state:r}=t;se(r);let{playerHand:e,betAmounts:n,sideBetResults:o}=r;m.Guard.against(e.cards.length!==2,"Split is only allowed with exactly 2 cards");let i=e.cards[0],c=e.cards[1];m.Guard.againstUndefined(i,"First card is missing"),m.Guard.againstUndefined(c,"Second card is missing"),m.Guard.against(i.rank!==c.rank,"Split requires two cards of the same rank");let u=S(a.randomValuePool.takeOne()),d=S(a.randomValuePool.takeOne()),s=I.withInitialDeal([i.value,u]),p=I.withInitialDeal([c.value,d]);if(i.rank==="Ace")return T({...r,mainHand:s,splitHand:p,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let B=s.highestHandValue===D,_=p.highestHandValue===D;if(B&&_)return T({mainHand:s,splitHand:p,dealerHand:r.dealerHand,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:r.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:n,sideBetResults:o});if(B)return{state:{...r,phase:"playing-split-hand",mainHand:s,splitHand:p,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(V)};return{state:{...r,phase:"playing-main-hand",multiplier:R.default(0),mainHand:s,splitHand:p,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.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],e=t.playerHand.cards[1];if(m.Guard.againstUndefined(r,"First player card is missing"),m.Guard.againstUndefined(e,"Second player card is missing"),r.rank===e.rank)a.push("BLACKJACK_SPLIT")}return a}default:m.Guard.againstNever(t,"Invalid phase for getting valid actions")}}}var $=H(require("big.js")),vt=require("@betorigami/guard");var Wt=0,Lt=51,Y=52,Kt=52;var pe=()=>({minPicks:5,maxPicks:36}),sr=(t)=>t.length===new Set(t).size,pr=(t)=>{let a=$.default(1),r=$.default(Y);for(let e=0;e<t;e+=1)a=a.mul($.default(Y-e).div(r));return a};class Ar extends A{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a,edge:r}){vt.Guard.against(a.pickCount<1||a.pickCount>Y,`pickCount must be between 1 and ${Y}`),vt.Guard.againstNonInteger(a.pickCount,"pickCount must be an integer");let e=t.getRandomIntsWithReplacement({min:Wt,max:Lt,count:Kt}),n=e.values.slice(0,a.pickCount),o=sr(n),i=pr(a.pickCount);return{isFinished:!0,payoutMultiplier:o?P.withMultiplier($.default(1).div(i),r):$.default(0),outputs:{result:e.values,cards:n.map((u)=>new N(u).toDto())},randomValues:e}}}var ta=0,jt=4294967295,aa;((n)=>{n.EASY="EASY";n.MEDIUM="MEDIUM";n.HARD="HARD";n.EXPERT="EXPERT"})(aa||={});var Ae=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Be={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:Ae},me=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Ee={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:me},ye=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],fe={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:ye},Oe=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],Se={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:Oe},He=(t)=>{let a=Tt[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((e,n)=>n>e?n:e)},Tt={EASY:Be,MEDIUM:Ee,HARD:fe,EXPERT:Se};var Rt=require("@betorigami/guard"),Br=H(require("big.js"));class mr extends A{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:ta,max:jt,count:2}),e=r.values[0],n=r.values[1];Rt.Guard.againstUndefined(e,"Random number generator returned no value for clockWiseRotation"),Rt.Guard.againstUndefined(n,"Random number generator returned no value for distanceFromCentre");let o=a.difficultyLevel;return{isFinished:!0,payoutMultiplier:Br.default(De(o,e,n)),outputs:{result:r.values},randomValues:r}}}var De=(t,a,r)=>{let e=Tt[t],{distanceBoundaries:n,multipliers:o}=e;if(r<n.bullseye)return o.bullseye;if(r<n.ringOne)return o.ringOne;if(r<n.ringTwo)return o.ringTwo;if(r<n.ringThree)return he(e,a);return o.ringFour},he=(t,a)=>{let r=t.segments.length,e=Math.floor(a/(jt+1)*r),n=t.segments[e];return Rt.Guard.againstUndefined(n,`Segment index ${e} out of bounds`),t.multipliers.ringThree[n]};var Er=H(require("big.js"));class b{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 yr;((i)=>{i.PAIR="PAIR";i.TWO_PAIR="TWO_PAIR";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.FULL_HOUSE="FULL_HOUSE";i.FOUR_OF_A_KIND="FOUR_OF_A_KIND";i.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(yr||={});var Ce={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},xe={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},Pe={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},be={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},je={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},fr=new b(new Map([[1,Ce],[2,xe],[3,Pe],[4,be],[8,je]])),Te={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Or extends A{constructor(){super("DIAMONDS")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a}){let r=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=fr.getMultipliers(a),n=r.values,o=this.calculatePayoutMultiplier(e,n);return{isFinished:!0,payoutMultiplier:Er.default(o),outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(t,a){let r=new Map;for(let o of a){let i=r.get(o)||0;r.set(o,i+1)}let e=[...r.values()].filter((o)=>o>1),n=this.classifyResult(e);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 e=Te[a];if(e===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return e}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}var ra=H(require("big.js"));var Sr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Sr||={});var ea=0,_t=1e4,Hr=_t-ea+1,Dr=(t)=>{let a=t.direction==="ABOVE"?_t-t.selectedValue:t.selectedValue;return new ra.default(a).div(Hr).mul(100)},hr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class Cr extends A{constructor(){super("DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:ea,max:_t}),n=Dr(r);return{isFinished:!0,payoutMultiplier:hr(r,e.value)?P.withWinChance(a,n):new ra.default(0),outputs:{result:e.values},randomValues:e}}}var _r=H(require("big.js"));var nt=require("@betorigami/guard");var na;((n)=>{n.CLASSIC="CLASSIC";n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(na||={});var xr=[1,2,3,4,5,6,7,8,9,10],oa=(t)=>{return xr.includes(t)};var Pr={[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]}},br={[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]}},jr={[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]}},Tr={[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]}},Rr={[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 b(new Map([[1,Pr],[2,br],[3,jr],[4,Tr],[8,Rr]]));class Nr extends A{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}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 p of r.selectedNumbers)nt.Guard.againstNonInteger(p,()=>l.createValidationError("Only integers can be selected")),nt.Guard.against(p<0||p>39,()=>l.createValidationError("Invalid number selected"));let e=t.getUniqueRandomInts({min:0,max:39,count:10}),n=r.selectedNumbers.filter((p)=>e.values.includes(p)),o=r.selectedNumbers.length;if(!oa(o))throw new Error(`Invalid tile count: ${o}`);let d=ia.getMultipliers(a)[o][r.riskLevel][n.length];if(d===void 0)throw new Error(`No multiplier found for matching tile count ${n.length}`);return{isFinished:!0,payoutMultiplier:new _r.default(d),outputs:{result:e.values},randomValues:e}}}var U=H(require("big.js"));var ca=(t,a)=>{return t.gt(a)?t:a};var la=(t,a)=>{return t.lt(a)?t:a};class wr extends A{constructor(){super("LIMBO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:1,max:4294967295}),n=e.max,o=new U.default(16777216),i=new U.default(1),c=new U.default(1e6),u=e.value,d=new U.default(u-1).div(n),s=(100-a)/100,p=o.div(d.mul(o).plus(1)).mul(s),E=ca(i,la(p,c));return{isFinished:!0,payoutMultiplier:E.gte(r.targetMultiplier)?new U.default(r.targetMultiplier):new U.default(0),outputs:{randomMultiplier:E,result:e.values},randomValues:e}}}var ot=H(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 e=1;e<=a;e++)r=r*(t-e+1)/e;return r};class Vr extends A{constructor(){super("MINES")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}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 i=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),c=i.values.some((B)=>r.selectedTiles.includes(B)),u=r.hasCashedOut||c,d=(100-a)/100,s=new ot.default(Nt(25-r.minesCount,r.selectedTiles.length)).div(new ot.default(Nt(25,r.selectedTiles.length))),E=r.hasCashedOut&&!c?new ot.default(d).div(s):new ot.default(0);return{isFinished:u,payoutMultiplier:E,outputs:{result:i.values},randomValues:i}}}var Ir=require("big.js");var da;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(da||={});var Re=[8,9,10,11,12,13,14,15,16],_e={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]}},Ne={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]}},we={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]}},Ve={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]}},Ie={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]}},ua=new b(new Map([[1,_e],[2,Ne],[3,we],[4,Ve],[8,Ie]]));class Ur extends A{constructor(){super("PLINKO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}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 e=a.numberOfRows,i=ua.getMultipliers(r)[a.riskLevel][e],c=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),d=c.values.reduce((p,E)=>p+E,0),s=i[d];if(s===void 0)throw new Error(`No payout found for end position ${d}`);return{isFinished:!0,payoutMultiplier:Ir.Big(s),outputs:{result:c.values},randomValues:c}}}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],sa=[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]],Aa=[[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]],Ba=[[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]],ma=[[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]],Ea=[[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]],ya=[[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=[0,1,2,3,37],Oa=[[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]],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]],Z;((r)=>{r.EVEN="EVEN";r.ODD="ODD"})(Z||={});var k;((r)=>{r.RED="RED";r.BLACK="BLACK"})(k||={});var G;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(G||={});var M;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(M||={});var F;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(F||={});var Vt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Vt||={});var z=2.7,q=5.3;var It=(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)&&it(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Ue(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Ze(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&ke(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Ge(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(F).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},it=(t)=>{return wt.includes(t)},Ue=(t)=>{if(t.length!==2)return!1;if(!t.every(it))return!1;return pa.some(([a,r])=>a===t[0]&&r===t[1])},Ze=(t)=>{if(t.length!==3)return!1;if(!t.every(it))return!1;return Ba.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},ke=(t)=>{if(t.length!==4)return!1;if(!t.every(it))return!1;return Ea.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},Ge=(t)=>{if(t.length!==6)return!1;if(!t.every(it))return!1;return Oa.some(([a,r,e,n,o,i])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3]&&o===t[4]&&i===t[5])};var Ut=(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)&&ct(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&Me(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&Fe(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Je(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)&&Ye(a.values)))throw l.createValidationError("Invalid double street bet.");if(!t.parityBets.every((a)=>a.amount.gte(0)&&Object.values(Z).includes(a.parity)))throw l.createValidationError("Invalid parity bet.");if(!t.colorBets.every((a)=>a.amount.gte(0)&&Object.values(k).includes(a.color)))throw l.createValidationError("Invalid color bet.");if(!t.halfBets.every((a)=>a.amount.gte(0)&&Object.values(G).includes(a.half)))throw l.createValidationError("Invalid half bet.");if(!t.columnBets.every((a)=>a.amount.gte(0)&&Object.values(M).includes(a.column)))throw l.createValidationError("Invalid column bet.");if(!t.dozenBets.every((a)=>a.amount.gte(0)&&Object.values(F).includes(a.dozen)))throw l.createValidationError("Invalid dozen bet.")},ct=(t)=>{return sa.includes(t)};function Me(t){if(t.length!==2)return!1;if(!t.every(ct))return!1;return Aa.some(([a,r])=>a===t[0]&&r===t[1])}var Fe=(t)=>{if(t.length!==3)return!1;if(!t.every(ct))return!1;return ma.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},Je=(t)=>{if(t.length!==4)return!1;if(!t.every(ct))return!1;return ya.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},Ye=(t)=>{if(t.length!==6)return!1;if(!t.every(ct))return!1;return Sa.some(([a,r,e,n,o,i])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3]&&o===t[4]&&i===t[5])};var $e=(t,a)=>{let r=a===z&&t.type==="EUROPEAN",e=a===q&&t.type==="AMERICAN";if(!r&&!e)throw l.createValidationError(`Attempted to play ${t.type} roulette on edge ${a}`)},Ha=(t,a)=>{if($e(t,a),t.type==="EUROPEAN")It(t.inputs);else Ut(t.inputs)};var Zr={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},kr=[3,6,9,12,15,18,21,24,27,30,33,36],Gr=[2,5,8,11,14,17,20,23,26,29,32,35],Mr=[1,4,7,10,13,16,19,22,25,28,31,34],Fr=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Jr=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];class Da extends A{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),e=r.value,n=this.determineBetOutcomes(a,e),{payoutMultiplier:o}=this.getPayoutDetails(a,e);return{outputs:{betOutcomes:n,result:r.values},payoutMultiplier:o,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.determineBetOutcomes(t,a),e=this.getBetTotals(t),n=this.getBetTotals(r.winningBets),o=this.calculateTotalBetAmount(e),i=this.calculateTotalPayout(n);return{payoutMultiplier:o.gt(0)?i.div(o):new lt.Big(0),payoutAmount:i}}determineBetOutcomes(t,a){let r={},e={};for(let n of Object.keys(t)){let o=t[n],i=this.betPredicates[n],{winning:c,losing:u}=this.partitionBets(o,i,a);r[n]=c,e[n]=u}return{winningBets:r,losingBets:e}}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 Fr.includes(a)&&r.color==="RED"||Jr.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 kr.includes(a)&&r.column==="TOP"||Gr.includes(a)&&r.column==="MIDDLE"||Mr.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 e=a%2===0?"EVEN":"ODD";return r.parity===e}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((e)=>a(e,r)),losing:t.filter((e)=>!a(e,r))}}calculateTotalPayout(t){return Object.entries(t).reduce((a,[r,e])=>{let o=Zr[r];return a.plus(e.mul(o||0))},new lt.Big(0))}}class ha extends Da{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[z]}validateInputs(t){It(t)}}class Ca extends Da{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[q]}validateInputs(t){Ut(t)}isWinningBasketBet(t,a){return fa.some((r)=>r===a)}}class xa extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new ha,this.americanGame=new Ca}get supportedEdgeConfigurations(){return[z,q]}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 o=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:i}=o.outputs;return{...o,outputs:{type:"european",betOutcomes:i,result:o.outputs.result}}}let e=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:n}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:n,result:e.outputs.result}}}}var ze=(t)=>{return new xa().getBetAmount(t)};var zr=require("big.js");var X;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(X||={});var Q;((o)=>{o[o.TEN=10]="TEN";o[o.TWENTY=20]="TWENTY";o[o.THIRTY=30]="THIRTY";o[o.FORTY=40]="FORTY";o[o.FIFTY=50]="FIFTY"})(Q||={});var qe={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}}},Xe={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}}},Qe={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}}},ge={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}}},We={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}}},Yr=new b(new Map([[1,qe],[2,Xe],[3,Qe],[4,ge],[8,We]]));var $r={LOW_RISK:{10:["B","A","A","A","ZERO","A","A","A","A","ZERO"],20:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],30:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],40:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"],50:["B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO","B","A","A","A","ZERO","A","A","A","A","ZERO"]},MEDIUM_RISK:{10:["ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","D"],20:["A","ZERO","C","ZERO","B","ZERO","C","ZERO","C","ZERO","A","ZERO","C","ZERO","C","ZERO","D","ZERO","C","ZERO"],30:["A","ZERO","C","ZERO","A","ZERO","C","ZERO","D","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","C","ZERO","E","ZERO","A","ZERO","C","ZERO"],40:["C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO","C","ZERO","A","ZERO","D","ZERO","C","ZERO","A","ZERO"],50:["A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","C","ZERO","A","ZERO","B","ZERO","A","ZERO","B","ZERO","A","ZERO","D","ZERO","A","ZERO","B","ZERO","A","ZERO"]},HIGH_RISK:{10:[...Array(9).fill("ZERO"),"A"],20:[...Array(19).fill("ZERO"),"A"],30:[...Array(29).fill("ZERO"),"A"],40:[...Array(39).fill("ZERO"),"A"],50:[...Array(49).fill("ZERO"),"A"]}};class qr extends A{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(Q).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(X).includes(a.riskLevel))throw new Error("Invalid risk level");let n=Yr.getMultipliers(r)[a.riskLevel];if(n===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let o=n[a.segments];if(o===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let i=$r[a.riskLevel];if(i===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let c=i[a.segments];if(c===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let u=t.getRandomInt({min:0,max:c.length-1}),d=c[u.value];if(d===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${u.value}`);let s=o[d];if(s===void 0)throw new Error(`No payout found for picked segment ${d}`);return{isFinished:!0,payoutMultiplier:new zr.Big(s),outputs:{result:u.values},randomValues:u}}}
|
|
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}}}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
3
|
import Big$1 from 'big.js';
|
|
4
|
-
import { Big as Big$1, Big as Big$2, Big as Big$3 } from 'big.js';
|
|
4
|
+
import { Big as Big$1, Big as Big$2, Big as Big$3, Big as Big$4, Big as Big$5 } from 'big.js';
|
|
5
5
|
import { ReadonlyDeep, Simplify } from 'type-fest';
|
|
6
6
|
|
|
7
7
|
export declare enum GameErrorCode {
|
|
@@ -70,6 +70,35 @@ export interface RandomNumberGenerator {
|
|
|
70
70
|
count: number;
|
|
71
71
|
}): MultipleRandomValues;
|
|
72
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* A single exact payout amount from a game round.
|
|
75
|
+
*
|
|
76
|
+
* A round returns zero or more legs. Neither their order nor their count is
|
|
77
|
+
* significant: a leg is not tied to a particular bet, an amount may be zero,
|
|
78
|
+
* and the number of legs need not match the number of bets placed. The only
|
|
79
|
+
* supported operation is summing them.
|
|
80
|
+
*
|
|
81
|
+
* Amounts are gross — they include returned stake — and unrounded. Rounding to
|
|
82
|
+
* a currency's precision is the consuming service's decision, not this
|
|
83
|
+
* package's.
|
|
84
|
+
*/
|
|
85
|
+
export type PayoutLeg = Readonly<{
|
|
86
|
+
amount: Big$1;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* A round's payout, expressed as its constituent legs.
|
|
90
|
+
*/
|
|
91
|
+
export type Payout = Readonly<{
|
|
92
|
+
legs: readonly PayoutLeg[];
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Totals a round's payout.
|
|
96
|
+
*
|
|
97
|
+
* Summing the legs is lossless; reconstructing the total from a rounded
|
|
98
|
+
* payout multiplier is not, so this is the only supported way to arrive at
|
|
99
|
+
* what a round pays.
|
|
100
|
+
*/
|
|
101
|
+
export declare const sumPayout: (payout: Payout) => Big$1;
|
|
73
102
|
export type EmptyGameOutput = {};
|
|
74
103
|
export interface GetGameResultRequest<TGameInputs> {
|
|
75
104
|
generator: RandomNumberGenerator;
|
|
@@ -78,6 +107,7 @@ export interface GetGameResultRequest<TGameInputs> {
|
|
|
78
107
|
}
|
|
79
108
|
export interface GameResult<TGameOutputs = EmptyGameOutput> {
|
|
80
109
|
isFinished: boolean;
|
|
110
|
+
payout: Payout;
|
|
81
111
|
payoutMultiplier: Big$1;
|
|
82
112
|
outputs: TGameOutputs & {
|
|
83
113
|
result: number[];
|
|
@@ -91,6 +121,7 @@ export declare abstract class SingleActionGame<TGameInputs, TGameOutputs = Empty
|
|
|
91
121
|
number,
|
|
92
122
|
...number[]
|
|
93
123
|
];
|
|
124
|
+
abstract getBetAmount(gameInputs: TGameInputs): Big$1;
|
|
94
125
|
getGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
|
|
95
126
|
protected abstract determineGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
|
|
96
127
|
}
|
|
@@ -115,25 +146,30 @@ export declare enum RollType {
|
|
|
115
146
|
export type RollBetween = {
|
|
116
147
|
mode: RollType.ROLL_BETWEEN;
|
|
117
148
|
bounds: Bounds;
|
|
149
|
+
betAmount: Big$1.Big;
|
|
118
150
|
};
|
|
119
151
|
export type RollOutside = {
|
|
120
152
|
mode: RollType.ROLL_OUTSIDE;
|
|
121
153
|
bounds: Bounds;
|
|
154
|
+
betAmount: Big$1.Big;
|
|
122
155
|
};
|
|
123
156
|
export type RollBetweenTwo = {
|
|
124
157
|
mode: RollType.ROLL_BETWEEN_TWO;
|
|
125
158
|
firstBounds: Bounds;
|
|
126
159
|
secondBounds: Bounds;
|
|
160
|
+
betAmount: Big$1.Big;
|
|
127
161
|
};
|
|
128
162
|
export type AdvancedDiceInputs = RollBetween | RollOutside | RollBetweenTwo;
|
|
129
|
-
export
|
|
130
|
-
export declare const
|
|
163
|
+
export type AdvancedDiceSelection = Pick<RollBetween, "mode" | "bounds"> | Pick<RollOutside, "mode" | "bounds"> | Pick<RollBetweenTwo, "mode" | "firstBounds" | "secondBounds">;
|
|
164
|
+
export declare const calculateAdvancedDiceWinChance: (gameInputs: AdvancedDiceSelection) => Big$1.Big;
|
|
165
|
+
export declare const validateAdvancedDiceInputs: (gameInputs: AdvancedDiceSelection) => void;
|
|
131
166
|
export declare class AdvancedDice extends SingleActionGame<AdvancedDiceInputs> {
|
|
132
167
|
constructor();
|
|
133
168
|
get supportedEdgeConfigurations(): [
|
|
134
169
|
number,
|
|
135
170
|
...number[]
|
|
136
171
|
];
|
|
172
|
+
getBetAmount(gameInputs: AdvancedDiceInputs): Big$1.Big;
|
|
137
173
|
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<AdvancedDiceInputs>): GameResult;
|
|
138
174
|
}
|
|
139
175
|
export interface Bet {
|
|
@@ -194,6 +230,7 @@ export declare class Baccarat extends SingleActionGame<BaccaratGameInputs, Bacca
|
|
|
194
230
|
number,
|
|
195
231
|
...number[]
|
|
196
232
|
];
|
|
233
|
+
getBetAmount(gameInputs: BaccaratGameInputs): Big$1;
|
|
197
234
|
protected determineGameResult({ generator, gameInputs }: GetGameResultRequest<BaccaratGameInputs>): GameResult<BaccaratGameOutputs>;
|
|
198
235
|
private validateGameInputs;
|
|
199
236
|
private mapRandomValueToCard;
|
|
@@ -375,6 +412,7 @@ export type BaseInProgressState = Readonly<{
|
|
|
375
412
|
}>;
|
|
376
413
|
export type BaseFinishedState = Readonly<{
|
|
377
414
|
isFinished: true;
|
|
415
|
+
payout: Payout;
|
|
378
416
|
multiplier: Big$1;
|
|
379
417
|
randomValues: number[];
|
|
380
418
|
}>;
|
|
@@ -552,6 +590,7 @@ export declare class Blackjack extends MultiActionGame<BlackjackInternalState, B
|
|
|
552
590
|
}
|
|
553
591
|
export interface BlitzGameInputs {
|
|
554
592
|
pickCount: number;
|
|
593
|
+
betAmount: Big$1;
|
|
555
594
|
}
|
|
556
595
|
export interface BlitzGameOutputs {
|
|
557
596
|
cards: CardDto[];
|
|
@@ -570,6 +609,7 @@ export declare class Blitz extends SingleActionGame<BlitzGameInputs, BlitzGameOu
|
|
|
570
609
|
number,
|
|
571
610
|
...number[]
|
|
572
611
|
];
|
|
612
|
+
getBetAmount(gameInputs: BlitzGameInputs): Big$1;
|
|
573
613
|
protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<BlitzGameInputs>): GameResult<BlitzGameOutputs>;
|
|
574
614
|
}
|
|
575
615
|
export declare const BLITZ_MIN_CARD_RANGE = 0;
|
|
@@ -586,6 +626,7 @@ export declare enum DARTS_DIFFICULTY_LEVEL {
|
|
|
586
626
|
}
|
|
587
627
|
export interface DartsGameInputs {
|
|
588
628
|
difficultyLevel: DARTS_DIFFICULTY_LEVEL;
|
|
629
|
+
betAmount: Big$1;
|
|
589
630
|
}
|
|
590
631
|
export declare class Darts extends SingleActionGame<DartsGameInputs> {
|
|
591
632
|
constructor();
|
|
@@ -593,6 +634,7 @@ export declare class Darts extends SingleActionGame<DartsGameInputs> {
|
|
|
593
634
|
number,
|
|
594
635
|
...number[]
|
|
595
636
|
];
|
|
637
|
+
getBetAmount(gameInputs: DartsGameInputs): Big$1;
|
|
596
638
|
protected determineGameResult({ generator, gameInputs }: GetGameResultRequest<DartsGameInputs>): GameResult;
|
|
597
639
|
}
|
|
598
640
|
export type Segment = "YELLOW" | "ORANGE" | "RED";
|
|
@@ -624,6 +666,7 @@ declare class MultiplierContainer<TMultipliers> {
|
|
|
624
666
|
}[];
|
|
625
667
|
}
|
|
626
668
|
export interface DiamondsGameInputs {
|
|
669
|
+
betAmount: Big$1;
|
|
627
670
|
}
|
|
628
671
|
export declare enum DiamondsResultType {
|
|
629
672
|
PAIR = "PAIR",
|
|
@@ -641,7 +684,8 @@ export declare class Diamonds extends SingleActionGame<DiamondsGameInputs> {
|
|
|
641
684
|
number,
|
|
642
685
|
...number[]
|
|
643
686
|
];
|
|
644
|
-
|
|
687
|
+
getBetAmount(gameInputs: DiamondsGameInputs): Big$1;
|
|
688
|
+
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<DiamondsGameInputs>): GameResult;
|
|
645
689
|
private calculatePayoutMultiplier;
|
|
646
690
|
private classifyResult;
|
|
647
691
|
}
|
|
@@ -652,18 +696,21 @@ export declare enum DiceDirection {
|
|
|
652
696
|
export interface DiceGameInputs {
|
|
653
697
|
direction: DiceDirection;
|
|
654
698
|
selectedValue: number;
|
|
699
|
+
betAmount: Big$1;
|
|
655
700
|
}
|
|
701
|
+
export type DiceSelection = Pick<DiceGameInputs, "direction" | "selectedValue">;
|
|
656
702
|
export declare const DICE_MIN_ROLL = 0;
|
|
657
703
|
export declare const DICE_MAX_ROLL = 10000;
|
|
658
704
|
export declare const DICE_EFFECTIVE_RANGE: number;
|
|
659
|
-
export declare const calculateDiceWinChance: (gameInputs:
|
|
660
|
-
export declare const hasDiceWon: (gameInputs:
|
|
705
|
+
export declare const calculateDiceWinChance: (gameInputs: DiceSelection) => Big$1;
|
|
706
|
+
export declare const hasDiceWon: (gameInputs: DiceSelection, rolledValue: number) => boolean;
|
|
661
707
|
export declare class Dice extends SingleActionGame<DiceGameInputs> {
|
|
662
708
|
constructor();
|
|
663
709
|
get supportedEdgeConfigurations(): [
|
|
664
710
|
number,
|
|
665
711
|
...number[]
|
|
666
712
|
];
|
|
713
|
+
getBetAmount(gameInputs: DiceGameInputs): Big$1;
|
|
667
714
|
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<DiceGameInputs>): GameResult;
|
|
668
715
|
}
|
|
669
716
|
export declare enum KenoRiskLevel {
|
|
@@ -689,6 +736,7 @@ export declare const isTileCount: (value: number) => value is TileCount;
|
|
|
689
736
|
export interface KenoGameInputs {
|
|
690
737
|
riskLevel: KenoRiskLevel;
|
|
691
738
|
selectedNumbers: number[];
|
|
739
|
+
betAmount: Big$1;
|
|
692
740
|
}
|
|
693
741
|
export declare class Keno extends SingleActionGame<KenoGameInputs> {
|
|
694
742
|
constructor();
|
|
@@ -696,6 +744,7 @@ export declare class Keno extends SingleActionGame<KenoGameInputs> {
|
|
|
696
744
|
number,
|
|
697
745
|
...number[]
|
|
698
746
|
];
|
|
747
|
+
getBetAmount(gameInputs: KenoGameInputs): Big$1;
|
|
699
748
|
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<KenoGameInputs>): GameResult;
|
|
700
749
|
}
|
|
701
750
|
export type KenoMultipliers = Record<TileCount, Record<KenoRiskLevel, number[]>>;
|
|
@@ -707,6 +756,7 @@ export declare const rtp92Multipliers: KenoMultipliers;
|
|
|
707
756
|
export declare const kenoMultipliers: MultiplierContainer<KenoMultipliers>;
|
|
708
757
|
export interface LimboGameInputs {
|
|
709
758
|
targetMultiplier: number;
|
|
759
|
+
betAmount: Big$1;
|
|
710
760
|
}
|
|
711
761
|
export interface LimboGameOutputs {
|
|
712
762
|
randomMultiplier: Big$1;
|
|
@@ -717,12 +767,14 @@ export declare class Limbo extends SingleActionGame<LimboGameInputs, LimboGameOu
|
|
|
717
767
|
number,
|
|
718
768
|
...number[]
|
|
719
769
|
];
|
|
770
|
+
getBetAmount(gameInputs: LimboGameInputs): Big$1;
|
|
720
771
|
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<LimboGameInputs>): GameResult<LimboGameOutputs>;
|
|
721
772
|
}
|
|
722
773
|
export interface MinesGameInputs {
|
|
723
774
|
minesCount: number;
|
|
724
775
|
selectedTiles: number[];
|
|
725
776
|
hasCashedOut: boolean;
|
|
777
|
+
betAmount: Big$1;
|
|
726
778
|
}
|
|
727
779
|
export declare class Mines extends SingleActionGame<MinesGameInputs> {
|
|
728
780
|
constructor();
|
|
@@ -730,6 +782,7 @@ export declare class Mines extends SingleActionGame<MinesGameInputs> {
|
|
|
730
782
|
number,
|
|
731
783
|
...number[]
|
|
732
784
|
];
|
|
785
|
+
getBetAmount(gameInputs: MinesGameInputs): Big$1;
|
|
733
786
|
protected determineGameResult({ generator, edge, gameInputs }: GetGameResultRequest<MinesGameInputs>): GameResult;
|
|
734
787
|
}
|
|
735
788
|
export declare enum PlinkoRiskLevel {
|
|
@@ -740,6 +793,7 @@ export declare enum PlinkoRiskLevel {
|
|
|
740
793
|
export interface PlinkoGameInputs {
|
|
741
794
|
numberOfRows: number;
|
|
742
795
|
riskLevel: PlinkoRiskLevel;
|
|
796
|
+
betAmount: Big$1.Big;
|
|
743
797
|
}
|
|
744
798
|
export declare class Plinko extends SingleActionGame<PlinkoGameInputs> {
|
|
745
799
|
constructor();
|
|
@@ -747,6 +801,7 @@ export declare class Plinko extends SingleActionGame<PlinkoGameInputs> {
|
|
|
747
801
|
number,
|
|
748
802
|
...number[]
|
|
749
803
|
];
|
|
804
|
+
getBetAmount(gameInputs: PlinkoGameInputs): Big$1.Big;
|
|
750
805
|
protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<PlinkoGameInputs>): GameResult;
|
|
751
806
|
}
|
|
752
807
|
export declare const PLINKO_ROW_COUNTS: readonly [
|
|
@@ -2113,7 +2168,7 @@ declare abstract class BaseRoulette<TInputs extends {
|
|
|
2113
2168
|
getBetAmount(gameInputs: TInputs): Big$1.Big;
|
|
2114
2169
|
getPayoutDetails(gameInputs: TInputs, gameResult: number): {
|
|
2115
2170
|
payoutMultiplier: Big$1.Big;
|
|
2116
|
-
|
|
2171
|
+
payout: Payout;
|
|
2117
2172
|
};
|
|
2118
2173
|
protected determineBetOutcomes(inputs: TInputs, result: number): {
|
|
2119
2174
|
winningBets: TInputs;
|
|
@@ -2137,7 +2192,11 @@ declare abstract class BaseRoulette<TInputs extends {
|
|
|
2137
2192
|
protected abstract validateInputs(inputs: TInputs): void;
|
|
2138
2193
|
protected abstract readonly betPredicates: Record<keyof TInputs, BetPredicate>;
|
|
2139
2194
|
private partitionBets;
|
|
2140
|
-
|
|
2195
|
+
/**
|
|
2196
|
+
* One leg per bet actually placed, in the order the inputs list them. A bet type the player
|
|
2197
|
+
* left empty contributes nothing, so an untouched part of the table produces no leg at all.
|
|
2198
|
+
*/
|
|
2199
|
+
protected calculatePayoutLegs(inputs: TInputs, result: number): PayoutLeg[];
|
|
2141
2200
|
}
|
|
2142
2201
|
export declare class EuropeanRoulette extends BaseRoulette<EuropeanRouletteGameInputs, EuropeanRouletteGameOutputs> {
|
|
2143
2202
|
protected readonly maxNumber = 36;
|
|
@@ -2186,6 +2245,7 @@ export declare enum WheelSegments {
|
|
|
2186
2245
|
export interface WheelGameInputs {
|
|
2187
2246
|
segments: WheelSegments;
|
|
2188
2247
|
riskLevel: WheelRiskLevel;
|
|
2248
|
+
betAmount: Big$1.Big;
|
|
2189
2249
|
}
|
|
2190
2250
|
export declare class Wheel extends SingleActionGame<WheelGameInputs> {
|
|
2191
2251
|
constructor();
|
|
@@ -2193,6 +2253,7 @@ export declare class Wheel extends SingleActionGame<WheelGameInputs> {
|
|
|
2193
2253
|
number,
|
|
2194
2254
|
...number[]
|
|
2195
2255
|
];
|
|
2256
|
+
getBetAmount(gameInputs: WheelGameInputs): Big$1.Big;
|
|
2196
2257
|
protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<WheelGameInputs>): GameResult;
|
|
2197
2258
|
}
|
|
2198
2259
|
export declare const bigMax: (a: Big$1, b: Big$1) => Big$1;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Fa;((r)=>{r.UNSUPPORTED_EDGE="UNSUPPORTED_EDGE";r.INPUT_VALIDATION_ERROR="INPUT_VALIDATION_ERROR"})(Fa||={});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 O;((B)=>{B.DICE="DICE";B.MINES="MINES";B.KENO="KENO";B.LIMBO="LIMBO";B.ADVANCED_DICE="ADVANCED_DICE";B.BACCARAT="BACCARAT";B.DIAMONDS="DIAMONDS";B.PLINKO="PLINKO";B.ROULETTE="ROULETTE";B.WHEEL="WHEEL";B.BLACKJACK="BLACKJACK";B.BLITZ="BLITZ";B.DARTS="DARTS"})(O||={});import{Guard as Ja}from"@betorigami/guard";class A{gameId;constructor(t){this.gameId=t}getGameResult(t){let a=this.supportedEdgeConfigurations.includes(t.edge);return Ja.against(!a,()=>l.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}}import{Big as Jt}from"big.js";import At from"big.js";class x{static withMultiplier(t,a){return new At(t).times(new At(100-a).div(100))}static withWinChance(t,a){return At(100-t).div(a)}}var at=0,rt=1e4,Ft=rt-at+1,Ya=0.01,$a=98,za=(t)=>{if(t<at)throw l.createValidationError(`Lower bound ${t} is below minimum allowed value ${at}`)},qa=(t)=>{if(t>rt)throw l.createValidationError(`Upper bound ${t} is above maximum allowed value ${rt}`)},tt=(t)=>{if(za(t.lower),qa(t.upper),t.lower>=t.upper)throw l.createValidationError(`Lower bound ${t.lower} must be less than ${t.upper}`)},Xa=(t,a)=>{let[r,e]=t.lower<=a.lower?[t,a]:[a,t];if(r.upper>e.lower)throw l.createValidationError("Bounds must not overlap")},Qa=(t,a)=>a>=t.lower&&a<=t.upper,ga=(t)=>t.upper-t.lower+1,Bt=(t,a)=>a>t.lower&&a<t.upper,mt=(t)=>t.upper-t.lower-1,Wa;((e)=>{e.ROLL_BETWEEN="ROLL_BETWEEN";e.ROLL_OUTSIDE="ROLL_OUTSIDE";e.ROLL_BETWEEN_TWO="ROLL_BETWEEN_TWO"})(Wa||={});var Yt=(t)=>{let r=(()=>{switch(t.mode){case"ROLL_BETWEEN":return tt(t.bounds),mt(t.bounds);case"ROLL_OUTSIDE":return tt(t.bounds),Ft-ga(t.bounds);case"ROLL_BETWEEN_TWO":return tt(t.firstBounds),tt(t.secondBounds),Xa(t.firstBounds,t.secondBounds),mt(t.firstBounds)+mt(t.secondBounds)}})(),e=Jt(r).div(Ft).mul(100);if(e.lt(Ya))throw l.createValidationError("Win chance too low");if(e.gt($a))throw l.createValidationError("Win chance too high");return e},Xe=(t)=>{Yt(t)};class La extends A{constructor(){super("ADVANCED_DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=Yt(r),n=t.getRandomInt({min:at,max:rt}),o=n.value;return{isFinished:!0,payoutMultiplier:(()=>{switch(r.mode){case"ROLL_BETWEEN":return Bt(r.bounds,o);case"ROLL_OUTSIDE":return!Qa(r.bounds,o);case"ROLL_BETWEEN_TWO":return Bt(r.firstBounds,o)||Bt(r.secondBounds,o)}})()?x.withWinChance(a,e):new Jt(0),outputs:{result:n.values},randomValues:n}}}import w from"big.js";import{Guard as yt}from"@betorigami/guard";var $t=0,zt=51,et=Array.from({length:52},(t,a)=>a),qt=["Spades","Hearts","Diamonds","Clubs"],nt=["Ace","Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King"],Xt=["Jack","Queen","King"],Et={Hearts:"red",Diamonds:"red",Spades:"black",Clubs:"black"};class T{value;constructor(t){let a=et[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=nt[t];return yt.againstNullOrUndefined(a,`Invalid rank index: ${t}`),a}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}}var on=["Clubs","Diamonds","Hearts","Spades"],cn=["Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"],Ka={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"},va;((e)=>{e.PLAYER_WIN="PLAYER_WIN";e.TIE="TIE";e.BANKER_WIN="BANKER_WIN"})(va||={});var tr;((e)=>{e.PLAYER="PLAYER";e.TIE="TIE";e.BANKER="BANKER"})(tr||={});var ar={["PLAYER_WIN"]:{betType:"PLAYER",multiplier:2},["TIE"]:{betType:"TIE",multiplier:9},["BANKER_WIN"]:{betType:"BANKER",multiplier:1.95}},rr=(t)=>{return new w(0).add(t.bets.reduce((r,e)=>r.add(e.amount),new w(0)))};class er extends A{constructor(){super("BACCARAT")}get supportedEdgeConfigurations(){return[1]}determineGameResult({generator:t,gameInputs:a}){this.validateGameInputs(a);let r=t.getRandomIntsWithReplacement({min:0,max:51,count:6}),e=r.values,n=e.slice(0,3),o=e.slice(3,6),i=[],c=0;for(let y of n.slice(0,2)){let D=this.mapRandomValueToCard(y),v=this.mapRandomValueToCardValue(y);i.push(D),c=(c+v)%10}let u=[],d=0;for(let y of o.slice(0,2)){let D=this.mapRandomValueToCard(y),v=this.mapRandomValueToCardValue(y);u.push(D),d=(d+v)%10}if(!this.isNaturalWin(c,d)){let y=this.shouldDrawThirdPlayerCard(c),D=null;if(y)D=this.mapRandomValueToCardValue(n[2]),i.push(this.mapRandomValueToCard(n[2])),c=(c+D)%10;if(this.shouldDrawThirdBankerCard(d,D))u.push(this.mapRandomValueToCard(o[2])),d=(d+this.mapRandomValueToCardValue(o[2]))%10}let s;if(c===d)s="TIE";else s=c>d?"PLAYER_WIN":"BANKER_WIN";let p=rr(a),{betType:E,multiplier:B}=ar[s],j=new w(0);if(j=j.add(a.bets.filter((y)=>y.type===E).reduce((y,D)=>y.add(D.amount.mul(B)),new w(0))),s==="TIE")j=j.add(a.bets.filter((y)=>y.type==="PLAYER"||y.type==="BANKER").reduce((y,D)=>y.add(D.amount),new w(0)));return{isFinished:!0,payoutMultiplier:p.gt(0)?j.div(p):new w(0),outputs:{playerCards:i,playerHandValue:c,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 T(t);return{suit:a.suit,rank:Ka[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;((c)=>{c.START="START";c.HIT="BLACKJACK_HIT";c.STAND="BLACKJACK_STAND";c.BUY_INSURANCE="BLACKJACK_BUY_INSURANCE";c.REJECT_INSURANCE="BLACKJACK_REJECT_INSURANCE";c.DOUBLE_DOWN="BLACKJACK_DOUBLE_DOWN";c.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;((i)=>{i.SUITED_TRIPS="SUITED_TRIPS";i.STRAIGHT_FLUSH="STRAIGHT_FLUSH";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.STRAIGHT="STRAIGHT";i.FLUSH="FLUSH";i.LOSS="LOSS"})(Dt||={});var nr=2.5,or=2,ir=1,cr=0,Qt=17,ht=21,h=21,Ct=63,An=1.5,F=0.5,xt=1.5,R=1,V=1,Bn=13,Pt=10,gt=10,ot={PLAYER_BLACKJACK:nr,WIN:or,PUSH:ir,LOSE:cr},Wt={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},Lt={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 m}from"@betorigami/guard";import{createStore as Ar}from"@xstate/store";import{Guard as lr}from"@betorigami/guard";class f extends T{get numericRank(){if(Xt.includes(this.rank))return gt;return nt.indexOf(this.rank)+1}static fromValue(t){return lr.against(!et.includes(t),`Invalid card value: ${t}`),new f(t)}}class J{cards;hardHandValue;softHandValue=null;constructor(t){this.cards=t;if(this.hardHandValue=t.reduce((r,e)=>r+e.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===h}get highestHandValue(){return this.softHandValue!==null?this.softHandValue:this.hardHandValue}}class Y{cards;value;constructor(t){this.cards=t.map((a)=>f.fromValue(a)),this.value=new J(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 $ extends Y{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 $(t.upCard,t.holeCard)}addDrawnCards(t){return new $(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(t=!1){if(t)return super.toDto();return{cards:[this.upCard.toDto()],value:new J([this.upCard]).highestHandValue}}}class _ extends Y{static withInitialDeal(t){return new _(t)}addDrawnCards(t){return new _([...this.rawValues,...t])}}import{Guard as it}from"@betorigami/guard";class ct{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 ct(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 Kt}from"@betorigami/guard";import dr 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 e=this.createGameStore(),n=this.generateRandomValues(t),o=n.toMultipleRandomValues();for(let u of r)e.send({...u.playerArgument,randomValuePool:n});let i=r[r.length-1];if(i)Kt.against(!dr(i.state,this.toExternalState(e.getSnapshot().context.state)),"The final state of the game does not match the expected state based on the previous actions");e.send({...a,randomValuePool:n});let c=e.getSnapshot().context;return{playerArgument:c.playerArgument,state:this.toExternalState(c.state),config:c.config,additionalBetAmount:c.additionalBetAmount,proof:{proofHash:o.proofHash,proofString:o.proofString}}}validateEdge(t){let a=this.supportedEdgeConfigurations.includes(t);Kt.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 vt=(t)=>{let a=t.pairBonus!==null?C(t.pairBonus.betAmount).mul(t.pairBonus.payoutMultiplier):C(0),r=t.threeCardBonus!==null?C(t.threeCardBonus.betAmount).mul(t.threeCardBonus.payoutMultiplier):C(0);return a.plus(r)},ta=(t)=>{let a=t.betAmounts.mainBetAmount,e=t.actionType==="BLACKJACK_DOUBLE_DOWN"?a.mul(R):C(0),n=t.insuranceOutcome!==void 0?a.mul(F):C(0),o=a.plus(e).mul(ot[t.outcome]),i=t.insuranceOutcome==="WON"?a.mul(xt):C(0),c=vt(t.sideBetResults),u=o.plus(i).plus(c),d=a.plus(n).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);jt.against(d.eq(0),"Total bet amount cannot be zero");let s=u.div(d);jt.against(t.actionType==="BLACKJACK_SPLIT","SPLIT action type is not valid for standard multiplier calculation");let p;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":p=e;break;case"BLACKJACK_BUY_INSURANCE":p=n;break;case"BLACKJACK_SPLIT":p=a.mul(V);break}return{multiplier:s,additionalBetAmount:p}},aa=(t)=>{let a=t.betAmounts.mainBetAmount,r=t.mainHandDoubledDown?a.mul(R):C(0),e=t.splitHandDoubledDown?a.mul(R):C(0),n=t.insuranceOutcome!==void 0?a.mul(F):C(0),o=a.plus(r).mul(ot[t.mainOutcome]),i=a.plus(e).mul(ot[t.splitOutcome]),c=t.insuranceOutcome==="WON"?a.mul(xt):C(0),u=vt(t.sideBetResults),d=o.plus(i).plus(c).plus(u),s=a.plus(a).plus(n).plus(r).plus(e).plus(t.betAmounts.pairBonusAmount).plus(t.betAmounts.threeCardBonusAmount);jt.against(s.eq(0),"Total bet amount cannot be zero");let p=d.div(s),E;switch(t.actionType){case"BLACKJACK_DOUBLE_DOWN":E=a.mul(R);break;case"BLACKJACK_SPLIT":E=a.mul(V);break}return{multiplier:p,additionalBetAmount:E}};import{Guard as ur}from"@betorigami/guard";var Tt=(t)=>t.every((a)=>a===t[0]),ra=(t)=>{let a=[...t].sort((r,e)=>r-e);return a.every((r,e)=>{let n=a[e-1];if(e===0)return!0;return ur.againstUndefined(n,"Previous value cannot be undefined"),r===n+1})},ea={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},sr={...ea,Ace:14},pr=(t)=>ra(t.map((a)=>ea[a]))||ra(t.map((a)=>sr[a])),na=(t,a)=>{let r=f.fromValue(t),e=f.fromValue(a);if(r.rank!==e.rank)return"LOSS";if(t===a)return"EXACT_PAIR";if(Et[r.suit]===Et[e.suit])return"COLORED_PAIR";return"MIXED_PAIR"},oa=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Wt[a]}),ia=(t,a,r)=>{let e=f.fromValue(t),n=f.fromValue(a),o=f.fromValue(r),i=[e.rank,n.rank,o.rank],c=Tt([e.suit,n.suit,o.suit]),u=Tt(i),d=pr(i);if(Tt([t,a,r]))return"SUITED_TRIPS";if(c&&d)return"STRAIGHT_FLUSH";if(u)return"THREE_OF_A_KIND";if(d)return"STRAIGHT";if(c)return"FLUSH";return"LOSS"},ca=(t,a)=>({betAmount:t,result:a,payoutMultiplier:Lt[a]});var Br={state:{isFinished:!1,phase:"uninitialised",multiplier:N(0)},config:{},playerArgument:{type:"START",mainBetAmount:"0",pairBonusAmount:"0",threeCardBonusAmount:"0"}},S=(t)=>f.fromValue(t).value;function mr(t){m.against(t.phase!=="in-progress","Expected a started, in-progress game state")}function la(t){m.against(t.phase!=="awaiting-insurance","Expected game to be awaiting insurance decision")}function Rt(t){m.against(t.phase!=="in-progress"&&t.phase!=="playing-main-hand"&&t.phase!=="playing-split-hand","Expected a started, in-progress game state")}var da=(t,a)=>{let r=a;while(r.highestHandValue<Qt)r=r.addDrawnCards([S(t.takeOne())]);return r},Nt=(t,a)=>{if(t.isBusted)return"LOSE";if(a.isBusted)return"WIN";let r=t.highestHandValue,e=a.highestHandValue;if(r>e)return"WIN";if(r<e)return"LOSE";return"PUSH"},H=(t)=>{let{multiplier:a,additionalBetAmount:r}=ta({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,multiplier:a,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:r}},_t=(t)=>{let a=da(t.randomValuePool,t.dealerHand),r=Nt(t.playerHand,a);return H({...t,dealerHand:a,outcome:r})},b=(t)=>{let r=t.mainHand.isBusted&&t.splitHand.isBusted?t.dealerHand:da(t.randomValuePool,t.dealerHand),e=Nt(t.mainHand,r),n=Nt(t.splitHand,r),{multiplier:o,additionalBetAmount:i}=aa({hasSplit:!0,mainOutcome:e,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:e,splitOutcome:n,multiplier:o,randomValues:t.randomValuePool.consumedValues,insuranceOutcome:t.insuranceOutcome,sideBetResults:t.sideBetResults},config:{},playerArgument:t.playerArgument,additionalBetAmount:i}};class Er extends bt{constructor(t){super("BLACKJACK",t)}get supportedEdgeConfigurations(){return[1]}generateRandomValues(t){return ct.from(t.getRandomIntsWithReplacement({min:$t,max:zt,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,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,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:m.againstNever(a,"Invalid state received")}}createGameStore(){return Ar({context:Br,on:{START:(t,a)=>{let{state:r}=t;m.against(r.phase!=="uninitialised","START action requires a fresh game");let e=S(a.randomValuePool.takeOne()),n=S(a.randomValuePool.takeOne()),o=S(a.randomValuePool.takeOne()),i=S(a.randomValuePool.takeOne()),c=_.withInitialDeal([e,n]),u=$.withInitialDeal({upCard:o,holeCard:i}),d={mainBetAmount:N(a.mainBetAmount),pairBonusAmount:N(a.pairBonusAmount),threeCardBonusAmount:N(a.threeCardBonusAmount)},s={pairBonus:N(a.pairBonusAmount).gt(0)?oa(a.pairBonusAmount,na(e,n)):null,threeCardBonus:N(a.threeCardBonusAmount).gt(0)?ca(a.threeCardBonusAmount,ia(e,n,o)):null},p={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:c,dealerHand:u,betAmounts:d,sideBetResults:s},config:{},playerArgument:p};let E={playerHand:c,dealerHand:u,randomValuePool:a.randomValuePool,playerArgument:p,betAmounts:d,sideBetResults:s};if(c.isBlackjack&&u.isBlackjack)return H({...E,outcome:"PUSH"});if(c.isBlackjack)return H({...E,outcome:"PLAYER_BLACKJACK"});if(u.isBlackjack)return H({...E,outcome:"LOSE"});return{state:{...r,isFinished:!1,phase:"in-progress",playerHand:c,dealerHand:u,insuranceOutcome:void 0,betAmounts:d,sideBetResults:s},config:{},playerArgument:p}},BLACKJACK_BUY_INSURANCE:(t,a)=>{let{state:r}=t;la(r);let{playerHand:e,dealerHand:n,betAmounts:o,sideBetResults:i}=r,c={...r,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},betAmounts:o,sideBetResults:i};if(e.isBlackjack&&n.isBlackjack)return H({...c,outcome:"PUSH",insuranceOutcome:"WON"});if(e.isBlackjack)return H({...c,outcome:"PLAYER_BLACKJACK",insuranceOutcome:"LOST"});if(n.isBlackjack)return H({...c,outcome:"LOSE",insuranceOutcome:"WON"});return{state:{...r,phase:"in-progress",insuranceOutcome:"LOST"},config:{},playerArgument:{type:"BLACKJACK_BUY_INSURANCE"},additionalBetAmount:o.mainBetAmount.mul(F)}},BLACKJACK_REJECT_INSURANCE:(t,a)=>{let{state:r}=t;la(r);let{playerHand:e,dealerHand:n,betAmounts:o,sideBetResults:i}=r,c={playerHand:e,dealerHand:n,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_REJECT_INSURANCE"},betAmounts:o,sideBetResults:i};if(e.isBlackjack&&n.isBlackjack)return H({...c,outcome:"PUSH"});if(e.isBlackjack)return H({...c,outcome:"PLAYER_BLACKJACK"});if(n.isBlackjack)return H({...c,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 e=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===h){if(r.splitHand.highestHandValue===h)return b({...r,mainHand:e,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}return{state:{...r,mainHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"playing-split-hand":{let e=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted||e.highestHandValue===h)return b({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,splitHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}case"in-progress":{let e=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted)return H({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});if(e.highestHandValue===h)return _t({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_HIT"}});return{state:{...r,phase:"in-progress",playerHand:e},config:{},playerArgument:{type:"BLACKJACK_HIT"}}}default:m.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===h)return b({...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 b({...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:m.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":{m.against(r.mainHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.mainHand.addDrawnCards([S(a.randomValuePool.takeOne())]),{betAmounts:n}=r;if(r.splitHand.highestHandValue===h)return b({...r,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return{state:{...r,phase:"playing-split-hand",mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},additionalBetAmount:n.mainBetAmount.mul(R)}}case"playing-split-hand":{m.against(r.splitHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.splitHand.addDrawnCards([S(a.randomValuePool.takeOne())]);return b({...r,splitHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"},splitHandDoubledDown:!0})}case"in-progress":{m.against(r.playerHand.cards.length!==2,"Double down is only allowed as the first action");let e=r.playerHand.addDrawnCards([S(a.randomValuePool.takeOne())]);if(e.isBusted)return H({...r,playerHand:e,outcome:"LOSE",randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}});return _t({...r,playerHand:e,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_DOUBLE_DOWN"}})}default:m.againstNever(r,"Invalid phase for DOUBLE_DOWN action")}},BLACKJACK_SPLIT:(t,a)=>{let{state:r}=t;mr(r);let{playerHand:e,betAmounts:n,sideBetResults:o}=r;m.against(e.cards.length!==2,"Split is only allowed with exactly 2 cards");let i=e.cards[0],c=e.cards[1];m.againstUndefined(i,"First card is missing"),m.againstUndefined(c,"Second card is missing"),m.against(i.rank!==c.rank,"Split requires two cards of the same rank");let u=S(a.randomValuePool.takeOne()),d=S(a.randomValuePool.takeOne()),s=_.withInitialDeal([i.value,u]),p=_.withInitialDeal([c.value,d]);if(i.rank==="Ace")return b({...r,mainHand:s,splitHand:p,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let B=s.highestHandValue===h,j=p.highestHandValue===h;if(B&&j)return b({mainHand:s,splitHand:p,dealerHand:r.dealerHand,randomValuePool:a.randomValuePool,playerArgument:{type:"BLACKJACK_SPLIT"},insuranceOutcome:r.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:n,sideBetResults:o});if(B)return{state:{...r,phase:"playing-split-hand",mainHand:s,splitHand:p,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.mainBetAmount.mul(V)};return{state:{...r,phase:"playing-main-hand",multiplier:N(0),mainHand:s,splitHand:p,mainHandDoubledDown:!1},config:{},playerArgument:{type:"BLACKJACK_SPLIT"},additionalBetAmount:n.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],e=t.playerHand.cards[1];if(m.againstUndefined(r,"First player card is missing"),m.againstUndefined(e,"Second player card is missing"),r.rank===e.rank)a.push("BLACKJACK_SPLIT")}return a}default:m.againstNever(t,"Invalid phase for getting valid actions")}}}import q from"big.js";import{Guard as Aa}from"@betorigami/guard";var ua=0,sa=51,z=52,pa=52;var ho=()=>({minPicks:5,maxPicks:36}),yr=(t)=>t.length===new Set(t).size,fr=(t)=>{let a=q(1),r=q(z);for(let e=0;e<t;e+=1)a=a.mul(q(z-e).div(r));return a};class Or extends A{constructor(){super("BLITZ")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a,edge:r}){Aa.against(a.pickCount<1||a.pickCount>z,`pickCount must be between 1 and ${z}`),Aa.againstNonInteger(a.pickCount,"pickCount must be an integer");let e=t.getRandomIntsWithReplacement({min:ua,max:sa,count:pa}),n=e.values.slice(0,a.pickCount),o=yr(n),i=fr(a.pickCount);return{isFinished:!0,payoutMultiplier:o?x.withMultiplier(q(1).div(i),r):q(0),outputs:{result:e.values,cards:n.map((u)=>new T(u).toDto())},randomValues:e}}}var Ba=0,wt=4294967295,ma;((n)=>{n.EASY="EASY";n.MEDIUM="MEDIUM";n.HARD="HARD";n.EXPERT="EXPERT"})(ma||={});var Sr=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],Hr={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:Sr},Dr=["YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],hr={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:Dr},Cr=["YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED","YELLOW","ORANGE","YELLOW","ORANGE","YELLOW","RED"],xr={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:Cr},Pr=["YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","ORANGE","YELLOW","YELLOW","RED","YELLOW","YELLOW","ORANGE","YELLOW"],br={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:Pr},Ro=(t)=>{let a=Vt[t];return[a.multipliers.bullseye,a.multipliers.ringOne,a.multipliers.ringTwo,...Object.values(a.multipliers.ringThree),a.multipliers.ringFour].reduce((e,n)=>n>e?n:e)},Vt={EASY:Hr,MEDIUM:hr,HARD:xr,EXPERT:br};import{Guard as It}from"@betorigami/guard";import jr from"big.js";class Tr extends A{constructor(){super("DARTS")}get supportedEdgeConfigurations(){return[2]}determineGameResult({generator:t,gameInputs:a}){let r=t.getRandomIntsWithReplacement({min:Ba,max:wt,count:2}),e=r.values[0],n=r.values[1];It.againstUndefined(e,"Random number generator returned no value for clockWiseRotation"),It.againstUndefined(n,"Random number generator returned no value for distanceFromCentre");let o=a.difficultyLevel;return{isFinished:!0,payoutMultiplier:jr(Rr(o,e,n)),outputs:{result:r.values},randomValues:r}}}var Rr=(t,a,r)=>{let e=Vt[t],{distanceBoundaries:n,multipliers:o}=e;if(r<n.bullseye)return o.bullseye;if(r<n.ringOne)return o.ringOne;if(r<n.ringTwo)return o.ringTwo;if(r<n.ringThree)return _r(e,a);return o.ringFour},_r=(t,a)=>{let r=t.segments.length,e=Math.floor(a/(wt+1)*r),n=t.segments[e];return It.againstUndefined(n,`Segment index ${e} out of bounds`),t.multipliers.ringThree[n]};import Nr 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 wr;((i)=>{i.PAIR="PAIR";i.TWO_PAIR="TWO_PAIR";i.THREE_OF_A_KIND="THREE_OF_A_KIND";i.FULL_HOUSE="FULL_HOUSE";i.FOUR_OF_A_KIND="FOUR_OF_A_KIND";i.FIVE_OF_A_KIND="FIVE_OF_A_KIND"})(wr||={});var Vr={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},Ir={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},Ur={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},Zr={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},kr={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},Gr=new P(new Map([[1,Vr],[2,Ir],[3,Ur],[4,Zr],[8,kr]])),Mr={2:"PAIR",3:"THREE_OF_A_KIND",4:"FOUR_OF_A_KIND",5:"FIVE_OF_A_KIND"};class Fr extends A{constructor(){super("DIAMONDS")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a}){let r=t.getRandomIntsWithReplacement({min:0,max:6,count:5}),e=Gr.getMultipliers(a),n=r.values,o=this.calculatePayoutMultiplier(e,n);return{isFinished:!0,payoutMultiplier:Nr(o),outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(t,a){let r=new Map;for(let o of a){let i=r.get(o)||0;r.set(o,i+1)}let e=[...r.values()].filter((o)=>o>1),n=this.classifyResult(e);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 e=Mr[a];if(e===void 0)throw new Error(`Unexpected single diamond repeat count: ${a}`);return e}return a===3||r===3?"FULL_HOUSE":"TWO_PAIR"}}import Ea from"big.js";var Jr;((r)=>{r.ABOVE="ABOVE";r.BELOW="BELOW"})(Jr||={});var ya=0,Ut=1e4,Yr=Ut-ya+1,$r=(t)=>{let a=t.direction==="ABOVE"?Ut-t.selectedValue:t.selectedValue;return new Ea(a).div(Yr).mul(100)},zr=(t,a)=>t.direction==="ABOVE"?a>t.selectedValue:a<t.selectedValue;class qr extends A{constructor(){super("DICE")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:ya,max:Ut}),n=$r(r);return{isFinished:!0,payoutMultiplier:zr(r,e.value)?x.withWinChance(a,n):new Ea(0),outputs:{result:e.values},randomValues:e}}}import vr from"big.js";import{Guard as lt}from"@betorigami/guard";var fa;((n)=>{n.CLASSIC="CLASSIC";n.LOW_RISK="LOW_RISK";n.MEDIUM_RISK="MEDIUM_RISK";n.HIGH_RISK="HIGH_RISK"})(fa||={});var Xr=[1,2,3,4,5,6,7,8,9,10],Oa=(t)=>{return Xr.includes(t)};var Qr={[1]:{CLASSIC:[0,3.96],LOW_RISK:[0.7,1.85],MEDIUM_RISK:[0.4,2.75],HIGH_RISK:[0,3.96]},[2]:{CLASSIC:[0,1.9,4.5],LOW_RISK:[0,2,3.8],MEDIUM_RISK:[0,1.8,5.1],HIGH_RISK:[0,0,17.1]},[3]:{CLASSIC:[0,1,3.1,10.4],LOW_RISK:[0,1.1,1.38,26],MEDIUM_RISK:[0,0,2.8,50],HIGH_RISK:[0,0,0,81.5]},[4]:{CLASSIC:[0,0.8,1.8,5,22.5],LOW_RISK:[0,0,2.2,7.9,90],MEDIUM_RISK:[0,0,1.7,10,100],HIGH_RISK:[0,0,0,10,259]},[5]:{CLASSIC:[0,0.25,1.4,4.1,16.5,36],LOW_RISK:[0,0,1.5,4.2,13,300],MEDIUM_RISK:[0,0,1.4,4,14,390],HIGH_RISK:[0,0,0,4.5,48,450]},[6]:{CLASSIC:[0,0,1,3.68,7,16.5,40],LOW_RISK:[0,0,1.1,2,6.2,100,700],MEDIUM_RISK:[0,0,0,3,9,180,710],HIGH_RISK:[0,0,0,0,11,350,710]},[7]:{CLASSIC:[0,0,0.47,3,4.5,14,31,60],LOW_RISK:[0,0,1.1,1.6,3.5,15,225,700],MEDIUM_RISK:[0,0,0,2,7,30,400,800],HIGH_RISK:[0,0,0,0,7,90,400,800]},[8]:{CLASSIC:[0,0,0,2.2,4,13,22,55,70],LOW_RISK:[0,0,1.1,1.5,2,5.5,39,100,800],MEDIUM_RISK:[0,0,0,2,4,11,67,400,900],HIGH_RISK:[0,0,0,0,5,20,270,600,900]},[9]:{CLASSIC:[0,0,0,1.55,3,8,15,44,60,85],LOW_RISK:[0,0,1.1,1.3,1.7,2.5,7.5,50,250,1000],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1000],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1000]},[10]:{CLASSIC:[0,0,0,1.4,2.25,4.5,8,17,50,80,100],LOW_RISK:[0,0,1.1,1.2,1.3,1.8,3.5,13,50,250,1000],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1000],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1000]}},gr={[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]}},Wr={[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]}},Lr={[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]}},Kr={[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]}},Sa=new P(new Map([[1,Qr],[2,gr],[3,Wr],[4,Lr],[8,Kr]]));class te extends A{constructor(){super("KENO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}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 p of r.selectedNumbers)lt.againstNonInteger(p,()=>l.createValidationError("Only integers can be selected")),lt.against(p<0||p>39,()=>l.createValidationError("Invalid number selected"));let e=t.getUniqueRandomInts({min:0,max:39,count:10}),n=r.selectedNumbers.filter((p)=>e.values.includes(p)),o=r.selectedNumbers.length;if(!Oa(o))throw new Error(`Invalid tile count: ${o}`);let d=Sa.getMultipliers(a)[o][r.riskLevel][n.length];if(d===void 0)throw new Error(`No multiplier found for matching tile count ${n.length}`);return{isFinished:!0,payoutMultiplier:new vr(d),outputs:{result:e.values},randomValues:e}}}import I from"big.js";var Ha=(t,a)=>{return t.gt(a)?t:a};var Da=(t,a)=>{return t.lt(a)?t:a};class ae extends A{constructor(){super("LIMBO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,edge:a,gameInputs:r}){let e=t.getRandomInt({min:1,max:4294967295}),n=e.max,o=new I(16777216),i=new I(1),c=new I(1e6),u=e.value,d=new I(u-1).div(n),s=(100-a)/100,p=o.div(d.mul(o).plus(1)).mul(s),E=Ha(i,Da(p,c));return{isFinished:!0,payoutMultiplier:E.gte(r.targetMultiplier)?new I(r.targetMultiplier):new I(0),outputs:{randomMultiplier:E,result:e.values},randomValues:e}}}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 e=1;e<=a;e++)r=r*(t-e+1)/e;return r};class re extends A{constructor(){super("MINES")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}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 i=t.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),c=i.values.some((B)=>r.selectedTiles.includes(B)),u=r.hasCashedOut||c,d=(100-a)/100,s=new dt(Zt(25-r.minesCount,r.selectedTiles.length)).div(new dt(Zt(25,r.selectedTiles.length))),E=r.hasCashedOut&&!c?new dt(d).div(s):new dt(0);return{isFinished:u,payoutMultiplier:E,outputs:{result:i.values},randomValues:i}}}import{Big as le}from"big.js";var ha;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(ha||={});var Ji=[8,9,10,11,12,13,14,15,16],ee={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]}},ne={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]}},oe={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]}},ie={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]}},ce={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]}},Ca=new P(new Map([[1,ee],[2,ne],[3,oe],[4,ie],[8,ce]]));class de extends A{constructor(){super("PLINKO")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}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 e=a.numberOfRows,i=Ca.getMultipliers(r)[a.riskLevel][e],c=t.getRandomIntsWithReplacement({min:0,max:1,count:a.numberOfRows}),d=c.values.reduce((p,E)=>p+E,0),s=i[d];if(s===void 0)throw new Error(`No payout found for end position ${d}`);return{isFinished:!0,payoutMultiplier:le(s),outputs:{result:c.values},randomValues:c}}}import{Big as pt}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],xa=[37,...kt],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]],ja=[[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]],Ta=[[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]],Ra=[[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]],_a=[[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]],Na=[0,1,2,3,37],wa=[[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]],Va=[[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 Z;((r)=>{r.RED="RED";r.BLACK="BLACK"})(Z||={});var k;((r)=>{r.LOW="LOW";r.HIGH="HIGH"})(k||={});var G;((e)=>{e.TOP="TOP";e.MIDDLE="MIDDLE";e.BOTTOM="BOTTOM"})(G||={});var M;((e)=>{e.FIRST="FIRST";e.SECOND="SECOND";e.THIRD="THIRD"})(M||={});var Gt;((r)=>{r.AMERICAN="AMERICAN";r.EUROPEAN="EUROPEAN"})(Gt||={});var X=2.7,Q=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)&&g(a.value)))throw l.createValidationError("Invalid straight bet.");if(!t.splitBets.every((a)=>a.amount.gte(0)&&ue(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&se(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&pe(a.values)))throw l.createValidationError("Invalid corner bet.");if(!t.doubleStreetBets.every((a)=>a.amount.gte(0)&&Ae(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(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.")},g=(t)=>{return kt.includes(t)},ue=(t)=>{if(t.length!==2)return!1;if(!t.every(g))return!1;return Pa.some(([a,r])=>a===t[0]&&r===t[1])},se=(t)=>{if(t.length!==3)return!1;if(!t.every(g))return!1;return ja.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},pe=(t)=>{if(t.length!==4)return!1;if(!t.every(g))return!1;return Ra.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},Ae=(t)=>{if(t.length!==6)return!1;if(!t.every(g))return!1;return wa.some(([a,r,e,n,o,i])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3]&&o===t[4]&&i===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)&&Be(a.values)))throw l.createValidationError("Invalid split bet.");if(!t.streetBets.every((a)=>a.amount.gte(0)&&me(a.values)))throw l.createValidationError("Invalid street bet.");if(!t.cornerBets.every((a)=>a.amount.gte(0)&&Ee(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)&&ye(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(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.")},W=(t)=>{return xa.includes(t)};function Be(t){if(t.length!==2)return!1;if(!t.every(W))return!1;return ba.some(([a,r])=>a===t[0]&&r===t[1])}var me=(t)=>{if(t.length!==3)return!1;if(!t.every(W))return!1;return Ta.some(([a,r,e])=>a===t[0]&&r===t[1]&&e===t[2])},Ee=(t)=>{if(t.length!==4)return!1;if(!t.every(W))return!1;return _a.some(([a,r,e,n])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3])},ye=(t)=>{if(t.length!==6)return!1;if(!t.every(W))return!1;return Va.some(([a,r,e,n,o,i])=>a===t[0]&&r===t[1]&&e===t[2]&&n===t[3]&&o===t[4]&&i===t[5])};var fe=(t,a)=>{let r=a===X&&t.type==="EUROPEAN",e=a===Q&&t.type==="AMERICAN";if(!r&&!e)throw l.createValidationError(`Attempted to play ${t.type} roulette on edge ${a}`)},Ia=(t,a)=>{if(fe(t,a),t.type==="EUROPEAN")ut(t.inputs);else st(t.inputs)};var Oe={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Se=[3,6,9,12,15,18,21,24,27,30,33,36],He=[2,5,8,11,14,17,20,23,26,29,32,35],De=[1,4,7,10,13,16,19,22,25,28,31,34],he=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Ce=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];class Mt extends A{constructor(){super("ROULETTE")}determineGameResult({generator:t,gameInputs:a}){this.validateInputs(a);let r=t.getRandomInt({min:0,max:this.maxNumber}),e=r.value,n=this.determineBetOutcomes(a,e),{payoutMultiplier:o}=this.getPayoutDetails(a,e);return{outputs:{betOutcomes:n,result:r.values},payoutMultiplier:o,isFinished:!0,randomValues:r}}getBetAmount(t){return this.calculateTotalBetAmount(this.getBetTotals(t))}getPayoutDetails(t,a){let r=this.determineBetOutcomes(t,a),e=this.getBetTotals(t),n=this.getBetTotals(r.winningBets),o=this.calculateTotalBetAmount(e),i=this.calculateTotalPayout(n);return{payoutMultiplier:o.gt(0)?i.div(o):new pt(0),payoutAmount:i}}determineBetOutcomes(t,a){let r={},e={};for(let n of Object.keys(t)){let o=t[n],i=this.betPredicates[n],{winning:c,losing:u}=this.partitionBets(o,i,a);r[n]=c,e[n]=u}return{winningBets:r,losingBets:e}}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 he.includes(a)&&r.color==="RED"||Ce.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 Se.includes(a)&&r.column==="TOP"||He.includes(a)&&r.column==="MIDDLE"||De.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 e=a%2===0?"EVEN":"ODD";return r.parity===e}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((e)=>a(e,r)),losing:t.filter((e)=>!a(e,r))}}calculateTotalPayout(t){return Object.entries(t).reduce((a,[r,e])=>{let o=Oe[r];return a.plus(e.mul(o||0))},new pt(0))}}class Ua 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[X]}validateInputs(t){ut(t)}}class Za 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[Q]}validateInputs(t){st(t)}isWinningBasketBet(t,a){return Na.some((r)=>r===a)}}class ka extends A{europeanGame;americanGame;constructor(){super("ROULETTE");this.europeanGame=new Ua,this.americanGame=new Za}get supportedEdgeConfigurations(){return[X,Q]}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(Ia(a,t.edge),a.type==="EUROPEAN"){let o=this.europeanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:i}=o.outputs;return{...o,outputs:{type:"european",betOutcomes:i,result:o.outputs.result}}}let e=this.americanGame.determineGameResult({...r,gameInputs:a.inputs}),{betOutcomes:n}=e.outputs;return{...e,outputs:{type:"american",betOutcomes:n,result:e.outputs.result}}}}var fc=(t)=>{return new ka().getBetAmount(t)};import{Big as Re}from"big.js";var L;((e)=>{e.LOW_RISK="LOW_RISK";e.MEDIUM_RISK="MEDIUM_RISK";e.HIGH_RISK="HIGH_RISK"})(L||={});var K;((o)=>{o[o.TEN=10]="TEN";o[o.TWENTY=20]="TWENTY";o[o.THIRTY=30]="THIRTY";o[o.FORTY=40]="FORTY";o[o.FIFTY=50]="FIFTY"})(K||={});var xe={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}}},Pe={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}}},be={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}}},je={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}}},Te={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}}},Ga=new P(new Map([[1,xe],[2,Pe],[3,be],[4,je],[8,Te]]));var Ma={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 _e extends A{constructor(){super("WHEEL")}get supportedEdgeConfigurations(){return[1,2,3,4,8]}determineGameResult({generator:t,gameInputs:a,edge:r}){if(!Object.values(K).includes(a.segments))throw new Error("Invalid segments value");if(!Object.values(L).includes(a.riskLevel))throw new Error("Invalid risk level");let n=Ga.getMultipliers(r)[a.riskLevel];if(n===void 0)throw new Error(`No multipliers found for risk level ${a.riskLevel}`);let o=n[a.segments];if(o===void 0)throw new Error(`No multipliers found for segment ${a.segments}`);let i=Ma[a.riskLevel];if(i===void 0)throw new Error(`No patterns found for risk level ${a.riskLevel}`);let c=i[a.segments];if(c===void 0)throw new Error(`No patterns found for segment ${a.segments}`);let u=t.getRandomInt({min:0,max:c.length-1}),d=c[u.value];if(d===void 0)throw new Error(`No pattern found for segment ${a.segments} and value ${u.value}`);let s=o[d];if(s===void 0)throw new Error(`No payout found for picked segment ${d}`);return{isFinished:!0,payoutMultiplier:new Re(s),outputs:{result:u.values},randomValues:u}}}export{Ia as validateRouletteGameInputs,Xe as validateAdvancedDiceInputs,Qr as rtp99Multipliers,gr as rtp98Multipliers,Wr as rtp97Multipliers,Lr as rtp96Multipliers,Kr as rtp92Multipliers,Ca as plinkoMultipliers,Zt as nCr,Sa as kenoMultipliers,Oa as isTileCount,zr as hasDiceWon,yr as hasBlitzWon,Ro as getMaxMultiplierForDifficulty,ho as getBlitzDefaults,Gr as diamondsMultipliers,fc as calculateRouletteBetAmount,$r as calculateDiceWinChance,fr as calculateBlitzWinChance,rr as calculateBaccaratBetAmount,Yt as calculateAdvancedDiceWinChance,Da as bigMin,Ha as bigMax,Qa as advancedDiceIsWithinBoundsInclusive,Bt as advancedDiceIsWithinBoundsExclusive,ga as advancedDiceGetInclusiveBoundsRange,mt as advancedDiceGetExclusiveBoundsRange,K as WheelSegments,L as WheelRiskLevel,_e as Wheel,or as WIN_MULTIPLIER,on as VALID_SUITS,cn as VALID_RANKS,ja as VALID_EUROPEAN_STREETS,kt as VALID_EUROPEAN_STRAIGHTS,Pa as VALID_EUROPEAN_SPLITS,wa as VALID_EUROPEAN_DOUBLE_STREETS,Ra as VALID_EUROPEAN_CORNERS,Ta as VALID_AMERICAN_STREETS,xa as VALID_AMERICAN_STRAIGHTS,ba as VALID_AMERICAN_SPLITS,Va as VALID_AMERICAN_DOUBLE_STREETS,_a as VALID_AMERICAN_CORNERS,Dt as ThreeCardBonusType,Se as TOP_COLUMN,Xr as TILE_COUNTS,Lt as THREE_CARD_BONUS_PAYOUTS,A as SingleActionGame,V as SPLIT_BET_SIZE_FACTOR,Gt as RouletteType,ka as Roulette,Wa as RollType,ct as RandomValuePool,he as RED_NUMBERS,at as RANDOM_MIN_VALUE,rt as RANDOM_MAX_VALUE,ha as PlinkoRiskLevel,de as Plinko,U as Parity,Ht as PairBonusType,ir as PUSH_MULTIPLIER,Ji as PLINKO_ROW_COUNTS,Oe as PAYOUT_MULTIPLIERS,Wt as PAIR_BONUS_PAYOUTS,O as OrigamiGame,x as MultiplierCalculator,bt as MultiActionGame,re as Mines,Ya as MIN_WIN_CHANCE,He as MIDDLE_COLUMN,$a as MAX_WIN_CHANCE,Ct as MAX_CARDS_PER_ROUND,ae as Limbo,cr as LOSE_MULTIPLIER,fa as KenoRiskLevel,te as Keno,Ot as InsuranceOutcome,xt as INSURANCE_WIN_PAYOUT,F as INSURANCE_BET_SIZE_FACTOR,An as INSURANCE_BET_MULTIPLIER,k as Half,Fa as GameErrorCode,l as GameError,gt as FACE_CARD_VALUE,Ua as EuropeanRoulette,X as EUROPEAN_HOUSE_EDGE,Ft as EFFECTIVE_RANGE,M as Dozen,Jr as DiceDirection,qr as Dice,wr as DiamondsResultType,Fr as Diamonds,Tr as Darts,R as DOUBLE_DOWN_BET_SIZE_FACTOR,ya as DICE_MIN_ROLL,Ut as DICE_MAX_ROLL,Yr as DICE_EFFECTIVE_RANGE,Qt as DEALER_STAND_VALUE,Ba as DARTS_MIN_VALUE,wt as DARTS_MAX_VALUE,ma as DARTS_DIFFICULTY_LEVEL,Vt as DARTS_BOARD_CONFIGS,G as Column,Z as Color,Bn as CARDS_PER_SUIT,Or as Blitz,ft as BlackjackOutcome,St as BlackjackActionType,Er as Blackjack,va as BaccaratOutcome,tr as BaccaratBetType,er as Baccarat,ht as BUST_VALUE,De as BOTTOM_COLUMN,pa as BLITZ_RANDOM_NUMBER_COUNT,ua as BLITZ_MIN_CARD_RANGE,sa as BLITZ_MAX_CARD_RANGE,z as BLITZ_CARD_COUNT,Ce as BLACK_NUMBERS,h as BLACKJACK_VALUE,nr as BLACKJACK_MULTIPLIER,ot as BASE_PAYOUT_MULTIPLIERS,Za as AmericanRoulette,La as AdvancedDice,Q as AMERICAN_HOUSE_EDGE,Na as AMERICAN_BASKET,Pt as ACE_SOFT_BONUS};
|
|
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};
|