import _extends from "@babel/runtime/helpers/esm/extends";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["className", "fullWidth", "size", "withRoundButton", "inputClassName", "buttonType"];
import * as React from 'react';
import cx from 'classnames';
import Input, { COLOR, SIZE } from '../form-elements/Input';
import Icon from '../icons/Icon';
import Button from '../buttons/Button';

// TODO: make back to spread (...InputModule.InputPropsType) after flow bump
var Search = function Search(_ref) {
  var _cx;

  var className = _ref.className,
      fullWidth = _ref.fullWidth,
      size = _ref.size,
      _ref$withRoundButton = _ref.withRoundButton,
      withRoundButton = _ref$withRoundButton === void 0 ? false : _ref$withRoundButton,
      inputClassName = _ref.inputClassName,
      buttonType = _ref.buttonType,
      additionalProps = _objectWithoutProperties(_ref, _excluded);

  var baseClassName = 'sg-search';
  var searchClassName = cx(baseClassName, (_cx = {}, _defineProperty(_cx, "sg-search--".concat(String(size)), size), _defineProperty(_cx, 'sg-search--full-width', fullWidth), _cx), className);
  return /*#__PURE__*/React.createElement("div", {
    className: searchClassName
  }, /*#__PURE__*/React.createElement(Input, _extends({}, additionalProps, {
    type: "search",
    withIcon: true,
    size: size,
    className: cx("".concat(baseClassName, "__input"), inputClassName),
    fullWidth: true
  })), /*#__PURE__*/React.createElement("div", {
    className: cx(["".concat(baseClassName, "-icon-wrapper"), "".concat(baseClassName, "-icon-wrapper--").concat(size)])
  }, /*#__PURE__*/React.createElement(Button, {
    variant: withRoundButton ? 'solid' : 'transparent-light',
    className: cx(["".concat(baseClassName, "__icon"), "".concat(baseClassName, "__icon--").concat(size), _defineProperty({}, "".concat(baseClassName, "__icon--transparent"), !withRoundButton)]),
    icon: /*#__PURE__*/React.createElement(Icon, {
      type: "search",
      size: size === 'l' ? 24 : 16,
      color: "adaptive"
    }),
    iconOnly: true,
    size: size === 'l' ? 'm' : 's',
    type: buttonType
  })));
};

export default Search;
export { SIZE, COLOR };