tods-competition-factory 1.7.14 → 1.7.15

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.7.14';
365
+ return '1.7.15';
366
366
  }
367
367
 
368
368
  /******************************************************************************
@@ -3529,31 +3529,25 @@ function validateTieFormat(params) {
3529
3529
  if (!params || !tieFormat || typeof tieFormat !== 'object') {
3530
3530
  errors.push('tieFormat must be an object');
3531
3531
  return decorateResult({
3532
- result: {
3533
- context: { tieFormat: tieFormat, errors: errors },
3534
- error: INVALID_TIE_FORMAT,
3535
- stack: stack,
3536
- },
3532
+ result: { error: INVALID_TIE_FORMAT },
3533
+ context: { tieFormat: tieFormat, errors: errors },
3534
+ stack: stack,
3537
3535
  });
3538
3536
  }
3539
3537
  if (typeof tieFormat.winCriteria !== 'object') {
3540
3538
  errors.push('tieFormat.winCriteria must be an object');
3541
3539
  return decorateResult({
3542
- result: {
3543
- context: { tieFormat: tieFormat, errors: errors },
3544
- error: INVALID_TIE_FORMAT,
3545
- stack: stack,
3546
- },
3540
+ result: { error: INVALID_TIE_FORMAT },
3541
+ context: { tieFormat: tieFormat, errors: errors },
3542
+ stack: stack,
3547
3543
  });
3548
3544
  }
3549
3545
  if (!Array.isArray(tieFormat.collectionDefinitions)) {
3550
3546
  errors.push(mustBeAnArray('tieFormat.collectionDefinitions'));
3551
3547
  return decorateResult({
3552
- result: {
3553
- context: { tieFormat: tieFormat, errors: errors },
3554
- error: INVALID_TIE_FORMAT,
3555
- stack: stack,
3556
- },
3548
+ result: { error: INVALID_TIE_FORMAT },
3549
+ context: { tieFormat: tieFormat, errors: errors },
3550
+ stack: stack,
3557
3551
  });
3558
3552
  }
3559
3553
  var aggregateValueImperative;
@@ -3587,11 +3581,9 @@ function validateTieFormat(params) {
3587
3581
  errors.push('Either non-zero valueGoal, or { aggregateValue: true } must be specified in winCriteria');
3588
3582
  }
3589
3583
  return decorateResult({
3590
- result: {
3591
- context: { tieFormat: tieFormat, errors: errors, aggregateValueImperative: aggregateValueImperative },
3592
- error: INVALID_TIE_FORMAT,
3593
- stack: stack,
3594
- },
3584
+ context: { tieFormat: tieFormat, errors: errors, aggregateValueImperative: aggregateValueImperative },
3585
+ result: { error: INVALID_TIE_FORMAT },
3586
+ stack: stack,
3595
3587
  });
3596
3588
  }
3597
3589
  var collectionIds = tieFormat.collectionDefinitions.map(function (_a) {
@@ -3604,11 +3596,9 @@ function validateTieFormat(params) {
3604
3596
  var result = { valid: valid, errors: errors };
3605
3597
  if (!valid) {
3606
3598
  return decorateResult({
3607
- result: {
3608
- context: { tieFormat: tieFormat, errors: errors },
3609
- error: INVALID_TIE_FORMAT,
3610
- stack: stack,
3611
- },
3599
+ result: { error: INVALID_TIE_FORMAT },
3600
+ context: { tieFormat: tieFormat, errors: errors },
3601
+ stack: stack,
3612
3602
  });
3613
3603
  }
3614
3604
  return result;
@@ -5932,26 +5922,27 @@ function getEvents(_a) {
5932
5922
  return { events: eventCopies };
5933
5923
  }
5934
5924
  function findEvent(_a) {
5925
+ var _b;
5935
5926
  var tournamentRecord = _a.tournamentRecord, eventId = _a.eventId, drawId = _a.drawId;
5936
5927
  var stack = 'findEvent';
5937
5928
  if (!tournamentRecord)
5938
- return __assign({ event: undefined, drawDefinition: undefined }, decorateResult({
5929
+ return decorateResult({
5939
5930
  result: { error: MISSING_TOURNAMENT_RECORD },
5940
5931
  stack: stack,
5941
- }));
5942
- var events = (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.events) || [];
5932
+ });
5933
+ var events = (_b = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.events) !== null && _b !== void 0 ? _b : [];
5943
5934
  if (drawId) {
5944
5935
  var drawDefinition_1;
5945
5936
  var event_1 = events.find(function (event) {
5946
- var _a;
5947
- var drawDefinitions = (event === null || event === void 0 ? void 0 : event.drawDefinitions) || [];
5937
+ var _a, _b;
5938
+ var drawDefinitions = (_a = event === null || event === void 0 ? void 0 : event.drawDefinitions) !== null && _a !== void 0 ? _a : [];
5948
5939
  var targetDrawDefinition = drawDefinitions.find(function (drawDefinition) { return drawDefinition.drawId === drawId; });
5949
5940
  if (targetDrawDefinition) {
5950
5941
  drawDefinition_1 = targetDrawDefinition;
5951
5942
  }
5952
5943
  else {
5953
5944
  var flightProfile = getFlightProfile({ event: event }).flightProfile;
5954
- var flight = (_a = flightProfile === null || flightProfile === void 0 ? void 0 : flightProfile.flights) === null || _a === void 0 ? void 0 : _a.find(function (flight) { return flight.drawId === drawId; });
5945
+ var flight = (_b = flightProfile === null || flightProfile === void 0 ? void 0 : flightProfile.flights) === null || _b === void 0 ? void 0 : _b.find(function (flight) { return flight.drawId === drawId; });
5955
5946
  if (flight)
5956
5947
  return {
5957
5948
  drawId: drawId,
@@ -5999,6 +5990,7 @@ function getDrawDefinition$2(_a) {
5999
5990
  }
6000
5991
 
6001
5992
  function addExtension$1(params) {
5993
+ var _a;
6002
5994
  if (typeof params !== 'object')
6003
5995
  return { error: MISSING_VALUE };
6004
5996
  var stack = 'addExtension';
@@ -6013,7 +6005,7 @@ function addExtension$1(params) {
6013
6005
  });
6014
6006
  if (!params.element.extensions)
6015
6007
  params.element.extensions = [];
6016
- var creationTime = params.creationTime !== undefined ? params.creationTime : true;
6008
+ var creationTime = (_a = params === null || params === void 0 ? void 0 : params.creationTime) !== null && _a !== void 0 ? _a : true;
6017
6009
  if (creationTime) {
6018
6010
  var createdAt = new Date().toISOString();
6019
6011
  Object.assign(params.extension, { createdAt: createdAt });
@@ -6578,7 +6570,7 @@ function publicFindVenue(_a) {
6578
6570
 
6579
6571
  function findCourt(_a) {
6580
6572
  var e_1, _b;
6581
- var _c;
6573
+ var _c, _d;
6582
6574
  var tournamentRecords = _a.tournamentRecords, tournamentRecord = _a.tournamentRecord, courtId = _a.courtId;
6583
6575
  if (!tournamentRecord)
6584
6576
  return { error: MISSING_TOURNAMENT_RECORD };
@@ -6600,9 +6592,9 @@ function findCourt(_a) {
6600
6592
  }
6601
6593
  else if (tournamentRecords) {
6602
6594
  // if tournamentRecords is provided then call is from competitionEngine
6603
- var linkedTournamentIds = getLinkedTournamentIds({
6595
+ var linkedTournamentIds = (_d = getLinkedTournamentIds({
6604
6596
  tournamentRecords: tournamentRecords,
6605
- }).linkedTournamentIds || [];
6597
+ }).linkedTournamentIds) !== null && _d !== void 0 ? _d : [];
6606
6598
  var relevantIds = linkedTournamentIds[tournamentRecord.tournamentId];
6607
6599
  try {
6608
6600
  // if there are linked tournaments search for court in all linked tournaments
@@ -22914,6 +22906,7 @@ function drawPositionRemovals(_a) {
22914
22906
  return { tasks: tasks, drawPositionCleared: drawPositionCleared, positionAssignments: positionAssignments };
22915
22907
  }
22916
22908
  function removeSubsequentRoundsParticipant(_a) {
22909
+ var _b;
22917
22910
  var inContextDrawMatchUps = _a.inContextDrawMatchUps, targetDrawPosition = _a.targetDrawPosition, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpsMap = _a.matchUpsMap, roundNumber = _a.roundNumber, structureId = _a.structureId;
22918
22911
  var structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure;
22919
22912
  if (!structure)
@@ -22933,10 +22926,10 @@ function removeSubsequentRoundsParticipant(_a) {
22933
22926
  matchUp.roundNumber !== initialRoundNumber &&
22934
22927
  ((_a = matchUp.drawPositions) === null || _a === void 0 ? void 0 : _a.includes(targetDrawPosition));
22935
22928
  });
22936
- var positionAssignments = getPositionAssignments$1({
22929
+ var positionAssignments = (_b = getPositionAssignments$1({
22937
22930
  drawDefinition: drawDefinition,
22938
22931
  structureId: structureId,
22939
- }).positionAssignments || [];
22932
+ }).positionAssignments) !== null && _b !== void 0 ? _b : [];
22940
22933
  relevantMatchUps === null || relevantMatchUps === void 0 ? void 0 : relevantMatchUps.forEach(function (matchUp) {
22941
22934
  return removeDrawPosition({
22942
22935
  drawPosition: targetDrawPosition,
@@ -22952,13 +22945,13 @@ function removeSubsequentRoundsParticipant(_a) {
22952
22945
  return __assign({}, SUCCESS);
22953
22946
  }
22954
22947
  function removeDrawPosition(_a) {
22955
- var _b, _c, _d, _e, _f;
22948
+ var _b, _c, _d, _e, _f, _g, _h;
22956
22949
  var inContextDrawMatchUps = _a.inContextDrawMatchUps, positionAssignments = _a.positionAssignments, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, targetMatchUp = _a.targetMatchUp, drawPosition = _a.drawPosition, matchUpsMap = _a.matchUpsMap, structure = _a.structure, event = _a.event;
22957
22950
  var stack = 'removeDrawPosition';
22958
22951
  var initialDrawPositions = (_b = targetMatchUp.drawPositions) === null || _b === void 0 ? void 0 : _b.slice();
22959
22952
  var initialMatchUpStatus = targetMatchUp.matchUpStatus;
22960
22953
  var initialWinningSide = targetMatchUp.winningSide;
22961
- matchUpsMap = matchUpsMap || getMatchUpsMap({ drawDefinition: drawDefinition });
22954
+ matchUpsMap = matchUpsMap !== null && matchUpsMap !== void 0 ? matchUpsMap : getMatchUpsMap({ drawDefinition: drawDefinition });
22962
22955
  var mappedMatchUps = matchUpsMap.mappedMatchUps;
22963
22956
  var matchUps = mappedMatchUps[structure.structureId].matchUps;
22964
22957
  var initialRoundNumber = getInitialRoundNumber({
@@ -22968,18 +22961,18 @@ function removeDrawPosition(_a) {
22968
22961
  if (targetMatchUp.roundNumber &&
22969
22962
  initialRoundNumber &&
22970
22963
  targetMatchUp.roundNumber > initialRoundNumber) {
22971
- var drawPositions = (targetMatchUp.drawPositions || []).map(function (currentDrawPosition) {
22964
+ var drawPositions = ((_c = targetMatchUp.drawPositions) !== null && _c !== void 0 ? _c : []).map(function (currentDrawPosition) {
22972
22965
  return currentDrawPosition === drawPosition ? undefined : currentDrawPosition;
22973
22966
  });
22974
22967
  targetMatchUp.drawPositions = drawPositions;
22975
22968
  }
22976
22969
  if (targetMatchUp.matchUpType === TEAM$2) {
22977
22970
  var inContextTargetMatchUp = inContextDrawMatchUps === null || inContextDrawMatchUps === void 0 ? void 0 : inContextDrawMatchUps.find(function (matchUp) { return matchUp.matchUpId === targetMatchUp.matchUpId; });
22978
- var sides = (inContextTargetMatchUp === null || inContextTargetMatchUp === void 0 ? void 0 : inContextTargetMatchUp.sides) || [];
22971
+ var sides = (_d = inContextTargetMatchUp === null || inContextTargetMatchUp === void 0 ? void 0 : inContextTargetMatchUp.sides) !== null && _d !== void 0 ? _d : [];
22979
22972
  var drawPositionSideIndex = sides.reduce(function (index, side, i) { return (side.drawPosition === drawPosition ? i : index); }, undefined);
22980
22973
  if (drawPositionSideIndex !== undefined &&
22981
- ((_d = (_c = targetMatchUp.sides) === null || _c === void 0 ? void 0 : _c[drawPositionSideIndex]) === null || _d === void 0 ? void 0 : _d.lineUp)) {
22982
- (_e = targetMatchUp.sides) === null || _e === void 0 ? true : delete _e[drawPositionSideIndex].lineUp;
22974
+ ((_f = (_e = targetMatchUp.sides) === null || _e === void 0 ? void 0 : _e[drawPositionSideIndex]) === null || _f === void 0 ? void 0 : _f.lineUp)) {
22975
+ (_g = targetMatchUp.sides) === null || _g === void 0 ? true : delete _g[drawPositionSideIndex].lineUp;
22983
22976
  modifyMatchUpNotice({
22984
22977
  tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
22985
22978
  context: "".concat(stack, "-TEAM"),
@@ -22994,7 +22987,7 @@ function removeDrawPosition(_a) {
22994
22987
  inContextDrawMatchUps: inContextDrawMatchUps,
22995
22988
  drawDefinition: drawDefinition,
22996
22989
  });
22997
- var winnerTargetLink = targetData.targetLinks.winnerTargetLink, _g = targetData.targetMatchUps, loserMatchUp = _g.loserMatchUp, winnerMatchUp = _g.winnerMatchUp, loserMatchUpDrawPositionIndex = _g.loserMatchUpDrawPositionIndex;
22990
+ var winnerTargetLink = targetData.targetLinks.winnerTargetLink, _j = targetData.targetMatchUps, loserMatchUp = _j.loserMatchUp, winnerMatchUp = _j.winnerMatchUp, loserMatchUpDrawPositionIndex = _j.loserMatchUpDrawPositionIndex;
22998
22991
  var matchUpAssignments = positionAssignments.filter(function (_a) {
22999
22992
  var _b;
23000
22993
  var drawPosition = _a.drawPosition;
@@ -23005,7 +22998,7 @@ function removeDrawPosition(_a) {
23005
22998
  (targetMatchUp.matchUpStatus &&
23006
22999
  [DEFAULTED, WALKOVER$2].includes(targetMatchUp.matchUpStatus) &&
23007
23000
  targetMatchUp.matcHUpStatus) ||
23008
- (((_f = targetMatchUp.drawPositions) === null || _f === void 0 ? void 0 : _f.length) === 2 && TO_BE_PLAYED) ||
23001
+ (((_h = targetMatchUp.drawPositions) === null || _h === void 0 ? void 0 : _h.length) === 2 && TO_BE_PLAYED) ||
23009
23002
  undefined;
23010
23003
  targetMatchUp.matchUpStatus = newMatchUpStatus;
23011
23004
  // if the matchUpStatus is WALKOVER then it is DOUBLE_WALKOVER produced
@@ -24132,9 +24125,7 @@ function assignMatchUpDrawPosition(_a) {
24132
24125
  }
24133
24126
  else {
24134
24127
  return decorateResult({
24135
- result: {
24136
- error: DRAW_POSITION_ASSIGNED,
24137
- },
24128
+ result: { error: DRAW_POSITION_ASSIGNED },
24138
24129
  context: { drawPosition: drawPosition },
24139
24130
  stack: stack,
24140
24131
  });
@@ -25215,8 +25206,8 @@ function getSeedGroups(_a) {
25215
25206
  if (roundRobinGroupsCount) {
25216
25207
  if (!isConvertableInteger(roundRobinGroupsCount))
25217
25208
  return __assign({ seedGroups: undefined }, decorateResult({
25218
- result: { error: INVALID_VALUES },
25219
25209
  context: { roundRobinGroupsCount: roundRobinGroupsCount },
25210
+ result: { error: INVALID_VALUES },
25220
25211
  stack: stack,
25221
25212
  }));
25222
25213
  var seedNumber_1 = 1;
@@ -25255,8 +25246,8 @@ function getSeedingThresholds(_a) {
25255
25246
  var invalid = !(validGroupsCounts === null || validGroupsCounts === void 0 ? void 0 : validGroupsCounts.includes(roundRobinGroupsCount));
25256
25247
  if (invalid) {
25257
25248
  return decorateResult({
25258
- result: { error: INVALID_VALUES },
25259
25249
  context: { roundRobinGroupsCount: roundRobinGroupsCount },
25250
+ result: { error: INVALID_VALUES },
25260
25251
  });
25261
25252
  }
25262
25253
  }
@@ -26337,7 +26328,8 @@ function directLoser(params) {
26337
26328
  }
26338
26329
  else if (loserParticipantId && isFeedRound) {
26339
26330
  // if target.roundNumber > 1 then it is a feed round and should always take the lower drawPosition
26340
- var fedDrawPosition = unfilledTargetMatchUpDrawPositions.sort(numericSort)[0];
26331
+ unfilledTargetMatchUpDrawPositions.sort(numericSort);
26332
+ var fedDrawPosition = unfilledTargetMatchUpDrawPositions[0];
26341
26333
  var result = assignDrawPosition$1({
26342
26334
  participantId: loserParticipantId,
26343
26335
  structureId: targetStructureId,
@@ -27289,7 +27281,7 @@ function swapWinnerLoser(params) {
27289
27281
  }
27290
27282
 
27291
27283
  function setMatchUpStatus$2(params) {
27292
- var _a, _b, _c, _d, _e;
27284
+ var _a, _b, _c, _d, _e, _f, _g, _h;
27293
27285
  var stack = 'setMatchUpStatus';
27294
27286
  // always clear score if DOUBLE_WALKOVER or WALKOVER
27295
27287
  if (params.matchUpStatus &&
@@ -27349,13 +27341,13 @@ function setMatchUpStatus$2(params) {
27349
27341
  else if (enableAutoCalc) {
27350
27342
  var existingDualMatchUpWinningSide = matchUp.winningSide;
27351
27343
  removeExtension$1({ name: DISABLE_AUTO_CALC, element: matchUp });
27352
- var _f = generateTieMatchUpScore({
27344
+ var _j = generateTieMatchUpScore({
27353
27345
  drawDefinition: drawDefinition,
27354
27346
  matchUpsMap: matchUpsMap,
27355
27347
  structure: structure,
27356
27348
  matchUp: matchUp,
27357
27349
  event: event,
27358
- }), projectedWinningSide = _f.winningSide, scoreStringSide1 = _f.scoreStringSide1, scoreStringSide2 = _f.scoreStringSide2, set = _f.set;
27350
+ }), projectedWinningSide = _j.winningSide, scoreStringSide1 = _j.scoreStringSide1, scoreStringSide2 = _j.scoreStringSide2, set = _j.set;
27359
27351
  var score_1 = {
27360
27352
  scoreStringSide1: scoreStringSide1,
27361
27353
  scoreStringSide2: scoreStringSide2,
@@ -27394,10 +27386,7 @@ function setMatchUpStatus$2(params) {
27394
27386
  drawDefinition: drawDefinition,
27395
27387
  });
27396
27388
  if (score && matchUp.matchUpType !== TEAM$2 && !disableScoreValidation) {
27397
- var matchUpFormat = matchUp.matchUpFormat ||
27398
- (structure === null || structure === void 0 ? void 0 : structure.matchUpFormat) ||
27399
- (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpFormat) ||
27400
- (event === null || event === void 0 ? void 0 : event.matchUpFormat);
27389
+ var matchUpFormat = (_d = (_c = (_b = matchUp.matchUpFormat) !== null && _b !== void 0 ? _b : structure === null || structure === void 0 ? void 0 : structure.matchUpFormat) !== null && _c !== void 0 ? _c : drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpFormat) !== null && _d !== void 0 ? _d : event === null || event === void 0 ? void 0 : event.matchUpFormat;
27401
27390
  var result_1 = validateScore({
27402
27391
  existingMatchUpStatus: matchUp.matchUpStatus,
27403
27392
  matchUpFormat: matchUpFormat,
@@ -27415,7 +27404,7 @@ function setMatchUpStatus$2(params) {
27415
27404
  structureId: structureId,
27416
27405
  }).positionAssignments
27417
27406
  : [];
27418
- var bothSideParticipants = ((_b = matchUp.sides) === null || _b === void 0 ? void 0 : _b.map(function (side) { return side.participantId; }).filter(Boolean).length) ===
27407
+ var bothSideParticipants = ((_e = matchUp.sides) === null || _e === void 0 ? void 0 : _e.map(function (side) { return side.participantId; }).filter(Boolean).length) ===
27419
27408
  2 ||
27420
27409
  ((assignedDrawPositions === null || assignedDrawPositions === void 0 ? void 0 : assignedDrawPositions.length) === 2 &&
27421
27410
  (positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) {
@@ -27425,17 +27414,17 @@ function setMatchUpStatus$2(params) {
27425
27414
  particicipantsRequiredMatchUpStatuses.includes(matchUpStatus) &&
27426
27415
  !bothSideParticipants) {
27427
27416
  return decorateResult({
27428
- result: { error: INVALID_MATCHUP_STATUS },
27429
27417
  info: 'present in participantRequiredMatchUpStatuses',
27430
27418
  context: { matchUpStatus: matchUpStatus, bothSideParticipants: bothSideParticipants },
27419
+ result: { error: INVALID_MATCHUP_STATUS },
27431
27420
  });
27432
27421
  }
27433
- var appliedPolicies = (_d = (_c = getAppliedPolicies({
27422
+ var appliedPolicies = (_g = (_f = getAppliedPolicies({
27434
27423
  policyTypes: [POLICY_TYPE_PROGRESSION],
27435
27424
  tournamentRecord: tournamentRecord,
27436
27425
  drawDefinition: drawDefinition,
27437
27426
  event: event,
27438
- })) === null || _c === void 0 ? void 0 : _c.appliedPolicies) !== null && _d !== void 0 ? _d : {};
27427
+ })) === null || _f === void 0 ? void 0 : _f.appliedPolicies) !== null && _g !== void 0 ? _g : {};
27439
27428
  if (typeof params.policyDefinitions === 'object') {
27440
27429
  Object.assign(appliedPolicies, params.policyDefinitions);
27441
27430
  }
@@ -27476,12 +27465,12 @@ function setMatchUpStatus$2(params) {
27476
27465
  event: event,
27477
27466
  }).matchUp;
27478
27467
  if (dualMatchUp) {
27479
- var tieFormat = (_e = resolveTieFormat({
27468
+ var tieFormat = (_h = resolveTieFormat({
27480
27469
  matchUp: dualMatchUp,
27481
27470
  drawDefinition: drawDefinition,
27482
27471
  structure: structure,
27483
27472
  event: event,
27484
- })) === null || _e === void 0 ? void 0 : _e.tieFormat;
27473
+ })) === null || _h === void 0 ? void 0 : _h.tieFormat;
27485
27474
  var projectedWinningSide = getProjectedDualWinningSide({
27486
27475
  drawDefinition: drawDefinition,
27487
27476
  matchUpStatus: matchUpStatus,
@@ -27577,8 +27566,8 @@ function winningSideWithDownstreamDependencies(params) {
27577
27566
  }
27578
27567
  else {
27579
27568
  return decorateResult({
27580
- result: { error: CANNOT_CHANGE_WINNING_SIDE },
27581
27569
  stack: 'winningSideWithDownstreamDependencies',
27570
+ result: { error: CANNOT_CHANGE_WINNING_SIDE },
27582
27571
  context: { winningSide: winningSide, matchUp: matchUp },
27583
27572
  });
27584
27573
  }
@@ -28035,13 +28024,13 @@ function addDrawDefinition$1(params) {
28035
28024
  return decorateResult({
28036
28025
  result: {
28037
28026
  error: INVALID_DRAW_DEFINITION,
28038
- context: {
28039
- drawEntriesPresentInFlight: drawEntriesPresentInFlight,
28040
- matchingEventEntries: matchingEventEntries,
28041
- relevantFlight: relevantFlight,
28042
- },
28043
- info: 'Draw entries are not present in flight or do not match entryStatuses',
28044
28027
  },
28028
+ context: {
28029
+ drawEntriesPresentInFlight: drawEntriesPresentInFlight,
28030
+ matchingEventEntries: matchingEventEntries,
28031
+ relevantFlight: relevantFlight,
28032
+ },
28033
+ info: 'Draw entries are not present in flight or do not match entryStatuses',
28045
28034
  });
28046
28035
  }
28047
28036
  if (modifyEventEntries) {
@@ -28061,9 +28050,9 @@ function addDrawDefinition$1(params) {
28061
28050
  if (eventEntries && !matchingEventEntries)
28062
28051
  return decorateResult({
28063
28052
  result: {
28064
- error: INVALID_DRAW_DEFINITION,
28065
- context: { matchingEventEntries: matchingEventEntries, eventEntries: eventEntries },
28066
28053
  info: 'Draw entries do not match event entryStatuses',
28054
+ context: { matchingEventEntries: matchingEventEntries, eventEntries: eventEntries },
28055
+ error: INVALID_DRAW_DEFINITION,
28067
28056
  },
28068
28057
  });
28069
28058
  var flightNumbers = ((_f = (_e = flightProfile === null || flightProfile === void 0 ? void 0 : flightProfile.flights) === null || _e === void 0 ? void 0 : _e.map(function (_a) {
@@ -28238,10 +28227,8 @@ function addParticipant$1(_a) {
28238
28227
  else if (participant.individualParticipantIds.length !== 2 &&
28239
28228
  !pairOverride) {
28240
28229
  return decorateResult({
28241
- result: {
28242
- error: INVALID_PARTICIPANT_IDS,
28243
- info: 'PAIR must be 2 individualParticipantIds',
28244
- },
28230
+ info: 'PAIR must be 2 individualParticipantIds',
28231
+ result: { error: INVALID_PARTICIPANT_IDS },
28245
28232
  stack: stack,
28246
28233
  });
28247
28234
  }
@@ -32157,6 +32144,7 @@ function updateTieFormat(_a) {
32157
32144
  var e_1, _b;
32158
32145
  var _c, _d, _e, _f, _g;
32159
32146
  var updateInProgressMatchUps = _a.updateInProgressMatchUps, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structure = _a.structure, tieFormat = _a.tieFormat, eventId = _a.eventId, matchUp = _a.matchUp, event = _a.event, uuids = _a.uuids;
32147
+ console.log('booo', { matchUp: matchUp });
32160
32148
  var stack = 'updateTieFormat';
32161
32149
  var tournamentId = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId;
32162
32150
  var modifiedStructuresCount = 0;
@@ -32223,6 +32211,7 @@ function updateTieFormat(_a) {
32223
32211
  return decorateResult({
32224
32212
  result: { error: CANNOT_MODIFY_TIEFORMAT },
32225
32213
  info: 'matchUp is IN_PROGRESS or COMPLETE',
32214
+ stack: stack,
32226
32215
  });
32227
32216
  }
32228
32217
  }
@@ -33203,8 +33192,9 @@ function removeCollectionDefinition(params) {
33203
33192
 
33204
33193
  function addCollectionDefinition$1(_a) {
33205
33194
  var e_1, _b, e_2, _c, _d, e_3, _e;
33206
- var _f, _g, _h, _j, _k, _l, _m;
33207
- var _o = _a.updateInProgressMatchUps, updateInProgressMatchUps = _o === void 0 ? true : _o, collectionDefinition = _a.collectionDefinition, tournamentRecord = _a.tournamentRecord, referenceGender = _a.referenceGender, drawDefinition = _a.drawDefinition, tieFormatName = _a.tieFormatName, enforceGender = _a.enforceGender, structureId = _a.structureId, matchUpId = _a.matchUpId, matchUp = _a.matchUp, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
33195
+ var _f, _g, _h, _j, _k, _l, _m, _o;
33196
+ var _p = _a.updateInProgressMatchUps, updateInProgressMatchUps = _p === void 0 ? true : _p, collectionDefinition = _a.collectionDefinition, tournamentRecord = _a.tournamentRecord, referenceGender = _a.referenceGender, drawDefinition = _a.drawDefinition, tieFormatName = _a.tieFormatName, enforceGender = _a.enforceGender, structureId = _a.structureId, matchUpId = _a.matchUpId, matchUp = _a.matchUp, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
33197
+ var stack = 'addCollectionDefinition';
33208
33198
  var appliedPolicies = (_f = getAppliedPolicies({
33209
33199
  tournamentRecord: tournamentRecord,
33210
33200
  drawDefinition: drawDefinition,
@@ -33213,16 +33203,16 @@ function addCollectionDefinition$1(_a) {
33213
33203
  enforceGender =
33214
33204
  enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_h = (_g = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _g === void 0 ? void 0 : _g.participants) === null || _h === void 0 ? void 0 : _h.enforceGender;
33215
33205
  var checkGender = !!(enforceGender !== false && (event === null || event === void 0 ? void 0 : event.gender));
33216
- var _p = validateCollectionDefinition({
33206
+ var _q = validateCollectionDefinition({
33217
33207
  collectionDefinition: collectionDefinition,
33218
33208
  referenceGender: referenceGender,
33219
33209
  checkGender: checkGender,
33220
33210
  event: event,
33221
- }), valid = _p.valid, errors = _p.errors;
33222
- if (!valid)
33223
- return { error: INVALID_VALUES, errors: errors };
33224
- var stack = 'addCollectionDefinition';
33225
- var result = !matchUp
33211
+ }), valid = _q.valid, errors = _q.errors;
33212
+ if (!valid) {
33213
+ return decorateResult({ result: { error: INVALID_VALUES, errors: errors }, stack: stack });
33214
+ }
33215
+ var result = !(matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieFormat)
33226
33216
  ? getTieFormat$1({
33227
33217
  drawDefinition: drawDefinition,
33228
33218
  structureId: structureId,
@@ -33232,14 +33222,15 @@ function addCollectionDefinition$1(_a) {
33232
33222
  })
33233
33223
  : undefined;
33234
33224
  if (result === null || result === void 0 ? void 0 : result.error)
33235
- return { error: result.error };
33225
+ return decorateResult({ result: { error: result.error }, stack: stack });
33236
33226
  var structure = result === null || result === void 0 ? void 0 : result.structure;
33237
33227
  matchUp = matchUp !== null && matchUp !== void 0 ? matchUp : result === null || result === void 0 ? void 0 : result.matchUp;
33238
- var existingTieFormat = result === null || result === void 0 ? void 0 : result.tieFormat;
33228
+ var existingTieFormat = (_j = matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieFormat) !== null && _j !== void 0 ? _j : result === null || result === void 0 ? void 0 : result.tieFormat;
33239
33229
  var tieFormat = copyTieFormat(existingTieFormat);
33240
33230
  result = validateTieFormat({ tieFormat: tieFormat });
33241
- if (result === null || result === void 0 ? void 0 : result.error)
33242
- return { error: result.error };
33231
+ if (result === null || result === void 0 ? void 0 : result.error) {
33232
+ return decorateResult({ result: { error: result.error }, stack: stack });
33233
+ }
33243
33234
  if (!collectionDefinition.collectionId) {
33244
33235
  collectionDefinition.collectionId = UUID();
33245
33236
  }
@@ -33262,7 +33253,7 @@ function addCollectionDefinition$1(_a) {
33262
33253
  });
33263
33254
  // calculate new winCriteria for tieFormat
33264
33255
  // if existing winCriteria is aggregateValue, retain
33265
- var _q = calculateWinCriteria(tieFormat), aggregateValue = _q.aggregateValue, valueGoal = _q.valueGoal;
33256
+ var _r = calculateWinCriteria(tieFormat), aggregateValue = _r.aggregateValue, valueGoal = _r.valueGoal;
33266
33257
  tieFormat.winCriteria = definedAttributes({ aggregateValue: aggregateValue, valueGoal: valueGoal });
33267
33258
  // if valueGoal has changed, force renaming of the tieFormat
33268
33259
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
@@ -33281,19 +33272,20 @@ function addCollectionDefinition$1(_a) {
33281
33272
  var targetMatchUps = [];
33282
33273
  var prunedTieFormat = definedAttributes(tieFormat);
33283
33274
  result = validateTieFormat({ tieFormat: prunedTieFormat });
33284
- if (result === null || result === void 0 ? void 0 : result.error)
33285
- return { error: result.error };
33275
+ if (result === null || result === void 0 ? void 0 : result.error) {
33276
+ return decorateResult({ result: { error: result.error }, stack: stack });
33277
+ }
33286
33278
  if (eventId && event) {
33287
33279
  event.tieFormat = prunedTieFormat;
33288
33280
  try {
33289
33281
  // all team matchUps in the event which do not have tieFormats and where draws/strucures do not have tieFormats should have matchUps added
33290
- for (var _r = __values((_j = event.drawDefinitions) !== null && _j !== void 0 ? _j : []), _s = _r.next(); !_s.done; _s = _r.next()) {
33291
- var drawDefinition_1 = _s.value;
33282
+ for (var _s = __values((_k = event.drawDefinitions) !== null && _k !== void 0 ? _k : []), _t = _s.next(); !_t.done; _t = _s.next()) {
33283
+ var drawDefinition_1 = _t.value;
33292
33284
  if (drawDefinition_1.tieFormat)
33293
33285
  continue;
33294
33286
  try {
33295
- for (var _t = (e_2 = void 0, __values((_k = drawDefinition_1.structures) !== null && _k !== void 0 ? _k : [])), _u = _t.next(); !_u.done; _u = _t.next()) {
33296
- var structure_1 = _u.value;
33287
+ for (var _u = (e_2 = void 0, __values((_l = drawDefinition_1.structures) !== null && _l !== void 0 ? _l : [])), _v = _u.next(); !_v.done; _v = _u.next()) {
33288
+ var structure_1 = _v.value;
33297
33289
  if (structure_1.tieFormat)
33298
33290
  continue;
33299
33291
  var result_1 = updateStructureMatchUps({
@@ -33310,7 +33302,7 @@ function addCollectionDefinition$1(_a) {
33310
33302
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
33311
33303
  finally {
33312
33304
  try {
33313
- if (_u && !_u.done && (_c = _t.return)) _c.call(_t);
33305
+ if (_v && !_v.done && (_c = _u.return)) _c.call(_u);
33314
33306
  }
33315
33307
  finally { if (e_2) throw e_2.error; }
33316
33308
  }
@@ -33319,7 +33311,7 @@ function addCollectionDefinition$1(_a) {
33319
33311
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
33320
33312
  finally {
33321
33313
  try {
33322
- if (_s && !_s.done && (_b = _r.return)) _b.call(_r);
33314
+ if (_t && !_t.done && (_b = _s.return)) _b.call(_s);
33323
33315
  }
33324
33316
  finally { if (e_1) throw e_1.error; }
33325
33317
  }
@@ -33382,8 +33374,8 @@ function addCollectionDefinition$1(_a) {
33382
33374
  // all team matchUps in the drawDefinition which do not have tieFormats and where strucures do not have tieFormats should have matchUps added
33383
33375
  drawDefinition.tieFormat = prunedTieFormat;
33384
33376
  try {
33385
- for (var _v = __values((_l = drawDefinition.structures) !== null && _l !== void 0 ? _l : []), _w = _v.next(); !_w.done; _w = _v.next()) {
33386
- var structure_2 = _w.value;
33377
+ for (var _w = __values((_m = drawDefinition.structures) !== null && _m !== void 0 ? _m : []), _x = _w.next(); !_x.done; _x = _w.next()) {
33378
+ var structure_2 = _x.value;
33387
33379
  var result_3 = updateStructureMatchUps({
33388
33380
  updateInProgressMatchUps: updateInProgressMatchUps,
33389
33381
  collectionDefinition: collectionDefinition,
@@ -33398,7 +33390,7 @@ function addCollectionDefinition$1(_a) {
33398
33390
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
33399
33391
  finally {
33400
33392
  try {
33401
- if (_w && !_w.done && (_e = _v.return)) _e.call(_v);
33393
+ if (_x && !_x.done && (_e = _w.return)) _e.call(_w);
33402
33394
  }
33403
33395
  finally { if (e_3) throw e_3.error; }
33404
33396
  }
@@ -33414,7 +33406,7 @@ function addCollectionDefinition$1(_a) {
33414
33406
  else {
33415
33407
  return { error: MISSING_DRAW_DEFINITION };
33416
33408
  }
33417
- if ((_m = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _m === void 0 ? void 0 : _m[TIE_FORMAT_MODIFICATIONS]) {
33409
+ if ((_o = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _o === void 0 ? void 0 : _o[TIE_FORMAT_MODIFICATIONS]) {
33418
33410
  var auditData = definedAttributes({
33419
33411
  drawId: drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawId,
33420
33412
  collectionDefinition: collectionDefinition,
@@ -33741,10 +33733,8 @@ function addCollectionGroup$1(_a) {
33741
33733
  var collectionId = collectionDefinition.collectionId, collectionGroupNumber_1 = collectionDefinition.collectionGroupNumber;
33742
33734
  if (collectionGroupNumber_1 && collectionIds.includes(collectionId))
33743
33735
  return decorateResult({
33744
- result: {
33745
- error: INVALID_VALUES,
33746
- info: 'collectionIds cannot be part of other collectionGroups',
33747
- },
33736
+ info: 'collectionIds cannot be part of other collectionGroups',
33737
+ result: { error: INVALID_VALUES },
33748
33738
  stack: stack,
33749
33739
  });
33750
33740
  // TODO: calculate the total value of the collectionDefinition
@@ -33797,7 +33787,7 @@ function addCollectionGroup(params) {
33797
33787
  function modifyTieFormat$1(_a) {
33798
33788
  var e_1, _b, e_2, _c, e_3, _d;
33799
33789
  var _e = _a.updateInProgressMatchUps, updateInProgressMatchUps = _e === void 0 ? false : _e, tieFormatComparison = _a.tieFormatComparison, modifiedTieFormat = _a.modifiedTieFormat, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structureId = _a.structureId, matchUpId = _a.matchUpId, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
33800
- var stack = 'updateTieFormat';
33790
+ var stack = 'modifyTieFormat';
33801
33791
  if (!validateTieFormat({ tieFormat: modifiedTieFormat }).valid) {
33802
33792
  return decorateResult({
33803
33793
  result: { error: INVALID_TIE_FORMAT },
@@ -33824,10 +33814,15 @@ function modifyTieFormat$1(_a) {
33824
33814
  return decorateResult({
33825
33815
  context: { invalid: comparison.invalid },
33826
33816
  result: { error: INVALID_TIE_FORMAT },
33817
+ stack: stack,
33827
33818
  });
33828
33819
  }
33829
33820
  if (!(comparison === null || comparison === void 0 ? void 0 : comparison.different)) {
33830
- return decorateResult({ result: __assign({}, SUCCESS), info: 'Nothing to do' });
33821
+ return decorateResult({
33822
+ result: __assign({}, SUCCESS),
33823
+ info: 'Nothing to do',
33824
+ stack: stack,
33825
+ });
33831
33826
  }
33832
33827
  var existingCollectionIds = tieFormat.collectionDefinitions.map(function (_a) {
33833
33828
  var collectionId = _a.collectionId;
@@ -46340,17 +46335,14 @@ function positionByes(_a) {
46340
46335
 
46341
46336
  function positionQualifiers(params) {
46342
46337
  var e_1, _a;
46343
- var structure = params.structure, structureId = params.structureId; // participants is being passed in
46344
- if (!structure)
46345
- (structure = findStructure(params).structure);
46346
- if (!structureId)
46347
- (structureId = structure.structureId);
46338
+ var _b;
46339
+ var structure = (_b = params.structure) !== null && _b !== void 0 ? _b : findStructure(params).structure;
46348
46340
  var stack = 'positionQualifiers';
46349
46341
  var qualifierDrawPositions = [];
46350
46342
  if (structure.stage === CONSOLATION) {
46351
46343
  return decorateResult({ result: { error: INVALID_STAGE }, stack: stack });
46352
46344
  }
46353
- var _b = getQualifiersData(params), unplacedRoundQualifierCounts = _b.unplacedRoundQualifierCounts, positionAssignments = _b.positionAssignments, roundDrawPositions = _b.roundDrawPositions;
46345
+ var _c = getQualifiersData(params), unplacedRoundQualifierCounts = _c.unplacedRoundQualifierCounts, positionAssignments = _c.positionAssignments, roundDrawPositions = _c.roundDrawPositions;
46354
46346
  var _loop_1 = function (roundNumber) {
46355
46347
  var unfilledDrawPositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) {
46356
46348
  return (roundDrawPositions[roundNumber].includes(assignment.drawPosition) &&
@@ -46377,8 +46369,8 @@ function positionQualifiers(params) {
46377
46369
  });
46378
46370
  };
46379
46371
  try {
46380
- for (var _c = __values(Object.keys(unplacedRoundQualifierCounts)), _d = _c.next(); !_d.done; _d = _c.next()) {
46381
- var roundNumber = _d.value;
46372
+ for (var _d = __values(Object.keys(unplacedRoundQualifierCounts)), _e = _d.next(); !_e.done; _e = _d.next()) {
46373
+ var roundNumber = _e.value;
46382
46374
  var state_1 = _loop_1(roundNumber);
46383
46375
  if (typeof state_1 === "object")
46384
46376
  return state_1.value;
@@ -46387,7 +46379,7 @@ function positionQualifiers(params) {
46387
46379
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
46388
46380
  finally {
46389
46381
  try {
46390
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
46382
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
46391
46383
  }
46392
46384
  finally { if (e_1) throw e_1.error; }
46393
46385
  }
@@ -46986,7 +46978,7 @@ function generateAndPopulatePlayoffStructures(params) {
46986
46978
  drawDefinition: drawDefinition,
46987
46979
  }).structure;
46988
46980
  if (!structure)
46989
- return decorateResult({ result: { error: STRUCTURE_NOT_FOUND } });
46981
+ return decorateResult({ result: { error: STRUCTURE_NOT_FOUND }, stack: stack });
46990
46982
  if (structure.structureType === CONTAINER || structure.structures) {
46991
46983
  return generateAndPopulateRRplayoffStructures(__assign(__assign(__assign({ sourceStructureId: structure.structureId }, params), availabilityResult), { drawDefinition: drawDefinition }));
46992
46984
  }
@@ -47779,11 +47771,11 @@ function attachStructures$1(_a) {
47779
47771
  var _b;
47780
47772
  var _c, _d, _e;
47781
47773
  var matchUpModifications = _a.matchUpModifications, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structures = _a.structures, _f = _a.links, links = _f === void 0 ? [] : _f, event = _a.event;
47774
+ var stack = 'attachStructures';
47782
47775
  if (!drawDefinition)
47783
47776
  return { error: MISSING_DRAW_DEFINITION };
47784
47777
  if (!Array.isArray(structures) || !Array.isArray(links))
47785
- return decorateResult({ result: { error: INVALID_VALUES } });
47786
- var stack = 'attachStructures';
47778
+ return decorateResult({ result: { error: INVALID_VALUES }, stack: stack });
47787
47779
  var linkHash = function (link) {
47788
47780
  var _a;
47789
47781
  return [
@@ -48793,7 +48785,9 @@ function positionParticipantAction(params) {
48793
48785
  _b);
48794
48786
  addPositionActionTelemetry({ drawDefinition: drawDefinition, positionAction: positionAction });
48795
48787
  return decorateResult({
48796
- result: __assign(__assign({}, SUCCESS), { context: { removedParticipantId: removedParticipantId }, stack: stack }),
48788
+ context: { removedParticipantId: removedParticipantId },
48789
+ result: __assign({}, SUCCESS),
48790
+ stack: stack,
48797
48791
  });
48798
48792
  }
48799
48793
  }
@@ -49643,8 +49637,8 @@ function addEventEntries(params) {
49643
49637
  (!Array.isArray(extensions) || !extensions.every(isValidExtension))) ||
49644
49638
  (extension && !isValidExtension({ extension: extension }))) {
49645
49639
  return decorateResult({
49646
- result: { error: INVALID_VALUES },
49647
49640
  context: definedAttributes({ extension: extension, extensions: extensions }),
49641
+ result: { error: INVALID_VALUES },
49648
49642
  info: 'Invalid extension(s)',
49649
49643
  stack: stack,
49650
49644
  });
@@ -49769,8 +49763,8 @@ function addEventEntries(params) {
49769
49763
  var invalidParticipantIds = validParticipantIds.length !== participantIds.length;
49770
49764
  if (invalidParticipantIds)
49771
49765
  return decorateResult({
49772
- result: { error: INVALID_PARTICIPANT_IDS },
49773
49766
  context: { misMatchedGender: misMatchedGender, gender: event.gender },
49767
+ result: { error: INVALID_PARTICIPANT_IDS },
49774
49768
  stack: stack,
49775
49769
  });
49776
49770
  if (autoEntryPositions) {
@@ -51503,26 +51497,24 @@ function enableTieAutoCalc$1(_a) {
51503
51497
 
51504
51498
  function setOrderOfFinish$1(_a) {
51505
51499
  var e_1, _b;
51506
- var _c;
51500
+ var _c, _d;
51507
51501
  var drawDefinition = _a.drawDefinition, finishingOrder = _a.finishingOrder;
51508
51502
  if (!drawDefinition)
51509
51503
  return { error: MISSING_DRAW_DEFINITION };
51510
51504
  var stack = 'setOrderOfFinish';
51511
51505
  if (!Array.isArray(finishingOrder))
51512
51506
  return decorateResult({
51513
- result: {
51514
- error: INVALID_VALUES,
51515
- },
51516
51507
  info: mustBeAnArray('finishingOrder'),
51508
+ result: { error: INVALID_VALUES },
51517
51509
  stack: stack,
51518
51510
  });
51519
- var _d = getDrawMatchUps({
51511
+ var _e = getDrawMatchUps({
51520
51512
  inContext: true,
51521
51513
  drawDefinition: drawDefinition,
51522
- }), completedMatchUps = _d.completedMatchUps, matchUpsMap = _d.matchUpsMap;
51523
- var matchUpIds = (completedMatchUps === null || completedMatchUps === void 0 ? void 0 : completedMatchUps.map(getMatchUpId)) || [];
51514
+ }), completedMatchUps = _e.completedMatchUps, matchUpsMap = _e.matchUpsMap;
51515
+ var matchUpIds = (_c = completedMatchUps === null || completedMatchUps === void 0 ? void 0 : completedMatchUps.map(getMatchUpId)) !== null && _c !== void 0 ? _c : [];
51524
51516
  var targetMatchUpIds = finishingOrder.map(getMatchUpId);
51525
- var _e = (completedMatchUps || [])
51517
+ var _f = (completedMatchUps !== null && completedMatchUps !== void 0 ? completedMatchUps : [])
51526
51518
  .filter(function (_a) {
51527
51519
  var matchUpId = _a.matchUpId;
51528
51520
  return targetMatchUpIds.includes(matchUpId);
@@ -51543,17 +51535,15 @@ function setOrderOfFinish$1(_a) {
51543
51535
  roundNumbers: [],
51544
51536
  structureIds: [],
51545
51537
  matchUpTieIds: [],
51546
- }), matchUpTypes = _e.matchUpTypes, roundNumbers = _e.roundNumbers, structureIds = _e.structureIds, matchUpTieIds = _e.matchUpTieIds;
51538
+ }), matchUpTypes = _f.matchUpTypes, roundNumbers = _f.roundNumbers, structureIds = _f.structureIds, matchUpTieIds = _f.matchUpTieIds;
51547
51539
  // targeted matchUps must all be of the same matchUpType and have the same roundNumber and structureId
51548
51540
  if (matchUpTypes.length > 1 ||
51549
51541
  matchUpTieIds.length > 1 ||
51550
51542
  roundNumbers.length > 1 ||
51551
51543
  structureIds.length > 1) {
51552
51544
  return decorateResult({
51553
- result: {
51554
- error: INVALID_VALUES,
51555
- },
51556
51545
  info: 'matchUpType, structureId and roundNumber must be equivalent',
51546
+ result: { error: INVALID_VALUES },
51557
51547
  stack: stack,
51558
51548
  });
51559
51549
  }
@@ -51596,8 +51586,8 @@ function setOrderOfFinish$1(_a) {
51596
51586
  });
51597
51587
  try {
51598
51588
  // throw an error if an existing matchUp has an invalid orderOfFinish value
51599
- for (var _f = __values(otherCohortMatchUps || []), _g = _f.next(); !_g.done; _g = _f.next()) {
51600
- var matchUp = _g.value;
51589
+ for (var _g = __values(otherCohortMatchUps !== null && otherCohortMatchUps !== void 0 ? otherCohortMatchUps : []), _h = _g.next(); !_h.done; _h = _g.next()) {
51590
+ var matchUp = _h.value;
51601
51591
  var orderOfFinish = (matchUp || {}).orderOfFinish;
51602
51592
  if (orderOfFinish) {
51603
51593
  if (!isConvertableInteger(orderOfFinish))
@@ -51613,7 +51603,7 @@ function setOrderOfFinish$1(_a) {
51613
51603
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
51614
51604
  finally {
51615
51605
  try {
51616
- if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
51606
+ if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
51617
51607
  }
51618
51608
  finally { if (e_1) throw e_1.error; }
51619
51609
  }
@@ -51621,10 +51611,8 @@ function setOrderOfFinish$1(_a) {
51621
51611
  if (uniqueValues(orderOfFinishValues).length !== orderOfFinishValues.length ||
51622
51612
  Math.max.apply(Math, __spreadArray([], __read(orderOfFinishValues), false)) > orderOfFinishValues.length) {
51623
51613
  return decorateResult({
51624
- result: {
51625
- error: INVALID_VALUES,
51626
- },
51627
51614
  info: 'Values not unique or greater than expected number of values',
51615
+ result: { error: INVALID_VALUES },
51628
51616
  stack: stack,
51629
51617
  });
51630
51618
  }
@@ -51639,7 +51627,7 @@ function setOrderOfFinish$1(_a) {
51639
51627
  if (result.error)
51640
51628
  return decorateResult({ result: result, stack: stack });
51641
51629
  // apply the new values to targeted matchUps
51642
- (_c = result.completedMatchUps) === null || _c === void 0 ? void 0 : _c.forEach(function (matchUp) { return (matchUp.orderOfFinish = valuesMap[matchUp.matchUpId]); });
51630
+ (_d = result.completedMatchUps) === null || _d === void 0 ? void 0 : _d.forEach(function (matchUp) { return (matchUp.orderOfFinish = valuesMap[matchUp.matchUpId]); });
51643
51631
  }
51644
51632
  return __assign({}, SUCCESS);
51645
51633
  }
@@ -52546,7 +52534,7 @@ function getValidQualifiersAction(_a) {
52546
52534
  }
52547
52535
  return { validAssignmentActions: validAssignmentActions, sourceStructureIds: sourceStructureIds };
52548
52536
  }
52549
- /*
52537
+ /**
52550
52538
  if (sourceStructureIds.length > 1)
52551
52539
  return decorateResult({
52552
52540
  stack: 'getValidQualifiersSaction',
@@ -54646,10 +54634,8 @@ function addIndividualParticipantIds(_a) {
54646
54634
  if ((groupingParticipant === null || groupingParticipant === void 0 ? void 0 : groupingParticipant.participantType) &&
54647
54635
  ![TEAM, GROUP].includes(groupingParticipant.participantType)) {
54648
54636
  return decorateResult({
54649
- result: {
54650
- error: INVALID_PARTICIPANT_TYPE,
54651
- },
54652
54637
  context: { participantType: groupingParticipant.participantType },
54638
+ result: { error: INVALID_PARTICIPANT_TYPE },
54653
54639
  stack: stack,
54654
54640
  });
54655
54641
  }
@@ -56626,7 +56612,7 @@ function getTieMatchUpContext(_a) {
56626
56612
  */
56627
56613
  function assignTieMatchUpParticipantId(params) {
56628
56614
  var e_1, _a;
56629
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
56615
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
56630
56616
  var matchUpContext = getTieMatchUpContext(params);
56631
56617
  if (matchUpContext.error)
56632
56618
  return matchUpContext;
@@ -56653,12 +56639,12 @@ function assignTieMatchUpParticipantId(params) {
56653
56639
  teamParticipantId ||
56654
56640
  (params.sideNumber &&
56655
56641
  ((_d = (_c = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _c === void 0 ? void 0 : _c.find(function (side) { return side.sideNumber === params.sideNumber; })) === null || _d === void 0 ? void 0 : _d.participantId));
56656
- var _q = __read(getTournamentParticipants({
56642
+ var _r = __read(getTournamentParticipants({
56657
56643
  tournamentRecord: tournamentRecord,
56658
56644
  participantFilters: {
56659
56645
  participantIds: [participantId],
56660
56646
  },
56661
- }).tournamentParticipants, 1), participantToAssign = _q[0];
56647
+ }).tournamentParticipants, 1), participantToAssign = _r[0];
56662
56648
  if (!participantToAssign) {
56663
56649
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack: stack });
56664
56650
  }
@@ -56726,11 +56712,10 @@ function assignTieMatchUpParticipantId(params) {
56726
56712
  }
56727
56713
  var dualMatchUpSide = (_m = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (side) { return side.sideNumber === sideNumber; });
56728
56714
  var tieMatchUpSide = (_o = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _o === void 0 ? void 0 : _o.find(function (side) { return side.sideNumber === sideNumber; });
56729
- var lineUp = (dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.lineUp) ||
56730
- ((_p = getTeamLineUp({
56731
- participantId: teamParticipantId,
56732
- drawDefinition: drawDefinition,
56733
- })) === null || _p === void 0 ? void 0 : _p.lineUp);
56715
+ var lineUp = (_p = dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.lineUp) !== null && _p !== void 0 ? _p : (_q = getTeamLineUp({
56716
+ participantId: teamParticipantId,
56717
+ drawDefinition: drawDefinition,
56718
+ })) === null || _q === void 0 ? void 0 : _q.lineUp;
56734
56719
  var targetAssignments = lineUp === null || lineUp === void 0 ? void 0 : lineUp.filter(function (participantAssignment) {
56735
56720
  var _a;
56736
56721
  return (_a = participantAssignment.collectionAssignments) === null || _a === void 0 ? void 0 : _a.find(function (assignment) {
@@ -59551,8 +59536,8 @@ function deleteDrawDefinitions(_a) {
59551
59536
  var auditTrail = [];
59552
59537
  if (!(event === null || event === void 0 ? void 0 : event.drawDefinitions))
59553
59538
  return decorateResult({
59554
- result: __assign({}, SUCCESS),
59555
59539
  info: 'event has no drawDefinition',
59540
+ result: __assign({}, SUCCESS),
59556
59541
  stack: stack,
59557
59542
  });
59558
59543
  var eventDrawIds = event.drawDefinitions.map(function (_a) {
@@ -59565,8 +59550,8 @@ function deleteDrawDefinitions(_a) {
59565
59550
  drawIds = drawIds.filter(function (drawId) { return eventDrawIds.includes(drawId); });
59566
59551
  if (!drawIds.length)
59567
59552
  return decorateResult({
59568
- result: __assign({}, SUCCESS),
59569
59553
  info: 'nothing to do; no matching drawIds in event.',
59554
+ result: __assign({}, SUCCESS),
59570
59555
  stack: stack,
59571
59556
  });
59572
59557
  var flightProfile = makeDeepCopy(getFlightProfile({ event: event }).flightProfile, false, true);
@@ -62623,6 +62608,7 @@ function addVoluntaryConsolationStructure(params) {
62623
62608
 
62624
62609
  function prepareStage(params) {
62625
62610
  var _a;
62611
+ var stack = 'prepareStage';
62626
62612
  var seedsCount = params.seedsCount;
62627
62613
  var preparedStructureIds = params.preparedStructureIds || [];
62628
62614
  var provisionalPositioning = params.provisionalPositioning, inContextDrawMatchUps = params.inContextDrawMatchUps, tournamentRecord = params.tournamentRecord, appliedPolicies = params.appliedPolicies, qualifyingOnly = params.qualifyingOnly, drawDefinition = params.drawDefinition, seedingProfile = params.seedingProfile, participants = params.participants, matchUpsMap = params.matchUpsMap, automated = params.automated, placeByes = params.placeByes, drawType = params.drawType, drawSize = params.drawSize, entries = params.entries, event = params.event, _b = params.enforcePolicyLimits, enforcePolicyLimits = _b === void 0 ? true : _b, seedAssignmentProfile = params.seedAssignmentProfile, // mainly used by mocksEngine for scenario testing
@@ -62661,7 +62647,7 @@ function prepareStage(params) {
62661
62647
  return !preparedStructureIds.includes(structureId);
62662
62648
  });
62663
62649
  if (!structure)
62664
- return decorateResult({ result: { error: STRUCTURE_NOT_FOUND } });
62650
+ return decorateResult({ result: { error: STRUCTURE_NOT_FOUND }, stack: stack });
62665
62651
  var structureId = structure === null || structure === void 0 ? void 0 : structure.structureId;
62666
62652
  var seedBlockInfo = structure
62667
62653
  ? getValidSeedBlocks({
@@ -62798,7 +62784,7 @@ function prepareStage(params) {
62798
62784
  positionAssignments = result === null || result === void 0 ? void 0 : result.positionAssignments;
62799
62785
  positioningReport = result === null || result === void 0 ? void 0 : result.positioningReport;
62800
62786
  if (result.error) {
62801
- return decorateResult({ result: result, stack: 'prepareStage' });
62787
+ return decorateResult({ result: result, stack: stack });
62802
62788
  }
62803
62789
  }
62804
62790
  return {
@@ -62988,10 +62974,8 @@ function generateDrawDefinition(params) {
62988
62974
  if (policyDefinitions) {
62989
62975
  if (typeof policyDefinitions !== 'object') {
62990
62976
  return decorateResult({
62991
- result: {
62992
- info: 'policyDefinitions must be an object',
62993
- error: INVALID_VALUES,
62994
- },
62977
+ info: 'policyDefinitions must be an object',
62978
+ result: { error: INVALID_VALUES },
62995
62979
  stack: stack,
62996
62980
  });
62997
62981
  }
@@ -63240,8 +63224,9 @@ function generateDrawDefinition(params) {
63240
63224
  var roundTargetProfile = _34.value;
63241
63225
  if (!Array.isArray(roundTargetProfile.structureProfiles))
63242
63226
  return decorateResult({
63243
- result: { error: MISSING_VALUE },
63244
63227
  info: mustBeAnArray('structureProfiles'),
63228
+ result: { error: MISSING_VALUE },
63229
+ stack: stack,
63245
63230
  });
63246
63231
  roundTarget = roundTargetProfile.roundTarget || roundTarget;
63247
63232
  var sortedStructureProfiles = ((_21 = roundTargetProfile.structureProfiles) === null || _21 === void 0 ? void 0 : _21.sort(sequenceSort)) || [];
@@ -63498,26 +63483,26 @@ function enableTieAutoCalc(params) {
63498
63483
  }
63499
63484
 
63500
63485
  function modifyEvent(_a) {
63501
- var _b;
63486
+ var _b, _c, _d, _e, _f;
63502
63487
  var tournamentRecord = _a.tournamentRecord, eventUpdates = _a.eventUpdates, eventId = _a.eventId, event = _a.event;
63503
63488
  if (!tournamentRecord)
63504
63489
  return { error: MISSING_TOURNAMENT_RECORD };
63505
63490
  if (!isString(eventId) || !isObject(eventUpdates))
63506
63491
  return { error: INVALID_VALUES };
63507
- var enteredParticipantIds = ((_b = event === null || event === void 0 ? void 0 : event.entries) === null || _b === void 0 ? void 0 : _b.filter(function (_a) {
63492
+ var enteredParticipantIds = (_c = (_b = event === null || event === void 0 ? void 0 : event.entries) === null || _b === void 0 ? void 0 : _b.filter(function (_a) {
63508
63493
  var entryStatus = _a.entryStatus;
63509
63494
  var status = entryStatus;
63510
63495
  return __spreadArray(__spreadArray([], __read(STRUCTURE_SELECTED_STATUSES), false), [ALTERNATE], false).includes(status);
63511
63496
  }).map(function (_a) {
63512
63497
  var participantId = _a.participantId;
63513
63498
  return participantId;
63514
- })) || [];
63499
+ })) !== null && _c !== void 0 ? _c : [];
63515
63500
  var enteredParticipants = enteredParticipantIds
63516
- ? getParticipants$1({
63501
+ ? (_d = getParticipants$1({
63517
63502
  participantFilters: { participantIds: enteredParticipantIds },
63518
63503
  withIndividualParticipants: true,
63519
63504
  tournamentRecord: tournamentRecord,
63520
- }).participants || []
63505
+ }).participants) !== null && _d !== void 0 ? _d : []
63521
63506
  : [];
63522
63507
  var genderAccumulator = [];
63523
63508
  var enteredParticipantTypes = enteredParticipants.reduce(function (types, participant) {
@@ -63532,7 +63517,7 @@ function modifyEvent(_a) {
63532
63517
  }, []);
63533
63518
  var enteredParticipantGenders = unique(genderAccumulator);
63534
63519
  var validGender = !enteredParticipantGenders.length ||
63535
- [MIXED, ANY].includes(eventUpdates.gender || '') ||
63520
+ [MIXED, ANY].includes((_e = eventUpdates.gender) !== null && _e !== void 0 ? _e : '') ||
63536
63521
  (enteredParticipantGenders.length === 1 &&
63537
63522
  enteredParticipantGenders[0] === eventUpdates.gender);
63538
63523
  if (eventUpdates.gender && !validGender)
@@ -63547,14 +63532,14 @@ function modifyEvent(_a) {
63547
63532
  SINGLES,
63548
63533
  TEAM$1,
63549
63534
  ];
63550
- var validEventType = validEventTypes.includes(eventUpdates.eventType || '');
63535
+ var validEventType = validEventTypes.includes((_f = eventUpdates.eventType) !== null && _f !== void 0 ? _f : '');
63551
63536
  if (eventUpdates.eventType && !validEventType)
63552
63537
  return decorateResult({
63553
63538
  context: { participantType: eventUpdates.eventType },
63554
63539
  result: { error: INVALID_VALUES },
63555
63540
  });
63556
63541
  if (eventUpdates.eventType)
63557
- event.eventType === eventUpdates.eventType;
63542
+ event.eventType = eventUpdates.eventType;
63558
63543
  if (eventUpdates.eventName)
63559
63544
  event.eventName = eventUpdates.eventName;
63560
63545
  if (eventUpdates.gender)