@everymatrix/casino-challenges-claim-code 0.11.6 → 0.11.7

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.",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();e.Success?this.openNotification.emit({message:c("claimCodeSuccessMessage",this.language)}):(this.hasError=!0,this.openNotification.emit({message:e.ErrorMessage,errored:!0,showTabLink:3002===e.ErrorCode||3023===e.ErrorCode||3003===e.ErrorCode}))}},this.applyCode=async()=>(this.loading=!0,fetch(`${this.endpoint}/challenge/GrantChallengeByCode`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({DomainId:this.domain,PlayerSessionId:this.session,ActivationCode:this.code})}).then((e=>e.json())).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:"1851f81fab42f91bf0fc6caf7cd511a2d65cd2dc",ref:e=>this.stylingContainer=e},n("div",{key:"bd24a77a9f98f7fece368a786da9cb143361e473",class:"code-container"},n("p",{key:"687b57bb1cb59a956a4691fda3015c4d82b875e4",class:"code-container__title"},c("claimCodeTitle",this.language)),n("input",{key:"7760308eda40ba9aec4368ae072fd5ea95adc538",class:"code-input "+(this.hasError?"errored":""),type:"text",placeholder:"e.g. SPRING24",onInput:this.handleInput}),n("p",{key:"44454ff83adc5adb3da7fc66d94daf928d020d32",class:"code-input__text"},c("claimCodeInputLabel",this.language)),n("button",{key:"a87bbabba465ad5ba101b863def2919b7c4e5439",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 background: transparent;\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-d1142ba4.js";import"./index-05d7637d.js";
1
+ export{C as casino_challenges_claim_code}from"./casino-challenges-claim-code-98d119cc.js";import"./index-05d7637d.js";
@@ -1 +1 @@
1
- export{C as CasinoChallengesClaimCode}from"./casino-challenges-claim-code-d1142ba4.js";import"./index-05d7637d.js";
1
+ export{C as CasinoChallengesClaimCode}from"./casino-challenges-claim-code-98d119cc.js";import"./index-05d7637d.js";
@@ -100,7 +100,7 @@ function getAdoptStyleSubscription(stylingContainer, domain) {
100
100
 
101
101
  const shadowRoot = stylingContainer.getRootNode();
102
102
  const cacheStyleObject = window[StyleCacheKey];
103
- let cachedStyle = cacheStyleObject[domain]?.sheet;
103
+ let cachedStyle = cacheStyleObject[domain] && cacheStyleObject[domain].sheet;
104
104
 
105
105
  if (!cachedStyle) {
106
106
  cachedStyle = new CSSStyleSheet();
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const casinoChallengesClaimCode = require('./casino-challenges-claim-code-e2fb2b4b.js');
5
+ const casinoChallengesClaimCode = require('./casino-challenges-claim-code-ad204a86.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-e2fb2b4b.js');
5
+ const casinoChallengesClaimCode = require('./casino-challenges-claim-code-ad204a86.js');
6
6
  require('./index-718e2d1c.js');
7
7
 
8
8
 
@@ -98,7 +98,7 @@ function getAdoptStyleSubscription(stylingContainer, domain) {
98
98
 
99
99
  const shadowRoot = stylingContainer.getRootNode();
100
100
  const cacheStyleObject = window[StyleCacheKey];
101
- let cachedStyle = cacheStyleObject[domain]?.sheet;
101
+ let cachedStyle = cacheStyleObject[domain] && cacheStyleObject[domain].sheet;
102
102
 
103
103
  if (!cachedStyle) {
104
104
  cachedStyle = new CSSStyleSheet();
@@ -1,2 +1,2 @@
1
- export { C as casino_challenges_claim_code } from './casino-challenges-claim-code-d1142ba4.js';
1
+ export { C as casino_challenges_claim_code } from './casino-challenges-claim-code-98d119cc.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-d1142ba4.js';
1
+ export { C as CasinoChallengesClaimCode } from './casino-challenges-claim-code-98d119cc.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.11.6",
3
+ "version": "0.11.7",
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]?.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.",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();e.Success?this.openNotification.emit({message:c("claimCodeSuccessMessage",this.language)}):(this.hasError=!0,this.openNotification.emit({message:e.ErrorMessage,errored:!0,showTabLink:3002===e.ErrorCode||3023===e.ErrorCode||3003===e.ErrorCode}))}},this.applyCode=async()=>(this.loading=!0,fetch(`${this.endpoint}/challenge/GrantChallengeByCode`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({DomainId:this.domain,PlayerSessionId:this.session,ActivationCode:this.code})}).then((e=>e.json())).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:"1851f81fab42f91bf0fc6caf7cd511a2d65cd2dc",ref:e=>this.stylingContainer=e},n("div",{key:"bd24a77a9f98f7fece368a786da9cb143361e473",class:"code-container"},n("p",{key:"687b57bb1cb59a956a4691fda3015c4d82b875e4",class:"code-container__title"},c("claimCodeTitle",this.language)),n("input",{key:"7760308eda40ba9aec4368ae072fd5ea95adc538",class:"code-input "+(this.hasError?"errored":""),type:"text",placeholder:"e.g. SPRING24",onInput:this.handleInput}),n("p",{key:"44454ff83adc5adb3da7fc66d94daf928d020d32",class:"code-input__text"},c("claimCodeInputLabel",this.language)),n("button",{key:"a87bbabba465ad5ba101b863def2919b7c4e5439",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 background: transparent;\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}