tods-competition-factory 1.8.46 → 1.9.0

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))
@@ -2929,7 +2955,7 @@ var matchUpFormatCode = {
2929
2955
  };
2930
2956
 
2931
2957
  function factoryVersion() {
2932
- return '1.8.46';
2958
+ return '1.9.0';
2933
2959
  }
2934
2960
 
2935
2961
  function getObjectTieFormat(obj) {
@@ -3010,34 +3036,6 @@ function decorateResult(_a) {
3010
3036
  return result !== null && result !== void 0 ? result : { success: true };
3011
3037
  }
3012
3038
 
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
3039
  var DrawTypeEnum;
3042
3040
  (function (DrawTypeEnum) {
3043
3041
  DrawTypeEnum["AdHoc"] = "AD_HOC";
@@ -3598,10 +3596,22 @@ var SexEnum;
3598
3596
  SexEnum["Other"] = "OTHER";
3599
3597
  })(SexEnum || (SexEnum = {}));
3600
3598
 
3599
+ var ANY = 'ANY';
3600
+ var MALE = 'MALE';
3601
+ var MIXED = 'MIXED';
3602
+ var OTHER$3 = 'OTHER';
3603
+ var FEMALE = 'FEMALE';
3604
+ var genderConstants = {
3605
+ ANY: ANY,
3606
+ MALE: MALE,
3607
+ FEMALE: FEMALE,
3608
+ MIXED: MIXED,
3609
+ OTHER: OTHER$3,
3610
+ };
3611
+
3601
3612
  var mixedGenderError = 'MIXED events can not contain mixed singles or { gender: ANY } collections';
3602
3613
  var anyMixedError = 'events with { gender: ANY } can not contain MIXED singles collections';
3603
3614
  function tieFormatGenderValidityCheck(params) {
3604
- var _a, _b;
3605
3615
  var stack = 'tieFormatGenderValidityCheck';
3606
3616
  var referenceGender = params.referenceGender, matchUpType = params.matchUpType, gender = params.gender;
3607
3617
  if (referenceGender &&
@@ -3613,11 +3623,8 @@ function tieFormatGenderValidityCheck(params) {
3613
3623
  context: { gender: gender },
3614
3624
  stack: stack,
3615
3625
  });
3616
- var eventType = (_a = params.eventType) !== null && _a !== void 0 ? _a : (_b = params.referenceEvent) === null || _b === void 0 ? void 0 : _b.eventType;
3617
3626
  if (referenceGender === MIXED &&
3618
- (eventType !== TEAM$2 ||
3619
- gender === ANY ||
3620
- (gender === MIXED && matchUpType !== TypeEnum.Doubles))) {
3627
+ (gender === ANY || (gender === MIXED && matchUpType !== TypeEnum.Doubles))) {
3621
3628
  return decorateResult({
3622
3629
  result: { error: INVALID_GENDER, valid: false },
3623
3630
  info: mixedGenderError,
@@ -3963,7 +3970,6 @@ function validateTieFormat(params) {
3963
3970
  var _a = validateCollectionDefinition({
3964
3971
  referenceCategory: params.category,
3965
3972
  referenceGender: params.gender,
3966
- eventType: params.eventType,
3967
3973
  collectionDefinition: collectionDefinition,
3968
3974
  checkCollectionIds: checkCollectionIds,
3969
3975
  checkCategory: checkCategory,
@@ -4013,7 +4019,7 @@ function validateTieFormat(params) {
4013
4019
  return result;
4014
4020
  }
4015
4021
  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;
4022
+ 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
4023
  referenceGender = referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender;
4018
4024
  var stack = 'validateCollectionDefinition';
4019
4025
  var errors = [];
@@ -4061,7 +4067,6 @@ function validateCollectionDefinition(_a) {
4061
4067
  }
4062
4068
  if (checkGender) {
4063
4069
  var result = tieFormatGenderValidityCheck({
4064
- eventType: eventType !== null && eventType !== void 0 ? eventType : event === null || event === void 0 ? void 0 : event.eventType,
4065
4070
  referenceGender: referenceGender,
4066
4071
  matchUpType: matchUpType,
4067
4072
  gender: gender,
@@ -4096,10 +4101,9 @@ function validateCollectionDefinition(_a) {
4096
4101
  // add collectionIds if missing
4097
4102
  function checkTieFormat(_a) {
4098
4103
  var e_1, _b;
4099
- var tieFormat = _a.tieFormat, eventType = _a.eventType;
4104
+ var tieFormat = _a.tieFormat;
4100
4105
  var result = validateTieFormat({
4101
4106
  checkCollectionIds: false,
4102
- eventType: eventType,
4103
4107
  tieFormat: tieFormat,
4104
4108
  });
4105
4109
  if (result.error)
@@ -4556,6 +4560,21 @@ function calculatePercentages(_a) {
4556
4560
  });
4557
4561
  }
4558
4562
 
4563
+ var SINGLES_MATCHUP = 'SINGLES';
4564
+ var SINGLES$1 = 'SINGLES';
4565
+ var DOUBLES_MATCHUP = 'DOUBLES';
4566
+ var DOUBLES$1 = 'DOUBLES';
4567
+ var TEAM_MATCHUP = 'TEAM';
4568
+ var TEAM$2 = 'TEAM';
4569
+ var matchUpTypes = {
4570
+ SINGLES_MATCHUP: SINGLES_MATCHUP,
4571
+ SINGLES: SINGLES$1,
4572
+ DOUBLES_MATCHUP: DOUBLES_MATCHUP,
4573
+ DOUBLES: DOUBLES$1,
4574
+ TEAM_MATCHUP: TEAM_MATCHUP,
4575
+ TEAM: TEAM$2,
4576
+ };
4577
+
4559
4578
  function getParticipantResults(_a) {
4560
4579
  var e_1, _b, e_2, _c, e_3, _d;
4561
4580
  var _e, _f, _g, _h, _j, _k;
@@ -5495,6 +5514,7 @@ function tallyParticipantResults(_a) {
5495
5514
  return result;
5496
5515
  }
5497
5516
 
5517
+ var ACTIVE_SUSPENSION = 'activeSuspension';
5498
5518
  var APPLIED_POLICIES = 'appliedPolicies';
5499
5519
  var AUDIT_POSITION_ACTIONS = 'positionActions';
5500
5520
  var CONTEXT = 'context';
@@ -5506,6 +5526,7 @@ var DRAW_DELETIONS = 'drawDeletions';
5506
5526
  var DRAW_PROFILE = 'drawProfile';
5507
5527
  var ENTRY_PROFILE = 'entryProfile';
5508
5528
  var EVENT_PROFILE = 'eventProfile';
5529
+ var EVENT_WITHDRAWAL_REQUESTS = 'eventWithdrawalRequests';
5509
5530
  var FACTORY$1 = 'factory';
5510
5531
  var FLIGHT_PROFILE = 'flightProfile';
5511
5532
  var GROUPING_ATTRIBUTE = 'groupingAttribute';
@@ -5524,6 +5545,7 @@ var SUB_ORDER = 'subOrder';
5524
5545
  var TALLY = 'tally';
5525
5546
  var TIE_FORMAT_MODIFICATIONS = 'tieFormatModification';
5526
5547
  var extensionConstants = {
5548
+ ACTIVE_SUSPENSION: ACTIVE_SUSPENSION,
5527
5549
  APPLIED_POLICIES: APPLIED_POLICIES,
5528
5550
  AUDIT_POSITION_ACTIONS: AUDIT_POSITION_ACTIONS,
5529
5551
  CONTEXT: CONTEXT, // used to capture, e.g. context in which a venue was added
@@ -5535,6 +5557,7 @@ var extensionConstants = {
5535
5557
  DRAW_PROFILE: DRAW_PROFILE,
5536
5558
  ENTRY_PROFILE: ENTRY_PROFILE, // used for drawGeneration; not relevant for anonymized tournaments
5537
5559
  EVENT_PROFILE: EVENT_PROFILE,
5560
+ EVENT_WITHDRAWAL_REQUESTS: EVENT_WITHDRAWAL_REQUESTS,
5538
5561
  FLIGHT_PROFILE: FLIGHT_PROFILE,
5539
5562
  GROUPING_ATTRIBUTE: GROUPING_ATTRIBUTE, // for generating teams; not relevant for anonymized tournaments
5540
5563
  LINEUPS: LINEUPS,
@@ -7301,8 +7324,8 @@ var eventConstants = {
7301
7324
 
7302
7325
  function getMatchUpScheduleDetails(_a) {
7303
7326
  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;
7327
+ var _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
7328
+ 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
7329
  if (!matchUp)
7307
7330
  return { error: MISSING_MATCHUP };
7308
7331
  // matchUpType is required to derive averageMatchUpMinutes and recoveryMinutes.
@@ -7330,11 +7353,11 @@ function getMatchUpScheduleDetails(_a) {
7330
7353
  (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpType) ||
7331
7354
  ((event === null || event === void 0 ? void 0 : event.eventType) !== TEAM$1 && (event === null || event === void 0 ? void 0 : event.eventType));
7332
7355
  }
7333
- var _q = matchUpDuration({ matchUp: matchUp }), milliseconds = _q.milliseconds, time = _q.time;
7356
+ var _v = matchUpDuration({ matchUp: matchUp }), milliseconds = _v.milliseconds, time = _v.time;
7334
7357
  var startTime = matchUpStartTime({ matchUp: matchUp }).startTime;
7335
7358
  var endTime = matchUpEndTime({ matchUp: matchUp }).endTime;
7336
7359
  var schedule;
7337
- var _r = scheduleVisibilityFilters !== null && scheduleVisibilityFilters !== void 0 ? scheduleVisibilityFilters : {}, visibilityThreshold = _r.visibilityThreshold, eventIds = _r.eventIds, drawIds = _r.drawIds;
7360
+ var _w = scheduleVisibilityFilters !== null && scheduleVisibilityFilters !== void 0 ? scheduleVisibilityFilters : {}, visibilityThreshold = _w.visibilityThreshold, eventIds = _w.eventIds, drawIds = _w.drawIds;
7338
7361
  if ((!eventIds || eventIds.includes(matchUp.eventId)) &&
7339
7362
  (!drawIds || drawIds.includes(matchUp.drawId))) {
7340
7363
  var scheduleSource = { matchUp: matchUp, visibilityThreshold: visibilityThreshold };
@@ -7391,8 +7414,8 @@ function getMatchUpScheduleDetails(_a) {
7391
7414
  allocatedCourt.courtName = courtInfo_1 === null || courtInfo_1 === void 0 ? void 0 : courtInfo_1.courtName;
7392
7415
  };
7393
7416
  try {
7394
- for (var _s = __values(allocatedCourts || []), _t = _s.next(); !_t.done; _t = _s.next()) {
7395
- var allocatedCourt = _t.value;
7417
+ for (var _x = __values(allocatedCourts || []), _y = _x.next(); !_y.done; _y = _x.next()) {
7418
+ var allocatedCourt = _y.value;
7396
7419
  var state_1 = _loop_1(allocatedCourt);
7397
7420
  if (state_1 === "break")
7398
7421
  break;
@@ -7401,7 +7424,7 @@ function getMatchUpScheduleDetails(_a) {
7401
7424
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
7402
7425
  finally {
7403
7426
  try {
7404
- if (_t && !_t.done && (_g = _s.return)) _g.call(_s);
7427
+ if (_y && !_y.done && (_g = _x.return)) _g.call(_x);
7405
7428
  }
7406
7429
  finally { if (e_1) throw e_1.error; }
7407
7430
  }
@@ -7430,16 +7453,36 @@ function getMatchUpScheduleDetails(_a) {
7430
7453
  }
7431
7454
  else {
7432
7455
  schedule = definedAttributes({
7433
- time: time,
7456
+ milliseconds: milliseconds,
7434
7457
  startTime: startTime,
7435
7458
  endTime: endTime,
7436
- milliseconds: milliseconds,
7459
+ time: time,
7437
7460
  });
7438
7461
  }
7439
- var hasCompletedStatus = matchUp.matchUpStatus &&
7440
- completedMatchUpStatuses.includes(matchUp.matchUpStatus);
7441
7462
  var scheduledDate = scheduledMatchUpDate({ matchUp: matchUp }).scheduledDate;
7442
7463
  var scheduledTime = scheduledMatchUpTime({ matchUp: matchUp }).scheduledTime;
7464
+ if (usePublishState && ((_q = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.displaySettings) === null || _q === void 0 ? void 0 : _q.draws)) {
7465
+ var drawSettings = publishStatus.displaySettings.draws;
7466
+ 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;
7467
+ if (scheduleDetails) {
7468
+ 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;
7469
+ if (scheduleAttributes) {
7470
+ // set all attributes to true
7471
+ var template = Object.assign.apply(Object, __spreadArray(__spreadArray([{}], __read(Object.keys(schedule).map(function (key) {
7472
+ var _a;
7473
+ return (_a = {}, _a[key] = true, _a);
7474
+ })), false), [
7475
+ // overwrite with publishStatus attributes
7476
+ scheduleAttributes], false));
7477
+ schedule = attributeFilter({
7478
+ source: schedule,
7479
+ template: template,
7480
+ });
7481
+ }
7482
+ }
7483
+ }
7484
+ var hasCompletedStatus = matchUp.matchUpStatus &&
7485
+ completedMatchUpStatuses.includes(matchUp.matchUpStatus);
7443
7486
  var endDate = (hasCompletedStatus &&
7444
7487
  (extractDate(endTime) ||
7445
7488
  extractDate(scheduledDate) ||
@@ -9546,7 +9589,7 @@ function getSeeding(_a) {
9546
9589
 
9547
9590
  function getAllStructureMatchUps(_a) {
9548
9591
  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;
9592
+ 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
9593
  var collectionPositionMatchUps = {}, roundMatchUps = {};
9551
9594
  tournamentParticipants =
9552
9595
  tournamentParticipants !== null && tournamentParticipants !== void 0 ? tournamentParticipants : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
@@ -9673,6 +9716,8 @@ function getAllStructureMatchUps(_a) {
9673
9716
  roundNamingProfile: roundNamingProfile,
9674
9717
  initialRoundOfPlay: initialRoundOfPlay,
9675
9718
  appliedPolicies: appliedPolicies,
9719
+ usePublishState: usePublishState,
9720
+ publishStatus: publishStatus,
9676
9721
  isRoundRobin: isRoundRobin,
9677
9722
  roundProfile: roundProfile,
9678
9723
  matchUp: matchUp,
@@ -9728,7 +9773,7 @@ function getAllStructureMatchUps(_a) {
9728
9773
  };
9729
9774
  function addMatchUpContext(_a) {
9730
9775
  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;
9776
+ 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
9777
  additionalContext = additionalContext !== null && additionalContext !== void 0 ? additionalContext : {};
9733
9778
  var tieFormat = (_b = resolveTieFormat({
9734
9779
  drawDefinition: drawDefinition,
@@ -9752,8 +9797,10 @@ function getAllStructureMatchUps(_a) {
9752
9797
  scheduleVisibilityFilters: scheduleVisibilityFilters,
9753
9798
  afterRecoveryTimes: afterRecoveryTimes,
9754
9799
  tournamentRecord: tournamentRecord,
9800
+ usePublishState: usePublishState,
9755
9801
  scheduleTiming: scheduleTiming,
9756
9802
  matchUpFormat: matchUpFormat,
9803
+ publishStatus: publishStatus,
9757
9804
  matchUpType: matchUpType,
9758
9805
  matchUp: matchUp,
9759
9806
  event: event,
@@ -9899,7 +9946,7 @@ function getAllStructureMatchUps(_a) {
9899
9946
  Object.assign(matchUpWithContext, makeDeepCopy({ sides: sides }, true, true));
9900
9947
  }
9901
9948
  if (tournamentParticipants && matchUpWithContext.sides) {
9902
- var participantAttributes_1 = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_PARTICIPANT];
9949
+ var participantAttributes_1 = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_PARTICIPANT];
9903
9950
  var getMappedParticipant_1 = function (participantId) {
9904
9951
  var _a;
9905
9952
  var participant = (_a = participantMap === null || participantMap === void 0 ? void 0 : participantMap[participantId]) === null || _a === void 0 ? void 0 : _a.participant;
@@ -10017,6 +10064,8 @@ function getAllStructureMatchUps(_a) {
10017
10064
  additionalContext: additionalContext,
10018
10065
  appliedPolicies: appliedPolicies,
10019
10066
  isCollectionBye: isCollectionBye_1,
10067
+ usePublishState: usePublishState,
10068
+ publishStatus: publishStatus,
10020
10069
  matchUpTieId: matchUpTieId,
10021
10070
  isRoundRobin: isRoundRobin,
10022
10071
  roundProfile: roundProfile,
@@ -10269,7 +10318,7 @@ function generateTieMatchUpScore(params) {
10269
10318
  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
10319
  if (!tieFormat)
10271
10320
  return { error: MISSING_TIE_FORMAT };
10272
- var result = validateTieFormat({ tieFormat: tieFormat, eventType: event === null || event === void 0 ? void 0 : event.eventType });
10321
+ var result = validateTieFormat({ tieFormat: tieFormat });
10273
10322
  if (result.error)
10274
10323
  return result;
10275
10324
  var collectionDefinitions = (tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) || [];
@@ -11439,7 +11488,7 @@ function getUpcomingInfo(params) {
11439
11488
  }
11440
11489
 
11441
11490
  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;
11491
+ 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
11492
  if (!structure && structureId) {
11444
11493
  (structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure);
11445
11494
  }
@@ -11450,13 +11499,15 @@ function getStructureMatchUps(_a) {
11450
11499
  afterRecoveryTimes: afterRecoveryTimes,
11451
11500
  policyDefinitions: policyDefinitions,
11452
11501
  tournamentRecord: tournamentRecord,
11453
- drawDefinition: drawDefinition,
11502
+ usePublishState: usePublishState,
11454
11503
  matchUpFilters: matchUpFilters,
11455
11504
  contextFilters: contextFilters,
11456
- contextProfile: contextProfile,
11457
11505
  contextContent: contextContent,
11458
11506
  participantMap: participantMap,
11459
11507
  scheduleTiming: scheduleTiming,
11508
+ publishStatus: publishStatus,
11509
+ contextProfile: contextProfile,
11510
+ drawDefinition: drawDefinition,
11460
11511
  exitProfiles: exitProfiles,
11461
11512
  matchUpsMap: matchUpsMap,
11462
11513
  structure: structure,
@@ -11545,7 +11596,7 @@ function getDrawMatchUps(params) {
11545
11596
  if (!(params === null || params === void 0 ? void 0 : params.drawDefinition))
11546
11597
  return { error: MISSING_DRAW_DEFINITION };
11547
11598
  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;
11599
+ 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
11600
  var allAbandonedMatchUps = [];
11550
11601
  var allCompletedMatchUps = [];
11551
11602
  var allUpcomingMatchUps = [];
@@ -11595,9 +11646,11 @@ function getDrawMatchUps(params) {
11595
11646
  afterRecoveryTimes: afterRecoveryTimes,
11596
11647
  policyDefinitions: policyDefinitions,
11597
11648
  tournamentRecord: tournamentRecord,
11649
+ usePublishState: usePublishState,
11650
+ contextContent: contextContent,
11598
11651
  participantMap: participantMap,
11599
11652
  scheduleTiming: scheduleTiming,
11600
- contextContent: contextContent,
11653
+ publishStatus: publishStatus,
11601
11654
  contextProfile: contextProfile,
11602
11655
  drawDefinition: drawDefinition,
11603
11656
  exitProfiles: exitProfiles,
@@ -17257,70 +17310,6 @@ var fixtures = {
17257
17310
  flagIOC: flagIOC,
17258
17311
  };
17259
17312
 
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
17313
  function getTimeItem(_a) {
17325
17314
  var returnPreviousValues = _a.returnPreviousValues, itemSubTypes = _a.itemSubTypes, itemType = _a.itemType, element = _a.element;
17326
17315
  if (!element)
@@ -17414,6 +17403,80 @@ function getParticipantTimeItem(_a) {
17414
17403
  return (timeItem && { timeItem: timeItem, previousItems: previousItems }) || { info: info };
17415
17404
  }
17416
17405
 
17406
+ function getEventPublishStatus(_a) {
17407
+ var _b, _c, _d;
17408
+ var event = _a.event, _e = _a.status, status = _e === void 0 ? PUBLIC : _e;
17409
+ var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
17410
+ return (_d = (_c = (_b = getEventTimeItem({
17411
+ itemType: itemType,
17412
+ event: event,
17413
+ })) === null || _b === void 0 ? void 0 : _b.timeItem) === null || _c === void 0 ? void 0 : _c.itemValue) === null || _d === void 0 ? void 0 : _d[status];
17414
+ }
17415
+
17416
+ function addNationalityCode(_a) {
17417
+ var participant = _a.participant, withISO2 = _a.withISO2, withIOC = _a.withIOC;
17418
+ var person = participant.person, individualParticipants = participant.individualParticipants;
17419
+ var persons = [person, individualParticipants === null || individualParticipants === void 0 ? void 0 : individualParticipants.map(function (_a) {
17420
+ var person = _a.person;
17421
+ return person;
17422
+ })]
17423
+ .flat()
17424
+ .filter(Boolean);
17425
+ function annotatePerson(person) {
17426
+ var nationalityCode = (person || {}).nationalityCode;
17427
+ if (nationalityCode) {
17428
+ var country = countries.find(function (_a) {
17429
+ var iso = _a.iso;
17430
+ return iso === nationalityCode;
17431
+ });
17432
+ if (withIOC && (country === null || country === void 0 ? void 0 : country.ioc) && !person.iocNationalityCode)
17433
+ person.iocNationalityCode = country.ioc;
17434
+ if (withISO2 && (country === null || country === void 0 ? void 0 : country.iso2) && !person.iso2NationalityCode)
17435
+ person.iso2NationalityCode = country.iso2;
17436
+ if ((country === null || country === void 0 ? void 0 : country.label) && !person.countryName)
17437
+ person.countryName = country.label;
17438
+ }
17439
+ }
17440
+ persons.forEach(annotatePerson);
17441
+ }
17442
+
17443
+ function addIndividualParticipants(_a) {
17444
+ var e_1, _b, e_2, _c;
17445
+ var _d;
17446
+ var participantMap = _a.participantMap, template = _a.template;
17447
+ var participantObjects = Object.values(participantMap);
17448
+ try {
17449
+ for (var participantObjects_1 = __values(participantObjects), participantObjects_1_1 = participantObjects_1.next(); !participantObjects_1_1.done; participantObjects_1_1 = participantObjects_1.next()) {
17450
+ var participantObject = participantObjects_1_1.value;
17451
+ var participant = participantObject.participant;
17452
+ if ((_d = participant.individualParticipantIds) === null || _d === void 0 ? void 0 : _d.length) {
17453
+ participant.individualParticipants = [];
17454
+ try {
17455
+ for (var _e = (e_2 = void 0, __values(participant.individualParticipantIds)), _f = _e.next(); !_f.done; _f = _e.next()) {
17456
+ var participantId = _f.value;
17457
+ var source = participantMap[participantId].participant;
17458
+ participant.individualParticipants.push(template ? attributeFilter({ template: template, source: source }) : source);
17459
+ }
17460
+ }
17461
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
17462
+ finally {
17463
+ try {
17464
+ if (_f && !_f.done && (_c = _e.return)) _c.call(_e);
17465
+ }
17466
+ finally { if (e_2) throw e_2.error; }
17467
+ }
17468
+ }
17469
+ }
17470
+ }
17471
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
17472
+ finally {
17473
+ try {
17474
+ if (participantObjects_1_1 && !participantObjects_1_1.done && (_b = participantObjects_1.return)) _b.call(participantObjects_1);
17475
+ }
17476
+ finally { if (e_1) throw e_1.error; }
17477
+ }
17478
+ }
17479
+
17417
17480
  var _a$4, _b;
17418
17481
  var typeMap = (_a$4 = {},
17419
17482
  _a$4[GROUP] = 'groupParticipantIds',
@@ -17801,7 +17864,7 @@ function tournamentMatchUps(params) {
17801
17864
  if (!(params === null || params === void 0 ? void 0 : params.tournamentRecord))
17802
17865
  return { error: MISSING_TOURNAMENT_RECORD };
17803
17866
  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;
17867
+ 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
17868
  var tournamentId = (_a = params.tournamentId) !== null && _a !== void 0 ? _a : tournamentRecord.tournamentId;
17806
17869
  var events = (_b = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.events) !== null && _b !== void 0 ? _b : [];
17807
17870
  var _e = hydrateParticipants({
@@ -17836,6 +17899,7 @@ function tournamentMatchUps(params) {
17836
17899
  afterRecoveryTimes: afterRecoveryTimes,
17837
17900
  policyDefinitions: policyDefinitions,
17838
17901
  tournamentRecord: tournamentRecord,
17902
+ usePublishState: usePublishState,
17839
17903
  contextFilters: contextFilters,
17840
17904
  contextProfile: contextProfile,
17841
17905
  contextContent: contextContent,
@@ -17867,7 +17931,7 @@ function eventMatchUps(params) {
17867
17931
  var _a;
17868
17932
  var _b, _c, _d;
17869
17933
  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;
17934
+ 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
17935
  if (!event)
17872
17936
  return { error: MISSING_EVENT };
17873
17937
  var eventId = event.eventId, eventName = event.eventName, endDate = event.endDate;
@@ -17897,6 +17961,7 @@ function eventMatchUps(params) {
17897
17961
  contextProfile: contextProfile,
17898
17962
  event: event,
17899
17963
  });
17964
+ var publishStatus = getEventPublishStatus({ event: event });
17900
17965
  var drawDefinitions = (_d = event.drawDefinitions) !== null && _d !== void 0 ? _d : [];
17901
17966
  var eventResult = drawDefinitions.reduce(function (results, drawDefinition) {
17902
17967
  var drawMatchUpsResult = getDrawMatchUps({
@@ -17908,12 +17973,14 @@ function eventMatchUps(params) {
17908
17973
  afterRecoveryTimes: afterRecoveryTimes,
17909
17974
  policyDefinitions: policyDefinitions,
17910
17975
  tournamentRecord: tournamentRecord,
17911
- drawDefinition: drawDefinition,
17976
+ usePublishState: usePublishState,
17912
17977
  contextContent: contextContent,
17913
17978
  contextFilters: contextFilters,
17914
- contextProfile: contextProfile,
17915
17979
  matchUpFilters: matchUpFilters,
17916
17980
  participantMap: participantMap,
17981
+ publishStatus: publishStatus,
17982
+ contextProfile: contextProfile,
17983
+ drawDefinition: drawDefinition,
17917
17984
  nextMatchUps: nextMatchUps,
17918
17985
  inContext: inContext,
17919
17986
  event: event,
@@ -17933,7 +18000,7 @@ function eventMatchUps(params) {
17933
18000
  function drawMatchUps$1(_a) {
17934
18001
  var _b;
17935
18002
  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;
18003
+ 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
18004
  var _f = event !== null && event !== void 0 ? event : {}, eventId = _f.eventId, eventName = _f.eventName, endDate = _f.endDate;
17938
18005
  var additionalContext = __assign(__assign({}, context), definedAttributes({
17939
18006
  eventId: eventId,
@@ -17971,12 +18038,14 @@ function drawMatchUps$1(_a) {
17971
18038
  afterRecoveryTimes: afterRecoveryTimes,
17972
18039
  policyDefinitions: policyDefinitions,
17973
18040
  tournamentRecord: tournamentRecord,
18041
+ usePublishState: usePublishState,
17974
18042
  participantMap: participantMap,
17975
- drawDefinition: drawDefinition,
17976
- matchUpFilters: matchUpFilters,
18043
+ contextContent: contextContent,
17977
18044
  contextFilters: contextFilters,
18045
+ matchUpFilters: matchUpFilters,
18046
+ publishStatus: publishStatus,
17978
18047
  contextProfile: contextProfile,
17979
- contextContent: contextContent,
18048
+ drawDefinition: drawDefinition,
17980
18049
  nextMatchUps: nextMatchUps,
17981
18050
  inContext: inContext,
17982
18051
  event: event,
@@ -18732,7 +18801,7 @@ function allCompetitionMatchUps(_a) {
18732
18801
  return { matchUps: competitionMatchUps };
18733
18802
  }
18734
18803
  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;
18804
+ 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
18805
  if (typeof tournamentRecords !== 'object' ||
18737
18806
  !Object.keys(tournamentRecords).length)
18738
18807
  return { error: MISSING_TOURNAMENT_RECORDS };
@@ -18744,6 +18813,7 @@ function competitionMatchUps(_a) {
18744
18813
  participantsProfile: participantsProfile,
18745
18814
  policyDefinitions: policyDefinitions,
18746
18815
  tournamentRecord: tournamentRecord,
18816
+ usePublishState: usePublishState,
18747
18817
  matchUpFilters: matchUpFilters,
18748
18818
  contextFilters: contextFilters,
18749
18819
  nextMatchUps: nextMatchUps,
@@ -24826,6 +24896,14 @@ function getMatchUpDailyLimits(_a) {
24826
24896
  return { matchUpDailyLimits: dailyLimits };
24827
24897
  }
24828
24898
 
24899
+ function getDrawPublishStatus(_a) {
24900
+ var _b;
24901
+ var drawDetails = _a.drawDetails, drawId = _a.drawId;
24902
+ // TODO: check details.embargo
24903
+ var details = (_b = drawDetails === null || drawDetails === void 0 ? void 0 : drawDetails[drawId]) === null || _b === void 0 ? void 0 : _b.publishingDetail;
24904
+ return details === null || details === void 0 ? void 0 : details.published;
24905
+ }
24906
+
24829
24907
  function scheduledSortedMatchUps(_a) {
24830
24908
  var e_1, _b, e_2, _c, e_3, _d, e_4, _e;
24831
24909
  var schedulingProfile = _a.schedulingProfile, _f = _a.matchUps, matchUps = _f === void 0 ? [] : _f;
@@ -24995,26 +25073,28 @@ function courtGridRows(_a) {
24995
25073
  }
24996
25074
 
24997
25075
  function competitionScheduleMatchUps(params) {
24998
- var _a, _b, _c, _d, _e, _f, _g;
25076
+ var _a;
25077
+ var _b, _c, _d, _e, _f, _g, _h, _j;
24999
25078
  if (typeof (params === null || params === void 0 ? void 0 : params.tournamentRecords) !== 'object' ||
25000
25079
  !Object.keys(params === null || params === void 0 ? void 0 : params.tournamentRecords).length)
25001
25080
  return { error: MISSING_TOURNAMENT_RECORDS };
25002
- var _h = getVenuesAndCourts(params), courts = _h.courts, venues = _h.venues;
25081
+ var _k = getVenuesAndCourts(params), courts = _k.courts, venues = _k.venues;
25003
25082
  var getResult = getSchedulingProfile$1(params);
25004
25083
  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({
25084
+ 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;
25085
+ // PUBLISH.STATUS is attached at the tournament level by `publishOrderOfPlay`
25086
+ var tournamentPublishStatus = usePublishState
25087
+ ? (_c = (_b = getTournamentTimeItem({
25008
25088
  tournamentRecord: tournamentRecords[activeTournamentId !== null && activeTournamentId !== void 0 ? activeTournamentId : getTournamentId()],
25009
25089
  itemType: "".concat(PUBLISH, ".").concat(STATUS$1),
25010
- }).timeItem
25090
+ }).timeItem) === null || _b === void 0 ? void 0 : _b.itemValue) === null || _c === void 0 ? void 0 : _c[status]
25011
25091
  : undefined;
25012
- var publishStatus = (_a = timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue) === null || _a === void 0 ? void 0 : _a[status];
25013
25092
  var allCompletedMatchUps = alwaysReturnCompleted
25014
25093
  ? competitionMatchUps(__assign(__assign({}, params), { matchUpFilters: __assign(__assign({}, params.matchUpFilters), { matchUpStatuses: [MatchUpStatusEnum.Completed] }), contextFilters: params.contextFilters })).completedMatchUps
25015
25094
  : [];
25095
+ // if { usePublishState: true } only return non-completed matchUps if there is orderOfPlay detail
25016
25096
  if (usePublishState &&
25017
- (!publishStatus || !Object.keys(publishStatus).length)) {
25097
+ (!tournamentPublishStatus || !Object.keys(tournamentPublishStatus).length)) {
25018
25098
  return {
25019
25099
  completedMatchUps: allCompletedMatchUps,
25020
25100
  dateMatchUps: [],
@@ -25022,57 +25102,62 @@ function competitionScheduleMatchUps(params) {
25022
25102
  venues: venues,
25023
25103
  };
25024
25104
  }
25025
- var publishedDrawIds = usePublishState
25026
- ? getCompetitionPublishedDrawIds({ tournamentRecords: tournamentRecords }).drawIds
25027
- : undefined;
25105
+ var publishedDrawIds, detailsMap;
25106
+ if (usePublishState) {
25107
+ (_a = getCompetitionPublishedDrawDetails({
25108
+ tournamentRecords: tournamentRecords,
25109
+ }), publishedDrawIds = _a.drawIds, detailsMap = _a.detailsMap);
25110
+ }
25028
25111
  if (publishedDrawIds === null || publishedDrawIds === void 0 ? void 0 : publishedDrawIds.length) {
25029
25112
  if (!params.contextFilters)
25030
25113
  params.contextFilters = {};
25031
- if (!((_b = params.contextFilters) === null || _b === void 0 ? void 0 : _b.drawIds)) {
25114
+ if (!((_d = params.contextFilters) === null || _d === void 0 ? void 0 : _d.drawIds)) {
25032
25115
  params.contextFilters.drawIds = publishedDrawIds;
25033
25116
  }
25034
25117
  else {
25035
25118
  params.contextFilters.drawIds = params.contextFilters.drawIds.filter(function (drawId) { return publishedDrawIds.includes(drawId); });
25036
25119
  }
25037
25120
  }
25038
- if ((_c = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.eventIds) === null || _c === void 0 ? void 0 : _c.length) {
25121
+ if ((_e = tournamentPublishStatus === null || tournamentPublishStatus === void 0 ? void 0 : tournamentPublishStatus.eventIds) === null || _e === void 0 ? void 0 : _e.length) {
25039
25122
  if (!params.matchUpFilters)
25040
25123
  params.matchUpFilters = {};
25041
- if ((_d = params.matchUpFilters) === null || _d === void 0 ? void 0 : _d.eventIds) {
25124
+ if ((_f = params.matchUpFilters) === null || _f === void 0 ? void 0 : _f.eventIds) {
25042
25125
  if (!params.matchUpFilters.eventIds.length) {
25043
- params.matchUpFilters.eventIds = publishStatus.eventIds;
25126
+ params.matchUpFilters.eventIds = tournamentPublishStatus.eventIds;
25044
25127
  }
25045
25128
  else {
25046
- params.matchUpFilters.eventIds = params.matchUpFilters.eventIds.filter(function (eventId) { return publishStatus.eventIds.includes(eventId); });
25129
+ params.matchUpFilters.eventIds = params.matchUpFilters.eventIds.filter(function (eventId) { return tournamentPublishStatus.eventIds.includes(eventId); });
25047
25130
  }
25048
25131
  }
25049
25132
  else {
25050
- params.matchUpFilters.eventIds = publishStatus.eventIds;
25133
+ params.matchUpFilters.eventIds = tournamentPublishStatus.eventIds;
25051
25134
  }
25052
25135
  }
25053
- if ((_e = publishStatus === null || publishStatus === void 0 ? void 0 : publishStatus.scheduledDates) === null || _e === void 0 ? void 0 : _e.length) {
25136
+ if ((_g = tournamentPublishStatus === null || tournamentPublishStatus === void 0 ? void 0 : tournamentPublishStatus.scheduledDates) === null || _g === void 0 ? void 0 : _g.length) {
25054
25137
  if (!params.matchUpFilters)
25055
25138
  params.matchUpFilters = {};
25056
25139
  if (params.matchUpFilters.scheduledDates) {
25057
25140
  if (!params.matchUpFilters.scheduledDates.length) {
25058
- params.matchUpFilters.scheduledDates = publishStatus.scheduledDates;
25141
+ params.matchUpFilters.scheduledDates =
25142
+ tournamentPublishStatus.scheduledDates;
25059
25143
  }
25060
25144
  else {
25061
25145
  params.matchUpFilters.scheduledDates =
25062
25146
  params.matchUpFilters.scheduledDates.filter(function (scheduledDate) {
25063
- return publishStatus.scheduledDates.includes(scheduledDate);
25147
+ return tournamentPublishStatus.scheduledDates.includes(scheduledDate);
25064
25148
  });
25065
25149
  }
25066
25150
  }
25067
25151
  else {
25068
- params.matchUpFilters.scheduledDates = publishStatus.scheduledDates;
25152
+ params.matchUpFilters.scheduledDates =
25153
+ tournamentPublishStatus.scheduledDates;
25069
25154
  }
25070
25155
  }
25071
25156
  // optimization: if all completed matchUps have already been retrieved, skip the hydration process
25072
25157
  if (alwaysReturnCompleted) {
25073
25158
  if (!params.matchUpFilters)
25074
25159
  params.matchUpFilters = {};
25075
- if ((_g = (_f = params.matchUpFilters) === null || _f === void 0 ? void 0 : _f.excludeMatchUpStatuses) === null || _g === void 0 ? void 0 : _g.length) {
25160
+ if ((_j = (_h = params.matchUpFilters) === null || _h === void 0 ? void 0 : _h.excludeMatchUpStatuses) === null || _j === void 0 ? void 0 : _j.length) {
25076
25161
  if (!params.matchUpFilters.excludeMatchUpStatuses.includes(COMPLETED$1)) {
25077
25162
  params.matchUpFilters.excludeMatchUpStatuses.push(COMPLETED$1);
25078
25163
  }
@@ -25081,8 +25166,47 @@ function competitionScheduleMatchUps(params) {
25081
25166
  params.matchUpFilters.excludeMatchUpStatuses = [COMPLETED$1];
25082
25167
  }
25083
25168
  }
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;
25169
+ 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
25170
  var relevantMatchUps = __spreadArray(__spreadArray([], __read((upcomingMatchUps !== null && upcomingMatchUps !== void 0 ? upcomingMatchUps : [])), false), __read((pendingMatchUps !== null && pendingMatchUps !== void 0 ? pendingMatchUps : [])), false);
25171
+ // add any stage or structure filtering
25172
+ if (detailsMap && Object.keys(detailsMap).length) {
25173
+ relevantMatchUps = relevantMatchUps.filter(function (matchUp) {
25174
+ var drawId = matchUp.drawId, structureId = matchUp.structureId, stage = matchUp.stage;
25175
+ if (!detailsMap[drawId])
25176
+ return false;
25177
+ if (detailsMap[drawId].stageDetails) {
25178
+ var stageKeys = Object.keys(detailsMap[drawId].stageDetails);
25179
+ var unpublishedStages = stageKeys.filter(function (stage) { return !detailsMap[drawId].stageDetails[stage].published; });
25180
+ var publishedStages = stageKeys.filter(function (stage) { return detailsMap[drawId].stageDetails[stage].published; });
25181
+ if (unpublishedStages.length && unpublishedStages.includes(stage))
25182
+ return false;
25183
+ if (publishedStages.length && publishedStages.includes(stage))
25184
+ return true;
25185
+ return (unpublishedStages.length &&
25186
+ !unpublishedStages.includes(stage) &&
25187
+ !publishedStages.length);
25188
+ }
25189
+ if (detailsMap[drawId].structureDetails) {
25190
+ var structureIdKeys = Object.keys(detailsMap[drawId].structureDetails);
25191
+ var unpublishedStructureIds = structureIdKeys.filter(function (structureId) {
25192
+ return !detailsMap[drawId].structureDetails[structureId].published;
25193
+ });
25194
+ var publishedStructureIds = structureIdKeys.filter(function (structureId) {
25195
+ return detailsMap[drawId].structureDetails[structureId].published;
25196
+ });
25197
+ if (unpublishedStructureIds.length &&
25198
+ unpublishedStructureIds.includes(structureId))
25199
+ return false;
25200
+ if (publishedStructureIds.length &&
25201
+ publishedStructureIds.includes(structureId))
25202
+ return true;
25203
+ return (unpublishedStructureIds.length &&
25204
+ !unpublishedStructureIds.includes(structureId) &&
25205
+ !publishedStructureIds.length);
25206
+ }
25207
+ return true;
25208
+ });
25209
+ }
25086
25210
  var dateMatchUps = sortDateMatchUps
25087
25211
  ? scheduledSortedMatchUps({ matchUps: relevantMatchUps, schedulingProfile: schedulingProfile })
25088
25212
  : relevantMatchUps;
@@ -25092,19 +25216,19 @@ function competitionScheduleMatchUps(params) {
25092
25216
  return __assign({ surfaceCategory: (_a = court === null || court === void 0 ? void 0 : court.surfaceCategory) !== null && _a !== void 0 ? _a : '', matchUps: matchUps }, court);
25093
25217
  });
25094
25218
  var result = {
25095
- courtsData: courtsData,
25096
25219
  completedMatchUps: alwaysReturnCompleted
25097
25220
  ? allCompletedMatchUps
25098
25221
  : completedMatchUps, // completed matchUps for the filter date
25099
25222
  dateMatchUps: dateMatchUps, // all incomplete matchUps for the filter date
25223
+ courtsData: courtsData,
25100
25224
  groupInfo: groupInfo,
25101
25225
  venues: venues,
25102
25226
  };
25103
25227
  if (withCourtGridRows) {
25104
- var _m = courtGridRows({
25228
+ var _p = courtGridRows({
25105
25229
  minRowsCount: minCourtGridRows,
25106
25230
  courtsData: courtsData,
25107
- }), rows = _m.rows, courtPrefix = _m.courtPrefix;
25231
+ }), rows = _p.rows, courtPrefix = _p.courtPrefix;
25108
25232
  result.courtPrefix = courtPrefix; // pass through for access to internal defaults by consumer
25109
25233
  result.rows = rows;
25110
25234
  }
@@ -25130,41 +25254,39 @@ function competitionScheduleMatchUps(params) {
25130
25254
  : courtMatchUps;
25131
25255
  }
25132
25256
  }
25133
- function getCompetitionPublishedDrawIds(_a) {
25257
+ function getCompetitionPublishedDrawDetails(_a) {
25134
25258
  var e_1, _b, e_2, _c;
25135
- var _d, _e, _f, _g;
25259
+ var _d, _e;
25136
25260
  var tournamentRecords = _a.tournamentRecords;
25137
25261
  var drawIds = [];
25262
+ var detailsMap = {};
25138
25263
  try {
25139
- for (var _h = __values(Object.values(tournamentRecords)), _j = _h.next(); !_j.done; _j = _h.next()) {
25140
- var tournamentRecord = _j.value;
25264
+ for (var _f = __values(Object.values(tournamentRecords)), _g = _f.next(); !_g.done; _g = _f.next()) {
25265
+ var tournamentRecord = _g.value;
25266
+ var _loop_1 = function (event_1) {
25267
+ var eventPubStatus = getEventPublishStatus({ event: event_1 });
25268
+ var drawDetails = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.drawDetails;
25269
+ if (isObject(drawDetails)) {
25270
+ Object.assign(detailsMap, drawDetails);
25271
+ drawIds.push.apply(drawIds, __spreadArray([], __read(Object.keys(drawDetails).filter(function (drawId) {
25272
+ return getDrawPublishStatus({ drawId: drawId, drawDetails: drawDetails });
25273
+ })), false));
25274
+ }
25275
+ else if ((_e = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.drawIds) === null || _e === void 0 ? void 0 : _e.length) {
25276
+ // LEGACY - deprecate
25277
+ drawIds.push.apply(drawIds, __spreadArray([], __read(eventPubStatus.drawIds), false));
25278
+ }
25279
+ };
25141
25280
  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
- }
25281
+ for (var _h = (e_2 = void 0, __values((_d = tournamentRecord.events) !== null && _d !== void 0 ? _d : [])), _j = _h.next(); !_j.done; _j = _h.next()) {
25282
+ var event_1 = _j.value;
25283
+ _loop_1(event_1);
25162
25284
  }
25163
25285
  }
25164
25286
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
25165
25287
  finally {
25166
25288
  try {
25167
- if (_l && !_l.done && (_c = _k.return)) _c.call(_k);
25289
+ if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
25168
25290
  }
25169
25291
  finally { if (e_2) throw e_2.error; }
25170
25292
  }
@@ -25173,11 +25295,11 @@ function getCompetitionPublishedDrawIds(_a) {
25173
25295
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
25174
25296
  finally {
25175
25297
  try {
25176
- if (_j && !_j.done && (_b = _h.return)) _b.call(_h);
25298
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
25177
25299
  }
25178
25300
  finally { if (e_1) throw e_1.error; }
25179
25301
  }
25180
- return { drawIds: drawIds };
25302
+ return { drawIds: drawIds, detailsMap: detailsMap };
25181
25303
  }
25182
25304
 
25183
25305
  var stageOrder = drawDefinitionConstants.stageOrder;
@@ -25522,23 +25644,24 @@ function getEventEntries(_a) {
25522
25644
  }
25523
25645
 
25524
25646
  function getEventPublishStatuses(_a) {
25525
- var _b;
25526
25647
  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;
25648
+ var eventPubStatus = getEventPublishStatus({ event: event });
25649
+ if (eventPubStatus) {
25534
25650
  var publishedSeeding = {
25535
25651
  published: undefined, // seeding can be present for all entries in an event when no flights have been defined
25536
25652
  seedingScaleNames: [],
25537
25653
  drawIds: [], // seeding can be specific to drawIds
25538
25654
  };
25539
- if (seeding) {
25540
- Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
25655
+ if (eventPubStatus.seeding) {
25656
+ Object.assign(publishedSeeding, eventPubStatus.seeding);
25541
25657
  }
25658
+ var drawDetails_1 = eventPubStatus.drawDetails, drawIds = eventPubStatus.drawIds;
25659
+ var publishedDrawIds = (drawDetails_1 &&
25660
+ Object.keys(drawDetails_1).filter(function (drawId) {
25661
+ return getDrawPublishStatus({ drawDetails: drawDetails_1, drawId: drawId });
25662
+ })) ||
25663
+ drawIds ||
25664
+ [];
25542
25665
  return {
25543
25666
  publishedDrawIds: publishedDrawIds,
25544
25667
  publishedSeeding: publishedSeeding,
@@ -26561,7 +26684,7 @@ function getParticipantEntries(params) {
26561
26684
  // if there is a time overlap capture both the prior matchUpId and the conflicted matchUpId
26562
26685
  if (timeOverlap && !(bothPotential && sameDraw) && itemIsPrior) {
26563
26686
  var key = [scheduleItem.matchUpId, consideredItem.matchUpId]
26564
- .sort()
26687
+ .sort(stringSort)
26565
26688
  .join('|');
26566
26689
  participantAggregator.scheduleConflicts[key] = {
26567
26690
  priorScheduledMatchUpId: scheduleItem.matchUpId,
@@ -28721,7 +28844,7 @@ function getStructureGroups(_a) {
28721
28844
  }
28722
28845
 
28723
28846
  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;
28847
+ 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
28848
  if (!drawDefinition)
28726
28849
  return { error: MISSING_DRAW_DEFINITION };
28727
28850
  var drawInfo = (function (_a) {
@@ -28789,6 +28912,8 @@ function getDrawData(params) {
28789
28912
  tournamentParticipants: tournamentParticipants,
28790
28913
  policyDefinitions: policyDefinitions,
28791
28914
  tournamentRecord: tournamentRecord,
28915
+ usePublishState: usePublishState,
28916
+ publishStatus: publishStatus,
28792
28917
  drawDefinition: drawDefinition,
28793
28918
  inContext: inContext,
28794
28919
  structure: structure,
@@ -28872,8 +28997,7 @@ function getDrawData(params) {
28872
28997
  }
28873
28998
 
28874
28999
  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;
29000
+ 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
29001
  var tournamentRecord = makeDeepCopy(t, false, true);
28878
29002
  var event = makeDeepCopy(e, false, true);
28879
29003
  if (!tournamentRecord)
@@ -28882,33 +29006,73 @@ function getEventData(params) {
28882
29006
  return { error: MISSING_EVENT };
28883
29007
  var eventId = event.eventId;
28884
29008
  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];
29009
+ var publishStatus = getEventPublishStatus({ event: event, status: status });
28890
29010
  var tournamentParticipants = getParticipants$1(__assign(__assign({ withGroupings: true, withEvents: false, withDraws: false }, participantsProfile), { // order is important!!
28891
29011
  tournamentRecord: tournamentRecord })).participants;
28892
29012
  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);
29013
+ var _b, _c, _d;
29014
+ var stage = _a.stage, drawId = _a.drawId;
29015
+ if (!usePublishState)
29016
+ return true;
29017
+ 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;
29018
+ if (!stageDetails || !Object.keys(stageDetails).length)
29019
+ return true;
29020
+ return (_d = stageDetails[stage]) === null || _d === void 0 ? void 0 : _d.published;
28898
29021
  };
28899
29022
  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);
29023
+ var _b, _c, _d;
29024
+ var structureId = _a.structureId, drawId = _a.drawId;
29025
+ if (!usePublishState)
29026
+ return true;
29027
+ 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;
29028
+ if (!structureDetails || !Object.keys(structureDetails).length)
29029
+ return true;
29030
+ return (_d = structureDetails[structureId]) === null || _d === void 0 ? void 0 : _d.published;
28905
29031
  };
28906
29032
  var drawFilter = function (_a) {
28907
- var _b;
29033
+ var _b, _c;
28908
29034
  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);
29035
+ if (!usePublishState)
29036
+ return true;
29037
+ if (publishStatus.drawDetails) {
29038
+ return (_c = (_b = publishStatus.drawDetails[drawId]) === null || _b === void 0 ? void 0 : _b.publishingDetail) === null || _c === void 0 ? void 0 : _c.published;
29039
+ }
29040
+ else if (publishStatus.drawIds) {
29041
+ return publishStatus.drawIds.includes(drawId);
29042
+ }
29043
+ return true;
29044
+ };
29045
+ var roundLimitMapper = function (_a) {
29046
+ var e_1, _b;
29047
+ var _c, _d, _e, _f;
29048
+ var drawId = _a.drawId, structure = _a.structure;
29049
+ if (!usePublishState)
29050
+ return structure;
29051
+ 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;
29052
+ if (isConvertableInteger(roundLimit)) {
29053
+ var roundNumbers = generateRange(1, roundLimit + 1);
29054
+ var roundMatchUps = {};
29055
+ var roundProfile = {};
29056
+ try {
29057
+ for (var roundNumbers_1 = __values(roundNumbers), roundNumbers_1_1 = roundNumbers_1.next(); !roundNumbers_1_1.done; roundNumbers_1_1 = roundNumbers_1.next()) {
29058
+ var roundNumber = roundNumbers_1_1.value;
29059
+ if (structure.roundMatchUps[roundNumber]) {
29060
+ roundMatchUps[roundNumber] = structure.roundMatchUps[roundNumber];
29061
+ roundProfile[roundNumber] = structure.roundProfile[roundNumber];
29062
+ }
29063
+ }
29064
+ }
29065
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
29066
+ finally {
29067
+ try {
29068
+ if (roundNumbers_1_1 && !roundNumbers_1_1.done && (_b = roundNumbers_1.return)) _b.call(roundNumbers_1);
29069
+ }
29070
+ finally { if (e_1) throw e_1.error; }
29071
+ }
29072
+ structure.roundMatchUps = roundMatchUps;
29073
+ structure.roundProfile = roundProfile;
29074
+ }
29075
+ return structure;
28912
29076
  };
28913
29077
  var drawDefinitions = event.drawDefinitions || [];
28914
29078
  var drawsData = drawDefinitions
@@ -28924,15 +29088,23 @@ function getEventData(params) {
28924
29088
  noDeepCopy: true,
28925
29089
  policyDefinitions: policyDefinitions,
28926
29090
  tournamentRecord: tournamentRecord,
29091
+ usePublishState: usePublishState,
28927
29092
  drawDefinition: drawDefinition,
29093
+ publishStatus: publishStatus,
28928
29094
  sortConfig: sortConfig,
28929
29095
  event: event,
28930
29096
  }));
28931
29097
  })
28932
29098
  .map(function (_a) {
28933
- var _b;
28934
29099
  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) }));
29100
+ var filteredStructures = structures === null || structures === void 0 ? void 0 : structures.filter(function (_a) {
29101
+ var stage = _a.stage, structureId = _a.structureId;
29102
+ return structureFilter({ structureId: structureId, drawId: drawData.drawId }) &&
29103
+ stageFilter({ stage: stage, drawId: drawData.drawId });
29104
+ }).map(function (structure) {
29105
+ return roundLimitMapper({ drawId: drawData.drawId, structure: structure });
29106
+ });
29107
+ return __assign(__assign({}, drawData), { structures: filteredStructures });
28936
29108
  })
28937
29109
  .filter(function (drawData) { var _a; return (_a = drawData.structures) === null || _a === void 0 ? void 0 : _a.length; });
28938
29110
  var tournamentInfo = getTournamentInfo({ tournamentRecord: tournamentRecord }).tournamentInfo;
@@ -28969,10 +29141,7 @@ function getEventData(params) {
28969
29141
  eventInfo: eventInfo,
28970
29142
  drawsData: drawsData,
28971
29143
  };
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
- };
29144
+ eventData.eventInfo.publish = publishStatus;
28976
29145
  return __assign(__assign({}, SUCCESS), { eventData: eventData });
28977
29146
  }
28978
29147
 
@@ -36050,10 +36219,7 @@ function modifyCollectionDefinition$1(_a) {
36050
36219
  modifications.push({ collectionId: collectionId, gender: gender });
36051
36220
  }
36052
36221
  var modifiedTieFormat = definedAttributes(tieFormat);
36053
- result = validateTieFormat({
36054
- tieFormat: modifiedTieFormat,
36055
- eventType: event === null || event === void 0 ? void 0 : event.eventType,
36056
- });
36222
+ result = validateTieFormat({ tieFormat: modifiedTieFormat });
36057
36223
  if (result.error) {
36058
36224
  return decorateResult({ result: result, stack: stack });
36059
36225
  }
@@ -36346,8 +36512,7 @@ function removeCollectionDefinition$1(_a) {
36346
36512
  matchUp = matchUp !== null && matchUp !== void 0 ? matchUp : result === null || result === void 0 ? void 0 : result.matchUp;
36347
36513
  var existingTieFormat = result === null || result === void 0 ? void 0 : result.tieFormat;
36348
36514
  var tieFormat = copyTieFormat(existingTieFormat);
36349
- var eventType = event === null || event === void 0 ? void 0 : event.eventType;
36350
- result = validateTieFormat({ tieFormat: tieFormat, eventType: eventType });
36515
+ result = validateTieFormat({ tieFormat: tieFormat });
36351
36516
  if (result.error)
36352
36517
  return decorateResult({ result: result, stack: stack });
36353
36518
  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 +36703,7 @@ function removeCollectionDefinition$1(_a) {
36538
36703
  });
36539
36704
  }
36540
36705
  var prunedTieFormat = definedAttributes(tieFormat);
36541
- result = validateTieFormat({ tieFormat: prunedTieFormat, eventType: eventType });
36706
+ result = validateTieFormat({ tieFormat: prunedTieFormat });
36542
36707
  if (result.error)
36543
36708
  return decorateResult({ result: result, stack: stack });
36544
36709
  // TODO: implement use of tieFormats and tieFormatId
@@ -36622,8 +36787,7 @@ function addCollectionDefinition$1(_a) {
36622
36787
  matchUp = matchUp !== null && matchUp !== void 0 ? matchUp : result === null || result === void 0 ? void 0 : result.matchUp;
36623
36788
  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
36789
  var tieFormat = copyTieFormat(existingTieFormat);
36625
- var eventType = event === null || event === void 0 ? void 0 : event.eventType;
36626
- result = validateTieFormat({ tieFormat: tieFormat, eventType: eventType });
36790
+ result = validateTieFormat({ tieFormat: tieFormat });
36627
36791
  if (result === null || result === void 0 ? void 0 : result.error) {
36628
36792
  return decorateResult({ result: { error: result.error }, stack: stack });
36629
36793
  }
@@ -36667,7 +36831,7 @@ function addCollectionDefinition$1(_a) {
36667
36831
  var addedMatchUps = [];
36668
36832
  var targetMatchUps = [];
36669
36833
  var prunedTieFormat = definedAttributes(tieFormat);
36670
- result = validateTieFormat({ tieFormat: prunedTieFormat, eventType: eventType });
36834
+ result = validateTieFormat({ tieFormat: prunedTieFormat });
36671
36835
  if (result === null || result === void 0 ? void 0 : result.error) {
36672
36836
  return decorateResult({ result: { error: result.error }, stack: stack });
36673
36837
  }
@@ -36989,10 +37153,7 @@ function collectionGroupUpdate(_a) {
36989
37153
  event: event,
36990
37154
  });
36991
37155
  var prunedTieFormat = definedAttributes(tieFormat);
36992
- var result = validateTieFormat({
36993
- eventType: event === null || event === void 0 ? void 0 : event.eventType,
36994
- tieFormat: prunedTieFormat,
36995
- });
37156
+ var result = validateTieFormat({ tieFormat: prunedTieFormat });
36996
37157
  if (result.error)
36997
37158
  return result;
36998
37159
  // TODO: implement use of tieFormats and tieFormatId
@@ -37041,7 +37202,7 @@ function removeCollectionGroup$1(_a) {
37041
37202
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
37042
37203
  var wasAggregateValue = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.aggregateValue;
37043
37204
  var tieFormat = copyTieFormat(existingTieFormat);
37044
- result = validateTieFormat({ tieFormat: tieFormat, eventType: event === null || event === void 0 ? void 0 : event.eventType });
37205
+ result = validateTieFormat({ tieFormat: tieFormat });
37045
37206
  if (result.error)
37046
37207
  return decorateResult({ result: result, stack: stack });
37047
37208
  var modifiedCollectionIds = [];
@@ -37122,7 +37283,7 @@ function addCollectionGroup$1(_a) {
37122
37283
  var existingTieFormat = result === null || result === void 0 ? void 0 : result.tieFormat;
37123
37284
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
37124
37285
  var tieFormat = copyTieFormat(existingTieFormat);
37125
- result = validateTieFormat({ tieFormat: tieFormat, eventType: event.eventType });
37286
+ result = validateTieFormat({ tieFormat: tieFormat });
37126
37287
  if (result.error)
37127
37288
  return decorateResult({ result: result, stack: stack });
37128
37289
  try {
@@ -37187,10 +37348,7 @@ function modifyTieFormat$1(_a) {
37187
37348
  var e_1, _b, e_2, _c, e_3, _d;
37188
37349
  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
37350
  var stack = 'modifyTieFormat';
37190
- if (!validateTieFormat({
37191
- tieFormat: modifiedTieFormat,
37192
- eventType: event === null || event === void 0 ? void 0 : event.eventType,
37193
- }).valid) {
37351
+ if (!validateTieFormat({ tieFormat: modifiedTieFormat }).valid) {
37194
37352
  return decorateResult({
37195
37353
  result: { error: INVALID_TIE_FORMAT },
37196
37354
  info: 'falied validation',
@@ -46475,8 +46633,8 @@ function setStageQualifiersCount(_a) {
46475
46633
  }
46476
46634
 
46477
46635
  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;
46636
+ var _a, _b;
46637
+ 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
46638
  var stack = 'generateDrawTypeAndModifyDrawDefinition';
46481
46639
  if (!params.drawDefinition)
46482
46640
  return decorateResult({
@@ -46488,12 +46646,11 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
46488
46646
  : makeDeepCopy(params.drawDefinition, false, true);
46489
46647
  var tieFormat = params.tieFormat, matchUpType = params.matchUpType;
46490
46648
  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 });
46649
+ var result_1 = validateTieFormat({ tieFormat: tieFormat });
46493
46650
  if (result_1.error)
46494
46651
  return result_1;
46495
46652
  }
46496
- tieFormat = copyTieFormat(tieFormat || ((_b = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _b === void 0 ? void 0 : _b.tieFormat));
46653
+ tieFormat = copyTieFormat(tieFormat || ((_a = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _a === void 0 ? void 0 : _a.tieFormat));
46497
46654
  matchUpType = matchUpType || drawDefinition.matchUpType || SINGLES$1;
46498
46655
  params.tieFormat = tieFormat;
46499
46656
  params.matchUpType = matchUpType;
@@ -46547,7 +46704,7 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
46547
46704
  }
46548
46705
  var drawSize = params.drawSize || mainStageDrawPositionsCount;
46549
46706
  Object.assign(params, definedAttributes({ drawSize: drawSize, matchUpType: matchUpType, tieFormat: tieFormat }));
46550
- var _g = getAllDrawMatchUps({ drawDefinition: drawDefinition }), matchUps = _g.matchUps, matchUpsMap = _g.matchUpsMap;
46707
+ var _f = getAllDrawMatchUps({ drawDefinition: drawDefinition }), matchUps = _f.matchUps, matchUpsMap = _f.matchUpsMap;
46551
46708
  if (tieFormat) {
46552
46709
  // if there were exiting matchUps, exclude them from this step
46553
46710
  matchUps === null || matchUps === void 0 ? void 0 : matchUps.forEach(function (matchUp) {
@@ -46559,7 +46716,7 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
46559
46716
  }
46560
46717
  var inContextDrawMatchUps = addGoesTo({ drawDefinition: drawDefinition, matchUpsMap: matchUpsMap }).inContextDrawMatchUps;
46561
46718
  modifyDrawNotice({
46562
- tournamentId: (_c = params.tournamentRecord) === null || _c === void 0 ? void 0 : _c.tournamentId,
46719
+ tournamentId: (_b = params.tournamentRecord) === null || _b === void 0 ? void 0 : _b.tournamentId,
46563
46720
  drawDefinition: drawDefinition,
46564
46721
  });
46565
46722
  return __assign(__assign({ inContextDrawMatchUps: inContextDrawMatchUps, drawDefinition: drawDefinition, matchUpsMap: matchUpsMap }, SUCCESS), { structures: structures, matchUps: matchUps, links: links });
@@ -49020,8 +49177,8 @@ function addVoluntaryConsolationStage$1(_a) {
49020
49177
 
49021
49178
  function generateVoluntaryConsolation$1(params) {
49022
49179
  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
49180
+ var _c, _d, _e, _f, _g, _h, _j;
49181
+ 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
49182
  automated = params.automated, placeByes = params.placeByes, isMock = params.isMock, event = params.event;
49026
49183
  var drawDefinition = params === null || params === void 0 ? void 0 : params.drawDefinition;
49027
49184
  if (!drawDefinition)
@@ -49052,13 +49209,12 @@ function generateVoluntaryConsolation$1(params) {
49052
49209
  return { error: INVALID_DRAW_SIZE };
49053
49210
  var tieFormat = params.tieFormat, matchUpType = params.matchUpType;
49054
49211
  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 });
49212
+ var result_1 = validateTieFormat({ tieFormat: tieFormat });
49057
49213
  if (result_1.error)
49058
49214
  return result_1;
49059
49215
  }
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;
49216
+ tieFormat = copyTieFormat(tieFormat !== null && tieFormat !== void 0 ? tieFormat : (_d = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _d === void 0 ? void 0 : _d.tieFormat);
49217
+ matchUpType = (_e = matchUpType !== null && matchUpType !== void 0 ? matchUpType : drawDefinition.matchUpType) !== null && _e !== void 0 ? _e : TypeEnum.Singles;
49062
49218
  var stageStructures = getDrawStructures({
49063
49219
  stageSequence: 1,
49064
49220
  drawDefinition: drawDefinition,
@@ -49069,11 +49225,11 @@ function generateVoluntaryConsolation$1(params) {
49069
49225
  if (structureCount > 1)
49070
49226
  return { error: STAGE_SEQUENCE_LIMIT };
49071
49227
  // 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)
49228
+ 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
49229
  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;
49230
+ var structureId = (_h = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _h === void 0 ? void 0 : _h.structureId;
49075
49231
  Object.assign(params, definedAttributes({
49076
- structureName: (_k = params.structureName) !== null && _k !== void 0 ? _k : constantToString(VOLUNTARY_CONSOLATION),
49232
+ structureName: (_j = params.structureName) !== null && _j !== void 0 ? _j : constantToString(VOLUNTARY_CONSOLATION),
49077
49233
  structureId: structureId,
49078
49234
  matchUpType: matchUpType,
49079
49235
  tieFormat: tieFormat,
@@ -55665,7 +55821,7 @@ function addParticipantContext(params) {
55665
55821
  params.withDraws) {
55666
55822
  // loop through all filtered events and capture events played
55667
55823
  (_a = params.tournamentEvents) === null || _a === void 0 ? void 0 : _a.forEach(function (rawEvent) {
55668
- var _a, _b, _c, _d, _e, _f, _g;
55824
+ var _a, _b, _c, _d, _e, _f;
55669
55825
  var event = makeDeepCopy(rawEvent, true, true);
55670
55826
  var flightProfile = getFlightProfile({ event: event }).flightProfile;
55671
55827
  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 +55841,21 @@ function addParticipantContext(params) {
55685
55841
  var extensionKeys = event && Object.keys(event).filter(function (key) { return key.startsWith('_'); });
55686
55842
  extensionKeys === null || extensionKeys === void 0 ? void 0 : extensionKeys.forEach(function (extensionKey) { return (eventInfo[extensionKey] = event[extensionKey]); });
55687
55843
  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;
55844
+ var pubStatus = getEventPublishStatus({ event: event });
55845
+ if (isObject(pubStatus)) {
55846
+ var drawIds = pubStatus.drawIds, drawDetails_1 = pubStatus.drawDetails, seeding = pubStatus.seeding;
55847
+ var publishedDrawIds = drawDetails_1
55848
+ ? Object.keys(drawDetails_1).filter(function (drawId) {
55849
+ return getDrawPublishStatus({ drawId: drawId, drawDetails: drawDetails_1 });
55850
+ })
55851
+ : drawIds !== null && drawIds !== void 0 ? drawIds : [];
55695
55852
  var publishedSeeding = {
55696
55853
  published: undefined, // seeding can be present for all entries in an event when no flights have been defined
55697
55854
  seedingScaleNames: [],
55698
55855
  drawIds: [], // seeding can be specific to drawIds
55699
55856
  };
55700
55857
  if (seeding)
55701
- Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
55858
+ Object.assign(publishedSeeding, pubStatus.seeding);
55702
55859
  eventsPublishStatuses[eventId] = {
55703
55860
  publishedDrawIds: publishedDrawIds,
55704
55861
  publishedSeeding: publishedSeeding,
@@ -55769,11 +55926,11 @@ function addParticipantContext(params) {
55769
55926
  });
55770
55927
  };
55771
55928
  // 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) {
55929
+ var drawIdsWithDefinitions = ((_c = event.drawDefinitions) === null || _c === void 0 ? void 0 : _c.map(function (_a) {
55773
55930
  var drawId = _a.drawId;
55774
55931
  return drawId;
55775
55932
  })) || [];
55776
- (_f = (_e = eventInfo._flightProfile) === null || _e === void 0 ? void 0 : _e.flights) === null || _f === void 0 ? void 0 : _f.forEach(function (flight) {
55933
+ (_e = (_d = eventInfo._flightProfile) === null || _d === void 0 ? void 0 : _d.flights) === null || _e === void 0 ? void 0 : _e.forEach(function (flight) {
55777
55934
  var drawId = flight.drawId, drawEntries = flight.drawEntries;
55778
55935
  if (!drawIdsWithDefinitions.includes(drawId)) {
55779
55936
  drawEntries === null || drawEntries === void 0 ? void 0 : drawEntries.forEach(function (drawEntry) {
@@ -55781,10 +55938,10 @@ function addParticipantContext(params) {
55781
55938
  });
55782
55939
  }
55783
55940
  });
55784
- var _k = getDrawDetails({
55941
+ var _g = getDrawDetails({
55785
55942
  eventEntries: eventEntries,
55786
55943
  event: event,
55787
- }), drawDetails = _k.drawDetails, derivedInfo = _k.derivedInfo;
55944
+ }), drawDetails = _g.drawDetails, derivedInfo = _g.derivedInfo;
55788
55945
  Object.assign(derivedDrawInfo, derivedInfo);
55789
55946
  if (event.eventType === TEAM$2 || // for TEAM events some individual attributes can only be derived by processing
55790
55947
  params.withScheduleItems ||
@@ -55793,14 +55950,14 @@ function addParticipantContext(params) {
55793
55950
  params.withOpponents ||
55794
55951
  params.withMatchUps ||
55795
55952
  params.withDraws) {
55796
- var matchUps = (_g = allEventMatchUps({
55953
+ var matchUps = (_f = allEventMatchUps({
55797
55954
  afterRecoveryTimes: params.scheduleAnalysis,
55798
55955
  participants: allTournamentParticipants,
55799
55956
  nextMatchUps: true,
55800
55957
  tournamentRecord: tournamentRecord,
55801
55958
  inContext: true,
55802
55959
  event: event,
55803
- })) === null || _g === void 0 ? void 0 : _g.matchUps;
55960
+ })) === null || _f === void 0 ? void 0 : _f.matchUps;
55804
55961
  matchUps === null || matchUps === void 0 ? void 0 : matchUps.forEach(function (matchUp) {
55805
55962
  return processMatchUp({
55806
55963
  relevantParticipantIdsMap: relevantParticipantIdsMap,
@@ -57573,35 +57730,48 @@ var participantGovernor = {
57573
57730
  getParticipants: getParticipants$1,
57574
57731
  };
57575
57732
 
57576
- function publishEventSeeding(_a) {
57733
+ function modifyEventPublishStatus(_a) {
57577
57734
  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;
57735
+ 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;
57736
+ if (!isObject(statusObject))
57737
+ return { error: INVALID_VALUES };
57738
+ var publishStatus = getEventPublishStatus({ event: event, status: status });
57739
+ var itemType = "".concat(PUBLISH, ".").concat(STATUS$1);
57740
+ var updatedTimeItem = {
57741
+ itemValue: (_b = {}, _b[status] = __assign(__assign({}, publishStatus), statusObject), _b),
57742
+ itemType: itemType,
57743
+ };
57744
+ return addEventTimeItem({
57745
+ timeItem: updatedTimeItem,
57746
+ removePriorValues: removePriorValues,
57747
+ event: event,
57748
+ });
57749
+ }
57750
+
57751
+ function publishEventSeeding(_a) {
57752
+ var _b, _c, _d, _e;
57753
+ 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
57754
  if (!tournamentRecord)
57581
57755
  return { error: MISSING_TOURNAMENT_RECORD };
57582
57756
  if (!event)
57583
57757
  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({
57758
+ var eventPubStatus = getEventPublishStatus({ event: event, status: status });
57759
+ var updatedSeedingScaleNames = (((_b = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.seeding) === null || _b === void 0 ? void 0 : _b.seedingScaleNames) ||
57760
+ seedingScaleNames) && __assign(__assign({}, (_c = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.seeding) === null || _c === void 0 ? void 0 : _c.seedingScaleNames), seedingScaleNames);
57761
+ var updatedStageSeedingScaleNames = (((_d = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.seeding) === null || _d === void 0 ? void 0 : _d.stageSeedingScaleNames) ||
57762
+ stageSeedingScaleNames) && __assign(__assign({}, (_e = eventPubStatus === null || eventPubStatus === void 0 ? void 0 : eventPubStatus.seeding) === null || _e === void 0 ? void 0 : _e.stageSeedingScaleNames), stageSeedingScaleNames);
57763
+ var seeding = definedAttributes({
57595
57764
  stageSeedingScaleNames: updatedStageSeedingScaleNames,
57596
57765
  seedingScaleNames: updatedSeedingScaleNames,
57597
57766
  published: true,
57598
57767
  drawIds: drawIds,
57599
57768
  });
57600
- var updatedTimeItem = {
57601
- itemValue: itemValue,
57602
- itemType: itemType,
57603
- };
57604
- addEventTimeItem({ event: event, timeItem: updatedTimeItem, removePriorValues: removePriorValues });
57769
+ modifyEventPublishStatus({
57770
+ statusObject: { seeding: seeding },
57771
+ removePriorValues: removePriorValues,
57772
+ status: status,
57773
+ event: event,
57774
+ });
57605
57775
  addNotice({
57606
57776
  topic: PUBLISH_EVENT_SEEDING,
57607
57777
  payload: {
@@ -57613,51 +57783,55 @@ function publishEventSeeding(_a) {
57613
57783
  return __assign({}, SUCCESS);
57614
57784
  }
57615
57785
  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;
57786
+ var e_1, _b;
57787
+ var _c, _d, _e;
57788
+ 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
57789
  if (!tournamentRecord)
57620
57790
  return { error: MISSING_TOURNAMENT_RECORD };
57621
57791
  if (!event)
57622
57792
  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)) {
57793
+ var eventPubStatus = getEventPublishStatus({ event: event });
57794
+ if (eventPubStatus) {
57795
+ var seeding = eventPubStatus.seeding;
57796
+ if (Array.isArray(stages) && seeding.stageSeedingScaleNames) {
57632
57797
  try {
57633
57798
  for (var stages_1 = __values(stages), stages_1_1 = stages_1.next(); !stages_1_1.done; stages_1_1 = stages_1.next()) {
57634
57799
  var stage = stages_1_1.value;
57635
- if (itemValue[status].seeding.stageSeedingScaleNames[stage]) {
57636
- delete itemValue[status].seeding.stageSeedingScaleNames[stage];
57800
+ if (seeding.stageSeedingScaleNames[stage]) {
57801
+ delete seeding.stageSeedingScaleNames[stage];
57637
57802
  }
57638
57803
  }
57639
57804
  }
57640
57805
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
57641
57806
  finally {
57642
57807
  try {
57643
- if (stages_1_1 && !stages_1_1.done && (_c = stages_1.return)) _c.call(stages_1);
57808
+ if (stages_1_1 && !stages_1_1.done && (_b = stages_1.return)) _b.call(stages_1);
57644
57809
  }
57645
57810
  finally { if (e_1) throw e_1.error; }
57646
57811
  }
57647
57812
  }
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); });
57813
+ if (Array.isArray(seedingScaleNames) && (seeding === null || seeding === void 0 ? void 0 : seeding.seedingScaleNames)) {
57814
+ seeding.seedingScaleNames = seeding.seedingScaleNames.filter(function (scaleName) { return !seedingScaleNames.includes(scaleName); });
57815
+ }
57816
+ if (Array.isArray(drawIds) && (seeding === null || seeding === void 0 ? void 0 : seeding.drawIds)) {
57817
+ seeding.drawIds = seeding.drawIds.filter(function (drawId) { return !drawIds.includes(drawId); });
57651
57818
  }
57652
- if (!stages && !seedingScaleNames) {
57653
- delete itemValue[status].seeding;
57819
+ if ((!Object.values((_c = seeding.stageSeedingScaleNames) !== null && _c !== void 0 ? _c : {}).length &&
57820
+ !((_d = seeding.seedingScaleNames) === null || _d === void 0 ? void 0 : _d.length) &&
57821
+ !((_e = seeding.drawIds) === null || _e === void 0 ? void 0 : _e.length)) ||
57822
+ (!stages && !seedingScaleNames && !(drawIds === null || drawIds === void 0 ? void 0 : drawIds.length))) {
57823
+ delete seeding.stageSeedingScaleNames;
57824
+ delete seeding.seedingScaleNames;
57825
+ delete seeding.drawIds;
57826
+ seeding.published = false;
57654
57827
  }
57828
+ modifyEventPublishStatus({
57829
+ statusObject: { seeding: seeding },
57830
+ removePriorValues: removePriorValues,
57831
+ status: status,
57832
+ event: event,
57833
+ });
57655
57834
  }
57656
- var updatedTimeItem = {
57657
- itemValue: itemValue,
57658
- itemType: itemType,
57659
- };
57660
- addEventTimeItem({ event: event, timeItem: updatedTimeItem, removePriorValues: removePriorValues });
57661
57835
  addNotice({
57662
57836
  topic: UNPUBLISH_EVENT_SEEDING,
57663
57837
  payload: {
@@ -57732,13 +57906,10 @@ function getAllEventData(_a) {
57732
57906
  },
57733
57907
  };
57734
57908
  });
57735
- var timeItem = getEventTimeItem({
57736
- itemType: "".concat(PUBLISH, ".").concat(STATUS$1),
57737
- event: event,
57738
- }).timeItem;
57909
+ var publish = getEventPublishStatus({ event: event });
57739
57910
  Object.assign(eventInfo, {
57740
- publish: timeItem === null || timeItem === void 0 ? void 0 : timeItem.itemValue,
57741
57911
  drawsData: drawsData,
57912
+ publish: publish,
57742
57913
  });
57743
57914
  return eventInfo;
57744
57915
  });
@@ -57746,6 +57917,72 @@ function getAllEventData(_a) {
57746
57917
  return { allEventData: allEventData };
57747
57918
  }
57748
57919
 
57920
+ function setEventDisplay(_a) {
57921
+ var e_1, _b, e_2, _c;
57922
+ var _d;
57923
+ var removePriorValues = _a.removePriorValues, tournamentRecord = _a.tournamentRecord, displaySettings = _a.displaySettings, _e = _a.status, status = _e === void 0 ? PUBLIC : _e, event = _a.event;
57924
+ if (!tournamentRecord)
57925
+ return decorateResult({ result: { error: MISSING_TOURNAMENT_RECORD } });
57926
+ if (!event)
57927
+ return decorateResult({ result: { error: MISSING_EVENT } });
57928
+ if (!isObject(displaySettings))
57929
+ return decorateResult({ result: { error: MISSING_VALUE } });
57930
+ // combine ScheduleDetails that are equivalent
57931
+ if (isObject(displaySettings.draws)) {
57932
+ try {
57933
+ for (var _f = __values(Object.keys(displaySettings.draws)), _g = _f.next(); !_g.done; _g = _f.next()) {
57934
+ var key = _g.value;
57935
+ var details = (_d = displaySettings.draws[key].scheduleDetails) !== null && _d !== void 0 ? _d : [];
57936
+ if (details.length) {
57937
+ var scheduleDetails = [];
57938
+ var _loop_1 = function (detail) {
57939
+ var _h;
57940
+ var existingDetail = scheduleDetails.find(function (sd) {
57941
+ return objShallowEqual(sd.attributes, detail.attributes);
57942
+ });
57943
+ if ((existingDetail === null || existingDetail === void 0 ? void 0 : existingDetail.dates) && detail.dates) {
57944
+ (_h = existingDetail.dates).push.apply(_h, __spreadArray([], __read(detail.dates), false));
57945
+ }
57946
+ else {
57947
+ scheduleDetails.push(detail);
57948
+ }
57949
+ };
57950
+ try {
57951
+ 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()) {
57952
+ var detail = details_1_1.value;
57953
+ _loop_1(detail);
57954
+ }
57955
+ }
57956
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
57957
+ finally {
57958
+ try {
57959
+ if (details_1_1 && !details_1_1.done && (_c = details_1.return)) _c.call(details_1);
57960
+ }
57961
+ finally { if (e_2) throw e_2.error; }
57962
+ }
57963
+ displaySettings.draws[key].scheduleDetails = scheduleDetails;
57964
+ }
57965
+ }
57966
+ }
57967
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
57968
+ finally {
57969
+ try {
57970
+ if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
57971
+ }
57972
+ finally { if (e_1) throw e_1.error; }
57973
+ }
57974
+ }
57975
+ var result = modifyEventPublishStatus({
57976
+ statusObject: { displaySettings: displaySettings },
57977
+ removePriorValues: removePriorValues,
57978
+ status: status,
57979
+ event: event,
57980
+ });
57981
+ if (result.error)
57982
+ return result;
57983
+ return __assign({}, SUCCESS);
57984
+ }
57985
+
57749
57986
  function unPublishEvent(_a) {
57750
57987
  var _b;
57751
57988
  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 +57996,21 @@ function unPublishEvent(_a) {
57759
57996
  event: event,
57760
57997
  }).timeItem;
57761
57998
  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;
57999
+ delete itemValue[status].structureIds; // legacy
58000
+ delete itemValue[status].drawDetails;
58001
+ delete itemValue[status].drawIds; // legacy
57764
58002
  var updatedTimeItem = { itemValue: itemValue, itemType: itemType };
57765
58003
  addEventTimeItem({ event: event, timeItem: updatedTimeItem, removePriorValues: removePriorValues });
58004
+ modifyEventPublishStatus({
58005
+ statusObject: {
58006
+ structureIds: undefined,
58007
+ drawIds: undefined,
58008
+ seeding: undefined,
58009
+ },
58010
+ removePriorValues: removePriorValues,
58011
+ status: status,
58012
+ event: event,
58013
+ });
57766
58014
  addNotice({
57767
58015
  topic: UNPUBLISH_EVENT,
57768
58016
  payload: {
@@ -57774,64 +58022,183 @@ function unPublishEvent(_a) {
57774
58022
  }
57775
58023
 
57776
58024
  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;
58025
+ var _a, e_1, _b;
58026
+ var _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
58027
+ 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
58028
  if (!tournamentRecord)
57782
58029
  return { error: MISSING_TOURNAMENT_RECORD };
57783
58030
  if (!event)
57784
58031
  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) {
58032
+ // publishing will draw on scoring policy, round naming policy and participant (privacy) policy
58033
+ var appliedPolicies = getAppliedPolicies({ tournamentRecord: tournamentRecord, event: event }).appliedPolicies;
58034
+ var policyDefinitions = __assign(__assign({}, appliedPolicies), params.policyDefinitions);
58035
+ var eventDrawIds = (_d = (_c = event.drawDefinitions) === null || _c === void 0 ? void 0 : _c.map(function (_a) {
57791
58036
  var drawId = _a.drawId;
57792
58037
  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)));
58038
+ })) !== null && _d !== void 0 ? _d : [];
58039
+ var keyedDrawIds = params.drawDetails
58040
+ ? Object.keys(params.drawDetails)
58041
+ : [];
58042
+ var specifiedDrawIds = keyedDrawIds.length ? [] : params.drawIds;
58043
+ 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));
58044
+ var invalidDrawIds = drawIdsToValidate.filter(function (drawId) { return !eventDrawIds.includes(drawId); });
58045
+ if (invalidDrawIds.length) {
58046
+ return decorateResult({
58047
+ result: { error: DRAW_DEFINITION_NOT_FOUND },
58048
+ context: { invalidDrawIds: invalidDrawIds },
58049
+ });
58050
+ }
58051
+ var pubStatus = getEventPublishStatus({ event: event, status: status });
58052
+ var drawDetails = (pubStatus === null || pubStatus === void 0 ? void 0 : pubStatus.drawDetails) || {};
58053
+ var _loop_1 = function (drawId) {
58054
+ var e_2, _r, e_3, _s, e_4, _t, e_5, _u, e_6, _v;
58055
+ if (!drawIdsToValidate.length || drawIdsToValidate.includes(drawId)) {
58056
+ if ((drawIdsToRemove === null || drawIdsToRemove === void 0 ? void 0 : drawIdsToRemove.includes(drawId)) ||
58057
+ ((specifiedDrawIds === null || specifiedDrawIds === void 0 ? void 0 : specifiedDrawIds.length) && !specifiedDrawIds.includes(drawId))) {
58058
+ drawDetails[drawId] = __assign(__assign({}, drawDetails[drawId]), { publishingDetail: { published: false } });
58059
+ }
58060
+ else if ((drawIdsToAdd === null || drawIdsToAdd === void 0 ? void 0 : drawIdsToAdd.includes(drawId)) ||
58061
+ (specifiedDrawIds === null || specifiedDrawIds === void 0 ? void 0 : specifiedDrawIds.includes(drawId)) ||
58062
+ !(specifiedDrawIds === null || specifiedDrawIds === void 0 ? void 0 : specifiedDrawIds.length)) {
58063
+ drawDetails[drawId] = __assign(__assign({}, drawDetails[drawId]), { publishingDetail: { published: true } });
58064
+ }
58065
+ }
58066
+ if ((_e = params.drawDetails) === null || _e === void 0 ? void 0 : _e[drawId]) {
58067
+ var newDetail = params.drawDetails[drawId];
58068
+ var structureDetails = (_f = newDetail.structureDetails) !== null && _f !== void 0 ? _f : drawDetails[drawId].structureDetails;
58069
+ var stageDetails = (_h = (_g = newDetail.stageDetails) !== null && _g !== void 0 ? _g : drawDetails[drawId].stageDetails) !== null && _h !== void 0 ? _h : {};
58070
+ 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;
58071
+ if (structureIdsToAdd || stagesToAdd)
58072
+ publishingDetail.published = true;
58073
+ drawDetails[drawId] = {
58074
+ publishingDetail: publishingDetail,
58075
+ structureDetails: structureDetails,
58076
+ stageDetails: stageDetails,
58077
+ };
58078
+ if (structureIdsToAdd.length || structureIdsToRemove.length) {
58079
+ 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) {
58080
+ var structureId = _a.structureId;
58081
+ return structureId;
58082
+ });
58083
+ var structureIdsToValidate = (structureIdsToAdd !== null && structureIdsToAdd !== void 0 ? structureIdsToAdd : []).concat(structureIdsToRemove !== null && structureIdsToRemove !== void 0 ? structureIdsToRemove : []);
58084
+ var invalidStructureIds = structureIdsToValidate.filter(function (structureId) { return !drawStructureIds_2.includes(structureId); });
58085
+ if (invalidStructureIds.length) {
58086
+ return { value: decorateResult({
58087
+ result: { error: STRUCTURE_NOT_FOUND },
58088
+ context: { invalidStructureIds: invalidStructureIds },
58089
+ }) };
58090
+ }
58091
+ structureDetails = structureDetails !== null && structureDetails !== void 0 ? structureDetails : {};
58092
+ try {
58093
+ 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()) {
58094
+ var structureId = drawStructureIds_1_1.value;
58095
+ if (structureIdsToRemove.includes(structureId)) {
58096
+ structureDetails[structureId] = { published: false };
58097
+ }
58098
+ else {
58099
+ structureDetails[structureId] = { published: true };
58100
+ }
58101
+ }
58102
+ }
58103
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
58104
+ finally {
58105
+ try {
58106
+ if (drawStructureIds_1_1 && !drawStructureIds_1_1.done && (_r = drawStructureIds_1.return)) _r.call(drawStructureIds_1);
58107
+ }
58108
+ finally { if (e_2) throw e_2.error; }
58109
+ }
58110
+ drawDetails[drawId].structureDetails = structureDetails;
58111
+ }
58112
+ 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) {
58113
+ var stage = _a.stage;
58114
+ return stage;
58115
+ });
58116
+ if (stagesToAdd.length) {
58117
+ try {
58118
+ 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()) {
58119
+ var stage = stagesToAdd_1_1.value;
58120
+ stageDetails[stage] = { published: true };
58121
+ }
58122
+ }
58123
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
58124
+ finally {
58125
+ try {
58126
+ if (stagesToAdd_1_1 && !stagesToAdd_1_1.done && (_s = stagesToAdd_1.return)) _s.call(stagesToAdd_1);
58127
+ }
58128
+ finally { if (e_3) throw e_3.error; }
58129
+ }
58130
+ try {
58131
+ 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()) {
58132
+ var stage = drawStages_1_1.value;
58133
+ if (!stageDetails[stage]) {
58134
+ stageDetails[stage] = { published: false };
58135
+ }
58136
+ }
58137
+ }
58138
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
58139
+ finally {
58140
+ try {
58141
+ if (drawStages_1_1 && !drawStages_1_1.done && (_t = drawStages_1.return)) _t.call(drawStages_1);
58142
+ }
58143
+ finally { if (e_4) throw e_4.error; }
58144
+ }
58145
+ }
58146
+ if (stagesToAdd.length || stagesToRemove.length) {
58147
+ try {
58148
+ 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()) {
58149
+ var stage = stagesToRemove_1_1.value;
58150
+ stageDetails[stage] = { published: false };
58151
+ }
58152
+ }
58153
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
58154
+ finally {
58155
+ try {
58156
+ if (stagesToRemove_1_1 && !stagesToRemove_1_1.done && (_u = stagesToRemove_1.return)) _u.call(stagesToRemove_1);
58157
+ }
58158
+ finally { if (e_5) throw e_5.error; }
58159
+ }
58160
+ try {
58161
+ 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()) {
58162
+ var stage = drawStages_2_1.value;
58163
+ if (!stageDetails[stage]) {
58164
+ stageDetails[stage] = { published: true };
58165
+ }
58166
+ }
58167
+ }
58168
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
58169
+ finally {
58170
+ try {
58171
+ if (drawStages_2_1 && !drawStages_2_1.done && (_v = drawStages_2.return)) _v.call(drawStages_2);
58172
+ }
58173
+ finally { if (e_6) throw e_6.error; }
58174
+ }
58175
+ }
58176
+ if (stagesToAdd.length || stagesToRemove.length) {
58177
+ drawDetails[drawId].stageDetails = stageDetails;
58178
+ }
58179
+ }
58180
+ };
58181
+ try {
58182
+ for (var eventDrawIds_1 = __values(eventDrawIds), eventDrawIds_1_1 = eventDrawIds_1.next(); !eventDrawIds_1_1.done; eventDrawIds_1_1 = eventDrawIds_1.next()) {
58183
+ var drawId = eventDrawIds_1_1.value;
58184
+ var state_1 = _loop_1(drawId);
58185
+ if (typeof state_1 === "object")
58186
+ return state_1.value;
58187
+ }
57808
58188
  }
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) || [];
58189
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
58190
+ finally {
58191
+ try {
58192
+ if (eventDrawIds_1_1 && !eventDrawIds_1_1.done && (_b = eventDrawIds_1.return)) _b.call(eventDrawIds_1);
58193
+ }
58194
+ finally { if (e_1) throw e_1.error; }
57812
58195
  }
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);
58196
+ modifyEventPublishStatus({
58197
+ statusObject: { drawDetails: drawDetails },
58198
+ removePriorValues: removePriorValues,
58199
+ status: status,
58200
+ event: event,
57816
58201
  });
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
58202
  var eventData = getEventData({
57836
58203
  includePositionAssignments: includePositionAssignments,
57837
58204
  usePublishState: true,
@@ -57839,13 +58206,6 @@ function publishEvent(params) {
57839
58206
  policyDefinitions: policyDefinitions,
57840
58207
  event: event,
57841
58208
  }).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
58209
  addNotice({
57850
58210
  payload: { eventData: eventData, tournamentId: tournamentRecord.tournamentId },
57851
58211
  topic: PUBLISH_EVENT,
@@ -57862,6 +58222,7 @@ var publishingGovernor = {
57862
58222
  getDrawData: getDrawData,
57863
58223
  unPublishEventSeeding: unPublishEventSeeding,
57864
58224
  publishEventSeeding: publishEventSeeding,
58225
+ setEventDisplay: setEventDisplay,
57865
58226
  unPublishEvent: unPublishEvent,
57866
58227
  publishEvent: publishEvent,
57867
58228
  unPublishOrderOfPlay: unPublishOrderOfPlay$1,
@@ -58260,7 +58621,7 @@ var sortingConstants = { ASC: ASC, ASCENDING: ASCENDING, DESC: DESC, DESCENDING:
58260
58621
  // by default if there are no scaleValues matching the scaleAccessor then participants will be assigned in the array order of [team].individidualParticipantIds
58261
58622
  function generateLineUps(params) {
58262
58623
  var e_1, _a, e_2, _b;
58263
- var _c, _d, _e, _f, _g, _h, _j, _k;
58624
+ var _c, _d, _e, _f, _g, _h, _j;
58264
58625
  var tieFormat = params.tieFormat;
58265
58626
  var useDefaultEventRanking = params.useDefaultEventRanking, tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, scaleAccessor = params.scaleAccessor, // e.g. { scaleType: 'RANKINGS', scaleName: 'U18', accessor: 'wtnRating', sortOrder: 'ASC' }
58266
58627
  singlesOnly = params.singlesOnly, // use singles scale for doubles events
@@ -58274,25 +58635,25 @@ function generateLineUps(params) {
58274
58635
  return { error: DRAW_DEFINITION_NOT_FOUND };
58275
58636
  tieFormat =
58276
58637
  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)
58638
+ if (validateTieFormat({ tieFormat: tieFormat }).error)
58278
58639
  return { error: INVALID_TIE_FORMAT };
58279
58640
  if (typeof scaleAccessor !== 'object' && !useDefaultEventRanking)
58280
58641
  return { error: INVALID_VALUES, context: { scaleAccessor: scaleAccessor } };
58281
58642
  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; });
58643
+ 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
58644
  var participantIds = targetEntries.map(getParticipantId);
58284
- var _l = getParticipants$1({
58645
+ var _k = getParticipants$1({
58285
58646
  withIndividualParticipants: true,
58286
58647
  withScaleValues: true,
58287
58648
  tournamentRecord: tournamentRecord,
58288
- }).participants, participants = _l === void 0 ? [] : _l;
58649
+ }).participants, participants = _k === void 0 ? [] : _k;
58289
58650
  var teamParticipants = participants.filter(function (_a) {
58290
58651
  var participantId = _a.participantId;
58291
58652
  return participantIds.includes(participantId);
58292
58653
  });
58293
58654
  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;
58655
+ 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;
58656
+ 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
58657
  var formattedScaleType = formatScaleType(scaleType);
58297
58658
  var getScaleValue = function (individualParticipant, matchUpType) {
58298
58659
  var _a, _b, _c;
@@ -58320,9 +58681,9 @@ function generateLineUps(params) {
58320
58681
  var singlesScaleSort = function (a, b) { return sortMethod(a, b, SINGLES_MATCHUP); };
58321
58682
  var doublesScaleSort = function (a, b) { return sortMethod(a, b, DOUBLES_MATCHUP); };
58322
58683
  var participantIdPairs = [];
58323
- var collectionDefinitions = (_k = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) !== null && _k !== void 0 ? _k : [];
58684
+ var collectionDefinitions = (_j = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions) !== null && _j !== void 0 ? _j : [];
58324
58685
  var _loop_1 = function (teamParticipant) {
58325
- var e_3, _q;
58686
+ var e_3, _p;
58326
58687
  var singlesSort = teamParticipant.individualParticipants.sort(singlesScaleSort);
58327
58688
  var doublesSort = singlesOnly
58328
58689
  ? singlesSort
@@ -58369,7 +58730,7 @@ function generateLineUps(params) {
58369
58730
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
58370
58731
  finally {
58371
58732
  try {
58372
- if (collectionDefinitions_1_1 && !collectionDefinitions_1_1.done && (_q = collectionDefinitions_1.return)) _q.call(collectionDefinitions_1);
58733
+ if (collectionDefinitions_1_1 && !collectionDefinitions_1_1.done && (_p = collectionDefinitions_1.return)) _p.call(collectionDefinitions_1);
58373
58734
  }
58374
58735
  finally { if (e_3) throw e_3.error; }
58375
58736
  }
@@ -61319,13 +61680,13 @@ function getPositionAssignments(_a) {
61319
61680
 
61320
61681
  function deleteDrawDefinitions(params) {
61321
61682
  var e_1, _a;
61322
- var _b, _c, _d, _e, _f, _g;
61683
+ var _b, _c, _d, _e, _f, _g, _h, _j;
61323
61684
  if (!params.tournamentRecord)
61324
61685
  return { error: MISSING_TOURNAMENT_RECORD };
61325
61686
  var stack = 'deleteDrawDefinitions';
61326
61687
  var drawIds = (_b = params.drawIds) !== null && _b !== void 0 ? _b : [];
61327
61688
  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;
61689
+ var _k = params.autoPublish, autoPublish = _k === void 0 ? true : _k, tournamentRecord = params.tournamentRecord, auditData = params.auditData, eventId = params.eventId, force = params.force;
61329
61690
  var appliedPolicies = getAppliedPolicies({ tournamentRecord: tournamentRecord, event: event }).appliedPolicies;
61330
61691
  var policyDefinitions = __assign(__assign({}, appliedPolicies), params.policyDefinitions);
61331
61692
  var drawId = Array.isArray(drawIds) ? drawIds[0] : undefined;
@@ -61365,6 +61726,9 @@ function deleteDrawDefinitions(params) {
61365
61726
  };
61366
61727
  var allowDeletionWithScoresPresent = force ||
61367
61728
  ((_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);
61729
+ var publishStatus = (_e = getEventPublishStatus({ event: event })) !== null && _e !== void 0 ? _e : {};
61730
+ var updatedDrawIds = (_g = (_f = publishStatus.drawIds) !== null && _f !== void 0 ? _f : (publishStatus.drawDetails && Object.keys(publishStatus.drawDetails))) !== null && _g !== void 0 ? _g : [];
61731
+ var publishedDrawsDeleted;
61368
61732
  var drawIdsWithScoresPresent = [];
61369
61733
  var filteredDrawDefinitions = event.drawDefinitions.filter(function (drawDefinition) {
61370
61734
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -61385,6 +61749,10 @@ function deleteDrawDefinitions(params) {
61385
61749
  return STRUCTURE_ENTERED_TYPES.includes(entry.entryStatus);
61386
61750
  });
61387
61751
  }
61752
+ if (updatedDrawIds.includes(drawId_1)) {
61753
+ updatedDrawIds = updatedDrawIds.filter(function (id) { return id !== drawId_1; });
61754
+ publishedDrawsDeleted = true;
61755
+ }
61388
61756
  var mainStructure = (_f = (_e = getDrawStructures({
61389
61757
  stageSequence: 1,
61390
61758
  drawDefinition: drawDefinition,
@@ -61414,6 +61782,7 @@ function deleteDrawDefinitions(params) {
61414
61782
  return { positionAssignments: positionAssignments, stageSequence: stageSequence };
61415
61783
  })
61416
61784
  : undefined;
61785
+ // TODO: conditionally add auditTrail based on policyDefinitions
61417
61786
  var audit = {
61418
61787
  action: DELETE_DRAW_DEFINITIONS,
61419
61788
  payload: {
@@ -61457,43 +61826,29 @@ function deleteDrawDefinitions(params) {
61457
61826
  }
61458
61827
  // cleanup references to drawId in schedulingProfile extension
61459
61828
  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 {
61829
+ if (publishedDrawsDeleted) {
61830
+ var drawDetails = {};
61493
61831
  try {
61494
- if (drawIds_1_1 && !drawIds_1_1.done && (_a = drawIds_1.return)) _a.call(drawIds_1);
61832
+ for (var updatedDrawIds_1 = __values(updatedDrawIds), updatedDrawIds_1_1 = updatedDrawIds_1.next(); !updatedDrawIds_1_1.done; updatedDrawIds_1_1 = updatedDrawIds_1.next()) {
61833
+ var drawId_2 = updatedDrawIds_1_1.value;
61834
+ drawDetails[drawId_2] = (_j = (_h = publishStatus.drawDetails) === null || _h === void 0 ? void 0 : _h[drawId_2]) !== null && _j !== void 0 ? _j : {
61835
+ published: true,
61836
+ };
61837
+ }
61495
61838
  }
61496
- finally { if (e_1) throw e_1.error; }
61839
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
61840
+ finally {
61841
+ try {
61842
+ if (updatedDrawIds_1_1 && !updatedDrawIds_1_1.done && (_a = updatedDrawIds_1.return)) _a.call(updatedDrawIds_1);
61843
+ }
61844
+ finally { if (e_1) throw e_1.error; }
61845
+ }
61846
+ var result = modifyEventPublishStatus({
61847
+ statusObject: { drawDetails: drawDetails },
61848
+ event: event,
61849
+ });
61850
+ if (result.error)
61851
+ return { error: result.error };
61497
61852
  }
61498
61853
  if (auditTrail.length) {
61499
61854
  addNotice({ topic: AUDIT, payload: auditTrail });
@@ -61509,9 +61864,14 @@ function deleteDrawDefinitions(params) {
61509
61864
  });
61510
61865
  addDrawDeletionTelemetry({ event: event, deletedDrawsDetail: deletedDrawsDetail, auditData: auditData });
61511
61866
  if (autoPublish && publishedDrawsDeleted) {
61512
- var result = publishEvent({ tournamentRecord: tournamentRecord, event: event, policyDefinitions: policyDefinitions });
61867
+ var result = publishEvent({
61868
+ drawIdsToRemove: drawIds,
61869
+ policyDefinitions: policyDefinitions,
61870
+ tournamentRecord: tournamentRecord,
61871
+ event: event,
61872
+ });
61513
61873
  if (result.error)
61514
- console.log('publish error', result);
61874
+ return __assign(__assign({}, SUCCESS), { info: result.error });
61515
61875
  }
61516
61876
  return __assign({}, SUCCESS);
61517
61877
  }
@@ -62161,10 +62521,7 @@ function addEvent(_a) {
62161
62521
  var eventRecord = __assign({ drawDefinitions: [], eventType: TypeEnum.Singles, entries: [], startDate: startDate, endDate: endDate }, event);
62162
62522
  if (event.eventType === TypeEnum.Team) {
62163
62523
  if (event.tieFormat) {
62164
- var result = validateTieFormat({
62165
- tieFormat: event.tieFormat,
62166
- eventType: event.eventType,
62167
- });
62524
+ var result = validateTieFormat({ tieFormat: event.tieFormat });
62168
62525
  if (result.error)
62169
62526
  return result;
62170
62527
  }
@@ -64800,7 +65157,6 @@ function generateDrawDefinition(params) {
64800
65157
  gender: event === null || event === void 0 ? void 0 : event.gender,
64801
65158
  enforceGender: enforceGender,
64802
65159
  tieFormat: tieFormat,
64803
- event: event,
64804
65160
  });
64805
65161
  if (result.error)
64806
65162
  return decorateResult({ result: result, stack: stack });
@@ -64828,10 +65184,7 @@ function generateDrawDefinition(params) {
64828
65184
  // there is no need to attach to the drawDefinition
64829
65185
  if (!equivalentInScope) {
64830
65186
  if (tieFormat) {
64831
- var result = checkTieFormat({
64832
- eventType: event.eventType,
64833
- tieFormat: tieFormat,
64834
- });
65187
+ var result = checkTieFormat({ tieFormat: tieFormat });
64835
65188
  if (result.error)
64836
65189
  return decorateResult({ result: result, stack: stack });
64837
65190
  drawDefinition.tieFormat = (_13 = result.tieFormat) !== null && _13 !== void 0 ? _13 : tieFormat;
@@ -65173,7 +65526,7 @@ function generateDrawDefinition(params) {
65173
65526
  }
65174
65527
  drawDefinition.drawName =
65175
65528
  (_33 = params.drawName) !== null && _33 !== void 0 ? _33 : (drawType && constantToString(drawType));
65176
- if (typeof voluntaryConsolation === 'object') {
65529
+ if (typeof voluntaryConsolation === 'object' && drawSize >= 4) {
65177
65530
  addVoluntaryConsolationStructure(__assign(__assign({}, voluntaryConsolation), { tournamentRecord: tournamentRecord, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, matchUpType: matchUpType }));
65178
65531
  }
65179
65532
  if (addToEvent) {
@@ -66375,10 +66728,8 @@ function bulkUpdatePublishedEventIds(_a) {
66375
66728
  if (!eventIdsMap[eventId]) {
66376
66729
  eventIdsMap[eventId] = [drawId];
66377
66730
  }
66378
- else {
66379
- if (!eventIdsMap[eventId].includes(drawId)) {
66380
- eventIdsMap[eventId].push(drawId);
66381
- }
66731
+ else if (!eventIdsMap[eventId].includes(drawId)) {
66732
+ eventIdsMap[eventId].push(drawId);
66382
66733
  }
66383
66734
  }
66384
66735
  return eventIdsMap;
@@ -66389,15 +66740,16 @@ function bulkUpdatePublishedEventIds(_a) {
66389
66740
  });
66390
66741
  var publishedEventIds = relevantEvents
66391
66742
  .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;
66743
+ var pubStatus = getEventPublishStatus({ event: event });
66744
+ var _a = pubStatus !== null && pubStatus !== void 0 ? pubStatus : {}, drawDetails = _a.drawDetails, drawIds = _a.drawIds;
66397
66745
  var eventId = event.eventId;
66398
66746
  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);
66747
+ var keyedDrawIds = drawDetails
66748
+ ? Object.keys(pubStatus.drawDetails).filter(function (drawId) {
66749
+ return getDrawPublishStatus({ drawId: drawId, drawDetails: drawDetails });
66750
+ })
66751
+ : [];
66752
+ return (drawIds === null || drawIds === void 0 ? void 0 : drawIds.includes(drawId)) || keyedDrawIds.includes(drawId);
66401
66753
  });
66402
66754
  return publishedDrawIds.length;
66403
66755
  })