import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import { createElement } from "../../utils";
import { set } from 'dot-prop-immutable';
export var handleElementSetting = function handleElementSetting(element, data) {
  var _data$formSettings = data.formSettings,
      formSettings = _data$formSettings === void 0 ? {} : _data$formSettings,
      _data$formItemSetting = data.formItemSettings,
      formItemSettings = _data$formItemSetting === void 0 ? {} : _data$formItemSetting,
      _data$settings = data.settings,
      settings = _data$settings === void 0 ? {} : _data$settings;
  element.data.formSettings = _objectSpread(_objectSpread({}, element.data.formSettings), formSettings);
  element.data.formItemSettings = _objectSpread(_objectSpread({}, element.data.formItemSettings), formItemSettings);
  element.data.settings = _objectSpread(_objectSpread({}, element.data.settings), settings);
};
export var createColumnsFormTpl = function createColumnsFormTpl(datas, formContainer) {
  datas.forEach(function (items) {
    if (items && Array.isArray(items) && items.length > 0) {
      var cols = {
        span: 24,
        offset: 0
      };
      cols.span = Math.floor(24 / items.length);
      items.map(function (v) {
        var type = v.type,
            _v$data = v.data,
            data = _v$data === void 0 ? {} : _v$data;

        if (type !== 'buttons') {
          var element = createElement(type, {});
          handleElementSetting(element, data);
          element = set(element, 'data.settings.cols', cols);
          formContainer.elements.push(element);
        } else {
          var _v$group = v.group,
              group = _v$group === void 0 ? [] : _v$group;
          group.forEach(function (btn) {
            var element = createElement(btn.type, {});
            handleElementSetting(element, btn.data);
            element = set(element, 'data.settings.cols', {
              span: 2
            });
            formContainer.elements.push(element);
          });
        }
      });
    }
  });
  return formContainer;
};
//# sourceMappingURL=util.js.map