'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.cjs');
var Cell = require('./Cell.cjs');
var useContext = require('./useContext.cjs');
var props = require('../../../utils/vue/props.cjs');

const Row = (props$1) => {
  const renderCells = (items, {
    colon,
    prefixCls: prefixCls2,
    bordered: bordered2
  }, {
    component,
    type,
    showLabel,
    showContent,
    labelStyle: rootLabelStyle,
    contentStyle: rootContentStyle
  }) => {
    return items.map((item, index2) => {
      var _a, _b;
      const itemProps = item.props || {};
      const {
        prefixCls: itemPrefixCls = prefixCls2,
        span = 1,
        labelStyle: labelStyle2 = itemProps["label-style"],
        contentStyle: contentStyle2 = itemProps["content-style"],
        label = (_b = (_a = item.children) == null ? void 0 : _a.label) == null ? void 0 : _b.call(_a)
      } = itemProps;
      const children = props.getSlot(item);
      const className = props.getClass(item);
      const style = props.getStyle(item);
      const {
        key
      } = item;
      if (typeof component === "string") {
        return vue.createVNode(Cell.default, {
          "key": `${type}-${String(key) || index2}`,
          "class": className,
          "style": style,
          "labelStyle": {
            ...rootLabelStyle,
            ...labelStyle2
          },
          "contentStyle": {
            ...rootContentStyle,
            ...contentStyle2
          },
          "span": span,
          "colon": colon,
          "component": component,
          "itemPrefixCls": itemPrefixCls,
          "bordered": bordered2,
          "label": showLabel ? label : null,
          "content": showContent ? children : null
        }, null);
      }
      return [vue.createVNode(Cell.default, {
        "key": `label-${String(key) || index2}`,
        "class": className,
        "style": {
          ...rootLabelStyle,
          ...style,
          ...labelStyle2
        },
        "span": 1,
        "colon": colon,
        "component": component[0],
        "itemPrefixCls": itemPrefixCls,
        "bordered": bordered2,
        "label": label
      }, null), vue.createVNode(Cell.default, {
        "key": `content-${String(key) || index2}`,
        "class": className,
        "style": {
          ...rootContentStyle,
          ...style,
          ...contentStyle2
        },
        "span": span * 2 - 1,
        "component": component[1],
        "itemPrefixCls": itemPrefixCls,
        "bordered": bordered2,
        "content": children
      }, null)];
    });
  };
  const {
    prefixCls,
    vertical,
    row,
    index,
    bordered
  } = props$1;
  const {
    labelStyle,
    contentStyle
  } = useContext.useProviderContext();
  if (vertical) {
    return vue.createVNode(vue.Fragment, null, [vue.createVNode("tr", {
      "key": `label-${index}`,
      "class": `${prefixCls}-row`
    }, [renderCells(row, props$1, {
      component: "th",
      type: "label",
      showLabel: true,
      labelStyle: labelStyle.value,
      contentStyle: contentStyle.value
    })]), vue.createVNode("tr", {
      "key": `content-${index}`,
      "class": `${prefixCls}-row`
    }, [renderCells(row, props$1, {
      component: "td",
      type: "content",
      showContent: true,
      labelStyle: labelStyle.value,
      contentStyle: contentStyle.value
    })])]);
  }
  return vue.createVNode("tr", {
    "key": index,
    "class": `${prefixCls}-row`
  }, [renderCells(row, props$1, {
    component: bordered ? ["th", "td"] : "td",
    type: "item",
    showLabel: true,
    showContent: true,
    labelStyle: labelStyle.value,
    contentStyle: contentStyle.value
  })]);
};

exports.default = Row;
//# sourceMappingURL=Row.cjs.map
