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

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