import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import React from 'react';
import { TokenInput } from "../../../components/TokenInput";
import { Token } from "../../../components/Token";
function getItems(_x) {
  return _getItems.apply(this, arguments);
}
function _getItems() {
  _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(query) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          return _context.abrupt("return", Promise.resolve(['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth'].filter(function (x) {
            return x.toLowerCase().includes(query.toLowerCase()) || x.toString() === query;
          })).then(function (res) {
            return new Promise(function (resolve) {
              return setTimeout(resolve.bind(null, res), 500);
            });
          }));
        case 1:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
  return _getItems.apply(this, arguments);
}
export var TokenInputPlayground = /*#__PURE__*/function (_React$Component) {
  function TokenInputPlayground() {
    var _this;
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
    _this.state = {
      selectedItems: ['First', 'Second']
    };
    return _this;
  }
  _inheritsLoose(TokenInputPlayground, _React$Component);
  var _proto = TokenInputPlayground.prototype;
  _proto.render = function render() {
    var _this2 = this;
    return /*#__PURE__*/(
      React.createElement(TokenInput, {
        getItems: getItems,
        selectedItems: this.state.selectedItems,
        renderToken: function renderToken(item, _ref) {
          var isActive = _ref.isActive,
            onClick = _ref.onClick,
            onRemove = _ref.onRemove;
          return /*#__PURE__*/(
            React.createElement(Token, {
              key: item.toString(),
              isActive: isActive,
              onClick: onClick,
              onRemove: onRemove
            }, item)
          );
        },
        onValueChange: function onValueChange(itemsNew) {
          return _this2.setState({
            selectedItems: itemsNew
          });
        }
      })
    );
  };
  return TokenInputPlayground;
}(React.Component);