"use strict";

exports.__esModule = true;
exports.useStyles = exports.default = exports.MemoTableRow = exports.MemoTableBody = void 0;
var _react = _interopRequireWildcard(require("react"));
var _Table = _interopRequireDefault(require("@material-ui/core/Table"));
var _TableContainer = _interopRequireDefault(require("@material-ui/core/TableContainer"));
var _TableHead = _interopRequireDefault(require("@material-ui/core/TableHead"));
var _TableRow = _interopRequireDefault(require("@material-ui/core/TableRow"));
var _styles = require("@material-ui/core/styles");
var _createInput = require("../Inputs/createInput");
var _useTableSelection3 = require("./useTableSelection");
var _TableProps = _interopRequireWildcard(require("./TableProps"));
var _classnames = _interopRequireDefault(require("classnames"));
var _reactResizeDetector = _interopRequireDefault(require("react-resize-detector"));
var _lodash = require("lodash");
var _useViewState3 = _interopRequireDefault(require("../../../hooks/useViewState"));
var _excluded = ["deepPropsComparation", "dataRows", "isEditingMode"],
  _excluded2 = ["deepPropsComparation", "isEditingMode"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var useStyles = exports.useStyles = (0, _styles.makeStyles)(function (theme) {
  return {
    container: {
      flex: "0 1 100%",
      fontSize: theme.typography.fontSize,
      display: "flex",
      flexDirection: "column"
    },
    tableContainer: {
      overflowY: "auto",
      position: "relative"
    },
    table: {
      tableLayout: "fixed",
      minWidth: "auto"
    },
    tableConstrained: {
      minWidth: theme.spacing(83)
    },
    stickyHeaderHead: {
      borderTop: function borderTop(props) {
        return props.withoutTopBorder ? "none" : "1px solid " + theme.palette.grey.borders;
      },
      borderBottom: "1px solid " + theme.palette.grey.borders,
      backgroundColor: theme.palette.grey.lighter,
      display: "flex",
      cursor: "default"
    },
    stickyHeaderTable: {
      tableLayout: "fixed",
      width: function width(props) {
        return "calc(100% - " + (props.scrolled || "0") + "px)";
      }
    },
    stickyHeaderTableScroll: {
      width: function width(props) {
        return (props.scrolled || "0") + "px";
      },
      backgroundColor: theme.palette.grey.lighter,
      display: function display(props) {
        return props.scrolled > 0 ? "block" : "none";
      }
    },
    tableHeader: {
      borderTop: function borderTop(props) {
        return props.withoutTopBorder ? "none" : "1px solid " + theme.palette.grey.borders;
      },
      borderBottom: function borderBottom(props) {
        return props.stickyHeader ? "none" : "1px solid " + theme.palette.grey.borders;
      },
      display: function display(props) {
        return props.stickyHeader ? "none" : "table-header-group";
      },
      backgroundColor: theme.palette.grey.lighter,
      overflow: "hidden",
      cursor: "default"
    },
    tableBody: {
      overflowX: "hidden",
      overflowY: "auto"
    },
    tableRow: {
      borderBottom: "1px solid " + theme.palette.grey.borders,
      cursor: function cursor(props) {
        return props.onRowClick ? "pointer" : "default";
      },
      backgroundColor: theme.palette.background.paper + "!important",
      "&:hover": {
        backgroundColor: function backgroundColor(props) {
          return props.onRowClick ? theme.palette.grey.lighter : theme.palette.background.paper;
        }
      }
    },
    tableCell: {
      padding: theme.spacing(2, 0.5),
      "&:first-child": {
        padding: theme.spacing(2, 0.5, 2, 2)
      }
    },
    tableCellSelect: {
      padding: theme.spacing(2, 0.5),
      width: theme.spacing(3),
      "&:first-child": {
        padding: theme.spacing(2, 0.5, 2, 2)
      }
    },
    headerCell: {
      padding: theme.spacing(1, 0.5),
      textAlign: "left",
      fontWeight: theme.typography.fontWeightSemiBold,
      "&:first-child": {
        padding: theme.spacing(2, 0.5, 2, 2)
      }
    },
    headerCellSelect: {
      padding: theme.spacing(1, 0.5),
      width: theme.spacing(3),
      textAlign: "left",
      fontWeight: theme.typography.fontWeightSemiBold,
      "&:first-child": {
        padding: theme.spacing(2, 0.5, 2, 2)
      }
    },
    rowSelectCheckbox: {
      padding: 0
    },
    placeholder: {
      display: "flex",
      flex: 1,
      justifyContent: "center",
      alignItems: "center"
    }
  };
});
function headersAreIdentical(prevHeaders, nextHeaders) {
  prevHeaders.forEach(function (prevHeader, index) {
    var _nextHeaders$index;
    var prevSortOptions = prevHeader.cellElement.props.columnDefinition.sortOptions;
    var nextSortOptions = (_nextHeaders$index = nextHeaders[index]) == null ? void 0 : _nextHeaders$index.cellElement.props.columnDefinition.sortOptions;
    if (prevSortOptions != null && nextSortOptions != null) {
      if (prevSortOptions.sortField !== nextSortOptions.sortField) {
        return false;
      }
      return prevSortOptions.direction === nextSortOptions.direction;
    }
    return true;
  });
}
function readOnlyMode(prevTableProps, nextTableProps) {
  var _prevTableProps$get, _nextTableProps$get;
  var prevEditingMode = (_prevTableProps$get = prevTableProps == null ? void 0 : prevTableProps.get(_TableProps.default.propNames.isEditingMode)) != null ? _prevTableProps$get : false;
  var nextEditingMode = (_nextTableProps$get = nextTableProps == null ? void 0 : nextTableProps.get(_TableProps.default.propNames.isEditingMode)) != null ? _nextTableProps$get : false;
  return isInReadOnlyMode(prevEditingMode, nextEditingMode);
}
function rowAreIdentical(prevRows, nextRows) {
  return prevRows.length === nextRows.length && prevRows.findIndex(function (pr, index) {
    return pr.key !== nextRows[index].key;
  }) === -1;
}
function contextIsIdentical(prevContext, nextContext) {
  return (0, _lodash.isEqual)(prevContext, nextContext);
}
function propsAreEqualRow(prev, next) {
  var isReadOnly = isInReadOnlyMode(prev.isEditingMode, next.isEditingMode);
  if (prev.deepPropsComparation && isReadOnly) {
    return propsAreEqualDeeplyRow(prev.dataRows, next.dataRows) && contextIsIdentical(prev.context, next.context);
  }
  return prev.selected === next.selected && isReadOnly && contextIsIdentical(prev.context, next.context);
}
function propsAreEqualDeeplyRow(prevRow, nextRow) {
  /* istanbul ignore next */
  if (prevRow.length !== nextRow.length) return false;
  for (var i = 0; i < prevRow.length; i++) {
    if (!(0, _lodash.isEqual)(prevRow[i].element, nextRow[i].element) || prevRow[i].columns.length !== nextRow[i].columns.length) {
      return false;
    }
  }
  return true;
}
var TableRowMemo = function TableRowMemo(_ref) {
  var deepPropsComparation = _ref.deepPropsComparation,
    dataRows = _ref.dataRows,
    isEditingMode = _ref.isEditingMode,
    props = _objectWithoutProperties(_ref, _excluded);
  return /*#__PURE__*/_react.default.createElement(_TableRow.default, props);
};
var MemoTableRow = exports.MemoTableRow = _react.default.memo(TableRowMemo, propsAreEqualRow);
function isInReadOnlyMode(prevIsEditingMode, nextIsEditingMode) {
  // In editing mode, we need to re-render everytime has cell value may have changed
  return prevIsEditingMode === nextIsEditingMode && !nextIsEditingMode;
}
function propsAreEqualBody(prev, next) {
  var isEqualBody = contextIsIdentical(prev.context, next.context) && isInReadOnlyMode(prev.isEditingMode, next.isEditingMode) && prev.selectedNumber === next.selectedNumber && rowAreIdentical(prev.dataRows, next.dataRows);
  if (prev.deepPropsComparation) {
    isEqualBody = isEqualBody && propsAreEqualDeeplyRow(prev.dataRows, next.dataRows);
  }
  return isEqualBody;
}
var TableBody = function TableBody(_ref2) {
  var deepPropsComparation = _ref2.deepPropsComparation,
    isEditingMode = _ref2.isEditingMode,
    props = _objectWithoutProperties(_ref2, _excluded2);
  return /*#__PURE__*/_react.default.createElement("tbody", {
    className: props.className
  }, props.tableRows);
};
var MemoTableBody = exports.MemoTableBody = _react.default.memo(TableBody, propsAreEqualBody);
var TableCell = _react.default.forwardRef(function (props, ref) {
  //withDeferredTooltip(
  return /*#__PURE__*/_react.default.createElement("td", _extends({
    className: props.className,
    ref: ref
  }, props), props.value);
});
//);

var buildRowCheckbox = function buildRowCheckbox(classes, key, selectionHandlers) {
  var rowSelected = selectionHandlers.isSelected(key);
  return /*#__PURE__*/_react.default.createElement("td", {
    className: classes.tableCellSelect,
    selected: rowSelected
  }, (0, _createInput.createInput)(_createInput.inputTypes.checkbox, {
    value: rowSelected,
    disabled: false,
    onChange: function onChange(event) {
      return selectionHandlers.selectionHandler(event, key);
    }
  }));
};
var buildTableCheckbox = function buildTableCheckbox(classes, tableSelectionStatus, selectionMethods) {
  return /*#__PURE__*/_react.default.createElement("th", {
    key: "tableSelector",
    className: classes.headerCellSelect
  }, (0, _createInput.createInput)(_createInput.inputTypes.checkbox, {
    value: tableSelectionStatus === _useTableSelection3.tableSelectionMode.all,
    disabled: false,
    indeterminate: tableSelectionStatus === _useTableSelection3.tableSelectionMode.indeterminate,
    onChange: function onChange(event) {
      return selectionMethods.selectionHandler(event, null);
    }
  }));
};
var StickerTableHeader = function StickerTableHeader(_ref3) {
  var classes = _ref3.classes,
    tableHeaders = _ref3.tableHeaders;
  return /*#__PURE__*/_react.default.createElement("div", {
    key: "stickyHeader",
    className: classes.stickyHeaderHead
  }, /*#__PURE__*/_react.default.createElement(_Table.default, {
    className: classes.stickyHeaderTable
  }, /*#__PURE__*/_react.default.createElement(_TableHead.default, null, /*#__PURE__*/_react.default.createElement(_TableRow.default, null, tableHeaders))), /*#__PURE__*/_react.default.createElement("div", {
    className: classes.stickyHeaderTableScroll
  }));
};
var buildTableHeaders = function buildTableHeaders(headers, classes, customClasses, selectMode, tableSelectionStatus, selectionMethods) {
  var tableCheckbox = selectMode === true ? [buildTableCheckbox(classes, tableSelectionStatus, selectionMethods)] : [];
  return tableCheckbox.concat(headers.map(function (header, index) {
    return /*#__PURE__*/_react.default.createElement("th", {
      key: index,
      className: (0, _classnames.default)(classes.headerCell, customClasses[header.className], customClasses.headerCell)
    }, header.cellElement);
  }));
};
var buildTableRows = function buildTableRows(rows, classes, customClasses, selectMode, onRowClick, selectionHandlers, deepPropsComparation, context, isEditingMode) {
  var _onClick = function onClick(evt, row) {
    if (evt.target.tagName !== "INPUT" && onRowClick != null) {
      onRowClick(evt, row.element);
    }
  };
  var mappedRows = rows.map(function (row) {
    var _row$style$show, _row$style, _row$style$customClas, _row$style2;
    var showStyle = (_row$style$show = row == null || (_row$style = row.style) == null ? void 0 : _row$style.show) != null ? _row$style$show : false;
    var rowClass = (_row$style$customClas = row == null || (_row$style2 = row.style) == null ? void 0 : _row$style2.customClass) != null ? _row$style$customClas : "";
    var customClassName = showStyle ? rowClass : "";
    return /*#__PURE__*/_react.default.createElement(MemoTableRow, {
      className: (0, _classnames.default)(classes.tableRow, customClasses.tableRow, customClasses[row.className], customClasses[customClassName]),
      key: row.key,
      onClick: function onClick(evt) {
        return _onClick(evt, row);
      },
      selected: selectionHandlers.isSelected(row.key),
      deepPropsComparation: deepPropsComparation,
      context: context,
      isEditingMode: isEditingMode,
      dataRows: rows
    }, selectMode === true ? buildRowCheckbox(classes, row.key, selectionHandlers) : null, row.columns.map(function (cell, cellIndex) {
      return /*#__PURE__*/_react.default.createElement(TableCell, {
        className: (0, _classnames.default)(classes.tableCell, customClasses[cell.className], customClasses.tableCell),
        key: cellIndex,
        value: cell.cellElement
      });
    }));
  });
  return mappedRows;
};
var FullTable = _react.default.forwardRef(function (props, ref) {
  return props.saveScrollbarPosition ? /*#__PURE__*/_react.default.createElement(FullTableWithSavedScrollbar, _extends({}, props, {
    ref: ref
  })) : /*#__PURE__*/_react.default.createElement(DefaultFullTable, _extends({}, props, {
    ref: ref
  }));
});
var DefaultFullTable = _react.default.forwardRef(function (props, ref) {
  var scrollEvent = function scrollEvent(evt) {
    if (evt.target.scrollHeight - (evt.target.scrollTop + evt.target.offsetHeight) < 100 && props.dataRows.length === props.latestPage * props.pageLength) {
      props.scrollLoader(props.latestPage + 1);
    }
    props.saveScrollBarPosition == null || props.saveScrollBarPosition(evt);
  };
  return /*#__PURE__*/_react.default.createElement("div", {
    key: "actualTable",
    className: (0, _classnames.default)(props.classes.tableContainer, props.customClasses.tableContainer),
    ref: ref,
    onScroll: scrollEvent,
    "data-qa": "scrollable-table-div"
  }, /*#__PURE__*/_react.default.createElement(_reactResizeDetector.default, {
    onResize: props.onResize
  }), /*#__PURE__*/_react.default.createElement(_Table.default, {
    className: (0, _classnames.default)(props.classes.table, props.customClasses.table, props.constrained ? props.classes.tableConstrained : "")
  }, /*#__PURE__*/_react.default.createElement(_TableHead.default, {
    className: (0, _classnames.default)(props.classes.tableHeader, props.customClasses.tableHeader)
  }, /*#__PURE__*/_react.default.createElement(_TableRow.default, null, props.tableHeaders)), /*#__PURE__*/_react.default.createElement(MemoTableBody, {
    className: (0, _classnames.default)(props.classes.tableBody, props.customClasses.tableBody),
    dataRows: props.dataRows,
    tableRows: props.tableRows,
    selectedNumber: props.selectedNumber,
    deepPropsComparation: props.deepPropsComparation,
    isEditingMode: props.isEditingMode,
    context: props.context
  })), props.tableRows.length > 0 ? null : /*#__PURE__*/_react.default.createElement("div", {
    className: props.classes.placeholder
  }, props.placeholder));
});
var FullTableWithSavedScrollbar = _react.default.forwardRef(__signature__(__signature__(function (props, ref) {
  if (props.saveScrollbarPosition && !props.tableName) {
    throw new Error("prop 'tableName' is required if 'saveScrollbarPosition' is set to true.");
  }
  var _useViewState = (0, _useViewState3.default)(props.tableName + "ScrollbarPosition"),
    _useViewState2 = _slicedToArray(_useViewState, 2),
    scrollbarViewState = _useViewState2[0],
    updateScrollbarViewState = _useViewState2[1];
  var _useState = (0, _react.useState)(scrollbarViewState.scrollBarPosition),
    _useState2 = _slicedToArray(_useState, 2),
    scrollbar = _useState2[0],
    setScrollbarPosition = _useState2[1];
  (0, _react.useEffect)(function () {
    var handler = setTimeout(function () {
      updateScrollbarViewState("scrollBarPosition", scrollbar);
    }, 500);
    return function () {
      clearTimeout(handler);
    };
  },
  // eslint-disable-next-line react-hooks/exhaustive-deps
  [scrollbar]);
  var saveScrollBarPosition = function saveScrollBarPosition(evt) {
    setScrollbarPosition(evt.target.scrollTop);
  };
  (0, _react.useEffect)(function () {
    if (scrollbarViewState.scrollBarPosition > 0) {
      // The Table component usually display the provided list ASAP however it can happen that the Table is not fully rendered with its items when we attempt to change the scrollTop value.
      // The timer should ensure that the list is rendered before attempting to change the scrollTop if the first attempt was not able to set the scroll position
      // 		This edge case was found using these steps:
      //          * Create an organization with 50+ customers
      //          * Go to the customer section of the organization and scroll down a bit
      //          * Wait 1 second for the scroll position to be stored
      //          * Go to the organization list (click on the tab)
      //          * Go back to the organization (its tab should still be visible)
      //          * We expect the customer list to remember its scroll position but it wasn't the case
      //
      // In addition to the timer, the tableName was added as a dependency to force the effect to execute again when it changes.
      // The tableName value in the organization's customers page is composed with 2 parts: "OrganizationCustomers_" + organizationId. This allows 2 organizations to use different scroll position for their respective customers pages.
      // When the page first load, it is possible for organizationId to not yet be defined (strange but it's routing related) and because of that this useEffect was executed but with an unknown scrollBarPosition.
      // The organizationId will be set on the next render and this useEffect needs be executed again to have the list scrolled to the correct position.

      var previousScrollTop = ref.current.scrollTop;
      ref.current.scrollTop = scrollbarViewState.scrollBarPosition;

      // Note AD20250714: I was not able to create a test for the code below because it needs to run in a real browser otherwise the behavior with scrollTop does not match reality
      /* istanbul ignore if */
      if (ref.current.scrollTop === previousScrollTop) {
        setTimeout(function () {
          // using a timer to give a chance to the UI to populate the list
          ref.current.scrollTop = scrollbarViewState.scrollBarPosition;
        }, 250);
      }
    }
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [props.tableName]); // forcing this effect to run again when the tableName changes

  return /*#__PURE__*/_react.default.createElement(DefaultFullTable, _extends({}, props, {
    ref: ref,
    saveScrollBarPosition: saveScrollBarPosition
  }));
}, "useViewState{[scrollbarViewState, updateScrollbarViewState]}\nuseState{[scrollbar, setScrollbarPosition](scrollbarViewState.scrollBarPosition)}\nuseEffect{}\nuseEffect{}", function () {
  return [_useViewState3.default];
}), "useViewState{[scrollbarViewState, updateScrollbarViewState]}\nuseState{[scrollbar, setScrollbarPosition](scrollbarViewState.scrollBarPosition)}\nuseEffect{}\nuseEffect{}", function () {
  return [_useViewState3.default];
}));
var Table = _react.default.forwardRef(__signature__(__signature__(function (_ref4, ref) {
  var tableInfo = _ref4.tableInfo,
    headers = _ref4.headers,
    rows = _ref4.rows,
    scrollLoader = _ref4.scrollLoader,
    latestPage = _ref4.latestPage,
    pageLength = _ref4.pageLength,
    placeholder = _ref4.placeholder,
    tableProps = _ref4.tableProps,
    context = _ref4.context;
  if ((0, _TableProps.isTableProps)(tableProps) === false) {
    throw new TypeError("tableProps property is not of type TableProps");
  }
  var customClasses = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.classes)) || {};
  var selectMode = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.selectMode)) || false;
  var stickyHeader = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.stickyHeader)) || false;
  var withoutTopBorder = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.withoutTopBorder)) || false;
  var onRowClick = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.onRowClick)) || null;
  var deepPropsComparation = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.deepPropsComparation)) || false;
  var isEditingMode = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.isEditingMode)) || false;
  var selectedRows = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.selectedRows)) || null;
  var selectedRowsChanged = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.selectedRowsChanged)) || null;
  var constrained = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.constrained)) || false;
  var tableName = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.tableName)) || null;
  var saveScrollbarPosition = (tableProps == null ? void 0 : tableProps.get(_TableProps.default.propNames.saveScrollbarPosition)) || false;
  customClasses["tableHeader"] = (tableProps == null ? void 0 : tableProps.getStyle(_TableProps.default.ruleNames.tableHeader)) || null;
  customClasses["tableRow"] = (tableProps == null ? void 0 : tableProps.getStyle(_TableProps.default.ruleNames.tableRow)) || null;
  customClasses["tableCell"] = (tableProps == null ? void 0 : tableProps.getStyle(_TableProps.default.ruleNames.tableCell)) || null;
  customClasses["headerCell"] = (tableProps == null ? void 0 : tableProps.getStyle(_TableProps.default.ruleNames.headerCell)) || null;
  customClasses["tableContainer"] = (tableProps == null ? void 0 : tableProps.getStyle(_TableProps.default.ruleNames.tableContainer)) || null;
  customClasses["container"] = (tableProps == null ? void 0 : tableProps.getStyle(_TableProps.default.ruleNames.container)) || null;
  customClasses["table"] = (tableProps == null ? void 0 : tableProps.getStyle(_TableProps.default.ruleNames.table)) || null;
  if (selectedRows && !selectedRowsChanged || !selectedRows && selectedRowsChanged) throw new Error("Both 'selectedRows' and 'selectedRowsChanged' need to be defined if one of them is.");
  var refScrolled = (0, _react.useRef)();
  (0, _react.useImperativeHandle)(ref, function () {
    return {
      scrollToTop: function scrollToTop() {
        if (refScrolled.current.scrollTop > 0) {
          refScrolled.current.scrollTop = 0;
        }
      }
    };
  });
  var _useState3 = (0, _react.useState)(0),
    _useState4 = _slicedToArray(_useState3, 2),
    scrolled = _useState4[0],
    setScrolled = _useState4[1];
  var _useState5 = (0, _react.useState)({
      width: 0,
      height: 0
    }),
    _useState6 = _slicedToArray(_useState5, 2),
    tableSize = _useState6[0],
    setTableSize = _useState6[1];
  var _useTableSelection = (0, _useTableSelection3.useTableSelection)(rows, selectedRows, selectedRowsChanged),
    _useTableSelection2 = _slicedToArray(_useTableSelection, 3),
    selectedNumber = _useTableSelection2[0],
    tableSelectionStatus = _useTableSelection2[1],
    selectionMethods = _useTableSelection2[2];
  var classes = useStyles({
    withoutTopBorder: withoutTopBorder,
    selectMode: selectMode,
    stickyHeader: stickyHeader,
    scrolled: scrolled,
    onRowClick: onRowClick
  });
  (0, _react.useEffect)(function () {
    var handleResize = function handleResize() {
      if (refScrolled.current.offsetHeight < refScrolled.current.scrollHeight) setScrolled(refScrolled.current.offsetWidth - refScrolled.current.clientWidth);else setScrolled(0);
    };
    handleResize();
    window.addEventListener("resize", handleResize);

    /* istanbul ignore next */
    return function () {
      return window.removeEventListener("resize", handleResize);
    };
  }, [refScrolled, tableSize.width, tableSize.height]);
  var tableHeaders = buildTableHeaders(headers, classes, customClasses, selectMode, tableSelectionStatus, selectionMethods);
  var tableRows = buildTableRows(rows, classes, customClasses, selectMode, onRowClick, selectionMethods, deepPropsComparation, context, isEditingMode);
  var stickerTableHeader = stickyHeader === true ? /*#__PURE__*/_react.default.createElement(StickerTableHeader, {
    selectMode: selectMode,
    classes: classes,
    tableHeaders: tableHeaders
  }) : null;

  /* istanbul ignore next */
  var onResize = (0, _react.useCallback)(function (width, height) {
    return setTableSize({
      width: width,
      height: height
    });
  }, [setTableSize]);
  return /*#__PURE__*/_react.default.createElement(_TableContainer.default, {
    className: (0, _classnames.default)(classes.container, customClasses.container)
  }, tableInfo, stickerTableHeader, /*#__PURE__*/_react.default.createElement(FullTable, {
    ref: refScrolled,
    classes: classes,
    customClasses: customClasses,
    constrained: constrained,
    onResize: onResize,
    selectedNumber: selectedNumber,
    scrollLoader: scrollLoader,
    tableHeaders: tableHeaders,
    dataRows: rows,
    tableRows: tableRows,
    stickyHeader: stickyHeader,
    latestPage: latestPage,
    pageLength: pageLength,
    placeholder: placeholder,
    deepPropsComparation: deepPropsComparation,
    isEditingMode: isEditingMode,
    context: context,
    tableName: tableName,
    saveScrollbarPosition: saveScrollbarPosition
  }));
}, "useRef{refScrolled}\nuseImperativeHandle{}\nuseState{[scrolled, setScrolled](0)}\nuseState{[tableSize, setTableSize]({ width: 0, height: 0 })}\nuseTableSelection{[selectedNumber, tableSelectionStatus, selectionMethods]}\nuseStyles{classes}\nuseEffect{}\nuseCallback{onResize}", function () {
  return [_react.useImperativeHandle, _useTableSelection3.useTableSelection, useStyles];
}), "useRef{refScrolled}\nuseImperativeHandle{}\nuseState{[scrolled, setScrolled](0)}\nuseState{[tableSize, setTableSize]({ width: 0, height: 0 })}\nuseTableSelection{[selectedNumber, tableSelectionStatus, selectionMethods]}\nuseStyles{classes}\nuseEffect{}\nuseCallback{onResize}", function () {
  return [_react.useImperativeHandle, _useTableSelection3.useTableSelection, useStyles];
}));
var _default = _react.default.memo(Table, function (prev, next) {
  return readOnlyMode(prev.tableProps, next.tableProps) && rowAreIdentical(prev.rows, next.rows) && headersAreIdentical(prev.headers, next.headers);
});
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(headersAreIdentical, "headersAreIdentical", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(readOnlyMode, "readOnlyMode", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(rowAreIdentical, "rowAreIdentical", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(contextIsIdentical, "contextIsIdentical", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(propsAreEqualRow, "propsAreEqualRow", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(propsAreEqualDeeplyRow, "propsAreEqualDeeplyRow", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(TableRowMemo, "TableRowMemo", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(MemoTableRow, "MemoTableRow", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(isInReadOnlyMode, "isInReadOnlyMode", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(propsAreEqualBody, "propsAreEqualBody", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(TableBody, "TableBody", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(MemoTableBody, "MemoTableBody", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(TableCell, "TableCell", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(buildRowCheckbox, "buildRowCheckbox", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(buildTableCheckbox, "buildTableCheckbox", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(StickerTableHeader, "StickerTableHeader", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(buildTableHeaders, "buildTableHeaders", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(buildTableRows, "buildTableRows", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(FullTable, "FullTable", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(DefaultFullTable, "DefaultFullTable", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(FullTableWithSavedScrollbar, "FullTableWithSavedScrollbar", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(Table, "Table", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(useStyles, "useStyles", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(headersAreIdentical, "headersAreIdentical", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(readOnlyMode, "readOnlyMode", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(rowAreIdentical, "rowAreIdentical", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(contextIsIdentical, "contextIsIdentical", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(propsAreEqualRow, "propsAreEqualRow", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(propsAreEqualDeeplyRow, "propsAreEqualDeeplyRow", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(TableRowMemo, "TableRowMemo", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(MemoTableRow, "MemoTableRow", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(isInReadOnlyMode, "isInReadOnlyMode", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(propsAreEqualBody, "propsAreEqualBody", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(TableBody, "TableBody", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(MemoTableBody, "MemoTableBody", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(TableCell, "TableCell", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(buildRowCheckbox, "buildRowCheckbox", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(buildTableCheckbox, "buildTableCheckbox", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(StickerTableHeader, "StickerTableHeader", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(buildTableHeaders, "buildTableHeaders", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(buildTableRows, "buildTableRows", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(FullTable, "FullTable", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(DefaultFullTable, "DefaultFullTable", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(FullTableWithSavedScrollbar, "FullTableWithSavedScrollbar", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(Table, "Table", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/MaterialUI/DataDisplay/Table.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();