import * as React from 'react';
import { Variants } from './types';
import { Carousel as BsCarousel } from 'react-bootstrap';
import defaultProps from 'recompose/defaultProps';
import setDisplayName from 'recompose/setDisplayName';
import compose from 'recompose/compose';
import cn from 'classnames';
var ITEM_WIDTH = 100;

var ItemPure = function ItemPure(_ref) {
  var slide = _ref.slide,
      width = _ref.width;
  return React.createElement("img", {
    className: cn({
      'd-block': width === ITEM_WIDTH
    }, "w-".concat(width || ITEM_WIDTH)),
    src: slide.src,
    alt: slide.alt
  });
};

var Item = compose(setDisplayName('Item'), defaultProps({
  width: 100,
  slide: {
    src: '',
    alt: ''
  }
}))(ItemPure);
var Items = setDisplayName('Items')(function (_ref2) {
  var slide = _ref2.slide;
  return React.createElement(React.Fragment, null, slide.map(function (item, i) {
    return React.createElement(Item, {
      width: ITEM_WIDTH / slide.length,
      slide: item,
      key: i
    });
  }));
});
export var Carousel = function Carousel(_ref3) {
  var slides = _ref3.slides,
      _ref3$variant = _ref3.variant,
      variant = _ref3$variant === void 0 ? Variants.SIMPLE : _ref3$variant;
  return React.createElement(BsCarousel, null, slides.map(function (slide, i) {
    if (Array.isArray(slide)) {
      return React.createElement(BsCarousel.Item, {
        key: i
      }, React.createElement(Items, {
        slide: slide
      }));
    }

    return React.createElement(BsCarousel.Item, {
      key: i
    }, React.createElement(Item, {
      slide: slide
    }));
  }));
};