@logickernel/bridge 0.5.0 → 0.6.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,1348 @@
1
+ 'use strict';
2
+
3
+ var React2 = require('react');
4
+ var reactSlot = require('@radix-ui/react-slot');
5
+ var classVarianceAuthority = require('class-variance-authority');
6
+ var LucideIcons = require('lucide-react');
7
+ var clsx = require('clsx');
8
+ var tailwindMerge = require('tailwind-merge');
9
+ var jsxRuntime = require('react/jsx-runtime');
10
+ require('@radix-ui/react-separator');
11
+ var SheetPrimitive = require('@radix-ui/react-dialog');
12
+ var TooltipPrimitive = require('@radix-ui/react-tooltip');
13
+ var navigation = require('next/navigation');
14
+ var Link = require('next/link');
15
+ var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
16
+ var react = require('next-auth/react');
17
+ var AvatarPrimitive = require('@radix-ui/react-avatar');
18
+ var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
19
+
20
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
+
22
+ function _interopNamespace(e) {
23
+ if (e && e.__esModule) return e;
24
+ var n = Object.create(null);
25
+ if (e) {
26
+ Object.keys(e).forEach(function (k) {
27
+ if (k !== 'default') {
28
+ var d = Object.getOwnPropertyDescriptor(e, k);
29
+ Object.defineProperty(n, k, d.get ? d : {
30
+ enumerable: true,
31
+ get: function () { return e[k]; }
32
+ });
33
+ }
34
+ });
35
+ }
36
+ n.default = e;
37
+ return Object.freeze(n);
38
+ }
39
+
40
+ var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
41
+ var LucideIcons__namespace = /*#__PURE__*/_interopNamespace(LucideIcons);
42
+ var SheetPrimitive__namespace = /*#__PURE__*/_interopNamespace(SheetPrimitive);
43
+ var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
44
+ var Link__default = /*#__PURE__*/_interopDefault(Link);
45
+ var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespace(CollapsiblePrimitive);
46
+ var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
47
+ var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
48
+
49
+ // src/next/components/ui/sidebar.tsx
50
+ var MOBILE_BREAKPOINT = 768;
51
+ function useIsMobile() {
52
+ const [isMobile, setIsMobile] = React2__namespace.useState(void 0);
53
+ React2__namespace.useEffect(() => {
54
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
55
+ const onChange = () => {
56
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
57
+ };
58
+ mql.addEventListener("change", onChange);
59
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
60
+ return () => mql.removeEventListener("change", onChange);
61
+ }, []);
62
+ return !!isMobile;
63
+ }
64
+ function cn(...inputs) {
65
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
66
+ }
67
+ var buttonVariants = classVarianceAuthority.cva(
68
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
69
+ {
70
+ variants: {
71
+ variant: {
72
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
73
+ destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
74
+ outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
75
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
76
+ ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
77
+ link: "text-primary underline-offset-4 hover:underline"
78
+ },
79
+ size: {
80
+ default: "h-9 px-4 py-2 has-[>svg]:px-3",
81
+ sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
82
+ lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
83
+ icon: "size-9",
84
+ "icon-sm": "size-8",
85
+ "icon-lg": "size-10"
86
+ }
87
+ },
88
+ defaultVariants: {
89
+ variant: "default",
90
+ size: "default"
91
+ }
92
+ }
93
+ );
94
+ function Button({
95
+ className,
96
+ variant,
97
+ size,
98
+ asChild = false,
99
+ ...props
100
+ }) {
101
+ const Comp = asChild ? reactSlot.Slot : "button";
102
+ return /* @__PURE__ */ jsxRuntime.jsx(
103
+ Comp,
104
+ {
105
+ "data-slot": "button",
106
+ className: cn(buttonVariants({ variant, size, className })),
107
+ ...props
108
+ }
109
+ );
110
+ }
111
+ function Sheet({ ...props }) {
112
+ return /* @__PURE__ */ jsxRuntime.jsx(SheetPrimitive__namespace.Root, { "data-slot": "sheet", ...props });
113
+ }
114
+ function SheetPortal({
115
+ ...props
116
+ }) {
117
+ return /* @__PURE__ */ jsxRuntime.jsx(SheetPrimitive__namespace.Portal, { "data-slot": "sheet-portal", ...props });
118
+ }
119
+ function SheetOverlay({
120
+ className,
121
+ ...props
122
+ }) {
123
+ return /* @__PURE__ */ jsxRuntime.jsx(
124
+ SheetPrimitive__namespace.Overlay,
125
+ {
126
+ "data-slot": "sheet-overlay",
127
+ className: cn(
128
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
129
+ className
130
+ ),
131
+ ...props
132
+ }
133
+ );
134
+ }
135
+ function SheetContent({
136
+ className,
137
+ children,
138
+ side = "right",
139
+ ...props
140
+ }) {
141
+ return /* @__PURE__ */ jsxRuntime.jsxs(SheetPortal, { children: [
142
+ /* @__PURE__ */ jsxRuntime.jsx(SheetOverlay, {}),
143
+ /* @__PURE__ */ jsxRuntime.jsxs(
144
+ SheetPrimitive__namespace.Content,
145
+ {
146
+ "data-slot": "sheet-content",
147
+ className: cn(
148
+ "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
149
+ side === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
150
+ side === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
151
+ side === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
152
+ side === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
153
+ className
154
+ ),
155
+ ...props,
156
+ children: [
157
+ children,
158
+ /* @__PURE__ */ jsxRuntime.jsxs(SheetPrimitive__namespace.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
159
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.XIcon, { className: "size-4" }),
160
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
161
+ ] })
162
+ ]
163
+ }
164
+ )
165
+ ] });
166
+ }
167
+ function SheetHeader({ className, ...props }) {
168
+ return /* @__PURE__ */ jsxRuntime.jsx(
169
+ "div",
170
+ {
171
+ "data-slot": "sheet-header",
172
+ className: cn("flex flex-col gap-1.5 p-4", className),
173
+ ...props
174
+ }
175
+ );
176
+ }
177
+ function SheetTitle({
178
+ className,
179
+ ...props
180
+ }) {
181
+ return /* @__PURE__ */ jsxRuntime.jsx(
182
+ SheetPrimitive__namespace.Title,
183
+ {
184
+ "data-slot": "sheet-title",
185
+ className: cn("text-foreground font-semibold", className),
186
+ ...props
187
+ }
188
+ );
189
+ }
190
+ function SheetDescription({
191
+ className,
192
+ ...props
193
+ }) {
194
+ return /* @__PURE__ */ jsxRuntime.jsx(
195
+ SheetPrimitive__namespace.Description,
196
+ {
197
+ "data-slot": "sheet-description",
198
+ className: cn("text-muted-foreground text-sm", className),
199
+ ...props
200
+ }
201
+ );
202
+ }
203
+ function Skeleton({ className, ...props }) {
204
+ return /* @__PURE__ */ jsxRuntime.jsx(
205
+ "div",
206
+ {
207
+ "data-slot": "skeleton",
208
+ className: cn("bg-accent animate-pulse rounded-md", className),
209
+ ...props
210
+ }
211
+ );
212
+ }
213
+ function TooltipProvider({
214
+ delayDuration = 0,
215
+ ...props
216
+ }) {
217
+ return /* @__PURE__ */ jsxRuntime.jsx(
218
+ TooltipPrimitive__namespace.Provider,
219
+ {
220
+ "data-slot": "tooltip-provider",
221
+ delayDuration,
222
+ ...props
223
+ }
224
+ );
225
+ }
226
+ function Tooltip({
227
+ ...props
228
+ }) {
229
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Root, { "data-slot": "tooltip", ...props }) });
230
+ }
231
+ function TooltipTrigger({
232
+ ...props
233
+ }) {
234
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { "data-slot": "tooltip-trigger", ...props });
235
+ }
236
+ function TooltipContent({
237
+ className,
238
+ sideOffset = 0,
239
+ children,
240
+ ...props
241
+ }) {
242
+ return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
243
+ TooltipPrimitive__namespace.Content,
244
+ {
245
+ "data-slot": "tooltip-content",
246
+ sideOffset,
247
+ className: cn(
248
+ "bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
249
+ className
250
+ ),
251
+ ...props,
252
+ children: [
253
+ children,
254
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
255
+ ]
256
+ }
257
+ ) });
258
+ }
259
+ var SIDEBAR_COOKIE_NAME = "sidebar_state";
260
+ var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
261
+ var SIDEBAR_WIDTH = "16rem";
262
+ var SIDEBAR_WIDTH_MOBILE = "18rem";
263
+ var SIDEBAR_WIDTH_ICON = "3rem";
264
+ var SIDEBAR_KEYBOARD_SHORTCUT = "b";
265
+ var SidebarContext = React2__namespace.createContext(null);
266
+ function useSidebar() {
267
+ const context = React2__namespace.useContext(SidebarContext);
268
+ if (!context) {
269
+ throw new Error("useSidebar must be used within a SidebarProvider.");
270
+ }
271
+ return context;
272
+ }
273
+ function SidebarProvider({
274
+ defaultOpen = true,
275
+ open: openProp,
276
+ onOpenChange: setOpenProp,
277
+ className,
278
+ style,
279
+ children,
280
+ ...props
281
+ }) {
282
+ const isMobile = useIsMobile();
283
+ const [openMobile, setOpenMobile] = React2__namespace.useState(false);
284
+ const [_open, _setOpen] = React2__namespace.useState(defaultOpen);
285
+ const open = openProp ?? _open;
286
+ const setOpen = React2__namespace.useCallback(
287
+ (value) => {
288
+ const openState = typeof value === "function" ? value(open) : value;
289
+ if (setOpenProp) {
290
+ setOpenProp(openState);
291
+ } else {
292
+ _setOpen(openState);
293
+ }
294
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
295
+ },
296
+ [setOpenProp, open]
297
+ );
298
+ const toggleSidebar = React2__namespace.useCallback(() => {
299
+ return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
300
+ }, [isMobile, setOpen, setOpenMobile]);
301
+ React2__namespace.useEffect(() => {
302
+ const handleKeyDown = (event) => {
303
+ if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
304
+ event.preventDefault();
305
+ toggleSidebar();
306
+ }
307
+ };
308
+ window.addEventListener("keydown", handleKeyDown);
309
+ return () => window.removeEventListener("keydown", handleKeyDown);
310
+ }, [toggleSidebar]);
311
+ const state = open ? "expanded" : "collapsed";
312
+ const contextValue = React2__namespace.useMemo(
313
+ () => ({
314
+ state,
315
+ open,
316
+ setOpen,
317
+ isMobile,
318
+ openMobile,
319
+ setOpenMobile,
320
+ toggleSidebar
321
+ }),
322
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
323
+ );
324
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
325
+ "div",
326
+ {
327
+ "data-slot": "sidebar-wrapper",
328
+ style: {
329
+ "--sidebar-width": SIDEBAR_WIDTH,
330
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
331
+ ...style
332
+ },
333
+ className: cn(
334
+ "group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
335
+ className
336
+ ),
337
+ ...props,
338
+ children
339
+ }
340
+ ) }) });
341
+ }
342
+ function Sidebar({
343
+ side = "left",
344
+ variant = "sidebar",
345
+ collapsible = "offcanvas",
346
+ className,
347
+ children,
348
+ ...props
349
+ }) {
350
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
351
+ if (collapsible === "none") {
352
+ return /* @__PURE__ */ jsxRuntime.jsx(
353
+ "div",
354
+ {
355
+ "data-slot": "sidebar",
356
+ className: cn(
357
+ "bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
358
+ className
359
+ ),
360
+ ...props,
361
+ children
362
+ }
363
+ );
364
+ }
365
+ if (isMobile) {
366
+ return /* @__PURE__ */ jsxRuntime.jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxRuntime.jsxs(
367
+ SheetContent,
368
+ {
369
+ "data-sidebar": "sidebar",
370
+ "data-slot": "sidebar",
371
+ "data-mobile": "true",
372
+ className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",
373
+ style: {
374
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE
375
+ },
376
+ side,
377
+ children: [
378
+ /* @__PURE__ */ jsxRuntime.jsxs(SheetHeader, { className: "sr-only", children: [
379
+ /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: "Sidebar" }),
380
+ /* @__PURE__ */ jsxRuntime.jsx(SheetDescription, { children: "Displays the mobile sidebar." })
381
+ ] }),
382
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full flex-col", children })
383
+ ]
384
+ }
385
+ ) });
386
+ }
387
+ return /* @__PURE__ */ jsxRuntime.jsxs(
388
+ "div",
389
+ {
390
+ className: "group peer text-sidebar-foreground hidden md:block",
391
+ "data-state": state,
392
+ "data-collapsible": state === "collapsed" ? collapsible : "",
393
+ "data-variant": variant,
394
+ "data-side": side,
395
+ "data-slot": "sidebar",
396
+ children: [
397
+ /* @__PURE__ */ jsxRuntime.jsx(
398
+ "div",
399
+ {
400
+ "data-slot": "sidebar-gap",
401
+ className: cn(
402
+ "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
403
+ "group-data-[collapsible=offcanvas]:w-0",
404
+ "group-data-[side=right]:rotate-180",
405
+ variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
406
+ )
407
+ }
408
+ ),
409
+ /* @__PURE__ */ jsxRuntime.jsx(
410
+ "div",
411
+ {
412
+ "data-slot": "sidebar-container",
413
+ className: cn(
414
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
415
+ side === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
416
+ // Adjust the padding for floating and inset variants.
417
+ variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
418
+ className
419
+ ),
420
+ ...props,
421
+ children: /* @__PURE__ */ jsxRuntime.jsx(
422
+ "div",
423
+ {
424
+ "data-sidebar": "sidebar",
425
+ "data-slot": "sidebar-inner",
426
+ className: "bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",
427
+ children
428
+ }
429
+ )
430
+ }
431
+ )
432
+ ]
433
+ }
434
+ );
435
+ }
436
+ function SidebarTrigger({
437
+ className,
438
+ onClick,
439
+ ...props
440
+ }) {
441
+ const { toggleSidebar } = useSidebar();
442
+ return /* @__PURE__ */ jsxRuntime.jsxs(
443
+ Button,
444
+ {
445
+ "data-sidebar": "trigger",
446
+ "data-slot": "sidebar-trigger",
447
+ variant: "ghost",
448
+ size: "icon",
449
+ className: cn("size-7", className),
450
+ onClick: (event) => {
451
+ onClick?.(event);
452
+ toggleSidebar();
453
+ },
454
+ ...props,
455
+ children: [
456
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.PanelLeftIcon, {}),
457
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Toggle Sidebar" })
458
+ ]
459
+ }
460
+ );
461
+ }
462
+ function SidebarRail({ className, ...props }) {
463
+ const { toggleSidebar } = useSidebar();
464
+ return /* @__PURE__ */ jsxRuntime.jsx(
465
+ "button",
466
+ {
467
+ "data-sidebar": "rail",
468
+ "data-slot": "sidebar-rail",
469
+ "aria-label": "Toggle Sidebar",
470
+ tabIndex: -1,
471
+ onClick: toggleSidebar,
472
+ title: "Toggle Sidebar",
473
+ className: cn(
474
+ "hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex",
475
+ "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
476
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
477
+ "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
478
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
479
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
480
+ className
481
+ ),
482
+ ...props
483
+ }
484
+ );
485
+ }
486
+ function SidebarInset({ className, ...props }) {
487
+ return /* @__PURE__ */ jsxRuntime.jsx(
488
+ "main",
489
+ {
490
+ "data-slot": "sidebar-inset",
491
+ className: cn(
492
+ "bg-background relative flex w-full flex-1 flex-col",
493
+ "px-4",
494
+ "md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
495
+ className
496
+ ),
497
+ ...props
498
+ }
499
+ );
500
+ }
501
+ function SidebarHeader({ className, ...props }) {
502
+ return /* @__PURE__ */ jsxRuntime.jsx(
503
+ "div",
504
+ {
505
+ "data-slot": "sidebar-header",
506
+ "data-sidebar": "header",
507
+ className: cn("flex flex-col gap-2 p-2", className),
508
+ ...props
509
+ }
510
+ );
511
+ }
512
+ function SidebarFooter({ className, ...props }) {
513
+ return /* @__PURE__ */ jsxRuntime.jsx(
514
+ "div",
515
+ {
516
+ "data-slot": "sidebar-footer",
517
+ "data-sidebar": "footer",
518
+ className: cn("flex flex-col gap-2 p-2", className),
519
+ ...props
520
+ }
521
+ );
522
+ }
523
+ function SidebarContent({ className, ...props }) {
524
+ return /* @__PURE__ */ jsxRuntime.jsx(
525
+ "div",
526
+ {
527
+ "data-slot": "sidebar-content",
528
+ "data-sidebar": "content",
529
+ className: cn(
530
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
531
+ className
532
+ ),
533
+ ...props
534
+ }
535
+ );
536
+ }
537
+ function SidebarGroup({ className, ...props }) {
538
+ return /* @__PURE__ */ jsxRuntime.jsx(
539
+ "div",
540
+ {
541
+ "data-slot": "sidebar-group",
542
+ "data-sidebar": "group",
543
+ className: cn("relative flex w-full min-w-0 flex-col p-2", className),
544
+ ...props
545
+ }
546
+ );
547
+ }
548
+ function SidebarGroupLabel({
549
+ className,
550
+ asChild = false,
551
+ ...props
552
+ }) {
553
+ const Comp = asChild ? reactSlot.Slot : "div";
554
+ return /* @__PURE__ */ jsxRuntime.jsx(
555
+ Comp,
556
+ {
557
+ "data-slot": "sidebar-group-label",
558
+ "data-sidebar": "group-label",
559
+ className: cn(
560
+ "text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
561
+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
562
+ className
563
+ ),
564
+ ...props
565
+ }
566
+ );
567
+ }
568
+ function SidebarMenu({ className, ...props }) {
569
+ return /* @__PURE__ */ jsxRuntime.jsx(
570
+ "ul",
571
+ {
572
+ "data-slot": "sidebar-menu",
573
+ "data-sidebar": "menu",
574
+ className: cn("flex w-full min-w-0 flex-col gap-1", className),
575
+ ...props
576
+ }
577
+ );
578
+ }
579
+ function SidebarMenuItem({ className, ...props }) {
580
+ return /* @__PURE__ */ jsxRuntime.jsx(
581
+ "li",
582
+ {
583
+ "data-slot": "sidebar-menu-item",
584
+ "data-sidebar": "menu-item",
585
+ className: cn("group/menu-item relative", className),
586
+ ...props
587
+ }
588
+ );
589
+ }
590
+ var sidebarMenuButtonVariants = classVarianceAuthority.cva(
591
+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
592
+ {
593
+ variants: {
594
+ variant: {
595
+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
596
+ outline: "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"
597
+ },
598
+ size: {
599
+ default: "h-8 text-sm",
600
+ sm: "h-7 text-xs",
601
+ lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
602
+ }
603
+ },
604
+ defaultVariants: {
605
+ variant: "default",
606
+ size: "default"
607
+ }
608
+ }
609
+ );
610
+ function SidebarMenuButton({
611
+ asChild = false,
612
+ isActive = false,
613
+ variant = "default",
614
+ size = "default",
615
+ tooltip,
616
+ className,
617
+ ...props
618
+ }) {
619
+ const Comp = asChild ? reactSlot.Slot : "button";
620
+ const { isMobile, state } = useSidebar();
621
+ const button = /* @__PURE__ */ jsxRuntime.jsx(
622
+ Comp,
623
+ {
624
+ "data-slot": "sidebar-menu-button",
625
+ "data-sidebar": "menu-button",
626
+ "data-size": size,
627
+ "data-active": isActive,
628
+ className: cn(sidebarMenuButtonVariants({ variant, size }), className),
629
+ ...props
630
+ }
631
+ );
632
+ if (!tooltip) {
633
+ return button;
634
+ }
635
+ if (typeof tooltip === "string") {
636
+ tooltip = {
637
+ children: tooltip
638
+ };
639
+ }
640
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
641
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: button }),
642
+ /* @__PURE__ */ jsxRuntime.jsx(
643
+ TooltipContent,
644
+ {
645
+ side: "right",
646
+ align: "center",
647
+ hidden: state !== "collapsed" || isMobile,
648
+ ...tooltip
649
+ }
650
+ )
651
+ ] });
652
+ }
653
+ function SidebarMenuSub({ className, ...props }) {
654
+ return /* @__PURE__ */ jsxRuntime.jsx(
655
+ "ul",
656
+ {
657
+ "data-slot": "sidebar-menu-sub",
658
+ "data-sidebar": "menu-sub",
659
+ className: cn(
660
+ "border-sidebar-border mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l px-2.5 py-0.5",
661
+ "group-data-[collapsible=icon]:hidden",
662
+ className
663
+ ),
664
+ ...props
665
+ }
666
+ );
667
+ }
668
+ function SidebarMenuSubItem({
669
+ className,
670
+ ...props
671
+ }) {
672
+ return /* @__PURE__ */ jsxRuntime.jsx(
673
+ "li",
674
+ {
675
+ "data-slot": "sidebar-menu-sub-item",
676
+ "data-sidebar": "menu-sub-item",
677
+ className: cn("group/menu-sub-item relative", className),
678
+ ...props
679
+ }
680
+ );
681
+ }
682
+ function SidebarMenuSubButton({
683
+ asChild = false,
684
+ size = "md",
685
+ isActive = false,
686
+ className,
687
+ ...props
688
+ }) {
689
+ const Comp = asChild ? reactSlot.Slot : "a";
690
+ return /* @__PURE__ */ jsxRuntime.jsx(
691
+ Comp,
692
+ {
693
+ "data-slot": "sidebar-menu-sub-button",
694
+ "data-sidebar": "menu-sub-button",
695
+ "data-size": size,
696
+ "data-active": isActive,
697
+ className: cn(
698
+ "text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 outline-hidden focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
699
+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
700
+ size === "sm" && "text-xs",
701
+ size === "md" && "text-sm",
702
+ "group-data-[collapsible=icon]:hidden",
703
+ className
704
+ ),
705
+ ...props
706
+ }
707
+ );
708
+ }
709
+ function Collapsible({
710
+ ...props
711
+ }) {
712
+ return /* @__PURE__ */ jsxRuntime.jsx(CollapsiblePrimitive__namespace.Root, { "data-slot": "collapsible", ...props });
713
+ }
714
+ function CollapsibleTrigger2({
715
+ ...props
716
+ }) {
717
+ return /* @__PURE__ */ jsxRuntime.jsx(
718
+ CollapsiblePrimitive__namespace.CollapsibleTrigger,
719
+ {
720
+ "data-slot": "collapsible-trigger",
721
+ ...props
722
+ }
723
+ );
724
+ }
725
+ function CollapsibleContent2({
726
+ ...props
727
+ }) {
728
+ return /* @__PURE__ */ jsxRuntime.jsx(
729
+ CollapsiblePrimitive__namespace.CollapsibleContent,
730
+ {
731
+ "data-slot": "collapsible-content",
732
+ ...props
733
+ }
734
+ );
735
+ }
736
+ var ICON_MAP = {
737
+ Home: LucideIcons__namespace.Home,
738
+ Users: LucideIcons__namespace.Users,
739
+ GalleryVerticalEnd: LucideIcons__namespace.GalleryVerticalEnd,
740
+ Settings: LucideIcons__namespace.Settings,
741
+ CreditCard: LucideIcons__namespace.CreditCard,
742
+ Building2: LucideIcons__namespace.Building2,
743
+ Check: LucideIcons__namespace.Check,
744
+ ChevronsUpDown: LucideIcons__namespace.ChevronsUpDown,
745
+ ChevronRight: LucideIcons__namespace.ChevronRight,
746
+ BadgeCheck: LucideIcons__namespace.BadgeCheck,
747
+ LogOut: LucideIcons__namespace.LogOut
748
+ // Add more icons as needed
749
+ };
750
+ function getIconComponent(icon) {
751
+ if (!icon) {
752
+ return void 0;
753
+ }
754
+ if (typeof icon !== "string") {
755
+ return icon;
756
+ }
757
+ return ICON_MAP[icon];
758
+ }
759
+ function NavMain({ items }) {
760
+ const pathname = navigation.usePathname();
761
+ const groups = [];
762
+ let currentGroup = {
763
+ items: []
764
+ };
765
+ items.forEach((item) => {
766
+ const iconComponent = getIconComponent(item.icon);
767
+ if (!item.url) {
768
+ if (currentGroup.items.length > 0 || currentGroup.label) {
769
+ groups.push(currentGroup);
770
+ }
771
+ currentGroup = {
772
+ label: { title: item.title, icon: iconComponent },
773
+ items: []
774
+ };
775
+ } else {
776
+ currentGroup.items.push({
777
+ title: item.title,
778
+ url: item.url,
779
+ icon: iconComponent,
780
+ isActive: item.isActive,
781
+ items: item.items
782
+ });
783
+ }
784
+ });
785
+ if (currentGroup.items.length > 0 || currentGroup.label) {
786
+ groups.push(currentGroup);
787
+ }
788
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsxs(SidebarGroup, { children: [
789
+ group.label && /* @__PURE__ */ jsxRuntime.jsxs(SidebarGroupLabel, { children: [
790
+ group.label.icon && /* @__PURE__ */ jsxRuntime.jsx(group.label.icon, { className: "mr-2" }),
791
+ group.label.title
792
+ ] }),
793
+ group.items.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: group.items.map((item) => {
794
+ const isActive = pathname === item.url || item.isActive;
795
+ const hasSubItems = item.items && item.items.length > 0;
796
+ if (hasSubItems) {
797
+ return /* @__PURE__ */ jsxRuntime.jsx(
798
+ Collapsible,
799
+ {
800
+ asChild: true,
801
+ defaultOpen: isActive,
802
+ className: "group/collapsible",
803
+ children: /* @__PURE__ */ jsxRuntime.jsxs(SidebarMenuItem, { children: [
804
+ /* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
805
+ SidebarMenuButton,
806
+ {
807
+ tooltip: item.title,
808
+ isActive,
809
+ children: [
810
+ item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
811
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title }),
812
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronRight, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
813
+ ]
814
+ }
815
+ ) }),
816
+ /* @__PURE__ */ jsxRuntime.jsx(CollapsibleContent2, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSub, { children: item.items?.map((subItem) => /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubItem, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuSubButton, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(Link__default.default, { href: subItem.url, children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: subItem.title }) }) }) }, subItem.title)) }) })
817
+ ] })
818
+ },
819
+ item.title
820
+ );
821
+ }
822
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
823
+ SidebarMenuButton,
824
+ {
825
+ asChild: true,
826
+ tooltip: item.title,
827
+ isActive,
828
+ children: /* @__PURE__ */ jsxRuntime.jsxs(Link__default.default, { href: item.url, children: [
829
+ item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
830
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
831
+ ] })
832
+ }
833
+ ) }, item.title);
834
+ }) })
835
+ ] }, groupIndex)) });
836
+ }
837
+ function Avatar({
838
+ className,
839
+ ...props
840
+ }) {
841
+ return /* @__PURE__ */ jsxRuntime.jsx(
842
+ AvatarPrimitive__namespace.Root,
843
+ {
844
+ "data-slot": "avatar",
845
+ className: cn(
846
+ "relative flex size-8 shrink-0 overflow-hidden rounded-full",
847
+ className
848
+ ),
849
+ ...props
850
+ }
851
+ );
852
+ }
853
+ function AvatarImage({
854
+ className,
855
+ ...props
856
+ }) {
857
+ return /* @__PURE__ */ jsxRuntime.jsx(
858
+ AvatarPrimitive__namespace.Image,
859
+ {
860
+ "data-slot": "avatar-image",
861
+ className: cn("aspect-square size-full", className),
862
+ ...props
863
+ }
864
+ );
865
+ }
866
+ function AvatarFallback({
867
+ className,
868
+ ...props
869
+ }) {
870
+ return /* @__PURE__ */ jsxRuntime.jsx(
871
+ AvatarPrimitive__namespace.Fallback,
872
+ {
873
+ "data-slot": "avatar-fallback",
874
+ className: cn(
875
+ "bg-muted flex size-full items-center justify-center rounded-full",
876
+ className
877
+ ),
878
+ ...props
879
+ }
880
+ );
881
+ }
882
+ function DropdownMenu({
883
+ ...props
884
+ }) {
885
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Root, { "data-slot": "dropdown-menu", ...props });
886
+ }
887
+ function DropdownMenuTrigger({
888
+ ...props
889
+ }) {
890
+ return /* @__PURE__ */ jsxRuntime.jsx(
891
+ DropdownMenuPrimitive__namespace.Trigger,
892
+ {
893
+ "data-slot": "dropdown-menu-trigger",
894
+ ...props
895
+ }
896
+ );
897
+ }
898
+ function DropdownMenuContent({
899
+ className,
900
+ sideOffset = 4,
901
+ ...props
902
+ }) {
903
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
904
+ DropdownMenuPrimitive__namespace.Content,
905
+ {
906
+ "data-slot": "dropdown-menu-content",
907
+ sideOffset,
908
+ className: cn(
909
+ "bg-popover text-popover-foreground 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 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",
910
+ className
911
+ ),
912
+ ...props
913
+ }
914
+ ) });
915
+ }
916
+ function DropdownMenuGroup({
917
+ ...props
918
+ }) {
919
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Group, { "data-slot": "dropdown-menu-group", ...props });
920
+ }
921
+ function DropdownMenuItem({
922
+ className,
923
+ inset,
924
+ variant = "default",
925
+ ...props
926
+ }) {
927
+ return /* @__PURE__ */ jsxRuntime.jsx(
928
+ DropdownMenuPrimitive__namespace.Item,
929
+ {
930
+ "data-slot": "dropdown-menu-item",
931
+ "data-inset": inset,
932
+ "data-variant": variant,
933
+ className: cn(
934
+ "focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
935
+ className
936
+ ),
937
+ ...props
938
+ }
939
+ );
940
+ }
941
+ function DropdownMenuLabel({
942
+ className,
943
+ inset,
944
+ ...props
945
+ }) {
946
+ return /* @__PURE__ */ jsxRuntime.jsx(
947
+ DropdownMenuPrimitive__namespace.Label,
948
+ {
949
+ "data-slot": "dropdown-menu-label",
950
+ "data-inset": inset,
951
+ className: cn(
952
+ "px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",
953
+ className
954
+ ),
955
+ ...props
956
+ }
957
+ );
958
+ }
959
+ function DropdownMenuSeparator({
960
+ className,
961
+ ...props
962
+ }) {
963
+ return /* @__PURE__ */ jsxRuntime.jsx(
964
+ DropdownMenuPrimitive__namespace.Separator,
965
+ {
966
+ "data-slot": "dropdown-menu-separator",
967
+ className: cn("bg-border -mx-1 my-1 h-px", className),
968
+ ...props
969
+ }
970
+ );
971
+ }
972
+ function getInitials(name, email) {
973
+ if (name) {
974
+ const parts = name.trim().split(/\s+/);
975
+ if (parts.length >= 2) {
976
+ const first = parts[0];
977
+ const last = parts[parts.length - 1];
978
+ if (first && last && first[0] && last[0]) {
979
+ return (first[0] + last[0]).toUpperCase();
980
+ }
981
+ }
982
+ const firstChar2 = name[0];
983
+ if (firstChar2) {
984
+ return firstChar2.toUpperCase();
985
+ }
986
+ }
987
+ const firstChar = email[0];
988
+ if (firstChar) {
989
+ return firstChar.toUpperCase();
990
+ }
991
+ return "?";
992
+ }
993
+ function NavUser({ user }) {
994
+ const sidebar = useSidebar();
995
+ const isMobile = sidebar?.isMobile ?? false;
996
+ const router = navigation.useRouter();
997
+ const initials = getInitials(user.name, user.email);
998
+ const displayName = user.name || user.email;
999
+ const handleSignOut = async () => {
1000
+ await react.signOut({ redirect: false });
1001
+ router.push("/auth/signin");
1002
+ router.refresh();
1003
+ };
1004
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1005
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1006
+ SidebarMenuButton,
1007
+ {
1008
+ size: "lg",
1009
+ className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
1010
+ children: [
1011
+ /* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "h-8 w-8 rounded-lg", children: [
1012
+ /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: user.image || void 0, alt: displayName }),
1013
+ /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { className: "rounded-lg", children: initials })
1014
+ ] }),
1015
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1016
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: displayName }),
1017
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs", children: user.email })
1018
+ ] }),
1019
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronsUpDown, { className: "ml-auto size-4" })
1020
+ ]
1021
+ }
1022
+ ) }),
1023
+ /* @__PURE__ */ jsxRuntime.jsxs(
1024
+ DropdownMenuContent,
1025
+ {
1026
+ className: "w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",
1027
+ side: isMobile ? "bottom" : "right",
1028
+ align: "end",
1029
+ sideOffset: 4,
1030
+ children: [
1031
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 px-1 py-1.5 text-left text-sm", children: [
1032
+ /* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "h-8 w-8 rounded-lg", children: [
1033
+ /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: user.image || void 0, alt: displayName }),
1034
+ /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { className: "rounded-lg", children: initials })
1035
+ ] }),
1036
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1037
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: displayName }),
1038
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs", children: user.email })
1039
+ ] })
1040
+ ] }) }),
1041
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1042
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { children: [
1043
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.BadgeCheck, {}),
1044
+ "Account"
1045
+ ] }) }),
1046
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1047
+ /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: handleSignOut, children: [
1048
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.LogOut, {}),
1049
+ "Log out"
1050
+ ] })
1051
+ ]
1052
+ }
1053
+ )
1054
+ ] }) }) });
1055
+ }
1056
+ function TeamSwitcher({
1057
+ teams,
1058
+ organizationId
1059
+ }) {
1060
+ const sidebar = useSidebar();
1061
+ const isMobile = sidebar?.isMobile ?? false;
1062
+ const pathname = navigation.usePathname();
1063
+ const router = navigation.useRouter();
1064
+ const pathSegments = pathname.split("/");
1065
+ const isAppOrgRoute = pathname.startsWith("/app/") && pathSegments.length > 2 && pathSegments[2] !== "user";
1066
+ const pathOrgId = isAppOrgRoute ? pathSegments[2] : null;
1067
+ const currentOrgId = organizationId || (pathOrgId && teams.some((team) => team.id === pathOrgId) ? pathOrgId : null);
1068
+ const activeTeam = currentOrgId ? teams.find((team) => team.id === currentOrgId) : null;
1069
+ const handleTeamChange = (teamId) => {
1070
+ router.push(`/app/${teamId}/home`);
1071
+ router.refresh();
1072
+ };
1073
+ const teamsWithLogo = teams.map((org) => {
1074
+ const logoIcon = org.logo ? getIconComponent(org.logo) : LucideIcons.GalleryVerticalEnd;
1075
+ return {
1076
+ id: org.id,
1077
+ name: org.name,
1078
+ logo: logoIcon || LucideIcons.GalleryVerticalEnd,
1079
+ plan: org.plan || "Member"
1080
+ };
1081
+ });
1082
+ if (teamsWithLogo.length === 0) {
1083
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(SidebarMenuButton, { size: "lg", className: "cursor-default", children: [
1084
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex aspect-square size-8 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.GalleryVerticalEnd, { className: "size-4 text-muted-foreground" }) }),
1085
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1086
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium text-muted-foreground", children: "No organizations" }),
1087
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs text-muted-foreground", children: "Join or create one" })
1088
+ ] })
1089
+ ] }) }) });
1090
+ }
1091
+ if (!activeTeam) {
1092
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1093
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1094
+ SidebarMenuButton,
1095
+ {
1096
+ size: "lg",
1097
+ className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
1098
+ children: [
1099
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-muted flex aspect-square size-8 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.GalleryVerticalEnd, { className: "size-4 text-muted-foreground" }) }),
1100
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1101
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: "Organizations" }),
1102
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "truncate text-xs text-muted-foreground", children: [
1103
+ teamsWithLogo.length,
1104
+ " available"
1105
+ ] })
1106
+ ] }),
1107
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronsUpDown, { className: "ml-auto" })
1108
+ ]
1109
+ }
1110
+ ) }),
1111
+ /* @__PURE__ */ jsxRuntime.jsxs(
1112
+ DropdownMenuContent,
1113
+ {
1114
+ className: "w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",
1115
+ align: "start",
1116
+ side: isMobile ? "bottom" : "right",
1117
+ sideOffset: 4,
1118
+ children: [
1119
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: "Select an organization" }),
1120
+ teamsWithLogo.map((team) => /* @__PURE__ */ jsxRuntime.jsxs(
1121
+ DropdownMenuItem,
1122
+ {
1123
+ onClick: () => handleTeamChange(team.id),
1124
+ className: "gap-2 p-2",
1125
+ children: [
1126
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-6 items-center justify-center rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(team.logo, { className: "size-3.5 shrink-0" }) }),
1127
+ team.name
1128
+ ]
1129
+ },
1130
+ team.id
1131
+ )),
1132
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1133
+ /* @__PURE__ */ jsxRuntime.jsxs(
1134
+ DropdownMenuItem,
1135
+ {
1136
+ className: "gap-2 p-2",
1137
+ onClick: () => router.push("/app/user/organizations"),
1138
+ children: [
1139
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-6 items-center justify-center rounded-md border bg-transparent", children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.GalleryVerticalEnd, { className: "size-4" }) }),
1140
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground font-medium", children: "Manage organizations" })
1141
+ ]
1142
+ }
1143
+ )
1144
+ ]
1145
+ }
1146
+ )
1147
+ ] }) }) });
1148
+ }
1149
+ const activeTeamWithLogo = teamsWithLogo.find(
1150
+ (team) => team.id === currentOrgId
1151
+ );
1152
+ if (!activeTeamWithLogo) {
1153
+ return null;
1154
+ }
1155
+ return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1156
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1157
+ SidebarMenuButton,
1158
+ {
1159
+ size: "lg",
1160
+ className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
1161
+ children: [
1162
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsxRuntime.jsx(activeTeamWithLogo.logo, { className: "size-4" }) }),
1163
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1164
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: activeTeamWithLogo.name }),
1165
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs", children: activeTeamWithLogo.plan })
1166
+ ] }),
1167
+ /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronsUpDown, { className: "ml-auto" })
1168
+ ]
1169
+ }
1170
+ ) }),
1171
+ /* @__PURE__ */ jsxRuntime.jsxs(
1172
+ DropdownMenuContent,
1173
+ {
1174
+ className: "w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",
1175
+ align: "start",
1176
+ side: isMobile ? "bottom" : "right",
1177
+ sideOffset: 4,
1178
+ children: [
1179
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: "Organizations" }),
1180
+ teamsWithLogo.map((team) => /* @__PURE__ */ jsxRuntime.jsxs(
1181
+ DropdownMenuItem,
1182
+ {
1183
+ onClick: () => handleTeamChange(team.id),
1184
+ className: "gap-2 p-2",
1185
+ children: [
1186
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-6 items-center justify-center rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(team.logo, { className: "size-3.5 shrink-0" }) }),
1187
+ team.name,
1188
+ team.id === currentOrgId && /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Check, { className: "ml-auto h-4 w-4" })
1189
+ ]
1190
+ },
1191
+ team.id
1192
+ )),
1193
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1194
+ /* @__PURE__ */ jsxRuntime.jsxs(
1195
+ DropdownMenuItem,
1196
+ {
1197
+ className: "gap-2 p-2",
1198
+ onClick: () => router.push("/app/user/organizations"),
1199
+ children: [
1200
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex size-6 items-center justify-center rounded-md border bg-transparent", children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.GalleryVerticalEnd, { className: "size-4" }) }),
1201
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground font-medium", children: "Manage organizations" })
1202
+ ]
1203
+ }
1204
+ )
1205
+ ]
1206
+ }
1207
+ )
1208
+ ] }) }) });
1209
+ }
1210
+ function useNavigation({
1211
+ organizationId,
1212
+ apiBaseUrl = "/api",
1213
+ enabled = true
1214
+ } = {}) {
1215
+ const [items, setItems] = React2.useState([]);
1216
+ const [organizations, setOrganizations] = React2.useState([]);
1217
+ const [user, setUser] = React2.useState(null);
1218
+ const [loading, setLoading] = React2.useState(false);
1219
+ const [error, setError] = React2.useState(null);
1220
+ React2.useEffect(() => {
1221
+ if (!enabled || !organizationId) {
1222
+ setItems([]);
1223
+ setOrganizations([]);
1224
+ setUser(null);
1225
+ return;
1226
+ }
1227
+ const fetchNavigation = async () => {
1228
+ setLoading(true);
1229
+ setError(null);
1230
+ try {
1231
+ const response = await fetch(
1232
+ `${apiBaseUrl}/navigation/${organizationId}`,
1233
+ {
1234
+ credentials: "include"
1235
+ // Include cookies for auth
1236
+ }
1237
+ );
1238
+ if (!response.ok) {
1239
+ if (response.status === 401) {
1240
+ throw new Error("Unauthorized");
1241
+ }
1242
+ if (response.status === 404) {
1243
+ throw new Error("Organization not found");
1244
+ }
1245
+ throw new Error(`Failed to fetch navigation: ${response.statusText}`);
1246
+ }
1247
+ const data = await response.json();
1248
+ setItems(data.items || []);
1249
+ setOrganizations(data.organizations || []);
1250
+ setUser(data.user || null);
1251
+ } catch (err) {
1252
+ const error2 = err instanceof Error ? err : new Error("Unknown error");
1253
+ setError(error2);
1254
+ setItems([]);
1255
+ setOrganizations([]);
1256
+ setUser(null);
1257
+ } finally {
1258
+ setLoading(false);
1259
+ }
1260
+ };
1261
+ fetchNavigation();
1262
+ }, [organizationId, apiBaseUrl, enabled]);
1263
+ return { items, organizations, user, loading, error };
1264
+ }
1265
+ function AppSidebar({
1266
+ user: userProp,
1267
+ organizationId,
1268
+ apiBaseUrl,
1269
+ ...props
1270
+ }) {
1271
+ const currentPathname = navigation.usePathname();
1272
+ const pathSegments = currentPathname.split("/");
1273
+ const isAppOrgRoute = currentPathname.startsWith("/app/") && pathSegments.length > 2 && pathSegments[2] !== "user";
1274
+ const pathOrgId = isAppOrgRoute ? pathSegments[2] : null;
1275
+ const {
1276
+ items: apiNavigationItems,
1277
+ organizations: apiOrganizations,
1278
+ user: navigationUser,
1279
+ loading: navigationLoading
1280
+ } = useNavigation({
1281
+ organizationId: organizationId || pathOrgId || void 0,
1282
+ apiBaseUrl,
1283
+ enabled: true
1284
+ });
1285
+ const user = navigationUser || userProp;
1286
+ const currentOrgId = organizationId || (pathOrgId && apiOrganizations.some((org) => org.id === pathOrgId) ? pathOrgId : void 0);
1287
+ let navigationItems = apiNavigationItems;
1288
+ if (currentOrgId && navigationItems.length > 0) {
1289
+ navigationItems = navigationItems.map((item) => ({
1290
+ ...item,
1291
+ url: item.url?.replace("{organizationId}", currentOrgId),
1292
+ items: item.items?.map((subItem) => ({
1293
+ ...subItem,
1294
+ url: subItem.url.replace("{organizationId}", currentOrgId)
1295
+ }))
1296
+ }));
1297
+ }
1298
+ const displayNavigationItems = currentOrgId ? navigationItems : [];
1299
+ return /* @__PURE__ */ jsxRuntime.jsxs(Sidebar, { collapsible: "icon", ...props, children: [
1300
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(
1301
+ TeamSwitcher,
1302
+ {
1303
+ teams: apiOrganizations,
1304
+ organizationId: currentOrgId || void 0
1305
+ }
1306
+ ) }),
1307
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarContent, { children: navigationLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-sm text-muted-foreground", children: "Loading..." }) : /* @__PURE__ */ jsxRuntime.jsx(NavMain, { items: displayNavigationItems }) }),
1308
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarFooter, { children: user ? /* @__PURE__ */ jsxRuntime.jsx(NavUser, { user }) : /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(SidebarMenuButton, { size: "lg", disabled: true, children: [
1309
+ /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-8 rounded-lg" }),
1310
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 gap-1 text-left text-sm", children: [
1311
+ /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-24" }),
1312
+ /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-3 w-32" })
1313
+ ] })
1314
+ ] }) }) }) }),
1315
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarRail, {})
1316
+ ] });
1317
+ }
1318
+ function AppLayout({
1319
+ user,
1320
+ organizationId,
1321
+ apiBaseUrl,
1322
+ children
1323
+ }) {
1324
+ return /* @__PURE__ */ jsxRuntime.jsxs(SidebarProvider, { children: [
1325
+ /* @__PURE__ */ jsxRuntime.jsx(
1326
+ AppSidebar,
1327
+ {
1328
+ user,
1329
+ organizationId,
1330
+ apiBaseUrl
1331
+ }
1332
+ ),
1333
+ /* @__PURE__ */ jsxRuntime.jsxs(SidebarInset, { children: [
1334
+ /* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, {}),
1335
+ children
1336
+ ] })
1337
+ ] });
1338
+ }
1339
+
1340
+ exports.AppLayout = AppLayout;
1341
+ exports.AppSidebar = AppSidebar;
1342
+ exports.NavMain = NavMain;
1343
+ exports.NavUser = NavUser;
1344
+ exports.TeamSwitcher = TeamSwitcher;
1345
+ exports.getIconComponent = getIconComponent;
1346
+ exports.useNavigation = useNavigation;
1347
+ //# sourceMappingURL=components.cjs.map
1348
+ //# sourceMappingURL=components.cjs.map