import { jsx, jsxs } from 'react/jsx-runtime';
import { forwardRef, useId } from 'react';
import { Slider as Slider$1 } from './primitives/Slider.js';
import { c as cn } from './utils-BJnb9o5c.js';
import { Field, FieldLabel, FieldContent, FieldError, FieldDescription } from './primitives/Field.js';

const Slider = forwardRef(
  ({
    label,
    error,
    helpText,
    required = false,
    className,
    labelProps,
    disabled,
    id: idProp,
    ...otherProps
  }, ref) => {
    const generatedId = 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__ */ jsx(
      Slider$1,
      {
        ref,
        id,
        disabled,
        "aria-invalid": !!error || void 0,
        "aria-describedby": ariaDescribedBy,
        "aria-label": !label ? void 0 : label,
        className: cn(!hasField && className),
        ...otherProps
      }
    );
    if (!hasField) {
      return slider;
    }
    return /* @__PURE__ */ jsxs(
      Field,
      {
        "data-disabled": disabled || void 0,
        "data-invalid": !!error || void 0,
        className,
        children: [
          label && /* @__PURE__ */ jsxs(FieldLabel, { htmlFor: id, ...labelProps, children: [
            label,
            required && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "text-destructive", children: "*" })
          ] }),
          /* @__PURE__ */ jsxs(FieldContent, { children: [
            slider,
            !!error && /* @__PURE__ */ jsx(FieldError, { id: errorId, children: error }),
            helpText && /* @__PURE__ */ jsx(FieldDescription, { id: helpTextId, children: helpText })
          ] })
        ]
      }
    );
  }
);
Slider.displayName = "Slider";

export { Slider as S };
//# sourceMappingURL=Slider-DNcH5X7b.js.map
