@everymatrix/lottery-game-page 0.1.26 → 1.0.69

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 (115) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/{helper-filters_2.cjs.entry.js → helper-accordion_13.cjs.entry.js} +13401 -9890
  3. package/dist/cjs/helper-pagination.cjs.entry.js +197 -189
  4. package/dist/cjs/index-f3851683.js +1345 -0
  5. package/dist/cjs/loader.cjs.js +7 -13
  6. package/dist/cjs/lottery-game-page.cjs.js +17 -11
  7. package/dist/collection/collection-manifest.json +4 -10
  8. package/dist/collection/components/lottery-game-page/index.js +1 -0
  9. package/dist/collection/components/lottery-game-page/lottery-game-page.css +11 -2
  10. package/dist/collection/components/lottery-game-page/lottery-game-page.js +579 -594
  11. package/dist/collection/utils/locale.utils.js +118 -95
  12. package/dist/collection/utils/utils.js +4 -4
  13. package/dist/esm/app-globals-0f993ce5.js +3 -0
  14. package/dist/esm/{helper-filters_2.entry.js → helper-accordion_13.entry.js} +13391 -9891
  15. package/dist/esm/helper-pagination.entry.js +197 -189
  16. package/dist/esm/index-8248702b.js +1316 -0
  17. package/dist/esm/loader.js +7 -13
  18. package/dist/esm/lottery-game-page.js +14 -11
  19. package/dist/lottery-game-page/lottery-game-page.esm.js +1 -1
  20. package/dist/lottery-game-page/p-46aaa562.entry.js +1 -0
  21. package/dist/lottery-game-page/p-8f2c63c7.js +2 -0
  22. package/dist/lottery-game-page/p-bd89bbf0.entry.js +3567 -0
  23. package/dist/lottery-game-page/p-e1255160.js +1 -0
  24. package/dist/stencil.config.dev.js +17 -0
  25. package/dist/stencil.config.js +12 -36
  26. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/lottery-game-page/.stencil/packages/stencil/lottery-game-page/stencil.config.d.ts +2 -0
  27. package/dist/types/Users/raul.vasile/workspace/everymatrix/widgets-monorepo/packages/stencil/lottery-game-page/.stencil/packages/stencil/lottery-game-page/stencil.config.dev.d.ts +2 -0
  28. package/dist/types/components/lottery-game-page/index.d.ts +1 -0
  29. package/dist/types/components/lottery-game-page/lottery-game-page.d.ts +99 -90
  30. package/dist/types/components.d.ts +28 -2
  31. package/dist/types/stencil-public-runtime.d.ts +142 -33
  32. package/loader/cdn.js +1 -3
  33. package/loader/index.cjs.js +1 -3
  34. package/loader/index.d.ts +13 -1
  35. package/loader/index.es2017.js +1 -3
  36. package/loader/index.js +1 -3
  37. package/loader/package.json +1 -0
  38. package/package.json +13 -7
  39. package/dist/cjs/helper-accordion.cjs.entry.js +0 -124
  40. package/dist/cjs/helper-modal.cjs.entry.js +0 -76
  41. package/dist/cjs/helper-tab.cjs.entry.js +0 -68
  42. package/dist/cjs/helper-tabs.cjs.entry.js +0 -74
  43. package/dist/cjs/index-cd44e726.js +0 -1324
  44. package/dist/cjs/lottery-bullet_2.cjs.entry.js +0 -270
  45. package/dist/cjs/lottery-draw-results-history.cjs.entry.js +0 -198
  46. package/dist/cjs/lottery-game-details.cjs.entry.js +0 -51
  47. package/dist/cjs/lottery-game-page.cjs.entry.js +0 -427
  48. package/dist/cjs/lottery-ticket-controller.cjs.entry.js +0 -116
  49. package/dist/cjs/lottery-ticket.cjs.entry.js +0 -201
  50. package/dist/collection/components/lottery-game-page/static/chrono_desktop.png +0 -0
  51. package/dist/collection/components/lottery-game-page/static/chrono_lottery_mobile.png +0 -0
  52. package/dist/components/assets/chrono_desktop.png +0 -0
  53. package/dist/components/assets/chrono_lottery_mobile.png +0 -0
  54. package/dist/components/helper-accordion.js +0 -6
  55. package/dist/components/helper-accordion2.js +0 -151
  56. package/dist/components/helper-filters.js +0 -6
  57. package/dist/components/helper-filters2.js +0 -22394
  58. package/dist/components/helper-modal.js +0 -6
  59. package/dist/components/helper-modal2.js +0 -94
  60. package/dist/components/helper-pagination.js +0 -251
  61. package/dist/components/helper-tab.js +0 -6
  62. package/dist/components/helper-tab2.js +0 -87
  63. package/dist/components/helper-tabs.js +0 -6
  64. package/dist/components/helper-tabs2.js +0 -103
  65. package/dist/components/index.d.ts +0 -26
  66. package/dist/components/index.js +0 -1
  67. package/dist/components/lottery-bullet.js +0 -6
  68. package/dist/components/lottery-bullet2.js +0 -92
  69. package/dist/components/lottery-draw-results-history.js +0 -6
  70. package/dist/components/lottery-draw-results-history2.js +0 -256
  71. package/dist/components/lottery-draw-results.js +0 -6
  72. package/dist/components/lottery-draw-results2.js +0 -335
  73. package/dist/components/lottery-game-details.js +0 -6
  74. package/dist/components/lottery-game-details2.js +0 -85
  75. package/dist/components/lottery-game-page.d.ts +0 -11
  76. package/dist/components/lottery-game-page.js +0 -542
  77. package/dist/components/lottery-grid.js +0 -6
  78. package/dist/components/lottery-grid2.js +0 -237
  79. package/dist/components/lottery-ticket-controller.js +0 -6
  80. package/dist/components/lottery-ticket-controller2.js +0 -168
  81. package/dist/components/lottery-ticket.js +0 -6
  82. package/dist/components/lottery-ticket2.js +0 -244
  83. package/dist/esm/helper-accordion.entry.js +0 -120
  84. package/dist/esm/helper-modal.entry.js +0 -72
  85. package/dist/esm/helper-tab.entry.js +0 -64
  86. package/dist/esm/helper-tabs.entry.js +0 -70
  87. package/dist/esm/index-d1baacd4.js +0 -1296
  88. package/dist/esm/lottery-bullet_2.entry.js +0 -265
  89. package/dist/esm/lottery-draw-results-history.entry.js +0 -194
  90. package/dist/esm/lottery-game-details.entry.js +0 -47
  91. package/dist/esm/lottery-game-page.entry.js +0 -423
  92. package/dist/esm/lottery-ticket-controller.entry.js +0 -112
  93. package/dist/esm/lottery-ticket.entry.js +0 -197
  94. package/dist/esm/polyfills/core-js.js +0 -11
  95. package/dist/esm/polyfills/css-shim.js +0 -1
  96. package/dist/esm/polyfills/dom.js +0 -79
  97. package/dist/esm/polyfills/es5-html-element.js +0 -1
  98. package/dist/esm/polyfills/index.js +0 -34
  99. package/dist/esm/polyfills/system.js +0 -6
  100. package/dist/lottery-game-page/p-023325a2.entry.js +0 -1
  101. package/dist/lottery-game-page/p-04fbc8fd.entry.js +0 -1
  102. package/dist/lottery-game-page/p-256b151c.entry.js +0 -1
  103. package/dist/lottery-game-page/p-381b5507.entry.js +0 -1
  104. package/dist/lottery-game-page/p-3f8b6ad9.entry.js +0 -1
  105. package/dist/lottery-game-page/p-4274053c.entry.js +0 -1
  106. package/dist/lottery-game-page/p-4f81cd37.entry.js +0 -1
  107. package/dist/lottery-game-page/p-5c389034.entry.js +0 -1
  108. package/dist/lottery-game-page/p-7d06371e.entry.js +0 -1
  109. package/dist/lottery-game-page/p-ca8430a0.entry.js +0 -2849
  110. package/dist/lottery-game-page/p-d6f76e8d.entry.js +0 -1
  111. package/dist/lottery-game-page/p-e765c7d9.js +0 -1
  112. package/dist/lottery-game-page/p-f6fcc22c.entry.js +0 -1
  113. package/dist/lottery-game-page/static/chrono_desktop.png +0 -0
  114. package/dist/lottery-game-page/static/chrono_lottery_mobile.png +0 -0
  115. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/lottery-game-page/.stencil/packages/lottery-game-page/stencil.config.d.ts +0 -2
@@ -1,427 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-cd44e726.js');
6
-
7
- const DEFAULT_LANGUAGE = 'en';
8
- const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar'];
9
- const TRANSLATIONS = {
10
- en: {
11
- error: 'Error',
12
- title: 'Chrono',
13
- backButton: 'Back',
14
- lobbyButton: 'Lobby',
15
- prize: 'Prize',
16
- winUpTo: 'Win up to',
17
- nextDraw: 'Next draw in: ',
18
- buy: 'Buy tickets',
19
- viewLatest: 'View latest results',
20
- createTicket: 'Create Ticket',
21
- modalSuccess: 'Purchase successfully completed!',
22
- deleteTicketModalTitle: 'Delete Ticket',
23
- deleteTicketModalText: 'Are you sure you want to delete this ticket?',
24
- deleteTicketModalCancel: 'Cancel',
25
- deleteTicketModalConfirm: 'Delete',
26
- orderSummaryTitle: 'Order Summary',
27
- orderSummaryTickets: 'Ticket',
28
- orderSummaryTotal: 'Total',
29
- orderSummarySubmit: 'Submit',
30
- lastDrawResultsTitle: 'Last Draw Results',
31
- modalLogin: 'Please login to submit a ticket',
32
- },
33
- ro: {
34
- error: 'Eroare',
35
- title: 'Loto 6/49',
36
- backButton: 'Inapoi',
37
- lobbyButton: 'Lobby',
38
- prize: 'MARELE JACKPOT OMG',
39
- winUpTo: 'Castiga pana la',
40
- nextDraw: 'Urmatoarea extragere:',
41
- buy: 'Cumpara bilet',
42
- viewLatest: 'Ultimile extrageri',
43
- createTicket: 'Creeaza bilet',
44
- modalSuccess: 'Achizitie efectuata cu succes',
45
- deleteTicketModalTitle: 'Sterge biletul',
46
- deleteTicketModalText: 'Esti sigur ca vrei sa stergi acest bilet?',
47
- deleteTicketModalCancel: 'Anuleaza',
48
- deleteTicketModalConfirm: 'Sterge',
49
- orderSummaryTitle: 'Rezumat comanda',
50
- orderSummaryTickets: 'Bilet',
51
- orderSummaryTotal: 'Total',
52
- orderSummarySubmit: 'Trimite',
53
- lastDrawResultsTitle: 'Cele mai recente extrageri',
54
- modalLogin: 'Please login to submit a ticket',
55
- },
56
- fr: {
57
- error: 'Error',
58
- title: 'Chrono',
59
- backButton: 'Back',
60
- lobbyButton: 'Lobby',
61
- prize: 'Prize',
62
- winUpTo: 'Win up to',
63
- nextDraw: 'Next draw in: ',
64
- buy: 'Buy tickets',
65
- viewLatest: 'View latest results',
66
- createTicket: 'Create Ticket',
67
- modalSuccess: 'Purchase successfully completed!',
68
- deleteTicketModalTitle: 'Delete Ticket',
69
- deleteTicketModalText: 'Are you sure you want to delete this ticket?',
70
- deleteTicketModalCancel: 'Cancel',
71
- deleteTicketModalConfirm: 'Delete',
72
- orderSummaryTitle: 'Order Summary',
73
- orderSummaryTickets: 'Ticket',
74
- orderSummaryTotal: 'Total',
75
- orderSummarySubmit: 'Submit',
76
- lastDrawResultsTitle: 'Résultats du dernier tirage',
77
- modalLogin: 'Please login to submit a ticket',
78
- },
79
- ar: {
80
- error: 'خطأ',
81
- title: 'كرونو',
82
- backButton: 'خلف',
83
- lobbyButton: 'ردهة',
84
- prize: 'جائزة',
85
- winUpTo: 'الفوز بما يصل الى',
86
- nextDraw: 'السحب التالي:',
87
- buy: 'اشتري تذاكر',
88
- viewLatest: 'عرض أحدث النتائج',
89
- createTicket: 'إنشاء تذكرة',
90
- modalSuccess: '!سيتم الشراء بنجاح قريبًا',
91
- deleteTicketModalTitle: 'حذف التذكرة',
92
- deleteTicketModalText: 'هل أنت متأكد أنك تريد حذف هذه التذكرة؟',
93
- deleteTicketModalCancel: 'يلغي',
94
- deleteTicketModalConfirm: 'حذف',
95
- orderSummaryTitle: 'ملخص الطلب',
96
- orderSummaryTickets: 'تذكرة',
97
- orderSummaryTotal: 'المجموع',
98
- orderSummarySubmit: 'يُقدِّم',
99
- lastDrawResultsTitle: 'نتائج آخر سحب',
100
- modalLogin: 'الرجاء تسجيل الدخول لتقديم تذكرة'
101
- }
102
- };
103
- const translate = (key, customLang) => {
104
- const lang = customLang;
105
- return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
106
- };
107
-
108
- /**
109
- * @name isMobile
110
- * @description A method that returns if the browser used to access the app is from a mobile device or not
111
- * @param {String} userAgent window.navigator.userAgent
112
- * @returns {Boolean} true or false
113
- */
114
- const isMobile = (userAgent) => {
115
- return !!(userAgent.toLowerCase().match(/android/i) ||
116
- userAgent.toLowerCase().match(/blackberry|bb/i) ||
117
- userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
118
- userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
119
- };
120
-
121
- const lotteryGamePageCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.GamePage .GridBanner{background-color:#009993;background-repeat:no-repeat;background-position:center;color:#111;padding:0 20px 10px;height:220px;display:flex;flex-direction:column;justify-content:space-between}.GamePage .GridBanner .BannerButtonsWrapper{display:flex;justify-content:space-between;padding-top:16px}.GamePage .GridBanner .BannerButtonsWrapper .BannerBackButton,.GamePage .GridBanner .BannerButtonsWrapper .BannerLobbyButton{background:#fff;border:1px solid #D4D4D4;border-radius:4px;padding:7px 15px;font-size:12px;text-transform:uppercase;width:80px}.GamePage .GridBanner .GridBannerArea{padding-top:30px;display:flex;flex-direction:column;align-items:center}.GamePage .TotalWinnings{color:#000;font-size:18px;display:flex;flex-direction:row;justify-content:center;align-items:center;gap:10px;text-transform:uppercase}.GamePage .TotalWinnings span{font-size:18px;font-weight:700}.GamePage .NextDraw{color:#00958f;font-size:24px;font-weight:600;margin:0 auto;text-align:center;text-transform:uppercase;display:flex;justify-content:center;align-items:center;flex-direction:column}.GamePage .NextDraw .BannerText{font-weight:400;font-size:18px;text-transform:uppercase;padding:0;margin:15px 0 0 0}.GamePage .NextDraw .BannerCountdown{font-size:22px;color:#00958f;display:flex;gap:20px}.GamePage .Tabs{display:flex;justify-content:center;gap:10px}.GamePage .Tabs .TabButton{border-radius:4px;cursor:pointer;padding:8px 0;width:50%;max-width:200px;border:1px solid #00958f;background:#00958f;color:#fff;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.GamePage .Tabs .TabButton.Active{color:#00958f;background:#F1F1F1;border:1px solid #F1F1F1}.LastDrawResultsTitle{color:#009993;padding:25px 0 10px 0;text-align:center;border-radius:4px;text-transform:uppercase;font-size:16px;font-weight:600;margin:0}.NextDrawWrapper{padding:10px 15px;background:#F1F1F1;background:linear-gradient(0deg, #f1f1f1 0%, rgba(253, 187, 45, 0) 100%)}.NextDrawWrapper .BannerText{font-size:16px;font-weight:700;text-align:center}.NextDrawWrapper .BannerCountdown{font-size:22px;display:flex;gap:8px;color:#009993;font-weight:bolder;justify-content:center}.GamePageContent{padding:15px;max-width:1200px;margin:0 auto}.GameDetails{padding-bottom:10px;margin-bottom:20px}.CreateNewTicket{background:#004D4A;height:100px;width:100%;display:flex;margin-top:10px;flex-direction:column;justify-content:center;align-items:center}.CreateNewTicket button{cursor:pointer;display:inline-block;border-radius:50%;width:40px;height:40px;margin:5px;border:1px solid #FFF;background:#FFF;color:#004D4A;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0}.CreateNewTicket button:hover{background:#F1F1F1}.CreateNewTicket span{display:inline-block;font-size:12px;text-align:center;margin:0 auto;color:#FFF}.OrderSummary{min-width:200px;border-radius:4px;display:flex;flex-direction:column;justify-content:center;margin-top:20px;background:#fff}.OrderSummary .OrderSummaryTitle{font-size:16px;color:#009993;text-transform:uppercase;text-align:center}.OrderSummary .Ticket{display:inline-block;color:#000;font-size:14px;height:50px;border-bottom:solid 1px #D4D4D4;line-height:50px}.OrderSummary .Ticket span{text-align:right}.OrderSummary .Total{display:inline-block;color:#000;font-size:14px;height:50px;line-height:50px}.OrderSummary .Total span{text-align:right}.ButtonWrapper{display:flex;align-items:center;justify-content:center}.ButtonWrapper .Button{cursor:pointer;border-radius:4px;padding:8px 60px;width:max-content;margin:5px;font-size:12px;transition:all 0.2s linear;text-transform:uppercase;text-align:center;letter-spacing:0;background:#009993;border:1px solid #009993;color:#FFF}.ButtonWrapper .Button:hover{background:#00ABA4}.ButtonWrapper .Button.ButtonDisabled{pointer-events:none;background:#ccc;border:1px solid #ccc}.SubmitModalSuccess{text-align:center;font-size:18px;padding:20px}.DeleteTicketModalWrapper{padding:20px;text-align:center}.DeleteTicketModalWrapper .DeleteTicketModalTitle{font-size:16px;color:#00958f;font-weight:400;text-transform:uppercase;margin:20px 0 40px}.DeleteTicketModalWrapper .DeleteTicketModalText{font-size:14px;color:#000;line-height:22px;margin-bottom:40px}.DeleteTicketModalWrapper .DeleteTicketModalButtons{display:flex;gap:10px;justify-content:center}.DeleteTicketModalWrapper .DeleteTicketModalButtons .DeleteTicketModalConfirm{cursor:pointer;border-radius:4px;padding:8px 25px;width:max-content;margin:5px;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}.DeleteTicketModalWrapper .DeleteTicketModalButtons .DeleteTicketModalConfirm:hover{background:#FF6536;border:1px solid #FF3D00}.DeleteTicketModalWrapper .DeleteTicketModalButtons .DeleteTicketModalCancel{cursor:pointer;width:max-content;border-radius:4px;padding:10px 25px;margin:5px;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}.DeleteTicketModalWrapper .DeleteTicketModalButtons .DeleteTicketModalCancel:hover{background:#F1F1F1}@media (min-width: 1200px){.GamePageContent .TicketsWrapper{float:left;width:49%}.GamePageContent .GameDetails{float:right;width:49%}.GamePageContent .OrderSummary{float:right;width:49%}}";
122
-
123
- const LotteryGamePage = class {
124
- constructor(hostRef) {
125
- index.registerInstance(this, hostRef);
126
- /**
127
- * Language of the widget
128
- */
129
- this.language = 'en';
130
- /**
131
- * Shows the auto-pick button
132
- */
133
- this.autoPick = false;
134
- /**
135
- * Shows the reset button
136
- */
137
- this.resetButton = false;
138
- /**
139
- * Client custom styling via string
140
- */
141
- this.clientStyling = '';
142
- /**
143
- * Client custom styling via url
144
- */
145
- this.clientStylingurl = '';
146
- this.clientStylingUrlContent = '';
147
- this.tickets = [];
148
- this.tabIndex = 0;
149
- this.hasErrors = false;
150
- this.totalAmount = 0;
151
- this.successVisible = false;
152
- this.deleteVisible = false;
153
- this.latestDraw = {};
154
- this.totalWinningsAmount = 0;
155
- this.isLoggedIn = false;
156
- this.loginModalVisible = false;
157
- this.limitStylingAppends = false;
158
- // @TODO fix any type
159
- this.userAgent = window.navigator.userAgent;
160
- this.multiplier = false;
161
- this.quickPick = false;
162
- this.setClientStyling = () => {
163
- let sheet = document.createElement('style');
164
- sheet.innerHTML = this.clientStyling;
165
- this.stylingContainer.prepend(sheet);
166
- };
167
- this.setClientStylingURL = () => {
168
- let url = new URL(this.clientStylingurl);
169
- let cssFile = document.createElement('style');
170
- fetch(url.href)
171
- .then((res) => res.text())
172
- .then((data) => {
173
- this.clientStylingUrlContent = data;
174
- cssFile.innerHTML = data;
175
- setTimeout(() => { this.stylingContainer.prepend(cssFile); }, 1);
176
- })
177
- .catch((err) => {
178
- console.log('error ', err);
179
- });
180
- };
181
- }
182
- // @TODO fix `any` type later, I'm lazy now
183
- handleSessionIdValue() {
184
- this.isLoggedIn = true;
185
- }
186
- connectedCallback() {
187
- this.getGameDetails();
188
- this.getDraws();
189
- if (this.sessionId) {
190
- this.isLoggedIn = true;
191
- }
192
- }
193
- componentDidRender() {
194
- // start custom styling area
195
- if (!this.limitStylingAppends && this.stylingContainer) {
196
- if (this.clientStyling)
197
- this.setClientStyling();
198
- if (this.clientStylingurl)
199
- this.setClientStylingURL();
200
- this.limitStylingAppends = true;
201
- }
202
- // end custom styling area
203
- }
204
- countdownLogic(date) {
205
- if (date) {
206
- this.interval = setInterval(() => {
207
- this.daysRemaining = Math.floor((Date.parse(date) - new Date().getTime()) / (1000 * 60 * 60 * 24));
208
- this.hoursRemaining = Math.floor((Date.parse(date) - new Date().getTime()) / (1000 * 60 * 60) - this.daysRemaining * 24);
209
- this.minutesRemaining = Math.floor((Date.parse(date) - new Date().getTime()) / (1000 * 60) - this.daysRemaining * 24 * 60 - this.hoursRemaining * 60);
210
- this.secondsRemaining = Math.floor((Date.parse(date) - new Date().getTime()) / 1000 - this.daysRemaining * 24 * 60 * 60 - this.hoursRemaining * 60 * 60 - this.minutesRemaining * 60);
211
- }, 1000);
212
- }
213
- }
214
- disconnectedCallback() {
215
- clearInterval(this.interval);
216
- }
217
- getGameDetails() {
218
- let url = new URL(`${this.endpoint}/games/${this.gameId}`);
219
- fetch(url.href)
220
- .then((res) => {
221
- if (res.status >= 300) {
222
- this.hasErrors = true;
223
- throw new Error('There was an error while fetching the data');
224
- }
225
- return res.json();
226
- })
227
- .then((data) => {
228
- this.gameData = data;
229
- this.basicStake = this.gameData.rules.stakes[0].amount;
230
- let draws = this.gameData.draws.filter((item) => !item.winningNumbers);
231
- this.nextDraw = draws[0].id;
232
- this.createNewTicket();
233
- })
234
- .catch((err) => {
235
- this.hasErrors = true;
236
- console.log('Error', err);
237
- });
238
- }
239
- calculateTotalAmount() {
240
- const { currency } = this.gameData.rules.stakes[0];
241
- this.totalAmount = 0;
242
- this.tickets.forEach((item) => {
243
- if (item.completed) {
244
- this.totalAmount += item.amount * item.stake;
245
- }
246
- });
247
- this.currency = currency;
248
- }
249
- // @TODO CustomEvent type
250
- gridFilledHandler(event) {
251
- // @TODO item ts
252
- this.tickets = this.tickets.map((item) => {
253
- if (item.ticketId == event.detail.id) {
254
- let arr = item.selectedNumbers || [];
255
- arr[event.detail.index] = event.detail.selectedNumbers.map((item) => parseInt(item, 10));
256
- return {
257
- gameId: item.gameId,
258
- ticketId: item.ticketId,
259
- completed: true,
260
- amount: event.detail.draws,
261
- stake: item.stake,
262
- selectedNumbers: arr
263
- };
264
- }
265
- return item;
266
- });
267
- this.calculateTotalAmount();
268
- }
269
- // @TODO fix any type
270
- gridDirtyHandler(event) {
271
- // @TODO item ts
272
- this.tickets = this.tickets.map((item) => {
273
- if (item.gameId == event.detail.id) {
274
- return {
275
- gameId: item.gameId,
276
- ticketId: item.ticketId,
277
- completed: false,
278
- amount: item.amount,
279
- stake: item.stake,
280
- grids: []
281
- };
282
- }
283
- return item;
284
- });
285
- }
286
- // @TODO CustomEvent type
287
- deleteTicketHandler(event) {
288
- this.deleteVisible = true;
289
- this.deleteEventData = event;
290
- }
291
- modalCloseEvent() {
292
- this.deleteVisible = false;
293
- this.loginModalVisible = false;
294
- }
295
- stakeChangeHandler(event) {
296
- const { ticketId, stake } = event.detail;
297
- this.tickets[ticketId - 1].stake = stake;
298
- this.calculateTotalAmount();
299
- }
300
- multiplierChangeHandler(event) {
301
- this.multiplier = event.detail;
302
- }
303
- getDraws() {
304
- // append from query param with the current date value in order to get the next draw
305
- let url = new URL(`${this.endpoint}/games/${this.gameId}/draws`);
306
- let drawOptions = {
307
- method: "GET",
308
- headers: {
309
- 'Content-Type': "application/json",
310
- 'Accept': 'application/json',
311
- },
312
- };
313
- fetch(url.href, drawOptions)
314
- .then((response) => {
315
- return response.json();
316
- })
317
- .then((data) => {
318
- var _a, _b;
319
- let upcoming = data.items.filter((item) => {
320
- if (Date.parse(item.date) > new Date().getTime()) {
321
- return !item.winningNumbers;
322
- }
323
- });
324
- let past = data.items.filter((item) => item.winningNumbers);
325
- this.latestDraw = upcoming[0] || {};
326
- this.nextDate = (_a = this.latestDraw) === null || _a === void 0 ? void 0 : _a.date;
327
- this.countdownLogic(this.nextDate || '');
328
- this.lastDrawId = past[past.length - 1].id;
329
- // calculate total winnings
330
- // @TODO fix any type
331
- (_b = this.latestDraw) === null || _b === void 0 ? void 0 : _b.prizes.forEach((element) => {
332
- this.totalWinningsAmount += JSON.parse(element.amount);
333
- });
334
- })
335
- .catch((err) => {
336
- console.log('error ', err);
337
- });
338
- }
339
- ;
340
- // @TODO fix any type
341
- confirmDeleteTicketHandler(event) {
342
- // @TODO fix any type
343
- this.tickets = this.tickets.filter((item) => {
344
- if (item.ticketId == event.detail.ticketId) {
345
- return false;
346
- }
347
- return true;
348
- });
349
- this.calculateTotalAmount();
350
- this.deleteVisible = false;
351
- }
352
- createNewTicket() {
353
- this.tickets = [
354
- ...this.tickets,
355
- { gameId: this.gameId, ticketId: this.tickets.length + 1, completed: false, amount: 1, stake: this.basicStake, grids: [] }
356
- ];
357
- }
358
- showLoginModal() {
359
- this.loginModalVisible = true;
360
- }
361
- submitTickets() {
362
- let url = new URL(`${this.endpoint}/tickets`);
363
- // @TODO Body TS type
364
- let body = {
365
- gameId: this.gameId,
366
- tickets: []
367
- };
368
- this.tickets.forEach((item) => {
369
- body.tickets.push({
370
- startingDrawId: this.nextDraw,
371
- amount: item.stake,
372
- gameId: this.gameId,
373
- currency: this.currency,
374
- selection: item.selectedNumbers,
375
- multiplier: this.multiplier,
376
- drawCount: item.amount,
377
- quickPick: this.quickPick,
378
- });
379
- });
380
- // @TODO Options TS type
381
- let options = {
382
- method: 'POST',
383
- headers: {
384
- 'Content-Type': 'application/json',
385
- 'Accept': 'application/json',
386
- 'Authorization': `Bearer ${this.sessionId}`
387
- },
388
- body: JSON.stringify(body)
389
- };
390
- fetch(url.href, options)
391
- .then((res) => {
392
- if (res.status > 300) {
393
- throw new Error('err');
394
- }
395
- return res.json();
396
- })
397
- .then((data) => {
398
- console.log('data', data);
399
- })
400
- .catch((err) => {
401
- console.log('error ', err);
402
- });
403
- this.successVisible = true;
404
- }
405
- render() {
406
- const backgroundSrc = index.getAssetPath('./static/chrono_lottery_mobile.png');
407
- const backgroundDesktopSrc = index.getAssetPath('./static/chrono_desktop.png');
408
- if (this.hasErrors) {
409
- return (index.h("div", { class: "GamePage" }, index.h("div", { class: "Title" }, translate('error', this.language))));
410
- }
411
- return (
412
- /* Game details */
413
- index.h("div", { class: "GamePage", dir: this.language == 'ar' ? 'rtl' : 'ltr', ref: el => this.stylingContainer = el }, index.h("div", { class: "GridBanner", style: { backgroundImage: isMobile(this.userAgent) ? `url(${backgroundSrc})` : `url(${backgroundDesktopSrc})` } }, index.h("div", { class: "BannerButtonsWrapper" }, index.h("button", { class: "BannerBackButton" }, index.h("span", { class: "BannerBackButtonArrow" }, "\u1438 "), translate('backButton', this.language)), index.h("button", { class: "BannerLobbyButton" }, translate('lobbyButton', this.language))), index.h("div", { class: "Tabs" }, index.h("div", { class: 'TabButton' + (this.tabIndex == 0 ? ' Active' : ''), onClick: () => this.tabIndex = 0 }, translate('buy', this.language)), index.h("div", { class: 'TabButton' + (this.tabIndex == 1 ? ' Active' : ''), onClick: () => this.tabIndex = 1 }, translate('viewLatest', this.language)))), index.h("div", { class: "NextDrawWrapper" }, index.h("div", { class: "TotalWinnings" }, translate('winUpTo', this.language), ": ", index.h("span", null, "$", this.totalWinningsAmount.toLocaleString('en-US', { maximumFractionDigits: 2 }))), index.h("div", { class: "NextDraw" }, index.h("p", { class: "BannerText" }, translate('nextDraw', this.language)), index.h("div", { class: "BannerCountdown" }, index.h("span", { class: "CountdownDays" }, this.daysRemaining, "D"), index.h("span", { class: "CountdownHours" }, this.hoursRemaining, "H"), index.h("span", { class: "CountdownMinutes" }, this.minutesRemaining, "M"), index.h("span", { class: "CountdownSeconds" }, this.secondsRemaining, "S")))), this.tabIndex == 0 &&
414
- index.h("div", { class: "GamePageContent" }, index.h("div", { class: "GameDetails" }, index.h("lottery-game-details", { "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent })), index.h("div", { class: "TicketsWrapper" }, this.tickets.map((item) => index.h("lottery-ticket-controller", { endpoint: this.endpoint, "ticket-id": item.ticketId, "game-id": item.gameId, collapsed: false, last: true, language: this.language, "auto-pick": this.autoPick, "reset-button": this.resetButton, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent })), index.h("div", { class: "CreateNewTicket" }, index.h("button", { onClick: () => this.createNewTicket() }, "+"), index.h("span", null, translate('createTicket', this.language)))), index.h("div", { class: "OrderSummary" }, index.h("h3", { class: "OrderSummaryTitle" }, translate('orderSummaryTitle', this.language)), index.h("div", { class: "Ticket" }, translate('orderSummaryTickets', this.language), ": ", index.h("span", null, this.tickets.length)), index.h("div", { class: "Total" }, translate('orderSummaryTotal', this.language), ": ", index.h("span", null, this.totalAmount, " ", this.currency)), index.h("div", { class: "ButtonWrapper" }, this.isLoggedIn &&
415
- index.h("span", { class: "Button", onClick: () => this.submitTickets() }, translate('orderSummarySubmit', this.language)), !this.isLoggedIn &&
416
- index.h("div", null, index.h("span", { class: "Button", onClick: () => this.showLoginModal() }, translate('orderSummarySubmit', this.language)), index.h("helper-modal", { "title-modal": "Success", visible: this.loginModalVisible, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }, index.h("p", { class: "SubmitModalSuccess" }, translate('modalLogin', this.language))))))), this.tabIndex == 1 &&
417
- index.h("div", null, index.h("h4", { class: "LastDrawResultsTitle" }, translate('lastDrawResultsTitle', this.language)), index.h("lottery-draw-results", { endpoint: this.endpoint, "game-id": this.gameId, language: this.language, "draw-id": this.lastDrawId, "draw-mode": true, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }), index.h("lottery-draw-results-history", { endpoint: this.endpoint, "game-id": this.gameId, language: this.language, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent })), index.h("helper-modal", { "title-modal": "Success", visible: this.successVisible, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }, index.h("p", { class: "SubmitModalSuccess" }, translate('modalSuccess', this.language))), index.h("helper-modal", { "title-modal": "Delete Ticket", visible: this.deleteVisible, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }, index.h("div", { class: "DeleteTicketModalWrapper" }, index.h("h3", { class: "DeleteTicketModalTitle" }, translate('deleteTicketModalTitle', this.language)), index.h("p", { class: "DeleteTicketModalText" }, translate('deleteTicketModalText', this.language)), index.h("div", { class: "DeleteTicketModalButtons" }, index.h("button", { class: "DeleteTicketModalCancel", onClick: () => this.modalCloseEvent() }, translate('deleteTicketModalCancel', this.language)), index.h("button", { class: "DeleteTicketModalConfirm", onClick: () => this.confirmDeleteTicketHandler(this.deleteEventData) }, translate('deleteTicketModalConfirm', this.language)))))));
418
- }
419
- static get assetsDirs() { return ["static"]; }
420
- get element() { return index.getElement(this); }
421
- static get watchers() { return {
422
- "sessionId": ["handleSessionIdValue"]
423
- }; }
424
- };
425
- LotteryGamePage.style = lotteryGamePageCss;
426
-
427
- exports.lottery_game_page = LotteryGamePage;
@@ -1,116 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-cd44e726.js');
6
-
7
- const DEFAULT_LANGUAGE = 'en';
8
- const SUPPORTED_LANGUAGES = ['ro', 'en'];
9
- const TRANSLATIONS = {
10
- en: {
11
- ticket: 'Ticket',
12
- },
13
- ro: {
14
- ticket: 'Bilet',
15
- },
16
- };
17
- const translate = (key, customLang) => {
18
- const lang = customLang;
19
- return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
20
- };
21
-
22
- const lotteryTicketControllerCss = ":host{display:block}";
23
-
24
- const LotteryTicketController = class {
25
- constructor(hostRef) {
26
- index.registerInstance(this, hostRef);
27
- this.deleteTicketEvent = index.createEvent(this, "deleteTicket", 7);
28
- /**
29
- * Endpoint URL for the source of data (NorWAy standard)
30
- */
31
- this.endpoint = '';
32
- /**
33
- * Ticket number
34
- */
35
- this.ticketId = 1;
36
- /**
37
- * Activates postMessages as events for actions from the widget
38
- */
39
- this.postMessage = false;
40
- /**
41
- * Name of the event emitter by the action button
42
- */
43
- this.eventName = 'deleteTicketAction';
44
- /**
45
- * Collapsed
46
- */
47
- this.collapsed = true;
48
- /**
49
- * Number of grids?
50
- */
51
- this.numberOfGrids = 1;
52
- /**
53
- * This toggles if the last ticket added should be expanded or not
54
- */
55
- this.last = false;
56
- /**
57
- * Language
58
- */
59
- this.language = 'en';
60
- /**
61
- * Shows the auto-pick button
62
- */
63
- this.autoPick = false;
64
- /**
65
- * Shows the reset button
66
- */
67
- this.resetButton = false;
68
- /**
69
- * Client custom styling via string
70
- */
71
- this.clientStyling = '';
72
- /**
73
- * Client custom styling via url content
74
- */
75
- this.clientStylingUrlContent = '';
76
- this.limitStylingAppends = false;
77
- this.setClientStyling = () => {
78
- let sheet = document.createElement('style');
79
- sheet.innerHTML = this.clientStyling;
80
- this.stylingContainer.prepend(sheet);
81
- };
82
- this.setClientStylingURL = () => {
83
- let cssFile = document.createElement('style');
84
- setTimeout(() => {
85
- cssFile.innerHTML = this.clientStylingUrlContent;
86
- this.stylingContainer.prepend(cssFile);
87
- }, 1);
88
- };
89
- }
90
- // @TODO fix the `any` type
91
- helperAccordionActionHandler() {
92
- if (this.postMessage) {
93
- window.postMessage({ type: this.eventName }, window.location.href);
94
- }
95
- this.deleteTicketEvent.emit({
96
- ticketId: this.ticketId
97
- });
98
- }
99
- componentDidRender() {
100
- // start custom styling area
101
- if (!this.limitStylingAppends && this.stylingContainer) {
102
- if (this.clientStyling)
103
- this.setClientStyling();
104
- if (this.clientStylingUrlContent)
105
- this.setClientStylingURL();
106
- this.limitStylingAppends = true;
107
- }
108
- // end custom styling area
109
- }
110
- render() {
111
- 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": true, 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 })))));
112
- }
113
- };
114
- LotteryTicketController.style = lotteryTicketControllerCss;
115
-
116
- exports.lottery_ticket_controller = LotteryTicketController;