"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.generateVirtualizedContainerDatum = generateVirtualizedContainerDatum;
exports.getScrollbarWidth = getScrollbarWidth;
var _constants = require("../../constants");
var _getColumnCount = require("./getColumnCount");
function generateVirtualizedContainerDatum(containerWidth, options) {
  var scrollbarWidth = options.scrollbarWidth;
  var columnCount = (0, _getColumnCount.getColumnCount)(containerWidth);
  var availableWidth = containerWidth - (scrollbarWidth + _constants.ELEMENT_LIST_PADDING);
  return {
    availableWidth: availableWidth,
    columnCount: columnCount
  };
}
var CALCULATED_SCROLLBAR_WIDTH;

// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
function getScrollbarWidth() {
  if (!CALCULATED_SCROLLBAR_WIDTH) {
    var _container$parentNode;
    var container = document.createElement('div');
    container.style.visibility = 'hidden';
    container.style.overflow = 'scroll';
    document.body.appendChild(container);
    var innerContainer = document.createElement('div');
    container.appendChild(innerContainer);
    var scrollbarWidth = container.offsetWidth - innerContainer.offsetWidth;
    (_container$parentNode = container.parentNode) === null || _container$parentNode === void 0 || _container$parentNode.removeChild(container);
    if (scrollbarWidth) {
      CALCULATED_SCROLLBAR_WIDTH = scrollbarWidth;
      return scrollbarWidth;
    }
    return _constants.SCROLLBAR_WIDTH;
  } else {
    return CALCULATED_SCROLLBAR_WIDTH;
  }
}
// eslint-disable-next-line @atlaskit/editor/no-re-export