"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

function _defineProperty2() {
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

  _defineProperty2 = function () {
    return data;
  };

  return data;
}

function _ramda() {
  const data = _interopRequireDefault(require("ramda"));

  _ramda = function () {
    return data;
  };

  return data;
}

function _chalk() {
  const data = _interopRequireDefault(require("chalk"));

  _chalk = function () {
    return data;
  };

  return data;
}

function _consumer() {
  const data = require("../../../api/consumer");

  _consumer = function () {
    return data;
  };

  return data;
}

function _command() {
  const data = _interopRequireDefault(require("../../command"));

  _command = function () {
    return data;
  };

  return data;
}

class Undeprecate extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'undeprecate <ids...>');
    (0, _defineProperty2().default)(this, "description", 'undeprecate a deprecated component (local/remote)');
    (0, _defineProperty2().default)(this, "alias", '');
    (0, _defineProperty2().default)(this, "opts", [['r', 'remote [boolean]', 'undeprecate a component from a remote scope']]);
    (0, _defineProperty2().default)(this, "loader", true);
    (0, _defineProperty2().default)(this, "migration", true);
  }

  action([ids], {
    remote = false
  }) {
    return (0, _consumer().undeprecate)({
      ids,
      remote
    });
  }

  report(deprecationResult) {
    const paintMissingComponents = missingComponents => !_ramda().default.isEmpty(missingComponents) ? _chalk().default.underline('missing components:') + (0, _chalk().default)(` ${missingComponents.join(', ')}\n`) : '';

    const paintRemoved = bitIds => !_ramda().default.isEmpty(bitIds) && !_ramda().default.isNil(bitIds) ? _chalk().default.underline('undeprecated components:') + (0, _chalk().default)(` ${bitIds.join(', ')}\n`) : '';

    const paintSingle = obj => paintRemoved(obj.bitIds) + paintMissingComponents(obj.missingComponents);

    const paintMany = deprecationResults => deprecationResults.map(obj => paintSingle(obj)).join('\n');

    return Array.isArray(deprecationResult) ? paintMany(deprecationResult) : paintSingle(deprecationResult);
  }

}

exports.default = Undeprecate;