@everymatrix/temporary-consents 1.43.0 → 1.43.2

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.
@@ -5,7 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-51051de1.js');
6
6
 
7
7
  const DEFAULT_LANGUAGE = 'en';
8
- const SUPPORTED_LANGUAGES = ['en', 'hr'];
9
8
  let TRANSLATIONS = {
10
9
  en: {
11
10
  title: 'Participation conditions',
@@ -41,9 +40,12 @@ const getTranslations = (url) => {
41
40
  fetch(url)
42
41
  .then((res) => res.json())
43
42
  .then((data) => {
44
- Object.keys(data).forEach((item) => {
45
- for (let key in data[item]) {
46
- TRANSLATIONS[item][key] = data[item][key];
43
+ Object.keys(data).forEach((lang) => {
44
+ if (!TRANSLATIONS[lang]) {
45
+ TRANSLATIONS[lang] = {};
46
+ }
47
+ for (let key in data[lang]) {
48
+ TRANSLATIONS[lang][key] = data[lang][key];
47
49
  }
48
50
  });
49
51
  resolve(true);
@@ -52,7 +54,7 @@ const getTranslations = (url) => {
52
54
  };
53
55
  const translate = (key, customLang, values) => {
54
56
  const lang = customLang;
55
- let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
57
+ let translation = TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
56
58
  if (values !== undefined) {
57
59
  for (const [key, value] of Object.entries(values.values)) {
58
60
  const regex = new RegExp(`{${key}}`, 'g');
@@ -1,5 +1,4 @@
1
1
  const DEFAULT_LANGUAGE = 'en';
2
- const SUPPORTED_LANGUAGES = ['en', 'hr'];
3
2
  let TRANSLATIONS = {
4
3
  en: {
5
4
  title: 'Participation conditions',
@@ -35,9 +34,12 @@ export const getTranslations = (url) => {
35
34
  fetch(url)
36
35
  .then((res) => res.json())
37
36
  .then((data) => {
38
- Object.keys(data).forEach((item) => {
39
- for (let key in data[item]) {
40
- TRANSLATIONS[item][key] = data[item][key];
37
+ Object.keys(data).forEach((lang) => {
38
+ if (!TRANSLATIONS[lang]) {
39
+ TRANSLATIONS[lang] = {};
40
+ }
41
+ for (let key in data[lang]) {
42
+ TRANSLATIONS[lang][key] = data[lang][key];
41
43
  }
42
44
  });
43
45
  resolve(true);
@@ -46,7 +48,7 @@ export const getTranslations = (url) => {
46
48
  };
47
49
  export const translate = (key, customLang, values) => {
48
50
  const lang = customLang;
49
- let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
51
+ let translation = TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
50
52
  if (values !== undefined) {
51
53
  for (const [key, value] of Object.entries(values.values)) {
52
54
  const regex = new RegExp(`{${key}}`, 'g');
@@ -1,7 +1,6 @@
1
1
  import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
2
 
3
3
  const DEFAULT_LANGUAGE = 'en';
4
- const SUPPORTED_LANGUAGES = ['en', 'hr'];
5
4
  let TRANSLATIONS = {
6
5
  en: {
7
6
  title: 'Participation conditions',
@@ -37,9 +36,12 @@ const getTranslations = (url) => {
37
36
  fetch(url)
38
37
  .then((res) => res.json())
39
38
  .then((data) => {
40
- Object.keys(data).forEach((item) => {
41
- for (let key in data[item]) {
42
- TRANSLATIONS[item][key] = data[item][key];
39
+ Object.keys(data).forEach((lang) => {
40
+ if (!TRANSLATIONS[lang]) {
41
+ TRANSLATIONS[lang] = {};
42
+ }
43
+ for (let key in data[lang]) {
44
+ TRANSLATIONS[lang][key] = data[lang][key];
43
45
  }
44
46
  });
45
47
  resolve(true);
@@ -48,7 +50,7 @@ const getTranslations = (url) => {
48
50
  };
49
51
  const translate = (key, customLang, values) => {
50
52
  const lang = customLang;
51
- let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
53
+ let translation = TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
52
54
  if (values !== undefined) {
53
55
  for (const [key, value] of Object.entries(values.values)) {
54
56
  const regex = new RegExp(`{${key}}`, 'g');
@@ -1,7 +1,6 @@
1
1
  import { r as registerInstance, h } from './index-0f95c245.js';
2
2
 
3
3
  const DEFAULT_LANGUAGE = 'en';
4
- const SUPPORTED_LANGUAGES = ['en', 'hr'];
5
4
  let TRANSLATIONS = {
6
5
  en: {
7
6
  title: 'Participation conditions',
@@ -37,9 +36,12 @@ const getTranslations = (url) => {
37
36
  fetch(url)
38
37
  .then((res) => res.json())
39
38
  .then((data) => {
40
- Object.keys(data).forEach((item) => {
41
- for (let key in data[item]) {
42
- TRANSLATIONS[item][key] = data[item][key];
39
+ Object.keys(data).forEach((lang) => {
40
+ if (!TRANSLATIONS[lang]) {
41
+ TRANSLATIONS[lang] = {};
42
+ }
43
+ for (let key in data[lang]) {
44
+ TRANSLATIONS[lang][key] = data[lang][key];
43
45
  }
44
46
  });
45
47
  resolve(true);
@@ -48,7 +50,7 @@ const getTranslations = (url) => {
48
50
  };
49
51
  const translate = (key, customLang, values) => {
50
52
  const lang = customLang;
51
- let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
53
+ let translation = TRANSLATIONS[(lang !== undefined) && (lang in TRANSLATIONS) ? lang : DEFAULT_LANGUAGE][key];
52
54
  if (values !== undefined) {
53
55
  for (const [key, value] of Object.entries(values.values)) {
54
56
  const regex = new RegExp(`{${key}}`, 'g');
@@ -0,0 +1 @@
1
+ import{r as t,h as e}from"./p-c8fa79f6.js";let o={en:{title:"Participation conditions",description:"Important: Full verification is required in order to be able to use our entire offer. If verification is not completed, it is not possible to withdraw and the betting account will be locked in {daysUntilLockout} days.",declineButton:"Decline and log out",acceptButton:"Accept",loading:"Please wait, loading..."},hr:{title:"Uvjeti sudjelovanja",description:"Važno: Potrebna je potpuna verifikacija kako biste mogli koristiti našu cjelokupnu ponudu. Ako potvrda nije dovršena, nije moguće podići i račun za klađenje bit će zaključan za {daysUntilLockout} dana.",declineButton:"Odbijte i odjavite se",acceptButton:"Prihvatiti",loading:"Molimo pričekajte, učitavanje..."},"es-mx":{title:"Condiciones de participación",description:"Importante: Una verificación completa es requerida para poder utilizar nuestra oferta. Si no se verifica, no será posible hacer retiros y la cuenta para realizar apuestas será bloqueada.",declineButton:"Declinar y salir",acceptButton:"Aceptar",Loading:"Espere por favor, Cargando..."},"pt-br":{title:"Condições de participação",description:"Importante: É necessária uma verificação completa para poder utilizar a nossa oferta. Se não for verificado, os saques não serão possíveis e a conta de apostas será bloqueada.",declineButton:"Recusar e sair",acceptButton:"Aceitar",Loading:"Espere, por favor, Carregando..."}};const n=(t,e,n)=>{let i=o[void 0!==e&&e in o?e:"en"][t];if(void 0!==n)for(const[t,e]of Object.entries(n.values)){const o=new RegExp(`{${t}}`,"g");i=i.replace(o,e)}return i},i=class{constructor(e){t(this,e),this.clientStyling="",this.clientStylingUrl="",this.translationUrl="",this.stylingAppends=!1,this.isLoading=!1,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=>{e.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(e)}),1)})).catch((t=>{console.log("error ",t)}))}}componentWillLoad(){const t=[];if(this.endpoint&&this.userId){const e=this.getConsents().then((t=>{this.temporaryAccountConsent=t.consents.some((t=>"temporaryaccountconsent"==t.tagCode))}));t.push(e)}if(this.translationUrl){const n=(e=this.translationUrl,new Promise((t=>{fetch(e).then((t=>t.json())).then((e=>{Object.keys(e).forEach((t=>{o[t]||(o[t]={});for(let n in e[t])o[t][n]=e[t][n]})),t(!0)}))})));t.push(n)}var e;return Promise.all(t)}componentDidRender(){!this.stylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.stylingAppends=!0)}getConsents(){const t=new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`),e=new Headers;e.append("X-SessionId",this.sessionId),e.append("Accept","application/json");const o={method:"GET",headers:e};return new Promise(((e,n)=>{this.isLoading=!0,fetch(t.href,o).then((t=>t.json())).then((t=>{e(t)})).catch((t=>{console.error(t),n(t)})).finally((()=>{this.isLoading=!1}))}))}setConsents(){const t=new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`),e=new Headers;e.append("X-SessionId",this.sessionId),e.append("Accept","application/json"),e.append("Content-Type","application/json");const o={method:"POST",headers:e,body:JSON.stringify({consents:[{tagCode:"temporaryaccountconsent",note:"",status:1}]})};return new Promise(((e,n)=>{this.isLoading=!0,fetch(t.href,o).then((t=>t.json())).then((t=>{e(t)})).catch((t=>{console.error(t),n(t)})).finally((()=>{this.isLoading=!1}))}))}handleDecline(){window.postMessage({type:"TemporaryConsentsDeclined"},window.location.href)}handleAccept(){this.setConsents(),window.postMessage({type:"TemporaryConsentsAccepted"},window.location.href)}render(){if(this.temporaryAccountConsent)return this.isLoading?e("p",null,n("loading",this.lang)):e("div",{class:"TemporaryConsents",ref:t=>this.stylingContainer=t},e("h2",{class:"TemporaryConsentsTitle"}," ",n("title",this.lang)," "),e("p",{class:"TemporaryConsentsText"}," ",n("description",this.lang,{values:{daysUntilLockout:this.daysUntilLockout}})," "),e("div",{class:"TemporaryConsentsButtonsWrapper"},e("button",{class:"TemporaryConsentsButton TemporaryConsentsButtonDecline",onClick:()=>this.handleDecline()},n("declineButton",this.lang)),e("button",{class:"TemporaryConsentsButton TemporaryConsentsButtonAccept",onClick:this.handleAccept},n("acceptButton",this.lang))))}};i.style="*,*::after,*::before{box-sizing:border-box;padding:0;margin:0}:host{display:block}.TemporaryConsents{max-width:500px;display:flex;gap:35px;flex-direction:column;box-shadow:0px 1px 5px 1px rgba(0, 0, 0, 0.1);padding:20px;font-family:sans-serif}.TemporaryConsentsTitle{text-align:left;font-family:inherit;color:#000;font-weight:400;font-size:18px;display:block;border-bottom:1px solid #000;padding-bottom:10px}.TemporaryConsentsText{font-family:inherit;font-weight:300;font-size:16px}.TemporaryConsentsButtonsWrapper{display:flex;justify-content:space-evenly;gap:50px}.TemporaryConsentsButton{font-family:inherit;font-weight:300;font-size:14px;border:none;padding:10px;min-width:150px;border-radius:4px}.TemporaryConsentsButtonDecline{background-color:transparent;border:1px solid #000}.TemporaryConsentsButtonAccept{color:white;background-color:#000}";export{i as temporary_consents}
@@ -1 +1 @@
1
- import{p as n,b as t}from"./p-c8fa79f6.js";(()=>{const t=import.meta.url,s={};return""!==t&&(s.resourcesUrl=new URL(".",t).href),n(s)})().then((n=>t([["p-0d997674",[[1,"temporary-consents",{endpoint:[513],userId:[513,"user-id"],sessionId:[513,"session-id"],daysUntilLockout:[513,"days-until-lockout"],lang:[513],clientStyling:[513,"client-styling"],clientStylingUrl:[513,"client-styling-url"],translationUrl:[513,"translation-url"],stylingAppends:[32]}]]]],n)));
1
+ import{p as n,b as t}from"./p-c8fa79f6.js";(()=>{const t=import.meta.url,s={};return""!==t&&(s.resourcesUrl=new URL(".",t).href),n(s)})().then((n=>t([["p-e9beb1df",[[1,"temporary-consents",{endpoint:[513],userId:[513,"user-id"],sessionId:[513,"session-id"],daysUntilLockout:[513,"days-until-lockout"],lang:[513],clientStyling:[513,"client-styling"],clientStylingUrl:[513,"client-styling-url"],translationUrl:[513,"translation-url"],stylingAppends:[32]}]]]],n)));
@@ -1,6 +1,2 @@
1
- interface TranslationValues {
2
- values: object;
3
- }
4
1
  export declare const getTranslations: (url: string) => Promise<unknown>;
5
- export declare const translate: (key: string, customLang?: any, values?: TranslationValues) => string;
6
- export {};
2
+ export declare const translate: (key: string, customLang?: any, values?: any) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/temporary-consents",
3
- "version": "1.43.0",
3
+ "version": "1.43.2",
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,h as e}from"./p-c8fa79f6.js";const o=["en","hr"];let n={en:{title:"Participation conditions",description:"Important: Full verification is required in order to be able to use our entire offer. If verification is not completed, it is not possible to withdraw and the betting account will be locked in {daysUntilLockout} days.",declineButton:"Decline and log out",acceptButton:"Accept",loading:"Please wait, loading..."},hr:{title:"Uvjeti sudjelovanja",description:"Važno: Potrebna je potpuna verifikacija kako biste mogli koristiti našu cjelokupnu ponudu. Ako potvrda nije dovršena, nije moguće podići i račun za klađenje bit će zaključan za {daysUntilLockout} dana.",declineButton:"Odbijte i odjavite se",acceptButton:"Prihvatiti",loading:"Molimo pričekajte, učitavanje..."},"es-mx":{title:"Condiciones de participación",description:"Importante: Una verificación completa es requerida para poder utilizar nuestra oferta. Si no se verifica, no será posible hacer retiros y la cuenta para realizar apuestas será bloqueada.",declineButton:"Declinar y salir",acceptButton:"Aceptar",Loading:"Espere por favor, Cargando..."},"pt-br":{title:"Condições de participação",description:"Importante: É necessária uma verificação completa para poder utilizar a nossa oferta. Se não for verificado, os saques não serão possíveis e a conta de apostas será bloqueada.",declineButton:"Recusar e sair",acceptButton:"Aceitar",Loading:"Espere, por favor, Carregando..."}};const i=(t,e,i)=>{const s=e;let a=n[void 0!==s&&o.includes(s)?s:"en"][t];if(void 0!==i)for(const[t,e]of Object.entries(i.values)){const o=new RegExp(`{${t}}`,"g");a=a.replace(o,e)}return a},s=class{constructor(e){t(this,e),this.clientStyling="",this.clientStylingUrl="",this.translationUrl="",this.stylingAppends=!1,this.isLoading=!1,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=>{e.innerHTML=t,setTimeout((()=>{this.stylingContainer.prepend(e)}),1)})).catch((t=>{console.log("error ",t)}))}}componentWillLoad(){const t=[];if(this.endpoint&&this.userId){const e=this.getConsents().then((t=>{this.temporaryAccountConsent=t.consents.some((t=>"temporaryaccountconsent"==t.tagCode))}));t.push(e)}if(this.translationUrl){const o=(e=this.translationUrl,new Promise((t=>{fetch(e).then((t=>t.json())).then((e=>{Object.keys(e).forEach((t=>{for(let o in e[t])n[t][o]=e[t][o]})),t(!0)}))})));t.push(o)}var e;return Promise.all(t)}componentDidRender(){!this.stylingAppends&&this.stylingContainer&&(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.stylingAppends=!0)}getConsents(){const t=new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`),e=new Headers;e.append("X-SessionId",this.sessionId),e.append("Accept","application/json");const o={method:"GET",headers:e};return new Promise(((e,n)=>{this.isLoading=!0,fetch(t.href,o).then((t=>t.json())).then((t=>{e(t)})).catch((t=>{console.error(t),n(t)})).finally((()=>{this.isLoading=!1}))}))}setConsents(){const t=new URL(`${this.endpoint}/v1/player/${this.userId}/legislation/consents`),e=new Headers;e.append("X-SessionId",this.sessionId),e.append("Accept","application/json"),e.append("Content-Type","application/json");const o={method:"POST",headers:e,body:JSON.stringify({consents:[{tagCode:"temporaryaccountconsent",note:"",status:1}]})};return new Promise(((e,n)=>{this.isLoading=!0,fetch(t.href,o).then((t=>t.json())).then((t=>{e(t)})).catch((t=>{console.error(t),n(t)})).finally((()=>{this.isLoading=!1}))}))}handleDecline(){window.postMessage({type:"TemporaryConsentsDeclined"},window.location.href)}handleAccept(){this.setConsents(),window.postMessage({type:"TemporaryConsentsAccepted"},window.location.href)}render(){if(this.temporaryAccountConsent)return this.isLoading?e("p",null,i("loading",this.lang)):e("div",{class:"TemporaryConsents",ref:t=>this.stylingContainer=t},e("h2",{class:"TemporaryConsentsTitle"}," ",i("title",this.lang)," "),e("p",{class:"TemporaryConsentsText"}," ",i("description",this.lang,{values:{daysUntilLockout:this.daysUntilLockout}})," "),e("div",{class:"TemporaryConsentsButtonsWrapper"},e("button",{class:"TemporaryConsentsButton TemporaryConsentsButtonDecline",onClick:()=>this.handleDecline()},i("declineButton",this.lang)),e("button",{class:"TemporaryConsentsButton TemporaryConsentsButtonAccept",onClick:this.handleAccept},i("acceptButton",this.lang))))}};s.style="*,*::after,*::before{box-sizing:border-box;padding:0;margin:0}:host{display:block}.TemporaryConsents{max-width:500px;display:flex;gap:35px;flex-direction:column;box-shadow:0px 1px 5px 1px rgba(0, 0, 0, 0.1);padding:20px;font-family:sans-serif}.TemporaryConsentsTitle{text-align:left;font-family:inherit;color:#000;font-weight:400;font-size:18px;display:block;border-bottom:1px solid #000;padding-bottom:10px}.TemporaryConsentsText{font-family:inherit;font-weight:300;font-size:16px}.TemporaryConsentsButtonsWrapper{display:flex;justify-content:space-evenly;gap:50px}.TemporaryConsentsButton{font-family:inherit;font-weight:300;font-size:14px;border:none;padding:10px;min-width:150px;border-radius:4px}.TemporaryConsentsButtonDecline{background-color:transparent;border:1px solid #000}.TemporaryConsentsButtonAccept{color:white;background-color:#000}";export{s as temporary_consents}