"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _typeof2=require("babel-runtime/helpers/typeof"),_typeof3=_interopRequireDefault(_typeof2),_defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_react=require("react"),React=_interopRequireWildcard(_react),_rcSelect=require("rc-select"),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_select=require("../select"),_select2=_interopRequireDefault(_select),_input=require("../input"),_input2=_interopRequireDefault(_input),_InputElement=require("./InputElement"),_InputElement2=_interopRequireDefault(_InputElement);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function isSelectOptionOrSelectOptGroup(e){return e&&e.type&&(e.type.isSelectOption||e.type.isSelectOptGroup)}var AutoComplete=function(e){function t(){(0,_classCallCheck3.default)(this,t);var l=(0,_possibleConstructorReturn3.default)(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return l.getInputElement=function(){var e=l.props.children,t=e&&React.isValidElement(e)&&e.type!==_rcSelect.Option?React.Children.only(l.props.children):React.createElement(_input2.default,null),r=(0,_extends3.default)({},t.props);return delete r.children,React.createElement(_InputElement2.default,r,t)},l.saveSelect=function(e){l.select=e},l}return(0,_inherits3.default)(t,e),(0,_createClass3.default)(t,[{key:"focus",value:function(){this.select.focus()}},{key:"blur",value:function(){this.select.blur()}},{key:"render",value:function(){var e,t=this.props,r=t.size,l=t.className,n=void 0===l?"":l,i=t.notFoundContent,u=t.prefixCls,o=t.optionLabelProp,a=t.dataSource,s=t.children,p=(0,_classnames2.default)((e={},(0,_defineProperty3.default)(e,u+"-lg","large"===r),(0,_defineProperty3.default)(e,u+"-sm","small"===r),(0,_defineProperty3.default)(e,n,!!n),(0,_defineProperty3.default)(e,u+"-show-search",!0),(0,_defineProperty3.default)(e,u+"-auto-complete",!0),e)),c=void 0,_=React.Children.toArray(s);return c=_.length&&isSelectOptionOrSelectOptGroup(_[0])?s:a?a.map(function(e){if(React.isValidElement(e))return e;switch(void 0===e?"undefined":(0,_typeof3.default)(e)){case"string":return React.createElement(_rcSelect.Option,{key:e},e);case"object":return React.createElement(_rcSelect.Option,{key:e.value},e.text);default:throw new Error("AutoComplete[dataSource] only supports type `string[] | Object[]`.")}}):[],React.createElement(_select2.default,(0,_extends3.default)({},this.props,{className:p,mode:"combobox",optionLabelProp:o,getInputElement:this.getInputElement,notFoundContent:i,ref:this.saveSelect}),c)}}]),t}(React.Component);(exports.default=AutoComplete).Option=_rcSelect.Option,AutoComplete.OptGroup=_rcSelect.OptGroup,AutoComplete.defaultProps={prefixCls:"dt-select",transitionName:"slide-up",optionLabelProp:"children",choiceTransitionName:"zoom",showSearch:!1,filterOption:!1},module.exports=exports.default;