'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.originalImage = exports.originalJpegImage = exports.mediumImage = exports.smallImage = exports.thumbnailImage = exports.derivativeImage = exports.getDerivativeUrl = exports.DERIVATIVE_ORIGINAL = exports.DERIVATIVE_ORIGINAL_JPEG = exports.DERIVATIVE_MEDIUM = exports.DERIVATIVE_SMALL = exports.DERIVATIVE_THUMBNAIL = undefined;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _BlobImage = require('../components/media/BlobImage');

var _BlobImage2 = _interopRequireDefault(_BlobImage);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var DERIVATIVE_THUMBNAIL = exports.DERIVATIVE_THUMBNAIL = 'Thumbnail';
var DERIVATIVE_SMALL = exports.DERIVATIVE_SMALL = 'Small';
var DERIVATIVE_MEDIUM = exports.DERIVATIVE_MEDIUM = 'Medium';
var DERIVATIVE_ORIGINAL_JPEG = exports.DERIVATIVE_ORIGINAL_JPEG = 'OriginalJpeg';
var DERIVATIVE_ORIGINAL = exports.DERIVATIVE_ORIGINAL = '';

var getDerivativeUrl = exports.getDerivativeUrl = function getDerivativeUrl(config, csid, derivative) {
  var servicesUrl = config.cspaceUrl || '';
  var derivativePath = derivative ? '/derivatives/' + derivative : '';

  return servicesUrl + '/cspace-services/blobs/' + csid + derivativePath + '/content';
};

var derivativeImage = exports.derivativeImage = function derivativeImage(blobCsid, derivative) {
  return blobCsid ? _react2.default.createElement(_BlobImage2.default, { csid: blobCsid, derivative: derivative }) : null;
};

var thumbnailImage = exports.thumbnailImage = function thumbnailImage(blobCsid) {
  return derivativeImage(blobCsid, DERIVATIVE_THUMBNAIL);
};

var smallImage = exports.smallImage = function smallImage(blobCsid) {
  return derivativeImage(blobCsid, DERIVATIVE_SMALL);
};

var mediumImage = exports.mediumImage = function mediumImage(blobCsid) {
  return derivativeImage(blobCsid, DERIVATIVE_MEDIUM);
};

var originalJpegImage = exports.originalJpegImage = function originalJpegImage(blobCsid) {
  return derivativeImage(blobCsid, DERIVATIVE_ORIGINAL_JPEG);
};

var originalImage = exports.originalImage = function originalImage(blobCsid) {
  return derivativeImage(blobCsid, DERIVATIVE_ORIGINAL);
};