/* index.tsx generated by @compiled/babel-plugin v0.38.1 */
import _extends from "@babel/runtime/helpers/extends";
import "./index.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
import { Fragment, useRef } from 'react';
import { di } from 'react-magnetic-di';
import { SmartLinkDirection } from '../../../../../../constants';
import useAISummaryAction from '../../../../../../state/hooks/use-ai-summary-action';
import AISummary from '../../../../../common/ai-summary';
import MotionWrapper from '../../../common/motion-wrapper';
import Block from '../../block';
import AIEventSummaryViewed from '../ai-event-summary-viewed';
var styles = null;
var AISummaryBlockResolvedView = function AISummaryBlockResolvedView(props) {
  var testId = props.testId,
    _props$aiSummaryMinHe = props.aiSummaryMinHeight,
    aiSummaryMinHeight = _props$aiSummaryMinHe === void 0 ? 0 : _props$aiSummaryMinHe,
    placeholder = props.placeholder,
    url = props.url;
  var _useAISummaryAction = useAISummaryAction(url),
    _useAISummaryAction$s = _useAISummaryAction.state,
    content = _useAISummaryAction$s.content,
    status = _useAISummaryAction$s.status;
  var showAISummary = status === 'done' ||
  // We want to display the AI Summary component only when there is content available during the loading process.
  status === 'loading' && !!content;
  var isSummarisedOnMountRef = useRef(status === 'done');
  var minHeight = isSummarisedOnMountRef.current ? 0 : aiSummaryMinHeight;
  if (!showAISummary) {
    return /*#__PURE__*/React.createElement(Fragment, null, placeholder);
  }
  return /*#__PURE__*/React.createElement(Block, _extends({}, props, {
    direction: SmartLinkDirection.Vertical,
    testId: "".concat(testId, "-resolved-view")
    /**
     * Enabled for feature discovery to allow box shadow to overflow
     * Cleanup: https://product-fabric.atlassian.net/browse/EDM-8681
     */,
    className: ax(["_1reoewfl _18m9ewfl"])
  }), status === 'done' && /*#__PURE__*/React.createElement(AIEventSummaryViewed, {
    fromCache: isSummarisedOnMountRef.current
  }), /*#__PURE__*/React.createElement(MotionWrapper, {
    minHeight: minHeight,
    show: showAISummary,
    showTransition: !isSummarisedOnMountRef.current
  }, /*#__PURE__*/React.createElement(AISummary, {
    testId: "".concat(testId, "-ai-summary"),
    minHeight: minHeight,
    content: content
  })));
};
export default AISummaryBlockResolvedView;