@everymatrix/lottery-ticket-controller 1.32.4 → 1.33.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 (56) hide show
  1. package/dist/cjs/helper-accordion_5.cjs.entry.js +755 -0
  2. package/dist/cjs/index-797fecd9.js +1286 -0
  3. package/dist/cjs/index.cjs.js +2 -0
  4. package/dist/cjs/loader.cjs.js +21 -0
  5. package/dist/cjs/lottery-ticket-controller.cjs.js +19 -0
  6. package/dist/collection/collection-manifest.json +37 -0
  7. package/dist/collection/components/lottery-ticket-controller/lottery-ticket-controller.css +185 -0
  8. package/dist/collection/components/lottery-ticket-controller/lottery-ticket-controller.js +404 -0
  9. package/dist/collection/index.js +1 -0
  10. package/dist/collection/utils/locale.utils.js +23 -0
  11. package/dist/collection/utils/utils.js +3 -0
  12. package/dist/components/helper-accordion.js +6 -0
  13. package/dist/components/helper-accordion2.js +159 -0
  14. package/dist/components/index.d.ts +26 -0
  15. package/dist/components/index.js +1 -0
  16. package/dist/components/lottery-bullet.js +6 -0
  17. package/dist/components/lottery-bullet2.js +91 -0
  18. package/dist/components/lottery-grid.js +6 -0
  19. package/dist/components/lottery-grid2.js +245 -0
  20. package/dist/components/lottery-ticket-controller.d.ts +11 -0
  21. package/dist/components/lottery-ticket-controller.js +185 -0
  22. package/dist/components/lottery-ticket.js +6 -0
  23. package/dist/components/lottery-ticket2.js +273 -0
  24. package/dist/esm/helper-accordion_5.entry.js +747 -0
  25. package/dist/esm/index-c4bda097.js +1260 -0
  26. package/dist/esm/index.js +1 -0
  27. package/dist/esm/loader.js +17 -0
  28. package/dist/esm/lottery-ticket-controller.js +17 -0
  29. package/dist/esm/polyfills/core-js.js +11 -0
  30. package/dist/esm/polyfills/css-shim.js +1 -0
  31. package/dist/esm/polyfills/dom.js +79 -0
  32. package/dist/esm/polyfills/es5-html-element.js +1 -0
  33. package/dist/esm/polyfills/index.js +34 -0
  34. package/dist/esm/polyfills/system.js +6 -0
  35. package/dist/index.cjs.js +1 -0
  36. package/dist/index.js +1 -0
  37. package/dist/lottery-ticket-controller/index.esm.js +0 -0
  38. package/dist/lottery-ticket-controller/lottery-ticket-controller.esm.js +1 -0
  39. package/dist/lottery-ticket-controller/p-1f81b6df.js +1 -0
  40. package/dist/lottery-ticket-controller/p-e25b2082.entry.js +1 -0
  41. package/dist/stencil.config.js +22 -0
  42. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/lottery-ticket-controller/.stencil/packages/lottery-ticket-controller/stencil.config.d.ts +2 -0
  43. package/dist/types/components/lottery-ticket-controller/lottery-ticket-controller.d.ts +73 -0
  44. package/dist/types/components.d.ts +158 -0
  45. package/dist/types/index.d.ts +1 -0
  46. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  47. package/dist/types/utils/locale.utils.d.ts +1 -0
  48. package/dist/types/utils/utils.d.ts +1 -0
  49. package/loader/cdn.js +3 -0
  50. package/loader/index.cjs.js +3 -0
  51. package/loader/index.d.ts +12 -0
  52. package/loader/index.es2017.js +3 -0
  53. package/loader/index.js +4 -0
  54. package/loader/package.json +10 -0
  55. package/package.json +2 -3
  56. package/LICENSE +0 -21
@@ -0,0 +1,755 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-797fecd9.js');
6
+
7
+ const DEFAULT_LANGUAGE$2 = 'en';
8
+ const SUPPORTED_LANGUAGES$2 = ['ro', 'en', 'hr'];
9
+ const TRANSLATIONS$2 = {
10
+ en: {
11
+ deleteTicket: 'Delete ticket'
12
+ },
13
+ ro: {
14
+ deleteTicket: 'Sterge biletul'
15
+ },
16
+ fr: {
17
+ deleteTicket: 'Supprimer le billet'
18
+ },
19
+ ar: {
20
+ deleteTicket: 'حذف التذكرة'
21
+ },
22
+ hr: {
23
+ deleteTicket: 'Izbriši listić'
24
+ }
25
+ };
26
+ const translate$2 = (key, customLang) => {
27
+ const lang = customLang;
28
+ return TRANSLATIONS$2[lang !== undefined && SUPPORTED_LANGUAGES$2.includes(lang) ? lang : DEFAULT_LANGUAGE$2][key];
29
+ };
30
+
31
+ const helperAccordionCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.Header{border-radius:5px;background:#009993;display:flex;gap:30px;border:1px solid #009993;padding:8px 10px;user-select:none;margin-bottom:1px;cursor:pointer}.Header:hover{background:#00ABA4}.Header .Title,.Header .Subtitle,.Header .Description{margin:0;font-size:14px;color:#fff;text-transform:capitalize}.Header .Expand{margin-left:auto;color:#FFF;width:17px;height:17px;cursor:pointer;text-align:center;transform:rotate(90deg);font-size:20px;user-select:none}.HeaderTicketHistory{border-radius:4px;background:#F1F1F1;display:flex;gap:30px;border:1px solid #009993;padding:8px 10px;user-select:none;margin-bottom:5px;cursor:pointer}.HeaderTicketHistory:hover{background:#00ABA4}.HeaderTicketHistory .Title,.HeaderTicketHistory .Subtitle,.HeaderTicketHistory .Description{margin:0;font-size:14px;color:#000}.HeaderTicketHistory .Expand{margin-left:auto;color:#FFF;width:17px;height:17px;cursor:pointer;text-align:center;transform:rotate(90deg);font-size:20px;user-select:none}.Content{border-radius:0 0 4px 4px;background:#fff;border:1px solid #009993;padding:10px 15px;user-select:none;color:#000;margin-bottom:10px}.ActionButton{cursor:pointer;display:inline-block;border-radius:4px;margin:20px 0 10px;text-transform:uppercase;font-size:12px;text-align:center;padding:8px 20px;min-width:80px;background:#FF3D00;border:1px solid #FF3D00;color:#FFF}.ActionButton:hover{background:#FF6536;border:1px solid #FF3D00}";
32
+
33
+ const Accordion = class {
34
+ constructor(hostRef) {
35
+ index.registerInstance(this, hostRef);
36
+ this.accordionEvent = index.createEvent(this, "helperAccordionAction", 7);
37
+ /**
38
+ * Flag for ticket history
39
+ */
40
+ this.ticketHistoryFlag = false;
41
+ /**
42
+ * Title (top header)
43
+ */
44
+ this.headerTitle = '';
45
+ /**
46
+ * SubTitle (top header)
47
+ */
48
+ this.headerSubtitle = '';
49
+ /**
50
+ * Description
51
+ */
52
+ this.description = '';
53
+ /**
54
+ * Enables footer content
55
+ */
56
+ this.footer = false;
57
+ /**
58
+ * Enables footer button for tab deletion
59
+ */
60
+ this.deleteTab = false;
61
+ /**
62
+ * Activates postMessages as events for actions from the widget
63
+ */
64
+ this.postMessage = false;
65
+ /**
66
+ * Name of the event emitter by the action button
67
+ */
68
+ this.eventName = 'helperAccordionAction';
69
+ /**
70
+ * Collapsed
71
+ */
72
+ this.collapsed = true;
73
+ /**
74
+ * Language
75
+ */
76
+ this.language = 'en';
77
+ /**
78
+ * Client custom styling via string
79
+ */
80
+ this.clientStyling = '';
81
+ /**
82
+ * Client custom styling via url content
83
+ */
84
+ this.clientStylingUrlContent = '';
85
+ this.limitStylingAppends = false;
86
+ this.setClientStyling = () => {
87
+ let sheet = document.createElement('style');
88
+ sheet.innerHTML = this.clientStyling;
89
+ this.stylingContainer.prepend(sheet);
90
+ };
91
+ this.setClientStylingURL = () => {
92
+ let cssFile = document.createElement('style');
93
+ setTimeout(() => {
94
+ cssFile.innerHTML = this.clientStylingUrlContent;
95
+ this.stylingContainer.prepend(cssFile);
96
+ }, 1);
97
+ };
98
+ }
99
+ // @TODO fix the `any` type :)
100
+ connectedCallback() {
101
+ this.showContent = !this.collapsed;
102
+ }
103
+ componentDidRender() {
104
+ // start custom styling area
105
+ if (!this.limitStylingAppends && this.stylingContainer) {
106
+ if (this.clientStyling)
107
+ this.setClientStyling();
108
+ if (this.clientStylingUrlContent)
109
+ this.setClientStylingURL();
110
+ this.limitStylingAppends = true;
111
+ }
112
+ // end custom styling area
113
+ }
114
+ toggleContent() {
115
+ this.showContent = !this.showContent;
116
+ }
117
+ deleteAction() {
118
+ if (this.postMessage) {
119
+ // @TODO maybe change the name type, this one sucks
120
+ window.postMessage({ type: this.eventName }, window.location.href);
121
+ }
122
+ this.accordionEvent.emit();
123
+ }
124
+ render() {
125
+ return (index.h("div", { class: "Wrapper", ref: el => this.stylingContainer = el }, index.h("div", { class: this.ticketHistoryFlag === true ? 'HeaderTicketHistory' : 'Header', onClick: () => this.toggleContent() }, index.h("p", { class: "Title" }, this.headerTitle), index.h("p", { class: "Subtitle" }, this.headerSubtitle), index.h("p", { class: "Subtitle Description" }, this.description), index.h("span", { class: "Expand" }, this.showContent ? '<' : '>')), this.showContent &&
126
+ index.h("div", null, index.h("div", { class: "Content" }, index.h("slot", { name: 'accordionContent' }), this.footer && this.showContent &&
127
+ index.h("div", null, this.deleteTab &&
128
+ index.h("span", { class: "ActionButton", onClick: () => this.deleteAction() }, translate$2('deleteTicket', this.language)))))));
129
+ }
130
+ };
131
+ Accordion.style = helperAccordionCss;
132
+
133
+ const lotteryBulletCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}@-webkit-keyframes Circle{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes Circle{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes hover-rotate{0%{-webkit-transform:scale(1) rotateZ(0);transform:scale(1) rotateZ(0)}50%{-webkit-transform:scale(1.2) rotateZ(180deg);transform:scale(1.22) rotateZ(180deg)}100%{-webkit-transform:scale(1) rotateZ(360deg);transform:scale(1) rotateZ(360deg)}}@keyframes hover-rotate{0%{-webkit-transform:scale(1) rotateZ(0);transform:scale(1) rotateZ(0)}50%{-webkit-transform:scale(1.2) rotateZ(180deg);transform:scale(1.2) rotateZ(180deg)}100%{-webkit-transform:scale(1) rotateZ(360deg);transform:scale(1) rotateZ(360deg)}}@-webkit-keyframes selected-scaleUp{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1.2);transform:scale(1.2)}}@keyframes selected-scaleUp{0%{-webkit-transform:scale(0.5);transform:scale(0.5)}100%{-webkit-transform:scale(1);transform:scale(1)}}.Circle{-webkit-animation:Circle 0.8s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:Circle 0.8s cubic-bezier(0.39, 0.575, 0.565, 1) both;cursor:pointer;color:#000000;display:block;height:30px;width:30px;margin:0;display:flex;align-items:center;justify-content:center;justify-content:center;align-items:center;border:solid 2px #ffffff;background:radial-gradient(circle at top, white 0%, white 100%);font-weight:bold;border-radius:50%;box-shadow:0 2px 4px 0 rgba(0, 0, 0, 0.5);user-select:none;font-size:16px;line-height:16px;font-weight:600;position:relative}.Circle:hover{-webkit-animation:hover-rotate 0.4s linear both;animation:hover-rotate 0.4s linear both;background:radial-gradient(circle at top, white 0%, #f1f1f1 100%)}.Circle.Selected{-webkit-animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;color:#ffffff;background:#9EC258;background:-webkit-radial-gradient(top, #00958f, #004D4A);background:-moz-radial-gradient(top, #00958f, #004D4A);background:radial-gradient(to bottom, #00958f, #004D4A);border:solid 2px #00958f}.Circle.Disabled{-webkit-animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;color:#f1f1f1;background:#D4D4D4;border:solid 2px #D4D4D4;cursor:default}.Circle.DisabledSelected{-webkit-animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;animation:selected-scaleUp 0.4s cubic-bezier(0.39, 0.575, 0.565, 1) both;color:#f1f1f1;background:#9EC258;background:-webkit-radial-gradient(top, #00958f, #004D4A);background:-moz-radial-gradient(top, #00958f, #004D4A);background:radial-gradient(to bottom, #00958f, #004D4A);border:solid 2px #D4D4D4;cursor:default}";
134
+
135
+ const LotteryBullet = class {
136
+ constructor(hostRef) {
137
+ index.registerInstance(this, hostRef);
138
+ this.bulletEvent = index.createEvent(this, "lotteryBulletSelection", 7);
139
+ /**
140
+ * Value of the bullet
141
+ */
142
+ this.value = '0';
143
+ /**
144
+ * Marks if the bullet should be selectable
145
+ */
146
+ this.selectable = true;
147
+ /**
148
+ * Marks if the bullet should be selected
149
+ */
150
+ this.isSelected = false;
151
+ /**
152
+ * Client custom styling via string
153
+ */
154
+ this.clientStyling = '';
155
+ /**
156
+ * Client custom styling via url content
157
+ */
158
+ this.clientStylingUrlContent = '';
159
+ this.limitStylingAppends = false;
160
+ this.select = () => {
161
+ if (this.selectable) {
162
+ this.isSelected = !this.isSelected;
163
+ this.bulletEvent.emit({
164
+ value: this.value,
165
+ selected: this.isSelected
166
+ });
167
+ }
168
+ };
169
+ this.setClientStyling = () => {
170
+ let sheet = document.createElement('style');
171
+ sheet.innerHTML = this.clientStyling;
172
+ this.stylingContainer.prepend(sheet);
173
+ };
174
+ this.setClientStylingURL = () => {
175
+ let cssFile = document.createElement('style');
176
+ setTimeout(() => {
177
+ cssFile.innerHTML = this.clientStylingUrlContent;
178
+ this.stylingContainer.prepend(cssFile);
179
+ }, 1);
180
+ };
181
+ }
182
+ componentDidRender() {
183
+ // start custom styling area
184
+ if (!this.limitStylingAppends && this.stylingContainer) {
185
+ if (this.clientStyling)
186
+ this.setClientStyling();
187
+ if (this.clientStylingUrlContent)
188
+ this.setClientStylingURL();
189
+ this.limitStylingAppends = true;
190
+ }
191
+ // end custom styling area
192
+ }
193
+ render() {
194
+ return (index.h("div", { class: 'Circle ' + (this.selectable ? '' : 'Disabled') + (this.isSelected ? 'Selected' : ''), onClick: () => this.select(), ref: el => this.stylingContainer = el }, this.value));
195
+ }
196
+ };
197
+ LotteryBullet.style = lotteryBulletCss;
198
+
199
+ const lotteryGridCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.GridContainer{display:flex;flex-direction:column;max-width:1200px}.Grid{margin-top:10px 0 10px 0;display:flex;flex-direction:row;flex-wrap:wrap;gap:20px}.Grid.TicketGrid{gap:5px}";
200
+
201
+ const LotteryGrid = class {
202
+ constructor(hostRef) {
203
+ index.registerInstance(this, hostRef);
204
+ this.gridFilledEvent = index.createEvent(this, "gridFilled", 7);
205
+ this.gridDirtyEvent = index.createEvent(this, "gridDirty", 7);
206
+ /**
207
+ * Number of bullets of grid
208
+ */
209
+ this.totalNumbers = 0;
210
+ /**
211
+ * Number of maximum bullets that can be selected
212
+ */
213
+ this.maximumAllowed = 0;
214
+ /**
215
+ * Minimum allowed of bullets
216
+ */
217
+ this.minimumAllowed = 1;
218
+ /**
219
+ * Allows the user to select numbers on the grid
220
+ */
221
+ this.selectable = true;
222
+ /**
223
+ * Numbers that should be showed as selected on the grid (as a string of those numbers e.g. '1,2,3,4,5,6')
224
+ */
225
+ this.selectedNumbers = '';
226
+ /**
227
+ * Show only selected numbers
228
+ */
229
+ this.displaySelected = false;
230
+ /**
231
+ * Language
232
+ */
233
+ this.language = 'en';
234
+ /**
235
+ * Personalize grid for ticket
236
+ */
237
+ this.gridType = '';
238
+ /**
239
+ * Client custom styling via string
240
+ */
241
+ this.clientStyling = '';
242
+ /**
243
+ * Client custom styling via url content
244
+ */
245
+ this.clientStylingUrlContent = '';
246
+ this.numbers = [];
247
+ this.limitStylingAppends = false;
248
+ this.selectedCounter = 0;
249
+ this.setClientStyling = () => {
250
+ let sheet = document.createElement('style');
251
+ sheet.innerHTML = this.clientStyling;
252
+ this.stylingContainer.prepend(sheet);
253
+ };
254
+ this.setClientStylingURL = () => {
255
+ let cssFile = document.createElement('style');
256
+ setTimeout(() => {
257
+ cssFile.innerHTML = this.clientStylingUrlContent;
258
+ this.stylingContainer.prepend(cssFile);
259
+ }, 1);
260
+ };
261
+ }
262
+ connectedCallback() {
263
+ let selected = [];
264
+ if (this.selectedNumbers.length > 0) {
265
+ selected = this.selectedNumbers.split(',');
266
+ this.selectedCounter = selected.length;
267
+ }
268
+ if (this.displaySelected) {
269
+ selected.forEach((item) => {
270
+ this.numbers.push({
271
+ number: item,
272
+ selected: true,
273
+ selectable: this.selectable
274
+ });
275
+ });
276
+ }
277
+ else {
278
+ [...Array(this.totalNumbers).keys()]
279
+ .map(number => (number + 1).toString())
280
+ .forEach((number) => {
281
+ this.numbers.push({
282
+ number,
283
+ selected: selected.indexOf(number) >= 0 ? true : false,
284
+ selectable: this.selectedCounter == this.maximumAllowed ? false : this.selectable
285
+ });
286
+ });
287
+ }
288
+ }
289
+ componentDidRender() {
290
+ // start custom styling area
291
+ if (!this.limitStylingAppends && this.stylingContainer) {
292
+ if (this.clientStyling)
293
+ this.setClientStyling();
294
+ if (this.clientStylingUrlContent)
295
+ this.setClientStylingURL();
296
+ this.limitStylingAppends = true;
297
+ }
298
+ // end custom styling area
299
+ }
300
+ // wrote this because the classic .sort(() => 0.5 - Math.random()) method yielded low entropy shuffles for some reason on certain devices
301
+ shuffleArray(array) {
302
+ const result = [];
303
+ while (array.length > 0) {
304
+ const randomIndex = Math.floor(Math.random() * (array.length));
305
+ result.push(array.splice(randomIndex, 1)[0]);
306
+ }
307
+ return result;
308
+ }
309
+ lotteryBulletSelectionHandler(event) {
310
+ this.numbers = this.numbers.map((item) => {
311
+ if (item.number == event.detail.value) {
312
+ return {
313
+ number: item.number,
314
+ selected: event.detail.selected,
315
+ selectable: item.selectable
316
+ };
317
+ }
318
+ return {
319
+ number: item.number,
320
+ selected: item.selected,
321
+ selectable: item.selectable
322
+ };
323
+ });
324
+ if (event.detail.selected) {
325
+ this.selectedCounter += 1;
326
+ if (this.selectedCounter == this.maximumAllowed) {
327
+ this.numbers = this.numbers.map((item) => {
328
+ return {
329
+ number: item.number,
330
+ selected: item.selected,
331
+ selectable: item.selected ? true : false
332
+ };
333
+ });
334
+ this.gridFilledEvent.emit({
335
+ id: this.ticketId,
336
+ index: this.gridIndex,
337
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
338
+ });
339
+ }
340
+ }
341
+ else {
342
+ if (this.selectedCounter == this.maximumAllowed) {
343
+ this.numbers = this.numbers.map((item) => {
344
+ return {
345
+ number: item.number,
346
+ selected: item.selected,
347
+ selectable: true
348
+ };
349
+ });
350
+ this.gridDirtyEvent.emit({
351
+ id: this.ticketId,
352
+ index: this.gridIndex,
353
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
354
+ });
355
+ }
356
+ this.selectedCounter -= 1;
357
+ }
358
+ }
359
+ async resetSelectionHandler(event) {
360
+ if (event.detail && event.detail == this.ticketId) {
361
+ this.selectedCounter = 0;
362
+ this.numbers = this.numbers.map((item) => {
363
+ return {
364
+ number: item.number,
365
+ selected: false,
366
+ selectable: this.selectable
367
+ };
368
+ });
369
+ this.gridDirtyEvent.emit({
370
+ id: this.ticketId,
371
+ index: this.gridIndex,
372
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
373
+ });
374
+ }
375
+ }
376
+ async autoSelectionHandler(event) {
377
+ if (event.detail && event.detail == this.ticketId) {
378
+ this.resetSelectionHandler(event);
379
+ let array = [...Array(this.totalNumbers).keys()]
380
+ .map(number => number + 1);
381
+ array = this.shuffleArray(array);
382
+ array = array.slice(0, this.minimumAllowed);
383
+ this.numbers = this.numbers.map((item) => {
384
+ return {
385
+ number: item.number,
386
+ selected: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
387
+ selectable: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
388
+ };
389
+ });
390
+ this.gridFilledEvent.emit({
391
+ id: this.ticketId,
392
+ index: this.gridIndex,
393
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
394
+ });
395
+ this.selectedCounter = this.maximumAllowed;
396
+ }
397
+ }
398
+ render() {
399
+ return (index.h("div", { class: "GridContainer", ref: el => this.stylingContainer = el }, index.h("div", { class: this.gridType === 'ticket' ? 'Grid TicketGrid' : 'Grid' }, this.numbers.map((item) => index.h("div", null, index.h("lottery-bullet", { value: item.number, selectable: item.selectable, "is-selected": item.selected, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }))))));
400
+ }
401
+ };
402
+ LotteryGrid.style = lotteryGridCss;
403
+
404
+ const DEFAULT_LANGUAGE$1 = 'en';
405
+ const SUPPORTED_LANGUAGES$1 = ['ro', 'en', 'hr'];
406
+ const TRANSLATIONS$1 = {
407
+ en: {
408
+ loading: 'Loading, please wait ...',
409
+ error: 'It was an error while trying to fetch the data',
410
+ grid: 'Grid',
411
+ multiplier: 'Multiplier',
412
+ numberOfDraws: 'Number of draws',
413
+ wagerPerDraw: 'Wager per draw',
414
+ resetButton: 'Reset',
415
+ autoButton: 'I feel lucky'
416
+ },
417
+ ro: {
418
+ loading: 'Se incarca, va rugam asteptati ...',
419
+ error: 'A fost o eroare in timp ce asteptam datele',
420
+ grid: 'Grid',
421
+ multiplier: 'Multiplicator',
422
+ numberOfDraws: 'Numarul de extrageri',
423
+ wagerPerDraw: 'Pariul per extragere',
424
+ resetButton: 'Reseteaza',
425
+ autoButton: 'Ma simt norocos'
426
+ },
427
+ fr: {
428
+ loading: 'Loading, please wait ...',
429
+ error: 'It was an error while trying to fetch the data',
430
+ grid: 'Grid',
431
+ multiplier: 'Multiplier',
432
+ numberOfDraws: 'Number of draws',
433
+ wagerPerDraw: 'Wager per draw',
434
+ resetButton: 'Reset',
435
+ autoButton: 'I feel lucky'
436
+ },
437
+ ar: {
438
+ loading: 'Loading, please wait ...',
439
+ error: 'It was an error while trying to fetch the data',
440
+ grid: 'Grid',
441
+ multiplier: 'Multiplier',
442
+ numberOfDraws: 'Number of draws',
443
+ wagerPerDraw: 'Wager per draw',
444
+ resetButton: 'Reset',
445
+ autoButton: 'I feel lucky'
446
+ },
447
+ hr: {
448
+ loading: 'Učitavanje, molimo pričekajte ...',
449
+ error: 'Došlo je do pogreške prilikom pokušaja dohvaćanja podataka',
450
+ grid: 'Tablica',
451
+ multiplier: 'Multiplikator',
452
+ numberOfDraws: 'Broj izvlačenja',
453
+ wagerPerDraw: 'Ulog po izvlačenju',
454
+ resetButton: 'Resetiraj',
455
+ autoButton: 'Osjećam se sretno'
456
+ }
457
+ };
458
+ const translate$1 = (key, customLang) => {
459
+ const lang = customLang;
460
+ return TRANSLATIONS$1[lang !== undefined && SUPPORTED_LANGUAGES$1.includes(lang) ? lang : DEFAULT_LANGUAGE$1][key];
461
+ };
462
+
463
+ const lotteryTicketCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.TicketTitle{font-size:16px;font-weight:bold}.ButtonContainer{display:flex;justify-content:flex-end}.Toggle{cursor:pointer;margin-top:20px;display:inline-block}.ToggleSwitch{display:inline-block;background:#707070;border-radius:16px;width:58px;height:24px;position:relative;vertical-align:middle;transition:background 0.25s}.ToggleSwitch:before,.ToggleSwitch:after{content:\"\"}.ToggleSwitch:before{display:block;background:linear-gradient(to bottom, #fff 0%, #F1F1F1 100%);border-radius:50%;box-shadow:0 0 0 1px rgba(0, 0, 0, 0.25);width:16px;height:16px;position:absolute;top:4px;left:4px;transition:left 0.25s}.Toggle:hover .ToggleSwitch:before{background:linear-gradient(to bottom, #fff 0%, #fff 100%);box-shadow:0 0 0 1px rgba(0, 0, 0, 0.5)}.ToggleCheckbox:checked+.ToggleSwitch{background:#00ABA4}.ToggleCheckbox:checked+.ToggleSwitch:before{left:38px}.ToggleCheckbox{position:absolute;visibility:hidden}.Label{margin-right:5px;position:relative;top:2px;font-size:14px;font-weight:lighter;color:#000}input[type=number]{-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none}.NumberInput,.WagerInput{margin-top:10px;display:inline-flex;align-items:center}.NumberInput,.NumberInput *{box-sizing:border-box}.NumberInput button{cursor:pointer;outline:none;-webkit-appearance:none;border:none;align-items:center;justify-content:center;height:20px;position:relative}.NumberInput button:after{display:inline-block;position:absolute;transform:translate(-50%, -50%) rotate(180deg);align-items:center;text-align:center}.NumberInput button.Plus:after{transform:translate(-50%, -50%) rotate(0deg);width:30px;display:inline-flex;align-items:center;text-align:center}.NumberInput input[type=number],.WagerInput input[type=number]{max-width:50px;display:inline-flex;align-items:center;padding:4px 10px;text-align:center}.NumberInput input[type=number] .WagerInputTitle,.WagerInput input[type=number] .WagerInputTitle{font-size:14px;color:#000;padding:10px}.InputDefault{background-color:#F1F1F1;border-radius:4px;padding:5px;border:solid 1px #D4D4D4;color:#707070}.AutoButton{cursor:pointer;display:inline-block;border-radius:4px;padding:8px 20px;width:max-content;margin:5px 0;border:1px solid #00958f;background:#FFF;color:#000;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.AutoButton:active{background:#00958f;color:#FFF}.ResetButton{cursor:pointer;display:inline-block;border-radius:4px;padding:8px 20px;width:max-content;margin:5px 0;color:#000;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0;background:#FF3D00;border:1px solid #FF3D00;color:#FFF}.ResetButton:hover{background:#FF6536;border:1px solid #FF3D00}.TicketGridBullets{background:#f1f1f1;border-radius:4px;padding:20px;margin-top:5px}.TicketGridBullets .TicketGridTitle{margin-top:0px}.Minus{border-radius:4px;width:30px;height:24px !important;margin-right:10px;color:#FFF;background:#009993}.Plus{border-radius:4px;width:30px;height:24px !important;margin-left:10px;color:#FFF;background:#009993}.SelectWrapper{width:auto;padding:5px;margin:0 auto;border:1px solid #ccc;border-radius:5px;position:relative}.SelectButton,.SelectOptions li{display:flex;align-items:center;cursor:pointer}.SelectButton{display:flex;padding:0 5px;border-radius:7px;align-items:center;justify-content:space-between;font-size:14px}.SelectButton span:first-child{padding-right:10px}.SelectExpand{transition:transform 0.3s linear;font-size:12px}.SelectActive .SelectExpand{transform:rotate(180deg)}.SelectContent{display:none;padding:5px;border-radius:7px}.SelectWrapper.SelectActive .SelectContent{width:100%;display:block;position:absolute;left:0;top:32px;padding:0;border:1px solid #ccc;overflow:hidden;background:#fff}.SelectContent .SelectOptions{max-height:100px;margin:0;overflow-y:auto;padding:0}.SelectContent .SelectOptions .SelectedValue{background-color:#009993;color:#fff}.SelectOptions::-webkit-scrollbar{width:7px}.SelectOptions::-webkit-scrollbar-track{background:#f1f1f1;border-radius:25px}.SelectOptions::-webkit-scrollbar-thumb{background:#ccc;border-radius:25px}.SelectOptions li{height:20px;padding:0 13px;font-size:14px}.SelectOptions li:hover{background:#f2f2f2}";
464
+
465
+ const LotteryTicket = class {
466
+ constructor(hostRef) {
467
+ index.registerInstance(this, hostRef);
468
+ this.ticketCompleted = index.createEvent(this, "ticketCompleted", 7);
469
+ this.autoSelection = index.createEvent(this, "autoSelection", 7);
470
+ this.resetSelection = index.createEvent(this, "resetSelection", 7);
471
+ this.stakeChange = index.createEvent(this, "stakeChange", 7);
472
+ this.multiplierChange = index.createEvent(this, "multiplierChange", 7);
473
+ /**
474
+ * Number of grids of a ticket
475
+ */
476
+ this.numberOfGrids = 1;
477
+ /**
478
+ * Option to have the ticket registered for multiple draws
479
+ */
480
+ this.multipleDraws = true;
481
+ /**
482
+ * Shows the reset button
483
+ */
484
+ this.resetButton = false;
485
+ /**
486
+ * Shows the auto-pick button
487
+ */
488
+ this.autoPick = false;
489
+ /**
490
+ * Language
491
+ */
492
+ this.language = 'en';
493
+ /**
494
+ * Client custom styling via string
495
+ */
496
+ this.clientStyling = '';
497
+ /**
498
+ * Client custom styling via url content
499
+ */
500
+ this.clientStylingUrlContent = '';
501
+ this.multiplier = false;
502
+ this.numberOfDraws = 1;
503
+ this.isLoading = true;
504
+ this.hasErrors = false;
505
+ this.ticketDone = false;
506
+ this.isCustomSelect = false;
507
+ this.amountInfo = {};
508
+ this.limitStylingAppends = false;
509
+ this.setClientStyling = () => {
510
+ let sheet = document.createElement('style');
511
+ sheet.innerHTML = this.clientStyling;
512
+ this.stylingContainer.prepend(sheet);
513
+ };
514
+ this.setClientStylingURL = () => {
515
+ let cssFile = document.createElement('style');
516
+ setTimeout(() => {
517
+ cssFile.innerHTML = this.clientStylingUrlContent;
518
+ this.stylingContainer.prepend(cssFile);
519
+ }, 1);
520
+ };
521
+ }
522
+ /**
523
+ * @TODO find a better way to implement click outside the custom select, so that we don't have to use the 'data-cluster' attribute on each element
524
+ */
525
+ checkForClickOutside(ev) {
526
+ if (ev.composedPath()[0].getAttribute('data-cluster') !== 'SelectComponent') {
527
+ this.isCustomSelect = false;
528
+ }
529
+ }
530
+ connectedCallback() {
531
+ let url = new URL(`${this.endpoint}/games/${this.gameId}`);
532
+ fetch(url.href)
533
+ .then((response) => {
534
+ if (response.ok) {
535
+ return response.json();
536
+ }
537
+ else {
538
+ // Throw error
539
+ this.hasErrors = true;
540
+ }
541
+ })
542
+ .then((data) => {
543
+ this.isLoading = false;
544
+ this.gameData = data;
545
+ this.grids = [...Array(this.gameData.type.boards.length).keys()];
546
+ this.amountInfo = this.gameData.type.stakes[0]; // initial value for select
547
+ })
548
+ .catch((err) => {
549
+ this.isLoading = false;
550
+ this.hasErrors = true;
551
+ console.error('Error!', err);
552
+ });
553
+ }
554
+ componentDidRender() {
555
+ // start custom styling area
556
+ if (!this.limitStylingAppends && this.stylingContainer) {
557
+ if (this.clientStyling)
558
+ this.setClientStyling();
559
+ if (this.clientStylingUrlContent)
560
+ this.setClientStylingURL();
561
+ this.limitStylingAppends = true;
562
+ }
563
+ // end custom styling area
564
+ }
565
+ multiplierChangeHandler(e) {
566
+ this.multiplier = e.target ? e.target.checked : false;
567
+ this.multiplierChange.emit(this.multiplier);
568
+ }
569
+ drawsChangeHandler(event) {
570
+ this.ticket = Object.assign(Object.assign({}, this.ticket), { draws: event });
571
+ this.ticketCompleted.emit(this.ticket);
572
+ }
573
+ gridFilledHandler(event) {
574
+ this.ticket = Object.assign(Object.assign({}, event.detail), { draws: this.numberOfDraws });
575
+ this.ticketDone = true;
576
+ this.ticketCompleted.emit(this.ticket);
577
+ }
578
+ toggleAutoSelection() {
579
+ this.ticketDone = true;
580
+ this.autoSelection.emit(this.ticketId);
581
+ }
582
+ toggleResetSelection() {
583
+ this.ticketDone = false;
584
+ this.resetSelection.emit(this.ticketId);
585
+ }
586
+ changeStake(ticketid, amount) {
587
+ this.stakeChange.emit({
588
+ ticketId: ticketid,
589
+ stake: amount
590
+ });
591
+ }
592
+ toggleClass() {
593
+ this.isCustomSelect = !this.isCustomSelect;
594
+ }
595
+ setDropdownItem(item) {
596
+ this.amountInfo = {
597
+ value: item.value,
598
+ currency: item.currency
599
+ };
600
+ this.isCustomSelect = false;
601
+ this.changeStake(this.ticketId, item.amount);
602
+ }
603
+ render() {
604
+ if (this.isLoading) {
605
+ return (index.h("div", null, index.h("p", null, translate$1('loading', this.language))));
606
+ }
607
+ else {
608
+ if (this.hasErrors) {
609
+ return (index.h("div", null, index.h("p", null, translate$1('error', this.language))));
610
+ }
611
+ else {
612
+ const { type } = this.gameData;
613
+ return (index.h("div", { class: "TicketContainer", ref: el => this.stylingContainer = el }, index.h("p", { class: "TicketTitle" }, this.gameData.name), this.resetButton && this.ticketDone &&
614
+ index.h("div", { class: "ButtonContainer" }, index.h("a", { class: "ResetButton", onClick: () => this.toggleResetSelection() }, translate$1('resetButton', this.language))), this.autoPick && !this.ticketDone &&
615
+ index.h("div", { class: "ButtonContainer" }, index.h("a", { class: "AutoButton", onClick: () => this.toggleAutoSelection() }, translate$1('autoButton', this.language))), this.grids.map((_, index$1) => index.h("div", { class: "TicketGridBullets" }, index.h("p", { class: "TicketGridTitle" }, translate$1('grid', this.language), " ", index$1 + 1), index.h("lottery-grid", { "grid-index": index$1, "maximum-allowed": type.boards[index$1].maximumAllowed, "minimum-allowed": type.boards[index$1].minimumAllowed, "total-numbers": type.boards[index$1].highNumber - type.boards[index$1].lowNumber + 1, selectable: true, "reset-button": true, "auto-pick": true, "game-id": this.gameId, "ticket-id": this.ticketId, language: this.language, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }))), type.multiplier &&
616
+ index.h("div", null, index.h("label", { class: "Toggle" }, index.h("label", { class: "Label" }, translate$1('multiplier', this.language), ": "), index.h("input", { class: "ToggleCheckbox", type: "checkbox", onInput: (e) => this.multiplierChangeHandler(e) }), index.h("div", { class: "ToggleSwitch" }))), this.multipleDraws &&
617
+ index.h("div", { class: "TicketDraws" }, index.h("label", { class: "Label" }, translate$1('numberOfDraws', this.language), ": "), index.h("div", { class: "NumberInput" }, index.h("button", { onClick: () => this.numberOfDraws > 1 ? this.numberOfDraws-- : this.numberOfDraws = 1, class: "Minus" }, "-"), index.h("input", { class: "InputDefault", min: "1", value: this.numberOfDraws, type: "number" }), index.h("button", { onClick: () => this.numberOfDraws++, class: "Plus" }, "+"))), index.h("div", null, index.h("label", { class: "Label" }, translate$1('wagerPerDraw', this.language), ": "), index.h("div", { class: "WagerInput" }, type.stakes.length > 1 ?
618
+ (index.h("div", { "data-cluster": "SelectComponent", class: this.isCustomSelect ? "SelectWrapper SelectActive" : "SelectWrapper" }, index.h("div", { "data-cluster": "SelectComponent", class: "SelectButton", onClick: () => this.toggleClass() }, index.h("span", { "data-cluster": "SelectComponent" }, this.amountInfo.value, " ", this.amountInfo.currency), index.h("span", { "data-cluster": "SelectComponent", class: "SelectExpand" }, "\u25BC")), index.h("div", { "data-cluster": "SelectComponent", class: "SelectContent" }, index.h("ul", { "data-cluster": "SelectComponent", class: "SelectOptions" }, type.stakes.map((item) => index.h("li", { "data-cluster": "SelectComponent", class: this.amountInfo.value == item.value ? 'SelectedValue' : '', value: item.value, onClick: () => this.setDropdownItem(item) }, item.value, " ", item.currency)))))) : (index.h("div", null, index.h("input", { min: "1", value: type.stakes[0].amount, type: "number", disabled: true }), index.h("p", { class: "WagerInputTitle" }, type.stakes[0].currency)))))));
619
+ }
620
+ }
621
+ }
622
+ static get watchers() { return {
623
+ "numberOfDraws": ["drawsChangeHandler"]
624
+ }; }
625
+ };
626
+ LotteryTicket.style = lotteryTicketCss;
627
+
628
+ const DEFAULT_LANGUAGE = 'en';
629
+ const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr'];
630
+ const TRANSLATIONS = {
631
+ en: {
632
+ ticket: 'Ticket',
633
+ },
634
+ ro: {
635
+ ticket: 'Bilet',
636
+ },
637
+ fr: {
638
+ ticket: 'Billet'
639
+ },
640
+ ar: {
641
+ ticket: 'تذكرة',
642
+ },
643
+ hr: {
644
+ ticket: 'Listić',
645
+ }
646
+ };
647
+ const translate = (key, customLang) => {
648
+ const lang = customLang;
649
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
650
+ };
651
+
652
+ const lotteryTicketControllerCss = ":host{font-family:\"Roboto\", system-ui, -apple-system, \"Segoe UI\", Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\";font-size:0.8rem}*,*::before,*::after{margin:0;padding:0;list-style:none;outline:none;box-sizing:border-box}input::-webkit-outer-spin-button,input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}input[type=number]{-moz-appearance:textfield}.player-account-gaming-limits-popup-2{background:var(--emfe-w-color-black, #000000);color:var(--emfe-w-color-white, #000)}.Title{font-weight:800;font-size:18px}button{display:block;font-size:0.75rem;padding:12px 0;border:0;border-radius:2px;cursor:pointer}button.PrimaryButtonStyle{font-size:14px;color:#fff;background:#7ac317}button.SecondaryButtonStyle{border:1px solid #999;color:#666;background:#fff}.LinkButton{display:inline;padding:0;color:#3366CC;text-decoration:underline;background-color:rgba(0, 0, 0, 0)}.ResultIconWrapper{display:flex;flex-direction:column;align-items:center;margin:12px 0}.ResultIconWrapper svg{height:auto;width:60px;margin:12px}.ResultIconWrapper p{color:#666}.Overlay{position:absolute;top:0;left:0;width:100vw;height:100vh;background-color:rgba(0, 0, 0, 0.5);display:flex;justify-content:center;align-items:center}.ModalContainer{position:fixed;top:30vh;width:320px;height:auto;padding:18px 14px;background:#fff;border-radius:4px}.InitialWrapper{display:flex;flex-direction:column;gap:12px}.AdditionalInformation{margin:10px 0;font-size:14px}.TermsConditions{font-size:12px}.ExpandButton{font-size:14px;background-color:#fff;border:0;padding:0;margin-top:-10px;color:#999;display:flex;justify-content:center;align-items:center;cursor:pointer}.ExpandButton svg{width:28px;height:auto;margin-left:-4px}.LeftAlign{text-align:left;font-size:16px}.CenterAlign{text-align:center}.SetLimitSection{display:flex;flex-direction:column;gap:6px}.DepositTextSection{display:flex;justify-content:space-between}.DepositInputSection{height:32px;display:flex;gap:4px}.DepositInput{flex-grow:1;padding:0 6px}.SubmitDepositButton{flex-grow:1;font-size:0.75rem;padding:0}.SubmitDepositButton[disabled]{align-items:center;color:#ccc;cursor:not-allowed;background:#fff;border:#ccc 1px solid}.Hidden{display:none}.Extended{transform:rotate(180deg)}";
653
+
654
+ const LotteryTicketController = class {
655
+ constructor(hostRef) {
656
+ index.registerInstance(this, hostRef);
657
+ this.deleteTicketEvent = index.createEvent(this, "deleteTicket", 7);
658
+ /**
659
+ * Endpoint URL for the source of data (NorWAy standard)
660
+ */
661
+ this.endpoint = '';
662
+ /**
663
+ * Ticket number
664
+ */
665
+ this.ticketId = 1;
666
+ /**
667
+ * Activates postMessages as events for actions from the widget
668
+ */
669
+ this.postMessage = false;
670
+ /**
671
+ * Name of the event emitter by the action button
672
+ */
673
+ this.eventName = 'deleteTicketAction';
674
+ /**
675
+ * Collapsed
676
+ */
677
+ this.collapsed = true;
678
+ /**
679
+ * Number of grids?
680
+ */
681
+ this.numberOfGrids = 1;
682
+ /**
683
+ * This toggles if the last ticket added should be expanded or not
684
+ */
685
+ this.last = false;
686
+ /**
687
+ * Language
688
+ */
689
+ this.language = 'en';
690
+ /**
691
+ * Shows the auto-pick button
692
+ */
693
+ this.autoPick = false;
694
+ /**
695
+ * Shows the reset button
696
+ */
697
+ this.resetButton = false;
698
+ /**
699
+ * Number of ticket controllers
700
+ */
701
+ this.totalControllers = 1;
702
+ /**
703
+ * Client custom styling via string
704
+ */
705
+ this.clientStyling = '';
706
+ /**
707
+ * Client custom styling via url content
708
+ */
709
+ this.clientStylingUrlContent = '';
710
+ this.limitStylingAppends = false;
711
+ this.setClientStyling = () => {
712
+ let sheet = document.createElement('style');
713
+ sheet.innerHTML = this.clientStyling;
714
+ this.stylingContainer.prepend(sheet);
715
+ };
716
+ this.setClientStylingURL = () => {
717
+ let cssFile = document.createElement('style');
718
+ setTimeout(() => {
719
+ cssFile.innerHTML = this.clientStylingUrlContent;
720
+ this.stylingContainer.prepend(cssFile);
721
+ }, 1);
722
+ };
723
+ }
724
+ // @TODO fix the `any` type
725
+ helperAccordionActionHandler() {
726
+ if (this.postMessage) {
727
+ window.postMessage({ type: this.eventName }, window.location.href);
728
+ }
729
+ this.deleteTicketEvent.emit({
730
+ ticketId: this.ticketId
731
+ });
732
+ }
733
+ componentDidRender() {
734
+ // start custom styling area
735
+ if (!this.limitStylingAppends && this.stylingContainer) {
736
+ if (this.clientStyling)
737
+ this.setClientStyling();
738
+ if (this.clientStylingUrlContent)
739
+ this.setClientStylingURL();
740
+ this.limitStylingAppends = true;
741
+ }
742
+ // end custom styling area
743
+ }
744
+ render() {
745
+ console.log('ticket id:', this.ticketId);
746
+ return (index.h("div", { class: "LotteryTicketControllerContainer", ref: el => this.stylingContainer = el }, index.h("helper-accordion", { "header-title": `${translate('ticket', this.language)} ${this.ticketId}`, "header-subtitle": this.ticketDescription, footer: true, "delete-tab": this.totalControllers !== 1, collapsed: !this.last || this.collapsed, language: this.language, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }, index.h("div", { slot: "accordionContent" }, index.h("lottery-ticket", { endpoint: this.endpoint, "game-id": this.gameId, "ticket-id": this.ticketId, "number-of-grids": this.numberOfGrids, language: this.language, "reset-button": this.resetButton, "auto-pick": this.autoPick, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent })))));
747
+ }
748
+ };
749
+ LotteryTicketController.style = lotteryTicketControllerCss;
750
+
751
+ exports.helper_accordion = Accordion;
752
+ exports.lottery_bullet = LotteryBullet;
753
+ exports.lottery_grid = LotteryGrid;
754
+ exports.lottery_ticket = LotteryTicket;
755
+ exports.lottery_ticket_controller = LotteryTicketController;