'use strict';

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /**
                                                                                                                                                                                                                                                                   * Created by geweimin on 17/5/2.
                                                                                                                                                                                                                                                                   */


var _StringUtils = require('./StringUtils');

var getMappings = exports.getMappings = function getMappings(modalInputData, props) {
  var mappingFields = null;
  if (!modalInputData.actionLinkMappings) {
    if (modalInputData.mappingsList) {
      mappingFields = modalInputData.mappingsList[0].mappings;
    } else {
      mappingFields = modalInputData.mappings;
    }
  } else {
    (function () {
      /* eslint-disable */
      var i = 0;
      var matchRes = modalInputData.actionLink.match(_StringUtils.templateReg);
      var templateField = matchRes && matchRes[0].substring(2, matchRes[0].length - 1);
      modalInputData.actionLinkMappings.forEach(function (item, index) {
        if (item.dictionaryItemName === _extends({}, props.form.getFieldsValue(), props.query)[templateField]) {
          i = index;
        }
      });
      mappingFields = modalInputData.mappingsList[i].mappings;
    })();
  }
  return mappingFields;
};