text: function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  
  import React, { Component } from 'react';
  import PropTypes from 'prop-types';
  import { intlShape } from 'react-intl';
  import { Field, reduxForm } from 'redux-form';
  import { TextField } from 'redux-form-material-ui';
  import Avatar from '@material-ui/core/Avatar';
  import IconButton from '@material-ui/core/IconButton';
  import Icon from '@material-ui/core/Icon';
  import Switch from '@material-ui/core/Switch';
  import classNames from 'classnames';
  import { withTheme, withStyles } from '@material-ui/core/styles';
  import withAppConfigs from '../../utils/withAppConfigs';
  import { GoogleIcon, FacebookIcon, GitHubIcon, TwitterIcon } from '../../components/Icons';
  import FormGroup from '@material-ui/core/FormGroup';
  import FormControlLabel from '@material-ui/core/FormControlLabel';
  import Typography from '@material-ui/core/Typography';
  
  var styles = function styles(theme) {
    return {
      avatar: {
        margin: 10
      },
      bigAvatar: {
        width: 120,
        height: 120
      },
      margin: {
        margin: theme.spacing.unit
      },
      withoutLabel: {
        marginTop: theme.spacing.unit * 3
      },
      root: {
        backgroundColor: theme.palette.background.default,
        display: 'flex',
        flexDirection: 'column',
        alignItems: 'center'
      }
    };
  };
  
  var UserForm = function (_Component) {
    _inherits(UserForm, _Component);
  
    function UserForm() {
      var _temp, _this, _ret;
  
      _classCallCheck(this, UserForm);
  
      for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.isLinkedWithProvider = function (provider) {
        var auth = _this.props.auth;
  
  
        try {
          return auth && auth.providerData && auth.providerData.find(function (p) {
            return p.providerId === provider;
          }) !== undefined;
        } catch (e) {
          return false;
        }
      }, _this.getProviderIcon = function (p) {
        var theme = _this.props.theme;
  
        var color = 'primary';
  
        switch (p) {
          case 'google.com':
            return React.createElement(GoogleIcon, null);
  
          case 'facebook.com':
            return React.createElement(FacebookIcon, null);
  
          case 'twitter.com':
            return React.createElement(TwitterIcon, null);
  
          case 'github.com':
            return React.createElement(GitHubIcon, null);
  
          default:
            return undefined;
        }
      }, _temp), _possibleConstructorReturn(_this, _ret);
    }
  
    UserForm.prototype.render = function render() {
      var _this2 = this;
  
      var _props = this.props,
          handleSubmit = _props.handleSubmit,
          intl = _props.intl,
          initialized = _props.initialized,
          uid = _props.uid,
          handleAdminChange = _props.handleAdminChange,
          isAdmin = _props.isAdmin,
          photoURL = _props.photoURL,
          classes = _props.classes,
          appConfig = _props.appConfig,
          displayName = _props.displayName,
          values = _props.values;
  
  
      return React.createElement(
        'div',
        { className: classes.root },
        values.photoURL && React.createElement(Avatar, {
          alt: '',
          src: values.photoURL,
          className: classNames(classes.avatar, classes.bigAvatar)
        }),
        !values.photoURL && React.createElement(
          Avatar,
          { className: classNames(classes.avatar, classes.bigAvatar) },
          ' ',
          React.createElement(
            Icon,
            { style: { fontSize: 60 } },
            ' person '
          ),
          '  '
        ),
        React.createElement(
          'div',
          null,
          appConfig.firebase_providers.map(function (p, i) {
            if (p !== 'email' && p !== 'password' && p !== 'phone') {
              return React.createElement(
                IconButton,
                {
                  key: i,
                  disabled: !_this2.isLinkedWithProvider(p),
                  color: 'primary'
                },
                _this2.getProviderIcon(p)
              );
            } else {
              return React.createElement('div', { key: i });
            }
          })
        ),
        React.createElement('br', null),
        React.createElement(
          Typography,
          { variant: 'display1', gutterBottom: true },
          values.displayName
        ),
        React.createElement(
          'div',
          null,
          React.createElement(FormControlLabel, {
            control: React.createElement(Switch, {
              checked: isAdmin,
              onChange: handleAdminChange
            }),
            label: intl.formatMessage({ id: 'is_admin_label' })
          })
        )
      );
    };
  
    return UserForm;
  }(Component);
  
  UserForm.propTypes = process.env.NODE_ENV !== "production" ? {
    handleSubmit: PropTypes.func.isRequired,
    handleAdminChange: PropTypes.func.isRequired,
    isAdmin: PropTypes.bool.isRequired,
    intl: intlShape.isRequired,
    initialized: PropTypes.bool.isRequired,
    uid: PropTypes.string.isRequired
  } : {};
  
  export default withAppConfigs(withStyles(styles, { withTheme: true })(UserForm));