function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

/*
Copyright (c) Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import * as React from 'react'; // Components

import MaybeChildMenu from './maybe-child-menu';
import { StyledListItemProfile, StyledProfileImgContainer, StyledProfileImg, StyledProfileLabelsContainer, StyledProfileTitle, StyledProfileSubtitle, StyledProfileBody } from './styled-components';
import { getOverrides } from '../helpers/overrides'; // Types

function OptionProfile(props, ref) {
  const {
    item,
    getChildMenu,
    getProfileItemLabels,
    getProfileItemImg,
    getProfileItemImgText,
    overrides = {},
    resetMenu = () => {},
    $isHighlighted,
    renderAll,
    ...restProps
  } = props;
  const [ListItemProfile, listItemProfileProps] = getOverrides(overrides.ListItemProfile, StyledListItemProfile);
  const [ProfileImgContainer, profileImgContainerProps] = getOverrides(overrides.ProfileImgContainer, StyledProfileImgContainer);
  const [ProfileImg, profileImgProps] = getOverrides(overrides.ProfileImg, StyledProfileImg);
  const [ProfileLabelsContainer, profileLabelsContainerProps] = getOverrides(overrides.ProfileLabelsContainer, StyledProfileLabelsContainer);
  const [ProfileTitle, profileTitleProps] = getOverrides(overrides.ProfileTitle, StyledProfileTitle);
  const [ProfileSubtitle, profileSubtitleProps] = getOverrides(overrides.ProfileSubtitle, StyledProfileSubtitle);
  const [ProfileBody, profileBodyProps] = getOverrides(overrides.ProfileBody, StyledProfileBody);
  const ItemImg = getProfileItemImg(item);
  const {
    title,
    subtitle,
    body
  } = getProfileItemLabels(item);
  return /*#__PURE__*/React.createElement(MaybeChildMenu // @ts-expect-error todo(flow->ts)
  , {
    ref: ref,
    getChildMenu: getChildMenu,
    isOpen: !!$isHighlighted,
    item: item,
    resetParentMenu: resetMenu,
    renderAll: renderAll,
    overrides: overrides
  }, /*#__PURE__*/React.createElement(ListItemProfile, _extends({}, restProps, listItemProfileProps), /*#__PURE__*/React.createElement(ProfileImgContainer, profileImgContainerProps, ItemImg && (typeof ItemImg === 'string' ?
  /*#__PURE__*/
  // Render img src string wrapped with image component
  React.createElement(ProfileImg, _extends({
    src: ItemImg,
    alt: getProfileItemImgText(item)
  }, profileImgProps)) :
  /*#__PURE__*/
  // Or just render the entire component user specified
  React.createElement(ItemImg, profileImgProps))), /*#__PURE__*/React.createElement(ProfileLabelsContainer, profileLabelsContainerProps, title && /*#__PURE__*/React.createElement(ProfileTitle, profileTitleProps, title), subtitle && /*#__PURE__*/React.createElement(ProfileSubtitle, profileSubtitleProps, subtitle), body && /*#__PURE__*/React.createElement(ProfileBody, profileBodyProps, body))));
}

const forwarded = /*#__PURE__*/React.forwardRef(OptionProfile);
forwarded.displayName = 'OptionProfile';
export default forwarded;