"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

Object.defineProperty(exports, "__esModule", {
  value: 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 _getPrototypeOf3 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));

var _react2 = require("format-message/react");

var _Button = _interopRequireDefault(require("@instructure/ui-buttons/lib/components/Button"));

var _Grid = _interopRequireWildcard(require("@instructure/ui-layout/lib/components/Grid"));

var _lib = _interopRequireDefault(require("@instructure/ui-themeable/lib"));

var _IconUpload = _interopRequireDefault(require("@instructure/ui-icons/lib/Line/IconUpload"));

var _IconComplete = _interopRequireDefault(require("@instructure/ui-icons/lib/Line/IconComplete"));

var _formatMessage = _interopRequireDefault(require("@instructure/quiz-common/lib/format-message"));

var _FileSelector = _interopRequireDefault(require("../../../../common/components/shared/file_selector/FileSelector"));

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'fqArL',
  template: function template(theme) {
    return "\n\n.fqArL_dVrD{color:".concat(theme.uploadIconContainerColor || 'inherit', ";font-size:").concat(theme.uploadIconContainerColorFontSize || 'inherit', ";text-align:right}\n\n[dir=ltr] .fqArL_dVrD,[dir=rtl] .fqArL_dVrD{text-align:right}\n\n.fqArL_brQK{color:").concat(theme.checkIconContainerColor || 'inherit', ";font-size:").concat(theme.checkIconContainerFontSize || 'inherit', ";text-align:right}\n\n[dir=ltr] .fqArL_brQK,[dir=rtl] .fqArL_brQK{text-align:right}\n\n.fqArL_kOWE{color:").concat(theme.smallTextColor || 'inherit', ";font-size:").concat(theme.smallTextFontSize || 'inherit', ";padding:0 ").concat(theme.smallTextPadding || 'inherit', "}\n\n.fqArL_ddCj{margin-top:").concat(theme.selectorMargin || 'inherit', "}\n\n.fqArL_cHlQ{color:").concat(theme.fileListSuccessColor || 'inherit', "}");
  },
  'uploadIconContainer': 'fqArL_dVrD',
  'checkIconContainer': 'fqArL_brQK',
  'smallText': 'fqArL_kOWE',
  'selector': 'fqArL_ddCj',
  'fileListSuccess': 'fqArL_cHlQ'
};

var _ref =
/*#__PURE__*/
_react.default.createElement("span", {
  key: "1"
});

var _ref2 =
/*#__PURE__*/
_react.default.createElement(_IconUpload.default, null);

var _ref3 =
/*#__PURE__*/
_react.default.createElement(_IconComplete.default, null);

var _ref4 =
/*#__PURE__*/
_react.default.createElement(_Button.default, {
  key: "1"
});

var ImportFileSelector = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(ImportFileSelector, _Component);

  function ImportFileSelector() {
    var _getPrototypeOf2;

    var _this;

    (0, _classCallCheck2.default)(this, ImportFileSelector);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = (0, _possibleConstructorReturn2.default)(this, (_getPrototypeOf2 = (0, _getPrototypeOf3.default)(ImportFileSelector)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _this.renderFileList = function () {
      var fileName = _this.props.files.get(0).name;

      return _react.default.createElement("div", null, (0, _react2.formatChildren)("<0>" + fileName + "</0> <1>er klar.</1>", [_react.default.createElement("span", {
        className: styles.fileListSuccess,
        key: "0"
      }), _ref]));
    };

    return _this;
  }

  (0, _createClass2.default)(ImportFileSelector, [{
    key: "renderUploadIcon",
    value: function renderUploadIcon() {
      return _react.default.createElement("div", {
        className: styles.uploadIconContainer
      }, _ref2);
    }
  }, {
    key: "renderCheckmarkIcon",
    value: function renderCheckmarkIcon() {
      return _react.default.createElement("div", {
        className: styles.checkIconContainer
      }, _ref3);
    }
  }, {
    key: "renderFilePickerText",
    value: function renderFilePickerText() {
      return _react.default.createElement("div", null, (0, _react2.formatChildren)("Tr\xE6k og slip her <0>eller</0> <1>Browse</1>", [_react.default.createElement("span", {
        className: styles.smallText,
        key: "0"
      }), _ref4]));
    }
  }, {
    key: "renderWrapper",
    value: function renderWrapper(renderIcon, renderText) {
      return _react.default.createElement(_Grid.default, null, _react.default.createElement(_Grid.GridRow, {
        vAlign: "middle"
      }, _react.default.createElement(_Grid.GridCol, {
        width: 3
      }, renderIcon()), _react.default.createElement(_Grid.GridCol, null, renderText())));
    }
  }, {
    key: "renderContent",
    value: function renderContent() {
      if (this.props.files && this.props.files.size) {
        return this.renderWrapper(this.renderCheckmarkIcon, this.renderFileList);
      } else {
        return this.renderWrapper(this.renderUploadIcon, this.renderFilePickerText);
      }
    }
  }, {
    key: "render",
    value: function render() {
      return _react.default.createElement("div", {
        className: styles.selector
      }, _react.default.createElement(_FileSelector.default, {
        content: this.renderContent(),
        fileHandler: this.props.receiveFile,
        acceptAttribute: this.props.acceptAttribute
      }));
    }
  }]);
  ImportFileSelector.displayName = "ImportFileSelector";
  return ImportFileSelector;
}(_react.Component), _class2.propTypes = {
  files: _reactImmutableProptypes.default.list.isRequired,
  receiveFile: _propTypes.default.func.isRequired,
  acceptAttribute: _propTypes.default.string.isRequired
}, _temp)) || _class);
exports.default = ImportFileSelector;