import React from 'react';
import Icon from '../../icon'; // @ts-ignore

import loadingGif from '../../spin/gif/loading-basic-gray.gif';
var DownLine = Icon.DownLine,
    LoadingLine = Icon.LoadingLine,
    ChooseLine = Icon.ChooseLine,
    CloseLine = Icon.CloseLine,
    CloseFill = Icon.CloseFill,
    SearchLine = Icon.SearchLine;

var GetIcons = function GetIcons(props) {
  var suffixIcon = props.suffixIcon,
      clearIcon = props.clearIcon,
      menuItemSelectedIcon = props.menuItemSelectedIcon,
      loading = props.loading,
      multiple = props.multiple,
      removeIcon = props.removeIcon,
      preCls = props.preCls,
      size = props.size,
      removeOptions = props.removeOptions; // replace clearIcon

  var mergedClearIcon = clearIcon;

  if (!clearIcon) {
    mergedClearIcon = /*#__PURE__*/React.createElement(CloseFill, null);
  } // replace suffixIcon


  var mergedSuffixIcon = null;

  if (suffixIcon !== undefined) {
    mergedSuffixIcon = suffixIcon;
  } else if (loading) {
    // mergedSuffixIcon = React.createElement(LoadingLine, {
    //   // spin: true,
    // });
    var sizeSty = '16px';
    mergedSuffixIcon = /*#__PURE__*/React.createElement("img", {
      src: loadingGif,
      style: {
        width: sizeSty,
        marginTop: -3,
        verticalAlign: 'middle'
      },
      alt: "\u52A0\u8F7D\u4E2D\u3002\u3002\u3002\u3002"
    });
  } else {
    var iconCls = ''.concat(preCls, '-suffix');

    mergedSuffixIcon = function mergedSuffixIcon(ref) {
      var open = ref.open,
          showSearch = ref.showSearch;

      if (open && showSearch) {
        return /*#__PURE__*/React.createElement(SearchLine, {
          className: iconCls
        });
      }

      return /*#__PURE__*/React.createElement(DownLine, {
        className: iconCls
      });
    };
  }

  var mergedItemIcon = null; // if (menuItemSelectedIcon !== undefined) {
  //   mergedItemIcon = menuItemSelectedIcon;
  // } else if (multiple) {
  //   mergedItemIcon = React.createElement(ChooseLine, null);
  // } else {
  //   mergedItemIcon = null;
  // }

  if (menuItemSelectedIcon !== undefined) {
    mergedItemIcon = menuItemSelectedIcon;
  } else {
    mergedItemIcon = /*#__PURE__*/React.createElement(ChooseLine, null);
  } // replace removeIcon


  var mergedRemoveIcon = null;

  if (removeIcon !== undefined) {
    mergedRemoveIcon = removeIcon;
  } else {
    mergedRemoveIcon = /*#__PURE__*/React.createElement(CloseLine, null);
  }

  return {
    clearIcon: mergedClearIcon,
    suffixIcon: mergedSuffixIcon,
    itemIcon: mergedItemIcon,
    removeIcon: mergedRemoveIcon
  };
};

export default GetIcons;