@betorigami/game-calculations 9.0.2 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("@betorigami/guard"),l=require("big.js");l=s(l,1);let u=require("@xstate/store"),d=require("fast-deep-equal");d=s(d,1);const f=Array.from({length:52},(e,t)=>t),p=[`Spades`,`Hearts`,`Diamonds`,`Clubs`],m=[`Ace`,`Two`,`Three`,`Four`,`Five`,`Six`,`Seven`,`Eight`,`Nine`,`Ten`,`Jack`,`Queen`,`King`],h=[`Jack`,`Queen`,`King`],g={Hearts:`red`,Diamonds:`red`,Spades:`black`,Clubs:`black`};let ee=function(e){return e.UNSUPPORTED_EDGE=`UNSUPPORTED_EDGE`,e.INPUT_VALIDATION_ERROR=`INPUT_VALIDATION_ERROR`,e}({});var _=class e extends Error{static createUnsupportedEdgeError(t){return new e(`UNSUPPORTED_EDGE`,t)}static createValidationError(t){return new e(`INPUT_VALIDATION_ERROR`,t)}static isGameError(t){return t instanceof e}errorCode;constructor(e,t){super(t),this.errorCode=e}};let te=function(e){return e.DICE=`DICE`,e.MINES=`MINES`,e.KENO=`KENO`,e.LIMBO=`LIMBO`,e.ADVANCED_DICE=`ADVANCED_DICE`,e.BACCARAT=`BACCARAT`,e.DIAMONDS=`DIAMONDS`,e.PLINKO=`PLINKO`,e.ROULETTE=`ROULETTE`,e.WHEEL=`WHEEL`,e.BLACKJACK=`BLACKJACK`,e.BLITZ=`BLITZ`,e.DARTS=`DARTS`,e}({});var v=class{gameId;constructor(e){this.gameId=e}getGameResult(e){let t=this.supportedEdgeConfigurations.includes(e.edge);return c.Guard.against(!t,()=>_.createUnsupportedEdgeError(`${this.gameId} does not support ${e.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(e)}},y=class{static withMultiplier(e,t){return new l.default(e).times(new l.default(100-t).div(100))}static withWinChance(e,t){return(0,l.default)(100-e).div(t)}};const b=1e4,x=10001,ne=e=>{if(e<0)throw _.createValidationError(`Lower bound ${e} is below minimum allowed value 0`)},re=e=>{if(e>1e4)throw _.createValidationError(`Upper bound ${e} is above maximum allowed value ${b}`)},S=e=>{if(ne(e.lower),re(e.upper),e.lower>=e.upper)throw _.createValidationError(`Lower bound ${e.lower} must be less than ${e.upper}`)},ie=(e,t)=>{let[n,r]=e.lower<=t.lower?[e,t]:[t,e];if(n.upper>r.lower)throw _.createValidationError(`Bounds must not overlap`)},ae=(e,t)=>t>=e.lower&&t<=e.upper,C=e=>e.upper-e.lower+1,w=(e,t)=>t>e.lower&&t<e.upper,T=e=>e.upper-e.lower-1;let oe=function(e){return e.ROLL_BETWEEN=`ROLL_BETWEEN`,e.ROLL_OUTSIDE=`ROLL_OUTSIDE`,e.ROLL_BETWEEN_TWO=`ROLL_BETWEEN_TWO`,e}({});const E=e=>{let t=(()=>{switch(e.mode){case`ROLL_BETWEEN`:return S(e.bounds),T(e.bounds);case`ROLL_OUTSIDE`:return S(e.bounds),x-C(e.bounds);case`ROLL_BETWEEN_TWO`:return S(e.firstBounds),S(e.secondBounds),ie(e.firstBounds,e.secondBounds),T(e.firstBounds)+T(e.secondBounds)}})(),n=(0,l.Big)(t).div(x).mul(100);if(n.lt(.01))throw _.createValidationError(`Win chance too low`);if(n.gt(98))throw _.createValidationError(`Win chance too high`);return n},se=e=>{E(e)};var ce=class extends v{constructor(){super(`ADVANCED_DICE`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=E(n),i=e.getRandomInt({min:0,max:b}),a=i.value,o=(()=>{switch(n.mode){case`ROLL_BETWEEN`:return w(n.bounds,a);case`ROLL_OUTSIDE`:return!ae(n.bounds,a);case`ROLL_BETWEEN_TWO`:return w(n.firstBounds,a)||w(n.secondBounds,a)}})()?y.withWinChance(t,r):new l.Big(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:i.values},randomValues:i}}},D=class{value;constructor(e){let t=f[e];c.Guard.againstNullOrUndefined(t,`Invalid card value: ${e}`),this.value=t}get suit(){let e=Math.floor(this.value/13),t=p[e];return c.Guard.againstNullOrUndefined(t,`Invalid suit index: ${e}`),t}get rank(){let e=this.value%13,t=m[e];return c.Guard.againstNullOrUndefined(t,`Invalid rank index: ${e}`),t}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}};const O=e=>e.legs.reduce((e,t)=>e.add(t.amount),new l.default(`0`)),le=[`Clubs`,`Diamonds`,`Hearts`,`Spades`],ue=[`Ace`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`Jack`,`Queen`,`King`],de={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`};let fe=function(e){return e.PLAYER_WIN=`PLAYER_WIN`,e.TIE=`TIE`,e.BANKER_WIN=`BANKER_WIN`,e}({}),pe=function(e){return e.PLAYER=`PLAYER`,e.TIE=`TIE`,e.BANKER=`BANKER`,e}({});const me={PLAYER_WIN:{betType:`PLAYER`,multiplier:2},TIE:{betType:`TIE`,multiplier:9},BANKER_WIN:{betType:`BANKER`,multiplier:1.95}},k=e=>new l.default(0).add(e.bets.reduce((e,t)=>e.add(t.amount),new l.default(0))),he=(e,t)=>e===`TIE`&&(t===`PLAYER`||t===`BANKER`);var ge=class extends v{constructor(){super(`BACCARAT`)}get supportedEdgeConfigurations(){return[1]}getBetAmount(e){return k(e)}determineGameResult({generator:e,gameInputs:t}){this.validateGameInputs(t);let n=e.getRandomIntsWithReplacement({min:0,max:51,count:6}),r=n.values,i=r.slice(0,3),a=r.slice(3,6),o=[],s=0;for(let e of i.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);o.push(t),s=(s+n)%10}let c=[],u=0;for(let e of a.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);c.push(t),u=(u+n)%10}if(!this.isNaturalWin(s,u)){let e=this.shouldDrawThirdPlayerCard(s),t=null;e&&(t=this.mapRandomValueToCardValue(i[2]),o.push(this.mapRandomValueToCard(i[2])),s=(s+t)%10),this.shouldDrawThirdBankerCard(u,t)&&(c.push(this.mapRandomValueToCard(a[2])),u=(u+this.mapRandomValueToCardValue(a[2]))%10)}let d;d=s===u?`TIE`:s>u?`PLAYER_WIN`:`BANKER_WIN`;let f=k(t),{betType:p,multiplier:m}=me[d],h={legs:t.bets.map(e=>e.type===p?{amount:e.amount.mul(m)}:{amount:he(d,e.type)?e.amount:new l.default(`0`)})},g=O(h);return{isFinished:!0,payout:h,payoutMultiplier:f.gt(0)?g.div(f):new l.default(0),outputs:{playerCards:o,playerHandValue:s,bankerCards:c,bankerHandValue:u,gameOutcome:d,result:n.values},randomValues:n}}validateGameInputs(e){if(e.bets.length===0)throw Error(`Must place at least a single bet.`);if(!e.bets.every(e=>e.amount.gte(0)))throw Error(`Invalid bet.`)}mapRandomValueToCard(e){let t=new D(e);return{suit:t.suit,rank:de[t.rank]}}isNaturalWin(e,t){let n=[8,9];return n.includes(e)||n.includes(t)}mapRandomValueToCardValue(e){let t=e%13;return t===0?1:t>=10?10:t+1}shouldDrawThirdPlayerCard(e){return e<=5}shouldDrawThirdBankerCard(e,t){return t===null?e<=5:e<=2?!0:e===3?t!==8:e===4?[2,3,4,5,6,7].includes(t):e===5?[4,5,6,7].includes(t):e===6&&[6,7].includes(t)}};let _e=function(e){return e.WIN=`WIN`,e.LOSE=`LOSE`,e.PUSH=`PUSH`,e.PLAYER_BLACKJACK=`PLAYER_BLACKJACK`,e}({}),ve=function(e){return e.WON=`WON`,e.LOST=`LOST`,e}({}),ye=function(e){return e.START=`START`,e.HIT=`BLACKJACK_HIT`,e.STAND=`BLACKJACK_STAND`,e.BUY_INSURANCE=`BLACKJACK_BUY_INSURANCE`,e.REJECT_INSURANCE=`BLACKJACK_REJECT_INSURANCE`,e.DOUBLE_DOWN=`BLACKJACK_DOUBLE_DOWN`,e.SPLIT=`BLACKJACK_SPLIT`,e}({}),be=function(e){return e.EXACT_PAIR=`EXACT_PAIR`,e.COLORED_PAIR=`COLORED_PAIR`,e.MIXED_PAIR=`MIXED_PAIR`,e.LOSS=`LOSS`,e}({}),xe=function(e){return e.SUITED_TRIPS=`SUITED_TRIPS`,e.STRAIGHT_FLUSH=`STRAIGHT_FLUSH`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.STRAIGHT=`STRAIGHT`,e.FLUSH=`FLUSH`,e.LOSS=`LOSS`,e}({});const Se=2.5,A=.5,j={PLAYER_BLACKJACK:Se,WIN:2,PUSH:1,LOSE:0},M={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},Ce={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var N=class e extends D{get numericRank(){return h.includes(this.rank)?10:m.indexOf(this.rank)+1}static fromValue(t){return c.Guard.against(!f.includes(t),`Invalid card value: ${t}`),new e(t)}},we=class{cards;hardHandValue;softHandValue=null;constructor(e){this.cards=e,this.hardHandValue=e.reduce((e,t)=>e+t.numericRank,0),e.some(e=>e.rank===`Ace`)&&this.hardHandValue+10<=21&&(this.softHandValue=this.hardHandValue+10)}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>21}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===21}get highestHandValue(){return this.softHandValue===null?this.hardHandValue:this.softHandValue}},Te=class{cards;value;constructor(e){this.cards=e.map(e=>N.fromValue(e)),this.value=new we(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(e=>e.value)}toDto(){return{cards:this.cards.map(e=>e.toDto()),value:this.highestHandValue}}},Ee=class e extends Te{otherCards;upCard;holeCard;constructor(e,t,n=[]){super([e,t,...n]),this.otherCards=n,this.upCard=N.fromValue(e),this.holeCard=N.fromValue(t)}static withInitialDeal(t){return new e(t.upCard,t.holeCard)}addDrawnCards(t){return new e(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(e=!1){return e?super.toDto():{cards:[this.upCard.toDto()],value:new we([this.upCard]).highestHandValue}}},P=class e extends Te{static withInitialDeal(t){return new e(t)}addDrawnCards(t){return new e([...this.rawValues,...t])}},De=class e{source;index=0;constructor(e){this.source=e}static from(t,n){return c.Guard.against(n<=0,`Count must be positive, got ${n}`),c.Guard.against(t.values.length!==n,`Expected ${n} values, got ${t.values.length}`),new e(t)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let e=this.source.values[this.index];return c.Guard.againstUndefined(e,`RandomValuePool exhausted`),this.index+=1,e}take(e){c.Guard.against(this.index+e>this.source.values.length,`RandomValuePool exhausted: requested ${e} but only ${this.source.values.length-this.index} remain`);let t=this.source.values.slice(this.index,this.index+e);return this.index+=e,t}},Oe=class{gameId;edge;constructor(e,t){this.gameId=e,this.edge=t,this.validateEdge(t)}play(e,t,n=[]){let r=this.createGameStore(),i=this.generateRandomValues(e),a=i.toMultipleRandomValues();for(let e of n)r.send({...e.playerArgument,randomValuePool:i});let o=n[n.length-1];o&&c.Guard.against(!(0,d.default)(o.state,this.toExternalState(r.getSnapshot().context.state)),`The final state of the game does not match the expected state based on the previous actions`),r.send({...t,randomValuePool:i});let s=r.getSnapshot().context;return{playerArgument:s.playerArgument,state:this.toExternalState(s.state),config:s.config,additionalBetAmount:s.additionalBetAmount,proof:{proofHash:a.proofHash,proofString:a.proofString}}}validateEdge(e){let t=this.supportedEdgeConfigurations.includes(e);c.Guard.against(!t,()=>_.createUnsupportedEdgeError(`${this.gameId} does not support ${e}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}};const ke=e=>[e.pairBonus===null?null:{amount:(0,l.default)(e.pairBonus.betAmount).mul(e.pairBonus.payoutMultiplier)},e.threeCardBonus===null?null:{amount:(0,l.default)(e.threeCardBonus.betAmount).mul(e.threeCardBonus.payoutMultiplier)}].filter(e=>e!==null),Ae=e=>{let t=e.betAmounts.mainBetAmount,n=e.actionType===`BLACKJACK_DOUBLE_DOWN`?t.mul(1):(0,l.default)(0),r=e.insuranceOutcome===void 0?(0,l.default)(0):e.insuranceStake,i=t.plus(n).mul(j[e.outcome]),a=e.insuranceOutcome===`WON`?r.mul(3):(0,l.default)(0),o=ke(e.sideBetResults),s=[{amount:i},...e.insuranceOutcome===void 0?[]:[{amount:a}],...o],u=O({legs:s}),d=t.plus(r).plus(n).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);c.Guard.against(d.eq(0),`Total bet amount cannot be zero`);let f=u.div(d);c.Guard.against(e.actionType===`BLACKJACK_SPLIT`,`SPLIT action type is not valid for standard multiplier calculation`);let p;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:p=n;break;case`BLACKJACK_BUY_INSURANCE`:p=e.insuranceStake;break;case`BLACKJACK_SPLIT`:p=t.mul(1)}return{payouts:s,totalBetAmount:d,multiplier:f,additionalBetAmount:p}},je=e=>{let t=e.betAmounts.mainBetAmount,n=e.mainHandDoubledDown?t.mul(1):(0,l.default)(0),r=e.splitHandDoubledDown?t.mul(1):(0,l.default)(0),i=e.insuranceOutcome===void 0?(0,l.default)(0):e.insuranceStake,a=t.plus(n).mul(j[e.mainOutcome]),o=t.plus(r).mul(j[e.splitOutcome]),s=e.insuranceOutcome===`WON`?i.mul(3):(0,l.default)(0),u=ke(e.sideBetResults),d=[{amount:a},{amount:o},...e.insuranceOutcome===void 0?[]:[{amount:s}],...u],f=O({legs:d}),p=t.plus(t).plus(i).plus(n).plus(r).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);c.Guard.against(p.eq(0),`Total bet amount cannot be zero`);let m=f.div(p),h;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:h=t.mul(1);break;case`BLACKJACK_SPLIT`:h=t.mul(1)}return{payouts:d,totalBetAmount:p,multiplier:m,additionalBetAmount:h}},Me=(e,t)=>t(e.mul(A)),F=e=>e.every(t=>t===e[0]),Ne=e=>{let t=[...e].sort((e,t)=>e-t);return t.every((e,n)=>{let r=t[n-1];return n===0||(c.Guard.againstUndefined(r,`Previous value cannot be undefined`),e===r+1)})},Pe={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},Fe={...Pe,Ace:14},Ie=e=>Ne(e.map(e=>Pe[e]))||Ne(e.map(e=>Fe[e])),Le=(e,t)=>{let n=N.fromValue(e),r=N.fromValue(t);return n.rank===r.rank?e===t?`EXACT_PAIR`:g[n.suit]===g[r.suit]?`COLORED_PAIR`:`MIXED_PAIR`:`LOSS`},Re=(e,t)=>({betAmount:e,result:t,payoutMultiplier:M[t]}),ze=(e,t,n)=>{let r=N.fromValue(e),i=N.fromValue(t),a=N.fromValue(n),o=[r.rank,i.rank,a.rank],s=F([r.suit,i.suit,a.suit]),c=F(o),l=Ie(o);return F([e,t,n])?`SUITED_TRIPS`:s&&l?`STRAIGHT_FLUSH`:c?`THREE_OF_A_KIND`:l?`STRAIGHT`:s?`FLUSH`:`LOSS`},Be=(e,t)=>({betAmount:e,result:t,payoutMultiplier:Ce[t]}),Ve={state:{isFinished:!1,phase:`uninitialised`,multiplier:(0,l.default)(0)},config:{},playerArgument:{type:`START`,mainBetAmount:`0`,pairBonusAmount:`0`,threeCardBonusAmount:`0`}},I=e=>N.fromValue(e).value;function He(e){c.Guard.against(e.phase!==`in-progress`,`Expected a started, in-progress game state`)}function Ue(e){c.Guard.against(e.phase!==`awaiting-insurance`,`Expected game to be awaiting insurance decision`)}function L(e){c.Guard.against(e.phase!==`in-progress`&&e.phase!==`playing-main-hand`&&e.phase!==`playing-split-hand`,`Expected a started, in-progress game state`)}const We=(e,t)=>{let n=t;for(;n.highestHandValue<17;)n=n.addDrawnCards([I(e.takeOne())]);return n},R=(e,t)=>{if(e.isBusted)return`LOSE`;if(t.isBusted)return`WIN`;let n=e.highestHandValue,r=t.highestHandValue;return n>r?`WIN`:n<r?`LOSE`:`PUSH`},Ge=e=>e.insuranceOutcome===void 0?(0,l.default)(0):e.calculateStake(e.betAmounts.mainBetAmount),Ke=e=>{let{payouts:t,multiplier:n,additionalBetAmount:r}=Ae({outcome:e.outcome,insuranceOutcome:e.insuranceOutcome,insuranceStake:Ge(e),actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`finished`,playerHand:e.playerHand,dealerHand:e.dealerHand,outcome:e.outcome,payout:{legs:t},multiplier:n,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:r}},qe=e=>{let t=We(e.randomValuePool,e.dealerHand),n=R(e.playerHand,t);return Ke({...e,dealerHand:t,outcome:n})},Je=e=>{let t=e.mainHand.isBusted&&e.splitHand.isBusted?e.dealerHand:We(e.randomValuePool,e.dealerHand),n=R(e.mainHand,t),r=R(e.splitHand,t),{payouts:i,multiplier:a,additionalBetAmount:o}=je({hasSplit:!0,mainOutcome:n,splitOutcome:r,insuranceOutcome:e.insuranceOutcome,insuranceStake:Ge(e),mainHandDoubledDown:e.mainHandDoubledDown,splitHandDoubledDown:e.splitHandDoubledDown,actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`split-finished`,mainHand:e.mainHand,splitHand:e.splitHand,dealerHand:t,mainOutcome:n,splitOutcome:r,payout:{legs:i},multiplier:a,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:o}};var Ye=class extends Oe{roundInsuranceStake;constructor(e,t){super(`BLACKJACK`,e),this.roundInsuranceStake=t}get supportedEdgeConfigurations(){return[1]}generateRandomValues(e){return De.from(e.getRandomIntsWithReplacement({min:0,max:51,count:63}),63)}toExternalState(e){let t=e.phase;switch(t){case`awaiting-insurance`:return{isFinished:!1,phase:`awaiting-insurance`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`in-progress`:return{isFinished:!1,phase:`player-turn`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-main-hand`:return{isFinished:!1,phase:`playing-main-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-split-hand`:return{isFinished:!1,phase:`playing-split-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,outcome:e.outcome,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`split-finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,mainOutcome:e.mainOutcome,splitOutcome:e.splitOutcome,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`uninitialised`:throw Error(`Cannot convert uninitialised state to external state`);default:c.Guard.againstNever(t,`Invalid state received`)}}createGameStore(){let e=e=>{let t=Me(e,this.roundInsuranceStake);return c.Guard.against(e.gt(0)&&t.eq(0),`Insurance stake rounds below the smallest unit this currency supports`),t},t=t=>Ke({...t,calculateStake:e}),n=t=>qe({...t,calculateStake:e}),r=t=>Je({...t,calculateStake:e});return(0,u.createStore)({context:Ve,on:{START:(e,n)=>{let{state:r}=e;c.Guard.against(r.phase!==`uninitialised`,`START action requires a fresh game`);let i=I(n.randomValuePool.takeOne()),a=I(n.randomValuePool.takeOne()),o=I(n.randomValuePool.takeOne()),s=I(n.randomValuePool.takeOne()),u=P.withInitialDeal([i,a]),d=Ee.withInitialDeal({upCard:o,holeCard:s}),f={mainBetAmount:(0,l.default)(n.mainBetAmount),pairBonusAmount:(0,l.default)(n.pairBonusAmount),threeCardBonusAmount:(0,l.default)(n.threeCardBonusAmount)},p={pairBonus:(0,l.default)(n.pairBonusAmount).gt(0)?Re(n.pairBonusAmount,Le(i,a)):null,threeCardBonus:(0,l.default)(n.threeCardBonusAmount).gt(0)?Be(n.threeCardBonusAmount,ze(i,a,o)):null},m={type:`START`,mainBetAmount:n.mainBetAmount,pairBonusAmount:n.pairBonusAmount,threeCardBonusAmount:n.threeCardBonusAmount};if(d.upCard.rank===`Ace`)return{state:{...r,isFinished:!1,phase:`awaiting-insurance`,playerHand:u,dealerHand:d,betAmounts:f,sideBetResults:p},config:{},playerArgument:m};let h={playerHand:u,dealerHand:d,randomValuePool:n.randomValuePool,playerArgument:m,betAmounts:f,sideBetResults:p};return u.isBlackjack&&d.isBlackjack?t({...h,outcome:`PUSH`}):u.isBlackjack?t({...h,outcome:`PLAYER_BLACKJACK`}):d.isBlackjack?t({...h,outcome:`LOSE`}):{state:{...r,isFinished:!1,phase:`in-progress`,playerHand:u,dealerHand:d,insuranceOutcome:void 0,betAmounts:f,sideBetResults:p},config:{},playerArgument:m}},BLACKJACK_BUY_INSURANCE:(n,r)=>{let{state:i}=n;Ue(i);let{playerHand:a,dealerHand:o,betAmounts:s,sideBetResults:c}=i,l={...i,randomValuePool:r.randomValuePool,playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},betAmounts:s,sideBetResults:c};return a.isBlackjack&&o.isBlackjack?t({...l,outcome:`PUSH`,insuranceOutcome:`WON`}):a.isBlackjack?t({...l,outcome:`PLAYER_BLACKJACK`,insuranceOutcome:`LOST`}):o.isBlackjack?t({...l,outcome:`LOSE`,insuranceOutcome:`WON`}):{state:{...i,phase:`in-progress`,insuranceOutcome:`LOST`},config:{},playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},additionalBetAmount:e(s.mainBetAmount)}},BLACKJACK_REJECT_INSURANCE:(e,n)=>{let{state:r}=e;Ue(r);let{playerHand:i,dealerHand:a,betAmounts:o,sideBetResults:s}=r,c={playerHand:i,dealerHand:a,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`},betAmounts:o,sideBetResults:s};return i.isBlackjack&&a.isBlackjack?t({...c,outcome:`PUSH`}):i.isBlackjack?t({...c,outcome:`PLAYER_BLACKJACK`}):a.isBlackjack?t({...c,outcome:`LOSE`}):{state:{...r,phase:`in-progress`,insuranceOutcome:void 0},config:{},playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`}}},BLACKJACK_HIT:(e,i)=>{let{state:a}=e;switch(L(a),a.phase){case`playing-main-hand`:{let e=a.mainHand.addDrawnCards([I(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?a.splitHand.highestHandValue===21?r({...a,mainHand:e,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_HIT`}}:{state:{...a,mainHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`playing-split-hand`:{let e=a.splitHand.addDrawnCards([I(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,splitHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`in-progress`:{let e=a.playerHand.addDrawnCards([I(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):e.highestHandValue===21?n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`in-progress`,playerHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}default:c.Guard.againstNever(a,`Invalid phase for HIT action`)}},BLACKJACK_STAND:(e,t)=>{let{state:i}=e;switch(L(i),i.phase){case`playing-main-hand`:return i.splitHand.highestHandValue===21?r({...i,splitHandDoubledDown:!1,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}}):{state:{...i,phase:`playing-split-hand`,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_STAND`}};case`playing-split-hand`:return r({...i,splitHandDoubledDown:i.splitHandDoubledDown,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});case`in-progress`:return n({...i,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});default:c.Guard.againstNever(i,`Invalid phase for STAND action`)}},BLACKJACK_DOUBLE_DOWN:(e,i)=>{let{state:a}=e;switch(L(a),a.phase){case`playing-main-hand`:{c.Guard.against(a.mainHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.mainHand.addDrawnCards([I(i.randomValuePool.takeOne())]),{betAmounts:t}=a;return a.splitHand.highestHandValue===21?r({...a,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},additionalBetAmount:t.mainBetAmount.mul(1)}}case`playing-split-hand`:{c.Guard.against(a.splitHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.splitHand.addDrawnCards([I(i.randomValuePool.takeOne())]);return r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},splitHandDoubledDown:!0})}case`in-progress`:{c.Guard.against(a.playerHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.playerHand.addDrawnCards([I(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}})}default:c.Guard.againstNever(a,`Invalid phase for DOUBLE_DOWN action`)}},BLACKJACK_SPLIT:(e,t)=>{let{state:n}=e;He(n);let{playerHand:i,betAmounts:a,sideBetResults:o}=n;c.Guard.against(i.cards.length!==2,`Split is only allowed with exactly 2 cards`);let s=i.cards[0],u=i.cards[1];c.Guard.againstUndefined(s,`First card is missing`),c.Guard.againstUndefined(u,`Second card is missing`),c.Guard.against(s.rank!==u.rank,`Split requires two cards of the same rank`);let d=I(t.randomValuePool.takeOne()),f=I(t.randomValuePool.takeOne()),p=P.withInitialDeal([s.value,d]),m=P.withInitialDeal([u.value,f]);if(s.rank===`Ace`)return r({...n,mainHand:p,splitHand:m,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let h=p.highestHandValue===21,g=m.highestHandValue===21;return h&&g?r({mainHand:p,splitHand:m,dealerHand:n.dealerHand,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},insuranceOutcome:n.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:a,sideBetResults:o}):h?{state:{...n,phase:`playing-split-hand`,mainHand:p,splitHand:m,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}:{state:{...n,phase:`playing-main-hand`,multiplier:(0,l.default)(0),mainHand:p,splitHand:m,mainHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}}}})}getValidNextActionTypes(e){if(e.isFinished)return[];switch(e.phase){case`awaiting-insurance`:return[`BLACKJACK_BUY_INSURANCE`,`BLACKJACK_REJECT_INSURANCE`];case`playing-main-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.mainHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`playing-split-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.splitHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`player-turn`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];if(e.playerHand.cards.length===2){t.push(`BLACKJACK_DOUBLE_DOWN`);let n=e.playerHand.cards[0],r=e.playerHand.cards[1];c.Guard.againstUndefined(n,`First player card is missing`),c.Guard.againstUndefined(r,`Second player card is missing`),n.rank===r.rank&&t.push(`BLACKJACK_SPLIT`)}return t}default:c.Guard.againstNever(e,`Invalid phase for getting valid actions`)}}};const Xe=()=>({minPicks:5,maxPicks:36}),Ze=e=>e.length===new Set(e).size,Qe=e=>{let t=(0,l.default)(1),n=(0,l.default)(52);for(let r=0;r<e;r+=1)t=t.mul((0,l.default)(52-r).div(n));return t};var $e=class extends v{constructor(){super(`BLITZ`)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){c.Guard.against(t.pickCount<1||t.pickCount>52,`pickCount must be between 1 and 52`),c.Guard.againstNonInteger(t.pickCount,`pickCount must be an integer`);let r=e.getRandomIntsWithReplacement({min:0,max:51,count:52}),i=r.values.slice(0,t.pickCount),a=Ze(i),o=Qe(t.pickCount),s=a?y.withMultiplier((0,l.default)(1).div(o),n):(0,l.default)(0);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:r.values,cards:i.map(e=>new D(e).toDto())},randomValues:r}}};const et=4294967295;let tt=function(e){return e.EASY=`EASY`,e.MEDIUM=`MEDIUM`,e.HARD=`HARD`,e.EXPERT=`EXPERT`,e}({});const nt={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:.5,ringTwo:.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:.5},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},rt={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:.4,ringTwo:.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:.4},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},it={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:.2,ringTwo:.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:.2},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},at={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:.1,ringTwo:.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:.1},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`]},ot=e=>{let t=z[e];return[t.multipliers.bullseye,t.multipliers.ringOne,t.multipliers.ringTwo,...Object.values(t.multipliers.ringThree),t.multipliers.ringFour].reduce((e,t)=>t>e?t:e)},z={EASY:nt,MEDIUM:rt,HARD:it,EXPERT:at};var st=class extends v{constructor(){super(`DARTS`)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t}){let n=e.getRandomIntsWithReplacement({min:0,max:et,count:2}),r=n.values[0],i=n.values[1];c.Guard.againstUndefined(r,`Random number generator returned no value for clockWiseRotation`),c.Guard.againstUndefined(i,`Random number generator returned no value for distanceFromCentre`);let a=t.difficultyLevel,o=(0,l.default)(ct(a,r,i));return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:n.values},randomValues:n}}};const ct=(e,t,n)=>{let r=z[e],{distanceBoundaries:i,multipliers:a}=r;return n<i.bullseye?a.bullseye:n<i.ringOne?a.ringOne:n<i.ringTwo?a.ringTwo:n<i.ringThree?lt(r,t):a.ringFour},lt=(e,t)=>{let n=e.segments.length,r=Math.floor(t/4294967296*n),i=e.segments[r];return c.Guard.againstUndefined(i,`Segment index ${r} out of bounds`),e.multipliers.ringThree[i]};var B=class{multipliers;constructor(e){this.multipliers=e}getMultipliers(e){let t=this.multipliers.get(e);if(t===void 0)throw Error(`Multipliers for ${e} not found`);return t}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([e,t])=>({edge:e,multipliers:t}))}};let ut=function(e){return e.PAIR=`PAIR`,e.TWO_PAIR=`TWO_PAIR`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.FULL_HOUSE=`FULL_HOUSE`,e.FOUR_OF_A_KIND=`FOUR_OF_A_KIND`,e.FIVE_OF_A_KIND=`FIVE_OF_A_KIND`,e}({});const dt=new B(new Map([[1,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50}],[2,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50}],[3,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50}],[4,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50}],[8,{PAIR:.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}]])),ft={2:`PAIR`,3:`THREE_OF_A_KIND`,4:`FOUR_OF_A_KIND`,5:`FIVE_OF_A_KIND`};var pt=class extends v{constructor(){super(`DIAMONDS`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomIntsWithReplacement({min:0,max:6,count:5}),i=dt.getMultipliers(t),a=r.values,o=(0,l.default)(this.calculatePayoutMultiplier(i,a));return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(e,t){let n=new Map;for(let e of t){let t=n.get(e)||0;n.set(e,t+1)}let r=[...n.values()].filter(e=>e>1),i=this.classifyResult(r);return i===null?0:e[i]}classifyResult(e){if(e.length>2)throw Error(`Unexpected number of repeats ${e.length}`);let[t,n]=e;if(t===void 0)return null;if(n===void 0){let e=ft[t];if(e===void 0)throw Error(`Unexpected single diamond repeat count: ${t}`);return e}return t===3||n===3?`FULL_HOUSE`:`TWO_PAIR`}};let mt=function(e){return e.ABOVE=`ABOVE`,e.BELOW=`BELOW`,e}({});const V=1e4,ht=10001,gt=e=>{let t=e.direction===`ABOVE`?V-e.selectedValue:e.selectedValue;return new l.default(t).div(ht).mul(100)},_t=(e,t)=>e.direction===`ABOVE`?t>e.selectedValue:t<e.selectedValue;var vt=class extends v{constructor(){super(`DICE`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:0,max:V}),i=gt(n),a=_t(n,r.value)?y.withWinChance(t,i):new l.default(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(a)}]},payoutMultiplier:a,outputs:{result:r.values},randomValues:r}}};let yt=function(e){return e.CLASSIC=`CLASSIC`,e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const bt=[1,2,3,4,5,6,7,8,9,10],xt=e=>bt.includes(e),St={1:{CLASSIC:[0,3.96],LOW_RISK:[.7,1.85],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1e3],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1e3]}},Ct={1:{CLASSIC:[0,3.92],LOW_RISK:[.7,1.82],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1e3],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1e3]}},wt={1:{CLASSIC:[0,3.88],LOW_RISK:[.7,1.78],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1e3]}},Tt={1:{CLASSIC:[0,3.84],LOW_RISK:[.69,1.77],MEDIUM_RISK:[.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,.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1e3],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1e3]}},Et={1:{CLASSIC:[0,3.68],LOW_RISK:[.7,1.58],MEDIUM_RISK:[.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1e3]}},Dt=new B(new Map([[1,St],[2,Ct],[3,wt],[4,Tt],[8,Et]]));var Ot=class extends v{constructor(){super(`KENO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){c.Guard.againstEmptyArray(n.selectedNumbers,()=>_.createValidationError(`No numbers selected`)),c.Guard.against(n.selectedNumbers.length>10,()=>_.createValidationError(`Maximum of 10 numbers can be selected`));for(let e of n.selectedNumbers)c.Guard.againstNonInteger(e,()=>_.createValidationError(`Only integers can be selected`)),c.Guard.against(e<0||e>39,()=>_.createValidationError(`Invalid number selected`));let r=e.getUniqueRandomInts({min:0,max:39,count:10}),i=n.selectedNumbers.filter(e=>r.values.includes(e)),a=n.selectedNumbers.length;if(!xt(a))throw Error(`Invalid tile count: ${a}`);let o=Dt.getMultipliers(t)[a][n.riskLevel][i.length];if(o===void 0)throw Error(`No multiplier found for matching tile count ${i.length}`);let s=new l.default(o);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:r.values},randomValues:r}}};const kt=(e,t)=>e.gt(t)?e:t,At=(e,t)=>e.lt(t)?e:t;var jt=class extends v{constructor(){super(`LIMBO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:1,max:4294967295}),i=r.max,a=new l.default(16777216),o=new l.default(1),s=new l.default(1e6),c=r.value,u=new l.default(c-1).div(i),d=(100-t)/100,f=a.div(u.mul(a).plus(1)).mul(d),p=kt(o,At(f,s)),m=p.gte(n.targetMultiplier)?new l.default(n.targetMultiplier):new l.default(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(m)}]},payoutMultiplier:m,outputs:{randomMultiplier:p,result:r.values},randomValues:r}}};const H=(e,t)=>{if(t<0||e<0||t>e)throw Error(`Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.`);t>e-t&&(t=e-t);let n=1;for(let r=1;r<=t;r++)n=n*(e-r+1)/r;return n};var Mt=class extends v{constructor(){super(`MINES`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){if(n.minesCount<=0||n.minesCount>24)throw Error(`Must select between 1 and 24 mines.`);if(n.selectedTiles.length>25-n.minesCount)throw Error(`Cannot select more tiles than available safe tiles (total tiles minus mines).`);let r=e.getUniqueRandomInts({min:1,max:25,count:n.minesCount}),i=r.values.some(e=>n.selectedTiles.includes(e)),a=n.hasCashedOut||i,o=(100-t)/100,s=new l.default(H(25-n.minesCount,n.selectedTiles.length)).div(new l.default(H(25,n.selectedTiles.length))),c=n.hasCashedOut&&!i?new l.default(o).div(s):new l.default(0);return{isFinished:a,payout:{legs:[{amount:n.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:r.values},randomValues:r}}};let Nt=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const Pt=[8,9,10,11,12,13,14,15,16],Ft=new B(new Map([[1,{LOW_RISK:{8:[6,2.1,1.1,1,.5,1,1.1,2.1,6],9:[6,2,1.6,1,.7,.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,.7,.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,.9,.7,.7,.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,.7,.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,.7,.4,.7,1.3,3,13],9:[18,4,1.7,.9,.5,.5,.9,1.7,4,18],10:[22,5,2,1.4,.6,.4,.6,1.4,2,5,22],11:[24,6,3,1.8,.7,.5,.5,.7,1.8,3,6,24],12:[33,11,4,2,1.1,.6,.3,.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,.7,.4,.4,.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,.5,.2,.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,.5,.3,.3,.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,.5,.3,.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,.3,.2,.3,1.5,4,29],9:[43,7,2,.6,.2,.2,.6,2,7,43],10:[76,10,3,.9,.3,.2,.3,.9,3,10,76],11:[120,13.9,5.2,1.4,.4,.2,.2,.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,.7,.2,.2,.2,.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,.2,.2,.2,.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,.3,.2,.2,.2,.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,.5,.2,.2,.2,.2,.5,3,8,27,82.8,620],16:[1e3,129.9,26.1,9,4,2,.2,.2,.2,.2,.2,2,4,9,26.1,129.9,1e3]}}],[2,{LOW_RISK:{8:[6,1.9,1.1,1,.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,.7,.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,.7,.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,.9,.7,.7,.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,.7,.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,.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,.6,.4,.6,1.4,3.2,13],9:[18,3.7,1.7,.9,.5,.5,.9,1.7,3.7,18],10:[22,5,1.9,1.4,.6,.4,.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,.7,.5,.5,.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,.6,.3,.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,.7,.4,.4,.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,.5,.2,.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,.5,.3,.3,.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,.5,.3,.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,.3,.2,.3,1.5,3.8,29],9:[43,7.1,1.9,.6,.2,.2,.6,1.9,7.1,43],10:[76,9.9,2.9,.9,.3,.2,.3,.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,.4,.2,.2,.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,.7,.2,.2,.2,.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,.2,.2,.2,.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,.3,.2,.2,.2,.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,.5,.2,.2,.2,.2,.5,3,7.7,26.8,82.3,620],16:[1e3,129.8,25.2,8.6,4,2,.2,.2,.2,.2,.2,2,4,8.6,25.2,129.8,1e3]}}],[3,{LOW_RISK:{8:[6,2.2,1.1,1,.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,.7,.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,.7,.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,.9,.7,.7,.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,.7,.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,.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,.7,.3,.7,1.2,3.5,13],9:[18,3.8,1.6,.9,.5,.5,.9,1.6,3.8,18],10:[22,5.2,2,1.3,.6,.4,.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,.7,.5,.5,.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,.6,.3,.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,.7,.4,.4,.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,.5,.2,.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,.5,.3,.3,.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,.5,.3,.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,.3,.2,.3,1.4,4,29],9:[43,7.3,2,.5,.2,.2,.5,2,7.3,43],10:[76,9.8,2.8,.9,.3,.2,.3,.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,.4,.2,.2,.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,.7,.2,.2,.2,.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,.2,.2,.2,.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,.3,.2,.2,.2,.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,.5,.2,.2,.2,.2,.5,2.9,7.7,26.6,81.9,620],16:[1e3,130,24.9,8.4,3.9,2,.2,.2,.2,.2,.2,2,3.9,8.4,24.9,130,1e3]}}],[4,{LOW_RISK:{8:[6,2,1.1,1,.4,1,1.1,2,6],9:[6,1.9,1.4,1,.7,.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,.7,.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,.9,.6,.6,.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,.6,.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,.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,.7,.4,.7,1.2,2.9,13],9:[18,3.5,1.6,.9,.5,.5,.9,1.6,3.5,18],10:[22,4.7,2,1.3,.6,.4,.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,.7,.5,.5,.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,.6,.3,.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,.7,.4,.4,.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,.5,.2,.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,.5,.3,.3,.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,.5,.3,.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,.3,.2,.3,1.4,3.9,29],9:[43,6.9,1.8,.6,.2,.2,.6,1.8,6.9,43],10:[76,9.8,2.7,.9,.3,.2,.3,.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,.4,.2,.2,.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,.7,.2,.2,.2,.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,.2,.2,.2,.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,.3,.2,.2,.2,.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,.5,.2,.2,.2,.2,.5,2.8,7.8,26.1,80.6,620],16:[1e3,129.7,24.7,8.2,3.8,2,.2,.2,.2,.2,.2,2,3.8,8.2,24.7,129.7,1e3]}}],[8,{LOW_RISK:{8:[5,1.8,1,1,.4,1,1,1.8,5],9:[5,1.7,1.2,1,.7,.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,.7,.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,.9,.6,.6,.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,.6,.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,.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,.7,.4,.7,1.1,2.6,13],9:[17,3.3,1.4,.9,.5,.5,.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,.6,.4,.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,.7,.5,.5,.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,.6,.2,.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,.7,.4,.4,.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,.5,.2,.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,.5,.3,.3,.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,.5,.3,.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,.3,.2,.3,1.4,3.3,28],9:[42,6.7,1.6,.6,.2,.2,.6,1.6,6.7,42],10:[74,9.6,2.6,.9,.3,.1,.3,.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,.4,.2,.2,.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,.7,.2,.2,.2,.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,.2,.2,.2,.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,.3,.2,.2,.2,.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,.5,.2,.2,.2,.2,.5,2.6,7.4,24.9,76.9,600],16:[1e3,122,24.5,8,3.7,1.8,.2,.2,.2,.2,.2,1.8,3.7,8,24.5,122,1e3]}}]]));var It=class extends v{constructor(){super(`PLINKO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){if(t.numberOfRows%1>0)throw Error(`Number of rows must be an integer`);if(t.numberOfRows<8||t.numberOfRows>16)throw Error(`Number of rows must be between 8 and 16`);let r=t.numberOfRows,i=Ft.getMultipliers(n)[t.riskLevel][r],a=e.getRandomIntsWithReplacement({min:0,max:1,count:t.numberOfRows}),o=a.values.reduce((e,t)=>e+t,0),s=i[o];if(s===void 0)throw Error(`No payout found for end position ${o}`);let c=(0,l.Big)(s);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:a.values},randomValues:a}}};const U=[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],Lt=[37,...U],Rt=[[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]],zt=[[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]],Bt=[[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]],Vt=[[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]],Ht=[[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]],Ut=[[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]],Wt=[0,1,2,3,37],Gt=[[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]],Kt=[[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]];let W=function(e){return e.EVEN=`EVEN`,e.ODD=`ODD`,e}({}),G=function(e){return e.RED=`RED`,e.BLACK=`BLACK`,e}({}),K=function(e){return e.LOW=`LOW`,e.HIGH=`HIGH`,e}({}),q=function(e){return e.TOP=`TOP`,e.MIDDLE=`MIDDLE`,e.BOTTOM=`BOTTOM`,e}({}),J=function(e){return e.FIRST=`FIRST`,e.SECOND=`SECOND`,e.THIRD=`THIRD`,e}({}),qt=function(e){return e.AMERICAN=`AMERICAN`,e.EUROPEAN=`EUROPEAN`,e}({});const Y=2.7,X=5.3,Jt=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw _.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Z(e.value)))throw _.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&Yt(e.values)))throw _.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&Xt(e.values)))throw _.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&Zt(e.values)))throw _.createValidationError(`Invalid corner bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&Qt(e.values)))throw _.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw _.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw _.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw _.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw _.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw _.createValidationError(`Invalid dozen bet.`)},Z=e=>U.includes(e),Yt=e=>e.length!==2||!e.every(Z)?!1:Rt.some(([t,n])=>t===e[0]&&n===e[1]),Xt=e=>e.length!==3||!e.every(Z)?!1:Bt.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),Zt=e=>e.length!==4||!e.every(Z)?!1:Ht.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),Qt=e=>e.length!==6||!e.every(Z)?!1:Gt.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),$t=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.basketBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw _.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Q(e.value)))throw _.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&en(e.values)))throw _.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&tn(e.values)))throw _.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&nn(e.values)))throw _.createValidationError(`Invalid corner bet.`);if(!e.basketBets.every(e=>e.amount.gte(0)))throw _.createValidationError(`Invalid basket bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&rn(e.values)))throw _.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw _.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw _.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw _.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw _.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw _.createValidationError(`Invalid dozen bet.`)},Q=e=>Lt.includes(e);function en(e){return e.length!==2||!e.every(Q)?!1:zt.some(([t,n])=>t===e[0]&&n===e[1])}const tn=e=>e.length!==3||!e.every(Q)?!1:Vt.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),nn=e=>e.length!==4||!e.every(Q)?!1:Ut.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),rn=e=>e.length!==6||!e.every(Q)?!1:Kt.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),an=(e,t)=>{let n=t===2.7&&e.type===`EUROPEAN`,r=t===5.3&&e.type===`AMERICAN`;if(!n&&!r)throw _.createValidationError(`Attempted to play ${e.type} roulette on edge ${t}`)},on=(e,t)=>{an(e,t),e.type===`EUROPEAN`?Jt(e.inputs):$t(e.inputs)},sn={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},$=[3,6,9,12,15,18,21,24,27,30,33,36],cn=[2,5,8,11,14,17,20,23,26,29,32,35],ln=[1,4,7,10,13,16,19,22,25,28,31,34],un=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],dn=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];var fn=class extends v{constructor(){super(`ROULETTE`)}determineGameResult({generator:e,gameInputs:t}){this.validateInputs(t);let n=e.getRandomInt({min:0,max:this.maxNumber}),r=n.value,i=this.determineBetOutcomes(t,r),{payoutMultiplier:a,payout:o}=this.getPayoutDetails(t,r);return{outputs:{betOutcomes:i,result:n.values},payout:o,payoutMultiplier:a,isFinished:!0,randomValues:n}}getBetAmount(e){return this.calculateTotalBetAmount(this.getBetTotals(e))}getPayoutDetails(e,t){let n=this.getBetTotals(e),r=this.calculateTotalBetAmount(n),i={legs:this.calculatePayoutLegs(e,t)},a=O(i);return{payoutMultiplier:r.gt(0)?a.div(r):new l.Big(0),payout:i}}determineBetOutcomes(e,t){let n={},r={};for(let i of Object.keys(e)){let a=e[i],o=this.betPredicates[i],{winning:s,losing:c}=this.partitionBets(a,o,t);n[i]=s,r[i]=c}return{winningBets:n,losingBets:r}}calculateTotalAmount(e){return e.reduce((e,t)=>e.plus(t.amount),new l.Big(0))}isWinningStraightBet(e,t){return e.value===t}isWinningSplitBet(e,t){return e.values.some(e=>e===t)}isWinningStreetBet(e,t){return e.values.some(e=>e===t)}isWinningCornerBet(e,t){return e.values.some(e=>e===t)}isWinningDoubleStreetBet(e,t){return e.values.some(e=>e===t)}isWinningColorBet(e,t){let n=e;return un.includes(t)&&n.color===`RED`||dn.includes(t)&&n.color===`BLACK`}isWinningHalfBet(e,t){let n=e;return t>0&&t<=18&&n.half===`LOW`||t>18&&t<=36&&n.half===`HIGH`}isWinningColumnBet(e,t){let n=e;return $.includes(t)&&n.column===`TOP`||cn.includes(t)&&n.column===`MIDDLE`||ln.includes(t)&&n.column===`BOTTOM`}isWinningDozenBet(e,t){let n=e;return t>0&&t<=12&&n.dozen===`FIRST`||t>12&&t<=24&&n.dozen===`SECOND`||t>24&&t<=36&&n.dozen===`THIRD`}isWinningParityBet(e,t){let n=e;if(t===0||t===37)return!1;let r=t%2==0?`EVEN`:`ODD`;return n.parity===r}getBetTotals(e){let t={};for(let n of Object.keys(e))t[n]=this.calculateTotalAmount(e[n]);return t}calculateTotalBetAmount(e){return Object.values(e).reduce((e,t)=>e.plus(t),new l.Big(0))}partitionBets(e,t,n){return{winning:e.filter(e=>t(e,n)),losing:e.filter(e=>!t(e,n))}}calculatePayoutLegs(e,t){return Object.keys(e).flatMap(n=>{let r=sn[n],i=this.betPredicates[n];return e[n].map(e=>i(e,t)?{amount:e.amount.mul(r||0)}:{amount:new l.Big(`0`)})})}},pn=class extends fn{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[Y]}validateInputs(e){Jt(e)}},mn=class extends fn{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(e){$t(e)}isWinningBasketBet(e,t){return Wt.some(e=>e===t)}},hn=class extends v{europeanGame;americanGame;constructor(){super(`ROULETTE`),this.europeanGame=new pn,this.americanGame=new mn}get supportedEdgeConfigurations(){return[Y,X]}getBetAmount(e){switch(e.type){case`AMERICAN`:return this.americanGame.getBetAmount(e.inputs);case`EUROPEAN`:return this.europeanGame.getBetAmount(e.inputs);default:throw Error(`Unhandled roulette type`)}}determineGameResult(e){let{gameInputs:t,...n}=e;if(on(t,e.edge),t.type===`EUROPEAN`){let e=this.europeanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:r}=e.outputs;return{...e,outputs:{type:`european`,betOutcomes:r,result:e.outputs.result}}}let r=this.americanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:i}=r.outputs;return{...r,outputs:{type:`american`,betOutcomes:i,result:r.outputs.result}}}};const gn=e=>new hn().getBetAmount(e);let _n=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({}),vn=function(e){return 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`,e}({});const yn=new B(new Map([[1,{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}}}],[2,{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}}}],[3,{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}}}],[4,{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}}}],[8,{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}}}]])),bn={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`.split(`.`),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`.split(`.`),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`.split(`.`)},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`.split(`.`),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`.split(`.`),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`.split(`.`)},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`]}};var xn=class extends v{constructor(){super(`WHEEL`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){if(!Object.values(vn).includes(t.segments))throw Error(`Invalid segments value`);if(!Object.values(_n).includes(t.riskLevel))throw Error(`Invalid risk level`);let r=yn.getMultipliers(n)[t.riskLevel];if(r===void 0)throw Error(`No multipliers found for risk level ${t.riskLevel}`);let i=r[t.segments];if(i===void 0)throw Error(`No multipliers found for segment ${t.segments}`);let a=bn[t.riskLevel];if(a===void 0)throw Error(`No patterns found for risk level ${t.riskLevel}`);let o=a[t.segments];if(o===void 0)throw Error(`No patterns found for segment ${t.segments}`);let s=e.getRandomInt({min:0,max:o.length-1}),c=o[s.value];if(c===void 0)throw Error(`No pattern found for segment ${t.segments} and value ${s.value}`);let u=i[c];if(u===void 0)throw Error(`No payout found for picked segment ${c}`);let d=new l.Big(u);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(d)}]},payoutMultiplier:d,outputs:{result:s.values},randomValues:s}}};exports.ACE_SOFT_BONUS=10,exports.AMERICAN_BASKET=Wt,exports.AMERICAN_HOUSE_EDGE=X,exports.AdvancedDice=ce,exports.AmericanRoulette=mn,exports.BASE_PAYOUT_MULTIPLIERS=j,exports.BLACKJACK_MULTIPLIER=Se,exports.BLACKJACK_VALUE=21,exports.BLACK_NUMBERS=dn,exports.BLITZ_CARD_COUNT=52,exports.BLITZ_MAX_CARD_RANGE=51,exports.BLITZ_MIN_CARD_RANGE=0,exports.BLITZ_RANDOM_NUMBER_COUNT=52,exports.BOTTOM_COLUMN=ln,exports.BUST_VALUE=21,exports.Baccarat=ge,exports.BaccaratBetType=pe,exports.BaccaratOutcome=fe,exports.Blackjack=Ye,exports.BlackjackActionType=ye,exports.BlackjackOutcome=_e,exports.Blitz=$e,exports.CARDS_PER_SUIT=13,exports.CARD_RANKS=m,exports.CARD_SUITS=p,exports.CARD_SUIT_COLORS=g,exports.CARD_VALUES=f,exports.Color=G,exports.Column=q,exports.DARTS_BOARD_CONFIGS=z,exports.DARTS_DIFFICULTY_LEVEL=tt,exports.DARTS_MAX_VALUE=et,exports.DARTS_MIN_VALUE=0,exports.DEALER_STAND_VALUE=17,exports.DICE_EFFECTIVE_RANGE=ht,exports.DICE_MAX_ROLL=V,exports.DICE_MIN_ROLL=0,exports.DOUBLE_DOWN_BET_SIZE_FACTOR=1,exports.Darts=st,exports.Diamonds=pt,exports.DiamondsResultType=ut,exports.Dice=vt,exports.DiceDirection=mt,exports.Dozen=J,exports.EFFECTIVE_RANGE=x,exports.EUROPEAN_HOUSE_EDGE=Y,exports.EuropeanRoulette=pn,exports.FACE_CARD_RANKS=h,exports.FACE_CARD_VALUE=10,exports.GameError=_,exports.GameErrorCode=ee,exports.Half=K,exports.INSURANCE_BET_SIZE_FACTOR=A,exports.INSURANCE_WIN_MULTIPLIER=3,exports.InsuranceOutcome=ve,exports.Keno=Ot,exports.KenoRiskLevel=yt,exports.LOSE_MULTIPLIER=0,exports.Limbo=jt,exports.MAX_CARDS_PER_ROUND=63,exports.MAX_CARD_VALUE=51,exports.MAX_WIN_CHANCE=98,exports.MIDDLE_COLUMN=cn,exports.MIN_CARD_VALUE=0,exports.MIN_WIN_CHANCE=.01,exports.Mines=Mt,exports.MultiActionGame=Oe,exports.MultiplierCalculator=y,exports.OrigamiGame=te,exports.PAIR_BONUS_PAYOUTS=M,exports.PAYOUT_MULTIPLIERS=sn,exports.PLINKO_ROW_COUNTS=Pt,exports.PUSH_MULTIPLIER=1,exports.PairBonusType=be,exports.Parity=W,exports.Plinko=It,exports.PlinkoRiskLevel=Nt,exports.RANDOM_MAX_VALUE=b,exports.RANDOM_MIN_VALUE=0,exports.RED_NUMBERS=un,exports.RandomValuePool=De,exports.RollType=oe,exports.Roulette=hn,exports.RouletteType=qt,exports.SPLIT_BET_SIZE_FACTOR=1,exports.SingleActionGame=v,exports.THREE_CARD_BONUS_PAYOUTS=Ce,exports.TILE_COUNTS=bt,exports.TOP_COLUMN=$,exports.ThreeCardBonusType=xe,exports.VALID_AMERICAN_CORNERS=Ut,exports.VALID_AMERICAN_DOUBLE_STREETS=Kt,exports.VALID_AMERICAN_SPLITS=zt,exports.VALID_AMERICAN_STRAIGHTS=Lt,exports.VALID_AMERICAN_STREETS=Vt,exports.VALID_EUROPEAN_CORNERS=Ht,exports.VALID_EUROPEAN_DOUBLE_STREETS=Gt,exports.VALID_EUROPEAN_SPLITS=Rt,exports.VALID_EUROPEAN_STRAIGHTS=U,exports.VALID_EUROPEAN_STREETS=Bt,exports.VALID_RANKS=ue,exports.VALID_SUITS=le,exports.WIN_MULTIPLIER=2,exports.Wheel=xn,exports.WheelRiskLevel=_n,exports.WheelSegments=vn,exports.advancedDiceGetExclusiveBoundsRange=T,exports.advancedDiceGetInclusiveBoundsRange=C,exports.advancedDiceIsWithinBoundsExclusive=w,exports.advancedDiceIsWithinBoundsInclusive=ae,exports.bigMax=kt,exports.bigMin=At,exports.calculateAdvancedDiceWinChance=E,exports.calculateBaccaratBetAmount=k,exports.calculateBlitzWinChance=Qe,exports.calculateDiceWinChance=gt,exports.calculateInsuranceStake=Me,exports.calculateRouletteBetAmount=gn,exports.diamondsMultipliers=dt,exports.getBlitzDefaults=Xe,exports.getMaxMultiplierForDifficulty=ot,exports.hasBlitzWon=Ze,exports.hasDiceWon=_t,exports.isTileCount=xt,exports.kenoMultipliers=Dt,exports.nCr=H,exports.plinkoMultipliers=Ft,exports.rtp92Multipliers=Et,exports.rtp96Multipliers=Tt,exports.rtp97Multipliers=wt,exports.rtp98Multipliers=Ct,exports.rtp99Multipliers=St,exports.sumPayout=O,exports.validateAdvancedDiceInputs=se,exports.validateRouletteGameInputs=on;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("@betorigami/game-engine"),l=require("big.js");l=s(l,1);let u=require("@betorigami/guard"),d=require("@xstate/store");const f=1e4,p=10001,m=e=>{if(e<0)throw c.GameError.createValidationError(`Lower bound ${e} is below minimum allowed value 0`)},h=e=>{if(e>1e4)throw c.GameError.createValidationError(`Upper bound ${e} is above maximum allowed value ${f}`)},g=e=>{if(m(e.lower),h(e.upper),e.lower>=e.upper)throw c.GameError.createValidationError(`Lower bound ${e.lower} must be less than ${e.upper}`)},ee=(e,t)=>{let[n,r]=e.lower<=t.lower?[e,t]:[t,e];if(n.upper>r.lower)throw c.GameError.createValidationError(`Bounds must not overlap`)},te=(e,t)=>t>=e.lower&&t<=e.upper,_=e=>e.upper-e.lower+1,v=(e,t)=>t>e.lower&&t<e.upper,y=e=>e.upper-e.lower-1;let ne=function(e){return e.ROLL_BETWEEN=`ROLL_BETWEEN`,e.ROLL_OUTSIDE=`ROLL_OUTSIDE`,e.ROLL_BETWEEN_TWO=`ROLL_BETWEEN_TWO`,e}({});const b=e=>{let t=(()=>{switch(e.mode){case`ROLL_BETWEEN`:return g(e.bounds),y(e.bounds);case`ROLL_OUTSIDE`:return g(e.bounds),p-_(e.bounds);case`ROLL_BETWEEN_TWO`:return g(e.firstBounds),g(e.secondBounds),ee(e.firstBounds,e.secondBounds),y(e.firstBounds)+y(e.secondBounds)}})(),n=(0,l.Big)(t).div(p).mul(100);if(n.lt(.01))throw c.GameError.createValidationError(`Win chance too low`);if(n.gt(98))throw c.GameError.createValidationError(`Win chance too high`);return n},re=e=>{b(e)};var ie=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.ADVANCED_DICE)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=b(n),i=e.getRandomInt({min:0,max:f}),a=i.value,o=(()=>{switch(n.mode){case`ROLL_BETWEEN`:return v(n.bounds,a);case`ROLL_OUTSIDE`:return!te(n.bounds,a);case`ROLL_BETWEEN_TWO`:return v(n.firstBounds,a)||v(n.secondBounds,a)}})()?c.MultiplierCalculator.withWinChance(t,r):new l.Big(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:i.values},randomValues:i}}};const ae=[`Clubs`,`Diamonds`,`Hearts`,`Spades`],oe=[`Ace`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`Jack`,`Queen`,`King`],se={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`};let ce=function(e){return e.PLAYER_WIN=`PLAYER_WIN`,e.TIE=`TIE`,e.BANKER_WIN=`BANKER_WIN`,e}({}),le=function(e){return e.PLAYER=`PLAYER`,e.TIE=`TIE`,e.BANKER=`BANKER`,e}({});const ue={PLAYER_WIN:{betType:`PLAYER`,multiplier:2},TIE:{betType:`TIE`,multiplier:9},BANKER_WIN:{betType:`BANKER`,multiplier:1.95}},x=e=>new l.default(0).add(e.bets.reduce((e,t)=>e.add(t.amount),new l.default(0))),de=(e,t)=>e===`TIE`&&(t===`PLAYER`||t===`BANKER`);var fe=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.BACCARAT)}get supportedEdgeConfigurations(){return[1]}getBetAmount(e){return x(e)}determineGameResult({generator:e,gameInputs:t}){this.validateGameInputs(t);let n=e.getRandomIntsWithReplacement({min:0,max:51,count:6}),r=n.values,i=r.slice(0,3),a=r.slice(3,6),o=[],s=0;for(let e of i.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);o.push(t),s=(s+n)%10}let u=[],d=0;for(let e of a.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);u.push(t),d=(d+n)%10}if(!this.isNaturalWin(s,d)){let e=this.shouldDrawThirdPlayerCard(s),t=null;e&&(t=this.mapRandomValueToCardValue(i[2]),o.push(this.mapRandomValueToCard(i[2])),s=(s+t)%10),this.shouldDrawThirdBankerCard(d,t)&&(u.push(this.mapRandomValueToCard(a[2])),d=(d+this.mapRandomValueToCardValue(a[2]))%10)}let f;f=s===d?`TIE`:s>d?`PLAYER_WIN`:`BANKER_WIN`;let p=x(t),{betType:m,multiplier:h}=ue[f],g={legs:t.bets.map(e=>e.type===m?{amount:e.amount.mul(h)}:{amount:de(f,e.type)?e.amount:new l.default(`0`)})},ee=(0,c.sumPayout)(g);return{isFinished:!0,payout:g,payoutMultiplier:p.gt(0)?ee.div(p):new l.default(0),outputs:{playerCards:o,playerHandValue:s,bankerCards:u,bankerHandValue:d,gameOutcome:f,result:n.values},randomValues:n}}validateGameInputs(e){if(e.bets.length===0)throw Error(`Must place at least a single bet.`);if(!e.bets.every(e=>e.amount.gte(0)))throw Error(`Invalid bet.`)}mapRandomValueToCard(e){let t=new c.Card(e);return{suit:t.suit,rank:se[t.rank]}}isNaturalWin(e,t){let n=[8,9];return n.includes(e)||n.includes(t)}mapRandomValueToCardValue(e){let t=e%13;return t===0?1:t>=10?10:t+1}shouldDrawThirdPlayerCard(e){return e<=5}shouldDrawThirdBankerCard(e,t){return t===null?e<=5:e<=2?!0:e===3?t!==8:e===4?[2,3,4,5,6,7].includes(t):e===5?[4,5,6,7].includes(t):e===6&&[6,7].includes(t)}};let pe=function(e){return e.WIN=`WIN`,e.LOSE=`LOSE`,e.PUSH=`PUSH`,e.PLAYER_BLACKJACK=`PLAYER_BLACKJACK`,e}({}),me=function(e){return e.WON=`WON`,e.LOST=`LOST`,e}({}),he=function(e){return e.START=`START`,e.HIT=`BLACKJACK_HIT`,e.STAND=`BLACKJACK_STAND`,e.BUY_INSURANCE=`BLACKJACK_BUY_INSURANCE`,e.REJECT_INSURANCE=`BLACKJACK_REJECT_INSURANCE`,e.DOUBLE_DOWN=`BLACKJACK_DOUBLE_DOWN`,e.SPLIT=`BLACKJACK_SPLIT`,e}({}),ge=function(e){return e.EXACT_PAIR=`EXACT_PAIR`,e.COLORED_PAIR=`COLORED_PAIR`,e.MIXED_PAIR=`MIXED_PAIR`,e.LOSS=`LOSS`,e}({}),_e=function(e){return e.SUITED_TRIPS=`SUITED_TRIPS`,e.STRAIGHT_FLUSH=`STRAIGHT_FLUSH`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.STRAIGHT=`STRAIGHT`,e.FLUSH=`FLUSH`,e.LOSS=`LOSS`,e}({});const ve=2.5,ye=.5,S={PLAYER_BLACKJACK:ve,WIN:2,PUSH:1,LOSE:0},C={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},w={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var T=class e extends c.Card{get numericRank(){return c.FACE_CARD_RANKS.includes(this.rank)?10:c.CARD_RANKS.indexOf(this.rank)+1}static fromValue(t){return u.Guard.against(!c.CARD_VALUES.includes(t),`Invalid card value: ${t}`),new e(t)}},E=class{cards;hardHandValue;softHandValue=null;constructor(e){this.cards=e,this.hardHandValue=e.reduce((e,t)=>e+t.numericRank,0),e.some(e=>e.rank===`Ace`)&&this.hardHandValue+10<=21&&(this.softHandValue=this.hardHandValue+10)}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>21}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===21}get highestHandValue(){return this.softHandValue===null?this.hardHandValue:this.softHandValue}},D=class{cards;value;constructor(e){this.cards=e.map(e=>T.fromValue(e)),this.value=new E(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(e=>e.value)}toDto(){return{cards:this.cards.map(e=>e.toDto()),value:this.highestHandValue}}},be=class e extends D{otherCards;upCard;holeCard;constructor(e,t,n=[]){super([e,t,...n]),this.otherCards=n,this.upCard=T.fromValue(e),this.holeCard=T.fromValue(t)}static withInitialDeal(t){return new e(t.upCard,t.holeCard)}addDrawnCards(t){return new e(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(e=!1){return e?super.toDto():{cards:[this.upCard.toDto()],value:new E([this.upCard]).highestHandValue}}},O=class e extends D{static withInitialDeal(t){return new e(t)}addDrawnCards(t){return new e([...this.rawValues,...t])}};const k=e=>[e.pairBonus===null?null:{amount:(0,l.default)(e.pairBonus.betAmount).mul(e.pairBonus.payoutMultiplier)},e.threeCardBonus===null?null:{amount:(0,l.default)(e.threeCardBonus.betAmount).mul(e.threeCardBonus.payoutMultiplier)}].filter(e=>e!==null),xe=e=>{let t=e.betAmounts.mainBetAmount,n=e.actionType===`BLACKJACK_DOUBLE_DOWN`?t.mul(1):(0,l.default)(0),r=e.insuranceOutcome===void 0?(0,l.default)(0):e.insuranceStake,i=t.plus(n).mul(S[e.outcome]),a=e.insuranceOutcome===`WON`?r.mul(3):(0,l.default)(0),o=k(e.sideBetResults),s=[{amount:i},...e.insuranceOutcome===void 0?[]:[{amount:a}],...o],d=(0,c.sumPayout)({legs:s}),f=t.plus(r).plus(n).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);u.Guard.against(f.eq(0),`Total bet amount cannot be zero`);let p=d.div(f);u.Guard.against(e.actionType===`BLACKJACK_SPLIT`,`SPLIT action type is not valid for standard multiplier calculation`);let m;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:m=n;break;case`BLACKJACK_BUY_INSURANCE`:m=e.insuranceStake;break;case`BLACKJACK_SPLIT`:m=t.mul(1)}return{payouts:s,totalBetAmount:f,multiplier:p,additionalBetAmount:m}},Se=e=>{let t=e.betAmounts.mainBetAmount,n=e.mainHandDoubledDown?t.mul(1):(0,l.default)(0),r=e.splitHandDoubledDown?t.mul(1):(0,l.default)(0),i=e.insuranceOutcome===void 0?(0,l.default)(0):e.insuranceStake,a=t.plus(n).mul(S[e.mainOutcome]),o=t.plus(r).mul(S[e.splitOutcome]),s=e.insuranceOutcome===`WON`?i.mul(3):(0,l.default)(0),d=k(e.sideBetResults),f=[{amount:a},{amount:o},...e.insuranceOutcome===void 0?[]:[{amount:s}],...d],p=(0,c.sumPayout)({legs:f}),m=t.plus(t).plus(i).plus(n).plus(r).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);u.Guard.against(m.eq(0),`Total bet amount cannot be zero`);let h=p.div(m),g;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:g=t.mul(1);break;case`BLACKJACK_SPLIT`:g=t.mul(1)}return{payouts:f,totalBetAmount:m,multiplier:h,additionalBetAmount:g}},A=(e,t)=>t(e.mul(ye)),j=e=>e.every(t=>t===e[0]),M=e=>{let t=[...e].sort((e,t)=>e-t);return t.every((e,n)=>{let r=t[n-1];return n===0||(u.Guard.againstUndefined(r,`Previous value cannot be undefined`),e===r+1)})},N={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},Ce={...N,Ace:14},we=e=>M(e.map(e=>N[e]))||M(e.map(e=>Ce[e])),Te=(e,t)=>{let n=T.fromValue(e),r=T.fromValue(t);return n.rank===r.rank?e===t?`EXACT_PAIR`:c.CARD_SUIT_COLORS[n.suit]===c.CARD_SUIT_COLORS[r.suit]?`COLORED_PAIR`:`MIXED_PAIR`:`LOSS`},Ee=(e,t)=>({betAmount:e,result:t,payoutMultiplier:C[t]}),De=(e,t,n)=>{let r=T.fromValue(e),i=T.fromValue(t),a=T.fromValue(n),o=[r.rank,i.rank,a.rank],s=j([r.suit,i.suit,a.suit]),c=j(o),l=we(o);return j([e,t,n])?`SUITED_TRIPS`:s&&l?`STRAIGHT_FLUSH`:c?`THREE_OF_A_KIND`:l?`STRAIGHT`:s?`FLUSH`:`LOSS`},Oe=(e,t)=>({betAmount:e,result:t,payoutMultiplier:w[t]}),ke={state:{isFinished:!1,phase:`uninitialised`,multiplier:(0,l.default)(0)},config:{},playerArgument:{type:`START`,mainBetAmount:`0`,pairBonusAmount:`0`,threeCardBonusAmount:`0`}},P=e=>T.fromValue(e).value;function Ae(e){u.Guard.against(e.phase!==`in-progress`,`Expected a started, in-progress game state`)}function F(e){u.Guard.against(e.phase!==`awaiting-insurance`,`Expected game to be awaiting insurance decision`)}function I(e){u.Guard.against(e.phase!==`in-progress`&&e.phase!==`playing-main-hand`&&e.phase!==`playing-split-hand`,`Expected a started, in-progress game state`)}const L=(e,t)=>{let n=t;for(;n.highestHandValue<17;)n=n.addDrawnCards([P(e.takeOne())]);return n},R=(e,t)=>{if(e.isBusted)return`LOSE`;if(t.isBusted)return`WIN`;let n=e.highestHandValue,r=t.highestHandValue;return n>r?`WIN`:n<r?`LOSE`:`PUSH`},z=e=>e.insuranceOutcome===void 0?(0,l.default)(0):e.calculateStake(e.betAmounts.mainBetAmount),B=e=>{let{payouts:t,multiplier:n,additionalBetAmount:r}=xe({outcome:e.outcome,insuranceOutcome:e.insuranceOutcome,insuranceStake:z(e),actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`finished`,playerHand:e.playerHand,dealerHand:e.dealerHand,outcome:e.outcome,payout:{legs:t},multiplier:n,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:r}},je=e=>{let t=L(e.randomValuePool,e.dealerHand),n=R(e.playerHand,t);return B({...e,dealerHand:t,outcome:n})},Me=e=>{let t=e.mainHand.isBusted&&e.splitHand.isBusted?e.dealerHand:L(e.randomValuePool,e.dealerHand),n=R(e.mainHand,t),r=R(e.splitHand,t),{payouts:i,multiplier:a,additionalBetAmount:o}=Se({hasSplit:!0,mainOutcome:n,splitOutcome:r,insuranceOutcome:e.insuranceOutcome,insuranceStake:z(e),mainHandDoubledDown:e.mainHandDoubledDown,splitHandDoubledDown:e.splitHandDoubledDown,actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`split-finished`,mainHand:e.mainHand,splitHand:e.splitHand,dealerHand:t,mainOutcome:n,splitOutcome:r,payout:{legs:i},multiplier:a,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:o}};var Ne=class extends c.MultiActionGame{roundInsuranceStake;constructor(e,t){super(c.OrigamiGame.BLACKJACK,e),this.roundInsuranceStake=t}get supportedEdgeConfigurations(){return[1]}generateRandomValues(e){return c.RandomValuePool.from(e.getRandomIntsWithReplacement({min:c.MIN_CARD_VALUE,max:c.MAX_CARD_VALUE,count:63}),63)}toExternalState(e){let t=e.phase;switch(t){case`awaiting-insurance`:return{isFinished:!1,phase:`awaiting-insurance`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`in-progress`:return{isFinished:!1,phase:`player-turn`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-main-hand`:return{isFinished:!1,phase:`playing-main-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-split-hand`:return{isFinished:!1,phase:`playing-split-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,outcome:e.outcome,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`split-finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,mainOutcome:e.mainOutcome,splitOutcome:e.splitOutcome,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`uninitialised`:throw Error(`Cannot convert uninitialised state to external state`);default:u.Guard.againstNever(t,`Invalid state received`)}}createGameStore(){let e=e=>{let t=A(e,this.roundInsuranceStake);return u.Guard.against(e.gt(0)&&t.eq(0),`Insurance stake rounds below the smallest unit this currency supports`),t},t=t=>B({...t,calculateStake:e}),n=t=>je({...t,calculateStake:e}),r=t=>Me({...t,calculateStake:e});return(0,d.createStore)({context:ke,on:{START:(e,n)=>{let{state:r}=e;u.Guard.against(r.phase!==`uninitialised`,`START action requires a fresh game`);let i=P(n.randomValuePool.takeOne()),a=P(n.randomValuePool.takeOne()),o=P(n.randomValuePool.takeOne()),s=P(n.randomValuePool.takeOne()),c=O.withInitialDeal([i,a]),d=be.withInitialDeal({upCard:o,holeCard:s}),f={mainBetAmount:(0,l.default)(n.mainBetAmount),pairBonusAmount:(0,l.default)(n.pairBonusAmount),threeCardBonusAmount:(0,l.default)(n.threeCardBonusAmount)},p={pairBonus:(0,l.default)(n.pairBonusAmount).gt(0)?Ee(n.pairBonusAmount,Te(i,a)):null,threeCardBonus:(0,l.default)(n.threeCardBonusAmount).gt(0)?Oe(n.threeCardBonusAmount,De(i,a,o)):null},m={type:`START`,mainBetAmount:n.mainBetAmount,pairBonusAmount:n.pairBonusAmount,threeCardBonusAmount:n.threeCardBonusAmount};if(d.upCard.rank===`Ace`)return{state:{...r,isFinished:!1,phase:`awaiting-insurance`,playerHand:c,dealerHand:d,betAmounts:f,sideBetResults:p},config:{},playerArgument:m};let h={playerHand:c,dealerHand:d,randomValuePool:n.randomValuePool,playerArgument:m,betAmounts:f,sideBetResults:p};return c.isBlackjack&&d.isBlackjack?t({...h,outcome:`PUSH`}):c.isBlackjack?t({...h,outcome:`PLAYER_BLACKJACK`}):d.isBlackjack?t({...h,outcome:`LOSE`}):{state:{...r,isFinished:!1,phase:`in-progress`,playerHand:c,dealerHand:d,insuranceOutcome:void 0,betAmounts:f,sideBetResults:p},config:{},playerArgument:m}},BLACKJACK_BUY_INSURANCE:(n,r)=>{let{state:i}=n;F(i);let{playerHand:a,dealerHand:o,betAmounts:s,sideBetResults:c}=i,l={...i,randomValuePool:r.randomValuePool,playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},betAmounts:s,sideBetResults:c};return a.isBlackjack&&o.isBlackjack?t({...l,outcome:`PUSH`,insuranceOutcome:`WON`}):a.isBlackjack?t({...l,outcome:`PLAYER_BLACKJACK`,insuranceOutcome:`LOST`}):o.isBlackjack?t({...l,outcome:`LOSE`,insuranceOutcome:`WON`}):{state:{...i,phase:`in-progress`,insuranceOutcome:`LOST`},config:{},playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},additionalBetAmount:e(s.mainBetAmount)}},BLACKJACK_REJECT_INSURANCE:(e,n)=>{let{state:r}=e;F(r);let{playerHand:i,dealerHand:a,betAmounts:o,sideBetResults:s}=r,c={playerHand:i,dealerHand:a,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`},betAmounts:o,sideBetResults:s};return i.isBlackjack&&a.isBlackjack?t({...c,outcome:`PUSH`}):i.isBlackjack?t({...c,outcome:`PLAYER_BLACKJACK`}):a.isBlackjack?t({...c,outcome:`LOSE`}):{state:{...r,phase:`in-progress`,insuranceOutcome:void 0},config:{},playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`}}},BLACKJACK_HIT:(e,i)=>{let{state:a}=e;switch(I(a),a.phase){case`playing-main-hand`:{let e=a.mainHand.addDrawnCards([P(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?a.splitHand.highestHandValue===21?r({...a,mainHand:e,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_HIT`}}:{state:{...a,mainHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`playing-split-hand`:{let e=a.splitHand.addDrawnCards([P(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,splitHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`in-progress`:{let e=a.playerHand.addDrawnCards([P(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):e.highestHandValue===21?n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`in-progress`,playerHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}default:u.Guard.againstNever(a,`Invalid phase for HIT action`)}},BLACKJACK_STAND:(e,t)=>{let{state:i}=e;switch(I(i),i.phase){case`playing-main-hand`:return i.splitHand.highestHandValue===21?r({...i,splitHandDoubledDown:!1,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}}):{state:{...i,phase:`playing-split-hand`,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_STAND`}};case`playing-split-hand`:return r({...i,splitHandDoubledDown:i.splitHandDoubledDown,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});case`in-progress`:return n({...i,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});default:u.Guard.againstNever(i,`Invalid phase for STAND action`)}},BLACKJACK_DOUBLE_DOWN:(e,i)=>{let{state:a}=e;switch(I(a),a.phase){case`playing-main-hand`:{u.Guard.against(a.mainHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.mainHand.addDrawnCards([P(i.randomValuePool.takeOne())]),{betAmounts:t}=a;return a.splitHand.highestHandValue===21?r({...a,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},additionalBetAmount:t.mainBetAmount.mul(1)}}case`playing-split-hand`:{u.Guard.against(a.splitHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.splitHand.addDrawnCards([P(i.randomValuePool.takeOne())]);return r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},splitHandDoubledDown:!0})}case`in-progress`:{u.Guard.against(a.playerHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.playerHand.addDrawnCards([P(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}})}default:u.Guard.againstNever(a,`Invalid phase for DOUBLE_DOWN action`)}},BLACKJACK_SPLIT:(e,t)=>{let{state:n}=e;Ae(n);let{playerHand:i,betAmounts:a,sideBetResults:o}=n;u.Guard.against(i.cards.length!==2,`Split is only allowed with exactly 2 cards`);let s=i.cards[0],c=i.cards[1];u.Guard.againstUndefined(s,`First card is missing`),u.Guard.againstUndefined(c,`Second card is missing`),u.Guard.against(s.rank!==c.rank,`Split requires two cards of the same rank`);let d=P(t.randomValuePool.takeOne()),f=P(t.randomValuePool.takeOne()),p=O.withInitialDeal([s.value,d]),m=O.withInitialDeal([c.value,f]);if(s.rank===`Ace`)return r({...n,mainHand:p,splitHand:m,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let h=p.highestHandValue===21,g=m.highestHandValue===21;return h&&g?r({mainHand:p,splitHand:m,dealerHand:n.dealerHand,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},insuranceOutcome:n.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:a,sideBetResults:o}):h?{state:{...n,phase:`playing-split-hand`,mainHand:p,splitHand:m,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}:{state:{...n,phase:`playing-main-hand`,multiplier:(0,l.default)(0),mainHand:p,splitHand:m,mainHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}}}})}getValidNextActionTypes(e){if(e.isFinished)return[];switch(e.phase){case`awaiting-insurance`:return[`BLACKJACK_BUY_INSURANCE`,`BLACKJACK_REJECT_INSURANCE`];case`playing-main-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.mainHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`playing-split-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.splitHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`player-turn`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];if(e.playerHand.cards.length===2){t.push(`BLACKJACK_DOUBLE_DOWN`);let n=e.playerHand.cards[0],r=e.playerHand.cards[1];u.Guard.againstUndefined(n,`First player card is missing`),u.Guard.againstUndefined(r,`Second player card is missing`),n.rank===r.rank&&t.push(`BLACKJACK_SPLIT`)}return t}default:u.Guard.againstNever(e,`Invalid phase for getting valid actions`)}}};const Pe=()=>({minPicks:5,maxPicks:36}),Fe=e=>e.length===new Set(e).size,Ie=e=>{let t=(0,l.default)(1),n=(0,l.default)(52);for(let r=0;r<e;r+=1)t=t.mul((0,l.default)(52-r).div(n));return t};var Le=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.BLITZ)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){u.Guard.against(t.pickCount<1||t.pickCount>52,`pickCount must be between 1 and 52`),u.Guard.againstNonInteger(t.pickCount,`pickCount must be an integer`);let r=e.getRandomIntsWithReplacement({min:0,max:51,count:52}),i=r.values.slice(0,t.pickCount),a=Fe(i),o=Ie(t.pickCount),s=a?c.MultiplierCalculator.withMultiplier((0,l.default)(1).div(o),n):(0,l.default)(0);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:r.values,cards:i.map(e=>new c.Card(e).toDto())},randomValues:r}}};const Re=4294967295;let ze=function(e){return e.EASY=`EASY`,e.MEDIUM=`MEDIUM`,e.HARD=`HARD`,e.EXPERT=`EXPERT`,e}({});const Be={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:.5,ringTwo:.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:.5},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},Ve={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:.4,ringTwo:.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:.4},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},He={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:.2,ringTwo:.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:.2},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},Ue={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:.1,ringTwo:.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:.1},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`]},We=e=>{let t=V[e];return[t.multipliers.bullseye,t.multipliers.ringOne,t.multipliers.ringTwo,...Object.values(t.multipliers.ringThree),t.multipliers.ringFour].reduce((e,t)=>t>e?t:e)},V={EASY:Be,MEDIUM:Ve,HARD:He,EXPERT:Ue};var Ge=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.DARTS)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t}){let n=e.getRandomIntsWithReplacement({min:0,max:Re,count:2}),r=n.values[0],i=n.values[1];u.Guard.againstUndefined(r,`Random number generator returned no value for clockWiseRotation`),u.Guard.againstUndefined(i,`Random number generator returned no value for distanceFromCentre`);let a=t.difficultyLevel,o=(0,l.default)(Ke(a,r,i));return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:n.values},randomValues:n}}};const Ke=(e,t,n)=>{let r=V[e],{distanceBoundaries:i,multipliers:a}=r;return n<i.bullseye?a.bullseye:n<i.ringOne?a.ringOne:n<i.ringTwo?a.ringTwo:n<i.ringThree?qe(r,t):a.ringFour},qe=(e,t)=>{let n=e.segments.length,r=Math.floor(t/4294967296*n),i=e.segments[r];return u.Guard.againstUndefined(i,`Segment index ${r} out of bounds`),e.multipliers.ringThree[i]};let Je=function(e){return e.PAIR=`PAIR`,e.TWO_PAIR=`TWO_PAIR`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.FULL_HOUSE=`FULL_HOUSE`,e.FOUR_OF_A_KIND=`FOUR_OF_A_KIND`,e.FIVE_OF_A_KIND=`FIVE_OF_A_KIND`,e}({});const Ye=new c.MultiplierContainer(new Map([[1,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50}],[2,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50}],[3,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50}],[4,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50}],[8,{PAIR:.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}]])),Xe={2:`PAIR`,3:`THREE_OF_A_KIND`,4:`FOUR_OF_A_KIND`,5:`FIVE_OF_A_KIND`};var Ze=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.DIAMONDS)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomIntsWithReplacement({min:0,max:6,count:5}),i=Ye.getMultipliers(t),a=r.values,o=(0,l.default)(this.calculatePayoutMultiplier(i,a));return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(e,t){let n=new Map;for(let e of t){let t=n.get(e)||0;n.set(e,t+1)}let r=[...n.values()].filter(e=>e>1),i=this.classifyResult(r);return i===null?0:e[i]}classifyResult(e){if(e.length>2)throw Error(`Unexpected number of repeats ${e.length}`);let[t,n]=e;if(t===void 0)return null;if(n===void 0){let e=Xe[t];if(e===void 0)throw Error(`Unexpected single diamond repeat count: ${t}`);return e}return t===3||n===3?`FULL_HOUSE`:`TWO_PAIR`}};let Qe=function(e){return e.ABOVE=`ABOVE`,e.BELOW=`BELOW`,e}({});const H=1e4,$e=10001,et=e=>{let t=e.direction===`ABOVE`?H-e.selectedValue:e.selectedValue;return new l.default(t).div($e).mul(100)},tt=(e,t)=>e.direction===`ABOVE`?t>e.selectedValue:t<e.selectedValue;var nt=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.DICE)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:0,max:H}),i=et(n),a=tt(n,r.value)?c.MultiplierCalculator.withWinChance(t,i):new l.default(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(a)}]},payoutMultiplier:a,outputs:{result:r.values},randomValues:r}}};let rt=function(e){return e.CLASSIC=`CLASSIC`,e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const it=[1,2,3,4,5,6,7,8,9,10],at=e=>it.includes(e),ot={1:{CLASSIC:[0,3.96],LOW_RISK:[.7,1.85],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1e3],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1e3]}},st={1:{CLASSIC:[0,3.92],LOW_RISK:[.7,1.82],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1e3],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1e3]}},ct={1:{CLASSIC:[0,3.88],LOW_RISK:[.7,1.78],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1e3]}},lt={1:{CLASSIC:[0,3.84],LOW_RISK:[.69,1.77],MEDIUM_RISK:[.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,.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1e3],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1e3]}},ut={1:{CLASSIC:[0,3.68],LOW_RISK:[.7,1.58],MEDIUM_RISK:[.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1e3]}},dt=new c.MultiplierContainer(new Map([[1,ot],[2,st],[3,ct],[4,lt],[8,ut]]));var ft=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.KENO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){u.Guard.againstEmptyArray(n.selectedNumbers,()=>c.GameError.createValidationError(`No numbers selected`)),u.Guard.against(n.selectedNumbers.length>10,()=>c.GameError.createValidationError(`Maximum of 10 numbers can be selected`));for(let e of n.selectedNumbers)u.Guard.againstNonInteger(e,()=>c.GameError.createValidationError(`Only integers can be selected`)),u.Guard.against(e<0||e>39,()=>c.GameError.createValidationError(`Invalid number selected`));let r=e.getUniqueRandomInts({min:0,max:39,count:10}),i=n.selectedNumbers.filter(e=>r.values.includes(e)),a=n.selectedNumbers.length;if(!at(a))throw Error(`Invalid tile count: ${a}`);let o=dt.getMultipliers(t)[a][n.riskLevel][i.length];if(o===void 0)throw Error(`No multiplier found for matching tile count ${i.length}`);let s=new l.default(o);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:r.values},randomValues:r}}},pt=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.LIMBO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:1,max:4294967295}),i=r.max,a=new l.default(16777216),o=new l.default(1),s=new l.default(1e6),u=r.value,d=new l.default(u-1).div(i),f=(100-t)/100,p=a.div(d.mul(a).plus(1)).mul(f),m=(0,c.bigMax)(o,(0,c.bigMin)(p,s)),h=m.gte(n.targetMultiplier)?new l.default(n.targetMultiplier):new l.default(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(h)}]},payoutMultiplier:h,outputs:{randomMultiplier:m,result:r.values},randomValues:r}}},mt=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.MINES)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){if(n.minesCount<=0||n.minesCount>24)throw Error(`Must select between 1 and 24 mines.`);if(n.selectedTiles.length>25-n.minesCount)throw Error(`Cannot select more tiles than available safe tiles (total tiles minus mines).`);let r=e.getUniqueRandomInts({min:1,max:25,count:n.minesCount}),i=r.values.some(e=>n.selectedTiles.includes(e)),a=n.hasCashedOut||i,o=(100-t)/100,s=new l.default((0,c.nCr)(25-n.minesCount,n.selectedTiles.length)).div(new l.default((0,c.nCr)(25,n.selectedTiles.length))),u=n.hasCashedOut&&!i?new l.default(o).div(s):new l.default(0);return{isFinished:a,payout:{legs:[{amount:n.betAmount.mul(u)}]},payoutMultiplier:u,outputs:{result:r.values},randomValues:r}}};let ht=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const gt=[8,9,10,11,12,13,14,15,16],_t=new c.MultiplierContainer(new Map([[1,{LOW_RISK:{8:[6,2.1,1.1,1,.5,1,1.1,2.1,6],9:[6,2,1.6,1,.7,.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,.7,.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,.9,.7,.7,.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,.7,.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,.7,.4,.7,1.3,3,13],9:[18,4,1.7,.9,.5,.5,.9,1.7,4,18],10:[22,5,2,1.4,.6,.4,.6,1.4,2,5,22],11:[24,6,3,1.8,.7,.5,.5,.7,1.8,3,6,24],12:[33,11,4,2,1.1,.6,.3,.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,.7,.4,.4,.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,.5,.2,.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,.5,.3,.3,.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,.5,.3,.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,.3,.2,.3,1.5,4,29],9:[43,7,2,.6,.2,.2,.6,2,7,43],10:[76,10,3,.9,.3,.2,.3,.9,3,10,76],11:[120,13.9,5.2,1.4,.4,.2,.2,.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,.7,.2,.2,.2,.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,.2,.2,.2,.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,.3,.2,.2,.2,.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,.5,.2,.2,.2,.2,.5,3,8,27,82.8,620],16:[1e3,129.9,26.1,9,4,2,.2,.2,.2,.2,.2,2,4,9,26.1,129.9,1e3]}}],[2,{LOW_RISK:{8:[6,1.9,1.1,1,.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,.7,.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,.7,.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,.9,.7,.7,.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,.7,.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,.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,.6,.4,.6,1.4,3.2,13],9:[18,3.7,1.7,.9,.5,.5,.9,1.7,3.7,18],10:[22,5,1.9,1.4,.6,.4,.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,.7,.5,.5,.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,.6,.3,.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,.7,.4,.4,.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,.5,.2,.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,.5,.3,.3,.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,.5,.3,.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,.3,.2,.3,1.5,3.8,29],9:[43,7.1,1.9,.6,.2,.2,.6,1.9,7.1,43],10:[76,9.9,2.9,.9,.3,.2,.3,.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,.4,.2,.2,.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,.7,.2,.2,.2,.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,.2,.2,.2,.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,.3,.2,.2,.2,.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,.5,.2,.2,.2,.2,.5,3,7.7,26.8,82.3,620],16:[1e3,129.8,25.2,8.6,4,2,.2,.2,.2,.2,.2,2,4,8.6,25.2,129.8,1e3]}}],[3,{LOW_RISK:{8:[6,2.2,1.1,1,.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,.7,.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,.7,.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,.9,.7,.7,.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,.7,.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,.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,.7,.3,.7,1.2,3.5,13],9:[18,3.8,1.6,.9,.5,.5,.9,1.6,3.8,18],10:[22,5.2,2,1.3,.6,.4,.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,.7,.5,.5,.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,.6,.3,.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,.7,.4,.4,.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,.5,.2,.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,.5,.3,.3,.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,.5,.3,.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,.3,.2,.3,1.4,4,29],9:[43,7.3,2,.5,.2,.2,.5,2,7.3,43],10:[76,9.8,2.8,.9,.3,.2,.3,.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,.4,.2,.2,.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,.7,.2,.2,.2,.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,.2,.2,.2,.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,.3,.2,.2,.2,.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,.5,.2,.2,.2,.2,.5,2.9,7.7,26.6,81.9,620],16:[1e3,130,24.9,8.4,3.9,2,.2,.2,.2,.2,.2,2,3.9,8.4,24.9,130,1e3]}}],[4,{LOW_RISK:{8:[6,2,1.1,1,.4,1,1.1,2,6],9:[6,1.9,1.4,1,.7,.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,.7,.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,.9,.6,.6,.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,.6,.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,.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,.7,.4,.7,1.2,2.9,13],9:[18,3.5,1.6,.9,.5,.5,.9,1.6,3.5,18],10:[22,4.7,2,1.3,.6,.4,.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,.7,.5,.5,.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,.6,.3,.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,.7,.4,.4,.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,.5,.2,.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,.5,.3,.3,.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,.5,.3,.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,.3,.2,.3,1.4,3.9,29],9:[43,6.9,1.8,.6,.2,.2,.6,1.8,6.9,43],10:[76,9.8,2.7,.9,.3,.2,.3,.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,.4,.2,.2,.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,.7,.2,.2,.2,.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,.2,.2,.2,.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,.3,.2,.2,.2,.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,.5,.2,.2,.2,.2,.5,2.8,7.8,26.1,80.6,620],16:[1e3,129.7,24.7,8.2,3.8,2,.2,.2,.2,.2,.2,2,3.8,8.2,24.7,129.7,1e3]}}],[8,{LOW_RISK:{8:[5,1.8,1,1,.4,1,1,1.8,5],9:[5,1.7,1.2,1,.7,.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,.7,.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,.9,.6,.6,.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,.6,.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,.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,.7,.4,.7,1.1,2.6,13],9:[17,3.3,1.4,.9,.5,.5,.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,.6,.4,.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,.7,.5,.5,.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,.6,.2,.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,.7,.4,.4,.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,.5,.2,.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,.5,.3,.3,.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,.5,.3,.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,.3,.2,.3,1.4,3.3,28],9:[42,6.7,1.6,.6,.2,.2,.6,1.6,6.7,42],10:[74,9.6,2.6,.9,.3,.1,.3,.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,.4,.2,.2,.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,.7,.2,.2,.2,.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,.2,.2,.2,.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,.3,.2,.2,.2,.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,.5,.2,.2,.2,.2,.5,2.6,7.4,24.9,76.9,600],16:[1e3,122,24.5,8,3.7,1.8,.2,.2,.2,.2,.2,1.8,3.7,8,24.5,122,1e3]}}]]));var vt=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.PLINKO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){if(t.numberOfRows%1>0)throw Error(`Number of rows must be an integer`);if(t.numberOfRows<8||t.numberOfRows>16)throw Error(`Number of rows must be between 8 and 16`);let r=t.numberOfRows,i=_t.getMultipliers(n)[t.riskLevel][r],a=e.getRandomIntsWithReplacement({min:0,max:1,count:t.numberOfRows}),o=a.values.reduce((e,t)=>e+t,0),s=i[o];if(s===void 0)throw Error(`No payout found for end position ${o}`);let c=(0,l.Big)(s);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:a.values},randomValues:a}}};const U=[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],yt=[37,...U],bt=[[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]],xt=[[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]],St=[[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]],Ct=[[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]],wt=[[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]],Tt=[[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]],Et=[0,1,2,3,37],Dt=[[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]],Ot=[[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]];let W=function(e){return e.EVEN=`EVEN`,e.ODD=`ODD`,e}({}),G=function(e){return e.RED=`RED`,e.BLACK=`BLACK`,e}({}),K=function(e){return e.LOW=`LOW`,e.HIGH=`HIGH`,e}({}),q=function(e){return e.TOP=`TOP`,e.MIDDLE=`MIDDLE`,e.BOTTOM=`BOTTOM`,e}({}),J=function(e){return e.FIRST=`FIRST`,e.SECOND=`SECOND`,e.THIRD=`THIRD`,e}({}),kt=function(e){return e.AMERICAN=`AMERICAN`,e.EUROPEAN=`EUROPEAN`,e}({});const Y=2.7,X=5.3,At=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw c.GameError.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Z(e.value)))throw c.GameError.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&jt(e.values)))throw c.GameError.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&Mt(e.values)))throw c.GameError.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&Nt(e.values)))throw c.GameError.createValidationError(`Invalid corner bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&Pt(e.values)))throw c.GameError.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw c.GameError.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw c.GameError.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw c.GameError.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw c.GameError.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw c.GameError.createValidationError(`Invalid dozen bet.`)},Z=e=>U.includes(e),jt=e=>e.length!==2||!e.every(Z)?!1:bt.some(([t,n])=>t===e[0]&&n===e[1]),Mt=e=>e.length!==3||!e.every(Z)?!1:St.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),Nt=e=>e.length!==4||!e.every(Z)?!1:wt.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),Pt=e=>e.length!==6||!e.every(Z)?!1:Dt.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),Ft=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.basketBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw c.GameError.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Q(e.value)))throw c.GameError.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&It(e.values)))throw c.GameError.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&Lt(e.values)))throw c.GameError.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&Rt(e.values)))throw c.GameError.createValidationError(`Invalid corner bet.`);if(!e.basketBets.every(e=>e.amount.gte(0)))throw c.GameError.createValidationError(`Invalid basket bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&zt(e.values)))throw c.GameError.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw c.GameError.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw c.GameError.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw c.GameError.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw c.GameError.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw c.GameError.createValidationError(`Invalid dozen bet.`)},Q=e=>yt.includes(e);function It(e){return e.length!==2||!e.every(Q)?!1:xt.some(([t,n])=>t===e[0]&&n===e[1])}const Lt=e=>e.length!==3||!e.every(Q)?!1:Ct.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),Rt=e=>e.length!==4||!e.every(Q)?!1:Tt.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),zt=e=>e.length!==6||!e.every(Q)?!1:Ot.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),Bt=(e,t)=>{let n=t===2.7&&e.type===`EUROPEAN`,r=t===5.3&&e.type===`AMERICAN`;if(!n&&!r)throw c.GameError.createValidationError(`Attempted to play ${e.type} roulette on edge ${t}`)},$=(e,t)=>{Bt(e,t),e.type===`EUROPEAN`?At(e.inputs):Ft(e.inputs)},Vt={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Ht=[3,6,9,12,15,18,21,24,27,30,33,36],Ut=[2,5,8,11,14,17,20,23,26,29,32,35],Wt=[1,4,7,10,13,16,19,22,25,28,31,34],Gt=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],Kt=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];var qt=class extends c.SingleActionGame{constructor(){super(c.OrigamiGame.ROULETTE)}determineGameResult({generator:e,gameInputs:t}){this.validateInputs(t);let n=e.getRandomInt({min:0,max:this.maxNumber}),r=n.value,i=this.determineBetOutcomes(t,r),{payoutMultiplier:a,payout:o}=this.getPayoutDetails(t,r);return{outputs:{betOutcomes:i,result:n.values},payout:o,payoutMultiplier:a,isFinished:!0,randomValues:n}}getBetAmount(e){return this.calculateTotalBetAmount(this.getBetTotals(e))}getPayoutDetails(e,t){let n=this.getBetTotals(e),r=this.calculateTotalBetAmount(n),i={legs:this.calculatePayoutLegs(e,t)},a=(0,c.sumPayout)(i);return{payoutMultiplier:r.gt(0)?a.div(r):new l.Big(0),payout:i}}determineBetOutcomes(e,t){let n={},r={};for(let i of Object.keys(e)){let a=e[i],o=this.betPredicates[i],{winning:s,losing:c}=this.partitionBets(a,o,t);n[i]=s,r[i]=c}return{winningBets:n,losingBets:r}}calculateTotalAmount(e){return e.reduce((e,t)=>e.plus(t.amount),new l.Big(0))}isWinningStraightBet(e,t){return e.value===t}isWinningSplitBet(e,t){return e.values.some(e=>e===t)}isWinningStreetBet(e,t){return e.values.some(e=>e===t)}isWinningCornerBet(e,t){return e.values.some(e=>e===t)}isWinningDoubleStreetBet(e,t){return e.values.some(e=>e===t)}isWinningColorBet(e,t){let n=e;return Gt.includes(t)&&n.color===`RED`||Kt.includes(t)&&n.color===`BLACK`}isWinningHalfBet(e,t){let n=e;return t>0&&t<=18&&n.half===`LOW`||t>18&&t<=36&&n.half===`HIGH`}isWinningColumnBet(e,t){let n=e;return Ht.includes(t)&&n.column===`TOP`||Ut.includes(t)&&n.column===`MIDDLE`||Wt.includes(t)&&n.column===`BOTTOM`}isWinningDozenBet(e,t){let n=e;return t>0&&t<=12&&n.dozen===`FIRST`||t>12&&t<=24&&n.dozen===`SECOND`||t>24&&t<=36&&n.dozen===`THIRD`}isWinningParityBet(e,t){let n=e;if(t===0||t===37)return!1;let r=t%2==0?`EVEN`:`ODD`;return n.parity===r}getBetTotals(e){let t={};for(let n of Object.keys(e))t[n]=this.calculateTotalAmount(e[n]);return t}calculateTotalBetAmount(e){return Object.values(e).reduce((e,t)=>e.plus(t),new l.Big(0))}partitionBets(e,t,n){return{winning:e.filter(e=>t(e,n)),losing:e.filter(e=>!t(e,n))}}calculatePayoutLegs(e,t){return Object.keys(e).flatMap(n=>{let r=Vt[n],i=this.betPredicates[n];return e[n].map(e=>i(e,t)?{amount:e.amount.mul(r||0)}:{amount:new l.Big(`0`)})})}},Jt=class extends qt{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[Y]}validateInputs(e){At(e)}},Yt=class extends qt{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(e){Ft(e)}isWinningBasketBet(e,t){return Et.some(e=>e===t)}},Xt=class extends c.SingleActionGame{europeanGame;americanGame;constructor(){super(c.OrigamiGame.ROULETTE),this.europeanGame=new Jt,this.americanGame=new Yt}get supportedEdgeConfigurations(){return[Y,X]}getBetAmount(e){switch(e.type){case`AMERICAN`:return this.americanGame.getBetAmount(e.inputs);case`EUROPEAN`:return this.europeanGame.getBetAmount(e.inputs);default:throw Error(`Unhandled roulette type`)}}determineGameResult(e){let{gameInputs:t,...n}=e;if($(t,e.edge),t.type===`EUROPEAN`){let e=this.europeanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:r}=e.outputs;return{...e,outputs:{type:`european`,betOutcomes:r,result:e.outputs.result}}}let r=this.americanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:i}=r.outputs;return{...r,outputs:{type:`american`,betOutcomes:i,result:r.outputs.result}}}};const Zt=e=>new Xt().getBetAmount(e);exports.ACE_SOFT_BONUS=10,exports.AMERICAN_BASKET=Et,exports.AMERICAN_HOUSE_EDGE=X,exports.AdvancedDice=ie,exports.AmericanRoulette=Yt,exports.BASE_PAYOUT_MULTIPLIERS=S,exports.BLACKJACK_MULTIPLIER=ve,exports.BLACKJACK_VALUE=21,exports.BLACK_NUMBERS=Kt,exports.BLITZ_CARD_COUNT=52,exports.BLITZ_MAX_CARD_RANGE=51,exports.BLITZ_MIN_CARD_RANGE=0,exports.BLITZ_RANDOM_NUMBER_COUNT=52,exports.BOTTOM_COLUMN=Wt,exports.BUST_VALUE=21,exports.Baccarat=fe,exports.BaccaratBetType=le,exports.BaccaratOutcome=ce,exports.Blackjack=Ne,exports.BlackjackActionType=he,exports.BlackjackOutcome=pe,exports.Blitz=Le,exports.CARDS_PER_SUIT=13,exports.Color=G,exports.Column=q,exports.DARTS_BOARD_CONFIGS=V,exports.DARTS_DIFFICULTY_LEVEL=ze,exports.DARTS_MAX_VALUE=Re,exports.DARTS_MIN_VALUE=0,exports.DEALER_STAND_VALUE=17,exports.DICE_EFFECTIVE_RANGE=$e,exports.DICE_MAX_ROLL=H,exports.DICE_MIN_ROLL=0,exports.DOUBLE_DOWN_BET_SIZE_FACTOR=1,exports.Darts=Ge,exports.Diamonds=Ze,exports.DiamondsResultType=Je,exports.Dice=nt,exports.DiceDirection=Qe,exports.Dozen=J,exports.EFFECTIVE_RANGE=p,exports.EUROPEAN_HOUSE_EDGE=Y,exports.EuropeanRoulette=Jt,exports.FACE_CARD_VALUE=10,exports.Half=K,exports.INSURANCE_BET_SIZE_FACTOR=ye,exports.INSURANCE_WIN_MULTIPLIER=3,exports.InsuranceOutcome=me,exports.Keno=ft,exports.KenoRiskLevel=rt,exports.LOSE_MULTIPLIER=0,exports.Limbo=pt,exports.MAX_CARDS_PER_ROUND=63,exports.MAX_WIN_CHANCE=98,exports.MIDDLE_COLUMN=Ut,exports.MIN_WIN_CHANCE=.01,exports.Mines=mt,exports.PAIR_BONUS_PAYOUTS=C,exports.PAYOUT_MULTIPLIERS=Vt,exports.PLINKO_ROW_COUNTS=gt,exports.PUSH_MULTIPLIER=1,exports.PairBonusType=ge,exports.Parity=W,exports.Plinko=vt,exports.PlinkoRiskLevel=ht,exports.RANDOM_MAX_VALUE=f,exports.RANDOM_MIN_VALUE=0,exports.RED_NUMBERS=Gt,exports.RollType=ne,exports.Roulette=Xt,exports.RouletteType=kt,exports.SPLIT_BET_SIZE_FACTOR=1,exports.THREE_CARD_BONUS_PAYOUTS=w,exports.TILE_COUNTS=it,exports.TOP_COLUMN=Ht,exports.ThreeCardBonusType=_e,exports.VALID_AMERICAN_CORNERS=Tt,exports.VALID_AMERICAN_DOUBLE_STREETS=Ot,exports.VALID_AMERICAN_SPLITS=xt,exports.VALID_AMERICAN_STRAIGHTS=yt,exports.VALID_AMERICAN_STREETS=Ct,exports.VALID_EUROPEAN_CORNERS=wt,exports.VALID_EUROPEAN_DOUBLE_STREETS=Dt,exports.VALID_EUROPEAN_SPLITS=bt,exports.VALID_EUROPEAN_STRAIGHTS=U,exports.VALID_EUROPEAN_STREETS=St,exports.VALID_RANKS=oe,exports.VALID_SUITS=ae,exports.WIN_MULTIPLIER=2,exports.advancedDiceGetExclusiveBoundsRange=y,exports.advancedDiceGetInclusiveBoundsRange=_,exports.advancedDiceIsWithinBoundsExclusive=v,exports.advancedDiceIsWithinBoundsInclusive=te,exports.calculateAdvancedDiceWinChance=b,exports.calculateBaccaratBetAmount=x,exports.calculateBlitzWinChance=Ie,exports.calculateDiceWinChance=et,exports.calculateInsuranceStake=A,exports.calculateRouletteBetAmount=Zt,exports.diamondsMultipliers=Ye,exports.getBlitzDefaults=Pe,exports.getMaxMultiplierForDifficulty=We,exports.hasBlitzWon=Fe,exports.hasDiceWon=tt,exports.isTileCount=at,exports.kenoMultipliers=dt,exports.plinkoMultipliers=_t,exports.rtp92Multipliers=ut,exports.rtp96Multipliers=lt,exports.rtp97Multipliers=ct,exports.rtp98Multipliers=st,exports.rtp99Multipliers=ot,exports.validateAdvancedDiceInputs=re,exports.validateRouletteGameInputs=$,Object.keys(c).forEach(function(e){e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return c[e]}})});
package/dist/index.d.cts CHANGED
@@ -1,148 +1,6 @@
1
+ import { BaseFinishedState, BaseInProgressState, Card as Card$1, CardDto, CardValue, GameContext, GameResult, GameStore, GetGameResultRequest, MultiActionGame, MultiplierContainer, Payout, PayoutLeg, RandomNumberGenerator, RandomValuePool, SingleActionGame } from "@betorigami/game-engine";
1
2
  import Big$1, { Big } from "big.js";
2
- //#region src/cards/types.d.ts
3
- export declare const MIN_CARD_VALUE = 0;
4
- export declare const MAX_CARD_VALUE = 51;
5
- export declare const CARD_VALUES: number[];
6
- export declare const CARD_SUITS: readonly ["Spades", "Hearts", "Diamonds", "Clubs"];
7
- export type CardSuit = (typeof CARD_SUITS)[number];
8
- export declare const CARD_RANKS: readonly ["Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"];
9
- export type CardRank = (typeof CARD_RANKS)[number];
10
- export declare const FACE_CARD_RANKS: readonly CardRank[];
11
- export type CardValue = (typeof CARD_VALUES)[number];
12
- export type CardDto = {
13
- rank: CardRank;
14
- suit: CardSuit;
15
- cardValue: CardValue;
16
- };
17
- export declare const CARD_SUIT_COLORS: Record<CardSuit, 'red' | 'black'>;
18
- //#endregion
19
- //#region src/errors/game.error.d.ts
20
- export declare enum GameErrorCode {
21
- UNSUPPORTED_EDGE = "UNSUPPORTED_EDGE",
22
- INPUT_VALIDATION_ERROR = "INPUT_VALIDATION_ERROR"
23
- }
24
- export declare class GameError extends Error {
25
- static createUnsupportedEdgeError(message: string): GameError;
26
- static createValidationError(message: string): GameError;
27
- static isGameError(error: unknown): error is GameError;
28
- errorCode: GameErrorCode;
29
- constructor(errorCode: GameErrorCode, message?: string);
30
- }
31
- //#endregion
32
- //#region src/games/origami-game.d.ts
33
- export declare enum OrigamiGame {
34
- DICE = "DICE",
35
- MINES = "MINES",
36
- KENO = "KENO",
37
- LIMBO = "LIMBO",
38
- ADVANCED_DICE = "ADVANCED_DICE",
39
- BACCARAT = "BACCARAT",
40
- DIAMONDS = "DIAMONDS",
41
- PLINKO = "PLINKO",
42
- ROULETTE = "ROULETTE",
43
- WHEEL = "WHEEL",
44
- BLACKJACK = "BLACKJACK",
45
- BLITZ = "BLITZ",
46
- DARTS = "DARTS"
47
- }
48
- //#endregion
49
- //#region src/games/game.d.ts
50
- export interface Game {
51
- gameId: OrigamiGame;
52
- supportedEdgeConfigurations: [number, ...number[]];
53
- }
54
- //#endregion
55
- //#region src/games/random.d.ts
56
- export type Proof = {
57
- proofHash: string;
58
- proofString: string;
59
- };
60
- export type SingleRandomValue = {
61
- value: number;
62
- values: number[];
63
- count: 1;
64
- min: number;
65
- max: number;
66
- } & Proof;
67
- export type MultipleRandomValues = {
68
- values: number[];
69
- count: number;
70
- min: number;
71
- max: number;
72
- } & Proof;
73
- export interface RandomNumberGenerator {
74
- getRandomInt({ min, max }: {
75
- min: number;
76
- max: number;
77
- }): SingleRandomValue;
78
- getUniqueRandomInts({ min, max, count }: {
79
- min: number;
80
- max: number;
81
- count: number;
82
- }): MultipleRandomValues;
83
- getRandomIntsWithReplacement({ min, max, count }: {
84
- min: number;
85
- max: number;
86
- count: number;
87
- }): MultipleRandomValues;
88
- }
89
- //#endregion
90
- //#region src/games/payout.d.ts
91
- /**
92
- * A single exact payout amount from a game round.
93
- *
94
- * A round returns zero or more legs. Neither their order nor their count is
95
- * significant: a leg is not tied to a particular bet, an amount may be zero,
96
- * and the number of legs need not match the number of bets placed. The only
97
- * supported operation is summing them.
98
- *
99
- * Amounts are gross — they include returned stake — and unrounded. Rounding to
100
- * a currency's precision is the consuming service's decision, not this
101
- * package's.
102
- */
103
- export type PayoutLeg = Readonly<{
104
- amount: Big$1;
105
- }>;
106
- /**
107
- * A round's payout, expressed as its constituent legs.
108
- */
109
- export type Payout = Readonly<{
110
- legs: readonly PayoutLeg[];
111
- }>;
112
- /**
113
- * Totals a round's payout.
114
- *
115
- * Summing the legs is lossless; reconstructing the total from a rounded
116
- * payout multiplier is not, so this is the only supported way to arrive at
117
- * what a round pays.
118
- */
119
- export declare const sumPayout: (payout: Payout) => Big$1;
120
- //#endregion
121
- //#region src/games/single-action-game.d.ts
122
- export type EmptyGameOutput = {};
123
- export interface GetGameResultRequest<TGameInputs> {
124
- generator: RandomNumberGenerator;
125
- edge: number;
126
- gameInputs: TGameInputs;
127
- }
128
- export interface GameResult<TGameOutputs = EmptyGameOutput> {
129
- isFinished: boolean;
130
- payout: Payout;
131
- payoutMultiplier: Big$1;
132
- outputs: TGameOutputs & {
133
- result: number[];
134
- };
135
- randomValues: SingleRandomValue | MultipleRandomValues;
136
- }
137
- export declare abstract class SingleActionGame<TGameInputs, TGameOutputs = EmptyGameOutput> implements Game {
138
- readonly gameId: OrigamiGame;
139
- protected constructor(gameId: OrigamiGame);
140
- abstract get supportedEdgeConfigurations(): [number, ...number[]];
141
- abstract getBetAmount(gameInputs: TGameInputs): Big$1;
142
- getGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
143
- protected abstract determineGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
144
- }
145
- //#endregion
3
+ export * from "@betorigami/game-engine";
146
4
  //#region src/games/advanced-dice/advanced-dice.d.ts
147
5
  export type Bounds = {
148
6
  lower: number;
@@ -490,15 +348,6 @@ Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper fo
490
348
  */
491
349
  type _ReadonlyObjectDeep<ObjectType extends object> = { readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>; };
492
350
  //#endregion
493
- //#region src/cards/card.d.ts
494
- declare class Card$1 {
495
- readonly value: CardValue;
496
- constructor(rawValue: number);
497
- get suit(): CardSuit;
498
- get rank(): CardRank;
499
- toDto(): CardDto;
500
- }
501
- //#endregion
502
351
  //#region src/games/blackjack/card/blackjack-card.d.ts
503
352
  declare class BlackjackCard extends Card$1 {
504
353
  get numericRank(): number;
@@ -551,70 +400,6 @@ declare class PlayerHand extends BlackjackHand {
551
400
  addDrawnCards(newCards: ReadonlyArray<CardValue>): PlayerHand;
552
401
  }
553
402
  //#endregion
554
- //#region src/games/random-value-pool.d.ts
555
- export declare class RandomValuePool {
556
- private readonly source;
557
- private index;
558
- private constructor();
559
- static from(result: MultipleRandomValues, count: number): RandomValuePool;
560
- get consumedValues(): number[];
561
- toMultipleRandomValues(): MultipleRandomValues;
562
- takeOne(): number;
563
- take(count: number): ReadonlyArray<number>;
564
- }
565
- //#endregion
566
- //#region src/games/multi-action-game.d.ts
567
- export type BaseInProgressState = Readonly<{
568
- isFinished: false;
569
- multiplier: Big$1;
570
- }>;
571
- export type BaseFinishedState = Readonly<{
572
- isFinished: true;
573
- payout: Payout;
574
- multiplier: Big$1;
575
- randomValues: number[];
576
- }>;
577
- export type BaseGameState = BaseInProgressState | BaseFinishedState;
578
- export type GameContext<TAction, TState extends BaseGameState, TConfig> = {
579
- readonly playerArgument: TAction;
580
- readonly state: TState;
581
- readonly config: TConfig;
582
- readonly additionalBetAmount?: Big$1;
583
- };
584
- export type RandomValuePoolEvent = Readonly<{
585
- randomValuePool: RandomValuePool;
586
- }>;
587
- export type UntypedGameContext = GameContext<{
588
- readonly type: string;
589
- }, BaseGameState, unknown>;
590
- export type PlayResult = UntypedGameContext & {
591
- readonly proof: Proof;
592
- };
593
- export interface GameStore<TInternalState extends BaseGameState, TAction, TConfig> {
594
- send(event: {
595
- readonly type: string;
596
- } & RandomValuePoolEvent & Record<string, unknown>): void;
597
- getSnapshot(): {
598
- readonly context: GameContext<TAction, TInternalState, TConfig>;
599
- };
600
- }
601
- export declare abstract class MultiActionGame<TInternalState extends BaseGameState, TExternalState extends BaseGameState, TAction extends {
602
- readonly type: string;
603
- }, TConfig> implements Game {
604
- readonly gameId: OrigamiGame;
605
- readonly edge: number;
606
- protected constructor(gameId: OrigamiGame, edge: number);
607
- abstract get supportedEdgeConfigurations(): [number, ...number[]];
608
- abstract getValidNextActionTypes(state: TExternalState): ReadonlyArray<TAction['type']>;
609
- protected abstract createGameStore(): GameStore<TInternalState, TAction, TConfig>;
610
- protected abstract generateRandomValues(generator: RandomNumberGenerator): RandomValuePool;
611
- protected abstract toExternalState(internal: TInternalState): TExternalState;
612
- play(generator: RandomNumberGenerator, action: {
613
- readonly type: string;
614
- } & Record<string, unknown>, previousActions?: readonly UntypedGameContext[]): PlayResult;
615
- private validateEdge;
616
- }
617
- //#endregion
618
403
  //#region src/games/blackjack/insurance-stake.d.ts
619
404
  export type RoundInsuranceStake = (unroundedStake: Big$1) => Big$1;
620
405
  export declare const calculateInsuranceStake: (mainBetAmount: Big$1, roundInsuranceStake: RoundInsuranceStake) => Big$1;
@@ -820,17 +605,6 @@ export type DartboardConfig = ReadonlyDeep<{
820
605
  export declare const getMaxMultiplierForDifficulty: (difficultyLevel: DARTS_DIFFICULTY_LEVEL) => number;
821
606
  export declare const DARTS_BOARD_CONFIGS: Record<DARTS_DIFFICULTY_LEVEL, DartboardConfig>;
822
607
  //#endregion
823
- //#region src/games/infrastructure/multiplier.container.d.ts
824
- declare class MultiplierContainer<TMultipliers> {
825
- readonly multipliers: Map<number, TMultipliers>;
826
- constructor(multipliers: Map<number, TMultipliers>);
827
- getMultipliers(edge: number): TMultipliers;
828
- getAllMultipliers(): {
829
- edge: number;
830
- multipliers: TMultipliers;
831
- }[];
832
- }
833
- //#endregion
834
608
  //#region src/games/diamonds/diamonds.d.ts
835
609
  export interface DiamondsGameInputs {
836
610
  betAmount: Big$1;
@@ -1210,46 +984,4 @@ export declare const calculateRouletteBetAmount: (gameInputs: RouletteGameInputs
1210
984
  //#endregion
1211
985
  //#region src/games/roulette/roulette.validation.d.ts
1212
986
  export declare const validateRouletteGameInputs: (gameInputs: RouletteGameInputs, edge: number) => void;
1213
- //#endregion
1214
- //#region src/games/wheel/wheel.constants.d.ts
1215
- export declare enum WheelRiskLevel {
1216
- LOW_RISK = "LOW_RISK",
1217
- MEDIUM_RISK = "MEDIUM_RISK",
1218
- HIGH_RISK = "HIGH_RISK"
1219
- }
1220
- export declare enum WheelSegments {
1221
- TEN = 10,
1222
- TWENTY = 20,
1223
- THIRTY = 30,
1224
- FORTY = 40,
1225
- FIFTY = 50
1226
- }
1227
- //#endregion
1228
- //#region src/games/wheel/wheel.d.ts
1229
- export interface WheelGameInputs {
1230
- segments: WheelSegments;
1231
- riskLevel: WheelRiskLevel;
1232
- betAmount: Big;
1233
- }
1234
- export declare class Wheel extends SingleActionGame<WheelGameInputs> {
1235
- constructor();
1236
- get supportedEdgeConfigurations(): [number, ...number[]];
1237
- getBetAmount(gameInputs: WheelGameInputs): Big;
1238
- protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<WheelGameInputs>): GameResult;
1239
- }
1240
- //#endregion
1241
- //#region src/utils/big-max.d.ts
1242
- export declare const bigMax: (a: Big$1, b: Big$1) => Big$1;
1243
- //#endregion
1244
- //#region src/utils/big-min.d.ts
1245
- export declare const bigMin: (a: Big$1, b: Big$1) => Big$1;
1246
- //#endregion
1247
- //#region src/utils/multiplier-calculator.d.ts
1248
- export declare abstract class MultiplierCalculator {
1249
- static withMultiplier(multiplier: Big$1, edge: number): Big$1;
1250
- static withWinChance(edge: number, winChance: Big$1): Big$1;
1251
- }
1252
- //#endregion
1253
- //#region src/utils/ncr.d.ts
1254
- export declare const nCr: (n: number, r: number) => number;
1255
987
  //#endregion
package/dist/index.d.ts CHANGED
@@ -1,148 +1,6 @@
1
+ import { BaseFinishedState, BaseInProgressState, Card as Card$1, CardDto, CardValue, GameContext, GameResult, GameStore, GetGameResultRequest, MultiActionGame, MultiplierContainer, Payout, PayoutLeg, RandomNumberGenerator, RandomValuePool, SingleActionGame } from "@betorigami/game-engine";
1
2
  import Big$1, { Big } from "big.js";
2
- //#region src/cards/types.d.ts
3
- export declare const MIN_CARD_VALUE = 0;
4
- export declare const MAX_CARD_VALUE = 51;
5
- export declare const CARD_VALUES: number[];
6
- export declare const CARD_SUITS: readonly ["Spades", "Hearts", "Diamonds", "Clubs"];
7
- export type CardSuit = (typeof CARD_SUITS)[number];
8
- export declare const CARD_RANKS: readonly ["Ace", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"];
9
- export type CardRank = (typeof CARD_RANKS)[number];
10
- export declare const FACE_CARD_RANKS: readonly CardRank[];
11
- export type CardValue = (typeof CARD_VALUES)[number];
12
- export type CardDto = {
13
- rank: CardRank;
14
- suit: CardSuit;
15
- cardValue: CardValue;
16
- };
17
- export declare const CARD_SUIT_COLORS: Record<CardSuit, 'red' | 'black'>;
18
- //#endregion
19
- //#region src/errors/game.error.d.ts
20
- export declare enum GameErrorCode {
21
- UNSUPPORTED_EDGE = "UNSUPPORTED_EDGE",
22
- INPUT_VALIDATION_ERROR = "INPUT_VALIDATION_ERROR"
23
- }
24
- export declare class GameError extends Error {
25
- static createUnsupportedEdgeError(message: string): GameError;
26
- static createValidationError(message: string): GameError;
27
- static isGameError(error: unknown): error is GameError;
28
- errorCode: GameErrorCode;
29
- constructor(errorCode: GameErrorCode, message?: string);
30
- }
31
- //#endregion
32
- //#region src/games/origami-game.d.ts
33
- export declare enum OrigamiGame {
34
- DICE = "DICE",
35
- MINES = "MINES",
36
- KENO = "KENO",
37
- LIMBO = "LIMBO",
38
- ADVANCED_DICE = "ADVANCED_DICE",
39
- BACCARAT = "BACCARAT",
40
- DIAMONDS = "DIAMONDS",
41
- PLINKO = "PLINKO",
42
- ROULETTE = "ROULETTE",
43
- WHEEL = "WHEEL",
44
- BLACKJACK = "BLACKJACK",
45
- BLITZ = "BLITZ",
46
- DARTS = "DARTS"
47
- }
48
- //#endregion
49
- //#region src/games/game.d.ts
50
- export interface Game {
51
- gameId: OrigamiGame;
52
- supportedEdgeConfigurations: [number, ...number[]];
53
- }
54
- //#endregion
55
- //#region src/games/random.d.ts
56
- export type Proof = {
57
- proofHash: string;
58
- proofString: string;
59
- };
60
- export type SingleRandomValue = {
61
- value: number;
62
- values: number[];
63
- count: 1;
64
- min: number;
65
- max: number;
66
- } & Proof;
67
- export type MultipleRandomValues = {
68
- values: number[];
69
- count: number;
70
- min: number;
71
- max: number;
72
- } & Proof;
73
- export interface RandomNumberGenerator {
74
- getRandomInt({ min, max }: {
75
- min: number;
76
- max: number;
77
- }): SingleRandomValue;
78
- getUniqueRandomInts({ min, max, count }: {
79
- min: number;
80
- max: number;
81
- count: number;
82
- }): MultipleRandomValues;
83
- getRandomIntsWithReplacement({ min, max, count }: {
84
- min: number;
85
- max: number;
86
- count: number;
87
- }): MultipleRandomValues;
88
- }
89
- //#endregion
90
- //#region src/games/payout.d.ts
91
- /**
92
- * A single exact payout amount from a game round.
93
- *
94
- * A round returns zero or more legs. Neither their order nor their count is
95
- * significant: a leg is not tied to a particular bet, an amount may be zero,
96
- * and the number of legs need not match the number of bets placed. The only
97
- * supported operation is summing them.
98
- *
99
- * Amounts are gross — they include returned stake — and unrounded. Rounding to
100
- * a currency's precision is the consuming service's decision, not this
101
- * package's.
102
- */
103
- export type PayoutLeg = Readonly<{
104
- amount: Big$1;
105
- }>;
106
- /**
107
- * A round's payout, expressed as its constituent legs.
108
- */
109
- export type Payout = Readonly<{
110
- legs: readonly PayoutLeg[];
111
- }>;
112
- /**
113
- * Totals a round's payout.
114
- *
115
- * Summing the legs is lossless; reconstructing the total from a rounded
116
- * payout multiplier is not, so this is the only supported way to arrive at
117
- * what a round pays.
118
- */
119
- export declare const sumPayout: (payout: Payout) => Big$1;
120
- //#endregion
121
- //#region src/games/single-action-game.d.ts
122
- export type EmptyGameOutput = {};
123
- export interface GetGameResultRequest<TGameInputs> {
124
- generator: RandomNumberGenerator;
125
- edge: number;
126
- gameInputs: TGameInputs;
127
- }
128
- export interface GameResult<TGameOutputs = EmptyGameOutput> {
129
- isFinished: boolean;
130
- payout: Payout;
131
- payoutMultiplier: Big$1;
132
- outputs: TGameOutputs & {
133
- result: number[];
134
- };
135
- randomValues: SingleRandomValue | MultipleRandomValues;
136
- }
137
- export declare abstract class SingleActionGame<TGameInputs, TGameOutputs = EmptyGameOutput> implements Game {
138
- readonly gameId: OrigamiGame;
139
- protected constructor(gameId: OrigamiGame);
140
- abstract get supportedEdgeConfigurations(): [number, ...number[]];
141
- abstract getBetAmount(gameInputs: TGameInputs): Big$1;
142
- getGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
143
- protected abstract determineGameResult(request: GetGameResultRequest<TGameInputs>): GameResult<TGameOutputs>;
144
- }
145
- //#endregion
3
+ export * from "@betorigami/game-engine";
146
4
  //#region src/games/advanced-dice/advanced-dice.d.ts
147
5
  export type Bounds = {
148
6
  lower: number;
@@ -490,15 +348,6 @@ Same as `ReadonlyDeep`, but accepts only `object`s as inputs. Internal helper fo
490
348
  */
491
349
  type _ReadonlyObjectDeep<ObjectType extends object> = { readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>; };
492
350
  //#endregion
493
- //#region src/cards/card.d.ts
494
- declare class Card$1 {
495
- readonly value: CardValue;
496
- constructor(rawValue: number);
497
- get suit(): CardSuit;
498
- get rank(): CardRank;
499
- toDto(): CardDto;
500
- }
501
- //#endregion
502
351
  //#region src/games/blackjack/card/blackjack-card.d.ts
503
352
  declare class BlackjackCard extends Card$1 {
504
353
  get numericRank(): number;
@@ -551,70 +400,6 @@ declare class PlayerHand extends BlackjackHand {
551
400
  addDrawnCards(newCards: ReadonlyArray<CardValue>): PlayerHand;
552
401
  }
553
402
  //#endregion
554
- //#region src/games/random-value-pool.d.ts
555
- export declare class RandomValuePool {
556
- private readonly source;
557
- private index;
558
- private constructor();
559
- static from(result: MultipleRandomValues, count: number): RandomValuePool;
560
- get consumedValues(): number[];
561
- toMultipleRandomValues(): MultipleRandomValues;
562
- takeOne(): number;
563
- take(count: number): ReadonlyArray<number>;
564
- }
565
- //#endregion
566
- //#region src/games/multi-action-game.d.ts
567
- export type BaseInProgressState = Readonly<{
568
- isFinished: false;
569
- multiplier: Big$1;
570
- }>;
571
- export type BaseFinishedState = Readonly<{
572
- isFinished: true;
573
- payout: Payout;
574
- multiplier: Big$1;
575
- randomValues: number[];
576
- }>;
577
- export type BaseGameState = BaseInProgressState | BaseFinishedState;
578
- export type GameContext<TAction, TState extends BaseGameState, TConfig> = {
579
- readonly playerArgument: TAction;
580
- readonly state: TState;
581
- readonly config: TConfig;
582
- readonly additionalBetAmount?: Big$1;
583
- };
584
- export type RandomValuePoolEvent = Readonly<{
585
- randomValuePool: RandomValuePool;
586
- }>;
587
- export type UntypedGameContext = GameContext<{
588
- readonly type: string;
589
- }, BaseGameState, unknown>;
590
- export type PlayResult = UntypedGameContext & {
591
- readonly proof: Proof;
592
- };
593
- export interface GameStore<TInternalState extends BaseGameState, TAction, TConfig> {
594
- send(event: {
595
- readonly type: string;
596
- } & RandomValuePoolEvent & Record<string, unknown>): void;
597
- getSnapshot(): {
598
- readonly context: GameContext<TAction, TInternalState, TConfig>;
599
- };
600
- }
601
- export declare abstract class MultiActionGame<TInternalState extends BaseGameState, TExternalState extends BaseGameState, TAction extends {
602
- readonly type: string;
603
- }, TConfig> implements Game {
604
- readonly gameId: OrigamiGame;
605
- readonly edge: number;
606
- protected constructor(gameId: OrigamiGame, edge: number);
607
- abstract get supportedEdgeConfigurations(): [number, ...number[]];
608
- abstract getValidNextActionTypes(state: TExternalState): ReadonlyArray<TAction['type']>;
609
- protected abstract createGameStore(): GameStore<TInternalState, TAction, TConfig>;
610
- protected abstract generateRandomValues(generator: RandomNumberGenerator): RandomValuePool;
611
- protected abstract toExternalState(internal: TInternalState): TExternalState;
612
- play(generator: RandomNumberGenerator, action: {
613
- readonly type: string;
614
- } & Record<string, unknown>, previousActions?: readonly UntypedGameContext[]): PlayResult;
615
- private validateEdge;
616
- }
617
- //#endregion
618
403
  //#region src/games/blackjack/insurance-stake.d.ts
619
404
  export type RoundInsuranceStake = (unroundedStake: Big$1) => Big$1;
620
405
  export declare const calculateInsuranceStake: (mainBetAmount: Big$1, roundInsuranceStake: RoundInsuranceStake) => Big$1;
@@ -820,17 +605,6 @@ export type DartboardConfig = ReadonlyDeep<{
820
605
  export declare const getMaxMultiplierForDifficulty: (difficultyLevel: DARTS_DIFFICULTY_LEVEL) => number;
821
606
  export declare const DARTS_BOARD_CONFIGS: Record<DARTS_DIFFICULTY_LEVEL, DartboardConfig>;
822
607
  //#endregion
823
- //#region src/games/infrastructure/multiplier.container.d.ts
824
- declare class MultiplierContainer<TMultipliers> {
825
- readonly multipliers: Map<number, TMultipliers>;
826
- constructor(multipliers: Map<number, TMultipliers>);
827
- getMultipliers(edge: number): TMultipliers;
828
- getAllMultipliers(): {
829
- edge: number;
830
- multipliers: TMultipliers;
831
- }[];
832
- }
833
- //#endregion
834
608
  //#region src/games/diamonds/diamonds.d.ts
835
609
  export interface DiamondsGameInputs {
836
610
  betAmount: Big$1;
@@ -1210,46 +984,4 @@ export declare const calculateRouletteBetAmount: (gameInputs: RouletteGameInputs
1210
984
  //#endregion
1211
985
  //#region src/games/roulette/roulette.validation.d.ts
1212
986
  export declare const validateRouletteGameInputs: (gameInputs: RouletteGameInputs, edge: number) => void;
1213
- //#endregion
1214
- //#region src/games/wheel/wheel.constants.d.ts
1215
- export declare enum WheelRiskLevel {
1216
- LOW_RISK = "LOW_RISK",
1217
- MEDIUM_RISK = "MEDIUM_RISK",
1218
- HIGH_RISK = "HIGH_RISK"
1219
- }
1220
- export declare enum WheelSegments {
1221
- TEN = 10,
1222
- TWENTY = 20,
1223
- THIRTY = 30,
1224
- FORTY = 40,
1225
- FIFTY = 50
1226
- }
1227
- //#endregion
1228
- //#region src/games/wheel/wheel.d.ts
1229
- export interface WheelGameInputs {
1230
- segments: WheelSegments;
1231
- riskLevel: WheelRiskLevel;
1232
- betAmount: Big;
1233
- }
1234
- export declare class Wheel extends SingleActionGame<WheelGameInputs> {
1235
- constructor();
1236
- get supportedEdgeConfigurations(): [number, ...number[]];
1237
- getBetAmount(gameInputs: WheelGameInputs): Big;
1238
- protected determineGameResult({ generator, gameInputs, edge }: GetGameResultRequest<WheelGameInputs>): GameResult;
1239
- }
1240
- //#endregion
1241
- //#region src/utils/big-max.d.ts
1242
- export declare const bigMax: (a: Big$1, b: Big$1) => Big$1;
1243
- //#endregion
1244
- //#region src/utils/big-min.d.ts
1245
- export declare const bigMin: (a: Big$1, b: Big$1) => Big$1;
1246
- //#endregion
1247
- //#region src/utils/multiplier-calculator.d.ts
1248
- export declare abstract class MultiplierCalculator {
1249
- static withMultiplier(multiplier: Big$1, edge: number): Big$1;
1250
- static withWinChance(edge: number, winChance: Big$1): Big$1;
1251
- }
1252
- //#endregion
1253
- //#region src/utils/ncr.d.ts
1254
- export declare const nCr: (n: number, r: number) => number;
1255
987
  //#endregion
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{Guard as e}from"@betorigami/guard";import t,{Big as n}from"big.js";import{createStore as r}from"@xstate/store";import i from"fast-deep-equal";const a=0,o=51,s=Array.from({length:52},(e,t)=>t),c=[`Spades`,`Hearts`,`Diamonds`,`Clubs`],l=[`Ace`,`Two`,`Three`,`Four`,`Five`,`Six`,`Seven`,`Eight`,`Nine`,`Ten`,`Jack`,`Queen`,`King`],u=[`Jack`,`Queen`,`King`],d={Hearts:`red`,Diamonds:`red`,Spades:`black`,Clubs:`black`};let f=function(e){return e.UNSUPPORTED_EDGE=`UNSUPPORTED_EDGE`,e.INPUT_VALIDATION_ERROR=`INPUT_VALIDATION_ERROR`,e}({});var p=class e extends Error{static createUnsupportedEdgeError(t){return new e(`UNSUPPORTED_EDGE`,t)}static createValidationError(t){return new e(`INPUT_VALIDATION_ERROR`,t)}static isGameError(t){return t instanceof e}errorCode;constructor(e,t){super(t),this.errorCode=e}};let m=function(e){return e.DICE=`DICE`,e.MINES=`MINES`,e.KENO=`KENO`,e.LIMBO=`LIMBO`,e.ADVANCED_DICE=`ADVANCED_DICE`,e.BACCARAT=`BACCARAT`,e.DIAMONDS=`DIAMONDS`,e.PLINKO=`PLINKO`,e.ROULETTE=`ROULETTE`,e.WHEEL=`WHEEL`,e.BLACKJACK=`BLACKJACK`,e.BLITZ=`BLITZ`,e.DARTS=`DARTS`,e}({});var h=class{gameId;constructor(e){this.gameId=e}getGameResult(t){let n=this.supportedEdgeConfigurations.includes(t.edge);return e.against(!n,()=>p.createUnsupportedEdgeError(`${this.gameId} does not support ${t.edge}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`)),this.determineGameResult(t)}},g=class{static withMultiplier(e,n){return new t(e).times(new t(100-n).div(100))}static withWinChance(e,n){return t(100-e).div(n)}};const ee=0,_=1e4,v=10001,te=.01,ne=98,re=e=>{if(e<0)throw p.createValidationError(`Lower bound ${e} is below minimum allowed value 0`)},ie=e=>{if(e>1e4)throw p.createValidationError(`Upper bound ${e} is above maximum allowed value ${_}`)},y=e=>{if(re(e.lower),ie(e.upper),e.lower>=e.upper)throw p.createValidationError(`Lower bound ${e.lower} must be less than ${e.upper}`)},ae=(e,t)=>{let[n,r]=e.lower<=t.lower?[e,t]:[t,e];if(n.upper>r.lower)throw p.createValidationError(`Bounds must not overlap`)},b=(e,t)=>t>=e.lower&&t<=e.upper,x=e=>e.upper-e.lower+1,S=(e,t)=>t>e.lower&&t<e.upper,C=e=>e.upper-e.lower-1;let oe=function(e){return e.ROLL_BETWEEN=`ROLL_BETWEEN`,e.ROLL_OUTSIDE=`ROLL_OUTSIDE`,e.ROLL_BETWEEN_TWO=`ROLL_BETWEEN_TWO`,e}({});const w=e=>{let t=(()=>{switch(e.mode){case`ROLL_BETWEEN`:return y(e.bounds),C(e.bounds);case`ROLL_OUTSIDE`:return y(e.bounds),v-x(e.bounds);case`ROLL_BETWEEN_TWO`:return y(e.firstBounds),y(e.secondBounds),ae(e.firstBounds,e.secondBounds),C(e.firstBounds)+C(e.secondBounds)}})(),r=n(t).div(v).mul(100);if(r.lt(.01))throw p.createValidationError(`Win chance too low`);if(r.gt(98))throw p.createValidationError(`Win chance too high`);return r},se=e=>{w(e)};var ce=class extends h{constructor(){super(`ADVANCED_DICE`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:r}){let i=w(r),a=e.getRandomInt({min:0,max:_}),o=a.value,s=(()=>{switch(r.mode){case`ROLL_BETWEEN`:return S(r.bounds,o);case`ROLL_OUTSIDE`:return!b(r.bounds,o);case`ROLL_BETWEEN_TWO`:return S(r.firstBounds,o)||S(r.secondBounds,o)}})()?g.withWinChance(t,i):new n(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:a.values},randomValues:a}}},T=class{value;constructor(t){let n=s[t];e.againstNullOrUndefined(n,`Invalid card value: ${t}`),this.value=n}get suit(){let t=Math.floor(this.value/13),n=c[t];return e.againstNullOrUndefined(n,`Invalid suit index: ${t}`),n}get rank(){let t=this.value%13,n=l[t];return e.againstNullOrUndefined(n,`Invalid rank index: ${t}`),n}toDto(){return{rank:this.rank,suit:this.suit,cardValue:this.value}}};const E=e=>e.legs.reduce((e,t)=>e.add(t.amount),new t(`0`)),le=[`Clubs`,`Diamonds`,`Hearts`,`Spades`],ue=[`Ace`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`Jack`,`Queen`,`King`],de={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`};let fe=function(e){return e.PLAYER_WIN=`PLAYER_WIN`,e.TIE=`TIE`,e.BANKER_WIN=`BANKER_WIN`,e}({}),pe=function(e){return e.PLAYER=`PLAYER`,e.TIE=`TIE`,e.BANKER=`BANKER`,e}({});const me={PLAYER_WIN:{betType:`PLAYER`,multiplier:2},TIE:{betType:`TIE`,multiplier:9},BANKER_WIN:{betType:`BANKER`,multiplier:1.95}},D=e=>new t(0).add(e.bets.reduce((e,t)=>e.add(t.amount),new t(0))),he=(e,t)=>e===`TIE`&&(t===`PLAYER`||t===`BANKER`);var ge=class extends h{constructor(){super(`BACCARAT`)}get supportedEdgeConfigurations(){return[1]}getBetAmount(e){return D(e)}determineGameResult({generator:e,gameInputs:n}){this.validateGameInputs(n);let r=e.getRandomIntsWithReplacement({min:0,max:51,count:6}),i=r.values,a=i.slice(0,3),o=i.slice(3,6),s=[],c=0;for(let e of a.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);s.push(t),c=(c+n)%10}let l=[],u=0;for(let e of o.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);l.push(t),u=(u+n)%10}if(!this.isNaturalWin(c,u)){let e=this.shouldDrawThirdPlayerCard(c),t=null;e&&(t=this.mapRandomValueToCardValue(a[2]),s.push(this.mapRandomValueToCard(a[2])),c=(c+t)%10),this.shouldDrawThirdBankerCard(u,t)&&(l.push(this.mapRandomValueToCard(o[2])),u=(u+this.mapRandomValueToCardValue(o[2]))%10)}let d;d=c===u?`TIE`:c>u?`PLAYER_WIN`:`BANKER_WIN`;let f=D(n),{betType:p,multiplier:m}=me[d],h={legs:n.bets.map(e=>e.type===p?{amount:e.amount.mul(m)}:{amount:he(d,e.type)?e.amount:new t(`0`)})},g=E(h);return{isFinished:!0,payout:h,payoutMultiplier:f.gt(0)?g.div(f):new t(0),outputs:{playerCards:s,playerHandValue:c,bankerCards:l,bankerHandValue:u,gameOutcome:d,result:r.values},randomValues:r}}validateGameInputs(e){if(e.bets.length===0)throw Error(`Must place at least a single bet.`);if(!e.bets.every(e=>e.amount.gte(0)))throw Error(`Invalid bet.`)}mapRandomValueToCard(e){let t=new T(e);return{suit:t.suit,rank:de[t.rank]}}isNaturalWin(e,t){let n=[8,9];return n.includes(e)||n.includes(t)}mapRandomValueToCardValue(e){let t=e%13;return t===0?1:t>=10?10:t+1}shouldDrawThirdPlayerCard(e){return e<=5}shouldDrawThirdBankerCard(e,t){return t===null?e<=5:e<=2?!0:e===3?t!==8:e===4?[2,3,4,5,6,7].includes(t):e===5?[4,5,6,7].includes(t):e===6&&[6,7].includes(t)}};let _e=function(e){return e.WIN=`WIN`,e.LOSE=`LOSE`,e.PUSH=`PUSH`,e.PLAYER_BLACKJACK=`PLAYER_BLACKJACK`,e}({}),ve=function(e){return e.WON=`WON`,e.LOST=`LOST`,e}({}),ye=function(e){return e.START=`START`,e.HIT=`BLACKJACK_HIT`,e.STAND=`BLACKJACK_STAND`,e.BUY_INSURANCE=`BLACKJACK_BUY_INSURANCE`,e.REJECT_INSURANCE=`BLACKJACK_REJECT_INSURANCE`,e.DOUBLE_DOWN=`BLACKJACK_DOUBLE_DOWN`,e.SPLIT=`BLACKJACK_SPLIT`,e}({}),be=function(e){return e.EXACT_PAIR=`EXACT_PAIR`,e.COLORED_PAIR=`COLORED_PAIR`,e.MIXED_PAIR=`MIXED_PAIR`,e.LOSS=`LOSS`,e}({}),xe=function(e){return e.SUITED_TRIPS=`SUITED_TRIPS`,e.STRAIGHT_FLUSH=`STRAIGHT_FLUSH`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.STRAIGHT=`STRAIGHT`,e.FLUSH=`FLUSH`,e.LOSS=`LOSS`,e}({});const O=2.5,Se=2,Ce=1,we=0,Te=17,Ee=21,De=21,Oe=63,k=.5,ke=3,Ae=1,je=1,Me=13,Ne=10,Pe=10,A={PLAYER_BLACKJACK:O,WIN:2,PUSH:1,LOSE:0},j={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},M={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var N=class t extends T{get numericRank(){return u.includes(this.rank)?10:l.indexOf(this.rank)+1}static fromValue(n){return e.against(!s.includes(n),`Invalid card value: ${n}`),new t(n)}},Fe=class{cards;hardHandValue;softHandValue=null;constructor(e){this.cards=e,this.hardHandValue=e.reduce((e,t)=>e+t.numericRank,0),e.some(e=>e.rank===`Ace`)&&this.hardHandValue+10<=21&&(this.softHandValue=this.hardHandValue+10)}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>21}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===21}get highestHandValue(){return this.softHandValue===null?this.hardHandValue:this.softHandValue}},Ie=class{cards;value;constructor(e){this.cards=e.map(e=>N.fromValue(e)),this.value=new Fe(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(e=>e.value)}toDto(){return{cards:this.cards.map(e=>e.toDto()),value:this.highestHandValue}}},Le=class e extends Ie{otherCards;upCard;holeCard;constructor(e,t,n=[]){super([e,t,...n]),this.otherCards=n,this.upCard=N.fromValue(e),this.holeCard=N.fromValue(t)}static withInitialDeal(t){return new e(t.upCard,t.holeCard)}addDrawnCards(t){return new e(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(e=!1){return e?super.toDto():{cards:[this.upCard.toDto()],value:new Fe([this.upCard]).highestHandValue}}},P=class e extends Ie{static withInitialDeal(t){return new e(t)}addDrawnCards(t){return new e([...this.rawValues,...t])}},Re=class t{source;index=0;constructor(e){this.source=e}static from(n,r){return e.against(r<=0,`Count must be positive, got ${r}`),e.against(n.values.length!==r,`Expected ${r} values, got ${n.values.length}`),new t(n)}get consumedValues(){return this.source.values.slice(0,this.index)}toMultipleRandomValues(){return this.source}takeOne(){let t=this.source.values[this.index];return e.againstUndefined(t,`RandomValuePool exhausted`),this.index+=1,t}take(t){e.against(this.index+t>this.source.values.length,`RandomValuePool exhausted: requested ${t} but only ${this.source.values.length-this.index} remain`);let n=this.source.values.slice(this.index,this.index+t);return this.index+=t,n}},ze=class{gameId;edge;constructor(e,t){this.gameId=e,this.edge=t,this.validateEdge(t)}play(t,n,r=[]){let a=this.createGameStore(),o=this.generateRandomValues(t),s=o.toMultipleRandomValues();for(let e of r)a.send({...e.playerArgument,randomValuePool:o});let c=r[r.length-1];c&&e.against(!i(c.state,this.toExternalState(a.getSnapshot().context.state)),`The final state of the game does not match the expected state based on the previous actions`),a.send({...n,randomValuePool:o});let l=a.getSnapshot().context;return{playerArgument:l.playerArgument,state:this.toExternalState(l.state),config:l.config,additionalBetAmount:l.additionalBetAmount,proof:{proofHash:s.proofHash,proofString:s.proofString}}}validateEdge(t){let n=this.supportedEdgeConfigurations.includes(t);e.against(!n,()=>p.createUnsupportedEdgeError(`${this.gameId} does not support ${t}% edge. Supported edge configurations include: ${this.supportedEdgeConfigurations}`))}};const Be=e=>[e.pairBonus===null?null:{amount:t(e.pairBonus.betAmount).mul(e.pairBonus.payoutMultiplier)},e.threeCardBonus===null?null:{amount:t(e.threeCardBonus.betAmount).mul(e.threeCardBonus.payoutMultiplier)}].filter(e=>e!==null),Ve=n=>{let r=n.betAmounts.mainBetAmount,i=n.actionType===`BLACKJACK_DOUBLE_DOWN`?r.mul(1):t(0),a=n.insuranceOutcome===void 0?t(0):n.insuranceStake,o=r.plus(i).mul(A[n.outcome]),s=n.insuranceOutcome===`WON`?a.mul(3):t(0),c=Be(n.sideBetResults),l=[{amount:o},...n.insuranceOutcome===void 0?[]:[{amount:s}],...c],u=E({legs:l}),d=r.plus(a).plus(i).plus(n.betAmounts.pairBonusAmount).plus(n.betAmounts.threeCardBonusAmount);e.against(d.eq(0),`Total bet amount cannot be zero`);let f=u.div(d);e.against(n.actionType===`BLACKJACK_SPLIT`,`SPLIT action type is not valid for standard multiplier calculation`);let p;switch(n.actionType){case`BLACKJACK_DOUBLE_DOWN`:p=i;break;case`BLACKJACK_BUY_INSURANCE`:p=n.insuranceStake;break;case`BLACKJACK_SPLIT`:p=r.mul(1)}return{payouts:l,totalBetAmount:d,multiplier:f,additionalBetAmount:p}},He=n=>{let r=n.betAmounts.mainBetAmount,i=n.mainHandDoubledDown?r.mul(1):t(0),a=n.splitHandDoubledDown?r.mul(1):t(0),o=n.insuranceOutcome===void 0?t(0):n.insuranceStake,s=r.plus(i).mul(A[n.mainOutcome]),c=r.plus(a).mul(A[n.splitOutcome]),l=n.insuranceOutcome===`WON`?o.mul(3):t(0),u=Be(n.sideBetResults),d=[{amount:s},{amount:c},...n.insuranceOutcome===void 0?[]:[{amount:l}],...u],f=E({legs:d}),p=r.plus(r).plus(o).plus(i).plus(a).plus(n.betAmounts.pairBonusAmount).plus(n.betAmounts.threeCardBonusAmount);e.against(p.eq(0),`Total bet amount cannot be zero`);let m=f.div(p),h;switch(n.actionType){case`BLACKJACK_DOUBLE_DOWN`:h=r.mul(1);break;case`BLACKJACK_SPLIT`:h=r.mul(1)}return{payouts:d,totalBetAmount:p,multiplier:m,additionalBetAmount:h}},Ue=(e,t)=>t(e.mul(k)),F=e=>e.every(t=>t===e[0]),We=t=>{let n=[...t].sort((e,t)=>e-t);return n.every((t,r)=>{let i=n[r-1];return r===0||(e.againstUndefined(i,`Previous value cannot be undefined`),t===i+1)})},Ge={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},Ke={...Ge,Ace:14},qe=e=>We(e.map(e=>Ge[e]))||We(e.map(e=>Ke[e])),Je=(e,t)=>{let n=N.fromValue(e),r=N.fromValue(t);return n.rank===r.rank?e===t?`EXACT_PAIR`:d[n.suit]===d[r.suit]?`COLORED_PAIR`:`MIXED_PAIR`:`LOSS`},Ye=(e,t)=>({betAmount:e,result:t,payoutMultiplier:j[t]}),Xe=(e,t,n)=>{let r=N.fromValue(e),i=N.fromValue(t),a=N.fromValue(n),o=[r.rank,i.rank,a.rank],s=F([r.suit,i.suit,a.suit]),c=F(o),l=qe(o);return F([e,t,n])?`SUITED_TRIPS`:s&&l?`STRAIGHT_FLUSH`:c?`THREE_OF_A_KIND`:l?`STRAIGHT`:s?`FLUSH`:`LOSS`},Ze=(e,t)=>({betAmount:e,result:t,payoutMultiplier:M[t]}),Qe={state:{isFinished:!1,phase:`uninitialised`,multiplier:t(0)},config:{},playerArgument:{type:`START`,mainBetAmount:`0`,pairBonusAmount:`0`,threeCardBonusAmount:`0`}},I=e=>N.fromValue(e).value;function $e(t){e.against(t.phase!==`in-progress`,`Expected a started, in-progress game state`)}function et(t){e.against(t.phase!==`awaiting-insurance`,`Expected game to be awaiting insurance decision`)}function L(t){e.against(t.phase!==`in-progress`&&t.phase!==`playing-main-hand`&&t.phase!==`playing-split-hand`,`Expected a started, in-progress game state`)}const tt=(e,t)=>{let n=t;for(;n.highestHandValue<17;)n=n.addDrawnCards([I(e.takeOne())]);return n},R=(e,t)=>{if(e.isBusted)return`LOSE`;if(t.isBusted)return`WIN`;let n=e.highestHandValue,r=t.highestHandValue;return n>r?`WIN`:n<r?`LOSE`:`PUSH`},nt=e=>e.insuranceOutcome===void 0?t(0):e.calculateStake(e.betAmounts.mainBetAmount),rt=e=>{let{payouts:t,multiplier:n,additionalBetAmount:r}=Ve({outcome:e.outcome,insuranceOutcome:e.insuranceOutcome,insuranceStake:nt(e),actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`finished`,playerHand:e.playerHand,dealerHand:e.dealerHand,outcome:e.outcome,payout:{legs:t},multiplier:n,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:r}},it=e=>{let t=tt(e.randomValuePool,e.dealerHand),n=R(e.playerHand,t);return rt({...e,dealerHand:t,outcome:n})},at=e=>{let t=e.mainHand.isBusted&&e.splitHand.isBusted?e.dealerHand:tt(e.randomValuePool,e.dealerHand),n=R(e.mainHand,t),r=R(e.splitHand,t),{payouts:i,multiplier:a,additionalBetAmount:o}=He({hasSplit:!0,mainOutcome:n,splitOutcome:r,insuranceOutcome:e.insuranceOutcome,insuranceStake:nt(e),mainHandDoubledDown:e.mainHandDoubledDown,splitHandDoubledDown:e.splitHandDoubledDown,actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`split-finished`,mainHand:e.mainHand,splitHand:e.splitHand,dealerHand:t,mainOutcome:n,splitOutcome:r,payout:{legs:i},multiplier:a,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:o}};var ot=class extends ze{roundInsuranceStake;constructor(e,t){super(`BLACKJACK`,e),this.roundInsuranceStake=t}get supportedEdgeConfigurations(){return[1]}generateRandomValues(e){return Re.from(e.getRandomIntsWithReplacement({min:0,max:51,count:63}),63)}toExternalState(t){let n=t.phase;switch(n){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 Error(`Cannot convert uninitialised state to external state`);default:e.againstNever(n,`Invalid state received`)}}createGameStore(){let n=t=>{let n=Ue(t,this.roundInsuranceStake);return e.against(t.gt(0)&&n.eq(0),`Insurance stake rounds below the smallest unit this currency supports`),n},i=e=>rt({...e,calculateStake:n}),a=e=>it({...e,calculateStake:n}),o=e=>at({...e,calculateStake:n});return r({context:Qe,on:{START:(n,r)=>{let{state:a}=n;e.against(a.phase!==`uninitialised`,`START action requires a fresh game`);let o=I(r.randomValuePool.takeOne()),s=I(r.randomValuePool.takeOne()),c=I(r.randomValuePool.takeOne()),l=I(r.randomValuePool.takeOne()),u=P.withInitialDeal([o,s]),d=Le.withInitialDeal({upCard:c,holeCard:l}),f={mainBetAmount:t(r.mainBetAmount),pairBonusAmount:t(r.pairBonusAmount),threeCardBonusAmount:t(r.threeCardBonusAmount)},p={pairBonus:t(r.pairBonusAmount).gt(0)?Ye(r.pairBonusAmount,Je(o,s)):null,threeCardBonus:t(r.threeCardBonusAmount).gt(0)?Ze(r.threeCardBonusAmount,Xe(o,s,c)):null},m={type:`START`,mainBetAmount:r.mainBetAmount,pairBonusAmount:r.pairBonusAmount,threeCardBonusAmount:r.threeCardBonusAmount};if(d.upCard.rank===`Ace`)return{state:{...a,isFinished:!1,phase:`awaiting-insurance`,playerHand:u,dealerHand:d,betAmounts:f,sideBetResults:p},config:{},playerArgument:m};let h={playerHand:u,dealerHand:d,randomValuePool:r.randomValuePool,playerArgument:m,betAmounts:f,sideBetResults:p};return u.isBlackjack&&d.isBlackjack?i({...h,outcome:`PUSH`}):u.isBlackjack?i({...h,outcome:`PLAYER_BLACKJACK`}):d.isBlackjack?i({...h,outcome:`LOSE`}):{state:{...a,isFinished:!1,phase:`in-progress`,playerHand:u,dealerHand:d,insuranceOutcome:void 0,betAmounts:f,sideBetResults:p},config:{},playerArgument:m}},BLACKJACK_BUY_INSURANCE:(e,t)=>{let{state:r}=e;et(r);let{playerHand:a,dealerHand:o,betAmounts:s,sideBetResults:c}=r,l={...r,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},betAmounts:s,sideBetResults:c};return a.isBlackjack&&o.isBlackjack?i({...l,outcome:`PUSH`,insuranceOutcome:`WON`}):a.isBlackjack?i({...l,outcome:`PLAYER_BLACKJACK`,insuranceOutcome:`LOST`}):o.isBlackjack?i({...l,outcome:`LOSE`,insuranceOutcome:`WON`}):{state:{...r,phase:`in-progress`,insuranceOutcome:`LOST`},config:{},playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},additionalBetAmount:n(s.mainBetAmount)}},BLACKJACK_REJECT_INSURANCE:(e,t)=>{let{state:n}=e;et(n);let{playerHand:r,dealerHand:a,betAmounts:o,sideBetResults:s}=n,c={playerHand:r,dealerHand:a,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`},betAmounts:o,sideBetResults:s};return r.isBlackjack&&a.isBlackjack?i({...c,outcome:`PUSH`}):r.isBlackjack?i({...c,outcome:`PLAYER_BLACKJACK`}):a.isBlackjack?i({...c,outcome:`LOSE`}):{state:{...n,phase:`in-progress`,insuranceOutcome:void 0},config:{},playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`}}},BLACKJACK_HIT:(t,n)=>{let{state:r}=t;switch(L(r),r.phase){case`playing-main-hand`:{let e=r.mainHand.addDrawnCards([I(n.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?r.splitHand.highestHandValue===21?o({...r,mainHand:e,splitHandDoubledDown:!1,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...r,phase:`playing-split-hand`,mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_HIT`}}:{state:{...r,mainHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`playing-split-hand`:{let e=r.splitHand.addDrawnCards([I(n.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?o({...r,splitHand:e,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...r,splitHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`in-progress`:{let e=r.playerHand.addDrawnCards([I(n.randomValuePool.takeOne())]);return e.isBusted?i({...r,playerHand:e,outcome:`LOSE`,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):e.highestHandValue===21?a({...r,playerHand:e,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...r,phase:`in-progress`,playerHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}default:e.againstNever(r,`Invalid phase for HIT action`)}},BLACKJACK_STAND:(t,n)=>{let{state:r}=t;switch(L(r),r.phase){case`playing-main-hand`:return r.splitHand.highestHandValue===21?o({...r,splitHandDoubledDown:!1,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}}):{state:{...r,phase:`playing-split-hand`,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_STAND`}};case`playing-split-hand`:return o({...r,splitHandDoubledDown:r.splitHandDoubledDown,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});case`in-progress`:return a({...r,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});default:e.againstNever(r,`Invalid phase for STAND action`)}},BLACKJACK_DOUBLE_DOWN:(t,n)=>{let{state:r}=t;switch(L(r),r.phase){case`playing-main-hand`:{e.against(r.mainHand.cards.length!==2,`Double down is only allowed as the first action`);let t=r.mainHand.addDrawnCards([I(n.randomValuePool.takeOne())]),{betAmounts:i}=r;return r.splitHand.highestHandValue===21?o({...r,mainHand:t,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):{state:{...r,phase:`playing-split-hand`,mainHand:t,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},additionalBetAmount:i.mainBetAmount.mul(1)}}case`playing-split-hand`:{e.against(r.splitHand.cards.length!==2,`Double down is only allowed as the first action`);let t=r.splitHand.addDrawnCards([I(n.randomValuePool.takeOne())]);return o({...r,splitHand:t,randomValuePool:n.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 t=r.playerHand.addDrawnCards([I(n.randomValuePool.takeOne())]);return t.isBusted?i({...r,playerHand:t,outcome:`LOSE`,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):a({...r,playerHand:t,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}})}default:e.againstNever(r,`Invalid phase for DOUBLE_DOWN action`)}},BLACKJACK_SPLIT:(n,r)=>{let{state:i}=n;$e(i);let{playerHand:a,betAmounts:s,sideBetResults:c}=i;e.against(a.cards.length!==2,`Split is only allowed with exactly 2 cards`);let l=a.cards[0],u=a.cards[1];e.againstUndefined(l,`First card is missing`),e.againstUndefined(u,`Second card is missing`),e.against(l.rank!==u.rank,`Split requires two cards of the same rank`);let d=I(r.randomValuePool.takeOne()),f=I(r.randomValuePool.takeOne()),p=P.withInitialDeal([l.value,d]),m=P.withInitialDeal([u.value,f]);if(l.rank===`Ace`)return o({...i,mainHand:p,splitHand:m,randomValuePool:r.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let h=p.highestHandValue===21,g=m.highestHandValue===21;return h&&g?o({mainHand:p,splitHand:m,dealerHand:i.dealerHand,randomValuePool:r.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},insuranceOutcome:i.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:s,sideBetResults:c}):h?{state:{...i,phase:`playing-split-hand`,mainHand:p,splitHand:m,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:s.mainBetAmount.mul(1)}:{state:{...i,phase:`playing-main-hand`,multiplier:t(0),mainHand:p,splitHand:m,mainHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:s.mainBetAmount.mul(1)}}}})}getValidNextActionTypes(t){if(t.isFinished)return[];switch(t.phase){case`awaiting-insurance`:return[`BLACKJACK_BUY_INSURANCE`,`BLACKJACK_REJECT_INSURANCE`];case`playing-main-hand`:{let e=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return t.mainHand.cards.length===2&&e.push(`BLACKJACK_DOUBLE_DOWN`),e}case`playing-split-hand`:{let e=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return t.splitHand.cards.length===2&&e.push(`BLACKJACK_DOUBLE_DOWN`),e}case`player-turn`:{let n=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];if(t.playerHand.cards.length===2){n.push(`BLACKJACK_DOUBLE_DOWN`);let r=t.playerHand.cards[0],i=t.playerHand.cards[1];e.againstUndefined(r,`First player card is missing`),e.againstUndefined(i,`Second player card is missing`),r.rank===i.rank&&n.push(`BLACKJACK_SPLIT`)}return n}default:e.againstNever(t,`Invalid phase for getting valid actions`)}}};const st=0,ct=51,lt=52,ut=52,dt=()=>({minPicks:5,maxPicks:36}),ft=e=>e.length===new Set(e).size,pt=e=>{let n=t(1),r=t(52);for(let i=0;i<e;i+=1)n=n.mul(t(52-i).div(r));return n};var mt=class extends h{constructor(){super(`BLITZ`)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:n,gameInputs:r,edge:i}){e.against(r.pickCount<1||r.pickCount>52,`pickCount must be between 1 and 52`),e.againstNonInteger(r.pickCount,`pickCount must be an integer`);let a=n.getRandomIntsWithReplacement({min:0,max:51,count:52}),o=a.values.slice(0,r.pickCount),s=ft(o),c=pt(r.pickCount),l=s?g.withMultiplier(t(1).div(c),i):t(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(l)}]},payoutMultiplier:l,outputs:{result:a.values,cards:o.map(e=>new T(e).toDto())},randomValues:a}}};const ht=0,gt=4294967295;let _t=function(e){return e.EASY=`EASY`,e.MEDIUM=`MEDIUM`,e.HARD=`HARD`,e.EXPERT=`EXPERT`,e}({});const vt={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:.5,ringTwo:.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:.5},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},yt={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:.4,ringTwo:.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:.4},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},bt={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:.2,ringTwo:.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:.2},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},xt={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:.1,ringTwo:.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:.1},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`]},St=e=>{let t=z[e];return[t.multipliers.bullseye,t.multipliers.ringOne,t.multipliers.ringTwo,...Object.values(t.multipliers.ringThree),t.multipliers.ringFour].reduce((e,t)=>t>e?t:e)},z={EASY:vt,MEDIUM:yt,HARD:bt,EXPERT:xt};var Ct=class extends h{constructor(){super(`DARTS`)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:n,gameInputs:r}){let i=n.getRandomIntsWithReplacement({min:0,max:gt,count:2}),a=i.values[0],o=i.values[1];e.againstUndefined(a,`Random number generator returned no value for clockWiseRotation`),e.againstUndefined(o,`Random number generator returned no value for distanceFromCentre`);let s=r.difficultyLevel,c=t(wt(s,a,o));return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:i.values},randomValues:i}}};const wt=(e,t,n)=>{let r=z[e],{distanceBoundaries:i,multipliers:a}=r;return n<i.bullseye?a.bullseye:n<i.ringOne?a.ringOne:n<i.ringTwo?a.ringTwo:n<i.ringThree?Tt(r,t):a.ringFour},Tt=(t,n)=>{let r=t.segments.length,i=Math.floor(n/4294967296*r),a=t.segments[i];return e.againstUndefined(a,`Segment index ${i} out of bounds`),t.multipliers.ringThree[a]};var B=class{multipliers;constructor(e){this.multipliers=e}getMultipliers(e){let t=this.multipliers.get(e);if(t===void 0)throw Error(`Multipliers for ${e} not found`);return t}getAllMultipliers(){return Array.from(this.multipliers.entries()).map(([e,t])=>({edge:e,multipliers:t}))}};let Et=function(e){return e.PAIR=`PAIR`,e.TWO_PAIR=`TWO_PAIR`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.FULL_HOUSE=`FULL_HOUSE`,e.FOUR_OF_A_KIND=`FOUR_OF_A_KIND`,e.FIVE_OF_A_KIND=`FIVE_OF_A_KIND`,e}({});const Dt=new B(new Map([[1,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50}],[2,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50}],[3,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50}],[4,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50}],[8,{PAIR:.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}]])),Ot={2:`PAIR`,3:`THREE_OF_A_KIND`,4:`FOUR_OF_A_KIND`,5:`FIVE_OF_A_KIND`};var kt=class extends h{constructor(){super(`DIAMONDS`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:n,gameInputs:r}){let i=e.getRandomIntsWithReplacement({min:0,max:6,count:5}),a=Dt.getMultipliers(n),o=i.values,s=t(this.calculatePayoutMultiplier(a,o));return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(s)}]},payoutMultiplier:s,outputs:{result:i.values},randomValues:i}}calculatePayoutMultiplier(e,t){let n=new Map;for(let e of t){let t=n.get(e)||0;n.set(e,t+1)}let r=[...n.values()].filter(e=>e>1),i=this.classifyResult(r);return i===null?0:e[i]}classifyResult(e){if(e.length>2)throw Error(`Unexpected number of repeats ${e.length}`);let[t,n]=e;if(t===void 0)return null;if(n===void 0){let e=Ot[t];if(e===void 0)throw Error(`Unexpected single diamond repeat count: ${t}`);return e}return t===3||n===3?`FULL_HOUSE`:`TWO_PAIR`}};let At=function(e){return e.ABOVE=`ABOVE`,e.BELOW=`BELOW`,e}({});const jt=0,V=1e4,Mt=10001,Nt=e=>{let n=e.direction===`ABOVE`?V-e.selectedValue:e.selectedValue;return new t(n).div(Mt).mul(100)},Pt=(e,t)=>e.direction===`ABOVE`?t>e.selectedValue:t<e.selectedValue;var Ft=class extends h{constructor(){super(`DICE`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:n,gameInputs:r}){let i=e.getRandomInt({min:0,max:V}),a=Nt(r),o=Pt(r,i.value)?g.withWinChance(n,a):new t(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:i.values},randomValues:i}}};let It=function(e){return e.CLASSIC=`CLASSIC`,e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const Lt=[1,2,3,4,5,6,7,8,9,10],Rt=e=>Lt.includes(e),zt={1:{CLASSIC:[0,3.96],LOW_RISK:[.7,1.85],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1e3],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1e3]}},Bt={1:{CLASSIC:[0,3.92],LOW_RISK:[.7,1.82],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1e3],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1e3]}},Vt={1:{CLASSIC:[0,3.88],LOW_RISK:[.7,1.78],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1e3]}},Ht={1:{CLASSIC:[0,3.84],LOW_RISK:[.69,1.77],MEDIUM_RISK:[.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,.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1e3],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1e3]}},Ut={1:{CLASSIC:[0,3.68],LOW_RISK:[.7,1.58],MEDIUM_RISK:[.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1e3]}},Wt=new B(new Map([[1,zt],[2,Bt],[3,Vt],[4,Ht],[8,Ut]]));var Gt=class extends h{constructor(){super(`KENO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:n,edge:r,gameInputs:i}){e.againstEmptyArray(i.selectedNumbers,()=>p.createValidationError(`No numbers selected`)),e.against(i.selectedNumbers.length>10,()=>p.createValidationError(`Maximum of 10 numbers can be selected`));for(let t of i.selectedNumbers)e.againstNonInteger(t,()=>p.createValidationError(`Only integers can be selected`)),e.against(t<0||t>39,()=>p.createValidationError(`Invalid number selected`));let a=n.getUniqueRandomInts({min:0,max:39,count:10}),o=i.selectedNumbers.filter(e=>a.values.includes(e)),s=i.selectedNumbers.length;if(!Rt(s))throw Error(`Invalid tile count: ${s}`);let c=Wt.getMultipliers(r)[s][i.riskLevel][o.length];if(c===void 0)throw Error(`No multiplier found for matching tile count ${o.length}`);let l=new t(c);return{isFinished:!0,payout:{legs:[{amount:i.betAmount.mul(l)}]},payoutMultiplier:l,outputs:{result:a.values},randomValues:a}}};const Kt=(e,t)=>e.gt(t)?e:t,qt=(e,t)=>e.lt(t)?e:t;var Jt=class extends h{constructor(){super(`LIMBO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:n,gameInputs:r}){let i=e.getRandomInt({min:1,max:4294967295}),a=i.max,o=new t(16777216),s=new t(1),c=new t(1e6),l=i.value,u=new t(l-1).div(a),d=(100-n)/100,f=o.div(u.mul(o).plus(1)).mul(d),p=Kt(s,qt(f,c)),m=p.gte(r.targetMultiplier)?new t(r.targetMultiplier):new t(0);return{isFinished:!0,payout:{legs:[{amount:r.betAmount.mul(m)}]},payoutMultiplier:m,outputs:{randomMultiplier:p,result:i.values},randomValues:i}}};const H=(e,t)=>{if(t<0||e<0||t>e)throw Error(`Invalid input: ensure 0 ≤ r ≤ n and n ≥ 0.`);t>e-t&&(t=e-t);let n=1;for(let r=1;r<=t;r++)n=n*(e-r+1)/r;return n};var Yt=class extends h{constructor(){super(`MINES`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:n,gameInputs:r}){if(r.minesCount<=0||r.minesCount>24)throw Error(`Must select between 1 and 24 mines.`);if(r.selectedTiles.length>25-r.minesCount)throw Error(`Cannot select more tiles than available safe tiles (total tiles minus mines).`);let i=e.getUniqueRandomInts({min:1,max:25,count:r.minesCount}),a=i.values.some(e=>r.selectedTiles.includes(e)),o=r.hasCashedOut||a,s=(100-n)/100,c=new t(H(25-r.minesCount,r.selectedTiles.length)).div(new t(H(25,r.selectedTiles.length))),l=r.hasCashedOut&&!a?new t(s).div(c):new t(0);return{isFinished:o,payout:{legs:[{amount:r.betAmount.mul(l)}]},payoutMultiplier:l,outputs:{result:i.values},randomValues:i}}};let Xt=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const Zt=[8,9,10,11,12,13,14,15,16],Qt=new B(new Map([[1,{LOW_RISK:{8:[6,2.1,1.1,1,.5,1,1.1,2.1,6],9:[6,2,1.6,1,.7,.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,.7,.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,.9,.7,.7,.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,.7,.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,.7,.4,.7,1.3,3,13],9:[18,4,1.7,.9,.5,.5,.9,1.7,4,18],10:[22,5,2,1.4,.6,.4,.6,1.4,2,5,22],11:[24,6,3,1.8,.7,.5,.5,.7,1.8,3,6,24],12:[33,11,4,2,1.1,.6,.3,.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,.7,.4,.4,.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,.5,.2,.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,.5,.3,.3,.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,.5,.3,.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,.3,.2,.3,1.5,4,29],9:[43,7,2,.6,.2,.2,.6,2,7,43],10:[76,10,3,.9,.3,.2,.3,.9,3,10,76],11:[120,13.9,5.2,1.4,.4,.2,.2,.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,.7,.2,.2,.2,.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,.2,.2,.2,.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,.3,.2,.2,.2,.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,.5,.2,.2,.2,.2,.5,3,8,27,82.8,620],16:[1e3,129.9,26.1,9,4,2,.2,.2,.2,.2,.2,2,4,9,26.1,129.9,1e3]}}],[2,{LOW_RISK:{8:[6,1.9,1.1,1,.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,.7,.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,.7,.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,.9,.7,.7,.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,.7,.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,.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,.6,.4,.6,1.4,3.2,13],9:[18,3.7,1.7,.9,.5,.5,.9,1.7,3.7,18],10:[22,5,1.9,1.4,.6,.4,.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,.7,.5,.5,.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,.6,.3,.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,.7,.4,.4,.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,.5,.2,.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,.5,.3,.3,.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,.5,.3,.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,.3,.2,.3,1.5,3.8,29],9:[43,7.1,1.9,.6,.2,.2,.6,1.9,7.1,43],10:[76,9.9,2.9,.9,.3,.2,.3,.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,.4,.2,.2,.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,.7,.2,.2,.2,.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,.2,.2,.2,.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,.3,.2,.2,.2,.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,.5,.2,.2,.2,.2,.5,3,7.7,26.8,82.3,620],16:[1e3,129.8,25.2,8.6,4,2,.2,.2,.2,.2,.2,2,4,8.6,25.2,129.8,1e3]}}],[3,{LOW_RISK:{8:[6,2.2,1.1,1,.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,.7,.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,.7,.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,.9,.7,.7,.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,.7,.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,.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,.7,.3,.7,1.2,3.5,13],9:[18,3.8,1.6,.9,.5,.5,.9,1.6,3.8,18],10:[22,5.2,2,1.3,.6,.4,.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,.7,.5,.5,.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,.6,.3,.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,.7,.4,.4,.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,.5,.2,.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,.5,.3,.3,.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,.5,.3,.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,.3,.2,.3,1.4,4,29],9:[43,7.3,2,.5,.2,.2,.5,2,7.3,43],10:[76,9.8,2.8,.9,.3,.2,.3,.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,.4,.2,.2,.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,.7,.2,.2,.2,.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,.2,.2,.2,.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,.3,.2,.2,.2,.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,.5,.2,.2,.2,.2,.5,2.9,7.7,26.6,81.9,620],16:[1e3,130,24.9,8.4,3.9,2,.2,.2,.2,.2,.2,2,3.9,8.4,24.9,130,1e3]}}],[4,{LOW_RISK:{8:[6,2,1.1,1,.4,1,1.1,2,6],9:[6,1.9,1.4,1,.7,.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,.7,.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,.9,.6,.6,.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,.6,.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,.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,.7,.4,.7,1.2,2.9,13],9:[18,3.5,1.6,.9,.5,.5,.9,1.6,3.5,18],10:[22,4.7,2,1.3,.6,.4,.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,.7,.5,.5,.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,.6,.3,.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,.7,.4,.4,.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,.5,.2,.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,.5,.3,.3,.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,.5,.3,.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,.3,.2,.3,1.4,3.9,29],9:[43,6.9,1.8,.6,.2,.2,.6,1.8,6.9,43],10:[76,9.8,2.7,.9,.3,.2,.3,.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,.4,.2,.2,.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,.7,.2,.2,.2,.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,.2,.2,.2,.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,.3,.2,.2,.2,.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,.5,.2,.2,.2,.2,.5,2.8,7.8,26.1,80.6,620],16:[1e3,129.7,24.7,8.2,3.8,2,.2,.2,.2,.2,.2,2,3.8,8.2,24.7,129.7,1e3]}}],[8,{LOW_RISK:{8:[5,1.8,1,1,.4,1,1,1.8,5],9:[5,1.7,1.2,1,.7,.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,.7,.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,.9,.6,.6,.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,.6,.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,.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,.7,.4,.7,1.1,2.6,13],9:[17,3.3,1.4,.9,.5,.5,.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,.6,.4,.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,.7,.5,.5,.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,.6,.2,.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,.7,.4,.4,.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,.5,.2,.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,.5,.3,.3,.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,.5,.3,.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,.3,.2,.3,1.4,3.3,28],9:[42,6.7,1.6,.6,.2,.2,.6,1.6,6.7,42],10:[74,9.6,2.6,.9,.3,.1,.3,.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,.4,.2,.2,.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,.7,.2,.2,.2,.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,.2,.2,.2,.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,.3,.2,.2,.2,.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,.5,.2,.2,.2,.2,.5,2.6,7.4,24.9,76.9,600],16:[1e3,122,24.5,8,3.7,1.8,.2,.2,.2,.2,.2,1.8,3.7,8,24.5,122,1e3]}}]]));var $t=class extends h{constructor(){super(`PLINKO`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:r}){if(t.numberOfRows%1>0)throw Error(`Number of rows must be an integer`);if(t.numberOfRows<8||t.numberOfRows>16)throw Error(`Number of rows must be between 8 and 16`);let i=t.numberOfRows,a=Qt.getMultipliers(r)[t.riskLevel][i],o=e.getRandomIntsWithReplacement({min:0,max:1,count:t.numberOfRows}),s=o.values.reduce((e,t)=>e+t,0),c=a[s];if(c===void 0)throw Error(`No payout found for end position ${s}`);let l=n(c);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(l)}]},payoutMultiplier:l,outputs:{result:o.values},randomValues:o}}};const U=[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],en=[37,...U],tn=[[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]],nn=[[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]],rn=[[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]],an=[[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]],on=[[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]],sn=[[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]],cn=[0,1,2,3,37],ln=[[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]],un=[[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]];let W=function(e){return e.EVEN=`EVEN`,e.ODD=`ODD`,e}({}),G=function(e){return e.RED=`RED`,e.BLACK=`BLACK`,e}({}),K=function(e){return e.LOW=`LOW`,e.HIGH=`HIGH`,e}({}),q=function(e){return e.TOP=`TOP`,e.MIDDLE=`MIDDLE`,e.BOTTOM=`BOTTOM`,e}({}),J=function(e){return e.FIRST=`FIRST`,e.SECOND=`SECOND`,e.THIRD=`THIRD`,e}({}),dn=function(e){return e.AMERICAN=`AMERICAN`,e.EUROPEAN=`EUROPEAN`,e}({});const Y=2.7,X=5.3,fn=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw p.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Z(e.value)))throw p.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&pn(e.values)))throw p.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&mn(e.values)))throw p.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&hn(e.values)))throw p.createValidationError(`Invalid corner bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&gn(e.values)))throw p.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw p.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw p.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw p.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw p.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw p.createValidationError(`Invalid dozen bet.`)},Z=e=>U.includes(e),pn=e=>e.length!==2||!e.every(Z)?!1:tn.some(([t,n])=>t===e[0]&&n===e[1]),mn=e=>e.length!==3||!e.every(Z)?!1:rn.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),hn=e=>e.length!==4||!e.every(Z)?!1:on.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),gn=e=>e.length!==6||!e.every(Z)?!1:ln.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),_n=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.basketBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw p.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Q(e.value)))throw p.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&vn(e.values)))throw p.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&yn(e.values)))throw p.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&bn(e.values)))throw p.createValidationError(`Invalid corner bet.`);if(!e.basketBets.every(e=>e.amount.gte(0)))throw p.createValidationError(`Invalid basket bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&xn(e.values)))throw p.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw p.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw p.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw p.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw p.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw p.createValidationError(`Invalid dozen bet.`)},Q=e=>en.includes(e);function vn(e){return e.length!==2||!e.every(Q)?!1:nn.some(([t,n])=>t===e[0]&&n===e[1])}const yn=e=>e.length!==3||!e.every(Q)?!1:an.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),bn=e=>e.length!==4||!e.every(Q)?!1:sn.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),xn=e=>e.length!==6||!e.every(Q)?!1:un.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),Sn=(e,t)=>{let n=t===2.7&&e.type===`EUROPEAN`,r=t===5.3&&e.type===`AMERICAN`;if(!n&&!r)throw p.createValidationError(`Attempted to play ${e.type} roulette on edge ${t}`)},Cn=(e,t)=>{Sn(e,t),e.type===`EUROPEAN`?fn(e.inputs):_n(e.inputs)},wn={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Tn=[3,6,9,12,15,18,21,24,27,30,33,36],En=[2,5,8,11,14,17,20,23,26,29,32,35],$=[1,4,7,10,13,16,19,22,25,28,31,34],Dn=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],On=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];var kn=class extends h{constructor(){super(`ROULETTE`)}determineGameResult({generator:e,gameInputs:t}){this.validateInputs(t);let n=e.getRandomInt({min:0,max:this.maxNumber}),r=n.value,i=this.determineBetOutcomes(t,r),{payoutMultiplier:a,payout:o}=this.getPayoutDetails(t,r);return{outputs:{betOutcomes:i,result:n.values},payout:o,payoutMultiplier:a,isFinished:!0,randomValues:n}}getBetAmount(e){return this.calculateTotalBetAmount(this.getBetTotals(e))}getPayoutDetails(e,t){let r=this.getBetTotals(e),i=this.calculateTotalBetAmount(r),a={legs:this.calculatePayoutLegs(e,t)},o=E(a);return{payoutMultiplier:i.gt(0)?o.div(i):new n(0),payout:a}}determineBetOutcomes(e,t){let n={},r={};for(let i of Object.keys(e)){let a=e[i],o=this.betPredicates[i],{winning:s,losing:c}=this.partitionBets(a,o,t);n[i]=s,r[i]=c}return{winningBets:n,losingBets:r}}calculateTotalAmount(e){return e.reduce((e,t)=>e.plus(t.amount),new n(0))}isWinningStraightBet(e,t){return e.value===t}isWinningSplitBet(e,t){return e.values.some(e=>e===t)}isWinningStreetBet(e,t){return e.values.some(e=>e===t)}isWinningCornerBet(e,t){return e.values.some(e=>e===t)}isWinningDoubleStreetBet(e,t){return e.values.some(e=>e===t)}isWinningColorBet(e,t){let n=e;return Dn.includes(t)&&n.color===`RED`||On.includes(t)&&n.color===`BLACK`}isWinningHalfBet(e,t){let n=e;return t>0&&t<=18&&n.half===`LOW`||t>18&&t<=36&&n.half===`HIGH`}isWinningColumnBet(e,t){let n=e;return Tn.includes(t)&&n.column===`TOP`||En.includes(t)&&n.column===`MIDDLE`||$.includes(t)&&n.column===`BOTTOM`}isWinningDozenBet(e,t){let n=e;return t>0&&t<=12&&n.dozen===`FIRST`||t>12&&t<=24&&n.dozen===`SECOND`||t>24&&t<=36&&n.dozen===`THIRD`}isWinningParityBet(e,t){let n=e;if(t===0||t===37)return!1;let r=t%2==0?`EVEN`:`ODD`;return n.parity===r}getBetTotals(e){let t={};for(let n of Object.keys(e))t[n]=this.calculateTotalAmount(e[n]);return t}calculateTotalBetAmount(e){return Object.values(e).reduce((e,t)=>e.plus(t),new n(0))}partitionBets(e,t,n){return{winning:e.filter(e=>t(e,n)),losing:e.filter(e=>!t(e,n))}}calculatePayoutLegs(e,t){return Object.keys(e).flatMap(r=>{let i=wn[r],a=this.betPredicates[r];return e[r].map(e=>a(e,t)?{amount:e.amount.mul(i||0)}:{amount:new n(`0`)})})}},An=class extends kn{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[Y]}validateInputs(e){fn(e)}},jn=class extends kn{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(e){_n(e)}isWinningBasketBet(e,t){return cn.some(e=>e===t)}},Mn=class extends h{europeanGame;americanGame;constructor(){super(`ROULETTE`),this.europeanGame=new An,this.americanGame=new jn}get supportedEdgeConfigurations(){return[Y,X]}getBetAmount(e){switch(e.type){case`AMERICAN`:return this.americanGame.getBetAmount(e.inputs);case`EUROPEAN`:return this.europeanGame.getBetAmount(e.inputs);default:throw Error(`Unhandled roulette type`)}}determineGameResult(e){let{gameInputs:t,...n}=e;if(Cn(t,e.edge),t.type===`EUROPEAN`){let e=this.europeanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:r}=e.outputs;return{...e,outputs:{type:`european`,betOutcomes:r,result:e.outputs.result}}}let r=this.americanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:i}=r.outputs;return{...r,outputs:{type:`american`,betOutcomes:i,result:r.outputs.result}}}};const Nn=e=>new Mn().getBetAmount(e);let Pn=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({}),Fn=function(e){return 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`,e}({});const In=new B(new Map([[1,{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}}}],[2,{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}}}],[3,{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}}}],[4,{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}}}],[8,{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}}}]])),Ln={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`.split(`.`),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`.split(`.`),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`.split(`.`)},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`.split(`.`),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`.split(`.`),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`.split(`.`)},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`]}};var Rn=class extends h{constructor(){super(`WHEEL`)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:r}){if(!Object.values(Fn).includes(t.segments))throw Error(`Invalid segments value`);if(!Object.values(Pn).includes(t.riskLevel))throw Error(`Invalid risk level`);let i=In.getMultipliers(r)[t.riskLevel];if(i===void 0)throw Error(`No multipliers found for risk level ${t.riskLevel}`);let a=i[t.segments];if(a===void 0)throw Error(`No multipliers found for segment ${t.segments}`);let o=Ln[t.riskLevel];if(o===void 0)throw Error(`No patterns found for risk level ${t.riskLevel}`);let s=o[t.segments];if(s===void 0)throw Error(`No patterns found for segment ${t.segments}`);let c=e.getRandomInt({min:0,max:s.length-1}),l=s[c.value];if(l===void 0)throw Error(`No pattern found for segment ${t.segments} and value ${c.value}`);let u=a[l];if(u===void 0)throw Error(`No payout found for picked segment ${l}`);let d=new n(u);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(d)}]},payoutMultiplier:d,outputs:{result:c.values},randomValues:c}}};export{Ne as ACE_SOFT_BONUS,cn as AMERICAN_BASKET,X as AMERICAN_HOUSE_EDGE,ce as AdvancedDice,jn as AmericanRoulette,A as BASE_PAYOUT_MULTIPLIERS,O as BLACKJACK_MULTIPLIER,De as BLACKJACK_VALUE,On as BLACK_NUMBERS,lt as BLITZ_CARD_COUNT,ct as BLITZ_MAX_CARD_RANGE,st as BLITZ_MIN_CARD_RANGE,ut as BLITZ_RANDOM_NUMBER_COUNT,$ as BOTTOM_COLUMN,Ee as BUST_VALUE,ge as Baccarat,pe as BaccaratBetType,fe as BaccaratOutcome,ot as Blackjack,ye as BlackjackActionType,_e as BlackjackOutcome,mt as Blitz,Me as CARDS_PER_SUIT,l as CARD_RANKS,c as CARD_SUITS,d as CARD_SUIT_COLORS,s as CARD_VALUES,G as Color,q as Column,z as DARTS_BOARD_CONFIGS,_t as DARTS_DIFFICULTY_LEVEL,gt as DARTS_MAX_VALUE,ht as DARTS_MIN_VALUE,Te as DEALER_STAND_VALUE,Mt as DICE_EFFECTIVE_RANGE,V as DICE_MAX_ROLL,jt as DICE_MIN_ROLL,Ae as DOUBLE_DOWN_BET_SIZE_FACTOR,Ct as Darts,kt as Diamonds,Et as DiamondsResultType,Ft as Dice,At as DiceDirection,J as Dozen,v as EFFECTIVE_RANGE,Y as EUROPEAN_HOUSE_EDGE,An as EuropeanRoulette,u as FACE_CARD_RANKS,Pe as FACE_CARD_VALUE,p as GameError,f as GameErrorCode,K as Half,k as INSURANCE_BET_SIZE_FACTOR,ke as INSURANCE_WIN_MULTIPLIER,ve as InsuranceOutcome,Gt as Keno,It as KenoRiskLevel,we as LOSE_MULTIPLIER,Jt as Limbo,Oe as MAX_CARDS_PER_ROUND,o as MAX_CARD_VALUE,ne as MAX_WIN_CHANCE,En as MIDDLE_COLUMN,a as MIN_CARD_VALUE,te as MIN_WIN_CHANCE,Yt as Mines,ze as MultiActionGame,g as MultiplierCalculator,m as OrigamiGame,j as PAIR_BONUS_PAYOUTS,wn as PAYOUT_MULTIPLIERS,Zt as PLINKO_ROW_COUNTS,Ce as PUSH_MULTIPLIER,be as PairBonusType,W as Parity,$t as Plinko,Xt as PlinkoRiskLevel,_ as RANDOM_MAX_VALUE,ee as RANDOM_MIN_VALUE,Dn as RED_NUMBERS,Re as RandomValuePool,oe as RollType,Mn as Roulette,dn as RouletteType,je as SPLIT_BET_SIZE_FACTOR,h as SingleActionGame,M as THREE_CARD_BONUS_PAYOUTS,Lt as TILE_COUNTS,Tn as TOP_COLUMN,xe as ThreeCardBonusType,sn as VALID_AMERICAN_CORNERS,un as VALID_AMERICAN_DOUBLE_STREETS,nn as VALID_AMERICAN_SPLITS,en as VALID_AMERICAN_STRAIGHTS,an as VALID_AMERICAN_STREETS,on as VALID_EUROPEAN_CORNERS,ln as VALID_EUROPEAN_DOUBLE_STREETS,tn as VALID_EUROPEAN_SPLITS,U as VALID_EUROPEAN_STRAIGHTS,rn as VALID_EUROPEAN_STREETS,ue as VALID_RANKS,le as VALID_SUITS,Se as WIN_MULTIPLIER,Rn as Wheel,Pn as WheelRiskLevel,Fn as WheelSegments,C as advancedDiceGetExclusiveBoundsRange,x as advancedDiceGetInclusiveBoundsRange,S as advancedDiceIsWithinBoundsExclusive,b as advancedDiceIsWithinBoundsInclusive,Kt as bigMax,qt as bigMin,w as calculateAdvancedDiceWinChance,D as calculateBaccaratBetAmount,pt as calculateBlitzWinChance,Nt as calculateDiceWinChance,Ue as calculateInsuranceStake,Nn as calculateRouletteBetAmount,Dt as diamondsMultipliers,dt as getBlitzDefaults,St as getMaxMultiplierForDifficulty,ft as hasBlitzWon,Pt as hasDiceWon,Rt as isTileCount,Wt as kenoMultipliers,H as nCr,Qt as plinkoMultipliers,Ut as rtp92Multipliers,Ht as rtp96Multipliers,Vt as rtp97Multipliers,Bt as rtp98Multipliers,zt as rtp99Multipliers,E as sumPayout,se as validateAdvancedDiceInputs,Cn as validateRouletteGameInputs};
1
+ import{CARD_RANKS as e,CARD_SUIT_COLORS as t,CARD_VALUES as n,Card as r,FACE_CARD_RANKS as i,GameError as a,MAX_CARD_VALUE as o,MIN_CARD_VALUE as s,MultiActionGame as c,MultiplierCalculator as l,MultiplierContainer as u,OrigamiGame as d,RandomValuePool as f,SingleActionGame as p,bigMax as m,bigMin as ee,nCr as te,sumPayout as h}from"@betorigami/game-engine";import g,{Big as _}from"big.js";import{Guard as v}from"@betorigami/guard";import{createStore as ne}from"@xstate/store";export*from"@betorigami/game-engine";const re=0,y=1e4,b=10001,ie=.01,ae=98,oe=e=>{if(e<0)throw a.createValidationError(`Lower bound ${e} is below minimum allowed value 0`)},se=e=>{if(e>1e4)throw a.createValidationError(`Upper bound ${e} is above maximum allowed value ${y}`)},x=e=>{if(oe(e.lower),se(e.upper),e.lower>=e.upper)throw a.createValidationError(`Lower bound ${e.lower} must be less than ${e.upper}`)},ce=(e,t)=>{let[n,r]=e.lower<=t.lower?[e,t]:[t,e];if(n.upper>r.lower)throw a.createValidationError(`Bounds must not overlap`)},le=(e,t)=>t>=e.lower&&t<=e.upper,ue=e=>e.upper-e.lower+1,S=(e,t)=>t>e.lower&&t<e.upper,C=e=>e.upper-e.lower-1;let de=function(e){return e.ROLL_BETWEEN=`ROLL_BETWEEN`,e.ROLL_OUTSIDE=`ROLL_OUTSIDE`,e.ROLL_BETWEEN_TWO=`ROLL_BETWEEN_TWO`,e}({});const w=e=>{let t=(()=>{switch(e.mode){case`ROLL_BETWEEN`:return x(e.bounds),C(e.bounds);case`ROLL_OUTSIDE`:return x(e.bounds),b-ue(e.bounds);case`ROLL_BETWEEN_TWO`:return x(e.firstBounds),x(e.secondBounds),ce(e.firstBounds,e.secondBounds),C(e.firstBounds)+C(e.secondBounds)}})(),n=_(t).div(b).mul(100);if(n.lt(.01))throw a.createValidationError(`Win chance too low`);if(n.gt(98))throw a.createValidationError(`Win chance too high`);return n},fe=e=>{w(e)};var pe=class extends p{constructor(){super(d.ADVANCED_DICE)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=w(n),i=e.getRandomInt({min:0,max:y}),a=i.value,o=(()=>{switch(n.mode){case`ROLL_BETWEEN`:return S(n.bounds,a);case`ROLL_OUTSIDE`:return!le(n.bounds,a);case`ROLL_BETWEEN_TWO`:return S(n.firstBounds,a)||S(n.secondBounds,a)}})()?l.withWinChance(t,r):new _(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:i.values},randomValues:i}}};const me=[`Clubs`,`Diamonds`,`Hearts`,`Spades`],he=[`Ace`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`10`,`Jack`,`Queen`,`King`],ge={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`};let _e=function(e){return e.PLAYER_WIN=`PLAYER_WIN`,e.TIE=`TIE`,e.BANKER_WIN=`BANKER_WIN`,e}({}),ve=function(e){return e.PLAYER=`PLAYER`,e.TIE=`TIE`,e.BANKER=`BANKER`,e}({});const ye={PLAYER_WIN:{betType:`PLAYER`,multiplier:2},TIE:{betType:`TIE`,multiplier:9},BANKER_WIN:{betType:`BANKER`,multiplier:1.95}},T=e=>new g(0).add(e.bets.reduce((e,t)=>e.add(t.amount),new g(0))),be=(e,t)=>e===`TIE`&&(t===`PLAYER`||t===`BANKER`);var xe=class extends p{constructor(){super(d.BACCARAT)}get supportedEdgeConfigurations(){return[1]}getBetAmount(e){return T(e)}determineGameResult({generator:e,gameInputs:t}){this.validateGameInputs(t);let n=e.getRandomIntsWithReplacement({min:0,max:51,count:6}),r=n.values,i=r.slice(0,3),a=r.slice(3,6),o=[],s=0;for(let e of i.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);o.push(t),s=(s+n)%10}let c=[],l=0;for(let e of a.slice(0,2)){let t=this.mapRandomValueToCard(e),n=this.mapRandomValueToCardValue(e);c.push(t),l=(l+n)%10}if(!this.isNaturalWin(s,l)){let e=this.shouldDrawThirdPlayerCard(s),t=null;e&&(t=this.mapRandomValueToCardValue(i[2]),o.push(this.mapRandomValueToCard(i[2])),s=(s+t)%10),this.shouldDrawThirdBankerCard(l,t)&&(c.push(this.mapRandomValueToCard(a[2])),l=(l+this.mapRandomValueToCardValue(a[2]))%10)}let u;u=s===l?`TIE`:s>l?`PLAYER_WIN`:`BANKER_WIN`;let d=T(t),{betType:f,multiplier:p}=ye[u],m={legs:t.bets.map(e=>e.type===f?{amount:e.amount.mul(p)}:{amount:be(u,e.type)?e.amount:new g(`0`)})},ee=h(m);return{isFinished:!0,payout:m,payoutMultiplier:d.gt(0)?ee.div(d):new g(0),outputs:{playerCards:o,playerHandValue:s,bankerCards:c,bankerHandValue:l,gameOutcome:u,result:n.values},randomValues:n}}validateGameInputs(e){if(e.bets.length===0)throw Error(`Must place at least a single bet.`);if(!e.bets.every(e=>e.amount.gte(0)))throw Error(`Invalid bet.`)}mapRandomValueToCard(e){let t=new r(e);return{suit:t.suit,rank:ge[t.rank]}}isNaturalWin(e,t){let n=[8,9];return n.includes(e)||n.includes(t)}mapRandomValueToCardValue(e){let t=e%13;return t===0?1:t>=10?10:t+1}shouldDrawThirdPlayerCard(e){return e<=5}shouldDrawThirdBankerCard(e,t){return t===null?e<=5:e<=2?!0:e===3?t!==8:e===4?[2,3,4,5,6,7].includes(t):e===5?[4,5,6,7].includes(t):e===6&&[6,7].includes(t)}};let Se=function(e){return e.WIN=`WIN`,e.LOSE=`LOSE`,e.PUSH=`PUSH`,e.PLAYER_BLACKJACK=`PLAYER_BLACKJACK`,e}({}),Ce=function(e){return e.WON=`WON`,e.LOST=`LOST`,e}({}),we=function(e){return e.START=`START`,e.HIT=`BLACKJACK_HIT`,e.STAND=`BLACKJACK_STAND`,e.BUY_INSURANCE=`BLACKJACK_BUY_INSURANCE`,e.REJECT_INSURANCE=`BLACKJACK_REJECT_INSURANCE`,e.DOUBLE_DOWN=`BLACKJACK_DOUBLE_DOWN`,e.SPLIT=`BLACKJACK_SPLIT`,e}({}),Te=function(e){return e.EXACT_PAIR=`EXACT_PAIR`,e.COLORED_PAIR=`COLORED_PAIR`,e.MIXED_PAIR=`MIXED_PAIR`,e.LOSS=`LOSS`,e}({}),Ee=function(e){return e.SUITED_TRIPS=`SUITED_TRIPS`,e.STRAIGHT_FLUSH=`STRAIGHT_FLUSH`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.STRAIGHT=`STRAIGHT`,e.FLUSH=`FLUSH`,e.LOSS=`LOSS`,e}({});const E=2.5,De=2,Oe=1,ke=0,Ae=17,je=21,Me=21,Ne=63,D=.5,Pe=3,Fe=1,Ie=1,Le=13,Re=10,ze=10,O={PLAYER_BLACKJACK:E,WIN:2,PUSH:1,LOSE:0},k={EXACT_PAIR:26,COLORED_PAIR:11,MIXED_PAIR:7,LOSS:0},A={SUITED_TRIPS:101,STRAIGHT_FLUSH:51,THREE_OF_A_KIND:31,STRAIGHT:11,FLUSH:5,LOSS:0};var j=class t extends r{get numericRank(){return i.includes(this.rank)?10:e.indexOf(this.rank)+1}static fromValue(e){return v.against(!n.includes(e),`Invalid card value: ${e}`),new t(e)}},M=class{cards;hardHandValue;softHandValue=null;constructor(e){this.cards=e,this.hardHandValue=e.reduce((e,t)=>e+t.numericRank,0),e.some(e=>e.rank===`Ace`)&&this.hardHandValue+10<=21&&(this.softHandValue=this.hardHandValue+10)}get cardCount(){return this.cards.length}get hasSoftHandValue(){return this.softHandValue!==null}get isBusted(){return this.hardHandValue>21}get isBlackjack(){return this.cardCount===2&&this.highestHandValue===21}get highestHandValue(){return this.softHandValue===null?this.hardHandValue:this.softHandValue}},N=class{cards;value;constructor(e){this.cards=e.map(e=>j.fromValue(e)),this.value=new M(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(e=>e.value)}toDto(){return{cards:this.cards.map(e=>e.toDto()),value:this.highestHandValue}}},Be=class e extends N{otherCards;upCard;holeCard;constructor(e,t,n=[]){super([e,t,...n]),this.otherCards=n,this.upCard=j.fromValue(e),this.holeCard=j.fromValue(t)}static withInitialDeal(t){return new e(t.upCard,t.holeCard)}addDrawnCards(t){return new e(this.upCard.value,this.holeCard.value,[...this.otherCards,...t])}toDto(e=!1){return e?super.toDto():{cards:[this.upCard.toDto()],value:new M([this.upCard]).highestHandValue}}},P=class e extends N{static withInitialDeal(t){return new e(t)}addDrawnCards(t){return new e([...this.rawValues,...t])}};const F=e=>[e.pairBonus===null?null:{amount:g(e.pairBonus.betAmount).mul(e.pairBonus.payoutMultiplier)},e.threeCardBonus===null?null:{amount:g(e.threeCardBonus.betAmount).mul(e.threeCardBonus.payoutMultiplier)}].filter(e=>e!==null),Ve=e=>{let t=e.betAmounts.mainBetAmount,n=e.actionType===`BLACKJACK_DOUBLE_DOWN`?t.mul(1):g(0),r=e.insuranceOutcome===void 0?g(0):e.insuranceStake,i=t.plus(n).mul(O[e.outcome]),a=e.insuranceOutcome===`WON`?r.mul(3):g(0),o=F(e.sideBetResults),s=[{amount:i},...e.insuranceOutcome===void 0?[]:[{amount:a}],...o],c=h({legs:s}),l=t.plus(r).plus(n).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);v.against(l.eq(0),`Total bet amount cannot be zero`);let u=c.div(l);v.against(e.actionType===`BLACKJACK_SPLIT`,`SPLIT action type is not valid for standard multiplier calculation`);let d;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:d=n;break;case`BLACKJACK_BUY_INSURANCE`:d=e.insuranceStake;break;case`BLACKJACK_SPLIT`:d=t.mul(1)}return{payouts:s,totalBetAmount:l,multiplier:u,additionalBetAmount:d}},He=e=>{let t=e.betAmounts.mainBetAmount,n=e.mainHandDoubledDown?t.mul(1):g(0),r=e.splitHandDoubledDown?t.mul(1):g(0),i=e.insuranceOutcome===void 0?g(0):e.insuranceStake,a=t.plus(n).mul(O[e.mainOutcome]),o=t.plus(r).mul(O[e.splitOutcome]),s=e.insuranceOutcome===`WON`?i.mul(3):g(0),c=F(e.sideBetResults),l=[{amount:a},{amount:o},...e.insuranceOutcome===void 0?[]:[{amount:s}],...c],u=h({legs:l}),d=t.plus(t).plus(i).plus(n).plus(r).plus(e.betAmounts.pairBonusAmount).plus(e.betAmounts.threeCardBonusAmount);v.against(d.eq(0),`Total bet amount cannot be zero`);let f=u.div(d),p;switch(e.actionType){case`BLACKJACK_DOUBLE_DOWN`:p=t.mul(1);break;case`BLACKJACK_SPLIT`:p=t.mul(1)}return{payouts:l,totalBetAmount:d,multiplier:f,additionalBetAmount:p}},I=(e,t)=>t(e.mul(D)),L=e=>e.every(t=>t===e[0]),Ue=e=>{let t=[...e].sort((e,t)=>e-t);return t.every((e,n)=>{let r=t[n-1];return n===0||(v.againstUndefined(r,`Previous value cannot be undefined`),e===r+1)})},We={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},Ge={...We,Ace:14},Ke=e=>Ue(e.map(e=>We[e]))||Ue(e.map(e=>Ge[e])),qe=(e,n)=>{let r=j.fromValue(e),i=j.fromValue(n);return r.rank===i.rank?e===n?`EXACT_PAIR`:t[r.suit]===t[i.suit]?`COLORED_PAIR`:`MIXED_PAIR`:`LOSS`},Je=(e,t)=>({betAmount:e,result:t,payoutMultiplier:k[t]}),Ye=(e,t,n)=>{let r=j.fromValue(e),i=j.fromValue(t),a=j.fromValue(n),o=[r.rank,i.rank,a.rank],s=L([r.suit,i.suit,a.suit]),c=L(o),l=Ke(o);return L([e,t,n])?`SUITED_TRIPS`:s&&l?`STRAIGHT_FLUSH`:c?`THREE_OF_A_KIND`:l?`STRAIGHT`:s?`FLUSH`:`LOSS`},Xe=(e,t)=>({betAmount:e,result:t,payoutMultiplier:A[t]}),Ze={state:{isFinished:!1,phase:`uninitialised`,multiplier:g(0)},config:{},playerArgument:{type:`START`,mainBetAmount:`0`,pairBonusAmount:`0`,threeCardBonusAmount:`0`}},R=e=>j.fromValue(e).value;function Qe(e){v.against(e.phase!==`in-progress`,`Expected a started, in-progress game state`)}function $e(e){v.against(e.phase!==`awaiting-insurance`,`Expected game to be awaiting insurance decision`)}function z(e){v.against(e.phase!==`in-progress`&&e.phase!==`playing-main-hand`&&e.phase!==`playing-split-hand`,`Expected a started, in-progress game state`)}const et=(e,t)=>{let n=t;for(;n.highestHandValue<17;)n=n.addDrawnCards([R(e.takeOne())]);return n},B=(e,t)=>{if(e.isBusted)return`LOSE`;if(t.isBusted)return`WIN`;let n=e.highestHandValue,r=t.highestHandValue;return n>r?`WIN`:n<r?`LOSE`:`PUSH`},tt=e=>e.insuranceOutcome===void 0?g(0):e.calculateStake(e.betAmounts.mainBetAmount),nt=e=>{let{payouts:t,multiplier:n,additionalBetAmount:r}=Ve({outcome:e.outcome,insuranceOutcome:e.insuranceOutcome,insuranceStake:tt(e),actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`finished`,playerHand:e.playerHand,dealerHand:e.dealerHand,outcome:e.outcome,payout:{legs:t},multiplier:n,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:r}},rt=e=>{let t=et(e.randomValuePool,e.dealerHand),n=B(e.playerHand,t);return nt({...e,dealerHand:t,outcome:n})},it=e=>{let t=e.mainHand.isBusted&&e.splitHand.isBusted?e.dealerHand:et(e.randomValuePool,e.dealerHand),n=B(e.mainHand,t),r=B(e.splitHand,t),{payouts:i,multiplier:a,additionalBetAmount:o}=He({hasSplit:!0,mainOutcome:n,splitOutcome:r,insuranceOutcome:e.insuranceOutcome,insuranceStake:tt(e),mainHandDoubledDown:e.mainHandDoubledDown,splitHandDoubledDown:e.splitHandDoubledDown,actionType:e.playerArgument.type,betAmounts:e.betAmounts,sideBetResults:e.sideBetResults});return{state:{isFinished:!0,phase:`split-finished`,mainHand:e.mainHand,splitHand:e.splitHand,dealerHand:t,mainOutcome:n,splitOutcome:r,payout:{legs:i},multiplier:a,randomValues:e.randomValuePool.consumedValues,insuranceOutcome:e.insuranceOutcome,sideBetResults:e.sideBetResults},config:{},playerArgument:e.playerArgument,additionalBetAmount:o}};var at=class extends c{roundInsuranceStake;constructor(e,t){super(d.BLACKJACK,e),this.roundInsuranceStake=t}get supportedEdgeConfigurations(){return[1]}generateRandomValues(e){return f.from(e.getRandomIntsWithReplacement({min:s,max:o,count:63}),63)}toExternalState(e){let t=e.phase;switch(t){case`awaiting-insurance`:return{isFinished:!1,phase:`awaiting-insurance`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`in-progress`:return{isFinished:!1,phase:`player-turn`,multiplier:e.multiplier,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-main-hand`:return{isFinished:!1,phase:`playing-main-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`playing-split-hand`:return{isFinished:!1,phase:`playing-split-hand`,multiplier:e.multiplier,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!1),sideBetResults:e.sideBetResults};case`finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,outcome:e.outcome,playerHand:e.playerHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`split-finished`:return{isFinished:!0,payout:e.payout,multiplier:e.multiplier,randomValues:e.randomValues,mainOutcome:e.mainOutcome,splitOutcome:e.splitOutcome,mainHand:e.mainHand.toDto(),splitHand:e.splitHand.toDto(),dealerHand:e.dealerHand.toDto(!0),sideBetResults:e.sideBetResults,...e.insuranceOutcome!==void 0&&{insuranceOutcome:e.insuranceOutcome}};case`uninitialised`:throw Error(`Cannot convert uninitialised state to external state`);default:v.againstNever(t,`Invalid state received`)}}createGameStore(){let e=e=>{let t=I(e,this.roundInsuranceStake);return v.against(e.gt(0)&&t.eq(0),`Insurance stake rounds below the smallest unit this currency supports`),t},t=t=>nt({...t,calculateStake:e}),n=t=>rt({...t,calculateStake:e}),r=t=>it({...t,calculateStake:e});return ne({context:Ze,on:{START:(e,n)=>{let{state:r}=e;v.against(r.phase!==`uninitialised`,`START action requires a fresh game`);let i=R(n.randomValuePool.takeOne()),a=R(n.randomValuePool.takeOne()),o=R(n.randomValuePool.takeOne()),s=R(n.randomValuePool.takeOne()),c=P.withInitialDeal([i,a]),l=Be.withInitialDeal({upCard:o,holeCard:s}),u={mainBetAmount:g(n.mainBetAmount),pairBonusAmount:g(n.pairBonusAmount),threeCardBonusAmount:g(n.threeCardBonusAmount)},d={pairBonus:g(n.pairBonusAmount).gt(0)?Je(n.pairBonusAmount,qe(i,a)):null,threeCardBonus:g(n.threeCardBonusAmount).gt(0)?Xe(n.threeCardBonusAmount,Ye(i,a,o)):null},f={type:`START`,mainBetAmount:n.mainBetAmount,pairBonusAmount:n.pairBonusAmount,threeCardBonusAmount:n.threeCardBonusAmount};if(l.upCard.rank===`Ace`)return{state:{...r,isFinished:!1,phase:`awaiting-insurance`,playerHand:c,dealerHand:l,betAmounts:u,sideBetResults:d},config:{},playerArgument:f};let p={playerHand:c,dealerHand:l,randomValuePool:n.randomValuePool,playerArgument:f,betAmounts:u,sideBetResults:d};return c.isBlackjack&&l.isBlackjack?t({...p,outcome:`PUSH`}):c.isBlackjack?t({...p,outcome:`PLAYER_BLACKJACK`}):l.isBlackjack?t({...p,outcome:`LOSE`}):{state:{...r,isFinished:!1,phase:`in-progress`,playerHand:c,dealerHand:l,insuranceOutcome:void 0,betAmounts:u,sideBetResults:d},config:{},playerArgument:f}},BLACKJACK_BUY_INSURANCE:(n,r)=>{let{state:i}=n;$e(i);let{playerHand:a,dealerHand:o,betAmounts:s,sideBetResults:c}=i,l={...i,randomValuePool:r.randomValuePool,playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},betAmounts:s,sideBetResults:c};return a.isBlackjack&&o.isBlackjack?t({...l,outcome:`PUSH`,insuranceOutcome:`WON`}):a.isBlackjack?t({...l,outcome:`PLAYER_BLACKJACK`,insuranceOutcome:`LOST`}):o.isBlackjack?t({...l,outcome:`LOSE`,insuranceOutcome:`WON`}):{state:{...i,phase:`in-progress`,insuranceOutcome:`LOST`},config:{},playerArgument:{type:`BLACKJACK_BUY_INSURANCE`},additionalBetAmount:e(s.mainBetAmount)}},BLACKJACK_REJECT_INSURANCE:(e,n)=>{let{state:r}=e;$e(r);let{playerHand:i,dealerHand:a,betAmounts:o,sideBetResults:s}=r,c={playerHand:i,dealerHand:a,randomValuePool:n.randomValuePool,playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`},betAmounts:o,sideBetResults:s};return i.isBlackjack&&a.isBlackjack?t({...c,outcome:`PUSH`}):i.isBlackjack?t({...c,outcome:`PLAYER_BLACKJACK`}):a.isBlackjack?t({...c,outcome:`LOSE`}):{state:{...r,phase:`in-progress`,insuranceOutcome:void 0},config:{},playerArgument:{type:`BLACKJACK_REJECT_INSURANCE`}}},BLACKJACK_HIT:(e,i)=>{let{state:a}=e;switch(z(a),a.phase){case`playing-main-hand`:{let e=a.mainHand.addDrawnCards([R(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?a.splitHand.highestHandValue===21?r({...a,mainHand:e,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_HIT`}}:{state:{...a,mainHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`playing-split-hand`:{let e=a.splitHand.addDrawnCards([R(i.randomValuePool.takeOne())]);return e.isBusted||e.highestHandValue===21?r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,splitHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}case`in-progress`:{let e=a.playerHand.addDrawnCards([R(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):e.highestHandValue===21?n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_HIT`}}):{state:{...a,phase:`in-progress`,playerHand:e},config:{},playerArgument:{type:`BLACKJACK_HIT`}}}default:v.againstNever(a,`Invalid phase for HIT action`)}},BLACKJACK_STAND:(e,t)=>{let{state:i}=e;switch(z(i),i.phase){case`playing-main-hand`:return i.splitHand.highestHandValue===21?r({...i,splitHandDoubledDown:!1,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}}):{state:{...i,phase:`playing-split-hand`,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_STAND`}};case`playing-split-hand`:return r({...i,splitHandDoubledDown:i.splitHandDoubledDown,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});case`in-progress`:return n({...i,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_STAND`}});default:v.againstNever(i,`Invalid phase for STAND action`)}},BLACKJACK_DOUBLE_DOWN:(e,i)=>{let{state:a}=e;switch(z(a),a.phase){case`playing-main-hand`:{v.against(a.mainHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.mainHand.addDrawnCards([R(i.randomValuePool.takeOne())]),{betAmounts:t}=a;return a.splitHand.highestHandValue===21?r({...a,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):{state:{...a,phase:`playing-split-hand`,mainHand:e,mainHandDoubledDown:!0,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},additionalBetAmount:t.mainBetAmount.mul(1)}}case`playing-split-hand`:{v.against(a.splitHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.splitHand.addDrawnCards([R(i.randomValuePool.takeOne())]);return r({...a,splitHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`},splitHandDoubledDown:!0})}case`in-progress`:{v.against(a.playerHand.cards.length!==2,`Double down is only allowed as the first action`);let e=a.playerHand.addDrawnCards([R(i.randomValuePool.takeOne())]);return e.isBusted?t({...a,playerHand:e,outcome:`LOSE`,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}}):n({...a,playerHand:e,randomValuePool:i.randomValuePool,playerArgument:{type:`BLACKJACK_DOUBLE_DOWN`}})}default:v.againstNever(a,`Invalid phase for DOUBLE_DOWN action`)}},BLACKJACK_SPLIT:(e,t)=>{let{state:n}=e;Qe(n);let{playerHand:i,betAmounts:a,sideBetResults:o}=n;v.against(i.cards.length!==2,`Split is only allowed with exactly 2 cards`);let s=i.cards[0],c=i.cards[1];v.againstUndefined(s,`First card is missing`),v.againstUndefined(c,`Second card is missing`),v.against(s.rank!==c.rank,`Split requires two cards of the same rank`);let l=R(t.randomValuePool.takeOne()),u=R(t.randomValuePool.takeOne()),d=P.withInitialDeal([s.value,l]),f=P.withInitialDeal([c.value,u]);if(s.rank===`Ace`)return r({...n,mainHand:d,splitHand:f,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},mainHandDoubledDown:!1,splitHandDoubledDown:!1});let p=d.highestHandValue===21,m=f.highestHandValue===21;return p&&m?r({mainHand:d,splitHand:f,dealerHand:n.dealerHand,randomValuePool:t.randomValuePool,playerArgument:{type:`BLACKJACK_SPLIT`},insuranceOutcome:n.insuranceOutcome,mainHandDoubledDown:!1,splitHandDoubledDown:!1,betAmounts:a,sideBetResults:o}):p?{state:{...n,phase:`playing-split-hand`,mainHand:d,splitHand:f,mainHandDoubledDown:!1,splitHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}:{state:{...n,phase:`playing-main-hand`,multiplier:g(0),mainHand:d,splitHand:f,mainHandDoubledDown:!1},config:{},playerArgument:{type:`BLACKJACK_SPLIT`},additionalBetAmount:a.mainBetAmount.mul(1)}}}})}getValidNextActionTypes(e){if(e.isFinished)return[];switch(e.phase){case`awaiting-insurance`:return[`BLACKJACK_BUY_INSURANCE`,`BLACKJACK_REJECT_INSURANCE`];case`playing-main-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.mainHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`playing-split-hand`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];return e.splitHand.cards.length===2&&t.push(`BLACKJACK_DOUBLE_DOWN`),t}case`player-turn`:{let t=[`BLACKJACK_HIT`,`BLACKJACK_STAND`];if(e.playerHand.cards.length===2){t.push(`BLACKJACK_DOUBLE_DOWN`);let n=e.playerHand.cards[0],r=e.playerHand.cards[1];v.againstUndefined(n,`First player card is missing`),v.againstUndefined(r,`Second player card is missing`),n.rank===r.rank&&t.push(`BLACKJACK_SPLIT`)}return t}default:v.againstNever(e,`Invalid phase for getting valid actions`)}}};const ot=0,st=51,ct=52,lt=52,ut=()=>({minPicks:5,maxPicks:36}),dt=e=>e.length===new Set(e).size,ft=e=>{let t=g(1),n=g(52);for(let r=0;r<e;r+=1)t=t.mul(g(52-r).div(n));return t};var pt=class extends p{constructor(){super(d.BLITZ)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){v.against(t.pickCount<1||t.pickCount>52,`pickCount must be between 1 and 52`),v.againstNonInteger(t.pickCount,`pickCount must be an integer`);let i=e.getRandomIntsWithReplacement({min:0,max:51,count:52}),a=i.values.slice(0,t.pickCount),o=dt(a),s=ft(t.pickCount),c=o?l.withMultiplier(g(1).div(s),n):g(0);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:i.values,cards:a.map(e=>new r(e).toDto())},randomValues:i}}};const mt=0,ht=4294967295;let gt=function(e){return e.EASY=`EASY`,e.MEDIUM=`MEDIUM`,e.HARD=`HARD`,e.EXPERT=`EXPERT`,e}({});const _t={distanceBoundaries:{bullseye:67108864,ringOne:1299227607,ringTwo:2415919104,ringThree:3478923509},multipliers:{bullseye:8.5,ringOne:.5,ringTwo:.8,ringThree:{YELLOW:1.2,ORANGE:1.5,RED:2.7},ringFour:.5},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},vt={distanceBoundaries:{bullseye:42949673,ringOne:869730878,ringTwo:2104533975,ringThree:2748779069},multipliers:{bullseye:16,ringOne:.4,ringTwo:.6,ringThree:{YELLOW:1.3,ORANGE:3.1,RED:6},ringFour:.4},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},yt={distanceBoundaries:{bullseye:15461883,ringOne:687194768,ringTwo:1870887754,ringThree:2415919104},multipliers:{bullseye:63,ringOne:.2,ringTwo:.5,ringThree:{YELLOW:2.5,ORANGE:3.6,RED:8.8},ringFour:.2},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`,`YELLOW`,`ORANGE`,`YELLOW`,`ORANGE`,`YELLOW`,`RED`]},bt={distanceBoundaries:{bullseye:1717987,ringOne:1073741824,ringTwo:2165093014,ringThree:2415919104},multipliers:{bullseye:500,ringOne:.1,ringTwo:.5,ringThree:{YELLOW:4.8,ORANGE:9.6,RED:42},ringFour:.1},segments:[`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`,`YELLOW`,`RED`,`YELLOW`,`YELLOW`,`ORANGE`,`YELLOW`]},xt=e=>{let t=V[e];return[t.multipliers.bullseye,t.multipliers.ringOne,t.multipliers.ringTwo,...Object.values(t.multipliers.ringThree),t.multipliers.ringFour].reduce((e,t)=>t>e?t:e)},V={EASY:_t,MEDIUM:vt,HARD:yt,EXPERT:bt};var St=class extends p{constructor(){super(d.DARTS)}get supportedEdgeConfigurations(){return[2]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t}){let n=e.getRandomIntsWithReplacement({min:0,max:ht,count:2}),r=n.values[0],i=n.values[1];v.againstUndefined(r,`Random number generator returned no value for clockWiseRotation`),v.againstUndefined(i,`Random number generator returned no value for distanceFromCentre`);let a=t.difficultyLevel,o=g(Ct(a,r,i));return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:n.values},randomValues:n}}};const Ct=(e,t,n)=>{let r=V[e],{distanceBoundaries:i,multipliers:a}=r;return n<i.bullseye?a.bullseye:n<i.ringOne?a.ringOne:n<i.ringTwo?a.ringTwo:n<i.ringThree?wt(r,t):a.ringFour},wt=(e,t)=>{let n=e.segments.length,r=Math.floor(t/4294967296*n),i=e.segments[r];return v.againstUndefined(i,`Segment index ${r} out of bounds`),e.multipliers.ringThree[i]};let Tt=function(e){return e.PAIR=`PAIR`,e.TWO_PAIR=`TWO_PAIR`,e.THREE_OF_A_KIND=`THREE_OF_A_KIND`,e.FULL_HOUSE=`FULL_HOUSE`,e.FOUR_OF_A_KIND=`FOUR_OF_A_KIND`,e.FIVE_OF_A_KIND=`FIVE_OF_A_KIND`,e}({});const Et=new u(new Map([[1,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4.3,FOUR_OF_A_KIND:5,FIVE_OF_A_KIND:50}],[2,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:4,FOUR_OF_A_KIND:4.8,FIVE_OF_A_KIND:50}],[3,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.7,FOUR_OF_A_KIND:4.6,FIVE_OF_A_KIND:50}],[4,{PAIR:.1,TWO_PAIR:2,THREE_OF_A_KIND:3,FULL_HOUSE:3.4,FOUR_OF_A_KIND:4.4,FIVE_OF_A_KIND:50}],[8,{PAIR:.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}]])),Dt={2:`PAIR`,3:`THREE_OF_A_KIND`,4:`FOUR_OF_A_KIND`,5:`FIVE_OF_A_KIND`};var Ot=class extends p{constructor(){super(d.DIAMONDS)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomIntsWithReplacement({min:0,max:6,count:5}),i=Et.getMultipliers(t),a=r.values,o=g(this.calculatePayoutMultiplier(i,a));return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(o)}]},payoutMultiplier:o,outputs:{result:r.values},randomValues:r}}calculatePayoutMultiplier(e,t){let n=new Map;for(let e of t){let t=n.get(e)||0;n.set(e,t+1)}let r=[...n.values()].filter(e=>e>1),i=this.classifyResult(r);return i===null?0:e[i]}classifyResult(e){if(e.length>2)throw Error(`Unexpected number of repeats ${e.length}`);let[t,n]=e;if(t===void 0)return null;if(n===void 0){let e=Dt[t];if(e===void 0)throw Error(`Unexpected single diamond repeat count: ${t}`);return e}return t===3||n===3?`FULL_HOUSE`:`TWO_PAIR`}};let kt=function(e){return e.ABOVE=`ABOVE`,e.BELOW=`BELOW`,e}({});const At=0,H=1e4,jt=10001,Mt=e=>{let t=e.direction===`ABOVE`?H-e.selectedValue:e.selectedValue;return new g(t).div(jt).mul(100)},Nt=(e,t)=>e.direction===`ABOVE`?t>e.selectedValue:t<e.selectedValue;var Pt=class extends p{constructor(){super(d.DICE)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:0,max:H}),i=Mt(n),a=Nt(n,r.value)?l.withWinChance(t,i):new g(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(a)}]},payoutMultiplier:a,outputs:{result:r.values},randomValues:r}}};let Ft=function(e){return e.CLASSIC=`CLASSIC`,e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const It=[1,2,3,4,5,6,7,8,9,10],Lt=e=>It.includes(e),Rt={1:{CLASSIC:[0,3.96],LOW_RISK:[.7,1.85],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,5,15,100,500,1e3],HIGH_RISK:[0,0,0,0,4,11,56,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,4,7,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,8,13,63,500,800,1e3]}},zt={1:{CLASSIC:[0,3.92],LOW_RISK:[.7,1.82],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.5,4.6,15.2,100,500,1e3],HIGH_RISK:[0,0,0,0,4,10.7,55.4,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.8,6.8,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.5,7.8,12.8,63,500,800,1e3]}},Bt={1:{CLASSIC:[0,3.88],LOW_RISK:[.7,1.78],MEDIUM_RISK:[.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.4,4.7,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.9,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.6,2,3.6,6.6,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.9,12.9,62,500,800,1e3]}},Vt={1:{CLASSIC:[0,3.84],LOW_RISK:[.69,1.77],MEDIUM_RISK:[.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,.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,1.97,2.4,4.6,15,97.1,500,1e3],HIGH_RISK:[0,0,0,0,3.8,10.8,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.58,1.98,3.6,6.4,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3.4,7.7,12.7,61.9,500,800,1e3]}},Ht={1:{CLASSIC:[0,3.68],LOW_RISK:[.7,1.58],MEDIUM_RISK:[.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,.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,.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,.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,.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,1e3],MEDIUM_RISK:[0,0,0,2,2.1,4,15,98,500,1e3],HIGH_RISK:[0,0,0,0,3.5,10.5,55,500,800,1e3]},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,1e3],MEDIUM_RISK:[0,0,0,1.5,1.9,3.5,6.2,26,100,500,1e3],HIGH_RISK:[0,0,0,0,3,8,14,57,500,800,1e3]}},Ut=new u(new Map([[1,Rt],[2,zt],[3,Bt],[4,Vt],[8,Ht]]));var Wt=class extends p{constructor(){super(d.KENO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){v.againstEmptyArray(n.selectedNumbers,()=>a.createValidationError(`No numbers selected`)),v.against(n.selectedNumbers.length>10,()=>a.createValidationError(`Maximum of 10 numbers can be selected`));for(let e of n.selectedNumbers)v.againstNonInteger(e,()=>a.createValidationError(`Only integers can be selected`)),v.against(e<0||e>39,()=>a.createValidationError(`Invalid number selected`));let r=e.getUniqueRandomInts({min:0,max:39,count:10}),i=n.selectedNumbers.filter(e=>r.values.includes(e)),o=n.selectedNumbers.length;if(!Lt(o))throw Error(`Invalid tile count: ${o}`);let s=Ut.getMultipliers(t)[o][n.riskLevel][i.length];if(s===void 0)throw Error(`No multiplier found for matching tile count ${i.length}`);let c=new g(s);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:r.values},randomValues:r}}},Gt=class extends p{constructor(){super(d.LIMBO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){let r=e.getRandomInt({min:1,max:4294967295}),i=r.max,a=new g(16777216),o=new g(1),s=new g(1e6),c=r.value,l=new g(c-1).div(i),u=(100-t)/100,d=a.div(l.mul(a).plus(1)).mul(u),f=m(o,ee(d,s)),p=f.gte(n.targetMultiplier)?new g(n.targetMultiplier):new g(0);return{isFinished:!0,payout:{legs:[{amount:n.betAmount.mul(p)}]},payoutMultiplier:p,outputs:{randomMultiplier:f,result:r.values},randomValues:r}}},Kt=class extends p{constructor(){super(d.MINES)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,edge:t,gameInputs:n}){if(n.minesCount<=0||n.minesCount>24)throw Error(`Must select between 1 and 24 mines.`);if(n.selectedTiles.length>25-n.minesCount)throw Error(`Cannot select more tiles than available safe tiles (total tiles minus mines).`);let r=e.getUniqueRandomInts({min:1,max:25,count:n.minesCount}),i=r.values.some(e=>n.selectedTiles.includes(e)),a=n.hasCashedOut||i,o=(100-t)/100,s=new g(te(25-n.minesCount,n.selectedTiles.length)).div(new g(te(25,n.selectedTiles.length))),c=n.hasCashedOut&&!i?new g(o).div(s):new g(0);return{isFinished:a,payout:{legs:[{amount:n.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:r.values},randomValues:r}}};let qt=function(e){return e.LOW_RISK=`LOW_RISK`,e.MEDIUM_RISK=`MEDIUM_RISK`,e.HIGH_RISK=`HIGH_RISK`,e}({});const Jt=[8,9,10,11,12,13,14,15,16],Yt=new u(new Map([[1,{LOW_RISK:{8:[6,2.1,1.1,1,.5,1,1.1,2.1,6],9:[6,2,1.6,1,.7,.7,1,1.6,2,6],10:[9,3,1.4,1.1,1,.5,1,1.1,1.4,3,9],11:[8,3,1.9,1.3,1,.7,.7,1,1.3,1.9,3,8],12:[10,3,1.6,1.4,1.1,1,.5,1,1.1,1.4,1.6,3,10],13:[8,4,3,1.9,1.2,.9,.7,.7,.9,1.2,1.9,3,4,8],14:[7,4,1.9,1.4,1.3,1.1,1,.5,1,1.1,1.3,1.4,1.9,4,7],15:[15,8,3,2,1.5,1.1,1,.7,.7,1,1.1,1.5,2,3,8,15],16:[16,9,2,1.4,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,1.4,2,9,16]},MEDIUM_RISK:{8:[13,3,1.3,.7,.4,.7,1.3,3,13],9:[18,4,1.7,.9,.5,.5,.9,1.7,4,18],10:[22,5,2,1.4,.6,.4,.6,1.4,2,5,22],11:[24,6,3,1.8,.7,.5,.5,.7,1.8,3,6,24],12:[33,11,4,2,1.1,.6,.3,.6,1.1,2,4,11,33],13:[43,13,6,3,1.3,.7,.4,.4,.7,1.3,3,6,13,43],14:[58,15,7,4,1.9,1,.5,.2,.5,1,1.9,4,7,15,58],15:[88,18,11,5,3,1.3,.5,.3,.3,.5,1.3,3,5,11,18,88],16:[110,41.1,10,5,3,1.5,1,.5,.3,.5,1,1.5,3,5,10,41.1,110]},HIGH_RISK:{8:[29,4,1.5,.3,.2,.3,1.5,4,29],9:[43,7,2,.6,.2,.2,.6,2,7,43],10:[76,10,3,.9,.3,.2,.3,.9,3,10,76],11:[120,13.9,5.2,1.4,.4,.2,.2,.4,1.4,5.2,13.9,120],12:[170,23.8,8.1,2,.7,.2,.2,.2,.7,2,8.1,23.8,170],13:[260,36.7,11,4,1,.2,.2,.2,.2,1,4,11,36.7,260],14:[420,56.1,18,5,1.9,.3,.2,.2,.2,.3,1.9,5,18,56.1,420],15:[620,82.8,27,8,3,.5,.2,.2,.2,.2,.5,3,8,27,82.8,620],16:[1e3,129.9,26.1,9,4,2,.2,.2,.2,.2,.2,2,4,9,26.1,129.9,1e3]}}],[2,{LOW_RISK:{8:[6,1.9,1.1,1,.5,1,1.1,1.9,6],9:[6,1.7,1.6,1,.7,.7,1,1.6,1.7,6],10:[9,2.5,1.4,1.1,1,.5,1,1.1,1.4,2.5,9],11:[9,2.5,1.8,1.3,1,.7,.7,1,1.3,1.8,2.5,9],12:[10,3.2,1.6,1.3,1.1,1,.5,1,1.1,1.3,1.6,3.2,10],13:[8,3.7,2.9,1.8,1.2,.9,.7,.7,.9,1.2,1.8,2.9,3.7,8],14:[7,4,1.8,1.2,1.3,1.1,1,.5,1,1.1,1.3,1.2,1.8,4,7],15:[15,7.6,2.8,2,1.4,1.1,1,.7,.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,.5,1,1.1,1.2,1.3,1.2,1.7,9,16]},MEDIUM_RISK:{8:[13,3.2,1.4,.6,.4,.6,1.4,3.2,13],9:[18,3.7,1.7,.9,.5,.5,.9,1.7,3.7,18],10:[22,5,1.9,1.4,.6,.4,.6,1.4,1.9,5,22],11:[24,6,2.8,1.8,.7,.5,.5,.7,1.8,2.8,6,24],12:[33,11.1,4,1.9,1.1,.6,.3,.6,1.1,1.9,4,11.1,33],13:[43,13.7,6.1,2.8,1.3,.7,.4,.4,.7,1.3,2.8,6.1,13.7,43],14:[58,13.7,6.7,3.9,1.9,1,.5,.2,.5,1,1.9,3.9,6.7,13.7,58],15:[88,17.7,10.8,5,2.9,1.3,.5,.3,.3,.5,1.3,2.9,5,10.8,17.7,88],16:[110,40.5,9.8,4.8,2.9,1.5,1,.5,.3,.5,1,1.5,2.9,4.8,9.8,40.5,110]},HIGH_RISK:{8:[29,3.8,1.5,.3,.2,.3,1.5,3.8,29],9:[43,7.1,1.9,.6,.2,.2,.6,1.9,7.1,43],10:[76,9.9,2.9,.9,.3,.2,.3,.9,2.9,9.9,76],11:[120,13.4,5.1,1.4,.4,.2,.2,.4,1.4,5.1,13.4,120],12:[170,23.2,7.9,2,.7,.2,.2,.2,.7,2,7.9,23.2,170],13:[260,36.6,10.5,4,1,.2,.2,.2,.2,1,4,10.5,36.6,260],14:[420,55.5,17.6,4.9,1.9,.3,.2,.2,.2,.3,1.9,4.9,17.6,55.5,420],15:[620,82.3,26.8,7.7,3,.5,.2,.2,.2,.2,.5,3,7.7,26.8,82.3,620],16:[1e3,129.8,25.2,8.6,4,2,.2,.2,.2,.2,.2,2,4,8.6,25.2,129.8,1e3]}}],[3,{LOW_RISK:{8:[6,2.2,1.1,1,.4,1,1.1,2.2,6],9:[6,1.8,1.5,1,.7,.7,1,1.5,1.8,6],10:[9,2.4,1.3,1.1,1,.5,1,1.1,1.3,2.4,9],11:[8,2.7,1.9,1.2,1,.7,.7,1,1.2,1.9,2.7,8],12:[10,3.3,1.6,1.2,1.1,1,.5,1,1.1,1.2,1.6,3.3,10],13:[8,3.8,2.9,1.9,1.1,.9,.7,.7,.9,1.1,1.9,2.9,3.8,8],14:[7,3.9,2,1.4,1.3,1.1,1,.4,1,1.1,1.3,1.4,2,3.9,7],15:[15,7.9,2.5,2,1.3,1.1,1,.7,.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,.4,1,1.1,1.2,1.4,1.4,1.9,8.9,16]},MEDIUM_RISK:{8:[13,3.5,1.2,.7,.3,.7,1.2,3.5,13],9:[18,3.8,1.6,.9,.5,.5,.9,1.6,3.8,18],10:[22,5.2,2,1.3,.6,.4,.6,1.3,2,5.2,22],11:[24,5.6,2.7,1.8,.7,.5,.5,.7,1.8,2.7,5.6,24],12:[33,11.3,4,1.8,1.1,.6,.3,.6,1.1,1.8,4,11.3,33],13:[43,12.9,5.7,2.8,1.3,.7,.4,.4,.7,1.3,2.8,5.7,12.9,43],14:[58,13.7,6.9,3.9,1.8,1,.5,.2,.5,1,1.8,3.9,6.9,13.7,58],15:[88,18,10.9,4.9,2.8,1.3,.5,.3,.3,.5,1.3,2.8,4.9,10.9,18,88],16:[110,39.9,9.9,5,2.9,1.4,1,.5,.3,.5,1,1.4,2.9,5,9.9,39.9,110]},HIGH_RISK:{8:[29,4,1.4,.3,.2,.3,1.4,4,29],9:[43,7.3,2,.5,.2,.2,.5,2,7.3,43],10:[76,9.8,2.8,.9,.3,.2,.3,.9,2.8,9.8,76],11:[120,13.5,4.9,1.4,.4,.2,.2,.4,1.4,4.9,13.5,120],12:[170,23.3,7.9,1.9,.7,.2,.2,.2,.7,1.9,7.9,23.3,170],13:[260,36.2,10.4,3.9,1,.2,.2,.2,.2,1,3.9,10.4,36.2,260],14:[420,54.8,17.9,4.9,1.8,.3,.2,.2,.2,.3,1.8,4.9,17.9,54.8,420],15:[620,81.9,26.6,7.7,2.9,.5,.2,.2,.2,.2,.5,2.9,7.7,26.6,81.9,620],16:[1e3,130,24.9,8.4,3.9,2,.2,.2,.2,.2,.2,2,3.9,8.4,24.9,130,1e3]}}],[4,{LOW_RISK:{8:[6,2,1.1,1,.4,1,1.1,2,6],9:[6,1.9,1.4,1,.7,.7,1,1.4,1.9,6],10:[9,2.8,1.1,1.1,1,.5,1,1.1,1.1,2.8,9],11:[8,2.7,1.7,1.2,1,.7,.7,1,1.2,1.7,2.7,8],12:[10,2.7,1.4,1.2,1.1,1,.5,1,1.1,1.2,1.4,2.7,10],13:[8,3.5,2.8,1.9,1.3,.9,.6,.6,.9,1.3,1.9,2.8,3.5,8],14:[7,3.3,1.6,1.3,1.3,1.1,1,.4,1,1.1,1.3,1.3,1.6,3.3,7],15:[15,8,2.9,2,1.4,1.2,1,.6,.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,.4,1,1.1,1.2,1.2,1.4,2.2,9.1,16]},MEDIUM_RISK:{8:[13,2.9,1.2,.7,.4,.7,1.2,2.9,13],9:[18,3.5,1.6,.9,.5,.5,.9,1.6,3.5,18],10:[22,4.7,2,1.3,.6,.4,.6,1.3,2,4.7,22],11:[24,5.7,2.5,1.8,.7,.5,.5,.7,1.8,2.5,5.7,24],12:[33,10.7,3.8,1.8,1.1,.6,.3,.6,1.1,1.8,3.8,10.7,33],13:[43,12.6,5.6,2.7,1.3,.7,.4,.4,.7,1.3,2.7,5.6,12.6,43],14:[58,13.7,6.4,3.8,1.8,1,.5,.2,.5,1,1.8,3.8,6.4,13.7,58],15:[88,17.7,10.7,4.9,2.7,1.3,.5,.3,.3,.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,.5,.3,.5,1,1.4,2.8,4.8,9.6,39.7,110]},HIGH_RISK:{8:[29,3.9,1.4,.3,.2,.3,1.4,3.9,29],9:[43,6.9,1.8,.6,.2,.2,.6,1.8,6.9,43],10:[76,9.8,2.7,.9,.3,.2,.3,.9,2.7,9.8,76],11:[120,13.1,5.1,1.3,.4,.2,.2,.4,1.3,5.1,13.1,120],12:[170,22.7,7.7,1.9,.7,.2,.2,.2,.7,1.9,7.7,22.7,170],13:[260,35.9,10.3,3.8,1,.2,.2,.2,.2,1,3.8,10.3,35.9,260],14:[420,54.2,17.5,4.8,1.8,.3,.2,.2,.2,.3,1.8,4.8,17.5,54.2,420],15:[620,80.6,26.1,7.8,2.8,.5,.2,.2,.2,.2,.5,2.8,7.8,26.1,80.6,620],16:[1e3,129.7,24.7,8.2,3.8,2,.2,.2,.2,.2,.2,2,3.8,8.2,24.7,129.7,1e3]}}],[8,{LOW_RISK:{8:[5,1.8,1,1,.4,1,1,1.8,5],9:[5,1.7,1.2,1,.7,.7,1,1.2,1.7,5],10:[9,2.8,1.2,1,1,.4,1,1,1.2,2.8,9],11:[8,2.5,1.6,1,1,.7,.7,1,1,1.6,2.5,8],12:[10,2.5,1.3,1.3,1,1,.4,1,1,1.3,1.3,2.5,10],13:[8,4.1,2.8,1.8,1.1,.9,.6,.6,.9,1.1,1.8,2.8,4.1,8],14:[7,3.3,1.7,1.2,1.2,1,1,.4,1,1,1.2,1.2,1.7,3.3,7],15:[15,7.3,2.9,1.9,1.4,1,1,.6,.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,.3,1,1.1,1,1.3,1.5,2,8.7,16]},MEDIUM_RISK:{8:[13,2.6,1.1,.7,.4,.7,1.1,2.6,13],9:[17,3.3,1.4,.9,.5,.5,.9,1.4,3.3,17],10:[21,4.1,1.7,1.3,.6,.4,.6,1.3,1.7,4.1,21],11:[23,5.6,2.4,1.6,.7,.5,.5,.7,1.6,2.4,5.6,23],12:[32,10.2,3.7,1.7,1.1,.6,.2,.6,1.1,1.7,3.7,10.2,32],13:[42,11.7,5.3,2.5,1.2,.7,.4,.4,.7,1.2,2.5,5.3,11.7,42],14:[56,13.2,5.9,3.6,1.6,1,.5,.2,.5,1,1.6,3.6,5.9,13.2,56],15:[86,17.3,10,4.6,2.6,1.2,.5,.3,.3,.5,1.2,2.6,4.6,10,17.3,86],16:[107,39,9.9,4.5,2.4,1.3,1,.5,.3,.5,1,1.3,2.4,4.5,9.9,39,107]},HIGH_RISK:{8:[28,3.3,1.4,.3,.2,.3,1.4,3.3,28],9:[42,6.7,1.6,.6,.2,.2,.6,1.6,6.7,42],10:[74,9.6,2.6,.9,.3,.1,.3,.9,2.6,9.6,74],11:[116,12.7,4.8,1.2,.4,.2,.2,.4,1.2,4.8,12.7,116],12:[165,20.9,7.2,1.8,.7,.2,.2,.2,.7,1.8,7.2,20.9,165],13:[252,33.9,10.1,3.4,1,.2,.2,.2,.2,1,3.4,10.1,33.9,252],14:[407,51.9,16.3,4.6,1.7,.3,.2,.2,.2,.3,1.7,4.6,16.3,51.9,407],15:[600,76.9,24.9,7.4,2.6,.5,.2,.2,.2,.2,.5,2.6,7.4,24.9,76.9,600],16:[1e3,122,24.5,8,3.7,1.8,.2,.2,.2,.2,.2,1.8,3.7,8,24.5,122,1e3]}}]]));var Xt=class extends p{constructor(){super(d.PLINKO)}get supportedEdgeConfigurations(){return[1,2,3,4,8]}getBetAmount(e){return e.betAmount}determineGameResult({generator:e,gameInputs:t,edge:n}){if(t.numberOfRows%1>0)throw Error(`Number of rows must be an integer`);if(t.numberOfRows<8||t.numberOfRows>16)throw Error(`Number of rows must be between 8 and 16`);let r=t.numberOfRows,i=Yt.getMultipliers(n)[t.riskLevel][r],a=e.getRandomIntsWithReplacement({min:0,max:1,count:t.numberOfRows}),o=a.values.reduce((e,t)=>e+t,0),s=i[o];if(s===void 0)throw Error(`No payout found for end position ${o}`);let c=_(s);return{isFinished:!0,payout:{legs:[{amount:t.betAmount.mul(c)}]},payoutMultiplier:c,outputs:{result:a.values},randomValues:a}}};const U=[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],Zt=[37,...U],Qt=[[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]],$t=[[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]],en=[[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]],tn=[[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]],nn=[[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]],rn=[[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]],an=[0,1,2,3,37],on=[[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]],sn=[[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]];let W=function(e){return e.EVEN=`EVEN`,e.ODD=`ODD`,e}({}),G=function(e){return e.RED=`RED`,e.BLACK=`BLACK`,e}({}),K=function(e){return e.LOW=`LOW`,e.HIGH=`HIGH`,e}({}),q=function(e){return e.TOP=`TOP`,e.MIDDLE=`MIDDLE`,e.BOTTOM=`BOTTOM`,e}({}),J=function(e){return e.FIRST=`FIRST`,e.SECOND=`SECOND`,e.THIRD=`THIRD`,e}({}),cn=function(e){return e.AMERICAN=`AMERICAN`,e.EUROPEAN=`EUROPEAN`,e}({});const Y=2.7,X=5.3,ln=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw a.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Z(e.value)))throw a.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&un(e.values)))throw a.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&dn(e.values)))throw a.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&fn(e.values)))throw a.createValidationError(`Invalid corner bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&pn(e.values)))throw a.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw a.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw a.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw a.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw a.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw a.createValidationError(`Invalid dozen bet.`)},Z=e=>U.includes(e),un=e=>e.length!==2||!e.every(Z)?!1:Qt.some(([t,n])=>t===e[0]&&n===e[1]),dn=e=>e.length!==3||!e.every(Z)?!1:en.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),fn=e=>e.length!==4||!e.every(Z)?!1:nn.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),pn=e=>e.length!==6||!e.every(Z)?!1:on.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),mn=e=>{if(e.straightBets.length===0&&e.splitBets.length===0&&e.streetBets.length===0&&e.cornerBets.length===0&&e.basketBets.length===0&&e.doubleStreetBets.length===0&&e.parityBets.length===0&&e.colorBets.length===0&&e.halfBets.length===0&&e.columnBets.length===0&&e.dozenBets.length===0)throw a.createValidationError(`Must place at least a single bet.`);if(!e.straightBets.every(e=>e.amount.gte(0)&&Q(e.value)))throw a.createValidationError(`Invalid straight bet.`);if(!e.splitBets.every(e=>e.amount.gte(0)&&hn(e.values)))throw a.createValidationError(`Invalid split bet.`);if(!e.streetBets.every(e=>e.amount.gte(0)&&gn(e.values)))throw a.createValidationError(`Invalid street bet.`);if(!e.cornerBets.every(e=>e.amount.gte(0)&&_n(e.values)))throw a.createValidationError(`Invalid corner bet.`);if(!e.basketBets.every(e=>e.amount.gte(0)))throw a.createValidationError(`Invalid basket bet.`);if(!e.doubleStreetBets.every(e=>e.amount.gte(0)&&vn(e.values)))throw a.createValidationError(`Invalid double street bet.`);if(!e.parityBets.every(e=>e.amount.gte(0)&&Object.values(W).includes(e.parity)))throw a.createValidationError(`Invalid parity bet.`);if(!e.colorBets.every(e=>e.amount.gte(0)&&Object.values(G).includes(e.color)))throw a.createValidationError(`Invalid color bet.`);if(!e.halfBets.every(e=>e.amount.gte(0)&&Object.values(K).includes(e.half)))throw a.createValidationError(`Invalid half bet.`);if(!e.columnBets.every(e=>e.amount.gte(0)&&Object.values(q).includes(e.column)))throw a.createValidationError(`Invalid column bet.`);if(!e.dozenBets.every(e=>e.amount.gte(0)&&Object.values(J).includes(e.dozen)))throw a.createValidationError(`Invalid dozen bet.`)},Q=e=>Zt.includes(e);function hn(e){return e.length!==2||!e.every(Q)?!1:$t.some(([t,n])=>t===e[0]&&n===e[1])}const gn=e=>e.length!==3||!e.every(Q)?!1:tn.some(([t,n,r])=>t===e[0]&&n===e[1]&&r===e[2]),_n=e=>e.length!==4||!e.every(Q)?!1:rn.some(([t,n,r,i])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]),vn=e=>e.length!==6||!e.every(Q)?!1:sn.some(([t,n,r,i,a,o])=>t===e[0]&&n===e[1]&&r===e[2]&&i===e[3]&&a===e[4]&&o===e[5]),yn=(e,t)=>{let n=t===2.7&&e.type===`EUROPEAN`,r=t===5.3&&e.type===`AMERICAN`;if(!n&&!r)throw a.createValidationError(`Attempted to play ${e.type} roulette on edge ${t}`)},bn=(e,t)=>{yn(e,t),e.type===`EUROPEAN`?ln(e.inputs):mn(e.inputs)},xn={straightBets:36,splitBets:18,streetBets:12,cornerBets:9,basketBets:7,doubleStreetBets:6,parityBets:2,colorBets:2,halfBets:2,columnBets:3,dozenBets:3},Sn=[3,6,9,12,15,18,21,24,27,30,33,36],Cn=[2,5,8,11,14,17,20,23,26,29,32,35],wn=[1,4,7,10,13,16,19,22,25,28,31,34],Tn=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],En=[2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35];var Dn=class extends p{constructor(){super(d.ROULETTE)}determineGameResult({generator:e,gameInputs:t}){this.validateInputs(t);let n=e.getRandomInt({min:0,max:this.maxNumber}),r=n.value,i=this.determineBetOutcomes(t,r),{payoutMultiplier:a,payout:o}=this.getPayoutDetails(t,r);return{outputs:{betOutcomes:i,result:n.values},payout:o,payoutMultiplier:a,isFinished:!0,randomValues:n}}getBetAmount(e){return this.calculateTotalBetAmount(this.getBetTotals(e))}getPayoutDetails(e,t){let n=this.getBetTotals(e),r=this.calculateTotalBetAmount(n),i={legs:this.calculatePayoutLegs(e,t)},a=h(i);return{payoutMultiplier:r.gt(0)?a.div(r):new _(0),payout:i}}determineBetOutcomes(e,t){let n={},r={};for(let i of Object.keys(e)){let a=e[i],o=this.betPredicates[i],{winning:s,losing:c}=this.partitionBets(a,o,t);n[i]=s,r[i]=c}return{winningBets:n,losingBets:r}}calculateTotalAmount(e){return e.reduce((e,t)=>e.plus(t.amount),new _(0))}isWinningStraightBet(e,t){return e.value===t}isWinningSplitBet(e,t){return e.values.some(e=>e===t)}isWinningStreetBet(e,t){return e.values.some(e=>e===t)}isWinningCornerBet(e,t){return e.values.some(e=>e===t)}isWinningDoubleStreetBet(e,t){return e.values.some(e=>e===t)}isWinningColorBet(e,t){let n=e;return Tn.includes(t)&&n.color===`RED`||En.includes(t)&&n.color===`BLACK`}isWinningHalfBet(e,t){let n=e;return t>0&&t<=18&&n.half===`LOW`||t>18&&t<=36&&n.half===`HIGH`}isWinningColumnBet(e,t){let n=e;return Sn.includes(t)&&n.column===`TOP`||Cn.includes(t)&&n.column===`MIDDLE`||wn.includes(t)&&n.column===`BOTTOM`}isWinningDozenBet(e,t){let n=e;return t>0&&t<=12&&n.dozen===`FIRST`||t>12&&t<=24&&n.dozen===`SECOND`||t>24&&t<=36&&n.dozen===`THIRD`}isWinningParityBet(e,t){let n=e;if(t===0||t===37)return!1;let r=t%2==0?`EVEN`:`ODD`;return n.parity===r}getBetTotals(e){let t={};for(let n of Object.keys(e))t[n]=this.calculateTotalAmount(e[n]);return t}calculateTotalBetAmount(e){return Object.values(e).reduce((e,t)=>e.plus(t),new _(0))}partitionBets(e,t,n){return{winning:e.filter(e=>t(e,n)),losing:e.filter(e=>!t(e,n))}}calculatePayoutLegs(e,t){return Object.keys(e).flatMap(n=>{let r=xn[n],i=this.betPredicates[n];return e[n].map(e=>i(e,t)?{amount:e.amount.mul(r||0)}:{amount:new _(`0`)})})}},On=class extends Dn{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[Y]}validateInputs(e){ln(e)}},$=class extends Dn{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(e){mn(e)}isWinningBasketBet(e,t){return an.some(e=>e===t)}},kn=class extends p{europeanGame;americanGame;constructor(){super(d.ROULETTE),this.europeanGame=new On,this.americanGame=new $}get supportedEdgeConfigurations(){return[Y,X]}getBetAmount(e){switch(e.type){case`AMERICAN`:return this.americanGame.getBetAmount(e.inputs);case`EUROPEAN`:return this.europeanGame.getBetAmount(e.inputs);default:throw Error(`Unhandled roulette type`)}}determineGameResult(e){let{gameInputs:t,...n}=e;if(bn(t,e.edge),t.type===`EUROPEAN`){let e=this.europeanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:r}=e.outputs;return{...e,outputs:{type:`european`,betOutcomes:r,result:e.outputs.result}}}let r=this.americanGame.determineGameResult({...n,gameInputs:t.inputs}),{betOutcomes:i}=r.outputs;return{...r,outputs:{type:`american`,betOutcomes:i,result:r.outputs.result}}}};const An=e=>new kn().getBetAmount(e);export{Re as ACE_SOFT_BONUS,an as AMERICAN_BASKET,X as AMERICAN_HOUSE_EDGE,pe as AdvancedDice,$ as AmericanRoulette,O as BASE_PAYOUT_MULTIPLIERS,E as BLACKJACK_MULTIPLIER,Me as BLACKJACK_VALUE,En as BLACK_NUMBERS,ct as BLITZ_CARD_COUNT,st as BLITZ_MAX_CARD_RANGE,ot as BLITZ_MIN_CARD_RANGE,lt as BLITZ_RANDOM_NUMBER_COUNT,wn as BOTTOM_COLUMN,je as BUST_VALUE,xe as Baccarat,ve as BaccaratBetType,_e as BaccaratOutcome,at as Blackjack,we as BlackjackActionType,Se as BlackjackOutcome,pt as Blitz,Le as CARDS_PER_SUIT,G as Color,q as Column,V as DARTS_BOARD_CONFIGS,gt as DARTS_DIFFICULTY_LEVEL,ht as DARTS_MAX_VALUE,mt as DARTS_MIN_VALUE,Ae as DEALER_STAND_VALUE,jt as DICE_EFFECTIVE_RANGE,H as DICE_MAX_ROLL,At as DICE_MIN_ROLL,Fe as DOUBLE_DOWN_BET_SIZE_FACTOR,St as Darts,Ot as Diamonds,Tt as DiamondsResultType,Pt as Dice,kt as DiceDirection,J as Dozen,b as EFFECTIVE_RANGE,Y as EUROPEAN_HOUSE_EDGE,On as EuropeanRoulette,ze as FACE_CARD_VALUE,K as Half,D as INSURANCE_BET_SIZE_FACTOR,Pe as INSURANCE_WIN_MULTIPLIER,Ce as InsuranceOutcome,Wt as Keno,Ft as KenoRiskLevel,ke as LOSE_MULTIPLIER,Gt as Limbo,Ne as MAX_CARDS_PER_ROUND,ae as MAX_WIN_CHANCE,Cn as MIDDLE_COLUMN,ie as MIN_WIN_CHANCE,Kt as Mines,k as PAIR_BONUS_PAYOUTS,xn as PAYOUT_MULTIPLIERS,Jt as PLINKO_ROW_COUNTS,Oe as PUSH_MULTIPLIER,Te as PairBonusType,W as Parity,Xt as Plinko,qt as PlinkoRiskLevel,y as RANDOM_MAX_VALUE,re as RANDOM_MIN_VALUE,Tn as RED_NUMBERS,de as RollType,kn as Roulette,cn as RouletteType,Ie as SPLIT_BET_SIZE_FACTOR,A as THREE_CARD_BONUS_PAYOUTS,It as TILE_COUNTS,Sn as TOP_COLUMN,Ee as ThreeCardBonusType,rn as VALID_AMERICAN_CORNERS,sn as VALID_AMERICAN_DOUBLE_STREETS,$t as VALID_AMERICAN_SPLITS,Zt as VALID_AMERICAN_STRAIGHTS,tn as VALID_AMERICAN_STREETS,nn as VALID_EUROPEAN_CORNERS,on as VALID_EUROPEAN_DOUBLE_STREETS,Qt as VALID_EUROPEAN_SPLITS,U as VALID_EUROPEAN_STRAIGHTS,en as VALID_EUROPEAN_STREETS,he as VALID_RANKS,me as VALID_SUITS,De as WIN_MULTIPLIER,C as advancedDiceGetExclusiveBoundsRange,ue as advancedDiceGetInclusiveBoundsRange,S as advancedDiceIsWithinBoundsExclusive,le as advancedDiceIsWithinBoundsInclusive,w as calculateAdvancedDiceWinChance,T as calculateBaccaratBetAmount,ft as calculateBlitzWinChance,Mt as calculateDiceWinChance,I as calculateInsuranceStake,An as calculateRouletteBetAmount,Et as diamondsMultipliers,ut as getBlitzDefaults,xt as getMaxMultiplierForDifficulty,dt as hasBlitzWon,Nt as hasDiceWon,Lt as isTileCount,Ut as kenoMultipliers,Yt as plinkoMultipliers,Ht as rtp92Multipliers,Vt as rtp96Multipliers,Bt as rtp97Multipliers,zt as rtp98Multipliers,Rt as rtp99Multipliers,fe as validateAdvancedDiceInputs,bn as validateRouletteGameInputs};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betorigami/game-calculations",
3
- "version": "9.0.2",
3
+ "version": "10.0.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -29,6 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
+ "@betorigami/game-engine": "1.0.0",
32
33
  "@betorigami/guard": "^2.0.7",
33
34
  "@xstate/store": "^3.16.0",
34
35
  "big.js": "^7.0.1",