'use strict';

var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var primitives_Slider = require('./primitives/Slider.js');
var utils = require('./utils-BhM0B89p.js');
var primitives_Field = require('./primitives/Field.js');

const Slider = React.forwardRef(
  ({
    label,
    error,
    helpText,
    required = false,
    className,
    labelProps,
    disabled,
    id: idProp,
    ...otherProps
  }, ref) => {
    const generatedId = React.useId();
    const id = idProp ?? generatedId;
    const errorId = `error_${id}`;
    const helpTextId = `helpText_${id}`;
    const ariaDescribedBy = [error ? errorId : null, helpText ? helpTextId : null].filter(Boolean).join(" ") || void 0;
    const hasField = !!(label || error || helpText);
    const slider = /* @__PURE__ */ jsxRuntime.jsx(
      primitives_Slider.Slider,
      {
        ref,
        id,
        disabled,
        "aria-invalid": !!error || void 0,
        "aria-describedby": ariaDescribedBy,
        "aria-label": !label ? void 0 : label,
        className: utils.cn(!hasField && className),
        ...otherProps
      }
    );
    if (!hasField) {
      return slider;
    }
    return /* @__PURE__ */ jsxRuntime.jsxs(
      primitives_Field.Field,
      {
        "data-disabled": disabled || void 0,
        "data-invalid": !!error || void 0,
        className,
        children: [
          label && /* @__PURE__ */ jsxRuntime.jsxs(primitives_Field.FieldLabel, { htmlFor: id, ...labelProps, children: [
            label,
            required && /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "text-destructive", children: "*" })
          ] }),
          /* @__PURE__ */ jsxRuntime.jsxs(primitives_Field.FieldContent, { children: [
            slider,
            !!error && /* @__PURE__ */ jsxRuntime.jsx(primitives_Field.FieldError, { id: errorId, children: error }),
            helpText && /* @__PURE__ */ jsxRuntime.jsx(primitives_Field.FieldDescription, { id: helpTextId, children: helpText })
          ] })
        ]
      }
    );
  }
);
Slider.displayName = "Slider";

exports.Slider = Slider;
//# sourceMappingURL=Slider-ICf2eQ6p.js.map
