@vidispine/vdt-js 22.4.0-pre.9 → 22.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -25,25 +25,20 @@ var parseFileSize__default = /*#__PURE__*/_interopDefaultLegacy(parseFileSize);
25
25
  var gcd = function gcd(a, b) {
26
26
  return b ? gcd(b, a % b) : a;
27
27
  };
28
-
29
28
  var parseAspectRatio = function parseAspectRatio(aspectRatio) {
30
29
  var _ref = aspectRatio || {},
31
- width = _ref.width,
32
- height = _ref.height;
33
-
30
+ width = _ref.width,
31
+ height = _ref.height;
34
32
  if (width === undefined || height === undefined) {
35
33
  return undefined;
36
34
  }
37
-
38
35
  var denominator = gcd(width, height);
39
36
  var widthRatio = width / denominator;
40
37
  var heightRatio = height / denominator;
41
-
42
38
  if (widthRatio > 21) {
43
39
  heightRatio = 1;
44
40
  widthRatio = (width / height).toFixed(2);
45
41
  }
46
-
47
42
  return [widthRatio, heightRatio].join(':');
48
43
  };
49
44
 
@@ -57,7 +52,7 @@ var parseAspectRatio = function parseAspectRatio(aspectRatio) {
57
52
  var parseKeyValuePairTypes = function parseKeyValuePairTypes(keyValuePairTypes) {
58
53
  return Object.fromEntries(keyValuePairTypes.map(function (_ref) {
59
54
  var key = _ref.key,
60
- value = _ref.value;
55
+ value = _ref.value;
61
56
  return [key, value];
62
57
  }));
63
58
  };
@@ -181,26 +176,26 @@ var ROLE_NAMES = {
181
176
 
182
177
  var SHARED_ATTRIBUTE_KEYS = ['uuid', 'user', 'timestamp', 'change', 'conflict', 'mode'];
183
178
  var SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS = ['name', 'id', 'referenced', 'data', 'inheritance'];
179
+
184
180
  /**
185
181
  * Array with all available metadata group attributes
186
182
  *
187
183
  * @category Metadata
188
184
  */
189
-
190
185
  var GROUP_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS, ['cycle', 'field', 'group']);
186
+
191
187
  /**
192
188
  * Array with all available metadata group attributes
193
189
  *
194
190
  * @category Metadata
195
191
  */
196
-
197
192
  var FIELD_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS, ['value', 'reference', 'type', 'track']);
193
+
198
194
  /**
199
195
  * Array with all available metadata field value attributes
200
196
  *
201
197
  * @category Metadata
202
198
  */
203
-
204
199
  var FIELD_VALUE_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, ['value', 'lang']);
205
200
 
206
201
  /**
@@ -209,84 +204,66 @@ var FIELD_VALUE_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, ['value', 'lan
209
204
  * @category Metadata
210
205
  */
211
206
  var SYSTEM_FIELDGROUPS = ['stl_subtitle', 'stl_tti', 'stl_gsi', 'mrk_marker', 'pho_validation', 'pho_resource', 'pho_error', 'facedetect_rect', 'facedetect_face', 'originalTrackFilename', 'stl_gsiHeader'];
207
+
212
208
  /**
213
209
  * Array with all available VidiCore system/default field group names
214
210
  *
215
211
  * @category Metadata
216
212
  */
217
-
218
213
  var SYSTEM_FIELDS = ['title', 'user', 'shapeTag', 'representativeThumbnail', 'representativeThumbnailNoAuth', 'representativeItems', 'itemId', 'collectionId', 'mediaType', 'mimeType', 'created', 'startTimeCode', 'startSeconds', 'fieldValidationError', 'schemaValidationError', 'originalFilename', 'originalUri', 'originalAudioCodec', 'originalVideoCodec', 'originalHeight', 'originalWidth', 'originalFormat', 'durationSeconds', 'durationTimeCode', 'solr-index', '__user', '__collection', '__collection_size', '__ancestor_collection', '__ancestor_collection_size', '__shape', '__shape_size', '__shape_last_added', '__placeholder_shape_size', '__version', '__version_count', '__storage', '__storage_size', '__shapetag_{tag}_hash_{hash}', '__storage_{tag}', '__storage_{tag}_size', '__storagegroup', '__storagegroup_size', '__sequence', '__sequence_size', '__metadata_last_modified', '__external_id', '__deletion_lock_id', '__deletion_lock_expiry', '__child_collection', '__child_collection_size', '__parent_collection', '__parent_collection_size', '__items_size', 'stl_text', 'stl_justification', 'stl_xrelative', 'stl_yrelative', 'stl_vertical', 'stl_verticalbase', 'stl_horizontalbase', 'stl_sizerelative', 'stl_color', 'stl_outline', 'stl_outlinecolor', 'stl_outlinesize', 'stl_font', 'stl_service', 'stl_tti', 'stl_gsi', 'cct', 'tcd', 'tcf', 'oet', 'cd', 'mnc', 'cpn', 'dfc', 'tcp', 'tcs', 'tet', 'tnb', 'tnd', 'en', 'co', 'tng', 'rd', 'mnr', 'dsc', 'opt', 'lc', 'tpt', 'tn', 'slr', 'tns', 'rn', 'pub', 'dsn', 'ecd', 'mrk_zerolength', 'mrk_text', 'mrk_color', 'pho_resource_name', 'pho_error_level', 'pho_error_code', 'pho_error_description', 'facedetect_rect_width', 'facedetect_rect_height', 'facedetect_rect_y', 'facedetect_rect_x', 'facedetect_pid', 'facedetect_rect', 'trackId', 'eidr_actor', 'eidr_alternateId', 'eidr_countryOfOrigin', 'eidr_director', 'eidr_id', 'eidr_referentType', 'eidr_releaseDate', 'eidr_resourceName', 'eidr_status', 'eidr_sync', 'ttml_div', 'ttml_root', 'vxa_collection_id', 'vxaId', 'vxaLocalPath', 'tco', 'cs', 'ebn', 'tf', 'cf', 'sgn', 'tci', 'jc', 'vp', 'sn'];
219
214
 
220
215
  var _excluded$e = ["value"],
221
- _excluded2$2 = ["start", "end", "base"];
222
-
216
+ _excluded2$2 = ["start", "end", "base"];
223
217
  function ownKeys$i(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
224
-
225
218
  function _objectSpread$i(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$i(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$i(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
226
-
227
219
  var isValueObject = function isValueObject(o) {
228
220
  return Object.prototype.toString.call(o) === '[object Object]' && o.value !== undefined;
229
221
  };
230
-
231
222
  var isFieldType = function isFieldType(v) {
232
223
  return ['string', 'boolean', 'number'].includes(_typeof__default["default"](v));
233
224
  };
234
-
235
225
  var isFieldObject = function isFieldObject(o) {
236
226
  return isValueObject(o) && ((o === null || o === void 0 ? void 0 : o.value) === null || isValueObject(o.value) || isFieldType(o.value));
237
227
  };
238
-
239
228
  var isObject = function isObject(o) {
240
229
  return Object.prototype.toString.call(o) === '[object Object]';
241
230
  };
242
-
243
231
  var isDate = function isDate(o) {
244
232
  return Object.prototype.toString.call(o) === '[object Date]';
245
233
  };
246
-
247
234
  var isField = function isField(value) {
248
235
  if (value === null) {
249
236
  return true;
250
237
  }
251
-
252
238
  if (Array.isArray(value)) {
253
239
  return value.some(isField);
254
240
  }
255
-
256
241
  return isFieldType(value) || isFieldObject(value) || isDate(value);
257
242
  };
258
-
259
243
  var isGroup = function isGroup(value) {
260
244
  var isGroupObject = function isGroupObject(v) {
261
245
  return isObject(v) && v.value === undefined && !!Object.entries(value);
262
246
  };
263
-
264
247
  if (Array.isArray(value)) {
265
248
  return value.every(isGroup);
266
249
  }
267
-
268
250
  return isGroupObject(value);
269
251
  };
270
-
271
252
  var tryPluralize = function tryPluralize(str, arr) {
272
253
  return str + (arr.length > 1 ? 's' : '');
273
254
  };
274
-
275
255
  var ensureKeysAreValid = function ensureKeysAreValid(keysToCheck, keysToMatch) {
276
256
  var unsupportedKeys = keysToCheck.filter(function (k) {
277
257
  return !keysToMatch.includes(k);
278
258
  });
279
-
280
259
  if (unsupportedKeys.length) {
281
260
  throw Error("Unsupported ".concat(tryPluralize('key', unsupportedKeys), " (").concat(unsupportedKeys.join(', '), ")"));
282
261
  }
283
262
  };
284
-
285
263
  var parseValue$1 = function parseValue(value) {
286
264
  if (Array.isArray(value)) {
287
265
  throw Error('Invalid value inside value object, cannot be array');
288
266
  }
289
-
290
267
  if ([undefined, null].includes(value)) return {};
291
268
  if (isDate(value)) return {
292
269
  value: value.toISOString()
@@ -295,70 +272,55 @@ var parseValue$1 = function parseValue(value) {
295
272
  value: value.toString()
296
273
  };
297
274
  };
298
-
299
275
  var parseValueObject = function parseValueObject(valueObject) {
300
276
  ensureKeysAreValid(Object.keys(valueObject), FIELD_VALUE_ATTRIBUTE_KEYS);
301
-
302
277
  if (Object.keys(valueObject).length === 0) {
303
278
  throw Error('Invalid value object, cannot be empty object');
304
279
  }
305
-
306
280
  if (typeof (valueObject === null || valueObject === void 0 ? void 0 : valueObject.value) === 'string') {
307
281
  return valueObject;
308
282
  }
309
-
310
283
  var parsedValue = parseValue$1(valueObject === null || valueObject === void 0 ? void 0 : valueObject.value);
311
284
  return _objectSpread$i(_objectSpread$i({}, valueObject), parsedValue !== undefined ? parsedValue : {});
312
285
  };
313
-
314
286
  var parseFieldValue = function parseFieldValue(value) {
315
287
  if ([undefined, null].includes(value)) return undefined;
316
288
  if (Array.isArray(value)) return value.flatMap(parseFieldValue);
317
289
  if (isValueObject(value)) return parseValueObject(value);
318
290
  return parseValue$1(value);
319
291
  };
320
-
321
292
  var parseFieldObject = function parseFieldObject(fieldObject) {
322
293
  ensureKeysAreValid(Object.keys(fieldObject), FIELD_ATTRIBUTE_KEYS);
323
294
  var parsedFieldValue = parseFieldValue(fieldObject === null || fieldObject === void 0 ? void 0 : fieldObject.value);
324
-
325
295
  if (parsedFieldValue === undefined) {
326
296
  fieldObject.value;
327
- var fieldObjectWithoutValue = _objectWithoutProperties__default["default"](fieldObject, _excluded$e);
328
-
297
+ var fieldObjectWithoutValue = _objectWithoutProperties__default["default"](fieldObject, _excluded$e);
329
298
  return fieldObjectWithoutValue;
330
299
  }
331
-
332
300
  return _objectSpread$i(_objectSpread$i({}, fieldObject), {}, {
333
301
  value: _toConsumableArray__default["default"](Array.isArray(parsedFieldValue) ? parsedFieldValue : [parsedFieldValue])
334
302
  });
335
303
  };
336
-
337
304
  var parseField$1 = function parseField(field) {
338
305
  if (isFieldObject(field)) {
339
306
  return parseFieldObject(field);
340
307
  }
341
-
342
308
  var parsedFieldValue = parseFieldValue(field);
343
-
344
309
  if (parsedFieldValue === undefined) {
345
310
  return undefined;
346
311
  }
347
-
348
312
  return {
349
313
  value: _toConsumableArray__default["default"](Array.isArray(parsedFieldValue) ? parsedFieldValue : [parsedFieldValue])
350
314
  };
351
315
  };
352
-
353
316
  var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
354
317
  var group = [];
355
318
  var field = [];
356
319
  var groupAttributes = {};
357
320
  Object.entries(groupOrField || {}).forEach(function (_ref) {
358
321
  var _ref2 = _slicedToArray__default["default"](_ref, 2),
359
- name = _ref2[0],
360
- value = _ref2[1];
361
-
322
+ name = _ref2[0],
323
+ value = _ref2[1];
362
324
  if (GROUP_ATTRIBUTE_KEYS.includes(name)) {
363
325
  groupAttributes = _objectSpread$i(_objectSpread$i({}, groupAttributes), {}, _defineProperty__default["default"]({}, name, value));
364
326
  } else if (isField(value)) {
@@ -385,20 +347,17 @@ var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
385
347
  field: field
386
348
  } : {});
387
349
  };
388
-
389
350
  var parseTimespan$1 = function parseTimespan(timespan) {
390
351
  var _timespan$start = timespan.start,
391
- start = _timespan$start === void 0 ? '-INF' : _timespan$start,
392
- _timespan$end = timespan.end,
393
- end = _timespan$end === void 0 ? '+INF' : _timespan$end,
394
- _timespan$base = timespan.base,
395
- base = _timespan$base === void 0 ? undefined : _timespan$base,
396
- groupsAndFields = _objectWithoutProperties__default["default"](timespan, _excluded2$2);
397
-
352
+ start = _timespan$start === void 0 ? '-INF' : _timespan$start,
353
+ _timespan$end = timespan.end,
354
+ end = _timespan$end === void 0 ? '+INF' : _timespan$end,
355
+ _timespan$base = timespan.base,
356
+ base = _timespan$base === void 0 ? undefined : _timespan$base,
357
+ groupsAndFields = _objectWithoutProperties__default["default"](timespan, _excluded2$2);
398
358
  var _parseGroupsAndFields = parseGroupsAndFields(groupsAndFields),
399
- group = _parseGroupsAndFields.group,
400
- field = _parseGroupsAndFields.field;
401
-
359
+ group = _parseGroupsAndFields.group,
360
+ field = _parseGroupsAndFields.field;
402
361
  return _objectSpread$i(_objectSpread$i(_objectSpread$i({}, group ? {
403
362
  group: group
404
363
  } : {}), field ? {
@@ -410,7 +369,6 @@ var parseTimespan$1 = function parseTimespan(timespan) {
410
369
  base: base
411
370
  } : {});
412
371
  };
413
-
414
372
  /**
415
373
  * Create a VidiCore metadata object from a more dense/simplified structure
416
374
  *
@@ -442,23 +400,18 @@ var createMetadataType = function createMetadataType(input) {
442
400
  */
443
401
  var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
444
402
  var _timespan1$start, _timespan2$start;
445
-
446
403
  var _ref = (timespan1 === null || timespan1 === void 0 ? void 0 : (_timespan1$start = timespan1.start) === null || _timespan1$start === void 0 ? void 0 : _timespan1$start.split('@')) || [],
447
- _ref2 = _slicedToArray__default["default"](_ref, 1),
448
- firstStart = _ref2[0];
449
-
404
+ _ref2 = _slicedToArray__default["default"](_ref, 1),
405
+ firstStart = _ref2[0];
450
406
  var _ref3 = (timespan2 === null || timespan2 === void 0 ? void 0 : (_timespan2$start = timespan2.start) === null || _timespan2$start === void 0 ? void 0 : _timespan2$start.split('@')) || [],
451
- _ref4 = _slicedToArray__default["default"](_ref3, 1),
452
- secondStart = _ref4[0];
453
-
407
+ _ref4 = _slicedToArray__default["default"](_ref3, 1),
408
+ secondStart = _ref4[0];
454
409
  if (Number(firstStart) < Number(secondStart)) {
455
410
  return -1;
456
411
  }
457
-
458
412
  if (Number(firstStart) > Number(secondStart)) {
459
413
  return 1;
460
414
  }
461
-
462
415
  return 0;
463
416
  };
464
417
 
@@ -470,10 +423,10 @@ var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
470
423
  * @param v value to return as array
471
424
  * @returns input value wrapped as array
472
425
  */
473
-
474
426
  var asArray = function asArray(v) {
475
427
  return Array.isArray(v) ? v : v && [v] || [];
476
428
  };
429
+
477
430
  /**
478
431
  * @private
479
432
  *
@@ -482,10 +435,10 @@ var asArray = function asArray(v) {
482
435
  * @param v value to return as array
483
436
  * @returns input value wrapped as array
484
437
  */
485
-
486
438
  var asSingle = function asSingle(v) {
487
439
  return Array.isArray(v) ? v.pop() : v;
488
440
  };
441
+
489
442
  /**
490
443
  * @private
491
444
  * Check if array is string array (+ type guard)
@@ -493,7 +446,6 @@ var asSingle = function asSingle(v) {
493
446
  * @param arr Array to check if string array
494
447
  * @returns true if string array
495
448
  */
496
-
497
449
  var isStringArray = function isStringArray(arr) {
498
450
  return (arr === null || arr === void 0 ? void 0 : arr.every(function (v) {
499
451
  return typeof v === 'string';
@@ -501,14 +453,12 @@ var isStringArray = function isStringArray(arr) {
501
453
  };
502
454
 
503
455
  var _excluded$d = ["value"];
504
-
505
456
  function ownKeys$h(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
506
-
507
457
  function _objectSpread$h(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$h(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$h(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
508
-
509
458
  var defaultOptions$a = {
510
459
  includeValueAttributes: false
511
460
  };
461
+
512
462
  /**
513
463
  * @internal
514
464
  * Parse the value object inside a field value list
@@ -517,22 +467,17 @@ var defaultOptions$a = {
517
467
  * @param options For how to parse the value object
518
468
  * @returns The parsed value
519
469
  */
520
-
521
470
  function parseValue(value, options) {
522
471
  var _defaultOptions = _objectSpread$h(_objectSpread$h({}, defaultOptions$a), options || {}),
523
- includeValueAttributes = _defaultOptions.includeValueAttributes;
524
-
472
+ includeValueAttributes = _defaultOptions.includeValueAttributes;
525
473
  if (includeValueAttributes === false) {
526
474
  return value === null || value === void 0 ? void 0 : value.value;
527
475
  }
528
-
529
476
  var stringValue = value.value,
530
- attributes = _objectWithoutProperties__default["default"](value, _excluded$d);
531
-
477
+ attributes = _objectWithoutProperties__default["default"](value, _excluded$d);
532
478
  var valueAttributes = includeValueAttributes === true && attributes || Array.isArray(includeValueAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref) {
533
479
  var _ref2 = _slicedToArray__default["default"](_ref, 1),
534
- key = _ref2[0];
535
-
480
+ key = _ref2[0];
536
481
  return includeValueAttributes.includes(key);
537
482
  })) || {};
538
483
  return _objectSpread$h(_objectSpread$h({}, valueAttributes), {}, {
@@ -541,14 +486,13 @@ function parseValue(value, options) {
541
486
  }
542
487
 
543
488
  var _excluded$c = ["joinValue", "arrayOnSingleValue"];
544
-
545
489
  function ownKeys$g(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
546
-
547
490
  function _objectSpread$g(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$g(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$g(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
548
491
  var defaultOptions$9 = _objectSpread$g(_objectSpread$g({}, defaultOptions$a), {}, {
549
492
  joinValue: undefined,
550
493
  arrayOnSingleValue: true
551
494
  });
495
+
552
496
  /**
553
497
  * @internal
554
498
  *
@@ -556,13 +500,11 @@ var defaultOptions$9 = _objectSpread$g(_objectSpread$g({}, defaultOptions$a), {}
556
500
  * @param options
557
501
  * @returns
558
502
  */
559
-
560
503
  function parseValueList(valueList, options) {
561
504
  var _defaultOptions = _objectSpread$g(_objectSpread$g({}, defaultOptions$9), options || {}),
562
- joinValue = _defaultOptions.joinValue,
563
- arrayOnSingleValue = _defaultOptions.arrayOnSingleValue,
564
- parseValueOptions = _objectWithoutProperties__default["default"](_defaultOptions, _excluded$c);
565
-
505
+ joinValue = _defaultOptions.joinValue,
506
+ arrayOnSingleValue = _defaultOptions.arrayOnSingleValue,
507
+ parseValueOptions = _objectWithoutProperties__default["default"](_defaultOptions, _excluded$c);
566
508
  var parsedValueList = valueList === null || valueList === void 0 ? void 0 : valueList.map(function (v) {
567
509
  return parseValue(v, parseValueOptions);
568
510
  });
@@ -572,14 +514,13 @@ function parseValueList(valueList, options) {
572
514
  }
573
515
 
574
516
  var _excluded$b = ["includeFieldAttributes"],
575
- _excluded2$1 = ["value"];
576
-
517
+ _excluded2$1 = ["value"];
577
518
  function ownKeys$f(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
578
-
579
519
  function _objectSpread$f(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$f(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$f(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
580
520
  var defaultOptions$8 = _objectSpread$f({
581
521
  includeFieldAttributes: false
582
522
  }, defaultOptions$9);
523
+
583
524
  /**
584
525
  * @internal
585
526
  *
@@ -587,20 +528,16 @@ var defaultOptions$8 = _objectSpread$f({
587
528
  * @param options
588
529
  * @returns
589
530
  */
590
-
591
531
  var parseField = function parseField(field, options) {
592
532
  var _defaultOptions = _objectSpread$f(_objectSpread$f({}, defaultOptions$8), options || {}),
593
- includeFieldAttributes = _defaultOptions.includeFieldAttributes,
594
- parseValueListOptions = _objectWithoutProperties__default["default"](_defaultOptions, _excluded$b);
595
-
533
+ includeFieldAttributes = _defaultOptions.includeFieldAttributes,
534
+ parseValueListOptions = _objectWithoutProperties__default["default"](_defaultOptions, _excluded$b);
596
535
  var value = field.value,
597
- attributes = _objectWithoutProperties__default["default"](field, _excluded2$1);
598
-
536
+ attributes = _objectWithoutProperties__default["default"](field, _excluded2$1);
599
537
  var parsedValueList = parseValueList(value, parseValueListOptions);
600
538
  var fieldAttributes = includeFieldAttributes === true && attributes || Array.isArray(includeFieldAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref) {
601
539
  var _ref2 = _slicedToArray__default["default"](_ref, 1),
602
- key = _ref2[0];
603
-
540
+ key = _ref2[0];
604
541
  return includeFieldAttributes.includes(key);
605
542
  })) || {};
606
543
  return includeFieldAttributes ? _objectSpread$f(_objectSpread$f({}, fieldAttributes), {}, {
@@ -609,25 +546,22 @@ var parseField = function parseField(field, options) {
609
546
  };
610
547
 
611
548
  function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
612
-
613
549
  function _objectSpread$e(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$e(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$e(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
614
550
  var defaultOptions$7 = _objectSpread$e(_objectSpread$e({}, defaultOptions$8), {}, {
615
551
  fieldAsList: false,
616
552
  arrayOnSingleField: false,
617
553
  overrideField: undefined
618
554
  });
619
-
620
555
  /**
621
556
  * Parse a metadata field list according to selected options
622
557
  *
623
558
  * @remarks
624
- * Duplicate fields (same field name in the same field list) are usually not the data model we'd advise using.
625
- * Since VidiCore supports multiple values in one fields, it's typically advised to store them as such.
626
- * But, given duplicated fields when parsing it will:
627
- * - with default options, merge duplicated field values to one field value array
628
- * - with `fieldAsList` enabled, separate fields in the list/array (as usual, even if not duplicate)
629
- * - with `includeFieldAttributes` enabled, return an array of field objects
630
- * - with `overrideField` enabled - Override so it returns the latest "duplicated" field it parses
559
+ * When parsing duplicate fields (same field name in the same field list) it will:
560
+ * - with default options: combine field values to one array within the same field name key
561
+ * - with `joinValue` enabled: join values within each field (returns array with string for each field value)
562
+ * - with `fieldAsList` enabled: separate fields in the list/array (as usual, even if not duplicate)
563
+ * - with `includeFieldAttributes` enabled: return an array of field objects
564
+ * - with `overrideField` enabled: return the latest duplicated field it parses
631
565
  *
632
566
  * @param fieldList Field list to parse
633
567
  * @param [options=defaultOptions] Options for how to parse the field list
@@ -637,10 +571,9 @@ var defaultOptions$7 = _objectSpread$e(_objectSpread$e({}, defaultOptions$8), {}
637
571
  */
638
572
  var parseFieldList = function parseFieldList(fieldList, options) {
639
573
  var parseFieldListOptions = _objectSpread$e(_objectSpread$e({}, defaultOptions$7), options || {});
640
-
641
574
  var fieldAsList = parseFieldListOptions.fieldAsList,
642
- arrayOnSingleField = parseFieldListOptions.arrayOnSingleField,
643
- overrideField = parseFieldListOptions.overrideField;
575
+ arrayOnSingleField = parseFieldListOptions.arrayOnSingleField,
576
+ overrideField = parseFieldListOptions.overrideField;
644
577
  var shouldOverride = overrideField === true && fieldAsList === false;
645
578
  var output = {};
646
579
  fieldList === null || fieldList === void 0 ? void 0 : fieldList.forEach(function (field) {
@@ -654,18 +587,14 @@ var parseFieldList = function parseFieldList(fieldList, options) {
654
587
  };
655
588
 
656
589
  var _excluded$a = ["field", "group"];
657
-
658
590
  function ownKeys$d(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
659
-
660
591
  function _objectSpread$d(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$d(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$d(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
661
-
662
592
  var defaultParseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultOptions$7), {}, {
663
593
  includeGroupAttributes: false,
664
594
  groupAsList: false,
665
595
  arrayOnSingleGroup: false,
666
596
  overrideGroup: undefined
667
597
  });
668
-
669
598
  /**
670
599
  * @internal
671
600
  *
@@ -677,26 +606,21 @@ var defaultParseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultOption
677
606
  */
678
607
  var parseGroup = function parseGroup(group, options) {
679
608
  var parseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultParseGroupOptions), options || {});
680
-
681
609
  var includeGroupAttributes = parseGroupOptions.includeGroupAttributes;
682
610
  var parseFieldListOptions = Object.fromEntries(Object.entries(parseGroupOptions).filter(function (_ref) {
683
611
  var _ref2 = _slicedToArray__default["default"](_ref, 1),
684
- key = _ref2[0];
685
-
612
+ key = _ref2[0];
686
613
  return Object.keys(defaultOptions$7).includes(key);
687
614
  }));
688
-
689
615
  var fieldList = group.field,
690
- groupList = group.group,
691
- attributes = _objectWithoutProperties__default["default"](group, _excluded$a);
692
-
693
- var parsedFieldList = fieldList && parseFieldList(fieldList, parseFieldListOptions); // eslint-disable-next-line @typescript-eslint/no-use-before-define
694
-
616
+ groupList = group.group,
617
+ attributes = _objectWithoutProperties__default["default"](group, _excluded$a);
618
+ var parsedFieldList = fieldList && parseFieldList(fieldList, parseFieldListOptions);
619
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
695
620
  var parsedGroupList = groupList && parseGroupList(groupList, parseGroupOptions);
696
621
  var groupAttributes = includeGroupAttributes === true && attributes || Array.isArray(includeGroupAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref3) {
697
622
  var _ref4 = _slicedToArray__default["default"](_ref3, 1),
698
- key = _ref4[0];
699
-
623
+ key = _ref4[0];
700
624
  return includeGroupAttributes.includes(key);
701
625
  })) || {};
702
626
  return _objectSpread$d(_objectSpread$d(_objectSpread$d({}, groupAttributes), parseFieldListOptions !== null && parseFieldListOptions !== void 0 && parseFieldListOptions.fieldAsList ? parsedFieldList && {
@@ -705,16 +629,16 @@ var parseGroup = function parseGroup(group, options) {
705
629
  group: parsedGroupList
706
630
  } || {} : parsedGroupList);
707
631
  };
708
-
709
632
  var defaultOptions$6 = defaultParseGroupOptions;
633
+
710
634
  /**
711
635
  * Parse a metadata group list according to selected options
712
636
  *
713
637
  * @remarks
714
- * Parsing duplicate groups (with identical name) in the same group list will return:
715
- * - with default options, an array of group objects
716
- * - with `groupAsList` enabled, separate group objects in the list/array (as usual, even if not duplicate)
717
- * - with `overrideGroup` enabled, return the latest duplicated group it parses
638
+ * Parsing duplicate groups (same group name in the same group list) it will:
639
+ * - with default options: combine group objects to one array within the same group name key
640
+ * - with `groupAsList` enabled: return separate group objects in a list/array (as usual, even if not duplicate)
641
+ * - with `overrideGroup` enabled: return the latest duplicated group it parses
718
642
  *
719
643
  * @param groupList Group list to parse
720
644
  * @param options options for how to parse list
@@ -722,13 +646,11 @@ var defaultOptions$6 = defaultParseGroupOptions;
722
646
  *
723
647
  * @category Metadata
724
648
  */
725
-
726
649
  var parseGroupList = function parseGroupList(groupList, options) {
727
650
  var parseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultOptions$6), options || {});
728
-
729
651
  var groupAsList = parseGroupOptions.groupAsList,
730
- arrayOnSingleGroup = parseGroupOptions.arrayOnSingleGroup,
731
- overrideGroup = parseGroupOptions.overrideGroup;
652
+ arrayOnSingleGroup = parseGroupOptions.arrayOnSingleGroup,
653
+ overrideGroup = parseGroupOptions.overrideGroup;
732
654
  var shouldOverride = overrideGroup === true && groupAsList === false;
733
655
  var output = {};
734
656
  groupList === null || groupList === void 0 ? void 0 : groupList.forEach(function (group) {
@@ -738,18 +660,14 @@ var parseGroupList = function parseGroupList(groupList, options) {
738
660
  var existingParsedGroups = output[name];
739
661
  if (!existingParsedGroups) output[name] = parsedGroupOutput;else if (shouldOverride) output[name] = parsedGroup;else output[name] = [asArray(existingParsedGroups), asArray(parsedGroup)].flat();
740
662
  });
741
-
742
663
  if (groupAsList) {
743
664
  return Object.values(output).flat();
744
665
  }
745
-
746
666
  return output;
747
667
  };
748
668
 
749
669
  var _excluded$9 = ["field", "group"];
750
-
751
670
  function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
752
-
753
671
  function _objectSpread$c(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$c(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
754
672
  var defaultOptions$5 = _objectSpread$c(_objectSpread$c({}, defaultOptions$6), {}, {
755
673
  includeTimespanAttributes: false,
@@ -759,6 +677,7 @@ var defaultOptions$5 = _objectSpread$c(_objectSpread$c({}, defaultOptions$6), {}
759
677
  arrayOnSingleGroup: undefined,
760
678
  arrayOnSingleField: undefined
761
679
  });
680
+
762
681
  /**
763
682
  *
764
683
  * Parses timespan according to specified options
@@ -774,68 +693,55 @@ var defaultOptions$5 = _objectSpread$c(_objectSpread$c({}, defaultOptions$6), {}
774
693
  *
775
694
  * @category Metadata
776
695
  */
777
-
778
696
  var parseTimespan = function parseTimespan(timespan, options) {
779
697
  var parseTimespanOptions = _objectSpread$c(_objectSpread$c({}, defaultOptions$5), options || {});
780
-
781
698
  var includeTimespanAttributes = parseTimespanOptions.includeTimespanAttributes,
782
- arrayOnSingle = parseTimespanOptions.arrayOnSingle,
783
- flat = parseTimespanOptions.flat;
699
+ arrayOnSingle = parseTimespanOptions.arrayOnSingle,
700
+ flat = parseTimespanOptions.flat;
784
701
  var parseGroupListOptions = Object.fromEntries(Object.entries(options).map(function (_ref) {
785
702
  var _ref2 = _slicedToArray__default["default"](_ref, 2),
786
- key = _ref2[0],
787
- value = _ref2[1];
788
-
703
+ key = _ref2[0],
704
+ value = _ref2[1];
789
705
  if (Object.keys(defaultOptions$6).includes(key)) {
790
706
  if (['arrayOnSingleGroup', 'arrayOnSingleField', 'arrayOnSingleValue'].includes(key) && (value !== undefined ? value : arrayOnSingle === true)) {
791
707
  return [key, true];
792
708
  }
793
-
794
709
  if (['overrideGroup', 'overrideField'].includes(key) && (value !== undefined ? value : flat === true)) {
795
710
  return [key, true];
796
711
  }
797
-
798
712
  return [key, value];
799
713
  }
800
-
801
714
  return undefined;
802
715
  }).filter(function (e) {
803
716
  return !!e;
804
717
  }));
805
718
  var parseFieldListOptions = Object.fromEntries(Object.entries(options).map(function (_ref3) {
806
719
  var _ref4 = _slicedToArray__default["default"](_ref3, 2),
807
- key = _ref4[0],
808
- value = _ref4[1];
809
-
720
+ key = _ref4[0],
721
+ value = _ref4[1];
810
722
  if (Object.keys(defaultOptions$7).includes(key)) {
811
723
  if (['arrayOnSingleField', 'arrayOnSingleValue'].includes(key) && (value !== undefined ? value : arrayOnSingle === true)) {
812
724
  return [key, true];
813
725
  }
814
-
815
726
  if (['overrideField'].includes(key) && (value !== undefined ? value : flat === true)) {
816
727
  return [key, true];
817
728
  }
818
-
819
729
  return [key, value];
820
730
  }
821
-
822
731
  return undefined;
823
732
  }).filter(function (e) {
824
733
  return !!e;
825
734
  }));
826
-
827
735
  var _ref5 = timespan || {},
828
- fieldList = _ref5.field,
829
- groupList = _ref5.group,
830
- attributes = _objectWithoutProperties__default["default"](_ref5, _excluded$9);
831
-
832
- var parsedFieldList = fieldList && parseFieldList(fieldList, parseFieldListOptions); // eslint-disable-next-line @typescript-eslint/no-use-before-define
833
-
736
+ fieldList = _ref5.field,
737
+ groupList = _ref5.group,
738
+ attributes = _objectWithoutProperties__default["default"](_ref5, _excluded$9);
739
+ var parsedFieldList = fieldList && parseFieldList(fieldList, parseFieldListOptions);
740
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
834
741
  var parsedGroupList = groupList && parseGroupList(groupList, parseGroupListOptions);
835
742
  var timespanAttributes = includeTimespanAttributes === true && attributes || Array.isArray(includeTimespanAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref6) {
836
743
  var _ref7 = _slicedToArray__default["default"](_ref6, 1),
837
- key = _ref7[0];
838
-
744
+ key = _ref7[0];
839
745
  return includeTimespanAttributes.includes(key);
840
746
  })) || {};
841
747
  return _objectSpread$c(_objectSpread$c(_objectSpread$c({}, timespanAttributes), parseFieldListOptions !== null && parseFieldListOptions !== void 0 && parseFieldListOptions.fieldAsList ? {
@@ -846,9 +752,7 @@ var parseTimespan = function parseTimespan(timespan, options) {
846
752
  };
847
753
 
848
754
  var _excluded$8 = ["timespanAsList", "joinTimespan", "sortTimespan", "flat", "flatTimespan"];
849
-
850
755
  function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
851
-
852
756
  function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$b(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
853
757
  var defaultOptions$4 = _objectSpread$b(_objectSpread$b({}, defaultOptions$5), {}, {
854
758
  timespanAsList: false,
@@ -869,27 +773,23 @@ var defaultOptions$4 = _objectSpread$b(_objectSpread$b({}, defaultOptions$5), {}
869
773
  *
870
774
  * @category Metadata
871
775
  */
872
-
873
776
  var parseTimespanList = function parseTimespanList(timespanList, options) {
874
777
  var parseTimespanListOptions = _objectSpread$b(_objectSpread$b({}, defaultOptions$4), options || {});
875
-
876
778
  var timespanAsList = parseTimespanListOptions.timespanAsList,
877
- joinTimespan = parseTimespanListOptions.joinTimespan,
878
- sortTimespan = parseTimespanListOptions.sortTimespan,
879
- flat = parseTimespanListOptions.flat,
880
- flatTimespan = parseTimespanListOptions.flatTimespan,
881
- otherOptions = _objectWithoutProperties__default["default"](parseTimespanListOptions, _excluded$8);
882
-
779
+ joinTimespan = parseTimespanListOptions.joinTimespan,
780
+ sortTimespan = parseTimespanListOptions.sortTimespan,
781
+ flat = parseTimespanListOptions.flat,
782
+ flatTimespan = parseTimespanListOptions.flatTimespan,
783
+ otherOptions = _objectWithoutProperties__default["default"](parseTimespanListOptions, _excluded$8);
883
784
  var parseTimespanOptions = _objectSpread$b({
884
785
  flat: flat
885
786
  }, otherOptions);
886
-
887
787
  if (sortTimespan) timespanList.sort(sortTimespanList);
888
788
  var shouldFlatten = (flatTimespan !== undefined ? flatTimespan === true : flat === true) && timespanAsList === false;
889
789
  var output = {};
890
790
  timespanList === null || timespanList === void 0 ? void 0 : timespanList.forEach(function (timespan) {
891
791
  var start = timespan.start,
892
- end = timespan.end;
792
+ end = timespan.end;
893
793
  var key = shouldFlatten ? 'flat' : [start, end].join(joinTimespan);
894
794
  var parsedTimespan = parseTimespan(timespan, parseTimespanOptions);
895
795
  var existingParsedTimespans = output[key];
@@ -901,27 +801,23 @@ var parseTimespanList = function parseTimespanList(timespanList, options) {
901
801
  }
902
802
  } else output[key] = [].concat(_toConsumableArray__default["default"](asArray(existingParsedTimespans)), [parsedTimespan]);
903
803
  });
904
-
905
804
  if (timespanAsList === true) {
906
805
  return Object.values(output);
907
806
  }
908
-
909
807
  if (shouldFlatten) {
910
808
  return Object.values(output).pop();
911
809
  }
912
-
913
810
  return output;
914
811
  };
915
812
 
916
813
  var _excluded$7 = ["timespan"];
917
-
918
814
  function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
919
-
920
815
  function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$a(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
921
816
  var defaultOptions$3 = _objectSpread$a(_objectSpread$a({}, defaultOptions$4), {}, {
922
817
  includeMetadataAttributes: false,
923
818
  flat: false
924
819
  });
820
+
925
821
  /**
926
822
  * Parses MetadataType according to specified options
927
823
  *
@@ -938,31 +834,24 @@ var defaultOptions$3 = _objectSpread$a(_objectSpread$a({}, defaultOptions$4), {}
938
834
  *
939
835
  * @category Metadata
940
836
  */
941
-
942
837
  function parseMetadataType(metadataType, options) {
943
838
  var parseMetadataTypeOptions = _objectSpread$a(_objectSpread$a({}, defaultOptions$3), options || {});
944
-
945
839
  var includeMetadataAttributes = parseMetadataTypeOptions.includeMetadataAttributes,
946
- flat = parseMetadataTypeOptions.flat;
947
-
840
+ flat = parseMetadataTypeOptions.flat;
948
841
  var _ref = metadataType || {},
949
- _ref$timespan = _ref.timespan,
950
- timespanList = _ref$timespan === void 0 ? [] : _ref$timespan,
951
- attributes = _objectWithoutProperties__default["default"](_ref, _excluded$7);
952
-
842
+ _ref$timespan = _ref.timespan,
843
+ timespanList = _ref$timespan === void 0 ? [] : _ref$timespan,
844
+ attributes = _objectWithoutProperties__default["default"](_ref, _excluded$7);
953
845
  var parseTimespanListOptions = Object.fromEntries(Object.entries(options).map(function (_ref2) {
954
846
  var _ref3 = _slicedToArray__default["default"](_ref2, 2),
955
- key = _ref3[0],
956
- value = _ref3[1];
957
-
847
+ key = _ref3[0],
848
+ value = _ref3[1];
958
849
  if (Object.keys(defaultOptions$4).includes(key)) {
959
850
  if (['onlyGeneric', 'overrideGroup', 'overrideField'].includes(key) && (value !== undefined ? value : flat === true)) {
960
851
  return [key, true];
961
852
  }
962
-
963
853
  return [key, value];
964
854
  }
965
-
966
855
  return undefined;
967
856
  }).filter(function (e) {
968
857
  return !!e;
@@ -972,13 +861,11 @@ function parseMetadataType(metadataType, options) {
972
861
  revision: attributes.revision.split(',')
973
862
  } : {}) || Array.isArray(includeMetadataAttributes) && Object.fromEntries(Object.entries(attributes).map(function (_ref4) {
974
863
  var _ref5 = _slicedToArray__default["default"](_ref4, 2),
975
- key = _ref5[0],
976
- value = _ref5[1];
977
-
864
+ key = _ref5[0],
865
+ value = _ref5[1];
978
866
  if (includeMetadataAttributes.includes(key)) {
979
867
  return [key, key === 'revision' && typeof value === 'string' ? value.split(',') : value];
980
868
  }
981
-
982
869
  return undefined;
983
870
  }).filter(function (o) {
984
871
  return !!o;
@@ -998,12 +885,10 @@ function parseMetadataType(metadataType, options) {
998
885
  *
999
886
  * @category Metadata
1000
887
  */
1001
-
1002
888
  var parseSimpleMetadataType = function parseSimpleMetadataType(simpleMetadataType) {
1003
889
  var _ref = simpleMetadataType || {},
1004
- _ref$field = _ref.field,
1005
- field = _ref$field === void 0 ? [] : _ref$field;
1006
-
890
+ _ref$field = _ref.field,
891
+ field = _ref$field === void 0 ? [] : _ref$field;
1007
892
  return parseKeyValuePairTypes(field);
1008
893
  };
1009
894
 
@@ -1048,6 +933,7 @@ var TIME_BASE_CONSTANTS = Object.keys(MAP_CONSTANT_TO_DEN_NUM);
1048
933
  */
1049
934
  var TimeBase = /*#__PURE__*/function () {
1050
935
  // The numerator for the TimeBase
936
+
1051
937
  // The denominator for the TimeBase
1052
938
 
1053
939
  /**
@@ -1057,50 +943,42 @@ var TimeBase = /*#__PURE__*/function () {
1057
943
  */
1058
944
  function TimeBase(timeBaseType) {
1059
945
  _classCallCheck__default["default"](this, TimeBase);
1060
-
1061
946
  _defineProperty__default["default"](this, "numerator", 1);
1062
-
1063
947
  _defineProperty__default["default"](this, "denominator", 1);
1064
-
1065
948
  var _ref = timeBaseType || {},
1066
- _ref$numerator = _ref.numerator,
1067
- numerator = _ref$numerator === void 0 ? 1 : _ref$numerator,
1068
- _ref$denominator = _ref.denominator,
1069
- denominator = _ref$denominator === void 0 ? 1 : _ref$denominator;
1070
-
949
+ _ref$numerator = _ref.numerator,
950
+ numerator = _ref$numerator === void 0 ? 1 : _ref$numerator,
951
+ _ref$denominator = _ref.denominator,
952
+ denominator = _ref$denominator === void 0 ? 1 : _ref$denominator;
1071
953
  this.numerator = Number(numerator);
1072
954
  this.denominator = Number(denominator);
1073
955
  }
956
+
1074
957
  /**
1075
958
  * Get TimeBase in a constant representation (e.g. "PAL") if possible, otherwise undefined
1076
959
  * @returns Constant representation of the TimeBase
1077
960
  */
1078
-
1079
-
1080
961
  _createClass__default["default"](TimeBase, [{
1081
962
  key: "toConstant",
1082
963
  value: function toConstant() {
1083
964
  var _this = this;
1084
-
1085
- var constant; // If multiple equal den/num, it selects first in MAP_CONSTANT_TO_DEN_NUM
1086
-
965
+ var constant;
966
+ // If multiple equal den/num, it selects first in MAP_CONSTANT_TO_DEN_NUM
1087
967
  Object.entries(MAP_CONSTANT_TO_DEN_NUM).find(function (timeBaseConstant) {
1088
968
  var _timeBaseConstant = _slicedToArray__default["default"](timeBaseConstant, 2),
1089
- thisTimeBaseText = _timeBaseConstant[0],
1090
- thisTimeBaseType = _timeBaseConstant[1];
1091
-
969
+ thisTimeBaseText = _timeBaseConstant[0],
970
+ thisTimeBaseType = _timeBaseConstant[1];
1092
971
  var numerator = thisTimeBaseType.numerator,
1093
- denominator = thisTimeBaseType.denominator;
1094
-
972
+ denominator = thisTimeBaseType.denominator;
1095
973
  if (numerator === _this.numerator && denominator === _this.denominator) {
1096
974
  constant = thisTimeBaseText;
1097
975
  return true;
1098
976
  }
1099
-
1100
977
  return false;
1101
978
  });
1102
979
  return constant;
1103
980
  }
981
+
1104
982
  /**
1105
983
  * Get TimeBase as a VidiCore TimeBaseType string
1106
984
  *
@@ -1111,25 +989,21 @@ var TimeBase = /*#__PURE__*/function () {
1111
989
  * @param options For how to display it as text
1112
990
  * @returns Text representation of the TimeBase
1113
991
  */
1114
-
1115
992
  }, {
1116
993
  key: "toText",
1117
994
  value: function toText(options) {
1118
995
  if (options !== null && options !== void 0 && options.constant) {
1119
996
  var _timeBaseText = this.toConstant();
1120
-
1121
997
  if (_timeBaseText) return _timeBaseText;
1122
998
  }
1123
-
1124
999
  if (options !== null && options !== void 0 && options.fraction || this.numerator > 1) {
1125
1000
  var _timeBaseText2 = [this.denominator, this.numerator].join(':');
1126
-
1127
1001
  return _timeBaseText2;
1128
1002
  }
1129
-
1130
1003
  var timeBaseText = String(this.denominator);
1131
1004
  return timeBaseText;
1132
1005
  }
1006
+
1133
1007
  /**
1134
1008
  * Output TimeBase as frame rate (by default max 16 decimal places)
1135
1009
  *
@@ -1148,36 +1022,30 @@ var TimeBase = /*#__PURE__*/function () {
1148
1022
  *
1149
1023
  * @category Time
1150
1024
  */
1151
-
1152
1025
  }, {
1153
1026
  key: "toRate",
1154
1027
  value: function toRate(options) {
1155
1028
  var rate = this.denominator / this.numerator;
1156
-
1157
1029
  if (Number.isInteger(rate)) {
1158
1030
  return rate;
1159
1031
  }
1160
-
1161
1032
  if (options !== null && options !== void 0 && options.rounded) {
1162
1033
  return Math.round(rate);
1163
1034
  }
1164
-
1165
1035
  var _ref2 = options || {},
1166
- _ref2$fixed = _ref2.fixed,
1167
- fixed = _ref2$fixed === void 0 ? true : _ref2$fixed;
1168
-
1036
+ _ref2$fixed = _ref2.fixed,
1037
+ fixed = _ref2$fixed === void 0 ? true : _ref2$fixed;
1169
1038
  if (fixed === true || typeof fixed === 'number') {
1170
1039
  return Number(rate.toFixed(typeof fixed === 'boolean' ? 2 : fixed));
1171
1040
  }
1172
-
1173
1041
  return rate;
1174
1042
  }
1043
+
1175
1044
  /**
1176
1045
  * Get TimeBase in a object representation
1177
1046
  *
1178
1047
  * @returns TimeBase as `{denominator, numerator}` object
1179
1048
  */
1180
-
1181
1049
  }, {
1182
1050
  key: "toObject",
1183
1051
  value: function toObject() {
@@ -1186,12 +1054,12 @@ var TimeBase = /*#__PURE__*/function () {
1186
1054
  numerator: this.numerator
1187
1055
  };
1188
1056
  }
1057
+
1189
1058
  /**
1190
1059
  * @deprecated Use {@link TimeBase#toObject | toObject} instead
1191
1060
  *
1192
1061
  * @returns TimeBase as `{denominator, numerator}` object
1193
1062
  */
1194
-
1195
1063
  }, {
1196
1064
  key: "toJson",
1197
1065
  value: function toJson() {
@@ -1200,7 +1068,6 @@ var TimeBase = /*#__PURE__*/function () {
1200
1068
  return this.toObject();
1201
1069
  }
1202
1070
  }]);
1203
-
1204
1071
  return TimeBase;
1205
1072
  }();
1206
1073
 
@@ -1212,38 +1079,31 @@ var TimeBase = /*#__PURE__*/function () {
1212
1079
  *
1213
1080
  * @category Time
1214
1081
  */
1215
-
1216
1082
  var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
1217
1083
  if (timeBaseText === undefined) {
1218
1084
  return new TimeBase();
1219
1085
  }
1220
-
1221
1086
  if (typeof timeBaseText === 'number') {
1222
1087
  return new TimeBase({
1223
1088
  denominator: timeBaseText
1224
1089
  });
1225
1090
  }
1226
-
1227
1091
  if (typeof timeBaseText === 'string' && timeBaseText.includes(':')) {
1228
1092
  var _timeBaseText$split = timeBaseText.split(':'),
1229
- _timeBaseText$split2 = _slicedToArray__default["default"](_timeBaseText$split, 2),
1230
- denominator = _timeBaseText$split2[0],
1231
- numerator = _timeBaseText$split2[1];
1232
-
1093
+ _timeBaseText$split2 = _slicedToArray__default["default"](_timeBaseText$split, 2),
1094
+ denominator = _timeBaseText$split2[0],
1095
+ numerator = _timeBaseText$split2[1];
1233
1096
  return new TimeBase({
1234
1097
  denominator: denominator,
1235
1098
  numerator: numerator
1236
1099
  });
1237
1100
  }
1238
-
1239
1101
  if (TIME_BASE_CONSTANTS.includes(timeBaseText)) {
1240
1102
  return new TimeBase(MAP_CONSTANT_TO_DEN_NUM[timeBaseText]);
1241
1103
  }
1242
-
1243
1104
  if (!['string', 'number'].includes(_typeof__default["default"](timeBaseText)) || Number.isNaN(Number(timeBaseText))) {
1244
1105
  throw new Error("timeBaseText must be a number or ".concat(TIME_BASE_CONSTANTS.join(','), " - is ").concat(JSON.stringify(timeBaseText)));
1245
1106
  }
1246
-
1247
1107
  return new TimeBase({
1248
1108
  denominator: Number(timeBaseText)
1249
1109
  });
@@ -1273,7 +1133,6 @@ var createTimeBase = function createTimeBase(timeBase) {
1273
1133
  if (typeof timeBase === 'string' || typeof timeBase === 'number') {
1274
1134
  return formatTimeBaseText(timeBase);
1275
1135
  }
1276
-
1277
1136
  return formatTimeBaseType(timeBase);
1278
1137
  };
1279
1138
 
@@ -1298,16 +1157,14 @@ var getAmountOfFrameDrops = function getAmountOfFrameDrops(timeBase) {
1298
1157
  * @param timeBase TimeBase Instance to check
1299
1158
  * @returns true if time base drops frames, false otherwise
1300
1159
  */
1301
-
1302
1160
  var isDropFrameTimeBase = function isDropFrameTimeBase(timeBase) {
1303
1161
  return getAmountOfFrameDrops(timeBase) > 0;
1304
1162
  };
1305
1163
 
1306
1164
  var _excluded$6 = ["hours"];
1307
-
1308
1165
  var getDroppedFramesFromSamples = function getDroppedFramesFromSamples(timeCode) {
1309
1166
  var samples = timeCode.samples,
1310
- timeBase = timeCode.timeBase;
1167
+ timeBase = timeCode.timeBase;
1311
1168
  var amountOfFrameDrops = getAmountOfFrameDrops(timeBase);
1312
1169
  if (!amountOfFrameDrops) return 0;
1313
1170
  var roundedFrameRate = timeBase.toRate({
@@ -1323,7 +1180,6 @@ var getDroppedFramesFromSamples = function getDroppedFramesFromSamples(timeCode)
1323
1180
  var amountOfFrameRemainderChunks = frameRemainder > 0 ? amountOfFrameDrops : 0;
1324
1181
  return amountOfTenMinuteChunks * 9 * amountOfFrameDrops + amountOfOneMinuteReminderChunks * amountOfFrameDrops + amountOfFrameRemainderChunks;
1325
1182
  };
1326
-
1327
1183
  /**
1328
1184
  * TimeCode class representing the TimeCodeType in VidiCore
1329
1185
  *
@@ -1333,8 +1189,11 @@ var getDroppedFramesFromSamples = function getDroppedFramesFromSamples(timeCode)
1333
1189
  */
1334
1190
  var TimeCode = /*#__PURE__*/function () {
1335
1191
  // Amount of samples for the time code
1192
+
1336
1193
  // The time base for the time code
1194
+
1337
1195
  // If time code is dropFrame or not (by default checks timeBase)
1196
+
1338
1197
  // Separator for frame in smpte output (default ":" for non-drop-frame and ";" for dropFrame)
1339
1198
 
1340
1199
  /**
@@ -1345,21 +1204,14 @@ var TimeCode = /*#__PURE__*/function () {
1345
1204
  */
1346
1205
  function TimeCode(timeCodeType, options) {
1347
1206
  var _options$dropFrame, _options$frameSeparat;
1348
-
1349
1207
  _classCallCheck__default["default"](this, TimeCode);
1350
-
1351
1208
  _defineProperty__default["default"](this, "samples", 0);
1352
-
1353
1209
  _defineProperty__default["default"](this, "timeBase", new TimeBase());
1354
-
1355
1210
  _defineProperty__default["default"](this, "dropFrame", void 0);
1356
-
1357
1211
  _defineProperty__default["default"](this, "frameSeparator", void 0);
1358
-
1359
1212
  var _ref = timeCodeType || {},
1360
- samples = _ref.samples,
1361
- timeBase = _ref.timeBase;
1362
-
1213
+ samples = _ref.samples,
1214
+ timeBase = _ref.timeBase;
1363
1215
  if (samples !== undefined) {
1364
1216
  if (typeof samples === 'number') {
1365
1217
  this.samples = samples;
@@ -1375,7 +1227,6 @@ var TimeCode = /*#__PURE__*/function () {
1375
1227
  throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));
1376
1228
  }
1377
1229
  }
1378
-
1379
1230
  if (timeBase !== undefined) {
1380
1231
  if (timeBase instanceof TimeBase) {
1381
1232
  this.timeBase = timeBase;
@@ -1383,10 +1234,10 @@ var TimeCode = /*#__PURE__*/function () {
1383
1234
  this.timeBase = createTimeBase(timeBase);
1384
1235
  }
1385
1236
  }
1386
-
1387
1237
  this.dropFrame = (_options$dropFrame = options === null || options === void 0 ? void 0 : options.dropFrame) !== null && _options$dropFrame !== void 0 ? _options$dropFrame : isDropFrameTimeBase(this.timeBase);
1388
1238
  this.frameSeparator = (_options$frameSeparat = options === null || options === void 0 ? void 0 : options.frameSeparator) !== null && _options$frameSeparat !== void 0 ? _options$frameSeparat : this.dropFrame ? ';' : ':';
1389
1239
  }
1240
+
1390
1241
  /**
1391
1242
  * Return this TimeCode added with the supplied timeCodeType
1392
1243
  * If time bases differ, it will retain the time base of this TimeCode instance
@@ -1399,32 +1250,27 @@ var TimeCode = /*#__PURE__*/function () {
1399
1250
  * @param timeCode A TimeCode instance you want to add with
1400
1251
  * @returns A new TimeCode instance with the addition applied
1401
1252
  */
1402
-
1403
-
1404
1253
  _createClass__default["default"](TimeCode, [{
1405
1254
  key: "add",
1406
1255
  value: function add(timeCode) {
1407
1256
  if (!(timeCode !== null && timeCode !== void 0 && timeCode.timeBase) || (timeCode === null || timeCode === void 0 ? void 0 : timeCode.samples) === undefined) {
1408
1257
  throw Error('Invalid timeCodeType, cannot be added');
1409
1258
  }
1410
-
1411
1259
  var _ref2 = (timeCode === null || timeCode === void 0 ? void 0 : timeCode.timeBase) || {},
1412
- numerator = _ref2.numerator,
1413
- denominator = _ref2.denominator;
1414
-
1260
+ numerator = _ref2.numerator,
1261
+ denominator = _ref2.denominator;
1415
1262
  var conformedTimeCode = timeCode;
1416
-
1417
1263
  if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
1418
1264
  conformedTimeCode = timeCode.conformTimeBase(this.timeBase);
1419
1265
  }
1420
-
1421
1266
  var _conformedTimeCode = conformedTimeCode,
1422
- samples = _conformedTimeCode.samples;
1267
+ samples = _conformedTimeCode.samples;
1423
1268
  return new TimeCode({
1424
1269
  samples: this.samples + samples,
1425
1270
  timeBase: this.timeBase
1426
1271
  });
1427
1272
  }
1273
+
1428
1274
  /**
1429
1275
  * Return this TimeCode subtracted with the supplied timeCodeType
1430
1276
  * If time bases differ, it will retain the time base of the instance time code
@@ -1437,31 +1283,28 @@ var TimeCode = /*#__PURE__*/function () {
1437
1283
  * @param timeCode A TimeCode instance you want to subtract with
1438
1284
  * @returns A new TimeCode instance with the subtraction applied
1439
1285
  */
1440
-
1441
1286
  }, {
1442
1287
  key: "subtract",
1443
1288
  value: function subtract(timeCode) {
1444
1289
  if (!(timeCode !== null && timeCode !== void 0 && timeCode.timeBase) || (timeCode === null || timeCode === void 0 ? void 0 : timeCode.samples) === undefined) {
1445
1290
  throw Error('Invalid timeCodeType, cannot be subtracted');
1446
1291
  }
1447
-
1448
1292
  var _timeCode$timeBase = timeCode.timeBase;
1449
1293
  _timeCode$timeBase = _timeCode$timeBase === void 0 ? {} : _timeCode$timeBase;
1450
1294
  var numerator = _timeCode$timeBase.numerator,
1451
- denominator = _timeCode$timeBase.denominator;
1295
+ denominator = _timeCode$timeBase.denominator;
1452
1296
  var conformedTimeCode = timeCode;
1453
-
1454
1297
  if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
1455
1298
  conformedTimeCode = timeCode.conformTimeBase(this.timeBase);
1456
1299
  }
1457
-
1458
1300
  var _conformedTimeCode2 = conformedTimeCode,
1459
- samples = _conformedTimeCode2.samples;
1301
+ samples = _conformedTimeCode2.samples;
1460
1302
  return new TimeCode({
1461
1303
  samples: this.samples - samples,
1462
1304
  timeBase: this.timeBase
1463
1305
  });
1464
1306
  }
1307
+
1465
1308
  /**
1466
1309
  * Creates a new TimeCode instance with specified timeBase and samples adjusted to that.
1467
1310
  *
@@ -1471,7 +1314,6 @@ var TimeCode = /*#__PURE__*/function () {
1471
1314
  * @param timeBase The TimeBase it should conform the TimeCode to
1472
1315
  * @returns A new TimeCode instance with the conformTo timeBase applied
1473
1316
  */
1474
-
1475
1317
  }, {
1476
1318
  key: "conformTimeBase",
1477
1319
  value: function conformTimeBase(timeBase) {
@@ -1487,6 +1329,7 @@ var TimeCode = /*#__PURE__*/function () {
1487
1329
  };
1488
1330
  return new TimeCode(timeCode);
1489
1331
  }
1332
+
1490
1333
  /**
1491
1334
  * Get TimeCode as a text representation
1492
1335
  *
@@ -1499,39 +1342,36 @@ var TimeCode = /*#__PURE__*/function () {
1499
1342
  *
1500
1343
  * @category Time
1501
1344
  */
1502
-
1503
1345
  }, {
1504
1346
  key: "toText",
1505
1347
  value: function toText(options) {
1506
1348
  var timeCodeText = "".concat(this.samples);
1507
1349
  var timeBaseText = this.timeBase.toText(options);
1508
-
1509
1350
  if (options !== null && options !== void 0 && options.includeTimeBaseForSeconds || !['1', '1:1'].includes(timeBaseText)) {
1510
1351
  timeCodeText = [this.samples, timeBaseText].join('@');
1511
1352
  }
1512
-
1513
1353
  return timeCodeText;
1514
1354
  }
1355
+
1515
1356
  /**
1516
1357
  * Get TimeCode in a units object representation
1517
1358
  *
1518
1359
  * @returns Units (time and frames) for the time code
1519
1360
  */
1520
-
1521
1361
  }, {
1522
1362
  key: "toUnits",
1523
1363
  value: function toUnits() {
1524
1364
  var totalSamples = this.samples + (this.dropFrame ? getDroppedFramesFromSamples(this) : 0);
1525
1365
  var roundedFrameRate = this.timeBase.toRate({
1526
1366
  rounded: true
1527
- }); // Calculated without drop-frame but with 2 decimal places
1367
+ });
1528
1368
 
1369
+ // Calculated without drop-frame but with 2 decimal places
1529
1370
  if (['23.976', '23.98'].includes(this.timeBase.toConstant())) {
1530
1371
  roundedFrameRate = this.timeBase.toRate({
1531
1372
  fixed: true
1532
1373
  });
1533
1374
  }
1534
-
1535
1375
  var hours = Math.floor(totalSamples / (3600 * roundedFrameRate));
1536
1376
  var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
1537
1377
  var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
@@ -1543,23 +1383,21 @@ var TimeCode = /*#__PURE__*/function () {
1543
1383
  frames: frames
1544
1384
  };
1545
1385
  }
1386
+
1546
1387
  /**
1547
1388
  * Get TimeCode in a time object representation
1548
1389
  * "milliseconds" is rounded down, if you want another representation use "partialSeconds"
1549
1390
  *
1550
1391
  * @returns Time for the time code
1551
1392
  */
1552
-
1553
1393
  }, {
1554
1394
  key: "toTime",
1555
1395
  value: function toTime() {
1556
1396
  var totalSamples = this.samples + getDroppedFramesFromSamples(this);
1557
-
1558
1397
  var _this$toUnits = this.toUnits(),
1559
- hours = _this$toUnits.hours,
1560
- minutes = _this$toUnits.minutes,
1561
- seconds = _this$toUnits.seconds;
1562
-
1398
+ hours = _this$toUnits.hours,
1399
+ minutes = _this$toUnits.minutes,
1400
+ seconds = _this$toUnits.seconds;
1563
1401
  var roundedFrameRate = this.timeBase.toRate({
1564
1402
  rounded: true
1565
1403
  });
@@ -1574,20 +1412,21 @@ var TimeCode = /*#__PURE__*/function () {
1574
1412
  partialSeconds: partialSeconds
1575
1413
  };
1576
1414
  }
1415
+
1577
1416
  /**
1578
1417
  * Get TimeCode in a seconds representation
1579
1418
  *
1580
1419
  * @returns Total seconds for the time code
1581
1420
  */
1582
-
1583
1421
  }, {
1584
1422
  key: "toSeconds",
1585
1423
  value: function toSeconds() {
1586
1424
  var _this$timeBase = this.timeBase,
1587
- numerator = _this$timeBase.numerator,
1588
- denominator = _this$timeBase.denominator;
1425
+ numerator = _this$timeBase.numerator,
1426
+ denominator = _this$timeBase.denominator;
1589
1427
  return Math.round(1000 * +(this.samples * numerator / denominator)) / 1000;
1590
1428
  }
1429
+
1591
1430
  /**
1592
1431
  * Get TimeCode in a duration representation
1593
1432
  * The time unit char keys for the format string are:
@@ -1606,52 +1445,40 @@ var TimeCode = /*#__PURE__*/function () {
1606
1445
  * @param options Options for how to display duration
1607
1446
  * @returns Duration representation of the TimeCode
1608
1447
  */
1609
-
1610
1448
  }, {
1611
1449
  key: "toDuration",
1612
1450
  value: function toDuration(options) {
1613
1451
  var _ref3 = options || {},
1614
- format = _ref3.format;
1615
-
1452
+ format = _ref3.format;
1616
1453
  var _this$toTime = this.toTime(),
1617
- hours = _this$toTime.hours,
1618
- rest = _objectWithoutProperties__default["default"](_this$toTime, _excluded$6);
1619
-
1454
+ hours = _this$toTime.hours,
1455
+ rest = _objectWithoutProperties__default["default"](_this$toTime, _excluded$6);
1620
1456
  var minutes = rest.minutes,
1621
- seconds = rest.seconds,
1622
- milliseconds = rest.milliseconds;
1623
-
1457
+ seconds = rest.seconds,
1458
+ milliseconds = rest.milliseconds;
1624
1459
  if (!!format && typeof format !== 'string') {
1625
1460
  throw Error('format has to be a string');
1626
1461
  }
1627
-
1628
1462
  var isBefore = function isBefore(unit, units) {
1629
1463
  return !format.includes(unit) || !units.some(function (u) {
1630
1464
  return format.includes(u) && format.lastIndexOf(unit) > format.indexOf(u);
1631
1465
  });
1632
1466
  };
1633
-
1634
1467
  if (!!format && !(isBefore('h', ['m', 's', 'S']) && isBefore('m', ['s', 'S']) && isBefore('s', ['S']))) {
1635
1468
  throw Error('format order is unsupported (has to be h, m, s then S)');
1636
1469
  }
1637
-
1638
1470
  if (!format) {
1639
1471
  return "".concat(hours > 0 ? "".concat(hours, ":").concat("".concat(minutes).padStart(2, '0')) : minutes, ":").concat("".concat(seconds).padStart(2, '0'));
1640
1472
  }
1641
-
1642
1473
  var countConsecutiveChars = function countConsecutiveChars(i, arr) {
1643
1474
  var j = i;
1644
-
1645
1475
  while (arr[j] === arr[j + 1]) {
1646
1476
  j += 1;
1647
1477
  }
1648
-
1649
1478
  return j - i + 1;
1650
1479
  };
1651
-
1652
1480
  var timeUnitKeys = ['h', 'm', 's', 'S'];
1653
1481
  var output = [];
1654
-
1655
1482
  _toConsumableArray__default["default"](format).forEach(function (c, i, arr) {
1656
1483
  switch (c) {
1657
1484
  case 'h':
@@ -1659,108 +1486,85 @@ var TimeCode = /*#__PURE__*/function () {
1659
1486
  if (arr[i - 1] === 'h') {
1660
1487
  break;
1661
1488
  }
1662
-
1663
1489
  var amount = countConsecutiveChars(i, arr);
1664
1490
  output.push("".concat(hours).padStart(amount, '0'));
1665
-
1666
1491
  if (timeUnitKeys.includes(arr[i + amount])) {
1667
1492
  output.push(':');
1668
1493
  }
1669
-
1670
1494
  break;
1671
1495
  }
1672
-
1673
1496
  case 'm':
1674
1497
  {
1675
1498
  if (arr[i - 1] === 'm') {
1676
1499
  break;
1677
1500
  }
1678
-
1679
1501
  var _amount = countConsecutiveChars(i, arr);
1680
-
1681
1502
  if (!format.includes('h')) {
1682
1503
  minutes += hours * 60;
1683
1504
  }
1684
-
1685
1505
  output.push("".concat(minutes).padStart(_amount, '0'));
1686
-
1687
1506
  if (timeUnitKeys.includes(arr[i + _amount])) {
1688
1507
  output.push(':');
1689
1508
  }
1690
-
1691
1509
  break;
1692
1510
  }
1693
-
1694
1511
  case 's':
1695
1512
  {
1696
1513
  if (arr[i - 1] === 's') {
1697
1514
  break;
1698
1515
  }
1699
-
1700
1516
  var _amount2 = countConsecutiveChars(i, arr);
1701
-
1702
1517
  if (!format.includes('m')) {
1703
1518
  seconds += minutes * 60;
1704
1519
  }
1705
-
1706
1520
  output.push("".concat(seconds).padStart(_amount2, '0'));
1707
-
1708
1521
  if (timeUnitKeys.includes(arr[i + _amount2])) {
1709
1522
  output.push('.');
1710
1523
  }
1711
-
1712
1524
  break;
1713
1525
  }
1714
-
1715
1526
  case 'S':
1716
1527
  {
1717
1528
  if (arr[i - 1] === 'S') {
1718
1529
  break;
1719
1530
  }
1720
-
1721
1531
  var _amount3 = countConsecutiveChars(i, arr);
1722
-
1723
1532
  if (!format.includes('s')) {
1724
1533
  milliseconds += seconds * 1000;
1725
1534
  }
1726
-
1727
1535
  output.push("".concat(Math.round(milliseconds / Math.pow(10, 3 - _amount3))).padStart(_amount3, '0'));
1728
1536
  break;
1729
1537
  }
1730
-
1731
1538
  default:
1732
1539
  output.push(c);
1733
1540
  }
1734
1541
  });
1735
-
1736
1542
  return output.join('');
1737
1543
  }
1544
+
1738
1545
  /**
1739
1546
  * Get TimeCode in a smpte representation
1740
1547
  *
1741
1548
  * @returns Smpte representation of the TimeCode
1742
1549
  */
1743
-
1744
1550
  }, {
1745
1551
  key: "toSmpte",
1746
1552
  value: function toSmpte() {
1747
1553
  if (this.samples === -Infinity) return '00:00:00:00';
1748
-
1749
1554
  var _this$toUnits2 = this.toUnits(),
1750
- hours = _this$toUnits2.hours,
1751
- minutes = _this$toUnits2.minutes,
1752
- seconds = _this$toUnits2.seconds,
1753
- frames = _this$toUnits2.frames;
1754
-
1555
+ hours = _this$toUnits2.hours,
1556
+ minutes = _this$toUnits2.minutes,
1557
+ seconds = _this$toUnits2.seconds,
1558
+ frames = _this$toUnits2.frames;
1755
1559
  var hhmmss = [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1756
1560
  return [hhmmss, "".concat(frames).padStart(2, '0')].join(this.frameSeparator);
1757
1561
  }
1562
+
1758
1563
  /**
1759
1564
  * Get TimeCode as a VidiCore TimeCodeType object
1760
1565
  *
1761
1566
  * @returns TimeCode as `{ samples, timeBase }`
1762
1567
  */
1763
-
1764
1568
  }, {
1765
1569
  key: "toObject",
1766
1570
  value: function toObject() {
@@ -1769,12 +1573,12 @@ var TimeCode = /*#__PURE__*/function () {
1769
1573
  timeBase: this.timeBase.toObject()
1770
1574
  };
1771
1575
  }
1576
+
1772
1577
  /**
1773
1578
  * @deprecated Use {@link TimeCode#toObject | toObject} instead
1774
1579
  *
1775
1580
  * @returns TimeCode as `{ samples, timeBase }`
1776
1581
  */
1777
-
1778
1582
  }, {
1779
1583
  key: "toJson",
1780
1584
  value: function toJson() {
@@ -1783,7 +1587,6 @@ var TimeCode = /*#__PURE__*/function () {
1783
1587
  return this.toObject();
1784
1588
  }
1785
1589
  }]);
1786
-
1787
1590
  return TimeCode;
1788
1591
  }();
1789
1592
 
@@ -1801,7 +1604,6 @@ var TimeCode = /*#__PURE__*/function () {
1801
1604
  var getGreatestCommonDivisor = function getGreatestCommonDivisor(num1, num2) {
1802
1605
  var a = Math.abs(num1);
1803
1606
  var b = Math.abs(num2);
1804
-
1805
1607
  while (a && b && a !== b) {
1806
1608
  if (a > b) {
1807
1609
  var _ref = [a - b, b];
@@ -1813,12 +1615,10 @@ var getGreatestCommonDivisor = function getGreatestCommonDivisor(num1, num2) {
1813
1615
  b = _ref2[1];
1814
1616
  }
1815
1617
  }
1816
-
1817
1618
  return a || b;
1818
1619
  };
1819
1620
 
1820
1621
  var _excluded$5 = ["timeBase", "useGCD"];
1821
-
1822
1622
  /**
1823
1623
  * Format seconds to TimeCode object
1824
1624
  * Input time base is always 1:1 since it expects seconds as input
@@ -1836,40 +1636,32 @@ var _excluded$5 = ["timeBase", "useGCD"];
1836
1636
  */
1837
1637
  var formatTimeCodeSeconds = function formatTimeCodeSeconds(seconds, options) {
1838
1638
  var _ref = options || {},
1839
- timeBase = _ref.timeBase,
1840
- _ref$useGCD = _ref.useGCD,
1841
- useGCD = _ref$useGCD === void 0 ? false : _ref$useGCD,
1842
- timeCodeOptions = _objectWithoutProperties__default["default"](_ref, _excluded$5);
1843
-
1639
+ timeBase = _ref.timeBase,
1640
+ _ref$useGCD = _ref.useGCD,
1641
+ useGCD = _ref$useGCD === void 0 ? false : _ref$useGCD,
1642
+ timeCodeOptions = _objectWithoutProperties__default["default"](_ref, _excluded$5);
1844
1643
  var secondsWithDot = "".concat(seconds).replace(/,/g, '.');
1845
-
1846
1644
  if (Number.isNaN(+secondsWithDot)) {
1847
1645
  throw new Error("seconds must be digits, is ".concat(seconds));
1848
1646
  }
1849
-
1850
1647
  var denominator = 1;
1851
1648
  var samples;
1852
-
1853
1649
  if (Number.isInteger(+secondsWithDot)) {
1854
1650
  samples = +secondsWithDot * denominator;
1855
1651
  } else {
1856
1652
  var _ms$length;
1857
-
1858
1653
  var _secondsWithDot$split = secondsWithDot.split('.'),
1859
- _secondsWithDot$split2 = _slicedToArray__default["default"](_secondsWithDot$split, 2),
1860
- ms = _secondsWithDot$split2[1];
1861
-
1654
+ _secondsWithDot$split2 = _slicedToArray__default["default"](_secondsWithDot$split, 2),
1655
+ ms = _secondsWithDot$split2[1];
1862
1656
  var decimalPlaces = Math.min((_ms$length = ms === null || ms === void 0 ? void 0 : ms.length) !== null && _ms$length !== void 0 ? _ms$length : 0, 16);
1863
1657
  denominator *= Math.pow(10, decimalPlaces);
1864
1658
  samples = Math.round(Number(secondsWithDot) * denominator);
1865
1659
  }
1866
-
1867
1660
  if (timeBase === undefined && useGCD) {
1868
1661
  var gcd = getGreatestCommonDivisor(denominator, samples);
1869
1662
  samples /= gcd;
1870
1663
  denominator /= gcd;
1871
1664
  }
1872
-
1873
1665
  var timeCode = new TimeCode({
1874
1666
  samples: samples,
1875
1667
  timeBase: {
@@ -1877,47 +1669,40 @@ var formatTimeCodeSeconds = function formatTimeCodeSeconds(seconds, options) {
1877
1669
  numerator: 1
1878
1670
  }
1879
1671
  }, timeCodeOptions);
1880
- return timeBase !== undefined ? timeCode.conformTimeBase(createTimeBase(timeBase === true ? 1 : timeBase)) : timeCode;
1672
+ return timeBase !== undefined ? timeCode.conformTimeBase(createTimeBase(timeBase)) : timeCode;
1881
1673
  };
1882
1674
 
1883
1675
  var getDroppedFramesFromSmpte = function getDroppedFramesFromSmpte(_ref, samples, timeBase) {
1884
1676
  var _ref2 = _slicedToArray__default["default"](_ref, 4),
1885
- hh = _ref2[0],
1886
- mm = _ref2[1],
1887
- ss = _ref2[2],
1888
- ff = _ref2[3];
1889
-
1677
+ hh = _ref2[0],
1678
+ mm = _ref2[1],
1679
+ ss = _ref2[2],
1680
+ ff = _ref2[3];
1890
1681
  var roundedFrameRate = timeBase.toRate({
1891
1682
  rounded: true
1892
1683
  });
1893
1684
  var dropFrames = getAmountOfFrameDrops(timeBase);
1894
-
1895
1685
  if (samples === 0 || !dropFrames) {
1896
1686
  return 0;
1897
1687
  }
1898
-
1899
1688
  var shouldDropMinute = mm % 10 !== 0;
1900
1689
  var shouldDropSecond = shouldDropMinute && ss === 0;
1901
1690
  var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
1902
1691
  var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
1903
1692
  var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
1904
-
1905
1693
  if (shouldDropSecond && ff < dropFrames) {
1906
1694
  throw new Error("Frame does not exist for ".concat(timeBase.toConstant() || timeBase.toRate(), " drop-frame"));
1907
1695
  }
1908
-
1909
1696
  var frameFrames = shouldDropSecond ? ff - dropFrames : ff;
1910
1697
  var samplesWithoutDroppedFrames = hourFrames + minuteFrames + secondFrames + frameFrames;
1911
1698
  return samples - samplesWithoutDroppedFrames;
1912
1699
  };
1913
-
1914
1700
  var getSamplesFromSmpte = function getSamplesFromSmpte(smpteValues, timeBase, dropFrame) {
1915
1701
  var _smpteValues = _slicedToArray__default["default"](smpteValues, 4),
1916
- hh = _smpteValues[0],
1917
- mm = _smpteValues[1],
1918
- ss = _smpteValues[2],
1919
- ff = _smpteValues[3];
1920
-
1702
+ hh = _smpteValues[0],
1703
+ mm = _smpteValues[1],
1704
+ ss = _smpteValues[2],
1705
+ ff = _smpteValues[3];
1921
1706
  var roundedFrameRate = timeBase.toRate({
1922
1707
  rounded: true
1923
1708
  });
@@ -1927,32 +1712,26 @@ var getSamplesFromSmpte = function getSamplesFromSmpte(smpteValues, timeBase, dr
1927
1712
 
1928
1713
  var splitSmpte = function splitSmpte(smpte) {
1929
1714
  var _ref = (smpte === null || smpte === void 0 ? void 0 : smpte.match(/[^0-9:\-_]/)) || [],
1930
- _ref2 = _slicedToArray__default["default"](_ref, 1),
1931
- nonColonFrameSeparator = _ref2[0];
1932
-
1715
+ _ref2 = _slicedToArray__default["default"](_ref, 1),
1716
+ nonColonFrameSeparator = _ref2[0];
1933
1717
  var smpteValues = [];
1934
-
1935
1718
  if (nonColonFrameSeparator) {
1936
1719
  var _smpte$split = smpte.split(nonColonFrameSeparator),
1937
- _smpte$split2 = _slicedToArray__default["default"](_smpte$split, 2),
1938
- hhmmss = _smpte$split2[0],
1939
- ff = _smpte$split2[1];
1940
-
1720
+ _smpte$split2 = _slicedToArray__default["default"](_smpte$split, 2),
1721
+ hhmmss = _smpte$split2[0],
1722
+ ff = _smpte$split2[1];
1941
1723
  smpteValues = [].concat(_toConsumableArray__default["default"](hhmmss.split(':')), [ff]);
1942
1724
  } else {
1943
1725
  smpteValues = smpte.split(':');
1944
1726
  }
1945
-
1946
1727
  if (smpteValues.length !== 4) {
1947
1728
  throw new Error('Invalid format, must be "##:##:##:##');
1948
1729
  }
1949
-
1950
1730
  if (smpteValues.some(function (n) {
1951
1731
  return Number.isNaN(n);
1952
1732
  })) {
1953
1733
  throw new Error('Invalid format, values must be numbers');
1954
1734
  }
1955
-
1956
1735
  var smpteFrameSeparator = nonColonFrameSeparator || ':';
1957
1736
  return {
1958
1737
  smpteValues: smpteValues.map(Number),
@@ -1961,12 +1740,9 @@ var splitSmpte = function splitSmpte(smpte) {
1961
1740
  };
1962
1741
 
1963
1742
  var _excluded$4 = ["exceedingMode", "timeBase"];
1964
-
1965
1743
  function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1966
-
1967
1744
  function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1968
1745
  var EXCEEDING_OPTIONS = ['error', 'add', 'ignore'];
1969
-
1970
1746
  /**
1971
1747
  * Format smpte text to a TimeCode Instance
1972
1748
  *
@@ -1983,98 +1759,79 @@ var EXCEEDING_OPTIONS = ['error', 'add', 'ignore'];
1983
1759
  */
1984
1760
  var formatTimeCodeSmpte = function formatTimeCodeSmpte(smpte, options) {
1985
1761
  var _ref = options || {},
1986
- _ref$exceedingMode = _ref.exceedingMode,
1987
- exceedingMode = _ref$exceedingMode === void 0 ? 'error' : _ref$exceedingMode,
1988
- timeBase = _ref.timeBase,
1989
- timeCodeOptions = _objectWithoutProperties__default["default"](_ref, _excluded$4);
1990
-
1762
+ _ref$exceedingMode = _ref.exceedingMode,
1763
+ exceedingMode = _ref$exceedingMode === void 0 ? 'error' : _ref$exceedingMode,
1764
+ timeBase = _ref.timeBase,
1765
+ timeCodeOptions = _objectWithoutProperties__default["default"](_ref, _excluded$4);
1991
1766
  if ([null, undefined].includes(smpte)) {
1992
1767
  throw new Error("smpte cannot be undefined or null");
1993
1768
  }
1994
-
1995
1769
  if (typeof smpte !== 'string') {
1996
1770
  throw new Error("smpte must be a string, is ".concat(JSON.stringify(smpte)));
1997
1771
  }
1998
-
1999
1772
  var _splitSmpte = splitSmpte(smpte),
2000
- smpteValues = _splitSmpte.smpteValues,
2001
- smpteFrameSeparator = _splitSmpte.smpteFrameSeparator;
2002
-
1773
+ smpteValues = _splitSmpte.smpteValues,
1774
+ smpteFrameSeparator = _splitSmpte.smpteFrameSeparator;
2003
1775
  var timeBaseInstance = createTimeBase(timeBase);
2004
-
2005
1776
  var mergedOptions = _objectSpread$9(_objectSpread$9({}, timeCodeOptions), {}, {
2006
1777
  frameSeparator: (timeCodeOptions === null || timeCodeOptions === void 0 ? void 0 : timeCodeOptions.frameSeparator) || smpteFrameSeparator
2007
1778
  }, (timeCodeOptions === null || timeCodeOptions === void 0 ? void 0 : timeCodeOptions.dropFrame) === undefined ? {
2008
1779
  dropFrame: timeBase !== undefined ? isDropFrameTimeBase(timeBaseInstance) : [';', ','].includes(smpteFrameSeparator)
2009
1780
  } : {});
2010
-
2011
1781
  var roundedFrameRate = timeBaseInstance.toRate({
2012
1782
  rounded: true
2013
1783
  });
2014
1784
  var maxFrame = Math.max(0, roundedFrameRate - 1);
2015
-
2016
1785
  if (smpteValues.some(function (v) {
2017
1786
  return v < 0;
2018
1787
  })) {
2019
1788
  throw new Error('Negative values are not supported');
2020
1789
  }
2021
-
2022
1790
  var samples;
2023
-
2024
1791
  switch (exceedingMode) {
2025
1792
  case 'error':
2026
1793
  {
2027
1794
  var _smpteValues = _slicedToArray__default["default"](smpteValues, 4),
2028
- hours = _smpteValues[0],
2029
- minutes = _smpteValues[1],
2030
- seconds = _smpteValues[2],
2031
- frames = _smpteValues[3];
2032
-
1795
+ hours = _smpteValues[0],
1796
+ minutes = _smpteValues[1],
1797
+ seconds = _smpteValues[2],
1798
+ frames = _smpteValues[3];
2033
1799
  if (hours >= 100) {
2034
1800
  throw Error('Minutes has to be less than 60');
2035
1801
  }
2036
-
2037
1802
  if (minutes >= 60) {
2038
1803
  throw Error('Minutes has to be less than 60');
2039
1804
  }
2040
-
2041
1805
  if (seconds >= 60) {
2042
1806
  throw Error('Seconds has to be less than 60');
2043
1807
  }
2044
-
2045
1808
  if (frames > maxFrame) {
2046
1809
  throw Error("Frames has to be less or equal to ".concat(maxFrame));
2047
1810
  }
2048
-
2049
1811
  samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
2050
1812
  break;
2051
1813
  }
2052
-
2053
1814
  case 'ignore':
2054
1815
  {
2055
1816
  var _smpteValues2 = _slicedToArray__default["default"](smpteValues, 4),
2056
- _hours = _smpteValues2[0],
2057
- _minutes = _smpteValues2[1],
2058
- _seconds = _smpteValues2[2],
2059
- _frames = _smpteValues2[3];
2060
-
1817
+ _hours = _smpteValues2[0],
1818
+ _minutes = _smpteValues2[1],
1819
+ _seconds = _smpteValues2[2],
1820
+ _frames = _smpteValues2[3];
2061
1821
  var truncatedSmpteValues = [Math.min(100, _hours), Math.min(59, _minutes), Math.min(59, _seconds), Math.min(maxFrame, _frames)];
2062
1822
  samples = getSamplesFromSmpte(truncatedSmpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
2063
1823
  break;
2064
1824
  }
2065
-
2066
1825
  case 'add':
2067
1826
  {
2068
1827
  samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
2069
1828
  break;
2070
1829
  }
2071
-
2072
1830
  default:
2073
1831
  {
2074
1832
  throw new Error("Invalid exceedingMode, options are ".concat(JSON.stringify(EXCEEDING_OPTIONS)));
2075
1833
  }
2076
1834
  }
2077
-
2078
1835
  return new TimeCode({
2079
1836
  samples: samples,
2080
1837
  timeBase: timeBaseInstance
@@ -2082,7 +1839,6 @@ var formatTimeCodeSmpte = function formatTimeCodeSmpte(smpte, options) {
2082
1839
  };
2083
1840
 
2084
1841
  var _excluded$3 = ["timeBase"];
2085
-
2086
1842
  /**
2087
1843
  * Format text to a TimeCode instance
2088
1844
  *
@@ -2092,13 +1848,10 @@ var _excluded$3 = ["timeBase"];
2092
1848
  */
2093
1849
  var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
2094
1850
  var _timeCodeObject;
2095
-
2096
1851
  var _ref = options || {},
2097
- timeBase = _ref.timeBase,
2098
- timeCodeOptions = _objectWithoutProperties__default["default"](_ref, _excluded$3);
2099
-
1852
+ timeBase = _ref.timeBase,
1853
+ timeCodeOptions = _objectWithoutProperties__default["default"](_ref, _excluded$3);
2100
1854
  var timeCodeObject;
2101
-
2102
1855
  if (timeCodeText === undefined) {
2103
1856
  timeCodeObject = {
2104
1857
  samples: 0
@@ -2109,10 +1862,9 @@ var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
2109
1862
  };
2110
1863
  } else if (timeCodeText.includes('@')) {
2111
1864
  var _timeCodeText$split = timeCodeText.split('@'),
2112
- _timeCodeText$split2 = _slicedToArray__default["default"](_timeCodeText$split, 2),
2113
- samplesString = _timeCodeText$split2[0],
2114
- timeBaseText = _timeCodeText$split2[1];
2115
-
1865
+ _timeCodeText$split2 = _slicedToArray__default["default"](_timeCodeText$split, 2),
1866
+ samplesString = _timeCodeText$split2[0],
1867
+ timeBaseText = _timeCodeText$split2[1];
2116
1868
  var samples = Number(samplesString);
2117
1869
  timeCodeObject = {
2118
1870
  samples: samples,
@@ -2131,11 +1883,9 @@ var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
2131
1883
  samples: Number(timeCodeText)
2132
1884
  };
2133
1885
  }
2134
-
2135
1886
  if (Number.isNaN((_timeCodeObject = timeCodeObject) === null || _timeCodeObject === void 0 ? void 0 : _timeCodeObject.samples) || timeCodeObject.timeBase && !(timeCodeObject.timeBase instanceof TimeBase)) {
2136
1887
  throw new Error("timeCodeText must be a number or sample@timeBase - is ".concat(timeCodeText));
2137
1888
  }
2138
-
2139
1889
  var timeCode = new TimeCode(timeCodeObject, timeCodeOptions);
2140
1890
  return timeBase ? timeCode.conformTimeBase(createTimeBase(timeBase)) : timeCode;
2141
1891
  };
@@ -2156,11 +1906,9 @@ var formatTimeCodeType = function formatTimeCodeType(timeCode, options) {
2156
1906
  var hasSmpteFormat = function hasSmpteFormat(s) {
2157
1907
  return !!s.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/);
2158
1908
  };
2159
-
2160
1909
  var isNumber = function isNumber(s) {
2161
1910
  return !Number.isNaN(Number(s));
2162
1911
  };
2163
-
2164
1912
  /**
2165
1913
  * Create a TimeCode instance from smpte, seconds/samples, timeCode object or string
2166
1914
  *
@@ -2172,42 +1920,38 @@ var isNumber = function isNumber(s) {
2172
1920
  */
2173
1921
  var createTimeCode = function createTimeCode(timeCode, options) {
2174
1922
  // TimeCode
2175
- if (typeof timeCode !== 'string' && typeof timeCode !== 'number') return formatTimeCodeType(timeCode, options); // SMPTE
2176
-
1923
+ if (typeof timeCode !== 'string' && typeof timeCode !== 'number') return formatTimeCodeType(timeCode, options);
1924
+ // SMPTE
2177
1925
  if (typeof timeCode === 'string' && hasSmpteFormat(timeCode)) return formatTimeCodeSmpte(timeCode, options);
2178
1926
  if (['string', 'number'].includes(_typeof__default["default"](timeCode)) && isNumber(timeCode)) return formatTimeCodeSeconds(timeCode, options);
2179
-
2180
1927
  if (typeof timeCode === 'string') {
2181
1928
  return formatTimeCodeText(timeCode, options);
2182
1929
  }
2183
-
2184
1930
  return undefined;
2185
1931
  };
2186
1932
 
2187
1933
  function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2188
-
2189
1934
  function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2190
-
2191
1935
  function timeToCueTime(_ref) {
2192
1936
  var _ref$hours = _ref.hours,
2193
- hours = _ref$hours === void 0 ? 0 : _ref$hours,
2194
- _ref$minutes = _ref.minutes,
2195
- minutes = _ref$minutes === void 0 ? 0 : _ref$minutes,
2196
- _ref$seconds = _ref.seconds,
2197
- seconds = _ref$seconds === void 0 ? 0 : _ref$seconds,
2198
- _ref$partialSeconds = _ref.partialSeconds,
2199
- partialSeconds = _ref$partialSeconds === void 0 ? 0 : _ref$partialSeconds;
1937
+ hours = _ref$hours === void 0 ? 0 : _ref$hours,
1938
+ _ref$minutes = _ref.minutes,
1939
+ minutes = _ref$minutes === void 0 ? 0 : _ref$minutes,
1940
+ _ref$seconds = _ref.seconds,
1941
+ seconds = _ref$seconds === void 0 ? 0 : _ref$seconds,
1942
+ _ref$partialSeconds = _ref.partialSeconds,
1943
+ partialSeconds = _ref$partialSeconds === void 0 ? 0 : _ref$partialSeconds;
2200
1944
  var hourStr = hours.toFixed().padStart(2, '0');
2201
1945
  var minStr = minutes.toFixed().padStart(2, '0');
2202
1946
  var secondsStr = seconds.toFixed().padStart(2, '0');
2203
1947
  var partialStr = (partialSeconds * 10).toFixed().padStart(3, '0');
2204
1948
  return "".concat(hourStr, ":").concat(minStr, ":").concat(secondsStr, ".").concat(partialStr);
2205
1949
  }
2206
-
2207
1950
  var defaultOptions$2 = {
2208
1951
  subtitleGroup: 'stl_subtitle',
2209
1952
  subtitleField: 'stl_text'
2210
1953
  };
1954
+
2211
1955
  /**
2212
1956
  * Convert metadata subtitle groups to WebVtt subtitles
2213
1957
  *
@@ -2217,16 +1961,13 @@ var defaultOptions$2 = {
2217
1961
  *
2218
1962
  * @category Metadata
2219
1963
  */
2220
-
2221
1964
  var metadataTypeToWebVtt = function metadataTypeToWebVtt(metadataType, options) {
2222
1965
  var _defaultOptions = _objectSpread$8(_objectSpread$8({}, defaultOptions$2), options || {}),
2223
- subtitleGroup = _defaultOptions.subtitleGroup,
2224
- subtitleField = _defaultOptions.subtitleField;
2225
-
1966
+ subtitleGroup = _defaultOptions.subtitleGroup,
1967
+ subtitleField = _defaultOptions.subtitleField;
2226
1968
  var _ref2 = metadataType || {},
2227
- _ref2$timespan = _ref2.timespan,
2228
- timespanList = _ref2$timespan === void 0 ? [] : _ref2$timespan;
2229
-
1969
+ _ref2$timespan = _ref2.timespan,
1970
+ timespanList = _ref2$timespan === void 0 ? [] : _ref2$timespan;
2230
1971
  if (timespanList.length === 0) return '';
2231
1972
  var parsedTimespans = parseTimespanList(timespanList, {
2232
1973
  includeTimespanAttributes: true,
@@ -2237,10 +1978,9 @@ var metadataTypeToWebVtt = function metadataTypeToWebVtt(metadataType, options)
2237
1978
  });
2238
1979
  var vttCues = parsedTimespans.map(function (timespan) {
2239
1980
  var _ref3 = (Array.isArray(timespan) ? timespan[0] : timespan) || {},
2240
- startText = _ref3.start,
2241
- endText = _ref3.end,
2242
- _ref3$subtitleGroup = _ref3[subtitleGroup];
2243
-
1981
+ startText = _ref3.start,
1982
+ endText = _ref3.end,
1983
+ _ref3$subtitleGroup = _ref3[subtitleGroup];
2244
1984
  _ref3$subtitleGroup = _ref3$subtitleGroup === void 0 ? {} : _ref3$subtitleGroup;
2245
1985
  var text = _ref3$subtitleGroup[subtitleField];
2246
1986
  if (!text) return '';
@@ -2276,9 +2016,7 @@ var createFacetType = function createFacetType() {
2276
2016
  };
2277
2017
 
2278
2018
  function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2279
-
2280
2019
  function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2281
-
2282
2020
  /** Parsed facet type */
2283
2021
 
2284
2022
  /**
@@ -2294,11 +2032,11 @@ var parseFacetType = function parseFacetType() {
2294
2032
  var output = {};
2295
2033
  facetType.forEach(function (_ref) {
2296
2034
  var name = _ref.name,
2297
- field = _ref.field,
2298
- count = _ref.count;
2035
+ field = _ref.field,
2036
+ count = _ref.count;
2299
2037
  output[name || field] = count.reduce(function (acc, _ref2) {
2300
2038
  var fieldValue = _ref2.fieldValue,
2301
- value = _ref2.value;
2039
+ value = _ref2.value;
2302
2040
  return _objectSpread$7(_objectSpread$7({}, acc), {}, _defineProperty__default["default"]({}, fieldValue, value));
2303
2041
  }, {});
2304
2042
  });
@@ -2306,14 +2044,13 @@ var parseFacetType = function parseFacetType() {
2306
2044
  };
2307
2045
 
2308
2046
  function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2309
-
2310
2047
  function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2311
-
2312
2048
  var defaultOptions$1 = {
2313
2049
  arrayOnSingle: true,
2314
2050
  joinValue: undefined,
2315
2051
  timespanAsList: false
2316
2052
  };
2053
+
2317
2054
  /**
2318
2055
  * Parses highlight timespan in VidiCore into key/value object.
2319
2056
  * The attributes can be targeted for each sub-type.
@@ -2322,48 +2059,40 @@ var defaultOptions$1 = {
2322
2059
  *
2323
2060
  * @category Search
2324
2061
  */
2325
-
2326
2062
  var parseHighlightTimespan = function parseHighlightTimespan(timespan, options) {
2327
2063
  var _defaultOptions = _objectSpread$6(_objectSpread$6({}, defaultOptions$1), options || {}),
2328
- _defaultOptions$array = _defaultOptions.arrayOnSingle,
2329
- arrayOnSingle = _defaultOptions$array === void 0 ? true : _defaultOptions$array,
2330
- _defaultOptions$joinV = _defaultOptions.joinValue,
2331
- joinValue = _defaultOptions$joinV === void 0 ? undefined : _defaultOptions$joinV,
2332
- _defaultOptions$times = _defaultOptions.timespanAsList,
2333
- timespanAsList = _defaultOptions$times === void 0 ? false : _defaultOptions$times;
2334
-
2064
+ _defaultOptions$array = _defaultOptions.arrayOnSingle,
2065
+ arrayOnSingle = _defaultOptions$array === void 0 ? true : _defaultOptions$array,
2066
+ _defaultOptions$joinV = _defaultOptions.joinValue,
2067
+ joinValue = _defaultOptions$joinV === void 0 ? undefined : _defaultOptions$joinV,
2068
+ _defaultOptions$times = _defaultOptions.timespanAsList,
2069
+ timespanAsList = _defaultOptions$times === void 0 ? false : _defaultOptions$times;
2335
2070
  var _ref = timespan || {},
2336
- _ref$field = _ref.field,
2337
- field = _ref$field === void 0 ? [] : _ref$field,
2338
- start = _ref.start,
2339
- end = _ref.end;
2340
-
2071
+ _ref$field = _ref.field,
2072
+ field = _ref$field === void 0 ? [] : _ref$field,
2073
+ start = _ref.start,
2074
+ end = _ref.end;
2341
2075
  var initialValue = timespanAsList ? {
2342
2076
  start: start,
2343
2077
  end: end
2344
2078
  } : {};
2345
2079
  var fieldList = field.reduce(function (acc, curr) {
2346
2080
  var name = curr.name,
2347
- _curr$value = curr.value,
2348
- valueList = _curr$value === void 0 ? [] : _curr$value;
2081
+ _curr$value = curr.value,
2082
+ valueList = _curr$value === void 0 ? [] : _curr$value;
2349
2083
  if (valueList.length === 0) return acc;
2350
2084
  var fieldValue;
2351
-
2352
2085
  if (arrayOnSingle === false && valueList.length === 1) {
2353
2086
  var _valueList = _slicedToArray__default["default"](valueList, 1);
2354
-
2355
2087
  fieldValue = _valueList[0];
2356
2088
  } else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
2357
-
2358
2089
  return _objectSpread$6(_objectSpread$6({}, acc), {}, _defineProperty__default["default"]({}, name, fieldValue));
2359
2090
  }, initialValue);
2360
2091
  return fieldList;
2361
2092
  };
2362
2093
 
2363
2094
  var _excluded$2 = ["timespanAsList", "joinTimespan", "flat", "flatTimespan"];
2364
-
2365
2095
  function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2366
-
2367
2096
  function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2368
2097
  var defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions$1), {}, {
2369
2098
  timespanAsList: false,
@@ -2371,6 +2100,7 @@ var defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions$1), {},
2371
2100
  flat: false,
2372
2101
  flatTimespan: false
2373
2102
  });
2103
+
2374
2104
  /**
2375
2105
  * Parses highlight timespans from VidiCore into key/value object.
2376
2106
  * The attributes can be targeted for each sub-type.
@@ -2380,19 +2110,16 @@ var defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions$1), {},
2380
2110
  *
2381
2111
  * @category Search
2382
2112
  */
2383
-
2384
2113
  var parseHighlightTimespanList = function parseHighlightTimespanList() {
2385
2114
  var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2386
2115
  var options = arguments.length > 1 ? arguments[1] : undefined;
2387
-
2388
2116
  var _defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions), options || {}),
2389
- timespanAsList = _defaultOptions.timespanAsList,
2390
- _defaultOptions$joinT = _defaultOptions.joinTimespan,
2391
- joinTimespan = _defaultOptions$joinT === void 0 ? '_' : _defaultOptions$joinT,
2392
- flat = _defaultOptions.flat,
2393
- flatTimespan = _defaultOptions.flatTimespan,
2394
- parseHighlightTimespanOptions = _objectWithoutProperties__default["default"](_defaultOptions, _excluded$2);
2395
-
2117
+ timespanAsList = _defaultOptions.timespanAsList,
2118
+ _defaultOptions$joinT = _defaultOptions.joinTimespan,
2119
+ joinTimespan = _defaultOptions$joinT === void 0 ? '_' : _defaultOptions$joinT,
2120
+ flat = _defaultOptions.flat,
2121
+ flatTimespan = _defaultOptions.flatTimespan,
2122
+ parseHighlightTimespanOptions = _objectWithoutProperties__default["default"](_defaultOptions, _excluded$2);
2396
2123
  if (timespanAsList === true) return highlightTimespanList.map(function (timespan) {
2397
2124
  return parseHighlightTimespan(timespan, _objectSpread$5(_objectSpread$5({}, parseHighlightTimespanOptions), {}, {
2398
2125
  timespanAsList: timespanAsList
@@ -2408,57 +2135,47 @@ var parseHighlightTimespanList = function parseHighlightTimespanList() {
2408
2135
 
2409
2136
  var parseNowDate = function parseNowDate() {
2410
2137
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NOW';
2411
-
2412
2138
  if (value.startsWith('NOW')) {
2413
2139
  if (value === 'NOW') return new Date();
2414
2140
  var sign = value[3];
2415
2141
  var number = Number(value.match(/(\d+)/)[0]);
2416
2142
  var unit = value.match(/(\d.*)/)[0].replace(/\d/g, '');
2417
2143
  var nowDiff = new Date();
2418
-
2419
2144
  switch (unit) {
2420
2145
  case 'HOUR':
2421
2146
  case 'HOURS':
2422
2147
  if (sign === '+') nowDiff.setHours(nowDiff.getHours() + number);
2423
2148
  if (sign === '-') nowDiff.setHours(nowDiff.getHours() - number);
2424
2149
  break;
2425
-
2426
2150
  case 'DAY':
2427
2151
  case 'DAYS':
2428
2152
  if (sign === '+') nowDiff.setDate(nowDiff.getDate() + number);
2429
2153
  if (sign === '-') nowDiff.setDate(nowDiff.getDate() - number);
2430
2154
  break;
2431
-
2432
2155
  case 'MONTH':
2433
2156
  case 'MONTHS':
2434
2157
  if (sign === '+') nowDiff.setMonth(nowDiff.getMonth() + number);
2435
2158
  if (sign === '-') nowDiff.setMonth(nowDiff.getMonth() - number);
2436
2159
  break;
2437
-
2438
2160
  case 'YEAR':
2439
2161
  case 'YEARS':
2440
2162
  if (sign === '+') nowDiff.setFullYear(nowDiff.getFullYear() + number);
2441
2163
  if (sign === '-') nowDiff.setFullYear(nowDiff.getFullYear() - number);
2442
2164
  break;
2443
2165
  }
2444
-
2445
2166
  return nowDiff;
2446
2167
  }
2447
-
2448
2168
  return new Date(value);
2449
2169
  };
2450
2170
 
2451
2171
  var _excluded$1 = ["property"];
2452
-
2453
2172
  function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2454
-
2455
2173
  function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2456
2174
  var parseBaseMediaInfoType = function parseBaseMediaInfoType(baseMediaInfoType) {
2457
2175
  var _ref = baseMediaInfoType || {},
2458
- _ref$property = _ref.property,
2459
- keyValuePairTypes = _ref$property === void 0 ? [] : _ref$property,
2460
- props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
2461
-
2176
+ _ref$property = _ref.property,
2177
+ keyValuePairTypes = _ref$property === void 0 ? [] : _ref$property,
2178
+ props = _objectWithoutProperties__default["default"](_ref, _excluded$1);
2462
2179
  var parsedKeyValuePairType = parseKeyValuePairTypes(keyValuePairTypes);
2463
2180
  return _objectSpread$4(_objectSpread$4({}, parsedKeyValuePairType), props);
2464
2181
  };
@@ -2479,7 +2196,6 @@ var bitRateSymbols = {
2479
2196
  B: 'bps',
2480
2197
  MB: 'mbps'
2481
2198
  };
2482
-
2483
2199
  /**
2484
2200
  * Parses the technical information of a AudioComponentType.
2485
2201
  * @param audioComponentType - A AudioComponentType from VidiCore.
@@ -2489,15 +2205,15 @@ var bitRateSymbols = {
2489
2205
  */
2490
2206
  var parseAudioComponent = function parseAudioComponent(audioComponentType) {
2491
2207
  var timeBase = audioComponentType.timeBase,
2492
- audioChannels = audioComponentType.channelCount,
2493
- audioCodec = audioComponentType.codec,
2494
- mediaInfo = audioComponentType.mediaInfo,
2495
- bitrate = audioComponentType.bitrate,
2496
- metadata = audioComponentType.metadata;
2208
+ audioChannels = audioComponentType.channelCount,
2209
+ audioCodec = audioComponentType.codec,
2210
+ mediaInfo = audioComponentType.mediaInfo,
2211
+ bitrate = audioComponentType.bitrate,
2212
+ metadata = audioComponentType.metadata;
2497
2213
  var audioMediaInfo = parseAudioMediaInfoType(mediaInfo);
2498
2214
  var audioFormat = audioMediaInfo.Format,
2499
- audioBitDepth = audioMediaInfo.Resolution,
2500
- audioBitRateMode = audioMediaInfo.Bit_rate_mode;
2215
+ audioBitDepth = audioMediaInfo.Resolution,
2216
+ audioBitRateMode = audioMediaInfo.Bit_rate_mode;
2501
2217
  var audioMetadata = parseKeyValuePairTypes(metadata || []);
2502
2218
  var audioSamplerateSamples = timeBase !== null && timeBase !== void 0 && timeBase.denominator ? ((timeBase === null || timeBase === void 0 ? void 0 : timeBase.denominator) || 1) / ((timeBase === null || timeBase === void 0 ? void 0 : timeBase.numerator) || 1) : undefined;
2503
2219
  var audioSamplerate = audioSamplerateSamples !== undefined ? parseFileSize__default["default"](audioSamplerateSamples, {
@@ -2534,15 +2250,13 @@ var parseAudioComponent = function parseAudioComponent(audioComponentType) {
2534
2250
  */
2535
2251
  var parseFileType = function parseFileType(fileType) {
2536
2252
  var _fileType$uri = fileType.uri,
2537
- uriList = _fileType$uri === void 0 ? [] : _fileType$uri,
2538
- fileSizeBytes = fileType.size,
2539
- hash = fileType.hash,
2540
- path = fileType.path,
2541
- fileId = fileType.id;
2542
-
2253
+ uriList = _fileType$uri === void 0 ? [] : _fileType$uri,
2254
+ fileSizeBytes = fileType.size,
2255
+ hash = fileType.hash,
2256
+ path = fileType.path,
2257
+ fileId = fileType.id;
2543
2258
  var _uriList = _slicedToArray__default["default"](uriList, 1),
2544
- uri = _uriList[0];
2545
-
2259
+ uri = _uriList[0];
2546
2260
  var fileSize = fileSizeBytes !== undefined ? parseFileSize__default["default"](fileSizeBytes) : '';
2547
2261
  var fileName = path ? path.split('/').pop() : undefined;
2548
2262
  return {
@@ -2557,9 +2271,7 @@ var parseFileType = function parseFileType(fileType) {
2557
2271
  };
2558
2272
 
2559
2273
  function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2560
-
2561
2274
  function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2562
-
2563
2275
  /**
2564
2276
  * Parses the technical information of a BinaryComponentType.
2565
2277
  * @param binaryComponentType - A BinaryComponentType from VidiCore.
@@ -2570,30 +2282,27 @@ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) {
2570
2282
  var parseBinaryComponent = function parseBinaryComponent() {
2571
2283
  var binaryComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2572
2284
  var fileList = binaryComponentType.file,
2573
- mediaInfo = binaryComponentType.mediaInfo,
2574
- _binaryComponentType$ = binaryComponentType.metadata,
2575
- metadata = _binaryComponentType$ === void 0 ? [] : _binaryComponentType$;
2285
+ mediaInfo = binaryComponentType.mediaInfo,
2286
+ _binaryComponentType$ = binaryComponentType.metadata,
2287
+ metadata = _binaryComponentType$ === void 0 ? [] : _binaryComponentType$;
2576
2288
  var binaryMetadata = parseKeyValuePairTypes(metadata);
2577
2289
  var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
2578
2290
  var parsedBinaryComponent = {
2579
2291
  binaryMetadata: binaryMetadata,
2580
2292
  binaryMediaInfo: binaryMediaInfo
2581
2293
  };
2582
-
2583
2294
  if (fileList) {
2584
2295
  var _fileList = _slicedToArray__default["default"](fileList, 1),
2585
- fileType = _fileList[0];
2586
-
2296
+ fileType = _fileList[0];
2587
2297
  var parsedFileType = parseFileType(fileType);
2588
2298
  parsedBinaryComponent = _objectSpread$3(_objectSpread$3({}, parsedBinaryComponent), parsedFileType);
2589
2299
  }
2590
-
2591
2300
  return parsedBinaryComponent;
2592
2301
  };
2593
2302
 
2594
2303
  function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2595
-
2596
2304
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2305
+
2597
2306
  /**
2598
2307
  * Parsed container component
2599
2308
  */
@@ -2608,32 +2317,27 @@ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) {
2608
2317
  var parseContainerComponent = function parseContainerComponent() {
2609
2318
  var containerComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2610
2319
  var mediaInfo = containerComponentType.mediaInfo,
2611
- metadata = containerComponentType.metadata,
2612
- fileList = containerComponentType.file,
2613
- durationTimeCode = containerComponentType.duration,
2614
- startTimestamp = containerComponentType.startTimestamp,
2615
- startTimecode = containerComponentType.startTimecode,
2616
- timeCodeTimeBase = containerComponentType.timeCodeTimeBase;
2320
+ metadata = containerComponentType.metadata,
2321
+ fileList = containerComponentType.file,
2322
+ durationTimeCode = containerComponentType.duration,
2323
+ startTimestamp = containerComponentType.startTimestamp,
2324
+ startTimecode = containerComponentType.startTimecode,
2325
+ timeCodeTimeBase = containerComponentType.timeCodeTimeBase;
2617
2326
  var containerMetadata = parseKeyValuePairTypes(metadata || []);
2618
2327
  var containerMediaInfo = parseBaseMediaInfoType(mediaInfo);
2619
2328
  var containerFormat = containerMediaInfo.Format;
2620
2329
  var videoFormat = containerMediaInfo.Video_Format_List,
2621
- audioFormat = containerMediaInfo.Audio_Format_List,
2622
- textFormat = containerMediaInfo.Text_Format_List;
2623
-
2330
+ audioFormat = containerMediaInfo.Audio_Format_List,
2331
+ textFormat = containerMediaInfo.Text_Format_List;
2624
2332
  if (containerFormat === undefined) {
2625
2333
  var format = containerComponentType.format;
2626
2334
  containerFormat = format;
2627
-
2628
2335
  if (format && format.includes(',')) {
2629
2336
  var formatList = format.split(',');
2630
-
2631
2337
  var _formatList = _slicedToArray__default["default"](formatList, 1);
2632
-
2633
2338
  containerFormat = _formatList[0];
2634
2339
  }
2635
2340
  }
2636
-
2637
2341
  var parsedContainerComponentType = {
2638
2342
  containerFormat: containerFormat,
2639
2343
  videoFormat: videoFormat,
@@ -2642,36 +2346,29 @@ var parseContainerComponent = function parseContainerComponent() {
2642
2346
  containerMetadata: containerMetadata,
2643
2347
  containerMediaInfo: containerMediaInfo
2644
2348
  };
2645
-
2646
2349
  if (containerMetadata.componentOriginalFilename) {
2647
2350
  parsedContainerComponentType.originalFilename = containerMetadata.componentOriginalFilename;
2648
2351
  }
2649
-
2650
2352
  if (durationTimeCode !== undefined && durationTimeCode.samples !== 0) {
2651
2353
  var timeCode = formatTimeCodeType(durationTimeCode);
2652
2354
  parsedContainerComponentType.durationTimeCode = timeCode.toObject();
2653
2355
  parsedContainerComponentType.duration = timeCode.toDuration();
2654
2356
  }
2655
-
2656
2357
  if (startTimestamp) {
2657
2358
  parsedContainerComponentType.startTimestamp = formatTimeCodeType(startTimestamp).toObject();
2658
2359
  }
2659
-
2660
2360
  if (startTimecode !== undefined && timeCodeTimeBase) {
2661
2361
  parsedContainerComponentType.startTimecode = formatTimeCodeType({
2662
2362
  samples: startTimecode,
2663
2363
  timeBase: timeCodeTimeBase
2664
2364
  });
2665
2365
  }
2666
-
2667
2366
  if (fileList) {
2668
2367
  var _fileList = _slicedToArray__default["default"](fileList, 1),
2669
- fileType = _fileList[0];
2670
-
2368
+ fileType = _fileList[0];
2671
2369
  var parsedFileType = parseFileType(fileType);
2672
2370
  parsedContainerComponentType = _objectSpread$2(_objectSpread$2({}, parsedContainerComponentType), parsedFileType);
2673
2371
  }
2674
-
2675
2372
  return parsedContainerComponentType;
2676
2373
  };
2677
2374
 
@@ -2685,23 +2382,22 @@ var parseContainerComponent = function parseContainerComponent() {
2685
2382
  var parseVideoComponent = function parseVideoComponent() {
2686
2383
  var videoComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2687
2384
  var videoCodec = videoComponentType.codec,
2688
- bitrate = videoComponentType.bitrate,
2689
- fieldOrder = videoComponentType.fieldOrder,
2690
- resolution = videoComponentType.resolution,
2691
- mediaInfo = videoComponentType.mediaInfo,
2692
- _videoComponentType$m = videoComponentType.metadata,
2693
- metadata = _videoComponentType$m === void 0 ? [] : _videoComponentType$m;
2385
+ bitrate = videoComponentType.bitrate,
2386
+ fieldOrder = videoComponentType.fieldOrder,
2387
+ resolution = videoComponentType.resolution,
2388
+ mediaInfo = videoComponentType.mediaInfo,
2389
+ _videoComponentType$m = videoComponentType.metadata,
2390
+ metadata = _videoComponentType$m === void 0 ? [] : _videoComponentType$m;
2694
2391
  var videoMediaInfo = parseVideoMediaInfoType(mediaInfo);
2695
2392
  var videoMetadata = parseKeyValuePairTypes(metadata);
2696
2393
  var videoFormat = videoMediaInfo.Format,
2697
- timeBaseText = videoMediaInfo['Frame rate'],
2698
- colorSpace = videoMediaInfo['Color space'],
2699
- colorPrimaries = videoMediaInfo['Color primaries'],
2700
- chromaSubsampling = videoMediaInfo.Colorimetry;
2394
+ timeBaseText = videoMediaInfo['Frame rate'],
2395
+ colorSpace = videoMediaInfo['Color space'],
2396
+ colorPrimaries = videoMediaInfo['Color primaries'],
2397
+ chromaSubsampling = videoMediaInfo.Colorimetry;
2701
2398
  var timeBase;
2702
2399
  var averageFrameRate = videoComponentType.averageFrameRate,
2703
- realBaseFrameRate = videoComponentType.realBaseFrameRate;
2704
-
2400
+ realBaseFrameRate = videoComponentType.realBaseFrameRate;
2705
2401
  if (realBaseFrameRate !== undefined) {
2706
2402
  timeBase = formatTimeBaseType({
2707
2403
  numerator: realBaseFrameRate.denominator,
@@ -2715,18 +2411,14 @@ var parseVideoComponent = function parseVideoComponent() {
2715
2411
  denominator: averageFrameRate.numerator
2716
2412
  });
2717
2413
  }
2718
-
2719
2414
  var samples = videoMediaInfo['Frame count'];
2720
-
2721
2415
  if (samples === undefined) {
2722
2416
  var numberOfPackets = videoComponentType.numberOfPackets;
2723
2417
  if (numberOfPackets !== undefined) samples = numberOfPackets.toString();
2724
2418
  }
2725
-
2726
2419
  var timeCode;
2727
2420
  var frameRate;
2728
2421
  var smpte;
2729
-
2730
2422
  if (samples && timeBase) {
2731
2423
  timeCode = formatTimeCodeType({
2732
2424
  samples: samples,
@@ -2735,11 +2427,9 @@ var parseVideoComponent = function parseVideoComponent() {
2735
2427
  frameRate = timeCode.timeBase.toConstant() || timeCode.timeBase.toRate();
2736
2428
  smpte = timeCode.toSmpte();
2737
2429
  }
2738
-
2739
2430
  var _ref = resolution || {},
2740
- height = _ref.height,
2741
- width = _ref.width;
2742
-
2431
+ height = _ref.height,
2432
+ width = _ref.width;
2743
2433
  var aspectRatio = parseAspectRatio(resolution);
2744
2434
  var dimension = "".concat(width, "x").concat(height);
2745
2435
  var videoBitrate = bitrate ? parseFileSize__default["default"](bitrate, {
@@ -2767,9 +2457,7 @@ var parseVideoComponent = function parseVideoComponent() {
2767
2457
  };
2768
2458
 
2769
2459
  function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2770
-
2771
2460
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2772
-
2773
2461
  /**
2774
2462
  * Parses the technical information of a ShapeType and its various components.
2775
2463
  *
@@ -2788,55 +2476,44 @@ var parseShapeType = function parseShapeType() {
2788
2476
  var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2789
2477
  var parsedShape = {};
2790
2478
  var containerComponent = shapeType.containerComponent,
2791
- videoComponentList = shapeType.videoComponent,
2792
- audioComponentList = shapeType.audioComponent,
2793
- binaryComponentList = shapeType.binaryComponent,
2794
- _shapeType$mimeType = shapeType.mimeType,
2795
- mimeTypeList = _shapeType$mimeType === void 0 ? [] : _shapeType$mimeType,
2796
- _shapeType$tag = shapeType.tag,
2797
- tagList = _shapeType$tag === void 0 ? [] : _shapeType$tag;
2798
-
2479
+ videoComponentList = shapeType.videoComponent,
2480
+ audioComponentList = shapeType.audioComponent,
2481
+ binaryComponentList = shapeType.binaryComponent,
2482
+ _shapeType$mimeType = shapeType.mimeType,
2483
+ mimeTypeList = _shapeType$mimeType === void 0 ? [] : _shapeType$mimeType,
2484
+ _shapeType$tag = shapeType.tag,
2485
+ tagList = _shapeType$tag === void 0 ? [] : _shapeType$tag;
2799
2486
  var _tagList = _slicedToArray__default["default"](tagList, 1);
2800
-
2801
2487
  parsedShape.tag = _tagList[0];
2802
-
2803
2488
  var _mimeTypeList = _slicedToArray__default["default"](mimeTypeList, 1);
2804
-
2805
2489
  parsedShape.mimeType = _mimeTypeList[0];
2806
-
2807
2490
  if (containerComponent) {
2808
2491
  var parsedContainerComponent = parseContainerComponent(containerComponent);
2809
2492
  parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedContainerComponent);
2810
2493
  }
2811
-
2812
2494
  if (videoComponentList) {
2813
2495
  var _videoComponentList = _slicedToArray__default["default"](videoComponentList, 1),
2814
- videoComponent = _videoComponentList[0];
2815
-
2496
+ videoComponent = _videoComponentList[0];
2816
2497
  var parsedVideoComponent = parseVideoComponent(videoComponent);
2817
2498
  parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedVideoComponent);
2818
2499
  }
2819
-
2820
2500
  if (audioComponentList) {
2821
2501
  var _audioComponentList = _slicedToArray__default["default"](audioComponentList, 1),
2822
- audioComponent = _audioComponentList[0];
2823
-
2502
+ audioComponent = _audioComponentList[0];
2824
2503
  var parsedAudioComponent = parseAudioComponent(audioComponent);
2825
2504
  parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedAudioComponent);
2826
2505
  }
2827
-
2828
2506
  if (binaryComponentList) {
2829
2507
  var _binaryComponentList = _slicedToArray__default["default"](binaryComponentList, 1),
2830
- binaryComponent = _binaryComponentList[0];
2831
-
2508
+ binaryComponent = _binaryComponentList[0];
2832
2509
  var parsedBinaryComponent = parseBinaryComponent(binaryComponent);
2833
2510
  parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedBinaryComponent);
2834
2511
  }
2835
-
2836
2512
  return parsedShape;
2837
2513
  };
2838
2514
 
2839
2515
  // eslint-disable-next-line import/no-cycle
2516
+
2840
2517
  var DOCUMENT_TYPES = {
2841
2518
  PDF: 'PDF',
2842
2519
  TEXT: 'TEXT',
@@ -2844,7 +2521,6 @@ var DOCUMENT_TYPES = {
2844
2521
  JSON: 'JSON',
2845
2522
  XML: 'XML'
2846
2523
  };
2847
-
2848
2524
  /**
2849
2525
  * Return a const for the document type of a shape (looks at mimeType)
2850
2526
  *
@@ -2878,21 +2554,20 @@ var QUICKTIME_MIMETYPE = 'video/quicktime';
2878
2554
  var M4V_MIMETYPE = 'video/x-m4v';
2879
2555
  var MP4_CONTAINER = 'MPEG-4';
2880
2556
  var MOV_CONTAINER = 'mov';
2881
- var H264_CODEC = 'h264'; // Sort by tags in the order of previewShapeOrder, secondary alphabetical.
2882
- // using reverse() so the first has highest index
2557
+ var H264_CODEC = 'h264';
2883
2558
 
2559
+ // Sort by tags in the order of previewShapeOrder, secondary alphabetical.
2560
+ // using reverse() so the first has highest index
2884
2561
  var PREVIEW_SHAPE_ORDER = ['__mp4', '__mp3_160k', '__png', '__jpeg', '__gif', 'original'].reverse();
2885
-
2886
2562
  var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
2887
2563
  var firstEl = _ref.parsedShape.tag;
2888
2564
  var secondEl = _ref2.parsedShape.tag;
2889
-
2890
2565
  if (PREVIEW_SHAPE_ORDER.includes(firstEl) || PREVIEW_SHAPE_ORDER.includes(secondEl)) {
2891
2566
  return PREVIEW_SHAPE_ORDER.indexOf(secondEl) - PREVIEW_SHAPE_ORDER.indexOf(firstEl);
2892
2567
  }
2893
-
2894
2568
  return firstEl.toLowerCase().localeCompare(secondEl.toLowerCase());
2895
2569
  };
2570
+
2896
2571
  /**
2897
2572
  * Filter a shape type list to get shapes that are playable in a browser
2898
2573
  *
@@ -2902,67 +2577,59 @@ var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
2902
2577
  *
2903
2578
  * @category Shape
2904
2579
  */
2905
-
2906
-
2907
2580
  var filterShapeSource = function filterShapeSource(itemType, options) {
2908
2581
  var _ref3 = options || {},
2909
- _ref3$allowedMimeType = _ref3.allowedMimeTypes,
2910
- allowedMimeTypes = _ref3$allowedMimeType === void 0 ? DEFAULT_ALLOWED_MIME_TYPES : _ref3$allowedMimeType,
2911
- _ref3$allowedMethods = _ref3.allowedMethods,
2912
- allowedMethods = _ref3$allowedMethods === void 0 ? DEFAULT_ALLOWED_METHODS : _ref3$allowedMethods,
2913
- _ref3$sortPriority = _ref3.sortPriority,
2914
- sortPriority = _ref3$sortPriority === void 0 ? defaultSortPriority : _ref3$sortPriority,
2915
- _ref3$sourceKey = _ref3.sourceKey,
2916
- sourceKey = _ref3$sourceKey === void 0 ? 'src' : _ref3$sourceKey,
2917
- _ref3$mimeTypeKey = _ref3.mimeTypeKey,
2918
- mimeTypeKey = _ref3$mimeTypeKey === void 0 ? 'type' : _ref3$mimeTypeKey,
2919
- _ref3$shapeKey = _ref3.shapeKey,
2920
- shapeKey = _ref3$shapeKey === void 0 ? 'shape' : _ref3$shapeKey,
2921
- _ref3$parsedShapeKey = _ref3.parsedShapeKey,
2922
- parsedShapeKey = _ref3$parsedShapeKey === void 0 ? 'parsedShape' : _ref3$parsedShapeKey;
2923
-
2582
+ _ref3$allowedMimeType = _ref3.allowedMimeTypes,
2583
+ allowedMimeTypes = _ref3$allowedMimeType === void 0 ? DEFAULT_ALLOWED_MIME_TYPES : _ref3$allowedMimeType,
2584
+ _ref3$allowedMethods = _ref3.allowedMethods,
2585
+ allowedMethods = _ref3$allowedMethods === void 0 ? DEFAULT_ALLOWED_METHODS : _ref3$allowedMethods,
2586
+ _ref3$sortPriority = _ref3.sortPriority,
2587
+ sortPriority = _ref3$sortPriority === void 0 ? defaultSortPriority : _ref3$sortPriority,
2588
+ _ref3$sourceKey = _ref3.sourceKey,
2589
+ sourceKey = _ref3$sourceKey === void 0 ? 'src' : _ref3$sourceKey,
2590
+ _ref3$mimeTypeKey = _ref3.mimeTypeKey,
2591
+ mimeTypeKey = _ref3$mimeTypeKey === void 0 ? 'type' : _ref3$mimeTypeKey,
2592
+ _ref3$shapeKey = _ref3.shapeKey,
2593
+ shapeKey = _ref3$shapeKey === void 0 ? 'shape' : _ref3$shapeKey,
2594
+ _ref3$parsedShapeKey = _ref3.parsedShapeKey,
2595
+ parsedShapeKey = _ref3$parsedShapeKey === void 0 ? 'parsedShape' : _ref3$parsedShapeKey;
2924
2596
  var _ref4 = itemType || {},
2925
- _ref4$shape = _ref4.shape,
2926
- shapeList = _ref4$shape === void 0 ? [] : _ref4$shape;
2927
-
2597
+ _ref4$shape = _ref4.shape,
2598
+ shapeList = _ref4$shape === void 0 ? [] : _ref4$shape;
2928
2599
  var filteredShapeList = shapeList.reduce(function (acc, shapeType) {
2929
2600
  var type;
2930
2601
  var src;
2931
2602
  var parsedShape = parseShapeType(shapeType);
2932
2603
  var uri = parsedShape.uri,
2933
- mimeType = parsedShape.mimeType,
2934
- containerFormat = parsedShape.containerFormat,
2935
- videoCodec = parsedShape.videoCodec;
2936
-
2604
+ mimeType = parsedShape.mimeType,
2605
+ containerFormat = parsedShape.containerFormat,
2606
+ videoCodec = parsedShape.videoCodec;
2937
2607
  if (mimeType) {
2938
2608
  type = mimeType;
2939
2609
  if ((mimeType === QUICKTIME_MIMETYPE || mimeType === M4V_MIMETYPE) && (containerFormat === MP4_CONTAINER || containerFormat === MOV_CONTAINER) && videoCodec === H264_CODEC) type = MP4_MIMETYPE;
2940
2610
  }
2941
-
2942
2611
  if (uri) {
2943
2612
  if (allowedMethods) {
2944
2613
  var _uri$split = uri.split('://'),
2945
- _uri$split2 = _slicedToArray__default["default"](_uri$split, 1),
2946
- thisMethod = _uri$split2[0];
2947
-
2614
+ _uri$split2 = _slicedToArray__default["default"](_uri$split, 1),
2615
+ thisMethod = _uri$split2[0];
2948
2616
  if (allowedMethods.includes(thisMethod)) src = uri;
2949
2617
  } else {
2950
2618
  src = uri;
2951
2619
  }
2952
2620
  }
2953
-
2954
2621
  if (src && allowedMimeTypes.includes(type)) {
2955
2622
  var _acc$push;
2956
-
2957
2623
  acc.push((_acc$push = {}, _defineProperty__default["default"](_acc$push, sourceKey, src), _defineProperty__default["default"](_acc$push, mimeTypeKey, type), _defineProperty__default["default"](_acc$push, shapeKey, shapeType), _defineProperty__default["default"](_acc$push, parsedShapeKey, parsedShape), _acc$push));
2958
2624
  }
2959
-
2960
2625
  return acc;
2961
2626
  }, []);
2962
2627
  if (typeof sortPriority === 'function') filteredShapeList.sort(defaultSortPriority);
2963
2628
  return filteredShapeList;
2964
2629
  };
2965
2630
 
2631
+ // eslint-disable-next-line import/no-cycle
2632
+
2966
2633
  var SHAPE_MEDIA_TYPES = {
2967
2634
  IMAGE: 'IMAGE',
2968
2635
  AUDIO: 'AUDIO',
@@ -2970,7 +2637,6 @@ var SHAPE_MEDIA_TYPES = {
2970
2637
  DOCUMENT: 'DOCUMENT',
2971
2638
  BINARY: 'BINARY'
2972
2639
  };
2973
-
2974
2640
  /**
2975
2641
  * Returns a const for which media type a shape has
2976
2642
  *
@@ -2982,19 +2648,16 @@ var SHAPE_MEDIA_TYPES = {
2982
2648
  var getShapeMediaType = function getShapeMediaType(shape) {
2983
2649
  var parsedShape = parseShapeType(shape);
2984
2650
  var mimeType = parsedShape.mimeType,
2985
- videoCodec = parsedShape.videoCodec,
2986
- audioCodec = parsedShape.audioCodec;
2651
+ videoCodec = parsedShape.videoCodec,
2652
+ audioCodec = parsedShape.audioCodec;
2987
2653
  if (!mimeType) return undefined;
2988
-
2989
2654
  if (mimeType.startsWith('audio/')) {
2990
2655
  if (audioCodec !== undefined) return SHAPE_MEDIA_TYPES.AUDIO;
2991
2656
  }
2992
-
2993
2657
  if (mimeType.startsWith('video/')) {
2994
2658
  if (videoCodec !== undefined) return SHAPE_MEDIA_TYPES.VIDEO;
2995
2659
  if (audioCodec !== undefined) return SHAPE_MEDIA_TYPES.AUDIO;
2996
2660
  }
2997
-
2998
2661
  if (mimeType.startsWith('image/')) return SHAPE_MEDIA_TYPES.IMAGE;
2999
2662
  if (mimeType.endsWith('/pdf')) return SHAPE_MEDIA_TYPES.DOCUMENT;
3000
2663
  if (mimeType.startsWith('text/')) return SHAPE_MEDIA_TYPES.DOCUMENT;
@@ -3019,13 +2682,11 @@ var getShapeMediaType = function getShapeMediaType(shape) {
3019
2682
  */
3020
2683
  var findNearestThumbnail = function findNearestThumbnail(itemType, timeCode) {
3021
2684
  var tcSeconds = createTimeCode(timeCode).toSeconds();
3022
-
3023
2685
  var _ref = itemType || {},
3024
- _ref$thumbnails = _ref.thumbnails,
3025
- thumbnails = _ref$thumbnails === void 0 ? {} : _ref$thumbnails;
3026
-
2686
+ _ref$thumbnails = _ref.thumbnails,
2687
+ thumbnails = _ref$thumbnails === void 0 ? {} : _ref$thumbnails;
3027
2688
  var _thumbnails$uri = thumbnails.uri,
3028
- srcList = _thumbnails$uri === void 0 ? [] : _thumbnails$uri;
2689
+ srcList = _thumbnails$uri === void 0 ? [] : _thumbnails$uri;
3029
2690
  var srcTcSeconds = srcList.map(function (url) {
3030
2691
  var tc = new URL(url).pathname.split('/').pop();
3031
2692
  return formatTimeCodeText(tc).toSeconds();
@@ -3037,7 +2698,8 @@ var findNearestThumbnail = function findNearestThumbnail(itemType, timeCode) {
3037
2698
  };
3038
2699
 
3039
2700
  var _excluded = ["Codec"],
3040
- _excluded2 = ["Codec"];
2701
+ _excluded2 = ["Codec"];
2702
+
3041
2703
  /**
3042
2704
  * TODO
3043
2705
  */
@@ -3052,36 +2714,29 @@ var _excluded = ["Codec"],
3052
2714
  */
3053
2715
  var parseMediaConvertPreset = function parseMediaConvertPreset(mediaconvert) {
3054
2716
  var output = {};
3055
-
3056
2717
  var _ref = mediaconvert || {},
3057
- _ref$outputSetting = _ref.outputSetting,
3058
- outputSetting = _ref$outputSetting === void 0 ? [] : _ref$outputSetting;
3059
-
2718
+ _ref$outputSetting = _ref.outputSetting,
2719
+ outputSetting = _ref$outputSetting === void 0 ? [] : _ref$outputSetting;
3060
2720
  if (outputSetting.length === 0) return output;
3061
2721
  var mc = JSON.parse(outputSetting[0]);
3062
2722
  var _mc$Settings = mc.Settings;
3063
2723
  _mc$Settings = _mc$Settings === void 0 ? {} : _mc$Settings;
3064
2724
  var ContainerSettings = _mc$Settings.ContainerSettings,
3065
- VideoDescription = _mc$Settings.VideoDescription,
3066
- AudioDescriptions = _mc$Settings.AudioDescriptions;
3067
-
2725
+ VideoDescription = _mc$Settings.VideoDescription,
2726
+ AudioDescriptions = _mc$Settings.AudioDescriptions;
3068
2727
  if (ContainerSettings) {
3069
2728
  output.containerFormat = ContainerSettings.Container;
3070
2729
  }
3071
-
3072
2730
  if (VideoDescription) {
3073
2731
  var _VideoDescription$Cod = VideoDescription.CodecSettings,
3074
- CodecSettings = _VideoDescription$Cod === void 0 ? {} : _VideoDescription$Cod;
3075
-
2732
+ CodecSettings = _VideoDescription$Cod === void 0 ? {} : _VideoDescription$Cod;
3076
2733
  var Codec = CodecSettings.Codec,
3077
- otherSettings = _objectWithoutProperties__default["default"](CodecSettings, _excluded);
3078
-
2734
+ otherSettings = _objectWithoutProperties__default["default"](CodecSettings, _excluded);
3079
2735
  output.videoFormat = Codec;
3080
2736
  var height = VideoDescription.Height,
3081
- width = VideoDescription.Width;
2737
+ width = VideoDescription.Width;
3082
2738
  output.height = height;
3083
2739
  output.width = width;
3084
-
3085
2740
  if (height && width) {
3086
2741
  output.dimension = "".concat(width, "x").concat(height);
3087
2742
  output.aspectRatio = parseAspectRatio({
@@ -3089,17 +2744,14 @@ var parseMediaConvertPreset = function parseMediaConvertPreset(mediaconvert) {
3089
2744
  width: width
3090
2745
  });
3091
2746
  }
3092
-
3093
2747
  var _Object$values = Object.values(otherSettings),
3094
- _Object$values2 = _slicedToArray__default["default"](_Object$values, 1),
3095
- codecSpecs = _Object$values2[0];
3096
-
2748
+ _Object$values2 = _slicedToArray__default["default"](_Object$values, 1),
2749
+ codecSpecs = _Object$values2[0];
3097
2750
  if (codecSpecs) {
3098
2751
  output.fieldOrder = codecSpecs.InterlaceMode;
3099
2752
  if (output.fieldOrder && output.fieldOrder.includes('TOP')) output.fieldOrder = 'interlaced';
3100
2753
  output.videoBitrate = codecSpecs.Bitrate;
3101
2754
  var numerator = codecSpecs.FramerateDenominator; // other way round to vs ¯\_(ツ)_/¯
3102
-
3103
2755
  var denominator = codecSpecs.FramerateNumerator;
3104
2756
  var timeBase = formatTimeBaseType({
3105
2757
  denominator: denominator,
@@ -3109,78 +2761,61 @@ var parseMediaConvertPreset = function parseMediaConvertPreset(mediaconvert) {
3109
2761
  output.frameRate = timeBase.toConstant() || timeBase.toRate();
3110
2762
  }
3111
2763
  }
3112
-
3113
2764
  if (AudioDescriptions && AudioDescriptions.length > 0) {
3114
2765
  var _AudioDescriptions$0$ = AudioDescriptions[0].CodecSettings,
3115
- _CodecSettings = _AudioDescriptions$0$ === void 0 ? {} : _AudioDescriptions$0$;
3116
-
2766
+ _CodecSettings = _AudioDescriptions$0$ === void 0 ? {} : _AudioDescriptions$0$;
3117
2767
  var _Codec = _CodecSettings.Codec,
3118
- _otherSettings = _objectWithoutProperties__default["default"](_CodecSettings, _excluded2);
3119
-
2768
+ _otherSettings = _objectWithoutProperties__default["default"](_CodecSettings, _excluded2);
3120
2769
  output.audioFormat = _Codec;
3121
-
3122
2770
  var _Object$values3 = Object.values(_otherSettings),
3123
- _Object$values4 = _slicedToArray__default["default"](_Object$values3, 1),
3124
- _codecSpecs = _Object$values4[0];
3125
-
2771
+ _Object$values4 = _slicedToArray__default["default"](_Object$values3, 1),
2772
+ _codecSpecs = _Object$values4[0];
3126
2773
  if (_codecSpecs) {
3127
2774
  output.audioSamplerate = _codecSpecs.SampleRate;
3128
2775
  output.audioBitrate = _codecSpecs.Bitrate;
3129
2776
  output.audioBitRateMode = _codecSpecs.RateControlMode;
3130
2777
  }
3131
2778
  }
3132
-
3133
2779
  return output;
3134
2780
  };
3135
2781
 
3136
2782
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3137
-
3138
2783
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3139
2784
  /**
3140
- * TODO
3141
- */
3142
-
3143
- /**
3144
- * TODO
2785
+ * Parse a VidiCore transcode preset
3145
2786
  *
3146
- * @param transcodePresetType
3147
- * @returns
2787
+ * @param transcodePresetType a VidiCore transcode preset
2788
+ * @returns A parsed transcode preset
3148
2789
  *
3149
2790
  * @category Transcode
3150
2791
  */
3151
2792
  var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
3152
2793
  var output = {};
3153
-
3154
2794
  var _ref = transcodePresetType || {},
3155
- description = _ref.description,
3156
- format = _ref.format,
3157
- audio = _ref.audio,
3158
- video = _ref.video,
3159
- mediaconvert = _ref.mediaconvert;
3160
-
2795
+ description = _ref.description,
2796
+ format = _ref.format,
2797
+ audio = _ref.audio,
2798
+ video = _ref.video,
2799
+ mediaconvert = _ref.mediaconvert;
3161
2800
  if (mediaconvert) return _objectSpread({
3162
2801
  description: description
3163
2802
  }, parseMediaConvertPreset(mediaconvert));
3164
2803
  output.description = description;
3165
2804
  output.containerFormat = format;
3166
-
3167
2805
  if (video) {
3168
2806
  output.videoFormat = video.codec;
3169
2807
  output.videoBitrate = video.bitrate;
3170
-
3171
2808
  if (video.framerate) {
3172
2809
  var timeBase = formatTimeBaseType(video.framerate);
3173
2810
  output.timeBase = timeBase;
3174
2811
  output.frameRate = timeBase.toConstant() || timeBase.toRate();
3175
2812
  }
3176
-
3177
2813
  if (video.scaling) {
3178
2814
  var _video$scaling = video.scaling,
3179
- height = _video$scaling.height,
3180
- width = _video$scaling.width;
2815
+ height = _video$scaling.height,
2816
+ width = _video$scaling.width;
3181
2817
  output.height = height;
3182
2818
  output.width = width;
3183
-
3184
2819
  if (height && width) {
3185
2820
  output.dimension = "".concat(width, "x").concat(height);
3186
2821
  output.aspectRatio = parseAspectRatio({
@@ -3190,14 +2825,12 @@ var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
3190
2825
  }
3191
2826
  }
3192
2827
  }
3193
-
3194
2828
  if (audio) {
3195
2829
  var audioFormat = audio.codec,
3196
- channel = audio.channel;
2830
+ channel = audio.channel;
3197
2831
  output.audioFormat = audioFormat;
3198
2832
  if (channel) output.audioChannels = channel.length;
3199
2833
  }
3200
-
3201
2834
  return output;
3202
2835
  };
3203
2836