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.
@@ -1293,6 +1293,10 @@ var SCHEDULED_MATCHUPS = {
1293
1293
  message: 'Scheduled matchUps',
1294
1294
  code: 'ERR_SCHEDULED_MATCHUPS',
1295
1295
  };
1296
+ var SCORES_PRESENT = {
1297
+ message: 'Scores present',
1298
+ code: 'ERR_SCORES_PRESENT',
1299
+ };
1296
1300
  var errorConditionConstants = {
1297
1301
  ANACHRONISM: ANACHRONISM,
1298
1302
  CANNOT_CHANGE_WINNING_SIDE: CANNOT_CHANGE_WINNING_SIDE,
@@ -1455,6 +1459,7 @@ var errorConditionConstants = {
1455
1459
  POLICY_NOT_FOUND: POLICY_NOT_FOUND,
1456
1460
  SCHEDULE_NOT_CLEARED: SCHEDULE_NOT_CLEARED,
1457
1461
  SCHEDULED_MATCHUPS: SCHEDULED_MATCHUPS,
1462
+ SCORES_PRESENT: SCORES_PRESENT,
1458
1463
  SEEDSCOUNT_GREATER_THAN_DRAW_SIZE: SEEDSCOUNT_GREATER_THAN_DRAW_SIZE,
1459
1464
  STAGE_SEQUENCE_LIMIT: STAGE_SEQUENCE_LIMIT,
1460
1465
  STRUCTURE_NOT_FOUND: STRUCTURE_NOT_FOUND,
@@ -2905,7 +2910,7 @@ var matchUpFormatCode = {
2905
2910
  };
2906
2911
 
2907
2912
  function factoryVersion() {
2908
- return '1.8.23';
2913
+ return '1.8.25';
2909
2914
  }
2910
2915
 
2911
2916
  function getObjectTieFormat(obj) {
@@ -4904,7 +4909,7 @@ function getTallyReport(_a) {
4904
4909
  var readable = [];
4905
4910
  if (Array.isArray(report)) {
4906
4911
  report.forEach(function (step, i) {
4907
- var _a;
4912
+ var _a, _b, _c;
4908
4913
  if ((_a = step.excludedDirectives) === null || _a === void 0 ? void 0 : _a.length) {
4909
4914
  var attributes = step.excludedDirectives
4910
4915
  .map(function (_a) {
@@ -4921,20 +4926,24 @@ function getTallyReport(_a) {
4921
4926
  var floatSort_1 = function (a, b) {
4922
4927
  return parseFloat(step.reversed ? a : b) - parseFloat(step.reversed ? b : a);
4923
4928
  };
4929
+ var participantsCount = step.groups
4930
+ ? Object.values(step.groups).flat(Infinity).length
4931
+ : (_c = (_b = step.participantIds) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
4924
4932
  var getExplanation = function (step) {
4925
- Object.keys(step.groups)
4926
- .sort(floatSort_1)
4927
- .forEach(function (key) {
4928
- var participantNames = step.groups[key]
4929
- .map(function (participantId) { return participants[participantId]; })
4930
- .join(', ');
4931
- var explanation = "".concat(key, " ").concat(step.attribute, ": ").concat(participantNames);
4932
- readable.push(explanation);
4933
- });
4933
+ step.groups &&
4934
+ Object.keys(step.groups)
4935
+ .sort(floatSort_1)
4936
+ .forEach(function (key) {
4937
+ var participantNames = step.groups[key]
4938
+ .map(function (participantId) { return participants[participantId]; })
4939
+ .join(', ');
4940
+ var explanation = "".concat(key, " ").concat(step.attribute, ": ").concat(participantNames);
4941
+ readable.push(explanation);
4942
+ });
4934
4943
  };
4935
4944
  var reversed = step.reversed ? ' in reverse order' : '';
4936
- var participantsCount = Object.values(step.groups).flat(Infinity).length;
4937
- var description = "Step ".concat(i + 1, ": ").concat(participantsCount, " particiants were grouped").concat(reversed, " by ").concat(step.attribute);
4945
+ var action = step.groups ? 'grouped' : 'separated';
4946
+ var description = "Step ".concat(i + 1, ": ").concat(participantsCount, " particiants were ").concat(action).concat(reversed, " by ").concat(step.attribute);
4938
4947
  readable.push(description);
4939
4948
  if (step.idsFilter) {
4940
4949
  var note = "".concat(step.attribute, " was calculated considering ONLY TIED PARTICIPANTS");
@@ -4949,7 +4958,7 @@ function getTallyReport(_a) {
4949
4958
  order.forEach(function (orderEntry) {
4950
4959
  var participantId = orderEntry.participantId, resolved = orderEntry.resolved;
4951
4960
  var pOrder = orderEntry.groupOrder || orderEntry.provisionalOrder;
4952
- readable.push("".concat(pOrder, ": ").concat(participants[participantId], " => resolved: ").concat(resolved));
4961
+ readable.push("".concat(pOrder, ": ").concat(participants[participantId], " => resolved: ").concat(!!resolved));
4953
4962
  });
4954
4963
  return readable.join('\r\n');
4955
4964
  }
@@ -5073,7 +5082,7 @@ function getGroupOrder(params) {
5073
5082
  .map(function (key) { return orderedTallyGroups[key]; })
5074
5083
  .map(function (participantIds) {
5075
5084
  var result = groupSubSort(__assign({ participantIds: participantIds }, params));
5076
- report.push(result.report);
5085
+ report.push.apply(report, __spreadArray([], __read((result.report || [])), false));
5077
5086
  return result.order;
5078
5087
  })
5079
5088
  .flat(Infinity);
@@ -5182,7 +5191,7 @@ function processAttribute(_a) {
5182
5191
  tallyPolicy: tallyPolicy,
5183
5192
  matchUps: matchUps,
5184
5193
  });
5185
- report.push(result.report);
5194
+ report.push.apply(report, __spreadArray([], __read((result.report || [])), false));
5186
5195
  return result.order;
5187
5196
  })
5188
5197
  .flat(Infinity);
@@ -5191,6 +5200,9 @@ function processAttribute(_a) {
5191
5200
  }
5192
5201
  function groupSubSort(_a) {
5193
5202
  var participantResults = _a.participantResults, disableHeadToHead = _a.disableHeadToHead, participantIds = _a.participantIds, matchUpFormat = _a.matchUpFormat, tallyPolicy = _a.tallyPolicy, matchUps = _a.matchUps;
5203
+ var excludedDirectives = [];
5204
+ var report = [];
5205
+ var result;
5194
5206
  if ((participantIds === null || participantIds === void 0 ? void 0 : participantIds.length) === 1) {
5195
5207
  var participantId = participantIds[0];
5196
5208
  return {
@@ -5201,13 +5213,13 @@ function groupSubSort(_a) {
5201
5213
  (!(tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.headToHead) ||
5202
5214
  (!tallyPolicy.headToHead.disabled && !disableHeadToHead))) {
5203
5215
  var result_1 = headToHeadWinner({ participantIds: participantIds, participantResults: participantResults });
5204
- if (result_1)
5205
- return { order: [result_1], headToHeadWinner: result_1[0].participantId };
5216
+ if (result_1) {
5217
+ var headToHeadWinner_1 = result_1[0].participantId;
5218
+ report.push({ attribute: 'head2Head', participantIds: participantIds, headToHeadWinner: headToHeadWinner_1 });
5219
+ return { order: [result_1], headToHeadWinner: headToHeadWinner_1, report: report };
5220
+ }
5206
5221
  }
5207
5222
  var directives = (tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.tallyDirectives) || headToHeadTallyDirectives;
5208
- var excludedDirectives = [];
5209
- var report = [];
5210
- var result;
5211
5223
  var filteredDirectives = directives.filter(function (directive) {
5212
5224
  // if maxParticipants is defined, filter out the rule if # of participants is greater than maxParticipants
5213
5225
  var keepDirective = isNumeric(directive.maxParticipants) &&
@@ -9241,6 +9253,7 @@ var POLICY_ROUND_NAMING_DEFAULT = (_a$h = {},
9241
9253
  policyName: 'Round Naming Default',
9242
9254
  namingConventions: {
9243
9255
  round: 'Round',
9256
+ pre: 'Pre',
9244
9257
  },
9245
9258
  qualifyingFinishMap: {
9246
9259
  1: 'Final',
@@ -9271,9 +9284,9 @@ var POLICY_ROUND_NAMING_DEFAULT = (_a$h = {},
9271
9284
  _a$h);
9272
9285
 
9273
9286
  function getRoundContextProfile(_a) {
9274
- var _b, _c, _d, _e, _f;
9287
+ var _b, _c, _d, _e, _f, _g;
9275
9288
  var roundNamingPolicy = _a.roundNamingPolicy, drawDefinition = _a.drawDefinition, structure = _a.structure, matchUps = _a.matchUps;
9276
- var _g = getRoundMatchUps$1({ matchUps: matchUps }), roundProfile = _g.roundProfile, roundMatchUps = _g.roundMatchUps;
9289
+ var _h = getRoundMatchUps$1({ matchUps: matchUps }), roundProfile = _h.roundProfile, roundMatchUps = _h.roundMatchUps;
9277
9290
  var structureAbbreviation = structure.structureAbbreviation, stage = structure.stage;
9278
9291
  var isAdHocStructure = isAdHoc({ structure: structure });
9279
9292
  var isLuckyStructure = isLucky({ structure: structure });
@@ -9281,10 +9294,6 @@ function getRoundContextProfile(_a) {
9281
9294
  var roundNamingProfile = {};
9282
9295
  var defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
9283
9296
  var isQualifying = structure.stage === QUALIFYING;
9284
- var qualifyingFinishgMap = isQualifying &&
9285
- ((roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.qualifyingFinishMap) ||
9286
- (defaultRoundNamingPolicy === null || defaultRoundNamingPolicy === void 0 ? void 0 : defaultRoundNamingPolicy.qualifyingFinishMap) ||
9287
- {});
9288
9297
  var qualifyingStageSequences = isQualifying
9289
9298
  ? Math.max.apply(Math, __spreadArray(__spreadArray([], __read(((_b = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) !== null && _b !== void 0 ? _b : [])
9290
9299
  .filter(function (structure) { return structure.stage === QUALIFYING; })
@@ -9292,11 +9301,11 @@ function getRoundContextProfile(_a) {
9292
9301
  var stageSequence = _a.stageSequence;
9293
9302
  return stageSequence !== null && stageSequence !== void 0 ? stageSequence : 1;
9294
9303
  })), false), [0], false)) : 0;
9295
- var preQualifyingSequence = qualifyingStageSequences
9296
- ? qualifyingStageSequences - ((_c = structure.stageSequence) !== null && _c !== void 0 ? _c : 1) || ''
9304
+ var preQualifyingSequence = ((_c = structure.stageSequence) !== null && _c !== void 0 ? _c : 1) < qualifyingStageSequences
9305
+ ? (_d = structure.stageSequence) !== null && _d !== void 0 ? _d : 1
9297
9306
  : '';
9298
9307
  var preQualifyingAffix = preQualifyingSequence
9299
- ? ((_d = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _d === void 0 ? void 0 : _d.preQualifying) ||
9308
+ ? ((_e = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _e === void 0 ? void 0 : _e.preQualifying) ||
9300
9309
  defaultRoundNamingPolicy.affixes.preQualifying ||
9301
9310
  ''
9302
9311
  : '';
@@ -9306,9 +9315,9 @@ function getRoundContextProfile(_a) {
9306
9315
  var abbreviatedRoundNamingMap = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.abbreviatedRoundNamingMap) ||
9307
9316
  defaultRoundNamingPolicy.abbreviatedRoundNamingMap ||
9308
9317
  {};
9309
- var preFeedAffix = ((_e = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _e === void 0 ? void 0 : _e.preFeedRound) ||
9318
+ var preFeedAffix = ((_f = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _f === void 0 ? void 0 : _f.preFeedRound) ||
9310
9319
  defaultRoundNamingPolicy.affixes.preFeedRound;
9311
- var roundNumberAffix = ((_f = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _f === void 0 ? void 0 : _f.roundNumber) ||
9320
+ var roundNumberAffix = ((_g = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _g === void 0 ? void 0 : _g.roundNumber) ||
9312
9321
  defaultRoundNamingPolicy.affixes.roundNumber;
9313
9322
  var namingConventions = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.namingConventions) ||
9314
9323
  defaultRoundNamingPolicy.namingConventions;
@@ -9331,14 +9340,18 @@ function getRoundContextProfile(_a) {
9331
9340
  })), false));
9332
9341
  }
9333
9342
  else {
9343
+ var qualifyingFinishgMap_1 = isQualifying &&
9344
+ ((roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.qualifyingFinishMap) ||
9345
+ (defaultRoundNamingPolicy === null || defaultRoundNamingPolicy === void 0 ? void 0 : defaultRoundNamingPolicy.qualifyingFinishMap) ||
9346
+ {});
9334
9347
  Object.assign.apply(Object, __spreadArray([roundNamingProfile], __read(roundProfileKeys.map(function (round) {
9335
9348
  var _a;
9336
9349
  if (!(roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[round]))
9337
9350
  return;
9338
9351
  var _b = roundProfile[round], matchUpsCount = _b.matchUpsCount, preFeedRound = _b.preFeedRound;
9339
9352
  var participantsCount = matchUpsCount * 2;
9340
- var sizedRoundName = (qualifyingFinishgMap === null || qualifyingFinishgMap === void 0 ? void 0 : qualifyingFinishgMap[roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[round].finishingRound]) ||
9341
- (qualifyingFinishgMap && "".concat(roundNumberAffix).concat(participantsCount)) ||
9353
+ var sizedRoundName = (qualifyingFinishgMap_1 === null || qualifyingFinishgMap_1 === void 0 ? void 0 : qualifyingFinishgMap_1[roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[round].finishingRound]) ||
9354
+ (qualifyingFinishgMap_1 && "".concat(roundNumberAffix).concat(participantsCount)) ||
9342
9355
  roundNamingMap[matchUpsCount] ||
9343
9356
  "".concat(roundNumberAffix).concat(participantsCount);
9344
9357
  var suffix = preFeedRound ? "-".concat(preFeedAffix) : '';
@@ -11631,8 +11644,10 @@ function modifyMatchUpScore(_a) {
11631
11644
  : undefined;
11632
11645
  var matchUps = getAllStructureMatchUps({
11633
11646
  afterRecoveryTimes: false,
11647
+ tournamentRecord: tournamentRecord,
11634
11648
  inContext: true,
11635
11649
  matchUpFilters: matchUpFilters,
11650
+ drawDefinition: drawDefinition,
11636
11651
  structure: structure,
11637
11652
  event: event,
11638
11653
  }).matchUps;
@@ -25326,7 +25341,7 @@ function allPlayoffPositionsFilled(params) {
25326
25341
  participantIdsCount++;
25327
25342
  return (assignment === null || assignment === void 0 ? void 0 : assignment.bye) || (assignment === null || assignment === void 0 ? void 0 : assignment.participantId);
25328
25343
  }).length;
25329
- return structurePositionsFilled && allFilled;
25344
+ return !!(structurePositionsFilled && allFilled);
25330
25345
  }, !!playoffStructures.length);
25331
25346
  // account for playoffStructure with only one participant
25332
25347
  var allParticipantIdsPlaced = participantIdsCount === enteredParticipantsCount;
@@ -46901,11 +46916,198 @@ function generateVoluntaryConsolation$1(params) {
46901
46916
  return __assign({ links: links, structures: structures }, SUCCESS);
46902
46917
  }
46903
46918
 
46919
+ /**
46920
+ * return an array of arrays of grouped structureIds => structureGroups
46921
+ * the expectation is that all structures within a drawDefintion are linked
46922
+ * return a boolean whether this condition is met => allSructuresLinked
46923
+ */
46924
+ function getStructureGroups(_a) {
46925
+ var e_1, _b, e_2, _c, e_3, _d;
46926
+ var _e, _f, _g, _h, _j, _k, _l, _m, _o;
46927
+ var drawDefinition = _a.drawDefinition;
46928
+ var structures = drawDefinition.structures || [];
46929
+ var links = drawDefinition.links || [];
46930
+ var structureProfiles = new Map();
46931
+ var initStructureProfile = function (structureId) {
46932
+ var profile = structureProfiles.get(structureId) ||
46933
+ (structureProfiles.set(structureId, {
46934
+ drawSources: [],
46935
+ drawTargets: [],
46936
+ progeny: [],
46937
+ sources: [],
46938
+ targets: [],
46939
+ }) &&
46940
+ structureProfiles.get(structureId));
46941
+ if (profile && !(profile === null || profile === void 0 ? void 0 : profile.stage)) {
46942
+ var structure = structures.find(function (structure) { return structure.structureId === structureId; });
46943
+ profile.stage = structure === null || structure === void 0 ? void 0 : structure.stage;
46944
+ }
46945
+ return profile;
46946
+ };
46947
+ var sourceStructureIds = {};
46948
+ var hasDrawFeedProfile = {};
46949
+ var linkedStructureIds = links.map(function (link) {
46950
+ var sourceId = link.source.structureId;
46951
+ var targetId = link.target.structureId;
46952
+ var sourceProfile = initStructureProfile(sourceId);
46953
+ var targetProfile = initStructureProfile(targetId);
46954
+ if ([BOTTOM_UP, TOP_DOWN, RANDOM, WATERFALL].includes(link.target.feedProfile)) {
46955
+ sourceProfile === null || sourceProfile === void 0 ? void 0 : sourceProfile.targets.push(targetId);
46956
+ targetProfile === null || targetProfile === void 0 ? void 0 : targetProfile.sources.push(sourceId);
46957
+ }
46958
+ else if (link.target.feedProfile === DRAW) {
46959
+ targetProfile === null || targetProfile === void 0 ? void 0 : targetProfile.drawSources.push(sourceId);
46960
+ sourceProfile === null || sourceProfile === void 0 ? void 0 : sourceProfile.drawTargets.push(targetId);
46961
+ }
46962
+ hasDrawFeedProfile[targetId] =
46963
+ hasDrawFeedProfile[targetId] || link.target.feedProfile === DRAW;
46964
+ sourceStructureIds[targetId] = unique(__spreadArray(__spreadArray([], __read((sourceStructureIds[targetId] || [])), false), [
46965
+ sourceId,
46966
+ ], false)).filter(Boolean);
46967
+ return [link.source.structureId, link.target.structureId];
46968
+ });
46969
+ try {
46970
+ for (var _p = __values(structureProfiles.keys()), _q = _p.next(); !_q.done; _q = _p.next()) {
46971
+ var structureId = _q.value;
46972
+ var profile = structureProfiles.get(structureId);
46973
+ if (profile) {
46974
+ var sourceIds = (_e = profile.targets) !== null && _e !== void 0 ? _e : [];
46975
+ while (sourceIds.length) {
46976
+ var sourceId = sourceIds.pop();
46977
+ var sourceProfile = sourceId && structureProfiles[sourceId];
46978
+ if ((_f = sourceProfile === null || sourceProfile === void 0 ? void 0 : sourceProfile.targets) === null || _f === void 0 ? void 0 : _f.length) {
46979
+ sourceIds.push.apply(sourceIds, __spreadArray([], __read(sourceProfile.targets), false));
46980
+ }
46981
+ else if (sourceProfile) {
46982
+ profile.rootStage = sourceProfile.stage;
46983
+ }
46984
+ }
46985
+ if (!profile.rootStage)
46986
+ profile.rootStage = profile.stage;
46987
+ if (!((_g = profile.targets) === null || _g === void 0 ? void 0 : _g.length)) {
46988
+ var targetIds = (_h = profile.sources) !== null && _h !== void 0 ? _h : [];
46989
+ while (targetIds.length) {
46990
+ var targetId = targetIds.pop();
46991
+ var targetProfile = targetId && structureProfiles[targetId];
46992
+ if ((_j = targetProfile === null || targetProfile === void 0 ? void 0 : targetProfile.sources) === null || _j === void 0 ? void 0 : _j.length) {
46993
+ try {
46994
+ for (var _r = (e_2 = void 0, __values(targetProfile.sources)), _s = _r.next(); !_s.done; _s = _r.next()) {
46995
+ var id = _s.value;
46996
+ if (!((_k = profile.progeny) === null || _k === void 0 ? void 0 : _k.includes(id)))
46997
+ (_l = profile.progeny) === null || _l === void 0 ? void 0 : _l.push(id);
46998
+ }
46999
+ }
47000
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
47001
+ finally {
47002
+ try {
47003
+ if (_s && !_s.done && (_c = _r.return)) _c.call(_r);
47004
+ }
47005
+ finally { if (e_2) throw e_2.error; }
47006
+ }
47007
+ targetIds.push.apply(targetIds, __spreadArray([], __read(targetProfile.sources), false));
47008
+ }
47009
+ }
47010
+ }
47011
+ }
47012
+ }
47013
+ }
47014
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
47015
+ finally {
47016
+ try {
47017
+ if (_q && !_q.done && (_b = _p.return)) _b.call(_p);
47018
+ }
47019
+ finally { if (e_1) throw e_1.error; }
47020
+ }
47021
+ var maxQualifyingDepth = 0;
47022
+ try {
47023
+ for (var _t = __values(structureProfiles.keys()), _u = _t.next(); !_u.done; _u = _t.next()) {
47024
+ var structureId = _u.value;
47025
+ var profile = structureProfiles.get(structureId);
47026
+ if (profile && profile.rootStage === QUALIFYING) {
47027
+ var drawTargets = [(_m = profile.drawTargets) === null || _m === void 0 ? void 0 : _m[0]];
47028
+ var distanceFromMain = 0;
47029
+ while (drawTargets.length) {
47030
+ distanceFromMain += 1;
47031
+ var drawTarget = drawTargets.pop();
47032
+ var targetProfile = drawTarget
47033
+ ? structureProfiles.get(drawTarget)
47034
+ : undefined;
47035
+ if ((_o = targetProfile === null || targetProfile === void 0 ? void 0 : targetProfile.drawTargets) === null || _o === void 0 ? void 0 : _o.length) {
47036
+ drawTargets.push(targetProfile.drawTargets[0]);
47037
+ }
47038
+ }
47039
+ profile.distanceFromMain = distanceFromMain;
47040
+ if (distanceFromMain > maxQualifyingDepth)
47041
+ maxQualifyingDepth = distanceFromMain;
47042
+ }
47043
+ }
47044
+ }
47045
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
47046
+ finally {
47047
+ try {
47048
+ if (_u && !_u.done && (_d = _t.return)) _d.call(_t);
47049
+ }
47050
+ finally { if (e_3) throw e_3.error; }
47051
+ }
47052
+ // iterate through all groups of structureIds to flatten tree of links between structures
47053
+ var iterations = linkedStructureIds.length;
47054
+ generateRange(0, Math.ceil(iterations / 2)).forEach(function () {
47055
+ linkedStructureIds = generateRange(0, iterations).map(function (index) {
47056
+ var structureIds = linkedStructureIds[index];
47057
+ var mergedWithOverlappingIds = linkedStructureIds.reduce(function (biggest, ids) {
47058
+ var hasOverlap = overlap(structureIds, ids);
47059
+ return hasOverlap ? biggest.concat.apply(biggest, __spreadArray([], __read(ids), false)) : biggest;
47060
+ }, []) || [];
47061
+ return unique(structureIds.concat.apply(structureIds, __spreadArray([], __read(mergedWithOverlappingIds), false)));
47062
+ });
47063
+ });
47064
+ // at this point all linkedStructureIds arrays should be equivalent
47065
+ // use the first of these as the identity array
47066
+ var groupedStructureIds = linkedStructureIds[0];
47067
+ // utility method to recognize equivalent arrays of structureIds
47068
+ var identityLink = function (a, b) { return intersection(a, b).length === a.length; };
47069
+ // check that all arrays of linkedStructureIds are equivalent to identity array
47070
+ var allLinkStructuresLinked = linkedStructureIds
47071
+ .slice(1)
47072
+ .reduce(function (allLinkStructuresLinked, ids) {
47073
+ return allLinkStructuresLinked && identityLink(ids, groupedStructureIds);
47074
+ }, true);
47075
+ // if a drawDefinition contains no links then no structure groups will exist
47076
+ // filter out undefined when there are no links in a drawDefinition
47077
+ var structureGroups = [groupedStructureIds].filter(Boolean);
47078
+ // this is the same as structureGroups, but excludes VOLUNTARY_CONSOLATION
47079
+ var linkCheck = [groupedStructureIds].filter(Boolean);
47080
+ // iterate through all structures to add missing structureIds
47081
+ structures.forEach(function (structure) {
47082
+ var structureId = structure.structureId, stage = structure.stage;
47083
+ var existingGroup = structureGroups.find(function (group) {
47084
+ return group.includes(structureId);
47085
+ });
47086
+ if (!existingGroup) {
47087
+ structureGroups.push([structureId]);
47088
+ if (stage !== VOLUNTARY_CONSOLATION)
47089
+ linkCheck.push([structureId]);
47090
+ }
47091
+ });
47092
+ var allStructuresLinked = allLinkStructuresLinked && linkCheck.length === 1;
47093
+ if (!(links === null || links === void 0 ? void 0 : links.length) && structures.length === 1) {
47094
+ initStructureProfile(structures[0].structureId);
47095
+ }
47096
+ return {
47097
+ structureProfiles: Object.fromEntries(structureProfiles),
47098
+ allStructuresLinked: allStructuresLinked,
47099
+ maxQualifyingDepth: maxQualifyingDepth,
47100
+ sourceStructureIds: sourceStructureIds,
47101
+ hasDrawFeedProfile: hasDrawFeedProfile,
47102
+ structureGroups: structureGroups,
47103
+ };
47104
+ }
47105
+
46904
47106
  // for use when adding a qualifying structure to an existing drawDefinition
46905
47107
  // not for use when generating structures from qualifyingProfiles
46906
47108
  function generateQualifyingStructure$1(params) {
46907
47109
  var _a;
46908
- var _b, _c, _d, _e, _f;
47110
+ var _b, _c, _d, _e, _f, _g, _h, _j;
46909
47111
  if (!params.drawDefinition)
46910
47112
  return { error: MISSING_DRAW_DEFINITION };
46911
47113
  var stack = 'generateQualifyingStructure';
@@ -46918,66 +47120,25 @@ function generateQualifyingStructure$1(params) {
46918
47120
  if (!isConvertableInteger(drawSize)) {
46919
47121
  return decorateResult({ result: { error: MISSING_DRAW_SIZE }, stack: stack });
46920
47122
  }
46921
- var result = findStructure({
46922
- structureId: targetStructureId,
46923
- drawDefinition: drawDefinition,
46924
- });
46925
- if (result.error) {
47123
+ var structureProfiles = getStructureGroups({ drawDefinition: drawDefinition }).structureProfiles;
47124
+ var structureProfile = structureProfiles[targetStructureId];
47125
+ if (!structureProfile) {
46926
47126
  return decorateResult({
47127
+ result: { error: STRUCTURE_NOT_FOUND },
46927
47128
  context: { targetStructureId: targetStructureId },
46928
- result: result,
46929
47129
  stack: stack,
46930
47130
  });
46931
47131
  }
46932
- if (!result.structure)
46933
- return { error: STRUCTURE_NOT_FOUND };
46934
- var targetStructure = result.structure;
46935
- var matchUpType = targetStructure.matchUpType;
46936
- if (targetStructure.stage === QUALIFYING) {
46937
- if (targetStructure.stageSequence && targetStructure.stageSequence > 1) {
46938
- stageSequence = targetStructure.stageSequence - 1;
46939
- }
46940
- else {
46941
- // stageSequence must be modified for entire qualifying chain
46942
- var nextStructureId_1 = targetStructureId;
46943
- var nextStageSequence = 2;
46944
- var chainModified = void 0;
46945
- while (!chainModified && nextStructureId_1) {
46946
- console.log('check getRoundContextProfile preqQualifyingStageSequence');
46947
- targetStructure.stageSequence = nextStageSequence;
46948
- var targetTargetStructureId = (_e = (_d = (_c = drawDefinition.links) === null || _c === void 0 ? void 0 : _c.find(function (link) { return link.source.structureId === nextStructureId_1; })) === null || _d === void 0 ? void 0 : _d.target) === null || _e === void 0 ? void 0 : _e.structureId;
46949
- nextStructureId_1 = targetTargetStructureId;
46950
- nextStageSequence += 1;
46951
- if (!targetTargetStructureId) {
46952
- chainModified = true;
46953
- }
46954
- else {
46955
- var result_1 = findStructure({
46956
- structureId: targetTargetStructureId,
46957
- drawDefinition: drawDefinition,
46958
- });
46959
- if (!result_1.structure)
46960
- return { error: STRUCTURE_NOT_FOUND };
46961
- if (result_1.error) {
46962
- return decorateResult({
46963
- context: { targetTargetStructureId: targetTargetStructureId },
46964
- result: result_1,
46965
- stack: stack,
46966
- });
46967
- }
46968
- if (result_1.structure.stage !== QUALIFYING)
46969
- chainModified = true;
46970
- }
46971
- }
46972
- }
46973
- }
47132
+ var matchUpType = drawDefinition.matchUpType;
46974
47133
  var roundTargetName = roundTarget ? "".concat(roundTarget, "-") : '';
46975
- var stageSequenceName = "".concat(stageSequence);
46976
- var qualifyingStructureName = structureName !== null && structureName !== void 0 ? structureName : (roundTargetName || stageSequenceName
46977
- ? "".concat(constantToString(QUALIFYING), " ").concat(roundTargetName).concat(stageSequenceName)
46978
- : constantToString(QUALIFYING));
47134
+ var isPreQualifying = structureProfile.stage === QUALIFYING;
47135
+ var preQualifyingNaming = (_e = (_d = (_c = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_ROUND_NAMING]) === null || _c === void 0 ? void 0 : _c.namingConventions) === null || _d === void 0 ? void 0 : _d.pre) !== null && _e !== void 0 ? _e : (_g = (_f = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING]) === null || _f === void 0 ? void 0 : _f.namingConventions) === null || _g === void 0 ? void 0 : _g.pre;
47136
+ var pre = isPreQualifying && preQualifyingNaming ? "".concat(preQualifyingNaming, "-") : '';
47137
+ var qualifyingStructureName = structureName !== null && structureName !== void 0 ? structureName : (roundTargetName
47138
+ ? "".concat(pre).concat(constantToString(QUALIFYING), " ").concat(roundTargetName)
47139
+ : "".concat(pre).concat(constantToString(QUALIFYING)));
46979
47140
  if (drawType === ROUND_ROBIN) {
46980
- var _g = generateRoundRobin({
47141
+ var _k = generateRoundRobin({
46981
47142
  structureName: structureName !== null && structureName !== void 0 ? structureName : qualifyingStructureName,
46982
47143
  structureId: structureId !== null && structureId !== void 0 ? structureId : uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
46983
47144
  stage: QUALIFYING,
@@ -46990,7 +47151,7 @@ function generateQualifyingStructure$1(params) {
46990
47151
  drawSize: drawSize,
46991
47152
  isMock: isMock,
46992
47153
  uuids: uuids,
46993
- }), maxRoundNumber = _g.maxRoundNumber /*, groupSize*/, structures = _g.structures, groupCount = _g.groupCount;
47154
+ }), maxRoundNumber = _k.maxRoundNumber /*, groupSize*/, structures = _k.structures, groupCount = _k.groupCount;
46994
47155
  qualifiersCount = groupCount;
46995
47156
  roundLimit = maxRoundNumber;
46996
47157
  structure = structures[0];
@@ -47025,20 +47186,48 @@ function generateQualifyingStructure$1(params) {
47025
47186
  extension: { name: ROUND_TARGET, value: roundTarget },
47026
47187
  });
47027
47188
  }
47028
- qualifiersCount = (_f = matchUps === null || matchUps === void 0 ? void 0 : matchUps.filter(function (matchUp) { return matchUp.roundNumber === roundLimit; })) === null || _f === void 0 ? void 0 : _f.length;
47189
+ qualifiersCount = (_h = matchUps === null || matchUps === void 0 ? void 0 : matchUps.filter(function (matchUp) { return matchUp.roundNumber === roundLimit; })) === null || _h === void 0 ? void 0 : _h.length;
47029
47190
  }
47030
47191
  // order of operations is important here!! finalQualifier positions is not yet updated when this step occurs
47031
47192
  var linkType = drawType === ROUND_ROBIN ? LinkTypeEnum.Position : LinkTypeEnum.Winner;
47032
- var link = generateQualifyingLink({
47033
- sourceStructureId: structure.structureId,
47034
- sourceRoundNumber: roundLimit,
47035
- targetStructureId: targetStructureId,
47036
- finishingPositions: finishingPositions,
47037
- linkType: linkType,
47038
- }).link;
47193
+ var link = structure &&
47194
+ roundLimit &&
47195
+ ((_j = generateQualifyingLink({
47196
+ sourceStructureId: structure.structureId,
47197
+ sourceRoundNumber: roundLimit,
47198
+ targetStructureId: targetStructureId,
47199
+ finishingPositions: finishingPositions,
47200
+ linkType: linkType,
47201
+ })) === null || _j === void 0 ? void 0 : _j.link);
47039
47202
  return __assign(__assign({ qualifyingDrawPositionsCount: drawSize, qualifiersCount: qualifiersCount }, SUCCESS), { structure: structure, link: link });
47040
47203
  }
47041
47204
 
47205
+ function resequenceStructures(_a) {
47206
+ var e_1, _b;
47207
+ var drawDefinition = _a.drawDefinition;
47208
+ var _c = getStructureGroups({
47209
+ drawDefinition: drawDefinition,
47210
+ }), maxQualifyingDepth = _c.maxQualifyingDepth, structureProfiles = _c.structureProfiles;
47211
+ try {
47212
+ for (var _d = __values(drawDefinition.structures), _e = _d.next(); !_e.done; _e = _d.next()) {
47213
+ var structure = _e.value;
47214
+ var profile = structureProfiles[structure.structureId];
47215
+ if (profile.distanceFromMain) {
47216
+ structure.stageSequence =
47217
+ maxQualifyingDepth + 1 - profile.distanceFromMain;
47218
+ }
47219
+ }
47220
+ }
47221
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
47222
+ finally {
47223
+ try {
47224
+ if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
47225
+ }
47226
+ finally { if (e_1) throw e_1.error; }
47227
+ }
47228
+ return __assign({}, SUCCESS);
47229
+ }
47230
+
47042
47231
  function attachQualifyingStructure$1(_a) {
47043
47232
  var _b;
47044
47233
  var drawDefinition = _a.drawDefinition, tournamentId = _a.tournamentId, structure = _a.structure, eventId = _a.eventId, link = _a.link;
@@ -47065,6 +47254,7 @@ function attachQualifyingStructure$1(_a) {
47065
47254
  drawDefinition.links = [];
47066
47255
  drawDefinition.structures.push(structure);
47067
47256
  drawDefinition.links.push(link);
47257
+ resequenceStructures({ drawDefinition: drawDefinition });
47068
47258
  var matchUps = ((_b = getAllStructureMatchUps({ structure: structure })) === null || _b === void 0 ? void 0 : _b.matchUps) || [];
47069
47259
  addMatchUpsNotice({
47070
47260
  drawDefinition: drawDefinition,
@@ -47278,6 +47468,10 @@ function getAdvancingParticipantId(matchUp) {
47278
47468
 
47279
47469
  function addQualifyingStructure$1(params) {
47280
47470
  var _a, _b;
47471
+ if (!params.drawDefinition)
47472
+ return { error: MISSING_DRAW_DEFINITION };
47473
+ if (!params.targetStructureId)
47474
+ return { error: MISSING_STRUCTURE_ID };
47281
47475
  var result = generateQualifyingStructure$1(params);
47282
47476
  if (result.error)
47283
47477
  return result;
@@ -47608,7 +47802,7 @@ function renameStructures$1(_a) {
47608
47802
 
47609
47803
  function removeStructure(_a) {
47610
47804
  var _b, _c, _d;
47611
- var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structureId = _a.structureId, event = _a.event;
47805
+ var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structureId = _a.structureId, event = _a.event, force = _a.force;
47612
47806
  if (typeof structureId !== 'string')
47613
47807
  return { error: INVALID_VALUES };
47614
47808
  if (!drawDefinition)
@@ -47617,11 +47811,21 @@ function removeStructure(_a) {
47617
47811
  return { error: MISSING_STRUCTURE_ID };
47618
47812
  var structures = drawDefinition.structures || [];
47619
47813
  var removedStructureIds = [];
47814
+ var structure = structures.find(function (structure) { return structure.structureId === structureId; });
47815
+ if (!structure)
47816
+ return { error: STRUCTURE_NOT_FOUND };
47817
+ var structureMatchUps = getAllStructureMatchUps({ structure: structure }).matchUps;
47818
+ var scoresPresent = structureMatchUps.some(function (_a) {
47819
+ var score = _a.score;
47820
+ return scoreHasValue({ score: score });
47821
+ });
47822
+ if (scoresPresent && !force)
47823
+ return { error: SCORES_PRESENT };
47620
47824
  var mainStageSequence1 = structures.find(function (_a) {
47621
47825
  var stage = _a.stage, stageSequence = _a.stageSequence;
47622
47826
  return stage === MAIN && stageSequence === 1;
47623
47827
  });
47624
- var isMainStageSequence1 = structureId === mainStageSequence1.structureId;
47828
+ var isMainStageSequence1 = structureId === (mainStageSequence1 === null || mainStageSequence1 === void 0 ? void 0 : mainStageSequence1.structureId);
47625
47829
  var qualifyingStructureIds = structures
47626
47830
  .filter(function (_a) {
47627
47831
  var stage = _a.stage;
@@ -47635,20 +47839,20 @@ function removeStructure(_a) {
47635
47839
  var removedMatchUpIds = [];
47636
47840
  var idsToRemove = [structureId];
47637
47841
  var getTargetedStructureIds = function (structureId) {
47638
- var _a;
47639
- return (_a = drawDefinition.links) === null || _a === void 0 ? void 0 : _a.map(function (link) {
47842
+ var _a, _b;
47843
+ return (_b = (_a = drawDefinition.links) === null || _a === void 0 ? void 0 : _a.map(function (link) {
47640
47844
  return link.source.structureId === structureId &&
47641
- link.target.structureId !== mainStageSequence1.structureId &&
47845
+ link.target.structureId !== (mainStageSequence1 === null || mainStageSequence1 === void 0 ? void 0 : mainStageSequence1.structureId) &&
47642
47846
  link.target.structureId;
47643
- }).filter(Boolean);
47847
+ }).filter(Boolean)) !== null && _b !== void 0 ? _b : [];
47644
47848
  };
47645
47849
  var getQualifyingSourceStructureIds = function (structureId) {
47646
- var _a;
47647
- return (_a = drawDefinition.links) === null || _a === void 0 ? void 0 : _a.map(function (link) {
47850
+ var _a, _b;
47851
+ return (_b = (_a = drawDefinition.links) === null || _a === void 0 ? void 0 : _a.map(function (link) {
47648
47852
  return qualifyingStructureIds.includes(link.source.structureId) &&
47649
47853
  link.target.structureId === structureId &&
47650
47854
  link.source.structureId;
47651
- }).filter(Boolean);
47855
+ }).filter(Boolean)) !== null && _b !== void 0 ? _b : [];
47652
47856
  };
47653
47857
  var isQualifyingStructure = qualifyingStructureIds.includes(structureId);
47654
47858
  var relatedStructureIdsMap = new Map();
@@ -47659,11 +47863,11 @@ function removeStructure(_a) {
47659
47863
  });
47660
47864
  var _loop_1 = function () {
47661
47865
  var idBeingRemoved = idsToRemove.pop();
47662
- var structure = findStructure({
47866
+ var structure_1 = findStructure({
47663
47867
  structureId: idBeingRemoved,
47664
47868
  drawDefinition: drawDefinition,
47665
47869
  }).structure;
47666
- var matchUps_1 = getAllStructureMatchUps({ structure: structure }).matchUps;
47870
+ var matchUps_1 = getAllStructureMatchUps({ structure: structure_1 }).matchUps;
47667
47871
  var matchUpIds = getMatchUpIds(matchUps_1);
47668
47872
  removedMatchUpIds.push.apply(removedMatchUpIds, __spreadArray([], __read(matchUpIds), false));
47669
47873
  drawDefinition.links =
@@ -47683,7 +47887,7 @@ function removeStructure(_a) {
47683
47887
  // targetedStructureIdsMap[idBeingRemoved].filter(
47684
47888
  (_d = relatedStructureIdsMap.get(idBeingRemoved)) === null || _d === void 0 ? void 0 : _d.filter(function (id) {
47685
47889
  // IMPORTANT: only delete MAIN stageSequence: 1 if specified to protect against DOUBLE_ELIMINATION scenario
47686
- return id !== mainStageSequence1.structureId ||
47890
+ return id !== (mainStageSequence1 === null || mainStageSequence1 === void 0 ? void 0 : mainStageSequence1.structureId) ||
47687
47891
  structureId === mainStageSequence1.structureId;
47688
47892
  }));
47689
47893
  if (targetedStructureIds === null || targetedStructureIds === void 0 ? void 0 : targetedStructureIds.length)
@@ -47713,6 +47917,7 @@ function removeStructure(_a) {
47713
47917
  mainStageSequence1.extensions = [];
47714
47918
  }
47715
47919
  }
47920
+ isQualifyingStructure && resequenceStructures({ drawDefinition: drawDefinition });
47716
47921
  deleteMatchUpsNotice({
47717
47922
  tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
47718
47923
  matchUpIds: removedMatchUpIds,
@@ -56789,76 +56994,6 @@ function unPublishEvent(_a) {
56789
56994
  return __assign({ eventId: event.eventId }, SUCCESS);
56790
56995
  }
56791
56996
 
56792
- /**
56793
- * return an array of arrays of grouped structureIds => structureGroups
56794
- * the expectation is that all structures within a drawDefintion are linked
56795
- * return a boolean whether this condition is met => allSructuresLinked
56796
- */
56797
- function getStructureGroups(_a) {
56798
- var drawDefinition = _a.drawDefinition;
56799
- var links = drawDefinition.links || [];
56800
- var sourceStructureIds = {};
56801
- var hasDrawFeedProfile = {};
56802
- var linkedStructureIds = links.map(function (link) {
56803
- var sourceId = link.source.structureId;
56804
- var targetId = link.target.structureId;
56805
- hasDrawFeedProfile[targetId] =
56806
- hasDrawFeedProfile[targetId] || link.target.feedProfile === DRAW;
56807
- sourceStructureIds[targetId] = unique(__spreadArray(__spreadArray([], __read((sourceStructureIds[targetId] || [])), false), [
56808
- sourceId,
56809
- ], false)).filter(Boolean);
56810
- return [link.source.structureId, link.target.structureId];
56811
- });
56812
- // iterate through all groups of structureIds to flatten tree of links between structures
56813
- var iterations = linkedStructureIds.length;
56814
- generateRange(0, Math.ceil(iterations / 2)).forEach(function () {
56815
- linkedStructureIds = generateRange(0, iterations).map(function (index) {
56816
- var structureIds = linkedStructureIds[index];
56817
- var mergedWithOverlappingIds = linkedStructureIds.reduce(function (biggest, ids) {
56818
- var hasOverlap = overlap(structureIds, ids);
56819
- return hasOverlap ? biggest.concat.apply(biggest, __spreadArray([], __read(ids), false)) : biggest;
56820
- }, []) || [];
56821
- return unique(structureIds.concat.apply(structureIds, __spreadArray([], __read(mergedWithOverlappingIds), false)));
56822
- });
56823
- });
56824
- // at this point all linkedStructureIds arrays should be equivalent
56825
- // use the first of these as the identity array
56826
- var groupedStructureIds = linkedStructureIds[0];
56827
- // utility method to recognize equivalent arrays of structureIds
56828
- var identityLink = function (a, b) { return intersection(a, b).length === a.length; };
56829
- // check that all arrays of linkedStructureIds are equivalent to identity array
56830
- var allLinkStructuresLinked = linkedStructureIds
56831
- .slice(1)
56832
- .reduce(function (allLinkStructuresLinked, ids) {
56833
- return allLinkStructuresLinked && identityLink(ids, groupedStructureIds);
56834
- }, true);
56835
- // if a drawDefinition contains no links then no structure groups will exist
56836
- // filter out undefined when there are no links in a drawDefinition
56837
- var structureGroups = [groupedStructureIds].filter(Boolean);
56838
- // this is the same as structureGroups, but excludes VOLUNTARY_CONSOLATION
56839
- var linkCheck = [groupedStructureIds].filter(Boolean);
56840
- // iterate through all structures to add missing structureIds
56841
- var structures = drawDefinition.structures || [];
56842
- structures.forEach(function (structure) {
56843
- var structureId = structure.structureId, stage = structure.stage;
56844
- var existingGroup = structureGroups.find(function (group) {
56845
- return group.includes(structureId);
56846
- });
56847
- if (!existingGroup) {
56848
- structureGroups.push([structureId]);
56849
- if (stage !== VOLUNTARY_CONSOLATION)
56850
- linkCheck.push(structureId);
56851
- }
56852
- });
56853
- var allStructuresLinked = allLinkStructuresLinked && linkCheck.length === 1;
56854
- return {
56855
- allStructuresLinked: allStructuresLinked,
56856
- sourceStructureIds: sourceStructureIds,
56857
- hasDrawFeedProfile: hasDrawFeedProfile,
56858
- structureGroups: structureGroups,
56859
- };
56860
- }
56861
-
56862
56997
  function getDrawData(params) {
56863
56998
  var _a = params.tournamentParticipants, tournamentParticipants = _a === void 0 ? [] : _a, includePositionAssignments = params.includePositionAssignments, policyDefinitions = params.policyDefinitions, tournamentRecord = params.tournamentRecord, _b = params.inContext, inContext = _b === void 0 ? true : _b, drawDefinition = params.drawDefinition, noDeepCopy = params.noDeepCopy, sortConfig = params.sortConfig, context = params.context, event = params.event;
56864
56999
  if (!drawDefinition)
@@ -56903,13 +57038,20 @@ function getDrawData(params) {
56903
57038
  .sort(function (a, b) { return structureSort(a, b, sortConfig); })
56904
57039
  .map(function (structure) {
56905
57040
  var _a;
56906
- var structureId = structure.structureId;
57041
+ if (!structure)
57042
+ return;
57043
+ var structureId = structure === null || structure === void 0 ? void 0 : structure.structureId;
56907
57044
  var seedAssignments = [];
56908
57045
  // pass seedAssignments from { stageSequence: 1 } to other stages
56909
- if ([MAIN, CONSOLATION, PLAY_OFF].includes(structure.stage)) {
57046
+ if (structure.stage &&
57047
+ [
57048
+ StageTypeEnum.Main,
57049
+ StageTypeEnum.Consolation,
57050
+ StageTypeEnum.PlayOff,
57051
+ ].includes(structure.stage)) {
56910
57052
  seedAssignments = mainStageSeedAssignments;
56911
57053
  }
56912
- if (structure.stage === QUALIFYING) {
57054
+ if ((structure === null || structure === void 0 ? void 0 : structure.stage) === QUALIFYING) {
56913
57055
  seedAssignments = qualificationStageSeedAssignments;
56914
57056
  }
56915
57057
  var _b = getAllStructureMatchUps({
@@ -56942,16 +57084,18 @@ function getDrawData(params) {
56942
57084
  participantResult: extension.value,
56943
57085
  });
56944
57086
  }).filter(function (f) { return f === null || f === void 0 ? void 0 : f.participantResult; });
56945
- var structureInfo = (function (_a) {
56946
- var stageSequence = _a.stageSequence, structureName = _a.structureName, structureType = _a.structureType, matchUpFormat = _a.matchUpFormat, stage = _a.stage;
56947
- return ({
56948
- stageSequence: stageSequence,
56949
- structureName: structureName,
56950
- structureType: structureType,
56951
- matchUpFormat: matchUpFormat,
56952
- stage: stage,
56953
- });
56954
- })(structure);
57087
+ var structureInfo = structure
57088
+ ? (function (_a) {
57089
+ var stageSequence = _a.stageSequence, structureName = _a.structureName, structureType = _a.structureType, matchUpFormat = _a.matchUpFormat, stage = _a.stage;
57090
+ return ({
57091
+ stageSequence: stageSequence,
57092
+ structureName: structureName,
57093
+ structureType: structureType,
57094
+ matchUpFormat: matchUpFormat,
57095
+ stage: stage,
57096
+ });
57097
+ })(structure)
57098
+ : {};
56955
57099
  structureInfo.sourceStructureIds = sourceStructureIds[structureId];
56956
57100
  structureInfo.hasDrawFeedProfile = hasDrawFeedProfile[structureId];
56957
57101
  structureInfo.positionAssignments = positionAssignments;
@@ -59246,11 +59390,11 @@ function getEntryStatusReports(_a) {
59246
59390
  var positionAssignments = _a.positionAssignments;
59247
59391
  return positionAssignments;
59248
59392
  })
59393
+ .filter(Boolean)
59249
59394
  .map(function (_a) {
59250
59395
  var participantId = _a.participantId;
59251
59396
  return participantId;
59252
- })
59253
- .filter(Boolean);
59397
+ });
59254
59398
  var entryFilter = function (_a) {
59255
59399
  var participantId = _a.participantId;
59256
59400
  return assignedParticipantIds.includes(participantId);
@@ -64508,8 +64652,7 @@ function isValidForQualifying(_a) {
64508
64652
  var targetFeedProfiles = result.links.target
64509
64653
  .flatMap(function (t) { return t.target.feedProfile; })
64510
64654
  .filter(Boolean);
64511
- var valid = !intersection([BOTTOM_UP, TOP_DOWN, RANDOM], targetFeedProfiles)
64512
- .length;
64655
+ var valid = !intersection([BOTTOM_UP, TOP_DOWN, RANDOM, WATERFALL], targetFeedProfiles).length;
64513
64656
  return __assign(__assign({}, SUCCESS), { valid: valid });
64514
64657
  }
64515
64658