/* ExpandedFrame.tsx generated by @compiled/babel-plugin v0.39.1 */
import _extends from "@babel/runtime/helpers/extends";
import "./ExpandedFrame.compiled.css";
import * as React from 'react';
import { ax, ix } from "@compiled/react/runtime";
// eslint-disable-next-line no-unused-vars

import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
import Tooltip from '@atlaskit/tooltip';
import { useMouseDownEvent } from '../../../state/analytics/useLinkClicked';
import { handleClickCommon } from '../../common/utils';
import { className } from './styled';
var ExpandedFrame = function ExpandedFrame(_ref) {
  var _ref$isPlaceholder = _ref.isPlaceholder,
    isPlaceholder = _ref$isPlaceholder === void 0 ? false : _ref$isPlaceholder,
    children = _ref.children,
    onClick = _ref.onClick,
    icon = _ref.icon,
    text = _ref.text,
    isSelected = _ref.isSelected,
    _ref$frameStyle = _ref.frameStyle,
    frameStyle = _ref$frameStyle === void 0 ? 'showOnHover' : _ref$frameStyle,
    href = _ref.href,
    minWidth = _ref.minWidth,
    maxWidth = _ref.maxWidth,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'expanded-frame' : _ref$testId,
    inheritDimensions = _ref.inheritDimensions,
    _ref$allowScrollBar = _ref.allowScrollBar,
    allowScrollBar = _ref$allowScrollBar === void 0 ? false : _ref$allowScrollBar,
    _ref$setOverflow = _ref.setOverflow,
    setOverflow = _ref$setOverflow === void 0 ? true : _ref$setOverflow,
    CompetitorPrompt = _ref.CompetitorPrompt;
  var isInteractive = function isInteractive() {
    return !isPlaceholder && (Boolean(href) || Boolean(onClick));
  };
  var handleClick = function handleClick(event) {
    return handleClickCommon(event, onClick);
  };
  var handleMouseDown = useMouseDownEvent();
  var CompetitorPromptComponent = CompetitorPrompt && href ? /*#__PURE__*/React.createElement(CompetitorPrompt, {
    sourceUrl: href,
    linkType: "embed"
  }) : null;
  var renderHeader = function renderHeader() {
    return frameStyle !== 'hide' && /*#__PURE__*/React.createElement("div", {
      className: ax([styles.header, "embed-header"])
    }, /*#__PURE__*/React.createElement("div", {
      className: ax([styles.leftSection])
    }, /*#__PURE__*/React.createElement("div", {
      className: ax([styles.headerIcon])
    }, icon), /*#__PURE__*/React.createElement("div", {
      className: ax([styles.tooltipWrapper])
    }, !isPlaceholder && /*#__PURE__*/React.createElement(Tooltip, {
      content: text,
      hideTooltipOnMouseDown: true
    }, /*#__PURE__*/React.createElement("a", {
      href: href,
      onClick: handleClick,
      onMouseDown: handleMouseDown,
      className: ax([styles.headerAnchor])
    }, text)))), CompetitorPromptComponent);
  };
  var interactive = isInteractive();
  var showBackgroundAlways = frameStyle === 'show' || isSelected && frameStyle !== 'hide';
  var showBackgroundOnHover = interactive && frameStyle !== 'hide';
  var renderContent = function renderContent() {
    return /*#__PURE__*/React.createElement("div", {
      "data-testid": "embed-content-wrapper",
      // This fixes an issue with input fields in cross domain iframes (ie. databases and jira fields from different domains)
      // See: HOT-107830
      contentEditable: false,
      className: ax([styles.contentStyle, setOverflow && allowScrollBar && styles.contentOverflowAuto, interactive && !showBackgroundAlways && !showBackgroundOnHover && styles.contentInteractiveActiveBorder])
    }, children);
  };
  return /*#__PURE__*/React.createElement("div", _extends({
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
    className: ax([styles.linkWrapper, inheritDimensions && styles.linkWrapperInheritDimensions, isSelected && frameStyle !== 'hide' && styles.linkWrapperSelected, showBackgroundAlways && styles.linkWrapperBorderAndBackground, showBackgroundOnHover && !showBackgroundAlways && styles.linkWrapperInteractiveNotHidden, className]),
    style: {
      minWidth: minWidth ? "".concat(minWidth, "px") : '',
      maxWidth: maxWidth ? "".concat(maxWidth, "px") : ''
    },
    "data-testid": testId,
    "data-trello-do-not-use-override": testId
    // Due to limitations of testing library, we can't assert ::after
    ,
    "data-is-selected": isSelected
  }, (isPlaceholder || !href) && {
    'data-wrapper-type': 'default',
    'data-is-interactive': isInteractive()
  }), renderHeader(), renderContent());
};
var styles = {
  linkWrapper: "_zulpu2gc _kqswh2mm _1e0c1txw _2lx21bp4 _4t3ik5xz _ca0qu2gc _u5f3u2gc _n3tdu2gc _19bvu2gc _uiztglyw _qc5o94zs _14mjpb1k _aetrb3bt _18postnw _15l2idpf _32rxidpf _1x88idpf _19doidpf _1hfk1j28 _1bqqidpf _u94kidpf _1ifiidpf",
  linkWrapperInheritDimensions: "_4t3i1osq",
  linkWrapperSelected: "_8x3u1yw3",
  linkWrapperBorderAndBackground: "_1tqzia51 _1hfkhp5a _1ifikb7n",
  linkWrapperInteractiveNotHidden: "_hcgvia51 _4tpuhp5a _x148kb7n",
  header: "_11c81qyo _zulp1b66 _1e0c1txw _4cvr1h6o _1bah1yb4 _4t3igktf _1pbykb7n",
  leftSection: "_zulp1b66 _1e0c1txw _4cvr1h6o _1ul9idpf",
  tooltipWrapper: "_1reo15vq _18m915vq",
  headerAnchor: "_11c81qyo _1reo15vq _18m915vq _1e0c1ule _1bto1l2s _o5721q9c _9oik1r31 _1bnxglyw _jf4cnqa1",
  headerIcon: "_11c81qyo _1bsb7vkz _4t3i7vkz",
  contentStyle: "_19itdlqj _2rkoy00x _1reo15vq _18m915vq _v56414au _bfhkhp5a _16jlkb7n _4t3i1osq _1pbykb7n",
  contentInteractiveActiveBorder: "_1jhm1tt7",
  contentOverflowAuto: "_1reo1wug _18m91wug"
};
var ExpandedFrameUpdated = function ExpandedFrameUpdated(_ref2) {
  var _ref2$isPlaceholder = _ref2.isPlaceholder,
    isPlaceholder = _ref2$isPlaceholder === void 0 ? false : _ref2$isPlaceholder,
    children = _ref2.children,
    onClick = _ref2.onClick,
    icon = _ref2.icon,
    text = _ref2.text,
    isSelected = _ref2.isSelected,
    _ref2$frameStyle = _ref2.frameStyle,
    frameStyle = _ref2$frameStyle === void 0 ? 'showOnHover' : _ref2$frameStyle,
    href = _ref2.href,
    minWidth = _ref2.minWidth,
    maxWidth = _ref2.maxWidth,
    _ref2$testId = _ref2.testId,
    testId = _ref2$testId === void 0 ? 'expanded-frame' : _ref2$testId,
    inheritDimensions = _ref2.inheritDimensions,
    _ref2$allowScrollBar = _ref2.allowScrollBar,
    allowScrollBar = _ref2$allowScrollBar === void 0 ? false : _ref2$allowScrollBar,
    _ref2$setOverflow = _ref2.setOverflow,
    setOverflow = _ref2$setOverflow === void 0 ? true : _ref2$setOverflow,
    CompetitorPrompt = _ref2.CompetitorPrompt,
    onContentMouseEnter = _ref2.onContentMouseEnter,
    onContentMouseLeave = _ref2.onContentMouseLeave;
  var isInteractive = function isInteractive() {
    return !isPlaceholder && (Boolean(href) || Boolean(onClick));
  };
  var handleClick = function handleClick(event) {
    return handleClickCommon(event, onClick);
  };
  var handleMouseDown = useMouseDownEvent();
  var CompetitorPromptComponent = CompetitorPrompt && href ? /*#__PURE__*/React.createElement(CompetitorPrompt, {
    sourceUrl: href,
    linkType: "embed"
  }) : null;
  var renderHeader = function renderHeader() {
    return frameStyle !== 'hide' && /*#__PURE__*/React.createElement("div", {
      className: ax([styles.header, "embed-header"])
    }, /*#__PURE__*/React.createElement("div", {
      className: ax([styles.leftSection])
    }, /*#__PURE__*/React.createElement("div", {
      className: ax([styles.headerIcon])
    }, icon), /*#__PURE__*/React.createElement("div", {
      className: ax([styles.tooltipWrapper])
    }, !isPlaceholder && /*#__PURE__*/React.createElement(Tooltip, {
      content: text,
      hideTooltipOnMouseDown: true
    }, /*#__PURE__*/React.createElement("a", {
      href: href,
      onClick: handleClick,
      onMouseDown: handleMouseDown,
      className: ax([styles.headerAnchor])
    }, text)))), CompetitorPromptComponent);
  };
  var interactive = isInteractive();
  var showBackgroundAlways = frameStyle === 'show' || isSelected && frameStyle !== 'hide';
  var showBackgroundOnHover = interactive && frameStyle !== 'hide';
  var renderContent = function renderContent() {
    return /*#__PURE__*/React.createElement("div", {
      "data-testid": "embed-content-wrapper",
      // This fixes an issue with input fields in cross domain iframes (ie. databases and jira fields from different domains)
      // See: HOT-107830
      contentEditable: false,
      onMouseEnter: onContentMouseEnter,
      onMouseLeave: onContentMouseLeave,
      onFocus: onContentMouseEnter,
      onBlur: onContentMouseLeave,
      className: ax([styles.contentStyle, setOverflow && allowScrollBar && styles.contentOverflowAuto, interactive && !showBackgroundAlways && !showBackgroundOnHover && styles.contentInteractiveActiveBorder])
    }, children);
  };
  return /*#__PURE__*/React.createElement("div", _extends({
    // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
    className: ax([styles.linkWrapper, inheritDimensions && styles.linkWrapperInheritDimensions, isSelected && frameStyle !== 'hide' && styles.linkWrapperSelected, showBackgroundAlways && styles.linkWrapperBorderAndBackground, showBackgroundOnHover && !showBackgroundAlways && styles.linkWrapperInteractiveNotHidden, className]),
    style: {
      minWidth: minWidth ? "".concat(minWidth, "px") : '',
      maxWidth: maxWidth ? "".concat(maxWidth, "px") : ''
    },
    "data-testid": testId,
    "data-trello-do-not-use-override": testId
    // Due to limitations of testing library, we can't assert ::after
    ,
    "data-is-selected": isSelected
  }, (isPlaceholder || !href) && {
    'data-wrapper-type': 'default',
    'data-is-interactive': isInteractive()
  }), renderHeader(), renderContent());
};
var ExpandedFrameWithFG = componentWithFG('rovo_chat_embed_card_dwell_and_hover_metrics', ExpandedFrameUpdated, ExpandedFrame);
export { ExpandedFrameWithFG as ExpandedFrame };