tods-competition-factory 1.8.30 → 1.8.32

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.
@@ -2929,7 +2929,7 @@ var matchUpFormatCode = {
2929
2929
  };
2930
2930
 
2931
2931
  function factoryVersion() {
2932
- return '1.8.30';
2932
+ return '1.8.32';
2933
2933
  }
2934
2934
 
2935
2935
  function getObjectTieFormat(obj) {
@@ -10761,8 +10761,11 @@ function updateAssignmentParticipantResults(_a) {
10761
10761
  }
10762
10762
 
10763
10763
  function addParticipantGroupings(_a) {
10764
- var participantsProfile = _a.participantsProfile, _b = _a.participants, participants = _b === void 0 ? [] : _b;
10765
- var participantsWithGroupings = makeDeepCopy(participants, participantsProfile === null || participantsProfile === void 0 ? void 0 : participantsProfile.convertExtensions, true);
10764
+ var participantsProfile = _a.participantsProfile, _b = _a.participants, participants = _b === void 0 ? [] : _b, deepCopy = _a.deepCopy;
10765
+ var groupMap = new Map();
10766
+ var participantsWithGroupings = deepCopy !== false
10767
+ ? makeDeepCopy(participants, participantsProfile === null || participantsProfile === void 0 ? void 0 : participantsProfile.convertExtensions, true)
10768
+ : participants;
10766
10769
  var teamParticipants = participantsWithGroupings.filter(function (participant) { return participant.participantType === TEAM; });
10767
10770
  var groupParticipants = participantsWithGroupings.filter(function (participant) { return participant.participantType === GROUP; });
10768
10771
  // should pairParticipants only consider those that are in the same event as current draw?
@@ -10782,6 +10785,11 @@ function addParticipantGroupings(_a) {
10782
10785
  if (individualParticipantId === participantId_1 &&
10783
10786
  !((_a = participant.teamParticipantIds) === null || _a === void 0 ? void 0 : _a.includes(team.participantId))) {
10784
10787
  participant.teamParticipantIds.push(team.participantId);
10788
+ if (!groupMap.get(team.participantId))
10789
+ groupMap.set(team.participantId, {
10790
+ participantName: team.participantName,
10791
+ participantId: team.participantId,
10792
+ });
10785
10793
  participant.teams.push({
10786
10794
  participantRoleResponsibilities: team.participantRoleResponsibilities,
10787
10795
  participantOtherName: team.participantOtherName,
@@ -10816,7 +10824,7 @@ function addParticipantGroupings(_a) {
10816
10824
  });
10817
10825
  }
10818
10826
  });
10819
- return participantsWithGroupings;
10827
+ return { participantsWithGroupings: participantsWithGroupings, groupInfo: Object.fromEntries(groupMap) };
10820
10828
  }
10821
10829
 
10822
10830
  var extractor = function (object) { return function (attr) { return object[attr]; }; };
@@ -11503,6 +11511,7 @@ function getAllDrawMatchUps(params) {
11503
11511
  return { matchUps: matchUps, matchUpsMap: matchUpsMap };
11504
11512
  }
11505
11513
  function getDrawMatchUps(params) {
11514
+ var _a;
11506
11515
  if (!(params === null || params === void 0 ? void 0 : params.drawDefinition))
11507
11516
  return { error: MISSING_DRAW_DEFINITION };
11508
11517
  var tournamentParticipants = params.tournamentParticipants, contextContent = params.contextContent, matchUpsMap = params.matchUpsMap;
@@ -11523,14 +11532,15 @@ function getDrawMatchUps(params) {
11523
11532
  // getParticipants() calls allEventMatchUps()
11524
11533
  // ...so participants must be sourced directly from tournamentRecord
11525
11534
  // ...and groupings must be added independent of that
11535
+ var groupInfo;
11526
11536
  if (!(tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.length) && tournamentRecord) {
11527
11537
  tournamentParticipants = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
11528
11538
  if ((inContext || (participantsProfile === null || participantsProfile === void 0 ? void 0 : participantsProfile.withGroupings)) &&
11529
11539
  (tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.length)) {
11530
- tournamentParticipants = addParticipantGroupings({
11540
+ (_a = addParticipantGroupings({
11531
11541
  participants: tournamentParticipants,
11532
11542
  participantsProfile: participantsProfile,
11533
- });
11543
+ }), tournamentParticipants = _a.participantsWithGroupings, groupInfo = _a.groupInfo);
11534
11544
  }
11535
11545
  }
11536
11546
  var structures = getDrawStructures({ drawDefinition: drawDefinition }).structures;
@@ -11584,7 +11594,7 @@ function getDrawMatchUps(params) {
11584
11594
  }
11585
11595
  return matchUps;
11586
11596
  };
11587
- var matchUpGroups = __assign({ abandonedMatchUps: applyFilter(allAbandonedMatchUps), completedMatchUps: applyFilter(allCompletedMatchUps), upcomingMatchUps: applyFilter(allUpcomingMatchUps), pendingMatchUps: applyFilter(allPendingMatchUps), byeMatchUps: applyFilter(allByeMatchUps), matchUpsMap: matchUpsMap }, SUCCESS);
11597
+ var drawMatchUpsResult = __assign(__assign({ abandonedMatchUps: applyFilter(allAbandonedMatchUps), completedMatchUps: applyFilter(allCompletedMatchUps), upcomingMatchUps: applyFilter(allUpcomingMatchUps), pendingMatchUps: applyFilter(allPendingMatchUps), byeMatchUps: applyFilter(allByeMatchUps), matchUpsMap: matchUpsMap }, SUCCESS), { groupInfo: groupInfo });
11588
11598
  if (nextMatchUps) {
11589
11599
  var nextFilter = typeof nextMatchUps === 'object' || {
11590
11600
  abandoned: true,
@@ -11600,7 +11610,7 @@ function getDrawMatchUps(params) {
11600
11610
  drawDefinition: drawDefinition,
11601
11611
  });
11602
11612
  }
11603
- return matchUpGroups;
11613
+ return drawMatchUpsResult;
11604
11614
  }
11605
11615
 
11606
11616
  var toBePlayed = {
@@ -17726,11 +17736,11 @@ function initializeParticipantId(_a) {
17726
17736
  }
17727
17737
 
17728
17738
  function hydrateParticipants(_a) {
17729
- var e_1, _b;
17730
- var _c;
17739
+ var _b, e_1, _c;
17740
+ var _d;
17731
17741
  var participantsProfile = _a.participantsProfile, useParticipantMap = _a.useParticipantMap, tournamentRecord = _a.tournamentRecord, contextProfile = _a.contextProfile, inContext = _a.inContext;
17732
17742
  if (useParticipantMap) {
17733
- var participantMap = (_c = getParticipantMap(__assign(__assign(__assign({}, participantsProfile), contextProfile), { tournamentRecord: tournamentRecord }))) === null || _c === void 0 ? void 0 : _c.participantMap;
17743
+ var participantMap = (_d = getParticipantMap(__assign(__assign(__assign({}, participantsProfile), contextProfile), { tournamentRecord: tournamentRecord }))) === null || _d === void 0 ? void 0 : _d.participantMap;
17734
17744
  return { participantMap: participantMap };
17735
17745
  }
17736
17746
  var participants = makeDeepCopy(tournamentRecord.participants, false, true) || [];
@@ -17738,18 +17748,20 @@ function hydrateParticipants(_a) {
17738
17748
  participants.forEach(function (participant) {
17739
17749
  return addNationalityCode(__assign({ participant: participant }, participantsProfile));
17740
17750
  });
17751
+ var groupInfo;
17741
17752
  if ((inContext || (participantsProfile === null || participantsProfile === void 0 ? void 0 : participantsProfile.withGroupings)) &&
17742
17753
  (participants === null || participants === void 0 ? void 0 : participants.length)) {
17743
- participants = addParticipantGroupings({
17754
+ (_b = addParticipantGroupings({
17744
17755
  participantsProfile: participantsProfile,
17756
+ deepCopy: false,
17745
17757
  participants: participants,
17746
- });
17758
+ }), participants = _b.participantsWithGroupings, groupInfo = _b.groupInfo);
17747
17759
  }
17748
17760
  if ((participantsProfile === null || participantsProfile === void 0 ? void 0 : participantsProfile.withScaleValues) && (participants === null || participants === void 0 ? void 0 : participants.length)) {
17749
17761
  try {
17750
17762
  for (var participants_1 = __values(participants), participants_1_1 = participants_1.next(); !participants_1_1.done; participants_1_1 = participants_1.next()) {
17751
17763
  var participant = participants_1_1.value;
17752
- var _d = getScaleValues({ participant: participant }), ratings = _d.ratings, rankings = _d.rankings;
17764
+ var _e = getScaleValues({ participant: participant }), ratings = _e.ratings, rankings = _e.rankings;
17753
17765
  participant.rankings = rankings;
17754
17766
  participant.ratings = ratings;
17755
17767
  }
@@ -17757,12 +17769,12 @@ function hydrateParticipants(_a) {
17757
17769
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
17758
17770
  finally {
17759
17771
  try {
17760
- if (participants_1_1 && !participants_1_1.done && (_b = participants_1.return)) _b.call(participants_1);
17772
+ if (participants_1_1 && !participants_1_1.done && (_c = participants_1.return)) _c.call(participants_1);
17761
17773
  }
17762
17774
  finally { if (e_1) throw e_1.error; }
17763
17775
  }
17764
17776
  }
17765
- return { participants: participants };
17777
+ return { participants: participants, groupInfo: groupInfo };
17766
17778
  }
17767
17779
 
17768
17780
  function allTournamentMatchUps(params) {
@@ -17827,6 +17839,7 @@ function allDrawMatchUps$1(params) {
17827
17839
  var scheduleVisibilityFilters = params.scheduleVisibilityFilters, tournamentAppliedPolicies = params.tournamentAppliedPolicies, participantsProfile = params.participantsProfile, afterRecoveryTimes = params.afterRecoveryTimes, policyDefinitions = params.policyDefinitions, useParticipantMap = params.useParticipantMap, tournamentRecord = params.tournamentRecord, contextFilters = params.contextFilters, contextProfile = params.contextProfile, drawDefinition = params.drawDefinition, matchUpFilters = params.matchUpFilters, nextMatchUps = params.nextMatchUps, inContext = params.inContext, context = params.context, event = params.event;
17828
17840
  var _e = event !== null && event !== void 0 ? event : {}, eventId = _e.eventId, eventName = _e.eventName, eventType = _e.eventType, category = _e.category, gender = _e.gender, matchUpFormat = _e.matchUpFormat;
17829
17841
  var additionalContext = __assign(__assign({}, context), { eventId: eventId, eventType: eventType, eventName: eventName, category: category, gender: gender, matchUpFormat: matchUpFormat, indoorOutDoor: (_c = event === null || event === void 0 ? void 0 : event.indoorOutdoor) !== null && _c !== void 0 ? _c : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.indoorOutdoor, surfaceCategory: (_d = event === null || event === void 0 ? void 0 : event.surfaceCategory) !== null && _d !== void 0 ? _d : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.surfaceCategory, endDate: event === null || event === void 0 ? void 0 : event.endDate });
17842
+ var groupInfo;
17830
17843
  if (!(tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.length) && !participantMap && tournamentRecord) {
17831
17844
  (_a = hydrateParticipants({
17832
17845
  participantsProfile: participantsProfile,
@@ -17835,7 +17848,7 @@ function allDrawMatchUps$1(params) {
17835
17848
  tournamentRecord: tournamentRecord,
17836
17849
  contextProfile: contextProfile,
17837
17850
  inContext: inContext,
17838
- }), _b = _a.participants, tournamentParticipants = _b === void 0 ? [] : _b, participantMap = _a.participantMap);
17851
+ }), _b = _a.participants, tournamentParticipants = _b === void 0 ? [] : _b, participantMap = _a.participantMap, groupInfo = _a.groupInfo);
17839
17852
  }
17840
17853
  if (contextProfile && !contextContent) {
17841
17854
  contextContent = getContextContent({
@@ -17846,7 +17859,7 @@ function allDrawMatchUps$1(params) {
17846
17859
  event: event,
17847
17860
  });
17848
17861
  }
17849
- return getAllDrawMatchUps({
17862
+ var allDrawMatchUpsResult = getAllDrawMatchUps({
17850
17863
  context: additionalContext,
17851
17864
  tournamentAppliedPolicies: tournamentAppliedPolicies,
17852
17865
  scheduleVisibilityFilters: scheduleVisibilityFilters,
@@ -17865,6 +17878,7 @@ function allDrawMatchUps$1(params) {
17865
17878
  inContext: inContext,
17866
17879
  event: event,
17867
17880
  });
17881
+ return __assign(__assign({}, allDrawMatchUpsResult), { groupInfo: groupInfo });
17868
17882
  }
17869
17883
  function allEventMatchUps(params) {
17870
17884
  var _a, _b, _c, _d, _e;
@@ -17894,6 +17908,7 @@ function allEventMatchUps(params) {
17894
17908
  event: event,
17895
17909
  });
17896
17910
  }
17911
+ var groupInfo;
17897
17912
  if (!(participants === null || participants === void 0 ? void 0 : participants.length) && !participantMap && tournamentRecord) {
17898
17913
  var hydratedParticipantResult = hydrateParticipants({
17899
17914
  participantsProfile: participantsProfile,
@@ -17905,6 +17920,7 @@ function allEventMatchUps(params) {
17905
17920
  });
17906
17921
  participantMap = hydratedParticipantResult.participantMap;
17907
17922
  participants = (_d = hydratedParticipantResult.participants) !== null && _d !== void 0 ? _d : [];
17923
+ groupInfo = hydratedParticipantResult.groupInfo;
17908
17924
  }
17909
17925
  var drawDefinitions = (_e = event.drawDefinitions) !== null && _e !== void 0 ? _e : [];
17910
17926
  var scheduleTiming = getScheduleTiming({
@@ -17934,7 +17950,7 @@ function allEventMatchUps(params) {
17934
17950
  }).matchUps;
17935
17951
  return matchUps !== null && matchUps !== void 0 ? matchUps : [];
17936
17952
  });
17937
- return { matchUps: matchUps };
17953
+ return { matchUps: matchUps, groupInfo: groupInfo };
17938
17954
  }
17939
17955
  function tournamentMatchUps(params) {
17940
17956
  var _a, _b, _c;
@@ -17951,7 +17967,7 @@ function tournamentMatchUps(params) {
17951
17967
  tournamentRecord: tournamentRecord,
17952
17968
  contextProfile: contextProfile,
17953
17969
  inContext: inContext,
17954
- }), participants = _e.participants, participantMap = _e.participantMap;
17970
+ }), participants = _e.participants, participantMap = _e.participantMap, groupInfo = _e.groupInfo;
17955
17971
  if (contextProfile && !contextContent)
17956
17972
  contextContent = getContextContent({
17957
17973
  policyDefinitions: policyDefinitions,
@@ -17988,17 +18004,20 @@ function tournamentMatchUps(params) {
17988
18004
  event: event,
17989
18005
  });
17990
18006
  });
17991
- return eventsDrawsMatchUps.reduce(function (matchUps, eventMatchUps) {
18007
+ var eventsDrawMatchUpsResult = eventsDrawsMatchUps.reduce(function (matchUps, eventMatchUps) {
17992
18008
  var keys = eventMatchUps &&
17993
18009
  Object.keys(eventMatchUps).filter(function (key) { return !['success', 'matchUpsMap'].includes(key); });
17994
18010
  keys === null || keys === void 0 ? void 0 : keys.forEach(function (key) {
17995
- if (!matchUps[key])
17996
- matchUps[key] = [];
17997
- matchUps[key] = matchUps[key].concat(eventMatchUps[key]);
17998
- matchUps.matchUpsCount += eventMatchUps[key].length;
18011
+ if (Array.isArray(eventMatchUps[key])) {
18012
+ if (!matchUps[key])
18013
+ matchUps[key] = [];
18014
+ matchUps[key] = matchUps[key].concat(eventMatchUps[key]);
18015
+ matchUps.matchUpsCount += eventMatchUps[key].length;
18016
+ }
17999
18017
  });
18000
18018
  return matchUps;
18001
18019
  }, { matchUpsCount: 0 });
18020
+ return __assign(__assign({}, eventsDrawMatchUpsResult), { groupInfo: groupInfo });
18002
18021
  }
18003
18022
  function eventMatchUps(params) {
18004
18023
  var _a;
@@ -18016,6 +18035,7 @@ function eventMatchUps(params) {
18016
18035
  indoorOutDoor: (_b = event.indoorOutdoor) !== null && _b !== void 0 ? _b : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.indoorOutdoor,
18017
18036
  surfaceCategory: (_c = event.surfaceCategory) !== null && _c !== void 0 ? _c : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.surfaceCategory,
18018
18037
  }));
18038
+ var groupInfo;
18019
18039
  if (!tournamentParticipants && tournamentRecord) {
18020
18040
  (_a = hydrateParticipants({
18021
18041
  participantsProfile: participantsProfile,
@@ -18024,7 +18044,7 @@ function eventMatchUps(params) {
18024
18044
  tournamentRecord: tournamentRecord,
18025
18045
  contextProfile: contextProfile,
18026
18046
  inContext: inContext,
18027
- }), tournamentParticipants = _a.participants, participantMap = _a.participantMap);
18047
+ }), tournamentParticipants = _a.participants, participantMap = _a.participantMap, groupInfo = _a.groupInfo);
18028
18048
  }
18029
18049
  if (contextProfile && !contextContent)
18030
18050
  contextContent = getContextContent({
@@ -18034,8 +18054,8 @@ function eventMatchUps(params) {
18034
18054
  event: event,
18035
18055
  });
18036
18056
  var drawDefinitions = (_d = event.drawDefinitions) !== null && _d !== void 0 ? _d : [];
18037
- return drawDefinitions.reduce(function (matchUps, drawDefinition) {
18038
- var drawMatchUps = getDrawMatchUps({
18057
+ var eventResult = drawDefinitions.reduce(function (results, drawDefinition) {
18058
+ var drawMatchUpsResult = getDrawMatchUps({
18039
18059
  context: additionalContext,
18040
18060
  tournamentAppliedPolicies: tournamentAppliedPolicies,
18041
18061
  scheduleVisibilityFilters: scheduleVisibilityFilters,
@@ -18054,14 +18074,17 @@ function eventMatchUps(params) {
18054
18074
  inContext: inContext,
18055
18075
  event: event,
18056
18076
  });
18057
- var keys = Object.keys(drawMatchUps);
18077
+ var keys = Object.keys(drawMatchUpsResult);
18058
18078
  keys === null || keys === void 0 ? void 0 : keys.forEach(function (key) {
18059
- if (!matchUps[key])
18060
- matchUps[key] = [];
18061
- matchUps[key] = matchUps[key].concat(drawMatchUps[key]);
18079
+ if (Array.isArray(drawMatchUpsResult[key])) {
18080
+ if (!results[key])
18081
+ results[key] = [];
18082
+ results[key] = results[key].concat(drawMatchUpsResult[key]);
18083
+ }
18062
18084
  });
18063
- return matchUps;
18085
+ return results;
18064
18086
  }, {});
18087
+ return __assign(__assign(__assign({}, eventResult), SUCCESS), { groupInfo: groupInfo });
18065
18088
  }
18066
18089
  function drawMatchUps$1(_a) {
18067
18090
  var _b;
@@ -18076,6 +18099,7 @@ function drawMatchUps$1(_a) {
18076
18099
  indoorOutDoor: (_d = event === null || event === void 0 ? void 0 : event.indoorOutdoor) !== null && _d !== void 0 ? _d : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.indoorOutdoor,
18077
18100
  surfaceCategory: (_e = event === null || event === void 0 ? void 0 : event.surfaceCategory) !== null && _e !== void 0 ? _e : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.surfaceCategory,
18078
18101
  }));
18102
+ var groupInfo;
18079
18103
  if (!(tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.length) && tournamentRecord) {
18080
18104
  (_b = hydrateParticipants({
18081
18105
  participantsProfile: participantsProfile,
@@ -18084,7 +18108,7 @@ function drawMatchUps$1(_a) {
18084
18108
  tournamentRecord: tournamentRecord,
18085
18109
  contextProfile: contextProfile,
18086
18110
  inContext: inContext,
18087
- }), tournamentParticipants = _b.participants, participantMap = _b.participantMap);
18111
+ }), tournamentParticipants = _b.participants, participantMap = _b.participantMap, groupInfo = _b.groupInfo);
18088
18112
  }
18089
18113
  if (event && contextProfile && !contextContent)
18090
18114
  contextContent = getContextContent({
@@ -18094,7 +18118,7 @@ function drawMatchUps$1(_a) {
18094
18118
  drawDefinition: drawDefinition,
18095
18119
  event: event,
18096
18120
  });
18097
- return getDrawMatchUps({
18121
+ var drawMatchUpsResult = getDrawMatchUps({
18098
18122
  context: additionalContext,
18099
18123
  tournamentAppliedPolicies: tournamentAppliedPolicies,
18100
18124
  scheduleVisibilityFilters: scheduleVisibilityFilters,
@@ -18113,6 +18137,7 @@ function drawMatchUps$1(_a) {
18113
18137
  inContext: inContext,
18114
18138
  event: event,
18115
18139
  });
18140
+ return __assign(__assign({}, drawMatchUpsResult), { groupInfo: groupInfo });
18116
18141
  }
18117
18142
 
18118
18143
  function addFinishingRounds(_a) {
@@ -18323,15 +18348,22 @@ function competitionMatchUps(_a) {
18323
18348
  inContext: inContext,
18324
18349
  });
18325
18350
  });
18326
- return tournamentsMatchUps.reduce(function (groupings, matchUpGroupings) {
18351
+ var groupInfo = {};
18352
+ var competitionMatchUpsResult = tournamentsMatchUps.reduce(function (groupings, matchUpGroupings) {
18327
18353
  var keys = Object.keys(matchUpGroupings);
18328
18354
  keys.forEach(function (key) {
18329
- if (!groupings[key])
18330
- groupings[key] = [];
18331
- groupings[key] = groupings[key].concat(matchUpGroupings[key]);
18355
+ if (Array.isArray(matchUpGroupings[key])) {
18356
+ if (!groupings[key])
18357
+ groupings[key] = [];
18358
+ groupings[key] = groupings[key].concat(matchUpGroupings[key]);
18359
+ }
18360
+ if (key === 'groupInfo') {
18361
+ Object.assign(groupInfo, matchUpGroupings[key]);
18362
+ }
18332
18363
  });
18333
18364
  return groupings;
18334
18365
  }, {});
18366
+ return __assign(__assign({}, competitionMatchUpsResult), { groupInfo: groupInfo });
18335
18367
  }
18336
18368
 
18337
18369
  /**
@@ -25889,9 +25921,115 @@ function getSeedingThresholds(_a) {
25889
25921
  return __assign(__assign({}, SUCCESS), { seedingThresholds: seedingThresholds });
25890
25922
  }
25891
25923
 
25924
+ function getDivisions(_a) {
25925
+ var size = _a.size;
25926
+ var divisions = [size];
25927
+ var division = size;
25928
+ while (division / 2 === Math.floor(division / 2)) {
25929
+ division = division / 2;
25930
+ divisions.push(division);
25931
+ }
25932
+ if (!divisions.includes(1))
25933
+ divisions.push(1);
25934
+ divisions.sort(numericSort);
25935
+ divisions.reverse();
25936
+ return divisions;
25937
+ }
25938
+ function getSubBlock(_a) {
25939
+ var e_1, _b;
25940
+ var blockPattern = _a.blockPattern, index = _a.index;
25941
+ var i = 0;
25942
+ try {
25943
+ for (var blockPattern_1 = __values(blockPattern), blockPattern_1_1 = blockPattern_1.next(); !blockPattern_1_1.done; blockPattern_1_1 = blockPattern_1.next()) {
25944
+ var subBlock = blockPattern_1_1.value;
25945
+ if (i === index)
25946
+ return subBlock;
25947
+ var j = 0;
25948
+ while (j < subBlock.length) {
25949
+ if (i === index)
25950
+ return subBlock;
25951
+ i += 1;
25952
+ j++;
25953
+ }
25954
+ }
25955
+ }
25956
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
25957
+ finally {
25958
+ try {
25959
+ if (blockPattern_1_1 && !blockPattern_1_1.done && (_b = blockPattern_1.return)) _b.call(blockPattern_1);
25960
+ }
25961
+ finally { if (e_1) throw e_1.error; }
25962
+ }
25963
+ }
25964
+ function generateBlockPattern(_a) {
25965
+ var e_2, _b;
25966
+ var positioning = _a.positioning, size = _a.size;
25967
+ var divisions = getDivisions({ size: size });
25968
+ var divisionGroupings = [];
25969
+ var selected = [];
25970
+ var firstMember = function (arr) { return arr[0]; };
25971
+ var lastMember = function (arr) { return arr[arr.length - 1]; };
25972
+ var getMember = function (arr, i) {
25973
+ return (positioning === CLUSTER && i % 2 ? lastMember(arr) : firstMember(arr)) ||
25974
+ firstMember(arr);
25975
+ };
25976
+ var noneSelected = function (chunk, i) {
25977
+ if (chunk.every(function (member) { return !selected.includes(member); })) {
25978
+ var member = getMember(chunk, i);
25979
+ selected.push(member);
25980
+ return member;
25981
+ }
25982
+ };
25983
+ var notSelected = function (chunk) {
25984
+ var notSelected = chunk.filter(function (member) { return !selected.includes(member); });
25985
+ if (notSelected.length) {
25986
+ selected.push.apply(selected, __spreadArray([], __read(notSelected), false));
25987
+ return notSelected;
25988
+ }
25989
+ };
25990
+ var select = function (chunk, i) {
25991
+ var member = getMember(chunk, i);
25992
+ if (!selected.includes(member)) {
25993
+ selected.push(member);
25994
+ return member;
25995
+ }
25996
+ };
25997
+ var range = generateRange(1, size + 1);
25998
+ try {
25999
+ for (var divisions_1 = __values(divisions), divisions_1_1 = divisions_1.next(); !divisions_1_1.done; divisions_1_1 = divisions_1.next()) {
26000
+ var division = divisions_1_1.value;
26001
+ if (division === 1) {
26002
+ var chunks = chunkArray(range, 2);
26003
+ // first check all pairs for pair that has no member included in selected
26004
+ var positions = chunks.map(noneSelected).filter(Boolean);
26005
+ if (positions.length)
26006
+ divisionGroupings.push(positions);
26007
+ // then return positions from each chunk which are not selected
26008
+ var lastPositions = chunks.flatMap(notSelected).filter(Boolean);
26009
+ if (lastPositions.length)
26010
+ divisionGroupings.push(lastPositions);
26011
+ }
26012
+ else {
26013
+ var chunks = chunkArray(range, division);
26014
+ var positions = chunks.map(select).filter(Boolean);
26015
+ if (positions.length)
26016
+ divisionGroupings.push(positions);
26017
+ }
26018
+ }
26019
+ }
26020
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
26021
+ finally {
26022
+ try {
26023
+ if (divisions_1_1 && !divisions_1_1.done && (_b = divisions_1.return)) _b.call(divisions_1);
26024
+ }
26025
+ finally { if (e_2) throw e_2.error; }
26026
+ }
26027
+ return { divisions: divisions, divisionGroupings: divisionGroupings };
26028
+ }
26029
+
25892
26030
  function getValidSeedBlocks(_a) {
25893
26031
  var _b, _c;
25894
- var provisionalPositioning = _a.provisionalPositioning, returnAllProxies = _a.returnAllProxies, appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, allPositions = _a.allPositions, structure = _a.structure;
26032
+ var provisionalPositioning = _a.provisionalPositioning, returnAllProxies = _a.returnAllProxies, appliedPolicies = _a.appliedPolicies, seedingProfile = _a.seedingProfile, drawDefinition = _a.drawDefinition, allPositions = _a.allPositions, structure = _a.structure;
25895
26033
  var validSeedBlocks = [];
25896
26034
  if (!structure)
25897
26035
  return { error: MISSING_STRUCTURE };
@@ -25927,7 +26065,7 @@ function getValidSeedBlocks(_a) {
25927
26065
  .reverse();
25928
26066
  var firstRoundDrawPositions = uniqueDrawPositionsByRound.pop();
25929
26067
  var firstRoundDrawPositionOffset = (firstRoundDrawPositions && Math.min.apply(Math, __spreadArray([], __read(firstRoundDrawPositions), false)) - 1) || 0;
25930
- var seedingProfile = (_c = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.seeding) === null || _c === void 0 ? void 0 : _c.seedingProfile;
26068
+ seedingProfile = seedingProfile !== null && seedingProfile !== void 0 ? seedingProfile : (_c = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.seeding) === null || _c === void 0 ? void 0 : _c.seedingProfile;
25931
26069
  var baseDrawSize = (firstRoundDrawPositions === null || firstRoundDrawPositions === void 0 ? void 0 : firstRoundDrawPositions.length) || 0;
25932
26070
  // firstRoundDrawPositions have been popped
25933
26071
  // seedRangeDrawPositionBlocks determines FEED_IN
@@ -25971,6 +26109,7 @@ function getValidSeedBlocks(_a) {
25971
26109
  });
25972
26110
  (validSeedBlocks = getSeedBlockPattern({
25973
26111
  drawPositionBlocks: drawPositionChunks_1,
26112
+ nonRandom: seedingProfile === null || seedingProfile === void 0 ? void 0 : seedingProfile.nonRandom,
25974
26113
  positioning: positioning,
25975
26114
  seedGroups: seedGroups,
25976
26115
  }).validSeedBlocks);
@@ -25978,6 +26117,7 @@ function getValidSeedBlocks(_a) {
25978
26117
  }
25979
26118
  else if (isContainer) {
25980
26119
  var result = getContainerBlocks({
26120
+ nonRandom: seedingProfile === null || seedingProfile === void 0 ? void 0 : seedingProfile.nonRandom,
25981
26121
  seedingProfile: seedingProfile,
25982
26122
  structure: structure,
25983
26123
  });
@@ -26029,7 +26169,7 @@ function getValidSeedBlocks(_a) {
26029
26169
  }
26030
26170
  function getContainerBlocks(_a) {
26031
26171
  var _b, _c;
26032
- var seedingProfile = _a.seedingProfile, structure = _a.structure;
26172
+ var seedingProfile = _a.seedingProfile, structure = _a.structure, nonRandom = _a.nonRandom;
26033
26173
  var containedStructures = structure.structures || [];
26034
26174
  var roundRobinGroupsCount = containedStructures.length;
26035
26175
  var positionAssignments = (_b = getPositionAssignments$1({
@@ -26051,28 +26191,42 @@ function getContainerBlocks(_a) {
26051
26191
  drawPositionBlocks: drawPositionBlocks,
26052
26192
  positioning: positioning,
26053
26193
  seedGroups: seedGroups,
26194
+ nonRandom: nonRandom,
26054
26195
  });
26055
26196
  }
26056
26197
  function getSeedBlockPattern(_a) {
26057
- var positioning = _a.positioning, seedGroups = _a.seedGroups, drawPositionBlocks = _a.drawPositionBlocks;
26198
+ var drawPositionBlocks = _a.drawPositionBlocks, positioning = _a.positioning, seedGroups = _a.seedGroups, nonRandom = _a.nonRandom;
26058
26199
  var validSeedBlocks = [];
26059
- var topDown = function (a, b) { return a - b; };
26060
- var bottomUp = function (a, b) { return b - a; };
26200
+ var divisionGroupings = generateBlockPattern({
26201
+ size: seedGroups.length,
26202
+ positioning: positioning,
26203
+ }).divisionGroupings;
26061
26204
  var assignedPositions = [];
26062
26205
  seedGroups.forEach(function (seedGroup, i) {
26063
- if (i && positioning !== WATERFALL) {
26064
- shuffleArray(seedGroup);
26065
- }
26206
+ var relativePositions = getSubBlock({
26207
+ blockPattern: divisionGroupings,
26208
+ index: i,
26209
+ });
26066
26210
  seedGroup.forEach(function (seedNumber, j) {
26067
26211
  var blockIndex = i % 2 ? drawPositionBlocks.length - j - 1 : j;
26068
- var drawPosition = drawPositionBlocks[blockIndex]
26069
- .sort(i % 2 ? bottomUp : topDown)
26070
- .find(function (drawPosition) { return !assignedPositions.includes(drawPosition); });
26071
- assignedPositions.push(drawPosition);
26072
- validSeedBlocks.push({
26073
- seedNumbers: [seedNumber],
26074
- drawPositions: [drawPosition],
26075
- });
26212
+ var block = drawPositionBlocks[blockIndex].slice();
26213
+ var consideredDrawPositions = block.filter(function (drawPosition, i) { return relativePositions.includes(i + 1) && drawPosition; });
26214
+ if (positioning !== WATERFALL) {
26215
+ consideredDrawPositions = nonRandom
26216
+ ? consideredDrawPositions
26217
+ : shuffleArray(consideredDrawPositions);
26218
+ }
26219
+ else if (i % 2) {
26220
+ consideredDrawPositions.reverse();
26221
+ }
26222
+ var drawPosition = consideredDrawPositions.find(function (drawPosition) { return !assignedPositions.includes(drawPosition); });
26223
+ if (drawPosition) {
26224
+ assignedPositions.push(drawPosition);
26225
+ validSeedBlocks.push({
26226
+ seedNumbers: [seedNumber],
26227
+ drawPositions: [drawPosition],
26228
+ });
26229
+ }
26076
26230
  });
26077
26231
  });
26078
26232
  return { validSeedBlocks: validSeedBlocks };
@@ -26140,7 +26294,7 @@ function isValidSeedPosition(_a) {
26140
26294
  }
26141
26295
  function getNextSeedBlock(params) {
26142
26296
  var _a, _b, _c;
26143
- var provisionalPositioning = params.provisionalPositioning, drawDefinition = params.drawDefinition, seedBlockInfo = params.seedBlockInfo, structureId = params.structureId, randomize = params.randomize;
26297
+ var provisionalPositioning = params.provisionalPositioning, drawDefinition = params.drawDefinition, seedingProfile = params.seedingProfile, seedBlockInfo = params.seedBlockInfo, structureId = params.structureId, randomize = params.randomize;
26144
26298
  var structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure;
26145
26299
  var seedAssignments = getStructureSeedAssignments({
26146
26300
  returnAllProxies: params.returnAllProxies,
@@ -26159,6 +26313,7 @@ function getNextSeedBlock(params) {
26159
26313
  provisionalPositioning: provisionalPositioning,
26160
26314
  appliedPolicies: appliedPolicies,
26161
26315
  drawDefinition: drawDefinition,
26316
+ seedingProfile: seedingProfile,
26162
26317
  structure: structure,
26163
26318
  })) === null || _a === void 0 ? void 0 : _a.validSeedBlocks));
26164
26319
  var unfilledSeedBlocks = (validSeedBlocks || []).filter(function (seedBlock) {
@@ -32872,13 +33027,14 @@ function publicFindMatchUp(params) {
32872
33027
  }
32873
33028
  function findMatchUp(_a) {
32874
33029
  var _b;
32875
- var _c, _d, _e, _f;
33030
+ var _c, _d, _e, _f, _g, _h;
32876
33031
  var participantsProfile = _a.participantsProfile, afterRecoveryTimes = _a.afterRecoveryTimes, tournamentRecord = _a.tournamentRecord, contextContent = _a.contextContent, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, nextMatchUps = _a.nextMatchUps, matchUpId = _a.matchUpId, inContext = _a.inContext, eventId = _a.eventId, drawId = _a.drawId, event = _a.event;
32877
33032
  if (!tournamentRecord)
32878
33033
  return { error: MISSING_TOURNAMENT_RECORD };
32879
33034
  if (typeof matchUpId !== 'string')
32880
33035
  return { error: MISSING_MATCHUP_ID };
32881
- if (!drawDefinition || !event || nextMatchUps) {
33036
+ // brute force
33037
+ if (!drawDefinition || !event) {
32882
33038
  var matchUps = (_c = allTournamentMatchUps({ tournamentRecord: tournamentRecord, nextMatchUps: nextMatchUps }).matchUps) !== null && _c !== void 0 ? _c : [];
32883
33039
  var inContextMatchUp = matchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
32884
33040
  if (!inContextMatchUp)
@@ -32903,24 +33059,44 @@ function findMatchUp(_a) {
32903
33059
  eventId: eventId !== null && eventId !== void 0 ? eventId : event === null || event === void 0 ? void 0 : event.eventId,
32904
33060
  drawId: drawId,
32905
33061
  };
32906
- var _g = hydrateParticipants({
33062
+ var _j = hydrateParticipants({
32907
33063
  participantsProfile: participantsProfile,
32908
33064
  tournamentRecord: tournamentRecord,
32909
33065
  contextProfile: contextProfile,
32910
33066
  inContext: inContext,
32911
- }).participants, tournamentParticipants = _g === void 0 ? [] : _g;
32912
- var _h = findDrawMatchUp({
32913
- context: inContext ? additionalContext : undefined,
32914
- tournamentParticipants: tournamentParticipants,
32915
- afterRecoveryTimes: afterRecoveryTimes,
32916
- contextContent: contextContent,
32917
- drawDefinition: drawDefinition,
32918
- contextProfile: contextProfile,
32919
- matchUpId: matchUpId,
32920
- inContext: inContext,
32921
- event: event,
32922
- }), matchUp = _h.matchUp, structure = _h.structure;
32923
- return { matchUp: matchUp, structure: structure, drawDefinition: drawDefinition };
33067
+ }).participants, tournamentParticipants = _j === void 0 ? [] : _j;
33068
+ if (nextMatchUps) {
33069
+ var matchUps = (_g = allDrawMatchUps$1({
33070
+ context: inContext ? additionalContext : undefined,
33071
+ participants: tournamentParticipants,
33072
+ afterRecoveryTimes: afterRecoveryTimes,
33073
+ contextContent: contextContent,
33074
+ contextProfile: contextProfile,
33075
+ drawDefinition: drawDefinition,
33076
+ nextMatchUps: nextMatchUps,
33077
+ inContext: inContext,
33078
+ event: event,
33079
+ }).matchUps) !== null && _g !== void 0 ? _g : [];
33080
+ var inContextMatchUp_1 = matchUps.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
33081
+ if (!inContextMatchUp_1)
33082
+ return { error: MATCHUP_NOT_FOUND };
33083
+ var structure = (_h = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _h === void 0 ? void 0 : _h.find(function (structure) { return structure.structureId === inContextMatchUp_1.structureId; });
33084
+ return { drawDefinition: drawDefinition, structure: structure, matchUp: inContextMatchUp_1 };
33085
+ }
33086
+ else {
33087
+ var _k = findDrawMatchUp({
33088
+ context: inContext ? additionalContext : undefined,
33089
+ tournamentParticipants: tournamentParticipants,
33090
+ afterRecoveryTimes: afterRecoveryTimes,
33091
+ contextContent: contextContent,
33092
+ drawDefinition: drawDefinition,
33093
+ contextProfile: contextProfile,
33094
+ matchUpId: matchUpId,
33095
+ inContext: inContext,
33096
+ event: event,
33097
+ }), matchUp = _k.matchUp, structure = _k.structure;
33098
+ return { matchUp: matchUp, structure: structure, drawDefinition: drawDefinition };
33099
+ }
32924
33100
  }
32925
33101
 
32926
33102
  function resetTieFormat$1(_a) {
@@ -34507,7 +34683,7 @@ function competitionScheduleMatchUps(params) {
34507
34683
  params.matchUpFilters.excludeMatchUpStatuses = [COMPLETED$1];
34508
34684
  }
34509
34685
  }
34510
- var _l = competitionMatchUps(__assign(__assign({}, params), { matchUpFilters: params.matchUpFilters, contextFilters: params.contextFilters })), completedMatchUps = _l.completedMatchUps, upcomingMatchUps = _l.upcomingMatchUps, pendingMatchUps = _l.pendingMatchUps;
34686
+ var _l = competitionMatchUps(__assign(__assign({}, params), { matchUpFilters: params.matchUpFilters, contextFilters: params.contextFilters })), completedMatchUps = _l.completedMatchUps, upcomingMatchUps = _l.upcomingMatchUps, pendingMatchUps = _l.pendingMatchUps, groupInfo = _l.groupInfo;
34511
34687
  var relevantMatchUps = __spreadArray(__spreadArray([], __read((upcomingMatchUps !== null && upcomingMatchUps !== void 0 ? upcomingMatchUps : [])), false), __read((pendingMatchUps !== null && pendingMatchUps !== void 0 ? pendingMatchUps : [])), false);
34512
34688
  var dateMatchUps = sortDateMatchUps
34513
34689
  ? scheduledSortedMatchUps({ matchUps: relevantMatchUps, schedulingProfile: schedulingProfile })
@@ -34523,6 +34699,7 @@ function competitionScheduleMatchUps(params) {
34523
34699
  ? allCompletedMatchUps
34524
34700
  : completedMatchUps, // completed matchUps for the filter date
34525
34701
  dateMatchUps: dateMatchUps, // all incomplete matchUps for the filter date
34702
+ groupInfo: groupInfo,
34526
34703
  venues: venues,
34527
34704
  };
34528
34705
  if (withCourtGridRows) {
@@ -34533,7 +34710,7 @@ function competitionScheduleMatchUps(params) {
34533
34710
  result.courtPrefix = courtPrefix; // pass through for access to internal defaults by consumer
34534
34711
  result.rows = rows;
34535
34712
  }
34536
- return result;
34713
+ return __assign(__assign({}, result), SUCCESS);
34537
34714
  function getCourtMatchUps(_a) {
34538
34715
  var courtId = _a.courtId;
34539
34716
  var matchUpsToConsider = courtCompletedMatchUps
@@ -45098,8 +45275,9 @@ function randomUnseededSeparation(_a) {
45098
45275
  var positionAssignments = structureAssignedDrawPositions({ structure: structure }).positionAssignments;
45099
45276
  var participantsWithGroupings = addParticipantGroupings({
45100
45277
  participantsProfile: { convertExtensions: true },
45278
+ deepCopy: false,
45101
45279
  participants: participants,
45102
- });
45280
+ }).participantsWithGroupings;
45103
45281
  var unassignedPositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) { return !assignment.participantId; });
45104
45282
  var allDrawPositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.map(function (assignment) { return assignment.drawPosition; });
45105
45283
  var isRoundRobin = (structure === null || structure === void 0 ? void 0 : structure.structureType) === CONTAINER;
@@ -45518,12 +45696,13 @@ function nestArray(arr) {
45518
45696
 
45519
45697
  function getSeedOrderByePositions(_a) {
45520
45698
  var _b, _c;
45521
- var provisionalPositioning = _a.provisionalPositioning, relevantMatchUps = _a.relevantMatchUps, appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, seedBlockInfo = _a.seedBlockInfo, byesToPlace = _a.byesToPlace, structure = _a.structure;
45699
+ var provisionalPositioning = _a.provisionalPositioning, relevantMatchUps = _a.relevantMatchUps, appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, seedingProfile = _a.seedingProfile, seedBlockInfo = _a.seedBlockInfo, byesToPlace = _a.byesToPlace, structure = _a.structure;
45522
45700
  if (!seedBlockInfo) {
45523
45701
  seedBlockInfo = getValidSeedBlocks({
45524
45702
  provisionalPositioning: provisionalPositioning,
45525
45703
  appliedPolicies: appliedPolicies,
45526
45704
  drawDefinition: drawDefinition,
45705
+ seedingProfile: seedingProfile,
45527
45706
  structure: structure,
45528
45707
  });
45529
45708
  }
@@ -45817,7 +45996,7 @@ function getByesData(_a) {
45817
45996
  function positionByes(_a) {
45818
45997
  var e_1, _b;
45819
45998
  var _c, _d;
45820
- var provisionalPositioning = _a.provisionalPositioning, tournamentRecord = _a.tournamentRecord, appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, seedBlockInfo = _a.seedBlockInfo, matchUpsMap = _a.matchUpsMap, structureId = _a.structureId, structure = _a.structure, seedLimit = _a.seedLimit, seedsOnly = _a.seedsOnly, event = _a.event;
45999
+ var provisionalPositioning = _a.provisionalPositioning, tournamentRecord = _a.tournamentRecord, appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, seedBlockInfo = _a.seedBlockInfo, seedingProfile = _a.seedingProfile, matchUpsMap = _a.matchUpsMap, structureId = _a.structureId, structure = _a.structure, seedLimit = _a.seedLimit, seedsOnly = _a.seedsOnly, event = _a.event;
45821
46000
  if (!structure)
45822
46001
  (structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure);
45823
46002
  if (!structureId)
@@ -45838,6 +46017,7 @@ function positionByes(_a) {
45838
46017
  relevantMatchUps: relevantMatchUps,
45839
46018
  appliedPolicies: appliedPolicies,
45840
46019
  drawDefinition: drawDefinition,
46020
+ seedingProfile: seedingProfile,
45841
46021
  seedBlockInfo: seedBlockInfo,
45842
46022
  byesToPlace: byesToPlace,
45843
46023
  structure: structure,
@@ -46048,6 +46228,7 @@ function positionSeedBlocks(_a) {
46048
46228
  provisionalPositioning: provisionalPositioning,
46049
46229
  appliedPolicies: appliedPolicies,
46050
46230
  drawDefinition: drawDefinition,
46231
+ seedingProfile: seedingProfile,
46051
46232
  structure: structure,
46052
46233
  });
46053
46234
  if (result === null || result === void 0 ? void 0 : result.error)
@@ -46090,6 +46271,7 @@ function positionSeedBlock(_a) {
46090
46271
  provisionalPositioning: provisionalPositioning,
46091
46272
  randomize: true,
46092
46273
  drawDefinition: drawDefinition,
46274
+ seedingProfile: seedingProfile,
46093
46275
  seedBlockInfo: seedBlockInfo,
46094
46276
  structureId: structureId,
46095
46277
  event: event,
@@ -46202,6 +46384,7 @@ function automatedPositioning$1(_a) {
46202
46384
  provisionalPositioning: provisionalPositioning,
46203
46385
  appliedPolicies: appliedPolicies,
46204
46386
  drawDefinition: drawDefinition,
46387
+ seedingProfile: seedingProfile,
46205
46388
  structure: structure,
46206
46389
  });
46207
46390
  if (seedBlockInfo.error)
@@ -51721,7 +51904,7 @@ function getEligibleVoluntaryConsolationParticipants$1(_a) {
51721
51904
  }
51722
51905
 
51723
51906
  function getNextUnfilledDrawPositions(_a) {
51724
- var provisionalPositioning = _a.provisionalPositioning, drawDefinition = _a.drawDefinition, seedBlockInfo = _a.seedBlockInfo, structureId = _a.structureId, event = _a.event;
51907
+ var provisionalPositioning = _a.provisionalPositioning, drawDefinition = _a.drawDefinition, seedBlockInfo = _a.seedBlockInfo, seedingProfile = _a.seedingProfile, structureId = _a.structureId, event = _a.event;
51725
51908
  if (!drawDefinition) {
51726
51909
  var error = MISSING_DRAW_DEFINITION;
51727
51910
  return { error: error, nextUnfilledDrawPositions: [] };
@@ -51741,6 +51924,7 @@ function getNextUnfilledDrawPositions(_a) {
51741
51924
  provisionalPositioning: provisionalPositioning,
51742
51925
  randomize: true,
51743
51926
  drawDefinition: drawDefinition,
51927
+ seedingProfile: seedingProfile,
51744
51928
  seedBlockInfo: seedBlockInfo,
51745
51929
  structureId: structureId,
51746
51930
  event: event,
@@ -52027,7 +52211,7 @@ function getValidLuckyLosersAction(_a) {
52027
52211
 
52028
52212
  function getValidAssignmentActions(_a) {
52029
52213
  var _b, _c, _d;
52030
- var positionSourceStructureIds = _a.positionSourceStructureIds, unassignedParticipantIds = _a.unassignedParticipantIds, possiblyDisablingAction = _a.possiblyDisablingAction, provisionalPositioning = _a.provisionalPositioning, tournamentParticipants = _a.tournamentParticipants, isWinRatioFedStructure = _a.isWinRatioFedStructure, positionAssignments = _a.positionAssignments, returnParticipants = _a.returnParticipants, appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, isByePosition = _a.isByePosition, drawPosition = _a.drawPosition, structureId = _a.structureId, event = _a.event;
52214
+ var positionSourceStructureIds = _a.positionSourceStructureIds, unassignedParticipantIds = _a.unassignedParticipantIds, possiblyDisablingAction = _a.possiblyDisablingAction, provisionalPositioning = _a.provisionalPositioning, tournamentParticipants = _a.tournamentParticipants, isWinRatioFedStructure = _a.isWinRatioFedStructure, positionAssignments = _a.positionAssignments, returnParticipants = _a.returnParticipants, appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, seedingProfile = _a.seedingProfile, isByePosition = _a.isByePosition, drawPosition = _a.drawPosition, structureId = _a.structureId, event = _a.event;
52031
52215
  var drawId = drawDefinition.drawId;
52032
52216
  var validAssignmentActions = [];
52033
52217
  var unplacedSeedParticipantIds, unplacedSeedAssignments, unfilledPositions = [];
@@ -52038,6 +52222,7 @@ function getValidAssignmentActions(_a) {
52038
52222
  returnAllProxies: true,
52039
52223
  randomize: true,
52040
52224
  drawDefinition: drawDefinition,
52225
+ seedingProfile: seedingProfile,
52041
52226
  structureId: structureId,
52042
52227
  event: event,
52043
52228
  });
@@ -64065,6 +64250,7 @@ function prepareStage(params) {
64065
64250
  provisionalPositioning: provisionalPositioning,
64066
64251
  appliedPolicies: appliedPolicies,
64067
64252
  drawDefinition: drawDefinition,
64253
+ seedingProfile: seedingProfile,
64068
64254
  structure: structure,
64069
64255
  })
64070
64256
  : undefined;
@@ -64210,10 +64396,10 @@ function prepareStage(params) {
64210
64396
 
64211
64397
  function generateDrawDefinition(params) {
64212
64398
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, _e, e_5, _f, e_6, _g, _h;
64213
- var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24;
64399
+ var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25;
64214
64400
  var stack = 'generateDrawDefinition';
64215
- var _25 = params.considerEventEntries, considerEventEntries = _25 === void 0 ? true : _25, // in the absence of drawSize and drawEntries, look to event.entries
64216
- ignoreAllowedDrawTypes = params.ignoreAllowedDrawTypes, voluntaryConsolation = params.voluntaryConsolation, hydrateCollections = params.hydrateCollections, policyDefinitions = params.policyDefinitions, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, tieFormatName = params.tieFormatName, drawEntries = params.drawEntries, addToEvent = params.addToEvent, placeByes = params.placeByes, event = params.event;
64401
+ var _26 = params.considerEventEntries, considerEventEntries = _26 === void 0 ? true : _26, // in the absence of drawSize and drawEntries, look to event.entries
64402
+ ignoreAllowedDrawTypes = params.ignoreAllowedDrawTypes, voluntaryConsolation = params.voluntaryConsolation, hydrateCollections = params.hydrateCollections, policyDefinitions = params.policyDefinitions, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, seedingProfile = params.seedingProfile, tieFormatName = params.tieFormatName, drawEntries = params.drawEntries, addToEvent = params.addToEvent, placeByes = params.placeByes, event = params.event;
64217
64403
  var appliedPolicies = (_j = getAppliedPolicies({
64218
64404
  tournamentRecord: tournamentRecord,
64219
64405
  event: event,
@@ -64226,10 +64412,10 @@ function generateDrawDefinition(params) {
64226
64412
  DrawTypeEnum.SingleElimination;
64227
64413
  // get participants both for entry validation and for automated placement
64228
64414
  // automated placement requires them to be "inContext" for avoidance policies to work
64229
- var _26 = getParticipants$1({
64415
+ var _27 = getParticipants$1({
64230
64416
  withIndividualParticipants: true,
64231
64417
  tournamentRecord: tournamentRecord,
64232
- }), participants = _26.participants, participantMap = _26.participantMap;
64418
+ }), participants = _27.participants, participantMap = _27.participantMap;
64233
64419
  var enforceGender = (_r = (_o = params.enforceGender) !== null && _o !== void 0 ? _o : (_q = (_p = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _p === void 0 ? void 0 : _p.participants) === null || _q === void 0 ? void 0 : _q.enforceGender) !== null && _r !== void 0 ? _r : (_t = (_s = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _s === void 0 ? void 0 : _s.participants) === null || _t === void 0 ? void 0 : _t.enforceGender;
64234
64420
  // if tournamentRecord is provided, and unless instructed to ignore valid types,
64235
64421
  // check for restrictions on allowed drawTypes
@@ -64399,8 +64585,8 @@ function generateDrawDefinition(params) {
64399
64585
  else {
64400
64586
  var policiesToAttach = {};
64401
64587
  try {
64402
- for (var _27 = __values(Object.keys(policyDefinitions)), _28 = _27.next(); !_28.done; _28 = _27.next()) {
64403
- var key = _28.value;
64588
+ for (var _28 = __values(Object.keys(policyDefinitions)), _29 = _28.next(); !_29.done; _29 = _28.next()) {
64589
+ var key = _29.value;
64404
64590
  if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !==
64405
64591
  JSON.stringify(policyDefinitions[key])) {
64406
64592
  policiesToAttach[key] = policyDefinitions[key];
@@ -64410,7 +64596,7 @@ function generateDrawDefinition(params) {
64410
64596
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
64411
64597
  finally {
64412
64598
  try {
64413
- if (_28 && !_28.done && (_a = _27.return)) _a.call(_27);
64599
+ if (_29 && !_29.done && (_a = _28.return)) _a.call(_28);
64414
64600
  }
64415
64601
  finally { if (e_1) throw e_1.error; }
64416
64602
  }
@@ -64462,7 +64648,7 @@ function generateDrawDefinition(params) {
64462
64648
  var source = _a.source;
64463
64649
  return source.structureId !== existingQualifyingPlaceholderStructureId;
64464
64650
  });
64465
- var _29 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _29.qualifiersCount, qualifyingDrawPositionsCount = _29.qualifyingDrawPositionsCount, qualifyingDetails = _29.qualifyingDetails;
64651
+ var _30 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _30.qualifiersCount, qualifyingDrawPositionsCount = _30.qualifyingDrawPositionsCount, qualifyingDetails = _30.qualifyingDetails;
64466
64652
  if (qualifyingDrawPositionsCount) {
64467
64653
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
64468
64654
  (_13 = drawDefinition.structures) === null || _13 === void 0 ? void 0 : _13.push.apply(_13, __spreadArray([], __read(qualifyingResult.structures), false));
@@ -64497,11 +64683,11 @@ function generateDrawDefinition(params) {
64497
64683
  if (result.error)
64498
64684
  return result;
64499
64685
  try {
64500
- for (var _30 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
64686
+ for (var _31 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
64501
64687
  var entryStage = _a.entryStage;
64502
64688
  return entryStage === StageTypeEnum.Qualifying;
64503
- })), _31 = _30.next(); !_31.done; _31 = _30.next()) {
64504
- var entry = _31.value;
64689
+ })), _32 = _31.next(); !_32.done; _32 = _31.next()) {
64690
+ var entry = _32.value;
64505
64691
  var entryData = __assign(__assign({}, entry), { entryStage: (_16 = entry.entryStage) !== null && _16 !== void 0 ? _16 : StageTypeEnum.Main, drawDefinition: drawDefinition });
64506
64692
  // ignore errors (EXITING_PARTICIPANT)
64507
64693
  addDrawEntry(entryData);
@@ -64510,13 +64696,13 @@ function generateDrawDefinition(params) {
64510
64696
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
64511
64697
  finally {
64512
64698
  try {
64513
- if (_31 && !_31.done && (_b = _30.return)) _b.call(_30);
64699
+ if (_32 && !_32.done && (_b = _31.return)) _b.call(_31);
64514
64700
  }
64515
64701
  finally { if (e_2) throw e_2.error; }
64516
64702
  }
64517
64703
  try {
64518
- for (var _32 = __values(qualifyingDetails || []), _33 = _32.next(); !_33.done; _33 = _32.next()) {
64519
- var qualifyingDetail = _33.value;
64704
+ for (var _33 = __values(qualifyingDetails || []), _34 = _33.next(); !_34.done; _34 = _33.next()) {
64705
+ var qualifyingDetail = _34.value;
64520
64706
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
64521
64707
  var link = mainStructure &&
64522
64708
  ((_17 = generateQualifyingLink({
@@ -64539,7 +64725,7 @@ function generateDrawDefinition(params) {
64539
64725
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
64540
64726
  finally {
64541
64727
  try {
64542
- if (_33 && !_33.done && (_c = _32.return)) _c.call(_32);
64728
+ if (_34 && !_34.done && (_c = _33.return)) _c.call(_33);
64543
64729
  }
64544
64730
  finally { if (e_3) throw e_3.error; }
64545
64731
  }
@@ -64580,7 +64766,7 @@ function generateDrawDefinition(params) {
64580
64766
  if (drawType === LUCKY_DRAW)
64581
64767
  seedsCount = 0;
64582
64768
  var structureResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { qualifyingOnly: !drawSize || qualifyingOnly, // ooo!! If there is no drawSize then MAIN is not being generated
64583
- appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, participants: participants, stage: MAIN, seedsCount: seedsCount, placeByes: placeByes, drawSize: drawSize, entries: entries }));
64769
+ appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, seedingProfile: seedingProfile, participants: participants, stage: MAIN, seedsCount: seedsCount, placeByes: placeByes, drawSize: drawSize, entries: entries }));
64584
64770
  if (structureResult.error && !structureResult.conflicts) {
64585
64771
  return structureResult;
64586
64772
  }
@@ -64637,8 +64823,8 @@ function generateDrawDefinition(params) {
64637
64823
  var roundTarget = 1;
64638
64824
  params.qualifyingProfiles.sort(roundTargetSort);
64639
64825
  try {
64640
- for (var _34 = __values(params.qualifyingProfiles), _35 = _34.next(); !_35.done; _35 = _34.next()) {
64641
- var roundTargetProfile = _35.value;
64826
+ for (var _35 = __values(params.qualifyingProfiles), _36 = _35.next(); !_36.done; _36 = _35.next()) {
64827
+ var roundTargetProfile = _36.value;
64642
64828
  if (!Array.isArray(roundTargetProfile.structureProfiles))
64643
64829
  return decorateResult({
64644
64830
  info: mustBeAnArray('structureProfiles'),
@@ -64651,8 +64837,8 @@ function generateDrawDefinition(params) {
64651
64837
  try {
64652
64838
  for (var sortedStructureProfiles_1 = (e_6 = void 0, __values(sortedStructureProfiles)), sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next(); !sortedStructureProfiles_1_1.done; sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next()) {
64653
64839
  var structureProfile = sortedStructureProfiles_1_1.value;
64654
- var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _36 = structureProfile.seedsCount, seedsCount_1 = _36 === void 0 ? 0 : _36, seedingProfile = structureProfile.seedingProfile, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
64655
- var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedingProfile: seedingProfile, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount_1, placeByes: placeByes_1, drawSize: drawSize_1, entries: entries }));
64840
+ var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _37 = structureProfile.seedsCount, seedsCount_1 = _37 === void 0 ? 0 : _37, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
64841
+ var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { seedingProfile: (_22 = structureProfile.seedingProfile) !== null && _22 !== void 0 ? _22 : seedingProfile, stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount_1, placeByes: placeByes_1, drawSize: drawSize_1, entries: entries }));
64656
64842
  if (qualifyingStageResult.error) {
64657
64843
  return qualifyingStageResult;
64658
64844
  }
@@ -64660,9 +64846,9 @@ function generateDrawDefinition(params) {
64660
64846
  preparedStructureIds.push(qualifyingStageResult.structureId);
64661
64847
  }
64662
64848
  sequence += 1;
64663
- if ((_22 = qualifyingStageResult.conflicts) === null || _22 === void 0 ? void 0 : _22.length)
64849
+ if ((_23 = qualifyingStageResult.conflicts) === null || _23 === void 0 ? void 0 : _23.length)
64664
64850
  qualifyingConflicts.push.apply(qualifyingConflicts, __spreadArray([], __read(qualifyingStageResult.conflicts), false));
64665
- if ((_23 = qualifyingStageResult.positioningReport) === null || _23 === void 0 ? void 0 : _23.length)
64851
+ if ((_24 = qualifyingStageResult.positioningReport) === null || _24 === void 0 ? void 0 : _24.length)
64666
64852
  positioningReports.push((_h = {},
64667
64853
  _h[QUALIFYING] = qualifyingStageResult.positioningReport,
64668
64854
  _h));
@@ -64681,7 +64867,7 @@ function generateDrawDefinition(params) {
64681
64867
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
64682
64868
  finally {
64683
64869
  try {
64684
- if (_35 && !_35.done && (_f = _34.return)) _f.call(_34);
64870
+ if (_36 && !_36.done && (_f = _35.return)) _f.call(_35);
64685
64871
  }
64686
64872
  finally { if (e_5) throw e_5.error; }
64687
64873
  }
@@ -64705,7 +64891,7 @@ function generateDrawDefinition(params) {
64705
64891
  drawDefinition.links.push(link);
64706
64892
  }
64707
64893
  drawDefinition.drawName =
64708
- (_24 = params.drawName) !== null && _24 !== void 0 ? _24 : (drawType && constantToString(drawType));
64894
+ (_25 = params.drawName) !== null && _25 !== void 0 ? _25 : (drawType && constantToString(drawType));
64709
64895
  if (typeof voluntaryConsolation === 'object') {
64710
64896
  addVoluntaryConsolationStructure(__assign(__assign({}, voluntaryConsolation), { tournamentRecord: tournamentRecord, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, matchUpType: matchUpType }));
64711
64897
  }