tods-competition-factory 1.8.4 → 1.8.5
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/forge/generate.mjs +32 -25
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +2 -1
- package/dist/forge/query.mjs +30 -23
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +32 -24
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +426 -418
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +616 -610
- 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 +5 -5
|
@@ -15,9 +15,8 @@ var setTypes$1 = {
|
|
|
15
15
|
function stringify(matchUpFormatObject, preserveRedundant) {
|
|
16
16
|
if (typeof matchUpFormatObject !== 'object')
|
|
17
17
|
return;
|
|
18
|
-
if (matchUpFormatObject.
|
|
19
|
-
|
|
20
|
-
if (matchUpFormatObject.bestOf && matchUpFormatObject.setFormat)
|
|
18
|
+
if ((matchUpFormatObject.bestOf || matchUpFormatObject.exactly) &&
|
|
19
|
+
matchUpFormatObject.setFormat)
|
|
21
20
|
return getSetFormat(matchUpFormatObject, preserveRedundant);
|
|
22
21
|
return undefined;
|
|
23
22
|
}
|
|
@@ -34,25 +33,27 @@ function timedSetFormat(matchUpFormatObject) {
|
|
|
34
33
|
}
|
|
35
34
|
function getSetFormat(matchUpFormatObject, preserveRedundant) {
|
|
36
35
|
var _a;
|
|
37
|
-
var bestOfValue = getNumber$1(matchUpFormatObject.bestOf);
|
|
36
|
+
var bestOfValue = getNumber$1(matchUpFormatObject.bestOf) || undefined;
|
|
37
|
+
var exactly = getNumber$1(matchUpFormatObject.exactly) || undefined;
|
|
38
|
+
var setLimit = bestOfValue || exactly;
|
|
38
39
|
if (((_a = matchUpFormatObject.setFormat) === null || _a === void 0 ? void 0 : _a.timed) &&
|
|
39
40
|
matchUpFormatObject.simplified &&
|
|
40
|
-
|
|
41
|
+
setLimit === 1) {
|
|
41
42
|
return timedSetFormat(matchUpFormatObject.setFormat);
|
|
42
43
|
}
|
|
43
|
-
var
|
|
44
|
+
var setLimitCode = (setLimit && "".concat(SET).concat(setLimit)) || '';
|
|
44
45
|
var setCountValue = stringifySet(matchUpFormatObject.setFormat, preserveRedundant);
|
|
45
46
|
var setCode = (setCountValue && "S:".concat(setCountValue)) || '';
|
|
46
47
|
var finalSetCountValue = stringifySet(matchUpFormatObject.finalSetFormat, preserveRedundant);
|
|
47
|
-
var finalSetCode = (
|
|
48
|
-
|
|
48
|
+
var finalSetCode = (setLimit &&
|
|
49
|
+
setLimit > 1 &&
|
|
49
50
|
finalSetCountValue &&
|
|
50
51
|
setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
|
|
51
52
|
"F:".concat(finalSetCountValue)) ||
|
|
52
53
|
'';
|
|
53
|
-
var valid =
|
|
54
|
+
var valid = setLimitCode && setCountValue;
|
|
54
55
|
if (valid) {
|
|
55
|
-
return [
|
|
56
|
+
return [setLimitCode, setCode, finalSetCode].filter(function (f) { return f; }).join('-');
|
|
56
57
|
}
|
|
57
58
|
return undefined;
|
|
58
59
|
}
|
|
@@ -190,181 +191,6 @@ function skewedDistribution(min, max, skew, step, significantDecimals) {
|
|
|
190
191
|
return parseFloat(num.toFixed(significantDecimals));
|
|
191
192
|
}
|
|
192
193
|
|
|
193
|
-
function parse(matchUpFormatCode) {
|
|
194
|
-
if (typeof matchUpFormatCode === 'string') {
|
|
195
|
-
var type = (matchUpFormatCode.startsWith('T') && TIMED) ||
|
|
196
|
-
(matchUpFormatCode.startsWith(SET) && SET) ||
|
|
197
|
-
'';
|
|
198
|
-
if (type === TIMED) {
|
|
199
|
-
var setFormat = parseTimedSet(matchUpFormatCode);
|
|
200
|
-
var parsedFormat = {
|
|
201
|
-
simplified: true,
|
|
202
|
-
setFormat: setFormat,
|
|
203
|
-
bestOf: 1,
|
|
204
|
-
};
|
|
205
|
-
if (parsedFormat.setFormat)
|
|
206
|
-
return parsedFormat;
|
|
207
|
-
}
|
|
208
|
-
if (type === SET)
|
|
209
|
-
return setsMatch(matchUpFormatCode);
|
|
210
|
-
}
|
|
211
|
-
return undefined;
|
|
212
|
-
}
|
|
213
|
-
function setsMatch(formatstring) {
|
|
214
|
-
var parts = formatstring.split('-');
|
|
215
|
-
var bestOf = getNumber(parts[0].slice(3));
|
|
216
|
-
var setFormat = parts && parseSetFormat(parts[1]);
|
|
217
|
-
var finalSetFormat = parts && parseSetFormat(parts[2]);
|
|
218
|
-
var validBestOf = bestOf && bestOf < 6;
|
|
219
|
-
var validFinalSet = !parts[2] || finalSetFormat;
|
|
220
|
-
var validSetsFormat = setFormat;
|
|
221
|
-
var result = { bestOf: bestOf, setFormat: setFormat };
|
|
222
|
-
if (finalSetFormat)
|
|
223
|
-
result.finalSetFormat = finalSetFormat;
|
|
224
|
-
if (validBestOf && validSetsFormat && validFinalSet)
|
|
225
|
-
return result;
|
|
226
|
-
}
|
|
227
|
-
function parseSetFormat(formatstring) {
|
|
228
|
-
if ((formatstring === null || formatstring === void 0 ? void 0 : formatstring[1]) === ':') {
|
|
229
|
-
var parts = formatstring.split(':');
|
|
230
|
-
var setType = setTypes$1[parts[0]];
|
|
231
|
-
var setFormatString = parts[1];
|
|
232
|
-
if (setType && setFormatString) {
|
|
233
|
-
var isTiebreakSet = setFormatString.indexOf('TB') === 0;
|
|
234
|
-
if (isTiebreakSet) {
|
|
235
|
-
var tiebreakSet = parseTiebreakFormat(setFormatString);
|
|
236
|
-
if (tiebreakSet === false)
|
|
237
|
-
return false;
|
|
238
|
-
return typeof tiebreakSet === 'object' ? { tiebreakSet: tiebreakSet } : undefined;
|
|
239
|
-
}
|
|
240
|
-
var timedSet = setFormatString.indexOf('T') === 0;
|
|
241
|
-
if (timedSet)
|
|
242
|
-
return parseTimedSet(setFormatString);
|
|
243
|
-
var parts_1 = formatstring.match(/^[FS]:(\d+)([A-Za-z]*)/);
|
|
244
|
-
var NoAD = (parts_1 && isNoAD(parts_1[2])) || false;
|
|
245
|
-
var validNoAD = !(parts_1 === null || parts_1 === void 0 ? void 0 : parts_1[2]) || NoAD;
|
|
246
|
-
var setTo = parts_1 ? getNumber(parts_1[1]) : undefined;
|
|
247
|
-
var tiebreakAtValue = parseTiebreakAt(setFormatString);
|
|
248
|
-
var validTiebreakAt = tiebreakAtValue !== false;
|
|
249
|
-
var tiebreakAt = (validTiebreakAt && tiebreakAtValue) || setTo;
|
|
250
|
-
var tiebreakFormat = parseTiebreakFormat(setFormatString.split('/')[1]);
|
|
251
|
-
var validTiebreak = tiebreakFormat !== false;
|
|
252
|
-
var result = { setTo: setTo };
|
|
253
|
-
if (NoAD)
|
|
254
|
-
result.NoAD = true;
|
|
255
|
-
if (tiebreakFormat) {
|
|
256
|
-
result.tiebreakFormat = tiebreakFormat;
|
|
257
|
-
result.tiebreakAt = tiebreakAt;
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
result.noTiebreak = true;
|
|
261
|
-
}
|
|
262
|
-
return ((setTo && validNoAD && validTiebreak && validTiebreakAt && result) ||
|
|
263
|
-
false);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return undefined;
|
|
267
|
-
}
|
|
268
|
-
function parseTiebreakAt(setFormatString, expectNumber) {
|
|
269
|
-
if (expectNumber === void 0) { expectNumber = true; }
|
|
270
|
-
var tiebreakAtValue = (setFormatString === null || setFormatString === void 0 ? void 0 : setFormatString.indexOf('@')) > 0 && setFormatString.split('@');
|
|
271
|
-
if (tiebreakAtValue) {
|
|
272
|
-
var tiebreakAt = expectNumber
|
|
273
|
-
? getNumber(tiebreakAtValue[1])
|
|
274
|
-
: tiebreakAtValue[1];
|
|
275
|
-
return tiebreakAt || false;
|
|
276
|
-
}
|
|
277
|
-
return undefined;
|
|
278
|
-
}
|
|
279
|
-
function parseTiebreakFormat(formatstring) {
|
|
280
|
-
if (formatstring) {
|
|
281
|
-
if (formatstring.startsWith('TB')) {
|
|
282
|
-
var modifier = parseTiebreakAt(formatstring, false);
|
|
283
|
-
var parts = formatstring.match(/^TB(\d+)([A-Za-z]*)/);
|
|
284
|
-
var tiebreakToString = parts === null || parts === void 0 ? void 0 : parts[1];
|
|
285
|
-
var NoAD = parts && isNoAD(parts[2]);
|
|
286
|
-
var validNoAD = !(parts === null || parts === void 0 ? void 0 : parts[2]) || NoAD;
|
|
287
|
-
var tiebreakTo = getNumber(tiebreakToString);
|
|
288
|
-
if (tiebreakTo && validNoAD) {
|
|
289
|
-
var result = { tiebreakTo: tiebreakTo };
|
|
290
|
-
// modifiers cannot be numeric
|
|
291
|
-
if (modifier &&
|
|
292
|
-
typeof modifier === 'string' &&
|
|
293
|
-
!isConvertableInteger(modifier)) {
|
|
294
|
-
result.modifier = modifier;
|
|
295
|
-
}
|
|
296
|
-
if (NoAD)
|
|
297
|
-
result.NoAD = true;
|
|
298
|
-
return result;
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return undefined;
|
|
309
|
-
}
|
|
310
|
-
function parseTimedSet(formatstring) {
|
|
311
|
-
var _a;
|
|
312
|
-
var timestring = formatstring.slice(1);
|
|
313
|
-
var parts = timestring.match(/^(\d+)(@?[A-Za-z]*)/);
|
|
314
|
-
var minutes = getNumber(parts === null || parts === void 0 ? void 0 : parts[1]);
|
|
315
|
-
if (!minutes)
|
|
316
|
-
return;
|
|
317
|
-
var setFormat = { timed: true, minutes: minutes };
|
|
318
|
-
var based = parts === null || parts === void 0 ? void 0 : parts[2];
|
|
319
|
-
var validModifier = [undefined, 'P', 'G'].includes(based);
|
|
320
|
-
if (based && !validModifier) {
|
|
321
|
-
var modifier = (_a = timestring.match(/^(\d+)(@)([A-Za-z]+)$/)) === null || _a === void 0 ? void 0 : _a[3];
|
|
322
|
-
if (modifier) {
|
|
323
|
-
setFormat.modifier = modifier;
|
|
324
|
-
return setFormat;
|
|
325
|
-
}
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
if (based)
|
|
329
|
-
setFormat.based = parts[2];
|
|
330
|
-
return setFormat;
|
|
331
|
-
}
|
|
332
|
-
function isNoAD(formatstring) {
|
|
333
|
-
return formatstring && formatstring.indexOf(NOAD) >= 0;
|
|
334
|
-
}
|
|
335
|
-
function getNumber(formatstring) {
|
|
336
|
-
return !isNaN(Number(formatstring)) ? Number(formatstring) : 0;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function isValid(matchUpFormat) {
|
|
340
|
-
if (typeof matchUpFormat !== 'string')
|
|
341
|
-
return false;
|
|
342
|
-
var parsedFormat = parse(matchUpFormat);
|
|
343
|
-
var setParts = matchUpFormat.match(/-S:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
344
|
-
var setsTo = setParts === null || setParts === void 0 ? void 0 : setParts[1];
|
|
345
|
-
var tiebreakTo = setParts === null || setParts === void 0 ? void 0 : setParts[2];
|
|
346
|
-
var tiebreakAt = setParts === null || setParts === void 0 ? void 0 : setParts[3];
|
|
347
|
-
var finalSetParts = matchUpFormat.match(/-F:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
348
|
-
var finalSetTo = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[1];
|
|
349
|
-
var finalSetTiebreakTo = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[2];
|
|
350
|
-
var finalTiebreakAt = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[3];
|
|
351
|
-
var preserveRedundant = !!((setParts && tiebreakTo && setsTo === tiebreakAt) ||
|
|
352
|
-
(finalSetParts && finalSetTiebreakTo && finalSetTo === finalTiebreakAt));
|
|
353
|
-
var stringified = stringify(parsedFormat, preserveRedundant);
|
|
354
|
-
return stringified === matchUpFormat;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
var matchUpFormatCode = {
|
|
358
|
-
isValidMatchUpFormat: isValid,
|
|
359
|
-
stringify: stringify,
|
|
360
|
-
isValid: isValid,
|
|
361
|
-
parse: parse,
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
function factoryVersion() {
|
|
365
|
-
return '1.8.4';
|
|
366
|
-
}
|
|
367
|
-
|
|
368
194
|
/******************************************************************************
|
|
369
195
|
Copyright (c) Microsoft Corporation.
|
|
370
196
|
|
|
@@ -566,65 +392,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
566
392
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
567
393
|
};
|
|
568
394
|
|
|
569
|
-
function getObjectTieFormat(obj) {
|
|
570
|
-
if (!obj)
|
|
571
|
-
return;
|
|
572
|
-
var tieFormatId = obj.tieFormatId, tieFormats = obj.tieFormats;
|
|
573
|
-
if (obj.tieFormat) {
|
|
574
|
-
return obj.tieFormat;
|
|
575
|
-
}
|
|
576
|
-
else if (tieFormatId && Array.isArray(tieFormats)) {
|
|
577
|
-
return tieFormats.find(function (tf) { return tf.tieFormatId === tieFormatId; });
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
function getItemTieFormat(_a) {
|
|
582
|
-
var _b, _c, _d;
|
|
583
|
-
var item = _a.item, drawDefinition = _a.drawDefinition, structure = _a.structure, event = _a.event;
|
|
584
|
-
if (!item)
|
|
585
|
-
return;
|
|
586
|
-
if (item.tieFormat)
|
|
587
|
-
return item.tieFormat;
|
|
588
|
-
// if there is a tieFormatId, only possible to look for referenced tieFormat in tieFormats on drawDefinition and event
|
|
589
|
-
if (item.tieFormatId) {
|
|
590
|
-
if (drawDefinition.tieFormat)
|
|
591
|
-
return drawDefinition.tieFormat;
|
|
592
|
-
var tieFormat = (_b = drawDefinition.tieFormats) === null || _b === void 0 ? void 0 : _b.find(function (tf) { return item.tieFormatId === tf.tieFormatId; });
|
|
593
|
-
if (tieFormat)
|
|
594
|
-
return tieFormat;
|
|
595
|
-
if (event.tieFormat)
|
|
596
|
-
return event.tieFormat;
|
|
597
|
-
return (_c = event.tieFormats) === null || _c === void 0 ? void 0 : _c.find(function (tf) { return item.tieFormatId === tf.tieFormatId; });
|
|
598
|
-
}
|
|
599
|
-
if (structure.tieFormat)
|
|
600
|
-
return structure.tieFormat;
|
|
601
|
-
if (structure.tieFormatId) {
|
|
602
|
-
var structureTieFormat = (_d = drawDefinition.tieFormats) === null || _d === void 0 ? void 0 : _d.find(function (tf) { return structure.tieFormatId === tf.tieFormatId; });
|
|
603
|
-
if (structureTieFormat)
|
|
604
|
-
return structureTieFormat;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
function resolveTieFormat(_a) {
|
|
609
|
-
var drawDefinition = _a.drawDefinition, structure = _a.structure, matchUp = _a.matchUp, event = _a.event;
|
|
610
|
-
return {
|
|
611
|
-
tieFormat: getItemTieFormat({
|
|
612
|
-
item: matchUp,
|
|
613
|
-
drawDefinition: drawDefinition,
|
|
614
|
-
structure: structure,
|
|
615
|
-
event: event,
|
|
616
|
-
}) ||
|
|
617
|
-
getItemTieFormat({
|
|
618
|
-
item: structure,
|
|
619
|
-
drawDefinition: drawDefinition,
|
|
620
|
-
structure: structure,
|
|
621
|
-
event: event,
|
|
622
|
-
}) ||
|
|
623
|
-
getObjectTieFormat(drawDefinition) ||
|
|
624
|
-
getObjectTieFormat(event),
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
|
|
628
395
|
// returns only unique values within an array
|
|
629
396
|
function unique(arr) {
|
|
630
397
|
return arr.filter(function (item, i, s) { return s.lastIndexOf(item) === i; });
|
|
@@ -2637,6 +2404,562 @@ function generateHashCode(o) {
|
|
|
2637
2404
|
return [str.length, keyCount, charSum].map(function (e) { return e.toString(36); }).join('');
|
|
2638
2405
|
}
|
|
2639
2406
|
|
|
2407
|
+
// NOTE: type really does need to be any!
|
|
2408
|
+
function attributeFilter(params) {
|
|
2409
|
+
if (params === null)
|
|
2410
|
+
return {};
|
|
2411
|
+
var _a = params || {}, source = _a.source, template = _a.template;
|
|
2412
|
+
if (!template)
|
|
2413
|
+
return source;
|
|
2414
|
+
var target = {};
|
|
2415
|
+
attributeCopy(source, template, target);
|
|
2416
|
+
return target;
|
|
2417
|
+
function attributeCopy(valuesObject, templateObject, outputObject) {
|
|
2418
|
+
var e_1, _a;
|
|
2419
|
+
if (!valuesObject || !templateObject)
|
|
2420
|
+
return undefined;
|
|
2421
|
+
var vKeys = Object.keys(valuesObject);
|
|
2422
|
+
var oKeys = Object.keys(templateObject);
|
|
2423
|
+
// the orMap allows spcification of { 'a||b': boolean } so that filter templates can apply to multiple attributes
|
|
2424
|
+
var orMap = Object.assign.apply(Object, __spreadArray([{}], __read(oKeys
|
|
2425
|
+
.filter(function (key) { return key.indexOf('||'); })
|
|
2426
|
+
.map(function (key) { return key.split('||').map(function (or) {
|
|
2427
|
+
var _a;
|
|
2428
|
+
return (_a = {}, _a[or] = key, _a);
|
|
2429
|
+
}); })
|
|
2430
|
+
.flat()), false));
|
|
2431
|
+
var allKeys = oKeys.concat.apply(oKeys, __spreadArray([], __read(Object.keys(orMap)), false));
|
|
2432
|
+
var wildcard = allKeys.includes('*');
|
|
2433
|
+
var _loop_1 = function (vKey) {
|
|
2434
|
+
if (allKeys.indexOf(vKey) >= 0 || wildcard) {
|
|
2435
|
+
var templateKey = orMap[vKey] || vKey;
|
|
2436
|
+
var tobj_1 = templateObject[templateKey] || wildcard;
|
|
2437
|
+
var vobj = valuesObject[vKey];
|
|
2438
|
+
if (typeof tobj_1 === 'object' &&
|
|
2439
|
+
typeof vobj !== 'function' &&
|
|
2440
|
+
!Array.isArray(tobj_1)) {
|
|
2441
|
+
if (Array.isArray(vobj)) {
|
|
2442
|
+
var mappedElements = vobj
|
|
2443
|
+
.map(function (arrayMember) {
|
|
2444
|
+
var target = {};
|
|
2445
|
+
var result = attributeCopy(arrayMember, tobj_1, target);
|
|
2446
|
+
return result !== false ? target : undefined;
|
|
2447
|
+
})
|
|
2448
|
+
.filter(Boolean);
|
|
2449
|
+
outputObject[vKey] = mappedElements;
|
|
2450
|
+
}
|
|
2451
|
+
else if (vobj) {
|
|
2452
|
+
outputObject[vKey] = {};
|
|
2453
|
+
attributeCopy(vobj, tobj_1, outputObject[vKey]);
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
else {
|
|
2457
|
+
var value = valuesObject[vKey];
|
|
2458
|
+
var exclude = Array.isArray(tobj_1) && !tobj_1.includes(value);
|
|
2459
|
+
if (exclude)
|
|
2460
|
+
return { value: false };
|
|
2461
|
+
if (templateObject[vKey] ||
|
|
2462
|
+
(wildcard && templateObject[vKey] !== false)) {
|
|
2463
|
+
outputObject[vKey] = value;
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
}
|
|
2467
|
+
};
|
|
2468
|
+
try {
|
|
2469
|
+
for (var vKeys_1 = __values(vKeys), vKeys_1_1 = vKeys_1.next(); !vKeys_1_1.done; vKeys_1_1 = vKeys_1.next()) {
|
|
2470
|
+
var vKey = vKeys_1_1.value;
|
|
2471
|
+
var state_1 = _loop_1(vKey);
|
|
2472
|
+
if (typeof state_1 === "object")
|
|
2473
|
+
return state_1.value;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2477
|
+
finally {
|
|
2478
|
+
try {
|
|
2479
|
+
if (vKeys_1_1 && !vKeys_1_1.done && (_a = vKeys_1.return)) _a.call(vKeys_1);
|
|
2480
|
+
}
|
|
2481
|
+
finally { if (e_1) throw e_1.error; }
|
|
2482
|
+
}
|
|
2483
|
+
return undefined;
|
|
2484
|
+
}
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2487
|
+
function generateTimeCode(index) {
|
|
2488
|
+
if (index === void 0) { index = 0; }
|
|
2489
|
+
var uidate = new Date();
|
|
2490
|
+
uidate.setHours(uidate.getHours() + index);
|
|
2491
|
+
return uidate.getTime().toString(36).slice(-6).toUpperCase();
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
function numericSort(a, b) {
|
|
2495
|
+
return a - b;
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
/**
|
|
2499
|
+
*
|
|
2500
|
+
* @param {object[]} arrayOfJSON - JSON objects array
|
|
2501
|
+
* @param {object} config - object which configures processing (see below)
|
|
2502
|
+
* @returns {string} - joined by '\r\n' or specified line separator
|
|
2503
|
+
*
|
|
2504
|
+
* config {
|
|
2505
|
+
* {boolean} includeTransformAccessors, // transform accessors are included with columnAccessors
|
|
2506
|
+
* {string[]} columnAccessors, // [ 'includeThis', 'andThis' ]
|
|
2507
|
+
* {object} columnTransform, // e.g. { 'newColumnName': ['oldColumn1', 'oldColumn2' ]}
|
|
2508
|
+
* {object} columnMap, // e.g. { 'columnName': 'newColumnName' }
|
|
2509
|
+
* {object} valuesMap, // e.g. { 'columnName': { 'value1': 'mappedValue' }} // useful for mapping IDs
|
|
2510
|
+
* {array} sortOrder // e.g. ['columnName1', 'columnName2'] // determine order of csv columns
|
|
2511
|
+
* {object} context, // attributes which are to be added to all rows { 'columnName': 'value }
|
|
2512
|
+
* {string} delimiter, // defaults to '"'
|
|
2513
|
+
* {string} columnJoiner, // defaults to ',' // defines how CSV columns are joined
|
|
2514
|
+
* {string} rowJoiner, // defaults to '\r\n' // defines how CSV lines are joined
|
|
2515
|
+
* {string} keyJoiner, // defaults to '.' // defines how flattened column names are constructed
|
|
2516
|
+
* }
|
|
2517
|
+
*
|
|
2518
|
+
* NOTE: `columnTransform` mapped array elements are sensitive to order and will resolve to the first matching value
|
|
2519
|
+
* NOTE: `columnMap` should not contain new columnName(s) that are `columnTransform` keys
|
|
2520
|
+
*/
|
|
2521
|
+
function JSON2CSV(arrayOfJSON, config) {
|
|
2522
|
+
if (config && typeof config !== 'object')
|
|
2523
|
+
return INVALID_VALUES;
|
|
2524
|
+
var _a = (config || {}).columnTransform, columnTransform = _a === void 0 ? {} : _a;
|
|
2525
|
+
var _b = config || {}, includeTransformAccessors = _b.includeTransformAccessors, _c = _b.includeHeaderRow, includeHeaderRow = _c === void 0 ? true : _c, returnTransformedJSON = _b.returnTransformedJSON, removeEmptyColumns = _b.removeEmptyColumns, onlyHeaderRow = _b.onlyHeaderRow, _d = _b.columnAccessors, columnAccessors = _d === void 0 ? [] : _d, _e = _b.functionMap, functionMap = _e === void 0 ? {} : _e, _f = _b.columnMap, columnMap = _f === void 0 ? {} : _f, _g = _b.valuesMap, valuesMap = _g === void 0 ? {} : _g, _h = _b.context, context = _h === void 0 ? {} : _h, _j = _b.delimiter, delimiter = _j === void 0 ? '"' : _j, _k = _b.columnJoiner, columnJoiner = _k === void 0 ? ',' : _k, _l = _b.rowJoiner, rowJoiner = _l === void 0 ? '\r\n' : _l, _m = _b.keyJoiner, keyJoiner = _m === void 0 ? '.' : _m;
|
|
2526
|
+
if (!Array.isArray(arrayOfJSON) ||
|
|
2527
|
+
!Array.isArray(columnAccessors) ||
|
|
2528
|
+
typeof context !== 'object' ||
|
|
2529
|
+
typeof columnMap !== 'object' ||
|
|
2530
|
+
typeof columnTransform !== 'object' ||
|
|
2531
|
+
typeof functionMap !== 'object' ||
|
|
2532
|
+
typeof valuesMap !== 'object' ||
|
|
2533
|
+
typeof columnJoiner !== 'string' ||
|
|
2534
|
+
typeof rowJoiner !== 'string' ||
|
|
2535
|
+
typeof keyJoiner !== 'string' ||
|
|
2536
|
+
typeof delimiter !== 'string')
|
|
2537
|
+
return INVALID_VALUES;
|
|
2538
|
+
// ensure all column transformers are arrays
|
|
2539
|
+
columnTransform = Object.assign.apply(Object, __spreadArray([{}], __read(Object.keys(columnTransform)
|
|
2540
|
+
.reverse() // reverse so that exported CSV columns are in the order as defined
|
|
2541
|
+
.map(function (key) {
|
|
2542
|
+
var _a;
|
|
2543
|
+
return (_a = {},
|
|
2544
|
+
_a[key] = Array.isArray(columnTransform[key])
|
|
2545
|
+
? columnTransform[key]
|
|
2546
|
+
: [
|
|
2547
|
+
// ensure transform attributes are strings
|
|
2548
|
+
typeof columnTransform[key] === 'string' && columnTransform[key],
|
|
2549
|
+
].filter(Boolean),
|
|
2550
|
+
_a);
|
|
2551
|
+
})), false));
|
|
2552
|
+
var flattened = arrayOfJSON
|
|
2553
|
+
.filter(Boolean)
|
|
2554
|
+
.map(function (obj) { return flattenJSON(obj, keyJoiner); });
|
|
2555
|
+
var transformColumns = Object.values(columnTransform).flat();
|
|
2556
|
+
if (includeTransformAccessors)
|
|
2557
|
+
columnAccessors.push.apply(columnAccessors, __spreadArray([], __read(transformColumns), false));
|
|
2558
|
+
var headerRow = flattened
|
|
2559
|
+
.reduce(function (aggregator, row) {
|
|
2560
|
+
return Object.keys(row).every(function (key) { return (!aggregator.includes(key) && aggregator.push(key)) || true; }) && aggregator;
|
|
2561
|
+
}, [])
|
|
2562
|
+
.filter(function (key) { return !(columnAccessors === null || columnAccessors === void 0 ? void 0 : columnAccessors.length) || columnAccessors.includes(key); });
|
|
2563
|
+
var accessorMap = Object.assign.apply(Object, __spreadArray([{}], __read(Object.keys(columnTransform)
|
|
2564
|
+
.reverse() // so that original order is preserved when later pushed
|
|
2565
|
+
.map(function (transform) {
|
|
2566
|
+
return columnTransform[transform]
|
|
2567
|
+
.map(function (value) {
|
|
2568
|
+
var _a;
|
|
2569
|
+
return (_a = {}, _a[value] = transform, _a);
|
|
2570
|
+
})
|
|
2571
|
+
.flat();
|
|
2572
|
+
})
|
|
2573
|
+
.flat()), false));
|
|
2574
|
+
var sortColumns = function (a, b) {
|
|
2575
|
+
return !(config === null || config === void 0 ? void 0 : config.sortOrder)
|
|
2576
|
+
? 0
|
|
2577
|
+
: (config.sortOrder.includes(a) &&
|
|
2578
|
+
config.sortOrder.includes(b) &&
|
|
2579
|
+
config.sortOrder.indexOf(a) - config.sortOrder.indexOf(b)) ||
|
|
2580
|
+
(!config.sortOrder.includes(b) && -1);
|
|
2581
|
+
};
|
|
2582
|
+
var tranformedHeaderRow = headerRow
|
|
2583
|
+
.reduce(function (def, key) {
|
|
2584
|
+
var transform = accessorMap[key];
|
|
2585
|
+
if (transform) {
|
|
2586
|
+
if (!def.includes(transform))
|
|
2587
|
+
def.push(transform);
|
|
2588
|
+
}
|
|
2589
|
+
else {
|
|
2590
|
+
def.push(key);
|
|
2591
|
+
}
|
|
2592
|
+
return def;
|
|
2593
|
+
}, [])
|
|
2594
|
+
.sort(sortColumns);
|
|
2595
|
+
Object.keys(columnMap).forEach(function (columnName) {
|
|
2596
|
+
return !tranformedHeaderRow.includes(columnName) &&
|
|
2597
|
+
tranformedHeaderRow.unshift(columnName);
|
|
2598
|
+
});
|
|
2599
|
+
Object.keys(columnTransform).forEach(function (columnName) {
|
|
2600
|
+
return !tranformedHeaderRow.includes(columnName) &&
|
|
2601
|
+
tranformedHeaderRow.unshift(columnName);
|
|
2602
|
+
});
|
|
2603
|
+
typeof context === 'object' &&
|
|
2604
|
+
Object.keys(context).forEach(function (columnName) {
|
|
2605
|
+
return !tranformedHeaderRow.includes(columnName) &&
|
|
2606
|
+
tranformedHeaderRow.unshift(columnName);
|
|
2607
|
+
});
|
|
2608
|
+
var mappedHeaderRow = tranformedHeaderRow.map(function (key) { return columnMap[key] || key; });
|
|
2609
|
+
if (onlyHeaderRow)
|
|
2610
|
+
return [mappedHeaderRow];
|
|
2611
|
+
var withDelimiter = function (value) { return "".concat(delimiter).concat(value).concat(delimiter); };
|
|
2612
|
+
var columnValueCounts = [];
|
|
2613
|
+
var processRow = function (row) {
|
|
2614
|
+
return Object.values(tranformedHeaderRow.reduce(function (columnsMap, columnName, columnIndex) {
|
|
2615
|
+
var _a;
|
|
2616
|
+
var accessors = columnTransform[columnName];
|
|
2617
|
+
var value = ((accessors === null || accessors === void 0 ? void 0 : accessors.length)
|
|
2618
|
+
? row[accessors.find(function (accessor) { return row[accessor]; })]
|
|
2619
|
+
: row[columnName]) ||
|
|
2620
|
+
(context === null || context === void 0 ? void 0 : context[columnName]) ||
|
|
2621
|
+
'';
|
|
2622
|
+
var mappedValue = ((_a = valuesMap[columnName]) === null || _a === void 0 ? void 0 : _a[value]) || value;
|
|
2623
|
+
var fxValue = typeof functionMap[columnName] === 'function'
|
|
2624
|
+
? functionMap[columnName](mappedValue)
|
|
2625
|
+
: mappedValue;
|
|
2626
|
+
columnsMap[columnName] = withDelimiter(fxValue);
|
|
2627
|
+
if (fxValue) {
|
|
2628
|
+
columnValueCounts[columnIndex] =
|
|
2629
|
+
(columnValueCounts[columnIndex] || 0) + 1;
|
|
2630
|
+
}
|
|
2631
|
+
return columnsMap;
|
|
2632
|
+
}, {}));
|
|
2633
|
+
};
|
|
2634
|
+
var flattenedRows = flattened.map(processRow);
|
|
2635
|
+
var indicesToRemove = removeEmptyColumns &&
|
|
2636
|
+
__spreadArray([], __read(columnValueCounts), false).map(function (count, index) { return !count && index; })
|
|
2637
|
+
.filter(isNumeric)
|
|
2638
|
+
.reverse();
|
|
2639
|
+
if (indicesToRemove) {
|
|
2640
|
+
var purge = function (row) {
|
|
2641
|
+
return row.filter(function (_, index) { return !indicesToRemove.includes(index); });
|
|
2642
|
+
};
|
|
2643
|
+
flattenedRows = flattenedRows.map(purge);
|
|
2644
|
+
mappedHeaderRow = purge(mappedHeaderRow);
|
|
2645
|
+
}
|
|
2646
|
+
var rows = flattenedRows.map(function (row) { return row.join(columnJoiner); });
|
|
2647
|
+
if (returnTransformedJSON) {
|
|
2648
|
+
return rows.map(function (row) {
|
|
2649
|
+
var columnValues = row.split(columnJoiner);
|
|
2650
|
+
return Object.assign.apply(Object, __spreadArray([{}], __read(columnValues.map(function (v, i) {
|
|
2651
|
+
var _a;
|
|
2652
|
+
return (_a = {}, _a[mappedHeaderRow[i]] = v, _a);
|
|
2653
|
+
})), false));
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
return includeHeaderRow
|
|
2657
|
+
? __spreadArray([mappedHeaderRow.map(withDelimiter).join(columnJoiner)], __read(rows), false).join(rowJoiner)
|
|
2658
|
+
: rows.join(rowJoiner);
|
|
2659
|
+
}
|
|
2660
|
+
function flattenJSON(obj, keyJoiner, path) {
|
|
2661
|
+
if (keyJoiner === void 0) { keyJoiner = '.'; }
|
|
2662
|
+
if (path === void 0) { path = []; }
|
|
2663
|
+
return (typeof obj === 'object' &&
|
|
2664
|
+
Object.keys(obj).reduce(function (result, key) {
|
|
2665
|
+
if (typeof obj[key] !== 'object') {
|
|
2666
|
+
result[path.concat(key).join(keyJoiner)] = obj[key];
|
|
2667
|
+
return result;
|
|
2668
|
+
}
|
|
2669
|
+
return Object.assign(result, flattenJSON(obj[key], keyJoiner, path.concat(key)));
|
|
2670
|
+
}, {}));
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
/*
|
|
2674
|
+
based on an answer provided by Jeff Ward on StackOverflow; November 2019
|
|
2675
|
+
https://stackoverflow.com/users/1026023/jeff-ward
|
|
2676
|
+
https://stackoverflow.com/questions/105034/how-to-create-guid-uuid?rq=1
|
|
2677
|
+
*/
|
|
2678
|
+
/**
|
|
2679
|
+
* generate a given number of UUIDs
|
|
2680
|
+
*
|
|
2681
|
+
* @param {number} count - number of UUIDs to generate
|
|
2682
|
+
*/
|
|
2683
|
+
function UUIDS(count) {
|
|
2684
|
+
if (count === void 0) { count = 1; }
|
|
2685
|
+
return generateRange(0, count).map(UUID);
|
|
2686
|
+
}
|
|
2687
|
+
function UUID() {
|
|
2688
|
+
var lut = [];
|
|
2689
|
+
for (var i = 0; i < 256; i++) {
|
|
2690
|
+
lut[i] = (i < 16 ? '0' : '') + i.toString(16);
|
|
2691
|
+
}
|
|
2692
|
+
var d0 = (Math.random() * 0xffffffff) | 0;
|
|
2693
|
+
var d1 = (Math.random() * 0xffffffff) | 0;
|
|
2694
|
+
var d2 = (Math.random() * 0xffffffff) | 0;
|
|
2695
|
+
var d3 = (Math.random() * 0xffffffff) | 0;
|
|
2696
|
+
// eslint-disable-next-line no-mixed-operators
|
|
2697
|
+
return (lut[d0 & 0xff] +
|
|
2698
|
+
lut[(d0 >> 8) & 0xff] +
|
|
2699
|
+
lut[(d0 >> 16) & 0xff] +
|
|
2700
|
+
lut[(d0 >> 24) & 0xff] +
|
|
2701
|
+
'-' +
|
|
2702
|
+
// eslint-disable-next-line no-mixed-operators
|
|
2703
|
+
lut[d1 & 0xff] +
|
|
2704
|
+
lut[(d1 >> 8) & 0xff] +
|
|
2705
|
+
'-' +
|
|
2706
|
+
lut[((d1 >> 16) & 0x0f) | 0x40] +
|
|
2707
|
+
lut[(d1 >> 24) & 0xff] +
|
|
2708
|
+
'-' +
|
|
2709
|
+
// eslint-disable-next-line no-mixed-operators
|
|
2710
|
+
lut[(d2 & 0x3f) | 0x80] +
|
|
2711
|
+
lut[(d2 >> 8) & 0xff] +
|
|
2712
|
+
'-' +
|
|
2713
|
+
lut[(d2 >> 16) & 0xff] +
|
|
2714
|
+
lut[(d2 >> 24) & 0xff] +
|
|
2715
|
+
// eslint-disable-next-line no-mixed-operators
|
|
2716
|
+
lut[d3 & 0xff] +
|
|
2717
|
+
lut[(d3 >> 8) & 0xff] +
|
|
2718
|
+
lut[(d3 >> 16) & 0xff] +
|
|
2719
|
+
lut[(d3 >> 24) & 0xff]);
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
function parse(matchUpFormatCode) {
|
|
2723
|
+
if (typeof matchUpFormatCode === 'string') {
|
|
2724
|
+
var type = (matchUpFormatCode.startsWith('T') && TIMED) ||
|
|
2725
|
+
(matchUpFormatCode.startsWith(SET) && SET) ||
|
|
2726
|
+
'';
|
|
2727
|
+
if (type === TIMED) {
|
|
2728
|
+
var setFormat = parseTimedSet(matchUpFormatCode);
|
|
2729
|
+
var parsedFormat = {
|
|
2730
|
+
simplified: true,
|
|
2731
|
+
setFormat: setFormat,
|
|
2732
|
+
bestOf: 1,
|
|
2733
|
+
};
|
|
2734
|
+
if (setFormat)
|
|
2735
|
+
return parsedFormat;
|
|
2736
|
+
}
|
|
2737
|
+
if (type === SET)
|
|
2738
|
+
return setsMatch(matchUpFormatCode);
|
|
2739
|
+
}
|
|
2740
|
+
return undefined;
|
|
2741
|
+
}
|
|
2742
|
+
function setsMatch(formatstring) {
|
|
2743
|
+
var parts = formatstring.split('-');
|
|
2744
|
+
var setsCount = getNumber(parts[0].slice(3));
|
|
2745
|
+
var bestOf = setsCount === 1 || setsCount % 2 !== 0 ? setsCount : undefined;
|
|
2746
|
+
var exactly = setsCount !== 1 && setsCount % 2 === 0 ? setsCount : undefined;
|
|
2747
|
+
var setFormat = parts && parseSetFormat(parts[1]);
|
|
2748
|
+
var finalSetFormat = parts && parseSetFormat(parts[2]);
|
|
2749
|
+
var timed = (setFormat && setFormat.timed) || (finalSetFormat && finalSetFormat.timed);
|
|
2750
|
+
var validSetsCount = (bestOf && bestOf < 6) || (timed && exactly);
|
|
2751
|
+
var validFinalSet = !parts[2] || finalSetFormat;
|
|
2752
|
+
var validSetsFormat = setFormat;
|
|
2753
|
+
var result = definedAttributes({
|
|
2754
|
+
setFormat: setFormat,
|
|
2755
|
+
exactly: exactly,
|
|
2756
|
+
bestOf: bestOf,
|
|
2757
|
+
});
|
|
2758
|
+
if (finalSetFormat)
|
|
2759
|
+
result.finalSetFormat = finalSetFormat;
|
|
2760
|
+
if (validSetsCount && validSetsFormat && validFinalSet)
|
|
2761
|
+
return result;
|
|
2762
|
+
}
|
|
2763
|
+
function parseSetFormat(formatstring) {
|
|
2764
|
+
if ((formatstring === null || formatstring === void 0 ? void 0 : formatstring[1]) === ':') {
|
|
2765
|
+
var parts = formatstring.split(':');
|
|
2766
|
+
var setType = setTypes$1[parts[0]];
|
|
2767
|
+
var setFormatString = parts[1];
|
|
2768
|
+
if (setType && setFormatString) {
|
|
2769
|
+
var isTiebreakSet = setFormatString.indexOf('TB') === 0;
|
|
2770
|
+
if (isTiebreakSet) {
|
|
2771
|
+
var tiebreakSet = parseTiebreakFormat(setFormatString);
|
|
2772
|
+
if (tiebreakSet === false)
|
|
2773
|
+
return false;
|
|
2774
|
+
return typeof tiebreakSet === 'object' ? { tiebreakSet: tiebreakSet } : undefined;
|
|
2775
|
+
}
|
|
2776
|
+
var timedSet = setFormatString.indexOf('T') === 0;
|
|
2777
|
+
if (timedSet)
|
|
2778
|
+
return parseTimedSet(setFormatString);
|
|
2779
|
+
var parts_1 = formatstring.match(/^[FS]:(\d+)([A-Za-z]*)/);
|
|
2780
|
+
var NoAD = (parts_1 && isNoAD(parts_1[2])) || false;
|
|
2781
|
+
var validNoAD = !(parts_1 === null || parts_1 === void 0 ? void 0 : parts_1[2]) || NoAD;
|
|
2782
|
+
var setTo = parts_1 ? getNumber(parts_1[1]) : undefined;
|
|
2783
|
+
var tiebreakAtValue = parseTiebreakAt(setFormatString);
|
|
2784
|
+
var validTiebreakAt = tiebreakAtValue !== false;
|
|
2785
|
+
var tiebreakAt = (validTiebreakAt && tiebreakAtValue) || setTo;
|
|
2786
|
+
var tiebreakFormat = parseTiebreakFormat(setFormatString.split('/')[1]);
|
|
2787
|
+
var validTiebreak = tiebreakFormat !== false;
|
|
2788
|
+
var result = { setTo: setTo };
|
|
2789
|
+
if (NoAD)
|
|
2790
|
+
result.NoAD = true;
|
|
2791
|
+
if (tiebreakFormat) {
|
|
2792
|
+
result.tiebreakFormat = tiebreakFormat;
|
|
2793
|
+
result.tiebreakAt = tiebreakAt;
|
|
2794
|
+
}
|
|
2795
|
+
else {
|
|
2796
|
+
result.noTiebreak = true;
|
|
2797
|
+
}
|
|
2798
|
+
return ((setTo && validNoAD && validTiebreak && validTiebreakAt && result) ||
|
|
2799
|
+
false);
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
return undefined;
|
|
2803
|
+
}
|
|
2804
|
+
function parseTiebreakAt(setFormatString, expectNumber) {
|
|
2805
|
+
if (expectNumber === void 0) { expectNumber = true; }
|
|
2806
|
+
var tiebreakAtValue = (setFormatString === null || setFormatString === void 0 ? void 0 : setFormatString.indexOf('@')) > 0 && setFormatString.split('@');
|
|
2807
|
+
if (tiebreakAtValue) {
|
|
2808
|
+
var tiebreakAt = expectNumber
|
|
2809
|
+
? getNumber(tiebreakAtValue[1])
|
|
2810
|
+
: tiebreakAtValue[1];
|
|
2811
|
+
return tiebreakAt || false;
|
|
2812
|
+
}
|
|
2813
|
+
return undefined;
|
|
2814
|
+
}
|
|
2815
|
+
function parseTiebreakFormat(formatstring) {
|
|
2816
|
+
if (formatstring) {
|
|
2817
|
+
if (formatstring.startsWith('TB')) {
|
|
2818
|
+
var modifier = parseTiebreakAt(formatstring, false);
|
|
2819
|
+
var parts = formatstring.match(/^TB(\d+)([A-Za-z]*)/);
|
|
2820
|
+
var tiebreakToString = parts === null || parts === void 0 ? void 0 : parts[1];
|
|
2821
|
+
var NoAD = parts && isNoAD(parts[2]);
|
|
2822
|
+
var validNoAD = !(parts === null || parts === void 0 ? void 0 : parts[2]) || NoAD;
|
|
2823
|
+
var tiebreakTo = getNumber(tiebreakToString);
|
|
2824
|
+
if (tiebreakTo && validNoAD) {
|
|
2825
|
+
var result = { tiebreakTo: tiebreakTo };
|
|
2826
|
+
// modifiers cannot be numeric
|
|
2827
|
+
if (modifier &&
|
|
2828
|
+
typeof modifier === 'string' &&
|
|
2829
|
+
!isConvertableInteger(modifier)) {
|
|
2830
|
+
result.modifier = modifier;
|
|
2831
|
+
}
|
|
2832
|
+
if (NoAD)
|
|
2833
|
+
result.NoAD = true;
|
|
2834
|
+
return result;
|
|
2835
|
+
}
|
|
2836
|
+
else {
|
|
2837
|
+
return false;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
else {
|
|
2841
|
+
return false;
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
return undefined;
|
|
2845
|
+
}
|
|
2846
|
+
function parseTimedSet(formatstring) {
|
|
2847
|
+
var _a;
|
|
2848
|
+
var timestring = formatstring.slice(1);
|
|
2849
|
+
var parts = timestring.match(/^(\d+)(@?[A-Za-z]*)/);
|
|
2850
|
+
var minutes = getNumber(parts === null || parts === void 0 ? void 0 : parts[1]);
|
|
2851
|
+
if (!minutes)
|
|
2852
|
+
return;
|
|
2853
|
+
var setFormat = { timed: true, minutes: minutes };
|
|
2854
|
+
var based = parts === null || parts === void 0 ? void 0 : parts[2];
|
|
2855
|
+
var validModifier = [undefined, 'P', 'G'].includes(based);
|
|
2856
|
+
if (based && !validModifier) {
|
|
2857
|
+
var modifier = (_a = timestring.match(/^(\d+)(@)([A-Za-z]+)$/)) === null || _a === void 0 ? void 0 : _a[3];
|
|
2858
|
+
if (modifier) {
|
|
2859
|
+
setFormat.modifier = modifier;
|
|
2860
|
+
return setFormat;
|
|
2861
|
+
}
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
if (based)
|
|
2865
|
+
setFormat.based = parts[2];
|
|
2866
|
+
return setFormat;
|
|
2867
|
+
}
|
|
2868
|
+
function isNoAD(formatstring) {
|
|
2869
|
+
return formatstring && formatstring.indexOf(NOAD) >= 0;
|
|
2870
|
+
}
|
|
2871
|
+
function getNumber(formatstring) {
|
|
2872
|
+
return !isNaN(Number(formatstring)) ? Number(formatstring) : 0;
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
function isValid(matchUpFormat) {
|
|
2876
|
+
if (typeof matchUpFormat !== 'string')
|
|
2877
|
+
return false;
|
|
2878
|
+
var parsedFormat = parse(matchUpFormat);
|
|
2879
|
+
var setParts = matchUpFormat.match(/-S:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
2880
|
+
var setsTo = setParts === null || setParts === void 0 ? void 0 : setParts[1];
|
|
2881
|
+
var tiebreakTo = setParts === null || setParts === void 0 ? void 0 : setParts[2];
|
|
2882
|
+
var tiebreakAt = setParts === null || setParts === void 0 ? void 0 : setParts[3];
|
|
2883
|
+
var finalSetParts = matchUpFormat.match(/-F:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
2884
|
+
var finalSetTo = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[1];
|
|
2885
|
+
var finalSetTiebreakTo = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[2];
|
|
2886
|
+
var finalTiebreakAt = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[3];
|
|
2887
|
+
var preserveRedundant = !!((setParts && tiebreakTo && setsTo === tiebreakAt) ||
|
|
2888
|
+
(finalSetParts && finalSetTiebreakTo && finalSetTo === finalTiebreakAt));
|
|
2889
|
+
var stringified = stringify(parsedFormat, preserveRedundant);
|
|
2890
|
+
return stringified === matchUpFormat;
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
var matchUpFormatCode = {
|
|
2894
|
+
isValidMatchUpFormat: isValid,
|
|
2895
|
+
stringify: stringify,
|
|
2896
|
+
isValid: isValid,
|
|
2897
|
+
parse: parse,
|
|
2898
|
+
};
|
|
2899
|
+
|
|
2900
|
+
function factoryVersion() {
|
|
2901
|
+
return '1.8.5';
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
function getObjectTieFormat(obj) {
|
|
2905
|
+
if (!obj)
|
|
2906
|
+
return;
|
|
2907
|
+
var tieFormatId = obj.tieFormatId, tieFormats = obj.tieFormats;
|
|
2908
|
+
if (obj.tieFormat) {
|
|
2909
|
+
return obj.tieFormat;
|
|
2910
|
+
}
|
|
2911
|
+
else if (tieFormatId && Array.isArray(tieFormats)) {
|
|
2912
|
+
return tieFormats.find(function (tf) { return tf.tieFormatId === tieFormatId; });
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
|
|
2916
|
+
function getItemTieFormat(_a) {
|
|
2917
|
+
var _b, _c, _d;
|
|
2918
|
+
var item = _a.item, drawDefinition = _a.drawDefinition, structure = _a.structure, event = _a.event;
|
|
2919
|
+
if (!item)
|
|
2920
|
+
return;
|
|
2921
|
+
if (item.tieFormat)
|
|
2922
|
+
return item.tieFormat;
|
|
2923
|
+
// if there is a tieFormatId, only possible to look for referenced tieFormat in tieFormats on drawDefinition and event
|
|
2924
|
+
if (item.tieFormatId) {
|
|
2925
|
+
if (drawDefinition.tieFormat)
|
|
2926
|
+
return drawDefinition.tieFormat;
|
|
2927
|
+
var tieFormat = (_b = drawDefinition.tieFormats) === null || _b === void 0 ? void 0 : _b.find(function (tf) { return item.tieFormatId === tf.tieFormatId; });
|
|
2928
|
+
if (tieFormat)
|
|
2929
|
+
return tieFormat;
|
|
2930
|
+
if (event.tieFormat)
|
|
2931
|
+
return event.tieFormat;
|
|
2932
|
+
return (_c = event.tieFormats) === null || _c === void 0 ? void 0 : _c.find(function (tf) { return item.tieFormatId === tf.tieFormatId; });
|
|
2933
|
+
}
|
|
2934
|
+
if (structure.tieFormat)
|
|
2935
|
+
return structure.tieFormat;
|
|
2936
|
+
if (structure.tieFormatId) {
|
|
2937
|
+
var structureTieFormat = (_d = drawDefinition.tieFormats) === null || _d === void 0 ? void 0 : _d.find(function (tf) { return structure.tieFormatId === tf.tieFormatId; });
|
|
2938
|
+
if (structureTieFormat)
|
|
2939
|
+
return structureTieFormat;
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
function resolveTieFormat(_a) {
|
|
2944
|
+
var drawDefinition = _a.drawDefinition, structure = _a.structure, matchUp = _a.matchUp, event = _a.event;
|
|
2945
|
+
return {
|
|
2946
|
+
tieFormat: getItemTieFormat({
|
|
2947
|
+
item: matchUp,
|
|
2948
|
+
drawDefinition: drawDefinition,
|
|
2949
|
+
structure: structure,
|
|
2950
|
+
event: event,
|
|
2951
|
+
}) ||
|
|
2952
|
+
getItemTieFormat({
|
|
2953
|
+
item: structure,
|
|
2954
|
+
drawDefinition: drawDefinition,
|
|
2955
|
+
structure: structure,
|
|
2956
|
+
event: event,
|
|
2957
|
+
}) ||
|
|
2958
|
+
getObjectTieFormat(drawDefinition) ||
|
|
2959
|
+
getObjectTieFormat(event),
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2640
2963
|
var typeMatch = function (arr, type) {
|
|
2641
2964
|
return arr.filter(Boolean).every(function (i) { return typeof i === type; });
|
|
2642
2965
|
};
|
|
@@ -2834,321 +3157,6 @@ function getCategoryAgeDetails(params) {
|
|
|
2834
3157
|
return result;
|
|
2835
3158
|
}
|
|
2836
3159
|
|
|
2837
|
-
// NOTE: type really does need to be any!
|
|
2838
|
-
function attributeFilter(params) {
|
|
2839
|
-
if (params === null)
|
|
2840
|
-
return {};
|
|
2841
|
-
var _a = params || {}, source = _a.source, template = _a.template;
|
|
2842
|
-
if (!template)
|
|
2843
|
-
return source;
|
|
2844
|
-
var target = {};
|
|
2845
|
-
attributeCopy(source, template, target);
|
|
2846
|
-
return target;
|
|
2847
|
-
function attributeCopy(valuesObject, templateObject, outputObject) {
|
|
2848
|
-
var e_1, _a;
|
|
2849
|
-
if (!valuesObject || !templateObject)
|
|
2850
|
-
return undefined;
|
|
2851
|
-
var vKeys = Object.keys(valuesObject);
|
|
2852
|
-
var oKeys = Object.keys(templateObject);
|
|
2853
|
-
// the orMap allows spcification of { 'a||b': boolean } so that filter templates can apply to multiple attributes
|
|
2854
|
-
var orMap = Object.assign.apply(Object, __spreadArray([{}], __read(oKeys
|
|
2855
|
-
.filter(function (key) { return key.indexOf('||'); })
|
|
2856
|
-
.map(function (key) { return key.split('||').map(function (or) {
|
|
2857
|
-
var _a;
|
|
2858
|
-
return (_a = {}, _a[or] = key, _a);
|
|
2859
|
-
}); })
|
|
2860
|
-
.flat()), false));
|
|
2861
|
-
var allKeys = oKeys.concat.apply(oKeys, __spreadArray([], __read(Object.keys(orMap)), false));
|
|
2862
|
-
var wildcard = allKeys.includes('*');
|
|
2863
|
-
var _loop_1 = function (vKey) {
|
|
2864
|
-
if (allKeys.indexOf(vKey) >= 0 || wildcard) {
|
|
2865
|
-
var templateKey = orMap[vKey] || vKey;
|
|
2866
|
-
var tobj_1 = templateObject[templateKey] || wildcard;
|
|
2867
|
-
var vobj = valuesObject[vKey];
|
|
2868
|
-
if (typeof tobj_1 === 'object' &&
|
|
2869
|
-
typeof vobj !== 'function' &&
|
|
2870
|
-
!Array.isArray(tobj_1)) {
|
|
2871
|
-
if (Array.isArray(vobj)) {
|
|
2872
|
-
var mappedElements = vobj
|
|
2873
|
-
.map(function (arrayMember) {
|
|
2874
|
-
var target = {};
|
|
2875
|
-
var result = attributeCopy(arrayMember, tobj_1, target);
|
|
2876
|
-
return result !== false ? target : undefined;
|
|
2877
|
-
})
|
|
2878
|
-
.filter(Boolean);
|
|
2879
|
-
outputObject[vKey] = mappedElements;
|
|
2880
|
-
}
|
|
2881
|
-
else if (vobj) {
|
|
2882
|
-
outputObject[vKey] = {};
|
|
2883
|
-
attributeCopy(vobj, tobj_1, outputObject[vKey]);
|
|
2884
|
-
}
|
|
2885
|
-
}
|
|
2886
|
-
else {
|
|
2887
|
-
var value = valuesObject[vKey];
|
|
2888
|
-
var exclude = Array.isArray(tobj_1) && !tobj_1.includes(value);
|
|
2889
|
-
if (exclude)
|
|
2890
|
-
return { value: false };
|
|
2891
|
-
if (templateObject[vKey] ||
|
|
2892
|
-
(wildcard && templateObject[vKey] !== false)) {
|
|
2893
|
-
outputObject[vKey] = value;
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
}
|
|
2897
|
-
};
|
|
2898
|
-
try {
|
|
2899
|
-
for (var vKeys_1 = __values(vKeys), vKeys_1_1 = vKeys_1.next(); !vKeys_1_1.done; vKeys_1_1 = vKeys_1.next()) {
|
|
2900
|
-
var vKey = vKeys_1_1.value;
|
|
2901
|
-
var state_1 = _loop_1(vKey);
|
|
2902
|
-
if (typeof state_1 === "object")
|
|
2903
|
-
return state_1.value;
|
|
2904
|
-
}
|
|
2905
|
-
}
|
|
2906
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2907
|
-
finally {
|
|
2908
|
-
try {
|
|
2909
|
-
if (vKeys_1_1 && !vKeys_1_1.done && (_a = vKeys_1.return)) _a.call(vKeys_1);
|
|
2910
|
-
}
|
|
2911
|
-
finally { if (e_1) throw e_1.error; }
|
|
2912
|
-
}
|
|
2913
|
-
return undefined;
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
|
|
2917
|
-
function generateTimeCode(index) {
|
|
2918
|
-
if (index === void 0) { index = 0; }
|
|
2919
|
-
var uidate = new Date();
|
|
2920
|
-
uidate.setHours(uidate.getHours() + index);
|
|
2921
|
-
return uidate.getTime().toString(36).slice(-6).toUpperCase();
|
|
2922
|
-
}
|
|
2923
|
-
|
|
2924
|
-
function numericSort(a, b) {
|
|
2925
|
-
return a - b;
|
|
2926
|
-
}
|
|
2927
|
-
|
|
2928
|
-
/**
|
|
2929
|
-
*
|
|
2930
|
-
* @param {object[]} arrayOfJSON - JSON objects array
|
|
2931
|
-
* @param {object} config - object which configures processing (see below)
|
|
2932
|
-
* @returns {string} - joined by '\r\n' or specified line separator
|
|
2933
|
-
*
|
|
2934
|
-
* config {
|
|
2935
|
-
* {boolean} includeTransformAccessors, // transform accessors are included with columnAccessors
|
|
2936
|
-
* {string[]} columnAccessors, // [ 'includeThis', 'andThis' ]
|
|
2937
|
-
* {object} columnTransform, // e.g. { 'newColumnName': ['oldColumn1', 'oldColumn2' ]}
|
|
2938
|
-
* {object} columnMap, // e.g. { 'columnName': 'newColumnName' }
|
|
2939
|
-
* {object} valuesMap, // e.g. { 'columnName': { 'value1': 'mappedValue' }} // useful for mapping IDs
|
|
2940
|
-
* {array} sortOrder // e.g. ['columnName1', 'columnName2'] // determine order of csv columns
|
|
2941
|
-
* {object} context, // attributes which are to be added to all rows { 'columnName': 'value }
|
|
2942
|
-
* {string} delimiter, // defaults to '"'
|
|
2943
|
-
* {string} columnJoiner, // defaults to ',' // defines how CSV columns are joined
|
|
2944
|
-
* {string} rowJoiner, // defaults to '\r\n' // defines how CSV lines are joined
|
|
2945
|
-
* {string} keyJoiner, // defaults to '.' // defines how flattened column names are constructed
|
|
2946
|
-
* }
|
|
2947
|
-
*
|
|
2948
|
-
* NOTE: `columnTransform` mapped array elements are sensitive to order and will resolve to the first matching value
|
|
2949
|
-
* NOTE: `columnMap` should not contain new columnName(s) that are `columnTransform` keys
|
|
2950
|
-
*/
|
|
2951
|
-
function JSON2CSV(arrayOfJSON, config) {
|
|
2952
|
-
if (config && typeof config !== 'object')
|
|
2953
|
-
return INVALID_VALUES;
|
|
2954
|
-
var _a = (config || {}).columnTransform, columnTransform = _a === void 0 ? {} : _a;
|
|
2955
|
-
var _b = config || {}, includeTransformAccessors = _b.includeTransformAccessors, _c = _b.includeHeaderRow, includeHeaderRow = _c === void 0 ? true : _c, returnTransformedJSON = _b.returnTransformedJSON, removeEmptyColumns = _b.removeEmptyColumns, onlyHeaderRow = _b.onlyHeaderRow, _d = _b.columnAccessors, columnAccessors = _d === void 0 ? [] : _d, _e = _b.functionMap, functionMap = _e === void 0 ? {} : _e, _f = _b.columnMap, columnMap = _f === void 0 ? {} : _f, _g = _b.valuesMap, valuesMap = _g === void 0 ? {} : _g, _h = _b.context, context = _h === void 0 ? {} : _h, _j = _b.delimiter, delimiter = _j === void 0 ? '"' : _j, _k = _b.columnJoiner, columnJoiner = _k === void 0 ? ',' : _k, _l = _b.rowJoiner, rowJoiner = _l === void 0 ? '\r\n' : _l, _m = _b.keyJoiner, keyJoiner = _m === void 0 ? '.' : _m;
|
|
2956
|
-
if (!Array.isArray(arrayOfJSON) ||
|
|
2957
|
-
!Array.isArray(columnAccessors) ||
|
|
2958
|
-
typeof context !== 'object' ||
|
|
2959
|
-
typeof columnMap !== 'object' ||
|
|
2960
|
-
typeof columnTransform !== 'object' ||
|
|
2961
|
-
typeof functionMap !== 'object' ||
|
|
2962
|
-
typeof valuesMap !== 'object' ||
|
|
2963
|
-
typeof columnJoiner !== 'string' ||
|
|
2964
|
-
typeof rowJoiner !== 'string' ||
|
|
2965
|
-
typeof keyJoiner !== 'string' ||
|
|
2966
|
-
typeof delimiter !== 'string')
|
|
2967
|
-
return INVALID_VALUES;
|
|
2968
|
-
// ensure all column transformers are arrays
|
|
2969
|
-
columnTransform = Object.assign.apply(Object, __spreadArray([{}], __read(Object.keys(columnTransform)
|
|
2970
|
-
.reverse() // reverse so that exported CSV columns are in the order as defined
|
|
2971
|
-
.map(function (key) {
|
|
2972
|
-
var _a;
|
|
2973
|
-
return (_a = {},
|
|
2974
|
-
_a[key] = Array.isArray(columnTransform[key])
|
|
2975
|
-
? columnTransform[key]
|
|
2976
|
-
: [
|
|
2977
|
-
// ensure transform attributes are strings
|
|
2978
|
-
typeof columnTransform[key] === 'string' && columnTransform[key],
|
|
2979
|
-
].filter(Boolean),
|
|
2980
|
-
_a);
|
|
2981
|
-
})), false));
|
|
2982
|
-
var flattened = arrayOfJSON
|
|
2983
|
-
.filter(Boolean)
|
|
2984
|
-
.map(function (obj) { return flattenJSON(obj, keyJoiner); });
|
|
2985
|
-
var transformColumns = Object.values(columnTransform).flat();
|
|
2986
|
-
if (includeTransformAccessors)
|
|
2987
|
-
columnAccessors.push.apply(columnAccessors, __spreadArray([], __read(transformColumns), false));
|
|
2988
|
-
var headerRow = flattened
|
|
2989
|
-
.reduce(function (aggregator, row) {
|
|
2990
|
-
return Object.keys(row).every(function (key) { return (!aggregator.includes(key) && aggregator.push(key)) || true; }) && aggregator;
|
|
2991
|
-
}, [])
|
|
2992
|
-
.filter(function (key) { return !(columnAccessors === null || columnAccessors === void 0 ? void 0 : columnAccessors.length) || columnAccessors.includes(key); });
|
|
2993
|
-
var accessorMap = Object.assign.apply(Object, __spreadArray([{}], __read(Object.keys(columnTransform)
|
|
2994
|
-
.reverse() // so that original order is preserved when later pushed
|
|
2995
|
-
.map(function (transform) {
|
|
2996
|
-
return columnTransform[transform]
|
|
2997
|
-
.map(function (value) {
|
|
2998
|
-
var _a;
|
|
2999
|
-
return (_a = {}, _a[value] = transform, _a);
|
|
3000
|
-
})
|
|
3001
|
-
.flat();
|
|
3002
|
-
})
|
|
3003
|
-
.flat()), false));
|
|
3004
|
-
var sortColumns = function (a, b) {
|
|
3005
|
-
return !(config === null || config === void 0 ? void 0 : config.sortOrder)
|
|
3006
|
-
? 0
|
|
3007
|
-
: (config.sortOrder.includes(a) &&
|
|
3008
|
-
config.sortOrder.includes(b) &&
|
|
3009
|
-
config.sortOrder.indexOf(a) - config.sortOrder.indexOf(b)) ||
|
|
3010
|
-
(!config.sortOrder.includes(b) && -1);
|
|
3011
|
-
};
|
|
3012
|
-
var tranformedHeaderRow = headerRow
|
|
3013
|
-
.reduce(function (def, key) {
|
|
3014
|
-
var transform = accessorMap[key];
|
|
3015
|
-
if (transform) {
|
|
3016
|
-
if (!def.includes(transform))
|
|
3017
|
-
def.push(transform);
|
|
3018
|
-
}
|
|
3019
|
-
else {
|
|
3020
|
-
def.push(key);
|
|
3021
|
-
}
|
|
3022
|
-
return def;
|
|
3023
|
-
}, [])
|
|
3024
|
-
.sort(sortColumns);
|
|
3025
|
-
Object.keys(columnMap).forEach(function (columnName) {
|
|
3026
|
-
return !tranformedHeaderRow.includes(columnName) &&
|
|
3027
|
-
tranformedHeaderRow.unshift(columnName);
|
|
3028
|
-
});
|
|
3029
|
-
Object.keys(columnTransform).forEach(function (columnName) {
|
|
3030
|
-
return !tranformedHeaderRow.includes(columnName) &&
|
|
3031
|
-
tranformedHeaderRow.unshift(columnName);
|
|
3032
|
-
});
|
|
3033
|
-
typeof context === 'object' &&
|
|
3034
|
-
Object.keys(context).forEach(function (columnName) {
|
|
3035
|
-
return !tranformedHeaderRow.includes(columnName) &&
|
|
3036
|
-
tranformedHeaderRow.unshift(columnName);
|
|
3037
|
-
});
|
|
3038
|
-
var mappedHeaderRow = tranformedHeaderRow.map(function (key) { return columnMap[key] || key; });
|
|
3039
|
-
if (onlyHeaderRow)
|
|
3040
|
-
return [mappedHeaderRow];
|
|
3041
|
-
var withDelimiter = function (value) { return "".concat(delimiter).concat(value).concat(delimiter); };
|
|
3042
|
-
var columnValueCounts = [];
|
|
3043
|
-
var processRow = function (row) {
|
|
3044
|
-
return Object.values(tranformedHeaderRow.reduce(function (columnsMap, columnName, columnIndex) {
|
|
3045
|
-
var _a;
|
|
3046
|
-
var accessors = columnTransform[columnName];
|
|
3047
|
-
var value = ((accessors === null || accessors === void 0 ? void 0 : accessors.length)
|
|
3048
|
-
? row[accessors.find(function (accessor) { return row[accessor]; })]
|
|
3049
|
-
: row[columnName]) ||
|
|
3050
|
-
(context === null || context === void 0 ? void 0 : context[columnName]) ||
|
|
3051
|
-
'';
|
|
3052
|
-
var mappedValue = ((_a = valuesMap[columnName]) === null || _a === void 0 ? void 0 : _a[value]) || value;
|
|
3053
|
-
var fxValue = typeof functionMap[columnName] === 'function'
|
|
3054
|
-
? functionMap[columnName](mappedValue)
|
|
3055
|
-
: mappedValue;
|
|
3056
|
-
columnsMap[columnName] = withDelimiter(fxValue);
|
|
3057
|
-
if (fxValue) {
|
|
3058
|
-
columnValueCounts[columnIndex] =
|
|
3059
|
-
(columnValueCounts[columnIndex] || 0) + 1;
|
|
3060
|
-
}
|
|
3061
|
-
return columnsMap;
|
|
3062
|
-
}, {}));
|
|
3063
|
-
};
|
|
3064
|
-
var flattenedRows = flattened.map(processRow);
|
|
3065
|
-
var indicesToRemove = removeEmptyColumns &&
|
|
3066
|
-
__spreadArray([], __read(columnValueCounts), false).map(function (count, index) { return !count && index; })
|
|
3067
|
-
.filter(isNumeric)
|
|
3068
|
-
.reverse();
|
|
3069
|
-
if (indicesToRemove) {
|
|
3070
|
-
var purge = function (row) {
|
|
3071
|
-
return row.filter(function (_, index) { return !indicesToRemove.includes(index); });
|
|
3072
|
-
};
|
|
3073
|
-
flattenedRows = flattenedRows.map(purge);
|
|
3074
|
-
mappedHeaderRow = purge(mappedHeaderRow);
|
|
3075
|
-
}
|
|
3076
|
-
var rows = flattenedRows.map(function (row) { return row.join(columnJoiner); });
|
|
3077
|
-
if (returnTransformedJSON) {
|
|
3078
|
-
return rows.map(function (row) {
|
|
3079
|
-
var columnValues = row.split(columnJoiner);
|
|
3080
|
-
return Object.assign.apply(Object, __spreadArray([{}], __read(columnValues.map(function (v, i) {
|
|
3081
|
-
var _a;
|
|
3082
|
-
return (_a = {}, _a[mappedHeaderRow[i]] = v, _a);
|
|
3083
|
-
})), false));
|
|
3084
|
-
});
|
|
3085
|
-
}
|
|
3086
|
-
return includeHeaderRow
|
|
3087
|
-
? __spreadArray([mappedHeaderRow.map(withDelimiter).join(columnJoiner)], __read(rows), false).join(rowJoiner)
|
|
3088
|
-
: rows.join(rowJoiner);
|
|
3089
|
-
}
|
|
3090
|
-
function flattenJSON(obj, keyJoiner, path) {
|
|
3091
|
-
if (keyJoiner === void 0) { keyJoiner = '.'; }
|
|
3092
|
-
if (path === void 0) { path = []; }
|
|
3093
|
-
return (typeof obj === 'object' &&
|
|
3094
|
-
Object.keys(obj).reduce(function (result, key) {
|
|
3095
|
-
if (typeof obj[key] !== 'object') {
|
|
3096
|
-
result[path.concat(key).join(keyJoiner)] = obj[key];
|
|
3097
|
-
return result;
|
|
3098
|
-
}
|
|
3099
|
-
return Object.assign(result, flattenJSON(obj[key], keyJoiner, path.concat(key)));
|
|
3100
|
-
}, {}));
|
|
3101
|
-
}
|
|
3102
|
-
|
|
3103
|
-
/*
|
|
3104
|
-
based on an answer provided by Jeff Ward on StackOverflow; November 2019
|
|
3105
|
-
https://stackoverflow.com/users/1026023/jeff-ward
|
|
3106
|
-
https://stackoverflow.com/questions/105034/how-to-create-guid-uuid?rq=1
|
|
3107
|
-
*/
|
|
3108
|
-
/**
|
|
3109
|
-
* generate a given number of UUIDs
|
|
3110
|
-
*
|
|
3111
|
-
* @param {number} count - number of UUIDs to generate
|
|
3112
|
-
*/
|
|
3113
|
-
function UUIDS(count) {
|
|
3114
|
-
if (count === void 0) { count = 1; }
|
|
3115
|
-
return generateRange(0, count).map(UUID);
|
|
3116
|
-
}
|
|
3117
|
-
function UUID() {
|
|
3118
|
-
var lut = [];
|
|
3119
|
-
for (var i = 0; i < 256; i++) {
|
|
3120
|
-
lut[i] = (i < 16 ? '0' : '') + i.toString(16);
|
|
3121
|
-
}
|
|
3122
|
-
var d0 = (Math.random() * 0xffffffff) | 0;
|
|
3123
|
-
var d1 = (Math.random() * 0xffffffff) | 0;
|
|
3124
|
-
var d2 = (Math.random() * 0xffffffff) | 0;
|
|
3125
|
-
var d3 = (Math.random() * 0xffffffff) | 0;
|
|
3126
|
-
// eslint-disable-next-line no-mixed-operators
|
|
3127
|
-
return (lut[d0 & 0xff] +
|
|
3128
|
-
lut[(d0 >> 8) & 0xff] +
|
|
3129
|
-
lut[(d0 >> 16) & 0xff] +
|
|
3130
|
-
lut[(d0 >> 24) & 0xff] +
|
|
3131
|
-
'-' +
|
|
3132
|
-
// eslint-disable-next-line no-mixed-operators
|
|
3133
|
-
lut[d1 & 0xff] +
|
|
3134
|
-
lut[(d1 >> 8) & 0xff] +
|
|
3135
|
-
'-' +
|
|
3136
|
-
lut[((d1 >> 16) & 0x0f) | 0x40] +
|
|
3137
|
-
lut[(d1 >> 24) & 0xff] +
|
|
3138
|
-
'-' +
|
|
3139
|
-
// eslint-disable-next-line no-mixed-operators
|
|
3140
|
-
lut[(d2 & 0x3f) | 0x80] +
|
|
3141
|
-
lut[(d2 >> 8) & 0xff] +
|
|
3142
|
-
'-' +
|
|
3143
|
-
lut[(d2 >> 16) & 0xff] +
|
|
3144
|
-
lut[(d2 >> 24) & 0xff] +
|
|
3145
|
-
// eslint-disable-next-line no-mixed-operators
|
|
3146
|
-
lut[d3 & 0xff] +
|
|
3147
|
-
lut[(d3 >> 8) & 0xff] +
|
|
3148
|
-
lut[(d3 >> 16) & 0xff] +
|
|
3149
|
-
lut[(d3 >> 24) & 0xff]);
|
|
3150
|
-
}
|
|
3151
|
-
|
|
3152
3160
|
function categoryCanContain(_a) {
|
|
3153
3161
|
var childCategory = _a.childCategory, withDetails = _a.withDetails, category = _a.category;
|
|
3154
3162
|
var categoryDetails = getCategoryAgeDetails({ category: category });
|
|
@@ -8920,6 +8928,7 @@ function structureAssignedDrawPositions(_a) {
|
|
|
8920
8928
|
}
|
|
8921
8929
|
|
|
8922
8930
|
function getOrderedDrawPositions(_a) {
|
|
8931
|
+
var _b;
|
|
8923
8932
|
var drawPositions = _a.drawPositions, roundProfile = _a.roundProfile, roundNumber = _a.roundNumber;
|
|
8924
8933
|
var unassignedDrawPositions = [undefined, undefined];
|
|
8925
8934
|
if (noNumeric(drawPositions)) {
|
|
@@ -8930,9 +8939,9 @@ function getOrderedDrawPositions(_a) {
|
|
|
8930
8939
|
}
|
|
8931
8940
|
var targetRoundProfile = roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[roundNumber];
|
|
8932
8941
|
var pairedDrawPositions = targetRoundProfile === null || targetRoundProfile === void 0 ? void 0 : targetRoundProfile.pairedDrawPositions;
|
|
8933
|
-
var displayOrder = (pairedDrawPositions === null || pairedDrawPositions === void 0 ? void 0 : pairedDrawPositions.find(function (pair) {
|
|
8942
|
+
var displayOrder = (_b = pairedDrawPositions === null || pairedDrawPositions === void 0 ? void 0 : pairedDrawPositions.find(function (pair) {
|
|
8934
8943
|
return overlap(pair || [], drawPositions.filter(Boolean));
|
|
8935
|
-
}))
|
|
8944
|
+
})) !== null && _b !== void 0 ? _b : unassignedDrawPositions;
|
|
8936
8945
|
// ############# IMPORTANT DO NOT CHANGE #################
|
|
8937
8946
|
// when both present, drawPositions are always sorted numerically
|
|
8938
8947
|
// this holds true even when fed positions encounter each other in later rounds
|
|
@@ -8942,7 +8951,7 @@ function getOrderedDrawPositions(_a) {
|
|
|
8942
8951
|
// previous round lookback is provided by the roundProfile
|
|
8943
8952
|
var isFeedRound = targetRoundProfile === null || targetRoundProfile === void 0 ? void 0 : targetRoundProfile.feedRound;
|
|
8944
8953
|
if (allNumeric$1(drawPositions)) {
|
|
8945
|
-
var orderedDrawPositions = drawPositions.sort(numericSort);
|
|
8954
|
+
var orderedDrawPositions = __spreadArray([], __read(drawPositions), false).sort(numericSort);
|
|
8946
8955
|
return {
|
|
8947
8956
|
orderedDrawPositions: orderedDrawPositions.length === 2 ? orderedDrawPositions : displayOrder,
|
|
8948
8957
|
displayOrder: isFeedRound ? orderedDrawPositions : displayOrder,
|
|
@@ -9723,9 +9732,9 @@ function getAllStructureMatchUps(_a) {
|
|
|
9723
9732
|
}
|
|
9724
9733
|
return { matchUps: matchUps, roundMatchUps: roundMatchUps, roundProfile: roundProfile, collectionPositionMatchUps: collectionPositionMatchUps };
|
|
9725
9734
|
function addMatchUpContext(_a) {
|
|
9726
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
9735
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
9727
9736
|
var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, sourceDrawPositionRanges = _a.sourceDrawPositionRanges, drawPositionsRanges = _a.drawPositionsRanges, initialRoundOfPlay = _a.initialRoundOfPlay, additionalContext = _a.additionalContext, roundNamingProfile = _a.roundNamingProfile, tieDrawPositions = _a.tieDrawPositions, appliedPolicies = _a.appliedPolicies, isCollectionBye = _a.isCollectionBye, matchUpTieId = _a.matchUpTieId, isRoundRobin = _a.isRoundRobin, roundProfile = _a.roundProfile, sideLineUps = _a.sideLineUps, matchUp = _a.matchUp, event = _a.event;
|
|
9728
|
-
additionalContext = additionalContext
|
|
9737
|
+
additionalContext = additionalContext !== null && additionalContext !== void 0 ? additionalContext : {};
|
|
9729
9738
|
var tieFormat = (_b = resolveTieFormat({
|
|
9730
9739
|
drawDefinition: drawDefinition,
|
|
9731
9740
|
structure: structure,
|
|
@@ -9737,17 +9746,14 @@ function getAllStructureMatchUps(_a) {
|
|
|
9737
9746
|
(collectionDefinitions === null || collectionDefinitions === void 0 ? void 0 : collectionDefinitions.find(function (definition) { return definition.collectionId === matchUp.collectionId; }));
|
|
9738
9747
|
var matchUpFormat = matchUp.collectionId
|
|
9739
9748
|
? collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpFormat
|
|
9740
|
-
: matchUp.matchUpFormat ||
|
|
9741
|
-
(structure === null || structure === void 0 ? void 0 : structure.matchUpFormat) ||
|
|
9742
|
-
(drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpFormat) ||
|
|
9743
|
-
(event === null || event === void 0 ? void 0 : event.matchUpFormat);
|
|
9749
|
+
: (_e = (_d = (_c = matchUp.matchUpFormat) !== null && _c !== void 0 ? _c : structure === null || structure === void 0 ? void 0 : structure.matchUpFormat) !== null && _d !== void 0 ? _d : drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpFormat) !== null && _e !== void 0 ? _e : event === null || event === void 0 ? void 0 : event.matchUpFormat;
|
|
9744
9750
|
var matchUpType = matchUp.matchUpType ||
|
|
9745
9751
|
(collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) ||
|
|
9746
9752
|
(structure === null || structure === void 0 ? void 0 : structure.matchUpType) ||
|
|
9747
9753
|
(drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpType) ||
|
|
9748
9754
|
((event === null || event === void 0 ? void 0 : event.eventType) !== TEAM$1 && (event === null || event === void 0 ? void 0 : event.eventType));
|
|
9749
9755
|
var matchUpStatus = isCollectionBye ? BYE : matchUp.matchUpStatus;
|
|
9750
|
-
var
|
|
9756
|
+
var _z = getMatchUpScheduleDetails({
|
|
9751
9757
|
scheduleVisibilityFilters: scheduleVisibilityFilters,
|
|
9752
9758
|
afterRecoveryTimes: afterRecoveryTimes,
|
|
9753
9759
|
tournamentRecord: tournamentRecord,
|
|
@@ -9756,10 +9762,10 @@ function getAllStructureMatchUps(_a) {
|
|
|
9756
9762
|
matchUpType: matchUpType,
|
|
9757
9763
|
matchUp: matchUp,
|
|
9758
9764
|
event: event,
|
|
9759
|
-
}), schedule =
|
|
9760
|
-
var drawPositions = (
|
|
9765
|
+
}), schedule = _z.schedule, endDate = _z.endDate;
|
|
9766
|
+
var drawPositions = (_f = tieDrawPositions !== null && tieDrawPositions !== void 0 ? tieDrawPositions : matchUp.drawPositions) !== null && _f !== void 0 ? _f : [];
|
|
9761
9767
|
var collectionPosition = matchUp.collectionPosition, collectionId = matchUp.collectionId, roundPosition = matchUp.roundPosition;
|
|
9762
|
-
var roundNumber = matchUp.roundNumber
|
|
9768
|
+
var roundNumber = (_g = matchUp.roundNumber) !== null && _g !== void 0 ? _g : additionalContext.roundNumber;
|
|
9763
9769
|
var drawPositionCollectionAssignment = collectionId
|
|
9764
9770
|
? getDrawPositionCollectionAssignment({
|
|
9765
9771
|
tournamentParticipants: tournamentParticipants,
|
|
@@ -9773,13 +9779,13 @@ function getAllStructureMatchUps(_a) {
|
|
|
9773
9779
|
matchUpType: matchUpType,
|
|
9774
9780
|
})
|
|
9775
9781
|
: undefined;
|
|
9776
|
-
var roundName = ((
|
|
9782
|
+
var roundName = ((_h = roundNamingProfile === null || roundNamingProfile === void 0 ? void 0 : roundNamingProfile[roundNumber]) === null || _h === void 0 ? void 0 : _h.roundName) ||
|
|
9777
9783
|
additionalContext.roundName;
|
|
9778
|
-
var abbreviatedRoundName = ((
|
|
9784
|
+
var abbreviatedRoundName = ((_j = roundNamingProfile === null || roundNamingProfile === void 0 ? void 0 : roundNamingProfile[roundNumber]) === null || _j === void 0 ? void 0 : _j.abbreviatedRoundName) ||
|
|
9779
9785
|
additionalContext.abbreviatedRoundName;
|
|
9780
|
-
var feedRound = (
|
|
9781
|
-
var preFeedRound = (
|
|
9782
|
-
var roundFactor = (
|
|
9786
|
+
var feedRound = (_k = roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[roundNumber]) === null || _k === void 0 ? void 0 : _k.feedRound;
|
|
9787
|
+
var preFeedRound = (_l = roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[roundNumber]) === null || _l === void 0 ? void 0 : _l.preFeedRound;
|
|
9788
|
+
var roundFactor = (_m = roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[roundNumber]) === null || _m === void 0 ? void 0 : _m.roundFactor;
|
|
9783
9789
|
var drawPositionsRoundRanges = drawPositionsRanges === null || drawPositionsRanges === void 0 ? void 0 : drawPositionsRanges[roundNumber];
|
|
9784
9790
|
var drawPositionsRange = roundPosition
|
|
9785
9791
|
? drawPositionsRoundRanges === null || drawPositionsRoundRanges === void 0 ? void 0 : drawPositionsRoundRanges[roundPosition]
|
|
@@ -9788,18 +9794,17 @@ function getAllStructureMatchUps(_a) {
|
|
|
9788
9794
|
// if part of a tie matchUp and collectionDefinition has a category definition, prioritize
|
|
9789
9795
|
var matchUpCategory = (collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.category)
|
|
9790
9796
|
? __assign(__assign({}, ((context === null || context === void 0 ? void 0 : context.category) || {})), collectionDefinition.category) : context === null || context === void 0 ? void 0 : context.category;
|
|
9791
|
-
var processCodes = (((
|
|
9792
|
-
(((
|
|
9797
|
+
var processCodes = (((_o = matchUp.processCodes) === null || _o === void 0 ? void 0 : _o.length) && matchUp.processCodes) ||
|
|
9798
|
+
(((_p = collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.processCodes) === null || _p === void 0 ? void 0 : _p.length) &&
|
|
9793
9799
|
(collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.processCodes)) ||
|
|
9794
|
-
(((
|
|
9795
|
-
(((
|
|
9796
|
-
(((
|
|
9800
|
+
(((_q = structure === null || structure === void 0 ? void 0 : structure.processCodes) === null || _q === void 0 ? void 0 : _q.length) && (structure === null || structure === void 0 ? void 0 : structure.processCodes)) ||
|
|
9801
|
+
(((_r = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.processCodes) === null || _r === void 0 ? void 0 : _r.length) && (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.processCodes)) ||
|
|
9802
|
+
(((_s = event === null || event === void 0 ? void 0 : event.processCodes) === null || _s === void 0 ? void 0 : _s.length) && (event === null || event === void 0 ? void 0 : event.processCodes)) ||
|
|
9797
9803
|
(tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.processCodes);
|
|
9798
9804
|
var competitiveProfile = (contextProfile === null || contextProfile === void 0 ? void 0 : contextProfile.withCompetitiveness) &&
|
|
9799
9805
|
getMatchUpCompetitiveProfile(__assign(__assign({}, contextContent), { matchUp: matchUp }));
|
|
9800
9806
|
// necessry for SINGLES/DOUBLES matchUps that are part of TEAM tournaments
|
|
9801
|
-
var finishingPositionRange = matchUp.finishingPositionRange
|
|
9802
|
-
additionalContext.finishingPositionRange;
|
|
9807
|
+
var finishingPositionRange = (_t = matchUp.finishingPositionRange) !== null && _t !== void 0 ? _t : additionalContext.finishingPositionRange;
|
|
9803
9808
|
// order is important here as Round Robin matchUps already have inContext structureId
|
|
9804
9809
|
var onlyDefined = function (obj) { return definedAttributes(obj, undefined, true); };
|
|
9805
9810
|
var matchUpWithContext = __assign(__assign(__assign({}, onlyDefined(context)), onlyDefined({
|
|
@@ -9808,7 +9813,7 @@ function getAllStructureMatchUps(_a) {
|
|
|
9808
9813
|
roundOfPlay: stage !== QUALIFYING &&
|
|
9809
9814
|
isConvertableInteger(initialRoundOfPlay) &&
|
|
9810
9815
|
initialRoundOfPlay + (roundNumber || 0),
|
|
9811
|
-
endDate: matchUp.endDate
|
|
9816
|
+
endDate: (_u = matchUp.endDate) !== null && _u !== void 0 ? _u : endDate,
|
|
9812
9817
|
gender: collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.gender,
|
|
9813
9818
|
discipline: event === null || event === void 0 ? void 0 : event.discipline,
|
|
9814
9819
|
category: matchUpCategory,
|
|
@@ -9837,9 +9842,9 @@ function getAllStructureMatchUps(_a) {
|
|
|
9837
9842
|
drawId: drawId,
|
|
9838
9843
|
stage: stage,
|
|
9839
9844
|
})), makeDeepCopy(onlyDefined(matchUp), true, true));
|
|
9840
|
-
if (matchUpFormat && ((
|
|
9845
|
+
if (matchUpFormat && ((_v = matchUp.score) === null || _v === void 0 ? void 0 : _v.scoreStringSide1)) {
|
|
9841
9846
|
var parsedFormat = parse(matchUpFormat);
|
|
9842
|
-
var
|
|
9847
|
+
var _0 = parsedFormat !== null && parsedFormat !== void 0 ? parsedFormat : {}, bestOf_1 = _0.bestOf, finalSetFormat_1 = _0.finalSetFormat, setFormat_1 = _0.setFormat;
|
|
9843
9848
|
if ((finalSetFormat_1 === null || finalSetFormat_1 === void 0 ? void 0 : finalSetFormat_1.tiebreakSet) ||
|
|
9844
9849
|
(setFormat_1 === null || setFormat_1 === void 0 ? void 0 : setFormat_1.tiebreakSet) ||
|
|
9845
9850
|
(setFormat_1 === null || setFormat_1 === void 0 ? void 0 : setFormat_1.timed)) {
|
|
@@ -9859,12 +9864,12 @@ function getAllStructureMatchUps(_a) {
|
|
|
9859
9864
|
}
|
|
9860
9865
|
}
|
|
9861
9866
|
if (Array.isArray(drawPositions)) {
|
|
9862
|
-
var
|
|
9867
|
+
var _1 = getOrderedDrawPositions({
|
|
9863
9868
|
drawPositions: drawPositions,
|
|
9864
9869
|
roundProfile: roundProfile,
|
|
9865
9870
|
roundNumber: roundNumber,
|
|
9866
|
-
}), orderedDrawPositions =
|
|
9867
|
-
var isFeedRound_1 = (
|
|
9871
|
+
}), orderedDrawPositions = _1.orderedDrawPositions, displayOrder = _1.displayOrder;
|
|
9872
|
+
var isFeedRound_1 = (_w = roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[roundNumber]) === null || _w === void 0 ? void 0 : _w.feedRound;
|
|
9868
9873
|
var reversedDisplayOrder_1 = displayOrder[0] !== orderedDrawPositions[0];
|
|
9869
9874
|
// ensure there are two sides generated
|
|
9870
9875
|
var sideDrawPositions = orderedDrawPositions
|
|
@@ -9957,7 +9962,7 @@ function getAllStructureMatchUps(_a) {
|
|
|
9957
9962
|
}
|
|
9958
9963
|
var inferGender = (contextProfile === null || contextProfile === void 0 ? void 0 : contextProfile.inferGender) &&
|
|
9959
9964
|
(!matchUpWithContext.gender || matchUpWithContext.gender === MIXED) &&
|
|
9960
|
-
((
|
|
9965
|
+
((_x = matchUpWithContext.sides) === null || _x === void 0 ? void 0 : _x.length) === 2 &&
|
|
9961
9966
|
matchUpWithContext.matchUpType !== TEAM$1;
|
|
9962
9967
|
if (inferGender) {
|
|
9963
9968
|
var sideGenders = matchUpWithContext.sides.map(function (side) {
|
|
@@ -9979,7 +9984,7 @@ function getAllStructureMatchUps(_a) {
|
|
|
9979
9984
|
}
|
|
9980
9985
|
if (matchUpWithContext.tieMatchUps) {
|
|
9981
9986
|
var isCollectionBye_1 = matchUpWithContext.matchUpStatus === BYE;
|
|
9982
|
-
var lineUps_1 = (
|
|
9987
|
+
var lineUps_1 = (_y = matchUpWithContext.sides) === null || _y === void 0 ? void 0 : _y.map(function (_a) {
|
|
9983
9988
|
var participant = _a.participant, drawPosition = _a.drawPosition, sideNumber = _a.sideNumber, lineUp = _a.lineUp;
|
|
9984
9989
|
var teamParticipant = (participant === null || participant === void 0 ? void 0 : participant.participantType) === TEAM$1 && participant;
|
|
9985
9990
|
var teamParticipantValues = teamParticipant &&
|
|
@@ -10032,7 +10037,7 @@ function getAllStructureMatchUps(_a) {
|
|
|
10032
10037
|
var readyToScore = scoringActive && hasParticipants && hasNoWinner;
|
|
10033
10038
|
Object.assign(matchUpWithContext, { readyToScore: readyToScore, hasContext: true });
|
|
10034
10039
|
if (hasParticipants) {
|
|
10035
|
-
var
|
|
10040
|
+
var _2 = getCheckedInParticipantIds({ matchUp: matchUpWithContext }), allParticipantsCheckedIn = _2.allParticipantsCheckedIn, checkedInParticipantIds = _2.checkedInParticipantIds;
|
|
10036
10041
|
Object.assign(matchUpWithContext, {
|
|
10037
10042
|
allParticipantsCheckedIn: allParticipantsCheckedIn,
|
|
10038
10043
|
checkedInParticipantIds: checkedInParticipantIds,
|
|
@@ -11055,17 +11060,18 @@ function addUpcomingMatchUps(_a) {
|
|
|
11055
11060
|
var drawDefinition = _a.drawDefinition, inContextDrawMatchUps = _a.inContextDrawMatchUps;
|
|
11056
11061
|
var scheduleConflictMatchUpIds = {};
|
|
11057
11062
|
inContextDrawMatchUps.forEach(function (inContextMatchUp) {
|
|
11058
|
-
var _a, _b, _c, _d, _e;
|
|
11059
|
-
var matchUpId = inContextMatchUp.matchUpId, structureId = inContextMatchUp.structureId,
|
|
11063
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11064
|
+
var matchUpId = inContextMatchUp.matchUpId, structureId = inContextMatchUp.structureId, _g = inContextMatchUp.drawPositions, drawPositions = _g === void 0 ? [] : _g;
|
|
11060
11065
|
var structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure;
|
|
11061
11066
|
if ((structure === null || structure === void 0 ? void 0 : structure.finishingPosition) === WIN_RATIO) {
|
|
11062
11067
|
var roundNumber = inContextMatchUp.roundNumber;
|
|
11063
11068
|
var nextRoundNumber_1 = roundNumber && ensureInt(roundNumber) + 1;
|
|
11064
|
-
var matchUps = structure.matchUps
|
|
11069
|
+
var matchUps = (_a = structure.matchUps) !== null && _a !== void 0 ? _a : [];
|
|
11065
11070
|
var roundMatchUps_1 = getRoundMatchUps$1({ matchUps: matchUps }).roundMatchUps;
|
|
11066
11071
|
// if this is a round robin then we have sidesTo information, not winnerTo and loserTo
|
|
11067
11072
|
if (nextRoundNumber_1 && (roundMatchUps_1 === null || roundMatchUps_1 === void 0 ? void 0 : roundMatchUps_1[nextRoundNumber_1])) {
|
|
11068
|
-
var sidesTo =
|
|
11073
|
+
var sidesTo = __spreadArray([], __read(drawPositions), false).sort(numericSort)
|
|
11074
|
+
.map(function (drawPosition, index) {
|
|
11069
11075
|
var nextRoundMatchUp = roundMatchUps_1[nextRoundNumber_1].find(function (matchUp) { var _a; return (_a = matchUp.drawPositions) === null || _a === void 0 ? void 0 : _a.includes(drawPosition); });
|
|
11070
11076
|
return {
|
|
11071
11077
|
matchUpId: nextRoundMatchUp === null || nextRoundMatchUp === void 0 ? void 0 : nextRoundMatchUp.matchUpId,
|
|
@@ -11108,9 +11114,9 @@ function addUpcomingMatchUps(_a) {
|
|
|
11108
11114
|
loserTo;
|
|
11109
11115
|
}
|
|
11110
11116
|
// scheduleConflict in the following only applies to conflicts between subsequent matchUps WITHIN the same draw
|
|
11111
|
-
var timeAfterRecovery = (
|
|
11117
|
+
var timeAfterRecovery = (_b = inContextMatchUp.schedule) === null || _b === void 0 ? void 0 : _b.timeAfterRecovery;
|
|
11112
11118
|
if (timeAfterRecovery) {
|
|
11113
|
-
if ((
|
|
11119
|
+
if ((_c = winnerTo === null || winnerTo === void 0 ? void 0 : winnerTo.schedule) === null || _c === void 0 ? void 0 : _c.scheduledTime) {
|
|
11114
11120
|
var scheduleConflict = timeStringMinutes(winnerTo.schedule.scheduledTime) <
|
|
11115
11121
|
timeStringMinutes(timeAfterRecovery);
|
|
11116
11122
|
if (scheduleConflict) {
|
|
@@ -11119,7 +11125,7 @@ function addUpcomingMatchUps(_a) {
|
|
|
11119
11125
|
winnerTo.schedule.scheduleConflict = inContextMatchUp.matchUpId;
|
|
11120
11126
|
}
|
|
11121
11127
|
}
|
|
11122
|
-
if ((
|
|
11128
|
+
if ((_d = loserTo === null || loserTo === void 0 ? void 0 : loserTo.schedule) === null || _d === void 0 ? void 0 : _d.scheduledTime) {
|
|
11123
11129
|
var scheduleConflict = timeStringMinutes(loserTo.schedule.scheduledTime) <
|
|
11124
11130
|
timeStringMinutes(timeAfterRecovery);
|
|
11125
11131
|
if (scheduleConflict) {
|
|
@@ -11130,8 +11136,8 @@ function addUpcomingMatchUps(_a) {
|
|
|
11130
11136
|
}
|
|
11131
11137
|
}
|
|
11132
11138
|
Object.assign(inContextMatchUp, { winnerTo: winnerTo, loserTo: loserTo });
|
|
11133
|
-
if ((
|
|
11134
|
-
var loserTargetLink = (
|
|
11139
|
+
if ((_e = inContextMatchUp.drawPositions) === null || _e === void 0 ? void 0 : _e.filter(Boolean).length) {
|
|
11140
|
+
var loserTargetLink = (_f = targetData.targetLinks) === null || _f === void 0 ? void 0 : _f.loserTargetLink;
|
|
11135
11141
|
var firstMatchUp = (loserTargetLink === null || loserTargetLink === void 0 ? void 0 : loserTargetLink.linkCondition) === FIRST_MATCHUP;
|
|
11136
11142
|
var participants = getMatchUpParticipants(inContextMatchUp);
|
|
11137
11143
|
if (participants.length) {
|
|
@@ -12776,7 +12782,7 @@ function getScoreAnalysis(_a) {
|
|
|
12776
12782
|
var setFormat = (isDecidingSet && (matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.finalSetFormat)) ||
|
|
12777
12783
|
(matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.setFormat) ||
|
|
12778
12784
|
{};
|
|
12779
|
-
var isTimedSet =
|
|
12785
|
+
var isTimedSet = setFormat === null || setFormat === void 0 ? void 0 : setFormat.timed;
|
|
12780
12786
|
var finalSet = isDecidingSet && sets[(matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.bestOf) - 1];
|
|
12781
12787
|
var finalSetIsComplete = finalSet === null || finalSet === void 0 ? void 0 : finalSet.winningSide;
|
|
12782
12788
|
var isSetTiebreakEntry = testTiebreakEntry({
|
|
@@ -19458,7 +19464,7 @@ function getRoundRobinGroupMatchUps(_a) {
|
|
|
19458
19464
|
return { groupMatchUps: groupMatchUps, uniqueMatchUpGroupings: uniqueMatchUpGroupings };
|
|
19459
19465
|
}
|
|
19460
19466
|
function drawPositionsHash(drawPositions) {
|
|
19461
|
-
return drawPositions.sort(numericSort).join('|');
|
|
19467
|
+
return __spreadArray([], __read(drawPositions), false).sort(numericSort).join('|');
|
|
19462
19468
|
}
|
|
19463
19469
|
function groupRounds(_a) {
|
|
19464
19470
|
var groupSize = _a.groupSize, drawPositionOffset = _a.drawPositionOffset;
|
|
@@ -19483,8 +19489,7 @@ function groupRounds(_a) {
|
|
|
19483
19489
|
aRow = __spreadArray([aHead, bUp], __read(aRow), false).filter(Boolean);
|
|
19484
19490
|
bRow = __spreadArray(__spreadArray([], __read(bRow), false), [aDown], false).filter(Boolean);
|
|
19485
19491
|
var sum = function (x) { return x[0].reduce(function (a, b) { return a + b; }); };
|
|
19486
|
-
return rounds
|
|
19487
|
-
.reverse()
|
|
19492
|
+
return __spreadArray([], __read(rounds), false).reverse()
|
|
19488
19493
|
.sort(function (a, b) { return sum(a) - sum(b); })
|
|
19489
19494
|
.map(function (round) {
|
|
19490
19495
|
return round
|
|
@@ -39044,10 +39049,11 @@ function bulkRescheduleMatchUps$1(_a) {
|
|
|
39044
39049
|
doNotReschedule = newTime < 0 || newTime > dayTotalMinutes;
|
|
39045
39050
|
if (!doNotReschedule) {
|
|
39046
39051
|
var timeString = addMinutesToTimeString(scheduledTime, minutesChange);
|
|
39047
|
-
|
|
39048
|
-
scheduledTimeDate &&
|
|
39049
|
-
|
|
39050
|
-
|
|
39052
|
+
var timeStringDate = (scheduledTimeDate && newScheduledDate) ||
|
|
39053
|
+
(scheduledDate === scheduledTimeDate && scheduledTimeDate);
|
|
39054
|
+
newScheduledTime = timeStringDate
|
|
39055
|
+
? "".concat(timeStringDate, "T").concat(timeString)
|
|
39056
|
+
: timeString;
|
|
39051
39057
|
}
|
|
39052
39058
|
}
|
|
39053
39059
|
if (doNotReschedule) {
|