tods-competition-factory 1.8.31 → 1.8.33

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.
@@ -12820,7 +12820,7 @@ function getParticipantEntries(params) {
12820
12820
  const minutesDifference = Math.abs(
12821
12821
  consideredMinutes - scheduledMinutes
12822
12822
  );
12823
- const itemIsPrior = consideredMinutes > scheduledMinutes;
12823
+ const itemIsPrior = consideredMinutes >= scheduledMinutes;
12824
12824
  const timeOverlap = scheduledMinutesDifference && !isNaN(scheduledMinutesDifference) ? minutesDifference <= scheduledMinutesDifference : itemIsPrior && timeStringMinutes(consideredItem.scheduledTime) < timeStringMinutes(notBeforeTime);
12825
12825
  if (timeOverlap && !(bothPotential && sameDraw) && itemIsPrior) {
12826
12826
  participantAggregator.scheduleConflicts.push({
@@ -13584,10 +13584,89 @@ function getSeedGroups({
13584
13584
  }
13585
13585
  }
13586
13586
 
13587
+ function getDivisions({ size }) {
13588
+ const divisions = [size];
13589
+ let division = size;
13590
+ while (division / 2 === Math.floor(division / 2)) {
13591
+ division = division / 2;
13592
+ divisions.push(division);
13593
+ }
13594
+ if (!divisions.includes(1))
13595
+ divisions.push(1);
13596
+ divisions.sort(numericSort);
13597
+ divisions.reverse();
13598
+ return divisions;
13599
+ }
13600
+ function getSubBlock({ blockPattern, index }) {
13601
+ let i = 0;
13602
+ for (const subBlock of blockPattern) {
13603
+ if (i === index)
13604
+ return subBlock;
13605
+ let j = 0;
13606
+ while (j < subBlock.length) {
13607
+ if (i === index)
13608
+ return subBlock;
13609
+ i += 1;
13610
+ j++;
13611
+ }
13612
+ }
13613
+ }
13614
+ function generateBlockPattern({
13615
+ positioning,
13616
+ size
13617
+ }) {
13618
+ const divisions = getDivisions({ size });
13619
+ const divisionGroupings = [];
13620
+ const selected = [];
13621
+ const firstMember = (arr) => arr[0];
13622
+ const lastMember = (arr) => arr[arr.length - 1];
13623
+ const getMember = (arr, i) => (positioning === CLUSTER && i % 2 ? lastMember(arr) : firstMember(arr)) || firstMember(arr);
13624
+ const noneSelected = (chunk, i) => {
13625
+ if (chunk.every((member) => !selected.includes(member))) {
13626
+ const member = getMember(chunk, i);
13627
+ selected.push(member);
13628
+ return member;
13629
+ }
13630
+ };
13631
+ const notSelected = (chunk) => {
13632
+ const notSelected2 = chunk.filter((member) => !selected.includes(member));
13633
+ if (notSelected2.length) {
13634
+ selected.push(...notSelected2);
13635
+ return notSelected2;
13636
+ }
13637
+ };
13638
+ const select = (chunk, i) => {
13639
+ const member = getMember(chunk, i);
13640
+ if (!selected.includes(member)) {
13641
+ selected.push(member);
13642
+ return member;
13643
+ }
13644
+ };
13645
+ const range = generateRange(1, size + 1);
13646
+ for (const division of divisions) {
13647
+ if (division === 1) {
13648
+ const chunks = chunkArray(range, 2);
13649
+ const positions = chunks.map(noneSelected).filter(Boolean);
13650
+ if (positions.length)
13651
+ divisionGroupings.push(positions);
13652
+ const lastPositions = chunks.flatMap(notSelected).filter(Boolean);
13653
+ if (lastPositions.length)
13654
+ divisionGroupings.push(lastPositions);
13655
+ } else {
13656
+ const chunks = chunkArray(range, division);
13657
+ const positions = chunks.map(select).filter(Boolean);
13658
+ if (positions.length)
13659
+ divisionGroupings.push(positions);
13660
+ }
13661
+ }
13662
+ return { divisions, divisionGroupings };
13663
+ }
13664
+
13587
13665
  function getValidSeedBlocks({
13588
13666
  provisionalPositioning,
13589
13667
  returnAllProxies,
13590
13668
  appliedPolicies,
13669
+ seedingProfile,
13591
13670
  drawDefinition,
13592
13671
  allPositions,
13593
13672
  structure
@@ -13621,7 +13700,7 @@ function getValidSeedBlocks({
13621
13700
  }).filter((f) => f.length).reverse();
13622
13701
  const firstRoundDrawPositions = uniqueDrawPositionsByRound.pop();
13623
13702
  const firstRoundDrawPositionOffset = firstRoundDrawPositions && Math.min(...firstRoundDrawPositions) - 1 || 0;
13624
- const seedingProfile = appliedPolicies?.seeding?.seedingProfile;
13703
+ seedingProfile = seedingProfile ?? appliedPolicies?.seeding?.seedingProfile;
13625
13704
  const baseDrawSize = firstRoundDrawPositions?.length || 0;
13626
13705
  const seedRangeDrawPositionBlocks = uniqueDrawPositionsByRound.filter(
13627
13706
  (block) => block.filter((drawPosition) => drawPosition <= seedsCount).length
@@ -13660,12 +13739,14 @@ function getValidSeedBlocks({
13660
13739
  );
13661
13740
  ({ validSeedBlocks } = getSeedBlockPattern({
13662
13741
  drawPositionBlocks: drawPositionChunks,
13742
+ nonRandom: seedingProfile?.nonRandom,
13663
13743
  positioning,
13664
13744
  seedGroups
13665
13745
  }));
13666
13746
  }
13667
13747
  } else if (isContainer) {
13668
13748
  const result = getContainerBlocks({
13749
+ nonRandom: seedingProfile?.nonRandom,
13669
13750
  seedingProfile,
13670
13751
  structure
13671
13752
  });
@@ -13715,7 +13796,7 @@ function getValidSeedBlocks({
13715
13796
  isFeedIn
13716
13797
  };
13717
13798
  }
13718
- function getContainerBlocks({ seedingProfile, structure }) {
13799
+ function getContainerBlocks({ seedingProfile, structure, nonRandom }) {
13719
13800
  const containedStructures = structure.structures || [];
13720
13801
  const roundRobinGroupsCount = containedStructures.length;
13721
13802
  const positionAssignments = getPositionAssignments({
@@ -13735,26 +13816,48 @@ function getContainerBlocks({ seedingProfile, structure }) {
13735
13816
  return getSeedBlockPattern({
13736
13817
  drawPositionBlocks,
13737
13818
  positioning,
13738
- seedGroups
13819
+ seedGroups,
13820
+ nonRandom
13739
13821
  });
13740
13822
  }
13741
- function getSeedBlockPattern({ positioning, seedGroups, drawPositionBlocks }) {
13823
+ function getSeedBlockPattern({
13824
+ drawPositionBlocks,
13825
+ positioning,
13826
+ seedGroups,
13827
+ nonRandom
13828
+ }) {
13742
13829
  const validSeedBlocks = [];
13743
- const topDown = (a, b) => a - b;
13744
- const bottomUp = (a, b) => b - a;
13830
+ const { divisionGroupings } = generateBlockPattern({
13831
+ size: seedGroups.length,
13832
+ positioning
13833
+ });
13745
13834
  const assignedPositions = [];
13746
13835
  seedGroups.forEach((seedGroup, i) => {
13747
- if (i && positioning !== WATERFALL) {
13748
- shuffleArray(seedGroup);
13749
- }
13836
+ const relativePositions = getSubBlock({
13837
+ blockPattern: divisionGroupings,
13838
+ index: i
13839
+ });
13750
13840
  seedGroup.forEach((seedNumber, j) => {
13751
13841
  const blockIndex = i % 2 ? drawPositionBlocks.length - j - 1 : j;
13752
- const drawPosition = drawPositionBlocks[blockIndex].sort(i % 2 ? bottomUp : topDown).find((drawPosition2) => !assignedPositions.includes(drawPosition2));
13753
- assignedPositions.push(drawPosition);
13754
- validSeedBlocks.push({
13755
- seedNumbers: [seedNumber],
13756
- drawPositions: [drawPosition]
13757
- });
13842
+ const block = drawPositionBlocks[blockIndex].slice();
13843
+ let consideredDrawPositions = block.filter(
13844
+ (drawPosition2, i2) => relativePositions.includes(i2 + 1) && drawPosition2
13845
+ );
13846
+ if (positioning !== WATERFALL) {
13847
+ consideredDrawPositions = nonRandom ? consideredDrawPositions : shuffleArray(consideredDrawPositions);
13848
+ } else if (i % 2) {
13849
+ consideredDrawPositions.reverse();
13850
+ }
13851
+ const drawPosition = consideredDrawPositions.find(
13852
+ (drawPosition2) => !assignedPositions.includes(drawPosition2)
13853
+ );
13854
+ if (drawPosition) {
13855
+ assignedPositions.push(drawPosition);
13856
+ validSeedBlocks.push({
13857
+ seedNumbers: [seedNumber],
13858
+ drawPositions: [drawPosition]
13859
+ });
13860
+ }
13758
13861
  });
13759
13862
  });
13760
13863
  return { validSeedBlocks };
@@ -13831,6 +13934,7 @@ function getNextSeedBlock(params) {
13831
13934
  const {
13832
13935
  provisionalPositioning,
13833
13936
  drawDefinition,
13937
+ seedingProfile,
13834
13938
  seedBlockInfo,
13835
13939
  structureId,
13836
13940
  randomize
@@ -13853,6 +13957,7 @@ function getNextSeedBlock(params) {
13853
13957
  provisionalPositioning,
13854
13958
  appliedPolicies,
13855
13959
  drawDefinition,
13960
+ seedingProfile,
13856
13961
  structure
13857
13962
  })?.validSeedBlocks;
13858
13963
  const unfilledSeedBlocks = (validSeedBlocks || []).filter((seedBlock) => {
@@ -13946,6 +14051,7 @@ function getValidAssignmentActions({
13946
14051
  returnParticipants,
13947
14052
  appliedPolicies,
13948
14053
  drawDefinition,
14054
+ seedingProfile,
13949
14055
  isByePosition,
13950
14056
  drawPosition,
13951
14057
  structureId,
@@ -13961,6 +14067,7 @@ function getValidAssignmentActions({
13961
14067
  returnAllProxies: true,
13962
14068
  randomize: true,
13963
14069
  drawDefinition,
14070
+ seedingProfile,
13964
14071
  structureId,
13965
14072
  event
13966
14073
  });