'use strict';

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

var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

exports.getLanguages = getLanguages;
exports.getKeywords = getKeywords;

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

var _gherkin = require('gherkin');

var _gherkin2 = _interopRequireDefault(_gherkin);

var _cliTable = require('cli-table');

var _cliTable2 = _interopRequireDefault(_cliTable);

var _titleCase = require('title-case');

var _titleCase2 = _interopRequireDefault(_titleCase);

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

var keywords = ['feature', 'background', 'scenario', 'scenarioOutline', 'examples', 'given', 'when', 'then', 'and', 'but'];

function getAsTable(header, rows) {
  var table = new _cliTable2.default({
    chars: {
      bottom: '',
      'bottom-left': '',
      'bottom-mid': '',
      'bottom-right': '',
      left: '',
      'left-mid': '',
      mid: '',
      'mid-mid': '',
      middle: ' | ',
      right: '',
      'right-mid': '',
      top: '',
      'top-left': '',
      'top-mid': '',
      'top-right': ''
    },
    style: {
      border: [],
      'padding-left': 0,
      'padding-right': 0
    }
  });
  table.push(header);
  table.push.apply(table, (0, _toConsumableArray3.default)(rows));
  return table.toString();
}

function getLanguages() {
  var rows = _lodash2.default.map(_gherkin2.default.DIALECTS, function (data, isoCode) {
    return [isoCode, data.name, data.native];
  });
  return getAsTable(['ISO 639-1', 'ENGLISH NAME', 'NATIVE NAME'], rows);
}

function getKeywords(isoCode) {
  var language = _gherkin2.default.DIALECTS[isoCode];
  var rows = _lodash2.default.map(keywords, function (keyword) {
    var words = _lodash2.default.map(language[keyword], function (s) {
      return '"' + s + '"';
    }).join(', ');
    return [(0, _titleCase2.default)(keyword), words];
  });
  return getAsTable(['ENGLISH KEYWORD', 'NATIVE KEYWORDS'], rows);
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 4184 characters]