tods-competition-factory 1.8.22 → 1.8.23
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 +34 -22
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +21 -16
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +11 -6
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +216 -203
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +480 -463
- 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 +2 -2
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.23";
|
|
2386
2386
|
}
|
|
2387
2387
|
|
|
2388
2388
|
function getObjectTieFormat(obj) {
|
|
@@ -4857,7 +4857,7 @@ function getMatchUpFormatTiming({
|
|
|
4857
4857
|
}) {
|
|
4858
4858
|
if (!tournamentRecord)
|
|
4859
4859
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
4860
|
-
eventType = eventType
|
|
4860
|
+
eventType = eventType ?? event?.eventType ?? TypeEnum.Singles;
|
|
4861
4861
|
const defaultTiming = {
|
|
4862
4862
|
averageTimes: [{ minutes: { default: defaultAverageMinutes } }],
|
|
4863
4863
|
recoveryTimes: [{ minutes: { default: defaultRecoveryMinutes } }]
|
|
@@ -5507,7 +5507,7 @@ function findVenue({
|
|
|
5507
5507
|
if (!venue && tournamentRecords) {
|
|
5508
5508
|
const linkedTournamentIds = getLinkedTournamentIds({
|
|
5509
5509
|
tournamentRecords
|
|
5510
|
-
}).linkedTournamentIds
|
|
5510
|
+
}).linkedTournamentIds ?? [];
|
|
5511
5511
|
const relevantIds = linkedTournamentIds[tournamentRecord.tournamentId];
|
|
5512
5512
|
for (const tournamentId of relevantIds) {
|
|
5513
5513
|
const record = tournamentRecords[tournamentId];
|
|
@@ -6185,7 +6185,7 @@ function getPairedParticipant({
|
|
|
6185
6185
|
result: { error: MISSING_PARTICIPANT_IDS },
|
|
6186
6186
|
stack
|
|
6187
6187
|
});
|
|
6188
|
-
tournamentParticipants = tournamentParticipants
|
|
6188
|
+
tournamentParticipants = tournamentParticipants ?? tournamentRecord?.participants ?? [];
|
|
6189
6189
|
const existingPairedParticipants = tournamentParticipants.filter(
|
|
6190
6190
|
(participant) => participant.participantType === PAIR && intersection(participantIds, participant.individualParticipantIds).length === participantIds.length && participant.individualParticipantIds.length === participantIds.length
|
|
6191
6191
|
);
|
|
@@ -7824,7 +7824,7 @@ function getRoundContextProfile({
|
|
|
7824
7824
|
...(drawDefinition?.structures ?? []).filter((structure2) => structure2.stage === QUALIFYING).map(({ stageSequence }) => stageSequence ?? 1),
|
|
7825
7825
|
0
|
|
7826
7826
|
) : 0;
|
|
7827
|
-
const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence
|
|
7827
|
+
const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence ?? 1) || "" : "";
|
|
7828
7828
|
const preQualifyingAffix = preQualifyingSequence ? roundNamingPolicy?.affixes?.preQualifying || defaultRoundNamingPolicy.affixes.preQualifying || "" : "";
|
|
7829
7829
|
const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
|
|
7830
7830
|
const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
|
|
@@ -8133,7 +8133,13 @@ function getAllStructureMatchUps({
|
|
|
8133
8133
|
matchUps
|
|
8134
8134
|
}));
|
|
8135
8135
|
}
|
|
8136
|
-
return {
|
|
8136
|
+
return {
|
|
8137
|
+
collectionPositionMatchUps,
|
|
8138
|
+
roundMatchUps,
|
|
8139
|
+
roundProfile,
|
|
8140
|
+
matchUpsMap,
|
|
8141
|
+
matchUps
|
|
8142
|
+
};
|
|
8137
8143
|
function addMatchUpContext({
|
|
8138
8144
|
scheduleVisibilityFilters: scheduleVisibilityFilters2,
|
|
8139
8145
|
sourceDrawPositionRanges,
|
|
@@ -17811,7 +17817,7 @@ function parseScoreString({
|
|
|
17811
17817
|
isSide1: winningSide === 2,
|
|
17812
17818
|
tiebreakTo
|
|
17813
17819
|
});
|
|
17814
|
-
const setTiebreak = side1TiebreakPerspective
|
|
17820
|
+
const setTiebreak = side1TiebreakPerspective ?? [];
|
|
17815
17821
|
const [side1Score, side2Score] = setScores || [];
|
|
17816
17822
|
const [side1TiebreakScore, side2TiebreakScore] = matchTiebreak || setTiebreak || [];
|
|
17817
17823
|
return {
|
|
@@ -18001,7 +18007,9 @@ function getSuper(values, index) {
|
|
|
18001
18007
|
values.slice(index, index + 2),
|
|
18002
18008
|
index ? values.slice(0, 1) : values.slice(2)
|
|
18003
18009
|
].map((n) => parseInt(n.join("")));
|
|
18004
|
-
|
|
18010
|
+
if (index)
|
|
18011
|
+
parts.reverse();
|
|
18012
|
+
const scores = parts;
|
|
18005
18013
|
const diff = Math.abs(scores.reduce((a, b) => +a - +b));
|
|
18006
18014
|
if (diff >= 2)
|
|
18007
18015
|
return scores.join("-");
|
|
@@ -19012,7 +19020,7 @@ function handleNumeric(params) {
|
|
|
19012
19020
|
if (superParse && score !== superParse) {
|
|
19013
19021
|
applied.push("parsedSuperPattern");
|
|
19014
19022
|
}
|
|
19015
|
-
score = superParse
|
|
19023
|
+
score = superParse ?? score;
|
|
19016
19024
|
}
|
|
19017
19025
|
}
|
|
19018
19026
|
return { score, applied, matchUpStatus };
|
|
@@ -19053,7 +19061,9 @@ function sensibleSets({ score, matchUpStatus, attributes }) {
|
|
|
19053
19061
|
const maxSetScore = Math.max(...sideScores);
|
|
19054
19062
|
const maxIndex = setScores.indexOf(maxSetScore);
|
|
19055
19063
|
const sensibleSetScores = [maxSetScore, maxSetScore - 1];
|
|
19056
|
-
|
|
19064
|
+
if (maxIndex)
|
|
19065
|
+
sensibleSetScores.reverse();
|
|
19066
|
+
const sensibleSetScore = sensibleSetScores.join("-");
|
|
19057
19067
|
return sensibleSetScore + tiebreak;
|
|
19058
19068
|
}
|
|
19059
19069
|
} else if (set.length === 2 && isNumeric(set)) {
|
|
@@ -19072,7 +19082,7 @@ function sensibleSets({ score, matchUpStatus, attributes }) {
|
|
|
19072
19082
|
const splitMax = max.toString().split("");
|
|
19073
19083
|
const reasonable = splitMax.find(
|
|
19074
19084
|
(value) => parseInt(value) > min || index && parseInt(value) <= maxSetValue
|
|
19075
|
-
)
|
|
19085
|
+
) ?? splitMax[0];
|
|
19076
19086
|
if (reasonable) {
|
|
19077
19087
|
set = minIndex ? [reasonable, min].join("-") : [min, reasonable].join("-");
|
|
19078
19088
|
}
|
|
@@ -19536,7 +19546,6 @@ function getVenuesAndCourts({
|
|
|
19536
19546
|
tournamentIds.forEach((tournamentId) => {
|
|
19537
19547
|
const tournamentRecord = tournamentRecords[tournamentId];
|
|
19538
19548
|
for (const venue of tournamentRecord.venues || []) {
|
|
19539
|
-
tournamentRecord.venues;
|
|
19540
19549
|
if (venueIds.length && !venueIds.includes(venue.venueId))
|
|
19541
19550
|
continue;
|
|
19542
19551
|
if (ignoreDisabled) {
|
|
@@ -21007,7 +21016,7 @@ function getContainedStructures({
|
|
|
21007
21016
|
const containerStructures = {};
|
|
21008
21017
|
const structureContainers = drawDefinitions.map((dd) => dd?.structures?.filter((structure) => structure?.structures)).flat().filter(Boolean);
|
|
21009
21018
|
for (const structureContainer of structureContainers) {
|
|
21010
|
-
const { structures, structureId } = structureContainer
|
|
21019
|
+
const { structures, structureId } = structureContainer ?? {};
|
|
21011
21020
|
structures && structureId && (containedStructures[structureId] = structures?.map(
|
|
21012
21021
|
(structure) => structure.structureId
|
|
21013
21022
|
)) && structures.forEach(
|
|
@@ -27875,7 +27884,7 @@ function filterParticipants({
|
|
|
27875
27884
|
);
|
|
27876
27885
|
if (event.eventType === SINGLES)
|
|
27877
27886
|
return enteredParticipantIds;
|
|
27878
|
-
const individualParticipantIds = (tournamentRecord?.participants
|
|
27887
|
+
const individualParticipantIds = (tournamentRecord?.participants ?? []).filter(
|
|
27879
27888
|
(participant) => enteredParticipantIds.includes(participant.participantId)
|
|
27880
27889
|
).map((participant) => participant.individualParticipantIds).flat(1);
|
|
27881
27890
|
return enteredParticipantIds.concat(...individualParticipantIds);
|
|
@@ -28242,7 +28251,7 @@ function addPenalty$1({
|
|
|
28242
28251
|
return { error: MISSING_PARTICIPANT_ID };
|
|
28243
28252
|
if (!penaltyType)
|
|
28244
28253
|
return { error: MISSING_PENALTY_TYPE };
|
|
28245
|
-
const participants = tournamentRecord?.participants
|
|
28254
|
+
const participants = tournamentRecord?.participants ?? [];
|
|
28246
28255
|
const relevantParticipants = participants.filter(
|
|
28247
28256
|
(participant) => participantIds.includes(participant.participantId)
|
|
28248
28257
|
);
|
|
@@ -28285,13 +28294,13 @@ function removePenalty$1({
|
|
|
28285
28294
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
28286
28295
|
if (!penaltyId)
|
|
28287
28296
|
return { error: MISSING_PENALTY_ID };
|
|
28288
|
-
const participants = tournamentRecord?.participants
|
|
28297
|
+
const participants = tournamentRecord?.participants ?? [];
|
|
28289
28298
|
const modifiedParticipants = [];
|
|
28290
28299
|
let penaltyRemoved = false;
|
|
28291
28300
|
let removedPenalty;
|
|
28292
28301
|
participants.forEach((participant) => {
|
|
28293
28302
|
let participantModified = false;
|
|
28294
|
-
participant.penalties = (participant.penalties
|
|
28303
|
+
participant.penalties = (participant.penalties ?? []).filter((penalty) => {
|
|
28295
28304
|
if (penalty.penaltyId === penaltyId) {
|
|
28296
28305
|
participantModified = true;
|
|
28297
28306
|
if (!penaltyRemoved) {
|
|
@@ -28320,10 +28329,10 @@ function getTournamentPenalties({
|
|
|
28320
28329
|
}) {
|
|
28321
28330
|
if (!tournamentRecord)
|
|
28322
28331
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
28323
|
-
const participants = tournamentRecord?.participants
|
|
28332
|
+
const participants = tournamentRecord?.participants ?? [];
|
|
28324
28333
|
const allPenalties = participants.reduce((penalties, participant) => {
|
|
28325
28334
|
const { participantId } = participant;
|
|
28326
|
-
(participant.penalties
|
|
28335
|
+
(participant.penalties ?? []).forEach((penalty) => {
|
|
28327
28336
|
const { penaltyId } = penalty || {};
|
|
28328
28337
|
if (penalties[penaltyId]) {
|
|
28329
28338
|
penalties[penaltyId].participants.push(participantId);
|
|
@@ -28349,7 +28358,7 @@ function modifyPenalty$1({
|
|
|
28349
28358
|
return { error: INVALID_VALUES, modifications };
|
|
28350
28359
|
if (!penaltyId)
|
|
28351
28360
|
return { error: MISSING_PENALTY_ID };
|
|
28352
|
-
const participants = tournamentRecord?.participants
|
|
28361
|
+
const participants = tournamentRecord?.participants ?? [];
|
|
28353
28362
|
const validAttributes = Object.keys(penaltyTemplate()).filter(
|
|
28354
28363
|
(attribute) => attribute !== "penaltyId"
|
|
28355
28364
|
);
|
|
@@ -28362,7 +28371,7 @@ function modifyPenalty$1({
|
|
|
28362
28371
|
const modifiedParticipants = [];
|
|
28363
28372
|
participants.forEach((participant) => {
|
|
28364
28373
|
let participantModified = false;
|
|
28365
|
-
participant.penalties = (participant.penalties
|
|
28374
|
+
participant.penalties = (participant.penalties ?? []).map((penalty) => {
|
|
28366
28375
|
if (penalty.penaltyId === penaltyId) {
|
|
28367
28376
|
participantModified = true;
|
|
28368
28377
|
validModificationAttributes.forEach(
|
|
@@ -28399,7 +28408,7 @@ function addPenalty(params) {
|
|
|
28399
28408
|
if (tournamentParticipantIds.length) {
|
|
28400
28409
|
const result = addPenalty$1({
|
|
28401
28410
|
...params,
|
|
28402
|
-
penaltyId: params.penaltyId
|
|
28411
|
+
penaltyId: params.penaltyId ?? penaltyId,
|
|
28403
28412
|
tournamentRecord,
|
|
28404
28413
|
participantIds: tournamentParticipantIds
|
|
28405
28414
|
});
|
|
@@ -28438,7 +28447,7 @@ function getCompetitionPenalties({
|
|
|
28438
28447
|
const allPenalties = [];
|
|
28439
28448
|
for (const tournamentRecord of Object.values(tournamentRecords)) {
|
|
28440
28449
|
const { penalties } = getTournamentPenalties({ tournamentRecord });
|
|
28441
|
-
allPenalties.push(...penalties
|
|
28450
|
+
allPenalties.push(...penalties ?? []);
|
|
28442
28451
|
}
|
|
28443
28452
|
return { penalties: allPenalties };
|
|
28444
28453
|
}
|
|
@@ -33748,18 +33757,18 @@ function clearScheduledMatchUps$1({
|
|
|
33748
33757
|
const inContextMatchUps = allTournamentMatchUps({
|
|
33749
33758
|
matchUpFilters: { scheduledDates },
|
|
33750
33759
|
tournamentRecord
|
|
33751
|
-
}).matchUps
|
|
33760
|
+
}).matchUps ?? [];
|
|
33752
33761
|
const relevantMatchUpIds = inContextMatchUps.filter(
|
|
33753
33762
|
(matchUp) => matchUp.matchUpStatus && !ignoreMatchUpStatuses.includes(matchUp.matchUpStatus) && hasSchedule({ schedule: matchUp.schedule, scheduleAttributes }) && (!venueIds?.length || venueIds.includes(matchUp.schedule.venueId))
|
|
33754
33763
|
).map(getMatchUpId);
|
|
33755
33764
|
const matchUps = allTournamentMatchUps({
|
|
33756
33765
|
tournamentRecord,
|
|
33757
33766
|
inContext: false
|
|
33758
|
-
}).matchUps
|
|
33767
|
+
}).matchUps ?? [];
|
|
33759
33768
|
let clearedScheduleCount = 0;
|
|
33760
33769
|
for (const matchUp of matchUps) {
|
|
33761
33770
|
if (relevantMatchUpIds.includes(matchUp.matchUpId)) {
|
|
33762
|
-
matchUp.timeItems = (matchUp.timeItems
|
|
33771
|
+
matchUp.timeItems = (matchUp.timeItems ?? []).filter(
|
|
33763
33772
|
(timeItem) => timeItem?.itemType && ![
|
|
33764
33773
|
ALLOCATE_COURTS,
|
|
33765
33774
|
ASSIGN_COURT,
|
|
@@ -36712,12 +36721,12 @@ function matchUpActions$1({
|
|
|
36712
36721
|
if (!tournamentRecord)
|
|
36713
36722
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
36714
36723
|
if (!drawId) {
|
|
36715
|
-
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps
|
|
36724
|
+
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps ?? [];
|
|
36716
36725
|
drawId = matchUps.reduce((drawId2, candidate) => {
|
|
36717
36726
|
return candidate.matchUpId === matchUpId ? candidate.drawId : drawId2;
|
|
36718
36727
|
}, void 0);
|
|
36719
|
-
const events = tournamentRecord.events
|
|
36720
|
-
const drawDefinitions = events.map((event2) => event2.drawDefinitions
|
|
36728
|
+
const events = tournamentRecord.events ?? [];
|
|
36729
|
+
const drawDefinitions = events.map((event2) => event2.drawDefinitions ?? []).flat();
|
|
36721
36730
|
drawDefinition = drawDefinitions.reduce(
|
|
36722
36731
|
(drawDefinition2, candidate) => {
|
|
36723
36732
|
return candidate.drawId === drawId ? candidate : drawDefinition2;
|
|
@@ -36731,7 +36740,7 @@ function matchUpActions$1({
|
|
|
36731
36740
|
drawDefinition,
|
|
36732
36741
|
event
|
|
36733
36742
|
});
|
|
36734
|
-
policyDefinitions = policyDefinitions
|
|
36743
|
+
policyDefinitions = policyDefinitions ?? attachedPolicy;
|
|
36735
36744
|
if (drawDefinition) {
|
|
36736
36745
|
return matchUpActions$2({
|
|
36737
36746
|
tournamentParticipants: tournamentRecord.participants,
|
|
@@ -37107,7 +37116,7 @@ function deleteVenue$1({
|
|
|
37107
37116
|
const matchUpsToUnschedule = allTournamentMatchUps({
|
|
37108
37117
|
tournamentRecord,
|
|
37109
37118
|
contextFilters
|
|
37110
|
-
}).matchUps
|
|
37119
|
+
}).matchUps ?? [];
|
|
37111
37120
|
if (!matchUpsToUnschedule.length || force) {
|
|
37112
37121
|
for (const matchUp of matchUpsToUnschedule) {
|
|
37113
37122
|
const result = removeCourtAssignment({
|
|
@@ -37122,7 +37131,7 @@ function deleteVenue$1({
|
|
|
37122
37131
|
return deletionMessage({ matchUpsCount: matchUpsToUnschedule.length });
|
|
37123
37132
|
}
|
|
37124
37133
|
let deleted;
|
|
37125
|
-
tournamentRecord.venues = (tournamentRecord.venues
|
|
37134
|
+
tournamentRecord.venues = (tournamentRecord.venues ?? []).filter(
|
|
37126
37135
|
(venue) => {
|
|
37127
37136
|
if (venue?.venueId !== venueId)
|
|
37128
37137
|
return true;
|
|
@@ -37334,7 +37343,7 @@ function deleteCourt$1({
|
|
|
37334
37343
|
courtId
|
|
37335
37344
|
});
|
|
37336
37345
|
if (!matchUps?.length || force) {
|
|
37337
|
-
for (const matchUp of matchUps
|
|
37346
|
+
for (const matchUp of matchUps ?? []) {
|
|
37338
37347
|
const result2 = removeCourtAssignment({
|
|
37339
37348
|
matchUpId: matchUp.matchUpId,
|
|
37340
37349
|
drawId: matchUp.drawId,
|
|
@@ -37345,7 +37354,7 @@ function deleteCourt$1({
|
|
|
37345
37354
|
return result2;
|
|
37346
37355
|
}
|
|
37347
37356
|
if (venue) {
|
|
37348
|
-
venue.courts = (venue.courts
|
|
37357
|
+
venue.courts = (venue.courts ?? []).filter((courtRecord) => {
|
|
37349
37358
|
return courtRecord.courtId !== courtId;
|
|
37350
37359
|
});
|
|
37351
37360
|
if (!disableNotice)
|
|
@@ -38608,7 +38617,7 @@ function treeMatchUps({
|
|
|
38608
38617
|
uuids
|
|
38609
38618
|
}));
|
|
38610
38619
|
roundNumber++;
|
|
38611
|
-
roundLimit = roundLimit
|
|
38620
|
+
roundLimit = roundLimit ?? qualifyingRoundNumber;
|
|
38612
38621
|
while (roundNodes.length > 1) {
|
|
38613
38622
|
if (qualifyingPositions && roundNodes.length === qualifyingPositions) {
|
|
38614
38623
|
roundLimit = roundNumber - 1;
|
|
@@ -38636,7 +38645,7 @@ function treeMatchUps({
|
|
|
38636
38645
|
roundLimit = roundNumber - 1;
|
|
38637
38646
|
} else {
|
|
38638
38647
|
matchUps = matchUps.filter(
|
|
38639
|
-
(matchUp) => roundLimit && (matchUp.roundNumber
|
|
38648
|
+
(matchUp) => roundLimit && (matchUp.roundNumber ?? 0) <= roundLimit
|
|
38640
38649
|
);
|
|
38641
38650
|
}
|
|
38642
38651
|
return { drawSize, matchUps, roundsCount, roundLimit };
|
|
@@ -38769,7 +38778,6 @@ function generateQualifyingStructures({
|
|
|
38769
38778
|
roundTarget,
|
|
38770
38779
|
linkType
|
|
38771
38780
|
});
|
|
38772
|
-
targetRoundQualifiersCount = 0;
|
|
38773
38781
|
roundTarget += 1;
|
|
38774
38782
|
}
|
|
38775
38783
|
return {
|
|
@@ -38784,6 +38792,7 @@ function generateQualifyingStructures({
|
|
|
38784
38792
|
|
|
38785
38793
|
function getStructureRoundProfile({
|
|
38786
38794
|
drawDefinition,
|
|
38795
|
+
matchUpsMap,
|
|
38787
38796
|
structureId
|
|
38788
38797
|
}) {
|
|
38789
38798
|
const result = findStructure({
|
|
@@ -38791,9 +38800,12 @@ function getStructureRoundProfile({
|
|
|
38791
38800
|
structureId
|
|
38792
38801
|
});
|
|
38793
38802
|
if (result.error)
|
|
38794
|
-
return result;
|
|
38795
|
-
const { matchUps } = getAllStructureMatchUps({
|
|
38796
|
-
|
|
38803
|
+
return decorateResult({ result });
|
|
38804
|
+
const { matchUps } = getAllStructureMatchUps({
|
|
38805
|
+
structure: result.structure,
|
|
38806
|
+
matchUpsMap
|
|
38807
|
+
});
|
|
38808
|
+
return { ...getRoundMatchUps$1({ matchUps }), matchUps, matchUpsMap };
|
|
38797
38809
|
}
|
|
38798
38810
|
|
|
38799
38811
|
function getFinishingPositionSourceRoundsMap({
|
|
@@ -38844,16 +38856,18 @@ function roundValueRanges(values) {
|
|
|
38844
38856
|
|
|
38845
38857
|
function getPositionsPlayedOff({
|
|
38846
38858
|
drawDefinition,
|
|
38847
|
-
structureIds
|
|
38859
|
+
structureIds,
|
|
38860
|
+
matchUpsMap
|
|
38848
38861
|
}) {
|
|
38849
38862
|
if (structureIds && !Array.isArray(structureIds))
|
|
38850
38863
|
return { error: INVALID_VALUES, context: { structureIds } };
|
|
38851
38864
|
if (!drawDefinition)
|
|
38852
38865
|
return { error: MISSING_DRAW_DEFINITION };
|
|
38853
|
-
structureIds = structureIds
|
|
38866
|
+
structureIds = structureIds ?? (drawDefinition.structures ?? []).filter((structure) => structure.stage !== QUALIFYING).map(({ structureId }) => structureId);
|
|
38854
38867
|
const allFinishingPositionRanges = structureIds.map((structureId) => {
|
|
38855
38868
|
const { roundProfile } = getStructureRoundProfile({
|
|
38856
38869
|
drawDefinition,
|
|
38870
|
+
matchUpsMap,
|
|
38857
38871
|
structureId
|
|
38858
38872
|
});
|
|
38859
38873
|
const values = roundProfile && Object.values(roundProfile);
|
|
@@ -38948,18 +38962,19 @@ function getPlayoffRoundsRanges({ playoffSourceRounds, roundProfile }) {
|
|
|
38948
38962
|
function getAvailablePlayoffProfiles$1({ drawDefinition, structureId }) {
|
|
38949
38963
|
if (!drawDefinition)
|
|
38950
38964
|
return { error: MISSING_DRAW_DEFINITION };
|
|
38951
|
-
const {
|
|
38965
|
+
const { matchUps, matchUpsMap } = allDrawMatchUps$1({
|
|
38966
|
+
inContext: true,
|
|
38952
38967
|
drawDefinition
|
|
38953
38968
|
});
|
|
38969
|
+
const { positionsNotPlayedOff, positionsPlayedOff } = getPositionsPlayedOff({
|
|
38970
|
+
drawDefinition,
|
|
38971
|
+
matchUpsMap
|
|
38972
|
+
});
|
|
38954
38973
|
const { structures } = getDrawStructures({ drawDefinition });
|
|
38955
38974
|
const filteredStructures = structures.filter(
|
|
38956
38975
|
(structure) => !structureId && structure.stage !== VOLUNTARY_CONSOLATION || structure.structureId === structureId
|
|
38957
38976
|
);
|
|
38958
38977
|
const available = {};
|
|
38959
|
-
const matchUps = allDrawMatchUps$1({
|
|
38960
|
-
inContext: true,
|
|
38961
|
-
drawDefinition
|
|
38962
|
-
}).matchUps;
|
|
38963
38978
|
for (const structure of filteredStructures) {
|
|
38964
38979
|
const structureId2 = structure?.structureId;
|
|
38965
38980
|
const result = availablePlayoffProfiles({
|
|
@@ -43382,7 +43397,7 @@ function generateQualifyingStructure$1(params) {
|
|
|
43382
43397
|
if (!params.drawDefinition)
|
|
43383
43398
|
return { error: MISSING_DRAW_DEFINITION };
|
|
43384
43399
|
const stack = "generateQualifyingStructure";
|
|
43385
|
-
let drawSize = params.drawSize
|
|
43400
|
+
let drawSize = params.drawSize ?? coerceEven(params.participantsCount);
|
|
43386
43401
|
const {
|
|
43387
43402
|
qualifyingRoundNumber,
|
|
43388
43403
|
qualifyingPositions,
|
|
@@ -43390,6 +43405,7 @@ function generateQualifyingStructure$1(params) {
|
|
|
43390
43405
|
structureOptions,
|
|
43391
43406
|
appliedPolicies,
|
|
43392
43407
|
drawDefinition,
|
|
43408
|
+
matchUpFormat,
|
|
43393
43409
|
structureName,
|
|
43394
43410
|
structureId,
|
|
43395
43411
|
roundTarget,
|
|
@@ -43428,6 +43444,7 @@ function generateQualifyingStructure$1(params) {
|
|
|
43428
43444
|
let nextStageSequence = 2;
|
|
43429
43445
|
let chainModified;
|
|
43430
43446
|
while (!chainModified && nextStructureId) {
|
|
43447
|
+
console.log("check getRoundContextProfile preqQualifyingStageSequence");
|
|
43431
43448
|
targetStructure.stageSequence = nextStageSequence;
|
|
43432
43449
|
const targetTargetStructureId = drawDefinition.links?.find(
|
|
43433
43450
|
(link2) => link2.source.structureId === nextStructureId
|
|
@@ -43458,11 +43475,11 @@ function generateQualifyingStructure$1(params) {
|
|
|
43458
43475
|
}
|
|
43459
43476
|
const roundTargetName = roundTarget ? `${roundTarget}-` : "";
|
|
43460
43477
|
const stageSequenceName = `${stageSequence}`;
|
|
43461
|
-
const qualifyingStructureName = structureName
|
|
43478
|
+
const qualifyingStructureName = structureName ?? (roundTargetName || stageSequenceName ? `${constantToString(QUALIFYING)} ${roundTargetName}${stageSequenceName}` : constantToString(QUALIFYING));
|
|
43462
43479
|
if (drawType === ROUND_ROBIN) {
|
|
43463
43480
|
const { maxRoundNumber, structures, groupCount } = generateRoundRobin({
|
|
43464
|
-
structureName: structureName
|
|
43465
|
-
structureId: structureId
|
|
43481
|
+
structureName: structureName ?? qualifyingStructureName,
|
|
43482
|
+
structureId: structureId ?? uuids?.pop(),
|
|
43466
43483
|
stage: QUALIFYING,
|
|
43467
43484
|
structureOptions,
|
|
43468
43485
|
appliedPolicies,
|
|
@@ -43491,10 +43508,11 @@ function generateQualifyingStructure$1(params) {
|
|
|
43491
43508
|
if (!roundLimit)
|
|
43492
43509
|
roundLimit = roundsCount;
|
|
43493
43510
|
structure = structureTemplate({
|
|
43494
|
-
structureName: structureName
|
|
43495
|
-
structureId: structureId
|
|
43511
|
+
structureName: structureName ?? qualifyingStructureName,
|
|
43512
|
+
structureId: structureId ?? uuids?.pop(),
|
|
43496
43513
|
qualifyingRoundNumber: roundLimit,
|
|
43497
43514
|
stage: QUALIFYING,
|
|
43515
|
+
matchUpFormat,
|
|
43498
43516
|
stageSequence,
|
|
43499
43517
|
matchUpType,
|
|
43500
43518
|
roundLimit,
|
|
@@ -44078,21 +44096,26 @@ function removeStructure({
|
|
|
44078
44096
|
({ stage, stageSequence }) => stage === MAIN && stageSequence === 1
|
|
44079
44097
|
);
|
|
44080
44098
|
const isMainStageSequence1 = structureId === mainStageSequence1.structureId;
|
|
44081
|
-
const
|
|
44082
|
-
if (isMainStageSequence1 && !
|
|
44099
|
+
const qualifyingStructureIds = structures.filter(({ stage }) => stage === QUALIFYING).map(extractAttributes("structureId"));
|
|
44100
|
+
if (isMainStageSequence1 && !qualifyingStructureIds.length) {
|
|
44083
44101
|
return { error: CANNOT_REMOVE_MAIN_STRUCTURE };
|
|
44084
44102
|
}
|
|
44103
|
+
const structureIds = structures.map(extractAttributes("structureId"));
|
|
44085
44104
|
const removedMatchUpIds = [];
|
|
44086
44105
|
const idsToRemove = [structureId];
|
|
44087
44106
|
const getTargetedStructureIds = (structureId2) => drawDefinition.links?.map(
|
|
44088
44107
|
(link) => link.source.structureId === structureId2 && link.target.structureId !== mainStageSequence1.structureId && link.target.structureId
|
|
44089
44108
|
).filter(Boolean);
|
|
44090
|
-
const
|
|
44091
|
-
|
|
44092
|
-
|
|
44093
|
-
|
|
44094
|
-
|
|
44095
|
-
|
|
44109
|
+
const getQualifyingSourceStructureIds = (structureId2) => drawDefinition.links?.map(
|
|
44110
|
+
(link) => qualifyingStructureIds.includes(link.source.structureId) && link.target.structureId === structureId2 && link.source.structureId
|
|
44111
|
+
).filter(Boolean);
|
|
44112
|
+
const isQualifyingStructure = qualifyingStructureIds.includes(structureId);
|
|
44113
|
+
const relatedStructureIdsMap = /* @__PURE__ */ new Map();
|
|
44114
|
+
structureIds.forEach(
|
|
44115
|
+
(id) => relatedStructureIdsMap.set(
|
|
44116
|
+
id,
|
|
44117
|
+
isQualifyingStructure ? getQualifyingSourceStructureIds(id) : getTargetedStructureIds(id)
|
|
44118
|
+
)
|
|
44096
44119
|
);
|
|
44097
44120
|
while (idsToRemove.length) {
|
|
44098
44121
|
const idBeingRemoved = idsToRemove.pop();
|
|
@@ -44115,7 +44138,8 @@ function removeStructure({
|
|
|
44115
44138
|
}
|
|
44116
44139
|
);
|
|
44117
44140
|
}
|
|
44118
|
-
const targetedStructureIds = idBeingRemoved && targetedStructureIdsMap[idBeingRemoved].filter(
|
|
44141
|
+
const targetedStructureIds = idBeingRemoved && // targetedStructureIdsMap[idBeingRemoved].filter(
|
|
44142
|
+
relatedStructureIdsMap.get(idBeingRemoved)?.filter(
|
|
44119
44143
|
(id) => (
|
|
44120
44144
|
// IMPORTANT: only delete MAIN stageSequence: 1 if specified to protect against DOUBLE_ELIMINATION scenario
|
|
44121
44145
|
id !== mainStageSequence1.structureId || structureId === mainStageSequence1.structureId
|
|
@@ -44912,7 +44936,7 @@ function modifyEntriesStatus({
|
|
|
44912
44936
|
}).assignedParticipantIds ?? [];
|
|
44913
44937
|
assignedParticipantIds.push(...participantIds2);
|
|
44914
44938
|
});
|
|
44915
|
-
const tournamentParticipants = tournamentRecord?.participants
|
|
44939
|
+
const tournamentParticipants = tournamentRecord?.participants ?? [];
|
|
44916
44940
|
const validEntryStatusForAllParticipantIds = participantIds.every(
|
|
44917
44941
|
(participantId) => {
|
|
44918
44942
|
const participantType = findParticipant({
|
|
@@ -44960,7 +44984,7 @@ function modifyEntriesStatus({
|
|
|
44960
44984
|
const autoPosition = ({ flight: flight2, drawDefinition: drawDefinition2 }) => {
|
|
44961
44985
|
if (event) {
|
|
44962
44986
|
event.entries = refreshEntryPositions({
|
|
44963
|
-
entries: event.entries
|
|
44987
|
+
entries: event.entries ?? []
|
|
44964
44988
|
});
|
|
44965
44989
|
}
|
|
44966
44990
|
if (flight2) {
|
|
@@ -44991,7 +45015,7 @@ function modifyEntriesStatus({
|
|
|
44991
45015
|
}
|
|
44992
45016
|
return { ...SUCCESS };
|
|
44993
45017
|
};
|
|
44994
|
-
const entryPositionsExist = event?.entries?.find(({ entryPosition }) => entryPosition)
|
|
45018
|
+
const entryPositionsExist = event?.entries?.find(({ entryPosition }) => entryPosition) ?? (flight?.drawEntries?.find(({ entryPosition }) => entryPosition) || drawDefinition?.entries?.find(({ entryPosition }) => entryPosition));
|
|
44995
45019
|
if (autoEntryPositions && !entryPositionsExist)
|
|
44996
45020
|
autoPosition({ flight, drawDefinition });
|
|
44997
45021
|
if (flight || drawDefinition) {
|
|
@@ -44999,7 +45023,7 @@ function modifyEntriesStatus({
|
|
|
44999
45023
|
if (result.error)
|
|
45000
45024
|
return decorateResult({ result, stack });
|
|
45001
45025
|
}
|
|
45002
|
-
const generatedDrawIds = event?.drawDefinitions?.map(({ drawId: drawId2 }) => drawId2)
|
|
45026
|
+
const generatedDrawIds = event?.drawDefinitions?.map(({ drawId: drawId2 }) => drawId2) ?? [];
|
|
45003
45027
|
const flightsNoDraw = flightProfile?.flights?.filter(
|
|
45004
45028
|
(flight2) => !generatedDrawIds.includes(flight2.drawId)
|
|
45005
45029
|
) || [];
|
|
@@ -45008,7 +45032,7 @@ function modifyEntriesStatus({
|
|
|
45008
45032
|
if (result?.error)
|
|
45009
45033
|
return decorateResult({ result, stack });
|
|
45010
45034
|
}
|
|
45011
|
-
const singleDraw = flightProfile?.flights?.length === 1 && (event?.drawDefinitions?.length
|
|
45035
|
+
const singleDraw = flightProfile?.flights?.length === 1 && (event?.drawDefinitions?.length ?? 0) <= flightProfile?.flights?.length;
|
|
45012
45036
|
if (!flight && !drawDefinition && entryStatus && DRAW_SPECIFIC_STATUSES.includes(entryStatus)) {
|
|
45013
45037
|
return { error: ENTRY_STATUS_NOT_ALLOWED_FOR_EVENT };
|
|
45014
45038
|
}
|
|
@@ -45046,7 +45070,7 @@ function modifyEntriesStatus({
|
|
|
45046
45070
|
}
|
|
45047
45071
|
if (autoEntryPositions)
|
|
45048
45072
|
autoPosition({ flight, drawDefinition });
|
|
45049
|
-
for (const drawDefinition2 of event?.drawDefinitions
|
|
45073
|
+
for (const drawDefinition2 of event?.drawDefinitions ?? []) {
|
|
45050
45074
|
if (modifiedDrawIds.length && !modifiedDrawIds.includes(drawDefinition2.drawId))
|
|
45051
45075
|
continue;
|
|
45052
45076
|
modifyDrawNotice({
|
|
@@ -45412,7 +45436,7 @@ function removeEventEntries({
|
|
|
45412
45436
|
if (!participantIds?.length)
|
|
45413
45437
|
return { ...SUCCESS, participantIdsRemoved: [] };
|
|
45414
45438
|
const participantIdsRemoved = [];
|
|
45415
|
-
event.entries = (event.entries
|
|
45439
|
+
event.entries = (event.entries ?? []).filter((entry) => {
|
|
45416
45440
|
const keepEntry = !participantIds.includes(entry?.participantId);
|
|
45417
45441
|
if (!keepEntry)
|
|
45418
45442
|
participantIdsRemoved.push(entry.participantId);
|
|
@@ -45430,7 +45454,7 @@ function removeEventEntries({
|
|
|
45430
45454
|
);
|
|
45431
45455
|
});
|
|
45432
45456
|
event.drawDefinitions?.forEach((drawDefinition) => {
|
|
45433
|
-
drawDefinition.entries = (drawDefinition.entries
|
|
45457
|
+
drawDefinition.entries = (drawDefinition.entries ?? []).filter(
|
|
45434
45458
|
(entry) => !participantIds.includes(entry.participantId)
|
|
45435
45459
|
);
|
|
45436
45460
|
});
|
|
@@ -45611,7 +45635,7 @@ function removeIndividualParticipantIds({
|
|
|
45611
45635
|
});
|
|
45612
45636
|
if (!groupingParticipantId || !individualParticipantIds)
|
|
45613
45637
|
return decorateResult({ result: { error: MISSING_VALUE }, stack });
|
|
45614
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
45638
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
45615
45639
|
const groupingParticipant = tournamentParticipants.find(
|
|
45616
45640
|
(participant) => {
|
|
45617
45641
|
return participant.participantId === groupingParticipantId;
|
|
@@ -45638,8 +45662,8 @@ function removeIndividualParticipantIds({
|
|
|
45638
45662
|
if (error)
|
|
45639
45663
|
return decorateResult({ result, stack });
|
|
45640
45664
|
if (addIndividualParticipantsToEvents) {
|
|
45641
|
-
for (const event of tournamentRecord.events
|
|
45642
|
-
const enteredIds = (event.entries
|
|
45665
|
+
for (const event of tournamentRecord.events ?? []) {
|
|
45666
|
+
const enteredIds = (event.entries ?? []).map(({ participantId }) => participantId).filter(Boolean);
|
|
45643
45667
|
if (enteredIds.includes(groupingParticipantId)) {
|
|
45644
45668
|
const participantIdsToEnter = removed?.filter(
|
|
45645
45669
|
(participantId) => !enteredIds.includes(participantId)
|
|
@@ -45690,7 +45714,7 @@ function removeParticipantIdsFromGroupingParticipant({
|
|
|
45690
45714
|
const groupingParticipantEventIds = inContextGroupingParticipant?.events?.map(
|
|
45691
45715
|
({ eventId }) => eventId
|
|
45692
45716
|
);
|
|
45693
|
-
const updatedIndividualParticipantIds = (groupingParticipant.individualParticipantIds
|
|
45717
|
+
const updatedIndividualParticipantIds = (groupingParticipant.individualParticipantIds ?? []).filter((participantId) => {
|
|
45694
45718
|
const targetParticipant = individualParticipantIds?.includes(participantId);
|
|
45695
45719
|
const scoredParticipantGroupingMatchUps = targetParticipant && participants?.find((participant) => participant.participantId === participantId)?.matchUps.filter(
|
|
45696
45720
|
({ eventId }) => groupingParticipantEventIds.includes(eventId)
|
|
@@ -45703,25 +45727,25 @@ function removeParticipantIdsFromGroupingParticipant({
|
|
|
45703
45727
|
}
|
|
45704
45728
|
if (removeParticipant) {
|
|
45705
45729
|
removed.push(participantId);
|
|
45706
|
-
for (const event of tournamentRecord.events
|
|
45707
|
-
for (const drawDefinition of event.drawDefinitions
|
|
45730
|
+
for (const event of tournamentRecord.events ?? []) {
|
|
45731
|
+
for (const drawDefinition of event.drawDefinitions ?? []) {
|
|
45708
45732
|
const { extension } = findExtension$2({
|
|
45709
45733
|
element: drawDefinition,
|
|
45710
45734
|
name: LINEUPS
|
|
45711
45735
|
});
|
|
45712
|
-
|
|
45736
|
+
const lineUp = extension?.value[groupingParticipant.participantId];
|
|
45713
45737
|
if (extension && lineUp) {
|
|
45714
|
-
|
|
45738
|
+
extension.value[groupingParticipant.participantId] = lineUp.filter(
|
|
45715
45739
|
(assignment) => assignment.participantId !== participantId
|
|
45716
45740
|
);
|
|
45717
45741
|
addExtension$1({ element: drawDefinition, extension });
|
|
45718
45742
|
addDrawNotice({ drawDefinition });
|
|
45719
45743
|
}
|
|
45720
|
-
const matchUps = allDrawMatchUps$1({ drawDefinition, inContext: false }).matchUps
|
|
45744
|
+
const matchUps = allDrawMatchUps$1({ drawDefinition, inContext: false }).matchUps ?? [];
|
|
45721
45745
|
for (const matchUp of matchUps) {
|
|
45722
|
-
const sides = matchUp.sides
|
|
45746
|
+
const sides = matchUp.sides ?? [];
|
|
45723
45747
|
for (const side of sides) {
|
|
45724
|
-
const lineUp2 = side.lineUp
|
|
45748
|
+
const lineUp2 = side.lineUp ?? [];
|
|
45725
45749
|
const containsParticipant = lineUp2.find(
|
|
45726
45750
|
(assignment) => assignment.participantId === participantId
|
|
45727
45751
|
);
|
|
@@ -45765,7 +45789,7 @@ function removeParticipantIdsFromAllTeams({
|
|
|
45765
45789
|
}) {
|
|
45766
45790
|
if (!tournamentRecord)
|
|
45767
45791
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
45768
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
45792
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
45769
45793
|
const { participants, mappedMatchUps } = getParticipants$1({
|
|
45770
45794
|
withMatchUps: true,
|
|
45771
45795
|
tournamentRecord,
|
|
@@ -45811,7 +45835,7 @@ function deleteParticipants(params) {
|
|
|
45811
45835
|
const matchUps = allTournamentMatchUps({
|
|
45812
45836
|
matchUpFilters: { drawIds: teamDrawIds, matchUpTypes: [DOUBLES$1] },
|
|
45813
45837
|
tournamentRecord
|
|
45814
|
-
}).matchUps
|
|
45838
|
+
}).matchUps ?? [];
|
|
45815
45839
|
const placedPairParticipantIds2 = matchUps.map(({ sides }) => sides?.map(({ participantId }) => participantId)).flat().filter(Boolean);
|
|
45816
45840
|
return intersection(placedPairParticipantIds2, participantIds);
|
|
45817
45841
|
};
|
|
@@ -45934,7 +45958,7 @@ function destroyGroupEntry({
|
|
|
45934
45958
|
if (!event.eventType || ![TypeEnum.Doubles, TypeEnum.Team].includes(event.eventType)) {
|
|
45935
45959
|
return decorateResult({ result: { error: INVALID_EVENT_TYPE }, stack });
|
|
45936
45960
|
}
|
|
45937
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
45961
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
45938
45962
|
const participant = tournamentParticipants.find(
|
|
45939
45963
|
(participant2) => participant2.participantId === participantId
|
|
45940
45964
|
);
|
|
@@ -45946,7 +45970,7 @@ function destroyGroupEntry({
|
|
|
45946
45970
|
) || participant.participantType === TEAM$1 && event.eventType !== TEAM$1 || participant.participantType === PAIR && event.eventType !== DOUBLES) {
|
|
45947
45971
|
return { error: INVALID_PARTICIPANT_TYPE };
|
|
45948
45972
|
}
|
|
45949
|
-
const eventEntries = event.entries
|
|
45973
|
+
const eventEntries = event.entries ?? [];
|
|
45950
45974
|
const entry = eventEntries.find(
|
|
45951
45975
|
(entry2) => entry2.participantId === participantId
|
|
45952
45976
|
);
|
|
@@ -46052,7 +46076,7 @@ function removeDrawPositionAssignment(params) {
|
|
|
46052
46076
|
tournamentRecord: tournamentRecord2,
|
|
46053
46077
|
participantId
|
|
46054
46078
|
});
|
|
46055
|
-
const { participantType, individualParticipantIds } = participant
|
|
46079
|
+
const { participantType, individualParticipantIds } = participant ?? {};
|
|
46056
46080
|
if (destroyPair && participantType === PAIR) {
|
|
46057
46081
|
const result2 = destroyPairEntry({
|
|
46058
46082
|
tournamentRecord: tournamentRecord2,
|
|
@@ -49587,12 +49611,12 @@ function getParticipantEventDetails({
|
|
|
49587
49611
|
if (!participantId)
|
|
49588
49612
|
return { error: MISSING_PARTICIPANT_ID };
|
|
49589
49613
|
const relevantParticipantIds = [participantId].concat(
|
|
49590
|
-
(tournamentRecord.participants
|
|
49614
|
+
(tournamentRecord.participants ?? []).filter(
|
|
49591
49615
|
(participant) => participant?.participantType && [TEAM, PAIR].includes(participant.participantType) && participant.individualParticipantIds?.includes(participantId)
|
|
49592
49616
|
).map((participant) => participant.participantId)
|
|
49593
49617
|
);
|
|
49594
|
-
const relevantEvents = (tournamentRecord.events
|
|
49595
|
-
const enteredParticipantIds = (event?.entries
|
|
49618
|
+
const relevantEvents = (tournamentRecord.events ?? []).filter((event) => {
|
|
49619
|
+
const enteredParticipantIds = (event?.entries ?? []).map(
|
|
49596
49620
|
(entry) => entry.participantId
|
|
49597
49621
|
);
|
|
49598
49622
|
return overlap(enteredParticipantIds, relevantParticipantIds);
|
|
@@ -49633,7 +49657,7 @@ function getRelevantParticipantIdsMap({
|
|
|
49633
49657
|
}) {
|
|
49634
49658
|
if (typeof tournamentRecord !== "object" && typeof tournamentRecords !== "object")
|
|
49635
49659
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
49636
|
-
const allParticipants = tournamentRecords ? Object.values(tournamentRecords).map((tournamentRecord2) => tournamentRecord2?.participants || []).flat() : tournamentRecord?.participants
|
|
49660
|
+
const allParticipants = tournamentRecords ? Object.values(tournamentRecords).map((tournamentRecord2) => tournamentRecord2?.participants || []).flat() : tournamentRecord?.participants ?? [];
|
|
49637
49661
|
const relevantParticipantIdsMap = Object.assign(
|
|
49638
49662
|
{},
|
|
49639
49663
|
...allParticipants.map(
|
|
@@ -49901,7 +49925,7 @@ function annotateParticipant(params) {
|
|
|
49901
49925
|
);
|
|
49902
49926
|
const scheduledMatchUps = participantScheduledMatchUps({
|
|
49903
49927
|
matchUps: allParticipantMatchUps
|
|
49904
|
-
})?.scheduledMatchUps
|
|
49928
|
+
})?.scheduledMatchUps ?? [];
|
|
49905
49929
|
const { scheduledMinutesDifference } = scheduleAnalysis || {};
|
|
49906
49930
|
const dates = Object.keys(scheduledMatchUps);
|
|
49907
49931
|
dates.forEach((date) => {
|
|
@@ -50706,7 +50730,7 @@ function getParticipantMembership({
|
|
|
50706
50730
|
participantFilters: { participantTypes: [TEAM, PAIR, GROUP] },
|
|
50707
50731
|
tournamentRecord
|
|
50708
50732
|
});
|
|
50709
|
-
const memberOf = (participants
|
|
50733
|
+
const memberOf = (participants ?? []).filter((participant) => {
|
|
50710
50734
|
return participant.individualParticipantIds?.includes(participantId);
|
|
50711
50735
|
});
|
|
50712
50736
|
return memberOf.reduce((groupingTypesMap, participant) => {
|
|
@@ -50732,7 +50756,7 @@ function getParticipantSchedules({
|
|
|
50732
50756
|
const matchUps = allTournamentMatchUps({
|
|
50733
50757
|
tournamentRecord,
|
|
50734
50758
|
contextFilters
|
|
50735
|
-
}).matchUps
|
|
50759
|
+
}).matchUps ?? [];
|
|
50736
50760
|
const matchUpsMap = Object.assign(
|
|
50737
50761
|
{},
|
|
50738
50762
|
...matchUps.map((matchUp) => ({ [matchUp.matchUpId]: matchUp }))
|
|
@@ -50743,7 +50767,7 @@ function getParticipantSchedules({
|
|
|
50743
50767
|
const sourceMatchUpIds = getMatchUpDependencies({
|
|
50744
50768
|
tournamentRecord,
|
|
50745
50769
|
matchUps
|
|
50746
|
-
}).sourceMatchUpIds
|
|
50770
|
+
}).sourceMatchUpIds ?? [];
|
|
50747
50771
|
const participantAggregator = {};
|
|
50748
50772
|
for (const matchUp of scheduledMatchUps) {
|
|
50749
50773
|
const { sides } = matchUp;
|
|
@@ -50753,13 +50777,11 @@ function getParticipantSchedules({
|
|
|
50753
50777
|
return [side.participant].concat(
|
|
50754
50778
|
...side.participant.individualParticipants || []
|
|
50755
50779
|
);
|
|
50756
|
-
} else {
|
|
50757
|
-
|
|
50758
|
-
relevantSourceMatchUps = (sourceMatchUpIds[matchUp.matchUpId] || []).map((matchUpId) => matchUpsMap[matchUpId]).filter(({ winningSide, bye }) => !winningSide && !bye);
|
|
50759
|
-
}
|
|
50780
|
+
} else if (sourceMatchUpIds[matchUp.matchUpId] && !relevantSourceMatchUps) {
|
|
50781
|
+
relevantSourceMatchUps = (sourceMatchUpIds[matchUp.matchUpId] || []).map((matchUpId) => matchUpsMap[matchUpId]).filter(({ winningSide, bye }) => !winningSide && !bye);
|
|
50760
50782
|
}
|
|
50761
50783
|
return void 0;
|
|
50762
|
-
}).filter(Boolean).flat()
|
|
50784
|
+
}).filter(Boolean).flat() ?? [];
|
|
50763
50785
|
for (const participant of participants) {
|
|
50764
50786
|
const { participantId } = participant;
|
|
50765
50787
|
if (!participantAggregator[participantId]) {
|
|
@@ -50890,7 +50912,7 @@ function addPersons({
|
|
|
50890
50912
|
const tournamentParticipants = getParticipants$1({
|
|
50891
50913
|
participantFilters: { participantTypes: [INDIVIDUAL] },
|
|
50892
50914
|
tournamentRecord
|
|
50893
|
-
})?.participants
|
|
50915
|
+
})?.participants ?? [];
|
|
50894
50916
|
if (participantRole === COMPETITOR) {
|
|
50895
50917
|
persons.filter(({ pairedPersons }) => pairedPersons).forEach(({ personId, pairedPersons }) => {
|
|
50896
50918
|
Array.isArray(pairedPersons) && pairedPersons.forEach((pairing) => {
|
|
@@ -50965,7 +50987,7 @@ function addIndividualParticipantIds({
|
|
|
50965
50987
|
});
|
|
50966
50988
|
if (!groupingParticipantId || !individualParticipantIds)
|
|
50967
50989
|
return decorateResult({ result: { error: MISSING_VALUE }, stack });
|
|
50968
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
50990
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
50969
50991
|
const groupingParticipant = tournamentParticipants.find(
|
|
50970
50992
|
(participant) => participant.participantId === groupingParticipantId
|
|
50971
50993
|
);
|
|
@@ -51126,7 +51148,7 @@ function generateTeamsFromParticipantAttribute({
|
|
|
51126
51148
|
if (!tournamentRecord)
|
|
51127
51149
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
51128
51150
|
const teams = {};
|
|
51129
|
-
const individualParticipants = (tournamentRecord.participants
|
|
51151
|
+
const individualParticipants = (tournamentRecord.participants ?? []).filter(
|
|
51130
51152
|
({ participantType, participantRole }) => participantType === INDIVIDUAL && participantRole === COMPETITOR
|
|
51131
51153
|
);
|
|
51132
51154
|
let teamIndex = 0;
|
|
@@ -51139,15 +51161,15 @@ function generateTeamsFromParticipantAttribute({
|
|
|
51139
51161
|
if (attributeValue) {
|
|
51140
51162
|
if (!Object.keys(teams).includes(attributeValue)) {
|
|
51141
51163
|
teams[attributeValue] = {
|
|
51142
|
-
participantName: teamNames?.[teamIndex]
|
|
51143
|
-
participantId: uuids?.pop()
|
|
51164
|
+
participantName: teamNames?.[teamIndex] ?? attributeValue,
|
|
51165
|
+
participantId: uuids?.pop() ?? UUID(),
|
|
51144
51166
|
individualParticipantIds: [],
|
|
51145
51167
|
participantRole: COMPETITOR,
|
|
51146
51168
|
participantType: TEAM
|
|
51147
51169
|
};
|
|
51148
51170
|
const extension = {
|
|
51149
|
-
|
|
51150
|
-
|
|
51171
|
+
value: personAttribute ?? participantAttribute,
|
|
51172
|
+
name: GROUPING_ATTRIBUTE
|
|
51151
51173
|
};
|
|
51152
51174
|
addExtension$1({ element: teams[attributeValue], extension });
|
|
51153
51175
|
teamIndex += 1;
|
|
@@ -51158,7 +51180,7 @@ function generateTeamsFromParticipantAttribute({
|
|
|
51158
51180
|
}
|
|
51159
51181
|
}
|
|
51160
51182
|
const groupingAttributes = Object.keys(teams);
|
|
51161
|
-
const overlappingTeamParticipantIds = (tournamentRecord.participants
|
|
51183
|
+
const overlappingTeamParticipantIds = (tournamentRecord.participants ?? []).map((participant) => {
|
|
51162
51184
|
if (participant.participantType !== TEAM)
|
|
51163
51185
|
return void 0;
|
|
51164
51186
|
if (participant.participantRole !== COMPETITOR)
|
|
@@ -51303,16 +51325,16 @@ function scaledTeamAssignment({
|
|
|
51303
51325
|
error: MISSING_VALUE
|
|
51304
51326
|
};
|
|
51305
51327
|
}
|
|
51306
|
-
let participantIdsToAssign = individualParticipantIds
|
|
51328
|
+
let participantIdsToAssign = individualParticipantIds ?? scaledParticipants.map(({ participantId }) => participantId);
|
|
51307
51329
|
if (reverseAssignmentOrder) {
|
|
51308
51330
|
teamParticipantIds?.reverse();
|
|
51309
51331
|
initialTeamIndex += 1;
|
|
51310
51332
|
}
|
|
51311
51333
|
if (initialTeamIndex > (teamParticipantIds?.length || 0) - 1)
|
|
51312
51334
|
initialTeamIndex = 0;
|
|
51313
|
-
const orderedTeamParticipantIds = teamParticipantIds?.slice(initialTeamIndex).concat(...teamParticipantIds.slice(0, initialTeamIndex))
|
|
51335
|
+
const orderedTeamParticipantIds = teamParticipantIds?.slice(initialTeamIndex).concat(...teamParticipantIds.slice(0, initialTeamIndex)) ?? [];
|
|
51314
51336
|
const relevantTeams = [];
|
|
51315
|
-
for (const participant of tournamentRecord.participants
|
|
51337
|
+
for (const participant of tournamentRecord.participants ?? []) {
|
|
51316
51338
|
const { participantId, participantType } = participant;
|
|
51317
51339
|
if (!orderedTeamParticipantIds.includes(participantId))
|
|
51318
51340
|
continue;
|
|
@@ -51322,7 +51344,7 @@ function scaledTeamAssignment({
|
|
|
51322
51344
|
}
|
|
51323
51345
|
if (teamsCount && relevantTeams.length < teamsCount) {
|
|
51324
51346
|
const addCount = teamsCount - (relevantTeams?.length || 0);
|
|
51325
|
-
const nameBase = teamNameBase
|
|
51347
|
+
const nameBase = teamNameBase ?? "Team";
|
|
51326
51348
|
const teamParticipants = generateRange(0, addCount).map((i) => ({
|
|
51327
51349
|
participantName: `${nameBase} ${i + 1}`,
|
|
51328
51350
|
participantType: TEAM_PARTICIPANT,
|
|
@@ -51361,7 +51383,7 @@ function scaledTeamAssignment({
|
|
|
51361
51383
|
return { error: NO_CANDIDATES, info: "Nothing to be done" };
|
|
51362
51384
|
}
|
|
51363
51385
|
if (!scaledParticipants.length) {
|
|
51364
|
-
for (const participant of tournamentRecord.participants
|
|
51386
|
+
for (const participant of tournamentRecord.participants ?? []) {
|
|
51365
51387
|
const { participantId, participantType } = participant;
|
|
51366
51388
|
if (!participantIdsToAssign.includes(participantId))
|
|
51367
51389
|
continue;
|
|
@@ -51399,10 +51421,10 @@ function scaledTeamAssignment({
|
|
|
51399
51421
|
relevantTeams.reverse();
|
|
51400
51422
|
}
|
|
51401
51423
|
const relevantTeamParticipantIds = relevantTeams.map(getParticipantId);
|
|
51402
|
-
for (const event2 of tournamentRecord.events
|
|
51424
|
+
for (const event2 of tournamentRecord.events ?? []) {
|
|
51403
51425
|
if (event2.eventType !== TEAM_EVENT)
|
|
51404
51426
|
continue;
|
|
51405
|
-
const relevantTeamEntries = (event2.entries
|
|
51427
|
+
const relevantTeamEntries = (event2.entries ?? []).filter(
|
|
51406
51428
|
(entry) => relevantTeamParticipantIds.includes(entry.participantId)
|
|
51407
51429
|
);
|
|
51408
51430
|
for (const relevantEntry of relevantTeamEntries) {
|
|
@@ -51411,11 +51433,11 @@ function scaledTeamAssignment({
|
|
|
51411
51433
|
(teamParticipant) => teamParticipant.participantId === relevantTeamParticipantId
|
|
51412
51434
|
);
|
|
51413
51435
|
const individualParticipantIds2 = relevantTeam?.individualParticipantIds;
|
|
51414
|
-
event2.entries = (event2.entries
|
|
51436
|
+
event2.entries = (event2.entries ?? []).filter(
|
|
51415
51437
|
(entry) => !individualParticipantIds2.includes(entry.participantId)
|
|
51416
51438
|
);
|
|
51417
|
-
(event2.drawDefinitions
|
|
51418
|
-
drawDefinition.entries = (drawDefinition.entries
|
|
51439
|
+
(event2.drawDefinitions ?? []).forEach((drawDefinition) => {
|
|
51440
|
+
drawDefinition.entries = (drawDefinition.entries ?? []).filter(
|
|
51419
51441
|
(entry) => !individualParticipantIds2.includes(entry.participantId)
|
|
51420
51442
|
);
|
|
51421
51443
|
});
|
|
@@ -52682,7 +52704,7 @@ function publishEvent(params) {
|
|
|
52682
52704
|
policyDefinitions = appliedPolicies;
|
|
52683
52705
|
}
|
|
52684
52706
|
const itemType = `${PUBLISH}.${STATUS$1}`;
|
|
52685
|
-
const eventDrawIds = event.drawDefinitions?.map(({ drawId }) => drawId)
|
|
52707
|
+
const eventDrawIds = event.drawDefinitions?.map(({ drawId }) => drawId) ?? [];
|
|
52686
52708
|
const { timeItem } = getEventTimeItem({
|
|
52687
52709
|
itemType,
|
|
52688
52710
|
event
|
|
@@ -52692,7 +52714,7 @@ function publishEvent(params) {
|
|
|
52692
52714
|
} else if (!drawIds && (drawIdsToAdd?.length || drawIdsToRemove?.length)) {
|
|
52693
52715
|
drawIds = timeItem?.itemValue?.PUBLIC?.drawIds || [];
|
|
52694
52716
|
}
|
|
52695
|
-
drawIds = (drawIds
|
|
52717
|
+
drawIds = (drawIds ?? []).filter(
|
|
52696
52718
|
(drawId) => !drawIdsToRemove?.length || !drawIdsToRemove.includes(drawId)
|
|
52697
52719
|
);
|
|
52698
52720
|
if (drawIdsToAdd?.length) {
|
|
@@ -52705,7 +52727,7 @@ function publishEvent(params) {
|
|
|
52705
52727
|
if (!structureIds && (structureIdsToAdd?.length || structureIdsToRemove?.length)) {
|
|
52706
52728
|
structureIds = timeItem?.itemValue?.PUBLIC?.structureIds || [];
|
|
52707
52729
|
}
|
|
52708
|
-
structureIds = (structureIds
|
|
52730
|
+
structureIds = (structureIds ?? []).filter(
|
|
52709
52731
|
(structureId) => !structureIdsToRemove?.length || !structureIdsToRemove.includes(structureId)
|
|
52710
52732
|
);
|
|
52711
52733
|
if (structureIdsToAdd?.length) {
|
|
@@ -52714,7 +52736,7 @@ function publishEvent(params) {
|
|
|
52714
52736
|
if (!stages && (stagesToAdd?.length || stagesToRemove?.length)) {
|
|
52715
52737
|
stages = timeItem?.itemValue?.PUBLIC?.stages || [];
|
|
52716
52738
|
}
|
|
52717
|
-
stages = (stages
|
|
52739
|
+
stages = (stages ?? []).filter(
|
|
52718
52740
|
(stage) => !stagesToRemove?.length || !stagesToRemove.includes(stage)
|
|
52719
52741
|
);
|
|
52720
52742
|
if (stagesToAdd?.length) {
|
|
@@ -54033,14 +54055,14 @@ function analyzeDraws({ tournamentRecord }) {
|
|
|
54033
54055
|
const positionsAssigned = positionAssignments?.filter(
|
|
54034
54056
|
({ participantId }) => participantId
|
|
54035
54057
|
);
|
|
54036
|
-
positionsAssignedCount += positionsAssigned?.length
|
|
54037
|
-
const unassignedPositionsCount = (positionAssignments?.length
|
|
54058
|
+
positionsAssignedCount += positionsAssigned?.length ?? 0;
|
|
54059
|
+
const unassignedPositionsCount = (positionAssignments?.length ?? 0) - (positionsAssigned?.length ?? 0);
|
|
54038
54060
|
const { roundMatchUps, roundProfile, roundNumbers, maxMatchUpsCount } = getRoundMatchUps$1({ matchUps: inContextStructureMatchUps });
|
|
54039
54061
|
const activeRounds = roundProfile && Object.keys(roundProfile).filter((roundNumber) => !roundProfile[roundNumber].inactiveRound).map((roundNumber) => parseInt(roundNumber));
|
|
54040
54062
|
const inactiveRounds = roundProfile && Object.keys(roundProfile).filter((roundNumber) => roundProfile[roundNumber].inactiveRound).map((roundNumber) => parseInt(roundNumber));
|
|
54041
54063
|
const inactiveStructure = roundProfile && Object.values(roundProfile).every((profile) => profile.inactiveRound);
|
|
54042
54064
|
return {
|
|
54043
|
-
positionsAssignedCount: positionsAssigned?.length
|
|
54065
|
+
positionsAssignedCount: positionsAssigned?.length ?? 0,
|
|
54044
54066
|
maxWinningSideFirstRoundPosition,
|
|
54045
54067
|
unassignedPositionsCount,
|
|
54046
54068
|
inactiveStructure,
|
|
@@ -54166,7 +54188,7 @@ function updateCourtAvailability({ tournamentRecord }) {
|
|
|
54166
54188
|
courts.push(...venue.courts);
|
|
54167
54189
|
}
|
|
54168
54190
|
for (const court of courts) {
|
|
54169
|
-
const { startTime, endTime } = (court.dateAvailability
|
|
54191
|
+
const { startTime, endTime } = (court.dateAvailability ?? []).reduce(
|
|
54170
54192
|
(extents, availability) => {
|
|
54171
54193
|
const startMinutes = timeStringMinutes(extents.startTime);
|
|
54172
54194
|
const endMinutes = timeStringMinutes(extents.endTime);
|
|
@@ -54182,7 +54204,7 @@ function updateCourtAvailability({ tournamentRecord }) {
|
|
|
54182
54204
|
const existing = court.dateAvailability?.find(
|
|
54183
54205
|
(availability) => availability.date === date
|
|
54184
54206
|
);
|
|
54185
|
-
return existing
|
|
54207
|
+
return existing ?? { date, startTime, endTime };
|
|
54186
54208
|
});
|
|
54187
54209
|
const defaultAvailability = court.dateAvailability?.find(
|
|
54188
54210
|
(availability) => !availability.date
|
|
@@ -54399,7 +54421,7 @@ function clearMatchUpSchedule({
|
|
|
54399
54421
|
}).matchUps?.[0];
|
|
54400
54422
|
if (!matchUp)
|
|
54401
54423
|
return { error: MATCHUP_NOT_FOUND };
|
|
54402
|
-
const newTimeItems = (matchUp.timeItems
|
|
54424
|
+
const newTimeItems = (matchUp.timeItems ?? []).filter(
|
|
54403
54425
|
(timeItem) => timeItem?.itemType && !scheduleAttributes.includes(timeItem?.itemType)
|
|
54404
54426
|
);
|
|
54405
54427
|
matchUp.timeItems = newTimeItems;
|
|
@@ -55303,7 +55325,7 @@ function assignMatchUpSideParticipant({
|
|
|
55303
55325
|
matchUp.sides = [1, 2].map((currentSideNumber) => {
|
|
55304
55326
|
const existingSide = matchUp.sides?.find(
|
|
55305
55327
|
(side) => side.sideNumber === currentSideNumber
|
|
55306
|
-
)
|
|
55328
|
+
) ?? { sideNumber: currentSideNumber };
|
|
55307
55329
|
return sideNumber === currentSideNumber ? { ...existingSide, participantId } : existingSide;
|
|
55308
55330
|
});
|
|
55309
55331
|
if (noSideNumberProvided) {
|
|
@@ -55703,7 +55725,7 @@ function removeTieMatchUpParticipantId(params) {
|
|
|
55703
55725
|
const tieMatchUpSide = inContextTieMatchUp?.sides?.find(
|
|
55704
55726
|
(side2) => side2.sideNumber === dualMatchUpSide?.sideNumber
|
|
55705
55727
|
);
|
|
55706
|
-
const { participantId: pairParticipantId } = tieMatchUpSide
|
|
55728
|
+
const { participantId: pairParticipantId } = tieMatchUpSide ?? {};
|
|
55707
55729
|
const pairParticipant = pairParticipantId && getParticipants$1({
|
|
55708
55730
|
participantFilters: { participantIds: [pairParticipantId] },
|
|
55709
55731
|
tournamentRecord,
|
|
@@ -55739,26 +55761,24 @@ function removeTieMatchUpParticipantId(params) {
|
|
|
55739
55761
|
if (result.error)
|
|
55740
55762
|
console.log("cleanup", { result });
|
|
55741
55763
|
}
|
|
55742
|
-
} else {
|
|
55743
|
-
|
|
55744
|
-
|
|
55745
|
-
|
|
55764
|
+
} else if (individualParticipantIds.length === 1) {
|
|
55765
|
+
const { participant: existingParticipant } = getPairedParticipant({
|
|
55766
|
+
participantIds: individualParticipantIds,
|
|
55767
|
+
tournamentRecord
|
|
55768
|
+
});
|
|
55769
|
+
if (!existingParticipant) {
|
|
55770
|
+
const newPairParticipant = {
|
|
55771
|
+
participantRole: COMPETITOR,
|
|
55772
|
+
individualParticipantIds,
|
|
55773
|
+
participantType: PAIR
|
|
55774
|
+
};
|
|
55775
|
+
const result = addParticipant$1({
|
|
55776
|
+
participant: newPairParticipant,
|
|
55777
|
+
pairOverride: true,
|
|
55746
55778
|
tournamentRecord
|
|
55747
55779
|
});
|
|
55748
|
-
if (
|
|
55749
|
-
|
|
55750
|
-
participantRole: COMPETITOR,
|
|
55751
|
-
individualParticipantIds,
|
|
55752
|
-
participantType: PAIR
|
|
55753
|
-
};
|
|
55754
|
-
const result = addParticipant$1({
|
|
55755
|
-
participant: newPairParticipant,
|
|
55756
|
-
pairOverride: true,
|
|
55757
|
-
tournamentRecord
|
|
55758
|
-
});
|
|
55759
|
-
if (result.error)
|
|
55760
|
-
return decorateResult({ result, stack });
|
|
55761
|
-
}
|
|
55780
|
+
if (result.error)
|
|
55781
|
+
return decorateResult({ result, stack });
|
|
55762
55782
|
}
|
|
55763
55783
|
}
|
|
55764
55784
|
} else {
|
|
@@ -55820,9 +55840,9 @@ function getPositionAssignments({
|
|
|
55820
55840
|
structure
|
|
55821
55841
|
});
|
|
55822
55842
|
return {
|
|
55823
|
-
|
|
55824
|
-
|
|
55825
|
-
|
|
55843
|
+
positionAssignments: assignments ?? [],
|
|
55844
|
+
structureId: structure?.structureId,
|
|
55845
|
+
error
|
|
55826
55846
|
};
|
|
55827
55847
|
}
|
|
55828
55848
|
|
|
@@ -56168,7 +56188,7 @@ function addEventEntryPairs({
|
|
|
56168
56188
|
return { error: MISSING_EVENT };
|
|
56169
56189
|
if (event.eventType !== DOUBLES$1)
|
|
56170
56190
|
return { error: INVALID_EVENT_TYPE };
|
|
56171
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
56191
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
56172
56192
|
const individualParticipantIds = tournamentParticipants.filter((participant) => participant.participantType === INDIVIDUAL).map((participant) => participant.participantId);
|
|
56173
56193
|
const invalidParticipantIds = individualParticipantIds.filter(
|
|
56174
56194
|
(participantId) => !individualParticipantIds.includes(participantId)
|
|
@@ -56183,7 +56203,7 @@ function addEventEntryPairs({
|
|
|
56183
56203
|
const existingParticipantIdPairs = tournamentParticipants.filter((participant) => participant.participantType === PAIR).map((participant) => participant.individualParticipantIds);
|
|
56184
56204
|
const provisionalParticipants = participantIdPairs.map(
|
|
56185
56205
|
(individualParticipantIds2) => ({
|
|
56186
|
-
participantId: uuids?.pop()
|
|
56206
|
+
participantId: uuids?.pop() ?? UUID(),
|
|
56187
56207
|
participantRole: COMPETITOR,
|
|
56188
56208
|
individualParticipantIds: individualParticipantIds2,
|
|
56189
56209
|
participantType: PAIR
|
|
@@ -56325,7 +56345,7 @@ function assignSeedPositions(params) {
|
|
|
56325
56345
|
const { seedAssignments, seedLimit } = result;
|
|
56326
56346
|
const mergeObject = Object.assign(
|
|
56327
56347
|
{},
|
|
56328
|
-
...(seedAssignments
|
|
56348
|
+
...(seedAssignments ?? []).filter((assignment) => assignment.seedNumber).map((assignment) => ({ [assignment.seedNumber]: assignment }))
|
|
56329
56349
|
);
|
|
56330
56350
|
assignments.forEach((newAssignment) => {
|
|
56331
56351
|
const { seedNumber } = newAssignment;
|
|
@@ -56606,17 +56626,14 @@ function addEvent({
|
|
|
56606
56626
|
context
|
|
56607
56627
|
};
|
|
56608
56628
|
}
|
|
56609
|
-
const eventRecord =
|
|
56610
|
-
|
|
56611
|
-
|
|
56612
|
-
|
|
56613
|
-
|
|
56614
|
-
|
|
56615
|
-
|
|
56616
|
-
|
|
56617
|
-
},
|
|
56618
|
-
event
|
|
56619
|
-
);
|
|
56629
|
+
const eventRecord = {
|
|
56630
|
+
drawDefinitions: [],
|
|
56631
|
+
eventType: TypeEnum.Singles,
|
|
56632
|
+
entries: [],
|
|
56633
|
+
startDate,
|
|
56634
|
+
endDate,
|
|
56635
|
+
...event
|
|
56636
|
+
};
|
|
56620
56637
|
if (event.eventType === TypeEnum.Team) {
|
|
56621
56638
|
if (event.tieFormat) {
|
|
56622
56639
|
const result = validateTieFormat({ tieFormat: event.tieFormat });
|
|
@@ -56646,7 +56663,7 @@ function addEvent({
|
|
|
56646
56663
|
if (!suppressNotifications) {
|
|
56647
56664
|
const { topics } = getTopics();
|
|
56648
56665
|
if (topics.includes(ADD_MATCHUPS)) {
|
|
56649
|
-
const matchUps = allEventMatchUps({ event }).matchUps
|
|
56666
|
+
const matchUps = allEventMatchUps({ event }).matchUps ?? [];
|
|
56650
56667
|
addMatchUpsNotice({
|
|
56651
56668
|
tournamentId: tournamentRecord?.tournamentId,
|
|
56652
56669
|
eventId: event.eventId,
|
|
@@ -57263,11 +57280,9 @@ function setMatchUpFormat({
|
|
|
57263
57280
|
drawDefinition: drawDefinition2
|
|
57264
57281
|
});
|
|
57265
57282
|
}
|
|
57266
|
-
} else {
|
|
57267
|
-
|
|
57268
|
-
|
|
57269
|
-
modificationsCount += 1;
|
|
57270
|
-
}
|
|
57283
|
+
} else if (event2.matchUpFormat !== matchUpFormat) {
|
|
57284
|
+
event2.matchUpFormat = matchUpFormat;
|
|
57285
|
+
modificationsCount += 1;
|
|
57271
57286
|
}
|
|
57272
57287
|
}
|
|
57273
57288
|
if (!modificationsCount)
|
|
@@ -57488,7 +57503,7 @@ function getScaledEntries({
|
|
|
57488
57503
|
}) {
|
|
57489
57504
|
if (!tournamentRecord)
|
|
57490
57505
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
57491
|
-
entries = entries
|
|
57506
|
+
entries = entries ?? event?.entries ?? [];
|
|
57492
57507
|
const stageEntries = entries.filter(
|
|
57493
57508
|
(entry) => (!stage || !entry.entryStage || entry.entryStage === stage) && (!stageSequence || !entry.entryStageSequence || entry.entryStageSequence === stageSequence) && STRUCTURE_SELECTED_STATUSES.includes(entry.entryStatus)
|
|
57494
57509
|
);
|
|
@@ -57807,7 +57822,7 @@ function generateFlightProfile(params) {
|
|
|
57807
57822
|
} = params;
|
|
57808
57823
|
if (!event)
|
|
57809
57824
|
return { error: MISSING_EVENT };
|
|
57810
|
-
const eventEntries = event.entries
|
|
57825
|
+
const eventEntries = event.entries ?? [];
|
|
57811
57826
|
const { flightProfile } = getFlightProfile({ event });
|
|
57812
57827
|
if (flightProfile && attachFlightProfile$1 && !deleteExisting) {
|
|
57813
57828
|
return { error: EXISTING_PROFILE };
|
|
@@ -57856,7 +57871,7 @@ function generateFlightProfile(params) {
|
|
|
57856
57871
|
const flightNumber = index + 1;
|
|
57857
57872
|
return {
|
|
57858
57873
|
flightNumber,
|
|
57859
|
-
drawId: uuids?.pop()
|
|
57874
|
+
drawId: uuids?.pop() ?? UUID(),
|
|
57860
57875
|
drawEntries: getDrawEntries(splitEntries[index]),
|
|
57861
57876
|
drawName: drawNames?.length && drawNames[index] || `${drawNameRoot} ${flightNumber}`
|
|
57862
57877
|
};
|
|
@@ -58152,7 +58167,7 @@ function pruneDrawDefinition({
|
|
|
58152
58167
|
const structureData = drawAnalysis.structuresData.find(
|
|
58153
58168
|
({ structureId }) => mainStructure.structureId === structureId
|
|
58154
58169
|
);
|
|
58155
|
-
const matchUps = mainStructure.matchUps
|
|
58170
|
+
const matchUps = mainStructure.matchUps ?? [];
|
|
58156
58171
|
relevantMatchUps = matchUps.sort((a, b) => a.roundPosition - b.roundPosition).filter(
|
|
58157
58172
|
({ roundNumber }) => !structureData.inactiveRounds.includes(roundNumber)
|
|
58158
58173
|
);
|
|
@@ -58167,7 +58182,7 @@ function pruneDrawDefinition({
|
|
|
58167
58182
|
(matchUpId) => !matchPlayMatchUpIds.includes(matchUpId)
|
|
58168
58183
|
);
|
|
58169
58184
|
deletedMatchUpIds.push(...matchUpIdsToDelete);
|
|
58170
|
-
const existingDrawPositionPairings = matchPlayMatchUps.flatMap((matchUp) => matchUp.drawPositions
|
|
58185
|
+
const existingDrawPositionPairings = matchPlayMatchUps.flatMap((matchUp) => matchUp.drawPositions ?? []).filter(Boolean);
|
|
58171
58186
|
const existingDrawPositions = existingDrawPositionPairings.flat();
|
|
58172
58187
|
const drawPositionsMap = Object.assign(
|
|
58173
58188
|
{},
|
|
@@ -58224,7 +58239,7 @@ function modifyEventEntries({
|
|
|
58224
58239
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
58225
58240
|
if (!event)
|
|
58226
58241
|
return { error: MISSING_EVENT };
|
|
58227
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
58242
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
58228
58243
|
const individualParticipantIds = tournamentParticipants.filter((participant) => participant.participantType === INDIVIDUAL).map((participant) => participant.participantId);
|
|
58229
58244
|
const incomingIndividualParticipantIds = unpairedParticipantIds.concat(...participantIdPairs).flat(Infinity);
|
|
58230
58245
|
const invalidParticipantIds = incomingIndividualParticipantIds.filter(
|
|
@@ -58274,7 +58289,7 @@ function modifyEventEntries({
|
|
|
58274
58289
|
entryStage
|
|
58275
58290
|
})
|
|
58276
58291
|
);
|
|
58277
|
-
event.entries = (event.entries
|
|
58292
|
+
event.entries = (event.entries ?? []).filter(
|
|
58278
58293
|
(entry) => entry.entryStage === entryStage
|
|
58279
58294
|
);
|
|
58280
58295
|
event.entries = event.entries.concat(
|
|
@@ -58305,7 +58320,7 @@ function addFlight({
|
|
|
58305
58320
|
if (!drawName)
|
|
58306
58321
|
return decorateResult({ result: { error: MISSING_VALUE }, stack });
|
|
58307
58322
|
if (drawEntries?.length) {
|
|
58308
|
-
const enteredParticipantIds = (event.entries
|
|
58323
|
+
const enteredParticipantIds = (event.entries ?? []).map(
|
|
58309
58324
|
extractAttributes("participantId")
|
|
58310
58325
|
);
|
|
58311
58326
|
const flightParticipantIds = drawEntries.map(
|
|
@@ -59786,7 +59801,7 @@ function getPredictiveAccuracy(params) {
|
|
|
59786
59801
|
const ascending = scaleProfile?.ascending ?? params.ascending ?? false;
|
|
59787
59802
|
const valueAccessor = scaleProfile?.accessor ?? params.valueAccessor;
|
|
59788
59803
|
const ratingsRangeDifference = Array.isArray(scaleProfile?.range) ? Math.abs(scaleProfile.range[0] - scaleProfile.range[1]) : 0;
|
|
59789
|
-
const zoneMargin = isConvertableInteger(zonePct) && ratingsRangeDifference ? (zonePct
|
|
59804
|
+
const zoneMargin = isConvertableInteger(zonePct) && ratingsRangeDifference ? (zonePct ?? 0 / 100) * ratingsRangeDifference : params.zoneMargin ?? ratingsRangeDifference;
|
|
59790
59805
|
const contextProfile = { withScaleValues: true, withCompetitiveness: true };
|
|
59791
59806
|
const contextFilters = {
|
|
59792
59807
|
matchUpTypes: matchUpType ? [matchUpType] : [SINGLES$1, DOUBLES$1]
|
|
@@ -59824,7 +59839,7 @@ function getPredictiveAccuracy(params) {
|
|
|
59824
59839
|
}
|
|
59825
59840
|
const relevantMatchUps = matchUps.filter(
|
|
59826
59841
|
({ winningSide, score, sides, matchUpStatus }) => ![RETIRED$1, DEFAULTED, WALKOVER$2, DEAD_RUBBER, ABANDONED$1].includes(
|
|
59827
|
-
matchUpStatus
|
|
59842
|
+
matchUpStatus ?? ""
|
|
59828
59843
|
) && scoreHasValue({ score }) && sides?.length === 2 && winningSide
|
|
59829
59844
|
);
|
|
59830
59845
|
const accuracy = getGroupingAccuracy({
|
|
@@ -61101,7 +61116,7 @@ function getTournamentPoints({
|
|
|
61101
61116
|
policyTypes: [POLICY_TYPE_RANKING_POINTS],
|
|
61102
61117
|
tournamentRecord
|
|
61103
61118
|
});
|
|
61104
|
-
const pointsPolicy = policyDefinitions?.[POLICY_TYPE_RANKING_POINTS]
|
|
61119
|
+
const pointsPolicy = policyDefinitions?.[POLICY_TYPE_RANKING_POINTS] ?? attachedPolicies?.[POLICY_TYPE_RANKING_POINTS];
|
|
61105
61120
|
if (!pointsPolicy)
|
|
61106
61121
|
return { error: MISSING_POLICY_DEFINITION };
|
|
61107
61122
|
const awardProfiles = pointsPolicy.awardProfiles;
|
|
@@ -61116,7 +61131,7 @@ function getTournamentPoints({
|
|
|
61116
61131
|
const personPoints = {};
|
|
61117
61132
|
const teamPoints = {};
|
|
61118
61133
|
const pairPoints = {};
|
|
61119
|
-
for (const participant of participantsWithOutcomes
|
|
61134
|
+
for (const participant of participantsWithOutcomes ?? []) {
|
|
61120
61135
|
const { participantType, participantId, person, draws } = participant;
|
|
61121
61136
|
for (const draw of draws) {
|
|
61122
61137
|
const { drawId, structureParticipation, eventId } = draw;
|
|
@@ -61424,8 +61439,9 @@ function generateDynamicRatings({
|
|
|
61424
61439
|
matchUpFilters: { matchUpIds, matchUpStatuses: completedMatchUpStatuses },
|
|
61425
61440
|
tournamentRecord,
|
|
61426
61441
|
inContext: true
|
|
61427
|
-
}).matchUps
|
|
61428
|
-
|
|
61442
|
+
}).matchUps ?? [];
|
|
61443
|
+
matchUps.sort(matchUpSort);
|
|
61444
|
+
for (const matchUp of matchUps) {
|
|
61429
61445
|
const { endDate, matchUpFormat, score, sides, winningSide } = matchUp;
|
|
61430
61446
|
const matchUpType = matchUp.matchUpType;
|
|
61431
61447
|
const scaleAttributes = {
|
|
@@ -61441,12 +61457,12 @@ function generateDynamicRatings({
|
|
|
61441
61457
|
};
|
|
61442
61458
|
const sideParticipantIds = Object.assign(
|
|
61443
61459
|
{},
|
|
61444
|
-
...(sides
|
|
61460
|
+
...(sides ?? []).map((side) => {
|
|
61445
61461
|
const { sideNumber, participant } = side;
|
|
61446
61462
|
return sideNumber && {
|
|
61447
61463
|
[sideNumber]: [
|
|
61448
61464
|
participant?.participantId,
|
|
61449
|
-
...participant?.individualParticipantIds
|
|
61465
|
+
...participant?.individualParticipantIds ?? []
|
|
61450
61466
|
].filter(Boolean).flat()
|
|
61451
61467
|
};
|
|
61452
61468
|
})
|
|
@@ -62983,11 +62999,10 @@ function generateParticipants(params) {
|
|
|
62983
62999
|
}
|
|
62984
63000
|
if (ratingType && ratingsParameters$1[ratingType]) {
|
|
62985
63001
|
const { ratingMax, ratingMin, ratingAttributes } = category;
|
|
62986
|
-
const ratingParameters =
|
|
62987
|
-
|
|
62988
|
-
|
|
62989
|
-
|
|
62990
|
-
);
|
|
63002
|
+
const ratingParameters = {
|
|
63003
|
+
...ratingsParameters$1[ratingType],
|
|
63004
|
+
...ratingAttributes || {}
|
|
63005
|
+
};
|
|
62991
63006
|
const {
|
|
62992
63007
|
attributes = {},
|
|
62993
63008
|
decimalsCount,
|
|
@@ -63326,15 +63341,13 @@ function getParticipantsCount({
|
|
|
63326
63341
|
} else if (drawSize + alternatesCount && drawSize + alternatesCount > largestDoublesDraw) {
|
|
63327
63342
|
largestDoublesDraw = drawSize + alternatesCount;
|
|
63328
63343
|
}
|
|
63329
|
-
} else {
|
|
63330
|
-
|
|
63331
|
-
|
|
63332
|
-
|
|
63333
|
-
|
|
63334
|
-
|
|
63335
|
-
|
|
63336
|
-
largestSinglesDraw = drawSize + alternatesCount;
|
|
63337
|
-
}
|
|
63344
|
+
} else if (requiresUniqueParticipants) {
|
|
63345
|
+
const additionalParticipantsCount = drawSize + alternatesCount;
|
|
63346
|
+
if (gender)
|
|
63347
|
+
gendersCount[gender] += additionalParticipantsCount;
|
|
63348
|
+
uniqueParticipantsCount += additionalParticipantsCount;
|
|
63349
|
+
} else if (drawSize && drawSize > largestSinglesDraw) {
|
|
63350
|
+
largestSinglesDraw = drawSize + alternatesCount;
|
|
63338
63351
|
}
|
|
63339
63352
|
};
|
|
63340
63353
|
eventProfiles?.forEach((eventProfile) => {
|
|
@@ -64270,7 +64283,7 @@ function generateVenues({
|
|
|
64270
64283
|
for (const [index, venueProfile] of venueProfiles.entries()) {
|
|
64271
64284
|
const {
|
|
64272
64285
|
venueAbbreviation,
|
|
64273
|
-
venueId = uuids?.pop()
|
|
64286
|
+
venueId = uuids?.pop() ?? UUID(),
|
|
64274
64287
|
dateAvailability,
|
|
64275
64288
|
startTime = "07:00",
|
|
64276
64289
|
endTime = "19:00",
|
|
@@ -64533,7 +64546,7 @@ function generateScheduledRounds({
|
|
|
64533
64546
|
const containedStructures = getContainedStructures({
|
|
64534
64547
|
tournamentRecord
|
|
64535
64548
|
}).containedStructures;
|
|
64536
|
-
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps
|
|
64549
|
+
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps ?? [];
|
|
64537
64550
|
const { tournamentId } = tournamentRecord;
|
|
64538
64551
|
const scheduledRounds = [];
|
|
64539
64552
|
for (const dateProfile of schedulingProfile) {
|
|
@@ -64554,7 +64567,7 @@ function generateScheduledRounds({
|
|
|
64554
64567
|
if (roundNumber && !winnerFinishingPositionRange) {
|
|
64555
64568
|
structureId = Object.keys(containedStructures).find(
|
|
64556
64569
|
(containingStructureId) => containedStructures[containingStructureId].includes(structureId)
|
|
64557
|
-
)
|
|
64570
|
+
) ?? structureId;
|
|
64558
64571
|
}
|
|
64559
64572
|
const roundToSchedule = {
|
|
64560
64573
|
tournamentId,
|