"use strict";

exports.__esModule = true;
exports.FilePreviewModal = void 0;
var _react = _interopRequireWildcard(require("react"));
var _designSystem = require("@wix/design-system");
var _resolveFileByMediaType = require("./resolveFileByMediaType");
var _useDownloadFile = require("./useDownloadFile");
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _react2 = require("@wix/bex-core/react");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/FileCard/FilePreviewModal.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const FilePreviewModal = ({
  file,
  isOpen,
  close,
  showDetails
}) => {
  const {
    translate: t
  } = (0, _react2.useWixPatternsContainer)();
  const {
    downloadFile,
    isDownloading
  } = (0, _useDownloadFile.useDownloadFile)({
    file
  });
  const {
    fileUrl
  } = (0, _resolveFileByMediaType.resolveFileByMediaType)(file, showDetails);
  const prefixIcon = (0, _react.useMemo)(() => /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    verticalAlign: "middle",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 31,
      columnNumber: 7
    }
  }, isDownloading ? /*#__PURE__*/_react.default.createElement(_designSystem.Loader, {
    size: "tiny",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 32,
      columnNumber: 26
    }
  }) : /*#__PURE__*/_react.default.createElement(_wixUiIconsCommon.Download, {
    size: "small",
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 32,
      columnNumber: 51
    }
  })), [isDownloading]);
  return /*#__PURE__*/_react.default.createElement(_designSystem.Modal, {
    isOpen: isOpen,
    onRequestClose: close,
    shouldCloseOnOverlayClick: true,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 38,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.CustomModalLayout, {
    title: file.displayName,
    onCloseButtonClick: close,
    primaryButtonText: t('cairo.customFields.fileUpload.download.cta'),
    primaryButtonProps: {
      prefixIcon
    },
    primaryButtonOnClick: downloadFile,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 39,
      columnNumber: 7
    }
  }, file.mediaType === 'video' ? /*#__PURE__*/_react.default.createElement("video", {
    controls: true,
    style: {
      width: '100%',
      height: 'auto',
      maxHeight: '70vh',
      margin: '0 auto'
    },
    src: fileUrl,
    autoPlay: false,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 49,
      columnNumber: 11
    }
  }) : /*#__PURE__*/_react.default.createElement(_designSystem.Image, {
    style: {
      height: '500px',
      width: '500px',
      objectFit: 'contain'
    },
    src: fileUrl,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 61,
      columnNumber: 11
    }
  })));
};
exports.FilePreviewModal = FilePreviewModal;
//# sourceMappingURL=FilePreviewModal.js.map