@everymatrix/lottery-order-summary 0.0.1

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.
Files changed (57) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-b1042ae5.js +1307 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/lottery-button_2.cjs.entry.js +179 -0
  6. package/dist/cjs/lottery-order-summary-9c494983.js +292 -0
  7. package/dist/cjs/lottery-order-summary.cjs.js +25 -0
  8. package/dist/collection/collection-manifest.json +19 -0
  9. package/dist/collection/components/lottery-order-summary/index.js +1 -0
  10. package/dist/collection/components/lottery-order-summary/lottery-order-summary.css +67 -0
  11. package/dist/collection/components/lottery-order-summary/lottery-order-summary.js +442 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/model/index.js +7 -0
  14. package/dist/collection/utils/utils.js +38 -0
  15. package/dist/esm/app-globals-0f993ce5.js +3 -0
  16. package/dist/esm/index-8e69c8be.js +1279 -0
  17. package/dist/esm/index.js +2 -0
  18. package/dist/esm/loader.js +11 -0
  19. package/dist/esm/lottery-button_2.entry.js +175 -0
  20. package/dist/esm/lottery-order-summary-1c477f07.js +287 -0
  21. package/dist/esm/lottery-order-summary.js +20 -0
  22. package/dist/index.cjs.js +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/lottery-order-summary/app-globals-0f993ce5.js +1 -0
  25. package/dist/lottery-order-summary/index-8e69c8be.js +2 -0
  26. package/dist/lottery-order-summary/index.esm.js +1 -0
  27. package/dist/lottery-order-summary/lottery-button_2.entry.js +1 -0
  28. package/dist/lottery-order-summary/lottery-order-summary-1c477f07.js +1 -0
  29. package/dist/lottery-order-summary/lottery-order-summary.esm.js +1 -0
  30. package/dist/stencil.config.dev.js +19 -0
  31. package/dist/stencil.config.js +19 -0
  32. package/dist/storybook/main.js +43 -0
  33. package/dist/storybook/preview.js +9 -0
  34. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  35. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/packages/stencil/lottery-order-summary/stencil.config.d.ts +2 -0
  36. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/packages/stencil/lottery-order-summary/stencil.config.dev.d.ts +2 -0
  37. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/packages/stencil/lottery-order-summary/storybook/main.d.ts +3 -0
  38. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/packages/stencil/lottery-order-summary/storybook/preview.d.ts +70 -0
  39. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/tools/plugins/index.d.ts +4 -0
  40. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
  41. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  42. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  43. package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/lottery-order-summary/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  44. package/dist/types/components/lottery-order-summary/index.d.ts +1 -0
  45. package/dist/types/components/lottery-order-summary/lottery-order-summary.d.ts +87 -0
  46. package/dist/types/components.d.ts +175 -0
  47. package/dist/types/index.d.ts +1 -0
  48. package/dist/types/model/index.d.ts +34 -0
  49. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  50. package/dist/types/utils/utils.d.ts +3 -0
  51. package/loader/cdn.js +1 -0
  52. package/loader/index.cjs.js +1 -0
  53. package/loader/index.d.ts +24 -0
  54. package/loader/index.es2017.js +1 -0
  55. package/loader/index.js +2 -0
  56. package/loader/package.json +11 -0
  57. package/package.json +27 -0
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const lotteryOrderSummary = require('./lottery-order-summary-9c494983.js');
6
+ require('./index-b1042ae5.js');
7
+
8
+
9
+
10
+ exports.LotteryOrderSummary = lotteryOrderSummary.LotteryOrderSummary;
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-b1042ae5.js');
6
+ const appGlobals = require('./app-globals-3a1e7e63.js');
7
+
8
+ const defineCustomElements = async (win, options) => {
9
+ if (typeof window === 'undefined') return undefined;
10
+ await appGlobals.globalScripts();
11
+ return index.bootstrapLazy([["lottery-button_2.cjs",[[1,"lottery-order-summary",{"endpoint":[513],"sessionId":[513,"session-id"],"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"language":[513],"orderSummaryTitle":[1,"order-summary-title"],"ticketsLabel":[1,"tickets-label"],"totalLabel":[1,"total-label"],"showColon":[4,"show-colon"],"showDivider":[4,"show-divider"],"submitDisabled":[4,"submit-disabled"],"submitButtonText":[1,"submit-button-text"],"submitLoading":[32]},[[8,"lotteryTicketParamsReady","handleLotteryTicketParamsReady"]],{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-button",{"variant":[513],"size":[513],"color":[513],"disabled":[516],"loading":[516],"text":[513],"mbSource":[513,"mb-source"],"language":[513],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"ripples":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}]]]], options);
12
+ };
13
+
14
+ exports.setNonce = index.setNonce;
15
+ exports.defineCustomElements = defineCustomElements;
@@ -0,0 +1,179 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-b1042ae5.js');
6
+ const lotteryOrderSummary = require('./lottery-order-summary-9c494983.js');
7
+
8
+ const DEFAULT_LANGUAGE = 'en';
9
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr', 'zh'];
10
+ const TRANSLATIONS = {
11
+ en: {
12
+ loading: 'Loading'
13
+ },
14
+ ro: {},
15
+ fr: {},
16
+ ar: {},
17
+ hr: {}
18
+ };
19
+ const translate = (key, customLang, replacements) => {
20
+ const lang = customLang;
21
+ let translation = TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
22
+ if (replacements) {
23
+ Object.keys(replacements).forEach((placeholder) => {
24
+ translation = translation.replace(`{${placeholder}}`, replacements[placeholder]);
25
+ });
26
+ }
27
+ return translation;
28
+ };
29
+ const getTranslations = (data) => {
30
+ Object.keys(data).forEach((item) => {
31
+ for (let key in data[item]) {
32
+ TRANSLATIONS[item][key] = data[item][key];
33
+ }
34
+ });
35
+ };
36
+ const resolveTranslationUrl = async (translationUrl) => {
37
+ if (translationUrl) {
38
+ try {
39
+ const response = await fetch(translationUrl);
40
+ if (!response.ok) {
41
+ throw new Error(`HTTP error! status: ${response.status}`);
42
+ }
43
+ const translations = await response.json();
44
+ getTranslations(translations);
45
+ }
46
+ catch (error) {
47
+ console.error('Failed to fetch or parse translations from URL:', error);
48
+ }
49
+ }
50
+ };
51
+
52
+ const lotteryButtonCss = ":host{display:inline-block}.btn{font:inherit;position:relative;display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:var(--lottery-button-border-radius, 6px);font-weight:var(--lottery-button-font-weight, 500);cursor:pointer;outline:none;overflow:hidden;transition:var(--lottery-button-transition, background-color 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s);user-select:none;-webkit-tap-highlight-color:transparent;box-shadow:var(--lottery-button-box-shadow, 0 2px 4px 0 rgba(0, 0, 0, 0.5))}.btn .content{position:relative;display:inline-flex;align-items:center;gap:var(--lottery-button-content-gap, 0.5em)}.btn .content ::slotted(span){display:inline-flex;align-items:center}.btn:hover:not(:disabled){box-shadow:var(--lottery-button-hover-box-shadow, 0 4px 8px 0 rgba(0, 0, 0, 0.5))}.btn:disabled{cursor:not-allowed;opacity:var(--lottery-button-disabled-opacity, 0.5)}.btn .loading-container{display:flex;align-items:center}.btn--loading{position:relative}.btn .spinner{display:inline-block;width:1em;height:1em;border:var(--lottery-button-spinner-border, 2px solid rgba(255, 255, 255, 0.3));border-radius:50%;border-top-color:var(--lottery-button-spinner-color, white);animation:spin 1s ease-in-out infinite;margin-left:0.5em;vertical-align:middle}.btn--small .spinner{width:0.8em;height:0.8em}.btn--large .spinner{width:1.2em;height:1.2em}@keyframes spin{to{transform:rotate(360deg)}}.btn--primary{background-color:var(--emw--color-primary, #0d196e);color:var(--emw--color-typography-inverse, #fff)}.btn--primary:hover:not(:disabled){background-color:var(--emw--color-primary-variant, #1367e7)}.btn--primary:active:not(:disabled){background-color:var(--lottery-button-primary-active-bg, #08104a)}.btn--outline .spinner,.btn--dashed .spinner,.btn--text .spinner{border-top-color:currentColor;border-color:var(--lottery-button-spinner-inverse-border-color, rgba(0, 0, 0, 0.2))}.btn--outline{background-color:var(--emw--color-background, #fff);border-color:var(--lottery-button-outline-border-color, #dcdcdc);color:var(--emw--color-typography, #000)}.btn--outline:hover:not(:disabled){background-color:var(--emw--color-background-tertiary, #ccc);border-color:var(--lottery-button-outline-hover-border-color, #a6a6a6)}.btn--outline:active:not(:disabled){background-color:var(--lottery-button-outline-active-bg, #e6e6e6)}.btn--dashed{background-color:transparent;border-style:dashed;border-color:var(--lottery-button-dashed-border-color, #dcdcdc);color:var(--lottery-button-dashed-color, #333)}.btn--dashed:hover:not(:disabled){border-color:var(--lottery-button-dashed-hover-border-color, #a6a6a6);color:var(--lottery-button-dashed-hover-color, #0052d9)}.btn--text{background-color:transparent;color:var(--lottery-button-text-color, #0052d9);border-color:transparent}.btn--text:hover:not(:disabled){background-color:var(--lottery-button-text-hover-bg, #f2f2f2)}.btn--text:active:not(:disabled){background-color:var(--lottery-button-text-active-bg, #e6e6e6)}.btn--custom-color:hover:not(:disabled){opacity:var(--lottery-button-custom-hover-opacity, 0.9)}.btn--custom-color:active:not(:disabled){opacity:var(--lottery-button-custom-active-opacity, 0.8)}.btn--small{height:var(--lottery-button-small-height, 28px);font-size:var(--lottery-button-small-font-size, 12px);padding:var(--lottery-button-small-padding, 0 12px)}.btn--medium{height:var(--lottery-button-medium-height, 34px);font-size:var(--lottery-button-medium-font-size, 14px);padding:var(--lottery-button-medium-padding, 0 18px)}.btn--large{height:var(--lottery-button-large-height, 40px);font-size:var(--lottery-button-large-font-size, 16px);padding:var(--lottery-button-large-padding, 0 24px)}.ripple-container{position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;border-radius:inherit}.ripple{position:absolute;border-radius:50%;background-color:var(--lottery-button-ripple-light, rgba(255, 255, 255, 0.3));transform:scale(0);animation:ripple-animation 600ms linear}.btn--outline .ripple,.btn--dashed .ripple,.btn--text .ripple{background-color:var(--lottery-button-ripple-dark, rgba(0, 0, 0, 0.03))}@keyframes ripple-animation{to{transform:scale(4);opacity:0}}";
53
+ const LotteryButtonStyle0 = lotteryButtonCss;
54
+
55
+ const LotteryButton = class {
56
+ constructor(hostRef) {
57
+ index.registerInstance(this, hostRef);
58
+ this.handleClick = (event) => {
59
+ if (this.disabled) {
60
+ return;
61
+ }
62
+ // Get the button element from the shadow root
63
+ const button = this.host.shadowRoot.querySelector('.btn');
64
+ if (!button)
65
+ return;
66
+ const rect = button.getBoundingClientRect();
67
+ const size = Math.max(rect.width, rect.height);
68
+ const top = event.clientY - rect.top - size / 2;
69
+ const left = event.clientX - rect.left - size / 2;
70
+ // Add the new ripple to the state, triggering a re-render
71
+ const newRipple = { top, left, size };
72
+ this.ripples = [...this.ripples, newRipple];
73
+ // Set a timeout to clean up the ripple from the state after the animation ends
74
+ // This prevents the DOM from filling up with old ripple elements
75
+ setTimeout(() => {
76
+ this.ripples = this.ripples.filter((r) => r !== newRipple);
77
+ }, 600); // This duration should match the CSS animation duration
78
+ };
79
+ this.variant = 'primary';
80
+ this.size = 'medium';
81
+ this.color = undefined;
82
+ this.disabled = false;
83
+ this.loading = false;
84
+ this.text = undefined;
85
+ this.mbSource = undefined;
86
+ this.language = 'en';
87
+ this.clientStyling = undefined;
88
+ this.clientStylingUrl = undefined;
89
+ this.translationUrl = '';
90
+ this.ripples = [];
91
+ }
92
+ handleClientStylingChange(newValue, oldValue) {
93
+ if (newValue != oldValue) {
94
+ lotteryOrderSummary.setClientStyling(this.stylingContainer, this.clientStyling);
95
+ }
96
+ }
97
+ handleClientStylingUrlChange(newValue, oldValue) {
98
+ if (newValue != oldValue) {
99
+ lotteryOrderSummary.setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
100
+ }
101
+ }
102
+ handleMbSourceChange(newValue, oldValue) {
103
+ if (newValue != oldValue) {
104
+ lotteryOrderSummary.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
105
+ }
106
+ }
107
+ disconnectedCallback() {
108
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
109
+ }
110
+ componentDidLoad() {
111
+ if (this.stylingContainer) {
112
+ if (this.mbSource)
113
+ lotteryOrderSummary.setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
114
+ if (this.clientStyling)
115
+ lotteryOrderSummary.setClientStyling(this.stylingContainer, this.clientStyling);
116
+ if (this.clientStylingUrl)
117
+ lotteryOrderSummary.setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
118
+ }
119
+ }
120
+ componentWillLoad() {
121
+ if (this.translationUrl) {
122
+ resolveTranslationUrl(this.translationUrl);
123
+ }
124
+ }
125
+ render() {
126
+ const { variant, disabled, size, color } = this;
127
+ const isDisabled = disabled || this.loading;
128
+ // Calculate styles based on variant and color
129
+ const buttonStyles = {};
130
+ if (color) {
131
+ switch (variant) {
132
+ case 'primary':
133
+ Object.assign(buttonStyles, {
134
+ backgroundColor: color,
135
+ borderColor: color
136
+ });
137
+ break;
138
+ case 'outline':
139
+ case 'dashed':
140
+ Object.assign(buttonStyles, {
141
+ color: color,
142
+ borderColor: color
143
+ });
144
+ break;
145
+ case 'text':
146
+ Object.assign(buttonStyles, {
147
+ color: color
148
+ });
149
+ break;
150
+ default:
151
+ Object.assign(buttonStyles, {
152
+ backgroundColor: color,
153
+ borderColor: color
154
+ });
155
+ }
156
+ }
157
+ return (index.h("button", { key: 'aa74ad98c90e7548228557bf8a8d26b125d4a83a', class: {
158
+ btn: true,
159
+ [`btn--${variant}`]: true,
160
+ [`btn--${size}`]: true,
161
+ 'btn--loading': this.loading
162
+ }, style: color ? buttonStyles : undefined, disabled: isDisabled, onClick: this.handleClick, ref: (el) => (this.stylingContainer = el) }, this.loading ? (index.h("div", { class: "loading-container" }, index.h("span", { class: "content" }, this.text || translate('loading', this.language)), index.h("span", { class: "spinner" }))) : (index.h("span", { class: "content" }, index.h("slot", { name: "icon-left" }), this.text || index.h("slot", null), index.h("slot", { name: "icon-right" }))), index.h("div", { key: '302ea02be395bb24989d4abc040a513e23fa029a', class: "ripple-container" }, this.ripples.map((ripple, index$1) => (index.h("span", { key: index$1, class: "ripple", style: {
163
+ top: `${ripple.top}px`,
164
+ left: `${ripple.left}px`,
165
+ width: `${ripple.size}px`,
166
+ height: `${ripple.size}px`
167
+ } }))))));
168
+ }
169
+ get host() { return index.getElement(this); }
170
+ static get watchers() { return {
171
+ "clientStyling": ["handleClientStylingChange"],
172
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
173
+ "mbSource": ["handleMbSourceChange"]
174
+ }; }
175
+ };
176
+ LotteryButton.style = LotteryButtonStyle0;
177
+
178
+ exports.lottery_order_summary = lotteryOrderSummary.LotteryOrderSummary;
179
+ exports.lottery_button = LotteryButton;
@@ -0,0 +1,292 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-b1042ae5.js');
4
+
5
+ const StyleCacheKey = '__WIDGET_GLOBAL_STYLE_CACHE__';
6
+
7
+ /**
8
+ * @name setClientStyling
9
+ * @description Method used to create and append to the passed element of the widget a style element with the content received
10
+ * @param {HTMLElement} stylingContainer The reference element of the widget
11
+ * @param {string} clientStyling The style content
12
+ */
13
+ function setClientStyling(stylingContainer, clientStyling) {
14
+ if (stylingContainer) {
15
+ const sheet = document.createElement('style');
16
+ sheet.innerHTML = clientStyling;
17
+ stylingContainer.appendChild(sheet);
18
+ }
19
+ }
20
+
21
+ /**
22
+ * @name setClientStylingURL
23
+ * @description Method used to create and append to the passed element of the widget a style element with the content fetched from a given URL
24
+ * @param {HTMLElement} stylingContainer The reference element of the widget
25
+ * @param {string} clientStylingUrl The URL of the style content
26
+ */
27
+ function setClientStylingURL(stylingContainer, clientStylingUrl) {
28
+ if (!stylingContainer || !clientStylingUrl) return;
29
+
30
+ const url = new URL(clientStylingUrl);
31
+
32
+ fetch(url.href)
33
+ .then((res) => res.text())
34
+ .then((data) => {
35
+ const cssFile = document.createElement('style');
36
+ cssFile.innerHTML = data;
37
+ if (stylingContainer) {
38
+ stylingContainer.appendChild(cssFile);
39
+ }
40
+ })
41
+ .catch((err) => {
42
+ console.error('There was an error while trying to load client styling from URL', err);
43
+ });
44
+ }
45
+
46
+ /**
47
+ * @name setStreamLibrary
48
+ * @description Method used to create and append to the passed element of the widget a style element with content fetched from the MessageBus
49
+ * @param {HTMLElement} stylingContainer The highest element of the widget
50
+ * @param {string} domain The domain from where the content should be fetched (e.g. 'Casino.Style', 'App.Style', 'casino-footer.style', etc.)
51
+ * @param {ref} subscription A reference to a variable where the subscription should be saved for unsubscribing when no longer needed
52
+ * @param {boolean} useAdoptedStyleSheets A flag to gradually enable testing of adoptedStyleSheets
53
+ */
54
+ function setStreamStyling(stylingContainer, domain, subscription, useAdoptedStyleSheets = false) {
55
+ if (!window.emMessageBus) return;
56
+
57
+ const supportAdoptStyle = 'adoptedStyleSheets' in Document.prototype;
58
+
59
+ if (!supportAdoptStyle || !useAdoptedStyleSheets) {
60
+ subscription = getStyleTagSubscription(stylingContainer, domain);
61
+
62
+ return subscription;
63
+ }
64
+
65
+ if (!window[StyleCacheKey]) {
66
+ window[StyleCacheKey] = {};
67
+ }
68
+ subscription = getAdoptStyleSubscription(stylingContainer, domain);
69
+
70
+ const originalUnsubscribe = subscription.unsubscribe.bind(subscription);
71
+ const wrappedUnsubscribe = () => {
72
+ if (window[StyleCacheKey][domain]) {
73
+ const cachedObject = window[StyleCacheKey][domain];
74
+ cachedObject.refCount > 1
75
+ ? (cachedObject.refCount = cachedObject.refCount - 1)
76
+ : delete window[StyleCacheKey][domain];
77
+ }
78
+
79
+ originalUnsubscribe();
80
+ };
81
+ subscription.unsubscribe = wrappedUnsubscribe;
82
+
83
+ return subscription;
84
+ }
85
+
86
+ function getStyleTagSubscription(stylingContainer, domain) {
87
+ const sheet = document.createElement('style');
88
+
89
+ return window.emMessageBus.subscribe(domain, (data) => {
90
+ if (stylingContainer) {
91
+ sheet.innerHTML = data;
92
+ stylingContainer.appendChild(sheet);
93
+ }
94
+ });
95
+ }
96
+
97
+ function getAdoptStyleSubscription(stylingContainer, domain) {
98
+ return window.emMessageBus.subscribe(domain, (data) => {
99
+ if (!stylingContainer) return;
100
+
101
+ const shadowRoot = stylingContainer.getRootNode();
102
+ const cacheStyleObject = window[StyleCacheKey];
103
+ let cachedStyle = cacheStyleObject[domain] && cacheStyleObject[domain].sheet;
104
+
105
+ if (!cachedStyle) {
106
+ cachedStyle = new CSSStyleSheet();
107
+ cachedStyle.replaceSync(data);
108
+ cacheStyleObject[domain] = {
109
+ sheet: cachedStyle,
110
+ refCount: 1
111
+ };
112
+ } else {
113
+ cacheStyleObject[domain].refCount = cacheStyleObject[domain].refCount + 1;
114
+ }
115
+
116
+ const currentSheets = shadowRoot.adoptedStyleSheets || [];
117
+ if (!currentSheets.includes(cachedStyle)) {
118
+ shadowRoot.adoptedStyleSheets = [...currentSheets, cachedStyle];
119
+ }
120
+ });
121
+ }
122
+
123
+ const generateUUID = () => {
124
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
125
+ var r = (Math.random() * 16) | 0, v = c == 'x' ? r : (r & 0x3) | 0x8;
126
+ return v.toString(16);
127
+ });
128
+ };
129
+ function fetchRequest(url, method = 'GET', body = null, headers = {}) {
130
+ return new Promise((resolve, reject) => {
131
+ const uuid = generateUUID();
132
+ const headersOrigin = Object.assign({ 'Content-Type': 'application/json' }, headers);
133
+ if (method !== 'GET' && method !== 'HEAD') {
134
+ headersOrigin['X-Idempotency-Key'] = uuid;
135
+ }
136
+ const options = {
137
+ method,
138
+ headers: headersOrigin,
139
+ body: null
140
+ };
141
+ if (body && method !== 'GET' && method !== 'HEAD') {
142
+ options.body = JSON.stringify(body);
143
+ }
144
+ else {
145
+ delete options.body;
146
+ }
147
+ fetch(url, options)
148
+ .then((response) => {
149
+ if (!response.ok) {
150
+ return reject(response);
151
+ }
152
+ return response.json();
153
+ })
154
+ .then((data) => resolve(data))
155
+ .catch((error) => reject(error));
156
+ });
157
+ }
158
+
159
+ var TicketStatus;
160
+ (function (TicketStatus) {
161
+ TicketStatus["PURCHASED"] = "Purchased";
162
+ TicketStatus["SETTLED"] = "Settled";
163
+ TicketStatus["CANCELED"] = "Canceled";
164
+ TicketStatus["ERROR"] = "Error";
165
+ })(TicketStatus || (TicketStatus = {}));
166
+
167
+ const lotteryOrderSummaryCss = ":host{width:100%}.order-summary{width:100%;background:var(--emw--color-background, #fff);border-radius:var(--lottery-order-summary-border-radius, 8px);border:var(--lottery-order-summary-border, none);box-shadow:var(--lottery-order-summary-box-shadow, none);box-sizing:border-box}.order-summary__title{margin:var(--lottery-order-summary-title-margin, 0 0 30px 0);text-align:var(--lottery-order-summary-title-text-align, center);color:var(--emw--color-typography, #000);text-transform:uppercase;font-weight:var(--lottery-order-summary-title-font-weight, 700)}.order-summary__ticket-info{display:flex;align-items:center;margin-bottom:var(--lottery-order-summary-row-gap, 16px);gap:var(--lottery-order-summary-col-gap, 10px);color:var(--emw--color-typography, #000)}.order-summary__ticket-label{display:flex;flex-direction:row;align-items:center;width:var(--lottery-order-summary-label-width, 50px);max-width:var(--lottery-order-summary-label-max-width, 100%);flex-shrink:0}.order-summary__colon{margin-left:2px}.order-summary__ticket{font-weight:var(--lottery-order-summary-label-font-weight, 500);color:var(--emw--color-typography, #000);overflow-wrap:break-word}.order-summary__details{display:flex;align-items:center;color:var(--emw--color-typography, #000);font-weight:var(--lottery-order-summary-details-font-weight, 400)}.order-summary__divider{border:none;border-top:var(--lottery-order-summary-divider-border, 1px solid var(--emw--color-gray-100, #e6e6e6));margin:var(--lottery-order-summary-divider-margin, 20px 0)}.order-summary__button-wrapper{display:flex;justify-content:center;margin:var(--lottery-order-summary-button-wrapper-margin, 0);padding:var(--lottery-order-summary-button-wrapper-padding, 0)}";
168
+ const LotteryOrderSummaryStyle0 = lotteryOrderSummaryCss;
169
+
170
+ const LotteryOrderSummary = class {
171
+ constructor(hostRef) {
172
+ index.registerInstance(this, hostRef);
173
+ this.orderSummarySubmit = index.createEvent(this, "orderSummarySubmit", 7);
174
+ this.submitSuccess = index.createEvent(this, "lotteryTicketSubmitSuccess", 7);
175
+ this.submitError = index.createEvent(this, "lotteryTicketSubmitError", 7);
176
+ this.sessionExpired = index.createEvent(this, "sessionExpired", 7);
177
+ this.endpoint = undefined;
178
+ this.sessionId = undefined;
179
+ this.mbSource = undefined;
180
+ this.clientStyling = undefined;
181
+ this.clientStylingUrl = undefined;
182
+ this.language = 'en';
183
+ this.orderSummaryTitle = undefined;
184
+ this.ticketsLabel = undefined;
185
+ this.totalLabel = undefined;
186
+ this.showColon = true;
187
+ this.showDivider = false;
188
+ this.submitDisabled = false;
189
+ this.submitButtonText = undefined;
190
+ this.submitLoading = false;
191
+ }
192
+ handleClientStylingChange(newValue, oldValue) {
193
+ if (newValue != oldValue) {
194
+ setClientStyling(this.stylingContainer, this.clientStyling);
195
+ }
196
+ }
197
+ handleClientStylingUrlChange(newValue, oldValue) {
198
+ if (newValue != oldValue) {
199
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
200
+ }
201
+ }
202
+ handleMbSourceChange(newValue, oldValue) {
203
+ if (newValue != oldValue) {
204
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
205
+ }
206
+ }
207
+ componentDidLoad() {
208
+ if (this.stylingContainer) {
209
+ if (this.mbSource)
210
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
211
+ if (this.clientStyling)
212
+ setClientStyling(this.stylingContainer, this.clientStyling);
213
+ if (this.clientStylingUrl)
214
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
215
+ }
216
+ }
217
+ disconnectedCallback() {
218
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
219
+ }
220
+ handleLotteryTicketParamsReady(event) {
221
+ if (event.detail && this.isValidTicketSubmitParam(event.detail)) {
222
+ this.handleSubmitTickets(event.detail);
223
+ }
224
+ }
225
+ isValidTicketSubmitParam(detail) {
226
+ return (detail &&
227
+ detail.playerId &&
228
+ Array.isArray(detail.tickets) &&
229
+ detail.tickets.length > 0 &&
230
+ detail.tickets.every((ticket) => this.isValidTicketParam(ticket)));
231
+ }
232
+ isValidTicketParam(ticket) {
233
+ return (ticket &&
234
+ ticket.amount !== undefined &&
235
+ ticket.multiplier !== undefined &&
236
+ ticket.multiplierNum !== undefined &&
237
+ typeof ticket.quickPick === 'boolean' &&
238
+ ticket.selection !== undefined);
239
+ }
240
+ async handleSubmitTickets(body) {
241
+ try {
242
+ this.submitLoading = true;
243
+ const res = await fetchRequest(`${this.endpoint}/tickets`, 'POST', body, {
244
+ Authorization: `Bearer ${this.sessionId}`
245
+ });
246
+ if (!res.tickets.every((ticket) => ticket.state === TicketStatus.PURCHASED)) {
247
+ this.submitError.emit({
248
+ message: 'Failed to purchase ticket',
249
+ dataOrigin: res,
250
+ status: 200
251
+ });
252
+ }
253
+ else {
254
+ this.submitSuccess.emit({
255
+ dataOrigin: res,
256
+ status: 200
257
+ });
258
+ }
259
+ }
260
+ catch (e) {
261
+ if (e.status === 401) {
262
+ this.sessionExpired.emit();
263
+ }
264
+ if (e.status > 300 || !e.status) {
265
+ this.submitError.emit({
266
+ dataOrigin: e,
267
+ status: e.status || 0
268
+ });
269
+ }
270
+ }
271
+ finally {
272
+ this.submitLoading = false;
273
+ }
274
+ }
275
+ handleSubmit() {
276
+ this.orderSummarySubmit.emit();
277
+ }
278
+ render() {
279
+ return (index.h("div", { key: 'efdb1636656b63aec159e534475fd666769fd4ca', ref: (el) => (this.stylingContainer = el) }, index.h("div", { key: '6d4c031bc462d721e18b3e652724835ba8fd690a', class: "order-summary" }, index.h("h3", { key: '16ce86d321b12b51bab202ab336d64968bf9ff89', class: "order-summary__title" }, this.orderSummaryTitle), index.h("div", { key: '198532d79c47577006ac5d11f90394ccc513c329', class: "order-summary__ticket" }, index.h("div", { key: '042e62b7d14a6edd406a14d617d17a1a113f5aae', class: "order-summary__ticket-info" }, index.h("div", { key: '7e52751fb547ba8b8383456c520228b2b02f5753', class: "order-summary__ticket-label" }, index.h("div", { key: '90684f3d39ba97a1abd9d8c63e2674b36e4b8678', class: "order-summary__ticket" }, this.ticketsLabel), index.h("span", { key: '16b27f067a674f75fb14b50dcaaaa4c85eb7ebf2', class: "order-summary__colon" }, this.showColon ? ':' : null)), index.h("div", { key: 'a197e3f00bc600a048b37f90ad3a8e37d57dbb13', class: "order-summary__details" }, index.h("slot", { key: '2ae61d6ba689093da155390d7fe85c3c96bb8ba0', name: "orderSummaryTicketDetail" }))), this.showDivider && index.h("hr", { key: 'a27f9309ef46d2d99edc2dd24c1cbe61153548c8', class: "order-summary__divider" }), index.h("div", { key: 'd7574288d92159b7f455c0ce610e0b44c6a5d5fb', class: "order-summary__ticket-info" }, index.h("div", { key: '160290be8ee8267c24372fcccc0172fbde699e54', class: "order-summary__ticket-label" }, index.h("div", { key: '2489842ef3993d180dbda4304d9bf0dd60c5179d', class: "order-summary__ticket" }, this.totalLabel), index.h("span", { key: 'f58319a518511ff51402e26d897ea60de1bf9dce', class: "order-summary__colon" }, this.showColon ? ':' : null)), index.h("span", { key: '7f01d9a780150d81e777702635d66aa04aa9b6da', class: "order-summary__details" }, index.h("slot", { key: 'f72248a4423c6edf89555d0c53d29cd0d4cedf7a', name: "orderSummaryTotalDetail" })))), index.h("slot", { key: 'a5da30406e02ea7dbdbf1f37fc89106b08bd8d3d', name: "orderSummaryChoice" }), index.h("div", { key: 'ed9429dd65495cea075910c5d41f0b9f7785cbb3', class: "order-summary__button-wrapper" }, index.h("lottery-button", { key: '5a31daaeb0faad9127e5c383fc1196a6763278d1', onClick: this.handleSubmit.bind(this), loading: this.submitLoading, disabled: this.submitDisabled, text: this.submitButtonText })))));
280
+ }
281
+ static get watchers() { return {
282
+ "clientStyling": ["handleClientStylingChange"],
283
+ "clientStylingUrl": ["handleClientStylingUrlChange"],
284
+ "mbSource": ["handleMbSourceChange"]
285
+ }; }
286
+ };
287
+ LotteryOrderSummary.style = LotteryOrderSummaryStyle0;
288
+
289
+ exports.LotteryOrderSummary = LotteryOrderSummary;
290
+ exports.setClientStyling = setClientStyling;
291
+ exports.setClientStylingURL = setClientStylingURL;
292
+ exports.setStreamStyling = setStreamStyling;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-b1042ae5.js');
6
+ const appGlobals = require('./app-globals-3a1e7e63.js');
7
+
8
+ /*
9
+ Stencil Client Patch Browser v4.19.2 | MIT Licensed | https://stenciljs.com
10
+ */
11
+ var patchBrowser = () => {
12
+ const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('lottery-order-summary.cjs.js', document.baseURI).href));
13
+ const opts = {};
14
+ if (importMeta !== "") {
15
+ opts.resourcesUrl = new URL(".", importMeta).href;
16
+ }
17
+ return index.promiseResolve(opts);
18
+ };
19
+
20
+ patchBrowser().then(async (options) => {
21
+ await appGlobals.globalScripts();
22
+ return index.bootstrapLazy([["lottery-button_2.cjs",[[1,"lottery-order-summary",{"endpoint":[513],"sessionId":[513,"session-id"],"mbSource":[513,"mb-source"],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"language":[513],"orderSummaryTitle":[1,"order-summary-title"],"ticketsLabel":[1,"tickets-label"],"totalLabel":[1,"total-label"],"showColon":[4,"show-colon"],"showDivider":[4,"show-divider"],"submitDisabled":[4,"submit-disabled"],"submitButtonText":[1,"submit-button-text"],"submitLoading":[32]},[[8,"lotteryTicketParamsReady","handleLotteryTicketParamsReady"]],{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}],[1,"lottery-button",{"variant":[513],"size":[513],"color":[513],"disabled":[516],"loading":[516],"text":[513],"mbSource":[513,"mb-source"],"language":[513],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"translationUrl":[513,"translation-url"],"ripples":[32]},null,{"clientStyling":["handleClientStylingChange"],"clientStylingUrl":["handleClientStylingUrlChange"],"mbSource":["handleMbSourceChange"]}]]]], options);
23
+ });
24
+
25
+ exports.setNonce = index.setNonce;
@@ -0,0 +1,19 @@
1
+ {
2
+ "entries": [
3
+ "components/lottery-order-summary/lottery-order-summary.js"
4
+ ],
5
+ "compiler": {
6
+ "name": "@stencil/core",
7
+ "version": "4.19.2",
8
+ "typescriptVersion": "5.4.5"
9
+ },
10
+ "collections": [
11
+ {
12
+ "name": "@everymatrix/lottery-button",
13
+ "tags": [
14
+ "lottery-button"
15
+ ]
16
+ }
17
+ ],
18
+ "bundles": []
19
+ }
@@ -0,0 +1 @@
1
+ export { LotteryOrderSummary } from './lottery-order-summary';
@@ -0,0 +1,67 @@
1
+ :host {
2
+ width: 100%;
3
+ }
4
+
5
+ .order-summary {
6
+ width: 100%;
7
+ background: var(--emw--color-background, #fff);
8
+ border-radius: var(--lottery-order-summary-border-radius, 8px);
9
+ border: var(--lottery-order-summary-border, none);
10
+ box-shadow: var(--lottery-order-summary-box-shadow, none);
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ .order-summary__title {
15
+ margin: var(--lottery-order-summary-title-margin, 0 0 30px 0);
16
+ text-align: var(--lottery-order-summary-title-text-align, center);
17
+ color: var(--emw--color-typography, #000);
18
+ text-transform: uppercase;
19
+ font-weight: var(--lottery-order-summary-title-font-weight, 700);
20
+ }
21
+
22
+ .order-summary__ticket-info {
23
+ display: flex;
24
+ align-items: center;
25
+ margin-bottom: var(--lottery-order-summary-row-gap, 16px);
26
+ gap: var(--lottery-order-summary-col-gap, 10px);
27
+ color: var(--emw--color-typography, #000);
28
+ }
29
+
30
+ .order-summary__ticket-label {
31
+ display: flex;
32
+ flex-direction: row;
33
+ align-items: center;
34
+ width: var(--lottery-order-summary-label-width, 50px);
35
+ max-width: var(--lottery-order-summary-label-max-width, 100%);
36
+ flex-shrink: 0;
37
+ }
38
+
39
+ .order-summary__colon {
40
+ margin-left: 2px;
41
+ }
42
+
43
+ .order-summary__ticket {
44
+ font-weight: var(--lottery-order-summary-label-font-weight, 500);
45
+ color: var(--emw--color-typography, #000);
46
+ overflow-wrap: break-word;
47
+ }
48
+
49
+ .order-summary__details {
50
+ display: flex;
51
+ align-items: center;
52
+ color: var(--emw--color-typography, #000);
53
+ font-weight: var(--lottery-order-summary-details-font-weight, 400);
54
+ }
55
+
56
+ .order-summary__divider {
57
+ border: none;
58
+ border-top: var(--lottery-order-summary-divider-border, 1px solid var(--emw--color-gray-100, #e6e6e6));
59
+ margin: var(--lottery-order-summary-divider-margin, 20px 0);
60
+ }
61
+
62
+ .order-summary__button-wrapper {
63
+ display: flex;
64
+ justify-content: center;
65
+ margin: var(--lottery-order-summary-button-wrapper-margin, 0);
66
+ padding: var(--lottery-order-summary-button-wrapper-padding, 0);
67
+ }