lido-player 0.0.2-alpha-49 → 0.0.2-alpha-43-dev

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 (159) hide show
  1. package/dist/cjs/{index-fe562525.js → index-6a69c33a.js} +36 -3
  2. package/dist/cjs/index.cjs.js +2 -2
  3. package/dist/cjs/{lido-avatar_19.cjs.entry.js → lido-avatar_21.cjs.entry.js} +431 -180
  4. package/dist/cjs/lido-player.cjs.js +2 -2
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/{utils-96ce5641.js → utils-079a5e7d.js} +1032 -165
  7. package/dist/collection/collection-manifest.json +2 -0
  8. package/dist/collection/components/calculator/lido-calculator.css +87 -0
  9. package/dist/collection/components/calculator/lido-calculator.js +321 -0
  10. package/dist/collection/components/cell/lido-cell.js +1 -1
  11. package/dist/collection/components/column/lido-col.js +1 -1
  12. package/dist/collection/components/container/lido-container.js +20 -1
  13. package/dist/collection/components/flashCard/lido-flash-card.js +1 -1
  14. package/dist/collection/components/float/lido-float.js +1 -1
  15. package/dist/collection/components/home/lido-home.js +9 -29
  16. package/dist/collection/components/keyboard/lido-keyboard.js +2 -2
  17. package/dist/collection/components/mathMatrix/lido-math-matrix.css +10 -2
  18. package/dist/collection/components/mathMatrix/lido-math-matrix.js +226 -20
  19. package/dist/collection/components/position/lido-pos.js +1 -1
  20. package/dist/collection/components/random/lido-random.js +1 -1
  21. package/dist/collection/components/row/lido-row.js +1 -1
  22. package/dist/collection/components/scale/lido-balance.css +114 -0
  23. package/dist/collection/components/scale/lido-balance.js +549 -0
  24. package/dist/collection/components/shape/lido-shape.js +1 -1
  25. package/dist/collection/components/slideFill/lido-slide-fill.js +1 -1
  26. package/dist/collection/components/text/lido-text.js +1 -1
  27. package/dist/collection/components/trace/lido-trace.js +49 -128
  28. package/dist/collection/components/wrap/lido-wrap.js +1 -1
  29. package/dist/collection/css/animation.css +21 -0
  30. package/dist/collection/css/index.css +45 -0
  31. package/dist/collection/stories/Templates/Fill-Up/fill-up.stories.js +24 -25
  32. package/dist/collection/stories/Templates/RocketGame/rocketGame.stories.js +0 -3
  33. package/dist/collection/stories/Templates/balancing/balancing.stories.js +67 -0
  34. package/dist/collection/stories/Templates/checker-block/checkerBlock.stories.js +156 -0
  35. package/dist/collection/stories/Templates/checkerBlock/checkerBlock.stories.js +49 -0
  36. package/dist/collection/stories/Templates/fillAnswer/fill-answer.stories.js +66 -0
  37. package/dist/collection/stories/Templates/foodJar/food-jar.stories.js +65 -0
  38. package/dist/collection/stories/Templates/matchBox/matchBox.stories.js +105 -0
  39. package/dist/collection/stories/Templates/matchBox/matchBox2.stories.js +92 -0
  40. package/dist/collection/stories/Templates/matchingCard/matching-card.stories.js +47 -0
  41. package/dist/collection/stories/Templates/multiplyBeeds/multiplyBeeds.stories.js +59 -0
  42. package/dist/collection/stories/Templates/nimbleTable/nimbleTable.stories.js +93 -0
  43. package/dist/collection/stories/Templates/numberBoardTwo/numberBoardTwo.stories.js +100 -0
  44. package/dist/collection/stories/Templates/numberPair/numberPair.stories.js +212 -0
  45. package/dist/collection/stories/Templates/order-tractor/order-tractor-ascending-order.stories.js +6 -7
  46. package/dist/collection/stories/Templates/order-tractor/order-tractor.stories.js +6 -7
  47. package/dist/collection/stories/Templates/questionBoard/questionBoard.stories.js +158 -0
  48. package/dist/collection/stories/Templates/sequenceBox/sequenceBox1.stories.js +102 -0
  49. package/dist/collection/stories/Templates/sequenceBox/sequenceBox2.stories.js +94 -0
  50. package/dist/collection/stories/Templates/shapePair/shape-pair.stories.js +184 -0
  51. package/dist/collection/stories/Templates/shapeTractor/shape-tractor.stories.js +213 -0
  52. package/dist/collection/stories/Templates/sumTogether/sumTogether.stories.js +109 -0
  53. package/dist/collection/stories/Templates/total/total.stories.js +59 -0
  54. package/dist/collection/stories/Templates/writeNumber/writeNumber.stories.js +96 -0
  55. package/dist/collection/stories/Templates/writeSet/writeSet.stories.js +55 -0
  56. package/dist/collection/stories/Templates/writeWord/writeWord.stories.js +5 -6
  57. package/dist/collection/utils/utils.js +439 -81
  58. package/dist/collection/utils/utilsHandlers/clickHandler.js +21 -25
  59. package/dist/collection/utils/utilsHandlers/dragDropHandler.js +95 -42
  60. package/dist/collection/utils/utilsHandlers/lidoBalanceHandler.js +67 -0
  61. package/dist/collection/utils/utilsHandlers/lidoCalculatorHandler.js +94 -0
  62. package/dist/collection/utils/utilsHandlers/matrixHandler.js +298 -0
  63. package/dist/collection/utils/utilsHandlers/slideHandler.js +4 -2
  64. package/dist/collection/utils/utilsHandlers/sortHandler.js +21 -12
  65. package/dist/components/index.js +1 -1
  66. package/dist/components/lido-avatar.js +1 -1
  67. package/dist/components/lido-balance.d.ts +11 -0
  68. package/dist/components/lido-balance.js +6 -0
  69. package/dist/components/lido-calculator.d.ts +11 -0
  70. package/dist/components/lido-calculator.js +6 -0
  71. package/dist/components/lido-cell.js +1 -1
  72. package/dist/components/lido-col.js +1 -1
  73. package/dist/components/lido-container.js +1 -1
  74. package/dist/components/lido-flash-card.js +1 -1
  75. package/dist/components/lido-float.js +1 -1
  76. package/dist/components/lido-home.js +1 -1
  77. package/dist/components/lido-image.js +1 -1
  78. package/dist/components/lido-keyboard.js +1 -1
  79. package/dist/components/lido-math-matrix.js +1 -1
  80. package/dist/components/lido-pos.js +1 -1
  81. package/dist/components/lido-random.js +1 -1
  82. package/dist/components/lido-root.js +32 -20
  83. package/dist/components/lido-row.js +1 -1
  84. package/dist/components/lido-shape.js +1 -1
  85. package/dist/components/lido-slide-fill.js +1 -1
  86. package/dist/components/lido-text.js +1 -1
  87. package/dist/components/lido-trace.js +1 -1
  88. package/dist/components/lido-wrap.js +1 -1
  89. package/dist/components/p-08d0deab.js +254 -0
  90. package/dist/components/{p-b5b6ad27.js → p-15971ede.js} +1 -1
  91. package/dist/components/{p-0bf92c7f.js → p-1fbdb431.js} +2 -2
  92. package/dist/components/{p-b43ce4e1.js → p-29bdd953.js} +2 -2
  93. package/dist/components/{p-b8af26e6.js → p-322acda6.js} +40 -48
  94. package/dist/components/{p-51943db6.js → p-3f406017.js} +2 -2
  95. package/dist/components/p-44808985.js +186 -0
  96. package/dist/components/{p-4cabbf28.js → p-52844fa4.js} +2 -2
  97. package/dist/components/{p-4882df37.js → p-73e31a86.js} +2 -2
  98. package/dist/components/{p-af54a485.js → p-74849cdd.js} +4 -4
  99. package/dist/components/{p-9c56f378.js → p-7f7e5672.js} +2 -2
  100. package/dist/components/{p-4dbae73b.js → p-835b973d.js} +2 -2
  101. package/dist/components/{p-b55af747.js → p-90465904.js} +50 -129
  102. package/dist/components/{p-cae021c6.js → p-904711c8.js} +2 -2
  103. package/dist/components/{p-e735dce9.js → p-9be56729.js} +5 -3
  104. package/dist/components/{p-cac6c8bf.js → p-afbc196f.js} +2 -2
  105. package/dist/components/{p-cfa2aec8.js → p-bed94c37.js} +1047 -164
  106. package/dist/components/{p-7f11a624.js → p-cbac3cbc.js} +1 -1
  107. package/dist/components/{p-61d97438.js → p-d37ab4dc.js} +2 -2
  108. package/dist/components/p-e36ddcc1.js +166 -0
  109. package/dist/components/{p-03e4cafe.js → p-e4e42677.js} +2 -2
  110. package/dist/esm/{index-f47852d4.js → index-170e58c7.js} +36 -4
  111. package/dist/esm/index.js +2 -2
  112. package/dist/esm/{lido-avatar_19.entry.js → lido-avatar_21.entry.js} +430 -181
  113. package/dist/esm/lido-player.js +3 -3
  114. package/dist/esm/loader.js +3 -3
  115. package/dist/esm/{utils-9ce243d8.js → utils-5df09162.js} +1031 -164
  116. package/dist/lido-player/index.esm.js +1 -1
  117. package/dist/lido-player/lido-player.css +1 -1
  118. package/dist/lido-player/lido-player.esm.js +1 -1
  119. package/dist/lido-player/p-137c99ce.js +2 -0
  120. package/dist/lido-player/p-7556e652.js +9 -0
  121. package/dist/lido-player/p-eb956325.entry.js +1 -0
  122. package/dist/types/components/calculator/lido-calculator.d.ts +40 -0
  123. package/dist/types/components/container/lido-container.d.ts +4 -0
  124. package/dist/types/components/home/lido-home.d.ts +0 -1
  125. package/dist/types/components/mathMatrix/lido-math-matrix.d.ts +24 -4
  126. package/dist/types/components/scale/lido-balance.d.ts +160 -0
  127. package/dist/types/components/trace/lido-trace.d.ts +0 -1
  128. package/dist/types/components.d.ts +342 -14
  129. package/dist/types/stories/Templates/balancing/balancing.stories.d.ts +4 -0
  130. package/dist/types/stories/Templates/checker-block/checkerBlock.stories.d.ts +4 -0
  131. package/dist/types/stories/Templates/checkerBlock/checkerBlock.stories.d.ts +4 -0
  132. package/dist/types/stories/Templates/fillAnswer/fill-answer.stories.d.ts +4 -0
  133. package/dist/types/stories/Templates/foodJar/food-jar.stories.d.ts +4 -0
  134. package/dist/types/stories/Templates/matchBox/matchBox.stories.d.ts +4 -0
  135. package/dist/types/stories/Templates/matchBox/matchBox2.stories.d.ts +4 -0
  136. package/dist/types/stories/Templates/matchingCard/matching-card.stories.d.ts +4 -0
  137. package/dist/types/stories/Templates/multiplyBeeds/multiplyBeeds.stories.d.ts +9 -0
  138. package/dist/types/stories/Templates/nimbleTable/nimbleTable.stories.d.ts +4 -0
  139. package/dist/types/stories/Templates/numberBoardTwo/numberBoardTwo.stories.d.ts +4 -0
  140. package/dist/types/stories/Templates/numberPair/numberPair.stories.d.ts +4 -0
  141. package/dist/types/stories/Templates/questionBoard/questionBoard.stories.d.ts +15 -0
  142. package/dist/types/stories/Templates/sequenceBox/sequenceBox1.stories.d.ts +11 -0
  143. package/dist/types/stories/Templates/sequenceBox/sequenceBox2.stories.d.ts +11 -0
  144. package/dist/types/stories/Templates/shapePair/shape-pair.stories.d.ts +4 -0
  145. package/dist/types/stories/Templates/shapeTractor/shape-tractor.stories.d.ts +12 -0
  146. package/dist/types/stories/Templates/sumTogether/sumTogether.stories.d.ts +11 -0
  147. package/dist/types/stories/Templates/total/total.stories.d.ts +4 -0
  148. package/dist/types/stories/Templates/writeNumber/writeNumber.stories.d.ts +13 -0
  149. package/dist/types/stories/Templates/writeSet/writeSet.stories.d.ts +4 -0
  150. package/dist/types/utils/utils.d.ts +8 -2
  151. package/dist/types/utils/utilsHandlers/dragDropHandler.d.ts +4 -0
  152. package/dist/types/utils/utilsHandlers/lidoBalanceHandler.d.ts +2 -0
  153. package/dist/types/utils/utilsHandlers/lidoCalculatorHandler.d.ts +1 -0
  154. package/dist/types/utils/utilsHandlers/matrixHandler.d.ts +1 -0
  155. package/package.json +1 -1
  156. package/dist/components/p-a8ab771b.js +0 -160
  157. package/dist/lido-player/p-90212aa9.js +0 -9
  158. package/dist/lido-player/p-d3911ee1.entry.js +0 -1
  159. package/dist/lido-player/p-ddf627b0.js +0 -2
@@ -1,6 +1,5 @@
1
- import { g as getAssetPath } from './index-f47852d4.js';
1
+ import { g as getAssetPath } from './index-170e58c7.js';
2
2
 
3
- const DragSelectedMapKey = 'lidoDragSelectedMap';
4
3
  const DragMapKey = 'lidoDragMap';
5
4
  const SelectedValuesKey = 'lidoSelectedValues';
6
5
  const ActivityScoreKey = 'lidoActivityScore';
@@ -14,7 +13,6 @@ const GameExitKey = 'lidoGameExit';
14
13
  const ElementDropKey = 'lidoElementDrop';
15
14
  const ElementClickKey = 'lidoElementClick';
16
15
  const DropLength = 'dropLength';
17
- const DropHasDrag = 'dropHasDrag';
18
16
  const DropToAttr = 'drop-to';
19
17
  const DropTimeAttr = 'drop-time';
20
18
  const LidoContainer = 'lido-container';
@@ -159,6 +157,88 @@ function stopHighlightForSpeakingElement(element) {
159
157
  // element.style.border = '';
160
158
  }
161
159
 
160
+ function updateBalanceOnDrop(dragElement, dropElement) {
161
+ const balanceEl = document.querySelector('lido-balance');
162
+ if (!balanceEl)
163
+ return;
164
+ const leftDrag = Array.from(document.querySelectorAll('[drop-to^="lefthandle"]'));
165
+ const rightDrag = Array.from(document.querySelectorAll('[drop-to^="righthandle"]'));
166
+ balanceEl.leftVal = calculateValue(leftDrag, balanceEl.operation);
167
+ balanceEl.rightVal = calculateValue(rightDrag, balanceEl.operation);
168
+ console.log("leftpan:", balanceEl.leftVal, "rightpan:", balanceEl.rightVal);
169
+ if (balanceEl.updateTilt) {
170
+ balanceEl.updateTilt(balanceEl.leftVal, balanceEl.rightVal);
171
+ }
172
+ }
173
+ function calculateValue(elements, operation) {
174
+ if (elements.length === 0)
175
+ return 0;
176
+ if (operation === "count") {
177
+ return elements.length;
178
+ }
179
+ const ADD = ["add", "+"];
180
+ const SUBTRACT = ["subtract", "-"];
181
+ const MULTIPLY = ["multiply", "*"];
182
+ const DIVIDE = ["divide", "/"];
183
+ const expr = elements
184
+ .map(el => el.getAttribute("value") || "0")
185
+ .join(ADD.includes(operation) ? " + " :
186
+ SUBTRACT.includes(operation) ? " - " :
187
+ MULTIPLY.includes(operation) ? " * " :
188
+ DIVIDE.includes(operation) ? " / " : " + ");
189
+ try {
190
+ const res = equationCheck(expr);
191
+ if (typeof res === "number") {
192
+ return res;
193
+ }
194
+ else if (typeof res === "boolean") {
195
+ return res ? 1 : 0;
196
+ }
197
+ else {
198
+ return parseFloat(expr) || 0;
199
+ }
200
+ }
201
+ catch (e) {
202
+ console.warn("invalid exp", expr);
203
+ return 0;
204
+ }
205
+ }
206
+ function balanceResult(container, objectiveString) {
207
+ var _a, _b, _c, _d, _e, _f;
208
+ const additionalCheck = container.getAttribute('equationCheck');
209
+ if (!additionalCheck)
210
+ return false;
211
+ const balanceEl = document.querySelector('lido-balance');
212
+ if (!balanceEl)
213
+ return false;
214
+ const leftVal = Number((_c = (_a = balanceEl.leftVal) !== null && _a !== void 0 ? _a : (_b = balanceEl.dataset) === null || _b === void 0 ? void 0 : _b.leftVal) !== null && _c !== void 0 ? _c : 0);
215
+ const rightVal = Number((_f = (_d = balanceEl.rightVal) !== null && _d !== void 0 ? _d : (_e = balanceEl.dataset) === null || _e === void 0 ? void 0 : _e.rightVal) !== null && _f !== void 0 ? _f : 0);
216
+ const hasLeft = !isNaN(leftVal) && leftVal !== 0;
217
+ const hasRight = !isNaN(rightVal) && rightVal !== 0;
218
+ if (!hasLeft || !hasRight) {
219
+ return false;
220
+ }
221
+ const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
222
+ const res = objectiveString === symbol;
223
+ console.log("Result:", res);
224
+ return res;
225
+ }
226
+
227
+ function buildDropHasDragFromDOM() {
228
+ const dropHasDrag = {};
229
+ const dropElements = document.querySelectorAll("[type='drop']");
230
+ dropElements.forEach(drop => {
231
+ const tabIndex = drop.getAttribute("tab-index") || drop.id;
232
+ const assignedDrag = document.querySelector(`[${DropToAttr}="${drop.id}"]`);
233
+ const isFull = !!assignedDrag;
234
+ drop.setAttribute("is-full", String(isFull));
235
+ dropHasDrag[tabIndex] = {
236
+ drop: drop.id,
237
+ isFull
238
+ };
239
+ });
240
+ return dropHasDrag;
241
+ }
162
242
  // Function to get the scale of an element
163
243
  const getElementScale$1 = (el) => {
164
244
  el.style.animation = 'unset';
@@ -209,7 +289,7 @@ function enableDraggingWithScaling(element) {
209
289
  isDragging = false;
210
290
  return;
211
291
  }
212
- AudioPlayer.getI().stop();
292
+ // AudioPlayer.getI().stop();
213
293
  removeHighlight(element);
214
294
  isDragging = true;
215
295
  isClicked = true;
@@ -313,7 +393,6 @@ function enableDraggingWithScaling(element) {
313
393
  // Start observing the element
314
394
  observer.observe(container, observerConfig);
315
395
  const onMove = (event) => {
316
- console.log("moved");
317
396
  if (!isDragging)
318
397
  return;
319
398
  if (isDraggingDisabled) {
@@ -322,7 +401,7 @@ function enableDraggingWithScaling(element) {
322
401
  }
323
402
  isClicked = false;
324
403
  element.style.transition = 'none';
325
- const containerScale = calculateScale();
404
+ const containerScale = getElementScale$1(container);
326
405
  let dx = 0;
327
406
  let dy = 0;
328
407
  if (event instanceof MouseEvent) {
@@ -344,7 +423,7 @@ function enableDraggingWithScaling(element) {
344
423
  // Reset styles for all elements
345
424
  allElements.forEach(otherElement => {
346
425
  var _a;
347
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
426
+ const dropObject = buildDragSelectedMapFromDOM();
348
427
  const storedTabIndexes = Object.keys(dropObject).map(Number);
349
428
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
350
429
  if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -402,7 +481,7 @@ function enableDraggingWithScaling(element) {
402
481
  allElements.forEach(otherElement => {
403
482
  allElements.forEach(otherElement => {
404
483
  var _a;
405
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
484
+ const dropObject = buildDragSelectedMapFromDOM();
406
485
  const storedTabIndexes = Object.keys(dropObject).map(Number);
407
486
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
408
487
  if (!(((_a = element.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -566,14 +645,18 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
566
645
  let prevDropItem = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === currentDrop);
567
646
  if (prevDropItem) {
568
647
  prevDropItem.isFull = false;
569
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
648
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
649
+ const dropEl = document.getElementById(prevDropItem.drop);
650
+ if (dropEl) {
651
+ dropEl.removeAttribute('is-full');
652
+ }
570
653
  }
571
654
  dragToDropMap.delete(dragElement);
572
655
  }
573
656
  if (selectedValueData) {
574
657
  let selectedValue = JSON.parse(selectedValueData);
575
658
  selectedValue = selectedValue.filter(value => value != dragElement['value']);
576
- localStorage.setItem(SelectedValuesKey, JSON.stringify(selectedValue));
659
+ container.setAttribute(SelectedValuesKey, JSON.stringify(selectedValue));
577
660
  }
578
661
  if (dragSelectedData) {
579
662
  let dragSelected = JSON.parse(dragSelectedData);
@@ -581,14 +664,15 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
581
664
  if (dragPreDropElement) {
582
665
  delete dragSelected[dragPreDropElement.getAttribute('tab-index')];
583
666
  }
584
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
667
+ // container.setAttribute(DragSelectedMapKey, JSON.stringify(dragSelected));
585
668
  dragElement.removeAttribute(DropToAttr);
586
669
  updateDropBorder(currentDrop);
670
+ updateBalanceOnDrop();
587
671
  }
588
672
  const allElements = document.querySelectorAll("[type='drop']");
589
673
  allElements.forEach(otherElement => {
590
674
  var _a;
591
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
675
+ const dropObject = buildDragSelectedMapFromDOM();
592
676
  const storedTabIndexes = Object.keys(dropObject).map(Number);
593
677
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
594
678
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -613,20 +697,22 @@ function handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedV
613
697
  });
614
698
  handleShowCheck();
615
699
  }
700
+ const tempVanishedValues = [];
616
701
  async function onElementDropComplete(dragElement, dropElement) {
617
- var _a, _b, _c, _d, _e;
618
- const selectedValueData = localStorage.getItem(SelectedValuesKey) || '';
619
- const dragSelectedData = localStorage.getItem(DragSelectedMapKey);
620
- localStorage.getItem(DragMapKey);
621
- console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
622
- let dropHasDrag = JSON.parse(localStorage.getItem(DropHasDrag) || ' {}');
702
+ var _a, _b, _c, _d, _e, _f, _g, _h;
623
703
  const container = document.getElementById(LidoContainer);
704
+ const selectedValueData = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : "[]";
705
+ const dragSelectedData = JSON.stringify(buildDragSelectedMapFromDOM());
706
+ const dropSelectedDataobject = buildDragSelectedMapFromDOM();
707
+ JSON.stringify(dropSelectedDataobject);
708
+ console.log("dragggedddd elem", { value: dragElement.getAttribute("value") });
709
+ let dropHasDrag = buildDropHasDragFromDOM();
624
710
  if (!dropElement) {
625
711
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
626
712
  return;
627
713
  }
628
714
  const dropTabIndex = dropElement.getAttribute('tab-index');
629
- if ((_a = dropHasDrag[dropTabIndex]) === null || _a === void 0 ? void 0 : _a.isFull) {
715
+ if ((_b = dropHasDrag[dropTabIndex]) === null || _b === void 0 ? void 0 : _b.isFull) {
630
716
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
631
717
  return;
632
718
  }
@@ -638,9 +724,10 @@ async function onElementDropComplete(dragElement, dropElement) {
638
724
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
639
725
  return;
640
726
  }
727
+ // let isCorrect = dropElement.getAttribute('value').toLowerCase().includes(dragElement.getAttribute('value').toLowerCase());
641
728
  let isCorrect;
642
- const dragValue = ((_b = dragElement.getAttribute('value')) === null || _b === void 0 ? void 0 : _b.trim()) || "";
643
- const dropValue = ((_c = dropElement.getAttribute('value')) === null || _c === void 0 ? void 0 : _c.trim()) || "";
729
+ const dragValue = ((_c = dragElement.getAttribute('value')) === null || _c === void 0 ? void 0 : _c.trim()) || "";
730
+ const dropValue = ((_d = dropElement.getAttribute('value')) === null || _d === void 0 ? void 0 : _d.trim()) || "";
644
731
  if (Number(dragValue)) {
645
732
  const dragNum = Number(dragValue);
646
733
  //array of numbers
@@ -654,8 +741,7 @@ async function onElementDropComplete(dragElement, dropElement) {
654
741
  }
655
742
  }
656
743
  else {
657
- //strings
658
- isCorrect = dropValue.toLowerCase().includes(dragValue.toLowerCase());
744
+ isCorrect = dropElement.getAttribute('value').toLowerCase().includes(dragElement.getAttribute('value').toLowerCase());
659
745
  }
660
746
  if (!isCorrect) {
661
747
  dragElement.style.transition = 'transform 0.5s ease';
@@ -670,7 +756,7 @@ async function onElementDropComplete(dragElement, dropElement) {
670
756
  // delete stored[oldDropIndex];
671
757
  // localStorage.setItem(localStorageKey, JSON.stringify(stored));
672
758
  // }
673
- // handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData, dropSelectedData);
759
+ handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
674
760
  }, 500);
675
761
  if (dragElement['type'] === 'option') {
676
762
  const childs = Array.from(container.querySelectorAll(`[value="${dragElement['value']}"]`));
@@ -689,6 +775,7 @@ async function onElementDropComplete(dragElement, dropElement) {
689
775
  if (checkdropAttr && checkdropAttr.toLowerCase() === DropMode.EnableAnimation.toLowerCase()) {
690
776
  container.style.pointerEvents = "none";
691
777
  setTimeout(() => {
778
+ var _a, _b, _c;
692
779
  const div = document.createElement('div');
693
780
  container.append(div);
694
781
  div.classList.add('after-drop-popup-container');
@@ -697,6 +784,11 @@ async function onElementDropComplete(dragElement, dropElement) {
697
784
  const allDragElements = container.querySelectorAll('[type="drag"]');
698
785
  const dragParents = Array.from(allDragElements).map(el => el.parentElement);
699
786
  const allSameParent = dragParents.every(parent => parent === dragElement.parentElement);
787
+ JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
788
+ const vanishedValue = (_b = dragElement.getAttribute('value')) !== null && _b !== void 0 ? _b : (_c = dragElement.textContent) === null || _c === void 0 ? void 0 : _c.trim();
789
+ if (vanishedValue) {
790
+ tempVanishedValues.push(vanishedValue);
791
+ }
700
792
  // Remove from old parents
701
793
  if (allSameParent) {
702
794
  dragElement.remove();
@@ -720,6 +812,16 @@ async function onElementDropComplete(dragElement, dropElement) {
720
812
  setTimeout(() => {
721
813
  div.remove();
722
814
  container.style.pointerEvents = 'auto';
815
+ const objective = container.getAttribute('objective');
816
+ if (objective && tempVanishedValues.map(v => v.trim()).sort().join(',') === objective.split(',').map(v => v.trim()).sort().join(',')) {
817
+ (async () => {
818
+ isCorrect = true;
819
+ const onCorrect = (container === null || container === void 0 ? void 0 : container.getAttribute('onCorrect')) || '';
820
+ await executeActions(onCorrect, container);
821
+ window.dispatchEvent(new CustomEvent(NextContainerKey));
822
+ tempVanishedValues.length = 0;
823
+ })();
824
+ }
723
825
  }, 800); // match animation duration
724
826
  }, 2000); // stay for 2 seconds
725
827
  }, 250);
@@ -727,6 +829,12 @@ async function onElementDropComplete(dragElement, dropElement) {
727
829
  }
728
830
  }
729
831
  if (dropElement) {
832
+ let selectedValues = JSON.parse((_e = container.getAttribute(SelectedValuesKey)) !== null && _e !== void 0 ? _e : "[]");
833
+ const dragValue = dragElement.getAttribute('value');
834
+ if (dragValue && !selectedValues.includes(dragValue)) {
835
+ selectedValues.push(dragValue);
836
+ }
837
+ container.setAttribute(SelectedValuesKey, JSON.stringify(selectedValues));
730
838
  if (dropElement.getAttribute('drop-attr') === 'stretch') {
731
839
  if (!dropElement.hasAttribute('data-original-width')) {
732
840
  const computedStyle = window.getComputedStyle(dropElement);
@@ -735,15 +843,16 @@ async function onElementDropComplete(dragElement, dropElement) {
735
843
  const dragWidth = dragElement.offsetWidth;
736
844
  dropElement.style.width = `${dragWidth}px`;
737
845
  }
738
- if (!(((_d = dropElement.getAttribute('dropAttr')) === null || _d === void 0 ? void 0 : _d.toLowerCase()) === DropMode.Diagonal) && (dropElement.getAttribute('minDrops') === '1' || !dropElement.getAttribute('minDrops'))) {
846
+ if (!(((_f = dropElement.getAttribute('dropAttr')) === null || _f === void 0 ? void 0 : _f.toLowerCase()) === DropMode.Diagonal) && (dropElement.getAttribute('minDrops') === '1' || !dropElement.getAttribute('minDrops'))) {
739
847
  const isisFull = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === dropElement);
740
848
  if (isisFull) {
741
849
  isisFull.isFull = true;
850
+ dropElement.setAttribute('is-full', 'true');
742
851
  }
743
852
  else {
744
853
  console.warn('No matching drop item found for', dropElement);
745
854
  }
746
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
855
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
747
856
  if (dragSelectedData) {
748
857
  let dragSelected = JSON.parse(dragSelectedData);
749
858
  for (const key in dragSelected) {
@@ -756,7 +865,7 @@ async function onElementDropComplete(dragElement, dropElement) {
756
865
  }
757
866
  }
758
867
  }
759
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
868
+ // container.setAttribute(DragSelectedMapKey, JSON.stringify(dragSelected));
760
869
  }
761
870
  dragElement.classList.add('dropped');
762
871
  if (dragElement) {
@@ -769,7 +878,7 @@ async function onElementDropComplete(dragElement, dropElement) {
769
878
  dragElement.setAttribute(DropTimeAttr, new Date().getTime().toString());
770
879
  }
771
880
  // Check for overlaps and highlight only the most overlapping element
772
- if (dropElement && !((_e = dropHasDrag[dropTabIndex]) === null || _e === void 0 ? void 0 : _e.isFull)) {
881
+ if (dropElement && !((_g = dropHasDrag[dropTabIndex]) === null || _g === void 0 ? void 0 : _g.isFull)) {
773
882
  let mostOverlappedElement = findMostoverlappedElement$1(dragElement, 'drag');
774
883
  const isAllowOnlyOneDrop = dropElement.getAttribute('is-allow-only-one-drop') === 'true' || '';
775
884
  if (mostOverlappedElement && isAllowOnlyOneDrop) {
@@ -778,7 +887,7 @@ async function onElementDropComplete(dragElement, dropElement) {
778
887
  const allElements = document.querySelectorAll("[type='drop']");
779
888
  allElements.forEach(otherElement => {
780
889
  var _a;
781
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
890
+ const dropObject = buildDragSelectedMapFromDOM();
782
891
  const storedTabIndexes = Object.keys(dropObject).map(Number);
783
892
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
784
893
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
@@ -810,13 +919,14 @@ async function onElementDropComplete(dragElement, dropElement) {
810
919
  handleResetDragElement(dragElement, dropElement, dropHasDrag, selectedValueData, dragSelectedData);
811
920
  return;
812
921
  }
922
+ updateBalanceOnDrop();
813
923
  if (dragSelectedData) {
814
924
  let currentDrop = dragToDropMap.get(dragElement);
815
925
  if (currentDrop) {
816
926
  let prevDropItem = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === currentDrop);
817
927
  if (prevDropItem) {
818
928
  prevDropItem.isFull = false;
819
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
929
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
820
930
  reduceSizeToOriginal();
821
931
  }
822
932
  }
@@ -829,9 +939,9 @@ async function onElementDropComplete(dragElement, dropElement) {
829
939
  // }
830
940
  // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
831
941
  }
832
- let dropLength = JSON.parse(localStorage.getItem(DropLength)) || 0;
942
+ let dropLength = parseInt((_h = container.getAttribute(DropLength)) !== null && _h !== void 0 ? _h : '0');
833
943
  dropLength += 1;
834
- localStorage.setItem(DropLength, JSON.stringify(dropLength));
944
+ container.setAttribute(DropLength, String(dropLength));
835
945
  if (dropLength === countPatternWords(dropElement['value'])) {
836
946
  const isisFull = Object.values(dropHasDrag).find(item => document.getElementById(item.drop) === dropElement);
837
947
  if (isisFull) {
@@ -840,9 +950,10 @@ async function onElementDropComplete(dragElement, dropElement) {
840
950
  else {
841
951
  console.warn('No matching drop item found for', dropElement);
842
952
  }
843
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHasDrag));
953
+ // memoryStorage[DropHasDrag] = dropHasDrag;
954
+ // container.setAttribute(DropHasDrag, JSON.stringify(dropHasDrag));
844
955
  dropLength = 0;
845
- localStorage.setItem(DropLength, JSON.stringify(dropLength));
956
+ container.setAttribute(DropLength, String(dropLength));
846
957
  }
847
958
  dragToDropMap.set(dragElement, dropElement);
848
959
  // Add pulse and highlight effect for a successful match
@@ -850,9 +961,9 @@ async function onElementDropComplete(dragElement, dropElement) {
850
961
  dispatchElementDropEvent(dragElement, dropElement, isCorrect);
851
962
  storingEachActivityScore(isCorrect);
852
963
  dragElement.style.opacity = '1';
964
+ await onActivityComplete(dragElement, dropElement);
853
965
  const allDropElements = document.querySelectorAll('.drop-element');
854
966
  allDropElements.forEach(el => updateDropBorder(el));
855
- await onActivityComplete(dragElement, dropElement);
856
967
  }
857
968
  function updateDropBorder(element) {
858
969
  if (!element || !element.classList.contains('drop-element'))
@@ -871,7 +982,9 @@ function updateDropBorder(element) {
871
982
  element.classList.remove('empty');
872
983
  }
873
984
  else {
874
- element.classList.add('empty');
985
+ if (!element.classList.contains('math-matrix')) {
986
+ element.classList.add('empty');
987
+ }
875
988
  element.classList.remove('filled');
876
989
  }
877
990
  }
@@ -879,15 +992,12 @@ function handleDropElement(element) {
879
992
  // let nextIndex = Object.keys(dropHas).length; // Get next index
880
993
  // dropHas[nextIndex] = { drop: element, isFull: false };
881
994
  element.classList.add('drop-element');
882
- let dropHas = JSON.parse(localStorage.getItem(DropHasDrag) || '{}');
883
- const tabIndex = element.getAttribute('tab-index');
884
- if (typeof dropHas !== 'object' || dropHas === null) {
885
- dropHas = {};
886
- }
887
- if (!dropHas[tabIndex]) {
888
- dropHas[tabIndex] = { drop: element.id, isFull: false };
889
- localStorage.setItem(DropHasDrag, JSON.stringify(dropHas));
890
- }
995
+ buildDragSelectedMapFromDOM();
996
+ element.getAttribute('tab-index');
997
+ // if (!dropHas[tabIndex]) {
998
+ // dropHas[tabIndex] = { drop: element.id, isFull: false };
999
+ // // localStorage.setItem(DropHasDrag, JSON.stringify(dropHas));
1000
+ // }
891
1001
  element.onclick = () => {
892
1002
  onClickDropOrDragElement(element, 'drop');
893
1003
  };
@@ -954,7 +1064,7 @@ async function onClickDropOrDragElement(element, type) {
954
1064
  const dragToDropMap = new Map();
955
1065
  async function onClickDragElement(element) {
956
1066
  AudioPlayer.getI().stop();
957
- const dropElements = JSON.parse(localStorage.getItem(DropHasDrag) || '{}');
1067
+ const dropElements = buildDropHasDragFromDOM();
958
1068
  const dragEl = element;
959
1069
  if (!dragEl) {
960
1070
  console.error('Element not found');
@@ -1000,9 +1110,12 @@ const appendingDragElementsInDrop = () => {
1000
1110
  });
1001
1111
  });
1002
1112
  };
1113
+ const container = document.getElementById(LidoContainer);
1003
1114
  const reduceSizeToOriginal = () => {
1004
1115
  const dropItems = document.querySelectorAll("[type='drop']");
1005
- let dropHasDrag = JSON.parse(localStorage.getItem(DropHasDrag) || ' {}');
1116
+ let dropHasDrag = buildDragSelectedMapFromDOM();
1117
+ if (!dropItems || !container)
1118
+ return;
1006
1119
  if (!dropHasDrag || !dropItems)
1007
1120
  return;
1008
1121
  dropItems.forEach(dropElement => {
@@ -1011,6 +1124,7 @@ const reduceSizeToOriginal = () => {
1011
1124
  const tabIndex = drop.getAttribute('tab-index');
1012
1125
  if (((_a = drop === null || drop === void 0 ? void 0 : drop.getAttribute('drop-attr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Stretch && dropHasDrag[tabIndex].isFull === false) {
1013
1126
  const originalWidth = drop.getAttribute('data-original-width');
1127
+ dropElement.removeAttribute('is-full');
1014
1128
  if (originalWidth) {
1015
1129
  drop.style.width = originalWidth;
1016
1130
  drop.removeAttribute('data-original-width');
@@ -1201,7 +1315,7 @@ function enableReorderDrag(element) {
1201
1315
  isClicked = false;
1202
1316
  event.preventDefault();
1203
1317
  const containerRect = container.getBoundingClientRect();
1204
- const containerScale = calculateScale();
1318
+ const containerScale = getElementScale(container);
1205
1319
  const newLeft = (point.clientX - containerRect.left - offsetXInElement) / containerScale;
1206
1320
  const newTop = (point.clientY - containerRect.top - offsetYInElement) / containerScale;
1207
1321
  element.style.left = `${newLeft}px`;
@@ -1268,16 +1382,18 @@ function enableReorderDrag(element) {
1268
1382
  else {
1269
1383
  if (element.parentElement['type'] !== 'category') {
1270
1384
  executeActions('this.alignMatch=true', divEl, element);
1271
- divEl.replaceWith(element);
1385
+ setTimeout(() => {
1386
+ divEl.replaceWith(element);
1387
+ }, 500);
1272
1388
  }
1273
1389
  else {
1274
1390
  const categoryElement = element.parentElement;
1275
- const dragValues = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
1391
+ const dragValues = buildDragSelectedMapFromDOM();
1276
1392
  const tabKey = categoryElement.getAttribute('tab-index');
1277
1393
  const targetValue = element['value'];
1278
1394
  if (dragValues[tabKey]) {
1279
1395
  dragValues[tabKey] = dragValues[tabKey].filter((el) => el !== targetValue);
1280
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
1396
+ // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
1281
1397
  }
1282
1398
  optionArea.scrollTo({
1283
1399
  top: optionArea.scrollHeight,
@@ -1285,6 +1401,7 @@ function enableReorderDrag(element) {
1285
1401
  });
1286
1402
  optionArea.appendChild(element);
1287
1403
  element.classList.remove('dropped');
1404
+ element.removeAttribute('drop-to');
1288
1405
  if (dummy) {
1289
1406
  dummy.remove();
1290
1407
  }
@@ -1323,12 +1440,12 @@ function enableReorderDrag(element) {
1323
1440
  category = categoryArr[0];
1324
1441
  }
1325
1442
  if (element.parentElement.getAttribute('type') === 'category') {
1326
- const dragValues = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
1443
+ const dragValues = buildDragSelectedMapFromDOM();
1327
1444
  const tabKey = category.getAttribute('tab-index');
1328
1445
  const targetValue = element['value'];
1329
1446
  if (dragValues[tabKey]) {
1330
1447
  dragValues[tabKey] = dragValues[tabKey].filter((el) => el !== targetValue);
1331
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
1448
+ // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragValues));
1332
1449
  }
1333
1450
  const dummy = createDummyElement(element);
1334
1451
  optionArea.appendChild(dummy);
@@ -1342,6 +1459,7 @@ function enableReorderDrag(element) {
1342
1459
  resetElementStyles(element);
1343
1460
  dummy.replaceWith(element);
1344
1461
  element.classList.remove('dropped');
1462
+ element.removeAttribute('drop-to');
1345
1463
  }, 100);
1346
1464
  return;
1347
1465
  }
@@ -1490,13 +1608,15 @@ function moveWithAnimation(target, overlapped) {
1490
1608
  }
1491
1609
  // Drop Completed
1492
1610
  const wordDropComplete = (block, element) => {
1611
+ var _a;
1612
+ console.log("worddrop");
1493
1613
  const container = document.getElementById(LidoContainer);
1494
1614
  const objective = container.getAttribute('objective');
1495
1615
  const objectiveArray = objective.split(',');
1496
- let wordArray = JSON.parse(localStorage.getItem(SelectedValuesKey)) || [];
1616
+ let wordArray = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
1497
1617
  const wordBlock = block.children;
1498
1618
  wordArray = Array.from(wordBlock).map(child => child.getAttribute('value'));
1499
- localStorage.setItem(SelectedValuesKey, JSON.stringify(wordArray));
1619
+ container.setAttribute(SelectedValuesKey, JSON.stringify(wordArray));
1500
1620
  const elementIndex = wordArray.indexOf(element['value']);
1501
1621
  if (elementIndex >= 0) {
1502
1622
  const res = matchStringPattern(element['value'], [objectiveArray[elementIndex].trim()]);
@@ -1511,7 +1631,7 @@ const wordDropComplete = (block, element) => {
1511
1631
  };
1512
1632
  async function onDropToCategory(dragElement, categoryElement) {
1513
1633
  dragElement.classList.add('dropped');
1514
- let dragSelected = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
1634
+ let dragSelected = buildDragSelectedMapFromDOM();
1515
1635
  let elementArr = dragSelected[categoryElement.getAttribute('tab-index')];
1516
1636
  if (Array.isArray(elementArr)) {
1517
1637
  if (elementArr.includes(dragElement['value']))
@@ -1523,7 +1643,10 @@ async function onDropToCategory(dragElement, categoryElement) {
1523
1643
  dragSelected[key].splice(index, 1);
1524
1644
  }
1525
1645
  }
1526
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
1646
+ if (categoryElement === null || categoryElement === void 0 ? void 0 : categoryElement.id) {
1647
+ dragElement.setAttribute(DropToAttr, categoryElement.id);
1648
+ }
1649
+ // localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragSelected));
1527
1650
  await onActivityComplete(dragElement, categoryElement);
1528
1651
  }
1529
1652
 
@@ -1742,13 +1865,15 @@ function slidingWithScaling(element) {
1742
1865
  });
1743
1866
  }
1744
1867
  const slideCompleted = (slideElement) => {
1745
- const slideArr = JSON.parse(localStorage.getItem(SelectedValuesKey)) || [];
1868
+ var _a;
1869
+ const container = document.getElementById(LidoContainer);
1870
+ const slideArr = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
1746
1871
  const allSlideElements = document.querySelectorAll("[type='slide']");
1747
1872
  let index = 0;
1748
1873
  allSlideElements.forEach(item => {
1749
1874
  slideArr[index++] = item['value'];
1750
1875
  });
1751
- localStorage.setItem(SelectedValuesKey, JSON.stringify(slideArr));
1876
+ container.setAttribute(SelectedValuesKey, JSON.stringify(slideArr));
1752
1877
  const objectiveString = document.getElementById(LidoContainer)['objective'];
1753
1878
  const objectiveArray = objectiveString.split(',');
1754
1879
  const elementIndex = slideArr.indexOf(slideElement['value']);
@@ -3010,6 +3135,7 @@ function addClickListenerForClickType(element) {
3010
3135
  return;
3011
3136
  }
3012
3137
  const onClick = async () => {
3138
+ var _a;
3013
3139
  const lido_buttons = element.getAttribute('id');
3014
3140
  if (lido_buttons === 'lido-arrow-left' || lido_buttons === 'lido-arrow-right') {
3015
3141
  return;
@@ -3026,24 +3152,15 @@ function addClickListenerForClickType(element) {
3026
3152
  }
3027
3153
  if (container['objective'].length === 0)
3028
3154
  return;
3029
- // element.style.border = '2px solid yellow';
3030
- // element.style.boxShadow = '0px 0px 10px rgba(255, 255, 0, 0.7)';
3031
- // element.style.transition = 'transform 0.2s ease, border 0.5s ease';
3032
- // element.style.transform = 'scale(1.1)';
3033
- // element.style.transform = 'scale(1)';
3034
- // element.style.border = '';
3035
- // element.style.boxShadow = '';
3036
3155
  const isActivated = element.classList.contains('lido-element-selected');
3037
- let selectedValue = JSON.parse(localStorage.getItem(SelectedValuesKey)) || [];
3156
+ let selectedValue = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]');
3038
3157
  if (objective.length === 1) {
3039
- localStorage.setItem(SelectedValuesKey, JSON.stringify([element['value']]));
3158
+ container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
3040
3159
  const isCorrect = objective.includes(element['value']);
3041
3160
  dispatchClickEvent(element, isCorrect);
3042
3161
  if (isCorrect) {
3043
3162
  const onCorrect = element.getAttribute('onCorrect');
3044
- if (!(element.id && element.id.startsWith('key-button'))) {
3045
- element.style.pointerEvents = 'none';
3046
- }
3163
+ // element.style.pointerEvents = 'none';
3047
3164
  await executeActions(onCorrect, element);
3048
3165
  }
3049
3166
  else {
@@ -3051,7 +3168,11 @@ function addClickListenerForClickType(element) {
3051
3168
  await executeActions(onInCorrect, element);
3052
3169
  // showWrongAnswerAnimation([element]);
3053
3170
  }
3054
- storingEachActivityScore(isCorrect);
3171
+ // const calciEl=document.querySelector('#lidoCalculator') as any;
3172
+ const isInsideCalculator = element.closest('#lidoCalculator') !== null;
3173
+ if (!isInsideCalculator) {
3174
+ storingEachActivityScore(isCorrect);
3175
+ }
3055
3176
  handleShowCheck();
3056
3177
  return;
3057
3178
  }
@@ -3062,8 +3183,8 @@ function addClickListenerForClickType(element) {
3062
3183
  element.classList.remove('lido-element-selected');
3063
3184
  executeActions(element.getAttribute('onEntry'), element);
3064
3185
  selectedValue = selectedValue.filter(item => item != element['value']);
3065
- localStorage.setItem(SelectedValuesKey, JSON.stringify(selectedValue));
3066
- let multiOptionScore = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
3186
+ container.setAttribute(SelectedValuesKey, JSON.stringify([element['value']]));
3187
+ let multiOptionScore = buildDragSelectedMapFromDOM();
3067
3188
  const valueToRemove = element['value'];
3068
3189
  const keyToRemove = Object.keys(multiOptionScore).find(key => multiOptionScore[key].includes(valueToRemove));
3069
3190
  if (keyToRemove) {
@@ -3071,10 +3192,9 @@ function addClickListenerForClickType(element) {
3071
3192
  if (multiOptionScore[keyToRemove].length === 0) {
3072
3193
  delete multiOptionScore[keyToRemove];
3073
3194
  }
3074
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(multiOptionScore));
3075
3195
  const sortedKeys = Object.keys(multiOptionScore).sort((a, b) => parseInt(a) - parseInt(b));
3076
3196
  const sortedValues = sortedKeys.reduce((acc, key) => acc.concat(multiOptionScore[key]), []);
3077
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
3197
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
3078
3198
  }
3079
3199
  if (showCheck && selectedValue.length === 0) {
3080
3200
  checkButton.classList.add('lido-disable-check-button');
@@ -3085,20 +3205,18 @@ function addClickListenerForClickType(element) {
3085
3205
  element.classList.add('lido-element-selected');
3086
3206
  const valueToFind = element['value'];
3087
3207
  const key = Object.keys(objective).find(key => objective[key] === valueToFind);
3088
- let multiOptionScore = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
3208
+ let multiOptionScore = buildDragSelectedMapFromDOM();
3089
3209
  if (!key) {
3090
3210
  multiOptionScore[objective.length + selectedValue.length] = [valueToFind];
3091
3211
  }
3092
3212
  else {
3093
3213
  multiOptionScore[key] = [valueToFind];
3094
3214
  }
3095
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(multiOptionScore));
3096
3215
  const sortedKeys = Object.keys(multiOptionScore).sort((a, b) => parseInt(a) - parseInt(b));
3097
3216
  const sortedValues = sortedKeys.reduce((acc, key) => acc.concat(multiOptionScore[key]), []);
3098
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
3217
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
3099
3218
  const isCorrect = objective.includes(element['value']);
3100
3219
  dispatchClickEvent(element, isCorrect);
3101
- AudioPlayer.getI().stop();
3102
3220
  if (isCorrect) {
3103
3221
  const onCorrect = element.getAttribute('onCorrect');
3104
3222
  await executeActions(onCorrect, element);
@@ -3110,8 +3228,11 @@ function addClickListenerForClickType(element) {
3110
3228
  }
3111
3229
  storingEachActivityScore(isCorrect);
3112
3230
  }
3113
- if (!showCheck && countPatternWords(objective) === countPatternWords(selectedValue)) {
3114
- validateObjectiveStatus();
3231
+ const isInsideCalculator = element.closest('#lidoCalculator') !== null;
3232
+ if (!isInsideCalculator) {
3233
+ if (!showCheck && countPatternWords(objective) === countPatternWords(selectedValue)) {
3234
+ validateObjectiveStatus();
3235
+ }
3115
3236
  }
3116
3237
  };
3117
3238
  element.addEventListener('click', onClick);
@@ -67929,7 +68050,431 @@ function calculateFill(input, currentFill = 0) {
67929
68050
  return Math.max(0, Math.min(100, value));
67930
68051
  }
67931
68052
 
68053
+ // Helper to animate and remove the active equation cell
68054
+ const animationToRemoveEquationSolvedCellForNimbleTable = (activeCell, allCalculateTypes) => {
68055
+ return new Promise((resolve) => {
68056
+ const keyframes = `
68057
+ @keyframes widthDecrease {
68058
+ 0% {
68059
+ background-color: ${activeCell.style.backgroundColor};
68060
+ height: ${activeCell.style.height};
68061
+ margin: ${activeCell.style.margin};
68062
+ ${activeCell.innerHTML = ""}
68063
+ }
68064
+ 100% { background-color: transparent; height: 0px; margin: 0px; }
68065
+ }`;
68066
+ const styleSheet = document.styleSheets[0];
68067
+ styleSheet.insertRule(keyframes, styleSheet.cssRules.length);
68068
+ activeCell.style.animation = `widthDecrease 0.1s`;
68069
+ activeCell.addEventListener('animationend', () => {
68070
+ activeCell.style.height = '0px';
68071
+ activeCell.style.margin = '0px';
68072
+ activeCell.style.backgroundColor = 'transparent';
68073
+ activeCell.remove();
68074
+ // Trigger next container if last cell
68075
+ if (allCalculateTypes.length === 1) {
68076
+ setTimeout(() => triggerNextContainer(), 2000);
68077
+ }
68078
+ resolve();
68079
+ });
68080
+ });
68081
+ };
68082
+ // Function: checks and animates equation when correct
68083
+ const checkEquationOfActiveCell = async (container) => {
68084
+ var _a;
68085
+ const calculatorValue = (_a = container.querySelector("#lidoCalculator")) === null || _a === void 0 ? void 0 : _a.getAttribute("value");
68086
+ const allCalculateTypes = document.querySelectorAll("[type='calculate']");
68087
+ const activeCell = allCalculateTypes[0];
68088
+ const activeCellValue = Number(activeCell["value"]);
68089
+ const calculteValue = Number(calculatorValue);
68090
+ if (!activeCell || calculteValue !== activeCellValue)
68091
+ return;
68092
+ const equation = activeCell["string"];
68093
+ // Replace equation after a short delay
68094
+ //await new Promise(r => setTimeout(r, 200));
68095
+ activeCell.innerHTML = equation.replaceAll("?", calculteValue);
68096
+ const element2 = container.querySelector("#dummy112");
68097
+ element2.innerHTML = activeCell.innerHTML;
68098
+ // Animate and clean up
68099
+ await animationToRemoveEquationSolvedCellForNimbleTable(activeCell, allCalculateTypes);
68100
+ };
68101
+ // Function: handles equation check when clicked on OK
68102
+ let score = 0;
68103
+ const handleSolvedEquationSubmissionAndScoreUpdate = async () => {
68104
+ var _a;
68105
+ const container = document.getElementById('lido-container');
68106
+ const calculatorValue = (_a = container.querySelector("#lidoCalculator")) === null || _a === void 0 ? void 0 : _a.getAttribute("value");
68107
+ const allCalculateTypes = document.querySelectorAll("[type='calculate']");
68108
+ const activeCell = allCalculateTypes[0];
68109
+ const isContinueOnCorrect = container.getAttribute("is-continue-on-correct") === "true";
68110
+ const activeCellValue = Number(activeCell["value"]);
68111
+ const calculteValue = Number(calculatorValue);
68112
+ const element1 = container.querySelector("#dummy111");
68113
+ const element2 = container.querySelector("#dummy112");
68114
+ // PRACTICE MODE (continue only if correct)
68115
+ if (isContinueOnCorrect) {
68116
+ if (element2.innerHTML.length > 0 && activeCellValue === calculteValue) {
68117
+ element1.innerHTML = element2.innerHTML;
68118
+ }
68119
+ await checkEquationOfActiveCell(container);
68120
+ }
68121
+ // TEST MODE (store all, animate regardless of correctness)
68122
+ else {
68123
+ if (calculatorValue.length > 0) {
68124
+ if (calculatorValue === activeCell["value"]) {
68125
+ score++;
68126
+ console.log("SCOREEEE", score);
68127
+ }
68128
+ else {
68129
+ if (score > 0) {
68130
+ score--;
68131
+ }
68132
+ console.log("SCOREEEE", score);
68133
+ }
68134
+ if (element2.innerHTML.length > 0) {
68135
+ element1.innerHTML = element2.innerHTML;
68136
+ }
68137
+ const equation = activeCell["string"];
68138
+ // Replace value visually
68139
+ activeCell.innerHTML = equation.replaceAll("?", calculteValue);
68140
+ element2.innerHTML = activeCell.innerHTML;
68141
+ // Animate
68142
+ await animationToRemoveEquationSolvedCellForNimbleTable(activeCell, allCalculateTypes);
68143
+ }
68144
+ }
68145
+ };
68146
+
68147
+ function handlingMatrix(element) {
68148
+ const container = document.querySelector(LidoContainer);
68149
+ if (!container)
68150
+ return;
68151
+ const defualtMatrix = element;
68152
+ adjustSizeForSlots(container, defualtMatrix);
68153
+ splitSlots(container, defualtMatrix);
68154
+ }
68155
+ const splitSlots = (container, defualtMatrix) => {
68156
+ const defualtElements = defualtMatrix.querySelectorAll('.slot');
68157
+ const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
68158
+ const allDragMatrixes = container.querySelectorAll('lido-math-matrix[type="drag"]');
68159
+ let slot = 1;
68160
+ for (let i = 0; i < allDropMatrixes.length; i++) {
68161
+ const el = allDropMatrixes[i];
68162
+ const rowCount = el.getAttribute('rows') ? parseInt(el.getAttribute('rows')) : 1;
68163
+ const colCount = el.getAttribute('cols') ? parseInt(el.getAttribute('cols')) : 1;
68164
+ if (rowCount === 1 || colCount === 1) {
68165
+ if (rowCount === colCount) {
68166
+ const numbers = Array.from({ length: 100 }, (_, i) => i + 1)
68167
+ .sort(() => Math.random() - 0.5) // Shuffle
68168
+ .slice(0, 10); // Take first 10 unique numbers
68169
+ allDropMatrixes.forEach((item, index) => {
68170
+ const dropElement = item;
68171
+ const dropPosition = defualtElements[numbers[index]];
68172
+ // Safeguard if index > available numbers
68173
+ if (!dropPosition)
68174
+ return;
68175
+ postioningDropElement(dropElement, dropPosition);
68176
+ const dragElement = allDragMatrixes[index];
68177
+ dragElement.setAttribute('text', (numbers[index] + 1).toString());
68178
+ });
68179
+ // return;
68180
+ }
68181
+ if (rowCount === 2 && colCount === 1) {
68182
+ const pairs = generateDoubleSquares(10);
68183
+ console.log('pairs double : ', pairs);
68184
+ allDropMatrixes.forEach((item, index) => {
68185
+ const dropElement = item;
68186
+ const dropPosition = defualtElements[pairs[index][0] - 1];
68187
+ postioningDropElement(dropElement, dropPosition);
68188
+ });
68189
+ allDragMatrixes.forEach((item, index) => {
68190
+ const dragElement = item;
68191
+ dragElement.setAttribute('text', pairs[index].toString());
68192
+ });
68193
+ break;
68194
+ }
68195
+ if (rowCount === 5) {
68196
+ const dropPositionElements = generateHalfHorizontalStripes(i);
68197
+ const dropPosition = defualtElements[dropPositionElements[0] - 1];
68198
+ const dragElement = allDragMatrixes[i];
68199
+ dragElement.setAttribute('text', dropPositionElements.toString());
68200
+ postioningDropElement(el, dropPosition);
68201
+ }
68202
+ if (rowCount === 10) {
68203
+ const dropPosition = defualtElements[slot];
68204
+ const dragElement = allDragMatrixes[i];
68205
+ dragElement.setAttribute('text', Array.from({ length: 10 }, (_, i) => slot + 1 + i * 10).toString());
68206
+ postioningDropElement(el, dropPosition);
68207
+ slot = slot + 2;
68208
+ }
68209
+ else if (colCount === 10) {
68210
+ const dropPosition = defualtElements[10 + (slot - 1)];
68211
+ const dragElement = allDragMatrixes[i];
68212
+ dragElement.setAttribute('text', Array.from({ length: 10 }, (_, i) => i + 10 + slot).toString());
68213
+ postioningDropElement(el, dropPosition);
68214
+ slot = slot + 20;
68215
+ }
68216
+ }
68217
+ else if (rowCount === 3 || colCount === 3) {
68218
+ const slotCell = generateSlotsFromDrops(container);
68219
+ const cellNumbers = Object.keys(slotCell).map(key => slotCell[key].cells);
68220
+ allDragMatrixes.forEach((matrix, index) => {
68221
+ const dragElement = matrix;
68222
+ // let dragTextAttr = dragElement.getAttribute('text');
68223
+ if (dragElement) {
68224
+ dragElement.setAttribute('text', cellNumbers[index].toString());
68225
+ }
68226
+ });
68227
+ allDropMatrixes.forEach((matrix, index) => {
68228
+ const dropElement = matrix;
68229
+ const dropPosition = defualtElements[slotCell[`slot-${index + 1}`].cells[0] - 1];
68230
+ postioningDropElement(dropElement, dropPosition);
68231
+ });
68232
+ break; // stops the loop immediately
68233
+ }
68234
+ else if (rowCount === 2 || colCount === 2) {
68235
+ if (rowCount === colCount) {
68236
+ const pairs = generate2by2Squares(10);
68237
+ allDropMatrixes.forEach((item, index) => {
68238
+ const dropElement = item;
68239
+ const dropPosition = defualtElements[pairs[index][0] - 1];
68240
+ postioningDropElement(dropElement, dropPosition);
68241
+ });
68242
+ allDragMatrixes.forEach((item, index) => {
68243
+ const dragElement = item;
68244
+ dragElement.setAttribute('text', pairs[index].toString());
68245
+ });
68246
+ break;
68247
+ }
68248
+ }
68249
+ }
68250
+ };
68251
+ function generateSlotsFromDrops(container) {
68252
+ const gridSize = 10;
68253
+ let availableCells = Array.from({ length: 100 }, (_, i) => i + 1);
68254
+ const occupied = new Set();
68255
+ const slots = {};
68256
+ let generated = 0;
68257
+ const getCell = (row, col) => row * gridSize + col + 1;
68258
+ // Get all <lido-math-matrix type="drop">
68259
+ const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
68260
+ for (const matrix of Array.from(allDropMatrixes)) {
68261
+ const width = parseInt(matrix.getAttribute('cols') || '1');
68262
+ const height = parseInt(matrix.getAttribute('rows') || '1');
68263
+ const possiblePositions = [];
68264
+ // generate all possible top-left positions
68265
+ for (let row = 0; row <= gridSize - height; row++) {
68266
+ for (let col = 0; col <= gridSize - width; col++) {
68267
+ const cells = [];
68268
+ let canPlace = true;
68269
+ for (let r = 0; r < height; r++) {
68270
+ for (let c = 0; c < width; c++) {
68271
+ const cell = getCell(row + r, col + c);
68272
+ if (occupied.has(cell)) {
68273
+ canPlace = false;
68274
+ break;
68275
+ }
68276
+ cells.push(cell);
68277
+ }
68278
+ if (!canPlace)
68279
+ break;
68280
+ }
68281
+ if (canPlace)
68282
+ possiblePositions.push(cells);
68283
+ }
68284
+ }
68285
+ if (possiblePositions.length === 0) {
68286
+ console.warn(`No space left for matrix ${generated + 1}`);
68287
+ continue;
68288
+ }
68289
+ // Pick a random valid position
68290
+ const randomCells = possiblePositions[Math.floor(Math.random() * possiblePositions.length)];
68291
+ // Mark as occupied & remove from available
68292
+ randomCells.forEach(c => {
68293
+ occupied.add(c);
68294
+ availableCells = availableCells.filter(x => x !== c);
68295
+ });
68296
+ generated++;
68297
+ slots[`slot-${generated}`] = { cells: randomCells, width, height };
68298
+ }
68299
+ return slots;
68300
+ }
68301
+ const postioningDropElement = (dropElement, dropPosition) => {
68302
+ const container = document.getElementById(LidoContainer);
68303
+ const containerScale = getElementScale$1(container);
68304
+ dropElement.style.transform = 'translate(0,0)';
68305
+ const posRect = dropPosition.getBoundingClientRect();
68306
+ const dropRect = dropElement.getBoundingClientRect();
68307
+ const posCenterX = posRect.left + posRect.width / 2;
68308
+ const posCenterY = posRect.top + posRect.height / 2;
68309
+ const dropCenterX = dropRect.left + dropRect.width / 2;
68310
+ const dropCenterY = dropRect.top + dropRect.height / 2;
68311
+ const scaledLeft = (posCenterX - dropCenterX) / containerScale;
68312
+ const scaledTop = (posCenterY - dropCenterY) / containerScale;
68313
+ const rowCount = dropElement.getAttribute('rows') ? parseInt(dropElement.getAttribute('rows')) : 1;
68314
+ const colCount = dropElement.getAttribute('cols') ? parseInt(dropElement.getAttribute('cols')) : 1;
68315
+ const elementWidth = parseInt(dropPosition.style.width);
68316
+ if (rowCount === 1 || colCount === 1) {
68317
+ if (rowCount === colCount) {
68318
+ dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop}px)`;
68319
+ return;
68320
+ }
68321
+ else if (rowCount > colCount) {
68322
+ if (rowCount === 10) {
68323
+ dropElement.style.transform = `translate(${scaledLeft + (elementWidth * 4 + elementWidth / 2)}px, ${scaledTop}px)`;
68324
+ }
68325
+ else if (rowCount === 5) {
68326
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth * 2}px, ${scaledTop}px)`;
68327
+ }
68328
+ else if (rowCount === 2) {
68329
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop}px)`;
68330
+ }
68331
+ }
68332
+ else if (rowCount < colCount) {
68333
+ if (colCount === 10) {
68334
+ dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop + elementWidth * 4 + elementWidth * 0.2 + elementWidth / 2}px)`;
68335
+ }
68336
+ else if (colCount === 5) {
68337
+ dropElement.style.transform = `translate(${scaledLeft}px, ${scaledTop + elementWidth * 2 + elementWidth * 0.0921}px)`;
68338
+ }
68339
+ }
68340
+ return;
68341
+ }
68342
+ if (rowCount === colCount) {
68343
+ if (rowCount === 2) {
68344
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop + elementWidth / 2 + 4}px)`;
68345
+ return;
68346
+ }
68347
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop + elementWidth + 4}px)`;
68348
+ return;
68349
+ }
68350
+ if (rowCount === 3) {
68351
+ if (colCount === 2) {
68352
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop + elementWidth / 2 + 4}px)`;
68353
+ return;
68354
+ }
68355
+ else if (colCount === 1) {
68356
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth}px, ${scaledTop}px)`;
68357
+ return;
68358
+ }
68359
+ }
68360
+ if (rowCount === 2) {
68361
+ if (colCount === 3) {
68362
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop + elementWidth + 4}px)`;
68363
+ return;
68364
+ }
68365
+ else if (colCount === 1) {
68366
+ dropElement.style.transform = `translate(${scaledLeft + elementWidth / 2}px, ${scaledTop}px)`;
68367
+ return;
68368
+ }
68369
+ }
68370
+ };
68371
+ const adjustSizeForSlots = (container, defualtMatrix) => {
68372
+ const defualtElement = defualtMatrix.querySelector('.slot');
68373
+ const width = defualtElement.style.width;
68374
+ const allDropMatrixes = container.querySelectorAll('lido-math-matrix[type="drop"]');
68375
+ const allDragMatrixes = container.querySelectorAll('lido-math-matrix[type="drag"]');
68376
+ allDragMatrixes.forEach(item => {
68377
+ const el = item;
68378
+ Array.from(el.querySelectorAll('.slot')).forEach(slot => {
68379
+ const slotEl = slot;
68380
+ slotEl.parentElement.style.width = width;
68381
+ slotEl.style.width = width;
68382
+ slotEl.style.height = width;
68383
+ });
68384
+ });
68385
+ allDropMatrixes.forEach(item => {
68386
+ const el = item;
68387
+ Array.from(el.querySelectorAll('.slot')).forEach(slot => {
68388
+ const slotEl = slot;
68389
+ slotEl.parentElement.style.width = width;
68390
+ slotEl.style.width = width;
68391
+ slotEl.style.height = width;
68392
+ });
68393
+ });
68394
+ };
68395
+ function generateHalfHorizontalStripes(index) {
68396
+ const numbers = Array.from({ length: 10 }, (_, i) => index + 1 + i * 10);
68397
+ const randomPlace = Math.floor(Math.random() * 6);
68398
+ const startSlot = numbers[randomPlace];
68399
+ console.log('kedachuruchu', Array.from({ length: 5 }, (_, i) => startSlot + i * 10));
68400
+ return Array.from({ length: 5 }, (_, i) => startSlot + i * 10);
68401
+ }
68402
+ function generate2by2Squares(count = 16) {
68403
+ const gridSize = 10;
68404
+ const squares = [];
68405
+ const usedCells = new Set();
68406
+ function getCell(row, col) {
68407
+ return (row - 1) * gridSize + col;
68408
+ }
68409
+ while (squares.length < count) {
68410
+ const row = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
68411
+ const col = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
68412
+ const square = [getCell(row, col), getCell(row, col + 1), getCell(row + 1, col), getCell(row + 1, col + 1)];
68413
+ // Skip if overlapping with previous
68414
+ if (square.some(cell => usedCells.has(cell)))
68415
+ continue;
68416
+ // Mark cells as used
68417
+ square.forEach(cell => usedCells.add(cell));
68418
+ squares.push(square);
68419
+ }
68420
+ return squares;
68421
+ }
68422
+ function generateDoubleSquares(count = 16) {
68423
+ const gridSize = 10;
68424
+ const pairs = [];
68425
+ const usedCells = new Set();
68426
+ function getCell(row, col) {
68427
+ return (row - 1) * gridSize + col;
68428
+ }
68429
+ while (pairs.length < count) {
68430
+ const row = Math.floor(Math.random() * (gridSize - 1)) + 1; // 1–9
68431
+ const col = Math.floor(Math.random() * gridSize) + 1; // 1–10
68432
+ const top = getCell(row, col);
68433
+ const bottom = getCell(row + 1, col);
68434
+ // Skip if already used
68435
+ if (usedCells.has(top) || usedCells.has(bottom))
68436
+ continue;
68437
+ pairs.push([top, bottom]);
68438
+ usedCells.add(top);
68439
+ usedCells.add(bottom);
68440
+ }
68441
+ return pairs;
68442
+ }
68443
+
67932
68444
  const gameScore = new GameScore();
68445
+ function buildDragSelectedMapFromDOM() {
68446
+ const map = {};
68447
+ const draggedEls = document.querySelectorAll(`[${DropToAttr}]`);
68448
+ draggedEls.forEach(dragEl => {
68449
+ var _a, _b, _c;
68450
+ const to = dragEl.getAttribute(DropToAttr);
68451
+ if (!to)
68452
+ return;
68453
+ const dropEl = document.getElementById(to);
68454
+ if (!dropEl)
68455
+ return;
68456
+ const tabIndex = (_a = dropEl.getAttribute('tab-index')) !== null && _a !== void 0 ? _a : to;
68457
+ if (!map[tabIndex])
68458
+ map[tabIndex] = [];
68459
+ const value = (_c = (_b = dragEl.getAttribute('value')) !== null && _b !== void 0 ? _b : dragEl.value) !== null && _c !== void 0 ? _c : '';
68460
+ map[tabIndex].push(value);
68461
+ });
68462
+ return map;
68463
+ }
68464
+ function getSortedValuesArrayFromMap(map) {
68465
+ const sortedKeys = Object.keys(map).sort((a, b) => parseInt(a) - parseInt(b));
68466
+ const sortedValues = sortedKeys.reduce((acc, key) => {
68467
+ const values = map[key];
68468
+ if (values.length > 1) {
68469
+ acc.push(`(${values.join('|')})`);
68470
+ }
68471
+ else {
68472
+ acc.push(values[0]);
68473
+ }
68474
+ return acc;
68475
+ }, []);
68476
+ return sortedValues;
68477
+ }
67933
68478
  function format(first, middle, last) {
67934
68479
  return (first || '') + (middle ? ` ${middle}` : '') + (last ? ` ${last}` : '');
67935
68480
  }
@@ -67974,12 +68519,16 @@ const initEventsForElement = async (element, type) => {
67974
68519
  enableOptionArea(element);
67975
68520
  break;
67976
68521
  }
68522
+ case 'checkerBlock': {
68523
+ handlingMatrix(element);
68524
+ break;
68525
+ }
67977
68526
  }
67978
68527
  onTouchListenerForOnTouch(element);
67979
68528
  };
67980
68529
  // Function to execute actions parsed from the onMatch string
67981
68530
  const executeActions = async (actionsString, thisElement, element) => {
67982
- var _a;
68531
+ var _a, _b, _c, _d, _e, _f, _g;
67983
68532
  const actions = parseActions(actionsString);
67984
68533
  for (let i = 0; i < actions.length; i++) {
67985
68534
  const action = actions[i];
@@ -67993,13 +68542,25 @@ const executeActions = async (actionsString, thisElement, element) => {
67993
68542
  targetElement.style.transform = currentTransform !== 'none' ? `${currentTransform} ${action.value}` : action.value;
67994
68543
  break;
67995
68544
  }
68545
+ case 'revealImageValue': {
68546
+ if (targetElement) {
68547
+ revealImageValue(targetElement); // call your function here
68548
+ }
68549
+ break;
68550
+ }
68551
+ case 'scrollCellAfterEquationSolved': {
68552
+ if (targetElement) {
68553
+ handleSolvedEquationSubmissionAndScoreUpdate();
68554
+ }
68555
+ break;
68556
+ }
67996
68557
  case 'alignMatch': {
67997
68558
  const dropElement = targetElement;
67998
68559
  const dragElement = element;
67999
68560
  const container = document.getElementById(LidoContainer);
68000
68561
  const containerScale = getElementScale$1(container);
68001
68562
  dragElement.style.transform = 'translate(0,0)';
68002
- console.log('logg alinmatch');
68563
+ console.log("logg alinmatch");
68003
68564
  const dropRect = dropElement.getBoundingClientRect();
68004
68565
  const dragRect = dragElement.getBoundingClientRect();
68005
68566
  const dropCenterX = dropRect.left + dropRect.width / 2;
@@ -68085,10 +68646,76 @@ const executeActions = async (actionsString, thisElement, element) => {
68085
68646
  }
68086
68647
  break;
68087
68648
  }
68649
+ case 'highlightStarsAndDisapper': {
68650
+ const value = action.value;
68651
+ if (value && targetElement) {
68652
+ console.log('highlightStar action triggered');
68653
+ console.log('Target Element:', targetElement);
68654
+ await HighlightStarsOneByOne(targetElement, value);
68655
+ }
68656
+ break;
68657
+ }
68658
+ case 'boxAnimationOneByOne': {
68659
+ const value = action.value;
68660
+ if (value && targetElement) {
68661
+ await animateBoxCells(targetElement, value);
68662
+ }
68663
+ break;
68664
+ }
68665
+ case 'questionBoxAnimate': {
68666
+ const value = action.value;
68667
+ if (value && targetElement) {
68668
+ await questionBoxAnimation(targetElement, value);
68669
+ }
68670
+ break;
68671
+ }
68088
68672
  case 'slideAnimation': {
68089
68673
  slideAnimation();
68090
68674
  break;
68091
68675
  }
68676
+ case 'showBalanceSymbol': {
68677
+ const balanceEl = document.querySelector('lido-balance');
68678
+ if (!balanceEl)
68679
+ break;
68680
+ const leftVal = Number((_b = balanceEl.leftVal) !== null && _b !== void 0 ? _b : Number((_d = (_c = balanceEl.dataset) === null || _c === void 0 ? void 0 : _c.leftVal) !== null && _d !== void 0 ? _d : 0));
68681
+ const rightVal = Number((_e = balanceEl.rightVal) !== null && _e !== void 0 ? _e : Number((_g = (_f = balanceEl.dataset) === null || _f === void 0 ? void 0 : _f.rightVal) !== null && _g !== void 0 ? _g : 0));
68682
+ const symbol = leftVal > rightVal ? '>' : leftVal < rightVal ? '<' : '=';
68683
+ balanceEl.balanceSymbol = symbol;
68684
+ balanceEl.dataset.balanceSymbol = symbol;
68685
+ if (balanceEl.revealSymbol) {
68686
+ await balanceEl.revealSymbol();
68687
+ }
68688
+ else {
68689
+ balanceEl.showSymbol = true;
68690
+ }
68691
+ break;
68692
+ }
68693
+ case 'hideBalanceSymbol': {
68694
+ const balanceEl = document.querySelector('lido-balance');
68695
+ if (!balanceEl)
68696
+ break;
68697
+ if (balanceEl.hideSymbol) {
68698
+ await balanceEl.hideSymbol();
68699
+ }
68700
+ else {
68701
+ balanceEl.showSymbol = false;
68702
+ }
68703
+ break;
68704
+ }
68705
+ case 'sumTogetherAnimation': {
68706
+ const value = action.value;
68707
+ if (value) {
68708
+ SumTogetherAnimation(targetElement, value);
68709
+ }
68710
+ break;
68711
+ }
68712
+ case 'addText': {
68713
+ const value = action.value;
68714
+ if (value) {
68715
+ targetElement.textContent += value;
68716
+ }
68717
+ break;
68718
+ }
68092
68719
  default: {
68093
68720
  targetElement.style[action.action] = action.value;
68094
68721
  break;
@@ -68186,6 +68813,9 @@ const matchStringPattern = (pattern, arr) => {
68186
68813
  const patternGroups = pattern.split(',').map(group => group.trim());
68187
68814
  let arrIndex = 0;
68188
68815
  let options = new Set();
68816
+ if (patternGroups.length == 0) { // If pattern is empty
68817
+ return true;
68818
+ }
68189
68819
  if (patternGroups.length > 0) {
68190
68820
  if (arr.length === 0)
68191
68821
  return false; // If pattern is not empty but user provided array is empty, return false
@@ -68270,38 +68900,36 @@ const calculateScore = () => {
68270
68900
  gameScore.wrongMoves = 0;
68271
68901
  };
68272
68902
  async function onActivityComplete(dragElement, dropElement) {
68273
- var _a, _b;
68903
+ var _a;
68274
68904
  const container = document.getElementById(LidoContainer);
68275
68905
  if (!container)
68276
68906
  return;
68277
68907
  await executeActions("this.alignMatch='true'", dropElement, dragElement);
68278
- let dragScore = JSON.parse((_a = localStorage.getItem(DragSelectedMapKey)) !== null && _a !== void 0 ? _a : '{}');
68279
- const tabindex = dropElement.getAttribute('tab-index');
68280
- if (!dragScore[tabindex]) {
68281
- dragScore[tabindex] = [];
68908
+ if (dragElement && dropElement) {
68909
+ const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
68910
+ if (isCorrect) {
68911
+ const onCorrect = dropElement.getAttribute('onCorrect');
68912
+ if (onCorrect) {
68913
+ await executeActions(onCorrect, dropElement, dragElement);
68914
+ }
68915
+ }
68916
+ else {
68917
+ const onInCorrect = dropElement.getAttribute('onInCorrect');
68918
+ await executeActions(onInCorrect, dropElement, dragElement);
68919
+ }
68282
68920
  }
68283
- dragScore[tabindex].push(dragElement['value']);
68284
- localStorage.setItem(DragSelectedMapKey, JSON.stringify(dragScore));
68921
+ let dragScore = buildDragSelectedMapFromDOM();
68922
+ const sortedValues = getSortedValuesArrayFromMap(dragScore);
68923
+ container.setAttribute(SelectedValuesKey, JSON.stringify(sortedValues));
68285
68924
  //localStorage
68286
- let drag = JSON.parse((_b = localStorage.getItem(DragMapKey)) !== null && _b !== void 0 ? _b : '{}');
68925
+ let drag = JSON.parse((_a = localStorage.getItem(DragMapKey)) !== null && _a !== void 0 ? _a : '{}');
68287
68926
  const index = dropElement.getAttribute('tab-index');
68288
68927
  if (!drag[index]) {
68289
68928
  drag[index] = [];
68290
68929
  }
68291
68930
  drag[index].push(dragElement.id);
68292
68931
  // localStorage.setItem(DragMapKey, JSON.stringify(drag));
68293
- const sortedKeys = Object.keys(dragScore).sort((a, b) => parseInt(a) - parseInt(b));
68294
- const sortedValues = sortedKeys.reduce((acc, key) => {
68295
- const values = dragScore[key];
68296
- if (values.length > 1) {
68297
- acc.push(`(${values.join('|')})`);
68298
- }
68299
- else {
68300
- acc.push(values[0]);
68301
- }
68302
- return acc;
68303
- }, []);
68304
- localStorage.setItem(SelectedValuesKey, JSON.stringify(sortedValues));
68932
+ Object.keys(dragScore).sort((a, b) => parseInt(a) - parseInt(b));
68305
68933
  if (dragElement && dropElement) {
68306
68934
  const isCorrect = dropElement['value'].toLowerCase().includes(dragElement['value'].toLowerCase());
68307
68935
  if (isCorrect) {
@@ -68318,8 +68946,7 @@ async function onActivityComplete(dragElement, dropElement) {
68318
68946
  const allElements = document.querySelectorAll("[type='drop']");
68319
68947
  allElements.forEach(otherElement => {
68320
68948
  var _a;
68321
- const dropObject = JSON.parse(localStorage.getItem(DragSelectedMapKey)) || {};
68322
- const storedTabIndexes = Object.keys(dropObject).map(Number);
68949
+ const storedTabIndexes = Object.keys(dragScore).map(Number);
68323
68950
  if (storedTabIndexes.includes(JSON.parse(otherElement.getAttribute('tab-index')))) {
68324
68951
  if (!(((_a = otherElement.getAttribute('dropAttr')) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === DropMode.Diagonal)) {
68325
68952
  if (otherElement.tagName.toLowerCase() === 'lido-text') {
@@ -68371,81 +68998,101 @@ const handleShowCheck = () => {
68371
68998
  var _a, _b;
68372
68999
  const container = document.getElementById(LidoContainer);
68373
69000
  const objectiveString = container['objective'];
68374
- const selectValues = (_a = localStorage.getItem(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '';
69001
+ const selectValues = (_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '';
68375
69002
  const checkButton = document.querySelector('#lido-checkButton');
68376
- if (!selectValues || countPatternWords(selectValues) !== countPatternWords(objectiveString)) {
69003
+ if (!selectValues || countPatternWords(selectValues) < countPatternWords(objectiveString)) {
68377
69004
  executeActions("this.addClass='lido-disable-check-button'", checkButton);
68378
69005
  return;
68379
69006
  }
68380
69007
  const showCheck = container.getAttribute('show-check') == 'true';
68381
69008
  if (showCheck) {
68382
69009
  (_b = checkButton === null || checkButton === void 0 ? void 0 : checkButton.classList) === null || _b === void 0 ? void 0 : _b.remove('lido-disable-check-button');
69010
+ const balanceEl = document.querySelector('lido-balance');
69011
+ if (balanceEl) {
69012
+ if (!checkButton.hasAttribute('data-balance-listener')) {
69013
+ checkButton.addEventListener('click', async function onClick() {
69014
+ if (balanceResult && res) {
69015
+ await executeActions("this.showBalanceSymbol='true'", checkButton);
69016
+ checkButton.removeEventListener('click', onClick);
69017
+ }
69018
+ });
69019
+ checkButton.setAttribute('data-balance-listener', 'true');
69020
+ }
69021
+ }
68383
69022
  }
68384
69023
  else {
68385
69024
  validateObjectiveStatus();
68386
69025
  }
68387
69026
  };
68388
- const body = document.body;
69027
+ let res;
68389
69028
  const validateObjectiveStatus = async () => {
68390
- var _a;
69029
+ var _a, _b;
68391
69030
  const container = document.getElementById(LidoContainer);
68392
69031
  if (!container)
68393
69032
  return;
68394
69033
  const objectiveString = container['objective'];
69034
+ const additionalCheck = container.getAttribute('equationCheck');
69035
+ console.log('🚀 ~ validateObjectiveStatus ~ additionalCheck:', additionalCheck);
69036
+ let equationGiven = false;
68395
69037
  if (objectiveString == null || objectiveString.length === 0) {
68396
- const onCorrect = container.getAttribute('onCorrect');
68397
- if (onCorrect) {
68398
- await executeActions(onCorrect, container);
69038
+ if (additionalCheck) {
69039
+ equationGiven = true;
69040
+ }
69041
+ if (!equationGiven) {
69042
+ const onCorrect = container.getAttribute('onCorrect');
69043
+ if (onCorrect) {
69044
+ await executeActions(onCorrect, container);
69045
+ }
69046
+ storeActivityScore(100);
69047
+ storingEachActivityScore(true);
69048
+ triggerNextContainer();
69049
+ return;
68399
69050
  }
68400
- storeActivityScore(100);
68401
- storingEachActivityScore(true);
68402
- triggerNextContainer();
68403
- return;
68404
69051
  }
68405
- else {
68406
- const objectiveArray = (_a = JSON.parse(localStorage.getItem(SelectedValuesKey))) !== null && _a !== void 0 ? _a : [];
68407
- let res;
68408
- const additionalCheck = container.getAttribute('equationCheck');
68409
- if (!!additionalCheck) {
69052
+ const objectiveArray = (_b = JSON.parse((_a = container.getAttribute(SelectedValuesKey)) !== null && _a !== void 0 ? _a : '[]')) !== null && _b !== void 0 ? _b : [];
69053
+ if (!!additionalCheck) {
69054
+ const balanceEl = document.querySelector('lido-balance');
69055
+ if (!balanceEl) {
68410
69056
  res = equationCheck(additionalCheck);
68411
- console.log('🚀 ~ handleShowCheck ~ res:', res);
68412
69057
  }
68413
69058
  else {
68414
- res = matchStringPattern(objectiveString, objectiveArray);
69059
+ res = balanceResult(container, objectiveString);
68415
69060
  }
68416
- if (res) {
68417
- const attach = container.getAttribute('appendToDropOnCompletion');
68418
- body.style.pointerEvents = 'none';
68419
- const onCorrect = container.getAttribute('onCorrect');
68420
- if (onCorrect) {
68421
- if (attach === 'true') {
68422
- appendingDragElementsInDrop();
68423
- }
68424
- await executeActions(onCorrect, container);
68425
- }
68426
- if (container.getAttribute('dropAttr') === 'EnableAnimation') {
68427
- setTimeout(() => {
68428
- triggerNextContainer();
68429
- }, 2000);
69061
+ console.log('🚀 ~ handleShowCheck ~ res:', res);
69062
+ }
69063
+ else {
69064
+ res = matchStringPattern(objectiveString, objectiveArray);
69065
+ }
69066
+ if (res) {
69067
+ const attach = container.getAttribute('appendToDropOnCompletion');
69068
+ const onCorrect = container.getAttribute('onCorrect');
69069
+ if (onCorrect) {
69070
+ if (attach === 'true') {
69071
+ appendingDragElementsInDrop();
68430
69072
  }
68431
- else {
69073
+ await executeActions(onCorrect, container);
69074
+ }
69075
+ if (container.getAttribute('dropAttr') === 'EnableAnimation') {
69076
+ setTimeout(() => {
68432
69077
  triggerNextContainer();
68433
- }
68434
- await calculateScore();
69078
+ }, 2000);
68435
69079
  }
68436
69080
  else {
68437
- const onInCorrect = container.getAttribute('onInCorrect');
68438
- await executeActions(onInCorrect, container);
68439
- const isContinueOnCorrect = container.getAttribute('is-continue-on-correct') === 'true';
68440
- if (!isContinueOnCorrect) {
68441
- triggerNextContainer();
68442
- await calculateScore();
68443
- }
69081
+ triggerNextContainer();
69082
+ }
69083
+ await calculateScore();
69084
+ }
69085
+ else {
69086
+ const onInCorrect = container.getAttribute('onInCorrect');
69087
+ await executeActions(onInCorrect, container);
69088
+ const isContinueOnCorrect = container.getAttribute('is-continue-on-correct') === 'true';
69089
+ if (!isContinueOnCorrect) {
69090
+ triggerNextContainer();
69091
+ await calculateScore();
68444
69092
  }
68445
69093
  }
68446
69094
  };
68447
69095
  const triggerNextContainer = () => {
68448
- body.style.pointerEvents = 'auto';
68449
69096
  AudioPlayer.getI().stop();
68450
69097
  // const event = new CustomEvent('nextContainer');
68451
69098
  console.log('🚀 ~ triggerNextContainer ~ event:', event);
@@ -68460,16 +69107,16 @@ const triggerPrevcontainer = () => {
68460
69107
  function convertUrlToRelative(url) {
68461
69108
  const container = document.getElementById(LidoContainer);
68462
69109
  const baseUrl = container.getAttribute('baseUrl');
68463
- if ((url === null || url === void 0 ? void 0 : url.startsWith('http')) || (url === null || url === void 0 ? void 0 : url.startsWith('blob')) || (url === null || url === void 0 ? void 0 : url.startsWith('data'))) {
69110
+ if ((url === null || url === void 0 ? void 0 : url.startsWith('http')) || (url === null || url === void 0 ? void 0 : url.startsWith('blob'))) {
68464
69111
  return url;
68465
69112
  }
68466
- if (baseUrl) {
68467
- const newUrl = url.startsWith('/') ? url.slice(1) : url;
68468
- if (newUrl.startsWith(baseUrl.replace(/^\/+|\/+$/g, '')))
68469
- return newUrl;
68470
- return baseUrl.endsWith('/') ? baseUrl + newUrl : `${baseUrl}/${newUrl}`;
69113
+ else if (baseUrl) {
69114
+ const newUrl = !url.startsWith('/') ? url : url.substring(1);
69115
+ return baseUrl + (baseUrl.endsWith('/') ? newUrl : '/' + newUrl);
69116
+ }
69117
+ else {
69118
+ return getAssetPath(url);
68471
69119
  }
68472
- return getAssetPath(url);
68473
69120
  }
68474
69121
  /**
68475
69122
  * Asynchronously speaks the given text using the browser's text-to-speech API.
@@ -68658,7 +69305,10 @@ const equationCheck = (additionalCheck) => {
68658
69305
  });
68659
69306
  // 3. Join the modified parts back into one string
68660
69307
  const resultString = modifiedParts.join('');
69308
+ console.log('🚀 ~ equationCheck ~ resultString:', resultString);
69309
+ // 4. Evaluate the final string as a mathematical expression
68661
69310
  const finalRes = evaluate(resultString);
69311
+ console.log('🚀 ~ equationCheck ~ finalRes:', finalRes);
68662
69312
  return finalRes;
68663
69313
  };
68664
69314
  const getElementsForQueries = (query) => {
@@ -68726,13 +69376,6 @@ const attachSpeakIcon = async (element) => {
68726
69376
  }
68727
69377
  element.appendChild(speakIconElement);
68728
69378
  };
68729
- const clearLocalStorage = () => {
68730
- localStorage.removeItem(DragSelectedMapKey);
68731
- localStorage.removeItem(DragMapKey);
68732
- localStorage.removeItem(SelectedValuesKey);
68733
- localStorage.removeItem(DropHasDrag);
68734
- localStorage.removeItem(DropLength);
68735
- };
68736
69379
  /**
68737
69380
  * Applies a delay to the element's visibility based on `delayVisible`.
68738
69381
  */
@@ -68818,5 +69461,229 @@ function generateUUIDFallback() {
68818
69461
  return v.toString(16);
68819
69462
  });
68820
69463
  }
69464
+ const revealImageValue = (imageEl) => {
69465
+ if (!imageEl)
69466
+ return;
69467
+ const value = imageEl.getAttribute('value');
69468
+ if (!value)
69469
+ return;
69470
+ let valueElement = imageEl.querySelector('.lido-display-hiddenvalue');
69471
+ if (!valueElement) {
69472
+ valueElement = document.createElement('div');
69473
+ valueElement.classList.add('lido-display-hiddenvalue');
69474
+ imageEl.style.position = 'relative';
69475
+ imageEl.appendChild(valueElement);
69476
+ }
69477
+ valueElement.innerText = value;
69478
+ };
69479
+ const setImageBackground = (el, color) => {
69480
+ if (!el)
69481
+ return;
69482
+ el.classList.add('lido-image-colorize');
69483
+ const img = el.querySelector('img');
69484
+ if (img) {
69485
+ // use same image as mask
69486
+ el.style.setProperty('--mask-url', `url(${img.src})`);
69487
+ }
69488
+ if (color === 'red') {
69489
+ el.style.setProperty('--tint-color', '#ff0000');
69490
+ }
69491
+ else if (color === 'green') {
69492
+ el.style.setProperty('--tint-color', '#00c853');
69493
+ }
69494
+ else {
69495
+ el.style.removeProperty('--tint-color');
69496
+ el.style.removeProperty('--mask-url');
69497
+ }
69498
+ };
69499
+ const HighlightStarsOneByOne = async (element, value) => {
69500
+ if (!element)
69501
+ return;
69502
+ if (!value)
69503
+ return;
69504
+ // Dynamically find the parent row of stars
69505
+ const stars = Array.from(element.children);
69506
+ console.log('starRow', stars);
69507
+ for (const star of stars) {
69508
+ // Highlight the star
69509
+ star.classList.add('lido-glow');
69510
+ // Play star sound
69511
+ await AudioPlayer.getI().play(star);
69512
+ // Fade out the star (disappear)
69513
+ star.style.opacity = '0';
69514
+ star.style.visibility = 'hidden';
69515
+ await new Promise(resolve => setTimeout(resolve, 300)); // Wait for fade-out to complete
69516
+ // Remove the highlight
69517
+ star.classList.remove('lido-glow');
69518
+ }
69519
+ };
69520
+ const animateBoxCells = async (element, value) => {
69521
+ if (!element)
69522
+ return;
69523
+ if (!value)
69524
+ return;
69525
+ // Select all cells with the attribute type="box"
69526
+ const boxCells = Array.from(element.children);
69527
+ console.log('boxCells', boxCells);
69528
+ if (!boxCells)
69529
+ return;
69530
+ boxCells.forEach(cell => {
69531
+ // Reset any previous styles
69532
+ cell.style.visibility = 'hidden';
69533
+ });
69534
+ // Animate each cell one by one
69535
+ for (const cell of boxCells) {
69536
+ cell.style.visibility = 'visible';
69537
+ cell.style.opacity = '1';
69538
+ // Apply the "come from top" animation
69539
+ cell.classList.add('lido-box-highlight');
69540
+ // Delay for each cell to come one after another
69541
+ await new Promise(resolve => setTimeout(resolve, 600)); // Adjust delay as needed
69542
+ cell.classList.remove('lido-box-highlight');
69543
+ }
69544
+ // After all cells have come down, apply the bounce animation
69545
+ for (const cell of boxCells) {
69546
+ // play the text child inside cell
69547
+ await AudioPlayer.getI().play(cell);
69548
+ }
69549
+ };
69550
+ const questionBoxAnimation = async (element, value) => {
69551
+ if (!element)
69552
+ return;
69553
+ if (!value)
69554
+ return;
69555
+ // Select all drag elements and drop elements
69556
+ const dragElements = Array.from(element.querySelectorAll("[type='drag']"));
69557
+ // Ensure all drag childrens which is dropped disappear
69558
+ dragElements.forEach(dragElement => {
69559
+ if (dragElement.hasAttribute('drop-to')) {
69560
+ dragElement.style.transition = 'opacity 0.5s ease';
69561
+ dragElement.style.opacity = '0'; // Fade out
69562
+ setTimeout(() => {
69563
+ dragElement.remove(); // Remove from view after fade-out
69564
+ }, 500);
69565
+ }
69566
+ });
69567
+ // Reveal all drop childrens which is hidden
69568
+ const dropElements = Array.from(element.querySelectorAll("[type='drop']"));
69569
+ let check = false;
69570
+ dropElements.forEach(dropEl => {
69571
+ const dropVal = dropEl.getAttribute("value");
69572
+ if (dropVal && dropEl.innerText.trim() === "?") {
69573
+ dropEl.innerText = dropVal;
69574
+ if (dropElements.length > 1 && check == false) {
69575
+ if (window.innerWidth > window.innerHeight) {
69576
+ dropEl.style.marginRight = "-45px";
69577
+ }
69578
+ else {
69579
+ dropEl.style.marginRight = "-65px";
69580
+ }
69581
+ check = true;
69582
+ }
69583
+ }
69584
+ });
69585
+ };
69586
+ const SumTogetherAnimation = async (element, value) => {
69587
+ if (!element)
69588
+ return;
69589
+ if (!value)
69590
+ return;
69591
+ const container = document.getElementById(LidoContainer);
69592
+ if (!container)
69593
+ return;
69594
+ // Expecting structure: [_, TopRow, questionRow, optionRow, ...]
69595
+ const TopRow = Array.from(element.children)[1];
69596
+ const questionRow = Array.from(element.children)[2];
69597
+ const optionRow = Array.from(element.children)[3];
69598
+ if (!TopRow || !questionRow || !optionRow)
69599
+ return;
69600
+ const topRowChildren = Array.from(TopRow.children);
69601
+ const questionRowChildren = Array.from(questionRow.children);
69602
+ const firstNumberEl = questionRowChildren[0];
69603
+ const signElement = questionRowChildren[1];
69604
+ const secondNumberEl = questionRowChildren[2];
69605
+ const equalElement = questionRowChildren[3];
69606
+ const answerElement = questionRowChildren[4];
69607
+ // helper functions
69608
+ const showElement = (el) => {
69609
+ if (!el)
69610
+ return;
69611
+ el.style.visibility = 'visible';
69612
+ el.style.display = '';
69613
+ el.style.opacity = '1';
69614
+ };
69615
+ const readNumber = (el) => {
69616
+ if (!el)
69617
+ return 0;
69618
+ const v = (el.getAttribute && (el.getAttribute('value') || el.getAttribute('string'))) || el.textContent || '';
69619
+ return parseInt(String(v).trim(), 10) || 0;
69620
+ };
69621
+ const elementAppearance = async (flag) => {
69622
+ if (flag) {
69623
+ if (firstNumberEl) {
69624
+ await new Promise(r => setTimeout(r, 200));
69625
+ showElement(firstNumberEl);
69626
+ }
69627
+ if (signElement) {
69628
+ await new Promise(r => setTimeout(r, 200));
69629
+ showElement(signElement);
69630
+ }
69631
+ }
69632
+ else {
69633
+ if (secondNumberEl) {
69634
+ await new Promise(r => setTimeout(r, 200));
69635
+ showElement(secondNumberEl);
69636
+ }
69637
+ if (equalElement) {
69638
+ await new Promise(r => setTimeout(r, 300));
69639
+ showElement(equalElement);
69640
+ }
69641
+ if (optionRow) {
69642
+ await new Promise(r => setTimeout(r, 300));
69643
+ showElement(optionRow);
69644
+ }
69645
+ if (answerElement) {
69646
+ await new Promise(r => setTimeout(r, 200));
69647
+ showElement(answerElement);
69648
+ }
69649
+ }
69650
+ };
69651
+ const number1 = readNumber(firstNumberEl);
69652
+ const number2 = readNumber(secondNumberEl);
69653
+ const sign = ((signElement && ((signElement.getAttribute('string') || signElement.textContent) || '')).toString().trim() === '+') ? '+' : '-';
69654
+ if (sign === '-') {
69655
+ // '-' flow: reveal one by one then change bgColor of last B to red
69656
+ for (let i = 0; i < topRowChildren.length; i++) {
69657
+ await new Promise(resolve => setTimeout(resolve, 75));
69658
+ showElement(topRowChildren[i]);
69659
+ }
69660
+ elementAppearance(true);
69661
+ await new Promise(r => setTimeout(r, 500));
69662
+ for (let k = 0; k < Math.min(number2, topRowChildren.length); k++) {
69663
+ const idx = topRowChildren.length - 1 - k;
69664
+ setImageBackground(topRowChildren[idx], 'red');
69665
+ await new Promise(r => setTimeout(r, 200));
69666
+ }
69667
+ elementAppearance(false);
69668
+ }
69669
+ else {
69670
+ // '+' flow: hide all, then showElement first A, then showElement next B in green
69671
+ for (let i = 0; i < Math.min(number1, topRowChildren.length); i++) {
69672
+ await new Promise(resolve => setTimeout(resolve, 120));
69673
+ showElement(topRowChildren[i]);
69674
+ }
69675
+ elementAppearance(true);
69676
+ await new Promise(r => setTimeout(r, 500));
69677
+ for (let j = 0; j < Math.min(number2, Math.max(0, topRowChildren.length - number1)); j++) {
69678
+ const idx = number1 + j;
69679
+ if (topRowChildren[idx]) {
69680
+ showElement(topRowChildren[idx]);
69681
+ setImageBackground(topRowChildren[idx], 'green');
69682
+ }
69683
+ await new Promise(r => setTimeout(r, 80));
69684
+ }
69685
+ elementAppearance(false);
69686
+ }
69687
+ };
68821
69688
 
68822
- export { ActivityScoreKey as A, setCancelBtnPopup as B, getDefaultExportFromCjs as C, tinyColor as D, storingEachActivityScore as E, DropAction as F, fraction as G, speakIcon as H, fingerUrl as I, LidoContainer as L, NextContainerKey as N, PrevContainerKey as P, RiveService as R, SelectedValuesKey as S, TraceMode as T, convertUrlToRelative as a, attachSpeakIcon as b, commonjsGlobal as c, calculateScale as d, handleFloatElementPosition as e, format as f, handleElementClick as g, handlingChildElements as h, initEventsForElement as i, clearLocalStorage as j, dispatchActivityChangeEvent as k, dispatchGameCompletedEvent as l, dispatchGameExitEvent as m, AudioPlayer as n, generateUUIDFallback as o, parseProp as p, exitUrl as q, prevUrl as r, setVisibilityWithDelay as s, nextUrl as t, speakUrl as u, getCancelBtnPopup as v, matchStringPattern as w, triggerNextContainer as x, triggerPrevcontainer as y, executeActions as z };
69689
+ export { ActivityScoreKey as A, getDefaultExportFromCjs as B, tinyColor as C, triggerNextContainer as D, DropAction as E, validateObjectiveStatus as F, fraction as G, speakIcon as H, fingerUrl as I, LidoContainer as L, NextContainerKey as N, PrevContainerKey as P, RiveService as R, SelectedValuesKey as S, TraceMode as T, convertUrlToRelative as a, storingEachActivityScore as b, commonjsGlobal as c, executeActions as d, equationCheck as e, format as f, attachSpeakIcon as g, handlingChildElements as h, initEventsForElement as i, calculateScale as j, handleFloatElementPosition as k, handleElementClick as l, dispatchActivityChangeEvent as m, dispatchGameCompletedEvent as n, dispatchGameExitEvent as o, parseProp as p, AudioPlayer as q, generateUUIDFallback as r, setVisibilityWithDelay as s, exitUrl as t, prevUrl as u, nextUrl as v, speakUrl as w, getCancelBtnPopup as x, triggerPrevcontainer as y, setCancelBtnPopup as z };