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