tods-competition-factory 1.8.43 → 1.8.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2929,7 +2929,7 @@ var matchUpFormatCode = {
2929
2929
  };
2930
2930
 
2931
2931
  function factoryVersion() {
2932
- return '1.8.43';
2932
+ return '1.8.45';
2933
2933
  }
2934
2934
 
2935
2935
  function getObjectTieFormat(obj) {
@@ -2991,6 +2991,53 @@ function resolveTieFormat(_a) {
2991
2991
  };
2992
2992
  }
2993
2993
 
2994
+ function decorateResult(_a) {
2995
+ var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
2996
+ if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
2997
+ result.stack = [];
2998
+ if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
2999
+ result.stack.push(stack);
3000
+ }
3001
+ if (result && info) {
3002
+ result.info = info;
3003
+ }
3004
+ if (result && typeof context === 'object' && Object.keys(context).length) {
3005
+ Object.assign(result, definedAttributes(context));
3006
+ }
3007
+ if (result && !(result === null || result === void 0 ? void 0 : result.error) && !(result === null || result === void 0 ? void 0 : result.success)) {
3008
+ Object.assign(result, __assign({}, SUCCESS));
3009
+ }
3010
+ return result !== null && result !== void 0 ? result : { success: true };
3011
+ }
3012
+
3013
+ var ANY = 'ANY';
3014
+ var MALE = 'MALE';
3015
+ var MIXED = 'MIXED';
3016
+ var OTHER$3 = 'OTHER';
3017
+ var FEMALE = 'FEMALE';
3018
+ var genderConstants = {
3019
+ ANY: ANY,
3020
+ MALE: MALE,
3021
+ FEMALE: FEMALE,
3022
+ MIXED: MIXED,
3023
+ OTHER: OTHER$3,
3024
+ };
3025
+
3026
+ var SINGLES_MATCHUP = 'SINGLES';
3027
+ var SINGLES$1 = 'SINGLES';
3028
+ var DOUBLES_MATCHUP = 'DOUBLES';
3029
+ var DOUBLES$1 = 'DOUBLES';
3030
+ var TEAM_MATCHUP = 'TEAM';
3031
+ var TEAM$2 = 'TEAM';
3032
+ var matchUpTypes = {
3033
+ SINGLES_MATCHUP: SINGLES_MATCHUP,
3034
+ SINGLES: SINGLES$1,
3035
+ DOUBLES_MATCHUP: DOUBLES_MATCHUP,
3036
+ DOUBLES: DOUBLES$1,
3037
+ TEAM_MATCHUP: TEAM_MATCHUP,
3038
+ TEAM: TEAM$2,
3039
+ };
3040
+
2994
3041
  var DrawTypeEnum;
2995
3042
  (function (DrawTypeEnum) {
2996
3043
  DrawTypeEnum["AdHoc"] = "AD_HOC";
@@ -3551,58 +3598,38 @@ var SexEnum;
3551
3598
  SexEnum["Other"] = "OTHER";
3552
3599
  })(SexEnum || (SexEnum = {}));
3553
3600
 
3554
- function decorateResult(_a) {
3555
- var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
3556
- if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
3557
- result.stack = [];
3558
- if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
3559
- result.stack.push(stack);
3560
- }
3561
- if (result && info) {
3562
- result.info = info;
3563
- }
3564
- if (result && typeof context === 'object' && Object.keys(context).length) {
3565
- Object.assign(result, definedAttributes(context));
3566
- }
3567
- if (result && !(result === null || result === void 0 ? void 0 : result.error) && !(result === null || result === void 0 ? void 0 : result.success)) {
3568
- Object.assign(result, __assign({}, SUCCESS));
3569
- }
3570
- return result !== null && result !== void 0 ? result : { success: true };
3571
- }
3572
-
3573
- var ANY = 'ANY';
3574
- var MALE = 'MALE';
3575
- var MIXED = 'MIXED';
3576
- var OTHER$3 = 'OTHER';
3577
- var FEMALE = 'FEMALE';
3578
- var genderConstants = {
3579
- ANY: ANY,
3580
- MALE: MALE,
3581
- FEMALE: FEMALE,
3582
- MIXED: MIXED,
3583
- OTHER: OTHER$3,
3584
- };
3585
-
3586
- function genderValidityCheck(_a) {
3587
- var referenceGender = _a.referenceGender, matchUpType = _a.matchUpType, gender = _a.gender;
3588
- var stack = 'genderValidityCheck';
3601
+ var mixedGenderError = 'MIXED events can not contain mixed singles or { gender: ANY } collections';
3602
+ var anyMixedError = 'events with { gender: ANY } can not contain MIXED singles collections';
3603
+ function tieFormatGenderValidityCheck(params) {
3604
+ var _a, _b;
3605
+ var stack = 'tieFormatGenderValidityCheck';
3606
+ var referenceGender = params.referenceGender, matchUpType = params.matchUpType, gender = params.gender;
3589
3607
  if (referenceGender &&
3590
3608
  gender &&
3591
- [GenderEnum.Male, GenderEnum.Female].includes(referenceGender)) {
3592
- var valid = gender === referenceGender;
3593
- return valid
3594
- ? { valid: true }
3595
- : decorateResult({
3596
- result: { valid: false, error: INVALID_GENDER },
3597
- context: { gender: gender },
3598
- stack: stack,
3599
- });
3600
- }
3609
+ [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) &&
3610
+ referenceGender !== gender)
3611
+ return decorateResult({
3612
+ result: { valid: false, error: INVALID_GENDER },
3613
+ context: { gender: gender },
3614
+ stack: stack,
3615
+ });
3616
+ var eventType = (_a = params.eventType) !== null && _a !== void 0 ? _a : (_b = params.referenceEvent) === null || _b === void 0 ? void 0 : _b.eventType;
3601
3617
  if (referenceGender === MIXED &&
3602
- (gender !== MIXED || matchUpType === TypeEnum.Singles))
3618
+ (eventType !== TEAM$2 ||
3619
+ gender === ANY ||
3620
+ (gender === MIXED && matchUpType !== TypeEnum.Doubles))) {
3603
3621
  return decorateResult({
3604
- info: 'MIXED events can only contain MIXED doubles collections',
3605
3622
  result: { error: INVALID_GENDER, valid: false },
3623
+ info: mixedGenderError,
3624
+ stack: stack,
3625
+ });
3626
+ }
3627
+ if (referenceGender === ANY &&
3628
+ gender === MIXED &&
3629
+ matchUpType !== TypeEnum.Doubles)
3630
+ return decorateResult({
3631
+ result: { error: INVALID_GENDER, valid: false },
3632
+ info: anyMixedError,
3606
3633
  stack: stack,
3607
3634
  });
3608
3635
  return { valid: true };
@@ -3901,6 +3928,7 @@ function validateTieFormat(params) {
3901
3928
  var checkGender = !!((params === null || params === void 0 ? void 0 : params.enforceGender) !== false && (params === null || params === void 0 ? void 0 : params.gender));
3902
3929
  var checkCollectionIds = params === null || params === void 0 ? void 0 : params.checkCollectionIds;
3903
3930
  var tieFormat = params === null || params === void 0 ? void 0 : params.tieFormat;
3931
+ var event = params === null || params === void 0 ? void 0 : params.event;
3904
3932
  var stack = 'validateTieFormat';
3905
3933
  var errors = [];
3906
3934
  if (!params || !tieFormat || typeof tieFormat !== 'object') {
@@ -3935,10 +3963,12 @@ function validateTieFormat(params) {
3935
3963
  var _a = validateCollectionDefinition({
3936
3964
  referenceCategory: params.category,
3937
3965
  referenceGender: params.gender,
3966
+ eventType: params.eventType,
3938
3967
  collectionDefinition: collectionDefinition,
3939
3968
  checkCollectionIds: checkCollectionIds,
3940
3969
  checkCategory: checkCategory,
3941
3970
  checkGender: checkGender,
3971
+ event: event,
3942
3972
  }), valid = _a.valid, collectionDefinitionErrors = _a.errors;
3943
3973
  if (valid) {
3944
3974
  return true;
@@ -3983,7 +4013,7 @@ function validateTieFormat(params) {
3983
4013
  return result;
3984
4014
  }
3985
4015
  function validateCollectionDefinition(_a) {
3986
- var _b = _a.checkCategory, checkCategory = _b === void 0 ? true : _b, collectionDefinition = _a.collectionDefinition, checkCollectionIds = _a.checkCollectionIds, _c = _a.checkGender, checkGender = _c === void 0 ? true : _c, referenceCategory = _a.referenceCategory, referenceGender = _a.referenceGender, event = _a.event;
4016
+ var _b = _a.checkCategory, checkCategory = _b === void 0 ? true : _b, collectionDefinition = _a.collectionDefinition, checkCollectionIds = _a.checkCollectionIds, _c = _a.checkGender, checkGender = _c === void 0 ? true : _c, referenceCategory = _a.referenceCategory, referenceGender = _a.referenceGender, eventType = _a.eventType, event = _a.event;
3987
4017
  referenceGender = referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender;
3988
4018
  var stack = 'validateCollectionDefinition';
3989
4019
  var errors = [];
@@ -4030,7 +4060,8 @@ function validateCollectionDefinition(_a) {
4030
4060
  errors.push("Invalid matchUpFormat: ".concat(matchUpFormat));
4031
4061
  }
4032
4062
  if (checkGender) {
4033
- var result = genderValidityCheck({
4063
+ var result = tieFormatGenderValidityCheck({
4064
+ eventType: eventType !== null && eventType !== void 0 ? eventType : event === null || event === void 0 ? void 0 : event.eventType,
4034
4065
  referenceGender: referenceGender,
4035
4066
  matchUpType: matchUpType,
4036
4067
  gender: gender,
@@ -4063,14 +4094,19 @@ function validateCollectionDefinition(_a) {
4063
4094
  return { valid: true };
4064
4095
  }
4065
4096
  // add collectionIds if missing
4066
- function checkTieFormat(tieFormat) {
4067
- var e_1, _a;
4068
- var result = validateTieFormat({ tieFormat: tieFormat, checkCollectionIds: false });
4097
+ function checkTieFormat(_a) {
4098
+ var e_1, _b;
4099
+ var tieFormat = _a.tieFormat, eventType = _a.eventType;
4100
+ var result = validateTieFormat({
4101
+ checkCollectionIds: false,
4102
+ eventType: eventType,
4103
+ tieFormat: tieFormat,
4104
+ });
4069
4105
  if (result.error)
4070
4106
  return result;
4071
4107
  try {
4072
- for (var _b = __values(tieFormat.collectionDefinitions), _c = _b.next(); !_c.done; _c = _b.next()) {
4073
- var collectionDefinition = _c.value;
4108
+ for (var _c = __values(tieFormat.collectionDefinitions), _d = _c.next(); !_d.done; _d = _c.next()) {
4109
+ var collectionDefinition = _d.value;
4074
4110
  if (!collectionDefinition.collectionId)
4075
4111
  collectionDefinition.collectionId = UUID();
4076
4112
  }
@@ -4078,7 +4114,7 @@ function checkTieFormat(tieFormat) {
4078
4114
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
4079
4115
  finally {
4080
4116
  try {
4081
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
4117
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
4082
4118
  }
4083
4119
  finally { if (e_1) throw e_1.error; }
4084
4120
  }
@@ -4520,21 +4556,6 @@ function calculatePercentages(_a) {
4520
4556
  });
4521
4557
  }
4522
4558
 
4523
- var SINGLES_MATCHUP = 'SINGLES';
4524
- var SINGLES$1 = 'SINGLES';
4525
- var DOUBLES_MATCHUP = 'DOUBLES';
4526
- var DOUBLES$1 = 'DOUBLES';
4527
- var TEAM_MATCHUP = 'TEAM';
4528
- var TEAM$2 = 'TEAM';
4529
- var matchUpTypes = {
4530
- SINGLES_MATCHUP: SINGLES_MATCHUP,
4531
- SINGLES: SINGLES$1,
4532
- DOUBLES_MATCHUP: DOUBLES_MATCHUP,
4533
- DOUBLES: DOUBLES$1,
4534
- TEAM_MATCHUP: TEAM_MATCHUP,
4535
- TEAM: TEAM$2,
4536
- };
4537
-
4538
4559
  function getParticipantResults(_a) {
4539
4560
  var e_1, _b, e_2, _c, e_3, _d;
4540
4561
  var _e, _f, _g, _h, _j, _k;
@@ -10248,7 +10269,7 @@ function generateTieMatchUpScore(params) {
10248
10269
  var tieFormat = ((_c = resolveTieFormat({ matchUp: matchUp, drawDefinition: drawDefinition, structure: structure, event: event })) === null || _c === void 0 ? void 0 : _c.tieFormat) || (params === null || params === void 0 ? void 0 : params.tieFormat);
10249
10270
  if (!tieFormat)
10250
10271
  return { error: MISSING_TIE_FORMAT };
10251
- var result = validateTieFormat({ tieFormat: tieFormat });
10272
+ var result = validateTieFormat({ tieFormat: tieFormat, eventType: event === null || event === void 0 ? void 0 : event.eventType });
10252
10273
  if (result.error)
10253
10274
  return result;
10254
10275
  var collectionDefinitions = (tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) || [];
@@ -23220,12 +23241,6 @@ function getTournamentStructures(_a) {
23220
23241
  return { structures: structures, stageStructures: stageStructures };
23221
23242
  }
23222
23243
 
23223
- /**
23224
- *
23225
- * @param {object} drawDefinition - complete drawDefinition object
23226
- * @param {string} structureId - UUID of structure to be found within drawDefinition
23227
- *
23228
- */
23229
23244
  function structureActions(params) {
23230
23245
  var actions = [];
23231
23246
  if (!(params === null || params === void 0 ? void 0 : params.drawDefinition))
@@ -23234,11 +23249,6 @@ function structureActions(params) {
23234
23249
  var hasPlayoffPositionsFilled = allPlayoffPositionsFilled(params);
23235
23250
  return { actions: actions, state: { isComplete: isComplete, hasPlayoffPositionsFilled: hasPlayoffPositionsFilled } };
23236
23251
  }
23237
- /**
23238
- *
23239
- * @param {object} drawDefinition
23240
- * @param {string} structureId
23241
- */
23242
23252
  function isCompletedStructure(params) {
23243
23253
  if (!(params === null || params === void 0 ? void 0 : params.drawDefinition))
23244
23254
  return false;
@@ -23264,12 +23274,6 @@ function isCompletedStructure(params) {
23264
23274
  !(upcomingMatchUps === null || upcomingMatchUps === void 0 ? void 0 : upcomingMatchUps.length);
23265
23275
  return !!isComplete;
23266
23276
  }
23267
- /**
23268
- *
23269
- * @param {object} drawDefinition
23270
- * @param {string} structureId - either drawDefinition and structureId or structure
23271
- * @param {object} structure - optional
23272
- */
23273
23277
  function allPlayoffPositionsFilled(params) {
23274
23278
  var _a, _b;
23275
23279
  var drawDefinition = params.drawDefinition, structureId = params.structureId;
@@ -23282,7 +23286,8 @@ function allPlayoffPositionsFilled(params) {
23282
23286
  if (!(playoffStructures === null || playoffStructures === void 0 ? void 0 : playoffStructures.length))
23283
23287
  return false;
23284
23288
  var enteredParticipantsCount = ((_b = (_a = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) === null || _a === void 0 ? void 0 : _a.filter(function (entry) {
23285
- return STRUCTURE_SELECTED_STATUSES.includes(entry === null || entry === void 0 ? void 0 : entry.entryStatus);
23289
+ return (entry === null || entry === void 0 ? void 0 : entry.entryStatus) &&
23290
+ STRUCTURE_SELECTED_STATUSES.includes(entry.entryStatus);
23286
23291
  })) === null || _b === void 0 ? void 0 : _b.length) || 0;
23287
23292
  var participantIdsCount = 0;
23288
23293
  var allPositionsFilled = (playoffStructures || []).reduce(function (allFilled, structure) {
@@ -24688,16 +24693,6 @@ function getStageEntries(_a) {
24688
24693
  return { entries: entries, stageEntries: stageEntries };
24689
24694
  }
24690
24695
 
24691
- /**
24692
- *
24693
- * @param {boolean} requireParticipantCount - whether or not to consider participantsCount
24694
- * @param {boolean} drawSizeProgression - drawSizeProgression indicates that rules for all smaller drawSizes should be considered
24695
- * @param {number} participantsCount - number of participants in draw structure // TODO: migrate to participantsCount
24696
- * @param {number} drawSize - number of positions available in draw structure
24697
- * @param {object} policyDefinitions - polictyDefinition object
24698
- * @param {object} drawDefinition - optional - retrieved automatically if drawId is provided
24699
- * @param {string} drawId - allows drawDefinition and event to be retrieved by tournamentEngine from tournament record
24700
- */
24701
24696
  function getSeedsCount(params) {
24702
24697
  var _a = params || {}, _b = _a.drawSizeProgression, drawSizeProgression = _b === void 0 ? false : _b, policyDefinitions = _a.policyDefinitions, drawSize = _a.drawSize;
24703
24698
  var _c = params || {}, _d = _c.requireParticipantCount, requireParticipantCount = _d === void 0 ? true : _d, tournamentRecord = _c.tournamentRecord, drawDefinition = _c.drawDefinition, event = _c.event;
@@ -24736,9 +24731,9 @@ function getSeedsCount(params) {
24736
24731
  }
24737
24732
  }
24738
24733
  var consideredParticipantCount = (requireParticipantCount && participantsCount) || drawSize;
24739
- if (consideredParticipantCount > drawSize)
24734
+ if (consideredParticipantCount && consideredParticipantCount > drawSize)
24740
24735
  return { error: PARTICIPANT_COUNT_EXCEEDS_DRAW_SIZE };
24741
- var policy = policyDefinitions[POLICY_TYPE_SEEDING];
24736
+ var policy = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_SEEDING];
24742
24737
  if (!policy)
24743
24738
  return { error: INVALID_POLICY_DEFINITION };
24744
24739
  var seedsCountThresholds = policy.seedsCountThresholds;
@@ -24752,7 +24747,8 @@ function getSeedsCount(params) {
24752
24747
  : drawSize === threshold.drawSize;
24753
24748
  });
24754
24749
  var seedsCount = relevantThresholds.reduce(function (seedsCount, threshold) {
24755
- return participantsCount >= threshold.minimumParticipantCount
24750
+ return participantsCount &&
24751
+ participantsCount >= threshold.minimumParticipantCount
24756
24752
  ? threshold.seedsCount
24757
24753
  : seedsCount;
24758
24754
  }, 0);
@@ -36030,7 +36026,10 @@ function modifyCollectionDefinition$1(_a) {
36030
36026
  modifications.push({ collectionId: collectionId, gender: gender });
36031
36027
  }
36032
36028
  var modifiedTieFormat = definedAttributes(tieFormat);
36033
- result = validateTieFormat({ tieFormat: modifiedTieFormat });
36029
+ result = validateTieFormat({
36030
+ tieFormat: modifiedTieFormat,
36031
+ eventType: event === null || event === void 0 ? void 0 : event.eventType,
36032
+ });
36034
36033
  if (result.error) {
36035
36034
  return decorateResult({ result: result, stack: stack });
36036
36035
  }
@@ -36323,7 +36322,8 @@ function removeCollectionDefinition$1(_a) {
36323
36322
  matchUp = matchUp !== null && matchUp !== void 0 ? matchUp : result === null || result === void 0 ? void 0 : result.matchUp;
36324
36323
  var existingTieFormat = result === null || result === void 0 ? void 0 : result.tieFormat;
36325
36324
  var tieFormat = copyTieFormat(existingTieFormat);
36326
- result = validateTieFormat({ tieFormat: tieFormat });
36325
+ var eventType = event === null || event === void 0 ? void 0 : event.eventType;
36326
+ result = validateTieFormat({ tieFormat: tieFormat, eventType: eventType });
36327
36327
  if (result.error)
36328
36328
  return decorateResult({ result: result, stack: stack });
36329
36329
  var targetCollection = (_e = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) === null || _e === void 0 ? void 0 : _e.find(function (collectionDefinition) { return collectionDefinition.collectionId === collectionId; });
@@ -36514,7 +36514,7 @@ function removeCollectionDefinition$1(_a) {
36514
36514
  });
36515
36515
  }
36516
36516
  var prunedTieFormat = definedAttributes(tieFormat);
36517
- result = validateTieFormat({ tieFormat: prunedTieFormat });
36517
+ result = validateTieFormat({ tieFormat: prunedTieFormat, eventType: eventType });
36518
36518
  if (result.error)
36519
36519
  return decorateResult({ result: result, stack: stack });
36520
36520
  // TODO: implement use of tieFormats and tieFormatId
@@ -36598,7 +36598,8 @@ function addCollectionDefinition$1(_a) {
36598
36598
  matchUp = matchUp !== null && matchUp !== void 0 ? matchUp : result === null || result === void 0 ? void 0 : result.matchUp;
36599
36599
  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;
36600
36600
  var tieFormat = copyTieFormat(existingTieFormat);
36601
- result = validateTieFormat({ tieFormat: tieFormat });
36601
+ var eventType = event === null || event === void 0 ? void 0 : event.eventType;
36602
+ result = validateTieFormat({ tieFormat: tieFormat, eventType: eventType });
36602
36603
  if (result === null || result === void 0 ? void 0 : result.error) {
36603
36604
  return decorateResult({ result: { error: result.error }, stack: stack });
36604
36605
  }
@@ -36642,7 +36643,7 @@ function addCollectionDefinition$1(_a) {
36642
36643
  var addedMatchUps = [];
36643
36644
  var targetMatchUps = [];
36644
36645
  var prunedTieFormat = definedAttributes(tieFormat);
36645
- result = validateTieFormat({ tieFormat: prunedTieFormat });
36646
+ result = validateTieFormat({ tieFormat: prunedTieFormat, eventType: eventType });
36646
36647
  if (result === null || result === void 0 ? void 0 : result.error) {
36647
36648
  return decorateResult({ result: { error: result.error }, stack: stack });
36648
36649
  }
@@ -36964,7 +36965,10 @@ function collectionGroupUpdate(_a) {
36964
36965
  event: event,
36965
36966
  });
36966
36967
  var prunedTieFormat = definedAttributes(tieFormat);
36967
- var result = validateTieFormat({ tieFormat: prunedTieFormat });
36968
+ var result = validateTieFormat({
36969
+ eventType: event === null || event === void 0 ? void 0 : event.eventType,
36970
+ tieFormat: prunedTieFormat,
36971
+ });
36968
36972
  if (result.error)
36969
36973
  return result;
36970
36974
  // TODO: implement use of tieFormats and tieFormatId
@@ -37013,7 +37017,7 @@ function removeCollectionGroup$1(_a) {
37013
37017
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
37014
37018
  var wasAggregateValue = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.aggregateValue;
37015
37019
  var tieFormat = copyTieFormat(existingTieFormat);
37016
- result = validateTieFormat({ tieFormat: tieFormat });
37020
+ result = validateTieFormat({ tieFormat: tieFormat, eventType: event === null || event === void 0 ? void 0 : event.eventType });
37017
37021
  if (result.error)
37018
37022
  return decorateResult({ result: result, stack: stack });
37019
37023
  var modifiedCollectionIds = [];
@@ -37094,7 +37098,7 @@ function addCollectionGroup$1(_a) {
37094
37098
  var existingTieFormat = result === null || result === void 0 ? void 0 : result.tieFormat;
37095
37099
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
37096
37100
  var tieFormat = copyTieFormat(existingTieFormat);
37097
- result = validateTieFormat({ tieFormat: tieFormat });
37101
+ result = validateTieFormat({ tieFormat: tieFormat, eventType: event.eventType });
37098
37102
  if (result.error)
37099
37103
  return decorateResult({ result: result, stack: stack });
37100
37104
  try {
@@ -37159,7 +37163,10 @@ function modifyTieFormat$1(_a) {
37159
37163
  var e_1, _b, e_2, _c, e_3, _d;
37160
37164
  var _e = _a.updateInProgressMatchUps, updateInProgressMatchUps = _e === void 0 ? false : _e, tieFormatComparison = _a.tieFormatComparison, modifiedTieFormat = _a.modifiedTieFormat, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, structureId = _a.structureId, matchUpId = _a.matchUpId, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
37161
37165
  var stack = 'modifyTieFormat';
37162
- if (!validateTieFormat({ tieFormat: modifiedTieFormat }).valid) {
37166
+ if (!validateTieFormat({
37167
+ tieFormat: modifiedTieFormat,
37168
+ eventType: event === null || event === void 0 ? void 0 : event.eventType,
37169
+ }).valid) {
37163
37170
  return decorateResult({
37164
37171
  result: { error: INVALID_TIE_FORMAT },
37165
37172
  info: 'falied validation',
@@ -46444,8 +46451,8 @@ function setStageQualifiersCount(_a) {
46444
46451
  }
46445
46452
 
46446
46453
  function generateDrawTypeAndModifyDrawDefinition$1(params) {
46447
- var _a, _b;
46448
- var _c = params || {}, _d = _c.modifyOriginal, modifyOriginal = _d === void 0 ? true : _d, _e = _c.stageSequence, stageSequence = _e === void 0 ? 1 : _e, isMock = _c.isMock;
46454
+ var _a, _b, _c;
46455
+ var _d = params || {}, _e = _d.modifyOriginal, modifyOriginal = _e === void 0 ? true : _e, _f = _d.stageSequence, stageSequence = _f === void 0 ? 1 : _f, isMock = _d.isMock;
46449
46456
  var stack = 'generateDrawTypeAndModifyDrawDefinition';
46450
46457
  if (!params.drawDefinition)
46451
46458
  return decorateResult({
@@ -46457,11 +46464,12 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
46457
46464
  : makeDeepCopy(params.drawDefinition, false, true);
46458
46465
  var tieFormat = params.tieFormat, matchUpType = params.matchUpType;
46459
46466
  if (tieFormat) {
46460
- var result_1 = validateTieFormat({ tieFormat: tieFormat });
46467
+ var eventType = (_a = params.event) === null || _a === void 0 ? void 0 : _a.eventType;
46468
+ var result_1 = validateTieFormat({ tieFormat: tieFormat, eventType: eventType });
46461
46469
  if (result_1.error)
46462
46470
  return result_1;
46463
46471
  }
46464
- tieFormat = copyTieFormat(tieFormat || ((_a = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _a === void 0 ? void 0 : _a.tieFormat));
46472
+ tieFormat = copyTieFormat(tieFormat || ((_b = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _b === void 0 ? void 0 : _b.tieFormat));
46465
46473
  matchUpType = matchUpType || drawDefinition.matchUpType || SINGLES$1;
46466
46474
  params.tieFormat = tieFormat;
46467
46475
  params.matchUpType = matchUpType;
@@ -46515,7 +46523,7 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
46515
46523
  }
46516
46524
  var drawSize = params.drawSize || mainStageDrawPositionsCount;
46517
46525
  Object.assign(params, definedAttributes({ drawSize: drawSize, matchUpType: matchUpType, tieFormat: tieFormat }));
46518
- var _f = getAllDrawMatchUps({ drawDefinition: drawDefinition }), matchUps = _f.matchUps, matchUpsMap = _f.matchUpsMap;
46526
+ var _g = getAllDrawMatchUps({ drawDefinition: drawDefinition }), matchUps = _g.matchUps, matchUpsMap = _g.matchUpsMap;
46519
46527
  if (tieFormat) {
46520
46528
  // if there were exiting matchUps, exclude them from this step
46521
46529
  matchUps === null || matchUps === void 0 ? void 0 : matchUps.forEach(function (matchUp) {
@@ -46527,7 +46535,7 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
46527
46535
  }
46528
46536
  var inContextDrawMatchUps = addGoesTo({ drawDefinition: drawDefinition, matchUpsMap: matchUpsMap }).inContextDrawMatchUps;
46529
46537
  modifyDrawNotice({
46530
- tournamentId: (_b = params.tournamentRecord) === null || _b === void 0 ? void 0 : _b.tournamentId,
46538
+ tournamentId: (_c = params.tournamentRecord) === null || _c === void 0 ? void 0 : _c.tournamentId,
46531
46539
  drawDefinition: drawDefinition,
46532
46540
  });
46533
46541
  return __assign(__assign({ inContextDrawMatchUps: inContextDrawMatchUps, drawDefinition: drawDefinition, matchUpsMap: matchUpsMap }, SUCCESS), { structures: structures, matchUps: matchUps, links: links });
@@ -48988,8 +48996,8 @@ function addVoluntaryConsolationStage$1(_a) {
48988
48996
 
48989
48997
  function generateVoluntaryConsolation$1(params) {
48990
48998
  var _a, _b;
48991
- var _c, _d, _e, _f, _g, _h, _j;
48992
- var _k = params.drawType, drawType = _k === void 0 ? SINGLE_ELIMINATION : _k, _l = params.attachConsolation, attachConsolation = _l === void 0 ? true : _l, _m = params.applyPositioning, applyPositioning = _m === void 0 ? true : _m, tournamentRecord = params.tournamentRecord, staggeredEntry = params.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
48999
+ var _c, _d, _e, _f, _g, _h, _j, _k;
49000
+ var _l = params.drawType, drawType = _l === void 0 ? SINGLE_ELIMINATION : _l, _m = params.attachConsolation, attachConsolation = _m === void 0 ? true : _m, _o = params.applyPositioning, applyPositioning = _o === void 0 ? true : _o, tournamentRecord = params.tournamentRecord, staggeredEntry = params.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
48993
49001
  automated = params.automated, placeByes = params.placeByes, isMock = params.isMock, event = params.event;
48994
49002
  var drawDefinition = params === null || params === void 0 ? void 0 : params.drawDefinition;
48995
49003
  if (!drawDefinition)
@@ -49020,12 +49028,13 @@ function generateVoluntaryConsolation$1(params) {
49020
49028
  return { error: INVALID_DRAW_SIZE };
49021
49029
  var tieFormat = params.tieFormat, matchUpType = params.matchUpType;
49022
49030
  if (tieFormat) {
49023
- var result_1 = validateTieFormat({ tieFormat: tieFormat });
49031
+ var eventType = (_d = params.event) === null || _d === void 0 ? void 0 : _d.eventType;
49032
+ var result_1 = validateTieFormat({ tieFormat: tieFormat, eventType: eventType });
49024
49033
  if (result_1.error)
49025
49034
  return result_1;
49026
49035
  }
49027
- tieFormat = copyTieFormat(tieFormat !== null && tieFormat !== void 0 ? tieFormat : (_d = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _d === void 0 ? void 0 : _d.tieFormat);
49028
- matchUpType = (_e = matchUpType !== null && matchUpType !== void 0 ? matchUpType : drawDefinition.matchUpType) !== null && _e !== void 0 ? _e : TypeEnum.Singles;
49036
+ tieFormat = copyTieFormat(tieFormat !== null && tieFormat !== void 0 ? tieFormat : (_e = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _e === void 0 ? void 0 : _e.tieFormat);
49037
+ matchUpType = (_f = matchUpType !== null && matchUpType !== void 0 ? matchUpType : drawDefinition.matchUpType) !== null && _f !== void 0 ? _f : TypeEnum.Singles;
49029
49038
  var stageStructures = getDrawStructures({
49030
49039
  stageSequence: 1,
49031
49040
  drawDefinition: drawDefinition,
@@ -49036,11 +49045,11 @@ function generateVoluntaryConsolation$1(params) {
49036
49045
  if (structureCount > 1)
49037
49046
  return { error: STAGE_SEQUENCE_LIMIT };
49038
49047
  // invalid to already have matchUps generated for any existing structure
49039
- if ((_g = (_f = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _f === void 0 ? void 0 : _f.matchUps) === null || _g === void 0 ? void 0 : _g.length)
49048
+ if ((_h = (_g = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _g === void 0 ? void 0 : _g.matchUps) === null || _h === void 0 ? void 0 : _h.length)
49040
49049
  return { error: EXISTING_STRUCTURE };
49041
- var structureId = (_h = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _h === void 0 ? void 0 : _h.structureId;
49050
+ var structureId = (_j = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _j === void 0 ? void 0 : _j.structureId;
49042
49051
  Object.assign(params, definedAttributes({
49043
- structureName: (_j = params.structureName) !== null && _j !== void 0 ? _j : constantToString(VOLUNTARY_CONSOLATION),
49052
+ structureName: (_k = params.structureName) !== null && _k !== void 0 ? _k : constantToString(VOLUNTARY_CONSOLATION),
49044
49053
  structureId: structureId,
49045
49054
  matchUpType: matchUpType,
49046
49055
  tieFormat: tieFormat,
@@ -58227,7 +58236,7 @@ var sortingConstants = { ASC: ASC, ASCENDING: ASCENDING, DESC: DESC, DESCENDING:
58227
58236
  // by default if there are no scaleValues matching the scaleAccessor then participants will be assigned in the array order of [team].individidualParticipantIds
58228
58237
  function generateLineUps(params) {
58229
58238
  var e_1, _a, e_2, _b;
58230
- var _c, _d, _e;
58239
+ var _c, _d, _e, _f, _g, _h, _j, _k;
58231
58240
  var tieFormat = params.tieFormat;
58232
58241
  var useDefaultEventRanking = params.useDefaultEventRanking, tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, scaleAccessor = params.scaleAccessor, // e.g. { scaleType: 'RANKINGS', scaleName: 'U18', accessor: 'wtnRating', sortOrder: 'ASC' }
58233
58242
  singlesOnly = params.singlesOnly, // use singles scale for doubles events
@@ -58240,26 +58249,26 @@ function generateLineUps(params) {
58240
58249
  if (!tieFormat && !drawDefinition)
58241
58250
  return { error: DRAW_DEFINITION_NOT_FOUND };
58242
58251
  tieFormat =
58243
- tieFormat || ((_c = resolveTieFormat({ drawDefinition: drawDefinition, event: event })) === null || _c === void 0 ? void 0 : _c.tieFormat);
58244
- if (validateTieFormat({ tieFormat: tieFormat }).error)
58252
+ tieFormat !== null && tieFormat !== void 0 ? tieFormat : (_c = resolveTieFormat({ drawDefinition: drawDefinition, event: event })) === null || _c === void 0 ? void 0 : _c.tieFormat;
58253
+ if (validateTieFormat({ tieFormat: tieFormat, eventType: (_d = params.event) === null || _d === void 0 ? void 0 : _d.eventType }).error)
58245
58254
  return { error: INVALID_TIE_FORMAT };
58246
58255
  if (typeof scaleAccessor !== 'object' && !useDefaultEventRanking)
58247
58256
  return { error: INVALID_VALUES, context: { scaleAccessor: scaleAccessor } };
58248
58257
  var lineUps = {};
58249
- var targetEntries = ((drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) || event.entries).filter(function (entry) { return (entry === null || entry === void 0 ? void 0 : entry.entryStatus) === DIRECT_ACCEPTANCE; });
58258
+ var targetEntries = ((_f = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) !== null && _e !== void 0 ? _e : event === null || event === void 0 ? void 0 : event.entries) !== null && _f !== void 0 ? _f : []).filter(function (entry) { return (entry === null || entry === void 0 ? void 0 : entry.entryStatus) === DIRECT_ACCEPTANCE; });
58250
58259
  var participantIds = targetEntries.map(getParticipantId);
58251
- var _f = getParticipants$1({
58260
+ var _l = getParticipants$1({
58252
58261
  withIndividualParticipants: true,
58253
58262
  withScaleValues: true,
58254
58263
  tournamentRecord: tournamentRecord,
58255
- }).participants, participants = _f === void 0 ? [] : _f;
58264
+ }).participants, participants = _l === void 0 ? [] : _l;
58256
58265
  var teamParticipants = participants.filter(function (_a) {
58257
58266
  var participantId = _a.participantId;
58258
58267
  return participantIds.includes(participantId);
58259
58268
  });
58260
58269
  var formatScaleType = function (type) { return (type === RANKING$1 ? 'rankings' : 'ratings'); };
58261
- var defaultScaleName = ((_d = event === null || event === void 0 ? void 0 : event.category) === null || _d === void 0 ? void 0 : _d.categoryName) || ((_e = event === null || event === void 0 ? void 0 : event.category) === null || _e === void 0 ? void 0 : _e.ageCategoryCode);
58262
- var _g = scaleAccessor || {}, _h = _g.scaleName, scaleName = _h === void 0 ? defaultScaleName : _h, _j = _g.scaleType, scaleType = _j === void 0 ? RANKING$1 : _j, sortOrder = _g.sortOrder, accessor = _g.accessor;
58270
+ var defaultScaleName = (_h = (_g = event === null || event === void 0 ? void 0 : event.category) === null || _g === void 0 ? void 0 : _g.categoryName) !== null && _h !== void 0 ? _h : (_j = event === null || event === void 0 ? void 0 : event.category) === null || _j === void 0 ? void 0 : _j.ageCategoryCode;
58271
+ var _m = scaleAccessor || {}, _o = _m.scaleName, scaleName = _o === void 0 ? defaultScaleName : _o, _p = _m.scaleType, scaleType = _p === void 0 ? RANKING$1 : _p, sortOrder = _m.sortOrder, accessor = _m.accessor;
58263
58272
  var formattedScaleType = formatScaleType(scaleType);
58264
58273
  var getScaleValue = function (individualParticipant, matchUpType) {
58265
58274
  var _a, _b, _c;
@@ -58287,9 +58296,9 @@ function generateLineUps(params) {
58287
58296
  var singlesScaleSort = function (a, b) { return sortMethod(a, b, SINGLES_MATCHUP); };
58288
58297
  var doublesScaleSort = function (a, b) { return sortMethod(a, b, DOUBLES_MATCHUP); };
58289
58298
  var participantIdPairs = [];
58290
- var collectionDefinitions = tieFormat.collectionDefinitions || [];
58299
+ var collectionDefinitions = (_k = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) !== null && _k !== void 0 ? _k : [];
58291
58300
  var _loop_1 = function (teamParticipant) {
58292
- var e_3, _k;
58301
+ var e_3, _q;
58293
58302
  var singlesSort = teamParticipant.individualParticipants.sort(singlesScaleSort);
58294
58303
  var doublesSort = singlesOnly
58295
58304
  ? singlesSort
@@ -58305,8 +58314,9 @@ function generateLineUps(params) {
58305
58314
  var participantIds = [];
58306
58315
  generateRange(0, singlesMatchUp ? 1 : 2).forEach(function (i) {
58307
58316
  var nextParticipantId = typeSort.find(function (participant) {
58308
- var targetGender = ([MALE, FEMALE].includes(gender) && gender) ||
58309
- (gender === MIXED && [MALE, FEMALE][i]);
58317
+ var targetGender = gender &&
58318
+ (([MALE, FEMALE].includes(gender) && gender) ||
58319
+ (gender === MIXED && [MALE, FEMALE][i]));
58310
58320
  return ((!targetGender || targetGender === participant.person.sex) &&
58311
58321
  !collectionParticipantIds.includes(participant.participantId));
58312
58322
  }).participantId;
@@ -58335,7 +58345,7 @@ function generateLineUps(params) {
58335
58345
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
58336
58346
  finally {
58337
58347
  try {
58338
- if (collectionDefinitions_1_1 && !collectionDefinitions_1_1.done && (_k = collectionDefinitions_1.return)) _k.call(collectionDefinitions_1);
58348
+ if (collectionDefinitions_1_1 && !collectionDefinitions_1_1.done && (_q = collectionDefinitions_1.return)) _q.call(collectionDefinitions_1);
58339
58349
  }
58340
58350
  finally { if (e_3) throw e_3.error; }
58341
58351
  }
@@ -62127,7 +62137,10 @@ function addEvent(_a) {
62127
62137
  var eventRecord = __assign({ drawDefinitions: [], eventType: TypeEnum.Singles, entries: [], startDate: startDate, endDate: endDate }, event);
62128
62138
  if (event.eventType === TypeEnum.Team) {
62129
62139
  if (event.tieFormat) {
62130
- var result = validateTieFormat({ tieFormat: event.tieFormat });
62140
+ var result = validateTieFormat({
62141
+ tieFormat: event.tieFormat,
62142
+ eventType: event.eventType,
62143
+ });
62131
62144
  if (result.error)
62132
62145
  return result;
62133
62146
  }
@@ -64763,6 +64776,7 @@ function generateDrawDefinition(params) {
64763
64776
  gender: event === null || event === void 0 ? void 0 : event.gender,
64764
64777
  enforceGender: enforceGender,
64765
64778
  tieFormat: tieFormat,
64779
+ event: event,
64766
64780
  });
64767
64781
  if (result.error)
64768
64782
  return decorateResult({ result: result, stack: stack });
@@ -64790,7 +64804,10 @@ function generateDrawDefinition(params) {
64790
64804
  // there is no need to attach to the drawDefinition
64791
64805
  if (!equivalentInScope) {
64792
64806
  if (tieFormat) {
64793
- var result = checkTieFormat(tieFormat);
64807
+ var result = checkTieFormat({
64808
+ eventType: event.eventType,
64809
+ tieFormat: tieFormat,
64810
+ });
64794
64811
  if (result.error)
64795
64812
  return decorateResult({ result: result, stack: stack });
64796
64813
  drawDefinition.tieFormat = (_13 = result.tieFormat) !== null && _13 !== void 0 ? _13 : tieFormat;
@@ -65217,15 +65234,16 @@ function aggregateTieFormats(_a) {
65217
65234
  addedCount += 1;
65218
65235
  }
65219
65236
  };
65220
- checkTieFormat(event_1);
65237
+ var eventType = event_1.eventType;
65238
+ checkTieFormat({ tieFormat: event_1.tieFormat, eventType: eventType });
65221
65239
  try {
65222
65240
  for (var _p = (e_2 = void 0, __values((_e = event_1.drawDefinitions) !== null && _e !== void 0 ? _e : [])), _q = _p.next(); !_q.done; _q = _p.next()) {
65223
65241
  var drawDefinition = _q.value;
65224
- checkTieFormat(drawDefinition);
65242
+ checkTieFormat({ tieFormat: drawDefinition.tieFormat, eventType: eventType });
65225
65243
  try {
65226
65244
  for (var _r = (e_3 = void 0, __values((_f = drawDefinition.structures) !== null && _f !== void 0 ? _f : [])), _s = _r.next(); !_s.done; _s = _r.next()) {
65227
65245
  var structure = _s.value;
65228
- checkTieFormat(structure);
65246
+ checkTieFormat({ tieFormat: structure.tieFormat, eventType: eventType });
65229
65247
  }
65230
65248
  }
65231
65249
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -71431,7 +71449,7 @@ var utilities = {
71431
71449
  findExtension: findExtension$2,
71432
71450
  flattenJSON: flattenJSON,
71433
71451
  garman: garman,
71434
- genderValidityCheck: genderValidityCheck,
71452
+ tieFormatGenderValidityCheck: tieFormatGenderValidityCheck,
71435
71453
  generateHashCode: generateHashCode,
71436
71454
  generateRange: generateRange,
71437
71455
  generateScoreString: generateScoreString,