"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments)).next());
    });
};
class EmulateCommandBase {
    constructor($options, $projectData, $logger, $platformService) {
        this.$options = $options;
        this.$projectData = $projectData;
        this.$logger = $logger;
        this.$platformService = $platformService;
        this.$projectData.initializeProjectData();
    }
    executeCore(args) {
        return __awaiter(this, void 0, void 0, function* () {
            this.$logger.warn(`Emulate command is deprecated and will soon be removed. Please use "tns run <platform>" instead. All options available for "tns emulate" are present in "tns run" command. To run on all available emulators, use "tns run <platform> --emulator".`);
            this.$options.emulator = true;
            const appFilesUpdaterOptions = { bundle: this.$options.bundle, release: this.$options.release };
            const emulateOptions = {
                avd: this.$options.avd,
                clean: this.$options.clean,
                device: this.$options.device,
                release: this.$options.release,
                emulator: this.$options.emulator,
                projectDir: this.$options.path,
                justlaunch: this.$options.justlaunch,
                availableDevices: this.$options.availableDevices,
                platformTemplate: this.$options.platformTemplate,
                provision: this.$options.provision,
                teamId: this.$options.teamId,
                keyStoreAlias: this.$options.keyStoreAlias,
                keyStoreAliasPassword: this.$options.keyStoreAliasPassword,
                keyStorePassword: this.$options.keyStorePassword,
                keyStorePath: this.$options.keyStorePath
            };
            return this.$platformService.emulatePlatform(args[0], appFilesUpdaterOptions, emulateOptions, this.$projectData, this.$options);
        });
    }
}
exports.EmulateCommandBase = EmulateCommandBase;
class EmulateIosCommand extends EmulateCommandBase {
    constructor($options, $projectData, $logger, $platformService, $platformsData) {
        super($options, $projectData, $logger, $platformService);
        this.$platformsData = $platformsData;
        this.allowedParameters = [];
    }
    execute(args) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.executeCore([this.$platformsData.availablePlatforms.iOS]);
        });
    }
}
exports.EmulateIosCommand = EmulateIosCommand;
$injector.registerCommand("emulate|ios", EmulateIosCommand);
class EmulateAndroidCommand extends EmulateCommandBase {
    constructor($options, $projectData, $logger, $platformService, $platformsData) {
        super($options, $projectData, $logger, $platformService);
        this.$platformsData = $platformsData;
        this.allowedParameters = [];
    }
    execute(args) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.executeCore([this.$platformsData.availablePlatforms.Android]);
        });
    }
}
exports.EmulateAndroidCommand = EmulateAndroidCommand;
$injector.registerCommand("emulate|android", EmulateAndroidCommand);
