"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.ConnectedReportViewerPage = void 0;

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

var _immutable = _interopRequireDefault(require("immutable"));

var _qs = _interopRequireDefault(require("qs"));

var _ReportViewerPage = _interopRequireDefault(require("../../components/pages/ReportViewerPage"));

var _withConfig = _interopRequireDefault(require("../../enhancers/withConfig"));

var _report = require("../../actions/report");

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

const mapDispatchToProps = (dispatch, ownProps) => ({
  readContent: (location, match) => {
    const queryParams = _qs.default.parse(location.search, {
      ignoreQueryPrefix: true
    });

    const {
      params: paramsJson,
      ...invocationDescriptorObject
    } = queryParams;
    const params = paramsJson && JSON.parse(paramsJson);

    const invocationDescriptor = _immutable.default.fromJS(invocationDescriptorObject);

    return dispatch((0, _report.invoke)(ownProps.config, match.params.reportCsid, invocationDescriptor, params));
  }
});

const ConnectedReportViewerPage = (0, _reactRedux.connect)(undefined, mapDispatchToProps)(_ReportViewerPage.default);
exports.ConnectedReportViewerPage = ConnectedReportViewerPage;

var _default = (0, _withConfig.default)(ConnectedReportViewerPage);

exports.default = _default;