"use client";
import { jsxs, jsx } from 'react/jsx-runtime';
import { cx, cva } from '../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js';
import { forwardRef } from 'react';
import { Text } from '../text/text.js';
import styles from './slider.module.css.js';
import { ThumbIcon } from './thumb.js';
import { Root, Track, Range, Thumb } from '../../node_modules/.pnpm/@radix-ui_react-slider@1.3.5_@types_react-dom@19.1.7_@types_react@19.1.9__@types_react@19.1.9_p32zwhugtqgn4tfikzqx3cas2u/node_modules/@radix-ui/react-slider/dist/index.js';

const slider = cva(styles.slider, {
    variants: {
        variant: {
            single: styles['slider-variant-single'],
            range: styles['slider-variant-range']
        }
    },
    defaultVariants: {
        variant: 'single'
    }
});
const Slider = forwardRef(({ className, variant = 'single', value, defaultValue, min = 0, max = 100, step = 1, label, onChange, 'aria-label': ariaLabel, 'aria-valuetext': ariaValueText, thumbSize = 'large', ...props }, ref) => {
    const isRange = variant === 'range';
    const isThumbSmall = thumbSize === 'small';
    const defaultVal = isRange
        ? defaultValue || [min, max]
        : [defaultValue || min];
    const currentValue = value
        ? isRange
            ? value
            : [value]
        : defaultVal;
    const getLabel = (index) => {
        if (!label)
            return undefined;
        if (typeof label === 'string')
            return label;
        return label[index];
    };
    const getAriaValueText = (index) => {
        if (ariaValueText)
            return ariaValueText;
        const labelText = getLabel(index);
        const val = currentValue[index];
        return labelText ? `${labelText}: ${val}` : `${val}`;
    };
    return (jsxs(Root, { ref: ref, className: `${slider({ variant })} ${className || ''}`, value: value ? currentValue : undefined, defaultValue: defaultVal, min: min, max: max, step: step, onValueChange: val => onChange?.(isRange ? val : val[0]), "aria-label": ariaLabel || (isRange ? 'Range slider' : 'Slider'), ...props, children: [jsx(Track, { className: styles.track, children: jsx(Range, { className: styles.range }) }), defaultVal.map((_, i) => (jsx(Thumb, { className: cx(styles.thumb), asChild: true, "aria-label": getLabel(i) || `Thumb ${i + 1}`, "aria-valuetext": getAriaValueText(i), "data-size": thumbSize, children: jsxs("div", { children: [isThumbSmall ? (jsx("div", { className: styles.thumbSmall })) : (jsx(ThumbIcon, {})), getLabel(i) && (jsx(Text, { className: styles.label, size: isThumbSmall ? 'micro' : 'mini', weight: 'medium', children: getLabel(i) }))] }) }, i)))] }));
});
Slider.displayName = 'Slider';

export { Slider };
//# sourceMappingURL=slider.js.map
