/**
 * DevExtreme (esm/__internal/ui/slider/m_slider_handle.js)
 * Version: 23.2.9 (build 24294-0112)
 * Build date: Sun Oct 20 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import $ from "../../../core/renderer";
import {
    extend
} from "../../../core/utils/extend";
import Widget from "../../../ui/widget/ui.widget";
import SliderTooltip from "./m_slider_tooltip";
var SLIDER_HANDLE_CLASS = "dx-slider-handle";
var SliderHandle = Widget.inherit({
    _getDefaultOptions() {
        return extend(this.callBase(), {
            hoverStateEnabled: false,
            value: 0,
            tooltip: {
                enabled: false,
                format: value => value,
                position: "top",
                showMode: "onHover"
            }
        })
    },
    _initMarkup() {
        this.callBase();
        this.$element().addClass(SLIDER_HANDLE_CLASS);
        this.setAria({
            role: "slider",
            valuenow: this.option("value"),
            label: "Slider"
        })
    },
    _render() {
        this.callBase();
        this._renderTooltip()
    },
    _renderTooltip() {
        var {
            tooltip: tooltip,
            value: value
        } = this.option();
        var {
            position: position,
            format: format,
            enabled: enabled,
            showMode: showMode
        } = tooltip;
        var $sliderTooltip = $("<div>");
        this._sliderTooltip = this._createComponent($sliderTooltip, SliderTooltip, {
            target: this.$element(),
            container: $sliderTooltip,
            position: position,
            visible: enabled,
            showMode: showMode,
            format: format,
            value: value
        })
    },
    _clean() {
        this.callBase();
        this._sliderTooltip = null
    },
    _updateTooltipOptions(args) {
        var _a;
        var tooltipOptions = Widget.getOptionsFromContainer(args);
        this._setWidgetOption("_sliderTooltip", [tooltipOptions]);
        null === (_a = this._sliderTooltip) || void 0 === _a ? void 0 : _a.option("visible", tooltipOptions.enabled)
    },
    _optionChanged(args) {
        var _a;
        var {
            name: name,
            value: value
        } = args;
        switch (name) {
            case "value":
                null === (_a = this._sliderTooltip) || void 0 === _a ? void 0 : _a.option("value", value);
                this.setAria("valuenow", value);
                break;
            case "tooltip":
                this._updateTooltipOptions(args);
                break;
            default:
                this.callBase(args)
        }
    },
    updateTooltipPosition() {
        var _a;
        null === (_a = this._sliderTooltip) || void 0 === _a ? void 0 : _a.updatePosition()
    },
    repaint() {
        var _a;
        null === (_a = this._sliderTooltip) || void 0 === _a ? void 0 : _a.repaint()
    }
});
export default SliderHandle;
