import React from 'react';
import { Select } from '@looker/components';
import { useHistory, useLocation } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { selectSpecs } from '../../state';
export var ApiSpecSelector = _ref => {
  var {
    spec
  } = _ref;
  var history = useHistory();
  var location = useLocation();
  var specs = useSelector(selectSpecs);
  var options = Object.entries(specs).map(_ref2 => {
    var [key, spec] = _ref2;
    return {
      value: key,
      label: key,
      description: spec.status
    };
  });

  var handleChange = specKey => {
    var matchPath = location.pathname.replace("/".concat(spec.key), "/".concat(specKey));
    history.push(matchPath);
  };

  return React.createElement(Select, {
    width: "10rem",
    "aria-label": "spec selector",
    defaultValue: spec.key,
    options: options,
    onChange: handleChange
  });
};
//# sourceMappingURL=ApiSpecSelector.js.map