/* index.tsx generated by @compiled/babel-plugin v0.39.1 */
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["actionGroup", "hideRetry", "retry", "position", "testId", "title", "icon", "hideIcon", "CompetitorPrompt"];
import "./index.compiled.css";
import { ax, ix } from "@compiled/react/runtime";
import React from 'react';
import { Box } from '@atlaskit/primitives/compiled';
import { InternalActionName, SmartLinkAlignment } from '../../../../../../constants';
import { useFlexibleUiContext } from '../../../../../../state/flexible-ui-context';
import { UnresolvedAction } from '../../../actions';
import { LinkIcon } from '../../../elements';
import Block from '../../block';
import ElementGroup from '../../element-group';
var styles = {
  titleBoxCard: "_1e0c1txw _2lx2vrvc _4cvr1h6o _1bsb1osq"
};

/**
 * Represents an Errored TitleBlock view.
 * This will render when a Smart Link did not successfully resolve.
 * This may be a result of a Smart Link not having the correct credentials,
 * or the backend response was errored or malformed.
 * @see TitleBlock
 */
var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
  var _context$actions;
  var actionGroup = _ref.actionGroup,
    hideRetry = _ref.hideRetry,
    _retry = _ref.retry,
    position = _ref.position,
    testId = _ref.testId,
    title = _ref.title,
    icon = _ref.icon,
    hideIcon = _ref.hideIcon,
    CompetitorPrompt = _ref.CompetitorPrompt,
    blockProps = _objectWithoutProperties(_ref, _excluded);
  var context = useFlexibleUiContext();
  var showRetry = !hideRetry && Boolean(context === null || context === void 0 || (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[InternalActionName.UnresolvedAction]);
  var competitorPrompt = CompetitorPrompt && context !== null && context !== void 0 && context.url ? /*#__PURE__*/React.createElement(CompetitorPrompt, {
    sourceUrl: context === null || context === void 0 ? void 0 : context.url,
    linkType: 'card'
  }) : null;
  return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
    testId: "".concat(testId, "-errored-view")
  }), !hideIcon && /*#__PURE__*/React.createElement(LinkIcon, {
    overrideIcon: icon,
    position: position
  }), competitorPrompt ? /*#__PURE__*/React.createElement(Box, {
    xcss: styles.titleBoxCard
  }, title, competitorPrompt) : title, showRetry && /*#__PURE__*/React.createElement(ElementGroup, {
    align: SmartLinkAlignment.Right
  }, /*#__PURE__*/React.createElement(UnresolvedAction, {
    testId: testId
  })), actionGroup);
};
export default TitleBlockErroredView;