'use strict';

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

var _reactRedux = require('react-redux');

var _omit = require('lodash/omit');

var _omit2 = _interopRequireDefault(_omit);

var _action_creators = require('../action_creators');

var _general_helpers = require('../util/general_helpers');

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

var _field_analysis2 = _interopRequireDefault(_field_analysis);

var _filterable_features = require('../selectors/filterable_features');

var _filterable_features2 = _interopRequireDefault(_filterable_features);

var _features_by_id = require('../selectors/features_by_id');

var _features_by_id2 = _interopRequireDefault(_features_by_id);

var _filtered_features = require('../selectors/filtered_features');

var _filtered_features2 = _interopRequireDefault(_filtered_features);

var _mapbox_filter = require('../selectors/mapbox_filter');

var _mapbox_filter2 = _interopRequireDefault(_mapbox_filter);

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

var _field_mapping2 = _interopRequireDefault(_field_mapping);

var _color_index = require('../selectors/color_index');

var _color_index2 = _interopRequireDefault(_color_index);

var _visible_fields = require('../selectors/visible_fields');

var _visible_fields2 = _interopRequireDefault(_visible_fields);

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

var ViewContainer = function ViewContainer(props) {
  return (0, _general_helpers.createElement)(props.component, (0, _omit2.default)(props, 'component'), props.children);
};

function mapStateToProps(state, ownProps) {
  var component = ownProps.component;
  return {
    children: component.props && component.props.children,
    viewState: state.viewStates[component.MfViewId],
    willPrint: state.print.willPrint,
    paperSize: state.print.paperSize,
    center: state.mapPosition.center,
    zoom: state.mapPosition.zoom,
    mapStyle: state.mapStyle,
    settings: state.settings,
    features: (0, _filterable_features2.default)(state),
    featuresById: (0, _features_by_id2.default)(state),
    fieldAnalysis: (0, _field_analysis2.default)(state),
    fieldOrder: state.fieldOrder,
    filter: (0, _mapbox_filter2.default)(state),
    filteredFeatures: (0, _filtered_features2.default)(state),
    fieldMapping: (0, _field_mapping2.default)(state),
    colorIndex: (0, _color_index2.default)(state),
    visibleFields: (0, _visible_fields2.default)(state)
  };
}

exports.default = (0, _reactRedux.connect)(mapStateToProps, function (dispatch, ownProps) {
  return {
    moveMap: function moveMap(payload) {
      return dispatch((0, _action_creators.moveMap)(payload));
    },
    showFeatureDetail: function showFeatureDetail(payload) {
      return dispatch((0, _action_creators.showFeatureDetail)(payload));
    },
    requestPrint: function requestPrint(payload) {
      return dispatch((0, _action_creators.requestPrint)(payload));
    },
    openSettings: function openSettings(payload) {
      return dispatch((0, _action_creators.openSettings)(payload));
    },
    updateViewState: function updateViewState(viewState) {
      return dispatch((0, _action_creators.updateViewState)({ id: ownProps.component.MfViewId, state: viewState }));
    }
  };
})(ViewContainer);
//# sourceMappingURL=ViewContainer.js.map