tods-competition-factory 1.8.4 → 1.8.5

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.
@@ -1648,9 +1648,7 @@ const setTypes = {
1648
1648
  function stringify(matchUpFormatObject, preserveRedundant) {
1649
1649
  if (typeof matchUpFormatObject !== "object")
1650
1650
  return;
1651
- if (matchUpFormatObject.timed && !isNaN(matchUpFormatObject.minutes))
1652
- return timedSetFormat(matchUpFormatObject);
1653
- if (matchUpFormatObject.bestOf && matchUpFormatObject.setFormat)
1651
+ if ((matchUpFormatObject.bestOf || matchUpFormatObject.exactly) && matchUpFormatObject.setFormat)
1654
1652
  return getSetFormat(matchUpFormatObject, preserveRedundant);
1655
1653
  return void 0;
1656
1654
  }
@@ -1666,11 +1664,13 @@ function timedSetFormat(matchUpFormatObject) {
1666
1664
  return value;
1667
1665
  }
1668
1666
  function getSetFormat(matchUpFormatObject, preserveRedundant) {
1669
- const bestOfValue = getNumber$1(matchUpFormatObject.bestOf);
1670
- if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && bestOfValue === 1) {
1667
+ const bestOfValue = getNumber$1(matchUpFormatObject.bestOf) || void 0;
1668
+ const exactly = getNumber$1(matchUpFormatObject.exactly) || void 0;
1669
+ const setLimit = bestOfValue || exactly;
1670
+ if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && setLimit === 1) {
1671
1671
  return timedSetFormat(matchUpFormatObject.setFormat);
1672
1672
  }
1673
- const bestOfCode = bestOfValue && `${SET}${bestOfValue}` || "";
1673
+ const setLimitCode = setLimit && `${SET}${setLimit}` || "";
1674
1674
  const setCountValue = stringifySet(
1675
1675
  matchUpFormatObject.setFormat,
1676
1676
  preserveRedundant
@@ -1680,11 +1680,11 @@ function getSetFormat(matchUpFormatObject, preserveRedundant) {
1680
1680
  matchUpFormatObject.finalSetFormat,
1681
1681
  preserveRedundant
1682
1682
  );
1683
- const finalSetCode = bestOfValue && bestOfValue > 1 && finalSetCountValue && setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
1683
+ const finalSetCode = setLimit && setLimit > 1 && finalSetCountValue && setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
1684
1684
  `F:${finalSetCountValue}` || "";
1685
- const valid = bestOfCode && setCountValue;
1685
+ const valid = setLimitCode && setCountValue;
1686
1686
  if (valid) {
1687
- return [bestOfCode, setCode, finalSetCode].filter((f) => f).join("-");
1687
+ return [setLimitCode, setCode, finalSetCode].filter((f) => f).join("-");
1688
1688
  }
1689
1689
  return void 0;
1690
1690
  }
@@ -1734,7 +1734,7 @@ function parse(matchUpFormatCode) {
1734
1734
  setFormat,
1735
1735
  bestOf: 1
1736
1736
  };
1737
- if (parsedFormat.setFormat)
1737
+ if (setFormat)
1738
1738
  return parsedFormat;
1739
1739
  }
1740
1740
  if (type === SET)
@@ -1744,16 +1744,23 @@ function parse(matchUpFormatCode) {
1744
1744
  }
1745
1745
  function setsMatch(formatstring) {
1746
1746
  const parts = formatstring.split("-");
1747
- const bestOf = getNumber(parts[0].slice(3));
1747
+ const setsCount = getNumber(parts[0].slice(3));
1748
+ const bestOf = setsCount === 1 || setsCount % 2 !== 0 ? setsCount : void 0;
1749
+ const exactly = setsCount !== 1 && setsCount % 2 === 0 ? setsCount : void 0;
1748
1750
  const setFormat = parts && parseSetFormat(parts[1]);
1749
1751
  const finalSetFormat = parts && parseSetFormat(parts[2]);
1750
- const validBestOf = bestOf && bestOf < 6;
1752
+ const timed = setFormat && setFormat.timed || finalSetFormat && finalSetFormat.timed;
1753
+ const validSetsCount = bestOf && bestOf < 6 || timed && exactly;
1751
1754
  const validFinalSet = !parts[2] || finalSetFormat;
1752
1755
  const validSetsFormat = setFormat;
1753
- const result = { bestOf, setFormat };
1756
+ const result = definedAttributes({
1757
+ setFormat,
1758
+ exactly,
1759
+ bestOf
1760
+ });
1754
1761
  if (finalSetFormat)
1755
1762
  result.finalSetFormat = finalSetFormat;
1756
- if (validBestOf && validSetsFormat && validFinalSet)
1763
+ if (validSetsCount && validSetsFormat && validFinalSet)
1757
1764
  return result;
1758
1765
  }
1759
1766
  function parseSetFormat(formatstring) {
@@ -5482,10 +5489,10 @@ function getOrderedDrawPositions({
5482
5489
  const pairedDrawPositions = targetRoundProfile?.pairedDrawPositions;
5483
5490
  const displayOrder = pairedDrawPositions?.find(
5484
5491
  (pair) => overlap(pair || [], drawPositions.filter(Boolean))
5485
- ) || unassignedDrawPositions;
5492
+ ) ?? unassignedDrawPositions;
5486
5493
  const isFeedRound = targetRoundProfile?.feedRound;
5487
5494
  if (allNumeric$1(drawPositions)) {
5488
- const orderedDrawPositions = drawPositions.sort(numericSort);
5495
+ const orderedDrawPositions = [...drawPositions].sort(numericSort);
5489
5496
  return {
5490
5497
  orderedDrawPositions: orderedDrawPositions.length === 2 ? orderedDrawPositions : displayOrder,
5491
5498
  displayOrder: isFeedRound ? orderedDrawPositions : displayOrder
@@ -6208,7 +6215,7 @@ function getAllStructureMatchUps({
6208
6215
  matchUp,
6209
6216
  event: event2
6210
6217
  }) {
6211
- additionalContext = additionalContext || {};
6218
+ additionalContext = additionalContext ?? {};
6212
6219
  const tieFormat = resolveTieFormat({
6213
6220
  drawDefinition,
6214
6221
  structure,
@@ -6219,7 +6226,7 @@ function getAllStructureMatchUps({
6219
6226
  const collectionDefinition = matchUp.collectionId && collectionDefinitions?.find(
6220
6227
  (definition) => definition.collectionId === matchUp.collectionId
6221
6228
  );
6222
- const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat || structure?.matchUpFormat || drawDefinition?.matchUpFormat || event2?.matchUpFormat;
6229
+ const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat ?? structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event2?.matchUpFormat;
6223
6230
  const matchUpType = matchUp.matchUpType || collectionDefinition?.matchUpType || structure?.matchUpType || drawDefinition?.matchUpType || event2?.eventType !== TEAM$1 && event2?.eventType;
6224
6231
  const matchUpStatus = isCollectionBye ? BYE : matchUp.matchUpStatus;
6225
6232
  const { schedule, endDate } = getMatchUpScheduleDetails({
@@ -6234,7 +6241,7 @@ function getAllStructureMatchUps({
6234
6241
  });
6235
6242
  const drawPositions = tieDrawPositions ?? matchUp.drawPositions ?? [];
6236
6243
  const { collectionPosition, collectionId, roundPosition } = matchUp;
6237
- const roundNumber = matchUp.roundNumber || additionalContext.roundNumber;
6244
+ const roundNumber = matchUp.roundNumber ?? additionalContext.roundNumber;
6238
6245
  const drawPositionCollectionAssignment = collectionId ? getDrawPositionCollectionAssignment({
6239
6246
  tournamentParticipants,
6240
6247
  positionAssignments,
@@ -6260,7 +6267,7 @@ function getAllStructureMatchUps({
6260
6267
  } : context?.category;
6261
6268
  const processCodes = matchUp.processCodes?.length && matchUp.processCodes || collectionDefinition?.processCodes?.length && collectionDefinition?.processCodes || structure?.processCodes?.length && structure?.processCodes || drawDefinition?.processCodes?.length && drawDefinition?.processCodes || event2?.processCodes?.length && event2?.processCodes || tournamentRecord?.processCodes;
6262
6269
  const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
6263
- const finishingPositionRange = matchUp.finishingPositionRange || additionalContext.finishingPositionRange;
6270
+ const finishingPositionRange = matchUp.finishingPositionRange ?? additionalContext.finishingPositionRange;
6264
6271
  const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
6265
6272
  const matchUpWithContext = {
6266
6273
  ...onlyDefined(context),
@@ -6268,7 +6275,7 @@ function getAllStructureMatchUps({
6268
6275
  matchUpFormat: matchUp.matchUpType === TEAM$1 ? void 0 : matchUpFormat,
6269
6276
  tieFormat: matchUp.matchUpType !== TEAM$1 ? void 0 : tieFormat,
6270
6277
  roundOfPlay: stage !== QUALIFYING && isConvertableInteger(initialRoundOfPlay2) && initialRoundOfPlay2 + (roundNumber || 0),
6271
- endDate: matchUp.endDate || endDate,
6278
+ endDate: matchUp.endDate ?? endDate,
6272
6279
  gender: collectionDefinition?.gender,
6273
6280
  discipline: event2?.discipline,
6274
6281
  category: matchUpCategory,
@@ -7177,10 +7184,10 @@ function addUpcomingMatchUps({ drawDefinition, inContextDrawMatchUps }) {
7177
7184
  if (structure?.finishingPosition === WIN_RATIO) {
7178
7185
  const { roundNumber } = inContextMatchUp;
7179
7186
  const nextRoundNumber = roundNumber && ensureInt(roundNumber) + 1;
7180
- const matchUps = structure.matchUps || [];
7187
+ const matchUps = structure.matchUps ?? [];
7181
7188
  const { roundMatchUps } = getRoundMatchUps({ matchUps });
7182
7189
  if (nextRoundNumber && roundMatchUps?.[nextRoundNumber]) {
7183
- const sidesTo = drawPositions.sort().map((drawPosition, index) => {
7190
+ const sidesTo = [...drawPositions].sort(numericSort).map((drawPosition, index) => {
7184
7191
  const nextRoundMatchUp = roundMatchUps[nextRoundNumber].find(
7185
7192
  (matchUp) => matchUp.drawPositions?.includes(drawPosition)
7186
7193
  );
@@ -17141,7 +17148,8 @@ function bulkRescheduleMatchUps$1({
17141
17148
  scheduledTime,
17142
17149
  minutesChange
17143
17150
  );
17144
- newScheduledTime = scheduledTimeDate && newScheduledDate ? `${newScheduledDate}T${timeString}` : timeString;
17151
+ const timeStringDate = scheduledTimeDate && newScheduledDate || scheduledDate === scheduledTimeDate && scheduledTimeDate;
17152
+ newScheduledTime = timeStringDate ? `${timeStringDate}T${timeString}` : timeString;
17145
17153
  }
17146
17154
  }
17147
17155
  if (doNotReschedule) {