@everymatrix/lottery-draw-results 0.1.6 → 0.1.20

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 (28) hide show
  1. package/dist/cjs/{index-33a98fae.js → index-43800d3c.js} +90 -1
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/lottery-bullet_3.cjs.entry.js +478 -0
  4. package/dist/cjs/lottery-draw-results.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +12 -5
  6. package/dist/collection/components/lottery-draw-results/lottery-draw-results.css +36 -13
  7. package/dist/collection/components/lottery-draw-results/lottery-draw-results.js +261 -100
  8. package/dist/collection/utils/locale.utils.js +4 -4
  9. package/dist/components/lottery-bullet.js +6 -0
  10. package/dist/components/lottery-bullet2.js +56 -0
  11. package/dist/components/lottery-draw-results.js +131 -18
  12. package/dist/components/lottery-grid.js +6 -0
  13. package/dist/components/lottery-grid2.js +196 -0
  14. package/dist/esm/{index-c6e6b7f8.js → index-9547eb6c.js} +90 -2
  15. package/dist/esm/loader.js +2 -2
  16. package/dist/esm/lottery-bullet_3.entry.js +472 -0
  17. package/dist/esm/lottery-draw-results.js +2 -2
  18. package/dist/lottery-draw-results/lottery-draw-results.esm.js +1 -1
  19. package/dist/lottery-draw-results/p-9678a673.entry.js +1 -0
  20. package/dist/lottery-draw-results/p-e1cb3144.js +1 -0
  21. package/dist/stencil.config.js +0 -3
  22. package/dist/types/components/lottery-draw-results/lottery-draw-results.d.ts +27 -3
  23. package/dist/types/components.d.ts +32 -0
  24. package/package.json +5 -2
  25. package/dist/cjs/lottery-draw-results.cjs.entry.js +0 -188
  26. package/dist/esm/lottery-draw-results.entry.js +0 -184
  27. package/dist/lottery-draw-results/p-31e0953f.js +0 -1
  28. package/dist/lottery-draw-results/p-d7361a7b.entry.js +0 -1
@@ -47,6 +47,40 @@ const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
47
47
  return false;
48
48
  })()
49
49
  ;
50
+ const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
51
+ if (listeners) {
52
+ listeners.map(([flags, name, method]) => {
53
+ const target = getHostListenerTarget(elm, flags) ;
54
+ const handler = hostListenerProxy(hostRef, method);
55
+ const opts = hostListenerOpts(flags);
56
+ plt.ael(target, name, handler, opts);
57
+ (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
58
+ });
59
+ }
60
+ };
61
+ const hostListenerProxy = (hostRef, methodName) => (ev) => {
62
+ try {
63
+ {
64
+ if (hostRef.$flags$ & 256 /* isListenReady */) {
65
+ // instance is ready, let's call it's member method for this event
66
+ hostRef.$lazyInstance$[methodName](ev);
67
+ }
68
+ else {
69
+ (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
70
+ }
71
+ }
72
+ }
73
+ catch (e) {
74
+ consoleError(e);
75
+ }
76
+ };
77
+ const getHostListenerTarget = (elm, flags) => {
78
+ if (flags & 4 /* TargetDocument */)
79
+ return doc;
80
+ return elm;
81
+ };
82
+ // prettier-ignore
83
+ const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
50
84
  const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
51
85
  const createTime = (fnName, tagName = '') => {
52
86
  {
@@ -234,6 +268,12 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
234
268
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
235
269
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
236
270
  }
271
+ else if (memberName === 'ref') {
272
+ // minifier will clean this up
273
+ if (newValue) {
274
+ newValue(elm);
275
+ }
276
+ }
237
277
  else if ((!isProp ) &&
238
278
  memberName[0] === 'o' &&
239
279
  memberName[1] === 'n') {
@@ -390,6 +430,7 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
390
430
  for (; startIdx <= endIdx; ++startIdx) {
391
431
  if ((vnode = vnodes[startIdx])) {
392
432
  elm = vnode.$elm$;
433
+ callNodeRefs(vnode);
393
434
  // remove the vnode's element from the dom
394
435
  elm.remove();
395
436
  }
@@ -508,6 +549,12 @@ const patch = (oldVNode, newVNode) => {
508
549
  elm.data = text;
509
550
  }
510
551
  };
552
+ const callNodeRefs = (vNode) => {
553
+ {
554
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
555
+ vNode.$children$ && vNode.$children$.map(callNodeRefs);
556
+ }
557
+ };
511
558
  const renderVdom = (hostRef, renderFnResults) => {
512
559
  const hostElm = hostRef.$hostElement$;
513
560
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
@@ -523,6 +570,20 @@ const renderVdom = (hostRef, renderFnResults) => {
523
570
  // synchronous patch
524
571
  patch(oldVNode, rootVnode);
525
572
  };
573
+ const getElement = (ref) => (getHostRef(ref).$hostElement$ );
574
+ const createEvent = (ref, name, flags) => {
575
+ const elm = getElement(ref);
576
+ return {
577
+ emit: (detail) => {
578
+ return emitEvent(elm, name, {
579
+ bubbles: !!(flags & 4 /* Bubbles */),
580
+ composed: !!(flags & 2 /* Composed */),
581
+ cancelable: !!(flags & 1 /* Cancellable */),
582
+ detail,
583
+ });
584
+ },
585
+ };
586
+ };
526
587
  /**
527
588
  * Helper function to create & dispatch a custom Event on a provided target
528
589
  * @param elm the target of the Event
@@ -559,6 +620,15 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
559
620
  const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
560
621
  const instance = hostRef.$lazyInstance$ ;
561
622
  let promise;
623
+ if (isInitialLoad) {
624
+ {
625
+ hostRef.$flags$ |= 256 /* isListenReady */;
626
+ if (hostRef.$queuedListeners$) {
627
+ hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
628
+ hostRef.$queuedListeners$ = null;
629
+ }
630
+ }
631
+ }
562
632
  endSchedule();
563
633
  return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
564
634
  };
@@ -626,7 +696,11 @@ const postUpdateComponent = (hostRef) => {
626
696
  const tagName = hostRef.$cmpMeta$.$tagName$;
627
697
  const elm = hostRef.$hostElement$;
628
698
  const endPostUpdate = createTime('postUpdate', tagName);
699
+ const instance = hostRef.$lazyInstance$ ;
629
700
  const ancestorComponent = hostRef.$ancestorComponent$;
701
+ {
702
+ safeCall(instance, 'componentDidRender');
703
+ }
630
704
  if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
631
705
  hostRef.$flags$ |= 64 /* hasLoadedComponent */;
632
706
  {
@@ -960,6 +1034,10 @@ const connectedCallback = (elm) => {
960
1034
  }
961
1035
  }
962
1036
  else {
1037
+ // not the first time this has connected
1038
+ // reattach any event listeners to the host
1039
+ // since they would have been removed when disconnected
1040
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
963
1041
  // fire off connectedCallback() on component instance
964
1042
  fireConnectedCallback(hostRef.$lazyInstance$);
965
1043
  }
@@ -968,7 +1046,13 @@ const connectedCallback = (elm) => {
968
1046
  };
969
1047
  const disconnectedCallback = (elm) => {
970
1048
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
971
- getHostRef(elm);
1049
+ const hostRef = getHostRef(elm);
1050
+ {
1051
+ if (hostRef.$rmListeners$) {
1052
+ hostRef.$rmListeners$.map((rmListener) => rmListener());
1053
+ hostRef.$rmListeners$ = undefined;
1054
+ }
1055
+ }
972
1056
  }
973
1057
  };
974
1058
  const bootstrapLazy = (lazyBundles, options = {}) => {
@@ -995,6 +1079,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
995
1079
  {
996
1080
  cmpMeta.$members$ = compactMeta[2];
997
1081
  }
1082
+ {
1083
+ cmpMeta.$listeners$ = compactMeta[3];
1084
+ }
998
1085
  const tagName = cmpMeta.$tagName$;
999
1086
  const HostElement = class extends HTMLElement {
1000
1087
  // StencilLazyHost
@@ -1075,6 +1162,7 @@ const registerHost = (elm, cmpMeta) => {
1075
1162
  elm['s-p'] = [];
1076
1163
  elm['s-rc'] = [];
1077
1164
  }
1165
+ addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
1078
1166
  return hostRefs.set(elm, hostRef);
1079
1167
  };
1080
1168
  const isMemberInElement = (elm, memberName) => memberName in elm;
@@ -1144,6 +1232,7 @@ const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
1144
1232
  const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
1145
1233
 
1146
1234
  exports.bootstrapLazy = bootstrapLazy;
1235
+ exports.createEvent = createEvent;
1147
1236
  exports.h = h;
1148
1237
  exports.promiseResolve = promiseResolve;
1149
1238
  exports.registerInstance = registerInstance;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-33a98fae.js');
5
+ const index = require('./index-43800d3c.js');
6
6
 
7
7
  /*
8
8
  Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["lottery-draw-results.cjs",[[1,"lottery-draw-results",{"endpoint":[1],"gameId":[1,"game-id"],"language":[1],"playerId":[1,"player-id"],"drawMode":[4,"draw-mode"],"drawId":[1,"draw-id"],"gameName":[1,"game-name"],"ticketDate":[1,"ticket-date"],"ticketStatus":[1,"ticket-status"],"ticketId":[1,"ticket-id"],"ticketAmount":[1,"ticket-amount"],"ticketMultiplier":[4,"ticket-multiplier"],"ticketDrawCount":[2,"ticket-draw-count"],"multiplier":[32],"isLoading":[32],"drawResults":[32],"rules":[32],"toggleDrawer":[32],"hasErrors":[32],"errorText":[32]}]]]], options);
17
+ return index.bootstrapLazy([["lottery-bullet_3.cjs",[[1,"lottery-draw-results",{"endpoint":[1],"gameId":[1,"game-id"],"language":[1],"playerId":[1,"player-id"],"drawMode":[4,"draw-mode"],"drawId":[1,"draw-id"],"gameName":[1,"game-name"],"ticketDate":[1,"ticket-date"],"ticketStatus":[1,"ticket-status"],"ticketId":[1,"ticket-id"],"ticketAmount":[1,"ticket-amount"],"ticketMultiplier":[4,"ticket-multiplier"],"ticketDrawCount":[2,"ticket-draw-count"],"ticketNumbers":[1,"ticket-numbers"],"sessionId":[1,"session-id"],"clientStyling":[1,"client-styling"],"clientStylingUrlContent":[1,"client-styling-url-content"],"multiplier":[32],"isLoading":[32],"rules":[32],"toggleDrawer":[32],"hasErrors":[32],"errorText":[32],"ticketData":[32],"ticketDataLoaded":[32],"ticketDraws":[32],"hasDrawNumbers":[32],"limitStylingAppends":[32]}],[1,"lottery-grid",{"ticketId":[2,"ticket-id"],"totalNumbers":[2,"total-numbers"],"gameId":[1,"game-id"],"maximumAllowed":[2,"maximum-allowed"],"minimumAllowed":[2,"minimum-allowed"],"selectable":[4],"selectedNumbers":[1,"selected-numbers"],"displaySelected":[4,"display-selected"],"language":[1],"gridIndex":[2,"grid-index"],"numbers":[32]},[[0,"lotteryBulletSelection","lotteryBulletSelectionHandler"],[4,"resetSelection","resetSelectionHandler"],[4,"autoSelection","autoSelectionHandler"]]],[1,"lottery-bullet",{"value":[1],"selectable":[4],"isSelected":[4,"is-selected"]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -0,0 +1,478 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-43800d3c.js');
6
+
7
+ 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}";
8
+
9
+ const LotteryBullet = class {
10
+ constructor(hostRef) {
11
+ index.registerInstance(this, hostRef);
12
+ this.bulletEvent = index.createEvent(this, "lotteryBulletSelection", 7);
13
+ /**
14
+ * Value of the bullet
15
+ */
16
+ this.value = '0';
17
+ /**
18
+ * Marks if the bullet should be selectable
19
+ */
20
+ this.selectable = true;
21
+ /**
22
+ * Marks if the bullet should be selected
23
+ */
24
+ this.isSelected = false;
25
+ this.select = () => {
26
+ if (this.selectable) {
27
+ this.isSelected = !this.isSelected;
28
+ this.bulletEvent.emit({
29
+ value: this.value,
30
+ selected: this.isSelected
31
+ });
32
+ }
33
+ };
34
+ }
35
+ render() {
36
+ return (index.h("div", { class: 'Circle ' + (this.selectable ? '' : 'Disabled') + (this.isSelected ? 'Selected' : ''), onClick: () => this.select() }, this.value));
37
+ }
38
+ };
39
+ LotteryBullet.style = lotteryBulletCss;
40
+
41
+ const DEFAULT_LANGUAGE = 'en';
42
+ const SUPPORTED_LANGUAGES = ['ro', 'en'];
43
+ const TRANSLATIONS = {
44
+ en: {
45
+ drawResultsHeader: 'Last draw results',
46
+ drawId: 'Draw ID',
47
+ drawName: 'Game name',
48
+ drawDate: 'Draw Date',
49
+ drawNumbersGridDraw: 'Draw numbers Grid ',
50
+ drawNumbersGridTicket: 'Draw numbers Grid ',
51
+ ticketResult: 'Ticket result',
52
+ amountWon: 'Amount won',
53
+ numberOfDraws: 'Number of draws',
54
+ multiplier: 'Multiplier:',
55
+ ticketPurchaseDate: 'Ticket Purchase Date',
56
+ ticketStatus: 'Ticket Status',
57
+ ticketId: 'Ticket ID',
58
+ ticketAmount: 'Ticket Amount',
59
+ winUpTo: 'Win up to',
60
+ },
61
+ ro: {
62
+ drawResultsHeader: 'Ultimele rezultate extragere',
63
+ drawId: 'Id extragere',
64
+ drawName: 'Numele jocului',
65
+ drawDate: 'Data extragerii',
66
+ drawNumbersGridDraw: 'Numerele extrase Grid',
67
+ drawNumbersGridTicket: 'Numerele extrase Grid',
68
+ ticketResult: 'Rezultatul biletului',
69
+ amountWon: 'Suma castigata',
70
+ numberOfDraws: 'Numarul de extrageri',
71
+ multiplier: 'Multiplicator:',
72
+ ticketPurchaseDate: 'Data achizitionarii biletului',
73
+ ticketStatus: 'Statusul biletului',
74
+ ticketId: 'Id biletul',
75
+ ticketAmount: 'Valoarea biletului',
76
+ winUpTo: 'Poti castiga'
77
+ },
78
+ };
79
+ const translate = (key, customLang) => {
80
+ const lang = customLang;
81
+ return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
82
+ };
83
+
84
+ const lotteryDrawResultsCss = "@import url(\"https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap\");:host{display:block;font-family:\"Roboto\", sans-serif}.TicketInfo{display:flex;flex-direction:row;gap:15px;background-color:#009993;color:#fff;padding:12px;font-size:14px}.DrawResultsArea{margin-top:15px}.DrawResultsArea.TicketDraws .Content{padding:0;border:0}.DrawResultsArea.TicketDraws .DrawResultsBody{padding:0;margin-bottom:5px;border-radius:0;border:0}.DrawResultsSection{max-width:600px;margin:0px auto;border-radius:4px}.DrawResultsHeader{display:flex;justify-content:space-between;padding:10px 20px;background-color:#009993;color:#fff;font-size:14px;border-radius:4px 4px 0 0}.DrawResultsHeader h4{text-transform:uppercase;font-weight:400;margin:0;padding-top:15px}.DrawResultsBody{padding:20px;margin-bottom:5px;border-radius:0 0 4px 4px;border:1px solid #009993}.DrawResultsBody>div{margin:10px 0}.DrawResultsBody .NumberOfDrawsContainer{display:table;width:100%}.DrawNumbersGrid{margin-bottom:15px}.DrawNumbersGrid label{display:block;margin-bottom:10px}.Toggle{cursor:pointer;display:inline-block}.ToggleSwitch{display:inline-block;background:#ccc;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%, #eee 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:#56c080}.ToggleCheckbox:checked+.ToggleSwitch:before{left:38px}.ToggleCheckbox{position:absolute;visibility:hidden}.Label{position:relative}.DrawTicketsContainer{display:flex;flex-direction:column;margin:20px auto 0}.DrawMultipler{margin-top:15px}.ExpandableBoxes{position:relative;display:flex;flex-direction:column}.ExpandableBox{line-height:12px;font-weight:lighter;width:100%;height:100%;max-height:80px;float:left;margin:0 0 20px 0;border:1px solid #009993;background:#fff;border-radius:4px;padding:10px;box-sizing:border-box;-webkit-transition:all 0.6s ease-in-out;-moz-transition:all 0.6s ease-in-out;-o-transition:all 0.6s ease-in-out;-ms-transition:all 0.6s ease-in-out;transition:all 0.6s ease-in-out;overflow:hidden;box-shadow:rgba(99, 99, 99, 0.2) 0px 2px 8px 0px}.ExpandableBox:last-of-type{margin-bottom:0}.ExpandableBox.ShowBox{max-height:400px;margin:0px 0px 20p 0px}.ExpandableBox.HideBox{width:0;height:0;overflow:hidden;border:none;padding:0;margin:0;opacity:0}";
85
+
86
+ const LotteryDrawResults = class {
87
+ constructor(hostRef) {
88
+ index.registerInstance(this, hostRef);
89
+ /**
90
+ * Language of the widget
91
+ */
92
+ this.language = 'en';
93
+ /**
94
+ * Shows only the last draw
95
+ */
96
+ this.drawMode = false;
97
+ /**
98
+ * The drawID (option)
99
+ */
100
+ this.drawId = '';
101
+ /**
102
+ * The game name
103
+ */
104
+ this.gameName = '';
105
+ /**
106
+ * The ticket submission date
107
+ */
108
+ this.ticketDate = '';
109
+ /**
110
+ * The ticket status
111
+ */
112
+ this.ticketStatus = '';
113
+ /**
114
+ * The ticket id
115
+ */
116
+ this.ticketId = '';
117
+ /**
118
+ * The ticket amount
119
+ */
120
+ this.ticketAmount = '';
121
+ /**
122
+ * The ticket multiplier
123
+ */
124
+ this.ticketMultiplier = false;
125
+ /**
126
+ * The ticket draw count
127
+ */
128
+ this.ticketDrawCount = 0;
129
+ /**
130
+ * The ticket winning numbers
131
+ */
132
+ this.ticketNumbers = '';
133
+ /**
134
+ * The session id
135
+ */
136
+ this.sessionId = '';
137
+ /**
138
+ * Client custom styling via string
139
+ */
140
+ this.clientStyling = '';
141
+ /**
142
+ * Client custom styling via url content
143
+ */
144
+ this.clientStylingUrlContent = '';
145
+ this.multiplier = 3;
146
+ this.isLoading = true;
147
+ this.rules = {};
148
+ this.toggleDrawer = [false];
149
+ this.hasErrors = false;
150
+ this.errorText = '';
151
+ this.ticketData = [];
152
+ this.ticketDataLoaded = false;
153
+ this.ticketDraws = [];
154
+ this.hasDrawNumbers = false;
155
+ this.limitStylingAppends = false;
156
+ this.getTicketsData = () => {
157
+ let url = new URL(`${this.endpoint}/tickets`);
158
+ let drawOptions = {
159
+ method: "GET",
160
+ headers: {
161
+ 'Content-Type': "application/json",
162
+ 'Accept': 'application/json',
163
+ 'Authorization': `Bearer ${this.sessionId}`
164
+ },
165
+ };
166
+ fetch(url.href, drawOptions)
167
+ .then((response) => {
168
+ return response.json();
169
+ })
170
+ .then((data) => {
171
+ if (data) {
172
+ this.ticketData = data;
173
+ this.ticketDataLoaded = true;
174
+ }
175
+ return this.ticketData;
176
+ }).then((response) => {
177
+ response.forEach(ticket => {
178
+ if (ticket.drawResults.length) {
179
+ ticket.drawResults.forEach(draw => {
180
+ fetch(`${this.endpoint}/games/${this.gameId}/draws/${draw.drawId}`)
181
+ .then((response) => {
182
+ return response.json();
183
+ })
184
+ .then((data) => {
185
+ // check if draw id is unique
186
+ if (!this.ticketDraws.some(el => el.drawId === draw.drawId)) {
187
+ this.ticketDraws.push({ drawId: draw.drawId, drawNumbers: data.winningNumbers });
188
+ }
189
+ });
190
+ });
191
+ }
192
+ return this.ticketDraws;
193
+ });
194
+ }).then(() => {
195
+ this.hasDrawNumbers = true;
196
+ });
197
+ };
198
+ this.changeBox = (index) => {
199
+ this.toggleDrawer = this.toggleDrawer.map((item, itemIndex) => {
200
+ if (itemIndex == index) {
201
+ return !item;
202
+ }
203
+ return item;
204
+ });
205
+ if (index >= this.toggleDrawer.length) {
206
+ this.toggleDrawer.push(true);
207
+ }
208
+ };
209
+ this.setClientStyling = () => {
210
+ let sheet = document.createElement('style');
211
+ sheet.innerHTML = this.clientStyling;
212
+ this.stylingContainer.prepend(sheet);
213
+ };
214
+ this.setClientStylingURL = () => {
215
+ let cssFile = document.createElement('style');
216
+ setTimeout(() => {
217
+ cssFile.innerHTML = this.clientStylingUrlContent;
218
+ this.stylingContainer.prepend(cssFile);
219
+ }, 1);
220
+ };
221
+ }
222
+ connectedCallback() {
223
+ let promises = [];
224
+ promises.push(this.getGameData());
225
+ if (this.drawId) {
226
+ promises.push(this.getDrawData());
227
+ }
228
+ if (!this.drawMode) {
229
+ this.getTicketsData();
230
+ }
231
+ Promise.all(promises)
232
+ .then(() => {
233
+ this.isLoading = false;
234
+ });
235
+ }
236
+ componentDidRender() {
237
+ // start custom styling area
238
+ if (!this.limitStylingAppends && this.stylingContainer) {
239
+ if (this.clientStyling)
240
+ this.setClientStyling();
241
+ if (this.clientStylingUrlContent)
242
+ this.setClientStylingURL();
243
+ this.limitStylingAppends = true;
244
+ }
245
+ // end custom styling area
246
+ }
247
+ getDrawData(drawID) {
248
+ return new Promise((resolve, reject) => {
249
+ let url = new URL(`${this.endpoint}/games/${this.gameId}/draws/${drawID ? drawID : this.drawId}`);
250
+ fetch(url.href)
251
+ .then((response) => {
252
+ // @TODO EXCEPTIONS
253
+ return response.json();
254
+ })
255
+ .then((data) => {
256
+ this.drawData = data;
257
+ resolve(true);
258
+ this.isLoading = false;
259
+ if (drawID) {
260
+ return this.drawData.winningNumbers;
261
+ }
262
+ })
263
+ .catch((err) => {
264
+ reject(err);
265
+ this.isLoading = false;
266
+ });
267
+ });
268
+ }
269
+ getGameData() {
270
+ return new Promise((resolve, reject) => {
271
+ let url = new URL(`${this.endpoint}/games/${this.gameId}`);
272
+ fetch(url.href)
273
+ .then((response) => {
274
+ return response.json();
275
+ })
276
+ .then((data) => {
277
+ this.rules = {
278
+ maximumAllowed: data.rules.boards[0].maximumAllowed,
279
+ totalNumbers: data.rules.boards[0].totalNumbers
280
+ };
281
+ resolve(true);
282
+ this.isLoading = false;
283
+ this.hasErrors = false;
284
+ })
285
+ .catch((err) => {
286
+ this.isLoading = false;
287
+ this.hasErrors = true;
288
+ this.errorText = err;
289
+ reject(err);
290
+ });
291
+ });
292
+ }
293
+ render() {
294
+ if (this.isLoading) {
295
+ return (index.h("p", null, "Loading, please wait ..."));
296
+ }
297
+ else if (this.hasErrors) {
298
+ index.h("p", null, this.errorText);
299
+ }
300
+ else {
301
+ return (index.h("section", { class: "DrawResultsSection", ref: el => this.stylingContainer = el }, this.drawMode ?
302
+ index.h("div", { class: "DrawResultsArea" }, this.drawData &&
303
+ index.h("div", null, index.h("div", { class: "DrawResultsHeader" }, index.h("span", null, translate('drawId', this.language), ": ", this.drawData.id), index.h("span", null, translate('drawDate', this.language), ": ", this.drawData.date.slice(0, 10))), index.h("div", { class: "DrawResultsBody" }, index.h("div", { class: "DrawNumbersGrid" }, index.h("p", null, translate('drawNumbersGridDraw', this.language), "0:"), index.h("div", { class: "BulletContainer" }, index.h("lottery-grid", { "maximum-allowed": this.rules.maximumAllowed, "total-numbers": this.rules.totalNumbers, "selected-numbers": this.drawData.winningNumbers.join(','), "display-selected": true, selectable: false, language: this.language, "grid-type": 'ticket', "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent })), index.h("div", { class: "DrawMultipler" }, index.h("label", { class: "Label" }, translate('multiplier', this.language), " ", this.multiplier))))))
304
+ :
305
+ index.h("div", { class: "DrawResultsArea TicketDraws" }, index.h("div", { class: "DrawResultsBody" }, index.h("div", { class: "TicketIdContainer" }, index.h("label", { class: "Label" }, translate('ticketId', this.language), ": ", index.h("span", null, this.ticketId))), index.h("div", { class: "TicketAmountContainer" }, index.h("label", { class: "Label" }, translate('ticketAmount', this.language), " ", index.h("span", null, this.ticketAmount))), index.h("div", { class: "DrawNumbersGrid" }, index.h("label", { class: "Label" }, translate('drawNumbersGridTicket', this.language), "0:"), index.h("div", { class: "BulletContainer" }, index.h("lottery-grid", { "maximum-allowed": this.rules.maximumAllowed, "total-numbers": this.rules.totalNumbers, "selected-numbers": JSON.parse(this.ticketNumbers).join(','), selectable: false, "display-selected": true, language: this.language, "grid-type": 'ticket', "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }))), index.h("div", { class: "DrawMultipler" }, index.h("label", { class: "Label" }, translate('multiplier', this.language), " ", JSON.stringify(this.ticketMultiplier))), index.h("div", { class: "NumberOfDrawsContainer" }, index.h("label", { class: "Label" }, translate('numberOfDraws', this.language), ": ", this.ticketDrawCount), index.h("div", { class: "DrawTicketsContainer" }, this.ticketData.map((ticket) => index.h("div", { class: "ExpandableBoxes" }, ticket.drawResults.length ?
306
+ index.h("div", null, ticket.id == this.ticketId && ticket.drawResults.map((item, index$1) => index.h("div", { class: this.toggleDrawer[index$1] ? 'ExpandableBox ShowBox' : 'ExpandableBox', onClick: () => this.changeBox(index$1) }, index.h("div", { class: "TicketResultContainer" }, index.h("p", null, translate('ticketResult', this.language), ": ", item.state)), item.state == 'won' &&
307
+ index.h("div", { class: "AmountWonContainer" }, index.h("p", null, translate('amountWon', this.language), ": ", Number(item.amount).toLocaleString('en'), " ", item.currency)), index.h("div", { class: "DrawIdContainer" }, index.h("p", null, translate('drawId', this.language), ": ", item.drawId)), index.h("div", { class: "DrawDateContainer" }, index.h("p", null, translate('drawDate', this.language), ": ", item.updatedAt.slice(0, 10), " | ", item.updatedAt.slice(11, 19))), index.h("div", { class: "DrawNumbersGrid" }, this.hasDrawNumbers && this.ticketDraws.map((ticketDraw) => item.drawId && item.drawId === ticketDraw.drawId &&
308
+ index.h("div", null, index.h("label", { class: "Label" }, translate('drawNumbersGridDraw', this.language), "A:"), index.h("lottery-grid", { "maximum-allowed": this.rules.maximumAllowed, "total-numbers": this.rules.totalNumbers, "selected-numbers": ticketDraw.drawNumbers.join(','), selectable: false, "display-selected": true, language: this.language, "grid-type": 'ticket', "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent })))), index.h("div", { class: "DrawMultipler" }, index.h("label", { class: "Label" }, translate('multiplier', this.language), " ", item.multiplier)))))
309
+ :
310
+ index.h("span", null)))))))));
311
+ }
312
+ }
313
+ };
314
+ LotteryDrawResults.style = lotteryDrawResultsCss;
315
+
316
+ 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:25px}";
317
+
318
+ const LotteryGrid = class {
319
+ constructor(hostRef) {
320
+ index.registerInstance(this, hostRef);
321
+ this.gridFilledEvent = index.createEvent(this, "gridFilled", 7);
322
+ this.gridDirtyEvent = index.createEvent(this, "gridDirty", 7);
323
+ /**
324
+ * Number of bullets of grid
325
+ */
326
+ this.totalNumbers = 0;
327
+ /**
328
+ * Number of maximum bullets that can be selected
329
+ */
330
+ this.maximumAllowed = 0;
331
+ /**
332
+ * Minimum allowed of bullets
333
+ */
334
+ this.minimumAllowed = 1;
335
+ /**
336
+ * Allows the user to select numbers on the grid
337
+ */
338
+ this.selectable = true;
339
+ /**
340
+ * Numbers that should be showed as selected on the grid (as a string of those numbers e.g. '1,2,3,4,5,6')
341
+ */
342
+ this.selectedNumbers = '';
343
+ /**
344
+ * Show only selected numbers
345
+ */
346
+ this.displaySelected = false;
347
+ /**
348
+ * Language
349
+ */
350
+ this.language = 'en';
351
+ this.numbers = [];
352
+ this.selectedCounter = 0;
353
+ }
354
+ connectedCallback() {
355
+ let selected = [];
356
+ if (this.selectedNumbers.length > 0) {
357
+ selected = this.selectedNumbers.split(',');
358
+ this.selectedCounter = selected.length;
359
+ }
360
+ if (this.displaySelected) {
361
+ selected.forEach((item) => {
362
+ this.numbers.push({
363
+ number: item,
364
+ selected: true,
365
+ selectable: this.selectable
366
+ });
367
+ });
368
+ }
369
+ else {
370
+ [...Array(this.totalNumbers).keys()]
371
+ .map(number => (number + 1).toString())
372
+ .forEach((number) => {
373
+ this.numbers.push({
374
+ number,
375
+ selected: selected.indexOf(number) >= 0 ? true : false,
376
+ selectable: this.selectedCounter == this.maximumAllowed ? false : this.selectable
377
+ });
378
+ });
379
+ }
380
+ }
381
+ lotteryBulletSelectionHandler(event) {
382
+ this.numbers = this.numbers.map((item) => {
383
+ if (item.number == event.detail.value) {
384
+ return {
385
+ number: item.number,
386
+ selected: event.detail.selected,
387
+ selectable: item.selectable
388
+ };
389
+ }
390
+ return {
391
+ number: item.number,
392
+ selected: item.selected,
393
+ selectable: item.selectable
394
+ };
395
+ });
396
+ if (event.detail.selected) {
397
+ this.selectedCounter += 1;
398
+ if (this.selectedCounter == this.maximumAllowed) {
399
+ this.numbers = this.numbers.map((item) => {
400
+ return {
401
+ number: item.number,
402
+ selected: item.selected,
403
+ selectable: item.selected ? true : false
404
+ };
405
+ });
406
+ this.gridFilledEvent.emit({
407
+ id: this.ticketId,
408
+ index: this.gridIndex,
409
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
410
+ });
411
+ }
412
+ }
413
+ else {
414
+ if (this.selectedCounter == this.maximumAllowed) {
415
+ this.numbers = this.numbers.map((item) => {
416
+ return {
417
+ number: item.number,
418
+ selected: item.selected,
419
+ selectable: true
420
+ };
421
+ });
422
+ this.gridDirtyEvent.emit({
423
+ id: this.ticketId,
424
+ index: this.gridIndex,
425
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
426
+ });
427
+ }
428
+ this.selectedCounter -= 1;
429
+ }
430
+ }
431
+ async resetSelectionHandler(event) {
432
+ if (event.detail && event.detail == this.ticketId) {
433
+ this.selectedCounter = 0;
434
+ this.numbers = this.numbers.map((item) => {
435
+ return {
436
+ number: item.number,
437
+ selected: false,
438
+ selectable: this.selectable
439
+ };
440
+ });
441
+ this.gridDirtyEvent.emit({
442
+ id: this.ticketId,
443
+ index: this.gridIndex,
444
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
445
+ });
446
+ }
447
+ }
448
+ async autoSelectionHandler(event) {
449
+ if (event.detail && event.detail == this.ticketId) {
450
+ this.resetSelectionHandler(event);
451
+ let array = [...Array(this.totalNumbers).keys()]
452
+ .map(number => number + 1)
453
+ .sort(() => 0.5 - Math.random());
454
+ array = array.slice(0, this.minimumAllowed);
455
+ this.numbers = this.numbers.map((item) => {
456
+ return {
457
+ number: item.number,
458
+ selected: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
459
+ selectable: array.indexOf(parseInt(item.number, 10)) >= 0 ? true : false,
460
+ };
461
+ });
462
+ this.gridFilledEvent.emit({
463
+ id: this.ticketId,
464
+ index: this.gridIndex,
465
+ selectedNumbers: this.numbers.filter((item) => item.selected).map((item) => item.number)
466
+ });
467
+ this.selectedCounter = this.maximumAllowed;
468
+ }
469
+ }
470
+ render() {
471
+ return (index.h("div", { class: "GridContainer" }, index.h("div", { class: "Grid" }, this.numbers.map((item) => index.h("div", null, index.h("lottery-bullet", { value: item.number, selectable: item.selectable, "is-selected": item.selected }))))));
472
+ }
473
+ };
474
+ LotteryGrid.style = lotteryGridCss;
475
+
476
+ exports.lottery_bullet = LotteryBullet;
477
+ exports.lottery_draw_results = LotteryDrawResults;
478
+ exports.lottery_grid = LotteryGrid;