import me from "../../../@babel/runtime/helpers/esm/extends.mjs";
import ue from "../../../@babel/runtime/helpers/esm/typeof.mjs";
import g from "../../../@babel/runtime/helpers/esm/objectSpread2.mjs";
import r from "../../../@babel/runtime/helpers/esm/defineProperty.mjs";
import U from "../../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import { useContext as ve } from "../../../@rc-component/context/es/context.mjs";
import * as y from "react";
import "../../../rc-util/node_modules/react-is/index.mjs";
import xe from "../../../classnames/index.mjs";
import pe from "../context/TableContext.mjs";
import ye from "../hooks/useRenderTimes.mjs";
import ge from "./useCellRender.mjs";
import he from "./useHoverState.mjs";
import D from "../../../rc-util/es/hooks/useEvent.mjs";
import "../../../rc-util/es/hooks/useLayoutEffect.mjs";
import "../../../rc-util/es/warning.mjs";
var Ce = function(d) {
  var m = d.ellipsis, v = d.rowType, n = d.children, s, u = m === !0 ? {
    showTitle: !0
  } : m;
  return u && (u.showTitle || v === "header") && (typeof n == "string" || typeof n == "number" ? s = n.toString() : /* @__PURE__ */ y.isValidElement(n) && typeof n.props.children == "string" && (s = n.props.children)), s;
};
function Se(e) {
  var d, m, v, n, s, u, h, t;
  process.env.NODE_ENV !== "production" && ye(e);
  var O = e.component, q = e.children, C = e.ellipsis, z = e.scope, B = e.prefixCls, G = e.className, T = e.align, S = e.record, J = e.render, K = e.dataIndex, Q = e.renderIndex, W = e.shouldCellUpdate, _ = e.index, X = e.rowType, Y = e.colSpan, Z = e.rowSpan, P = e.fixLeft, E = e.fixRight, ee = e.firstFixLeft, w = e.lastFixLeft, k = e.firstFixRight, ie = e.lastFixRight, M = e.appendNode, $ = e.additionalProps, i = $ === void 0 ? {} : $, le = e.isSticky, o = "".concat(B, "-cell"), b = ve(pe, ["supportSticky", "allColumnsFixedLeft"]), a = b.supportSticky, te = b.allColumnsFixedLeft, oe = ge(S, K, Q, q, J, W), A = U(oe, 2), H = A[0], l = A[1], x = {}, F = typeof P == "number" && a, N = typeof E == "number" && a;
  F && (x.position = "sticky", x.left = P), N && (x.position = "sticky", x.right = E);
  var R = (d = (m = (v = l == null ? void 0 : l.colSpan) !== null && v !== void 0 ? v : i.colSpan) !== null && m !== void 0 ? m : Y) !== null && d !== void 0 ? d : 1, p = (n = (s = (u = l == null ? void 0 : l.rowSpan) !== null && u !== void 0 ? u : i.rowSpan) !== null && s !== void 0 ? s : Z) !== null && n !== void 0 ? n : 1, re = he(_, p), I = U(re, 2), ne = I[0], V = I[1], ae = D(function(L) {
    var f;
    S && V(_, _ + p - 1), i == null || (f = i.onMouseEnter) === null || f === void 0 || f.call(i, L);
  }), de = D(function(L) {
    var f;
    S && V(-1, -1), i == null || (f = i.onMouseLeave) === null || f === void 0 || f.call(i, L);
  });
  if (R === 0 || p === 0)
    return null;
  var se = (h = i.title) !== null && h !== void 0 ? h : Ce({
    rowType: X,
    ellipsis: C,
    children: H
  }), ce = xe(o, G, (t = {}, r(t, "".concat(o, "-fix-left"), F && a), r(t, "".concat(o, "-fix-left-first"), ee && a), r(t, "".concat(o, "-fix-left-last"), w && a), r(t, "".concat(o, "-fix-left-all"), w && te && a), r(t, "".concat(o, "-fix-right"), N && a), r(t, "".concat(o, "-fix-right-first"), k && a), r(t, "".concat(o, "-fix-right-last"), ie && a), r(t, "".concat(o, "-ellipsis"), C), r(t, "".concat(o, "-with-append"), M), r(t, "".concat(o, "-fix-sticky"), (F || N) && le && a), r(t, "".concat(o, "-row-hover"), !l && ne), t), i.className, l == null ? void 0 : l.className), j = {};
  T && (j.textAlign = T);
  var fe = g(g(g(g({}, x), i.style), j), l == null ? void 0 : l.style), c = H;
  return ue(c) === "object" && !Array.isArray(c) && !/* @__PURE__ */ y.isValidElement(c) && (c = null), C && (w || k) && (c = /* @__PURE__ */ y.createElement("span", {
    className: "".concat(o, "-content")
  }, c)), /* @__PURE__ */ y.createElement(O, me({}, l, i, {
    className: ce,
    style: fe,
    title: se,
    scope: z,
    onMouseEnter: ae,
    onMouseLeave: de,
    colSpan: R !== 1 ? R : null,
    rowSpan: p !== 1 ? p : null
  }), M, c);
}
const Ie = /* @__PURE__ */ y.memo(Se);
export {
  Ie as default
};
