@timardex/cluemart-shared 1.5.794 → 1.5.795

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.
package/dist/index.d.mts CHANGED
@@ -3035,6 +3035,11 @@ declare const futureTimePeriods: {
3035
3035
  value: string;
3036
3036
  }[];
3037
3037
 
3038
+ /**
3039
+ * Convert an array of strings to an array of objects with label and value properties.
3040
+ */
3041
+ declare const mapArrayToOptions: (items: string[]) => OptionItem[];
3042
+
3038
3043
  declare const removeTypename: (obj: any) => any;
3039
3044
  /**
3040
3045
  * Truncate text to a specified length and append ellipsis if necessary.
@@ -3043,12 +3048,6 @@ declare const removeTypename: (obj: any) => any;
3043
3048
  * @returns
3044
3049
  */
3045
3050
  declare const truncateText: (text: string, maxLength?: number) => string;
3046
- /**
3047
- * Convert an array of strings to an array of objects with label and value properties.
3048
- * @param items - The array of strings to convert.
3049
- * @returns - The converted array of objects.
3050
- */
3051
- declare const mapArrayToOptions: (items: string[]) => OptionItem[];
3052
3051
  declare const capitalizeFirstLetter: (str: string) => string;
3053
3052
  declare const statusOptions: {
3054
3053
  label: EnumInviteStatus;
package/dist/index.d.ts CHANGED
@@ -3035,6 +3035,11 @@ declare const futureTimePeriods: {
3035
3035
  value: string;
3036
3036
  }[];
3037
3037
 
3038
+ /**
3039
+ * Convert an array of strings to an array of objects with label and value properties.
3040
+ */
3041
+ declare const mapArrayToOptions: (items: string[]) => OptionItem[];
3042
+
3038
3043
  declare const removeTypename: (obj: any) => any;
3039
3044
  /**
3040
3045
  * Truncate text to a specified length and append ellipsis if necessary.
@@ -3043,12 +3048,6 @@ declare const removeTypename: (obj: any) => any;
3043
3048
  * @returns
3044
3049
  */
3045
3050
  declare const truncateText: (text: string, maxLength?: number) => string;
3046
- /**
3047
- * Convert an array of strings to an array of objects with label and value properties.
3048
- * @param items - The array of strings to convert.
3049
- * @returns - The converted array of objects.
3050
- */
3051
- declare const mapArrayToOptions: (items: string[]) => OptionItem[];
3052
3051
  declare const capitalizeFirstLetter: (str: string) => string;
3053
3052
  declare const statusOptions: {
3054
3053
  label: EnumInviteStatus;
package/dist/index.mjs CHANGED
@@ -562,6 +562,163 @@ import isSameOrAfter from "dayjs/plugin/isSameOrAfter.js";
562
562
  import timezone from "dayjs/plugin/timezone.js";
563
563
  import utc from "dayjs/plugin/utc.js";
564
564
 
565
+ // src/utils/mapArrayToOptions.ts
566
+ var mapArrayToOptions = (items) => items.map((item) => ({
567
+ label: item,
568
+ value: item
569
+ }));
570
+
571
+ // src/utils/date.ts
572
+ var dateFormat = "DD-MM-YYYY";
573
+ var timeFormat = "HH:mm";
574
+ dayjs.extend(customParseFormat);
575
+ dayjs.extend(utc);
576
+ dayjs.extend(timezone);
577
+ dayjs.extend(isSameOrAfter);
578
+ var NZ_TZ = "Pacific/Auckland";
579
+ function toNZTime(date) {
580
+ return date ? dayjs(date).tz(NZ_TZ) : dayjs().tz(NZ_TZ);
581
+ }
582
+ function nzStartOfDay(input) {
583
+ if (input == null) {
584
+ return dayjs().tz(NZ_TZ).startOf("day");
585
+ }
586
+ return dayjs.tz(input, NZ_TZ).startOf("day");
587
+ }
588
+ var formatDate = (dateStr, display = "datetime", timeStr) => {
589
+ const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;
590
+ const dateTime = timeStr ? dayjs(dateTimeStr, `${dateFormat} ${timeFormat}`) : dayjs(dateStr, dateFormat);
591
+ const formattedDate = dateTime.format("dddd, D MMMM, YYYY");
592
+ const formattedTime = dateTime.format("h:mm a");
593
+ switch (display) {
594
+ case "date":
595
+ return formattedDate;
596
+ case "time":
597
+ return formattedTime;
598
+ case "datetime":
599
+ return `${formattedDate} at ${formattedTime}`;
600
+ default:
601
+ return formattedDate;
602
+ }
603
+ };
604
+ var getCurrentAndFutureDates = (dates) => {
605
+ const now = dayjs();
606
+ return dates.filter((dateObj) => {
607
+ const dateTime = dayjs(
608
+ `${dateObj.startDate} ${dateObj.startTime}`,
609
+ `${dateFormat} ${timeFormat}`
610
+ );
611
+ return dateTime.isSameOrAfter(now);
612
+ });
613
+ };
614
+ var isFutureDatesBeforeThreshold = (date, minHoursFromNow) => {
615
+ const threshold = minHoursFromNow ? dayjs().add(minHoursFromNow, "hour") : dayjs().startOf("day");
616
+ const dateTime = dayjs(
617
+ `${date.startDate} ${date.startTime}`,
618
+ `${dateFormat} ${timeFormat}`
619
+ );
620
+ return dateTime.isSameOrAfter(threshold);
621
+ };
622
+ var formatTimestamp = (timestamp) => {
623
+ const formattedDate = toNZTime(timestamp).format(dateFormat);
624
+ return formatDate(formattedDate, "date");
625
+ };
626
+ var isIsoDateString = (value) => {
627
+ return typeof value === "string" && !Number.isNaN(Date.parse(value));
628
+ };
629
+ function sortDatesChronologically(dates) {
630
+ if (!dates?.length) {
631
+ return [];
632
+ }
633
+ return [...dates].sort((a, b) => {
634
+ const dateTimeFormat = `${dateFormat} ${timeFormat}`;
635
+ const dateA = dayjs(`${a.startDate} ${a.startTime}`, dateTimeFormat);
636
+ const dateB = dayjs(`${b.startDate} ${b.startTime}`, dateTimeFormat);
637
+ return dateA.valueOf() - dateB.valueOf();
638
+ });
639
+ }
640
+ var futureTimePeriods = mapArrayToOptions(
641
+ Object.values(EnumEventDateStatus)
642
+ ).filter(
643
+ (period) => period.value !== "Starting_Soon" /* STARTING_SOON */ && period.value !== "Canceled" /* CANCELED */ && period.value !== "Rescheduled" /* RE_SCHEDULED */ && period.value !== "Started" /* STARTED */ && period.value !== "Ended" /* ENDED */ && period.value !== "Invalid" /* INVALID */
644
+ ).map((period) => ({
645
+ label: period.value.replaceAll("_", " "),
646
+ value: period.value
647
+ }));
648
+
649
+ // src/utils/dailyClueGame.ts
650
+ function createSeededRng(seed) {
651
+ let t = seed >>> 0;
652
+ return function random() {
653
+ t += 1831565813;
654
+ let x = t;
655
+ x = Math.imul(x ^ x >>> 15, x | 1);
656
+ x ^= x + Math.imul(x ^ x >>> 7, x | 61);
657
+ return ((x ^ x >>> 14) >>> 0) / 4294967296;
658
+ };
659
+ }
660
+ function hashStringToNumber(seed) {
661
+ let hash = 2166136261;
662
+ for (let i = 0; i < seed.length; i++) {
663
+ hash ^= seed.codePointAt(i) ?? 0;
664
+ hash = Math.imul(hash, 16777619);
665
+ }
666
+ return hash >>> 0;
667
+ }
668
+ function seededShuffle(array, seed) {
669
+ const rng = createSeededRng(hashStringToNumber(seed));
670
+ const result = [...array];
671
+ for (let i = result.length - 1; i > 0; i--) {
672
+ const j = Math.floor(rng() * (i + 1));
673
+ [result[i], result[j]] = [result[j], result[i]];
674
+ }
675
+ return result;
676
+ }
677
+ function getDayIndex(start, today) {
678
+ return today.diff(start, "day");
679
+ }
680
+ function computeDailyClueState(dailyClue) {
681
+ const { startDate, endDate } = dailyClue.gameFields.gameDate;
682
+ const { solutionShuffled, collected } = dailyClue.letterInfo;
683
+ const today = nzStartOfDay();
684
+ const start = nzStartOfDay(startDate);
685
+ const end = nzStartOfDay(endDate);
686
+ if (today.isBefore(start)) {
687
+ return null;
688
+ }
689
+ const shuffledPlacements = seededShuffle(
690
+ gameScreenIdentifierList,
691
+ start.toISOString()
692
+ );
693
+ const index = getDayIndex(start, today);
694
+ if (today.isAfter(end)) {
695
+ return {
696
+ todaysClue: null,
697
+ todaysLetter: null,
698
+ todaysPlacement: null
699
+ };
700
+ }
701
+ if (index < 0 || index >= solutionShuffled.length || index >= shuffledPlacements.length) {
702
+ return null;
703
+ }
704
+ const letterToday = solutionShuffled[index];
705
+ const placement = shuffledPlacements[index];
706
+ if (!letterToday || !placement) return null;
707
+ const alreadyCollectedToday = (collected ?? []).includes(letterToday);
708
+ if (alreadyCollectedToday) {
709
+ return {
710
+ todaysClue: null,
711
+ todaysLetter: null,
712
+ todaysPlacement: null
713
+ };
714
+ }
715
+ return {
716
+ todaysClue: placement.clue,
717
+ todaysLetter: letterToday,
718
+ todaysPlacement: placement.id
719
+ };
720
+ }
721
+
565
722
  // src/sharing/relationShareTypes.ts
566
723
  var RELATION_SHARE_INVITATION = "invitation";
567
724
  var RELATION_SHARE_APPLICATION = "application";
@@ -846,10 +1003,6 @@ var truncateText = (text, maxLength = 30) => {
846
1003
  const result = stripOverlaySubtitleSpecialChars(text);
847
1004
  return result.length > maxLength ? result.substring(0, maxLength) + "..." : result;
848
1005
  };
849
- var mapArrayToOptions = (items) => items.map((item) => ({
850
- label: item,
851
- value: item
852
- }));
853
1006
  var capitalizeFirstLetter = (str) => {
854
1007
  return str.split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
855
1008
  };
@@ -936,157 +1089,6 @@ function formatNZBankAccount(input) {
936
1089
  return parts.join("-");
937
1090
  }
938
1091
 
939
- // src/utils/date.ts
940
- var dateFormat = "DD-MM-YYYY";
941
- var timeFormat = "HH:mm";
942
- dayjs.extend(customParseFormat);
943
- dayjs.extend(utc);
944
- dayjs.extend(timezone);
945
- dayjs.extend(isSameOrAfter);
946
- var NZ_TZ = "Pacific/Auckland";
947
- function toNZTime(date) {
948
- return date ? dayjs(date).tz(NZ_TZ) : dayjs().tz(NZ_TZ);
949
- }
950
- function nzStartOfDay(input) {
951
- if (input == null) {
952
- return dayjs().tz(NZ_TZ).startOf("day");
953
- }
954
- return dayjs.tz(input, NZ_TZ).startOf("day");
955
- }
956
- var formatDate = (dateStr, display = "datetime", timeStr) => {
957
- const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;
958
- const dateTime = timeStr ? dayjs(dateTimeStr, `${dateFormat} ${timeFormat}`) : dayjs(dateStr, dateFormat);
959
- const formattedDate = dateTime.format("dddd, D MMMM, YYYY");
960
- const formattedTime = dateTime.format("h:mm a");
961
- switch (display) {
962
- case "date":
963
- return formattedDate;
964
- case "time":
965
- return formattedTime;
966
- case "datetime":
967
- return `${formattedDate} at ${formattedTime}`;
968
- default:
969
- return formattedDate;
970
- }
971
- };
972
- var getCurrentAndFutureDates = (dates) => {
973
- const now = dayjs();
974
- return dates.filter((dateObj) => {
975
- const dateTime = dayjs(
976
- `${dateObj.startDate} ${dateObj.startTime}`,
977
- `${dateFormat} ${timeFormat}`
978
- );
979
- return dateTime.isSameOrAfter(now);
980
- });
981
- };
982
- var isFutureDatesBeforeThreshold = (date, minHoursFromNow) => {
983
- const threshold = minHoursFromNow ? dayjs().add(minHoursFromNow, "hour") : dayjs().startOf("day");
984
- const dateTime = dayjs(
985
- `${date.startDate} ${date.startTime}`,
986
- `${dateFormat} ${timeFormat}`
987
- );
988
- return dateTime.isSameOrAfter(threshold);
989
- };
990
- var formatTimestamp = (timestamp) => {
991
- const formattedDate = toNZTime(timestamp).format(dateFormat);
992
- return formatDate(formattedDate, "date");
993
- };
994
- var isIsoDateString = (value) => {
995
- return typeof value === "string" && !Number.isNaN(Date.parse(value));
996
- };
997
- function sortDatesChronologically(dates) {
998
- if (!dates?.length) {
999
- return [];
1000
- }
1001
- return [...dates].sort((a, b) => {
1002
- const dateTimeFormat = `${dateFormat} ${timeFormat}`;
1003
- const dateA = dayjs(`${a.startDate} ${a.startTime}`, dateTimeFormat);
1004
- const dateB = dayjs(`${b.startDate} ${b.startTime}`, dateTimeFormat);
1005
- return dateA.valueOf() - dateB.valueOf();
1006
- });
1007
- }
1008
- var futureTimePeriods = mapArrayToOptions(
1009
- Object.values(EnumEventDateStatus)
1010
- ).filter(
1011
- (period) => period.value !== "Starting_Soon" /* STARTING_SOON */ && period.value !== "Canceled" /* CANCELED */ && period.value !== "Rescheduled" /* RE_SCHEDULED */ && period.value !== "Started" /* STARTED */ && period.value !== "Ended" /* ENDED */ && period.value !== "Invalid" /* INVALID */
1012
- ).map((period) => ({
1013
- label: period.value.replaceAll("_", " "),
1014
- value: period.value
1015
- }));
1016
-
1017
- // src/utils/dailyClueGame.ts
1018
- function createSeededRng(seed) {
1019
- let t = seed >>> 0;
1020
- return function random() {
1021
- t += 1831565813;
1022
- let x = t;
1023
- x = Math.imul(x ^ x >>> 15, x | 1);
1024
- x ^= x + Math.imul(x ^ x >>> 7, x | 61);
1025
- return ((x ^ x >>> 14) >>> 0) / 4294967296;
1026
- };
1027
- }
1028
- function hashStringToNumber(seed) {
1029
- let hash = 2166136261;
1030
- for (let i = 0; i < seed.length; i++) {
1031
- hash ^= seed.codePointAt(i) ?? 0;
1032
- hash = Math.imul(hash, 16777619);
1033
- }
1034
- return hash >>> 0;
1035
- }
1036
- function seededShuffle(array, seed) {
1037
- const rng = createSeededRng(hashStringToNumber(seed));
1038
- const result = [...array];
1039
- for (let i = result.length - 1; i > 0; i--) {
1040
- const j = Math.floor(rng() * (i + 1));
1041
- [result[i], result[j]] = [result[j], result[i]];
1042
- }
1043
- return result;
1044
- }
1045
- function getDayIndex(start, today) {
1046
- return today.diff(start, "day");
1047
- }
1048
- function computeDailyClueState(dailyClue) {
1049
- const { startDate, endDate } = dailyClue.gameFields.gameDate;
1050
- const { solutionShuffled, collected } = dailyClue.letterInfo;
1051
- const today = nzStartOfDay();
1052
- const start = nzStartOfDay(startDate);
1053
- const end = nzStartOfDay(endDate);
1054
- if (today.isBefore(start)) {
1055
- return null;
1056
- }
1057
- const shuffledPlacements = seededShuffle(
1058
- gameScreenIdentifierList,
1059
- start.toISOString()
1060
- );
1061
- const index = getDayIndex(start, today);
1062
- if (today.isAfter(end)) {
1063
- return {
1064
- todaysClue: null,
1065
- todaysLetter: null,
1066
- todaysPlacement: null
1067
- };
1068
- }
1069
- if (index < 0 || index >= solutionShuffled.length || index >= shuffledPlacements.length) {
1070
- return null;
1071
- }
1072
- const letterToday = solutionShuffled[index];
1073
- const placement = shuffledPlacements[index];
1074
- if (!letterToday || !placement) return null;
1075
- const alreadyCollectedToday = (collected ?? []).includes(letterToday);
1076
- if (alreadyCollectedToday) {
1077
- return {
1078
- todaysClue: null,
1079
- todaysLetter: null,
1080
- todaysPlacement: null
1081
- };
1082
- }
1083
- return {
1084
- todaysClue: placement.clue,
1085
- todaysLetter: letterToday,
1086
- todaysPlacement: placement.id
1087
- };
1088
- }
1089
-
1090
1092
  // src/utils/affiliate.ts
1091
1093
  var AFFILIATE_REWARDS = {
1092
1094
  ["NEW_EVENT_REGISTRATION" /* NEW_EVENT_REGISTRATION */]: {