import { fg } from '@atlaskit/platform-feature-flags';
import { useSmartLinkContext } from '../../../state';
import { getExtensionKey } from '../../../state/helpers';
import { getEmbedRovoActionsFooterExperimentMeta } from '../../../state/hooks/use-embed-rovo-actions-footer-experiment';
import useRovoConfig from '../../../state/hooks/use-rovo-config';
import { getSocialProofExperimentMeta, getInlineSocialProofExperimentMeta } from '../../../state/hooks/use-social-proof-experiment';
import { getIsRovoChatEnabled } from '../../../utils/rovo';
const useExperimentMetaEventAttributes = ({
  actionOptions,
  appearance,
  state
}) => {
  var _actionOptions$rovoCh, _actionOptions$rovoCh2;
  const {
    connections: {
      client: {
        baseUrlOverride: baseUriWithNoTrailingSlash
      }
    }
  } = useSmartLinkContext();
  const {
    rovoOptions,
    product
  } = useRovoConfig();
  const {
    details,
    status
  } = state;
  const extensionKey = getExtensionKey(details);
  const embedRovoActionsFooterExperimentMeta = appearance === 'embed' && status === 'resolved' ? getEmbedRovoActionsFooterExperimentMeta({
    extensionKey,
    isRovoChatActionOptedIn: (_actionOptions$rovoCh = actionOptions === null || actionOptions === void 0 ? void 0 : (_actionOptions$rovoCh2 = actionOptions.rovoChatAction) === null || _actionOptions$rovoCh2 === void 0 ? void 0 : _actionOptions$rovoCh2.optIn) !== null && _actionOptions$rovoCh !== void 0 ? _actionOptions$rovoCh : false,
    isRovoChatEnabled: getIsRovoChatEnabled(rovoOptions),
    product
  }) : undefined;
  if (!embedRovoActionsFooterExperimentMeta && !fg('social-proof-3p-unauth-block-fg') && !fg('platform_sl_3p_preauth_soc_proof_inline_killswitch')) {
    return undefined;
  }
  const blockSocialProofExperimentMeta = appearance === 'block' && status === 'unauthorized' && fg('social-proof-3p-unauth-block-fg') ? getSocialProofExperimentMeta({
    extensionKey,
    baseUriWithNoTrailingSlash
  }) : undefined;
  const inlineSocialProofExperimentMeta = appearance === 'inline' && status === 'unauthorized' && fg('platform_sl_3p_preauth_soc_proof_inline_killswitch') ? getInlineSocialProofExperimentMeta({
    extensionKey,
    baseUriWithNoTrailingSlash
  }) : undefined;
  const experimentMeta = {
    ...blockSocialProofExperimentMeta,
    ...inlineSocialProofExperimentMeta,
    ...embedRovoActionsFooterExperimentMeta
  };
  if (Object.keys(experimentMeta).length > 0) {
    return experimentMeta;
  }
};
export default useExperimentMetaEventAttributes;