qstd 0.1.0

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.
@@ -0,0 +1,3155 @@
1
+ require("./index.css");
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var React11 = require('react');
7
+ var reactDom = require('react-dom');
8
+ var framerMotion = require('framer-motion');
9
+ var react = require('@floating-ui/react');
10
+ var css = require('panda/css');
11
+ var reactSpinners = require('react-spinners');
12
+ var reactLoaderSpinner = require('react-loader-spinner');
13
+ var jsx = require('panda/jsx');
14
+ var jsxRuntime = require('react/jsx-runtime');
15
+ var nanoid = require('nanoid');
16
+ var mmb = require('music-metadata-browser');
17
+ var reactFontawesome = require('@fortawesome/react-fontawesome');
18
+ var fontawesomeSvgCore = require('@fortawesome/fontawesome-svg-core');
19
+ var freeRegularSvgIcons = require('@fortawesome/free-regular-svg-icons');
20
+ var freeBrandsSvgIcons = require('@fortawesome/free-brands-svg-icons');
21
+ var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
22
+ var useImmer = require('use-immer');
23
+
24
+ function _interopNamespace(e) {
25
+ if (e && e.__esModule) return e;
26
+ var n = Object.create(null);
27
+ if (e) {
28
+ Object.keys(e).forEach(function (k) {
29
+ if (k !== 'default') {
30
+ var d = Object.getOwnPropertyDescriptor(e, k);
31
+ Object.defineProperty(n, k, d.get ? d : {
32
+ enumerable: true,
33
+ get: function () { return e[k]; }
34
+ });
35
+ }
36
+ });
37
+ }
38
+ n.default = e;
39
+ return Object.freeze(n);
40
+ }
41
+
42
+ var React11__namespace = /*#__PURE__*/_interopNamespace(React11);
43
+ var mmb__namespace = /*#__PURE__*/_interopNamespace(mmb);
44
+
45
+ // src/react/index.ts
46
+ var base = jsx.styled("div", { base: { m: 0 } });
47
+ var tags = {
48
+ div: base,
49
+ a: jsx.styled("a"),
50
+ br: jsx.styled("br"),
51
+ button: jsx.styled("button"),
52
+ canvas: jsx.styled("canvas"),
53
+ form: jsx.styled("form"),
54
+ h1: jsx.styled("h1"),
55
+ h2: jsx.styled("h2"),
56
+ h3: jsx.styled("h3"),
57
+ hr: jsx.styled("hr"),
58
+ nav: jsx.styled("nav"),
59
+ main: jsx.styled("main"),
60
+ aside: jsx.styled("aside"),
61
+ article: jsx.styled("article"),
62
+ section: jsx.styled("section"),
63
+ details: jsx.styled("details"),
64
+ header: jsx.styled("header"),
65
+ footer: jsx.styled("footer"),
66
+ strong: jsx.styled("strong"),
67
+ em: jsx.styled("em"),
68
+ img: jsx.styled("img"),
69
+ del: jsx.styled("del"),
70
+ ins: jsx.styled("ins"),
71
+ kbd: jsx.styled("kbd"),
72
+ code: jsx.styled("code"),
73
+ mark: jsx.styled("mark"),
74
+ samp: jsx.styled("samp"),
75
+ small: jsx.styled("small"),
76
+ sub: jsx.styled("sub"),
77
+ sup: jsx.styled("sup"),
78
+ u: jsx.styled("u"),
79
+ var: jsx.styled("var"),
80
+ input: jsx.styled("input"),
81
+ label: jsx.styled("label"),
82
+ legend: jsx.styled("legend"),
83
+ p: jsx.styled("p"),
84
+ select: jsx.styled("select"),
85
+ span: jsx.styled("span"),
86
+ svg: jsx.styled("svg"),
87
+ textarea: jsx.styled("textarea"),
88
+ table: jsx.styled("table"),
89
+ tr: jsx.styled("tr"),
90
+ th: jsx.styled("th"),
91
+ td: jsx.styled("td"),
92
+ tbody: jsx.styled("tbody"),
93
+ thead: jsx.styled("thead"),
94
+ tfoot: jsx.styled("tfoot"),
95
+ progress: jsx.styled("progress"),
96
+ ol: jsx.styled("ol"),
97
+ ul: jsx.styled("ul"),
98
+ li: jsx.styled("li"),
99
+ blockquote: jsx.styled("blockquote"),
100
+ pre: jsx.styled("pre")
101
+ };
102
+ var motionTags = {
103
+ div: jsx.styled(framerMotion.motion.div, { base: { m: 0 } }),
104
+ a: jsx.styled(framerMotion.motion.a),
105
+ br: jsx.styled(framerMotion.motion.br),
106
+ button: jsx.styled(framerMotion.motion.button),
107
+ canvas: jsx.styled(framerMotion.motion.canvas),
108
+ form: jsx.styled(framerMotion.motion.form),
109
+ h1: jsx.styled(framerMotion.motion.h1),
110
+ h2: jsx.styled(framerMotion.motion.h2),
111
+ h3: jsx.styled(framerMotion.motion.h3),
112
+ hr: jsx.styled(framerMotion.motion.hr),
113
+ nav: jsx.styled(framerMotion.motion.nav),
114
+ main: jsx.styled(framerMotion.motion.main),
115
+ aside: jsx.styled(framerMotion.motion.aside),
116
+ article: jsx.styled(framerMotion.motion.article),
117
+ section: jsx.styled(framerMotion.motion.section),
118
+ details: jsx.styled(framerMotion.motion.details),
119
+ header: jsx.styled(framerMotion.motion.header),
120
+ footer: jsx.styled(framerMotion.motion.footer),
121
+ strong: jsx.styled(framerMotion.motion.strong),
122
+ em: jsx.styled(framerMotion.motion.em),
123
+ img: jsx.styled(framerMotion.motion.img),
124
+ del: jsx.styled(framerMotion.motion.del),
125
+ ins: jsx.styled(framerMotion.motion.ins),
126
+ kbd: jsx.styled(framerMotion.motion.kbd),
127
+ code: jsx.styled(framerMotion.motion.code),
128
+ mark: jsx.styled(framerMotion.motion.mark),
129
+ samp: jsx.styled(framerMotion.motion.samp),
130
+ small: jsx.styled(framerMotion.motion.small),
131
+ sub: jsx.styled(framerMotion.motion.sub),
132
+ sup: jsx.styled(framerMotion.motion.sup),
133
+ u: jsx.styled(framerMotion.motion.u),
134
+ var: jsx.styled(framerMotion.motion.var),
135
+ input: jsx.styled(framerMotion.motion.input),
136
+ label: jsx.styled(framerMotion.motion.label),
137
+ legend: jsx.styled(framerMotion.motion.legend),
138
+ p: jsx.styled(framerMotion.motion.p),
139
+ select: jsx.styled(framerMotion.motion.select),
140
+ span: jsx.styled(framerMotion.motion.span),
141
+ svg: jsx.styled(framerMotion.motion.svg),
142
+ textarea: jsx.styled(framerMotion.motion.textarea),
143
+ table: jsx.styled(framerMotion.motion.table),
144
+ tr: jsx.styled(framerMotion.motion.tr),
145
+ th: jsx.styled(framerMotion.motion.th),
146
+ td: jsx.styled(framerMotion.motion.td),
147
+ tbody: jsx.styled(framerMotion.motion.tbody),
148
+ thead: jsx.styled(framerMotion.motion.thead),
149
+ tfoot: jsx.styled(framerMotion.motion.tfoot),
150
+ progress: jsx.styled(framerMotion.motion.progress),
151
+ ol: jsx.styled(framerMotion.motion.ol),
152
+ ul: jsx.styled(framerMotion.motion.ul),
153
+ li: jsx.styled(framerMotion.motion.li),
154
+ blockquote: jsx.styled(framerMotion.motion.blockquote),
155
+ pre: jsx.styled(framerMotion.motion.pre)
156
+ };
157
+ var loadingIconsMap = {
158
+ rotatingLines: reactLoaderSpinner.RotatingLines,
159
+ spinner: reactLoaderSpinner.TailSpin,
160
+ beat: reactSpinners.BeatLoader,
161
+ dots: reactLoaderSpinner.ThreeDots,
162
+ oval: reactLoaderSpinner.Oval
163
+ };
164
+ var loadingIcons = Object.keys(loadingIconsMap);
165
+ var Div = tags.div;
166
+ var MotionDiv = motionTags.div;
167
+ function MenuContainer(props) {
168
+ const { children, ...rest } = props;
169
+ return /* @__PURE__ */ jsxRuntime.jsx(Div, { ...rest, role: "menu", "data-menu-container": true, children });
170
+ }
171
+ function Menu(props) {
172
+ const {
173
+ variant = "click",
174
+ isOpen: isOpenControlled,
175
+ children,
176
+ trigger,
177
+ ...rest
178
+ } = props;
179
+ const hoverTimeoutRef = React11__namespace.default.useRef(null);
180
+ const [isOpen, setOpen] = React11__namespace.default.useState(isOpenControlled ?? false);
181
+ const onOpenChange = (open) => {
182
+ const newOpenState = typeof open === "function" ? open(isOpen) : open;
183
+ props.onOpenOrClose?.(newOpenState);
184
+ setOpen(newOpenState);
185
+ };
186
+ React11__namespace.default.useEffect(() => {
187
+ if (typeof isOpenControlled !== "boolean") return;
188
+ setOpen(isOpenControlled);
189
+ }, [isOpenControlled]);
190
+ const {
191
+ refs,
192
+ x,
193
+ y,
194
+ middlewareData: { hide: hideData },
195
+ context: floatingContext
196
+ } = react.useFloating({
197
+ placement: props.placement ?? "bottom-start",
198
+ whileElementsMounted: react.autoUpdate,
199
+ open: isOpen,
200
+ onOpenChange,
201
+ middleware: [
202
+ react.offset({ crossAxis: props.offset?.x, mainAxis: props.offset?.y }),
203
+ react.flip({ fallbackPlacements: ["top-end"] }),
204
+ react.shift({ padding: 5 }),
205
+ react.hide({ strategy: "referenceHidden" })
206
+ ]
207
+ });
208
+ const openMenu = () => {
209
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
210
+ hoverTimeoutRef.current = null;
211
+ onOpenChange(true);
212
+ };
213
+ const closeMenuHover = () => {
214
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
215
+ hoverTimeoutRef.current = setTimeout(
216
+ () => onOpenChange(false),
217
+ props.hoverDelay ?? 150
218
+ );
219
+ };
220
+ const closeMenuImmediate = () => {
221
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
222
+ hoverTimeoutRef.current = null;
223
+ onOpenChange(false);
224
+ };
225
+ const handleTriggerClick = () => {
226
+ if (variant === "click") onOpenChange((prev) => !prev);
227
+ };
228
+ const handleTriggerMouseEnter = () => {
229
+ if (variant === "hover") {
230
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
231
+ hoverTimeoutRef.current = setTimeout(() => {
232
+ openMenu();
233
+ }, props.hoverDelay ?? 250);
234
+ }
235
+ };
236
+ const handleTriggerMouseLeave = () => {
237
+ if (variant === "hover") {
238
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
239
+ closeMenuHover();
240
+ }
241
+ };
242
+ const handleMenuMouseEnter = () => {
243
+ if (variant === "hover") openMenu();
244
+ };
245
+ const handleMenuMouseLeave = () => {
246
+ if (variant === "hover") closeMenuHover();
247
+ };
248
+ useOutsideClick(
249
+ refs.floating,
250
+ (event) => {
251
+ const referenceElement = refs.reference.current;
252
+ if (isOpen && referenceElement instanceof Element && !referenceElement.contains(event.target)) {
253
+ closeMenuImmediate();
254
+ }
255
+ },
256
+ isOpen
257
+ );
258
+ React11__namespace.default.useEffect(() => {
259
+ if (!hideData?.referenceHidden) return;
260
+ closeMenuImmediate();
261
+ }, [hideData, closeMenuImmediate]);
262
+ React11__namespace.default.useEffect(() => {
263
+ return () => {
264
+ if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
265
+ };
266
+ }, []);
267
+ const menuVariants = {
268
+ hidden: {
269
+ opacity: 0,
270
+ scale: 0.9,
271
+ transition: { duration: 0.1, ease: "easeOut" }
272
+ },
273
+ visible: {
274
+ opacity: 1,
275
+ scale: 1,
276
+ transition: { duration: 0.15, ease: "easeIn" }
277
+ }
278
+ };
279
+ const triggerEventProps = variant === "hover" ? {
280
+ onMouseEnter: handleTriggerMouseEnter,
281
+ onMouseLeave: handleTriggerMouseLeave
282
+ } : { onClick: handleTriggerClick };
283
+ const menuEventProps = variant === "hover" ? {
284
+ onMouseEnter: handleMenuMouseEnter,
285
+ onMouseLeave: handleMenuMouseLeave
286
+ } : {};
287
+ const transformOrigin = floatingContext.placement.startsWith("top") ? "bottom left" : "top left";
288
+ const childArray = React11__namespace.default.Children.toArray(children);
289
+ let customContainerEl = null;
290
+ for (const c of childArray) {
291
+ if (React11__namespace.default.isValidElement(c)) {
292
+ const anyType = c.type;
293
+ if (c.props?.["data-menu-container"] || anyType?.isBlockMenuContainer) {
294
+ customContainerEl = c;
295
+ break;
296
+ }
297
+ }
298
+ }
299
+ let floatingLayer = null;
300
+ if (customContainerEl) {
301
+ const childProps = customContainerEl.props || {};
302
+ const { style: restStyle, ...restPanda } = rest || {};
303
+ const defaultStyles = {};
304
+ if (childProps.borderRadius === void 0 && childProps.rounded === void 0 && childProps.style?.borderRadius === void 0)
305
+ defaultStyles.borderRadius = "md";
306
+ if (childProps.shadow === void 0 && childProps.boxShadow === void 0 && childProps.style?.boxShadow === void 0)
307
+ defaultStyles.shadow = "lg";
308
+ if (childProps.bg === void 0 && childProps.background === void 0 && !(childProps.style?.background || childProps.style?.backgroundColor))
309
+ defaultStyles.bg = { base: "neutral.100", _dark: "neutral.900" };
310
+ if (childProps.overflow === void 0 && childProps.style?.overflow === void 0)
311
+ defaultStyles.overflow = "hidden";
312
+ if (childProps.outline === void 0 && childProps.style?.outline === void 0)
313
+ defaultStyles.outline = "none";
314
+ const defaultsClassName = Object.keys(defaultStyles).length > 0 ? css.css(defaultStyles) : "";
315
+ const mergedStyle = {
316
+ ...childProps.style || {},
317
+ ...restStyle || {}
318
+ };
319
+ const mergedClassName = [defaultsClassName, childProps.className].filter(Boolean).join(" ");
320
+ const contentNode = React11__namespace.default.cloneElement(
321
+ customContainerEl,
322
+ {
323
+ // Defaults are now in mergedClassName via css()
324
+ // Then Panda props coming from the parent <Block is="menu" ...>
325
+ ...restPanda,
326
+ // Finally explicit props on the provided container win
327
+ ...childProps,
328
+ // Apply merged className
329
+ className: mergedClassName,
330
+ // Apply menu event props to the actual container
331
+ ...menuEventProps,
332
+ role: childProps.role ?? "menu",
333
+ "aria-orientation": childProps["aria-orientation"] ?? "vertical",
334
+ css: {
335
+ ...restPanda.css || {},
336
+ ...childProps.css || {},
337
+ ring: (childProps.css && childProps.css.ring) ?? (restPanda.css && restPanda.css.ring) ?? "1px solid rgba(208, 58, 58, 0.05)"
338
+ },
339
+ style: mergedStyle
340
+ },
341
+ childProps.children
342
+ );
343
+ floatingLayer = /* @__PURE__ */ jsxRuntime.jsx(
344
+ MotionDiv,
345
+ {
346
+ zIndex: props.zIndex,
347
+ ref: refs.setFloating,
348
+ onClick: (e) => e.stopPropagation(),
349
+ style: { position: "absolute", top: y, left: x, transformOrigin },
350
+ variants: menuVariants,
351
+ initial: "hidden",
352
+ animate: "visible",
353
+ exit: "hidden",
354
+ children: contentNode
355
+ }
356
+ );
357
+ } else {
358
+ const { style: restStyle, ...restPanda } = rest || {};
359
+ const container = /* @__PURE__ */ jsxRuntime.jsx(
360
+ MenuContainer,
361
+ {
362
+ role: "menu",
363
+ "aria-orientation": "vertical",
364
+ borderRadius: "md",
365
+ shadow: "lg",
366
+ bg: { base: "neutral.100", _dark: "neutral.900" },
367
+ overflow: "hidden",
368
+ outline: "none",
369
+ css: { ring: "1px solid rgba(208, 58, 58, 0.05)" },
370
+ ...restPanda,
371
+ ...menuEventProps,
372
+ style: { ...restStyle || {} },
373
+ children
374
+ }
375
+ );
376
+ floatingLayer = /* @__PURE__ */ jsxRuntime.jsx(
377
+ MotionDiv,
378
+ {
379
+ zIndex: props.zIndex,
380
+ ref: refs.setFloating,
381
+ onClick: (e) => e.stopPropagation(),
382
+ style: { position: "absolute", top: y, left: x, transformOrigin },
383
+ variants: menuVariants,
384
+ initial: "hidden",
385
+ animate: "visible",
386
+ exit: "hidden",
387
+ children: container
388
+ }
389
+ );
390
+ }
391
+ return /* @__PURE__ */ jsxRuntime.jsxs(
392
+ Div,
393
+ {
394
+ ref: refs.setReference,
395
+ h: "max-content",
396
+ style: { width: props.width || "max-content" },
397
+ ...triggerEventProps,
398
+ children: [
399
+ trigger,
400
+ /* @__PURE__ */ jsxRuntime.jsx(react.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: isOpen && floatingLayer }) })
401
+ ]
402
+ }
403
+ );
404
+ }
405
+ function useOutsideClick(ref, handler, enabled = true) {
406
+ React11__namespace.default.useEffect(() => {
407
+ if (!enabled) return;
408
+ const listener = (event) => {
409
+ if (!ref.current || ref.current.contains(event.target)) {
410
+ return;
411
+ }
412
+ handler(event);
413
+ };
414
+ document.addEventListener("mousedown", listener);
415
+ document.addEventListener("touchstart", listener);
416
+ return () => {
417
+ document.removeEventListener("mousedown", listener);
418
+ document.removeEventListener("touchstart", listener);
419
+ };
420
+ }, [ref, handler, enabled]);
421
+ }
422
+ var extractImageMetadata = (f) => {
423
+ return new Promise((res, rej) => {
424
+ if (!f) rej("No image file provided.");
425
+ const ext = f.type.split("/").pop();
426
+ const id = `${ext}_${nanoid.nanoid()}.${ext}`;
427
+ const preview = URL.createObjectURL(f);
428
+ const image = new Image();
429
+ image.onload = () => {
430
+ const { height, width } = image;
431
+ let orientation = "";
432
+ if (height === width) orientation = "square";
433
+ else if (height > width) orientation = "portrait";
434
+ else orientation = "landscape";
435
+ res({ id, preview, orientation, height, width });
436
+ };
437
+ image.onerror = (e, x, y, z, a) => {
438
+ if (ext?.includes("tif")) {
439
+ const { height, width } = image;
440
+ let orientation = "";
441
+ if (height === width) orientation = "square";
442
+ else if (height > width) orientation = "portrait";
443
+ else orientation = "landscape";
444
+ res({ id, preview, orientation, height, width });
445
+ } else {
446
+ console.log("image error");
447
+ rej("Image failed to load.");
448
+ }
449
+ };
450
+ image.src = preview;
451
+ });
452
+ };
453
+ var extractAudioMetadata = async (f) => {
454
+ const meta = await mmb__namespace.parseBlob(f, { duration: true });
455
+ return new Promise((res, rej) => {
456
+ if (!f) rej("No audio file provided.");
457
+ const ext = f.name.split(".").pop();
458
+ const id = `${ext}_${nanoid.nanoid()}.${ext}`;
459
+ const [cover] = meta.common.picture ?? [];
460
+ const preview = URL.createObjectURL(
461
+ new Blob([cover.data], { type: cover.format })
462
+ );
463
+ const audioMetadata = {
464
+ id,
465
+ preview,
466
+ source: { ...meta.format, ...meta.common }
467
+ };
468
+ res(audioMetadata);
469
+ });
470
+ };
471
+ var extractVideoMetadata = (f) => {
472
+ return new Promise((res, rej) => {
473
+ if (!f) rej("No video file provided.");
474
+ const ext = f.type.split("/").pop();
475
+ const id = `${ext}_${nanoid.nanoid()}.${ext}`;
476
+ const video = document.createElement("video");
477
+ video.addEventListener("loadedmetadata", () => {
478
+ const height = video.videoHeight;
479
+ const width = video.videoWidth;
480
+ const duration = video.duration;
481
+ let orientation = "";
482
+ if (height === width) orientation = "square";
483
+ else if (height > width) orientation = "portrait";
484
+ else orientation = "landscape";
485
+ res({ id, orientation, duration, height, width });
486
+ });
487
+ video.src = URL.createObjectURL(f);
488
+ });
489
+ };
490
+ var prepareFiles = async (acceptedFiles) => {
491
+ return Promise.all(
492
+ acceptedFiles.map(async (f) => {
493
+ if (f.type.startsWith("image")) {
494
+ const metadata = await extractImageMetadata(f);
495
+ return Object.assign(f, metadata);
496
+ } else if (f.type.startsWith("audio")) {
497
+ const metadata = await extractAudioMetadata(f);
498
+ return Object.assign(f, metadata);
499
+ } else if (f.type.startsWith("video")) {
500
+ const metadata = await extractVideoMetadata(f);
501
+ return Object.assign(f, metadata);
502
+ } else {
503
+ const ext = f.type.split("/").pop();
504
+ const id = `${ext}_${nanoid.nanoid()}.${ext}`;
505
+ const metadata = { id };
506
+ return Object.assign(f, metadata);
507
+ }
508
+ })
509
+ );
510
+ };
511
+ var findChildrenByDisplayName = (children, displayName2) => {
512
+ return React11__namespace.default.Children.toArray(children).find(
513
+ (child) => {
514
+ if (React11__namespace.default.isValidElement(child)) {
515
+ const childType = child.type;
516
+ return childType.displayName === displayName2;
517
+ } else {
518
+ return false;
519
+ }
520
+ }
521
+ );
522
+ };
523
+ var extractElType = (is, props) => {
524
+ let el = "div";
525
+ if (is === "txt") el = "p";
526
+ else if (is === "hr") el = "hr";
527
+ else if (is === "btn") el = "button";
528
+ else if (is === "link") el = "button";
529
+ else if (is === "img") el = "img";
530
+ else if (is === "input") el = "input";
531
+ else if (is === "accordion") el = "div";
532
+ else if (is === "textarea") el = "textarea";
533
+ else if (is === "checkbox") el = "button";
534
+ else if (is === "radio") el = "div";
535
+ else if (is === "skeleton") el = "div";
536
+ else if (is === "switch") el = "button";
537
+ else if (is === "select") el = "select";
538
+ else if (is === "blockquote") el = "blockquote";
539
+ else if (is === "pre") el = "pre";
540
+ else if (is === "progress") el = "progress";
541
+ else if (is === "drawer") el = "div";
542
+ else if (is === "menu") el = "div";
543
+ else if (is === "form") el = "form";
544
+ else if (is === "table") el = "table";
545
+ else if (is === "list") el = "ul";
546
+ else if (is === "seo") el = "section";
547
+ else el = "div";
548
+ const isHr = is === "hr";
549
+ const isLink = is === "link";
550
+ const isMenu = is === "menu";
551
+ const isInput = is === "input";
552
+ const isRadio = is === "radio";
553
+ const isDrawer = is === "drawer";
554
+ const isSwitch = is === "switch";
555
+ const isSkeleton = is === "skeleton";
556
+ const isCheckbox = is === "checkbox";
557
+ const isTextarea = is === "textarea";
558
+ const isProgress = is === "progress";
559
+ const isAccordion = is === "accordion";
560
+ const isBtnLike = is === "btn" || is === "link";
561
+ const filepickerAllowed = !is && props.filepicker || is && (is === "txt" || is === "btn" || is === "link" || is === "img") && props.filepicker;
562
+ return {
563
+ el,
564
+ is,
565
+ isMenu,
566
+ isLink,
567
+ isInput,
568
+ isRadio,
569
+ isSwitch,
570
+ isBtnLike,
571
+ isAccordion,
572
+ filepickerAllowed,
573
+ isTextarea,
574
+ isCheckbox,
575
+ isSkeleton,
576
+ isProgress,
577
+ isDrawer,
578
+ isHr
579
+ };
580
+ };
581
+ var extractElAndStyles = (extract, anyProps) => {
582
+ const {
583
+ _motion,
584
+ layout,
585
+ initial,
586
+ animate,
587
+ exit,
588
+ whileTap,
589
+ whileHover,
590
+ whileFocus,
591
+ transition,
592
+ variants,
593
+ ...rest
594
+ } = anyProps;
595
+ const StdComp = tags[extract.el] || tags.div;
596
+ const MotionComp = motionTags[extract.el] || motionTags.div;
597
+ const hasMotionProps = layout !== void 0 || initial !== void 0 || animate !== void 0 || exit !== void 0 || whileHover !== void 0 || whileTap !== void 0 || whileFocus !== void 0 || variants !== void 0 || transition !== void 0;
598
+ const comp = hasMotionProps ? MotionComp : StdComp;
599
+ const motionProps = hasMotionProps ? {
600
+ layout,
601
+ initial,
602
+ animate,
603
+ exit,
604
+ whileHover,
605
+ whileTap,
606
+ whileFocus,
607
+ variants,
608
+ transition
609
+ } : void 0;
610
+ const remaining = omit(rest, ["loadingPosition", "loadingIcon", "isLoading"]);
611
+ const cursor = anyProps.isLoading ? "not-allowed" : "pointer";
612
+ const btnClassName = extract.is === "btn" ? css.css({ display: "flex", alignI: "center", cursor }) : "";
613
+ const linkClassName = extract.isLink ? css.css({
614
+ color: { base: "blue.500", _dark: "blue.400" },
615
+ _hover: { textDecoration: "underline" },
616
+ cursor
617
+ }) : "";
618
+ const mergedClassName = [btnClassName, linkClassName, anyProps.className].filter(Boolean).join(" ");
619
+ return [
620
+ comp,
621
+ {
622
+ ...motionProps,
623
+ ...remaining,
624
+ className: mergedClassName
625
+ }
626
+ ];
627
+ };
628
+ function getIcon(position, Icon2, props) {
629
+ const {
630
+ loadingIcon,
631
+ iconPrefix = "solid",
632
+ loadingPosition = "start",
633
+ loadingIconSize,
634
+ isLoading,
635
+ _loading,
636
+ strokeColor,
637
+ strokeWidth
638
+ } = props;
639
+ const prefix = iconPrefix === "solid" ? "fas" : iconPrefix === "regular" ? "far" : "fab";
640
+ if (isLoading && position === loadingPosition) {
641
+ const chosen = Icon2 ?? loadingIcon ?? null;
642
+ if (chosen) {
643
+ if (typeof chosen === "string" && loadingIcons.includes(chosen)) {
644
+ const Cmp = loadingIconsMap[chosen];
645
+ const sizePx = typeof loadingIconSize === "number" ? `${loadingIconSize}px` : "12px";
646
+ return Cmp({ width: sizePx, height: sizePx });
647
+ } else if (React11__namespace.default.isValidElement(chosen)) {
648
+ return chosen;
649
+ } else if (typeof chosen === "function") {
650
+ return chosen();
651
+ } else if (chosen?.iconName) {
652
+ return /* @__PURE__ */ jsxRuntime.jsx(
653
+ reactFontawesome.FontAwesomeIcon,
654
+ {
655
+ icon: chosen,
656
+ className: props.className,
657
+ spinPulse: props.pulse,
658
+ size: props.size,
659
+ spin: props.spin
660
+ }
661
+ );
662
+ }
663
+ }
664
+ const widthPx = typeof loadingIconSize === "number" ? `${loadingIconSize}px` : "12px";
665
+ const resolvedStrokeWidth = _loading?.strokeWidth ?? strokeWidth ?? 4;
666
+ const resolvedStrokeColor = typeof _loading?.strokeColor === "string" && _loading.strokeColor || typeof strokeColor === "string" && strokeColor || "var(--colors-neutral-200)";
667
+ return /* @__PURE__ */ jsxRuntime.jsx(
668
+ reactLoaderSpinner.RotatingLines,
669
+ {
670
+ strokeWidth: `${resolvedStrokeWidth}`,
671
+ strokeColor: resolvedStrokeColor,
672
+ width: widthPx
673
+ }
674
+ );
675
+ }
676
+ if (!Icon2) return null;
677
+ else if (typeof Icon2 === "string") {
678
+ return /* @__PURE__ */ jsxRuntime.jsx(
679
+ reactFontawesome.FontAwesomeIcon,
680
+ {
681
+ icon: { prefix, iconName: Icon2 },
682
+ className: props.className,
683
+ spinPulse: props.pulse,
684
+ size: props.size,
685
+ spin: props.spin
686
+ }
687
+ );
688
+ } else if ("iconName" in Icon2) {
689
+ return /* @__PURE__ */ jsxRuntime.jsx(
690
+ reactFontawesome.FontAwesomeIcon,
691
+ {
692
+ icon: Icon2,
693
+ className: props.className,
694
+ spinPulse: props.pulse,
695
+ size: props.size,
696
+ spin: props.spin
697
+ }
698
+ );
699
+ } else if (typeof Icon2 === "function") {
700
+ return Icon2(props);
701
+ } else return Icon2;
702
+ }
703
+ var getIcons = (extract, anyProps) => {
704
+ const { icon, startIcon, endIcon } = anyProps;
705
+ let isLoading;
706
+ let loadingIcon;
707
+ let loadingPosition;
708
+ if (extract.isBtnLike) {
709
+ const loadingProps = anyProps;
710
+ loadingPosition = loadingProps.loadingPosition;
711
+ loadingIcon = loadingProps.loadingIcon;
712
+ isLoading = loadingProps.isLoading;
713
+ }
714
+ const leftArg = isLoading && loadingPosition === "start" ? loadingIcon ?? null : icon ?? startIcon;
715
+ const rightArg = isLoading && loadingPosition === "end" ? loadingIcon ?? null : endIcon ?? null;
716
+ const leftIcon = getIcon("start", leftArg, anyProps);
717
+ const rightIcon = getIcon("end", rightArg, anyProps);
718
+ return { leftIcon, rightIcon };
719
+ };
720
+ var omit = (obj, keys) => {
721
+ const result = {};
722
+ if (keys.length === 0) {
723
+ for (const k in obj) {
724
+ if (Object.prototype.hasOwnProperty.call(obj, k)) {
725
+ result[k] = obj[k];
726
+ }
727
+ }
728
+ return result;
729
+ }
730
+ const skip = new Set(keys);
731
+ for (const k in obj) {
732
+ if (!Object.prototype.hasOwnProperty.call(obj, k)) continue;
733
+ if (!skip.has(k)) {
734
+ result[k] = obj[k];
735
+ }
736
+ }
737
+ return result;
738
+ };
739
+ var TrackNameKey = "Track";
740
+ var ThumbNameKey = "Thumb";
741
+ var Button = motionTags.button;
742
+ var Base = motionTags.div;
743
+ var SwitchContext = React11__namespace.default.createContext(null);
744
+ var useSwitchContext = () => {
745
+ const context = React11__namespace.default.useContext(SwitchContext);
746
+ if (!context) {
747
+ throw new Error("Switch compound components must be used within Switch");
748
+ }
749
+ return context;
750
+ };
751
+ function Switch(props) {
752
+ const {
753
+ checked = false,
754
+ disabled = false,
755
+ thumbSize = 20,
756
+ onChange,
757
+ children,
758
+ _motion,
759
+ ...rest
760
+ } = props;
761
+ const [x, setX] = React11__namespace.default.useState(0);
762
+ const [pressed, setPressed] = React11__namespace.default.useState(false);
763
+ const [growThumb, setGrowThumb] = React11__namespace.default.useState(false);
764
+ const borderWidth = 4;
765
+ const trackWidth = thumbSize * 1.5;
766
+ const borderRadius = thumbSize * 2.5;
767
+ const xWhileOn = thumbSize;
768
+ const checkedPosition = xWhileOn * 0.5;
769
+ const stopwatch = useStopwatch();
770
+ React11__namespace.default.useEffect(() => {
771
+ if (pressed && !disabled) {
772
+ stopwatch.start();
773
+ } else {
774
+ setGrowThumb(false);
775
+ stopwatch.clear();
776
+ }
777
+ }, [pressed, disabled]);
778
+ React11__namespace.default.useEffect(() => {
779
+ if (stopwatch.time > 200) {
780
+ setGrowThumb(true);
781
+ }
782
+ }, [stopwatch.time]);
783
+ React11__namespace.default.useEffect(() => {
784
+ setX(checked ? checkedPosition : 0);
785
+ }, [checked, checkedPosition]);
786
+ const toggle = () => {
787
+ if (disabled) return;
788
+ if (growThumb) {
789
+ setGrowThumb(false);
790
+ setPressed(false);
791
+ setTimeout(() => {
792
+ const isOff = x === 0;
793
+ setX(isOff ? checkedPosition : 0);
794
+ onChange?.(isOff);
795
+ }, 50);
796
+ } else {
797
+ const isOff = x === 0;
798
+ setX(isOff ? checkedPosition : 0);
799
+ onChange?.(isOff);
800
+ }
801
+ };
802
+ const handlePointerDown = () => {
803
+ if (disabled) return;
804
+ setPressed(true);
805
+ };
806
+ const handlePointerUp = () => setPressed(false);
807
+ const handleKeyDown = (event) => {
808
+ if (disabled) return;
809
+ if (event.code === "Space" || event.key === " ") {
810
+ event.preventDefault();
811
+ if (!pressed) {
812
+ setPressed(true);
813
+ }
814
+ }
815
+ };
816
+ const handleKeyUp = (event) => {
817
+ if (disabled) return;
818
+ if (event.code === "Space" || event.key === " ") {
819
+ event.preventDefault();
820
+ if (pressed) {
821
+ toggle();
822
+ }
823
+ setPressed(false);
824
+ }
825
+ };
826
+ const contextValue = {
827
+ checked,
828
+ disabled,
829
+ pressed,
830
+ growThumb,
831
+ thumbSize,
832
+ trackWidth,
833
+ thumbOffset: x,
834
+ // Use actual x position for animations
835
+ borderRadius,
836
+ borderWidth,
837
+ setPressed,
838
+ toggle
839
+ };
840
+ const track = findChildrenByDisplayName(
841
+ children,
842
+ TrackNameKey
843
+ );
844
+ const thumb = findChildrenByDisplayName(
845
+ children,
846
+ ThumbNameKey
847
+ );
848
+ const trackElement = track ? React11__namespace.default.cloneElement(track, {
849
+ _motion,
850
+ children: thumb ? React11__namespace.default.cloneElement(thumb, { _motion }) : /* @__PURE__ */ jsxRuntime.jsx(Thumb, { _motion })
851
+ }) : /* @__PURE__ */ jsxRuntime.jsx(Track, { _motion, children: thumb ? React11__namespace.default.cloneElement(thumb, { _motion }) : /* @__PURE__ */ jsxRuntime.jsx(Thumb, { _motion }) });
852
+ return /* @__PURE__ */ jsxRuntime.jsx(SwitchContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsxRuntime.jsx(
853
+ Button,
854
+ {
855
+ flex: true,
856
+ alignItems: "center",
857
+ justifyContent: "center",
858
+ m: 0,
859
+ px: 1,
860
+ py: 1,
861
+ h: "fit-content",
862
+ outlineOffset: 1,
863
+ initial: false,
864
+ animate: {
865
+ outlineOffset: pressed ? "-2px" : "0px",
866
+ transition: { duration: 0.1, ease: "linear" }
867
+ },
868
+ cursor: disabled ? "not-allowed" : "pointer",
869
+ _hover: { bg: "none!" },
870
+ _active: {
871
+ bg: "none",
872
+ transform: "none!",
873
+ scale: "none!"
874
+ // Disable any button press effects that might shrink the toggle
875
+ },
876
+ background: "none",
877
+ style: { borderRadius },
878
+ onClick: toggle,
879
+ onPointerDown: handlePointerDown,
880
+ onPointerUp: handlePointerUp,
881
+ onPointerLeave: handlePointerUp,
882
+ onTouchStart: handlePointerDown,
883
+ onTouchEnd: handlePointerUp,
884
+ onKeyDown: handleKeyDown,
885
+ onKeyUp: handleKeyUp,
886
+ disabled,
887
+ ...rest,
888
+ children: /* @__PURE__ */ jsxRuntime.jsx(
889
+ Base,
890
+ {
891
+ flex: true,
892
+ flexDirection: "column",
893
+ justifyContent: "center",
894
+ alignItems: "center",
895
+ boxSizing: "border-box",
896
+ children: trackElement
897
+ }
898
+ )
899
+ }
900
+ ) }) });
901
+ }
902
+ function Track(props) {
903
+ const { _motion, children, ...rest } = props;
904
+ const {
905
+ checked,
906
+ trackWidth,
907
+ thumbSize,
908
+ borderWidth,
909
+ borderRadius: toggleBorderRadius
910
+ } = useSwitchContext();
911
+ const defaultBg = checked ? "#60a5fa !important" : "#d1d5db !important";
912
+ return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsxRuntime.jsx(
913
+ Base,
914
+ {
915
+ flex: true,
916
+ relative: true,
917
+ alignItems: "center",
918
+ justifyContent: "flex-start",
919
+ boxSizing: "content-box",
920
+ cursor: "pointer",
921
+ bg: defaultBg,
922
+ transition: "background-color 0.2s ease-in-out",
923
+ style: {
924
+ minHeight: thumbSize,
925
+ width: trackWidth,
926
+ border: `${borderWidth}px solid transparent`,
927
+ borderRadius: toggleBorderRadius
928
+ },
929
+ ...rest,
930
+ children
931
+ }
932
+ ) });
933
+ }
934
+ function Thumb(props) {
935
+ const { _motion, ...rest } = props;
936
+ const {
937
+ pressed,
938
+ growThumb,
939
+ thumbSize,
940
+ thumbOffset,
941
+ borderRadius: toggleBorderRadius
942
+ } = useSwitchContext();
943
+ const thumbWidth = thumbSize + (pressed && growThumb ? thumbSize * 0.2 : 0);
944
+ const shouldUseRightAnchor = thumbOffset && growThumb;
945
+ return /* @__PURE__ */ jsxRuntime.jsx(
946
+ framerMotion.MotionConfig,
947
+ {
948
+ transition: _motion || { type: "spring", stiffness: 700, damping: 30 },
949
+ children: /* @__PURE__ */ jsxRuntime.jsx(
950
+ Base,
951
+ {
952
+ grid: true,
953
+ bg: "white",
954
+ style: {
955
+ height: thumbSize,
956
+ // width: thumbWidth,
957
+ borderRadius: toggleBorderRadius,
958
+ transition: "background-color 0.2s ease-in-out"
959
+ },
960
+ animate: {
961
+ // Always use consistent x positioning - no switching
962
+ x: thumbOffset,
963
+ width: thumbWidth,
964
+ // Use negative margin to create left-directional growth when ON
965
+ marginLeft: shouldUseRightAnchor ? -(thumbWidth - thumbSize) : 0
966
+ },
967
+ ...rest
968
+ }
969
+ )
970
+ }
971
+ );
972
+ }
973
+ Track.displayName = TrackNameKey;
974
+ Thumb.displayName = ThumbNameKey;
975
+ function useStopwatch(props = {}) {
976
+ const [active, setActive] = React11__namespace.default.useState(false);
977
+ const [time, setTime] = React11__namespace.default.useState(0);
978
+ const timeInterval = props?.interval ?? 10;
979
+ React11__namespace.default.useEffect(() => {
980
+ let interval = null;
981
+ if (active) {
982
+ interval = setInterval(() => {
983
+ setTime((prevTime) => prevTime + timeInterval);
984
+ }, timeInterval);
985
+ } else {
986
+ clearInterval(interval);
987
+ }
988
+ return () => clearInterval(interval);
989
+ }, [active, timeInterval]);
990
+ const start = () => setActive(true);
991
+ const stop = () => setActive(false);
992
+ const clear = () => {
993
+ setActive(false);
994
+ setTime(0);
995
+ };
996
+ return { time, start, stop, clear };
997
+ }
998
+ var switch_default = Switch;
999
+ var RadioContext = React11__namespace.default.createContext(null);
1000
+ var Base2 = base;
1001
+ var MotionDiv2 = motionTags.div;
1002
+ function Radio(props) {
1003
+ const {
1004
+ value: controlledValue,
1005
+ defaultValue = null,
1006
+ disabled,
1007
+ onChange,
1008
+ name,
1009
+ options,
1010
+ renderOption,
1011
+ onKeyDown: onKeyDownProp,
1012
+ ...rest
1013
+ } = props;
1014
+ const groupId = React11__namespace.default.useId();
1015
+ const isControlled = controlledValue !== void 0;
1016
+ const [uncontrolled, setUncontrolled] = React11__namespace.default.useState(
1017
+ defaultValue
1018
+ );
1019
+ const selectedValue = isControlled ? controlledValue : uncontrolled;
1020
+ const itemsRef = React11__namespace.default.useRef([]);
1021
+ const [activeId, setActiveId] = React11__namespace.default.useState("");
1022
+ const setSelectedValue = (val) => {
1023
+ if (!isControlled) setUncontrolled(val);
1024
+ onChange?.(val);
1025
+ };
1026
+ const registerItem = (entry) => {
1027
+ const exists = itemsRef.current.find((x) => x.id === entry.id);
1028
+ if (exists) {
1029
+ exists.value = entry.value;
1030
+ exists.disabled = entry.disabled;
1031
+ exists.ref = entry.ref;
1032
+ } else {
1033
+ itemsRef.current.push(entry);
1034
+ }
1035
+ if (!activeId) {
1036
+ const selected = selectedValue ? itemsRef.current.find((x) => x.value === selectedValue) : void 0;
1037
+ const firstEnabled = itemsRef.current.find((x) => !x.disabled);
1038
+ const initial = (selected || firstEnabled)?.id;
1039
+ if (initial) setActiveId(initial);
1040
+ }
1041
+ };
1042
+ const unregisterItem = (id) => {
1043
+ itemsRef.current = itemsRef.current.filter((x) => x.id !== id);
1044
+ if (activeId === id) {
1045
+ const firstEnabled = itemsRef.current.find((x) => !x.disabled);
1046
+ if (firstEnabled) setActiveId(firstEnabled.id);
1047
+ else setActiveId("");
1048
+ }
1049
+ };
1050
+ const getIndexById = (id) => itemsRef.current.findIndex((x) => x.id === id);
1051
+ const moveActive = (delta) => {
1052
+ if (!itemsRef.current.length) return;
1053
+ const currentIndex = getIndexById(activeId);
1054
+ const total = itemsRef.current.length;
1055
+ let next = currentIndex;
1056
+ for (let i = 0; i < total; i++) {
1057
+ next = (next + delta + total) % total;
1058
+ const candidate = itemsRef.current[next];
1059
+ if (candidate && !candidate.disabled) {
1060
+ setActiveId(candidate.id);
1061
+ candidate.ref.current?.focus();
1062
+ setSelectedValue(candidate.value);
1063
+ break;
1064
+ }
1065
+ }
1066
+ };
1067
+ const isActiveId = (id) => id === activeId;
1068
+ const setActiveById = (id) => {
1069
+ const found = itemsRef.current.find((x) => x.id === id && !x.disabled);
1070
+ if (found) {
1071
+ setActiveId(found.id);
1072
+ }
1073
+ };
1074
+ React11__namespace.default.useEffect(() => {
1075
+ if (!selectedValue) return;
1076
+ const selected = itemsRef.current.find((x) => x.value === selectedValue);
1077
+ if (selected && !selected.disabled) setActiveId(selected.id);
1078
+ }, [selectedValue]);
1079
+ const ctx = {
1080
+ groupId,
1081
+ disabled,
1082
+ selectedValue: selectedValue ?? null,
1083
+ setSelectedValue,
1084
+ unregisterItem,
1085
+ registerItem,
1086
+ isActiveId,
1087
+ setActiveById
1088
+ };
1089
+ return /* @__PURE__ */ jsxRuntime.jsx(RadioContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxRuntime.jsxs(
1090
+ Base2,
1091
+ {
1092
+ role: "radiogroup",
1093
+ "aria-disabled": disabled,
1094
+ ...rest,
1095
+ onKeyDown: (e) => {
1096
+ if (disabled) return;
1097
+ if (["ArrowUp", "ArrowLeft"].includes(e.code)) {
1098
+ e.preventDefault();
1099
+ moveActive(-1);
1100
+ } else if (["ArrowDown", "ArrowRight"].includes(e.code)) {
1101
+ e.preventDefault();
1102
+ moveActive(1);
1103
+ } else if (["Space", "Enter"].includes(e.code)) {
1104
+ e.preventDefault();
1105
+ const current = itemsRef.current.find((x) => x.id === activeId);
1106
+ if (current && !current.disabled) {
1107
+ setSelectedValue(current.value);
1108
+ current.ref.current?.focus();
1109
+ }
1110
+ }
1111
+ onKeyDownProp?.(e);
1112
+ },
1113
+ children: [
1114
+ (options ?? []).map(
1115
+ (opt) => renderOption ? /* @__PURE__ */ jsxRuntime.jsx(React11__namespace.default.Fragment, { children: renderOption(opt) }, opt.value) : /* @__PURE__ */ jsxRuntime.jsx(
1116
+ Item,
1117
+ {
1118
+ value: opt.value,
1119
+ disabled: !!(disabled || opt.disabled),
1120
+ alignI: true,
1121
+ gap: "8px",
1122
+ whiteSpace: "nowrap",
1123
+ children: opt.label
1124
+ },
1125
+ opt.value
1126
+ )
1127
+ ),
1128
+ typeof name === "string" && /* @__PURE__ */ jsxRuntime.jsx("input", { type: "hidden", name, value: selectedValue ?? "" })
1129
+ ]
1130
+ }
1131
+ ) });
1132
+ }
1133
+ function Item(props) {
1134
+ const {
1135
+ value,
1136
+ children,
1137
+ grid: gridProp,
1138
+ cols: colsProp,
1139
+ disabled: itemDisabled,
1140
+ onClick: onClickProp,
1141
+ onFocus: onFocusProp,
1142
+ onBlur: onBlurProp,
1143
+ ...rest
1144
+ } = props;
1145
+ const ctx = React11__namespace.default.useContext(RadioContext);
1146
+ if (!ctx) {
1147
+ return /* @__PURE__ */ jsxRuntime.jsxs(Base2, { flex: true, alignI: true, cursor: "pointer", ...rest, children: [
1148
+ /* @__PURE__ */ jsxRuntime.jsx(Base2, { "data-radio-circle": true, w: 24, h: 24, br: 9999, mr: 8 }),
1149
+ children
1150
+ ] });
1151
+ }
1152
+ const {
1153
+ groupId,
1154
+ registerItem,
1155
+ unregisterItem,
1156
+ selectedValue,
1157
+ setSelectedValue,
1158
+ isActiveId,
1159
+ setActiveById,
1160
+ disabled: groupDisabled
1161
+ } = ctx;
1162
+ const disabled = !!(groupDisabled || itemDisabled);
1163
+ const id = `radio-item-${groupId}-${value}`;
1164
+ const ref = React11__namespace.default.useRef(null);
1165
+ React11__namespace.default.useEffect(() => {
1166
+ registerItem({ id, value, disabled, ref });
1167
+ return () => unregisterItem(id);
1168
+ }, [id, value, disabled]);
1169
+ const isSelected = selectedValue === value;
1170
+ const isActive = isActiveId(id);
1171
+ const [isFocused, setIsFocused] = React11__namespace.default.useState(false);
1172
+ const shouldUseGrid = gridProp || !!colsProp;
1173
+ const renderLabel = () => {
1174
+ const onlyChild = React11__namespace.default.Children.count(children) === 1 ? React11__namespace.default.Children.toArray(children)[0] : null;
1175
+ if (typeof onlyChild === "string") {
1176
+ return /* @__PURE__ */ jsxRuntime.jsx(Base2, { "data-radio-label": true, children: onlyChild });
1177
+ }
1178
+ if (React11__namespace.default.isValidElement(onlyChild)) {
1179
+ return React11__namespace.default.cloneElement(
1180
+ onlyChild,
1181
+ {
1182
+ ...onlyChild.props || {},
1183
+ ["data-radio-label"]: true
1184
+ }
1185
+ );
1186
+ }
1187
+ return /* @__PURE__ */ jsxRuntime.jsx(Base2, { "data-radio-label": true, children });
1188
+ };
1189
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1190
+ Base2,
1191
+ {
1192
+ ref,
1193
+ flex: true,
1194
+ alignI: true,
1195
+ outline: "none",
1196
+ role: "radio",
1197
+ tabIndex: isActive ? 0 : -1,
1198
+ "aria-checked": isSelected,
1199
+ "aria-disabled": disabled,
1200
+ ...shouldUseGrid ? { grid: true } : { flex: true, alignI: true },
1201
+ ...colsProp && { cols: colsProp },
1202
+ gap: shouldUseGrid ? void 0 : "8px",
1203
+ cursor: disabled ? "not-allowed" : "pointer",
1204
+ userSelect: "none",
1205
+ ...isSelected && { "data-selected": true },
1206
+ ...disabled && { "data-disabled": true },
1207
+ _disabled: {
1208
+ _radioLabel: { color: { base: "neutral.400", _dark: "neutral.600" } }
1209
+ },
1210
+ onClick: (e) => {
1211
+ if (!disabled) setSelectedValue(value);
1212
+ onClickProp?.(e);
1213
+ },
1214
+ onFocus: (e) => {
1215
+ setActiveById(id);
1216
+ setIsFocused(true);
1217
+ onFocusProp?.(e);
1218
+ },
1219
+ onBlur: (e) => {
1220
+ setIsFocused(false);
1221
+ onBlurProp?.(e);
1222
+ },
1223
+ ...rest,
1224
+ children: [
1225
+ /* @__PURE__ */ jsxRuntime.jsxs(
1226
+ Base2,
1227
+ {
1228
+ "data-radio-outer": true,
1229
+ relative: true,
1230
+ ...isSelected && { "data-selected": true },
1231
+ ...disabled && { "data-disabled": true },
1232
+ w: "24px",
1233
+ h: "24px",
1234
+ grid: true,
1235
+ placeI: true,
1236
+ br: 9999,
1237
+ boxSizing: "border-box",
1238
+ borderWidth: 2,
1239
+ borderStyle: "solid",
1240
+ mr: shouldUseGrid ? void 0 : "8px",
1241
+ borderColor: { base: "neutral.400", _dark: "neutral.400" },
1242
+ _selected: { borderColor: { base: "blue.500", _dark: "blue.400" } },
1243
+ _disabled: {
1244
+ borderColor: { base: "neutral.400", _dark: "neutral.600" }
1245
+ },
1246
+ children: [
1247
+ /* @__PURE__ */ jsxRuntime.jsx(
1248
+ MotionDiv2,
1249
+ {
1250
+ "data-radio-focusring": true,
1251
+ absolute: true,
1252
+ top: 0,
1253
+ left: 0,
1254
+ w: "100%",
1255
+ h: "100%",
1256
+ br: 9999,
1257
+ pointerEvents: "none",
1258
+ boxShadow: {
1259
+ base: "0 0 0 6px rgba(0,0,0,.08)",
1260
+ _dark: "0 0 0 6px rgba(255,255,255,.08)"
1261
+ },
1262
+ initial: { scale: 0, opacity: 0 },
1263
+ animate: {
1264
+ scale: isFocused ? 1 : 0,
1265
+ opacity: isFocused ? 1 : 0,
1266
+ transition: { type: "spring", stiffness: 520, damping: 34 }
1267
+ }
1268
+ }
1269
+ ),
1270
+ /* @__PURE__ */ jsxRuntime.jsx(
1271
+ MotionDiv2,
1272
+ {
1273
+ "data-radio-inner": true,
1274
+ ...isSelected && { "data-selected": true },
1275
+ ...disabled && { "data-disabled": true },
1276
+ w: "12px",
1277
+ h: "12px",
1278
+ br: 9999,
1279
+ bg: { base: "blue.500", _dark: "blue.400" },
1280
+ initial: { scale: 0 },
1281
+ animate: {
1282
+ scale: isSelected ? 1 : 0,
1283
+ transition: { type: "spring", stiffness: 520, damping: 34 }
1284
+ },
1285
+ _disabled: { bg: { base: "neutral.400", _dark: "neutral.600" } }
1286
+ }
1287
+ )
1288
+ ]
1289
+ }
1290
+ ),
1291
+ renderLabel()
1292
+ ]
1293
+ }
1294
+ );
1295
+ }
1296
+ var LabelNameKey = "Label";
1297
+ var Base3 = base;
1298
+ var isBrowser = typeof window !== "undefined";
1299
+ var useIsomorphicLayoutEffect = isBrowser ? React11__namespace.default.useLayoutEffect : React11__namespace.default.useEffect;
1300
+ function pick(props, obj) {
1301
+ return props.reduce(
1302
+ (acc, prop) => {
1303
+ acc[prop] = obj[prop];
1304
+ return acc;
1305
+ },
1306
+ {}
1307
+ );
1308
+ }
1309
+ function assignRefs(targetRef, userRef) {
1310
+ return (node) => {
1311
+ targetRef.current = node;
1312
+ if (!userRef) return;
1313
+ if (typeof userRef === "function") userRef(node);
1314
+ else userRef.current = node;
1315
+ };
1316
+ }
1317
+ var HIDDEN_TEXTAREA_STYLE = {
1318
+ display: "block",
1319
+ position: "absolute",
1320
+ "max-height": "none",
1321
+ "min-height": "0",
1322
+ height: "0",
1323
+ top: "0",
1324
+ right: "0",
1325
+ "z-index": "-1000",
1326
+ visibility: "hidden",
1327
+ overflow: "hidden"
1328
+ };
1329
+ var forceHiddenStyles = (node) => {
1330
+ Object.keys(HIDDEN_TEXTAREA_STYLE).forEach((key) => {
1331
+ node.style.setProperty(
1332
+ key,
1333
+ HIDDEN_TEXTAREA_STYLE[key],
1334
+ "important"
1335
+ );
1336
+ });
1337
+ };
1338
+ var SIZING_STYLE = [
1339
+ "borderBottomWidth",
1340
+ "borderLeftWidth",
1341
+ "borderRightWidth",
1342
+ "borderTopWidth",
1343
+ "boxSizing",
1344
+ "fontFamily",
1345
+ "fontSize",
1346
+ "fontStyle",
1347
+ "fontWeight",
1348
+ "letterSpacing",
1349
+ "lineHeight",
1350
+ "paddingBottom",
1351
+ "paddingLeft",
1352
+ "paddingRight",
1353
+ "paddingTop",
1354
+ // Non-standard but may affect sizing
1355
+ "tabSize",
1356
+ "textIndent",
1357
+ "textRendering",
1358
+ "textTransform",
1359
+ "width",
1360
+ "wordBreak",
1361
+ "wordSpacing",
1362
+ "scrollbarGutter"
1363
+ ];
1364
+ var getSizingData = (node) => {
1365
+ const style = window.getComputedStyle(node);
1366
+ if (!style) return null;
1367
+ const sizingStyle = pick(SIZING_STYLE, style);
1368
+ const { boxSizing } = sizingStyle;
1369
+ if (!boxSizing) return null;
1370
+ const paddingSize = parseFloat(sizingStyle.paddingBottom) + parseFloat(sizingStyle.paddingTop);
1371
+ const borderSize = parseFloat(sizingStyle.borderBottomWidth) + parseFloat(sizingStyle.borderTopWidth);
1372
+ return { sizingStyle, paddingSize, borderSize };
1373
+ };
1374
+ var hiddenTextarea = null;
1375
+ var getHeight = (node, sizingData) => {
1376
+ const height = node.scrollHeight;
1377
+ if (sizingData.sizingStyle.boxSizing === "border-box") {
1378
+ return height + sizingData.borderSize;
1379
+ }
1380
+ return height - sizingData.paddingSize;
1381
+ };
1382
+ function calculateNodeHeight(sizingData, value, minRows = 1, maxRows = Infinity) {
1383
+ if (!hiddenTextarea) {
1384
+ hiddenTextarea = document.createElement("textarea");
1385
+ hiddenTextarea.setAttribute("tabindex", "-1");
1386
+ hiddenTextarea.setAttribute("aria-hidden", "true");
1387
+ forceHiddenStyles(hiddenTextarea);
1388
+ }
1389
+ if (hiddenTextarea.parentNode === null) {
1390
+ document.body.appendChild(hiddenTextarea);
1391
+ }
1392
+ const { paddingSize, borderSize, sizingStyle } = sizingData;
1393
+ const { boxSizing } = sizingStyle;
1394
+ Object.keys(sizingStyle).forEach((_key) => {
1395
+ const key = _key;
1396
+ hiddenTextarea.style[key] = sizingStyle[key];
1397
+ });
1398
+ forceHiddenStyles(hiddenTextarea);
1399
+ hiddenTextarea.value = value;
1400
+ let height = getHeight(hiddenTextarea, sizingData);
1401
+ hiddenTextarea.value = value;
1402
+ height = getHeight(hiddenTextarea, sizingData);
1403
+ hiddenTextarea.value = "x";
1404
+ const rowHeight = hiddenTextarea.scrollHeight - paddingSize;
1405
+ let minHeight = rowHeight * minRows;
1406
+ if (boxSizing === "border-box") {
1407
+ minHeight = minHeight + paddingSize + borderSize;
1408
+ }
1409
+ height = Math.max(minHeight, height);
1410
+ let maxHeight = rowHeight * maxRows;
1411
+ if (boxSizing === "border-box") {
1412
+ maxHeight = maxHeight + paddingSize + borderSize;
1413
+ }
1414
+ height = Math.min(maxHeight, height);
1415
+ return [height, rowHeight];
1416
+ }
1417
+ var Txtarea = tags.textarea;
1418
+ function Textarea(props) {
1419
+ const {
1420
+ maxRows,
1421
+ minRows,
1422
+ onChange,
1423
+ onHeightChange,
1424
+ ref: userRef,
1425
+ children,
1426
+ _motion,
1427
+ error,
1428
+ ...rest
1429
+ } = props;
1430
+ const isControlled = rest.value !== void 0;
1431
+ const libRef = React11__namespace.default.useRef(null);
1432
+ const ref = assignRefs(libRef, userRef);
1433
+ const heightRef = React11__namespace.default.useRef(0);
1434
+ const [_value, _setValue] = React11__namespace.default.useState("");
1435
+ const value = props.value ?? _value;
1436
+ const label = findChildrenByDisplayName(
1437
+ children,
1438
+ LabelNameKey
1439
+ );
1440
+ const labelWithProps = label ? React11__namespace.default.cloneElement(label, {
1441
+ required: props.required,
1442
+ value: props.value,
1443
+ error
1444
+ }) : null;
1445
+ const resizeTextarea = () => {
1446
+ const node = libRef.current;
1447
+ if (!node) return;
1448
+ const nodeSizingData = getSizingData(node);
1449
+ if (!nodeSizingData) return;
1450
+ const value2 = node.value || node.placeholder || "x";
1451
+ const [height, rowHeight] = calculateNodeHeight(
1452
+ nodeSizingData,
1453
+ value2,
1454
+ minRows,
1455
+ maxRows
1456
+ );
1457
+ if (heightRef.current !== height) {
1458
+ heightRef.current = height;
1459
+ node.style.setProperty("height", `${height}px`, "important");
1460
+ onHeightChange?.(height, { rowHeight });
1461
+ }
1462
+ };
1463
+ const handleChange = (e) => {
1464
+ if (!isControlled) resizeTextarea();
1465
+ _setValue(e.target.value);
1466
+ onChange?.(e);
1467
+ };
1468
+ useIsomorphicLayoutEffect(() => {
1469
+ resizeTextarea();
1470
+ }, [rest.value, rest.placeholder, minRows, maxRows]);
1471
+ React11__namespace.default.useEffect(() => {
1472
+ if (!isBrowser) return;
1473
+ const onResize = () => resizeTextarea();
1474
+ window.addEventListener("resize", onResize);
1475
+ return () => window.removeEventListener("resize", onResize);
1476
+ }, [minRows, maxRows, rest.placeholder, rest.value]);
1477
+ React11__namespace.default.useEffect(() => {
1478
+ const fonts = isBrowser ? document.fonts : void 0;
1479
+ if (!fonts || typeof fonts.addEventListener !== "function") return;
1480
+ const onFontsLoaded = () => resizeTextarea();
1481
+ fonts.addEventListener("loadingdone", onFontsLoaded);
1482
+ return () => fonts.removeEventListener("loadingdone", onFontsLoaded);
1483
+ }, [minRows, maxRows, rest.placeholder, rest.value]);
1484
+ React11__namespace.default.useEffect(() => {
1485
+ const node = libRef.current;
1486
+ const form = node?.form;
1487
+ if (!node || !form || isControlled) return;
1488
+ const onReset = () => {
1489
+ const currentValue = node.value;
1490
+ requestAnimationFrame(() => {
1491
+ if (node && currentValue !== node.value) resizeTextarea();
1492
+ });
1493
+ };
1494
+ form.addEventListener("reset", onReset);
1495
+ return () => form.removeEventListener("reset", onReset);
1496
+ }, [isControlled]);
1497
+ const resize = props.resize ?? "none";
1498
+ return /* @__PURE__ */ jsxRuntime.jsxs(Base3, { grid: true, rows: "/ 4", children: [
1499
+ /* @__PURE__ */ jsxRuntime.jsxs(Base3, { grid: true, relative: true, children: [
1500
+ labelWithProps,
1501
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsxRuntime.jsx(
1502
+ Txtarea,
1503
+ {
1504
+ ref,
1505
+ value,
1506
+ onContextMenu: (e) => e.preventDefault(),
1507
+ resize,
1508
+ py: 0.5,
1509
+ px: 2,
1510
+ color: "text-primary",
1511
+ border: "1.5px solid",
1512
+ borderColor: error ? "input-border-color-error" : "input-border-color",
1513
+ ...error && { outlineColor: "input-outline-color-error" },
1514
+ borderRadius: 8,
1515
+ placeholder: props.placeholder ?? " ",
1516
+ _placeholder: {
1517
+ color: "input-label-color",
1518
+ opacity: label ? 0 : 1
1519
+ },
1520
+ _focusWithin: { _placeholder: { opacity: 1 } },
1521
+ css: {
1522
+ boxSizing: "border-box",
1523
+ /* Works on Firefox */
1524
+ scrollbarWidth: "thin",
1525
+ scrollbarColor: "neutral.300 neutral.300",
1526
+ /* Works on Chrome, Edge, and Safari */
1527
+ "&::-webkit-scrollbar": { height: 6, width: 6 },
1528
+ "&::-webkit-scrollbar-track": {
1529
+ background: "transparent !important"
1530
+ },
1531
+ "&::-webkit-scrollbar-thumb": {
1532
+ backgroundColor: "neutral.300",
1533
+ borderRadius: 20
1534
+ }
1535
+ },
1536
+ ...rest,
1537
+ onChange: handleChange
1538
+ }
1539
+ ) })
1540
+ ] }),
1541
+ error && /* @__PURE__ */ jsxRuntime.jsx(Base3, { pl: 3, fontSize: "sm", color: "text-alert", children: error })
1542
+ ] });
1543
+ }
1544
+ function Label(props) {
1545
+ const { value, error, required, children, ...rest } = props;
1546
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1547
+ Base3,
1548
+ {
1549
+ position: "absolute",
1550
+ gridAutoFlow: "column",
1551
+ top: 1,
1552
+ transformOrigin: "top left",
1553
+ transform: "translate(0, 0) scale(1)",
1554
+ transition: "200ms cubic-bezier(0, 0, 0.2, 1) 0ms, .2s color ease-in-out, .2s background ease-in-out",
1555
+ ml: 1,
1556
+ mr: 1,
1557
+ px: 2,
1558
+ py: 0.5,
1559
+ br: 8,
1560
+ pointerEvents: "none",
1561
+ color: "input-label-color",
1562
+ zIndex: 1,
1563
+ css: {
1564
+ // lift label when sibling textarea has focus or blurred but not empty
1565
+ "&:has(+ textarea:focus, + textarea:not(:placeholder-shown))": {
1566
+ transformOrigin: "top left",
1567
+ transform: "scale(0.8)",
1568
+ top: "-14px",
1569
+ color: value ? "input-label-color-lifted" : "input-label-color",
1570
+ // only when lifted since autocomplete has lightblue background
1571
+ bg: "input-label-bg"
1572
+ },
1573
+ ...error && { color: "text-alert" }
1574
+ },
1575
+ ...rest,
1576
+ children: [
1577
+ children,
1578
+ required && "*"
1579
+ ]
1580
+ }
1581
+ );
1582
+ }
1583
+ Label.displayName = LabelNameKey;
1584
+ fontawesomeSvgCore.library.add(freeSolidSvgIcons.fas, freeRegularSvgIcons.far, freeBrandsSvgIcons.fab);
1585
+ function Icon(props) {
1586
+ const { className, iconPrefix, pulse, spin } = props;
1587
+ const iconSize = props.iconSize;
1588
+ const IconComp = props.icon ?? props.startIcon;
1589
+ const prefix = !iconPrefix || iconPrefix === "solid" ? "fas" : iconPrefix === "regular" ? "far" : "fab";
1590
+ if (!IconComp) return null;
1591
+ else if (typeof IconComp === "string") {
1592
+ return /* @__PURE__ */ jsxRuntime.jsx(
1593
+ reactFontawesome.FontAwesomeIcon,
1594
+ {
1595
+ icon: { prefix, iconName: IconComp },
1596
+ className,
1597
+ spinPulse: pulse,
1598
+ size: iconSize,
1599
+ spin
1600
+ }
1601
+ );
1602
+ } else if ("iconName" in IconComp) {
1603
+ return /* @__PURE__ */ jsxRuntime.jsx(
1604
+ reactFontawesome.FontAwesomeIcon,
1605
+ {
1606
+ icon: IconComp,
1607
+ className,
1608
+ spinPulse: pulse,
1609
+ size: iconSize,
1610
+ spin
1611
+ }
1612
+ );
1613
+ } else if (typeof IconComp === "function") {
1614
+ return IconComp(props);
1615
+ } else return IconComp;
1616
+ }
1617
+ var LabelNameKey2 = "Label";
1618
+ var LeftSideNameKey = "LeftIcon";
1619
+ var RightSideNameKey = "RightSide";
1620
+ var InputBase = tags.input;
1621
+ var Base4 = base;
1622
+ function Input(props) {
1623
+ const { _motion, error, children, ...rest } = props;
1624
+ const label = findChildrenByDisplayName(
1625
+ children,
1626
+ LabelNameKey2
1627
+ );
1628
+ const leftIcon = findChildrenByDisplayName(
1629
+ children,
1630
+ LeftSideNameKey
1631
+ );
1632
+ const rightSide = findChildrenByDisplayName(
1633
+ children,
1634
+ RightSideNameKey
1635
+ );
1636
+ const labelWithProps = label ? React11__namespace.default.cloneElement(label, {
1637
+ hasLeftIcon: !!leftIcon,
1638
+ required: props.required,
1639
+ value: props.value,
1640
+ error
1641
+ }) : null;
1642
+ const rightSideWithProps = rightSide ? React11__namespace.default.cloneElement(rightSide, {
1643
+ onChange: props.onChange,
1644
+ value: props.value
1645
+ }) : null;
1646
+ return /* @__PURE__ */ jsxRuntime.jsxs(Base4, { grid: true, rows: "/ 4", children: [
1647
+ /* @__PURE__ */ jsxRuntime.jsxs(Base4, { grid: true, relative: true, children: [
1648
+ leftIcon,
1649
+ labelWithProps,
1650
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsxRuntime.jsx(
1651
+ InputBase,
1652
+ {
1653
+ py: 0.5,
1654
+ pl: leftIcon ? 7 : 2,
1655
+ pr: rightSide ? 6 : 2,
1656
+ color: "text-primary",
1657
+ border: "1.5px solid",
1658
+ borderColor: error ? "input-border-color-error" : "input-border-color",
1659
+ ...error && { outlineColor: "input-outline-color-error" },
1660
+ borderRadius: 8,
1661
+ placeholder: props.placeholder ?? " ",
1662
+ _placeholder: {
1663
+ color: "input-label-color",
1664
+ opacity: label ? 0 : 1
1665
+ },
1666
+ _focusWithin: { _placeholder: { opacity: 1 } },
1667
+ ...rest
1668
+ }
1669
+ ) }),
1670
+ rightSideWithProps
1671
+ ] }),
1672
+ error && /* @__PURE__ */ jsxRuntime.jsx(Base4, { pl: 3, fontSize: "sm", color: "text-alert", children: error })
1673
+ ] });
1674
+ }
1675
+ function LeftIcon(props) {
1676
+ const remaining = omit(props, [
1677
+ "iconPrefix",
1678
+ "startIcon",
1679
+ "endIcon",
1680
+ "icon",
1681
+ "spin",
1682
+ "size",
1683
+ "pulse"
1684
+ ]);
1685
+ return /* @__PURE__ */ jsxRuntime.jsx(
1686
+ Base4,
1687
+ {
1688
+ position: "absolute",
1689
+ transform: "translateY(-50%)",
1690
+ top: "50%",
1691
+ left: "11px",
1692
+ ...remaining,
1693
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { ...props })
1694
+ }
1695
+ );
1696
+ }
1697
+ LeftIcon.displayName = LeftSideNameKey;
1698
+ function RightSide(props) {
1699
+ const { clearable, ...rest } = props;
1700
+ if (clearable && !props.value) return null;
1701
+ return /* @__PURE__ */ jsxRuntime.jsx(
1702
+ Base4,
1703
+ {
1704
+ position: "absolute",
1705
+ top: "50%",
1706
+ transform: "translateY(-50%)",
1707
+ right: "11px",
1708
+ ...rest,
1709
+ ...clearable && {
1710
+ cursor: "pointer",
1711
+ onClick: (e) => {
1712
+ const clearedValueEvent = {
1713
+ ...e,
1714
+ target: { ...e.target, value: "" }
1715
+ };
1716
+ props.onChange?.(clearedValueEvent);
1717
+ }
1718
+ }
1719
+ }
1720
+ );
1721
+ }
1722
+ RightSide.displayName = RightSideNameKey;
1723
+ function Label2(props) {
1724
+ const { value, error, required, children, hasLeftIcon, ...rest } = props;
1725
+ const ml = hasLeftIcon ? 6 : 1;
1726
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1727
+ Base4,
1728
+ {
1729
+ gridAutoFlow: "column",
1730
+ position: "absolute",
1731
+ pointerEvents: "none",
1732
+ top: "50%",
1733
+ transformOrigin: "top left",
1734
+ transform: "translate(0, -50%) scale(1)",
1735
+ transition: "200ms cubic-bezier(0, 0, 0.2, 1) 0ms, .2s color ease-in-out, .2s background ease-in-out",
1736
+ ml,
1737
+ mr: 1,
1738
+ px: 2,
1739
+ py: 0.5,
1740
+ br: 8,
1741
+ color: "input-label-color",
1742
+ lineHeight: 1.1,
1743
+ css: {
1744
+ // lift label when sibling input has focus or blurred but empty
1745
+ "&:has(+ input:focus, + input:not(:placeholder-shown))": {
1746
+ transformOrigin: "top left",
1747
+ transform: "scale(0.8)",
1748
+ top: "-10px",
1749
+ ml,
1750
+ color: value ? "input-label-color-lifted" : "input-label-color",
1751
+ // only when lifted since autocomplete has lightblue background
1752
+ bg: "input-label-bg"
1753
+ },
1754
+ ...error && { color: "text-alert" }
1755
+ },
1756
+ ...rest,
1757
+ children: [
1758
+ children,
1759
+ required && "*"
1760
+ ]
1761
+ }
1762
+ );
1763
+ }
1764
+ Label2.displayName = LabelNameKey2;
1765
+ function useResizeObserver(opts = {}) {
1766
+ const onResize = opts.onResize;
1767
+ const onResizeRef = React11__namespace.default.useRef(void 0);
1768
+ onResizeRef.current = onResize;
1769
+ const round = opts.round || Math.round;
1770
+ const resizeObserverRef = React11__namespace.default.useRef(null);
1771
+ const [size, setSize] = React11__namespace.default.useState({
1772
+ width: void 0,
1773
+ height: void 0
1774
+ });
1775
+ const didUnmount = React11__namespace.default.useRef(false);
1776
+ React11__namespace.default.useEffect(() => {
1777
+ didUnmount.current = false;
1778
+ return () => {
1779
+ didUnmount.current = true;
1780
+ };
1781
+ }, []);
1782
+ const previous = React11__namespace.default.useRef({
1783
+ width: void 0,
1784
+ height: void 0
1785
+ });
1786
+ const refCallback = useResolvedElement(
1787
+ React11__namespace.default.useCallback(
1788
+ (element) => {
1789
+ if (!resizeObserverRef.current || resizeObserverRef.current.box !== opts.box || resizeObserverRef.current.round !== round) {
1790
+ resizeObserverRef.current = {
1791
+ box: opts.box,
1792
+ round,
1793
+ instance: new ResizeObserver((entries) => {
1794
+ const entry = entries[0];
1795
+ const boxProp = opts.box === "border-box" ? "borderBoxSize" : opts.box === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize";
1796
+ const reportedWidth = extractSize(entry, boxProp, "inlineSize");
1797
+ const reportedHeight = extractSize(entry, boxProp, "blockSize");
1798
+ const newWidth = reportedWidth ? round(reportedWidth) : void 0;
1799
+ const newHeight = reportedHeight ? round(reportedHeight) : void 0;
1800
+ if (previous.current.width !== newWidth || previous.current.height !== newHeight) {
1801
+ const newSize = { width: newWidth, height: newHeight };
1802
+ previous.current.width = newWidth;
1803
+ previous.current.height = newHeight;
1804
+ if (onResizeRef.current) {
1805
+ onResizeRef.current(newSize);
1806
+ } else {
1807
+ if (!didUnmount.current) {
1808
+ setSize(newSize);
1809
+ }
1810
+ }
1811
+ }
1812
+ })
1813
+ };
1814
+ }
1815
+ resizeObserverRef.current.instance.observe(element, { box: opts.box });
1816
+ return () => {
1817
+ if (resizeObserverRef.current) {
1818
+ resizeObserverRef.current.instance.unobserve(element);
1819
+ }
1820
+ };
1821
+ },
1822
+ [opts.box, round]
1823
+ ),
1824
+ opts.ref
1825
+ );
1826
+ return React11__namespace.default.useMemo(
1827
+ () => ({
1828
+ ref: refCallback,
1829
+ width: size.width,
1830
+ height: size.height
1831
+ }),
1832
+ // Note: when `onResize` is provided, width/height will remain whatever the
1833
+ // state was initialized to; consumers should rely on the callback in that mode.
1834
+ [refCallback, size.width, size.height]
1835
+ );
1836
+ }
1837
+ function useResolvedElement(subscriber, refOrElement) {
1838
+ const lastReportRef = React11__namespace.default.useRef(null);
1839
+ const refOrElementRef = React11__namespace.default.useRef(null);
1840
+ refOrElementRef.current = refOrElement;
1841
+ const cbElementRef = React11__namespace.default.useRef(null);
1842
+ React11__namespace.default.useEffect(() => {
1843
+ evaluateSubscription();
1844
+ });
1845
+ const evaluateSubscription = React11__namespace.default.useCallback(() => {
1846
+ const cbElement = cbElementRef.current;
1847
+ const refOrElement2 = refOrElementRef.current;
1848
+ const element = cbElement ? cbElement : refOrElement2 ? refOrElement2 instanceof Element ? refOrElement2 : refOrElement2.current : null;
1849
+ if (lastReportRef.current && lastReportRef.current.element === element && lastReportRef.current.subscriber === subscriber) {
1850
+ return;
1851
+ }
1852
+ if (lastReportRef.current && lastReportRef.current.cleanup) {
1853
+ lastReportRef.current.cleanup();
1854
+ }
1855
+ lastReportRef.current = {
1856
+ element,
1857
+ subscriber,
1858
+ // Only calling the subscriber, if there's an actual element to report.
1859
+ // Setting cleanup to undefined unless a subscriber returns one, as an existing cleanup function would've been just called.
1860
+ cleanup: element ? subscriber(element) : void 0
1861
+ };
1862
+ }, [subscriber]);
1863
+ React11__namespace.default.useEffect(() => {
1864
+ return () => {
1865
+ if (lastReportRef.current && lastReportRef.current.cleanup) {
1866
+ lastReportRef.current.cleanup();
1867
+ lastReportRef.current = null;
1868
+ }
1869
+ };
1870
+ }, []);
1871
+ return React11__namespace.default.useCallback(
1872
+ (element) => {
1873
+ cbElementRef.current = element;
1874
+ evaluateSubscription();
1875
+ },
1876
+ [evaluateSubscription]
1877
+ );
1878
+ }
1879
+ function extractSize(entry, boxProp, sizeType) {
1880
+ if (!entry[boxProp]) {
1881
+ if (boxProp === "contentBoxSize") {
1882
+ return entry.contentRect[sizeType === "inlineSize" ? "width" : "height"];
1883
+ }
1884
+ return void 0;
1885
+ }
1886
+ return entry[boxProp][0] ? entry[boxProp][0][sizeType] : (
1887
+ // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current
1888
+ // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.
1889
+ // @ts-ignore
1890
+ entry[boxProp][sizeType]
1891
+ );
1892
+ }
1893
+ var use_resize_observer_default = useResizeObserver;
1894
+ var MotionDiv3 = motionTags.div;
1895
+ var MotionBtn = motionTags.button;
1896
+ var displayName = "AccordionItem";
1897
+ var AccordionContext = React11__namespace.default.createContext({});
1898
+ function AccordionProvider(props) {
1899
+ const [state, setState] = useImmer.useImmer({
1900
+ allowMultiple: false,
1901
+ allowToggle: true,
1902
+ open: []
1903
+ });
1904
+ return /* @__PURE__ */ jsxRuntime.jsx(AccordionContext.Provider, { value: { setState, state }, children: props.children });
1905
+ }
1906
+ function useAccordion() {
1907
+ const context = React11__namespace.default.useContext(AccordionContext);
1908
+ if (context === void 0) {
1909
+ throw new Error("useAccordion must be used within a AccordionProvider");
1910
+ }
1911
+ return context;
1912
+ }
1913
+ function AccordionComponent(props) {
1914
+ const accordion = useAccordion();
1915
+ const accordionState = accordion.state;
1916
+ React11__namespace.default.useEffect(() => {
1917
+ accordion.setState((draft) => {
1918
+ draft.allowMultiple = !!props.allowMultiple;
1919
+ draft.allowToggle = !!props.allowToggle;
1920
+ });
1921
+ }, [props.allowMultiple, props.allowToggle]);
1922
+ React11__namespace.default.Children.forEach(props.children, (x) => {
1923
+ if (typeof x.type === "function" && "displayName" in x.type && x.type.displayName !== displayName) {
1924
+ throw new Error("Accordion can only have AccordionItems as children");
1925
+ }
1926
+ });
1927
+ const children = React11__namespace.default.Children.map(props.children, (child, i) => {
1928
+ if (!React11__namespace.default.isValidElement(child)) return child;
1929
+ return React11__namespace.default.cloneElement(child, { idx: i });
1930
+ });
1931
+ React11__namespace.default.useEffect(() => {
1932
+ if (accordionState.open.length === children.length) return;
1933
+ const defaultOpenIdx = props.defaultOpenIdx;
1934
+ const items = new Array(children.length).fill(null).map((x, i) => {
1935
+ if (defaultOpenIdx) return defaultOpenIdx.includes(i);
1936
+ else return false;
1937
+ });
1938
+ accordion.setState((draft) => {
1939
+ draft.open = items;
1940
+ });
1941
+ }, [
1942
+ accordionState.open.length,
1943
+ children.length,
1944
+ props.defaultOpenIdx?.length
1945
+ ]);
1946
+ return /* @__PURE__ */ jsxRuntime.jsx(MotionDiv3, { grid: true, children });
1947
+ }
1948
+ function Accordion(props) {
1949
+ return /* @__PURE__ */ jsxRuntime.jsx(AccordionProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(AccordionComponent, { ...props }) });
1950
+ }
1951
+ function Item2(props) {
1952
+ const { ref, height } = use_resize_observer_default();
1953
+ const { idx, children, rightIndicator, rightStatusIcon, title, ...rest } = props;
1954
+ const accordion = useAccordion();
1955
+ const accordionState = accordion.state;
1956
+ const isOpen = accordionState.open.at(idx);
1957
+ const isLastItem = idx === accordionState.open.length - 1;
1958
+ const toggle = () => {
1959
+ const updatedItems = accordionState.open.map((x, i) => {
1960
+ if (accordionState.allowMultiple) return i === idx ? !x : x;
1961
+ else return i === idx ? !x : false;
1962
+ });
1963
+ accordion.setState((draft) => {
1964
+ draft.open = updatedItems;
1965
+ });
1966
+ };
1967
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1968
+ MotionDiv3,
1969
+ {
1970
+ grid: true,
1971
+ alignC: "start",
1972
+ overflow: "auto",
1973
+ style: {
1974
+ borderBottom: isLastItem ? `1px solid ${props.borderBottomColor ?? props.borderColor ?? "var(--colors-neutral-300)!"}` : void 0,
1975
+ borderTop: `1px solid ${props.borderTopColor ?? props.borderColor ?? "var(--colors-neutral-300)!"}`
1976
+ },
1977
+ children: [
1978
+ /* @__PURE__ */ jsxRuntime.jsxs(
1979
+ MotionBtn,
1980
+ {
1981
+ flex: true,
1982
+ py: 2,
1983
+ rows: "between",
1984
+ borderRadius: 0,
1985
+ boxSizing: "border-box",
1986
+ cursor: "pointer",
1987
+ transition: ".2s all ease-in-out",
1988
+ _hover: { bg: { base: "neutral.100", _dark: "neutral.700" } },
1989
+ _active: { scale: 0.98 },
1990
+ overflow: "auto",
1991
+ zIndex: 1,
1992
+ ...rest,
1993
+ onClick: (e) => {
1994
+ toggle();
1995
+ props.onClick?.(e);
1996
+ },
1997
+ children: [
1998
+ /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: title }),
1999
+ rightIndicator ? rightIndicator?.(isOpen) : /* @__PURE__ */ jsxRuntime.jsx(MotionDiv3, { grid: true, pr: ".5rem", color: "neutral.500", children: /* @__PURE__ */ jsxRuntime.jsx(
2000
+ Icon,
2001
+ {
2002
+ fontSize: ".8rem",
2003
+ icon: isOpen ? "chevron-up" : "chevron-down"
2004
+ }
2005
+ ) }),
2006
+ rightStatusIcon ? rightStatusIcon : null
2007
+ ]
2008
+ }
2009
+ ),
2010
+ /* @__PURE__ */ jsxRuntime.jsx(MotionDiv3, { grid: true, overflowY: "auto", maxH: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(
2011
+ MotionDiv3,
2012
+ {
2013
+ grid: true,
2014
+ animate: { height: isOpen ? height ?? 0 : 0 },
2015
+ overflowY: "hidden",
2016
+ children: /* @__PURE__ */ jsxRuntime.jsx(MotionDiv3, { grid: true, ref, children: isOpen && /* @__PURE__ */ jsxRuntime.jsx(
2017
+ MotionDiv3,
2018
+ {
2019
+ grid: true,
2020
+ initial: { opacity: 0 },
2021
+ animate: { opacity: 1 },
2022
+ exit: { opacity: 0 },
2023
+ children
2024
+ }
2025
+ ) })
2026
+ }
2027
+ ) })
2028
+ ]
2029
+ }
2030
+ );
2031
+ }
2032
+ Item2.displayName = displayName;
2033
+ var accordion_default = Accordion;
2034
+ var MotionDiv4 = motionTags.div;
2035
+ var MotionBtn2 = motionTags.button;
2036
+ var breakpoint = ["(min-width: 600px)"];
2037
+ function DrawerComponent(props) {
2038
+ const ref = React11__namespace.default.useRef(null);
2039
+ const dragHandleRef = React11__namespace.default.useRef(null);
2040
+ const [isDesktop] = useMatchMedia(breakpoint);
2041
+ const closeFnRef = React11__namespace.default.useRef(null);
2042
+ const dragControls = framerMotion.useDragControls();
2043
+ const { open, setOpen } = useDrawer();
2044
+ const { onClose, ...rest } = props;
2045
+ const y = framerMotion.useMotionValue(0);
2046
+ const openDrawer = () => {
2047
+ y.stop();
2048
+ y.set(0);
2049
+ setOpen(true);
2050
+ };
2051
+ const closeDrawer = () => setOpen(false);
2052
+ closeFnRef.current = () => {
2053
+ closeDrawer();
2054
+ onClose?.();
2055
+ };
2056
+ const onDragStart = (e, info) => {
2057
+ console.log({ e });
2058
+ if (isDesktop) return;
2059
+ const noDragEl = document.querySelector("[data-no-drag]");
2060
+ if (!noDragEl || !noDragEl.contains(e.target)) {
2061
+ dragControls.start(e);
2062
+ } else {
2063
+ dragControls.componentControls.forEach((entry) => {
2064
+ entry.stop(e, info);
2065
+ });
2066
+ }
2067
+ };
2068
+ React11__namespace.default.useEffect(() => {
2069
+ if (props.open) openDrawer();
2070
+ else closeFnRef.current();
2071
+ }, [props.open]);
2072
+ React11__namespace.default.useEffect(() => {
2073
+ const container = ref.current;
2074
+ if (!open || !container) return;
2075
+ container.setAttribute("tabindex", "0");
2076
+ const trapFocus = (e) => {
2077
+ if (container.contains(e.relatedTarget)) return;
2078
+ container.focus();
2079
+ };
2080
+ const closeOnEsc = (e) => {
2081
+ if (e.key !== "Escape" || props.closeOnEsc === false) return;
2082
+ console.log("[close] esc key");
2083
+ closeFnRef.current();
2084
+ };
2085
+ container.addEventListener("focusout", trapFocus);
2086
+ container.addEventListener("keydown", closeOnEsc);
2087
+ document.body.style.overflow = "hidden";
2088
+ return () => {
2089
+ container.removeEventListener("focusout", trapFocus);
2090
+ container.removeEventListener("keydown", closeOnEsc);
2091
+ document.body.style.overflow = "auto";
2092
+ };
2093
+ }, [open]);
2094
+ React11__namespace.default.useEffect(() => {
2095
+ const unsubscribeY = y.on("change", (latestY) => {
2096
+ if (latestY > 150) {
2097
+ console.log("[close] latestY > 150");
2098
+ closeFnRef.current();
2099
+ }
2100
+ });
2101
+ return () => {
2102
+ unsubscribeY();
2103
+ };
2104
+ }, [y]);
2105
+ const onBackdropClick = () => {
2106
+ const outsideClickClose = props.outsideClickClose ?? true;
2107
+ if (!outsideClickClose) return;
2108
+ console.log("[close] clicked backdrop");
2109
+ closeFnRef.current();
2110
+ };
2111
+ return reactDom.createPortal(
2112
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { initial: false, mode: "wait", children: open && /* @__PURE__ */ jsxRuntime.jsx(
2113
+ Backdrop,
2114
+ {
2115
+ onClick: () => onBackdropClick(),
2116
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2117
+ MotionDiv4,
2118
+ {
2119
+ grid: true,
2120
+ onClick: (e) => e.stopPropagation(),
2121
+ position: "fixed",
2122
+ initial: "initial",
2123
+ animate: "animate",
2124
+ exit: "exit",
2125
+ ...isDesktop ? {
2126
+ drag: false,
2127
+ style: void 0,
2128
+ dragControls: null,
2129
+ dragConstraints: void 0,
2130
+ // style: null,
2131
+ // dragConstraints: null,
2132
+ height: props.height ?? "max-content!",
2133
+ // "min(50%, 300px)",
2134
+ width: props.width ?? "clamp(50%, 700px, 90%)",
2135
+ pt: 6,
2136
+ // px: 4,
2137
+ margin: "auto",
2138
+ borderRadius: 12,
2139
+ zIndex: 1,
2140
+ variants: {
2141
+ initial: { opacity: 0, scale: 0.5 },
2142
+ animate: {
2143
+ opacity: 1,
2144
+ scale: 1,
2145
+ transition: {
2146
+ type: "spring",
2147
+ damping: 20,
2148
+ stiffness: 300
2149
+ }
2150
+ },
2151
+ exit: {
2152
+ opacity: 0,
2153
+ scale: 0.3,
2154
+ transition: { type: "spring", duration: 0.45 }
2155
+ }
2156
+ }
2157
+ } : {
2158
+ w: "100vw",
2159
+ left: 0,
2160
+ right: 0,
2161
+ bottom: 0,
2162
+ borderTopLeftRadius: 12,
2163
+ borderTopRightRadius: 12,
2164
+ variants: {
2165
+ initial: { height: 0, opacity: 0 },
2166
+ animate: {
2167
+ height: "auto",
2168
+ opacity: 1,
2169
+ // transition: { type: "spring", damping: 26, stiffness: 300 },
2170
+ transition: { type: "spring", duration: 0.3 }
2171
+ },
2172
+ exit: { height: 0, opacity: 0 }
2173
+ },
2174
+ drag: "y",
2175
+ style: { y },
2176
+ dragControls,
2177
+ // @ts-ignore
2178
+ onPointerDown: (...args) => onDragStart(args[0], args[1]),
2179
+ // onPointerDown: (x, y) => onDragStart(x, y),
2180
+ // drag={hasBackdrop ? "y" : false}
2181
+ dragElastic: 0,
2182
+ // prevent drawer from being dragged higher than what its opened to
2183
+ dragConstraints: { top: 0 },
2184
+ onDragEnd: (_, drag) => {
2185
+ if (props.drag === false) return;
2186
+ const pageHeight = document.documentElement.scrollHeight;
2187
+ const yCoord = drag.point.y;
2188
+ const velocity = drag.velocity.y;
2189
+ const releaseThreshold = 0.8;
2190
+ const releasePct = yCoord / pageHeight;
2191
+ if (velocity > 25 && releasePct >= releaseThreshold || velocity > 750) {
2192
+ props.onClose?.();
2193
+ }
2194
+ }
2195
+ },
2196
+ boxSizing: "border-box",
2197
+ boxShadow: "hsl(0deg 0% 0% / 60%) 0px -4px 20px",
2198
+ bg: { base: "neutral.100", _dark: "neutral.900" },
2199
+ color: "text-primary",
2200
+ ref,
2201
+ ...rest,
2202
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
2203
+ MotionDiv4,
2204
+ {
2205
+ grid: true,
2206
+ ...isDesktop ? { position: "relative" } : { rows: "max-content 1fr" },
2207
+ children: [
2208
+ !isDesktop && props.hideHandle !== false && /* @__PURE__ */ jsxRuntime.jsx(
2209
+ MotionDiv4,
2210
+ {
2211
+ grid: true,
2212
+ justifySelf: "center",
2213
+ h: 6,
2214
+ w: 34,
2215
+ mt: "16px",
2216
+ mb: 4,
2217
+ br: 20,
2218
+ bg: { base: "neutral.400", _dark: "neutral.600" },
2219
+ cursor: props.drag ? "row-resize" : "default",
2220
+ ref: dragHandleRef
2221
+ }
2222
+ ),
2223
+ props.children
2224
+ ]
2225
+ }
2226
+ )
2227
+ },
2228
+ "drawer"
2229
+ )
2230
+ }
2231
+ ) }),
2232
+ document.getElementById("portal")
2233
+ );
2234
+ }
2235
+ var DrawerContext = React11__namespace.default.createContext({
2236
+ open: false,
2237
+ setOpen: (_value) => {
2238
+ return;
2239
+ }
2240
+ });
2241
+ function DrawerProvider(props) {
2242
+ const [open, setOpen] = React11__namespace.default.useState(false);
2243
+ const value = { open, setOpen };
2244
+ return /* @__PURE__ */ jsxRuntime.jsx(DrawerContext.Provider, { value, children: props.children });
2245
+ }
2246
+ function useDrawer() {
2247
+ const context = React11__namespace.default.useContext(DrawerContext);
2248
+ if (context === void 0) {
2249
+ throw new Error("useDrawer must be used within a DrawerProvider");
2250
+ }
2251
+ return context;
2252
+ }
2253
+ function Drawer(props) {
2254
+ return /* @__PURE__ */ jsxRuntime.jsx(DrawerProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(DrawerComponent, { ...props }) });
2255
+ }
2256
+ function BtnGroup(props) {
2257
+ const [isDesktop] = useMatchMedia(breakpoint);
2258
+ const { children, ...rest } = props;
2259
+ if (isDesktop) {
2260
+ return /* @__PURE__ */ jsxRuntime.jsx(MotionDiv4, { flex: true, alignI: true, gap: 4, ...rest, children: React11__namespace.default.Children.toArray(children).toReversed() });
2261
+ } else {
2262
+ return /* @__PURE__ */ jsxRuntime.jsx(MotionDiv4, { grid: true, rowG: 14, ...props });
2263
+ }
2264
+ }
2265
+ function CloseBtn(props) {
2266
+ const [isDesktop] = useMatchMedia(breakpoint);
2267
+ const { children, ...rest } = props;
2268
+ if (isDesktop) {
2269
+ return /* @__PURE__ */ jsxRuntime.jsx(
2270
+ MotionBtn2,
2271
+ {
2272
+ transition: ".14s all ease-out",
2273
+ _after: {
2274
+ content: '""',
2275
+ position: "absolute",
2276
+ inset: 0,
2277
+ scale: 0,
2278
+ rounded: true,
2279
+ transition: ".14s all ease-out",
2280
+ zIndex: -1
2281
+ },
2282
+ _hover: {
2283
+ _after: {
2284
+ scale: 1,
2285
+ bg: { base: "neutral.200", _dark: "neutral.800" }
2286
+ }
2287
+ },
2288
+ _active: {
2289
+ scale: 0.9,
2290
+ _after: { scale: 0.94 },
2291
+ bg: { base: "neutral.200", _dark: "neutral.800" }
2292
+ },
2293
+ position: "absolute",
2294
+ h: 32,
2295
+ w: 32,
2296
+ top: -2,
2297
+ right: 3,
2298
+ borderRadius: 32,
2299
+ cursor: "pointer",
2300
+ ...rest,
2301
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2302
+ Icon,
2303
+ {
2304
+ icon: "times",
2305
+ placeC: true,
2306
+ h: 16,
2307
+ w: 16,
2308
+ fontSize: 16,
2309
+ color: { base: "neutral.400", _dark: "neutral.300" }
2310
+ }
2311
+ )
2312
+ }
2313
+ );
2314
+ } else if (children) {
2315
+ return /* @__PURE__ */ jsxRuntime.jsx(MotionDiv4, { grid: true, children: /* @__PURE__ */ jsxRuntime.jsx(MotionBtn2, { ...props, children: "Close" }) });
2316
+ } else {
2317
+ return;
2318
+ }
2319
+ }
2320
+ function Backdrop(props) {
2321
+ const [allowOutsideClick, setAllowOutsideClick] = React11__namespace.default.useState(true);
2322
+ const [isDesktop] = useMatchMedia(breakpoint);
2323
+ return /* @__PURE__ */ jsxRuntime.jsx(
2324
+ MotionDiv4,
2325
+ {
2326
+ grid: true,
2327
+ "data-backdrop": true,
2328
+ background: "hsl(0 0% 0% / 0.3)",
2329
+ zIndex: 1,
2330
+ initial: { opacity: 0 },
2331
+ animate: { opacity: 1, transition: { duration: 0.2 } },
2332
+ exit: { opacity: 0, transition: { duration: 0.3 } },
2333
+ onAnimationStart: () => {
2334
+ setAllowOutsideClick(false);
2335
+ },
2336
+ onAnimationComplete: () => {
2337
+ setAllowOutsideClick(true);
2338
+ },
2339
+ position: "fixed",
2340
+ top: 0,
2341
+ left: 0,
2342
+ height: "100%",
2343
+ width: "100%",
2344
+ placeI: isDesktop,
2345
+ onClick: () => allowOutsideClick ? props.onClick() : void 0,
2346
+ children: props.children
2347
+ }
2348
+ );
2349
+ }
2350
+ function useMatchMedia(queries, defaultValues = []) {
2351
+ const initialValues = defaultValues.length ? defaultValues : Array(queries.length).fill(false);
2352
+ const mediaQueryLists = queries.map((q) => window.matchMedia(q));
2353
+ const getValue = () => {
2354
+ const matchedQueries = mediaQueryLists.map((mql) => mql.matches);
2355
+ return matchedQueries;
2356
+ };
2357
+ const [value, setValue] = React11__namespace.default.useState(getValue);
2358
+ React11__namespace.default.useLayoutEffect(() => {
2359
+ const handler = () => setValue(getValue);
2360
+ mediaQueryLists.forEach((mql) => mql.addListener(handler));
2361
+ return () => mediaQueryLists.forEach((mql) => mql.removeListener(handler));
2362
+ }, []);
2363
+ if (typeof window === "undefined") return initialValues;
2364
+ return value;
2365
+ }
2366
+ var MotionDiv5 = motionTags.div;
2367
+ var TrackBgNameKey = "TrackBg";
2368
+ var TrackFillNameKey = "TrackFill";
2369
+ function Progress(props) {
2370
+ const { children, steps, value, max: maxProp, ...rest } = props;
2371
+ const [progress, setProgress] = React11__namespace.default.useState(0);
2372
+ const max = maxProp ?? 100;
2373
+ React11__namespace.default.useEffect(() => {
2374
+ setProgress(Math.min((value ?? 0) / max, 1) * 100);
2375
+ }, [value, max]);
2376
+ const width = `${progress}%`;
2377
+ const barBackground = "var(--colors-blue-500)";
2378
+ const trackBackground = "var(--colors-neutral-300)";
2379
+ if (typeof steps === "number") {
2380
+ const stepSize = max / steps;
2381
+ return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.LayoutGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(MotionDiv5, { autoCols: "1fr", colG: 8, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: Array.from({ length: steps }, (_, i) => {
2382
+ const normalizedValue = stepSize * i;
2383
+ const isComplete = normalizedValue < (value ?? 0);
2384
+ const defaultBgColor = trackBackground;
2385
+ return /* @__PURE__ */ jsxRuntime.jsx(
2386
+ MotionDiv5,
2387
+ {
2388
+ layout: true,
2389
+ h: 8,
2390
+ rounded: true,
2391
+ initial: { scale: 0, width: 0, opacity: 0 },
2392
+ animate: {
2393
+ scale: 1,
2394
+ opacity: 1,
2395
+ width: "100%",
2396
+ background: isComplete ? barBackground : defaultBgColor
2397
+ },
2398
+ exit: { scale: 0, width: 0, opacity: 0 }
2399
+ },
2400
+ i
2401
+ );
2402
+ }) }) }) });
2403
+ }
2404
+ const trackBgChild = findChildrenByDisplayName(
2405
+ children,
2406
+ TrackBgNameKey
2407
+ );
2408
+ const trackFillChild = findChildrenByDisplayName(
2409
+ children,
2410
+ TrackFillNameKey
2411
+ );
2412
+ const barHeight = rest.h ?? 8;
2413
+ const bgEl = trackBgChild ? React11__namespace.default.cloneElement(trackBgChild, {
2414
+ gridArea: "1 / 1",
2415
+ h: barHeight,
2416
+ w: trackBgChild.props.w ?? true
2417
+ }) : /* @__PURE__ */ jsxRuntime.jsx(
2418
+ MotionDiv5,
2419
+ {
2420
+ "data-progress-bg": true,
2421
+ gridArea: "1 / 1",
2422
+ rounded: true,
2423
+ h: barHeight,
2424
+ w: true,
2425
+ bg: { base: "neutral.200", _dark: "neutral.700" }
2426
+ }
2427
+ );
2428
+ const fillEl = trackFillChild ? React11__namespace.default.cloneElement(trackFillChild, {
2429
+ gridArea: "1 / 1",
2430
+ h: barHeight,
2431
+ roundedLeft: 9999,
2432
+ roundedRight: width === "100%" ? 9999 : void 0,
2433
+ // Pass width via both animation and style for custom implementations
2434
+ animate: {
2435
+ ...trackFillChild.props.animate || {},
2436
+ width
2437
+ },
2438
+ style: {
2439
+ ...trackFillChild.props.style || {},
2440
+ width
2441
+ },
2442
+ progressWidth: width,
2443
+ progressPercent: progress,
2444
+ progressValue: value ?? 0,
2445
+ progressMax: max
2446
+ }) : /* @__PURE__ */ jsxRuntime.jsx(
2447
+ MotionDiv5,
2448
+ {
2449
+ "data-progress-bar": true,
2450
+ gridArea: "1 / 1",
2451
+ h: barHeight,
2452
+ roundedLeft: 9999,
2453
+ roundedRight: width === "100%" ? 9999 : void 0,
2454
+ animate: { width, background: barBackground },
2455
+ style: { width, background: barBackground }
2456
+ }
2457
+ );
2458
+ return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.LayoutGroup, { children: /* @__PURE__ */ jsxRuntime.jsxs(MotionDiv5, { layout: true, grid: true, cols: "1", rows: "1", w: true, ...rest, children: [
2459
+ bgEl,
2460
+ fillEl
2461
+ ] }) });
2462
+ }
2463
+ function TrackBg(props) {
2464
+ const { h, ...rest } = props;
2465
+ return /* @__PURE__ */ jsxRuntime.jsx(
2466
+ MotionDiv5,
2467
+ {
2468
+ "data-track-bg": true,
2469
+ gridArea: "1 / 1",
2470
+ rounded: true,
2471
+ h: h ?? 8,
2472
+ w: true,
2473
+ bg: { base: "neutral.200", _dark: "neutral.700" },
2474
+ ...rest
2475
+ }
2476
+ );
2477
+ }
2478
+ TrackBg.displayName = TrackBgNameKey;
2479
+ function TrackFill(props) {
2480
+ const { progressWidth, animate, style, h, ...rest } = props;
2481
+ const mergedAnimate = progressWidth ? animate && typeof animate === "object" && !Array.isArray(animate) ? { ...animate, width: progressWidth } : { width: progressWidth } : animate;
2482
+ const mergedStyle = progressWidth ? Object.assign({}, style, { width: progressWidth }) : style;
2483
+ return /* @__PURE__ */ jsxRuntime.jsx(
2484
+ MotionDiv5,
2485
+ {
2486
+ "data-track-fill": true,
2487
+ gridArea: "1 / 1",
2488
+ rounded: true,
2489
+ h: h ?? 8,
2490
+ bg: { base: "neutral.200", _dark: "neutral.700" },
2491
+ ...rest,
2492
+ animate: mergedAnimate,
2493
+ style: mergedStyle
2494
+ }
2495
+ );
2496
+ }
2497
+ TrackFill.displayName = TrackFillNameKey;
2498
+ var Base5 = base;
2499
+ var TooltipContainer = React11__namespace.default.forwardRef(function TooltipContainer2(props, ref) {
2500
+ const { children, className, style, ...rest } = props;
2501
+ return /* @__PURE__ */ jsxRuntime.jsx(
2502
+ Base5,
2503
+ {
2504
+ className,
2505
+ style,
2506
+ ref,
2507
+ role: "tooltip",
2508
+ ...rest,
2509
+ children
2510
+ }
2511
+ );
2512
+ });
2513
+ function Tooltip(props) {
2514
+ const {
2515
+ children,
2516
+ content,
2517
+ placement = "auto",
2518
+ interactive = true,
2519
+ disabled = false,
2520
+ showArrow = true,
2521
+ follow = false,
2522
+ offsetVal = 8,
2523
+ delay = 80,
2524
+ className
2525
+ } = props;
2526
+ const referenceRef = React11__namespace.default.useRef(null);
2527
+ const arrowRef = React11__namespace.default.useRef(null);
2528
+ const [open, setOpen] = React11__namespace.default.useState(false);
2529
+ const { x, y, refs, strategy, middlewareData, context } = react.useFloating({
2530
+ open,
2531
+ onOpenChange: setOpen,
2532
+ placement: placement === "auto" ? "top" : placement,
2533
+ middleware: [
2534
+ react.offset(offsetVal),
2535
+ react.flip(),
2536
+ react.shift({ padding: 6 }),
2537
+ react.arrow({ element: arrowRef })
2538
+ ],
2539
+ whileElementsMounted: react.autoUpdate,
2540
+ strategy: "fixed"
2541
+ });
2542
+ const hover = react.useHover(context, {
2543
+ delay: { open: delay, close: 120 },
2544
+ handleClose: react.safePolygon(),
2545
+ move: true
2546
+ });
2547
+ const focus = react.useFocus(context);
2548
+ const dismiss = react.useDismiss(context);
2549
+ const role = react.useRole(context, { role: "tooltip" });
2550
+ const { getReferenceProps, getFloatingProps } = react.useInteractions([
2551
+ hover,
2552
+ focus,
2553
+ dismiss,
2554
+ role
2555
+ ]);
2556
+ const referenceProps = getReferenceProps({});
2557
+ React11__namespace.default.useEffect(() => {
2558
+ if (!follow || !referenceRef.current) return;
2559
+ const el = referenceRef.current;
2560
+ const onMove = (e) => {
2561
+ const virtualElement = {
2562
+ getBoundingClientRect: () => new DOMRect(e.clientX, e.clientY, 0, 0),
2563
+ contextElement: document.body
2564
+ };
2565
+ refs.setReference(virtualElement);
2566
+ };
2567
+ el.addEventListener("pointermove", onMove);
2568
+ return () => {
2569
+ el.removeEventListener("pointermove", onMove);
2570
+ };
2571
+ }, [follow, refs]);
2572
+ const arrowX = middlewareData?.arrow?.x ?? 0;
2573
+ const arrowY = middlewareData?.arrow?.y ?? 0;
2574
+ const side = context.placement || "top";
2575
+ const ARROW_SIZE = 10;
2576
+ const anchorOffset = Math.max(ARROW_SIZE / 2 - 1, 3);
2577
+ const arrowAnchorStyle = side.startsWith("top") ? { bottom: -anchorOffset } : side.startsWith("bottom") ? { top: -anchorOffset } : side.startsWith("left") ? { right: -anchorOffset } : { left: -anchorOffset };
2578
+ const arrowStyle = side.startsWith("top") || side.startsWith("bottom") ? { left: arrowX || void 0, ...arrowAnchorStyle } : { top: arrowY || void 0, ...arrowAnchorStyle };
2579
+ const transformOrigin = side.startsWith("top") ? "center bottom" : side.startsWith("bottom") ? "center top" : side.startsWith("left") ? "right center" : side.startsWith("right") ? "left center" : "center";
2580
+ const childrenArray = React11__namespace.default.Children.toArray(children);
2581
+ const hasMultipleChildren = childrenArray.length > 1;
2582
+ let child;
2583
+ if (hasMultipleChildren) {
2584
+ child = /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "inline-block" }, children });
2585
+ } else {
2586
+ const only = React11__namespace.default.Children.only(children);
2587
+ const isDomElement = React11__namespace.default.isValidElement(only) && typeof only.type === "string";
2588
+ child = isDomElement ? only : (
2589
+ // Ensure the wrapper reliably captures mouseenter/pointerenter and can contain block elements
2590
+ /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "inline-block" }, children: only })
2591
+ );
2592
+ }
2593
+ const mergedRef = (node) => {
2594
+ referenceRef.current = node;
2595
+ if (!follow) {
2596
+ refs.setReference(node);
2597
+ }
2598
+ const childWithRef = child;
2599
+ const originalRef = childWithRef?.ref;
2600
+ if (typeof originalRef === "function") originalRef(node);
2601
+ else if (originalRef && "current" in originalRef)
2602
+ originalRef.current = node;
2603
+ };
2604
+ const refAttrs = referenceProps;
2605
+ const cloned = React11__namespace.default.cloneElement(
2606
+ child,
2607
+ {
2608
+ ...refAttrs,
2609
+ ref: mergedRef,
2610
+ "data-tooltip-ref": true
2611
+ }
2612
+ );
2613
+ if (disabled) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: cloned });
2614
+ const [isMounted, setIsMounted] = React11__namespace.default.useState(false);
2615
+ const closeTimerRef = React11__namespace.default.useRef(
2616
+ null
2617
+ );
2618
+ React11__namespace.default.useEffect(() => {
2619
+ if (closeTimerRef.current) {
2620
+ clearTimeout(closeTimerRef.current);
2621
+ closeTimerRef.current = null;
2622
+ }
2623
+ if (open) {
2624
+ setIsMounted(true);
2625
+ } else {
2626
+ closeTimerRef.current = setTimeout(() => {
2627
+ setIsMounted(false);
2628
+ closeTimerRef.current = null;
2629
+ }, 160);
2630
+ }
2631
+ return () => {
2632
+ if (closeTimerRef.current) {
2633
+ clearTimeout(closeTimerRef.current);
2634
+ closeTimerRef.current = null;
2635
+ }
2636
+ };
2637
+ }, [open]);
2638
+ let arrowEl = null;
2639
+ let floatingNode = null;
2640
+ const findRoleTooltipElement = (node) => {
2641
+ if (!React11__namespace.default.isValidElement(node)) return null;
2642
+ const el = node;
2643
+ if (el.props?.role === "tooltip") return el;
2644
+ const kids = el.props?.children;
2645
+ if (!kids) return null;
2646
+ const arr = React11__namespace.default.Children.toArray(kids);
2647
+ for (const c of arr) {
2648
+ if (React11__namespace.default.isValidElement(c) && c.props?.role === "tooltip") {
2649
+ return c;
2650
+ }
2651
+ }
2652
+ return null;
2653
+ };
2654
+ const isCustomTooltip = React11__namespace.default.isValidElement(content) && !!(content.type && content.type.isBlockTooltipContainer);
2655
+ const customEl = isCustomTooltip ? content : findRoleTooltipElement(content);
2656
+ const containerRef = React11__namespace.default.useRef(null);
2657
+ const [containerBg, setContainerBg] = React11__namespace.default.useState();
2658
+ React11__namespace.default.useEffect(() => {
2659
+ if (!(open || isMounted)) return;
2660
+ const el = containerRef.current;
2661
+ if (!el) return;
2662
+ try {
2663
+ const cs = getComputedStyle(el);
2664
+ const bg = cs.backgroundColor;
2665
+ if (bg && bg !== "transparent" && bg !== "rgba(0, 0, 0, 0)") {
2666
+ setContainerBg(bg);
2667
+ } else {
2668
+ setContainerBg("rgba(20,20,20,0.95)");
2669
+ }
2670
+ } catch {
2671
+ }
2672
+ }, [open, isMounted, isCustomTooltip]);
2673
+ if (isCustomTooltip) {
2674
+ const el = customEl;
2675
+ const childProps = el.props || {};
2676
+ const floatingProps = getFloatingProps({});
2677
+ const defaultStyles = {};
2678
+ if (childProps.bg === void 0 && childProps.background === void 0 && !(childProps.style?.background || childProps.style?.backgroundColor)) {
2679
+ defaultStyles.background = "rgba(20,20,20,0.95)";
2680
+ }
2681
+ if (childProps.color === void 0 && !childProps.style?.color) {
2682
+ defaultStyles.color = "white";
2683
+ }
2684
+ const hasPadding = childProps.p !== void 0 || childProps.padding !== void 0 || childProps.px !== void 0 || childProps.py !== void 0 || childProps.paddingLeft !== void 0 || childProps.paddingRight !== void 0 || childProps.paddingTop !== void 0 || childProps.paddingBottom !== void 0 || childProps.style?.padding !== void 0 || childProps.style?.paddingLeft !== void 0 || childProps.style?.paddingRight !== void 0 || childProps.style?.paddingTop !== void 0 || childProps.style?.paddingBottom !== void 0;
2685
+ if (!hasPadding) {
2686
+ defaultStyles.paddingLeft = "10px";
2687
+ defaultStyles.paddingRight = "10px";
2688
+ defaultStyles.paddingTop = "8px";
2689
+ defaultStyles.paddingBottom = "8px";
2690
+ }
2691
+ if (childProps.borderRadius === void 0 && childProps.rounded === void 0 && childProps.style?.borderRadius === void 0) {
2692
+ defaultStyles.borderRadius = "6px";
2693
+ }
2694
+ if (childProps.boxShadow === void 0 && childProps.shadow === void 0 && childProps.style?.boxShadow === void 0) {
2695
+ defaultStyles.boxShadow = "0 6px 18px rgba(0,0,0,0.18)";
2696
+ }
2697
+ if (childProps.fontSize === void 0 && childProps.style?.fontSize === void 0) {
2698
+ defaultStyles.fontSize = "13px";
2699
+ }
2700
+ const mergedClassName = [childProps.className, className ?? "tooltip-root"].filter(Boolean).join(" ");
2701
+ const mergedStyle = { ...defaultStyles, ...childProps.style };
2702
+ ({
2703
+ ...childProps,
2704
+ ...floatingProps});
2705
+ Object.keys(floatingProps).forEach((key) => {
2706
+ if (key.startsWith("on") && typeof floatingProps[key] === "function") {
2707
+ floatingProps[key];
2708
+ childProps[key];
2709
+ }
2710
+ });
2711
+ const originalRef = el.ref;
2712
+ const mergedFloatingRef = (node) => {
2713
+ refs.setFloating(node);
2714
+ if (typeof originalRef === "function") originalRef(node);
2715
+ else if (originalRef && typeof originalRef === "object")
2716
+ originalRef.current = node;
2717
+ };
2718
+ arrowEl = showArrow ? /* @__PURE__ */ jsxRuntime.jsx(
2719
+ "div",
2720
+ {
2721
+ ref: (node) => {
2722
+ arrowRef.current = node;
2723
+ },
2724
+ style: {
2725
+ position: "absolute",
2726
+ width: ARROW_SIZE,
2727
+ height: ARROW_SIZE,
2728
+ transform: "rotate(45deg) translateZ(0)",
2729
+ background: containerBg ?? "rgba(20,20,20,0.95)",
2730
+ ...arrowStyle
2731
+ },
2732
+ "data-arrow": true
2733
+ }
2734
+ ) : null;
2735
+ floatingNode = /* @__PURE__ */ jsxRuntime.jsxs(
2736
+ framerMotion.motion.div,
2737
+ {
2738
+ ref: mergedFloatingRef,
2739
+ ...floatingProps,
2740
+ className,
2741
+ style: {
2742
+ // Required runtime positioning (highest precedence - cannot be overridden)
2743
+ position: strategy,
2744
+ left: x || 0,
2745
+ top: y || 0,
2746
+ transformOrigin,
2747
+ pointerEvents: (open || isMounted) && interactive ? "auto" : "none",
2748
+ zIndex: 9999,
2749
+ maxWidth: 320,
2750
+ display: "inline-block",
2751
+ overflow: "visible"
2752
+ },
2753
+ initial: { opacity: 0, scale: 0.92 },
2754
+ animate: { opacity: open ? 1 : 0, scale: open ? 1 : 0.92 },
2755
+ transition: { type: "spring", stiffness: 520, damping: 34 },
2756
+ role: "tooltip",
2757
+ children: [
2758
+ (() => {
2759
+ const originalChildRef = el.ref;
2760
+ const mergedChildRef = (node) => {
2761
+ containerRef.current = node;
2762
+ if (typeof originalChildRef === "function") originalChildRef(node);
2763
+ else if (originalChildRef && typeof originalChildRef === "object")
2764
+ originalChildRef.current = node;
2765
+ };
2766
+ return React11__namespace.default.cloneElement(
2767
+ el,
2768
+ {
2769
+ // Spread childProps first
2770
+ ...childProps,
2771
+ ref: mergedChildRef,
2772
+ // Then override className with merged value (must be after ...childProps)
2773
+ className: mergedClassName,
2774
+ style: {
2775
+ // Apply inline defaults first, then user styles, then position
2776
+ ...mergedStyle,
2777
+ position: "relative"
2778
+ }
2779
+ },
2780
+ childProps.children
2781
+ );
2782
+ })(),
2783
+ arrowEl
2784
+ ]
2785
+ }
2786
+ );
2787
+ } else {
2788
+ arrowEl = showArrow ? /* @__PURE__ */ jsxRuntime.jsx(
2789
+ "div",
2790
+ {
2791
+ ref: (node) => {
2792
+ arrowRef.current = node;
2793
+ },
2794
+ style: {
2795
+ position: "absolute",
2796
+ width: ARROW_SIZE,
2797
+ height: ARROW_SIZE,
2798
+ transform: "rotate(45deg) translateZ(0)",
2799
+ background: containerBg ?? "rgba(20,20,20,0.95)",
2800
+ ...arrowStyle
2801
+ },
2802
+ "data-arrow": true
2803
+ }
2804
+ ) : null;
2805
+ floatingNode = /* @__PURE__ */ jsxRuntime.jsxs(
2806
+ framerMotion.motion.div,
2807
+ {
2808
+ ref: (node) => {
2809
+ refs.setFloating(node);
2810
+ },
2811
+ ...getFloatingProps({}),
2812
+ className,
2813
+ role: "tooltip",
2814
+ style: {
2815
+ position: strategy,
2816
+ left: x || 0,
2817
+ top: y || 0,
2818
+ transformOrigin,
2819
+ pointerEvents: (open || isMounted) && interactive ? "auto" : "none",
2820
+ zIndex: 9999,
2821
+ maxWidth: 320,
2822
+ display: "inline-block",
2823
+ overflow: "visible"
2824
+ },
2825
+ initial: { opacity: 0, scale: 0.92 },
2826
+ animate: { opacity: open ? 1 : 0, scale: open ? 1 : 0.92 },
2827
+ transition: { type: "spring", stiffness: 520, damping: 34 },
2828
+ children: [
2829
+ /* @__PURE__ */ jsxRuntime.jsx(
2830
+ Base5,
2831
+ {
2832
+ role: "tooltip",
2833
+ style: { position: "relative" },
2834
+ bg: "rgba(20,20,20,0.95)",
2835
+ color: "white",
2836
+ px: "10px",
2837
+ py: "8px",
2838
+ borderRadius: 6,
2839
+ boxShadow: "0 6px 18px rgba(0,0,0,0.18)",
2840
+ fontSize: 13,
2841
+ ref: containerRef,
2842
+ children: content
2843
+ }
2844
+ ),
2845
+ arrowEl
2846
+ ]
2847
+ }
2848
+ );
2849
+ }
2850
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2851
+ cloned,
2852
+ (open || isMounted) && reactDom.createPortal(
2853
+ floatingNode,
2854
+ props.portalContainer || document.getElementById("portal") || document.body
2855
+ )
2856
+ ] });
2857
+ }
2858
+ var Base6 = base;
2859
+ var Svg = motionTags.svg;
2860
+ var CheckboxBtn = motionTags.button;
2861
+ function Checkbox(props) {
2862
+ const { children, onClick, ...rest } = props;
2863
+ const [checked, setChecked] = React11__namespace.default.useState(false);
2864
+ const [indeterminate, setIndeterminate] = React11__namespace.default.useState(false);
2865
+ React11__namespace.default.useEffect(() => {
2866
+ setChecked(!!rest.checked);
2867
+ }, [rest.checked]);
2868
+ React11__namespace.default.useEffect(() => {
2869
+ setIndeterminate(!!rest.indeterminate);
2870
+ }, [rest.indeterminate]);
2871
+ const isIndeterminate = typeof rest.indeterminate === "boolean";
2872
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2873
+ Base6,
2874
+ {
2875
+ flex: true,
2876
+ alignI: true,
2877
+ gap: 2,
2878
+ cursor: "pointer",
2879
+ userSelect: "none",
2880
+ ...rest,
2881
+ onClick: () => rest.onChecked?.(!rest.checked),
2882
+ children: [
2883
+ /* @__PURE__ */ jsxRuntime.jsx(
2884
+ CheckboxBtn,
2885
+ {
2886
+ "data-checkbox": true,
2887
+ ...checked && { "data-checked": checked },
2888
+ w: "24px",
2889
+ p: 1,
2890
+ br: 6,
2891
+ cursor: "pointer",
2892
+ boxSizing: "border-box",
2893
+ outline: "none !important",
2894
+ bg: { base: "neutral.200", _dark: "neutral.700" },
2895
+ _checked: { bg: "blue.500", transition: ".14s background ease-out" },
2896
+ _active: { scale: 0.9 },
2897
+ color: "neutral.100",
2898
+ transition: ".14s background ease-out .1s",
2899
+ _focus: { boxShadow: "0 0 0 6px hsl(0 0% 100% / 0.05)" },
2900
+ children: /* @__PURE__ */ jsxRuntime.jsx(
2901
+ Svg,
2902
+ {
2903
+ fill: "none",
2904
+ width: "100%",
2905
+ viewBox: "0 0 24 24",
2906
+ stroke: "currentColor",
2907
+ strokeWidth: 4,
2908
+ children: /* @__PURE__ */ jsxRuntime.jsxs(framerMotion.AnimatePresence, { mode: "wait", children: [
2909
+ isIndeterminate && indeterminate && /* @__PURE__ */ jsxRuntime.jsx(
2910
+ framerMotion.motion.path,
2911
+ {
2912
+ initial: { scaleX: 0 },
2913
+ animate: { scaleX: 1 },
2914
+ exit: { scaleX: 0 },
2915
+ transition: {
2916
+ type: "tween",
2917
+ ease: "easeOut",
2918
+ duration: 0.3,
2919
+ delay: 0.2
2920
+ },
2921
+ strokeLinecap: "round",
2922
+ d: "M6 12 L18 12"
2923
+ },
2924
+ "indeterminate"
2925
+ ),
2926
+ !indeterminate && checked && /* @__PURE__ */ jsxRuntime.jsx(
2927
+ framerMotion.motion.path,
2928
+ {
2929
+ initial: { pathLength: 0 },
2930
+ animate: { pathLength: 1 },
2931
+ exit: { pathLength: 0 },
2932
+ transition: { type: "tween", ease: "easeOut", duration: 0.2 },
2933
+ strokeLinecap: "round",
2934
+ strokeLinejoin: "round",
2935
+ d: "M5 13l4 4L19 7"
2936
+ },
2937
+ "check"
2938
+ )
2939
+ ] })
2940
+ }
2941
+ )
2942
+ }
2943
+ ),
2944
+ children
2945
+ ]
2946
+ }
2947
+ );
2948
+ }
2949
+ var Hr = motionTags.hr;
2950
+ var Skeleton = motionTags.div;
2951
+ function Block(props) {
2952
+ const anyProps = props;
2953
+ const {
2954
+ _motion,
2955
+ sheenInterval = "1.4s",
2956
+ children,
2957
+ tooltip,
2958
+ ...rest
2959
+ } = anyProps;
2960
+ const fileInputRef = React11__namespace.useRef(null);
2961
+ const isLoading = anyProps.isLoading;
2962
+ const multiple = anyProps.multiple;
2963
+ const is = anyProps.is;
2964
+ const extract = extractElType(is, anyProps);
2965
+ const [Comp, initialStyles] = extractElAndStyles(extract, props);
2966
+ const icons = getIcons(extract, props);
2967
+ let component = /* @__PURE__ */ jsxRuntime.jsx(framerMotion.MotionConfig, { transition: _motion, children: extract.isHr ? /* @__PURE__ */ jsxRuntime.jsx(Hr, { w: true, py: 2, color: "neutral.300", ...anyProps }) : extract.isProgress ? /* @__PURE__ */ jsxRuntime.jsx(Progress, { ...anyProps }) : extract.isDrawer ? /* @__PURE__ */ jsxRuntime.jsx(Drawer, { ...anyProps }) : extract.isAccordion ? /* @__PURE__ */ jsxRuntime.jsx(accordion_default, { ...anyProps }) : extract.isMenu ? /* @__PURE__ */ jsxRuntime.jsx(Menu, { ...anyProps }) : extract.isSwitch ? /* @__PURE__ */ jsxRuntime.jsx(switch_default, { ...anyProps }) : extract.isRadio ? /* @__PURE__ */ jsxRuntime.jsx(Radio, { ...anyProps }) : extract.isInput ? /* @__PURE__ */ jsxRuntime.jsx(Input, { ...anyProps }) : extract.isTextarea ? /* @__PURE__ */ jsxRuntime.jsx(Textarea, { ...anyProps }) : extract.isCheckbox ? /* @__PURE__ */ jsxRuntime.jsx(Checkbox, { ...anyProps }) : extract.isSkeleton ? /* @__PURE__ */ jsxRuntime.jsx(
2968
+ Skeleton,
2969
+ {
2970
+ ...anyProps.as === "circle" ? { br: "50%", size: 40 } : {
2971
+ height: 20,
2972
+ width: "100%",
2973
+ backgroundSize: "200% 100%",
2974
+ overflow: "hidden"
2975
+ },
2976
+ backgroundColor: { base: "neutral.300", _dark: "neutral.700" },
2977
+ backgroundImage: {
2978
+ base: `linear-gradient(
2979
+ 90deg,
2980
+ hsla(220, 8.94%, 66.08%, 0) 0%,
2981
+ {colors.neutral.100/80} 50%,
2982
+ hsla(220, 8.94%, 66.08%, 0) 100%
2983
+ )`,
2984
+ _dark: `linear-gradient(
2985
+ 90deg,
2986
+ hsla(220, 8.94%, 66.08%, 0) 0%,
2987
+ {colors.neutral.500/80} 50%,
2988
+ hsla(220, 8.94%, 66.08%, 0) 100%
2989
+ )`
2990
+ },
2991
+ backgroundRepeat: "no-repeat",
2992
+ backgroundSize: "200% 100%",
2993
+ animation: `sheen ${sheenInterval} infinite linear`,
2994
+ ...anyProps
2995
+ }
2996
+ ) : extract.filepickerAllowed ? /* @__PURE__ */ jsxRuntime.jsxs("div", { onClick: () => fileInputRef.current?.click(), children: [
2997
+ React11__namespace.createElement(
2998
+ Comp,
2999
+ {
3000
+ cursor: "pointer",
3001
+ ...isLoading && { "data-loading": isLoading },
3002
+ onContextMenu: (e) => e.preventDefault(),
3003
+ ...initialStyles
3004
+ },
3005
+ icons.leftIcon,
3006
+ children,
3007
+ icons.rightIcon
3008
+ ),
3009
+ /* @__PURE__ */ jsxRuntime.jsx(
3010
+ "input",
3011
+ {
3012
+ type: "file",
3013
+ ref: fileInputRef,
3014
+ multiple,
3015
+ accept: anyProps.accept,
3016
+ style: { display: "none" },
3017
+ onChange: async (e) => {
3018
+ const files = Array.from(e.target.files ?? []);
3019
+ const selectedFiles = files.length ? await prepareFiles(files) : [];
3020
+ if (anyProps.onChange) {
3021
+ anyProps.onChange(selectedFiles);
3022
+ }
3023
+ },
3024
+ value: ""
3025
+ }
3026
+ )
3027
+ ] }) : React11__namespace.createElement(
3028
+ Comp,
3029
+ {
3030
+ ...isLoading && { "data-loading": isLoading },
3031
+ onContextMenu: (e) => e.preventDefault(),
3032
+ ...initialStyles
3033
+ },
3034
+ icons.leftIcon,
3035
+ children,
3036
+ icons.rightIcon
3037
+ ) });
3038
+ if (tooltip) {
3039
+ const tooltipContent = typeof tooltip === "boolean" ? rest.content : tooltip;
3040
+ const tooltipProps = { ...rest, content: tooltipContent };
3041
+ component = /* @__PURE__ */ jsxRuntime.jsx(Tooltip, { ...tooltipProps, children: component });
3042
+ }
3043
+ if (rest.portal) {
3044
+ const portalContainer = rest.portalContainer;
3045
+ const fallback = document.getElementById("portal") || document.body;
3046
+ const container = portalContainer ?? fallback;
3047
+ return reactDom.createPortal(
3048
+ component,
3049
+ container
3050
+ );
3051
+ } else {
3052
+ return component;
3053
+ }
3054
+ }
3055
+ TooltipContainer.isBlockTooltipContainer = true;
3056
+ MenuContainer.isBlockMenuContainer = true;
3057
+ var TooltipNamespace = { Container: TooltipContainer };
3058
+ var MenuNamespace = { Container: MenuContainer };
3059
+ var InputNamespace = {
3060
+ Label: Label2,
3061
+ RightSide,
3062
+ LeftIcon
3063
+ };
3064
+ var TextareaNamespace = {
3065
+ Label
3066
+ };
3067
+ var RadioNamespace = {
3068
+ Item
3069
+ };
3070
+ var SwitchNamespace = { Track, Thumb };
3071
+ var AccordionNamespace = {
3072
+ Item: Item2
3073
+ };
3074
+ var DrawerNamespace = {
3075
+ CloseBtn,
3076
+ BtnGroup
3077
+ };
3078
+ var ProgressNamespace = {
3079
+ TrackFill,
3080
+ TrackBg
3081
+ };
3082
+ var CompoundBlock = Object.assign(Block, {
3083
+ Accordion: AccordionNamespace,
3084
+ Progress: ProgressNamespace,
3085
+ Textarea: TextareaNamespace,
3086
+ Tooltip: TooltipNamespace,
3087
+ Switch: SwitchNamespace,
3088
+ Drawer: DrawerNamespace,
3089
+ Menu: MenuNamespace,
3090
+ Input: InputNamespace,
3091
+ Radio: RadioNamespace
3092
+ });
3093
+ var block_default = CompoundBlock;
3094
+
3095
+ // src/react/index.ts
3096
+ function useDebounce(value, delay = 500) {
3097
+ const [debouncedValue, setDebouncedValue] = React11__namespace.default.useState(value);
3098
+ React11__namespace.default.useEffect(() => {
3099
+ const handler = setTimeout(() => {
3100
+ setDebouncedValue(value);
3101
+ }, delay);
3102
+ return () => {
3103
+ clearTimeout(handler);
3104
+ };
3105
+ }, [value, delay]);
3106
+ return debouncedValue;
3107
+ }
3108
+ function useThrottle(value, interval = 500) {
3109
+ const [throttledValue, setThrottledValue] = React11__namespace.default.useState(value);
3110
+ const lastUpdate = React11__namespace.default.useRef(0);
3111
+ const timeoutRef = React11__namespace.default.useRef(null);
3112
+ React11__namespace.default.useEffect(() => {
3113
+ const now = Date.now();
3114
+ const timeSinceLastUpdate = now - lastUpdate.current;
3115
+ if (timeSinceLastUpdate >= interval) {
3116
+ setThrottledValue(value);
3117
+ lastUpdate.current = now;
3118
+ } else {
3119
+ if (timeoutRef.current) {
3120
+ clearTimeout(timeoutRef.current);
3121
+ }
3122
+ timeoutRef.current = setTimeout(() => {
3123
+ setThrottledValue(value);
3124
+ lastUpdate.current = Date.now();
3125
+ }, interval - timeSinceLastUpdate);
3126
+ }
3127
+ return () => {
3128
+ if (timeoutRef.current) {
3129
+ clearTimeout(timeoutRef.current);
3130
+ }
3131
+ };
3132
+ }, [value, interval]);
3133
+ return throttledValue;
3134
+ }
3135
+ function useMatchMedia2(queries, defaultValues = []) {
3136
+ const initialValues = defaultValues.length ? defaultValues : Array(queries.length).fill(false);
3137
+ const mediaQueryLists = queries.map((q) => window.matchMedia(q));
3138
+ const getValue = () => {
3139
+ const matchedQueries = mediaQueryLists.map((mql) => mql.matches);
3140
+ return matchedQueries;
3141
+ };
3142
+ const [value, setValue] = React11__namespace.default.useState(getValue);
3143
+ React11__namespace.default.useLayoutEffect(() => {
3144
+ const handler = () => setValue(getValue);
3145
+ mediaQueryLists.forEach((mql) => mql.addListener(handler));
3146
+ return () => mediaQueryLists.forEach((mql) => mql.removeListener(handler));
3147
+ }, []);
3148
+ if (typeof window === "undefined") return initialValues;
3149
+ return value;
3150
+ }
3151
+
3152
+ exports.default = block_default;
3153
+ exports.useDebounce = useDebounce;
3154
+ exports.useMatchMedia = useMatchMedia2;
3155
+ exports.useThrottle = useThrottle;