"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTaskFile = exports.buildTaskFileFieldname = exports.approximateIntroOutroAdditionalSize = void 0;
const tslib_1 = require("tslib");
const extra_utils_1 = require("../../shared/extra-utils");
function buildTaskFileFieldname(indice, fieldName = 'file') {
    return `tasks[${indice}][options][${fieldName}]`;
}
exports.buildTaskFileFieldname = buildTaskFileFieldname;
function getTaskFile(files, indice, fieldName = 'file') {
    return files.find(f => f.fieldname === buildTaskFileFieldname(indice, fieldName));
}
exports.getTaskFile = getTaskFile;
function approximateIntroOutroAdditionalSize(video, tasks, fileFinder) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        let additionalDuration = 0;
        for (let i = 0; i < tasks.length; i++) {
            const task = tasks[i];
            if (task.name !== 'add-intro' && task.name !== 'add-outro')
                continue;
            const filePath = fileFinder(i);
            additionalDuration += yield (0, extra_utils_1.getVideoStreamDuration)(filePath);
        }
        return (video.getMaxQualityFile().size / video.duration) * additionalDuration;
    });
}
exports.approximateIntroOutroAdditionalSize = approximateIntroOutroAdditionalSize;
//# sourceMappingURL=video-studio.js.map