/* index.tsx generated by @compiled/babel-plugin v0.38.1 */
import _extends from "@babel/runtime/helpers/extends";
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';
const 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
 */
const TitleBlockErroredView = ({
  actionGroup,
  hideRetry,
  retry: _retry,
  position,
  testId,
  title,
  icon,
  hideIcon,
  CompetitorPrompt,
  ...blockProps
}) => {
  var _context$actions;
  const context = useFlexibleUiContext();
  const showRetry = !hideRetry && Boolean(context === null || context === void 0 ? void 0 : (_context$actions = context.actions) === null || _context$actions === void 0 ? void 0 : _context$actions[InternalActionName.UnresolvedAction]);
  const 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: `${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;