import { tooltipLegacyDriverFactory } from '../Tooltip/Tooltip.driver';
import { dataHooks } from './constants';
const sliderDriverFactory = ({ element, eventTrigger }) => {
    const $sliderHandles = () => element.querySelectorAll(`[data-hook="${dataHooks.sliderHandle}"]`);
    const $sliderDots = () => element.querySelectorAll('.wsr-slider-dot');
    const $sliderMarks = () => element.querySelectorAll(`[data-hook="${dataHooks.sliderMarkLabel}"]`);
    const getTooltipDriver = index => {
        const sliderDataHook = element.getAttribute('data-hook');
        const tooltipDataHook = sliderDataHook
            ? `${sliderDataHook}-${dataHooks.sliderTooltip}-${index}`
            : `${dataHooks.sliderTooltip}-${index}`;
        return tooltipLegacyDriverFactory({
            element: element.querySelector(`[data-hook="${tooltipDataHook}"]`),
            eventTrigger,
        });
    };
    return {
        /** returns true if element in the DOM */
        exists: () => !!element,
        /** returns true if slider grade is selected */
        isDotSelected: number => $sliderDots()
            .item(number - 1)
            .classList.contains('wsr-slider-dot-active'),
        /** returns number of slider grades */
        numOfSliderDots: () => $sliderDots().length,
        /** returns number of slider handles */
        numOfSliderHandles: () => $sliderHandles().length,
        /** returns number of slider marks labels */
        numOfSliderMarksLabels: () => $sliderMarks().length,
        /** returns slider tooltip value */
        getToolTipValue: index => {
            const tooltipDriver = getTooltipDriver(index);
            let text = null;
            try {
                text = tooltipDriver.getTooltipText();
            }
            catch { }
            return text;
        },
        /** returns if the slider is disabled */
        isDisabled: () => {
            return !!element.querySelector('.wsr-slider-disabled');
        },
    };
};
export default sliderDriverFactory;
//# sourceMappingURL=Slider.driver.js.map