text: 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; }; }();
  
  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; }
  
  import React, { Component } from 'react';
  import PropTypes from 'prop-types';
  
  var Camera = function (_Component) {
    _inherits(Camera, _Component);
  
    function Camera() {
      _classCallCheck(this, Camera);
  
      return _possibleConstructorReturn(this, (Camera.__proto__ || Object.getPrototypeOf(Camera)).apply(this, arguments));
    }
  
    _createClass(Camera, [{
      key: 'componentWillMount',
      value: function componentWillMount() {
        var _this2 = this;
  
        var _props = this.props,
            video = _props.video,
            audio = _props.audio;
  
        if (navigator.mediaDevices) {
          navigator.mediaDevices.getUserMedia({ video: video, audio: audio }).then(function (mediaStream) {
            _this2.setState({ mediaStream: mediaStream });
            _this2.video.srcObject = mediaStream;
            _this2.video.play();
          }).catch(function (error) {
            return error;
          });
        }
      }
    }, {
      key: 'capture',
      value: function capture() {
        var mediaStreamTrack = this.state.mediaStream.getVideoTracks()[0];
        var imageCapture = new window.ImageCapture(mediaStreamTrack);
  
        return imageCapture.takePhoto();
      }
    }, {
      key: 'render',
      value: function render() {
        var _this3 = this;
  
        return React.createElement(
          'div',
          { style: this.props.style },
          this.props.children,
          React.createElement('video', { style: styles.base, ref: function ref(video) {
              _this3.video = video;
            } })
        );
      }
    }]);
  
    return Camera;
  }(Component);
  
  Camera.propTypes = process.env.NODE_ENV !== "production" ? {
    audio: PropTypes.bool,
    video: PropTypes.bool,
    children: PropTypes.element,
    style: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
  } : {};
  
  Camera.defaultProps = {
    audio: false,
    video: true,
    style: {},
    children: null
  };
  
  export default Camera;
  
  var styles = {
    base: {
      width: '100%',
      height: '100%'
    }
  };