import { clsx } from 'clsx';
import '../common/theme.mjs';
import '../common/direction.mjs';
import '@transferwise/neptune-tokens';
import '../common/propsValues/control.mjs';
import '../common/propsValues/size.mjs';
import '../common/propsValues/typography.mjs';
import '../common/propsValues/width.mjs';
import '../common/propsValues/type.mjs';
import '../common/propsValues/dateMode.mjs';
import '../common/propsValues/monthFormat.mjs';
import '../common/propsValues/position.mjs';
import { Layout } from '../common/propsValues/layouts.mjs';
import '../common/propsValues/status.mjs';
import '../common/propsValues/sentiment.mjs';
import '../common/propsValues/profileType.mjs';
import '../common/propsValues/variant.mjs';
import '../common/propsValues/scroll.mjs';
import '../common/propsValues/markdownNodeType.mjs';
import '../common/fileType.mjs';
import '@transferwise/formatting';
import '@transferwise/icons';
import 'react';
import 'react-intl';
import '../common/closeButton/CloseButton.messages.mjs';
import { jsx, jsxs } from 'react/jsx-runtime';
import Button from '../button/Button.resolver.mjs';

const isLayoutHorizontal = layout => layout === Layout.HORIZONTAL_LEFT_ALIGNED || layout === Layout.HORIZONTAL_RIGHT_ALIGNED || layout === Layout.HORIZONTAL_JUSTIFIED;
const getAlignmentClasses = (layout, action) => {
  const classes = ['d-flex'];
  if (action) {
    if (isLayoutHorizontal(layout)) {
      classes.push('align-items-center');
    } else {
      classes.push('align-items-start');
    }
  }
  if (layout === Layout.HORIZONTAL_RIGHT_ALIGNED) {
    classes.push('text-sm-right tw-definition-list--right-aligned-desktop');
  } else {
    classes.push('justify-content-between');
  }
  if (layout === Layout.HORIZONTAL_JUSTIFIED) {
    classes.push('text-sm-justify');
  }
  return classes;
};
const defaultDefinitions = [];
function DefinitionList({
  definitions = defaultDefinitions,
  layout = 'VERTICAL_TWO_COLUMN',
  muted
}) {
  return /*#__PURE__*/jsx("dl", {
    className: clsx('tw-definition-list d-flex ', {
      'text-muted': muted,
      'flex-column': layout === Layout.VERTICAL_ONE_COLUMN,
      'tw-definition-list--columns flex-column flex-row--sm': layout === Layout.VERTICAL_TWO_COLUMN,
      'tw-definition-list--horizontal flex-column': isLayoutHorizontal(layout)
    }),
    children: definitions.filter(definition => definition).map(({
      action,
      title,
      value,
      key
    }) => /*#__PURE__*/jsxs("div", {
      className: "tw-definition-list__item",
      children: [/*#__PURE__*/jsx("dt", {
        children: title
      }), /*#__PURE__*/jsxs("dd", {
        className: clsx(...getAlignmentClasses(layout, action)),
        children: [/*#__PURE__*/jsx("div", {
          children: value
        }), action ? /*#__PURE__*/jsx("div", {
          className: clsx(isLayoutHorizontal(layout) ? 'p-l-2' : 'p-x-2', 'tw-definition-list__action'),
          children: /*#__PURE__*/jsx(Button, {
            as: "button",
            size: "sm",
            v2: true,
            onClick: action.onClick,
            children: action.label
          })
        }) : null]
      })]
    }, key))
  });
}

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