"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.CaptionComponent = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
var _react = _interopRequireDefault(require("react"));
var _react2 = require("@emotion/react");
var _reactIntlNext = require("react-intl-next");
var _colors = require("@atlaskit/theme/colors");
var _messages = require("./messages");
var _templateObject, _templateObject2;
/** @jsx jsx */
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var captionWrapperStyle = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n  margin-top: ", ";\n  text-align: center;\n  position: relative;\n  color: ", ";\n"])), "var(--ds-space-100, 8px)", "var(--ds-text-subtle, ".concat(_colors.N400, ")"));
var placeholderStyle = (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n  color: ", ";\n  position: absolute;\n  top: 0;\n  width: 100%;\n"])), "var(--ds-text-subtlest, ".concat(_colors.N200, ")"));
var CaptionComponent = exports.CaptionComponent = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2.default)(CaptionComponent, _React$Component);
  var _super = _createSuper(CaptionComponent);
  function CaptionComponent() {
    (0, _classCallCheck2.default)(this, CaptionComponent);
    return _super.apply(this, arguments);
  }
  (0, _createClass2.default)(CaptionComponent, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
        selected = _this$props.selected,
        hasContent = _this$props.hasContent,
        children = _this$props.children,
        dataAttributes = _this$props.dataAttributes,
        formatMessage = _this$props.intl.formatMessage;
      var showPlaceholder = !selected && !hasContent;
      return (0, _react2.jsx)("div", (0, _extends2.default)({
        "data-media-caption": true,
        "data-testid": "media-caption"
      }, dataAttributes, {
        css: captionWrapperStyle
      }), showPlaceholder ? (0, _react2.jsx)("p", {
        css: placeholderStyle
      }, formatMessage(_messages.messages.placeholder)) : null, children);
    }
  }]);
  return CaptionComponent;
}(_react.default.Component);
var _default = exports.default = (0, _reactIntlNext.injectIntl)(CaptionComponent);