tods-competition-factory 0.85.0 → 0.86.2

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.
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
249
249
  };
250
250
 
251
251
  function factoryVersion() {
252
- return '0.85.0';
252
+ return '0.86.2';
253
253
  }
254
254
 
255
255
  const FORMAT_STANDARD = 'SET3-S:6/TB7'; // Best of 3 Tiebreak Sets to 6
@@ -22692,7 +22692,7 @@ function addParticipantContext(params) {
22692
22692
  return relevantParticipantIds.some(obj => !targetParticipantIds || targetParticipantIds.includes(obj.relevantParticipantId)) ? relevantParticipantIds : [];
22693
22693
  };
22694
22694
 
22695
- allTournamentParticipants.forEach(participant => {
22695
+ params.withGroupings && allTournamentParticipants.forEach(participant => {
22696
22696
  if (participant.participantType === GROUP) {
22697
22697
  var _participant$individu;
22698
22698
 
@@ -22861,14 +22861,6 @@ function addParticipantContext(params) {
22861
22861
  }));
22862
22862
  }
22863
22863
  });
22864
- const {
22865
- matchUps
22866
- } = allEventMatchUps({
22867
- tournamentRecord,
22868
- nextMatchUps: true,
22869
- inContext: true,
22870
- event
22871
- });
22872
22864
  const drawDetails = Object.assign({}, ...(event.drawDefinitions || []).map(drawDefinition => {
22873
22865
  var _getPositionAssignmen, _getPositionAssignmen2, _getPositionAssignmen3, _getPositionAssignmen4;
22874
22866
 
@@ -22905,11 +22897,23 @@ function addParticipantContext(params) {
22905
22897
  }
22906
22898
  };
22907
22899
  }));
22908
- matchUps === null || matchUps === void 0 ? void 0 : matchUps.forEach(matchUp => processMatchUp({
22909
- matchUp,
22910
- drawDetails,
22911
- eventType
22912
- }));
22900
+
22901
+ if (event.eventType === TEAM$3 || // for TEAM events some individual attributes can only be derived by processing
22902
+ params.withScheduleItems || params.scheduleAnalysis || params.withStatistics || params.withOpponents || params.withMatchUps) {
22903
+ const {
22904
+ matchUps
22905
+ } = allEventMatchUps({
22906
+ nextMatchUps: true,
22907
+ tournamentRecord,
22908
+ inContext: true,
22909
+ event
22910
+ });
22911
+ matchUps === null || matchUps === void 0 ? void 0 : matchUps.forEach(matchUp => processMatchUp({
22912
+ matchUp,
22913
+ drawDetails,
22914
+ eventType
22915
+ }));
22916
+ }
22913
22917
  });
22914
22918
  } // tournamentParticipants is an array of FILTERED participants
22915
22919
  // whereas allTournamentParticipants = params.tournamentRecord.participants
@@ -22924,6 +22928,16 @@ function addParticipantContext(params) {
22924
22928
  participantIdMap
22925
22929
  });
22926
22930
 
22931
+ if (params.withSignInStatus) {
22932
+ const {
22933
+ timeItem
22934
+ } = getTimeItem({
22935
+ itemType: SIGN_IN_STATUS,
22936
+ element: participant
22937
+ });
22938
+ participant.signedIn = !!((timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === SIGNED_IN);
22939
+ }
22940
+
22927
22941
  if (params.withScheduleItems) {
22928
22942
  participant.scheduleItems = scheduleItems;
22929
22943
  }
@@ -23585,6 +23599,7 @@ function getEventEntries({
23585
23599
 
23586
23600
  function getTournamentParticipants({
23587
23601
  participantFilters = {},
23602
+ withSignInStatus,
23588
23603
  convertExtensions,
23589
23604
  policyDefinitions,
23590
23605
  withScheduleItems,
@@ -23605,7 +23620,9 @@ function getTournamentParticipants({
23605
23620
  if (!tournamentRecord.participants) return {
23606
23621
  error: MISSING_PARTICIPANTS
23607
23622
  };
23608
- let tournamentParticipants = tournamentRecord.participants.map(participant => makeDeepCopy(participant, convertExtensions, true));
23623
+ let tournamentParticipants = tournamentRecord.participants.map( // (participant) => makeDeepCopy(participant, convertExtensions, true)
23624
+ participant => makeDeepCopy(participant, convertExtensions) // removed until Mongo/Mongoose issues resolved
23625
+ );
23609
23626
  if (typeof participantFilters !== 'object') return {
23610
23627
  error: INVALID_OBJECT,
23611
23628
  participantFilters
@@ -23631,7 +23648,7 @@ function getTournamentParticipants({
23631
23648
  participantFilters,
23632
23649
  participants: tournamentParticipants
23633
23650
  });
23634
- const addContext = withScheduleItems || scheduleAnalysis || withStatistics || withGroupings || withOpponents || withMatchUps || withEvents || withDraws || withISO;
23651
+ const addContext = withSignInStatus || withScheduleItems || scheduleAnalysis || withStatistics || withGroupings || withOpponents || withMatchUps || withEvents || withDraws || withISO;
23635
23652
  let participantIdsWithConflicts;
23636
23653
 
23637
23654
  if (addContext) {
@@ -23640,6 +23657,7 @@ function getTournamentParticipants({
23640
23657
  tournamentParticipants,
23641
23658
  participantFilters,
23642
23659
  withScheduleItems,
23660
+ withSignInStatus,
23643
23661
  tournamentRecord,
23644
23662
  scheduleAnalysis,
23645
23663
  withStatistics,
@@ -26324,7 +26342,7 @@ function generateBookings({
26324
26342
  };
26325
26343
  const dateScheduledMatchUps = matchUps === null || matchUps === void 0 ? void 0 : matchUps.filter(matchUp => hasSchedule(matchUp) && (!scheduleDate || matchUp.schedule.scheduledDate === scheduleDate));
26326
26344
  const relevantMatchUps = dateScheduledMatchUps === null || dateScheduledMatchUps === void 0 ? void 0 : dateScheduledMatchUps.filter(matchUp => !venueIds.length || venueIds.includes(matchUp.schedule.venueId));
26327
- const bookings = dateScheduledMatchUps === null || dateScheduledMatchUps === void 0 ? void 0 : dateScheduledMatchUps.map(({
26345
+ const bookings = relevantMatchUps === null || relevantMatchUps === void 0 ? void 0 : relevantMatchUps.map(({
26328
26346
  eventId,
26329
26347
  schedule,
26330
26348
  matchUpFormat
@@ -26491,21 +26509,26 @@ function jinnScheduler({
26491
26509
  modifications: schedulingProfileModifications
26492
26510
  } = getSchedulingProfile$1({
26493
26511
  tournamentRecords
26494
- });
26512
+ }); // round robin structures contain other structures and the scheduler
26513
+ // needs to reference the containing structure by contained structureIds
26514
+
26495
26515
  const containedStructureIds = Object.assign({}, ...Object.values(tournamentRecords).map(tournamentRecord => getContainedStructures({
26496
26516
  tournamentRecord
26497
- }).containedStructures));
26517
+ }).containedStructures)); // ensure all scheduleDates are valid date strings
26518
+
26498
26519
  const validScheduleDates = scheduleDates.map(scheduleDate => {
26499
26520
  if (!isValidDateString(scheduleDate)) return;
26500
26521
  return extractDate(scheduleDate);
26501
- }).filter(Boolean);
26502
- const profileDates = schedulingProfile.map(dateSchedulingProfile => dateSchedulingProfile.scheduleDate).map(scheduleDate => isValidDateString(scheduleDate) && extractDate(scheduleDate)).filter(scheduleDate => scheduleDate && (!scheduleDates.length || validScheduleDates.includes(scheduleDate)));
26522
+ }).filter(Boolean); // filter out any invalid scheduleDates in schedulingProfile
26523
+
26524
+ const profileDates = schedulingProfile.map(dateSchedulingProfile => dateSchedulingProfile.scheduleDate).map(scheduleDate => isValidDateString(scheduleDate) && extractDate(scheduleDate)).filter(scheduleDate => scheduleDate && (!scheduleDates.length || validScheduleDates.includes(scheduleDate))); // if no valid profileDates remain throw an error
26503
26525
 
26504
26526
  if (!profileDates.length) {
26505
26527
  return {
26506
26528
  error: NO_VALID_DATES
26507
26529
  };
26508
- }
26530
+ } // if array of clearScheduleDates, clear all matchUps on scheduledDates
26531
+
26509
26532
 
26510
26533
  if (clearScheduleDates && !dryRun) {
26511
26534
  const scheduledDates = Array.isArray(clearScheduleDates) ? clearScheduleDates : undefined;
@@ -26523,9 +26546,10 @@ function jinnScheduler({
26523
26546
  const {
26524
26547
  matchUps
26525
26548
  } = allCompetitionMatchUps({
26526
- tournamentRecords,
26527
- nextMatchUps: true
26528
- });
26549
+ nextMatchUps: true,
26550
+ tournamentRecords
26551
+ }); // build up a map of all matchUp dependencies
26552
+
26529
26553
  const {
26530
26554
  matchUpDependencies
26531
26555
  } = getMatchUpDependencies({
@@ -26543,7 +26567,8 @@ function jinnScheduler({
26543
26567
  } = getPersonRequests({
26544
26568
  requestType: DO_NOT_SCHEDULE,
26545
26569
  tournamentRecords
26546
- });
26570
+ }); // filter out any dates in schedulingProfile which have been excluded and sort
26571
+
26547
26572
  const dateSchedulingProfiles = schedulingProfile.filter(dateschedulingProfile => {
26548
26573
  const scheduleDate = extractDate(dateschedulingProfile === null || dateschedulingProfile === void 0 ? void 0 : dateschedulingProfile.scheduleDate);
26549
26574
  return profileDates.includes(scheduleDate);
@@ -42661,24 +42686,30 @@ const publishingGovernor = {
42661
42686
  unPublishEvent
42662
42687
  };
42663
42688
 
42664
- function analyzeDraws(tournamentRecord) {
42689
+ function analyzeDraws({
42690
+ tournamentRecord
42691
+ }) {
42665
42692
  var _tournamentRecord$eve;
42666
42693
 
42694
+ if (!tournamentRecord) return {
42695
+ error: MISSING_TOURNAMENT_RECORD
42696
+ };
42667
42697
  const drawsAnalysis = {
42668
- noPositionsAssigned: 0,
42669
- // no positions assigned
42670
- positionsNoOutcomes: 0,
42698
+ positionsNoOutcomes: [],
42671
42699
  // all positions assigned and no outcomes
42672
- matchPlayDraws: 0,
42673
- // only first round has active matchUps; some unassigned positions
42674
- canBePruned: 0,
42700
+ canBePruned: [],
42675
42701
  // partially assigned positions with outcomes => drawSizes can be reduced
42676
- draws: []
42702
+ matchPlay: [],
42703
+ // only first round has active matchUps; some unassigned positions
42704
+ inactive: [],
42705
+ drawAnalysis: {}
42677
42706
  };
42678
42707
  const drawDefinitions = (_tournamentRecord$eve = tournamentRecord.events) === null || _tournamentRecord$eve === void 0 ? void 0 : _tournamentRecord$eve.map(event => event === null || event === void 0 ? void 0 : event.drawDefinitions).flat().filter(Boolean);
42679
42708
  drawDefinitions.forEach(drawDefinition => {
42709
+ let positionsAssignedCount = 0;
42710
+ let matchUpsWithWinningSideCount = 0;
42680
42711
  const structures = (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) || [];
42681
- const structureData = structures.map(structure => {
42712
+ const structuresData = structures.map(structure => {
42682
42713
  const {
42683
42714
  stage,
42684
42715
  stageSequence,
@@ -42691,6 +42722,16 @@ function analyzeDraws(tournamentRecord) {
42691
42722
  drawDefinition,
42692
42723
  structure
42693
42724
  });
42725
+ const matchUpsWithWinningSide = inContextStructureMatchUps === null || inContextStructureMatchUps === void 0 ? void 0 : inContextStructureMatchUps.filter(({
42726
+ winningSide
42727
+ }) => winningSide);
42728
+ const winningSideCount = matchUpsWithWinningSide.filter(Boolean).length || 0;
42729
+ matchUpsWithWinningSideCount += winningSideCount;
42730
+ const maxWinningSideFirstRoundPosition = Math.max(matchUpsWithWinningSide.filter(({
42731
+ roundNumber
42732
+ }) => roundNumber === 1).map(({
42733
+ roundPosition
42734
+ }) => roundPosition));
42694
42735
  const {
42695
42736
  positionAssignments
42696
42737
  } = getPositionAssignments$1({
@@ -42699,6 +42740,7 @@ function analyzeDraws(tournamentRecord) {
42699
42740
  const positionsAssigned = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(({
42700
42741
  participantId
42701
42742
  }) => participantId);
42743
+ positionsAssignedCount += positionsAssigned.length;
42702
42744
  const unassignedPositionsCount = ((positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.length) || 0) - ((positionsAssigned === null || positionsAssigned === void 0 ? void 0 : positionsAssigned.length) || 0);
42703
42745
  const {
42704
42746
  roundMatchUps,
@@ -42708,13 +42750,16 @@ function analyzeDraws(tournamentRecord) {
42708
42750
  } = getRoundMatchUps$1({
42709
42751
  matchUps: inContextStructureMatchUps
42710
42752
  });
42711
- const activeRounds = Object.keys(roundProfile).filter(roundNumber => !roundProfile[roundNumber].inactiveRound);
42753
+ const activeRounds = Object.keys(roundProfile).filter(roundNumber => !roundProfile[roundNumber].inactiveRound).map(roundNumber => parseInt(roundNumber));
42754
+ const inactiveRounds = Object.keys(roundProfile).filter(roundNumber => roundProfile[roundNumber].inactiveRound).map(roundNumber => parseInt(roundNumber));
42712
42755
  const inactiveStructure = Object.values(roundProfile).every(profile => profile.inactiveRound);
42713
42756
  return {
42714
42757
  positionsAssignedCount: (positionsAssigned === null || positionsAssigned === void 0 ? void 0 : positionsAssigned.length) || 0,
42758
+ maxWinningSideFirstRoundPosition,
42715
42759
  unassignedPositionsCount,
42716
42760
  inactiveStructure,
42717
42761
  maxMatchUpsCount,
42762
+ inactiveRounds,
42718
42763
  roundMatchUps,
42719
42764
  activeRounds,
42720
42765
  roundNumbers,
@@ -42725,16 +42770,35 @@ function analyzeDraws(tournamentRecord) {
42725
42770
  stage
42726
42771
  };
42727
42772
  });
42728
- const mainStructure = structureData.find(data => data.orderNumber === 2 && data.stageSequence === 1);
42729
- const isMatchPlay = mainStructure.activeRounds.length === 1 && parseInt(mainStructure.activeRounds[0]) === 1;
42730
- const canBePruned = mainStructure.activeRounds.length && mainStructure.roundProfile[1].inActiveCount;
42731
- if (isMatchPlay) drawsAnalysis.matchPlayDraws += 1;
42732
- if (canBePruned) drawsAnalysis.canBePruned += 1;
42733
- drawsAnalysis.draws.push({
42734
- drawId: drawDefinition.drawId,
42735
- structureData,
42736
- isMatchPlay
42773
+ const mainStructure = structuresData.find(data => data.orderNumber === 2 && data.stageSequence === 1);
42774
+ const activeStructuresCount = structuresData.filter(({
42775
+ inactiveStructure
42776
+ }) => !inactiveStructure).length;
42777
+ const {
42778
+ links
42779
+ } = getStructureLinks({
42780
+ drawDefinition,
42781
+ structureId: mainStructure.structureId
42737
42782
  });
42783
+ const isMatchPlay = parseInt(mainStructure.activeRounds[0]) === 1 && mainStructure.activeRounds.length === 1 && activeStructuresCount === 1;
42784
+ const inactiveDraw = structuresData === null || structuresData === void 0 ? void 0 : structuresData.every(({
42785
+ inactiveStructure
42786
+ }) => inactiveStructure);
42787
+ const canBePruned = !links.length && mainStructure.activeRounds.length && (mainStructure.roundProfile[1].inactiveCount || mainStructure.inactiveRounds.length);
42788
+ const drawId = drawDefinition.drawId;
42789
+ if (positionsAssignedCount && !matchUpsWithWinningSideCount) drawsAnalysis.positionsNoOutcomes.push(drawId);
42790
+ if (inactiveDraw) drawsAnalysis.inactive.push(drawId);
42791
+ if (isMatchPlay) drawsAnalysis.matchPlay.push(drawId);
42792
+ if (canBePruned) drawsAnalysis.canBePruned.push(drawId);
42793
+ const drawAnalysis = {
42794
+ matchUpsWithWinningSideCount,
42795
+ positionsAssignedCount,
42796
+ structuresData,
42797
+ inactiveDraw,
42798
+ isMatchPlay,
42799
+ drawId
42800
+ };
42801
+ drawsAnalysis.drawAnalysis[drawId] = drawAnalysis;
42738
42802
  });
42739
42803
  return { ...SUCCESS,
42740
42804
  drawsAnalysis
@@ -42752,7 +42816,7 @@ function checkIsDual(tournamentRecord) {
42752
42816
  const drawDefinition = (event === null || event === void 0 ? void 0 : (_event$drawDefinition = event.drawDefinitions) === null || _event$drawDefinition === void 0 ? void 0 : _event$drawDefinition.length) === 1 && event.drawDefinitions[0];
42753
42817
  const structure = (drawDefinition === null || drawDefinition === void 0 ? void 0 : (_drawDefinition$struc = drawDefinition.structures) === null || _drawDefinition$struc === void 0 ? void 0 : _drawDefinition$struc.length) === 1 && drawDefinition.structures[0];
42754
42818
  const twoDrawPositions = (structure === null || structure === void 0 ? void 0 : (_structure$positionAs = structure.positionAssignments) === null || _structure$positionAs === void 0 ? void 0 : _structure$positionAs.length) === 2;
42755
- return event.tieFormat && twoTeams && twoDrawPositions;
42819
+ return !!(event.tieFormat && twoTeams && twoDrawPositions);
42756
42820
  }
42757
42821
 
42758
42822
  function analyzeTournament({
@@ -42763,7 +42827,9 @@ function analyzeTournament({
42763
42827
  };
42764
42828
  const {
42765
42829
  drawsAnalysis
42766
- } = analyzeDraws(tournamentRecord);
42830
+ } = analyzeDraws({
42831
+ tournamentRecord
42832
+ });
42767
42833
  const analysis = {
42768
42834
  isDual: checkIsDual(tournamentRecord),
42769
42835
  drawsAnalysis
@@ -42870,6 +42936,7 @@ const tournamentGovernor = {
42870
42936
  addNotes,
42871
42937
  removeNotes,
42872
42938
  analyzeTournament,
42939
+ analyzeDraws,
42873
42940
  setTournamentName,
42874
42941
  setTournamentNotes,
42875
42942
  setTournamentEndDate,
@@ -46552,6 +46619,179 @@ function deleteAdHocMatchUps(params) {
46552
46619
  return deleteAdHocMatchUps$1(params);
46553
46620
  }
46554
46621
 
46622
+ function resetDrawDefinition({
46623
+ drawDefinition,
46624
+ removeScheduling
46625
+ }) {
46626
+ if (!drawDefinition) return {
46627
+ error: MISSING_DRAW_DEFINITION
46628
+ }; // for matchups in all structures:
46629
+ // remove all drawPositions which are not first round or fed
46630
+ // remove all extensions
46631
+ // if removeScheudling, remove all scheduling timeItems
46632
+ // for all structures which are NOT QUALIFYING or MAIN { stageSequence: 1 }
46633
+ // remove all positionAssignments that are not BYE
46634
+
46635
+ const matchUpsMap = getMatchUpsMap({
46636
+ drawDefinition
46637
+ });
46638
+
46639
+ const getRawMatchUp = matchUpId => {
46640
+ var _matchUpsMap$drawMatc;
46641
+
46642
+ return matchUpsMap === null || matchUpsMap === void 0 ? void 0 : (_matchUpsMap$drawMatc = matchUpsMap.drawMatchUps) === null || _matchUpsMap$drawMatc === void 0 ? void 0 : _matchUpsMap$drawMatc.find(matchUp => matchUp.matchUpId === matchUpId);
46643
+ };
46644
+
46645
+ for (const structure of drawDefinition.structures || []) {
46646
+ const {
46647
+ positionAssignments,
46648
+ stage,
46649
+ stageSequence
46650
+ } = structure; // reset positionAssignments and seedAssignments where appropriate
46651
+
46652
+ if (positionAssignments && (stageSequence !== 1 || ![QUALIFYING, MAIN].includes(stage))) {
46653
+ structure.positionAssignments = positionAssignments.map(assignment => {
46654
+ delete assignment.participantId;
46655
+ return assignment;
46656
+ });
46657
+ structure.seedAssignments = [];
46658
+ }
46659
+
46660
+ const {
46661
+ matchUps: inContextMatchUps
46662
+ } = getAllStructureMatchUps({
46663
+ inContext: true,
46664
+ matchUpsMap,
46665
+ structure
46666
+ }); // reset all matchUps to initial state
46667
+
46668
+ for (const inContextMatchUp of inContextMatchUps) {
46669
+ var _matchUp$timeItems;
46670
+
46671
+ const {
46672
+ matchUpId,
46673
+ roundNumber,
46674
+ sides
46675
+ } = inContextMatchUp;
46676
+ const matchUp = getRawMatchUp(matchUpId);
46677
+ delete matchUp.extensions;
46678
+ delete matchUp.notes;
46679
+
46680
+ if (matchUp.matchUpStatus !== BYE) {
46681
+ matchUp.matchUpStatus = TO_BE_PLAYED;
46682
+ delete matchUp.matchUpStatusCodes;
46683
+ delete matchUp.matchUpFormat;
46684
+ delete matchUp.winningSide;
46685
+ delete matchUp.score;
46686
+ }
46687
+
46688
+ if (roundNumber && roundNumber > 1 && matchUp.drawPositions) {
46689
+ const fedDrawPositions = sides === null || sides === void 0 ? void 0 : sides.map(({
46690
+ drawPosition,
46691
+ participantFed
46692
+ }) => !participantFed && drawPosition).filter(Boolean);
46693
+ matchUp.drawPositions = matchUp.drawPositions.map(drawPosition => !fedDrawPositions.includes(drawPosition) ? drawPosition : undefined);
46694
+ }
46695
+
46696
+ if (removeScheduling) {
46697
+ delete matchUp.timeItems;
46698
+ } else if ((_matchUp$timeItems = matchUp.timeItems) !== null && _matchUp$timeItems !== void 0 && _matchUp$timeItems.length) {
46699
+ matchUp.timeItems = matchUp.timeItems.filter(timeItem => ![ASSIGN_COURT, ASSIGN_VENUE, ASSIGN_OFFICIAL, SCHEDULED_DATE, SCHEDULED_TIME].includes(timeItem.itemType));
46700
+ }
46701
+
46702
+ modifyMatchUpNotice({
46703
+ drawDefinition,
46704
+ matchUp
46705
+ });
46706
+ }
46707
+ }
46708
+
46709
+ const structureIds = (drawDefinition.structures || []).map(({
46710
+ structureId
46711
+ }) => structureId);
46712
+ modifyDrawNotice({
46713
+ drawDefinition,
46714
+ structureIds
46715
+ });
46716
+ return { ...SUCCESS
46717
+ };
46718
+ }
46719
+
46720
+ function pruneDrawDefinition({
46721
+ tournamentRecord,
46722
+ drawDefinition,
46723
+ drawId
46724
+ }) {
46725
+ if (!tournamentRecord) return {
46726
+ error: MISSING_TOURNAMENT_RECORD
46727
+ };
46728
+ if (!drawDefinition) return {
46729
+ error: MISSING_DRAW_DEFINITION
46730
+ };
46731
+ const {
46732
+ drawsAnalysis
46733
+ } = analyzeDraws({
46734
+ tournamentRecord
46735
+ });
46736
+
46737
+ if (drawsAnalysis.canBePruned.includes(drawId)) {
46738
+ const isMatchPlay = drawsAnalysis.matchPlay.includes(drawId);
46739
+ const drawAnalysis = drawsAnalysis.drawAnalysis[drawId];
46740
+ const {
46741
+ structures: [mainStructure]
46742
+ } = getDrawStructures({
46743
+ drawDefinition,
46744
+ stage: MAIN,
46745
+ stageSequence: 1
46746
+ });
46747
+ const structureData = drawAnalysis.structuresData.find(({
46748
+ structureId
46749
+ }) => mainStructure.structureId === structureId);
46750
+ const matchUps = mainStructure.matchUps || [];
46751
+ const relevantMatchUps = matchUps.sort((a, b) => a.roundPosition - b.roundPosition).filter(({
46752
+ roundNumber
46753
+ }) => !structureData.inactiveRounds.includes(roundNumber));
46754
+ const relevantMatchUpIds = relevantMatchUps.map(getMatchUpId);
46755
+ const deletedMatchUpIds = matchUps.map(getMatchUpId).filter(matchUpId => !relevantMatchUpIds.includes(matchUpId)); // only ifMatchPlay can the positionAssignments be reallocated
46756
+
46757
+ if (isMatchPlay) {
46758
+ const matchPlayMatchUps = relevantMatchUps.sort((a, b) => a.roundPosition - b.roundPosition).filter(({
46759
+ roundNumber
46760
+ }) => !structureData.inactiveRounds.includes(roundNumber)).filter(({
46761
+ winningSide
46762
+ }) => !isMatchPlay || winningSide);
46763
+ const matchPlayMatchUpIds = matchPlayMatchUps.map(getMatchUpId);
46764
+ const matchUpIdsToDelete = relevantMatchUpIds.filter(matchUpId => !matchPlayMatchUpIds.includes(matchUpId));
46765
+ deletedMatchUpIds.push(...matchUpIdsToDelete);
46766
+ const existingDrawPositionPairings = matchPlayMatchUps.map(({
46767
+ drawPositions
46768
+ }) => drawPositions);
46769
+ const existingDrawPositions = existingDrawPositionPairings.flat();
46770
+ const drawPositionsMap = Object.assign({}, ...existingDrawPositions.map((drawPosition, i) => ({
46771
+ [drawPosition]: i + 1
46772
+ })));
46773
+ matchPlayMatchUps.forEach(matchUp => matchUp.drawPositions = matchUp.drawPositions.map(drawPosition => drawPositionsMap[drawPosition]));
46774
+ const updatedPositionAssignments = mainStructure.positionAssignments.filter(assignment => existingDrawPositions.includes(assignment.drawPosition)).map(assignment => {
46775
+ assignment.drawPosition = drawPositionsMap[assignment.drawPosition];
46776
+ return assignment;
46777
+ });
46778
+ mainStructure.positionAssignments = updatedPositionAssignments;
46779
+ mainStructure.matchUps = matchPlayMatchUps;
46780
+ }
46781
+
46782
+ deleteMatchUpsNotice({
46783
+ drawDefinition,
46784
+ matchUpIds: deletedMatchUpIds
46785
+ });
46786
+ modifyDrawNotice({
46787
+ drawDefinition
46788
+ });
46789
+ }
46790
+
46791
+ return { ...SUCCESS
46792
+ };
46793
+ }
46794
+
46555
46795
  /**
46556
46796
  *
46557
46797
  * @param {object} orderedDrawIdsMap - required - mapping of ALL present drawIds => { [drawId]: drawOrder }
@@ -47001,6 +47241,8 @@ const eventGovernor = {
47001
47241
  deleteFlightAndFlightDraw,
47002
47242
  generateFlightProfile,
47003
47243
  attachFlightProfile,
47244
+ resetDrawDefinition,
47245
+ pruneDrawDefinition,
47004
47246
  updateDrawIdsOrder,
47005
47247
  getFlightProfile,
47006
47248
  getScaledEntries,
@@ -47162,8 +47404,8 @@ function getParticipantSignInStatus({
47162
47404
  const {
47163
47405
  timeItem
47164
47406
  } = getTimeItem({
47165
- element: participant,
47166
- itemType: SIGN_IN_STATUS
47407
+ itemType: SIGN_IN_STATUS,
47408
+ element: participant
47167
47409
  });
47168
47410
  return timeItem && timeItem.itemValue === SIGNED_IN && SIGNED_IN;
47169
47411
  }