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