"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class LiveSyncProcessDataService {
    constructor() {
        this.processes = {};
    }
    persistData(projectDir, deviceDescriptors, platforms) {
        this.processes[projectDir] = this.processes[projectDir] || Object.create(null);
        this.processes[projectDir].actionsChain = this.processes[projectDir].actionsChain || Promise.resolve();
        this.processes[projectDir].currentSyncAction = this.processes[projectDir].actionsChain;
        this.processes[projectDir].isStopped = false;
        this.processes[projectDir].platforms = platforms;
        const currentDeviceDescriptors = this.getDeviceDescriptors(projectDir);
        this.processes[projectDir].deviceDescriptors = _.uniqBy(currentDeviceDescriptors.concat(deviceDescriptors), "identifier");
    }
    getPersistedData(projectDir) {
        return this.processes[projectDir];
    }
    getDeviceDescriptors(projectDir) {
        const liveSyncProcessesInfo = this.processes[projectDir] || {};
        const currentDescriptors = liveSyncProcessesInfo.deviceDescriptors;
        return currentDescriptors || [];
    }
    hasDeviceDescriptors(projectDir) {
        const deviceDescriptors = this.getDeviceDescriptors(projectDir);
        return !!deviceDescriptors.length;
    }
    getAllPersistedData() {
        return this.processes;
    }
}
exports.LiveSyncProcessDataService = LiveSyncProcessDataService;
$injector.register("liveSyncProcessDataService", LiveSyncProcessDataService);
