@everymatrix/user-action-controller 1.34.0 → 1.35.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.
@@ -3,58 +3,94 @@ import { r as registerInstance, c as createEvent, h } from './index-71f14530.js'
3
3
  const DEFAULT_LANGUAGE$1 = 'en';
4
4
  const TRANSLATIONS$1 = {
5
5
  en: {
6
- termsandconditions1: "I accept the ",
7
- termsandconditions2: ", I have read and understood the ",
8
- termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
9
- tc: "Terms and Conditions",
10
- privacy: "Privacy Policy",
6
+ termsAndConditions: {
7
+ acceptPart1: "I accept the ",
8
+ acceptPart2: ", I have read and understood the ",
9
+ acceptPart3: " as published on this site and confirm that I am over 18 years old.",
10
+ tc: "Terms and Conditions"
11
+ },
12
+ privacyPolicy: {
13
+ readUnderstandPart1: "I have read and understood the ",
14
+ readUnderstandPart2: ", as published on this site and confirm that I am over 18 years old.",
15
+ privacy: "Privacy Policy"
16
+ },
11
17
  sms: "I consent to receive marketing communication via SMS.",
12
- emailmarketing: "I consent to receive marketing communication via Email."
18
+ email: "I consent to receive marketing communication via Email."
13
19
  },
14
20
  ro: {
15
- termsandconditions1: "Accept ",
16
- termsandconditions2: " platformei. Am citit şi înţeles ",
17
- termsandconditions3: " publicată pe acest site şi confirm că am vârstă peste 18 ani.",
18
- tc: "Termenii şi condiţiile",
19
- privacy: "Politica de confidenţialitate",
21
+ termsAndConditions: {
22
+ acceptPart1: "Accept ",
23
+ acceptPart2: " platformei. Am citit şi înţeles ",
24
+ acceptPart3: " publicată pe acest site şi confirm că am vârstă peste 18 ani.",
25
+ tc: "Termenii şi condiţiile"
26
+ },
27
+ privacyPolicy: {
28
+ readUnderstandPart1: "Am citit şi înţeles ",
29
+ readUnderstandPart2: " publicată pe acest site şi confirm că am vârstă peste 18 ani.",
30
+ privacy: "Politica de confidenţialitate"
31
+ },
20
32
  sms: "Sunt de acord să primesc promoţii de marketing prin SMS.",
21
- emailmarketing: "Sunt de acord să primesc promoţii de marketing pe e-mail."
33
+ email: "Sunt de acord să primesc promoţii de marketing pe e-mail."
22
34
  },
23
35
  hr: {
24
- termsandconditions1: "I accept the ",
25
- termsandconditions2: ", I have read and understood the ",
26
- termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
27
- tc: "Terms and Conditions",
28
- privacy: "Privacy Policy",
36
+ termsAndConditions: {
37
+ acceptPart1: "I accept the ",
38
+ acceptPart2: ", I have read and understood the ",
39
+ acceptPart3: " as published on this site and confirm that I am over 18 years old.",
40
+ tc: "Terms and Conditions"
41
+ },
42
+ privacyPolicy: {
43
+ readUnderstandPart1: "I have read and understood the ",
44
+ readUnderstandPart2: ", as published on this site and confirm that I am over 18 years old.",
45
+ privacy: "Privacy Policy"
46
+ },
29
47
  sms: "I consent to receive marketing communication via SMS.",
30
- emailmarketing: "I consent to receive marketing communication via Email."
48
+ email: "I consent to receive marketing communication via Email."
31
49
  },
32
50
  fr: {
33
- termsandconditions1: "I accept the ",
34
- termsandconditions2: ", I have read and understood the ",
35
- termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
36
- tc: "Terms and Conditions",
37
- privacy: "Privacy Policy",
51
+ termsAndConditions: {
52
+ acceptPart1: "I accept the ",
53
+ acceptPart2: ", I have read and understood the ",
54
+ acceptPart3: " as published on this site and confirm that I am over 18 years old.",
55
+ tc: "Terms and Conditions"
56
+ },
57
+ privacyPolicy: {
58
+ readUnderstandPart1: "I have read and understood the ",
59
+ readUnderstandPart2: ", as published on this site and confirm that I am over 18 years old.",
60
+ privacy: "Privacy Policy"
61
+ },
38
62
  sms: "I consent to receive marketing communication via SMS.",
39
- emailmarketing: "I consent to receive marketing communication via Email."
63
+ email: "I consent to receive marketing communication via Email."
40
64
  },
41
65
  cs: {
42
- termsandconditions1: "I accept the ",
43
- termsandconditions2: ", I have read and understood the ",
44
- termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
45
- tc: "Terms and Conditions",
46
- privacy: "Privacy Policy",
66
+ termsAndConditions: {
67
+ acceptPart1: "I accept the ",
68
+ acceptPart2: ", I have read and understood the ",
69
+ acceptPart3: " as published on this site and confirm that I am over 18 years old.",
70
+ tc: "Terms and Conditions"
71
+ },
72
+ privacyPolicy: {
73
+ readUnderstandPart1: "I have read and understood the ",
74
+ readUnderstandPart2: ", as published on this site and confirm that I am over 18 years old.",
75
+ privacy: "Privacy Policy"
76
+ },
47
77
  sms: "I consent to receive marketing communication via SMS.",
48
- emailmarketing: "I consent to receive marketing communication via Email."
78
+ email: "I consent to receive marketing communication via Email."
49
79
  },
50
80
  de: {
51
- termsandconditions1: "I accept the ",
52
- termsandconditions2: ", I have read and understood the ",
53
- termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
54
- tc: "Terms and Conditions",
55
- privacy: "Privacy Policy",
81
+ termsAndConditions: {
82
+ acceptPart1: "I accept the ",
83
+ acceptPart2: ", I have read and understood the ",
84
+ acceptPart3: " as published on this site and confirm that I am over 18 years old.",
85
+ tc: "Terms and Conditions"
86
+ },
87
+ privacyPolicy: {
88
+ readUnderstandPart1: "I have read and understood the ",
89
+ readUnderstandPart2: ", as published on this site and confirm that I am over 18 years old.",
90
+ privacy: "Privacy Policy"
91
+ },
56
92
  sms: "I consent to receive marketing communication via SMS.",
57
- emailmarketing: "I consent to receive marketing communication via Email."
93
+ email: "I consent to receive marketing communication via Email."
58
94
  },
59
95
  };
60
96
  const getTranslations$1 = (url) => {
@@ -73,12 +109,18 @@ const getTranslations$1 = (url) => {
73
109
  });
74
110
  };
75
111
  const translate$1 = (key, customLang, values) => {
76
- const lang = customLang;
77
- let translation = TRANSLATIONS$1[lang !== undefined ? lang : DEFAULT_LANGUAGE$1][key];
112
+ const lang = customLang || DEFAULT_LANGUAGE$1;
113
+ const getNestedTranslation = (obj, path) => {
114
+ return path.split('.').reduce((o, k) => (o && o[k] !== undefined ? o[k] : null), obj);
115
+ };
116
+ let translation = getNestedTranslation(TRANSLATIONS$1[lang], key);
117
+ if (translation === null) {
118
+ return key;
119
+ }
78
120
  if (values !== undefined) {
79
- for (const [key, value] of Object.entries(values.values)) {
80
- const regex = new RegExp(`{${key}}`, 'g');
81
- translation = translation.replace(regex, value);
121
+ for (const [k, v] of Object.entries(values)) {
122
+ const regex = new RegExp(`{${k}}`, 'g');
123
+ translation = translation.replace(regex, v);
82
124
  }
83
125
  }
84
126
  return translation;
@@ -106,6 +148,10 @@ const PlayerUserConsents = class {
106
148
  * wether or not this consent is mandatory. Used for render details
107
149
  */
108
150
  this.mandatory = false;
151
+ /**
152
+ * Select GM version
153
+ */
154
+ this.gmVersion = '';
109
155
  /**
110
156
  * the title of the consent to be displayed
111
157
  */
@@ -155,9 +201,20 @@ const PlayerUserConsents = class {
155
201
  // end custom styling area
156
202
  }
157
203
  determineTextContent() {
158
- return this.consentType === 'termsandconditions' ?
159
- h("p", null, translate$1('termsandconditions1', this.lang), h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate$1('tc', this.lang)), translate$1('termsandconditions2', this.lang), h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate$1('privacy', this.lang)), translate$1('termsandconditions3', this.lang))
160
- : h("p", null, translate$1(this.consentType, this.lang));
204
+ if (this.gmVersion === 'gmcore') {
205
+ if (this.consentType === 'termsandconditions') {
206
+ return h("p", null, translate$1('termsAndConditions.acceptPart1', this.lang), h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate$1('termsAndConditions.tc', this.lang)), translate$1('termsAndConditions.acceptPart2', this.lang), h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate$1('privacyPolicy.privacy', this.lang)), translate$1('termsAndConditions.acceptPart3', this.lang));
207
+ }
208
+ }
209
+ if (this.gmVersion === 'gm16') {
210
+ if (this.consentType === 'termsandconditions') {
211
+ return h("p", null, translate$1('termsAndConditions.acceptPart1', this.lang), h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate$1('termsAndConditions.tc', this.lang)));
212
+ }
213
+ if (this.consentType === 'privacypolicy') {
214
+ return h("p", null, translate$1('privacyPolicy.readUnderstandPart1', this.lang), h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate$1('privacyPolicy.privacy', this.lang)), translate$1('privacyPolicy.readUnderstandPart2', this.lang));
215
+ }
216
+ }
217
+ return h("p", null, translate$1(this.consentType, this.lang));
161
218
  }
162
219
  render() {
163
220
  if (this.queried) {
@@ -177,32 +234,38 @@ const TRANSLATIONS = {
177
234
  en: {
178
235
  termsandconditions: 'Terms and Conditions',
179
236
  sms: 'SMS marketing',
180
- emailmarketing: 'Email marketing'
237
+ emailmarketing: 'Email marketing',
238
+ privacypolicy: 'Privacy Policy'
181
239
  },
182
240
  ro: {
183
241
  termsandconditions: 'Termeni şi condiţii',
184
242
  sms: 'SMS marketing',
185
- emailmarketing: 'Email marketing'
243
+ emailmarketing: 'Email marketing',
244
+ privacypolicy: 'Privacy Policy'
186
245
  },
187
246
  hr: {
188
247
  termsandconditions: 'Terms and Conditions',
189
248
  sms: 'SMS marketing',
190
- emailmarketing: 'Email marketing'
249
+ emailmarketing: 'Email marketing',
250
+ privacypolicy: 'Privacy Policy'
191
251
  },
192
252
  fr: {
193
253
  termsandconditions: 'Terms and Conditions',
194
254
  sms: 'SMS marketing',
195
- emailmarketing: 'Email marketing'
255
+ emailmarketing: 'Email marketing',
256
+ privacypolicy: 'Privacy Policy'
196
257
  },
197
258
  cs: {
198
259
  termsandconditions: 'Terms and Conditions',
199
260
  sms: 'SMS marketing',
200
- emailmarketing: 'Email marketing'
261
+ emailmarketing: 'Email marketing',
262
+ privacypolicy: 'Privacy Policy'
201
263
  },
202
264
  de: {
203
265
  termsandconditions: 'Terms and Conditions',
204
266
  sms: 'SMS marketing',
205
- emailmarketing: 'Email marketing'
267
+ emailmarketing: 'Email marketing',
268
+ privacypolicy: 'Privacy Policy'
206
269
  },
207
270
  };
208
271
  const getTranslations = (url) => {
@@ -268,13 +331,14 @@ const UserActionController = class {
268
331
  this.limitStylingAppends = false;
269
332
  this.isLoading = true;
270
333
  this.mandatoryActionsChecked = 0;
271
- //for now this variable is hardcoded bcs we have only terms and conditions mandatory and we dont receive with these new functionality the mandatory actions
272
- this.mandatoryActions = ['termsandconditions'];
334
+ //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
335
+ this.mandatoryActions = ['termsandconditions', 'privacypolicy'];
273
336
  this.userActions = [];
274
337
  this.consentTitles = {
275
338
  termsandconditions: translate('termsandconditions', this.lang),
276
339
  sms: translate('sms', this.lang),
277
- emailmarketing: translate('emailmarketing', this.lang)
340
+ emailmarketing: translate('emailmarketing', this.lang),
341
+ privacypolicy: translate('privacypolicy', this.lang)
278
342
  };
279
343
  this.setClientStyling = () => {
280
344
  let sheet = document.createElement('style');
@@ -316,56 +380,62 @@ const UserActionController = class {
316
380
  this.receivedQueryResponses++;
317
381
  }
318
382
  }
319
- determineUserActions() {
383
+ determineUserActionsCore() {
320
384
  const url = new URL(`${this.endpoint}/v1/player/${this.userId}/consent`);
321
385
  const headers = new Headers();
322
386
  headers.append('X-SessionId', this.userSession);
323
- let requestOptions;
324
- requestOptions = {
387
+ let requestOptions = {
325
388
  method: 'GET',
326
389
  headers
327
390
  };
328
- if (url && requestOptions) {
329
- return fetch(url.href, requestOptions)
330
- .then(res => res.json())
331
- .then(data => {
332
- const actionItems = data.items;
333
- actionItems.forEach(element => {
334
- if (element.status === 'Expired') {
335
- this.activeUserActions.push(element.tagCode);
336
- }
337
- });
338
- this.isLoading = false;
339
- })
340
- .catch(error => {
341
- console.error('Error fetching data:', error);
342
- this.isLoading = false;
391
+ return fetch(url.href, requestOptions)
392
+ .then(res => res.json())
393
+ .then(data => {
394
+ const actionItems = data.items;
395
+ actionItems.forEach(element => {
396
+ if (element.status === 'Expired') {
397
+ this.activeUserActions.push(element.tagCode);
398
+ }
343
399
  });
344
- }
345
- else {
346
- return Promise.reject('Unsupported endpoint');
347
- }
400
+ this.isLoading = false;
401
+ })
402
+ .catch(error => {
403
+ console.error('Error fetching data:', error);
404
+ this.isLoading = false;
405
+ });
406
+ }
407
+ determineUserActions16() {
408
+ const url = new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
409
+ const headers = new Headers();
410
+ headers.append('X-SessionId', this.userSession);
411
+ let requestOptions = {
412
+ method: 'GET',
413
+ headers
414
+ };
415
+ return fetch(url.href, requestOptions)
416
+ .then(res => res.json())
417
+ .then(data => {
418
+ const actionItems = data.consents;
419
+ actionItems.forEach(element => {
420
+ if (element.status === 2) {
421
+ this.activeUserActions.push(element.tagCode);
422
+ }
423
+ });
424
+ this.isLoading = false;
425
+ })
426
+ .catch(error => {
427
+ console.error('Error fetching data:', error);
428
+ this.isLoading = false;
429
+ });
348
430
  }
349
431
  updateUserConsents() {
350
- let url;
351
- let requestOptions;
352
- url = (this.gmVersion === 'gmcore')
432
+ const url = (this.gmVersion === 'gmcore')
353
433
  ? new URL(`${this.endpoint}/v1/player/${this.userId}/consent`)
354
434
  : new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);
355
- const body = (this.gmVersion === 'gmcore')
356
- ? {
357
- items: this.userActions
358
- }
359
- : {
360
- consents: [
361
- {
362
- tagCode: "termsandconditions",
363
- note: "",
364
- status: 1
365
- }
366
- ]
367
- };
368
- requestOptions = {
435
+ const body = {
436
+ items: this.userActions
437
+ };
438
+ let requestOptions = {
369
439
  method: 'POST',
370
440
  headers: {
371
441
  'Content-Type': 'application/json',
@@ -374,43 +444,40 @@ const UserActionController = class {
374
444
  },
375
445
  body: JSON.stringify(body)
376
446
  };
377
- if (url && requestOptions) {
378
- fetch(url.href, requestOptions)
379
- .then(res => res.json())
380
- .then(() => {
381
- window.postMessage({
382
- type: 'WidgetNotification',
383
- data: {
384
- type: 'success',
385
- message: 'Consent update successful!'
386
- }
387
- }, window.location.href);
388
- })
389
- .catch((err) => {
390
- window.postMessage({
391
- type: 'WidgetNotification',
392
- data: {
393
- type: 'error',
394
- message: 'Server might not be responding',
395
- err
396
- }
397
- }, window.location.href);
398
- })
399
- .finally(() => {
400
- window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
401
- });
402
- }
447
+ fetch(url.href, requestOptions)
448
+ .then(res => res.json())
449
+ .then(() => {
450
+ window.postMessage({
451
+ type: 'WidgetNotification',
452
+ data: {
453
+ type: 'success',
454
+ message: 'Consent update successful!'
455
+ }
456
+ }, window.location.href);
457
+ })
458
+ .catch((err) => {
459
+ window.postMessage({
460
+ type: 'WidgetNotification',
461
+ data: {
462
+ type: 'error',
463
+ message: 'Server might not be responding',
464
+ err
465
+ }
466
+ }, window.location.href);
467
+ })
468
+ .finally(() => {
469
+ window.postMessage({ type: 'UserActionsCompleted' }, window.location.href);
470
+ });
403
471
  }
404
472
  handleApplyClick() {
405
473
  this.queryFired = true;
406
474
  }
407
475
  async componentWillLoad() {
408
476
  if (this.gmVersion === 'gmcore') {
409
- return this.determineUserActions();
477
+ this.determineUserActionsCore();
410
478
  }
411
- else {
412
- this.activeUserActions = ['termsandconditions'];
413
- this.isLoading = false;
479
+ if (this.gmVersion === 'gm16') {
480
+ this.determineUserActions16();
414
481
  }
415
482
  if (this.translationUrl.length > 2) {
416
483
  await getTranslations(this.translationUrl);
@@ -428,17 +495,19 @@ const UserActionController = class {
428
495
  // end custom styling area
429
496
  }
430
497
  render() {
431
- const isMandatoryPresent = this.mandatoryActions.every(action => this.activeUserActions.includes(action));
432
- if (isMandatoryPresent) {
433
- this.userActionsValidated = !(this.mandatoryActionsChecked === this.mandatoryActions.length);
434
- }
435
- else {
436
- this.userActionsValidated = false;
437
- }
498
+ let mandatoryItems = 0;
499
+ const isMandatoryPresent = this.mandatoryActions.some(action => {
500
+ const isPresent = this.activeUserActions.includes(action);
501
+ if (isPresent) {
502
+ mandatoryItems++;
503
+ }
504
+ return isPresent;
505
+ });
506
+ this.userActionsValidated = isMandatoryPresent && (this.mandatoryActionsChecked === mandatoryItems);
438
507
  return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (h("slot", { name: 'spinner' })
439
508
  &&
440
- h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" }, h("h2", { class: "UserConsentNotice" }, this.userNoticeText), h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action }, h("player-user-consents", { lang: this.lang, "translation-url": this.translationUrl, slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
441
- h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
509
+ h("svg", { class: "spinner", viewBox: "0 0 50 50" }, h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" }, h("h2", { class: "UserConsentNotice" }, this.userNoticeText), h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action }, h("player-user-consents", { lang: this.lang, "gm-version": this.gmVersion, "translation-url": this.translationUrl, slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
510
+ h("button", { class: "ConsentSubmitButton", disabled: !this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
442
511
  }
443
512
  static get watchers() { return {
444
513
  "translationUrl": ["handleNewTranslations"],
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["player-user-consents_2",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"lang":[1537],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"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]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-user-consents",{"lang":[1537],"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"translationUrl":[513,"translation-url"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
16
+ return bootstrapLazy([["player-user-consents_2",[[1,"user-action-controller",{"endpoint":[513],"userSession":[513,"user-session"],"userId":[513,"user-id"],"lang":[1537],"includeSubmitButton":[516,"include-submit-button"],"submitButtonText":[513,"submit-button-text"],"userNoticeText":[513,"user-notice-text"],"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]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[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]}]]]], options);
17
17
  });
@@ -66,7 +66,8 @@ export declare class UserActionController {
66
66
  private userActions;
67
67
  private stylingContainer;
68
68
  private consentTitles;
69
- determineUserActions(): Promise<void>;
69
+ determineUserActionsCore(): Promise<void>;
70
+ determineUserActions16(): Promise<void>;
70
71
  updateUserConsents(): void;
71
72
  handleApplyClick(): void;
72
73
  componentWillLoad(): Promise<void>;
@@ -0,0 +1 @@
1
+ import{r as t,c as e,h as i}from"./p-ba444709.js";const s={en:{termsAndConditions:{acceptPart1:"I accept the ",acceptPart2:", I have read and understood the ",acceptPart3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions"},privacyPolicy:{readUnderstandPart1:"I have read and understood the ",readUnderstandPart2:", as published on this site and confirm that I am over 18 years old.",privacy:"Privacy Policy"},sms:"I consent to receive marketing communication via SMS.",email:"I consent to receive marketing communication via Email."},ro:{termsAndConditions:{acceptPart1:"Accept ",acceptPart2:" platformei. Am citit şi înţeles ",acceptPart3:" publicată pe acest site şi confirm că am vârstă peste 18 ani.",tc:"Termenii şi condiţiile"},privacyPolicy:{readUnderstandPart1:"Am citit şi înţeles ",readUnderstandPart2:" publicată pe acest site şi confirm că am vârstă peste 18 ani.",privacy:"Politica de confidenţialitate"},sms:"Sunt de acord să primesc promoţii de marketing prin SMS.",email:"Sunt de acord să primesc promoţii de marketing pe e-mail."},hr:{termsAndConditions:{acceptPart1:"I accept the ",acceptPart2:", I have read and understood the ",acceptPart3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions"},privacyPolicy:{readUnderstandPart1:"I have read and understood the ",readUnderstandPart2:", as published on this site and confirm that I am over 18 years old.",privacy:"Privacy Policy"},sms:"I consent to receive marketing communication via SMS.",email:"I consent to receive marketing communication via Email."},fr:{termsAndConditions:{acceptPart1:"I accept the ",acceptPart2:", I have read and understood the ",acceptPart3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions"},privacyPolicy:{readUnderstandPart1:"I have read and understood the ",readUnderstandPart2:", as published on this site and confirm that I am over 18 years old.",privacy:"Privacy Policy"},sms:"I consent to receive marketing communication via SMS.",email:"I consent to receive marketing communication via Email."},cs:{termsAndConditions:{acceptPart1:"I accept the ",acceptPart2:", I have read and understood the ",acceptPart3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions"},privacyPolicy:{readUnderstandPart1:"I have read and understood the ",readUnderstandPart2:", as published on this site and confirm that I am over 18 years old.",privacy:"Privacy Policy"},sms:"I consent to receive marketing communication via SMS.",email:"I consent to receive marketing communication via Email."},de:{termsAndConditions:{acceptPart1:"I accept the ",acceptPart2:", I have read and understood the ",acceptPart3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions"},privacyPolicy:{readUnderstandPart1:"I have read and understood the ",readUnderstandPart2:", as published on this site and confirm that I am over 18 years old.",privacy:"Privacy Policy"},sms:"I consent to receive marketing communication via SMS.",email:"I consent to receive marketing communication via Email."}},n=t=>new Promise((e=>{fetch(t).then((t=>t.json())).then((t=>{Object.keys(t).forEach((e=>{for(let i in t[e])s[e][i]=t[e][i]})),e(!0)}))})),a=(t,e,i)=>{let n=(a=s[e||"en"],t.split(".").reduce(((t,e)=>t&&void 0!==t[e]?t[e]:null),a));var a;if(null===n)return t;if(void 0!==i)for(const[t,e]of Object.entries(i)){const i=new RegExp(`{${t}}`,"g");n=n.replace(i,e)}return n},r=class{constructor(i){t(this,i),this.userLegislationConsent=e(this,"userLegislationConsent",7),this.lang="en",this.queried=!1,this.consentType="",this.mandatory=!1,this.gmVersion="",this.consentTitle="",this.clientStyling="",this.translationUrl="",this.textContent="",this.limitStylingAppends=!1,this.goToTermsAndConditions=()=>window.postMessage({type:"GoToTermsAndConditions"}),this.goToPrivacyPolicy=()=>window.postMessage({type:"GoToPrivacyPolicy"}),this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}handleNewTranslations(){n(this.translationUrl)}async componentWillLoad(){this.translationUrl.length>2&&await n(this.translationUrl)}userLegislationConsentHandler(){this.userLegislationConsent.emit({type:this.consentType,value:this.checkboxInput.checked})}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}determineTextContent(){if("gmcore"===this.gmVersion&&"termsandconditions"===this.consentType)return i("p",null,a("termsAndConditions.acceptPart1",this.lang),i("span",{class:"ConsentLink",onClick:this.goToTermsAndConditions},a("termsAndConditions.tc",this.lang)),a("termsAndConditions.acceptPart2",this.lang),i("span",{class:"ConsentLink",onClick:this.goToPrivacyPolicy},a("privacyPolicy.privacy",this.lang)),a("termsAndConditions.acceptPart3",this.lang));if("gm16"===this.gmVersion){if("termsandconditions"===this.consentType)return i("p",null,a("termsAndConditions.acceptPart1",this.lang),i("span",{class:"ConsentLink",onClick:this.goToTermsAndConditions},a("termsAndConditions.tc",this.lang)));if("privacypolicy"===this.consentType)return i("p",null,a("privacyPolicy.readUnderstandPart1",this.lang),i("span",{class:"ConsentLink",onClick:this.goToPrivacyPolicy},a("privacyPolicy.privacy",this.lang)),a("privacyPolicy.readUnderstandPart2",this.lang))}return i("p",null,a(this.consentType,this.lang))}render(){return this.queried&&this.userLegislationConsentHandler(),i("div",{ref:t=>this.stylingContainer=t},i("p",{class:"ConsentTitle"},this.consentTitle),i("label",{class:"UserConsent",htmlFor:"userConsent"},i("input",{ref:t=>this.checkboxInput=t,id:"userConsent",type:"checkbox",onInput:()=>this.userLegislationConsentHandler()}),this.determineTextContent(),this.mandatory&&i("span",{class:"MandatoryItem"},"*")))}static get watchers(){return{translationUrl:["handleNewTranslations"]}}};r.style=":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}";const o=["ro","en","cz","de","hr"],c={en:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing",privacypolicy:"Privacy Policy"},ro:{termsandconditions:"Termeni şi condiţii",sms:"SMS marketing",emailmarketing:"Email marketing",privacypolicy:"Privacy Policy"},hr:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing",privacypolicy:"Privacy Policy"},fr:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing",privacypolicy:"Privacy Policy"},cs:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing",privacypolicy:"Privacy Policy"},de:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing",privacypolicy:"Privacy Policy"}},d=t=>new Promise((e=>{fetch(t).then((t=>t.json())).then((t=>{Object.keys(t).forEach((e=>{for(let i in t[e])c[e][i]=t[e][i]})),e(!0)}))})),h=(t,e,i)=>{const s=e;let n=c[void 0!==s&&o.includes(s)?s:"en"][t];if(void 0!==i)for(const[t,e]of Object.entries(i.values)){const i=new RegExp(`{${t}}`,"g");n=n.replace(i,e)}return n},l=class{constructor(e){t(this,e),this.lang="en",this.gmVersion="",this.translationUrl="",this.clientStyling="",this.clientStylingUrl="",this.queryFired=!1,this.readyActionsCount=0,this.activeUserActions=[],this.userActionsValidated=!0,this.receivedQueryResponses=0,this.limitStylingAppends=!1,this.isLoading=!0,this.mandatoryActionsChecked=0,this.mandatoryActions=["termsandconditions","privacypolicy"],this.userActions=[],this.consentTitles={termsandconditions:h("termsandconditions",this.lang),sms:h("sms",this.lang),emailmarketing:h("emailmarketing",this.lang),privacypolicy:h("privacypolicy",this.lang)},this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),e=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{this.clientStyling=t,e.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(e)}),1)})).catch((t=>{console.log("error ",t)}))}}handleNewTranslations(){d(this.translationUrl)}handleQueryResponse(){this.receivedQueryResponses===this.activeUserActions.length&&this.updateUserConsents()}userLegislationConsentHandler(t){const e=t.detail.type,i=t.detail.value;this.mandatoryActions.includes(e)&&!1===this.queryFired&&(!0===i?this.mandatoryActionsChecked++:this.mandatoryActionsChecked--),this.queryFired&&(this.userActions.push({tagCode:e,status:i?"Accepted":"Denied"}),this.receivedQueryResponses++)}determineUserActionsCore(){const t=new URL(`${this.endpoint}/v1/player/${this.userId}/consent`),e=new Headers;return e.append("X-SessionId",this.userSession),fetch(t.href,{method:"GET",headers:e}).then((t=>t.json())).then((t=>{t.items.forEach((t=>{"Expired"===t.status&&this.activeUserActions.push(t.tagCode)})),this.isLoading=!1})).catch((t=>{console.error("Error fetching data:",t),this.isLoading=!1}))}determineUserActions16(){const t=new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`),e=new Headers;return e.append("X-SessionId",this.userSession),fetch(t.href,{method:"GET",headers:e}).then((t=>t.json())).then((t=>{t.consents.forEach((t=>{2===t.status&&this.activeUserActions.push(t.tagCode)})),this.isLoading=!1})).catch((t=>{console.error("Error fetching data:",t),this.isLoading=!1}))}updateUserConsents(){const t="gmcore"===this.gmVersion?new URL(`${this.endpoint}/v1/player/${this.userId}/consent`):new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`);let e={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-SessionId":`${this.userSession}`},body:JSON.stringify({items:this.userActions})};fetch(t.href,e).then((t=>t.json())).then((()=>{window.postMessage({type:"WidgetNotification",data:{type:"success",message:"Consent update successful!"}},window.location.href)})).catch((t=>{window.postMessage({type:"WidgetNotification",data:{type:"error",message:"Server might not be responding",err:t}},window.location.href)})).finally((()=>{window.postMessage({type:"UserActionsCompleted"},window.location.href)}))}handleApplyClick(){this.queryFired=!0}async componentWillLoad(){"gmcore"===this.gmVersion&&this.determineUserActionsCore(),"gm16"===this.gmVersion&&this.determineUserActions16(),this.translationUrl.length>2&&await d(this.translationUrl)}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.limitStylingAppends=!0)}render(){let t=0;const e=this.mandatoryActions.some((e=>{const i=this.activeUserActions.includes(e);return i&&t++,i}));return this.userActionsValidated=e&&this.mandatoryActionsChecked===t,i("div",{class:"QueryReferenceContainer",ref:t=>this.stylingContainer=t},this.isLoading?i("slot",{name:"spinner"})&&i("svg",{class:"spinner",viewBox:"0 0 50 50"},i("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"5"})):i("div",{class:"UserActionController"},i("h2",{class:"UserConsentNotice"},this.userNoticeText),i("div",{class:"PlayerLegislationWrapper"},this.activeUserActions.map((t=>i("slot",{name:t},i("player-user-consents",{lang:this.lang,"gm-version":this.gmVersion,"translation-url":this.translationUrl,slot:t,consentType:t,consentTitle:this.consentTitles[t],queried:this.queryFired,mandatory:this.mandatoryActions.includes(t),"client-styling":this.clientStyling}))))),this.includeSubmitButton&&i("button",{class:"ConsentSubmitButton",disabled:!this.userActionsValidated,onClick:()=>this.handleApplyClick()},this.submitButtonText)))}static get watchers(){return{translationUrl:["handleNewTranslations"],receivedQueryResponses:["handleQueryResponse"]}}};l.style=":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}.ConsentSubmitButton:disabled{border:2px solid #ccc;color:#ccc}@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}}";export{r as player_user_consents,l as user_action_controller}
@@ -1 +1 @@
1
- import{p as t,b as n}from"./p-ba444709.js";(()=>{const n=import.meta.url,e={};return""!==n&&(e.resourcesUrl=new URL(".",n).href),t(e)})().then((t=>n([["p-1b7bd94a",[[1,"user-action-controller",{endpoint:[513],userSession:[513,"user-session"],userId:[513,"user-id"],lang:[1537],includeSubmitButton:[516,"include-submit-button"],submitButtonText:[513,"submit-button-text"],userNoticeText:[513,"user-notice-text"],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]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[1,"player-user-consents",{lang:[1537],queried:[516],consentType:[513,"consent-type"],mandatory:[516],consentTitle:[513,"consent-title"],clientStyling:[1,"client-styling"],translationUrl:[513,"translation-url"],textContent:[32],limitStylingAppends:[32]}]]]],t)));
1
+ import{p as t,b as n}from"./p-ba444709.js";(()=>{const n=import.meta.url,e={};return""!==n&&(e.resourcesUrl=new URL(".",n).href),t(e)})().then((t=>n([["p-02211033",[[1,"user-action-controller",{endpoint:[513],userSession:[513,"user-session"],userId:[513,"user-id"],lang:[1537],includeSubmitButton:[516,"include-submit-button"],submitButtonText:[513,"submit-button-text"],userNoticeText:[513,"user-notice-text"],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]},[[0,"userLegislationConsent","userLegislationConsentHandler"]]],[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]}]]]],t)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/user-action-controller",
3
- "version": "1.34.0",
3
+ "version": "1.35.0",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",
@@ -1 +0,0 @@
1
- import{r as t,c as e,h as i}from"./p-ba444709.js";const s={en:{termsandconditions1:"I accept the ",termsandconditions2:", I have read and understood the ",termsandconditions3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions",privacy:"Privacy Policy",sms:"I consent to receive marketing communication via SMS.",emailmarketing:"I consent to receive marketing communication via Email."},ro:{termsandconditions1:"Accept ",termsandconditions2:" platformei. Am citit şi înţeles ",termsandconditions3:" publicată pe acest site şi confirm că am vârstă peste 18 ani.",tc:"Termenii şi condiţiile",privacy:"Politica de confidenţialitate",sms:"Sunt de acord să primesc promoţii de marketing prin SMS.",emailmarketing:"Sunt de acord să primesc promoţii de marketing pe e-mail."},hr:{termsandconditions1:"I accept the ",termsandconditions2:", I have read and understood the ",termsandconditions3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions",privacy:"Privacy Policy",sms:"I consent to receive marketing communication via SMS.",emailmarketing:"I consent to receive marketing communication via Email."},fr:{termsandconditions1:"I accept the ",termsandconditions2:", I have read and understood the ",termsandconditions3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions",privacy:"Privacy Policy",sms:"I consent to receive marketing communication via SMS.",emailmarketing:"I consent to receive marketing communication via Email."},cs:{termsandconditions1:"I accept the ",termsandconditions2:", I have read and understood the ",termsandconditions3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions",privacy:"Privacy Policy",sms:"I consent to receive marketing communication via SMS.",emailmarketing:"I consent to receive marketing communication via Email."},de:{termsandconditions1:"I accept the ",termsandconditions2:", I have read and understood the ",termsandconditions3:" as published on this site and confirm that I am over 18 years old.",tc:"Terms and Conditions",privacy:"Privacy Policy",sms:"I consent to receive marketing communication via SMS.",emailmarketing:"I consent to receive marketing communication via Email."}},n=t=>new Promise((e=>{fetch(t).then((t=>t.json())).then((t=>{Object.keys(t).forEach((e=>{for(let i in t[e])s[e][i]=t[e][i]})),e(!0)}))})),o=(t,e,i)=>{let n=s[void 0!==e?e:"en"][t];if(void 0!==i)for(const[t,e]of Object.entries(i.values)){const i=new RegExp(`{${t}}`,"g");n=n.replace(i,e)}return n},a=class{constructor(i){t(this,i),this.userLegislationConsent=e(this,"userLegislationConsent",7),this.lang="en",this.queried=!1,this.consentType="",this.mandatory=!1,this.consentTitle="",this.clientStyling="",this.translationUrl="",this.textContent="",this.limitStylingAppends=!1,this.goToTermsAndConditions=()=>window.postMessage({type:"GoToTermsAndConditions"}),this.goToPrivacyPolicy=()=>window.postMessage({type:"GoToPrivacyPolicy"}),this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}handleNewTranslations(){n(this.translationUrl)}async componentWillLoad(){this.translationUrl.length>2&&await n(this.translationUrl)}userLegislationConsentHandler(){this.userLegislationConsent.emit({type:this.consentType,value:this.checkboxInput.checked})}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}determineTextContent(){return"termsandconditions"===this.consentType?i("p",null,o("termsandconditions1",this.lang),i("span",{class:"ConsentLink",onClick:this.goToTermsAndConditions},o("tc",this.lang)),o("termsandconditions2",this.lang),i("span",{class:"ConsentLink",onClick:this.goToPrivacyPolicy},o("privacy",this.lang)),o("termsandconditions3",this.lang)):i("p",null,o(this.consentType,this.lang))}render(){return this.queried&&this.userLegislationConsentHandler(),i("div",{ref:t=>this.stylingContainer=t},i("p",{class:"ConsentTitle"},this.consentTitle),i("label",{class:"UserConsent",htmlFor:"userConsent"},i("input",{ref:t=>this.checkboxInput=t,id:"userConsent",type:"checkbox",onInput:()=>this.userLegislationConsentHandler()}),this.determineTextContent(),this.mandatory&&i("span",{class:"MandatoryItem"},"*")))}static get watchers(){return{translationUrl:["handleNewTranslations"]}}};a.style=":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}";const r=["ro","en","cz","de","hr"],c={en:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing"},ro:{termsandconditions:"Termeni şi condiţii",sms:"SMS marketing",emailmarketing:"Email marketing"},hr:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing"},fr:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing"},cs:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing"},de:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing"}},d=t=>new Promise((e=>{fetch(t).then((t=>t.json())).then((t=>{Object.keys(t).forEach((e=>{for(let i in t[e])c[e][i]=t[e][i]})),e(!0)}))})),m=(t,e,i)=>{const s=e;let n=c[void 0!==s&&r.includes(s)?s:"en"][t];if(void 0!==i)for(const[t,e]of Object.entries(i.values)){const i=new RegExp(`{${t}}`,"g");n=n.replace(i,e)}return n},h=class{constructor(e){t(this,e),this.lang="en",this.gmVersion="",this.translationUrl="",this.clientStyling="",this.clientStylingUrl="",this.queryFired=!1,this.readyActionsCount=0,this.activeUserActions=[],this.userActionsValidated=!0,this.receivedQueryResponses=0,this.limitStylingAppends=!1,this.isLoading=!0,this.mandatoryActionsChecked=0,this.mandatoryActions=["termsandconditions"],this.userActions=[],this.consentTitles={termsandconditions:m("termsandconditions",this.lang),sms:m("sms",this.lang),emailmarketing:m("emailmarketing",this.lang)},this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),e=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{this.clientStyling=t,e.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(e)}),1)})).catch((t=>{console.log("error ",t)}))}}handleNewTranslations(){d(this.translationUrl)}handleQueryResponse(){this.receivedQueryResponses===this.activeUserActions.length&&this.updateUserConsents()}userLegislationConsentHandler(t){const e=t.detail.type,i=t.detail.value;this.mandatoryActions.includes(e)&&!1===this.queryFired&&(!0===i?this.mandatoryActionsChecked++:this.mandatoryActionsChecked--),this.queryFired&&(this.userActions.push({tagCode:e,status:i?"Accepted":"Denied"}),this.receivedQueryResponses++)}determineUserActions(){const t=new URL(`${this.endpoint}/v1/player/${this.userId}/consent`),e=new Headers;let i;return e.append("X-SessionId",this.userSession),i={method:"GET",headers:e},t&&i?fetch(t.href,i).then((t=>t.json())).then((t=>{t.items.forEach((t=>{"Expired"===t.status&&this.activeUserActions.push(t.tagCode)})),this.isLoading=!1})).catch((t=>{console.error("Error fetching data:",t),this.isLoading=!1})):Promise.reject("Unsupported endpoint")}updateUserConsents(){let t,e;t="gmcore"===this.gmVersion?new URL(`${this.endpoint}/v1/player/${this.userId}/consent`):new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`),e={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-SessionId":`${this.userSession}`},body:JSON.stringify("gmcore"===this.gmVersion?{items:this.userActions}:{consents:[{tagCode:"termsandconditions",note:"",status:1}]})},t&&e&&fetch(t.href,e).then((t=>t.json())).then((()=>{window.postMessage({type:"WidgetNotification",data:{type:"success",message:"Consent update successful!"}},window.location.href)})).catch((t=>{window.postMessage({type:"WidgetNotification",data:{type:"error",message:"Server might not be responding",err:t}},window.location.href)})).finally((()=>{window.postMessage({type:"UserActionsCompleted"},window.location.href)}))}handleApplyClick(){this.queryFired=!0}async componentWillLoad(){if("gmcore"===this.gmVersion)return this.determineUserActions();this.activeUserActions=["termsandconditions"],this.isLoading=!1,this.translationUrl.length>2&&await d(this.translationUrl)}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.limitStylingAppends=!0)}render(){const t=this.mandatoryActions.every((t=>this.activeUserActions.includes(t)));return this.userActionsValidated=!(!t||this.mandatoryActionsChecked===this.mandatoryActions.length),i("div",{class:"QueryReferenceContainer",ref:t=>this.stylingContainer=t},this.isLoading?i("slot",{name:"spinner"})&&i("svg",{class:"spinner",viewBox:"0 0 50 50"},i("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"5"})):i("div",{class:"UserActionController"},i("h2",{class:"UserConsentNotice"},this.userNoticeText),i("div",{class:"PlayerLegislationWrapper"},this.activeUserActions.map((t=>i("slot",{name:t},i("player-user-consents",{lang:this.lang,"translation-url":this.translationUrl,slot:t,consentType:t,consentTitle:this.consentTitles[t],queried:this.queryFired,mandatory:this.mandatoryActions.includes(t),"client-styling":this.clientStyling}))))),this.includeSubmitButton&&i("button",{class:"ConsentSubmitButton",disabled:this.userActionsValidated,onClick:()=>this.handleApplyClick()},this.submitButtonText)))}static get watchers(){return{translationUrl:["handleNewTranslations"],receivedQueryResponses:["handleQueryResponse"]}}};h.style=":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}.ConsentSubmitButton:disabled{border:2px solid #ccc;color:#ccc}@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}}";export{a as player_user_consents,h as user_action_controller}