import{a9 as le,w as de,r as l,N as ue,j as f,D as C,x as M,K as fe,y as V,I as me,F as pe,Q as he}from"./index-E6IUtMcU.js";import{c as Y}from"./index-BdQq_4o_.js";var $=["PageUp","PageDown"],X=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],G={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},j="Slider",[H,Se,ge]=le(j),[W,Te]=de(j,[ge]),[be,B]=W(j),Q=l.forwardRef((e,t)=>{const{name:n,min:o=0,max:a=100,step:c=1,orientation:r="horizontal",disabled:i=!1,minStepsBetweenThumbs:d=0,defaultValue:S=[o],value:g,onValueChange:s=()=>{},onValueCommit:u=()=>{},inverted:v=!1,form:y,...b}=e,p=l.useRef(new Set),m=l.useRef(0),x=r==="horizontal"?ve:xe,[h=[],I]=ue({prop:g,defaultProp:S,onChange:w=>{var E;(E=[...p.current][m.current])==null||E.focus(),s(w)}}),N=l.useRef(h);function T(w){const R=De(h,w);A(w,R)}function ae(w){A(w,m.current)}function ce(){const w=N.current[m.current];h[m.current]!==w&&u(h)}function A(w,R,{commit:E}={commit:!1}){const F=Me(c),k=je(Math.round((w-o)/c)*c+o,F),K=Y(k,[o,a]);I((_=[])=>{const P=Re(_,K,R);if(Ce(P,d*c)){m.current=P.indexOf(K);const U=String(P)!==String(_);return U&&E&&u(P),U?P:_}else return _})}return f.jsx(be,{scope:e.__scopeSlider,name:n,disabled:i,min:o,max:a,valueIndexToChangeRef:m,thumbs:p.current,values:h,orientation:r,form:y,children:f.jsx(H.Provider,{scope:e.__scopeSlider,children:f.jsx(H.Slot,{scope:e.__scopeSlider,children:f.jsx(x,{"aria-disabled":i,"data-disabled":i?"":void 0,...b,ref:t,onPointerDown:C(b.onPointerDown,()=>{i||(N.current=h)}),min:o,max:a,inverted:v,onSlideStart:i?void 0:T,onSlideMove:i?void 0:ae,onSlideEnd:i?void 0:ce,onHomeKeyDown:()=>!i&&A(o,0,{commit:!0}),onEndKeyDown:()=>!i&&A(a,h.length-1,{commit:!0}),onStepKeyDown:({event:w,direction:R})=>{if(!i){const k=$.includes(w.key)||w.shiftKey&&X.includes(w.key)?10:1,K=m.current,_=h[K],P=c*k*R;A(_+P,K,{commit:!0})}}})})})})});Q.displayName=j;var[q,J]=W(j,{startEdge:"left",endEdge:"right",size:"width",direction:1}),ve=l.forwardRef((e,t)=>{const{min:n,max:o,dir:a,inverted:c,onSlideStart:r,onSlideMove:i,onSlideEnd:d,onStepKeyDown:S,...g}=e,[s,u]=l.useState(null),v=M(t,x=>u(x)),y=l.useRef(void 0),b=fe(a),p=b==="ltr",m=p&&!c||!p&&c;function D(x){const h=y.current||s.getBoundingClientRect(),I=[0,h.width],T=O(I,m?[n,o]:[o,n]);return y.current=h,T(x-h.left)}return f.jsx(q,{scope:e.__scopeSlider,startEdge:m?"left":"right",endEdge:m?"right":"left",direction:m?1:-1,size:"width",children:f.jsx(Z,{dir:b,"data-orientation":"horizontal",...g,ref:v,style:{...g.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:x=>{const h=D(x.clientX);r==null||r(h)},onSlideMove:x=>{const h=D(x.clientX);i==null||i(h)},onSlideEnd:()=>{y.current=void 0,d==null||d()},onStepKeyDown:x=>{const I=G[m?"from-left":"from-right"].includes(x.key);S==null||S({event:x,direction:I?-1:1})}})})}),xe=l.forwardRef((e,t)=>{const{min:n,max:o,inverted:a,onSlideStart:c,onSlideMove:r,onSlideEnd:i,onStepKeyDown:d,...S}=e,g=l.useRef(null),s=M(t,g),u=l.useRef(void 0),v=!a;function y(b){const p=u.current||g.current.getBoundingClientRect(),m=[0,p.height],x=O(m,v?[o,n]:[n,o]);return u.current=p,x(b-p.top)}return f.jsx(q,{scope:e.__scopeSlider,startEdge:v?"bottom":"top",endEdge:v?"top":"bottom",size:"height",direction:v?1:-1,children:f.jsx(Z,{"data-orientation":"vertical",...S,ref:s,style:{...S.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const p=y(b.clientY);c==null||c(p)},onSlideMove:b=>{const p=y(b.clientY);r==null||r(p)},onSlideEnd:()=>{u.current=void 0,i==null||i()},onStepKeyDown:b=>{const m=G[v?"from-bottom":"from-top"].includes(b.key);d==null||d({event:b,direction:m?-1:1})}})})}),Z=l.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:o,onSlideMove:a,onSlideEnd:c,onHomeKeyDown:r,onEndKeyDown:i,onStepKeyDown:d,...S}=e,g=B(j,n);return f.jsx(V.span,{...S,ref:t,onKeyDown:C(e.onKeyDown,s=>{s.key==="Home"?(r(s),s.preventDefault()):s.key==="End"?(i(s),s.preventDefault()):$.concat(X).includes(s.key)&&(d(s),s.preventDefault())}),onPointerDown:C(e.onPointerDown,s=>{const u=s.target;u.setPointerCapture(s.pointerId),s.preventDefault(),g.thumbs.has(u)?u.focus():o(s)}),onPointerMove:C(e.onPointerMove,s=>{s.target.hasPointerCapture(s.pointerId)&&a(s)}),onPointerUp:C(e.onPointerUp,s=>{const u=s.target;u.hasPointerCapture(s.pointerId)&&(u.releasePointerCapture(s.pointerId),c(s))})})}),ee="SliderTrack",te=l.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,a=B(ee,n);return f.jsx(V.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...o,ref:t})});te.displayName=ee;var z="SliderRange",ne=l.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,a=B(z,n),c=J(z,n),r=l.useRef(null),i=M(t,r),d=a.values.length,S=a.values.map(u=>se(u,a.min,a.max)),g=d>1?Math.min(...S):0,s=100-Math.max(...S);return f.jsx(V.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...o,ref:i,style:{...e.style,[c.startEdge]:g+"%",[c.endEdge]:s+"%"}})});ne.displayName=z;var L="SliderThumb",oe=l.forwardRef((e,t)=>{const n=Se(e.__scopeSlider),[o,a]=l.useState(null),c=M(t,i=>a(i)),r=l.useMemo(()=>o?n().findIndex(i=>i.ref.current===o):-1,[n,o]);return f.jsx(we,{...e,ref:c,index:r})}),we=l.forwardRef((e,t)=>{const{__scopeSlider:n,index:o,name:a,...c}=e,r=B(L,n),i=J(L,n),[d,S]=l.useState(null),g=M(t,D=>S(D)),s=d?r.form||!!d.closest("form"):!0,u=me(d),v=r.values[o],y=v===void 0?0:se(v,r.min,r.max),b=Pe(o,r.values.length),p=u==null?void 0:u[i.size],m=p?Ee(p,y,i.direction):0;return l.useEffect(()=>{if(d)return r.thumbs.add(d),()=>{r.thumbs.delete(d)}},[d,r.thumbs]),f.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[i.startEdge]:`calc(${y}% + ${m}px)`},children:[f.jsx(H.ItemSlot,{scope:e.__scopeSlider,children:f.jsx(V.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":r.min,"aria-valuenow":v,"aria-valuemax":r.max,"aria-orientation":r.orientation,"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,tabIndex:r.disabled?void 0:0,...c,ref:g,style:v===void 0?{display:"none"}:e.style,onFocus:C(e.onFocus,()=>{r.valueIndexToChangeRef.current=o})})}),s&&f.jsx(re,{name:a??(r.name?r.name+(r.values.length>1?"[]":""):void 0),form:r.form,value:v},o)]})});oe.displayName=L;var ye="RadioBubbleInput",re=l.forwardRef(({__scopeSlider:e,value:t,...n},o)=>{const a=l.useRef(null),c=M(a,o),r=pe(t);return l.useEffect(()=>{const i=a.current;if(!i)return;const d=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(d,"value").set;if(r!==t&&g){const s=new Event("input",{bubbles:!0});g.call(i,t),i.dispatchEvent(s)}},[r,t]),f.jsx(V.input,{style:{display:"none"},...n,ref:c,defaultValue:t})});re.displayName=ye;function Re(e=[],t,n){const o=[...e];return o[n]=t,o.sort((a,c)=>a-c)}function se(e,t,n){const c=100/(n-t)*(e-t);return Y(c,[0,100])}function Pe(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function De(e,t){if(e.length===1)return 0;const n=e.map(a=>Math.abs(a-t)),o=Math.min(...n);return n.indexOf(o)}function Ee(e,t,n){const o=e/2,c=O([0,50],[0,o]);return(o-c(t)*n)*n}function _e(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function Ce(e,t){if(t>0){const n=_e(e);return Math.min(...n)>=t}return!0}function O(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function Me(e){return(String(e).split(".")[1]||"").length}function je(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var ie=Q,Ie=te,Ae=ne,Ke=oe;const Ve=l.forwardRef(({className:e,...t},n)=>f.jsxs(ie,{ref:n,className:he("relative flex w-full touch-none select-none items-center",e),...t,children:[f.jsx(Ie,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:f.jsx(Ae,{className:"absolute h-full bg-primary"})}),f.jsx(Ke,{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"})]}));Ve.displayName=ie.displayName;export{Ve as S};