import { clsx } from 'clsx';
import { forwardRef, useId } from 'react';
import Body from '../body/Body.mjs';
import Chevron from '../chevron/Chevron.mjs';
import Option from '../common/Option/Option.mjs';
import { jsxs, jsx } from 'react/jsx-runtime';
import { Position } from '../common/propsValues/position.mjs';
import { Typography } from '../common/propsValues/typography.mjs';

const Card = /*#__PURE__*/forwardRef(function Card({
  'aria-label': ariaLabel,
  as: Element = 'div',
  isExpanded,
  title,
  details,
  children,
  onClick,
  icon,
  id,
  className,
  'data-testid': dataTestId
}, reference) {
  const labelId = useId();
  const contentId = useId();
  const isExpandable = Boolean(children);
  return /*#__PURE__*/jsxs(Element, {
    ref: reference,
    className: clsx('np-card', className, {
      'np-card--expanded': isExpandable && isExpanded,
      'np-card--inactive': !children,
      'np-card--has-icon': !!icon
    }),
    id: id,
    "data-testid": dataTestId,
    children: [/*#__PURE__*/jsx(Option, {
      "aria-expanded": isExpandable ? isExpanded : undefined,
      "aria-controls": isExpanded ? contentId : undefined,
      id: labelId,
      "aria-label": ariaLabel,
      as: isExpandable ? 'button' : 'div',
      className: "np-card__button",
      media: icon,
      title: title,
      content: details,
      showMediaAtAllSizes: true,
      button: isExpandable ? /*#__PURE__*/jsx(Chevron, {
        orientation: isExpanded ? Position.TOP : Position.BOTTOM
      }) : null,
      onClick: isExpandable ? () => onClick?.(!isExpanded) : undefined
    }), isExpandable && /*#__PURE__*/jsx("div", {
      className: clsx('np-card__divider', {
        'np-card__divider--expanded': isExpanded
      })
    }), isExpandable && isExpanded && /*#__PURE__*/jsx(Body, {
      as: "div",
      type: Typography.BODY_LARGE,
      className: clsx('np-card__content', isExpanded ? 'd-block' : 'hide'),
      id: contentId,
      "aria-labelledby": labelId,
      children: children
    })]
  });
});

export { Card as default };
//# sourceMappingURL=Card.mjs.map
