'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _regenerator;

function _load_regenerator() {
  return _regenerator = _interopRequireDefault(require('babel-runtime/regenerator'));
}

var _bluebird;

function _load_bluebird() {
  return _bluebird = require('bluebird');
}

var _consumer;

function _load_consumer() {
  return _consumer = require('../../../consumer');
}

var _loader;

function _load_loader() {
  return _loader = _interopRequireDefault(require('../../../cli/loader'));
}

var _loaderMessages;

function _load_loaderMessages() {
  return _loaderMessages = require('../../../cli/loader/loader-messages');
}

var _bitId;

function _load_bitId() {
  return _bitId = require('../../../bit-id');
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

exports.default = function () {
  var _ref = (0, (_bluebird || _load_bluebird()).coroutine)( /*#__PURE__*/(_regenerator || _load_regenerator()).default.mark(function _callee(_ref2) {
    var ids = _ref2.ids,
        remote = _ref2.remote;
    var consumer, bitIds;
    return (_regenerator || _load_regenerator()).default.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            if (remote) (_loader || _load_loader()).default.start((_loaderMessages || _load_loaderMessages()).BEFORE_REMOTE_DEPRECATE);
            _context.next = 3;
            return (0, (_consumer || _load_consumer()).loadConsumer)();

          case 3:
            consumer = _context.sent;
            bitIds = ids.map(function (id) {
              return remote ? (_bitId || _load_bitId()).BitId.parse(id, true) : consumer.getParsedId(id);
            });
            return _context.abrupt('return', consumer.deprecate(bitIds, remote));

          case 6:
          case 'end':
            return _context.stop();
        }
      }
    }, _callee, this);
  }));

  function deprecate(_x) {
    return _ref.apply(this, arguments);
  }

  return deprecate;
}();