import{defineProperty as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as t}from"react/jsx-runtime";import{useRef as n,useEffect as o}from"react";import{DialogPosition as i}from"../../../constants/positions.js";import{NOOP as a}from"../../../utils/function-utils.js";import r from"../../Tooltip/Tooltip.js";import{TOOLTIP_SHOW_DELAY as l}from"../SliderConstants.js";import{bem as s}from"../SliderHelpers.js";import{useSliderSelection as u,useSliderUi as d,useSliderActions as c}from"../SliderContext.js";var m=i.TOP,p=function(i){var p=i.className,v=i.index,f=void 0===v?0:v,b=i.onMove,g=void 0===b?a:b,j=i.position,x=void 0===j?0:j,h=u(),L=h.max,P=h.min,y=h.ranged,T=h.value,w=h.valueText,E=y?T[f]:T,O=y?w[f]:w,D=d(),N=D.active,S=D.ariaLabel,B=D.ariaLabelledby,C=D.disabled,F=D.dragging,H=D.focused,I=D.shapeTestId,_=D.showValue,A=c(),M=A.setActive,V=A.setFocused,k=A.setDragging,q=n(null);function z(){k(null),document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",z)}return o((function(){H===f&&q&&q.current&&q.current.focus()}),[H,f]),t(r,Object.assign({open:N===f||F===f,content:_?null:O,position:m,showDelay:l},{children:t("div",Object.assign({"aria-label":S,"aria-labelledby":B,"aria-valuemax":L,"aria-valuemin":P,"aria-valuenow":E,"aria-valuetext":O,"aria-disabled":C,className:s("thumb",e({dragging:F===f,focused:H===f,disabled:C},"index-".concat(f),!0),p),"data-testid":I("thumb-".concat(f)),onFocus:function(){V(f),M(f)},onBlur:function(){V(null),M(null)},onPointerDown:function(e){e.stopPropagation(),k(f),document.addEventListener("pointermove",g),document.addEventListener("pointerup",z)},onPointerLeave:function(){M(null)},ref:q,role:"slider",style:{left:"".concat(x,"%")},tabIndex:C?-1:0},{children:_&&t("label",Object.assign({className:s("thumb-label")},{children:O}))}))}))};export{p as default};
