"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.isBuildSchemeSupported = void 0;var _deepmerge = _interopRequireDefault(require("deepmerge"));
var _logger = require("../systemManager/logger");
var _prompt = require("../../cli/prompt");function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { "default": obj };}function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {try {var info = gen[key](arg);var value = info.value;} catch (error) {reject(error);return;}if (info.done) {resolve(value);} else {Promise.resolve(value).then(_next, _throw);}}function _asyncToGenerator(fn) {return function () {var self = this,args = arguments;return new Promise(function (resolve, reject) {var gen = fn.apply(self, args);function _next(value) {asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);}function _throw(err) {asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);}_next(undefined);});};}

var isBuildSchemeSupported = /*#__PURE__*/function () {var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(c) {var _c$buildConfig$common, _c$buildConfig$platfo, _c$buildConfig$platfo2;var scheme, baseBuildSchemes, platformBuildSchemes, buildSchemes, schemeDoesNotExist, schemeOptions, schemeVals, _yield$inquirerPrompt, selectedScheme;return regeneratorRuntime.wrap(function _callee$(_context) {while (1) {switch (_context.prev = _context.next) {case 0:
            (0, _logger.logTask)('isBuildSchemeSupported');

            scheme = c.program.scheme;

            if (!c.buildConfig.platforms[c.platform]) {
              c.buildConfig.platforms[c.platform] = {};
            }

            baseBuildSchemes = ((_c$buildConfig$common = c.buildConfig.common) === null || _c$buildConfig$common === void 0 ? void 0 : _c$buildConfig$common.buildSchemes) || {};
            platformBuildSchemes = ((_c$buildConfig$platfo = c.buildConfig.platforms) === null || _c$buildConfig$platfo === void 0 ? void 0 : (_c$buildConfig$platfo2 = _c$buildConfig$platfo[c.platform]) === null || _c$buildConfig$platfo2 === void 0 ? void 0 : _c$buildConfig$platfo2.buildSchemes) || {};

            buildSchemes = (0, _deepmerge["default"])(baseBuildSchemes, platformBuildSchemes);if (

            buildSchemes) {_context.next = 9;break;}
            (0, _logger.logWarning)("Your appConfig for platform ".concat(

            c.platform, " has no buildSchemes. Will continue with defaults"));return _context.abrupt("return",


            false);case 9:


            schemeDoesNotExist = scheme && !buildSchemes[scheme];if (!(
            scheme === true || schemeDoesNotExist)) {_context.next = 21;break;}
            if (schemeDoesNotExist && scheme && scheme !== true) {
              (0, _logger.logError)('Build scheme you picked does not exists.');
            }
            // const opts = generateOptions(buildSchemes);
            schemeOptions = [];
            schemeVals = {};
            Object.keys(buildSchemes).forEach(function (k) {
              var s = buildSchemes[k];
              var desc = s.description ? (0, _logger.chalk)().grey(" (".concat(s.description, ")")) : '';
              var key = "".concat(k).concat(desc);
              schemeOptions.push(key);
              schemeVals[key] = k;
            });_context.next = 17;return (

              (0, _prompt.inquirerPrompt)({
                name: 'selectedScheme',
                type: 'list',
                message: 'Pick one of available buildSchemes',
                choices: schemeOptions,
                logMessage: 'You need to specify scheme' }));case 17:_yield$inquirerPrompt = _context.sent;selectedScheme = _yield$inquirerPrompt.selectedScheme;


            c.program.scheme = schemeVals[selectedScheme];
            c.runtime.scheme = c.program.scheme;case 21:

            (0, _logger.logInfo)("Current Build Scheme: ".concat((0, _logger.chalk)().bold.white(
            c.runtime.scheme)));return _context.abrupt("return",

            true);case 23:case "end":return _context.stop();}}}, _callee);}));return function isBuildSchemeSupported(_x) {return _ref.apply(this, arguments);};}();exports.isBuildSchemeSupported = isBuildSchemeSupported;
//# sourceMappingURL=schemeParser.js.map