tods-competition-factory 1.8.46 → 1.9.1

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.
@@ -2351,7 +2351,33 @@ function isString(obj) {
2351
2351
  return typeof obj === 'string';
2352
2352
  }
2353
2353
  function isObject(obj) {
2354
- return typeof obj === 'object';
2354
+ return obj !== null && typeof obj === 'object';
2355
+ }
2356
+ function objShallowEqual(o1, o2) {
2357
+ var e_1, _a;
2358
+ if (!isObject(o1) || !isObject(o2))
2359
+ return false;
2360
+ var keys1 = Object.keys(o1);
2361
+ var keys2 = Object.keys(o2);
2362
+ if (keys1.length !== keys2.length) {
2363
+ return false;
2364
+ }
2365
+ try {
2366
+ for (var keys1_1 = __values(keys1), keys1_1_1 = keys1_1.next(); !keys1_1_1.done; keys1_1_1 = keys1_1.next()) {
2367
+ var key = keys1_1_1.value;
2368
+ if (o1[key] !== o2[key]) {
2369
+ return false;
2370
+ }
2371
+ }
2372
+ }
2373
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2374
+ finally {
2375
+ try {
2376
+ if (keys1_1_1 && !keys1_1_1.done && (_a = keys1_1.return)) _a.call(keys1_1);
2377
+ }
2378
+ finally { if (e_1) throw e_1.error; }
2379
+ }
2380
+ return true;
2355
2381
  }
2356
2382
  function createMap(objectArray, attribute) {
2357
2383
  if (!Array.isArray(objectArray))
@@ -2395,6 +2421,12 @@ var extractAttributes = function (accessor) { return function (element) {
2395
2421
  })) ||
2396
2422
  ((_a = (typeof accessor === 'string' && getAccessorValue({ element: element, accessor: accessor }))) === null || _a === void 0 ? void 0 : _a.value);
2397
2423
  }; };
2424
+ function getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays) {
2425
+ return Object.keys(obj).filter(function (key) {
2426
+ return !ignoreValues.includes(obj[key]) &&
2427
+ (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true));
2428
+ });
2429
+ }
2398
2430
  function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
2399
2431
  if (typeof obj !== 'object' || obj === null)
2400
2432
  return obj;
@@ -2404,10 +2436,7 @@ function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
2404
2436
  var ignoreValues = ['', undefined, null];
2405
2437
  if (ignoreFalse)
2406
2438
  ignoreValues.push(false);
2407
- var definedKeys = Object.keys(obj).filter(function (key) {
2408
- return !ignoreValues.includes(obj[key]) &&
2409
- (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true));
2410
- });
2439
+ var definedKeys = getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays);
2411
2440
  return Object.assign.apply(Object, __spreadArray([{}], __read(definedKeys.map(function (key) {
2412
2441
  var _a, _b;
2413
2442
  return Array.isArray(obj[key])
@@ -2929,7 +2958,7 @@ var matchUpFormatCode = {
2929
2958
  };
2930
2959
 
2931
2960
  function factoryVersion() {
2932
- return '1.8.46';
2961
+ return '1.9.1';
2933
2962
  }
2934
2963
 
2935
2964
  function getObjectTieFormat(obj) {
@@ -3010,34 +3039,6 @@ function decorateResult(_a) {
3010
3039
  return result !== null && result !== void 0 ? result : { success: true };
3011
3040
  }
3012
3041
 
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
-
3041
3042
  var DrawTypeEnum;
3042
3043
  (function (DrawTypeEnum) {
3043
3044
  DrawTypeEnum["AdHoc"] = "AD_HOC";
@@ -3598,10 +3599,22 @@ var SexEnum;
3598
3599
  SexEnum["Other"] = "OTHER";
3599
3600
  })(SexEnum || (SexEnum = {}));
3600
3601
 
3602
+ var ANY = 'ANY';
3603
+ var MALE = 'MALE';
3604
+ var MIXED = 'MIXED';
3605
+ var OTHER$3 = 'OTHER';
3606
+ var FEMALE = 'FEMALE';
3607
+ var genderConstants = {
3608
+ ANY: ANY,
3609
+ MALE: MALE,
3610
+ FEMALE: FEMALE,
3611
+ MIXED: MIXED,
3612
+ OTHER: OTHER$3,
3613
+ };
3614
+
3601
3615
  var mixedGenderError = 'MIXED events can not contain mixed singles or { gender: ANY } collections';
3602
3616
  var anyMixedError = 'events with { gender: ANY } can not contain MIXED singles collections';
3603
3617
  function tieFormatGenderValidityCheck(params) {
3604
- var _a, _b;
3605
3618
  var stack = 'tieFormatGenderValidityCheck';
3606
3619
  var referenceGender = params.referenceGender, matchUpType = params.matchUpType, gender = params.gender;
3607
3620
  if (referenceGender &&
@@ -3613,11 +3626,8 @@ function tieFormatGenderValidityCheck(params) {
3613
3626
  context: { gender: gender },
3614
3627
  stack: stack,
3615
3628
  });
3616
- var eventType = (_a = params.eventType) !== null && _a !== void 0 ? _a : (_b = params.referenceEvent) === null || _b === void 0 ? void 0 : _b.eventType;
3617
3629
  if (referenceGender === MIXED &&
3618
- (eventType !== TEAM$2 ||
3619
- gender === ANY ||
3620
- (gender === MIXED && matchUpType !== TypeEnum.Doubles))) {
3630
+ (gender === ANY || (gender === MIXED && matchUpType !== TypeEnum.Doubles))) {
3621
3631
  return decorateResult({
3622
3632
  result: { error: INVALID_GENDER, valid: false },
3623
3633
  info: mixedGenderError,
@@ -3963,7 +3973,6 @@ function validateTieFormat(params) {
3963
3973
  var _a = validateCollectionDefinition({
3964
3974
  referenceCategory: params.category,
3965
3975
  referenceGender: params.gender,
3966
- eventType: params.eventType,
3967
3976
  collectionDefinition: collectionDefinition,
3968
3977
  checkCollectionIds: checkCollectionIds,
3969
3978
  checkCategory: checkCategory,
@@ -4013,7 +4022,7 @@ function validateTieFormat(params) {
4013
4022
  return result;
4014
4023
  }
4015
4024
  function validateCollectionDefinition(_a) {
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;
4025
+ 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;
4017
4026
  referenceGender = referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender;
4018
4027
  var stack = 'validateCollectionDefinition';
4019
4028
  var errors = [];
@@ -4061,7 +4070,6 @@ function validateCollectionDefinition(_a) {
4061
4070
  }
4062
4071
  if (checkGender) {
4063
4072
  var result = tieFormatGenderValidityCheck({
4064
- eventType: eventType !== null && eventType !== void 0 ? eventType : event === null || event === void 0 ? void 0 : event.eventType,
4065
4073
  referenceGender: referenceGender,
4066
4074
  matchUpType: matchUpType,
4067
4075
  gender: gender,
@@ -4096,10 +4104,9 @@ function validateCollectionDefinition(_a) {
4096
4104
  // add collectionIds if missing
4097
4105
  function checkTieFormat(_a) {
4098
4106
  var e_1, _b;
4099
- var tieFormat = _a.tieFormat, eventType = _a.eventType;
4107
+ var tieFormat = _a.tieFormat;
4100
4108
  var result = validateTieFormat({
4101
4109
  checkCollectionIds: false,
4102
- eventType: eventType,
4103
4110
  tieFormat: tieFormat,
4104
4111
  });
4105
4112
  if (result.error)
@@ -4556,6 +4563,21 @@ function calculatePercentages(_a) {
4556
4563
  });
4557
4564
  }
4558
4565
 
4566
+ var SINGLES_MATCHUP = 'SINGLES';
4567
+ var SINGLES$1 = 'SINGLES';
4568
+ var DOUBLES_MATCHUP = 'DOUBLES';
4569
+ var DOUBLES$1 = 'DOUBLES';
4570
+ var TEAM_MATCHUP = 'TEAM';
4571
+ var TEAM$2 = 'TEAM';
4572
+ var matchUpTypes = {
4573
+ SINGLES_MATCHUP: SINGLES_MATCHUP,
4574
+ SINGLES: SINGLES$1,
4575
+ DOUBLES_MATCHUP: DOUBLES_MATCHUP,
4576
+ DOUBLES: DOUBLES$1,
4577
+ TEAM_MATCHUP: TEAM_MATCHUP,
4578
+ TEAM: TEAM$2,
4579
+ };
4580
+
4559
4581
  function getParticipantResults(_a) {
4560
4582
  var e_1, _b, e_2, _c, e_3, _d;
4561
4583
  var _e, _f, _g, _h, _j, _k;
@@ -5495,6 +5517,7 @@ function tallyParticipantResults(_a) {
5495
5517
  return result;
5496
5518
  }
5497
5519
 
5520
+ var ACTIVE_SUSPENSION = 'activeSuspension';
5498
5521
  var APPLIED_POLICIES = 'appliedPolicies';
5499
5522
  var AUDIT_POSITION_ACTIONS = 'positionActions';
5500
5523
  var CONTEXT = 'context';
@@ -5506,6 +5529,7 @@ var DRAW_DELETIONS = 'drawDeletions';
5506
5529
  var DRAW_PROFILE = 'drawProfile';
5507
5530
  var ENTRY_PROFILE = 'entryProfile';
5508
5531
  var EVENT_PROFILE = 'eventProfile';
5532
+ var EVENT_WITHDRAWAL_REQUESTS = 'eventWithdrawalRequests';
5509
5533
  var FACTORY$1 = 'factory';
5510
5534
  var FLIGHT_PROFILE = 'flightProfile';
5511
5535
  var GROUPING_ATTRIBUTE = 'groupingAttribute';
@@ -5524,6 +5548,7 @@ var SUB_ORDER = 'subOrder';
5524
5548
  var TALLY = 'tally';
5525
5549
  var TIE_FORMAT_MODIFICATIONS = 'tieFormatModification';
5526
5550
  var extensionConstants = {
5551
+ ACTIVE_SUSPENSION: ACTIVE_SUSPENSION,
5527
5552
  APPLIED_POLICIES: APPLIED_POLICIES,
5528
5553
  AUDIT_POSITION_ACTIONS: AUDIT_POSITION_ACTIONS,
5529
5554
  CONTEXT: CONTEXT, // used to capture, e.g. context in which a venue was added
@@ -5535,6 +5560,7 @@ var extensionConstants = {
5535
5560
  DRAW_PROFILE: DRAW_PROFILE,
5536
5561
  ENTRY_PROFILE: ENTRY_PROFILE, // used for drawGeneration; not relevant for anonymized tournaments
5537
5562
  EVENT_PROFILE: EVENT_PROFILE,
5563
+ EVENT_WITHDRAWAL_REQUESTS: EVENT_WITHDRAWAL_REQUESTS,
5538
5564
  FLIGHT_PROFILE: FLIGHT_PROFILE,
5539
5565
  GROUPING_ATTRIBUTE: GROUPING_ATTRIBUTE, // for generating teams; not relevant for anonymized tournaments
5540
5566
  LINEUPS: LINEUPS,
@@ -7301,8 +7327,8 @@ var eventConstants = {
7301
7327
 
7302
7328
  function getMatchUpScheduleDetails(_a) {
7303
7329
  var _b, _c, _d, _e, _f, e_1, _g;
7304
- var _h, _j, _k, _l, _m, _o, _p;
7305
- var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, afterRecoveryTimes = _a.afterRecoveryTimes, tournamentRecord = _a.tournamentRecord, scheduleTiming = _a.scheduleTiming, matchUpFormat = _a.matchUpFormat, matchUpType = _a.matchUpType, matchUp = _a.matchUp, event = _a.event;
7330
+ var _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
7331
+ var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, afterRecoveryTimes = _a.afterRecoveryTimes, tournamentRecord = _a.tournamentRecord, usePublishState = _a.usePublishState, scheduleTiming = _a.scheduleTiming, matchUpFormat = _a.matchUpFormat, publishStatus = _a.publishStatus, matchUpType = _a.matchUpType, matchUp = _a.matchUp, event = _a.event;
7306
7332
  if (!matchUp)
7307
7333
  return { error: MISSING_MATCHUP };
7308
7334
  // matchUpType is required to derive averageMatchUpMinutes and recoveryMinutes.
@@ -7330,11 +7356,11 @@ function getMatchUpScheduleDetails(_a) {
7330
7356
  (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpType) ||
7331
7357
  ((event === null || event === void 0 ? void 0 : event.eventType) !== TEAM$1 && (event === null || event === void 0 ? void 0 : event.eventType));
7332
7358
  }
7333
- var _q = matchUpDuration({ matchUp: matchUp }), milliseconds = _q.milliseconds, time = _q.time;
7359
+ var _v = matchUpDuration({ matchUp: matchUp }), milliseconds = _v.milliseconds, time = _v.time;
7334
7360
  var startTime = matchUpStartTime({ matchUp: matchUp }).startTime;
7335
7361
  var endTime = matchUpEndTime({ matchUp: matchUp }).endTime;
7336
7362
  var schedule;
7337
- var _r = scheduleVisibilityFilters !== null && scheduleVisibilityFilters !== void 0 ? scheduleVisibilityFilters : {}, visibilityThreshold = _r.visibilityThreshold, eventIds = _r.eventIds, drawIds = _r.drawIds;
7363
+ var _w = scheduleVisibilityFilters !== null && scheduleVisibilityFilters !== void 0 ? scheduleVisibilityFilters : {}, visibilityThreshold = _w.visibilityThreshold, eventIds = _w.eventIds, drawIds = _w.drawIds;
7338
7364
  if ((!eventIds || eventIds.includes(matchUp.eventId)) &&
7339
7365
  (!drawIds || drawIds.includes(matchUp.drawId))) {
7340
7366
  var scheduleSource = { matchUp: matchUp, visibilityThreshold: visibilityThreshold };
@@ -7391,8 +7417,8 @@ function getMatchUpScheduleDetails(_a) {
7391
7417
  allocatedCourt.courtName = courtInfo_1 === null || courtInfo_1 === void 0 ? void 0 : courtInfo_1.courtName;
7392
7418
  };
7393
7419
  try {
7394
- for (var _s = __values(allocatedCourts || []), _t = _s.next(); !_t.done; _t = _s.next()) {
7395
- var allocatedCourt = _t.value;
7420
+ for (var _x = __values(allocatedCourts || []), _y = _x.next(); !_y.done; _y = _x.next()) {
7421
+ var allocatedCourt = _y.value;
7396
7422
  var state_1 = _loop_1(allocatedCourt);
7397
7423
  if (state_1 === "break")
7398
7424
  break;
@@ -7401,7 +7427,7 @@ function getMatchUpScheduleDetails(_a) {
7401
7427
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
7402
7428
  finally {
7403
7429
  try {
7404
- if (_t && !_t.done && (_g = _s.return)) _g.call(_s);
7430
+ if (_y && !_y.done && (_g = _x.return)) _g.call(_x);
7405
7431
  }
7406
7432
  finally { if (e_1) throw e_1.error; }
7407
7433
  }
@@ -7430,16 +7456,36 @@ function getMatchUpScheduleDetails(_a) {
7430
7456
  }
7431
7457
  else {
7432
7458
  schedule = definedAttributes({
7433
- time: time,
7459
+ milliseconds: milliseconds,
7434
7460
  startTime: startTime,
7435
7461
  endTime: endTime,
7436
- milliseconds: milliseconds,
7462
+ time: time,
7437
7463
  });
7438
7464
  }
7439
- var hasCompletedStatus = matchUp.matchUpStatus &&
7440
- completedMatchUpStatuses.includes(matchUp.matchUpStatus);
7441
7465
  var scheduledDate = scheduledMatchUpDate({ matchUp: matchUp }).scheduledDate;
7442
7466
  var scheduledTime = scheduledMatchUpTime({ matchUp: matchUp }).scheduledTime;
7467
+ if (usePublishState && ((_q = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.displaySettings) === null || _q === void 0 ? void 0 : _q.draws)) {
7468
+ var drawSettings = publishStatus.displaySettings.draws;
7469
+ var scheduleDetails = (_s = ((_r = drawSettings === null || drawSettings === void 0 ? void 0 : drawSettings[matchUp.drawId]) !== null && _r !== void 0 ? _r : drawSettings === null || drawSettings === void 0 ? void 0 : drawSettings.default)) === null || _s === void 0 ? void 0 : _s.scheduleDetails;
7470
+ if (scheduleDetails) {
7471
+ var scheduleAttributes = (_u = ((_t = scheduleDetails.find(function (details) { var _a; return scheduledDate && ((_a = details.dates) === null || _a === void 0 ? void 0 : _a.includes(scheduledDate)); })) !== null && _t !== void 0 ? _t : scheduleDetails.find(function (details) { var _a; return !((_a = details.dates) === null || _a === void 0 ? void 0 : _a.length); }))) === null || _u === void 0 ? void 0 : _u.attributes;
7472
+ if (scheduleAttributes) {
7473
+ // set all attributes to true
7474
+ var template = Object.assign.apply(Object, __spreadArray(__spreadArray([{}], __read(Object.keys(schedule).map(function (key) {
7475
+ var _a;
7476
+ return (_a = {}, _a[key] = true, _a);
7477
+ })), false), [
7478
+ // overwrite with publishStatus attributes
7479
+ scheduleAttributes], false));
7480
+ schedule = attributeFilter({
7481
+ source: schedule,
7482
+ template: template,
7483
+ });
7484
+ }
7485
+ }
7486
+ }
7487
+ var hasCompletedStatus = matchUp.matchUpStatus &&
7488
+ completedMatchUpStatuses.includes(matchUp.matchUpStatus);
7443
7489
  var endDate = (hasCompletedStatus &&
7444
7490
  (extractDate(endTime) ||
7445
7491
  extractDate(scheduledDate) ||
@@ -9546,7 +9592,7 @@ function getSeeding(_a) {
9546
9592
 
9547
9593
  function getAllStructureMatchUps(_a) {
9548
9594
  var _b, _c, _d, _e, _f, _g, _h;
9549
- var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, tournamentAppliedPolicies = _a.tournamentAppliedPolicies, provisionalPositioning = _a.provisionalPositioning, tournamentParticipants = _a.tournamentParticipants, afterRecoveryTimes = _a.afterRecoveryTimes, policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, seedAssignments = _a.seedAssignments, contextFilters = _a.contextFilters, contextContent = _a.contextContent, matchUpFilters = _a.matchUpFilters, participantMap = _a.participantMap, scheduleTiming = _a.scheduleTiming, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, _j = _a.context, context = _j === void 0 ? {} : _j, exitProfiles = _a.exitProfiles, matchUpsMap = _a.matchUpsMap, structure = _a.structure, inContext = _a.inContext, event = _a.event;
9595
+ var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, tournamentAppliedPolicies = _a.tournamentAppliedPolicies, provisionalPositioning = _a.provisionalPositioning, tournamentParticipants = _a.tournamentParticipants, afterRecoveryTimes = _a.afterRecoveryTimes, policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, seedAssignments = _a.seedAssignments, usePublishState = _a.usePublishState, contextFilters = _a.contextFilters, contextContent = _a.contextContent, matchUpFilters = _a.matchUpFilters, participantMap = _a.participantMap, scheduleTiming = _a.scheduleTiming, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, publishStatus = _a.publishStatus, _j = _a.context, context = _j === void 0 ? {} : _j, exitProfiles = _a.exitProfiles, matchUpsMap = _a.matchUpsMap, structure = _a.structure, inContext = _a.inContext, event = _a.event;
9550
9596
  var collectionPositionMatchUps = {}, roundMatchUps = {};
9551
9597
  tournamentParticipants =
9552
9598
  tournamentParticipants !== null && tournamentParticipants !== void 0 ? tournamentParticipants : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
@@ -9673,6 +9719,8 @@ function getAllStructureMatchUps(_a) {
9673
9719
  roundNamingProfile: roundNamingProfile,
9674
9720
  initialRoundOfPlay: initialRoundOfPlay,
9675
9721
  appliedPolicies: appliedPolicies,
9722
+ usePublishState: usePublishState,
9723
+ publishStatus: publishStatus,
9676
9724
  isRoundRobin: isRoundRobin,
9677
9725
  roundProfile: roundProfile,
9678
9726
  matchUp: matchUp,
@@ -9728,7 +9776,7 @@ function getAllStructureMatchUps(_a) {
9728
9776
  };
9729
9777
  function addMatchUpContext(_a) {
9730
9778
  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;
9731
- var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, sourceDrawPositionRanges = _a.sourceDrawPositionRanges, drawPositionsRanges = _a.drawPositionsRanges, initialRoundOfPlay = _a.initialRoundOfPlay, additionalContext = _a.additionalContext, roundNamingProfile = _a.roundNamingProfile, tieDrawPositions = _a.tieDrawPositions, appliedPolicies = _a.appliedPolicies, isCollectionBye = _a.isCollectionBye, matchUpTieId = _a.matchUpTieId, isRoundRobin = _a.isRoundRobin, roundProfile = _a.roundProfile, sideLineUps = _a.sideLineUps, matchUp = _a.matchUp, event = _a.event;
9779
+ var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, sourceDrawPositionRanges = _a.sourceDrawPositionRanges, drawPositionsRanges = _a.drawPositionsRanges, initialRoundOfPlay = _a.initialRoundOfPlay, additionalContext = _a.additionalContext, roundNamingProfile = _a.roundNamingProfile, tieDrawPositions = _a.tieDrawPositions, appliedPolicies = _a.appliedPolicies, isCollectionBye = _a.isCollectionBye, usePublishState = _a.usePublishState, publishStatus = _a.publishStatus, matchUpTieId = _a.matchUpTieId, isRoundRobin = _a.isRoundRobin, roundProfile = _a.roundProfile, sideLineUps = _a.sideLineUps, matchUp = _a.matchUp, event = _a.event;
9732
9780
  additionalContext = additionalContext !== null && additionalContext !== void 0 ? additionalContext : {};
9733
9781
  var tieFormat = (_b = resolveTieFormat({
9734
9782
  drawDefinition: drawDefinition,
@@ -9752,8 +9800,10 @@ function getAllStructureMatchUps(_a) {
9752
9800
  scheduleVisibilityFilters: scheduleVisibilityFilters,
9753
9801
  afterRecoveryTimes: afterRecoveryTimes,
9754
9802
  tournamentRecord: tournamentRecord,
9803
+ usePublishState: usePublishState,
9755
9804
  scheduleTiming: scheduleTiming,
9756
9805
  matchUpFormat: matchUpFormat,
9806
+ publishStatus: publishStatus,
9757
9807
  matchUpType: matchUpType,
9758
9808
  matchUp: matchUp,
9759
9809
  event: event,
@@ -9899,7 +9949,7 @@ function getAllStructureMatchUps(_a) {
9899
9949
  Object.assign(matchUpWithContext, makeDeepCopy({ sides: sides }, true, true));
9900
9950
  }
9901
9951
  if (tournamentParticipants && matchUpWithContext.sides) {
9902
- var participantAttributes_1 = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_PARTICIPANT];
9952
+ var participantAttributes_1 = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_PARTICIPANT];
9903
9953
  var getMappedParticipant_1 = function (participantId) {
9904
9954
  var _a;
9905
9955
  var participant = (_a = participantMap === null || participantMap === void 0 ? void 0 : participantMap[participantId]) === null || _a === void 0 ? void 0 : _a.participant;
@@ -10017,6 +10067,8 @@ function getAllStructureMatchUps(_a) {
10017
10067
  additionalContext: additionalContext,
10018
10068
  appliedPolicies: appliedPolicies,
10019
10069
  isCollectionBye: isCollectionBye_1,
10070
+ usePublishState: usePublishState,
10071
+ publishStatus: publishStatus,
10020
10072
  matchUpTieId: matchUpTieId,
10021
10073
  isRoundRobin: isRoundRobin,
10022
10074
  roundProfile: roundProfile,
@@ -10269,7 +10321,7 @@ function generateTieMatchUpScore(params) {
10269
10321
  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);
10270
10322
  if (!tieFormat)
10271
10323
  return { error: MISSING_TIE_FORMAT };
10272
- var result = validateTieFormat({ tieFormat: tieFormat, eventType: event === null || event === void 0 ? void 0 : event.eventType });
10324
+ var result = validateTieFormat({ tieFormat: tieFormat });
10273
10325
  if (result.error)
10274
10326
  return result;
10275
10327
  var collectionDefinitions = (tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) || [];
@@ -11439,7 +11491,7 @@ function getUpcomingInfo(params) {
11439
11491
  }
11440
11492
 
11441
11493
  function getStructureMatchUps(_a) {
11442
- var _b = _a.requireParticipants, requireParticipants = _b === void 0 ? true : _b, scheduleVisibilityFilters = _a.scheduleVisibilityFilters, tournamentAppliedPolicies = _a.tournamentAppliedPolicies, tournamentParticipants = _a.tournamentParticipants, afterRecoveryTimes = _a.afterRecoveryTimes, policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, matchUpFilters = _a.matchUpFilters, contextFilters = _a.contextFilters, contextContent = _a.contextContent, participantMap = _a.participantMap, scheduleTiming = _a.scheduleTiming, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, exitProfiles = _a.exitProfiles, matchUpsMap = _a.matchUpsMap, structureId = _a.structureId, inContext = _a.inContext, structure = _a.structure, context = _a.context, event = _a.event;
11494
+ var _b = _a.requireParticipants, requireParticipants = _b === void 0 ? true : _b, scheduleVisibilityFilters = _a.scheduleVisibilityFilters, tournamentAppliedPolicies = _a.tournamentAppliedPolicies, tournamentParticipants = _a.tournamentParticipants, afterRecoveryTimes = _a.afterRecoveryTimes, policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, usePublishState = _a.usePublishState, matchUpFilters = _a.matchUpFilters, contextFilters = _a.contextFilters, contextContent = _a.contextContent, participantMap = _a.participantMap, scheduleTiming = _a.scheduleTiming, publishStatus = _a.publishStatus, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, exitProfiles = _a.exitProfiles, matchUpsMap = _a.matchUpsMap, structureId = _a.structureId, inContext = _a.inContext, structure = _a.structure, context = _a.context, event = _a.event;
11443
11495
  if (!structure && structureId) {
11444
11496
  (structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure);
11445
11497
  }
@@ -11450,13 +11502,15 @@ function getStructureMatchUps(_a) {
11450
11502
  afterRecoveryTimes: afterRecoveryTimes,
11451
11503
  policyDefinitions: policyDefinitions,
11452
11504
  tournamentRecord: tournamentRecord,
11453
- drawDefinition: drawDefinition,
11505
+ usePublishState: usePublishState,
11454
11506
  matchUpFilters: matchUpFilters,
11455
11507
  contextFilters: contextFilters,
11456
- contextProfile: contextProfile,
11457
11508
  contextContent: contextContent,
11458
11509
  participantMap: participantMap,
11459
11510
  scheduleTiming: scheduleTiming,
11511
+ publishStatus: publishStatus,
11512
+ contextProfile: contextProfile,
11513
+ drawDefinition: drawDefinition,
11460
11514
  exitProfiles: exitProfiles,
11461
11515
  matchUpsMap: matchUpsMap,
11462
11516
  structure: structure,
@@ -11545,7 +11599,7 @@ function getDrawMatchUps(params) {
11545
11599
  if (!(params === null || params === void 0 ? void 0 : params.drawDefinition))
11546
11600
  return { error: MISSING_DRAW_DEFINITION };
11547
11601
  var tournamentParticipants = params.tournamentParticipants, contextContent = params.contextContent, matchUpsMap = params.matchUpsMap;
11548
- var scheduleVisibilityFilters = params.scheduleVisibilityFilters, tournamentAppliedPolicies = params.tournamentAppliedPolicies, requireParticipants = params.requireParticipants, participantsProfile = params.participantsProfile, afterRecoveryTimes = params.afterRecoveryTimes, policyDefinitions = params.policyDefinitions, tournamentRecord = params.tournamentRecord, contextFilters = params.contextFilters, contextProfile = params.contextProfile, drawDefinition = params.drawDefinition, matchUpFilters = params.matchUpFilters, scheduleTiming = params.scheduleTiming, participantMap = params.participantMap, nextMatchUps = params.nextMatchUps, inContext = params.inContext, context = params.context, event = params.event;
11602
+ var scheduleVisibilityFilters = params.scheduleVisibilityFilters, tournamentAppliedPolicies = params.tournamentAppliedPolicies, requireParticipants = params.requireParticipants, participantsProfile = params.participantsProfile, afterRecoveryTimes = params.afterRecoveryTimes, policyDefinitions = params.policyDefinitions, tournamentRecord = params.tournamentRecord, usePublishState = params.usePublishState, contextFilters = params.contextFilters, matchUpFilters = params.matchUpFilters, scheduleTiming = params.scheduleTiming, participantMap = params.participantMap, publishStatus = params.publishStatus, contextProfile = params.contextProfile, drawDefinition = params.drawDefinition, nextMatchUps = params.nextMatchUps, inContext = params.inContext, context = params.context, event = params.event;
11549
11603
  var allAbandonedMatchUps = [];
11550
11604
  var allCompletedMatchUps = [];
11551
11605
  var allUpcomingMatchUps = [];
@@ -11595,9 +11649,11 @@ function getDrawMatchUps(params) {
11595
11649
  afterRecoveryTimes: afterRecoveryTimes,
11596
11650
  policyDefinitions: policyDefinitions,
11597
11651
  tournamentRecord: tournamentRecord,
11652
+ usePublishState: usePublishState,
11653
+ contextContent: contextContent,
11598
11654
  participantMap: participantMap,
11599
11655
  scheduleTiming: scheduleTiming,
11600
- contextContent: contextContent,
11656
+ publishStatus: publishStatus,
11601
11657
  contextProfile: contextProfile,
11602
11658
  drawDefinition: drawDefinition,
11603
11659
  exitProfiles: exitProfiles,
@@ -17257,70 +17313,6 @@ var fixtures = {
17257
17313
  flagIOC: flagIOC,
17258
17314
  };
17259
17315
 
17260
- function addNationalityCode(_a) {
17261
- var participant = _a.participant, withISO2 = _a.withISO2, withIOC = _a.withIOC;
17262
- var person = participant.person, individualParticipants = participant.individualParticipants;
17263
- var persons = [person, individualParticipants === null || individualParticipants === void 0 ? void 0 : individualParticipants.map(function (_a) {
17264
- var person = _a.person;
17265
- return person;
17266
- })]
17267
- .flat()
17268
- .filter(Boolean);
17269
- function annotatePerson(person) {
17270
- var nationalityCode = (person || {}).nationalityCode;
17271
- if (nationalityCode) {
17272
- var country = countries.find(function (_a) {
17273
- var iso = _a.iso;
17274
- return iso === nationalityCode;
17275
- });
17276
- if (withIOC && (country === null || country === void 0 ? void 0 : country.ioc) && !person.iocNationalityCode)
17277
- person.iocNationalityCode = country.ioc;
17278
- if (withISO2 && (country === null || country === void 0 ? void 0 : country.iso2) && !person.iso2NationalityCode)
17279
- person.iso2NationalityCode = country.iso2;
17280
- if ((country === null || country === void 0 ? void 0 : country.label) && !person.countryName)
17281
- person.countryName = country.label;
17282
- }
17283
- }
17284
- persons.forEach(annotatePerson);
17285
- }
17286
-
17287
- function addIndividualParticipants(_a) {
17288
- var e_1, _b, e_2, _c;
17289
- var _d;
17290
- var participantMap = _a.participantMap, template = _a.template;
17291
- var participantObjects = Object.values(participantMap);
17292
- try {
17293
- for (var participantObjects_1 = __values(participantObjects), participantObjects_1_1 = participantObjects_1.next(); !participantObjects_1_1.done; participantObjects_1_1 = participantObjects_1.next()) {
17294
- var participantObject = participantObjects_1_1.value;
17295
- var participant = participantObject.participant;
17296
- if ((_d = participant.individualParticipantIds) === null || _d === void 0 ? void 0 : _d.length) {
17297
- participant.individualParticipants = [];
17298
- try {
17299
- for (var _e = (e_2 = void 0, __values(participant.individualParticipantIds)), _f = _e.next(); !_f.done; _f = _e.next()) {
17300
- var participantId = _f.value;
17301
- var source = participantMap[participantId].participant;
17302
- participant.individualParticipants.push(template ? attributeFilter({ template: template, source: source }) : source);
17303
- }
17304
- }
17305
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
17306
- finally {
17307
- try {
17308
- if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
17309
- }
17310
- finally { if (e_2) throw e_2.error; }
17311
- }
17312
- }
17313
- }
17314
- }
17315
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
17316
- finally {
17317
- try {
17318
- if (participantObjects_1_1 && !participantObjects_1_1.done && (_b = participantObjects_1.return)) _b.call(participantObjects_1);
17319
- }
17320
- finally { if (e_1) throw e_1.error; }
17321
- }
17322
- }
17323
-
17324
17316
  function getTimeItem(_a) {
17325
17317
  var returnPreviousValues = _a.returnPreviousValues, itemSubTypes = _a.itemSubTypes, itemType = _a.itemType, element = _a.element;
17326
17318
  if (!element)
@@ -17414,6 +17406,80 @@ function getParticipantTimeItem(_a) {
17414
17406
  return (timeItem && { timeItem: timeItem, previousItems: previousItems }) || { info: info };
17415
17407
  }
17416
17408
 
17409
+ function getEventPublishStatus(_a) {
17410
+ var _b, _c, _d;
17411
+ var event = _a.event, _e = _a.status, status = _e === void 0 ? PUBLIC : _e;
17412
+ var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
17413
+ return (_d = (_c = (_b = getEventTimeItem({
17414
+ itemType: itemType,
17415
+ event: event,
17416
+ })) === null || _b === void 0 ? void 0 : _b.timeItem) === null || _c === void 0 ? void 0 : _c.itemValue) === null || _d === void 0 ? void 0 : _d[status];
17417
+ }
17418
+
17419
+ function addNationalityCode(_a) {
17420
+ var participant = _a.participant, withISO2 = _a.withISO2, withIOC = _a.withIOC;
17421
+ var person = participant.person, individualParticipants = participant.individualParticipants;
17422
+ var persons = [person, individualParticipants === null || individualParticipants === void 0 ? void 0 : individualParticipants.map(function (_a) {
17423
+ var person = _a.person;
17424
+ return person;
17425
+ })]
17426
+ .flat()
17427
+ .filter(Boolean);
17428
+ function annotatePerson(person) {
17429
+ var nationalityCode = (person || {}).nationalityCode;
17430
+ if (nationalityCode) {
17431
+ var country = countries.find(function (_a) {
17432
+ var iso = _a.iso;
17433
+ return iso === nationalityCode;
17434
+ });
17435
+ if (withIOC && (country === null || country === void 0 ? void 0 : country.ioc) && !person.iocNationalityCode)
17436
+ person.iocNationalityCode = country.ioc;
17437
+ if (withISO2 && (country === null || country === void 0 ? void 0 : country.iso2) && !person.iso2NationalityCode)
17438
+ person.iso2NationalityCode = country.iso2;
17439
+ if ((country === null || country === void 0 ? void 0 : country.label) && !person.countryName)
17440
+ person.countryName = country.label;
17441
+ }
17442
+ }
17443
+ persons.forEach(annotatePerson);
17444
+ }
17445
+
17446
+ function addIndividualParticipants(_a) {
17447
+ var e_1, _b, e_2, _c;
17448
+ var _d;
17449
+ var participantMap = _a.participantMap, template = _a.template;
17450
+ var participantObjects = Object.values(participantMap);
17451
+ try {
17452
+ for (var participantObjects_1 = __values(participantObjects), participantObjects_1_1 = participantObjects_1.next(); !participantObjects_1_1.done; participantObjects_1_1 = participantObjects_1.next()) {
17453
+ var participantObject = participantObjects_1_1.value;
17454
+ var participant = participantObject.participant;
17455
+ if ((_d = participant.individualParticipantIds) === null || _d === void 0 ? void 0 : _d.length) {
17456
+ participant.individualParticipants = [];
17457
+ try {
17458
+ for (var _e = (e_2 = void 0, __values(participant.individualParticipantIds)), _f = _e.next(); !_f.done; _f = _e.next()) {
17459
+ var participantId = _f.value;
17460
+ var source = participantMap[participantId].participant;
17461
+ participant.individualParticipants.push(template ? attributeFilter({ template: template, source: source }) : source);
17462
+ }
17463
+ }
17464
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
17465
+ finally {
17466
+ try {
17467
+ if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
17468
+ }
17469
+ finally { if (e_2) throw e_2.error; }
17470
+ }
17471
+ }
17472
+ }
17473
+ }
17474
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
17475
+ finally {
17476
+ try {
17477
+ if (participantObjects_1_1 && !participantObjects_1_1.done && (_b = participantObjects_1.return)) _b.call(participantObjects_1);
17478
+ }
17479
+ finally { if (e_1) throw e_1.error; }
17480
+ }
17481
+ }
17482
+
17417
17483
  var _a$4, _b;
17418
17484
  var typeMap = (_a$4 = {},
17419
17485
  _a$4[GROUP] = 'groupParticipantIds',
@@ -17801,7 +17867,7 @@ function tournamentMatchUps(params) {
17801
17867
  if (!(params === null || params === void 0 ? void 0 : params.tournamentRecord))
17802
17868
  return { error: MISSING_TOURNAMENT_RECORD };
17803
17869
  var contextContent = params.contextContent;
17804
- var scheduleVisibilityFilters = params.scheduleVisibilityFilters, participantsProfile = params.participantsProfile, afterRecoveryTimes = params.afterRecoveryTimes, policyDefinitions = params.policyDefinitions, useParticipantMap = params.useParticipantMap, tournamentRecord = params.tournamentRecord, _d = params.inContext, inContext = _d === void 0 ? true : _d, contextFilters = params.contextFilters, contextProfile = params.contextProfile, matchUpFilters = params.matchUpFilters, nextMatchUps = params.nextMatchUps, context = params.context;
17870
+ var scheduleVisibilityFilters = params.scheduleVisibilityFilters, participantsProfile = params.participantsProfile, afterRecoveryTimes = params.afterRecoveryTimes, policyDefinitions = params.policyDefinitions, useParticipantMap = params.useParticipantMap, tournamentRecord = params.tournamentRecord, _d = params.inContext, inContext = _d === void 0 ? true : _d, usePublishState = params.usePublishState, contextFilters = params.contextFilters, matchUpFilters = params.matchUpFilters, contextProfile = params.contextProfile, nextMatchUps = params.nextMatchUps, context = params.context;
17805
17871
  var tournamentId = (_a = params.tournamentId) !== null && _a !== void 0 ? _a : tournamentRecord.tournamentId;
17806
17872
  var events = (_b = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.events) !== null && _b !== void 0 ? _b : [];
17807
17873
  var _e = hydrateParticipants({
@@ -17836,6 +17902,7 @@ function tournamentMatchUps(params) {
17836
17902
  afterRecoveryTimes: afterRecoveryTimes,
17837
17903
  policyDefinitions: policyDefinitions,
17838
17904
  tournamentRecord: tournamentRecord,
17905
+ usePublishState: usePublishState,
17839
17906
  contextFilters: contextFilters,
17840
17907
  contextProfile: contextProfile,
17841
17908
  contextContent: contextContent,
@@ -17867,7 +17934,7 @@ function eventMatchUps(params) {
17867
17934
  var _a;
17868
17935
  var _b, _c, _d;
17869
17936
  var tournamentParticipants = params.participants, contextContent = params.contextContent, participantMap = params.participantMap;
17870
- var tournamentAppliedPolicies = params.tournamentAppliedPolicies, scheduleVisibilityFilters = params.scheduleVisibilityFilters, participantsProfile = params.participantsProfile, afterRecoveryTimes = params.afterRecoveryTimes, policyDefinitions = params.policyDefinitions, useParticipantMap = params.useParticipantMap, tournamentRecord = params.tournamentRecord, contextFilters = params.contextFilters, contextProfile = params.contextProfile, matchUpFilters = params.matchUpFilters, nextMatchUps = params.nextMatchUps, tournamentId = params.tournamentId, inContext = params.inContext, context = params.context, event = params.event;
17937
+ var tournamentAppliedPolicies = params.tournamentAppliedPolicies, scheduleVisibilityFilters = params.scheduleVisibilityFilters, participantsProfile = params.participantsProfile, afterRecoveryTimes = params.afterRecoveryTimes, policyDefinitions = params.policyDefinitions, useParticipantMap = params.useParticipantMap, tournamentRecord = params.tournamentRecord, usePublishState = params.usePublishState, contextFilters = params.contextFilters, matchUpFilters = params.matchUpFilters, contextProfile = params.contextProfile, nextMatchUps = params.nextMatchUps, tournamentId = params.tournamentId, inContext = params.inContext, context = params.context, event = params.event;
17871
17938
  if (!event)
17872
17939
  return { error: MISSING_EVENT };
17873
17940
  var eventId = event.eventId, eventName = event.eventName, endDate = event.endDate;
@@ -17897,6 +17964,7 @@ function eventMatchUps(params) {
17897
17964
  contextProfile: contextProfile,
17898
17965
  event: event,
17899
17966
  });
17967
+ var publishStatus = getEventPublishStatus({ event: event });
17900
17968
  var drawDefinitions = (_d = event.drawDefinitions) !== null && _d !== void 0 ? _d : [];
17901
17969
  var eventResult = drawDefinitions.reduce(function (results, drawDefinition) {
17902
17970
  var drawMatchUpsResult = getDrawMatchUps({
@@ -17908,12 +17976,14 @@ function eventMatchUps(params) {
17908
17976
  afterRecoveryTimes: afterRecoveryTimes,
17909
17977
  policyDefinitions: policyDefinitions,
17910
17978
  tournamentRecord: tournamentRecord,
17911
- drawDefinition: drawDefinition,
17979
+ usePublishState: usePublishState,
17912
17980
  contextContent: contextContent,
17913
17981
  contextFilters: contextFilters,
17914
- contextProfile: contextProfile,
17915
17982
  matchUpFilters: matchUpFilters,
17916
17983
  participantMap: participantMap,
17984
+ publishStatus: publishStatus,
17985
+ contextProfile: contextProfile,
17986
+ drawDefinition: drawDefinition,
17917
17987
  nextMatchUps: nextMatchUps,
17918
17988
  inContext: inContext,
17919
17989
  event: event,
@@ -17933,7 +18003,7 @@ function eventMatchUps(params) {
17933
18003
  function drawMatchUps$1(_a) {
17934
18004
  var _b;
17935
18005
  var _c, _d, _e;
17936
- var tournamentParticipants = _a.participants, tournamentAppliedPolicies = _a.tournamentAppliedPolicies, scheduleVisibilityFilters = _a.scheduleVisibilityFilters, participantsProfile = _a.participantsProfile, afterRecoveryTimes = _a.afterRecoveryTimes, policyDefinitions = _a.policyDefinitions, useParticipantMap = _a.useParticipantMap, tournamentRecord = _a.tournamentRecord, contextFilters = _a.contextFilters, contextProfile = _a.contextProfile, contextContent = _a.contextContent, drawDefinition = _a.drawDefinition, matchUpFilters = _a.matchUpFilters, participantMap = _a.participantMap, nextMatchUps = _a.nextMatchUps, tournamentId = _a.tournamentId, inContext = _a.inContext, context = _a.context, event = _a.event;
18006
+ var tournamentParticipants = _a.participants, tournamentAppliedPolicies = _a.tournamentAppliedPolicies, scheduleVisibilityFilters = _a.scheduleVisibilityFilters, participantsProfile = _a.participantsProfile, afterRecoveryTimes = _a.afterRecoveryTimes, policyDefinitions = _a.policyDefinitions, useParticipantMap = _a.useParticipantMap, tournamentRecord = _a.tournamentRecord, usePublishState = _a.usePublishState, contextFilters = _a.contextFilters, contextContent = _a.contextContent, matchUpFilters = _a.matchUpFilters, participantMap = _a.participantMap, publishStatus = _a.publishStatus, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, nextMatchUps = _a.nextMatchUps, tournamentId = _a.tournamentId, inContext = _a.inContext, context = _a.context, event = _a.event;
17937
18007
  var _f = event !== null && event !== void 0 ? event : {}, eventId = _f.eventId, eventName = _f.eventName, endDate = _f.endDate;
17938
18008
  var additionalContext = __assign(__assign({}, context), definedAttributes({
17939
18009
  eventId: eventId,
@@ -17971,12 +18041,14 @@ function drawMatchUps$1(_a) {
17971
18041
  afterRecoveryTimes: afterRecoveryTimes,
17972
18042
  policyDefinitions: policyDefinitions,
17973
18043
  tournamentRecord: tournamentRecord,
18044
+ usePublishState: usePublishState,
17974
18045
  participantMap: participantMap,
17975
- drawDefinition: drawDefinition,
17976
- matchUpFilters: matchUpFilters,
18046
+ contextContent: contextContent,
17977
18047
  contextFilters: contextFilters,
18048
+ matchUpFilters: matchUpFilters,
18049
+ publishStatus: publishStatus,
17978
18050
  contextProfile: contextProfile,
17979
- contextContent: contextContent,
18051
+ drawDefinition: drawDefinition,
17980
18052
  nextMatchUps: nextMatchUps,
17981
18053
  inContext: inContext,
17982
18054
  event: event,
@@ -18732,7 +18804,7 @@ function allCompetitionMatchUps(_a) {
18732
18804
  return { matchUps: competitionMatchUps };
18733
18805
  }
18734
18806
  function competitionMatchUps(_a) {
18735
- var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, participantsProfile = _a.participantsProfile, tournamentRecords = _a.tournamentRecords, policyDefinitions = _a.policyDefinitions, matchUpFilters = _a.matchUpFilters, contextFilters = _a.contextFilters, nextMatchUps = _a.nextMatchUps, inContext = _a.inContext;
18807
+ var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, participantsProfile = _a.participantsProfile, tournamentRecords = _a.tournamentRecords, policyDefinitions = _a.policyDefinitions, usePublishState = _a.usePublishState, matchUpFilters = _a.matchUpFilters, contextFilters = _a.contextFilters, nextMatchUps = _a.nextMatchUps, inContext = _a.inContext;
18736
18808
  if (typeof tournamentRecords !== 'object' ||
18737
18809
  !Object.keys(tournamentRecords).length)
18738
18810
  return { error: MISSING_TOURNAMENT_RECORDS };
@@ -18744,6 +18816,7 @@ function competitionMatchUps(_a) {
18744
18816
  participantsProfile: participantsProfile,
18745
18817
  policyDefinitions: policyDefinitions,
18746
18818
  tournamentRecord: tournamentRecord,
18819
+ usePublishState: usePublishState,
18747
18820
  matchUpFilters: matchUpFilters,
18748
18821
  contextFilters: contextFilters,
18749
18822
  nextMatchUps: nextMatchUps,
@@ -24826,6 +24899,14 @@ function getMatchUpDailyLimits(_a) {
24826
24899
  return { matchUpDailyLimits: dailyLimits };
24827
24900
  }
24828
24901
 
24902
+ function getDrawPublishStatus(_a) {
24903
+ var _b;
24904
+ var drawDetails = _a.drawDetails, drawId = _a.drawId;
24905
+ // TODO: check details.embargo
24906
+ var details = (_b = drawDetails === null || drawDetails === void 0 ? void 0 : drawDetails[drawId]) === null || _b === void 0 ? void 0 : _b.publishingDetail;
24907
+ return details === null || details === void 0 ? void 0 : details.published;
24908
+ }
24909
+
24829
24910
  function scheduledSortedMatchUps(_a) {
24830
24911
  var e_1, _b, e_2, _c, e_3, _d, e_4, _e;
24831
24912
  var schedulingProfile = _a.schedulingProfile, _f = _a.matchUps, matchUps = _f === void 0 ? [] : _f;
@@ -24995,26 +25076,28 @@ function courtGridRows(_a) {
24995
25076
  }
24996
25077
 
24997
25078
  function competitionScheduleMatchUps(params) {
24998
- var _a, _b, _c, _d, _e, _f, _g;
25079
+ var _a;
25080
+ var _b, _c, _d, _e, _f, _g, _h, _j;
24999
25081
  if (typeof (params === null || params === void 0 ? void 0 : params.tournamentRecords) !== 'object' ||
25000
25082
  !Object.keys(params === null || params === void 0 ? void 0 : params.tournamentRecords).length)
25001
25083
  return { error: MISSING_TOURNAMENT_RECORDS };
25002
- var _h = getVenuesAndCourts(params), courts = _h.courts, venues = _h.venues;
25084
+ var _k = getVenuesAndCourts(params), courts = _k.courts, venues = _k.venues;
25003
25085
  var getResult = getSchedulingProfile$1(params);
25004
25086
  var schedulingProfile = getResult.schedulingProfile;
25005
- var _j = params.sortDateMatchUps, sortDateMatchUps = _j === void 0 ? true : _j, courtCompletedMatchUps = params.courtCompletedMatchUps, alwaysReturnCompleted = params.alwaysReturnCompleted, activeTournamentId = params.activeTournamentId, tournamentRecords = params.tournamentRecords, withCourtGridRows = params.withCourtGridRows, minCourtGridRows = params.minCourtGridRows, usePublishState = params.usePublishState, _k = params.status, status = _k === void 0 ? PUBLIC : _k, sortCourtsData = params.sortCourtsData;
25006
- var timeItem = usePublishState
25007
- ? getTournamentTimeItem({
25087
+ var _l = params.sortDateMatchUps, sortDateMatchUps = _l === void 0 ? true : _l, courtCompletedMatchUps = params.courtCompletedMatchUps, alwaysReturnCompleted = params.alwaysReturnCompleted, activeTournamentId = params.activeTournamentId, tournamentRecords = params.tournamentRecords, withCourtGridRows = params.withCourtGridRows, minCourtGridRows = params.minCourtGridRows, usePublishState = params.usePublishState, _m = params.status, status = _m === void 0 ? PUBLIC : _m, sortCourtsData = params.sortCourtsData;
25088
+ // PUBLISH.STATUS is attached at the tournament level by `publishOrderOfPlay`
25089
+ var tournamentPublishStatus = usePublishState
25090
+ ? (_c = (_b = getTournamentTimeItem({
25008
25091
  tournamentRecord: tournamentRecords[activeTournamentId !== null && activeTournamentId !== void 0 ? activeTournamentId : getTournamentId()],
25009
25092
  itemType: "".concat(PUBLISH, ".").concat(STATUS$1),
25010
- }).timeItem
25093
+ }).timeItem) === null || _b === void 0 ? void 0 : _b.itemValue) === null || _c === void 0 ? void 0 : _c[status]
25011
25094
  : undefined;
25012
- var publishStatus = (_a = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _a === void 0 ? void 0 : _a[status];
25013
25095
  var allCompletedMatchUps = alwaysReturnCompleted
25014
25096
  ? competitionMatchUps(__assign(__assign({}, params), { matchUpFilters: __assign(__assign({}, params.matchUpFilters), { matchUpStatuses: [MatchUpStatusEnum.Completed] }), contextFilters: params.contextFilters })).completedMatchUps
25015
25097
  : [];
25098
+ // if { usePublishState: true } only return non-completed matchUps if there is orderOfPlay detail
25016
25099
  if (usePublishState &&
25017
- (!publishStatus || !Object.keys(publishStatus).length)) {
25100
+ (!tournamentPublishStatus || !Object.keys(tournamentPublishStatus).length)) {
25018
25101
  return {
25019
25102
  completedMatchUps: allCompletedMatchUps,
25020
25103
  dateMatchUps: [],
@@ -25022,57 +25105,62 @@ function competitionScheduleMatchUps(params) {
25022
25105
  venues: venues,
25023
25106
  };
25024
25107
  }
25025
- var publishedDrawIds = usePublishState
25026
- ? getCompetitionPublishedDrawIds({ tournamentRecords: tournamentRecords }).drawIds
25027
- : undefined;
25108
+ var publishedDrawIds, detailsMap;
25109
+ if (usePublishState) {
25110
+ (_a = getCompetitionPublishedDrawDetails({
25111
+ tournamentRecords: tournamentRecords,
25112
+ }), publishedDrawIds = _a.drawIds, detailsMap = _a.detailsMap);
25113
+ }
25028
25114
  if (publishedDrawIds === null || publishedDrawIds === void 0 ? void 0 : publishedDrawIds.length) {
25029
25115
  if (!params.contextFilters)
25030
25116
  params.contextFilters = {};
25031
- if (!((_b = params.contextFilters) === null || _b === void 0 ? void 0 : _b.drawIds)) {
25117
+ if (!((_d = params.contextFilters) === null || _d === void 0 ? void 0 : _d.drawIds)) {
25032
25118
  params.contextFilters.drawIds = publishedDrawIds;
25033
25119
  }
25034
25120
  else {
25035
25121
  params.contextFilters.drawIds = params.contextFilters.drawIds.filter(function (drawId) { return publishedDrawIds.includes(drawId); });
25036
25122
  }
25037
25123
  }
25038
- if ((_c = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.eventIds) === null || _c === void 0 ? void 0 : _c.length) {
25124
+ if ((_e = tournamentPublishStatus === null || tournamentPublishStatus === void 0 ? void 0 : tournamentPublishStatus.eventIds) === null || _e === void 0 ? void 0 : _e.length) {
25039
25125
  if (!params.matchUpFilters)
25040
25126
  params.matchUpFilters = {};
25041
- if ((_d = params.matchUpFilters) === null || _d === void 0 ? void 0 : _d.eventIds) {
25127
+ if ((_f = params.matchUpFilters) === null || _f === void 0 ? void 0 : _f.eventIds) {
25042
25128
  if (!params.matchUpFilters.eventIds.length) {
25043
- params.matchUpFilters.eventIds = publishStatus.eventIds;
25129
+ params.matchUpFilters.eventIds = tournamentPublishStatus.eventIds;
25044
25130
  }
25045
25131
  else {
25046
- params.matchUpFilters.eventIds = params.matchUpFilters.eventIds.filter(function (eventId) { return publishStatus.eventIds.includes(eventId); });
25132
+ params.matchUpFilters.eventIds = params.matchUpFilters.eventIds.filter(function (eventId) { return tournamentPublishStatus.eventIds.includes(eventId); });
25047
25133
  }
25048
25134
  }
25049
25135
  else {
25050
- params.matchUpFilters.eventIds = publishStatus.eventIds;
25136
+ params.matchUpFilters.eventIds = tournamentPublishStatus.eventIds;
25051
25137
  }
25052
25138
  }
25053
- if ((_e = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.scheduledDates) === null || _e === void 0 ? void 0 : _e.length) {
25139
+ if ((_g = tournamentPublishStatus === null || tournamentPublishStatus === void 0 ? void 0 : tournamentPublishStatus.scheduledDates) === null || _g === void 0 ? void 0 : _g.length) {
25054
25140
  if (!params.matchUpFilters)
25055
25141
  params.matchUpFilters = {};
25056
25142
  if (params.matchUpFilters.scheduledDates) {
25057
25143
  if (!params.matchUpFilters.scheduledDates.length) {
25058
- params.matchUpFilters.scheduledDates = publishStatus.scheduledDates;
25144
+ params.matchUpFilters.scheduledDates =
25145
+ tournamentPublishStatus.scheduledDates;
25059
25146
  }
25060
25147
  else {
25061
25148
  params.matchUpFilters.scheduledDates =
25062
25149
  params.matchUpFilters.scheduledDates.filter(function (scheduledDate) {
25063
- return publishStatus.scheduledDates.includes(scheduledDate);
25150
+ return tournamentPublishStatus.scheduledDates.includes(scheduledDate);
25064
25151
  });
25065
25152
  }
25066
25153
  }
25067
25154
  else {
25068
- params.matchUpFilters.scheduledDates = publishStatus.scheduledDates;
25155
+ params.matchUpFilters.scheduledDates =
25156
+ tournamentPublishStatus.scheduledDates;
25069
25157
  }
25070
25158
  }
25071
25159
  // optimization: if all completed matchUps have already been retrieved, skip the hydration process
25072
25160
  if (alwaysReturnCompleted) {
25073
25161
  if (!params.matchUpFilters)
25074
25162
  params.matchUpFilters = {};
25075
- if ((_g = (_f = params.matchUpFilters) === null || _f === void 0 ? void 0 : _f.excludeMatchUpStatuses) === null || _g === void 0 ? void 0 : _g.length) {
25163
+ if ((_j = (_h = params.matchUpFilters) === null || _h === void 0 ? void 0 : _h.excludeMatchUpStatuses) === null || _j === void 0 ? void 0 : _j.length) {
25076
25164
  if (!params.matchUpFilters.excludeMatchUpStatuses.includes(COMPLETED$1)) {
25077
25165
  params.matchUpFilters.excludeMatchUpStatuses.push(COMPLETED$1);
25078
25166
  }
@@ -25081,8 +25169,47 @@ function competitionScheduleMatchUps(params) {
25081
25169
  params.matchUpFilters.excludeMatchUpStatuses = [COMPLETED$1];
25082
25170
  }
25083
25171
  }
25084
- var _l = competitionMatchUps(__assign(__assign({}, params), { matchUpFilters: params.matchUpFilters, contextFilters: params.contextFilters })), completedMatchUps = _l.completedMatchUps, upcomingMatchUps = _l.upcomingMatchUps, pendingMatchUps = _l.pendingMatchUps, groupInfo = _l.groupInfo;
25172
+ var _o = competitionMatchUps(__assign(__assign({}, params), { matchUpFilters: params.matchUpFilters, contextFilters: params.contextFilters })), completedMatchUps = _o.completedMatchUps, upcomingMatchUps = _o.upcomingMatchUps, pendingMatchUps = _o.pendingMatchUps, groupInfo = _o.groupInfo;
25085
25173
  var relevantMatchUps = __spreadArray(__spreadArray([], __read((upcomingMatchUps !== null && upcomingMatchUps !== void 0 ? upcomingMatchUps : [])), false), __read((pendingMatchUps !== null && pendingMatchUps !== void 0 ? pendingMatchUps : [])), false);
25174
+ // add any stage or structure filtering
25175
+ if (detailsMap && Object.keys(detailsMap).length) {
25176
+ relevantMatchUps = relevantMatchUps.filter(function (matchUp) {
25177
+ var drawId = matchUp.drawId, structureId = matchUp.structureId, stage = matchUp.stage;
25178
+ if (!detailsMap[drawId])
25179
+ return false;
25180
+ if (detailsMap[drawId].stageDetails) {
25181
+ var stageKeys = Object.keys(detailsMap[drawId].stageDetails);
25182
+ var unpublishedStages = stageKeys.filter(function (stage) { return !detailsMap[drawId].stageDetails[stage].published; });
25183
+ var publishedStages = stageKeys.filter(function (stage) { return detailsMap[drawId].stageDetails[stage].published; });
25184
+ if (unpublishedStages.length && unpublishedStages.includes(stage))
25185
+ return false;
25186
+ if (publishedStages.length && publishedStages.includes(stage))
25187
+ return true;
25188
+ return (unpublishedStages.length &&
25189
+ !unpublishedStages.includes(stage) &&
25190
+ !publishedStages.length);
25191
+ }
25192
+ if (detailsMap[drawId].structureDetails) {
25193
+ var structureIdKeys = Object.keys(detailsMap[drawId].structureDetails);
25194
+ var unpublishedStructureIds = structureIdKeys.filter(function (structureId) {
25195
+ return !detailsMap[drawId].structureDetails[structureId].published;
25196
+ });
25197
+ var publishedStructureIds = structureIdKeys.filter(function (structureId) {
25198
+ return detailsMap[drawId].structureDetails[structureId].published;
25199
+ });
25200
+ if (unpublishedStructureIds.length &&
25201
+ unpublishedStructureIds.includes(structureId))
25202
+ return false;
25203
+ if (publishedStructureIds.length &&
25204
+ publishedStructureIds.includes(structureId))
25205
+ return true;
25206
+ return (unpublishedStructureIds.length &&
25207
+ !unpublishedStructureIds.includes(structureId) &&
25208
+ !publishedStructureIds.length);
25209
+ }
25210
+ return true;
25211
+ });
25212
+ }
25086
25213
  var dateMatchUps = sortDateMatchUps
25087
25214
  ? scheduledSortedMatchUps({ matchUps: relevantMatchUps, schedulingProfile: schedulingProfile })
25088
25215
  : relevantMatchUps;
@@ -25092,19 +25219,19 @@ function competitionScheduleMatchUps(params) {
25092
25219
  return __assign({ surfaceCategory: (_a = court === null || court === void 0 ? void 0 : court.surfaceCategory) !== null && _a !== void 0 ? _a : '', matchUps: matchUps }, court);
25093
25220
  });
25094
25221
  var result = {
25095
- courtsData: courtsData,
25096
25222
  completedMatchUps: alwaysReturnCompleted
25097
25223
  ? allCompletedMatchUps
25098
25224
  : completedMatchUps, // completed matchUps for the filter date
25099
25225
  dateMatchUps: dateMatchUps, // all incomplete matchUps for the filter date
25226
+ courtsData: courtsData,
25100
25227
  groupInfo: groupInfo,
25101
25228
  venues: venues,
25102
25229
  };
25103
25230
  if (withCourtGridRows) {
25104
- var _m = courtGridRows({
25231
+ var _p = courtGridRows({
25105
25232
  minRowsCount: minCourtGridRows,
25106
25233
  courtsData: courtsData,
25107
- }), rows = _m.rows, courtPrefix = _m.courtPrefix;
25234
+ }), rows = _p.rows, courtPrefix = _p.courtPrefix;
25108
25235
  result.courtPrefix = courtPrefix; // pass through for access to internal defaults by consumer
25109
25236
  result.rows = rows;
25110
25237
  }
@@ -25130,41 +25257,39 @@ function competitionScheduleMatchUps(params) {
25130
25257
  : courtMatchUps;
25131
25258
  }
25132
25259
  }
25133
- function getCompetitionPublishedDrawIds(_a) {
25260
+ function getCompetitionPublishedDrawDetails(_a) {
25134
25261
  var e_1, _b, e_2, _c;
25135
- var _d, _e, _f, _g;
25262
+ var _d, _e;
25136
25263
  var tournamentRecords = _a.tournamentRecords;
25137
25264
  var drawIds = [];
25265
+ var detailsMap = {};
25138
25266
  try {
25139
- for (var _h = __values(Object.values(tournamentRecords)), _j = _h.next(); !_j.done; _j = _h.next()) {
25140
- var tournamentRecord = _j.value;
25267
+ for (var _f = __values(Object.values(tournamentRecords)), _g = _f.next(); !_g.done; _g = _f.next()) {
25268
+ var tournamentRecord = _g.value;
25269
+ var _loop_1 = function (event_1) {
25270
+ var eventPubStatus = getEventPublishStatus({ event: event_1 });
25271
+ var drawDetails = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.drawDetails;
25272
+ if (isObject(drawDetails)) {
25273
+ Object.assign(detailsMap, drawDetails);
25274
+ drawIds.push.apply(drawIds, __spreadArray([], __read(Object.keys(drawDetails).filter(function (drawId) {
25275
+ return getDrawPublishStatus({ drawId: drawId, drawDetails: drawDetails });
25276
+ })), false));
25277
+ }
25278
+ else if ((_e = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.drawIds) === null || _e === void 0 ? void 0 : _e.length) {
25279
+ // LEGACY - deprecate
25280
+ drawIds.push.apply(drawIds, __spreadArray([], __read(eventPubStatus.drawIds), false));
25281
+ }
25282
+ };
25141
25283
  try {
25142
- for (var _k = (e_2 = void 0, __values((_d = tournamentRecord.events) !== null && _d !== void 0 ? _d : [])), _l = _k.next(); !_l.done; _l = _k.next()) {
25143
- var event_1 = _l.value;
25144
- var timeItem = getEventTimeItem({
25145
- itemType: "".concat(PUBLISH, ".").concat(STATUS$1),
25146
- event: event_1,
25147
- }).timeItem;
25148
- var pubState = (_e = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _e === void 0 ? void 0 : _e[PUBLIC];
25149
- if ((_f = pubState === null || pubState === void 0 ? void 0 : pubState.drawIds) === null || _f === void 0 ? void 0 : _f.length) {
25150
- drawIds.push.apply(drawIds, __spreadArray([], __read(pubState.drawIds), false));
25151
- }
25152
- else {
25153
- // if there are no drawIds specified then all draws are published
25154
- var eventDrawIds = ((_g = event_1.drawDefinitions) !== null && _g !== void 0 ? _g : [])
25155
- .map(function (_a) {
25156
- var drawId = _a.drawId;
25157
- return drawId;
25158
- })
25159
- .filter(Boolean);
25160
- drawIds.push.apply(drawIds, __spreadArray([], __read(eventDrawIds), false));
25161
- }
25284
+ for (var _h = (e_2 = void 0, __values((_d = tournamentRecord.events) !== null && _d !== void 0 ? _d : [])), _j = _h.next(); !_j.done; _j = _h.next()) {
25285
+ var event_1 = _j.value;
25286
+ _loop_1(event_1);
25162
25287
  }
25163
25288
  }
25164
25289
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
25165
25290
  finally {
25166
25291
  try {
25167
- if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
25292
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
25168
25293
  }
25169
25294
  finally { if (e_2) throw e_2.error; }
25170
25295
  }
@@ -25173,11 +25298,11 @@ function getCompetitionPublishedDrawIds(_a) {
25173
25298
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
25174
25299
  finally {
25175
25300
  try {
25176
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
25301
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
25177
25302
  }
25178
25303
  finally { if (e_1) throw e_1.error; }
25179
25304
  }
25180
- return { drawIds: drawIds };
25305
+ return { drawIds: drawIds, detailsMap: detailsMap };
25181
25306
  }
25182
25307
 
25183
25308
  var stageOrder = drawDefinitionConstants.stageOrder;
@@ -25522,23 +25647,24 @@ function getEventEntries(_a) {
25522
25647
  }
25523
25648
 
25524
25649
  function getEventPublishStatuses(_a) {
25525
- var _b;
25526
25650
  var event = _a.event;
25527
- var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
25528
- var timeItem = getTimeItem({
25529
- element: event,
25530
- itemType: itemType,
25531
- }).timeItem;
25532
- if ((_b = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _b === void 0 ? void 0 : _b.PUBLIC) {
25533
- var _c = timeItem.itemValue.PUBLIC || {}, _d = _c.drawIds, publishedDrawIds = _d === void 0 ? [] : _d, seeding = _c.seeding;
25651
+ var eventPubStatus = getEventPublishStatus({ event: event });
25652
+ if (eventPubStatus) {
25534
25653
  var publishedSeeding = {
25535
25654
  published: undefined, // seeding can be present for all entries in an event when no flights have been defined
25536
25655
  seedingScaleNames: [],
25537
25656
  drawIds: [], // seeding can be specific to drawIds
25538
25657
  };
25539
- if (seeding) {
25540
- Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
25658
+ if (eventPubStatus.seeding) {
25659
+ Object.assign(publishedSeeding, eventPubStatus.seeding);
25541
25660
  }
25661
+ var drawDetails_1 = eventPubStatus.drawDetails, drawIds = eventPubStatus.drawIds;
25662
+ var publishedDrawIds = (drawDetails_1 &&
25663
+ Object.keys(drawDetails_1).filter(function (drawId) {
25664
+ return getDrawPublishStatus({ drawDetails: drawDetails_1, drawId: drawId });
25665
+ })) ||
25666
+ drawIds ||
25667
+ [];
25542
25668
  return {
25543
25669
  publishedDrawIds: publishedDrawIds,
25544
25670
  publishedSeeding: publishedSeeding,
@@ -26561,7 +26687,7 @@ function getParticipantEntries(params) {
26561
26687
  // if there is a time overlap capture both the prior matchUpId and the conflicted matchUpId
26562
26688
  if (timeOverlap && !(bothPotential && sameDraw) && itemIsPrior) {
26563
26689
  var key = [scheduleItem.matchUpId, consideredItem.matchUpId]
26564
- .sort()
26690
+ .sort(stringSort)
26565
26691
  .join('|');
26566
26692
  participantAggregator.scheduleConflicts[key] = {
26567
26693
  priorScheduledMatchUpId: scheduleItem.matchUpId,
@@ -28170,6 +28296,12 @@ function getValidSwapAction(_a) {
28170
28296
  return {};
28171
28297
  }
28172
28298
 
28299
+ /**
28300
+ * Calculates the valid actions for a draw position based on the provided parameters.
28301
+ *
28302
+ * @param params - The parameters for calculating the position actions.
28303
+ * @returns An object containing the valid actions for the draw position.
28304
+ */
28173
28305
  function positionActions$1(params) {
28174
28306
  var _a, _b, _c, _d;
28175
28307
  var specifiedPolicyDefinitions = params.policyDefinitions, _e = params.tournamentParticipants, tournamentParticipants = _e === void 0 ? [] : _e, _f = params.returnParticipants, returnParticipants = _f === void 0 ? true : _f, provisionalPositioning = params.provisionalPositioning, tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, drawPosition = params.drawPosition, event = params.event;
@@ -28278,12 +28410,12 @@ function positionActions$1(params) {
28278
28410
  var isActiveDrawPosition = activeDrawPositions.includes(drawPosition);
28279
28411
  if (actionsDisabled)
28280
28412
  return {
28413
+ hasPositionAssigned: !!positionAssignment,
28281
28414
  info: 'Actions Disabled for structure',
28282
- isByePosition: isByePosition,
28283
28415
  isActiveDrawPosition: isActiveDrawPosition,
28284
28416
  isDrawPosition: true,
28285
- hasPositionAssigned: !!positionAssignment,
28286
28417
  validActions: [],
28418
+ isByePosition: isByePosition,
28287
28419
  };
28288
28420
  if (isAvailableAction({ policyActions: policyActions, action: ASSIGN_PARTICIPANT }) &&
28289
28421
  !isActiveDrawPosition &&
@@ -28721,7 +28853,7 @@ function getStructureGroups(_a) {
28721
28853
  }
28722
28854
 
28723
28855
  function getDrawData(params) {
28724
- var _a = params.tournamentParticipants, tournamentParticipants = _a === void 0 ? [] : _a, includePositionAssignments = params.includePositionAssignments, policyDefinitions = params.policyDefinitions, tournamentRecord = params.tournamentRecord, _b = params.inContext, inContext = _b === void 0 ? true : _b, drawDefinition = params.drawDefinition, noDeepCopy = params.noDeepCopy, sortConfig = params.sortConfig, context = params.context, event = params.event;
28856
+ var _a = params.tournamentParticipants, tournamentParticipants = _a === void 0 ? [] : _a, includePositionAssignments = params.includePositionAssignments, policyDefinitions = params.policyDefinitions, tournamentRecord = params.tournamentRecord, _b = params.inContext, inContext = _b === void 0 ? true : _b, usePublishState = params.usePublishState, drawDefinition = params.drawDefinition, publishStatus = params.publishStatus, noDeepCopy = params.noDeepCopy, sortConfig = params.sortConfig, context = params.context, event = params.event;
28725
28857
  if (!drawDefinition)
28726
28858
  return { error: MISSING_DRAW_DEFINITION };
28727
28859
  var drawInfo = (function (_a) {
@@ -28789,6 +28921,8 @@ function getDrawData(params) {
28789
28921
  tournamentParticipants: tournamentParticipants,
28790
28922
  policyDefinitions: policyDefinitions,
28791
28923
  tournamentRecord: tournamentRecord,
28924
+ usePublishState: usePublishState,
28925
+ publishStatus: publishStatus,
28792
28926
  drawDefinition: drawDefinition,
28793
28927
  inContext: inContext,
28794
28928
  structure: structure,
@@ -28872,8 +29006,7 @@ function getDrawData(params) {
28872
29006
  }
28873
29007
 
28874
29008
  function getEventData(params) {
28875
- var _a;
28876
- var includePositionAssignments = params.includePositionAssignments, t = params.tournamentRecord, participantsProfile = params.participantsProfile, policyDefinitions = params.policyDefinitions, usePublishState = params.usePublishState, _b = params.status, status = _b === void 0 ? PUBLIC : _b, sortConfig = params.sortConfig, e = params.event;
29009
+ var includePositionAssignments = params.includePositionAssignments, t = params.tournamentRecord, participantsProfile = params.participantsProfile, policyDefinitions = params.policyDefinitions, usePublishState = params.usePublishState, _a = params.status, status = _a === void 0 ? PUBLIC : _a, sortConfig = params.sortConfig, e = params.event;
28877
29010
  var tournamentRecord = makeDeepCopy(t, false, true);
28878
29011
  var event = makeDeepCopy(e, false, true);
28879
29012
  if (!tournamentRecord)
@@ -28882,33 +29015,73 @@ function getEventData(params) {
28882
29015
  return { error: MISSING_EVENT };
28883
29016
  var eventId = event.eventId;
28884
29017
  var tournamentId = tournamentRecord.tournamentId, endDate = tournamentRecord.endDate;
28885
- var timeItem = getEventTimeItem({
28886
- itemType: "".concat(PUBLISH, ".").concat(STATUS$1),
28887
- event: event,
28888
- }).timeItem;
28889
- var publishStatus = (_a = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _a === void 0 ? void 0 : _a[status];
29018
+ var publishStatus = getEventPublishStatus({ event: event, status: status });
28890
29019
  var tournamentParticipants = getParticipants$1(__assign(__assign({ withGroupings: true, withEvents: false, withDraws: false }, participantsProfile), { // order is important!!
28891
29020
  tournamentRecord: tournamentRecord })).participants;
28892
29021
  var stageFilter = function (_a) {
28893
- var _b;
28894
- var stage = _a.stage;
28895
- return !usePublishState ||
28896
- !((_b = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.stages) === null || _b === void 0 ? void 0 : _b.length) ||
28897
- publishStatus.stages.includes(stage);
29022
+ var _b, _c, _d;
29023
+ var stage = _a.stage, drawId = _a.drawId;
29024
+ if (!usePublishState)
29025
+ return true;
29026
+ var stageDetails = (_c = (_b = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.drawDetails) === null || _b === void 0 ? void 0 : _b[drawId]) === null || _c === void 0 ? void 0 : _c.stageDetails;
29027
+ if (!stageDetails || !Object.keys(stageDetails).length)
29028
+ return true;
29029
+ return (_d = stageDetails[stage]) === null || _d === void 0 ? void 0 : _d.published;
28898
29030
  };
28899
29031
  var structureFilter = function (_a) {
28900
- var _b;
28901
- var structureId = _a.structureId;
28902
- return !usePublishState ||
28903
- !((_b = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.structureIds) === null || _b === void 0 ? void 0 : _b.length) ||
28904
- publishStatus.structureIds.includes(structureId);
29032
+ var _b, _c, _d;
29033
+ var structureId = _a.structureId, drawId = _a.drawId;
29034
+ if (!usePublishState)
29035
+ return true;
29036
+ var structureDetails = (_c = (_b = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.drawDetails) === null || _b === void 0 ? void 0 : _b[drawId]) === null || _c === void 0 ? void 0 : _c.structureDetails;
29037
+ if (!structureDetails || !Object.keys(structureDetails).length)
29038
+ return true;
29039
+ return (_d = structureDetails[structureId]) === null || _d === void 0 ? void 0 : _d.published;
28905
29040
  };
28906
29041
  var drawFilter = function (_a) {
28907
- var _b;
29042
+ var _b, _c;
28908
29043
  var drawId = _a.drawId;
28909
- return !usePublishState ||
28910
- !((_b = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.drawIds) === null || _b === void 0 ? void 0 : _b.length) ||
28911
- publishStatus.drawIds.includes(drawId);
29044
+ if (!usePublishState)
29045
+ return true;
29046
+ if (publishStatus.drawDetails) {
29047
+ return (_c = (_b = publishStatus.drawDetails[drawId]) === null || _b === void 0 ? void 0 : _b.publishingDetail) === null || _c === void 0 ? void 0 : _c.published;
29048
+ }
29049
+ else if (publishStatus.drawIds) {
29050
+ return publishStatus.drawIds.includes(drawId);
29051
+ }
29052
+ return true;
29053
+ };
29054
+ var roundLimitMapper = function (_a) {
29055
+ var e_1, _b;
29056
+ var _c, _d, _e, _f;
29057
+ var drawId = _a.drawId, structure = _a.structure;
29058
+ if (!usePublishState)
29059
+ return structure;
29060
+ var roundLimit = (_f = (_e = (_d = (_c = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.drawDetails) === null || _c === void 0 ? void 0 : _c[drawId]) === null || _d === void 0 ? void 0 : _d.structureDetails) === null || _e === void 0 ? void 0 : _e[structure.structureId]) === null || _f === void 0 ? void 0 : _f.roundLimit;
29061
+ if (isConvertableInteger(roundLimit)) {
29062
+ var roundNumbers = generateRange(1, roundLimit + 1);
29063
+ var roundMatchUps = {};
29064
+ var roundProfile = {};
29065
+ try {
29066
+ for (var roundNumbers_1 = __values(roundNumbers), roundNumbers_1_1 = roundNumbers_1.next(); !roundNumbers_1_1.done; roundNumbers_1_1 = roundNumbers_1.next()) {
29067
+ var roundNumber = roundNumbers_1_1.value;
29068
+ if (structure.roundMatchUps[roundNumber]) {
29069
+ roundMatchUps[roundNumber] = structure.roundMatchUps[roundNumber];
29070
+ roundProfile[roundNumber] = structure.roundProfile[roundNumber];
29071
+ }
29072
+ }
29073
+ }
29074
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
29075
+ finally {
29076
+ try {
29077
+ if (roundNumbers_1_1 && !roundNumbers_1_1.done && (_b = roundNumbers_1.return)) _b.call(roundNumbers_1);
29078
+ }
29079
+ finally { if (e_1) throw e_1.error; }
29080
+ }
29081
+ structure.roundMatchUps = roundMatchUps;
29082
+ structure.roundProfile = roundProfile;
29083
+ }
29084
+ return structure;
28912
29085
  };
28913
29086
  var drawDefinitions = event.drawDefinitions || [];
28914
29087
  var drawsData = drawDefinitions
@@ -28924,15 +29097,23 @@ function getEventData(params) {
28924
29097
  noDeepCopy: true,
28925
29098
  policyDefinitions: policyDefinitions,
28926
29099
  tournamentRecord: tournamentRecord,
29100
+ usePublishState: usePublishState,
28927
29101
  drawDefinition: drawDefinition,
29102
+ publishStatus: publishStatus,
28928
29103
  sortConfig: sortConfig,
28929
29104
  event: event,
28930
29105
  }));
28931
29106
  })
28932
29107
  .map(function (_a) {
28933
- var _b;
28934
29108
  var structures = _a.structures, drawData = __rest(_a, ["structures"]);
28935
- return (__assign(__assign({}, drawData), { structures: (_b = structures === null || structures === void 0 ? void 0 : structures.filter(structureFilter)) === null || _b === void 0 ? void 0 : _b.filter(stageFilter) }));
29109
+ var filteredStructures = structures === null || structures === void 0 ? void 0 : structures.filter(function (_a) {
29110
+ var stage = _a.stage, structureId = _a.structureId;
29111
+ return structureFilter({ structureId: structureId, drawId: drawData.drawId }) &&
29112
+ stageFilter({ stage: stage, drawId: drawData.drawId });
29113
+ }).map(function (structure) {
29114
+ return roundLimitMapper({ drawId: drawData.drawId, structure: structure });
29115
+ });
29116
+ return __assign(__assign({}, drawData), { structures: filteredStructures });
28936
29117
  })
28937
29118
  .filter(function (drawData) { var _a; return (_a = drawData.structures) === null || _a === void 0 ? void 0 : _a.length; });
28938
29119
  var tournamentInfo = getTournamentInfo({ tournamentRecord: tournamentRecord }).tournamentInfo;
@@ -28969,10 +29150,7 @@ function getEventData(params) {
28969
29150
  eventInfo: eventInfo,
28970
29151
  drawsData: drawsData,
28971
29152
  };
28972
- eventData.eventInfo.publish = {
28973
- createdAt: timeItem === null || timeItem === void 0 ? void 0 : timeItem.createdAt,
28974
- state: timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue,
28975
- };
29153
+ eventData.eventInfo.publish = publishStatus;
28976
29154
  return __assign(__assign({}, SUCCESS), { eventData: eventData });
28977
29155
  }
28978
29156
 
@@ -31929,22 +32107,18 @@ function conditionallyAdvanceDrawPosition(params) {
31929
32107
  sourceSideNumber = 2;
31930
32108
  }
31931
32109
  }
31932
- else {
31933
- if (targetMatchUp.feedRound) {
31934
- // if different structureIds then structureId that is not equivalent to noContextTargetMatchUp.structureId is fed
31935
- // ... and fed positions are always sideNumber 1
31936
- if (sourceMatchUp.structureId === targetMatchUp.structureId) {
31937
- sourceSideNumber = 2;
31938
- }
31939
- else {
31940
- sourceSideNumber = 1;
31941
- }
32110
+ else if (targetMatchUp.feedRound) {
32111
+ // if different structureIds then structureId that is not equivalent to noContextTargetMatchUp.structureId is fed
32112
+ // ... and fed positions are always sideNumber 1
32113
+ if (sourceMatchUp.structureId === targetMatchUp.structureId) {
32114
+ sourceSideNumber = 2;
31942
32115
  }
31943
32116
  else {
31944
- if (walkoverWinningSide)
31945
- sourceSideNumber = 3 - walkoverWinningSide;
32117
+ sourceSideNumber = 1;
31946
32118
  }
31947
32119
  }
32120
+ else if (walkoverWinningSide)
32121
+ sourceSideNumber = 3 - walkoverWinningSide;
31948
32122
  }
31949
32123
  var sourceMatchUpStatus = params.matchUpStatus;
31950
32124
  var pairedMatchUpStatus = pairedPreviousMatchUp === null || pairedPreviousMatchUp === void 0 ? void 0 : pairedPreviousMatchUp.matchUpStatus;
@@ -36050,10 +36224,7 @@ function modifyCollectionDefinition$1(_a) {
36050
36224
  modifications.push({ collectionId: collectionId, gender: gender });
36051
36225
  }
36052
36226
  var modifiedTieFormat = definedAttributes(tieFormat);
36053
- result = validateTieFormat({
36054
- tieFormat: modifiedTieFormat,
36055
- eventType: event === null || event === void 0 ? void 0 : event.eventType,
36056
- });
36227
+ result = validateTieFormat({ tieFormat: modifiedTieFormat });
36057
36228
  if (result.error) {
36058
36229
  return decorateResult({ result: result, stack: stack });
36059
36230
  }
@@ -36346,8 +36517,7 @@ function removeCollectionDefinition$1(_a) {
36346
36517
  matchUp = matchUp !== null && matchUp !== void 0 ? matchUp : result === null || result === void 0 ? void 0 : result.matchUp;
36347
36518
  var existingTieFormat = result === null || result === void 0 ? void 0 : result.tieFormat;
36348
36519
  var tieFormat = copyTieFormat(existingTieFormat);
36349
- var eventType = event === null || event === void 0 ? void 0 : event.eventType;
36350
- result = validateTieFormat({ tieFormat: tieFormat, eventType: eventType });
36520
+ result = validateTieFormat({ tieFormat: tieFormat });
36351
36521
  if (result.error)
36352
36522
  return decorateResult({ result: result, stack: stack });
36353
36523
  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; });
@@ -36538,7 +36708,7 @@ function removeCollectionDefinition$1(_a) {
36538
36708
  });
36539
36709
  }
36540
36710
  var prunedTieFormat = definedAttributes(tieFormat);
36541
- result = validateTieFormat({ tieFormat: prunedTieFormat, eventType: eventType });
36711
+ result = validateTieFormat({ tieFormat: prunedTieFormat });
36542
36712
  if (result.error)
36543
36713
  return decorateResult({ result: result, stack: stack });
36544
36714
  // TODO: implement use of tieFormats and tieFormatId
@@ -36622,8 +36792,7 @@ function addCollectionDefinition$1(_a) {
36622
36792
  matchUp = matchUp !== null && matchUp !== void 0 ? matchUp : result === null || result === void 0 ? void 0 : result.matchUp;
36623
36793
  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;
36624
36794
  var tieFormat = copyTieFormat(existingTieFormat);
36625
- var eventType = event === null || event === void 0 ? void 0 : event.eventType;
36626
- result = validateTieFormat({ tieFormat: tieFormat, eventType: eventType });
36795
+ result = validateTieFormat({ tieFormat: tieFormat });
36627
36796
  if (result === null || result === void 0 ? void 0 : result.error) {
36628
36797
  return decorateResult({ result: { error: result.error }, stack: stack });
36629
36798
  }
@@ -36667,7 +36836,7 @@ function addCollectionDefinition$1(_a) {
36667
36836
  var addedMatchUps = [];
36668
36837
  var targetMatchUps = [];
36669
36838
  var prunedTieFormat = definedAttributes(tieFormat);
36670
- result = validateTieFormat({ tieFormat: prunedTieFormat, eventType: eventType });
36839
+ result = validateTieFormat({ tieFormat: prunedTieFormat });
36671
36840
  if (result === null || result === void 0 ? void 0 : result.error) {
36672
36841
  return decorateResult({ result: { error: result.error }, stack: stack });
36673
36842
  }
@@ -36989,10 +37158,7 @@ function collectionGroupUpdate(_a) {
36989
37158
  event: event,
36990
37159
  });
36991
37160
  var prunedTieFormat = definedAttributes(tieFormat);
36992
- var result = validateTieFormat({
36993
- eventType: event === null || event === void 0 ? void 0 : event.eventType,
36994
- tieFormat: prunedTieFormat,
36995
- });
37161
+ var result = validateTieFormat({ tieFormat: prunedTieFormat });
36996
37162
  if (result.error)
36997
37163
  return result;
36998
37164
  // TODO: implement use of tieFormats and tieFormatId
@@ -37041,7 +37207,7 @@ function removeCollectionGroup$1(_a) {
37041
37207
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
37042
37208
  var wasAggregateValue = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.aggregateValue;
37043
37209
  var tieFormat = copyTieFormat(existingTieFormat);
37044
- result = validateTieFormat({ tieFormat: tieFormat, eventType: event === null || event === void 0 ? void 0 : event.eventType });
37210
+ result = validateTieFormat({ tieFormat: tieFormat });
37045
37211
  if (result.error)
37046
37212
  return decorateResult({ result: result, stack: stack });
37047
37213
  var modifiedCollectionIds = [];
@@ -37122,7 +37288,7 @@ function addCollectionGroup$1(_a) {
37122
37288
  var existingTieFormat = result === null || result === void 0 ? void 0 : result.tieFormat;
37123
37289
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
37124
37290
  var tieFormat = copyTieFormat(existingTieFormat);
37125
- result = validateTieFormat({ tieFormat: tieFormat, eventType: event.eventType });
37291
+ result = validateTieFormat({ tieFormat: tieFormat });
37126
37292
  if (result.error)
37127
37293
  return decorateResult({ result: result, stack: stack });
37128
37294
  try {
@@ -37187,10 +37353,7 @@ function modifyTieFormat$1(_a) {
37187
37353
  var e_1, _b, e_2, _c, e_3, _d;
37188
37354
  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;
37189
37355
  var stack = 'modifyTieFormat';
37190
- if (!validateTieFormat({
37191
- tieFormat: modifiedTieFormat,
37192
- eventType: event === null || event === void 0 ? void 0 : event.eventType,
37193
- }).valid) {
37356
+ if (!validateTieFormat({ tieFormat: modifiedTieFormat }).valid) {
37194
37357
  return decorateResult({
37195
37358
  result: { error: INVALID_TIE_FORMAT },
37196
37359
  info: 'falied validation',
@@ -44609,10 +44772,11 @@ function generateQualifyingStructures(_a) {
44609
44772
  var stageSequence = 1, targetRoundQualifiersCount = 0, finalQualifyingRoundNumber = void 0, finalQualifyingStructureId = void 0, linkType = void 0;
44610
44773
  var _loop_1 = function (structureProfile) {
44611
44774
  var _j;
44612
- var drawSize = structureProfile.drawSize ||
44613
- coerceEven(structureProfile.participantsCount);
44614
- var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, structureOptions = structureProfile.structureOptions, matchUpFormat = structureProfile.matchUpFormat, structureName = structureProfile.structureName, structureId = structureProfile.structureId, drawType = structureProfile.drawType;
44775
+ var drawSize = coerceEven(structureProfile.drawSize || structureProfile.participantsCount);
44776
+ var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, structureOptions = structureProfile.structureOptions, matchUpFormat = structureProfile.matchUpFormat, structureName = structureProfile.structureName, structureId = structureProfile.structureId, drawType = structureProfile.drawType;
44615
44777
  var matchUpType = structureProfile.matchUpType;
44778
+ var qualifyingPositions = structureProfile.qualifyingPositions ||
44779
+ deriveQualifyingPositions({ drawSize: drawSize, qualifyingRoundNumber: qualifyingRoundNumber });
44616
44780
  var roundLimit, structure = void 0, matchUps = void 0;
44617
44781
  if (!isConvertableInteger(drawSize)) {
44618
44782
  return { value: decorateResult({
@@ -44738,6 +44902,16 @@ function generateQualifyingStructures(_a) {
44738
44902
  }
44739
44903
  return __assign(__assign({ qualifiersCount: totalQualifiersCount, qualifyingDrawPositionsCount: qualifyingDrawPositionsCount, qualifyingDetails: qualifyingDetails, structures: structures }, SUCCESS), { links: links });
44740
44904
  }
44905
+ function deriveQualifyingPositions(_a) {
44906
+ var drawSize = _a.drawSize, qualifyingRoundNumber = _a.qualifyingRoundNumber;
44907
+ var qualifyingPositions = drawSize;
44908
+ var divisionsCount = 0;
44909
+ while (divisionsCount < qualifyingRoundNumber) {
44910
+ qualifyingPositions = Math.floor(qualifyingPositions / 2);
44911
+ divisionsCount += 1;
44912
+ }
44913
+ return qualifyingPositions;
44914
+ }
44741
44915
 
44742
44916
  function getPositionRangeMap(_a) {
44743
44917
  var _b;
@@ -46475,8 +46649,8 @@ function setStageQualifiersCount(_a) {
46475
46649
  }
46476
46650
 
46477
46651
  function generateDrawTypeAndModifyDrawDefinition$1(params) {
46478
- var _a, _b, _c;
46479
- var _d = params || {}, _e = _d.modifyOriginal, modifyOriginal = _e === void 0 ? true : _e, _f = _d.stageSequence, stageSequence = _f === void 0 ? 1 : _f, isMock = _d.isMock;
46652
+ var _a, _b;
46653
+ var _c = params || {}, _d = _c.modifyOriginal, modifyOriginal = _d === void 0 ? true : _d, _e = _c.stageSequence, stageSequence = _e === void 0 ? 1 : _e, isMock = _c.isMock;
46480
46654
  var stack = 'generateDrawTypeAndModifyDrawDefinition';
46481
46655
  if (!params.drawDefinition)
46482
46656
  return decorateResult({
@@ -46488,12 +46662,11 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
46488
46662
  : makeDeepCopy(params.drawDefinition, false, true);
46489
46663
  var tieFormat = params.tieFormat, matchUpType = params.matchUpType;
46490
46664
  if (tieFormat) {
46491
- var eventType = (_a = params.event) === null || _a === void 0 ? void 0 : _a.eventType;
46492
- var result_1 = validateTieFormat({ tieFormat: tieFormat, eventType: eventType });
46665
+ var result_1 = validateTieFormat({ tieFormat: tieFormat });
46493
46666
  if (result_1.error)
46494
46667
  return result_1;
46495
46668
  }
46496
- tieFormat = copyTieFormat(tieFormat || ((_b = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _b === void 0 ? void 0 : _b.tieFormat));
46669
+ tieFormat = copyTieFormat(tieFormat || ((_a = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _a === void 0 ? void 0 : _a.tieFormat));
46497
46670
  matchUpType = matchUpType || drawDefinition.matchUpType || SINGLES$1;
46498
46671
  params.tieFormat = tieFormat;
46499
46672
  params.matchUpType = matchUpType;
@@ -46547,7 +46720,7 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
46547
46720
  }
46548
46721
  var drawSize = params.drawSize || mainStageDrawPositionsCount;
46549
46722
  Object.assign(params, definedAttributes({ drawSize: drawSize, matchUpType: matchUpType, tieFormat: tieFormat }));
46550
- var _g = getAllDrawMatchUps({ drawDefinition: drawDefinition }), matchUps = _g.matchUps, matchUpsMap = _g.matchUpsMap;
46723
+ var _f = getAllDrawMatchUps({ drawDefinition: drawDefinition }), matchUps = _f.matchUps, matchUpsMap = _f.matchUpsMap;
46551
46724
  if (tieFormat) {
46552
46725
  // if there were exiting matchUps, exclude them from this step
46553
46726
  matchUps === null || matchUps === void 0 ? void 0 : matchUps.forEach(function (matchUp) {
@@ -46559,7 +46732,7 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
46559
46732
  }
46560
46733
  var inContextDrawMatchUps = addGoesTo({ drawDefinition: drawDefinition, matchUpsMap: matchUpsMap }).inContextDrawMatchUps;
46561
46734
  modifyDrawNotice({
46562
- tournamentId: (_c = params.tournamentRecord) === null || _c === void 0 ? void 0 : _c.tournamentId,
46735
+ tournamentId: (_b = params.tournamentRecord) === null || _b === void 0 ? void 0 : _b.tournamentId,
46563
46736
  drawDefinition: drawDefinition,
46564
46737
  });
46565
46738
  return __assign(__assign({ inContextDrawMatchUps: inContextDrawMatchUps, drawDefinition: drawDefinition, matchUpsMap: matchUpsMap }, SUCCESS), { structures: structures, matchUps: matchUps, links: links });
@@ -49020,8 +49193,8 @@ function addVoluntaryConsolationStage$1(_a) {
49020
49193
 
49021
49194
  function generateVoluntaryConsolation$1(params) {
49022
49195
  var _a, _b;
49023
- var _c, _d, _e, _f, _g, _h, _j, _k;
49024
- 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
49196
+ var _c, _d, _e, _f, _g, _h, _j;
49197
+ 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
49025
49198
  automated = params.automated, placeByes = params.placeByes, isMock = params.isMock, event = params.event;
49026
49199
  var drawDefinition = params === null || params === void 0 ? void 0 : params.drawDefinition;
49027
49200
  if (!drawDefinition)
@@ -49052,13 +49225,12 @@ function generateVoluntaryConsolation$1(params) {
49052
49225
  return { error: INVALID_DRAW_SIZE };
49053
49226
  var tieFormat = params.tieFormat, matchUpType = params.matchUpType;
49054
49227
  if (tieFormat) {
49055
- var eventType = (_d = params.event) === null || _d === void 0 ? void 0 : _d.eventType;
49056
- var result_1 = validateTieFormat({ tieFormat: tieFormat, eventType: eventType });
49228
+ var result_1 = validateTieFormat({ tieFormat: tieFormat });
49057
49229
  if (result_1.error)
49058
49230
  return result_1;
49059
49231
  }
49060
- tieFormat = copyTieFormat(tieFormat !== null && tieFormat !== void 0 ? tieFormat : (_e = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _e === void 0 ? void 0 : _e.tieFormat);
49061
- matchUpType = (_f = matchUpType !== null && matchUpType !== void 0 ? matchUpType : drawDefinition.matchUpType) !== null && _f !== void 0 ? _f : TypeEnum.Singles;
49232
+ tieFormat = copyTieFormat(tieFormat !== null && tieFormat !== void 0 ? tieFormat : (_d = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _d === void 0 ? void 0 : _d.tieFormat);
49233
+ matchUpType = (_e = matchUpType !== null && matchUpType !== void 0 ? matchUpType : drawDefinition.matchUpType) !== null && _e !== void 0 ? _e : TypeEnum.Singles;
49062
49234
  var stageStructures = getDrawStructures({
49063
49235
  stageSequence: 1,
49064
49236
  drawDefinition: drawDefinition,
@@ -49069,11 +49241,11 @@ function generateVoluntaryConsolation$1(params) {
49069
49241
  if (structureCount > 1)
49070
49242
  return { error: STAGE_SEQUENCE_LIMIT };
49071
49243
  // invalid to already have matchUps generated for any existing structure
49072
- 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)
49244
+ 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)
49073
49245
  return { error: EXISTING_STRUCTURE };
49074
- var structureId = (_j = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _j === void 0 ? void 0 : _j.structureId;
49246
+ var structureId = (_h = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _h === void 0 ? void 0 : _h.structureId;
49075
49247
  Object.assign(params, definedAttributes({
49076
- structureName: (_k = params.structureName) !== null && _k !== void 0 ? _k : constantToString(VOLUNTARY_CONSOLATION),
49248
+ structureName: (_j = params.structureName) !== null && _j !== void 0 ? _j : constantToString(VOLUNTARY_CONSOLATION),
49077
49249
  structureId: structureId,
49078
49250
  matchUpType: matchUpType,
49079
49251
  tieFormat: tieFormat,
@@ -53406,7 +53578,6 @@ function getNextUnfilledDrawPositions(_a) {
53406
53578
  var _b = structureAssignedDrawPositions({
53407
53579
  structure: result.structure,
53408
53580
  }).positionAssignments, positionAssignments = _b === void 0 ? [] : _b;
53409
- // console.log('gnudp', { provisionalPositioning });
53410
53581
  var unfilledPositions = getNextSeedBlock({
53411
53582
  provisionalPositioning: provisionalPositioning,
53412
53583
  randomize: true,
@@ -55665,7 +55836,7 @@ function addParticipantContext(params) {
55665
55836
  params.withDraws) {
55666
55837
  // loop through all filtered events and capture events played
55667
55838
  (_a = params.tournamentEvents) === null || _a === void 0 ? void 0 : _a.forEach(function (rawEvent) {
55668
- var _a, _b, _c, _d, _e, _f, _g;
55839
+ var _a, _b, _c, _d, _e, _f;
55669
55840
  var event = makeDeepCopy(rawEvent, true, true);
55670
55841
  var flightProfile = getFlightProfile({ event: event }).flightProfile;
55671
55842
  var eventDrawsCount = ((_a = flightProfile === null || flightProfile === void 0 ? void 0 : flightProfile.flights) === null || _a === void 0 ? void 0 : _a.length) || ((_b = event.drawDefinitions) === null || _b === void 0 ? void 0 : _b.length) || 0;
@@ -55685,20 +55856,21 @@ function addParticipantContext(params) {
55685
55856
  var extensionKeys = event && Object.keys(event).filter(function (key) { return key.startsWith('_'); });
55686
55857
  extensionKeys === null || extensionKeys === void 0 ? void 0 : extensionKeys.forEach(function (extensionKey) { return (eventInfo[extensionKey] = event[extensionKey]); });
55687
55858
  var eventEntries = event.entries || [];
55688
- var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
55689
- var timeItem = getEventTimeItem({
55690
- itemType: itemType,
55691
- event: event,
55692
- }).timeItem;
55693
- if ((_c = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _c === void 0 ? void 0 : _c.PUBLIC) {
55694
- var _h = timeItem.itemValue.PUBLIC || {}, _j = _h.drawIds, publishedDrawIds = _j === void 0 ? [] : _j, seeding = _h.seeding;
55859
+ var pubStatus = getEventPublishStatus({ event: event });
55860
+ if (isObject(pubStatus)) {
55861
+ var drawIds = pubStatus.drawIds, drawDetails_1 = pubStatus.drawDetails, seeding = pubStatus.seeding;
55862
+ var publishedDrawIds = drawDetails_1
55863
+ ? Object.keys(drawDetails_1).filter(function (drawId) {
55864
+ return getDrawPublishStatus({ drawId: drawId, drawDetails: drawDetails_1 });
55865
+ })
55866
+ : drawIds !== null && drawIds !== void 0 ? drawIds : [];
55695
55867
  var publishedSeeding = {
55696
55868
  published: undefined, // seeding can be present for all entries in an event when no flights have been defined
55697
55869
  seedingScaleNames: [],
55698
55870
  drawIds: [], // seeding can be specific to drawIds
55699
55871
  };
55700
55872
  if (seeding)
55701
- Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
55873
+ Object.assign(publishedSeeding, pubStatus.seeding);
55702
55874
  eventsPublishStatuses[eventId] = {
55703
55875
  publishedDrawIds: publishedDrawIds,
55704
55876
  publishedSeeding: publishedSeeding,
@@ -55769,11 +55941,11 @@ function addParticipantContext(params) {
55769
55941
  });
55770
55942
  };
55771
55943
  // iterate through flights to ensure that draw entries are captured if drawDefinitions have not yet been generated
55772
- var drawIdsWithDefinitions = ((_d = event.drawDefinitions) === null || _d === void 0 ? void 0 : _d.map(function (_a) {
55944
+ var drawIdsWithDefinitions = ((_c = event.drawDefinitions) === null || _c === void 0 ? void 0 : _c.map(function (_a) {
55773
55945
  var drawId = _a.drawId;
55774
55946
  return drawId;
55775
55947
  })) || [];
55776
- (_f = (_e = eventInfo._flightProfile) === null || _e === void 0 ? void 0 : _e.flights) === null || _f === void 0 ? void 0 : _f.forEach(function (flight) {
55948
+ (_e = (_d = eventInfo._flightProfile) === null || _d === void 0 ? void 0 : _d.flights) === null || _e === void 0 ? void 0 : _e.forEach(function (flight) {
55777
55949
  var drawId = flight.drawId, drawEntries = flight.drawEntries;
55778
55950
  if (!drawIdsWithDefinitions.includes(drawId)) {
55779
55951
  drawEntries === null || drawEntries === void 0 ? void 0 : drawEntries.forEach(function (drawEntry) {
@@ -55781,10 +55953,10 @@ function addParticipantContext(params) {
55781
55953
  });
55782
55954
  }
55783
55955
  });
55784
- var _k = getDrawDetails({
55956
+ var _g = getDrawDetails({
55785
55957
  eventEntries: eventEntries,
55786
55958
  event: event,
55787
- }), drawDetails = _k.drawDetails, derivedInfo = _k.derivedInfo;
55959
+ }), drawDetails = _g.drawDetails, derivedInfo = _g.derivedInfo;
55788
55960
  Object.assign(derivedDrawInfo, derivedInfo);
55789
55961
  if (event.eventType === TEAM$2 || // for TEAM events some individual attributes can only be derived by processing
55790
55962
  params.withScheduleItems ||
@@ -55793,14 +55965,14 @@ function addParticipantContext(params) {
55793
55965
  params.withOpponents ||
55794
55966
  params.withMatchUps ||
55795
55967
  params.withDraws) {
55796
- var matchUps = (_g = allEventMatchUps({
55968
+ var matchUps = (_f = allEventMatchUps({
55797
55969
  afterRecoveryTimes: params.scheduleAnalysis,
55798
55970
  participants: allTournamentParticipants,
55799
55971
  nextMatchUps: true,
55800
55972
  tournamentRecord: tournamentRecord,
55801
55973
  inContext: true,
55802
55974
  event: event,
55803
- })) === null || _g === void 0 ? void 0 : _g.matchUps;
55975
+ })) === null || _f === void 0 ? void 0 : _f.matchUps;
55804
55976
  matchUps === null || matchUps === void 0 ? void 0 : matchUps.forEach(function (matchUp) {
55805
55977
  return processMatchUp({
55806
55978
  relevantParticipantIdsMap: relevantParticipantIdsMap,
@@ -57573,35 +57745,48 @@ var participantGovernor = {
57573
57745
  getParticipants: getParticipants$1,
57574
57746
  };
57575
57747
 
57576
- function publishEventSeeding(_a) {
57748
+ function modifyEventPublishStatus(_a) {
57577
57749
  var _b;
57578
- var _c, _d, _e, _f;
57579
- var _g = _a.removePriorValues, removePriorValues = _g === void 0 ? true : _g, stageSeedingScaleNames = _a.stageSeedingScaleNames, seedingScaleNames = _a.seedingScaleNames, tournamentRecord = _a.tournamentRecord, _h = _a.status, status = _h === void 0 ? PUBLIC : _h, _j = _a.drawIds, drawIds = _j === void 0 ? [] : _j, event = _a.event;
57750
+ var _c = _a.removePriorValues, removePriorValues = _c === void 0 ? true : _c, _d = _a.status, status = _d === void 0 ? PUBLIC : _d, statusObject = _a.statusObject, event = _a.event;
57751
+ if (!isObject(statusObject))
57752
+ return { error: INVALID_VALUES };
57753
+ var publishStatus = getEventPublishStatus({ event: event, status: status });
57754
+ var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
57755
+ var updatedTimeItem = {
57756
+ itemValue: (_b = {}, _b[status] = __assign(__assign({}, publishStatus), statusObject), _b),
57757
+ itemType: itemType,
57758
+ };
57759
+ return addEventTimeItem({
57760
+ timeItem: updatedTimeItem,
57761
+ removePriorValues: removePriorValues,
57762
+ event: event,
57763
+ });
57764
+ }
57765
+
57766
+ function publishEventSeeding(_a) {
57767
+ var _b, _c, _d, _e;
57768
+ var _f = _a.removePriorValues, removePriorValues = _f === void 0 ? true : _f, stageSeedingScaleNames = _a.stageSeedingScaleNames, seedingScaleNames = _a.seedingScaleNames, tournamentRecord = _a.tournamentRecord, _g = _a.status, status = _g === void 0 ? PUBLIC : _g, _h = _a.drawIds, drawIds = _h === void 0 ? [] : _h, event = _a.event;
57580
57769
  if (!tournamentRecord)
57581
57770
  return { error: MISSING_TOURNAMENT_RECORD };
57582
57771
  if (!event)
57583
57772
  return { error: MISSING_EVENT };
57584
- var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
57585
- var timeItem = getEventTimeItem({
57586
- itemType: itemType,
57587
- event: event,
57588
- }).timeItem;
57589
- var itemValue = (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) || (_b = {}, _b[status] = {}, _b);
57590
- var updatedSeedingScaleNames = (((_c = itemValue[status].seeding) === null || _c === void 0 ? void 0 : _c.seedingScaleNames) ||
57591
- seedingScaleNames) && __assign(__assign({}, (_d = itemValue[status].seeding) === null || _d === void 0 ? void 0 : _d.seedingScaleNames), seedingScaleNames);
57592
- var updatedStageSeedingScaleNames = (((_e = itemValue[status].seeding) === null || _e === void 0 ? void 0 : _e.stageSeedingScaleNames) ||
57593
- stageSeedingScaleNames) && __assign(__assign({}, (_f = itemValue[status].seeding) === null || _f === void 0 ? void 0 : _f.stageSeedingScaleNames), stageSeedingScaleNames);
57594
- itemValue[status].seeding = definedAttributes({
57773
+ var eventPubStatus = getEventPublishStatus({ event: event, status: status });
57774
+ var updatedSeedingScaleNames = (((_b = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.seeding) === null || _b === void 0 ? void 0 : _b.seedingScaleNames) ||
57775
+ seedingScaleNames) && __assign(__assign({}, (_c = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.seeding) === null || _c === void 0 ? void 0 : _c.seedingScaleNames), seedingScaleNames);
57776
+ var updatedStageSeedingScaleNames = (((_d = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.seeding) === null || _d === void 0 ? void 0 : _d.stageSeedingScaleNames) ||
57777
+ stageSeedingScaleNames) && __assign(__assign({}, (_e = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.seeding) === null || _e === void 0 ? void 0 : _e.stageSeedingScaleNames), stageSeedingScaleNames);
57778
+ var seeding = definedAttributes({
57595
57779
  stageSeedingScaleNames: updatedStageSeedingScaleNames,
57596
57780
  seedingScaleNames: updatedSeedingScaleNames,
57597
57781
  published: true,
57598
57782
  drawIds: drawIds,
57599
57783
  });
57600
- var updatedTimeItem = {
57601
- itemValue: itemValue,
57602
- itemType: itemType,
57603
- };
57604
- addEventTimeItem({ event: event, timeItem: updatedTimeItem, removePriorValues: removePriorValues });
57784
+ modifyEventPublishStatus({
57785
+ statusObject: { seeding: seeding },
57786
+ removePriorValues: removePriorValues,
57787
+ status: status,
57788
+ event: event,
57789
+ });
57605
57790
  addNotice({
57606
57791
  topic: PUBLISH_EVENT_SEEDING,
57607
57792
  payload: {
@@ -57613,51 +57798,55 @@ function publishEventSeeding(_a) {
57613
57798
  return __assign({}, SUCCESS);
57614
57799
  }
57615
57800
  function unPublishEventSeeding(_a) {
57616
- var _b, e_1, _c;
57617
- var _d, _e;
57618
- var _f = _a.removePriorValues, removePriorValues = _f === void 0 ? true : _f, seedingScaleNames = _a.seedingScaleNames, tournamentRecord = _a.tournamentRecord, _g = _a.status, status = _g === void 0 ? PUBLIC : _g, stages = _a.stages, event = _a.event;
57801
+ var e_1, _b;
57802
+ var _c, _d, _e;
57803
+ var _f = _a.removePriorValues, removePriorValues = _f === void 0 ? true : _f, seedingScaleNames = _a.seedingScaleNames, tournamentRecord = _a.tournamentRecord, _g = _a.status, status = _g === void 0 ? PUBLIC : _g, drawIds = _a.drawIds, stages = _a.stages, event = _a.event;
57619
57804
  if (!tournamentRecord)
57620
57805
  return { error: MISSING_TOURNAMENT_RECORD };
57621
57806
  if (!event)
57622
57807
  return { error: MISSING_EVENT };
57623
- var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
57624
- var timeItem = getEventTimeItem({
57625
- itemType: itemType,
57626
- event: event,
57627
- }).timeItem;
57628
- var itemValue = (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) || (_b = {}, _b[status] = {}, _b);
57629
- if (itemValue[status]) {
57630
- if (Array.isArray(stages) &&
57631
- ((_d = itemValue[status].seeding) === null || _d === void 0 ? void 0 : _d.stageSeedingScaleNames)) {
57808
+ var eventPubStatus = getEventPublishStatus({ event: event });
57809
+ if (eventPubStatus) {
57810
+ var seeding = eventPubStatus.seeding;
57811
+ if (Array.isArray(stages) && seeding.stageSeedingScaleNames) {
57632
57812
  try {
57633
57813
  for (var stages_1 = __values(stages), stages_1_1 = stages_1.next(); !stages_1_1.done; stages_1_1 = stages_1.next()) {
57634
57814
  var stage = stages_1_1.value;
57635
- if (itemValue[status].seeding.stageSeedingScaleNames[stage]) {
57636
- delete itemValue[status].seeding.stageSeedingScaleNames[stage];
57815
+ if (seeding.stageSeedingScaleNames[stage]) {
57816
+ delete seeding.stageSeedingScaleNames[stage];
57637
57817
  }
57638
57818
  }
57639
57819
  }
57640
57820
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
57641
57821
  finally {
57642
57822
  try {
57643
- if (stages_1_1 && !stages_1_1.done && (_c = stages_1.return)) _c.call(stages_1);
57823
+ if (stages_1_1 && !stages_1_1.done && (_b = stages_1.return)) _b.call(stages_1);
57644
57824
  }
57645
57825
  finally { if (e_1) throw e_1.error; }
57646
57826
  }
57647
57827
  }
57648
- if (Array.isArray(seedingScaleNames) &&
57649
- ((_e = itemValue[status].seeding) === null || _e === void 0 ? void 0 : _e.seedingScaleNames)) {
57650
- itemValue[status].seeding.seedingScaleNames = itemValue[status].seeding.seedingScaleNames.filter(function (scaleName) { return !seedingScaleNames.includes(scaleName); });
57828
+ if (Array.isArray(seedingScaleNames) && (seeding === null || seeding === void 0 ? void 0 : seeding.seedingScaleNames)) {
57829
+ seeding.seedingScaleNames = seeding.seedingScaleNames.filter(function (scaleName) { return !seedingScaleNames.includes(scaleName); });
57651
57830
  }
57652
- if (!stages && !seedingScaleNames) {
57653
- delete itemValue[status].seeding;
57831
+ if (Array.isArray(drawIds) && (seeding === null || seeding === void 0 ? void 0 : seeding.drawIds)) {
57832
+ seeding.drawIds = seeding.drawIds.filter(function (drawId) { return !drawIds.includes(drawId); });
57654
57833
  }
57834
+ if ((!Object.values((_c = seeding.stageSeedingScaleNames) !== null && _c !== void 0 ? _c : {}).length &&
57835
+ !((_d = seeding.seedingScaleNames) === null || _d === void 0 ? void 0 : _d.length) &&
57836
+ !((_e = seeding.drawIds) === null || _e === void 0 ? void 0 : _e.length)) ||
57837
+ (!stages && !seedingScaleNames && !(drawIds === null || drawIds === void 0 ? void 0 : drawIds.length))) {
57838
+ delete seeding.stageSeedingScaleNames;
57839
+ delete seeding.seedingScaleNames;
57840
+ delete seeding.drawIds;
57841
+ seeding.published = false;
57842
+ }
57843
+ modifyEventPublishStatus({
57844
+ statusObject: { seeding: seeding },
57845
+ removePriorValues: removePriorValues,
57846
+ status: status,
57847
+ event: event,
57848
+ });
57655
57849
  }
57656
- var updatedTimeItem = {
57657
- itemValue: itemValue,
57658
- itemType: itemType,
57659
- };
57660
- addEventTimeItem({ event: event, timeItem: updatedTimeItem, removePriorValues: removePriorValues });
57661
57850
  addNotice({
57662
57851
  topic: UNPUBLISH_EVENT_SEEDING,
57663
57852
  payload: {
@@ -57732,13 +57921,10 @@ function getAllEventData(_a) {
57732
57921
  },
57733
57922
  };
57734
57923
  });
57735
- var timeItem = getEventTimeItem({
57736
- itemType: "".concat(PUBLISH, ".").concat(STATUS$1),
57737
- event: event,
57738
- }).timeItem;
57924
+ var publish = getEventPublishStatus({ event: event });
57739
57925
  Object.assign(eventInfo, {
57740
- publish: timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue,
57741
57926
  drawsData: drawsData,
57927
+ publish: publish,
57742
57928
  });
57743
57929
  return eventInfo;
57744
57930
  });
@@ -57746,6 +57932,72 @@ function getAllEventData(_a) {
57746
57932
  return { allEventData: allEventData };
57747
57933
  }
57748
57934
 
57935
+ function setEventDisplay(_a) {
57936
+ var e_1, _b, e_2, _c;
57937
+ var _d;
57938
+ var removePriorValues = _a.removePriorValues, tournamentRecord = _a.tournamentRecord, displaySettings = _a.displaySettings, _e = _a.status, status = _e === void 0 ? PUBLIC : _e, event = _a.event;
57939
+ if (!tournamentRecord)
57940
+ return decorateResult({ result: { error: MISSING_TOURNAMENT_RECORD } });
57941
+ if (!event)
57942
+ return decorateResult({ result: { error: MISSING_EVENT } });
57943
+ if (!isObject(displaySettings))
57944
+ return decorateResult({ result: { error: MISSING_VALUE } });
57945
+ // combine ScheduleDetails that are equivalent
57946
+ if (isObject(displaySettings.draws)) {
57947
+ try {
57948
+ for (var _f = __values(Object.keys(displaySettings.draws)), _g = _f.next(); !_g.done; _g = _f.next()) {
57949
+ var key = _g.value;
57950
+ var details = (_d = displaySettings.draws[key].scheduleDetails) !== null && _d !== void 0 ? _d : [];
57951
+ if (details.length) {
57952
+ var scheduleDetails = [];
57953
+ var _loop_1 = function (detail) {
57954
+ var _h;
57955
+ var existingDetail = scheduleDetails.find(function (sd) {
57956
+ return objShallowEqual(sd.attributes, detail.attributes);
57957
+ });
57958
+ if ((existingDetail === null || existingDetail === void 0 ? void 0 : existingDetail.dates) && detail.dates) {
57959
+ (_h = existingDetail.dates).push.apply(_h, __spreadArray([], __read(detail.dates), false));
57960
+ }
57961
+ else {
57962
+ scheduleDetails.push(detail);
57963
+ }
57964
+ };
57965
+ try {
57966
+ for (var details_1 = (e_2 = void 0, __values(details)), details_1_1 = details_1.next(); !details_1_1.done; details_1_1 = details_1.next()) {
57967
+ var detail = details_1_1.value;
57968
+ _loop_1(detail);
57969
+ }
57970
+ }
57971
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
57972
+ finally {
57973
+ try {
57974
+ if (details_1_1 && !details_1_1.done && (_c = details_1.return)) _c.call(details_1);
57975
+ }
57976
+ finally { if (e_2) throw e_2.error; }
57977
+ }
57978
+ displaySettings.draws[key].scheduleDetails = scheduleDetails;
57979
+ }
57980
+ }
57981
+ }
57982
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
57983
+ finally {
57984
+ try {
57985
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
57986
+ }
57987
+ finally { if (e_1) throw e_1.error; }
57988
+ }
57989
+ }
57990
+ var result = modifyEventPublishStatus({
57991
+ statusObject: { displaySettings: displaySettings },
57992
+ removePriorValues: removePriorValues,
57993
+ status: status,
57994
+ event: event,
57995
+ });
57996
+ if (result.error)
57997
+ return result;
57998
+ return __assign({}, SUCCESS);
57999
+ }
58000
+
57749
58001
  function unPublishEvent(_a) {
57750
58002
  var _b;
57751
58003
  var _c = _a.removePriorValues, removePriorValues = _c === void 0 ? true : _c, tournamentRecord = _a.tournamentRecord, _d = _a.status, status = _d === void 0 ? PUBLIC : _d, event = _a.event;
@@ -57759,10 +58011,21 @@ function unPublishEvent(_a) {
57759
58011
  event: event,
57760
58012
  }).timeItem;
57761
58013
  var itemValue = (timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) || (_b = {}, _b[status] = {}, _b);
57762
- delete itemValue[status].structureIds;
57763
- delete itemValue[status].drawIds;
58014
+ delete itemValue[status].structureIds; // legacy
58015
+ delete itemValue[status].drawDetails;
58016
+ delete itemValue[status].drawIds; // legacy
57764
58017
  var updatedTimeItem = { itemValue: itemValue, itemType: itemType };
57765
58018
  addEventTimeItem({ event: event, timeItem: updatedTimeItem, removePriorValues: removePriorValues });
58019
+ modifyEventPublishStatus({
58020
+ statusObject: {
58021
+ structureIds: undefined,
58022
+ drawIds: undefined,
58023
+ seeding: undefined,
58024
+ },
58025
+ removePriorValues: removePriorValues,
58026
+ status: status,
58027
+ event: event,
58028
+ });
57766
58029
  addNotice({
57767
58030
  topic: UNPUBLISH_EVENT,
57768
58031
  payload: {
@@ -57774,64 +58037,183 @@ function unPublishEvent(_a) {
57774
58037
  }
57775
58038
 
57776
58039
  function publishEvent(params) {
57777
- var _a;
57778
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
57779
- var policyDefinitions = params.policyDefinitions, drawIds = params.drawIds, structureIds = params.structureIds, stages = params.stages;
57780
- var includePositionAssignments = params.includePositionAssignments, removePriorValues = params.removePriorValues, tournamentRecord = params.tournamentRecord, _o = params.status, status = _o === void 0 ? PUBLIC : _o, event = params.event, drawIdsToRemove = params.drawIdsToRemove, drawIdsToAdd = params.drawIdsToAdd, stagesToRemove = params.stagesToRemove, stagesToAdd = params.stagesToAdd, structureIdsToRemove = params.structureIdsToRemove, structureIdsToAdd = params.structureIdsToAdd;
58040
+ var _a, e_1, _b;
58041
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
58042
+ var includePositionAssignments = params.includePositionAssignments, removePriorValues = params.removePriorValues, tournamentRecord = params.tournamentRecord, _q = params.status, status = _q === void 0 ? PUBLIC : _q, event = params.event, drawIdsToRemove = params.drawIdsToRemove, drawIdsToAdd = params.drawIdsToAdd;
57781
58043
  if (!tournamentRecord)
57782
58044
  return { error: MISSING_TOURNAMENT_RECORD };
57783
58045
  if (!event)
57784
58046
  return { error: MISSING_EVENT };
57785
- if (!policyDefinitions) {
57786
- var appliedPolicies = getAppliedPolicies({ tournamentRecord: tournamentRecord, event: event }).appliedPolicies;
57787
- policyDefinitions = appliedPolicies;
57788
- }
57789
- var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
57790
- var eventDrawIds = (_c = (_b = event.drawDefinitions) === null || _b === void 0 ? void 0 : _b.map(function (_a) {
58047
+ // publishing will draw on scoring policy, round naming policy and participant (privacy) policy
58048
+ var appliedPolicies = getAppliedPolicies({ tournamentRecord: tournamentRecord, event: event }).appliedPolicies;
58049
+ var policyDefinitions = __assign(__assign({}, appliedPolicies), params.policyDefinitions);
58050
+ var eventDrawIds = (_d = (_c = event.drawDefinitions) === null || _c === void 0 ? void 0 : _c.map(function (_a) {
57791
58051
  var drawId = _a.drawId;
57792
58052
  return drawId;
57793
- })) !== null && _c !== void 0 ? _c : [];
57794
- var timeItem = getEventTimeItem({
57795
- itemType: itemType,
57796
- event: event,
57797
- }).timeItem;
57798
- if (!drawIds && !drawIdsToAdd && !drawIdsToRemove) {
57799
- // by default publish all drawIds in an event
57800
- drawIds = eventDrawIds;
57801
- }
57802
- else if (!drawIds && ((drawIdsToAdd === null || drawIdsToAdd === void 0 ? void 0 : drawIdsToAdd.length) || (drawIdsToRemove === null || drawIdsToRemove === void 0 ? void 0 : drawIdsToRemove.length))) {
57803
- drawIds = ((_e = (_d = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _d === void 0 ? void 0 : _d.PUBLIC) === null || _e === void 0 ? void 0 : _e.drawIds) || [];
57804
- }
57805
- drawIds = (drawIds !== null && drawIds !== void 0 ? drawIds : []).filter(function (drawId) { return !(drawIdsToRemove === null || drawIdsToRemove === void 0 ? void 0 : drawIdsToRemove.length) || !drawIdsToRemove.includes(drawId); });
57806
- if (drawIdsToAdd === null || drawIdsToAdd === void 0 ? void 0 : drawIdsToAdd.length) {
57807
- drawIds = unique(drawIds.concat.apply(drawIds, __spreadArray([], __read(drawIdsToAdd.filter(function (drawId) { return eventDrawIds.includes(drawId); })), false)));
58053
+ })) !== null && _d !== void 0 ? _d : [];
58054
+ var keyedDrawIds = params.drawDetails
58055
+ ? Object.keys(params.drawDetails)
58056
+ : [];
58057
+ var specifiedDrawIds = keyedDrawIds.length ? [] : params.drawIds;
58058
+ var drawIdsToValidate = (_a = (drawIdsToAdd !== null && drawIdsToAdd !== void 0 ? drawIdsToAdd : [])).concat.apply(_a, __spreadArray(__spreadArray(__spreadArray([], __read((drawIdsToRemove !== null && drawIdsToRemove !== void 0 ? drawIdsToRemove : [])), false), __read((specifiedDrawIds !== null && specifiedDrawIds !== void 0 ? specifiedDrawIds : [])), false), __read(keyedDrawIds), false));
58059
+ var invalidDrawIds = drawIdsToValidate.filter(function (drawId) { return !eventDrawIds.includes(drawId); });
58060
+ if (invalidDrawIds.length) {
58061
+ return decorateResult({
58062
+ result: { error: DRAW_DEFINITION_NOT_FOUND },
58063
+ context: { invalidDrawIds: invalidDrawIds },
58064
+ });
58065
+ }
58066
+ var pubStatus = getEventPublishStatus({ event: event, status: status });
58067
+ var drawDetails = (pubStatus === null || pubStatus === void 0 ? void 0 : pubStatus.drawDetails) || {};
58068
+ var _loop_1 = function (drawId) {
58069
+ var e_2, _r, e_3, _s, e_4, _t, e_5, _u, e_6, _v;
58070
+ if (!drawIdsToValidate.length || drawIdsToValidate.includes(drawId)) {
58071
+ if ((drawIdsToRemove === null || drawIdsToRemove === void 0 ? void 0 : drawIdsToRemove.includes(drawId)) ||
58072
+ ((specifiedDrawIds === null || specifiedDrawIds === void 0 ? void 0 : specifiedDrawIds.length) && !specifiedDrawIds.includes(drawId))) {
58073
+ drawDetails[drawId] = __assign(__assign({}, drawDetails[drawId]), { publishingDetail: { published: false } });
58074
+ }
58075
+ else if ((drawIdsToAdd === null || drawIdsToAdd === void 0 ? void 0 : drawIdsToAdd.includes(drawId)) ||
58076
+ (specifiedDrawIds === null || specifiedDrawIds === void 0 ? void 0 : specifiedDrawIds.includes(drawId)) ||
58077
+ !(specifiedDrawIds === null || specifiedDrawIds === void 0 ? void 0 : specifiedDrawIds.length)) {
58078
+ drawDetails[drawId] = __assign(__assign({}, drawDetails[drawId]), { publishingDetail: { published: true } });
58079
+ }
58080
+ }
58081
+ if ((_e = params.drawDetails) === null || _e === void 0 ? void 0 : _e[drawId]) {
58082
+ var newDetail = params.drawDetails[drawId];
58083
+ var structureDetails = (_f = newDetail.structureDetails) !== null && _f !== void 0 ? _f : drawDetails[drawId].structureDetails;
58084
+ var stageDetails = (_h = (_g = newDetail.stageDetails) !== null && _g !== void 0 ? _g : drawDetails[drawId].stageDetails) !== null && _h !== void 0 ? _h : {};
58085
+ var _w = newDetail.structureIdsToRemove, structureIdsToRemove = _w === void 0 ? [] : _w, _x = newDetail.structureIdsToAdd, structureIdsToAdd = _x === void 0 ? [] : _x, _y = newDetail.publishingDetail, publishingDetail = _y === void 0 ? {} : _y, _z = newDetail.stagesToRemove, stagesToRemove = _z === void 0 ? [] : _z, _0 = newDetail.stagesToAdd, stagesToAdd = _0 === void 0 ? [] : _0;
58086
+ if (structureIdsToAdd || stagesToAdd)
58087
+ publishingDetail.published = true;
58088
+ drawDetails[drawId] = {
58089
+ publishingDetail: publishingDetail,
58090
+ structureDetails: structureDetails,
58091
+ stageDetails: stageDetails,
58092
+ };
58093
+ if (structureIdsToAdd.length || structureIdsToRemove.length) {
58094
+ var drawStructureIds_2 = ((_l = (_k = (_j = event.drawDefinitions) === null || _j === void 0 ? void 0 : _j.find(function (drawDefinition) { return drawDefinition.drawId === drawId; })) === null || _k === void 0 ? void 0 : _k.structures) !== null && _l !== void 0 ? _l : []).map(function (_a) {
58095
+ var structureId = _a.structureId;
58096
+ return structureId;
58097
+ });
58098
+ var structureIdsToValidate = (structureIdsToAdd !== null && structureIdsToAdd !== void 0 ? structureIdsToAdd : []).concat(structureIdsToRemove !== null && structureIdsToRemove !== void 0 ? structureIdsToRemove : []);
58099
+ var invalidStructureIds = structureIdsToValidate.filter(function (structureId) { return !drawStructureIds_2.includes(structureId); });
58100
+ if (invalidStructureIds.length) {
58101
+ return { value: decorateResult({
58102
+ result: { error: STRUCTURE_NOT_FOUND },
58103
+ context: { invalidStructureIds: invalidStructureIds },
58104
+ }) };
58105
+ }
58106
+ structureDetails = structureDetails !== null && structureDetails !== void 0 ? structureDetails : {};
58107
+ try {
58108
+ for (var drawStructureIds_1 = (e_2 = void 0, __values(drawStructureIds_2)), drawStructureIds_1_1 = drawStructureIds_1.next(); !drawStructureIds_1_1.done; drawStructureIds_1_1 = drawStructureIds_1.next()) {
58109
+ var structureId = drawStructureIds_1_1.value;
58110
+ if (structureIdsToRemove.includes(structureId)) {
58111
+ structureDetails[structureId] = { published: false };
58112
+ }
58113
+ else {
58114
+ structureDetails[structureId] = { published: true };
58115
+ }
58116
+ }
58117
+ }
58118
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
58119
+ finally {
58120
+ try {
58121
+ if (drawStructureIds_1_1 && !drawStructureIds_1_1.done && (_r = drawStructureIds_1.return)) _r.call(drawStructureIds_1);
58122
+ }
58123
+ finally { if (e_2) throw e_2.error; }
58124
+ }
58125
+ drawDetails[drawId].structureDetails = structureDetails;
58126
+ }
58127
+ var drawStages = ((_p = (_o = (_m = event.drawDefinitions) === null || _m === void 0 ? void 0 : _m.find(function (drawDefinition) { return drawDefinition.drawId === drawId; })) === null || _o === void 0 ? void 0 : _o.structures) !== null && _p !== void 0 ? _p : []).map(function (_a) {
58128
+ var stage = _a.stage;
58129
+ return stage;
58130
+ });
58131
+ if (stagesToAdd.length) {
58132
+ try {
58133
+ for (var stagesToAdd_1 = (e_3 = void 0, __values(stagesToAdd)), stagesToAdd_1_1 = stagesToAdd_1.next(); !stagesToAdd_1_1.done; stagesToAdd_1_1 = stagesToAdd_1.next()) {
58134
+ var stage = stagesToAdd_1_1.value;
58135
+ stageDetails[stage] = { published: true };
58136
+ }
58137
+ }
58138
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
58139
+ finally {
58140
+ try {
58141
+ if (stagesToAdd_1_1 && !stagesToAdd_1_1.done && (_s = stagesToAdd_1.return)) _s.call(stagesToAdd_1);
58142
+ }
58143
+ finally { if (e_3) throw e_3.error; }
58144
+ }
58145
+ try {
58146
+ for (var drawStages_1 = (e_4 = void 0, __values(drawStages)), drawStages_1_1 = drawStages_1.next(); !drawStages_1_1.done; drawStages_1_1 = drawStages_1.next()) {
58147
+ var stage = drawStages_1_1.value;
58148
+ if (!stageDetails[stage]) {
58149
+ stageDetails[stage] = { published: false };
58150
+ }
58151
+ }
58152
+ }
58153
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
58154
+ finally {
58155
+ try {
58156
+ if (drawStages_1_1 && !drawStages_1_1.done && (_t = drawStages_1.return)) _t.call(drawStages_1);
58157
+ }
58158
+ finally { if (e_4) throw e_4.error; }
58159
+ }
58160
+ }
58161
+ if (stagesToAdd.length || stagesToRemove.length) {
58162
+ try {
58163
+ for (var stagesToRemove_1 = (e_5 = void 0, __values(stagesToRemove)), stagesToRemove_1_1 = stagesToRemove_1.next(); !stagesToRemove_1_1.done; stagesToRemove_1_1 = stagesToRemove_1.next()) {
58164
+ var stage = stagesToRemove_1_1.value;
58165
+ stageDetails[stage] = { published: false };
58166
+ }
58167
+ }
58168
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
58169
+ finally {
58170
+ try {
58171
+ if (stagesToRemove_1_1 && !stagesToRemove_1_1.done && (_u = stagesToRemove_1.return)) _u.call(stagesToRemove_1);
58172
+ }
58173
+ finally { if (e_5) throw e_5.error; }
58174
+ }
58175
+ try {
58176
+ for (var drawStages_2 = (e_6 = void 0, __values(drawStages)), drawStages_2_1 = drawStages_2.next(); !drawStages_2_1.done; drawStages_2_1 = drawStages_2.next()) {
58177
+ var stage = drawStages_2_1.value;
58178
+ if (!stageDetails[stage]) {
58179
+ stageDetails[stage] = { published: true };
58180
+ }
58181
+ }
58182
+ }
58183
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
58184
+ finally {
58185
+ try {
58186
+ if (drawStages_2_1 && !drawStages_2_1.done && (_v = drawStages_2.return)) _v.call(drawStages_2);
58187
+ }
58188
+ finally { if (e_6) throw e_6.error; }
58189
+ }
58190
+ }
58191
+ if (stagesToAdd.length || stagesToRemove.length) {
58192
+ drawDetails[drawId].stageDetails = stageDetails;
58193
+ }
58194
+ }
58195
+ };
58196
+ try {
58197
+ for (var eventDrawIds_1 = __values(eventDrawIds), eventDrawIds_1_1 = eventDrawIds_1.next(); !eventDrawIds_1_1.done; eventDrawIds_1_1 = eventDrawIds_1.next()) {
58198
+ var drawId = eventDrawIds_1_1.value;
58199
+ var state_1 = _loop_1(drawId);
58200
+ if (typeof state_1 === "object")
58201
+ return state_1.value;
58202
+ }
57808
58203
  }
57809
- if (!structureIds &&
57810
- ((structureIdsToAdd === null || structureIdsToAdd === void 0 ? void 0 : structureIdsToAdd.length) || (structureIdsToRemove === null || structureIdsToRemove === void 0 ? void 0 : structureIdsToRemove.length))) {
57811
- structureIds = ((_g = (_f = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _f === void 0 ? void 0 : _f.PUBLIC) === null || _g === void 0 ? void 0 : _g.structureIds) || [];
58204
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
58205
+ finally {
58206
+ try {
58207
+ if (eventDrawIds_1_1 && !eventDrawIds_1_1.done && (_b = eventDrawIds_1.return)) _b.call(eventDrawIds_1);
58208
+ }
58209
+ finally { if (e_1) throw e_1.error; }
57812
58210
  }
57813
- structureIds = (structureIds !== null && structureIds !== void 0 ? structureIds : []).filter(function (structureId) {
57814
- return !(structureIdsToRemove === null || structureIdsToRemove === void 0 ? void 0 : structureIdsToRemove.length) ||
57815
- !structureIdsToRemove.includes(structureId);
58211
+ modifyEventPublishStatus({
58212
+ statusObject: { drawDetails: drawDetails },
58213
+ removePriorValues: removePriorValues,
58214
+ status: status,
58215
+ event: event,
57816
58216
  });
57817
- if (structureIdsToAdd === null || structureIdsToAdd === void 0 ? void 0 : structureIdsToAdd.length) {
57818
- structureIds = unique(structureIds.concat.apply(structureIds, __spreadArray([], __read(structureIdsToAdd), false)));
57819
- }
57820
- if (!stages && ((stagesToAdd === null || stagesToAdd === void 0 ? void 0 : stagesToAdd.length) || (stagesToRemove === null || stagesToRemove === void 0 ? void 0 : stagesToRemove.length))) {
57821
- stages = ((_j = (_h = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _h === void 0 ? void 0 : _h.PUBLIC) === null || _j === void 0 ? void 0 : _j.stages) || [];
57822
- }
57823
- stages = (stages !== null && stages !== void 0 ? stages : []).filter(function (stage) { return !(stagesToRemove === null || stagesToRemove === void 0 ? void 0 : stagesToRemove.length) || !stagesToRemove.includes(stage); });
57824
- if (stagesToAdd === null || stagesToAdd === void 0 ? void 0 : stagesToAdd.length) {
57825
- stages = unique(stages.concat.apply(stages, __spreadArray([], __read(stagesToAdd), false)));
57826
- }
57827
- var existingStatusValue = (_k = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _k === void 0 ? void 0 : _k[status];
57828
- var updatedTimeItem = {
57829
- itemValue: (_a = {},
57830
- _a[status] = __assign(__assign({}, existingStatusValue), { drawIds: drawIds, structureIds: structureIds, stages: stages }),
57831
- _a),
57832
- itemType: itemType,
57833
- };
57834
- addEventTimeItem({ event: event, timeItem: updatedTimeItem, removePriorValues: removePriorValues });
57835
58217
  var eventData = getEventData({
57836
58218
  includePositionAssignments: includePositionAssignments,
57837
58219
  usePublishState: true,
@@ -57839,13 +58221,6 @@ function publishEvent(params) {
57839
58221
  policyDefinitions: policyDefinitions,
57840
58222
  event: event,
57841
58223
  }).eventData;
57842
- // filter out drawData for unPublished draws
57843
- var publishState = (_m = (_l = eventData === null || eventData === void 0 ? void 0 : eventData.eventInfo) === null || _l === void 0 ? void 0 : _l.publish) === null || _m === void 0 ? void 0 : _m.state;
57844
- eventData.drawsData = eventData.drawsData.filter(function (_a) {
57845
- var _b;
57846
- var drawId = _a.drawId;
57847
- return (_b = publishState === null || publishState === void 0 ? void 0 : publishState.PUBLIC) === null || _b === void 0 ? void 0 : _b.drawIds.includes(drawId);
57848
- });
57849
58224
  addNotice({
57850
58225
  payload: { eventData: eventData, tournamentId: tournamentRecord.tournamentId },
57851
58226
  topic: PUBLISH_EVENT,
@@ -57862,6 +58237,7 @@ var publishingGovernor = {
57862
58237
  getDrawData: getDrawData,
57863
58238
  unPublishEventSeeding: unPublishEventSeeding,
57864
58239
  publishEventSeeding: publishEventSeeding,
58240
+ setEventDisplay: setEventDisplay,
57865
58241
  unPublishEvent: unPublishEvent,
57866
58242
  publishEvent: publishEvent,
57867
58243
  unPublishOrderOfPlay: unPublishOrderOfPlay$1,
@@ -58260,7 +58636,7 @@ var sortingConstants = { ASC: ASC, ASCENDING: ASCENDING, DESC: DESC, DESCENDING:
58260
58636
  // by default if there are no scaleValues matching the scaleAccessor then participants will be assigned in the array order of [team].individidualParticipantIds
58261
58637
  function generateLineUps(params) {
58262
58638
  var e_1, _a, e_2, _b;
58263
- var _c, _d, _e, _f, _g, _h, _j, _k;
58639
+ var _c, _d, _e, _f, _g, _h, _j;
58264
58640
  var tieFormat = params.tieFormat;
58265
58641
  var useDefaultEventRanking = params.useDefaultEventRanking, tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, scaleAccessor = params.scaleAccessor, // e.g. { scaleType: 'RANKINGS', scaleName: 'U18', accessor: 'wtnRating', sortOrder: 'ASC' }
58266
58642
  singlesOnly = params.singlesOnly, // use singles scale for doubles events
@@ -58274,25 +58650,25 @@ function generateLineUps(params) {
58274
58650
  return { error: DRAW_DEFINITION_NOT_FOUND };
58275
58651
  tieFormat =
58276
58652
  tieFormat !== null && tieFormat !== void 0 ? tieFormat : (_c = resolveTieFormat({ drawDefinition: drawDefinition, event: event })) === null || _c === void 0 ? void 0 : _c.tieFormat;
58277
- if (validateTieFormat({ tieFormat: tieFormat, eventType: (_d = params.event) === null || _d === void 0 ? void 0 : _d.eventType }).error)
58653
+ if (validateTieFormat({ tieFormat: tieFormat }).error)
58278
58654
  return { error: INVALID_TIE_FORMAT };
58279
58655
  if (typeof scaleAccessor !== 'object' && !useDefaultEventRanking)
58280
58656
  return { error: INVALID_VALUES, context: { scaleAccessor: scaleAccessor } };
58281
58657
  var lineUps = {};
58282
- 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; });
58658
+ var targetEntries = ((_e = (_d = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) !== null && _d !== void 0 ? _d : event === null || event === void 0 ? void 0 : event.entries) !== null && _e !== void 0 ? _e : []).filter(function (entry) { return (entry === null || entry === void 0 ? void 0 : entry.entryStatus) === DIRECT_ACCEPTANCE; });
58283
58659
  var participantIds = targetEntries.map(getParticipantId);
58284
- var _l = getParticipants$1({
58660
+ var _k = getParticipants$1({
58285
58661
  withIndividualParticipants: true,
58286
58662
  withScaleValues: true,
58287
58663
  tournamentRecord: tournamentRecord,
58288
- }).participants, participants = _l === void 0 ? [] : _l;
58664
+ }).participants, participants = _k === void 0 ? [] : _k;
58289
58665
  var teamParticipants = participants.filter(function (_a) {
58290
58666
  var participantId = _a.participantId;
58291
58667
  return participantIds.includes(participantId);
58292
58668
  });
58293
58669
  var formatScaleType = function (type) { return (type === RANKING$1 ? 'rankings' : 'ratings'); };
58294
- 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;
58295
- 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;
58670
+ var defaultScaleName = (_g = (_f = event === null || event === void 0 ? void 0 : event.category) === null || _f === void 0 ? void 0 : _f.categoryName) !== null && _g !== void 0 ? _g : (_h = event === null || event === void 0 ? void 0 : event.category) === null || _h === void 0 ? void 0 : _h.ageCategoryCode;
58671
+ var _l = scaleAccessor || {}, _m = _l.scaleName, scaleName = _m === void 0 ? defaultScaleName : _m, _o = _l.scaleType, scaleType = _o === void 0 ? RANKING$1 : _o, sortOrder = _l.sortOrder, accessor = _l.accessor;
58296
58672
  var formattedScaleType = formatScaleType(scaleType);
58297
58673
  var getScaleValue = function (individualParticipant, matchUpType) {
58298
58674
  var _a, _b, _c;
@@ -58320,9 +58696,9 @@ function generateLineUps(params) {
58320
58696
  var singlesScaleSort = function (a, b) { return sortMethod(a, b, SINGLES_MATCHUP); };
58321
58697
  var doublesScaleSort = function (a, b) { return sortMethod(a, b, DOUBLES_MATCHUP); };
58322
58698
  var participantIdPairs = [];
58323
- var collectionDefinitions = (_k = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) !== null && _k !== void 0 ? _k : [];
58699
+ var collectionDefinitions = (_j = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) !== null && _j !== void 0 ? _j : [];
58324
58700
  var _loop_1 = function (teamParticipant) {
58325
- var e_3, _q;
58701
+ var e_3, _p;
58326
58702
  var singlesSort = teamParticipant.individualParticipants.sort(singlesScaleSort);
58327
58703
  var doublesSort = singlesOnly
58328
58704
  ? singlesSort
@@ -58369,7 +58745,7 @@ function generateLineUps(params) {
58369
58745
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
58370
58746
  finally {
58371
58747
  try {
58372
- if (collectionDefinitions_1_1 && !collectionDefinitions_1_1.done && (_q = collectionDefinitions_1.return)) _q.call(collectionDefinitions_1);
58748
+ if (collectionDefinitions_1_1 && !collectionDefinitions_1_1.done && (_p = collectionDefinitions_1.return)) _p.call(collectionDefinitions_1);
58373
58749
  }
58374
58750
  finally { if (e_3) throw e_3.error; }
58375
58751
  }
@@ -61319,13 +61695,13 @@ function getPositionAssignments(_a) {
61319
61695
 
61320
61696
  function deleteDrawDefinitions(params) {
61321
61697
  var e_1, _a;
61322
- var _b, _c, _d, _e, _f, _g;
61698
+ var _b, _c, _d, _e, _f, _g, _h, _j;
61323
61699
  if (!params.tournamentRecord)
61324
61700
  return { error: MISSING_TOURNAMENT_RECORD };
61325
61701
  var stack = 'deleteDrawDefinitions';
61326
61702
  var drawIds = (_b = params.drawIds) !== null && _b !== void 0 ? _b : [];
61327
61703
  var event = params.event;
61328
- var _h = params.autoPublish, autoPublish = _h === void 0 ? true : _h, tournamentRecord = params.tournamentRecord, auditData = params.auditData, eventId = params.eventId, force = params.force;
61704
+ var _k = params.autoPublish, autoPublish = _k === void 0 ? true : _k, tournamentRecord = params.tournamentRecord, auditData = params.auditData, eventId = params.eventId, force = params.force;
61329
61705
  var appliedPolicies = getAppliedPolicies({ tournamentRecord: tournamentRecord, event: event }).appliedPolicies;
61330
61706
  var policyDefinitions = __assign(__assign({}, appliedPolicies), params.policyDefinitions);
61331
61707
  var drawId = Array.isArray(drawIds) ? drawIds[0] : undefined;
@@ -61365,6 +61741,9 @@ function deleteDrawDefinitions(params) {
61365
61741
  };
61366
61742
  var allowDeletionWithScoresPresent = force ||
61367
61743
  ((_d = (_c = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SCORING]) === null || _c === void 0 ? void 0 : _c.allowDeletionWithScoresPresent) === null || _d === void 0 ? void 0 : _d.drawDefinitions);
61744
+ var publishStatus = (_e = getEventPublishStatus({ event: event })) !== null && _e !== void 0 ? _e : {};
61745
+ var updatedDrawIds = (_g = (_f = publishStatus.drawIds) !== null && _f !== void 0 ? _f : (publishStatus.drawDetails && Object.keys(publishStatus.drawDetails))) !== null && _g !== void 0 ? _g : [];
61746
+ var publishedDrawsDeleted;
61368
61747
  var drawIdsWithScoresPresent = [];
61369
61748
  var filteredDrawDefinitions = event.drawDefinitions.filter(function (drawDefinition) {
61370
61749
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -61385,6 +61764,10 @@ function deleteDrawDefinitions(params) {
61385
61764
  return STRUCTURE_ENTERED_TYPES.includes(entry.entryStatus);
61386
61765
  });
61387
61766
  }
61767
+ if (updatedDrawIds.includes(drawId_1)) {
61768
+ updatedDrawIds = updatedDrawIds.filter(function (id) { return id !== drawId_1; });
61769
+ publishedDrawsDeleted = true;
61770
+ }
61388
61771
  var mainStructure = (_f = (_e = getDrawStructures({
61389
61772
  stageSequence: 1,
61390
61773
  drawDefinition: drawDefinition,
@@ -61414,6 +61797,7 @@ function deleteDrawDefinitions(params) {
61414
61797
  return { positionAssignments: positionAssignments, stageSequence: stageSequence };
61415
61798
  })
61416
61799
  : undefined;
61800
+ // TODO: conditionally add auditTrail based on policyDefinitions
61417
61801
  var audit = {
61418
61802
  action: DELETE_DRAW_DEFINITIONS,
61419
61803
  payload: {
@@ -61457,43 +61841,29 @@ function deleteDrawDefinitions(params) {
61457
61841
  }
61458
61842
  // cleanup references to drawId in schedulingProfile extension
61459
61843
  checkSchedulingProfile({ tournamentRecord: tournamentRecord });
61460
- var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
61461
- var timeItem = getTimeItem({ element: event, itemType: itemType }).timeItem;
61462
- var publishStatus = (_e = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _e === void 0 ? void 0 : _e[PUBLIC];
61463
- var publishedDrawsDeleted;
61464
- var _loop_1 = function (drawId_2) {
61465
- var _j;
61466
- var drawPublished = (_f = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.drawIds) === null || _f === void 0 ? void 0 : _f.includes(drawId_2);
61467
- if (drawPublished) {
61468
- publishedDrawsDeleted = true;
61469
- var updatedDrawIds = ((_g = publishStatus.drawIds) === null || _g === void 0 ? void 0 : _g.filter(function (publishedDrawId) { return publishedDrawId !== drawId_2; })) || [];
61470
- var timeItem_1 = {
61471
- itemType: "".concat(PUBLISH, ".").concat(STATUS$1),
61472
- itemValue: (_j = {},
61473
- _j[PUBLIC] = {
61474
- drawIds: updatedDrawIds,
61475
- },
61476
- _j),
61477
- };
61478
- var result = addEventTimeItem({ event: event, timeItem: timeItem_1 });
61479
- if (result.error)
61480
- return { value: { error: result.error } };
61481
- }
61482
- };
61483
- try {
61484
- for (var drawIds_1 = __values(drawIds), drawIds_1_1 = drawIds_1.next(); !drawIds_1_1.done; drawIds_1_1 = drawIds_1.next()) {
61485
- var drawId_2 = drawIds_1_1.value;
61486
- var state_1 = _loop_1(drawId_2);
61487
- if (typeof state_1 === "object")
61488
- return state_1.value;
61489
- }
61490
- }
61491
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
61492
- finally {
61844
+ if (publishedDrawsDeleted) {
61845
+ var drawDetails = {};
61493
61846
  try {
61494
- if (drawIds_1_1 && !drawIds_1_1.done && (_a = drawIds_1.return)) _a.call(drawIds_1);
61847
+ for (var updatedDrawIds_1 = __values(updatedDrawIds), updatedDrawIds_1_1 = updatedDrawIds_1.next(); !updatedDrawIds_1_1.done; updatedDrawIds_1_1 = updatedDrawIds_1.next()) {
61848
+ var drawId_2 = updatedDrawIds_1_1.value;
61849
+ drawDetails[drawId_2] = (_j = (_h = publishStatus.drawDetails) === null || _h === void 0 ? void 0 : _h[drawId_2]) !== null && _j !== void 0 ? _j : {
61850
+ published: true,
61851
+ };
61852
+ }
61495
61853
  }
61496
- finally { if (e_1) throw e_1.error; }
61854
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
61855
+ finally {
61856
+ try {
61857
+ if (updatedDrawIds_1_1 && !updatedDrawIds_1_1.done && (_a = updatedDrawIds_1.return)) _a.call(updatedDrawIds_1);
61858
+ }
61859
+ finally { if (e_1) throw e_1.error; }
61860
+ }
61861
+ var result = modifyEventPublishStatus({
61862
+ statusObject: { drawDetails: drawDetails },
61863
+ event: event,
61864
+ });
61865
+ if (result.error)
61866
+ return { error: result.error };
61497
61867
  }
61498
61868
  if (auditTrail.length) {
61499
61869
  addNotice({ topic: AUDIT, payload: auditTrail });
@@ -61509,9 +61879,14 @@ function deleteDrawDefinitions(params) {
61509
61879
  });
61510
61880
  addDrawDeletionTelemetry({ event: event, deletedDrawsDetail: deletedDrawsDetail, auditData: auditData });
61511
61881
  if (autoPublish && publishedDrawsDeleted) {
61512
- var result = publishEvent({ tournamentRecord: tournamentRecord, event: event, policyDefinitions: policyDefinitions });
61882
+ var result = publishEvent({
61883
+ drawIdsToRemove: drawIds,
61884
+ policyDefinitions: policyDefinitions,
61885
+ tournamentRecord: tournamentRecord,
61886
+ event: event,
61887
+ });
61513
61888
  if (result.error)
61514
- console.log('publish error', result);
61889
+ return __assign(__assign({}, SUCCESS), { info: result.error });
61515
61890
  }
61516
61891
  return __assign({}, SUCCESS);
61517
61892
  }
@@ -62161,10 +62536,7 @@ function addEvent(_a) {
62161
62536
  var eventRecord = __assign({ drawDefinitions: [], eventType: TypeEnum.Singles, entries: [], startDate: startDate, endDate: endDate }, event);
62162
62537
  if (event.eventType === TypeEnum.Team) {
62163
62538
  if (event.tieFormat) {
62164
- var result = validateTieFormat({
62165
- tieFormat: event.tieFormat,
62166
- eventType: event.eventType,
62167
- });
62539
+ var result = validateTieFormat({ tieFormat: event.tieFormat });
62168
62540
  if (result.error)
62169
62541
  return result;
62170
62542
  }
@@ -64800,7 +65172,6 @@ function generateDrawDefinition(params) {
64800
65172
  gender: event === null || event === void 0 ? void 0 : event.gender,
64801
65173
  enforceGender: enforceGender,
64802
65174
  tieFormat: tieFormat,
64803
- event: event,
64804
65175
  });
64805
65176
  if (result.error)
64806
65177
  return decorateResult({ result: result, stack: stack });
@@ -64828,10 +65199,7 @@ function generateDrawDefinition(params) {
64828
65199
  // there is no need to attach to the drawDefinition
64829
65200
  if (!equivalentInScope) {
64830
65201
  if (tieFormat) {
64831
- var result = checkTieFormat({
64832
- eventType: event.eventType,
64833
- tieFormat: tieFormat,
64834
- });
65202
+ var result = checkTieFormat({ tieFormat: tieFormat });
64835
65203
  if (result.error)
64836
65204
  return decorateResult({ result: result, stack: stack });
64837
65205
  drawDefinition.tieFormat = (_13 = result.tieFormat) !== null && _13 !== void 0 ? _13 : tieFormat;
@@ -65173,7 +65541,7 @@ function generateDrawDefinition(params) {
65173
65541
  }
65174
65542
  drawDefinition.drawName =
65175
65543
  (_33 = params.drawName) !== null && _33 !== void 0 ? _33 : (drawType && constantToString(drawType));
65176
- if (typeof voluntaryConsolation === 'object') {
65544
+ if (typeof voluntaryConsolation === 'object' && drawSize >= 4) {
65177
65545
  addVoluntaryConsolationStructure(__assign(__assign({}, voluntaryConsolation), { tournamentRecord: tournamentRecord, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, matchUpType: matchUpType }));
65178
65546
  }
65179
65547
  if (addToEvent) {
@@ -66375,10 +66743,8 @@ function bulkUpdatePublishedEventIds(_a) {
66375
66743
  if (!eventIdsMap[eventId]) {
66376
66744
  eventIdsMap[eventId] = [drawId];
66377
66745
  }
66378
- else {
66379
- if (!eventIdsMap[eventId].includes(drawId)) {
66380
- eventIdsMap[eventId].push(drawId);
66381
- }
66746
+ else if (!eventIdsMap[eventId].includes(drawId)) {
66747
+ eventIdsMap[eventId].push(drawId);
66382
66748
  }
66383
66749
  }
66384
66750
  return eventIdsMap;
@@ -66389,15 +66755,16 @@ function bulkUpdatePublishedEventIds(_a) {
66389
66755
  });
66390
66756
  var publishedEventIds = relevantEvents
66391
66757
  .filter(function (event) {
66392
- var timeItem = getEventTimeItem({
66393
- itemType: "".concat(PUBLISH, ".").concat(STATUS$1),
66394
- event: event,
66395
- }).timeItem;
66396
- var pubState = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue;
66758
+ var pubStatus = getEventPublishStatus({ event: event });
66759
+ var _a = pubStatus !== null && pubStatus !== void 0 ? pubStatus : {}, drawDetails = _a.drawDetails, drawIds = _a.drawIds;
66397
66760
  var eventId = event.eventId;
66398
66761
  var publishedDrawIds = eventIdsMap[eventId].filter(function (drawId) {
66399
- var _a, _b;
66400
- return (_b = (_a = pubState === null || pubState === void 0 ? void 0 : pubState[PUBLIC]) === null || _a === void 0 ? void 0 : _a.drawIds) === null || _b === void 0 ? void 0 : _b.includes(drawId);
66762
+ var keyedDrawIds = drawDetails
66763
+ ? Object.keys(pubStatus.drawDetails).filter(function (drawId) {
66764
+ return getDrawPublishStatus({ drawId: drawId, drawDetails: drawDetails });
66765
+ })
66766
+ : [];
66767
+ return (drawIds === null || drawIds === void 0 ? void 0 : drawIds.includes(drawId)) || keyedDrawIds.includes(drawId);
66401
66768
  });
66402
66769
  return publishedDrawIds.length;
66403
66770
  })