tods-competition-factory 2.2.49 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +8 -8
- package/dist/tods-competition-factory.d.ts +50 -13
- package/dist/tods-competition-factory.development.cjs.js +212 -200
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +10 -7
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.
|
|
6
|
+
return '2.3.1';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const SINGLES_MATCHUP = 'SINGLES';
|
|
@@ -2289,7 +2289,8 @@ function validTimeValue(value) {
|
|
|
2289
2289
|
const spaceSplit = typeof value === 'string' ? value?.split(' ') : [];
|
|
2290
2290
|
if (value && spaceSplit?.length > 1 && !['AM', 'PM'].includes(spaceSplit[1].toUpperCase()))
|
|
2291
2291
|
return false;
|
|
2292
|
-
|
|
2292
|
+
const converted = convertTime(value, true, true);
|
|
2293
|
+
return !!(!value || (converted && timeValidation.test(converted)));
|
|
2293
2294
|
}
|
|
2294
2295
|
function isValidDateString(scheduleDate) {
|
|
2295
2296
|
return isISODateString(scheduleDate) || validDateString.test(scheduleDate);
|
|
@@ -2300,7 +2301,7 @@ function DateHHMM(date) {
|
|
|
2300
2301
|
return HHMMSS(secs, { displaySeconds: false });
|
|
2301
2302
|
}
|
|
2302
2303
|
function HHMMSS(s, format) {
|
|
2303
|
-
const secondNumber = parseInt(s, 10);
|
|
2304
|
+
const secondNumber = Number.parseInt(s, 10);
|
|
2304
2305
|
const hours = Math.floor(secondNumber / 3600);
|
|
2305
2306
|
const minutes = Math.floor((secondNumber - hours * 3600) / 60);
|
|
2306
2307
|
const seconds = secondNumber - hours * 3600 - minutes * 60;
|
|
@@ -2321,7 +2322,7 @@ function timeUTC(date) {
|
|
|
2321
2322
|
function formatDate(date, separator = '-', format = 'YMD') {
|
|
2322
2323
|
if (!date)
|
|
2323
2324
|
return '';
|
|
2324
|
-
if (typeof date === 'string' && date.
|
|
2325
|
+
if (typeof date === 'string' && !date.includes('T'))
|
|
2325
2326
|
date = date + 'T00:00';
|
|
2326
2327
|
const d = new Date(date);
|
|
2327
2328
|
let month = '' + (d.getMonth() + 1);
|
|
@@ -2354,8 +2355,11 @@ function offsetTime(date) {
|
|
|
2354
2355
|
function isDate(dateArg) {
|
|
2355
2356
|
if (typeof dateArg == 'boolean')
|
|
2356
2357
|
return false;
|
|
2357
|
-
const t = (dateArg instanceof Date && dateArg) || (!isNaN(dateArg) && new Date(dateArg)) || false;
|
|
2358
|
-
return t && !isNaN(t.valueOf());
|
|
2358
|
+
const t = (dateArg instanceof Date && dateArg) || (!Number.isNaN(Number(dateArg)) && new Date(dateArg)) || false;
|
|
2359
|
+
return t && !Number.isNaN(Number(t.valueOf()));
|
|
2360
|
+
}
|
|
2361
|
+
function isValidDateRange(minDate, maxDate) {
|
|
2362
|
+
return minDate <= maxDate;
|
|
2359
2363
|
}
|
|
2360
2364
|
function generateDateRange(startDt, endDt) {
|
|
2361
2365
|
if (!isValidDateString(startDt) || !isValidDateString(endDt))
|
|
@@ -2377,9 +2381,6 @@ function generateDateRange(startDt, endDt) {
|
|
|
2377
2381
|
}
|
|
2378
2382
|
}
|
|
2379
2383
|
return between.map((date) => formatDate(date));
|
|
2380
|
-
function isValidDateRange(minDate, maxDate) {
|
|
2381
|
-
return minDate <= maxDate;
|
|
2382
|
-
}
|
|
2383
2384
|
}
|
|
2384
2385
|
const re = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
|
|
2385
2386
|
function isISODateString(dateString) {
|
|
@@ -2392,15 +2393,15 @@ function isTimeString(timeString) {
|
|
|
2392
2393
|
return false;
|
|
2393
2394
|
const noZ = timeString.split('Z')[0];
|
|
2394
2395
|
const parts = noZ.split(':');
|
|
2395
|
-
const isNumeric = parts.every((part) => !isNaN(parseInt(part)));
|
|
2396
|
-
const invalid = parts.length < 2 || !isNumeric || parseInt(parts[0]) > 23 || parseInt(parts[1]) > 60;
|
|
2396
|
+
const isNumeric = parts.every((part) => !Number.isNaN(Number.parseInt(part)));
|
|
2397
|
+
const invalid = parts.length < 2 || !isNumeric || Number.parseInt(parts[0]) > 23 || Number.parseInt(parts[1]) > 60;
|
|
2397
2398
|
return !invalid;
|
|
2398
2399
|
}
|
|
2399
2400
|
function timeStringMinutes$1(timeString) {
|
|
2400
2401
|
const validTimeString = extractTime$1(timeString);
|
|
2401
2402
|
if (!validTimeString)
|
|
2402
2403
|
return 0;
|
|
2403
|
-
const [hours, minutes] = validTimeString.split(':').map((value) => parseInt(value));
|
|
2404
|
+
const [hours, minutes] = validTimeString.split(':').map((value) => Number.parseInt(value));
|
|
2404
2405
|
return hours * 60 + minutes;
|
|
2405
2406
|
}
|
|
2406
2407
|
function dayMinutesToTimeString(totalMinutes) {
|
|
@@ -2419,7 +2420,7 @@ function extractTime$1(dateString) {
|
|
|
2419
2420
|
: tidyTime(dateString);
|
|
2420
2421
|
}
|
|
2421
2422
|
function extractDate(dateString) {
|
|
2422
|
-
return isISODateString(dateString) || dateValidation.test(dateString) ? dateString.split('T')[0] :
|
|
2423
|
+
return isISODateString(dateString) || dateValidation.test(dateString) ? dateString.split('T')[0] : '';
|
|
2423
2424
|
}
|
|
2424
2425
|
function dateStringDaysChange(dateString, daysChange) {
|
|
2425
2426
|
const date = new Date(dateString);
|
|
@@ -2427,20 +2428,22 @@ function dateStringDaysChange(dateString, daysChange) {
|
|
|
2427
2428
|
return extractDate(date.toISOString());
|
|
2428
2429
|
}
|
|
2429
2430
|
function splitTime(value) {
|
|
2430
|
-
value = typeof value
|
|
2431
|
+
value = typeof value === 'string' ? value : '00:00';
|
|
2431
2432
|
const o = {}, time = {};
|
|
2432
2433
|
({ 0: o.time, 1: o.ampm } = value.split(' ') || []);
|
|
2433
2434
|
({ 0: time.hours, 1: time.minutes } = o.time.split(':') || []);
|
|
2434
2435
|
time.ampm = o.ampm;
|
|
2435
|
-
if (isNaN(
|
|
2436
|
+
if (Number.isNaN(Number.parseInt(time.hours)) ||
|
|
2437
|
+
Number.isNaN(Number.parseInt(time.minutes)) ||
|
|
2438
|
+
(time.ampm && !['AM', 'PM'].includes(time.ampm.toUpperCase())))
|
|
2436
2439
|
return {};
|
|
2437
2440
|
return time;
|
|
2438
2441
|
}
|
|
2439
2442
|
function militaryTime(value) {
|
|
2440
2443
|
const time = splitTime(value);
|
|
2441
2444
|
if (time.ampm && time.hours) {
|
|
2442
|
-
if (time.ampm.toLowerCase() === 'pm' && parseInt(time.hours) < 12)
|
|
2443
|
-
time.hours = ((time.hours && parseInt(time.hours)) || 0) + 12;
|
|
2445
|
+
if (time.ampm.toLowerCase() === 'pm' && Number.parseInt(time.hours) < 12)
|
|
2446
|
+
time.hours = ((time.hours && Number.parseInt(time.hours)) || 0) + 12;
|
|
2444
2447
|
if (time.ampm.toLowerCase() === 'am' && time.hours === '12')
|
|
2445
2448
|
time.hours = '00';
|
|
2446
2449
|
}
|
|
@@ -2476,21 +2479,21 @@ function convertTime(value, time24, keepDate) {
|
|
|
2476
2479
|
const hasDate = extractDate(value);
|
|
2477
2480
|
const timeString = extractTime$1(value);
|
|
2478
2481
|
const timeValue = hasDate ? timeString : value;
|
|
2479
|
-
return
|
|
2480
|
-
?
|
|
2481
|
-
:
|
|
2482
|
+
return value
|
|
2483
|
+
? (time24 && ((hasDate && keepDate && value) || militaryTime(timeValue))) || regularTime(timeValue)
|
|
2484
|
+
: undefined;
|
|
2482
2485
|
}
|
|
2483
2486
|
function timeSort(a, b) {
|
|
2484
2487
|
const as = splitTime(a);
|
|
2485
2488
|
const bs = splitTime(b);
|
|
2486
|
-
if (parseInt(as.hours) < parseInt(bs.hours))
|
|
2489
|
+
if (Number.parseInt(as.hours) < Number.parseInt(bs.hours))
|
|
2487
2490
|
return -1;
|
|
2488
|
-
if (parseInt(as.hours) > parseInt(bs.hours))
|
|
2491
|
+
if (Number.parseInt(as.hours) > Number.parseInt(bs.hours))
|
|
2489
2492
|
return 1;
|
|
2490
2493
|
if (as.hours === bs.hours) {
|
|
2491
|
-
if (parseInt(as.minutes) < parseInt(bs.minutes))
|
|
2494
|
+
if (Number.parseInt(as.minutes) < Number.parseInt(bs.minutes))
|
|
2492
2495
|
return -1;
|
|
2493
|
-
if (parseInt(as.minutes) > parseInt(bs.minutes))
|
|
2496
|
+
if (Number.parseInt(as.minutes) > Number.parseInt(bs.minutes))
|
|
2494
2497
|
return 1;
|
|
2495
2498
|
}
|
|
2496
2499
|
return 0;
|
|
@@ -2529,8 +2532,8 @@ function addMinutesToTimeString(timeString, minutes) {
|
|
|
2529
2532
|
const validTimeString = extractTime$1(timeString);
|
|
2530
2533
|
if (!validTimeString)
|
|
2531
2534
|
return '00:00';
|
|
2532
|
-
const minutesToAdd = isNaN(minutes) ? 0 : minutes;
|
|
2533
|
-
return extractTime$1(addMinutes(timeToDate(validTimeString), minutesToAdd).toISOString());
|
|
2535
|
+
const minutesToAdd = Number.isNaN(minutes) ? 0 : minutes;
|
|
2536
|
+
return extractTime$1(addMinutes(timeToDate(validTimeString), minutesToAdd).toISOString()) || '00:00';
|
|
2534
2537
|
}
|
|
2535
2538
|
function addMinutes(startDate, minutes) {
|
|
2536
2539
|
const date = new Date(startDate);
|
|
@@ -2586,23 +2589,27 @@ function getCategoryAgeDetails(params) {
|
|
|
2586
2589
|
if (!isValidCategory)
|
|
2587
2590
|
return { error: INVALID_CATEGORY };
|
|
2588
2591
|
const consideredDate = params.consideredDate ?? extractDate(new Date().toLocaleDateString('sv'));
|
|
2589
|
-
if (!isValidDateString(consideredDate))
|
|
2592
|
+
if (!consideredDate || !isValidDateString(consideredDate))
|
|
2590
2593
|
return { error: INVALID_DATE };
|
|
2591
2594
|
const [consideredYear] = consideredDate
|
|
2592
2595
|
.split('-')
|
|
2593
2596
|
.slice(0, 3)
|
|
2594
|
-
.map((n) => parseInt(n));
|
|
2597
|
+
.map((n) => Number.parseInt(n));
|
|
2595
2598
|
const previousDayDate = dateStringDaysChange(consideredDate, -1);
|
|
2599
|
+
if (!previousDayDate)
|
|
2600
|
+
return { error: INVALID_DATE };
|
|
2596
2601
|
const [previousDayMonth, previousDay] = previousDayDate
|
|
2597
2602
|
.split('-')
|
|
2598
2603
|
.slice(1, 3)
|
|
2599
|
-
.map((n) => parseInt(n));
|
|
2604
|
+
.map((n) => Number.parseInt(n));
|
|
2600
2605
|
const previousMonthDay = `${zeroPad(previousDayMonth)}-${zeroPad(previousDay)}`;
|
|
2601
2606
|
const nextDayDate = dateStringDaysChange(consideredDate, 1);
|
|
2607
|
+
if (!nextDayDate)
|
|
2608
|
+
return { error: INVALID_DATE };
|
|
2602
2609
|
const [nextDayMonth, nextDay] = nextDayDate
|
|
2603
2610
|
.split('-')
|
|
2604
2611
|
.slice(1, 3)
|
|
2605
|
-
.map((n) => parseInt(n));
|
|
2612
|
+
.map((n) => Number.parseInt(n));
|
|
2606
2613
|
const nextMonthDay = `${zeroPad(nextDayMonth)}-${zeroPad(nextDay)}`;
|
|
2607
2614
|
let calculatedAgeMaxDate = ageMin && dateStringDaysChange(consideredDate, -1 * 365 * ageMin);
|
|
2608
2615
|
let calculatedAgeMinDate = ageMax && dateStringDaysChange(consideredDate, -1 * 365 * ageMax);
|
|
@@ -2679,7 +2686,7 @@ function getCategoryAgeDetails(params) {
|
|
|
2679
2686
|
};
|
|
2680
2687
|
const processCode = (code) => {
|
|
2681
2688
|
const [pre, age, post] = (code.match(prePost) || []).slice(1);
|
|
2682
|
-
const ageInt = parseInt(age);
|
|
2689
|
+
const ageInt = Number.parseInt(age);
|
|
2683
2690
|
if (pre === 'U') {
|
|
2684
2691
|
if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
|
|
2685
2692
|
addError(`Invalid submitted ageMaxDate: ${category.ageMaxDate}`);
|
|
@@ -2698,8 +2705,8 @@ function getCategoryAgeDetails(params) {
|
|
|
2698
2705
|
else if (post === 'O') {
|
|
2699
2706
|
oPost(ageInt);
|
|
2700
2707
|
}
|
|
2701
|
-
ageMaxDate = ageMaxDate ?? calculatedAgeMaxDate;
|
|
2702
|
-
ageMinDate = ageMinDate ?? calculatedAgeMinDate;
|
|
2708
|
+
ageMaxDate = (ageMaxDate ?? calculatedAgeMaxDate) || undefined;
|
|
2709
|
+
ageMinDate = (ageMinDate ?? calculatedAgeMinDate) || undefined;
|
|
2703
2710
|
};
|
|
2704
2711
|
if (isCombined) {
|
|
2705
2712
|
ageMaxDate = undefined;
|
|
@@ -2714,7 +2721,7 @@ function getCategoryAgeDetails(params) {
|
|
|
2714
2721
|
const ageMinYear = consideredYear - category.ageMax - 1;
|
|
2715
2722
|
ageMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
2716
2723
|
}
|
|
2717
|
-
const [lowAge, highAge] = (ageCategoryCode?.match(extractCombined) ?? []).slice(1).map((n) => parseInt(n));
|
|
2724
|
+
const [lowAge, highAge] = (ageCategoryCode?.match(extractCombined) ?? []).slice(1).map((n) => Number.parseInt(n));
|
|
2718
2725
|
if (lowAge <= highAge) {
|
|
2719
2726
|
ageMin = lowAge;
|
|
2720
2727
|
ageMax = highAge;
|
|
@@ -4347,6 +4354,7 @@ const aggregateOrder = {
|
|
|
4347
4354
|
[VOLUNTARY_CONSOLATION]: 5,
|
|
4348
4355
|
};
|
|
4349
4356
|
const CLUSTER = 'CLUSTER';
|
|
4357
|
+
const ADJACENT = 'ADJACENT';
|
|
4350
4358
|
const SEPARATE = 'SEPARATE';
|
|
4351
4359
|
const WATERFALL = 'WATERFALL';
|
|
4352
4360
|
const ITEM = 'ITEM';
|
|
@@ -4484,6 +4492,9 @@ const drawDefinitionConstants = {
|
|
|
4484
4492
|
RANDOM,
|
|
4485
4493
|
TOP_DOWN,
|
|
4486
4494
|
BOTTOM_UP,
|
|
4495
|
+
CLUSTER,
|
|
4496
|
+
ADJACENT,
|
|
4497
|
+
SEPARATE,
|
|
4487
4498
|
WATERFALL,
|
|
4488
4499
|
WIN_RATIO: WIN_RATIO$1,
|
|
4489
4500
|
ROUND_OUTCOME,
|
|
@@ -8671,7 +8682,7 @@ function getRoundMatchUps({ matchUps = [], interpolate }) {
|
|
|
8671
8682
|
if (interpolate) {
|
|
8672
8683
|
const maxRoundNumber = Math.max(...Object.keys(roundMatchUps)
|
|
8673
8684
|
.map((key) => ensureInt(key))
|
|
8674
|
-
.filter((f) => !isNaN(f)));
|
|
8685
|
+
.filter((f) => !Number.isNaN(f)));
|
|
8675
8686
|
const maxRoundMatchUpsCount = roundMatchUps[maxRoundNumber]?.length;
|
|
8676
8687
|
if (maxRoundMatchUpsCount > 1 && isPowerOf2(maxRoundMatchUpsCount)) {
|
|
8677
8688
|
const nextRound = maxRoundNumber + 1;
|
|
@@ -8694,10 +8705,10 @@ function getRoundMatchUps({ matchUps = [], interpolate }) {
|
|
|
8694
8705
|
let feedRoundIndex = 0;
|
|
8695
8706
|
const roundNumbers = Object.keys(roundMatchUps)
|
|
8696
8707
|
.map((key) => ensureInt(key))
|
|
8697
|
-
.filter((f) => !isNaN(f));
|
|
8708
|
+
.filter((f) => !Number.isNaN(f));
|
|
8698
8709
|
roundNumbers.forEach((roundNumber) => {
|
|
8699
8710
|
const currentRoundMatchUps = roundMatchUps[roundNumber].sort((a, b) => a.roundPosition - b.roundPosition);
|
|
8700
|
-
const currentRoundDrawPositions = currentRoundMatchUps.
|
|
8711
|
+
const currentRoundDrawPositions = currentRoundMatchUps.flatMap((matchUp) => matchUp?.drawPositions || []);
|
|
8701
8712
|
roundProfile[roundNumber].roundNumber = roundNumber;
|
|
8702
8713
|
roundProfile[roundNumber].roundFactor = roundProfile[roundNumber].matchUpsCount
|
|
8703
8714
|
? maxMatchUpsCount / roundProfile[roundNumber].matchUpsCount
|
|
@@ -8758,7 +8769,7 @@ function getRoundMatchUps({ matchUps = [], interpolate }) {
|
|
|
8758
8769
|
roundIndex += 1;
|
|
8759
8770
|
}
|
|
8760
8771
|
});
|
|
8761
|
-
const roundsNotPowerOf2 = !!Object.values(roundProfile).
|
|
8772
|
+
const roundsNotPowerOf2 = !!Object.values(roundProfile).some(({ matchUpsCount }) => !isPowerOf2(matchUpsCount));
|
|
8762
8773
|
const hasNoRoundPositions = matchUps.some((matchUp) => !matchUp.roundPosition);
|
|
8763
8774
|
return {
|
|
8764
8775
|
hasNoRoundPositions,
|
|
@@ -9111,7 +9122,7 @@ function getRoundContextProfile({ roundNamingPolicy, drawDefinition, structure,
|
|
|
9111
9122
|
const add = (a, b) => (a || 0) + (b || 0);
|
|
9112
9123
|
function getBand(spread, bandProfiles) {
|
|
9113
9124
|
const spreadValue = Array.isArray(spread) ? spread[0] : spread;
|
|
9114
|
-
return ((isNaN(spreadValue) && WALKOVER$1) ||
|
|
9125
|
+
return ((Number.isNaN(spreadValue) && WALKOVER$1) ||
|
|
9115
9126
|
(spreadValue <= bandProfiles[DECISIVE] && DECISIVE) ||
|
|
9116
9127
|
(spreadValue <= bandProfiles[ROUTINE] && ROUTINE) ||
|
|
9117
9128
|
COMPETITIVE);
|
|
@@ -9281,7 +9292,7 @@ function getCheckedInParticipantIds({ matchUp }) {
|
|
|
9281
9292
|
return { error: MISSING_MATCHUP };
|
|
9282
9293
|
if (!matchUp.hasContext)
|
|
9283
9294
|
return { error: MISSING_CONTEXT };
|
|
9284
|
-
if (!matchUp.sides || matchUp
|
|
9295
|
+
if (!matchUp.sides || matchUp?.sides.filter(Boolean).length !== 2) {
|
|
9285
9296
|
return { error: INVALID_MATCHUP };
|
|
9286
9297
|
}
|
|
9287
9298
|
const { nestedIndividualParticipantIds, allRelevantParticipantIds, sideParticipantIds } = getMatchUpParticipantIds({
|
|
@@ -15778,6 +15789,84 @@ function addVoluntaryConsolationStructure({ structureName = constantToString(VOL
|
|
|
15778
15789
|
return { ...SUCCESS };
|
|
15779
15790
|
}
|
|
15780
15791
|
|
|
15792
|
+
function getDivisions({ size }) {
|
|
15793
|
+
const divisions = [size];
|
|
15794
|
+
let division = size;
|
|
15795
|
+
while (division / 2 === Math.floor(division / 2)) {
|
|
15796
|
+
division = division / 2;
|
|
15797
|
+
divisions.push(division);
|
|
15798
|
+
}
|
|
15799
|
+
if (!divisions.includes(1))
|
|
15800
|
+
divisions.push(1);
|
|
15801
|
+
divisions.sort(numericSort);
|
|
15802
|
+
divisions.reverse();
|
|
15803
|
+
return divisions;
|
|
15804
|
+
}
|
|
15805
|
+
function getSubBlock({ blockPattern, index }) {
|
|
15806
|
+
let i = 0;
|
|
15807
|
+
for (const subBlock of blockPattern) {
|
|
15808
|
+
if (i === index)
|
|
15809
|
+
return subBlock;
|
|
15810
|
+
let j = 0;
|
|
15811
|
+
while (j < subBlock.length) {
|
|
15812
|
+
if (i === index)
|
|
15813
|
+
return subBlock;
|
|
15814
|
+
i += 1;
|
|
15815
|
+
j++;
|
|
15816
|
+
}
|
|
15817
|
+
}
|
|
15818
|
+
}
|
|
15819
|
+
function generateBlockPattern({ positioning, size }) {
|
|
15820
|
+
const divisions = getDivisions({ size });
|
|
15821
|
+
const divisionGroupings = [];
|
|
15822
|
+
const selected = [];
|
|
15823
|
+
const firstMember = (arr) => arr[0];
|
|
15824
|
+
const lastMember = (arr) => arr[arr.length - 1];
|
|
15825
|
+
const getMember = (arr, i) => (positioning && [CLUSTER, ADJACENT, WATERFALL].includes(positioning) && i % 2
|
|
15826
|
+
? lastMember(arr)
|
|
15827
|
+
: firstMember(arr)) || firstMember(arr);
|
|
15828
|
+
const noneSelected = (chunk, i) => {
|
|
15829
|
+
if (chunk.every((member) => !selected.includes(member))) {
|
|
15830
|
+
const member = getMember(chunk, i);
|
|
15831
|
+
selected.push(member);
|
|
15832
|
+
return member;
|
|
15833
|
+
}
|
|
15834
|
+
};
|
|
15835
|
+
const notSelected = (chunk) => {
|
|
15836
|
+
const notSelected = chunk.filter((member) => !selected.includes(member));
|
|
15837
|
+
if (notSelected.length) {
|
|
15838
|
+
selected.push(...notSelected);
|
|
15839
|
+
return notSelected;
|
|
15840
|
+
}
|
|
15841
|
+
};
|
|
15842
|
+
const select = (chunk, i) => {
|
|
15843
|
+
const member = getMember(chunk, i);
|
|
15844
|
+
if (!selected.includes(member)) {
|
|
15845
|
+
selected.push(member);
|
|
15846
|
+
return member;
|
|
15847
|
+
}
|
|
15848
|
+
};
|
|
15849
|
+
const range = generateRange(1, size + 1);
|
|
15850
|
+
for (const division of divisions) {
|
|
15851
|
+
if (division === 1) {
|
|
15852
|
+
const chunks = chunkArray(range, 2);
|
|
15853
|
+
const positions = chunks.map(noneSelected).filter(Boolean);
|
|
15854
|
+
if (positions.length)
|
|
15855
|
+
divisionGroupings.push(positions);
|
|
15856
|
+
const lastPositions = chunks.flatMap(notSelected).filter(Boolean);
|
|
15857
|
+
if (lastPositions.length)
|
|
15858
|
+
divisionGroupings.push(lastPositions);
|
|
15859
|
+
}
|
|
15860
|
+
else {
|
|
15861
|
+
const chunks = chunkArray(range, division);
|
|
15862
|
+
const positions = chunks.map(select).filter(Boolean);
|
|
15863
|
+
if (positions.length)
|
|
15864
|
+
divisionGroupings.push(positions);
|
|
15865
|
+
}
|
|
15866
|
+
}
|
|
15867
|
+
return { divisions, divisionGroupings };
|
|
15868
|
+
}
|
|
15869
|
+
|
|
15781
15870
|
function getRoundRobinGroupMatchUps({ drawPositions }) {
|
|
15782
15871
|
if (!drawPositions?.length)
|
|
15783
15872
|
return { error: MISSING_DRAW_POSITIONS };
|
|
@@ -16128,83 +16217,6 @@ function getNumericSeedValue(seedValue) {
|
|
|
16128
16217
|
return Infinity;
|
|
16129
16218
|
}
|
|
16130
16219
|
|
|
16131
|
-
function getDivisions({ size }) {
|
|
16132
|
-
const divisions = [size];
|
|
16133
|
-
let division = size;
|
|
16134
|
-
while (division / 2 === Math.floor(division / 2)) {
|
|
16135
|
-
division = division / 2;
|
|
16136
|
-
divisions.push(division);
|
|
16137
|
-
}
|
|
16138
|
-
if (!divisions.includes(1))
|
|
16139
|
-
divisions.push(1);
|
|
16140
|
-
divisions.sort(numericSort);
|
|
16141
|
-
divisions.reverse();
|
|
16142
|
-
return divisions;
|
|
16143
|
-
}
|
|
16144
|
-
function getSubBlock({ blockPattern, index }) {
|
|
16145
|
-
let i = 0;
|
|
16146
|
-
for (const subBlock of blockPattern) {
|
|
16147
|
-
if (i === index)
|
|
16148
|
-
return subBlock;
|
|
16149
|
-
let j = 0;
|
|
16150
|
-
while (j < subBlock.length) {
|
|
16151
|
-
if (i === index)
|
|
16152
|
-
return subBlock;
|
|
16153
|
-
i += 1;
|
|
16154
|
-
j++;
|
|
16155
|
-
}
|
|
16156
|
-
}
|
|
16157
|
-
}
|
|
16158
|
-
function generateBlockPattern({ positioning, size }) {
|
|
16159
|
-
const divisions = getDivisions({ size });
|
|
16160
|
-
const divisionGroupings = [];
|
|
16161
|
-
const selected = [];
|
|
16162
|
-
const firstMember = (arr) => arr[0];
|
|
16163
|
-
const lastMember = (arr) => arr[arr.length - 1];
|
|
16164
|
-
const getMember = (arr, i) => (positioning && [CLUSTER, WATERFALL].includes(positioning) && i % 2 ? lastMember(arr) : firstMember(arr)) ||
|
|
16165
|
-
firstMember(arr);
|
|
16166
|
-
const noneSelected = (chunk, i) => {
|
|
16167
|
-
if (chunk.every((member) => !selected.includes(member))) {
|
|
16168
|
-
const member = getMember(chunk, i);
|
|
16169
|
-
selected.push(member);
|
|
16170
|
-
return member;
|
|
16171
|
-
}
|
|
16172
|
-
};
|
|
16173
|
-
const notSelected = (chunk) => {
|
|
16174
|
-
const notSelected = chunk.filter((member) => !selected.includes(member));
|
|
16175
|
-
if (notSelected.length) {
|
|
16176
|
-
selected.push(...notSelected);
|
|
16177
|
-
return notSelected;
|
|
16178
|
-
}
|
|
16179
|
-
};
|
|
16180
|
-
const select = (chunk, i) => {
|
|
16181
|
-
const member = getMember(chunk, i);
|
|
16182
|
-
if (!selected.includes(member)) {
|
|
16183
|
-
selected.push(member);
|
|
16184
|
-
return member;
|
|
16185
|
-
}
|
|
16186
|
-
};
|
|
16187
|
-
const range = generateRange(1, size + 1);
|
|
16188
|
-
for (const division of divisions) {
|
|
16189
|
-
if (division === 1) {
|
|
16190
|
-
const chunks = chunkArray(range, 2);
|
|
16191
|
-
const positions = chunks.map(noneSelected).filter(Boolean);
|
|
16192
|
-
if (positions.length)
|
|
16193
|
-
divisionGroupings.push(positions);
|
|
16194
|
-
const lastPositions = chunks.flatMap(notSelected).filter(Boolean);
|
|
16195
|
-
if (lastPositions.length)
|
|
16196
|
-
divisionGroupings.push(lastPositions);
|
|
16197
|
-
}
|
|
16198
|
-
else {
|
|
16199
|
-
const chunks = chunkArray(range, division);
|
|
16200
|
-
const positions = chunks.map(select).filter(Boolean);
|
|
16201
|
-
if (positions.length)
|
|
16202
|
-
divisionGroupings.push(positions);
|
|
16203
|
-
}
|
|
16204
|
-
}
|
|
16205
|
-
return { divisions, divisionGroupings };
|
|
16206
|
-
}
|
|
16207
|
-
|
|
16208
16220
|
function getValidSeedBlocks({ provisionalPositioning, returnAllProxies, appliedPolicies, seedingProfile, drawDefinition, allPositions, structure, }) {
|
|
16209
16221
|
let validSeedBlocks = [];
|
|
16210
16222
|
if (!structure)
|
|
@@ -16394,7 +16406,7 @@ function constructPower2Blocks(params) {
|
|
|
16394
16406
|
let count = 1;
|
|
16395
16407
|
const blocks = [];
|
|
16396
16408
|
const { seedBlocks } = getSeedBlocks({
|
|
16397
|
-
cluster: getSeedPattern(seedingProfile)
|
|
16409
|
+
cluster: [CLUSTER, ADJACENT].includes(getSeedPattern(seedingProfile)),
|
|
16398
16410
|
participantsCount: baseDrawSize,
|
|
16399
16411
|
roundRobinGroupsCount,
|
|
16400
16412
|
});
|
|
@@ -18850,7 +18862,7 @@ function getUnseededByePositions({ provisionalPositioning, seedOrderByePositions
|
|
|
18850
18862
|
if (isFeedIn) {
|
|
18851
18863
|
const baseDrawSize = relevantDrawPositions.length;
|
|
18852
18864
|
const { seedBlocks } = getSeedBlocks({
|
|
18853
|
-
cluster: getSeedPattern(seedingProfile)
|
|
18865
|
+
cluster: [CLUSTER, ADJACENT].includes(getSeedPattern(seedingProfile)),
|
|
18854
18866
|
participantsCount: baseDrawSize,
|
|
18855
18867
|
});
|
|
18856
18868
|
const blockDrawPositions = seedBlocks.map((seedBlock) => seedBlock.map((drawPosition) => drawPosition + drawPositionOffset));
|
|
@@ -21666,8 +21678,7 @@ function processPlayoffGroups({ requireSequential = true, playoffMatchUpFormat,
|
|
|
21666
21678
|
finishingPositions,
|
|
21667
21679
|
sourceStructureId,
|
|
21668
21680
|
});
|
|
21669
|
-
links.push(playoffLink);
|
|
21670
|
-
links.push(...playoffLinks);
|
|
21681
|
+
links.push(playoffLink, ...playoffLinks);
|
|
21671
21682
|
structures.push(...playoffStructures);
|
|
21672
21683
|
finishingPositionTargets.push({
|
|
21673
21684
|
structureId: playoffStructure.structureId,
|
|
@@ -21794,8 +21805,7 @@ function processPlayoffGroups({ requireSequential = true, playoffMatchUpFormat,
|
|
|
21794
21805
|
finishingPositions,
|
|
21795
21806
|
sourceStructureId,
|
|
21796
21807
|
});
|
|
21797
|
-
links.push(playoffLink);
|
|
21798
|
-
links.push(...feedInLinks);
|
|
21808
|
+
links.push(playoffLink, ...feedInLinks);
|
|
21799
21809
|
structures.push(...champitionShipStructures);
|
|
21800
21810
|
finishingPositionTargets.push({
|
|
21801
21811
|
structureId: playoffStructure.structureId,
|
|
@@ -22010,7 +22020,7 @@ function getRatingConvertedFromELO({ targetRatingType, sourceRating }) {
|
|
|
22010
22020
|
sourceRange: eloRatingRange,
|
|
22011
22021
|
value: sourceRating,
|
|
22012
22022
|
});
|
|
22013
|
-
const convertedRating = parseFloat(result.toFixed(decimalPlaces));
|
|
22023
|
+
const convertedRating = Number.parseFloat(result.toFixed(decimalPlaces));
|
|
22014
22024
|
return invertedScale ? maxTargetRatingRange - convertedRating : convertedRating;
|
|
22015
22025
|
}
|
|
22016
22026
|
|
|
@@ -22061,8 +22071,8 @@ function calculatePressureRatings({ participantResults, sides, score }) {
|
|
|
22061
22071
|
}
|
|
22062
22072
|
}
|
|
22063
22073
|
function getSideValues$1({ side1ConvertedRating, side2ConvertedRating, score }) {
|
|
22064
|
-
const highRating = side1ConvertedRating
|
|
22065
|
-
const lowRating = side1ConvertedRating
|
|
22074
|
+
const highRating = Math.max(side1ConvertedRating, side2ConvertedRating);
|
|
22075
|
+
const lowRating = Math.min(side1ConvertedRating, side2ConvertedRating);
|
|
22066
22076
|
const ratingsDifference = Math.abs(side1ConvertedRating - side2ConvertedRating);
|
|
22067
22077
|
const eloRatingRange = ratingsParameters[ELO].range;
|
|
22068
22078
|
const rangeMax = Math.max(...eloRatingRange);
|
|
@@ -22227,19 +22237,19 @@ function calculatePercentages({ participantResults, groupingTotal, matchUpFormat
|
|
|
22227
22237
|
? totalSets
|
|
22228
22238
|
: perPlayer * (bracketSetsToWin) || setsWon + setsLost;
|
|
22229
22239
|
let setsPct = Math.round((setsWon / setsTotal) * precision) / precision;
|
|
22230
|
-
if (setsPct === Infinity || isNaN(setsPct))
|
|
22240
|
+
if (setsPct === Infinity || Number.isNaN(setsPct))
|
|
22231
22241
|
setsPct = setsTotal;
|
|
22232
22242
|
const tieMatchUpsWon = participantResults[participantId].tieMatchUpsWon;
|
|
22233
22243
|
const tieMatchUpsLost = participantResults[participantId].tieMatchUpsLost;
|
|
22234
22244
|
const tieMatchUpsTotal = tieMatchUpsWon + tieMatchUpsLost;
|
|
22235
22245
|
let tieMatchUpsPct = Math.round((tieMatchUpsWon / tieMatchUpsTotal) * precision) / precision;
|
|
22236
|
-
if (tieMatchUpsPct === Infinity || isNaN(tieMatchUpsPct))
|
|
22246
|
+
if (tieMatchUpsPct === Infinity || Number.isNaN(tieMatchUpsPct))
|
|
22237
22247
|
tieMatchUpsPct = tieMatchUpsWon;
|
|
22238
22248
|
const matchUpsWon = participantResults[participantId].matchUpsWon;
|
|
22239
22249
|
const matchUpsLost = participantResults[participantId].matchUpsLost;
|
|
22240
22250
|
const matchUpsTotal = matchUpsWon + matchUpsLost;
|
|
22241
22251
|
let matchUpsPct = Math.round((matchUpsWon / matchUpsTotal) * precision) / precision;
|
|
22242
|
-
if (matchUpsPct === Infinity || isNaN(matchUpsPct))
|
|
22252
|
+
if (matchUpsPct === Infinity || Number.isNaN(matchUpsPct))
|
|
22243
22253
|
matchUpsPct = matchUpsWon;
|
|
22244
22254
|
const gamesWon = participantResults[participantId].gamesWon || 0;
|
|
22245
22255
|
const gamesLost = participantResults[participantId].gamesLost || 0;
|
|
@@ -22248,11 +22258,11 @@ function calculatePercentages({ participantResults, groupingTotal, matchUpFormat
|
|
|
22248
22258
|
? totalGames
|
|
22249
22259
|
: Math.max(minimumExpectedGames, gamesWon + gamesLost);
|
|
22250
22260
|
let gamesPct = Math.round((gamesWon / gamesTotal) * precision) / precision;
|
|
22251
|
-
if (gamesPct === Infinity || isNaN(gamesPct))
|
|
22261
|
+
if (gamesPct === Infinity || Number.isNaN(gamesPct))
|
|
22252
22262
|
gamesPct = 0;
|
|
22253
22263
|
const pointsTotal = participantResults[participantId].pointsWon + participantResults[participantId].pointsLost;
|
|
22254
22264
|
let pointsPct = Math.round((participantResults[participantId].pointsWon / pointsTotal) * precision) / precision;
|
|
22255
|
-
if (pointsPct === Infinity || isNaN(pointsPct))
|
|
22265
|
+
if (pointsPct === Infinity || Number.isNaN(pointsPct))
|
|
22256
22266
|
pointsPct = 0;
|
|
22257
22267
|
participantResults[participantId].setsWon = setsWon;
|
|
22258
22268
|
participantResults[participantId].setsLost = setsLost;
|
|
@@ -23471,16 +23481,16 @@ function evaluateCollectionResult({ collectionDefinition, groupValueNumbers, gro
|
|
|
23471
23481
|
else {
|
|
23472
23482
|
sideCollectionValues = sideMatchUpValues;
|
|
23473
23483
|
}
|
|
23474
|
-
if (
|
|
23475
|
-
sideCollectionValues.forEach((sideCollectionValue, i) => (sideTieValues[i] += sideCollectionValue || 0));
|
|
23476
|
-
}
|
|
23477
|
-
else {
|
|
23484
|
+
if (belongsToValueGroup) {
|
|
23478
23485
|
groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
|
|
23479
23486
|
groupValueGroups[collectionGroupNumber].sideWins[1] += sideWins[1] || 0;
|
|
23480
23487
|
groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted =
|
|
23481
23488
|
groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted && allCollectionMatchUpsCompleted;
|
|
23482
23489
|
groupValueGroups[collectionGroupNumber].matchUpsCount += collectionMatchUps.length;
|
|
23483
23490
|
}
|
|
23491
|
+
else {
|
|
23492
|
+
sideCollectionValues.forEach((sideCollectionValue, i) => (sideTieValues[i] += sideCollectionValue || 0));
|
|
23493
|
+
}
|
|
23484
23494
|
}
|
|
23485
23495
|
function getCollectionPositionValue({ collectionDefinition, collectionPosition }) {
|
|
23486
23496
|
const collectionValueProfiles = collectionDefinition.collectionValueProfiles || [];
|
|
@@ -23492,7 +23502,7 @@ function generateTieMatchUpScore(params) {
|
|
|
23492
23502
|
const { sideAdjustments = [0, 0], separator = '-', drawDefinition, matchUpsMap, structure, matchUp, event, } = params;
|
|
23493
23503
|
if (!Array.isArray(sideAdjustments) ||
|
|
23494
23504
|
sideAdjustments.length !== 2 ||
|
|
23495
|
-
isNaN(sideAdjustments.reduce((a, b) => a + b))) {
|
|
23505
|
+
Number.isNaN(sideAdjustments.reduce((a, b) => a + b))) {
|
|
23496
23506
|
return { error: INVALID_VALUES };
|
|
23497
23507
|
}
|
|
23498
23508
|
if (!matchUp)
|
|
@@ -24897,7 +24907,7 @@ function analyzeDraws({ tournamentRecord }) {
|
|
|
24897
24907
|
};
|
|
24898
24908
|
const eventsMap = {};
|
|
24899
24909
|
const eventDraws = tournamentRecord.events
|
|
24900
|
-
?.
|
|
24910
|
+
?.flatMap((event) => {
|
|
24901
24911
|
const eventId = event.eventId;
|
|
24902
24912
|
eventsMap[eventId] = event;
|
|
24903
24913
|
return (event?.drawDefinitions || []).map((drawDefinition) => ({
|
|
@@ -24905,7 +24915,6 @@ function analyzeDraws({ tournamentRecord }) {
|
|
|
24905
24915
|
eventId,
|
|
24906
24916
|
}));
|
|
24907
24917
|
})
|
|
24908
|
-
.flat()
|
|
24909
24918
|
.filter(Boolean);
|
|
24910
24919
|
eventDraws.forEach(({ drawDefinition, eventId }) => {
|
|
24911
24920
|
let positionsAssignedCount = 0;
|
|
@@ -24939,11 +24948,11 @@ function analyzeDraws({ tournamentRecord }) {
|
|
|
24939
24948
|
const activeRounds = roundProfile &&
|
|
24940
24949
|
Object.keys(roundProfile)
|
|
24941
24950
|
.filter((roundNumber) => !roundProfile[roundNumber].inactiveRound)
|
|
24942
|
-
.map((roundNumber) => parseInt(roundNumber));
|
|
24951
|
+
.map((roundNumber) => Number.parseInt(roundNumber));
|
|
24943
24952
|
const inactiveRounds = roundProfile &&
|
|
24944
24953
|
Object.keys(roundProfile)
|
|
24945
24954
|
.filter((roundNumber) => roundProfile[roundNumber].inactiveRound)
|
|
24946
|
-
.map((roundNumber) => parseInt(roundNumber));
|
|
24955
|
+
.map((roundNumber) => Number.parseInt(roundNumber));
|
|
24947
24956
|
const inactiveStructure = roundProfile && Object.values(roundProfile).every((profile) => profile.inactiveRound);
|
|
24948
24957
|
return {
|
|
24949
24958
|
positionsAssignedCount: positionsAssigned?.length ?? 0,
|
|
@@ -28374,7 +28383,7 @@ const k538 = (countables = 0) => 250 / Math.pow(countables + 5, 0.4);
|
|
|
28374
28383
|
const kDefault = () => 1;
|
|
28375
28384
|
function kSet(maxCountables = 3, counted = 2) {
|
|
28376
28385
|
const kset = maxCountables / counted;
|
|
28377
|
-
return isNaN(kset) ? eloConfig.kDefault() : kset;
|
|
28386
|
+
return Number.isNaN(kset) ? eloConfig.kDefault() : kset;
|
|
28378
28387
|
}
|
|
28379
28388
|
const eloConfig = {
|
|
28380
28389
|
nSpread: 400,
|
|
@@ -28395,7 +28404,7 @@ function calculateNewRatings(params) {
|
|
|
28395
28404
|
const invertedScale = ratingRange[0] > ratingRange[1];
|
|
28396
28405
|
const decimalPlaces = ratingParameters.decimalsCount || 0;
|
|
28397
28406
|
const consideredRange = invertedScale ? ratingRange.slice().reverse() : ratingRange;
|
|
28398
|
-
const inRange = (range, value) => parseFloat(value) >= Math.min(...range) && parseFloat(value) <= Math.max(...range);
|
|
28407
|
+
const inRange = (range, value) => Number.parseFloat(value) >= Math.min(...range) && Number.parseFloat(value) <= Math.max(...range);
|
|
28399
28408
|
if (!inRange(ratingRange, winnerRating) || !inRange(ratingRange, loserRating)) {
|
|
28400
28409
|
if (!inRange(ratingRange, winnerRating))
|
|
28401
28410
|
winnerRating = ratingParameters.defaultInitialization;
|
|
@@ -28433,9 +28442,9 @@ function calculateNewRatings(params) {
|
|
|
28433
28442
|
const updatedWinnerRating = invertedScale
|
|
28434
28443
|
? ratingRange[0] - convertedUpdatedWinnerRating
|
|
28435
28444
|
: convertedUpdatedWinnerRating;
|
|
28436
|
-
let newWinnerRating = parseFloat(updatedWinnerRating.toFixed(decimalPlaces));
|
|
28445
|
+
let newWinnerRating = Number.parseFloat(updatedWinnerRating.toFixed(decimalPlaces));
|
|
28437
28446
|
const updatedLoserRating = invertedScale ? ratingRange[0] - convertedUpdatedLoserRating : convertedUpdatedLoserRating;
|
|
28438
|
-
let newLoserRating = parseFloat(updatedLoserRating.toFixed(decimalPlaces));
|
|
28447
|
+
let newLoserRating = Number.parseFloat(updatedLoserRating.toFixed(decimalPlaces));
|
|
28439
28448
|
const percentageDifference = Math.max(...ratingRange)
|
|
28440
28449
|
? Math.abs(winnerRating - loserRating) / Math.max(...ratingRange)
|
|
28441
28450
|
: 0;
|
|
@@ -30442,7 +30451,7 @@ function keyValueScore(params) {
|
|
|
30442
30451
|
const { tiebreakTo, NoAD } = tiebreakFormat || {};
|
|
30443
30452
|
const leadingSide = getLeadingSide({ set });
|
|
30444
30453
|
if (!analysis.isTiebreakSet) {
|
|
30445
|
-
const lowTiebreakScore = parseInt(scoreString.split(open).reverse()[0]);
|
|
30454
|
+
const lowTiebreakScore = Number.parseInt(scoreString.split(open).reverse()[0]);
|
|
30446
30455
|
const highTiebreakScore = getHighTiebreakValue$1({
|
|
30447
30456
|
lowValue: lowTiebreakScore,
|
|
30448
30457
|
tiebreakTo,
|
|
@@ -34586,11 +34595,13 @@ function getCompetitionDateRange({ tournamentRecords }) {
|
|
|
34586
34595
|
const dateRange = tournamentIds.reduce((dateRange, tournamentId) => {
|
|
34587
34596
|
const tournamentRecord = tournamentRecords[tournamentId];
|
|
34588
34597
|
const { tournamentInfo: { startDate, endDate }, } = getTournamentInfo({ tournamentRecord });
|
|
34589
|
-
const
|
|
34598
|
+
const extractedStart = startDate && extractDate(startDate);
|
|
34599
|
+
const dateOfStart = extractedStart && new Date(extractedStart);
|
|
34590
34600
|
if (!dateRange.startDate || (dateOfStart && dateOfStart < dateRange.startDate)) {
|
|
34591
34601
|
dateRange.startDate = dateOfStart;
|
|
34592
34602
|
}
|
|
34593
|
-
const
|
|
34603
|
+
const extractedEnd = endDate && extractDate(endDate);
|
|
34604
|
+
const dateOfEnd = extractedEnd && new Date(extractedEnd);
|
|
34594
34605
|
if (!dateRange.endDate || (dateOfEnd && dateOfEnd > dateRange.endDate)) {
|
|
34595
34606
|
dateRange.endDate = dateOfEnd;
|
|
34596
34607
|
}
|
|
@@ -38492,7 +38503,7 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
|
|
|
38492
38503
|
withScaleValues: true,
|
|
38493
38504
|
tournamentRecord,
|
|
38494
38505
|
}).participantMap;
|
|
38495
|
-
const sum = (values) => values.reduce((total, value) => total + parseFloat(value), 0);
|
|
38506
|
+
const sum = (values) => values.reduce((total, value) => total + Number.parseFloat(value), 0);
|
|
38496
38507
|
for (const event of eventCopies) {
|
|
38497
38508
|
const eventType = scaleEventType ?? event.eventType;
|
|
38498
38509
|
const eventId = event.eventId;
|
|
@@ -38513,7 +38524,7 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
|
|
|
38513
38524
|
eventsMap[eventId].ratings[scaleName] = [];
|
|
38514
38525
|
const accessor = ratingsParameters[scaleName]?.accessor;
|
|
38515
38526
|
if (accessor) {
|
|
38516
|
-
const value = parseFloat(rating.scaleValue?.[accessor]);
|
|
38527
|
+
const value = Number.parseFloat(rating.scaleValue?.[accessor]);
|
|
38517
38528
|
if (value)
|
|
38518
38529
|
eventsMap[eventId].ratings[scaleName].push(value);
|
|
38519
38530
|
}
|
|
@@ -38531,15 +38542,15 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
|
|
|
38531
38542
|
};
|
|
38532
38543
|
for (const participantId of participantIds) {
|
|
38533
38544
|
const participant = participantMap?.[participantId]?.participant;
|
|
38534
|
-
if (participant?.participantType
|
|
38545
|
+
if (participant?.participantType === INDIVIDUAL) {
|
|
38546
|
+
processParticipant(participant);
|
|
38547
|
+
}
|
|
38548
|
+
else {
|
|
38535
38549
|
for (const individualParticipantId of participant?.individualParticipantIds ?? []) {
|
|
38536
38550
|
const individualParticipant = participantMap?.[individualParticipantId]?.participant;
|
|
38537
38551
|
processParticipant(individualParticipant);
|
|
38538
38552
|
}
|
|
38539
38553
|
}
|
|
38540
|
-
else {
|
|
38541
|
-
processParticipant(participant);
|
|
38542
|
-
}
|
|
38543
38554
|
}
|
|
38544
38555
|
const ratings = eventsMap[eventId].ratings;
|
|
38545
38556
|
for (const scaleName of Object.keys(ratings)) {
|
|
@@ -38548,8 +38559,8 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
|
|
|
38548
38559
|
continue;
|
|
38549
38560
|
const med = median(scaleRating)?.toFixed(2);
|
|
38550
38561
|
eventsMap[eventId].ratingsStats[scaleName] = {
|
|
38551
|
-
avg: parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
|
|
38552
|
-
median: med ? parseFloat(med) : undefined,
|
|
38562
|
+
avg: Number.parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
|
|
38563
|
+
median: med ? Number.parseFloat(med) : undefined,
|
|
38553
38564
|
max: Math.max(...scaleRating),
|
|
38554
38565
|
min: Math.min(...scaleRating),
|
|
38555
38566
|
};
|
|
@@ -38563,7 +38574,7 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
|
|
|
38563
38574
|
eventsMap[eventId].draws[drawId].ratings[scaleName] = [];
|
|
38564
38575
|
const accessor = ratingsParameters[scaleName]?.accessor;
|
|
38565
38576
|
if (accessor) {
|
|
38566
|
-
const value = parseFloat(rating.scaleValue?.[accessor]);
|
|
38577
|
+
const value = Number.parseFloat(rating.scaleValue?.[accessor]);
|
|
38567
38578
|
if (value) {
|
|
38568
38579
|
eventsMap[eventId].draws[drawId].ratings[scaleName].push(value);
|
|
38569
38580
|
}
|
|
@@ -38584,15 +38595,15 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
|
|
|
38584
38595
|
};
|
|
38585
38596
|
for (const participantId of participantIds.filter(Boolean)) {
|
|
38586
38597
|
const participant = participantMap?.[participantId]?.participant;
|
|
38587
|
-
if (participant?.participantType
|
|
38598
|
+
if (participant?.participantType === INDIVIDUAL) {
|
|
38599
|
+
processParticipant(participant);
|
|
38600
|
+
}
|
|
38601
|
+
else {
|
|
38588
38602
|
for (const individualParticipantId of participant?.individualParticipantIds ?? []) {
|
|
38589
38603
|
const individualParticipant = participantMap?.[individualParticipantId]?.participant;
|
|
38590
38604
|
processParticipant(individualParticipant);
|
|
38591
38605
|
}
|
|
38592
38606
|
}
|
|
38593
|
-
else {
|
|
38594
|
-
processParticipant(participant);
|
|
38595
|
-
}
|
|
38596
38607
|
}
|
|
38597
38608
|
};
|
|
38598
38609
|
const processedDrawIds = [];
|
|
@@ -38629,8 +38640,8 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
|
|
|
38629
38640
|
continue;
|
|
38630
38641
|
const med = median(scaleRating)?.toFixed(2);
|
|
38631
38642
|
eventsMap[eventId].draws[drawId].ratingsStats[scaleName] = {
|
|
38632
|
-
avg: parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
|
|
38633
|
-
median: med ? parseFloat(med) : undefined,
|
|
38643
|
+
avg: Number.parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
|
|
38644
|
+
median: med ? Number.parseFloat(med) : undefined,
|
|
38634
38645
|
max: Math.max(...scaleRating),
|
|
38635
38646
|
min: Math.min(...scaleRating),
|
|
38636
38647
|
};
|
|
@@ -42095,7 +42106,7 @@ function generateTimeSlots(params) {
|
|
|
42095
42106
|
let startTime = timeToDate(courtDate.startTime);
|
|
42096
42107
|
(courtDate.bookings || [])
|
|
42097
42108
|
.filter((booking) => !booking.bookingType || !includeBookingTypes.includes(booking.bookingType))
|
|
42098
|
-
.sort((a, b) => tidyTime(a.startTime).localeCompare(tidyTime(b.startTime)))
|
|
42109
|
+
.sort((a, b) => (tidyTime(a.startTime) || '').localeCompare(tidyTime(b.startTime) || ''))
|
|
42099
42110
|
.forEach((booking) => {
|
|
42100
42111
|
const timeSlot = {
|
|
42101
42112
|
startTime: extractTime$1(startTime.toISOString()),
|
|
@@ -42190,11 +42201,11 @@ function generateVirtualCourts(params) {
|
|
|
42190
42201
|
const { courtBookings, unassignedBookings } = bookings.reduce((accumulator, booking) => {
|
|
42191
42202
|
const { courtId } = booking;
|
|
42192
42203
|
if (courtId) {
|
|
42193
|
-
if (
|
|
42194
|
-
accumulator.courtBookings[courtId]
|
|
42204
|
+
if (accumulator.courtBookings[courtId]) {
|
|
42205
|
+
accumulator.courtBookings[courtId].push(booking);
|
|
42195
42206
|
}
|
|
42196
42207
|
else {
|
|
42197
|
-
accumulator.courtBookings[courtId]
|
|
42208
|
+
accumulator.courtBookings[courtId] = [booking];
|
|
42198
42209
|
}
|
|
42199
42210
|
}
|
|
42200
42211
|
else {
|
|
@@ -42228,8 +42239,7 @@ function generateVirtualCourts(params) {
|
|
|
42228
42239
|
};
|
|
42229
42240
|
});
|
|
42230
42241
|
unassignedBookings.sort((a, b) => timeStringMinutes$1(a.startTime) - timeStringMinutes$1(b.startTime));
|
|
42231
|
-
const getCourtTimeSlots = () => inProcessCourts
|
|
42232
|
-
.map((court) => {
|
|
42242
|
+
const getCourtTimeSlots = () => inProcessCourts.flatMap((court) => {
|
|
42233
42243
|
const courtDate = court.dateAvailability;
|
|
42234
42244
|
const { timeSlots = [] } = generateTimeSlots({ courtDate });
|
|
42235
42245
|
return {
|
|
@@ -42237,8 +42247,7 @@ function generateVirtualCourts(params) {
|
|
|
42237
42247
|
courtId: court.courtId,
|
|
42238
42248
|
timeSlots,
|
|
42239
42249
|
};
|
|
42240
|
-
})
|
|
42241
|
-
.flat();
|
|
42250
|
+
});
|
|
42242
42251
|
const assignedBookings = [];
|
|
42243
42252
|
for (const unassignedBooking of unassignedBookings) {
|
|
42244
42253
|
const { startTime, endTime, averageMinutes, recoveryMinutes, matchUpId } = unassignedBooking;
|
|
@@ -42335,7 +42344,7 @@ function getFirstTimeSlotStartTime({ averageMinutes, startTime, endTime, courts,
|
|
|
42335
42344
|
const available = timeSlotMinutes >= averageMinutes;
|
|
42336
42345
|
if (available) {
|
|
42337
42346
|
const timeString = extractTime$1(timeSlotStartTime.toISOString());
|
|
42338
|
-
if (!firstTimeSlotStartTime || timeString < firstTimeSlotStartTime) {
|
|
42347
|
+
if (timeString && (!firstTimeSlotStartTime || timeString < firstTimeSlotStartTime)) {
|
|
42339
42348
|
firstTimeSlotStartTime = timeString;
|
|
42340
42349
|
}
|
|
42341
42350
|
}
|
|
@@ -45277,15 +45286,15 @@ function addMatchUpScheduleItems(params) {
|
|
|
45277
45286
|
let { matchUpDependencies, inContextMatchUps } = params;
|
|
45278
45287
|
const { errorOnAnachronism = false, checkChronology = true, removePriorValues, tournamentRecords, tournamentRecord, drawDefinition, disableNotice, drawMatchUps, matchUpId, schedule, event, } = params;
|
|
45279
45288
|
let matchUp, warning;
|
|
45280
|
-
if (
|
|
45289
|
+
if (drawMatchUps) {
|
|
45290
|
+
matchUp = drawMatchUps.find((drawMatchUp) => drawMatchUp.matchUpId === matchUpId);
|
|
45291
|
+
}
|
|
45292
|
+
else {
|
|
45281
45293
|
const result = findDrawMatchUp({ drawDefinition, event, matchUpId });
|
|
45282
45294
|
if (result.error)
|
|
45283
45295
|
return result;
|
|
45284
45296
|
matchUp = result.matchUp;
|
|
45285
45297
|
}
|
|
45286
|
-
else {
|
|
45287
|
-
matchUp = drawMatchUps.find((drawMatchUp) => drawMatchUp.matchUpId === matchUpId);
|
|
45288
|
-
}
|
|
45289
45298
|
const { endTime, courtId, courtIds, courtOrder, resumeTime, homeParticipantId, scheduledDate, scheduledTime, startTime, stopTime, timeModifiers, venueId, } = schedule;
|
|
45290
45299
|
if (checkChronology && (!matchUpDependencies || !inContextMatchUps)) {
|
|
45291
45300
|
({ matchUpDependencies, matchUps: inContextMatchUps } = getMatchUpDependencies({
|
|
@@ -45299,11 +45308,11 @@ function addMatchUpScheduleItems(params) {
|
|
|
45299
45308
|
priorMatchUpIds.includes(matchUp.matchUpId))
|
|
45300
45309
|
.map(({ schedule }) => {
|
|
45301
45310
|
const isoDateString = getIsoDateString(schedule);
|
|
45302
|
-
return new Date(isoDateString).getTime();
|
|
45311
|
+
return new Date(isoDateString ?? '').getTime();
|
|
45303
45312
|
});
|
|
45304
45313
|
if (priorMatchUpTimes?.length) {
|
|
45305
45314
|
const isoDateString = getIsoDateString(schedule);
|
|
45306
|
-
const matchUpTime = new Date(isoDateString).getTime();
|
|
45315
|
+
const matchUpTime = new Date(isoDateString ?? '').getTime();
|
|
45307
45316
|
const maxPriorMatchUpTime = Math.max(...priorMatchUpTimes);
|
|
45308
45317
|
if (maxPriorMatchUpTime >= matchUpTime) {
|
|
45309
45318
|
if (errorOnAnachronism) {
|
|
@@ -45613,8 +45622,8 @@ function addMatchUpStopTime({ removePriorValues, tournamentRecord, drawDefinitio
|
|
|
45613
45622
|
const relevantTimeItems = timeItems
|
|
45614
45623
|
.filter((timeItem) => [START_TIME, RESUME_TIME, STOP_TIME].includes(timeItem?.itemType))
|
|
45615
45624
|
.sort((a, b) => timeDate(a.itemValue, scheduledDate) - timeDate(b.itemValue, scheduledDate));
|
|
45616
|
-
const lastRelevantTimeItem = relevantTimeItems
|
|
45617
|
-
const lastRelevantTimeItemIsStop = lastRelevantTimeItem
|
|
45625
|
+
const lastRelevantTimeItem = relevantTimeItems.at(-1);
|
|
45626
|
+
const lastRelevantTimeItemIsStop = lastRelevantTimeItem?.itemType === STOP_TIME;
|
|
45618
45627
|
const latestRelevantTimeValue = relevantTimeItems
|
|
45619
45628
|
.filter((timeItem) => !lastRelevantTimeItemIsStop || timeItem.createdAt !== lastRelevantTimeItem.createdAt)
|
|
45620
45629
|
.map((timeItem) => timeDate(timeItem.itemValue, scheduledDate))
|
|
@@ -45659,8 +45668,8 @@ function addMatchUpResumeTime({ removePriorValues, tournamentRecord, drawDefinit
|
|
|
45659
45668
|
const relevantTimeItems = timeItems
|
|
45660
45669
|
.filter((timeItem) => [START_TIME, RESUME_TIME, STOP_TIME].includes(timeItem?.itemType))
|
|
45661
45670
|
.sort((a, b) => timeDate(a.itemValue, scheduledDate) - timeDate(b.itemValue, scheduledDate));
|
|
45662
|
-
const lastRelevantTimeItem = relevantTimeItems
|
|
45663
|
-
const lastRelevantTimeItemIsResume = lastRelevantTimeItem
|
|
45671
|
+
const lastRelevantTimeItem = relevantTimeItems.at(-1);
|
|
45672
|
+
const lastRelevantTimeItemIsResume = lastRelevantTimeItem?.itemType === RESUME_TIME;
|
|
45664
45673
|
const latestRelevantTimeValue = relevantTimeItems
|
|
45665
45674
|
.filter((timeItem) => !lastRelevantTimeItemIsResume || timeItem.createdAt !== lastRelevantTimeItem.createdAt)
|
|
45666
45675
|
.map((timeItem) => timeDate(timeItem.itemValue, scheduledDate))
|
|
@@ -47205,6 +47214,7 @@ var mutate$7 = {
|
|
|
47205
47214
|
resetTieFormat: resetTieFormat,
|
|
47206
47215
|
setDelegatedOutcome: setDelegatedOutcome,
|
|
47207
47216
|
setMatchUpFormat: setMatchUpFormat,
|
|
47217
|
+
setMatchUpState: setMatchUpState,
|
|
47208
47218
|
setMatchUpStatus: setMatchUpStatus,
|
|
47209
47219
|
setOrderOfFinish: setOrderOfFinish,
|
|
47210
47220
|
substituteParticipant: substituteParticipant,
|
|
@@ -47271,6 +47281,7 @@ var index$9 = {
|
|
|
47271
47281
|
resetTieFormat: resetTieFormat,
|
|
47272
47282
|
setDelegatedOutcome: setDelegatedOutcome,
|
|
47273
47283
|
setMatchUpFormat: setMatchUpFormat,
|
|
47284
|
+
setMatchUpState: setMatchUpState,
|
|
47274
47285
|
setMatchUpStatus: setMatchUpStatus,
|
|
47275
47286
|
setOrderOfFinish: setOrderOfFinish,
|
|
47276
47287
|
substituteParticipant: substituteParticipant,
|
|
@@ -47425,7 +47436,9 @@ function updateTimeAfterRecovery({ matchUpPotentialParticipantIds, individualPar
|
|
|
47425
47436
|
participantId,
|
|
47426
47437
|
});
|
|
47427
47438
|
const matchUpTypeChange = individualParticipantProfiles[participantId].priorMatchUpType !== matchUp.matchUpType;
|
|
47428
|
-
const recoveryValue = matchUpTypeChange
|
|
47439
|
+
const recoveryValue = matchUpTypeChange
|
|
47440
|
+
? typeChangeTimeAfterRecovery || timeAfterRecovery
|
|
47441
|
+
: timeAfterRecovery;
|
|
47429
47442
|
if (potentialIndividualParticipantIds.includes(participantId)) {
|
|
47430
47443
|
addParticipantPotentialRecovery({
|
|
47431
47444
|
individualParticipantProfiles,
|
|
@@ -47514,22 +47527,23 @@ function checkRequestConflicts({ averageMatchUpMinutes = 90, requestConflicts =
|
|
|
47514
47527
|
const averageEnd = extractTime$1(addMinutes(scheduleStart, averageMatchUpMinutes).toISOString());
|
|
47515
47528
|
for (const request of relevantPersonRequests) {
|
|
47516
47529
|
const { requestId, startTime, endTime } = request;
|
|
47517
|
-
const conflict = (scheduleTime > startTime && scheduleTime < endTime) ||
|
|
47530
|
+
const conflict = (scheduleTime > startTime && scheduleTime < endTime) ||
|
|
47531
|
+
(averageEnd && averageEnd > startTime && averageEnd < endTime);
|
|
47518
47532
|
if (conflict) {
|
|
47519
47533
|
conflicts.push({ matchUpId, request, scheduleTime });
|
|
47520
|
-
if (
|
|
47534
|
+
if (requestConflicts[requestId]) {
|
|
47535
|
+
if (!requestConflicts[requestId].scheduleTimes.includes(scheduleTime))
|
|
47536
|
+
requestConflicts[requestId].scheduleTimes.push(scheduleTime);
|
|
47537
|
+
if (!requestConflicts[requestId].matchUpIds.includes(matchUpId))
|
|
47538
|
+
requestConflicts[requestId].matchUpIds.push(matchUpId);
|
|
47539
|
+
}
|
|
47540
|
+
else {
|
|
47521
47541
|
requestConflicts[requestId] = {
|
|
47522
47542
|
request,
|
|
47523
47543
|
scheduleTimes: [scheduleTime],
|
|
47524
47544
|
matchUpIds: [matchUpId],
|
|
47525
47545
|
};
|
|
47526
47546
|
}
|
|
47527
|
-
else {
|
|
47528
|
-
if (!requestConflicts[requestId].scheduleTimes.includes(scheduleTime))
|
|
47529
|
-
requestConflicts[requestId].scheduleTimes.push(scheduleTime);
|
|
47530
|
-
if (!requestConflicts[requestId].matchUpIds.includes(matchUpId))
|
|
47531
|
-
requestConflicts[requestId].matchUpIds.push(matchUpId);
|
|
47532
|
-
}
|
|
47533
47547
|
}
|
|
47534
47548
|
}
|
|
47535
47549
|
return { conflicts };
|
|
@@ -48414,7 +48428,7 @@ function getEarliestCourtTime({ averageMinutes, startTime, endTime, court, date
|
|
|
48414
48428
|
const available = timeSlotMinutes >= averageMinutes;
|
|
48415
48429
|
if (available) {
|
|
48416
48430
|
const timeString = extractTime$1(consideredStartTime.toISOString());
|
|
48417
|
-
if (!first || timeString < first)
|
|
48431
|
+
if (timeString && (!first || timeString < first))
|
|
48418
48432
|
first = timeString;
|
|
48419
48433
|
}
|
|
48420
48434
|
return first;
|
|
@@ -49655,7 +49669,7 @@ function generatePersonData(params) {
|
|
|
49655
49669
|
function generatePersons(params) {
|
|
49656
49670
|
let count = params?.count || 1;
|
|
49657
49671
|
const { personExtensions, consideredDate, isMock = true, gendersCount, personData, category, sex } = params || {};
|
|
49658
|
-
if (isNaN(count))
|
|
49672
|
+
if (Number.isNaN(Number(count)))
|
|
49659
49673
|
return { error: INVALID_VALUES };
|
|
49660
49674
|
const maleCount = gendersCount?.[MALE] || (isMale(sex) && count) || 0;
|
|
49661
49675
|
const femaleCount = gendersCount?.[FEMALE] || (isFemale(sex) && count) || 0;
|
|
@@ -49695,7 +49709,7 @@ function generatePersons(params) {
|
|
|
49695
49709
|
if (person.nationalityCode &&
|
|
49696
49710
|
(typeof person.nationalityCode !== 'string' ||
|
|
49697
49711
|
person.nationalityCode.length > 3 ||
|
|
49698
|
-
!countries.
|
|
49712
|
+
!countries.some(({ iso, ioc }) => [iso, ioc].includes(person.nationalityCode))))
|
|
49699
49713
|
return false;
|
|
49700
49714
|
if (person.nationalityCode)
|
|
49701
49715
|
nationalityCodes.push(person.nationalityCode);
|
|
@@ -50403,7 +50417,9 @@ function generateOutcome(params) {
|
|
|
50403
50417
|
return { error: INVALID_VALUES };
|
|
50404
50418
|
if (defaultWithScorePercent > 100)
|
|
50405
50419
|
defaultWithScorePercent = 100;
|
|
50406
|
-
if (isNaN(defaultWithScorePercent)
|
|
50420
|
+
if (Number.isNaN(Number(defaultWithScorePercent)) ||
|
|
50421
|
+
Number.isNaN(Number(pointsPerMinute)) ||
|
|
50422
|
+
Number.isNaN(Number(sideWeight)))
|
|
50407
50423
|
return { error: INVALID_VALUES };
|
|
50408
50424
|
const matchUpStatuses = Object.keys(matchUpStatusProfile).filter((matchUpStatus) => Object.keys(matchUpStatusConstants).includes(matchUpStatus) && matchUpStatus !== COMPLETED$1);
|
|
50409
50425
|
const matchUpStatusTotals = Object.keys(matchUpStatuses).reduce((total, key) => total + matchUpStatusProfile[key], 0);
|
|
@@ -50524,9 +50540,7 @@ function generateSet({ weightedRange = [0, 1], pointsPerMinute, matchUpStatus, i
|
|
|
50524
50540
|
return { set, incomplete, winningSideNumber };
|
|
50525
50541
|
}
|
|
50526
50542
|
else {
|
|
50527
|
-
const range = generateRange(1, setTo + 1)
|
|
50528
|
-
.map((value) => generateRange(0, setTo + 2 - value).map(() => value))
|
|
50529
|
-
.flat();
|
|
50543
|
+
const range = generateRange(1, setTo + 1).flatMap((value) => generateRange(0, setTo + 2 - value).map(() => value));
|
|
50530
50544
|
const lowValue = range[randomInt(0, range.length - 1)];
|
|
50531
50545
|
const scores = setTo &&
|
|
50532
50546
|
getSetComplement({
|
|
@@ -50556,9 +50570,7 @@ function generateSet({ weightedRange = [0, 1], pointsPerMinute, matchUpStatus, i
|
|
|
50556
50570
|
let tiebreakWinningSide;
|
|
50557
50571
|
if (setAnalysis.hasTiebreakCondition || isTiebreakSet) {
|
|
50558
50572
|
const { NoAD: tiebreakNoAd, tiebreakTo } = tiebreakFormat || tiebreakSet || {};
|
|
50559
|
-
const range = generateRange(1, tiebreakTo + 1)
|
|
50560
|
-
.map((value) => generateRange(0, tiebreakTo + 2 - value).map(() => value))
|
|
50561
|
-
.flat();
|
|
50573
|
+
const range = generateRange(1, tiebreakTo + 1).flatMap((value) => generateRange(0, tiebreakTo + 2 - value).map(() => value));
|
|
50562
50574
|
const lowValue = range[randomInt(0, range.length - 1)];
|
|
50563
50575
|
const scores = getTiebreakComplement({
|
|
50564
50576
|
isSide1: true,
|