"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = UploadFileStatusMessage;
var _react = _interopRequireDefault(require("react"));
var _progressBar = require("../progress-bar");
var _fileUploaderHelpers = require("./file-uploader-helpers");
var _useTranslation = require("../hooks/use-translation");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function UploadFileStatusMessage({
  isExpanded = false,
  completed = false,
  size = 0,
  details = '',
  showProgressBar = false,
  progressBarFile = {},
  showFileSize = true,
  showStatusMessage = true
}) {
  const {
    t
  } = (0, _useTranslation.useTranslation)();
  const {
    progress = 0,
    statusMessage = t('Uploading...'),
    overrideStatusMessage = false,
    forceShowProgressBar = false
  } = progressBarFile;
  if (completed && !forceShowProgressBar) {
    if (!showFileSize) {
      return null;
    }
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      className: "file-uploader-file-size-message-wrapper",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
        className: "file-uploader-file-size-message",
        "test-id": "file-uploader-file-size-message",
        children: overrideStatusMessage ? statusMessage : details || (0, _fileUploaderHelpers.bytesToSize)(size)
      })
    });
  }
  const progressBarContent = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: "file-uploader-progress-bar",
    "test-id": "file-uploader-progress-bar",
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_progressBar.ProgressBar, {
      value: progress,
      max: 100,
      ariaLabel: statusMessage
    })
  });
  const isProgressBarShown = showProgressBar || forceShowProgressBar;
  if (isExpanded) {
    return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
        className: "file-uploader-expanded-uploading-message",
        "test-id": "file-uploader-uploading-message",
        children: statusMessage
      }), isProgressBarShown && progressBarContent]
    });
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
      className: "file-uploader-uploading-message",
      "test-id": "file-uploader-uploading-message",
      children: [isProgressBarShown && progressBarContent, showStatusMessage && statusMessage]
    })
  });
}