"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _base = _interopRequireDefault(require("@emotion/styled/base"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _MediaLibrarySearch = _interopRequireDefault(require("./MediaLibrarySearch"));
var _MediaLibraryHeader = _interopRequireDefault(require("./MediaLibraryHeader"));
var _MediaLibraryButtons = require("./MediaLibraryButtons");
var _react2 = require("@emotion/react");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
const LibraryTop = /*#__PURE__*/(0, _base.default)("div", {
  target: "e1n0ky5z2",
  label: "LibraryTop"
})(process.env.NODE_ENV === "production" ? {
  name: "16hjiy4",
  styles: "position:relative;display:flex;flex-direction:column"
} : {
  name: "16hjiy4",
  styles: "position:relative;display:flex;flex-direction:column",
  map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 5840 characters] */",
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
});
const RowContainer = /*#__PURE__*/(0, _base.default)("div", {
  target: "e1n0ky5z1",
  label: "RowContainer"
})(process.env.NODE_ENV === "production" ? {
  name: "1eoy87d",
  styles: "display:flex;justify-content:space-between"
} : {
  name: "1eoy87d",
  styles: "display:flex;justify-content:space-between",
  map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 5840 characters] */",
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
});
const ButtonsContainer = /*#__PURE__*/(0, _base.default)("div", {
  target: "e1n0ky5z0",
  label: "ButtonsContainer"
})(process.env.NODE_ENV === "production" ? {
  name: "ozd7xs",
  styles: "flex-shrink:0"
} : {
  name: "ozd7xs",
  styles: "flex-shrink:0",
  map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 5840 characters] */",
  toString: _EMOTION_STRINGIFIED_CSS_ERROR__
});
function MediaLibraryTop({
  t,
  onClose,
  privateUpload,
  forImage,
  onDownload,
  onUpload,
  query,
  onSearchChange,
  onSearchKeyDown,
  searchDisabled,
  onDelete,
  canInsert,
  onInsert,
  hasSelection,
  isPersisting,
  isDeleting,
  selectedFile
}) {
  const shouldShowButtonLoader = isPersisting || isDeleting;
  const uploadEnabled = !shouldShowButtonLoader;
  const deleteEnabled = !shouldShowButtonLoader && hasSelection;
  const uploadButtonLabel = isPersisting ? t('mediaLibrary.mediaLibraryModal.uploading') : t('mediaLibrary.mediaLibraryModal.upload');
  const deleteButtonLabel = isDeleting ? t('mediaLibrary.mediaLibraryModal.deleting') : t('mediaLibrary.mediaLibraryModal.deleteSelected');
  const downloadButtonLabel = t('mediaLibrary.mediaLibraryModal.download');
  const insertButtonLabel = t('mediaLibrary.mediaLibraryModal.chooseSelected');
  return (0, _react2.jsx)(LibraryTop, null, (0, _react2.jsx)(RowContainer, null, (0, _react2.jsx)(_MediaLibraryHeader.default, {
    onClose: onClose,
    title: `${privateUpload ? t('mediaLibrary.mediaLibraryModal.private') : ''}${forImage ? t('mediaLibrary.mediaLibraryModal.images') : t('mediaLibrary.mediaLibraryModal.mediaAssets')}`,
    isPrivate: privateUpload
  }), (0, _react2.jsx)(ButtonsContainer, null, (0, _react2.jsx)(_MediaLibraryButtons.CopyToClipBoardButton, {
    disabled: !hasSelection,
    path: selectedFile.path,
    name: selectedFile.name,
    draft: selectedFile.draft,
    t: t
  }), (0, _react2.jsx)(_MediaLibraryButtons.DownloadButton, {
    onClick: onDownload,
    disabled: !hasSelection
  }, downloadButtonLabel), (0, _react2.jsx)(_MediaLibraryButtons.UploadButton, {
    label: uploadButtonLabel,
    imagesOnly: forImage,
    onChange: onUpload,
    disabled: !uploadEnabled
  }))), (0, _react2.jsx)(RowContainer, null, (0, _react2.jsx)(_MediaLibrarySearch.default, {
    value: query,
    onChange: onSearchChange,
    onKeyDown: onSearchKeyDown,
    placeholder: t('mediaLibrary.mediaLibraryModal.search'),
    disabled: searchDisabled
  }), (0, _react2.jsx)(ButtonsContainer, null, (0, _react2.jsx)(_MediaLibraryButtons.DeleteButton, {
    onClick: onDelete,
    disabled: !deleteEnabled
  }, deleteButtonLabel), !canInsert ? null : (0, _react2.jsx)(_MediaLibraryButtons.InsertButton, {
    onClick: onInsert,
    disabled: !hasSelection
  }, insertButtonLabel))));
}
MediaLibraryTop.propTypes = {
  t: _propTypes.default.func.isRequired,
  onClose: _propTypes.default.func.isRequired,
  privateUpload: _propTypes.default.bool,
  forImage: _propTypes.default.bool,
  onDownload: _propTypes.default.func.isRequired,
  onUpload: _propTypes.default.func.isRequired,
  query: _propTypes.default.string,
  onSearchChange: _propTypes.default.func.isRequired,
  onSearchKeyDown: _propTypes.default.func.isRequired,
  searchDisabled: _propTypes.default.bool.isRequired,
  onDelete: _propTypes.default.func.isRequired,
  canInsert: _propTypes.default.bool,
  onInsert: _propTypes.default.func.isRequired,
  hasSelection: _propTypes.default.bool.isRequired,
  isPersisting: _propTypes.default.bool,
  isDeleting: _propTypes.default.bool,
  selectedFile: _propTypes.default.oneOfType([_propTypes.default.shape({
    path: _propTypes.default.string.isRequired,
    draft: _propTypes.default.bool.isRequired,
    name: _propTypes.default.string.isRequired
  }), _propTypes.default.shape({})])
};
var _default = exports.default = MediaLibraryTop;