@everymatrix/player-elevate-optin 0.0.0-stage → 1.99.52
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/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/index-0dc5272e.js +1196 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/cjs/player-elevate-optin-d65e764f.js +280 -0
- package/dist/cjs/player-elevate-optin.cjs.entry.js +10 -0
- package/dist/cjs/player-elevate-optin.cjs.js +25 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/player-elevate-optin/index.js +1 -0
- package/dist/collection/components/player-elevate-optin/player-elevate-optin.css +205 -0
- package/dist/collection/components/player-elevate-optin/player-elevate-optin.js +338 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +56 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/index-06b994f3.js +1170 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/player-elevate-optin-6b9e7727.js +278 -0
- package/dist/esm/player-elevate-optin.entry.js +2 -0
- package/dist/esm/player-elevate-optin.js +20 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/player-elevate-optin/app-globals-0f993ce5.js +1 -0
- package/dist/player-elevate-optin/index-06b994f3.js +2 -0
- package/dist/player-elevate-optin/index.esm.js +1 -0
- package/dist/player-elevate-optin/player-elevate-optin-6b9e7727.js +1 -0
- package/dist/player-elevate-optin/player-elevate-optin.entry.js +1 -0
- package/dist/player-elevate-optin/player-elevate-optin.esm.js +1 -0
- package/dist/stencil.config.dev.js +19 -0
- package/dist/stencil.config.js +19 -0
- package/dist/storybook/main.js +43 -0
- package/dist/storybook/preview.js +9 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-optin/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-optin/.stencil/packages/stencil/player-elevate-optin/stencil.config.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-optin/.stencil/packages/stencil/player-elevate-optin/stencil.config.dev.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-optin/.stencil/packages/stencil/player-elevate-optin/storybook/main.d.ts +3 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-optin/.stencil/packages/stencil/player-elevate-optin/storybook/preview.d.ts +70 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-optin/.stencil/tools/plugins/index.d.ts +4 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-optin/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-optin/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-optin/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/player-elevate-optin/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
- package/dist/types/components/player-elevate-optin/index.d.ts +1 -0
- package/dist/types/components/player-elevate-optin/player-elevate-optin.d.ts +27 -0
- package/dist/types/components.d.ts +45 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/utils/locale.utils.d.ts +10 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +24 -3
- package/README.md +0 -3
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import { translate } from "../../utils/locale.utils";
|
|
3
|
+
export class PlayerElevateOptin {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.endpoint = undefined;
|
|
6
|
+
this.session = undefined;
|
|
7
|
+
this.language = "en";
|
|
8
|
+
this.enableOptIn = false;
|
|
9
|
+
this.openOptIn = false;
|
|
10
|
+
this.openOptOut = false;
|
|
11
|
+
this.terms = {
|
|
12
|
+
url: '',
|
|
13
|
+
description: '',
|
|
14
|
+
complianceUrl: '',
|
|
15
|
+
complianceDescription: '',
|
|
16
|
+
};
|
|
17
|
+
this.playerOptIn = null;
|
|
18
|
+
this.openShopRestriction = false;
|
|
19
|
+
this.pendingShopItem = null;
|
|
20
|
+
this.submitting = false;
|
|
21
|
+
}
|
|
22
|
+
async handleMessage(event) {
|
|
23
|
+
var _a, _b, _c;
|
|
24
|
+
if (event.origin !== window.location.origin)
|
|
25
|
+
return;
|
|
26
|
+
if (!this.enableOptIn)
|
|
27
|
+
return;
|
|
28
|
+
switch ((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) {
|
|
29
|
+
case "BEE_OPT_IN_CLICKED":
|
|
30
|
+
if (this.playerOptIn) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.openOptIn = true;
|
|
34
|
+
this.openOptOut = false;
|
|
35
|
+
break;
|
|
36
|
+
case "BEE_OPT_OUT_CLICKED":
|
|
37
|
+
this.openOptOut = true;
|
|
38
|
+
this.openOptIn = false;
|
|
39
|
+
break;
|
|
40
|
+
case 'BEE_REDEEM_CLICKED':
|
|
41
|
+
if (!((_b = event.data) === null || _b === void 0 ? void 0 : _b.shopItem))
|
|
42
|
+
return;
|
|
43
|
+
this.pendingShopItem = (_c = event.data) === null || _c === void 0 ? void 0 : _c.shopItem;
|
|
44
|
+
if (this.playerOptIn === null) {
|
|
45
|
+
await this.loadPlayerInfo();
|
|
46
|
+
}
|
|
47
|
+
if (this.playerOptIn === false) {
|
|
48
|
+
this.openShopRestriction = true;
|
|
49
|
+
}
|
|
50
|
+
else if (this.playerOptIn === true) {
|
|
51
|
+
this.continuePendingRedeem();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.error('Unable to verify player opt-in status');
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
continuePendingRedeem() {
|
|
60
|
+
if (!this.pendingShopItem) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
window.postMessage({
|
|
64
|
+
type: 'BEERedeemConfirm',
|
|
65
|
+
shopItem: this.pendingShopItem,
|
|
66
|
+
}, window.location.origin);
|
|
67
|
+
this.pendingShopItem = null;
|
|
68
|
+
}
|
|
69
|
+
async handleOptIn() {
|
|
70
|
+
if (this.submitting) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.submitting = true;
|
|
74
|
+
try {
|
|
75
|
+
const response = await fetch(`${this.endpoint}/v1/elevate/optIn`, {
|
|
76
|
+
method: "PUT",
|
|
77
|
+
headers: {
|
|
78
|
+
"X-Sessionid": this.session,
|
|
79
|
+
"Content-Type": "application/json",
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
const result = await response.json();
|
|
83
|
+
if (!response.ok || !result.success) {
|
|
84
|
+
await this.loadPlayerInfo();
|
|
85
|
+
if (this.playerOptIn === true) {
|
|
86
|
+
this.openOptIn = false;
|
|
87
|
+
this.openShopRestriction = false;
|
|
88
|
+
this.continuePendingRedeem();
|
|
89
|
+
window.postMessage({
|
|
90
|
+
type: 'userUpdateOptLoyaltySuccess',
|
|
91
|
+
data: {
|
|
92
|
+
type: 'success',
|
|
93
|
+
message: translate('loyaltyEnrollSuccess', this.language),
|
|
94
|
+
config: {
|
|
95
|
+
timeOut: 3000,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
}, window.location.origin);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const message = result.errorCode === 6016
|
|
102
|
+
? translate('optInNotAvailable', this.language)
|
|
103
|
+
: translate('loyaltyEnrollFailed', this.language);
|
|
104
|
+
window.postMessage({
|
|
105
|
+
type: 'WidgetNotification',
|
|
106
|
+
data: {
|
|
107
|
+
type: 'error',
|
|
108
|
+
message,
|
|
109
|
+
},
|
|
110
|
+
}, window.location.origin);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.playerOptIn = true;
|
|
114
|
+
this.openOptIn = false;
|
|
115
|
+
this.continuePendingRedeem();
|
|
116
|
+
window.postMessage({
|
|
117
|
+
type: "userUpdateOptLoyaltySuccess",
|
|
118
|
+
data: {
|
|
119
|
+
type: "success",
|
|
120
|
+
message: translate('loyaltyEnrollSuccess', this.language),
|
|
121
|
+
config: {
|
|
122
|
+
timeOut: 3000,
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
}, window.location.origin);
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
console.error('Failed to opt in', error);
|
|
129
|
+
window.postMessage({
|
|
130
|
+
type: 'WidgetNotification',
|
|
131
|
+
data: {
|
|
132
|
+
type: 'error',
|
|
133
|
+
message: translate('loyaltyEnrollFailed', this.language),
|
|
134
|
+
},
|
|
135
|
+
}, window.location.origin);
|
|
136
|
+
}
|
|
137
|
+
finally {
|
|
138
|
+
this.submitting = false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
async loadPlayerInfo() {
|
|
142
|
+
var _a;
|
|
143
|
+
try {
|
|
144
|
+
const url = new URL(`${this.endpoint}/v1/elevate/playerInfo?language=${this.language}`);
|
|
145
|
+
const response = await fetch(url.href, {
|
|
146
|
+
method: "GET",
|
|
147
|
+
headers: {
|
|
148
|
+
"X-Sessionid": this.session,
|
|
149
|
+
"Content-Type": "application/json",
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
const result = await response.json();
|
|
153
|
+
if (!result.success)
|
|
154
|
+
return;
|
|
155
|
+
this.playerOptIn = ((_a = result.data) === null || _a === void 0 ? void 0 : _a.optIn) === true;
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
console.error('Failed to load PlayerInfo', error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
async loadTerms() {
|
|
162
|
+
var _a, _b, _c, _d;
|
|
163
|
+
try {
|
|
164
|
+
const response = await fetch(`${this.endpoint}/v1/elevate/optIn/terms?language=${this.language}`);
|
|
165
|
+
const result = await response.json();
|
|
166
|
+
if (!result.success) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.terms = {
|
|
170
|
+
url: ((_a = result.data) === null || _a === void 0 ? void 0 : _a.url) || '',
|
|
171
|
+
description: ((_b = result.data) === null || _b === void 0 ? void 0 : _b.description) || '',
|
|
172
|
+
complianceUrl: ((_c = result.data) === null || _c === void 0 ? void 0 : _c.complianceUrl) || '',
|
|
173
|
+
complianceDescription: ((_d = result.data) === null || _d === void 0 ? void 0 : _d.complianceDesc) || '',
|
|
174
|
+
};
|
|
175
|
+
window.postMessage({
|
|
176
|
+
type: 'BEE_OPT_IN_TERMS_LOADED',
|
|
177
|
+
terms: this.terms,
|
|
178
|
+
}, window.location.origin);
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
console.error('Failed to load opt-in terms', error);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async componentWillLoad() {
|
|
185
|
+
if (!this.enableOptIn) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (!this.endpoint || !this.session) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const storageKey = `player-elevate-optin-shown-${this.session}`;
|
|
192
|
+
let alreadyShown = null;
|
|
193
|
+
try {
|
|
194
|
+
alreadyShown = localStorage.getItem(storageKey);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
console.error('Failed to access localStorage', error);
|
|
198
|
+
}
|
|
199
|
+
await Promise.all([
|
|
200
|
+
this.loadTerms(),
|
|
201
|
+
alreadyShown ? Promise.resolve() : this.loadPlayerInfo(),
|
|
202
|
+
]);
|
|
203
|
+
if (!alreadyShown && this.playerOptIn === false) {
|
|
204
|
+
this.openOptIn = true;
|
|
205
|
+
try {
|
|
206
|
+
localStorage.setItem(storageKey, 'true');
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
console.error('Failed to write localStorage', error);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
render() {
|
|
214
|
+
if (!this.enableOptIn) {
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
if (!this.openOptIn && !this.openOptOut && !this.openShopRestriction) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
return (h("div", { class: "Overlay" }, this.openOptIn && (h("div", { class: "GradientContainer" }, h("button", { class: "CloseButton", onClick: () => (this.openOptIn = false) }, "X"), h("div", { class: "Modal" }, h("h2", { class: "TermsTitle" }, translate('joinLoyaltyProgram', this.language)), h("div", { class: "Divider" }), this.terms.description && (h("p", { class: "TermsDescription" }, this.terms.description)), this.terms.complianceDescription && (h("p", { class: "ComplianceDescription" }, this.terms.complianceDescription)), this.terms.complianceUrl && (h("a", { href: this.terms.complianceUrl, target: "_blank", rel: "noopener noreferrer", class: "TermsLink" }, translate('readTermsAndConditions', this.language), h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round" }, h("g", { transform: "translate(0 1)" }, h("path", { d: "M14 3h7v7" }), h("path", { d: "M10 14L21 3" }), h("path", { d: "M21 14v5a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5" }))))), h("div", { class: "Divider" }), h("div", { class: "Actions" }, h("button", { class: "SecondaryButton", onClick: () => (this.openOptIn = false) }, translate('maybeLater', this.language)), h("button", { class: "PrimaryButton", disabled: this.submitting, onClick: () => this.handleOptIn() }, this.submitting
|
|
221
|
+
? translate('processing', this.language)
|
|
222
|
+
: translate('optIn', this.language)))))), this.openShopRestriction && (h("div", { class: "GradientContainer" }, h("button", { class: "CloseButton", onClick: () => {
|
|
223
|
+
this.openShopRestriction = false;
|
|
224
|
+
this.pendingShopItem = null;
|
|
225
|
+
} }, "X"), h("div", { class: "Modal" }, h("div", { class: "Icon" }, h("svg", { class: "GamificationButtonIcon", width: "24", height: "24", viewBox: "0 0 22 23", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M7.46429 2.19354C7.21442 2.19354 6.97106 2.2977 6.78878 2.48928C6.6059 2.6815 6.50001 2.94609 6.50001 3.2258C6.50001 3.50552 6.6059 3.77011 6.78878 3.96232C6.97106 4.15391 7.21442 4.25806 7.46429 4.25806H9.63425C9.56187 4.08118 9.47857 3.89797 9.38356 3.7164C8.89769 2.78793 8.27398 2.19354 7.46429 2.19354ZM10 6.32258V9.41935L2.60001 9.41935C2.30348 9.41935 2.14122 9.41855 2.02464 9.40871C2.02 9.40832 2.0156 9.40793 2.01145 9.40753C2.01107 9.40325 2.01069 9.39871 2.01031 9.39392C2.00078 9.27358 2.00001 9.10609 2.00001 8.8V6.94193C2.00001 6.63584 2.00078 6.46835 2.01031 6.348C2.01069 6.34321 2.01107 6.33868 2.01145 6.33439C2.0156 6.334 2.02 6.3336 2.02464 6.33321C2.14122 6.32338 2.30348 6.32258 2.60001 6.32258H10ZM4.66953 4.25806C4.55822 3.92911 4.50001 3.58027 4.50001 3.2258C4.50001 2.41043 4.80802 1.62479 5.36188 1.04266C5.91635 0.459899 6.67224 0.129028 7.46429 0.129028C9.259 0.129028 10.3725 1.38679 11 2.47456C11.6275 1.38679 12.741 0.129028 14.5357 0.129028C15.3278 0.129028 16.0837 0.459899 16.6381 1.04266C17.192 1.62479 17.5 2.41043 17.5 3.2258C17.5 3.58027 17.4418 3.92911 17.3305 4.25806L19.4319 4.25806C19.6843 4.25803 19.9301 4.258 20.1382 4.27555C20.3668 4.29483 20.6366 4.34032 20.908 4.48308C21.2843 4.68101 21.5903 4.99684 21.782 5.38531C21.9203 5.66549 21.9644 5.94392 21.9831 6.17989C22.0001 6.39476 22 6.64847 22 6.90899V8.83294C22 9.09346 22.0001 9.34717 21.9831 9.56204C21.9644 9.79801 21.9203 10.0764 21.782 10.3566C21.5903 10.7451 21.2843 11.0609 20.908 11.2588C20.6366 11.4016 20.3668 11.4471 20.1382 11.4664C20.0938 11.4701 20.0476 11.4731 20 11.4754V18.543C20 19.0872 20 19.5566 19.9694 19.9433C19.9371 20.3513 19.8658 20.7573 19.673 21.1478C19.3854 21.7305 18.9265 22.2043 18.362 22.5012C17.9836 22.7002 17.5904 22.7738 17.195 22.8071C16.8205 22.8387 16.3657 22.8387 15.8386 22.8387H11.0014C11.0009 22.8387 11.0005 22.8387 11 22.8387C10.9995 22.8387 10.9991 22.8387 10.9986 22.8387H6.16144C5.6343 22.8387 5.17954 22.8387 4.80498 22.8071C4.40963 22.7738 4.01641 22.7002 3.63803 22.5012C3.07355 22.2043 2.6146 21.7305 2.32699 21.1478C2.13419 20.7572 2.06288 20.3513 2.03057 19.9432C1.99997 19.5566 1.99999 19.0872 2 18.543L2.00001 11.4754C1.95241 11.4731 1.90624 11.4701 1.86178 11.4664C1.63318 11.4471 1.36345 11.4016 1.09202 11.2588C0.715701 11.0609 0.409739 10.7451 0.217992 10.3566C0.0796947 10.0764 0.0356271 9.79801 0.0169504 9.56204C-5.6861e-05 9.34717 -2.74161e-05 9.09345 2.50544e-06 8.83292L5.24726e-06 6.94193C5.24726e-06 6.93095 3.93595e-06 6.91997 2.62465e-06 6.909C-2.72969e-05 6.64848 -5.67418e-05 6.39476 0.0169505 6.17989C0.0356274 5.94392 0.079695 5.66549 0.217992 5.38531C0.409739 4.99684 0.7157 4.68101 1.09202 4.48308C1.36345 4.34032 1.63318 4.29483 1.86178 4.27555C2.06993 4.258 2.31573 4.25803 2.56811 4.25806C2.57873 4.25806 2.58936 4.25806 2.60001 4.25806H4.66953ZM4.00001 11.4839V18.5032C4.00001 19.0984 4.00078 19.4827 4.02393 19.7751C4.04613 20.0556 4.08381 20.1595 4.109 20.2106C4.20487 20.4048 4.35785 20.5627 4.54601 20.6617C4.59546 20.6877 4.69618 20.7266 4.96784 20.7495C5.25118 20.7734 5.62345 20.7742 6.20001 20.7742H10V11.4839H4.00001ZM12 11.4839V20.7742H15.8C16.3766 20.7742 16.7488 20.7734 17.0322 20.7495C17.3038 20.7266 17.4046 20.6877 17.454 20.6617C17.6422 20.5627 17.7951 20.4048 17.891 20.2106C17.9162 20.1595 17.9539 20.0556 17.9761 19.7751C17.9992 19.4827 18 19.0984 18 18.5032V11.4839H12ZM19.4 9.41935C19.6965 9.41935 19.8588 9.41855 19.9754 9.40871C19.98 9.40832 19.9844 9.40792 19.9886 9.40752C19.9889 9.40324 19.9893 9.39871 19.9897 9.39392C19.9992 9.27358 20 9.10609 20 8.8V6.94193C20 6.63584 19.9992 6.46835 19.9897 6.34801C19.9893 6.34322 19.9889 6.33868 19.9885 6.33439C19.9844 6.334 19.98 6.3336 19.9754 6.33321C19.8588 6.32338 19.6965 6.32258 19.4 6.32258H12V9.41935H19.4ZM14.5357 4.25806C14.7856 4.25806 15.0289 4.15391 15.2112 3.96232C15.3941 3.77011 15.5 3.50552 15.5 3.2258C15.5 2.94609 15.3941 2.6815 15.2112 2.48928C15.0289 2.2977 14.7856 2.19354 14.5357 2.19354C13.726 2.19354 13.1023 2.78793 12.6165 3.7164C12.5214 3.89797 12.4381 4.08118 12.3658 4.25806H14.5357Z" }))), h("h2", { class: "Title" }, translate('optInRedeemTitle', this.language)), h("div", { class: "Divider" }), h("p", { class: "Description" }, translate('optInRedeemDescription', this.language)), h("div", { class: "Divider" }), h("div", { class: "Actions" }, h("button", { class: "SecondaryButton", onClick: () => {
|
|
226
|
+
this.openShopRestriction = false;
|
|
227
|
+
this.pendingShopItem = null;
|
|
228
|
+
} }, translate('maybeLater', this.language)), h("button", { class: "PrimaryButton", disabled: this.submitting, onClick: () => this.handleOptIn() }, this.submitting
|
|
229
|
+
? translate('processing', this.language)
|
|
230
|
+
: translate('optIn', this.language)))))), this.openOptOut && (h("div", { class: "GradientContainer" }, h("button", { class: "CloseButton", onClick: () => (this.openOptOut = false) }, "X"), h("div", { class: "Modal" }, h("div", { class: "Icon" }, h("svg", { width: "24", height: "24", viewBox: "0 0 80 80", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, h("circle", { cx: "40", cy: "40", r: "34", stroke: "currentColor", "stroke-width": "8" }), h("circle", { cx: "40", cy: "24", r: "4", fill: "currentColor" }), h("path", { d: "M40 34V56", stroke: "currentColor", "stroke-width": "8", "stroke-linecap": "round" }))), h("h2", { class: "Title" }, translate('optOutTitle', this.language)), h("div", { class: "Divider" }), h("p", { class: "OptOutDescription" }, translate('optOutDescription', this.language)), h("div", { class: "Divider" }), h("div", { class: "Actions" }, h("button", { class: "PrimaryButton", onClick: () => (this.openOptOut = false) }, translate('okay', this.language))))))));
|
|
231
|
+
}
|
|
232
|
+
static get is() { return "player-elevate-optin"; }
|
|
233
|
+
static get encapsulation() { return "shadow"; }
|
|
234
|
+
static get originalStyleUrls() {
|
|
235
|
+
return {
|
|
236
|
+
"$": ["player-elevate-optin.scss"]
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
static get styleUrls() {
|
|
240
|
+
return {
|
|
241
|
+
"$": ["player-elevate-optin.css"]
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
static get properties() {
|
|
245
|
+
return {
|
|
246
|
+
"endpoint": {
|
|
247
|
+
"type": "string",
|
|
248
|
+
"mutable": false,
|
|
249
|
+
"complexType": {
|
|
250
|
+
"original": "string",
|
|
251
|
+
"resolved": "string",
|
|
252
|
+
"references": {}
|
|
253
|
+
},
|
|
254
|
+
"required": true,
|
|
255
|
+
"optional": false,
|
|
256
|
+
"docs": {
|
|
257
|
+
"tags": [],
|
|
258
|
+
"text": ""
|
|
259
|
+
},
|
|
260
|
+
"attribute": "endpoint",
|
|
261
|
+
"reflect": false
|
|
262
|
+
},
|
|
263
|
+
"session": {
|
|
264
|
+
"type": "string",
|
|
265
|
+
"mutable": false,
|
|
266
|
+
"complexType": {
|
|
267
|
+
"original": "string",
|
|
268
|
+
"resolved": "string",
|
|
269
|
+
"references": {}
|
|
270
|
+
},
|
|
271
|
+
"required": true,
|
|
272
|
+
"optional": false,
|
|
273
|
+
"docs": {
|
|
274
|
+
"tags": [],
|
|
275
|
+
"text": ""
|
|
276
|
+
},
|
|
277
|
+
"attribute": "session",
|
|
278
|
+
"reflect": false
|
|
279
|
+
},
|
|
280
|
+
"language": {
|
|
281
|
+
"type": "string",
|
|
282
|
+
"mutable": false,
|
|
283
|
+
"complexType": {
|
|
284
|
+
"original": "string",
|
|
285
|
+
"resolved": "string",
|
|
286
|
+
"references": {}
|
|
287
|
+
},
|
|
288
|
+
"required": false,
|
|
289
|
+
"optional": false,
|
|
290
|
+
"docs": {
|
|
291
|
+
"tags": [],
|
|
292
|
+
"text": ""
|
|
293
|
+
},
|
|
294
|
+
"attribute": "language",
|
|
295
|
+
"reflect": false,
|
|
296
|
+
"defaultValue": "\"en\""
|
|
297
|
+
},
|
|
298
|
+
"enableOptIn": {
|
|
299
|
+
"type": "boolean",
|
|
300
|
+
"mutable": false,
|
|
301
|
+
"complexType": {
|
|
302
|
+
"original": "boolean",
|
|
303
|
+
"resolved": "boolean",
|
|
304
|
+
"references": {}
|
|
305
|
+
},
|
|
306
|
+
"required": false,
|
|
307
|
+
"optional": false,
|
|
308
|
+
"docs": {
|
|
309
|
+
"tags": [],
|
|
310
|
+
"text": ""
|
|
311
|
+
},
|
|
312
|
+
"attribute": "enable-opt-in",
|
|
313
|
+
"reflect": false,
|
|
314
|
+
"defaultValue": "false"
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
static get states() {
|
|
319
|
+
return {
|
|
320
|
+
"openOptIn": {},
|
|
321
|
+
"openOptOut": {},
|
|
322
|
+
"terms": {},
|
|
323
|
+
"playerOptIn": {},
|
|
324
|
+
"openShopRestriction": {},
|
|
325
|
+
"pendingShopItem": {},
|
|
326
|
+
"submitting": {}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
static get listeners() {
|
|
330
|
+
return [{
|
|
331
|
+
"name": "message",
|
|
332
|
+
"method": "handleMessage",
|
|
333
|
+
"target": "window",
|
|
334
|
+
"capture": false,
|
|
335
|
+
"passive": false
|
|
336
|
+
}];
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/player-elevate-optin';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const DEFAULT_LANGUAGE = 'en';
|
|
2
|
+
export const TRANSLATIONS = {
|
|
3
|
+
en: {
|
|
4
|
+
joinLoyaltyProgram: 'JOIN THE LOYALTY PROGRAM',
|
|
5
|
+
readTermsAndConditions: 'Read Terms & Conditions',
|
|
6
|
+
maybeLater: 'MAYBE LATER',
|
|
7
|
+
optIn: 'OPT IN',
|
|
8
|
+
optOut: 'OPT OUT',
|
|
9
|
+
optInRedeemTitle: 'OPT IN AND REDEEM YOUR GIFT',
|
|
10
|
+
optInRedeemDescription: 'You are not enrolled in the Loyalty programme. Opt in now to join the programme and redeem this gift.',
|
|
11
|
+
optInRakebackTitle: 'OPT IN AND CLAIM YOUR RAKEBACK',
|
|
12
|
+
optInRakebackDescription: 'You are not enrolled in the Loyalty programme. Opt in now to join the programme and claim this rakeback.',
|
|
13
|
+
optOutTitle: 'NEXT STEPS TO OPT OUT',
|
|
14
|
+
optOutDescription: 'Please contact the support team to opt out of the Loyalty Programme.',
|
|
15
|
+
okay: 'OKAY',
|
|
16
|
+
loyaltyEnrollSuccess: 'Congratulations! You are now enrolled in the Loyalty Programme.',
|
|
17
|
+
loyaltyEnrollFailed: 'Unable to enroll in the Loyalty Programme. Please try again later.',
|
|
18
|
+
optInNotAvailable: 'Opt-in is not available for this loyalty program.',
|
|
19
|
+
processing: 'Processing...',
|
|
20
|
+
},
|
|
21
|
+
'zh-hk': {
|
|
22
|
+
joinLoyaltyProgram: '加入忠誠計劃',
|
|
23
|
+
readTermsAndConditions: '閱讀條款及細則',
|
|
24
|
+
maybeLater: '稍後再說',
|
|
25
|
+
optIn: '立即加入',
|
|
26
|
+
optOut: '退出',
|
|
27
|
+
okay: '確定',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export const translate = (key, customLang) => {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const lang = customLang && TRANSLATIONS[customLang]
|
|
33
|
+
? customLang
|
|
34
|
+
: DEFAULT_LANGUAGE;
|
|
35
|
+
return (((_a = TRANSLATIONS[lang]) === null || _a === void 0 ? void 0 : _a[key]) ||
|
|
36
|
+
((_b = TRANSLATIONS[DEFAULT_LANGUAGE]) === null || _b === void 0 ? void 0 : _b[key]) ||
|
|
37
|
+
key);
|
|
38
|
+
};
|
|
39
|
+
export const getTranslations = (url) => {
|
|
40
|
+
return new Promise((resolve) => {
|
|
41
|
+
fetch(url)
|
|
42
|
+
.then((res) => res.json())
|
|
43
|
+
.then((data) => {
|
|
44
|
+
Object.keys(data).forEach((lang) => {
|
|
45
|
+
if (!TRANSLATIONS[lang]) {
|
|
46
|
+
TRANSLATIONS[lang] = {};
|
|
47
|
+
}
|
|
48
|
+
Object.keys(data[lang]).forEach((key) => {
|
|
49
|
+
TRANSLATIONS[lang][key] = data[lang][key];
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
resolve(true);
|
|
53
|
+
})
|
|
54
|
+
.catch(() => resolve(false));
|
|
55
|
+
});
|
|
56
|
+
};
|