var _excluded = ["portal", "src", "maskAttribute", "videoAttribute", "poster", "children"];

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import PlayerDialog from './PlayerDialog';
import Context from '../Context/instance.js';

var Player = /*#__PURE__*/function (_Component) {
  _inheritsLoose(Player, _Component);

  function Player(props) {
    var _this;

    _this = _Component.call(this, props) || this;

    _defineProperty(_assertThisInitialized(_this), "state", {
      videoShow: false
    });

    _defineProperty(_assertThisInitialized(_this), "play", function (e, show) {
      _this.setState({
        videoShow: show
      });

      e.stopPropagation();
    });

    return _this;
  }

  var _proto = Player.prototype;

  _proto.componentDidMount = function componentDidMount() {
    this.$ComponentPlayerDialog = this.refs.$ComponentPlayerDialog;
    this.$video = this.refs.$ComponentPlayerDialog.$el;
  } // 显隐视频弹窗
  ;

  _proto.render = function render() {
    var _this2 = this;

    var _this$props = this.props,
        portal = _this$props.portal,
        src = _this$props.src,
        _this$props$maskAttri = _this$props.maskAttribute,
        maskAttribute = _this$props$maskAttri === void 0 ? {} : _this$props$maskAttri,
        _this$props$videoAttr = _this$props.videoAttribute,
        videoAttribute = _this$props$videoAttr === void 0 ? {} : _this$props$videoAttr,
        poster = _this$props.poster,
        children = _this$props.children,
        others = _objectWithoutPropertiesLoose(_this$props, _excluded);

    return /*#__PURE__*/React.createElement("div", _extends({
      ref: function ref(el) {
        _this2.$el = el;
      }
    }, others, {
      className: 'player-thumbnail' + (others.className ? ' ' + others.className : ''),
      onClick: others.onClick ? others.onClick : function (e) {
        return _this2.play(e, true);
      }
    }), poster && /*#__PURE__*/React.createElement("div", {
      style: {
        backgroundImage: "url(" + poster + ")"
      },
      className: "player-thumbnail-poster"
    }), /*#__PURE__*/React.createElement("div", {
      className: "player-thumbnail-button"
    }), children, /*#__PURE__*/React.createElement(PlayerDialog, {
      ref: "$ComponentPlayerDialog",
      show: this.state.videoShow,
      portal: portal,
      src: src,
      maskAttribute: maskAttribute,
      videoAttribute: videoAttribute,
      onHide: function onHide(e) {
        return _this2.play(e, false);
      }
    }));
  };

  return Player;
}(Component);

_defineProperty(Player, "contextType", Context);

_defineProperty(Player, "defaultProps", {});

export { Player as default };
Player.propTypes = process.env.NODE_ENV !== "production" ? {
  portal: PropTypes.object,
  src: PropTypes.string,
  maskAttribute: PropTypes.object,
  videoAttribute: PropTypes.object,
  poster: PropTypes.string,
  children: PropTypes.node
} : {};