@yuhuanowo/yunui 0.1.4

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,1839 @@
1
+ "use client";
2
+ import { cn } from './chunk-DRZ7UCRU.js';
3
+ import { useYunUI } from './chunk-XZGNL5A6.js';
4
+ import * as React from 'react';
5
+ import { forwardRef, useState, useEffect, useRef, useCallback } from 'react';
6
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
7
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
8
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
9
+ import * as SelectPrimitive from '@radix-ui/react-select';
10
+ import * as SliderPrimitive from '@radix-ui/react-slider';
11
+ import * as ProgressPrimitive from '@radix-ui/react-progress';
12
+ import * as TabsPrimitive from '@radix-ui/react-tabs';
13
+ import * as AvatarPrimitive from '@radix-ui/react-avatar';
14
+ import { motion, AnimatePresence, useSpring, useTransform } from 'framer-motion';
15
+ import { Check, Loader2, AlertCircle, X, ChevronDown, ChevronRight, CheckCircle2, CheckCircle, Info, RefreshCw, Trash2, Search, ArrowRight, AlertTriangle } from 'lucide-react';
16
+ import { createPortal } from 'react-dom';
17
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
18
+ import * as Primitive from '@radix-ui/react-collapsible';
19
+ import * as PopoverPrimitive from '@radix-ui/react-popover';
20
+ import { Toaster as Toaster$1, toast as toast$1 } from 'sonner';
21
+
22
+ function useEscapeKey(onEscape, enabled = true) {
23
+ const onEscapeRef = useRef(onEscape);
24
+ onEscapeRef.current = onEscape;
25
+ const enabledRef = useRef(enabled);
26
+ enabledRef.current = enabled;
27
+ const handleKeyDown = useCallback(
28
+ (event) => {
29
+ if (!enabledRef.current) return;
30
+ if (event.key === "Escape") {
31
+ event.preventDefault();
32
+ event.stopPropagation();
33
+ onEscapeRef.current();
34
+ }
35
+ },
36
+ []
37
+ // No dependencies - uses refs
38
+ );
39
+ useEffect(() => {
40
+ document.addEventListener("keydown", handleKeyDown, true);
41
+ return () => {
42
+ document.removeEventListener("keydown", handleKeyDown, true);
43
+ };
44
+ }, [handleKeyDown]);
45
+ }
46
+ var scrollLockCount = 0;
47
+ var originalOverflow = "";
48
+ function useBodyScrollLock(locked = true) {
49
+ const hasLockedRef = useRef(false);
50
+ useEffect(() => {
51
+ if (!locked) {
52
+ if (hasLockedRef.current) {
53
+ scrollLockCount--;
54
+ hasLockedRef.current = false;
55
+ if (scrollLockCount === 0) {
56
+ document.body.style.overflow = originalOverflow;
57
+ originalOverflow = "";
58
+ }
59
+ }
60
+ return;
61
+ }
62
+ if (!hasLockedRef.current) {
63
+ if (scrollLockCount === 0) {
64
+ originalOverflow = document.body.style.overflow;
65
+ }
66
+ scrollLockCount++;
67
+ document.body.style.overflow = "hidden";
68
+ hasLockedRef.current = true;
69
+ }
70
+ return () => {
71
+ if (hasLockedRef.current) {
72
+ scrollLockCount--;
73
+ hasLockedRef.current = false;
74
+ if (scrollLockCount === 0) {
75
+ document.body.style.overflow = originalOverflow;
76
+ originalOverflow = "";
77
+ }
78
+ }
79
+ };
80
+ }, [locked]);
81
+ }
82
+ function useModalBehavior(isOpen, onClose) {
83
+ useEscapeKey(onClose, isOpen);
84
+ useBodyScrollLock(isOpen);
85
+ }
86
+
87
+ // src/primitives/modal/constants.ts
88
+ var Z_INDEX = {
89
+ MODAL: 50,
90
+ CONFIRM_DIALOG: 60};
91
+ var SIZE_CLASSES = {
92
+ sm: "max-w-sm",
93
+ // 384px
94
+ md: "max-w-md",
95
+ // 448px
96
+ lg: "max-w-lg",
97
+ // 512px
98
+ xl: "max-w-xl",
99
+ // 576px
100
+ "2xl": "max-w-2xl",
101
+ // 672px
102
+ "3xl": "max-w-3xl",
103
+ // 768px
104
+ "4xl": "max-w-4xl",
105
+ // 896px
106
+ "5xl": "max-w-5xl",
107
+ // 1024px
108
+ "6xl": "max-w-6xl",
109
+ // 1152px
110
+ full: "max-w-[95vw]"
111
+ // 95% viewport width
112
+ };
113
+ var ANIMATION_DURATION = 150;
114
+ var DEFAULT_MAX_HEIGHT = "85vh";
115
+ var closeIdCounter = 0;
116
+ function Modal({
117
+ isOpen,
118
+ onClose,
119
+ title,
120
+ subtitle,
121
+ children,
122
+ footer,
123
+ size = "lg",
124
+ className,
125
+ showCloseButton = true,
126
+ isClosing: externalIsClosing,
127
+ setIsClosing: externalSetIsClosing,
128
+ showUnsavedBadge = false,
129
+ maxHeight = DEFAULT_MAX_HEIGHT,
130
+ onBackdropClick
131
+ }) {
132
+ const t = useYunUI().useT("components.modal");
133
+ const modalRef = useRef(null);
134
+ const timeoutRef = useRef(null);
135
+ const closeIdRef = useRef(0);
136
+ const [internalIsClosing, setInternalIsClosing] = useState(false);
137
+ const [mounted, setMounted] = useState(false);
138
+ const isClosing = externalIsClosing ?? internalIsClosing;
139
+ useEffect(() => {
140
+ setMounted(true);
141
+ return () => setMounted(false);
142
+ }, []);
143
+ useEffect(() => {
144
+ return () => {
145
+ if (timeoutRef.current) {
146
+ clearTimeout(timeoutRef.current);
147
+ timeoutRef.current = null;
148
+ }
149
+ };
150
+ }, []);
151
+ const isClosingRef = useRef(isClosing);
152
+ isClosingRef.current = isClosing;
153
+ const onCloseRef = useRef(onClose);
154
+ onCloseRef.current = onClose;
155
+ const externalSetIsClosingRef = useRef(externalSetIsClosing);
156
+ externalSetIsClosingRef.current = externalSetIsClosing;
157
+ const handleClose = useCallback(() => {
158
+ if (isClosingRef.current) return;
159
+ if (timeoutRef.current) {
160
+ clearTimeout(timeoutRef.current);
161
+ timeoutRef.current = null;
162
+ }
163
+ const currentCloseId = ++closeIdCounter;
164
+ closeIdRef.current = currentCloseId;
165
+ const executeClose = () => {
166
+ if (closeIdRef.current === currentCloseId) {
167
+ onCloseRef.current();
168
+ if (externalSetIsClosingRef.current) {
169
+ externalSetIsClosingRef.current(false);
170
+ } else {
171
+ setInternalIsClosing(false);
172
+ }
173
+ timeoutRef.current = null;
174
+ }
175
+ };
176
+ if (externalSetIsClosingRef.current) {
177
+ externalSetIsClosingRef.current(true);
178
+ timeoutRef.current = setTimeout(executeClose, ANIMATION_DURATION);
179
+ } else {
180
+ setInternalIsClosing(true);
181
+ timeoutRef.current = setTimeout(executeClose, ANIMATION_DURATION);
182
+ }
183
+ }, []);
184
+ useEscapeKey(handleClose, isOpen);
185
+ useBodyScrollLock(isOpen);
186
+ useEffect(() => {
187
+ if (isOpen && modalRef.current) {
188
+ const timer = setTimeout(() => {
189
+ modalRef.current?.focus();
190
+ }, 0);
191
+ return () => clearTimeout(timer);
192
+ }
193
+ }, [isOpen]);
194
+ useEffect(() => {
195
+ if (isOpen && internalIsClosing) {
196
+ setInternalIsClosing(false);
197
+ }
198
+ }, [isOpen, internalIsClosing]);
199
+ const handleBackdropClick = useCallback((e) => {
200
+ if (e.target === e.currentTarget) {
201
+ if (onBackdropClick) {
202
+ onBackdropClick();
203
+ } else {
204
+ handleClose();
205
+ }
206
+ }
207
+ }, [onBackdropClick, handleClose]);
208
+ if (!isOpen || !mounted) return null;
209
+ const sizeClass = SIZE_CLASSES[size] ?? SIZE_CLASSES.lg;
210
+ const modalContent = /* @__PURE__ */ jsxs(
211
+ "div",
212
+ {
213
+ className: cn(
214
+ "fixed inset-0 flex items-center justify-center p-4 transition-opacity",
215
+ isClosing ? "opacity-0 pointer-events-none" : "opacity-100"
216
+ ),
217
+ style: { zIndex: Z_INDEX.MODAL },
218
+ onClick: handleBackdropClick,
219
+ role: "dialog",
220
+ "aria-modal": "true",
221
+ "aria-labelledby": "modal-title",
222
+ children: [
223
+ /* @__PURE__ */ jsx(
224
+ "div",
225
+ {
226
+ className: cn(
227
+ "absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity",
228
+ isClosing ? "opacity-0" : "opacity-100"
229
+ ),
230
+ onClick: handleClose,
231
+ "aria-hidden": "true"
232
+ }
233
+ ),
234
+ /* @__PURE__ */ jsxs(
235
+ "div",
236
+ {
237
+ ref: modalRef,
238
+ className: cn(
239
+ "card relative w-full shadow-2xl flex flex-col transition-all",
240
+ sizeClass,
241
+ isClosing ? "scale-95 opacity-0" : "scale-100 opacity-100",
242
+ className
243
+ ),
244
+ style: { maxHeight },
245
+ onClick: (e) => e.stopPropagation(),
246
+ tabIndex: -1,
247
+ children: [
248
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b border-border shrink-0", children: [
249
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1 min-w-0", children: [
250
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
251
+ /* @__PURE__ */ jsx("h2", { id: "modal-title", className: "text-lg font-semibold truncate", children: title }),
252
+ showUnsavedBadge && /* @__PURE__ */ jsx("span", { className: "badge bg-amber-500/10 text-amber-600 border-amber-500/20 shrink-0", children: t("unsaved") })
253
+ ] }),
254
+ subtitle && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground truncate", children: subtitle })
255
+ ] }),
256
+ showCloseButton && /* @__PURE__ */ jsx(
257
+ Button,
258
+ {
259
+ variant: "ghost",
260
+ size: "sm",
261
+ onClick: handleClose,
262
+ className: "p-2 shrink-0",
263
+ "aria-label": t("close"),
264
+ children: /* @__PURE__ */ jsx(X, { size: 20 })
265
+ }
266
+ )
267
+ ] }),
268
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-6", children }),
269
+ footer && /* @__PURE__ */ jsx("div", { className: "p-4 border-t border-border bg-muted/20 shrink-0", children: footer })
270
+ ]
271
+ }
272
+ )
273
+ ]
274
+ }
275
+ );
276
+ return createPortal(modalContent, document.body);
277
+ }
278
+ var closeIdCounter2 = 0;
279
+ var variantConfig = {
280
+ danger: {
281
+ iconBg: "bg-red-100 dark:bg-red-900/30",
282
+ iconColor: "text-red-600 dark:text-red-400",
283
+ buttonVariant: "red",
284
+ Icon: Trash2
285
+ },
286
+ warning: {
287
+ iconBg: "bg-amber-100 dark:bg-amber-900/30",
288
+ iconColor: "text-amber-600 dark:text-amber-400",
289
+ buttonVariant: "amber",
290
+ Icon: RefreshCw
291
+ },
292
+ info: {
293
+ iconBg: "bg-blue-100 dark:bg-blue-900/30",
294
+ iconColor: "text-blue-600 dark:text-blue-400",
295
+ buttonVariant: "default",
296
+ Icon: Info
297
+ },
298
+ success: {
299
+ iconBg: "bg-green-100 dark:bg-green-900/30",
300
+ iconColor: "text-green-600 dark:text-green-400",
301
+ buttonVariant: "default",
302
+ Icon: CheckCircle
303
+ }
304
+ };
305
+ function ConfirmModal({
306
+ isOpen,
307
+ title,
308
+ subtitle,
309
+ message,
310
+ variant = "warning",
311
+ confirmText,
312
+ cancelText,
313
+ isLoading = false,
314
+ onConfirm,
315
+ onClose,
316
+ className,
317
+ icon
318
+ }) {
319
+ const t = useYunUI().useT("components.confirmModal");
320
+ const confirmButtonRef = useRef(null);
321
+ const timeoutRef = useRef(null);
322
+ const closeIdRef = useRef(0);
323
+ const [isClosing, setIsClosing] = useState(false);
324
+ const [mounted, setMounted] = useState(false);
325
+ const config = variantConfig[variant];
326
+ const _confirmText = confirmText ?? t("confirm");
327
+ const _cancelText = cancelText ?? t("cancel");
328
+ useEffect(() => {
329
+ setMounted(true);
330
+ return () => setMounted(false);
331
+ }, []);
332
+ useEffect(() => {
333
+ return () => {
334
+ if (timeoutRef.current) {
335
+ clearTimeout(timeoutRef.current);
336
+ timeoutRef.current = null;
337
+ }
338
+ };
339
+ }, []);
340
+ const isClosingRef = useRef(isClosing);
341
+ isClosingRef.current = isClosing;
342
+ const isLoadingRef = useRef(isLoading);
343
+ isLoadingRef.current = isLoading;
344
+ const onCloseRef = useRef(onClose);
345
+ onCloseRef.current = onClose;
346
+ const handleClose = useCallback(() => {
347
+ if (isClosingRef.current || isLoadingRef.current) return;
348
+ if (timeoutRef.current) {
349
+ clearTimeout(timeoutRef.current);
350
+ timeoutRef.current = null;
351
+ }
352
+ const currentCloseId = ++closeIdCounter2;
353
+ closeIdRef.current = currentCloseId;
354
+ setIsClosing(true);
355
+ timeoutRef.current = setTimeout(() => {
356
+ if (closeIdRef.current === currentCloseId) {
357
+ onCloseRef.current();
358
+ setIsClosing(false);
359
+ timeoutRef.current = null;
360
+ }
361
+ }, ANIMATION_DURATION);
362
+ }, []);
363
+ useEscapeKey(handleClose, isOpen);
364
+ useBodyScrollLock(isOpen);
365
+ useEffect(() => {
366
+ if (isOpen) {
367
+ const timer = setTimeout(() => {
368
+ confirmButtonRef.current?.focus();
369
+ }, 0);
370
+ return () => clearTimeout(timer);
371
+ }
372
+ }, [isOpen]);
373
+ useEffect(() => {
374
+ if (isOpen && isClosing) {
375
+ setIsClosing(false);
376
+ }
377
+ }, [isOpen, isClosing]);
378
+ if (!isOpen || !mounted) return null;
379
+ const Icon2 = config.Icon;
380
+ const modalContent = /* @__PURE__ */ jsxs(
381
+ "div",
382
+ {
383
+ className: cn(
384
+ "fixed inset-0 flex items-center justify-center p-4 transition-opacity",
385
+ isClosing ? "opacity-0 pointer-events-none" : "opacity-100"
386
+ ),
387
+ style: { zIndex: Z_INDEX.CONFIRM_DIALOG },
388
+ role: "dialog",
389
+ "aria-modal": "true",
390
+ "aria-labelledby": "confirm-modal-title",
391
+ "aria-describedby": "confirm-modal-description",
392
+ children: [
393
+ /* @__PURE__ */ jsx(
394
+ "div",
395
+ {
396
+ className: cn(
397
+ "absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity",
398
+ isClosing ? "opacity-0" : "opacity-100"
399
+ ),
400
+ onClick: handleClose,
401
+ "aria-hidden": "true"
402
+ }
403
+ ),
404
+ /* @__PURE__ */ jsx(
405
+ "div",
406
+ {
407
+ className: cn(
408
+ "card relative w-full max-w-sm shadow-2xl transition-all",
409
+ isClosing ? "scale-95 opacity-0" : "scale-100 opacity-100",
410
+ className
411
+ ),
412
+ onClick: (e) => e.stopPropagation(),
413
+ children: /* @__PURE__ */ jsxs("div", { className: "p-5", children: [
414
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 mb-4", children: [
415
+ /* @__PURE__ */ jsx(
416
+ "div",
417
+ {
418
+ className: cn(
419
+ "w-10 h-10 rounded-full flex items-center justify-center shrink-0",
420
+ config.iconBg
421
+ ),
422
+ children: icon || /* @__PURE__ */ jsx(Icon2, { size: 20, className: config.iconColor })
423
+ }
424
+ ),
425
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
426
+ /* @__PURE__ */ jsx("h3", { id: "confirm-modal-title", className: "font-semibold truncate", children: title }),
427
+ subtitle && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground truncate", children: subtitle })
428
+ ] })
429
+ ] }),
430
+ /* @__PURE__ */ jsx(
431
+ "div",
432
+ {
433
+ id: "confirm-modal-description",
434
+ className: "text-sm text-muted-foreground mb-4",
435
+ children: message
436
+ }
437
+ ),
438
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
439
+ /* @__PURE__ */ jsx(
440
+ Button,
441
+ {
442
+ onClick: handleClose,
443
+ disabled: isLoading,
444
+ variant: "secondary",
445
+ className: "flex-1",
446
+ children: _cancelText
447
+ }
448
+ ),
449
+ /* @__PURE__ */ jsx(
450
+ Button,
451
+ {
452
+ ref: confirmButtonRef,
453
+ onClick: onConfirm,
454
+ disabled: isLoading,
455
+ variant: config.buttonVariant,
456
+ className: "flex-1",
457
+ children: isLoading ? /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
458
+ /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
459
+ t("processing")
460
+ ] }) : _confirmText
461
+ }
462
+ )
463
+ ] })
464
+ ] })
465
+ }
466
+ )
467
+ ]
468
+ }
469
+ );
470
+ return createPortal(modalContent, document.body);
471
+ }
472
+ function DeleteConfirmModal({
473
+ itemName,
474
+ ...props
475
+ }) {
476
+ const t = useYunUI().useT("components.confirmModal");
477
+ return /* @__PURE__ */ jsx(
478
+ ConfirmModal,
479
+ {
480
+ variant: "danger",
481
+ title: t("deleteQuestion"),
482
+ confirmText: t("delete"),
483
+ message: /* @__PURE__ */ jsx(Fragment, { children: t("deleteMessage", { item: itemName }) }),
484
+ ...props
485
+ }
486
+ );
487
+ }
488
+ function RegenerateConfirmModal({
489
+ itemName,
490
+ ...props
491
+ }) {
492
+ const t = useYunUI().useT("components.confirmModal");
493
+ return /* @__PURE__ */ jsx(
494
+ ConfirmModal,
495
+ {
496
+ variant: "warning",
497
+ title: t("regenerateQuestion"),
498
+ subtitle: t("actionCannotBeUndone"),
499
+ confirmText: t("regenerate"),
500
+ message: /* @__PURE__ */ jsx(Fragment, { children: t("regenerateMessage", { item: itemName }) }),
501
+ ...props
502
+ }
503
+ );
504
+ }
505
+ function Sheet({ open, onClose, children, title }) {
506
+ const [mounted, setMounted] = useState(false);
507
+ useEffect(() => {
508
+ setMounted(true);
509
+ return () => setMounted(false);
510
+ }, []);
511
+ useModalBehavior(open, onClose);
512
+ if (!mounted) return null;
513
+ return createPortal(
514
+ /* @__PURE__ */ jsx(AnimatePresence, { children: open && /* @__PURE__ */ jsxs(Fragment, { children: [
515
+ /* @__PURE__ */ jsx(
516
+ motion.div,
517
+ {
518
+ initial: { opacity: 0 },
519
+ animate: { opacity: 1 },
520
+ exit: { opacity: 0 },
521
+ transition: { duration: 0.2 },
522
+ className: "fixed inset-0 bg-black/20 backdrop-blur-sm lg:hidden",
523
+ style: { zIndex: 40 },
524
+ onClick: onClose,
525
+ "aria-hidden": "true"
526
+ },
527
+ "sheet-backdrop"
528
+ ),
529
+ /* @__PURE__ */ jsxs(
530
+ motion.div,
531
+ {
532
+ initial: { x: "100%" },
533
+ animate: { x: 0 },
534
+ exit: { x: "100%" },
535
+ transition: { type: "spring", damping: 30, stiffness: 300 },
536
+ className: "fixed inset-y-0 right-0 w-[85vw] min-w-72 max-w-sm bg-card shadow-xl flex flex-col lg:hidden",
537
+ style: { zIndex: 50 },
538
+ onClick: (e) => e.stopPropagation(),
539
+ children: [
540
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-4 border-b border-border shrink-0", children: [
541
+ title && /* @__PURE__ */ jsx("h2", { className: "font-semibold text-sm", children: title }),
542
+ /* @__PURE__ */ jsx(
543
+ "button",
544
+ {
545
+ onClick: onClose,
546
+ className: "p-2 rounded-lg hover:bg-muted text-muted-foreground hover:text-foreground transition-colors ml-auto",
547
+ "aria-label": "Close",
548
+ children: /* @__PURE__ */ jsx(X, { size: 18 })
549
+ }
550
+ )
551
+ ] }),
552
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto", children })
553
+ ]
554
+ },
555
+ "sheet-panel"
556
+ )
557
+ ] }) }),
558
+ document.body
559
+ );
560
+ }
561
+ var Checkbox = forwardRef(
562
+ ({ checked, onCheckedChange, disabled = false, className = "", id }, ref) => {
563
+ return /* @__PURE__ */ jsx(
564
+ "button",
565
+ {
566
+ ref,
567
+ type: "button",
568
+ role: "checkbox",
569
+ "aria-checked": checked,
570
+ id,
571
+ onClick: () => !disabled && onCheckedChange(!checked),
572
+ disabled,
573
+ className: `
574
+ w-4 h-4 rounded border-2 flex items-center justify-center
575
+ transition-all duration-200 ease-in-out
576
+ ${checked ? "bg-primary border-primary text-primary-foreground" : "border-slate-300 dark:border-slate-600 bg-transparent hover:border-primary/50"}
577
+ ${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
578
+ ${className}
579
+ `,
580
+ children: checked && /* @__PURE__ */ jsx(Check, { size: 12, strokeWidth: 3 })
581
+ }
582
+ );
583
+ }
584
+ );
585
+ Checkbox.displayName = "Checkbox";
586
+ function Combobox({
587
+ options,
588
+ value,
589
+ onChange,
590
+ placeholder,
591
+ className = "",
592
+ disabled = false,
593
+ allowCustom = true,
594
+ creatableText
595
+ }) {
596
+ const { Image: Image2, useT } = useYunUI();
597
+ const t = useT("common.combobox");
598
+ const resolvedPlaceholder = placeholder || t("placeholder");
599
+ const resolvedCreatableText = creatableText || t("creatableText", { value: "" });
600
+ const [isOpen, setIsOpen] = useState(false);
601
+ const [inputValue, setInputValue] = useState(value || "");
602
+ const containerRef = useRef(null);
603
+ const inputRef = useRef(null);
604
+ useEffect(() => {
605
+ const selectedOption2 = options.find((o) => o.value === value);
606
+ setInputValue(selectedOption2?.label || value || "");
607
+ }, [value, options]);
608
+ useEffect(() => {
609
+ const handleClickOutside = (e) => {
610
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
611
+ setIsOpen(false);
612
+ }
613
+ };
614
+ document.addEventListener("mousedown", handleClickOutside);
615
+ return () => document.removeEventListener("mousedown", handleClickOutside);
616
+ }, []);
617
+ const filteredOptions = inputValue ? options.filter(
618
+ (o) => o.label.toLowerCase().includes(inputValue.toLowerCase()) || o.value.toLowerCase().includes(inputValue.toLowerCase())
619
+ ) : options;
620
+ const canCreateNew = allowCustom && inputValue && !options.some(
621
+ (o) => o.value.toLowerCase() === inputValue.toLowerCase() || o.label.toLowerCase() === inputValue.toLowerCase()
622
+ );
623
+ const handleSelect = (selectedValue) => {
624
+ onChange(selectedValue);
625
+ setIsOpen(false);
626
+ };
627
+ const handleInputChange = (e) => {
628
+ setInputValue(e.target.value);
629
+ setIsOpen(true);
630
+ };
631
+ const handleKeyDown = (e) => {
632
+ if (e.key === "Enter") {
633
+ e.preventDefault();
634
+ if (canCreateNew) {
635
+ handleSelect(inputValue);
636
+ } else if (filteredOptions.length > 0) {
637
+ handleSelect(filteredOptions[0].value);
638
+ }
639
+ } else if (e.key === "Escape") {
640
+ setIsOpen(false);
641
+ setInputValue(value || "");
642
+ }
643
+ };
644
+ const clearValue = () => {
645
+ onChange("");
646
+ setInputValue("");
647
+ inputRef.current?.focus();
648
+ };
649
+ const selectedOption = options.find((o) => o.value === value);
650
+ const selectedIconPath = selectedOption?.iconUrl ?? null;
651
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: `relative ${className}`, children: [
652
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
653
+ selectedIconPath && selectedOption && /* @__PURE__ */ jsx("div", { className: "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none", children: /* @__PURE__ */ jsx("div", { className: "rounded-md overflow-hidden bg-linear-to-br from-black/2 to-black/5", style: { width: 16, height: 16 }, children: /* @__PURE__ */ jsx(
654
+ Image2,
655
+ {
656
+ src: selectedIconPath,
657
+ alt: selectedOption.label,
658
+ width: 16,
659
+ height: 16,
660
+ className: "object-cover",
661
+ unoptimized: true
662
+ }
663
+ ) }) }),
664
+ /* @__PURE__ */ jsx(
665
+ "input",
666
+ {
667
+ ref: inputRef,
668
+ type: "text",
669
+ value: inputValue,
670
+ onChange: handleInputChange,
671
+ onFocus: () => !disabled && setIsOpen(true),
672
+ onKeyDown: handleKeyDown,
673
+ placeholder: resolvedPlaceholder,
674
+ disabled,
675
+ className: `
676
+ w-full py-2
677
+ rounded-xl border border-(--border-default) bg-(--bg-elevated)
678
+ hover:border-(--border-strong) hover:bg-(--bg-hover)
679
+ focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary
680
+ transition-all duration-200 text-sm
681
+ ${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
682
+ ${selectedIconPath ? "pl-10 pr-20" : "px-3 pr-20"}
683
+ `
684
+ }
685
+ ),
686
+ inputValue && !disabled && /* @__PURE__ */ jsx(
687
+ "button",
688
+ {
689
+ type: "button",
690
+ onClick: clearValue,
691
+ className: "absolute right-8 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-1",
692
+ children: /* @__PURE__ */ jsx(X, { size: 14 })
693
+ }
694
+ ),
695
+ /* @__PURE__ */ jsx(
696
+ "button",
697
+ {
698
+ type: "button",
699
+ onClick: () => !disabled && setIsOpen(!isOpen),
700
+ disabled,
701
+ className: "absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-1 disabled:opacity-50",
702
+ children: /* @__PURE__ */ jsx(ChevronDown, { size: 14, className: isOpen ? "rotate-180 transition-transform" : "" })
703
+ }
704
+ )
705
+ ] }),
706
+ isOpen && !disabled && /* @__PURE__ */ jsx("div", { className: "absolute z-50 w-full mt-1 py-1 rounded-xl border border-(--border-default) bg-(--bg-elevated) shadow-lg overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "max-h-60 overflow-y-auto", children: filteredOptions.length === 0 && !canCreateNew ? /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-muted-foreground", children: t("noResults") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
707
+ filteredOptions.map((option) => {
708
+ const isSelected = option.value === value;
709
+ const optionIconPath = option.iconUrl ?? null;
710
+ return /* @__PURE__ */ jsxs(
711
+ "button",
712
+ {
713
+ type: "button",
714
+ onClick: () => handleSelect(option.value),
715
+ className: `
716
+ w-full px-3 py-2 text-left text-sm
717
+ flex items-center gap-2
718
+ hover:bg-(--bg-hover) transition-colors
719
+ ${isSelected ? "bg-primary/10 text-primary" : ""}
720
+ `,
721
+ children: [
722
+ optionIconPath && /* @__PURE__ */ jsx("div", { className: "rounded-md overflow-hidden bg-linear-to-br from-black/2 to-black/5 shrink-0", style: { width: 16, height: 16 }, children: /* @__PURE__ */ jsx(
723
+ Image2,
724
+ {
725
+ src: optionIconPath,
726
+ alt: option.label,
727
+ width: 16,
728
+ height: 16,
729
+ className: "object-cover",
730
+ unoptimized: true
731
+ }
732
+ ) }),
733
+ /* @__PURE__ */ jsx("span", { className: "font-medium truncate", children: option.label }),
734
+ isSelected && /* @__PURE__ */ jsx(Check, { size: 14, className: "ml-auto shrink-0" })
735
+ ]
736
+ },
737
+ option.value
738
+ );
739
+ }),
740
+ canCreateNew && /* @__PURE__ */ jsxs(
741
+ "button",
742
+ {
743
+ type: "button",
744
+ onClick: () => handleSelect(inputValue),
745
+ className: "\n w-full px-3 py-2 text-left text-sm\n flex items-center gap-2\n text-primary hover:bg-muted/50\n transition-colors\n ",
746
+ children: [
747
+ /* @__PURE__ */ jsx("span", { className: "text-lg", children: "+" }),
748
+ /* @__PURE__ */ jsx("span", { children: resolvedCreatableText.replace("{value}", inputValue) })
749
+ ]
750
+ }
751
+ )
752
+ ] }) }) })
753
+ ] });
754
+ }
755
+ var Button = React.forwardRef(
756
+ ({ className, variant = "default", size = "md", loading, disabled, asChild, children, ...props }, ref) => {
757
+ const variantMap = {
758
+ default: "btn-primary",
759
+ primary: "btn-primary",
760
+ secondary: "btn-secondary",
761
+ ghost: "btn-ghost",
762
+ accent: "btn-accent",
763
+ outline: "btn-outline",
764
+ amber: "btn-amber",
765
+ red: "btn-red",
766
+ destructive: "btn-red"
767
+ };
768
+ const variantClass = variantMap[variant] || variantMap.default;
769
+ const sizes = {
770
+ sm: "btn-sm",
771
+ md: "",
772
+ lg: "btn-lg",
773
+ icon: "w-10 h-10 p-0"
774
+ };
775
+ const classes = cn("btn", variantClass, sizes[size], className);
776
+ if (asChild && React.isValidElement(children)) {
777
+ return React.cloneElement(children, {
778
+ className: cn(classes, children.props.className)
779
+ });
780
+ }
781
+ return /* @__PURE__ */ jsxs(
782
+ "button",
783
+ {
784
+ ref,
785
+ disabled: disabled || loading,
786
+ className: classes,
787
+ ...props,
788
+ children: [
789
+ loading && /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 mr-2 animate-spin" }),
790
+ children
791
+ ]
792
+ }
793
+ );
794
+ }
795
+ );
796
+ Button.displayName = "Button";
797
+ var Input = React.forwardRef(
798
+ ({ className, icon, error, ...props }, ref) => {
799
+ return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
800
+ icon && /* @__PURE__ */ jsx("div", { className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground", children: icon }),
801
+ /* @__PURE__ */ jsx(
802
+ "input",
803
+ {
804
+ ref,
805
+ className: cn(
806
+ "w-full h-10 px-4 bg-background border rounded-xl text-sm outline-none transition-colors",
807
+ "placeholder:text-muted-foreground",
808
+ "focus:border-ring focus:ring-2 focus:ring-ring/20",
809
+ icon && "pl-10",
810
+ error ? "border-red-300 focus:border-red-400 dark:border-red-700" : "border-border",
811
+ className
812
+ ),
813
+ ...props
814
+ }
815
+ ),
816
+ error && /* @__PURE__ */ jsxs("p", { className: "mt-1.5 text-xs text-red-500 flex items-center gap-1", children: [
817
+ /* @__PURE__ */ jsx(AlertCircle, { className: "w-3 h-3" }),
818
+ error
819
+ ] })
820
+ ] });
821
+ }
822
+ );
823
+ Input.displayName = "Input";
824
+ var Textarea = React.forwardRef(
825
+ ({ className, error, ...props }, ref) => {
826
+ return /* @__PURE__ */ jsxs("div", { children: [
827
+ /* @__PURE__ */ jsx(
828
+ "textarea",
829
+ {
830
+ ref,
831
+ className: cn(
832
+ "w-full px-4 py-3 bg-background border rounded-xl text-sm outline-none transition-colors resize-none",
833
+ "placeholder:text-muted-foreground",
834
+ "focus:border-ring focus:ring-2 focus:ring-ring/20",
835
+ error ? "border-red-300 dark:border-red-700" : "border-border",
836
+ className
837
+ ),
838
+ ...props
839
+ }
840
+ ),
841
+ error && /* @__PURE__ */ jsxs("p", { className: "mt-1.5 text-xs text-red-500 flex items-center gap-1", children: [
842
+ /* @__PURE__ */ jsx(AlertCircle, { className: "w-3 h-3" }),
843
+ error
844
+ ] })
845
+ ] });
846
+ }
847
+ );
848
+ Textarea.displayName = "Textarea";
849
+ var Card = React.forwardRef(
850
+ ({ className, hover, ...props }, ref) => {
851
+ return /* @__PURE__ */ jsx(
852
+ "div",
853
+ {
854
+ ref,
855
+ className: cn(
856
+ // Renders the canonical `.card` class so <Card> matches the
857
+ // ~226 raw `className="card"` usages across the app (single look).
858
+ "card",
859
+ hover && "hover:border-ring hover:shadow-lg hover:shadow-foreground/5 transition-all duration-200",
860
+ className
861
+ ),
862
+ ...props
863
+ }
864
+ );
865
+ }
866
+ );
867
+ Card.displayName = "Card";
868
+ function Badge({ className, variant = "default", ...props }) {
869
+ const variants = {
870
+ default: "bg-muted text-foreground/80",
871
+ success: "bg-green-50 text-green-700 dark:bg-green-900/30 dark:text-green-400",
872
+ warning: "bg-amber-50 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",
873
+ error: "bg-red-50 text-red-700 dark:bg-red-900/30 dark:text-red-400",
874
+ info: "bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400"
875
+ };
876
+ return /* @__PURE__ */ jsx(
877
+ "span",
878
+ {
879
+ className: cn(
880
+ "inline-flex items-center px-2 py-0.5 rounded-md text-xs font-medium",
881
+ variants[variant],
882
+ className
883
+ ),
884
+ ...props
885
+ }
886
+ );
887
+ }
888
+ var Dialog = DialogPrimitive.Root;
889
+ var DialogTrigger = DialogPrimitive.Trigger;
890
+ var DialogPortal = DialogPrimitive.Portal;
891
+ var DialogClose = DialogPrimitive.Close;
892
+ var DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
893
+ DialogPrimitive.Overlay,
894
+ {
895
+ ref,
896
+ className: cn(
897
+ "fixed inset-0 z-50 bg-black/60 backdrop-blur-sm",
898
+ "data-[state=open]:animate-in data-[state=closed]:animate-out",
899
+ "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
900
+ className
901
+ ),
902
+ ...props
903
+ }
904
+ ));
905
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
906
+ var DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
907
+ /* @__PURE__ */ jsx(DialogOverlay, {}),
908
+ /* @__PURE__ */ jsxs(
909
+ DialogPrimitive.Content,
910
+ {
911
+ ref,
912
+ className: cn(
913
+ "fixed left-[50%] top-[50%] z-50 w-[calc(100%-2rem)] max-w-lg translate-x-[-50%] translate-y-[-50%]",
914
+ "bg-card rounded-2xl shadow-2xl p-6",
915
+ "data-[state=open]:animate-in data-[state=closed]:animate-out",
916
+ "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
917
+ "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
918
+ "data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]",
919
+ "data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",
920
+ className
921
+ ),
922
+ ...props,
923
+ children: [
924
+ children,
925
+ /* @__PURE__ */ jsx(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-lg p-1.5 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors", children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) })
926
+ ]
927
+ }
928
+ )
929
+ ] }));
930
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
931
+ function DialogHeader({ className, ...props }) {
932
+ return /* @__PURE__ */ jsx("div", { className: cn("mb-4", className), ...props });
933
+ }
934
+ var DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
935
+ DialogPrimitive.Title,
936
+ {
937
+ ref,
938
+ className: cn("text-lg font-semibold", className),
939
+ ...props
940
+ }
941
+ ));
942
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
943
+ var DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
944
+ DialogPrimitive.Description,
945
+ {
946
+ ref,
947
+ className: cn("text-sm text-muted-foreground mt-1", className),
948
+ ...props
949
+ }
950
+ ));
951
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
952
+ function DialogFooter({ className, ...props }) {
953
+ return /* @__PURE__ */ jsx("div", { className: cn("flex items-center justify-end gap-3 mt-6", className), ...props });
954
+ }
955
+ var Select = SelectPrimitive.Root;
956
+ var SelectValue = SelectPrimitive.Value;
957
+ var SelectGroup = SelectPrimitive.Group;
958
+ var SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
959
+ SelectPrimitive.Trigger,
960
+ {
961
+ ref,
962
+ className: cn(
963
+ "flex h-10 w-full items-center justify-between rounded-xl border border-border bg-card px-3 text-sm",
964
+ "placeholder:text-muted-foreground",
965
+ "focus:outline-none focus:ring-2 focus:ring-ring/20",
966
+ "disabled:cursor-not-allowed disabled:opacity-50",
967
+ className
968
+ ),
969
+ ...props,
970
+ children: [
971
+ children,
972
+ /* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })
973
+ ]
974
+ }
975
+ ));
976
+ SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
977
+ var SelectContent = React.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsx(
978
+ SelectPrimitive.Content,
979
+ {
980
+ ref,
981
+ position,
982
+ className: cn(
983
+ "relative z-50 min-w-32 overflow-hidden rounded-xl border border-border bg-popover shadow-lg",
984
+ "data-[state=open]:animate-in data-[state=closed]:animate-out",
985
+ "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
986
+ "data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
987
+ position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=top]:-translate-y-1",
988
+ className
989
+ ),
990
+ ...props,
991
+ children: /* @__PURE__ */ jsx(
992
+ SelectPrimitive.Viewport,
993
+ {
994
+ className: cn(
995
+ "p-1",
996
+ position === "popper" && "h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width)"
997
+ ),
998
+ children
999
+ }
1000
+ )
1001
+ }
1002
+ ) }));
1003
+ SelectContent.displayName = SelectPrimitive.Content.displayName;
1004
+ var SelectItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1005
+ SelectPrimitive.Item,
1006
+ {
1007
+ ref,
1008
+ className: cn(
1009
+ "relative flex w-full cursor-pointer select-none items-center rounded-lg py-2 px-3 text-sm outline-none",
1010
+ "focus:bg-muted data-disabled:pointer-events-none data-disabled:opacity-50",
1011
+ className
1012
+ ),
1013
+ ...props,
1014
+ children: [
1015
+ /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
1016
+ /* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
1017
+ ]
1018
+ }
1019
+ ));
1020
+ SelectItem.displayName = SelectPrimitive.Item.displayName;
1021
+ var Slider = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxs(
1022
+ SliderPrimitive.Root,
1023
+ {
1024
+ ref,
1025
+ className: cn("relative flex w-full touch-none select-none items-center", className),
1026
+ ...props,
1027
+ children: [
1028
+ /* @__PURE__ */ jsx(SliderPrimitive.Track, { className: "relative h-2 w-full grow overflow-hidden rounded-full bg-muted", children: /* @__PURE__ */ jsx(SliderPrimitive.Range, { className: "absolute h-full bg-foreground" }) }),
1029
+ /* @__PURE__ */ jsx(
1030
+ SliderPrimitive.Thumb,
1031
+ {
1032
+ className: "block h-5 w-5 rounded-full border-2 border-foreground bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"
1033
+ }
1034
+ )
1035
+ ]
1036
+ }
1037
+ ));
1038
+ Slider.displayName = SliderPrimitive.Root.displayName;
1039
+ var Progress = React.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ jsx(
1040
+ ProgressPrimitive.Root,
1041
+ {
1042
+ ref,
1043
+ className: cn("relative h-2 w-full overflow-hidden rounded-full bg-muted", className),
1044
+ ...props,
1045
+ children: /* @__PURE__ */ jsx(
1046
+ ProgressPrimitive.Indicator,
1047
+ {
1048
+ className: "h-full w-full flex-1 bg-foreground transition-all duration-300",
1049
+ style: { transform: `translateX(-${100 - (value || 0)}%)` }
1050
+ }
1051
+ )
1052
+ }
1053
+ ));
1054
+ Progress.displayName = ProgressPrimitive.Root.displayName;
1055
+ var Tabs = TabsPrimitive.Root;
1056
+ var TabsList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1057
+ TabsPrimitive.List,
1058
+ {
1059
+ ref,
1060
+ className: cn(
1061
+ "inline-flex h-11 items-center justify-center rounded-xl bg-muted p-1 flex-nowrap overflow-x-auto",
1062
+ className
1063
+ ),
1064
+ ...props
1065
+ }
1066
+ ));
1067
+ TabsList.displayName = TabsPrimitive.List.displayName;
1068
+ var TabsTrigger = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1069
+ TabsPrimitive.Trigger,
1070
+ {
1071
+ ref,
1072
+ className: cn(
1073
+ "inline-flex items-center justify-center whitespace-nowrap rounded-lg px-4 py-2 text-sm font-medium transition-all",
1074
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1075
+ "disabled:pointer-events-none disabled:opacity-50",
1076
+ "data-[state=active]:bg-card data-[state=active]:shadow-sm",
1077
+ "data-[state=inactive]:text-muted-foreground data-[state=inactive]:hover:text-foreground",
1078
+ className
1079
+ ),
1080
+ ...props
1081
+ }
1082
+ ));
1083
+ TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
1084
+ var TabsContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1085
+ TabsPrimitive.Content,
1086
+ {
1087
+ ref,
1088
+ className: cn("mt-4 focus-visible:outline-none", className),
1089
+ ...props
1090
+ }
1091
+ ));
1092
+ TabsContent.displayName = TabsPrimitive.Content.displayName;
1093
+ var Avatar = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1094
+ AvatarPrimitive.Root,
1095
+ {
1096
+ ref,
1097
+ className: cn(
1098
+ "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
1099
+ className
1100
+ ),
1101
+ ...props
1102
+ }
1103
+ ));
1104
+ Avatar.displayName = AvatarPrimitive.Root.displayName;
1105
+ var AvatarImage = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1106
+ AvatarPrimitive.Image,
1107
+ {
1108
+ ref,
1109
+ className: cn("aspect-square h-full w-full", className),
1110
+ ...props
1111
+ }
1112
+ ));
1113
+ AvatarImage.displayName = AvatarPrimitive.Image.displayName;
1114
+ var AvatarFallback = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1115
+ AvatarPrimitive.Fallback,
1116
+ {
1117
+ ref,
1118
+ className: cn(
1119
+ "flex h-full w-full items-center justify-center rounded-full bg-muted text-sm font-medium",
1120
+ className
1121
+ ),
1122
+ ...props
1123
+ }
1124
+ ));
1125
+ AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
1126
+ var TooltipProvider = TooltipPrimitive.Provider;
1127
+ var Tooltip = TooltipPrimitive.Root;
1128
+ var TooltipTrigger = TooltipPrimitive.Trigger;
1129
+ var TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(
1130
+ TooltipPrimitive.Content,
1131
+ {
1132
+ ref,
1133
+ sideOffset,
1134
+ className: cn(
1135
+ "z-50 overflow-hidden rounded-lg bg-foreground px-3 py-1.5 text-xs text-background shadow-lg",
1136
+ "animate-in fade-in-0 zoom-in-95",
1137
+ className
1138
+ ),
1139
+ ...props
1140
+ }
1141
+ ));
1142
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
1143
+ function Skeleton({ className, ...props }) {
1144
+ return /* @__PURE__ */ jsx(
1145
+ "div",
1146
+ {
1147
+ className: cn("animate-pulse rounded-lg bg-muted", className),
1148
+ ...props
1149
+ }
1150
+ );
1151
+ }
1152
+ var spinnerSizes = {
1153
+ sm: "w-4 h-4",
1154
+ md: "w-6 h-6",
1155
+ lg: "w-8 h-8"
1156
+ };
1157
+ function Spinner({ size = "md", className, ...props }) {
1158
+ return /* @__PURE__ */ jsxs("div", { role: "status", className: cn("inline-flex", className), ...props, children: [
1159
+ /* @__PURE__ */ jsx(Loader2, { className: cn("animate-spin text-muted-foreground", spinnerSizes[size]) }),
1160
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading..." })
1161
+ ] });
1162
+ }
1163
+ function PageLoader({ title, subtitle, className, ...props }) {
1164
+ return /* @__PURE__ */ jsx(
1165
+ "div",
1166
+ {
1167
+ className: cn("flex items-center justify-center min-h-dvh w-full", className),
1168
+ ...props,
1169
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-4", children: [
1170
+ /* @__PURE__ */ jsx(Spinner, { size: "lg" }),
1171
+ (title || subtitle) && /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-1", children: [
1172
+ title && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm font-medium", children: title }),
1173
+ subtitle && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground/60 text-xs", children: subtitle })
1174
+ ] })
1175
+ ] })
1176
+ }
1177
+ );
1178
+ }
1179
+ function EmptyState({ icon, title, description, action }) {
1180
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center py-12 text-center", children: [
1181
+ icon && /* @__PURE__ */ jsx("div", { className: "text-4xl mb-4", children: icon }),
1182
+ /* @__PURE__ */ jsx("h3", { className: "text-lg font-medium mb-1", children: title }),
1183
+ description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-4 max-w-sm", children: description }),
1184
+ action
1185
+ ] });
1186
+ }
1187
+ var MotionDiv = motion.div;
1188
+ var MotionSpan = motion.span;
1189
+ var fadeIn = {
1190
+ initial: { opacity: 0, y: 10 },
1191
+ animate: { opacity: 1, y: 0 },
1192
+ exit: { opacity: 0, y: -10 },
1193
+ transition: { duration: 0.2 }
1194
+ };
1195
+ var staggerContainer = {
1196
+ animate: {
1197
+ transition: { staggerChildren: 0.05 }
1198
+ }
1199
+ };
1200
+ var staggerItem = {
1201
+ initial: { opacity: 0, y: 20 },
1202
+ animate: { opacity: 1, y: 0 }
1203
+ };
1204
+ var IconButton = React.forwardRef(
1205
+ ({ className, icon, label, ...props }, ref) => {
1206
+ return /* @__PURE__ */ jsx(TooltipProvider, { delayDuration: 300, children: /* @__PURE__ */ jsxs(Tooltip, { children: [
1207
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
1208
+ "button",
1209
+ {
1210
+ ref,
1211
+ className: cn(
1212
+ "p-2 rounded-lg text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",
1213
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1214
+ className
1215
+ ),
1216
+ ...props,
1217
+ children: icon
1218
+ }
1219
+ ) }),
1220
+ /* @__PURE__ */ jsx(TooltipContent, { children: label })
1221
+ ] }) });
1222
+ }
1223
+ );
1224
+ IconButton.displayName = "IconButton";
1225
+ function Label2({ className, ...props }) {
1226
+ return /* @__PURE__ */ jsx(
1227
+ "label",
1228
+ {
1229
+ className: cn(
1230
+ "text-[11px] font-medium text-muted-foreground uppercase tracking-wider block mb-2",
1231
+ className
1232
+ ),
1233
+ ...props
1234
+ }
1235
+ );
1236
+ }
1237
+ var DropdownMenu = DropdownMenuPrimitive.Root;
1238
+ var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
1239
+ var DropdownMenuGroup = DropdownMenuPrimitive.Group;
1240
+ var DropdownMenuPortal = DropdownMenuPrimitive.Portal;
1241
+ var DropdownMenuSub = DropdownMenuPrimitive.Sub;
1242
+ var DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
1243
+ var DropdownMenuSubTrigger = React.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1244
+ DropdownMenuPrimitive.SubTrigger,
1245
+ {
1246
+ ref,
1247
+ className: cn(
1248
+ "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
1249
+ inset && "pl-8",
1250
+ className
1251
+ ),
1252
+ ...props,
1253
+ children: [
1254
+ children,
1255
+ /* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto h-4 w-4" })
1256
+ ]
1257
+ }
1258
+ ));
1259
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
1260
+ var DropdownMenuSubContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1261
+ DropdownMenuPrimitive.SubContent,
1262
+ {
1263
+ ref,
1264
+ className: cn(
1265
+ "z-50 min-w-32 overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
1266
+ className
1267
+ ),
1268
+ ...props
1269
+ }
1270
+ ));
1271
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
1272
+ var DropdownMenuContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
1273
+ DropdownMenuPrimitive.Content,
1274
+ {
1275
+ ref,
1276
+ sideOffset,
1277
+ className: cn(
1278
+ "z-50 min-w-32 overflow-hidden rounded-xl border border-border bg-popover p-1 text-popover-foreground shadow-md",
1279
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
1280
+ className
1281
+ ),
1282
+ ...props
1283
+ }
1284
+ ) }));
1285
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
1286
+ var DropdownMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1287
+ DropdownMenuItemInternal,
1288
+ {
1289
+ ref,
1290
+ className: cn(
1291
+ "relative flex cursor-default select-none items-center rounded-lg px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
1292
+ inset && "pl-8",
1293
+ className
1294
+ ),
1295
+ ...props
1296
+ }
1297
+ ));
1298
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
1299
+ var DropdownMenuItemInternal = DropdownMenuPrimitive.Item;
1300
+ var DropdownMenuCheckboxItem = React.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
1301
+ DropdownMenuPrimitive.CheckboxItem,
1302
+ {
1303
+ ref,
1304
+ className: cn(
1305
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
1306
+ className
1307
+ ),
1308
+ checked,
1309
+ ...props,
1310
+ children: [
1311
+ /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
1312
+ children
1313
+ ]
1314
+ }
1315
+ ));
1316
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
1317
+ var DropdownMenuRadioItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
1318
+ DropdownMenuPrimitive.RadioItem,
1319
+ {
1320
+ ref,
1321
+ className: cn(
1322
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
1323
+ className
1324
+ ),
1325
+ ...props,
1326
+ children: [
1327
+ /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckCircle2, { className: "h-2 w-2 fill-current" }) }) }),
1328
+ children
1329
+ ]
1330
+ }
1331
+ ));
1332
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
1333
+ var DropdownMenuLabel = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
1334
+ DropdownMenuPrimitive.Label,
1335
+ {
1336
+ ref,
1337
+ className: cn(
1338
+ "px-2 py-1.5 text-sm font-semibold",
1339
+ inset && "pl-8",
1340
+ className
1341
+ ),
1342
+ ...props
1343
+ }
1344
+ ));
1345
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
1346
+ var DropdownMenuSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1347
+ DropdownMenuPrimitive.Separator,
1348
+ {
1349
+ ref,
1350
+ className: cn("-mx-1 my-1 h-px bg-muted", className),
1351
+ ...props
1352
+ }
1353
+ ));
1354
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
1355
+ var DropdownMenuShortcut = ({
1356
+ className,
1357
+ ...props
1358
+ }) => {
1359
+ return /* @__PURE__ */ jsx(
1360
+ "span",
1361
+ {
1362
+ className: cn("ml-auto text-xs tracking-widest opacity-60", className),
1363
+ ...props
1364
+ }
1365
+ );
1366
+ };
1367
+ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
1368
+ function CustomSelect({
1369
+ options,
1370
+ value,
1371
+ onChange,
1372
+ placeholder,
1373
+ searchable = false,
1374
+ className = "",
1375
+ disabled = false
1376
+ }) {
1377
+ const t = useYunUI().useT("common.select");
1378
+ const resolvedPlaceholder = placeholder || t("placeholder");
1379
+ const [isOpen, setIsOpen] = useState(false);
1380
+ const [searchQuery, setSearchQuery] = useState("");
1381
+ const containerRef = useRef(null);
1382
+ const inputRef = useRef(null);
1383
+ useEffect(() => {
1384
+ const handleClickOutside = (e) => {
1385
+ if (containerRef.current && !containerRef.current.contains(e.target)) {
1386
+ setIsOpen(false);
1387
+ setSearchQuery("");
1388
+ }
1389
+ };
1390
+ document.addEventListener("mousedown", handleClickOutside);
1391
+ return () => document.removeEventListener("mousedown", handleClickOutside);
1392
+ }, []);
1393
+ useEffect(() => {
1394
+ if (isOpen && searchable && inputRef.current) {
1395
+ inputRef.current.focus();
1396
+ }
1397
+ }, [isOpen, searchable]);
1398
+ const selectedOption = options.find((o) => o.value === value);
1399
+ const filteredOptions = searchQuery ? options.filter(
1400
+ (o) => o.label.toLowerCase().includes(searchQuery.toLowerCase()) || o.value.toLowerCase().includes(searchQuery.toLowerCase())
1401
+ ) : options;
1402
+ const handleSelect = (optionValue) => {
1403
+ onChange(optionValue);
1404
+ setIsOpen(false);
1405
+ setSearchQuery("");
1406
+ };
1407
+ const handleWheel = (e) => {
1408
+ const target = e.currentTarget;
1409
+ const { scrollTop, scrollHeight, clientHeight } = target;
1410
+ const isAtTop = scrollTop <= 1;
1411
+ const isAtBottom = scrollTop + clientHeight >= scrollHeight - 1;
1412
+ if (isAtTop && e.deltaY < 0 || isAtBottom && e.deltaY > 0) {
1413
+ e.preventDefault();
1414
+ }
1415
+ };
1416
+ return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: `relative ${className}`, children: [
1417
+ /* @__PURE__ */ jsxs(
1418
+ "button",
1419
+ {
1420
+ type: "button",
1421
+ onClick: () => !disabled && setIsOpen(!isOpen),
1422
+ disabled,
1423
+ className: `
1424
+ w-full flex items-center justify-between gap-2 px-3 py-2
1425
+ rounded-xl border border-(--border-default) bg-(--bg-elevated)
1426
+ hover:border-(--border-strong) hover:bg-(--bg-hover)
1427
+ transition-all duration-200 text-sm
1428
+ ${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
1429
+ ${isOpen ? "border-primary ring-2 ring-primary/20" : ""}
1430
+ `,
1431
+ children: [
1432
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
1433
+ selectedOption?.icon && /* @__PURE__ */ jsx("span", { className: "shrink-0", children: selectedOption.icon }),
1434
+ /* @__PURE__ */ jsx("span", { className: `truncate ${!selectedOption ? "text-muted-foreground" : ""}`, children: selectedOption ? selectedOption.label : resolvedPlaceholder })
1435
+ ] }),
1436
+ /* @__PURE__ */ jsx(
1437
+ ChevronDown,
1438
+ {
1439
+ size: 16,
1440
+ className: `shrink-0 text-muted-foreground transition-transform ${isOpen ? "rotate-180" : ""}`
1441
+ }
1442
+ )
1443
+ ]
1444
+ }
1445
+ ),
1446
+ isOpen && /* @__PURE__ */ jsxs("div", { className: "\n absolute z-50 w-full mt-1 py-1\n rounded-xl border border-(--border-default)\n bg-(--bg-elevated) shadow-lg\n max-h-64 overflow-hidden\n animate-in fade-in-0 zoom-in-95 duration-200\n ", children: [
1447
+ searchable && /* @__PURE__ */ jsx("div", { className: "px-2.5 pb-2 pt-1.5 border-b border-(--border-subtle)", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
1448
+ /* @__PURE__ */ jsx(Search, { size: 14, className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" }),
1449
+ /* @__PURE__ */ jsx(
1450
+ "input",
1451
+ {
1452
+ ref: inputRef,
1453
+ type: "text",
1454
+ value: searchQuery,
1455
+ onChange: (e) => setSearchQuery(e.target.value),
1456
+ placeholder: t("search"),
1457
+ className: "w-full pl-9 pr-8 py-1.5 text-sm rounded-lg\n bg-(--bg-muted) border border-transparent\n focus:border-primary focus:outline-none focus:bg-(--bg-elevated) transition-colors"
1458
+ }
1459
+ ),
1460
+ searchQuery && /* @__PURE__ */ jsx(
1461
+ "button",
1462
+ {
1463
+ onClick: () => setSearchQuery(""),
1464
+ className: "absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-0.5 rounded-md hover:bg-(--bg-hover)",
1465
+ title: t("clearSearch"),
1466
+ children: /* @__PURE__ */ jsx(X, { size: 12 })
1467
+ }
1468
+ )
1469
+ ] }) }),
1470
+ /* @__PURE__ */ jsx(
1471
+ "div",
1472
+ {
1473
+ onWheel: handleWheel,
1474
+ className: "max-h-52 overflow-y-auto overscroll-contain",
1475
+ children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-muted-foreground text-center whitespace-nowrap", children: t("noOptions") }) : filteredOptions.map((option) => /* @__PURE__ */ jsxs(
1476
+ "button",
1477
+ {
1478
+ type: "button",
1479
+ onClick: () => handleSelect(option.value),
1480
+ className: `
1481
+ w-full flex items-center gap-2 px-3 py-2 text-sm text-left
1482
+ hover:bg-(--bg-hover) transition-colors
1483
+ ${option.value === value ? "bg-primary/10 text-primary" : ""}
1484
+ `,
1485
+ children: [
1486
+ option.icon && /* @__PURE__ */ jsx("span", { className: "shrink-0 w-5 h-5 flex items-center justify-center", children: option.icon }),
1487
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
1488
+ /* @__PURE__ */ jsx("div", { className: "truncate", children: option.label }),
1489
+ option.description && /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground truncate", children: option.description })
1490
+ ] }),
1491
+ option.value === value && /* @__PURE__ */ jsx(Check, { size: 14, className: "shrink-0 text-primary" })
1492
+ ]
1493
+ },
1494
+ option.value
1495
+ ))
1496
+ }
1497
+ )
1498
+ ] })
1499
+ ] });
1500
+ }
1501
+ function SegmentedSelect({
1502
+ options,
1503
+ value,
1504
+ onChange,
1505
+ className,
1506
+ disabled = false
1507
+ }) {
1508
+ return /* @__PURE__ */ jsx("div", { className: cn("flex gap-1 flex-wrap", className), children: options.map((opt) => {
1509
+ const Icon2 = opt.icon;
1510
+ return /* @__PURE__ */ jsxs(
1511
+ "button",
1512
+ {
1513
+ onClick: () => !disabled && onChange(opt.value),
1514
+ disabled,
1515
+ title: opt.desc,
1516
+ className: cn(
1517
+ "inline-flex items-center justify-center gap-2 px-3 py-1.5 text-xs font-medium border rounded-lg whitespace-nowrap transition-all duration-150 ease cursor-pointer outline-none",
1518
+ value === opt.value ? "text-foreground border-border-strong bg-accent-subtle hover:bg-accent-muted hover:shadow-xs" : "text-muted-foreground border-border-default bg-muted/50 hover:text-foreground hover:border-border-strong hover:bg-muted",
1519
+ disabled && "opacity-50 cursor-not-allowed pointer-events-none"
1520
+ ),
1521
+ children: [
1522
+ Icon2 && /* @__PURE__ */ jsx(Icon2, { size: 14 }),
1523
+ opt.label
1524
+ ]
1525
+ },
1526
+ String(opt.value)
1527
+ );
1528
+ }) });
1529
+ }
1530
+ function NavTabs({ tabs, activeKey, onChange, className = "", ariaLabel }) {
1531
+ const { Link } = useYunUI();
1532
+ return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx("nav", { className: "flex items-center gap-1 overflow-x-auto", "aria-label": ariaLabel, children: tabs.map((tab) => {
1533
+ const active = tab.key === activeKey;
1534
+ const cls = `nav-tab ${active ? "active" : ""}`;
1535
+ return tab.href ? /* @__PURE__ */ jsx(Link, { href: tab.href, className: cls, "aria-current": active ? "page" : void 0, children: tab.label }, tab.key) : /* @__PURE__ */ jsx(
1536
+ "button",
1537
+ {
1538
+ type: "button",
1539
+ onClick: () => onChange?.(tab.key),
1540
+ className: cls,
1541
+ "aria-current": active ? "true" : void 0,
1542
+ children: tab.label
1543
+ },
1544
+ tab.key
1545
+ );
1546
+ }) }) });
1547
+ }
1548
+ function ShinyButton({
1549
+ children,
1550
+ className,
1551
+ href,
1552
+ onClick
1553
+ }) {
1554
+ const { Link } = useYunUI();
1555
+ const ButtonContent = /* @__PURE__ */ jsxs(
1556
+ "div",
1557
+ {
1558
+ className: cn(
1559
+ "group relative flex items-center justify-center gap-2 overflow-hidden rounded-xl bg-(--text-primary) px-8 py-3 font-semibold text-background transition-all hover:ring-2 hover:ring-(--brand-primary) hover:ring-offset-2 hover:ring-offset-background",
1560
+ className
1561
+ ),
1562
+ children: [
1563
+ /* @__PURE__ */ jsxs("span", { className: "relative z-10 flex items-center gap-2", children: [
1564
+ children,
1565
+ /* @__PURE__ */ jsx(ArrowRight, { className: "h-4 w-4 transition-transform group-hover:translate-x-1" })
1566
+ ] }),
1567
+ /* @__PURE__ */ jsx("div", { className: "absolute inset-0 -z-10 block animate-shimmer bg-linear-to-r from-transparent via-(--text-primary)/10 to-transparent bg-size-[200%_100%]" })
1568
+ ]
1569
+ }
1570
+ );
1571
+ if (href) {
1572
+ return /* @__PURE__ */ jsx(Link, { href, onClick, children: ButtonContent });
1573
+ }
1574
+ return /* @__PURE__ */ jsx("button", { onClick, children: ButtonContent });
1575
+ }
1576
+ function Marquee({
1577
+ className,
1578
+ reverse,
1579
+ pauseOnHover = false,
1580
+ children,
1581
+ vertical = false,
1582
+ repeat = 4,
1583
+ ...props
1584
+ }) {
1585
+ return /* @__PURE__ */ jsx(
1586
+ "div",
1587
+ {
1588
+ ...props,
1589
+ className: cn(
1590
+ "group flex overflow-hidden p-2 [--duration:40s] [--gap:1rem] gap-(--gap)",
1591
+ {
1592
+ "flex-row": !vertical,
1593
+ "flex-col": vertical
1594
+ },
1595
+ className
1596
+ ),
1597
+ children: Array(repeat).fill(0).map((_, i) => /* @__PURE__ */ jsx(
1598
+ "div",
1599
+ {
1600
+ className: cn("flex shrink-0 justify-around gap-(--gap)", {
1601
+ "animate-marquee flex-row": !vertical,
1602
+ "animate-marquee-vertical flex-col": vertical,
1603
+ "group-hover:[animation-play-state:paused]": pauseOnHover,
1604
+ "[animation-direction:reverse]": reverse
1605
+ }),
1606
+ children
1607
+ },
1608
+ i
1609
+ ))
1610
+ }
1611
+ );
1612
+ }
1613
+ var BentoGrid = ({
1614
+ className,
1615
+ children
1616
+ }) => {
1617
+ return /* @__PURE__ */ jsx(
1618
+ "div",
1619
+ {
1620
+ className: cn(
1621
+ "grid grid-cols-1 md:grid-cols-3 gap-6 max-w-7xl mx-auto",
1622
+ className
1623
+ ),
1624
+ children
1625
+ }
1626
+ );
1627
+ };
1628
+ var BentoCard = ({
1629
+ className,
1630
+ title,
1631
+ description,
1632
+ header,
1633
+ icon
1634
+ }) => {
1635
+ return /* @__PURE__ */ jsxs(
1636
+ "div",
1637
+ {
1638
+ className: cn(
1639
+ "row-span-1 glass-card p-6 flex flex-col justify-between space-y-4 group/bento overflow-hidden",
1640
+ className
1641
+ ),
1642
+ children: [
1643
+ header,
1644
+ /* @__PURE__ */ jsxs("div", { className: "group-hover/bento:translate-x-2 transition duration-200", children: [
1645
+ /* @__PURE__ */ jsx("div", { className: "mb-2 text-[var(--text-primary)]", children: icon }),
1646
+ /* @__PURE__ */ jsx("div", { className: "font-bold text-[var(--text-primary)] text-lg mb-2 mt-2", children: title }),
1647
+ /* @__PURE__ */ jsx("div", { className: "font-normal text-[var(--text-secondary)] text-sm leading-relaxed", children: description })
1648
+ ] })
1649
+ ]
1650
+ }
1651
+ );
1652
+ };
1653
+ var Collapsible = Primitive.Root;
1654
+ var CollapsibleTrigger2 = Primitive.CollapsibleTrigger;
1655
+ var CollapsibleContent2 = forwardRef(({ children, ...props }, ref) => {
1656
+ const [mounted, setMounted] = useState(false);
1657
+ useEffect(() => {
1658
+ setMounted(true);
1659
+ }, []);
1660
+ return /* @__PURE__ */ jsx(
1661
+ Primitive.CollapsibleContent,
1662
+ {
1663
+ ref,
1664
+ ...props,
1665
+ className: cn(
1666
+ "overflow-hidden",
1667
+ mounted && "data-[state=closed]:animate-fd-collapsible-up data-[state=open]:animate-fd-collapsible-down",
1668
+ props.className
1669
+ ),
1670
+ children
1671
+ }
1672
+ );
1673
+ });
1674
+ CollapsibleContent2.displayName = Primitive.CollapsibleContent.displayName;
1675
+ var Popover = PopoverPrimitive.Root;
1676
+ var PopoverTrigger = PopoverPrimitive.Trigger;
1677
+ var PopoverContent = React.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
1678
+ PopoverPrimitive.Content,
1679
+ {
1680
+ ref,
1681
+ align,
1682
+ sideOffset,
1683
+ side: "bottom",
1684
+ className: cn(
1685
+ "z-50 origin-(--radix-popover-content-transform-origin) overflow-y-auto max-h-(--radix-popover-content-available-height) min-w-[240px] max-w-[98vw] rounded-xl border bg-fd-popover/60 backdrop-blur-lg p-2 text-sm text-fd-popover-foreground shadow-lg focus-visible:outline-none data-[state=closed]:animate-fd-popover-out data-[state=open]:animate-fd-popover-in",
1686
+ className
1687
+ ),
1688
+ ...props
1689
+ }
1690
+ ) }));
1691
+ PopoverContent.displayName = PopoverPrimitive.Content.displayName;
1692
+ var PopoverClose2 = PopoverPrimitive.PopoverClose;
1693
+ var sizeClasses = {
1694
+ sm: {
1695
+ track: "w-8 h-4",
1696
+ thumb: "w-2.5 h-2.5",
1697
+ thumbTranslate: "translate-x-3.5"
1698
+ },
1699
+ md: {
1700
+ track: "w-11 h-6",
1701
+ thumb: "w-4 h-4",
1702
+ thumbTranslate: "translate-x-5"
1703
+ }
1704
+ };
1705
+ var variantClasses = {
1706
+ default: {
1707
+ checkedTrack: "border-primary bg-primary/10",
1708
+ uncheckedTrack: "border-slate-300 dark:border-slate-600 bg-transparent",
1709
+ checkedThumb: "bg-primary",
1710
+ uncheckedThumb: "bg-slate-300 dark:bg-slate-600"
1711
+ },
1712
+ success: {
1713
+ checkedTrack: "border-emerald-500 bg-emerald-500/10",
1714
+ uncheckedTrack: "border-slate-300 dark:border-slate-600 bg-transparent",
1715
+ checkedThumb: "bg-emerald-500",
1716
+ uncheckedThumb: "bg-slate-300 dark:bg-slate-600"
1717
+ },
1718
+ warning: {
1719
+ checkedTrack: "border-amber-500 bg-amber-500/10",
1720
+ uncheckedTrack: "border-slate-300 dark:border-slate-600 bg-transparent",
1721
+ checkedThumb: "bg-amber-500",
1722
+ uncheckedThumb: "bg-slate-300 dark:bg-slate-600"
1723
+ },
1724
+ danger: {
1725
+ checkedTrack: "border-red-500 bg-red-500/10",
1726
+ uncheckedTrack: "border-slate-300 dark:border-slate-600 bg-transparent",
1727
+ checkedThumb: "bg-red-500",
1728
+ uncheckedThumb: "bg-slate-300 dark:bg-slate-600"
1729
+ }
1730
+ };
1731
+ var Switch = forwardRef(
1732
+ ({ checked, onCheckedChange, disabled = false, size = "sm", variant = "default", className = "", id }, ref) => {
1733
+ const sizeClass = sizeClasses[size];
1734
+ const variantClass = variantClasses[variant];
1735
+ return /* @__PURE__ */ jsx(
1736
+ "button",
1737
+ {
1738
+ ref,
1739
+ type: "button",
1740
+ role: "switch",
1741
+ "aria-checked": checked,
1742
+ id,
1743
+ onClick: () => !disabled && onCheckedChange(!checked),
1744
+ disabled,
1745
+ className: `
1746
+ ${sizeClass.track} rounded-full border-2 flex items-center px-0.5
1747
+ transition-all duration-200 ease-in-out
1748
+ ${checked ? variantClass.checkedTrack : variantClass.uncheckedTrack}
1749
+ ${disabled ? "opacity-50 cursor-not-allowed" : "cursor-pointer"}
1750
+ ${className}
1751
+ `,
1752
+ children: /* @__PURE__ */ jsx(
1753
+ "span",
1754
+ {
1755
+ className: `
1756
+ ${sizeClass.thumb} rounded-full transition-all duration-200 ease-in-out
1757
+ ${checked ? variantClass.checkedThumb + " " + sizeClass.thumbTranslate : variantClass.uncheckedThumb + " translate-x-0"}
1758
+ shadow-sm
1759
+ `
1760
+ }
1761
+ )
1762
+ }
1763
+ );
1764
+ }
1765
+ );
1766
+ Switch.displayName = "Switch";
1767
+ function AnimatedNumber({ value, suffix = "", decimals = 0 }) {
1768
+ const animatedValue = useSpring(0, { stiffness: 50, damping: 15 });
1769
+ const displayValue = useTransform(animatedValue, (latest) => {
1770
+ const numStr = decimals > 0 ? latest.toFixed(decimals) : Math.round(latest).toString();
1771
+ return Number(numStr).toString() + suffix;
1772
+ });
1773
+ useEffect(() => {
1774
+ animatedValue.set(value);
1775
+ }, [animatedValue, value]);
1776
+ return /* @__PURE__ */ jsx(motion.span, { children: displayValue });
1777
+ }
1778
+ function Toaster() {
1779
+ return /* @__PURE__ */ jsx(
1780
+ Toaster$1,
1781
+ {
1782
+ position: "bottom-right",
1783
+ toastOptions: {
1784
+ classNames: {
1785
+ toast: "bg-card border border-border rounded-xl shadow-lg p-4",
1786
+ title: "text-sm font-medium",
1787
+ description: "text-xs text-muted-foreground",
1788
+ actionButton: "bg-foreground text-background text-xs px-3 py-1.5 rounded-lg",
1789
+ cancelButton: "text-muted-foreground text-xs px-3 py-1.5 rounded-lg hover:bg-muted"
1790
+ }
1791
+ }
1792
+ }
1793
+ );
1794
+ }
1795
+ var toast = {
1796
+ success: (message, description) => {
1797
+ toast$1.success(message, {
1798
+ description,
1799
+ icon: /* @__PURE__ */ jsx(CheckCircle2, { className: "w-5 h-5 text-green-500" })
1800
+ });
1801
+ },
1802
+ error: (message, description) => {
1803
+ toast$1.error(message, {
1804
+ description,
1805
+ icon: /* @__PURE__ */ jsx(AlertCircle, { className: "w-5 h-5 text-red-500" })
1806
+ });
1807
+ },
1808
+ info: (message, description) => {
1809
+ toast$1.info(message, {
1810
+ description,
1811
+ icon: /* @__PURE__ */ jsx(Info, { className: "w-5 h-5 text-blue-500" })
1812
+ });
1813
+ },
1814
+ warning: (message, description) => {
1815
+ toast$1.warning(message, {
1816
+ description,
1817
+ icon: /* @__PURE__ */ jsx(AlertTriangle, { className: "w-5 h-5 text-amber-500" })
1818
+ });
1819
+ },
1820
+ loading: (message) => {
1821
+ return toast$1.loading(message, {
1822
+ icon: /* @__PURE__ */ jsx(Loader2, { className: "w-5 h-5 animate-spin" })
1823
+ });
1824
+ },
1825
+ dismiss: (id) => {
1826
+ toast$1.dismiss(id);
1827
+ },
1828
+ promise: (promise, messages) => {
1829
+ return toast$1.promise(promise, {
1830
+ loading: messages.loading,
1831
+ success: messages.success,
1832
+ error: messages.error
1833
+ });
1834
+ }
1835
+ };
1836
+
1837
+ export { AnimatedNumber, Avatar, AvatarFallback, AvatarImage, Badge, BentoCard, BentoGrid, Button, Card, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Combobox, ConfirmModal, CustomSelect, DeleteConfirmModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, IconButton, Input, Label2 as Label, Marquee, Modal, MotionDiv, MotionSpan, NavTabs, PageLoader, Popover, PopoverClose2 as PopoverClose, PopoverContent, PopoverTrigger, Progress, RegenerateConfirmModal, SegmentedSelect, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Sheet, ShinyButton, Skeleton, Slider, Spinner, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, fadeIn, staggerContainer, staggerItem, toast, useBodyScrollLock, useEscapeKey, useModalBehavior };
1838
+ //# sourceMappingURL=chunk-OHIFY64L.js.map
1839
+ //# sourceMappingURL=chunk-OHIFY64L.js.map