@everymatrix/casino-challenges-claim-code 0.22.64 → 0.22.66

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.
@@ -0,0 +1 @@
1
+ import{r as e,c as t,h as n}from"./index-05d7637d.js";const o="__WIDGET_GLOBAL_STYLE_CACHE__";function i(e,t){if(e){const n=document.createElement("style");n.innerHTML=t,e.appendChild(n)}}function r(e,t){if(!e||!t)return;const n=new URL(t);fetch(n.href).then((e=>e.text())).then((t=>{const n=document.createElement("style");n.innerHTML=t,e&&e.appendChild(n)})).catch((e=>{console.error("There was an error while trying to load client styling from URL",e)}))}function s(e,t,n,i=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!i)return n=function(e,t){const n=document.createElement("style");return window.emMessageBus.subscribe(t,(t=>{e&&(n.innerHTML=t,e.appendChild(n))}))}(e,t),n;window[o]||(window[o]={}),n=function(e,t){return window.emMessageBus.subscribe(t,(n=>{if(!e)return;const i=e.getRootNode(),r=window[o];let s=r[t]&&r[t].sheet;s?r[t].refCount=r[t].refCount+1:(s=new CSSStyleSheet,s.replaceSync(n),r[t]={sheet:s,refCount:1});const a=i.adoptedStyleSheets||[];a.includes(s)||(i.adoptedStyleSheets=[...a,s])}))}(e,t);const r=n.unsubscribe.bind(n);return n.unsubscribe=()=>{if(window[o][t]){const e=window[o][t];e.refCount>1?e.refCount=e.refCount-1:delete window[o][t]}r()},n}const a={en:{claimCodeTitle:"Enter the secret code to unlock hidden quests and rewards.",claimCodeSuccessMessage:"The code was successfully applied.",requestErrorMessage:"Something went wrong. Please try again.",claimCodeInputLabel:"3–30 characters, no spaces",claimCodeBtnText:"Apply code"}},c=(e,t)=>{var n;return null!==(n=a[void 0!==t&&t in a?t:"en"][e])&&void 0!==n?n:a.en[e]},d=class{constructor(n){e(this,n),this.openNotification=t(this,"openNotification",7),this.asciiPrintableRegex=/^[\x21-\x7E]+$/,this.handleSubmit=async()=>{if(this.endpoint&&this.session&&this.domain){const e=await this.applyCode();if(!e)return;if(e.Success)this.openNotification.emit({message:c("claimCodeSuccessMessage",this.language)});else{this.hasError=!0;const t=3002===e.ErrorCode||3023===e.ErrorCode||3003===e.ErrorCode;this.openNotification.emit({message:e.ErrorMessage||c("requestErrorMessage",this.language),errored:!0,showTabLink:t})}}},this.applyCode=async()=>{this.loading=!0;const e=`${this.endpoint}/challenge/GrantChallengeByCode`,t=Object.assign({DomainId:this.domain,ActivationCode:this.code},this.session&&{PlayerSession:this.session});return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((e=>e.json())).catch((()=>(this.openNotification.emit({message:c("requestErrorMessage",this.language),errored:!0}),null))).finally((()=>this.loading=!1))},this.handleInput=e=>{this.code=e.target.value,this.debounceTime&&clearTimeout(this.debounceTime),this.debounceTime=setTimeout((()=>{this.hasError=!this.validate(this.code)}),200)},this.mbSource=void 0,this.clientStyling=void 0,this.clientStylingUrl=void 0,this.translationUrl="",this.language="en",this.endpoint="",this.domain="",this.session="",this.loading=!1,this.hasError=!1,this.code="",this.notificationMessage=""}handleClientStylingChange(e,t){e!=t&&i(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(e,t){e!=t&&r(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(e,t){e!=t&&s(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription)}componentWillLoad(){this.translationUrl&&(async e=>{if(e)try{const n=await fetch(e);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const o=await n.json();t=o,Object.keys(t).forEach((e=>{a[e]||(a[e]={});for(let n in t[e])a[e][n]=t[e][n]}))}catch(e){console.error("Failed to fetch or parse translations from URL:",e)}var t})(this.translationUrl)}componentDidLoad(){this.stylingContainer&&(this.mbSource&&s(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription),this.clientStyling&&i(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&r(this.stylingContainer,this.clientStylingUrl))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}validate(e){return e.length>=3&&e.length<=30&&this.asciiPrintableRegex.test(e)}render(){return n("div",{key:"601b5f6a7123b912a6f753879da34759c77033a2",ref:e=>this.stylingContainer=e},n("div",{key:"5924a51db396bc167d930daa874c571c94c55679",class:"code-container"},n("p",{key:"dbbea8c309114aeb458721030b9ef739a2761a87",class:"code-container__title"},c("claimCodeTitle",this.language)),n("input",{key:"38aaaee10deb9702090c440987a047c9fbc3f856",class:"code-input "+(this.hasError?"errored":""),type:"text",placeholder:"e.g. SPRING24",onInput:this.handleInput}),n("p",{key:"6e0c22a813072a20381ddb63e3f97179ecc26e10",class:"code-input__text"},c("claimCodeInputLabel",this.language)),n("button",{key:"df63607b59067968e425e2903f00058761a6e35c",class:"code-container__button",onClick:this.handleSubmit,disabled:this.loading||!this.code||this.hasError},c("claimCodeBtnText",this.language))))}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"]}}};d.style=".code-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n padding: 80px 0;\n text-align: center;\n}\n.code-container__title {\n font-size: var(--emw--font-size-medium-plus, 18px);\n font-weight: var(--emw--font-weight-medium, 500);\n line-height: 22px;\n color: var(--emw--color-white, white);\n margin: 0 0 32px;\n}\n.code-container__button {\n margin-top: 45px;\n padding: 14px 20px;\n text-transform: uppercase;\n border-radius: var(--emw--button-border-radius, 99px);\n border: 2px solid var(--emw--button-border-color, #083b17);\n font-size: var(--emw--font-size-x-small, 12px);\n font-weight: var(--emw--font-weight-bold, 700);\n color: var(--emw--color-white, #ffffff);\n background-color: var(--emw--button-background-color, #18ce51);\n cursor: pointer;\n}\n.code-container__button:hover {\n color: var(--emw--button-border-color, #083b17);\n border-color: transparent;\n box-shadow: 0 0 4px 0 rgba(188, 252, 177, 0.2), 0 0 20px 0 rgba(0, 183, 79, 0.5);\n}\n.code-container__button:disabled, .code-container__button:disabled:hover {\n color: var(--emw--color-gray-50, #e2e2e2);\n border: 2px solid var(--emw--button-border-color, #083b17);\n opacity: 0.7;\n cursor: not-allowed;\n}\n@container challenges-container (max-width: 576px) {\n .code-container__button {\n width: 100%;\n position: absolute;\n bottom: 50px;\n }\n}\n\n.code-input {\n border: 1px solid var(--emw--button-border-color, #083b17);\n background: var(--emw--color-code-background-secondary, rgba(221, 255, 207, 0.1019607843));\n border-radius: 6px;\n padding: 12px 0;\n line-height: 24px;\n color: var(--emw--color-white, #ffffff);\n text-align: center;\n font-size: var(--emw--font-size-medium, 16px);\n min-width: 340px;\n}\n.code-input:focus {\n outline: 1px solid var(--emw--border-success-color, #00b74f);\n}\n.code-input:focus.errored {\n outline-color: var(--emw--color-error, #d6421e);\n}\n.code-input.errored {\n border-color: var(--emw--color-error, #d6421e);\n}\n.code-input__text {\n margin: 8px 0 0;\n line-height: 22px;\n font-size: var(--emw--font-size-x-small, 12px);\n font-weight: var(--emw--font-weight-medium, 500);\n color: var(--emw--color-gray-150, #c8d6ce);\n}\n.code-input__text.errored {\n color: var(--emw--color-error, #d6421e);\n}\n@container challenges-container (max-width: 576px) {\n .code-input {\n min-width: 100%;\n }\n}";export{d as C}
@@ -1 +1 @@
1
- export{C as casino_challenges_claim_code}from"./casino-challenges-claim-code-0c9a3c42.js";import"./index-05d7637d.js";
1
+ export{C as casino_challenges_claim_code}from"./casino-challenges-claim-code-4731a38c.js";import"./index-05d7637d.js";
@@ -1 +1 @@
1
- export{C as CasinoChallengesClaimCode}from"./casino-challenges-claim-code-0c9a3c42.js";import"./index-05d7637d.js";
1
+ export{C as CasinoChallengesClaimCode}from"./casino-challenges-claim-code-4731a38c.js";import"./index-05d7637d.js";
@@ -131,8 +131,9 @@ const TRANSLATIONS = {
131
131
  }
132
132
  };
133
133
  const translate = (key, customLang) => {
134
+ var _a;
134
135
  const lang = customLang;
135
- return TRANSLATIONS[lang !== undefined && lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key];
136
+ return (_a = TRANSLATIONS[lang !== undefined && lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key]) !== null && _a !== void 0 ? _a : TRANSLATIONS[DEFAULT_LANGUAGE][key];
136
137
  };
137
138
  const getTranslations = (data) => {
138
139
  Object.keys(data).forEach((item) => {
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const casinoChallengesClaimCode = require('./casino-challenges-claim-code-caed3db1.js');
5
+ const casinoChallengesClaimCode = require('./casino-challenges-claim-code-bc9fd0e1.js');
6
6
  require('./index-718e2d1c.js');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const casinoChallengesClaimCode = require('./casino-challenges-claim-code-caed3db1.js');
5
+ const casinoChallengesClaimCode = require('./casino-challenges-claim-code-bc9fd0e1.js');
6
6
  require('./index-718e2d1c.js');
7
7
 
8
8
 
@@ -9,8 +9,9 @@ const TRANSLATIONS = {
9
9
  }
10
10
  };
11
11
  export const translate = (key, customLang) => {
12
+ var _a;
12
13
  const lang = customLang;
13
- return TRANSLATIONS[lang !== undefined && lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key];
14
+ return (_a = TRANSLATIONS[lang !== undefined && lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key]) !== null && _a !== void 0 ? _a : TRANSLATIONS[DEFAULT_LANGUAGE][key];
14
15
  };
15
16
  export const getTranslations = (data) => {
16
17
  Object.keys(data).forEach((item) => {
@@ -129,8 +129,9 @@ const TRANSLATIONS = {
129
129
  }
130
130
  };
131
131
  const translate = (key, customLang) => {
132
+ var _a;
132
133
  const lang = customLang;
133
- return TRANSLATIONS[lang !== undefined && lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key];
134
+ return (_a = TRANSLATIONS[lang !== undefined && lang in TRANSLATIONS ? lang : DEFAULT_LANGUAGE][key]) !== null && _a !== void 0 ? _a : TRANSLATIONS[DEFAULT_LANGUAGE][key];
134
135
  };
135
136
  const getTranslations = (data) => {
136
137
  Object.keys(data).forEach((item) => {
@@ -1,2 +1,2 @@
1
- export { C as casino_challenges_claim_code } from './casino-challenges-claim-code-0c9a3c42.js';
1
+ export { C as casino_challenges_claim_code } from './casino-challenges-claim-code-4731a38c.js';
2
2
  import './index-05d7637d.js';
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { C as CasinoChallengesClaimCode } from './casino-challenges-claim-code-0c9a3c42.js';
1
+ export { C as CasinoChallengesClaimCode } from './casino-challenges-claim-code-4731a38c.js';
2
2
  import './index-05d7637d.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/casino-challenges-claim-code",
3
- "version": "0.22.64",
3
+ "version": "0.22.66",
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 e,c as t,h as n}from"./index-05d7637d.js";const o="__WIDGET_GLOBAL_STYLE_CACHE__";function i(e,t){if(e){const n=document.createElement("style");n.innerHTML=t,e.appendChild(n)}}function r(e,t){if(!e||!t)return;const n=new URL(t);fetch(n.href).then((e=>e.text())).then((t=>{const n=document.createElement("style");n.innerHTML=t,e&&e.appendChild(n)})).catch((e=>{console.error("There was an error while trying to load client styling from URL",e)}))}function s(e,t,n,i=!1){if(!window.emMessageBus)return;if(!("adoptedStyleSheets"in Document.prototype)||!i)return n=function(e,t){const n=document.createElement("style");return window.emMessageBus.subscribe(t,(t=>{e&&(n.innerHTML=t,e.appendChild(n))}))}(e,t),n;window[o]||(window[o]={}),n=function(e,t){return window.emMessageBus.subscribe(t,(n=>{if(!e)return;const i=e.getRootNode(),r=window[o];let s=r[t]&&r[t].sheet;s?r[t].refCount=r[t].refCount+1:(s=new CSSStyleSheet,s.replaceSync(n),r[t]={sheet:s,refCount:1});const a=i.adoptedStyleSheets||[];a.includes(s)||(i.adoptedStyleSheets=[...a,s])}))}(e,t);const r=n.unsubscribe.bind(n);return n.unsubscribe=()=>{if(window[o][t]){const e=window[o][t];e.refCount>1?e.refCount=e.refCount-1:delete window[o][t]}r()},n}const a={en:{claimCodeTitle:"Enter the secret code to unlock hidden quests and rewards.",claimCodeSuccessMessage:"The code was successfully applied.",requestErrorMessage:"Something went wrong. Please try again.",claimCodeInputLabel:"3–30 characters, no spaces",claimCodeBtnText:"Apply code"}},c=(e,t)=>a[void 0!==t&&t in a?t:"en"][e],d=class{constructor(n){e(this,n),this.openNotification=t(this,"openNotification",7),this.asciiPrintableRegex=/^[\x21-\x7E]+$/,this.handleSubmit=async()=>{if(this.endpoint&&this.session&&this.domain){const e=await this.applyCode();if(!e)return;if(e.Success)this.openNotification.emit({message:c("claimCodeSuccessMessage",this.language)});else{this.hasError=!0;const t=3002===e.ErrorCode||3023===e.ErrorCode||3003===e.ErrorCode;this.openNotification.emit({message:e.ErrorMessage||c("requestErrorMessage",this.language),errored:!0,showTabLink:t})}}},this.applyCode=async()=>{this.loading=!0;const e=`${this.endpoint}/challenge/GrantChallengeByCode`,t=Object.assign({DomainId:this.domain,ActivationCode:this.code},this.session&&{PlayerSession:this.session});return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then((e=>e.json())).catch((()=>(this.openNotification.emit({message:c("requestErrorMessage",this.language),errored:!0}),null))).finally((()=>this.loading=!1))},this.handleInput=e=>{this.code=e.target.value,this.debounceTime&&clearTimeout(this.debounceTime),this.debounceTime=setTimeout((()=>{this.hasError=!this.validate(this.code)}),200)},this.mbSource=void 0,this.clientStyling=void 0,this.clientStylingUrl=void 0,this.translationUrl="",this.language="en",this.endpoint="",this.domain="",this.session="",this.loading=!1,this.hasError=!1,this.code="",this.notificationMessage=""}handleClientStylingChange(e,t){e!=t&&i(this.stylingContainer,this.clientStyling)}handleClientStylingUrlChange(e,t){e!=t&&r(this.stylingContainer,this.clientStylingUrl)}handleMbSourceChange(e,t){e!=t&&s(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription)}componentWillLoad(){this.translationUrl&&(async e=>{if(e)try{const n=await fetch(e);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const o=await n.json();t=o,Object.keys(t).forEach((e=>{a[e]||(a[e]={});for(let n in t[e])a[e][n]=t[e][n]}))}catch(e){console.error("Failed to fetch or parse translations from URL:",e)}var t})(this.translationUrl)}componentDidLoad(){this.stylingContainer&&(this.mbSource&&s(this.stylingContainer,`${this.mbSource}.Style`,this.stylingSubscription),this.clientStyling&&i(this.stylingContainer,this.clientStyling),this.clientStylingUrl&&r(this.stylingContainer,this.clientStylingUrl))}disconnectedCallback(){this.stylingSubscription&&this.stylingSubscription.unsubscribe()}validate(e){return e.length>=3&&e.length<=30&&this.asciiPrintableRegex.test(e)}render(){return n("div",{key:"601b5f6a7123b912a6f753879da34759c77033a2",ref:e=>this.stylingContainer=e},n("div",{key:"5924a51db396bc167d930daa874c571c94c55679",class:"code-container"},n("p",{key:"dbbea8c309114aeb458721030b9ef739a2761a87",class:"code-container__title"},c("claimCodeTitle",this.language)),n("input",{key:"38aaaee10deb9702090c440987a047c9fbc3f856",class:"code-input "+(this.hasError?"errored":""),type:"text",placeholder:"e.g. SPRING24",onInput:this.handleInput}),n("p",{key:"6e0c22a813072a20381ddb63e3f97179ecc26e10",class:"code-input__text"},c("claimCodeInputLabel",this.language)),n("button",{key:"df63607b59067968e425e2903f00058761a6e35c",class:"code-container__button",onClick:this.handleSubmit,disabled:this.loading||!this.code||this.hasError},c("claimCodeBtnText",this.language))))}static get watchers(){return{clientStyling:["handleClientStylingChange"],clientStylingUrl:["handleClientStylingUrlChange"],mbSource:["handleMbSourceChange"]}}};d.style=".code-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n padding: 80px 0;\n text-align: center;\n}\n.code-container__title {\n font-size: var(--emw--font-size-medium-plus, 18px);\n font-weight: var(--emw--font-weight-medium, 500);\n line-height: 22px;\n color: var(--emw--color-white, white);\n margin: 0 0 32px;\n}\n.code-container__button {\n margin-top: 45px;\n padding: 14px 20px;\n text-transform: uppercase;\n border-radius: var(--emw--button-border-radius, 99px);\n border: 2px solid var(--emw--button-border-color, #083b17);\n font-size: var(--emw--font-size-x-small, 12px);\n font-weight: var(--emw--font-weight-bold, 700);\n color: var(--emw--color-white, #ffffff);\n background-color: var(--emw--button-background-color, #18ce51);\n cursor: pointer;\n}\n.code-container__button:hover {\n color: var(--emw--button-border-color, #083b17);\n border-color: transparent;\n box-shadow: 0 0 4px 0 rgba(188, 252, 177, 0.2), 0 0 20px 0 rgba(0, 183, 79, 0.5);\n}\n.code-container__button:disabled, .code-container__button:disabled:hover {\n color: var(--emw--color-gray-50, #e2e2e2);\n border: 2px solid var(--emw--button-border-color, #083b17);\n opacity: 0.7;\n cursor: not-allowed;\n}\n@container challenges-container (max-width: 576px) {\n .code-container__button {\n width: 100%;\n position: absolute;\n bottom: 50px;\n }\n}\n\n.code-input {\n border: 1px solid var(--emw--button-border-color, #083b17);\n background: var(--emw--color-code-background-secondary, rgba(221, 255, 207, 0.1019607843));\n border-radius: 6px;\n padding: 12px 0;\n line-height: 24px;\n color: var(--emw--color-white, #ffffff);\n text-align: center;\n font-size: var(--emw--font-size-medium, 16px);\n min-width: 340px;\n}\n.code-input:focus {\n outline: 1px solid var(--emw--border-success-color, #00b74f);\n}\n.code-input:focus.errored {\n outline-color: var(--emw--color-error, #d6421e);\n}\n.code-input.errored {\n border-color: var(--emw--color-error, #d6421e);\n}\n.code-input__text {\n margin: 8px 0 0;\n line-height: 22px;\n font-size: var(--emw--font-size-x-small, 12px);\n font-weight: var(--emw--font-weight-medium, 500);\n color: var(--emw--color-gray-150, #c8d6ce);\n}\n.code-input__text.errored {\n color: var(--emw--color-error, #d6421e);\n}\n@container challenges-container (max-width: 576px) {\n .code-input {\n min-width: 100%;\n }\n}";export{d as C}