function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
var _excluded = ["as", "clickable", "disabled", "href", "size", "children", "onBlur", "onFocus", "rel", "role", "target"],
  _excluded2 = ["icon"],
  _excluded3 = ["children"],
  _excluded4 = ["imageUrl"];
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); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { useButton } from '@react-aria/button';
import React from 'react';
import { addSubcomponents } from '../_utils/addSubcomponents';
import { StyledAvatarContainer, StyledAvatarOverlay, StyledIconContainer, StyledLabelContainer, StyledPortraitContainer } from './Avatar.styles';
/**

 We use avatars to visually represent our users, places, and things in the app.
 These can be in the form of rich media or representative illustrations.

 @since 10.19.0

 @see [Storybook](https://stories.core.procore.com/?path=/story/core-react_demos-avatar--demo)

 @see [Design Guidelines](https://design.procore.com/avatar)

 @a11y Avatar's need a `aria-label` and can be enhanced with `role` for interaction. If decorative only, add `aria-hidden`. The inaccessible `clickable` prop is for UI only

 */
function AvatarInner(_ref, ref) {
  var _ref3, _ref4;
  var as = _ref.as,
    clickable = _ref.clickable,
    disabled = _ref.disabled,
    href = _ref.href,
    size = _ref.size,
    children = _ref.children,
    onBlur = _ref.onBlur,
    onFocus = _ref.onFocus,
    rel = _ref.rel,
    role = _ref.role,
    target = _ref.target,
    props = _objectWithoutProperties(_ref, _excluded);
  var _ref2 = props,
    onPress = _ref2.onPress;
  var _useButton = useButton(_objectSpread(_objectSpread({}, props), {}, {
      onBlur: onBlur,
      onFocus: onFocus,
      elementType: as === 'a' ? 'a' : 'div',
      href: href,
      isDisabled: disabled,
      onPress: onPress,
      rel: rel,
      target: target,
      type: 'button'
    }), ref // TODO fix
    ),
    buttonProps = _useButton.buttonProps;
  var linkDisabled = disabled || role === 'link' && !href;
  var a11yProps = role === 'button' ? _objectSpread(_objectSpread({}, buttonProps), {}, {
    as: as || 'div',
    $clickable: !disabled
  }) : role === 'link' ? (_ref3 = {}, _defineProperty(_ref3, 'aria-disabled', linkDisabled ? true : undefined), _defineProperty(_ref3, "as", as || 'a'), _defineProperty(_ref3, "$clickable", !linkDisabled), _defineProperty(_ref3, "href", linkDisabled ? undefined : href), _defineProperty(_ref3, "onBlur", onBlur), _defineProperty(_ref3, "onFocus", onFocus), _defineProperty(_ref3, "rel", rel), _defineProperty(_ref3, "role", 'link'), _defineProperty(_ref3, "target", target), _ref3) : role === 'img' ? (_ref4 = {}, _defineProperty(_ref4, 'aria-disabled', disabled ? true : undefined), _defineProperty(_ref4, "role", 'img'), _defineProperty(_ref4, "onBlur", onBlur), _defineProperty(_ref4, "onFocus", onFocus), _ref4) : {
    onBlur: onBlur,
    onFocus: onFocus
  };
  return /*#__PURE__*/React.createElement(StyledAvatarContainer, _extends({
    ref: ref,
    $clickable: clickable,
    $disabled: disabled,
    $size: size,
    "data-qa": "core-avatar"
  }, a11yProps, props), React.Children.only(children), /*#__PURE__*/React.createElement(StyledAvatarOverlay, {
    "aria-hidden": true
  }));
}
var Avatar_ = /*#__PURE__*/React.forwardRef(AvatarInner);
var NextAvatar_ = /*#__PURE__*/React.forwardRef(AvatarInner);
export var Icon = /*#__PURE__*/React.forwardRef(function Icon(_ref5, ref) {
  var icon = _ref5.icon,
    props = _objectWithoutProperties(_ref5, _excluded2);
  return /*#__PURE__*/React.createElement(StyledIconContainer, _extends({
    ref: ref
  }, props), icon);
});
export var Label = /*#__PURE__*/React.forwardRef(function Label(_ref6, ref) {
  var children = _ref6.children,
    props = _objectWithoutProperties(_ref6, _excluded3);
  // Breaking change: Option to make aria-hidden since parent requires a label.
  // Can add in major once labelling is enforced
  return /*#__PURE__*/React.createElement(StyledLabelContainer, _extends({
    ref: ref
  }, props), children);
});
export var Portrait = /*#__PURE__*/React.forwardRef(function Portrait(_ref7, ref) {
  var imageUrl = _ref7.imageUrl,
    props = _objectWithoutProperties(_ref7, _excluded4);
  return /*#__PURE__*/React.createElement(StyledPortraitContainer, _extends({
    ref: ref,
    $imageUrl: imageUrl
  }, props), /*#__PURE__*/React.createElement(StyledAvatarOverlay, null));
});

// @ts-ignore
Avatar_.displayName = 'Avatar';
Icon.displayName = 'Avatar.Icon';
Label.displayName = 'Avatar.Label';
Portrait.displayName = 'Avatar.Portrait';

// @ts-ignore
NextAvatar_.displayName = 'Avatar';
export var NextAvatar = addSubcomponents({
  Icon: Icon,
  Label: Label,
  Portrait: Portrait
}, NextAvatar_);
export var Avatar = addSubcomponents({
  Icon: Icon,
  Label: Label,
  Portrait: Portrait
}, Avatar_);
//# sourceMappingURL=Avatar.js.map