import _extends from "@babel/runtime/helpers/extends";
import React, { useEffect } from 'react';
import { di } from 'react-magnetic-di';
import { fg } from '@atlaskit/platform-feature-flags';
import useAISummaryAction from '../../../../../state/hooks/use-ai-summary-action';
import { AISummariseAction } from './ai-summarise-action';
import { CopySummaryAction, CopySummaryActionNew } from './copy-summary-action';
export const AISummaryActionComponent = props => {
  const {
    url,
    onLoadingChange,
    testId = 'smart-action-ai-summary-action'
  } = props;
  const {
    state: {
      status,
      content
    },
    summariseUrl
  } = useAISummaryAction(url);
  useEffect(() => {
    onLoadingChange === null || onLoadingChange === void 0 ? void 0 : onLoadingChange(status === 'loading');
  }, [onLoadingChange, status]);
  return status === 'done' ? fg('platform_sl_action_refactoring') ? /*#__PURE__*/React.createElement(CopySummaryActionNew, _extends({}, props, {
    summary: content,
    testId: testId
  })) : /*#__PURE__*/React.createElement(CopySummaryAction, _extends({}, props, {
    testId: testId,
    content: content
  })) : /*#__PURE__*/React.createElement(AISummariseAction, _extends({}, props, {
    testId: testId,
    summariseUrl: summariseUrl,
    status: status
  }));
};