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AA,UACxCJ,IAAWK,EAAAA,GAAAA,gBACXL,IAAWK,EAAAA,GAAAA,kBACXL,IAAWK,EAAAA,GAAAA,eACXL,IAAWK,EAAAA,GAAAA,YACJzG,EAAAA,EAAAA,KAEJA,EAAAA,EAAAA,MAEJA,EAAAA,EAAAA,IACX,KAAC,EA1IY,CAjDoB0G,EAAAA,GAAW,qDAI3CjF,EAAAA,IAAU,wEACyD,CAAC,CAAE,IAAD,wHAOR,CAAC,CAAE,KAAD,yR","sources":["app-react/services/jackpots/jackpots.service.interface.ts","utils/gradual-increase-helper.ts","app-react/services/jackpots/jackpot-handler/jackpot-handler.ts","app-react/services/jackpots/jackpots.service.ts"],"sourcesContent":["import {NullableNumber} from \"../../../common/types/nullable-types\";\nimport { IJackpotHandler } from \"./jackpot-handler/jackpot-handler.interface\";\nimport {JACKPOT_STATE, JackpotType} from '../../../common/const/jackpot_map_ids';\n\nexport enum JackpotThemeType {\n Light,\n Dark\n}\n\nexport interface IJackpotStatefulData {\n amountInCents: number;\n jackpotId: string;\n jackpotState: JACKPOT_STATE;\n lastWinAmount: number;\n mustHitTime: Date;\n}\n\nexport interface IJackpotStatelessData {\n amountInCents: number;\n jackpotId: string;\n jackpotState: 0;\n lastWinAmount: 0;\n}\n\nexport type IJackpotData = IJackpotStatefulData | IJackpotStatelessData;\n\nexport interface IJackpotsService {\n getGameJackpot(gameType: number): NullableNumber;\n readonly currentJackpotsById: Record;\n getThemeType(jpType: JackpotType): JackpotThemeType;\n}\n","import { IGradualIncreaseHelperParams, IGradualIncreaseHelper } from \"./gradual-increase-helper.interface\";\nimport {SetIntervalType} from \"../common/types/set-interval-type\";\n\ninterface GradualIncreaseHelperCompleteParams extends IGradualIncreaseHelperParams {\n frequency: number;\n}\n\nexport class GradualIncreaseHelper implements IGradualIncreaseHelper {\n private params: GradualIncreaseHelperCompleteParams;\n\n private previousUpdateTime: number | undefined;\n private realAmount: number = 0;\n private fakeAmount: number = 0;\n private stepAmount: number = 0;\n\n private amountIncreaseTimer: SetIntervalType;\n\n constructor(_params: IGradualIncreaseHelperParams) {\n this.params = {\n frequency: 1000,\n ..._params,\n };\n }\n\n public restart(){\n this.realAmount = 0;\n this.previousUpdateTime = undefined;\n this.stopAmountIncreaseTimer();\n }\n\n public updateAmount(amount: number, previousUpdateTime?: number, startAmount?: number) {\n if(!this.realAmount) {\n this.realAmount = startAmount;\n }\n\n if(!this.previousUpdateTime) {\n this.previousUpdateTime = previousUpdateTime;\n }\n\n // As a safety net, when this function is called with an argument lower than the current amount, just ignore\n // It shouldn't happen.\n if(amount <= this.realAmount) {\n return;\n }\n\n // stop the previous timer (interval)\n this.stopAmountIncreaseTimer();\n\n // calculate number of steps\n const interval = this.params.interval || (Date.now() - this.previousUpdateTime) + 5000; // add 5 seconds to prevent uneven amount update intervals\n const steps = interval / this.params.frequency;\n\n // calculate step amount\n this.stepAmount = (amount - this.realAmount) / steps;\n\n // update amount with the previous real amount\n this.params.updateAmountFunction(this.realAmount);\n\n this.fakeAmount = this.realAmount;\n\n this.realAmount = amount;\n this.previousUpdateTime = Date.now();\n\n // start timer\n this.startAmountIncreaseTimer();\n }\n\n private updateFakeAmount() {\n this.fakeAmount = this.fakeAmount + this.stepAmount;\n if (this.fakeAmount <= this.realAmount) {\n this.params.updateAmountFunction(this.fakeAmount);\n } else {\n if ((this.fakeAmount - this.realAmount) < this.stepAmount) {\n this.params.updateAmountFunction(this.realAmount);\n }\n }\n }\n\n private stopAmountIncreaseTimer(){\n if (this.amountIncreaseTimer){\n clearInterval(this.amountIncreaseTimer);\n this.amountIncreaseTimer = undefined;\n }\n }\n\n private startAmountIncreaseTimer() {\n this.amountIncreaseTimer = setInterval(() => {\n this.updateFakeAmount();\n }, this.params.frequency);\n }\n}\n","import { IJackpotData } from \"../jackpots.service.interface\";\nimport { action, observable, makeObservable } from \"mobx\";\nimport { IServiceFactoryExtended } from \"../../service-factory-extended.interface\";\nimport { IGradualIncreaseHelper } from \"../../../../utils/gradual-increase-helper.interface\";\nimport { IJackpotHandler } from \"./jackpot-handler.interface\";\nimport { reaction, IReactionDisposer } from 'mobx'\nimport {GradualIncreaseHelper} from \"../../../../utils/gradual-increase-helper\";\n\nexport class JackpotHandler implements IJackpotHandler {\n @observable.ref\n public jackpotData: IJackpotData | null = null;\n /**\n * We don't show in the interface the value directly from this.currentJackpot.amountInCents because most of the time we want\n * to show a gradual increase of the amount. So we pass that value to the gradualIncreaseHelper which will set this value\n * and we show this value instead. This value will briefly be out of sync\n */\n @observable.ref\n public jackpotAmount: number = 0;\n\n private gradualIncreaseAmountHelper: IGradualIncreaseHelper | undefined;\n private readonly onAuthChangeReaction: IReactionDisposer;\n private previousUpdateTime: number;\n private gradualRealAmountInCents: number;\n private isFastGradualIncreaseFinish = false;\n\n constructor(private services: IServiceFactoryExtended) {\n makeObservable(this);\n\n /**\n * This service must listen to auth changes and when that happens to remove the gradual increase helper. It will be recreated when needed\n */\n this.onAuthChangeReaction = reaction(\n () => this.services.user.isAuthorized,\n () => this.removeGradualIncreaseAmountHelper(),\n );\n }\n\n @action.bound\n startGradual(jackpot: IJackpotData | null) {\n let newState = this.jackpotData?.jackpotState !== jackpot.jackpotState;\n this.previousUpdateTime = Date.now();\n\n if (!this.gradualIncreaseAmountHelper || newState) {\n // If new state or not exists - start fast gradual increase.\n this.createGradualIncreaseAmountHelper(50, 3000);\n this.gradualIncreaseAmountHelper.updateAmount(jackpot.amountInCents, this.previousUpdateTime, 0);\n this.gradualRealAmountInCents = jackpot.amountInCents;\n } else if (this.jackpotAmount === this.gradualRealAmountInCents && !this.isFastGradualIncreaseFinish) {\n // After fast gradual increase finish - start slow gradual increase from current value to the new value.\n this.isFastGradualIncreaseFinish = true;\n this.createGradualIncreaseAmountHelper();\n this.gradualIncreaseAmountHelper.updateAmount(jackpot.amountInCents, this.previousUpdateTime, this.jackpotData.amountInCents);\n } else if (this.isFastGradualIncreaseFinish) {\n // Update new amount with slow gradual increase from current value to the new value.\n this.gradualIncreaseAmountHelper.updateAmount(jackpot.amountInCents, this.previousUpdateTime, this.jackpotData.amountInCents);\n }\n }\n\n @action.bound\n forceGradual(jackpot: IJackpotData | null) {\n this.createGradualIncreaseAmountHelper(50, 2000);\n this.gradualIncreaseAmountHelper.updateAmount(jackpot.amountInCents, Date.now(), 0);\n this.gradualRealAmountInCents = jackpot.amountInCents;\n }\n\n @action.bound\n public setJackpotData(jackpot: IJackpotData | null, useGradualAmountIncrease: boolean = true) {\n if (jackpot) {\n if (useGradualAmountIncrease) {\n this.startGradual(jackpot);\n } else {\n this.setCurrentJackpotAmount(jackpot.amountInCents);\n }\n }\n this.jackpotData = jackpot;\n }\n\n @action.bound\n private setCurrentJackpotAmount(val: number) {\n this.jackpotAmount = val;\n }\n\n private createGradualIncreaseAmountHelper(frequency?: number, interval?: number) {\n this.removeGradualIncreaseAmountHelper();\n this.gradualIncreaseAmountHelper = new GradualIncreaseHelper({\n updateAmountFunction: (amount) => this.setCurrentJackpotAmount(amount),\n frequency: frequency || 300,\n interval: interval\n });\n }\n\n private removeGradualIncreaseAmountHelper() {\n if (this.gradualIncreaseAmountHelper) {\n this.gradualIncreaseAmountHelper.restart();\n this.gradualIncreaseAmountHelper = undefined;\n }\n }\n\n public dispose() {\n this.onAuthChangeReaction();\n this.removeGradualIncreaseAmountHelper();\n }\n}\n","import { action, observable, makeObservable } from \"mobx\";\nimport { ServiceBase } from \"../ServiceBase\";\nimport { IJackpotsService } from \"./jackpots.service.interface\";\nimport { IServiceFactoryExtended } from \"../service-factory-extended.interface\";\nimport {NullableNumber} from \"../../../common/types/nullable-types\";\nimport {IJackpotHandler} from \"./jackpot-handler/jackpot-handler.interface\";\nimport {IJackpotData, JackpotThemeType} from \"../jackpots/jackpots.service.interface\";\nimport {JackpotHandler} from \"./jackpot-handler/jackpot-handler\";\nimport {Check} from \"@sparkware/app-utils\";\nimport {JackpotType, JACKPOT_STATE} from \"../../../common/const/jackpot_map_ids\";\nimport {ThemeName} from \"../../themes/architecture/theme-names\";\n\nexport class JackpotsService extends ServiceBase implements IJackpotsService {\n /**\n * Current jackpot amounts, map where the key is the gameType\n */\n @observable\n public currentJackpotAmountsByGame: Record = {};\n\n /**\n * Current jackpot amounts, map where the key is the jackpot ID\n * In order to accomodate Blue Ribbon we moved from number index to string index in the currentJackpots record\n */\n @observable.ref\n public currentJackpotsById: Record = {};\n\n constructor(serviceFactory: IServiceFactoryExtended) {\n super(serviceFactory);\n makeObservable(this);\n const jackpotsByGameType = this.services.sdk.getJackpotsByGameType();\n this.updateCurrentJackpotsByGame(this.readJackpotsByGameTypeData(jackpotsByGameType));\n const jackpotsById = this.services.sdk.getJackpotsById();\n this.updateCurrentJackpotsById(this.readJackpotsByIdData(jackpotsById));\n this.subscribe();\n }\n\n /**\n * When the LIVE_FEEDS_JACKPOT_AMOUNTS_BY_GAME_UPDATED from CGP is fired, the jackpots must be updated\n * The data in the event is of type Record\n */\n private subscribe() {\n this.services.sdk.events.onJackpotsAmountsByGameUpdate((jackpotsAmounts: Record) => {\n let amounts = Object.keys(jackpotsAmounts).reduce((accumulator, jpId) => {\n accumulator[jpId] = Number(jackpotsAmounts[jpId]);\n return accumulator;\n }, {});\n this.updateCurrentJackpotsByGame(amounts);\n });\n\n this.services.sdk.events.onJackpotsByIdUpdate((jackpotsById) => {\n this.updateCurrentJackpotsById(this.readJackpotsByIdData(jackpotsById));\n });\n }\n\n @action.bound\n private updateCurrentJackpotsByGame(jackpots: Record) {\n Object.keys(jackpots).forEach((gameType) => {\n this.currentJackpotAmountsByGame[gameType] = jackpots[gameType];\n });\n }\n\n @action.bound\n private updateCurrentJackpotsById(jackpots: IJackpotData[], useGradualAmountIncrease: boolean = true) {\n let jackpotsAddition: Record = {};\n jackpots.forEach(jpData => {\n if (this.currentJackpotsById[jpData.jackpotId]) {\n this.currentJackpotsById[jpData.jackpotId].setJackpotData(jpData, useGradualAmountIncrease);\n } else {\n jackpotsAddition[jpData.jackpotId] = new JackpotHandler(this.services);\n jackpotsAddition[jpData.jackpotId].setJackpotData(jpData, useGradualAmountIncrease);\n }\n });\n if (!Check.isEmpty(jackpotsAddition)) {\n this.currentJackpotsById = {\n ...this.currentJackpotsById,\n ...jackpotsAddition\n };\n }\n }\n\n getGameJackpot(gameType: number): NullableNumber {\n return this.currentJackpotAmountsByGame[gameType] || null;\n }\n\n /**\n * Because cgp relies on a lot of js, \"any\" types, un-strict typescript and it's a separate system\n * data must be validated before use.\n */\n private readJackpotsByGameTypeData(rawJackpots: unknown): Record {\n let jackpotAmounts: Record = {};\n if (Check.isNullOrUndefined(rawJackpots) || !Check.isObject(rawJackpots)) {\n return jackpotAmounts;\n }\n\n Object.keys(rawJackpots).forEach(gameType => {\n try {\n let amount: any = (rawJackpots as any)[gameType].AmountInCents;\n if (!Check.isNumber(Number(amount))) {\n throw new Error(\"Jackpot AmountInCents missing or corrupted. Data received: \" + amount);\n }\n jackpotAmounts[gameType] = Number(amount);\n } catch (e) {\n this.services.logger.error(\"Error occurred reading jackpot data\", e);\n }\n });\n return jackpotAmounts;\n }\n \n /**\n * Because cgp relies on a lot of js, \"any\" types, un-strict typescript and it's a separate system\n * data must be validated before use.\n */\n private readJackpotsByIdData(rawJackpots: unknown): IJackpotData[] {\n\n let jackpots: IJackpotData[] = [];\n if (Check.isNullOrUndefined(rawJackpots) || !Check.isObject(rawJackpots)) {\n return jackpots;\n }\n\n Object.keys(rawJackpots).forEach(jpId => {\n try {\n let rawJackpot: any = (rawJackpots as any)[jpId].Jackpot;\n\n if (Check.isNullOrUndefined(rawJackpot) || Check.isEmpty(rawJackpot)) {\n return;\n }\n\n if (!Check.isNumber(Number(rawJackpot[\"AmountInCents\"]))) {\n throw new Error(\"Jackpot AmountInCents missing or corrupted. Data received: \" + rawJackpot);\n }\n if (!rawJackpot[\"JackpotId\"]) {\n throw new Error(\"Jackpot JackpotId missing or corrupted. Data received: \" + rawJackpot);\n }\n let jackpotState = Number(rawJackpot[\"JackpotState\"]);\n if (!Check.isNumber(jackpotState)) {\n jackpotState = 0;\n }\n let lastWinAmount = Number(rawJackpot[\"LastWinAmount\"]);\n if (!Check.isNumber(lastWinAmount)) {\n lastWinAmount = 0;\n }\n if (Check.isNullOrUndefined(rawJackpot[\"MustHitTime\"])) {\n throw new Error(\"Jackpot MustHitTime missing. Data received: \" + rawJackpot);\n }\n const mustHitTime = new Date(String(rawJackpot[\"MustHitTime\"]));\n // mustHitTime must be a Date formatted string: Ex: \"2020-08-04T15:47:43.683Z\"\n if (mustHitTime.toString() === \"Invalid Date\") {\n throw new Error(\"Jackpot MustHitTime corrupted\");\n }\n\n jackpots.push({\n amountInCents: Number(rawJackpot[\"AmountInCents\"]),\n jackpotId: String(rawJackpot[\"JackpotId\"]),\n jackpotState: this.readJackpotState(jackpotState),\n lastWinAmount,\n mustHitTime\n });\n } catch (e) {\n this.services.logger.error(\"Error occurred reading jackpot data\", e);\n }\n });\n\n return jackpots;\n }\n\n private readJackpotState(state: number) {\n switch (state) {\n case 0:\n // the stateless case\n return 0;\n case 1:\n return JACKPOT_STATE.Cold;\n case 2:\n return JACKPOT_STATE.Regular;\n case 3:\n case 4:\n case 5:\n return JACKPOT_STATE.Hot;\n default:\n return JACKPOT_STATE.Regular;\n }\n }\n\n /**\n * the 888 theme is dark and so it is the widget. So the texts are light\n * the 777 theme is light and so it is the widget. So the texts are dark\n * But, the Hourly Captain 8 widget is dark on all skins so we need to adapt\n */\n public getThemeType(jpType: JackpotType): JackpotThemeType {\n if (this.services.theme.themeName.forClient === ThemeName.Casino777.forClient) {\n if (jpType === JackpotType.HourlyCaptain8 || \n jpType === JackpotType.MillionaireGenie ||\n jpType === JackpotType.VegasMillions ||\n jpType === JackpotType.JackpotKing ) {\n return JackpotThemeType.Dark;\n }\n return JackpotThemeType.Light;\n }\n return JackpotThemeType.Dark;\n }\n}"],"names":["JackpotThemeType","GradualIncreaseHelper","_params","params","previousUpdateTime","realAmount","fakeAmount","stepAmount","amountIncreaseTimer","this","frequency","undefined","stopAmountIncreaseTimer","amount","startAmount","steps","interval","Date","now","updateAmountFunction","startAmountIncreaseTimer","clearInterval","setInterval","updateFakeAmount","JackpotHandler","observable","action","services","gradualIncreaseAmountHelper","onAuthChangeReaction","gradualRealAmountInCents","isFastGradualIncreaseFinish","makeObservable","reaction","user","isAuthorized","removeGradualIncreaseAmountHelper","jackpot","newState","jackpotData","jackpotState","createGradualIncreaseAmountHelper","updateAmount","amountInCents","jackpotAmount","startGradual","setCurrentJackpotAmount","val","restart","JackpotsService","serviceFactory","jackpotsByGameType","sdk","getJackpotsByGameType","updateCurrentJackpotsByGame","readJackpotsByGameTypeData","jackpotsById","getJackpotsById","updateCurrentJackpotsById","readJackpotsByIdData","subscribe","events","onJackpotsAmountsByGameUpdate","jackpotsAmounts","amounts","Object","keys","reduce","accumulator","jpId","Number","onJackpotsByIdUpdate","jackpots","forEach","gameType","currentJackpotAmountsByGame","useGradualAmountIncrease","jackpotsAddition","jpData","currentJackpotsById","jackpotId","setJackpotData","Check","rawJackpots","jackpotAmounts","AmountInCents","Error","e","logger","error","rawJackpot","Jackpot","lastWinAmount","mustHitTime","String","toString","push","readJackpotState","state","JACKPOT_STATE","jpType","theme","themeName","forClient","ThemeName","JackpotType","ServiceBase"],"sourceRoot":""}