import _extends from "@babel/runtime/helpers/extends";
import React from 'react';
import { Page } from '@atlaskit/embedded-confluence';
import { fg } from '@atlaskit/platform-feature-flags';
import { useConfluencePageData } from '../../../hooks/useConfluencePageData';
/**
 * Iframe element isolated for DI purposes
 */
export const IFrame = ({
  childRef,
  className,
  extensionKey,
  ...props
}) => {
  const confluencePageData = fg('platform_deprecate_lp_cc_embed') ?
  // eslint-disable-next-line react-hooks/rules-of-hooks
  useConfluencePageData(props.src || '', extensionKey || '') : undefined;

  // Conditional rendering: Page component for lp-cc-embed URLs, iframe for everything else
  return confluencePageData && fg('platform_deprecate_lp_cc_embed') ? /*#__PURE__*/React.createElement(Page, {
    hostname: confluencePageData.hostname,
    spaceKey: confluencePageData.spaceKey,
    contentId: confluencePageData.contentId,
    parentProduct: confluencePageData.parentProduct,
    hash: confluencePageData.hash,
    mode: confluencePageData.mode,
    locale: confluencePageData.locale,
    iframeRef: childRef,
    onLoad: props.onLoad,
    onMouseEnter: props.onMouseEnter,
    onMouseLeave: props.onMouseLeave,
    sandbox: props.sandbox,
    allowedFeatures: confluencePageData.allowedFeatures,
    themeState: confluencePageData.themeStateObject,
    userInfo: confluencePageData.userInfo
  }) :
  /*#__PURE__*/
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
  React.createElement("iframe", _extends({
    className: className
  }, props, {
    ref: childRef,
    title: props.title
  }));
};