tods-competition-factory 1.8.19 → 1.8.21

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.21';
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
  }
@@ -6434,8 +6434,8 @@ function unlinkTournament(_a) {
6434
6434
  var _a;
6435
6435
  var tournamentRecord = tournamentRecords[currentTournamentId];
6436
6436
  var extension = findTournamentExtension({
6437
- tournamentRecord: tournamentRecord,
6438
6437
  name: LINKED_TOURNAMENTS,
6438
+ tournamentRecord: tournamentRecord,
6439
6439
  }).extension;
6440
6440
  // if there is no extension return { ...SUCCESS } because no links exist
6441
6441
  if (!extension)
@@ -9241,6 +9241,9 @@ var POLICY_ROUND_NAMING_DEFAULT = (_a$h = {},
9241
9241
  namingConventions: {
9242
9242
  round: 'Round',
9243
9243
  },
9244
+ qualifyingFinishMap: {
9245
+ 1: 'Final',
9246
+ },
9244
9247
  abbreviatedRoundNamingMap: {
9245
9248
  // key is matchUpsCount for the round
9246
9249
  1: 'F',
@@ -9255,6 +9258,7 @@ var POLICY_ROUND_NAMING_DEFAULT = (_a$h = {},
9255
9258
  affixes: {
9256
9259
  roundNumber: 'R',
9257
9260
  preFeedRound: 'Q',
9261
+ preQualifying: 'P',
9258
9262
  },
9259
9263
  stageConstants: (_b$4 = {},
9260
9264
  _b$4[MAIN] = '',
@@ -9266,33 +9270,61 @@ var POLICY_ROUND_NAMING_DEFAULT = (_a$h = {},
9266
9270
  _a$h);
9267
9271
 
9268
9272
  function getRoundContextProfile(_a) {
9269
- var roundNamingPolicy = _a.roundNamingPolicy, structure = _a.structure, matchUps = _a.matchUps;
9270
- var _b = getRoundMatchUps$1({ matchUps: matchUps }), roundProfile = _b.roundProfile, roundMatchUps = _b.roundMatchUps;
9273
+ var _b, _c, _d, _e;
9274
+ var roundNamingPolicy = _a.roundNamingPolicy, drawDefinition = _a.drawDefinition, structure = _a.structure, matchUps = _a.matchUps;
9275
+ var _f = getRoundMatchUps$1({ matchUps: matchUps }), roundProfile = _f.roundProfile, roundMatchUps = _f.roundMatchUps;
9271
9276
  var structureAbbreviation = structure.structureAbbreviation, stage = structure.stage;
9272
9277
  var isAdHocStructure = isAdHoc({ structure: structure });
9273
9278
  var isLuckyStructure = isLucky({ structure: structure });
9274
9279
  var isRoundRobin = structure.structures;
9275
9280
  var roundNamingProfile = {};
9276
9281
  var defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
9282
+ var isQualifying = structure.stage === QUALIFYING;
9283
+ var qualifyingFinishgMap = isQualifying &&
9284
+ ((roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.qualifyingFinishMap) ||
9285
+ (defaultRoundNamingPolicy === null || defaultRoundNamingPolicy === void 0 ? void 0 : defaultRoundNamingPolicy.qualifyingFinishMap) ||
9286
+ {});
9287
+ var qualifyingStageSequences = isQualifying
9288
+ ? Math.max.apply(Math, __spreadArray(__spreadArray([], __read(((_b = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) !== null && _b !== void 0 ? _b : [])
9289
+ .filter(function (structure) { return structure.stage === QUALIFYING; })
9290
+ .map(function (_a) {
9291
+ var stageSequence = _a.stageSequence;
9292
+ return stageSequence !== null && stageSequence !== void 0 ? stageSequence : 1;
9293
+ })), false), [0], false)) : 0;
9294
+ var preQualifyingSequence = qualifyingStageSequences
9295
+ ? qualifyingStageSequences - (structure.stageSequence || 1) || ''
9296
+ : '';
9297
+ var preQualifyingAffix = preQualifyingSequence
9298
+ ? ((_c = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _c === void 0 ? void 0 : _c.preQualifying) ||
9299
+ defaultRoundNamingPolicy.affixes.preQualifying ||
9300
+ ''
9301
+ : '';
9277
9302
  var roundNamingMap = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.roundNamingMap) ||
9278
9303
  defaultRoundNamingPolicy.roundNamingMap ||
9279
9304
  {};
9280
9305
  var abbreviatedRoundNamingMap = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.abbreviatedRoundNamingMap) ||
9281
9306
  defaultRoundNamingPolicy.abbreviatedRoundNamingMap ||
9282
9307
  {};
9283
- var roundNamePrefix = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) || defaultRoundNamingPolicy.affixes;
9284
- var roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
9308
+ var preFeedAffix = ((_d = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _d === void 0 ? void 0 : _d.preFeedRound) ||
9309
+ defaultRoundNamingPolicy.affixes.preFeedRound;
9310
+ var roundNumberAffix = ((_e = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.affixes) === null || _e === void 0 ? void 0 : _e.roundNumber) ||
9311
+ defaultRoundNamingPolicy.affixes.roundNumber;
9285
9312
  var namingConventions = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.namingConventions) ||
9286
9313
  defaultRoundNamingPolicy.namingConventions;
9287
9314
  var roundNameFallback = namingConventions.round;
9288
- var stageInitial = stage && stage !== MAIN && stage[0];
9289
- var stageConstants = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.stageConstants;
9290
- var stageConstant = (stage && (stageConstants === null || stageConstants === void 0 ? void 0 : stageConstants[stage])) || stageInitial;
9315
+ var stageInitial = stage && stage !== MAIN ? stage[0] : '';
9316
+ var stageConstants = (roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.stageConstants) ||
9317
+ defaultRoundNamingPolicy.stageConstants;
9318
+ var stageIndicator = (stage && (stageConstants === null || stageConstants === void 0 ? void 0 : stageConstants[stage])) || stageInitial;
9319
+ var stageConstant = "".concat(preQualifyingAffix).concat(stageIndicator).concat(preQualifyingSequence);
9291
9320
  var roundProfileKeys = roundProfile ? Object.keys(roundProfile) : [];
9321
+ var qualifyingAffix = isQualifying && (stageConstants === null || stageConstants === void 0 ? void 0 : stageConstants[QUALIFYING])
9322
+ ? "".concat(stageConstants === null || stageConstants === void 0 ? void 0 : stageConstants[QUALIFYING], "-")
9323
+ : '';
9292
9324
  if (isRoundRobin || isAdHocStructure || isLuckyStructure) {
9293
9325
  Object.assign.apply(Object, __spreadArray([roundNamingProfile], __read(roundProfileKeys.map(function (key) {
9294
9326
  var _a;
9295
- var roundName = "".concat(roundNameFallback, " ").concat(key);
9327
+ var roundName = "".concat(qualifyingAffix).concat(roundNameFallback, " ").concat(key);
9296
9328
  var abbreviatedRoundName = "".concat(roundNumberAffix).concat(key);
9297
9329
  return _a = {}, _a[key] = { roundName: roundName, abbreviatedRoundName: abbreviatedRoundName }, _a;
9298
9330
  })), false));
@@ -9304,9 +9336,11 @@ function getRoundContextProfile(_a) {
9304
9336
  return;
9305
9337
  var _b = roundProfile[round], matchUpsCount = _b.matchUpsCount, preFeedRound = _b.preFeedRound;
9306
9338
  var participantsCount = matchUpsCount * 2;
9307
- var sizedRoundName = roundNamingMap[matchUpsCount] ||
9308
- "".concat(roundNamePrefix.roundNumber).concat(participantsCount);
9309
- var suffix = preFeedRound ? "-".concat(roundNamePrefix.preFeedRound) : '';
9339
+ var sizedRoundName = (qualifyingFinishgMap === null || qualifyingFinishgMap === void 0 ? void 0 : qualifyingFinishgMap[roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[round].finishingRound]) ||
9340
+ (qualifyingFinishgMap && "".concat(roundNumberAffix).concat(participantsCount)) ||
9341
+ roundNamingMap[matchUpsCount] ||
9342
+ "".concat(roundNumberAffix).concat(participantsCount);
9343
+ var suffix = preFeedRound ? "-".concat(preFeedAffix) : '';
9310
9344
  var profileRoundName = "".concat(sizedRoundName).concat(suffix);
9311
9345
  var roundName = [
9312
9346
  stageConstant,
@@ -9316,7 +9350,7 @@ function getRoundContextProfile(_a) {
9316
9350
  .filter(Boolean)
9317
9351
  .join('-');
9318
9352
  var sizedAbbreviation = abbreviatedRoundNamingMap[matchUpsCount] ||
9319
- "".concat(roundNamePrefix.roundNumber).concat(participantsCount);
9353
+ "".concat(roundNumberAffix).concat(participantsCount);
9320
9354
  var profileAbbreviation = "".concat(sizedAbbreviation).concat(suffix);
9321
9355
  var abbreviatedRoundName = [
9322
9356
  stageConstant,
@@ -9514,6 +9548,7 @@ function getAllStructureMatchUps(_a) {
9514
9548
  var roundNamingPolicy = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_ROUND_NAMING];
9515
9549
  var result = getRoundContextProfile({
9516
9550
  roundNamingPolicy: roundNamingPolicy,
9551
+ drawDefinition: drawDefinition,
9517
9552
  structure: structure,
9518
9553
  matchUps: matchUps,
9519
9554
  });
@@ -25071,16 +25106,6 @@ function scoreModification$1(params) {
25071
25106
  return decorateResult({ result: result, stack: stack });
25072
25107
  }
25073
25108
 
25074
- /**
25075
- *
25076
- * Finds all structureIds which are affected by an outcome change in a completed structure
25077
- * Is specific to Round Robins which direct participants by WIN_RATIO
25078
- *
25079
- * @param {object} drawDefinition
25080
- * @param {object} structure
25081
- * @param {object} matchUp
25082
- *
25083
- */
25084
25109
  function getAffectedTargetStructureIds(_a) {
25085
25110
  var _b, _c;
25086
25111
  var drawDefinition = _a.drawDefinition, structure = _a.structure, matchUp = _a.matchUp;
@@ -31985,23 +32010,22 @@ function removeCollectionDefinition(params) {
31985
32010
 
31986
32011
  function addCollectionDefinition$1(_a) {
31987
32012
  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;
32013
+ var _f, _g, _h, _j, _k, _l, _m, _o, _p;
32014
+ 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
32015
  var stack = 'addCollectionDefinition';
31991
32016
  var appliedPolicies = (_f = getAppliedPolicies({
31992
32017
  tournamentRecord: tournamentRecord,
31993
32018
  drawDefinition: drawDefinition,
31994
32019
  event: event,
31995
32020
  }).appliedPolicies) !== null && _f !== void 0 ? _f : {};
31996
- var matchUpActionsPolicy = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS];
32021
+ 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
32022
  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;
32023
+ enforceCategory !== null && enforceCategory !== void 0 ? enforceCategory : (_h = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _h === void 0 ? void 0 : _h.enforceCategory;
32024
+ 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) !==
32025
+ false;
32001
32026
  var checkCategory = !!((referenceCategory !== null && referenceCategory !== void 0 ? referenceCategory : event === null || event === void 0 ? void 0 : event.category) &&
32002
32027
  enforceCategory !== false);
32003
- var checkGender = !!((referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender) &&
32004
- enforceGender !== false);
32028
+ var checkGender = !!((referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender) && genderEnforced);
32005
32029
  var validationResult = validateCollectionDefinition({
32006
32030
  referenceCategory: referenceCategory !== null && referenceCategory !== void 0 ? referenceCategory : event === null || event === void 0 ? void 0 : event.category,
32007
32031
  collectionDefinition: collectionDefinition,
@@ -32026,7 +32050,7 @@ function addCollectionDefinition$1(_a) {
32026
32050
  return decorateResult({ result: { error: result.error }, stack: stack });
32027
32051
  var structure = result === null || result === void 0 ? void 0 : result.structure;
32028
32052
  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;
32053
+ 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
32054
  var tieFormat = copyTieFormat(existingTieFormat);
32031
32055
  result = validateTieFormat({ tieFormat: tieFormat });
32032
32056
  if (result === null || result === void 0 ? void 0 : result.error) {
@@ -32054,7 +32078,7 @@ function addCollectionDefinition$1(_a) {
32054
32078
  });
32055
32079
  // calculate new winCriteria for tieFormat
32056
32080
  // if existing winCriteria is aggregateValue, retain
32057
- var _q = calculateWinCriteria(tieFormat), aggregateValue = _q.aggregateValue, valueGoal = _q.valueGoal;
32081
+ var _r = calculateWinCriteria(tieFormat), aggregateValue = _r.aggregateValue, valueGoal = _r.valueGoal;
32058
32082
  tieFormat.winCriteria = definedAttributes({ aggregateValue: aggregateValue, valueGoal: valueGoal });
32059
32083
  // if valueGoal has changed, force renaming of the tieFormat
32060
32084
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
@@ -32080,13 +32104,13 @@ function addCollectionDefinition$1(_a) {
32080
32104
  event.tieFormat = prunedTieFormat;
32081
32105
  try {
32082
32106
  // 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;
32107
+ for (var _s = __values((_l = event.drawDefinitions) !== null && _l !== void 0 ? _l : []), _t = _s.next(); !_t.done; _t = _s.next()) {
32108
+ var drawDefinition_1 = _t.value;
32085
32109
  if (drawDefinition_1.tieFormat)
32086
32110
  continue;
32087
32111
  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;
32112
+ 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()) {
32113
+ var structure_1 = _v.value;
32090
32114
  if (structure_1.tieFormat)
32091
32115
  continue;
32092
32116
  var result_1 = updateStructureMatchUps({
@@ -32103,7 +32127,7 @@ function addCollectionDefinition$1(_a) {
32103
32127
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
32104
32128
  finally {
32105
32129
  try {
32106
- if (_u && !_u.done && (_c = _t.return)) _c.call(_t);
32130
+ if (_v && !_v.done && (_c = _u.return)) _c.call(_u);
32107
32131
  }
32108
32132
  finally { if (e_2) throw e_2.error; }
32109
32133
  }
@@ -32112,7 +32136,7 @@ function addCollectionDefinition$1(_a) {
32112
32136
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
32113
32137
  finally {
32114
32138
  try {
32115
- if (_s && !_s.done && (_b = _r.return)) _b.call(_r);
32139
+ if (_t && !_t.done && (_b = _s.return)) _b.call(_s);
32116
32140
  }
32117
32141
  finally { if (e_1) throw e_1.error; }
32118
32142
  }
@@ -32175,8 +32199,8 @@ function addCollectionDefinition$1(_a) {
32175
32199
  // all team matchUps in the drawDefinition which do not have tieFormats and where strucures do not have tieFormats should have matchUps added
32176
32200
  drawDefinition.tieFormat = prunedTieFormat;
32177
32201
  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;
32202
+ for (var _w = __values((_o = drawDefinition.structures) !== null && _o !== void 0 ? _o : []), _x = _w.next(); !_x.done; _x = _w.next()) {
32203
+ var structure_2 = _x.value;
32180
32204
  var result_3 = updateStructureMatchUps({
32181
32205
  updateInProgressMatchUps: updateInProgressMatchUps,
32182
32206
  collectionDefinition: collectionDefinition,
@@ -32191,7 +32215,7 @@ function addCollectionDefinition$1(_a) {
32191
32215
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
32192
32216
  finally {
32193
32217
  try {
32194
- if (_w && !_w.done && (_e = _v.return)) _e.call(_v);
32218
+ if (_x && !_x.done && (_e = _w.return)) _e.call(_w);
32195
32219
  }
32196
32220
  finally { if (e_3) throw e_3.error; }
32197
32221
  }
@@ -32207,7 +32231,7 @@ function addCollectionDefinition$1(_a) {
32207
32231
  else {
32208
32232
  return { error: MISSING_DRAW_DEFINITION };
32209
32233
  }
32210
- if ((_o = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _o === void 0 ? void 0 : _o[TIE_FORMAT_MODIFICATIONS]) {
32234
+ if ((_p = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _p === void 0 ? void 0 : _p[TIE_FORMAT_MODIFICATIONS]) {
32211
32235
  var auditData = definedAttributes({
32212
32236
  drawId: drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawId,
32213
32237
  collectionDefinition: collectionDefinition,
@@ -39261,7 +39285,7 @@ var matchUpActionConstants = {
39261
39285
  function matchUpActions$2(_a) {
39262
39286
  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
39287
  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;
39288
+ 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
39289
  if (!drawDefinition)
39266
39290
  return { error: MISSING_DRAW_DEFINITION };
39267
39291
  if (!matchUpId)
@@ -39287,8 +39311,8 @@ function matchUpActions$2(_a) {
39287
39311
  event: event,
39288
39312
  }).appliedPolicies) !== null && _c !== void 0 ? _c : {};
39289
39313
  Object.assign(appliedPolicies, specifiedPolicyDefinitions !== null && specifiedPolicyDefinitions !== void 0 ? specifiedPolicyDefinitions : {});
39290
- var isAdHocMatchUp = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
39291
39314
  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];
39315
+ var isAdHocMatchUp = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
39292
39316
  var enabledStructures = getEnabledStructures({
39293
39317
  actionType: MATCHUP_ACTION,
39294
39318
  appliedPolicies: appliedPolicies,
@@ -39527,9 +39551,9 @@ function matchUpActions$2(_a) {
39527
39551
  ((_v = inContextMatchUp.sides) === null || _v === void 0 ? void 0 : _v.filter(function (side) { return side.particiapntId; }).length) === 1 &&
39528
39552
  ((_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
39553
  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;
39554
+ 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) !==
39555
+ false;
39556
+ var gender_1 = genderEnforced ? inContextMatchUp.gender : undefined;
39533
39557
  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
39558
  var allParticipantIds_1 = allParticipants === null || allParticipants === void 0 ? void 0 : allParticipants.map(getParticipantId);
39535
39559
  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 +39722,7 @@ function getEventAlternateParticipantIds(_a) {
39698
39722
  }
39699
39723
 
39700
39724
  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;
39725
+ 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
39726
  if (!tournamentRecord)
39703
39727
  return { error: MISSING_TOURNAMENT_RECORD };
39704
39728
  if (!drawId) {
@@ -39727,6 +39751,7 @@ function matchUpActions$1(_a) {
39727
39751
  tournamentParticipants: tournamentRecord.participants,
39728
39752
  policyDefinitions: policyDefinitions,
39729
39753
  drawDefinition: drawDefinition,
39754
+ enforceGender: enforceGender,
39730
39755
  participantId: participantId,
39731
39756
  sideNumber: sideNumber,
39732
39757
  matchUpId: matchUpId,
@@ -39739,7 +39764,7 @@ function matchUpActions$1(_a) {
39739
39764
  }
39740
39765
 
39741
39766
  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;
39767
+ 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
39768
  if (typeof tournamentRecords !== 'object' ||
39744
39769
  typeof tournamentId !== 'string' ||
39745
39770
  typeof matchUpId !== 'string' ||
@@ -39757,7 +39782,9 @@ function matchUpActions(params) {
39757
39782
  return result;
39758
39783
  return matchUpActions$1({
39759
39784
  drawDefinition: result.drawDefinition,
39785
+ policyDefinitions: policyDefinitions,
39760
39786
  tournamentRecord: tournamentRecord,
39787
+ enforceGender: enforceGender,
39761
39788
  participantId: participantId,
39762
39789
  sideNumber: sideNumber,
39763
39790
  matchUpId: matchUpId,
@@ -46854,7 +46881,7 @@ function generateVoluntaryConsolation$1(params) {
46854
46881
  // not for use when generating structures from qualifyingProfiles
46855
46882
  function generateQualifyingStructure$1(params) {
46856
46883
  var _a;
46857
- var _b, _c, _d;
46884
+ var _b, _c, _d, _e;
46858
46885
  if (!params.drawDefinition)
46859
46886
  return { error: MISSING_DRAW_DEFINITION };
46860
46887
  var stack = 'generateQualifyingStructure';
@@ -46893,7 +46920,7 @@ function generateQualifyingStructure$1(params) {
46893
46920
  var chainModified = void 0;
46894
46921
  while (!chainModified && nextStructureId_1) {
46895
46922
  targetStructure.stageSequence = nextStageSequence;
46896
- var targetTargetStructureId = (_c = (_b = drawDefinition.links.find(function (link) { return link.source.structureId === nextStructureId_1; })) === null || _b === void 0 ? void 0 : _b.target) === null || _c === void 0 ? void 0 : _c.structureId;
46923
+ var targetTargetStructureId = (_d = (_c = (_b = drawDefinition.links) === null || _b === void 0 ? void 0 : _b.find(function (link) { return link.source.structureId === nextStructureId_1; })) === null || _c === void 0 ? void 0 : _c.target) === null || _d === void 0 ? void 0 : _d.structureId;
46897
46924
  nextStructureId_1 = targetTargetStructureId;
46898
46925
  nextStageSequence += 1;
46899
46926
  if (!targetTargetStructureId) {
@@ -46926,7 +46953,7 @@ function generateQualifyingStructure$1(params) {
46926
46953
  ? "".concat(constantToString(QUALIFYING), " ").concat(roundTargetName).concat(stageSequenceName)
46927
46954
  : constantToString(QUALIFYING));
46928
46955
  if (drawType === ROUND_ROBIN) {
46929
- var _e = generateRoundRobin({
46956
+ var _f = generateRoundRobin({
46930
46957
  structureName: structureName || qualifyingStructureName,
46931
46958
  structureId: structureId || (uuids === null || uuids === void 0 ? void 0 : uuids.pop()),
46932
46959
  stage: QUALIFYING,
@@ -46939,7 +46966,7 @@ function generateQualifyingStructure$1(params) {
46939
46966
  drawSize: drawSize,
46940
46967
  isMock: isMock,
46941
46968
  uuids: uuids,
46942
- }), maxRoundNumber = _e.maxRoundNumber /*, groupSize*/, structures = _e.structures, groupCount = _e.groupCount;
46969
+ }), maxRoundNumber = _f.maxRoundNumber /*, groupSize*/, structures = _f.structures, groupCount = _f.groupCount;
46943
46970
  qualifiersCount = groupCount;
46944
46971
  roundLimit = maxRoundNumber;
46945
46972
  structure = structures[0];
@@ -46973,7 +47000,7 @@ function generateQualifyingStructure$1(params) {
46973
47000
  extension: { name: ROUND_TARGET, value: roundTarget },
46974
47001
  });
46975
47002
  }
46976
- qualifiersCount = (_d = matchUps === null || matchUps === void 0 ? void 0 : matchUps.filter(function (matchUp) { return matchUp.roundNumber === roundLimit; })) === null || _d === void 0 ? void 0 : _d.length;
47003
+ qualifiersCount = (_e = matchUps === null || matchUps === void 0 ? void 0 : matchUps.filter(function (matchUp) { return matchUp.roundNumber === roundLimit; })) === null || _e === void 0 ? void 0 : _e.length;
46977
47004
  }
46978
47005
  // order of operations is important here!! finalQualifier positions is not yet updated when this step occurs
46979
47006
  var linkType = drawType === ROUND_ROBIN ? LinkTypeEnum.Position : LinkTypeEnum.Winner;
@@ -49067,20 +49094,11 @@ function removeEventEntries(_a) {
49067
49094
  }
49068
49095
 
49069
49096
  /**
49070
- *
49071
49097
  * 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
49098
  */
49081
49099
  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;
49100
+ var _a, _b, _c, _d, _e;
49101
+ 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
49102
  var stack = 'addEventEntries';
49085
49103
  if (!event)
49086
49104
  return { error: MISSING_EVENT };
@@ -49092,6 +49110,10 @@ function addEventEntries(params) {
49092
49110
  }
49093
49111
  if (!(event === null || event === void 0 ? void 0 : event.eventId))
49094
49112
  return { error: EVENT_NOT_FOUND };
49113
+ var appliedPolicies = (_a = getAppliedPolicies({ tournamentRecord: tournamentRecord, event: event }).appliedPolicies) !== null && _a !== void 0 ? _a : {};
49114
+ 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];
49115
+ 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) !==
49116
+ false;
49095
49117
  var addedParticipantIdEntries = [];
49096
49118
  var removedEntries = [];
49097
49119
  if ((extensions &&
@@ -49105,9 +49127,9 @@ function addEventEntries(params) {
49105
49127
  });
49106
49128
  }
49107
49129
  var checkTypedParticipants = !!tournamentRecord;
49108
- var misMatchedGender = [];
49130
+ var mismatchedGender = [];
49109
49131
  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) {
49132
+ var typedParticipantIds = ((_e = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants) === null || _e === void 0 ? void 0 : _e.filter(function (participant) {
49111
49133
  var _a, _b, _c;
49112
49134
  if (!participantIds.includes(participant.participantId))
49113
49135
  return false;
@@ -49117,7 +49139,7 @@ function addEventEntries(params) {
49117
49139
  var validDoubles = event.eventType === DOUBLES$1 && participant.participantType === PAIR;
49118
49140
  if (validSingles &&
49119
49141
  (!event.gender ||
49120
- ignoreEventGender ||
49142
+ !genderEnforced ||
49121
49143
  [MIXED, ANY].includes(event.gender) ||
49122
49144
  event.gender === ((_a = participant.person) === null || _a === void 0 ? void 0 : _a.sex))) {
49123
49145
  return true;
@@ -49132,10 +49154,10 @@ function addEventEntries(params) {
49132
49154
  }
49133
49155
  if (validSingles &&
49134
49156
  event.gender &&
49135
- !ignoreEventGender &&
49157
+ genderEnforced &&
49136
49158
  ![MIXED, ANY].includes(event.gender) &&
49137
49159
  event.gender !== ((_b = participant.person) === null || _b === void 0 ? void 0 : _b.sex)) {
49138
- misMatchedGender.push({
49160
+ mismatchedGender.push({
49139
49161
  participantId: participant.participantId,
49140
49162
  sex: (_c = participant.person) === null || _c === void 0 ? void 0 : _c.sex,
49141
49163
  });
@@ -49224,7 +49246,7 @@ function addEventEntries(params) {
49224
49246
  var invalidParticipantIds = validParticipantIds.length !== participantIds.length;
49225
49247
  if (invalidParticipantIds)
49226
49248
  return decorateResult({
49227
- context: { misMatchedGender: misMatchedGender, gender: event.gender },
49249
+ context: { mismatchedGender: mismatchedGender, gender: event.gender },
49228
49250
  result: { error: INVALID_PARTICIPANT_IDS },
49229
49251
  stack: stack,
49230
49252
  });
@@ -52588,6 +52610,7 @@ var entryGovernor = {
52588
52610
 
52589
52611
  var linkGovernor = {
52590
52612
  generateQualifyingLink: generateQualifyingLink,
52613
+ getStructureLinks: getStructureLinks,
52591
52614
  };
52592
52615
 
52593
52616
  var definitionTemplate = function () { return ({
@@ -57251,7 +57274,7 @@ function getTieMatchUpContext(_a) {
57251
57274
 
57252
57275
  function assignTieMatchUpParticipantId(params) {
57253
57276
  var e_1, _a;
57254
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
57277
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
57255
57278
  var matchUpContext = getTieMatchUpContext(params);
57256
57279
  if (matchUpContext.error)
57257
57280
  return matchUpContext;
@@ -57275,10 +57298,9 @@ function assignTieMatchUpParticipantId(params) {
57275
57298
  return decorateResult({ result: __assign({}, SUCCESS), stack: stack });
57276
57299
  }
57277
57300
  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);
57301
+ teamParticipantId !== null && teamParticipantId !== void 0 ? teamParticipantId : (params.sideNumber
57302
+ ? (_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
57303
+ : undefined);
57282
57304
  var participantToAssign = (_f = (_e = getParticipants$1({
57283
57305
  participantFilters: { participantIds: [participantId] },
57284
57306
  tournamentRecord: tournamentRecord,
@@ -57291,12 +57313,11 @@ function assignTieMatchUpParticipantId(params) {
57291
57313
  drawDefinition: drawDefinition,
57292
57314
  event: event,
57293
57315
  }).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) &&
57316
+ 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];
57317
+ 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;
57318
+ if (genderEnforced &&
57298
57319
  [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)) {
57320
+ (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) !== ((_m = participantToAssign.person) === null || _m === void 0 ? void 0 : _m.sex)) {
57300
57321
  return { error: INVALID_PARTICIPANT, info: 'Gender mismatch' };
57301
57322
  }
57302
57323
  var individualParticipantIds = participantToAssign.individualParticipantIds, participantType = participantToAssign.participantType;
@@ -57323,12 +57344,12 @@ function assignTieMatchUpParticipantId(params) {
57323
57344
  return { error: PARTICIPANT_NOT_FOUND };
57324
57345
  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
57346
  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);
57347
+ 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; });
57348
+ var sideNumber = (_p = params.sideNumber) !== null && _p !== void 0 ? _p : teamSide === null || teamSide === void 0 ? void 0 : teamSide.sideNumber;
57328
57349
  if (!tieFormat) {
57329
57350
  return { error: MISSING_TIE_FORMAT };
57330
57351
  }
57331
- var collectionDefinition = (_l = tieFormat.collectionDefinitions) === null || _l === void 0 ? void 0 : _l.find(function (collectionDefinition) { return collectionDefinition.collectionId === collectionId; });
57352
+ var collectionDefinition = (_q = tieFormat.collectionDefinitions) === null || _q === void 0 ? void 0 : _q.find(function (collectionDefinition) { return collectionDefinition.collectionId === collectionId; });
57332
57353
  if (!collectionDefinition)
57333
57354
  return { error: MISSING_COLLECTION_DEFINITION };
57334
57355
  ensureSideLineUps({
@@ -57338,12 +57359,12 @@ function assignTieMatchUpParticipantId(params) {
57338
57359
  drawDefinition: drawDefinition,
57339
57360
  dualMatchUp: dualMatchUp,
57340
57361
  });
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({
57362
+ 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; });
57363
+ 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; });
57364
+ var lineUp = (_t = dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.lineUp) !== null && _t !== void 0 ? _t : (_u = getTeamLineUp({
57344
57365
  participantId: teamParticipantId,
57345
57366
  drawDefinition: drawDefinition,
57346
- })) === null || _q === void 0 ? void 0 : _q.lineUp;
57367
+ })) === null || _u === void 0 ? void 0 : _u.lineUp;
57347
57368
  var targetAssignments = lineUp === null || lineUp === void 0 ? void 0 : lineUp.filter(function (participantAssignment) {
57348
57369
  var _a;
57349
57370
  return (_a = participantAssignment.collectionAssignments) === null || _a === void 0 ? void 0 : _a.find(function (assignment) {
@@ -58571,8 +58592,8 @@ function analyzeDraws(_a) {
58571
58592
  return !inactiveStructure;
58572
58593
  }).length;
58573
58594
  var links = getStructureLinks({
58574
- drawDefinition: drawDefinition,
58575
58595
  structureId: mainStructure.structureId,
58596
+ drawDefinition: drawDefinition,
58576
58597
  }).links;
58577
58598
  var isMatchPlay = ensureInt(mainStructure.activeRounds[0]) === 1 &&
58578
58599
  mainStructure.activeRounds.length === 1 &&
@@ -60122,7 +60143,7 @@ function removeMatchUpSideParticipant(_a) {
60122
60143
 
60123
60144
  function replaceTieMatchUpParticipantId(params) {
60124
60145
  var e_1, _a;
60125
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
60146
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
60126
60147
  var matchUpContext = getTieMatchUpContext(params);
60127
60148
  if (matchUpContext.error)
60128
60149
  return matchUpContext;
@@ -60160,18 +60181,18 @@ function replaceTieMatchUpParticipantId(params) {
60160
60181
  drawDefinition: drawDefinition,
60161
60182
  event: event,
60162
60183
  }).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];
60184
+ 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
60185
  var newParticipant = targetParticipants.find(function (_a) {
60166
60186
  var participantId = _a.participantId;
60167
60187
  return participantId === newParticipantId;
60168
60188
  });
60169
- if (((_e = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _e === void 0 ? void 0 : _e.enforceGender) &&
60189
+ 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;
60190
+ if (genderEnforced &&
60170
60191
  [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)) {
60192
+ (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
60193
  return { error: INVALID_PARTICIPANT, info: 'Gender mismatch' };
60173
60194
  }
60174
- var substitutionProcessCodes = (_g = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _g === void 0 ? void 0 : _g.substitution;
60195
+ var substitutionProcessCodes = (_l = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _l === void 0 ? void 0 : _l.substitution;
60175
60196
  ensureSideLineUps({
60176
60197
  tournamentId: tournamentRecord.tournamentId,
60177
60198
  eventId: event.eventId,
@@ -60179,7 +60200,7 @@ function replaceTieMatchUpParticipantId(params) {
60179
60200
  drawDefinition: drawDefinition,
60180
60201
  dualMatchUp: dualMatchUp,
60181
60202
  });
60182
- var dualMatchUpSide = (_h = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _h === void 0 ? void 0 : _h.find(function (_a) {
60203
+ var dualMatchUpSide = (_m = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (_a) {
60183
60204
  var sideNumber = _a.sideNumber;
60184
60205
  return sideNumber === side.sideNumber;
60185
60206
  });
@@ -60193,7 +60214,7 @@ function replaceTieMatchUpParticipantId(params) {
60193
60214
  stack: stack,
60194
60215
  });
60195
60216
  }
60196
- var allTieIndividualParticipantIds = (_j = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _j === void 0 ? void 0 : _j.flatMap(function (side) {
60217
+ var allTieIndividualParticipantIds = (_o = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _o === void 0 ? void 0 : _o.flatMap(function (side) {
60197
60218
  var _a, _b;
60198
60219
  return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds) ||
60199
60220
  ((_b = side.participant) === null || _b === void 0 ? void 0 : _b.participantId) ||
@@ -60202,10 +60223,10 @@ function replaceTieMatchUpParticipantId(params) {
60202
60223
  if (allTieIndividualParticipantIds === null || allTieIndividualParticipantIds === void 0 ? void 0 : allTieIndividualParticipantIds.includes(newParticipantId)) {
60203
60224
  return decorateResult({ result: { error: EXISTING_PARTICIPANT }, stack: stack });
60204
60225
  }
60205
- var teamParticipantId = (_l = (_k = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _k === void 0 ? void 0 : _k.find(function (_a) {
60226
+ var teamParticipantId = (_q = (_p = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _p === void 0 ? void 0 : _p.find(function (_a) {
60206
60227
  var sideNumber = _a.sideNumber;
60207
60228
  return sideNumber === side.sideNumber;
60208
- })) === null || _l === void 0 ? void 0 : _l.participantId;
60229
+ })) === null || _q === void 0 ? void 0 : _q.participantId;
60209
60230
  var teamLineUp = dualMatchUpSide.lineUp;
60210
60231
  var newParticipantIdInLineUp = teamLineUp === null || teamLineUp === void 0 ? void 0 : teamLineUp.find(function (_a) {
60211
60232
  var participantId = _a.participantId;
@@ -60216,7 +60237,7 @@ function replaceTieMatchUpParticipantId(params) {
60216
60237
  ? teamCompetitor.substitutionOrder
60217
60238
  : order;
60218
60239
  }, 0);
60219
- var modifiedLineUp = (teamLineUp === null || teamLineUp === void 0 ? void 0 : teamLineUp.map(function (teamCompetitor) {
60240
+ var modifiedLineUp = (_r = teamLineUp === null || teamLineUp === void 0 ? void 0 : teamLineUp.map(function (teamCompetitor) {
60220
60241
  var _a;
60221
60242
  var modifiedCompetitor = makeDeepCopy(teamCompetitor, false, true);
60222
60243
  // if the current competitor is not either id, return as is
@@ -60251,16 +60272,16 @@ function replaceTieMatchUpParticipantId(params) {
60251
60272
  var assignment = { collectionId: collectionId, collectionPosition: collectionPosition };
60252
60273
  if (substitution) {
60253
60274
  assignment.previousParticipantId = existingParticipantId;
60254
- assignment.substitutionOrder = (substitutionOrder || 0) + 1;
60275
+ assignment.substitutionOrder = (substitutionOrder !== null && substitutionOrder !== void 0 ? substitutionOrder : 0) + 1;
60255
60276
  }
60256
60277
  modifiedCompetitor.collectionAssignments.push(assignment);
60257
60278
  }
60258
60279
  return modifiedCompetitor;
60259
- })) || [];
60280
+ })) !== null && _r !== void 0 ? _r : [];
60260
60281
  if (!newParticipantIdInLineUp) {
60261
60282
  var collectionAssignment = { collectionId: collectionId, collectionPosition: collectionPosition };
60262
60283
  if (substitution) {
60263
- collectionAssignment.substitutionOrder = (substitutionOrder || 0) + 1;
60284
+ collectionAssignment.substitutionOrder = (substitutionOrder !== null && substitutionOrder !== void 0 ? substitutionOrder : 0) + 1;
60264
60285
  collectionAssignment.previousParticipantId = existingParticipantId;
60265
60286
  }
60266
60287
  var assignment = {
@@ -60316,14 +60337,14 @@ function replaceTieMatchUpParticipantId(params) {
60316
60337
  });
60317
60338
  if (result_1.error)
60318
60339
  return decorateResult({ result: result_1, stack: stack });
60319
- participantAdded = (_m = result_1.participant) === null || _m === void 0 ? void 0 : _m.participantId;
60340
+ participantAdded = (_s = result_1.participant) === null || _s === void 0 ? void 0 : _s.participantId;
60320
60341
  }
60321
60342
  // now attempt to cleanup/delete previous pairParticipant
60322
60343
  result = getPairedParticipant({
60323
60344
  participantIds: existingIndividualParticipantIds,
60324
60345
  tournamentRecord: tournamentRecord_1,
60325
60346
  });
60326
- var existingPairParticipantId = (_o = result.participant) === null || _o === void 0 ? void 0 : _o.participantId;
60347
+ var existingPairParticipantId = (_t = result.participant) === null || _t === void 0 ? void 0 : _t.participantId;
60327
60348
  if (existingPairParticipantId) {
60328
60349
  var result_2 = deleteParticipants({
60329
60350
  participantIds: [existingPairParticipantId],
@@ -60333,9 +60354,9 @@ function replaceTieMatchUpParticipantId(params) {
60333
60354
  participantRemoved = existingPairParticipantId;
60334
60355
  }
60335
60356
  }
60336
- if (substitution || ((_p = side.substitutions) === null || _p === void 0 ? void 0 : _p.length) === 1) {
60357
+ if (substitution || ((_u = side.substitutions) === null || _u === void 0 ? void 0 : _u.length) === 1) {
60337
60358
  if (substitution) {
60338
- var processCodes = (tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) || [];
60359
+ var processCodes = (_v = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) !== null && _v !== void 0 ? _v : [];
60339
60360
  if (substitutionProcessCodes)
60340
60361
  processCodes.push.apply(processCodes, __spreadArray([], __read(substitutionProcessCodes), false));
60341
60362
  if (tieMatchUp)
@@ -60344,18 +60365,18 @@ function replaceTieMatchUpParticipantId(params) {
60344
60365
  else {
60345
60366
  try {
60346
60367
  // 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);
60368
+ for (var _y = __values(substitutionProcessCodes || []), _z = _y.next(); !_z.done; _z = _y.next()) {
60369
+ var substitutionProcessCode = _z.value;
60370
+ var codeIndex = (_w = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _w === void 0 ? void 0 : _w.lastIndexOf(substitutionProcessCode);
60350
60371
  // remove only one instance of substitutionProcessCode
60351
60372
  codeIndex !== undefined &&
60352
- ((_r = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _r === void 0 ? void 0 : _r.splice(codeIndex, 1));
60373
+ ((_x = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _x === void 0 ? void 0 : _x.splice(codeIndex, 1));
60353
60374
  }
60354
60375
  }
60355
60376
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
60356
60377
  finally {
60357
60378
  try {
60358
- if (_t && !_t.done && (_a = _s.return)) _a.call(_s);
60379
+ if (_z && !_z.done && (_a = _y.return)) _a.call(_y);
60359
60380
  }
60360
60381
  finally { if (e_1) throw e_1.error; }
60361
60382
  }
@@ -60382,7 +60403,7 @@ function replaceTieMatchUpParticipantId(params) {
60382
60403
 
60383
60404
  function removeTieMatchUpParticipantId(params) {
60384
60405
  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;
60406
+ 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
60407
  var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, participantId = params.participantId, event = params.event;
60387
60408
  var stack = 'removeTieMatchUpParticiapantId';
60388
60409
  if (!participantId)
@@ -60395,33 +60416,32 @@ function removeTieMatchUpParticipantId(params) {
60395
60416
  drawDefinition: drawDefinition,
60396
60417
  event: event,
60397
60418
  }).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;
60419
+ 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];
60420
+ var substitutionProcessCodes = (_e = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _e === void 0 ? void 0 : _e.substitution;
60401
60421
  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
60422
  if (!dualMatchUp)
60403
60423
  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) {
60424
+ var side = (_f = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _f === void 0 ? void 0 : _f.find(function (side) {
60405
60425
  var _a, _b, _c;
60406
60426
  return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.participantId) === participantId ||
60407
60427
  ((_c = (_b = side.participant) === null || _b === void 0 ? void 0 : _b.individualParticipantIds) === null || _c === void 0 ? void 0 : _c.includes(participantId));
60408
60428
  });
60409
60429
  if (!side)
60410
60430
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack: stack });
60411
- if (!((_d = side.substitutions) === null || _d === void 0 ? void 0 : _d.length) &&
60431
+ if (!((_g = side.substitutions) === null || _g === void 0 ? void 0 : _g.length) &&
60412
60432
  (scoreHasValue({ score: inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.score }) ||
60413
60433
  (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.winningSide)))
60414
60434
  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) {
60435
+ var teamParticipantId = (_j = (_h = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _h === void 0 ? void 0 : _h.find(function (_a) {
60416
60436
  var sideNumber = _a.sideNumber;
60417
60437
  return sideNumber === side.sideNumber;
60418
- })) === null || _f === void 0 ? void 0 : _f.participantId;
60438
+ })) === null || _j === void 0 ? void 0 : _j.participantId;
60419
60439
  if (!teamParticipantId)
60420
60440
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack: stack });
60421
- var participantToRemove = (_h = (_g = getParticipants$1({
60441
+ var participantToRemove = (_l = (_k = getParticipants$1({
60422
60442
  participantFilters: { participantIds: [participantId] },
60423
60443
  tournamentRecord: tournamentRecord,
60424
- })) === null || _g === void 0 ? void 0 : _g.participants) === null || _h === void 0 ? void 0 : _h[0];
60444
+ })) === null || _k === void 0 ? void 0 : _k.participants) === null || _l === void 0 ? void 0 : _l[0];
60425
60445
  if (!participantToRemove) {
60426
60446
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack: stack });
60427
60447
  }
@@ -60438,12 +60458,12 @@ function removeTieMatchUpParticipantId(params) {
60438
60458
  drawDefinition: drawDefinition,
60439
60459
  dualMatchUp: dualMatchUp,
60440
60460
  });
60441
- var dualMatchUpSide = (_j = dualMatchUp.sides) === null || _j === void 0 ? void 0 : _j.find(function (_a) {
60461
+ var dualMatchUpSide = (_m = dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (_a) {
60442
60462
  var sideNumber = _a.sideNumber;
60443
60463
  return sideNumber === side.sideNumber;
60444
60464
  });
60445
60465
  if (!dualMatchUpSide &&
60446
- (((_k = dualMatchUp.sides) === null || _k === void 0 ? void 0 : _k.filter(function (_a) {
60466
+ (((_o = dualMatchUp.sides) === null || _o === void 0 ? void 0 : _o.filter(function (_a) {
60447
60467
  var lineUp = _a.lineUp;
60448
60468
  return !lineUp;
60449
60469
  }).length) || 0) < 2) {
@@ -60455,7 +60475,7 @@ function removeTieMatchUpParticipantId(params) {
60455
60475
  teamParticipantId: teamParticipantId,
60456
60476
  });
60457
60477
  });
60458
- dualMatchUpSide = (_l = dualMatchUp.sides) === null || _l === void 0 ? void 0 : _l.find(function (side) {
60478
+ dualMatchUpSide = (_p = dualMatchUp.sides) === null || _p === void 0 ? void 0 : _p.find(function (side) {
60459
60479
  var _a;
60460
60480
  return ((_a = drawPositionMap_1 === null || drawPositionMap_1 === void 0 ? void 0 : drawPositionMap_1.find(function (_a) {
60461
60481
  var drawPosition = _a.drawPosition;
@@ -60468,14 +60488,14 @@ function removeTieMatchUpParticipantId(params) {
60468
60488
  result: { error: PARTICIPANT_NOT_FOUND, context: { participantId: participantId } },
60469
60489
  });
60470
60490
  }
60471
- var _x = removeCollectionAssignments({
60491
+ var _0 = removeCollectionAssignments({
60472
60492
  collectionPosition: collectionPosition,
60473
60493
  teamParticipantId: teamParticipantId,
60474
60494
  dualMatchUpSide: dualMatchUpSide,
60475
60495
  participantIds: participantIds,
60476
60496
  drawDefinition: drawDefinition,
60477
60497
  collectionId: collectionId,
60478
- }), modifiedLineUp = _x.modifiedLineUp, previousParticipantIds = _x.previousParticipantIds;
60498
+ }), modifiedLineUp = _0.modifiedLineUp, previousParticipantIds = _0.previousParticipantIds;
60479
60499
  dualMatchUpSide.lineUp = modifiedLineUp;
60480
60500
  teamParticipantId &&
60481
60501
  tieFormat &&
@@ -60489,16 +60509,16 @@ function removeTieMatchUpParticipantId(params) {
60489
60509
  // ...then the PAIR participant may need to be modified
60490
60510
  if (matchUpType === DOUBLES$1 &&
60491
60511
  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); });
60512
+ 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
60513
  var pairParticipantId = (tieMatchUpSide || {}).participantId;
60494
60514
  var pairParticipant = pairParticipantId &&
60495
- ((_p = (_o = getParticipants$1({
60515
+ ((_s = (_r = getParticipants$1({
60496
60516
  participantFilters: { participantIds: [pairParticipantId] },
60497
60517
  tournamentRecord: tournamentRecord,
60498
60518
  withDraws: true,
60499
- })) === null || _o === void 0 ? void 0 : _o.participants) === null || _p === void 0 ? void 0 : _p[0]);
60519
+ })) === null || _r === void 0 ? void 0 : _r.participants) === null || _s === void 0 ? void 0 : _s[0]);
60500
60520
  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 : [];
60521
+ 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
60522
  if (previousParticipantIds)
60503
60523
  individualParticipantIds.push.apply(individualParticipantIds, __spreadArray([], __read(previousParticipantIds), false));
60504
60524
  if (individualParticipantIds.length > 2) {
@@ -60508,7 +60528,7 @@ function removeTieMatchUpParticipantId(params) {
60508
60528
  });
60509
60529
  }
60510
60530
  // 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)) {
60531
+ if (!((_v = pairParticipant.draws) === null || _v === void 0 ? void 0 : _v.length)) {
60512
60532
  if (individualParticipantIds.length) {
60513
60533
  pairParticipant.individualParticipantIds = individualParticipantIds;
60514
60534
  var result = modifyParticipant({
@@ -60559,13 +60579,13 @@ function removeTieMatchUpParticipantId(params) {
60559
60579
  }
60560
60580
  }
60561
60581
  // 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)) {
60582
+ if (((_w = side.substitutions) === null || _w === void 0 ? void 0 : _w.length) === 1) {
60583
+ 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; });
60584
+ 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
60585
  try {
60566
60586
  // remove processCode(s)
60567
- for (var _y = __values(substitutionProcessCodes || []), _z = _y.next(); !_z.done; _z = _y.next()) {
60568
- var substitutionProcessCode = _z.value;
60587
+ for (var _1 = __values(substitutionProcessCodes || []), _2 = _1.next(); !_2.done; _2 = _1.next()) {
60588
+ var substitutionProcessCode = _2.value;
60569
60589
  var codeIndex = tieMatchUp.processCodes.lastIndexOf(substitutionProcessCode);
60570
60590
  // remove only one instance of substitutionProcessCode
60571
60591
  tieMatchUp.processCodes.splice(codeIndex, 1);
@@ -60574,7 +60594,7 @@ function removeTieMatchUpParticipantId(params) {
60574
60594
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
60575
60595
  finally {
60576
60596
  try {
60577
- if (_z && !_z.done && (_a = _y.return)) _a.call(_y);
60597
+ if (_2 && !_2.done && (_a = _1.return)) _a.call(_1);
60578
60598
  }
60579
60599
  finally { if (e_1) throw e_1.error; }
60580
60600
  }
@@ -61028,19 +61048,27 @@ function addEventEntryPairs(_a) {
61028
61048
  }
61029
61049
 
61030
61050
  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);
61051
+ var _b;
61052
+ var _c, _d, _e, _f;
61053
+ 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;
61054
+ if ((!participants || !participantMap) && tournamentRecord) {
61055
+ (_b = getParticipants$1({
61056
+ tournamentRecord: tournamentRecord,
61057
+ }), participants = _b.participants, participantMap = _b.participantMap);
61058
+ }
61033
61059
  if (!participants)
61034
61060
  return { error: MISSING_PARTICIPANTS };
61035
61061
  if (!Array.isArray(participants))
61036
61062
  return { error: INVALID_VALUES };
61037
61063
  if (!event)
61038
61064
  return { error: MISSING_EVENT };
61065
+ 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];
61066
+ 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) !==
61067
+ false;
61039
61068
  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) {
61069
+ var isDoubles = eventType === DOUBLES_EVENT;
61070
+ var participantType = (eventType === TEAM_EVENT && TEAM) || (isDoubles && PAIR) || INDIVIDUAL;
61071
+ 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
61072
  var _a;
61045
61073
  return (_a = {},
61046
61074
  _a[entry.participantId] = entry.entryStatus,
@@ -61051,27 +61079,39 @@ function checkValidEntries(_a) {
61051
61079
  return enteredParticipantIds.includes(participant.participantId);
61052
61080
  });
61053
61081
  var invalidEntries = enteredParticipants.filter(function (participant) {
61054
- var _a;
61082
+ var _a, _b, _c, _d;
61055
61083
  var entryStatus = entryStatusMap[participant.participantId];
61056
61084
  var ungroupedParticipant = eventType &&
61057
61085
  [TypeEnum.Doubles, TypeEnum.Team].includes(eventType) &&
61058
61086
  participant.participantType === INDIVIDUAL &&
61059
61087
  (isUngrouped(entryStatus) || entryStatus === WITHDRAWN);
61060
61088
  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;
61089
+ var pairGender = !mismatch &&
61090
+ isDoubles &&
61091
+ 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 : []);
61092
+ var validPairGender = !eventGender ||
61093
+ !(pairGender === null || pairGender === void 0 ? void 0 : pairGender.length) ||
61094
+ GenderEnum.Any === eventGender ||
61095
+ ([GenderEnum.Male, GenderEnum.Female].includes(eventGender) &&
61096
+ pairGender[0] === eventGender) ||
61097
+ (GenderEnum.Mixed === eventGender &&
61098
+ ((pairGender.length == 1 &&
61099
+ ((_c = participant.individualParticipantIds) === null || _c === void 0 ? void 0 : _c.length) === 1) ||
61100
+ pairGender.length === 2));
61101
+ var personGender = (_d = participant === null || participant === void 0 ? void 0 : participant.person) === null || _d === void 0 ? void 0 : _d.sex;
61102
+ var validPersonGender = !(participant === null || participant === void 0 ? void 0 : participant.person) ||
61103
+ !eventGender ||
61104
+ [GenderEnum.Any, GenderEnum.Mixed].includes(eventGender) ||
61105
+ ([GenderEnum.Male, GenderEnum.Female].includes(eventGender) &&
61106
+ personGender === eventGender);
61107
+ var validGender = !genderEnforced || (validPairGender && validPersonGender);
61108
+ return mismatch || !validGender;
61069
61109
  });
61070
61110
  if (invalidEntries.length) {
61071
61111
  var invalidParticipantIds = invalidEntries.map(function (participant) { return participant.participantId; });
61072
61112
  return { error: INVALID_ENTRIES, invalidParticipantIds: invalidParticipantIds };
61073
61113
  }
61074
- return __assign({}, SUCCESS);
61114
+ return __assign(__assign({}, SUCCESS), { valid: true });
61075
61115
  }
61076
61116
 
61077
61117
  function assignSeedPositions(params) {
@@ -63945,10 +63985,10 @@ function generateDrawDefinition(params) {
63945
63985
  DrawTypeEnum.SingleElimination;
63946
63986
  // get participants both for entry validation and for automated placement
63947
63987
  // automated placement requires them to be "inContext" for avoidance policies to work
63948
- var participants = getParticipants$1({
63988
+ var _26 = getParticipants$1({
63949
63989
  withIndividualParticipants: true,
63950
63990
  tournamentRecord: tournamentRecord,
63951
- }).participants;
63991
+ }), participants = _26.participants, participantMap = _26.participantMap;
63952
63992
  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
63993
  // if tournamentRecord is provided, and unless instructed to ignore valid types,
63954
63994
  // check for restrictions on allowed drawTypes
@@ -63978,6 +64018,8 @@ function generateDrawDefinition(params) {
63978
64018
  participants &&
63979
64019
  checkValidEntries({
63980
64020
  consideredEntries: consideredEntries,
64021
+ appliedPolicies: appliedPolicies,
64022
+ participantMap: participantMap,
63981
64023
  enforceGender: enforceGender,
63982
64024
  participants: participants,
63983
64025
  event: event,
@@ -64116,8 +64158,8 @@ function generateDrawDefinition(params) {
64116
64158
  else {
64117
64159
  var policiesToAttach = {};
64118
64160
  try {
64119
- for (var _26 = __values(Object.keys(policyDefinitions)), _27 = _26.next(); !_27.done; _27 = _26.next()) {
64120
- var key = _27.value;
64161
+ for (var _27 = __values(Object.keys(policyDefinitions)), _28 = _27.next(); !_28.done; _28 = _27.next()) {
64162
+ var key = _28.value;
64121
64163
  if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !==
64122
64164
  JSON.stringify(policyDefinitions[key])) {
64123
64165
  policiesToAttach[key] = policyDefinitions[key];
@@ -64127,7 +64169,7 @@ function generateDrawDefinition(params) {
64127
64169
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
64128
64170
  finally {
64129
64171
  try {
64130
- if (_27 && !_27.done && (_a = _26.return)) _a.call(_26);
64172
+ if (_28 && !_28.done && (_a = _27.return)) _a.call(_27);
64131
64173
  }
64132
64174
  finally { if (e_1) throw e_1.error; }
64133
64175
  }
@@ -64179,7 +64221,7 @@ function generateDrawDefinition(params) {
64179
64221
  var source = _a.source;
64180
64222
  return source.structureId !== existingQualifyingPlaceholderStructureId;
64181
64223
  });
64182
- var _28 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _28.qualifiersCount, qualifyingDrawPositionsCount = _28.qualifyingDrawPositionsCount, qualifyingDetails = _28.qualifyingDetails;
64224
+ var _29 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _29.qualifiersCount, qualifyingDrawPositionsCount = _29.qualifyingDrawPositionsCount, qualifyingDetails = _29.qualifyingDetails;
64183
64225
  if (qualifyingDrawPositionsCount) {
64184
64226
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
64185
64227
  (_13 = drawDefinition.structures) === null || _13 === void 0 ? void 0 : _13.push.apply(_13, __spreadArray([], __read(qualifyingResult.structures), false));
@@ -64214,11 +64256,11 @@ function generateDrawDefinition(params) {
64214
64256
  if (result.error)
64215
64257
  return result;
64216
64258
  try {
64217
- for (var _29 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
64259
+ for (var _30 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
64218
64260
  var entryStage = _a.entryStage;
64219
64261
  return entryStage === StageTypeEnum.Qualifying;
64220
- })), _30 = _29.next(); !_30.done; _30 = _29.next()) {
64221
- var entry = _30.value;
64262
+ })), _31 = _30.next(); !_31.done; _31 = _30.next()) {
64263
+ var entry = _31.value;
64222
64264
  var entryData = __assign(__assign({}, entry), { entryStage: (_16 = entry.entryStage) !== null && _16 !== void 0 ? _16 : StageTypeEnum.Main, drawDefinition: drawDefinition });
64223
64265
  // ignore errors (EXITING_PARTICIPANT)
64224
64266
  addDrawEntry(entryData);
@@ -64227,13 +64269,13 @@ function generateDrawDefinition(params) {
64227
64269
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
64228
64270
  finally {
64229
64271
  try {
64230
- if (_30 && !_30.done && (_b = _29.return)) _b.call(_29);
64272
+ if (_31 && !_31.done && (_b = _30.return)) _b.call(_30);
64231
64273
  }
64232
64274
  finally { if (e_2) throw e_2.error; }
64233
64275
  }
64234
64276
  try {
64235
- for (var _31 = __values(qualifyingDetails || []), _32 = _31.next(); !_32.done; _32 = _31.next()) {
64236
- var qualifyingDetail = _32.value;
64277
+ for (var _32 = __values(qualifyingDetails || []), _33 = _32.next(); !_33.done; _33 = _32.next()) {
64278
+ var qualifyingDetail = _33.value;
64237
64279
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
64238
64280
  var link = mainStructure &&
64239
64281
  ((_17 = generateQualifyingLink({
@@ -64256,7 +64298,7 @@ function generateDrawDefinition(params) {
64256
64298
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
64257
64299
  finally {
64258
64300
  try {
64259
- if (_32 && !_32.done && (_c = _31.return)) _c.call(_31);
64301
+ if (_33 && !_33.done && (_c = _32.return)) _c.call(_32);
64260
64302
  }
64261
64303
  finally { if (e_3) throw e_3.error; }
64262
64304
  }
@@ -64354,8 +64396,8 @@ function generateDrawDefinition(params) {
64354
64396
  var roundTarget = 1;
64355
64397
  params.qualifyingProfiles.sort(roundTargetSort);
64356
64398
  try {
64357
- for (var _33 = __values(params.qualifyingProfiles), _34 = _33.next(); !_34.done; _34 = _33.next()) {
64358
- var roundTargetProfile = _34.value;
64399
+ for (var _34 = __values(params.qualifyingProfiles), _35 = _34.next(); !_35.done; _35 = _34.next()) {
64400
+ var roundTargetProfile = _35.value;
64359
64401
  if (!Array.isArray(roundTargetProfile.structureProfiles))
64360
64402
  return decorateResult({
64361
64403
  info: mustBeAnArray('structureProfiles'),
@@ -64368,7 +64410,7 @@ function generateDrawDefinition(params) {
64368
64410
  try {
64369
64411
  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
64412
  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;
64413
+ 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
64414
  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
64415
  if (qualifyingStageResult.error) {
64374
64416
  return qualifyingStageResult;
@@ -64398,7 +64440,7 @@ function generateDrawDefinition(params) {
64398
64440
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
64399
64441
  finally {
64400
64442
  try {
64401
- if (_34 && !_34.done && (_f = _33.return)) _f.call(_33);
64443
+ if (_35 && !_35.done && (_f = _34.return)) _f.call(_34);
64402
64444
  }
64403
64445
  finally { if (e_5) throw e_5.error; }
64404
64446
  }
@@ -64432,6 +64474,25 @@ function generateDrawDefinition(params) {
64432
64474
  return __assign(__assign({ existingDrawDefinition: !!existingDrawDefinition, qualifyingConflicts: qualifyingConflicts, positioningReports: positioningReports, drawDefinition: drawDefinition, structureId: structureId }, SUCCESS), { conflicts: conflicts });
64433
64475
  }
64434
64476
 
64477
+ function isValidForQualifying(_a) {
64478
+ var structureId = _a.structureId, drawDefinition = _a.drawDefinition;
64479
+ if (!drawDefinition)
64480
+ return { error: MISSING_DRAW_DEFINITION };
64481
+ if (!isString(structureId))
64482
+ return { error: INVALID_VALUES };
64483
+ var result = getStructureLinks({
64484
+ drawDefinition: drawDefinition,
64485
+ structureId: structureId,
64486
+ });
64487
+ if (result.error)
64488
+ return result;
64489
+ var targetFeedProfiles = result.links.target
64490
+ .flatMap(function (t) { return t.target.feedProfile; })
64491
+ .filter(Boolean);
64492
+ var valid = !!intersection([BOTTOM_UP, TOP_DOWN, RANDOM], targetFeedProfiles).length;
64493
+ return __assign(__assign({}, SUCCESS), { valid: valid });
64494
+ }
64495
+
64435
64496
  function renameStructures(params) {
64436
64497
  return renameStructures$1(params);
64437
64498
  }
@@ -64703,6 +64764,7 @@ var eventGovernor = {
64703
64764
  attachQualifyingStructure: attachQualifyingStructure,
64704
64765
  attachPlayoffStructures: attachPlayoffStructures,
64705
64766
  addQualifyingStructure: addQualifyingStructure,
64767
+ isValidForQualifying: isValidForQualifying,
64706
64768
  setStructureOrder: setStructureOrder,
64707
64769
  attachStructures: attachStructures,
64708
64770
  renameStructures: renameStructures,