@purpurds/slider 6.0.1 → 6.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/slider.es.js CHANGED
@@ -1,252 +1,197 @@
1
- import { jsxs as Pe, jsx as G } from "react/jsx-runtime";
2
- import D, { useCallback as ce, createContext as q, useMemo as O, createElement as b, useContext as ae, useRef as E, useEffect as B, useState as T, useLayoutEffect as Ee, forwardRef as P, Children as k, isValidElement as F, cloneElement as se, Fragment as De, useId as Me } from "react";
1
+ import { jsx as b, Fragment as be, jsxs as Z } from "react/jsx-runtime";
2
+ import * as a from "react";
3
+ import E, { forwardRef as ye, useId as ve } from "react";
3
4
  import "react-dom";
4
- function y() {
5
- return y = Object.assign ? Object.assign.bind() : function(e) {
6
- for (var t = 1; t < arguments.length; t++) {
7
- var n = arguments[t];
8
- for (var r in n) ({}).hasOwnProperty.call(n, r) && (e[r] = n[r]);
9
- }
10
- return e;
11
- }, y.apply(null, arguments);
12
- }
13
- function le(e, [t, n]) {
5
+ function J(e, [t, n]) {
14
6
  return Math.min(n, Math.max(t, e));
15
7
  }
16
- function N(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
17
- return function(i) {
18
- if (e == null || e(i), n === !1 || !i.defaultPrevented) return t == null ? void 0 : t(i);
8
+ function I(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
9
+ return function(s) {
10
+ if (e == null || e(s), n === !1 || !s.defaultPrevented)
11
+ return t == null ? void 0 : t(s);
19
12
  };
20
13
  }
21
- function Re(e, t) {
22
- typeof e == "function" ? e(t) : e != null && (e.current = t);
14
+ function q(e, t) {
15
+ if (typeof e == "function")
16
+ return e(t);
17
+ e != null && (e.current = t);
23
18
  }
24
- function ue(...e) {
25
- return (t) => e.forEach(
26
- (n) => Re(n, t)
27
- );
19
+ function Q(...e) {
20
+ return (t) => {
21
+ let n = !1;
22
+ const o = e.map((s) => {
23
+ const r = q(s, t);
24
+ return !n && typeof r == "function" && (n = !0), r;
25
+ });
26
+ if (n)
27
+ return () => {
28
+ for (let s = 0; s < o.length; s++) {
29
+ const r = o[s];
30
+ typeof r == "function" ? r() : q(e[s], null);
31
+ }
32
+ };
33
+ };
28
34
  }
29
- function M(...e) {
30
- return ce(ue(...e), e);
35
+ function D(...e) {
36
+ return a.useCallback(Q(...e), e);
31
37
  }
32
- function de(e, t = []) {
38
+ function ee(e, t = []) {
33
39
  let n = [];
34
- function r(o, a) {
35
- const c = /* @__PURE__ */ q(a), l = n.length;
36
- n = [
37
- ...n,
38
- a
39
- ];
40
- function u(s) {
41
- const { scope: d, children: S, ...f } = s, $ = (d == null ? void 0 : d[e][l]) || c, p = O(
42
- () => f,
43
- Object.values(f)
44
- );
45
- return /* @__PURE__ */ b($.Provider, {
46
- value: p
47
- }, S);
48
- }
49
- function m(s, d) {
50
- const S = (d == null ? void 0 : d[e][l]) || c, f = ae(S);
51
- if (f) return f;
52
- if (a !== void 0) return a;
53
- throw new Error(`\`${s}\` must be used within \`${o}\``);
40
+ function o(r, i) {
41
+ const c = a.createContext(i), u = n.length;
42
+ n = [...n, i];
43
+ const d = (l) => {
44
+ var p;
45
+ const { scope: f, children: g, ...m } = l, h = ((p = f == null ? void 0 : f[e]) == null ? void 0 : p[u]) || c, S = a.useMemo(() => m, Object.values(m));
46
+ return /* @__PURE__ */ b(h.Provider, { value: S, children: g });
47
+ };
48
+ d.displayName = r + "Provider";
49
+ function v(l, f) {
50
+ var h;
51
+ const g = ((h = f == null ? void 0 : f[e]) == null ? void 0 : h[u]) || c, m = a.useContext(g);
52
+ if (m) return m;
53
+ if (i !== void 0) return i;
54
+ throw new Error(`\`${l}\` must be used within \`${r}\``);
54
55
  }
55
- return u.displayName = o + "Provider", [
56
- u,
57
- m
58
- ];
56
+ return [d, v];
59
57
  }
60
- const i = () => {
61
- const o = n.map((a) => /* @__PURE__ */ q(a));
58
+ const s = () => {
59
+ const r = n.map((i) => a.createContext(i));
62
60
  return function(c) {
63
- const l = (c == null ? void 0 : c[e]) || o;
64
- return O(
65
- () => ({
66
- [`__scope${e}`]: {
67
- ...c,
68
- [e]: l
69
- }
70
- }),
71
- [
72
- c,
73
- l
74
- ]
61
+ const u = (c == null ? void 0 : c[e]) || r;
62
+ return a.useMemo(
63
+ () => ({ [`__scope${e}`]: { ...c, [e]: u } }),
64
+ [c, u]
75
65
  );
76
66
  };
77
67
  };
78
- return i.scopeName = e, [
79
- r,
80
- Ae(i, ...t)
81
- ];
68
+ return s.scopeName = e, [o, we(s, ...t)];
82
69
  }
83
- function Ae(...e) {
70
+ function we(...e) {
84
71
  const t = e[0];
85
72
  if (e.length === 1) return t;
86
73
  const n = () => {
87
- const r = e.map(
88
- (i) => ({
89
- useScope: i(),
90
- scopeName: i.scopeName
91
- })
92
- );
93
- return function(o) {
94
- const a = r.reduce((c, { useScope: l, scopeName: u }) => {
95
- const s = l(o)[`__scope${u}`];
96
- return {
97
- ...c,
98
- ...s
99
- };
74
+ const o = e.map((s) => ({
75
+ useScope: s(),
76
+ scopeName: s.scopeName
77
+ }));
78
+ return function(r) {
79
+ const i = o.reduce((c, { useScope: u, scopeName: d }) => {
80
+ const l = u(r)[`__scope${d}`];
81
+ return { ...c, ...l };
100
82
  }, {});
101
- return O(
102
- () => ({
103
- [`__scope${t.scopeName}`]: a
104
- }),
105
- [
106
- a
107
- ]
108
- );
83
+ return a.useMemo(() => ({ [`__scope${t.scopeName}`]: i }), [i]);
109
84
  };
110
85
  };
111
86
  return n.scopeName = t.scopeName, n;
112
87
  }
113
- function fe(e) {
114
- const t = E(e);
115
- return B(() => {
88
+ function te(e) {
89
+ const t = a.useRef(e);
90
+ return a.useEffect(() => {
116
91
  t.current = e;
117
- }), O(
118
- () => (...n) => {
119
- var r;
120
- return (r = t.current) === null || r === void 0 ? void 0 : r.call(t, ...n);
92
+ }), a.useMemo(() => (...n) => {
93
+ var o;
94
+ return (o = t.current) == null ? void 0 : o.call(t, ...n);
95
+ }, []);
96
+ }
97
+ function Ce({
98
+ prop: e,
99
+ defaultProp: t,
100
+ onChange: n = () => {
101
+ }
102
+ }) {
103
+ const [o, s] = _e({ defaultProp: t, onChange: n }), r = e !== void 0, i = r ? e : o, c = te(n), u = a.useCallback(
104
+ (d) => {
105
+ if (r) {
106
+ const l = typeof d == "function" ? d(e) : d;
107
+ l !== e && c(l);
108
+ } else
109
+ s(d);
121
110
  },
122
- []
111
+ [r, e, s, c]
123
112
  );
113
+ return [i, u];
124
114
  }
125
- function Ie({ prop: e, defaultProp: t, onChange: n = () => {
126
- } }) {
127
- const [r, i] = Ne({
128
- defaultProp: t,
129
- onChange: n
130
- }), o = e !== void 0, a = o ? e : r, c = fe(n), l = ce((u) => {
131
- if (o) {
132
- const s = typeof u == "function" ? u(e) : u;
133
- s !== e && c(s);
134
- } else i(u);
135
- }, [
136
- o,
137
- e,
138
- i,
139
- c
140
- ]);
141
- return [
142
- a,
143
- l
144
- ];
115
+ function _e({
116
+ defaultProp: e,
117
+ onChange: t
118
+ }) {
119
+ const n = a.useState(e), [o] = n, s = a.useRef(o), r = te(t);
120
+ return a.useEffect(() => {
121
+ s.current !== o && (r(o), s.current = o);
122
+ }, [o, s, r]), n;
145
123
  }
146
- function Ne({ defaultProp: e, onChange: t }) {
147
- const n = T(e), [r] = n, i = E(r), o = fe(t);
148
- return B(() => {
149
- i.current !== r && (o(r), i.current = r);
150
- }, [
151
- r,
152
- i,
153
- o
154
- ]), n;
155
- }
156
- const Oe = /* @__PURE__ */ q(void 0);
157
- function Te(e) {
158
- const t = ae(Oe);
124
+ var Re = a.createContext(void 0);
125
+ function xe(e) {
126
+ const t = a.useContext(Re);
159
127
  return e || t || "ltr";
160
128
  }
161
- function Ke(e) {
162
- const t = E({
163
- value: e,
164
- previous: e
165
- });
166
- return O(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [
167
- e
168
- ]);
129
+ function Pe(e) {
130
+ const t = a.useRef({ value: e, previous: e });
131
+ return a.useMemo(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [e]);
169
132
  }
170
- const Ve = globalThis != null && globalThis.document ? Ee : () => {
133
+ var Ee = globalThis != null && globalThis.document ? a.useLayoutEffect : () => {
171
134
  };
172
- function ke(e) {
173
- const [t, n] = T(void 0);
174
- return Ve(() => {
135
+ function De(e) {
136
+ const [t, n] = a.useState(void 0);
137
+ return Ee(() => {
175
138
  if (e) {
176
- n({
177
- width: e.offsetWidth,
178
- height: e.offsetHeight
179
- });
180
- const r = new ResizeObserver((i) => {
181
- if (!Array.isArray(i) || !i.length) return;
182
- const o = i[0];
183
- let a, c;
184
- if ("borderBoxSize" in o) {
185
- const l = o.borderBoxSize, u = Array.isArray(l) ? l[0] : l;
186
- a = u.inlineSize, c = u.blockSize;
139
+ n({ width: e.offsetWidth, height: e.offsetHeight });
140
+ const o = new ResizeObserver((s) => {
141
+ if (!Array.isArray(s) || !s.length)
142
+ return;
143
+ const r = s[0];
144
+ let i, c;
145
+ if ("borderBoxSize" in r) {
146
+ const u = r.borderBoxSize, d = Array.isArray(u) ? u[0] : u;
147
+ i = d.inlineSize, c = d.blockSize;
187
148
  } else
188
- a = e.offsetWidth, c = e.offsetHeight;
189
- n({
190
- width: a,
191
- height: c
192
- });
149
+ i = e.offsetWidth, c = e.offsetHeight;
150
+ n({ width: i, height: c });
193
151
  });
194
- return r.observe(e, {
195
- box: "border-box"
196
- }), () => r.unobserve(e);
152
+ return o.observe(e, { box: "border-box" }), () => o.unobserve(e);
197
153
  } else
198
154
  n(void 0);
199
- }, [
200
- e
201
- ]), t;
155
+ }, [e]), t;
202
156
  }
203
- const U = /* @__PURE__ */ P((e, t) => {
204
- const { children: n, ...r } = e, i = k.toArray(n), o = i.find(ze);
205
- if (o) {
206
- const a = o.props.children, c = i.map((l) => l === o ? k.count(a) > 1 ? k.only(null) : /* @__PURE__ */ F(a) ? a.props.children : null : l);
207
- return /* @__PURE__ */ b(Z, y({}, r, {
208
- ref: t
209
- }), /* @__PURE__ */ F(a) ? /* @__PURE__ */ se(a, void 0, c) : null);
157
+ var z = a.forwardRef((e, t) => {
158
+ const { children: n, ...o } = e, s = a.Children.toArray(n), r = s.find(Ae);
159
+ if (r) {
160
+ const i = r.props.children, c = s.map((u) => u === r ? a.Children.count(i) > 1 ? a.Children.only(null) : a.isValidElement(i) ? i.props.children : null : u);
161
+ return /* @__PURE__ */ b(F, { ...o, ref: t, children: a.isValidElement(i) ? a.cloneElement(i, void 0, c) : null });
210
162
  }
211
- return /* @__PURE__ */ b(Z, y({}, r, {
212
- ref: t
213
- }), n);
163
+ return /* @__PURE__ */ b(F, { ...o, ref: t, children: n });
214
164
  });
215
- U.displayName = "Slot";
216
- const Z = /* @__PURE__ */ P((e, t) => {
217
- const { children: n, ...r } = e;
218
- return /* @__PURE__ */ F(n) ? /* @__PURE__ */ se(n, {
219
- ...Le(r, n.props),
220
- ref: t ? ue(t, n.ref) : n.ref
221
- }) : k.count(n) > 1 ? k.only(null) : null;
165
+ z.displayName = "Slot";
166
+ var F = a.forwardRef((e, t) => {
167
+ const { children: n, ...o } = e;
168
+ if (a.isValidElement(n)) {
169
+ const s = Ne(n), r = Ie(o, n.props);
170
+ return n.type !== a.Fragment && (r.ref = t ? Q(t, s) : s), a.cloneElement(n, r);
171
+ }
172
+ return a.Children.count(n) > 1 ? a.Children.only(null) : null;
222
173
  });
223
- Z.displayName = "SlotClone";
224
- const Be = ({ children: e }) => /* @__PURE__ */ b(De, null, e);
225
- function ze(e) {
226
- return /* @__PURE__ */ F(e) && e.type === Be;
174
+ F.displayName = "SlotClone";
175
+ var Me = ({ children: e }) => /* @__PURE__ */ b(be, { children: e });
176
+ function Ae(e) {
177
+ return a.isValidElement(e) && e.type === Me;
227
178
  }
228
- function Le(e, t) {
229
- const n = {
230
- ...t
231
- };
232
- for (const r in t) {
233
- const i = e[r], o = t[r];
234
- /^on[A-Z]/.test(r) ? i && o ? n[r] = (...c) => {
235
- o(...c), i(...c);
236
- } : i && (n[r] = i) : r === "style" ? n[r] = {
237
- ...i,
238
- ...o
239
- } : r === "className" && (n[r] = [
240
- i,
241
- o
242
- ].filter(Boolean).join(" "));
179
+ function Ie(e, t) {
180
+ const n = { ...t };
181
+ for (const o in t) {
182
+ const s = e[o], r = t[o];
183
+ /^on[A-Z]/.test(o) ? s && r ? n[o] = (...c) => {
184
+ r(...c), s(...c);
185
+ } : s && (n[o] = s) : o === "style" ? n[o] = { ...s, ...r } : o === "className" && (n[o] = [s, r].filter(Boolean).join(" "));
243
186
  }
244
- return {
245
- ...e,
246
- ...n
247
- };
187
+ return { ...e, ...n };
248
188
  }
249
- const He = [
189
+ function Ne(e) {
190
+ var o, s;
191
+ let t = (o = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning;
192
+ return n ? e.ref : (t = (s = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : s.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
193
+ }
194
+ var Oe = [
250
195
  "a",
251
196
  "button",
252
197
  "div",
@@ -263,495 +208,459 @@ const He = [
263
208
  "span",
264
209
  "svg",
265
210
  "ul"
266
- ], Y = He.reduce((e, t) => {
267
- const n = /* @__PURE__ */ P((r, i) => {
268
- const { asChild: o, ...a } = r, c = o ? U : t;
269
- return B(() => {
270
- window[Symbol.for("radix-ui")] = !0;
271
- }, []), /* @__PURE__ */ b(c, y({}, a, {
272
- ref: i
273
- }));
211
+ ], B = Oe.reduce((e, t) => {
212
+ const n = a.forwardRef((o, s) => {
213
+ const { asChild: r, ...i } = o, c = r ? z : t;
214
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ b(c, { ...i, ref: s });
274
215
  });
275
- return n.displayName = `Primitive.${t}`, {
276
- ...e,
277
- [t]: n
278
- };
216
+ return n.displayName = `Primitive.${t}`, { ...e, [t]: n };
279
217
  }, {});
280
- function je(e) {
281
- const t = e + "CollectionProvider", [n, r] = de(t), [i, o] = n(t, {
282
- collectionRef: {
283
- current: null
284
- },
285
- itemMap: /* @__PURE__ */ new Map()
286
- }), a = (S) => {
287
- const { scope: f, children: $ } = S, p = D.useRef(null), v = D.useRef(/* @__PURE__ */ new Map()).current;
288
- return /* @__PURE__ */ D.createElement(i, {
289
- scope: f,
290
- itemMap: v,
291
- collectionRef: p
292
- }, $);
293
- }, c = e + "CollectionSlot", l = /* @__PURE__ */ D.forwardRef((S, f) => {
294
- const { scope: $, children: p } = S, v = o(c, $), _ = M(f, v.collectionRef);
295
- return /* @__PURE__ */ D.createElement(U, {
296
- ref: _
297
- }, p);
298
- }), u = e + "CollectionItemSlot", m = "data-radix-collection-item", s = /* @__PURE__ */ D.forwardRef((S, f) => {
299
- const { scope: $, children: p, ...v } = S, _ = D.useRef(null), h = M(f, _), g = o(u, $);
300
- return D.useEffect(() => (g.itemMap.set(_, {
301
- ref: _,
302
- ...v
303
- }), () => void g.itemMap.delete(_))), /* @__PURE__ */ D.createElement(U, {
304
- [m]: "",
305
- ref: h
306
- }, p);
307
- });
308
- function d(S) {
309
- const f = o(e + "CollectionConsumer", S);
310
- return D.useCallback(() => {
311
- const p = f.collectionRef.current;
312
- if (!p) return [];
313
- const v = Array.from(p.querySelectorAll(`[${m}]`));
314
- return Array.from(f.itemMap.values()).sort(
315
- (g, R) => v.indexOf(g.ref.current) - v.indexOf(R.ref.current)
218
+ function Te(e) {
219
+ const t = e + "CollectionProvider", [n, o] = ee(t), [s, r] = n(
220
+ t,
221
+ { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
222
+ ), i = (g) => {
223
+ const { scope: m, children: h } = g, S = E.useRef(null), p = E.useRef(/* @__PURE__ */ new Map()).current;
224
+ return /* @__PURE__ */ b(s, { scope: m, itemMap: p, collectionRef: S, children: h });
225
+ };
226
+ i.displayName = t;
227
+ const c = e + "CollectionSlot", u = E.forwardRef(
228
+ (g, m) => {
229
+ const { scope: h, children: S } = g, p = r(c, h), C = D(m, p.collectionRef);
230
+ return /* @__PURE__ */ b(z, { ref: C, children: S });
231
+ }
232
+ );
233
+ u.displayName = c;
234
+ const d = e + "CollectionItemSlot", v = "data-radix-collection-item", l = E.forwardRef(
235
+ (g, m) => {
236
+ const { scope: h, children: S, ...p } = g, C = E.useRef(null), w = D(m, C), y = r(d, h);
237
+ return E.useEffect(() => (y.itemMap.set(C, { ref: C, ...p }), () => void y.itemMap.delete(C))), /* @__PURE__ */ b(z, { [v]: "", ref: w, children: S });
238
+ }
239
+ );
240
+ l.displayName = d;
241
+ function f(g) {
242
+ const m = r(e + "CollectionConsumer", g);
243
+ return E.useCallback(() => {
244
+ const S = m.collectionRef.current;
245
+ if (!S) return [];
246
+ const p = Array.from(S.querySelectorAll(`[${v}]`));
247
+ return Array.from(m.itemMap.values()).sort(
248
+ (y, R) => p.indexOf(y.ref.current) - p.indexOf(R.ref.current)
316
249
  );
317
- }, [
318
- f.collectionRef,
319
- f.itemMap
320
- ]);
250
+ }, [m.collectionRef, m.itemMap]);
321
251
  }
322
252
  return [
323
- {
324
- Provider: a,
325
- Slot: l,
326
- ItemSlot: s
327
- },
328
- d,
329
- r
253
+ { Provider: i, Slot: u, ItemSlot: l },
254
+ f,
255
+ o
330
256
  ];
331
257
  }
332
- const pe = [
333
- "PageUp",
334
- "PageDown"
335
- ], $e = [
336
- "ArrowUp",
337
- "ArrowDown",
338
- "ArrowLeft",
339
- "ArrowRight"
340
- ], me = {
341
- "from-left": [
342
- "Home",
343
- "PageDown",
344
- "ArrowDown",
345
- "ArrowLeft"
346
- ],
347
- "from-right": [
348
- "Home",
349
- "PageDown",
350
- "ArrowDown",
351
- "ArrowRight"
352
- ],
353
- "from-bottom": [
354
- "Home",
355
- "PageDown",
356
- "ArrowDown",
357
- "ArrowLeft"
358
- ],
359
- "from-top": [
360
- "Home",
361
- "PageDown",
362
- "ArrowUp",
363
- "ArrowLeft"
364
- ]
365
- }, z = "Slider", [J, Fe, Ue] = je(z), [Se, wt] = de(z, [
366
- Ue
367
- ]), [Ye, W] = Se(z), We = /* @__PURE__ */ P((e, t) => {
368
- const { name: n, min: r = 0, max: i = 100, step: o = 1, orientation: a = "horizontal", disabled: c = !1, minStepsBetweenThumbs: l = 0, defaultValue: u = [
369
- r
370
- ], value: m, onValueChange: s = () => {
371
- }, onValueCommit: d = () => {
372
- }, inverted: S = !1, ...f } = e, [$, p] = T(null), v = M(
373
- t,
374
- (x) => p(x)
375
- ), _ = E(/* @__PURE__ */ new Set()), h = E(0), g = a === "horizontal", R = $ ? !!$.closest("form") : !0, ee = g ? Xe : Ge, [w = [], _e] = Ie({
376
- prop: m,
377
- defaultProp: u,
378
- onChange: (x) => {
379
- var C;
380
- (C = [
381
- ..._.current
382
- ][h.current]) === null || C === void 0 || C.focus(), s(x);
383
- }
384
- }), te = E(w);
385
- function ye(x) {
386
- const C = rt(w, x);
387
- K(x, C);
388
- }
389
- function we(x) {
390
- K(x, h.current);
391
- }
392
- function Ce() {
393
- const x = te.current[h.current];
394
- w[h.current] !== x && d(w);
395
- }
396
- function K(x, C, { commit: L } = {
397
- commit: !1
398
- }) {
399
- const ne = st(o), X = lt(Math.round((x - r) / o) * o + r, ne), V = le(X, [
400
- r,
401
- i
402
- ]);
403
- _e((I = []) => {
404
- const A = nt(I, V, C);
405
- if (at(A, l * o)) {
406
- h.current = A.indexOf(V);
407
- const oe = String(A) !== String(I);
408
- return oe && L && d(A), oe ? A : I;
409
- } else return I;
410
- });
411
- }
412
- return /* @__PURE__ */ b(Ye, {
413
- scope: e.__scopeSlider,
414
- disabled: c,
415
- min: r,
416
- max: i,
417
- valueIndexToChangeRef: h,
418
- thumbs: _.current,
419
- values: w,
420
- orientation: a
421
- }, /* @__PURE__ */ b(J.Provider, {
422
- scope: e.__scopeSlider
423
- }, /* @__PURE__ */ b(J.Slot, {
424
- scope: e.__scopeSlider
425
- }, /* @__PURE__ */ b(ee, y({
426
- "aria-disabled": c,
427
- "data-disabled": c ? "" : void 0
428
- }, f, {
429
- ref: v,
430
- onPointerDown: N(f.onPointerDown, () => {
431
- c || (te.current = w);
432
- }),
433
- min: r,
434
- max: i,
435
- inverted: S,
436
- onSlideStart: c ? void 0 : ye,
437
- onSlideMove: c ? void 0 : we,
438
- onSlideEnd: c ? void 0 : Ce,
439
- onHomeKeyDown: () => !c && K(r, 0, {
440
- commit: !0
441
- }),
442
- onEndKeyDown: () => !c && K(i, w.length - 1, {
443
- commit: !0
444
- }),
445
- onStepKeyDown: ({ event: x, direction: C }) => {
446
- if (!c) {
447
- const X = pe.includes(x.key) || x.shiftKey && $e.includes(x.key) ? 10 : 1, V = h.current, I = w[V], A = o * X * C;
448
- K(I + A, V, {
449
- commit: !0
450
- });
258
+ var ne = ["PageUp", "PageDown"], re = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], oe = {
259
+ "from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
260
+ "from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"],
261
+ "from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
262
+ "from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"]
263
+ }, N = "Slider", [H, Ve, ke] = Te(N), [se, ut] = ee(N, [
264
+ ke
265
+ ]), [ze, K] = se(N), ie = a.forwardRef(
266
+ (e, t) => {
267
+ const {
268
+ name: n,
269
+ min: o = 0,
270
+ max: s = 100,
271
+ step: r = 1,
272
+ orientation: i = "horizontal",
273
+ disabled: c = !1,
274
+ minStepsBetweenThumbs: u = 0,
275
+ defaultValue: d = [o],
276
+ value: v,
277
+ onValueChange: l = () => {
278
+ },
279
+ onValueCommit: f = () => {
280
+ },
281
+ inverted: g = !1,
282
+ form: m,
283
+ ...h
284
+ } = e, S = a.useRef(/* @__PURE__ */ new Set()), p = a.useRef(0), w = i === "horizontal" ? Be : Ke, [y = [], R] = Ce({
285
+ prop: v,
286
+ defaultProp: d,
287
+ onChange: (_) => {
288
+ var M;
289
+ (M = [...S.current][p.current]) == null || M.focus(), l(_);
451
290
  }
291
+ }), L = a.useRef(y);
292
+ function $(_) {
293
+ const x = He(y, _);
294
+ O(_, x);
295
+ }
296
+ function Se(_) {
297
+ O(_, p.current);
298
+ }
299
+ function ge() {
300
+ const _ = L.current[p.current];
301
+ y[p.current] !== _ && f(y);
302
+ }
303
+ function O(_, x, { commit: M } = { commit: !1 }) {
304
+ const X = Xe(r), j = Ge(Math.round((_ - o) / r) * r + o, X), T = J(j, [o, s]);
305
+ R((A = []) => {
306
+ const P = je(A, T, x);
307
+ if (Ye(P, u * r)) {
308
+ p.current = P.indexOf(T);
309
+ const G = String(P) !== String(A);
310
+ return G && M && f(P), G ? P : A;
311
+ } else
312
+ return A;
313
+ });
452
314
  }
453
- })))), R && w.map(
454
- (x, C) => /* @__PURE__ */ b(tt, {
455
- key: C,
456
- name: n ? n + (w.length > 1 ? "[]" : "") : void 0,
457
- value: x
458
- })
459
- ));
460
- }), [he, be] = Se(z, {
315
+ return /* @__PURE__ */ b(
316
+ ze,
317
+ {
318
+ scope: e.__scopeSlider,
319
+ name: n,
320
+ disabled: c,
321
+ min: o,
322
+ max: s,
323
+ valueIndexToChangeRef: p,
324
+ thumbs: S.current,
325
+ values: y,
326
+ orientation: i,
327
+ form: m,
328
+ children: /* @__PURE__ */ b(H.Provider, { scope: e.__scopeSlider, children: /* @__PURE__ */ b(H.Slot, { scope: e.__scopeSlider, children: /* @__PURE__ */ b(
329
+ w,
330
+ {
331
+ "aria-disabled": c,
332
+ "data-disabled": c ? "" : void 0,
333
+ ...h,
334
+ ref: t,
335
+ onPointerDown: I(h.onPointerDown, () => {
336
+ c || (L.current = y);
337
+ }),
338
+ min: o,
339
+ max: s,
340
+ inverted: g,
341
+ onSlideStart: c ? void 0 : $,
342
+ onSlideMove: c ? void 0 : Se,
343
+ onSlideEnd: c ? void 0 : ge,
344
+ onHomeKeyDown: () => !c && O(o, 0, { commit: !0 }),
345
+ onEndKeyDown: () => !c && O(s, y.length - 1, { commit: !0 }),
346
+ onStepKeyDown: ({ event: _, direction: x }) => {
347
+ if (!c) {
348
+ const j = ne.includes(_.key) || _.shiftKey && re.includes(_.key) ? 10 : 1, T = p.current, A = y[T], P = r * j * x;
349
+ O(A + P, T, { commit: !0 });
350
+ }
351
+ }
352
+ }
353
+ ) }) })
354
+ }
355
+ );
356
+ }
357
+ );
358
+ ie.displayName = N;
359
+ var [ce, ae] = se(N, {
461
360
  startEdge: "left",
462
361
  endEdge: "right",
463
362
  size: "width",
464
363
  direction: 1
465
- }), Xe = /* @__PURE__ */ P((e, t) => {
466
- const { min: n, max: r, dir: i, inverted: o, onSlideStart: a, onSlideMove: c, onSlideEnd: l, onStepKeyDown: u, ...m } = e, [s, d] = T(null), S = M(
467
- t,
468
- (h) => d(h)
469
- ), f = E(), $ = Te(i), p = $ === "ltr", v = p && !o || !p && o;
470
- function _(h) {
471
- const g = f.current || s.getBoundingClientRect(), R = [
472
- 0,
473
- g.width
474
- ], w = Q(R, v ? [
475
- n,
476
- r
477
- ] : [
478
- r,
479
- n
480
- ]);
481
- return f.current = g, w(h - g.left);
482
- }
483
- return /* @__PURE__ */ b(he, {
484
- scope: e.__scopeSlider,
485
- startEdge: v ? "left" : "right",
486
- endEdge: v ? "right" : "left",
487
- direction: v ? 1 : -1,
488
- size: "width"
489
- }, /* @__PURE__ */ b(ve, y({
490
- dir: $,
491
- "data-orientation": "horizontal"
492
- }, m, {
493
- ref: S,
494
- style: {
495
- ...m.style,
496
- "--radix-slider-thumb-transform": "translateX(-50%)"
497
- },
498
- onSlideStart: (h) => {
499
- const g = _(h.clientX);
500
- a == null || a(g);
501
- },
502
- onSlideMove: (h) => {
503
- const g = _(h.clientX);
504
- c == null || c(g);
505
- },
506
- onSlideEnd: () => {
507
- f.current = void 0, l == null || l();
508
- },
509
- onStepKeyDown: (h) => {
510
- const R = me[v ? "from-left" : "from-right"].includes(h.key);
511
- u == null || u({
512
- event: h,
513
- direction: R ? -1 : 1
514
- });
364
+ }), Be = a.forwardRef(
365
+ (e, t) => {
366
+ const {
367
+ min: n,
368
+ max: o,
369
+ dir: s,
370
+ inverted: r,
371
+ onSlideStart: i,
372
+ onSlideMove: c,
373
+ onSlideEnd: u,
374
+ onStepKeyDown: d,
375
+ ...v
376
+ } = e, [l, f] = a.useState(null), g = D(t, (w) => f(w)), m = a.useRef(void 0), h = xe(s), S = h === "ltr", p = S && !r || !S && r;
377
+ function C(w) {
378
+ const y = m.current || l.getBoundingClientRect(), R = [0, y.width], $ = Y(R, p ? [n, o] : [o, n]);
379
+ return m.current = y, $(w - y.left);
515
380
  }
516
- })));
517
- }), Ge = /* @__PURE__ */ P((e, t) => {
518
- const { min: n, max: r, inverted: i, onSlideStart: o, onSlideMove: a, onSlideEnd: c, onStepKeyDown: l, ...u } = e, m = E(null), s = M(t, m), d = E(), S = !i;
519
- function f($) {
520
- const p = d.current || m.current.getBoundingClientRect(), v = [
521
- 0,
522
- p.height
523
- ], h = Q(v, S ? [
524
- r,
525
- n
526
- ] : [
527
- n,
528
- r
529
- ]);
530
- return d.current = p, h($ - p.top);
381
+ return /* @__PURE__ */ b(
382
+ ce,
383
+ {
384
+ scope: e.__scopeSlider,
385
+ startEdge: p ? "left" : "right",
386
+ endEdge: p ? "right" : "left",
387
+ direction: p ? 1 : -1,
388
+ size: "width",
389
+ children: /* @__PURE__ */ b(
390
+ le,
391
+ {
392
+ dir: h,
393
+ "data-orientation": "horizontal",
394
+ ...v,
395
+ ref: g,
396
+ style: {
397
+ ...v.style,
398
+ "--radix-slider-thumb-transform": "translateX(-50%)"
399
+ },
400
+ onSlideStart: (w) => {
401
+ const y = C(w.clientX);
402
+ i == null || i(y);
403
+ },
404
+ onSlideMove: (w) => {
405
+ const y = C(w.clientX);
406
+ c == null || c(y);
407
+ },
408
+ onSlideEnd: () => {
409
+ m.current = void 0, u == null || u();
410
+ },
411
+ onStepKeyDown: (w) => {
412
+ const R = oe[p ? "from-left" : "from-right"].includes(w.key);
413
+ d == null || d({ event: w, direction: R ? -1 : 1 });
414
+ }
415
+ }
416
+ )
417
+ }
418
+ );
531
419
  }
532
- return /* @__PURE__ */ b(he, {
533
- scope: e.__scopeSlider,
534
- startEdge: S ? "bottom" : "top",
535
- endEdge: S ? "top" : "bottom",
536
- size: "height",
537
- direction: S ? 1 : -1
538
- }, /* @__PURE__ */ b(ve, y({
539
- "data-orientation": "vertical"
540
- }, u, {
541
- ref: s,
542
- style: {
543
- ...u.style,
544
- "--radix-slider-thumb-transform": "translateY(50%)"
545
- },
546
- onSlideStart: ($) => {
547
- const p = f($.clientY);
548
- o == null || o(p);
549
- },
550
- onSlideMove: ($) => {
551
- const p = f($.clientY);
552
- a == null || a(p);
553
- },
554
- onSlideEnd: () => {
555
- d.current = void 0, c == null || c();
556
- },
557
- onStepKeyDown: ($) => {
558
- const v = me[S ? "from-bottom" : "from-top"].includes($.key);
559
- l == null || l({
560
- event: $,
561
- direction: v ? -1 : 1
562
- });
420
+ ), Ke = a.forwardRef(
421
+ (e, t) => {
422
+ const {
423
+ min: n,
424
+ max: o,
425
+ inverted: s,
426
+ onSlideStart: r,
427
+ onSlideMove: i,
428
+ onSlideEnd: c,
429
+ onStepKeyDown: u,
430
+ ...d
431
+ } = e, v = a.useRef(null), l = D(t, v), f = a.useRef(void 0), g = !s;
432
+ function m(h) {
433
+ const S = f.current || v.current.getBoundingClientRect(), p = [0, S.height], w = Y(p, g ? [o, n] : [n, o]);
434
+ return f.current = S, w(h - S.top);
563
435
  }
564
- })));
565
- }), ve = /* @__PURE__ */ P((e, t) => {
566
- const { __scopeSlider: n, onSlideStart: r, onSlideMove: i, onSlideEnd: o, onHomeKeyDown: a, onEndKeyDown: c, onStepKeyDown: l, ...u } = e, m = W(z, n);
567
- return /* @__PURE__ */ b(Y.span, y({}, u, {
568
- ref: t,
569
- onKeyDown: N(e.onKeyDown, (s) => {
570
- s.key === "Home" ? (a(s), s.preventDefault()) : s.key === "End" ? (c(s), s.preventDefault()) : pe.concat($e).includes(s.key) && (l(s), s.preventDefault());
571
- }),
572
- onPointerDown: N(e.onPointerDown, (s) => {
573
- const d = s.target;
574
- d.setPointerCapture(s.pointerId), s.preventDefault(), m.thumbs.has(d) ? d.focus() : r(s);
575
- }),
576
- onPointerMove: N(e.onPointerMove, (s) => {
577
- s.target.hasPointerCapture(s.pointerId) && i(s);
578
- }),
579
- onPointerUp: N(e.onPointerUp, (s) => {
580
- const d = s.target;
581
- d.hasPointerCapture(s.pointerId) && (d.releasePointerCapture(s.pointerId), o(s));
582
- })
583
- }));
584
- }), qe = "SliderTrack", Ze = /* @__PURE__ */ P((e, t) => {
585
- const { __scopeSlider: n, ...r } = e, i = W(qe, n);
586
- return /* @__PURE__ */ b(Y.span, y({
587
- "data-disabled": i.disabled ? "" : void 0,
588
- "data-orientation": i.orientation
589
- }, r, {
590
- ref: t
591
- }));
592
- }), re = "SliderRange", Je = /* @__PURE__ */ P((e, t) => {
593
- const { __scopeSlider: n, ...r } = e, i = W(re, n), o = be(re, n), a = E(null), c = M(t, a), l = i.values.length, u = i.values.map(
594
- (d) => xe(d, i.min, i.max)
595
- ), m = l > 1 ? Math.min(...u) : 0, s = 100 - Math.max(...u);
596
- return /* @__PURE__ */ b(Y.span, y({
597
- "data-orientation": i.orientation,
598
- "data-disabled": i.disabled ? "" : void 0
599
- }, r, {
600
- ref: c,
601
- style: {
602
- ...e.style,
603
- [o.startEdge]: m + "%",
604
- [o.endEdge]: s + "%"
605
- }
606
- }));
607
- }), ie = "SliderThumb", Qe = /* @__PURE__ */ P((e, t) => {
608
- const n = Fe(e.__scopeSlider), [r, i] = T(null), o = M(
609
- t,
610
- (c) => i(c)
611
- ), a = O(
612
- () => r ? n().findIndex(
613
- (c) => c.ref.current === r
614
- ) : -1,
615
- [
616
- n,
617
- r
618
- ]
619
- );
620
- return /* @__PURE__ */ b(et, y({}, e, {
621
- ref: o,
622
- index: a
623
- }));
624
- }), et = /* @__PURE__ */ P((e, t) => {
625
- const { __scopeSlider: n, index: r, ...i } = e, o = W(ie, n), a = be(ie, n), [c, l] = T(null), u = M(
626
- t,
627
- (p) => l(p)
628
- ), m = ke(c), s = o.values[r], d = s === void 0 ? 0 : xe(s, o.min, o.max), S = ot(r, o.values.length), f = m == null ? void 0 : m[a.size], $ = f ? it(f, d, a.direction) : 0;
629
- return B(() => {
630
- if (c)
631
- return o.thumbs.add(c), () => {
632
- o.thumbs.delete(c);
633
- };
634
- }, [
635
- c,
636
- o.thumbs
637
- ]), /* @__PURE__ */ b("span", {
638
- style: {
639
- transform: "var(--radix-slider-thumb-transform)",
640
- position: "absolute",
641
- [a.startEdge]: `calc(${d}% + ${$}px)`
642
- }
643
- }, /* @__PURE__ */ b(J.ItemSlot, {
644
- scope: e.__scopeSlider
645
- }, /* @__PURE__ */ b(Y.span, y({
646
- role: "slider",
647
- "aria-label": e["aria-label"] || S,
648
- "aria-valuemin": o.min,
649
- "aria-valuenow": s,
650
- "aria-valuemax": o.max,
651
- "aria-orientation": o.orientation,
652
- "data-orientation": o.orientation,
653
- "data-disabled": o.disabled ? "" : void 0,
654
- tabIndex: o.disabled ? void 0 : 0
655
- }, i, {
656
- ref: u,
657
- style: s === void 0 ? {
658
- display: "none"
659
- } : e.style,
660
- onFocus: N(e.onFocus, () => {
661
- o.valueIndexToChangeRef.current = r;
662
- })
663
- }))));
664
- }), tt = (e) => {
665
- const { value: t, ...n } = e, r = E(null), i = Ke(t);
666
- return B(() => {
667
- const o = r.current, a = window.HTMLInputElement.prototype, l = Object.getOwnPropertyDescriptor(a, "value").set;
668
- if (i !== t && l) {
669
- const u = new Event("input", {
670
- bubbles: !0
671
- });
672
- l.call(o, t), o.dispatchEvent(u);
673
- }
674
- }, [
675
- i,
676
- t
677
- ]), /* @__PURE__ */ b("input", y({
678
- style: {
679
- display: "none"
436
+ return /* @__PURE__ */ b(
437
+ ce,
438
+ {
439
+ scope: e.__scopeSlider,
440
+ startEdge: g ? "bottom" : "top",
441
+ endEdge: g ? "top" : "bottom",
442
+ size: "height",
443
+ direction: g ? 1 : -1,
444
+ children: /* @__PURE__ */ b(
445
+ le,
446
+ {
447
+ "data-orientation": "vertical",
448
+ ...d,
449
+ ref: l,
450
+ style: {
451
+ ...d.style,
452
+ "--radix-slider-thumb-transform": "translateY(50%)"
453
+ },
454
+ onSlideStart: (h) => {
455
+ const S = m(h.clientY);
456
+ r == null || r(S);
457
+ },
458
+ onSlideMove: (h) => {
459
+ const S = m(h.clientY);
460
+ i == null || i(S);
461
+ },
462
+ onSlideEnd: () => {
463
+ f.current = void 0, c == null || c();
464
+ },
465
+ onStepKeyDown: (h) => {
466
+ const p = oe[g ? "from-bottom" : "from-top"].includes(h.key);
467
+ u == null || u({ event: h, direction: p ? -1 : 1 });
468
+ }
469
+ }
470
+ )
471
+ }
472
+ );
473
+ }
474
+ ), le = a.forwardRef(
475
+ (e, t) => {
476
+ const {
477
+ __scopeSlider: n,
478
+ onSlideStart: o,
479
+ onSlideMove: s,
480
+ onSlideEnd: r,
481
+ onHomeKeyDown: i,
482
+ onEndKeyDown: c,
483
+ onStepKeyDown: u,
484
+ ...d
485
+ } = e, v = K(N, n);
486
+ return /* @__PURE__ */ b(
487
+ B.span,
488
+ {
489
+ ...d,
490
+ ref: t,
491
+ onKeyDown: I(e.onKeyDown, (l) => {
492
+ l.key === "Home" ? (i(l), l.preventDefault()) : l.key === "End" ? (c(l), l.preventDefault()) : ne.concat(re).includes(l.key) && (u(l), l.preventDefault());
493
+ }),
494
+ onPointerDown: I(e.onPointerDown, (l) => {
495
+ const f = l.target;
496
+ f.setPointerCapture(l.pointerId), l.preventDefault(), v.thumbs.has(f) ? f.focus() : o(l);
497
+ }),
498
+ onPointerMove: I(e.onPointerMove, (l) => {
499
+ l.target.hasPointerCapture(l.pointerId) && s(l);
500
+ }),
501
+ onPointerUp: I(e.onPointerUp, (l) => {
502
+ const f = l.target;
503
+ f.hasPointerCapture(l.pointerId) && (f.releasePointerCapture(l.pointerId), r(l));
504
+ })
505
+ }
506
+ );
507
+ }
508
+ ), ue = "SliderTrack", de = a.forwardRef(
509
+ (e, t) => {
510
+ const { __scopeSlider: n, ...o } = e, s = K(ue, n);
511
+ return /* @__PURE__ */ b(
512
+ B.span,
513
+ {
514
+ "data-disabled": s.disabled ? "" : void 0,
515
+ "data-orientation": s.orientation,
516
+ ...o,
517
+ ref: t
518
+ }
519
+ );
520
+ }
521
+ );
522
+ de.displayName = ue;
523
+ var W = "SliderRange", fe = a.forwardRef(
524
+ (e, t) => {
525
+ const { __scopeSlider: n, ...o } = e, s = K(W, n), r = ae(W, n), i = a.useRef(null), c = D(t, i), u = s.values.length, d = s.values.map(
526
+ (f) => me(f, s.min, s.max)
527
+ ), v = u > 1 ? Math.min(...d) : 0, l = 100 - Math.max(...d);
528
+ return /* @__PURE__ */ b(
529
+ B.span,
530
+ {
531
+ "data-orientation": s.orientation,
532
+ "data-disabled": s.disabled ? "" : void 0,
533
+ ...o,
534
+ ref: c,
535
+ style: {
536
+ ...e.style,
537
+ [r.startEdge]: v + "%",
538
+ [r.endEdge]: l + "%"
539
+ }
540
+ }
541
+ );
542
+ }
543
+ );
544
+ fe.displayName = W;
545
+ var U = "SliderThumb", pe = a.forwardRef(
546
+ (e, t) => {
547
+ const n = Ve(e.__scopeSlider), [o, s] = a.useState(null), r = D(t, (c) => s(c)), i = a.useMemo(
548
+ () => o ? n().findIndex((c) => c.ref.current === o) : -1,
549
+ [n, o]
550
+ );
551
+ return /* @__PURE__ */ b(Le, { ...e, ref: r, index: i });
552
+ }
553
+ ), Le = a.forwardRef(
554
+ (e, t) => {
555
+ const { __scopeSlider: n, index: o, name: s, ...r } = e, i = K(U, n), c = ae(U, n), [u, d] = a.useState(null), v = D(t, (C) => d(C)), l = u ? i.form || !!u.closest("form") : !0, f = De(u), g = i.values[o], m = g === void 0 ? 0 : me(g, i.min, i.max), h = Fe(o, i.values.length), S = f == null ? void 0 : f[c.size], p = S ? We(S, m, c.direction) : 0;
556
+ return a.useEffect(() => {
557
+ if (u)
558
+ return i.thumbs.add(u), () => {
559
+ i.thumbs.delete(u);
560
+ };
561
+ }, [u, i.thumbs]), /* @__PURE__ */ Z(
562
+ "span",
563
+ {
564
+ style: {
565
+ transform: "var(--radix-slider-thumb-transform)",
566
+ position: "absolute",
567
+ [c.startEdge]: `calc(${m}% + ${p}px)`
568
+ },
569
+ children: [
570
+ /* @__PURE__ */ b(H.ItemSlot, { scope: e.__scopeSlider, children: /* @__PURE__ */ b(
571
+ B.span,
572
+ {
573
+ role: "slider",
574
+ "aria-label": e["aria-label"] || h,
575
+ "aria-valuemin": i.min,
576
+ "aria-valuenow": g,
577
+ "aria-valuemax": i.max,
578
+ "aria-orientation": i.orientation,
579
+ "data-orientation": i.orientation,
580
+ "data-disabled": i.disabled ? "" : void 0,
581
+ tabIndex: i.disabled ? void 0 : 0,
582
+ ...r,
583
+ ref: v,
584
+ style: g === void 0 ? { display: "none" } : e.style,
585
+ onFocus: I(e.onFocus, () => {
586
+ i.valueIndexToChangeRef.current = o;
587
+ })
588
+ }
589
+ ) }),
590
+ l && /* @__PURE__ */ b(
591
+ $e,
592
+ {
593
+ name: s ?? (i.name ? i.name + (i.values.length > 1 ? "[]" : "") : void 0),
594
+ form: i.form,
595
+ value: g
596
+ },
597
+ o
598
+ )
599
+ ]
600
+ }
601
+ );
602
+ }
603
+ );
604
+ pe.displayName = U;
605
+ var $e = (e) => {
606
+ const { value: t, ...n } = e, o = a.useRef(null), s = Pe(t);
607
+ return a.useEffect(() => {
608
+ const r = o.current, i = window.HTMLInputElement.prototype, u = Object.getOwnPropertyDescriptor(i, "value").set;
609
+ if (s !== t && u) {
610
+ const d = new Event("input", { bubbles: !0 });
611
+ u.call(r, t), r.dispatchEvent(d);
680
612
  }
681
- }, n, {
682
- ref: r,
683
- defaultValue: t
684
- }));
613
+ }, [s, t]), /* @__PURE__ */ b("input", { style: { display: "none" }, ...n, ref: o, defaultValue: t });
685
614
  };
686
- function nt(e = [], t, n) {
687
- const r = [
688
- ...e
689
- ];
690
- return r[n] = t, r.sort(
691
- (i, o) => i - o
692
- );
615
+ function je(e = [], t, n) {
616
+ const o = [...e];
617
+ return o[n] = t, o.sort((s, r) => s - r);
693
618
  }
694
- function xe(e, t, n) {
695
- const o = 100 / (n - t) * (e - t);
696
- return le(o, [
697
- 0,
698
- 100
699
- ]);
619
+ function me(e, t, n) {
620
+ const r = 100 / (n - t) * (e - t);
621
+ return J(r, [0, 100]);
700
622
  }
701
- function ot(e, t) {
702
- return t > 2 ? `Value ${e + 1} of ${t}` : t === 2 ? [
703
- "Minimum",
704
- "Maximum"
705
- ][e] : void 0;
623
+ function Fe(e, t) {
624
+ return t > 2 ? `Value ${e + 1} of ${t}` : t === 2 ? ["Minimum", "Maximum"][e] : void 0;
706
625
  }
707
- function rt(e, t) {
626
+ function He(e, t) {
708
627
  if (e.length === 1) return 0;
709
- const n = e.map(
710
- (i) => Math.abs(i - t)
711
- ), r = Math.min(...n);
712
- return n.indexOf(r);
628
+ const n = e.map((s) => Math.abs(s - t)), o = Math.min(...n);
629
+ return n.indexOf(o);
713
630
  }
714
- function it(e, t, n) {
715
- const r = e / 2, o = Q([
716
- 0,
717
- 50
718
- ], [
719
- 0,
720
- r
721
- ]);
722
- return (r - o(t) * n) * n;
631
+ function We(e, t, n) {
632
+ const o = e / 2, r = Y([0, 50], [0, o]);
633
+ return (o - r(t) * n) * n;
723
634
  }
724
- function ct(e) {
725
- return e.slice(0, -1).map(
726
- (t, n) => e[n + 1] - t
727
- );
635
+ function Ue(e) {
636
+ return e.slice(0, -1).map((t, n) => e[n + 1] - t);
728
637
  }
729
- function at(e, t) {
638
+ function Ye(e, t) {
730
639
  if (t > 0) {
731
- const n = ct(e);
640
+ const n = Ue(e);
732
641
  return Math.min(...n) >= t;
733
642
  }
734
643
  return !0;
735
644
  }
736
- function Q(e, t) {
645
+ function Y(e, t) {
737
646
  return (n) => {
738
647
  if (e[0] === e[1] || t[0] === t[1]) return t[0];
739
- const r = (t[1] - t[0]) / (e[1] - e[0]);
740
- return t[0] + r * (n - e[0]);
648
+ const o = (t[1] - t[0]) / (e[1] - e[0]);
649
+ return t[0] + o * (n - e[0]);
741
650
  };
742
651
  }
743
- function st(e) {
652
+ function Xe(e) {
744
653
  return (String(e).split(".")[1] || "").length;
745
654
  }
746
- function lt(e, t) {
655
+ function Ge(e, t) {
747
656
  const n = Math.pow(10, t);
748
657
  return Math.round(e * n) / n;
749
658
  }
750
- const ut = We, dt = Ze, ft = Je, pt = Qe;
751
- function $t(e) {
659
+ var qe = ie, Ze = de, Je = fe, Qe = pe;
660
+ function et(e) {
752
661
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
753
662
  }
754
- var ge = { exports: {} };
663
+ var he = { exports: {} };
755
664
  /*!
756
665
  Copyright (c) 2018 Jed Watson.
757
666
  Licensed under the MIT License (MIT), see
@@ -761,75 +670,75 @@ var ge = { exports: {} };
761
670
  (function() {
762
671
  var t = {}.hasOwnProperty;
763
672
  function n() {
764
- for (var o = "", a = 0; a < arguments.length; a++) {
765
- var c = arguments[a];
766
- c && (o = i(o, r.call(this, c)));
673
+ for (var r = "", i = 0; i < arguments.length; i++) {
674
+ var c = arguments[i];
675
+ c && (r = s(r, o.call(this, c)));
767
676
  }
768
- return o;
677
+ return r;
769
678
  }
770
- function r(o) {
771
- if (typeof o == "string" || typeof o == "number")
772
- return this && this[o] || o;
773
- if (typeof o != "object")
679
+ function o(r) {
680
+ if (typeof r == "string" || typeof r == "number")
681
+ return this && this[r] || r;
682
+ if (typeof r != "object")
774
683
  return "";
775
- if (Array.isArray(o))
776
- return n.apply(this, o);
777
- if (o.toString !== Object.prototype.toString && !o.toString.toString().includes("[native code]"))
778
- return o.toString();
779
- var a = "";
780
- for (var c in o)
781
- t.call(o, c) && o[c] && (a = i(a, this && this[c] || c));
782
- return a;
684
+ if (Array.isArray(r))
685
+ return n.apply(this, r);
686
+ if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
687
+ return r.toString();
688
+ var i = "";
689
+ for (var c in r)
690
+ t.call(r, c) && r[c] && (i = s(i, this && this[c] || c));
691
+ return i;
783
692
  }
784
- function i(o, a) {
785
- return a ? o ? o + " " + a : o + a : o;
693
+ function s(r, i) {
694
+ return i ? r ? r + " " + i : r + i : r;
786
695
  }
787
696
  e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
788
697
  })();
789
- })(ge);
790
- var mt = ge.exports;
791
- const St = /* @__PURE__ */ $t(mt), ht = {
698
+ })(he);
699
+ var tt = he.exports;
700
+ const nt = /* @__PURE__ */ et(tt), rt = {
792
701
  "purpur-slider": "_purpur-slider_14tuk_1",
793
702
  "purpur-slider__track": "_purpur-slider__track_14tuk_17",
794
703
  "purpur-slider__range": "_purpur-slider__range_14tuk_17",
795
704
  "purpur-slider__thumb": "_purpur-slider__thumb_14tuk_43"
796
- }, H = St.bind(ht), Ct = ["horizontal", "vertical"], j = "purpur-slider", bt = (e) => String(e), vt = ({
705
+ }, V = nt.bind(rt), dt = ["horizontal", "vertical"], k = "purpur-slider", ot = (e) => String(e), st = ({
797
706
  "aria-label": e,
798
707
  "aria-valuetext": t,
799
708
  className: n,
800
- defaultValue: r,
801
- id: i,
802
- value: o,
803
- ...a
709
+ defaultValue: o,
710
+ id: s,
711
+ value: r,
712
+ ...i
804
713
  }, c) => {
805
- const l = Me(), u = o || r;
806
- return /* @__PURE__ */ Pe(
807
- ut,
714
+ const u = ve(), d = r || o;
715
+ return /* @__PURE__ */ Z(
716
+ qe,
808
717
  {
809
- ...a,
810
- id: i || l,
718
+ ...i,
719
+ id: s || u,
811
720
  ref: c,
812
- className: H(j, n),
813
- value: o,
814
- defaultValue: r,
721
+ className: V(k, n),
722
+ value: r,
723
+ defaultValue: o,
815
724
  children: [
816
- /* @__PURE__ */ G(dt, { className: H(`${j}__track`), children: /* @__PURE__ */ G(ft, { className: H(`${j}__range`) }) }),
817
- u == null ? void 0 : u.map((m, s) => /* @__PURE__ */ G(
818
- pt,
725
+ /* @__PURE__ */ b(Ze, { className: V(`${k}__track`), children: /* @__PURE__ */ b(Je, { className: V(`${k}__range`) }) }),
726
+ d == null ? void 0 : d.map((v, l) => /* @__PURE__ */ b(
727
+ Qe,
819
728
  {
820
- className: H(`${j}__thumb`),
729
+ className: V(`${k}__thumb`),
821
730
  "aria-label": e,
822
731
  "aria-valuetext": t
823
732
  },
824
- bt(s)
733
+ ot(l)
825
734
  ))
826
735
  ]
827
736
  }
828
737
  );
829
- }, xt = P(vt);
830
- xt.displayName = "Slider";
738
+ }, it = ye(st);
739
+ it.displayName = "Slider";
831
740
  export {
832
- Ct as SLIDER_ORIENTATION,
833
- xt as Slider
741
+ dt as SLIDER_ORIENTATION,
742
+ it as Slider
834
743
  };
835
744
  //# sourceMappingURL=slider.es.js.map