@everymatrix/user-action-controller 1.31.2 → 1.33.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.
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- 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"],"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",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
17
+ 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"],"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);
18
18
  });
19
19
  };
20
20
 
@@ -4,12 +4,100 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-87049e21.js');
6
6
 
7
- const playerUserConsentsCss = ":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.userConsent:hover{border-bottom:1px solid #000;cursor:pointer}.MandatoryItem{color:#f00;font-size:1.2rem}";
7
+ const DEFAULT_LANGUAGE$1 = 'en';
8
+ const TRANSLATIONS$1 = {
9
+ en: {
10
+ termsandconditions1: "I accept the ",
11
+ termsandconditions2: ", I have read and understood the ",
12
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
13
+ tc: "Terms and Conditions",
14
+ privacy: "Privacy Policy",
15
+ sms: "I consent to receive marketing communication via SMS.",
16
+ emailmarketing: "I consent to receive marketing communication via Email."
17
+ },
18
+ ro: {
19
+ termsandconditions1: "I accept the ",
20
+ termsandconditions2: ", I have read and understood the ",
21
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
22
+ tc: "Terms and Conditions",
23
+ privacy: "Privacy Policy",
24
+ sms: "I consent to receive marketing communication via SMS.",
25
+ emailmarketing: "I consent to receive marketing communication via Email."
26
+ },
27
+ hr: {
28
+ termsandconditions1: "I accept the ",
29
+ termsandconditions2: ", I have read and understood the ",
30
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
31
+ tc: "Terms and Conditions",
32
+ privacy: "Privacy Policy",
33
+ sms: "I consent to receive marketing communication via SMS.",
34
+ emailmarketing: "I consent to receive marketing communication via Email."
35
+ },
36
+ fr: {
37
+ termsandconditions1: "I accept the ",
38
+ termsandconditions2: ", I have read and understood the ",
39
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
40
+ tc: "Terms and Conditions",
41
+ privacy: "Privacy Policy",
42
+ sms: "I consent to receive marketing communication via SMS.",
43
+ emailmarketing: "I consent to receive marketing communication via Email."
44
+ },
45
+ cs: {
46
+ termsandconditions1: "I accept the ",
47
+ termsandconditions2: ", I have read and understood the ",
48
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
49
+ tc: "Terms and Conditions",
50
+ privacy: "Privacy Policy",
51
+ sms: "I consent to receive marketing communication via SMS.",
52
+ emailmarketing: "I consent to receive marketing communication via Email."
53
+ },
54
+ de: {
55
+ termsandconditions1: "I accept the ",
56
+ termsandconditions2: ", I have read and understood the ",
57
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
58
+ tc: "Terms and Conditions",
59
+ privacy: "Privacy Policy",
60
+ sms: "I consent to receive marketing communication via SMS.",
61
+ emailmarketing: "I consent to receive marketing communication via Email."
62
+ },
63
+ };
64
+ const getTranslations$1 = (url) => {
65
+ // fetch url, get the data, replace the TRANSLATIONS content
66
+ return new Promise((resolve) => {
67
+ fetch(url)
68
+ .then((res) => res.json())
69
+ .then((data) => {
70
+ Object.keys(data).forEach((item) => {
71
+ for (let key in data[item]) {
72
+ TRANSLATIONS$1[item][key] = data[item][key];
73
+ }
74
+ });
75
+ resolve(true);
76
+ });
77
+ });
78
+ };
79
+ const translate$1 = (key, customLang, values) => {
80
+ const lang = customLang;
81
+ let translation = TRANSLATIONS$1[lang !== undefined ? lang : DEFAULT_LANGUAGE$1][key];
82
+ if (values !== undefined) {
83
+ for (const [key, value] of Object.entries(values.values)) {
84
+ const regex = new RegExp(`{${key}}`, 'g');
85
+ translation = translation.replace(regex, value);
86
+ }
87
+ }
88
+ return translation;
89
+ };
90
+
91
+ 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}";
8
92
 
9
93
  const PlayerUserConsents = class {
10
94
  constructor(hostRef) {
11
95
  index.registerInstance(this, hostRef);
12
96
  this.userLegislationConsent = index.createEvent(this, "userLegislationConsent", 7);
97
+ /**
98
+ * Language
99
+ */
100
+ this.lang = 'en';
13
101
  /**
14
102
  * 'true' when parent expects component to emit it's current value
15
103
  */
@@ -26,44 +114,34 @@ const PlayerUserConsents = class {
26
114
  * the title of the consent to be displayed
27
115
  */
28
116
  this.consentTitle = '';
29
- /**
30
- * link to the t&c page
31
- */
32
- this.tcLink = '#';
33
- /**
34
- * link to privacy policy page
35
- */
36
- this.privacyLink = '#';
37
117
  /**
38
118
  * Client custom styling via inline style
39
119
  */
40
120
  this.clientStyling = '';
121
+ /**
122
+ * Translation url
123
+ */
124
+ this.translationUrl = '';
41
125
  /**
42
126
  * the text content to be rendered by the component. Determined at runtime
43
127
  */
44
128
  this.textContent = '';
45
129
  this.limitStylingAppends = false;
46
- // Maybe switch this out with a localization source
47
- this.stringVariants = {
48
- termsandconditions1: "I accept the ",
49
- termsandconditions2: ", I have read and understood the ",
50
- termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
51
- tc: "Terms and Conditions",
52
- privacy: "Privacy Policy",
53
- sms: "I consent to receive marketing communication via SMS.",
54
- emailmarketing: "I consent to receive marketing communication via Email."
55
- };
130
+ this.goToTermsAndConditions = () => window.postMessage({ type: 'GoToTermsAndConditions' });
131
+ this.goToPrivacyPolicy = () => window.postMessage({ type: 'GoToPrivacyPolicy' });
56
132
  this.setClientStyling = () => {
57
133
  let sheet = document.createElement('style');
58
134
  sheet.innerHTML = this.clientStyling;
59
135
  this.stylingContainer.prepend(sheet);
60
136
  };
61
137
  }
62
- determineTextContent() {
63
- let result = this.consentType === 'termsandconditions' ?
64
- index.h("span", null, this.stringVariants['termsandconditions1'], index.h("a", { href: this.tcLink }, this.stringVariants['tc']), this.stringVariants['termsandconditions2'], index.h("a", { href: this.privacyLink }, this.stringVariants['privacy']), this.stringVariants['termsandconditions3'])
65
- : index.h("span", null, this.stringVariants[this.consentType]);
66
- return result;
138
+ handleNewTranslations() {
139
+ getTranslations$1(this.translationUrl);
140
+ }
141
+ async componentWillLoad() {
142
+ if (this.translationUrl.length > 2) {
143
+ await getTranslations$1(this.translationUrl);
144
+ }
67
145
  }
68
146
  userLegislationConsentHandler() {
69
147
  this.userLegislationConsent.emit({
@@ -80,13 +158,20 @@ const PlayerUserConsents = class {
80
158
  }
81
159
  // end custom styling area
82
160
  }
161
+ determineTextContent() {
162
+ return this.consentType === 'termsandconditions' ?
163
+ index.h("p", null, translate$1('termsandconditions1', this.lang), index.h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate$1('tc', this.lang)), translate$1('termsandconditions2', this.lang), index.h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate$1('privacy', this.lang)), translate$1('termsandconditions3', this.lang))
164
+ : index.h("p", null, translate$1('consentType', this.lang));
165
+ }
83
166
  render() {
84
167
  if (this.queried) {
85
168
  this.userLegislationConsentHandler();
86
169
  }
87
- this.textContent = this.determineTextContent();
88
- return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("p", { class: "ConsentTitle" }, this.consentTitle), index.h("label", { class: "userConsent", htmlFor: "userConsent" }, index.h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.textContent, this.mandatory && index.h("span", { class: "MandatoryItem" }, "*"))));
170
+ return (index.h("div", { ref: el => this.stylingContainer = el }, index.h("p", { class: "ConsentTitle" }, this.consentTitle), index.h("label", { class: "UserConsent", htmlFor: "userConsent" }, index.h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.determineTextContent(), this.mandatory && index.h("span", { class: "MandatoryItem" }, "*"))));
89
171
  }
172
+ static get watchers() { return {
173
+ "translationUrl": ["handleNewTranslations"]
174
+ }; }
90
175
  };
91
176
  PlayerUserConsents.style = playerUserConsentsCss;
92
177
 
@@ -356,7 +441,7 @@ const UserActionController = class {
356
441
  }
357
442
  return (index.h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (index.h("slot", { name: 'spinner' })
358
443
  &&
359
- 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" }, this.userNoticeText), index.h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (index.h("slot", { name: action }, index.h("player-user-consents", { slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
444
+ 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" }, this.userNoticeText), index.h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (index.h("slot", { name: action }, index.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 &&
360
445
  index.h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
361
446
  }
362
447
  static get watchers() { return {
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- 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"],"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",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
18
+ 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"],"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);
19
19
  });
@@ -207,7 +207,7 @@ export class UserActionController {
207
207
  h("circle", { class: "path", cx: "25", cy: "25", r: "20", fill: "none", "stroke-width": "5" }))) : (h("div", { class: "UserActionController" },
208
208
  h("h2", { class: "UserConsentNotice" }, this.userNoticeText),
209
209
  h("div", { class: "PlayerLegislationWrapper" }, this.activeUserActions.map(action => (h("slot", { name: action },
210
- h("player-user-consents", { slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))),
210
+ 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 }))))),
211
211
  this.includeSubmitButton &&
212
212
  h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
213
213
  }
@@ -1,6 +1,90 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
 
3
- const playerUserConsentsCss = ":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.userConsent:hover{border-bottom:1px solid #000;cursor:pointer}.MandatoryItem{color:#f00;font-size:1.2rem}";
3
+ const DEFAULT_LANGUAGE = 'en';
4
+ const TRANSLATIONS = {
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",
11
+ sms: "I consent to receive marketing communication via SMS.",
12
+ emailmarketing: "I consent to receive marketing communication via Email."
13
+ },
14
+ ro: {
15
+ termsandconditions1: "I accept the ",
16
+ termsandconditions2: ", I have read and understood the ",
17
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
18
+ tc: "Terms and Conditions",
19
+ privacy: "Privacy Policy",
20
+ sms: "I consent to receive marketing communication via SMS.",
21
+ emailmarketing: "I consent to receive marketing communication via Email."
22
+ },
23
+ 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",
29
+ sms: "I consent to receive marketing communication via SMS.",
30
+ emailmarketing: "I consent to receive marketing communication via Email."
31
+ },
32
+ 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",
38
+ sms: "I consent to receive marketing communication via SMS.",
39
+ emailmarketing: "I consent to receive marketing communication via Email."
40
+ },
41
+ 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",
47
+ sms: "I consent to receive marketing communication via SMS.",
48
+ emailmarketing: "I consent to receive marketing communication via Email."
49
+ },
50
+ 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",
56
+ sms: "I consent to receive marketing communication via SMS.",
57
+ emailmarketing: "I consent to receive marketing communication via Email."
58
+ },
59
+ };
60
+ const getTranslations = (url) => {
61
+ // fetch url, get the data, replace the TRANSLATIONS content
62
+ return new Promise((resolve) => {
63
+ fetch(url)
64
+ .then((res) => res.json())
65
+ .then((data) => {
66
+ Object.keys(data).forEach((item) => {
67
+ for (let key in data[item]) {
68
+ TRANSLATIONS[item][key] = data[item][key];
69
+ }
70
+ });
71
+ resolve(true);
72
+ });
73
+ });
74
+ };
75
+ const translate = (key, customLang, values) => {
76
+ const lang = customLang;
77
+ let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
78
+ 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);
82
+ }
83
+ }
84
+ return translation;
85
+ };
86
+
87
+ 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}";
4
88
 
5
89
  const PlayerUserConsents = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
6
90
  constructor() {
@@ -8,6 +92,10 @@ const PlayerUserConsents = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
8
92
  this.__registerHost();
9
93
  this.__attachShadow();
10
94
  this.userLegislationConsent = createEvent(this, "userLegislationConsent", 7);
95
+ /**
96
+ * Language
97
+ */
98
+ this.lang = 'en';
11
99
  /**
12
100
  * 'true' when parent expects component to emit it's current value
13
101
  */
@@ -24,44 +112,34 @@ const PlayerUserConsents = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
24
112
  * the title of the consent to be displayed
25
113
  */
26
114
  this.consentTitle = '';
27
- /**
28
- * link to the t&c page
29
- */
30
- this.tcLink = '#';
31
- /**
32
- * link to privacy policy page
33
- */
34
- this.privacyLink = '#';
35
115
  /**
36
116
  * Client custom styling via inline style
37
117
  */
38
118
  this.clientStyling = '';
119
+ /**
120
+ * Translation url
121
+ */
122
+ this.translationUrl = '';
39
123
  /**
40
124
  * the text content to be rendered by the component. Determined at runtime
41
125
  */
42
126
  this.textContent = '';
43
127
  this.limitStylingAppends = false;
44
- // Maybe switch this out with a localization source
45
- this.stringVariants = {
46
- termsandconditions1: "I accept the ",
47
- termsandconditions2: ", I have read and understood the ",
48
- termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
49
- tc: "Terms and Conditions",
50
- privacy: "Privacy Policy",
51
- sms: "I consent to receive marketing communication via SMS.",
52
- emailmarketing: "I consent to receive marketing communication via Email."
53
- };
128
+ this.goToTermsAndConditions = () => window.postMessage({ type: 'GoToTermsAndConditions' });
129
+ this.goToPrivacyPolicy = () => window.postMessage({ type: 'GoToPrivacyPolicy' });
54
130
  this.setClientStyling = () => {
55
131
  let sheet = document.createElement('style');
56
132
  sheet.innerHTML = this.clientStyling;
57
133
  this.stylingContainer.prepend(sheet);
58
134
  };
59
135
  }
60
- determineTextContent() {
61
- let result = this.consentType === 'termsandconditions' ?
62
- h("span", null, this.stringVariants['termsandconditions1'], h("a", { href: this.tcLink }, this.stringVariants['tc']), this.stringVariants['termsandconditions2'], h("a", { href: this.privacyLink }, this.stringVariants['privacy']), this.stringVariants['termsandconditions3'])
63
- : h("span", null, this.stringVariants[this.consentType]);
64
- return result;
136
+ handleNewTranslations() {
137
+ getTranslations(this.translationUrl);
138
+ }
139
+ async componentWillLoad() {
140
+ if (this.translationUrl.length > 2) {
141
+ await getTranslations(this.translationUrl);
142
+ }
65
143
  }
66
144
  userLegislationConsentHandler() {
67
145
  this.userLegislationConsent.emit({
@@ -78,22 +156,29 @@ const PlayerUserConsents = /*@__PURE__*/ proxyCustomElement(class extends HTMLEl
78
156
  }
79
157
  // end custom styling area
80
158
  }
159
+ determineTextContent() {
160
+ return this.consentType === 'termsandconditions' ?
161
+ h("p", null, translate('termsandconditions1', this.lang), h("span", { class: "ConsentLink", onClick: this.goToTermsAndConditions }, translate('tc', this.lang)), translate('termsandconditions2', this.lang), h("span", { class: "ConsentLink", onClick: this.goToPrivacyPolicy }, translate('privacy', this.lang)), translate('termsandconditions3', this.lang))
162
+ : h("p", null, translate('consentType', this.lang));
163
+ }
81
164
  render() {
82
165
  if (this.queried) {
83
166
  this.userLegislationConsentHandler();
84
167
  }
85
- this.textContent = this.determineTextContent();
86
- return (h("div", { ref: el => this.stylingContainer = el }, h("p", { class: "ConsentTitle" }, this.consentTitle), h("label", { class: "userConsent", htmlFor: "userConsent" }, h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.textContent, this.mandatory && h("span", { class: "MandatoryItem" }, "*"))));
168
+ return (h("div", { ref: el => this.stylingContainer = el }, h("p", { class: "ConsentTitle" }, this.consentTitle), h("label", { class: "UserConsent", htmlFor: "userConsent" }, h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.determineTextContent(), this.mandatory && h("span", { class: "MandatoryItem" }, "*"))));
87
169
  }
170
+ static get watchers() { return {
171
+ "translationUrl": ["handleNewTranslations"]
172
+ }; }
88
173
  static get style() { return playerUserConsentsCss; }
89
174
  }, [1, "player-user-consents", {
175
+ "lang": [1537],
90
176
  "queried": [516],
91
177
  "consentType": [513, "consent-type"],
92
178
  "mandatory": [516],
93
179
  "consentTitle": [513, "consent-title"],
94
- "tcLink": [513, "tc-link"],
95
- "privacyLink": [513, "privacy-link"],
96
180
  "clientStyling": [1, "client-styling"],
181
+ "translationUrl": [513, "translation-url"],
97
182
  "textContent": [32],
98
183
  "limitStylingAppends": [32]
99
184
  }]);
@@ -269,7 +269,7 @@ const UserActionController$1 = /*@__PURE__*/ proxyCustomElement(class extends HT
269
269
  }
270
270
  return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (h("slot", { name: 'spinner' })
271
271
  &&
272
- 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", { slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
272
+ 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 &&
273
273
  h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
274
274
  }
275
275
  static get watchers() { return {
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- 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",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
13
+ 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);
14
14
  });
15
15
  };
16
16
 
@@ -1,11 +1,99 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-71f14530.js';
2
2
 
3
- const playerUserConsentsCss = ":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.userConsent:hover{border-bottom:1px solid #000;cursor:pointer}.MandatoryItem{color:#f00;font-size:1.2rem}";
3
+ const DEFAULT_LANGUAGE$1 = 'en';
4
+ const TRANSLATIONS$1 = {
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",
11
+ sms: "I consent to receive marketing communication via SMS.",
12
+ emailmarketing: "I consent to receive marketing communication via Email."
13
+ },
14
+ ro: {
15
+ termsandconditions1: "I accept the ",
16
+ termsandconditions2: ", I have read and understood the ",
17
+ termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
18
+ tc: "Terms and Conditions",
19
+ privacy: "Privacy Policy",
20
+ sms: "I consent to receive marketing communication via SMS.",
21
+ emailmarketing: "I consent to receive marketing communication via Email."
22
+ },
23
+ 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",
29
+ sms: "I consent to receive marketing communication via SMS.",
30
+ emailmarketing: "I consent to receive marketing communication via Email."
31
+ },
32
+ 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",
38
+ sms: "I consent to receive marketing communication via SMS.",
39
+ emailmarketing: "I consent to receive marketing communication via Email."
40
+ },
41
+ 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",
47
+ sms: "I consent to receive marketing communication via SMS.",
48
+ emailmarketing: "I consent to receive marketing communication via Email."
49
+ },
50
+ 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",
56
+ sms: "I consent to receive marketing communication via SMS.",
57
+ emailmarketing: "I consent to receive marketing communication via Email."
58
+ },
59
+ };
60
+ const getTranslations$1 = (url) => {
61
+ // fetch url, get the data, replace the TRANSLATIONS content
62
+ return new Promise((resolve) => {
63
+ fetch(url)
64
+ .then((res) => res.json())
65
+ .then((data) => {
66
+ Object.keys(data).forEach((item) => {
67
+ for (let key in data[item]) {
68
+ TRANSLATIONS$1[item][key] = data[item][key];
69
+ }
70
+ });
71
+ resolve(true);
72
+ });
73
+ });
74
+ };
75
+ const translate$1 = (key, customLang, values) => {
76
+ const lang = customLang;
77
+ let translation = TRANSLATIONS$1[lang !== undefined ? lang : DEFAULT_LANGUAGE$1][key];
78
+ 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);
82
+ }
83
+ }
84
+ return translation;
85
+ };
86
+
87
+ 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}";
4
88
 
5
89
  const PlayerUserConsents = class {
6
90
  constructor(hostRef) {
7
91
  registerInstance(this, hostRef);
8
92
  this.userLegislationConsent = createEvent(this, "userLegislationConsent", 7);
93
+ /**
94
+ * Language
95
+ */
96
+ this.lang = 'en';
9
97
  /**
10
98
  * 'true' when parent expects component to emit it's current value
11
99
  */
@@ -22,44 +110,34 @@ const PlayerUserConsents = class {
22
110
  * the title of the consent to be displayed
23
111
  */
24
112
  this.consentTitle = '';
25
- /**
26
- * link to the t&c page
27
- */
28
- this.tcLink = '#';
29
- /**
30
- * link to privacy policy page
31
- */
32
- this.privacyLink = '#';
33
113
  /**
34
114
  * Client custom styling via inline style
35
115
  */
36
116
  this.clientStyling = '';
117
+ /**
118
+ * Translation url
119
+ */
120
+ this.translationUrl = '';
37
121
  /**
38
122
  * the text content to be rendered by the component. Determined at runtime
39
123
  */
40
124
  this.textContent = '';
41
125
  this.limitStylingAppends = false;
42
- // Maybe switch this out with a localization source
43
- this.stringVariants = {
44
- termsandconditions1: "I accept the ",
45
- termsandconditions2: ", I have read and understood the ",
46
- termsandconditions3: " as published on this site and confirm that I am over 18 years old.",
47
- tc: "Terms and Conditions",
48
- privacy: "Privacy Policy",
49
- sms: "I consent to receive marketing communication via SMS.",
50
- emailmarketing: "I consent to receive marketing communication via Email."
51
- };
126
+ this.goToTermsAndConditions = () => window.postMessage({ type: 'GoToTermsAndConditions' });
127
+ this.goToPrivacyPolicy = () => window.postMessage({ type: 'GoToPrivacyPolicy' });
52
128
  this.setClientStyling = () => {
53
129
  let sheet = document.createElement('style');
54
130
  sheet.innerHTML = this.clientStyling;
55
131
  this.stylingContainer.prepend(sheet);
56
132
  };
57
133
  }
58
- determineTextContent() {
59
- let result = this.consentType === 'termsandconditions' ?
60
- h("span", null, this.stringVariants['termsandconditions1'], h("a", { href: this.tcLink }, this.stringVariants['tc']), this.stringVariants['termsandconditions2'], h("a", { href: this.privacyLink }, this.stringVariants['privacy']), this.stringVariants['termsandconditions3'])
61
- : h("span", null, this.stringVariants[this.consentType]);
62
- return result;
134
+ handleNewTranslations() {
135
+ getTranslations$1(this.translationUrl);
136
+ }
137
+ async componentWillLoad() {
138
+ if (this.translationUrl.length > 2) {
139
+ await getTranslations$1(this.translationUrl);
140
+ }
63
141
  }
64
142
  userLegislationConsentHandler() {
65
143
  this.userLegislationConsent.emit({
@@ -76,13 +154,20 @@ const PlayerUserConsents = class {
76
154
  }
77
155
  // end custom styling area
78
156
  }
157
+ 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('consentType', this.lang));
161
+ }
79
162
  render() {
80
163
  if (this.queried) {
81
164
  this.userLegislationConsentHandler();
82
165
  }
83
- this.textContent = this.determineTextContent();
84
- return (h("div", { ref: el => this.stylingContainer = el }, h("p", { class: "ConsentTitle" }, this.consentTitle), h("label", { class: "userConsent", htmlFor: "userConsent" }, h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.textContent, this.mandatory && h("span", { class: "MandatoryItem" }, "*"))));
166
+ return (h("div", { ref: el => this.stylingContainer = el }, h("p", { class: "ConsentTitle" }, this.consentTitle), h("label", { class: "UserConsent", htmlFor: "userConsent" }, h("input", { ref: el => this.checkboxInput = el, id: "userConsent", type: "checkbox", onInput: () => this.userLegislationConsentHandler() }), this.determineTextContent(), this.mandatory && h("span", { class: "MandatoryItem" }, "*"))));
85
167
  }
168
+ static get watchers() { return {
169
+ "translationUrl": ["handleNewTranslations"]
170
+ }; }
86
171
  };
87
172
  PlayerUserConsents.style = playerUserConsentsCss;
88
173
 
@@ -352,7 +437,7 @@ const UserActionController = class {
352
437
  }
353
438
  return (h("div", { class: "QueryReferenceContainer", ref: el => this.stylingContainer = el }, this.isLoading ? (h("slot", { name: 'spinner' })
354
439
  &&
355
- 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", { slot: action, consentType: action, consentTitle: this.consentTitles[action], queried: this.queryFired, mandatory: this.mandatoryActions.includes(action), "client-styling": this.clientStyling }))))), this.includeSubmitButton &&
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 &&
356
441
  h("button", { class: "ConsentSubmitButton", disabled: this.userActionsValidated, onClick: () => this.handleApplyClick() }, this.submitButtonText)))));
357
442
  }
358
443
  static get watchers() { return {
@@ -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",{"queried":[516],"consentType":[513,"consent-type"],"mandatory":[516],"consentTitle":[513,"consent-title"],"tcLink":[513,"tc-link"],"privacyLink":[513,"privacy-link"],"clientStyling":[1,"client-styling"],"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],"consentTitle":[513,"consent-title"],"clientStyling":[1,"client-styling"],"translationUrl":[513,"translation-url"],"textContent":[32],"limitStylingAppends":[32]}]]]], options);
17
17
  });
@@ -0,0 +1,2 @@
1
+ import { Config } from '../../../../../../../../../../stencil-public-runtime';
2
+ export declare const config: Config;
@@ -0,0 +1 @@
1
+ import{r as t,c as e,h as i}from"./p-ba444709.js";const n={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:"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."},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."}},s=t=>new Promise((e=>{fetch(t).then((t=>t.json())).then((t=>{Object.keys(t).forEach((e=>{for(let i in t[e])n[e][i]=t[e][i]})),e(!0)}))})),o=(t,e,i)=>{let s=n[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");s=s.replace(i,e)}return s},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(){s(this.translationUrl)}async componentWillLoad(){this.translationUrl.length>2&&await s(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("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:"Terms and Conditions",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)}))})),h=(t,e,i)=>{const n=e;let s=c[void 0!==n&&r.includes(n)?n:"en"][t];if(void 0!==i)for(const[t,e]of Object.entries(i.values)){const i=new RegExp(`{${t}}`,"g");s=s.replace(i,e)}return s},m=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:h("termsandconditions",this.lang),sms:h("sms",this.lang),emailmarketing:h("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"]}}};m.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,m 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-711fa494",[[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",{queried:[516],consentType:[513,"consent-type"],mandatory:[516],consentTitle:[513,"consent-title"],tcLink:[513,"tc-link"],privacyLink:[513,"privacy-link"],clientStyling:[1,"client-styling"],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-d1fdbddb",[[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)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/user-action-controller",
3
- "version": "1.31.2",
3
+ "version": "1.33.0",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",
@@ -1,2 +0,0 @@
1
- import { Config } from '../../../../../../../../../../../stencil-public-runtime';
2
- export declare const config: Config;
@@ -1 +0,0 @@
1
- import{r as t,c as s,h as e}from"./p-ba444709.js";const i=class{constructor(e){t(this,e),this.userLegislationConsent=s(this,"userLegislationConsent",7),this.queried=!1,this.consentType="",this.mandatory=!1,this.consentTitle="",this.tcLink="#",this.privacyLink="#",this.clientStyling="",this.textContent="",this.limitStylingAppends=!1,this.stringVariants={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."},this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.stylingContainer.prepend(t)}}determineTextContent(){return"termsandconditions"===this.consentType?e("span",null,this.stringVariants.termsandconditions1,e("a",{href:this.tcLink},this.stringVariants.tc),this.stringVariants.termsandconditions2,e("a",{href:this.privacyLink},this.stringVariants.privacy),this.stringVariants.termsandconditions3):e("span",null,this.stringVariants[this.consentType])}userLegislationConsentHandler(){this.userLegislationConsent.emit({type:this.consentType,value:this.checkboxInput.checked})}componentDidRender(){!this.limitStylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.limitStylingAppends=!0)}render(){return this.queried&&this.userLegislationConsentHandler(),this.textContent=this.determineTextContent(),e("div",{ref:t=>this.stylingContainer=t},e("p",{class:"ConsentTitle"},this.consentTitle),e("label",{class:"userConsent",htmlFor:"userConsent"},e("input",{ref:t=>this.checkboxInput=t,id:"userConsent",type:"checkbox",onInput:()=>this.userLegislationConsentHandler()}),this.textContent,this.mandatory&&e("span",{class:"MandatoryItem"},"*")))}};i.style=":host{display:block}.ConsentTitle{margin-bottom:0.2rem;font-weight:600}.userConsent:hover{border-bottom:1px solid #000;cursor:pointer}.MandatoryItem{color:#f00;font-size:1.2rem}";const n=["ro","en","cz","de","hr"],o={en:{termsandconditions:"Terms and Conditions",sms:"SMS marketing",emailmarketing:"Email marketing"},ro:{termsandconditions:"Terms and Conditions",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"}},r=t=>new Promise((s=>{fetch(t).then((t=>t.json())).then((t=>{Object.keys(t).forEach((s=>{for(let e in t[s])o[s][e]=t[s][e]})),s(!0)}))})),a=(t,s,e)=>{const i=s;let r=o[void 0!==i&&n.includes(i)?i:"en"][t];if(void 0!==e)for(const[t,s]of Object.entries(e.values)){const e=new RegExp(`{${t}}`,"g");r=r.replace(e,s)}return r},h=class{constructor(s){t(this,s),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:a("termsandconditions",this.lang),sms:a("sms",this.lang),emailmarketing:a("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),s=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{this.clientStyling=t,s.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(s)}),1)})).catch((t=>{console.log("error ",t)}))}}handleNewTranslations(){r(this.translationUrl)}handleQueryResponse(){this.receivedQueryResponses===this.activeUserActions.length&&this.updateUserConsents()}userLegislationConsentHandler(t){const s=t.detail.type,e=t.detail.value;this.mandatoryActions.includes(s)&&!1===this.queryFired&&(!0===e?this.mandatoryActionsChecked++:this.mandatoryActionsChecked--),this.queryFired&&(this.userActions.push({tagCode:s,status:e?"Accepted":"Denied"}),this.receivedQueryResponses++)}determineUserActions(){const t=new URL(`${this.endpoint}/v1/player/${this.userId}/consent`),s=new Headers;let e;return s.append("X-SessionId",this.userSession),e={method:"GET",headers:s},t&&e?fetch(t.href,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})):Promise.reject("Unsupported endpoint")}updateUserConsents(){let t,s;t="gmcore"===this.gmVersion?new URL(`${this.endpoint}/v1/player/${this.userId}/consent`):new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`),s={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&&s&&fetch(t.href,s).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 r(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),e("div",{class:"QueryReferenceContainer",ref:t=>this.stylingContainer=t},this.isLoading?e("slot",{name:"spinner"})&&e("svg",{class:"spinner",viewBox:"0 0 50 50"},e("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"5"})):e("div",{class:"UserActionController"},e("h2",{class:"UserConsentNotice"},this.userNoticeText),e("div",{class:"PlayerLegislationWrapper"},this.activeUserActions.map((t=>e("slot",{name:t},e("player-user-consents",{slot:t,consentType:t,consentTitle:this.consentTitles[t],queried:this.queryFired,mandatory:this.mandatoryActions.includes(t),"client-styling":this.clientStyling}))))),this.includeSubmitButton&&e("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{i as player_user_consents,h as user_action_controller}