"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.internals = void 0;
function safeRenderHeader(column) {
  var _a;
  return (_a = column.title) !== null && _a !== void 0 ? _a : column.name;
}
function safeGetValue(column, record, rowIndex) {
  if (column.getValue) {
    return column.getValue(record, rowIndex);
  }
  return record[column.code];
}
function safeGetRowKey(primaryKey, record, rowIndex) {
  var key;
  if (typeof primaryKey === 'string') {
    key = record[primaryKey];
  } else if (typeof primaryKey === 'function') {
    key = primaryKey(record);
  }
  if (key == null) {
    key = String(rowIndex);
  }
  return key;
}
function safeGetCellProps(column, record, rowIndex) {
  if (column.getCellProps) {
    var value = safeGetValue(column, record, rowIndex);
    return column.getCellProps(value, record, rowIndex) || {};
  }
  return {};
}
function safeRender(column, record, rowIndex) {
  var value = safeGetValue(column, record, rowIndex);
  if (column.render) {
    return column.render(value, record, rowIndex);
  }
  return value;
}
var internals = exports.internals = {
  safeRenderHeader: safeRenderHeader,
  safeGetValue: safeGetValue,
  safeGetRowKey: safeGetRowKey,
  safeGetCellProps: safeGetCellProps,
  safeRender: safeRender
};