'use strict';

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

var _defineProperty2 = require('babel-runtime/helpers/defineProperty');

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _isInterestingField;

var _reselect = require('reselect');

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

var _field_analysis2 = _interopRequireDefault(_field_analysis);

var _constants = require('../constants');

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

var isInterestingField = (_isInterestingField = {}, (0, _defineProperty3.default)(_isInterestingField, _constants.FIELD_TYPE_STRING, true), (0, _defineProperty3.default)(_isInterestingField, _constants.FIELD_TYPE_BOOLEAN, true), (0, _defineProperty3.default)(_isInterestingField, _constants.FIELD_TYPE_NUMBER, true), (0, _defineProperty3.default)(_isInterestingField, _constants.FIELD_TYPE_DATE, true), (0, _defineProperty3.default)(_isInterestingField, _constants.FIELD_TYPE_MIXED, true), _isInterestingField);

var getVisibleFields = (0, _reselect.createSelector)(function (state) {
  return state.visibleFields && state.visibleFields.length && state.visibleFields;
}, _field_analysis2.default, function (visibleFields, fieldAnalysis) {
  if (visibleFields) return visibleFields;
  visibleFields = [];
  for (var fieldname in fieldAnalysis.properties) {
    var fieldType = fieldAnalysis.properties[fieldname].type;
    if (isInterestingField[fieldType]) visibleFields.push(fieldname);
  }
  return visibleFields;
});

exports.default = getVisibleFields;
//# sourceMappingURL=visible_fields.js.map