tods-competition-factory 1.8.18 → 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.
- package/dist/forge/generate.mjs +92 -20
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +3 -3
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +238 -166
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +533 -493
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +463 -398
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2382,7 +2382,7 @@ const matchUpFormatCode = {
|
|
|
2382
2382
|
};
|
|
2383
2383
|
|
|
2384
2384
|
function factoryVersion() {
|
|
2385
|
-
return "1.8.
|
|
2385
|
+
return "1.8.19";
|
|
2386
2386
|
}
|
|
2387
2387
|
|
|
2388
2388
|
function getObjectTieFormat(obj) {
|
|
@@ -2616,28 +2616,76 @@ function getCategoryAgeDetails(params) {
|
|
|
2616
2616
|
return result;
|
|
2617
2617
|
}
|
|
2618
2618
|
|
|
2619
|
+
function decorateResult({
|
|
2620
|
+
context,
|
|
2621
|
+
result,
|
|
2622
|
+
stack,
|
|
2623
|
+
info
|
|
2624
|
+
}) {
|
|
2625
|
+
if (result && !Array.isArray(result?.stack))
|
|
2626
|
+
result.stack = [];
|
|
2627
|
+
if (result && Array.isArray(result?.stack) && typeof stack === "string") {
|
|
2628
|
+
result.stack.push(stack);
|
|
2629
|
+
}
|
|
2630
|
+
if (result && info) {
|
|
2631
|
+
result.info = info;
|
|
2632
|
+
}
|
|
2633
|
+
if (result && typeof context === "object" && Object.keys(context).length) {
|
|
2634
|
+
Object.assign(result, definedAttributes(context));
|
|
2635
|
+
}
|
|
2636
|
+
if (result && !result?.error && !result?.success) {
|
|
2637
|
+
Object.assign(result, { ...SUCCESS });
|
|
2638
|
+
}
|
|
2639
|
+
return result ?? { success: true };
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
function validateCategory({ category }) {
|
|
2643
|
+
if (!isObject(category))
|
|
2644
|
+
return { error: INVALID_VALUES };
|
|
2645
|
+
const categoryDetails = getCategoryAgeDetails({ category });
|
|
2646
|
+
if (categoryDetails.error)
|
|
2647
|
+
return { error: categoryDetails };
|
|
2648
|
+
const { ratingMax, ratingMin } = category;
|
|
2649
|
+
if (ratingMax && !isNumeric(ratingMax))
|
|
2650
|
+
return decorateResult({
|
|
2651
|
+
result: { error: INVALID_VALUES },
|
|
2652
|
+
context: { ratingMax }
|
|
2653
|
+
});
|
|
2654
|
+
if (ratingMin && !isNumeric(ratingMin))
|
|
2655
|
+
return decorateResult({
|
|
2656
|
+
result: { error: INVALID_VALUES },
|
|
2657
|
+
context: { ratingMin }
|
|
2658
|
+
});
|
|
2659
|
+
return { ...categoryDetails };
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2619
2662
|
function categoryCanContain({
|
|
2620
2663
|
childCategory,
|
|
2621
2664
|
withDetails,
|
|
2622
2665
|
category
|
|
2623
2666
|
}) {
|
|
2624
|
-
const categoryDetails =
|
|
2625
|
-
const childCategoryDetails =
|
|
2667
|
+
const categoryDetails = validateCategory({ category });
|
|
2668
|
+
const childCategoryDetails = validateCategory({
|
|
2626
2669
|
category: childCategory
|
|
2627
2670
|
});
|
|
2628
2671
|
const invalidAgeMin = childCategoryDetails.ageMin && (categoryDetails.ageMin && childCategoryDetails.ageMin < categoryDetails.ageMin || categoryDetails.ageMax && childCategoryDetails.ageMin > categoryDetails.ageMax);
|
|
2629
2672
|
const invalidAgeMax = childCategoryDetails.ageMax && (categoryDetails.ageMax && childCategoryDetails.ageMax > categoryDetails.ageMax || categoryDetails.ageMin && childCategoryDetails.ageMax < categoryDetails.ageMin);
|
|
2630
2673
|
const invalidAgeMinDate = childCategoryDetails.ageMinDate && categoryDetails.ageMaxDate && new Date(childCategoryDetails.ageMinDate) > new Date(categoryDetails.ageMaxDate);
|
|
2631
2674
|
const invalidAgeMaxDate = childCategoryDetails.ageMaxDate && categoryDetails.ageMinDate && new Date(childCategoryDetails.ageMaxDate) < new Date(categoryDetails.ageMinDate);
|
|
2632
|
-
const
|
|
2675
|
+
const ratingComparison = category.ratingType && childCategory.ratingType && category.ratingType === childCategory.ratingType;
|
|
2676
|
+
const invalidRatingRange = ratingComparison && (category.ratingMin && childCategory.ratingMin && childCategory.ratingMin < category.ratingMin || category.ratingMax && childCategory.ratingMax && childCategory.ratingMax > category.ratingMax || category.ratingMin && childCategory.ratingMax && childCategory.ratingMax < category.ratingMin || category.ratingMax && childCategory.ratingMin && childCategory.ratingMin > category.ratingMax);
|
|
2677
|
+
const invalidBallType = category.ballType && childCategory.ballType && category.ballType !== childCategory.ballType;
|
|
2678
|
+
const valid = !invalidRatingRange && !invalidAgeMinDate && !invalidAgeMaxDate && !invalidBallType && !invalidAgeMax && !invalidAgeMin;
|
|
2633
2679
|
const ignoreFalse = true;
|
|
2634
2680
|
const result = definedAttributes(
|
|
2635
2681
|
{
|
|
2636
|
-
|
|
2682
|
+
invalidRatingRange,
|
|
2683
|
+
invalidAgeMinDate,
|
|
2684
|
+
invalidAgeMaxDate,
|
|
2685
|
+
invalidBallType,
|
|
2637
2686
|
invalidAgeMax,
|
|
2638
2687
|
invalidAgeMin,
|
|
2639
|
-
|
|
2640
|
-
invalidAgeMaxDate
|
|
2688
|
+
valid
|
|
2641
2689
|
},
|
|
2642
2690
|
ignoreFalse
|
|
2643
2691
|
);
|
|
@@ -2651,29 +2699,6 @@ function mustBeAnArray(value) {
|
|
|
2651
2699
|
return `${value} must be an array`;
|
|
2652
2700
|
}
|
|
2653
2701
|
|
|
2654
|
-
function decorateResult({
|
|
2655
|
-
context,
|
|
2656
|
-
result,
|
|
2657
|
-
stack,
|
|
2658
|
-
info
|
|
2659
|
-
}) {
|
|
2660
|
-
if (result && !Array.isArray(result?.stack))
|
|
2661
|
-
result.stack = [];
|
|
2662
|
-
if (result && Array.isArray(result?.stack) && typeof stack === "string") {
|
|
2663
|
-
result.stack.push(stack);
|
|
2664
|
-
}
|
|
2665
|
-
if (result && info) {
|
|
2666
|
-
result.info = info;
|
|
2667
|
-
}
|
|
2668
|
-
if (result && typeof context === "object" && Object.keys(context).length) {
|
|
2669
|
-
Object.assign(result, definedAttributes(context));
|
|
2670
|
-
}
|
|
2671
|
-
if (result && !result?.error && !result?.success) {
|
|
2672
|
-
Object.assign(result, { ...SUCCESS });
|
|
2673
|
-
}
|
|
2674
|
-
return result ?? { success: true };
|
|
2675
|
-
}
|
|
2676
|
-
|
|
2677
2702
|
var DrawTypeEnum = /* @__PURE__ */ ((DrawTypeEnum2) => {
|
|
2678
2703
|
DrawTypeEnum2["AdHoc"] = "AD_HOC";
|
|
2679
2704
|
DrawTypeEnum2["Compass"] = "COMPASS";
|
|
@@ -4206,142 +4231,6 @@ function tallyParticipantResults({
|
|
|
4206
4231
|
return result;
|
|
4207
4232
|
}
|
|
4208
4233
|
|
|
4209
|
-
function evaluateCollectionResult({
|
|
4210
|
-
collectionDefinition,
|
|
4211
|
-
groupValueNumbers,
|
|
4212
|
-
groupValueGroups,
|
|
4213
|
-
sideTieValues,
|
|
4214
|
-
tieMatchUps
|
|
4215
|
-
}) {
|
|
4216
|
-
const collectionMatchUps = tieMatchUps.filter(
|
|
4217
|
-
(matchUp) => matchUp.collectionId === collectionDefinition.collectionId
|
|
4218
|
-
);
|
|
4219
|
-
const sideMatchUpValues = [0, 0];
|
|
4220
|
-
let sideCollectionValues = [0, 0];
|
|
4221
|
-
const allCollectionMatchUpsCompleted = collectionMatchUps.every(
|
|
4222
|
-
(matchUp) => completedMatchUpStatuses.includes(matchUp.matchUpStatus)
|
|
4223
|
-
);
|
|
4224
|
-
const {
|
|
4225
|
-
collectionValueProfiles,
|
|
4226
|
-
collectionGroupNumber,
|
|
4227
|
-
collectionValue,
|
|
4228
|
-
matchUpValue,
|
|
4229
|
-
winCriteria,
|
|
4230
|
-
scoreValue,
|
|
4231
|
-
setValue
|
|
4232
|
-
} = collectionDefinition;
|
|
4233
|
-
const belongsToValueGroup = collectionGroupNumber && groupValueNumbers.includes(collectionGroupNumber);
|
|
4234
|
-
const sideWins = [0, 0];
|
|
4235
|
-
collectionMatchUps.forEach((matchUp) => {
|
|
4236
|
-
if (matchUp.winningSide)
|
|
4237
|
-
sideWins[matchUp.winningSide - 1] += 1;
|
|
4238
|
-
});
|
|
4239
|
-
if (isConvertableInteger(matchUpValue)) {
|
|
4240
|
-
collectionMatchUps.forEach((matchUp) => {
|
|
4241
|
-
if (matchUp.winningSide) {
|
|
4242
|
-
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
|
|
4243
|
-
}
|
|
4244
|
-
});
|
|
4245
|
-
} else if (isConvertableInteger(setValue)) {
|
|
4246
|
-
collectionMatchUps.forEach((matchUp) => {
|
|
4247
|
-
matchUp.score?.sets?.forEach((set) => {
|
|
4248
|
-
if (set.winningSide)
|
|
4249
|
-
sideMatchUpValues[set.winningSide - 1] += setValue;
|
|
4250
|
-
});
|
|
4251
|
-
});
|
|
4252
|
-
} else if (isConvertableInteger(scoreValue)) {
|
|
4253
|
-
collectionMatchUps.forEach((matchUp) => {
|
|
4254
|
-
matchUp.score?.sets?.forEach((set) => {
|
|
4255
|
-
const {
|
|
4256
|
-
side1TiebreakScore = 0,
|
|
4257
|
-
side2TiebreakScore = 0,
|
|
4258
|
-
side1Score = 0,
|
|
4259
|
-
side2Score = 0
|
|
4260
|
-
} = set;
|
|
4261
|
-
if (matchUp.matchUpStatus === COMPLETED$1 || matchUp.winningSide || set.winningSide) {
|
|
4262
|
-
if (side1Score || side2Score) {
|
|
4263
|
-
sideMatchUpValues[0] += side1Score;
|
|
4264
|
-
sideMatchUpValues[1] += side2Score;
|
|
4265
|
-
} else if ((side1TiebreakScore || side2TiebreakScore) && set.winningSide) {
|
|
4266
|
-
sideMatchUpValues[set.winningSide - 1] += 1;
|
|
4267
|
-
}
|
|
4268
|
-
}
|
|
4269
|
-
});
|
|
4270
|
-
});
|
|
4271
|
-
} else if (Array.isArray(collectionValueProfiles)) {
|
|
4272
|
-
collectionMatchUps.forEach((matchUp) => {
|
|
4273
|
-
if (matchUp.winningSide) {
|
|
4274
|
-
const collectionPosition = matchUp.collectionPosition;
|
|
4275
|
-
const matchUpValue2 = getCollectionPositionValue({
|
|
4276
|
-
collectionDefinition,
|
|
4277
|
-
collectionPosition
|
|
4278
|
-
});
|
|
4279
|
-
if (isConvertableInteger(matchUpValue2)) {
|
|
4280
|
-
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue2;
|
|
4281
|
-
}
|
|
4282
|
-
}
|
|
4283
|
-
});
|
|
4284
|
-
}
|
|
4285
|
-
if (isConvertableInteger(collectionValue)) {
|
|
4286
|
-
let collectionWinningSide;
|
|
4287
|
-
if (winCriteria?.aggregateValue) {
|
|
4288
|
-
if (allCollectionMatchUpsCompleted) {
|
|
4289
|
-
if (isConvertableInteger(matchUpValue || setValue || scoreValue) && sideMatchUpValues[0] !== sideMatchUpValues[1]) {
|
|
4290
|
-
collectionWinningSide = sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
|
|
4291
|
-
} else if (sideWins[0] !== sideWins[1]) {
|
|
4292
|
-
collectionWinningSide = sideWins[0] > sideWins[1] ? 1 : 2;
|
|
4293
|
-
}
|
|
4294
|
-
}
|
|
4295
|
-
} else if (winCriteria?.valueGoal) {
|
|
4296
|
-
collectionWinningSide = sideMatchUpValues.reduce(
|
|
4297
|
-
(winningSide, side, i) => {
|
|
4298
|
-
return side >= winCriteria.valueGoal ? i + 1 : winningSide;
|
|
4299
|
-
},
|
|
4300
|
-
0
|
|
4301
|
-
);
|
|
4302
|
-
} else {
|
|
4303
|
-
const winGoal = Math.floor(collectionDefinition.matchUpCount / 2) + 1;
|
|
4304
|
-
collectionWinningSide = sideWins.reduce((winningSide, side, i) => {
|
|
4305
|
-
return side >= winGoal ? i + 1 : winningSide;
|
|
4306
|
-
}, 0);
|
|
4307
|
-
}
|
|
4308
|
-
if (collectionWinningSide) {
|
|
4309
|
-
if (belongsToValueGroup) {
|
|
4310
|
-
groupValueGroups[collectionGroupNumber].values[collectionWinningSide - 1] += collectionValue;
|
|
4311
|
-
} else {
|
|
4312
|
-
sideCollectionValues[collectionWinningSide - 1] += collectionValue;
|
|
4313
|
-
}
|
|
4314
|
-
}
|
|
4315
|
-
} else {
|
|
4316
|
-
if (belongsToValueGroup) {
|
|
4317
|
-
groupValueGroups[collectionGroupNumber].values[0] += sideMatchUpValues[0] || 0;
|
|
4318
|
-
groupValueGroups[collectionGroupNumber].values[1] += sideMatchUpValues[1] || 0;
|
|
4319
|
-
} else {
|
|
4320
|
-
sideCollectionValues = sideMatchUpValues;
|
|
4321
|
-
}
|
|
4322
|
-
}
|
|
4323
|
-
if (!belongsToValueGroup) {
|
|
4324
|
-
sideCollectionValues.forEach(
|
|
4325
|
-
(sideCollectionValue, i) => sideTieValues[i] += sideCollectionValue || 0
|
|
4326
|
-
);
|
|
4327
|
-
} else {
|
|
4328
|
-
groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
|
|
4329
|
-
groupValueGroups[collectionGroupNumber].sideWins[1] += sideWins[1] || 0;
|
|
4330
|
-
groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted = groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted && allCollectionMatchUpsCompleted;
|
|
4331
|
-
groupValueGroups[collectionGroupNumber].matchUpsCount += collectionMatchUps.length;
|
|
4332
|
-
}
|
|
4333
|
-
}
|
|
4334
|
-
function getCollectionPositionValue({
|
|
4335
|
-
collectionDefinition,
|
|
4336
|
-
collectionPosition
|
|
4337
|
-
}) {
|
|
4338
|
-
const collectionValueProfiles = collectionDefinition.collectionValueProfiles || [];
|
|
4339
|
-
const profile = collectionValueProfiles?.find(
|
|
4340
|
-
(profile2) => profile2.collectionPosition === collectionPosition
|
|
4341
|
-
);
|
|
4342
|
-
return profile?.matchUpValue;
|
|
4343
|
-
}
|
|
4344
|
-
|
|
4345
4234
|
const APPLIED_POLICIES = "appliedPolicies";
|
|
4346
4235
|
const AUDIT_POSITION_ACTIONS = "positionActions";
|
|
4347
4236
|
const CONTEXT = "context";
|
|
@@ -8534,11 +8423,13 @@ function getAllStructureMatchUps({
|
|
|
8534
8423
|
}
|
|
8535
8424
|
}
|
|
8536
8425
|
|
|
8537
|
-
function
|
|
8426
|
+
function publicFindDrawMatchUp(params) {
|
|
8538
8427
|
Object.assign(params, { inContext: true });
|
|
8539
|
-
return {
|
|
8428
|
+
return {
|
|
8429
|
+
matchUp: makeDeepCopy(findDrawMatchUp(params).matchUp, false, true)
|
|
8430
|
+
};
|
|
8540
8431
|
}
|
|
8541
|
-
function
|
|
8432
|
+
function findDrawMatchUp({
|
|
8542
8433
|
tournamentParticipants,
|
|
8543
8434
|
afterRecoveryTimes,
|
|
8544
8435
|
contextContent,
|
|
@@ -8579,6 +8470,142 @@ function findMatchUp$1({
|
|
|
8579
8470
|
return { error: MATCHUP_NOT_FOUND };
|
|
8580
8471
|
}
|
|
8581
8472
|
|
|
8473
|
+
function evaluateCollectionResult({
|
|
8474
|
+
collectionDefinition,
|
|
8475
|
+
groupValueNumbers,
|
|
8476
|
+
groupValueGroups,
|
|
8477
|
+
sideTieValues,
|
|
8478
|
+
tieMatchUps
|
|
8479
|
+
}) {
|
|
8480
|
+
const collectionMatchUps = tieMatchUps.filter(
|
|
8481
|
+
(matchUp) => matchUp.collectionId === collectionDefinition.collectionId
|
|
8482
|
+
);
|
|
8483
|
+
const sideMatchUpValues = [0, 0];
|
|
8484
|
+
let sideCollectionValues = [0, 0];
|
|
8485
|
+
const allCollectionMatchUpsCompleted = collectionMatchUps.every(
|
|
8486
|
+
(matchUp) => completedMatchUpStatuses.includes(matchUp.matchUpStatus)
|
|
8487
|
+
);
|
|
8488
|
+
const {
|
|
8489
|
+
collectionValueProfiles,
|
|
8490
|
+
collectionGroupNumber,
|
|
8491
|
+
collectionValue,
|
|
8492
|
+
matchUpValue,
|
|
8493
|
+
winCriteria,
|
|
8494
|
+
scoreValue,
|
|
8495
|
+
setValue
|
|
8496
|
+
} = collectionDefinition;
|
|
8497
|
+
const belongsToValueGroup = collectionGroupNumber && groupValueNumbers.includes(collectionGroupNumber);
|
|
8498
|
+
const sideWins = [0, 0];
|
|
8499
|
+
collectionMatchUps.forEach((matchUp) => {
|
|
8500
|
+
if (matchUp.winningSide)
|
|
8501
|
+
sideWins[matchUp.winningSide - 1] += 1;
|
|
8502
|
+
});
|
|
8503
|
+
if (isConvertableInteger(matchUpValue)) {
|
|
8504
|
+
collectionMatchUps.forEach((matchUp) => {
|
|
8505
|
+
if (matchUp.winningSide) {
|
|
8506
|
+
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
|
|
8507
|
+
}
|
|
8508
|
+
});
|
|
8509
|
+
} else if (isConvertableInteger(setValue)) {
|
|
8510
|
+
collectionMatchUps.forEach((matchUp) => {
|
|
8511
|
+
matchUp.score?.sets?.forEach((set) => {
|
|
8512
|
+
if (set.winningSide)
|
|
8513
|
+
sideMatchUpValues[set.winningSide - 1] += setValue;
|
|
8514
|
+
});
|
|
8515
|
+
});
|
|
8516
|
+
} else if (isConvertableInteger(scoreValue)) {
|
|
8517
|
+
collectionMatchUps.forEach((matchUp) => {
|
|
8518
|
+
matchUp.score?.sets?.forEach((set) => {
|
|
8519
|
+
const {
|
|
8520
|
+
side1TiebreakScore = 0,
|
|
8521
|
+
side2TiebreakScore = 0,
|
|
8522
|
+
side1Score = 0,
|
|
8523
|
+
side2Score = 0
|
|
8524
|
+
} = set;
|
|
8525
|
+
if (matchUp.matchUpStatus === COMPLETED$1 || matchUp.winningSide || set.winningSide) {
|
|
8526
|
+
if (side1Score || side2Score) {
|
|
8527
|
+
sideMatchUpValues[0] += side1Score;
|
|
8528
|
+
sideMatchUpValues[1] += side2Score;
|
|
8529
|
+
} else if ((side1TiebreakScore || side2TiebreakScore) && set.winningSide) {
|
|
8530
|
+
sideMatchUpValues[set.winningSide - 1] += 1;
|
|
8531
|
+
}
|
|
8532
|
+
}
|
|
8533
|
+
});
|
|
8534
|
+
});
|
|
8535
|
+
} else if (Array.isArray(collectionValueProfiles)) {
|
|
8536
|
+
collectionMatchUps.forEach((matchUp) => {
|
|
8537
|
+
if (matchUp.winningSide) {
|
|
8538
|
+
const collectionPosition = matchUp.collectionPosition;
|
|
8539
|
+
const matchUpValue2 = getCollectionPositionValue({
|
|
8540
|
+
collectionDefinition,
|
|
8541
|
+
collectionPosition
|
|
8542
|
+
});
|
|
8543
|
+
if (isConvertableInteger(matchUpValue2)) {
|
|
8544
|
+
sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue2;
|
|
8545
|
+
}
|
|
8546
|
+
}
|
|
8547
|
+
});
|
|
8548
|
+
}
|
|
8549
|
+
if (isConvertableInteger(collectionValue)) {
|
|
8550
|
+
let collectionWinningSide;
|
|
8551
|
+
if (winCriteria?.aggregateValue) {
|
|
8552
|
+
if (allCollectionMatchUpsCompleted) {
|
|
8553
|
+
if (isConvertableInteger(matchUpValue || setValue || scoreValue) && sideMatchUpValues[0] !== sideMatchUpValues[1]) {
|
|
8554
|
+
collectionWinningSide = sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
|
|
8555
|
+
} else if (sideWins[0] !== sideWins[1]) {
|
|
8556
|
+
collectionWinningSide = sideWins[0] > sideWins[1] ? 1 : 2;
|
|
8557
|
+
}
|
|
8558
|
+
}
|
|
8559
|
+
} else if (winCriteria?.valueGoal) {
|
|
8560
|
+
collectionWinningSide = sideMatchUpValues.reduce(
|
|
8561
|
+
(winningSide, side, i) => {
|
|
8562
|
+
return side >= winCriteria.valueGoal ? i + 1 : winningSide;
|
|
8563
|
+
},
|
|
8564
|
+
0
|
|
8565
|
+
);
|
|
8566
|
+
} else {
|
|
8567
|
+
const winGoal = Math.floor(collectionDefinition.matchUpCount / 2) + 1;
|
|
8568
|
+
collectionWinningSide = sideWins.reduce((winningSide, side, i) => {
|
|
8569
|
+
return side >= winGoal ? i + 1 : winningSide;
|
|
8570
|
+
}, 0);
|
|
8571
|
+
}
|
|
8572
|
+
if (collectionWinningSide) {
|
|
8573
|
+
if (belongsToValueGroup) {
|
|
8574
|
+
groupValueGroups[collectionGroupNumber].values[collectionWinningSide - 1] += collectionValue;
|
|
8575
|
+
} else {
|
|
8576
|
+
sideCollectionValues[collectionWinningSide - 1] += collectionValue;
|
|
8577
|
+
}
|
|
8578
|
+
}
|
|
8579
|
+
} else {
|
|
8580
|
+
if (belongsToValueGroup) {
|
|
8581
|
+
groupValueGroups[collectionGroupNumber].values[0] += sideMatchUpValues[0] || 0;
|
|
8582
|
+
groupValueGroups[collectionGroupNumber].values[1] += sideMatchUpValues[1] || 0;
|
|
8583
|
+
} else {
|
|
8584
|
+
sideCollectionValues = sideMatchUpValues;
|
|
8585
|
+
}
|
|
8586
|
+
}
|
|
8587
|
+
if (!belongsToValueGroup) {
|
|
8588
|
+
sideCollectionValues.forEach(
|
|
8589
|
+
(sideCollectionValue, i) => sideTieValues[i] += sideCollectionValue || 0
|
|
8590
|
+
);
|
|
8591
|
+
} else {
|
|
8592
|
+
groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
|
|
8593
|
+
groupValueGroups[collectionGroupNumber].sideWins[1] += sideWins[1] || 0;
|
|
8594
|
+
groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted = groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted && allCollectionMatchUpsCompleted;
|
|
8595
|
+
groupValueGroups[collectionGroupNumber].matchUpsCount += collectionMatchUps.length;
|
|
8596
|
+
}
|
|
8597
|
+
}
|
|
8598
|
+
function getCollectionPositionValue({
|
|
8599
|
+
collectionDefinition,
|
|
8600
|
+
collectionPosition
|
|
8601
|
+
}) {
|
|
8602
|
+
const collectionValueProfiles = collectionDefinition.collectionValueProfiles || [];
|
|
8603
|
+
const profile = collectionValueProfiles?.find(
|
|
8604
|
+
(profile2) => profile2.collectionPosition === collectionPosition
|
|
8605
|
+
);
|
|
8606
|
+
return profile?.matchUpValue;
|
|
8607
|
+
}
|
|
8608
|
+
|
|
8582
8609
|
function getGroupValueGroups({
|
|
8583
8610
|
collectionGroups = []
|
|
8584
8611
|
}) {
|
|
@@ -8692,7 +8719,7 @@ function generateTieMatchUpScore(params) {
|
|
|
8692
8719
|
}
|
|
8693
8720
|
if (!winningSide && tallyDirectives) {
|
|
8694
8721
|
const matchUpId = matchUp.matchUpId;
|
|
8695
|
-
const inContextMatchUp = matchUp.hasContext ? matchUp : matchUpsMap?.drawMatchUps?.[matchUpId] || drawDefinition &&
|
|
8722
|
+
const inContextMatchUp = matchUp.hasContext ? matchUp : matchUpsMap?.drawMatchUps?.[matchUpId] || drawDefinition && findDrawMatchUp({
|
|
8696
8723
|
inContext: true,
|
|
8697
8724
|
drawDefinition,
|
|
8698
8725
|
matchUpId
|
|
@@ -8720,6 +8747,247 @@ function generateTieMatchUpScore(params) {
|
|
|
8720
8747
|
};
|
|
8721
8748
|
}
|
|
8722
8749
|
|
|
8750
|
+
function drawUpdatedAt(drawDefinition, structureIds) {
|
|
8751
|
+
if (!drawDefinition)
|
|
8752
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
8753
|
+
let timeStamp = Date.now();
|
|
8754
|
+
if (drawDefinition.updatedAt && timeStamp === new Date(drawDefinition.updatedAt).getTime())
|
|
8755
|
+
timeStamp += 1;
|
|
8756
|
+
const updatedAt = new Date(timeStamp).toISOString();
|
|
8757
|
+
const relevantStructureIds = structureIds?.filter(Boolean);
|
|
8758
|
+
drawDefinition.updatedAt = updatedAt;
|
|
8759
|
+
drawDefinition.structures?.filter(Boolean).forEach((structure) => {
|
|
8760
|
+
if (!relevantStructureIds?.length || relevantStructureIds?.includes(structure.structureId)) {
|
|
8761
|
+
structure.updatedAt = updatedAt;
|
|
8762
|
+
}
|
|
8763
|
+
});
|
|
8764
|
+
return { ...SUCCESS };
|
|
8765
|
+
}
|
|
8766
|
+
function addMatchUpsNotice({
|
|
8767
|
+
drawDefinition,
|
|
8768
|
+
tournamentId,
|
|
8769
|
+
matchUps,
|
|
8770
|
+
eventId
|
|
8771
|
+
}) {
|
|
8772
|
+
if (drawDefinition)
|
|
8773
|
+
drawUpdatedAt(drawDefinition);
|
|
8774
|
+
addNotice({
|
|
8775
|
+
payload: { matchUps, tournamentId, eventId },
|
|
8776
|
+
topic: ADD_MATCHUPS
|
|
8777
|
+
});
|
|
8778
|
+
return { ...SUCCESS };
|
|
8779
|
+
}
|
|
8780
|
+
function deleteMatchUpsNotice({
|
|
8781
|
+
drawDefinition,
|
|
8782
|
+
tournamentId,
|
|
8783
|
+
matchUpIds,
|
|
8784
|
+
eventId,
|
|
8785
|
+
action
|
|
8786
|
+
}) {
|
|
8787
|
+
if (drawDefinition)
|
|
8788
|
+
drawUpdatedAt(drawDefinition);
|
|
8789
|
+
addNotice({
|
|
8790
|
+
topic: DELETED_MATCHUP_IDS,
|
|
8791
|
+
payload: {
|
|
8792
|
+
tournamentId,
|
|
8793
|
+
matchUpIds,
|
|
8794
|
+
eventId,
|
|
8795
|
+
action
|
|
8796
|
+
}
|
|
8797
|
+
});
|
|
8798
|
+
for (const matchUpId of matchUpIds) {
|
|
8799
|
+
deleteNotice({ key: matchUpId });
|
|
8800
|
+
}
|
|
8801
|
+
return { ...SUCCESS };
|
|
8802
|
+
}
|
|
8803
|
+
function modifyMatchUpNotice({
|
|
8804
|
+
drawDefinition,
|
|
8805
|
+
tournamentId,
|
|
8806
|
+
structureId,
|
|
8807
|
+
context,
|
|
8808
|
+
eventId,
|
|
8809
|
+
matchUp
|
|
8810
|
+
}) {
|
|
8811
|
+
if (!matchUp) {
|
|
8812
|
+
console.log(MISSING_MATCHUP);
|
|
8813
|
+
return { error: MISSING_MATCHUP };
|
|
8814
|
+
}
|
|
8815
|
+
if (drawDefinition) {
|
|
8816
|
+
const structureIds = structureId ? [structureId] : void 0;
|
|
8817
|
+
modifyDrawNotice({
|
|
8818
|
+
drawDefinition,
|
|
8819
|
+
structureIds,
|
|
8820
|
+
tournamentId,
|
|
8821
|
+
eventId
|
|
8822
|
+
});
|
|
8823
|
+
}
|
|
8824
|
+
addNotice({
|
|
8825
|
+
topic: MODIFY_MATCHUP,
|
|
8826
|
+
payload: { matchUp, tournamentId, context },
|
|
8827
|
+
key: matchUp.matchUpId
|
|
8828
|
+
});
|
|
8829
|
+
return { ...SUCCESS };
|
|
8830
|
+
}
|
|
8831
|
+
function updateInContextMatchUp({ tournamentId, inContextMatchUp }) {
|
|
8832
|
+
if (!inContextMatchUp) {
|
|
8833
|
+
return { error: MISSING_MATCHUP };
|
|
8834
|
+
}
|
|
8835
|
+
addNotice({
|
|
8836
|
+
payload: { inContextMatchUp, tournamentId },
|
|
8837
|
+
topic: UPDATE_INCONTEXT_MATCHUP,
|
|
8838
|
+
key: inContextMatchUp.matchUpId
|
|
8839
|
+
});
|
|
8840
|
+
return { ...SUCCESS };
|
|
8841
|
+
}
|
|
8842
|
+
function addDrawNotice({
|
|
8843
|
+
tournamentId,
|
|
8844
|
+
eventId,
|
|
8845
|
+
drawDefinition
|
|
8846
|
+
}) {
|
|
8847
|
+
if (!drawDefinition) {
|
|
8848
|
+
console.log(MISSING_DRAW_DEFINITION);
|
|
8849
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
8850
|
+
}
|
|
8851
|
+
drawUpdatedAt(drawDefinition);
|
|
8852
|
+
addNotice({
|
|
8853
|
+
payload: { drawDefinition, tournamentId, eventId },
|
|
8854
|
+
topic: ADD_DRAW_DEFINITION,
|
|
8855
|
+
key: drawDefinition.drawId
|
|
8856
|
+
});
|
|
8857
|
+
return { ...SUCCESS };
|
|
8858
|
+
}
|
|
8859
|
+
function deleteDrawNotice({
|
|
8860
|
+
tournamentId,
|
|
8861
|
+
eventId,
|
|
8862
|
+
drawId
|
|
8863
|
+
}) {
|
|
8864
|
+
addNotice({
|
|
8865
|
+
payload: { drawId, tournamentId, eventId },
|
|
8866
|
+
topic: DELETED_DRAW_IDS,
|
|
8867
|
+
key: drawId
|
|
8868
|
+
});
|
|
8869
|
+
deleteNotice({ key: drawId });
|
|
8870
|
+
return { ...SUCCESS };
|
|
8871
|
+
}
|
|
8872
|
+
function modifyDrawNotice({
|
|
8873
|
+
drawDefinition,
|
|
8874
|
+
tournamentId,
|
|
8875
|
+
structureIds,
|
|
8876
|
+
eventId
|
|
8877
|
+
}) {
|
|
8878
|
+
if (!drawDefinition) {
|
|
8879
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
8880
|
+
}
|
|
8881
|
+
drawUpdatedAt(drawDefinition, structureIds);
|
|
8882
|
+
addNotice({
|
|
8883
|
+
payload: { tournamentId, eventId, drawDefinition },
|
|
8884
|
+
topic: MODIFY_DRAW_DEFINITION,
|
|
8885
|
+
key: drawDefinition.drawId
|
|
8886
|
+
});
|
|
8887
|
+
return { ...SUCCESS };
|
|
8888
|
+
}
|
|
8889
|
+
function modifySeedAssignmentsNotice({
|
|
8890
|
+
drawDefinition,
|
|
8891
|
+
tournamentId,
|
|
8892
|
+
structure,
|
|
8893
|
+
eventId
|
|
8894
|
+
}) {
|
|
8895
|
+
if (!drawDefinition)
|
|
8896
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
8897
|
+
if (!structure)
|
|
8898
|
+
return { error: MISSING_STRUCTURE };
|
|
8899
|
+
const seedAssignments = structure.seedAssignments;
|
|
8900
|
+
const structureId = structure.structureId;
|
|
8901
|
+
const drawId = drawDefinition.drawId;
|
|
8902
|
+
addNotice({
|
|
8903
|
+
payload: { tournamentId, eventId, drawId, structureId, seedAssignments },
|
|
8904
|
+
topic: MODIFY_SEED_ASSIGNMENTS,
|
|
8905
|
+
key: drawDefinition.drawId
|
|
8906
|
+
});
|
|
8907
|
+
modifyDrawNotice({
|
|
8908
|
+
structureIds: [structureId],
|
|
8909
|
+
drawDefinition,
|
|
8910
|
+
tournamentId,
|
|
8911
|
+
eventId
|
|
8912
|
+
});
|
|
8913
|
+
return { ...SUCCESS };
|
|
8914
|
+
}
|
|
8915
|
+
function modifyPositionAssignmentsNotice({
|
|
8916
|
+
drawDefinition,
|
|
8917
|
+
tournamentId,
|
|
8918
|
+
structure,
|
|
8919
|
+
event
|
|
8920
|
+
}) {
|
|
8921
|
+
if (!drawDefinition)
|
|
8922
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
8923
|
+
if (!structure)
|
|
8924
|
+
return { error: MISSING_STRUCTURE };
|
|
8925
|
+
const positionAssignments = getPositionAssignments$1({ structure });
|
|
8926
|
+
const structureId = structure.structureId;
|
|
8927
|
+
const drawId = drawDefinition.drawId;
|
|
8928
|
+
const eventId = event?.eventId;
|
|
8929
|
+
addNotice({
|
|
8930
|
+
topic: MODIFY_POSITION_ASSIGNMENTS,
|
|
8931
|
+
payload: {
|
|
8932
|
+
positionAssignments,
|
|
8933
|
+
tournamentId,
|
|
8934
|
+
structureId,
|
|
8935
|
+
eventId,
|
|
8936
|
+
drawId
|
|
8937
|
+
},
|
|
8938
|
+
key: structureId
|
|
8939
|
+
});
|
|
8940
|
+
modifyDrawNotice({
|
|
8941
|
+
structureIds: [structureId],
|
|
8942
|
+
drawDefinition,
|
|
8943
|
+
tournamentId,
|
|
8944
|
+
eventId
|
|
8945
|
+
});
|
|
8946
|
+
return { ...SUCCESS };
|
|
8947
|
+
}
|
|
8948
|
+
|
|
8949
|
+
function ensureSideLineUps({
|
|
8950
|
+
inContextDualMatchUp,
|
|
8951
|
+
drawDefinition,
|
|
8952
|
+
tournamentId,
|
|
8953
|
+
dualMatchUp,
|
|
8954
|
+
eventId
|
|
8955
|
+
}) {
|
|
8956
|
+
if (dualMatchUp && !dualMatchUp?.sides?.length) {
|
|
8957
|
+
if (!inContextDualMatchUp) {
|
|
8958
|
+
inContextDualMatchUp = findDrawMatchUp({
|
|
8959
|
+
matchUpId: dualMatchUp.matchUpId,
|
|
8960
|
+
inContext: true,
|
|
8961
|
+
drawDefinition
|
|
8962
|
+
})?.matchUp;
|
|
8963
|
+
}
|
|
8964
|
+
const { extension } = findExtension$2({
|
|
8965
|
+
element: drawDefinition,
|
|
8966
|
+
name: LINEUPS
|
|
8967
|
+
});
|
|
8968
|
+
const lineUps = makeDeepCopy(extension?.value || {}, false, true);
|
|
8969
|
+
const extractSideDetail = ({
|
|
8970
|
+
displaySideNumber,
|
|
8971
|
+
drawPosition,
|
|
8972
|
+
sideNumber
|
|
8973
|
+
}) => ({ drawPosition, sideNumber, displaySideNumber });
|
|
8974
|
+
dualMatchUp.sides = inContextDualMatchUp?.sides?.map((side) => {
|
|
8975
|
+
const participantId = side.participantId;
|
|
8976
|
+
return {
|
|
8977
|
+
...extractSideDetail(side),
|
|
8978
|
+
lineUp: participantId && lineUps[participantId] || []
|
|
8979
|
+
};
|
|
8980
|
+
});
|
|
8981
|
+
modifyMatchUpNotice({
|
|
8982
|
+
context: "ensureSidLineUps",
|
|
8983
|
+
matchUp: dualMatchUp,
|
|
8984
|
+
drawDefinition,
|
|
8985
|
+
tournamentId,
|
|
8986
|
+
eventId
|
|
8987
|
+
});
|
|
8988
|
+
}
|
|
8989
|
+
}
|
|
8990
|
+
|
|
8723
8991
|
function copyTieFormat(tieFormat) {
|
|
8724
8992
|
if (!tieFormat)
|
|
8725
8993
|
return void 0;
|
|
@@ -8793,205 +9061,6 @@ function removeNotes(params) {
|
|
|
8793
9061
|
return { ...SUCCESS };
|
|
8794
9062
|
}
|
|
8795
9063
|
|
|
8796
|
-
function drawUpdatedAt(drawDefinition, structureIds) {
|
|
8797
|
-
if (!drawDefinition)
|
|
8798
|
-
return { error: MISSING_DRAW_DEFINITION };
|
|
8799
|
-
let timeStamp = Date.now();
|
|
8800
|
-
if (drawDefinition.updatedAt && timeStamp === new Date(drawDefinition.updatedAt).getTime())
|
|
8801
|
-
timeStamp += 1;
|
|
8802
|
-
const updatedAt = new Date(timeStamp).toISOString();
|
|
8803
|
-
const relevantStructureIds = structureIds?.filter(Boolean);
|
|
8804
|
-
drawDefinition.updatedAt = updatedAt;
|
|
8805
|
-
drawDefinition.structures?.filter(Boolean).forEach((structure) => {
|
|
8806
|
-
if (!relevantStructureIds?.length || relevantStructureIds?.includes(structure.structureId)) {
|
|
8807
|
-
structure.updatedAt = updatedAt;
|
|
8808
|
-
}
|
|
8809
|
-
});
|
|
8810
|
-
return { ...SUCCESS };
|
|
8811
|
-
}
|
|
8812
|
-
function addMatchUpsNotice({
|
|
8813
|
-
drawDefinition,
|
|
8814
|
-
tournamentId,
|
|
8815
|
-
matchUps,
|
|
8816
|
-
eventId
|
|
8817
|
-
}) {
|
|
8818
|
-
if (drawDefinition)
|
|
8819
|
-
drawUpdatedAt(drawDefinition);
|
|
8820
|
-
addNotice({
|
|
8821
|
-
payload: { matchUps, tournamentId, eventId },
|
|
8822
|
-
topic: ADD_MATCHUPS
|
|
8823
|
-
});
|
|
8824
|
-
return { ...SUCCESS };
|
|
8825
|
-
}
|
|
8826
|
-
function deleteMatchUpsNotice({
|
|
8827
|
-
drawDefinition,
|
|
8828
|
-
tournamentId,
|
|
8829
|
-
matchUpIds,
|
|
8830
|
-
eventId,
|
|
8831
|
-
action
|
|
8832
|
-
}) {
|
|
8833
|
-
if (drawDefinition)
|
|
8834
|
-
drawUpdatedAt(drawDefinition);
|
|
8835
|
-
addNotice({
|
|
8836
|
-
topic: DELETED_MATCHUP_IDS,
|
|
8837
|
-
payload: {
|
|
8838
|
-
tournamentId,
|
|
8839
|
-
matchUpIds,
|
|
8840
|
-
eventId,
|
|
8841
|
-
action
|
|
8842
|
-
}
|
|
8843
|
-
});
|
|
8844
|
-
for (const matchUpId of matchUpIds) {
|
|
8845
|
-
deleteNotice({ key: matchUpId });
|
|
8846
|
-
}
|
|
8847
|
-
return { ...SUCCESS };
|
|
8848
|
-
}
|
|
8849
|
-
function modifyMatchUpNotice({
|
|
8850
|
-
drawDefinition,
|
|
8851
|
-
tournamentId,
|
|
8852
|
-
structureId,
|
|
8853
|
-
context,
|
|
8854
|
-
eventId,
|
|
8855
|
-
matchUp
|
|
8856
|
-
}) {
|
|
8857
|
-
if (!matchUp) {
|
|
8858
|
-
console.log(MISSING_MATCHUP);
|
|
8859
|
-
return { error: MISSING_MATCHUP };
|
|
8860
|
-
}
|
|
8861
|
-
if (drawDefinition) {
|
|
8862
|
-
const structureIds = structureId ? [structureId] : void 0;
|
|
8863
|
-
modifyDrawNotice({
|
|
8864
|
-
drawDefinition,
|
|
8865
|
-
structureIds,
|
|
8866
|
-
tournamentId,
|
|
8867
|
-
eventId
|
|
8868
|
-
});
|
|
8869
|
-
}
|
|
8870
|
-
addNotice({
|
|
8871
|
-
topic: MODIFY_MATCHUP,
|
|
8872
|
-
payload: { matchUp, tournamentId, context },
|
|
8873
|
-
key: matchUp.matchUpId
|
|
8874
|
-
});
|
|
8875
|
-
return { ...SUCCESS };
|
|
8876
|
-
}
|
|
8877
|
-
function updateInContextMatchUp({ tournamentId, inContextMatchUp }) {
|
|
8878
|
-
if (!inContextMatchUp) {
|
|
8879
|
-
return { error: MISSING_MATCHUP };
|
|
8880
|
-
}
|
|
8881
|
-
addNotice({
|
|
8882
|
-
topic: UPDATE_INCONTEXT_MATCHUP,
|
|
8883
|
-
payload: { inContextMatchUp, tournamentId },
|
|
8884
|
-
key: inContextMatchUp.matchUpId
|
|
8885
|
-
});
|
|
8886
|
-
return { ...SUCCESS };
|
|
8887
|
-
}
|
|
8888
|
-
function addDrawNotice({
|
|
8889
|
-
tournamentId,
|
|
8890
|
-
eventId,
|
|
8891
|
-
drawDefinition
|
|
8892
|
-
}) {
|
|
8893
|
-
if (!drawDefinition) {
|
|
8894
|
-
console.log(MISSING_DRAW_DEFINITION);
|
|
8895
|
-
return { error: MISSING_DRAW_DEFINITION };
|
|
8896
|
-
}
|
|
8897
|
-
drawUpdatedAt(drawDefinition);
|
|
8898
|
-
addNotice({
|
|
8899
|
-
payload: { drawDefinition, tournamentId, eventId },
|
|
8900
|
-
topic: ADD_DRAW_DEFINITION,
|
|
8901
|
-
key: drawDefinition.drawId
|
|
8902
|
-
});
|
|
8903
|
-
return { ...SUCCESS };
|
|
8904
|
-
}
|
|
8905
|
-
function deleteDrawNotice({
|
|
8906
|
-
tournamentId,
|
|
8907
|
-
eventId,
|
|
8908
|
-
drawId
|
|
8909
|
-
}) {
|
|
8910
|
-
addNotice({
|
|
8911
|
-
payload: { drawId, tournamentId, eventId },
|
|
8912
|
-
topic: DELETED_DRAW_IDS,
|
|
8913
|
-
key: drawId
|
|
8914
|
-
});
|
|
8915
|
-
deleteNotice({ key: drawId });
|
|
8916
|
-
return { ...SUCCESS };
|
|
8917
|
-
}
|
|
8918
|
-
function modifyDrawNotice({
|
|
8919
|
-
drawDefinition,
|
|
8920
|
-
tournamentId,
|
|
8921
|
-
structureIds,
|
|
8922
|
-
eventId
|
|
8923
|
-
}) {
|
|
8924
|
-
if (!drawDefinition) {
|
|
8925
|
-
return { error: MISSING_DRAW_DEFINITION };
|
|
8926
|
-
}
|
|
8927
|
-
drawUpdatedAt(drawDefinition, structureIds);
|
|
8928
|
-
addNotice({
|
|
8929
|
-
payload: { tournamentId, eventId, drawDefinition },
|
|
8930
|
-
topic: MODIFY_DRAW_DEFINITION,
|
|
8931
|
-
key: drawDefinition.drawId
|
|
8932
|
-
});
|
|
8933
|
-
return { ...SUCCESS };
|
|
8934
|
-
}
|
|
8935
|
-
function modifySeedAssignmentsNotice({
|
|
8936
|
-
drawDefinition,
|
|
8937
|
-
tournamentId,
|
|
8938
|
-
structure,
|
|
8939
|
-
eventId
|
|
8940
|
-
}) {
|
|
8941
|
-
if (!drawDefinition)
|
|
8942
|
-
return { error: MISSING_DRAW_DEFINITION };
|
|
8943
|
-
if (!structure)
|
|
8944
|
-
return { error: MISSING_STRUCTURE };
|
|
8945
|
-
const seedAssignments = structure.seedAssignments;
|
|
8946
|
-
const structureId = structure.structureId;
|
|
8947
|
-
const drawId = drawDefinition.drawId;
|
|
8948
|
-
addNotice({
|
|
8949
|
-
payload: { tournamentId, eventId, drawId, structureId, seedAssignments },
|
|
8950
|
-
topic: MODIFY_SEED_ASSIGNMENTS,
|
|
8951
|
-
key: drawDefinition.drawId
|
|
8952
|
-
});
|
|
8953
|
-
modifyDrawNotice({
|
|
8954
|
-
structureIds: [structureId],
|
|
8955
|
-
drawDefinition,
|
|
8956
|
-
tournamentId,
|
|
8957
|
-
eventId
|
|
8958
|
-
});
|
|
8959
|
-
return { ...SUCCESS };
|
|
8960
|
-
}
|
|
8961
|
-
function modifyPositionAssignmentsNotice({
|
|
8962
|
-
drawDefinition,
|
|
8963
|
-
tournamentId,
|
|
8964
|
-
structure,
|
|
8965
|
-
event
|
|
8966
|
-
}) {
|
|
8967
|
-
if (!drawDefinition)
|
|
8968
|
-
return { error: MISSING_DRAW_DEFINITION };
|
|
8969
|
-
if (!structure)
|
|
8970
|
-
return { error: MISSING_STRUCTURE };
|
|
8971
|
-
const positionAssignments = getPositionAssignments$1({ structure });
|
|
8972
|
-
const structureId = structure.structureId;
|
|
8973
|
-
const drawId = drawDefinition.drawId;
|
|
8974
|
-
const eventId = event?.eventId;
|
|
8975
|
-
addNotice({
|
|
8976
|
-
topic: MODIFY_POSITION_ASSIGNMENTS,
|
|
8977
|
-
payload: {
|
|
8978
|
-
positionAssignments,
|
|
8979
|
-
tournamentId,
|
|
8980
|
-
structureId,
|
|
8981
|
-
eventId,
|
|
8982
|
-
drawId
|
|
8983
|
-
},
|
|
8984
|
-
key: structureId
|
|
8985
|
-
});
|
|
8986
|
-
modifyDrawNotice({
|
|
8987
|
-
structureIds: [structureId],
|
|
8988
|
-
drawDefinition,
|
|
8989
|
-
tournamentId,
|
|
8990
|
-
eventId
|
|
8991
|
-
});
|
|
8992
|
-
return { ...SUCCESS };
|
|
8993
|
-
}
|
|
8994
|
-
|
|
8995
9064
|
const hasParticipantId = (o) => o?.participantId;
|
|
8996
9065
|
|
|
8997
9066
|
function createSubOrderMap({ positionAssignments }) {
|
|
@@ -9975,7 +10044,7 @@ function modifyMatchUpScore({
|
|
|
9975
10044
|
const isDualMatchUp = matchUp.matchUpType === TEAM$2;
|
|
9976
10045
|
if (isDualMatchUp && drawDefinition) {
|
|
9977
10046
|
if (matchUpId && matchUp.matchUpId !== matchUpId) {
|
|
9978
|
-
const findResult =
|
|
10047
|
+
const findResult = findDrawMatchUp({
|
|
9979
10048
|
drawDefinition,
|
|
9980
10049
|
matchUpId,
|
|
9981
10050
|
event
|
|
@@ -10004,7 +10073,7 @@ function modifyMatchUpScore({
|
|
|
10004
10073
|
if (removeWinningSide)
|
|
10005
10074
|
matchUp.winningSide = void 0;
|
|
10006
10075
|
if (!structure && drawDefinition) {
|
|
10007
|
-
({ structure } =
|
|
10076
|
+
({ structure } = findDrawMatchUp({
|
|
10008
10077
|
drawDefinition,
|
|
10009
10078
|
matchUpId,
|
|
10010
10079
|
event
|
|
@@ -10120,7 +10189,7 @@ function updateTieMatchUpScore$1({
|
|
|
10120
10189
|
matchUpId,
|
|
10121
10190
|
event
|
|
10122
10191
|
}) {
|
|
10123
|
-
const result =
|
|
10192
|
+
const result = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
10124
10193
|
if (result.error)
|
|
10125
10194
|
return result;
|
|
10126
10195
|
if (!result.matchUp)
|
|
@@ -10128,6 +10197,12 @@ function updateTieMatchUpScore$1({
|
|
|
10128
10197
|
const { matchUp, structure } = result;
|
|
10129
10198
|
if (!matchUp.tieMatchUps)
|
|
10130
10199
|
return { error: INVALID_MATCHUP };
|
|
10200
|
+
ensureSideLineUps({
|
|
10201
|
+
tournamentId: tournamentRecord?.tournamentId,
|
|
10202
|
+
eventId: event?.eventId,
|
|
10203
|
+
dualMatchUp: matchUp,
|
|
10204
|
+
drawDefinition
|
|
10205
|
+
});
|
|
10131
10206
|
const { extension } = findExtension({
|
|
10132
10207
|
name: DISABLE_AUTO_CALC,
|
|
10133
10208
|
element: matchUp
|
|
@@ -19625,7 +19700,7 @@ function addMatchUpTimeItem({
|
|
|
19625
19700
|
timeItem,
|
|
19626
19701
|
event
|
|
19627
19702
|
}) {
|
|
19628
|
-
const { matchUp } =
|
|
19703
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
19629
19704
|
if (!matchUp)
|
|
19630
19705
|
return { error: MATCHUP_NOT_FOUND };
|
|
19631
19706
|
const result = addTimeItem({
|
|
@@ -19651,7 +19726,7 @@ function resetMatchUpTimeItems({
|
|
|
19651
19726
|
matchUpId,
|
|
19652
19727
|
event
|
|
19653
19728
|
}) {
|
|
19654
|
-
const { matchUp } =
|
|
19729
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
19655
19730
|
if (!matchUp)
|
|
19656
19731
|
return { error: MATCHUP_NOT_FOUND };
|
|
19657
19732
|
matchUp.timeItems = [];
|
|
@@ -19679,7 +19754,7 @@ function allocateTeamMatchUpCourts$1({
|
|
|
19679
19754
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
19680
19755
|
if (!matchUpId)
|
|
19681
19756
|
return { error: MISSING_MATCHUP_ID };
|
|
19682
|
-
const result =
|
|
19757
|
+
const result = findDrawMatchUp({
|
|
19683
19758
|
drawDefinition,
|
|
19684
19759
|
matchUpId
|
|
19685
19760
|
});
|
|
@@ -19837,7 +19912,7 @@ function addMatchUpScheduledTime$2(params) {
|
|
|
19837
19912
|
if (!validTimeValue(scheduledTime))
|
|
19838
19913
|
return decorateResult({ result: { error: INVALID_TIME }, stack });
|
|
19839
19914
|
if (!matchUp) {
|
|
19840
|
-
const result =
|
|
19915
|
+
const result = findDrawMatchUp({ drawDefinition, matchUpId });
|
|
19841
19916
|
if (result.error)
|
|
19842
19917
|
return decorateResult({ result, stack });
|
|
19843
19918
|
matchUp = result.matchUp;
|
|
@@ -19894,7 +19969,7 @@ function addMatchUpTimeModifiers({
|
|
|
19894
19969
|
stack
|
|
19895
19970
|
});
|
|
19896
19971
|
if (!matchUp) {
|
|
19897
|
-
const result =
|
|
19972
|
+
const result = findDrawMatchUp({ drawDefinition, matchUpId });
|
|
19898
19973
|
if (result.error)
|
|
19899
19974
|
return decorateResult({ result, stack });
|
|
19900
19975
|
matchUp = result.matchUp;
|
|
@@ -19968,7 +20043,7 @@ function addMatchUpScheduleItems$2({
|
|
|
19968
20043
|
const stack = "drawEngine.addMatchUpScheduleItems";
|
|
19969
20044
|
let matchUp, warning;
|
|
19970
20045
|
if (!drawMatchUps) {
|
|
19971
|
-
const result =
|
|
20046
|
+
const result = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
19972
20047
|
if (result.error)
|
|
19973
20048
|
return result;
|
|
19974
20049
|
matchUp = result.matchUp;
|
|
@@ -20263,7 +20338,7 @@ function addMatchUpStartTime$2({
|
|
|
20263
20338
|
return { error: MISSING_MATCHUP_ID };
|
|
20264
20339
|
if (!validTimeValue(startTime))
|
|
20265
20340
|
return { error: INVALID_TIME };
|
|
20266
|
-
const { matchUp } =
|
|
20341
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
20267
20342
|
const { scheduledDate } = scheduledMatchUpDate({ matchUp });
|
|
20268
20343
|
const timeItems = matchUp?.timeItems ?? [];
|
|
20269
20344
|
const earliestRelevantTimeValue = timeItems.filter(
|
|
@@ -20307,7 +20382,7 @@ function addMatchUpEndTime$2({
|
|
|
20307
20382
|
return { error: MISSING_MATCHUP_ID };
|
|
20308
20383
|
if (!validTimeValue(endTime))
|
|
20309
20384
|
return { error: INVALID_TIME };
|
|
20310
|
-
const { matchUp } =
|
|
20385
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
20311
20386
|
const { scheduledDate } = scheduledMatchUpDate({ matchUp });
|
|
20312
20387
|
const timeItems = matchUp?.timeItems ?? [];
|
|
20313
20388
|
const latestRelevantTimeValue = timeItems.filter(
|
|
@@ -20350,7 +20425,7 @@ function addMatchUpStopTime$2({
|
|
|
20350
20425
|
return { error: MISSING_MATCHUP_ID };
|
|
20351
20426
|
if (!validTimeValue(stopTime))
|
|
20352
20427
|
return { error: INVALID_TIME };
|
|
20353
|
-
const { matchUp } =
|
|
20428
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
20354
20429
|
const { scheduledDate } = scheduledMatchUpDate({ matchUp });
|
|
20355
20430
|
const timeItems = matchUp?.timeItems ?? [];
|
|
20356
20431
|
const hasEndTime = timeItems.reduce((hasEndTime2, timeItem) => {
|
|
@@ -20409,7 +20484,7 @@ function addMatchUpResumeTime$2({
|
|
|
20409
20484
|
return { error: MISSING_MATCHUP_ID };
|
|
20410
20485
|
if (!validTimeValue(resumeTime))
|
|
20411
20486
|
return { error: INVALID_TIME };
|
|
20412
|
-
const { matchUp } =
|
|
20487
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
20413
20488
|
const { scheduledDate } = scheduledMatchUpDate({ matchUp });
|
|
20414
20489
|
const timeItems = matchUp?.timeItems ?? [];
|
|
20415
20490
|
const hasEndTime = timeItems.reduce((hasEndTime2, timeItem) => {
|
|
@@ -22254,8 +22329,8 @@ function updateSideLineUp({
|
|
|
22254
22329
|
element: drawDefinition,
|
|
22255
22330
|
name: LINEUPS
|
|
22256
22331
|
});
|
|
22257
|
-
const
|
|
22258
|
-
const lineUp =
|
|
22332
|
+
const lineUps = existingExtension?.value || {};
|
|
22333
|
+
const lineUp = makeDeepCopy(lineUps[teamParticipantId], false, true);
|
|
22259
22334
|
if (sideExists) {
|
|
22260
22335
|
matchUp?.sides?.forEach((side) => {
|
|
22261
22336
|
if (side.sideNumber === drawPositionSideNumber) {
|
|
@@ -22270,13 +22345,12 @@ function updateSideLineUp({
|
|
|
22270
22345
|
const targetSide = matchUp.sides.find(
|
|
22271
22346
|
(side) => side.sideNumber === drawPositionSideNumber
|
|
22272
22347
|
);
|
|
22273
|
-
if (targetSide)
|
|
22348
|
+
if (targetSide)
|
|
22274
22349
|
targetSide.lineUp = lineUp;
|
|
22275
|
-
}
|
|
22276
22350
|
}
|
|
22277
22351
|
modifyMatchUpNotice({
|
|
22278
22352
|
tournamentId: tournamentRecord?.tournamentId,
|
|
22279
|
-
context: "
|
|
22353
|
+
context: "updateSidLineUp",
|
|
22280
22354
|
eventId: event?.eventId,
|
|
22281
22355
|
drawDefinition,
|
|
22282
22356
|
matchUp
|
|
@@ -23213,10 +23287,10 @@ function removeLineUpSubstitutions({ lineUp }) {
|
|
|
23213
23287
|
const participantAssignments = {};
|
|
23214
23288
|
const permutations = unique(
|
|
23215
23289
|
lineUp.flatMap(
|
|
23216
|
-
({ collectionAssignments }) => collectionAssignments
|
|
23290
|
+
({ collectionAssignments }) => collectionAssignments?.map(
|
|
23217
23291
|
({ collectionId, collectionPosition }) => [collectionId, collectionPosition].join("|")
|
|
23218
23292
|
)
|
|
23219
|
-
)
|
|
23293
|
+
).filter(Boolean)
|
|
23220
23294
|
);
|
|
23221
23295
|
permutations.forEach((permutation) => {
|
|
23222
23296
|
const [collectionId, position] = permutation.split("|");
|
|
@@ -25821,7 +25895,7 @@ function setMatchUpStatus$2(params) {
|
|
|
25821
25895
|
matchUp
|
|
25822
25896
|
});
|
|
25823
25897
|
if (matchUpTieId) {
|
|
25824
|
-
const { matchUp: dualMatchUp } =
|
|
25898
|
+
const { matchUp: dualMatchUp } = findDrawMatchUp({
|
|
25825
25899
|
matchUpId: matchUpTieId,
|
|
25826
25900
|
inContext: true,
|
|
25827
25901
|
drawDefinition,
|
|
@@ -25967,7 +26041,7 @@ function setMatchUpFormat$1(params) {
|
|
|
25967
26041
|
return { error: UNRECOGNIZED_MATCHUP_FORMAT };
|
|
25968
26042
|
const stack = "setMatchUpFormat";
|
|
25969
26043
|
if (matchUpId) {
|
|
25970
|
-
const result =
|
|
26044
|
+
const result = findDrawMatchUp({
|
|
25971
26045
|
drawDefinition,
|
|
25972
26046
|
matchUpId,
|
|
25973
26047
|
event
|
|
@@ -28374,7 +28448,7 @@ function getTieFormat$1({
|
|
|
28374
28448
|
tieFormat = getObjectTieFormat(event);
|
|
28375
28449
|
} else if (matchUpId) {
|
|
28376
28450
|
if (drawDefinition && (!matchUp || !structure)) {
|
|
28377
|
-
const result =
|
|
28451
|
+
const result = findDrawMatchUp({
|
|
28378
28452
|
drawDefinition,
|
|
28379
28453
|
matchUpId
|
|
28380
28454
|
});
|
|
@@ -29048,7 +29122,7 @@ function orderCollectionDefinitions$1({
|
|
|
29048
29122
|
if (eventId && event?.tieFormat) {
|
|
29049
29123
|
updateEventTieFormat({ tournamentRecord, event, orderMap });
|
|
29050
29124
|
} else if (matchUpId) {
|
|
29051
|
-
const result = drawDefinition &&
|
|
29125
|
+
const result = drawDefinition && findDrawMatchUp({
|
|
29052
29126
|
drawDefinition,
|
|
29053
29127
|
matchUpId
|
|
29054
29128
|
});
|
|
@@ -29312,7 +29386,7 @@ function removeCollectionDefinition$1({
|
|
|
29312
29386
|
});
|
|
29313
29387
|
if (result2.error)
|
|
29314
29388
|
return result2;
|
|
29315
|
-
result2 =
|
|
29389
|
+
result2 = findDrawMatchUp({
|
|
29316
29390
|
drawDefinition,
|
|
29317
29391
|
matchUpId
|
|
29318
29392
|
});
|
|
@@ -30171,7 +30245,7 @@ function findMatchUp({
|
|
|
30171
30245
|
contextProfile,
|
|
30172
30246
|
inContext
|
|
30173
30247
|
});
|
|
30174
|
-
const { matchUp, structure } =
|
|
30248
|
+
const { matchUp, structure } = findDrawMatchUp({
|
|
30175
30249
|
context: inContext ? additionalContext : void 0,
|
|
30176
30250
|
tournamentParticipants,
|
|
30177
30251
|
afterRecoveryTimes,
|
|
@@ -33879,7 +33953,7 @@ function checkInParticipant$1({
|
|
|
33879
33953
|
tournamentParticipants = tournamentParticipants ?? tournamentRecord?.participants;
|
|
33880
33954
|
if (tournamentParticipants?.length) {
|
|
33881
33955
|
if (!matchUp && drawDefinition) {
|
|
33882
|
-
const result2 =
|
|
33956
|
+
const result2 = findDrawMatchUp({
|
|
33883
33957
|
tournamentParticipants,
|
|
33884
33958
|
inContext: true,
|
|
33885
33959
|
drawDefinition,
|
|
@@ -33928,7 +34002,7 @@ function checkOutParticipant$1({
|
|
|
33928
34002
|
return { error: MISSING_MATCHUP_ID };
|
|
33929
34003
|
tournamentParticipants = tournamentParticipants ?? tournamentRecord?.participants;
|
|
33930
34004
|
if (!matchUp) {
|
|
33931
|
-
const result =
|
|
34005
|
+
const result = findDrawMatchUp({
|
|
33932
34006
|
tournamentParticipants,
|
|
33933
34007
|
inContext: true,
|
|
33934
34008
|
drawDefinition,
|
|
@@ -34052,7 +34126,7 @@ function removeMatchUpCourtAssignment$1(params) {
|
|
|
34052
34126
|
});
|
|
34053
34127
|
if (!drawDefinition)
|
|
34054
34128
|
return { error: MISSING_DRAW_DEFINITION };
|
|
34055
|
-
const result =
|
|
34129
|
+
const result = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
34056
34130
|
if (result.error)
|
|
34057
34131
|
return result;
|
|
34058
34132
|
if (result?.matchUp?.matchUpType === TEAM_MATCHUP) {
|
|
@@ -36251,7 +36325,7 @@ function matchUpActions$2({
|
|
|
36251
36325
|
});
|
|
36252
36326
|
const otherFlightEntries = specifiedPolicyDefinitions?.[POLICY_TYPE_POSITION_ACTIONS]?.otherFlightEntries;
|
|
36253
36327
|
const { drawId } = drawDefinition;
|
|
36254
|
-
const { matchUp, structure } =
|
|
36328
|
+
const { matchUp, structure } = findDrawMatchUp({
|
|
36255
36329
|
drawDefinition,
|
|
36256
36330
|
matchUpId,
|
|
36257
36331
|
event
|
|
@@ -36959,7 +37033,7 @@ function removeCourtAssignment({
|
|
|
36959
37033
|
({ drawDefinition } = findEvent({ tournamentRecord, drawId }));
|
|
36960
37034
|
}
|
|
36961
37035
|
if (drawDefinition) {
|
|
36962
|
-
({ matchUp } =
|
|
37036
|
+
({ matchUp } = findDrawMatchUp({ drawDefinition, matchUpId }));
|
|
36963
37037
|
} else {
|
|
36964
37038
|
if (!tournamentRecord)
|
|
36965
37039
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
@@ -46308,13 +46382,13 @@ function resetMatchUpLineUps$1({
|
|
|
46308
46382
|
}) {
|
|
46309
46383
|
if (!drawDefinition)
|
|
46310
46384
|
return { error: MISSING_DRAW_DEFINITION };
|
|
46311
|
-
const matchUp =
|
|
46385
|
+
const matchUp = findDrawMatchUp({
|
|
46312
46386
|
drawDefinition,
|
|
46313
46387
|
matchUpId
|
|
46314
46388
|
})?.matchUp;
|
|
46315
46389
|
if (!matchUp?.tieMatchUps)
|
|
46316
46390
|
return { error: INVALID_MATCHUP };
|
|
46317
|
-
const inContextMatchUp =
|
|
46391
|
+
const inContextMatchUp = findDrawMatchUp({
|
|
46318
46392
|
inContext: true,
|
|
46319
46393
|
drawDefinition,
|
|
46320
46394
|
matchUpId,
|
|
@@ -46427,7 +46501,7 @@ function removeDelegatedOutcome$1({ drawDefinition, event, matchUpId }) {
|
|
|
46427
46501
|
return { error: MISSING_DRAW_DEFINITION };
|
|
46428
46502
|
if (!matchUpId)
|
|
46429
46503
|
return { error: MISSING_MATCHUP_ID };
|
|
46430
|
-
const { matchUp } =
|
|
46504
|
+
const { matchUp } = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
46431
46505
|
if (!matchUp)
|
|
46432
46506
|
return { error: MATCHUP_NOT_FOUND };
|
|
46433
46507
|
return removeExtension$1({
|
|
@@ -46941,7 +47015,7 @@ function setDelegatedOutcome$1({
|
|
|
46941
47015
|
if (!matchUp && !matchUpId)
|
|
46942
47016
|
return { error: MISSING_MATCHUP };
|
|
46943
47017
|
if (!matchUp) {
|
|
46944
|
-
const result =
|
|
47018
|
+
const result = findDrawMatchUp({
|
|
46945
47019
|
drawDefinition,
|
|
46946
47020
|
matchUpId
|
|
46947
47021
|
});
|
|
@@ -46989,7 +47063,7 @@ function validDrawPosition(drawPosition) {
|
|
|
46989
47063
|
function disableTieAutoCalc$1({ drawDefinition, matchUpId, event }) {
|
|
46990
47064
|
if (!drawDefinition)
|
|
46991
47065
|
return { error: MISSING_DRAW_DEFINITION };
|
|
46992
|
-
const { matchUp } =
|
|
47066
|
+
const { matchUp } = findDrawMatchUp({
|
|
46993
47067
|
drawDefinition,
|
|
46994
47068
|
matchUpId,
|
|
46995
47069
|
event
|
|
@@ -47008,7 +47082,7 @@ function enableTieAutoCalc$1({
|
|
|
47008
47082
|
}) {
|
|
47009
47083
|
if (!drawDefinition)
|
|
47010
47084
|
return { error: MISSING_DRAW_DEFINITION };
|
|
47011
|
-
const { matchUp } =
|
|
47085
|
+
const { matchUp } = findDrawMatchUp({
|
|
47012
47086
|
drawDefinition,
|
|
47013
47087
|
matchUpId,
|
|
47014
47088
|
event
|
|
@@ -47158,7 +47232,7 @@ const matchUpGovernor = {
|
|
|
47158
47232
|
removeDelegatedOutcome: removeDelegatedOutcome$1,
|
|
47159
47233
|
drawMatic: drawMatic$1,
|
|
47160
47234
|
addMatchUpOfficial: addMatchUpOfficial$2,
|
|
47161
|
-
findMatchUp:
|
|
47235
|
+
findMatchUp: publicFindDrawMatchUp,
|
|
47162
47236
|
getRoundMatchUps: getRoundMatchUps$1,
|
|
47163
47237
|
validDrawPositions,
|
|
47164
47238
|
validateScore
|
|
@@ -52715,14 +52789,14 @@ function getTieMatchUpContext({
|
|
|
52715
52789
|
if (!event)
|
|
52716
52790
|
return { error: EVENT_NOT_FOUND };
|
|
52717
52791
|
const matchUpsMap = getMatchUpsMap({ drawDefinition });
|
|
52718
|
-
const { matchUp: tieMatchUp } =
|
|
52792
|
+
const { matchUp: tieMatchUp } = findDrawMatchUp({
|
|
52719
52793
|
matchUpId: tieMatchUpId,
|
|
52720
52794
|
drawDefinition,
|
|
52721
52795
|
matchUpsMap
|
|
52722
52796
|
});
|
|
52723
52797
|
if (!tieMatchUp)
|
|
52724
52798
|
return { error: MATCHUP_NOT_FOUND };
|
|
52725
|
-
const { matchUp: inContextTieMatchUp, structure } =
|
|
52799
|
+
const { matchUp: inContextTieMatchUp, structure } = findDrawMatchUp({
|
|
52726
52800
|
tournamentParticipants: tournamentRecord.participants,
|
|
52727
52801
|
matchUpId: tieMatchUpId,
|
|
52728
52802
|
inContext: true,
|
|
@@ -52755,12 +52829,12 @@ function getTieMatchUpContext({
|
|
|
52755
52829
|
participantIds
|
|
52756
52830
|
}
|
|
52757
52831
|
});
|
|
52758
|
-
const { matchUp: dualMatchUp } =
|
|
52832
|
+
const { matchUp: dualMatchUp } = findDrawMatchUp({
|
|
52759
52833
|
matchUpId: matchUpTieId,
|
|
52760
52834
|
drawDefinition,
|
|
52761
52835
|
matchUpsMap
|
|
52762
52836
|
});
|
|
52763
|
-
const { matchUp: inContextDualMatchUp } =
|
|
52837
|
+
const { matchUp: inContextDualMatchUp } = findDrawMatchUp({
|
|
52764
52838
|
matchUpId: matchUpTieId,
|
|
52765
52839
|
inContext: true,
|
|
52766
52840
|
drawDefinition,
|
|
@@ -52818,9 +52892,9 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
52818
52892
|
if (allTieIndividualParticipantIds?.includes(participantId)) {
|
|
52819
52893
|
return decorateResult({ result: { ...SUCCESS }, stack });
|
|
52820
52894
|
}
|
|
52821
|
-
teamParticipantId = teamParticipantId || params.sideNumber
|
|
52895
|
+
teamParticipantId = teamParticipantId || (params.sideNumber ? inContextDualMatchUp?.sides?.find(
|
|
52822
52896
|
(side) => side.sideNumber === params.sideNumber
|
|
52823
|
-
)?.participantId;
|
|
52897
|
+
)?.participantId : void 0);
|
|
52824
52898
|
const participantToAssign = getParticipants$1({
|
|
52825
52899
|
participantFilters: { participantIds: [participantId] },
|
|
52826
52900
|
tournamentRecord
|
|
@@ -52870,27 +52944,13 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
52870
52944
|
);
|
|
52871
52945
|
if (!collectionDefinition)
|
|
52872
52946
|
return { error: MISSING_COLLECTION_DEFINITION };
|
|
52873
|
-
|
|
52874
|
-
|
|
52875
|
-
|
|
52876
|
-
|
|
52877
|
-
|
|
52878
|
-
|
|
52879
|
-
|
|
52880
|
-
displaySideNumber,
|
|
52881
|
-
drawPosition,
|
|
52882
|
-
sideNumber: sideNumber2
|
|
52883
|
-
}) => ({ drawPosition, sideNumber: sideNumber2, displaySideNumber });
|
|
52884
|
-
if (dualMatchUp) {
|
|
52885
|
-
dualMatchUp.sides = inContextDualMatchUp?.sides?.map((side) => {
|
|
52886
|
-
const participantId2 = side.participantId;
|
|
52887
|
-
return {
|
|
52888
|
-
...extractSideDetail(side),
|
|
52889
|
-
lineUp: participantId2 && lineUps[participantId2] || []
|
|
52890
|
-
};
|
|
52891
|
-
});
|
|
52892
|
-
}
|
|
52893
|
-
}
|
|
52947
|
+
ensureSideLineUps({
|
|
52948
|
+
tournamentId: tournamentRecord.tournamentId,
|
|
52949
|
+
eventId: event.eventId,
|
|
52950
|
+
inContextDualMatchUp,
|
|
52951
|
+
drawDefinition,
|
|
52952
|
+
dualMatchUp
|
|
52953
|
+
});
|
|
52894
52954
|
const dualMatchUpSide = dualMatchUp?.sides?.find(
|
|
52895
52955
|
(side) => side.sideNumber === sideNumber
|
|
52896
52956
|
);
|
|
@@ -52921,7 +52981,7 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
52921
52981
|
if (removeResult.error)
|
|
52922
52982
|
return decorateResult({ result: removeResult, stack });
|
|
52923
52983
|
const { modifiedLineUp } = removeResult;
|
|
52924
|
-
let
|
|
52984
|
+
let deletedParticipantId;
|
|
52925
52985
|
if (matchUpType === DOUBLES$1) {
|
|
52926
52986
|
if (participantType !== PAIR) {
|
|
52927
52987
|
let result = updateLineUp({
|
|
@@ -52940,7 +53000,7 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
52940
53000
|
});
|
|
52941
53001
|
if (result.error)
|
|
52942
53002
|
return result;
|
|
52943
|
-
|
|
53003
|
+
deletedParticipantId = result.deletedParticipantId;
|
|
52944
53004
|
if (dualMatchUpSide)
|
|
52945
53005
|
dualMatchUpSide.lineUp = modifiedLineUp;
|
|
52946
53006
|
if (dualMatchUp) {
|
|
@@ -52986,9 +53046,9 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
52986
53046
|
context: stack,
|
|
52987
53047
|
drawDefinition
|
|
52988
53048
|
});
|
|
52989
|
-
if (
|
|
53049
|
+
if (deletedParticipantId) {
|
|
52990
53050
|
const { error } = deleteParticipants({
|
|
52991
|
-
participantIds: [
|
|
53051
|
+
participantIds: [deletedParticipantId],
|
|
52992
53052
|
tournamentRecord
|
|
52993
53053
|
});
|
|
52994
53054
|
if (error)
|
|
@@ -52996,7 +53056,7 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
52996
53056
|
}
|
|
52997
53057
|
return { ...SUCCESS, modifiedLineUp };
|
|
52998
53058
|
function addParticipantId2Pair({ side }) {
|
|
52999
|
-
let
|
|
53059
|
+
let deletedParticipantId2;
|
|
53000
53060
|
if (!side.participant) {
|
|
53001
53061
|
const newPairParticipant = {
|
|
53002
53062
|
individualParticipantIds: [participantId],
|
|
@@ -53033,11 +53093,11 @@ function assignTieMatchUpParticipantId(params) {
|
|
|
53033
53093
|
if (result.error)
|
|
53034
53094
|
return result;
|
|
53035
53095
|
} else {
|
|
53036
|
-
|
|
53096
|
+
deletedParticipantId2 = participant?.participantId;
|
|
53037
53097
|
}
|
|
53038
53098
|
}
|
|
53039
53099
|
}
|
|
53040
|
-
return { ...SUCCESS,
|
|
53100
|
+
return { ...SUCCESS, deletedParticipantId: deletedParticipantId2 };
|
|
53041
53101
|
}
|
|
53042
53102
|
}
|
|
53043
53103
|
function updateLineUp({
|
|
@@ -53182,10 +53242,12 @@ function generateLineUps(params) {
|
|
|
53182
53242
|
participantIdPairs.push(participantIds2);
|
|
53183
53243
|
});
|
|
53184
53244
|
}
|
|
53185
|
-
const lineUp = Object.keys(participantAssignments).map(
|
|
53186
|
-
|
|
53187
|
-
|
|
53188
|
-
|
|
53245
|
+
const lineUp = Object.keys(participantAssignments).map(
|
|
53246
|
+
(participantId) => ({
|
|
53247
|
+
collectionAssignments: participantAssignments[participantId],
|
|
53248
|
+
participantId
|
|
53249
|
+
})
|
|
53250
|
+
);
|
|
53189
53251
|
lineUps[teamParticipant.participantId] = lineUp;
|
|
53190
53252
|
}
|
|
53191
53253
|
const participantsToAdd = [];
|
|
@@ -53554,7 +53616,7 @@ function completeDrawMatchUps(params) {
|
|
|
53554
53616
|
);
|
|
53555
53617
|
if (teamParticipant) {
|
|
53556
53618
|
const individualParticipantId = teamParticipant.individualParticipantIds?.[i];
|
|
53557
|
-
assignTieMatchUpParticipantId({
|
|
53619
|
+
individualParticipantId && assignTieMatchUpParticipantId({
|
|
53558
53620
|
teamParticipantId: teamParticipant.participantId,
|
|
53559
53621
|
participantId: individualParticipantId,
|
|
53560
53622
|
tournamentRecord,
|
|
@@ -55189,8 +55251,10 @@ function assignMatchUpSideParticipant({
|
|
|
55189
55251
|
if (noSideNumberProvided)
|
|
55190
55252
|
sideNumber = 1;
|
|
55191
55253
|
if (![1, 2].includes(sideNumber))
|
|
55192
|
-
return {
|
|
55193
|
-
|
|
55254
|
+
return decorateResult({
|
|
55255
|
+
result: { error: INVALID_VALUES, context: { sideNumber } }
|
|
55256
|
+
});
|
|
55257
|
+
const { matchUp, structure } = findDrawMatchUp({
|
|
55194
55258
|
drawDefinition,
|
|
55195
55259
|
matchUpId,
|
|
55196
55260
|
event
|
|
@@ -55245,7 +55309,7 @@ function removeMatchUpSideParticipant({
|
|
|
55245
55309
|
return { error: MISSING_VALUE };
|
|
55246
55310
|
if (![1, 2].includes(sideNumber))
|
|
55247
55311
|
return { error: INVALID_VALUES, sideNumber };
|
|
55248
|
-
const { matchUp, structure } =
|
|
55312
|
+
const { matchUp, structure } = findDrawMatchUp({
|
|
55249
55313
|
drawDefinition,
|
|
55250
55314
|
matchUpId,
|
|
55251
55315
|
event
|
|
@@ -55328,27 +55392,13 @@ function replaceTieMatchUpParticipantId(params) {
|
|
|
55328
55392
|
return { error: INVALID_PARTICIPANT, info: "Gender mismatch" };
|
|
55329
55393
|
}
|
|
55330
55394
|
const substitutionProcessCodes = matchUpActionsPolicy?.processCodes?.substitution;
|
|
55331
|
-
|
|
55332
|
-
|
|
55333
|
-
|
|
55395
|
+
ensureSideLineUps({
|
|
55396
|
+
tournamentId: tournamentRecord.tournamentId,
|
|
55397
|
+
eventId: event.eventId,
|
|
55398
|
+
inContextDualMatchUp,
|
|
55399
|
+
drawDefinition,
|
|
55400
|
+
dualMatchUp
|
|
55334
55401
|
});
|
|
55335
|
-
const lineUps = extension?.value || {};
|
|
55336
|
-
if (!dualMatchUp?.sides?.length) {
|
|
55337
|
-
const extractSideDetail = ({
|
|
55338
|
-
displaySideNumber,
|
|
55339
|
-
drawPosition,
|
|
55340
|
-
sideNumber
|
|
55341
|
-
}) => ({ drawPosition, sideNumber, displaySideNumber });
|
|
55342
|
-
if (dualMatchUp) {
|
|
55343
|
-
dualMatchUp.sides = inContextDualMatchUp?.sides?.map((side2) => {
|
|
55344
|
-
const participantId = side2.participantId;
|
|
55345
|
-
return {
|
|
55346
|
-
...extractSideDetail(side2),
|
|
55347
|
-
lineUp: participantId && lineUps[participantId] || []
|
|
55348
|
-
};
|
|
55349
|
-
});
|
|
55350
|
-
}
|
|
55351
|
-
}
|
|
55352
55402
|
const dualMatchUpSide = dualMatchUp?.sides?.find(
|
|
55353
55403
|
({ sideNumber }) => sideNumber === side.sideNumber
|
|
55354
55404
|
);
|
|
@@ -55573,25 +55623,13 @@ function removeTieMatchUpParticipantId(params) {
|
|
|
55573
55623
|
return decorateResult({ result: { error: INVALID_PARTICIPANT }, stack });
|
|
55574
55624
|
}
|
|
55575
55625
|
const participantIds = participantToRemove.participantType === INDIVIDUAL ? [participantId] : participantToRemove.individualParticipantIds;
|
|
55576
|
-
|
|
55577
|
-
|
|
55578
|
-
|
|
55579
|
-
|
|
55580
|
-
|
|
55581
|
-
|
|
55582
|
-
|
|
55583
|
-
displaySideNumber,
|
|
55584
|
-
drawPosition,
|
|
55585
|
-
sideNumber
|
|
55586
|
-
}) => ({ drawPosition, sideNumber, displaySideNumber });
|
|
55587
|
-
dualMatchUp.sides = inContextDualMatchUp?.sides?.map((side2) => {
|
|
55588
|
-
const participantId2 = side2.participantId;
|
|
55589
|
-
return {
|
|
55590
|
-
...extractSideDetail(side2),
|
|
55591
|
-
lineUp: participantId2 && lineUps[participantId2] || []
|
|
55592
|
-
};
|
|
55593
|
-
});
|
|
55594
|
-
}
|
|
55626
|
+
ensureSideLineUps({
|
|
55627
|
+
tournamentId: tournamentRecord.tournamentId,
|
|
55628
|
+
eventId: event.eventId,
|
|
55629
|
+
inContextDualMatchUp,
|
|
55630
|
+
drawDefinition,
|
|
55631
|
+
dualMatchUp
|
|
55632
|
+
});
|
|
55595
55633
|
let dualMatchUpSide = dualMatchUp.sides?.find(
|
|
55596
55634
|
({ sideNumber }) => sideNumber === side.sideNumber
|
|
55597
55635
|
);
|
|
@@ -55611,8 +55649,9 @@ function removeTieMatchUpParticipantId(params) {
|
|
|
55611
55649
|
);
|
|
55612
55650
|
}
|
|
55613
55651
|
if (!dualMatchUpSide) {
|
|
55614
|
-
|
|
55615
|
-
|
|
55652
|
+
return decorateResult({
|
|
55653
|
+
result: { error: PARTICIPANT_NOT_FOUND, context: { participantId } }
|
|
55654
|
+
});
|
|
55616
55655
|
}
|
|
55617
55656
|
const { modifiedLineUp, previousParticipantIds } = removeCollectionAssignments({
|
|
55618
55657
|
collectionPosition,
|
|
@@ -57824,7 +57863,7 @@ function substituteParticipant$1({
|
|
|
57824
57863
|
return { error: MISSING_MATCHUP_ID };
|
|
57825
57864
|
if (!existingParticipantId || !substituteParticipantId)
|
|
57826
57865
|
return decorateResult({ result: { error: MISSING_PARTICIPANT_ID }, stack });
|
|
57827
|
-
const { matchUp } =
|
|
57866
|
+
const { matchUp } = findDrawMatchUp({
|
|
57828
57867
|
drawDefinition,
|
|
57829
57868
|
matchUpId,
|
|
57830
57869
|
event
|
|
@@ -58442,7 +58481,7 @@ function applyLineUps({
|
|
|
58442
58481
|
return { error: INVALID_VALUES, lineUps };
|
|
58443
58482
|
const stack = "applyLineUps";
|
|
58444
58483
|
const tournamentParticipants = tournamentRecord.participants || [];
|
|
58445
|
-
let result =
|
|
58484
|
+
let result = findDrawMatchUp({
|
|
58446
58485
|
tournamentParticipants,
|
|
58447
58486
|
inContext: true,
|
|
58448
58487
|
drawDefinition,
|
|
@@ -58547,7 +58586,7 @@ function applyLineUps({
|
|
|
58547
58586
|
}
|
|
58548
58587
|
if (!Object.keys(sideAssignments).length)
|
|
58549
58588
|
return { error: VALUE_UNCHANGED };
|
|
58550
|
-
result =
|
|
58589
|
+
result = findDrawMatchUp({ drawDefinition, matchUpId });
|
|
58551
58590
|
if (result.error)
|
|
58552
58591
|
return result;
|
|
58553
58592
|
if (!result.matchUp)
|
|
@@ -64871,6 +64910,7 @@ const utilities = {
|
|
|
64871
64910
|
unique,
|
|
64872
64911
|
UUID,
|
|
64873
64912
|
UUIDS,
|
|
64913
|
+
validateCategory,
|
|
64874
64914
|
validateTieFormat,
|
|
64875
64915
|
visualizeScheduledMatchUps
|
|
64876
64916
|
};
|