tods-competition-factory 1.8.23 → 1.8.24

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
@@ -2382,7 +2382,7 @@ const matchUpFormatCode = {
2382
2382
  };
2383
2383
 
2384
2384
  function factoryVersion() {
2385
- return "1.8.23";
2385
+ return "1.8.24";
2386
2386
  }
2387
2387
 
2388
2388
  function getObjectTieFormat(obj) {
@@ -3811,18 +3811,17 @@ function getTallyReport({ matchUps, order, report }) {
3811
3811
  readable.push(excluded);
3812
3812
  } else {
3813
3813
  const floatSort = (a, b) => parseFloat(step.reversed ? a : b) - parseFloat(step.reversed ? b : a);
3814
+ const participantsCount = step.groups ? Object.values(step.groups).flat(Infinity).length : step.participantIds?.length ?? 0;
3814
3815
  const getExplanation = (step2) => {
3815
- Object.keys(step2.groups).sort(floatSort).forEach((key) => {
3816
+ step2.groups && Object.keys(step2.groups).sort(floatSort).forEach((key) => {
3816
3817
  const participantNames = step2.groups[key].map((participantId) => participants[participantId]).join(", ");
3817
3818
  const explanation = `${key} ${step2.attribute}: ${participantNames}`;
3818
3819
  readable.push(explanation);
3819
3820
  });
3820
3821
  };
3821
3822
  const reversed = step.reversed ? " in reverse order" : "";
3822
- const participantsCount = Object.values(step.groups).flat(
3823
- Infinity
3824
- ).length;
3825
- const description = `Step ${i + 1}: ${participantsCount} particiants were grouped${reversed} by ${step.attribute}`;
3823
+ const action = step.groups ? "grouped" : "separated";
3824
+ const description = `Step ${i + 1}: ${participantsCount} particiants were ${action}${reversed} by ${step.attribute}`;
3826
3825
  readable.push(description);
3827
3826
  if (step.idsFilter) {
3828
3827
  const note = `${step.attribute} was calculated considering ONLY TIED PARTICIPANTS`;
@@ -3838,7 +3837,7 @@ function getTallyReport({ matchUps, order, report }) {
3838
3837
  const { participantId, resolved } = orderEntry;
3839
3838
  const pOrder = orderEntry.groupOrder || orderEntry.provisionalOrder;
3840
3839
  readable.push(
3841
- `${pOrder}: ${participants[participantId]} => resolved: ${resolved}`
3840
+ `${pOrder}: ${participants[participantId]} => resolved: ${!!resolved}`
3842
3841
  );
3843
3842
  });
3844
3843
  return readable.join("\r\n");
@@ -3927,7 +3926,7 @@ function getGroupOrder(params) {
3927
3926
  report.push({ attribute, groups: orderedTallyGroups });
3928
3927
  const groupOrder = Object.keys(orderedTallyGroups).map((key) => parseFloat(key)).sort((a, b) => b - a).map((key) => orderedTallyGroups[key]).map((participantIds) => {
3929
3928
  const result = groupSubSort({ participantIds, ...params });
3930
- report.push(result.report);
3929
+ report.push(...result.report || []);
3931
3930
  return result.order;
3932
3931
  }).flat(Infinity);
3933
3932
  let groupPosition = 1;
@@ -4019,7 +4018,7 @@ function processAttribute({
4019
4018
  tallyPolicy,
4020
4019
  matchUps
4021
4020
  });
4022
- report.push(result.report);
4021
+ report.push(...result.report || []);
4023
4022
  return result.order;
4024
4023
  }).flat(Infinity);
4025
4024
  }
@@ -4033,6 +4032,9 @@ function groupSubSort({
4033
4032
  tallyPolicy,
4034
4033
  matchUps
4035
4034
  }) {
4035
+ const excludedDirectives = [];
4036
+ const report = [];
4037
+ let result;
4036
4038
  if (participantIds?.length === 1) {
4037
4039
  const participantId = participantIds[0];
4038
4040
  return {
@@ -4041,13 +4043,13 @@ function groupSubSort({
4041
4043
  }
4042
4044
  if (participantIds?.length === 2 && (!tallyPolicy?.headToHead || !tallyPolicy.headToHead.disabled && !disableHeadToHead)) {
4043
4045
  const result2 = headToHeadWinner({ participantIds, participantResults });
4044
- if (result2)
4045
- return { order: [result2], headToHeadWinner: result2[0].participantId };
4046
+ if (result2) {
4047
+ const headToHeadWinner2 = result2[0].participantId;
4048
+ report.push({ attribute: "head2Head", participantIds, headToHeadWinner: headToHeadWinner2 });
4049
+ return { order: [result2], headToHeadWinner: headToHeadWinner2, report };
4050
+ }
4046
4051
  }
4047
4052
  const directives = tallyPolicy?.tallyDirectives || headToHeadTallyDirectives;
4048
- const excludedDirectives = [];
4049
- const report = [];
4050
- let result;
4051
4053
  const filteredDirectives = directives.filter((directive) => {
4052
4054
  const keepDirective = isNumeric(directive.maxParticipants) && participantIds?.length > directive.maxParticipants ? false : true;
4053
4055
  if (!keepDirective)
@@ -7775,7 +7777,8 @@ const POLICY_ROUND_NAMING_DEFAULT = {
7775
7777
  [POLICY_TYPE_ROUND_NAMING]: {
7776
7778
  policyName: "Round Naming Default",
7777
7779
  namingConventions: {
7778
- round: "Round"
7780
+ round: "Round",
7781
+ pre: "Pre"
7779
7782
  },
7780
7783
  qualifyingFinishMap: {
7781
7784
  1: "Final"
@@ -7819,12 +7822,11 @@ function getRoundContextProfile({
7819
7822
  const roundNamingProfile = {};
7820
7823
  const defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
7821
7824
  const isQualifying = structure.stage === QUALIFYING;
7822
- const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
7823
7825
  const qualifyingStageSequences = isQualifying ? Math.max(
7824
7826
  ...(drawDefinition?.structures ?? []).filter((structure2) => structure2.stage === QUALIFYING).map(({ stageSequence }) => stageSequence ?? 1),
7825
7827
  0
7826
7828
  ) : 0;
7827
- const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence ?? 1) || "" : "";
7829
+ const preQualifyingSequence = (structure.stageSequence ?? 1) < qualifyingStageSequences ? structure.stageSequence ?? 1 : "";
7828
7830
  const preQualifyingAffix = preQualifyingSequence ? roundNamingPolicy?.affixes?.preQualifying || defaultRoundNamingPolicy.affixes.preQualifying || "" : "";
7829
7831
  const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
7830
7832
  const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
@@ -7848,6 +7850,7 @@ function getRoundContextProfile({
7848
7850
  })
7849
7851
  );
7850
7852
  } else {
7853
+ const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
7851
7854
  Object.assign(
7852
7855
  roundNamingProfile,
7853
7856
  ...roundProfileKeys.map((round) => {
@@ -10122,8 +10125,10 @@ function modifyMatchUpScore({
10122
10125
  const matchUpFilters = isDualMatchUp ? { matchUpTypes: [TEAM$2] } : void 0;
10123
10126
  const { matchUps } = getAllStructureMatchUps({
10124
10127
  afterRecoveryTimes: false,
10128
+ tournamentRecord,
10125
10129
  inContext: true,
10126
10130
  matchUpFilters,
10131
+ drawDefinition,
10127
10132
  structure: structure2,
10128
10133
  event
10129
10134
  });
@@ -23088,7 +23093,10 @@ function getAffectedTargetStructureIds({
23088
23093
  return { structureIds };
23089
23094
  }
23090
23095
 
23091
- function getPlayoffStructures({ drawDefinition, structureId }) {
23096
+ function getPlayoffStructures({
23097
+ drawDefinition,
23098
+ structureId
23099
+ }) {
23092
23100
  if (!drawDefinition)
23093
23101
  return { error: MISSING_DRAW_DEFINITION };
23094
23102
  const { structure } = findStructure({ drawDefinition, structureId });
@@ -23223,7 +23231,7 @@ function allPlayoffPositionsFilled(params) {
23223
23231
  return assignment?.bye || assignment?.participantId;
23224
23232
  }
23225
23233
  ).length;
23226
- return structurePositionsFilled && allFilled;
23234
+ return !!(structurePositionsFilled && allFilled);
23227
23235
  },
23228
23236
  !!playoffStructures.length
23229
23237
  );
@@ -43393,6 +43401,142 @@ function generateVoluntaryConsolation$1(params) {
43393
43401
  return { links, structures, ...SUCCESS };
43394
43402
  }
43395
43403
 
43404
+ function getStructureGroups({
43405
+ drawDefinition
43406
+ }) {
43407
+ const structures = drawDefinition.structures || [];
43408
+ const links = drawDefinition.links || [];
43409
+ const structureProfiles = /* @__PURE__ */ new Map();
43410
+ const initStructureProfile = (structureId) => {
43411
+ const profile = structureProfiles.get(structureId) || structureProfiles.set(structureId, {
43412
+ drawSources: [],
43413
+ drawTargets: [],
43414
+ progeny: [],
43415
+ sources: [],
43416
+ targets: []
43417
+ }) && structureProfiles.get(structureId);
43418
+ if (profile && !profile?.stage) {
43419
+ const structure = structures.find(
43420
+ (structure2) => structure2.structureId === structureId
43421
+ );
43422
+ profile.stage = structure?.stage;
43423
+ }
43424
+ return profile;
43425
+ };
43426
+ const sourceStructureIds = {};
43427
+ const hasDrawFeedProfile = {};
43428
+ let linkedStructureIds = links.map((link) => {
43429
+ const sourceId = link.source.structureId;
43430
+ const targetId = link.target.structureId;
43431
+ const sourceProfile = initStructureProfile(sourceId);
43432
+ const targetProfile = initStructureProfile(targetId);
43433
+ if ([BOTTOM_UP, TOP_DOWN, RANDOM, WATERFALL].includes(link.target.feedProfile)) {
43434
+ sourceProfile?.targets.push(targetId);
43435
+ targetProfile?.sources.push(sourceId);
43436
+ } else if (link.target.feedProfile === DRAW) {
43437
+ targetProfile?.drawSources.push(sourceId);
43438
+ sourceProfile?.drawTargets.push(targetId);
43439
+ }
43440
+ hasDrawFeedProfile[targetId] = hasDrawFeedProfile[targetId] || link.target.feedProfile === DRAW;
43441
+ sourceStructureIds[targetId] = unique([
43442
+ ...sourceStructureIds[targetId] || [],
43443
+ sourceId
43444
+ ]).filter(Boolean);
43445
+ return [link.source.structureId, link.target.structureId];
43446
+ });
43447
+ for (const structureId of structureProfiles.keys()) {
43448
+ const profile = structureProfiles.get(structureId);
43449
+ if (profile) {
43450
+ const sourceIds = profile.targets ?? [];
43451
+ while (sourceIds.length) {
43452
+ const sourceId = sourceIds.pop();
43453
+ const sourceProfile = sourceId && structureProfiles[sourceId];
43454
+ if (sourceProfile?.targets?.length) {
43455
+ sourceIds.push(...sourceProfile.targets);
43456
+ } else if (sourceProfile) {
43457
+ profile.rootStage = sourceProfile.stage;
43458
+ }
43459
+ }
43460
+ if (!profile.rootStage)
43461
+ profile.rootStage = profile.stage;
43462
+ if (!profile.targets?.length) {
43463
+ const targetIds = profile.sources ?? [];
43464
+ while (targetIds.length) {
43465
+ const targetId = targetIds.pop();
43466
+ const targetProfile = targetId && structureProfiles[targetId];
43467
+ if (targetProfile?.sources?.length) {
43468
+ for (const id of targetProfile.sources) {
43469
+ if (!profile.progeny?.includes(id))
43470
+ profile.progeny?.push(id);
43471
+ }
43472
+ targetIds.push(...targetProfile.sources);
43473
+ }
43474
+ }
43475
+ }
43476
+ }
43477
+ }
43478
+ let maxQualifyingDepth = 0;
43479
+ for (const structureId of structureProfiles.keys()) {
43480
+ const profile = structureProfiles.get(structureId);
43481
+ if (profile && profile.rootStage === QUALIFYING) {
43482
+ const drawTargets = [profile.drawTargets?.[0]];
43483
+ let distanceFromMain = 0;
43484
+ while (drawTargets.length) {
43485
+ distanceFromMain += 1;
43486
+ const drawTarget = drawTargets.pop();
43487
+ const targetProfile = drawTarget ? structureProfiles.get(drawTarget) : void 0;
43488
+ if (targetProfile?.drawTargets?.length) {
43489
+ drawTargets.push(targetProfile.drawTargets[0]);
43490
+ }
43491
+ }
43492
+ profile.distanceFromMain = distanceFromMain;
43493
+ if (distanceFromMain > maxQualifyingDepth)
43494
+ maxQualifyingDepth = distanceFromMain;
43495
+ }
43496
+ }
43497
+ const iterations = linkedStructureIds.length;
43498
+ generateRange(0, Math.ceil(iterations / 2)).forEach(() => {
43499
+ linkedStructureIds = generateRange(0, iterations).map((index) => {
43500
+ const structureIds = linkedStructureIds[index];
43501
+ const mergedWithOverlappingIds = linkedStructureIds.reduce((biggest, ids) => {
43502
+ const hasOverlap = overlap(structureIds, ids);
43503
+ return hasOverlap ? biggest.concat(...ids) : biggest;
43504
+ }, []) || [];
43505
+ return unique(structureIds.concat(...mergedWithOverlappingIds));
43506
+ });
43507
+ });
43508
+ const groupedStructureIds = linkedStructureIds[0];
43509
+ const identityLink = (a, b) => intersection(a, b).length === a.length;
43510
+ const allLinkStructuresLinked = linkedStructureIds.slice(1).reduce((allLinkStructuresLinked2, ids) => {
43511
+ return allLinkStructuresLinked2 && identityLink(ids, groupedStructureIds);
43512
+ }, true);
43513
+ const structureGroups = [groupedStructureIds].filter(Boolean);
43514
+ const linkCheck = [groupedStructureIds].filter(Boolean);
43515
+ structures.forEach((structure) => {
43516
+ const { structureId, stage } = structure;
43517
+ const existingGroup = structureGroups.find((group) => {
43518
+ return group.includes(structureId);
43519
+ });
43520
+ if (!existingGroup) {
43521
+ structureGroups.push([structureId]);
43522
+ if (stage !== VOLUNTARY_CONSOLATION)
43523
+ linkCheck.push([structureId]);
43524
+ }
43525
+ });
43526
+ const allStructuresLinked = allLinkStructuresLinked && linkCheck.length === 1;
43527
+ if (!links?.length && structures.length === 1) {
43528
+ initStructureProfile(structures[0].structureId);
43529
+ }
43530
+ return {
43531
+ structureProfiles: Object.fromEntries(structureProfiles),
43532
+ allStructuresLinked,
43533
+ maxQualifyingDepth,
43534
+ sourceStructureIds,
43535
+ hasDrawFeedProfile,
43536
+ structureGroups
43537
+ };
43538
+ }
43539
+
43396
43540
  function generateQualifyingStructure$1(params) {
43397
43541
  if (!params.drawDefinition)
43398
43542
  return { error: MISSING_DRAW_DEFINITION };
@@ -43417,65 +43561,25 @@ function generateQualifyingStructure$1(params) {
43417
43561
  let roundLimit, roundsCount, structure, matchUps;
43418
43562
  let qualifiersCount = 0;
43419
43563
  let finishingPositions;
43420
- let stageSequence = 1;
43564
+ const stageSequence = 1;
43421
43565
  if (!isConvertableInteger(drawSize)) {
43422
43566
  return decorateResult({ result: { error: MISSING_DRAW_SIZE }, stack });
43423
43567
  }
43424
- const result = findStructure({
43425
- structureId: targetStructureId,
43426
- drawDefinition
43427
- });
43428
- if (result.error) {
43568
+ const { structureProfiles } = getStructureGroups({ drawDefinition });
43569
+ const structureProfile = structureProfiles[targetStructureId];
43570
+ if (!structureProfile) {
43429
43571
  return decorateResult({
43572
+ result: { error: STRUCTURE_NOT_FOUND },
43430
43573
  context: { targetStructureId },
43431
- result,
43432
43574
  stack
43433
43575
  });
43434
43576
  }
43435
- if (!result.structure)
43436
- return { error: STRUCTURE_NOT_FOUND };
43437
- const targetStructure = result.structure;
43438
- const matchUpType = targetStructure.matchUpType;
43439
- if (targetStructure.stage === QUALIFYING) {
43440
- if (targetStructure.stageSequence && targetStructure.stageSequence > 1) {
43441
- stageSequence = targetStructure.stageSequence - 1;
43442
- } else {
43443
- let nextStructureId = targetStructureId;
43444
- let nextStageSequence = 2;
43445
- let chainModified;
43446
- while (!chainModified && nextStructureId) {
43447
- console.log("check getRoundContextProfile preqQualifyingStageSequence");
43448
- targetStructure.stageSequence = nextStageSequence;
43449
- const targetTargetStructureId = drawDefinition.links?.find(
43450
- (link2) => link2.source.structureId === nextStructureId
43451
- )?.target?.structureId;
43452
- nextStructureId = targetTargetStructureId;
43453
- nextStageSequence += 1;
43454
- if (!targetTargetStructureId) {
43455
- chainModified = true;
43456
- } else {
43457
- const result2 = findStructure({
43458
- structureId: targetTargetStructureId,
43459
- drawDefinition
43460
- });
43461
- if (!result2.structure)
43462
- return { error: STRUCTURE_NOT_FOUND };
43463
- if (result2.error) {
43464
- return decorateResult({
43465
- context: { targetTargetStructureId },
43466
- result: result2,
43467
- stack
43468
- });
43469
- }
43470
- if (result2.structure.stage !== QUALIFYING)
43471
- chainModified = true;
43472
- }
43473
- }
43474
- }
43475
- }
43577
+ const matchUpType = drawDefinition.matchUpType;
43476
43578
  const roundTargetName = roundTarget ? `${roundTarget}-` : "";
43477
- const stageSequenceName = `${stageSequence}`;
43478
- const qualifyingStructureName = structureName ?? (roundTargetName || stageSequenceName ? `${constantToString(QUALIFYING)} ${roundTargetName}${stageSequenceName}` : constantToString(QUALIFYING));
43579
+ const isPreQualifying = structureProfile.stage === QUALIFYING;
43580
+ const preQualifyingNaming = appliedPolicies?.[POLICY_TYPE_ROUND_NAMING]?.namingConventions?.pre ?? POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING]?.namingConventions?.pre;
43581
+ const pre = isPreQualifying && preQualifyingNaming ? `${preQualifyingNaming}-` : "";
43582
+ const qualifyingStructureName = structureName ?? (roundTargetName ? `${pre}${constantToString(QUALIFYING)} ${roundTargetName}` : `${pre}${constantToString(QUALIFYING)}`);
43479
43583
  if (drawType === ROUND_ROBIN) {
43480
43584
  const { maxRoundNumber, structures, groupCount } = generateRoundRobin({
43481
43585
  structureName: structureName ?? qualifyingStructureName,
@@ -43530,13 +43634,13 @@ function generateQualifyingStructure$1(params) {
43530
43634
  )?.length;
43531
43635
  }
43532
43636
  const linkType = drawType === ROUND_ROBIN ? LinkTypeEnum.Position : LinkTypeEnum.Winner;
43533
- const { link } = generateQualifyingLink({
43637
+ const link = structure && roundLimit && generateQualifyingLink({
43534
43638
  sourceStructureId: structure.structureId,
43535
43639
  sourceRoundNumber: roundLimit,
43536
43640
  targetStructureId,
43537
43641
  finishingPositions,
43538
43642
  linkType
43539
- });
43643
+ })?.link;
43540
43644
  return {
43541
43645
  qualifyingDrawPositionsCount: drawSize,
43542
43646
  qualifiersCount,
@@ -43576,6 +43680,15 @@ function attachQualifyingStructure$1({
43576
43680
  drawDefinition.links = [];
43577
43681
  drawDefinition.structures.push(structure);
43578
43682
  drawDefinition.links.push(link);
43683
+ const { maxQualifyingDepth, structureProfiles } = getStructureGroups({
43684
+ drawDefinition
43685
+ });
43686
+ for (const structure2 of drawDefinition.structures) {
43687
+ const profile = structureProfiles[structure2.structureId];
43688
+ if (profile.distanceFromMain) {
43689
+ structure2.stageSequence = maxQualifyingDepth + 1 - profile.distanceFromMain;
43690
+ }
43691
+ }
43579
43692
  const matchUps = getAllStructureMatchUps({ structure })?.matchUps || [];
43580
43693
  addMatchUpsNotice({
43581
43694
  drawDefinition,
@@ -43799,6 +43912,10 @@ function getAdvancingParticipantId(matchUp) {
43799
43912
  }
43800
43913
 
43801
43914
  function addQualifyingStructure$1(params) {
43915
+ if (!params.drawDefinition)
43916
+ return { error: MISSING_DRAW_DEFINITION };
43917
+ if (!params.targetStructureId)
43918
+ return { error: MISSING_STRUCTURE_ID };
43802
43919
  const result = generateQualifyingStructure$1(params);
43803
43920
  if (result.error)
43804
43921
  return result;
@@ -52351,59 +52468,6 @@ function unPublishEvent({
52351
52468
  return { eventId: event.eventId, ...SUCCESS };
52352
52469
  }
52353
52470
 
52354
- function getStructureGroups({ drawDefinition }) {
52355
- const links = drawDefinition.links || [];
52356
- const sourceStructureIds = {};
52357
- const hasDrawFeedProfile = {};
52358
- let linkedStructureIds = links.map((link) => {
52359
- const sourceId = link.source.structureId;
52360
- const targetId = link.target.structureId;
52361
- hasDrawFeedProfile[targetId] = hasDrawFeedProfile[targetId] || link.target.feedProfile === DRAW;
52362
- sourceStructureIds[targetId] = unique([
52363
- ...sourceStructureIds[targetId] || [],
52364
- sourceId
52365
- ]).filter(Boolean);
52366
- return [link.source.structureId, link.target.structureId];
52367
- });
52368
- const iterations = linkedStructureIds.length;
52369
- generateRange(0, Math.ceil(iterations / 2)).forEach(() => {
52370
- linkedStructureIds = generateRange(0, iterations).map((index) => {
52371
- const structureIds = linkedStructureIds[index];
52372
- const mergedWithOverlappingIds = linkedStructureIds.reduce((biggest, ids) => {
52373
- const hasOverlap = overlap(structureIds, ids);
52374
- return hasOverlap ? biggest.concat(...ids) : biggest;
52375
- }, []) || [];
52376
- return unique(structureIds.concat(...mergedWithOverlappingIds));
52377
- });
52378
- });
52379
- const groupedStructureIds = linkedStructureIds[0];
52380
- const identityLink = (a, b) => intersection(a, b).length === a.length;
52381
- const allLinkStructuresLinked = linkedStructureIds.slice(1).reduce((allLinkStructuresLinked2, ids) => {
52382
- return allLinkStructuresLinked2 && identityLink(ids, groupedStructureIds);
52383
- }, true);
52384
- const structureGroups = [groupedStructureIds].filter(Boolean);
52385
- const linkCheck = [groupedStructureIds].filter(Boolean);
52386
- const structures = drawDefinition.structures || [];
52387
- structures.forEach((structure) => {
52388
- const { structureId, stage } = structure;
52389
- const existingGroup = structureGroups.find((group) => {
52390
- return group.includes(structureId);
52391
- });
52392
- if (!existingGroup) {
52393
- structureGroups.push([structureId]);
52394
- if (stage !== VOLUNTARY_CONSOLATION)
52395
- linkCheck.push(structureId);
52396
- }
52397
- });
52398
- const allStructuresLinked = allLinkStructuresLinked && linkCheck.length === 1;
52399
- return {
52400
- allStructuresLinked,
52401
- sourceStructureIds,
52402
- hasDrawFeedProfile,
52403
- structureGroups
52404
- };
52405
- }
52406
-
52407
52471
  function getDrawData(params) {
52408
52472
  const {
52409
52473
  tournamentParticipants = [],
@@ -52462,12 +52526,18 @@ function getDrawData(params) {
52462
52526
  }
52463
52527
  return structure;
52464
52528
  }).sort((a, b) => structureSort(a, b, sortConfig)).map((structure) => {
52465
- const { structureId } = structure;
52529
+ if (!structure)
52530
+ return;
52531
+ const structureId = structure?.structureId;
52466
52532
  let seedAssignments = [];
52467
- if ([MAIN, CONSOLATION, PLAY_OFF].includes(structure.stage)) {
52533
+ if (structure.stage && [
52534
+ StageTypeEnum.Main,
52535
+ StageTypeEnum.Consolation,
52536
+ StageTypeEnum.PlayOff
52537
+ ].includes(structure.stage)) {
52468
52538
  seedAssignments = mainStageSeedAssignments;
52469
52539
  }
52470
- if (structure.stage === QUALIFYING) {
52540
+ if (structure?.stage === QUALIFYING) {
52471
52541
  seedAssignments = qualificationStageSeedAssignments;
52472
52542
  }
52473
52543
  const { matchUps, roundMatchUps, roundProfile } = getAllStructureMatchUps({
@@ -52498,7 +52568,7 @@ function getDrawData(params) {
52498
52568
  participantResult: extension.value
52499
52569
  };
52500
52570
  }).filter((f) => f?.participantResult);
52501
- const structureInfo = (({
52571
+ const structureInfo = structure ? (({
52502
52572
  stageSequence,
52503
52573
  structureName,
52504
52574
  structureType,
@@ -52510,7 +52580,7 @@ function getDrawData(params) {
52510
52580
  structureType,
52511
52581
  matchUpFormat,
52512
52582
  stage
52513
- }))(structure);
52583
+ }))(structure) : {};
52514
52584
  structureInfo.sourceStructureIds = sourceStructureIds[structureId];
52515
52585
  structureInfo.hasDrawFeedProfile = hasDrawFeedProfile[structureId];
52516
52586
  structureInfo.positionAssignments = positionAssignments;
@@ -54627,7 +54697,7 @@ function getEntryStatusReports({
54627
54697
  drawDefinitionsCount += 1;
54628
54698
  const stageFilter = ({ stage, stageSequence }) => stage === MAIN && stageSequence === 1 || stage === QUALIFYING;
54629
54699
  const structures = params.structures ?? [];
54630
- const assignedParticipantIds = structures.filter(stageFilter).flatMap(({ positionAssignments }) => positionAssignments).map(({ participantId }) => participantId).filter(Boolean);
54700
+ const assignedParticipantIds = structures.filter(stageFilter).flatMap(({ positionAssignments }) => positionAssignments).filter(Boolean).map(({ participantId }) => participantId);
54631
54701
  const entryFilter = ({ participantId }) => assignedParticipantIds.includes(participantId);
54632
54702
  const createEntryProfile = (params2) => {
54633
54703
  const { participantId, entryStatus, entryStage } = params2;
@@ -59444,7 +59514,10 @@ function isValidForQualifying({ structureId, drawDefinition }) {
59444
59514
  if (result.error)
59445
59515
  return result;
59446
59516
  const targetFeedProfiles = result.links.target.flatMap((t) => t.target.feedProfile).filter(Boolean);
59447
- const valid = !intersection([BOTTOM_UP, TOP_DOWN, RANDOM], targetFeedProfiles).length;
59517
+ const valid = !intersection(
59518
+ [BOTTOM_UP, TOP_DOWN, RANDOM, WATERFALL],
59519
+ targetFeedProfiles
59520
+ ).length;
59448
59521
  return { ...SUCCESS, valid };
59449
59522
  }
59450
59523