"use client";

// src/components/ui/sidebar-drill-in.tsx
import * as React2 from "react";

// src/lib/utils.ts
import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";
function cn(...inputs) {
  return twMerge(clsx(inputs));
}

// src/components/ui/sidebar.tsx
import * as React from "react";
import { cva } from "class-variance-authority";
import { Slot } from "radix-ui";

// src/components/ui/tooltip.tsx
import { Tooltip as TooltipPrimitive } from "radix-ui";
import { jsx, jsxs } from "react/jsx-runtime";
function Tooltip({
  ...props
}) {
  return /* @__PURE__ */ jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props });
}
function TooltipTrigger({
  className,
  ...props
}) {
  return /* @__PURE__ */ jsx(
    TooltipPrimitive.Trigger,
    {
      "data-slot": "tooltip-trigger",
      suppressHydrationWarning: true,
      className: cn("cursor-pointer", className),
      ...props
    }
  );
}
function TooltipContent({
  className,
  sideOffset = 0,
  children,
  ...props
}) {
  return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
    TooltipPrimitive.Content,
    {
      "data-slot": "tooltip-content",
      sideOffset,
      className: cn(
        "z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pe-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-end-2 data-[side=right]:slide-in-from-start-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
        className
      ),
      ...props,
      children: [
        children,
        /* @__PURE__ */ jsx(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground" })
      ]
    }
  ) });
}

// src/components/ui/sidebar.tsx
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
var SidebarContext = React.createContext(null);
function useSidebar() {
  const context = React.useContext(SidebarContext);
  if (!context) {
    throw new Error("useSidebar must be used within a SidebarProvider.");
  }
  return context;
}
function SidebarGroup({ className, ...props }) {
  return /* @__PURE__ */ jsx2(
    "div",
    {
      "data-slot": "sidebar-group",
      "data-sidebar": "group",
      className: cn("relative flex w-full min-w-0 flex-col p-2", className),
      ...props
    }
  );
}
function SidebarGroupLabel({
  className,
  asChild = false,
  ...props
}) {
  const Comp = asChild ? Slot.Root : "p";
  return /* @__PURE__ */ jsx2(
    Comp,
    {
      "data-slot": "sidebar-group-label",
      "data-sidebar": "group-label",
      className: cn(
        "m-0 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-section-label ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:hidden focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
        className
      ),
      ...props
    }
  );
}
function SidebarGroupContent({
  className,
  ...props
}) {
  return /* @__PURE__ */ jsx2(
    "div",
    {
      "data-slot": "sidebar-group-content",
      "data-sidebar": "group-content",
      className: cn("w-full text-sm", className),
      ...props
    }
  );
}
function SidebarMenu({ className, ...props }) {
  return /* @__PURE__ */ jsx2(
    "ul",
    {
      "data-slot": "sidebar-menu",
      "data-sidebar": "menu",
      className: cn("flex w-full min-w-0 flex-col gap-0", className),
      ...props
    }
  );
}
function SidebarMenuItem({ className, ...props }) {
  return /* @__PURE__ */ jsx2(
    "li",
    {
      "data-slot": "sidebar-menu-item",
      "data-sidebar": "menu-item",
      suppressHydrationWarning: true,
      className: cn(
        "group/menu-item relative",
        /* Icon rail: center the square menu control in the column (footer + primary). */
        "group-data-[collapsible=icon]:flex group-data-[collapsible=icon]:justify-center",
        className
      ),
      ...props
    }
  );
}
var sidebarMenuButtonVariants = cva(
  "peer/menu-button group/menu-button flex w-full group-data-[collapsible=icon]:w-8 cursor-pointer select-none items-center gap-2 overflow-hidden rounded-md p-2 text-start text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pe-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! 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 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-background data-active:font-medium data-active:text-foreground data-active:shadow-sm data-active:ring-1 data-active:ring-sidebar-border data-active:hover:bg-background data-active:hover:text-foreground data-active:hc:border data-active:hc:border-foreground data-active:forced-colors:border data-active:forced-colors:border-[Highlight] [&_svg:not([data-product-logo]):not([data-product-logo-mark])]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 group-data-[collapsible=icon]:[&>*:not(:first-child)]:hidden",
  {
    variants: {
      variant: {
        default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
        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))]"
      },
      size: {
        default: "h-8 text-sm",
        sm: "h-7 text-xs",
        lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default"
    }
  }
);
var SidebarMenuButton = React.forwardRef(function SidebarMenuButton2({
  asChild = false,
  isActive = false,
  variant = "default",
  size = "default",
  tooltip,
  className,
  ...props
}, ref) {
  const Comp = asChild ? Slot.Root : "button";
  const { isMobile, state } = useSidebar();
  const button = /* @__PURE__ */ jsx2(
    Comp,
    {
      ref,
      "data-slot": "sidebar-menu-button",
      "data-sidebar": "menu-button",
      "data-size": size,
      "data-active": isActive || void 0,
      className: cn(
        sidebarMenuButtonVariants({ variant, size }),
        className,
        // `asChild` merges the child (e.g. Next `<Link className="w-full">`) onto this node —
        // plain `w-full` can win over `group-data-[collapsible=icon]:w-8` in the stylesheet and
        // squash the icon rail to a non-square hit target (WCAG 2.5.8).
        "group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!min-w-8 group-data-[collapsible=icon]:!max-w-8 group-data-[collapsible=icon]:shrink-0"
      ),
      ...props
    }
  );
  if (!tooltip) {
    return button;
  }
  const tooltipProps = typeof tooltip === "string" ? { children: tooltip } : tooltip;
  return /* @__PURE__ */ jsxs2(Tooltip, { children: [
    /* @__PURE__ */ jsx2(TooltipTrigger, { asChild: true, children: button }),
    /* @__PURE__ */ jsx2(
      TooltipContent,
      {
        side: "right",
        align: "center",
        hidden: state !== "collapsed" || isMobile,
        ...tooltipProps
      }
    )
  ] });
});

// src/components/ui/kbd.tsx
import { jsx as jsx3 } from "react/jsx-runtime";
function Kbd({
  className,
  variant = "tile",
  "aria-hidden": ariaHidden,
  ...props
}) {
  const hidden = ariaHidden ?? (variant === "bare" ? true : void 0);
  return /* @__PURE__ */ jsx3(
    "kbd",
    {
      "data-slot": "kbd",
      "data-variant": variant,
      "aria-hidden": hidden,
      className: cn(
        "pointer-events-none inline-flex h-5 min-w-5 select-none items-center justify-center gap-1 px-1 font-sans text-xs font-medium",
        variant === "tile" && "bg-muted text-muted-foreground rounded-sm border",
        variant === "bare" && "text-current/70 px-0",
        className
      ),
      ...props
    }
  );
}

// src/components/ui/sidebar-drill-in.tsx
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
function SidebarDrillIn({
  open,
  sectionTitle,
  onBack,
  baseContent,
  children,
  className
}) {
  const backButtonRef = React2.useRef(null);
  const mountedRef = React2.useRef(false);
  React2.useEffect(() => {
    if (!mountedRef.current) {
      mountedRef.current = true;
      return;
    }
    if (!open) return;
    const t = window.setTimeout(() => {
      backButtonRef.current?.focus({ preventScroll: true });
    }, 140);
    return () => window.clearTimeout(t);
  }, [open]);
  return /* @__PURE__ */ jsxs3(
    "div",
    {
      "data-slot": "sidebar-drill-in",
      "data-open": open || void 0,
      className: cn(
        "relative flex min-h-0 flex-1 flex-col overflow-x-hidden",
        className
      ),
      children: [
        /* @__PURE__ */ jsx4(
          "div",
          {
            "data-slot": "sidebar-drill-in-base",
            "aria-hidden": open || void 0,
            inert: open,
            className: cn(
              "flex min-h-0 flex-1 flex-col gap-0 motion-safe:transition-transform motion-safe:duration-[120ms] motion-safe:ease-out",
              open && "-translate-x-full"
            ),
            children: baseContent
          }
        ),
        /* @__PURE__ */ jsxs3(
          "div",
          {
            "data-slot": "sidebar-drill-in-section",
            "aria-hidden": !open || void 0,
            inert: !open,
            className: cn(
              "absolute inset-0 flex min-h-0 flex-col gap-0 overflow-y-auto motion-safe:transition-transform motion-safe:duration-[120ms] motion-safe:ease-out",
              !open && "translate-x-full"
            ),
            children: [
              /* @__PURE__ */ jsx4(SidebarGroup, { className: "py-2", children: /* @__PURE__ */ jsx4(SidebarGroupContent, { children: /* @__PURE__ */ jsx4(SidebarMenu, { className: "gap-0.5", children: /* @__PURE__ */ jsx4(SidebarMenuItem, { children: /* @__PURE__ */ jsxs3(
                SidebarMenuButton,
                {
                  ref: backButtonRef,
                  type: "button",
                  "aria-label": "Back to main navigation",
                  onClick: onBack,
                  children: [
                    /* @__PURE__ */ jsx4(
                      "span",
                      {
                        className: "flex size-4 shrink-0 items-center justify-center",
                        "aria-hidden": "true",
                        children: /* @__PURE__ */ jsx4("i", { className: "fa-light fa-arrow-left", "aria-hidden": "true" })
                      }
                    ),
                    /* @__PURE__ */ jsx4("span", { children: "Back" }),
                    /* @__PURE__ */ jsx4(Kbd, { variant: "bare", className: "ms-auto", children: "Esc" })
                  ]
                }
              ) }) }) }) }),
              /* @__PURE__ */ jsxs3(SidebarGroup, { className: "py-0 pt-0", role: "group", "aria-label": sectionTitle, children: [
                /* @__PURE__ */ jsx4(SidebarGroupLabel, { className: "text-xs font-medium uppercase tracking-wide px-2 text-sidebar-section-label", children: sectionTitle }),
                /* @__PURE__ */ jsx4(SidebarGroupContent, { children })
              ] })
            ]
          }
        )
      ]
    }
  );
}
export {
  SidebarDrillIn
};
//# sourceMappingURL=sidebar-drill-in.js.map