"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ItemInfo = void 0;
var _ui = require("../../ui");
var _xeUtils = _interopRequireDefault(require("xe-utils"));
var _log = require("../../ui/src/log");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var _createComponentLog = (0, _log.createComponentLog)('form'),
  errLog = _createComponentLog.errLog;
var ItemInfo = exports.ItemInfo = /*#__PURE__*/function () {
  function ItemInfo($xeForm, item) {
    _classCallCheck(this, ItemInfo);
    var field = item.field,
      itemRender = item.itemRender,
      formatter = item.formatter;
    if (formatter) {
      if (_xeUtils.default.isString(formatter)) {
        var gFormatOpts = _ui.formats.get(formatter);
        if (!gFormatOpts || !gFormatOpts.formItemFormatMethod) {
          errLog('vxe.error.notFormats', [formatter]);
        }
      } else if (_xeUtils.default.isArray(formatter)) {
        var _gFormatOpts = _ui.formats.get(formatter[0]);
        if (!_gFormatOpts || !_gFormatOpts.formItemFormatMethod) {
          errLog('vxe.error.notFormats', [formatter[0]]);
        }
      }
    }
    if (field && itemRender) {
      if (itemRender.startField && "".concat(itemRender.startField).indexOf(field) >= 0) {
        errLog('vxe.error.modelConflicts', ["field=".concat(field), "item-render.startField=".concat(itemRender.startField)]);
      }
      if (itemRender.endField && "".concat(itemRender.endField).indexOf(field) >= 0) {
        errLog('vxe.error.modelConflicts', ["field=".concat(field), "item-render.endField=".concat(itemRender.endField)]);
      }
    }
    Object.assign(this, {
      id: _xeUtils.default.uniqueId('item_'),
      title: item.title,
      field: field,
      span: item.span,
      align: item.align,
      verticalAlign: item.verticalAlign,
      titleBackground: item.titleBackground,
      titleBold: item.titleBold,
      titleAlign: item.titleAlign,
      titleWidth: item.titleWidth,
      titleColon: item.titleColon,
      vertical: item.vertical,
      padding: item.padding,
      titleAsterisk: item.titleAsterisk,
      titlePrefix: item.titlePrefix,
      titleSuffix: item.titleSuffix,
      titleOverflow: item.titleOverflow,
      showTitle: item.showTitle,
      resetValue: item.resetValue,
      visibleMethod: item.visibleMethod,
      visible: item.visible,
      showContent: item.showContent,
      folding: item.folding,
      collapseNode: item.collapseNode,
      className: item.className,
      contentClassName: item.contentClassName,
      contentStyle: item.contentStyle,
      titleClassName: item.titleClassName,
      titleStyle: item.titleStyle,
      itemRender: itemRender,
      rules: item.rules,
      formatter: item.formatter,
      // 自定义参数
      params: item.params,
      // 渲染属性
      showError: false,
      showIconMsg: false,
      errRule: null,
      slots: item.slots,
      children: []
    });
  }
  return _createClass(ItemInfo, [{
    key: "update",
    value: function update(name, value) {
      this[name] = value;
    }
  }]);
}();