'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports['default'] = getIcons;

var _react = require('react');

var React = _interopRequireWildcard(_react);

var _icon = require('../../icon');

var _icon2 = _interopRequireDefault(_icon);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }

function getIcons(_ref) {
    var suffixIcon = _ref.suffixIcon,
        clearIcon = _ref.clearIcon,
        menuItemSelectedIcon = _ref.menuItemSelectedIcon,
        removeIcon = _ref.removeIcon,
        loading = _ref.loading,
        multiple = _ref.multiple,
        prefixCls = _ref.prefixCls;

    // Clear Icon
    var mergedClearIcon = clearIcon;
    if (!clearIcon) {
        mergedClearIcon = React.createElement(_icon2['default'], { type: 'close-circle' });
    }
    // Arrow item icon
    var mergedSuffixIcon = null;
    if (suffixIcon !== undefined) {
        mergedSuffixIcon = suffixIcon;
    } else if (loading) {
        mergedSuffixIcon = React.createElement(_icon2['default'], { type: 'loading' });
    } else {
        var iconCls = prefixCls + '-suffix';
        mergedSuffixIcon = function mergedSuffixIcon(_ref2) {
            var open = _ref2.open,
                showSearch = _ref2.showSearch;

            if (open && showSearch) {
                return React.createElement(_icon2['default'], { type: 'search', className: iconCls });
            }
            return React.createElement(_icon2['default'], { type: 'down', className: iconCls });
        };
    }
    // Checked item icon
    var mergedItemIcon = null;
    if (menuItemSelectedIcon !== undefined) {
        mergedItemIcon = menuItemSelectedIcon;
    } else if (multiple) {
        mergedItemIcon = React.createElement(_icon2['default'], { type: 'check' });
    } else {
        mergedItemIcon = null;
    }
    var mergedRemoveIcon = null;
    if (removeIcon !== undefined) {
        mergedRemoveIcon = removeIcon;
    } else {
        mergedRemoveIcon = React.createElement(_icon2['default'], { type: 'close' });
    }
    return {
        clearIcon: mergedClearIcon,
        suffixIcon: mergedSuffixIcon,
        menuItemSelectedIcon: mergedItemIcon,
        removeIcon: mergedRemoveIcon
    };
}
module.exports = exports['default'];