"use client";
import { Box } from "../../../core/Box/Box.mjs";
import { Transition } from "../../Transition/Transition.mjs";
import { useSliderContext } from "../Slider.context.mjs";
import { useState } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/Slider/Thumb/Thumb.tsx
function Thumb({ max, min, value, position, label, dragging, onMouseDown, onKeyDownCapture, labelTransitionProps, labelAlwaysOn, thumbLabel, thumbValueText, onFocus, onBlur, showLabelOnHover, isHovered, children = null, disabled, orientation = "horizontal", ref }) {
	const { getStyles } = useSliderContext();
	const [focused, setFocused] = useState(false);
	const isVisible = labelAlwaysOn || dragging || focused || showLabelOnHover && isHovered;
	const valueText = typeof thumbValueText === "function" ? thumbValueText(value) : thumbValueText;
	return /* @__PURE__ */ jsxs(Box, {
		tabIndex: disabled ? -1 : 0,
		role: "slider",
		"aria-label": thumbLabel,
		"aria-valuemax": max,
		"aria-valuemin": min,
		"aria-valuenow": value,
		"aria-valuetext": valueText,
		"aria-disabled": disabled,
		"aria-orientation": orientation,
		ref,
		__vars: { "--slider-thumb-offset": `${position}%` },
		...getStyles("thumb", { focusable: true }),
		mod: {
			dragging,
			disabled
		},
		onFocus: (event) => {
			setFocused(true);
			typeof onFocus === "function" && onFocus(event);
		},
		onBlur: (event) => {
			setFocused(false);
			typeof onBlur === "function" && onBlur(event);
		},
		onTouchStart: onMouseDown,
		onMouseDown,
		onKeyDownCapture,
		onClick: (event) => event.stopPropagation(),
		children: [children, /* @__PURE__ */ jsx(Transition, {
			mounted: label != null && !!isVisible,
			transition: "fade",
			duration: 0,
			...labelTransitionProps,
			children: (transitionStyles) => /* @__PURE__ */ jsx("div", {
				...getStyles("label", { style: transitionStyles }),
				children: label
			})
		})]
	});
}
Thumb.displayName = "@mantine/core/SliderThumb";
//#endregion
export { Thumb };

//# sourceMappingURL=Thumb.mjs.map