'use strict';

var jsxRuntime = require('react/jsx-runtime');
var primitives_Field = require('./primitives/Field.js');

function SelectFieldWrapper({
  id,
  label,
  error,
  helpText,
  errorId,
  helpTextId,
  isDisabled,
  required,
  testIdPrefix,
  labelProps,
  className,
  children
}) {
  const hasField = !!(label || error || helpText);
  if (!hasField) {
    return /* @__PURE__ */ jsxRuntime.jsx(
      "div",
      {
        className,
        ...testIdPrefix ? { "data-testid": `${testIdPrefix}-select-container-wrapper` } : {},
        children
      }
    );
  }
  return /* @__PURE__ */ jsxRuntime.jsxs(
    primitives_Field.Field,
    {
      "data-disabled": isDisabled || void 0,
      "data-invalid": !!error || void 0,
      className,
      ...testIdPrefix ? { "data-testid": `${testIdPrefix}-select-container-wrapper` } : {},
      children: [
        label && /* @__PURE__ */ jsxRuntime.jsxs(
          primitives_Field.FieldLabel,
          {
            htmlFor: id,
            ...labelProps,
            ...testIdPrefix ? { "data-testid": `${testIdPrefix}-input-label` } : {},
            children: [
              label,
              required && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "text-destructive", children: "*" })
            ]
          }
        ),
        /* @__PURE__ */ jsxRuntime.jsxs(primitives_Field.FieldContent, { children: [
          children,
          !!error && /* @__PURE__ */ jsxRuntime.jsx(
            primitives_Field.FieldError,
            {
              id: errorId,
              ...testIdPrefix ? { "data-testid": `${testIdPrefix}-select-error` } : {},
              children: error
            }
          ),
          helpText && /* @__PURE__ */ jsxRuntime.jsx(
            primitives_Field.FieldDescription,
            {
              id: helpTextId,
              ...testIdPrefix ? { "data-testid": `${testIdPrefix}-select-help-text` } : {},
              children: helpText
            }
          )
        ] })
      ]
    }
  );
}

exports.SelectFieldWrapper = SelectFieldWrapper;
//# sourceMappingURL=SelectFieldWrapper-DKkizQNM.js.map
