@vidispine/vdt-js 22.1.0-pre.3 → 22.2.0-pre.2

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.es.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
2
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
- import parseFileSize from 'filesize';
3
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
4
  import _typeof from '@babel/runtime/helpers/typeof';
6
5
  import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
7
6
  import _createClass from '@babel/runtime/helpers/createClass';
8
7
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
8
+ import parseFileSize from 'filesize';
9
9
 
10
10
  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; }
11
11
 
@@ -23,2134 +23,1958 @@ var parseKeyValuePairType = function parseKeyValuePairType() {
23
23
  return keyValuePairType.reduce(keyValuePairTypeReducer, {});
24
24
  };
25
25
 
26
- var parseNowDate = function parseNowDate() {
27
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NOW';
28
-
29
- if (value.startsWith('NOW')) {
30
- if (value === 'NOW') return new Date();
31
- var sign = value[3];
32
- var number = Number(value.match(/(\d+)/)[0]);
33
- var unit = value.match(/(\d.*)/)[0].replace(/\d/g, '');
34
- var nowDiff = new Date();
26
+ var ACCESSCONTROL_READ = '_accesscontrol_read';
27
+ var ACCESSCONTROL_WRITE = '_accesscontrol_write';
28
+ var ADMINISTRATOR = '_administrator';
29
+ var AUTO_PROJECTION_READ = '_auto_projection_read';
30
+ var AUTO_PROJECTION_WRITE = '_auto_projection_write';
31
+ var COLLECTION_NOTIFICATION_READ = '_collection_notification_read';
32
+ var COLLECTION_NOTIFICATION_WRITE = '_collection_notification_write';
33
+ var COLLECTION_READ = '_collection_read';
34
+ var COLLECTION_WRITE = '_collection_write';
35
+ var DELETION_LOCK_NOTIFICATION_READ = '_deletion_lock_notification_read';
36
+ var DELETION_LOCK_NOTIFICATION_WRITE = '_deletion_lock_notification_write';
37
+ var DELETION_LOCK_READ = '_deletion_lock_read';
38
+ var DELETION_LOCK_WRITE = '_deletion_lock_write';
39
+ var DOCUMENT_NOTIFICATION_READ = '_document_notification_read';
40
+ var DOCUMENT_NOTIFICATION_WRITE = '_document_notification_write';
41
+ var DOCUMENT_READ = '_document_read';
42
+ var DOCUMENT_WRITE = '_document_write';
43
+ var ERROR_READ = '_error_read';
44
+ var ERROR_WRITE = '_error_write';
45
+ var EXPORT = '_export';
46
+ var EXPORT_TEMPLATE_READ = '_export_template_read';
47
+ var EXPORT_TEMPLATE_WRITE = '_export_template_write';
48
+ var EXTERNAL_ID_READ = '_external_id_read';
49
+ var EXTERNAL_ID_WRITE = '_external_id_write';
50
+ var FILE_NOTIFICATION_READ = '_file_notification_read';
51
+ var FILE_NOTIFICATION_WRITE = '_file_notification_write';
52
+ var FILE_READ = '_file_read';
53
+ var FILE_WRITE = '_file_write';
54
+ var GROUP_READ = '_group_read';
55
+ var GROUP_WRITE = '_group_write';
56
+ var IMPORT_WRITE = '_import';
57
+ var ITEM_ID_READ = '_item_id_read';
58
+ var ITEM_ID_WRITE = '_item_id_write';
59
+ var ITEM_NOTIFICATION_READ = '_item_notification_read';
60
+ var ITEM_NOTIFICATION_WRITE = '_item_notification_write';
61
+ var ITEM_WRITE = '_item_write';
62
+ var ITEM_SEARCH = '_item_search';
63
+ var ITEM_SHAPE_READ = '_item_shape_read';
64
+ var ITEM_SHAPE_WRITE = '_item_shape_write';
65
+ var ITEM_TIMELINE_READ = '_item_timeline_read';
66
+ var ITEM_TIMELINE_WRITE = '_item_timeline_write';
67
+ var ITEM_URI = '_item_uri';
68
+ var JOB_NOTIFICATION_READ = '_job_notification_read';
69
+ var JOB_NOTIFICATION_WRITE = '_job_notification_write';
70
+ var JOB_READ = '_job_read';
71
+ var JOB_WRITE = '_job_write';
72
+ var LIBRARY_READ = '_library_read';
73
+ var LIBRARY_WRITE = '_library_write';
74
+ var LOCK_READ = '_lock_read';
75
+ var LOCK_WRITE = '_lock_write';
76
+ var LOG_READ = '_log_read';
77
+ var METADATA_DATASET_READ = '_metadata_dataset_read';
78
+ var METADATA_DATASET_WRITE = '_metadata_dataset_write';
79
+ var METADATA_FIELD_GROUP_READ = '_metadata_field_group_read';
80
+ var METADATA_FIELD_GROUP_WRITE = '_metadata_field_group_write';
81
+ var METADATA_FIELD_READ = '_metadata_field_read';
82
+ var METADATA_FIELD_WRITE = '_metadata_field_write';
83
+ var METADATA_GLOBAL_READ = '_metadata_global_read';
84
+ var METADATA_GLOBAL_WRITE = '_metadata_global_write';
85
+ var METADATA_LOCK_READ = '_metadata_lock_read';
86
+ var METADATA_LOCK_WRITE = '_metadata_lock_write';
87
+ var METADATA_READ = '_metadata_read';
88
+ var METADATA_SCHEMA_READ = '_metadata_schema_read';
89
+ var METADATA_SCHEMA_WRITE = '_metadata_schema_write';
90
+ var METADATA_WRITE = '_metadata_write';
91
+ var OTIF_ANALYZE = '_otif_analyze';
92
+ var OTIF_READ = '_otif_read';
93
+ var OTIF_WRITE = '_otif_write';
94
+ var PLACEHOLDER_NOTIFICATION_READ = '_placeholder_notification_read';
95
+ var PLACEHOLDER_NOTIFICATION_WRITE = '_placeholder_notification_write';
96
+ var PROJECTION_READ = '_projection_read';
97
+ var PROJECTION_WRITE = '_projection_write';
98
+ var QUOTA_NOTIFICATION_READ = '_quota_notification_read';
99
+ var QUOTA_NOTIFICATION_WRITE = '_quota_notification_write';
100
+ var QUOTA_READ = '_quota_read';
101
+ var QUOTA_WRITE = '_quota_write';
102
+ var RELATION_READ = '_relation_read';
103
+ var RELATION_WRITE = '_relation_write';
104
+ var RESOURCE_READ = '_resource_read';
105
+ var RESOURCE_WRITE = '_resource_write';
106
+ var RUN_AS = '_run_as';
107
+ var SEARCH = '_search';
108
+ var SEQUENCE_READ = '_sequence_read';
109
+ var SEQUENCE_WRITE = '_sequence_write';
110
+ var SHAPE_TAG_READ = '_shape_tag_read';
111
+ var SHAPE_TAG_WRITE = '_shape_tag_write';
112
+ var SITE_MANAGER = '_site_manager';
113
+ var SITE_RULE_READ = '_site_rule_read';
114
+ var SITE_RULE_WRITE = '_site_rule_write';
115
+ var STORAGE_GROUP_READ = '_storage_group_read';
116
+ var STORAGE_GROUP_WRITE = '_storage_group_write';
117
+ var STORAGE_NOTIFICATION_READ = '_storage_notification_read';
118
+ var STORAGE_NOTIFICATION_WRITE = '_storage_notification_write';
119
+ var STORAGE_READ = '_storage_read';
120
+ var STORAGE_RULE_READ = '_storage_rule_read';
121
+ var STORAGE_RULE_WRITE = '_storage_rule_write';
122
+ var STORAGE_WRITE = '_storage_write';
123
+ var SUPER_ACCESS_USER = '_super_access_user';
124
+ var TASKDEFINITION_READ = '_taskdefinition_read';
125
+ var TASKDEFINITION_WRITE = '_taskdefinition_write';
126
+ var THUMBNAIL_READ = '_thumbnail_read';
127
+ var THUMBNAIL_WRITE = '_thumbnail_write';
128
+ var TRANSCODER = '_transcoder';
129
+ var TRANSFER_READ = '_transfer_read';
130
+ var TRANSFER_WRITE = '_transfer_write';
131
+ var USER = '_user';
132
+ var VXA = '_vxa';
133
+ var VXA_READ = '_vxa_read';
35
134
 
36
- switch (unit) {
37
- case 'HOUR':
38
- case 'HOURS':
39
- if (sign === '+') nowDiff.setHours(nowDiff.getHours() + number);
40
- if (sign === '-') nowDiff.setHours(nowDiff.getHours() - number);
41
- break;
135
+ var roles = /*#__PURE__*/Object.freeze({
136
+ __proto__: null,
137
+ ACCESSCONTROL_READ: ACCESSCONTROL_READ,
138
+ ACCESSCONTROL_WRITE: ACCESSCONTROL_WRITE,
139
+ ADMINISTRATOR: ADMINISTRATOR,
140
+ AUTO_PROJECTION_READ: AUTO_PROJECTION_READ,
141
+ AUTO_PROJECTION_WRITE: AUTO_PROJECTION_WRITE,
142
+ COLLECTION_NOTIFICATION_READ: COLLECTION_NOTIFICATION_READ,
143
+ COLLECTION_NOTIFICATION_WRITE: COLLECTION_NOTIFICATION_WRITE,
144
+ COLLECTION_READ: COLLECTION_READ,
145
+ COLLECTION_WRITE: COLLECTION_WRITE,
146
+ DELETION_LOCK_NOTIFICATION_READ: DELETION_LOCK_NOTIFICATION_READ,
147
+ DELETION_LOCK_NOTIFICATION_WRITE: DELETION_LOCK_NOTIFICATION_WRITE,
148
+ DELETION_LOCK_READ: DELETION_LOCK_READ,
149
+ DELETION_LOCK_WRITE: DELETION_LOCK_WRITE,
150
+ DOCUMENT_NOTIFICATION_READ: DOCUMENT_NOTIFICATION_READ,
151
+ DOCUMENT_NOTIFICATION_WRITE: DOCUMENT_NOTIFICATION_WRITE,
152
+ DOCUMENT_READ: DOCUMENT_READ,
153
+ DOCUMENT_WRITE: DOCUMENT_WRITE,
154
+ ERROR_READ: ERROR_READ,
155
+ ERROR_WRITE: ERROR_WRITE,
156
+ EXPORT: EXPORT,
157
+ EXPORT_TEMPLATE_READ: EXPORT_TEMPLATE_READ,
158
+ EXPORT_TEMPLATE_WRITE: EXPORT_TEMPLATE_WRITE,
159
+ EXTERNAL_ID_READ: EXTERNAL_ID_READ,
160
+ EXTERNAL_ID_WRITE: EXTERNAL_ID_WRITE,
161
+ FILE_NOTIFICATION_READ: FILE_NOTIFICATION_READ,
162
+ FILE_NOTIFICATION_WRITE: FILE_NOTIFICATION_WRITE,
163
+ FILE_READ: FILE_READ,
164
+ FILE_WRITE: FILE_WRITE,
165
+ GROUP_READ: GROUP_READ,
166
+ GROUP_WRITE: GROUP_WRITE,
167
+ IMPORT_WRITE: IMPORT_WRITE,
168
+ ITEM_ID_READ: ITEM_ID_READ,
169
+ ITEM_ID_WRITE: ITEM_ID_WRITE,
170
+ ITEM_NOTIFICATION_READ: ITEM_NOTIFICATION_READ,
171
+ ITEM_NOTIFICATION_WRITE: ITEM_NOTIFICATION_WRITE,
172
+ ITEM_WRITE: ITEM_WRITE,
173
+ ITEM_SEARCH: ITEM_SEARCH,
174
+ ITEM_SHAPE_READ: ITEM_SHAPE_READ,
175
+ ITEM_SHAPE_WRITE: ITEM_SHAPE_WRITE,
176
+ ITEM_TIMELINE_READ: ITEM_TIMELINE_READ,
177
+ ITEM_TIMELINE_WRITE: ITEM_TIMELINE_WRITE,
178
+ ITEM_URI: ITEM_URI,
179
+ JOB_NOTIFICATION_READ: JOB_NOTIFICATION_READ,
180
+ JOB_NOTIFICATION_WRITE: JOB_NOTIFICATION_WRITE,
181
+ JOB_READ: JOB_READ,
182
+ JOB_WRITE: JOB_WRITE,
183
+ LIBRARY_READ: LIBRARY_READ,
184
+ LIBRARY_WRITE: LIBRARY_WRITE,
185
+ LOCK_READ: LOCK_READ,
186
+ LOCK_WRITE: LOCK_WRITE,
187
+ LOG_READ: LOG_READ,
188
+ METADATA_DATASET_READ: METADATA_DATASET_READ,
189
+ METADATA_DATASET_WRITE: METADATA_DATASET_WRITE,
190
+ METADATA_FIELD_GROUP_READ: METADATA_FIELD_GROUP_READ,
191
+ METADATA_FIELD_GROUP_WRITE: METADATA_FIELD_GROUP_WRITE,
192
+ METADATA_FIELD_READ: METADATA_FIELD_READ,
193
+ METADATA_FIELD_WRITE: METADATA_FIELD_WRITE,
194
+ METADATA_GLOBAL_READ: METADATA_GLOBAL_READ,
195
+ METADATA_GLOBAL_WRITE: METADATA_GLOBAL_WRITE,
196
+ METADATA_LOCK_READ: METADATA_LOCK_READ,
197
+ METADATA_LOCK_WRITE: METADATA_LOCK_WRITE,
198
+ METADATA_READ: METADATA_READ,
199
+ METADATA_SCHEMA_READ: METADATA_SCHEMA_READ,
200
+ METADATA_SCHEMA_WRITE: METADATA_SCHEMA_WRITE,
201
+ METADATA_WRITE: METADATA_WRITE,
202
+ OTIF_ANALYZE: OTIF_ANALYZE,
203
+ OTIF_READ: OTIF_READ,
204
+ OTIF_WRITE: OTIF_WRITE,
205
+ PLACEHOLDER_NOTIFICATION_READ: PLACEHOLDER_NOTIFICATION_READ,
206
+ PLACEHOLDER_NOTIFICATION_WRITE: PLACEHOLDER_NOTIFICATION_WRITE,
207
+ PROJECTION_READ: PROJECTION_READ,
208
+ PROJECTION_WRITE: PROJECTION_WRITE,
209
+ QUOTA_NOTIFICATION_READ: QUOTA_NOTIFICATION_READ,
210
+ QUOTA_NOTIFICATION_WRITE: QUOTA_NOTIFICATION_WRITE,
211
+ QUOTA_READ: QUOTA_READ,
212
+ QUOTA_WRITE: QUOTA_WRITE,
213
+ RELATION_READ: RELATION_READ,
214
+ RELATION_WRITE: RELATION_WRITE,
215
+ RESOURCE_READ: RESOURCE_READ,
216
+ RESOURCE_WRITE: RESOURCE_WRITE,
217
+ RUN_AS: RUN_AS,
218
+ SEARCH: SEARCH,
219
+ SEQUENCE_READ: SEQUENCE_READ,
220
+ SEQUENCE_WRITE: SEQUENCE_WRITE,
221
+ SHAPE_TAG_READ: SHAPE_TAG_READ,
222
+ SHAPE_TAG_WRITE: SHAPE_TAG_WRITE,
223
+ SITE_MANAGER: SITE_MANAGER,
224
+ SITE_RULE_READ: SITE_RULE_READ,
225
+ SITE_RULE_WRITE: SITE_RULE_WRITE,
226
+ STORAGE_GROUP_READ: STORAGE_GROUP_READ,
227
+ STORAGE_GROUP_WRITE: STORAGE_GROUP_WRITE,
228
+ STORAGE_NOTIFICATION_READ: STORAGE_NOTIFICATION_READ,
229
+ STORAGE_NOTIFICATION_WRITE: STORAGE_NOTIFICATION_WRITE,
230
+ STORAGE_READ: STORAGE_READ,
231
+ STORAGE_RULE_READ: STORAGE_RULE_READ,
232
+ STORAGE_RULE_WRITE: STORAGE_RULE_WRITE,
233
+ STORAGE_WRITE: STORAGE_WRITE,
234
+ SUPER_ACCESS_USER: SUPER_ACCESS_USER,
235
+ TASKDEFINITION_READ: TASKDEFINITION_READ,
236
+ TASKDEFINITION_WRITE: TASKDEFINITION_WRITE,
237
+ THUMBNAIL_READ: THUMBNAIL_READ,
238
+ THUMBNAIL_WRITE: THUMBNAIL_WRITE,
239
+ TRANSCODER: TRANSCODER,
240
+ TRANSFER_READ: TRANSFER_READ,
241
+ TRANSFER_WRITE: TRANSFER_WRITE,
242
+ USER: USER,
243
+ VXA: VXA,
244
+ VXA_READ: VXA_READ
245
+ });
42
246
 
43
- case 'DAY':
44
- case 'DAYS':
45
- if (sign === '+') nowDiff.setDate(nowDiff.getDate() + number);
46
- if (sign === '-') nowDiff.setDate(nowDiff.getDate() - number);
47
- break;
247
+ var _excluded$4 = ["groupName"],
248
+ _excluded2$2 = ["start", "end"];
48
249
 
49
- case 'MONTH':
50
- case 'MONTHS':
51
- if (sign === '+') nowDiff.setMonth(nowDiff.getMonth() + number);
52
- if (sign === '-') nowDiff.setMonth(nowDiff.getMonth() - number);
53
- break;
250
+ 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; }
54
251
 
55
- case 'YEAR':
56
- case 'YEARS':
57
- if (sign === '+') nowDiff.setFullYear(nowDiff.getFullYear() + number);
58
- if (sign === '-') nowDiff.setFullYear(nowDiff.getFullYear() - number);
59
- break;
60
- }
252
+ 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(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; }
61
253
 
62
- return nowDiff;
254
+ var parseValueList$1 = function parseValueList(value) {
255
+ if (value === undefined) return [];
256
+ if (value === null) return [{
257
+ value: ''
258
+ }];
259
+
260
+ if (Array.isArray(value)) {
261
+ return value.map(function (valueOrObject) {
262
+ if (_typeof(valueOrObject) === 'object') {
263
+ return _objectSpread$7({
264
+ value: valueOrObject.value || ''
265
+ }, valueOrObject);
266
+ }
267
+
268
+ return {
269
+ value: valueOrObject
270
+ };
271
+ });
63
272
  }
64
273
 
65
- return new Date(value);
274
+ if (value.value) return [value];
275
+ return [{
276
+ value: value
277
+ }];
66
278
  };
67
279
 
68
- var _CONSTANT_TIMEBASES;
280
+ var parseValue = function parseValue() {
281
+ var fieldValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
69
282
 
70
- var PAL = 'PAL';
71
- var NTSC = 'NTSC';
72
- var NTSC30 = 'NTSC30';
73
- var CONSTANT_TIMEBASES = (_CONSTANT_TIMEBASES = {}, _defineProperty(_CONSTANT_TIMEBASES, PAL, {
74
- denominator: 25,
75
- numerator: 1
76
- }), _defineProperty(_CONSTANT_TIMEBASES, NTSC, {
77
- denominator: 30000,
78
- numerator: 1001
79
- }), _defineProperty(_CONSTANT_TIMEBASES, NTSC30, {
80
- denominator: 30,
81
- numerator: 1
82
- }), _defineProperty(_CONSTANT_TIMEBASES, 29.97, {
83
- denominator: 30000,
84
- numerator: 1001
85
- }), _defineProperty(_CONSTANT_TIMEBASES, 59.94, {
86
- denominator: 60000,
87
- numerator: 1001
88
- }), _CONSTANT_TIMEBASES);
89
- var FRAME_SEPARATORS = {
90
- ':': {
91
- dropFrame: false,
92
- field: 2
93
- },
94
- ';': {
95
- dropFrame: true,
96
- field: 2
97
- },
98
- '.': {
99
- dropFrame: false,
100
- field: 1
101
- },
102
- ',': {
103
- dropFrame: true,
104
- field: 1
283
+ if (fieldValue && (fieldValue.value || fieldValue.name)) {
284
+ var valueList = fieldValue.value,
285
+ uuid = fieldValue.uuid;
286
+ var value = parseValueList$1(valueList);
287
+ return {
288
+ value: value,
289
+ uuid: uuid
290
+ };
105
291
  }
106
- };
107
292
 
108
- 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; }
293
+ return {
294
+ value: parseValueList$1(fieldValue)
295
+ };
296
+ };
109
297
 
110
- 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(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; }
298
+ var parseField$1 = function parseField() {
299
+ var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
300
+ var name = field.name,
301
+ value = field.value;
302
+ var parsedValue = parseValue(value);
303
+ return _objectSpread$7({
304
+ name: name
305
+ }, parsedValue);
306
+ };
111
307
 
112
- var splitSmpte = function splitSmpte(smpteText) {
113
- var hasDropFrameSeparator = smpteText.match(/[^0-9:\-_]/);
114
- var hhmmssff;
115
- var frameOptions = {};
308
+ var shouldBeField = function shouldBeField(_ref) {
309
+ var name = _ref.name,
310
+ value = _ref.value;
311
+ return ['string', 'boolean', 'number'].includes(_typeof(value)) || name !== 'group' && Array.isArray(value) || value === null;
312
+ };
116
313
 
117
- if (hasDropFrameSeparator) {
118
- var _hasDropFrameSeparato = _slicedToArray(hasDropFrameSeparator, 1),
119
- frameSeparator = _hasDropFrameSeparato[0];
314
+ var parseGroup$1 = function parseGroup() {
315
+ var thisGroup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
316
+ var groupName = thisGroup.name,
317
+ _thisGroup$value = thisGroup.value,
318
+ groupsOrFields = _thisGroup$value === void 0 ? {} : _thisGroup$value; // eslint-disable-next-line no-use-before-define
120
319
 
121
- var _smpteText$split = smpteText.split(frameSeparator),
122
- _smpteText$split2 = _slicedToArray(_smpteText$split, 2),
123
- hhmmss = _smpteText$split2[0],
124
- splitFrames = _smpteText$split2[1];
320
+ var _parseGroupsOrFields = parseGroupsOrFields(groupsOrFields),
321
+ field = _parseGroupsOrFields.field,
322
+ group = _parseGroupsOrFields.group;
125
323
 
126
- hhmmssff = [].concat(_toConsumableArray(hhmmss.split(':')), [splitFrames]);
127
- frameOptions = FRAME_SEPARATORS[frameSeparator] || {};
128
- } else {
129
- hhmmssff = smpteText.split(':');
130
- }
324
+ return {
325
+ name: groupName,
326
+ group: group,
327
+ field: field
328
+ };
329
+ };
131
330
 
132
- hhmmssff = hhmmssff.map(Number);
331
+ var parseGroupsOrFields = function parseGroupsOrFields(groupsOrFields) {
332
+ var group = [];
333
+ var field = [];
334
+ Object.entries(groupsOrFields).forEach(function (_ref2) {
335
+ var _ref3 = _slicedToArray(_ref2, 2),
336
+ name = _ref3[0],
337
+ value = _ref3[1];
133
338
 
134
- if (hhmmssff.length > 4 || hhmmssff.some(function (n) {
135
- return Number.isNaN(n);
136
- })) {
137
- throw new Error('Invalid SMPTE timecode');
138
- }
339
+ if (shouldBeField({
340
+ name: name,
341
+ value: value
342
+ })) {
343
+ field.push(parseField$1({
344
+ name: name,
345
+ value: value
346
+ }));
347
+ } else if (Array.isArray(value)) {
348
+ value.forEach(function (_ref4) {
349
+ var groupName = _ref4.groupName,
350
+ groupValue = _objectWithoutProperties(_ref4, _excluded$4);
139
351
 
140
- return [hhmmssff, frameOptions];
352
+ group.push(parseGroup$1({
353
+ name: groupName,
354
+ value: groupValue
355
+ }));
356
+ });
357
+ } else {
358
+ group.push(parseGroup$1({
359
+ name: name,
360
+ value: value
361
+ }));
362
+ }
363
+ });
364
+ return {
365
+ group: group,
366
+ field: field
367
+ };
141
368
  };
142
369
 
143
- var getDropFrames = function getDropFrames(roundedFrameRate) {
144
- return roundedFrameRate === 60 ? 4 : 2;
145
- };
370
+ var parseTimespan$1 = function parseTimespan() {
371
+ var timespan = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
146
372
 
147
- var getRoundedFrameRate = function getRoundedFrameRate(timeBase) {
148
- return Math.round(timeBase.denominator / timeBase.numerator);
149
- };
373
+ var _ref5 = timespan || {},
374
+ _ref5$start = _ref5.start,
375
+ start = _ref5$start === void 0 ? '-INF' : _ref5$start,
376
+ _ref5$end = _ref5.end,
377
+ end = _ref5$end === void 0 ? '+INF' : _ref5$end,
378
+ groupsOrFields = _objectWithoutProperties(_ref5, _excluded2$2);
150
379
 
151
- var countSamples = function countSamples(hh, mm, ss, ff, _ref) {
152
- var dropFrame = _ref.dropFrame,
153
- roundedFrameRate = _ref.roundedFrameRate;
380
+ var _parseGroupsOrFields2 = parseGroupsOrFields(groupsOrFields),
381
+ group = _parseGroupsOrFields2.group,
382
+ field = _parseGroupsOrFields2.field;
154
383
 
155
- if (!dropFrame) {
156
- return hh * 3600 * roundedFrameRate + mm * 60 * roundedFrameRate + ss * roundedFrameRate + ff;
157
- }
384
+ return {
385
+ start: start,
386
+ end: end,
387
+ field: field,
388
+ group: group
389
+ };
390
+ };
391
+ /**
392
+ * Create a MetadataType object from a metadata object
393
+ * @param {Object} metadata={} - object with metadata to create MetadataType object of
394
+ * @returns {Object} MetadataType
395
+ */
158
396
 
159
- if (![30, 60].includes(roundedFrameRate)) {
160
- throw new Error('Cannot use dropframe with non NTSC timebase');
161
- }
162
397
 
163
- var dropFrames = getDropFrames(roundedFrameRate);
164
- var shouldDropMinute = mm % 10 !== 0;
165
- var shouldDropSecond = shouldDropMinute && ss === 0;
166
- var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
167
- var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
168
- var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
398
+ var createMetadataType = function createMetadataType() {
399
+ var metadata = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
400
+ var metadataType = {};
169
401
 
170
- if (shouldDropSecond && ff < dropFrames) {
171
- throw new Error('Invalid ff');
402
+ if (Array.isArray(metadata)) {
403
+ metadataType.timespan = metadata.map(function (thisTimeSpan) {
404
+ return parseTimespan$1(thisTimeSpan);
405
+ });
406
+ } else {
407
+ var genericTimespan = parseTimespan$1(metadata);
408
+ metadataType.timespan = [genericTimespan];
172
409
  }
173
410
 
174
- var frameFrames = shouldDropSecond ? ff - dropFrames : ff;
175
- return hourFrames + minuteFrames + secondFrames + frameFrames;
411
+ return metadataType;
176
412
  };
177
413
 
178
- function countDroppedFrames(frames, roundedFrameRate) {
179
- var dropFrames = getDropFrames(roundedFrameRate);
180
- var oneMinuteUndroppedFrames = 60 * roundedFrameRate;
181
- var oneMinuteDroppedFrames = 60 * roundedFrameRate - dropFrames;
182
- var tenMinuteFrames = 10 * (oneMinuteUndroppedFrames - dropFrames) + dropFrames;
183
- var tenMinuteChunks = Math.floor(frames / tenMinuteFrames);
184
- var minuteRemainder = Math.max(0, frames % tenMinuteFrames - oneMinuteUndroppedFrames);
185
- var oneMinuteChunks = Math.floor(minuteRemainder / oneMinuteDroppedFrames);
186
- var frameRemainder = minuteRemainder % oneMinuteDroppedFrames;
187
- var frameChunks = frameRemainder > 0 ? dropFrames : 0;
188
- return tenMinuteChunks * 9 * dropFrames + oneMinuteChunks * dropFrames + frameChunks;
189
- }
190
- /**
191
- * @class TimeBase
192
- * @constructs formatTimeBaseText(timeBaseText: string)
193
- */
194
-
414
+ var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
415
+ var firstStart = timespan1.start;
416
+ var secondStart = timespan2.start;
195
417
 
196
- var TimeBase = /*#__PURE__*/function () {
197
- function TimeBase() {
198
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
199
- _ref2$numerator = _ref2.numerator,
200
- numerator = _ref2$numerator === void 0 ? 1 : _ref2$numerator,
201
- _ref2$denominator = _ref2.denominator,
202
- denominator = _ref2$denominator === void 0 ? 1 : _ref2$denominator;
418
+ var _firstStart$split = firstStart.split('@'),
419
+ _firstStart$split2 = _slicedToArray(_firstStart$split, 1),
420
+ first = _firstStart$split2[0];
203
421
 
204
- _classCallCheck(this, TimeBase);
422
+ var _secondStart$split = secondStart.split('@'),
423
+ _secondStart$split2 = _slicedToArray(_secondStart$split, 1),
424
+ second = _secondStart$split2[0];
205
425
 
206
- this.numerator = Number(numerator);
207
- this.denominator = Number(denominator);
426
+ if (Number(first) < Number(second)) {
427
+ return -1;
208
428
  }
209
429
 
210
- _createClass(TimeBase, [{
211
- key: "toJSON",
212
- value: function toJSON() {
213
- return {
214
- denominator: this.denominator,
215
- numerator: this.numerator
216
- };
217
- }
218
- }, {
219
- key: "toConstant",
220
- value: function toConstant() {
221
- var _this = this;
430
+ if (Number(first) > Number(second)) {
431
+ return 1;
432
+ }
222
433
 
223
- var constant;
224
- Object.entries(CONSTANT_TIMEBASES).find(function (thisTimeBase) {
225
- var _thisTimeBase = _slicedToArray(thisTimeBase, 2),
226
- thisTimeBaseText = _thisTimeBase[0],
227
- thisTimeBaseType = _thisTimeBase[1];
434
+ return 0;
435
+ };
228
436
 
229
- var numerator = thisTimeBaseType.numerator,
230
- denominator = thisTimeBaseType.denominator;
437
+ var _excluded$3 = ["value"],
438
+ _excluded2$1 = ["field", "group"],
439
+ _excluded3 = ["field", "group"];
231
440
 
232
- if (numerator === _this.numerator && denominator === _this.denominator) {
233
- constant = thisTimeBaseText;
234
- return true;
235
- }
441
+ 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; }
236
442
 
237
- return false;
238
- });
239
- return constant;
240
- }
241
- }, {
242
- key: "toText",
243
- value: function toText() {
244
- var useConstant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
443
+ 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(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; }
245
444
 
246
- if (useConstant) {
247
- var _timeBaseText = this.toConstant();
445
+ var parseValueList = function parseValueList() {
446
+ var valueList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
447
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
248
448
 
249
- if (_timeBaseText) return _timeBaseText;
250
- }
449
+ var _ref = options || {},
450
+ _ref$arrayOnSingle = _ref.arrayOnSingle,
451
+ arrayOnSingle = _ref$arrayOnSingle === void 0 ? true : _ref$arrayOnSingle,
452
+ _ref$arrayOnSingleVal = _ref.arrayOnSingleValue,
453
+ arrayOnSingleValue = _ref$arrayOnSingleVal === void 0 ? true : _ref$arrayOnSingleVal,
454
+ joinValue = _ref.joinValue,
455
+ includeAttributes = _ref.includeAttributes,
456
+ includeValueAttributes = _ref.includeValueAttributes;
251
457
 
252
- if (this.numerator > 1) {
253
- var _timeBaseText2 = [this.denominator, this.numerator].join(':');
458
+ if (includeAttributes || includeValueAttributes) return valueList;
459
+ var valueArray = [];
460
+ valueList.forEach(function (thisValue) {
461
+ if (thisValue.value) valueArray.push(thisValue.value);
462
+ });
463
+ if (joinValue) return valueArray.join(joinValue);
254
464
 
255
- return _timeBaseText2;
256
- }
465
+ if (arrayOnSingle === false || arrayOnSingleValue === false && valueArray.length === 1) {
466
+ return valueArray[0];
467
+ }
257
468
 
258
- var timeBaseText = String(this.denominator);
259
- return timeBaseText;
260
- }
261
- }, {
262
- key: "toRate",
263
- value: function toRate() {
264
- var useConstant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
265
- var round = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
469
+ return valueArray;
470
+ };
266
471
 
267
- if (useConstant) {
268
- var _rate = this.toConstant();
472
+ var parseField = function parseField() {
473
+ var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
474
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
269
475
 
270
- if (_rate) return _rate;
271
- }
476
+ var _ref2 = options || {},
477
+ includeAttributes = _ref2.includeAttributes,
478
+ includeFieldAttributes = _ref2.includeFieldAttributes;
272
479
 
273
- var rate = this.denominator / this.numerator;
480
+ var _field$value = field.value,
481
+ value = _field$value === void 0 ? [] : _field$value,
482
+ attributes = _objectWithoutProperties(field, _excluded$3);
274
483
 
275
- if (Number.isInteger(rate)) {
276
- return rate;
277
- }
484
+ var parsedValueList = parseValueList(value, options);
485
+ if (includeAttributes || includeFieldAttributes) return _objectSpread$6(_objectSpread$6({}, attributes), {}, {
486
+ value: parsedValueList
487
+ });
488
+ return parsedValueList;
489
+ };
278
490
 
279
- return round ? rate.toFixed(2) : rate;
280
- }
281
- }]);
491
+ var parseFieldList = function parseFieldList() {
492
+ var fieldList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
493
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
282
494
 
283
- return TimeBase;
284
- }();
495
+ var _ref3 = options || {},
496
+ joinValue = _ref3.joinValue,
497
+ includeAttributes = _ref3.includeAttributes,
498
+ includeFieldAttributes = _ref3.includeFieldAttributes,
499
+ includeValueAttributes = _ref3.includeValueAttributes,
500
+ fieldAsList = _ref3.fieldAsList;
285
501
 
286
- var isDropFrameTimeBase = function isDropFrameTimeBase(_ref3) {
287
- var numerator = _ref3.numerator,
288
- denominator = _ref3.denominator;
289
- return numerator === 1001 && (denominator === 60000 || denominator === 30000);
290
- };
502
+ var output = {};
291
503
 
292
- var TimeCode = /*#__PURE__*/function () {
293
- function TimeCode() {
294
- var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
295
- _ref4$samples = _ref4.samples,
296
- samples = _ref4$samples === void 0 ? 0 : _ref4$samples,
297
- timeBase = _ref4.timeBase;
504
+ if (fieldAsList) {
505
+ return fieldList.map(function (thisField) {
506
+ return parseField(thisField, options);
507
+ });
508
+ }
298
509
 
299
- var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
300
- dropFrame = _ref5.dropFrame,
301
- _ref5$field = _ref5.field,
302
- field = _ref5$field === void 0 ? 2 : _ref5$field;
510
+ fieldList.forEach(function (thisField) {
511
+ var key = thisField.name;
512
+ var parsedField = parseField(thisField, options);
303
513
 
304
- _classCallCheck(this, TimeCode);
514
+ if (output[key]) {
515
+ if (includeAttributes || includeFieldAttributes) {
516
+ var currentValue = output[key].value;
517
+ var parsedValue = parsedField.value;
305
518
 
306
- if (typeof samples === 'number') {
307
- this.samples = samples;
308
- } else if (typeof samples === 'string') {
309
- if (samples === '-INF') {
310
- this.samples = -Infinity;
311
- } else if (samples === '+INF') {
312
- this.samples = Infinity;
519
+ if (joinValue && !includeAttributes && !includeValueAttributes) {
520
+ output[key].value = [currentValue, parsedValue].join(joinValue);
521
+ } else {
522
+ output[key].value = parsedValue.concat(currentValue);
523
+ }
313
524
  } else {
314
- this.samples = Number(samples);
525
+ var _currentValue = output[key];
526
+ var _parsedValue = parsedField;
527
+
528
+ if (joinValue) {
529
+ output[key] = [_currentValue, _parsedValue].join(joinValue);
530
+ } else {
531
+ output[key] = _parsedValue.concat(_currentValue);
532
+ }
315
533
  }
316
534
  } else {
317
- throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));
535
+ output[key] = parsedField;
318
536
  }
537
+ });
538
+ return output;
539
+ };
319
540
 
320
- this.timeBase = new TimeBase(timeBase);
321
- this.dropFrame = dropFrame === undefined ? isDropFrameTimeBase(this.timeBase) : dropFrame;
322
- this.field = field;
323
- }
541
+ var parseGroup = function parseGroup() {
542
+ var group = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
543
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
324
544
 
325
- _createClass(TimeCode, [{
326
- key: "add",
327
- value: function add(val) {
328
- var _val$timeBase = val.timeBase,
329
- numerator = _val$timeBase.numerator,
330
- denominator = _val$timeBase.denominator;
331
- var conformedTimeCode = val;
545
+ var _ref4 = options || {},
546
+ includeAttributes = _ref4.includeAttributes,
547
+ includeGroupAttributes = _ref4.includeGroupAttributes,
548
+ flat = _ref4.flat,
549
+ flatGroup = _ref4.flatGroup,
550
+ groupAsList = _ref4.groupAsList,
551
+ fieldAsList = _ref4.fieldAsList;
332
552
 
333
- if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
334
- conformedTimeCode = val.conformTimeBase(this.timeBase);
335
- }
553
+ var _group$field = group.field,
554
+ fieldList = _group$field === void 0 ? [] : _group$field,
555
+ _group$group = group.group,
556
+ groupList = _group$group === void 0 ? [] : _group$group,
557
+ attributes = _objectWithoutProperties(group, _excluded2$1);
336
558
 
337
- var _conformedTimeCode = conformedTimeCode,
338
- samples = _conformedTimeCode.samples;
339
- return new TimeCode({
340
- samples: this.samples + samples,
341
- timeBase: this.timeBase
559
+ var parsedFieldList = parseFieldList(fieldList, options); // eslint-disable-next-line no-use-before-define
560
+
561
+ var parsedGroupList = parseGroupList(groupList, options);
562
+ var output = {};
563
+
564
+ if (includeAttributes || includeGroupAttributes) {
565
+ Object.assign(output, attributes);
566
+ }
567
+
568
+ if (flat || flatGroup) {
569
+ if (groupAsList) {
570
+ Object.assign(output, {
571
+ group: parsedGroupList
342
572
  });
573
+ } else {
574
+ Object.assign(output, parsedGroupList);
343
575
  }
344
- }, {
345
- key: "subtract",
346
- value: function subtract(val) {
347
- var _val$timeBase2 = val.timeBase,
348
- numerator = _val$timeBase2.numerator,
349
- denominator = _val$timeBase2.denominator;
350
- var conformedTimeCode = val;
351
-
352
- if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
353
- conformedTimeCode = val.conformTimeBase(this.timeBase);
354
- }
355
576
 
356
- var _conformedTimeCode2 = conformedTimeCode,
357
- samples = _conformedTimeCode2.samples;
358
- return new TimeCode({
359
- samples: this.samples - samples,
360
- timeBase: this.timeBase
577
+ if (fieldAsList) {
578
+ Object.assign(output, {
579
+ field: parsedFieldList
361
580
  });
581
+ } else {
582
+ Object.assign(output, parsedFieldList);
362
583
  }
363
- }, {
364
- key: "conformTimeBase",
365
- value: function conformTimeBase(conformTo) {
366
- var timeBase = conformTo;
584
+ } else {
585
+ Object.assign(output, {
586
+ field: parsedFieldList
587
+ });
588
+ Object.assign(output, {
589
+ group: parsedGroupList
590
+ });
591
+ }
367
592
 
368
- if (conformTo instanceof TimeCode === false) {
369
- timeBase = new TimeBase(conformTo);
370
- }
593
+ return output;
594
+ };
371
595
 
372
- var samples = Math.round(this.samples / (this.timeBase.toRate(false, false) / timeBase.toRate(false, false)));
373
- var timeCode = {
374
- samples: samples,
375
- timeBase: timeBase
376
- };
377
- return new TimeCode(timeCode);
378
- }
379
- }, {
380
- key: "toJSON",
381
- value: function toJSON() {
382
- return {
383
- samples: this.samples,
384
- timeBase: this.timeBase
385
- };
386
- }
387
- }, {
388
- key: "toText",
389
- value: function toText() {
390
- var timeCodeText = String(this.samples);
391
- var timeBaseText = this.timeBase.toText();
596
+ var parseGroupList = function parseGroupList() {
597
+ var groupList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
598
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
392
599
 
393
- if (timeBaseText !== '1') {
394
- timeCodeText = [this.samples, timeBaseText].join('@');
395
- }
600
+ var _ref5 = options || {},
601
+ groupAsList = _ref5.groupAsList;
396
602
 
397
- return timeCodeText;
398
- }
399
- }, {
400
- key: "toSeconds",
401
- value: function toSeconds() {
402
- var _this$timeBase = this.timeBase,
403
- numerator = _this$timeBase.numerator,
404
- denominator = _this$timeBase.denominator;
405
- return this.samples * (numerator / denominator);
406
- }
407
- }, {
408
- key: "toTime",
409
- value: function toTime() {
410
- var roundedFrameRate = getRoundedFrameRate(this.timeBase);
411
- var totalSamples = this.samples + (this.dropFrame ? countDroppedFrames(this.samples + 1, roundedFrameRate) : 0);
412
- var hours = Math.floor(totalSamples / (3600 * roundedFrameRate));
413
- var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
414
- var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
415
- var frames = totalSamples % roundedFrameRate;
416
- var partialSeconds = frames / roundedFrameRate;
417
- return {
418
- hours: hours,
419
- minutes: minutes,
420
- seconds: seconds,
421
- frames: frames,
422
- partialSeconds: partialSeconds
423
- };
424
- }
425
- }, {
426
- key: "toDuration",
427
- value: function toDuration() {
428
- var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
429
- format = _ref6.format;
430
-
431
- var _this$toTime = this.toTime(),
432
- hours = _this$toTime.hours,
433
- minutes = _this$toTime.minutes,
434
- seconds = _this$toTime.seconds;
435
-
436
- if (typeof format === 'string') {
437
- if (format.toLowerCase() === 'hhmmss') {
438
- return [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
439
- }
440
- }
441
-
442
- if (hours) {
443
- return [hours.toFixed(), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
444
- }
603
+ if (groupAsList) {
604
+ return groupList.map(function (thisGroup) {
605
+ return parseGroup(thisGroup, options);
606
+ });
607
+ }
445
608
 
446
- if (minutes >= 10) {
447
- return [minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
448
- }
609
+ var output = {};
610
+ groupList.forEach(function (thisGroup) {
611
+ var key = thisGroup.name;
612
+ var parsedGroup = parseGroup(thisGroup, options);
449
613
 
450
- return [minutes.toFixed(), seconds.toFixed().padStart(2, '0')].join(':');
614
+ if (output[key]) {
615
+ var _output$key = output[key],
616
+ currentField = _output$key.field,
617
+ currentGroup = _output$key.group;
618
+ var parsedField = parsedGroup.field,
619
+ parsedGroupList = parsedGroup.group;
620
+ output[key].field = _objectSpread$6(_objectSpread$6({}, currentField), parsedField);
621
+ output[key].group = _objectSpread$6(_objectSpread$6({}, currentGroup), parsedGroupList);
622
+ } else {
623
+ output[key] = parsedGroup;
451
624
  }
452
- }, {
453
- key: "toSmpte",
454
- value: function toSmpte() {
455
- var _this2 = this;
456
-
457
- if (this.samples === -Infinity) return '00:00:00:00';
458
-
459
- var _this$toTime2 = this.toTime(),
460
- hours = _this$toTime2.hours,
461
- minutes = _this$toTime2.minutes,
462
- seconds = _this$toTime2.seconds,
463
- frames = _this$toTime2.frames;
464
-
465
- var hhmmss = [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
466
-
467
- var _Object$entries$find = Object.entries(FRAME_SEPARATORS).find(function (thisSeparator) {
468
- var _thisSeparator = _slicedToArray(thisSeparator, 2),
469
- _thisSeparator$ = _thisSeparator[1],
470
- dropFrame = _thisSeparator$.dropFrame,
471
- field = _thisSeparator$.field;
625
+ });
626
+ return output;
627
+ };
628
+ /**
629
+ * Parses timespan according to specified options.
630
+ * The attributes can be targeted for each sub-type.
631
+ * @param {Object} timespan={} - The timespan response from the API.
632
+ * @param {Object} options={} - Options which change how the metadataType is parsed.
633
+ * @param {string} options.joinValue=undefined - String to join the values, eg ','.
634
+ * @param {boolean} options.includeAttributes=false - Include attributes on all objects.
635
+ * @param {boolean} options.includeTimespanAttributes=false - Include attributes on timespans.
636
+ * @param {boolean} options.includeGroupAttributes=false - Include attributes on groups.
637
+ * @param {boolean} options.includeFieldAttributes=false - Include attributes on fields.
638
+ * @param {boolean} options.includeValueAttributes=false - Include attributes on values.
639
+ * @param {boolean} options.flat=false - Flatten to key/value (Note: keys may be overwritten).
640
+ * @param {boolean} options.flatTimespan=false - Flatten timespan.
641
+ * @param {boolean} options.flatGroup=false - Flatten group.
642
+ * @param {boolean} options.groupAsList=false - Return groups as list.
643
+ * @param {boolean} options.fieldAsList=false - Return fields as list.
644
+ * @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
645
+ * @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
646
+ * @returns {Object} Metadata object parsed according to options.
647
+ */
472
648
 
473
- return dropFrame === _this2.dropFrame && field === _this2.field;
474
- }),
475
- _Object$entries$find2 = _slicedToArray(_Object$entries$find, 1),
476
- _Object$entries$find3 = _Object$entries$find2[0],
477
- frameSeparator = _Object$entries$find3 === void 0 ? ':' : _Object$entries$find3;
478
649
 
479
- return [hhmmss, frames.toFixed().padStart(2, '0')].join(frameSeparator);
480
- }
481
- }, {
482
- key: "toFraction",
483
- value: function toFraction() {
484
- return "".concat(this.samples, "@").concat(this.timeBase.denominator, ":").concat(this.timeBase.numerator);
485
- }
486
- }]);
650
+ var parseTimespan = function parseTimespan() {
651
+ var timespan = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
652
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
487
653
 
488
- return TimeCode;
489
- }();
654
+ var _ref6 = options || {},
655
+ includeAttributes = _ref6.includeAttributes,
656
+ includeTimespanAttributes = _ref6.includeTimespanAttributes,
657
+ flat = _ref6.flat,
658
+ flatTimespan = _ref6.flatTimespan,
659
+ groupAsList = _ref6.groupAsList,
660
+ fieldAsList = _ref6.fieldAsList;
490
661
 
491
- var formatTimeBaseType = function formatTimeBaseType(timeBase) {
492
- return new TimeBase(timeBase);
493
- };
662
+ var _timespan$field = timespan.field,
663
+ fieldList = _timespan$field === void 0 ? [] : _timespan$field,
664
+ _timespan$group = timespan.group,
665
+ groupList = _timespan$group === void 0 ? [] : _timespan$group,
666
+ attributes = _objectWithoutProperties(timespan, _excluded3);
494
667
 
495
- var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
496
- if (timeBaseText === undefined) {
497
- return formatTimeBaseType();
498
- }
668
+ var field = parseFieldList(fieldList, options);
669
+ var group = parseGroupList(groupList, options);
670
+ var output = {};
499
671
 
500
- if (typeof timeBaseText === 'number') {
501
- return formatTimeBaseType({
502
- denominator: timeBaseText
503
- });
672
+ if (includeAttributes || includeTimespanAttributes) {
673
+ Object.assign(output, attributes);
504
674
  }
505
675
 
506
- if (timeBaseText.includes(':')) {
507
- var _timeBaseText$split = timeBaseText.split(':'),
508
- _timeBaseText$split2 = _slicedToArray(_timeBaseText$split, 2),
509
- _denominator = _timeBaseText$split2[0],
510
- numerator = _timeBaseText$split2[1];
676
+ if (flat || flatTimespan) {
677
+ if (groupAsList) {
678
+ Object.assign(output, {
679
+ group: group
680
+ });
681
+ } else {
682
+ Object.assign(output, group);
683
+ }
511
684
 
512
- return formatTimeBaseType({
513
- denominator: _denominator,
514
- numerator: numerator
685
+ if (fieldAsList) {
686
+ Object.assign(output, {
687
+ field: field
688
+ });
689
+ } else {
690
+ Object.assign(output, field);
691
+ }
692
+ } else {
693
+ Object.assign(output, {
694
+ field: field
695
+ });
696
+ Object.assign(output, {
697
+ group: group
515
698
  });
516
699
  }
517
700
 
518
- if (Object.keys(CONSTANT_TIMEBASES).includes(timeBaseText)) {
519
- return formatTimeBaseType(CONSTANT_TIMEBASES[timeBaseText]);
520
- }
701
+ return output;
702
+ };
521
703
 
522
- var denominator = Number(timeBaseText);
704
+ 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; }
523
705
 
524
- if (Number.isNaN(denominator)) {
525
- throw new Error("timeBaseText must be a number or ".concat(Object.keys(CONSTANT_TIMEBASES).join(','), " - is ").concat(timeBaseText));
526
- }
706
+ 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(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; }
707
+ /**
708
+ * Parses timespanList according to specified options.
709
+ * The attributes can be targeted for each sub-type.
710
+ * @param {Object[]} timespanList - The timespanList response from the API.
711
+ * @param {Object} options - Options which change how the metadataType is parsed.
712
+ * @param {string} options.joinValue - String to join the values, eg ','.
713
+ * @param {boolean} options.includeAttributes - Include attributes on all objects.
714
+ * @param {boolean} options.includeMetadataAttributes - Include attributes on root.
715
+ * @param {boolean} options.includeTimespanAttributes - Include attributes on timespans.
716
+ * @param {boolean} options.includeGroupAttributes - Include attributes on groups.
717
+ * @param {boolean} options.includeFieldAttributes - Include attributes on fields.
718
+ * @param {boolean} options.includeValueAttributes - Include attributes on values.
719
+ * @param {boolean} options.flat - Flatten to key/value (Note: keys may be overwritten).
720
+ * @param {boolean} options.flatTimespan - Flatten timespan.
721
+ * @param {boolean} options.flatGroup - Flatten group.
722
+ * @param {boolean} options.sortTimespan - Sort timespan by start time.
723
+ * @param {boolean} options.timespanAsList - Return timespans as list.
724
+ * @param {boolean} options.groupAsList - Return groups as list.
725
+ * @param {boolean} options.fieldAsList - Return fields as list.
726
+ * @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
727
+ * @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
728
+ * @returns {Object} Metadata object parsed according to options.
729
+ */
527
730
 
528
- return formatTimeBaseType({
529
- denominator: denominator
530
- });
531
- };
731
+ var parseTimespanList = function parseTimespanList() {
732
+ var timespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
733
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
532
734
 
533
- var formatTimeBase = function formatTimeBase(timeBase) {
534
- if (_typeof(timeBase) === 'object') {
535
- return formatTimeBaseType(timeBase);
735
+ var _ref = options || {},
736
+ joinTimespan = _ref.joinTimespan,
737
+ flat = _ref.flat,
738
+ timespanAsList = _ref.timespanAsList;
739
+
740
+ if (timespanAsList) {
741
+ return timespanList.map(function (thisTimespan) {
742
+ return parseTimespan(thisTimespan, options);
743
+ });
536
744
  }
537
745
 
538
- return formatTimeBaseText(timeBase);
539
- };
746
+ var output = {};
747
+ timespanList.forEach(function (thisTimespan) {
748
+ var start = thisTimespan.start,
749
+ end = thisTimespan.end;
750
+ var key = [start, end].join(joinTimespan || '_');
751
+ var parsedTimespan = parseTimespan(thisTimespan, options);
540
752
 
541
- var formatTimeCodeType = function formatTimeCodeType(timeCode, options) {
542
- return new TimeCode(timeCode, options);
753
+ if (flat) {
754
+ output = _objectSpread$5(_objectSpread$5({}, output), parsedTimespan);
755
+ } else if (output[key]) {
756
+ var _output$key = output[key],
757
+ currentField = _output$key.field,
758
+ currentGroup = _output$key.group;
759
+ var parsedField = parsedTimespan.field,
760
+ parsedGroup = parsedTimespan.group;
761
+ output[key].field = _objectSpread$5(_objectSpread$5({}, currentField), parsedField);
762
+ output[key].group = _objectSpread$5(_objectSpread$5({}, currentGroup), parsedGroup);
763
+ } else {
764
+ output[key] = parsedTimespan;
765
+ }
766
+ });
767
+ return output;
543
768
  };
544
769
 
545
- var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
546
- if (timeCodeText === undefined) {
547
- var _timeCode = {
548
- samples: 0
549
- };
550
- return formatTimeCodeType(_timeCode, options);
551
- }
552
-
553
- if (typeof timeCodeText === 'number') {
554
- var _timeCode2 = {
555
- samples: timeCodeText
556
- };
557
- return formatTimeCodeType(_timeCode2, options);
558
- }
559
-
560
- if (timeCodeText.includes('@')) {
561
- var _timeCodeText$split = timeCodeText.split('@'),
562
- _timeCodeText$split2 = _slicedToArray(_timeCodeText$split, 2),
563
- samplesString = _timeCodeText$split2[0],
564
- timeBaseText = _timeCodeText$split2[1];
770
+ var _excluded$2 = ["timespan"];
771
+ /**
772
+ * Parses MetadataType according to specified options.
773
+ * The attributes can be targeted for each sub-type.
774
+ * @param {Object} metadataType - The MetadataType response from the API.
775
+ * @param {Object} options - Options which change how the metadataType is parsed.
776
+ * @param {string} options.joinValue - String to join the values, eg ','.
777
+ * @param {boolean} options.includeAttributes - Include attributes on all objects.
778
+ * @param {boolean} options.includeMetadataAttributes - Include attributes on root.
779
+ * @param {boolean} options.includeTimespanAttributes - Include attributes on timespans.
780
+ * @param {boolean} options.includeGroupAttributes - Include attributes on groups.
781
+ * @param {boolean} options.includeFieldAttributes - Include attributes on fields.
782
+ * @param {boolean} options.includeValueAttributes - Include attributes on values.
783
+ * @param {boolean} options.flat - Flatten to key/value (Note: keys may be overwritten).
784
+ * @param {boolean} options.flatTimespan - Flatten timespan.
785
+ * @param {boolean} options.flatGroup - Flatten group.
786
+ * @param {boolean} options.sortTimespan - Sort timespan by start time.
787
+ * @param {boolean} options.timespanAsList - Return timespans as list.
788
+ * @param {boolean} options.groupAsList - Return groups as list.
789
+ * @param {boolean} options.fieldAsList - Return fields as list.
790
+ * @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
791
+ * @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
792
+ * @returns {Object} Metadata object parsed according to options.
793
+ */
565
794
 
566
- var _samples = Number(samplesString);
795
+ var parseMetadataType = function parseMetadataType() {
796
+ var metadataType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
797
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
567
798
 
568
- var timeBase = formatTimeBaseText(timeBaseText);
569
- var _timeCode3 = {
570
- samples: _samples,
571
- timeBase: timeBase
572
- };
573
- return formatTimeCodeType(_timeCode3, options);
574
- }
799
+ var _ref = options || {},
800
+ includeAttributes = _ref.includeAttributes,
801
+ includeMetadataAttributes = _ref.includeMetadataAttributes,
802
+ sortTimespan = _ref.sortTimespan;
575
803
 
576
- if (timeCodeText === '-INF') {
577
- var _samples2 = -Infinity;
804
+ var _ref2 = metadataType || {},
805
+ _ref2$timespan = _ref2.timespan,
806
+ timespanList = _ref2$timespan === void 0 ? [] : _ref2$timespan,
807
+ attributes = _objectWithoutProperties(_ref2, _excluded$2);
578
808
 
579
- var _timeCode4 = {
580
- samples: _samples2
581
- };
582
- return formatTimeCodeType(_timeCode4, options);
583
- }
809
+ if (sortTimespan) timespanList.sort(sortTimespanList);
810
+ var timespan = parseTimespanList(timespanList, options);
584
811
 
585
- if (timeCodeText === '+INF') {
586
- var _samples3 = Infinity;
587
- var _timeCode5 = {
588
- samples: _samples3
589
- };
590
- return formatTimeCodeType(_timeCode5, options);
812
+ if (includeAttributes || includeMetadataAttributes) {
813
+ Object.assign(timespan, attributes);
591
814
  }
592
815
 
593
- var samples = Number(timeCodeText);
816
+ return timespan;
817
+ };
594
818
 
595
- if (Number.isNaN(samples)) {
596
- throw new Error("timeBaseText must be a number or sample@timeBase - is ".concat(timeCodeText));
597
- }
819
+ var parseSimpleMetadataType = function parseSimpleMetadataType() {
820
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
821
+ _ref$field = _ref.field,
822
+ field = _ref$field === void 0 ? [] : _ref$field;
598
823
 
599
- var timeCode = {
600
- samples: samples
601
- };
602
- return formatTimeCodeType(timeCode, options);
824
+ return parseKeyValuePairType(field);
603
825
  };
604
826
 
605
- var formatSeconds = function formatSeconds(seconds, timeBase, options) {
606
- if (Number.isNaN(Number(seconds))) {
607
- throw new Error("seconds must be digits, is ".concat(seconds));
608
- }
609
-
610
- var _ref7 = timeBase || {},
611
- _ref7$denominator = _ref7.denominator,
612
- denominator = _ref7$denominator === void 0 ? 1 : _ref7$denominator,
613
- _ref7$numerator = _ref7.numerator,
614
- numerator = _ref7$numerator === void 0 ? 1 : _ref7$numerator;
827
+ 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; }
615
828
 
616
- var samples = seconds * (denominator / numerator);
617
- var timeCode = {
618
- samples: samples,
619
- timeBase: timeBase || {}
620
- };
621
- return new TimeCode(timeCode, options);
622
- };
829
+ 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(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; }
623
830
 
624
- var formatSecondsPrecise = function formatSecondsPrecise(seconds, timeBase, options) {
625
- if (Number.isNaN(Number(seconds))) {
626
- throw new Error("seconds must be digits, is ".concat(seconds));
627
- }
831
+ /**
832
+ * Parses highlight timespan responses from the api into key/value object.
833
+ * The attributes can be targeted for each sub-type.
834
+ * @param {Object[]} highlightTimespan - A timespan object from the api response.
835
+ * @param {Object} options - Options which change how the timespans are parsed.
836
+ * @param {boolean} options.arrayOnSingle=true - Return an array if there is a single value.
837
+ * @param {boolean} options.timespanAsList=false - Return timespans as list.
838
+ * @param {string} options.joinValue - String to join the values, eg ','.
839
+ */
840
+ var parseHighlightTimespan = function parseHighlightTimespan() {
841
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
842
+ _ref$field = _ref.field,
843
+ field = _ref$field === void 0 ? [] : _ref$field,
844
+ start = _ref.start,
845
+ end = _ref.end;
628
846
 
629
- var _ref8 = timeBase || {},
630
- _ref8$numerator = _ref8.numerator,
631
- numerator = _ref8$numerator === void 0 ? 1 : _ref8$numerator;
847
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
848
+ var _opts$arrayOnSingle = opts.arrayOnSingle,
849
+ arrayOnSingle = _opts$arrayOnSingle === void 0 ? true : _opts$arrayOnSingle,
850
+ _opts$joinValue = opts.joinValue,
851
+ joinValue = _opts$joinValue === void 0 ? undefined : _opts$joinValue,
852
+ _opts$timespanAsList = opts.timespanAsList,
853
+ timespanAsList = _opts$timespanAsList === void 0 ? undefined : _opts$timespanAsList;
854
+ var initialValue = timespanAsList ? {
855
+ start: start,
856
+ end: end
857
+ } : {};
858
+ var fieldList = field.reduce(function (a, _ref2) {
859
+ var name = _ref2.name,
860
+ _ref2$value = _ref2.value,
861
+ valueList = _ref2$value === void 0 ? [] : _ref2$value;
862
+ if (valueList.length === 0) return a;
863
+ var fieldValue;
632
864
 
633
- var _ref9 = timeBase || {},
634
- _ref9$denominator = _ref9.denominator,
635
- denominator = _ref9$denominator === void 0 ? 1 : _ref9$denominator;
865
+ if (arrayOnSingle === false && valueList.length === 1) {
866
+ var _valueList = _slicedToArray(valueList, 1);
636
867
 
637
- if (!Number.isInteger(seconds)) {
638
- var decimalPlaces = String(seconds).split('.')[1].length;
639
- denominator *= Math.pow(10, decimalPlaces);
640
- }
868
+ fieldValue = _valueList[0];
869
+ } else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
641
870
 
642
- var samples = (seconds * (denominator / numerator)).toFixed();
643
- var timeCode = {
644
- samples: samples,
645
- timeBase: {
646
- denominator: denominator,
647
- numerator: numerator
648
- }
649
- };
650
- return new TimeCode(timeCode, options);
871
+ return _objectSpread$4(_objectSpread$4({}, a), {}, _defineProperty({}, name, fieldValue));
872
+ }, initialValue);
873
+ return fieldList;
651
874
  };
652
875
 
653
- var formatSmpte = function formatSmpte(smpteText, timeBaseText) {
654
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
876
+ 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; }
655
877
 
656
- if (smpteText === undefined) {
657
- var _timeBase = formatTimeBase(timeBaseText);
878
+ 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(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; }
879
+ /**
880
+ * Parses highlight timespans responses from the api into key/value object.
881
+ * The attributes can be targeted for each sub-type.
882
+ * @param {Object} highlightTimespanList - A list of timespans from the api response.
883
+ * @param {Object} options - Options which change how the timespans are parsed.
884
+ * @param {boolean} options.arrayOnSingle=true - Return an array if there is a single value.
885
+ * @param {string} options.joinValue - String to join the values, eg ','.
886
+ * @param {boolean} options.timespanAsList=false - Return timespans as list.
887
+ * @param {boolean} options.flat=false - Flatten to field-name/field-value (Note: field-values may be overwritten).
888
+ * @param {boolean} options.flatTimespan=false - Flatten timespan to object with start/end as key.
889
+ * @param {string} options.joinTimespan=_ - Character to join the start/end timecodes.
890
+ */
658
891
 
659
- var _timeCode6 = {
660
- samples: 0,
661
- timeBase: _timeBase
662
- };
663
- return formatTimeCodeType(_timeCode6);
664
- }
892
+ var parseHighlightTimespanList = function parseHighlightTimespanList() {
893
+ var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
894
+ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
895
+ var flat = opts.flat,
896
+ timespanAsList = opts.timespanAsList,
897
+ _opts$joinTimespan = opts.joinTimespan,
898
+ joinTimespan = _opts$joinTimespan === void 0 ? '_' : _opts$joinTimespan,
899
+ flatTimespan = opts.flatTimespan;
900
+ if (timespanAsList === true) return highlightTimespanList.map(function (timespan) {
901
+ return parseHighlightTimespan(timespan, opts);
902
+ });
903
+ if (flat === true || flatTimespan === true) return highlightTimespanList.reduce(function (a, timespan) {
904
+ return _objectSpread$3(_objectSpread$3({}, a), parseHighlightTimespan(timespan, opts));
905
+ }, {});
906
+ return highlightTimespanList.reduce(function (a, timespan) {
907
+ return _objectSpread$3(_objectSpread$3({}, a), {}, _defineProperty({}, [timespan.start, timespan.end].join(joinTimespan), parseHighlightTimespan(timespan, opts)));
908
+ }, {});
909
+ };
665
910
 
666
- if (typeof smpteText !== 'string') {
667
- throw new Error("smpteText must be a string, is ".concat(smpteText));
911
+ var _CONSTANT_TIMEBASES;
912
+
913
+ var PAL = 'PAL';
914
+ var NTSC = 'NTSC';
915
+ var NTSC30 = 'NTSC30';
916
+ var CONSTANT_TIMEBASES = (_CONSTANT_TIMEBASES = {}, _defineProperty(_CONSTANT_TIMEBASES, PAL, {
917
+ denominator: 25,
918
+ numerator: 1
919
+ }), _defineProperty(_CONSTANT_TIMEBASES, NTSC, {
920
+ denominator: 30000,
921
+ numerator: 1001
922
+ }), _defineProperty(_CONSTANT_TIMEBASES, NTSC30, {
923
+ denominator: 30,
924
+ numerator: 1
925
+ }), _defineProperty(_CONSTANT_TIMEBASES, 29.97, {
926
+ denominator: 30000,
927
+ numerator: 1001
928
+ }), _defineProperty(_CONSTANT_TIMEBASES, 59.94, {
929
+ denominator: 60000,
930
+ numerator: 1001
931
+ }), _CONSTANT_TIMEBASES);
932
+ var FRAME_SEPARATORS = {
933
+ ':': {
934
+ dropFrame: false,
935
+ field: 2
936
+ },
937
+ ';': {
938
+ dropFrame: true,
939
+ field: 2
940
+ },
941
+ '.': {
942
+ dropFrame: false,
943
+ field: 1
944
+ },
945
+ ',': {
946
+ dropFrame: true,
947
+ field: 1
668
948
  }
949
+ };
669
950
 
670
- var _splitSmpte = splitSmpte(smpteText),
671
- _splitSmpte2 = _slicedToArray(_splitSmpte, 2),
672
- _splitSmpte2$ = _slicedToArray(_splitSmpte2[0], 4),
673
- hh = _splitSmpte2$[0],
674
- mm = _splitSmpte2$[1],
675
- ss = _splitSmpte2$[2],
676
- _splitSmpte2$$ = _splitSmpte2$[3],
677
- ff = _splitSmpte2$$ === void 0 ? 0 : _splitSmpte2$$,
678
- frameOptions = _splitSmpte2[1];
951
+ 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; }
679
952
 
680
- var _frameOptions$dropFra = frameOptions.dropFrame,
681
- dropFrame = _frameOptions$dropFra === void 0 ? false : _frameOptions$dropFra;
682
- var timeBase = formatTimeBase(timeBaseText);
683
- var roundedFrameRate = getRoundedFrameRate(timeBase);
953
+ 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(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; }
684
954
 
685
- if (mm >= 60 || mm < 0 || ss >= 60 || ss < 0 || ff >= roundedFrameRate || ff < 0) {
686
- throw new Error('Invalid mm, ss or ff');
687
- }
955
+ var splitSmpte = function splitSmpte(smpteText) {
956
+ var hasDropFrameSeparator = smpteText.match(/[^0-9:\-_]/);
957
+ var hhmmssff;
958
+ var frameOptions = {};
688
959
 
689
- var samples = countSamples(hh, mm, ss, ff, {
690
- dropFrame: dropFrame,
691
- roundedFrameRate: roundedFrameRate
692
- });
693
- var timeCode = {
694
- samples: samples,
695
- timeBase: timeBase
696
- };
697
- return formatTimeCodeType(timeCode, _objectSpread$7(_objectSpread$7({}, frameOptions), options));
698
- };
960
+ if (hasDropFrameSeparator) {
961
+ var _hasDropFrameSeparato = _slicedToArray(hasDropFrameSeparator, 1),
962
+ frameSeparator = _hasDropFrameSeparato[0];
699
963
 
700
- var _excluded$4 = ["property"];
964
+ var _smpteText$split = smpteText.split(frameSeparator),
965
+ _smpteText$split2 = _slicedToArray(_smpteText$split, 2),
966
+ hhmmss = _smpteText$split2[0],
967
+ splitFrames = _smpteText$split2[1];
701
968
 
702
- 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; }
969
+ hhmmssff = [].concat(_toConsumableArray(hhmmss.split(':')), [splitFrames]);
970
+ frameOptions = FRAME_SEPARATORS[frameSeparator] || {};
971
+ } else {
972
+ hhmmssff = smpteText.split(':');
973
+ }
703
974
 
704
- 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(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; }
705
- var sampleRateSymbols = {
706
- kB: 'kHz',
707
- B: 'Hz',
708
- mB: 'mHz'
975
+ hhmmssff = hhmmssff.map(Number);
976
+
977
+ if (hhmmssff.length > 4 || hhmmssff.some(function (n) {
978
+ return Number.isNaN(n);
979
+ })) {
980
+ throw new Error('Invalid SMPTE timecode');
981
+ }
982
+
983
+ return [hhmmssff, frameOptions];
709
984
  };
710
- var bitRateSymbols = {
711
- kB: 'kbps',
712
- B: 'bps',
713
- MB: 'mbps'
985
+
986
+ var getDropFrames = function getDropFrames(roundedFrameRate) {
987
+ return roundedFrameRate === 60 ? 4 : 2;
714
988
  };
715
989
 
716
- var gcd = function gcd(a, b) {
717
- return b ? gcd(b, a % b) : a;
990
+ var getRoundedFrameRate = function getRoundedFrameRate(timeBase) {
991
+ return Math.round(timeBase.denominator / timeBase.numerator);
718
992
  };
719
993
 
720
- var parseAspectRatio = function parseAspectRatio(_ref) {
721
- var width = _ref.width,
722
- height = _ref.height;
723
- var denominator = gcd(width, height);
724
- var widthRatio = width / denominator;
725
- var heightRatio = height / denominator;
994
+ var countSamples = function countSamples(hh, mm, ss, ff, _ref) {
995
+ var dropFrame = _ref.dropFrame,
996
+ roundedFrameRate = _ref.roundedFrameRate;
726
997
 
727
- if (widthRatio > 21) {
728
- heightRatio = 1;
729
- widthRatio = (width / height).toFixed(2);
998
+ if (!dropFrame) {
999
+ return hh * 3600 * roundedFrameRate + mm * 60 * roundedFrameRate + ss * roundedFrameRate + ff;
730
1000
  }
731
1001
 
732
- return [widthRatio, heightRatio].join(':');
733
- };
1002
+ if (![30, 60].includes(roundedFrameRate)) {
1003
+ throw new Error('Cannot use dropframe with non NTSC timebase');
1004
+ }
734
1005
 
735
- var parseBaseMediaInfoType = function parseBaseMediaInfoType() {
736
- var baseMediaInfoType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1006
+ var dropFrames = getDropFrames(roundedFrameRate);
1007
+ var shouldDropMinute = mm % 10 !== 0;
1008
+ var shouldDropSecond = shouldDropMinute && ss === 0;
1009
+ var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
1010
+ var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
1011
+ var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
737
1012
 
738
- var keyValuePairType = baseMediaInfoType.property,
739
- props = _objectWithoutProperties(baseMediaInfoType, _excluded$4);
1013
+ if (shouldDropSecond && ff < dropFrames) {
1014
+ throw new Error('Invalid ff');
1015
+ }
740
1016
 
741
- var parsedKeyValuePairType = parseKeyValuePairType(keyValuePairType);
742
- return _objectSpread$6(_objectSpread$6({}, parsedKeyValuePairType), props);
1017
+ var frameFrames = shouldDropSecond ? ff - dropFrames : ff;
1018
+ return hourFrames + minuteFrames + secondFrames + frameFrames;
743
1019
  };
744
1020
 
745
- var parseFileType = function parseFileType(fileType) {
746
- var _fileType$uri = fileType.uri,
747
- uriList = _fileType$uri === void 0 ? [] : _fileType$uri,
748
- fileSizeBytes = fileType.size,
749
- hash = fileType.hash,
750
- path = fileType.path,
751
- fileId = fileType.id;
1021
+ function countDroppedFrames(frames, roundedFrameRate) {
1022
+ var dropFrames = getDropFrames(roundedFrameRate);
1023
+ var oneMinuteUndroppedFrames = 60 * roundedFrameRate;
1024
+ var oneMinuteDroppedFrames = 60 * roundedFrameRate - dropFrames;
1025
+ var tenMinuteFrames = 10 * (oneMinuteUndroppedFrames - dropFrames) + dropFrames;
1026
+ var tenMinuteChunks = Math.floor(frames / tenMinuteFrames);
1027
+ var minuteRemainder = Math.max(0, frames % tenMinuteFrames - oneMinuteUndroppedFrames);
1028
+ var oneMinuteChunks = Math.floor(minuteRemainder / oneMinuteDroppedFrames);
1029
+ var frameRemainder = minuteRemainder % oneMinuteDroppedFrames;
1030
+ var frameChunks = frameRemainder > 0 ? dropFrames : 0;
1031
+ return tenMinuteChunks * 9 * dropFrames + oneMinuteChunks * dropFrames + frameChunks;
1032
+ }
1033
+ /**
1034
+ * @class TimeBase
1035
+ * @constructs formatTimeBaseText(timeBaseText: string)
1036
+ */
752
1037
 
753
- var _uriList = _slicedToArray(uriList, 1),
754
- uri = _uriList[0];
755
1038
 
756
- var fileSize = fileSizeBytes !== undefined ? parseFileSize(fileSizeBytes) : '';
757
- var fileName = path ? path.split('/').pop() : undefined;
758
- return {
759
- uri: uri,
760
- hash: hash,
761
- fileSize: fileSize,
762
- fileSizeBytes: fileSizeBytes,
763
- path: path,
764
- fileName: fileName,
765
- fileId: fileId
766
- };
767
- };
1039
+ var TimeBase = /*#__PURE__*/function () {
1040
+ function TimeBase() {
1041
+ var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1042
+ _ref2$numerator = _ref2.numerator,
1043
+ numerator = _ref2$numerator === void 0 ? 1 : _ref2$numerator,
1044
+ _ref2$denominator = _ref2.denominator,
1045
+ denominator = _ref2$denominator === void 0 ? 1 : _ref2$denominator;
768
1046
 
769
- var parseContainerComponent = function parseContainerComponent(containerComponent) {
770
- var _containerComponent$m = containerComponent.mediaInfo,
771
- mediaInfo = _containerComponent$m === void 0 ? {} : _containerComponent$m,
772
- _containerComponent$m2 = containerComponent.metadata,
773
- metadata = _containerComponent$m2 === void 0 ? [] : _containerComponent$m2,
774
- fileList = containerComponent.file,
775
- durationTimeCode = containerComponent.duration,
776
- startTimestamp = containerComponent.startTimestamp,
777
- startTimecode = containerComponent.startTimecode,
778
- timeCodeTimeBase = containerComponent.timeCodeTimeBase;
779
- var containerMetadata = parseKeyValuePairType(metadata);
780
- var containerMediaInfo = parseBaseMediaInfoType(mediaInfo);
781
- var containerFormat = containerMediaInfo.Format;
782
- var videoFormat = containerMediaInfo.Video_Format_List,
783
- audioFormat = containerMediaInfo.Audio_Format_List,
784
- textFormat = containerMediaInfo.Text_Format_List;
1047
+ _classCallCheck(this, TimeBase);
785
1048
 
786
- if (containerFormat === undefined) {
787
- var format = containerComponent.format;
788
- containerFormat = format;
1049
+ this.numerator = Number(numerator);
1050
+ this.denominator = Number(denominator);
1051
+ }
789
1052
 
790
- if (format && format.includes(',')) {
791
- var formatList = format.split(',');
1053
+ _createClass(TimeBase, [{
1054
+ key: "toJSON",
1055
+ value: function toJSON() {
1056
+ return {
1057
+ denominator: this.denominator,
1058
+ numerator: this.numerator
1059
+ };
1060
+ }
1061
+ }, {
1062
+ key: "toConstant",
1063
+ value: function toConstant() {
1064
+ var _this = this;
792
1065
 
793
- var _formatList = _slicedToArray(formatList, 1);
1066
+ var constant;
1067
+ Object.entries(CONSTANT_TIMEBASES).find(function (thisTimeBase) {
1068
+ var _thisTimeBase = _slicedToArray(thisTimeBase, 2),
1069
+ thisTimeBaseText = _thisTimeBase[0],
1070
+ thisTimeBaseType = _thisTimeBase[1];
794
1071
 
795
- containerFormat = _formatList[0];
1072
+ var numerator = thisTimeBaseType.numerator,
1073
+ denominator = thisTimeBaseType.denominator;
1074
+
1075
+ if (numerator === _this.numerator && denominator === _this.denominator) {
1076
+ constant = thisTimeBaseText;
1077
+ return true;
1078
+ }
1079
+
1080
+ return false;
1081
+ });
1082
+ return constant;
796
1083
  }
797
- }
1084
+ }, {
1085
+ key: "toText",
1086
+ value: function toText() {
1087
+ var useConstant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
798
1088
 
799
- var parsedContainerComponent = {
800
- containerFormat: containerFormat,
801
- videoFormat: videoFormat,
802
- audioFormat: audioFormat,
803
- textFormat: textFormat,
804
- containerMetadata: containerMetadata,
805
- containerMediaInfo: containerMediaInfo
806
- };
1089
+ if (useConstant) {
1090
+ var _timeBaseText = this.toConstant();
807
1091
 
808
- if (containerMetadata.componentOriginalFilename) {
809
- parsedContainerComponent.originalFilename = containerMetadata.componentOriginalFilename;
810
- }
1092
+ if (_timeBaseText) return _timeBaseText;
1093
+ }
811
1094
 
812
- if (durationTimeCode !== undefined && durationTimeCode.samples !== 0) {
813
- parsedContainerComponent.durationTimeCode = formatTimeCodeType(durationTimeCode);
814
- parsedContainerComponent.duration = parsedContainerComponent.durationTimeCode.toDuration();
815
- }
1095
+ if (this.numerator > 1) {
1096
+ var _timeBaseText2 = [this.denominator, this.numerator].join(':');
816
1097
 
817
- if (startTimestamp) {
818
- parsedContainerComponent.startTimestamp = formatTimeCodeType(startTimestamp);
819
- }
1098
+ return _timeBaseText2;
1099
+ }
820
1100
 
821
- if (startTimecode !== undefined && timeCodeTimeBase) {
822
- parsedContainerComponent.startTimecode = formatTimeCodeType({
823
- samples: startTimecode,
824
- timeBase: timeCodeTimeBase
825
- });
826
- }
1101
+ var timeBaseText = String(this.denominator);
1102
+ return timeBaseText;
1103
+ }
1104
+ }, {
1105
+ key: "toRate",
1106
+ value: function toRate() {
1107
+ var useConstant = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1108
+ var round = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
827
1109
 
828
- if (fileList) {
829
- var _fileList = _slicedToArray(fileList, 1),
830
- fileType = _fileList[0];
1110
+ if (useConstant) {
1111
+ var _rate = this.toConstant();
831
1112
 
832
- var parsedFileType = parseFileType(fileType);
833
- parsedContainerComponent = _objectSpread$6(_objectSpread$6({}, parsedContainerComponent), parsedFileType);
834
- }
1113
+ if (_rate) return _rate;
1114
+ }
835
1115
 
836
- return parsedContainerComponent;
837
- };
1116
+ var rate = this.denominator / this.numerator;
838
1117
 
839
- var parseVideoComponent = function parseVideoComponent(videoComponent) {
840
- var videoCodec = videoComponent.codec,
841
- bitrate = videoComponent.bitrate,
842
- fieldOrder = videoComponent.fieldOrder,
843
- _videoComponent$resol = videoComponent.resolution,
844
- resolution = _videoComponent$resol === void 0 ? {} : _videoComponent$resol,
845
- _videoComponent$media = videoComponent.mediaInfo,
846
- mediaInfo = _videoComponent$media === void 0 ? {} : _videoComponent$media,
847
- _videoComponent$metad = videoComponent.metadata,
848
- metadata = _videoComponent$metad === void 0 ? [] : _videoComponent$metad;
849
- var videoMediaInfo = parseBaseMediaInfoType(mediaInfo);
850
- var videoMetadata = parseKeyValuePairType(metadata);
851
- var videoFormat = videoMediaInfo.Format,
852
- timeBaseText = videoMediaInfo['Frame rate'],
853
- colorSpace = videoMediaInfo['Color space'],
854
- colorPrimaries = videoMediaInfo['Color primaries'],
855
- chromaSubsampling = videoMediaInfo.Colorimetry;
856
- var timeBase;
857
- var averageFrameRate = videoComponent.averageFrameRate,
858
- realBaseFrameRate = videoComponent.realBaseFrameRate;
859
-
860
- if (realBaseFrameRate !== undefined) {
861
- timeBase = {
862
- numerator: realBaseFrameRate.denominator,
863
- denominator: realBaseFrameRate.numerator
864
- };
865
- } else if (timeBaseText !== undefined) {
866
- timeBase = formatTimeBaseText(timeBaseText);
867
- } else if (averageFrameRate !== undefined) {
868
- timeBase = {
869
- numerator: averageFrameRate.denominator,
870
- denominator: averageFrameRate.numerator
871
- };
872
- }
873
-
874
- var samples = videoMediaInfo['Frame count'];
875
-
876
- if (samples === undefined) {
877
- var numberOfPackets = videoComponent.numberOfPackets;
878
- if (numberOfPackets !== undefined) samples = numberOfPackets;
879
- }
880
-
881
- var timeCode;
882
- var frameRate;
883
- var smpte;
1118
+ if (Number.isInteger(rate)) {
1119
+ return rate;
1120
+ }
884
1121
 
885
- if (samples && timeBase) {
886
- timeCode = formatTimeCodeType({
887
- samples: samples,
888
- timeBase: timeBase
889
- });
890
- frameRate = timeCode.timeBase.toRate(true);
891
- smpte = timeCode.toSmpte(true);
892
- }
1122
+ return round ? rate.toFixed(2) : rate;
1123
+ }
1124
+ }]);
893
1125
 
894
- var height = resolution.height,
895
- width = resolution.width;
896
- var aspectRatio = parseAspectRatio(resolution);
897
- var dimension = "".concat(width, "x").concat(height);
898
- var videoBitrate = bitrate ? parseFileSize(bitrate, {
899
- bits: true
900
- }) : undefined;
901
- return {
902
- videoFormat: videoFormat,
903
- dimension: dimension,
904
- frameRate: frameRate,
905
- height: height,
906
- width: width,
907
- timeBase: timeBase,
908
- timeCode: timeCode,
909
- videoCodec: videoCodec,
910
- smpte: smpte,
911
- videoBitrate: videoBitrate,
912
- fieldOrder: fieldOrder,
913
- colorSpace: colorSpace,
914
- chromaSubsampling: chromaSubsampling,
915
- aspectRatio: aspectRatio,
916
- colorPrimaries: colorPrimaries,
917
- videoMetadata: videoMetadata,
918
- videoMediaInfo: videoMediaInfo
919
- };
920
- };
1126
+ return TimeBase;
1127
+ }();
921
1128
 
922
- var parseAudioComponent = function parseAudioComponent(audioComponent) {
923
- var _audioComponent$timeB = audioComponent.timeBase,
924
- timeBase = _audioComponent$timeB === void 0 ? {} : _audioComponent$timeB,
925
- audioChannels = audioComponent.channelCount,
926
- audioCodec = audioComponent.codec,
927
- _audioComponent$media = audioComponent.mediaInfo,
928
- mediaInfo = _audioComponent$media === void 0 ? {} : _audioComponent$media,
929
- bitrate = audioComponent.bitrate,
930
- _audioComponent$metad = audioComponent.metadata,
931
- metadata = _audioComponent$metad === void 0 ? [] : _audioComponent$metad;
932
- var audioMediaInfo = parseBaseMediaInfoType(mediaInfo);
933
- var audioMetadata = parseKeyValuePairType(metadata);
934
- var audioFormat = audioMediaInfo.Format,
935
- audioBitDepth = audioMediaInfo.Resolution,
936
- audioBitRateMode = audioMediaInfo.Bit_rate_mode;
937
- var audioSamplerateSamples = timeBase.denominator ? timeBase.denominator / timeBase.numerator : undefined;
938
- var audioSamplerate = audioSamplerateSamples ? parseFileSize(audioSamplerateSamples, {
939
- base: 10,
940
- round: 1,
941
- symbols: sampleRateSymbols
942
- }) : undefined;
943
- var audioBitrate = bitrate ? parseFileSize(bitrate, {
944
- base: 10,
945
- round: 2,
946
- symbols: bitRateSymbols
947
- }) : undefined;
948
- return {
949
- audioFormat: audioFormat,
950
- audioCodec: audioCodec,
951
- audioSamplerate: audioSamplerate,
952
- audioSamplerateSamples: audioSamplerateSamples,
953
- audioBitDepth: audioBitDepth,
954
- audioBitrate: audioBitrate,
955
- audioBitRateMode: audioBitRateMode,
956
- audioChannels: audioChannels,
957
- audioMediaInfo: audioMediaInfo,
958
- audioMetadata: audioMetadata
959
- };
1129
+ var isDropFrameTimeBase = function isDropFrameTimeBase(_ref3) {
1130
+ var numerator = _ref3.numerator,
1131
+ denominator = _ref3.denominator;
1132
+ return numerator === 1001 && (denominator === 60000 || denominator === 30000);
960
1133
  };
961
1134
 
962
- var parseBinaryComponent = function parseBinaryComponent(binaryComponent) {
963
- var fileList = binaryComponent.file,
964
- _binaryComponent$medi = binaryComponent.mediaInfo,
965
- mediaInfo = _binaryComponent$medi === void 0 ? {} : _binaryComponent$medi,
966
- _binaryComponent$meta = binaryComponent.metadata,
967
- metadata = _binaryComponent$meta === void 0 ? [] : _binaryComponent$meta;
968
- var binaryMetadata = parseKeyValuePairType(metadata);
969
- var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
970
- var parsedBinaryComponent = {
971
- binaryMetadata: binaryMetadata,
972
- binaryMediaInfo: binaryMediaInfo
973
- };
1135
+ var TimeCode = /*#__PURE__*/function () {
1136
+ function TimeCode() {
1137
+ var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1138
+ _ref4$samples = _ref4.samples,
1139
+ samples = _ref4$samples === void 0 ? 0 : _ref4$samples,
1140
+ timeBase = _ref4.timeBase;
974
1141
 
975
- if (fileList) {
976
- var _fileList2 = _slicedToArray(fileList, 1),
977
- fileType = _fileList2[0];
1142
+ var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1143
+ dropFrame = _ref5.dropFrame,
1144
+ _ref5$field = _ref5.field,
1145
+ field = _ref5$field === void 0 ? 2 : _ref5$field;
978
1146
 
979
- var parsedFileType = parseFileType(fileType);
980
- parsedBinaryComponent = _objectSpread$6(_objectSpread$6({}, parsedBinaryComponent), parsedFileType);
981
- }
1147
+ _classCallCheck(this, TimeCode);
982
1148
 
983
- return parsedBinaryComponent;
984
- };
1149
+ if (typeof samples === 'number') {
1150
+ this.samples = samples;
1151
+ } else if (typeof samples === 'string') {
1152
+ if (samples === '-INF') {
1153
+ this.samples = -Infinity;
1154
+ } else if (samples === '+INF') {
1155
+ this.samples = Infinity;
1156
+ } else {
1157
+ this.samples = Number(samples);
1158
+ }
1159
+ } else {
1160
+ throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));
1161
+ }
985
1162
 
986
- var parseShapeType = function parseShapeType() {
987
- var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
988
- var parsedShape = {};
989
- var containerComponent = shapeType.containerComponent,
990
- videoComponentList = shapeType.videoComponent,
991
- audioComponentList = shapeType.audioComponent,
992
- binaryComponentList = shapeType.binaryComponent,
993
- _shapeType$mimeType = shapeType.mimeType,
994
- mimeTypeList = _shapeType$mimeType === void 0 ? [] : _shapeType$mimeType,
995
- _shapeType$tag = shapeType.tag,
996
- tagList = _shapeType$tag === void 0 ? [] : _shapeType$tag;
1163
+ this.timeBase = new TimeBase(timeBase);
1164
+ this.dropFrame = dropFrame === undefined ? isDropFrameTimeBase(this.timeBase) : dropFrame;
1165
+ this.field = field;
1166
+ }
997
1167
 
998
- var _tagList = _slicedToArray(tagList, 1);
1168
+ _createClass(TimeCode, [{
1169
+ key: "add",
1170
+ value: function add(val) {
1171
+ var _val$timeBase = val.timeBase,
1172
+ numerator = _val$timeBase.numerator,
1173
+ denominator = _val$timeBase.denominator;
1174
+ var conformedTimeCode = val;
999
1175
 
1000
- parsedShape.tag = _tagList[0];
1176
+ if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
1177
+ conformedTimeCode = val.conformTimeBase(this.timeBase);
1178
+ }
1001
1179
 
1002
- var _mimeTypeList = _slicedToArray(mimeTypeList, 1);
1180
+ var _conformedTimeCode = conformedTimeCode,
1181
+ samples = _conformedTimeCode.samples;
1182
+ return new TimeCode({
1183
+ samples: this.samples + samples,
1184
+ timeBase: this.timeBase
1185
+ });
1186
+ }
1187
+ }, {
1188
+ key: "subtract",
1189
+ value: function subtract(val) {
1190
+ var _val$timeBase2 = val.timeBase,
1191
+ numerator = _val$timeBase2.numerator,
1192
+ denominator = _val$timeBase2.denominator;
1193
+ var conformedTimeCode = val;
1003
1194
 
1004
- parsedShape.mimeType = _mimeTypeList[0];
1195
+ if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
1196
+ conformedTimeCode = val.conformTimeBase(this.timeBase);
1197
+ }
1005
1198
 
1006
- if (containerComponent) {
1007
- var parsedContainerComponent = parseContainerComponent(containerComponent);
1008
- parsedShape = _objectSpread$6(_objectSpread$6({}, parsedShape), parsedContainerComponent);
1009
- }
1199
+ var _conformedTimeCode2 = conformedTimeCode,
1200
+ samples = _conformedTimeCode2.samples;
1201
+ return new TimeCode({
1202
+ samples: this.samples - samples,
1203
+ timeBase: this.timeBase
1204
+ });
1205
+ }
1206
+ }, {
1207
+ key: "conformTimeBase",
1208
+ value: function conformTimeBase(conformTo) {
1209
+ var timeBase = conformTo;
1010
1210
 
1011
- if (videoComponentList) {
1012
- var _videoComponentList = _slicedToArray(videoComponentList, 1),
1013
- videoComponent = _videoComponentList[0];
1211
+ if (conformTo instanceof TimeCode === false) {
1212
+ timeBase = new TimeBase(conformTo);
1213
+ }
1014
1214
 
1015
- var parsedVideoComponent = parseVideoComponent(videoComponent);
1016
- parsedShape = _objectSpread$6(_objectSpread$6({}, parsedShape), parsedVideoComponent);
1017
- }
1215
+ var samples = Math.round(this.samples / (this.timeBase.toRate(false, false) / timeBase.toRate(false, false)));
1216
+ var timeCode = {
1217
+ samples: samples,
1218
+ timeBase: timeBase
1219
+ };
1220
+ return new TimeCode(timeCode);
1221
+ }
1222
+ }, {
1223
+ key: "toJSON",
1224
+ value: function toJSON() {
1225
+ return {
1226
+ samples: this.samples,
1227
+ timeBase: this.timeBase
1228
+ };
1229
+ }
1230
+ }, {
1231
+ key: "toText",
1232
+ value: function toText() {
1233
+ var timeCodeText = String(this.samples);
1234
+ var timeBaseText = this.timeBase.toText();
1018
1235
 
1019
- if (audioComponentList) {
1020
- var _audioComponentList = _slicedToArray(audioComponentList, 1),
1021
- audioComponent = _audioComponentList[0];
1236
+ if (timeBaseText !== '1') {
1237
+ timeCodeText = [this.samples, timeBaseText].join('@');
1238
+ }
1022
1239
 
1023
- var parsedAudioComponent = parseAudioComponent(audioComponent);
1024
- parsedShape = _objectSpread$6(_objectSpread$6({}, parsedShape), parsedAudioComponent);
1025
- }
1026
-
1027
- if (binaryComponentList) {
1028
- var _binaryComponentList = _slicedToArray(binaryComponentList, 1),
1029
- binaryComponent = _binaryComponentList[0];
1030
-
1031
- var parsedBinaryComponent = parseBinaryComponent(binaryComponent);
1032
- parsedShape = _objectSpread$6(_objectSpread$6({}, parsedShape), parsedBinaryComponent);
1033
- }
1034
-
1035
- return parsedShape;
1036
- };
1037
-
1038
- var _excluded$3 = ["Codec"],
1039
- _excluded2$2 = ["Codec"];
1040
-
1041
- var parseMediaConvertPreset = function parseMediaConvertPreset(transcodePresetType) {
1042
- var output = {};
1043
- var description = transcodePresetType.description,
1044
- _transcodePresetType$ = transcodePresetType.mediaconvert;
1045
- _transcodePresetType$ = _transcodePresetType$ === void 0 ? {} : _transcodePresetType$;
1046
- var _transcodePresetType$2 = _transcodePresetType$.outputSetting,
1047
- outputSetting = _transcodePresetType$2 === void 0 ? [] : _transcodePresetType$2;
1048
- output.description = description;
1049
- if (outputSetting.length === 0) return output;
1050
- var mc = JSON.parse(outputSetting[0]);
1051
- var _mc$Settings = mc.Settings;
1052
- _mc$Settings = _mc$Settings === void 0 ? {} : _mc$Settings;
1053
- var ContainerSettings = _mc$Settings.ContainerSettings,
1054
- VideoDescription = _mc$Settings.VideoDescription,
1055
- AudioDescriptions = _mc$Settings.AudioDescriptions;
1056
- output.containerFormat = ContainerSettings.Container;
1057
-
1058
- if (ContainerSettings) {
1059
- output.containerFormat = ContainerSettings.Container;
1060
- }
1061
-
1062
- if (VideoDescription) {
1063
- var _VideoDescription$Cod = VideoDescription.CodecSettings,
1064
- CodecSettings = _VideoDescription$Cod === void 0 ? {} : _VideoDescription$Cod;
1065
-
1066
- var Codec = CodecSettings.Codec,
1067
- otherSettings = _objectWithoutProperties(CodecSettings, _excluded$3);
1068
-
1069
- output.videoFormat = Codec;
1070
- var height = VideoDescription.Height,
1071
- width = VideoDescription.Width;
1072
- output.height = height;
1073
- output.width = width;
1074
-
1075
- if (height && width) {
1076
- output.dimension = "".concat(width, "x").concat(height);
1077
- output.aspectRatio = parseAspectRatio({
1078
- height: height,
1079
- width: width
1080
- });
1240
+ return timeCodeText;
1081
1241
  }
1082
-
1083
- var _Object$values = Object.values(otherSettings),
1084
- _Object$values2 = _slicedToArray(_Object$values, 1),
1085
- codecSpecs = _Object$values2[0];
1086
-
1087
- if (codecSpecs) {
1088
- output.fieldOrder = codecSpecs.InterlaceMode;
1089
- if (output.fieldOrder && output.fieldOrder.includes('TOP')) output.fieldOrder = 'interlaced';
1090
- output.videoBitrate = codecSpecs.Bitrate;
1091
- var numerator = codecSpecs.FramerateDenominator; // other way round to vs ¯\_(ツ)_/¯
1092
-
1093
- var denominator = codecSpecs.FramerateNumerator;
1094
- var timeBase = formatTimeBaseType({
1095
- denominator: denominator,
1096
- numerator: numerator
1097
- });
1098
- output.timeBase = timeBase;
1099
- output.frameRate = timeBase.toRate(true);
1242
+ }, {
1243
+ key: "toSeconds",
1244
+ value: function toSeconds() {
1245
+ var _this$timeBase = this.timeBase,
1246
+ numerator = _this$timeBase.numerator,
1247
+ denominator = _this$timeBase.denominator;
1248
+ return this.samples * (numerator / denominator);
1100
1249
  }
1101
- }
1102
-
1103
- if (AudioDescriptions && AudioDescriptions.length > 0) {
1104
- var _AudioDescriptions$0$ = AudioDescriptions[0].CodecSettings,
1105
- _CodecSettings = _AudioDescriptions$0$ === void 0 ? {} : _AudioDescriptions$0$;
1106
-
1107
- var _Codec = _CodecSettings.Codec,
1108
- _otherSettings = _objectWithoutProperties(_CodecSettings, _excluded2$2);
1109
-
1110
- output.audioFormat = _Codec;
1111
-
1112
- var _Object$values3 = Object.values(_otherSettings),
1113
- _Object$values4 = _slicedToArray(_Object$values3, 1),
1114
- _codecSpecs = _Object$values4[0];
1115
-
1116
- if (_codecSpecs) {
1117
- output.audioSamplerate = _codecSpecs.SampleRate;
1118
- output.audioBitrate = _codecSpecs.Bitrate;
1119
- output.audioBitRateMode = _codecSpecs.RateControlMode;
1250
+ }, {
1251
+ key: "toTime",
1252
+ value: function toTime() {
1253
+ var roundedFrameRate = getRoundedFrameRate(this.timeBase);
1254
+ var totalSamples = this.samples + (this.dropFrame ? countDroppedFrames(this.samples + 1, roundedFrameRate) : 0);
1255
+ var hours = Math.floor(totalSamples / (3600 * roundedFrameRate));
1256
+ var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
1257
+ var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
1258
+ var frames = totalSamples % roundedFrameRate;
1259
+ var partialSeconds = frames / roundedFrameRate;
1260
+ return {
1261
+ hours: hours,
1262
+ minutes: minutes,
1263
+ seconds: seconds,
1264
+ frames: frames,
1265
+ partialSeconds: partialSeconds
1266
+ };
1120
1267
  }
1121
- }
1122
-
1123
- return output;
1124
- };
1125
-
1126
- var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
1127
- var output = {};
1128
- var description = transcodePresetType.description,
1129
- format = transcodePresetType.format,
1130
- audio = transcodePresetType.audio,
1131
- video = transcodePresetType.video,
1132
- mediaconvert = transcodePresetType.mediaconvert;
1133
- if (mediaconvert) return parseMediaConvertPreset(transcodePresetType);
1134
- output.description = description;
1135
- output.containerFormat = format;
1268
+ }, {
1269
+ key: "toDuration",
1270
+ value: function toDuration() {
1271
+ var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1272
+ format = _ref6.format;
1136
1273
 
1137
- if (video) {
1138
- output.videoFormat = video.codec;
1139
- output.videoBitrate = video.bitrate;
1274
+ var _this$toTime = this.toTime(),
1275
+ hours = _this$toTime.hours,
1276
+ minutes = _this$toTime.minutes,
1277
+ seconds = _this$toTime.seconds;
1140
1278
 
1141
- if (video.framerate) {
1142
- var timeBase = formatTimeBaseType(video.framerate);
1143
- output.timeBase = timeBase;
1144
- output.frameRate = timeBase.toRate(true);
1145
- }
1279
+ if (typeof format === 'string') {
1280
+ if (format.toLowerCase() === 'hhmmss') {
1281
+ return [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1282
+ }
1283
+ }
1146
1284
 
1147
- if (video.scaling) {
1148
- var _video$scaling = video.scaling,
1149
- height = _video$scaling.height,
1150
- width = _video$scaling.width;
1151
- output.height = height;
1152
- output.width = width;
1285
+ if (hours) {
1286
+ return [hours.toFixed(), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1287
+ }
1153
1288
 
1154
- if (height && width) {
1155
- output.dimension = "".concat(width, "x").concat(height);
1156
- output.aspectRatio = parseAspectRatio({
1157
- height: height,
1158
- width: width
1159
- });
1289
+ if (minutes >= 10) {
1290
+ return [minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1160
1291
  }
1292
+
1293
+ return [minutes.toFixed(), seconds.toFixed().padStart(2, '0')].join(':');
1161
1294
  }
1162
- }
1295
+ }, {
1296
+ key: "toSmpte",
1297
+ value: function toSmpte() {
1298
+ var _this2 = this;
1163
1299
 
1164
- if (audio) {
1165
- var audioFormat = audio.codec,
1166
- channel = audio.channel;
1167
- output.audioFormat = audioFormat;
1168
- if (channel) output.audioChannels = channel.length;
1169
- }
1300
+ if (this.samples === -Infinity) return '00:00:00:00';
1170
1301
 
1171
- return output;
1172
- };
1302
+ var _this$toTime2 = this.toTime(),
1303
+ hours = _this$toTime2.hours,
1304
+ minutes = _this$toTime2.minutes,
1305
+ seconds = _this$toTime2.seconds,
1306
+ frames = _this$toTime2.frames;
1173
1307
 
1174
- var PDF = 'PDF';
1175
- var TEXT = 'TEXT';
1176
- var MSWORD = 'MSWORD';
1177
- var JSON$1 = 'JSON';
1178
- var XML = 'XML';
1179
- var getDocumentType = function getDocumentType() {
1180
- var shape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1181
- var mimeType = shape.mimeType;
1182
- if (!mimeType) return undefined;
1183
- if (mimeType.endsWith('/pdf')) return PDF;
1184
- if (mimeType.startsWith('text/')) return TEXT;
1185
- if (mimeType.endsWith('/msword')) return MSWORD;
1186
- if (mimeType.endsWith('/json')) return JSON$1;
1187
- if (mimeType.endsWith('/xml')) return XML;
1188
- return undefined;
1189
- };
1308
+ var hhmmss = [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1190
1309
 
1191
- var ACCESSCONTROL_READ = '_accesscontrol_read';
1192
- var ACCESSCONTROL_WRITE = '_accesscontrol_write';
1193
- var ADMINISTRATOR = '_administrator';
1194
- var AUTO_PROJECTION_READ = '_auto_projection_read';
1195
- var AUTO_PROJECTION_WRITE = '_auto_projection_write';
1196
- var COLLECTION_NOTIFICATION_READ = '_collection_notification_read';
1197
- var COLLECTION_NOTIFICATION_WRITE = '_collection_notification_write';
1198
- var COLLECTION_READ = '_collection_read';
1199
- var COLLECTION_WRITE = '_collection_write';
1200
- var DELETION_LOCK_NOTIFICATION_READ = '_deletion_lock_notification_read';
1201
- var DELETION_LOCK_NOTIFICATION_WRITE = '_deletion_lock_notification_write';
1202
- var DELETION_LOCK_READ = '_deletion_lock_read';
1203
- var DELETION_LOCK_WRITE = '_deletion_lock_write';
1204
- var DOCUMENT_NOTIFICATION_READ = '_document_notification_read';
1205
- var DOCUMENT_NOTIFICATION_WRITE = '_document_notification_write';
1206
- var DOCUMENT_READ = '_document_read';
1207
- var DOCUMENT_WRITE = '_document_write';
1208
- var ERROR_READ = '_error_read';
1209
- var ERROR_WRITE = '_error_write';
1210
- var EXPORT = '_export';
1211
- var EXPORT_TEMPLATE_READ = '_export_template_read';
1212
- var EXPORT_TEMPLATE_WRITE = '_export_template_write';
1213
- var EXTERNAL_ID_READ = '_external_id_read';
1214
- var EXTERNAL_ID_WRITE = '_external_id_write';
1215
- var FILE_NOTIFICATION_READ = '_file_notification_read';
1216
- var FILE_NOTIFICATION_WRITE = '_file_notification_write';
1217
- var FILE_READ = '_file_read';
1218
- var FILE_WRITE = '_file_write';
1219
- var GROUP_READ = '_group_read';
1220
- var GROUP_WRITE = '_group_write';
1221
- var IMPORT_WRITE = '_import';
1222
- var ITEM_ID_READ = '_item_id_read';
1223
- var ITEM_ID_WRITE = '_item_id_write';
1224
- var ITEM_NOTIFICATION_READ = '_item_notification_read';
1225
- var ITEM_NOTIFICATION_WRITE = '_item_notification_write';
1226
- var ITEM_WRITE = '_item_write';
1227
- var ITEM_SEARCH = '_item_search';
1228
- var ITEM_SHAPE_READ = '_item_shape_read';
1229
- var ITEM_SHAPE_WRITE = '_item_shape_write';
1230
- var ITEM_TIMELINE_READ = '_item_timeline_read';
1231
- var ITEM_TIMELINE_WRITE = '_item_timeline_write';
1232
- var ITEM_URI = '_item_uri';
1233
- var JOB_NOTIFICATION_READ = '_job_notification_read';
1234
- var JOB_NOTIFICATION_WRITE = '_job_notification_write';
1235
- var JOB_READ = '_job_read';
1236
- var JOB_WRITE = '_job_write';
1237
- var LIBRARY_READ = '_library_read';
1238
- var LIBRARY_WRITE = '_library_write';
1239
- var LOCK_READ = '_lock_read';
1240
- var LOCK_WRITE = '_lock_write';
1241
- var LOG_READ = '_log_read';
1242
- var METADATA_DATASET_READ = '_metadata_dataset_read';
1243
- var METADATA_DATASET_WRITE = '_metadata_dataset_write';
1244
- var METADATA_FIELD_GROUP_READ = '_metadata_field_group_read';
1245
- var METADATA_FIELD_GROUP_WRITE = '_metadata_field_group_write';
1246
- var METADATA_FIELD_READ = '_metadata_field_read';
1247
- var METADATA_FIELD_WRITE = '_metadata_field_write';
1248
- var METADATA_GLOBAL_READ = '_metadata_global_read';
1249
- var METADATA_GLOBAL_WRITE = '_metadata_global_write';
1250
- var METADATA_LOCK_READ = '_metadata_lock_read';
1251
- var METADATA_LOCK_WRITE = '_metadata_lock_write';
1252
- var METADATA_READ = '_metadata_read';
1253
- var METADATA_SCHEMA_READ = '_metadata_schema_read';
1254
- var METADATA_SCHEMA_WRITE = '_metadata_schema_write';
1255
- var METADATA_WRITE = '_metadata_write';
1256
- var OTIF_ANALYZE = '_otif_analyze';
1257
- var OTIF_READ = '_otif_read';
1258
- var OTIF_WRITE = '_otif_write';
1259
- var PLACEHOLDER_NOTIFICATION_READ = '_placeholder_notification_read';
1260
- var PLACEHOLDER_NOTIFICATION_WRITE = '_placeholder_notification_write';
1261
- var PROJECTION_READ = '_projection_read';
1262
- var PROJECTION_WRITE = '_projection_write';
1263
- var QUOTA_NOTIFICATION_READ = '_quota_notification_read';
1264
- var QUOTA_NOTIFICATION_WRITE = '_quota_notification_write';
1265
- var QUOTA_READ = '_quota_read';
1266
- var QUOTA_WRITE = '_quota_write';
1267
- var RELATION_READ = '_relation_read';
1268
- var RELATION_WRITE = '_relation_write';
1269
- var RESOURCE_READ = '_resource_read';
1270
- var RESOURCE_WRITE = '_resource_write';
1271
- var RUN_AS = '_run_as';
1272
- var SEARCH = '_search';
1273
- var SEQUENCE_READ = '_sequence_read';
1274
- var SEQUENCE_WRITE = '_sequence_write';
1275
- var SHAPE_TAG_READ = '_shape_tag_read';
1276
- var SHAPE_TAG_WRITE = '_shape_tag_write';
1277
- var SITE_MANAGER = '_site_manager';
1278
- var SITE_RULE_READ = '_site_rule_read';
1279
- var SITE_RULE_WRITE = '_site_rule_write';
1280
- var STORAGE_GROUP_READ = '_storage_group_read';
1281
- var STORAGE_GROUP_WRITE = '_storage_group_write';
1282
- var STORAGE_NOTIFICATION_READ = '_storage_notification_read';
1283
- var STORAGE_NOTIFICATION_WRITE = '_storage_notification_write';
1284
- var STORAGE_READ = '_storage_read';
1285
- var STORAGE_RULE_READ = '_storage_rule_read';
1286
- var STORAGE_RULE_WRITE = '_storage_rule_write';
1287
- var STORAGE_WRITE = '_storage_write';
1288
- var SUPER_ACCESS_USER = '_super_access_user';
1289
- var TASKDEFINITION_READ = '_taskdefinition_read';
1290
- var TASKDEFINITION_WRITE = '_taskdefinition_write';
1291
- var THUMBNAIL_READ = '_thumbnail_read';
1292
- var THUMBNAIL_WRITE = '_thumbnail_write';
1293
- var TRANSCODER = '_transcoder';
1294
- var TRANSFER_READ = '_transfer_read';
1295
- var TRANSFER_WRITE = '_transfer_write';
1296
- var USER = '_user';
1297
- var VXA = '_vxa';
1298
- var VXA_READ = '_vxa_read';
1310
+ var _Object$entries$find = Object.entries(FRAME_SEPARATORS).find(function (thisSeparator) {
1311
+ var _thisSeparator = _slicedToArray(thisSeparator, 2),
1312
+ _thisSeparator$ = _thisSeparator[1],
1313
+ dropFrame = _thisSeparator$.dropFrame,
1314
+ field = _thisSeparator$.field;
1299
1315
 
1300
- var roles = /*#__PURE__*/Object.freeze({
1301
- __proto__: null,
1302
- ACCESSCONTROL_READ: ACCESSCONTROL_READ,
1303
- ACCESSCONTROL_WRITE: ACCESSCONTROL_WRITE,
1304
- ADMINISTRATOR: ADMINISTRATOR,
1305
- AUTO_PROJECTION_READ: AUTO_PROJECTION_READ,
1306
- AUTO_PROJECTION_WRITE: AUTO_PROJECTION_WRITE,
1307
- COLLECTION_NOTIFICATION_READ: COLLECTION_NOTIFICATION_READ,
1308
- COLLECTION_NOTIFICATION_WRITE: COLLECTION_NOTIFICATION_WRITE,
1309
- COLLECTION_READ: COLLECTION_READ,
1310
- COLLECTION_WRITE: COLLECTION_WRITE,
1311
- DELETION_LOCK_NOTIFICATION_READ: DELETION_LOCK_NOTIFICATION_READ,
1312
- DELETION_LOCK_NOTIFICATION_WRITE: DELETION_LOCK_NOTIFICATION_WRITE,
1313
- DELETION_LOCK_READ: DELETION_LOCK_READ,
1314
- DELETION_LOCK_WRITE: DELETION_LOCK_WRITE,
1315
- DOCUMENT_NOTIFICATION_READ: DOCUMENT_NOTIFICATION_READ,
1316
- DOCUMENT_NOTIFICATION_WRITE: DOCUMENT_NOTIFICATION_WRITE,
1317
- DOCUMENT_READ: DOCUMENT_READ,
1318
- DOCUMENT_WRITE: DOCUMENT_WRITE,
1319
- ERROR_READ: ERROR_READ,
1320
- ERROR_WRITE: ERROR_WRITE,
1321
- EXPORT: EXPORT,
1322
- EXPORT_TEMPLATE_READ: EXPORT_TEMPLATE_READ,
1323
- EXPORT_TEMPLATE_WRITE: EXPORT_TEMPLATE_WRITE,
1324
- EXTERNAL_ID_READ: EXTERNAL_ID_READ,
1325
- EXTERNAL_ID_WRITE: EXTERNAL_ID_WRITE,
1326
- FILE_NOTIFICATION_READ: FILE_NOTIFICATION_READ,
1327
- FILE_NOTIFICATION_WRITE: FILE_NOTIFICATION_WRITE,
1328
- FILE_READ: FILE_READ,
1329
- FILE_WRITE: FILE_WRITE,
1330
- GROUP_READ: GROUP_READ,
1331
- GROUP_WRITE: GROUP_WRITE,
1332
- IMPORT_WRITE: IMPORT_WRITE,
1333
- ITEM_ID_READ: ITEM_ID_READ,
1334
- ITEM_ID_WRITE: ITEM_ID_WRITE,
1335
- ITEM_NOTIFICATION_READ: ITEM_NOTIFICATION_READ,
1336
- ITEM_NOTIFICATION_WRITE: ITEM_NOTIFICATION_WRITE,
1337
- ITEM_WRITE: ITEM_WRITE,
1338
- ITEM_SEARCH: ITEM_SEARCH,
1339
- ITEM_SHAPE_READ: ITEM_SHAPE_READ,
1340
- ITEM_SHAPE_WRITE: ITEM_SHAPE_WRITE,
1341
- ITEM_TIMELINE_READ: ITEM_TIMELINE_READ,
1342
- ITEM_TIMELINE_WRITE: ITEM_TIMELINE_WRITE,
1343
- ITEM_URI: ITEM_URI,
1344
- JOB_NOTIFICATION_READ: JOB_NOTIFICATION_READ,
1345
- JOB_NOTIFICATION_WRITE: JOB_NOTIFICATION_WRITE,
1346
- JOB_READ: JOB_READ,
1347
- JOB_WRITE: JOB_WRITE,
1348
- LIBRARY_READ: LIBRARY_READ,
1349
- LIBRARY_WRITE: LIBRARY_WRITE,
1350
- LOCK_READ: LOCK_READ,
1351
- LOCK_WRITE: LOCK_WRITE,
1352
- LOG_READ: LOG_READ,
1353
- METADATA_DATASET_READ: METADATA_DATASET_READ,
1354
- METADATA_DATASET_WRITE: METADATA_DATASET_WRITE,
1355
- METADATA_FIELD_GROUP_READ: METADATA_FIELD_GROUP_READ,
1356
- METADATA_FIELD_GROUP_WRITE: METADATA_FIELD_GROUP_WRITE,
1357
- METADATA_FIELD_READ: METADATA_FIELD_READ,
1358
- METADATA_FIELD_WRITE: METADATA_FIELD_WRITE,
1359
- METADATA_GLOBAL_READ: METADATA_GLOBAL_READ,
1360
- METADATA_GLOBAL_WRITE: METADATA_GLOBAL_WRITE,
1361
- METADATA_LOCK_READ: METADATA_LOCK_READ,
1362
- METADATA_LOCK_WRITE: METADATA_LOCK_WRITE,
1363
- METADATA_READ: METADATA_READ,
1364
- METADATA_SCHEMA_READ: METADATA_SCHEMA_READ,
1365
- METADATA_SCHEMA_WRITE: METADATA_SCHEMA_WRITE,
1366
- METADATA_WRITE: METADATA_WRITE,
1367
- OTIF_ANALYZE: OTIF_ANALYZE,
1368
- OTIF_READ: OTIF_READ,
1369
- OTIF_WRITE: OTIF_WRITE,
1370
- PLACEHOLDER_NOTIFICATION_READ: PLACEHOLDER_NOTIFICATION_READ,
1371
- PLACEHOLDER_NOTIFICATION_WRITE: PLACEHOLDER_NOTIFICATION_WRITE,
1372
- PROJECTION_READ: PROJECTION_READ,
1373
- PROJECTION_WRITE: PROJECTION_WRITE,
1374
- QUOTA_NOTIFICATION_READ: QUOTA_NOTIFICATION_READ,
1375
- QUOTA_NOTIFICATION_WRITE: QUOTA_NOTIFICATION_WRITE,
1376
- QUOTA_READ: QUOTA_READ,
1377
- QUOTA_WRITE: QUOTA_WRITE,
1378
- RELATION_READ: RELATION_READ,
1379
- RELATION_WRITE: RELATION_WRITE,
1380
- RESOURCE_READ: RESOURCE_READ,
1381
- RESOURCE_WRITE: RESOURCE_WRITE,
1382
- RUN_AS: RUN_AS,
1383
- SEARCH: SEARCH,
1384
- SEQUENCE_READ: SEQUENCE_READ,
1385
- SEQUENCE_WRITE: SEQUENCE_WRITE,
1386
- SHAPE_TAG_READ: SHAPE_TAG_READ,
1387
- SHAPE_TAG_WRITE: SHAPE_TAG_WRITE,
1388
- SITE_MANAGER: SITE_MANAGER,
1389
- SITE_RULE_READ: SITE_RULE_READ,
1390
- SITE_RULE_WRITE: SITE_RULE_WRITE,
1391
- STORAGE_GROUP_READ: STORAGE_GROUP_READ,
1392
- STORAGE_GROUP_WRITE: STORAGE_GROUP_WRITE,
1393
- STORAGE_NOTIFICATION_READ: STORAGE_NOTIFICATION_READ,
1394
- STORAGE_NOTIFICATION_WRITE: STORAGE_NOTIFICATION_WRITE,
1395
- STORAGE_READ: STORAGE_READ,
1396
- STORAGE_RULE_READ: STORAGE_RULE_READ,
1397
- STORAGE_RULE_WRITE: STORAGE_RULE_WRITE,
1398
- STORAGE_WRITE: STORAGE_WRITE,
1399
- SUPER_ACCESS_USER: SUPER_ACCESS_USER,
1400
- TASKDEFINITION_READ: TASKDEFINITION_READ,
1401
- TASKDEFINITION_WRITE: TASKDEFINITION_WRITE,
1402
- THUMBNAIL_READ: THUMBNAIL_READ,
1403
- THUMBNAIL_WRITE: THUMBNAIL_WRITE,
1404
- TRANSCODER: TRANSCODER,
1405
- TRANSFER_READ: TRANSFER_READ,
1406
- TRANSFER_WRITE: TRANSFER_WRITE,
1407
- USER: USER,
1408
- VXA: VXA,
1409
- VXA_READ: VXA_READ
1410
- });
1316
+ return dropFrame === _this2.dropFrame && field === _this2.field;
1317
+ }),
1318
+ _Object$entries$find2 = _slicedToArray(_Object$entries$find, 1),
1319
+ _Object$entries$find3 = _Object$entries$find2[0],
1320
+ frameSeparator = _Object$entries$find3 === void 0 ? ':' : _Object$entries$find3;
1411
1321
 
1412
- var _excluded$2 = ["groupName"],
1413
- _excluded2$1 = ["start", "end"];
1322
+ return [hhmmss, frames.toFixed().padStart(2, '0')].join(frameSeparator);
1323
+ }
1324
+ }, {
1325
+ key: "toFraction",
1326
+ value: function toFraction() {
1327
+ return "".concat(this.samples, "@").concat(this.timeBase.denominator, ":").concat(this.timeBase.numerator);
1328
+ }
1329
+ }]);
1414
1330
 
1415
- 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; }
1331
+ return TimeCode;
1332
+ }();
1416
1333
 
1417
- 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(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; }
1334
+ var formatTimeBaseType = function formatTimeBaseType(timeBase) {
1335
+ return new TimeBase(timeBase);
1336
+ };
1418
1337
 
1419
- var parseValueList$1 = function parseValueList(value) {
1420
- if (value === undefined) return [];
1421
- if (value === null) return [{
1422
- value: ''
1423
- }];
1338
+ var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
1339
+ if (timeBaseText === undefined) {
1340
+ return formatTimeBaseType();
1341
+ }
1424
1342
 
1425
- if (Array.isArray(value)) {
1426
- return value.map(function (valueOrObject) {
1427
- if (_typeof(valueOrObject) === 'object') {
1428
- return _objectSpread$5({
1429
- value: valueOrObject.value || ''
1430
- }, valueOrObject);
1431
- }
1343
+ if (typeof timeBaseText === 'number') {
1344
+ return formatTimeBaseType({
1345
+ denominator: timeBaseText
1346
+ });
1347
+ }
1432
1348
 
1433
- return {
1434
- value: valueOrObject
1435
- };
1349
+ if (timeBaseText.includes(':')) {
1350
+ var _timeBaseText$split = timeBaseText.split(':'),
1351
+ _timeBaseText$split2 = _slicedToArray(_timeBaseText$split, 2),
1352
+ _denominator = _timeBaseText$split2[0],
1353
+ numerator = _timeBaseText$split2[1];
1354
+
1355
+ return formatTimeBaseType({
1356
+ denominator: _denominator,
1357
+ numerator: numerator
1436
1358
  });
1437
1359
  }
1438
1360
 
1439
- if (value.value) return [value];
1440
- return [{
1441
- value: value
1442
- }];
1443
- };
1361
+ if (Object.keys(CONSTANT_TIMEBASES).includes(timeBaseText)) {
1362
+ return formatTimeBaseType(CONSTANT_TIMEBASES[timeBaseText]);
1363
+ }
1444
1364
 
1445
- var parseValue = function parseValue() {
1446
- var fieldValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1365
+ var denominator = Number(timeBaseText);
1447
1366
 
1448
- if (fieldValue && (fieldValue.value || fieldValue.name)) {
1449
- var valueList = fieldValue.value,
1450
- uuid = fieldValue.uuid;
1451
- var value = parseValueList$1(valueList);
1452
- return {
1453
- value: value,
1454
- uuid: uuid
1455
- };
1367
+ if (Number.isNaN(denominator)) {
1368
+ throw new Error("timeBaseText must be a number or ".concat(Object.keys(CONSTANT_TIMEBASES).join(','), " - is ").concat(timeBaseText));
1456
1369
  }
1457
1370
 
1458
- return {
1459
- value: parseValueList$1(fieldValue)
1460
- };
1371
+ return formatTimeBaseType({
1372
+ denominator: denominator
1373
+ });
1461
1374
  };
1462
1375
 
1463
- var parseField$1 = function parseField() {
1464
- var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1465
- var name = field.name,
1466
- value = field.value;
1467
- var parsedValue = parseValue(value);
1468
- return _objectSpread$5({
1469
- name: name
1470
- }, parsedValue);
1376
+ var formatTimeBase = function formatTimeBase(timeBase) {
1377
+ if (_typeof(timeBase) === 'object') {
1378
+ return formatTimeBaseType(timeBase);
1379
+ }
1380
+
1381
+ return formatTimeBaseText(timeBase);
1471
1382
  };
1472
1383
 
1473
- var shouldBeField = function shouldBeField(_ref) {
1474
- var name = _ref.name,
1475
- value = _ref.value;
1476
- return ['string', 'boolean', 'number'].includes(_typeof(value)) || name !== 'group' && Array.isArray(value) || value === null;
1384
+ var formatTimeCodeType = function formatTimeCodeType(timeCode, options) {
1385
+ return new TimeCode(timeCode, options);
1477
1386
  };
1478
1387
 
1479
- var parseGroup$1 = function parseGroup() {
1480
- var thisGroup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1481
- var groupName = thisGroup.name,
1482
- _thisGroup$value = thisGroup.value,
1483
- groupsOrFields = _thisGroup$value === void 0 ? {} : _thisGroup$value; // eslint-disable-next-line no-use-before-define
1388
+ var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
1389
+ if (timeCodeText === undefined) {
1390
+ var _timeCode = {
1391
+ samples: 0
1392
+ };
1393
+ return formatTimeCodeType(_timeCode, options);
1394
+ }
1484
1395
 
1485
- var _parseGroupsOrFields = parseGroupsOrFields(groupsOrFields),
1486
- field = _parseGroupsOrFields.field,
1487
- group = _parseGroupsOrFields.group;
1396
+ if (typeof timeCodeText === 'number') {
1397
+ var _timeCode2 = {
1398
+ samples: timeCodeText
1399
+ };
1400
+ return formatTimeCodeType(_timeCode2, options);
1401
+ }
1488
1402
 
1489
- return {
1490
- name: groupName,
1491
- group: group,
1492
- field: field
1493
- };
1494
- };
1403
+ if (timeCodeText.includes('@')) {
1404
+ var _timeCodeText$split = timeCodeText.split('@'),
1405
+ _timeCodeText$split2 = _slicedToArray(_timeCodeText$split, 2),
1406
+ samplesString = _timeCodeText$split2[0],
1407
+ timeBaseText = _timeCodeText$split2[1];
1495
1408
 
1496
- var parseGroupsOrFields = function parseGroupsOrFields(groupsOrFields) {
1497
- var group = [];
1498
- var field = [];
1499
- Object.entries(groupsOrFields).forEach(function (_ref2) {
1500
- var _ref3 = _slicedToArray(_ref2, 2),
1501
- name = _ref3[0],
1502
- value = _ref3[1];
1409
+ var _samples = Number(samplesString);
1503
1410
 
1504
- if (shouldBeField({
1505
- name: name,
1506
- value: value
1507
- })) {
1508
- field.push(parseField$1({
1509
- name: name,
1510
- value: value
1511
- }));
1512
- } else if (Array.isArray(value)) {
1513
- value.forEach(function (_ref4) {
1514
- var groupName = _ref4.groupName,
1515
- groupValue = _objectWithoutProperties(_ref4, _excluded$2);
1411
+ var timeBase = formatTimeBaseText(timeBaseText);
1412
+ var _timeCode3 = {
1413
+ samples: _samples,
1414
+ timeBase: timeBase
1415
+ };
1416
+ return formatTimeCodeType(_timeCode3, options);
1417
+ }
1516
1418
 
1517
- group.push(parseGroup$1({
1518
- name: groupName,
1519
- value: groupValue
1520
- }));
1521
- });
1522
- } else {
1523
- group.push(parseGroup$1({
1524
- name: name,
1525
- value: value
1526
- }));
1527
- }
1528
- });
1529
- return {
1530
- group: group,
1531
- field: field
1419
+ if (timeCodeText === '-INF') {
1420
+ var _samples2 = -Infinity;
1421
+
1422
+ var _timeCode4 = {
1423
+ samples: _samples2
1424
+ };
1425
+ return formatTimeCodeType(_timeCode4, options);
1426
+ }
1427
+
1428
+ if (timeCodeText === '+INF') {
1429
+ var _samples3 = Infinity;
1430
+ var _timeCode5 = {
1431
+ samples: _samples3
1432
+ };
1433
+ return formatTimeCodeType(_timeCode5, options);
1434
+ }
1435
+
1436
+ var samples = Number(timeCodeText);
1437
+
1438
+ if (Number.isNaN(samples)) {
1439
+ throw new Error("timeBaseText must be a number or sample@timeBase - is ".concat(timeCodeText));
1440
+ }
1441
+
1442
+ var timeCode = {
1443
+ samples: samples
1532
1444
  };
1445
+ return formatTimeCodeType(timeCode, options);
1533
1446
  };
1534
1447
 
1535
- var parseTimespan$1 = function parseTimespan() {
1536
- var timespan = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1537
-
1538
- var _ref5 = timespan || {},
1539
- _ref5$start = _ref5.start,
1540
- start = _ref5$start === void 0 ? '-INF' : _ref5$start,
1541
- _ref5$end = _ref5.end,
1542
- end = _ref5$end === void 0 ? '+INF' : _ref5$end,
1543
- groupsOrFields = _objectWithoutProperties(_ref5, _excluded2$1);
1448
+ var formatSeconds = function formatSeconds(seconds, timeBase, options) {
1449
+ if (Number.isNaN(Number(seconds))) {
1450
+ throw new Error("seconds must be digits, is ".concat(seconds));
1451
+ }
1544
1452
 
1545
- var _parseGroupsOrFields2 = parseGroupsOrFields(groupsOrFields),
1546
- group = _parseGroupsOrFields2.group,
1547
- field = _parseGroupsOrFields2.field;
1453
+ var _ref7 = timeBase || {},
1454
+ _ref7$denominator = _ref7.denominator,
1455
+ denominator = _ref7$denominator === void 0 ? 1 : _ref7$denominator,
1456
+ _ref7$numerator = _ref7.numerator,
1457
+ numerator = _ref7$numerator === void 0 ? 1 : _ref7$numerator;
1548
1458
 
1549
- return {
1550
- start: start,
1551
- end: end,
1552
- field: field,
1553
- group: group
1459
+ var samples = seconds * (denominator / numerator);
1460
+ var timeCode = {
1461
+ samples: samples,
1462
+ timeBase: timeBase || {}
1554
1463
  };
1464
+ return new TimeCode(timeCode, options);
1555
1465
  };
1556
- /**
1557
- * Create a MetadataType object from a metadata object
1558
- * @param {Object} metadata={} - object with metadata to create MetadataType object of
1559
- * @returns {Object} MetadataType
1560
- */
1561
1466
 
1467
+ var formatSecondsPrecise = function formatSecondsPrecise(seconds, timeBase, options) {
1468
+ if (Number.isNaN(Number(seconds))) {
1469
+ throw new Error("seconds must be digits, is ".concat(seconds));
1470
+ }
1562
1471
 
1563
- var createMetadataType = function createMetadataType() {
1564
- var metadata = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1565
- var metadataType = {};
1472
+ var _ref8 = timeBase || {},
1473
+ _ref8$numerator = _ref8.numerator,
1474
+ numerator = _ref8$numerator === void 0 ? 1 : _ref8$numerator;
1566
1475
 
1567
- if (Array.isArray(metadata)) {
1568
- metadataType.timespan = metadata.map(function (thisTimeSpan) {
1569
- return parseTimespan$1(thisTimeSpan);
1570
- });
1571
- } else {
1572
- var genericTimespan = parseTimespan$1(metadata);
1573
- metadataType.timespan = [genericTimespan];
1476
+ var _ref9 = timeBase || {},
1477
+ _ref9$denominator = _ref9.denominator,
1478
+ denominator = _ref9$denominator === void 0 ? 1 : _ref9$denominator;
1479
+
1480
+ if (!Number.isInteger(seconds)) {
1481
+ var decimalPlaces = String(seconds).split('.')[1].length;
1482
+ denominator *= Math.pow(10, decimalPlaces);
1574
1483
  }
1575
1484
 
1576
- return metadataType;
1485
+ var samples = (seconds * (denominator / numerator)).toFixed();
1486
+ var timeCode = {
1487
+ samples: samples,
1488
+ timeBase: {
1489
+ denominator: denominator,
1490
+ numerator: numerator
1491
+ }
1492
+ };
1493
+ return new TimeCode(timeCode, options);
1577
1494
  };
1578
1495
 
1579
- var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
1580
- var firstStart = timespan1.start;
1581
- var secondStart = timespan2.start;
1582
-
1583
- var _firstStart$split = firstStart.split('@'),
1584
- _firstStart$split2 = _slicedToArray(_firstStart$split, 1),
1585
- first = _firstStart$split2[0];
1496
+ var formatSmpte = function formatSmpte(smpteText, timeBaseText) {
1497
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1586
1498
 
1587
- var _secondStart$split = secondStart.split('@'),
1588
- _secondStart$split2 = _slicedToArray(_secondStart$split, 1),
1589
- second = _secondStart$split2[0];
1499
+ if (smpteText === undefined) {
1500
+ var _timeBase = formatTimeBase(timeBaseText);
1590
1501
 
1591
- if (Number(first) < Number(second)) {
1592
- return -1;
1502
+ var _timeCode6 = {
1503
+ samples: 0,
1504
+ timeBase: _timeBase
1505
+ };
1506
+ return formatTimeCodeType(_timeCode6);
1593
1507
  }
1594
1508
 
1595
- if (Number(first) > Number(second)) {
1596
- return 1;
1509
+ if (typeof smpteText !== 'string') {
1510
+ throw new Error("smpteText must be a string, is ".concat(smpteText));
1597
1511
  }
1598
1512
 
1599
- return 0;
1600
- };
1601
-
1602
- var _excluded$1 = ["value"],
1603
- _excluded2 = ["field", "group"],
1604
- _excluded3 = ["field", "group"];
1513
+ var _splitSmpte = splitSmpte(smpteText),
1514
+ _splitSmpte2 = _slicedToArray(_splitSmpte, 2),
1515
+ _splitSmpte2$ = _slicedToArray(_splitSmpte2[0], 4),
1516
+ hh = _splitSmpte2$[0],
1517
+ mm = _splitSmpte2$[1],
1518
+ ss = _splitSmpte2$[2],
1519
+ _splitSmpte2$$ = _splitSmpte2$[3],
1520
+ ff = _splitSmpte2$$ === void 0 ? 0 : _splitSmpte2$$,
1521
+ frameOptions = _splitSmpte2[1];
1605
1522
 
1606
- 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; }
1523
+ var _frameOptions$dropFra = frameOptions.dropFrame,
1524
+ dropFrame = _frameOptions$dropFra === void 0 ? false : _frameOptions$dropFra;
1525
+ var timeBase = formatTimeBase(timeBaseText);
1526
+ var roundedFrameRate = getRoundedFrameRate(timeBase);
1607
1527
 
1608
- 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(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; }
1528
+ if (mm >= 60 || mm < 0 || ss >= 60 || ss < 0 || ff >= roundedFrameRate || ff < 0) {
1529
+ throw new Error('Invalid mm, ss or ff');
1530
+ }
1609
1531
 
1610
- var parseValueList = function parseValueList() {
1611
- var valueList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1612
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1613
- var _options$arrayOnSingl = options.arrayOnSingle,
1614
- arrayOnSingle = _options$arrayOnSingl === void 0 ? true : _options$arrayOnSingl,
1615
- _options$arrayOnSingl2 = options.arrayOnSingleValue,
1616
- arrayOnSingleValue = _options$arrayOnSingl2 === void 0 ? true : _options$arrayOnSingl2,
1617
- joinValue = options.joinValue,
1618
- includeAttributes = options.includeAttributes,
1619
- includeValueAttributes = options.includeValueAttributes;
1620
- if (includeAttributes || includeValueAttributes) return valueList;
1621
- var valueArray = [];
1622
- valueList.forEach(function (thisValue) {
1623
- if (thisValue.value) valueArray.push(thisValue.value);
1532
+ var samples = countSamples(hh, mm, ss, ff, {
1533
+ dropFrame: dropFrame,
1534
+ roundedFrameRate: roundedFrameRate
1624
1535
  });
1625
- if (joinValue) return valueArray.join(joinValue);
1536
+ var timeCode = {
1537
+ samples: samples,
1538
+ timeBase: timeBase
1539
+ };
1540
+ return formatTimeCodeType(timeCode, _objectSpread$2(_objectSpread$2({}, frameOptions), options));
1541
+ };
1626
1542
 
1627
- if (arrayOnSingle === false || arrayOnSingleValue === false && valueArray.length === 1) {
1628
- return valueArray[0];
1629
- }
1543
+ function timeToCueTime(_ref) {
1544
+ var _ref$hours = _ref.hours,
1545
+ hours = _ref$hours === void 0 ? 0 : _ref$hours,
1546
+ _ref$minutes = _ref.minutes,
1547
+ minutes = _ref$minutes === void 0 ? 0 : _ref$minutes,
1548
+ _ref$seconds = _ref.seconds,
1549
+ seconds = _ref$seconds === void 0 ? 0 : _ref$seconds,
1550
+ _ref$partialSeconds = _ref.partialSeconds,
1551
+ partialSeconds = _ref$partialSeconds === void 0 ? 0 : _ref$partialSeconds;
1552
+ var hourStr = hours.toFixed().padStart(2, '0');
1553
+ var minStr = minutes.toFixed().padStart(2, '0');
1554
+ var secondsStr = seconds.toFixed().padStart(2, '0');
1555
+ var partialStr = (partialSeconds * 10).toFixed().padStart(3, '0');
1556
+ return "".concat(hourStr, ":").concat(minStr, ":").concat(secondsStr, ".").concat(partialStr);
1557
+ }
1558
+ /**
1559
+ * Convert subtitle groups to WebVtt subtitle format
1560
+ * @param {Object} input={}
1561
+ * @param {Object} input.metadataType - MetadataType response from API.
1562
+ * @param {string} input.subtitleGroup=stl_subtitle - Name of group containing subtitle field/text.
1563
+ * @param {string} input.subtitleField=stl_text - Name of field (text) to use for the subtitles.
1564
+ * @returns {string} WebVtt subtitles
1565
+ */
1630
1566
 
1631
- return valueArray;
1632
- };
1633
1567
 
1634
- var parseField = function parseField() {
1635
- var field = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1636
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1637
- var includeAttributes = options.includeAttributes,
1638
- includeFieldAttributes = options.includeFieldAttributes;
1568
+ function metadataTypeToWebVtt(_ref2) {
1569
+ var metadataType = _ref2.metadataType,
1570
+ _ref2$subtitleGroup = _ref2.subtitleGroup,
1571
+ subtitleGroup = _ref2$subtitleGroup === void 0 ? 'stl_subtitle' : _ref2$subtitleGroup,
1572
+ _ref2$subtitleField = _ref2.subtitleField,
1573
+ subtitleField = _ref2$subtitleField === void 0 ? 'stl_text' : _ref2$subtitleField;
1574
+ var parseOptions = {
1575
+ includeTimespanAttributes: true,
1576
+ flatTimespan: true,
1577
+ flatGroup: true,
1578
+ joinValue: ','
1579
+ };
1639
1580
 
1640
- var _field$value = field.value,
1641
- value = _field$value === void 0 ? [] : _field$value,
1642
- attributes = _objectWithoutProperties(field, _excluded$1);
1581
+ var _ref3 = metadataType || {},
1582
+ _ref3$timespan = _ref3.timespan,
1583
+ timespanList = _ref3$timespan === void 0 ? [] : _ref3$timespan;
1643
1584
 
1644
- var parsedValueList = parseValueList(value, options);
1645
- if (includeAttributes || includeFieldAttributes) return _objectSpread$4(_objectSpread$4({}, attributes), {}, {
1646
- value: parsedValueList
1585
+ if (timespanList.length === 0) return '';
1586
+ var sortedTimespans = timespanList.sort(sortTimespanList);
1587
+ var parsedTimespans = sortedTimespans.map(function (timespanType) {
1588
+ return parseTimespan(timespanType, parseOptions);
1647
1589
  });
1648
- return parsedValueList;
1649
- };
1590
+ var vttCues = parsedTimespans.map(function (thisTimespan) {
1591
+ var startText = thisTimespan.start,
1592
+ endText = thisTimespan.end,
1593
+ _thisTimespan$subtitl = thisTimespan[subtitleGroup];
1594
+ _thisTimespan$subtitl = _thisTimespan$subtitl === void 0 ? {} : _thisTimespan$subtitl;
1595
+ var text = _thisTimespan$subtitl[subtitleField];
1596
+ if (!text) return '';
1597
+ var startTime = formatTimeCodeText(startText).toTime();
1598
+ var start = timeToCueTime(startTime);
1599
+ var endTime = formatTimeCodeText(endText).toTime();
1600
+ var end = timeToCueTime(endTime);
1601
+ return "".concat(start, " --> ").concat(end, " line:0%\r").concat(text, "\r");
1602
+ });
1603
+ return "WEBVTT\n\n\n".concat(vttCues.join('\n'));
1604
+ }
1650
1605
 
1651
- var parseFieldList = function parseFieldList() {
1606
+ var createFacetType = function createFacetType() {
1652
1607
  var fieldList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1653
1608
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1654
- var joinValue = options.joinValue,
1655
- includeAttributes = options.includeAttributes,
1656
- includeFieldAttributes = options.includeFieldAttributes,
1657
- includeValueAttributes = options.includeValueAttributes;
1658
- var output = {};
1659
- var fieldAsList = options.fieldAsList;
1609
+ return fieldList.map(function (field) {
1610
+ return {
1611
+ field: field,
1612
+ name: field,
1613
+ count: options.count || true,
1614
+ exclude: fieldList
1615
+ };
1616
+ });
1617
+ };
1660
1618
 
1661
- if (fieldAsList) {
1662
- return fieldList.map(function (thisField) {
1663
- return parseField(thisField, options);
1664
- });
1665
- }
1619
+ 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; }
1666
1620
 
1667
- fieldList.forEach(function (thisField) {
1668
- var key = thisField.name;
1669
- var parsedField = parseField(thisField, options);
1621
+ 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(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; }
1670
1622
 
1671
- if (output[key]) {
1672
- if (includeAttributes || includeFieldAttributes) {
1673
- var currentValue = output[key].value;
1674
- var parsedValue = parsedField.value;
1623
+ var parseFacetType = function parseFacetType() {
1624
+ var facetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1625
+ var output = {};
1675
1626
 
1676
- if (joinValue && !includeAttributes && !includeValueAttributes) {
1677
- output[key].value = [currentValue, parsedValue].join(joinValue);
1678
- } else {
1679
- output[key].value = parsedValue.concat(currentValue);
1680
- }
1681
- } else {
1682
- var _currentValue = output[key];
1683
- var _parsedValue = parsedField;
1627
+ var facetFieldReducer = function facetFieldReducer(a, _ref) {
1628
+ var fieldValue = _ref.fieldValue,
1629
+ value = _ref.value;
1630
+ return _objectSpread$1(_objectSpread$1({}, a), {}, _defineProperty({}, fieldValue, value));
1631
+ };
1684
1632
 
1685
- if (joinValue) {
1686
- output[key] = [_currentValue, _parsedValue].join(joinValue);
1687
- } else {
1688
- output[key] = _parsedValue.concat(_currentValue);
1689
- }
1690
- }
1691
- } else {
1692
- output[key] = parsedField;
1693
- }
1633
+ facetType.forEach(function (_ref2) {
1634
+ var name = _ref2.name,
1635
+ field = _ref2.field,
1636
+ count = _ref2.count;
1637
+ output[name || field] = count.reduce(facetFieldReducer, {});
1694
1638
  });
1695
1639
  return output;
1696
1640
  };
1697
1641
 
1698
- var parseGroup = function parseGroup() {
1699
- var group = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1700
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1701
- var includeAttributes = options.includeAttributes,
1702
- includeGroupAttributes = options.includeGroupAttributes,
1703
- flat = options.flat,
1704
- flatGroup = options.flatGroup,
1705
- groupAsList = options.groupAsList,
1706
- fieldAsList = options.fieldAsList;
1707
-
1708
- var _group$field = group.field,
1709
- fieldList = _group$field === void 0 ? [] : _group$field,
1710
- _group$group = group.group,
1711
- groupList = _group$group === void 0 ? [] : _group$group,
1712
- attributes = _objectWithoutProperties(group, _excluded2);
1713
-
1714
- var parsedFieldList = parseFieldList(fieldList, options); // eslint-disable-next-line no-use-before-define
1642
+ var _excluded$1 = ["property"];
1715
1643
 
1716
- var parsedGroupList = parseGroupList(groupList, options);
1717
- var output = {};
1644
+ 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; }
1718
1645
 
1719
- if (includeAttributes || includeGroupAttributes) {
1720
- Object.assign(output, attributes);
1721
- }
1646
+ 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(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; }
1647
+ var sampleRateSymbols = {
1648
+ kB: 'kHz',
1649
+ B: 'Hz',
1650
+ mB: 'mHz'
1651
+ };
1652
+ var bitRateSymbols = {
1653
+ kB: 'kbps',
1654
+ B: 'bps',
1655
+ MB: 'mbps'
1656
+ };
1722
1657
 
1723
- if (flat || flatGroup) {
1724
- if (groupAsList) {
1725
- Object.assign(output, {
1726
- group: parsedGroupList
1727
- });
1728
- } else {
1729
- Object.assign(output, parsedGroupList);
1730
- }
1658
+ var gcd = function gcd(a, b) {
1659
+ return b ? gcd(b, a % b) : a;
1660
+ };
1731
1661
 
1732
- if (fieldAsList) {
1733
- Object.assign(output, {
1734
- field: parsedFieldList
1735
- });
1736
- } else {
1737
- Object.assign(output, parsedFieldList);
1738
- }
1739
- } else {
1740
- Object.assign(output, {
1741
- field: parsedFieldList
1742
- });
1743
- Object.assign(output, {
1744
- group: parsedGroupList
1745
- });
1662
+ var parseAspectRatio = function parseAspectRatio(_ref) {
1663
+ var width = _ref.width,
1664
+ height = _ref.height;
1665
+ var denominator = gcd(width, height);
1666
+ var widthRatio = width / denominator;
1667
+ var heightRatio = height / denominator;
1668
+
1669
+ if (widthRatio > 21) {
1670
+ heightRatio = 1;
1671
+ widthRatio = (width / height).toFixed(2);
1746
1672
  }
1747
1673
 
1748
- return output;
1674
+ return [widthRatio, heightRatio].join(':');
1749
1675
  };
1750
1676
 
1751
- var parseGroupList = function parseGroupList() {
1752
- var groupList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1753
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1754
- var groupAsList = options.groupAsList;
1755
-
1756
- if (groupAsList) {
1757
- return groupList.map(function (thisGroup) {
1758
- return parseGroup(thisGroup, options);
1759
- });
1760
- }
1677
+ var parseBaseMediaInfoType = function parseBaseMediaInfoType() {
1678
+ var baseMediaInfoType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1761
1679
 
1762
- var output = {};
1763
- groupList.forEach(function (thisGroup) {
1764
- var key = thisGroup.name;
1765
- var parsedGroup = parseGroup(thisGroup, options);
1680
+ var keyValuePairType = baseMediaInfoType.property,
1681
+ props = _objectWithoutProperties(baseMediaInfoType, _excluded$1);
1766
1682
 
1767
- if (output[key]) {
1768
- var _output$key = output[key],
1769
- currentField = _output$key.field,
1770
- currentGroup = _output$key.group;
1771
- var parsedField = parsedGroup.field,
1772
- parsedGroupList = parsedGroup.group;
1773
- output[key].field = _objectSpread$4(_objectSpread$4({}, currentField), parsedField);
1774
- output[key].group = _objectSpread$4(_objectSpread$4({}, currentGroup), parsedGroupList);
1775
- } else {
1776
- output[key] = parsedGroup;
1777
- }
1778
- });
1779
- return output;
1683
+ var parsedKeyValuePairType = parseKeyValuePairType(keyValuePairType);
1684
+ return _objectSpread(_objectSpread({}, parsedKeyValuePairType), props);
1780
1685
  };
1781
- /**
1782
- * Parses timespan according to specified options.
1783
- * The attributes can be targeted for each sub-type.
1784
- * @param {Object} timespan={} - The timespan response from the API.
1785
- * @param {Object} options={} - Options which change how the metadataType is parsed.
1786
- * @param {string} options.joinValue=undefined - String to join the values, eg ','.
1787
- * @param {boolean} options.includeAttributes=false - Include attributes on all objects.
1788
- * @param {boolean} options.includeTimespanAttributes=false - Include attributes on timespans.
1789
- * @param {boolean} options.includeGroupAttributes=false - Include attributes on groups.
1790
- * @param {boolean} options.includeFieldAttributes=false - Include attributes on fields.
1791
- * @param {boolean} options.includeValueAttributes=false - Include attributes on values.
1792
- * @param {boolean} options.flat=false - Flatten to key/value (Note: keys may be overwritten).
1793
- * @param {boolean} options.flatTimespan=false - Flatten timespan.
1794
- * @param {boolean} options.flatGroup=false - Flatten group.
1795
- * @param {boolean} options.groupAsList=false - Return groups as list.
1796
- * @param {boolean} options.fieldAsList=false - Return fields as list.
1797
- * @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
1798
- * @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
1799
- * @returns {Object} Metadata object parsed according to options.
1800
- */
1801
1686
 
1687
+ var parseFileType = function parseFileType(fileType) {
1688
+ var _fileType$uri = fileType.uri,
1689
+ uriList = _fileType$uri === void 0 ? [] : _fileType$uri,
1690
+ fileSizeBytes = fileType.size,
1691
+ hash = fileType.hash,
1692
+ path = fileType.path,
1693
+ fileId = fileType.id;
1802
1694
 
1803
- var parseTimespan = function parseTimespan() {
1804
- var timespan = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1805
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1806
- var includeAttributes = options.includeAttributes,
1807
- includeTimespanAttributes = options.includeTimespanAttributes,
1808
- flat = options.flat,
1809
- flatTimespan = options.flatTimespan,
1810
- groupAsList = options.groupAsList,
1811
- fieldAsList = options.fieldAsList;
1695
+ var _uriList = _slicedToArray(uriList, 1),
1696
+ uri = _uriList[0];
1812
1697
 
1813
- var _timespan$field = timespan.field,
1814
- fieldList = _timespan$field === void 0 ? [] : _timespan$field,
1815
- _timespan$group = timespan.group,
1816
- groupList = _timespan$group === void 0 ? [] : _timespan$group,
1817
- attributes = _objectWithoutProperties(timespan, _excluded3);
1698
+ var fileSize = fileSizeBytes !== undefined ? parseFileSize(fileSizeBytes) : '';
1699
+ var fileName = path ? path.split('/').pop() : undefined;
1700
+ return {
1701
+ uri: uri,
1702
+ hash: hash,
1703
+ fileSize: fileSize,
1704
+ fileSizeBytes: fileSizeBytes,
1705
+ path: path,
1706
+ fileName: fileName,
1707
+ fileId: fileId
1708
+ };
1709
+ };
1818
1710
 
1819
- var field = parseFieldList(fieldList, options);
1820
- var group = parseGroupList(groupList, options);
1821
- var output = {};
1711
+ var parseContainerComponent = function parseContainerComponent(containerComponent) {
1712
+ var _containerComponent$m = containerComponent.mediaInfo,
1713
+ mediaInfo = _containerComponent$m === void 0 ? {} : _containerComponent$m,
1714
+ _containerComponent$m2 = containerComponent.metadata,
1715
+ metadata = _containerComponent$m2 === void 0 ? [] : _containerComponent$m2,
1716
+ fileList = containerComponent.file,
1717
+ durationTimeCode = containerComponent.duration,
1718
+ startTimestamp = containerComponent.startTimestamp,
1719
+ startTimecode = containerComponent.startTimecode,
1720
+ timeCodeTimeBase = containerComponent.timeCodeTimeBase;
1721
+ var containerMetadata = parseKeyValuePairType(metadata);
1722
+ var containerMediaInfo = parseBaseMediaInfoType(mediaInfo);
1723
+ var containerFormat = containerMediaInfo.Format;
1724
+ var videoFormat = containerMediaInfo.Video_Format_List,
1725
+ audioFormat = containerMediaInfo.Audio_Format_List,
1726
+ textFormat = containerMediaInfo.Text_Format_List;
1822
1727
 
1823
- if (includeAttributes || includeTimespanAttributes) {
1824
- Object.assign(output, attributes);
1825
- }
1728
+ if (containerFormat === undefined) {
1729
+ var format = containerComponent.format;
1730
+ containerFormat = format;
1826
1731
 
1827
- if (flat || flatTimespan) {
1828
- if (groupAsList) {
1829
- Object.assign(output, {
1830
- group: group
1831
- });
1832
- } else {
1833
- Object.assign(output, group);
1834
- }
1732
+ if (format && format.includes(',')) {
1733
+ var formatList = format.split(',');
1835
1734
 
1836
- if (fieldAsList) {
1837
- Object.assign(output, {
1838
- field: field
1839
- });
1840
- } else {
1841
- Object.assign(output, field);
1735
+ var _formatList = _slicedToArray(formatList, 1);
1736
+
1737
+ containerFormat = _formatList[0];
1842
1738
  }
1843
- } else {
1844
- Object.assign(output, {
1845
- field: field
1846
- });
1847
- Object.assign(output, {
1848
- group: group
1849
- });
1850
1739
  }
1851
1740
 
1852
- return output;
1853
- };
1741
+ var parsedContainerComponent = {
1742
+ containerFormat: containerFormat,
1743
+ videoFormat: videoFormat,
1744
+ audioFormat: audioFormat,
1745
+ textFormat: textFormat,
1746
+ containerMetadata: containerMetadata,
1747
+ containerMediaInfo: containerMediaInfo
1748
+ };
1854
1749
 
1855
- 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; }
1750
+ if (containerMetadata.componentOriginalFilename) {
1751
+ parsedContainerComponent.originalFilename = containerMetadata.componentOriginalFilename;
1752
+ }
1856
1753
 
1857
- 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(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; }
1858
- /**
1859
- * Parses timespanList according to specified options.
1860
- * The attributes can be targeted for each sub-type.
1861
- * @param {Object[]} timespanList - The timespanList response from the API.
1862
- * @param {Object} options - Options which change how the metadataType is parsed.
1863
- * @param {string} options.joinValue - String to join the values, eg ','.
1864
- * @param {boolean} options.includeAttributes - Include attributes on all objects.
1865
- * @param {boolean} options.includeMetadataAttributes - Include attributes on root.
1866
- * @param {boolean} options.includeTimespanAttributes - Include attributes on timespans.
1867
- * @param {boolean} options.includeGroupAttributes - Include attributes on groups.
1868
- * @param {boolean} options.includeFieldAttributes - Include attributes on fields.
1869
- * @param {boolean} options.includeValueAttributes - Include attributes on values.
1870
- * @param {boolean} options.flat - Flatten to key/value (Note: keys may be overwritten).
1871
- * @param {boolean} options.flatTimespan - Flatten timespan.
1872
- * @param {boolean} options.flatGroup - Flatten group.
1873
- * @param {boolean} options.sortTimespan - Sort timespan by start time.
1874
- * @param {boolean} options.timespanAsList - Return timespans as list.
1875
- * @param {boolean} options.groupAsList - Return groups as list.
1876
- * @param {boolean} options.fieldAsList - Return fields as list.
1877
- * @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
1878
- * @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
1879
- * @returns {Object} Metadata object parsed according to options.
1880
- */
1754
+ if (durationTimeCode !== undefined && durationTimeCode.samples !== 0) {
1755
+ parsedContainerComponent.durationTimeCode = formatTimeCodeType(durationTimeCode);
1756
+ parsedContainerComponent.duration = parsedContainerComponent.durationTimeCode.toDuration();
1757
+ }
1881
1758
 
1882
- var parseTimespanList = function parseTimespanList() {
1883
- var timespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1884
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1885
- var joinTimespan = options.joinTimespan,
1886
- flat = options.flat;
1887
- var timespanAsList = options.timespanAsList;
1759
+ if (startTimestamp) {
1760
+ parsedContainerComponent.startTimestamp = formatTimeCodeType(startTimestamp);
1761
+ }
1888
1762
 
1889
- if (timespanAsList) {
1890
- return timespanList.map(function (thisTimespan) {
1891
- return parseTimespan(thisTimespan, options);
1763
+ if (startTimecode !== undefined && timeCodeTimeBase) {
1764
+ parsedContainerComponent.startTimecode = formatTimeCodeType({
1765
+ samples: startTimecode,
1766
+ timeBase: timeCodeTimeBase
1892
1767
  });
1893
1768
  }
1894
1769
 
1895
- var output = {};
1896
- timespanList.forEach(function (thisTimespan) {
1897
- var start = thisTimespan.start,
1898
- end = thisTimespan.end;
1899
- var key = [start, end].join(joinTimespan || '_');
1900
- var parsedTimespan = parseTimespan(thisTimespan, options);
1770
+ if (fileList) {
1771
+ var _fileList = _slicedToArray(fileList, 1),
1772
+ fileType = _fileList[0];
1901
1773
 
1902
- if (flat) {
1903
- output = _objectSpread$3(_objectSpread$3({}, output), parsedTimespan);
1904
- } else if (output[key]) {
1905
- var _output$key = output[key],
1906
- currentField = _output$key.field,
1907
- currentGroup = _output$key.group;
1908
- var parsedField = parsedTimespan.field,
1909
- parsedGroup = parsedTimespan.group;
1910
- output[key].field = _objectSpread$3(_objectSpread$3({}, currentField), parsedField);
1911
- output[key].group = _objectSpread$3(_objectSpread$3({}, currentGroup), parsedGroup);
1912
- } else {
1913
- output[key] = parsedTimespan;
1914
- }
1915
- });
1916
- return output;
1917
- };
1774
+ var parsedFileType = parseFileType(fileType);
1775
+ parsedContainerComponent = _objectSpread(_objectSpread({}, parsedContainerComponent), parsedFileType);
1776
+ }
1918
1777
 
1919
- var _excluded = ["timespan"];
1920
- /**
1921
- * Parses MetadataType according to specified options.
1922
- * The attributes can be targeted for each sub-type.
1923
- * @param {Object} metadataType - The MetadataType response from the API.
1924
- * @param {Object} options - Options which change how the metadataType is parsed.
1925
- * @param {string} options.joinValue - String to join the values, eg ','.
1926
- * @param {boolean} options.includeAttributes - Include attributes on all objects.
1927
- * @param {boolean} options.includeMetadataAttributes - Include attributes on root.
1928
- * @param {boolean} options.includeTimespanAttributes - Include attributes on timespans.
1929
- * @param {boolean} options.includeGroupAttributes - Include attributes on groups.
1930
- * @param {boolean} options.includeFieldAttributes - Include attributes on fields.
1931
- * @param {boolean} options.includeValueAttributes - Include attributes on values.
1932
- * @param {boolean} options.flat - Flatten to key/value (Note: keys may be overwritten).
1933
- * @param {boolean} options.flatTimespan - Flatten timespan.
1934
- * @param {boolean} options.flatGroup - Flatten group.
1935
- * @param {boolean} options.sortTimespan - Sort timespan by start time.
1936
- * @param {boolean} options.timespanAsList - Return timespans as list.
1937
- * @param {boolean} options.groupAsList - Return groups as list.
1938
- * @param {boolean} options.fieldAsList - Return fields as list.
1939
- * @param {boolean} options.arrayOnSingle=true - Return fields as array even if single field.
1940
- * @param {boolean} options.arrayOnSingleValue=true - Return fields as array even if single field value.
1941
- * @returns {Object} Metadata object parsed according to options.
1942
- */
1778
+ return parsedContainerComponent;
1779
+ };
1943
1780
 
1944
- var parseMetadataType = function parseMetadataType() {
1945
- var metadataType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1946
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1947
- var includeAttributes = options.includeAttributes,
1948
- includeMetadataAttributes = options.includeMetadataAttributes,
1949
- sortTimespan = options.sortTimespan;
1781
+ var parseVideoComponent = function parseVideoComponent(videoComponent) {
1782
+ var videoCodec = videoComponent.codec,
1783
+ bitrate = videoComponent.bitrate,
1784
+ fieldOrder = videoComponent.fieldOrder,
1785
+ _videoComponent$resol = videoComponent.resolution,
1786
+ resolution = _videoComponent$resol === void 0 ? {} : _videoComponent$resol,
1787
+ _videoComponent$media = videoComponent.mediaInfo,
1788
+ mediaInfo = _videoComponent$media === void 0 ? {} : _videoComponent$media,
1789
+ _videoComponent$metad = videoComponent.metadata,
1790
+ metadata = _videoComponent$metad === void 0 ? [] : _videoComponent$metad;
1791
+ var videoMediaInfo = parseBaseMediaInfoType(mediaInfo);
1792
+ var videoMetadata = parseKeyValuePairType(metadata);
1793
+ var videoFormat = videoMediaInfo.Format,
1794
+ timeBaseText = videoMediaInfo['Frame rate'],
1795
+ colorSpace = videoMediaInfo['Color space'],
1796
+ colorPrimaries = videoMediaInfo['Color primaries'],
1797
+ chromaSubsampling = videoMediaInfo.Colorimetry;
1798
+ var timeBase;
1799
+ var averageFrameRate = videoComponent.averageFrameRate,
1800
+ realBaseFrameRate = videoComponent.realBaseFrameRate;
1950
1801
 
1951
- var _metadataType$timespa = metadataType.timespan,
1952
- timespanList = _metadataType$timespa === void 0 ? [] : _metadataType$timespa,
1953
- attributes = _objectWithoutProperties(metadataType, _excluded);
1802
+ if (realBaseFrameRate !== undefined) {
1803
+ timeBase = {
1804
+ numerator: realBaseFrameRate.denominator,
1805
+ denominator: realBaseFrameRate.numerator
1806
+ };
1807
+ } else if (timeBaseText !== undefined) {
1808
+ timeBase = formatTimeBaseText(timeBaseText);
1809
+ } else if (averageFrameRate !== undefined) {
1810
+ timeBase = {
1811
+ numerator: averageFrameRate.denominator,
1812
+ denominator: averageFrameRate.numerator
1813
+ };
1814
+ }
1954
1815
 
1955
- if (sortTimespan) timespanList.sort(sortTimespanList);
1956
- var timespan = parseTimespanList(timespanList, options);
1816
+ var samples = videoMediaInfo['Frame count'];
1957
1817
 
1958
- if (includeAttributes || includeMetadataAttributes) {
1959
- Object.assign(timespan, attributes);
1818
+ if (samples === undefined) {
1819
+ var numberOfPackets = videoComponent.numberOfPackets;
1820
+ if (numberOfPackets !== undefined) samples = numberOfPackets;
1960
1821
  }
1961
1822
 
1962
- return timespan;
1963
- };
1823
+ var timeCode;
1824
+ var frameRate;
1825
+ var smpte;
1964
1826
 
1965
- var parseSimpleMetadataType = function parseSimpleMetadataType() {
1966
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1967
- _ref$field = _ref.field,
1968
- field = _ref$field === void 0 ? [] : _ref$field;
1827
+ if (samples && timeBase) {
1828
+ timeCode = formatTimeCodeType({
1829
+ samples: samples,
1830
+ timeBase: timeBase
1831
+ });
1832
+ frameRate = timeCode.timeBase.toRate(true);
1833
+ smpte = timeCode.toSmpte(true);
1834
+ }
1969
1835
 
1970
- return parseKeyValuePairType(field);
1836
+ var height = resolution.height,
1837
+ width = resolution.width;
1838
+ var aspectRatio = parseAspectRatio(resolution);
1839
+ var dimension = "".concat(width, "x").concat(height);
1840
+ var videoBitrate = bitrate ? parseFileSize(bitrate, {
1841
+ bits: true
1842
+ }) : undefined;
1843
+ return {
1844
+ videoFormat: videoFormat,
1845
+ dimension: dimension,
1846
+ frameRate: frameRate,
1847
+ height: height,
1848
+ width: width,
1849
+ timeBase: timeBase,
1850
+ timeCode: timeCode,
1851
+ videoCodec: videoCodec,
1852
+ smpte: smpte,
1853
+ videoBitrate: videoBitrate,
1854
+ fieldOrder: fieldOrder,
1855
+ colorSpace: colorSpace,
1856
+ chromaSubsampling: chromaSubsampling,
1857
+ aspectRatio: aspectRatio,
1858
+ colorPrimaries: colorPrimaries,
1859
+ videoMetadata: videoMetadata,
1860
+ videoMediaInfo: videoMediaInfo
1861
+ };
1971
1862
  };
1972
1863
 
1973
- 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; }
1974
-
1975
- 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(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; }
1976
-
1977
- /**
1978
- * Parses highlight timespan responses from the api into key/value object.
1979
- * The attributes can be targeted for each sub-type.
1980
- * @param {Object[]} highlightTimespan - A timespan object from the api response.
1981
- * @param {Object} options - Options which change how the timespans are parsed.
1982
- * @param {boolean} options.arrayOnSingle=true - Return an array if there is a single value.
1983
- * @param {boolean} options.timespanAsList=false - Return timespans as list.
1984
- * @param {string} options.joinValue - String to join the values, eg ','.
1985
- */
1986
- var parseHighlightTimespan = function parseHighlightTimespan() {
1987
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1988
- _ref$field = _ref.field,
1989
- field = _ref$field === void 0 ? [] : _ref$field,
1990
- start = _ref.start,
1991
- end = _ref.end;
1864
+ var parseAudioComponent = function parseAudioComponent(audioComponent) {
1865
+ var _audioComponent$timeB = audioComponent.timeBase,
1866
+ timeBase = _audioComponent$timeB === void 0 ? {} : _audioComponent$timeB,
1867
+ audioChannels = audioComponent.channelCount,
1868
+ audioCodec = audioComponent.codec,
1869
+ _audioComponent$media = audioComponent.mediaInfo,
1870
+ mediaInfo = _audioComponent$media === void 0 ? {} : _audioComponent$media,
1871
+ bitrate = audioComponent.bitrate,
1872
+ _audioComponent$metad = audioComponent.metadata,
1873
+ metadata = _audioComponent$metad === void 0 ? [] : _audioComponent$metad;
1874
+ var audioMediaInfo = parseBaseMediaInfoType(mediaInfo);
1875
+ var audioMetadata = parseKeyValuePairType(metadata);
1876
+ var audioFormat = audioMediaInfo.Format,
1877
+ audioBitDepth = audioMediaInfo.Resolution,
1878
+ audioBitRateMode = audioMediaInfo.Bit_rate_mode;
1879
+ var audioSamplerateSamples = timeBase.denominator ? timeBase.denominator / timeBase.numerator : undefined;
1880
+ var audioSamplerate = audioSamplerateSamples ? parseFileSize(audioSamplerateSamples, {
1881
+ base: 10,
1882
+ round: 1,
1883
+ symbols: sampleRateSymbols
1884
+ }) : undefined;
1885
+ var audioBitrate = bitrate ? parseFileSize(bitrate, {
1886
+ base: 10,
1887
+ round: 2,
1888
+ symbols: bitRateSymbols
1889
+ }) : undefined;
1890
+ return {
1891
+ audioFormat: audioFormat,
1892
+ audioCodec: audioCodec,
1893
+ audioSamplerate: audioSamplerate,
1894
+ audioSamplerateSamples: audioSamplerateSamples,
1895
+ audioBitDepth: audioBitDepth,
1896
+ audioBitrate: audioBitrate,
1897
+ audioBitRateMode: audioBitRateMode,
1898
+ audioChannels: audioChannels,
1899
+ audioMediaInfo: audioMediaInfo,
1900
+ audioMetadata: audioMetadata
1901
+ };
1902
+ };
1992
1903
 
1993
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1994
- var _opts$arrayOnSingle = opts.arrayOnSingle,
1995
- arrayOnSingle = _opts$arrayOnSingle === void 0 ? true : _opts$arrayOnSingle,
1996
- _opts$joinValue = opts.joinValue,
1997
- joinValue = _opts$joinValue === void 0 ? undefined : _opts$joinValue,
1998
- _opts$timespanAsList = opts.timespanAsList,
1999
- timespanAsList = _opts$timespanAsList === void 0 ? undefined : _opts$timespanAsList;
2000
- var initialValue = timespanAsList ? {
2001
- start: start,
2002
- end: end
2003
- } : {};
2004
- var fieldList = field.reduce(function (a, _ref2) {
2005
- var name = _ref2.name,
2006
- _ref2$value = _ref2.value,
2007
- valueList = _ref2$value === void 0 ? [] : _ref2$value;
2008
- if (valueList.length === 0) return a;
2009
- var fieldValue;
1904
+ var parseBinaryComponent = function parseBinaryComponent(binaryComponent) {
1905
+ var fileList = binaryComponent.file,
1906
+ _binaryComponent$medi = binaryComponent.mediaInfo,
1907
+ mediaInfo = _binaryComponent$medi === void 0 ? {} : _binaryComponent$medi,
1908
+ _binaryComponent$meta = binaryComponent.metadata,
1909
+ metadata = _binaryComponent$meta === void 0 ? [] : _binaryComponent$meta;
1910
+ var binaryMetadata = parseKeyValuePairType(metadata);
1911
+ var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
1912
+ var parsedBinaryComponent = {
1913
+ binaryMetadata: binaryMetadata,
1914
+ binaryMediaInfo: binaryMediaInfo
1915
+ };
2010
1916
 
2011
- if (arrayOnSingle === false && valueList.length === 1) {
2012
- var _valueList = _slicedToArray(valueList, 1);
1917
+ if (fileList) {
1918
+ var _fileList2 = _slicedToArray(fileList, 1),
1919
+ fileType = _fileList2[0];
2013
1920
 
2014
- fieldValue = _valueList[0];
2015
- } else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
1921
+ var parsedFileType = parseFileType(fileType);
1922
+ parsedBinaryComponent = _objectSpread(_objectSpread({}, parsedBinaryComponent), parsedFileType);
1923
+ }
2016
1924
 
2017
- return _objectSpread$2(_objectSpread$2({}, a), {}, _defineProperty({}, name, fieldValue));
2018
- }, initialValue);
2019
- return fieldList;
1925
+ return parsedBinaryComponent;
2020
1926
  };
2021
1927
 
2022
- 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; }
2023
-
2024
- 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(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; }
2025
- /**
2026
- * Parses highlight timespans responses from the api into key/value object.
2027
- * The attributes can be targeted for each sub-type.
2028
- * @param {Object} highlightTimespanList - A list of timespans from the api response.
2029
- * @param {Object} options - Options which change how the timespans are parsed.
2030
- * @param {boolean} options.arrayOnSingle=true - Return an array if there is a single value.
2031
- * @param {string} options.joinValue - String to join the values, eg ','.
2032
- * @param {boolean} options.timespanAsList=false - Return timespans as list.
2033
- * @param {boolean} options.flat=false - Flatten to field-name/field-value (Note: field-values may be overwritten).
2034
- * @param {boolean} options.flatTimespan=false - Flatten timespan to object with start/end as key.
2035
- * @param {string} options.joinTimespan=_ - Character to join the start/end timecodes.
2036
- */
1928
+ var parseShapeType = function parseShapeType() {
1929
+ var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1930
+ var parsedShape = {};
1931
+ var containerComponent = shapeType.containerComponent,
1932
+ videoComponentList = shapeType.videoComponent,
1933
+ audioComponentList = shapeType.audioComponent,
1934
+ binaryComponentList = shapeType.binaryComponent,
1935
+ _shapeType$mimeType = shapeType.mimeType,
1936
+ mimeTypeList = _shapeType$mimeType === void 0 ? [] : _shapeType$mimeType,
1937
+ _shapeType$tag = shapeType.tag,
1938
+ tagList = _shapeType$tag === void 0 ? [] : _shapeType$tag;
2037
1939
 
2038
- var parseHighlightTimespanList = function parseHighlightTimespanList() {
2039
- var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2040
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2041
- var flat = opts.flat,
2042
- timespanAsList = opts.timespanAsList,
2043
- _opts$joinTimespan = opts.joinTimespan,
2044
- joinTimespan = _opts$joinTimespan === void 0 ? '_' : _opts$joinTimespan,
2045
- flatTimespan = opts.flatTimespan;
2046
- if (timespanAsList === true) return highlightTimespanList.map(function (timespan) {
2047
- return parseHighlightTimespan(timespan, opts);
2048
- });
2049
- if (flat === true || flatTimespan === true) return highlightTimespanList.reduce(function (a, timespan) {
2050
- return _objectSpread$1(_objectSpread$1({}, a), parseHighlightTimespan(timespan, opts));
2051
- }, {});
2052
- return highlightTimespanList.reduce(function (a, timespan) {
2053
- return _objectSpread$1(_objectSpread$1({}, a), {}, _defineProperty({}, [timespan.start, timespan.end].join(joinTimespan), parseHighlightTimespan(timespan, opts)));
2054
- }, {});
2055
- };
1940
+ var _tagList = _slicedToArray(tagList, 1);
2056
1941
 
2057
- function timeToCueTime(_ref) {
2058
- var _ref$hours = _ref.hours,
2059
- hours = _ref$hours === void 0 ? 0 : _ref$hours,
2060
- _ref$minutes = _ref.minutes,
2061
- minutes = _ref$minutes === void 0 ? 0 : _ref$minutes,
2062
- _ref$seconds = _ref.seconds,
2063
- seconds = _ref$seconds === void 0 ? 0 : _ref$seconds,
2064
- _ref$partialSeconds = _ref.partialSeconds,
2065
- partialSeconds = _ref$partialSeconds === void 0 ? 0 : _ref$partialSeconds;
2066
- var hourStr = hours.toFixed().padStart(2, '0');
2067
- var minStr = minutes.toFixed().padStart(2, '0');
2068
- var secondsStr = seconds.toFixed().padStart(2, '0');
2069
- var partialStr = (partialSeconds * 10).toFixed().padStart(3, '0');
2070
- return "".concat(hourStr, ":").concat(minStr, ":").concat(secondsStr, ".").concat(partialStr);
2071
- }
2072
- /**
2073
- * Convert subtitle groups to WebVtt subtitle format
2074
- * @param {Object} input={}
2075
- * @param {Object} input.metadataType - MetadataType response from API.
2076
- * @param {string} input.subtitleGroup=stl_subtitle - Name of group containing subtitle field/text.
2077
- * @param {string} input.subtitleField=stl_text - Name of field (text) to use for the subtitles.
2078
- * @returns {string} WebVtt subtitles
2079
- */
1942
+ parsedShape.tag = _tagList[0];
2080
1943
 
1944
+ var _mimeTypeList = _slicedToArray(mimeTypeList, 1);
2081
1945
 
2082
- function metadataTypeToWebVtt(_ref2) {
2083
- var metadataType = _ref2.metadataType,
2084
- _ref2$subtitleGroup = _ref2.subtitleGroup,
2085
- subtitleGroup = _ref2$subtitleGroup === void 0 ? 'stl_subtitle' : _ref2$subtitleGroup,
2086
- _ref2$subtitleField = _ref2.subtitleField,
2087
- subtitleField = _ref2$subtitleField === void 0 ? 'stl_text' : _ref2$subtitleField;
2088
- var parseOptions = {
2089
- includeTimespanAttributes: true,
2090
- flatTimespan: true,
2091
- flatGroup: true,
2092
- joinValue: ','
2093
- };
1946
+ parsedShape.mimeType = _mimeTypeList[0];
2094
1947
 
2095
- var _ref3 = metadataType || {},
2096
- _ref3$timespan = _ref3.timespan,
2097
- timespanList = _ref3$timespan === void 0 ? [] : _ref3$timespan;
1948
+ if (containerComponent) {
1949
+ var parsedContainerComponent = parseContainerComponent(containerComponent);
1950
+ parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedContainerComponent);
1951
+ }
2098
1952
 
2099
- if (timespanList.length === 0) return '';
2100
- var sortedTimespans = timespanList.sort(sortTimespanList);
2101
- var parsedTimespans = sortedTimespans.map(function (timespanType) {
2102
- return parseTimespan(timespanType, parseOptions);
2103
- });
2104
- var vttCues = parsedTimespans.map(function (thisTimespan) {
2105
- var startText = thisTimespan.start,
2106
- endText = thisTimespan.end,
2107
- _thisTimespan$subtitl = thisTimespan[subtitleGroup];
2108
- _thisTimespan$subtitl = _thisTimespan$subtitl === void 0 ? {} : _thisTimespan$subtitl;
2109
- var text = _thisTimespan$subtitl[subtitleField];
2110
- if (!text) return '';
2111
- var startTime = formatTimeCodeText(startText).toTime();
2112
- var start = timeToCueTime(startTime);
2113
- var endTime = formatTimeCodeText(endText).toTime();
2114
- var end = timeToCueTime(endTime);
2115
- return "".concat(start, " --> ").concat(end, " line:0%\r").concat(text, "\r");
2116
- });
2117
- return "WEBVTT\n\n\n".concat(vttCues.join('\n'));
2118
- }
1953
+ if (videoComponentList) {
1954
+ var _videoComponentList = _slicedToArray(videoComponentList, 1),
1955
+ videoComponent = _videoComponentList[0];
2119
1956
 
2120
- var createFacetType = function createFacetType() {
2121
- var fieldList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2122
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2123
- return fieldList.map(function (field) {
2124
- return {
2125
- field: field,
2126
- name: field,
2127
- count: options.count || true,
2128
- exclude: fieldList
2129
- };
2130
- });
2131
- };
1957
+ var parsedVideoComponent = parseVideoComponent(videoComponent);
1958
+ parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedVideoComponent);
1959
+ }
2132
1960
 
2133
- 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; }
1961
+ if (audioComponentList) {
1962
+ var _audioComponentList = _slicedToArray(audioComponentList, 1),
1963
+ audioComponent = _audioComponentList[0];
2134
1964
 
2135
- 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(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; }
1965
+ var parsedAudioComponent = parseAudioComponent(audioComponent);
1966
+ parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedAudioComponent);
1967
+ }
2136
1968
 
2137
- var parseFacetType = function parseFacetType() {
2138
- var facetType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2139
- var output = {};
1969
+ if (binaryComponentList) {
1970
+ var _binaryComponentList = _slicedToArray(binaryComponentList, 1),
1971
+ binaryComponent = _binaryComponentList[0];
2140
1972
 
2141
- var facetFieldReducer = function facetFieldReducer(a, _ref) {
2142
- var fieldValue = _ref.fieldValue,
2143
- value = _ref.value;
2144
- return _objectSpread(_objectSpread({}, a), {}, _defineProperty({}, fieldValue, value));
2145
- };
1973
+ var parsedBinaryComponent = parseBinaryComponent(binaryComponent);
1974
+ parsedShape = _objectSpread(_objectSpread({}, parsedShape), parsedBinaryComponent);
1975
+ }
2146
1976
 
2147
- facetType.forEach(function (_ref2) {
2148
- var name = _ref2.name,
2149
- field = _ref2.field,
2150
- count = _ref2.count;
2151
- output[name || field] = count.reduce(facetFieldReducer, {});
2152
- });
2153
- return output;
1977
+ return parsedShape;
2154
1978
  };
2155
1979
 
2156
1980
  var IMAGE_MIME_TYPES = ['image/apng', 'image/bmp', 'image/gif', 'image/jpeg', 'image/x-icon', 'image/png', 'image/svg+xml'];
@@ -2282,5 +2106,200 @@ var findNearestThumbnail = function findNearestThumbnail(itemType, timeCodeText)
2282
2106
  return srcList[nearestSrcIndex];
2283
2107
  };
2284
2108
 
2109
+ var parseNowDate = function parseNowDate() {
2110
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NOW';
2111
+
2112
+ if (value.startsWith('NOW')) {
2113
+ if (value === 'NOW') return new Date();
2114
+ var sign = value[3];
2115
+ var number = Number(value.match(/(\d+)/)[0]);
2116
+ var unit = value.match(/(\d.*)/)[0].replace(/\d/g, '');
2117
+ var nowDiff = new Date();
2118
+
2119
+ switch (unit) {
2120
+ case 'HOUR':
2121
+ case 'HOURS':
2122
+ if (sign === '+') nowDiff.setHours(nowDiff.getHours() + number);
2123
+ if (sign === '-') nowDiff.setHours(nowDiff.getHours() - number);
2124
+ break;
2125
+
2126
+ case 'DAY':
2127
+ case 'DAYS':
2128
+ if (sign === '+') nowDiff.setDate(nowDiff.getDate() + number);
2129
+ if (sign === '-') nowDiff.setDate(nowDiff.getDate() - number);
2130
+ break;
2131
+
2132
+ case 'MONTH':
2133
+ case 'MONTHS':
2134
+ if (sign === '+') nowDiff.setMonth(nowDiff.getMonth() + number);
2135
+ if (sign === '-') nowDiff.setMonth(nowDiff.getMonth() - number);
2136
+ break;
2137
+
2138
+ case 'YEAR':
2139
+ case 'YEARS':
2140
+ if (sign === '+') nowDiff.setFullYear(nowDiff.getFullYear() + number);
2141
+ if (sign === '-') nowDiff.setFullYear(nowDiff.getFullYear() - number);
2142
+ break;
2143
+ }
2144
+
2145
+ return nowDiff;
2146
+ }
2147
+
2148
+ return new Date(value);
2149
+ };
2150
+
2151
+ var _excluded = ["Codec"],
2152
+ _excluded2 = ["Codec"];
2153
+
2154
+ var parseMediaConvertPreset = function parseMediaConvertPreset(transcodePresetType) {
2155
+ var output = {};
2156
+ var description = transcodePresetType.description,
2157
+ _transcodePresetType$ = transcodePresetType.mediaconvert;
2158
+ _transcodePresetType$ = _transcodePresetType$ === void 0 ? {} : _transcodePresetType$;
2159
+ var _transcodePresetType$2 = _transcodePresetType$.outputSetting,
2160
+ outputSetting = _transcodePresetType$2 === void 0 ? [] : _transcodePresetType$2;
2161
+ output.description = description;
2162
+ if (outputSetting.length === 0) return output;
2163
+ var mc = JSON.parse(outputSetting[0]);
2164
+ var _mc$Settings = mc.Settings;
2165
+ _mc$Settings = _mc$Settings === void 0 ? {} : _mc$Settings;
2166
+ var ContainerSettings = _mc$Settings.ContainerSettings,
2167
+ VideoDescription = _mc$Settings.VideoDescription,
2168
+ AudioDescriptions = _mc$Settings.AudioDescriptions;
2169
+ output.containerFormat = ContainerSettings.Container;
2170
+
2171
+ if (ContainerSettings) {
2172
+ output.containerFormat = ContainerSettings.Container;
2173
+ }
2174
+
2175
+ if (VideoDescription) {
2176
+ var _VideoDescription$Cod = VideoDescription.CodecSettings,
2177
+ CodecSettings = _VideoDescription$Cod === void 0 ? {} : _VideoDescription$Cod;
2178
+
2179
+ var Codec = CodecSettings.Codec,
2180
+ otherSettings = _objectWithoutProperties(CodecSettings, _excluded);
2181
+
2182
+ output.videoFormat = Codec;
2183
+ var height = VideoDescription.Height,
2184
+ width = VideoDescription.Width;
2185
+ output.height = height;
2186
+ output.width = width;
2187
+
2188
+ if (height && width) {
2189
+ output.dimension = "".concat(width, "x").concat(height);
2190
+ output.aspectRatio = parseAspectRatio({
2191
+ height: height,
2192
+ width: width
2193
+ });
2194
+ }
2195
+
2196
+ var _Object$values = Object.values(otherSettings),
2197
+ _Object$values2 = _slicedToArray(_Object$values, 1),
2198
+ codecSpecs = _Object$values2[0];
2199
+
2200
+ if (codecSpecs) {
2201
+ output.fieldOrder = codecSpecs.InterlaceMode;
2202
+ if (output.fieldOrder && output.fieldOrder.includes('TOP')) output.fieldOrder = 'interlaced';
2203
+ output.videoBitrate = codecSpecs.Bitrate;
2204
+ var numerator = codecSpecs.FramerateDenominator; // other way round to vs ¯\_(ツ)_/¯
2205
+
2206
+ var denominator = codecSpecs.FramerateNumerator;
2207
+ var timeBase = formatTimeBaseType({
2208
+ denominator: denominator,
2209
+ numerator: numerator
2210
+ });
2211
+ output.timeBase = timeBase;
2212
+ output.frameRate = timeBase.toRate(true);
2213
+ }
2214
+ }
2215
+
2216
+ if (AudioDescriptions && AudioDescriptions.length > 0) {
2217
+ var _AudioDescriptions$0$ = AudioDescriptions[0].CodecSettings,
2218
+ _CodecSettings = _AudioDescriptions$0$ === void 0 ? {} : _AudioDescriptions$0$;
2219
+
2220
+ var _Codec = _CodecSettings.Codec,
2221
+ _otherSettings = _objectWithoutProperties(_CodecSettings, _excluded2);
2222
+
2223
+ output.audioFormat = _Codec;
2224
+
2225
+ var _Object$values3 = Object.values(_otherSettings),
2226
+ _Object$values4 = _slicedToArray(_Object$values3, 1),
2227
+ _codecSpecs = _Object$values4[0];
2228
+
2229
+ if (_codecSpecs) {
2230
+ output.audioSamplerate = _codecSpecs.SampleRate;
2231
+ output.audioBitrate = _codecSpecs.Bitrate;
2232
+ output.audioBitRateMode = _codecSpecs.RateControlMode;
2233
+ }
2234
+ }
2235
+
2236
+ return output;
2237
+ };
2238
+
2239
+ var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
2240
+ var output = {};
2241
+ var description = transcodePresetType.description,
2242
+ format = transcodePresetType.format,
2243
+ audio = transcodePresetType.audio,
2244
+ video = transcodePresetType.video,
2245
+ mediaconvert = transcodePresetType.mediaconvert;
2246
+ if (mediaconvert) return parseMediaConvertPreset(transcodePresetType);
2247
+ output.description = description;
2248
+ output.containerFormat = format;
2249
+
2250
+ if (video) {
2251
+ output.videoFormat = video.codec;
2252
+ output.videoBitrate = video.bitrate;
2253
+
2254
+ if (video.framerate) {
2255
+ var timeBase = formatTimeBaseType(video.framerate);
2256
+ output.timeBase = timeBase;
2257
+ output.frameRate = timeBase.toRate(true);
2258
+ }
2259
+
2260
+ if (video.scaling) {
2261
+ var _video$scaling = video.scaling,
2262
+ height = _video$scaling.height,
2263
+ width = _video$scaling.width;
2264
+ output.height = height;
2265
+ output.width = width;
2266
+
2267
+ if (height && width) {
2268
+ output.dimension = "".concat(width, "x").concat(height);
2269
+ output.aspectRatio = parseAspectRatio({
2270
+ height: height,
2271
+ width: width
2272
+ });
2273
+ }
2274
+ }
2275
+ }
2276
+
2277
+ if (audio) {
2278
+ var audioFormat = audio.codec,
2279
+ channel = audio.channel;
2280
+ output.audioFormat = audioFormat;
2281
+ if (channel) output.audioChannels = channel.length;
2282
+ }
2283
+
2284
+ return output;
2285
+ };
2286
+
2287
+ var PDF = 'PDF';
2288
+ var TEXT = 'TEXT';
2289
+ var MSWORD = 'MSWORD';
2290
+ var JSON$1 = 'JSON';
2291
+ var XML = 'XML';
2292
+ var getDocumentType = function getDocumentType() {
2293
+ var shape = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2294
+ var mimeType = shape.mimeType;
2295
+ if (!mimeType) return undefined;
2296
+ if (mimeType.endsWith('/pdf')) return PDF;
2297
+ if (mimeType.startsWith('text/')) return TEXT;
2298
+ if (mimeType.endsWith('/msword')) return MSWORD;
2299
+ if (mimeType.endsWith('/json')) return JSON$1;
2300
+ if (mimeType.endsWith('/xml')) return XML;
2301
+ return undefined;
2302
+ };
2303
+
2285
2304
  export { TimeBase, TimeCode, createFacetType, createMetadataType, filterShapeSource, findNearestThumbnail, formatSeconds, formatSecondsPrecise, formatSmpte, formatTimeBase, formatTimeBaseText, formatTimeBaseType, formatTimeCodeText, formatTimeCodeType, getDocumentType, getShapeMediaType, metadataTypeToWebVtt, parseAspectRatio, parseAudioComponent, parseBaseMediaInfoType, parseBinaryComponent, parseContainerComponent, parseFacetType, parseFileType, parseHighlightTimespan, parseHighlightTimespanList, parseKeyValuePairType, parseMediaConvertPreset, parseMetadataType, parseNowDate, parseShapeType, parseSimpleMetadataType, parseTimespan, parseTimespanList, parseTranscodePreset, parseVideoComponent, roles };
2286
2305
  //# sourceMappingURL=index.es.js.map