import{E as e,H as t,It as n,L as r,Mt as i,Q as a,R as o,T as s,V as c,W as l,Y as u,Z as d,_t as f,at as p,d as m,ft as h,g,ht as _,jt as v,mt as y,ot as ee,s as b,st as x,t as S,tt as C,x as w,yt as T}from"./BA99CCI5.js";import"./xihTtKlq.js";import"./DGo8yE5j.js";var E=l(`<div><button type="button"></button> <div><span> </span></div></div>`),D=l(`<div><div><div></div> <!></div></div>`);function O(l,O){i(O,!1);let k=b(O,`orientation`,8,`horizontal`),A=b(O,`direction`,8,`start`),j=b(O,`min`,8,0),M=b(O,`max`,8,100),N=b(O,`step`,8,1),P=b(O,`minSeparation`,8,20),F=b(O,`markers`,28,()=>[]),I=b(O,`unit`,8,``),L=b(O,`unlimitedValue`,8,null),R=b(O,`displayTransform`,8,null),z=b(O,`disabled`,8,!1),B=S(),V=_(),H=_(null),U={accent:{dot:`bg-accent-500`,badge:`bg-accent-100 text-accent-700 dark:bg-accent-900/40 dark:text-accent-300`},blue:{dot:`bg-blue-500`,badge:`bg-blue-100 text-blue-700 dark:bg-blue-900/40 dark:text-blue-300`},green:{dot:`bg-green-500`,badge:`bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300`},orange:{dot:`bg-orange-500`,badge:`bg-orange-100 text-orange-700 dark:bg-orange-900/40 dark:text-orange-300`},red:{dot:`bg-red-500`,badge:`bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300`},purple:{dot:`bg-purple-500`,badge:`bg-purple-100 text-purple-700 dark:bg-purple-900/40 dark:text-purple-300`},neutral:{dot:`bg-neutral-500`,badge:`bg-neutral-100 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300`}};function W(e){let t=(e-j())/(M()-j())*100;return A()===`start`?t:100-t}function G(e,t){let n=e/t*100;A()===`end`&&(n=100-n);let r=j()+n/100*(M()-j()),i=Math.round(r/N())*N();return Math.max(j(),Math.min(M(),i))}function K(){return a(V)?k()===`horizontal`?a(V).offsetWidth:a(V).offsetHeight:0}function q(e){let t=K(),n=M()-j(),r=t>0?P()/t*n:0,i=j(),a=M();return e>0&&(i=F()[e-1].value+r),e<F().length-1&&(a=F()[e+1].value-r),{minVal:i,maxVal:a}}function J(e,t){if(z())return;t.preventDefault(),f(H,e);let n=e=>te(e),r=()=>{f(H,null),window.removeEventListener(`mousemove`,n),window.removeEventListener(`mouseup`,r),window.removeEventListener(`touchmove`,n),window.removeEventListener(`touchend`,r)};window.addEventListener(`mousemove`,n),window.addEventListener(`mouseup`,r),window.addEventListener(`touchmove`,n),window.addEventListener(`touchend`,r)}function te(e){if(z()||a(H)===null||!a(V))return;let t=a(V).getBoundingClientRect(),n=`touches`in e?e.touches[0]:e,r;r=k()===`horizontal`?n.clientX-t.left:n.clientY-t.top;let i=K();r=Math.max(0,Math.min(i,r));let o=G(r,i),s=q(a(H));o=Math.max(s.minVal,Math.min(s.maxVal,o)),o=Math.round(o/N())*N(),F()[a(H)].value!==o&&(F(F()[a(H)].value=o,!0),F(F()),B(`change`,{index:a(H),value:o,markers:F()}))}p(()=>(d(F()),d(j()),d(M())),()=>{let e=!1,t=F().map((t,n)=>{q(n);let r=t.value;return r=Math.max(j(),Math.min(M(),r)),r===t.value?t:(e=!0,{...t,value:r})});e&&F(t)}),ee(),m();var Y=D();let X;var Z=h(Y);let Q;var $=h(Z),ne=y($,2);r(ne,1,F,o,(r,i,o)=>{let l=T(()=>(a(i),C(()=>W(a(i).value)))),f=T(()=>(a(i),C(()=>U[a(i).color])));var p=E(),m=h(p),g=y(m,2),_=h(g),v=h(_);n(_),n(g),n(p),x(t=>{e(p,1,`absolute ${k()===`horizontal`?`top-1/2 -translate-y-1/2`:`left-1/2 -translate-x-1/2`}`),s(p,`${k()===`horizontal`?`left`:`top`}: ${a(l)??``}%;`),m.disabled=z(),e(m,1,`relative h-4 w-4 -translate-x-1/2 rounded-full shadow-sm transition-transform disabled:cursor-not-allowed ${z()?``:`cursor-grab hover:scale-125`} ${d(a(f)),C(()=>a(f).dot)??``} ${k()===`vertical`?`-translate-y-1/2`:``} ${a(H)===o&&!z()?`scale-150 cursor-grabbing`:``}`),w(m,`aria-label`,`Drag to adjust ${a(i),C(()=>a(i).label)??``}`),e(g,1,`absolute whitespace-nowrap ${k()===`horizontal`?`left-0 -translate-x-1/2 ${o%2==0?`top-6`:`bottom-6`}`:`left-6 translate-x-0`}`),e(_,1,`inline-block rounded px-1.5 py-0.5 text-xs font-medium ${d(a(f)),C(()=>a(f).badge)??``}`),c(v,`${a(i),C(()=>a(i).label)??``}: ${t??``}`)},[()=>(d(L()),a(i),d(R()),d(I()),C(()=>L()!==null&&a(i).value>=L()?`Unlimited`:`${R()?R()(a(i).value).toFixed(1):Math.round(a(i).value)}${I()?` ${I()}`:``}`))]),u(`mousedown`,m,e=>J(o,e)),u(`touchstart`,m,e=>J(o,e)),t(r,p)}),n(Z),g(Z,e=>f(V,e),()=>a(V)),n(Y),x(()=>{X=e(Y,1,`relative select-none`,null,X,{"w-full":k()===`horizontal`,"h-full":k()===`vertical`,"opacity-50":z()}),Q=e(Z,1,`relative`,null,Q,{"h-2":k()===`horizontal`,"w-2":k()===`vertical`,"w-full":k()===`horizontal`,"h-full":k()===`vertical`}),e($,1,`absolute rounded-full bg-neutral-200 dark:bg-neutral-700 ${k()===`horizontal`?`top-1/2 h-1 w-full -translate-y-1/2`:`left-1/2 h-full w-1 -translate-x-1/2`}`)}),t(l,Y),v()}export{O as t};