tods-competition-factory 2.1.7 → 2.1.8

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.
@@ -4961,7 +4961,8 @@ declare function generateStatCrew(params: any): (ResultType & {
4961
4961
  valid?: boolean | undefined;
4962
4962
  }) | {
4963
4963
  success: boolean;
4964
- xml: any;
4964
+ json: any[];
4965
+ xml: string[];
4965
4966
  };
4966
4967
 
4967
4968
  type GenerateLineUpsArgs = {
@@ -7903,7 +7904,7 @@ type GetStructureReportsArgs = {
7903
7904
  extensionProfiles?: any[];
7904
7905
  firstFlightOnly?: boolean;
7905
7906
  };
7906
- declare function getStructureReports({ firstFlightOnly, extensionProfiles, tournamentRecord, }: GetStructureReportsArgs): {
7907
+ declare function getStructureReports(params: GetStructureReportsArgs): {
7907
7908
  error: {
7908
7909
  message: string;
7909
7910
  code: string;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.1.7';
6
+ return '2.1.8';
7
7
  }
8
8
 
9
9
  function isFunction(obj) {
@@ -14787,8 +14787,8 @@ function assignMatchUpDrawPosition({ inContextDrawMatchUps, sourceMatchUpStatus,
14787
14787
  const matchUp = matchUpsMap?.drawMatchUps?.find((matchUp) => matchUp.matchUpId === matchUpId);
14788
14788
  const drawPositions = matchUp?.drawPositions ?? [];
14789
14789
  const { positionAdded, positionAssigned, updatedDrawPositions } = getUpdatedDrawPositions({
14790
- drawPosition,
14791
14790
  drawPositions,
14791
+ drawPosition,
14792
14792
  });
14793
14793
  const { positionAssignments } = getPositionAssignments$1({
14794
14794
  drawDefinition,
@@ -38993,7 +38993,7 @@ function setEventDates(params) {
38993
38993
  endDate: false,
38994
38994
  },
38995
38995
  {
38996
- [VALIDATE]: (value) => value.every((d) => dateValidation.test(d)),
38996
+ [VALIDATE]: (value) => value.filter(Boolean).every((d) => dateValidation.test(d)),
38997
38997
  [INVALID]: INVALID_DATE,
38998
38998
  activeDates: false,
38999
38999
  },
@@ -39004,7 +39004,8 @@ function setEventDates(params) {
39004
39004
  ]);
39005
39005
  if (paramsCheck.error)
39006
39006
  return paramsCheck;
39007
- const { tournamentRecord, activeDates, weekdays, event, startDate, endDate } = params;
39007
+ const { tournamentRecord, weekdays, event, startDate, endDate } = params;
39008
+ const activeDates = params.activeDates?.filter(Boolean);
39008
39009
  if (startDate && endDate) {
39009
39010
  const newStartDate = new Date(extractDate(startDate)).getTime();
39010
39011
  const newEndDate = new Date(extractDate(endDate)).getTime();
@@ -40230,6 +40231,60 @@ function generateStatCrew(params) {
40230
40231
  tournamentRecord,
40231
40232
  });
40232
40233
  const teamParticipants = tournamentRecord.participants.filter((participant) => participant.participantType === TEAM);
40234
+ const teamMatchUps = matchUps?.filter((matchUp) => matchUp.matchUpType === TEAM) ?? [];
40235
+ const tieMatchUps = teamMatchUps?.reduce((t, matchUp) => {
40236
+ const tieMatchUps = matchUp?.tieMatchUps ?? [];
40237
+ return tieMatchUps ? [...t, ...tieMatchUps] : tieMatchUps;
40238
+ }, []) ?? [];
40239
+ const singles = matchUps?.filter((matchUp) => matchUp.matchUpType === SINGLES) ?? [];
40240
+ const doubles = matchUps?.filter((matchUp) => matchUp.matchUpType === DOUBLES) ?? [];
40241
+ const allDuals = tieMatchUps.length === singles.length + doubles.length;
40242
+ const isDual = teamMatchUps.length === 1 && allDuals;
40243
+ const tournament = !allDuals ? 'Y' : 'N';
40244
+ const attrs = {
40245
+ mappedMatchUps,
40246
+ participantMap,
40247
+ tournamentName,
40248
+ tournamentId,
40249
+ tournament,
40250
+ startDate,
40251
+ };
40252
+ const xmlResult = [];
40253
+ const jsonResult = [];
40254
+ if (isDual) {
40255
+ const teamMatchUp = teamMatchUps[0];
40256
+ const { json, xml } = getXml({
40257
+ teamParticipants,
40258
+ teamMatchUp,
40259
+ ...attrs,
40260
+ doubles,
40261
+ singles,
40262
+ });
40263
+ jsonResult.push(json);
40264
+ xmlResult.push(xml);
40265
+ }
40266
+ else {
40267
+ for (const teamMatchUp of teamMatchUps) {
40268
+ const teamParticipantIds = teamMatchUp?.sides
40269
+ ?.map(({ participant }) => participant?.participantId)
40270
+ .filter(Boolean);
40271
+ if (teamParticipantIds?.length !== 2)
40272
+ continue;
40273
+ const teamParticipants = teamParticipantIds.map((participantId) => participantId && participantMap?.[participantId]?.participant);
40274
+ const { xml, json } = getXml({
40275
+ doubles: teamMatchUp.tieMatchUps?.filter((matchUp) => matchUp.matchUpType === DOUBLES),
40276
+ singles: teamMatchUp.tieMatchUps?.filter((matchUp) => matchUp.matchUpType === SINGLES),
40277
+ teamParticipants,
40278
+ teamMatchUp,
40279
+ ...attrs,
40280
+ });
40281
+ jsonResult.push(json);
40282
+ xmlResult.push(xml);
40283
+ }
40284
+ }
40285
+ return { json: jsonResult, xml: xmlResult, ...SUCCESS };
40286
+ }
40287
+ function getXml({ teamParticipants, mappedMatchUps, participantMap, tournamentName, tournamentId, teamMatchUp, tournament, startDate, doubles, singles, }) {
40233
40288
  const homeTeam = teamParticipants?.find((team) => team.participantRoleResponsibilities?.includes('Home'));
40234
40289
  const awayTeams = teamParticipants?.filter((team) => team.participantId !== homeTeam?.participantId);
40235
40290
  const date = formatDate(startDate, '/', 'MDY');
@@ -40237,109 +40292,17 @@ function generateStatCrew(params) {
40237
40292
  const homeid = homeTeam?.participantId || awayTeams?.[1]?.participantId;
40238
40293
  const visname = awayTeams?.[0]?.participantName;
40239
40294
  const visid = awayTeams?.[0]?.participantId;
40240
- const singles = matchUps?.filter((matchUp) => matchUp.matchUpType === SINGLES);
40241
- const doubles = matchUps?.filter((matchUp) => matchUp.matchUpType === DOUBLES);
40242
40295
  const uniValues = {};
40243
- const getTeam = (teamParticipant) => {
40244
- const { participantId: id, participantName: name } = teamParticipant;
40245
- const vh = (homeid && (id === homeid ? 'H' : 'V')) || '';
40246
- const teamMatchUps = participantMap?.[id]?.matchUps;
40247
- const matchUpIds = teamMatchUps && Object.keys(teamMatchUps);
40248
- uniValues[id] = {};
40249
- const winLoss = { SINGLES: { w: 0, l: 0 }, DOUBLES: { w: 0, l: 0 } };
40250
- const doubles = [];
40251
- const singles = [];
40252
- let score = 0;
40253
- for (const matchUpId of matchUpIds ?? []) {
40254
- const matchUp = mappedMatchUps?.[matchUpId];
40255
- const sideNumber = matchUp.sides.find(({ participant }) => participant.participantId === id)?.sideNumber;
40256
- const matchScore = matchUp.score?.sets?.[0]?.[`side${sideNumber}Score`] ?? 0;
40257
- score += matchScore;
40258
- for (const tieMatchUp of matchUp.tieMatchUps ?? []) {
40259
- const { matchUpType, winningSide } = tieMatchUp;
40260
- const wl = (winningSide && (winningSide === sideNumber ? 'w' : 'l')) || '';
40261
- if (wl)
40262
- winLoss[matchUpType][wl] += 1;
40263
- const won = wl === 'w' ? '1' : '0';
40264
- const lost = wl === 'l' ? '1' : '0';
40265
- if (matchUpType === SINGLES) {
40266
- const pair = singles.length + 1;
40267
- singles.push({ singles_pair: { pair, won, lost } });
40268
- }
40269
- else if (matchUpType === DOUBLES) {
40270
- const pair = doubles.length + 1;
40271
- doubles.push({ doubles_pair: { pair, won, lost } });
40272
- }
40273
- }
40274
- }
40275
- const totals = [
40276
- { singles: { childArray: singles, won: winLoss.SINGLES.w, lost: winLoss.SINGLES.l } },
40277
- { doubles: { childArray: doubles, won: winLoss.DOUBLES.w, lost: winLoss.DOUBLES.l } },
40278
- ];
40279
- const players = [];
40280
- let playerIndex = 1;
40281
- for (const individualParticipantId of teamParticipant.individualParticipantIds) {
40282
- const mappedParticipant = participantMap?.[individualParticipantId];
40283
- if (mappedParticipant) {
40284
- const { participant, counters } = mappedParticipant;
40285
- const doublesStats = { won: counters?.DOUBLES?.wins || 0, lost: counters?.DOUBLES?.losses || 0 };
40286
- const singlesStats = { won: counters?.SINGLES?.wins || 0, lost: counters?.SINGLES?.losses || 0 };
40287
- const { participantName: name, participantId } = participant;
40288
- uniValues[id][participantId] = playerIndex;
40289
- players.push({ player: { name, uni: playerIndex, singles: singlesStats, doubles: doublesStats } });
40290
- }
40291
- playerIndex += 1;
40292
- }
40293
- return { vh, id, name, score, totals, childArray: players };
40294
- };
40295
- const teams = teamParticipants.map((p) => ({ team: { ...getTeam(p) } }));
40296
- const getScoreAttributes = ({ sets, sideNumber }) => Object.assign({}, ...(sets?.map((set) => {
40297
- const { setNumber, side1Score, side2Score, side1TiebreakScore, side2TiebreakScore } = set;
40298
- const setKey = `set_${setNumber}`;
40299
- const tbKey = `tie_${setNumber}`;
40300
- const setValue = sideNumber === 1 ? side1Score : side2Score;
40301
- const tieValue = sideNumber === 1 ? side1TiebreakScore : side2TiebreakScore;
40302
- return { [setKey]: setValue, [tbKey]: tieValue };
40303
- }) ?? []));
40304
- const getParticipantAttibutes = ({ participant }) => {
40305
- if (!participant)
40306
- return {};
40307
- const pair = participant.individualParticipants?.length === 2;
40308
- const pairTeamParticipantIds = pair
40309
- ? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.participantId))
40310
- : [];
40311
- const pairTeamIds = pair ? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.teamId)) : [];
40312
- const teamParticipantId = (!pair && participant.teams?.[0]?.participantId) ||
40313
- (pairTeamParticipantIds?.length === 1 && pairTeamParticipantIds[0]) ||
40314
- undefined;
40315
- const team = (!pair && participant.teams?.[0]?.teamId) || (pairTeamIds?.length === 1 && pairTeamIds[0]) || teamParticipantId;
40316
- const name = !pair ? participant.participantName : undefined;
40317
- const name_1 = participant.individualParticipants?.[0]?.participantName;
40318
- const name_2 = participant.individualParticipants?.[1]?.participantName;
40319
- const vh = (homeid && (teamParticipantId === homeid ? 'H' : 'V')) || '';
40320
- const uni = !pair ? uniValues[teamParticipantId][participant.participantId] : undefined;
40321
- const uni_1 = uniValues[teamParticipantId][participant.individualParticipants?.[0]?.participantId];
40322
- const uni_2 = uniValues[teamParticipantId][participant.individualParticipants?.[1]?.participantId];
40323
- return definedAttributes({ vh, uni, uni_1, uni_2, team, name, name_1, name_2 });
40324
- };
40325
- const mapMatchUp = (matchUp) => {
40326
- const { collectionPosition: match, orderOfFinish: order, matchUpType, sides } = matchUp ?? {};
40327
- const childArray = sides?.map((side) => {
40328
- const { sideNumber, participant } = side;
40329
- const scoreAttributes = getScoreAttributes({ sets: matchUp.score?.sets, sideNumber });
40330
- const scoreType = matchUpType === SINGLES ? 'singles_score' : 'doubles_score';
40331
- return { [scoreType]: { ...getParticipantAttibutes({ participant }), ...scoreAttributes } };
40332
- });
40333
- const matchType = matchUpType === SINGLES ? 'singles_match' : 'doubles_match';
40334
- return { [matchType]: { match, order, childArray } };
40335
- };
40336
- const json = {
40296
+ const teams = teamParticipants.map((teamParticipant) => ({
40297
+ team: { ...getTeam({ teamParticipant, teamMatchUp, uniValues, participantMap, mappedMatchUps, homeid }) },
40298
+ }));
40299
+ const json = definedAttributes({
40337
40300
  venue: {
40338
- tournament: teamParticipants?.length > 2 ? 'Y' : 'N',
40301
+ tournamentname: tournament ? tournamentName : undefined,
40339
40302
  neutralgame: !homeTeam ? 'Y' : 'N',
40340
- tournamentname: tournamentName,
40341
40303
  gameid: tournamentId,
40342
40304
  officials: {},
40305
+ tournament,
40343
40306
  rules: {},
40344
40307
  homename,
40345
40308
  visname,
@@ -40348,11 +40311,107 @@ function generateStatCrew(params) {
40348
40311
  date,
40349
40312
  },
40350
40313
  childArray: teams,
40351
- singles_matches: singles?.map(mapMatchUp),
40352
- doubles_matches: doubles?.map(mapMatchUp),
40353
- };
40354
- const xml = jsonToXml({ json, tagName: 'tngame' });
40355
- return { xml, ...SUCCESS };
40314
+ singles_matches: singles?.map((matchUp) => mapMatchUp({ matchUp, homeid, uniValues })),
40315
+ doubles_matches: doubles?.map((matchUp) => mapMatchUp({ matchUp, homeid, uniValues })),
40316
+ });
40317
+ return { json, xml: jsonToXml({ json, tagName: 'tngame' }) };
40318
+ }
40319
+ function getParticipantAttibutes({ homeid, uniValues, participant }) {
40320
+ if (!participant)
40321
+ return {};
40322
+ const pair = participant.individualParticipants?.length === 2;
40323
+ const pairTeamParticipantIds = pair
40324
+ ? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.participantId))
40325
+ : [];
40326
+ const pairTeamIds = pair ? unique(participant.individualParticipants?.map((p) => p.teams?.[0]?.teamId)) : [];
40327
+ const teamParticipantId = (!pair && participant.teams?.[0]?.participantId) ||
40328
+ (pairTeamParticipantIds?.length === 1 && pairTeamParticipantIds[0]) ||
40329
+ undefined;
40330
+ const team = (!pair && participant.teams?.[0]?.teamId) || (pairTeamIds?.length === 1 && pairTeamIds[0]) || teamParticipantId;
40331
+ const name = !pair ? participant.participantName : undefined;
40332
+ const name_1 = participant.individualParticipants?.[0]?.participantName;
40333
+ const name_2 = participant.individualParticipants?.[1]?.participantName;
40334
+ const vh = (homeid && (teamParticipantId === homeid ? 'H' : 'V')) || '';
40335
+ const uni = !pair ? uniValues[teamParticipantId][participant.participantId] : undefined;
40336
+ const uni_1 = uniValues[teamParticipantId][participant.individualParticipants?.[0]?.participantId];
40337
+ const uni_2 = uniValues[teamParticipantId][participant.individualParticipants?.[1]?.participantId];
40338
+ return definedAttributes({ vh, uni, uni_1, uni_2, team, name, name_1, name_2 });
40339
+ }
40340
+ function getScoreAttributes({ sets, sideNumber }) {
40341
+ return Object.assign({}, ...(sets?.map((set) => {
40342
+ const { setNumber, side1Score, side2Score, side1TiebreakScore, side2TiebreakScore } = set;
40343
+ const setKey = `set_${setNumber}`;
40344
+ const tbKey = `tie_${setNumber}`;
40345
+ const setValue = sideNumber === 1 ? side1Score : side2Score;
40346
+ const tieValue = sideNumber === 1 ? side1TiebreakScore : side2TiebreakScore;
40347
+ return { [setKey]: setValue, [tbKey]: tieValue };
40348
+ }) ?? []));
40349
+ }
40350
+ function getTeam({ teamParticipant, teamMatchUp, participantMap, mappedMatchUps, homeid, uniValues }) {
40351
+ const { participantId: id, participantName: name } = teamParticipant;
40352
+ const vh = (homeid && (id === homeid ? 'H' : 'V')) || '';
40353
+ const teamMatchUps = participantMap?.[id]?.matchUps;
40354
+ const matchUpIds = teamMatchUps && Object.keys(teamMatchUps);
40355
+ const teamSideNumber = teamMatchUp?.sides?.find(({ participant }) => participant.participantId === id)?.sideNumber;
40356
+ const setScore = teamMatchUp?.score?.sets?.[0]?.[`side${teamSideNumber}Score`] ?? 0;
40357
+ uniValues[id] = {};
40358
+ const winLoss = { SINGLES: { w: 0, l: 0 }, DOUBLES: { w: 0, l: 0 } };
40359
+ const doubles = [];
40360
+ const singles = [];
40361
+ let calcScore = 0;
40362
+ for (const matchUpId of matchUpIds ?? []) {
40363
+ const matchUp = mappedMatchUps?.[matchUpId];
40364
+ const sideNumber = matchUp.sides.find(({ participant }) => participant.participantId === id)?.sideNumber;
40365
+ const matchScore = matchUp.score?.sets?.[0]?.[`side${sideNumber}Score`] ?? 0;
40366
+ calcScore += matchScore;
40367
+ for (const tieMatchUp of matchUp.tieMatchUps ?? []) {
40368
+ const { matchUpType, winningSide } = tieMatchUp;
40369
+ const wl = (winningSide && (winningSide === sideNumber ? 'w' : 'l')) || '';
40370
+ if (wl)
40371
+ winLoss[matchUpType][wl] += 1;
40372
+ const won = wl === 'w' ? '1' : '0';
40373
+ const lost = wl === 'l' ? '1' : '0';
40374
+ if (matchUpType === SINGLES) {
40375
+ const pair = singles.length + 1;
40376
+ singles.push({ singles_pair: { pair, won, lost, tied: '0' } });
40377
+ }
40378
+ else if (matchUpType === DOUBLES) {
40379
+ const pair = doubles.length + 1;
40380
+ doubles.push({ doubles_pair: { pair, won, lost, tied: '0' } });
40381
+ }
40382
+ }
40383
+ }
40384
+ const totals = [
40385
+ { singles: { childArray: singles, won: winLoss.SINGLES.w, lost: winLoss.SINGLES.l } },
40386
+ { doubles: { childArray: doubles, won: winLoss.DOUBLES.w, lost: winLoss.DOUBLES.l } },
40387
+ ];
40388
+ const players = [];
40389
+ let playerIndex = 1;
40390
+ for (const individualParticipantId of teamParticipant.individualParticipantIds) {
40391
+ const mappedParticipant = participantMap?.[individualParticipantId];
40392
+ if (mappedParticipant) {
40393
+ const { participant, counters } = mappedParticipant;
40394
+ const doublesStats = { won: counters?.DOUBLES?.wins || 0, lost: counters?.DOUBLES?.losses || 0 };
40395
+ const singlesStats = { won: counters?.SINGLES?.wins || 0, lost: counters?.SINGLES?.losses || 0 };
40396
+ const { participantName: name, participantId } = participant;
40397
+ uniValues[id][participantId] = playerIndex;
40398
+ players.push({ player: { name, uni: playerIndex, singles: singlesStats, doubles: doublesStats } });
40399
+ }
40400
+ playerIndex += 1;
40401
+ }
40402
+ const score = setScore || calcScore;
40403
+ return { vh, id, name, score, totals, childArray: players };
40404
+ }
40405
+ function mapMatchUp({ matchUp, homeid, uniValues }) {
40406
+ const { collectionPosition: match, orderOfFinish: order, matchUpType, sides } = matchUp ?? {};
40407
+ const childArray = sides?.map((side) => {
40408
+ const { sideNumber, participant } = side;
40409
+ const scoreAttributes = getScoreAttributes({ sets: matchUp.score?.sets, sideNumber });
40410
+ const scoreType = matchUpType === SINGLES ? 'singles_score' : 'doubles_score';
40411
+ return { [scoreType]: { ...getParticipantAttibutes({ homeid, uniValues, participant }), ...scoreAttributes } };
40412
+ });
40413
+ const matchType = matchUpType === SINGLES ? 'singles_match' : 'doubles_match';
40414
+ return { [matchType]: { match, order, childArray } };
40356
40415
  }
40357
40416
 
40358
40417
  const ASC = 'ASC';
@@ -42482,6 +42541,8 @@ function doubleExitAdvancement(params) {
42482
42541
  return decorateResult({ result: { ...SUCCESS }, stack });
42483
42542
  const { matchUp: sourceMatchUp, targetMatchUps, targetLinks } = targetData;
42484
42543
  const { loserMatchUp, winnerMatchUp, loserTargetDrawPosition } = targetMatchUps;
42544
+ const loserMatchUpIsEmptyExit = [WALKOVER$2, DEFAULTED].includes(loserMatchUp?.matchUpStatus) &&
42545
+ !loserMatchUp.sides?.map((side) => side.participantId ?? side.participant).filter(Boolean).length;
42485
42546
  if (loserMatchUp && loserMatchUp.matchUpStatus !== BYE) {
42486
42547
  const { loserTargetLink } = targetLinks;
42487
42548
  if (appliedPolicies?.progression?.doubleExitPropagateBye) {
@@ -42497,7 +42558,7 @@ function doubleExitAdvancement(params) {
42497
42558
  if (result.error)
42498
42559
  return decorateResult({ result, stack });
42499
42560
  }
42500
- else {
42561
+ else if (!loserMatchUpIsEmptyExit) {
42501
42562
  const { feedRound, drawPositions, matchUpId } = loserMatchUp;
42502
42563
  const walkoverWinningSide = feedRound ? 2 : 2 - drawPositions.indexOf(loserTargetDrawPosition);
42503
42564
  const result = conditionallyAdvanceDrawPosition({
@@ -43100,6 +43161,19 @@ function removeDoubleExit(params) {
43100
43161
  });
43101
43162
  }
43102
43163
  const byePropagatedToLoserMatchUp = loserMatchUp?.matchUpStatus === BYE && (loserMatchUp?.feedRound || loserMatchUp?.roundNumber === 1);
43164
+ const isFMLC = targetData?.targetLinks?.loserTargetLink?.linkCondition === FIRST_MATCHUP;
43165
+ if (byePropagatedToLoserMatchUp && isFMLC) {
43166
+ const roundMatchUps = inContextDrawMatchUps.filter(({ roundNumber, structureId }) => structureId === matchUp.structureId && roundNumber === 1);
43167
+ const roundPositions = roundMatchUps.map(({ roundPosition }) => roundPosition);
43168
+ const pairedPosition = chunkArray(roundPositions.sort(), 2)
43169
+ .find((chunk) => chunk.includes(matchUp.roundPosition))
43170
+ .filter((position) => position !== matchUp.roundPosition)[0];
43171
+ const pairedMatchUpStatus = roundMatchUps.find(({ roundPosition }) => roundPosition === pairedPosition)?.matchUpStatus;
43172
+ const pairedMatchUpIsDoubleExit = [DOUBLE_DEFAULT, DOUBLE_WALKOVER].includes(pairedMatchUpStatus);
43173
+ if (pairedMatchUpIsDoubleExit) {
43174
+ return decorateResult({ result: { ...SUCCESS }, stack });
43175
+ }
43176
+ }
43103
43177
  if (loserMatchUp && (loserMatchUp.matchUpStatus !== BYE || byePropagatedToLoserMatchUp)) {
43104
43178
  const inContextLoserMatchUp = inContextDrawMatchUps.find(({ matchUpId }) => matchUpId === loserMatchUp.matchUpId);
43105
43179
  const { structure: loserStructure } = findStructure({
@@ -52897,7 +52971,8 @@ function getAvgWTN({ eventType, matchUps, eventId, drawId }) {
52897
52971
  };
52898
52972
  }
52899
52973
 
52900
- function getStructureReports({ firstFlightOnly = true, extensionProfiles, tournamentRecord, }) {
52974
+ function getStructureReports(params) {
52975
+ const { tournamentRecord, extensionProfiles, firstFlightOnly } = params;
52901
52976
  if (!tournamentRecord)
52902
52977
  return { error: MISSING_TOURNAMENT_ID };
52903
52978
  const mainStructures = [];
@@ -52944,7 +53019,7 @@ function getStructureReports({ firstFlightOnly = true, extensionProfiles, tourna
52944
53019
  const drawDeletionsExtension = extensions?.find((x) => x.name === DRAW_DELETIONS);
52945
53020
  const drawDeletionsTimeItem = eventTimeItems?.find((x) => x.itemType === DRAW_DELETIONS);
52946
53021
  const drawDeletionsCount = drawDeletionsExtension?.value?.length || drawDeletionsTimeItem?.itemValue || 0;
52947
- const mapValues = Object.values(flightMap);
53022
+ const mapValues = Object.values(flightMap ?? {});
52948
53023
  const minFlightNumber = flightMap && Math.min(...mapValues);
52949
53024
  const eventSeedingBasis = getSeedingBasis(eventTimeItems);
52950
53025
  eventStructureReports[eventId] = {
@@ -56249,7 +56324,8 @@ function updateCourtAvailability({ tournamentRecord }) {
56249
56324
  }
56250
56325
 
56251
56326
  function setTournamentDates(params) {
56252
- const { tournamentRecord, startDate, endDate, activeDates, weekdays } = params;
56327
+ const { tournamentRecord, startDate, endDate, weekdays } = params;
56328
+ const activeDates = params.activeDates?.filter(Boolean);
56253
56329
  const paramsCheck = checkRequiredParameters(params, [
56254
56330
  { tournamentRecord: true },
56255
56331
  {
@@ -56259,7 +56335,7 @@ function setTournamentDates(params) {
56259
56335
  endDate: false,
56260
56336
  },
56261
56337
  {
56262
- [VALIDATE]: (value) => value.every((d) => dateValidation.test(d)),
56338
+ [VALIDATE]: (value) => value.filter(Boolean).every((d) => dateValidation.test(d)),
56263
56339
  [INVALID]: INVALID_DATE,
56264
56340
  activeDates: false,
56265
56341
  },
@@ -56274,7 +56350,7 @@ function setTournamentDates(params) {
56274
56350
  return { error: INVALID_VALUES };
56275
56351
  if (endDate && startDate && new Date(startDate) > new Date(endDate))
56276
56352
  return { error: INVALID_VALUES };
56277
- if (activeDates) {
56353
+ if (activeDates?.length) {
56278
56354
  const start = startDate || tournamentRecord.startDate;
56279
56355
  const end = endDate || tournamentRecord.endDate;
56280
56356
  const validStart = !start || activeDates.every((d) => new Date(d) >= new Date(start));