tods-competition-factory 1.8.17 → 1.8.19

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.
@@ -2905,7 +2905,7 @@ var matchUpFormatCode = {
2905
2905
  };
2906
2906
 
2907
2907
  function factoryVersion() {
2908
- return '1.8.17';
2908
+ return '1.8.19';
2909
2909
  }
2910
2910
 
2911
2911
  function getObjectTieFormat(obj) {
@@ -3164,10 +3164,50 @@ function getCategoryAgeDetails(params) {
3164
3164
  return result;
3165
3165
  }
3166
3166
 
3167
+ function decorateResult(_a) {
3168
+ var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
3169
+ if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
3170
+ result.stack = [];
3171
+ if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
3172
+ result.stack.push(stack);
3173
+ }
3174
+ if (result && info) {
3175
+ result.info = info;
3176
+ }
3177
+ if (result && typeof context === 'object' && Object.keys(context).length) {
3178
+ Object.assign(result, definedAttributes(context));
3179
+ }
3180
+ if (result && !(result === null || result === void 0 ? void 0 : result.error) && !(result === null || result === void 0 ? void 0 : result.success)) {
3181
+ Object.assign(result, __assign({}, SUCCESS));
3182
+ }
3183
+ return result !== null && result !== void 0 ? result : { success: true };
3184
+ }
3185
+
3186
+ function validateCategory(_a) {
3187
+ var category = _a.category;
3188
+ if (!isObject(category))
3189
+ return { error: INVALID_VALUES };
3190
+ var categoryDetails = getCategoryAgeDetails({ category: category });
3191
+ if (categoryDetails.error)
3192
+ return { error: categoryDetails };
3193
+ var ratingMax = category.ratingMax, ratingMin = category.ratingMin;
3194
+ if (ratingMax && !isNumeric(ratingMax))
3195
+ return decorateResult({
3196
+ result: { error: INVALID_VALUES },
3197
+ context: { ratingMax: ratingMax },
3198
+ });
3199
+ if (ratingMin && !isNumeric(ratingMin))
3200
+ return decorateResult({
3201
+ result: { error: INVALID_VALUES },
3202
+ context: { ratingMin: ratingMin },
3203
+ });
3204
+ return __assign({}, categoryDetails);
3205
+ }
3206
+
3167
3207
  function categoryCanContain(_a) {
3168
3208
  var childCategory = _a.childCategory, withDetails = _a.withDetails, category = _a.category;
3169
- var categoryDetails = getCategoryAgeDetails({ category: category });
3170
- var childCategoryDetails = getCategoryAgeDetails({
3209
+ var categoryDetails = validateCategory({ category: category });
3210
+ var childCategoryDetails = validateCategory({
3171
3211
  category: childCategory,
3172
3212
  });
3173
3213
  var invalidAgeMin = childCategoryDetails.ageMin &&
@@ -3188,17 +3228,40 @@ function categoryCanContain(_a) {
3188
3228
  categoryDetails.ageMinDate &&
3189
3229
  new Date(childCategoryDetails.ageMaxDate) <
3190
3230
  new Date(categoryDetails.ageMinDate);
3191
- var valid = !invalidAgeMax &&
3192
- !invalidAgeMin &&
3231
+ var ratingComparison = category.ratingType &&
3232
+ childCategory.ratingType &&
3233
+ category.ratingType === childCategory.ratingType;
3234
+ var invalidRatingRange = ratingComparison &&
3235
+ ((category.ratingMin &&
3236
+ childCategory.ratingMin &&
3237
+ childCategory.ratingMin < category.ratingMin) ||
3238
+ (category.ratingMax &&
3239
+ childCategory.ratingMax &&
3240
+ childCategory.ratingMax > category.ratingMax) ||
3241
+ (category.ratingMin &&
3242
+ childCategory.ratingMax &&
3243
+ childCategory.ratingMax < category.ratingMin) ||
3244
+ (category.ratingMax &&
3245
+ childCategory.ratingMin &&
3246
+ childCategory.ratingMin > category.ratingMax));
3247
+ var invalidBallType = category.ballType &&
3248
+ childCategory.ballType &&
3249
+ category.ballType !== childCategory.ballType;
3250
+ var valid = !invalidRatingRange &&
3193
3251
  !invalidAgeMinDate &&
3194
- !invalidAgeMaxDate;
3252
+ !invalidAgeMaxDate &&
3253
+ !invalidBallType &&
3254
+ !invalidAgeMax &&
3255
+ !invalidAgeMin;
3195
3256
  var ignoreFalse = true;
3196
3257
  var result = definedAttributes({
3197
- valid: valid,
3198
- invalidAgeMax: invalidAgeMax,
3199
- invalidAgeMin: invalidAgeMin,
3258
+ invalidRatingRange: invalidRatingRange,
3200
3259
  invalidAgeMinDate: invalidAgeMinDate,
3201
3260
  invalidAgeMaxDate: invalidAgeMaxDate,
3261
+ invalidBallType: invalidBallType,
3262
+ invalidAgeMax: invalidAgeMax,
3263
+ invalidAgeMin: invalidAgeMin,
3264
+ valid: valid,
3202
3265
  }, ignoreFalse);
3203
3266
  if (withDetails) {
3204
3267
  Object.assign(result, { categoryDetails: categoryDetails, childCategoryDetails: childCategoryDetails });
@@ -3210,25 +3273,6 @@ function mustBeAnArray(value) {
3210
3273
  return "".concat(value, " must be an array");
3211
3274
  }
3212
3275
 
3213
- function decorateResult(_a) {
3214
- var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
3215
- if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
3216
- result.stack = [];
3217
- if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
3218
- result.stack.push(stack);
3219
- }
3220
- if (result && info) {
3221
- result.info = info;
3222
- }
3223
- if (result && typeof context === 'object' && Object.keys(context).length) {
3224
- Object.assign(result, definedAttributes(context));
3225
- }
3226
- if (result && !(result === null || result === void 0 ? void 0 : result.error) && !(result === null || result === void 0 ? void 0 : result.success)) {
3227
- Object.assign(result, __assign({}, SUCCESS));
3228
- }
3229
- return result !== null && result !== void 0 ? result : { success: true };
3230
- }
3231
-
3232
3276
  var DrawTypeEnum;
3233
3277
  (function (DrawTypeEnum) {
3234
3278
  DrawTypeEnum["AdHoc"] = "AD_HOC";
@@ -5359,142 +5403,6 @@ function tallyParticipantResults(_a) {
5359
5403
  return result;
5360
5404
  }
5361
5405
 
5362
- function evaluateCollectionResult(_a) {
5363
- var collectionDefinition = _a.collectionDefinition, groupValueNumbers = _a.groupValueNumbers, groupValueGroups = _a.groupValueGroups, sideTieValues = _a.sideTieValues, tieMatchUps = _a.tieMatchUps;
5364
- var collectionMatchUps = tieMatchUps.filter(function (matchUp) { return matchUp.collectionId === collectionDefinition.collectionId; });
5365
- // keep track of the values derived from matchUps
5366
- var sideMatchUpValues = [0, 0];
5367
- // will be equivalent to sideMatchUpValues unless there is a collectionValue,
5368
- // in which case the sideMatchUpValues are used in comparision with winCriteria
5369
- var sideCollectionValues = [0, 0];
5370
- var allCollectionMatchUpsCompleted = collectionMatchUps.every(function (matchUp) {
5371
- return completedMatchUpStatuses.includes(matchUp.matchUpStatus);
5372
- });
5373
- var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionGroupNumber = collectionDefinition.collectionGroupNumber, collectionValue = collectionDefinition.collectionValue, matchUpValue = collectionDefinition.matchUpValue, winCriteria = collectionDefinition.winCriteria, scoreValue = collectionDefinition.scoreValue, setValue = collectionDefinition.setValue;
5374
- var belongsToValueGroup = collectionGroupNumber && groupValueNumbers.includes(collectionGroupNumber);
5375
- var sideWins = [0, 0];
5376
- collectionMatchUps.forEach(function (matchUp) {
5377
- if (matchUp.winningSide)
5378
- sideWins[matchUp.winningSide - 1] += 1;
5379
- });
5380
- if (isConvertableInteger(matchUpValue)) {
5381
- // if tiebreak set count as set value and game value
5382
- collectionMatchUps.forEach(function (matchUp) {
5383
- if (matchUp.winningSide) {
5384
- sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
5385
- }
5386
- });
5387
- }
5388
- else if (isConvertableInteger(setValue)) {
5389
- collectionMatchUps.forEach(function (matchUp) {
5390
- var _a, _b;
5391
- (_b = (_a = matchUp.score) === null || _a === void 0 ? void 0 : _a.sets) === null || _b === void 0 ? void 0 : _b.forEach(function (set) {
5392
- if (set.winningSide)
5393
- sideMatchUpValues[set.winningSide - 1] += setValue;
5394
- });
5395
- });
5396
- }
5397
- else if (isConvertableInteger(scoreValue)) {
5398
- collectionMatchUps.forEach(function (matchUp) {
5399
- var _a, _b;
5400
- (_b = (_a = matchUp.score) === null || _a === void 0 ? void 0 : _a.sets) === null || _b === void 0 ? void 0 : _b.forEach(function (set) {
5401
- var _a = set.side1TiebreakScore, side1TiebreakScore = _a === void 0 ? 0 : _a, _b = set.side2TiebreakScore, side2TiebreakScore = _b === void 0 ? 0 : _b, _c = set.side1Score, side1Score = _c === void 0 ? 0 : _c, _d = set.side2Score, side2Score = _d === void 0 ? 0 : _d;
5402
- if (matchUp.matchUpStatus === COMPLETED$1 ||
5403
- matchUp.winningSide ||
5404
- set.winningSide) {
5405
- if (side1Score || side2Score) {
5406
- sideMatchUpValues[0] += side1Score;
5407
- sideMatchUpValues[1] += side2Score;
5408
- }
5409
- else if ((side1TiebreakScore || side2TiebreakScore) &&
5410
- set.winningSide) {
5411
- sideMatchUpValues[set.winningSide - 1] += 1;
5412
- }
5413
- }
5414
- });
5415
- });
5416
- }
5417
- else if (Array.isArray(collectionValueProfiles)) {
5418
- // this must come last because it will be true for []
5419
- collectionMatchUps.forEach(function (matchUp) {
5420
- if (matchUp.winningSide) {
5421
- var collectionPosition = matchUp.collectionPosition;
5422
- var matchUpValue_1 = getCollectionPositionValue({
5423
- collectionDefinition: collectionDefinition,
5424
- collectionPosition: collectionPosition,
5425
- });
5426
- if (isConvertableInteger(matchUpValue_1)) {
5427
- sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue_1;
5428
- }
5429
- }
5430
- });
5431
- }
5432
- // processed separately so that setValue, scoreValue and collecitonValueProfile can be used in conjunction with collectionValue
5433
- if (isConvertableInteger(collectionValue)) {
5434
- var collectionWinningSide = void 0;
5435
- if (winCriteria === null || winCriteria === void 0 ? void 0 : winCriteria.aggregateValue) {
5436
- if (allCollectionMatchUpsCompleted) {
5437
- if (isConvertableInteger(matchUpValue || setValue || scoreValue) &&
5438
- sideMatchUpValues[0] !== sideMatchUpValues[1]) {
5439
- collectionWinningSide =
5440
- sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
5441
- }
5442
- else if (sideWins[0] !== sideWins[1]) {
5443
- collectionWinningSide = sideWins[0] > sideWins[1] ? 1 : 2;
5444
- }
5445
- }
5446
- }
5447
- else if (winCriteria === null || winCriteria === void 0 ? void 0 : winCriteria.valueGoal) {
5448
- collectionWinningSide = sideMatchUpValues.reduce(function (winningSide, side, i) {
5449
- return side >= winCriteria.valueGoal ? i + 1 : winningSide;
5450
- }, 0);
5451
- }
5452
- else {
5453
- var winGoal_1 = Math.floor(collectionDefinition.matchUpCount / 2) + 1;
5454
- collectionWinningSide = sideWins.reduce(function (winningSide, side, i) {
5455
- return side >= winGoal_1 ? i + 1 : winningSide;
5456
- }, 0);
5457
- }
5458
- if (collectionWinningSide) {
5459
- if (belongsToValueGroup) {
5460
- groupValueGroups[collectionGroupNumber].values[collectionWinningSide - 1] += collectionValue;
5461
- }
5462
- else {
5463
- sideCollectionValues[collectionWinningSide - 1] += collectionValue;
5464
- }
5465
- }
5466
- }
5467
- else {
5468
- if (belongsToValueGroup) {
5469
- groupValueGroups[collectionGroupNumber].values[0] +=
5470
- sideMatchUpValues[0] || 0;
5471
- groupValueGroups[collectionGroupNumber].values[1] +=
5472
- sideMatchUpValues[1] || 0;
5473
- }
5474
- else {
5475
- sideCollectionValues = sideMatchUpValues;
5476
- }
5477
- }
5478
- if (!belongsToValueGroup) {
5479
- sideCollectionValues.forEach(function (sideCollectionValue, i) { return (sideTieValues[i] += sideCollectionValue || 0); });
5480
- }
5481
- else {
5482
- groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
5483
- groupValueGroups[collectionGroupNumber].sideWins[1] += sideWins[1] || 0;
5484
- groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted =
5485
- groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted &&
5486
- allCollectionMatchUpsCompleted;
5487
- groupValueGroups[collectionGroupNumber].matchUpsCount +=
5488
- collectionMatchUps.length;
5489
- }
5490
- }
5491
- function getCollectionPositionValue(_a) {
5492
- var collectionDefinition = _a.collectionDefinition, collectionPosition = _a.collectionPosition;
5493
- var collectionValueProfiles = collectionDefinition.collectionValueProfiles || [];
5494
- var profile = collectionValueProfiles === null || collectionValueProfiles === void 0 ? void 0 : collectionValueProfiles.find(function (profile) { return profile.collectionPosition === collectionPosition; });
5495
- return profile === null || profile === void 0 ? void 0 : profile.matchUpValue;
5496
- }
5497
-
5498
5406
  var APPLIED_POLICIES = 'appliedPolicies';
5499
5407
  var AUDIT_POSITION_ACTIONS = 'positionActions';
5500
5408
  var CONTEXT = 'context';
@@ -10007,11 +9915,13 @@ function getAllStructureMatchUps(_a) {
10007
9915
  /*
10008
9916
  public version of findMatchUp
10009
9917
  */
10010
- function publicFindMatchUp$1(params) {
9918
+ function publicFindDrawMatchUp(params) {
10011
9919
  Object.assign(params, { inContext: true });
10012
- return { matchUp: makeDeepCopy(findMatchUp$1(params).matchUp, false, true) };
9920
+ return {
9921
+ matchUp: makeDeepCopy(findDrawMatchUp(params).matchUp, false, true),
9922
+ };
10013
9923
  }
10014
- function findMatchUp$1(_a) {
9924
+ function findDrawMatchUp(_a) {
10015
9925
  var e_1, _b;
10016
9926
  var tournamentParticipants = _a.tournamentParticipants, afterRecoveryTimes = _a.afterRecoveryTimes, contextContent = _a.contextContent, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, matchUpsMap = _a.matchUpsMap, matchUpId = _a.matchUpId, inContext = _a.inContext, context = _a.context, event = _a.event;
10017
9927
  if (!drawDefinition)
@@ -10053,6 +9963,142 @@ function findMatchUp$1(_a) {
10053
9963
  return { error: MATCHUP_NOT_FOUND };
10054
9964
  }
10055
9965
 
9966
+ function evaluateCollectionResult(_a) {
9967
+ var collectionDefinition = _a.collectionDefinition, groupValueNumbers = _a.groupValueNumbers, groupValueGroups = _a.groupValueGroups, sideTieValues = _a.sideTieValues, tieMatchUps = _a.tieMatchUps;
9968
+ var collectionMatchUps = tieMatchUps.filter(function (matchUp) { return matchUp.collectionId === collectionDefinition.collectionId; });
9969
+ // keep track of the values derived from matchUps
9970
+ var sideMatchUpValues = [0, 0];
9971
+ // will be equivalent to sideMatchUpValues unless there is a collectionValue,
9972
+ // in which case the sideMatchUpValues are used in comparision with winCriteria
9973
+ var sideCollectionValues = [0, 0];
9974
+ var allCollectionMatchUpsCompleted = collectionMatchUps.every(function (matchUp) {
9975
+ return completedMatchUpStatuses.includes(matchUp.matchUpStatus);
9976
+ });
9977
+ var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionGroupNumber = collectionDefinition.collectionGroupNumber, collectionValue = collectionDefinition.collectionValue, matchUpValue = collectionDefinition.matchUpValue, winCriteria = collectionDefinition.winCriteria, scoreValue = collectionDefinition.scoreValue, setValue = collectionDefinition.setValue;
9978
+ var belongsToValueGroup = collectionGroupNumber && groupValueNumbers.includes(collectionGroupNumber);
9979
+ var sideWins = [0, 0];
9980
+ collectionMatchUps.forEach(function (matchUp) {
9981
+ if (matchUp.winningSide)
9982
+ sideWins[matchUp.winningSide - 1] += 1;
9983
+ });
9984
+ if (isConvertableInteger(matchUpValue)) {
9985
+ // if tiebreak set count as set value and game value
9986
+ collectionMatchUps.forEach(function (matchUp) {
9987
+ if (matchUp.winningSide) {
9988
+ sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
9989
+ }
9990
+ });
9991
+ }
9992
+ else if (isConvertableInteger(setValue)) {
9993
+ collectionMatchUps.forEach(function (matchUp) {
9994
+ var _a, _b;
9995
+ (_b = (_a = matchUp.score) === null || _a === void 0 ? void 0 : _a.sets) === null || _b === void 0 ? void 0 : _b.forEach(function (set) {
9996
+ if (set.winningSide)
9997
+ sideMatchUpValues[set.winningSide - 1] += setValue;
9998
+ });
9999
+ });
10000
+ }
10001
+ else if (isConvertableInteger(scoreValue)) {
10002
+ collectionMatchUps.forEach(function (matchUp) {
10003
+ var _a, _b;
10004
+ (_b = (_a = matchUp.score) === null || _a === void 0 ? void 0 : _a.sets) === null || _b === void 0 ? void 0 : _b.forEach(function (set) {
10005
+ var _a = set.side1TiebreakScore, side1TiebreakScore = _a === void 0 ? 0 : _a, _b = set.side2TiebreakScore, side2TiebreakScore = _b === void 0 ? 0 : _b, _c = set.side1Score, side1Score = _c === void 0 ? 0 : _c, _d = set.side2Score, side2Score = _d === void 0 ? 0 : _d;
10006
+ if (matchUp.matchUpStatus === COMPLETED$1 ||
10007
+ matchUp.winningSide ||
10008
+ set.winningSide) {
10009
+ if (side1Score || side2Score) {
10010
+ sideMatchUpValues[0] += side1Score;
10011
+ sideMatchUpValues[1] += side2Score;
10012
+ }
10013
+ else if ((side1TiebreakScore || side2TiebreakScore) &&
10014
+ set.winningSide) {
10015
+ sideMatchUpValues[set.winningSide - 1] += 1;
10016
+ }
10017
+ }
10018
+ });
10019
+ });
10020
+ }
10021
+ else if (Array.isArray(collectionValueProfiles)) {
10022
+ // this must come last because it will be true for []
10023
+ collectionMatchUps.forEach(function (matchUp) {
10024
+ if (matchUp.winningSide) {
10025
+ var collectionPosition = matchUp.collectionPosition;
10026
+ var matchUpValue_1 = getCollectionPositionValue({
10027
+ collectionDefinition: collectionDefinition,
10028
+ collectionPosition: collectionPosition,
10029
+ });
10030
+ if (isConvertableInteger(matchUpValue_1)) {
10031
+ sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue_1;
10032
+ }
10033
+ }
10034
+ });
10035
+ }
10036
+ // processed separately so that setValue, scoreValue and collecitonValueProfile can be used in conjunction with collectionValue
10037
+ if (isConvertableInteger(collectionValue)) {
10038
+ var collectionWinningSide = void 0;
10039
+ if (winCriteria === null || winCriteria === void 0 ? void 0 : winCriteria.aggregateValue) {
10040
+ if (allCollectionMatchUpsCompleted) {
10041
+ if (isConvertableInteger(matchUpValue || setValue || scoreValue) &&
10042
+ sideMatchUpValues[0] !== sideMatchUpValues[1]) {
10043
+ collectionWinningSide =
10044
+ sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
10045
+ }
10046
+ else if (sideWins[0] !== sideWins[1]) {
10047
+ collectionWinningSide = sideWins[0] > sideWins[1] ? 1 : 2;
10048
+ }
10049
+ }
10050
+ }
10051
+ else if (winCriteria === null || winCriteria === void 0 ? void 0 : winCriteria.valueGoal) {
10052
+ collectionWinningSide = sideMatchUpValues.reduce(function (winningSide, side, i) {
10053
+ return side >= winCriteria.valueGoal ? i + 1 : winningSide;
10054
+ }, 0);
10055
+ }
10056
+ else {
10057
+ var winGoal_1 = Math.floor(collectionDefinition.matchUpCount / 2) + 1;
10058
+ collectionWinningSide = sideWins.reduce(function (winningSide, side, i) {
10059
+ return side >= winGoal_1 ? i + 1 : winningSide;
10060
+ }, 0);
10061
+ }
10062
+ if (collectionWinningSide) {
10063
+ if (belongsToValueGroup) {
10064
+ groupValueGroups[collectionGroupNumber].values[collectionWinningSide - 1] += collectionValue;
10065
+ }
10066
+ else {
10067
+ sideCollectionValues[collectionWinningSide - 1] += collectionValue;
10068
+ }
10069
+ }
10070
+ }
10071
+ else {
10072
+ if (belongsToValueGroup) {
10073
+ groupValueGroups[collectionGroupNumber].values[0] +=
10074
+ sideMatchUpValues[0] || 0;
10075
+ groupValueGroups[collectionGroupNumber].values[1] +=
10076
+ sideMatchUpValues[1] || 0;
10077
+ }
10078
+ else {
10079
+ sideCollectionValues = sideMatchUpValues;
10080
+ }
10081
+ }
10082
+ if (!belongsToValueGroup) {
10083
+ sideCollectionValues.forEach(function (sideCollectionValue, i) { return (sideTieValues[i] += sideCollectionValue || 0); });
10084
+ }
10085
+ else {
10086
+ groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
10087
+ groupValueGroups[collectionGroupNumber].sideWins[1] += sideWins[1] || 0;
10088
+ groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted =
10089
+ groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted &&
10090
+ allCollectionMatchUpsCompleted;
10091
+ groupValueGroups[collectionGroupNumber].matchUpsCount +=
10092
+ collectionMatchUps.length;
10093
+ }
10094
+ }
10095
+ function getCollectionPositionValue(_a) {
10096
+ var collectionDefinition = _a.collectionDefinition, collectionPosition = _a.collectionPosition;
10097
+ var collectionValueProfiles = collectionDefinition.collectionValueProfiles || [];
10098
+ var profile = collectionValueProfiles === null || collectionValueProfiles === void 0 ? void 0 : collectionValueProfiles.find(function (profile) { return profile.collectionPosition === collectionPosition; });
10099
+ return profile === null || profile === void 0 ? void 0 : profile.matchUpValue;
10100
+ }
10101
+
10056
10102
  function getGroupValueGroups(_a) {
10057
10103
  var _b = _a.collectionGroups, collectionGroups = _b === void 0 ? [] : _b;
10058
10104
  // set up to handle groupValue
@@ -10190,7 +10236,7 @@ function generateTieMatchUpScore(params) {
10190
10236
  ? matchUp
10191
10237
  : ((_d = matchUpsMap === null || matchUpsMap === void 0 ? void 0 : matchUpsMap.drawMatchUps) === null || _d === void 0 ? void 0 : _d[matchUpId]) ||
10192
10238
  (drawDefinition &&
10193
- ((_e = findMatchUp$1({
10239
+ ((_e = findDrawMatchUp({
10194
10240
  inContext: true,
10195
10241
  drawDefinition: drawDefinition,
10196
10242
  matchUpId: matchUpId,
@@ -10219,83 +10265,6 @@ function generateTieMatchUpScore(params) {
10219
10265
  };
10220
10266
  }
10221
10267
 
10222
- function copyTieFormat(tieFormat) {
10223
- if (!tieFormat)
10224
- return undefined;
10225
- return makeDeepCopy(tieFormat, false, true);
10226
- }
10227
-
10228
- function scoreHasValue(params) {
10229
- var _a, _b;
10230
- var matchUp = params === null || params === void 0 ? void 0 : params.matchUp;
10231
- var score = (params === null || params === void 0 ? void 0 : params.score) || (matchUp === null || matchUp === void 0 ? void 0 : matchUp.score);
10232
- var firstSet = (_a = score === null || score === void 0 ? void 0 : score.sets) === null || _a === void 0 ? void 0 : _a[0];
10233
- var _c = firstSet || {}, side1Score = _c.side1Score, side2Score = _c.side2Score, side1TiebreakScore = _c.side1TiebreakScore, side2TiebreakScore = _c.side2TiebreakScore, side1PointScore = _c.side1PointScore, side2PointScore = _c.side2PointScore;
10234
- var firstSetScore = side1Score ||
10235
- side2Score ||
10236
- side1TiebreakScore ||
10237
- side2TiebreakScore ||
10238
- side1PointScore ||
10239
- side2PointScore;
10240
- var hasValue = ((_b = score === null || score === void 0 ? void 0 : score.sets) === null || _b === void 0 ? void 0 : _b.length) > 1 || firstSetScore;
10241
- return !!hasValue;
10242
- }
10243
-
10244
- function isDirectingMatchUpStatus(_a) {
10245
- var matchUpStatus = _a.matchUpStatus;
10246
- return directingMatchUpStatuses.includes(matchUpStatus);
10247
- }
10248
- function isActiveMatchUpStatus(_a) {
10249
- var matchUpStatus = _a.matchUpStatus;
10250
- return activeMatchUpStatuses.includes(matchUpStatus);
10251
- }
10252
- function isNonDirectingMatchUpStatus(_a) {
10253
- var matchUpStatus = _a.matchUpStatus;
10254
- return nonDirectingMatchUpStatuses.includes(matchUpStatus);
10255
- }
10256
-
10257
- function isActiveMatchUp(_a) {
10258
- var _b;
10259
- var matchUpStatus = _a.matchUpStatus, winningSide = _a.winningSide, tieMatchUps = _a.tieMatchUps, sides = _a.sides, score = _a.score;
10260
- var participantAssigned = sides === null || sides === void 0 ? void 0 : sides.find(function (_a) {
10261
- var participantId = _a.participantId;
10262
- return participantId;
10263
- });
10264
- var activeTieMatchUps = (_b = tieMatchUps === null || tieMatchUps === void 0 ? void 0 : tieMatchUps.filter(isActiveMatchUp)) === null || _b === void 0 ? void 0 : _b.length;
10265
- var scoreExists = scoreHasValue({ score: score });
10266
- return (scoreExists ||
10267
- activeTieMatchUps ||
10268
- (winningSide && participantAssigned) || // if winningSide and no participant assigned => "produced" WALKOVER
10269
- // must exclude IN_PROGRESS as this is automatically set by updateTieMatchUpScore
10270
- // must exclude WALKOVER and DEFAULTED as "produced" scenarios do not imply a winningSide
10271
- (matchUpStatus &&
10272
- isActiveMatchUpStatus({ matchUpStatus: matchUpStatus }) &&
10273
- ![DEFAULTED, WALKOVER$2, IN_PROGRESS$1].includes(matchUpStatus)));
10274
- }
10275
-
10276
- function addNotes(params) {
10277
- var _a;
10278
- if (typeof params !== 'object')
10279
- return { error: MISSING_VALUE };
10280
- if (typeof params.element !== 'object')
10281
- return { error: INVALID_VALUES };
10282
- if (!params.notes)
10283
- return { error: MISSING_VALUE };
10284
- if (typeof params.notes !== 'string' && !((_a = params.notes) === null || _a === void 0 ? void 0 : _a.testing))
10285
- return { error: INVALID_VALUES };
10286
- Object.assign(params.element, { notes: params.notes });
10287
- return __assign({}, SUCCESS);
10288
- }
10289
- function removeNotes(params) {
10290
- if (typeof params !== 'object')
10291
- return { error: MISSING_VALUE };
10292
- if (typeof params.element !== 'object')
10293
- return { error: INVALID_VALUES };
10294
- if (params.element.notes)
10295
- delete params.element.notes;
10296
- return __assign({}, SUCCESS);
10297
- }
10298
-
10299
10268
  function drawUpdatedAt(drawDefinition, structureIds) {
10300
10269
  var _a;
10301
10270
  if (!drawDefinition)
@@ -10382,8 +10351,8 @@ function updateInContextMatchUp(_a) {
10382
10351
  return { error: MISSING_MATCHUP };
10383
10352
  }
10384
10353
  addNotice({
10385
- topic: UPDATE_INCONTEXT_MATCHUP,
10386
10354
  payload: { inContextMatchUp: inContextMatchUp, tournamentId: tournamentId },
10355
+ topic: UPDATE_INCONTEXT_MATCHUP,
10387
10356
  key: inContextMatchUp.matchUpId,
10388
10357
  });
10389
10358
  return __assign({}, SUCCESS);
@@ -10477,6 +10446,117 @@ function modifyPositionAssignmentsNotice(_a) {
10477
10446
  return __assign({}, SUCCESS);
10478
10447
  }
10479
10448
 
10449
+ function ensureSideLineUps(_a) {
10450
+ var _b, _c, _d;
10451
+ var inContextDualMatchUp = _a.inContextDualMatchUp, drawDefinition = _a.drawDefinition, tournamentId = _a.tournamentId, dualMatchUp = _a.dualMatchUp, eventId = _a.eventId;
10452
+ if (dualMatchUp && !((_b = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _b === void 0 ? void 0 : _b.length)) {
10453
+ if (!inContextDualMatchUp) {
10454
+ inContextDualMatchUp = (_c = findDrawMatchUp({
10455
+ matchUpId: dualMatchUp.matchUpId,
10456
+ inContext: true,
10457
+ drawDefinition: drawDefinition,
10458
+ })) === null || _c === void 0 ? void 0 : _c.matchUp;
10459
+ }
10460
+ var extension = findExtension$2({
10461
+ element: drawDefinition,
10462
+ name: LINEUPS,
10463
+ }).extension;
10464
+ var lineUps_1 = makeDeepCopy((extension === null || extension === void 0 ? void 0 : extension.value) || {}, false, true);
10465
+ var extractSideDetail_1 = function (_a) {
10466
+ var displaySideNumber = _a.displaySideNumber, drawPosition = _a.drawPosition, sideNumber = _a.sideNumber;
10467
+ return ({ drawPosition: drawPosition, sideNumber: sideNumber, displaySideNumber: displaySideNumber });
10468
+ };
10469
+ dualMatchUp.sides = (_d = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _d === void 0 ? void 0 : _d.map(function (side) {
10470
+ var participantId = side.participantId;
10471
+ return __assign(__assign({}, extractSideDetail_1(side)), { lineUp: (participantId && lineUps_1[participantId]) || [] });
10472
+ });
10473
+ modifyMatchUpNotice({
10474
+ context: 'ensureSidLineUps',
10475
+ matchUp: dualMatchUp,
10476
+ drawDefinition: drawDefinition,
10477
+ tournamentId: tournamentId,
10478
+ eventId: eventId,
10479
+ });
10480
+ }
10481
+ }
10482
+
10483
+ function copyTieFormat(tieFormat) {
10484
+ if (!tieFormat)
10485
+ return undefined;
10486
+ return makeDeepCopy(tieFormat, false, true);
10487
+ }
10488
+
10489
+ function scoreHasValue(params) {
10490
+ var _a, _b;
10491
+ var matchUp = params === null || params === void 0 ? void 0 : params.matchUp;
10492
+ var score = (params === null || params === void 0 ? void 0 : params.score) || (matchUp === null || matchUp === void 0 ? void 0 : matchUp.score);
10493
+ var firstSet = (_a = score === null || score === void 0 ? void 0 : score.sets) === null || _a === void 0 ? void 0 : _a[0];
10494
+ var _c = firstSet || {}, side1Score = _c.side1Score, side2Score = _c.side2Score, side1TiebreakScore = _c.side1TiebreakScore, side2TiebreakScore = _c.side2TiebreakScore, side1PointScore = _c.side1PointScore, side2PointScore = _c.side2PointScore;
10495
+ var firstSetScore = side1Score ||
10496
+ side2Score ||
10497
+ side1TiebreakScore ||
10498
+ side2TiebreakScore ||
10499
+ side1PointScore ||
10500
+ side2PointScore;
10501
+ var hasValue = ((_b = score === null || score === void 0 ? void 0 : score.sets) === null || _b === void 0 ? void 0 : _b.length) > 1 || firstSetScore;
10502
+ return !!hasValue;
10503
+ }
10504
+
10505
+ function isDirectingMatchUpStatus(_a) {
10506
+ var matchUpStatus = _a.matchUpStatus;
10507
+ return directingMatchUpStatuses.includes(matchUpStatus);
10508
+ }
10509
+ function isActiveMatchUpStatus(_a) {
10510
+ var matchUpStatus = _a.matchUpStatus;
10511
+ return activeMatchUpStatuses.includes(matchUpStatus);
10512
+ }
10513
+ function isNonDirectingMatchUpStatus(_a) {
10514
+ var matchUpStatus = _a.matchUpStatus;
10515
+ return nonDirectingMatchUpStatuses.includes(matchUpStatus);
10516
+ }
10517
+
10518
+ function isActiveMatchUp(_a) {
10519
+ var _b;
10520
+ var matchUpStatus = _a.matchUpStatus, winningSide = _a.winningSide, tieMatchUps = _a.tieMatchUps, sides = _a.sides, score = _a.score;
10521
+ var participantAssigned = sides === null || sides === void 0 ? void 0 : sides.find(function (_a) {
10522
+ var participantId = _a.participantId;
10523
+ return participantId;
10524
+ });
10525
+ var activeTieMatchUps = (_b = tieMatchUps === null || tieMatchUps === void 0 ? void 0 : tieMatchUps.filter(isActiveMatchUp)) === null || _b === void 0 ? void 0 : _b.length;
10526
+ var scoreExists = scoreHasValue({ score: score });
10527
+ return (scoreExists ||
10528
+ activeTieMatchUps ||
10529
+ (winningSide && participantAssigned) || // if winningSide and no participant assigned => "produced" WALKOVER
10530
+ // must exclude IN_PROGRESS as this is automatically set by updateTieMatchUpScore
10531
+ // must exclude WALKOVER and DEFAULTED as "produced" scenarios do not imply a winningSide
10532
+ (matchUpStatus &&
10533
+ isActiveMatchUpStatus({ matchUpStatus: matchUpStatus }) &&
10534
+ ![DEFAULTED, WALKOVER$2, IN_PROGRESS$1].includes(matchUpStatus)));
10535
+ }
10536
+
10537
+ function addNotes(params) {
10538
+ var _a;
10539
+ if (typeof params !== 'object')
10540
+ return { error: MISSING_VALUE };
10541
+ if (typeof params.element !== 'object')
10542
+ return { error: INVALID_VALUES };
10543
+ if (!params.notes)
10544
+ return { error: MISSING_VALUE };
10545
+ if (typeof params.notes !== 'string' && !((_a = params.notes) === null || _a === void 0 ? void 0 : _a.testing))
10546
+ return { error: INVALID_VALUES };
10547
+ Object.assign(params.element, { notes: params.notes });
10548
+ return __assign({}, SUCCESS);
10549
+ }
10550
+ function removeNotes(params) {
10551
+ if (typeof params !== 'object')
10552
+ return { error: MISSING_VALUE };
10553
+ if (typeof params.element !== 'object')
10554
+ return { error: INVALID_VALUES };
10555
+ if (params.element.notes)
10556
+ delete params.element.notes;
10557
+ return __assign({}, SUCCESS);
10558
+ }
10559
+
10480
10560
  var hasParticipantId = function (o) { return o === null || o === void 0 ? void 0 : o.participantId; };
10481
10561
 
10482
10562
  function createSubOrderMap(_a) {
@@ -11433,7 +11513,7 @@ function modifyMatchUpScore(_a) {
11433
11513
  if (isDualMatchUp && drawDefinition) {
11434
11514
  if (matchUpId && matchUp.matchUpId !== matchUpId) {
11435
11515
  // the modification is to be applied to a tieMatchUp
11436
- var findResult = findMatchUp$1({
11516
+ var findResult = findDrawMatchUp({
11437
11517
  drawDefinition: drawDefinition,
11438
11518
  matchUpId: matchUpId,
11439
11519
  event: event,
@@ -11467,7 +11547,7 @@ function modifyMatchUpScore(_a) {
11467
11547
  if (removeWinningSide)
11468
11548
  matchUp.winningSide = undefined;
11469
11549
  if (!structure && drawDefinition) {
11470
- (structure = findMatchUp$1({
11550
+ (structure = findDrawMatchUp({
11471
11551
  drawDefinition: drawDefinition,
11472
11552
  matchUpId: matchUpId,
11473
11553
  event: event,
@@ -11606,7 +11686,7 @@ function modifyMatchUpScore(_a) {
11606
11686
  function updateTieMatchUpScore$1(_a) {
11607
11687
  var _b, _c;
11608
11688
  var tournamentRecord = _a.tournamentRecord, exitWhenNoValues = _a.exitWhenNoValues, drawDefinition = _a.drawDefinition, matchUpStatus = _a.matchUpStatus, removeScore = _a.removeScore, matchUpsMap = _a.matchUpsMap, matchUpId = _a.matchUpId, event = _a.event;
11609
- var result = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
11689
+ var result = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
11610
11690
  if (result.error)
11611
11691
  return result;
11612
11692
  if (!result.matchUp)
@@ -11614,6 +11694,12 @@ function updateTieMatchUpScore$1(_a) {
11614
11694
  var matchUp = result.matchUp, structure = result.structure;
11615
11695
  if (!matchUp.tieMatchUps)
11616
11696
  return { error: INVALID_MATCHUP };
11697
+ ensureSideLineUps({
11698
+ tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
11699
+ eventId: event === null || event === void 0 ? void 0 : event.eventId,
11700
+ dualMatchUp: matchUp,
11701
+ drawDefinition: drawDefinition,
11702
+ });
11617
11703
  var extension = findExtension({
11618
11704
  name: DISABLE_AUTO_CALC,
11619
11705
  element: matchUp,
@@ -17577,8 +17663,8 @@ function allTournamentMatchUps(params) {
17577
17663
  if (!participants) {
17578
17664
  (_a = hydrateParticipants({
17579
17665
  participantsProfile: participantsProfile,
17580
- policyDefinitions: policyDefinitions,
17581
17666
  useParticipantMap: useParticipantMap,
17667
+ policyDefinitions: policyDefinitions,
17582
17668
  tournamentRecord: tournamentRecord,
17583
17669
  contextProfile: contextProfile,
17584
17670
  inContext: inContext,
@@ -21744,7 +21830,7 @@ function addEventTimeItem(params) {
21744
21830
 
21745
21831
  function addMatchUpTimeItem(_a) {
21746
21832
  var removePriorValues = _a.removePriorValues, tournamentRecord = _a.tournamentRecord, duplicateValues = _a.duplicateValues, drawDefinition = _a.drawDefinition, disableNotice = _a.disableNotice, matchUpId = _a.matchUpId, timeItem = _a.timeItem, event = _a.event;
21747
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
21833
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
21748
21834
  if (!matchUp)
21749
21835
  return { error: MATCHUP_NOT_FOUND };
21750
21836
  var result = addTimeItem({
@@ -21766,7 +21852,7 @@ function addMatchUpTimeItem(_a) {
21766
21852
  }
21767
21853
  function resetMatchUpTimeItems(_a) {
21768
21854
  var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, event = _a.event;
21769
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
21855
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
21770
21856
  if (!matchUp)
21771
21857
  return { error: MATCHUP_NOT_FOUND };
21772
21858
  matchUp.timeItems = [];
@@ -21788,7 +21874,7 @@ function allocateTeamMatchUpCourts$1(_a) {
21788
21874
  return { error: MISSING_TOURNAMENT_RECORD };
21789
21875
  if (!matchUpId)
21790
21876
  return { error: MISSING_MATCHUP_ID };
21791
- var result = findMatchUp$1({
21877
+ var result = findDrawMatchUp({
21792
21878
  drawDefinition: drawDefinition,
21793
21879
  matchUpId: matchUpId,
21794
21880
  });
@@ -21931,7 +22017,7 @@ function addMatchUpScheduledTime$2(params) {
21931
22017
  if (!validTimeValue(scheduledTime))
21932
22018
  return decorateResult({ result: { error: INVALID_TIME }, stack: stack });
21933
22019
  if (!matchUp) {
21934
- var result = findMatchUp$1({ drawDefinition: drawDefinition, matchUpId: matchUpId });
22020
+ var result = findDrawMatchUp({ drawDefinition: drawDefinition, matchUpId: matchUpId });
21935
22021
  if (result.error)
21936
22022
  return decorateResult({ result: result, stack: stack });
21937
22023
  matchUp = result.matchUp;
@@ -21982,7 +22068,7 @@ function addMatchUpTimeModifiers(_a) {
21982
22068
  stack: stack,
21983
22069
  });
21984
22070
  if (!matchUp) {
21985
- var result = findMatchUp$1({ drawDefinition: drawDefinition, matchUpId: matchUpId });
22071
+ var result = findDrawMatchUp({ drawDefinition: drawDefinition, matchUpId: matchUpId });
21986
22072
  if (result.error)
21987
22073
  return decorateResult({ result: result, stack: stack });
21988
22074
  matchUp = result.matchUp;
@@ -22047,7 +22133,7 @@ function addMatchUpScheduleItems$2(_a) {
22047
22133
  var stack = 'drawEngine.addMatchUpScheduleItems';
22048
22134
  var matchUp, warning;
22049
22135
  if (!drawMatchUps) {
22050
- var result = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
22136
+ var result = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
22051
22137
  if (result.error)
22052
22138
  return result;
22053
22139
  matchUp = result.matchUp;
@@ -22313,7 +22399,7 @@ function addMatchUpStartTime$2(_a) {
22313
22399
  return { error: MISSING_MATCHUP_ID };
22314
22400
  if (!validTimeValue(startTime))
22315
22401
  return { error: INVALID_TIME };
22316
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22402
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22317
22403
  var scheduledDate = scheduledMatchUpDate({ matchUp: matchUp }).scheduledDate;
22318
22404
  var timeItems = (_b = matchUp === null || matchUp === void 0 ? void 0 : matchUp.timeItems) !== null && _b !== void 0 ? _b : [];
22319
22405
  var earliestRelevantTimeValue = timeItems
@@ -22354,7 +22440,7 @@ function addMatchUpEndTime$2(_a) {
22354
22440
  return { error: MISSING_MATCHUP_ID };
22355
22441
  if (!validTimeValue(endTime))
22356
22442
  return { error: INVALID_TIME };
22357
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22443
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22358
22444
  var scheduledDate = scheduledMatchUpDate({ matchUp: matchUp }).scheduledDate;
22359
22445
  var timeItems = (_b = matchUp === null || matchUp === void 0 ? void 0 : matchUp.timeItems) !== null && _b !== void 0 ? _b : [];
22360
22446
  var latestRelevantTimeValue = timeItems
@@ -22397,7 +22483,7 @@ function addMatchUpStopTime$2(_a) {
22397
22483
  return { error: MISSING_MATCHUP_ID };
22398
22484
  if (!validTimeValue(stopTime))
22399
22485
  return { error: INVALID_TIME };
22400
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22486
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22401
22487
  var scheduledDate = scheduledMatchUpDate({ matchUp: matchUp }).scheduledDate;
22402
22488
  var timeItems = (_b = matchUp === null || matchUp === void 0 ? void 0 : matchUp.timeItems) !== null && _b !== void 0 ? _b : [];
22403
22489
  // can't add a STOP_TIME if the matchUp is not STARTED or RESUMED, or has START_TIME
@@ -22458,7 +22544,7 @@ function addMatchUpResumeTime$2(_a) {
22458
22544
  return { error: MISSING_MATCHUP_ID };
22459
22545
  if (!validTimeValue(resumeTime))
22460
22546
  return { error: INVALID_TIME };
22461
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22547
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22462
22548
  var scheduledDate = scheduledMatchUpDate({ matchUp: matchUp }).scheduledDate;
22463
22549
  var timeItems = (_b = matchUp === null || matchUp === void 0 ? void 0 : matchUp.timeItems) !== null && _b !== void 0 ? _b : [];
22464
22550
  // can't add a RESUME_TIME if the matchUp is not STOPPED, or if it has ENDED
@@ -24293,8 +24379,8 @@ function updateSideLineUp(_a) {
24293
24379
  element: drawDefinition,
24294
24380
  name: LINEUPS,
24295
24381
  }).extension;
24296
- var value = (existingExtension === null || existingExtension === void 0 ? void 0 : existingExtension.value) || {};
24297
- var lineUp = value[teamParticipantId];
24382
+ var lineUps = (existingExtension === null || existingExtension === void 0 ? void 0 : existingExtension.value) || {};
24383
+ var lineUp = makeDeepCopy(lineUps[teamParticipantId], false, true);
24298
24384
  if (sideExists) {
24299
24385
  (_e = matchUp === null || matchUp === void 0 ? void 0 : matchUp.sides) === null || _e === void 0 ? void 0 : _e.forEach(function (side) {
24300
24386
  if (side.sideNumber === drawPositionSideNumber) {
@@ -24309,13 +24395,12 @@ function updateSideLineUp(_a) {
24309
24395
  return __assign(__assign({}, existingSide), { sideNumber: sideNumber });
24310
24396
  });
24311
24397
  var targetSide = matchUp.sides.find(function (side) { return side.sideNumber === drawPositionSideNumber; });
24312
- if (targetSide) {
24398
+ if (targetSide)
24313
24399
  targetSide.lineUp = lineUp;
24314
- }
24315
24400
  }
24316
24401
  modifyMatchUpNotice({
24317
24402
  tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
24318
- context: 'updateSidLineUps',
24403
+ context: 'updateSidLineUp',
24319
24404
  eventId: event === null || event === void 0 ? void 0 : event.eventId,
24320
24405
  drawDefinition: drawDefinition,
24321
24406
  matchUp: matchUp,
@@ -25290,13 +25375,15 @@ function removeLineUpSubstitutions(_a) {
25290
25375
  if (!Array.isArray(lineUp))
25291
25376
  return;
25292
25377
  var participantAssignments = {};
25293
- var permutations = unique(lineUp.flatMap(function (_a) {
25378
+ var permutations = unique(lineUp
25379
+ .flatMap(function (_a) {
25294
25380
  var collectionAssignments = _a.collectionAssignments;
25295
- return collectionAssignments.map(function (_a) {
25381
+ return collectionAssignments === null || collectionAssignments === void 0 ? void 0 : collectionAssignments.map(function (_a) {
25296
25382
  var collectionId = _a.collectionId, collectionPosition = _a.collectionPosition;
25297
25383
  return [collectionId, collectionPosition].join('|');
25298
25384
  });
25299
- }));
25385
+ })
25386
+ .filter(Boolean));
25300
25387
  permutations.forEach(function (permutation) {
25301
25388
  var _a = __read(permutation.split('|'), 2), collectionId = _a[0], position = _a[1];
25302
25389
  var collectionPosition = parseInt(position);
@@ -27925,7 +28012,7 @@ function setMatchUpStatus$2(params) {
27925
28012
  matchUp: matchUp,
27926
28013
  });
27927
28014
  if (matchUpTieId) {
27928
- var dualMatchUp = findMatchUp$1({
28015
+ var dualMatchUp = findDrawMatchUp({
27929
28016
  matchUpId: matchUpTieId,
27930
28017
  inContext: true,
27931
28018
  drawDefinition: drawDefinition,
@@ -28089,7 +28176,7 @@ function setMatchUpFormat$1(params) {
28089
28176
  return { error: UNRECOGNIZED_MATCHUP_FORMAT };
28090
28177
  var stack = 'setMatchUpFormat';
28091
28178
  if (matchUpId) {
28092
- var result = findMatchUp$1({
28179
+ var result = findDrawMatchUp({
28093
28180
  drawDefinition: drawDefinition,
28094
28181
  matchUpId: matchUpId,
28095
28182
  event: event,
@@ -30722,7 +30809,7 @@ function getTieFormat$1(_a) {
30722
30809
  else if (matchUpId) {
30723
30810
  // if matchUpId is present, structure and drawDefinition are always required
30724
30811
  if (drawDefinition && (!matchUp || !structure)) {
30725
- var result = findMatchUp$1({
30812
+ var result = findDrawMatchUp({
30726
30813
  drawDefinition: drawDefinition,
30727
30814
  matchUpId: matchUpId,
30728
30815
  });
@@ -31460,7 +31547,7 @@ function orderCollectionDefinitions$1(_a) {
31460
31547
  }
31461
31548
  else if (matchUpId) {
31462
31549
  var result = drawDefinition &&
31463
- findMatchUp$1({
31550
+ findDrawMatchUp({
31464
31551
  drawDefinition: drawDefinition,
31465
31552
  matchUpId: matchUpId,
31466
31553
  });
@@ -31765,7 +31852,7 @@ function removeCollectionDefinition$1(_a) {
31765
31852
  });
31766
31853
  if (result_1.error)
31767
31854
  return result_1;
31768
- result_1 = findMatchUp$1({
31855
+ result_1 = findDrawMatchUp({
31769
31856
  drawDefinition: drawDefinition,
31770
31857
  matchUpId: matchUpId,
31771
31858
  });
@@ -32705,7 +32792,7 @@ function findMatchUp(_a) {
32705
32792
  contextProfile: contextProfile,
32706
32793
  inContext: inContext,
32707
32794
  }).participants, tournamentParticipants = _g === void 0 ? [] : _g;
32708
- var _h = findMatchUp$1({
32795
+ var _h = findDrawMatchUp({
32709
32796
  context: inContext ? additionalContext : undefined,
32710
32797
  tournamentParticipants: tournamentParticipants,
32711
32798
  afterRecoveryTimes: afterRecoveryTimes,
@@ -36813,7 +36900,7 @@ function checkInParticipant$1(_a) {
36813
36900
  tournamentParticipants !== null && tournamentParticipants !== void 0 ? tournamentParticipants : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
36814
36901
  if (tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.length) {
36815
36902
  if (!matchUp && drawDefinition) {
36816
- var result_1 = findMatchUp$1({
36903
+ var result_1 = findDrawMatchUp({
36817
36904
  tournamentParticipants: tournamentParticipants,
36818
36905
  inContext: true,
36819
36906
  drawDefinition: drawDefinition,
@@ -36856,7 +36943,7 @@ function checkOutParticipant$1(_a) {
36856
36943
  tournamentParticipants =
36857
36944
  tournamentParticipants !== null && tournamentParticipants !== void 0 ? tournamentParticipants : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
36858
36945
  if (!matchUp) {
36859
- var result = findMatchUp$1({
36946
+ var result = findDrawMatchUp({
36860
36947
  tournamentParticipants: tournamentParticipants,
36861
36948
  inContext: true,
36862
36949
  drawDefinition: drawDefinition,
@@ -36975,7 +37062,7 @@ function removeMatchUpCourtAssignment$1(params) {
36975
37062
  }), drawDefinition = _c.drawDefinition, event = _c.event;
36976
37063
  if (!drawDefinition)
36977
37064
  return { error: MISSING_DRAW_DEFINITION };
36978
- var result = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
37065
+ var result = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
36979
37066
  if (result.error)
36980
37067
  return result;
36981
37068
  if (((_a = result === null || result === void 0 ? void 0 : result.matchUp) === null || _a === void 0 ? void 0 : _a.matchUpType) === TEAM_MATCHUP) {
@@ -39186,7 +39273,7 @@ function matchUpActions$2(_a) {
39186
39273
  });
39187
39274
  var otherFlightEntries = (_b = specifiedPolicyDefinitions === null || specifiedPolicyDefinitions === void 0 ? void 0 : specifiedPolicyDefinitions[POLICY_TYPE_POSITION_ACTIONS]) === null || _b === void 0 ? void 0 : _b.otherFlightEntries;
39188
39275
  var drawId = drawDefinition.drawId;
39189
- var _12 = findMatchUp$1({
39276
+ var _12 = findDrawMatchUp({
39190
39277
  drawDefinition: drawDefinition,
39191
39278
  matchUpId: matchUpId,
39192
39279
  event: event,
@@ -40076,7 +40163,7 @@ function removeCourtAssignment(_a) {
40076
40163
  (drawDefinition = findEvent({ tournamentRecord: tournamentRecord, drawId: drawId }).drawDefinition);
40077
40164
  }
40078
40165
  if (drawDefinition) {
40079
- (matchUp = findMatchUp$1({ drawDefinition: drawDefinition, matchUpId: matchUpId }).matchUp);
40166
+ (matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, matchUpId: matchUpId }).matchUp);
40080
40167
  }
40081
40168
  else {
40082
40169
  if (!tournamentRecord)
@@ -50099,13 +50186,13 @@ function resetMatchUpLineUps$1(_a) {
50099
50186
  var _d = _a.inheritance, inheritance = _d === void 0 ? true : _d, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, event = _a.event;
50100
50187
  if (!drawDefinition)
50101
50188
  return { error: MISSING_DRAW_DEFINITION };
50102
- var matchUp = (_b = findMatchUp$1({
50189
+ var matchUp = (_b = findDrawMatchUp({
50103
50190
  drawDefinition: drawDefinition,
50104
50191
  matchUpId: matchUpId,
50105
50192
  })) === null || _b === void 0 ? void 0 : _b.matchUp;
50106
50193
  if (!(matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieMatchUps))
50107
50194
  return { error: INVALID_MATCHUP };
50108
- var inContextMatchUp = (_c = findMatchUp$1({
50195
+ var inContextMatchUp = (_c = findDrawMatchUp({
50109
50196
  inContext: true,
50110
50197
  drawDefinition: drawDefinition,
50111
50198
  matchUpId: matchUpId,
@@ -50215,7 +50302,7 @@ function removeDelegatedOutcome$1(_a) {
50215
50302
  return { error: MISSING_DRAW_DEFINITION };
50216
50303
  if (!matchUpId)
50217
50304
  return { error: MISSING_MATCHUP_ID };
50218
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
50305
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
50219
50306
  if (!matchUp)
50220
50307
  return { error: MATCHUP_NOT_FOUND };
50221
50308
  return removeExtension$1({
@@ -50785,7 +50872,7 @@ function setDelegatedOutcome$1(_a) {
50785
50872
  if (!matchUp && !matchUpId)
50786
50873
  return { error: MISSING_MATCHUP };
50787
50874
  if (!matchUp) {
50788
- var result = findMatchUp$1({
50875
+ var result = findDrawMatchUp({
50789
50876
  drawDefinition: drawDefinition,
50790
50877
  matchUpId: matchUpId,
50791
50878
  });
@@ -50838,7 +50925,7 @@ function disableTieAutoCalc$1(_a) {
50838
50925
  var drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, event = _a.event;
50839
50926
  if (!drawDefinition)
50840
50927
  return { error: MISSING_DRAW_DEFINITION };
50841
- var matchUp = findMatchUp$1({
50928
+ var matchUp = findDrawMatchUp({
50842
50929
  drawDefinition: drawDefinition,
50843
50930
  matchUpId: matchUpId,
50844
50931
  event: event,
@@ -50853,7 +50940,7 @@ function enableTieAutoCalc$1(_a) {
50853
50940
  var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, event = _a.event;
50854
50941
  if (!drawDefinition)
50855
50942
  return { error: MISSING_DRAW_DEFINITION };
50856
- var matchUp = findMatchUp$1({
50943
+ var matchUp = findDrawMatchUp({
50857
50944
  drawDefinition: drawDefinition,
50858
50945
  matchUpId: matchUpId,
50859
50946
  event: event,
@@ -51034,7 +51121,7 @@ var matchUpGovernor = {
51034
51121
  removeDelegatedOutcome: removeDelegatedOutcome$1,
51035
51122
  drawMatic: drawMatic$1,
51036
51123
  addMatchUpOfficial: addMatchUpOfficial$2,
51037
- findMatchUp: publicFindMatchUp$1,
51124
+ findMatchUp: publicFindDrawMatchUp,
51038
51125
  getRoundMatchUps: getRoundMatchUps$1,
51039
51126
  validDrawPositions: validDrawPositions,
51040
51127
  validateScore: validateScore,
@@ -57112,14 +57199,14 @@ function getTieMatchUpContext(_a) {
57112
57199
  return { error: EVENT_NOT_FOUND };
57113
57200
  var matchUpsMap = getMatchUpsMap({ drawDefinition: drawDefinition });
57114
57201
  // tieMatchUp is matchUpType: SINGLES or DOUBLES
57115
- var tieMatchUp = findMatchUp$1({
57202
+ var tieMatchUp = findDrawMatchUp({
57116
57203
  matchUpId: tieMatchUpId,
57117
57204
  drawDefinition: drawDefinition,
57118
57205
  matchUpsMap: matchUpsMap,
57119
57206
  }).matchUp;
57120
57207
  if (!tieMatchUp)
57121
57208
  return { error: MATCHUP_NOT_FOUND };
57122
- var _c = findMatchUp$1({
57209
+ var _c = findDrawMatchUp({
57123
57210
  tournamentParticipants: tournamentRecord.participants,
57124
57211
  matchUpId: tieMatchUpId,
57125
57212
  inContext: true,
@@ -57142,12 +57229,12 @@ function getTieMatchUpContext(_a) {
57142
57229
  participantIds: participantIds,
57143
57230
  },
57144
57231
  }).participants;
57145
- var dualMatchUp = findMatchUp$1({
57232
+ var dualMatchUp = findDrawMatchUp({
57146
57233
  matchUpId: matchUpTieId,
57147
57234
  drawDefinition: drawDefinition,
57148
57235
  matchUpsMap: matchUpsMap,
57149
57236
  }).matchUp;
57150
- var inContextDualMatchUp = findMatchUp$1({
57237
+ var inContextDualMatchUp = findDrawMatchUp({
57151
57238
  matchUpId: matchUpTieId,
57152
57239
  inContext: true,
57153
57240
  drawDefinition: drawDefinition,
@@ -57162,19 +57249,9 @@ function getTieMatchUpContext(_a) {
57162
57249
  return __assign({ inContextDualMatchUp: inContextDualMatchUp, inContextTieMatchUp: inContextTieMatchUp, relevantAssignments: relevantAssignments, collectionPosition: collectionPosition, teamParticipants: teamParticipants, collectionId: collectionId, matchUpType: matchUpType, dualMatchUp: dualMatchUp, tieMatchUp: tieMatchUp, tieFormat: tieFormat, structure: structure }, SUCCESS);
57163
57250
  }
57164
57251
 
57165
- /**
57166
- * @param {object} tournamentRecord
57167
- * @param {string} participantId
57168
- * @param {object} drawDefinition
57169
- * @param {string} tieMatchUpId
57170
- * @param {number=} sideNumber
57171
- * @param {string} matchUpId
57172
- * @param {string=} drawId
57173
- * @param {object} event
57174
- */
57175
57252
  function assignTieMatchUpParticipantId(params) {
57176
57253
  var e_1, _a;
57177
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
57254
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
57178
57255
  var matchUpContext = getTieMatchUpContext(params);
57179
57256
  if (matchUpContext.error)
57180
57257
  return matchUpContext;
@@ -57199,8 +57276,9 @@ function assignTieMatchUpParticipantId(params) {
57199
57276
  }
57200
57277
  teamParticipantId =
57201
57278
  teamParticipantId ||
57202
- (params.sideNumber &&
57203
- ((_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));
57279
+ (params.sideNumber
57280
+ ? (_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
57281
+ : undefined);
57204
57282
  var participantToAssign = (_f = (_e = getParticipants$1({
57205
57283
  participantFilters: { participantIds: [participantId] },
57206
57284
  tournamentRecord: tournamentRecord,
@@ -57253,29 +57331,19 @@ function assignTieMatchUpParticipantId(params) {
57253
57331
  var collectionDefinition = (_l = tieFormat.collectionDefinitions) === null || _l === void 0 ? void 0 : _l.find(function (collectionDefinition) { return collectionDefinition.collectionId === collectionId; });
57254
57332
  if (!collectionDefinition)
57255
57333
  return { error: MISSING_COLLECTION_DEFINITION };
57256
- if (!((_m = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.length)) {
57257
- var extension = findExtension$2({
57258
- element: drawDefinition,
57259
- name: LINEUPS,
57260
- }).extension;
57261
- var lineUps_1 = makeDeepCopy((extension === null || extension === void 0 ? void 0 : extension.value) || {}, false, true);
57262
- var extractSideDetail_1 = function (_a) {
57263
- var displaySideNumber = _a.displaySideNumber, drawPosition = _a.drawPosition, sideNumber = _a.sideNumber;
57264
- return ({ drawPosition: drawPosition, sideNumber: sideNumber, displaySideNumber: displaySideNumber });
57265
- };
57266
- if (dualMatchUp) {
57267
- dualMatchUp.sides = (_o = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _o === void 0 ? void 0 : _o.map(function (side) {
57268
- var participantId = side.participantId;
57269
- return __assign(__assign({}, extractSideDetail_1(side)), { lineUp: (participantId && lineUps_1[participantId]) || [] });
57270
- });
57271
- }
57272
- }
57273
- var dualMatchUpSide = (_p = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _p === void 0 ? void 0 : _p.find(function (side) { return side.sideNumber === sideNumber; });
57274
- var tieMatchUpSide = (_q = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _q === void 0 ? void 0 : _q.find(function (side) { return side.sideNumber === sideNumber; });
57275
- var lineUp = (_r = dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.lineUp) !== null && _r !== void 0 ? _r : (_s = getTeamLineUp({
57334
+ ensureSideLineUps({
57335
+ tournamentId: tournamentRecord.tournamentId,
57336
+ eventId: event.eventId,
57337
+ inContextDualMatchUp: inContextDualMatchUp,
57338
+ drawDefinition: drawDefinition,
57339
+ dualMatchUp: dualMatchUp,
57340
+ });
57341
+ 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; });
57342
+ 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; });
57343
+ var lineUp = (_p = dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.lineUp) !== null && _p !== void 0 ? _p : (_q = getTeamLineUp({
57276
57344
  participantId: teamParticipantId,
57277
57345
  drawDefinition: drawDefinition,
57278
- })) === null || _s === void 0 ? void 0 : _s.lineUp;
57346
+ })) === null || _q === void 0 ? void 0 : _q.lineUp;
57279
57347
  var targetAssignments = lineUp === null || lineUp === void 0 ? void 0 : lineUp.filter(function (participantAssignment) {
57280
57348
  var _a;
57281
57349
  return (_a = participantAssignment.collectionAssignments) === null || _a === void 0 ? void 0 : _a.find(function (assignment) {
@@ -57302,7 +57370,7 @@ function assignTieMatchUpParticipantId(params) {
57302
57370
  if (removeResult.error)
57303
57371
  return decorateResult({ result: removeResult, stack: stack });
57304
57372
  var modifiedLineUp = removeResult.modifiedLineUp;
57305
- var deleteParticipantId;
57373
+ var deletedParticipantId;
57306
57374
  if (matchUpType === DOUBLES$1) {
57307
57375
  if (participantType !== PAIR) {
57308
57376
  var result = updateLineUp({
@@ -57321,7 +57389,7 @@ function assignTieMatchUpParticipantId(params) {
57321
57389
  });
57322
57390
  if (result.error)
57323
57391
  return result;
57324
- deleteParticipantId = result.deleteParticipantId;
57392
+ deletedParticipantId = result.deletedParticipantId;
57325
57393
  if (dualMatchUpSide)
57326
57394
  dualMatchUpSide.lineUp = modifiedLineUp;
57327
57395
  if (dualMatchUp) {
@@ -57379,9 +57447,9 @@ function assignTieMatchUpParticipantId(params) {
57379
57447
  context: stack,
57380
57448
  drawDefinition: drawDefinition,
57381
57449
  });
57382
- if (deleteParticipantId) {
57450
+ if (deletedParticipantId) {
57383
57451
  var error = deleteParticipants({
57384
- participantIds: [deleteParticipantId],
57452
+ participantIds: [deletedParticipantId],
57385
57453
  tournamentRecord: tournamentRecord,
57386
57454
  }).error;
57387
57455
  if (error)
@@ -57390,7 +57458,7 @@ function assignTieMatchUpParticipantId(params) {
57390
57458
  return __assign(__assign({}, SUCCESS), { modifiedLineUp: modifiedLineUp });
57391
57459
  function addParticipantId2Pair(_a) {
57392
57460
  var side = _a.side;
57393
- var deleteParticipantId;
57461
+ var deletedParticipantId;
57394
57462
  if (!side.participant) {
57395
57463
  var newPairParticipant = {
57396
57464
  individualParticipantIds: [participantId],
@@ -57431,11 +57499,11 @@ function assignTieMatchUpParticipantId(params) {
57431
57499
  else {
57432
57500
  // check if there is a pairParticipant that includes both individualParticipantIds
57433
57501
  // if there is, use that and delete the PAIR participant with only one [individualParticipantId]
57434
- deleteParticipantId = participant === null || participant === void 0 ? void 0 : participant.participantId;
57502
+ deletedParticipantId = participant === null || participant === void 0 ? void 0 : participant.participantId;
57435
57503
  }
57436
57504
  }
57437
57505
  }
57438
- return __assign(__assign({}, SUCCESS), { deleteParticipantId: deleteParticipantId });
57506
+ return __assign(__assign({}, SUCCESS), { deletedParticipantId: deletedParticipantId });
57439
57507
  }
57440
57508
  }
57441
57509
  function updateLineUp(_a) {
@@ -58038,14 +58106,15 @@ function completeDrawMatchUps(params) {
58038
58106
  });
58039
58107
  if (teamParticipant) {
58040
58108
  var individualParticipantId = (_a = teamParticipant.individualParticipantIds) === null || _a === void 0 ? void 0 : _a[i];
58041
- assignTieMatchUpParticipantId({
58042
- teamParticipantId: teamParticipant.participantId,
58043
- participantId: individualParticipantId,
58044
- tournamentRecord: tournamentRecord,
58045
- drawDefinition: drawDefinition,
58046
- tieMatchUpId: tieMatchUpId,
58047
- event: event,
58048
- });
58109
+ individualParticipantId &&
58110
+ assignTieMatchUpParticipantId({
58111
+ teamParticipantId: teamParticipant.participantId,
58112
+ participantId: individualParticipantId,
58113
+ tournamentRecord: tournamentRecord,
58114
+ drawDefinition: drawDefinition,
58115
+ tieMatchUpId: tieMatchUpId,
58116
+ event: event,
58117
+ });
58049
58118
  }
58050
58119
  });
58051
58120
  });
@@ -59255,12 +59324,15 @@ function getEntryStatusReports(_a) {
59255
59324
  function getParticipantStats(_a) {
59256
59325
  var e_1, _b, e_2, _c, e_3, _d, e_4, _e, e_5, _f, e_6, _g, e_7, _h;
59257
59326
  var _j, _k, _l, _m, _o, _p;
59258
- var withCompetitiveProfiles = _a.withCompetitiveProfiles, opponentParticipantId = _a.opponentParticipantId, withIndividualStats = _a.withIndividualStats, teamParticipantId = _a.teamParticipantId, tournamentRecord = _a.tournamentRecord, tallyPolicy = _a.tallyPolicy, matchUps = _a.matchUps;
59327
+ var withCompetitiveProfiles = _a.withCompetitiveProfiles, opponentParticipantId = _a.opponentParticipantId, withIndividualStats = _a.withIndividualStats, teamParticipantId = _a.teamParticipantId, tournamentRecord = _a.tournamentRecord, withScaleValues = _a.withScaleValues, tallyPolicy = _a.tallyPolicy, matchUps = _a.matchUps;
59259
59328
  if (!tournamentRecord)
59260
59329
  return { error: MISSING_TOURNAMENT_RECORD };
59261
59330
  if (matchUps && !Array.isArray(matchUps))
59262
59331
  return { error: INVALID_MATCHUP };
59263
- matchUps = matchUps || allTournamentMatchUps({ tournamentRecord: tournamentRecord }).matchUps;
59332
+ var participantsProfile = withScaleValues ? { withScaleValues: withScaleValues } : undefined;
59333
+ matchUps =
59334
+ matchUps ||
59335
+ allTournamentMatchUps({ tournamentRecord: tournamentRecord, participantsProfile: participantsProfile }).matchUps;
59264
59336
  if (!(matchUps === null || matchUps === void 0 ? void 0 : matchUps.length))
59265
59337
  return { error: MISSING_MATCHUPS };
59266
59338
  var teamParticipantIds = [];
@@ -59280,8 +59352,8 @@ function getParticipantStats(_a) {
59280
59352
  }
59281
59353
  if (!teamParticipantIds.length)
59282
59354
  teamParticipantIds.push.apply(teamParticipantIds, __spreadArray([], __read(teamParticipants.map(extractAttributes('participantId'))), false));
59355
+ var participantDetails = new Map();
59283
59356
  var participantStats = new Map();
59284
- var participantNameMap = new Map();
59285
59357
  var participating = new Map();
59286
59358
  var teamMap = new Map();
59287
59359
  var initStats = function (participantId, participantName) {
@@ -59329,13 +59401,17 @@ function getParticipantStats(_a) {
59329
59401
  var relevantMatchUps = [];
59330
59402
  var getSideParticipantIds = function (sides) {
59331
59403
  var e_8, _a, e_9, _b, e_10, _c;
59332
- var _d;
59333
59404
  var sideParticipantIds = [[], []];
59334
59405
  try {
59335
59406
  for (var sides_1 = __values(sides), sides_1_1 = sides_1.next(); !sides_1_1.done; sides_1_1 = sides_1.next()) {
59336
59407
  var side = sides_1_1.value;
59337
- if ((_d = side.participant) === null || _d === void 0 ? void 0 : _d.participantName)
59338
- participantNameMap.set(side.participant.participantId, side.participant.participantName);
59408
+ var participant = side.participant;
59409
+ if (participant === null || participant === void 0 ? void 0 : participant.participantName) {
59410
+ participantDetails.set(participant.participantId, {
59411
+ participantName: participant.participantName,
59412
+ ratings: participant.ratings,
59413
+ });
59414
+ }
59339
59415
  }
59340
59416
  }
59341
59417
  catch (e_8_1) { e_8 = { error: e_8_1 }; }
@@ -59423,7 +59499,7 @@ function getParticipantStats(_a) {
59423
59499
  else {
59424
59500
  try {
59425
59501
  for (var teamMap_1 = __values(teamMap), teamMap_1_1 = teamMap_1.next(); !teamMap_1_1.done; teamMap_1_1 = teamMap_1.next()) {
59426
- var _e = __read(teamMap_1_1.value, 2), thisTeamId = _e[0], individualParticipantIds = _e[1];
59502
+ var _d = __read(teamMap_1_1.value, 2), thisTeamId = _d[0], individualParticipantIds = _d[1];
59427
59503
  processSides(thisTeamId, individualParticipantIds);
59428
59504
  }
59429
59505
  }
@@ -59499,8 +59575,10 @@ function getParticipantStats(_a) {
59499
59575
  }), pointsTally = _v.pointsTally, tiebreaksTally = _v.tiebreaksTally;
59500
59576
  sideParticipantIds.forEach(function (ids, index) {
59501
59577
  var e_13, _a;
59578
+ var _b;
59502
59579
  var _loop_2 = function (id) {
59503
- var stats = initStats(id, participantNameMap.get(id));
59580
+ var participantName = (_b = participantDetails.get(id)) === null || _b === void 0 ? void 0 : _b.participantName;
59581
+ var stats = initStats(id, participantName);
59504
59582
  if (stats) {
59505
59583
  var teamSumTally = function (stat, tally) {
59506
59584
  return tally.forEach(function (t, i) { return (stats[stat][i] += t); });
@@ -59937,8 +60015,10 @@ function assignMatchUpSideParticipant(_a) {
59937
60015
  if (noSideNumberProvided)
59938
60016
  sideNumber = 1;
59939
60017
  if (![1, 2].includes(sideNumber))
59940
- return { error: INVALID_VALUES, sideNumber: sideNumber };
59941
- var _e = findMatchUp$1({
60018
+ return decorateResult({
60019
+ result: { error: INVALID_VALUES, context: { sideNumber: sideNumber } },
60020
+ });
60021
+ var _e = findDrawMatchUp({
59942
60022
  drawDefinition: drawDefinition,
59943
60023
  matchUpId: matchUpId,
59944
60024
  event: event,
@@ -60012,7 +60092,7 @@ function removeMatchUpSideParticipant(_a) {
60012
60092
  // TODO: move to drawEngine and passthrough
60013
60093
  if (![1, 2].includes(sideNumber))
60014
60094
  return { error: INVALID_VALUES, sideNumber: sideNumber };
60015
- var _d = findMatchUp$1({
60095
+ var _d = findDrawMatchUp({
60016
60096
  drawDefinition: drawDefinition,
60017
60097
  matchUpId: matchUpId,
60018
60098
  event: event,
@@ -60042,7 +60122,7 @@ function removeMatchUpSideParticipant(_a) {
60042
60122
 
60043
60123
  function replaceTieMatchUpParticipantId(params) {
60044
60124
  var e_1, _a;
60045
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
60125
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
60046
60126
  var matchUpContext = getTieMatchUpContext(params);
60047
60127
  if (matchUpContext.error)
60048
60128
  return matchUpContext;
@@ -60092,24 +60172,14 @@ function replaceTieMatchUpParticipantId(params) {
60092
60172
  return { error: INVALID_PARTICIPANT, info: 'Gender mismatch' };
60093
60173
  }
60094
60174
  var substitutionProcessCodes = (_g = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _g === void 0 ? void 0 : _g.substitution;
60095
- var extension = findExtension$2({
60096
- element: drawDefinition,
60097
- name: LINEUPS,
60098
- }).extension;
60099
- var lineUps = (extension === null || extension === void 0 ? void 0 : extension.value) || {};
60100
- if (!((_h = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _h === void 0 ? void 0 : _h.length)) {
60101
- var extractSideDetail_1 = function (_a) {
60102
- var displaySideNumber = _a.displaySideNumber, drawPosition = _a.drawPosition, sideNumber = _a.sideNumber;
60103
- return ({ drawPosition: drawPosition, sideNumber: sideNumber, displaySideNumber: displaySideNumber });
60104
- };
60105
- if (dualMatchUp) {
60106
- dualMatchUp.sides = (_j = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _j === void 0 ? void 0 : _j.map(function (side) {
60107
- var participantId = side.participantId;
60108
- return __assign(__assign({}, extractSideDetail_1(side)), { lineUp: (participantId && lineUps[participantId]) || [] });
60109
- });
60110
- }
60111
- }
60112
- var dualMatchUpSide = (_k = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _k === void 0 ? void 0 : _k.find(function (_a) {
60175
+ ensureSideLineUps({
60176
+ tournamentId: tournamentRecord.tournamentId,
60177
+ eventId: event.eventId,
60178
+ inContextDualMatchUp: inContextDualMatchUp,
60179
+ drawDefinition: drawDefinition,
60180
+ dualMatchUp: dualMatchUp,
60181
+ });
60182
+ var dualMatchUpSide = (_h = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _h === void 0 ? void 0 : _h.find(function (_a) {
60113
60183
  var sideNumber = _a.sideNumber;
60114
60184
  return sideNumber === side.sideNumber;
60115
60185
  });
@@ -60123,7 +60193,7 @@ function replaceTieMatchUpParticipantId(params) {
60123
60193
  stack: stack,
60124
60194
  });
60125
60195
  }
60126
- var allTieIndividualParticipantIds = (_l = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _l === void 0 ? void 0 : _l.flatMap(function (side) {
60196
+ var allTieIndividualParticipantIds = (_j = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _j === void 0 ? void 0 : _j.flatMap(function (side) {
60127
60197
  var _a, _b;
60128
60198
  return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds) ||
60129
60199
  ((_b = side.participant) === null || _b === void 0 ? void 0 : _b.participantId) ||
@@ -60132,10 +60202,10 @@ function replaceTieMatchUpParticipantId(params) {
60132
60202
  if (allTieIndividualParticipantIds === null || allTieIndividualParticipantIds === void 0 ? void 0 : allTieIndividualParticipantIds.includes(newParticipantId)) {
60133
60203
  return decorateResult({ result: { error: EXISTING_PARTICIPANT }, stack: stack });
60134
60204
  }
60135
- var teamParticipantId = (_o = (_m = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (_a) {
60205
+ var teamParticipantId = (_l = (_k = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _k === void 0 ? void 0 : _k.find(function (_a) {
60136
60206
  var sideNumber = _a.sideNumber;
60137
60207
  return sideNumber === side.sideNumber;
60138
- })) === null || _o === void 0 ? void 0 : _o.participantId;
60208
+ })) === null || _l === void 0 ? void 0 : _l.participantId;
60139
60209
  var teamLineUp = dualMatchUpSide.lineUp;
60140
60210
  var newParticipantIdInLineUp = teamLineUp === null || teamLineUp === void 0 ? void 0 : teamLineUp.find(function (_a) {
60141
60211
  var participantId = _a.participantId;
@@ -60246,14 +60316,14 @@ function replaceTieMatchUpParticipantId(params) {
60246
60316
  });
60247
60317
  if (result_1.error)
60248
60318
  return decorateResult({ result: result_1, stack: stack });
60249
- participantAdded = (_p = result_1.participant) === null || _p === void 0 ? void 0 : _p.participantId;
60319
+ participantAdded = (_m = result_1.participant) === null || _m === void 0 ? void 0 : _m.participantId;
60250
60320
  }
60251
60321
  // now attempt to cleanup/delete previous pairParticipant
60252
60322
  result = getPairedParticipant({
60253
60323
  participantIds: existingIndividualParticipantIds,
60254
60324
  tournamentRecord: tournamentRecord_1,
60255
60325
  });
60256
- var existingPairParticipantId = (_q = result.participant) === null || _q === void 0 ? void 0 : _q.participantId;
60326
+ var existingPairParticipantId = (_o = result.participant) === null || _o === void 0 ? void 0 : _o.participantId;
60257
60327
  if (existingPairParticipantId) {
60258
60328
  var result_2 = deleteParticipants({
60259
60329
  participantIds: [existingPairParticipantId],
@@ -60263,7 +60333,7 @@ function replaceTieMatchUpParticipantId(params) {
60263
60333
  participantRemoved = existingPairParticipantId;
60264
60334
  }
60265
60335
  }
60266
- if (substitution || ((_r = side.substitutions) === null || _r === void 0 ? void 0 : _r.length) === 1) {
60336
+ if (substitution || ((_p = side.substitutions) === null || _p === void 0 ? void 0 : _p.length) === 1) {
60267
60337
  if (substitution) {
60268
60338
  var processCodes = (tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) || [];
60269
60339
  if (substitutionProcessCodes)
@@ -60274,18 +60344,18 @@ function replaceTieMatchUpParticipantId(params) {
60274
60344
  else {
60275
60345
  try {
60276
60346
  // if there was only one substitution, remove processCode(s)
60277
- for (var _u = __values(substitutionProcessCodes || []), _v = _u.next(); !_v.done; _v = _u.next()) {
60278
- var substitutionProcessCode = _v.value;
60279
- var codeIndex = (_s = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _s === void 0 ? void 0 : _s.lastIndexOf(substitutionProcessCode);
60347
+ for (var _s = __values(substitutionProcessCodes || []), _t = _s.next(); !_t.done; _t = _s.next()) {
60348
+ var substitutionProcessCode = _t.value;
60349
+ var codeIndex = (_q = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _q === void 0 ? void 0 : _q.lastIndexOf(substitutionProcessCode);
60280
60350
  // remove only one instance of substitutionProcessCode
60281
60351
  codeIndex !== undefined &&
60282
- ((_t = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _t === void 0 ? void 0 : _t.splice(codeIndex, 1));
60352
+ ((_r = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _r === void 0 ? void 0 : _r.splice(codeIndex, 1));
60283
60353
  }
60284
60354
  }
60285
60355
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
60286
60356
  finally {
60287
60357
  try {
60288
- if (_v && !_v.done && (_a = _u.return)) _a.call(_u);
60358
+ if (_t && !_t.done && (_a = _s.return)) _a.call(_s);
60289
60359
  }
60290
60360
  finally { if (e_1) throw e_1.error; }
60291
60361
  }
@@ -60312,7 +60382,7 @@ function replaceTieMatchUpParticipantId(params) {
60312
60382
 
60313
60383
  function removeTieMatchUpParticipantId(params) {
60314
60384
  var e_1, _a;
60315
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
60385
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
60316
60386
  var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, participantId = params.participantId, event = params.event;
60317
60387
  var stack = 'removeTieMatchUpParticiapantId';
60318
60388
  if (!participantId)
@@ -60361,27 +60431,19 @@ function removeTieMatchUpParticipantId(params) {
60361
60431
  var participantIds = participantToRemove.participantType === INDIVIDUAL
60362
60432
  ? [participantId]
60363
60433
  : participantToRemove.individualParticipantIds;
60364
- if (!((_j = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _j === void 0 ? void 0 : _j.length)) {
60365
- var extension = findExtension$2({
60366
- element: drawDefinition,
60367
- name: LINEUPS,
60368
- }).extension;
60369
- var lineUps_1 = (extension === null || extension === void 0 ? void 0 : extension.value) || {};
60370
- var extractSideDetail_1 = function (_a) {
60371
- var displaySideNumber = _a.displaySideNumber, drawPosition = _a.drawPosition, sideNumber = _a.sideNumber;
60372
- return ({ drawPosition: drawPosition, sideNumber: sideNumber, displaySideNumber: displaySideNumber });
60373
- };
60374
- dualMatchUp.sides = (_k = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _k === void 0 ? void 0 : _k.map(function (side) {
60375
- var participantId = side.participantId;
60376
- return __assign(__assign({}, extractSideDetail_1(side)), { lineUp: (participantId && lineUps_1[participantId]) || [] });
60377
- });
60378
- }
60379
- var dualMatchUpSide = (_l = dualMatchUp.sides) === null || _l === void 0 ? void 0 : _l.find(function (_a) {
60434
+ ensureSideLineUps({
60435
+ tournamentId: tournamentRecord.tournamentId,
60436
+ eventId: event.eventId,
60437
+ inContextDualMatchUp: inContextDualMatchUp,
60438
+ drawDefinition: drawDefinition,
60439
+ dualMatchUp: dualMatchUp,
60440
+ });
60441
+ var dualMatchUpSide = (_j = dualMatchUp.sides) === null || _j === void 0 ? void 0 : _j.find(function (_a) {
60380
60442
  var sideNumber = _a.sideNumber;
60381
60443
  return sideNumber === side.sideNumber;
60382
60444
  });
60383
60445
  if (!dualMatchUpSide &&
60384
- (((_m = dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.filter(function (_a) {
60446
+ (((_k = dualMatchUp.sides) === null || _k === void 0 ? void 0 : _k.filter(function (_a) {
60385
60447
  var lineUp = _a.lineUp;
60386
60448
  return !lineUp;
60387
60449
  }).length) || 0) < 2) {
@@ -60393,7 +60455,7 @@ function removeTieMatchUpParticipantId(params) {
60393
60455
  teamParticipantId: teamParticipantId,
60394
60456
  });
60395
60457
  });
60396
- dualMatchUpSide = (_o = dualMatchUp.sides) === null || _o === void 0 ? void 0 : _o.find(function (side) {
60458
+ dualMatchUpSide = (_l = dualMatchUp.sides) === null || _l === void 0 ? void 0 : _l.find(function (side) {
60397
60459
  var _a;
60398
60460
  return ((_a = drawPositionMap_1 === null || drawPositionMap_1 === void 0 ? void 0 : drawPositionMap_1.find(function (_a) {
60399
60461
  var drawPosition = _a.drawPosition;
@@ -60402,17 +60464,18 @@ function removeTieMatchUpParticipantId(params) {
60402
60464
  });
60403
60465
  }
60404
60466
  if (!dualMatchUpSide) {
60405
- console.log({ teamParticipantId: teamParticipantId, teamParticipants: teamParticipants });
60406
- return { error: PARTICIPANT_NOT_FOUND, participantId: participantId };
60467
+ return decorateResult({
60468
+ result: { error: PARTICIPANT_NOT_FOUND, context: { participantId: participantId } },
60469
+ });
60407
60470
  }
60408
- var _z = removeCollectionAssignments({
60471
+ var _x = removeCollectionAssignments({
60409
60472
  collectionPosition: collectionPosition,
60410
60473
  teamParticipantId: teamParticipantId,
60411
60474
  dualMatchUpSide: dualMatchUpSide,
60412
60475
  participantIds: participantIds,
60413
60476
  drawDefinition: drawDefinition,
60414
60477
  collectionId: collectionId,
60415
- }), modifiedLineUp = _z.modifiedLineUp, previousParticipantIds = _z.previousParticipantIds;
60478
+ }), modifiedLineUp = _x.modifiedLineUp, previousParticipantIds = _x.previousParticipantIds;
60416
60479
  dualMatchUpSide.lineUp = modifiedLineUp;
60417
60480
  teamParticipantId &&
60418
60481
  tieFormat &&
@@ -60426,16 +60489,16 @@ function removeTieMatchUpParticipantId(params) {
60426
60489
  // ...then the PAIR participant may need to be modified
60427
60490
  if (matchUpType === DOUBLES$1 &&
60428
60491
  participantToRemove.participantType === INDIVIDUAL) {
60429
- var tieMatchUpSide = (_p = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _p === void 0 ? void 0 : _p.find(function (side) { return side.sideNumber === (dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.sideNumber); });
60492
+ var tieMatchUpSide = (_m = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (side) { return side.sideNumber === (dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.sideNumber); });
60430
60493
  var pairParticipantId = (tieMatchUpSide || {}).participantId;
60431
60494
  var pairParticipant = pairParticipantId &&
60432
- ((_r = (_q = getParticipants$1({
60495
+ ((_p = (_o = getParticipants$1({
60433
60496
  participantFilters: { participantIds: [pairParticipantId] },
60434
60497
  tournamentRecord: tournamentRecord,
60435
60498
  withDraws: true,
60436
- })) === null || _q === void 0 ? void 0 : _q.participants) === null || _r === void 0 ? void 0 : _r[0]);
60499
+ })) === null || _o === void 0 ? void 0 : _o.participants) === null || _p === void 0 ? void 0 : _p[0]);
60437
60500
  if (pairParticipant) {
60438
- var individualParticipantIds = (_t = (_s = pairParticipant === null || pairParticipant === void 0 ? void 0 : pairParticipant.individualParticipantIds) === null || _s === void 0 ? void 0 : _s.filter(function (currentId) { return currentId !== participantId; })) !== null && _t !== void 0 ? _t : [];
60501
+ var individualParticipantIds = (_r = (_q = pairParticipant === null || pairParticipant === void 0 ? void 0 : pairParticipant.individualParticipantIds) === null || _q === void 0 ? void 0 : _q.filter(function (currentId) { return currentId !== participantId; })) !== null && _r !== void 0 ? _r : [];
60439
60502
  if (previousParticipantIds)
60440
60503
  individualParticipantIds.push.apply(individualParticipantIds, __spreadArray([], __read(previousParticipantIds), false));
60441
60504
  if (individualParticipantIds.length > 2) {
@@ -60445,7 +60508,7 @@ function removeTieMatchUpParticipantId(params) {
60445
60508
  });
60446
60509
  }
60447
60510
  // don't modify pair participant that is part of other events/draws
60448
- if (!((_u = pairParticipant.draws) === null || _u === void 0 ? void 0 : _u.length)) {
60511
+ if (!((_s = pairParticipant.draws) === null || _s === void 0 ? void 0 : _s.length)) {
60449
60512
  if (individualParticipantIds.length) {
60450
60513
  pairParticipant.individualParticipantIds = individualParticipantIds;
60451
60514
  var result = modifyParticipant({
@@ -60496,13 +60559,13 @@ function removeTieMatchUpParticipantId(params) {
60496
60559
  }
60497
60560
  }
60498
60561
  // if there was only one subsitution on target side and there are no substiutions on other side
60499
- if (((_v = side.substitutions) === null || _v === void 0 ? void 0 : _v.length) === 1) {
60500
- var otherSide = (_w = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _w === void 0 ? void 0 : _w.find(function (s) { return s.sideNumber !== side.sideNumber; });
60501
- if (!((_x = otherSide === null || otherSide === void 0 ? void 0 : otherSide.substitutions) === null || _x === void 0 ? void 0 : _x.length) && ((_y = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _y === void 0 ? void 0 : _y.length)) {
60562
+ if (((_t = side.substitutions) === null || _t === void 0 ? void 0 : _t.length) === 1) {
60563
+ var otherSide = (_u = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _u === void 0 ? void 0 : _u.find(function (s) { return s.sideNumber !== side.sideNumber; });
60564
+ if (!((_v = otherSide === null || otherSide === void 0 ? void 0 : otherSide.substitutions) === null || _v === void 0 ? void 0 : _v.length) && ((_w = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _w === void 0 ? void 0 : _w.length)) {
60502
60565
  try {
60503
60566
  // remove processCode(s)
60504
- for (var _0 = __values(substitutionProcessCodes || []), _1 = _0.next(); !_1.done; _1 = _0.next()) {
60505
- var substitutionProcessCode = _1.value;
60567
+ for (var _y = __values(substitutionProcessCodes || []), _z = _y.next(); !_z.done; _z = _y.next()) {
60568
+ var substitutionProcessCode = _z.value;
60506
60569
  var codeIndex = tieMatchUp.processCodes.lastIndexOf(substitutionProcessCode);
60507
60570
  // remove only one instance of substitutionProcessCode
60508
60571
  tieMatchUp.processCodes.splice(codeIndex, 1);
@@ -60511,7 +60574,7 @@ function removeTieMatchUpParticipantId(params) {
60511
60574
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
60512
60575
  finally {
60513
60576
  try {
60514
- if (_1 && !_1.done && (_a = _0.return)) _a.call(_0);
60577
+ if (_z && !_z.done && (_a = _y.return)) _a.call(_y);
60515
60578
  }
60516
60579
  finally { if (e_1) throw e_1.error; }
60517
60580
  }
@@ -62745,7 +62808,7 @@ function substituteParticipant$1(_a) {
62745
62808
  return { error: MISSING_MATCHUP_ID };
62746
62809
  if (!existingParticipantId || !substituteParticipantId)
62747
62810
  return decorateResult({ result: { error: MISSING_PARTICIPANT_ID }, stack: stack });
62748
- var matchUp = findMatchUp$1({
62811
+ var matchUp = findDrawMatchUp({
62749
62812
  drawDefinition: drawDefinition,
62750
62813
  matchUpId: matchUpId,
62751
62814
  event: event,
@@ -63385,7 +63448,7 @@ function applyLineUps(_a) {
63385
63448
  return { error: INVALID_VALUES, lineUps: lineUps };
63386
63449
  var stack = 'applyLineUps';
63387
63450
  var tournamentParticipants = tournamentRecord.participants || [];
63388
- var result = findMatchUp$1({
63451
+ var result = findDrawMatchUp({
63389
63452
  tournamentParticipants: tournamentParticipants,
63390
63453
  inContext: true,
63391
63454
  drawDefinition: drawDefinition,
@@ -63550,7 +63613,7 @@ function applyLineUps(_a) {
63550
63613
  }
63551
63614
  if (!Object.keys(sideAssignments).length)
63552
63615
  return { error: VALUE_UNCHANGED };
63553
- result = findMatchUp$1({ drawDefinition: drawDefinition, matchUpId: matchUpId });
63616
+ result = findDrawMatchUp({ drawDefinition: drawDefinition, matchUpId: matchUpId });
63554
63617
  if (result.error)
63555
63618
  return result;
63556
63619
  if (!result.matchUp)
@@ -65360,17 +65423,18 @@ function getEvents(_a) {
65360
65423
  var _c, _d, _e;
65361
65424
  var processParticipant = function (participant) {
65362
65425
  var e_12, _a;
65363
- var _b, _c, _d, _e, _f;
65364
- if ((_b = participant === null || participant === void 0 ? void 0 : participant.ratings) === null || _b === void 0 ? void 0 : _b[eventType]) {
65426
+ var _b, _c, _d, _e, _f, _g, _h;
65427
+ if (((_b = eventsMap[eventId].draws) === null || _b === void 0 ? void 0 : _b[drawId]) &&
65428
+ ((_c = participant === null || participant === void 0 ? void 0 : participant.ratings) === null || _c === void 0 ? void 0 : _c[eventType])) {
65365
65429
  try {
65366
- for (var _g = (e_12 = void 0, __values((_d = (_c = participant === null || participant === void 0 ? void 0 : participant.ratings) === null || _c === void 0 ? void 0 : _c[eventType]) !== null && _d !== void 0 ? _d : [])), _h = _g.next(); !_h.done; _h = _g.next()) {
65367
- var rating = _h.value;
65430
+ for (var _j = (e_12 = void 0, __values((_e = (_d = participant === null || participant === void 0 ? void 0 : participant.ratings) === null || _d === void 0 ? void 0 : _d[eventType]) !== null && _e !== void 0 ? _e : [])), _k = _j.next(); !_k.done; _k = _j.next()) {
65431
+ var rating = _k.value;
65368
65432
  var scaleName = rating.scaleName;
65369
- if (!eventsMap[eventId].draws[drawId].ratings[scaleName])
65433
+ if (!((_f = eventsMap[eventId].draws[drawId]) === null || _f === void 0 ? void 0 : _f.ratings[scaleName]))
65370
65434
  eventsMap[eventId].draws[drawId].ratings[scaleName] = [];
65371
- var accessor = (_e = ratingsParameters[scaleName]) === null || _e === void 0 ? void 0 : _e.accessor;
65435
+ var accessor = (_g = ratingsParameters[scaleName]) === null || _g === void 0 ? void 0 : _g.accessor;
65372
65436
  if (accessor) {
65373
- var value = parseFloat((_f = rating.scaleValue) === null || _f === void 0 ? void 0 : _f[accessor]);
65437
+ var value = parseFloat((_h = rating.scaleValue) === null || _h === void 0 ? void 0 : _h[accessor]);
65374
65438
  if (value) {
65375
65439
  eventsMap[eventId].draws[drawId].ratings[scaleName].push(value);
65376
65440
  }
@@ -65380,7 +65444,7 @@ function getEvents(_a) {
65380
65444
  catch (e_12_1) { e_12 = { error: e_12_1 }; }
65381
65445
  finally {
65382
65446
  try {
65383
- if (_h && !_h.done && (_a = _g.return)) _a.call(_g);
65447
+ if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
65384
65448
  }
65385
65449
  finally { if (e_12) throw e_12.error; }
65386
65450
  }
@@ -70675,6 +70739,7 @@ var utilities = {
70675
70739
  unique: unique,
70676
70740
  UUID: UUID,
70677
70741
  UUIDS: UUIDS,
70742
+ validateCategory: validateCategory,
70678
70743
  validateTieFormat: validateTieFormat,
70679
70744
  visualizeScheduledMatchUps: visualizeScheduledMatchUps,
70680
70745
  };