"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = require("react");
var _react2 = require("@emotion/react");
var _utils = require("../../../utils");
var _styles = require("../styles");
var _LozengeComponent = require("./LozengeComponent");
var _excluded = ["url"];
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /**
 * @jsxRuntime classic
 * @jsx jsx
 */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled, @typescript-eslint/consistent-type-imports -- Ignored via go/DSP-18766; jsx required at runtime for @jsxRuntime classic
// Ignored via go/ees005
// eslint-disable-next-line @repo/internal/react/no-class-components, @typescript-eslint/no-explicit-any
var ExtensionLozenge = exports.default = /*#__PURE__*/function (_Component) {
  function ExtensionLozenge() {
    var _this;
    (0, _classCallCheck2.default)(this, ExtensionLozenge);
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _callSuper(this, ExtensionLozenge, [].concat(args));
    (0, _defineProperty2.default)(_this, "renderImage", function (lozengeData) {
      var extensionKey = _this.props.node.attrs.extensionKey;
      var url = lozengeData.url,
        rest = (0, _objectWithoutProperties2.default)(lozengeData, _excluded);
      // eslint-disable-next-line react/jsx-props-no-spreading, @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
      return (0, _react2.jsx)("img", (0, _extends2.default)({
        css: _styles.styledImage,
        src: url
      }, rest, {
        alt: extensionKey
      }));
    });
    (0, _defineProperty2.default)(_this, "renderFallback", function (lozengeData) {
      var _this$props = _this.props,
        showMacroInteractionDesignUpdates = _this$props.showMacroInteractionDesignUpdates,
        isNodeSelected = _this$props.isNodeSelected,
        isNodeHovered = _this$props.isNodeHovered,
        isNodeNested = _this$props.isNodeNested,
        customContainerStyles = _this$props.customContainerStyles,
        setIsNodeHovered = _this$props.setIsNodeHovered,
        isBodiedMacro = _this$props.isBodiedMacro,
        showLivePagesBodiedMacrosRendererView = _this$props.showLivePagesBodiedMacrosRendererView,
        showUpdatedLivePages1PBodiedExtensionUI = _this$props.showUpdatedLivePages1PBodiedExtensionUI,
        showBodiedExtensionRendererView = _this$props.showBodiedExtensionRendererView,
        setShowBodiedExtensionRendererView = _this$props.setShowBodiedExtensionRendererView,
        pluginInjectionApi = _this$props.pluginInjectionApi,
        isMultiBodiedMacro = _this$props.isMultiBodiedMacro;
      var _this$props$node$attr = _this.props.node.attrs,
        parameters = _this$props$node$attr.parameters,
        extensionKey = _this$props$node$attr.extensionKey;
      var name = _this.props.node.type.name;
      var params = parameters && parameters.macroParams;
      var title = parameters && parameters.extensionTitle || parameters && parameters.macroMetadata && parameters.macroMetadata.title || extensionKey;
      return (0, _react2.jsx)(_LozengeComponent.LozengeComponent, {
        isNodeHovered: isNodeHovered,
        isNodeSelected: isNodeSelected,
        isNodeNested: isNodeNested,
        showMacroInteractionDesignUpdates: showMacroInteractionDesignUpdates,
        extensionName: name,
        lozengeData: lozengeData,
        params: params,
        title: title,
        renderImage: _this.renderImage,
        customContainerStyles: customContainerStyles,
        setIsNodeHovered: setIsNodeHovered,
        isBodiedMacro: isBodiedMacro,
        showLivePagesBodiedMacrosRendererView: showLivePagesBodiedMacrosRendererView,
        showUpdatedLivePages1PBodiedExtensionUI: showUpdatedLivePages1PBodiedExtensionUI,
        showBodiedExtensionRendererView: showBodiedExtensionRendererView,
        setShowBodiedExtensionRendererView: setShowBodiedExtensionRendererView,
        pluginInjectionApi: pluginInjectionApi,
        isMultiBodiedMacro: isMultiBodiedMacro
      });
    });
    return _this;
  }
  (0, _inherits2.default)(ExtensionLozenge, _Component);
  return (0, _createClass2.default)(ExtensionLozenge, [{
    key: "render",
    value: function render() {
      var _this$props2 = this.props,
        node = _this$props2.node,
        showMacroInteractionDesignUpdates = _this$props2.showMacroInteractionDesignUpdates;
      var imageData = (0, _utils.getExtensionLozengeData)({
        node: node,
        type: 'image'
      });
      if (!showMacroInteractionDesignUpdates && imageData && node.type.name !== 'extension') {
        return this.renderImage(imageData);
      }
      var iconData = (0, _utils.getExtensionLozengeData)({
        node: node,
        type: 'icon'
      });
      return this.renderFallback(iconData);
    }
  }]);
}(_react.Component);