import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import React, { Component } from 'react';
import { EmailCrawler as EmailComponent } from './component';
export var EmailContainer =
/*#__PURE__*/
function (_Component) {
  _inherits(EmailContainer, _Component);

  function EmailContainer(props) {
    var _this;

    _classCallCheck(this, EmailContainer);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(EmailContainer).call(this, props));
    _this.state = void 0;

    _this.handleChange = function (e) {
      _this.setState({
        email: e.currentTarget.value
      });
    };

    _this.handleSubmit = function () {
      _this.props.onSubmit(_this.state.email);
    };

    _this.handleEmailValid = function (valid) {
      _this.setState({
        valid: valid
      });
    };

    _this.state = {
      email: '',
      valid: false
    };
    return _this;
  }

  _createClass(EmailContainer, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          labels = _this$props.labels,
          messages = _this$props.messages;
      var props = {
        labels: labels,
        value: this.state.email,
        onSubmit: this.handleSubmit,
        onChange: this.handleChange,
        messages: messages,
        valid: this.state.valid,
        onEmailValid: this.handleEmailValid
      };
      return React.createElement(EmailComponent, props);
    }
  }]);

  return EmailContainer;
}(Component);