@purpurds/toggle 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/toggle.es.js CHANGED
@@ -1,10 +1,11 @@
1
- import { jsx as w, jsxs as F } from "react/jsx-runtime";
2
- import { forwardRef as S, Children as $, isValidElement as A, createElement as _, cloneElement as B, useEffect as C, Fragment as K, useCallback as z, createContext as W, useMemo as j, useContext as pe, useRef as x, useState as y, useLayoutEffect as de } from "react";
1
+ import { jsx as f, Fragment as F, jsxs as M } from "react/jsx-runtime";
2
+ import * as s from "react";
3
+ import { useState as C, useCallback as z, useEffect as k, isValidElement as ce, cloneElement as le, Children as pe, useRef as $, forwardRef as de } from "react";
3
4
  import "react-dom";
4
5
  function fe(e) {
5
6
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
6
7
  }
7
- var Q = { exports: {} };
8
+ var U = { exports: {} };
8
9
  /*!
9
10
  Copyright (c) 2018 Jed Watson.
10
11
  Licensed under the MIT License (MIT), see
@@ -14,9 +15,9 @@ var Q = { exports: {} };
14
15
  (function() {
15
16
  var n = {}.hasOwnProperty;
16
17
  function t() {
17
- for (var r = "", o = 0; o < arguments.length; o++) {
18
- var c = arguments[o];
19
- c && (r = u(r, a.call(this, c)));
18
+ for (var r = "", i = 0; i < arguments.length; i++) {
19
+ var u = arguments[i];
20
+ u && (r = o(r, a.call(this, u)));
20
21
  }
21
22
  return r;
22
23
  }
@@ -29,19 +30,19 @@ var Q = { exports: {} };
29
30
  return t.apply(this, r);
30
31
  if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
31
32
  return r.toString();
32
- var o = "";
33
- for (var c in r)
34
- n.call(r, c) && r[c] && (o = u(o, this && this[c] || c));
35
- return o;
33
+ var i = "";
34
+ for (var u in r)
35
+ n.call(r, u) && r[u] && (i = o(i, this && this[u] || u));
36
+ return i;
36
37
  }
37
- function u(r, o) {
38
- return o ? r ? r + " " + o : r + o : r;
38
+ function o(r, i) {
39
+ return i ? r ? r + " " + i : r + i : r;
39
40
  }
40
41
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
41
42
  })();
42
- })(Q);
43
- var he = Q.exports;
44
- const ge = /* @__PURE__ */ fe(he), be = {
43
+ })(U);
44
+ var he = U.exports;
45
+ const ge = /* @__PURE__ */ fe(he), me = {
45
46
  "purpur-icon": "_purpur-icon_8u1lq_1",
46
47
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
47
48
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -49,108 +50,103 @@ const ge = /* @__PURE__ */ fe(he), be = {
49
50
  "purpur-icon--md": "_purpur-icon--md_8u1lq_16",
50
51
  "purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
51
52
  "purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
52
- }, _e = ge.bind(be), U = "purpur-icon", me = "md", ve = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), $e = ({ content: e = "", title: n } = {}) => {
53
+ }, _e = ge.bind(me), X = "purpur-icon", ve = "md", be = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), ye = ({ content: e = "", title: n } = {}) => {
53
54
  const t = [
54
55
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
55
56
  { name: "fill", value: "currentColor" },
56
57
  { name: "viewBox", value: "0 0 24 24" },
57
58
  n ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
58
59
  ], a = n ? `<title>${n}</title>` : "";
59
- return `<svg ${ve(t)}>${a}${e}</svg>`;
60
- }, ye = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), Y = ({
60
+ return `<svg ${be(t)}>${a}${e}</svg>`;
61
+ }, we = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), G = ({
61
62
  ["data-testid"]: e,
62
63
  svg: n,
63
64
  allyTitle: t,
64
65
  className: a,
65
- size: u = me,
66
+ size: o = ve,
66
67
  ...r
67
68
  }) => {
68
- const o = $e({
69
- content: ye(n.svg),
69
+ const i = ye({
70
+ content: we(n.svg),
70
71
  title: t
71
- }), c = _e(a, U, `${U}--${u}`);
72
- return /* @__PURE__ */ w(
72
+ }), u = _e(a, X, `${X}--${o}`);
73
+ return /* @__PURE__ */ f(
73
74
  "span",
74
75
  {
75
76
  "aria-label": t,
76
- className: c,
77
+ className: u,
77
78
  "data-testid": e,
78
- dangerouslySetInnerHTML: { __html: o },
79
+ dangerouslySetInnerHTML: { __html: i },
79
80
  ...r
80
81
  }
81
82
  );
82
83
  };
83
- Y.displayName = "Icon";
84
- const we = {
84
+ G.displayName = "Icon";
85
+ const Se = {
85
86
  name: "checkmark-bold",
86
87
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M21.243 4.176a2 2 0 0 1 .324 2.81l-10.45 13.176a2.092 2.092 0 0 1-3.118.18l-5.413-5.413A2 2 0 1 1 5.414 12.1l3.9 3.9 9.118-11.5a2 2 0 0 1 2.81-.324Z" clip-rule="evenodd"/></svg>',
87
88
  keywords: ["checkmark-bold"],
88
89
  category: "utility"
89
90
  };
90
- function O() {
91
- return O = Object.assign ? Object.assign.bind() : function(e) {
92
- for (var n = 1; n < arguments.length; n++) {
93
- var t = arguments[n];
94
- for (var a in t) ({}).hasOwnProperty.call(t, a) && (e[a] = t[a]);
95
- }
96
- return e;
97
- }, O.apply(null, arguments);
91
+ function W(e, n) {
92
+ if (typeof e == "function")
93
+ return e(n);
94
+ e != null && (e.current = n);
98
95
  }
99
- function xe(e, n) {
100
- typeof e == "function" ? e(n) : e != null && (e.current = n);
101
- }
102
- function Se(...e) {
103
- return (n) => e.forEach(
104
- (t) => xe(t, n)
105
- );
96
+ function xe(...e) {
97
+ return (n) => {
98
+ let t = !1;
99
+ const a = e.map((o) => {
100
+ const r = W(o, n);
101
+ return !t && typeof r == "function" && (t = !0), r;
102
+ });
103
+ if (t)
104
+ return () => {
105
+ for (let o = 0; o < a.length; o++) {
106
+ const r = a[o];
107
+ typeof r == "function" ? r() : W(e[o], null);
108
+ }
109
+ };
110
+ };
106
111
  }
107
- const ee = /* @__PURE__ */ S((e, n) => {
108
- const { children: t, ...a } = e, u = $.toArray(t), r = u.find(ke);
112
+ var Z = s.forwardRef((e, n) => {
113
+ const { children: t, ...a } = e, o = s.Children.toArray(t), r = o.find(Ce);
109
114
  if (r) {
110
- const o = r.props.children, c = u.map((i) => i === r ? $.count(o) > 1 ? $.only(null) : /* @__PURE__ */ A(o) ? o.props.children : null : i);
111
- return /* @__PURE__ */ _(T, O({}, a, {
112
- ref: n
113
- }), /* @__PURE__ */ A(o) ? /* @__PURE__ */ B(o, void 0, c) : null);
115
+ const i = r.props.children, u = o.map((c) => c === r ? s.Children.count(i) > 1 ? s.Children.only(null) : s.isValidElement(i) ? i.props.children : null : c);
116
+ return /* @__PURE__ */ f(j, { ...a, ref: n, children: s.isValidElement(i) ? s.cloneElement(i, void 0, u) : null });
114
117
  }
115
- return /* @__PURE__ */ _(T, O({}, a, {
116
- ref: n
117
- }), t);
118
+ return /* @__PURE__ */ f(j, { ...a, ref: n, children: t });
118
119
  });
119
- ee.displayName = "Slot";
120
- const T = /* @__PURE__ */ S((e, n) => {
120
+ Z.displayName = "Slot";
121
+ var j = s.forwardRef((e, n) => {
121
122
  const { children: t, ...a } = e;
122
- return /* @__PURE__ */ A(t) ? /* @__PURE__ */ B(t, {
123
- ...Ae(a, t.props),
124
- ref: n ? Se(n, t.ref) : t.ref
125
- }) : $.count(t) > 1 ? $.only(null) : null;
123
+ if (s.isValidElement(t)) {
124
+ const o = Ee(t), r = Pe(a, t.props);
125
+ return t.type !== s.Fragment && (r.ref = n ? xe(n, o) : o), s.cloneElement(t, r);
126
+ }
127
+ return s.Children.count(t) > 1 ? s.Children.only(null) : null;
126
128
  });
127
- T.displayName = "SlotClone";
128
- const Pe = ({ children: e }) => /* @__PURE__ */ _(K, null, e);
129
- function ke(e) {
130
- return /* @__PURE__ */ A(e) && e.type === Pe;
129
+ j.displayName = "SlotClone";
130
+ var Re = ({ children: e }) => /* @__PURE__ */ f(F, { children: e });
131
+ function Ce(e) {
132
+ return s.isValidElement(e) && e.type === Re;
131
133
  }
132
- function Ae(e, n) {
133
- const t = {
134
- ...n
135
- };
134
+ function Pe(e, n) {
135
+ const t = { ...n };
136
136
  for (const a in n) {
137
- const u = e[a], r = n[a];
138
- /^on[A-Z]/.test(a) ? u && r ? t[a] = (...o) => {
139
- r(...o), u(...o);
140
- } : u && (t[a] = u) : a === "style" ? t[a] = {
141
- ...u,
142
- ...r
143
- } : a === "className" && (t[a] = [
144
- u,
145
- r
146
- ].filter(Boolean).join(" "));
137
+ const o = e[a], r = n[a];
138
+ /^on[A-Z]/.test(a) ? o && r ? t[a] = (...i) => {
139
+ r(...i), o(...i);
140
+ } : o && (t[a] = o) : a === "style" ? t[a] = { ...o, ...r } : a === "className" && (t[a] = [o, r].filter(Boolean).join(" "));
147
141
  }
148
- return {
149
- ...e,
150
- ...t
151
- };
142
+ return { ...e, ...t };
143
+ }
144
+ function Ee(e) {
145
+ var n, t;
146
+ let a = (n = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : n.get, o = a && "isReactWarning" in a && a.isReactWarning;
147
+ return o ? e.ref : (a = (t = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : t.get, o = a && "isReactWarning" in a && a.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
152
148
  }
153
- const Ce = [
149
+ var $e = [
154
150
  "a",
155
151
  "button",
156
152
  "div",
@@ -167,30 +163,29 @@ const Ce = [
167
163
  "span",
168
164
  "svg",
169
165
  "ul"
170
- ], De = Ce.reduce((e, n) => {
171
- const t = /* @__PURE__ */ S((a, u) => {
172
- const { asChild: r, ...o } = a, c = r ? ee : n;
173
- return C(() => {
174
- window[Symbol.for("radix-ui")] = !0;
175
- }, []), /* @__PURE__ */ _(c, O({}, o, {
176
- ref: u
177
- }));
166
+ ], ke = $e.reduce((e, n) => {
167
+ const t = s.forwardRef((a, o) => {
168
+ const { asChild: r, ...i } = a, u = r ? Z : n;
169
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ f(u, { ...i, ref: o });
178
170
  });
179
- return t.displayName = `Primitive.${n}`, {
171
+ return t.displayName = `Primitive.${n}`, { ...e, [n]: t };
172
+ }, {}), Ae = "Label", J = s.forwardRef((e, n) => /* @__PURE__ */ f(
173
+ ke.label,
174
+ {
180
175
  ...e,
181
- [n]: t
182
- };
183
- }, {}), Ne = /* @__PURE__ */ S((e, n) => /* @__PURE__ */ _(De.label, O({}, e, {
184
- ref: n,
185
- onMouseDown: (t) => {
186
- var a;
187
- (a = e.onMouseDown) === null || a === void 0 || a.call(e, t), !t.defaultPrevented && t.detail > 1 && t.preventDefault();
176
+ ref: n,
177
+ onMouseDown: (t) => {
178
+ var a;
179
+ t.target.closest("button, input, select, textarea") || ((a = e.onMouseDown) == null || a.call(e, t), !t.defaultPrevented && t.detail > 1 && t.preventDefault());
180
+ }
188
181
  }
189
- }))), Ee = Ne;
190
- function Oe(e) {
182
+ ));
183
+ J.displayName = Ae;
184
+ var De = J;
185
+ function Ne(e) {
191
186
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
192
187
  }
193
- var re = { exports: {} };
188
+ var K = { exports: {} };
194
189
  /*!
195
190
  Copyright (c) 2018 Jed Watson.
196
191
  Licensed under the MIT License (MIT), see
@@ -200,9 +195,9 @@ var re = { exports: {} };
200
195
  (function() {
201
196
  var n = {}.hasOwnProperty;
202
197
  function t() {
203
- for (var r = "", o = 0; o < arguments.length; o++) {
204
- var c = arguments[o];
205
- c && (r = u(r, a(c)));
198
+ for (var r = "", i = 0; i < arguments.length; i++) {
199
+ var u = arguments[i];
200
+ u && (r = o(r, a(u)));
206
201
  }
207
202
  return r;
208
203
  }
@@ -215,45 +210,45 @@ var re = { exports: {} };
215
210
  return t.apply(null, r);
216
211
  if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
217
212
  return r.toString();
218
- var o = "";
219
- for (var c in r)
220
- n.call(r, c) && r[c] && (o = u(o, c));
221
- return o;
213
+ var i = "";
214
+ for (var u in r)
215
+ n.call(r, u) && r[u] && (i = o(i, u));
216
+ return i;
222
217
  }
223
- function u(r, o) {
224
- return o ? r ? r + " " + o : r + o : r;
218
+ function o(r, i) {
219
+ return i ? r ? r + " " + i : r + i : r;
225
220
  }
226
221
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
227
222
  })();
228
- })(re);
229
- var Re = re.exports;
230
- const Me = /* @__PURE__ */ Oe(Re), X = {
223
+ })(K);
224
+ var Oe = K.exports;
225
+ const Me = /* @__PURE__ */ Ne(Oe), D = {
231
226
  "purpur-label": "_purpur-label_12cfi_1",
232
227
  "purpur-label--negative": "_purpur-label--negative_12cfi_9",
233
228
  "purpur-label--disabled": "_purpur-label--disabled_12cfi_12"
234
- }, H = "purpur-label", ze = ({
229
+ }, N = "purpur-label", ze = ({
235
230
  children: e,
236
231
  className: n,
237
232
  htmlFor: t,
238
233
  "data-testid": a,
239
- disabled: u,
234
+ disabled: o,
240
235
  negative: r = !1,
241
- ...o
236
+ ...i
242
237
  }) => {
243
- const c = Me([
238
+ const u = Me([
244
239
  n,
245
- X[H],
240
+ D[N],
246
241
  {
247
- [X[`${H}--disabled`]]: u,
248
- [X[`${H}--negative`]]: r
242
+ [D[`${N}--disabled`]]: o,
243
+ [D[`${N}--negative`]]: r
249
244
  }
250
245
  ]);
251
- return /* @__PURE__ */ w(Ee, { className: c, "data-testid": a, htmlFor: t, ...o, children: e });
246
+ return /* @__PURE__ */ f(De, { className: u, "data-testid": a, htmlFor: t, ...i, children: e });
252
247
  };
253
248
  function je(e) {
254
249
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
255
250
  }
256
- var te = { exports: {} };
251
+ var Q = { exports: {} };
257
252
  /*!
258
253
  Copyright (c) 2018 Jed Watson.
259
254
  Licensed under the MIT License (MIT), see
@@ -263,9 +258,9 @@ var te = { exports: {} };
263
258
  (function() {
264
259
  var n = {}.hasOwnProperty;
265
260
  function t() {
266
- for (var r = "", o = 0; o < arguments.length; o++) {
267
- var c = arguments[o];
268
- c && (r = u(r, a(c)));
261
+ for (var r = "", i = 0; i < arguments.length; i++) {
262
+ var u = arguments[i];
263
+ u && (r = o(r, a(u)));
269
264
  }
270
265
  return r;
271
266
  }
@@ -278,19 +273,19 @@ var te = { exports: {} };
278
273
  return t.apply(null, r);
279
274
  if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
280
275
  return r.toString();
281
- var o = "";
282
- for (var c in r)
283
- n.call(r, c) && r[c] && (o = u(o, c));
284
- return o;
276
+ var i = "";
277
+ for (var u in r)
278
+ n.call(r, u) && r[u] && (i = o(i, u));
279
+ return i;
285
280
  }
286
- function u(r, o) {
287
- return o ? r ? r + " " + o : r + o : r;
281
+ function o(r, i) {
282
+ return i ? r ? r + " " + i : r + i : r;
288
283
  }
289
284
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
290
285
  })();
291
- })(te);
292
- var Be = te.exports;
293
- const Le = /* @__PURE__ */ je(Be), R = {
286
+ })(Q);
287
+ var Le = Q.exports;
288
+ const Be = /* @__PURE__ */ je(Le), P = {
294
289
  "purpur-paragraph": "_purpur-paragraph_1rh57_1",
295
290
  "purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
296
291
  "purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1rh57_10",
@@ -316,267 +311,211 @@ const Le = /* @__PURE__ */ je(Be), R = {
316
311
  ADDITIONAL100MEDIUM: "additional-100-medium",
317
312
  OVERLINE100: "overline-100",
318
313
  OVERLINE200: "overline-200"
319
- }, M = "purpur-paragraph", ne = ({
314
+ }, E = "purpur-paragraph", Y = ({
320
315
  ["data-testid"]: e,
321
316
  children: n,
322
317
  className: t,
323
318
  disabled: a,
324
- enableHyphenation: u = !1,
319
+ enableHyphenation: o = !1,
325
320
  negative: r = !1,
326
- variant: o = Xe.PARAGRAPH100,
327
- ...c
321
+ variant: i = Xe.PARAGRAPH100,
322
+ ...u
328
323
  }) => {
329
- const i = Le([
324
+ const c = Be([
330
325
  t,
331
- R[M],
332
- R[`${M}--${o}`],
326
+ P[E],
327
+ P[`${E}--${i}`],
333
328
  {
334
- [R[`${M}--hyphens`]]: u,
335
- [R[`${M}--disabled`]]: a,
336
- [R[`${M}--negative`]]: r
329
+ [P[`${E}--hyphens`]]: o,
330
+ [P[`${E}--disabled`]]: a,
331
+ [P[`${E}--negative`]]: r
337
332
  }
338
333
  ]);
339
- return /* @__PURE__ */ w("p", { ...c, className: i, "data-testid": e, children: n });
334
+ return /* @__PURE__ */ f("p", { ...u, className: c, "data-testid": e, children: n });
340
335
  };
341
- ne.displayName = "Paragraph";
342
- function N() {
343
- return N = Object.assign ? Object.assign.bind() : function(e) {
344
- for (var n = 1; n < arguments.length; n++) {
345
- var t = arguments[n];
346
- for (var a in t) ({}).hasOwnProperty.call(t, a) && (e[a] = t[a]);
347
- }
348
- return e;
349
- }, N.apply(null, arguments);
350
- }
351
- function He(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
352
- return function(u) {
353
- if (e == null || e(u), t === !1 || !u.defaultPrevented) return n == null ? void 0 : n(u);
336
+ Y.displayName = "Paragraph";
337
+ function We(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
338
+ return function(o) {
339
+ if (e == null || e(o), t === !1 || !o.defaultPrevented)
340
+ return n == null ? void 0 : n(o);
354
341
  };
355
342
  }
356
- function Ie(e, n) {
357
- typeof e == "function" ? e(n) : e != null && (e.current = n);
343
+ function I(e, n) {
344
+ if (typeof e == "function")
345
+ return e(n);
346
+ e != null && (e.current = n);
358
347
  }
359
- function oe(...e) {
360
- return (n) => e.forEach(
361
- (t) => Ie(t, n)
362
- );
348
+ function ee(...e) {
349
+ return (n) => {
350
+ let t = !1;
351
+ const a = e.map((o) => {
352
+ const r = I(o, n);
353
+ return !t && typeof r == "function" && (t = !0), r;
354
+ });
355
+ if (t)
356
+ return () => {
357
+ for (let o = 0; o < a.length; o++) {
358
+ const r = a[o];
359
+ typeof r == "function" ? r() : I(e[o], null);
360
+ }
361
+ };
362
+ };
363
363
  }
364
- function Te(...e) {
365
- return z(oe(...e), e);
364
+ function Ie(...e) {
365
+ return s.useCallback(ee(...e), e);
366
366
  }
367
- function qe(e, n = []) {
367
+ function He(e, n = []) {
368
368
  let t = [];
369
- function a(r, o) {
370
- const c = /* @__PURE__ */ W(o), i = t.length;
371
- t = [
372
- ...t,
373
- o
374
- ];
375
- function s(l) {
376
- const { scope: p, children: f, ...d } = l, b = (p == null ? void 0 : p[e][i]) || c, h = j(
377
- () => d,
378
- Object.values(d)
379
- );
380
- return /* @__PURE__ */ _(b.Provider, {
381
- value: h
382
- }, f);
383
- }
384
- function g(l, p) {
385
- const f = (p == null ? void 0 : p[e][i]) || c, d = pe(f);
386
- if (d) return d;
387
- if (o !== void 0) return o;
388
- throw new Error(`\`${l}\` must be used within \`${r}\``);
369
+ function a(r, i) {
370
+ const u = s.createContext(i), c = t.length;
371
+ t = [...t, i];
372
+ const l = (d) => {
373
+ var v;
374
+ const { scope: p, children: g, ...h } = d, m = ((v = p == null ? void 0 : p[e]) == null ? void 0 : v[c]) || u, b = s.useMemo(() => h, Object.values(h));
375
+ return /* @__PURE__ */ f(m.Provider, { value: b, children: g });
376
+ };
377
+ l.displayName = r + "Provider";
378
+ function _(d, p) {
379
+ var m;
380
+ const g = ((m = p == null ? void 0 : p[e]) == null ? void 0 : m[c]) || u, h = s.useContext(g);
381
+ if (h) return h;
382
+ if (i !== void 0) return i;
383
+ throw new Error(`\`${d}\` must be used within \`${r}\``);
389
384
  }
390
- return s.displayName = r + "Provider", [
391
- s,
392
- g
393
- ];
385
+ return [l, _];
394
386
  }
395
- const u = () => {
396
- const r = t.map((o) => /* @__PURE__ */ W(o));
397
- return function(c) {
398
- const i = (c == null ? void 0 : c[e]) || r;
399
- return j(
400
- () => ({
401
- [`__scope${e}`]: {
402
- ...c,
403
- [e]: i
404
- }
405
- }),
406
- [
407
- c,
408
- i
409
- ]
387
+ const o = () => {
388
+ const r = t.map((i) => s.createContext(i));
389
+ return function(u) {
390
+ const c = (u == null ? void 0 : u[e]) || r;
391
+ return s.useMemo(
392
+ () => ({ [`__scope${e}`]: { ...u, [e]: c } }),
393
+ [u, c]
410
394
  );
411
395
  };
412
396
  };
413
- return u.scopeName = e, [
414
- a,
415
- Fe(u, ...n)
416
- ];
397
+ return o.scopeName = e, [a, Ve(o, ...n)];
417
398
  }
418
- function Fe(...e) {
399
+ function Ve(...e) {
419
400
  const n = e[0];
420
401
  if (e.length === 1) return n;
421
402
  const t = () => {
422
- const a = e.map(
423
- (u) => ({
424
- useScope: u(),
425
- scopeName: u.scopeName
426
- })
427
- );
403
+ const a = e.map((o) => ({
404
+ useScope: o(),
405
+ scopeName: o.scopeName
406
+ }));
428
407
  return function(r) {
429
- const o = a.reduce((c, { useScope: i, scopeName: s }) => {
430
- const l = i(r)[`__scope${s}`];
431
- return {
432
- ...c,
433
- ...l
434
- };
408
+ const i = a.reduce((u, { useScope: c, scopeName: l }) => {
409
+ const d = c(r)[`__scope${l}`];
410
+ return { ...u, ...d };
435
411
  }, {});
436
- return j(
437
- () => ({
438
- [`__scope${n.scopeName}`]: o
439
- }),
440
- [
441
- o
442
- ]
443
- );
412
+ return s.useMemo(() => ({ [`__scope${n.scopeName}`]: i }), [i]);
444
413
  };
445
414
  };
446
415
  return t.scopeName = n.scopeName, t;
447
416
  }
448
- function ae(e) {
449
- const n = x(e);
450
- return C(() => {
417
+ function re(e) {
418
+ const n = s.useRef(e);
419
+ return s.useEffect(() => {
451
420
  n.current = e;
452
- }), j(
453
- () => (...t) => {
454
- var a;
455
- return (a = n.current) === null || a === void 0 ? void 0 : a.call(n, ...t);
421
+ }), s.useMemo(() => (...t) => {
422
+ var a;
423
+ return (a = n.current) == null ? void 0 : a.call(n, ...t);
424
+ }, []);
425
+ }
426
+ function Te({
427
+ prop: e,
428
+ defaultProp: n,
429
+ onChange: t = () => {
430
+ }
431
+ }) {
432
+ const [a, o] = qe({ defaultProp: n, onChange: t }), r = e !== void 0, i = r ? e : a, u = re(t), c = s.useCallback(
433
+ (l) => {
434
+ if (r) {
435
+ const d = typeof l == "function" ? l(e) : l;
436
+ d !== e && u(d);
437
+ } else
438
+ o(l);
456
439
  },
457
- []
440
+ [r, e, o, u]
458
441
  );
442
+ return [i, c];
459
443
  }
460
- function We({ prop: e, defaultProp: n, onChange: t = () => {
461
- } }) {
462
- const [a, u] = Ue({
463
- defaultProp: n,
464
- onChange: t
465
- }), r = e !== void 0, o = r ? e : a, c = ae(t), i = z((s) => {
466
- if (r) {
467
- const l = typeof s == "function" ? s(e) : s;
468
- l !== e && c(l);
469
- } else u(s);
470
- }, [
471
- r,
472
- e,
473
- u,
474
- c
475
- ]);
476
- return [
477
- o,
478
- i
479
- ];
444
+ function qe({
445
+ defaultProp: e,
446
+ onChange: n
447
+ }) {
448
+ const t = s.useState(e), [a] = t, o = s.useRef(a), r = re(n);
449
+ return s.useEffect(() => {
450
+ o.current !== a && (r(a), o.current = a);
451
+ }, [a, o, r]), t;
480
452
  }
481
- function Ue({ defaultProp: e, onChange: n }) {
482
- const t = y(e), [a] = t, u = x(a), r = ae(n);
483
- return C(() => {
484
- u.current !== a && (r(a), u.current = a);
485
- }, [
486
- a,
487
- u,
488
- r
489
- ]), t;
453
+ function Fe(e) {
454
+ const n = s.useRef({ value: e, previous: e });
455
+ return s.useMemo(() => (n.current.value !== e && (n.current.previous = n.current.value, n.current.value = e), n.current.previous), [e]);
490
456
  }
491
- function Ve(e) {
492
- const n = x({
493
- value: e,
494
- previous: e
495
- });
496
- return j(() => (n.current.value !== e && (n.current.previous = n.current.value, n.current.value = e), n.current.previous), [
497
- e
498
- ]);
499
- }
500
- const Ge = globalThis != null && globalThis.document ? de : () => {
457
+ var Ue = globalThis != null && globalThis.document ? s.useLayoutEffect : () => {
501
458
  };
502
- function Ze(e) {
503
- const [n, t] = y(void 0);
504
- return Ge(() => {
459
+ function Ge(e) {
460
+ const [n, t] = s.useState(void 0);
461
+ return Ue(() => {
505
462
  if (e) {
506
- t({
507
- width: e.offsetWidth,
508
- height: e.offsetHeight
509
- });
510
- const a = new ResizeObserver((u) => {
511
- if (!Array.isArray(u) || !u.length) return;
512
- const r = u[0];
513
- let o, c;
463
+ t({ width: e.offsetWidth, height: e.offsetHeight });
464
+ const a = new ResizeObserver((o) => {
465
+ if (!Array.isArray(o) || !o.length)
466
+ return;
467
+ const r = o[0];
468
+ let i, u;
514
469
  if ("borderBoxSize" in r) {
515
- const i = r.borderBoxSize, s = Array.isArray(i) ? i[0] : i;
516
- o = s.inlineSize, c = s.blockSize;
470
+ const c = r.borderBoxSize, l = Array.isArray(c) ? c[0] : c;
471
+ i = l.inlineSize, u = l.blockSize;
517
472
  } else
518
- o = e.offsetWidth, c = e.offsetHeight;
519
- t({
520
- width: o,
521
- height: c
522
- });
473
+ i = e.offsetWidth, u = e.offsetHeight;
474
+ t({ width: i, height: u });
523
475
  });
524
- return a.observe(e, {
525
- box: "border-box"
526
- }), () => a.unobserve(e);
476
+ return a.observe(e, { box: "border-box" }), () => a.unobserve(e);
527
477
  } else
528
478
  t(void 0);
529
- }, [
530
- e
531
- ]), n;
479
+ }, [e]), n;
532
480
  }
533
- const ue = /* @__PURE__ */ S((e, n) => {
534
- const { children: t, ...a } = e, u = $.toArray(t), r = u.find(Ke);
481
+ var te = s.forwardRef((e, n) => {
482
+ const { children: t, ...a } = e, o = s.Children.toArray(t), r = o.find(Je);
535
483
  if (r) {
536
- const o = r.props.children, c = u.map((i) => i === r ? $.count(o) > 1 ? $.only(null) : /* @__PURE__ */ A(o) ? o.props.children : null : i);
537
- return /* @__PURE__ */ _(q, N({}, a, {
538
- ref: n
539
- }), /* @__PURE__ */ A(o) ? /* @__PURE__ */ B(o, void 0, c) : null);
484
+ const i = r.props.children, u = o.map((c) => c === r ? s.Children.count(i) > 1 ? s.Children.only(null) : s.isValidElement(i) ? i.props.children : null : c);
485
+ return /* @__PURE__ */ f(L, { ...a, ref: n, children: s.isValidElement(i) ? s.cloneElement(i, void 0, u) : null });
540
486
  }
541
- return /* @__PURE__ */ _(q, N({}, a, {
542
- ref: n
543
- }), t);
487
+ return /* @__PURE__ */ f(L, { ...a, ref: n, children: t });
544
488
  });
545
- ue.displayName = "Slot";
546
- const q = /* @__PURE__ */ S((e, n) => {
489
+ te.displayName = "Slot";
490
+ var L = s.forwardRef((e, n) => {
547
491
  const { children: t, ...a } = e;
548
- return /* @__PURE__ */ A(t) ? /* @__PURE__ */ B(t, {
549
- ...Qe(a, t.props),
550
- ref: n ? oe(n, t.ref) : t.ref
551
- }) : $.count(t) > 1 ? $.only(null) : null;
492
+ if (s.isValidElement(t)) {
493
+ const o = Qe(t), r = Ke(a, t.props);
494
+ return t.type !== s.Fragment && (r.ref = n ? ee(n, o) : o), s.cloneElement(t, r);
495
+ }
496
+ return s.Children.count(t) > 1 ? s.Children.only(null) : null;
552
497
  });
553
- q.displayName = "SlotClone";
554
- const Je = ({ children: e }) => /* @__PURE__ */ _(K, null, e);
555
- function Ke(e) {
556
- return /* @__PURE__ */ A(e) && e.type === Je;
498
+ L.displayName = "SlotClone";
499
+ var Ze = ({ children: e }) => /* @__PURE__ */ f(F, { children: e });
500
+ function Je(e) {
501
+ return s.isValidElement(e) && e.type === Ze;
557
502
  }
558
- function Qe(e, n) {
559
- const t = {
560
- ...n
561
- };
503
+ function Ke(e, n) {
504
+ const t = { ...n };
562
505
  for (const a in n) {
563
- const u = e[a], r = n[a];
564
- /^on[A-Z]/.test(a) ? u && r ? t[a] = (...c) => {
565
- r(...c), u(...c);
566
- } : u && (t[a] = u) : a === "style" ? t[a] = {
567
- ...u,
568
- ...r
569
- } : a === "className" && (t[a] = [
570
- u,
571
- r
572
- ].filter(Boolean).join(" "));
506
+ const o = e[a], r = n[a];
507
+ /^on[A-Z]/.test(a) ? o && r ? t[a] = (...u) => {
508
+ r(...u), o(...u);
509
+ } : o && (t[a] = o) : a === "style" ? t[a] = { ...o, ...r } : a === "className" && (t[a] = [o, r].filter(Boolean).join(" "));
573
510
  }
574
- return {
575
- ...e,
576
- ...t
577
- };
511
+ return { ...e, ...t };
578
512
  }
579
- const Ye = [
513
+ function Qe(e) {
514
+ var a, o;
515
+ let n = (a = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : a.get, t = n && "isReactWarning" in n && n.isReactWarning;
516
+ return t ? e.ref : (n = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, t = n && "isReactWarning" in n && n.isReactWarning, t ? e.props.ref : e.props.ref || e.ref);
517
+ }
518
+ var Ye = [
580
519
  "a",
581
520
  "button",
582
521
  "div",
@@ -593,107 +532,118 @@ const Ye = [
593
532
  "span",
594
533
  "svg",
595
534
  "ul"
596
- ], ce = Ye.reduce((e, n) => {
597
- const t = /* @__PURE__ */ S((a, u) => {
598
- const { asChild: r, ...o } = a, c = r ? ue : n;
599
- return C(() => {
600
- window[Symbol.for("radix-ui")] = !0;
601
- }, []), /* @__PURE__ */ _(c, N({}, o, {
602
- ref: u
603
- }));
535
+ ], ne = Ye.reduce((e, n) => {
536
+ const t = s.forwardRef((a, o) => {
537
+ const { asChild: r, ...i } = a, u = r ? te : n;
538
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ f(u, { ...i, ref: o });
604
539
  });
605
- return t.displayName = `Primitive.${n}`, {
606
- ...e,
607
- [n]: t
608
- };
609
- }, {}), ie = "Switch", [er, vr] = qe(ie), [rr, tr] = er(ie), nr = /* @__PURE__ */ S((e, n) => {
610
- const { __scopeSwitch: t, name: a, checked: u, defaultChecked: r, required: o, disabled: c, value: i = "on", onCheckedChange: s, ...g } = e, [l, p] = y(null), f = Te(
611
- n,
612
- (v) => p(v)
613
- ), d = x(!1), b = l ? !!l.closest("form") : !0, [h = !1, m] = We({
614
- prop: u,
615
- defaultProp: r,
616
- onChange: s
617
- });
618
- return /* @__PURE__ */ _(rr, {
619
- scope: t,
620
- checked: h,
621
- disabled: c
622
- }, /* @__PURE__ */ _(ce.button, N({
623
- type: "button",
624
- role: "switch",
625
- "aria-checked": h,
626
- "aria-required": o,
627
- "data-state": se(h),
628
- "data-disabled": c ? "" : void 0,
629
- disabled: c,
630
- value: i
631
- }, g, {
632
- ref: f,
633
- onClick: He(e.onClick, (v) => {
634
- m(
635
- (D) => !D
636
- ), b && (d.current = v.isPropagationStopped(), d.current || v.stopPropagation());
637
- })
638
- })), b && /* @__PURE__ */ _(ur, {
639
- control: l,
640
- bubbles: !d.current,
641
- name: a,
642
- value: i,
643
- checked: h,
644
- required: o,
645
- disabled: c,
646
- style: {
647
- transform: "translateX(-100%)"
648
- }
649
- }));
650
- }), or = "SwitchThumb", ar = /* @__PURE__ */ S((e, n) => {
651
- const { __scopeSwitch: t, ...a } = e, u = tr(or, t);
652
- return /* @__PURE__ */ _(ce.span, N({
653
- "data-state": se(u.checked),
654
- "data-disabled": u.disabled ? "" : void 0
655
- }, a, {
656
- ref: n
657
- }));
658
- }), ur = (e) => {
659
- const { control: n, checked: t, bubbles: a = !0, ...u } = e, r = x(null), o = Ve(t), c = Ze(n);
660
- return C(() => {
661
- const i = r.current, s = window.HTMLInputElement.prototype, l = Object.getOwnPropertyDescriptor(s, "checked").set;
662
- if (o !== t && l) {
663
- const p = new Event("click", {
664
- bubbles: a
665
- });
666
- l.call(i, t), i.dispatchEvent(p);
540
+ return t.displayName = `Primitive.${n}`, { ...e, [n]: t };
541
+ }, {}), B = "Switch", [er, mr] = He(B), [rr, tr] = er(B), oe = s.forwardRef(
542
+ (e, n) => {
543
+ const {
544
+ __scopeSwitch: t,
545
+ name: a,
546
+ checked: o,
547
+ defaultChecked: r,
548
+ required: i,
549
+ disabled: u,
550
+ value: c = "on",
551
+ onCheckedChange: l,
552
+ form: _,
553
+ ...d
554
+ } = e, [p, g] = s.useState(null), h = Ie(n, (y) => g(y)), m = s.useRef(!1), b = p ? _ || !!p.closest("form") : !0, [v = !1, R] = Te({
555
+ prop: o,
556
+ defaultProp: r,
557
+ onChange: l
558
+ });
559
+ return /* @__PURE__ */ M(rr, { scope: t, checked: v, disabled: u, children: [
560
+ /* @__PURE__ */ f(
561
+ ne.button,
562
+ {
563
+ type: "button",
564
+ role: "switch",
565
+ "aria-checked": v,
566
+ "aria-required": i,
567
+ "data-state": ue(v),
568
+ "data-disabled": u ? "" : void 0,
569
+ disabled: u,
570
+ value: c,
571
+ ...d,
572
+ ref: h,
573
+ onClick: We(e.onClick, (y) => {
574
+ R((w) => !w), b && (m.current = y.isPropagationStopped(), m.current || y.stopPropagation());
575
+ })
576
+ }
577
+ ),
578
+ b && /* @__PURE__ */ f(
579
+ nr,
580
+ {
581
+ control: p,
582
+ bubbles: !m.current,
583
+ name: a,
584
+ value: c,
585
+ checked: v,
586
+ required: i,
587
+ disabled: u,
588
+ form: _,
589
+ style: { transform: "translateX(-100%)" }
590
+ }
591
+ )
592
+ ] });
593
+ }
594
+ );
595
+ oe.displayName = B;
596
+ var ae = "SwitchThumb", ie = s.forwardRef(
597
+ (e, n) => {
598
+ const { __scopeSwitch: t, ...a } = e, o = tr(ae, t);
599
+ return /* @__PURE__ */ f(
600
+ ne.span,
601
+ {
602
+ "data-state": ue(o.checked),
603
+ "data-disabled": o.disabled ? "" : void 0,
604
+ ...a,
605
+ ref: n
606
+ }
607
+ );
608
+ }
609
+ );
610
+ ie.displayName = ae;
611
+ var nr = (e) => {
612
+ const { control: n, checked: t, bubbles: a = !0, ...o } = e, r = s.useRef(null), i = Fe(t), u = Ge(n);
613
+ return s.useEffect(() => {
614
+ const c = r.current, l = window.HTMLInputElement.prototype, d = Object.getOwnPropertyDescriptor(l, "checked").set;
615
+ if (i !== t && d) {
616
+ const p = new Event("click", { bubbles: a });
617
+ d.call(c, t), c.dispatchEvent(p);
667
618
  }
668
- }, [
669
- o,
670
- t,
671
- a
672
- ]), /* @__PURE__ */ _("input", N({
673
- type: "checkbox",
674
- "aria-hidden": !0,
675
- defaultChecked: t
676
- }, u, {
677
- tabIndex: -1,
678
- ref: r,
679
- style: {
680
- ...e.style,
681
- ...c,
682
- position: "absolute",
683
- pointerEvents: "none",
684
- opacity: 0,
685
- margin: 0
619
+ }, [i, t, a]), /* @__PURE__ */ f(
620
+ "input",
621
+ {
622
+ type: "checkbox",
623
+ "aria-hidden": !0,
624
+ defaultChecked: t,
625
+ ...o,
626
+ tabIndex: -1,
627
+ ref: r,
628
+ style: {
629
+ ...e.style,
630
+ ...u,
631
+ position: "absolute",
632
+ pointerEvents: "none",
633
+ opacity: 0,
634
+ margin: 0
635
+ }
686
636
  }
687
- }));
637
+ );
688
638
  };
689
- function se(e) {
639
+ function ue(e) {
690
640
  return e ? "checked" : "unchecked";
691
641
  }
692
- const cr = nr, ir = ar;
693
- function sr(e) {
642
+ var or = oe, ar = ie;
643
+ function ir(e) {
694
644
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
695
645
  }
696
- var le = { exports: {} };
646
+ var se = { exports: {} };
697
647
  /*!
698
648
  Copyright (c) 2018 Jed Watson.
699
649
  Licensed under the MIT License (MIT), see
@@ -703,9 +653,9 @@ var le = { exports: {} };
703
653
  (function() {
704
654
  var n = {}.hasOwnProperty;
705
655
  function t() {
706
- for (var r = "", o = 0; o < arguments.length; o++) {
707
- var c = arguments[o];
708
- c && (r = u(r, a(c)));
656
+ for (var r = "", i = 0; i < arguments.length; i++) {
657
+ var u = arguments[i];
658
+ u && (r = o(r, a(u)));
709
659
  }
710
660
  return r;
711
661
  }
@@ -718,118 +668,118 @@ var le = { exports: {} };
718
668
  return t.apply(null, r);
719
669
  if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
720
670
  return r.toString();
721
- var o = "";
722
- for (var c in r)
723
- n.call(r, c) && r[c] && (o = u(o, c));
724
- return o;
671
+ var i = "";
672
+ for (var u in r)
673
+ n.call(r, u) && r[u] && (i = o(i, u));
674
+ return i;
725
675
  }
726
- function u(r, o) {
727
- return o ? r ? r + " " + o : r + o : r;
676
+ function o(r, i) {
677
+ return i ? r ? r + " " + i : r + i : r;
728
678
  }
729
679
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
730
680
  })();
731
- })(le);
732
- var lr = le.exports;
733
- const I = /* @__PURE__ */ sr(lr), V = (e) => e && "touches" in e, pr = ({
681
+ })(se);
682
+ var ur = se.exports;
683
+ const O = /* @__PURE__ */ ir(ur), H = (e) => e && "touches" in e, sr = ({
734
684
  children: e,
735
685
  disabled: n,
736
686
  onStart: t,
737
687
  onDrag: a,
738
- onStop: u,
688
+ onStop: o,
739
689
  bounds: r,
740
- position: o,
741
- style: c
690
+ position: i,
691
+ style: u
742
692
  }) => {
743
- const [i, s] = y(void 0), [g, l] = y(void 0), [p, f] = y(!1), d = (m) => {
693
+ const [c, l] = C(void 0), [_, d] = C(void 0), [p, g] = C(!1), h = (v) => {
744
694
  if (!n) {
745
- m.preventDefault();
746
- const v = V(m.nativeEvent) ? m.nativeEvent.touches[0].clientX : m.nativeEvent.clientX;
747
- l(v), t == null || t();
695
+ v.preventDefault();
696
+ const R = H(v.nativeEvent) ? v.nativeEvent.touches[0].clientX : v.nativeEvent.clientX;
697
+ d(R), t == null || t();
748
698
  }
749
- }, b = z(
750
- (m) => {
751
- if (typeof g != "number")
699
+ }, m = z(
700
+ (v) => {
701
+ if (typeof _ != "number")
752
702
  return;
753
- const D = (V(m) ? m.touches[0].clientX : m.clientX) - g;
754
- if (!D)
703
+ const y = (H(v) ? v.touches[0].clientX : v.clientX) - _;
704
+ if (!y)
755
705
  return;
756
- const E = o + D;
757
- !p && Math.abs(E) && f(!0);
758
- const L = E > r.right ? r.right : E < r.left ? r.left : E;
759
- s(L), a == null || a({ x: L });
706
+ const w = i + y;
707
+ !p && Math.abs(w) && g(!0);
708
+ const A = w > r.right ? r.right : w < r.left ? r.left : w;
709
+ l(A), a == null || a({ x: A });
760
710
  },
761
- [a, s, p, g]
762
- ), h = z(() => {
763
- l(void 0), s(void 0), f(!1), u == null || u();
764
- }, [u, l]);
765
- return C(() => (window.addEventListener("mousemove", b), window.addEventListener("touchmove", b), () => {
766
- window.removeEventListener("mousemove", b), window.removeEventListener("touchmove", b);
767
- }), [b]), C(() => (window.addEventListener("mouseup", h), window.addEventListener("touchend", h), () => {
768
- window.removeEventListener("mouseup", h), window.removeEventListener("touchend", h);
769
- }), [h]), A(e) ? B($.only(e), {
770
- onMouseDown: d,
771
- onTouchStart: d,
772
- style: { ...c, transform: `translateX(${p ? i : o}px)` }
711
+ [a, l, p, _]
712
+ ), b = z(() => {
713
+ d(void 0), l(void 0), g(!1), o == null || o();
714
+ }, [o, d]);
715
+ return k(() => (window.addEventListener("mousemove", m), window.addEventListener("touchmove", m), () => {
716
+ window.removeEventListener("mousemove", m), window.removeEventListener("touchmove", m);
717
+ }), [m]), k(() => (window.addEventListener("mouseup", b), window.addEventListener("touchend", b), () => {
718
+ window.removeEventListener("mouseup", b), window.removeEventListener("touchend", b);
719
+ }), [b]), ce(e) ? le(pe.only(e), {
720
+ onMouseDown: h,
721
+ onTouchStart: h,
722
+ style: { ...u, transform: `translateX(${p ? c : i}px)` }
773
723
  }) : null;
774
- }, G = {
724
+ }, V = {
775
725
  width: void 0,
776
726
  height: void 0
777
727
  };
778
- function Z(e) {
779
- const { ref: n, box: t = "content-box", round: a } = e, [{ width: u, height: r }, o] = y(G), c = dr(), i = x({ ...G }), s = x(void 0);
780
- return s.current = e.onResize, C(() => {
728
+ function T(e) {
729
+ const { ref: n, box: t = "content-box", round: a } = e, [{ width: o, height: r }, i] = C(V), u = cr(), c = $({ ...V }), l = $(void 0);
730
+ return l.current = e.onResize, k(() => {
781
731
  if (!n.current || typeof window > "u" || !("ResizeObserver" in window))
782
732
  return;
783
- const g = new ResizeObserver(([l]) => {
733
+ const _ = new ResizeObserver(([d]) => {
784
734
  const p = (
785
735
  // eslint-disable-next-line no-nested-ternary
786
736
  t === "border-box" ? "borderBoxSize" : t === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize"
787
- ), f = J(l, p, "inlineSize"), d = J(l, p, "blockSize");
788
- if (i.current.width !== f || i.current.height !== d) {
789
- const h = {
790
- width: f && a ? Math.round(f) : f,
791
- height: d && a ? Math.round(d) : d
737
+ ), g = q(d, p, "inlineSize"), h = q(d, p, "blockSize");
738
+ if (c.current.width !== g || c.current.height !== h) {
739
+ const b = {
740
+ width: g && a ? Math.round(g) : g,
741
+ height: h && a ? Math.round(h) : h
792
742
  };
793
- i.current.width = f, i.current.height = d, s.current ? s.current(h) : c() && o(h);
743
+ c.current.width = g, c.current.height = h, l.current ? l.current(b) : u() && i(b);
794
744
  }
795
745
  });
796
- return g.observe(n.current, { box: t }), () => {
797
- g.disconnect();
746
+ return _.observe(n.current, { box: t }), () => {
747
+ _.disconnect();
798
748
  };
799
- }, [t, n, c, a]), { width: u, height: r };
749
+ }, [t, n, u, a]), { width: o, height: r };
800
750
  }
801
- function J(e, n, t) {
751
+ function q(e, n, t) {
802
752
  return e[n] ? Array.isArray(e[n]) ? e[n][0][t] : (
803
753
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
804
754
  // @ts-ignore Support Firefox's non-standard behavior
805
755
  e[n][t]
806
756
  ) : n === "contentBoxSize" ? e.contentRect[t === "inlineSize" ? "width" : "height"] : void 0;
807
757
  }
808
- function dr() {
809
- const e = x(!1);
810
- return C(() => (e.current = !0, () => {
758
+ function cr() {
759
+ const e = $(!1);
760
+ return k(() => (e.current = !0, () => {
811
761
  e.current = !1;
812
762
  }), []), z(() => e.current, []);
813
763
  }
814
- const fr = ({ checked: e, onChange: n }) => {
815
- const t = x(null), a = x(null), [u, r] = y(void 0), [o, c] = y(!1), [i, s] = y(0), { height: g = 0 } = Z({ ref: a, round: !0 }), { height: l = 0 } = Z({ ref: t, round: !0 }), p = (l || 0) - g, f = g + p, d = p / 2, b = f / 2, h = typeof u == "number" && (e ? u < b : u > b);
764
+ const lr = ({ checked: e, onChange: n }) => {
765
+ const t = $(null), a = $(null), [o, r] = C(void 0), [i, u] = C(!1), [c, l] = C(0), { height: _ = 0 } = T({ ref: a, round: !0 }), { height: d = 0 } = T({ ref: t, round: !0 }), p = (d || 0) - _, g = _ + p, h = p / 2, m = g / 2, b = typeof o == "number" && (e ? o < m : o > m);
816
766
  return {
817
767
  trackRef: t,
818
768
  thumbRef: a,
819
- isDragging: o,
820
- bounds: { left: d, right: f },
821
- position: e ? f : d,
822
- onDrag: ({ x: E }) => {
823
- r(E), Math.abs((e ? f : d) - E) > 2 && c(!0);
769
+ isDragging: i,
770
+ bounds: { left: h, right: g },
771
+ position: e ? g : h,
772
+ onDrag: ({ x: w }) => {
773
+ r(w), Math.abs((e ? g : h) - w) > 2 && u(!0);
824
774
  },
825
775
  onStop: () => {
826
- c(!1), o && s(Date.now()), h && (n == null || n(!e));
776
+ u(!1), i && l(Date.now()), b && (n == null || n(!e));
827
777
  },
828
778
  onChangeWithDrag: () => {
829
- Date.now() - i > 50 && (n == null || n(!e)), r(void 0);
779
+ Date.now() - c > 50 && (n == null || n(!e)), r(void 0);
830
780
  }
831
781
  };
832
- }, P = {
782
+ }, S = {
833
783
  "purpur-toggle": "_purpur-toggle_1xng6_1",
834
784
  "purpur-toggle__track": "_purpur-toggle__track_1xng6_7",
835
785
  "purpur-toggle__checkmark-container": "_purpur-toggle__checkmark-container_1xng6_45",
@@ -839,67 +789,67 @@ const fr = ({ checked: e, onChange: n }) => {
839
789
  "purpur-toggle__label--right": "_purpur-toggle__label--right_1xng6_100",
840
790
  "purpur-toggle__label--left": "_purpur-toggle__label--left_1xng6_103",
841
791
  "purpur-toggle__container": "_purpur-toggle__container_1xng6_106"
842
- }, k = "purpur-toggle", hr = ({
792
+ }, x = "purpur-toggle", pr = ({
843
793
  ["data-testid"]: e,
844
794
  className: n,
845
795
  label: t,
846
796
  onChange: a,
847
- labelPosition: u = "right",
797
+ labelPosition: o = "right",
848
798
  checked: r,
849
- disableDrag: o,
850
- defaultChecked: c,
851
- ...i
852
- }, s) => {
853
- const [g, l] = y(
854
- typeof r == "boolean" ? r : !!c
855
- ), p = !!(typeof r == "boolean" ? r : g), { thumbRef: f, trackRef: d, isDragging: b, onChangeWithDrag: h, ...m } = fr({
799
+ disableDrag: i,
800
+ defaultChecked: u,
801
+ ...c
802
+ }, l) => {
803
+ const [_, d] = C(
804
+ typeof r == "boolean" ? r : !!u
805
+ ), p = !!(typeof r == "boolean" ? r : _), { thumbRef: g, trackRef: h, isDragging: m, onChangeWithDrag: b, ...v } = lr({
856
806
  checked: p,
857
- onChange: (D) => {
858
- i.disabled || (a == null || a(D), l(D));
807
+ onChange: (y) => {
808
+ c.disabled || (a == null || a(y), d(y));
859
809
  }
860
- }), v = () => /* @__PURE__ */ w(
810
+ }), R = () => /* @__PURE__ */ f(
861
811
  ze,
862
812
  {
863
- htmlFor: i.id,
813
+ htmlFor: c.id,
864
814
  "data-testid": e && `${e}-label`,
865
- disabled: i.disabled,
866
- className: I(
867
- P[`${k}__label`],
868
- P[`${k}__label--${u}`]
815
+ disabled: c.disabled,
816
+ className: O(
817
+ S[`${x}__label`],
818
+ S[`${x}__label--${o}`]
869
819
  ),
870
- children: /* @__PURE__ */ w(ne, { variant: "paragraph-100", disabled: i.disabled, children: t })
820
+ children: /* @__PURE__ */ f(Y, { variant: "paragraph-100", disabled: c.disabled, children: t })
871
821
  }
872
822
  );
873
- return /* @__PURE__ */ F("div", { className: I([n, P[`${k}__container`]]), children: [
874
- t && u === "left" && v(),
875
- /* @__PURE__ */ w(
876
- cr,
823
+ return /* @__PURE__ */ M("div", { className: O([n, S[`${x}__container`]]), children: [
824
+ t && o === "left" && R(),
825
+ /* @__PURE__ */ f(
826
+ or,
877
827
  {
878
- ...i,
879
- ref: s,
880
- id: i.id,
828
+ ...c,
829
+ ref: l,
830
+ id: c.id,
881
831
  "data-testid": e,
882
- className: P[k],
883
- onCheckedChange: h,
832
+ className: S[x],
833
+ onCheckedChange: b,
884
834
  checked: p,
885
- children: /* @__PURE__ */ F("span", { ref: d, className: P[`${k}__track`], children: [
886
- /* @__PURE__ */ w("span", { className: P[`${k}__checkmark-container`], children: /* @__PURE__ */ w(
887
- Y,
835
+ children: /* @__PURE__ */ M("span", { ref: h, className: S[`${x}__track`], children: [
836
+ /* @__PURE__ */ f("span", { className: S[`${x}__checkmark-container`], children: /* @__PURE__ */ f(
837
+ G,
888
838
  {
889
- className: P[`${k}__checkmark`],
890
- svg: we,
839
+ className: S[`${x}__checkmark`],
840
+ svg: Se,
891
841
  size: "xxs"
892
842
  }
893
843
  ) }),
894
- /* @__PURE__ */ w(pr, { disabled: o, ...m, children: /* @__PURE__ */ w(
895
- ir,
844
+ /* @__PURE__ */ f(sr, { disabled: i, ...v, children: /* @__PURE__ */ f(
845
+ ar,
896
846
  {
897
- ref: f,
847
+ ref: g,
898
848
  "data-testid": e && `${e}-thumb`,
899
- className: I([
900
- P[`${k}__thumb`],
849
+ className: O([
850
+ S[`${x}__thumb`],
901
851
  {
902
- [P[`${k}__thumb--dragging`]]: b
852
+ [S[`${x}__thumb--dragging`]]: m
903
853
  }
904
854
  ])
905
855
  }
@@ -907,11 +857,11 @@ const fr = ({ checked: e, onChange: n }) => {
907
857
  ] })
908
858
  }
909
859
  ),
910
- t && u === "right" && v()
860
+ t && o === "right" && R()
911
861
  ] });
912
- }, gr = S(hr);
913
- gr.displayName = "Toggle";
862
+ }, dr = de(pr);
863
+ dr.displayName = "Toggle";
914
864
  export {
915
- gr as Toggle
865
+ dr as Toggle
916
866
  };
917
867
  //# sourceMappingURL=toggle.es.js.map