"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.resolveFileByMediaType = exports.THUMB_WIDTH = exports.SMALL_THUMB_WIDTH = void 0;
var _designSystem = require("@wix/design-system");
var _sdk = require("@wix/sdk");
var _react = _interopRequireDefault(require("react"));
var _icons = require("./icons");
var _lodash = require("lodash");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/FileCard/resolveFileByMediaType.tsx";
const THUMB_WIDTH = exports.THUMB_WIDTH = 48;
const SMALL_THUMB_WIDTH = exports.SMALL_THUMB_WIDTH = 36;
const resolveFileByMediaType = exports.resolveFileByMediaType = (0, _lodash.memoize)(({
  mediaType,
  mediaId
}, showDetails) => {
  let thumbnail;
  let fileUrl;
  switch (mediaType) {
    case 'audio':
      {
        const audio = _sdk.media.getAudioUrl(`wix:audio://v1/${mediaId}`);
        fileUrl = audio.url;
        thumbnail = _icons.audioIcon;
        break;
      }
    case 'video':
      {
        const video = _sdk.media.getVideoUrl(`wix:video://v1/${mediaId}`);
        fileUrl = video.url;
        thumbnail = _icons.videoIcon;
        break;
      }
    case 'picture':
      {
        const image = _sdk.media.getImageUrl(`wix:image://v1/${mediaId}`);
        const thumbImage = _sdk.media.getScaledToFillImageUrl(image.url, THUMB_WIDTH + 20, THUMB_WIDTH + 20, {});
        fileUrl = image.url;
        thumbnail = /*#__PURE__*/_react.default.createElement(_designSystem.Image, {
          src: thumbImage,
          style: {
            height: showDetails ? `${THUMB_WIDTH}px` : `${SMALL_THUMB_WIDTH}px`,
            width: showDetails ? `${THUMB_WIDTH}px` : `${SMALL_THUMB_WIDTH}px`,
            minHeight: showDetails ? `${THUMB_WIDTH}px` : `${SMALL_THUMB_WIDTH}px`,
            minWidth: showDetails ? `${THUMB_WIDTH}px` : `${SMALL_THUMB_WIDTH}px`,
            maxHeight: showDetails ? `${THUMB_WIDTH}px` : `${SMALL_THUMB_WIDTH}px`,
            maxWidth: showDetails ? `${THUMB_WIDTH}px` : `${SMALL_THUMB_WIDTH}px`
          },
          fit: "cover",
          borderRadius: 5,
          __self: void 0,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 42,
            columnNumber: 11
          }
        });
        break;
      }
    case 'document':
      {
        const document = _sdk.media.getDocumentUrl(`wix:document://v1/${mediaId}`);
        fileUrl = document.url;
        thumbnail = fileUrl.toLowerCase().endsWith('.pdf') ? _icons.pdfIcon : _icons.docIcon;
        break;
      }
    default:
      {
        const document = _sdk.media.getDocumentUrl(`wix:document://v1/${mediaId}`);
        fileUrl = document.url;
        thumbnail = _icons.defaultIcon;
        break;
      }
  }
  return {
    thumbnail,
    fileUrl
  };
});
//# sourceMappingURL=resolveFileByMediaType.js.map