'use strict';

var clsx = require('clsx');
var React = require('react');
var Body = require('../../body/Body.js');
var Chevron = require('../../chevron/Chevron.js');
var Option = require('../../common/Option/Option.js');
var jsxRuntime = require('react/jsx-runtime');
var typography = require('../../common/propsValues/typography.js');
var position = require('../../common/propsValues/position.js');
var size = require('../../common/propsValues/size.js');

const AccordionItem = ({
  'aria-label': ariaLabel,
  id,
  title,
  subtitle,
  content,
  onClick,
  open,
  icon,
  theme = 'light'
}) => {
  const iconElement = icon ? /*#__PURE__*/React.cloneElement(icon, {
    size: 24
  }) : null;
  const fallbackId = React.useId();
  const accordionId = id ?? fallbackId;
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
    id: accordionId,
    className: clsx.clsx('np-accordion-item', iconElement ? 'np-accordion-item--with-icon' : null, {
      'np-accordion-item--open': open
    }),
    children: [/*#__PURE__*/jsxRuntime.jsx(Option, {
      "aria-label": ariaLabel,
      as: "button",
      media: iconElement,
      title: title,
      content: subtitle,
      button: /*#__PURE__*/jsxRuntime.jsx(Chevron, {
        orientation: open ? position.Position.TOP : position.Position.BOTTOM,
        size: size.Size.MEDIUM
      }),
      inverseMediaCircle: false,
      "aria-expanded": open,
      "aria-controls": `${accordionId}-section`,
      id: `${accordionId}-control`,
      onClick: onClick
    }), open && /*#__PURE__*/jsxRuntime.jsx("div", {
      id: `${accordionId}-section`,
      role: "region",
      "aria-labelledby": `${accordionId}-control`,
      children: /*#__PURE__*/jsxRuntime.jsx(Body, {
        as: "span",
        type: typography.Typography.BODY_LARGE,
        className: clsx.clsx('np-accordion-item__content', 'd-block', {
          'has-icon': icon
        }),
        children: content
      })
    })]
  });
};

module.exports = AccordionItem;
//# sourceMappingURL=AccordionItem.js.map
