import React__default from 'react';
import cx from 'classnames';
import Note from '../note/index.js';
import { useFormContext } from '../use-form/index.js';
import '../objectWithoutProperties-TXwlfNxG.js';
import 'prop-types';
import '../ck-icon/index.js';
import '../extends-C4cduGrv.js';
import '../ck-icon/assets/icon-map/index.js';
import '../icon/index.js';
import '@fortawesome/react-fontawesome';
import '../icon/icons.js';
import '../icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/pro-solid-svg-icons';
import '@fortawesome/pro-light-svg-icons';
import '@fortawesome/free-brands-svg-icons';
import '../button/index.js';
import '../defineProperty-CEd-kZQW.js';
import '@reach/visually-hidden';
import '../slicedToArray-BB-AwwkK.js';
import '../floating-ui.react-cWPyyUrN.js';
import '../typeof-CgC7Bq6K.js';
import '../toConsumableArray-dKQYsfpV.js';
import '../index-qSfOyGhk.js';
import 'react-dom';
import '../button/button-group.js';
import '../auto-id.esm-Cly76abB.js';
import '../utils.esm-CKyxlHOy.js';
import '../warning-s9zGJbnw.js';
import '../_commonjsHelpers-_1FafXWI.js';
import '../use-progress/index.js';
import '../use-trailing-debounce/index.js';

var capitalize = function capitalize(str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
};

function ValidationErrors() {
  var _useFormContext = useFormContext(),
      errors = _useFormContext.errors;

  var keys = Object.keys(errors);
  if (keys.length === 0) return null;
  return /*#__PURE__*/React__default.createElement(Note, {
    className: "mb-2",
    type: "warning"
  }, /*#__PURE__*/React__default.createElement("ul", {
    className: "list-none p-0"
  }, keys.map(function (key, index) {
    var label = capitalize(key.replace("_", " "));
    var message = errors[key].join("; ");
    var className = cx({
      "mt-1": index > 0
    });
    return /*#__PURE__*/React__default.createElement("li", {
      className: className,
      key: key
    }, "".concat(label, " ").concat(message));
  })));
}

export { ValidationErrors as default };
