"use strict";

exports.__esModule = true;
exports["default"] = void 0;

var _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _reactDom = require("react-dom");

var _instance = _interopRequireDefault(require("../Context/instance.js"));

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

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

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 _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; }

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

  function PlayerDialog(props, context) {
    return _Component.call(this, props, context) || this;
  }

  var _proto = PlayerDialog.prototype;

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

    var _this$props = this.props,
        portal = _this$props.portal,
        show = _this$props.show,
        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,
        onHide = _this$props.onHide;
    return (0, _reactDom.createPortal)( /*#__PURE__*/_react["default"].createElement("div", _extends({
      ref: function ref(el) {
        _this.$el = el;
      }
    }, maskAttribute, {
      className: "mask video-mask" + (maskAttribute.className ? ' ' + maskAttribute.className : '') + (show ? ' active' : '')
    }), /*#__PURE__*/_react["default"].createElement("video", _extends({
      controls: true
    }, videoAttribute), /*#__PURE__*/_react["default"].createElement("source", {
      src: src
    }), "\u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 video \u6807\u7B7E\u3002"), /*#__PURE__*/_react["default"].createElement("div", {
      className: "video-line"
    }), /*#__PURE__*/_react["default"].createElement("div", {
      className: "video-close",
      onClick: onHide
    })), portal || this.context.portal || document.getElementById('root') || document.body);
  };

  return PlayerDialog;
}(_react.Component);

exports["default"] = PlayerDialog;

_defineProperty(PlayerDialog, "contextType", _instance["default"]);

PlayerDialog.propTypes = process.env.NODE_ENV !== "production" ? {
  portal: _propTypes["default"].object,
  show: _propTypes["default"].bool,
  src: _propTypes["default"].string,
  maskAttribute: _propTypes["default"].object,
  videoAttribute: _propTypes["default"].object,
  onHide: _propTypes["default"].func
} : {};
module.exports = exports.default;