import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
var _excluded = ["iconDescription", "status", "style"];

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

/* eslint react/no-multi-comp: "off" */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Icon from '../Icon';
import { iconCloseGlyph, iconCheckmarkGlyph } from '@wfp/icons-react';
import { settings } from '../../globals/js';
var prefix = settings.prefix;
export var Filename = /*#__PURE__*/function (_Component) {
  _inherits(Filename, _Component);

  var _super = _createSuper(Filename);

  function Filename() {
    _classCallCheck(this, Filename);

    return _super.apply(this, arguments);
  }

  _createClass(Filename, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          iconDescription = _this$props.iconDescription,
          status = _this$props.status,
          style = _this$props.style,
          other = _objectWithoutProperties(_this$props, _excluded);

      if (status === 'uploading') {
        return /*#__PURE__*/React.createElement("div", _extends({
          className: "".concat(prefix, "--loading"),
          style: _objectSpread(_objectSpread({}, style), {}, {
            width: '1rem',
            height: '1rem'
          })
        }, other), /*#__PURE__*/React.createElement("svg", {
          className: "".concat(prefix, "--loading__svg"),
          viewBox: "-42 -42 84 84"
        }, /*#__PURE__*/React.createElement("circle", {
          cx: "0",
          cy: "0",
          r: "37.5"
        })));
      } else if (status === 'edit') {
        return /*#__PURE__*/React.createElement(Icon, _extends({
          description: iconDescription,
          className: "".concat(prefix, "--file-close"),
          icon: iconCloseGlyph,
          style: style
        }, other));
      } else if (status === 'complete') {
        return /*#__PURE__*/React.createElement(Icon, _extends({
          description: iconDescription,
          className: "".concat(prefix, "--file-complete"),
          icon: iconCheckmarkGlyph,
          style: style
        }, other));
      } else {
        return null;
      }
    }
  }]);

  return Filename;
}(Component);

_defineProperty(Filename, "propTypes", {
  /**
   * Specify an optional object of styles to be applied inline to the root
   * node
   */
  style: PropTypes.object,

  /**
   * Specify the status of the File Upload
   */
  status: PropTypes.oneOf(['edit', 'complete', 'uploading']),

  /**
   * Provide a description for the complete/close icon that can be read by screen readers
   */
  iconDescription: PropTypes.string
});

_defineProperty(Filename, "defaultProps", {
  onKeyDown: function onKeyDown() {},
  status: 'uploading',
  style: {},
  tabIndex: 0
});