import _extends from "@babel/runtime/helpers/extends";
import React, { useCallback } from 'react';
import { FormattedMessage } from 'react-intl';
import { fg } from '@atlaskit/platform-feature-flags';
import { Anchor } from '@atlaskit/primitives/compiled';
import { useAnalyticsEvents } from '../../common/analytics/generated/use-analytics-events';
import { CONTENT_URL_3P_ACCOUNT_AUTH, CONTENT_URL_SECURITY_AND_PERMISSIONS } from '../../constants';
import { messages } from '../../messages';
/**
 * This component is used in unauthorized views of a smart link.
 * It represents the main text that provides a user with information on how to connect their account
 */
const UnauthorisedViewContent = ({
  providerName,
  isProductIntegrationSupported,
  testId = 'unauthorised-view-content'
}) => {
  const {
    fireEvent
  } = useAnalyticsEvents();
  const handleLearnMoreClick = useCallback(() => {
    fireEvent('ui.button.clicked.learnMore', {});
  }, [fireEvent]);
  const learnMoreMessage = isProductIntegrationSupported ? fg('product-terminology-refresh') ? messages.learn_more_about_connecting_account_appify : messages.learn_more_about_connecting_account : messages.learn_more_about_smart_links;
  const unauthorizedAccountDescriptionMessage = messages.learn_more_about_connecting_account_experiment_shorter;
  return /*#__PURE__*/React.createElement(React.Fragment, null, providerName ? /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, unauthorizedAccountDescriptionMessage, {
    values: {
      context: providerName
    }
  })) : /*#__PURE__*/React.createElement(FormattedMessage, fg('product-terminology-refresh') ? messages.connect_unauthorised_account_description_no_provider_appify : messages.connect_unauthorised_account_description_no_provider), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Anchor, {
    href: isProductIntegrationSupported ? CONTENT_URL_3P_ACCOUNT_AUTH : CONTENT_URL_SECURITY_AND_PERMISSIONS,
    target: "_blank",
    testId: `${testId}-learn-more`,
    onClick: handleLearnMoreClick
  }, /*#__PURE__*/React.createElement(FormattedMessage, learnMoreMessage)));
};
export default UnauthorisedViewContent;