"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const comp = require("../../ui/src/comp.js");
require("../../ui/index.js");
const utils = require("../../ui/src/utils.js");
const render = require("./render.js");
const XEUtils = require("xe-utils");
const renderer = require("../../../../@vxe-ui/core/es/src/renderer.js");
const index_esm = require("../../../../@vxe-ui/core/es/index.esm.js");
const VxeFormConfigItem = comp.defineVxeComponent({
  name: "VxeFormConfigItem",
  props: {
    itemConfig: Object
  },
  setup(props) {
    const $xeForm = vue.inject("$xeForm", {});
    const xeformiteminfo = { itemConfig: props.itemConfig };
    vue.provide("xeFormItemInfo", xeformiteminfo);
    const renderItem = ($xeForm2, item) => {
      const formProps = $xeForm2.props;
      const $xeGrid = $xeForm2.xeGrid;
      const { data, readonly, disabled } = formProps;
      const { visible, field, itemRender, contentStyle, children, showContent } = item;
      const compConf = utils.isEnableConf(itemRender) ? renderer.renderer.get(itemRender.name) : null;
      const itemStyle = compConf ? compConf.formItemStyle || compConf.itemStyle : null;
      const itemContentStyle = compConf ? compConf.formItemContentStyle || compConf.itemContentStyle : null;
      const params = { data, disabled, readonly, field, property: field, item, $form: $xeForm2, $grid: $xeGrid };
      const hasGroup = children && children.length > 0;
      if (visible === false) {
        return index_esm.renderEmptyElement();
      }
      return vue.h("div", {
        key: item.id,
        itemid: item.id,
        class: render.getItemClass($xeForm2, item),
        style: XEUtils.isFunction(itemStyle) ? itemStyle(params) : itemStyle
      }, [
        render.renderTitle($xeForm2, item),
        showContent === false ? index_esm.renderEmptyElement() : vue.h("div", {
          class: render.getItemContentClass($xeForm2, item),
          style: Object.assign({}, XEUtils.isFunction(itemContentStyle) ? itemContentStyle(params) : itemContentStyle, XEUtils.isFunction(contentStyle) ? contentStyle(params) : contentStyle)
        }, hasGroup ? children.map((childItem) => renderItem($xeForm2, childItem)) : [
          render.renderItemContent($xeForm2, item),
          render.renderItemErrorIcon($xeForm2, item)
        ])
      ]);
    };
    const renderVN = () => {
      return renderItem($xeForm, props.itemConfig);
    };
    const $xeFormconfigitem = {
      renderVN
    };
    vue.provide("$xeFormGroup", null);
    return $xeFormconfigitem;
  },
  render() {
    return this.renderVN();
  }
});
exports.default = VxeFormConfigItem;
