'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.AlignedYoutube = undefined;

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

var _BlockAlignmentWrapper = require('./BlockAlignmentWrapper');

var _BlockAlignmentWrapper2 = _interopRequireDefault(_BlockAlignmentWrapper);

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactYoutube = require('react-youtube');

var _reactYoutube2 = _interopRequireDefault(_reactYoutube);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _Common = {
  "inner-block": "Common__inner-block___2cOrF",
  "disable-inner-block": "Common__disable-inner-block___1MLd0",
  "components": "Common__components___2fQuj",
  "component": "Common__component___3bwMg",
  "hide": "Common__hide___2HyoH",
  "desc-text-color": "Common__desc-text-color___2fV3l",
  "desc-text-block": "Common__desc-text-block___1Z4b-",
  "text-link": "Common__text-link___1jaLy",
  "image": "Common__image___AKB6W",
  "imagediff": "Common__imagediff___2j7tX",
  "slideshow": "Common__slideshow___1Fz23",
  "embeddedcode": "Common__embeddedcode___3Avmp",
  "youtube": "Common__youtube___2oq1n",
  "topic-box": "Common__topic-box___2Q-kN"
};

var _Common2 = _interopRequireDefault(_Common);

var _Youtube = {
  "youtube-container": "Youtube__youtube-container___2NUCz",
  "youtube-iframe-container": "Youtube__youtube-iframe-container___393kW"
};

var _Youtube2 = _interopRequireDefault(_Youtube);

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // eslint-disable-next-line


var Youtube = function (_React$Component) {
  _inherits(Youtube, _React$Component);

  function Youtube(props) {
    _classCallCheck(this, Youtube);

    return _possibleConstructorReturn(this, (Youtube.__proto__ || Object.getPrototypeOf(Youtube)).call(this, props));
  }

  _createClass(Youtube, [{
    key: 'render',
    value: function render() {
      var content = this.props.content;

      var _$get = _lodash2.default.get(content, [0], {});

      var description = _$get.description;
      var youtubeId = _$get.youtubeId;


      if (!youtubeId) {
        return null;
      }

      return _react2.default.createElement(
        'div',
        { className: _Youtube2.default['youtube-container'] },
        _react2.default.createElement(
          'div',
          { className: _Youtube2.default['youtube-iframe-container'] },
          _react2.default.createElement(_reactYoutube2.default, { videoId: youtubeId })
        ),
        _react2.default.createElement(
          'div',
          { className: (0, _classnames2.default)(_Common2.default['desc-text-block'], 'text-justify') },
          description
        )
      );
    }
  }]);

  return Youtube;
}(_react2.default.Component);

Youtube.propTypes = {
  content: _react2.default.PropTypes.array.isRequired,
  device: _react2.default.PropTypes.string,
  styles: _react2.default.PropTypes.object
};

Youtube.defaultProps = {
  content: [],
  device: '',
  styles: {}
};

var AlignedYoutube = exports.AlignedYoutube = (0, _BlockAlignmentWrapper2.default)(Youtube);