tods-competition-factory 1.8.19 → 1.8.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2905,7 +2905,7 @@ var matchUpFormatCode = {
2905
2905
  };
2906
2906
 
2907
2907
  function factoryVersion() {
2908
- return '1.8.19';
2908
+ return '1.8.20';
2909
2909
  }
2910
2910
 
2911
2911
  function getObjectTieFormat(obj) {
@@ -3974,8 +3974,8 @@ function validateCollectionDefinition(_a) {
3974
3974
  referenceGender !== gender) {
3975
3975
  errors.push("Invalid gender: ".concat(gender));
3976
3976
  return decorateResult({
3977
+ result: { error: INVALID_GENDER, errors: errors },
3977
3978
  context: { referenceGender: referenceGender, gender: gender },
3978
- result: { error: INVALID_GENDER },
3979
3979
  stack: stack,
3980
3980
  });
3981
3981
  }
@@ -31985,23 +31985,22 @@ function removeCollectionDefinition(params) {
31985
31985
 
31986
31986
  function addCollectionDefinition$1(_a) {
31987
31987
  var e_1, _b, e_2, _c, _d, e_3, _e;
31988
- var _f, _g, _h, _j, _k, _l, _m, _o;
31989
- var _p = _a.updateInProgressMatchUps, updateInProgressMatchUps = _p === void 0 ? true : _p, collectionDefinition = _a.collectionDefinition, referenceCategory = _a.referenceCategory, tournamentRecord = _a.tournamentRecord, enforceCategory = _a.enforceCategory, referenceGender = _a.referenceGender, drawDefinition = _a.drawDefinition, tieFormatName = _a.tieFormatName, enforceGender = _a.enforceGender, structureId = _a.structureId, matchUpId = _a.matchUpId, matchUp = _a.matchUp, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
31988
+ var _f, _g, _h, _j, _k, _l, _m, _o, _p;
31989
+ var _q = _a.updateInProgressMatchUps, updateInProgressMatchUps = _q === void 0 ? true : _q, collectionDefinition = _a.collectionDefinition, referenceCategory = _a.referenceCategory, tournamentRecord = _a.tournamentRecord, policyDefinitions = _a.policyDefinitions, enforceCategory = _a.enforceCategory, referenceGender = _a.referenceGender, drawDefinition = _a.drawDefinition, tieFormatName = _a.tieFormatName, enforceGender = _a.enforceGender, structureId = _a.structureId, matchUpId = _a.matchUpId, matchUp = _a.matchUp, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
31990
31990
  var stack = 'addCollectionDefinition';
31991
31991
  var appliedPolicies = (_f = getAppliedPolicies({
31992
31992
  tournamentRecord: tournamentRecord,
31993
31993
  drawDefinition: drawDefinition,
31994
31994
  event: event,
31995
31995
  }).appliedPolicies) !== null && _f !== void 0 ? _f : {};
31996
- var matchUpActionsPolicy = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS];
31996
+ var matchUpActionsPolicy = (_g = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _g !== void 0 ? _g : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS];
31997
31997
  enforceCategory =
31998
- enforceCategory !== null && enforceCategory !== void 0 ? enforceCategory : (_g = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _g === void 0 ? void 0 : _g.enforceCategory;
31999
- enforceGender =
32000
- enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_h = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _h === void 0 ? void 0 : _h.enforceGender;
31998
+ enforceCategory !== null && enforceCategory !== void 0 ? enforceCategory : (_h = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _h === void 0 ? void 0 : _h.enforceCategory;
31999
+ var genderEnforced = (enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_j = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _j === void 0 ? void 0 : _j.enforceGender) !==
32000
+ false;
32001
32001
  var checkCategory = !!((referenceCategory !== null && referenceCategory !== void 0 ? referenceCategory : event === null || event === void 0 ? void 0 : event.category) &&
32002
32002
  enforceCategory !== false);
32003
- var checkGender = !!((referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender) &&
32004
- enforceGender !== false);
32003
+ var checkGender = !!((referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender) && genderEnforced);
32005
32004
  var validationResult = validateCollectionDefinition({
32006
32005
  referenceCategory: referenceCategory !== null && referenceCategory !== void 0 ? referenceCategory : event === null || event === void 0 ? void 0 : event.category,
32007
32006
  collectionDefinition: collectionDefinition,
@@ -32026,7 +32025,7 @@ function addCollectionDefinition$1(_a) {
32026
32025
  return decorateResult({ result: { error: result.error }, stack: stack });
32027
32026
  var structure = result === null || result === void 0 ? void 0 : result.structure;
32028
32027
  matchUp = matchUp !== null && matchUp !== void 0 ? matchUp : result === null || result === void 0 ? void 0 : result.matchUp;
32029
- var existingTieFormat = (_j = matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieFormat) !== null && _j !== void 0 ? _j : result === null || result === void 0 ? void 0 : result.tieFormat;
32028
+ var existingTieFormat = (_k = matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieFormat) !== null && _k !== void 0 ? _k : result === null || result === void 0 ? void 0 : result.tieFormat;
32030
32029
  var tieFormat = copyTieFormat(existingTieFormat);
32031
32030
  result = validateTieFormat({ tieFormat: tieFormat });
32032
32031
  if (result === null || result === void 0 ? void 0 : result.error) {
@@ -32054,7 +32053,7 @@ function addCollectionDefinition$1(_a) {
32054
32053
  });
32055
32054
  // calculate new winCriteria for tieFormat
32056
32055
  // if existing winCriteria is aggregateValue, retain
32057
- var _q = calculateWinCriteria(tieFormat), aggregateValue = _q.aggregateValue, valueGoal = _q.valueGoal;
32056
+ var _r = calculateWinCriteria(tieFormat), aggregateValue = _r.aggregateValue, valueGoal = _r.valueGoal;
32058
32057
  tieFormat.winCriteria = definedAttributes({ aggregateValue: aggregateValue, valueGoal: valueGoal });
32059
32058
  // if valueGoal has changed, force renaming of the tieFormat
32060
32059
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
@@ -32080,13 +32079,13 @@ function addCollectionDefinition$1(_a) {
32080
32079
  event.tieFormat = prunedTieFormat;
32081
32080
  try {
32082
32081
  // all team matchUps in the event which do not have tieFormats and where draws/strucures do not have tieFormats should have matchUps added
32083
- for (var _r = __values((_k = event.drawDefinitions) !== null && _k !== void 0 ? _k : []), _s = _r.next(); !_s.done; _s = _r.next()) {
32084
- var drawDefinition_1 = _s.value;
32082
+ for (var _s = __values((_l = event.drawDefinitions) !== null && _l !== void 0 ? _l : []), _t = _s.next(); !_t.done; _t = _s.next()) {
32083
+ var drawDefinition_1 = _t.value;
32085
32084
  if (drawDefinition_1.tieFormat)
32086
32085
  continue;
32087
32086
  try {
32088
- for (var _t = (e_2 = void 0, __values((_l = drawDefinition_1.structures) !== null && _l !== void 0 ? _l : [])), _u = _t.next(); !_u.done; _u = _t.next()) {
32089
- var structure_1 = _u.value;
32087
+ for (var _u = (e_2 = void 0, __values((_m = drawDefinition_1.structures) !== null && _m !== void 0 ? _m : [])), _v = _u.next(); !_v.done; _v = _u.next()) {
32088
+ var structure_1 = _v.value;
32090
32089
  if (structure_1.tieFormat)
32091
32090
  continue;
32092
32091
  var result_1 = updateStructureMatchUps({
@@ -32103,7 +32102,7 @@ function addCollectionDefinition$1(_a) {
32103
32102
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
32104
32103
  finally {
32105
32104
  try {
32106
- if (_u && !_u.done && (_c = _t.return)) _c.call(_t);
32105
+ if (_v && !_v.done && (_c = _u.return)) _c.call(_u);
32107
32106
  }
32108
32107
  finally { if (e_2) throw e_2.error; }
32109
32108
  }
@@ -32112,7 +32111,7 @@ function addCollectionDefinition$1(_a) {
32112
32111
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
32113
32112
  finally {
32114
32113
  try {
32115
- if (_s && !_s.done && (_b = _r.return)) _b.call(_r);
32114
+ if (_t && !_t.done && (_b = _s.return)) _b.call(_s);
32116
32115
  }
32117
32116
  finally { if (e_1) throw e_1.error; }
32118
32117
  }
@@ -32175,8 +32174,8 @@ function addCollectionDefinition$1(_a) {
32175
32174
  // all team matchUps in the drawDefinition which do not have tieFormats and where strucures do not have tieFormats should have matchUps added
32176
32175
  drawDefinition.tieFormat = prunedTieFormat;
32177
32176
  try {
32178
- for (var _v = __values((_m = drawDefinition.structures) !== null && _m !== void 0 ? _m : []), _w = _v.next(); !_w.done; _w = _v.next()) {
32179
- var structure_2 = _w.value;
32177
+ for (var _w = __values((_o = drawDefinition.structures) !== null && _o !== void 0 ? _o : []), _x = _w.next(); !_x.done; _x = _w.next()) {
32178
+ var structure_2 = _x.value;
32180
32179
  var result_3 = updateStructureMatchUps({
32181
32180
  updateInProgressMatchUps: updateInProgressMatchUps,
32182
32181
  collectionDefinition: collectionDefinition,
@@ -32191,7 +32190,7 @@ function addCollectionDefinition$1(_a) {
32191
32190
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
32192
32191
  finally {
32193
32192
  try {
32194
- if (_w && !_w.done && (_e = _v.return)) _e.call(_v);
32193
+ if (_x && !_x.done && (_e = _w.return)) _e.call(_w);
32195
32194
  }
32196
32195
  finally { if (e_3) throw e_3.error; }
32197
32196
  }
@@ -32207,7 +32206,7 @@ function addCollectionDefinition$1(_a) {
32207
32206
  else {
32208
32207
  return { error: MISSING_DRAW_DEFINITION };
32209
32208
  }
32210
- if ((_o = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _o === void 0 ? void 0 : _o[TIE_FORMAT_MODIFICATIONS]) {
32209
+ if ((_p = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _p === void 0 ? void 0 : _p[TIE_FORMAT_MODIFICATIONS]) {
32211
32210
  var auditData = definedAttributes({
32212
32211
  drawId: drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawId,
32213
32212
  collectionDefinition: collectionDefinition,
@@ -39261,7 +39260,7 @@ var matchUpActionConstants = {
39261
39260
  function matchUpActions$2(_a) {
39262
39261
  var _b, _c, _d, _e, _f, _g, _h, _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;
39263
39262
  var _10 = _a.restrictAdHocRoundParticipants, restrictAdHocRoundParticipants = _10 === void 0 ? true : _10, // disallow the same participant being in the same round multiple times
39264
- specifiedPolicyDefinitions = _a.policyDefinitions, _11 = _a.tournamentParticipants, tournamentParticipants = _11 === void 0 ? [] : _11, inContextDrawMatchUps = _a.inContextDrawMatchUps, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, participantId = _a.participantId, matchUpsMap = _a.matchUpsMap, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, event = _a.event;
39263
+ specifiedPolicyDefinitions = _a.policyDefinitions, _11 = _a.tournamentParticipants, tournamentParticipants = _11 === void 0 ? [] : _11, inContextDrawMatchUps = _a.inContextDrawMatchUps, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, enforceGender = _a.enforceGender, participantId = _a.participantId, matchUpsMap = _a.matchUpsMap, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, event = _a.event;
39265
39264
  if (!drawDefinition)
39266
39265
  return { error: MISSING_DRAW_DEFINITION };
39267
39266
  if (!matchUpId)
@@ -39287,8 +39286,8 @@ function matchUpActions$2(_a) {
39287
39286
  event: event,
39288
39287
  }).appliedPolicies) !== null && _c !== void 0 ? _c : {};
39289
39288
  Object.assign(appliedPolicies, specifiedPolicyDefinitions !== null && specifiedPolicyDefinitions !== void 0 ? specifiedPolicyDefinitions : {});
39290
- var isAdHocMatchUp = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
39291
39289
  var matchUpActionsPolicy = (_d = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _d !== void 0 ? _d : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
39290
+ var isAdHocMatchUp = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
39292
39291
  var enabledStructures = getEnabledStructures({
39293
39292
  actionType: MATCHUP_ACTION,
39294
39293
  appliedPolicies: appliedPolicies,
@@ -39527,9 +39526,9 @@ function matchUpActions$2(_a) {
39527
39526
  ((_v = inContextMatchUp.sides) === null || _v === void 0 ? void 0 : _v.filter(function (side) { return side.particiapntId; }).length) === 1 &&
39528
39527
  ((_x = (_w = firstFoundSide === null || firstFoundSide === void 0 ? void 0 : firstFoundSide.participant) === null || _w === void 0 ? void 0 : _w.person) === null || _x === void 0 ? void 0 : _x.sex);
39529
39528
  var matchUpType = inContextMatchUp.matchUpType;
39530
- var gender_1 = ((_y = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _y === void 0 ? void 0 : _y.enforceGender)
39531
- ? inContextMatchUp.gender
39532
- : undefined;
39529
+ var genderEnforced = (enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_y = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _y === void 0 ? void 0 : _y.enforceGender) !==
39530
+ false;
39531
+ var gender_1 = genderEnforced ? inContextMatchUp.gender : undefined;
39533
39532
  var allParticipants = (_z = inContextMatchUp.sides) === null || _z === void 0 ? void 0 : _z.flatMap(function (side) { var _a; return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipants) || side.participant; }).filter(Boolean);
39534
39533
  var allParticipantIds_1 = allParticipants === null || allParticipants === void 0 ? void 0 : allParticipants.map(getParticipantId);
39535
39534
  var existingParticipants = (_0 = inContextMatchUp.sides) === null || _0 === void 0 ? void 0 : _0.filter(function (side) { return !sideNumber || side.sideNumber === sideNumber; }).flatMap(function (side) { var _a; return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipants) || side.participant; }).filter(Boolean);
@@ -39698,7 +39697,7 @@ function getEventAlternateParticipantIds(_a) {
39698
39697
  }
39699
39698
 
39700
39699
  function matchUpActions$1(_a) {
39701
- var policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, participantId = _a.participantId, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, drawId = _a.drawId, event = _a.event;
39700
+ var policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, enforceGender = _a.enforceGender, participantId = _a.participantId, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, drawId = _a.drawId, event = _a.event;
39702
39701
  if (!tournamentRecord)
39703
39702
  return { error: MISSING_TOURNAMENT_RECORD };
39704
39703
  if (!drawId) {
@@ -39727,6 +39726,7 @@ function matchUpActions$1(_a) {
39727
39726
  tournamentParticipants: tournamentRecord.participants,
39728
39727
  policyDefinitions: policyDefinitions,
39729
39728
  drawDefinition: drawDefinition,
39729
+ enforceGender: enforceGender,
39730
39730
  participantId: participantId,
39731
39731
  sideNumber: sideNumber,
39732
39732
  matchUpId: matchUpId,
@@ -39739,7 +39739,7 @@ function matchUpActions$1(_a) {
39739
39739
  }
39740
39740
 
39741
39741
  function matchUpActions(params) {
39742
- var _a = params !== null && params !== void 0 ? params : {}, tournamentRecords = _a.tournamentRecords, participantId = _a.participantId, tournamentId = _a.tournamentId, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, eventId = _a.eventId, drawId = _a.drawId;
39742
+ var _a = params !== null && params !== void 0 ? params : {}, tournamentRecords = _a.tournamentRecords, policyDefinitions = _a.policyDefinitions, enforceGender = _a.enforceGender, participantId = _a.participantId, tournamentId = _a.tournamentId, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, eventId = _a.eventId, drawId = _a.drawId;
39743
39743
  if (typeof tournamentRecords !== 'object' ||
39744
39744
  typeof tournamentId !== 'string' ||
39745
39745
  typeof matchUpId !== 'string' ||
@@ -39757,7 +39757,9 @@ function matchUpActions(params) {
39757
39757
  return result;
39758
39758
  return matchUpActions$1({
39759
39759
  drawDefinition: result.drawDefinition,
39760
+ policyDefinitions: policyDefinitions,
39760
39761
  tournamentRecord: tournamentRecord,
39762
+ enforceGender: enforceGender,
39761
39763
  participantId: participantId,
39762
39764
  sideNumber: sideNumber,
39763
39765
  matchUpId: matchUpId,
@@ -49067,20 +49069,11 @@ function removeEventEntries(_a) {
49067
49069
  }
49068
49070
 
49069
49071
  /**
49070
- *
49071
49072
  * Add entries into an event; optionally add to specified drawDefinition/flightProfile, if possible.
49072
- *
49073
- * @param {object} tournamentRecord - passed in automatically by tournamentEngine
49074
- * @param {string} eventId - tournamentEngine automatically retrieves event
49075
- * @param {string} drawId - optional - also add to drawDefinition.entries & flightProfile.drawEntries (if possible)
49076
- * @param {string[]} participantIds - ids of all participants to add to event
49077
- * @param {string} enryStatus - entryStatus enum
49078
- * @param {string} entryStage - entryStage enum
49079
- *
49080
49073
  */
49081
49074
  function addEventEntries(params) {
49082
- var _a;
49083
- var _b = params.entryStatus, entryStatus = _b === void 0 ? DIRECT_ACCEPTANCE : _b, _c = params.autoEntryPositions, autoEntryPositions = _c === void 0 ? true : _c, _d = params.participantIds, participantIds = _d === void 0 ? [] : _d, entryStageSequence = params.entryStageSequence, ignoreEventGender = params.ignoreEventGender, _e = params.entryStage, entryStage = _e === void 0 ? MAIN : _e, tournamentRecord = params.tournamentRecord, ignoreStageSpace = params.ignoreStageSpace, drawDefinition = params.drawDefinition, roundTarget = params.roundTarget, extensions = params.extensions, extension = params.extension, drawId = params.drawId, event = params.event;
49075
+ var _a, _b, _c, _d, _e;
49076
+ var _f = params.entryStatus, entryStatus = _f === void 0 ? DIRECT_ACCEPTANCE : _f, _g = params.autoEntryPositions, autoEntryPositions = _g === void 0 ? true : _g, _h = params.enforceGender, enforceGender = _h === void 0 ? true : _h, _j = params.participantIds, participantIds = _j === void 0 ? [] : _j, entryStageSequence = params.entryStageSequence, policyDefinitions = params.policyDefinitions, _k = params.entryStage, entryStage = _k === void 0 ? MAIN : _k, tournamentRecord = params.tournamentRecord, ignoreStageSpace = params.ignoreStageSpace, drawDefinition = params.drawDefinition, roundTarget = params.roundTarget, extensions = params.extensions, extension = params.extension, drawId = params.drawId, event = params.event;
49084
49077
  var stack = 'addEventEntries';
49085
49078
  if (!event)
49086
49079
  return { error: MISSING_EVENT };
@@ -49092,6 +49085,10 @@ function addEventEntries(params) {
49092
49085
  }
49093
49086
  if (!(event === null || event === void 0 ? void 0 : event.eventId))
49094
49087
  return { error: EVENT_NOT_FOUND };
49088
+ var appliedPolicies = (_a = getAppliedPolicies({ tournamentRecord: tournamentRecord, event: event }).appliedPolicies) !== null && _a !== void 0 ? _a : {};
49089
+ var matchUpActionsPolicy = (_c = (_b = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _b !== void 0 ? _b : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _c !== void 0 ? _c : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
49090
+ var genderEnforced = (enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_d = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _d === void 0 ? void 0 : _d.enforceGender) !==
49091
+ false;
49095
49092
  var addedParticipantIdEntries = [];
49096
49093
  var removedEntries = [];
49097
49094
  if ((extensions &&
@@ -49105,9 +49102,9 @@ function addEventEntries(params) {
49105
49102
  });
49106
49103
  }
49107
49104
  var checkTypedParticipants = !!tournamentRecord;
49108
- var misMatchedGender = [];
49105
+ var mismatchedGender = [];
49109
49106
  var info;
49110
- var typedParticipantIds = ((_a = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants) === null || _a === void 0 ? void 0 : _a.filter(function (participant) {
49107
+ var typedParticipantIds = ((_e = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants) === null || _e === void 0 ? void 0 : _e.filter(function (participant) {
49111
49108
  var _a, _b, _c;
49112
49109
  if (!participantIds.includes(participant.participantId))
49113
49110
  return false;
@@ -49117,7 +49114,7 @@ function addEventEntries(params) {
49117
49114
  var validDoubles = event.eventType === DOUBLES$1 && participant.participantType === PAIR;
49118
49115
  if (validSingles &&
49119
49116
  (!event.gender ||
49120
- ignoreEventGender ||
49117
+ !genderEnforced ||
49121
49118
  [MIXED, ANY].includes(event.gender) ||
49122
49119
  event.gender === ((_a = participant.person) === null || _a === void 0 ? void 0 : _a.sex))) {
49123
49120
  return true;
@@ -49132,10 +49129,10 @@ function addEventEntries(params) {
49132
49129
  }
49133
49130
  if (validSingles &&
49134
49131
  event.gender &&
49135
- !ignoreEventGender &&
49132
+ genderEnforced &&
49136
49133
  ![MIXED, ANY].includes(event.gender) &&
49137
49134
  event.gender !== ((_b = participant.person) === null || _b === void 0 ? void 0 : _b.sex)) {
49138
- misMatchedGender.push({
49135
+ mismatchedGender.push({
49139
49136
  participantId: participant.participantId,
49140
49137
  sex: (_c = participant.person) === null || _c === void 0 ? void 0 : _c.sex,
49141
49138
  });
@@ -49224,7 +49221,7 @@ function addEventEntries(params) {
49224
49221
  var invalidParticipantIds = validParticipantIds.length !== participantIds.length;
49225
49222
  if (invalidParticipantIds)
49226
49223
  return decorateResult({
49227
- context: { misMatchedGender: misMatchedGender, gender: event.gender },
49224
+ context: { mismatchedGender: mismatchedGender, gender: event.gender },
49228
49225
  result: { error: INVALID_PARTICIPANT_IDS },
49229
49226
  stack: stack,
49230
49227
  });
@@ -57251,7 +57248,7 @@ function getTieMatchUpContext(_a) {
57251
57248
 
57252
57249
  function assignTieMatchUpParticipantId(params) {
57253
57250
  var e_1, _a;
57254
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
57251
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
57255
57252
  var matchUpContext = getTieMatchUpContext(params);
57256
57253
  if (matchUpContext.error)
57257
57254
  return matchUpContext;
@@ -57275,10 +57272,9 @@ function assignTieMatchUpParticipantId(params) {
57275
57272
  return decorateResult({ result: __assign({}, SUCCESS), stack: stack });
57276
57273
  }
57277
57274
  teamParticipantId =
57278
- teamParticipantId ||
57279
- (params.sideNumber
57280
- ? (_d = (_c = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _c === void 0 ? void 0 : _c.find(function (side) { return side.sideNumber === params.sideNumber; })) === null || _d === void 0 ? void 0 : _d.participantId
57281
- : undefined);
57275
+ teamParticipantId !== null && teamParticipantId !== void 0 ? teamParticipantId : (params.sideNumber
57276
+ ? (_d = (_c = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _c === void 0 ? void 0 : _c.find(function (side) { return side.sideNumber === params.sideNumber; })) === null || _d === void 0 ? void 0 : _d.participantId
57277
+ : undefined);
57282
57278
  var participantToAssign = (_f = (_e = getParticipants$1({
57283
57279
  participantFilters: { participantIds: [participantId] },
57284
57280
  tournamentRecord: tournamentRecord,
@@ -57291,12 +57287,11 @@ function assignTieMatchUpParticipantId(params) {
57291
57287
  drawDefinition: drawDefinition,
57292
57288
  event: event,
57293
57289
  }).appliedPolicies;
57294
- var matchUpActionsPolicy = ((_g = params.policyDefinitions) === null || _g === void 0 ? void 0 : _g[POLICY_TYPE_MATCHUP_ACTIONS]) ||
57295
- (appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) ||
57296
- POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
57297
- if (((_h = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _h === void 0 ? void 0 : _h.enforceGender) &&
57290
+ var matchUpActionsPolicy = (_j = (_h = (_g = params.policyDefinitions) === null || _g === void 0 ? void 0 : _g[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _h !== void 0 ? _h : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _j !== void 0 ? _j : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
57291
+ var genderEnforced = ((_k = params.enforceGender) !== null && _k !== void 0 ? _k : (_l = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _l === void 0 ? void 0 : _l.enforceGender) !== false;
57292
+ if (genderEnforced &&
57298
57293
  [MALE, FEMALE].includes(inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) &&
57299
- (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) !== ((_j = participantToAssign.person) === null || _j === void 0 ? void 0 : _j.sex)) {
57294
+ (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) !== ((_m = participantToAssign.person) === null || _m === void 0 ? void 0 : _m.sex)) {
57300
57295
  return { error: INVALID_PARTICIPANT, info: 'Gender mismatch' };
57301
57296
  }
57302
57297
  var individualParticipantIds = participantToAssign.individualParticipantIds, participantType = participantToAssign.participantType;
@@ -57323,12 +57318,12 @@ function assignTieMatchUpParticipantId(params) {
57323
57318
  return { error: PARTICIPANT_NOT_FOUND };
57324
57319
  var teamAssignment = relevantAssignments === null || relevantAssignments === void 0 ? void 0 : relevantAssignments.find(function (assignment) { return assignment.participantId === (participantTeam === null || participantTeam === void 0 ? void 0 : participantTeam.participantId); });
57325
57320
  var teamDrawPosition = teamAssignment === null || teamAssignment === void 0 ? void 0 : teamAssignment.drawPosition;
57326
- var teamSide = (_k = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _k === void 0 ? void 0 : _k.find(function (side) { return side.drawPosition === teamDrawPosition; });
57327
- var sideNumber = params.sideNumber || (teamSide === null || teamSide === void 0 ? void 0 : teamSide.sideNumber);
57321
+ var teamSide = (_o = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _o === void 0 ? void 0 : _o.find(function (side) { return side.drawPosition === teamDrawPosition; });
57322
+ var sideNumber = (_p = params.sideNumber) !== null && _p !== void 0 ? _p : teamSide === null || teamSide === void 0 ? void 0 : teamSide.sideNumber;
57328
57323
  if (!tieFormat) {
57329
57324
  return { error: MISSING_TIE_FORMAT };
57330
57325
  }
57331
- var collectionDefinition = (_l = tieFormat.collectionDefinitions) === null || _l === void 0 ? void 0 : _l.find(function (collectionDefinition) { return collectionDefinition.collectionId === collectionId; });
57326
+ var collectionDefinition = (_q = tieFormat.collectionDefinitions) === null || _q === void 0 ? void 0 : _q.find(function (collectionDefinition) { return collectionDefinition.collectionId === collectionId; });
57332
57327
  if (!collectionDefinition)
57333
57328
  return { error: MISSING_COLLECTION_DEFINITION };
57334
57329
  ensureSideLineUps({
@@ -57338,12 +57333,12 @@ function assignTieMatchUpParticipantId(params) {
57338
57333
  drawDefinition: drawDefinition,
57339
57334
  dualMatchUp: dualMatchUp,
57340
57335
  });
57341
- var dualMatchUpSide = (_m = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (side) { return side.sideNumber === sideNumber; });
57342
- var tieMatchUpSide = (_o = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _o === void 0 ? void 0 : _o.find(function (side) { return side.sideNumber === sideNumber; });
57343
- var lineUp = (_p = dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.lineUp) !== null && _p !== void 0 ? _p : (_q = getTeamLineUp({
57336
+ var dualMatchUpSide = (_r = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _r === void 0 ? void 0 : _r.find(function (side) { return side.sideNumber === sideNumber; });
57337
+ var tieMatchUpSide = (_s = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _s === void 0 ? void 0 : _s.find(function (side) { return side.sideNumber === sideNumber; });
57338
+ var lineUp = (_t = dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.lineUp) !== null && _t !== void 0 ? _t : (_u = getTeamLineUp({
57344
57339
  participantId: teamParticipantId,
57345
57340
  drawDefinition: drawDefinition,
57346
- })) === null || _q === void 0 ? void 0 : _q.lineUp;
57341
+ })) === null || _u === void 0 ? void 0 : _u.lineUp;
57347
57342
  var targetAssignments = lineUp === null || lineUp === void 0 ? void 0 : lineUp.filter(function (participantAssignment) {
57348
57343
  var _a;
57349
57344
  return (_a = participantAssignment.collectionAssignments) === null || _a === void 0 ? void 0 : _a.find(function (assignment) {
@@ -60122,7 +60117,7 @@ function removeMatchUpSideParticipant(_a) {
60122
60117
 
60123
60118
  function replaceTieMatchUpParticipantId(params) {
60124
60119
  var e_1, _a;
60125
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
60120
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
60126
60121
  var matchUpContext = getTieMatchUpContext(params);
60127
60122
  if (matchUpContext.error)
60128
60123
  return matchUpContext;
@@ -60160,18 +60155,18 @@ function replaceTieMatchUpParticipantId(params) {
60160
60155
  drawDefinition: drawDefinition,
60161
60156
  event: event,
60162
60157
  }).appliedPolicies;
60163
- var matchUpActionsPolicy = (appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) ||
60164
- POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
60158
+ var matchUpActionsPolicy = (_g = (_f = (_e = params.policyDefinitions) === null || _e === void 0 ? void 0 : _e[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _f !== void 0 ? _f : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _g !== void 0 ? _g : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
60165
60159
  var newParticipant = targetParticipants.find(function (_a) {
60166
60160
  var participantId = _a.participantId;
60167
60161
  return participantId === newParticipantId;
60168
60162
  });
60169
- if (((_e = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _e === void 0 ? void 0 : _e.enforceGender) &&
60163
+ var genderEnforced = ((_h = params.enforceGender) !== null && _h !== void 0 ? _h : (_j = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _j === void 0 ? void 0 : _j.enforceGender) !== false;
60164
+ if (genderEnforced &&
60170
60165
  [MALE, FEMALE].includes(inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) &&
60171
- (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) !== ((_f = newParticipant === null || newParticipant === void 0 ? void 0 : newParticipant.person) === null || _f === void 0 ? void 0 : _f.sex)) {
60166
+ (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) !== ((_k = newParticipant === null || newParticipant === void 0 ? void 0 : newParticipant.person) === null || _k === void 0 ? void 0 : _k.sex)) {
60172
60167
  return { error: INVALID_PARTICIPANT, info: 'Gender mismatch' };
60173
60168
  }
60174
- var substitutionProcessCodes = (_g = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _g === void 0 ? void 0 : _g.substitution;
60169
+ var substitutionProcessCodes = (_l = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _l === void 0 ? void 0 : _l.substitution;
60175
60170
  ensureSideLineUps({
60176
60171
  tournamentId: tournamentRecord.tournamentId,
60177
60172
  eventId: event.eventId,
@@ -60179,7 +60174,7 @@ function replaceTieMatchUpParticipantId(params) {
60179
60174
  drawDefinition: drawDefinition,
60180
60175
  dualMatchUp: dualMatchUp,
60181
60176
  });
60182
- var dualMatchUpSide = (_h = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _h === void 0 ? void 0 : _h.find(function (_a) {
60177
+ var dualMatchUpSide = (_m = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (_a) {
60183
60178
  var sideNumber = _a.sideNumber;
60184
60179
  return sideNumber === side.sideNumber;
60185
60180
  });
@@ -60193,7 +60188,7 @@ function replaceTieMatchUpParticipantId(params) {
60193
60188
  stack: stack,
60194
60189
  });
60195
60190
  }
60196
- var allTieIndividualParticipantIds = (_j = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _j === void 0 ? void 0 : _j.flatMap(function (side) {
60191
+ var allTieIndividualParticipantIds = (_o = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _o === void 0 ? void 0 : _o.flatMap(function (side) {
60197
60192
  var _a, _b;
60198
60193
  return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds) ||
60199
60194
  ((_b = side.participant) === null || _b === void 0 ? void 0 : _b.participantId) ||
@@ -60202,10 +60197,10 @@ function replaceTieMatchUpParticipantId(params) {
60202
60197
  if (allTieIndividualParticipantIds === null || allTieIndividualParticipantIds === void 0 ? void 0 : allTieIndividualParticipantIds.includes(newParticipantId)) {
60203
60198
  return decorateResult({ result: { error: EXISTING_PARTICIPANT }, stack: stack });
60204
60199
  }
60205
- var teamParticipantId = (_l = (_k = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _k === void 0 ? void 0 : _k.find(function (_a) {
60200
+ var teamParticipantId = (_q = (_p = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _p === void 0 ? void 0 : _p.find(function (_a) {
60206
60201
  var sideNumber = _a.sideNumber;
60207
60202
  return sideNumber === side.sideNumber;
60208
- })) === null || _l === void 0 ? void 0 : _l.participantId;
60203
+ })) === null || _q === void 0 ? void 0 : _q.participantId;
60209
60204
  var teamLineUp = dualMatchUpSide.lineUp;
60210
60205
  var newParticipantIdInLineUp = teamLineUp === null || teamLineUp === void 0 ? void 0 : teamLineUp.find(function (_a) {
60211
60206
  var participantId = _a.participantId;
@@ -60216,7 +60211,7 @@ function replaceTieMatchUpParticipantId(params) {
60216
60211
  ? teamCompetitor.substitutionOrder
60217
60212
  : order;
60218
60213
  }, 0);
60219
- var modifiedLineUp = (teamLineUp === null || teamLineUp === void 0 ? void 0 : teamLineUp.map(function (teamCompetitor) {
60214
+ var modifiedLineUp = (_r = teamLineUp === null || teamLineUp === void 0 ? void 0 : teamLineUp.map(function (teamCompetitor) {
60220
60215
  var _a;
60221
60216
  var modifiedCompetitor = makeDeepCopy(teamCompetitor, false, true);
60222
60217
  // if the current competitor is not either id, return as is
@@ -60251,16 +60246,16 @@ function replaceTieMatchUpParticipantId(params) {
60251
60246
  var assignment = { collectionId: collectionId, collectionPosition: collectionPosition };
60252
60247
  if (substitution) {
60253
60248
  assignment.previousParticipantId = existingParticipantId;
60254
- assignment.substitutionOrder = (substitutionOrder || 0) + 1;
60249
+ assignment.substitutionOrder = (substitutionOrder !== null && substitutionOrder !== void 0 ? substitutionOrder : 0) + 1;
60255
60250
  }
60256
60251
  modifiedCompetitor.collectionAssignments.push(assignment);
60257
60252
  }
60258
60253
  return modifiedCompetitor;
60259
- })) || [];
60254
+ })) !== null && _r !== void 0 ? _r : [];
60260
60255
  if (!newParticipantIdInLineUp) {
60261
60256
  var collectionAssignment = { collectionId: collectionId, collectionPosition: collectionPosition };
60262
60257
  if (substitution) {
60263
- collectionAssignment.substitutionOrder = (substitutionOrder || 0) + 1;
60258
+ collectionAssignment.substitutionOrder = (substitutionOrder !== null && substitutionOrder !== void 0 ? substitutionOrder : 0) + 1;
60264
60259
  collectionAssignment.previousParticipantId = existingParticipantId;
60265
60260
  }
60266
60261
  var assignment = {
@@ -60316,14 +60311,14 @@ function replaceTieMatchUpParticipantId(params) {
60316
60311
  });
60317
60312
  if (result_1.error)
60318
60313
  return decorateResult({ result: result_1, stack: stack });
60319
- participantAdded = (_m = result_1.participant) === null || _m === void 0 ? void 0 : _m.participantId;
60314
+ participantAdded = (_s = result_1.participant) === null || _s === void 0 ? void 0 : _s.participantId;
60320
60315
  }
60321
60316
  // now attempt to cleanup/delete previous pairParticipant
60322
60317
  result = getPairedParticipant({
60323
60318
  participantIds: existingIndividualParticipantIds,
60324
60319
  tournamentRecord: tournamentRecord_1,
60325
60320
  });
60326
- var existingPairParticipantId = (_o = result.participant) === null || _o === void 0 ? void 0 : _o.participantId;
60321
+ var existingPairParticipantId = (_t = result.participant) === null || _t === void 0 ? void 0 : _t.participantId;
60327
60322
  if (existingPairParticipantId) {
60328
60323
  var result_2 = deleteParticipants({
60329
60324
  participantIds: [existingPairParticipantId],
@@ -60333,9 +60328,9 @@ function replaceTieMatchUpParticipantId(params) {
60333
60328
  participantRemoved = existingPairParticipantId;
60334
60329
  }
60335
60330
  }
60336
- if (substitution || ((_p = side.substitutions) === null || _p === void 0 ? void 0 : _p.length) === 1) {
60331
+ if (substitution || ((_u = side.substitutions) === null || _u === void 0 ? void 0 : _u.length) === 1) {
60337
60332
  if (substitution) {
60338
- var processCodes = (tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) || [];
60333
+ var processCodes = (_v = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) !== null && _v !== void 0 ? _v : [];
60339
60334
  if (substitutionProcessCodes)
60340
60335
  processCodes.push.apply(processCodes, __spreadArray([], __read(substitutionProcessCodes), false));
60341
60336
  if (tieMatchUp)
@@ -60344,18 +60339,18 @@ function replaceTieMatchUpParticipantId(params) {
60344
60339
  else {
60345
60340
  try {
60346
60341
  // if there was only one substitution, remove processCode(s)
60347
- for (var _s = __values(substitutionProcessCodes || []), _t = _s.next(); !_t.done; _t = _s.next()) {
60348
- var substitutionProcessCode = _t.value;
60349
- var codeIndex = (_q = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _q === void 0 ? void 0 : _q.lastIndexOf(substitutionProcessCode);
60342
+ for (var _y = __values(substitutionProcessCodes || []), _z = _y.next(); !_z.done; _z = _y.next()) {
60343
+ var substitutionProcessCode = _z.value;
60344
+ var codeIndex = (_w = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _w === void 0 ? void 0 : _w.lastIndexOf(substitutionProcessCode);
60350
60345
  // remove only one instance of substitutionProcessCode
60351
60346
  codeIndex !== undefined &&
60352
- ((_r = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _r === void 0 ? void 0 : _r.splice(codeIndex, 1));
60347
+ ((_x = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _x === void 0 ? void 0 : _x.splice(codeIndex, 1));
60353
60348
  }
60354
60349
  }
60355
60350
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
60356
60351
  finally {
60357
60352
  try {
60358
- if (_t && !_t.done && (_a = _s.return)) _a.call(_s);
60353
+ if (_z && !_z.done && (_a = _y.return)) _a.call(_y);
60359
60354
  }
60360
60355
  finally { if (e_1) throw e_1.error; }
60361
60356
  }
@@ -60382,7 +60377,7 @@ function replaceTieMatchUpParticipantId(params) {
60382
60377
 
60383
60378
  function removeTieMatchUpParticipantId(params) {
60384
60379
  var e_1, _a;
60385
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
60380
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
60386
60381
  var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, participantId = params.participantId, event = params.event;
60387
60382
  var stack = 'removeTieMatchUpParticiapantId';
60388
60383
  if (!participantId)
@@ -60395,33 +60390,32 @@ function removeTieMatchUpParticipantId(params) {
60395
60390
  drawDefinition: drawDefinition,
60396
60391
  event: event,
60397
60392
  }).appliedPolicies;
60398
- var matchUpActionsPolicy = (appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) ||
60399
- POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
60400
- var substitutionProcessCodes = (_b = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _b === void 0 ? void 0 : _b.substitution;
60393
+ var matchUpActionsPolicy = (_d = (_c = (_b = params.policyDefinitions) === null || _b === void 0 ? void 0 : _b[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _c !== void 0 ? _c : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _d !== void 0 ? _d : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
60394
+ var substitutionProcessCodes = (_e = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _e === void 0 ? void 0 : _e.substitution;
60401
60395
  var inContextDualMatchUp = matchUpContext.inContextDualMatchUp, inContextTieMatchUp = matchUpContext.inContextTieMatchUp, relevantAssignments = matchUpContext.relevantAssignments, collectionPosition = matchUpContext.collectionPosition, teamParticipants = matchUpContext.teamParticipants, collectionId = matchUpContext.collectionId, matchUpType = matchUpContext.matchUpType, dualMatchUp = matchUpContext.dualMatchUp, tieMatchUp = matchUpContext.tieMatchUp, tieFormat = matchUpContext.tieFormat;
60402
60396
  if (!dualMatchUp)
60403
60397
  return decorateResult({ result: { error: MISSING_MATCHUP }, stack: stack });
60404
- var side = (_c = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _c === void 0 ? void 0 : _c.find(function (side) {
60398
+ var side = (_f = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _f === void 0 ? void 0 : _f.find(function (side) {
60405
60399
  var _a, _b, _c;
60406
60400
  return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.participantId) === participantId ||
60407
60401
  ((_c = (_b = side.participant) === null || _b === void 0 ? void 0 : _b.individualParticipantIds) === null || _c === void 0 ? void 0 : _c.includes(participantId));
60408
60402
  });
60409
60403
  if (!side)
60410
60404
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack: stack });
60411
- if (!((_d = side.substitutions) === null || _d === void 0 ? void 0 : _d.length) &&
60405
+ if (!((_g = side.substitutions) === null || _g === void 0 ? void 0 : _g.length) &&
60412
60406
  (scoreHasValue({ score: inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.score }) ||
60413
60407
  (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.winningSide)))
60414
60408
  return decorateResult({ result: { error: EXISTING_OUTCOME }, stack: stack });
60415
- var teamParticipantId = (_f = (_e = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _e === void 0 ? void 0 : _e.find(function (_a) {
60409
+ var teamParticipantId = (_j = (_h = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _h === void 0 ? void 0 : _h.find(function (_a) {
60416
60410
  var sideNumber = _a.sideNumber;
60417
60411
  return sideNumber === side.sideNumber;
60418
- })) === null || _f === void 0 ? void 0 : _f.participantId;
60412
+ })) === null || _j === void 0 ? void 0 : _j.participantId;
60419
60413
  if (!teamParticipantId)
60420
60414
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack: stack });
60421
- var participantToRemove = (_h = (_g = getParticipants$1({
60415
+ var participantToRemove = (_l = (_k = getParticipants$1({
60422
60416
  participantFilters: { participantIds: [participantId] },
60423
60417
  tournamentRecord: tournamentRecord,
60424
- })) === null || _g === void 0 ? void 0 : _g.participants) === null || _h === void 0 ? void 0 : _h[0];
60418
+ })) === null || _k === void 0 ? void 0 : _k.participants) === null || _l === void 0 ? void 0 : _l[0];
60425
60419
  if (!participantToRemove) {
60426
60420
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack: stack });
60427
60421
  }
@@ -60438,12 +60432,12 @@ function removeTieMatchUpParticipantId(params) {
60438
60432
  drawDefinition: drawDefinition,
60439
60433
  dualMatchUp: dualMatchUp,
60440
60434
  });
60441
- var dualMatchUpSide = (_j = dualMatchUp.sides) === null || _j === void 0 ? void 0 : _j.find(function (_a) {
60435
+ var dualMatchUpSide = (_m = dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (_a) {
60442
60436
  var sideNumber = _a.sideNumber;
60443
60437
  return sideNumber === side.sideNumber;
60444
60438
  });
60445
60439
  if (!dualMatchUpSide &&
60446
- (((_k = dualMatchUp.sides) === null || _k === void 0 ? void 0 : _k.filter(function (_a) {
60440
+ (((_o = dualMatchUp.sides) === null || _o === void 0 ? void 0 : _o.filter(function (_a) {
60447
60441
  var lineUp = _a.lineUp;
60448
60442
  return !lineUp;
60449
60443
  }).length) || 0) < 2) {
@@ -60455,7 +60449,7 @@ function removeTieMatchUpParticipantId(params) {
60455
60449
  teamParticipantId: teamParticipantId,
60456
60450
  });
60457
60451
  });
60458
- dualMatchUpSide = (_l = dualMatchUp.sides) === null || _l === void 0 ? void 0 : _l.find(function (side) {
60452
+ dualMatchUpSide = (_p = dualMatchUp.sides) === null || _p === void 0 ? void 0 : _p.find(function (side) {
60459
60453
  var _a;
60460
60454
  return ((_a = drawPositionMap_1 === null || drawPositionMap_1 === void 0 ? void 0 : drawPositionMap_1.find(function (_a) {
60461
60455
  var drawPosition = _a.drawPosition;
@@ -60468,14 +60462,14 @@ function removeTieMatchUpParticipantId(params) {
60468
60462
  result: { error: PARTICIPANT_NOT_FOUND, context: { participantId: participantId } },
60469
60463
  });
60470
60464
  }
60471
- var _x = removeCollectionAssignments({
60465
+ var _0 = removeCollectionAssignments({
60472
60466
  collectionPosition: collectionPosition,
60473
60467
  teamParticipantId: teamParticipantId,
60474
60468
  dualMatchUpSide: dualMatchUpSide,
60475
60469
  participantIds: participantIds,
60476
60470
  drawDefinition: drawDefinition,
60477
60471
  collectionId: collectionId,
60478
- }), modifiedLineUp = _x.modifiedLineUp, previousParticipantIds = _x.previousParticipantIds;
60472
+ }), modifiedLineUp = _0.modifiedLineUp, previousParticipantIds = _0.previousParticipantIds;
60479
60473
  dualMatchUpSide.lineUp = modifiedLineUp;
60480
60474
  teamParticipantId &&
60481
60475
  tieFormat &&
@@ -60489,16 +60483,16 @@ function removeTieMatchUpParticipantId(params) {
60489
60483
  // ...then the PAIR participant may need to be modified
60490
60484
  if (matchUpType === DOUBLES$1 &&
60491
60485
  participantToRemove.participantType === INDIVIDUAL) {
60492
- var tieMatchUpSide = (_m = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (side) { return side.sideNumber === (dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.sideNumber); });
60486
+ var tieMatchUpSide = (_q = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _q === void 0 ? void 0 : _q.find(function (side) { return side.sideNumber === (dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.sideNumber); });
60493
60487
  var pairParticipantId = (tieMatchUpSide || {}).participantId;
60494
60488
  var pairParticipant = pairParticipantId &&
60495
- ((_p = (_o = getParticipants$1({
60489
+ ((_s = (_r = getParticipants$1({
60496
60490
  participantFilters: { participantIds: [pairParticipantId] },
60497
60491
  tournamentRecord: tournamentRecord,
60498
60492
  withDraws: true,
60499
- })) === null || _o === void 0 ? void 0 : _o.participants) === null || _p === void 0 ? void 0 : _p[0]);
60493
+ })) === null || _r === void 0 ? void 0 : _r.participants) === null || _s === void 0 ? void 0 : _s[0]);
60500
60494
  if (pairParticipant) {
60501
- var individualParticipantIds = (_r = (_q = pairParticipant === null || pairParticipant === void 0 ? void 0 : pairParticipant.individualParticipantIds) === null || _q === void 0 ? void 0 : _q.filter(function (currentId) { return currentId !== participantId; })) !== null && _r !== void 0 ? _r : [];
60495
+ var individualParticipantIds = (_u = (_t = pairParticipant === null || pairParticipant === void 0 ? void 0 : pairParticipant.individualParticipantIds) === null || _t === void 0 ? void 0 : _t.filter(function (currentId) { return currentId !== participantId; })) !== null && _u !== void 0 ? _u : [];
60502
60496
  if (previousParticipantIds)
60503
60497
  individualParticipantIds.push.apply(individualParticipantIds, __spreadArray([], __read(previousParticipantIds), false));
60504
60498
  if (individualParticipantIds.length > 2) {
@@ -60508,7 +60502,7 @@ function removeTieMatchUpParticipantId(params) {
60508
60502
  });
60509
60503
  }
60510
60504
  // don't modify pair participant that is part of other events/draws
60511
- if (!((_s = pairParticipant.draws) === null || _s === void 0 ? void 0 : _s.length)) {
60505
+ if (!((_v = pairParticipant.draws) === null || _v === void 0 ? void 0 : _v.length)) {
60512
60506
  if (individualParticipantIds.length) {
60513
60507
  pairParticipant.individualParticipantIds = individualParticipantIds;
60514
60508
  var result = modifyParticipant({
@@ -60559,13 +60553,13 @@ function removeTieMatchUpParticipantId(params) {
60559
60553
  }
60560
60554
  }
60561
60555
  // if there was only one subsitution on target side and there are no substiutions on other side
60562
- if (((_t = side.substitutions) === null || _t === void 0 ? void 0 : _t.length) === 1) {
60563
- var otherSide = (_u = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _u === void 0 ? void 0 : _u.find(function (s) { return s.sideNumber !== side.sideNumber; });
60564
- if (!((_v = otherSide === null || otherSide === void 0 ? void 0 : otherSide.substitutions) === null || _v === void 0 ? void 0 : _v.length) && ((_w = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _w === void 0 ? void 0 : _w.length)) {
60556
+ if (((_w = side.substitutions) === null || _w === void 0 ? void 0 : _w.length) === 1) {
60557
+ var otherSide = (_x = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _x === void 0 ? void 0 : _x.find(function (s) { return s.sideNumber !== side.sideNumber; });
60558
+ if (!((_y = otherSide === null || otherSide === void 0 ? void 0 : otherSide.substitutions) === null || _y === void 0 ? void 0 : _y.length) && ((_z = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _z === void 0 ? void 0 : _z.length)) {
60565
60559
  try {
60566
60560
  // remove processCode(s)
60567
- for (var _y = __values(substitutionProcessCodes || []), _z = _y.next(); !_z.done; _z = _y.next()) {
60568
- var substitutionProcessCode = _z.value;
60561
+ for (var _1 = __values(substitutionProcessCodes || []), _2 = _1.next(); !_2.done; _2 = _1.next()) {
60562
+ var substitutionProcessCode = _2.value;
60569
60563
  var codeIndex = tieMatchUp.processCodes.lastIndexOf(substitutionProcessCode);
60570
60564
  // remove only one instance of substitutionProcessCode
60571
60565
  tieMatchUp.processCodes.splice(codeIndex, 1);
@@ -60574,7 +60568,7 @@ function removeTieMatchUpParticipantId(params) {
60574
60568
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
60575
60569
  finally {
60576
60570
  try {
60577
- if (_z && !_z.done && (_a = _y.return)) _a.call(_y);
60571
+ if (_2 && !_2.done && (_a = _1.return)) _a.call(_1);
60578
60572
  }
60579
60573
  finally { if (e_1) throw e_1.error; }
60580
60574
  }
@@ -61028,19 +61022,27 @@ function addEventEntryPairs(_a) {
61028
61022
  }
61029
61023
 
61030
61024
  function checkValidEntries(_a) {
61031
- var _b = _a.enforceGender, enforceGender = _b === void 0 ? true : _b, consideredEntries = _a.consideredEntries, tournamentRecord = _a.tournamentRecord, participants = _a.participants, event = _a.event;
61032
- participants = participants || (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants);
61025
+ var _b;
61026
+ var _c, _d, _e, _f;
61027
+ var consideredEntries = _a.consideredEntries, policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, appliedPolicies = _a.appliedPolicies, participantMap = _a.participantMap, enforceGender = _a.enforceGender, participants = _a.participants, event = _a.event;
61028
+ if ((!participants || !participantMap) && tournamentRecord) {
61029
+ (_b = getParticipants$1({
61030
+ tournamentRecord: tournamentRecord,
61031
+ }), participants = _b.participants, participantMap = _b.participantMap);
61032
+ }
61033
61033
  if (!participants)
61034
61034
  return { error: MISSING_PARTICIPANTS };
61035
61035
  if (!Array.isArray(participants))
61036
61036
  return { error: INVALID_VALUES };
61037
61037
  if (!event)
61038
61038
  return { error: MISSING_EVENT };
61039
+ var matchUpActionsPolicy = (_d = (_c = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _c !== void 0 ? _c : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _d !== void 0 ? _d : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
61040
+ var genderEnforced = (enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_e = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _e === void 0 ? void 0 : _e.enforceGender) !==
61041
+ false;
61039
61042
  var eventType = event.eventType, eventGender = event.gender;
61040
- var participantType = (eventType === TEAM_EVENT && TEAM) ||
61041
- (eventType === DOUBLES_EVENT && PAIR) ||
61042
- INDIVIDUAL;
61043
- var entryStatusMap = Object.assign.apply(Object, __spreadArray([{}], __read((consideredEntries || event.entries || []).map(function (entry) {
61043
+ var isDoubles = eventType === DOUBLES_EVENT;
61044
+ var participantType = (eventType === TEAM_EVENT && TEAM) || (isDoubles && PAIR) || INDIVIDUAL;
61045
+ var entryStatusMap = Object.assign.apply(Object, __spreadArray([{}], __read(((_f = consideredEntries !== null && consideredEntries !== void 0 ? consideredEntries : event.entries) !== null && _f !== void 0 ? _f : []).map(function (entry) {
61044
61046
  var _a;
61045
61047
  return (_a = {},
61046
61048
  _a[entry.participantId] = entry.entryStatus,
@@ -61051,27 +61053,39 @@ function checkValidEntries(_a) {
61051
61053
  return enteredParticipantIds.includes(participant.participantId);
61052
61054
  });
61053
61055
  var invalidEntries = enteredParticipants.filter(function (participant) {
61054
- var _a;
61056
+ var _a, _b, _c, _d;
61055
61057
  var entryStatus = entryStatusMap[participant.participantId];
61056
61058
  var ungroupedParticipant = eventType &&
61057
61059
  [TypeEnum.Doubles, TypeEnum.Team].includes(eventType) &&
61058
61060
  participant.participantType === INDIVIDUAL &&
61059
61061
  (isUngrouped(entryStatus) || entryStatus === WITHDRAWN);
61060
61062
  var mismatch = participant.participantType !== participantType && !ungroupedParticipant;
61061
- // TODO: implement gender checking for teams & pairs
61062
- var personGender = (_a = participant === null || participant === void 0 ? void 0 : participant.person) === null || _a === void 0 ? void 0 : _a.sex;
61063
- var wrongGender = enforceGender &&
61064
- eventGender &&
61065
- eventType === TypeEnum.Singles &&
61066
- [GenderEnum.Male, GenderEnum.Female].includes(eventGender) &&
61067
- personGender !== eventGender;
61068
- return mismatch || wrongGender;
61063
+ var pairGender = !mismatch &&
61064
+ isDoubles &&
61065
+ unique((_b = (_a = participant === null || participant === void 0 ? void 0 : participant.individualParticipantIds) === null || _a === void 0 ? void 0 : _a.map(function (id) { var _a, _b, _c; return (_c = (_b = (_a = participantMap === null || participantMap === void 0 ? void 0 : participantMap[id]) === null || _a === void 0 ? void 0 : _a.participant) === null || _b === void 0 ? void 0 : _b.person) === null || _c === void 0 ? void 0 : _c.sex; }).filter(Boolean)) !== null && _b !== void 0 ? _b : []);
61066
+ var validPairGender = !eventGender ||
61067
+ !(pairGender === null || pairGender === void 0 ? void 0 : pairGender.length) ||
61068
+ GenderEnum.Any === eventGender ||
61069
+ ([GenderEnum.Male, GenderEnum.Female].includes(eventGender) &&
61070
+ pairGender[0] === eventGender) ||
61071
+ (GenderEnum.Mixed === eventGender &&
61072
+ ((pairGender.length == 1 &&
61073
+ ((_c = participant.individualParticipantIds) === null || _c === void 0 ? void 0 : _c.length) === 1) ||
61074
+ pairGender.length === 2));
61075
+ var personGender = (_d = participant === null || participant === void 0 ? void 0 : participant.person) === null || _d === void 0 ? void 0 : _d.sex;
61076
+ var validPersonGender = !(participant === null || participant === void 0 ? void 0 : participant.person) ||
61077
+ !eventGender ||
61078
+ [GenderEnum.Any, GenderEnum.Mixed].includes(eventGender) ||
61079
+ ([GenderEnum.Male, GenderEnum.Female].includes(eventGender) &&
61080
+ personGender === eventGender);
61081
+ var validGender = !genderEnforced || (validPairGender && validPersonGender);
61082
+ return mismatch || !validGender;
61069
61083
  });
61070
61084
  if (invalidEntries.length) {
61071
61085
  var invalidParticipantIds = invalidEntries.map(function (participant) { return participant.participantId; });
61072
61086
  return { error: INVALID_ENTRIES, invalidParticipantIds: invalidParticipantIds };
61073
61087
  }
61074
- return __assign({}, SUCCESS);
61088
+ return __assign(__assign({}, SUCCESS), { valid: true });
61075
61089
  }
61076
61090
 
61077
61091
  function assignSeedPositions(params) {
@@ -63945,10 +63959,10 @@ function generateDrawDefinition(params) {
63945
63959
  DrawTypeEnum.SingleElimination;
63946
63960
  // get participants both for entry validation and for automated placement
63947
63961
  // automated placement requires them to be "inContext" for avoidance policies to work
63948
- var participants = getParticipants$1({
63962
+ var _26 = getParticipants$1({
63949
63963
  withIndividualParticipants: true,
63950
63964
  tournamentRecord: tournamentRecord,
63951
- }).participants;
63965
+ }), participants = _26.participants, participantMap = _26.participantMap;
63952
63966
  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;
63953
63967
  // if tournamentRecord is provided, and unless instructed to ignore valid types,
63954
63968
  // check for restrictions on allowed drawTypes
@@ -63978,6 +63992,8 @@ function generateDrawDefinition(params) {
63978
63992
  participants &&
63979
63993
  checkValidEntries({
63980
63994
  consideredEntries: consideredEntries,
63995
+ appliedPolicies: appliedPolicies,
63996
+ participantMap: participantMap,
63981
63997
  enforceGender: enforceGender,
63982
63998
  participants: participants,
63983
63999
  event: event,
@@ -64116,8 +64132,8 @@ function generateDrawDefinition(params) {
64116
64132
  else {
64117
64133
  var policiesToAttach = {};
64118
64134
  try {
64119
- for (var _26 = __values(Object.keys(policyDefinitions)), _27 = _26.next(); !_27.done; _27 = _26.next()) {
64120
- var key = _27.value;
64135
+ for (var _27 = __values(Object.keys(policyDefinitions)), _28 = _27.next(); !_28.done; _28 = _27.next()) {
64136
+ var key = _28.value;
64121
64137
  if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !==
64122
64138
  JSON.stringify(policyDefinitions[key])) {
64123
64139
  policiesToAttach[key] = policyDefinitions[key];
@@ -64127,7 +64143,7 @@ function generateDrawDefinition(params) {
64127
64143
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
64128
64144
  finally {
64129
64145
  try {
64130
- if (_27 && !_27.done && (_a = _26.return)) _a.call(_26);
64146
+ if (_28 && !_28.done && (_a = _27.return)) _a.call(_27);
64131
64147
  }
64132
64148
  finally { if (e_1) throw e_1.error; }
64133
64149
  }
@@ -64179,7 +64195,7 @@ function generateDrawDefinition(params) {
64179
64195
  var source = _a.source;
64180
64196
  return source.structureId !== existingQualifyingPlaceholderStructureId;
64181
64197
  });
64182
- var _28 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _28.qualifiersCount, qualifyingDrawPositionsCount = _28.qualifyingDrawPositionsCount, qualifyingDetails = _28.qualifyingDetails;
64198
+ var _29 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _29.qualifiersCount, qualifyingDrawPositionsCount = _29.qualifyingDrawPositionsCount, qualifyingDetails = _29.qualifyingDetails;
64183
64199
  if (qualifyingDrawPositionsCount) {
64184
64200
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
64185
64201
  (_13 = drawDefinition.structures) === null || _13 === void 0 ? void 0 : _13.push.apply(_13, __spreadArray([], __read(qualifyingResult.structures), false));
@@ -64214,11 +64230,11 @@ function generateDrawDefinition(params) {
64214
64230
  if (result.error)
64215
64231
  return result;
64216
64232
  try {
64217
- for (var _29 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
64233
+ for (var _30 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
64218
64234
  var entryStage = _a.entryStage;
64219
64235
  return entryStage === StageTypeEnum.Qualifying;
64220
- })), _30 = _29.next(); !_30.done; _30 = _29.next()) {
64221
- var entry = _30.value;
64236
+ })), _31 = _30.next(); !_31.done; _31 = _30.next()) {
64237
+ var entry = _31.value;
64222
64238
  var entryData = __assign(__assign({}, entry), { entryStage: (_16 = entry.entryStage) !== null && _16 !== void 0 ? _16 : StageTypeEnum.Main, drawDefinition: drawDefinition });
64223
64239
  // ignore errors (EXITING_PARTICIPANT)
64224
64240
  addDrawEntry(entryData);
@@ -64227,13 +64243,13 @@ function generateDrawDefinition(params) {
64227
64243
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
64228
64244
  finally {
64229
64245
  try {
64230
- if (_30 && !_30.done && (_b = _29.return)) _b.call(_29);
64246
+ if (_31 && !_31.done && (_b = _30.return)) _b.call(_30);
64231
64247
  }
64232
64248
  finally { if (e_2) throw e_2.error; }
64233
64249
  }
64234
64250
  try {
64235
- for (var _31 = __values(qualifyingDetails || []), _32 = _31.next(); !_32.done; _32 = _31.next()) {
64236
- var qualifyingDetail = _32.value;
64251
+ for (var _32 = __values(qualifyingDetails || []), _33 = _32.next(); !_33.done; _33 = _32.next()) {
64252
+ var qualifyingDetail = _33.value;
64237
64253
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
64238
64254
  var link = mainStructure &&
64239
64255
  ((_17 = generateQualifyingLink({
@@ -64256,7 +64272,7 @@ function generateDrawDefinition(params) {
64256
64272
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
64257
64273
  finally {
64258
64274
  try {
64259
- if (_32 && !_32.done && (_c = _31.return)) _c.call(_31);
64275
+ if (_33 && !_33.done && (_c = _32.return)) _c.call(_32);
64260
64276
  }
64261
64277
  finally { if (e_3) throw e_3.error; }
64262
64278
  }
@@ -64354,8 +64370,8 @@ function generateDrawDefinition(params) {
64354
64370
  var roundTarget = 1;
64355
64371
  params.qualifyingProfiles.sort(roundTargetSort);
64356
64372
  try {
64357
- for (var _33 = __values(params.qualifyingProfiles), _34 = _33.next(); !_34.done; _34 = _33.next()) {
64358
- var roundTargetProfile = _34.value;
64373
+ for (var _34 = __values(params.qualifyingProfiles), _35 = _34.next(); !_35.done; _35 = _34.next()) {
64374
+ var roundTargetProfile = _35.value;
64359
64375
  if (!Array.isArray(roundTargetProfile.structureProfiles))
64360
64376
  return decorateResult({
64361
64377
  info: mustBeAnArray('structureProfiles'),
@@ -64368,7 +64384,7 @@ function generateDrawDefinition(params) {
64368
64384
  try {
64369
64385
  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()) {
64370
64386
  var structureProfile = sortedStructureProfiles_1_1.value;
64371
- var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _35 = structureProfile.seedsCount, seedsCount_1 = _35 === void 0 ? 0 : _35, seedingProfile = structureProfile.seedingProfile, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
64387
+ 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;
64372
64388
  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 }));
64373
64389
  if (qualifyingStageResult.error) {
64374
64390
  return qualifyingStageResult;
@@ -64398,7 +64414,7 @@ function generateDrawDefinition(params) {
64398
64414
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
64399
64415
  finally {
64400
64416
  try {
64401
- if (_34 && !_34.done && (_f = _33.return)) _f.call(_33);
64417
+ if (_35 && !_35.done && (_f = _34.return)) _f.call(_34);
64402
64418
  }
64403
64419
  finally { if (e_5) throw e_5.error; }
64404
64420
  }