"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.TableBodyCellContent = TableBodyCellContent;
var _react = _interopRequireDefault(require("react"));
var _reactTable = require("@tanstack/react-table");
var _isNaN = _interopRequireDefault(require("lodash-es/isNaN"));
var _truncateWithTooltip = require("../../truncate-with-tooltip");
var _useTranslation = require("../../hooks/use-translation");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
// eslint-disable-next-line you-dont-need-lodash-underscore/is-nan

const isValuePresent = value => {
  return typeof value === 'number' ? !(0, _isNaN.default)(value) : !!value;
};
function TableBodyCellContent({
  cell,
  getRowActions,
  getRowFooterAction,
  rowClickDisabled,
  rowSelectionDisabled,
  keyboardNavCellId,
  localizationProps
}) {
  const {
    t
  } = (0, _useTranslation.useTranslation)();
  const shouldTruncate = !!cell.column.columnDef.meta?.truncateText;
  const value = cell.getValue();
  const cellProps = {
    ...cell.getContext(),
    getRowActions,
    getRowFooterAction,
    rowClickDisabled,
    rowSelectionDisabled,
    keyboardNavCellId
  };
  if (!shouldTruncate) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
      children: (0, _reactTable.flexRender)(cell.column.columnDef.cell, cellProps)
    });
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_truncateWithTooltip.TruncateWithTooltip, {
    className: "react-table-cell-text",
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      children: isValuePresent(value) ? (0, _reactTable.flexRender)(cell.column.columnDef.cell, cellProps) : localizationProps?.emptyCellLabel ?? t('N/A')
    })
  });
}