@logickernel/bridge 0.6.0 → 0.7.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.
@@ -3,51 +3,6 @@
3
3
  var headers = require('next/headers');
4
4
  var jwt = require('@auth/core/jwt');
5
5
  var server = require('next/server');
6
- var React2 = require('react');
7
- var reactSlot = require('@radix-ui/react-slot');
8
- var classVarianceAuthority = require('class-variance-authority');
9
- var LucideIcons = require('lucide-react');
10
- var clsx = require('clsx');
11
- var tailwindMerge = require('tailwind-merge');
12
- var jsxRuntime = require('react/jsx-runtime');
13
- require('@radix-ui/react-separator');
14
- var SheetPrimitive = require('@radix-ui/react-dialog');
15
- var TooltipPrimitive = require('@radix-ui/react-tooltip');
16
- var navigation = require('next/navigation');
17
- var Link = require('next/link');
18
- var CollapsiblePrimitive = require('@radix-ui/react-collapsible');
19
- var react = require('next-auth/react');
20
- var AvatarPrimitive = require('@radix-ui/react-avatar');
21
- var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
22
-
23
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
24
-
25
- function _interopNamespace(e) {
26
- if (e && e.__esModule) return e;
27
- var n = Object.create(null);
28
- if (e) {
29
- Object.keys(e).forEach(function (k) {
30
- if (k !== 'default') {
31
- var d = Object.getOwnPropertyDescriptor(e, k);
32
- Object.defineProperty(n, k, d.get ? d : {
33
- enumerable: true,
34
- get: function () { return e[k]; }
35
- });
36
- }
37
- });
38
- }
39
- n.default = e;
40
- return Object.freeze(n);
41
- }
42
-
43
- var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
44
- var LucideIcons__namespace = /*#__PURE__*/_interopNamespace(LucideIcons);
45
- var SheetPrimitive__namespace = /*#__PURE__*/_interopNamespace(SheetPrimitive);
46
- var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
47
- var Link__default = /*#__PURE__*/_interopDefault(Link);
48
- var CollapsiblePrimitive__namespace = /*#__PURE__*/_interopNamespace(CollapsiblePrimitive);
49
- var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
50
- var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
51
6
 
52
7
  // src/next/session.ts
53
8
  function getBaseCookieName() {
@@ -451,1306 +406,11 @@ var defaultProxyConfig = {
451
406
  "/((?!_next/static|_next/image|favicon.ico|public).*)"
452
407
  ]
453
408
  };
454
- var MOBILE_BREAKPOINT = 768;
455
- function useIsMobile() {
456
- const [isMobile, setIsMobile] = React2__namespace.useState(void 0);
457
- React2__namespace.useEffect(() => {
458
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
459
- const onChange = () => {
460
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
461
- };
462
- mql.addEventListener("change", onChange);
463
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
464
- return () => mql.removeEventListener("change", onChange);
465
- }, []);
466
- return !!isMobile;
467
- }
468
- function cn(...inputs) {
469
- return tailwindMerge.twMerge(clsx.clsx(inputs));
470
- }
471
- var buttonVariants = classVarianceAuthority.cva(
472
- "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",
473
- {
474
- variants: {
475
- variant: {
476
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
477
- destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
478
- 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",
479
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
480
- ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
481
- link: "text-primary underline-offset-4 hover:underline"
482
- },
483
- size: {
484
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
485
- sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
486
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
487
- icon: "size-9",
488
- "icon-sm": "size-8",
489
- "icon-lg": "size-10"
490
- }
491
- },
492
- defaultVariants: {
493
- variant: "default",
494
- size: "default"
495
- }
496
- }
497
- );
498
- function Button({
499
- className,
500
- variant,
501
- size,
502
- asChild = false,
503
- ...props
504
- }) {
505
- const Comp = asChild ? reactSlot.Slot : "button";
506
- return /* @__PURE__ */ jsxRuntime.jsx(
507
- Comp,
508
- {
509
- "data-slot": "button",
510
- className: cn(buttonVariants({ variant, size, className })),
511
- ...props
512
- }
513
- );
514
- }
515
- function Sheet({ ...props }) {
516
- return /* @__PURE__ */ jsxRuntime.jsx(SheetPrimitive__namespace.Root, { "data-slot": "sheet", ...props });
517
- }
518
- function SheetPortal({
519
- ...props
520
- }) {
521
- return /* @__PURE__ */ jsxRuntime.jsx(SheetPrimitive__namespace.Portal, { "data-slot": "sheet-portal", ...props });
522
- }
523
- function SheetOverlay({
524
- className,
525
- ...props
526
- }) {
527
- return /* @__PURE__ */ jsxRuntime.jsx(
528
- SheetPrimitive__namespace.Overlay,
529
- {
530
- "data-slot": "sheet-overlay",
531
- className: cn(
532
- "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",
533
- className
534
- ),
535
- ...props
536
- }
537
- );
538
- }
539
- function SheetContent({
540
- className,
541
- children,
542
- side = "right",
543
- ...props
544
- }) {
545
- return /* @__PURE__ */ jsxRuntime.jsxs(SheetPortal, { children: [
546
- /* @__PURE__ */ jsxRuntime.jsx(SheetOverlay, {}),
547
- /* @__PURE__ */ jsxRuntime.jsxs(
548
- SheetPrimitive__namespace.Content,
549
- {
550
- "data-slot": "sheet-content",
551
- className: cn(
552
- "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",
553
- 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",
554
- 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",
555
- 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",
556
- 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",
557
- className
558
- ),
559
- ...props,
560
- children: [
561
- children,
562
- /* @__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: [
563
- /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.XIcon, { className: "size-4" }),
564
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
565
- ] })
566
- ]
567
- }
568
- )
569
- ] });
570
- }
571
- function SheetHeader({ className, ...props }) {
572
- return /* @__PURE__ */ jsxRuntime.jsx(
573
- "div",
574
- {
575
- "data-slot": "sheet-header",
576
- className: cn("flex flex-col gap-1.5 p-4", className),
577
- ...props
578
- }
579
- );
580
- }
581
- function SheetTitle({
582
- className,
583
- ...props
584
- }) {
585
- return /* @__PURE__ */ jsxRuntime.jsx(
586
- SheetPrimitive__namespace.Title,
587
- {
588
- "data-slot": "sheet-title",
589
- className: cn("text-foreground font-semibold", className),
590
- ...props
591
- }
592
- );
593
- }
594
- function SheetDescription({
595
- className,
596
- ...props
597
- }) {
598
- return /* @__PURE__ */ jsxRuntime.jsx(
599
- SheetPrimitive__namespace.Description,
600
- {
601
- "data-slot": "sheet-description",
602
- className: cn("text-muted-foreground text-sm", className),
603
- ...props
604
- }
605
- );
606
- }
607
- function Skeleton({ className, ...props }) {
608
- return /* @__PURE__ */ jsxRuntime.jsx(
609
- "div",
610
- {
611
- "data-slot": "skeleton",
612
- className: cn("bg-accent animate-pulse rounded-md", className),
613
- ...props
614
- }
615
- );
616
- }
617
- function TooltipProvider({
618
- delayDuration = 0,
619
- ...props
620
- }) {
621
- return /* @__PURE__ */ jsxRuntime.jsx(
622
- TooltipPrimitive__namespace.Provider,
623
- {
624
- "data-slot": "tooltip-provider",
625
- delayDuration,
626
- ...props
627
- }
628
- );
629
- }
630
- function Tooltip({
631
- ...props
632
- }) {
633
- return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Root, { "data-slot": "tooltip", ...props }) });
634
- }
635
- function TooltipTrigger({
636
- ...props
637
- }) {
638
- return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Trigger, { "data-slot": "tooltip-trigger", ...props });
639
- }
640
- function TooltipContent({
641
- className,
642
- sideOffset = 0,
643
- children,
644
- ...props
645
- }) {
646
- return /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
647
- TooltipPrimitive__namespace.Content,
648
- {
649
- "data-slot": "tooltip-content",
650
- sideOffset,
651
- className: cn(
652
- "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",
653
- className
654
- ),
655
- ...props,
656
- children: [
657
- children,
658
- /* @__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]" })
659
- ]
660
- }
661
- ) });
662
- }
663
- var SIDEBAR_COOKIE_NAME = "sidebar_state";
664
- var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
665
- var SIDEBAR_WIDTH = "16rem";
666
- var SIDEBAR_WIDTH_MOBILE = "18rem";
667
- var SIDEBAR_WIDTH_ICON = "3rem";
668
- var SIDEBAR_KEYBOARD_SHORTCUT = "b";
669
- var SidebarContext = React2__namespace.createContext(null);
670
- function useSidebar() {
671
- const context = React2__namespace.useContext(SidebarContext);
672
- if (!context) {
673
- throw new Error("useSidebar must be used within a SidebarProvider.");
674
- }
675
- return context;
676
- }
677
- function SidebarProvider({
678
- defaultOpen = true,
679
- open: openProp,
680
- onOpenChange: setOpenProp,
681
- className,
682
- style,
683
- children,
684
- ...props
685
- }) {
686
- const isMobile = useIsMobile();
687
- const [openMobile, setOpenMobile] = React2__namespace.useState(false);
688
- const [_open, _setOpen] = React2__namespace.useState(defaultOpen);
689
- const open = openProp ?? _open;
690
- const setOpen = React2__namespace.useCallback(
691
- (value) => {
692
- const openState = typeof value === "function" ? value(open) : value;
693
- if (setOpenProp) {
694
- setOpenProp(openState);
695
- } else {
696
- _setOpen(openState);
697
- }
698
- document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
699
- },
700
- [setOpenProp, open]
701
- );
702
- const toggleSidebar = React2__namespace.useCallback(() => {
703
- return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
704
- }, [isMobile, setOpen, setOpenMobile]);
705
- React2__namespace.useEffect(() => {
706
- const handleKeyDown = (event) => {
707
- if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
708
- event.preventDefault();
709
- toggleSidebar();
710
- }
711
- };
712
- window.addEventListener("keydown", handleKeyDown);
713
- return () => window.removeEventListener("keydown", handleKeyDown);
714
- }, [toggleSidebar]);
715
- const state = open ? "expanded" : "collapsed";
716
- const contextValue = React2__namespace.useMemo(
717
- () => ({
718
- state,
719
- open,
720
- setOpen,
721
- isMobile,
722
- openMobile,
723
- setOpenMobile,
724
- toggleSidebar
725
- }),
726
- [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
727
- );
728
- return /* @__PURE__ */ jsxRuntime.jsx(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
729
- "div",
730
- {
731
- "data-slot": "sidebar-wrapper",
732
- style: {
733
- "--sidebar-width": SIDEBAR_WIDTH,
734
- "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
735
- ...style
736
- },
737
- className: cn(
738
- "group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",
739
- className
740
- ),
741
- ...props,
742
- children
743
- }
744
- ) }) });
745
- }
746
- function Sidebar({
747
- side = "left",
748
- variant = "sidebar",
749
- collapsible = "offcanvas",
750
- className,
751
- children,
752
- ...props
753
- }) {
754
- const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
755
- if (collapsible === "none") {
756
- return /* @__PURE__ */ jsxRuntime.jsx(
757
- "div",
758
- {
759
- "data-slot": "sidebar",
760
- className: cn(
761
- "bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",
762
- className
763
- ),
764
- ...props,
765
- children
766
- }
767
- );
768
- }
769
- if (isMobile) {
770
- return /* @__PURE__ */ jsxRuntime.jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxRuntime.jsxs(
771
- SheetContent,
772
- {
773
- "data-sidebar": "sidebar",
774
- "data-slot": "sidebar",
775
- "data-mobile": "true",
776
- className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",
777
- style: {
778
- "--sidebar-width": SIDEBAR_WIDTH_MOBILE
779
- },
780
- side,
781
- children: [
782
- /* @__PURE__ */ jsxRuntime.jsxs(SheetHeader, { className: "sr-only", children: [
783
- /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: "Sidebar" }),
784
- /* @__PURE__ */ jsxRuntime.jsx(SheetDescription, { children: "Displays the mobile sidebar." })
785
- ] }),
786
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full w-full flex-col", children })
787
- ]
788
- }
789
- ) });
790
- }
791
- return /* @__PURE__ */ jsxRuntime.jsxs(
792
- "div",
793
- {
794
- className: "group peer text-sidebar-foreground hidden md:block",
795
- "data-state": state,
796
- "data-collapsible": state === "collapsed" ? collapsible : "",
797
- "data-variant": variant,
798
- "data-side": side,
799
- "data-slot": "sidebar",
800
- children: [
801
- /* @__PURE__ */ jsxRuntime.jsx(
802
- "div",
803
- {
804
- "data-slot": "sidebar-gap",
805
- className: cn(
806
- "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
807
- "group-data-[collapsible=offcanvas]:w-0",
808
- "group-data-[side=right]:rotate-180",
809
- variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
810
- )
811
- }
812
- ),
813
- /* @__PURE__ */ jsxRuntime.jsx(
814
- "div",
815
- {
816
- "data-slot": "sidebar-container",
817
- className: cn(
818
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
819
- 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)]",
820
- // Adjust the padding for floating and inset variants.
821
- 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",
822
- className
823
- ),
824
- ...props,
825
- children: /* @__PURE__ */ jsxRuntime.jsx(
826
- "div",
827
- {
828
- "data-sidebar": "sidebar",
829
- "data-slot": "sidebar-inner",
830
- 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",
831
- children
832
- }
833
- )
834
- }
835
- )
836
- ]
837
- }
838
- );
839
- }
840
- function SidebarTrigger({
841
- className,
842
- onClick,
843
- ...props
844
- }) {
845
- const { toggleSidebar } = useSidebar();
846
- return /* @__PURE__ */ jsxRuntime.jsxs(
847
- Button,
848
- {
849
- "data-sidebar": "trigger",
850
- "data-slot": "sidebar-trigger",
851
- variant: "ghost",
852
- size: "icon",
853
- className: cn("size-7", className),
854
- onClick: (event) => {
855
- onClick?.(event);
856
- toggleSidebar();
857
- },
858
- ...props,
859
- children: [
860
- /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.PanelLeftIcon, {}),
861
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Toggle Sidebar" })
862
- ]
863
- }
864
- );
865
- }
866
- function SidebarRail({ className, ...props }) {
867
- const { toggleSidebar } = useSidebar();
868
- return /* @__PURE__ */ jsxRuntime.jsx(
869
- "button",
870
- {
871
- "data-sidebar": "rail",
872
- "data-slot": "sidebar-rail",
873
- "aria-label": "Toggle Sidebar",
874
- tabIndex: -1,
875
- onClick: toggleSidebar,
876
- title: "Toggle Sidebar",
877
- className: cn(
878
- "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",
879
- "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
880
- "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
881
- "hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full",
882
- "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
883
- "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
884
- className
885
- ),
886
- ...props
887
- }
888
- );
889
- }
890
- function SidebarInset({ className, ...props }) {
891
- return /* @__PURE__ */ jsxRuntime.jsx(
892
- "main",
893
- {
894
- "data-slot": "sidebar-inset",
895
- className: cn(
896
- "bg-background relative flex w-full flex-1 flex-col",
897
- "px-4",
898
- "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",
899
- className
900
- ),
901
- ...props
902
- }
903
- );
904
- }
905
- function SidebarHeader({ className, ...props }) {
906
- return /* @__PURE__ */ jsxRuntime.jsx(
907
- "div",
908
- {
909
- "data-slot": "sidebar-header",
910
- "data-sidebar": "header",
911
- className: cn("flex flex-col gap-2 p-2", className),
912
- ...props
913
- }
914
- );
915
- }
916
- function SidebarFooter({ className, ...props }) {
917
- return /* @__PURE__ */ jsxRuntime.jsx(
918
- "div",
919
- {
920
- "data-slot": "sidebar-footer",
921
- "data-sidebar": "footer",
922
- className: cn("flex flex-col gap-2 p-2", className),
923
- ...props
924
- }
925
- );
926
- }
927
- function SidebarContent({ className, ...props }) {
928
- return /* @__PURE__ */ jsxRuntime.jsx(
929
- "div",
930
- {
931
- "data-slot": "sidebar-content",
932
- "data-sidebar": "content",
933
- className: cn(
934
- "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
935
- className
936
- ),
937
- ...props
938
- }
939
- );
940
- }
941
- function SidebarGroup({ className, ...props }) {
942
- return /* @__PURE__ */ jsxRuntime.jsx(
943
- "div",
944
- {
945
- "data-slot": "sidebar-group",
946
- "data-sidebar": "group",
947
- className: cn("relative flex w-full min-w-0 flex-col p-2", className),
948
- ...props
949
- }
950
- );
951
- }
952
- function SidebarGroupLabel({
953
- className,
954
- asChild = false,
955
- ...props
956
- }) {
957
- const Comp = asChild ? reactSlot.Slot : "div";
958
- return /* @__PURE__ */ jsxRuntime.jsx(
959
- Comp,
960
- {
961
- "data-slot": "sidebar-group-label",
962
- "data-sidebar": "group-label",
963
- className: cn(
964
- "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",
965
- "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
966
- className
967
- ),
968
- ...props
969
- }
970
- );
971
- }
972
- function SidebarMenu({ className, ...props }) {
973
- return /* @__PURE__ */ jsxRuntime.jsx(
974
- "ul",
975
- {
976
- "data-slot": "sidebar-menu",
977
- "data-sidebar": "menu",
978
- className: cn("flex w-full min-w-0 flex-col gap-1", className),
979
- ...props
980
- }
981
- );
982
- }
983
- function SidebarMenuItem({ className, ...props }) {
984
- return /* @__PURE__ */ jsxRuntime.jsx(
985
- "li",
986
- {
987
- "data-slot": "sidebar-menu-item",
988
- "data-sidebar": "menu-item",
989
- className: cn("group/menu-item relative", className),
990
- ...props
991
- }
992
- );
993
- }
994
- var sidebarMenuButtonVariants = classVarianceAuthority.cva(
995
- "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",
996
- {
997
- variants: {
998
- variant: {
999
- default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
1000
- 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))]"
1001
- },
1002
- size: {
1003
- default: "h-8 text-sm",
1004
- sm: "h-7 text-xs",
1005
- lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
1006
- }
1007
- },
1008
- defaultVariants: {
1009
- variant: "default",
1010
- size: "default"
1011
- }
1012
- }
1013
- );
1014
- function SidebarMenuButton({
1015
- asChild = false,
1016
- isActive = false,
1017
- variant = "default",
1018
- size = "default",
1019
- tooltip,
1020
- className,
1021
- ...props
1022
- }) {
1023
- const Comp = asChild ? reactSlot.Slot : "button";
1024
- const { isMobile, state } = useSidebar();
1025
- const button = /* @__PURE__ */ jsxRuntime.jsx(
1026
- Comp,
1027
- {
1028
- "data-slot": "sidebar-menu-button",
1029
- "data-sidebar": "menu-button",
1030
- "data-size": size,
1031
- "data-active": isActive,
1032
- className: cn(sidebarMenuButtonVariants({ variant, size }), className),
1033
- ...props
1034
- }
1035
- );
1036
- if (!tooltip) {
1037
- return button;
1038
- }
1039
- if (typeof tooltip === "string") {
1040
- tooltip = {
1041
- children: tooltip
1042
- };
1043
- }
1044
- return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
1045
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: button }),
1046
- /* @__PURE__ */ jsxRuntime.jsx(
1047
- TooltipContent,
1048
- {
1049
- side: "right",
1050
- align: "center",
1051
- hidden: state !== "collapsed" || isMobile,
1052
- ...tooltip
1053
- }
1054
- )
1055
- ] });
1056
- }
1057
- function SidebarMenuSub({ className, ...props }) {
1058
- return /* @__PURE__ */ jsxRuntime.jsx(
1059
- "ul",
1060
- {
1061
- "data-slot": "sidebar-menu-sub",
1062
- "data-sidebar": "menu-sub",
1063
- className: cn(
1064
- "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",
1065
- "group-data-[collapsible=icon]:hidden",
1066
- className
1067
- ),
1068
- ...props
1069
- }
1070
- );
1071
- }
1072
- function SidebarMenuSubItem({
1073
- className,
1074
- ...props
1075
- }) {
1076
- return /* @__PURE__ */ jsxRuntime.jsx(
1077
- "li",
1078
- {
1079
- "data-slot": "sidebar-menu-sub-item",
1080
- "data-sidebar": "menu-sub-item",
1081
- className: cn("group/menu-sub-item relative", className),
1082
- ...props
1083
- }
1084
- );
1085
- }
1086
- function SidebarMenuSubButton({
1087
- asChild = false,
1088
- size = "md",
1089
- isActive = false,
1090
- className,
1091
- ...props
1092
- }) {
1093
- const Comp = asChild ? reactSlot.Slot : "a";
1094
- return /* @__PURE__ */ jsxRuntime.jsx(
1095
- Comp,
1096
- {
1097
- "data-slot": "sidebar-menu-sub-button",
1098
- "data-sidebar": "menu-sub-button",
1099
- "data-size": size,
1100
- "data-active": isActive,
1101
- className: cn(
1102
- "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",
1103
- "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
1104
- size === "sm" && "text-xs",
1105
- size === "md" && "text-sm",
1106
- "group-data-[collapsible=icon]:hidden",
1107
- className
1108
- ),
1109
- ...props
1110
- }
1111
- );
1112
- }
1113
- function Collapsible({
1114
- ...props
1115
- }) {
1116
- return /* @__PURE__ */ jsxRuntime.jsx(CollapsiblePrimitive__namespace.Root, { "data-slot": "collapsible", ...props });
1117
- }
1118
- function CollapsibleTrigger2({
1119
- ...props
1120
- }) {
1121
- return /* @__PURE__ */ jsxRuntime.jsx(
1122
- CollapsiblePrimitive__namespace.CollapsibleTrigger,
1123
- {
1124
- "data-slot": "collapsible-trigger",
1125
- ...props
1126
- }
1127
- );
1128
- }
1129
- function CollapsibleContent2({
1130
- ...props
1131
- }) {
1132
- return /* @__PURE__ */ jsxRuntime.jsx(
1133
- CollapsiblePrimitive__namespace.CollapsibleContent,
1134
- {
1135
- "data-slot": "collapsible-content",
1136
- ...props
1137
- }
1138
- );
1139
- }
1140
- var ICON_MAP = {
1141
- Home: LucideIcons__namespace.Home,
1142
- Users: LucideIcons__namespace.Users,
1143
- GalleryVerticalEnd: LucideIcons__namespace.GalleryVerticalEnd,
1144
- Settings: LucideIcons__namespace.Settings,
1145
- CreditCard: LucideIcons__namespace.CreditCard,
1146
- Building2: LucideIcons__namespace.Building2,
1147
- Check: LucideIcons__namespace.Check,
1148
- ChevronsUpDown: LucideIcons__namespace.ChevronsUpDown,
1149
- ChevronRight: LucideIcons__namespace.ChevronRight,
1150
- BadgeCheck: LucideIcons__namespace.BadgeCheck,
1151
- LogOut: LucideIcons__namespace.LogOut
1152
- // Add more icons as needed
1153
- };
1154
- function getIconComponent(icon) {
1155
- if (!icon) {
1156
- return void 0;
1157
- }
1158
- if (typeof icon !== "string") {
1159
- return icon;
1160
- }
1161
- return ICON_MAP[icon];
1162
- }
1163
- function NavMain({ items }) {
1164
- const pathname = navigation.usePathname();
1165
- const groups = [];
1166
- let currentGroup = {
1167
- items: []
1168
- };
1169
- items.forEach((item) => {
1170
- const iconComponent = getIconComponent(item.icon);
1171
- if (!item.url) {
1172
- if (currentGroup.items.length > 0 || currentGroup.label) {
1173
- groups.push(currentGroup);
1174
- }
1175
- currentGroup = {
1176
- label: { title: item.title, icon: iconComponent },
1177
- items: []
1178
- };
1179
- } else {
1180
- currentGroup.items.push({
1181
- title: item.title,
1182
- url: item.url,
1183
- icon: iconComponent,
1184
- isActive: item.isActive,
1185
- items: item.items
1186
- });
1187
- }
1188
- });
1189
- if (currentGroup.items.length > 0 || currentGroup.label) {
1190
- groups.push(currentGroup);
1191
- }
1192
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: groups.map((group, groupIndex) => /* @__PURE__ */ jsxRuntime.jsxs(SidebarGroup, { children: [
1193
- group.label && /* @__PURE__ */ jsxRuntime.jsxs(SidebarGroupLabel, { children: [
1194
- group.label.icon && /* @__PURE__ */ jsxRuntime.jsx(group.label.icon, { className: "mr-2" }),
1195
- group.label.title
1196
- ] }),
1197
- group.items.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: group.items.map((item) => {
1198
- const isActive = pathname === item.url || item.isActive;
1199
- const hasSubItems = item.items && item.items.length > 0;
1200
- if (hasSubItems) {
1201
- return /* @__PURE__ */ jsxRuntime.jsx(
1202
- Collapsible,
1203
- {
1204
- asChild: true,
1205
- defaultOpen: isActive,
1206
- className: "group/collapsible",
1207
- children: /* @__PURE__ */ jsxRuntime.jsxs(SidebarMenuItem, { children: [
1208
- /* @__PURE__ */ jsxRuntime.jsx(CollapsibleTrigger2, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1209
- SidebarMenuButton,
1210
- {
1211
- tooltip: item.title,
1212
- isActive,
1213
- children: [
1214
- item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
1215
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title }),
1216
- /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronRight, { className: "ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" })
1217
- ]
1218
- }
1219
- ) }),
1220
- /* @__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)) }) })
1221
- ] })
1222
- },
1223
- item.title
1224
- );
1225
- }
1226
- return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsx(
1227
- SidebarMenuButton,
1228
- {
1229
- asChild: true,
1230
- tooltip: item.title,
1231
- isActive,
1232
- children: /* @__PURE__ */ jsxRuntime.jsxs(Link__default.default, { href: item.url, children: [
1233
- item.icon && /* @__PURE__ */ jsxRuntime.jsx(item.icon, {}),
1234
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: item.title })
1235
- ] })
1236
- }
1237
- ) }, item.title);
1238
- }) })
1239
- ] }, groupIndex)) });
1240
- }
1241
- function Avatar({
1242
- className,
1243
- ...props
1244
- }) {
1245
- return /* @__PURE__ */ jsxRuntime.jsx(
1246
- AvatarPrimitive__namespace.Root,
1247
- {
1248
- "data-slot": "avatar",
1249
- className: cn(
1250
- "relative flex size-8 shrink-0 overflow-hidden rounded-full",
1251
- className
1252
- ),
1253
- ...props
1254
- }
1255
- );
1256
- }
1257
- function AvatarImage({
1258
- className,
1259
- ...props
1260
- }) {
1261
- return /* @__PURE__ */ jsxRuntime.jsx(
1262
- AvatarPrimitive__namespace.Image,
1263
- {
1264
- "data-slot": "avatar-image",
1265
- className: cn("aspect-square size-full", className),
1266
- ...props
1267
- }
1268
- );
1269
- }
1270
- function AvatarFallback({
1271
- className,
1272
- ...props
1273
- }) {
1274
- return /* @__PURE__ */ jsxRuntime.jsx(
1275
- AvatarPrimitive__namespace.Fallback,
1276
- {
1277
- "data-slot": "avatar-fallback",
1278
- className: cn(
1279
- "bg-muted flex size-full items-center justify-center rounded-full",
1280
- className
1281
- ),
1282
- ...props
1283
- }
1284
- );
1285
- }
1286
- function DropdownMenu({
1287
- ...props
1288
- }) {
1289
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Root, { "data-slot": "dropdown-menu", ...props });
1290
- }
1291
- function DropdownMenuTrigger({
1292
- ...props
1293
- }) {
1294
- return /* @__PURE__ */ jsxRuntime.jsx(
1295
- DropdownMenuPrimitive__namespace.Trigger,
1296
- {
1297
- "data-slot": "dropdown-menu-trigger",
1298
- ...props
1299
- }
1300
- );
1301
- }
1302
- function DropdownMenuContent({
1303
- className,
1304
- sideOffset = 4,
1305
- ...props
1306
- }) {
1307
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
1308
- DropdownMenuPrimitive__namespace.Content,
1309
- {
1310
- "data-slot": "dropdown-menu-content",
1311
- sideOffset,
1312
- className: cn(
1313
- "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",
1314
- className
1315
- ),
1316
- ...props
1317
- }
1318
- ) });
1319
- }
1320
- function DropdownMenuGroup({
1321
- ...props
1322
- }) {
1323
- return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuPrimitive__namespace.Group, { "data-slot": "dropdown-menu-group", ...props });
1324
- }
1325
- function DropdownMenuItem({
1326
- className,
1327
- inset,
1328
- variant = "default",
1329
- ...props
1330
- }) {
1331
- return /* @__PURE__ */ jsxRuntime.jsx(
1332
- DropdownMenuPrimitive__namespace.Item,
1333
- {
1334
- "data-slot": "dropdown-menu-item",
1335
- "data-inset": inset,
1336
- "data-variant": variant,
1337
- className: cn(
1338
- "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",
1339
- className
1340
- ),
1341
- ...props
1342
- }
1343
- );
1344
- }
1345
- function DropdownMenuLabel({
1346
- className,
1347
- inset,
1348
- ...props
1349
- }) {
1350
- return /* @__PURE__ */ jsxRuntime.jsx(
1351
- DropdownMenuPrimitive__namespace.Label,
1352
- {
1353
- "data-slot": "dropdown-menu-label",
1354
- "data-inset": inset,
1355
- className: cn(
1356
- "px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",
1357
- className
1358
- ),
1359
- ...props
1360
- }
1361
- );
1362
- }
1363
- function DropdownMenuSeparator({
1364
- className,
1365
- ...props
1366
- }) {
1367
- return /* @__PURE__ */ jsxRuntime.jsx(
1368
- DropdownMenuPrimitive__namespace.Separator,
1369
- {
1370
- "data-slot": "dropdown-menu-separator",
1371
- className: cn("bg-border -mx-1 my-1 h-px", className),
1372
- ...props
1373
- }
1374
- );
1375
- }
1376
- function getInitials(name, email) {
1377
- if (name) {
1378
- const parts = name.trim().split(/\s+/);
1379
- if (parts.length >= 2) {
1380
- const first = parts[0];
1381
- const last = parts[parts.length - 1];
1382
- if (first && last && first[0] && last[0]) {
1383
- return (first[0] + last[0]).toUpperCase();
1384
- }
1385
- }
1386
- const firstChar2 = name[0];
1387
- if (firstChar2) {
1388
- return firstChar2.toUpperCase();
1389
- }
1390
- }
1391
- const firstChar = email[0];
1392
- if (firstChar) {
1393
- return firstChar.toUpperCase();
1394
- }
1395
- return "?";
1396
- }
1397
- function NavUser({ user }) {
1398
- const sidebar = useSidebar();
1399
- const isMobile = sidebar?.isMobile ?? false;
1400
- const router = navigation.useRouter();
1401
- const initials = getInitials(user.name, user.email);
1402
- const displayName = user.name || user.email;
1403
- const handleSignOut = async () => {
1404
- await react.signOut({ redirect: false });
1405
- router.push("/auth/signin");
1406
- router.refresh();
1407
- };
1408
- return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1409
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1410
- SidebarMenuButton,
1411
- {
1412
- size: "lg",
1413
- className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
1414
- children: [
1415
- /* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "h-8 w-8 rounded-lg", children: [
1416
- /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: user.image || void 0, alt: displayName }),
1417
- /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { className: "rounded-lg", children: initials })
1418
- ] }),
1419
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1420
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: displayName }),
1421
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs", children: user.email })
1422
- ] }),
1423
- /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronsUpDown, { className: "ml-auto size-4" })
1424
- ]
1425
- }
1426
- ) }),
1427
- /* @__PURE__ */ jsxRuntime.jsxs(
1428
- DropdownMenuContent,
1429
- {
1430
- className: "w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",
1431
- side: isMobile ? "bottom" : "right",
1432
- align: "end",
1433
- sideOffset: 4,
1434
- children: [
1435
- /* @__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: [
1436
- /* @__PURE__ */ jsxRuntime.jsxs(Avatar, { className: "h-8 w-8 rounded-lg", children: [
1437
- /* @__PURE__ */ jsxRuntime.jsx(AvatarImage, { src: user.image || void 0, alt: displayName }),
1438
- /* @__PURE__ */ jsxRuntime.jsx(AvatarFallback, { className: "rounded-lg", children: initials })
1439
- ] }),
1440
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1441
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: displayName }),
1442
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs", children: user.email })
1443
- ] })
1444
- ] }) }),
1445
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1446
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuGroup, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { children: [
1447
- /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.BadgeCheck, {}),
1448
- "Account"
1449
- ] }) }),
1450
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1451
- /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenuItem, { onClick: handleSignOut, children: [
1452
- /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.LogOut, {}),
1453
- "Log out"
1454
- ] })
1455
- ]
1456
- }
1457
- )
1458
- ] }) }) });
1459
- }
1460
- function TeamSwitcher({
1461
- teams,
1462
- organizationId
1463
- }) {
1464
- const sidebar = useSidebar();
1465
- const isMobile = sidebar?.isMobile ?? false;
1466
- const pathname = navigation.usePathname();
1467
- const router = navigation.useRouter();
1468
- const pathSegments = pathname.split("/");
1469
- const isAppOrgRoute = pathname.startsWith("/app/") && pathSegments.length > 2 && pathSegments[2] !== "user";
1470
- const pathOrgId = isAppOrgRoute ? pathSegments[2] : null;
1471
- const currentOrgId = organizationId || (pathOrgId && teams.some((team) => team.id === pathOrgId) ? pathOrgId : null);
1472
- const activeTeam = currentOrgId ? teams.find((team) => team.id === currentOrgId) : null;
1473
- const handleTeamChange = (teamId) => {
1474
- router.push(`/app/${teamId}/home`);
1475
- router.refresh();
1476
- };
1477
- const teamsWithLogo = teams.map((org) => {
1478
- const logoIcon = org.logo ? getIconComponent(org.logo) : LucideIcons.GalleryVerticalEnd;
1479
- return {
1480
- id: org.id,
1481
- name: org.name,
1482
- logo: logoIcon || LucideIcons.GalleryVerticalEnd,
1483
- plan: org.plan || "Member"
1484
- };
1485
- });
1486
- if (teamsWithLogo.length === 0) {
1487
- return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(SidebarMenuButton, { size: "lg", className: "cursor-default", children: [
1488
- /* @__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" }) }),
1489
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1490
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium text-muted-foreground", children: "No organizations" }),
1491
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs text-muted-foreground", children: "Join or create one" })
1492
- ] })
1493
- ] }) }) });
1494
- }
1495
- if (!activeTeam) {
1496
- return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1497
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1498
- SidebarMenuButton,
1499
- {
1500
- size: "lg",
1501
- className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
1502
- children: [
1503
- /* @__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" }) }),
1504
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1505
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: "Organizations" }),
1506
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "truncate text-xs text-muted-foreground", children: [
1507
- teamsWithLogo.length,
1508
- " available"
1509
- ] })
1510
- ] }),
1511
- /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronsUpDown, { className: "ml-auto" })
1512
- ]
1513
- }
1514
- ) }),
1515
- /* @__PURE__ */ jsxRuntime.jsxs(
1516
- DropdownMenuContent,
1517
- {
1518
- className: "w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",
1519
- align: "start",
1520
- side: isMobile ? "bottom" : "right",
1521
- sideOffset: 4,
1522
- children: [
1523
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: "Select an organization" }),
1524
- teamsWithLogo.map((team) => /* @__PURE__ */ jsxRuntime.jsxs(
1525
- DropdownMenuItem,
1526
- {
1527
- onClick: () => handleTeamChange(team.id),
1528
- className: "gap-2 p-2",
1529
- children: [
1530
- /* @__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" }) }),
1531
- team.name
1532
- ]
1533
- },
1534
- team.id
1535
- )),
1536
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1537
- /* @__PURE__ */ jsxRuntime.jsxs(
1538
- DropdownMenuItem,
1539
- {
1540
- className: "gap-2 p-2",
1541
- onClick: () => router.push("/app/user/organizations"),
1542
- children: [
1543
- /* @__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" }) }),
1544
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground font-medium", children: "Manage organizations" })
1545
- ]
1546
- }
1547
- )
1548
- ]
1549
- }
1550
- )
1551
- ] }) }) });
1552
- }
1553
- const activeTeamWithLogo = teamsWithLogo.find(
1554
- (team) => team.id === currentOrgId
1555
- );
1556
- if (!activeTeamWithLogo) {
1557
- return null;
1558
- }
1559
- return /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu, { children: [
1560
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
1561
- SidebarMenuButton,
1562
- {
1563
- size: "lg",
1564
- className: "data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",
1565
- children: [
1566
- /* @__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" }) }),
1567
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 text-left text-sm leading-tight", children: [
1568
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate font-medium", children: activeTeamWithLogo.name }),
1569
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-xs", children: activeTeamWithLogo.plan })
1570
- ] }),
1571
- /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.ChevronsUpDown, { className: "ml-auto" })
1572
- ]
1573
- }
1574
- ) }),
1575
- /* @__PURE__ */ jsxRuntime.jsxs(
1576
- DropdownMenuContent,
1577
- {
1578
- className: "w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg",
1579
- align: "start",
1580
- side: isMobile ? "bottom" : "right",
1581
- sideOffset: 4,
1582
- children: [
1583
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuLabel, { className: "text-muted-foreground text-xs", children: "Organizations" }),
1584
- teamsWithLogo.map((team) => /* @__PURE__ */ jsxRuntime.jsxs(
1585
- DropdownMenuItem,
1586
- {
1587
- onClick: () => handleTeamChange(team.id),
1588
- className: "gap-2 p-2",
1589
- children: [
1590
- /* @__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" }) }),
1591
- team.name,
1592
- team.id === currentOrgId && /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Check, { className: "ml-auto h-4 w-4" })
1593
- ]
1594
- },
1595
- team.id
1596
- )),
1597
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenuSeparator, {}),
1598
- /* @__PURE__ */ jsxRuntime.jsxs(
1599
- DropdownMenuItem,
1600
- {
1601
- className: "gap-2 p-2",
1602
- onClick: () => router.push("/app/user/organizations"),
1603
- children: [
1604
- /* @__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" }) }),
1605
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-muted-foreground font-medium", children: "Manage organizations" })
1606
- ]
1607
- }
1608
- )
1609
- ]
1610
- }
1611
- )
1612
- ] }) }) });
1613
- }
1614
- function useNavigation({
1615
- organizationId,
1616
- apiBaseUrl = "/api",
1617
- enabled = true
1618
- } = {}) {
1619
- const [items, setItems] = React2.useState([]);
1620
- const [organizations, setOrganizations] = React2.useState([]);
1621
- const [user, setUser] = React2.useState(null);
1622
- const [loading, setLoading] = React2.useState(false);
1623
- const [error, setError] = React2.useState(null);
1624
- React2.useEffect(() => {
1625
- if (!enabled || !organizationId) {
1626
- setItems([]);
1627
- setOrganizations([]);
1628
- setUser(null);
1629
- return;
1630
- }
1631
- const fetchNavigation = async () => {
1632
- setLoading(true);
1633
- setError(null);
1634
- try {
1635
- const response = await fetch(
1636
- `${apiBaseUrl}/navigation/${organizationId}`,
1637
- {
1638
- credentials: "include"
1639
- // Include cookies for auth
1640
- }
1641
- );
1642
- if (!response.ok) {
1643
- if (response.status === 401) {
1644
- throw new Error("Unauthorized");
1645
- }
1646
- if (response.status === 404) {
1647
- throw new Error("Organization not found");
1648
- }
1649
- throw new Error(`Failed to fetch navigation: ${response.statusText}`);
1650
- }
1651
- const data = await response.json();
1652
- setItems(data.items || []);
1653
- setOrganizations(data.organizations || []);
1654
- setUser(data.user || null);
1655
- } catch (err) {
1656
- const error2 = err instanceof Error ? err : new Error("Unknown error");
1657
- setError(error2);
1658
- setItems([]);
1659
- setOrganizations([]);
1660
- setUser(null);
1661
- } finally {
1662
- setLoading(false);
1663
- }
1664
- };
1665
- fetchNavigation();
1666
- }, [organizationId, apiBaseUrl, enabled]);
1667
- return { items, organizations, user, loading, error };
1668
- }
1669
- function AppSidebar({
1670
- user: userProp,
1671
- organizationId,
1672
- apiBaseUrl,
1673
- ...props
1674
- }) {
1675
- const currentPathname = navigation.usePathname();
1676
- const pathSegments = currentPathname.split("/");
1677
- const isAppOrgRoute = currentPathname.startsWith("/app/") && pathSegments.length > 2 && pathSegments[2] !== "user";
1678
- const pathOrgId = isAppOrgRoute ? pathSegments[2] : null;
1679
- const {
1680
- items: apiNavigationItems,
1681
- organizations: apiOrganizations,
1682
- user: navigationUser,
1683
- loading: navigationLoading
1684
- } = useNavigation({
1685
- organizationId: organizationId || pathOrgId || void 0,
1686
- apiBaseUrl,
1687
- enabled: true
1688
- });
1689
- const user = navigationUser || userProp;
1690
- const currentOrgId = organizationId || (pathOrgId && apiOrganizations.some((org) => org.id === pathOrgId) ? pathOrgId : void 0);
1691
- let navigationItems = apiNavigationItems;
1692
- if (currentOrgId && navigationItems.length > 0) {
1693
- navigationItems = navigationItems.map((item) => ({
1694
- ...item,
1695
- url: item.url?.replace("{organizationId}", currentOrgId),
1696
- items: item.items?.map((subItem) => ({
1697
- ...subItem,
1698
- url: subItem.url.replace("{organizationId}", currentOrgId)
1699
- }))
1700
- }));
1701
- }
1702
- const displayNavigationItems = currentOrgId ? navigationItems : [];
1703
- return /* @__PURE__ */ jsxRuntime.jsxs(Sidebar, { collapsible: "icon", ...props, children: [
1704
- /* @__PURE__ */ jsxRuntime.jsx(SidebarHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(
1705
- TeamSwitcher,
1706
- {
1707
- teams: apiOrganizations,
1708
- organizationId: currentOrgId || void 0
1709
- }
1710
- ) }),
1711
- /* @__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 }) }),
1712
- /* @__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: [
1713
- /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-8 w-8 rounded-lg" }),
1714
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid flex-1 gap-1 text-left text-sm", children: [
1715
- /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-4 w-24" }),
1716
- /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-3 w-32" })
1717
- ] })
1718
- ] }) }) }) }),
1719
- /* @__PURE__ */ jsxRuntime.jsx(SidebarRail, {})
1720
- ] });
1721
- }
1722
- function AppLayout({
1723
- user,
1724
- organizationId,
1725
- apiBaseUrl,
1726
- children
1727
- }) {
1728
- return /* @__PURE__ */ jsxRuntime.jsxs(SidebarProvider, { children: [
1729
- /* @__PURE__ */ jsxRuntime.jsx(
1730
- AppSidebar,
1731
- {
1732
- user,
1733
- organizationId,
1734
- apiBaseUrl
1735
- }
1736
- ),
1737
- /* @__PURE__ */ jsxRuntime.jsxs(SidebarInset, { children: [
1738
- /* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, {}),
1739
- children
1740
- ] })
1741
- ] });
1742
- }
1743
409
 
1744
- exports.AppLayout = AppLayout;
1745
- exports.AppSidebar = AppSidebar;
1746
- exports.NavMain = NavMain;
1747
- exports.NavUser = NavUser;
1748
- exports.TeamSwitcher = TeamSwitcher;
1749
410
  exports.checkPageAuth = checkPageAuth;
1750
411
  exports.createProxyHandler = createProxyHandler;
1751
412
  exports.defaultProxyConfig = defaultProxyConfig;
1752
413
  exports.getBaseUrl = getBaseUrl;
1753
- exports.getIconComponent = getIconComponent;
1754
414
  exports.getSession = getSession;
1755
415
  exports.getSessionCookie = getSessionCookie;
1756
416
  exports.getSessionFromRequest = getSessionFromRequest;
@@ -1759,7 +419,6 @@ exports.getUserRoles = getUserRoles;
1759
419
  exports.hasRequiredRole = hasRequiredRole;
1760
420
  exports.isSecureCookie = isSecureCookie;
1761
421
  exports.requireAuth = requireAuth;
1762
- exports.useNavigation = useNavigation;
1763
422
  exports.withAuth = withAuth;
1764
423
  //# sourceMappingURL=index.cjs.map
1765
424
  //# sourceMappingURL=index.cjs.map