import * as e from "react";
import p from "./Cell.mjs";
import k from "./DescriptionsContext.mjs";
function d(n, s, o) {
  let {
    colon: r,
    prefixCls: a,
    bordered: t
  } = s, {
    component: l,
    type: x,
    showLabel: $,
    showContent: h,
    labelStyle: C,
    contentStyle: f
  } = o;
  return n.map((S, c) => {
    let {
      label: g,
      children: u,
      prefixCls: i = a,
      className: m,
      style: b,
      labelStyle: j,
      contentStyle: O,
      span: w = 1,
      key: y
    } = S;
    return typeof l == "string" ? /* @__PURE__ */ e.createElement(p, {
      key: `${x}-${y || c}`,
      className: m,
      style: b,
      labelStyle: Object.assign(Object.assign({}, C), j),
      contentStyle: Object.assign(Object.assign({}, f), O),
      span: w,
      colon: r,
      component: l,
      itemPrefixCls: i,
      bordered: t,
      label: $ ? g : null,
      content: h ? u : null
    }) : [/* @__PURE__ */ e.createElement(p, {
      key: `label-${y || c}`,
      className: m,
      style: Object.assign(Object.assign(Object.assign({}, C), b), j),
      span: 1,
      colon: r,
      component: l[0],
      itemPrefixCls: i,
      bordered: t,
      label: g
    }), /* @__PURE__ */ e.createElement(p, {
      key: `content-${y || c}`,
      className: m,
      style: Object.assign(Object.assign(Object.assign({}, f), b), O),
      span: w * 2 - 1,
      component: l[1],
      itemPrefixCls: i,
      bordered: t,
      content: u
    })];
  });
}
const E = (n) => {
  const s = e.useContext(k), {
    prefixCls: o,
    vertical: r,
    row: a,
    index: t,
    bordered: l
  } = n;
  return r ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("tr", {
    key: `label-${t}`,
    className: `${o}-row`
  }, d(a, n, Object.assign({
    component: "th",
    type: "label",
    showLabel: !0
  }, s))), /* @__PURE__ */ e.createElement("tr", {
    key: `content-${t}`,
    className: `${o}-row`
  }, d(a, n, Object.assign({
    component: "td",
    type: "content",
    showContent: !0
  }, s)))) : /* @__PURE__ */ e.createElement("tr", {
    key: t,
    className: `${o}-row`
  }, d(a, n, Object.assign({
    component: l ? ["th", "td"] : "td",
    type: "item",
    showLabel: !0,
    showContent: !0
  }, s)));
}, P = E;
export {
  P as default
};
