"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.ConnectedUploadInput = void 0;
var _reactRedux = require("react-redux");
var _reactIntl = require("react-intl");
var _cspaceInput = require("cspace-input");
var _reducers = require("../../reducers");
var _prefs = require("../../actions/prefs");
const {
  UploadInput
} = _cspaceInput.components;
const messages = (0, _reactIntl.defineMessages)({
  typeInputLabel: {
    "id": "UploadInputContainer.typeInputLabel",
    "defaultMessage": "Upload"
  },
  fileOptionLabel: {
    "id": "UploadInputContainer.fileOptionLabel",
    "defaultMessage": "local file"
  },
  urlOptionLabel: {
    "id": "UploadInputContainer.urlOptionLabel",
    "defaultMessage": "external media"
  },
  fileInputLabel: {
    "id": "UploadInputContainer.fileInputLabel",
    "defaultMessage": "File"
  },
  fileChooseButtonLabel: {
    "id": "UploadInputContainer.fileChooseButtonLabel",
    "defaultMessage": "Select\u2026"
  },
  urlInputLabel: {
    "id": "UploadInputContainer.urlInputLabel",
    "defaultMessage": "URL"
  },
  fileInfo: {
    "id": "UploadInputContainer.fileInfo",
    "defaultMessage": "{name} ({type}, {size, number} bytes)"
  }
});
const mapStateToProps = state => ({
  type: (0, _reducers.getUploadType)(state)
});
const mapDispatchToProps = {
  onTypeChanged: _prefs.setUploadType
};
const mergeProps = (stateProps, dispatchProps, ownProps) => {
  const {
    intl,
    ...remainingOwnProps
  } = ownProps;
  const intlProps = {
    typeInputLabel: intl.formatMessage(messages.typeInputLabel),
    fileOptionLabel: intl.formatMessage(messages.fileOptionLabel),
    urlOptionLabel: intl.formatMessage(messages.urlOptionLabel),
    fileInputLabel: intl.formatMessage(messages.fileInputLabel),
    fileChooseButtonLabel: intl.formatMessage(messages.fileChooseButtonLabel),
    urlInputLabel: intl.formatMessage(messages.urlInputLabel),
    formatFileInfo: (name, type, size) => intl.formatMessage(messages.fileInfo, {
      name,
      type,
      size
    })
  };
  return {
    ...remainingOwnProps,
    ...stateProps,
    ...dispatchProps,
    ...intlProps
  };
};
const ConnectedUploadInput = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps, mergeProps)(UploadInput);
exports.ConnectedUploadInput = ConnectedUploadInput;
const IntlizedUploadInput = (0, _reactIntl.injectIntl)(ConnectedUploadInput);
IntlizedUploadInput.propTypes = UploadInput.propTypes;
var _default = IntlizedUploadInput;
exports.default = _default;