'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var clsx = require('clsx');
require('../common/theme.js');
require('../common/direction.js');
require('../common/propsValues/control.js');
require('../common/propsValues/breakpoint.js');
require('../common/propsValues/size.js');
require('../common/propsValues/typography.js');
require('../common/propsValues/width.js');
require('../common/propsValues/type.js');
require('../common/propsValues/dateMode.js');
require('../common/propsValues/monthFormat.js');
require('../common/propsValues/position.js');
var layouts = require('../common/propsValues/layouts.js');
require('../common/propsValues/status.js');
require('../common/propsValues/sentiment.js');
require('../common/propsValues/profileType.js');
require('../common/propsValues/variant.js');
require('../common/propsValues/scroll.js');
require('../common/propsValues/markdownNodeType.js');
require('../common/fileType.js');
require('@transferwise/icons');
require('react');
require('react-intl');
require('../common/closeButton/CloseButton.messages.js');
var jsxRuntime = require('react/jsx-runtime');
var Button_resolver = require('../button/Button.resolver.js');

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

exports.default = DefinitionList;
//# sourceMappingURL=DefinitionList.js.map
