'use strict';

var React = require('react');
var jsxRuntime = require('react/jsx-runtime');

const FieldLabelContext = /*#__PURE__*/React.createContext(undefined);
const FieldLabelContextProvider = FieldLabelContext.Provider;
const InputIdContext = /*#__PURE__*/React.createContext(undefined);
const InputIdContextProvider = InputIdContext.Provider;
const InputDescribedByContext = /*#__PURE__*/React.createContext(undefined);
const InputDescribedByProvider = InputDescribedByContext.Provider;
const InputInvalidContext = /*#__PURE__*/React.createContext(undefined);
const InputInvalidProvider = InputInvalidContext.Provider;
function useInputAttributes({
  nonLabelable
} = {}) {
  const labelId = React.useContext(FieldLabelContext)?.id;
  return {
    id: React.useContext(InputIdContext),
    'aria-labelledby': nonLabelable ? labelId : undefined,
    'aria-describedby': React.useContext(InputDescribedByContext),
    'aria-invalid': React.useContext(InputInvalidContext)
  };
}
function useFieldLabelRef() {
  return React.useContext(FieldLabelContext)?.ref;
}
function withInputAttributes(Component, args) {
  function ComponentWithInputAttributes(props) {
    return /*#__PURE__*/jsxRuntime.jsx(Component, {
      inputAttributes: useInputAttributes(args),
      ...props
    });
  }
  ComponentWithInputAttributes.displayName = `withInputAttributes(${Component.displayName || Component.name || 'Component'})`;
  return ComponentWithInputAttributes;
}

exports.FieldLabelContextProvider = FieldLabelContextProvider;
exports.InputDescribedByProvider = InputDescribedByProvider;
exports.InputIdContextProvider = InputIdContextProvider;
exports.InputInvalidProvider = InputInvalidProvider;
exports.useFieldLabelRef = useFieldLabelRef;
exports.useInputAttributes = useInputAttributes;
exports.withInputAttributes = withInputAttributes;
//# sourceMappingURL=contexts.js.map
