tods-competition-factory 1.8.23 → 1.8.25

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.
@@ -6760,7 +6760,8 @@ const POLICY_ROUND_NAMING_DEFAULT = {
6760
6760
  [POLICY_TYPE_ROUND_NAMING]: {
6761
6761
  policyName: "Round Naming Default",
6762
6762
  namingConventions: {
6763
- round: "Round"
6763
+ round: "Round",
6764
+ pre: "Pre"
6764
6765
  },
6765
6766
  qualifyingFinishMap: {
6766
6767
  1: "Final"
@@ -6804,12 +6805,11 @@ function getRoundContextProfile({
6804
6805
  const roundNamingProfile = {};
6805
6806
  const defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
6806
6807
  const isQualifying = structure.stage === QUALIFYING;
6807
- const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
6808
6808
  const qualifyingStageSequences = isQualifying ? Math.max(
6809
6809
  ...(drawDefinition?.structures ?? []).filter((structure2) => structure2.stage === QUALIFYING).map(({ stageSequence }) => stageSequence ?? 1),
6810
6810
  0
6811
6811
  ) : 0;
6812
- const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence ?? 1) || "" : "";
6812
+ const preQualifyingSequence = (structure.stageSequence ?? 1) < qualifyingStageSequences ? structure.stageSequence ?? 1 : "";
6813
6813
  const preQualifyingAffix = preQualifyingSequence ? roundNamingPolicy?.affixes?.preQualifying || defaultRoundNamingPolicy.affixes.preQualifying || "" : "";
6814
6814
  const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
6815
6815
  const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
@@ -6833,6 +6833,7 @@ function getRoundContextProfile({
6833
6833
  })
6834
6834
  );
6835
6835
  } else {
6836
+ const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
6836
6837
  Object.assign(
6837
6838
  roundNamingProfile,
6838
6839
  ...roundProfileKeys.map((round) => {
@@ -14557,13 +14558,42 @@ function positionActions(params) {
14557
14558
 
14558
14559
  const hasParticipantId = (o) => o?.participantId;
14559
14560
 
14560
- function getStructureGroups({ drawDefinition }) {
14561
+ function getStructureGroups({
14562
+ drawDefinition
14563
+ }) {
14564
+ const structures = drawDefinition.structures || [];
14561
14565
  const links = drawDefinition.links || [];
14566
+ const structureProfiles = /* @__PURE__ */ new Map();
14567
+ const initStructureProfile = (structureId) => {
14568
+ const profile = structureProfiles.get(structureId) || structureProfiles.set(structureId, {
14569
+ drawSources: [],
14570
+ drawTargets: [],
14571
+ progeny: [],
14572
+ sources: [],
14573
+ targets: []
14574
+ }) && structureProfiles.get(structureId);
14575
+ if (profile && !profile?.stage) {
14576
+ const structure = structures.find(
14577
+ (structure2) => structure2.structureId === structureId
14578
+ );
14579
+ profile.stage = structure?.stage;
14580
+ }
14581
+ return profile;
14582
+ };
14562
14583
  const sourceStructureIds = {};
14563
14584
  const hasDrawFeedProfile = {};
14564
14585
  let linkedStructureIds = links.map((link) => {
14565
14586
  const sourceId = link.source.structureId;
14566
14587
  const targetId = link.target.structureId;
14588
+ const sourceProfile = initStructureProfile(sourceId);
14589
+ const targetProfile = initStructureProfile(targetId);
14590
+ if ([BOTTOM_UP, TOP_DOWN, RANDOM, WATERFALL].includes(link.target.feedProfile)) {
14591
+ sourceProfile?.targets.push(targetId);
14592
+ targetProfile?.sources.push(sourceId);
14593
+ } else if (link.target.feedProfile === DRAW) {
14594
+ targetProfile?.drawSources.push(sourceId);
14595
+ sourceProfile?.drawTargets.push(targetId);
14596
+ }
14567
14597
  hasDrawFeedProfile[targetId] = hasDrawFeedProfile[targetId] || link.target.feedProfile === DRAW;
14568
14598
  sourceStructureIds[targetId] = unique([
14569
14599
  ...sourceStructureIds[targetId] || [],
@@ -14571,6 +14601,56 @@ function getStructureGroups({ drawDefinition }) {
14571
14601
  ]).filter(Boolean);
14572
14602
  return [link.source.structureId, link.target.structureId];
14573
14603
  });
14604
+ for (const structureId of structureProfiles.keys()) {
14605
+ const profile = structureProfiles.get(structureId);
14606
+ if (profile) {
14607
+ const sourceIds = profile.targets ?? [];
14608
+ while (sourceIds.length) {
14609
+ const sourceId = sourceIds.pop();
14610
+ const sourceProfile = sourceId && structureProfiles[sourceId];
14611
+ if (sourceProfile?.targets?.length) {
14612
+ sourceIds.push(...sourceProfile.targets);
14613
+ } else if (sourceProfile) {
14614
+ profile.rootStage = sourceProfile.stage;
14615
+ }
14616
+ }
14617
+ if (!profile.rootStage)
14618
+ profile.rootStage = profile.stage;
14619
+ if (!profile.targets?.length) {
14620
+ const targetIds = profile.sources ?? [];
14621
+ while (targetIds.length) {
14622
+ const targetId = targetIds.pop();
14623
+ const targetProfile = targetId && structureProfiles[targetId];
14624
+ if (targetProfile?.sources?.length) {
14625
+ for (const id of targetProfile.sources) {
14626
+ if (!profile.progeny?.includes(id))
14627
+ profile.progeny?.push(id);
14628
+ }
14629
+ targetIds.push(...targetProfile.sources);
14630
+ }
14631
+ }
14632
+ }
14633
+ }
14634
+ }
14635
+ let maxQualifyingDepth = 0;
14636
+ for (const structureId of structureProfiles.keys()) {
14637
+ const profile = structureProfiles.get(structureId);
14638
+ if (profile && profile.rootStage === QUALIFYING) {
14639
+ const drawTargets = [profile.drawTargets?.[0]];
14640
+ let distanceFromMain = 0;
14641
+ while (drawTargets.length) {
14642
+ distanceFromMain += 1;
14643
+ const drawTarget = drawTargets.pop();
14644
+ const targetProfile = drawTarget ? structureProfiles.get(drawTarget) : void 0;
14645
+ if (targetProfile?.drawTargets?.length) {
14646
+ drawTargets.push(targetProfile.drawTargets[0]);
14647
+ }
14648
+ }
14649
+ profile.distanceFromMain = distanceFromMain;
14650
+ if (distanceFromMain > maxQualifyingDepth)
14651
+ maxQualifyingDepth = distanceFromMain;
14652
+ }
14653
+ }
14574
14654
  const iterations = linkedStructureIds.length;
14575
14655
  generateRange(0, Math.ceil(iterations / 2)).forEach(() => {
14576
14656
  linkedStructureIds = generateRange(0, iterations).map((index) => {
@@ -14589,7 +14669,6 @@ function getStructureGroups({ drawDefinition }) {
14589
14669
  }, true);
14590
14670
  const structureGroups = [groupedStructureIds].filter(Boolean);
14591
14671
  const linkCheck = [groupedStructureIds].filter(Boolean);
14592
- const structures = drawDefinition.structures || [];
14593
14672
  structures.forEach((structure) => {
14594
14673
  const { structureId, stage } = structure;
14595
14674
  const existingGroup = structureGroups.find((group) => {
@@ -14598,12 +14677,17 @@ function getStructureGroups({ drawDefinition }) {
14598
14677
  if (!existingGroup) {
14599
14678
  structureGroups.push([structureId]);
14600
14679
  if (stage !== VOLUNTARY_CONSOLATION)
14601
- linkCheck.push(structureId);
14680
+ linkCheck.push([structureId]);
14602
14681
  }
14603
14682
  });
14604
14683
  const allStructuresLinked = allLinkStructuresLinked && linkCheck.length === 1;
14684
+ if (!links?.length && structures.length === 1) {
14685
+ initStructureProfile(structures[0].structureId);
14686
+ }
14605
14687
  return {
14688
+ structureProfiles: Object.fromEntries(structureProfiles),
14606
14689
  allStructuresLinked,
14690
+ maxQualifyingDepth,
14607
14691
  sourceStructureIds,
14608
14692
  hasDrawFeedProfile,
14609
14693
  structureGroups
@@ -14668,12 +14752,18 @@ function getDrawData(params) {
14668
14752
  }
14669
14753
  return structure;
14670
14754
  }).sort((a, b) => structureSort(a, b, sortConfig)).map((structure) => {
14671
- const { structureId } = structure;
14755
+ if (!structure)
14756
+ return;
14757
+ const structureId = structure?.structureId;
14672
14758
  let seedAssignments = [];
14673
- if ([MAIN, CONSOLATION, PLAY_OFF].includes(structure.stage)) {
14759
+ if (structure.stage && [
14760
+ StageTypeEnum.Main,
14761
+ StageTypeEnum.Consolation,
14762
+ StageTypeEnum.PlayOff
14763
+ ].includes(structure.stage)) {
14674
14764
  seedAssignments = mainStageSeedAssignments;
14675
14765
  }
14676
- if (structure.stage === QUALIFYING) {
14766
+ if (structure?.stage === QUALIFYING) {
14677
14767
  seedAssignments = qualificationStageSeedAssignments;
14678
14768
  }
14679
14769
  const { matchUps, roundMatchUps, roundProfile } = getAllStructureMatchUps({
@@ -14704,7 +14794,7 @@ function getDrawData(params) {
14704
14794
  participantResult: extension.value
14705
14795
  };
14706
14796
  }).filter((f) => f?.participantResult);
14707
- const structureInfo = (({
14797
+ const structureInfo = structure ? (({
14708
14798
  stageSequence,
14709
14799
  structureName,
14710
14800
  structureType,
@@ -14716,7 +14806,7 @@ function getDrawData(params) {
14716
14806
  structureType,
14717
14807
  matchUpFormat,
14718
14808
  stage
14719
- }))(structure);
14809
+ }))(structure) : {};
14720
14810
  structureInfo.sourceStructureIds = sourceStructureIds[structureId];
14721
14811
  structureInfo.hasDrawFeedProfile = hasDrawFeedProfile[structureId];
14722
14812
  structureInfo.positionAssignments = positionAssignments;