import React__default, { useContext } from "react";
import { SummaryContext } from "./context.js";
import cs from "../../_util/classNames.js";
import { ConfigContext } from "../../ConfigProvider/index.js";
import { jsx } from "../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
var __rest = globalThis && globalThis.__rest || function(s, e) {
  var t = {};
  for (var p in s)
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
      t[p] = s[p];
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
      if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
        t[p[i]] = s[p[i]];
    }
  return t;
};
function Row(props) {
  var rtl = useContext(ConfigContext).rtl;
  var _a = useContext(SummaryContext), columns = _a.columns, stickyOffsets = _a.stickyOffsets, stickyClassNames = _a.stickyClassNames, prefixCls = _a.prefixCls;
  var children = props.children, rest = __rest(props, ["children"]);
  var colSpans = React__default.Children.map(children, function(child) {
    return child.props.colSpan || 1;
  });
  var element = React__default.Children.map(children, function(child, index) {
    var _a2, _b;
    var _c, _d, _e;
    var childElement = child;
    var isSummaryCell = (_c = childElement === null || childElement === void 0 ? void 0 : childElement.props) === null || _c === void 0 ? void 0 : _c.$$ArcoTableSummaryCell;
    var childStyle = (_d = childElement === null || childElement === void 0 ? void 0 : childElement.props) === null || _d === void 0 ? void 0 : _d.style;
    var childClassName = (_e = childElement === null || childElement === void 0 ? void 0 : childElement.props) === null || _e === void 0 ? void 0 : _e.className;
    var prevAllColSpan = colSpans.slice(0, index).reduce(function(p, n) {
      return p + n;
    }, 0);
    var stickyIndex = prevAllColSpan;
    var stickyStyle = columns[stickyIndex].fixed === "left" ? (_a2 = {}, _a2[rtl ? "right" : "left"] = stickyOffsets[stickyIndex], _a2) : columns[stickyIndex].fixed === "right" ? (_b = {}, _b[rtl ? "left" : "right"] = stickyOffsets[stickyIndex], _b) : {};
    var stickyClassName = columns[stickyIndex].fixed === "left" || columns[stickyIndex].fixed === "right" ? stickyClassNames[stickyIndex] : "";
    return isSummaryCell ? React__default.cloneElement(childElement, __assign(__assign({}, childElement.props), {
      className: cs(prefixCls + "-td", stickyClassName, childClassName),
      style: __assign(__assign({}, childStyle), stickyStyle)
    })) : child;
  });
  return /* @__PURE__ */ jsx("tr", {
    ...__assign({}, rest),
    children: element
  });
}
export {
  Row as default
};
//# sourceMappingURL=row.js.map
