'use strict';

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

var _reselect = require('reselect');

var _field_analysis = require('./field_analysis');

var _field_analysis2 = _interopRequireDefault(_field_analysis);

var _field_mapping = require('./field_mapping');

var _field_mapping2 = _interopRequireDefault(_field_mapping);

var _config = require('../../config.json');

var _config2 = _interopRequireDefault(_config);

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

var getColorIndex = (0, _reselect.createSelector)(_field_mapping2.default, _field_analysis2.default, function (fieldMapping, fieldAnalysis) {
  if (!fieldMapping.color) return {};
  var coloredField = fieldAnalysis.properties[fieldMapping.color];
  var colorIndex = {};
  if (!coloredField || !coloredField.values) return colorIndex;
  var values = coloredField.values.map(function (v) {
    return v.value;
  });
  values.forEach(function (v, i) {
    colorIndex[v] = _config2.default.colors[i] || _config2.default.defaultColor;
  });
  return colorIndex;
});

exports.default = getColorIndex;
//# sourceMappingURL=color_index.js.map