import React__default from 'react';
import cx from 'classnames';
import Note from '../note/index.js';
import { useFormContext } from '../use-form/index.js';
import '../objectWithoutProperties-72d23964.js';
import 'prop-types';
import '../ck-icon/index.js';
import '../extends-e61fd370.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-18999f8e.js';
import '@reach/visually-hidden';
import '../slicedToArray-5b664d46.js';
import '../button/button-group.js';
import '../index-81a9bdac.js';
import '../typeof-6c6d8d7a.js';
import '../auto-id.esm-2b54f757.js';
import '../utils.esm-514fad91.js';
import '../warning-ed2bf294.js';
import '../_commonjsHelpers-57e89916.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 };
