tods-competition-factory 1.9.0 → 1.9.1

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.mjs CHANGED
@@ -2015,6 +2015,11 @@ const extractAttributes = (accessor) => (element) => !accessor || typeof element
2015
2015
  })) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
2016
2016
  [key]: getAccessorValue({ element, accessor: key })?.value
2017
2017
  })) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
2018
+ function getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays) {
2019
+ return Object.keys(obj).filter(
2020
+ (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
2021
+ );
2022
+ }
2018
2023
  function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
2019
2024
  if (typeof obj !== "object" || obj === null)
2020
2025
  return obj;
@@ -2024,9 +2029,7 @@ function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
2024
2029
  const ignoreValues = ["", void 0, null];
2025
2030
  if (ignoreFalse)
2026
2031
  ignoreValues.push(false);
2027
- const definedKeys = Object.keys(obj).filter(
2028
- (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
2029
- );
2032
+ const definedKeys = getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays);
2030
2033
  return Object.assign(
2031
2034
  {},
2032
2035
  ...definedKeys.map((key) => {
@@ -2419,7 +2422,7 @@ const matchUpFormatCode = {
2419
2422
  };
2420
2423
 
2421
2424
  function factoryVersion() {
2422
- return "1.9.0";
2425
+ return "1.9.1";
2423
2426
  }
2424
2427
 
2425
2428
  function getObjectTieFormat(obj) {
@@ -25811,12 +25814,12 @@ function positionActions$1(params) {
25811
25814
  const isActiveDrawPosition = activeDrawPositions.includes(drawPosition);
25812
25815
  if (actionsDisabled)
25813
25816
  return {
25817
+ hasPositionAssigned: !!positionAssignment,
25814
25818
  info: "Actions Disabled for structure",
25815
- isByePosition,
25816
25819
  isActiveDrawPosition,
25817
25820
  isDrawPosition: true,
25818
- hasPositionAssigned: !!positionAssignment,
25819
- validActions: []
25821
+ validActions: [],
25822
+ isByePosition
25820
25823
  };
25821
25824
  if (isAvailableAction({ policyActions, action: ASSIGN_PARTICIPANT }) && !isActiveDrawPosition && positionAssignments && !disablePlacementActions && (!positionAssignment || isByePosition)) {
25822
25825
  const { validAssignmentActions } = getValidAssignmentActions({
@@ -29591,18 +29594,14 @@ function conditionallyAdvanceDrawPosition(params) {
29591
29594
  } else {
29592
29595
  sourceSideNumber = 2;
29593
29596
  }
29594
- } else {
29595
- if (targetMatchUp.feedRound) {
29596
- if (sourceMatchUp.structureId === targetMatchUp.structureId) {
29597
- sourceSideNumber = 2;
29598
- } else {
29599
- sourceSideNumber = 1;
29600
- }
29597
+ } else if (targetMatchUp.feedRound) {
29598
+ if (sourceMatchUp.structureId === targetMatchUp.structureId) {
29599
+ sourceSideNumber = 2;
29601
29600
  } else {
29602
- if (walkoverWinningSide)
29603
- sourceSideNumber = 3 - walkoverWinningSide;
29601
+ sourceSideNumber = 1;
29604
29602
  }
29605
- }
29603
+ } else if (walkoverWinningSide)
29604
+ sourceSideNumber = 3 - walkoverWinningSide;
29606
29605
  }
29607
29606
  const sourceMatchUpStatus = params.matchUpStatus;
29608
29607
  const pairedMatchUpStatus = pairedPreviousMatchUp?.matchUpStatus;
@@ -41237,10 +41236,11 @@ function generateQualifyingStructures({
41237
41236
  for (const structureProfile of (structureProfiles || []).sort(
41238
41237
  sequenceSort
41239
41238
  )) {
41240
- let drawSize = structureProfile.drawSize || coerceEven(structureProfile.participantsCount);
41239
+ let drawSize = coerceEven(
41240
+ structureProfile.drawSize || structureProfile.participantsCount
41241
+ );
41241
41242
  const {
41242
41243
  qualifyingRoundNumber,
41243
- qualifyingPositions,
41244
41244
  structureOptions,
41245
41245
  matchUpFormat,
41246
41246
  structureName,
@@ -41248,6 +41248,7 @@ function generateQualifyingStructures({
41248
41248
  drawType
41249
41249
  } = structureProfile;
41250
41250
  const matchUpType = structureProfile.matchUpType;
41251
+ const qualifyingPositions = structureProfile.qualifyingPositions || deriveQualifyingPositions({ drawSize, qualifyingRoundNumber });
41251
41252
  let roundLimit, structure, matchUps;
41252
41253
  if (!isConvertableInteger(drawSize)) {
41253
41254
  return decorateResult({
@@ -41354,6 +41355,15 @@ function generateQualifyingStructures({
41354
41355
  links
41355
41356
  };
41356
41357
  }
41358
+ function deriveQualifyingPositions({ drawSize, qualifyingRoundNumber }) {
41359
+ let qualifyingPositions = drawSize;
41360
+ let divisionsCount = 0;
41361
+ while (divisionsCount < qualifyingRoundNumber) {
41362
+ qualifyingPositions = Math.floor(qualifyingPositions / 2);
41363
+ divisionsCount += 1;
41364
+ }
41365
+ return qualifyingPositions;
41366
+ }
41357
41367
 
41358
41368
  function getPositionRangeMap({
41359
41369
  playoffGroups,