var _excluded = ["children", "className", "hasSide", "hideScaling", "hideToolbar", "isFullWidth"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React, { useContext } from 'react';
import classNames from 'classnames';
import { extractChildren } from './helpers/children';
import { StyledHeader } from './partials/StyledHeader';
import { StyledInner } from './partials/StyledInner';
import { StyledTimeline } from './partials/StyledTimeline';
import { TimelineContext } from './context';
import { TimelineDays } from './TimelineDays';
import { TimelineHours } from './TimelineHours';
import { TimelineMonths } from './TimelineMonths';
import { TimelineRows } from './TimelineRows';
import { TimelineTodayMarker } from './TimelineTodayMarker';
import { TimelineToolbar } from './TimelineToolbar';
import { TimelineWeekColumns } from './TimelineWeekColumns';
import { TimelineWeeks } from './TimelineWeeks';
import { useTimelineWidth } from './hooks/useTimelineWidth';
function getRenderColumns(children) {
  var rowsChildren = extractChildren(children, [TimelineRows]);
  return rowsChildren[0].props.render;
}
export var TimelineGrid = function TimelineGrid(_ref) {
  var children = _ref.children,
    className = _ref.className,
    hasSide = _ref.hasSide,
    hideScaling = _ref.hideScaling,
    hideToolbar = _ref.hideToolbar,
    isFullWidth = _ref.isFullWidth,
    rest = _objectWithoutProperties(_ref, _excluded);
  var _useContext = useContext(TimelineContext),
    currentScaleOption = _useContext.state.currentScaleOption;
  var _useTimelineWidth = useTimelineWidth(hasSide, isFullWidth),
    timelineRef = _useTimelineWidth.timelineRef;
  var renderColumns = getRenderColumns(children);
  var rootChildren = extractChildren(children, [TimelineDays, TimelineHours, TimelineMonths, TimelineRows, TimelineTodayMarker, TimelineWeeks], true);
  var headChildren = extractChildren(children, [TimelineDays, TimelineHours, TimelineWeeks, TimelineMonths, TimelineTodayMarker]);
  var bodyChildren = extractChildren(children, [TimelineRows]);
  return /*#__PURE__*/React.createElement(React.Fragment, null, currentScaleOption && !hideToolbar && /*#__PURE__*/React.createElement(TimelineToolbar, {
    hideScaling: hideScaling
  }), /*#__PURE__*/React.createElement(StyledTimeline, _extends({
    className: classNames('timeline', className),
    ref: timelineRef,
    role: "grid"
  }, rest), currentScaleOption && /*#__PURE__*/React.createElement(StyledInner, {
    className: "timeline__inner",
    $hasSide: hasSide
  }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TimelineWeekColumns, {
    render: renderColumns
  }), rootChildren, /*#__PURE__*/React.createElement(StyledHeader, {
    className: "timeline__header",
    role: "rowgroup"
  }, headChildren), bodyChildren))));
};
TimelineGrid.displayName = 'TimelineGrid';