@enigma-lake/mines-play-controller-sdk 1.0.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -4
- package/dist/components/AutoManualPlayStateProvider/AutoManualPlayStateContext.d.ts +5 -0
- package/dist/components/Widgets/Widgets.d.ts +14 -0
- package/dist/components/base/AutoPlayController/enum.d.ts +4 -0
- package/dist/components/base/Button/Button.d.ts +4 -2
- package/dist/components/base/ChevronIcon/ChevronIcon.d.ts +5 -0
- package/dist/components/base/ChevronIcon/index.d.ts +1 -0
- package/dist/components/base/Input/Input.d.ts +1 -1
- package/dist/components/base/InputWithSwitch/InputWithSwitch.d.ts +11 -0
- package/dist/components/base/InputWithSwitch/index.d.ts +1 -0
- package/dist/components/base/PlayController/PlayController.d.ts +1 -10
- package/dist/components/base/PlayValueInput/PlayValueInput.d.ts +8 -0
- package/dist/components/base/PlayValueInput/index.d.ts +1 -0
- package/dist/components/base/PlayValueList/PlayValueList.d.ts +2 -0
- package/dist/components/base/PlayValueList/index.d.ts +1 -0
- package/dist/components/base/SelectMenu/SelectMenu.d.ts +1 -7
- package/dist/components/base/SelectMenu/config.d.ts +3 -0
- package/dist/components/base/Switch/Switch.d.ts +1 -3
- package/dist/components/hooks/usePlayController.d.ts +10 -7
- package/dist/components/utils.d.ts +5 -0
- package/dist/index.d.ts +29 -10
- package/dist/index.mjs +567 -112
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/types/playController.d.ts +10 -10
- package/dist/types/widgets.d.ts +13 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
|
-
import cx from 'classnames';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import cx$1 from 'classnames';
|
|
3
|
+
import React, { createContext, useContext, useMemo, useEffect, Fragment, useRef, useCallback, useState } from 'react';
|
|
4
|
+
import { Switch as Switch$1, Menu, MenuButton, MenuItems, MenuItem } from '@headlessui/react';
|
|
5
|
+
import { Currency, sendSetUserCurrencyEvent, sendSetUserCurrencyEventV2, setToggleGameWidgetsVisibility, setToggleGameWidgetsExpansion, sendOpenHighPlayModalEvent } from '@enigma-lake/zoot-platform-sdk';
|
|
6
|
+
|
|
7
|
+
const hexToRgb = (hex) => {
|
|
8
|
+
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
9
|
+
hex = hex.replace(shorthandRegex, (_, r, g, b) => r + r + g + g + b + b);
|
|
10
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
11
|
+
return result
|
|
12
|
+
? `${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)}`
|
|
13
|
+
: null;
|
|
14
|
+
};
|
|
15
|
+
const selectButton = (gameMode) => {
|
|
16
|
+
const role = `role-${gameMode}-button`;
|
|
17
|
+
const buttons = document.querySelectorAll(`[data-role="${role}"]`);
|
|
18
|
+
return buttons[0];
|
|
19
|
+
};
|
|
20
|
+
const addPressedClass = (gameMode, activeClassName) => {
|
|
21
|
+
const button = selectButton(gameMode);
|
|
22
|
+
if (!button) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!button.classList.contains(activeClassName)) {
|
|
26
|
+
button.classList.add(activeClassName);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const removePressedClass = (gameMode, activeClassName) => {
|
|
30
|
+
const button = selectButton(gameMode);
|
|
31
|
+
if (!button) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (button.classList.contains(activeClassName)) {
|
|
35
|
+
button.classList.remove(activeClassName);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const format = (balance, decimals) => balance?.toFixed(decimals) ?? 0;
|
|
7
39
|
|
|
8
40
|
var GAME_MODE;
|
|
9
41
|
(function (GAME_MODE) {
|
|
@@ -17,28 +49,30 @@ var AUTO_PLAY_STATE;
|
|
|
17
49
|
AUTO_PLAY_STATE["PLAYING"] = "playing";
|
|
18
50
|
})(AUTO_PLAY_STATE || (AUTO_PLAY_STATE = {}));
|
|
19
51
|
|
|
20
|
-
var
|
|
52
|
+
var WIDGET;
|
|
53
|
+
(function (WIDGET) {
|
|
54
|
+
WIDGET["CENTER"] = "center";
|
|
55
|
+
WIDGET["SIDE"] = "side";
|
|
56
|
+
})(WIDGET || (WIDGET = {}));
|
|
57
|
+
|
|
58
|
+
var styles_button = {"base":"Button-module__base___muNxk","base__theme-ghost":"Button-module__base__theme-ghost___I5-LJ","base__theme-primary":"Button-module__base__theme-primary___Zuswb","base__state-disabled":"Button-module__base__state-disabled___EU5tH","buttonPlayAmount":"Button-module__buttonPlayAmount___GMy3F","buttonCashout":"Button-module__buttonCashout___LG-Yr","buttonPlayAmount__active":"Button-module__buttonPlayAmount__active___e0nGe","buttonCashout__active":"Button-module__buttonCashout__active___qnE3h","buttonSweeps":"Button-module__buttonSweeps___0snDQ","buttonSweeps__active":"Button-module__buttonSweeps__active___PXIFH","buttonGold":"Button-module__buttonGold___DAj-d","buttonGold__active":"Button-module__buttonGold__active___vsi7m","buttonDefault":"Button-module__buttonDefault___QENXy","buttonDefault__active":"Button-module__buttonDefault__active___oS6gd","buttonOverride":"Button-module__buttonOverride___jLkKT"};
|
|
21
59
|
|
|
22
60
|
const themes = {
|
|
23
61
|
primary: "primary",
|
|
24
62
|
success: "success",
|
|
25
63
|
ghost: "ghost",
|
|
26
64
|
};
|
|
27
|
-
const Button = ({ disabled, className = "", theme = "primary",
|
|
28
|
-
|
|
29
|
-
const handleOnClick = useCallback((event) => {
|
|
30
|
-
debouncedOnClick(event);
|
|
31
|
-
}, [debouncedOnClick]);
|
|
32
|
-
return (jsx("button", { ...props, className: cx(styles_button.base, styles_button[`base__theme-${theme}`], className, {
|
|
65
|
+
const Button = ({ disabled, roleType, className = "", theme = "primary", ...props }) => {
|
|
66
|
+
return (jsx("button", { ...props, className: cx$1(styles_button.base, styles_button[`base__theme-${theme}`], className, {
|
|
33
67
|
[styles_button["base__state-disabled"]]: disabled,
|
|
34
|
-
}), disabled: disabled,
|
|
68
|
+
}), disabled: disabled, "data-role": `role-${roleType}-button` }));
|
|
35
69
|
};
|
|
36
70
|
Button.themes = themes;
|
|
37
71
|
|
|
38
|
-
var styles_group = {"label":"GroupRow-module__label___Du57P","group":"GroupRow-module__group___V7xa6","groupItem":"GroupRow-module__groupItem___yNSX8","x2":"GroupRow-module__x2___9bLae","last":"GroupRow-module__last___ArsSn"};
|
|
72
|
+
var styles_group = {"base":"GroupRow-module__base___b241-","label":"GroupRow-module__label___Du57P","group":"GroupRow-module__group___V7xa6","groupItem":"GroupRow-module__groupItem___yNSX8","x2":"GroupRow-module__x2___9bLae","last":"GroupRow-module__last___ArsSn"};
|
|
39
73
|
|
|
40
74
|
const GroupRow = ({ children, label, className, ...restProps }) => {
|
|
41
|
-
return (jsxs("div", { ...restProps, className: cx(styles_group.base, className), children: [label && jsx("div", { className: styles_group.label, children: label }), jsx("div", { className: styles_group.group, children: children })] }));
|
|
75
|
+
return (jsxs("div", { ...restProps, className: cx$1(styles_group.base, className), children: [label && jsx("div", { className: styles_group.label, children: label }), jsx("div", { className: styles_group.group, children: children })] }));
|
|
42
76
|
};
|
|
43
77
|
|
|
44
78
|
const ALLOWED_SEPARATORS = [",", "."];
|
|
@@ -61,75 +95,138 @@ function cleanInputNumber(value) {
|
|
|
61
95
|
return `${integerPart}.${decimalPart}`;
|
|
62
96
|
}
|
|
63
97
|
|
|
64
|
-
var styles$
|
|
98
|
+
var styles$4 = {"base":"Input-module__base___IifiA","disabled":"Input-module__disabled___WqyKa"};
|
|
65
99
|
|
|
66
|
-
const Input = ({ onChange, disabled, className, ...restProps }) => {
|
|
67
|
-
const handleChange = useCallback((event) => {
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
onChange?.(event);
|
|
100
|
+
const Input = ({ onChange, disabled, className, max, ...restProps }) => {
|
|
101
|
+
const handleChange = React.useCallback((event) => {
|
|
102
|
+
if (disabled) {
|
|
103
|
+
return;
|
|
71
104
|
}
|
|
72
|
-
|
|
73
|
-
|
|
105
|
+
const cleaned = cleanInputNumber(event.target.value).replace(/\D+/g, "");
|
|
106
|
+
const value = cleaned.slice(0, 2);
|
|
107
|
+
const clamped = value
|
|
108
|
+
? String(Math.min(Number(value), max))
|
|
109
|
+
: "";
|
|
110
|
+
event.target.value = clamped;
|
|
111
|
+
onChange?.(event);
|
|
112
|
+
}, [disabled, max, onChange]);
|
|
113
|
+
return (jsx("input", { ...restProps, type: "text", max: max, inputMode: "numeric", pattern: "\\d*", maxLength: 2, disabled: disabled, onChange: handleChange, className: cx$1(styles$4.base, className, { [styles$4.disabled]: disabled }) }));
|
|
74
114
|
};
|
|
75
115
|
|
|
76
|
-
var styles$
|
|
116
|
+
var styles$3 = {"base":"Switch-module__base___gj2ey","switcher":"Switch-module__switcher___gHXIx","gold":"Switch-module__gold___oewnb","sweeps":"Switch-module__sweeps___yS-IY","unchecked":"Switch-module__unchecked___ooSS2","disabled":"Switch-module__disabled___lMRv0","thumb":"Switch-module__thumb___1wJ9D","move-right":"Switch-module__move-right___ca-6D","label":"Switch-module__label___pG2uz"};
|
|
77
117
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
return
|
|
118
|
+
const AutoManualPlayStateContext = createContext(undefined);
|
|
119
|
+
const useAutoManualPlayState = () => {
|
|
120
|
+
const context = useContext(AutoManualPlayStateContext);
|
|
121
|
+
if (!context) {
|
|
122
|
+
throw new Error("useAutoManualPlayStateState must be used within a AutoManualPlayStateProvider");
|
|
123
|
+
}
|
|
124
|
+
return context;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const Switch = ({ enabled, onSwitch, disabled, isPlaying, }) => {
|
|
128
|
+
const { config } = useAutoManualPlayState();
|
|
129
|
+
const { current } = config.currencyOptions;
|
|
130
|
+
const defaultClassName = useMemo(() => {
|
|
131
|
+
if (current.code === Currency.GOLD) {
|
|
132
|
+
return styles$3.gold;
|
|
133
|
+
}
|
|
134
|
+
if (current.code === Currency.SWEEPS) {
|
|
135
|
+
return styles$3.sweeps;
|
|
136
|
+
}
|
|
137
|
+
return styles$3.default;
|
|
138
|
+
}, [current.code]);
|
|
139
|
+
const switcherClassName = useMemo(() => cx$1(styles$3.switcher, defaultClassName, {
|
|
140
|
+
[styles$3.checked]: enabled,
|
|
141
|
+
[styles$3.unchecked]: !enabled,
|
|
142
|
+
[styles$3.disabled]: disabled,
|
|
143
|
+
}), [defaultClassName, enabled, disabled]);
|
|
144
|
+
useEffect(() => {
|
|
145
|
+
const handleGlobalKeyDown = (event) => {
|
|
146
|
+
const focusedElement = document.activeElement;
|
|
147
|
+
if (event.code === "Space" &&
|
|
148
|
+
focusedElement?.getAttribute("role") === "switch") {
|
|
149
|
+
event.preventDefault();
|
|
150
|
+
event.stopPropagation();
|
|
151
|
+
event.stopImmediatePropagation();
|
|
152
|
+
focusedElement.blur();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
// Attach global event listener
|
|
156
|
+
window.addEventListener("keydown", handleGlobalKeyDown, true);
|
|
157
|
+
// Cleanup event listener on unmount
|
|
158
|
+
return () => {
|
|
159
|
+
window.removeEventListener("keydown", handleGlobalKeyDown, true);
|
|
160
|
+
};
|
|
161
|
+
}, []);
|
|
162
|
+
return (jsx(Switch$1, { checked: enabled, onChange: onSwitch, as: Fragment, disabled: isPlaying, children: jsxs("div", { className: styles$3.base, children: [jsx("span", { className: styles$3.label, children: "Auto" }), jsx("div", { className: switcherClassName, children: jsx("span", { className: cx$1(styles$3.thumb, { [styles$3["move-right"]]: enabled }) }) })] }) }));
|
|
85
163
|
};
|
|
86
164
|
|
|
87
|
-
var
|
|
165
|
+
var style_select = {"button":"SelectMenu-module__button___N-HeB","menu":"SelectMenu-module__menu___c5jvZ","menuItems":"SelectMenu-module__menuItems___BX1YQ","menuItem":"SelectMenu-module__menuItem___eXbi3","selected":"SelectMenu-module__selected___XyADw","disabled":"SelectMenu-module__disabled___jiTPl"};
|
|
88
166
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
167
|
+
var style_chevron = {"chevron":"ChevronIcon-module__chevron___lif8s","open":"ChevronIcon-module__open___niD1n","disable":"ChevronIcon-module__disable___8n-xg"};
|
|
168
|
+
|
|
169
|
+
const ChevronIcon = ({ open, disabled, }) => {
|
|
170
|
+
return (jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "9", height: "5", viewBox: "0 0 9 5", fill: "none", children: jsx("path", { className: cx$1(style_chevron.chevron, {
|
|
171
|
+
[style_chevron.open]: open,
|
|
172
|
+
[style_chevron.disabled]: disabled,
|
|
173
|
+
}), d: "M0.689012 0.1912C0.808821 0.0687748 0.971296 8.20624e-08 1.14071 1.11683e-07C1.31012 1.41304e-07 1.47259 0.0687749 1.5924 0.1912L4.7549 3.42372L7.9174 0.191201C8.0379 0.072246 8.19928 0.00642387 8.3668 0.00791163C8.53431 0.00939939 8.69455 0.0780783 8.81301 0.199156C8.93146 0.320233 8.99865 0.484023 9.00011 0.655246C9.00156 0.826469 8.93717 0.991427 8.82079 1.11459L5.20659 4.8088C5.08678 4.93123 4.92431 5 4.7549 5C4.58549 5 4.42302 4.93123 4.30321 4.8088L0.689012 1.11459C0.569239 0.992127 0.501954 0.826056 0.501954 0.652894C0.501954 0.479733 0.569239 0.313662 0.689012 0.1912Z", fill: "white" }) }));
|
|
95
174
|
};
|
|
96
175
|
|
|
97
176
|
const GoldIcon = () => (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", children: [jsx("path", { opacity: "0.39", d: "M7.41645 14.1044C11.0357 14.1044 13.9697 11.136 13.9697 7.47417C13.9697 3.81236 11.0357 0.843872 7.41645 0.843872C3.79725 0.843872 0.863281 3.81236 0.863281 7.47417C0.863281 11.136 3.79725 14.1044 7.41645 14.1044Z", fill: "#F2BF0B" }), jsx("path", { d: "M7.49933 13.5066C5.90609 13.5066 4.37818 12.8736 3.25163 11.7471C2.12508 10.6205 1.49219 9.09258 1.49219 7.49944C1.49219 5.90626 2.12508 4.37833 3.25163 3.25178C4.37818 2.12523 5.90609 1.49234 7.49933 1.49234C8.32641 1.48979 9.14495 1.6605 9.90213 1.99347C9.92954 2.00654 9.9541 2.02489 9.97447 2.04746C9.99484 2.07003 10.0105 2.0964 10.0207 2.12503C10.0308 2.15367 10.0352 2.18402 10.0336 2.21437C10.032 2.2447 10.0244 2.27444 10.0113 2.30186C9.98737 2.3563 9.94287 2.39903 9.88746 2.42071C9.83205 2.44238 9.77036 2.44123 9.71579 2.4175C9.01511 2.11018 8.25801 1.95261 7.49287 1.95492C6.19268 1.95633 4.93427 2.41409 3.93705 3.24836C2.93984 4.08263 2.26711 5.24047 2.03619 6.51997C1.80527 7.79947 2.03081 9.11941 2.67348 10.2497C3.31615 11.3799 4.33517 12.2487 5.55286 12.7045C6.77048 13.1603 8.10948 13.1743 9.3364 12.7439C10.5632 12.3135 11.6001 11.466 12.2661 10.3494C12.9322 9.23282 13.1852 7.91786 12.9809 6.63384C12.7767 5.34981 12.1281 4.17822 11.1485 3.32338C11.1125 3.28223 11.0928 3.22938 11.0929 3.17472C11.0931 3.12006 11.1132 3.06732 11.1494 3.02638C11.1856 2.98544 11.2355 2.9591 11.2897 2.95227C11.344 2.94544 11.3988 2.9586 11.4441 2.98929C12.3644 3.79366 13.0174 4.85964 13.316 6.04489C13.6146 7.23014 13.5444 8.47827 13.1151 9.62268C12.6857 10.767 11.9174 11.7531 10.9128 12.4495C9.90824 13.1457 8.71519 13.519 7.49287 13.5194L7.49933 13.5066Z", fill: "#F2BF0B" }), jsx("path", { d: "M7.50001 14.6249C6.09085 14.6249 4.71327 14.207 3.54156 13.4241C2.36986 12.6412 1.45664 11.5284 0.91736 10.2265C0.378089 8.92454 0.236989 7.49197 0.511905 6.10986C0.78683 4.72775 1.46542 3.45819 2.46187 2.46175C3.45832 1.4653 4.72787 0.786705 6.10996 0.511786C7.49213 0.236866 8.92467 0.377965 10.2266 0.91724C11.5286 1.45651 12.6413 2.36974 13.4242 3.54145C14.2071 4.71314 14.625 6.09069 14.625 7.49988C14.6233 9.38901 13.8721 11.2003 12.5363 12.5362C11.2004 13.872 9.38914 14.6232 7.50001 14.6249ZM7.50001 1.01735C6.21784 1.01735 4.96455 1.39754 3.8985 2.10986C2.83246 2.82216 2.00158 3.83459 1.51093 5.01912C1.02028 6.20365 0.891903 7.50707 1.14203 8.76452C1.39216 10.022 2.00956 11.1771 2.91617 12.0837C3.82276 12.9903 4.97784 13.6077 6.23536 13.8578C7.4928 14.1079 8.79625 13.9796 9.98076 13.489C11.1653 12.9983 12.1777 12.1674 12.89 11.1014C13.6024 10.0354 13.9825 8.78204 13.9825 7.49988C13.9791 5.78165 13.2951 4.13477 12.0801 2.91979C10.8651 1.70481 9.21822 1.02075 7.50001 1.01735Z", fill: "#F2BF0B" }), jsx("path", { d: "M10.1591 10.5131C9.43158 10.7452 8.6739 10.8686 7.91043 10.8794C6.91972 10.9596 5.93706 10.6482 5.17347 10.012C4.86218 9.70525 4.61761 9.33743 4.45509 8.93173C4.29258 8.52596 4.21562 8.09104 4.22904 7.65417C4.22904 5.37982 5.94443 4.22981 8.08386 4.22981C8.72897 4.20483 9.37215 4.31423 9.97274 4.55104L9.61934 5.95163C9.13325 5.7425 8.60617 5.64587 8.07741 5.66894C7.8189 5.63999 7.55711 5.6683 7.31067 5.75187C7.06423 5.83544 6.83925 5.9722 6.65165 6.15248C6.46397 6.33274 6.31837 6.5521 6.22499 6.79497C6.13161 7.03784 6.09288 7.29828 6.11149 7.5578C6.0892 7.80993 6.12113 8.0639 6.20512 8.30265C6.2892 8.5414 6.42332 8.75939 6.59859 8.94195C6.77387 9.12461 6.98628 9.26753 7.2214 9.36124C7.45653 9.45496 7.709 9.4972 7.96181 9.48522C8.14782 9.49377 8.33407 9.47423 8.51429 9.42738V8.29664H7.60841V6.94745H10.1783L10.1591 10.5131Z", fill: "#F2BF0B" })] }));
|
|
98
177
|
|
|
99
178
|
const SweepsIcon = () => (jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", children: [jsx("path", { opacity: "0.39", d: "M7.41174 14.4521C11.2215 14.4521 14.3099 11.3275 14.3099 7.47291C14.3099 3.61837 11.2215 0.493652 7.41174 0.493652C3.60206 0.493652 0.513672 3.61837 0.513672 7.47291C0.513672 11.3275 3.60206 14.4521 7.41174 14.4521Z", fill: "#0DE83D" }), jsx("path", { d: "M8.35827 6.34123C8.33727 6.1169 8.25066 5.94313 8.09843 5.81991C7.94619 5.6951 7.75459 5.6327 7.52362 5.6327C7.35827 5.6327 7.21522 5.6643 7.09449 5.72749C6.97375 5.7891 6.87992 5.87441 6.81299 5.98341C6.74738 6.09084 6.71457 6.21327 6.71457 6.35071C6.71457 6.46603 6.73688 6.56556 6.7815 6.64929C6.82743 6.73302 6.88714 6.80332 6.96063 6.86019C7.03543 6.91548 7.11549 6.96209 7.20079 7C7.28609 7.03633 7.36811 7.06635 7.44685 7.09005L7.84055 7.21327C7.96916 7.25118 8.10105 7.30253 8.23622 7.3673C8.37139 7.43207 8.49672 7.51738 8.6122 7.62322C8.72769 7.72907 8.82087 7.86019 8.89173 8.01659C8.96391 8.17299 9 8.36019 9 8.5782C9 8.85308 8.94094 9.09716 8.82283 9.31043C8.70604 9.5237 8.53609 9.69194 8.31299 9.81517C8.09121 9.93839 7.82283 10 7.50787 10C7.20604 10 6.94488 9.94234 6.72441 9.82701C6.50394 9.71169 6.33136 9.54818 6.20669 9.33649C6.08202 9.12322 6.01312 8.87046 6 8.5782H6.61024C6.62205 8.75355 6.66929 8.89968 6.75197 9.01659C6.83596 9.13191 6.94291 9.21801 7.07283 9.27488C7.20407 9.33017 7.34777 9.35782 7.50394 9.35782C7.67585 9.35782 7.82874 9.32543 7.9626 9.26066C8.09777 9.19431 8.20407 9.10269 8.2815 8.98578C8.35892 8.8673 8.39764 8.72907 8.39764 8.57109C8.39764 8.42733 8.36352 8.30964 8.29528 8.21801C8.22835 8.12638 8.13714 8.05055 8.02165 7.99052C7.90748 7.93049 7.77822 7.87757 7.63386 7.83175L7.15748 7.67536C6.83465 7.56951 6.57874 7.4139 6.38976 7.20853C6.2021 7.00316 6.10827 6.73144 6.10827 6.39336C6.10827 6.11374 6.17126 5.86967 6.29724 5.66114C6.42323 5.45261 6.59383 5.29068 6.80906 5.17536C7.02428 5.05845 7.26706 5 7.5374 5C7.81037 5 8.05118 5.05766 8.25984 5.17299C8.46982 5.28831 8.63517 5.44708 8.75591 5.64929C8.87664 5.84992 8.93963 6.08057 8.94488 6.34123H8.35827Z", fill: "#0DE83D" }), jsx("path", { d: "M7.50006 13.8228C5.82297 13.8228 4.21465 13.1566 3.0288 11.9708C1.84296 10.7849 1.17676 9.17656 1.17676 7.49957C1.17676 5.82253 1.84296 4.21419 3.0288 3.02834C4.21465 1.8425 5.82297 1.1763 7.50006 1.1763C8.37068 1.17362 9.2323 1.35331 10.0293 1.7038C10.0582 1.71756 10.084 1.73688 10.1055 1.76064C10.1269 1.7844 10.1434 1.81215 10.1541 1.84229C10.1648 1.87244 10.1694 1.90439 10.1677 1.93633C10.166 1.96826 10.1581 1.99956 10.1443 2.02842C10.1191 2.08573 10.0722 2.13071 10.0139 2.15353C9.95556 2.17634 9.89062 2.17513 9.83318 2.15015C9.09562 1.82665 8.29868 1.6608 7.49327 1.66323C6.12465 1.66471 4.8 2.14656 3.7503 3.02474C2.7006 3.90292 1.99247 5.1217 1.74939 6.46855C1.50632 7.81539 1.74373 9.20479 2.42022 10.3946C3.09672 11.5842 4.16937 12.4988 5.45115 12.9786C6.73285 13.4583 8.14233 13.4731 9.43383 13.02C10.7252 12.567 11.8167 11.6749 12.5177 10.4996C13.2189 9.32417 13.4851 7.94001 13.2701 6.5884C13.0552 5.2368 12.3725 4.00354 11.3413 3.10371C11.3034 3.0604 11.2826 3.00476 11.2828 2.94723C11.283 2.88969 11.3041 2.83418 11.3423 2.79108C11.3804 2.74799 11.4329 2.72026 11.49 2.71307C11.5471 2.70588 11.6048 2.71974 11.6524 2.75204C12.6211 3.59875 13.3086 4.72083 13.6229 5.96845C13.9372 7.21609 13.8633 8.52992 13.4114 9.73456C12.9594 10.9391 12.1507 11.9771 11.0932 12.7101C10.0358 13.443 8.77991 13.8359 7.49327 13.8363L7.50006 13.8228Z", fill: "#0DE83D" }), jsx("path", { d: "M7.50001 15C6.01668 15 4.5666 14.5601 3.33323 13.736C2.09986 12.9119 1.13857 11.7406 0.570905 10.3701C0.00325189 8.99965 -0.145274 7.49168 0.144111 6.03682C0.433505 4.58197 1.14781 3.24559 2.1967 2.19671C3.2456 1.14781 4.58197 0.433502 6.0368 0.144114C7.49171 -0.145275 8.99965 0.00324947 10.3701 0.570907C11.7406 1.13856 12.9119 2.09986 13.736 3.33323C14.5602 4.56659 15 6.01664 15 7.5C14.9982 9.48856 14.2075 11.3951 12.8014 12.8014C11.3952 14.2075 9.48857 14.9982 7.50001 15ZM7.50001 0.676288C6.15036 0.676288 4.83111 1.07649 3.70895 1.82629C2.5868 2.57609 1.71218 3.64181 1.19572 4.88868C0.679241 6.13555 0.544108 7.50757 0.807402 8.83121C1.0707 10.1549 1.72059 11.3708 2.67491 12.3251C3.62922 13.2794 4.84509 13.9293 6.1688 14.1926C7.49242 14.4559 8.86448 14.3208 10.1113 13.8043C11.3582 13.2878 12.4239 12.4132 13.1737 11.291C13.9235 10.1689 14.3237 8.84965 14.3237 7.5C14.3202 5.69134 13.6001 3.95778 12.3212 2.67886C11.0422 1.39993 9.30865 0.679862 7.50001 0.676288Z", fill: "#0DE83D" })] }));
|
|
100
179
|
|
|
101
|
-
|
|
180
|
+
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
181
|
+
const getIcon = (option) => {
|
|
182
|
+
if (option.code === Currency.GOLD) {
|
|
183
|
+
return GoldIcon;
|
|
184
|
+
}
|
|
185
|
+
if (option.code === Currency.SWEEPS) {
|
|
186
|
+
return SweepsIcon;
|
|
187
|
+
}
|
|
188
|
+
return option.icon;
|
|
189
|
+
};
|
|
102
190
|
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const
|
|
191
|
+
const SelectMenu = ({ disabled = false }) => {
|
|
192
|
+
const { config } = useAutoManualPlayState();
|
|
193
|
+
const { current, available } = config.currencyOptions;
|
|
194
|
+
const handleClick = (e) => {
|
|
107
195
|
if (disabled) {
|
|
108
196
|
return;
|
|
109
197
|
}
|
|
110
|
-
|
|
198
|
+
const target = e.target;
|
|
199
|
+
const value = target.dataset.value;
|
|
200
|
+
if (!value) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const newCurrency = available.find((d) => d.code === value);
|
|
204
|
+
if (newCurrency) {
|
|
205
|
+
sendSetUserCurrencyEvent({ currency: newCurrency.code });
|
|
206
|
+
sendSetUserCurrencyEventV2({ current: newCurrency, available });
|
|
207
|
+
}
|
|
111
208
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const AutoManualPlayStateContext = createContext(undefined);
|
|
118
|
-
const useAutoManualPlayState = () => {
|
|
119
|
-
const context = useContext(AutoManualPlayStateContext);
|
|
120
|
-
if (!context) {
|
|
121
|
-
throw new Error("useAutoManualPlayStateState must be used within a AutoManualPlayStateProvider");
|
|
209
|
+
const ButtonIcon = getIcon(current);
|
|
210
|
+
if (available.length === 1) {
|
|
211
|
+
return (jsx("div", { className: cx$1(style_select.button), children: ButtonIcon && jsx(ButtonIcon, {}) }));
|
|
122
212
|
}
|
|
123
|
-
return
|
|
213
|
+
return (jsx(Menu, { as: "div", className: cx$1(style_select.menu), children: ({ open }) => (jsxs(Fragment$1, { children: [jsxs(MenuButton, { className: cx$1(style_select.button, {
|
|
214
|
+
[style_select.disabled]: disabled,
|
|
215
|
+
}), disabled: disabled, as: "div", children: [ButtonIcon && jsx(ButtonIcon, {}), jsx(ChevronIcon, { open: open, disabled: disabled })] }), jsx(MenuItems, { anchor: { to: "top start" }, className: cx$1(style_select.menuItems), children: available.map((option) => {
|
|
216
|
+
const Icon = getIcon(option);
|
|
217
|
+
return (jsxs(MenuItem, { as: "div", "data-value": option.code, onClick: handleClick, className: cx$1(style_select.menuItem, {
|
|
218
|
+
[style_select.selected]: String(current.code) === String(option.code),
|
|
219
|
+
}), children: [Icon && jsx(Icon, {}), capitalize(String(option.label))] }, `element-${option.code}`));
|
|
220
|
+
}) })] })) }));
|
|
124
221
|
};
|
|
125
222
|
|
|
126
223
|
const usePlayController = () => {
|
|
127
|
-
const { config, autoPlay: { setNumberOfPlays, numberOfPlays, setPlayedRounds, playedRounds, selection, setState, state, }, } = useAutoManualPlayState();
|
|
128
|
-
const {
|
|
224
|
+
const { config, autoPlay: { setNumberOfPlays, numberOfPlays, setPlayedRounds, playedRounds, selection, setState, state, }, playValues: { displayPlayAmountView, setDisplayPlayAmountView, togglePlayAmountView, }, } = useAutoManualPlayState();
|
|
225
|
+
const { current } = config.currencyOptions;
|
|
129
226
|
const { isPlaying, canCashout, disabledController, showAutoPlayToast, autoPlayDelay = 1500, playHook, } = config.playOptions;
|
|
130
227
|
const { playAmount, playLimits, setPlayAmount } = playHook?.() ?? {};
|
|
131
|
-
const minPlayAmount = playLimits?.[
|
|
132
|
-
const maxPlayAmount = playLimits?.[
|
|
228
|
+
const minPlayAmount = playLimits?.[current.code]?.limits.min ?? 0;
|
|
229
|
+
const maxPlayAmount = playLimits?.[current.code]?.limits.max ?? 0;
|
|
133
230
|
const playIntervalRef = useRef(null);
|
|
134
231
|
const isAutoplayActiveRef = useRef(false);
|
|
135
232
|
const stopAutoplay = () => {
|
|
@@ -142,6 +239,8 @@ const usePlayController = () => {
|
|
|
142
239
|
setTimeout(() => {
|
|
143
240
|
setPlayedRounds(0);
|
|
144
241
|
}, 1500);
|
|
242
|
+
// Call the onAutoPlayStop callback if provided
|
|
243
|
+
config.onAutoPlayStop?.();
|
|
145
244
|
};
|
|
146
245
|
const loopRounds = (currentPlayedRounds, remainingPlays) => {
|
|
147
246
|
if (!isAutoplayActiveRef.current) {
|
|
@@ -159,7 +258,7 @@ const usePlayController = () => {
|
|
|
159
258
|
return;
|
|
160
259
|
}
|
|
161
260
|
playIntervalRef.current = setTimeout(() => loopRounds(currentPlayedRounds + 1, remainingPlays - 1), autoPlayDelay);
|
|
162
|
-
}, stopAutoplay);
|
|
261
|
+
}, stopAutoplay, state);
|
|
163
262
|
};
|
|
164
263
|
const handleAutoPlay = () => {
|
|
165
264
|
if (disabledController) {
|
|
@@ -178,39 +277,53 @@ const usePlayController = () => {
|
|
|
178
277
|
};
|
|
179
278
|
const isDisabled = () => disabledController || isPlaying;
|
|
180
279
|
const isAutoplayDisabled = () => disabledController || state === AUTO_PLAY_STATE.PLAYING;
|
|
181
|
-
const adjustPlayAmount = (
|
|
280
|
+
const adjustPlayAmount = ({ direction }) => {
|
|
182
281
|
if (isDisabled()) {
|
|
183
282
|
return;
|
|
184
283
|
}
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
};
|
|
188
|
-
const onChangeAmount = (event) => {
|
|
189
|
-
if (isDisabled()) {
|
|
284
|
+
const opts = playLimits?.[current.code]?.defaultBetOptions ?? [];
|
|
285
|
+
if (!opts.length) {
|
|
190
286
|
return;
|
|
191
287
|
}
|
|
192
|
-
|
|
288
|
+
// Ensure options sorted ascending
|
|
289
|
+
const sorted = [...opts].sort((a, b) => a - b);
|
|
290
|
+
const currentIndex = sorted.findIndex((o) => o === playAmount);
|
|
291
|
+
let newAmount;
|
|
292
|
+
if (currentIndex === -1) {
|
|
293
|
+
// if current isn't exactly in list, insert it logically
|
|
294
|
+
sorted.push(playAmount);
|
|
295
|
+
sorted.sort((a, b) => a - b);
|
|
296
|
+
const idx = sorted.indexOf(playAmount);
|
|
297
|
+
newAmount = sorted[idx + direction] ?? playAmount;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
const targetIdx = currentIndex + direction;
|
|
301
|
+
if (targetIdx >= 0 && targetIdx < sorted.length) {
|
|
302
|
+
newAmount = sorted[targetIdx];
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
// clamp if out of bounds
|
|
306
|
+
newAmount = sorted[currentIndex];
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
setPlayAmount(newAmount);
|
|
193
310
|
};
|
|
194
|
-
const
|
|
311
|
+
const onChangeAmount = (playValue) => {
|
|
195
312
|
if (isDisabled()) {
|
|
196
313
|
return;
|
|
197
314
|
}
|
|
198
|
-
|
|
199
|
-
setPlayAmount(Math.max(minPlayAmount, Math.min(newAmount, maxPlayAmount)));
|
|
315
|
+
setPlayAmount(playValue);
|
|
200
316
|
};
|
|
201
317
|
const isValidPlayAmount = playAmount >= minPlayAmount && playAmount <= maxPlayAmount;
|
|
202
318
|
return {
|
|
203
|
-
currentCurrency,
|
|
204
|
-
currencies,
|
|
205
319
|
playAmount,
|
|
206
320
|
minPlayAmount,
|
|
207
321
|
maxPlayAmount,
|
|
208
322
|
setPlayAmount,
|
|
209
323
|
adjustPlayAmount,
|
|
210
324
|
onChangeAmount,
|
|
211
|
-
onBlurAmount,
|
|
212
325
|
isValidPlayAmount,
|
|
213
|
-
|
|
326
|
+
totalBalance: config.playOptions.totalBalance,
|
|
214
327
|
manualPlay: {
|
|
215
328
|
isDisabled,
|
|
216
329
|
onPlay: config.onPlay,
|
|
@@ -222,39 +335,367 @@ const usePlayController = () => {
|
|
|
222
335
|
onPlay: handleAutoPlay,
|
|
223
336
|
onStopPlay: stopAutoplay,
|
|
224
337
|
},
|
|
338
|
+
playValues: {
|
|
339
|
+
displayPlayAmountView,
|
|
340
|
+
setDisplayPlayAmountView,
|
|
341
|
+
togglePlayAmountView,
|
|
342
|
+
},
|
|
225
343
|
};
|
|
226
344
|
};
|
|
227
345
|
|
|
228
|
-
|
|
229
|
-
const PLAY_DOUBLE = 2;
|
|
346
|
+
var styles$2 = {"base":"PlayValueInput-module__base___sTNW2","icon":"PlayValueInput-module__icon___jZj7O","playValueInput":"PlayValueInput-module__playValueInput___7pJtn","playValueInputWithLabel":"PlayValueInput-module__playValueInputWithLabel___S55Cr","label":"PlayValueInput-module__label___1ZSAV","inputContainer":"PlayValueInput-module__inputContainer___RKr1l","playValueWithLabel":"PlayValueInput-module__playValueWithLabel___K4-pr"};
|
|
230
347
|
|
|
231
|
-
const
|
|
348
|
+
const PlayValueInput = ({ disabled, children, className, value, onClick, }) => {
|
|
349
|
+
const handleOnClick = () => {
|
|
350
|
+
if (disabled) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
onClick();
|
|
354
|
+
};
|
|
355
|
+
return (jsxs("div", { className: cx$1(styles$2.base, className, {
|
|
356
|
+
[styles$2.disabled]: disabled,
|
|
357
|
+
}), children: [children && jsx("div", { className: cx$1(styles$2.icon), children: children }), jsxs("div", { className: cx$1(styles$2.inputContainer), onClick: (e) => {
|
|
358
|
+
e.preventDefault();
|
|
359
|
+
handleOnClick();
|
|
360
|
+
}, children: [jsx("span", { className: styles$2.label, children: "Play amount" }), jsx("div", { className: cx$1(styles$2.playValueInput, {
|
|
361
|
+
[styles$2.playValueInputWithLabel]: true,
|
|
362
|
+
}), children: value })] })] }));
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
const PlayAmountControl = ({ isDisabled }) => {
|
|
366
|
+
const { config } = useAutoManualPlayState();
|
|
367
|
+
const { playAmount, adjustPlayAmount, playValues: { togglePlayAmountView }, autoPlay: { state }, } = usePlayController();
|
|
368
|
+
const handleTogglePlayAmount = () => {
|
|
369
|
+
setToggleGameWidgetsVisibility();
|
|
370
|
+
togglePlayAmountView();
|
|
371
|
+
setToggleGameWidgetsExpansion();
|
|
372
|
+
};
|
|
373
|
+
return (jsxs(GroupRow, { children: [jsx(PlayValueInput, { className: styles_group.groupItem, value: `${playAmount} ${config.currencyOptions.current.abbr}`, disabled: isDisabled() ||
|
|
374
|
+
config.playOptions.disabledController ||
|
|
375
|
+
state === AUTO_PLAY_STATE.PLAYING, onClick: handleTogglePlayAmount, children: jsx(SelectMenu, { disabled: isDisabled() }) }), jsx(Button, { className: styles_group.groupItem, onClick: () => adjustPlayAmount({ direction: -1 }), theme: "ghost", disabled: isDisabled(), children: jsx("span", { className: styles_group.x2, children: "-" }) }), jsx(Button, { className: styles_group.groupItem, onClick: () => adjustPlayAmount({ direction: 1 }), theme: "ghost", disabled: isDisabled(), children: jsx("span", { className: cx$1(styles_group.x2, styles_group.last), children: "+" }) })] }));
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
var AUTOPLAY_LABEL;
|
|
379
|
+
(function (AUTOPLAY_LABEL) {
|
|
380
|
+
AUTOPLAY_LABEL["START"] = "START AUTOPLAY";
|
|
381
|
+
AUTOPLAY_LABEL["STOP"] = "STOP AUTOPLAY";
|
|
382
|
+
})(AUTOPLAY_LABEL || (AUTOPLAY_LABEL = {}));
|
|
232
383
|
|
|
233
384
|
const AutoPlayController = () => {
|
|
234
|
-
const {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
385
|
+
const { config } = useAutoManualPlayState();
|
|
386
|
+
const { isValidPlayAmount, playValues: { displayPlayAmountView, togglePlayAmountView }, autoPlay: { isDisabled, state, onPlay, onStopPlay }, } = usePlayController();
|
|
387
|
+
const { current } = config.currencyOptions;
|
|
388
|
+
const roleButton = GAME_MODE.AUTOPLAY;
|
|
389
|
+
const buttonLabel = state === AUTO_PLAY_STATE.PLAYING
|
|
390
|
+
? AUTOPLAY_LABEL.STOP
|
|
391
|
+
: AUTOPLAY_LABEL.START;
|
|
392
|
+
const activeClassName = useMemo(() => {
|
|
393
|
+
if (current.code === Currency.GOLD) {
|
|
394
|
+
return styles_button.buttonGold__active;
|
|
395
|
+
}
|
|
396
|
+
if (current.code === Currency.SWEEPS) {
|
|
397
|
+
return styles_button.buttonSweeps__active;
|
|
398
|
+
}
|
|
399
|
+
return styles_button.buttonDefault__active;
|
|
400
|
+
}, [current.code]);
|
|
401
|
+
const defaultClassName = useMemo(() => {
|
|
402
|
+
if (buttonLabel === AUTOPLAY_LABEL.STOP) {
|
|
403
|
+
return styles_button.buttonCashout;
|
|
404
|
+
}
|
|
405
|
+
if (current.code === Currency.GOLD) {
|
|
406
|
+
return styles_button.buttonGold;
|
|
407
|
+
}
|
|
408
|
+
if (current.code === Currency.SWEEPS) {
|
|
409
|
+
return styles_button.buttonSweeps;
|
|
410
|
+
}
|
|
411
|
+
return styles_button.buttonDefault;
|
|
412
|
+
}, [buttonLabel, current.code]);
|
|
413
|
+
const handleKeyPress = useCallback((event) => {
|
|
414
|
+
if (event.code !== "Space") {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const button = selectButton(roleButton);
|
|
418
|
+
if (!button) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
event.preventDefault();
|
|
422
|
+
event.stopPropagation();
|
|
423
|
+
const canTrigger = !isDisabled() || state === AUTO_PLAY_STATE.PLAYING;
|
|
424
|
+
if (canTrigger) {
|
|
425
|
+
addPressedClass(roleButton, activeClassName);
|
|
426
|
+
button.click();
|
|
427
|
+
}
|
|
428
|
+
}, [activeClassName, isDisabled, roleButton, state]);
|
|
429
|
+
const handleKeyUp = useCallback((event) => {
|
|
430
|
+
if (event.code !== "Space") {
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
const button = selectButton(roleButton);
|
|
434
|
+
if (!button) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
event.preventDefault();
|
|
438
|
+
event.stopPropagation();
|
|
439
|
+
removePressedClass(roleButton, activeClassName);
|
|
440
|
+
}, [activeClassName, roleButton]);
|
|
441
|
+
useEffect(() => {
|
|
442
|
+
window.addEventListener("keydown", handleKeyPress, true);
|
|
443
|
+
window.addEventListener("keyup", handleKeyUp, true);
|
|
444
|
+
return () => {
|
|
445
|
+
window.removeEventListener("keydown", handleKeyPress, true);
|
|
446
|
+
window.removeEventListener("keyup", handleKeyUp, true);
|
|
447
|
+
};
|
|
448
|
+
}, [handleKeyPress, handleKeyUp]);
|
|
449
|
+
const isButtonDisabled = state === AUTO_PLAY_STATE.PLAYING
|
|
450
|
+
? false
|
|
451
|
+
: isDisabled() || !isValidPlayAmount;
|
|
452
|
+
const buttonAction = state === AUTO_PLAY_STATE.PLAYING ? onStopPlay : onPlay;
|
|
453
|
+
const renderButton = useMemo(() => {
|
|
454
|
+
if (displayPlayAmountView) {
|
|
455
|
+
return (jsx(Button, { className: styles_button.buttonPlayAmount, onClick: togglePlayAmountView, roleType: roleButton, children: "SELECT PLAY AMOUNT" }));
|
|
456
|
+
}
|
|
457
|
+
return (jsx(Button, { disabled: isButtonDisabled, className: defaultClassName, onClick: buttonAction, roleType: roleButton, children: buttonLabel }));
|
|
458
|
+
}, [
|
|
459
|
+
buttonAction,
|
|
460
|
+
buttonLabel,
|
|
461
|
+
defaultClassName,
|
|
462
|
+
displayPlayAmountView,
|
|
463
|
+
isButtonDisabled,
|
|
464
|
+
roleButton,
|
|
465
|
+
togglePlayAmountView,
|
|
466
|
+
]);
|
|
467
|
+
return (jsxs(Fragment$1, { children: [jsx(PlayAmountControl, { isDisabled: isDisabled }), renderButton] }));
|
|
238
468
|
};
|
|
239
469
|
|
|
240
470
|
const ManualPlayController = () => {
|
|
241
471
|
const { config } = useAutoManualPlayState();
|
|
242
|
-
const {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
472
|
+
const { isValidPlayAmount, playValues: { displayPlayAmountView, togglePlayAmountView }, manualPlay: { isDisabled, onPlay, canCashout }, } = usePlayController();
|
|
473
|
+
const { current } = config.currencyOptions;
|
|
474
|
+
const roleButton = GAME_MODE.MANUAL;
|
|
475
|
+
const activeClassName = useMemo(() => {
|
|
476
|
+
if (current.code === Currency.GOLD) {
|
|
477
|
+
return styles_button.buttonGold__active;
|
|
478
|
+
}
|
|
479
|
+
if (current.code === Currency.SWEEPS) {
|
|
480
|
+
return styles_button.buttonSweeps__active;
|
|
481
|
+
}
|
|
482
|
+
return styles_button.buttonDefault__active;
|
|
483
|
+
}, [current.code]);
|
|
484
|
+
const defaultClassName = useMemo(() => {
|
|
485
|
+
if (current.code === Currency.GOLD) {
|
|
486
|
+
return styles_button.buttonGold;
|
|
487
|
+
}
|
|
488
|
+
if (current.code === Currency.SWEEPS) {
|
|
489
|
+
return styles_button.buttonSweeps;
|
|
490
|
+
}
|
|
491
|
+
return styles_button.buttonDefault;
|
|
492
|
+
}, [current.code]);
|
|
493
|
+
const handleKeyPress = useCallback((event) => {
|
|
494
|
+
if (event.code !== "Space") {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const button = selectButton(roleButton);
|
|
498
|
+
if (!button || isDisabled()) {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
event.preventDefault();
|
|
502
|
+
event.stopPropagation();
|
|
503
|
+
addPressedClass(roleButton, activeClassName);
|
|
504
|
+
button.click();
|
|
505
|
+
}, [roleButton, isDisabled, activeClassName]);
|
|
506
|
+
const handleKeyUp = useCallback((event) => {
|
|
507
|
+
if (event.code !== "Space") {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
const button = selectButton(roleButton);
|
|
511
|
+
if (!button) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
event.preventDefault();
|
|
515
|
+
event.stopPropagation();
|
|
516
|
+
removePressedClass(roleButton, activeClassName);
|
|
517
|
+
}, [roleButton, activeClassName]);
|
|
518
|
+
useEffect(() => {
|
|
519
|
+
window.addEventListener("keydown", handleKeyPress, true);
|
|
520
|
+
window.addEventListener("keyup", handleKeyUp, true);
|
|
521
|
+
return () => {
|
|
522
|
+
window.removeEventListener("keydown", handleKeyPress, true);
|
|
523
|
+
window.removeEventListener("keyup", handleKeyUp, true);
|
|
524
|
+
};
|
|
525
|
+
}, [handleKeyPress, handleKeyUp]);
|
|
526
|
+
const isButtonDisabled = isDisabled() || !isValidPlayAmount;
|
|
527
|
+
const renderButton = useMemo(() => {
|
|
528
|
+
if (displayPlayAmountView) {
|
|
529
|
+
return (jsx(Button, { className: styles_button.buttonPlayAmount, onClick: togglePlayAmountView, roleType: roleButton, children: "SELECT PLAY AMOUNT" }));
|
|
530
|
+
}
|
|
531
|
+
if (canCashout) {
|
|
532
|
+
return (jsxs(Button, { disabled: config.playOptions.disabledController ||
|
|
533
|
+
!config.playOptions.isPlaying, className: styles_button.buttonCashout, onClick: config.onCashout, roleType: roleButton, children: ["CASHOUT ", format(current.possibleWin ?? 0, current.decimals), " ", current.abbr] }));
|
|
534
|
+
}
|
|
535
|
+
return (jsx(Button, { disabled: isButtonDisabled, className: defaultClassName, onClick: onPlay, roleType: roleButton, children: "PLAY NOW" }));
|
|
536
|
+
}, [
|
|
537
|
+
canCashout,
|
|
538
|
+
config.onCashout,
|
|
539
|
+
config.playOptions.disabledController,
|
|
540
|
+
config.playOptions.isPlaying,
|
|
541
|
+
current,
|
|
542
|
+
defaultClassName,
|
|
543
|
+
displayPlayAmountView,
|
|
544
|
+
isButtonDisabled,
|
|
545
|
+
onPlay,
|
|
546
|
+
roleButton,
|
|
547
|
+
togglePlayAmountView,
|
|
548
|
+
]);
|
|
549
|
+
return (jsxs(Fragment$1, { children: [jsx(PlayAmountControl, { isDisabled: isDisabled || displayPlayAmountView }), renderButton] }));
|
|
247
550
|
};
|
|
248
551
|
|
|
249
|
-
var styles_ui = {"base":"UI-module__base___wThyQ","betForm":"UI-module__betForm___hQkYd","disabled":"UI-module__disabled___dnZJX"};
|
|
552
|
+
var styles_ui = {"base":"UI-module__base___wThyQ","container":"UI-module__container___gMSiK","betForm":"UI-module__betForm___hQkYd","disabled":"UI-module__disabled___dnZJX","auto":"UI-module__auto___5peb8","controllerWidgets":"UI-module__controllerWidgets___x2lBy","sideWidget":"UI-module__sideWidget___WMGRy","centerWidget":"UI-module__centerWidget___sLLUi","left":"UI-module__left___1wtUp","center":"UI-module__center___E0ILH","right":"UI-module__right___yLHvk"};
|
|
250
553
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
554
|
+
function getDefaultExportFromCjs (x) {
|
|
555
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
var bind = {exports: {}};
|
|
559
|
+
|
|
560
|
+
/*!
|
|
561
|
+
Copyright (c) 2018 Jed Watson.
|
|
562
|
+
Licensed under the MIT License (MIT), see
|
|
563
|
+
http://jedwatson.github.io/classnames
|
|
564
|
+
*/
|
|
565
|
+
|
|
566
|
+
var hasRequiredBind;
|
|
567
|
+
|
|
568
|
+
function requireBind () {
|
|
569
|
+
if (hasRequiredBind) return bind.exports;
|
|
570
|
+
hasRequiredBind = 1;
|
|
571
|
+
(function (module) {
|
|
572
|
+
/* global define */
|
|
573
|
+
|
|
574
|
+
(function () {
|
|
575
|
+
|
|
576
|
+
var hasOwn = {}.hasOwnProperty;
|
|
577
|
+
|
|
578
|
+
function classNames () {
|
|
579
|
+
var classes = '';
|
|
580
|
+
|
|
581
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
582
|
+
var arg = arguments[i];
|
|
583
|
+
if (arg) {
|
|
584
|
+
classes = appendClass(classes, parseValue.call(this, arg));
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
return classes;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
function parseValue (arg) {
|
|
592
|
+
if (typeof arg === 'string' || typeof arg === 'number') {
|
|
593
|
+
return this && this[arg] || arg;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if (typeof arg !== 'object') {
|
|
597
|
+
return '';
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
if (Array.isArray(arg)) {
|
|
601
|
+
return classNames.apply(this, arg);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {
|
|
605
|
+
return arg.toString();
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
var classes = '';
|
|
609
|
+
|
|
610
|
+
for (var key in arg) {
|
|
611
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
612
|
+
classes = appendClass(classes, this && this[key] || key);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
return classes;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
function appendClass (value, newClass) {
|
|
620
|
+
if (!newClass) {
|
|
621
|
+
return value;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
if (value) {
|
|
625
|
+
return value + ' ' + newClass;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
return value + newClass;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
if (module.exports) {
|
|
632
|
+
classNames.default = classNames;
|
|
633
|
+
module.exports = classNames;
|
|
634
|
+
} else {
|
|
635
|
+
window.classNames = classNames;
|
|
636
|
+
}
|
|
637
|
+
}());
|
|
638
|
+
} (bind));
|
|
639
|
+
return bind.exports;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
var bindExports = requireBind();
|
|
643
|
+
var cn = /*@__PURE__*/getDefaultExportFromCjs(bindExports);
|
|
644
|
+
|
|
645
|
+
const cx = cn.bind(styles_ui);
|
|
646
|
+
const WidgetContainer = ({ state, widgets, displayPlayAmountView, }) => {
|
|
647
|
+
const { left = [], center = [], right = [] } = widgets ?? {};
|
|
648
|
+
const renderZone = (items, zone) => {
|
|
649
|
+
const containerClass = zone === "center" ? cx("centerWidget") : cx("sideWidget");
|
|
650
|
+
return (jsx("div", { className: cx(containerClass, zone), children: items.map((widget) => widget.renderElement({ state, displayPlayAmountView })) }));
|
|
651
|
+
};
|
|
652
|
+
return (jsxs("div", { className: cx("controllerWidgets"), children: [renderZone(left, "left"), renderZone(center, "center"), renderZone(right, "right")] }));
|
|
653
|
+
};
|
|
654
|
+
|
|
655
|
+
var styles$1 = {"base":"PlayValueList-module__base___5duc6","playValuesWrapper":"PlayValueList-module__playValuesWrapper___-zfj2","playValue":"PlayValueList-module__playValue___TJQhI","selectedPlayValue":"PlayValueList-module__selectedPlayValue___3DhDC","disabledPlayValue":"PlayValueList-module__disabledPlayValue___U9Bkj"};
|
|
656
|
+
|
|
657
|
+
const PlayValueList = () => {
|
|
658
|
+
const { config } = useAutoManualPlayState();
|
|
659
|
+
const { onChangeAmount, playAmount, totalBalance, playValues: { displayPlayAmountView, togglePlayAmountView }, } = usePlayController();
|
|
660
|
+
const { playLimits } = config.playOptions.playHook();
|
|
661
|
+
if (!displayPlayAmountView) {
|
|
662
|
+
return null;
|
|
663
|
+
}
|
|
664
|
+
const applyValue = (value) => {
|
|
665
|
+
if (totalBalance < value) {
|
|
666
|
+
sendOpenHighPlayModalEvent();
|
|
667
|
+
}
|
|
668
|
+
else {
|
|
669
|
+
onChangeAmount(value);
|
|
670
|
+
}
|
|
671
|
+
togglePlayAmountView();
|
|
672
|
+
};
|
|
673
|
+
const handleClick = (e) => {
|
|
674
|
+
const el = e.target?.closest("[data-value]");
|
|
675
|
+
if (!el) {
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
const raw = el.dataset.value;
|
|
679
|
+
if (!raw) {
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const value = Number(raw);
|
|
683
|
+
if (!Number.isNaN(value)) {
|
|
684
|
+
applyValue(value);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
return (jsx("div", { className: cx$1(styles$1.base), children: jsx("div", { className: cx$1(styles$1.playValuesWrapper), onClick: handleClick, role: "listbox", "aria-label": "Select play amount", "data-testid": "play-value-list", children: playLimits?.[config.currencyOptions.current.code].defaultBetOptions.map((playValue) => (jsx("div", { className: cx$1(styles$1.playValue, {
|
|
688
|
+
[styles$1.selectedPlayValue]: playValue === playAmount,
|
|
689
|
+
[styles$1.disabledPlayValue]: playValue > totalBalance,
|
|
690
|
+
}), "data-value": playValue, role: "option", tabIndex: 0, "aria-selected": false, children: format(playValue, config.currencyOptions.current.decimals) }, `${config.currencyOptions.current.code}-${playValue}`))) }) }));
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
var styles = {"base":"InputWithSwitch-module__base___vjLoh","icon":"InputWithSwitch-module__icon___upeAL","input":"InputWithSwitch-module__input___K6RCD","iconInput":"InputWithSwitch-module__iconInput___e5g5H"};
|
|
694
|
+
|
|
695
|
+
const InputWithSwitch = ({ children, switcherConfig, disabled, className, ...restProps }) => {
|
|
696
|
+
return (jsxs("div", { className: cx$1(styles.base, className, {
|
|
697
|
+
[styles.disabled]: switcherConfig.disabled,
|
|
698
|
+
}), children: [jsxs("div", { className: cx$1(styles.iconInput), children: [jsx("div", { className: cx$1(styles.icon), children: children }), jsx(Input, { ...restProps, className: cx$1(styles.input), disabled: disabled })] }), jsx(Switch, { ...switcherConfig })] }));
|
|
258
699
|
};
|
|
259
700
|
|
|
260
701
|
const AutoManualPlayProvider = ({ children, config, }) => {
|
|
@@ -264,6 +705,10 @@ const AutoManualPlayProvider = ({ children, config, }) => {
|
|
|
264
705
|
const [playedRounds, setPlayedRounds] = useState(0);
|
|
265
706
|
const [numberOfPlays, setNumberOfPlays] = useState(Infinity);
|
|
266
707
|
const [selection, setSelection] = useState([]);
|
|
708
|
+
const [displayPlayAmountView, setDisplayPlayAmountView] = useState(false);
|
|
709
|
+
const togglePlayAmountView = useCallback(() => {
|
|
710
|
+
setDisplayPlayAmountView((v) => !v);
|
|
711
|
+
}, []);
|
|
267
712
|
const startAutoplay = useCallback((numPlays) => {
|
|
268
713
|
setMode(GAME_MODE.AUTOPLAY);
|
|
269
714
|
setAutoplayState(AUTO_PLAY_STATE.SELECTING);
|
|
@@ -322,6 +767,11 @@ const AutoManualPlayProvider = ({ children, config, }) => {
|
|
|
322
767
|
},
|
|
323
768
|
reset: resetState,
|
|
324
769
|
toggleMode,
|
|
770
|
+
playValues: {
|
|
771
|
+
displayPlayAmountView,
|
|
772
|
+
setDisplayPlayAmountView,
|
|
773
|
+
togglePlayAmountView,
|
|
774
|
+
},
|
|
325
775
|
}), [
|
|
326
776
|
mode,
|
|
327
777
|
config,
|
|
@@ -337,25 +787,30 @@ const AutoManualPlayProvider = ({ children, config, }) => {
|
|
|
337
787
|
updateAutoplayState,
|
|
338
788
|
resetState,
|
|
339
789
|
toggleMode,
|
|
790
|
+
displayPlayAmountView,
|
|
791
|
+
togglePlayAmountView,
|
|
340
792
|
]);
|
|
341
|
-
return (jsxs(AutoManualPlayStateContext.Provider, { value: contextValue, children: [typeof children === "function" ? children(contextValue) : children, config.playOptions.displayController && (
|
|
342
|
-
"--
|
|
343
|
-
"--
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
793
|
+
return (jsxs(AutoManualPlayStateContext.Provider, { value: contextValue, children: [typeof children === "function" ? children(contextValue) : children, config.playOptions.displayController && (jsx("div", { className: cx$1(styles_ui.base, styles_ui.betForm), style: {
|
|
794
|
+
"--play-bottom": config.panel.bottom ?? 0,
|
|
795
|
+
"--play-panel-bg": hexToRgb(config.panel.bgColorHex ?? "#01243A"),
|
|
796
|
+
"--play-panel-bg-opacity": 0.5,
|
|
797
|
+
}, children: jsxs("div", { className: cx$1(styles_ui.container), children: [jsx(PlayValueList, {}), jsx("div", { className: cx$1(styles_ui.auto), children: jsx(InputWithSwitch, { value: numberOfPlays === Infinity ? 0 : numberOfPlays, type: "number", onChange: (e) => setNumberOfPlays(Number(e.currentTarget.value)), placeholder: "Number of Plays", min: 0, max: 99, disabled: config.playOptions.disabledController ||
|
|
798
|
+
mode === GAME_MODE.MANUAL, switcherConfig: {
|
|
799
|
+
onSwitch: toggleMode,
|
|
800
|
+
isPlaying: isAutoPlaying || config.playOptions.isPlaying,
|
|
801
|
+
enabled: mode !== GAME_MODE.MANUAL,
|
|
802
|
+
disabled: config.playOptions.disabledController ||
|
|
803
|
+
autoplayState === AUTO_PLAY_STATE.PLAYING,
|
|
804
|
+
}, children: jsx("span", { className: cx$1({
|
|
805
|
+
[styles_ui.disabled]: mode !== GAME_MODE.AUTOPLAY ||
|
|
806
|
+
numberOfPlays !== Infinity ||
|
|
807
|
+
autoplayState === AUTO_PLAY_STATE.PLAYING,
|
|
808
|
+
}), children: `∞` }) }) }), mode === GAME_MODE.MANUAL ? (jsx(ManualPlayController, {})) : (jsx(AutoPlayController, {})), jsx(WidgetContainer, { state: autoplayState, displayPlayAmountView: displayPlayAmountView, widgets: {
|
|
809
|
+
left: config.leftWidgets,
|
|
810
|
+
center: config.centerWidgets,
|
|
811
|
+
right: config.rightWidgets,
|
|
812
|
+
} })] }) }))] }));
|
|
358
813
|
};
|
|
359
814
|
|
|
360
|
-
export { AUTO_PLAY_STATE, AutoManualPlayProvider, GAME_MODE };
|
|
815
|
+
export { AUTO_PLAY_STATE, AutoManualPlayProvider, GAME_MODE, WIDGET, format };
|
|
361
816
|
//# sourceMappingURL=index.mjs.map
|