"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
exports.__esModule = true;
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireDefault(require("react"));
var _Input = _interopRequireDefault(require("../Input"));
var _InputWithOptions2 = _interopRequireWildcard(require("../InputWithOptions/InputWithOptions"));
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/AutoComplete/AutoComplete.jsx",
  _AutoComplete;
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var AutoComplete = /*#__PURE__*/function (_InputWithOptions) {
  function AutoComplete() {
    (0, _classCallCheck2["default"])(this, AutoComplete);
    return _callSuper(this, AutoComplete, arguments);
  }
  (0, _inherits2["default"])(AutoComplete, _InputWithOptions);
  return (0, _createClass2["default"])(AutoComplete, [{
    key: "dropdownAdditionalProps",
    value: function dropdownAdditionalProps() {
      var _this$props = this.props,
        options = _this$props.options,
        predicate = _this$props.predicate,
        emptyStateMessage = _this$props.emptyStateMessage,
        onEmptyState = _this$props.onEmptyState;
      var filterFunc = this.state.isEditing ? predicate : function () {
        return true;
      };
      var filtered = options.filter(filterFunc);
      if (filtered.length === 0) {
        onEmptyState == null || onEmptyState();
        return emptyStateMessage ? {
          options: [{
            id: 'empty-state-message',
            value: emptyStateMessage,
            disabled: true
          }]
        } : {
          options: []
        };
      } else {
        return {
          options: filtered
        };
      }
    }
  }]);
}(_InputWithOptions2["default"]);
_AutoComplete = AutoComplete;
AutoComplete.displayName = 'AutoComplete';
AutoComplete.defaultProps = {
  predicate: function predicate() {
    return true;
  },
  autoSelect: true,
  border: 'standard',
  clearButton: false,
  closeOnSelect: true,
  dropdownOffsetLeft: '0',
  dropdownWidth: null,
  hasMore: false,
  hideStatusSuffix: false,
  inContainer: false,
  infiniteScroll: false,
  loadMore: null,
  markedOption: false,
  maxHeightPixels: 260,
  maxLength: 524288,
  options: [],
  overflow: 'auto',
  selectedHighlight: true,
  showOptionsIfEmptyInput: true,
  textOverflow: 'clip',
  onSelect: function onSelect() {},
  inputElement: /*#__PURE__*/_react["default"].createElement(_Input["default"], {
    __self: _AutoComplete,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 31,
      columnNumber: 19
    }
  }),
  popoverProps: _InputWithOptions2.DEFAULT_POPOVER_PROPS,
  tabIndex: 0,
  autocomplete: 'off'
};
var _default = exports["default"] = AutoComplete;