tods-competition-factory 1.6.27 → 1.6.29

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.
@@ -362,7 +362,7 @@ var matchUpFormatCode = {
362
362
  };
363
363
 
364
364
  function factoryVersion() {
365
- return '1.6.27';
365
+ return '1.6.29';
366
366
  }
367
367
 
368
368
  /******************************************************************************
@@ -43348,9 +43348,11 @@ function processPlayoffGroups(_a) {
43348
43348
  finishingPositions
43349
43349
  .map(function (p) { var _a; return (_a = positionRangeMap[p]) === null || _a === void 0 ? void 0 : _a.finishingPositions; })
43350
43350
  .flat();
43351
- var playoffDrawType = playoffGroup.drawType || SINGLE_ELIMINATION;
43352
43351
  var participantsInDraw = groupCount * finishingPositions.length;
43353
43352
  var drawSize = nextPowerOf2(participantsInDraw);
43353
+ var playoffDrawType = (drawSize === 2 && SINGLE_ELIMINATION) ||
43354
+ playoffGroup.drawType ||
43355
+ SINGLE_ELIMINATION;
43354
43356
  if (positionsPlayedOff) {
43355
43357
  finishingPositionOffset = Math.min.apply(Math, __spreadArray([], __read(positionsPlayedOff), false)) - 1;
43356
43358
  }
@@ -43933,15 +43935,19 @@ function getGenerators(params) {
43933
43935
 
43934
43936
  function generateDrawStructuresAndLinks$1(params) {
43935
43937
  var e_1, _a, e_2, _b;
43936
- var _c, _d, _e, _f, _g, _h, _j;
43937
- var _k = params || {}, _l = _k.enforceMinimumDrawSize, enforceMinimumDrawSize = _l === void 0 ? true : _l, overwriteExisting = _k.overwriteExisting, drawTypeCoercion = _k.drawTypeCoercion, // coerce to SINGLE_ELIMINATION for drawSize: 2
43938
- appliedPolicies = _k.appliedPolicies, staggeredEntry = _k.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
43939
- drawDefinition = _k.drawDefinition, tieFormat = _k.tieFormat, drawSize = _k.drawSize, isMock = _k.isMock, uuids = _k.uuids;
43938
+ var _c, _d, _e, _f, _g, _h;
43939
+ var _j = params || {}, _k = _j.enforceMinimumDrawSize, enforceMinimumDrawSize = _k === void 0 ? true : _k, _l = _j.drawTypeCoercion, drawTypeCoercion = _l === void 0 ? true : _l, // coerce to SINGLE_ELIMINATION for drawSize: 2
43940
+ overwriteExisting = _j.overwriteExisting, appliedPolicies = _j.appliedPolicies, staggeredEntry = _j.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
43941
+ drawDefinition = _j.drawDefinition, tieFormat = _j.tieFormat, drawSize = _j.drawSize, isMock = _j.isMock, uuids = _j.uuids;
43940
43942
  var stack = 'generateDrawStructuresAndLinks';
43941
- var drawType = (_c = params.drawType) !== null && _c !== void 0 ? _c : SINGLE_ELIMINATION;
43943
+ var drawType = (drawTypeCoercion &&
43944
+ params.drawSize === 2 &&
43945
+ DrawTypeEnum.SingleElimination) ||
43946
+ params.drawType ||
43947
+ DrawTypeEnum.SingleElimination;
43942
43948
  var structures = [], links = [];
43943
- var matchUpType = (_d = params === null || params === void 0 ? void 0 : params.matchUpType) !== null && _d !== void 0 ? _d : SINGLES$1;
43944
- var existingQualifyingStructures = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.filter(function (_a) {
43949
+ var matchUpType = (_c = params === null || params === void 0 ? void 0 : params.matchUpType) !== null && _c !== void 0 ? _c : SINGLES$1;
43950
+ var existingQualifyingStructures = (_d = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _d === void 0 ? void 0 : _d.filter(function (_a) {
43945
43951
  var stage = _a.stage;
43946
43952
  return stage === QUALIFYING;
43947
43953
  });
@@ -43952,11 +43958,11 @@ function generateDrawStructuresAndLinks$1(params) {
43952
43958
  var structureId = _a.structureId;
43953
43959
  return structureId;
43954
43960
  });
43955
- var existingMainStructure = (_f = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _f === void 0 ? void 0 : _f.find(function (_a) {
43961
+ var existingMainStructure = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.find(function (_a) {
43956
43962
  var stage = _a.stage, stageSequence = _a.stageSequence;
43957
43963
  return stage === MAIN && stageSequence === 1;
43958
43964
  });
43959
- var existingQualifyingLinks = (_g = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.links) === null || _g === void 0 ? void 0 : _g.filter(function (link) {
43965
+ var existingQualifyingLinks = (_f = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.links) === null || _f === void 0 ? void 0 : _f.filter(function (link) {
43960
43966
  return link.target.structureId === (existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.structureId) &&
43961
43967
  (existingQualifyingStructureIds === null || existingQualifyingStructureIds === void 0 ? void 0 : existingQualifyingStructureIds.includes(link.source.structureId));
43962
43968
  });
@@ -43991,7 +43997,7 @@ function generateDrawStructuresAndLinks$1(params) {
43991
43997
  var structure = existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.find(function (structure) { return structure.structureId === qualifyingStructureId; });
43992
43998
  return getQualifiersCount(link, structure);
43993
43999
  }).filter(Boolean).reduce(function (a, b) { return a + b; }, 0);
43994
- var mainStructureIsPlaceholder = !!(existingMainStructure && !((_h = existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.matchUps) === null || _h === void 0 ? void 0 : _h.length));
44000
+ var mainStructureIsPlaceholder = !!(existingMainStructure && !((_g = existingMainStructure === null || existingMainStructure === void 0 ? void 0 : existingMainStructure.matchUps) === null || _g === void 0 ? void 0 : _g.length));
43995
44001
  if ((existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) && !mainStructureIsPlaceholder) {
43996
44002
  return { error: EXISTING_STAGE };
43997
44003
  }
@@ -44116,14 +44122,14 @@ function generateDrawStructuresAndLinks$1(params) {
44116
44122
  var qualifyingDetail = _q.value;
44117
44123
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
44118
44124
  var link = mainStructure &&
44119
- ((_j = generateQualifyingLink({
44125
+ ((_h = generateQualifyingLink({
44120
44126
  targetStructureId: mainStructure.structureId,
44121
44127
  sourceStructureId: qualifyingStructureId,
44122
44128
  sourceRoundNumber: qualifyingRoundNumber,
44123
44129
  finishingPositions: finishingPositions,
44124
44130
  targetEntryRound: targetEntryRound,
44125
44131
  linkType: linkType,
44126
- })) === null || _j === void 0 ? void 0 : _j.link);
44132
+ })) === null || _h === void 0 ? void 0 : _h.link);
44127
44133
  if (link === null || link === void 0 ? void 0 : link.error)
44128
44134
  return link;
44129
44135
  if (link) {
@@ -59356,7 +59362,8 @@ function addEventEntryPairs(_a) {
59356
59362
  }
59357
59363
 
59358
59364
  function checkValidEntries(_a) {
59359
- var _b = _a.enforceGender, enforceGender = _b === void 0 ? true : _b, participants = _a.participants, event = _a.event;
59365
+ var _b = _a.enforceGender, enforceGender = _b === void 0 ? true : _b, consideredEntries = _a.consideredEntries, tournamentRecord = _a.tournamentRecord, participants = _a.participants, event = _a.event;
59366
+ participants = participants || (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants);
59360
59367
  if (!participants)
59361
59368
  return { error: MISSING_PARTICIPANTS };
59362
59369
  if (!Array.isArray(participants))
@@ -59367,7 +59374,7 @@ function checkValidEntries(_a) {
59367
59374
  var participantType = (eventType === TEAM_EVENT && TEAM) ||
59368
59375
  (eventType === DOUBLES_EVENT && PAIR) ||
59369
59376
  INDIVIDUAL;
59370
- var entryStatusMap = Object.assign.apply(Object, __spreadArray([{}], __read((event.entries || []).map(function (entry) {
59377
+ var entryStatusMap = Object.assign.apply(Object, __spreadArray([{}], __read((consideredEntries || event.entries || []).map(function (entry) {
59371
59378
  var _a;
59372
59379
  return (_a = {},
59373
59380
  _a[entry.participantId] = entry.entryStatus,
@@ -62179,45 +62186,61 @@ function prepareStage(params) {
62179
62186
 
62180
62187
  function generateDrawDefinition(params) {
62181
62188
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, _e, e_5, _f, e_6, _g, _h;
62182
- var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
62189
+ var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21;
62183
62190
  var stack = 'generateDrawDefinition';
62184
- var _16 = params.drawType, drawType = _16 === void 0 ? DrawTypeEnum.SingleElimination : _16, _17 = params.considerEventEntries, considerEventEntries = _17 === void 0 ? true : _17, // in the absence of drawSize and drawEntries, look to event.entries
62185
- ignoreAllowedDrawTypes = params.ignoreAllowedDrawTypes, voluntaryConsolation = params.voluntaryConsolation, hydrateCollections = params.hydrateCollections, policyDefinitions = params.policyDefinitions, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, enforceGender = params.enforceGender, tieFormatName = params.tieFormatName, drawEntries = params.drawEntries, addToEvent = params.addToEvent, placeByes = params.placeByes, event = params.event;
62191
+ var _22 = params.considerEventEntries, considerEventEntries = _22 === void 0 ? true : _22, // in the absence of drawSize and drawEntries, look to event.entries
62192
+ _23 = params.drawTypeCoercion, // in the absence of drawSize and drawEntries, look to event.entries
62193
+ drawTypeCoercion = _23 === void 0 ? true : _23, ignoreAllowedDrawTypes = params.ignoreAllowedDrawTypes, voluntaryConsolation = params.voluntaryConsolation, hydrateCollections = params.hydrateCollections, policyDefinitions = params.policyDefinitions, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, tieFormatName = params.tieFormatName, drawEntries = params.drawEntries, addToEvent = params.addToEvent, placeByes = params.placeByes, event = params.event;
62194
+ var drawType = (drawTypeCoercion &&
62195
+ params.drawSize === 2 &&
62196
+ DrawTypeEnum.SingleElimination) ||
62197
+ params.drawType ||
62198
+ DrawTypeEnum.SingleElimination;
62186
62199
  // get participants both for entry validation and for automated placement
62187
62200
  // automated placement requires them to be "inContext" for avoidance policies to work
62188
62201
  var participants = getTournamentParticipants({
62189
62202
  tournamentRecord: tournamentRecord,
62190
62203
  inContext: true,
62191
62204
  }).tournamentParticipants;
62192
- // entries participantTypes must correspond with eventType
62193
- // this is only possible if the event is provided
62194
- var validEntriesResult = event &&
62195
- participants &&
62196
- checkValidEntries({ event: event, participants: participants, enforceGender: enforceGender });
62197
- if (validEntriesResult === null || validEntriesResult === void 0 ? void 0 : validEntriesResult.error)
62198
- return decorateResult({ result: validEntriesResult, stack: stack });
62205
+ var appliedPolicies = (_j = getAppliedPolicies({
62206
+ tournamentRecord: tournamentRecord,
62207
+ event: event,
62208
+ }).appliedPolicies) !== null && _j !== void 0 ? _j : {};
62209
+ var enforceGender = (_o = (_k = params.enforceGender) !== null && _k !== void 0 ? _k : (_m = (_l = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _l === void 0 ? void 0 : _l.participants) === null || _m === void 0 ? void 0 : _m.enforceGender) !== null && _o !== void 0 ? _o : (_q = (_p = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _p === void 0 ? void 0 : _p.participants) === null || _q === void 0 ? void 0 : _q.enforceGender;
62199
62210
  // if tournamentRecord is provided, and unless instructed to ignore valid types,
62200
62211
  // check for restrictions on allowed drawTypes
62201
62212
  var allowedDrawTypes = !ignoreAllowedDrawTypes &&
62202
62213
  tournamentRecord &&
62203
62214
  getAllowedDrawTypes({
62204
62215
  tournamentRecord: tournamentRecord,
62205
- categoryType: (_j = event === null || event === void 0 ? void 0 : event.category) === null || _j === void 0 ? void 0 : _j.categoryType,
62206
- categoryName: (_k = event === null || event === void 0 ? void 0 : event.category) === null || _k === void 0 ? void 0 : _k.categoryName,
62216
+ categoryType: (_r = event === null || event === void 0 ? void 0 : event.category) === null || _r === void 0 ? void 0 : _r.categoryType,
62217
+ categoryName: (_s = event === null || event === void 0 ? void 0 : event.category) === null || _s === void 0 ? void 0 : _s.categoryName,
62207
62218
  });
62208
62219
  if ((allowedDrawTypes === null || allowedDrawTypes === void 0 ? void 0 : allowedDrawTypes.length) && !allowedDrawTypes.includes(drawType)) {
62209
62220
  return decorateResult({ result: { error: INVALID_DRAW_TYPE }, stack: stack });
62210
62221
  }
62211
- var eventEntries = (_m = (_l = event === null || event === void 0 ? void 0 : event.entries) === null || _l === void 0 ? void 0 : _l.filter(function (entry) {
62222
+ var eventEntries = (_u = (_t = event === null || event === void 0 ? void 0 : event.entries) === null || _t === void 0 ? void 0 : _t.filter(function (entry) {
62212
62223
  return entry.entryStatus &&
62213
62224
  __spreadArray(__spreadArray([], __read(STRUCTURE_ENTERED_TYPES), false), [QUALIFIER], false).includes(entry.entryStatus);
62214
- })) !== null && _m !== void 0 ? _m : [];
62225
+ })) !== null && _u !== void 0 ? _u : [];
62215
62226
  var consideredEntries = ((qualifyingOnly && []) ||
62216
62227
  drawEntries ||
62217
62228
  (considerEventEntries ? eventEntries : [])).filter(function (_a) {
62218
62229
  var entryStage = _a.entryStage;
62219
62230
  return !entryStage || entryStage === MAIN;
62220
62231
  });
62232
+ // entries participantTypes must correspond with eventType
62233
+ // this is only possible if the event is provided
62234
+ var validEntriesResult = event &&
62235
+ participants &&
62236
+ checkValidEntries({
62237
+ consideredEntries: consideredEntries,
62238
+ enforceGender: enforceGender,
62239
+ participants: participants,
62240
+ event: event,
62241
+ });
62242
+ if (validEntriesResult === null || validEntriesResult === void 0 ? void 0 : validEntriesResult.error)
62243
+ return decorateResult({ result: validEntriesResult, stack: stack });
62221
62244
  var derivedDrawSize = !params.drawSize &&
62222
62245
  consideredEntries.length &&
62223
62246
  ![
@@ -62241,12 +62264,12 @@ function generateDrawDefinition(params) {
62241
62264
  });
62242
62265
  }
62243
62266
  var seedsCount = typeof params.seedsCount !== 'number'
62244
- ? ensureInt((_o = params.seedsCount) !== null && _o !== void 0 ? _o : 0)
62245
- : (_p = params.seedsCount) !== null && _p !== void 0 ? _p : 0;
62267
+ ? ensureInt((_v = params.seedsCount) !== null && _v !== void 0 ? _v : 0)
62268
+ : (_w = params.seedsCount) !== null && _w !== void 0 ? _w : 0;
62246
62269
  var eventType = event === null || event === void 0 ? void 0 : event.eventType;
62247
- var matchUpType = (_q = params.matchUpType) !== null && _q !== void 0 ? _q : eventType;
62270
+ var matchUpType = (_x = params.matchUpType) !== null && _x !== void 0 ? _x : eventType;
62248
62271
  var existingDrawDefinition = params.drawId
62249
- ? (_r = event === null || event === void 0 ? void 0 : event.drawDefinitions) === null || _r === void 0 ? void 0 : _r.find(function (d) { return d.drawId === params.drawId; })
62272
+ ? (_y = event === null || event === void 0 ? void 0 : event.drawDefinitions) === null || _y === void 0 ? void 0 : _y.find(function (d) { return d.drawId === params.drawId; })
62250
62273
  : undefined;
62251
62274
  // drawDefinition cannot have both tieFormat and matchUpFormat
62252
62275
  var tieFormat = params.tieFormat, matchUpFormat = params.matchUpFormat;
@@ -62254,16 +62277,16 @@ function generateDrawDefinition(params) {
62254
62277
  if (matchUpType === TEAM$2 && eventType === TEAM$2) {
62255
62278
  // if there is an existingDrawDefinition which has a tieFormat on MAIN structure
62256
62279
  // use this tieFormat ONLY when no tieFormat is specified in params
62257
- var existingMainTieFormat = (_t = (_s = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _s === void 0 ? void 0 : _s.find(function (_a) {
62280
+ var existingMainTieFormat = (_0 = (_z = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _z === void 0 ? void 0 : _z.find(function (_a) {
62258
62281
  var stage = _a.stage;
62259
62282
  return stage === MAIN;
62260
- })) === null || _t === void 0 ? void 0 : _t.tieFormat;
62283
+ })) === null || _0 === void 0 ? void 0 : _0.tieFormat;
62261
62284
  tieFormat =
62262
62285
  tieFormat ||
62263
62286
  existingMainTieFormat ||
62264
62287
  // if tieFormatName is provided and it matches the name of the tieFormat attached to parent event...
62265
62288
  (tieFormatName &&
62266
- ((_u = event === null || event === void 0 ? void 0 : event.tieFormat) === null || _u === void 0 ? void 0 : _u.tieFormatName) === tieFormatName &&
62289
+ ((_1 = event === null || event === void 0 ? void 0 : event.tieFormat) === null || _1 === void 0 ? void 0 : _1.tieFormatName) === tieFormatName &&
62267
62290
  event.tieFormat) ||
62268
62291
  // if the tieFormatName is not found in the factory then will use default
62269
62292
  (tieFormatName &&
@@ -62315,7 +62338,7 @@ function generateDrawDefinition(params) {
62315
62338
  var result = checkTieFormat(tieFormat);
62316
62339
  if (result.error)
62317
62340
  return decorateResult({ result: result, stack: stack });
62318
- drawDefinition.tieFormat = (_v = result.tieFormat) !== null && _v !== void 0 ? _v : tieFormat;
62341
+ drawDefinition.tieFormat = (_2 = result.tieFormat) !== null && _2 !== void 0 ? _2 : tieFormat;
62319
62342
  }
62320
62343
  else if (matchUpFormat) {
62321
62344
  var result = setMatchUpFormat$1({
@@ -62335,10 +62358,6 @@ function generateDrawDefinition(params) {
62335
62358
  drawDefinition.matchUpType = matchUpType;
62336
62359
  }
62337
62360
  }
62338
- var appliedPolicies = (_w = getAppliedPolicies({
62339
- tournamentRecord: tournamentRecord,
62340
- event: event,
62341
- }).appliedPolicies) !== null && _w !== void 0 ? _w : {};
62342
62361
  if (policyDefinitions) {
62343
62362
  if (typeof policyDefinitions !== 'object') {
62344
62363
  return decorateResult({
@@ -62352,8 +62371,8 @@ function generateDrawDefinition(params) {
62352
62371
  else {
62353
62372
  var policiesToAttach = {};
62354
62373
  try {
62355
- for (var _18 = __values(Object.keys(policyDefinitions)), _19 = _18.next(); !_19.done; _19 = _18.next()) {
62356
- var key = _19.value;
62374
+ for (var _24 = __values(Object.keys(policyDefinitions)), _25 = _24.next(); !_25.done; _25 = _24.next()) {
62375
+ var key = _25.value;
62357
62376
  if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !==
62358
62377
  JSON.stringify(policyDefinitions[key])) {
62359
62378
  policiesToAttach[key] = policyDefinitions[key];
@@ -62363,7 +62382,7 @@ function generateDrawDefinition(params) {
62363
62382
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
62364
62383
  finally {
62365
62384
  try {
62366
- if (_19 && !_19.done && (_a = _18.return)) _a.call(_18);
62385
+ if (_25 && !_25.done && (_a = _24.return)) _a.call(_24);
62367
62386
  }
62368
62387
  finally { if (e_1) throw e_1.error; }
62369
62388
  }
@@ -62379,19 +62398,19 @@ function generateDrawDefinition(params) {
62379
62398
  Object.assign(appliedPolicies, POLICY_SEEDING_USTA);
62380
62399
  }
62381
62400
  // find existing MAIN structureId if existingDrawDefinition
62382
- var structureId = (_y = (_x = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _x === void 0 ? void 0 : _x.find(function (structure) { return structure.stage === MAIN && structure.stageSequence === 1; })) === null || _y === void 0 ? void 0 : _y.structureId;
62401
+ var structureId = (_4 = (_3 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _3 === void 0 ? void 0 : _3.find(function (structure) { return structure.stage === MAIN && structure.stageSequence === 1; })) === null || _4 === void 0 ? void 0 : _4.structureId;
62383
62402
  var entries = drawEntries !== null && drawEntries !== void 0 ? drawEntries : eventEntries;
62384
62403
  var positioningReports = [];
62385
62404
  var drawTypeResult;
62386
62405
  var conflicts = [];
62387
62406
  var generateQualifyingPlaceholder = params.qualifyingPlaceholder &&
62388
- !((_z = params.qualifyingProfiles) === null || _z === void 0 ? void 0 : _z.length) &&
62407
+ !((_5 = params.qualifyingProfiles) === null || _5 === void 0 ? void 0 : _5.length) &&
62389
62408
  !existingDrawDefinition;
62390
62409
  var existingQualifyingStructures = existingDrawDefinition
62391
- ? (_0 = existingDrawDefinition.structures) === null || _0 === void 0 ? void 0 : _0.filter(function (structure) { return structure.stage === QUALIFYING; })
62410
+ ? (_6 = existingDrawDefinition.structures) === null || _6 === void 0 ? void 0 : _6.filter(function (structure) { return structure.stage === QUALIFYING; })
62392
62411
  : [];
62393
62412
  var existingQualifyingPlaceholderStructureId = (existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) === 1 &&
62394
- !((_1 = existingQualifyingStructures[0].matchUps) === null || _1 === void 0 ? void 0 : _1.length) &&
62413
+ !((_7 = existingQualifyingStructures[0].matchUps) === null || _7 === void 0 ? void 0 : _7.length) &&
62395
62414
  existingQualifyingStructures[0].structureId;
62396
62415
  if (existingQualifyingPlaceholderStructureId) {
62397
62416
  var qualifyingProfiles = params.qualifyingProfiles;
@@ -62407,24 +62426,24 @@ function generateDrawDefinition(params) {
62407
62426
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
62408
62427
  return qualifyingResult;
62409
62428
  }
62410
- drawDefinition.structures = (_2 = drawDefinition.structures) === null || _2 === void 0 ? void 0 : _2.filter(function (_a) {
62429
+ drawDefinition.structures = (_8 = drawDefinition.structures) === null || _8 === void 0 ? void 0 : _8.filter(function (_a) {
62411
62430
  var structureId = _a.structureId;
62412
62431
  return structureId !== existingQualifyingPlaceholderStructureId;
62413
62432
  });
62414
- drawDefinition.links = (_3 = drawDefinition.links) === null || _3 === void 0 ? void 0 : _3.filter(function (_a) {
62433
+ drawDefinition.links = (_9 = drawDefinition.links) === null || _9 === void 0 ? void 0 : _9.filter(function (_a) {
62415
62434
  var source = _a.source;
62416
62435
  return source.structureId !== existingQualifyingPlaceholderStructureId;
62417
62436
  });
62418
- var _20 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _20.qualifiersCount, qualifyingDrawPositionsCount = _20.qualifyingDrawPositionsCount, qualifyingDetails = _20.qualifyingDetails;
62437
+ var _26 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _26.qualifiersCount, qualifyingDrawPositionsCount = _26.qualifyingDrawPositionsCount, qualifyingDetails = _26.qualifyingDetails;
62419
62438
  if (qualifyingDrawPositionsCount) {
62420
62439
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
62421
- (_4 = drawDefinition.structures) === null || _4 === void 0 ? void 0 : _4.push.apply(_4, __spreadArray([], __read(qualifyingResult.structures), false));
62440
+ (_10 = drawDefinition.structures) === null || _10 === void 0 ? void 0 : _10.push.apply(_10, __spreadArray([], __read(qualifyingResult.structures), false));
62422
62441
  }
62423
62442
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.links) {
62424
- (_5 = drawDefinition.links) === null || _5 === void 0 ? void 0 : _5.push.apply(_5, __spreadArray([], __read(qualifyingResult.links), false));
62443
+ (_11 = drawDefinition.links) === null || _11 === void 0 ? void 0 : _11.push.apply(_11, __spreadArray([], __read(qualifyingResult.links), false));
62425
62444
  }
62426
62445
  }
62427
- var mainStructure = (_6 = drawDefinition.structures) === null || _6 === void 0 ? void 0 : _6.find(function (_a) {
62446
+ var mainStructure = (_12 = drawDefinition.structures) === null || _12 === void 0 ? void 0 : _12.find(function (_a) {
62428
62447
  var stage = _a.stage, stageSequence = _a.stageSequence;
62429
62448
  return stage === MAIN && stageSequence === 1;
62430
62449
  });
@@ -62450,12 +62469,12 @@ function generateDrawDefinition(params) {
62450
62469
  if (result.error)
62451
62470
  return result;
62452
62471
  try {
62453
- for (var _21 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
62472
+ for (var _27 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
62454
62473
  var entryStage = _a.entryStage;
62455
62474
  return entryStage === StageTypeEnum.Qualifying;
62456
- })), _22 = _21.next(); !_22.done; _22 = _21.next()) {
62457
- var entry = _22.value;
62458
- var entryData = __assign(__assign({}, entry), { entryStage: (_7 = entry.entryStage) !== null && _7 !== void 0 ? _7 : StageTypeEnum.Main, drawDefinition: drawDefinition });
62475
+ })), _28 = _27.next(); !_28.done; _28 = _27.next()) {
62476
+ var entry = _28.value;
62477
+ var entryData = __assign(__assign({}, entry), { entryStage: (_13 = entry.entryStage) !== null && _13 !== void 0 ? _13 : StageTypeEnum.Main, drawDefinition: drawDefinition });
62459
62478
  // ignore errors (EXITING_PARTICIPANT)
62460
62479
  addDrawEntry(entryData);
62461
62480
  }
@@ -62463,23 +62482,23 @@ function generateDrawDefinition(params) {
62463
62482
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
62464
62483
  finally {
62465
62484
  try {
62466
- if (_22 && !_22.done && (_b = _21.return)) _b.call(_21);
62485
+ if (_28 && !_28.done && (_b = _27.return)) _b.call(_27);
62467
62486
  }
62468
62487
  finally { if (e_2) throw e_2.error; }
62469
62488
  }
62470
62489
  try {
62471
- for (var _23 = __values(qualifyingDetails || []), _24 = _23.next(); !_24.done; _24 = _23.next()) {
62472
- var qualifyingDetail = _24.value;
62490
+ for (var _29 = __values(qualifyingDetails || []), _30 = _29.next(); !_30.done; _30 = _29.next()) {
62491
+ var qualifyingDetail = _30.value;
62473
62492
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
62474
62493
  var link = mainStructure &&
62475
- ((_8 = generateQualifyingLink({
62494
+ ((_14 = generateQualifyingLink({
62476
62495
  targetStructureId: mainStructure.structureId,
62477
62496
  sourceStructureId: qualifyingStructureId,
62478
62497
  sourceRoundNumber: qualifyingRoundNumber,
62479
62498
  finishingPositions: finishingPositions,
62480
62499
  targetEntryRound: targetEntryRound,
62481
62500
  linkType: linkType,
62482
- })) === null || _8 === void 0 ? void 0 : _8.link);
62501
+ })) === null || _14 === void 0 ? void 0 : _14.link);
62483
62502
  if (link === null || link === void 0 ? void 0 : link.error)
62484
62503
  return link;
62485
62504
  if (link) {
@@ -62492,7 +62511,7 @@ function generateDrawDefinition(params) {
62492
62511
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
62493
62512
  finally {
62494
62513
  try {
62495
- if (_24 && !_24.done && (_c = _23.return)) _c.call(_23);
62514
+ if (_30 && !_30.done && (_c = _29.return)) _c.call(_29);
62496
62515
  }
62497
62516
  finally { if (e_3) throw e_3.error; }
62498
62517
  }
@@ -62513,7 +62532,7 @@ function generateDrawDefinition(params) {
62513
62532
  entry.entryStage &&
62514
62533
  entry.entryStage !== StageTypeEnum.Main)
62515
62534
  continue;
62516
- var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (_9 = entry.entryStage) !== null && _9 !== void 0 ? _9 : StageTypeEnum.Main, drawDefinition: drawDefinition, drawType: drawType });
62535
+ var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (_15 = entry.entryStage) !== null && _15 !== void 0 ? _15 : StageTypeEnum.Main, drawDefinition: drawDefinition, drawType: drawType });
62517
62536
  var result = addDrawEntry(entryData);
62518
62537
  if (drawEntries && result.error) {
62519
62538
  // only report errors with drawEntries
@@ -62537,13 +62556,13 @@ function generateDrawDefinition(params) {
62537
62556
  if (structureResult.error && !structureResult.conflicts) {
62538
62557
  return structureResult;
62539
62558
  }
62540
- if ((_10 = structureResult.positioningReport) === null || _10 === void 0 ? void 0 : _10.length)
62559
+ if ((_16 = structureResult.positioningReport) === null || _16 === void 0 ? void 0 : _16.length)
62541
62560
  positioningReports.push((_e = {}, _e[MAIN] = structureResult.positioningReport, _e));
62542
62561
  structureId = structureResult.structureId;
62543
62562
  if (structureResult.conflicts)
62544
62563
  conflicts = structureResult.conflicts;
62545
62564
  if (drawType === AD_HOC && params.roundsCount) {
62546
- var entries_2 = (_11 = event === null || event === void 0 ? void 0 : event.entries) === null || _11 === void 0 ? void 0 : _11.filter(function (_a) {
62565
+ var entries_2 = (_17 = event === null || event === void 0 ? void 0 : event.entries) === null || _17 === void 0 ? void 0 : _17.filter(function (_a) {
62547
62566
  var entryStage = _a.entryStage, entryStatus = _a.entryStatus;
62548
62567
  return (!entryStage || entryStage === MAIN) &&
62549
62568
  entryStatus &&
@@ -62590,20 +62609,20 @@ function generateDrawDefinition(params) {
62590
62609
  var roundTarget = 1;
62591
62610
  params.qualifyingProfiles.sort(roundTargetSort);
62592
62611
  try {
62593
- for (var _25 = __values(params.qualifyingProfiles), _26 = _25.next(); !_26.done; _26 = _25.next()) {
62594
- var roundTargetProfile = _26.value;
62612
+ for (var _31 = __values(params.qualifyingProfiles), _32 = _31.next(); !_32.done; _32 = _31.next()) {
62613
+ var roundTargetProfile = _32.value;
62595
62614
  if (!Array.isArray(roundTargetProfile.structureProfiles))
62596
62615
  return decorateResult({
62597
62616
  result: { error: MISSING_VALUE },
62598
62617
  info: mustBeAnArray('structureProfiles'),
62599
62618
  });
62600
62619
  roundTarget = roundTargetProfile.roundTarget || roundTarget;
62601
- var sortedStructureProfiles = ((_12 = roundTargetProfile.structureProfiles) === null || _12 === void 0 ? void 0 : _12.sort(sequenceSort)) || [];
62620
+ var sortedStructureProfiles = ((_18 = roundTargetProfile.structureProfiles) === null || _18 === void 0 ? void 0 : _18.sort(sequenceSort)) || [];
62602
62621
  var sequence = 1;
62603
62622
  try {
62604
62623
  for (var sortedStructureProfiles_1 = (e_6 = void 0, __values(sortedStructureProfiles)), sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next(); !sortedStructureProfiles_1_1.done; sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next()) {
62605
62624
  var structureProfile = sortedStructureProfiles_1_1.value;
62606
- var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _27 = structureProfile.seedsCount, seedsCount_1 = _27 === void 0 ? 0 : _27, seedingProfile = structureProfile.seedingProfile, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
62625
+ var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _33 = structureProfile.seedsCount, seedsCount_1 = _33 === void 0 ? 0 : _33, seedingProfile = structureProfile.seedingProfile, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
62607
62626
  var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedingProfile: seedingProfile, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount_1, placeByes: placeByes_1, drawSize: drawSize_1, entries: entries }));
62608
62627
  if (qualifyingStageResult.error) {
62609
62628
  return qualifyingStageResult;
@@ -62612,9 +62631,9 @@ function generateDrawDefinition(params) {
62612
62631
  preparedStructureIds.push(qualifyingStageResult.structureId);
62613
62632
  }
62614
62633
  sequence += 1;
62615
- if ((_13 = qualifyingStageResult.conflicts) === null || _13 === void 0 ? void 0 : _13.length)
62634
+ if ((_19 = qualifyingStageResult.conflicts) === null || _19 === void 0 ? void 0 : _19.length)
62616
62635
  qualifyingConflicts.push.apply(qualifyingConflicts, __spreadArray([], __read(qualifyingStageResult.conflicts), false));
62617
- if ((_14 = qualifyingStageResult.positioningReport) === null || _14 === void 0 ? void 0 : _14.length)
62636
+ if ((_20 = qualifyingStageResult.positioningReport) === null || _20 === void 0 ? void 0 : _20.length)
62618
62637
  positioningReports.push((_h = {},
62619
62638
  _h[QUALIFYING] = qualifyingStageResult.positioningReport,
62620
62639
  _h));
@@ -62633,7 +62652,7 @@ function generateDrawDefinition(params) {
62633
62652
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
62634
62653
  finally {
62635
62654
  try {
62636
- if (_26 && !_26.done && (_f = _25.return)) _f.call(_25);
62655
+ if (_32 && !_32.done && (_f = _31.return)) _f.call(_31);
62637
62656
  }
62638
62657
  finally { if (e_5) throw e_5.error; }
62639
62658
  }
@@ -62656,7 +62675,7 @@ function generateDrawDefinition(params) {
62656
62675
  drawDefinition.links = [];
62657
62676
  drawDefinition.links.push(link);
62658
62677
  }
62659
- drawDefinition.drawName = (_15 = params.drawName) !== null && _15 !== void 0 ? _15 : drawType;
62678
+ drawDefinition.drawName = (_21 = params.drawName) !== null && _21 !== void 0 ? _21 : drawType;
62660
62679
  if (typeof voluntaryConsolation === 'object') {
62661
62680
  addVoluntaryConsolationStructure(__assign(__assign({}, voluntaryConsolation), { tournamentRecord: tournamentRecord, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, matchUpType: matchUpType }));
62662
62681
  }