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 from 'react';
import { paths } from '../../utilities/routes';
var PAGES_BASE_PATH = paths.PAGES_BASE_PATH;

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

    function RelatedAppsBannerIframe() {
        _classCallCheck(this, RelatedAppsBannerIframe);

        var _this = _possibleConstructorReturn(this, (RelatedAppsBannerIframe.__proto__ || Object.getPrototypeOf(RelatedAppsBannerIframe)).apply(this, arguments));

        _this.state = {
            width: 210,
            height: 260
        };
        return _this;
    }

    _createClass(RelatedAppsBannerIframe, [{
        key: 'updateFrameDimensions',
        value: function updateFrameDimensions() {
            var iframe = this.iframe;

            this.setState({
                width: iframe.contentWindow.document.body.scrollWidth,
                height: iframe.contentWindow.document.body.scrollHeight
            });
        }
    }, {
        key: 'componentDidMount',
        value: function componentDidMount() {
            this.iframe.addEventListener('load', this.updateFrameDimensions.bind(this));
        }
    }, {
        key: 'render',
        value: function render() {
            var _this2 = this;

            var url = PAGES_BASE_PATH + '/pages/related-apps-banner?utm_source=cf-dashboard';
            url += this.props.categories.map(function (category) {
                return '&app-category=' + category;
            });
            return React.createElement("iframe", { ref: function ref(iframe) {
                    return _this2.iframe = iframe;
                }, src: url, seamless: true, width: this.state.width, height: this.state.height, frameBorder: '0', style: { backgroundColor: 'transparent', border: '0 none transparent', padding: 0 } });
        }
    }]);

    return RelatedAppsBannerIframe;
}(React.Component);
//# sourceMappingURL=related-apps-banner-iframe.js.map


export { RelatedAppsBannerIframe as default };