@betorigami/games 2.8.1 → 2.8.2

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.d.ts CHANGED
@@ -7502,7 +7502,6 @@ export interface RouletteEndAction {
7502
7502
  result: number[];
7503
7503
  }
7504
7504
  export interface Action {
7505
- id: string;
7506
7505
  data: {
7507
7506
  DICE?: DiceStartAction | EndAction;
7508
7507
  KENO?: KenoStartAction | EndAction;
package/dist/index.mjs CHANGED
@@ -11714,7 +11714,7 @@ var Z6=Object.create;var{getPrototypeOf:O6,defineProperty:N3,getOwnPropertyNames
11714
11714
  .multipliersForSelectedTiles=${this.multipliersForSelectedTiles}
11715
11715
  ></origami-keno-content-bottom>
11716
11716
  </div>
11717
- `}}h([w({type:Array})],Et.prototype,"selectedTiles",void 0),h([w({type:Array})],Et.prototype,"resultTiles",void 0),h([w({type:Boolean})],Et.prototype,"isPlaying",void 0),h([w({type:Boolean})],Et.prototype,"gameOver",void 0),h([w({type:Number})],Et.prototype,"multipliersForSelectedTiles",void 0),h([w({type:Object})],Et.prototype,"payout",void 0),h([w({type:Boolean})],Et.prototype,"gameWinPopupShowing",void 0),h([w({type:Number})],Et.prototype,"multiplier",void 0),h([w({type:String})],Et.prototype,"risk",void 0),h([w({type:String})],Et.prototype,"betAmount",void 0),h([w({type:String})],Et.prototype,"betId",void 0),h([w({type:Boolean})],Et.prototype,"isDesktop",void 0),Et=h([F("origami-keno-content")],Et);var pr=10,js=40;class Wt{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/keno"}async startBet(a){let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify(a)}),i=await e.json();if(e.ok)return{success:!0,data:i};let r="alerts.gameError";switch(i.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}}var B9=10;class S2{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e,riskLevel:i,selectedNumbers:r}=a,n=S2.generateRandomTiles(B9),t=this.calculateMultiplier(r,n,i),o=I(e).mul(t).toFixed(4);return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",gameId:"KENO",currency:a.currency,amount:e,payout:o,afterBalance:"1000",multiplier:t.toString(),tenantUserId:"mock-user",clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),data:{KENO:{selectedNumbers:r,riskLevel:i}},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{id:crypto.randomUUID(),data:{KENO:{result:n}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:o}]}}}static generateRandomTiles(a,e=[]){let i=Array.from({length:js},(r,n)=>n).filter((r)=>!e.includes(r));return[...i].sort(()=>0.5-Math.random()).slice(0,Math.min(a,i.length))}calculateMultiplier(a,e,i){let r=a.filter((l)=>e.includes(l)).length,n=a.length,t=A1.configs(this.edge)[n-1].payout;if(!t)return 0;let o=t[i];if(!o||r>=o.length)return 0;return o[r]||0}}var qs=E`
11717
+ `}}h([w({type:Array})],Et.prototype,"selectedTiles",void 0),h([w({type:Array})],Et.prototype,"resultTiles",void 0),h([w({type:Boolean})],Et.prototype,"isPlaying",void 0),h([w({type:Boolean})],Et.prototype,"gameOver",void 0),h([w({type:Number})],Et.prototype,"multipliersForSelectedTiles",void 0),h([w({type:Object})],Et.prototype,"payout",void 0),h([w({type:Boolean})],Et.prototype,"gameWinPopupShowing",void 0),h([w({type:Number})],Et.prototype,"multiplier",void 0),h([w({type:String})],Et.prototype,"risk",void 0),h([w({type:String})],Et.prototype,"betAmount",void 0),h([w({type:String})],Et.prototype,"betId",void 0),h([w({type:Boolean})],Et.prototype,"isDesktop",void 0),Et=h([F("origami-keno-content")],Et);var pr=10,js=40;class Wt{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/keno"}async startBet(a){let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify(a)}),i=await e.json();if(e.ok)return{success:!0,data:i};let r="alerts.gameError";switch(i.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}}var B9=10;class S2{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e,riskLevel:i,selectedNumbers:r}=a,n=S2.generateRandomTiles(B9),t=this.calculateMultiplier(r,n,i),o=I(e).mul(t).toFixed(4);return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",gameId:"KENO",currency:a.currency,amount:e,payout:o,afterBalance:"1000",multiplier:t.toString(),tenantUserId:"mock-user",clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{data:{KENO:{selectedNumbers:r,riskLevel:i}},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{data:{KENO:{result:n}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:o}]}}}static generateRandomTiles(a,e=[]){let i=Array.from({length:js},(r,n)=>n).filter((r)=>!e.includes(r));return[...i].sort(()=>0.5-Math.random()).slice(0,Math.min(a,i.length))}calculateMultiplier(a,e,i){let r=a.filter((l)=>e.includes(l)).length,n=a.length,t=A1.configs(this.edge)[n-1].payout;if(!t)return 0;let o=t[i];if(!o||r>=o.length)return 0;return o[r]||0}}var qs=E`
11718
11718
  :host {
11719
11719
  height: 100%;
11720
11720
  }
@@ -12185,7 +12185,7 @@ var Z6=Object.create;var{getPrototypeOf:O6,defineProperty:N3,getOwnPropertyNames
12185
12185
  ></origami-game-win-popup>
12186
12186
  `:C}
12187
12187
  </origami-game-layout>
12188
- `}}h([q()],K2.prototype,"minesCount",void 0),h([q()],K2.prototype,"autobetSelectedTiles",void 0),h([q()],K2.prototype,"minesData",void 0),h([q()],K2.prototype,"isLoading",void 0),h([q()],K2.prototype,"isSelectingRandomTile",void 0),h([q()],K2.prototype,"isCheckingForSession",void 0),h([q()],K2.prototype,"loadingTiles",void 0),h([aa("origami-mines-manual")],K2.prototype,"_minesManualEl",void 0),h([aa("origami-mines-auto")],K2.prototype,"_minesAutoEl",void 0),h([pa("manualOrAuto")],K2.prototype,"onManualOrAutoChange",null),h([pa("minesCount")],K2.prototype,"onMinesCountChange",null),h([pa("autobetInProgress")],K2.prototype,"onAutobetChange",null),K2=h([F("origami-mines-game")],K2);class Xt{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/diamonds"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify({currency:a.currency,amount:a.amount,gameInputs:{},meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}catch(e){return{success:!1,error:R("alerts.gameError",a.language)}}}}class Nt{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e}=a,i=7,r=Array.from({length:5},()=>Math.floor(Math.random()*7)),n=zl(this.edge,r),t=I(e).mul(n).toString(),o={id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"diamonds",currency:a.currency,amount:e,payout:t,afterBalance:"1000",multiplier:n.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),data:{DIAMONDS:{}},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{id:crypto.randomUUID(),data:{DIAMONDS:{result:r}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:t}]};return await Aa(0),{success:!0,data:o}}}var Cs=E`
12188
+ `}}h([q()],K2.prototype,"minesCount",void 0),h([q()],K2.prototype,"autobetSelectedTiles",void 0),h([q()],K2.prototype,"minesData",void 0),h([q()],K2.prototype,"isLoading",void 0),h([q()],K2.prototype,"isSelectingRandomTile",void 0),h([q()],K2.prototype,"isCheckingForSession",void 0),h([q()],K2.prototype,"loadingTiles",void 0),h([aa("origami-mines-manual")],K2.prototype,"_minesManualEl",void 0),h([aa("origami-mines-auto")],K2.prototype,"_minesAutoEl",void 0),h([pa("manualOrAuto")],K2.prototype,"onManualOrAutoChange",null),h([pa("minesCount")],K2.prototype,"onMinesCountChange",null),h([pa("autobetInProgress")],K2.prototype,"onAutobetChange",null),K2=h([F("origami-mines-game")],K2);class Xt{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/diamonds"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify({currency:a.currency,amount:a.amount,gameInputs:{},meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}catch(e){return{success:!1,error:R("alerts.gameError",a.language)}}}}class Nt{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e}=a,i=7,r=Array.from({length:5},()=>Math.floor(Math.random()*7)),n=zl(this.edge,r),t=I(e).mul(n).toString(),o={id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"diamonds",currency:a.currency,amount:e,payout:t,afterBalance:"1000",multiplier:n.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{data:{DIAMONDS:{}},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{data:{DIAMONDS:{result:r}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:t}]};return await Aa(0),{success:!0,data:o}}}var Cs=E`
12189
12189
  :host {
12190
12190
  width: 100%;
12191
12191
  height: 100%;
@@ -12520,7 +12520,7 @@ var Z6=Object.create;var{getPrototypeOf:O6,defineProperty:N3,getOwnPropertyNames
12520
12520
  .instantReveal=${this.gameData?.instantBetEnabled}
12521
12521
  ></origami-diamonds-content>
12522
12522
  </origami-game-layout>
12523
- `}}h([q()],O2.prototype,"isManualPlaying",void 0),h([q()],O2.prototype,"resultGems",void 0),h([aa("origami-diamonds-manual")],O2.prototype,"_diamondsManualEl",void 0),h([aa("origami-diamonds-auto")],O2.prototype,"_diamondsAutoEl",void 0),O2=h([F("origami-diamonds-game")],O2);class e3{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/wheel"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify({currency:a.currency,amount:a.amount,gameInputs:{riskLevel:a.riskLevel,segments:a.segments},meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}catch(e){return{success:!1,error:R("alerts.gameError",a.language)}}}}class i3{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e,riskLevel:i,segments:r}=a,t=ye(this.edge)[i][r];if(!t)throw new Error(`No multiplier configuration found for ${r} segments at edge ${this.edge}`);let o=Math.floor(Math.random()*r),s=xe(r,i)[o],d=t[s],c=I(d??0),m=I(e).mul(c).toString();return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"wheel",currency:a.currency,amount:e,payout:m,afterBalance:"1000",multiplier:c.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),data:{WHEEL:{riskLevel:a.riskLevel,segments:a.segments}},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{id:crypto.randomUUID(),data:{WHEEL:{result:[o]}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:m}]}}}}var $s=E`
12523
+ `}}h([q()],O2.prototype,"isManualPlaying",void 0),h([q()],O2.prototype,"resultGems",void 0),h([aa("origami-diamonds-manual")],O2.prototype,"_diamondsManualEl",void 0),h([aa("origami-diamonds-auto")],O2.prototype,"_diamondsAutoEl",void 0),O2=h([F("origami-diamonds-game")],O2);class e3{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/wheel"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify({currency:a.currency,amount:a.amount,gameInputs:{riskLevel:a.riskLevel,segments:a.segments},meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}catch(e){return{success:!1,error:R("alerts.gameError",a.language)}}}}class i3{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e,riskLevel:i,segments:r}=a,t=ye(this.edge)[i][r];if(!t)throw new Error(`No multiplier configuration found for ${r} segments at edge ${this.edge}`);let o=Math.floor(Math.random()*r),s=xe(r,i)[o],d=t[s],c=I(d??0),m=I(e).mul(c).toString();return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"wheel",currency:a.currency,amount:e,payout:m,afterBalance:"1000",multiplier:c.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{data:{WHEEL:{riskLevel:a.riskLevel,segments:a.segments}},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{data:{WHEEL:{result:[o]}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:m}]}}}}var $s=E`
12524
12524
  :host {
12525
12525
  width: 100%;
12526
12526
  height: 100%;
@@ -12928,7 +12928,7 @@ var Z6=Object.create;var{getPrototypeOf:O6,defineProperty:N3,getOwnPropertyNames
12928
12928
  .resultSegment=${this.resultSegment}
12929
12929
  ></origami-wheel-layout>
12930
12930
  </origami-game-layout>
12931
- `}}h([q()],j2.prototype,"isManualPlaying",void 0),h([q()],j2.prototype,"history",void 0),h([q()],j2.prototype,"wheelRisk",void 0),h([q()],j2.prototype,"numberOfSegments",void 0),h([q()],j2.prototype,"targetAngle",void 0),h([q()],j2.prototype,"resultSegment",void 0),h([q()],j2.prototype,"isWheelSpinning",void 0),h([aa("origami-wheel-manual")],j2.prototype,"_wheelManualEl",void 0),h([aa("origami-wheel-auto")],j2.prototype,"_wheelAutoEl",void 0),j2=h([F("origami-wheel-game")],j2);class l3{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/plinko"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify({currency:a.currency,amount:a.amount,gameInputs:{riskLevel:a.riskLevel,numberOfRows:a.rowCount},meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}catch(e){return{success:!1,error:R("alerts.gameError",a.language)}}}}class s3{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e,currency:i,riskLevel:r,rowCount:n}=a,t=zn[this.edge][r][n],o=Array.from({length:n},()=>Math.random()<0.5?0:1),l=o.reduce((m,u)=>m+u,0),s=t[l]??0,d=I(e).mul(s).toString();return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"PLINKO",currency:i,amount:e,payout:d,afterBalance:"1000",multiplier:s.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),data:{PLINKO:{riskLevel:r,numberOfRows:n}},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{id:crypto.randomUUID(),data:{PLINKO:{result:o}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:d}]}}}}var Ds=E`
12931
+ `}}h([q()],j2.prototype,"isManualPlaying",void 0),h([q()],j2.prototype,"history",void 0),h([q()],j2.prototype,"wheelRisk",void 0),h([q()],j2.prototype,"numberOfSegments",void 0),h([q()],j2.prototype,"targetAngle",void 0),h([q()],j2.prototype,"resultSegment",void 0),h([q()],j2.prototype,"isWheelSpinning",void 0),h([aa("origami-wheel-manual")],j2.prototype,"_wheelManualEl",void 0),h([aa("origami-wheel-auto")],j2.prototype,"_wheelAutoEl",void 0),j2=h([F("origami-wheel-game")],j2);class l3{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/plinko"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify({currency:a.currency,amount:a.amount,gameInputs:{riskLevel:a.riskLevel,numberOfRows:a.rowCount},meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}catch(e){return{success:!1,error:R("alerts.gameError",a.language)}}}}class s3{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e,currency:i,riskLevel:r,rowCount:n}=a,t=zn[this.edge][r][n],o=Array.from({length:n},()=>Math.random()<0.5?0:1),l=o.reduce((m,u)=>m+u,0),s=t[l]??0,d=I(e).mul(s).toString();return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"PLINKO",currency:i,amount:e,payout:d,afterBalance:"1000",multiplier:s.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{data:{PLINKO:{riskLevel:r,numberOfRows:n}},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{data:{PLINKO:{result:o}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:d}]}}}}var Ds=E`
12932
12932
  :host {
12933
12933
  width: 100%;
12934
12934
  height: 100%;
@@ -13775,7 +13775,7 @@ var Z6=Object.create;var{getPrototypeOf:O6,defineProperty:N3,getOwnPropertyNames
13775
13775
  grid-template-columns: 1fr 1fr;
13776
13776
  gap: 8px;
13777
13777
  }
13778
- `;var ru=(a,e)=>{return Math.floor(Math.random()*(e-a+1))+a};class b3{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e,gameInputs:i}=a,r=ru(mi,Ra),n=D1[i.mode],t,o;if(i.mode==="ROLL_BETWEEN_TWO")t=i.firstBounds,o=i.secondBounds;else t=i.bounds;let{winChancePercent:l,isWin:s}=n.evaluateOutcome(t,o,r),d=I(l).eq(0)?I(0):I(100-this.edge).div(l).round(4),c=s?d:I(0),m=I(e).mul(c).toString();return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",gameId:"ADVANCED_DICE",currency:a.currency??wa,amount:e,payout:m,afterBalance:"1000",multiplier:c.toString(),tenantUserId:"mock-user",clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),data:{ADVANCED_DICE:i},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{id:crypto.randomUUID(),data:{ADVANCED_DICE:{result:[r]}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:m}]}}}}class z3{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/advanced-dice"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify({currency:a.currency,amount:a.amount,gameInputs:a.gameInputs,meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}catch(e){return{success:!1,error:R("alerts.gameError",a.language)}}}}class _e extends xa{static styles=[...xa.styles,a6];get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}static ROLL_TYPE_ORDER=["ROLL_BETWEEN","ROLL_OUTSIDE","ROLL_BETWEEN_TWO"];constructor(){super();this.isManualPlaying=!1;this.showDice=!1;this.isWin=!0;this.resultValue=null;this.history=[];this.rollType="ROLL_BETWEEN";this.bounds={lower:2500,upper:7500};this.secondBounds={lower:6250,upper:8750};this._multiplierInputValid=!0;this._winChanceInputValid=!0;this._boundsInputValid=!0;new qa(this,[{key:" ",callback:()=>ba.clickBetButton(this.manualOrAuto,this._diceManualEl,this._diceAutoEl),options:{repeat:!0,repeatInterval:200,disabled:()=>{if(!this.gameData?.hotkeysOpenEnabled)return!0;return ba.isBetButtonDisabled(this.manualOrAuto,this._diceManualEl,this._diceAutoEl)}}},{key:"q",callback:l1(()=>this.gameData,this.cycleRollType.bind(this)),options:{disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}}])}cycleRollType(){let e=(_e.ROLL_TYPE_ORDER.indexOf(this.rollType)+1)%_e.ROLL_TYPE_ORDER.length;this.handleRollTypeChange(_e.ROLL_TYPE_ORDER[e])}get advancedDiceApi(){return this.isDemoMode?new b3(this.gameData.edge):new z3(this.gameData.authToken,this.gameData.baseUrl)}buildGameInputs(){switch(this.rollType){case"ROLL_BETWEEN":return{mode:"ROLL_BETWEEN",bounds:this.bounds};case"ROLL_OUTSIDE":return{mode:"ROLL_OUTSIDE",bounds:this.bounds};case"ROLL_BETWEEN_TWO":return{mode:"ROLL_BETWEEN_TWO",firstBounds:this.bounds,secondBounds:this.secondBounds}}}calculateWinChance(){return D1[this.rollType].calculateWinChance(this.bounds,this.secondBounds)}calculateMultiplier(){let a=this.calculateWinChance();return ka.calculateMultiplier(a,this.gameData.edge)}isValidWinChance(){let a=this.calculateWinChance(),e=ka.getMaxWinChance(this.gameData.edge,this.gameData.advancedDiceMinMultiplier);return a>=u1&&a<=e}async dicePlay(){this.isManualPlaying=!0,this.showDice=!1,await this.handleBetExecution(this.gameData.betAmount),this.isManualPlaying=!1}async handleBetExecution(a,e){if(!this.gameData.currency)throw new Error(R("alerts.gameError",this.gameData?.language||W));let i=this.buildGameInputs(),r={language:this.gameData.language,amount:a,currency:this.gameData.currency,gameInputs:i,meta:e?Ba(e):void 0},n;if(this.isDemoMode&&I(this.gameData.balance).lt(r.amount))n={success:!1,error:R("alerts.insufficientBalance",this.gameData?.language||"en")};else n=await this.advancedDiceApi.startBet(r);if(n.success){if(!this.gameData.instantBetEnabled)this.gameData.soundEffects?.play(da.diceRoll());let t=this.isDemoMode?I(this.gameData.balance).minus(n.data.amount??0).plus(n.data.payout??0):I(n.data.afterBalance??0);this.gameData.updateBalance(t),this.showDice=!0;let{betActions:o}=n.data,l=o[o.length-1];if(!l)throw new Error("No action data received");let{result:s}=l.data.ADVANCED_DICE,d=s[0];if(this.resultValue=d,this.isWin=I(n.data.multiplier??0).gt(1),this.isWin)setTimeout(()=>{this.playWinFeedback()},300);this.addToHistory(d/100,this.isWin,n.data.id??""),this.updateHistoryWithBet(n.data)}else if(!e)this.showError(n.error);return n}addToHistory(a,e,i){this.history=[...this.history,{multiplier:a,won:e,id:i}].slice(-5)}async executeAutobet(a,e){let i=await this.handleBetExecution(e,a);if(!i.success)return{pnl:I(0),gameOutcome:"Draw",hasError:!0,errorMessage:i.error||R("alerts.gameError",this.gameData?.language||W)};let r=i.data,n=I(r.payout??0).minus(r.amount??0),t=Ga(Number(r.multiplier));return await this.ensureMinimumDisplayTime(this.isWin,300,300),{pnl:n,gameOutcome:t,hasError:!1}}handleRollTypeChange(a){this.rollType=a;let e=Jl[a];if(e.bounds)this.bounds={...e.bounds};if(e.firstBounds)this.bounds={...e.firstBounds};if(e.secondBounds)this.secondBounds={...e.secondBounds}}handleBoundsChange(a){if(this.bounds=a.detail.bounds,a.detail.secondBounds)this.secondBounds=a.detail.secondBounds}handleMultiplierInputChange(a){this._multiplierInputValid=ka.isValidMultiplier(a.detail.multiplier,this.gameData.edge,this.gameData.advancedDiceMinMultiplier)}handleWinChanceInputChange(a){this._winChanceInputValid=ka.isValidWinChance(a.detail.winChance,this.gameData.edge,this.gameData.advancedDiceMinMultiplier)}handleBoundsInputValidityChange(a){this._boundsInputValid=a.detail.isValid}render(){let a=this.calculateMultiplier(),e=I(a).mul(this.gameData.betAmount).minus(this.gameData.betAmount).toFixed(4),i=!this._multiplierInputValid||!this._winChanceInputValid||!this._boundsInputValid||!this.isValidWinChance(),r=Va(this.gameData),n=this.gameData.mainWidth>=768;return x`
13778
+ `;var ru=(a,e)=>{return Math.floor(Math.random()*(e-a+1))+a};class b3{edge;constructor(a){this.edge=a}async startBet(a){let{amount:e,gameInputs:i}=a,r=ru(mi,Ra),n=D1[i.mode],t,o;if(i.mode==="ROLL_BETWEEN_TWO")t=i.firstBounds,o=i.secondBounds;else t=i.bounds;let{winChancePercent:l,isWin:s}=n.evaluateOutcome(t,o,r),d=I(l).eq(0)?I(0):I(100-this.edge).div(l).round(4),c=s?d:I(0),m=I(e).mul(c).toString();return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",gameId:"ADVANCED_DICE",currency:a.currency??wa,amount:e,payout:m,afterBalance:"1000",multiplier:c.toString(),tenantUserId:"mock-user",clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{data:{ADVANCED_DICE:i},type:"START_BET",actionIndex:0,betAmount:e,payoutAmount:null},{data:{ADVANCED_DICE:{result:[r]}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:m}]}}}}class z3{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/advanced-dice"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify({currency:a.currency,amount:a.amount,gameInputs:a.gameInputs,meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}catch(e){return{success:!1,error:R("alerts.gameError",a.language)}}}}class _e extends xa{static styles=[...xa.styles,a6];get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}static ROLL_TYPE_ORDER=["ROLL_BETWEEN","ROLL_OUTSIDE","ROLL_BETWEEN_TWO"];constructor(){super();this.isManualPlaying=!1;this.showDice=!1;this.isWin=!0;this.resultValue=null;this.history=[];this.rollType="ROLL_BETWEEN";this.bounds={lower:2500,upper:7500};this.secondBounds={lower:6250,upper:8750};this._multiplierInputValid=!0;this._winChanceInputValid=!0;this._boundsInputValid=!0;new qa(this,[{key:" ",callback:()=>ba.clickBetButton(this.manualOrAuto,this._diceManualEl,this._diceAutoEl),options:{repeat:!0,repeatInterval:200,disabled:()=>{if(!this.gameData?.hotkeysOpenEnabled)return!0;return ba.isBetButtonDisabled(this.manualOrAuto,this._diceManualEl,this._diceAutoEl)}}},{key:"q",callback:l1(()=>this.gameData,this.cycleRollType.bind(this)),options:{disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}}])}cycleRollType(){let e=(_e.ROLL_TYPE_ORDER.indexOf(this.rollType)+1)%_e.ROLL_TYPE_ORDER.length;this.handleRollTypeChange(_e.ROLL_TYPE_ORDER[e])}get advancedDiceApi(){return this.isDemoMode?new b3(this.gameData.edge):new z3(this.gameData.authToken,this.gameData.baseUrl)}buildGameInputs(){switch(this.rollType){case"ROLL_BETWEEN":return{mode:"ROLL_BETWEEN",bounds:this.bounds};case"ROLL_OUTSIDE":return{mode:"ROLL_OUTSIDE",bounds:this.bounds};case"ROLL_BETWEEN_TWO":return{mode:"ROLL_BETWEEN_TWO",firstBounds:this.bounds,secondBounds:this.secondBounds}}}calculateWinChance(){return D1[this.rollType].calculateWinChance(this.bounds,this.secondBounds)}calculateMultiplier(){let a=this.calculateWinChance();return ka.calculateMultiplier(a,this.gameData.edge)}isValidWinChance(){let a=this.calculateWinChance(),e=ka.getMaxWinChance(this.gameData.edge,this.gameData.advancedDiceMinMultiplier);return a>=u1&&a<=e}async dicePlay(){this.isManualPlaying=!0,this.showDice=!1,await this.handleBetExecution(this.gameData.betAmount),this.isManualPlaying=!1}async handleBetExecution(a,e){if(!this.gameData.currency)throw new Error(R("alerts.gameError",this.gameData?.language||W));let i=this.buildGameInputs(),r={language:this.gameData.language,amount:a,currency:this.gameData.currency,gameInputs:i,meta:e?Ba(e):void 0},n;if(this.isDemoMode&&I(this.gameData.balance).lt(r.amount))n={success:!1,error:R("alerts.insufficientBalance",this.gameData?.language||"en")};else n=await this.advancedDiceApi.startBet(r);if(n.success){if(!this.gameData.instantBetEnabled)this.gameData.soundEffects?.play(da.diceRoll());let t=this.isDemoMode?I(this.gameData.balance).minus(n.data.amount??0).plus(n.data.payout??0):I(n.data.afterBalance??0);this.gameData.updateBalance(t),this.showDice=!0;let{betActions:o}=n.data,l=o[o.length-1];if(!l)throw new Error("No action data received");let{result:s}=l.data.ADVANCED_DICE,d=s[0];if(this.resultValue=d,this.isWin=I(n.data.multiplier??0).gt(1),this.isWin)setTimeout(()=>{this.playWinFeedback()},300);this.addToHistory(d/100,this.isWin,n.data.id??""),this.updateHistoryWithBet(n.data)}else if(!e)this.showError(n.error);return n}addToHistory(a,e,i){this.history=[...this.history,{multiplier:a,won:e,id:i}].slice(-5)}async executeAutobet(a,e){let i=await this.handleBetExecution(e,a);if(!i.success)return{pnl:I(0),gameOutcome:"Draw",hasError:!0,errorMessage:i.error||R("alerts.gameError",this.gameData?.language||W)};let r=i.data,n=I(r.payout??0).minus(r.amount??0),t=Ga(Number(r.multiplier));return await this.ensureMinimumDisplayTime(this.isWin,300,300),{pnl:n,gameOutcome:t,hasError:!1}}handleRollTypeChange(a){this.rollType=a;let e=Jl[a];if(e.bounds)this.bounds={...e.bounds};if(e.firstBounds)this.bounds={...e.firstBounds};if(e.secondBounds)this.secondBounds={...e.secondBounds}}handleBoundsChange(a){if(this.bounds=a.detail.bounds,a.detail.secondBounds)this.secondBounds=a.detail.secondBounds}handleMultiplierInputChange(a){this._multiplierInputValid=ka.isValidMultiplier(a.detail.multiplier,this.gameData.edge,this.gameData.advancedDiceMinMultiplier)}handleWinChanceInputChange(a){this._winChanceInputValid=ka.isValidWinChance(a.detail.winChance,this.gameData.edge,this.gameData.advancedDiceMinMultiplier)}handleBoundsInputValidityChange(a){this._boundsInputValid=a.detail.isValid}render(){let a=this.calculateMultiplier(),e=I(a).mul(this.gameData.betAmount).minus(this.gameData.betAmount).toFixed(4),i=!this._multiplierInputValid||!this._winChanceInputValid||!this._boundsInputValid||!this.isValidWinChance(),r=Va(this.gameData),n=this.gameData.mainWidth>=768;return x`
13779
13779
  <origami-game-layout style=${r} .gameType=${"ADVANCED_DICE"} data-is-desktop=${n}>
13780
13780
  <origami-game-sidebar
13781
13781
  data-is-desktop=${n}
@@ -13844,7 +13844,7 @@ var Z6=Object.create;var{getPrototypeOf:O6,defineProperty:N3,getOwnPropertyNames
13844
13844
  @advanced-dice-bounds-input-validity-change=${this.handleBoundsInputValidityChange}
13845
13845
  ></origami-advanced-dice-content>
13846
13846
  </origami-game-layout>
13847
- `}}h([q()],_e.prototype,"isManualPlaying",void 0),h([q()],_e.prototype,"showDice",void 0),h([q()],_e.prototype,"isWin",void 0),h([q()],_e.prototype,"resultValue",void 0),h([q()],_e.prototype,"history",void 0),h([q()],_e.prototype,"rollType",void 0),h([q()],_e.prototype,"bounds",void 0),h([q()],_e.prototype,"secondBounds",void 0),h([q()],_e.prototype,"_multiplierInputValid",void 0),h([q()],_e.prototype,"_winChanceInputValid",void 0),h([q()],_e.prototype,"_boundsInputValid",void 0),h([aa("origami-advanced-dice-manual")],_e.prototype,"_diceManualEl",void 0),h([aa("origami-advanced-dice-auto")],_e.prototype,"_diceAutoEl",void 0),_e=h([F("origami-advanced-dice-game")],_e);class y3{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/roulette"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify({currency:a.currency,gameInputs:a.gameInputs,meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}catch(e){return{success:!1,error:R("alerts.gameError",a.language)}}}}var nu=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],tu=[3,6,9,12,15,18,21,24,27,30,33,36],ou=[2,5,8,11,14,17,20,23,26,29,32,35],lu=[1,4,7,10,13,16,19,22,25,28,31,34],su=[0,1,2,3,37],e6={straightBets:[],splitBets:[],streetBets:[],cornerBets:[],doubleStreetBets:[],parityBets:[],colorBets:[],halfBets:[],columnBets:[],dozenBets:[]};function hu(a,e,i){let r=I(0);for(let n of e.straightBets)if(n.value===a)r=r.plus(I(n.amount).times(36));for(let n of e.splitBets)if(n.values.includes(a))r=r.plus(I(n.amount).times(18));for(let n of e.streetBets)if(n.values.includes(a))r=r.plus(I(n.amount).times(12));for(let n of e.cornerBets)if(n.values.includes(a))r=r.plus(I(n.amount).times(9));for(let n of e.doubleStreetBets)if(n.values.includes(a))r=r.plus(I(n.amount).times(6));if(i&&"basketBets"in e){for(let n of e.basketBets)if(su.includes(a))r=r.plus(I(n.amount).times(7))}if(a>=1&&a<=36){for(let n of e.parityBets){let t=a%2===0;if(n.parity==="EVEN"&&t||n.parity==="ODD"&&!t)r=r.plus(I(n.amount).times(2))}for(let n of e.colorBets){let t=nu.includes(a);if(n.color==="RED"&&t||n.color==="BLACK"&&!t)r=r.plus(I(n.amount).times(2))}for(let n of e.halfBets)if(n.half==="LOW"&&a<=18||n.half==="HIGH"&&a>18)r=r.plus(I(n.amount).times(2));for(let n of e.columnBets)if(n.column==="TOP"&&tu.includes(a)||n.column==="MIDDLE"&&ou.includes(a)||n.column==="BOTTOM"&&lu.includes(a))r=r.plus(I(n.amount).times(3));for(let n of e.dozenBets){let t=a>=1&&a<=12,o=a>=13&&a<=24,l=a>=25&&a<=36;if(n.dozen==="FIRST"&&t||n.dozen==="SECOND"&&o||n.dozen==="THIRD"&&l)r=r.plus(I(n.amount).times(3))}}return r}function uu(a,e){let i=I(0);for(let r of a.straightBets)i=i.plus(r.amount);for(let r of a.splitBets)i=i.plus(r.amount);for(let r of a.streetBets)i=i.plus(r.amount);for(let r of a.cornerBets)i=i.plus(r.amount);for(let r of a.doubleStreetBets)i=i.plus(r.amount);for(let r of a.parityBets)i=i.plus(r.amount);for(let r of a.colorBets)i=i.plus(r.amount);for(let r of a.halfBets)i=i.plus(r.amount);for(let r of a.columnBets)i=i.plus(r.amount);for(let r of a.dozenBets)i=i.plus(r.amount);if(e&&"basketBets"in a)for(let r of a.basketBets)i=i.plus(r.amount);return i}class x3{async startBet(a){let{gameInputs:e,currency:i}=a,r=e.type===ua.AMERICAN,n=r?37:36,t=Math.floor(Math.random()*(n+1)),o=e.inputs,l=uu(o,r),s=hu(t,o,r),d=l.gt(0)?s.div(l):I(0);return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"ROULETTE",currency:i??wa,amount:l.toString(),payout:s.toString(),afterBalance:"1000",multiplier:d.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),data:{ROULETTE:e},type:"START_BET",actionIndex:0,betAmount:l.toString(),payoutAmount:null},{id:crypto.randomUUID(),data:{ROULETTE:{type:r?"american":"european",betOutcomes:{winningBets:e6,losingBets:e6},result:[t]}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:s.toString()}]}}}}var i6=E`
13847
+ `}}h([q()],_e.prototype,"isManualPlaying",void 0),h([q()],_e.prototype,"showDice",void 0),h([q()],_e.prototype,"isWin",void 0),h([q()],_e.prototype,"resultValue",void 0),h([q()],_e.prototype,"history",void 0),h([q()],_e.prototype,"rollType",void 0),h([q()],_e.prototype,"bounds",void 0),h([q()],_e.prototype,"secondBounds",void 0),h([q()],_e.prototype,"_multiplierInputValid",void 0),h([q()],_e.prototype,"_winChanceInputValid",void 0),h([q()],_e.prototype,"_boundsInputValid",void 0),h([aa("origami-advanced-dice-manual")],_e.prototype,"_diceManualEl",void 0),h([aa("origami-advanced-dice-auto")],_e.prototype,"_diceAutoEl",void 0),_e=h([F("origami-advanced-dice-game")],_e);class y3{authToken;baseUrl;constructor(a,e){this.authToken=a,this.baseUrl=e+"/games/roulette"}async startBet(a){try{let e=await fetch(`${this.baseUrl}/play`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.authToken}`,"X-Origami-Trace":ja()},body:JSON.stringify({currency:a.currency,gameInputs:a.gameInputs,meta:a.meta})}),i=await e.json();if(e.ok&&!!i.id)return{success:!0,data:i};let r="alerts.gameError";switch(i?.errorCode){case"INSUFFICIENT_BALANCE":r="alerts.insufficientBalance";break;case"LIMIT_REACHED":r="alerts.betLimitReached";break}return{success:!1,error:R(r,a.language)}}catch(e){return{success:!1,error:R("alerts.gameError",a.language)}}}}var nu=[1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36],tu=[3,6,9,12,15,18,21,24,27,30,33,36],ou=[2,5,8,11,14,17,20,23,26,29,32,35],lu=[1,4,7,10,13,16,19,22,25,28,31,34],su=[0,1,2,3,37],e6={straightBets:[],splitBets:[],streetBets:[],cornerBets:[],doubleStreetBets:[],parityBets:[],colorBets:[],halfBets:[],columnBets:[],dozenBets:[]};function hu(a,e,i){let r=I(0);for(let n of e.straightBets)if(n.value===a)r=r.plus(I(n.amount).times(36));for(let n of e.splitBets)if(n.values.includes(a))r=r.plus(I(n.amount).times(18));for(let n of e.streetBets)if(n.values.includes(a))r=r.plus(I(n.amount).times(12));for(let n of e.cornerBets)if(n.values.includes(a))r=r.plus(I(n.amount).times(9));for(let n of e.doubleStreetBets)if(n.values.includes(a))r=r.plus(I(n.amount).times(6));if(i&&"basketBets"in e){for(let n of e.basketBets)if(su.includes(a))r=r.plus(I(n.amount).times(7))}if(a>=1&&a<=36){for(let n of e.parityBets){let t=a%2===0;if(n.parity==="EVEN"&&t||n.parity==="ODD"&&!t)r=r.plus(I(n.amount).times(2))}for(let n of e.colorBets){let t=nu.includes(a);if(n.color==="RED"&&t||n.color==="BLACK"&&!t)r=r.plus(I(n.amount).times(2))}for(let n of e.halfBets)if(n.half==="LOW"&&a<=18||n.half==="HIGH"&&a>18)r=r.plus(I(n.amount).times(2));for(let n of e.columnBets)if(n.column==="TOP"&&tu.includes(a)||n.column==="MIDDLE"&&ou.includes(a)||n.column==="BOTTOM"&&lu.includes(a))r=r.plus(I(n.amount).times(3));for(let n of e.dozenBets){let t=a>=1&&a<=12,o=a>=13&&a<=24,l=a>=25&&a<=36;if(n.dozen==="FIRST"&&t||n.dozen==="SECOND"&&o||n.dozen==="THIRD"&&l)r=r.plus(I(n.amount).times(3))}}return r}function uu(a,e){let i=I(0);for(let r of a.straightBets)i=i.plus(r.amount);for(let r of a.splitBets)i=i.plus(r.amount);for(let r of a.streetBets)i=i.plus(r.amount);for(let r of a.cornerBets)i=i.plus(r.amount);for(let r of a.doubleStreetBets)i=i.plus(r.amount);for(let r of a.parityBets)i=i.plus(r.amount);for(let r of a.colorBets)i=i.plus(r.amount);for(let r of a.halfBets)i=i.plus(r.amount);for(let r of a.columnBets)i=i.plus(r.amount);for(let r of a.dozenBets)i=i.plus(r.amount);if(e&&"basketBets"in a)for(let r of a.basketBets)i=i.plus(r.amount);return i}class x3{async startBet(a){let{gameInputs:e,currency:i}=a,r=e.type===ua.AMERICAN,n=r?37:36,t=Math.floor(Math.random()*(n+1)),o=e.inputs,l=uu(o,r),s=hu(t,o,r),d=l.gt(0)?s.div(l):I(0);return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"ROULETTE",currency:i??wa,amount:l.toString(),payout:s.toString(),afterBalance:"1000",multiplier:d.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{data:{ROULETTE:e},type:"START_BET",actionIndex:0,betAmount:l.toString(),payoutAmount:null},{data:{ROULETTE:{type:r?"american":"european",betOutcomes:{winningBets:e6,losingBets:e6},result:[t]}},type:"END_BET",actionIndex:1,betAmount:null,payoutAmount:s.toString()}]}}}}var i6=E`
13848
13848
  :host {
13849
13849
  display: block;
13850
13850
  width: 100%;
@@ -16136,7 +16136,7 @@ var Z6=Object.create;var{getPrototypeOf:O6,defineProperty:N3,getOwnPropertyNames
16136
16136
  :host {
16137
16137
  height: 100%;
16138
16138
  }
16139
- `;var p6=()=>({getRandomInt:({min:a,max:e})=>{let i=Math.floor(Math.random()*(e-a+1))+a;return{value:i,values:[i],count:1,min:a,max:e,proofHash:"mock",proofString:"mock"}},getUniqueRandomInts:({min:a,max:e,count:i})=>{let r=[];while(r.length<i){let n=Math.floor(Math.random()*(e-a+1))+a;if(!r.includes(n))r.push(n)}return{values:r,count:i,min:a,max:e,proofHash:"mock",proofString:"mock"}},getRandomIntsWithReplacement:({min:a,max:e,count:i})=>{return{values:Array.from({length:i},()=>Math.floor(Math.random()*(e-a+1))+a),count:i,min:a,max:e,proofHash:"mock",proofString:"mock"}}}),F3=(a)=>{let e=0,i=(r)=>{let n=[];for(let t=0;t<r;t++){if(e>=a.length)throw new Error("Random sequence exhausted - not enough values provided for this action");n.push(a[e]),e++}return n};return{getRandomInt:({min:r,max:n})=>{let t=i(1);return{value:t[0],values:t,count:1,min:r,max:n,proofHash:"mock",proofString:"mock"}},getUniqueRandomInts:({min:r,max:n,count:t})=>{return{values:i(t),count:t,min:r,max:n,proofHash:"mock",proofString:"mock"}},getRandomIntsWithReplacement:({min:r,max:n,count:t})=>{return{values:i(t),count:t,min:r,max:n,proofHash:"mock",proofString:"mock"}}}};class J3{async startBet(a){let{amount:e,selections:i}=a,r={bets:i.map((d)=>({type:d.position,amount:I(d.amount)}))},t=new Jn().getGameResult({generator:p6(),edge:1,gameInputs:r}),o=Fn(r),l=o.mul(t.payoutMultiplier);return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"baccarat",currency:a.currency??"USD",amount:o.toString(),payout:l.toString(),afterBalance:"1000",multiplier:t.payoutMultiplier.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{id:crypto.randomUUID(),type:"START_BET",betAmount:e,payoutAmount:null,actionIndex:0,data:{BACCARAT:r}},{id:crypto.randomUUID(),type:"END_BET",betAmount:null,payoutAmount:l.toString(),actionIndex:1,data:{BACCARAT:t.outputs}}]}}}}class C2 extends ai{static styles=[...ai.styles,m6];constructor(){super();this.isManualPlaying=!1;this.resultMultiplier=null;this.history=[];this.gameWinPopupShowing=!1;this.payout=null;this.instantModeForCurrentBet=!1;this.slowRevealEnabled=!1;this.currentRound=null;new qa(this,[...this.getChipTableHotkeys(()=>this._baccaratManualEl,()=>this._baccaratAutoEl),{key:"p",callback:()=>this.handleChipInteraction("PLAYER"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"b",callback:()=>this.handleChipInteraction("BANKER"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"t",callback:()=>this.handleChipInteraction("TIE"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}}])}get baccaratApi(){return this.isDemoMode?new J3:new M3(this.gameData.authToken,this.gameData.baseUrl??"")}get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get isSlowRevealActive(){return this.slowRevealEnabled&&this.manualOrAuto==="Manual"&&!this.instantModeForCurrentBet}isMaxPayoutExceeded(a){let e=d1.deriveState(a,I(this.gameData?.maxBet??0));return Ma.getMaxPossiblePayoutFromChips(e).gt(this.gameData?.maxPayout??0)}handleGridClick=(a)=>{let{position:e,remove:i}=a.detail;this.handleChipInteraction(e,!!i)};handleSlowRevealChange=(a)=>{this.slowRevealEnabled=a.detail.enabled};resetRound(){this.currentRound=null,this.resultMultiplier=null,this.gameWinPopupShowing=!1,this.payout=null}onManualOrAutoChange(){this.resetRound()}addToHistory(a,e,i){this.history=[...this.history.filter((r)=>r.id!==i),{multiplier:a,won:e,id:i}].slice(-C5)}onDealSound=()=>{this.gameData?.soundEffects?.play(da.cardSlide())};onCardFlip=()=>{this.gameData?.soundEffects?.play(da.cardFlip())};async processBetResult(a,e,i){let n=a.betActions.find((d)=>d.type==="END_BET")?.data.BACCARAT;if(!n)throw new Error("No baccarat data found");let t=Ma.createGameRound(a,n);this.currentRound=t,await M1(this,"baccarat-dealing-complete",()=>!0,this.isSlowRevealActive?void 0:E5);let o=this.isDemoMode?e.minus(i).plus(a.payout??0):I(a.afterBalance??0);this.gameData.updateBalance(o);let l=t.multiplier,s=l>=1;if(this.resultMultiplier=l,this.betId=t.betId,this.payout=t.payout,this.gameWinPopupShowing=s,l>1)this.playWinFeedback();this.addToHistory(l,s,t.betId),this.updateHistoryWithBet(a)}async handleBetExecution(){if(this.instantModeForCurrentBet=this.gameData?.instantBetEnabled??!1,!this.gameData?.currency)return{success:!1,error:R("alerts.gameError",this.gameData?.language||W)};if(this.derivedChips.size===0)return{success:!1,error:R("games.baccarat.selectChip",this.gameData?.language||W)};if(this.isMaxPayoutExceeded(this.chipEvents))return{success:!1,error:R("alerts.maxPayoutExceeded",this.gameData?.language||W)};let{selections:a,totalAmount:e}=Ma.buildSelectionsAndTotal(this.derivedChips),i=e.toFixed(8);this.currentRound=null,this.resultMultiplier=null,this.gameWinPopupShowing=!1,this.payout=null;let r=I(this.gameData.balance);try{if(this.isDemoMode&&r.lt(e))return{success:!1,error:R("alerts.insufficientBalance",this.gameData?.language||W)};this.gameData.updateBalance(r.minus(e));let n=await this.baccaratApi.startBet({language:this.gameData.language,amount:i,currency:this.gameData.currency,selections:a});if(!n.success)throw new Error(n.error);return await this.processBetResult(n.data,r,e),n}catch(n){return{success:!1,error:n instanceof Error?n.message:R("alerts.gameError",this.gameData?.language||W)}}}async toggleAutobet(a){if(this.derivedChips.size===0){this.emit("show-alert",{detail:{type:"error",message:R("games.baccarat.selectChip",this.gameData?.language||W)}});return}if(!this.autobetInProgress)this.emit("show-alert",{detail:{id:"autobet-started",type:"info",message:R("autobet.startAutobet",this.gameData?.language||W),autoCloseDelay:5000}});await super.toggleAutobet(a)}async baccaratPlay(){if(this.gameWinPopupShowing=!1,this.derivedChips.size===0){this.emit("show-alert",{detail:{type:"error",message:R("games.baccarat.selectChip",this.gameData?.language||W)}});return}this.isManualPlaying=!0;let a=await this.handleBetExecution();if(!a.success)this.showError(a.error);this.isManualPlaying=!1}async executeAutobet(a,e){try{if(this.gameWinPopupShowing=!1,this.derivedChips.size===0)return{pnl:I(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("games.baccarat.selectChip",this.gameData?.language||W)};let i=await this.handleBetExecution();if(!i.success)return{pnl:I(0),gameOutcome:"Draw",hasError:!0,errorMessage:i.error||R("alerts.errorProcessingBet",this.gameData?.language||W)};let r=i.data,n=I(r.payout??0).minus(r.amount??0),t=Ga(Number(r.multiplier));if(!this.instantModeForCurrentBet){if(await Aa(this.getDelay(200)),t==="Win")await Aa(this.getDelay(150));await Aa(300)}return this.gameWinPopupShowing=!1,{pnl:n,gameOutcome:t,hasError:!1}}catch(i){return console.error("Error in executeAutobet:",i),{pnl:I(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("alerts.gameError",this.gameData?.language||W)}}}render(){let a=this.gameData?.mainWidth>=768,e=Va(this.gameData),i=this.totalBetAmount===0;return x`
16139
+ `;var p6=()=>({getRandomInt:({min:a,max:e})=>{let i=Math.floor(Math.random()*(e-a+1))+a;return{value:i,values:[i],count:1,min:a,max:e,proofHash:"mock",proofString:"mock"}},getUniqueRandomInts:({min:a,max:e,count:i})=>{let r=[];while(r.length<i){let n=Math.floor(Math.random()*(e-a+1))+a;if(!r.includes(n))r.push(n)}return{values:r,count:i,min:a,max:e,proofHash:"mock",proofString:"mock"}},getRandomIntsWithReplacement:({min:a,max:e,count:i})=>{return{values:Array.from({length:i},()=>Math.floor(Math.random()*(e-a+1))+a),count:i,min:a,max:e,proofHash:"mock",proofString:"mock"}}}),F3=(a)=>{let e=0,i=(r)=>{let n=[];for(let t=0;t<r;t++){if(e>=a.length)throw new Error("Random sequence exhausted - not enough values provided for this action");n.push(a[e]),e++}return n};return{getRandomInt:({min:r,max:n})=>{let t=i(1);return{value:t[0],values:t,count:1,min:r,max:n,proofHash:"mock",proofString:"mock"}},getUniqueRandomInts:({min:r,max:n,count:t})=>{return{values:i(t),count:t,min:r,max:n,proofHash:"mock",proofString:"mock"}},getRandomIntsWithReplacement:({min:r,max:n,count:t})=>{return{values:i(t),count:t,min:r,max:n,proofHash:"mock",proofString:"mock"}}}};class J3{async startBet(a){let{amount:e,selections:i}=a,r={bets:i.map((d)=>({type:d.position,amount:I(d.amount)}))},t=new Jn().getGameResult({generator:p6(),edge:1,gameInputs:r}),o=Fn(r),l=o.mul(t.payoutMultiplier);return{success:!0,data:{id:crypto.randomUUID(),tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:"baccarat",currency:a.currency??"USD",amount:o.toString(),payout:l.toString(),afterBalance:"1000",multiplier:t.payoutMultiplier.toString(),clientSeed:"mock-seed",randomValue:"mock-random",proof:"mock-proof",nonce:1,betActions:[{type:"START_BET",betAmount:e,payoutAmount:null,actionIndex:0,data:{BACCARAT:r}},{type:"END_BET",betAmount:null,payoutAmount:l.toString(),actionIndex:1,data:{BACCARAT:t.outputs}}]}}}}class C2 extends ai{static styles=[...ai.styles,m6];constructor(){super();this.isManualPlaying=!1;this.resultMultiplier=null;this.history=[];this.gameWinPopupShowing=!1;this.payout=null;this.instantModeForCurrentBet=!1;this.slowRevealEnabled=!1;this.currentRound=null;new qa(this,[...this.getChipTableHotkeys(()=>this._baccaratManualEl,()=>this._baccaratAutoEl),{key:"p",callback:()=>this.handleChipInteraction("PLAYER"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"b",callback:()=>this.handleChipInteraction("BANKER"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}},{key:"t",callback:()=>this.handleChipInteraction("TIE"),options:{repeat:!0,repeatInterval:200,disabled:()=>this.areInputsDisabled||!this.gameData?.hotkeysOpenEnabled}}])}get baccaratApi(){return this.isDemoMode?new J3:new M3(this.gameData.authToken,this.gameData.baseUrl??"")}get isToggleDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get areInputsDisabled(){return this.isManualPlaying||this.autobetInProgress||this.autobetStopping}get isSlowRevealActive(){return this.slowRevealEnabled&&this.manualOrAuto==="Manual"&&!this.instantModeForCurrentBet}isMaxPayoutExceeded(a){let e=d1.deriveState(a,I(this.gameData?.maxBet??0));return Ma.getMaxPossiblePayoutFromChips(e).gt(this.gameData?.maxPayout??0)}handleGridClick=(a)=>{let{position:e,remove:i}=a.detail;this.handleChipInteraction(e,!!i)};handleSlowRevealChange=(a)=>{this.slowRevealEnabled=a.detail.enabled};resetRound(){this.currentRound=null,this.resultMultiplier=null,this.gameWinPopupShowing=!1,this.payout=null}onManualOrAutoChange(){this.resetRound()}addToHistory(a,e,i){this.history=[...this.history.filter((r)=>r.id!==i),{multiplier:a,won:e,id:i}].slice(-C5)}onDealSound=()=>{this.gameData?.soundEffects?.play(da.cardSlide())};onCardFlip=()=>{this.gameData?.soundEffects?.play(da.cardFlip())};async processBetResult(a,e,i){let n=a.betActions.find((d)=>d.type==="END_BET")?.data.BACCARAT;if(!n)throw new Error("No baccarat data found");let t=Ma.createGameRound(a,n);this.currentRound=t,await M1(this,"baccarat-dealing-complete",()=>!0,this.isSlowRevealActive?void 0:E5);let o=this.isDemoMode?e.minus(i).plus(a.payout??0):I(a.afterBalance??0);this.gameData.updateBalance(o);let l=t.multiplier,s=l>=1;if(this.resultMultiplier=l,this.betId=t.betId,this.payout=t.payout,this.gameWinPopupShowing=s,l>1)this.playWinFeedback();this.addToHistory(l,s,t.betId),this.updateHistoryWithBet(a)}async handleBetExecution(){if(this.instantModeForCurrentBet=this.gameData?.instantBetEnabled??!1,!this.gameData?.currency)return{success:!1,error:R("alerts.gameError",this.gameData?.language||W)};if(this.derivedChips.size===0)return{success:!1,error:R("games.baccarat.selectChip",this.gameData?.language||W)};if(this.isMaxPayoutExceeded(this.chipEvents))return{success:!1,error:R("alerts.maxPayoutExceeded",this.gameData?.language||W)};let{selections:a,totalAmount:e}=Ma.buildSelectionsAndTotal(this.derivedChips),i=e.toFixed(8);this.currentRound=null,this.resultMultiplier=null,this.gameWinPopupShowing=!1,this.payout=null;let r=I(this.gameData.balance);try{if(this.isDemoMode&&r.lt(e))return{success:!1,error:R("alerts.insufficientBalance",this.gameData?.language||W)};this.gameData.updateBalance(r.minus(e));let n=await this.baccaratApi.startBet({language:this.gameData.language,amount:i,currency:this.gameData.currency,selections:a});if(!n.success)throw new Error(n.error);return await this.processBetResult(n.data,r,e),n}catch(n){return{success:!1,error:n instanceof Error?n.message:R("alerts.gameError",this.gameData?.language||W)}}}async toggleAutobet(a){if(this.derivedChips.size===0){this.emit("show-alert",{detail:{type:"error",message:R("games.baccarat.selectChip",this.gameData?.language||W)}});return}if(!this.autobetInProgress)this.emit("show-alert",{detail:{id:"autobet-started",type:"info",message:R("autobet.startAutobet",this.gameData?.language||W),autoCloseDelay:5000}});await super.toggleAutobet(a)}async baccaratPlay(){if(this.gameWinPopupShowing=!1,this.derivedChips.size===0){this.emit("show-alert",{detail:{type:"error",message:R("games.baccarat.selectChip",this.gameData?.language||W)}});return}this.isManualPlaying=!0;let a=await this.handleBetExecution();if(!a.success)this.showError(a.error);this.isManualPlaying=!1}async executeAutobet(a,e){try{if(this.gameWinPopupShowing=!1,this.derivedChips.size===0)return{pnl:I(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("games.baccarat.selectChip",this.gameData?.language||W)};let i=await this.handleBetExecution();if(!i.success)return{pnl:I(0),gameOutcome:"Draw",hasError:!0,errorMessage:i.error||R("alerts.errorProcessingBet",this.gameData?.language||W)};let r=i.data,n=I(r.payout??0).minus(r.amount??0),t=Ga(Number(r.multiplier));if(!this.instantModeForCurrentBet){if(await Aa(this.getDelay(200)),t==="Win")await Aa(this.getDelay(150));await Aa(300)}return this.gameWinPopupShowing=!1,{pnl:n,gameOutcome:t,hasError:!1}}catch(i){return console.error("Error in executeAutobet:",i),{pnl:I(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("alerts.gameError",this.gameData?.language||W)}}}render(){let a=this.gameData?.mainWidth>=768,e=Va(this.gameData),i=this.totalBetAmount===0;return x`
16140
16140
  <origami-game-layout style=${e} .gameType=${"BACCARAT"} data-is-desktop=${a}>
16141
16141
  <origami-game-sidebar
16142
16142
  slot="control-panel"
@@ -16573,7 +16573,7 @@ var Z6=Object.create;var{getPrototypeOf:O6,defineProperty:N3,getOwnPropertyNames
16573
16573
  :host {
16574
16574
  height: 100%;
16575
16575
  }
16576
- `;class $3{edge=0;currentBalance;activeBet=null;previousPlayResults=[];randomSequence=[];useCustomSequence=!1;amount="0";betCurrency="USD";constructor(a){this.currentBalance=I(a)}setRandomSequence(a){let e=Array.from({length:this.maxRandomValues-a.length},()=>Math.floor(Math.random()*(this.maxRandomValue-this.minRandomValue+1))+this.minRandomValue);this.randomSequence=[...a,...e],this.useCustomSequence=!0}async startGame(a){let e=I(a.amount);if(e.gt(this.currentBalance))return{success:!1,error:"Insufficient balance"};let i=this.currentBalance.minus(e);if(!this.useCustomSequence)this.randomSequence=Array.from({length:this.maxRandomValues},()=>Math.floor(Math.random()*(this.maxRandomValue-this.minRandomValue+1))+this.minRandomValue);this.useCustomSequence=!1,this.amount=a.amount,this.betCurrency=a.currency??"USD";let r=F3(this.randomSequence),t=this.createGameEngine(this.edge).play(r,a.gameInputs,[]);this.previousPlayResults=[t];let o=crypto.randomUUID(),l=this.toActionData(t);if(t.state.isFinished){let d=e.mul(t.state.multiplier),c=i.plus(d);this.currentBalance=c;let m={id:o,tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:this.gameId,currency:this.betCurrency,amount:e.toString(),payout:d.toString(),afterBalance:c.toString(),multiplier:t.state.multiplier.toString(),clientSeed:"mock-seed",randomValue:t.proof.proofHash,proof:t.proof.proofString,nonce:1,betActions:[{id:crypto.randomUUID(),type:"START_BET",betAmount:a.amount,payoutAmount:null,actionIndex:0,data:l},{id:crypto.randomUUID(),type:"END_BET",betAmount:null,payoutAmount:d.toString(),actionIndex:1,data:l}]};return this.clearState(),{success:!0,data:m}}let s={id:o,tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:this.gameId,currency:this.betCurrency,amount:e.toString(),payout:null,afterBalance:i.toString(),multiplier:null,clientSeed:"mock-seed",randomValue:null,proof:null,nonce:1,betActions:[{id:crypto.randomUUID(),type:"START_BET",betAmount:a.amount,payoutAmount:null,actionIndex:0,data:l}]};return this.currentBalance=i,this.activeBet=s,{success:!0,data:s}}async performNextAction(a){if(!this.activeBet)return{success:!1,error:"No active bet"};let e=F3(this.randomSequence),r=this.createGameEngine(this.edge).play(e,a,this.previousPlayResults);this.previousPlayResults=[...this.previousPlayResults,r];let n=this.activeBet,t=[...n.betActions],o=t.length,l=this.toActionData(r),s=r.additionalBetAmount!==void 0,d=s?r.additionalBetAmount:null,c=d!==null?I(this.amount).plus(d):I(this.amount),m=c.mul(r.state.multiplier),u=this.currentBalance;if(s&&d!==null){u=u.minus(d),this.amount=c.toString();let H={id:crypto.randomUUID(),type:"INTERMEDIATE_BET_ACTION",betAmount:d.toString(),payoutAmount:null,actionIndex:o,data:l},z=[...t,H];if(!r.state.isFinished){this.currentBalance=u;let b={...n,amount:c.toString(),afterBalance:u.toString(),betActions:z};return this.activeBet=b,{success:!0,data:b}}let v=u.plus(m);this.currentBalance=v,z.push({id:crypto.randomUUID(),type:"END_BET",betAmount:null,payoutAmount:m.toString(),actionIndex:o+1,data:l});let g={...n,amount:c.toString(),payout:m.toString(),afterBalance:v.toString(),multiplier:r.state.multiplier.toString(),randomValue:r.proof.proofHash,proof:r.proof.proofString,betActions:z};return this.clearState(),{success:!0,data:g}}if(!r.state.isFinished){let H={id:crypto.randomUUID(),type:"INTERMEDIATE_NON_BET_ACTION",betAmount:null,payoutAmount:null,actionIndex:o,data:l},z={...n,afterBalance:u.toString(),betActions:[...t,H]};return this.currentBalance=u,this.activeBet=z,{success:!0,data:z}}let f=u.plus(m);this.currentBalance=f;let k={id:crypto.randomUUID(),type:"END_BET",betAmount:null,payoutAmount:m.toString(),actionIndex:o,data:l},p={...n,payout:m.toString(),afterBalance:f.toString(),multiplier:r.state.multiplier.toString(),randomValue:r.proof.proofHash,proof:r.proof.proofString,betActions:[...t,k]};return this.clearState(),{success:!0,data:p}}async fetchActiveBet(){if(!this.activeBet)return{success:!1,error:"No active bet"};return{success:!0,data:this.activeBet}}clearState(){this.activeBet=null,this.previousPlayResults=[],this.randomSequence=[],this.amount="0"}}var mu=0,pu=51,gu=63;class ei extends $3{static pendingCardSequence=null;gameId="blackjack";maxRandomValues=gu;minRandomValue=mu;maxRandomValue=pu;static setCardSequence(a){ei.pendingCardSequence=[...a]}constructor(a){super(a)}createGameEngine(a){return new er(a)}toActionData(a){return{BLACKJACK:a}}async startBet(a){if(ei.pendingCardSequence!==null)this.setRandomSequence(ei.pendingCardSequence),ei.pendingCardSequence=null;let e=a.mainBetAmount,i=a.pairBonusAmount??"0",r=a.threeCardBonusAmount??"0",n=I(e).plus(i).plus(r),t=await this.startGame({amount:n.toString(),currency:a.currency??"USD",gameInputs:{type:Za.START,mainBetAmount:e,pairBonusAmount:i,threeCardBonusAmount:r}});if(t.success)return t;return{success:!1,errorCode:t.error==="Insufficient balance"?"INSUFFICIENT_BALANCE":"UNKNOWN"}}async next(a){let e=await this.performNextAction({type:a.type});if(e.success)return e;return{success:!1,errorCode:"UNKNOWN"}}async getActiveBet(){let a=await this.fetchActiveBet();if(a.success)return a;if(a.error==="No active bet")return{success:!0,data:null};return{success:!1,errorCode:"UNKNOWN"}}}var wu=(a)=>{if(typeof a!=="object"||a===null||!("cardId"in a))return!1;return a.cardId===void 0||typeof a.cardId==="string"};class wr{host;constructor(a){this.host=a,a.addController(this)}hostConnected(){}get instantMode(){return this.host.gameData.instantBetEnabled}static BETWEEN_CARD_ACTIONS_PAUSE=120;static DEALER_REVEAL_PAUSE=300;async waitBeforeDealerReveal(){if(this.instantMode)return;if(this.host.visibleState.stage!=="player")return;await Aa(wr.DEALER_REVEAL_PAUSE)}async waitBetweenCardActions(){if(this.instantMode)return;await Aa(wr.BETWEEN_CARD_ACTIONS_PAUSE)}async dealPlayerCard(a,e){let i=this.host.addPlayerCardToHand(a,e);await this.waitForCardDealComplete(i)}async dealDealerCard(a){let e=this.host.addDealerCard(a);await this.waitForCardDealComplete(e)}async revealDealerHoleCard(a){this.host.updateDealerCard(1,a,!1),await this.waitForCardDealComplete("d-1")}async runCardActions(a){for(let e=0;e<a.length;e++){let i=a[e];if(await i(),e<a.length-1)await this.waitBetweenCardActions()}}async playInitialDeal(a,e){if(this.instantMode){this.host.updateVisibleState({playerHands:[a],dealerCards:e});return}let i={...e[1],faceDown:!0};await this.runCardActions([()=>this.dealPlayerCard(0,a[0]),()=>this.dealDealerCard(e[0]),()=>this.dealPlayerCard(0,a[1]),()=>this.dealDealerCard(i)])}async playDealerReveal(a){await this.waitBeforeDealerReveal(),this.host.updateVisibleState({stage:"dealer"}),await this.host.triggerForceUIUpdate();let e=[];if(a[1])e.push(()=>this.revealDealerHoleCard(a[1]));for(let i=2;i<a.length;i++){let r=a[i];e.push(()=>this.dealDealerCard(r))}await this.runCardActions(e)}async playSplitDeal(a,e){await this.dealPlayerCard(0,a),await this.waitBetweenCardActions(),await this.dealPlayerCard(1,e)}async waitForAllCardsToBeIdle(){if(this.instantMode)return;await this.host.triggerForceUIUpdate(),await Aa(50)}waitForCardDealComplete(a){if(this.instantMode)return Promise.resolve();return new Promise((e)=>{let i=!1,r=(n)=>{if(!(n instanceof CustomEvent)||!wu(n.detail)||n.detail.cardId!==a)return;this.host.removeEventListener("blackjack-card-dealt",r),i=!0,e()};this.host.addEventListener("blackjack-card-dealt",r),Aa(2000).then(()=>{if(i)return;this.host.removeEventListener("blackjack-card-dealt",r),e()})})}}var ku=5,I6="origami-blackjack-sidebet-onboarded";class W2 extends xa{static styles=[...xa.styles,S6];currentBetId=null;currentMainBetAmount="0";animationController;actionHandlers;betController;hasTrackedSessionConfig=!1;previousAuthToken="";previousBaseUrl="";get activeHand(){return this.visibleState.playerHands[this.visibleState.activeHandIndex]??[]}get playerHandsForContent(){return this.visibleState.playerHands}get activeHandIndexForContent(){return this.visibleState.activeHandIndex}get isGameActive(){return this.visibleState.stage!=="idle"&&this.visibleState.stage!=="settled"}get isToggleDisabled(){return this.visibleState.isActing||this.autobetInProgress||this.autobetStopping||this.isGameActive}get areInputsDisabled(){return this.visibleState.isActing||this.autobetInProgress||this.autobetStopping||this.controlsLocked}get totalBetExceedsBalance(){if(!this.gameData?.hasLoadedBalance)return!1;let a=this.gameData.betAmount??"0",e=this.sideBetMode?this.pairBonusAmount:"0",i=this.sideBetMode?this.threeCardBonusAmount:"0";if(![a,e,i].every(fa))return!1;return I(a).plus(e).plus(i).gt(I(this.gameData.balance??0))}get sidebarMode(){return this.sideBetMode||this.showSideBetOnboarding?"Auto":"Manual"}_getBlackjackApi=U1(()=>this.gameData,()=>this.isDemoMode,{createReal:(a,e)=>new P3(a,e),createMock:()=>new ei(this.gameData.balance)});getBlackjackApi(){return this._getBlackjackApi()}constructor(){super();this.canonicalState=null;this.visibleState=hr();this.history=[];this.controlsLocked=!1;this._loadingAction=null;this.suppressNextContentAnimations=!1;this.sideBetMode=!1;this.pairBonusAmount="0";this.threeCardBonusAmount="0";this.sideBetResults=null;this.showSideBetOnboarding=!1;this.animationController=new wr(this),this.actionHandlers=new W3(this,this.animationController),this.betController=new E3(this,this.animationController),new qa(this,[{key:" ",callback:this.handleSpacebar,options:{repeat:!0,repeatInterval:200,disabled:this.isSpacebarDisabled}},{key:"q",callback:this.handleHit,options:{disabled:this.isHitDisabled}},{key:"w",callback:this.handleStand,options:{disabled:this.isStandDisabled}},{key:"e",callback:this.handleSplit,options:{disabled:this.isSplitDisabled}},{key:"r",callback:this.handleDoubleDown,options:{disabled:this.isDoubleDisabled}},{key:"t",callback:this.handleAcceptInsurance,options:{disabled:this.isAcceptInsuranceDisabled}},{key:"y",callback:this.handleNoInsurance,options:{disabled:this.isNoInsuranceDisabled}}])}setCanonicalState(a){this.canonicalState=a}setVisibleState(a){this.visibleState=a}updateVisibleState(a){this.visibleState={...this.visibleState,...a}}addToHistory(a,e,i){this.history=[...this.history,{multiplier:a,won:e,id:i}].slice(-ku)}async withOptimisticBalanceDeduction(a,e){let i=I(this.gameData.balance);this.gameData.updateBalance(i.minus(a));try{let r=await e();if(r===null)this.gameData.updateBalance(i);return r}catch(r){throw this.gameData.updateBalance(i),r}}async runWithLockedControls(a,e){this.controlsLocked=!0,this._loadingAction=e??null;try{await a()}finally{this.controlsLocked=!1,this._loadingAction=null}}async firstUpdated(a){super.firstUpdated(a),await this.getBlackjackActiveBet()}updated(a){super.updated(a);let e=this.gameData.authToken,i=this.gameData.baseUrl;if(!this.hasTrackedSessionConfig){this.previousAuthToken=e,this.previousBaseUrl=i,this.hasTrackedSessionConfig=!0;return}if(e===this.previousAuthToken&&i===this.previousBaseUrl)return;let r=Boolean(this.previousAuthToken)&&Boolean(this.previousBaseUrl),n=Boolean(e)&&Boolean(i);if(this.previousAuthToken=e,this.previousBaseUrl=i,!r&&!n)return;this.getBlackjackActiveBet()}async getBlackjackActiveBet(){let a=!1;try{let e=await this.getBlackjackApi().getActiveBet();if(!e.success)return;if(e.data===null){this.currentBetId=null,this.canonicalState=null,this.sideBetResults=null,this.setVisibleState(hr());return}this.currentBetId=e.data.id;let i=ur(e.data);if(!i)return;this.canonicalState=i,this.suppressNextContentAnimations=!0,a=!0,this.setVisibleState(ls(i)),this.sideBetResults=Ai(i),await this.forceUIUpdate()}catch{this.showError(R("alerts.gameError",this.gameData.language||W))}finally{if(a)this.suppressNextContentAnimations=!1}}addPlayerCardToHand(a,e){let i=this.visibleState.playerHands.map((r,n)=>n===a?[...r,e]:r);return this.visibleState={...this.visibleState,playerHands:i},`p-${a}-${i[a].length-1}`}addDealerCard(a){return this.visibleState={...this.visibleState,dealerCards:[...this.visibleState.dealerCards,a]},`d-${this.visibleState.dealerCards.length-1}`}updateDealerCard(a,e,i){this.visibleState={...this.visibleState,dealerCards:this.visibleState.dealerCards.map((r,n)=>{if(n===a)return{...e,faceDown:i};return r})}}setSuppressAnimations(a){this.suppressNextContentAnimations=a}setSideBetResults(a){this.sideBetResults=a}revertToStandardModeIfNoSideBets(){if(!this.sideBetMode)return;if(![this.pairBonusAmount,this.threeCardBonusAmount].some((e)=>fa(e)&&I(e).gt(0)))this.sideBetMode=!1}async finishRound(a){if(!this.canonicalState)return;let e=this.canonicalState.multiplier.toNumber(),i=e>1;this.addToHistory(e,i,a.id),this.updateHistoryWithBet({id:a.id,currency:a.currency,amount:a.amount,payout:a.payout});let r=bt(this.canonicalState),n=dr(this.canonicalState);if(await this.animationController.waitForAllCardsToBeIdle(),this.updateVisibleState({resultMultiplier:e,mainHandOutcome:r.mainOutcome,splitHandOutcome:r.splitOutcome,insuranceOutcome:n}),await this.forceUIUpdate(),i)this.playWinFeedback();if(a.afterBalance)this.gameData.updateBalance(I(a.afterBalance));this.updateVisibleState({stage:"settled",isActing:!1}),this.hasPendingBet=!1,this.currentBetId=null,this.currentMainBetAmount="0"}async executeNextAction(a){if(!this.currentBetId)return null;let e=await this.getBlackjackApi().next({betId:this.currentBetId,type:a});if(!e.success)return this.showError(R(e1(e.errorCode),this.gameData.language||W)),null;let i=ur(e.data);return this.canonicalState=i,e.data}async blackjackPlay(){if(this.isGameActive)return;this.updateVisibleState({isActing:!0}),this.gameData.soundEffects?.play(da.buttonPress(0.5));try{await this.betController.handleBetExecution(this.gameData.betAmount??"0")}catch{this.showError(R("alerts.gameError",this.gameData.language||W))}finally{this.updateVisibleState({isActing:!1})}}async executeAutobet(a,e){return{pnl:I(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("alerts.gameError",this.gameData.language||W)}}triggerForceUIUpdate(){return this.forceUIUpdate()}triggerShowError(a){this.showError(a)}setHasPendingBet(a){this.hasPendingBet=a}canAffordAction(a){if(!this.gameData?.hasLoadedBalance)return!0;if(!fa(this.currentMainBetAmount))return!0;let e=I(this.gameData.balance??0),i=I(this.currentMainBetAmount);switch(a){case Za.SPLIT:case Za.DOUBLE_DOWN:return e.gte(i);case Za.BUY_INSURANCE:return e.gte(i.div(2));case Za.HIT:case Za.STAND:case Za.START:case Za.REJECT_INSURANCE:return!0;default:return!1}}canPerformAction(a){return this.visibleState.stage==="player"&&!this.controlsLocked&&this.currentBetId!==null&&os(this.canonicalState).includes(a)&&this.canAffordAction(a)}onBuyInsurance=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleInsurance(Za.BUY_INSURANCE),"buy-insurance")};onDeclineInsurance=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleInsurance(Za.REJECT_INSURANCE),"no-insurance")};handleHit=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleHit(this.currentBetId),"hit")};handleStand=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleStand(this.currentBetId),"stand")};handleDoubleDown=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleDoubleDown(this.currentBetId),"double")};handleSplit=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleSplit(this.currentBetId),"split")};isSpacebarDisabled=()=>{if(!this.gameData.hotkeysOpenEnabled||this.isGameActive)return!0;return this._blackjackManualEl?.isPrimaryActionDisabled()??!0};isHitDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||!this.canPerformAction(Za.HIT)};isStandDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||!this.canPerformAction(Za.STAND)};isSplitDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||!this.canPerformAction(Za.SPLIT)};isDoubleDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||!this.canPerformAction(Za.DOUBLE_DOWN)};isAcceptInsuranceDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||this.controlsLocked||this.visibleState.stage!=="insurance"||!this.canAffordAction(Za.BUY_INSURANCE)};isNoInsuranceDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||this.controlsLocked||this.visibleState.stage!=="insurance"};handleAcceptInsurance=()=>{if(this.isAcceptInsuranceDisabled())return;this.onBuyInsurance()};handleNoInsurance=()=>{if(this.isNoInsuranceDisabled())return;this.onDeclineInsurance()};handleSpacebar=()=>{if(this.isSpacebarDisabled())return;this._blackjackManualEl?.triggerPrimaryAction()};onBetModeChange=(a)=>{if(!$1(a.detail.tab))return;if(a.detail.tab==="Manual"&&this.showSideBetOnboarding){this.showSideBetOnboarding=!1;return}if(a.detail.tab==="Auto"&&!this.sideBetMode&&!this.sideBetOnboardingComplete){this.showSideBetOnboarding=!0;return}this.showSideBetOnboarding=!1,this.sideBetMode=a.detail.tab==="Auto"};get sideBetOnboardingComplete(){if(typeof localStorage==="undefined")return!1;return localStorage.getItem(I6)==="1"}handleSideBetOnboardingComplete=()=>{if(typeof localStorage!=="undefined")localStorage.setItem(I6,"1");this.showSideBetOnboarding=!1,this.sideBetMode=!0};onPairBonusAmountChange=(a)=>{this.pairBonusAmount=a.detail.value};onThreeCardBonusAmountChange=(a)=>{this.threeCardBonusAmount=a.detail.value};onDealSound=()=>{this.gameData.soundEffects?.play(da.cardSlide())};onCardFlip=()=>{this.gameData.soundEffects?.play(da.cardFlip())};render(){let a=this.gameData.mainWidth>=768,e=this.areInputsDisabled||this.isGameActive||this.totalBetExceedsBalance,i=Va(this.gameData);return x`
16576
+ `;class $3{edge=0;currentBalance;activeBet=null;previousPlayResults=[];randomSequence=[];useCustomSequence=!1;amount="0";betCurrency="USD";constructor(a){this.currentBalance=I(a)}setRandomSequence(a){let e=Array.from({length:this.maxRandomValues-a.length},()=>Math.floor(Math.random()*(this.maxRandomValue-this.minRandomValue+1))+this.minRandomValue);this.randomSequence=[...a,...e],this.useCustomSequence=!0}async startGame(a){let e=I(a.amount);if(e.gt(this.currentBalance))return{success:!1,error:"Insufficient balance"};let i=this.currentBalance.minus(e);if(!this.useCustomSequence)this.randomSequence=Array.from({length:this.maxRandomValues},()=>Math.floor(Math.random()*(this.maxRandomValue-this.minRandomValue+1))+this.minRandomValue);this.useCustomSequence=!1,this.amount=a.amount,this.betCurrency=a.currency??"USD";let r=F3(this.randomSequence),t=this.createGameEngine(this.edge).play(r,a.gameInputs,[]);this.previousPlayResults=[t];let o=crypto.randomUUID(),l=this.toActionData(t);if(t.state.isFinished){let d=e.mul(t.state.multiplier),c=i.plus(d);this.currentBalance=c;let m={id:o,tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:this.gameId,currency:this.betCurrency,amount:e.toString(),payout:d.toString(),afterBalance:c.toString(),multiplier:t.state.multiplier.toString(),clientSeed:"mock-seed",randomValue:t.proof.proofHash,proof:t.proof.proofString,nonce:1,betActions:[{type:"START_BET",betAmount:a.amount,payoutAmount:null,actionIndex:0,data:l},{type:"END_BET",betAmount:null,payoutAmount:d.toString(),actionIndex:1,data:l}]};return this.clearState(),{success:!0,data:m}}let s={id:o,tenantId:"origami-casino",userId:"mock-user",tenantUserId:"mock-user",gameId:this.gameId,currency:this.betCurrency,amount:e.toString(),payout:null,afterBalance:i.toString(),multiplier:null,clientSeed:"mock-seed",randomValue:null,proof:null,nonce:1,betActions:[{type:"START_BET",betAmount:a.amount,payoutAmount:null,actionIndex:0,data:l}]};return this.currentBalance=i,this.activeBet=s,{success:!0,data:s}}async performNextAction(a){if(!this.activeBet)return{success:!1,error:"No active bet"};let e=F3(this.randomSequence),r=this.createGameEngine(this.edge).play(e,a,this.previousPlayResults);this.previousPlayResults=[...this.previousPlayResults,r];let n=this.activeBet,t=[...n.betActions],o=t.length,l=this.toActionData(r),s=r.additionalBetAmount!==void 0,d=s?r.additionalBetAmount:null,c=d!==null?I(this.amount).plus(d):I(this.amount),m=c.mul(r.state.multiplier),u=this.currentBalance;if(s&&d!==null){u=u.minus(d),this.amount=c.toString();let H={type:"INTERMEDIATE_BET_ACTION",betAmount:d.toString(),payoutAmount:null,actionIndex:o,data:l},z=[...t,H];if(!r.state.isFinished){this.currentBalance=u;let b={...n,amount:c.toString(),afterBalance:u.toString(),betActions:z};return this.activeBet=b,{success:!0,data:b}}let v=u.plus(m);this.currentBalance=v,z.push({type:"END_BET",betAmount:null,payoutAmount:m.toString(),actionIndex:o+1,data:l});let g={...n,amount:c.toString(),payout:m.toString(),afterBalance:v.toString(),multiplier:r.state.multiplier.toString(),randomValue:r.proof.proofHash,proof:r.proof.proofString,betActions:z};return this.clearState(),{success:!0,data:g}}if(!r.state.isFinished){let H={type:"INTERMEDIATE_NON_BET_ACTION",betAmount:null,payoutAmount:null,actionIndex:o,data:l},z={...n,afterBalance:u.toString(),betActions:[...t,H]};return this.currentBalance=u,this.activeBet=z,{success:!0,data:z}}let f=u.plus(m);this.currentBalance=f;let k={type:"END_BET",betAmount:null,payoutAmount:m.toString(),actionIndex:o,data:l},p={...n,payout:m.toString(),afterBalance:f.toString(),multiplier:r.state.multiplier.toString(),randomValue:r.proof.proofHash,proof:r.proof.proofString,betActions:[...t,k]};return this.clearState(),{success:!0,data:p}}async fetchActiveBet(){if(!this.activeBet)return{success:!1,error:"No active bet"};return{success:!0,data:this.activeBet}}clearState(){this.activeBet=null,this.previousPlayResults=[],this.randomSequence=[],this.amount="0"}}var mu=0,pu=51,gu=63;class ei extends $3{static pendingCardSequence=null;gameId="blackjack";maxRandomValues=gu;minRandomValue=mu;maxRandomValue=pu;static setCardSequence(a){ei.pendingCardSequence=[...a]}constructor(a){super(a)}createGameEngine(a){return new er(a)}toActionData(a){return{BLACKJACK:a}}async startBet(a){if(ei.pendingCardSequence!==null)this.setRandomSequence(ei.pendingCardSequence),ei.pendingCardSequence=null;let e=a.mainBetAmount,i=a.pairBonusAmount??"0",r=a.threeCardBonusAmount??"0",n=I(e).plus(i).plus(r),t=await this.startGame({amount:n.toString(),currency:a.currency??"USD",gameInputs:{type:Za.START,mainBetAmount:e,pairBonusAmount:i,threeCardBonusAmount:r}});if(t.success)return t;return{success:!1,errorCode:t.error==="Insufficient balance"?"INSUFFICIENT_BALANCE":"UNKNOWN"}}async next(a){let e=await this.performNextAction({type:a.type});if(e.success)return e;return{success:!1,errorCode:"UNKNOWN"}}async getActiveBet(){let a=await this.fetchActiveBet();if(a.success)return a;if(a.error==="No active bet")return{success:!0,data:null};return{success:!1,errorCode:"UNKNOWN"}}}var wu=(a)=>{if(typeof a!=="object"||a===null||!("cardId"in a))return!1;return a.cardId===void 0||typeof a.cardId==="string"};class wr{host;constructor(a){this.host=a,a.addController(this)}hostConnected(){}get instantMode(){return this.host.gameData.instantBetEnabled}static BETWEEN_CARD_ACTIONS_PAUSE=120;static DEALER_REVEAL_PAUSE=300;async waitBeforeDealerReveal(){if(this.instantMode)return;if(this.host.visibleState.stage!=="player")return;await Aa(wr.DEALER_REVEAL_PAUSE)}async waitBetweenCardActions(){if(this.instantMode)return;await Aa(wr.BETWEEN_CARD_ACTIONS_PAUSE)}async dealPlayerCard(a,e){let i=this.host.addPlayerCardToHand(a,e);await this.waitForCardDealComplete(i)}async dealDealerCard(a){let e=this.host.addDealerCard(a);await this.waitForCardDealComplete(e)}async revealDealerHoleCard(a){this.host.updateDealerCard(1,a,!1),await this.waitForCardDealComplete("d-1")}async runCardActions(a){for(let e=0;e<a.length;e++){let i=a[e];if(await i(),e<a.length-1)await this.waitBetweenCardActions()}}async playInitialDeal(a,e){if(this.instantMode){this.host.updateVisibleState({playerHands:[a],dealerCards:e});return}let i={...e[1],faceDown:!0};await this.runCardActions([()=>this.dealPlayerCard(0,a[0]),()=>this.dealDealerCard(e[0]),()=>this.dealPlayerCard(0,a[1]),()=>this.dealDealerCard(i)])}async playDealerReveal(a){await this.waitBeforeDealerReveal(),this.host.updateVisibleState({stage:"dealer"}),await this.host.triggerForceUIUpdate();let e=[];if(a[1])e.push(()=>this.revealDealerHoleCard(a[1]));for(let i=2;i<a.length;i++){let r=a[i];e.push(()=>this.dealDealerCard(r))}await this.runCardActions(e)}async playSplitDeal(a,e){await this.dealPlayerCard(0,a),await this.waitBetweenCardActions(),await this.dealPlayerCard(1,e)}async waitForAllCardsToBeIdle(){if(this.instantMode)return;await this.host.triggerForceUIUpdate(),await Aa(50)}waitForCardDealComplete(a){if(this.instantMode)return Promise.resolve();return new Promise((e)=>{let i=!1,r=(n)=>{if(!(n instanceof CustomEvent)||!wu(n.detail)||n.detail.cardId!==a)return;this.host.removeEventListener("blackjack-card-dealt",r),i=!0,e()};this.host.addEventListener("blackjack-card-dealt",r),Aa(2000).then(()=>{if(i)return;this.host.removeEventListener("blackjack-card-dealt",r),e()})})}}var ku=5,I6="origami-blackjack-sidebet-onboarded";class W2 extends xa{static styles=[...xa.styles,S6];currentBetId=null;currentMainBetAmount="0";animationController;actionHandlers;betController;hasTrackedSessionConfig=!1;previousAuthToken="";previousBaseUrl="";get activeHand(){return this.visibleState.playerHands[this.visibleState.activeHandIndex]??[]}get playerHandsForContent(){return this.visibleState.playerHands}get activeHandIndexForContent(){return this.visibleState.activeHandIndex}get isGameActive(){return this.visibleState.stage!=="idle"&&this.visibleState.stage!=="settled"}get isToggleDisabled(){return this.visibleState.isActing||this.autobetInProgress||this.autobetStopping||this.isGameActive}get areInputsDisabled(){return this.visibleState.isActing||this.autobetInProgress||this.autobetStopping||this.controlsLocked}get totalBetExceedsBalance(){if(!this.gameData?.hasLoadedBalance)return!1;let a=this.gameData.betAmount??"0",e=this.sideBetMode?this.pairBonusAmount:"0",i=this.sideBetMode?this.threeCardBonusAmount:"0";if(![a,e,i].every(fa))return!1;return I(a).plus(e).plus(i).gt(I(this.gameData.balance??0))}get sidebarMode(){return this.sideBetMode||this.showSideBetOnboarding?"Auto":"Manual"}_getBlackjackApi=U1(()=>this.gameData,()=>this.isDemoMode,{createReal:(a,e)=>new P3(a,e),createMock:()=>new ei(this.gameData.balance)});getBlackjackApi(){return this._getBlackjackApi()}constructor(){super();this.canonicalState=null;this.visibleState=hr();this.history=[];this.controlsLocked=!1;this._loadingAction=null;this.suppressNextContentAnimations=!1;this.sideBetMode=!1;this.pairBonusAmount="0";this.threeCardBonusAmount="0";this.sideBetResults=null;this.showSideBetOnboarding=!1;this.animationController=new wr(this),this.actionHandlers=new W3(this,this.animationController),this.betController=new E3(this,this.animationController),new qa(this,[{key:" ",callback:this.handleSpacebar,options:{repeat:!0,repeatInterval:200,disabled:this.isSpacebarDisabled}},{key:"q",callback:this.handleHit,options:{disabled:this.isHitDisabled}},{key:"w",callback:this.handleStand,options:{disabled:this.isStandDisabled}},{key:"e",callback:this.handleSplit,options:{disabled:this.isSplitDisabled}},{key:"r",callback:this.handleDoubleDown,options:{disabled:this.isDoubleDisabled}},{key:"t",callback:this.handleAcceptInsurance,options:{disabled:this.isAcceptInsuranceDisabled}},{key:"y",callback:this.handleNoInsurance,options:{disabled:this.isNoInsuranceDisabled}}])}setCanonicalState(a){this.canonicalState=a}setVisibleState(a){this.visibleState=a}updateVisibleState(a){this.visibleState={...this.visibleState,...a}}addToHistory(a,e,i){this.history=[...this.history,{multiplier:a,won:e,id:i}].slice(-ku)}async withOptimisticBalanceDeduction(a,e){let i=I(this.gameData.balance);this.gameData.updateBalance(i.minus(a));try{let r=await e();if(r===null)this.gameData.updateBalance(i);return r}catch(r){throw this.gameData.updateBalance(i),r}}async runWithLockedControls(a,e){this.controlsLocked=!0,this._loadingAction=e??null;try{await a()}finally{this.controlsLocked=!1,this._loadingAction=null}}async firstUpdated(a){super.firstUpdated(a),await this.getBlackjackActiveBet()}updated(a){super.updated(a);let e=this.gameData.authToken,i=this.gameData.baseUrl;if(!this.hasTrackedSessionConfig){this.previousAuthToken=e,this.previousBaseUrl=i,this.hasTrackedSessionConfig=!0;return}if(e===this.previousAuthToken&&i===this.previousBaseUrl)return;let r=Boolean(this.previousAuthToken)&&Boolean(this.previousBaseUrl),n=Boolean(e)&&Boolean(i);if(this.previousAuthToken=e,this.previousBaseUrl=i,!r&&!n)return;this.getBlackjackActiveBet()}async getBlackjackActiveBet(){let a=!1;try{let e=await this.getBlackjackApi().getActiveBet();if(!e.success)return;if(e.data===null){this.currentBetId=null,this.canonicalState=null,this.sideBetResults=null,this.setVisibleState(hr());return}this.currentBetId=e.data.id;let i=ur(e.data);if(!i)return;this.canonicalState=i,this.suppressNextContentAnimations=!0,a=!0,this.setVisibleState(ls(i)),this.sideBetResults=Ai(i),await this.forceUIUpdate()}catch{this.showError(R("alerts.gameError",this.gameData.language||W))}finally{if(a)this.suppressNextContentAnimations=!1}}addPlayerCardToHand(a,e){let i=this.visibleState.playerHands.map((r,n)=>n===a?[...r,e]:r);return this.visibleState={...this.visibleState,playerHands:i},`p-${a}-${i[a].length-1}`}addDealerCard(a){return this.visibleState={...this.visibleState,dealerCards:[...this.visibleState.dealerCards,a]},`d-${this.visibleState.dealerCards.length-1}`}updateDealerCard(a,e,i){this.visibleState={...this.visibleState,dealerCards:this.visibleState.dealerCards.map((r,n)=>{if(n===a)return{...e,faceDown:i};return r})}}setSuppressAnimations(a){this.suppressNextContentAnimations=a}setSideBetResults(a){this.sideBetResults=a}revertToStandardModeIfNoSideBets(){if(!this.sideBetMode)return;if(![this.pairBonusAmount,this.threeCardBonusAmount].some((e)=>fa(e)&&I(e).gt(0)))this.sideBetMode=!1}async finishRound(a){if(!this.canonicalState)return;let e=this.canonicalState.multiplier.toNumber(),i=e>1;this.addToHistory(e,i,a.id),this.updateHistoryWithBet({id:a.id,currency:a.currency,amount:a.amount,payout:a.payout});let r=bt(this.canonicalState),n=dr(this.canonicalState);if(await this.animationController.waitForAllCardsToBeIdle(),this.updateVisibleState({resultMultiplier:e,mainHandOutcome:r.mainOutcome,splitHandOutcome:r.splitOutcome,insuranceOutcome:n}),await this.forceUIUpdate(),i)this.playWinFeedback();if(a.afterBalance)this.gameData.updateBalance(I(a.afterBalance));this.updateVisibleState({stage:"settled",isActing:!1}),this.hasPendingBet=!1,this.currentBetId=null,this.currentMainBetAmount="0"}async executeNextAction(a){if(!this.currentBetId)return null;let e=await this.getBlackjackApi().next({betId:this.currentBetId,type:a});if(!e.success)return this.showError(R(e1(e.errorCode),this.gameData.language||W)),null;let i=ur(e.data);return this.canonicalState=i,e.data}async blackjackPlay(){if(this.isGameActive)return;this.updateVisibleState({isActing:!0}),this.gameData.soundEffects?.play(da.buttonPress(0.5));try{await this.betController.handleBetExecution(this.gameData.betAmount??"0")}catch{this.showError(R("alerts.gameError",this.gameData.language||W))}finally{this.updateVisibleState({isActing:!1})}}async executeAutobet(a,e){return{pnl:I(0),gameOutcome:"Draw",hasError:!0,errorMessage:R("alerts.gameError",this.gameData.language||W)}}triggerForceUIUpdate(){return this.forceUIUpdate()}triggerShowError(a){this.showError(a)}setHasPendingBet(a){this.hasPendingBet=a}canAffordAction(a){if(!this.gameData?.hasLoadedBalance)return!0;if(!fa(this.currentMainBetAmount))return!0;let e=I(this.gameData.balance??0),i=I(this.currentMainBetAmount);switch(a){case Za.SPLIT:case Za.DOUBLE_DOWN:return e.gte(i);case Za.BUY_INSURANCE:return e.gte(i.div(2));case Za.HIT:case Za.STAND:case Za.START:case Za.REJECT_INSURANCE:return!0;default:return!1}}canPerformAction(a){return this.visibleState.stage==="player"&&!this.controlsLocked&&this.currentBetId!==null&&os(this.canonicalState).includes(a)&&this.canAffordAction(a)}onBuyInsurance=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleInsurance(Za.BUY_INSURANCE),"buy-insurance")};onDeclineInsurance=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleInsurance(Za.REJECT_INSURANCE),"no-insurance")};handleHit=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleHit(this.currentBetId),"hit")};handleStand=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleStand(this.currentBetId),"stand")};handleDoubleDown=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleDoubleDown(this.currentBetId),"double")};handleSplit=async()=>{await this.runWithLockedControls(()=>this.actionHandlers.handleSplit(this.currentBetId),"split")};isSpacebarDisabled=()=>{if(!this.gameData.hotkeysOpenEnabled||this.isGameActive)return!0;return this._blackjackManualEl?.isPrimaryActionDisabled()??!0};isHitDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||!this.canPerformAction(Za.HIT)};isStandDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||!this.canPerformAction(Za.STAND)};isSplitDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||!this.canPerformAction(Za.SPLIT)};isDoubleDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||!this.canPerformAction(Za.DOUBLE_DOWN)};isAcceptInsuranceDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||this.controlsLocked||this.visibleState.stage!=="insurance"||!this.canAffordAction(Za.BUY_INSURANCE)};isNoInsuranceDisabled=()=>{return!this.gameData.hotkeysOpenEnabled||this.controlsLocked||this.visibleState.stage!=="insurance"};handleAcceptInsurance=()=>{if(this.isAcceptInsuranceDisabled())return;this.onBuyInsurance()};handleNoInsurance=()=>{if(this.isNoInsuranceDisabled())return;this.onDeclineInsurance()};handleSpacebar=()=>{if(this.isSpacebarDisabled())return;this._blackjackManualEl?.triggerPrimaryAction()};onBetModeChange=(a)=>{if(!$1(a.detail.tab))return;if(a.detail.tab==="Manual"&&this.showSideBetOnboarding){this.showSideBetOnboarding=!1;return}if(a.detail.tab==="Auto"&&!this.sideBetMode&&!this.sideBetOnboardingComplete){this.showSideBetOnboarding=!0;return}this.showSideBetOnboarding=!1,this.sideBetMode=a.detail.tab==="Auto"};get sideBetOnboardingComplete(){if(typeof localStorage==="undefined")return!1;return localStorage.getItem(I6)==="1"}handleSideBetOnboardingComplete=()=>{if(typeof localStorage!=="undefined")localStorage.setItem(I6,"1");this.showSideBetOnboarding=!1,this.sideBetMode=!0};onPairBonusAmountChange=(a)=>{this.pairBonusAmount=a.detail.value};onThreeCardBonusAmountChange=(a)=>{this.threeCardBonusAmount=a.detail.value};onDealSound=()=>{this.gameData.soundEffects?.play(da.cardSlide())};onCardFlip=()=>{this.gameData.soundEffects?.play(da.cardFlip())};render(){let a=this.gameData.mainWidth>=768,e=this.areInputsDisabled||this.isGameActive||this.totalBetExceedsBalance,i=Va(this.gameData);return x`
16577
16577
  <origami-game-layout style=${i} .gameType=${"BLACKJACK"} data-is-desktop=${a}>
16578
16578
  <origami-game-sidebar
16579
16579
  slot="control-panel"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betorigami/games",
3
- "version": "2.8.1",
3
+ "version": "2.8.2",
4
4
  "author": "",
5
5
  "license": "UNLICENSED",
6
6
  "description": "",
@@ -46,15 +46,12 @@
46
46
  "@playwright/test": "^1.53.0",
47
47
  "@rollup/plugin-babel": "^6.0.4",
48
48
  "@rollup/plugin-terser": "^0.4.4",
49
- "@storybook/web-components": "^9.0.4",
50
- "@storybook/web-components-vite": "^9.0.4",
51
49
  "@types/big.js": "^6.2.2",
52
50
  "@types/matter-js": "^0.18.2",
53
51
  "async": "^3.2.6",
54
52
  "glob": "^11.0.2",
55
53
  "mkdirp": "^3.0.1",
56
54
  "rollup": "^4.41.1",
57
- "storybook": "^9.0.4",
58
55
  "typescript": "^5.8.3",
59
56
  "underscore": "^1.13.7",
60
57
  "vite": "^6.3.5",