import{c as e,a as n,b as t,j as o,f as r,u as i,W as a,P as s,Q as d,N as l,ae as u}from"./ui-vendor-BxIDIFnU.js";import{r as c}from"./react-vendor-0XwOhuTY.js";import{T as f}from"./index-CK9GMtDj.js";var m=["PageUp","PageDown"],p=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],v={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},h="Slider",[w,g,S]=e(h),[b,x]=n(h,[S]),[y,D]=b(h),j=c.forwardRef((e,n)=>{const{name:i,min:a=0,max:s=100,step:d=1,orientation:l="horizontal",disabled:f=!1,minStepsBetweenThumbs:v=0,defaultValue:h=[a],value:g,onValueChange:S=()=>{},onValueCommit:b=()=>{},inverted:x=!1,form:D,...j}=e,R=c.useRef(new Set),_=c.useRef(0),M="horizontal"===l?E:P,[K=[],N]=t({prop:g,defaultProp:h,onChange:e=>{const n=[...R.current];n[_.current]?.focus(),S(e)}}),A=c.useRef(K);function k(e,n,{commit:t}={commit:!1}){const o=function(e){return(String(e).split(".")[1]||"").length}(d),r=function(e,n){const t=Math.pow(10,n);return Math.round(e*t)/t}(Math.round((e-a)/d)*d+a,o),i=u(r,[a,s]);N((e=[])=>{const o=function(e=[],n,t){const o=[...e];return o[t]=n,o.sort((e,n)=>e-n)}(e,i,n);if(function(e,n){if(n>0){const t=function(e){return e.slice(0,-1).map((n,t)=>e[t+1]-n)}(e);return Math.min(...t)>=n}return!0}(o,v*d)){_.current=o.indexOf(i);const n=String(o)!==String(e);return n&&t&&b(o),n?o:e}return e})}return o.jsx(y,{scope:e.__scopeSlider,name:i,disabled:f,min:a,max:s,valueIndexToChangeRef:_,thumbs:R.current,values:K,orientation:l,form:D,children:o.jsx(w.Provider,{scope:e.__scopeSlider,children:o.jsx(w.Slot,{scope:e.__scopeSlider,children:o.jsx(M,{"aria-disabled":f,"data-disabled":f?"":void 0,...j,ref:n,onPointerDown:r(j.onPointerDown,()=>{f||(A.current=K)}),min:a,max:s,inverted:x,onSlideStart:f?void 0:function(e){const n=function(e,n){if(1===e.length)return 0;const t=e.map(e=>Math.abs(e-n)),o=Math.min(...t);return t.indexOf(o)}(K,e);k(e,n)},onSlideMove:f?void 0:function(e){k(e,_.current)},onSlideEnd:f?void 0:function(){const e=A.current[_.current];K[_.current]!==e&&b(K)},onHomeKeyDown:()=>!f&&k(a,0,{commit:!0}),onEndKeyDown:()=>!f&&k(s,K.length-1,{commit:!0}),onStepKeyDown:({event:e,direction:n})=>{if(!f){const t=m.includes(e.key)||e.shiftKey&&p.includes(e.key)?10:1,o=_.current;k(K[o]+d*t*n,o,{commit:!0})}}})})})})});j.displayName=h;var[R,_]=b(h,{startEdge:"left",endEdge:"right",size:"width",direction:1}),E=c.forwardRef((e,n)=>{const{min:t,max:r,dir:s,inverted:d,onSlideStart:l,onSlideMove:u,onSlideEnd:f,onStepKeyDown:m,...p}=e,[h,w]=c.useState(null),g=i(n,e=>w(e)),S=c.useRef(void 0),b=a(s),x="ltr"===b,y=x&&!d||!x&&d;function D(e){const n=S.current||h.getBoundingClientRect(),o=L([0,n.width],y?[t,r]:[r,t]);return S.current=n,o(e-n.left)}return o.jsx(R,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:o.jsx(M,{dir:b,"data-orientation":"horizontal",...p,ref:g,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:e=>{const n=D(e.clientX);l?.(n)},onSlideMove:e=>{const n=D(e.clientX);u?.(n)},onSlideEnd:()=>{S.current=void 0,f?.()},onStepKeyDown:e=>{const n=v[y?"from-left":"from-right"].includes(e.key);m?.({event:e,direction:n?-1:1})}})})}),P=c.forwardRef((e,n)=>{const{min:t,max:r,inverted:a,onSlideStart:s,onSlideMove:d,onSlideEnd:l,onStepKeyDown:u,...f}=e,m=c.useRef(null),p=i(n,m),h=c.useRef(void 0),w=!a;function g(e){const n=h.current||m.current.getBoundingClientRect(),o=L([0,n.height],w?[r,t]:[t,r]);return h.current=n,o(e-n.top)}return o.jsx(R,{scope:e.__scopeSlider,startEdge:w?"bottom":"top",endEdge:w?"top":"bottom",size:"height",direction:w?1:-1,children:o.jsx(M,{"data-orientation":"vertical",...f,ref:p,style:{...f.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:e=>{const n=g(e.clientY);s?.(n)},onSlideMove:e=>{const n=g(e.clientY);d?.(n)},onSlideEnd:()=>{h.current=void 0,l?.()},onStepKeyDown:e=>{const n=v[w?"from-bottom":"from-top"].includes(e.key);u?.({event:e,direction:n?-1:1})}})})}),M=c.forwardRef((e,n)=>{const{__scopeSlider:t,onSlideStart:i,onSlideMove:a,onSlideEnd:d,onHomeKeyDown:l,onEndKeyDown:u,onStepKeyDown:c,...f}=e,v=D(h,t);return o.jsx(s.span,{...f,ref:n,onKeyDown:r(e.onKeyDown,e=>{"Home"===e.key?(l(e),e.preventDefault()):"End"===e.key?(u(e),e.preventDefault()):m.concat(p).includes(e.key)&&(c(e),e.preventDefault())}),onPointerDown:r(e.onPointerDown,e=>{const n=e.target;n.setPointerCapture(e.pointerId),e.preventDefault(),v.thumbs.has(n)?n.focus():i(e)}),onPointerMove:r(e.onPointerMove,e=>{e.target.hasPointerCapture(e.pointerId)&&a(e)}),onPointerUp:r(e.onPointerUp,e=>{const n=e.target;n.hasPointerCapture(e.pointerId)&&(n.releasePointerCapture(e.pointerId),d(e))})})}),K="SliderTrack",N=c.forwardRef((e,n)=>{const{__scopeSlider:t,...r}=e,i=D(K,t);return o.jsx(s.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:n})});N.displayName=K;var A="SliderRange",k=c.forwardRef((e,n)=>{const{__scopeSlider:t,...r}=e,a=D(A,t),d=_(A,t),l=c.useRef(null),u=i(n,l),f=a.values.length,m=a.values.map(e=>T(e,a.min,a.max)),p=f>1?Math.min(...m):0,v=100-Math.max(...m);return o.jsx(s.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:u,style:{...e.style,[d.startEdge]:p+"%",[d.endEdge]:v+"%"}})});k.displayName=A;var C="SliderThumb",I=c.forwardRef((e,n)=>{const t=g(e.__scopeSlider),[r,a]=c.useState(null),s=i(n,e=>a(e)),d=c.useMemo(()=>r?t().findIndex(e=>e.ref.current===r):-1,[t,r]);return o.jsx(H,{...e,ref:s,index:d})}),H=c.forwardRef((e,n)=>{const{__scopeSlider:t,index:a,name:l,...u}=e,f=D(C,t),m=_(C,t),[p,v]=c.useState(null),h=i(n,e=>v(e)),g=!p||(f.form||!!p.closest("form")),S=d(p),b=f.values[a],x=void 0===b?0:T(b,f.min,f.max),y=function(e,n){return n>2?`Value ${e+1} of ${n}`:2===n?["Minimum","Maximum"][e]:void 0}(a,f.values.length),j=S?.[m.size],R=j?function(e,n,t){const o=e/2,r=L([0,50],[0,o]);return(o-r(n)*t)*t}(j,x,m.direction):0;return c.useEffect(()=>{if(p)return f.thumbs.add(p),()=>{f.thumbs.delete(p)}},[p,f.thumbs]),o.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[m.startEdge]:`calc(${x}% + ${R}px)`},children:[o.jsx(w.ItemSlot,{scope:e.__scopeSlider,children:o.jsx(s.span,{role:"slider","aria-label":e["aria-label"]||y,"aria-valuemin":f.min,"aria-valuenow":b,"aria-valuemax":f.max,"aria-orientation":f.orientation,"data-orientation":f.orientation,"data-disabled":f.disabled?"":void 0,tabIndex:f.disabled?void 0:0,...u,ref:h,style:void 0===b?{display:"none"}:e.style,onFocus:r(e.onFocus,()=>{f.valueIndexToChangeRef.current=a})})}),g&&o.jsx(z,{name:l??(f.name?f.name+(f.values.length>1?"[]":""):void 0),form:f.form,value:b},a)]})});I.displayName=C;var z=c.forwardRef(({__scopeSlider:e,value:n,...t},r)=>{const a=c.useRef(null),d=i(a,r),u=l(n);return c.useEffect(()=>{const e=a.current;if(!e)return;const t=window.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(t,"value").set;if(u!==n&&o){const t=new Event("input",{bubbles:!0});o.call(e,n),e.dispatchEvent(t)}},[u,n]),o.jsx(s.input,{style:{display:"none"},...t,ref:d,defaultValue:n})});function T(e,n,t){return u(100/(t-n)*(e-n),[0,100])}function L(e,n){return t=>{if(e[0]===e[1]||n[0]===n[1])return n[0];const o=(n[1]-n[0])/(e[1]-e[0]);return n[0]+o*(t-e[0])}}z.displayName="RadioBubbleInput";var U=j,V=N,B=k,O=I;const $=c.forwardRef(({className:e,...n},t)=>o.jsxs(U,{ref:t,className:f("relative flex w-full touch-none select-none items-center",e),...n,children:[o.jsx(V,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:o.jsx(B,{className:"absolute h-full bg-primary"})}),o.jsx(O,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));$.displayName=U.displayName;export{$ as S};