import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children", "type"];
import React from 'react';
import { ReactEditorViewContext } from '../../ui-react';
import { ColorPaletteArrowKeyNavigationProvider } from './ColorPaletteArrowKeyNavigationProvider';
import { MenuArrowKeyNavigationProvider } from './MenuArrowKeyNavigationProvider';
import { ArrowKeyNavigationType } from './types';
export var ArrowKeyNavigationProvider = function ArrowKeyNavigationProvider(props) {
  var children = props.children,
    type = props.type,
    restProps = _objectWithoutProperties(props, _excluded);
  if (type === ArrowKeyNavigationType.COLOR) {
    return /*#__PURE__*/React.createElement(ReactEditorViewContext.Consumer, null, function (_ref) {
      var editorView = _ref.editorView,
        editorRef = _ref.editorRef;
      return editorRef && /*#__PURE__*/React.createElement(ColorPaletteArrowKeyNavigationProvider, _extends({
        selectedRowIndex: props.selectedRowIndex,
        selectedColumnIndex: props.selectedColumnIndex,
        isOpenedByKeyboard: props.isOpenedByKeyboard,
        isPopupPositioned: props.isPopupPositioned,
        editorRef: editorRef
      }, restProps), children);
    });
  }
  return /*#__PURE__*/React.createElement(ReactEditorViewContext.Consumer, null, function (_ref2) {
    var editorView = _ref2.editorView,
      editorRef = _ref2.editorRef;
    return editorRef && /*#__PURE__*/React.createElement(MenuArrowKeyNavigationProvider, _extends({
      editorRef: editorRef
    }, restProps), children);
  });
};