tods-competition-factory 1.7.5 → 1.7.7

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.
package/dist/index.mjs CHANGED
@@ -333,7 +333,7 @@ const matchUpFormatCode = {
333
333
  };
334
334
 
335
335
  function factoryVersion() {
336
- return "1.7.5";
336
+ return "1.7.7";
337
337
  }
338
338
 
339
339
  function getObjectTieFormat(obj) {
@@ -1727,6 +1727,9 @@ function handleCaughtError({
1727
1727
  });
1728
1728
  }
1729
1729
 
1730
+ function isString(obj) {
1731
+ return typeof obj === "string";
1732
+ }
1730
1733
  function isObject(obj) {
1731
1734
  return typeof obj === "object";
1732
1735
  }
@@ -4163,7 +4166,7 @@ const WIN_RATIO$1 = "winRatio";
4163
4166
  const POLICY_COMPETITIVE_BANDS_DEFAULT = {
4164
4167
  [POLICY_TYPE_COMPETITIVE_BANDS]: {
4165
4168
  policyName: "Competitive Bands Default",
4166
- competitiveProfile: {
4169
+ profileBands: {
4167
4170
  [DECISIVE]: 20,
4168
4171
  [ROUTINE]: 50
4169
4172
  }
@@ -4217,7 +4220,8 @@ function getCollectionPositionMatchUps({ matchUps }) {
4217
4220
 
4218
4221
  const add = (a, b) => (a || 0) + (b || 0);
4219
4222
  function getBand(spread, bandProfiles) {
4220
- return isNaN(spread) && WALKOVER$1 || spread <= bandProfiles[DECISIVE] && DECISIVE || spread <= bandProfiles[ROUTINE] && ROUTINE || COMPETITIVE;
4223
+ const spreadValue = Array.isArray(spread) ? spread[0] : spread;
4224
+ return isNaN(spreadValue) && WALKOVER$1 || spreadValue <= bandProfiles[DECISIVE] && DECISIVE || spreadValue <= bandProfiles[ROUTINE] && ROUTINE || COMPETITIVE;
4221
4225
  }
4222
4226
  function getScoreComponents({ score }) {
4223
4227
  const sets = score?.sets || [];
@@ -4248,7 +4252,7 @@ function gamesPercent(scoreComponents) {
4248
4252
  return Math.round(minGames / maxGames * 100);
4249
4253
  }
4250
4254
  function pctSpread(pcts) {
4251
- return pcts.map(gamesPercent).sort().map((p) => p.toFixed(2));
4255
+ return pcts.map(gamesPercent).sort().map((p) => parseFloat(p.toFixed(2)));
4252
4256
  }
4253
4257
 
4254
4258
  function findPolicy({
@@ -4269,8 +4273,8 @@ function findPolicy({
4269
4273
  return appliedPolicies?.[policyType] ? { policy: appliedPolicies[policyType] } : { error: POLICY_NOT_FOUND };
4270
4274
  }
4271
4275
 
4272
- function getMatchUpCompetitiveness({
4273
- competitiveProfile,
4276
+ function getMatchUpCompetitiveProfile({
4277
+ profileBands,
4274
4278
  tournamentRecord,
4275
4279
  matchUp
4276
4280
  }) {
@@ -4279,15 +4283,16 @@ function getMatchUpCompetitiveness({
4279
4283
  const { score, winningSide } = matchUp;
4280
4284
  if (!winningSide)
4281
4285
  return { error: INVALID_VALUES };
4282
- const policy = !competitiveProfile && tournamentRecord && findPolicy({
4286
+ const policy = !profileBands && tournamentRecord && findPolicy({
4283
4287
  policyType: POLICY_TYPE_COMPETITIVE_BANDS,
4284
4288
  tournamentRecord
4285
4289
  }).policy;
4286
- const bandProfiles = competitiveProfile || policy?.competitiveProfile || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].competitiveProfile;
4290
+ const bandProfiles = profileBands || policy?.profileBands || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].profileBands;
4287
4291
  const scoreComponents = getScoreComponents({ score });
4288
4292
  const spread = pctSpread([scoreComponents]);
4289
4293
  const competitiveness = getBand(spread, bandProfiles);
4290
- return { ...SUCCESS, competitiveness };
4294
+ const pctSpreadValue = Array.isArray(spread) ? spread[0] : spread;
4295
+ return { ...SUCCESS, competitiveness, pctSpread: pctSpreadValue };
4291
4296
  }
4292
4297
 
4293
4298
  function findMatchupFormatAverageTimes(params) {
@@ -7606,6 +7611,9 @@ function isAdHoc({ drawDefinition, structure }) {
7606
7611
  const POLICY_ROUND_NAMING_DEFAULT = {
7607
7612
  [POLICY_TYPE_ROUND_NAMING]: {
7608
7613
  policyName: "Round Naming Default",
7614
+ namingConventions: {
7615
+ round: "Round"
7616
+ },
7609
7617
  abbreviatedRoundNamingMap: {
7610
7618
  // key is matchUpsCount for the round
7611
7619
  1: "F",
@@ -7645,6 +7653,9 @@ function getRoundContextProfile({
7645
7653
  const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
7646
7654
  const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
7647
7655
  const roundNamePrefix = roundNamingPolicy?.affixes || defaultRoundNamingPolicy.affixes;
7656
+ const roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
7657
+ const namingConventions = roundNamingPolicy?.namingConventions || defaultRoundNamingPolicy.namingConventions;
7658
+ const roundNameFallback = namingConventions.round;
7648
7659
  const stageInitial = stage && stage !== MAIN && stage[0];
7649
7660
  const stageConstants = roundNamingPolicy?.stageConstants;
7650
7661
  const stageConstant = stage && stageConstants?.[stage] || stageInitial;
@@ -7653,8 +7664,8 @@ function getRoundContextProfile({
7653
7664
  Object.assign(
7654
7665
  roundNamingProfile,
7655
7666
  ...roundProfileKeys.map((key) => {
7656
- const roundName = `Round ${key}`;
7657
- const abbreviatedRoundName = `R${key}`;
7667
+ const roundName = `${roundNameFallback} ${key}`;
7668
+ const abbreviatedRoundName = `${roundNumberAffix}${key}`;
7658
7669
  return { [key]: { roundName, abbreviatedRoundName } };
7659
7670
  })
7660
7671
  );
@@ -8012,7 +8023,7 @@ function getAllStructureMatchUps({
8012
8023
  ...collectionDefinition.category
8013
8024
  } : context?.category;
8014
8025
  const processCodes = matchUp.processCodes?.length && matchUp.processCodes || collectionDefinition?.processCodes?.length && collectionDefinition?.processCodes || structure?.processCodes?.length && structure?.processCodes || drawDefinition?.processCodes?.length && drawDefinition?.processCodes || event2?.processCodes?.length && event2?.processCodes || tournamentRecord?.processCodes;
8015
- const competitiveness = contextProfile?.withCompetitiveness && getMatchUpCompetitiveness({ ...contextContent, matchUp }).competitiveness;
8026
+ const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
8016
8027
  const finishingPositionRange = matchUp.finishingPositionRange || additionalContext.finishingPositionRange;
8017
8028
  const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
8018
8029
  const matchUpWithContext = {
@@ -8028,7 +8039,7 @@ function getAllStructureMatchUps({
8028
8039
  finishingPositionRange,
8029
8040
  abbreviatedRoundName,
8030
8041
  drawPositionsRange,
8031
- competitiveness,
8042
+ competitiveProfile,
8032
8043
  structureName,
8033
8044
  stageSequence,
8034
8045
  drawPositions,
@@ -13381,13 +13392,19 @@ const ratingConstants = {
13381
13392
  };
13382
13393
 
13383
13394
  const ratingsParameters = {
13384
- [ELO]: { range: [0, 3e3], decimalsCount: 0, defaultInitialization: 1500 },
13395
+ [ELO]: {
13396
+ defaultInitialization: 1500,
13397
+ decimalsCount: 0,
13398
+ range: [0, 3e3],
13399
+ ascending: true
13400
+ },
13385
13401
  [NTRP]: {
13386
13402
  accessors: ["ntrpRating", "dntrpRatingHundredths"],
13387
13403
  attributes: { ustaRatingType: "" },
13388
13404
  accessor: "dntrpRatingHundredths",
13389
13405
  defaultInitialization: 3,
13390
13406
  decimalsCount: 1,
13407
+ ascending: true,
13391
13408
  range: [1, 7]
13392
13409
  },
13393
13410
  [UTR]: {
@@ -13395,6 +13412,7 @@ const ratingsParameters = {
13395
13412
  accessors: ["utrRating"],
13396
13413
  accessor: "utrRating",
13397
13414
  decimalsCount: 2,
13415
+ ascending: true,
13398
13416
  range: [1, 16]
13399
13417
  },
13400
13418
  [WTN]: {
@@ -13402,6 +13420,7 @@ const ratingsParameters = {
13402
13420
  accessors: ["wtnRating", "confidence"],
13403
13421
  defaultInitialization: 23,
13404
13422
  accessor: "wtnRating",
13423
+ ascending: false,
13405
13424
  decimalsCount: 2,
13406
13425
  range: [40, 1]
13407
13426
  }
@@ -26373,8 +26392,8 @@ function modifyMatchUpFormatTiming$1({
26373
26392
  recoveryTimes
26374
26393
  });
26375
26394
  addTournamentExtension({
26376
- tournamentRecord,
26377
- extension: { name, value }
26395
+ extension: { name, value },
26396
+ tournamentRecord
26378
26397
  });
26379
26398
  }
26380
26399
  return { ...SUCCESS };
@@ -32229,8 +32248,8 @@ function checkSchedulingProfile$1({ tournamentRecords }) {
32229
32248
  }
32230
32249
 
32231
32250
  function scheduledSortedMatchUps({
32232
- matchUps = [],
32233
- schedulingProfile
32251
+ schedulingProfile,
32252
+ matchUps = []
32234
32253
  }) {
32235
32254
  const profileHash = {};
32236
32255
  const getHash = ({ eventId, drawId, structureId, roundNumber }) => {
@@ -46724,6 +46743,10 @@ function removeDelegatedOutcome$1({ drawDefinition, event, matchUpId }) {
46724
46743
  });
46725
46744
  }
46726
46745
 
46746
+ function stringSort(a, b) {
46747
+ return (a || "").localeCompare(b || "");
46748
+ }
46749
+
46727
46750
  function generateCandidate({
46728
46751
  maxIterations = 4e3,
46729
46752
  // cap the processing intensity of the candidate generator
@@ -46858,7 +46881,7 @@ function roundCandidate({
46858
46881
  return { value: candidateValue, participantIdPairings, maxDelta, maxDiff };
46859
46882
  }
46860
46883
  function pairingHash(id1, id2) {
46861
- return [id1, id2].sort().join("|");
46884
+ return [id1, id2].sort(stringSort).join("|");
46862
46885
  }
46863
46886
 
46864
46887
  function getPairingsData({ participantIds }) {
@@ -47458,7 +47481,10 @@ const matchUpGovernor = {
47458
47481
  validateScore
47459
47482
  };
47460
47483
 
47461
- function attachPolicies({ drawDefinition, policyDefinitions }) {
47484
+ function attachPolicies({
47485
+ drawDefinition,
47486
+ policyDefinitions
47487
+ }) {
47462
47488
  if (!drawDefinition) {
47463
47489
  return { error: MISSING_DRAW_DEFINITION };
47464
47490
  }
@@ -47468,8 +47494,9 @@ function attachPolicies({ drawDefinition, policyDefinitions }) {
47468
47494
  if (!drawDefinition.extensions)
47469
47495
  drawDefinition.extensions = [];
47470
47496
  const appliedPolicies = getAppliedPolicies({ drawDefinition })?.appliedPolicies ?? {};
47497
+ const validReplacements = [POLICY_TYPE_ROUND_NAMING, POLICY_TYPE_DISPLAY];
47471
47498
  const applied = Object.keys(policyDefinitions).every((policyType) => {
47472
- if (!appliedPolicies[policyType]) {
47499
+ if (!appliedPolicies[policyType] || validReplacements.includes(policyType)) {
47473
47500
  appliedPolicies[policyType] = policyDefinitions[policyType];
47474
47501
  return true;
47475
47502
  } else {
@@ -52897,6 +52924,20 @@ function setTournamentStatus({ tournamentRecord, status }) {
52897
52924
  return { ...SUCCESS };
52898
52925
  }
52899
52926
 
52927
+ function addOnlineResource({
52928
+ tournamentRecord,
52929
+ onlineResource
52930
+ }) {
52931
+ if (!tournamentRecord)
52932
+ return { error: MISSING_TOURNAMENT_RECORD };
52933
+ if (!onlineResource)
52934
+ return { error: MISSING_VALUE };
52935
+ if (!tournamentRecord.onlineResources)
52936
+ tournamentRecord.onlineResources = [];
52937
+ tournamentRecord.onlineResources.push(onlineResource);
52938
+ return { ...SUCCESS };
52939
+ }
52940
+
52900
52941
  function analyzeDraws({ tournamentRecord }) {
52901
52942
  if (!tournamentRecord)
52902
52943
  return { error: MISSING_TOURNAMENT_RECORD };
@@ -53175,10 +53216,11 @@ function removeInvalidScheduling({ tournamentRecord }) {
53175
53216
  }
53176
53217
 
53177
53218
  const tournamentGovernor = {
53178
- addNotes,
53179
- removeNotes,
53180
- analyzeDraws,
53181
53219
  analyzeTournament,
53220
+ analyzeDraws,
53221
+ addOnlineResource,
53222
+ removeNotes,
53223
+ addNotes,
53182
53224
  completeDrawMatchUps,
53183
53225
  getRounds,
53184
53226
  getProfileRounds,
@@ -56396,13 +56438,6 @@ function deleteFlightAndFlightDraw({
56396
56438
  return refreshEventDrawOrder({ tournamentRecord, event });
56397
56439
  }
56398
56440
 
56399
- function generateAdHocMatchUps(params) {
56400
- return generateAdHocMatchUps$1(params);
56401
- }
56402
- function addAdHocMatchUps(params) {
56403
- return addAdHocMatchUps$1(params);
56404
- }
56405
-
56406
56441
  function attachFlightProfile({ deleteExisting, event, flightProfile }) {
56407
56442
  const stack = "attachFlightProfile";
56408
56443
  if (!flightProfile)
@@ -56608,6 +56643,98 @@ function deleteAdHocMatchUps(params) {
56608
56643
  return deleteAdHocMatchUps$1(params);
56609
56644
  }
56610
56645
 
56646
+ function modifyDrawName({
56647
+ tournamentRecord,
56648
+ drawDefinition,
56649
+ flightProfile,
56650
+ drawName,
56651
+ drawId,
56652
+ event
56653
+ }) {
56654
+ if (!drawName || typeof drawName !== "string")
56655
+ return decorateResult({
56656
+ result: { error: INVALID_VALUES },
56657
+ context: { drawName }
56658
+ });
56659
+ if (!flightProfile) {
56660
+ flightProfile = getFlightProfile({ event }).flightProfile;
56661
+ }
56662
+ const flight = flightProfile?.flights?.find(
56663
+ (flight2) => flight2.drawId === drawId
56664
+ );
56665
+ if (flight) {
56666
+ flight.drawName = drawName;
56667
+ const extension = {
56668
+ name: FLIGHT_PROFILE,
56669
+ value: {
56670
+ ...flightProfile,
56671
+ flights: flightProfile.flights
56672
+ }
56673
+ };
56674
+ addEventExtension$1({ event, extension });
56675
+ }
56676
+ if (drawDefinition) {
56677
+ drawDefinition.drawName = drawName;
56678
+ modifyDrawNotice({
56679
+ tournamentId: tournamentRecord?.tournamentId,
56680
+ drawDefinition
56681
+ });
56682
+ }
56683
+ if (!flight && !drawDefinition) {
56684
+ return { error: MISSING_DRAW_DEFINITION };
56685
+ }
56686
+ return { ...SUCCESS, flight };
56687
+ }
56688
+
56689
+ function modifyDrawDefinition({
56690
+ tournamentRecord,
56691
+ drawDefinition,
56692
+ drawUpdates,
56693
+ drawId,
56694
+ event
56695
+ }) {
56696
+ if (!isObject(drawUpdates))
56697
+ return { error: INVALID_END_TIME };
56698
+ const flightProfile = getFlightProfile({ event }).flightProfile;
56699
+ const nameResult = drawUpdates.drawName && modifyDrawName({
56700
+ drawName: drawUpdates.drawName,
56701
+ tournamentRecord,
56702
+ drawDefinition,
56703
+ flightProfile,
56704
+ drawId,
56705
+ event
56706
+ });
56707
+ if (nameResult?.error)
56708
+ return nameResult?.error;
56709
+ const flight = nameResult?.flight || flightProfile?.flights?.find((flight2) => flight2.drawId === drawId);
56710
+ if (!flight && !drawDefinition) {
56711
+ return { error: MISSING_DRAW_DEFINITION };
56712
+ }
56713
+ if (flight) {
56714
+ const extension = {
56715
+ name: FLIGHT_PROFILE,
56716
+ value: {
56717
+ ...flightProfile,
56718
+ flights: flightProfile.flights
56719
+ }
56720
+ };
56721
+ addEventExtension$1({ event, extension });
56722
+ }
56723
+ if (drawDefinition) {
56724
+ if (drawUpdates.policyDefinitions) {
56725
+ attachPolicies({
56726
+ policyDefinitions: drawUpdates.policyDefinitions,
56727
+ drawDefinition
56728
+ });
56729
+ }
56730
+ modifyDrawNotice({
56731
+ tournamentId: tournamentRecord?.tournamentId,
56732
+ drawDefinition
56733
+ });
56734
+ }
56735
+ return { ...SUCCESS };
56736
+ }
56737
+
56611
56738
  function resetDrawDefinition({
56612
56739
  tournamentRecord,
56613
56740
  removeScheduling,
@@ -56768,34 +56895,6 @@ function setOrderOfFinish(params) {
56768
56895
  return setOrderOfFinish$1(params);
56769
56896
  }
56770
56897
 
56771
- function modifyDrawName({ event, drawId, drawDefinition, drawName }) {
56772
- if (!drawName || typeof drawName !== "string")
56773
- return { error: INVALID_VALUES, drawName };
56774
- const { flightProfile } = getFlightProfile({ event });
56775
- const flight = flightProfile?.flights?.find(
56776
- (flight2) => flight2.drawId === drawId
56777
- );
56778
- if (flight) {
56779
- flight.drawName = drawName;
56780
- const extension = {
56781
- name: FLIGHT_PROFILE,
56782
- value: {
56783
- ...flightProfile,
56784
- flights: flightProfile.flights
56785
- }
56786
- };
56787
- addEventExtension$1({ event, extension });
56788
- }
56789
- if (drawDefinition) {
56790
- drawDefinition.drawName = drawName;
56791
- modifyDrawNotice({ drawDefinition });
56792
- }
56793
- if (!flight && !drawDefinition) {
56794
- return { error: MISSING_DRAW_DEFINITION };
56795
- }
56796
- return { ...SUCCESS };
56797
- }
56798
-
56799
56898
  function modifyEventEntries({
56800
56899
  entryStatus = DIRECT_ACCEPTANCE,
56801
56900
  unpairedParticipantIds = [],
@@ -56931,6 +57030,13 @@ function addFlight({
56931
57030
  return addEventExtension$1({ event, extension });
56932
57031
  }
56933
57032
 
57033
+ function generateAdHocMatchUps(params) {
57034
+ return generateAdHocMatchUps$1(params);
57035
+ }
57036
+ function addAdHocMatchUps(params) {
57037
+ return addAdHocMatchUps$1(params);
57038
+ }
57039
+
56934
57040
  function attachConsolationStructures(params) {
56935
57041
  return attachStructures({
56936
57042
  ...params,
@@ -58092,6 +58198,61 @@ function enableTieAutoCalc(params) {
58092
58198
  return enableTieAutoCalc$1(params);
58093
58199
  }
58094
58200
 
58201
+ function modifyEvent({
58202
+ tournamentRecord,
58203
+ eventUpdates,
58204
+ eventId,
58205
+ event
58206
+ }) {
58207
+ if (!tournamentRecord)
58208
+ return { error: MISSING_TOURNAMENT_RECORD };
58209
+ if (!isString(eventId) || !isObject(eventUpdates))
58210
+ return { error: INVALID_VALUES };
58211
+ const enteredParticipantIds = event?.entries?.filter(({ entryStatus }) => {
58212
+ const status = entryStatus;
58213
+ return [...STRUCTURE_SELECTED_STATUSES, ALTERNATE].includes(status);
58214
+ }).map(({ participantId }) => participantId) || [];
58215
+ const enteredParticipants = enteredParticipantIds ? getParticipants$1({
58216
+ participantFilters: { participantIds: enteredParticipantIds },
58217
+ withIndividualParticipants: true,
58218
+ tournamentRecord
58219
+ }).participants || [] : [];
58220
+ const genderAccumulator = [];
58221
+ const enteredParticipantTypes = enteredParticipants.reduce(
58222
+ (types, participant) => {
58223
+ const genders = participant.person?.sex ? [participant.person.sex] : participant.individualParticpants?.map((p) => p.person?.sex) || [];
58224
+ genderAccumulator.push(...genders);
58225
+ return !types.includes(participant.participantType) ? types.concat(participant.participantType) : types;
58226
+ },
58227
+ []
58228
+ );
58229
+ const enteredParticipantGenders = unique(genderAccumulator);
58230
+ const validGender = !enteredParticipantGenders.length || [MIXED, ANY].includes(eventUpdates.gender || "") || enteredParticipantGenders.length === 1 && enteredParticipantGenders[0] === eventUpdates.gender;
58231
+ if (eventUpdates.gender && !validGender)
58232
+ return decorateResult({
58233
+ context: { gender: eventUpdates.gender },
58234
+ result: { error: INVALID_VALUES }
58235
+ });
58236
+ const validEventTypes = enteredParticipantTypes.includes(TEAM$1) && [TEAM$1] || enteredParticipantTypes.includes(INDIVIDUAL) && [SINGLES] || enteredParticipantTypes.includes(PAIR) && [DOUBLES] || [
58237
+ DOUBLES,
58238
+ SINGLES,
58239
+ TEAM$1
58240
+ ];
58241
+ const validEventType = validEventTypes.includes(eventUpdates.eventType || "");
58242
+ if (eventUpdates.eventType && !validEventType)
58243
+ return decorateResult({
58244
+ context: { participantType: eventUpdates.eventType },
58245
+ result: { error: INVALID_VALUES }
58246
+ });
58247
+ if (eventUpdates.eventType)
58248
+ event.eventType === eventUpdates.eventType;
58249
+ if (eventUpdates.eventName)
58250
+ event.eventName = eventUpdates.eventName;
58251
+ if (eventUpdates.gender)
58252
+ event.gender = eventUpdates.gender;
58253
+ return { ...SUCCESS };
58254
+ }
58255
+
58095
58256
  const eventGovernor = {
58096
58257
  generateQualifyingStructure,
58097
58258
  attachQualifyingStructure,
@@ -58112,11 +58273,12 @@ const eventGovernor = {
58112
58273
  modifyTieFormat: modifyTieFormat$1,
58113
58274
  resetScorecard,
58114
58275
  resetTieFormat: resetTieFormat$1,
58115
- addEvent,
58116
- deleteEvents,
58117
- setEventDates,
58118
58276
  setEventStartDate,
58119
58277
  setEventEndDate,
58278
+ setEventDates,
58279
+ deleteEvents,
58280
+ modifyEvent,
58281
+ addEvent,
58120
58282
  removeSeededParticipant,
58121
58283
  removeScaleValues,
58122
58284
  checkValidEntries,
@@ -58128,6 +58290,7 @@ const eventGovernor = {
58128
58290
  getAvailablePlayoffProfiles,
58129
58291
  deleteDrawDefinitions,
58130
58292
  addPlayoffStructures,
58293
+ modifyDrawDefinition,
58131
58294
  addDrawDefinition: addDrawDefinition$1,
58132
58295
  removeStructure,
58133
58296
  modifyDrawName,
@@ -58227,16 +58390,14 @@ function getPredictiveAccuracy(params) {
58227
58390
  let { matchUps } = params;
58228
58391
  const {
58229
58392
  tournamentRecord,
58230
- ascending = true,
58231
58393
  drawDefinition,
58232
58394
  excludeMargin,
58233
58395
  exclusionRule,
58234
- valueAccessor,
58235
58396
  zoneDoubling,
58236
58397
  matchUpType,
58237
- zoneMargin,
58238
58398
  scaleName,
58239
58399
  eventId,
58400
+ zonePct,
58240
58401
  drawId,
58241
58402
  event
58242
58403
  } = params;
@@ -58246,6 +58407,11 @@ function getPredictiveAccuracy(params) {
58246
58407
  return { error: INVALID_VALUES, info: { matchUpType } };
58247
58408
  if (matchUps && !validMatchUps(matchUps))
58248
58409
  return { error: INVALID_VALUES, context: { matchUps } };
58410
+ const scaleProfile = ratingsParameters[scaleName];
58411
+ const ascending = scaleProfile?.ascending ?? params.ascending ?? false;
58412
+ const valueAccessor = scaleProfile?.accessor ?? params.valueAccessor;
58413
+ const ratingsRangeDifference = Array.isArray(scaleProfile?.range) ? Math.abs(scaleProfile.range[0] - scaleProfile.range[1]) : 0;
58414
+ const zoneMargin = isConvertableInteger(zonePct) && ratingsRangeDifference ? (zonePct || 0 / 100) * ratingsRangeDifference : params.zoneMargin || ratingsRangeDifference;
58249
58415
  const contextProfile = { withScaleValues: true, withCompetitiveness: true };
58250
58416
  const contextFilters = {
58251
58417
  matchUpTypes: matchUpType ? [matchUpType] : [SINGLES$1, DOUBLES$1]
@@ -58283,7 +58449,7 @@ function getPredictiveAccuracy(params) {
58283
58449
  }
58284
58450
  const relevantMatchUps = matchUps.filter(
58285
58451
  ({ winningSide, score, sides, matchUpStatus }) => ![RETIRED$1, DEFAULTED, WALKOVER$2, DEAD_RUBBER, ABANDONED$1].includes(
58286
- matchUpStatus
58452
+ matchUpStatus || ""
58287
58453
  ) && scoreHasValue({ score }) && sides?.length === 2 && winningSide
58288
58454
  );
58289
58455
  const accuracy = getGroupingAccuracy({
@@ -58294,8 +58460,8 @@ function getPredictiveAccuracy(params) {
58294
58460
  ascending,
58295
58461
  scaleName
58296
58462
  });
58297
- const marginCalc = !zoneDoubling || matchUpType === SINGLES$1 ? zoneMargin : zoneMargin * 2;
58298
- const zoneData = zoneMargin && relevantMatchUps.map(({ competitiveness, matchUpType: matchUpType2, score, sides }) => {
58463
+ const marginCalc = !zoneDoubling || matchUpType === SINGLES$1 ? zoneMargin : (zoneMargin || 0) * 2;
58464
+ const zoneData = zoneMargin ? relevantMatchUps.map(({ competitiveProfile, matchUpType: matchUpType2, score, sides }) => {
58299
58465
  const sideValues = getSideValues({
58300
58466
  valueAccessor,
58301
58467
  matchUpType: matchUpType2,
@@ -58303,11 +58469,15 @@ function getPredictiveAccuracy(params) {
58303
58469
  sides
58304
58470
  });
58305
58471
  const valuesGap = Math.abs(sideValues[0].value - sideValues[1].value);
58306
- return { competitiveness, score, valuesGap };
58472
+ return {
58473
+ competitiveness: competitiveProfile?.competitiveness,
58474
+ valuesGap,
58475
+ score
58476
+ };
58307
58477
  }).filter(({ valuesGap }) => {
58308
58478
  return valuesGap <= marginCalc;
58309
- });
58310
- const zoneBands = zoneData?.length && getGroupingBands({ zoneData });
58479
+ }) : [];
58480
+ const zoneBands = getGroupingBands({ zoneData });
58311
58481
  const totalZoneMatchUps = zoneBands && [].concat(Object.values(zoneBands)).flat().length;
58312
58482
  const zoneDistribution = totalZoneMatchUps && Object.assign(
58313
58483
  {},
@@ -58458,7 +58628,7 @@ function getGroupingAccuracy({
58458
58628
  continue;
58459
58629
  }
58460
58630
  const valuesGap = sideValues[winningIndex].value - sideValues[1 - winningIndex].value;
58461
- const floatMargin = parseFloat(excludeMargin);
58631
+ const floatMargin = parseFloat(excludeMargin || 0);
58462
58632
  const excludeGap = floatMargin && Math.abs(valuesGap) < floatMargin;
58463
58633
  if (excludeGap) {
58464
58634
  accuracy.excluded.push({
@@ -58471,7 +58641,7 @@ function getGroupingAccuracy({
58471
58641
  });
58472
58642
  continue;
58473
58643
  }
58474
- const signedGap = ascending ? valuesGap * -1 : valuesGap;
58644
+ const signedGap = ascending ? valuesGap : valuesGap * -1;
58475
58645
  const winningScoreString = winningSide === 1 ? score?.scoreStringSide1 : score?.scoreStringSide2;
58476
58646
  if (signedGap > 0) {
58477
58647
  accuracy.affirmative.push({
@@ -58545,18 +58715,14 @@ function getMatchUpFormat({
58545
58715
  };
58546
58716
  }
58547
58717
 
58548
- function getMatchUpsStats({
58549
- competitiveProfile,
58550
- tournamentRecord,
58551
- matchUps
58552
- }) {
58718
+ function getMatchUpsStats({ profileBands, tournamentRecord, matchUps }) {
58553
58719
  if (!validMatchUps(matchUps))
58554
58720
  return { error: MISSING_MATCHUPS };
58555
- const policy = !competitiveProfile && findPolicy({
58721
+ const policy = !profileBands && findPolicy({
58556
58722
  policyType: POLICY_TYPE_COMPETITIVE_BANDS,
58557
58723
  tournamentRecord
58558
58724
  }).policy;
58559
- const bandProfiles = competitiveProfile || policy?.competitiveProfile || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].competitiveProfile;
58725
+ const bandProfiles = profileBands || policy?.profileBands || POLICY_COMPETITIVE_BANDS_DEFAULT[POLICY_TYPE_COMPETITIVE_BANDS].profileBands;
58560
58726
  const relevantMatchUps = matchUps.filter(({ winningSide }) => winningSide);
58561
58727
  const gamesMap = relevantMatchUps.map(getScoreComponents);
58562
58728
  const categorize = (p, spread) => {
@@ -58745,7 +58911,7 @@ const queryGovernor = {
58745
58911
  getPositionAssignments,
58746
58912
  isValidMatchUpFormat: isValid,
58747
58913
  getMaxEntryPosition,
58748
- getMatchUpCompetitiveness,
58914
+ getMatchUpCompetitiveProfile,
58749
58915
  findVenue,
58750
58916
  getCourts,
58751
58917
  getVenuesAndCourts: getVenuesAndCourts$1,