@everymatrix/user-action-controller 1.0.0 → 1.0.69

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.
Files changed (57) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-c5061e5a.js +1315 -0
  3. package/dist/cjs/loader.cjs.js +7 -13
  4. package/dist/cjs/player-user-consents_2.cjs.entry.js +504 -0
  5. package/dist/cjs/user-action-controller.cjs.js +17 -11
  6. package/dist/collection/collection-manifest.json +5 -11
  7. package/dist/collection/components/user-action-controller/index.js +1 -0
  8. package/dist/collection/components/user-action-controller/user-action-controller.css +37 -0
  9. package/dist/collection/components/user-action-controller/user-action-controller.js +418 -328
  10. package/dist/collection/utils/locale.utils.js +66 -0
  11. package/dist/collection/utils/utils.js +1 -1
  12. package/dist/esm/app-globals-0f993ce5.js +3 -0
  13. package/dist/esm/index-02b86e76.js +1288 -0
  14. package/dist/esm/loader.js +7 -13
  15. package/dist/esm/player-user-consents_2.entry.js +499 -0
  16. package/dist/esm/user-action-controller.js +14 -11
  17. package/dist/stencil.config.dev.js +17 -0
  18. package/dist/stencil.config.js +14 -19
  19. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/user-action-controller/.stencil/packages/stencil/user-action-controller/stencil.config.d.ts +2 -0
  20. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/user-action-controller/.stencil/packages/stencil/user-action-controller/stencil.config.dev.d.ts +2 -0
  21. package/dist/types/components/user-action-controller/index.d.ts +1 -0
  22. package/dist/types/components/user-action-controller/user-action-controller.d.ts +68 -68
  23. package/dist/types/components.d.ts +28 -40
  24. package/dist/types/stencil-public-runtime.d.ts +142 -33
  25. package/dist/types/utils/locale.utils.d.ts +2 -0
  26. package/dist/user-action-controller/p-4bd71dba.entry.js +1 -0
  27. package/dist/user-action-controller/p-b996e8b8.js +2 -0
  28. package/dist/user-action-controller/p-e1255160.js +1 -0
  29. package/dist/user-action-controller/user-action-controller.esm.js +1 -1
  30. package/loader/cdn.js +1 -3
  31. package/loader/index.cjs.js +1 -3
  32. package/loader/index.d.ts +13 -1
  33. package/loader/index.es2017.js +1 -3
  34. package/loader/index.js +1 -3
  35. package/loader/package.json +1 -0
  36. package/package.json +16 -3
  37. package/dist/cjs/generic-user-consent_3.cjs.entry.js +0 -210
  38. package/dist/cjs/index-5b463836.js +0 -1285
  39. package/dist/components/generic-user-consent.js +0 -6
  40. package/dist/components/generic-user-consent2.js +0 -93
  41. package/dist/components/index.d.ts +0 -26
  42. package/dist/components/index.js +0 -1
  43. package/dist/components/legislation-wrapper.js +0 -6
  44. package/dist/components/legislation-wrapper2.js +0 -33
  45. package/dist/components/user-action-controller.d.ts +0 -11
  46. package/dist/components/user-action-controller.js +0 -168
  47. package/dist/esm/generic-user-consent_3.entry.js +0 -204
  48. package/dist/esm/index-e34db4b0.js +0 -1259
  49. package/dist/esm/polyfills/core-js.js +0 -11
  50. package/dist/esm/polyfills/css-shim.js +0 -1
  51. package/dist/esm/polyfills/dom.js +0 -79
  52. package/dist/esm/polyfills/es5-html-element.js +0 -1
  53. package/dist/esm/polyfills/index.js +0 -34
  54. package/dist/esm/polyfills/system.js +0 -6
  55. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/user-action-controller/.stencil/packages/user-action-controller/stencil.config.d.ts +0 -2
  56. package/dist/user-action-controller/p-20213f37.js +0 -1
  57. package/dist/user-action-controller/p-2a14a5fe.entry.js +0 -1
@@ -2,20 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-5b463836.js');
5
+ const index = require('./index-c5061e5a.js');
6
+ const appGlobals = require('./app-globals-3a1e7e63.js');
6
7
 
7
- /*
8
- Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
9
- */
10
- const patchEsm = () => {
11
- return index.promiseResolve();
12
- };
13
-
14
- const defineCustomElements = (win, options) => {
15
- if (typeof window === 'undefined') return Promise.resolve();
16
- return patchEsm().then(() => {
17
- return index.bootstrapLazy([["generic-user-consent_3.cjs",[[1,"user-action-controller",{"endpoint":[1],"userSession":[1,"user-session"],"userId":[1,"user-id"],"includeSubmitButton":[4,"include-submit-button"],"submitButtonText":[1,"submit-button-text"],"userNoticeText":[1,"user-notice-text"],"activeUserActions":[1,"active-user-actions"],"showCloseButton":[4,"show-close-button"],"usePostmessage":[4,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"generic-user-consent",{"queried":[4],"consentType":[1,"consent-type"],"mandatory":[4],"consentTitle":[1,"consent-title"],"tcLink":[1,"tc-link"],"privacyLink":[1,"privacy-link"],"textContent":[32]}],[1,"legislation-wrapper",{"activeUserActions":[1,"active-user-actions"]}]]]], options);
18
- });
8
+ const defineCustomElements = async (win, options) => {
9
+ if (typeof window === 'undefined') return undefined;
10
+ await appGlobals.globalScripts();
11
+ return index.bootstrapLazy([["player-user-consents_2.cjs",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"lang":[1537],"includeSubmitButton":[516,"include-submit-button"],"gmVersion":[1,"gm-version"],"translationUrl":[513,"translation-url"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"activeUserActions":[32],"userActionsValidated":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32],"isLoading":[32],"mandatoryActionsChecked":[32],"mandatoryItems":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]],{"translationUrl":["handleNewTranslations"],"receivedQueryResponses":["handleQueryResponse"]}],[1,"player-user-consents",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"gmVersion":[1,"gm-version"],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"translationUrl":[513,"translation-url"],"textContent":[32],"limitStylingAppends":[32]},null,{"translationUrl":["handleNewTranslations"]}]]]], options);
19
12
  };
20
13
 
14
+ exports.setNonce = index.setNonce;
21
15
  exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,504 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-c5061e5a.js');
6
+
7
+ const DEFAULT_LANGUAGE$1 = 'en';
8
+ const TRANSLATIONS$1 = {
9
+ en: {
10
+ termsAndConditions: {
11
+ acceptPart1: "I accept the ",
12
+ acceptPart2: ", I have read and understood the ",
13
+ acceptPart3: " as published on this site and confirm that I am over 18 years old.",
14
+ tc: "Terms and Conditions"
15
+ },
16
+ privacyPolicy: {
17
+ readUnderstandPart1: "I have read and understood the ",
18
+ readUnderstandPart2: ", as published on this site and confirm that I am over 18 years old.",
19
+ privacy: "Privacy Policy"
20
+ },
21
+ sms: "I consent to receive marketing communication via SMS.",
22
+ emailmarketing: "I consent to receive marketing communication via Email."
23
+ },
24
+ ro: {
25
+ termsAndConditions: {
26
+ acceptPart1: "Accept ",
27
+ acceptPart2: " platformei. Am citit şi înţeles ",
28
+ acceptPart3: " publicată pe acest site şi confirm că am vârstă peste 18 ani.",
29
+ tc: "Termenii şi condiţiile"
30
+ },
31
+ privacyPolicy: {
32
+ readUnderstandPart1: "Am citit şi înţeles ",
33
+ readUnderstandPart2: " publicată pe acest site şi confirm că am vârstă peste 18 ani.",
34
+ privacy: "Politica de confidenţialitate"
35
+ },
36
+ sms: "Sunt de acord să primesc promoţii de marketing prin SMS.",
37
+ emailmarketing: "Sunt de acord să primesc promoţii de marketing pe e-mail."
38
+ },
39
+ hr: {
40
+ termsAndConditions: {
41
+ acceptPart1: "I accept the ",
42
+ acceptPart2: ", I have read and understood the ",
43
+ acceptPart3: " as published on this site and confirm that I am over 18 years old.",
44
+ tc: "Terms and Conditions"
45
+ },
46
+ privacyPolicy: {
47
+ readUnderstandPart1: "I have read and understood the ",
48
+ readUnderstandPart2: ", as published on this site and confirm that I am over 18 years old.",
49
+ privacy: "Privacy Policy"
50
+ },
51
+ sms: "I consent to receive marketing communication via SMS.",
52
+ emailmarketing: "I consent to receive marketing communication via Email."
53
+ },
54
+ fr: {
55
+ termsAndConditions: {
56
+ acceptPart1: "I accept the ",
57
+ acceptPart2: ", I have read and understood the ",
58
+ acceptPart3: " as published on this site and confirm that I am over 18 years old.",
59
+ tc: "Terms and Conditions"
60
+ },
61
+ privacyPolicy: {
62
+ readUnderstandPart1: "I have read and understood the ",
63
+ readUnderstandPart2: ", as published on this site and confirm that I am over 18 years old.",
64
+ privacy: "Privacy Policy"
65
+ },
66
+ sms: "I consent to receive marketing communication via SMS.",
67
+ emailmarketing: "I consent to receive marketing communication via Email."
68
+ },
69
+ cs: {
70
+ termsAndConditions: {
71
+ acceptPart1: "I accept the ",
72
+ acceptPart2: ", I have read and understood the ",
73
+ acceptPart3: " as published on this site and confirm that I am over 18 years old.",
74
+ tc: "Terms and Conditions"
75
+ },
76
+ privacyPolicy: {
77
+ readUnderstandPart1: "I have read and understood the ",
78
+ readUnderstandPart2: ", as published on this site and confirm that I am over 18 years old.",
79
+ privacy: "Privacy Policy"
80
+ },
81
+ sms: "I consent to receive marketing communication via SMS.",
82
+ emailmarketing: "I consent to receive marketing communication via Email."
83
+ },
84
+ de: {
85
+ termsAndConditions: {
86
+ acceptPart1: "I accept the ",
87
+ acceptPart2: ", I have read and understood the ",
88
+ acceptPart3: " as published on this site and confirm that I am over 18 years old.",
89
+ tc: "Terms and Conditions"
90
+ },
91
+ privacyPolicy: {
92
+ readUnderstandPart1: "I have read and understood the ",
93
+ readUnderstandPart2: ", as published on this site and confirm that I am over 18 years old.",
94
+ privacy: "Privacy Policy"
95
+ },
96
+ sms: "I consent to receive marketing communication via SMS.",
97
+ emailmarketing: "I consent to receive marketing communication via Email."
98
+ },
99
+ };
100
+ const getTranslations$1 = (url) => {
101
+ // fetch url, get the data, replace the TRANSLATIONS content
102
+ return new Promise((resolve) => {
103
+ fetch(url)
104
+ .then((res) => res.json())
105
+ .then((data) => {
106
+ Object.keys(data).forEach((item) => {
107
+ for (let key in data[item]) {
108
+ TRANSLATIONS$1[item][key] = data[item][key];
109
+ }
110
+ });
111
+ resolve(true);
112
+ });
113
+ });
114
+ };
115
+ const translate$1 = (key, customLang, values) => {
116
+ const lang = customLang || DEFAULT_LANGUAGE$1;
117
+ const getNestedTranslation = (obj, path) => {
118
+ return path.split('.').reduce((o, k) => (o && o[k] !== undefined ? o[k] : null), obj);
119
+ };
120
+ let translation = getNestedTranslation(TRANSLATIONS$1[lang], key);
121
+ if (translation === null) {
122
+ return key;
123
+ }
124
+ if (values !== undefined) {
125
+ for (const [k, v] of Object.entries(values)) {
126
+ const regex = new RegExp(`{${k}}`, 'g');
127
+ translation = translation.replace(regex, v);
128
+ }
129
+ }
130
+ return translation;
131
+ };
132
+
133
+ const playerUserConsentsCss = ":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.UserConsent:hover{cursor:pointer}.UserConsent{display:flex;align-items:baseline}.MandatoryItem{color:#f00;font-size:1.2rem}.ConsentLink{text-decoration:underline;color:var(--emfe-w-color-primary);font-weight:bold}";
134
+ const PlayerUserConsentsStyle0 = playerUserConsentsCss;
135
+
136
+ const PlayerUserConsents = class {
137
+ constructor(hostRef) {
138
+ index.registerInstance(this, hostRef);
139
+ this.userLegislationConsent = index.createEvent(this, "userLegislationConsent", 7);
140
+ this.goToTermsAndConditions = () => window.postMessage({ type: 'GoToTermsAndConditions' });
141
+ this.goToPrivacyPolicy = () => window.postMessage({ type: 'GoToPrivacyPolicy' });
142
+ this.setClientStyling = () => {
143
+ let sheet = document.createElement('style');
144
+ sheet.innerHTML = this.clientStyling;
145
+ this.stylingContainer.prepend(sheet);
146
+ };
147
+ this.lang = 'en';
148
+ this.queried = false;
149
+ this.consentType = '';
150
+ this.mandatory = false;
151
+ this.gmVersion = '';
152
+ this.consentTitle = '';
153
+ this.clientStyling = '';
154
+ this.translationUrl = '';
155
+ this.textContent = '';
156
+ this.limitStylingAppends = false;
157
+ }
158
+ handleNewTranslations() {
159
+ getTranslations$1(this.translationUrl);
160
+ }
161
+ async componentWillLoad() {
162
+ if (this.translationUrl.length > 2) {
163
+ await getTranslations$1(this.translationUrl);
164
+ }
165
+ }
166
+ userLegislationConsentHandler() {
167
+ this.userLegislationConsent.emit({
168
+ type: this.consentType,
169
+ value: this.checkboxInput.checked
170
+ });
171
+ }
172
+ componentDidRender() {
173
+ // start custom styling area
174
+ if (!this.limitStylingAppends && this.stylingContainer) {
175
+ if (this.clientStyling)
176
+ this.setClientStyling();
177
+ this.limitStylingAppends = true;
178
+ }
179
+ // end custom styling area
180
+ }
181
+ determineTextContent() {
182
+ if (this.gmVersion === 'gmcore') {
183
+ if (this.consentType === 'termsandconditions') {
184
+ return index.h("p", null, translate$1('termsAndConditions.acceptPart1', this.lang), index.h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate$1('termsAndConditions.tcLink', this.lang)), translate$1('termsAndConditions.acceptPart2', this.lang), index.h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate$1('privacyPolicy.privacyLink', this.lang)), translate$1('termsAndConditions.acceptPart3', this.lang));
185
+ }
186
+ }
187
+ if (this.gmVersion === 'gm16') {
188
+ if (this.consentType === 'termsandconditions') {
189
+ return index.h("p", null, translate$1('termsAndConditions.acceptPart1', this.lang), index.h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate$1('termsAndConditions.tcLink', this.lang)));
190
+ }
191
+ if (this.consentType === 'privacypolicy') {
192
+ return index.h("p", null, translate$1('privacyPolicy.readUnderstandPart1', this.lang), index.h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate$1('privacyPolicy.privacyLink', this.lang)), translate$1('privacyPolicy.readUnderstandPart2', this.lang));
193
+ }
194
+ }
195
+ return index.h("p", null, translate$1(this.consentType, this.lang));
196
+ }
197
+ render() {
198
+ if (this.queried) {
199
+ this.userLegislationConsentHandler();
200
+ }
201
+ return (index.h("div", { key: 'e3c5e7d280de637fd8297dd59c170479d6142372', ref: el => this.stylingContainer = el }, index.h("p", { key: '8d103ef2eda5fd078a46a7d818eadd07dade5277', class: "ConsentTitle" }, this.consentTitle), index.h("label", { key: '6a333af5b8585e609285f9f172bf8ddb3b0d4b4b', class: "UserConsent", htmlFor: "userConsent" }, index.h("input", { key: 'c003a2ef7219e4c5442730432dffcaef4a16b947', ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.determineTextContent(), this.mandatory && index.h("span", { key: '0bc4b24a85b76763af5e691f126e8ee8ae90e447', class: "MandatoryItem" }, "*"))));
202
+ }
203
+ static get watchers() { return {
204
+ "translationUrl": ["handleNewTranslations"]
205
+ }; }
206
+ };
207
+ PlayerUserConsents.style = PlayerUserConsentsStyle0;
208
+
209
+ const DEFAULT_LANGUAGE = 'en';
210
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'cz', 'de', 'hr'];
211
+ const TRANSLATIONS = {
212
+ en: {
213
+ termsandconditions: 'Terms and Conditions',
214
+ sms: 'SMS marketing',
215
+ emailmarketing: 'Email marketing',
216
+ privacypolicy: 'Privacy Policy'
217
+ },
218
+ ro: {
219
+ termsandconditions: 'Termeni şi condiţii',
220
+ sms: 'SMS marketing',
221
+ emailmarketing: 'Email marketing',
222
+ privacypolicy: 'Privacy Policy'
223
+ },
224
+ hr: {
225
+ termsandconditions: 'Terms and Conditions',
226
+ sms: 'SMS marketing',
227
+ emailmarketing: 'Email marketing',
228
+ privacypolicy: 'Privacy Policy'
229
+ },
230
+ fr: {
231
+ termsandconditions: 'Terms and Conditions',
232
+ sms: 'SMS marketing',
233
+ emailmarketing: 'Email marketing',
234
+ privacypolicy: 'Privacy Policy'
235
+ },
236
+ cs: {
237
+ termsandconditions: 'Terms and Conditions',
238
+ sms: 'SMS marketing',
239
+ emailmarketing: 'Email marketing',
240
+ privacypolicy: 'Privacy Policy'
241
+ },
242
+ de: {
243
+ termsandconditions: 'Terms and Conditions',
244
+ sms: 'SMS marketing',
245
+ emailmarketing: 'Email marketing',
246
+ privacypolicy: 'Privacy Policy'
247
+ },
248
+ };
249
+ const getTranslations = (url) => {
250
+ // fetch url, get the data, replace the TRANSLATIONS content
251
+ return new Promise((resolve) => {
252
+ fetch(url)
253
+ .then((res) => res.json())
254
+ .then((data) => {
255
+ Object.keys(data).forEach((item) => {
256
+ for (let key in data[item]) {
257
+ TRANSLATIONS[item][key] = data[item][key];
258
+ }
259
+ });
260
+ resolve(true);
261
+ });
262
+ });
263
+ };
264
+ const translate = (key, customLang, values) => {
265
+ const lang = customLang;
266
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
267
+ if (values !== undefined) {
268
+ for (const [key, value] of Object.entries(values.values)) {
269
+ const regex = new RegExp(`{${key}}`, 'g');
270
+ translation = translation.replace(regex, value);
271
+ }
272
+ }
273
+ return translation;
274
+ };
275
+
276
+ const userActionControllerCss = ":host{display:block}.QueryReferenceContainer{height:100%;width:100%}.UserConsentNotice{font-size:1.2rem;font-weight:200;text-align:center}.CloseButton{width:25px;height:25px;align-self:flex-end}.UserActionController{font-family:Arial, Helvetica, sans-serif;font-weight:100;height:100%;width:100%;padding:1rem 1.5rem 2rem;background-color:#fff;display:flex;flex-direction:column;justify-content:space-between;border-radius:5%}.ConsentSubmitButton{font-size:1rem;padding:0.4rem 1.4rem;background:#fff;border:2px solid #000;color:#000;border-radius:5px;align-self:flex-end;cursor:pointer}.ConsentSubmitButton:disabled{border:2px solid #ccc;color:#ccc;cursor:unset}@media screen and (max-width: 320px){.QueryReferenceContainer{font-size:0.8rem;color:blue}}.spinner{animation:rotate 2s linear infinite;z-index:2;position:absolute;top:50%;left:50%;margin:-25px 0 0 -25px;width:50px;height:50px}.spinner .path{stroke:var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C));stroke-linecap:round;animation:dash 1.5s ease-in-out infinite}@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1, 150;stroke-dashoffset:0}50%{stroke-dasharray:90, 150;stroke-dashoffset:-35}100%{stroke-dasharray:90, 150;stroke-dashoffset:-124}}";
277
+ const UserActionControllerStyle0 = userActionControllerCss;
278
+
279
+ const UserActionController = class {
280
+ constructor(hostRef) {
281
+ index.registerInstance(this, hostRef);
282
+ //for now this variable is hardcoded bcs we have terms and conditions and privacy policy mandatory and we dont receive with these new functionality the mandatory actions
283
+ this.mandatoryActions = ['termsandconditions', 'privacypolicy'];
284
+ this.userActions = [];
285
+ this.consentTitles = {
286
+ termsandconditions: translate('termsAndConditionsTitle', this.lang),
287
+ sms: translate('smsTitle', this.lang),
288
+ emailmarketing: translate('emailMarketingTitle', this.lang),
289
+ privacypolicy: translate('privacyPolicyTitle', this.lang)
290
+ };
291
+ this.setClientStyling = () => {
292
+ let sheet = document.createElement('style');
293
+ sheet.innerHTML = this.clientStyling;
294
+ this.stylingContainer.prepend(sheet);
295
+ };
296
+ this.setClientStylingURL = () => {
297
+ let url = new URL(this.clientStylingUrl);
298
+ let cssFile = document.createElement('style');
299
+ fetch(url.href)
300
+ .then((res) => res.text())
301
+ .then((data) => {
302
+ this.clientStyling = data;
303
+ cssFile.innerHTML = data;
304
+ setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
305
+ })
306
+ .catch((err) => {
307
+ console.log('error ', err);
308
+ });
309
+ };
310
+ this.endpoint = undefined;
311
+ this.userSession = undefined;
312
+ this.userId = undefined;
313
+ this.lang = 'en';
314
+ this.includeSubmitButton = undefined;
315
+ this.gmVersion = '';
316
+ this.translationUrl = '';
317
+ this.clientStyling = '';
318
+ this.clientStylingUrl = '';
319
+ this.queryFired = false;
320
+ this.readyActionsCount = 0;
321
+ this.activeUserActions = [];
322
+ this.userActionsValidated = true;
323
+ this.receivedQueryResponses = 0;
324
+ this.limitStylingAppends = false;
325
+ this.isLoading = true;
326
+ this.mandatoryActionsChecked = 0;
327
+ this.mandatoryItems = undefined;
328
+ }
329
+ handleNewTranslations() {
330
+ getTranslations(this.translationUrl);
331
+ }
332
+ handleQueryResponse() {
333
+ if (this.receivedQueryResponses === this.activeUserActions.length) {
334
+ this.updateUserConsents();
335
+ }
336
+ }
337
+ userLegislationConsentHandler(event) {
338
+ const actionType = event.detail.type;
339
+ const actionTypeChecked = event.detail.value;
340
+ if (this.mandatoryActions.includes(actionType) && this.queryFired === false) {
341
+ actionTypeChecked === true ? this.mandatoryActionsChecked++ : this.mandatoryActionsChecked--;
342
+ }
343
+ // Register final user choices only if we're ready to update
344
+ if (this.queryFired) {
345
+ const determineStatus = (checked, version) => {
346
+ if (version === 'gm16') {
347
+ return checked ? 1 : 0;
348
+ }
349
+ return checked ? 'Accepted' : 'Denied';
350
+ };
351
+ this.userActions.push(Object.assign({ tagCode: actionType, status: determineStatus(actionTypeChecked, this.gmVersion) }, (this.gmVersion === 'gm16' && { note: '' })));
352
+ this.receivedQueryResponses++;
353
+ }
354
+ }
355
+ determineUserActionsCore() {
356
+ const url = new URL(`${this.endpoint}/v1/player/${this.userId}/consent`);
357
+ const headers = new Headers();
358
+ headers.append('X-SessionId', this.userSession);
359
+ let requestOptions = {
360
+ method: 'GET',
361
+ headers
362
+ };
363
+ return fetch(url.href, requestOptions)
364
+ .then(res => res.json())
365
+ .then(data => {
366
+ const actionItems = data.items;
367
+ actionItems.forEach(element => {
368
+ if (element.status === 'Expired') {
369
+ this.activeUserActions.push(element.tagCode);
370
+ }
371
+ });
372
+ this.isLoading = false;
373
+ })
374
+ .catch(error => {
375
+ console.error('Error fetching data:', error);
376
+ this.isLoading = false;
377
+ }).finally(() => {
378
+ this.calcMandatoryActions();
379
+ window.postMessage({ type: 'UserActionsExists', displayUserActions: this.mandatoryItems > 0 ? true : false }, window.location.href);
380
+ });
381
+ }
382
+ determineUserActions16() {
383
+ const url = new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
384
+ const headers = new Headers();
385
+ headers.append('X-SessionId', this.userSession);
386
+ let requestOptions = {
387
+ method: 'GET',
388
+ headers
389
+ };
390
+ return fetch(url.href, requestOptions)
391
+ .then(res => res.json())
392
+ .then(data => {
393
+ const actionItems = data.consents;
394
+ actionItems.forEach(element => {
395
+ if (element.status === 2 && element.tagCode !== 'pepconsent') {
396
+ this.activeUserActions.push(element.tagCode);
397
+ }
398
+ });
399
+ this.isLoading = false;
400
+ })
401
+ .catch(error => {
402
+ console.error('Error fetching data:', error);
403
+ this.isLoading = false;
404
+ }).finally(() => {
405
+ this.calcMandatoryActions();
406
+ window.postMessage({ type: 'UserActionsExists', displayUserActions: this.mandatoryItems > 0 ? true : false }, window.location.href);
407
+ });
408
+ }
409
+ updateUserConsents() {
410
+ const url = (this.gmVersion === 'gmcore')
411
+ ? new URL(`${this.endpoint}/v1/player/${this.userId}/consent`)
412
+ : new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
413
+ const body = {
414
+ consents: this.userActions
415
+ };
416
+ let requestOptions = {
417
+ method: 'POST',
418
+ headers: {
419
+ 'Content-Type': 'application/json',
420
+ 'Accept': 'application/json',
421
+ 'X-SessionId': `${this.userSession}`,
422
+ },
423
+ body: JSON.stringify(body)
424
+ };
425
+ fetch(url.href, requestOptions)
426
+ .then(res => res.json())
427
+ .then(() => {
428
+ window.postMessage({
429
+ type: 'WidgetNotification',
430
+ data: {
431
+ type: 'success',
432
+ message: 'Consent update successful!'
433
+ }
434
+ }, window.location.href);
435
+ })
436
+ .catch((err) => {
437
+ window.postMessage({
438
+ type: 'WidgetNotification',
439
+ data: {
440
+ type: 'error',
441
+ message: 'Server might not be responding',
442
+ err
443
+ }
444
+ }, window.location.href);
445
+ })
446
+ .finally(() => {
447
+ window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
448
+ });
449
+ }
450
+ handleApplyClick() {
451
+ this.queryFired = true;
452
+ }
453
+ async componentWillLoad() {
454
+ if (this.gmVersion === 'gmcore') {
455
+ this.determineUserActionsCore();
456
+ }
457
+ if (this.gmVersion === 'gm16') {
458
+ this.determineUserActions16();
459
+ }
460
+ if (this.translationUrl.length > 2) {
461
+ await getTranslations(this.translationUrl);
462
+ }
463
+ }
464
+ componentDidRender() {
465
+ // start custom styling area
466
+ if (!this.limitStylingAppends && this.stylingContainer) {
467
+ if (this.clientStyling)
468
+ this.setClientStyling();
469
+ if (this.clientStylingUrl)
470
+ this.setClientStylingURL();
471
+ this.limitStylingAppends = true;
472
+ }
473
+ // end custom styling area
474
+ }
475
+ calcMandatoryActions() {
476
+ this.mandatoryItems = 0;
477
+ this.mandatoryActions.map(action => {
478
+ const isPresent = this.activeUserActions.includes(action);
479
+ if (isPresent) {
480
+ this.mandatoryItems++;
481
+ }
482
+ });
483
+ }
484
+ render() {
485
+ if (this.mandatoryItems > 0) {
486
+ this.userActionsValidated = this.mandatoryActionsChecked === this.mandatoryItems;
487
+ return (index.h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (index.h("slot", { name: 'spinner' })
488
+ &&
489
+ index.h("svg", { class: "spinner", viewBox: "0 0 50 50" }, index.h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (index.h("div", { class: "UserActionController" }, index.h("h2", { class: "UserConsentNotice" }, translate('userNoticeText', this.lang)), index.h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (index.h("slot", { name: action }, index.h("player-user-consents", { lang: this.lang, "gm-version": this.gmVersion, "translation-url": this.translationUrl, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
490
+ index.h("button", { class: "ConsentSubmitButton", disabled: !this.userActionsValidated, onClick: () => this.handleApplyClick() }, translate('submitButtonText', this.lang))))));
491
+ }
492
+ else {
493
+ return;
494
+ }
495
+ }
496
+ static get watchers() { return {
497
+ "translationUrl": ["handleNewTranslations"],
498
+ "receivedQueryResponses": ["handleQueryResponse"]
499
+ }; }
500
+ };
501
+ UserActionController.style = UserActionControllerStyle0;
502
+
503
+ exports.player_user_consents = PlayerUserConsents;
504
+ exports.user_action_controller = UserActionController;
@@ -1,19 +1,25 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index-5b463836.js');
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-c5061e5a.js');
6
+ const appGlobals = require('./app-globals-3a1e7e63.js');
4
7
 
5
8
  /*
6
- Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
9
+ Stencil Client Patch Browser v4.20.0 | MIT Licensed | https://stenciljs.com
7
10
  */
8
- const patchBrowser = () => {
9
- const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('user-action-controller.cjs.js', document.baseURI).href));
10
- const opts = {};
11
- if (importMeta !== '') {
12
- opts.resourcesUrl = new URL('.', importMeta).href;
13
- }
14
- return index.promiseResolve(opts);
11
+ var patchBrowser = () => {
12
+ const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('user-action-controller.cjs.js', document.baseURI).href));
13
+ const opts = {};
14
+ if (importMeta !== "") {
15
+ opts.resourcesUrl = new URL(".", importMeta).href;
16
+ }
17
+ return index.promiseResolve(opts);
15
18
  };
16
19
 
17
- patchBrowser().then(options => {
18
- return index.bootstrapLazy([["generic-user-consent_3.cjs",[[1,"user-action-controller",{"endpoint":[1],"userSession":[1,"user-session"],"userId":[1,"user-id"],"includeSubmitButton":[4,"include-submit-button"],"submitButtonText":[1,"submit-button-text"],"userNoticeText":[1,"user-notice-text"],"activeUserActions":[1,"active-user-actions"],"showCloseButton":[4,"show-close-button"],"usePostmessage":[4,"use-postmessage"],"postMessageEvent":[1,"post-message-event"],"queryFired":[32],"readyActionsCount":[32],"receivedQueryResponses":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"generic-user-consent",{"queried":[4],"consentType":[1,"consent-type"],"mandatory":[4],"consentTitle":[1,"consent-title"],"tcLink":[1,"tc-link"],"privacyLink":[1,"privacy-link"],"textContent":[32]}],[1,"legislation-wrapper",{"activeUserActions":[1,"active-user-actions"]}]]]], options);
20
+ patchBrowser().then(async (options) => {
21
+ await appGlobals.globalScripts();
22
+ return index.bootstrapLazy([["player-user-consents_2.cjs",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"lang":[1537],"includeSubmitButton":[516,"include-submit-button"],"gmVersion":[1,"gm-version"],"translationUrl":[513,"translation-url"],"clientStyling":[1537,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"queryFired":[32],"readyActionsCount":[32],"activeUserActions":[32],"userActionsValidated":[32],"receivedQueryResponses":[32],"limitStylingAppends":[32],"isLoading":[32],"mandatoryActionsChecked":[32],"mandatoryItems":[32]},[[0,"userLegislationConsent","userLegislationConsentHandler"]],{"translationUrl":["handleNewTranslations"],"receivedQueryResponses":["handleQueryResponse"]}],[1,"player-user-consents",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"gmVersion":[1,"gm-version"],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"translationUrl":[513,"translation-url"],"textContent":[32],"limitStylingAppends":[32]},null,{"translationUrl":["handleNewTranslations"]}]]]], options);
19
23
  });
24
+
25
+ exports.setNonce = index.setNonce;
@@ -1,23 +1,17 @@
1
1
  {
2
2
  "entries": [
3
- "./components/user-action-controller/user-action-controller.js"
3
+ "components/user-action-controller/user-action-controller.js"
4
4
  ],
5
5
  "compiler": {
6
6
  "name": "@stencil/core",
7
- "version": "2.15.2",
8
- "typescriptVersion": "4.5.4"
7
+ "version": "4.20.0",
8
+ "typescriptVersion": "5.5.3"
9
9
  },
10
10
  "collections": [
11
11
  {
12
- "name": "@everymatrix/generic-user-consent",
12
+ "name": "@everymatrix/player-user-consents",
13
13
  "tags": [
14
- "generic-user-consent"
15
- ]
16
- },
17
- {
18
- "name": "@everymatrix/legislation-wrapper",
19
- "tags": [
20
- "legislation-wrapper"
14
+ "player-user-consents"
21
15
  ]
22
16
  }
23
17
  ],
@@ -0,0 +1 @@
1
+ export { UserActionController } from './user-action-controller';
@@ -40,10 +40,12 @@
40
40
  color: #000;
41
41
  border-radius: 5px;
42
42
  align-self: flex-end;
43
+ cursor: pointer;
43
44
  }
44
45
  .ConsentSubmitButton:disabled {
45
46
  border: 2px solid #ccc;
46
47
  color: #ccc;
48
+ cursor: unset;
47
49
  }
48
50
 
49
51
  @media screen and (max-width: 320px) {
@@ -51,4 +53,39 @@
51
53
  font-size: 0.8rem;
52
54
  color: blue;
53
55
  }
56
+ }
57
+ .spinner {
58
+ animation: rotate 2s linear infinite;
59
+ z-index: 2;
60
+ position: absolute;
61
+ top: 50%;
62
+ left: 50%;
63
+ margin: -25px 0 0 -25px;
64
+ width: 50px;
65
+ height: 50px;
66
+ }
67
+ .spinner .path {
68
+ stroke: var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C));
69
+ stroke-linecap: round;
70
+ animation: dash 1.5s ease-in-out infinite;
71
+ }
72
+
73
+ @keyframes rotate {
74
+ 100% {
75
+ transform: rotate(360deg);
76
+ }
77
+ }
78
+ @keyframes dash {
79
+ 0% {
80
+ stroke-dasharray: 1, 150;
81
+ stroke-dashoffset: 0;
82
+ }
83
+ 50% {
84
+ stroke-dasharray: 90, 150;
85
+ stroke-dashoffset: -35;
86
+ }
87
+ 100% {
88
+ stroke-dasharray: 90, 150;
89
+ stroke-dashoffset: -124;
90
+ }
54
91
  }