@timardex/cluemart-shared 2.2.23 → 2.2.24

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.
@@ -2,12 +2,12 @@ import "../chunk-6O6TRUOV.mjs";
2
2
  import "../chunk-VA5YN2K3.mjs";
3
3
  import "../chunk-VPANTTZI.mjs";
4
4
  import "../chunk-DWO35OY4.mjs";
5
- import "../chunk-6NGXF4G7.mjs";
5
+ import "../chunk-PNGFNH7J.mjs";
6
6
  import {
7
7
  SCHOOL_MIN_STUDENT_COUNT,
8
8
  isValidIrdNumber,
9
9
  normalizeUrl
10
- } from "../chunk-OWEIH2ME.mjs";
10
+ } from "../chunk-UOJGSBHK.mjs";
11
11
  import "../chunk-RE4NZPYY.mjs";
12
12
  import {
13
13
  dateFormat,
@@ -21,7 +21,7 @@ import {
21
21
  EnumAffiliateParticipantType,
22
22
  EnumPostContentType,
23
23
  EnumPostType
24
- } from "../chunk-FWKZZMQR.mjs";
24
+ } from "../chunk-IKRXLKJ3.mjs";
25
25
  import "../chunk-RAYUJODN.mjs";
26
26
  import "../chunk-DQ7ZHIXW.mjs";
27
27
  import "../chunk-TCV735VY.mjs";
package/dist/index.cjs CHANGED
@@ -213,6 +213,8 @@ __export(index_exports, {
213
213
  computeDailyClueState: () => computeDailyClueState,
214
214
  computeHasMore: () => computeHasMore,
215
215
  contactUsFields: () => contactUsFields,
216
+ countLetterOccurrences: () => countLetterOccurrences,
217
+ countLetterOccurrencesUpTo: () => countLetterOccurrencesUpTo,
216
218
  createAffiliateReward: () => createAffiliateReward,
217
219
  darkColors: () => darkColors,
218
220
  dateFormat: () => dateFormat,
@@ -262,6 +264,7 @@ __export(index_exports, {
262
264
  getAllowedEventDateStatuses: () => getAllowedEventDateStatuses,
263
265
  getBillingCatalogKeyForSelection: () => getBillingCatalogKeyForSelection,
264
266
  getCurrentAndFutureDates: () => getCurrentAndFutureDates,
267
+ getDailyClueDayIndex: () => getDailyClueDayIndex,
265
268
  getDefaultAdminHome: () => getDefaultAdminHome,
266
269
  getDistanceInKilometers: () => getDistanceInKilometers,
267
270
  getDistanceInMeters: () => getDistanceInMeters,
@@ -1387,6 +1390,31 @@ function seededShuffle(array, seed) {
1387
1390
  function getDayIndex(start, today) {
1388
1391
  return today.diff(start, "day");
1389
1392
  }
1393
+ function getDailyClueDayIndex(dailyClue) {
1394
+ const today = nzStartOfDay();
1395
+ const start = nzStartOfDay(dailyClue.gameFields.gameDate.startDate);
1396
+ const end = nzStartOfDay(dailyClue.gameFields.gameDate.endDate);
1397
+ if (today.isBefore(start) || today.isAfter(end)) {
1398
+ return null;
1399
+ }
1400
+ return getDayIndex(start, today);
1401
+ }
1402
+ function countLetterOccurrences(letters, letter) {
1403
+ return letters.reduce(
1404
+ (count, candidate) => candidate === letter ? count + 1 : count,
1405
+ 0
1406
+ );
1407
+ }
1408
+ function countLetterOccurrencesUpTo(letters, letter, index) {
1409
+ let count = 0;
1410
+ const end = Math.min(index, letters.length - 1);
1411
+ for (let i = 0; i <= end; i++) {
1412
+ if (letters[i] === letter) {
1413
+ count++;
1414
+ }
1415
+ }
1416
+ return count;
1417
+ }
1390
1418
  function computeDailyClueState(dailyClue) {
1391
1419
  const { startDate, endDate } = dailyClue.gameFields.gameDate;
1392
1420
  const { solutionShuffled, collected } = dailyClue.letterInfo;
@@ -1414,7 +1442,8 @@ function computeDailyClueState(dailyClue) {
1414
1442
  const letterToday = solutionShuffled[index];
1415
1443
  const placement = shuffledPlacements[index];
1416
1444
  if (!letterToday || !placement) return null;
1417
- const alreadyCollectedToday = (collected ?? []).includes(letterToday);
1445
+ const collectedLetters = collected ?? [];
1446
+ const alreadyCollectedToday = countLetterOccurrences(collectedLetters, letterToday) >= countLetterOccurrencesUpTo(solutionShuffled, letterToday, index);
1418
1447
  if (alreadyCollectedToday) {
1419
1448
  return {
1420
1449
  todaysClue: null,
@@ -10349,6 +10378,8 @@ function canAccessAdminPath(roles, pathname) {
10349
10378
  computeDailyClueState,
10350
10379
  computeHasMore,
10351
10380
  contactUsFields,
10381
+ countLetterOccurrences,
10382
+ countLetterOccurrencesUpTo,
10352
10383
  createAffiliateReward,
10353
10384
  darkColors,
10354
10385
  dateFormat,
@@ -10398,6 +10429,7 @@ function canAccessAdminPath(roles, pathname) {
10398
10429
  getAllowedEventDateStatuses,
10399
10430
  getBillingCatalogKeyForSelection,
10400
10431
  getCurrentAndFutureDates,
10432
+ getDailyClueDayIndex,
10401
10433
  getDefaultAdminHome,
10402
10434
  getDistanceInKilometers,
10403
10435
  getDistanceInMeters,