import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
var _excluded = ["url"];
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(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
 */
import { Component } from 'react';
// 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
import { jsx } from '@emotion/react';
import { getExtensionLozengeData } from '../../../utils';
import { styledImage } from '../styles';
import { LozengeComponent } from './LozengeComponent';
// Ignored via go/ees005
// eslint-disable-next-line @repo/internal/react/no-class-components, @typescript-eslint/no-explicit-any
var ExtensionLozenge = /*#__PURE__*/function (_Component) {
  function ExtensionLozenge() {
    var _this;
    _classCallCheck(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));
    _defineProperty(_this, "renderImage", function (lozengeData) {
      var extensionKey = _this.props.node.attrs.extensionKey;
      var url = lozengeData.url,
        rest = _objectWithoutProperties(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 jsx("img", _extends({
        css: styledImage,
        src: url
      }, rest, {
        alt: extensionKey
      }));
    });
    _defineProperty(_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 jsx(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;
  }
  _inherits(ExtensionLozenge, _Component);
  return _createClass(ExtensionLozenge, [{
    key: "render",
    value: function render() {
      var _this$props2 = this.props,
        node = _this$props2.node,
        showMacroInteractionDesignUpdates = _this$props2.showMacroInteractionDesignUpdates;
      var imageData = getExtensionLozengeData({
        node: node,
        type: 'image'
      });
      if (!showMacroInteractionDesignUpdates && imageData && node.type.name !== 'extension') {
        return this.renderImage(imageData);
      }
      var iconData = getExtensionLozengeData({
        node: node,
        type: 'icon'
      });
      return this.renderFallback(iconData);
    }
  }]);
}(Component);
export { ExtensionLozenge as default };