"use strict";

exports.__esModule = true;
exports.default = void 0;
var _Tooltip = require("../Tooltip/Tooltip.driver");
var _constants = require("./constants");
var sliderDriverFactory = _ref => {
  var {
    element,
    eventTrigger
  } = _ref;
  var $sliderHandles = () => element.querySelectorAll("[data-hook=\"".concat(_constants.dataHooks.sliderHandle, "\"]"));
  var $sliderDots = () => element.querySelectorAll('.wsr-slider-dot');
  var $sliderMarks = () => element.querySelectorAll("[data-hook=\"".concat(_constants.dataHooks.sliderMarkLabel, "\"]"));
  var getTooltipDriver = index => {
    var sliderDataHook = element.getAttribute('data-hook');
    var tooltipDataHook = sliderDataHook ? "".concat(sliderDataHook, "-").concat(_constants.dataHooks.sliderTooltip, "-").concat(index) : "".concat(_constants.dataHooks.sliderTooltip, "-").concat(index);
    return (0, _Tooltip.tooltipLegacyDriverFactory)({
      element: element.querySelector("[data-hook=\"".concat(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 => {
      var tooltipDriver = getTooltipDriver(index);
      var text = null;
      try {
        text = tooltipDriver.getTooltipText();
      } catch (_unused) {}
      return text;
    },
    /** returns if the slider is disabled */
    isDisabled: () => {
      return !!element.querySelector('.wsr-slider-disabled');
    }
  };
};
var _default = exports.default = sliderDriverFactory;
//# sourceMappingURL=Slider.driver.js.map