"use strict";

exports.__esModule = true;
exports.default = void 0;
var _getOr2 = _interopRequireDefault(require("lodash/fp/getOr"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _bubbling = _interopRequireDefault(require("../../util/bubbling"));
var _provider = _interopRequireDefault(require("../../atom/provider"));
var _button = _interopRequireDefault(require("../../atom/button"));
var _analyticsPopin = _interopRequireDefault(require("./analytics-popin.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const AnalyticsPopin = (props, context) => {
  const {
    skin
  } = context;
  const {
    ctaLabel,
    ctaOnClick,
    header,
    closeOnClick,
    content
  } = props;
  function createMarkup() {
    return {
      __html: content
    };
  }
  const primary = (0, _getOr2.default)('#00B0FF', ['common', 'primary'], skin);
  function onCloseClick(e) {
    (0, _bubbling.default)(e);
    closeOnClick(e);
  }
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _analyticsPopin.default.defaultStyle,
    onClick: onCloseClick
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _analyticsPopin.default.popin
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _analyticsPopin.default.header,
    onClick: onCloseClick,
    "data-name": "popin-header"
  }, header), /*#__PURE__*/_react.default.createElement("div", {
    className: _analyticsPopin.default.content
  }, /*#__PURE__*/_react.default.createElement("div", {
    // eslint-disable-next-line react/no-danger
    dangerouslySetInnerHTML: createMarkup()
  })), /*#__PURE__*/_react.default.createElement(_button.default, {
    type: "link",
    onClick: ctaOnClick,
    submitValue: ctaLabel,
    style: {
      backgroundColor: primary
    }
  })));
};
AnalyticsPopin.contextTypes = {
  skin: _provider.default.childContextTypes.skin
};
AnalyticsPopin.propTypes = process.env.NODE_ENV !== "production" ? {
  ctaLabel: _propTypes.default.string,
  ctaOnClick: _propTypes.default.func,
  closeOnClick: _propTypes.default.func,
  header: _propTypes.default.string,
  content: _propTypes.default.string
} : {};
var _default = exports.default = AnalyticsPopin;
//# sourceMappingURL=analytics-popin.js.map