import P from "../../../@babel/runtime/helpers/esm/extends.mjs";
import S from "../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import h from "../../../classnames/index.mjs";
import * as o from "react";
import $ from "../Cell/index.mjs";
import { responseImmutable as j } from "../context/TableContext.mjs";
import b from "../hooks/useRenderTimes.mjs";
import q from "../hooks/useRowInfo.mjs";
import A from "./ExpandedRow.mjs";
function G(e, x, i, t, p) {
  var m = e.record, c = e.prefixCls, C = e.columnsKey, l = e.fixedInfoList, f = e.expandIconColumnIndex, v = e.nestExpandable, w = e.indentSize, n = e.expandIcon, r = e.expanded, N = e.hasNestChildren, u = e.onTriggerExpand, R = C[i], a = l[i], s;
  i === (f || 0) && v && (s = /* @__PURE__ */ o.createElement(o.Fragment, null, /* @__PURE__ */ o.createElement("span", {
    style: {
      paddingLeft: "".concat(w * t, "px")
    },
    className: "".concat(c, "-row-indent indent-level-").concat(t)
  }), n({
    prefixCls: c,
    expanded: r,
    expandable: N,
    record: m,
    onExpand: u
  })));
  var y;
  return x.onCell && (y = x.onCell(m, p)), {
    key: R,
    fixedInfo: a,
    appendCellNode: s,
    additionalCellProps: y || {}
  };
}
function k(e) {
  process.env.NODE_ENV !== "production" && b(e);
  var x = e.className, i = e.style, t = e.record, p = e.index, m = e.renderIndex, c = e.rowKey, C = e.indent, l = C === void 0 ? 0 : C, f = e.rowComponent, v = e.cellComponent, w = e.scopeCellComponent, n = q(t, c, p, l), r = n.prefixCls, N = n.flattenColumns, u = n.expandedRowClassName, R = n.expandedRowRender, a = n.rowProps, s = n.expanded, y = n.rowSupportExpand, g = o.useRef(!1);
  g.current || (g.current = s), process.env.NODE_ENV !== "production" && b(e);
  var _ = /* @__PURE__ */ o.createElement(f, P({}, a, {
    "data-row-key": c,
    className: h(x, "".concat(r, "-row"), "".concat(r, "-row-level-").concat(l), a == null ? void 0 : a.className),
    style: S(S({}, i), a == null ? void 0 : a.style)
  }), N.map(function(d, L) {
    var T = d.render, z = d.dataIndex, D = d.className, E = G(n, d, L, l, p), F = E.key, O = E.fixedInfo, U = E.appendCellNode, V = E.additionalCellProps;
    return /* @__PURE__ */ o.createElement($, P({
      className: D,
      ellipsis: d.ellipsis,
      align: d.align,
      scope: d.rowScope,
      component: d.rowScope ? w : v,
      prefixCls: r,
      key: F,
      record: t,
      index: p,
      renderIndex: m,
      dataIndex: z,
      render: T,
      shouldCellUpdate: d.shouldCellUpdate
    }, O, {
      appendNode: U,
      additionalProps: V
    }));
  })), I;
  if (y && (g.current || s)) {
    var K = R(t, p, l + 1, s), B = u && u(t, p, l);
    I = /* @__PURE__ */ o.createElement(A, {
      expanded: s,
      className: h("".concat(r, "-expanded-row"), "".concat(r, "-expanded-row-level-").concat(l + 1), B),
      prefixCls: r,
      component: f,
      cellComponent: v,
      colSpan: N.length,
      isEmpty: !1
    }, K);
  }
  return /* @__PURE__ */ o.createElement(o.Fragment, null, _, I);
}
k.displayName = "BodyRow";
const ee = j(k);
export {
  ee as default,
  G as getCellProps
};
