'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

require('./_commonjsHelpers-06173234.js');
var React = require('react');
var React__default = _interopDefault(React);
var index$1 = require('./index-be0c82be.js');
var entities = require('./entities-310b46ee.js');
var reactBootstrap = require('react-bootstrap');

var urlFor = function urlFor(source, client) {
  var builder = index$1.imageUrlBuilder(client);
  return builder.image(source).auto('format');
};

var renderCardImage = function renderCardImage(thumbnail, client, imageHeight, imageWidth) {
  var url = urlFor(thumbnail, client);
  if (imageHeight) url = url.height(imageHeight);
  if (imageWidth) url = url.width(imageWidth);
  return url.url();
};

var Hero = function Hero(_ref) {
  var data = _ref.data,
      client = _ref.client,
      imageHeight = _ref.imageHeight,
      imageWidth = _ref.imageWidth;
  var title = data.title,
      summary = data.summary,
      thumbnail = data.thumbnail,
      url = data.url;

  return React__default.createElement(
    'a',
    { href: '/view/' + url.current },
    React__default.createElement(
      reactBootstrap.Card,
      { bsPrefix: 'hero-card' },
      title && React__default.createElement(
        reactBootstrap.Card.Header,
        { className: 'h4' },
        title
      ),
      thumbnail && client && React__default.createElement(reactBootstrap.Card.Img, { src: renderCardImage(thumbnail, client, imageHeight, imageWidth) }),
      summary && React__default.createElement(
        reactBootstrap.Card.Footer,
        { className: 'h6' },
        entities.clean_html_1(summary)
      )
    )
  );
};

module.exports = Hero;
