{"slug":"animated-sidebar","name":"Animated Sidebar","description":"A composable application sidebar with morphing nested navigation that folds into an animated icon rail on desktop and becomes a focus-managed sheet on mobile.","category":"motion","source_url":"https://beui.dev/r/animated-sidebar/raw","detail_url":"https://beui.dev/r/animated-sidebar","raw_url":"https://beui.dev/r/animated-sidebar/raw","page_url":"https://beui.dev/components/motion/animated-sidebar","markdown_url":"https://beui.dev/components/motion/animated-sidebar.md","published_at":"2026-07-29","updated_at":"2026-11-24","dependencies":["clsx","lucide-react","motion","react","react-dom","tailwind-merge"],"internal":["./animated-sidebar/context","./animated-sidebar/menu-button","./animated-sidebar/menu-sub-button","./animated-sidebar/mobile-sidebar","./animated-sidebar/motion","./animated-sidebar/use-is-mobile","./context","./motion","@/components/motion/animated-sidebar","@/components/motion/shared-layout-bg","@/lib/ease","@/lib/focusable","@/lib/hooks/use-focus-trap","@/lib/i18n","@/lib/layers","@/lib/scroll-lock","@/lib/utils"],"install_slugs":["animated-sidebar"],"requires_theme":false,"props":[{"displayName":"AnimatedSidebarProvider","props":[{"name":"open","type":"boolean","required":false,"defaultValue":null,"description":"Whether the desktop sidebar is expanded, for controlled use."},{"name":"defaultOpen","type":"boolean","required":false,"defaultValue":"true","description":"Whether the desktop sidebar starts expanded when uncontrolled. Default: true"},{"name":"onOpenChange","type":"((open: boolean) => void)","required":false,"defaultValue":null,"description":"Called with the next state when the desktop sidebar expands or collapses."},{"name":"openMobile","type":"boolean","required":false,"defaultValue":null,"description":"Whether the mobile drawer is open, for controlled use."},{"name":"defaultOpenMobile","type":"boolean","required":false,"defaultValue":"false","description":"Whether the mobile drawer starts open when uncontrolled. Default: false"},{"name":"onOpenMobileChange","type":"((open: boolean) => void)","required":false,"defaultValue":null,"description":"Called with the next state when the mobile drawer opens or closes."},{"name":"style","type":"SidebarProviderStyle","required":false,"defaultValue":null,"description":"Inline styles; set `--sidebar-width`, `--sidebar-width-icon` or `--sidebar-width-mobile` here."},{"name":"labels","type":"Partial<{ label: string; toggle: string; close: string; }>","required":false,"defaultValue":null,"description":"Override any built-in string."},{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarMenuSubButton","props":[{"name":"icon","type":"ReactNode","required":false,"defaultValue":null,"description":"Leading icon. Defaults to a small dot."},{"name":"href","type":"string","required":false,"defaultValue":null,"description":"Renders a link to this URL instead of a button."},{"name":"isActive","type":"boolean","required":false,"defaultValue":"false","description":"Marks the row as the current page. Default: false"},{"name":"disabled","type":"boolean","required":false,"defaultValue":"false","description":"Dims the row and blocks selection. Default: false"},{"name":"closeOnSelect","type":"boolean","required":false,"defaultValue":"true","description":"Closes the mobile sidebar after selecting. Default: true"},{"name":"target","type":"\"_self\" | \"_blank\" | \"_parent\" | \"_top\"","required":false,"defaultValue":null,"description":"Link target, used with `href`."},{"name":"rel","type":"string","required":false,"defaultValue":null,"description":"Link rel, used with `href`. Defaults to \"noreferrer noopener\" for \"_blank\"."},{"name":"onSelect","type":"(() => void)","required":false,"defaultValue":null,"description":"Called when the row is clicked and not disabled."},{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the button or link."}]},{"displayName":"AnimatedSidebarMenuButton","props":[{"name":"icon","type":"ReactNode","required":false,"defaultValue":null,"description":"Icon shown before the label; stays visible in the collapsed rail."},{"name":"badge","type":"ReactNode","required":false,"defaultValue":null,"description":"Trailing content such as a count, hidden while collapsed."},{"name":"href","type":"string","required":false,"defaultValue":null,"description":"Renders a link to this URL instead of a button."},{"name":"isActive","type":"boolean","required":false,"defaultValue":"false","description":"Marks the current page and moves the shared highlight here. Default: false"},{"name":"ariaExpanded","type":"boolean","required":false,"defaultValue":null,"description":"Expanded state of a submenu this button toggles; also shows a chevron."},{"name":"disabled","type":"boolean","required":false,"defaultValue":"false","description":"Disables the item. Default: false"},{"name":"closeOnSelect","type":"boolean","required":false,"defaultValue":null,"description":"Close the mobile drawer on select. Defaults to true unless `ariaExpanded` is set."},{"name":"target","type":"\"_self\" | \"_blank\" | \"_parent\" | \"_top\"","required":false,"defaultValue":null,"description":"Link target, used with `href`."},{"name":"rel","type":"string","required":false,"defaultValue":null,"description":"Link rel, used with `href`. Defaults to \"noreferrer noopener\" for `_blank`."},{"name":"onSelect","type":"(() => void)","required":false,"defaultValue":null,"description":"Called when the item is clicked."},{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the button or link element."}]},{"displayName":"AnimatedSidebar","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."},{"name":"side","type":"\"left\" | \"right\"","required":false,"defaultValue":"left","description":"Which edge of the layout the sidebar sits on. Default: \"left\""},{"name":"variant","type":"\"inset\" | \"sidebar\" | \"floating\"","required":false,"defaultValue":"sidebar","description":"Panel style: bordered edge, floating card, or inset card. Default: \"sidebar\""},{"name":"collapsible","type":"\"none\" | \"icon\" | \"offcanvas\"","required":false,"defaultValue":"icon","description":"How it collapses: to an icon rail, fully off canvas, or never. Default: \"icon\""},{"name":"ariaLabel","type":"string","required":false,"defaultValue":null,"description":"Accessible name for the sidebar landmark. Default: \"Sidebar\""},{"name":"panelClassName","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the inner panel that holds the content."}]},{"displayName":"AnimatedSidebarTrigger","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarClose","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarRail","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarInset","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarHeader","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarContent","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarFooter","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarGroup","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarGroupLabel","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarGroupContent","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarMenu","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarMenuItem","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]},{"displayName":"AnimatedSidebarMenuSub","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."},{"name":"open","type":"boolean","required":true,"defaultValue":null,"description":"Shows the submenu. It stays hidden while the sidebar is collapsed."}]},{"displayName":"AnimatedSidebarMenuSubItem","props":[{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]}],"types":[],"files":[{"path":"components/motion/animated-sidebar.tsx","type":"component","content":"\"use client\";\n// beui.dev/components/motion/animated-sidebar\n\nimport {\n  AnimatePresence,\n  type HTMLMotionProps,\n  motion,\n  useReducedMotion,\n} from \"motion/react\";\nimport {\n  type ButtonHTMLAttributes,\n  type CSSProperties,\n  forwardRef,\n  type HTMLAttributes,\n  type ReactNode,\n  useCallback,\n  useEffect,\n  useId,\n  useRef,\n  useState,\n} from \"react\";\nimport { SharedLayoutBg } from \"@/components/motion/shared-layout-bg\";\nimport { SPRING_LAYOUT } from \"@/lib/ease\";\nimport { useMessages } from \"@/lib/i18n\";\nimport { cn } from \"@/lib/utils\";\nimport {\n  AnimatedSidebarContext,\n  AnimatedSidebarPanelContext,\n  type AnimatedSidebarMessages,\n  animatedSidebarMessages,\n  type SidebarCollapsible,\n  type SidebarSide,\n  type SidebarVariant,\n  useAnimatedSidebar,\n  useAnimatedSidebarPanel,\n} from \"./animated-sidebar/context\";\nimport { MobileSidebar } from \"./animated-sidebar/mobile-sidebar\";\nimport {\n  PANEL_TRANSITION,\n  REDUCED_TRANSITION,\n  SIDEBAR_MORPH_TRANSITION,\n  SUBMENU_ITEM_VARIANTS,\n  SUBMENU_VARIANTS,\n} from \"./animated-sidebar/motion\";\nimport { useIsMobile } from \"./animated-sidebar/use-is-mobile\";\n\nexport {\n  AnimatedSidebarMenuSubButton,\n  type AnimatedSidebarMenuSubButtonProps,\n} from \"./animated-sidebar/menu-sub-button\";\nexport {\n  AnimatedSidebarMenuButton,\n  type AnimatedSidebarMenuButtonProps,\n} from \"./animated-sidebar/menu-button\";\nexport {\n  type AnimatedSidebarMessages,\n  animatedSidebarMessages,\n  useAnimatedSidebar,\n} from \"./animated-sidebar/context\";\n\nconst SIDEBAR_KEYBOARD_SHORTCUT = \"b\";\n\ntype SidebarProviderStyle = CSSProperties & {\n  \"--sidebar-width\"?: string;\n  \"--sidebar-width-icon\"?: string;\n  \"--sidebar-width-mobile\"?: string;\n};\n\nexport interface AnimatedSidebarProviderProps\n  extends HTMLAttributes<HTMLDivElement> {\n  /** Whether the desktop sidebar is expanded, for controlled use. */\n  open?: boolean;\n  /** Whether the desktop sidebar starts expanded when uncontrolled. Default: true */\n  defaultOpen?: boolean;\n  /** Called with the next state when the desktop sidebar expands or collapses. */\n  onOpenChange?: (open: boolean) => void;\n  /** Whether the mobile drawer is open, for controlled use. */\n  openMobile?: boolean;\n  /** Whether the mobile drawer starts open when uncontrolled. Default: false */\n  defaultOpenMobile?: boolean;\n  /** Called with the next state when the mobile drawer opens or closes. */\n  onOpenMobileChange?: (open: boolean) => void;\n  /** Inline styles; set `--sidebar-width`, `--sidebar-width-icon` or `--sidebar-width-mobile` here. */\n  style?: SidebarProviderStyle;\n  /** Override any built-in string. */\n  labels?: Partial<AnimatedSidebarMessages>;\n}\n\nexport function AnimatedSidebarProvider({\n  children,\n  open,\n  defaultOpen = true,\n  onOpenChange,\n  openMobile,\n  defaultOpenMobile = false,\n  onOpenMobileChange,\n  className,\n  style,\n  labels,\n  ...props\n}: AnimatedSidebarProviderProps) {\n  const t = useMessages(\"animatedSidebar\", animatedSidebarMessages, labels);\n  const [internalOpen, setInternalOpen] = useState(defaultOpen);\n  const [internalOpenMobile, setInternalOpenMobile] =\n    useState(defaultOpenMobile);\n  const isMobile = useIsMobile();\n  const reduce = useReducedMotion() ?? false;\n  const generatedId = useId();\n  const triggerRef = useRef<HTMLButtonElement>(null);\n  const desktopOpen = open ?? internalOpen;\n  const mobileOpen = openMobile ?? internalOpenMobile;\n\n  const setOpen = useCallback(\n    (nextOpen: boolean) => {\n      if (open === undefined) setInternalOpen(nextOpen);\n      onOpenChange?.(nextOpen);\n    },\n    [onOpenChange, open],\n  );\n\n  const setOpenMobile = useCallback(\n    (nextOpen: boolean) => {\n      if (openMobile === undefined) setInternalOpenMobile(nextOpen);\n      onOpenMobileChange?.(nextOpen);\n    },\n    [onOpenMobileChange, openMobile],\n  );\n\n  const toggleSidebar = useCallback(() => {\n    if (isMobile) setOpenMobile(!mobileOpen);\n    else setOpen(!desktopOpen);\n  }, [desktopOpen, isMobile, mobileOpen, setOpen, setOpenMobile]);\n\n  useEffect(() => {\n    const handleShortcut = (event: KeyboardEvent) => {\n      if (\n        event.key.toLowerCase() === SIDEBAR_KEYBOARD_SHORTCUT &&\n        (event.metaKey || event.ctrlKey)\n      ) {\n        event.preventDefault();\n        toggleSidebar();\n      }\n    };\n\n    window.addEventListener(\"keydown\", handleShortcut);\n    return () => window.removeEventListener(\"keydown\", handleShortcut);\n  }, [toggleSidebar]);\n\n  return (\n    <AnimatedSidebarContext.Provider\n      value={{\n        isMobile,\n        layoutId: `${generatedId}-active`,\n        open: desktopOpen,\n        openMobile: mobileOpen,\n        reduce,\n        setOpen,\n        setOpenMobile,\n        state: desktopOpen ? \"expanded\" : \"collapsed\",\n        toggleSidebar,\n        triggerRef,\n        t,\n      }}\n    >\n      <div\n        {...props}\n        data-slot=\"sidebar-wrapper\"\n        data-state={desktopOpen ? \"expanded\" : \"collapsed\"}\n        style={{\n          \"--sidebar-width\": \"16rem\",\n          \"--sidebar-width-icon\": \"4.25rem\",\n          \"--sidebar-width-mobile\": \"18rem\",\n          ...style,\n        }}\n        className={cn(\n          \"group/sidebar-wrapper flex min-h-svh w-full min-w-0\",\n          className,\n        )}\n      >\n        {children}\n      </div>\n    </AnimatedSidebarContext.Provider>\n  );\n}\n\nexport interface AnimatedSidebarProps\n  extends Omit<HTMLMotionProps<\"aside\">, \"children\"> {\n  children?: ReactNode;\n  /** Which edge of the layout the sidebar sits on. Default: \"left\" */\n  side?: SidebarSide;\n  /** Panel style: bordered edge, floating card, or inset card. Default: \"sidebar\" */\n  variant?: SidebarVariant;\n  /** How it collapses: to an icon rail, fully off canvas, or never. Default: \"icon\" */\n  collapsible?: SidebarCollapsible;\n  /** Accessible name for the sidebar landmark. Default: \"Sidebar\" */\n  ariaLabel?: string;\n  /** Classes merged onto the inner panel that holds the content. */\n  panelClassName?: string;\n}\n\nexport const AnimatedSidebar = forwardRef<HTMLElement, AnimatedSidebarProps>(\n  function AnimatedSidebar(\n    {\n      side = \"left\",\n      variant = \"sidebar\",\n      collapsible = \"icon\",\n      ariaLabel: ariaLabelProp,\n      children,\n      className,\n      panelClassName,\n      style,\n      ...props\n    },\n    forwardedRef,\n  ) {\n    const context = useAnimatedSidebar();\n    const ariaLabel = ariaLabelProp ?? context.t(\"label\");\n    const collapsed = collapsible !== \"none\" && !context.open;\n    const offcanvas = collapsed && collapsible === \"offcanvas\";\n    const width = offcanvas\n      ? \"0px\"\n      : collapsed\n        ? \"var(--sidebar-width-icon)\"\n        : \"var(--sidebar-width)\";\n\n    if (context.isMobile) {\n      return (\n        <MobileSidebar\n          ariaLabel={ariaLabel}\n          className={className}\n          side={side}\n        >\n          {children}\n        </MobileSidebar>\n      );\n    }\n\n    return (\n      <motion.aside\n        {...props}\n        ref={forwardedRef}\n        initial={false}\n        aria-label={ariaLabel}\n        data-slot=\"sidebar\"\n        data-state={collapsed ? \"collapsed\" : \"expanded\"}\n        data-collapsible={collapsible}\n        data-variant={variant}\n        data-side={side}\n        animate={{ width }}\n        transition={\n          context.reduce ? { duration: 0 } : SIDEBAR_MORPH_TRANSITION\n        }\n        style={style}\n        className={cn(\n          \"group/sidebar relative hidden h-auto shrink-0 md:block will-change-[width]\",\n          \"peer\",\n          side === \"right\" && \"order-last\",\n          className,\n        )}\n      >\n        <motion.div\n          initial={false}\n          animate={{\n            opacity: offcanvas ? 0 : 1,\n            x: offcanvas ? (side === \"left\" ? \"-100%\" : \"100%\") : \"0%\",\n          }}\n          transition={\n            context.reduce ? REDUCED_TRANSITION : PANEL_TRANSITION\n          }\n          className={cn(\n            \"sticky top-0 flex h-svh w-full flex-col overflow-hidden bg-background\",\n            collapsible === \"offcanvas\" && \"w-[var(--sidebar-width)]\",\n            variant === \"sidebar\" &&\n              (side === \"left\" ? \"border-border border-r\" : \"border-border border-l\"),\n            variant === \"floating\" &&\n              \"m-2 h-[calc(100svh-1rem)] rounded-2xl border border-border shadow-sm\",\n            variant === \"inset\" && \"m-2 h-[calc(100svh-1rem)] rounded-2xl\",\n            panelClassName,\n          )}\n        >\n          <AnimatedSidebarPanelContext.Provider\n            value={{ collapsed, collapsible, side }}\n          >\n            {children}\n          </AnimatedSidebarPanelContext.Provider>\n        </motion.div>\n      </motion.aside>\n    );\n  },\n);\n\nexport interface AnimatedSidebarTriggerProps\n  extends ButtonHTMLAttributes<HTMLButtonElement> {}\n\nexport const AnimatedSidebarTrigger = forwardRef<\n  HTMLButtonElement,\n  AnimatedSidebarTriggerProps\n>(function AnimatedSidebarTrigger(\n  { className, onClick, type = \"button\", ...props },\n  forwardedRef,\n) {\n  const context = useAnimatedSidebar();\n  const expanded = context.isMobile ? context.openMobile : context.open;\n\n  return (\n    <button\n      {...props}\n      ref={(node) => {\n        context.triggerRef.current = node;\n        if (typeof forwardedRef === \"function\") forwardedRef(node);\n        else if (forwardedRef) forwardedRef.current = node;\n      }}\n      type={type}\n      aria-label={props[\"aria-label\"] ?? context.t(\"toggle\")}\n      aria-expanded={expanded}\n      data-slot=\"sidebar-trigger\"\n      data-state={expanded ? \"expanded\" : \"collapsed\"}\n      onClick={(event) => {\n        onClick?.(event);\n        if (!event.defaultPrevented) context.toggleSidebar();\n      }}\n      className={cn(\n        \"inline-flex size-10 shrink-0 items-center justify-center rounded-full outline-none\",\n        \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n        className,\n      )}\n    />\n  );\n});\n\nexport interface AnimatedSidebarCloseProps\n  extends ButtonHTMLAttributes<HTMLButtonElement> {}\n\nexport const AnimatedSidebarClose = forwardRef<\n  HTMLButtonElement,\n  AnimatedSidebarCloseProps\n>(function AnimatedSidebarClose(\n  { className, onClick, type = \"button\", ...props },\n  forwardedRef,\n) {\n  const context = useAnimatedSidebar();\n\n  return (\n    <button\n      {...props}\n      ref={forwardedRef}\n      type={type}\n      aria-label={props[\"aria-label\"] ?? context.t(\"close\")}\n      onClick={(event) => {\n        onClick?.(event);\n        if (event.defaultPrevented) return;\n        if (context.isMobile) context.setOpenMobile(false);\n        else context.setOpen(false);\n      }}\n      className={cn(\n        \"inline-flex size-10 shrink-0 items-center justify-center rounded-full outline-none\",\n        \"focus-visible:ring-2 focus-visible:ring-ring\",\n        className,\n      )}\n    />\n  );\n});\n\nexport interface AnimatedSidebarRailProps\n  extends ButtonHTMLAttributes<HTMLButtonElement> {}\n\nexport const AnimatedSidebarRail = forwardRef<\n  HTMLButtonElement,\n  AnimatedSidebarRailProps\n>(function AnimatedSidebarRail(\n  { className, onClick, type = \"button\", ...props },\n  forwardedRef,\n) {\n  const context = useAnimatedSidebar();\n  const panel = useAnimatedSidebarPanel();\n\n  return (\n    <button\n      {...props}\n      ref={forwardedRef}\n      type={type}\n      data-side={panel.side}\n      aria-label={props[\"aria-label\"] ?? context.t(\"toggle\")}\n      title={context.t(\"toggle\")}\n      tabIndex={-1}\n      onClick={(event) => {\n        onClick?.(event);\n        if (!event.defaultPrevented) context.toggleSidebar();\n      }}\n      className={cn(\n        \"absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 outline-none md:block\",\n        \"after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-transparent after:transition-colors hover:after:bg-border\",\n        \"data-[side=right]:right-0 data-[side=right]:translate-x-1/2 data-[side=left]:left-full\",\n        className,\n      )}\n    />\n  );\n});\n\nexport interface AnimatedSidebarInsetProps\n  extends HTMLMotionProps<\"main\"> {}\n\nexport const AnimatedSidebarInset = forwardRef<\n  HTMLElement,\n  AnimatedSidebarInsetProps\n>(function AnimatedSidebarInset({ className, ...props }, forwardedRef) {\n  return (\n    <motion.main\n      {...props}\n      ref={forwardedRef}\n      data-slot=\"sidebar-inset\"\n      className={cn(\n        \"relative flex min-h-svh min-w-0 flex-1 flex-col bg-background\",\n        \"md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-2xl md:peer-data-[variant=inset]:shadow-sm\",\n        className,\n      )}\n    />\n  );\n});\n\nexport const AnimatedSidebarHeader = forwardRef<\n  HTMLDivElement,\n  HTMLAttributes<HTMLDivElement>\n>(function AnimatedSidebarHeader({ className, ...props }, forwardedRef) {\n  return (\n    <div\n      {...props}\n      ref={forwardedRef}\n      data-slot=\"sidebar-header\"\n      className={cn(\"flex shrink-0 flex-col gap-2 p-3\", className)}\n    />\n  );\n});\n\nexport const AnimatedSidebarContent = forwardRef<\n  HTMLDivElement,\n  HTMLAttributes<HTMLDivElement>\n>(function AnimatedSidebarContent({ className, ...props }, forwardedRef) {\n  return (\n    <div\n      {...props}\n      ref={forwardedRef}\n      data-slot=\"sidebar-content\"\n      className={cn(\n        \"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden overscroll-contain px-2 py-2\",\n        className,\n      )}\n    />\n  );\n});\n\nexport const AnimatedSidebarFooter = forwardRef<\n  HTMLDivElement,\n  HTMLAttributes<HTMLDivElement>\n>(function AnimatedSidebarFooter({ className, ...props }, forwardedRef) {\n  return (\n    <div\n      {...props}\n      ref={forwardedRef}\n      data-slot=\"sidebar-footer\"\n      className={cn(\n        \"flex shrink-0 flex-col gap-2 border-border border-t p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]\",\n        className,\n      )}\n    />\n  );\n});\n\nexport const AnimatedSidebarGroup = forwardRef<\n  HTMLDivElement,\n  HTMLAttributes<HTMLDivElement>\n>(function AnimatedSidebarGroup({ className, ...props }, forwardedRef) {\n  return (\n    <div\n      {...props}\n      ref={forwardedRef}\n      data-slot=\"sidebar-group\"\n      className={cn(\"flex w-full min-w-0 flex-col px-1 py-1.5\", className)}\n    />\n  );\n});\n\nexport const AnimatedSidebarGroupLabel = forwardRef<\n  HTMLDivElement,\n  HTMLAttributes<HTMLDivElement>\n>(function AnimatedSidebarGroupLabel(\n  { children, className, ...props },\n  forwardedRef,\n) {\n  const { collapsed } = useAnimatedSidebarPanel();\n\n  return (\n    <div\n      {...props}\n      ref={forwardedRef}\n      aria-hidden={collapsed}\n      data-slot=\"sidebar-group-label\"\n      className={cn(\n        \"mb-1 h-7 overflow-hidden px-2 text-[11px] font-medium uppercase tracking-[0.14em] text-muted-foreground transition-opacity\",\n        collapsed ? \"opacity-0\" : \"opacity-100\",\n        className,\n      )}\n    >\n      {children}\n    </div>\n  );\n});\n\nexport const AnimatedSidebarGroupContent = forwardRef<\n  HTMLDivElement,\n  HTMLAttributes<HTMLDivElement>\n>(function AnimatedSidebarGroupContent(\n  { className, ...props },\n  forwardedRef,\n) {\n  return (\n    <div\n      {...props}\n      ref={forwardedRef}\n      data-slot=\"sidebar-group-content\"\n      className={cn(\"w-full min-w-0\", className)}\n    />\n  );\n});\n\nexport const AnimatedSidebarMenu = forwardRef<\n  HTMLUListElement,\n  HTMLAttributes<HTMLUListElement>\n>(function AnimatedSidebarMenu(\n  { children, className, ...props },\n  forwardedRef,\n) {\n  return (\n    <SharedLayoutBg\n      {...props}\n      ref={forwardedRef as React.Ref<HTMLElement>}\n      as=\"ul\"\n      inset={0}\n      pillClassName=\"rounded-full bg-muted/70\"\n      pillContainerClassName=\"inset-y-auto top-0 h-9\"\n      data-slot=\"sidebar-menu\"\n      className={cn(\"flex w-full min-w-0 list-none flex-col gap-0.5\", className)}\n    >\n      {children}\n    </SharedLayoutBg>\n  );\n});\n\nexport const AnimatedSidebarMenuItem = forwardRef<\n  HTMLLIElement,\n  HTMLMotionProps<\"li\">\n>(function AnimatedSidebarMenuItem({ className, ...props }, forwardedRef) {\n  return (\n    <motion.li\n      {...props}\n      ref={forwardedRef}\n      layout=\"position\"\n      transition={SPRING_LAYOUT}\n      data-slot=\"sidebar-menu-item\"\n      className={cn(\"relative\", className)}\n    />\n  );\n});\n\nexport interface AnimatedSidebarMenuSubProps\n  extends Omit<HTMLMotionProps<\"ul\">, \"children\"> {\n  /** Shows the submenu. It stays hidden while the sidebar is collapsed. */\n  open: boolean;\n  children?: ReactNode;\n}\n\nexport const AnimatedSidebarMenuSub = forwardRef<\n  HTMLUListElement,\n  AnimatedSidebarMenuSubProps\n>(function AnimatedSidebarMenuSub(\n  { open, children, className, ...props },\n  forwardedRef,\n) {\n  const context = useAnimatedSidebar();\n  const panel = useAnimatedSidebarPanel();\n\n  return (\n    <AnimatePresence initial={false} mode=\"popLayout\">\n      {open && !panel.collapsed ? (\n        <motion.ul\n          {...props}\n          ref={forwardedRef}\n          key=\"sidebar-submenu\"\n          variants={context.reduce ? undefined : SUBMENU_VARIANTS}\n          initial={context.reduce ? false : \"closed\"}\n          animate={context.reduce ? { opacity: 1 } : \"open\"}\n          exit={context.reduce ? { opacity: 0 } : \"closed\"}\n          transition={context.reduce ? { duration: 0.12 } : undefined}\n          data-slot=\"sidebar-menu-sub\"\n          className={cn(\n            \"relative mt-1 ml-5 flex min-w-0 flex-col gap-0.5 border-border border-l pl-3\",\n            className,\n          )}\n        >\n          {children}\n        </motion.ul>\n      ) : null}\n    </AnimatePresence>\n  );\n});\n\nexport const AnimatedSidebarMenuSubItem = forwardRef<\n  HTMLLIElement,\n  HTMLMotionProps<\"li\">\n>(function AnimatedSidebarMenuSubItem(\n  { className, ...props },\n  forwardedRef,\n) {\n  return (\n    <motion.li\n      {...props}\n      ref={forwardedRef}\n      variants={SUBMENU_ITEM_VARIANTS}\n      data-slot=\"sidebar-menu-sub-item\"\n      className={cn(\"relative min-w-0\", className)}\n    />\n  );\n});\n"},{"path":"components/motion/animated-sidebar/context.ts","type":"util","content":"\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport type { useMessages } from \"@/lib/i18n\";\n\nexport type SidebarState = \"expanded\" | \"collapsed\";\nexport type SidebarSide = \"left\" | \"right\";\nexport type SidebarVariant = \"sidebar\" | \"floating\" | \"inset\";\nexport type SidebarCollapsible = \"offcanvas\" | \"icon\" | \"none\";\n\n/** English defaults. Override per instance with `labels`, or app-wide with `LocaleProvider`. */\nexport const animatedSidebarMessages = {\n  label: \"Sidebar\",\n  toggle: \"Toggle sidebar\",\n  close: \"Close sidebar\",\n};\n\nexport type AnimatedSidebarMessages = typeof animatedSidebarMessages;\n\ninterface AnimatedSidebarContextValue {\n  isMobile: boolean;\n  layoutId: string;\n  open: boolean;\n  openMobile: boolean;\n  reduce: boolean;\n  setOpen: (open: boolean) => void;\n  setOpenMobile: (open: boolean) => void;\n  state: SidebarState;\n  toggleSidebar: () => void;\n  triggerRef: React.RefObject<HTMLButtonElement | null>;\n  t: ReturnType<typeof useMessages<AnimatedSidebarMessages>>;\n}\n\nexport const AnimatedSidebarContext =\n  createContext<AnimatedSidebarContextValue | null>(null);\n\ninterface AnimatedSidebarPanelContextValue {\n  collapsed: boolean;\n  collapsible: SidebarCollapsible;\n  side: SidebarSide;\n}\n\nexport const AnimatedSidebarPanelContext =\n  createContext<AnimatedSidebarPanelContextValue | null>(null);\n\nexport function useAnimatedSidebar() {\n  const context = useContext(AnimatedSidebarContext);\n  if (!context) {\n    throw new Error(\n      \"useAnimatedSidebar must be used inside AnimatedSidebarProvider.\",\n    );\n  }\n  return context;\n}\n\nexport function useAnimatedSidebarPanel() {\n  const context = useContext(AnimatedSidebarPanelContext);\n  if (!context) {\n    throw new Error(\n      \"Animated Sidebar parts must be used inside AnimatedSidebar.\",\n    );\n  }\n  return context;\n}\n"},{"path":"components/motion/animated-sidebar/menu-button.tsx","type":"util","content":"\"use client\";\n\nimport { ChevronRight } from \"lucide-react\";\nimport { motion } from \"motion/react\";\nimport type { ReactNode } from \"react\";\nimport { SPRING_LAYOUT, SPRING_PRESS } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\nimport { useAnimatedSidebar, useAnimatedSidebarPanel } from \"./context\";\nimport {\n  LABEL_ENTER_TRANSITION,\n  LABEL_EXIT_TRANSITION,\n  REDUCED_TRANSITION,\n} from \"./motion\";\n\nexport interface AnimatedSidebarMenuButtonProps {\n  children: ReactNode;\n  /** Icon shown before the label; stays visible in the collapsed rail. */\n  icon?: ReactNode;\n  /** Trailing content such as a count, hidden while collapsed. */\n  badge?: ReactNode;\n  /** Renders a link to this URL instead of a button. */\n  href?: string;\n  /** Marks the current page and moves the shared highlight here. Default: false */\n  isActive?: boolean;\n  /** Expanded state of a submenu this button toggles; also shows a chevron. */\n  ariaExpanded?: boolean;\n  /** Disables the item. Default: false */\n  disabled?: boolean;\n  /** Close the mobile drawer on select. Defaults to true unless `ariaExpanded` is set. */\n  closeOnSelect?: boolean;\n  /** Link target, used with `href`. */\n  target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\";\n  /** Link rel, used with `href`. Defaults to \"noreferrer noopener\" for `_blank`. */\n  rel?: string;\n  /** Called when the item is clicked. */\n  onSelect?: () => void;\n  /** Classes merged onto the button or link element. */\n  className?: string;\n}\n\nexport function AnimatedSidebarMenuButton({\n  children,\n  icon,\n  badge,\n  href,\n  isActive = false,\n  ariaExpanded,\n  disabled = false,\n  closeOnSelect,\n  target,\n  rel,\n  onSelect,\n  className,\n}: AnimatedSidebarMenuButtonProps) {\n  const context = useAnimatedSidebar();\n  const panel = useAnimatedSidebarPanel();\n  const textLabel = typeof children === \"string\" ? children : undefined;\n\n  const select = (\n    event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>,\n  ) => {\n    if (disabled) {\n      event.preventDefault();\n      return;\n    }\n    onSelect?.();\n    const shouldCloseOnSelect =\n      closeOnSelect ?? ariaExpanded === undefined;\n    if (context.isMobile && shouldCloseOnSelect) {\n      context.setOpenMobile(false);\n    }\n    // A submenu cannot render in the icon rail, so opening one from there\n    // leaves its children unreachable - a pointer can still fall back to the\n    // rail or the shortcut, a finger has nothing. Selecting a group unfolds\n    // the panel that is about to hold it.\n    if (ariaExpanded !== undefined && panel.collapsed && !context.isMobile) {\n      context.setOpen(true);\n    }\n  };\n\n  const content = (\n    <>\n      {isActive ? (\n        <motion.span\n          layoutId={context.layoutId}\n          transition={context.reduce ? { duration: 0 } : SPRING_LAYOUT}\n          className=\"absolute inset-0 rounded-full bg-muted\"\n        />\n      ) : null}\n      {icon ? (\n        <span\n          aria-hidden=\"true\"\n          className=\"relative z-10 grid size-5 shrink-0 place-items-center\"\n        >\n          {icon}\n        </span>\n      ) : null}\n      <motion.span\n        initial={false}\n        animate={{\n          opacity: panel.collapsed ? 0 : 1,\n          x: panel.collapsed ? -4 : 0,\n        }}\n        transition={\n          context.reduce\n            ? REDUCED_TRANSITION\n            : panel.collapsed\n              ? LABEL_EXIT_TRANSITION\n              : LABEL_ENTER_TRANSITION\n        }\n        aria-hidden={panel.collapsed}\n        className={cn(\n          \"relative z-10 min-w-0 flex-1 truncate\",\n          panel.collapsed && \"pointer-events-none\",\n        )}\n      >\n        {children}\n      </motion.span>\n      {badge && !panel.collapsed ? (\n        <span className=\"relative z-10 shrink-0 text-xs text-muted-foreground\">\n          {badge}\n        </span>\n      ) : null}\n      {ariaExpanded !== undefined ? (\n        <motion.span\n          aria-hidden=\"true\"\n          initial={false}\n          animate={{\n            opacity: panel.collapsed ? 0 : 1,\n            rotate: ariaExpanded ? 90 : 0,\n            x: panel.collapsed ? 4 : 0,\n          }}\n          transition={context.reduce ? { duration: 0 } : SPRING_LAYOUT}\n          className=\"relative z-10 grid size-4 shrink-0 place-items-center text-muted-foreground\"\n        >\n          <ChevronRight className=\"size-3.5\" />\n        </motion.span>\n      ) : null}\n    </>\n  );\n\n  const interactiveClassName = cn(\n    \"relative flex min-h-9 w-full min-w-0 items-center gap-2.5 overflow-hidden rounded-full px-3 text-left text-sm font-medium outline-none\",\n    \"text-muted-foreground transition-colors hover:text-foreground\",\n    \"focus-visible:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring\",\n    isActive && \"text-foreground\",\n    disabled && \"cursor-not-allowed opacity-40\",\n    className,\n  );\n\n  return href ? (\n    <motion.a\n      href={href}\n      target={target}\n      rel={\n        rel ??\n        (target === \"_blank\" ? \"noreferrer noopener\" : undefined)\n      }\n      aria-current={isActive ? \"page\" : undefined}\n      aria-expanded={ariaExpanded}\n      aria-disabled={disabled || undefined}\n      aria-label={panel.collapsed ? textLabel : undefined}\n      title={panel.collapsed ? textLabel : undefined}\n      tabIndex={disabled ? -1 : undefined}\n      onClick={select}\n      whileTap={context.reduce || disabled ? undefined : { scale: 0.98 }}\n      transition={SPRING_PRESS}\n      className={interactiveClassName}\n    >\n      {content}\n    </motion.a>\n  ) : (\n    <motion.button\n      type=\"button\"\n      disabled={disabled}\n      aria-current={isActive ? \"page\" : undefined}\n      aria-expanded={ariaExpanded}\n      aria-label={panel.collapsed ? textLabel : undefined}\n      title={panel.collapsed ? textLabel : undefined}\n      onClick={select}\n      whileTap={context.reduce || disabled ? undefined : { scale: 0.98 }}\n      transition={SPRING_PRESS}\n      className={interactiveClassName}\n    >\n      {content}\n    </motion.button>\n  );\n}\n"},{"path":"components/motion/animated-sidebar/menu-sub-button.tsx","type":"util","content":"\"use client\";\n\nimport { motion } from \"motion/react\";\nimport type { ReactNode } from \"react\";\nimport { SPRING_PRESS } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\nimport { useAnimatedSidebar } from \"./context\";\n\nexport interface AnimatedSidebarMenuSubButtonProps {\n  children: ReactNode;\n  /** Leading icon. Defaults to a small dot. */\n  icon?: ReactNode;\n  /** Renders a link to this URL instead of a button. */\n  href?: string;\n  /** Marks the row as the current page. Default: false */\n  isActive?: boolean;\n  /** Dims the row and blocks selection. Default: false */\n  disabled?: boolean;\n  /** Closes the mobile sidebar after selecting. Default: true */\n  closeOnSelect?: boolean;\n  /** Link target, used with `href`. */\n  target?: \"_blank\" | \"_self\" | \"_parent\" | \"_top\";\n  /** Link rel, used with `href`. Defaults to \"noreferrer noopener\" for \"_blank\". */\n  rel?: string;\n  /** Called when the row is clicked and not disabled. */\n  onSelect?: () => void;\n  /** Classes merged onto the button or link. */\n  className?: string;\n}\n\nexport function AnimatedSidebarMenuSubButton({\n  children,\n  icon,\n  href,\n  isActive = false,\n  disabled = false,\n  closeOnSelect = true,\n  target,\n  rel,\n  onSelect,\n  className,\n}: AnimatedSidebarMenuSubButtonProps) {\n  const context = useAnimatedSidebar();\n\n  const select = (\n    event: React.MouseEvent<HTMLAnchorElement | HTMLButtonElement>,\n  ) => {\n    if (disabled) {\n      event.preventDefault();\n      return;\n    }\n    onSelect?.();\n    if (context.isMobile && closeOnSelect) context.setOpenMobile(false);\n  };\n\n  const content = (\n    <>\n      <span\n        aria-hidden=\"true\"\n        className=\"grid size-4 shrink-0 place-items-center\"\n      >\n        {icon ?? <span className=\"size-1 rounded-full bg-current\" />}\n      </span>\n      <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n    </>\n  );\n\n  const interactiveClassName = cn(\n    \"flex min-h-8 w-full min-w-0 items-center gap-2 rounded-full px-3 text-left text-xs outline-none\",\n    \"text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground\",\n    \"focus-visible:bg-muted/70 focus-visible:ring-2 focus-visible:ring-ring\",\n    isActive && \"bg-muted/70 text-foreground\",\n    disabled && \"cursor-not-allowed opacity-40\",\n    className,\n  );\n\n  return href ? (\n    <motion.a\n      href={href}\n      target={target}\n      rel={\n        rel ??\n        (target === \"_blank\" ? \"noreferrer noopener\" : undefined)\n      }\n      aria-current={isActive ? \"page\" : undefined}\n      aria-disabled={disabled || undefined}\n      tabIndex={disabled ? -1 : undefined}\n      onClick={select}\n      whileTap={context.reduce || disabled ? undefined : { scale: 0.98 }}\n      transition={SPRING_PRESS}\n      className={interactiveClassName}\n    >\n      {content}\n    </motion.a>\n  ) : (\n    <motion.button\n      type=\"button\"\n      disabled={disabled}\n      aria-current={isActive ? \"page\" : undefined}\n      onClick={select}\n      whileTap={context.reduce || disabled ? undefined : { scale: 0.98 }}\n      transition={SPRING_PRESS}\n      className={interactiveClassName}\n    >\n      {content}\n    </motion.button>\n  );\n}\n"},{"path":"components/motion/animated-sidebar/mobile-sidebar.tsx","type":"util","content":"\"use client\";\n\nimport { motion } from \"motion/react\";\nimport {\n  type ReactNode,\n  useCallback,\n  useEffect,\n  useRef,\n  useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { useFocusTrap } from \"@/lib/hooks/use-focus-trap\";\nimport { useScrollLock } from \"@/lib/scroll-lock\";\nimport { cn } from \"@/lib/utils\";\nimport {\n  AnimatedSidebarPanelContext,\n  type SidebarSide,\n  useAnimatedSidebar,\n} from \"./context\";\nimport { PANEL_TRANSITION, REDUCED_TRANSITION } from \"./motion\";\n\nexport function MobileSidebar({\n  ariaLabel,\n  children,\n  className,\n  side,\n}: {\n  ariaLabel: string;\n  children: ReactNode;\n  className?: string;\n  side: SidebarSide;\n}) {\n  const context = useAnimatedSidebar();\n  const panelRef = useRef<HTMLDivElement>(null);\n  const [mounted, setMounted] = useState(false);\n  // The sheet is mounted for as long as the viewport is mobile, so it hides\n  // itself while closed rather than sitting there transparent and interactive.\n  // Opening shows it in the same commit that starts the slide - a delayed show\n  // would run the focus effect below against a still-hidden panel, and focus()\n  // on a hidden element is ignored. Closing waits for the slide to finish, and\n  // the panel's own exit tells us when that is: no duration to keep in sync.\n  const [hidden, setHidden] = useState(!context.openMobile);\n  // The completion callback fires for the open slide too, and it reads state\n  // from whenever motion settles: a ref keeps it on the current one.\n  const openMobileRef = useRef(context.openMobile);\n\n  useEffect(() => setMounted(true), []);\n\n  useEffect(() => {\n    openMobileRef.current = context.openMobile;\n    if (context.openMobile) setHidden(false);\n  }, [context.openMobile]);\n\n  // A modal sheet: focus moves in, Tab stays inside, Escape closes, and focus\n  // returns to the opener. The fixed body lock holds on iOS Safari too.\n  const { openMobile, setOpenMobile } = context;\n  const closeMobile = useCallback(() => setOpenMobile(false), [setOpenMobile]);\n  useFocusTrap(openMobile && mounted, panelRef, { onEscape: closeMobile });\n  useScrollLock(openMobile, { fixed: true });\n\n  if (!mounted) return null;\n\n  // This container groups the sheet for hiding and the z-index and carries no\n  // box: both children are `fixed` and resolve against the viewport themselves.\n  // The scrim spans the viewport edges but paints a colour, and the panel is\n  // inset off one side and paints its own surface, so no layer here is a\n  // transparent edge-spanning one.\n  return createPortal(\n    <div\n      className={cn(\n        \"pointer-events-none fixed left-0 top-0 z-50 size-0 md:hidden\",\n        hidden && !context.openMobile ? \"invisible\" : \"visible\",\n      )}\n    >\n      <motion.button\n        type=\"button\"\n        aria-label={context.t(\"close\")}\n        tabIndex={context.openMobile ? 0 : -1}\n        initial={false}\n        animate={{ opacity: context.openMobile ? 1 : 0 }}\n        transition={\n          context.reduce ? REDUCED_TRANSITION : PANEL_TRANSITION\n        }\n        onClick={() => context.setOpenMobile(false)}\n        className={cn(\n          \"fixed inset-0 bg-black/40\",\n          context.openMobile\n            ? \"pointer-events-auto\"\n            : \"pointer-events-none\",\n        )}\n      />\n\n      <motion.div\n        ref={panelRef}\n        role=\"dialog\"\n        aria-modal=\"true\"\n        aria-label={ariaLabel}\n        aria-hidden={!context.openMobile}\n        inert={!context.openMobile}\n        tabIndex={-1}\n        data-mobile=\"true\"\n        data-state={context.openMobile ? \"expanded\" : \"collapsed\"}\n        data-side={side}\n        initial={false}\n        animate={{\n          opacity: context.reduce\n            ? context.openMobile\n              ? 1\n              : 0\n            : 1,\n          x: context.reduce\n            ? 0\n            : context.openMobile\n              ? \"0%\"\n              : side === \"left\"\n                ? \"-100%\"\n                : \"100%\",\n        }}\n        transition={\n          context.reduce ? REDUCED_TRANSITION : PANEL_TRANSITION\n        }\n        onAnimationComplete={() => {\n          if (!openMobileRef.current) setHidden(true);\n        }}\n        className={cn(\n          \"pointer-events-auto fixed inset-y-0 flex h-dvh w-(--sidebar-width-mobile) max-w-[88vw] flex-col overflow-hidden\",\n          \"border-border bg-background shadow-2xl will-change-transform\",\n          side === \"left\" ? \"left-0 border-r\" : \"right-0 border-l\",\n          !context.openMobile && \"pointer-events-none\",\n          className,\n        )}\n      >\n        <AnimatedSidebarPanelContext.Provider\n          value={{ collapsed: false, collapsible: \"none\", side }}\n        >\n          {children}\n        </AnimatedSidebarPanelContext.Provider>\n      </motion.div>\n    </div>,\n    document.body,\n  );\n}\n"},{"path":"components/motion/animated-sidebar/motion.ts","type":"util","content":"import type { Variants } from \"motion/react\";\nimport { EASE_DRAWER, EASE_OUT } from \"@/lib/ease\";\n\nexport const PANEL_TRANSITION = {\n  duration: 0.36,\n  ease: EASE_DRAWER,\n} as const;\n\n// The desktop rail settles at a hard zero-width boundary. Keep the spring\n// critically damped so it cannot overshoot, pause against that boundary, and\n// then snap back during the final frame.\nexport const SIDEBAR_MORPH_TRANSITION = {\n  type: \"spring\",\n  stiffness: 380,\n  damping: 35,\n  mass: 0.75,\n} as const;\n\nexport const LABEL_ENTER_TRANSITION = {\n  duration: 0.2,\n  delay: 0.08,\n  ease: EASE_OUT,\n} as const;\n\nexport const LABEL_EXIT_TRANSITION = {\n  duration: 0.12,\n  ease: EASE_OUT,\n} as const;\n\nconst SUBMENU_TRANSITION = {\n  duration: 0.18,\n  ease: EASE_OUT,\n} as const;\n\nexport const SUBMENU_VARIANTS: Variants = {\n  closed: {\n    opacity: 0,\n    clipPath: \"inset(0 0 100% 0 round 8px)\",\n    transition: {\n      duration: 0.14,\n      ease: EASE_OUT,\n      staggerChildren: 0.025,\n      staggerDirection: -1,\n    },\n  },\n  open: {\n    opacity: 1,\n    clipPath: \"inset(0 0 0% 0 round 8px)\",\n    transition: {\n      duration: 0.2,\n      delayChildren: 0.035,\n      ease: EASE_OUT,\n      staggerChildren: 0.045,\n    },\n  },\n};\n\nexport const SUBMENU_ITEM_VARIANTS: Variants = {\n  closed: {\n    opacity: 0,\n    y: -6,\n    filter: \"blur(3px)\",\n  },\n  open: {\n    opacity: 1,\n    y: 0,\n    filter: \"blur(0px)\",\n    transition: SUBMENU_TRANSITION,\n  },\n};\n\nexport const REDUCED_TRANSITION = {\n  duration: 0.16,\n  ease: EASE_OUT,\n} as const;\n"},{"path":"components/motion/animated-sidebar/use-is-mobile.ts","type":"util","content":"\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\nconst MOBILE_QUERY = \"(max-width: 767px)\";\n\nfunction subscribeToMobileQuery(callback: () => void) {\n  const query = window.matchMedia(MOBILE_QUERY);\n  query.addEventListener(\"change\", callback);\n  return () => query.removeEventListener(\"change\", callback);\n}\n\nfunction getMobileSnapshot() {\n  return window.matchMedia(MOBILE_QUERY).matches;\n}\n\nfunction getServerMobileSnapshot() {\n  return false;\n}\n\nexport function useIsMobile() {\n  return useSyncExternalStore(\n    subscribeToMobileQuery,\n    getMobileSnapshot,\n    getServerMobileSnapshot,\n  );\n}\n"},{"path":"components/motion/shared-layout-bg.tsx","type":"util","content":"\"use client\";\n\nimport {\n  AnimatePresence,\n  type HTMLMotionProps,\n  motion,\n  useReducedMotion,\n  type Variants,\n} from \"motion/react\";\nimport {\n  Children,\n  cloneElement,\n  forwardRef,\n  type HTMLAttributes,\n  type FocusEvent,\n  isValidElement,\n  type MouseEvent,\n  type ReactElement,\n  type ReactNode,\n  type Ref,\n  useId,\n  useRef,\n  useState,\n} from \"react\";\nimport { SPRING_LAYOUT } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface SharedLayoutBgProps\n  extends Omit<HTMLAttributes<HTMLElement>, \"children\"> {\n  children: ReactNode;\n  /** Semantic container used for the children. */\n  as?: \"div\" | \"ul\";\n  /** Tailwind class applied to the moving pill. Defaults to a subtle foreground tint. */\n  pillClassName?: string;\n  /** Horizontal inset of the pill relative to each row (px). Default 20. */\n  inset?: number;\n  /** Optional positioning override for the pill wrapper inside each item. */\n  pillContainerClassName?: string;\n}\n\nconst variants: Variants = {\n  initial: { opacity: 0, filter: \"blur(6px)\" },\n  animate: { opacity: 1, filter: \"blur(0px)\" },\n  exit: (isActive: boolean) =>\n    !isActive ? { opacity: 0, filter: \"blur(6px)\" } : {},\n};\n\nconst reducedVariants: Variants = {\n  initial: { opacity: 0 },\n  animate: { opacity: 1 },\n  exit: (isActive: boolean) => (!isActive ? { opacity: 0 } : {}),\n};\n\nexport const SharedLayoutBg = forwardRef<HTMLElement, SharedLayoutBgProps>(\n  function SharedLayoutBg(\n    {\n      children,\n      as = \"div\",\n      className,\n      onMouseLeave,\n      onBlur,\n      pillClassName,\n      pillContainerClassName,\n      inset = 20,\n      ...props\n    },\n    forwardedRef,\n  ) {\n  const [activeId, setActiveId] = useState<string | null>(null);\n  const uid = useId();\n  const reduce = useReducedMotion();\n  // Focus leaving the list only clears the pill when the pointer is not\n  // still resting on an item.\n  const hovering = useRef(false);\n\n    const renderedChildren = Children.toArray(children)\n      .filter(isValidElement)\n      .map((child, index) => {\n        const el = child as ReactElement<{\n          className?: string;\n          onMouseEnter?: (event: MouseEvent<HTMLElement>) => void;\n          onFocus?: (event: FocusEvent<HTMLElement>) => void;\n          children?: ReactNode;\n        }>;\n        const childKey = el.key ? String(el.key) : `item-${index}`;\n        return cloneElement(\n          el,\n          {\n            key: childKey,\n            className: cn(\"relative\", el.props.className),\n            onMouseEnter: (event: MouseEvent<HTMLElement>) => {\n              el.props.onMouseEnter?.(event);\n              hovering.current = true;\n              setActiveId(childKey);\n            },\n            // Focus bubbles in React, so a link or button anywhere inside the\n            // item brings the pill to it for keyboard users too.\n            onFocus: (event: FocusEvent<HTMLElement>) => {\n              el.props.onFocus?.(event);\n              setActiveId(childKey);\n            },\n          },\n          <>\n            <AnimatePresence custom={activeId !== null}>\n              {activeId !== null ? (\n                <motion.div\n                  variants={reduce ? reducedVariants : variants}\n                  initial=\"initial\"\n                  animate=\"animate\"\n                  exit=\"exit\"\n                  custom={activeId !== null}\n                  className={cn(\n                    \"pointer-events-none absolute inset-y-0\",\n                    pillContainerClassName,\n                  )}\n                  style={{ left: -inset, right: -inset }}\n                >\n                  {activeId === childKey ? (\n                    <motion.div\n                      layoutId={`shared-bg-${uid}`}\n                      transition={reduce ? { duration: 0 } : SPRING_LAYOUT}\n                      className={cn(\n                        \"pointer-events-none h-full w-full rounded-2xl bg-muted/80\",\n                        pillClassName,\n                      )}\n                    />\n                  ) : null}\n                </motion.div>\n              ) : null}\n            </AnimatePresence>\n            <div className=\"relative z-10\">{el.props.children}</div>\n          </>,\n        );\n      });\n\n    const handleMouseLeave = (event: MouseEvent<HTMLElement>) => {\n      hovering.current = false;\n      // Keep the pill on a focused item so keyboard position stays visible.\n      if (!event.currentTarget.contains(document.activeElement))\n        setActiveId(null);\n      onMouseLeave?.(event);\n    };\n\n    const handleBlur = (event: FocusEvent<HTMLElement>) => {\n      const next = event.relatedTarget;\n      if (\n        !hovering.current &&\n        !(next instanceof Node && event.currentTarget.contains(next))\n      )\n        setActiveId(null);\n      onBlur?.(event);\n    };\n\n    // layoutRoot scopes the pill's layout projection to this list, so fixed or\n    // scrolled ancestors can't smear scroll offsets into its movement.\n    return as === \"ul\" ? (\n      <motion.ul\n        {...(props as HTMLMotionProps<\"ul\">)}\n        ref={forwardedRef as Ref<HTMLUListElement>}\n        layoutRoot\n        onMouseLeave={handleMouseLeave}\n        onBlur={handleBlur}\n        className={cn(\"flex w-full flex-col\", className)}\n      >\n        {renderedChildren}\n      </motion.ul>\n    ) : (\n      <motion.div\n        {...(props as HTMLMotionProps<\"div\">)}\n        ref={forwardedRef as Ref<HTMLDivElement>}\n        layoutRoot\n        onMouseLeave={handleMouseLeave}\n        onBlur={handleBlur}\n        className={cn(\"flex w-full flex-col\", className)}\n      >\n        {renderedChildren}\n      </motion.div>\n    );\n  },\n);\n"},{"path":"lib/ease.ts","type":"util","content":"// Shared motion tokens. Easing curves mirror the CSS custom properties in\n// globals.css; springs are the canonical physics used across components.\n// Strong custom variants - defaults like `ease-in`/`ease-out` feel weak.\n\nexport const EASE_OUT = [0.16, 1, 0.3, 1] as const;\n/** Accelerating curve for things that fall (a dropped ball, a toppled block). Not for UI entrances. */\nexport const EASE_IN = [0.55, 0, 1, 0.45] as const;\nexport const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const;\nexport const EASE_DRAWER = [0.32, 0.72, 0, 1] as const;\n\n/** CSS string form of EASE_OUT for inline style transitions. */\nexport const EASE_OUT_CSS = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** Press feedback on buttons and other tappable surfaces. */\nexport const SPRING_PRESS = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 30,\n  mass: 0.6,\n} as const;\n\n/** Content swaps - label/icon slots trading places inside a control. */\nexport const SPRING_SWAP = {\n  type: \"spring\",\n  stiffness: 460,\n  damping: 30,\n  mass: 0.55,\n} as const;\n\n/** Overlay panel entrances - modals and sheets summoned by pointer. */\nexport const SPRING_PANEL = {\n  type: \"spring\",\n  stiffness: 420,\n  damping: 40,\n  mass: 0.5,\n} as const;\n\n/** Shared-layout glides - pills, indicators and panels morphing between positions. */\nexport const SPRING_LAYOUT = {\n  type: \"spring\",\n  stiffness: 360,\n  damping: 32,\n  mass: 0.6,\n} as const;\n\n/** Cursor-follow physics for decorative mouse tracking (magnetic, tilt, dock). */\nexport const SPRING_MOUSE = {\n  stiffness: 200,\n  damping: 15,\n  mass: 0.3,\n} as const;\n\n/** Dragged handles and fills (sliders) - critically damped `useSpring` config,\n * so the value follows the pointer butterily and never rebounds off an end. */\nexport const SPRING_GLIDE = {\n  stiffness: 700,\n  damping: 50,\n  mass: 0.5,\n} as const;\n\n/** Shared-surface morphs: a trigger growing into its panel and back on one\n * weighted spring, so opening and closing travel the same path. */\nexport const SPRING_MORPH = {\n  type: \"spring\",\n  duration: 0.5,\n  bounce: 0.22,\n} as const;\n"},{"path":"lib/i18n.tsx","type":"util","content":"\"use client\";\n\nimport {\n  createContext,\n  type ReactNode,\n  useCallback,\n  useContext,\n  useMemo,\n} from \"react\";\n\n/**\n * A component's messages. Plain strings with `{name}` placeholders, so a\n * dictionary stays JSON-serializable and can be passed from a server layout.\n * There are no plural forms: write messages that read correctly for any count.\n */\nexport type Messages = Record<string, string>;\n\n/** A language file: component namespace → any subset of that component's messages. */\nexport type LocaleMessages = Record<string, Partial<Messages>>;\n\ntype LocaleContextValue = {\n  locale?: string;\n  messages: LocaleMessages;\n};\n\nconst NO_MESSAGES: LocaleMessages = {};\n\nconst LocaleContext = createContext<LocaleContextValue>({ messages: NO_MESSAGES });\n\n/** Without a locale, digits stay plain so server and client render the same text. */\nexport function formatNumber(value: number, locale?: string) {\n  return locale ? new Intl.NumberFormat(locale).format(value) : String(value);\n}\n\nexport interface LocaleProviderProps {\n  /** BCP 47 tag, e.g. `de`, `pt-BR`. Drives `Intl` number formatting. */\n  locale: string;\n  /**\n   * Component namespace → translated strings. Missing keys fall back to English.\n   * Pass a stable object (a module constant, imported JSON or a memoized value):\n   * a new object each render gives every translated component a new `t`.\n   */\n  messages?: LocaleMessages;\n  children: ReactNode;\n}\n\nexport function LocaleProvider({ locale, messages = NO_MESSAGES, children }: LocaleProviderProps) {\n  const value = useMemo(() => ({ locale, messages }), [locale, messages]);\n  return <LocaleContext.Provider value={value}>{children}</LocaleContext.Provider>;\n}\n\nexport function useLocale(): { locale?: string } {\n  return { locale: useContext(LocaleContext).locale };\n}\n\n/**\n * Resolves a component's strings: `labels` prop, then the provider's\n * messages for `namespace`, then the component's English `defaults`.\n * Numbers passed as values are formatted for the provider's locale.\n */\nexport function useMessages<T extends Messages>(\n  namespace: string,\n  defaults: T,\n  labels?: Partial<T>,\n) {\n  const { locale, messages } = useContext(LocaleContext);\n  const provided = messages[namespace];\n  // Inline `labels={{ … }}` is a new object every render. Keying it by content\n  // keeps `t` one identity until a label changes, so effects and memos that\n  // depend on `t` don't re-run per render, and render-time reads never lag.\n  const labelsKey = labels ? JSON.stringify(labels) : \"\";\n  const stableLabels = useMemo(\n    () => (labelsKey ? (JSON.parse(labelsKey) as Partial<T>) : undefined),\n    [labelsKey],\n  );\n\n  return useCallback(\n    (key: keyof T & string, values?: Record<string, string | number>) => {\n      const template = stableLabels?.[key] ?? provided?.[key] ?? defaults[key];\n      if (!values) return template;\n      return template.replace(/\\{(\\w+)\\}/g, (match, name: string) => {\n        const value = values[name];\n        if (value === undefined) return match;\n        return typeof value === \"number\" ? formatNumber(value, locale) : value;\n      });\n    },\n    [defaults, stableLabels, locale, provided],\n  );\n}\n"},{"path":"lib/utils.ts","type":"util","content":"import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs))\n}\n"},{"path":"lib/hooks/use-focus-trap.ts","type":"util","content":"\"use client\";\n\nimport { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\nimport { cycleTab, focusFirstIn } from \"@/lib/focusable\";\nimport { inLayerAbove, type Layer, openLayer, ownsEscape, trapAbove } from \"@/lib/layers\";\n\nexport interface FocusTrapOptions {\n  /** Called on Escape while this is the innermost open layer. */\n  onEscape?: () => void;\n}\n\n/**\n * Moves focus into `panel` when `open` turns true, keeps Tab cycling inside it,\n * pulls focus back if it lands outside, and returns focus to whatever held it\n * before opening once `open` turns false.\n *\n * Layers opened on top (a menu portaled out of a drawer, a sheet opened from\n * it) keep focus and Escape until they close: see `lib/layers.ts`.\n *\n * For overlays rendered in place, where `useModalScope` cannot inert the rest\n * of the page. Pass `open` rather than presence: an exiting panel is already\n * inert through `PresenceGate`, so the trap releases with the same commit.\n * Give the panel `tabIndex={-1}` so it can take focus when it holds nothing\n * focusable.\n */\nexport function useFocusTrap(\n  open: boolean,\n  panel: RefObject<HTMLElement | null>,\n  { onEscape }: FocusTrapOptions = {},\n) {\n  const escapeRef = useRef(onEscape);\n  useLayoutEffect(() => {\n    escapeRef.current = onEscape;\n  });\n\n  useEffect(() => {\n    if (!open || !panel.current) return;\n    const layer: Layer = {\n      contains: (target) => Boolean(panel.current?.contains(target)),\n      traps: true,\n      get escape() {\n        return Boolean(escapeRef.current);\n      },\n    };\n    const closeLayer = openLayer(layer);\n    const returnFocus =\n      document.activeElement instanceof HTMLElement\n        ? document.activeElement\n        : null;\n    if (!panel.current.contains(document.activeElement)) focusFirstIn(panel.current);\n\n    const onFocus = (event: FocusEvent) => {\n      const target = event.target;\n      if (!(target instanceof Node) || !panel.current) return;\n      if (panel.current.closest(\"[inert]\") || panel.current.contains(target)) return;\n      if (inLayerAbove(layer, target) || trapAbove(layer)) return;\n      focusFirstIn(panel.current);\n    };\n    const onKey = (event: KeyboardEvent) => {\n      if (event.key === \"Escape\") {\n        if (!escapeRef.current || !ownsEscape(layer, event)) return;\n        event.preventDefault();\n        escapeRef.current();\n        return;\n      }\n      const active = document.activeElement;\n      if (event.defaultPrevented || (active && inLayerAbove(layer, active))) return;\n      cycleTab(event, panel.current);\n    };\n    document.addEventListener(\"focusin\", onFocus);\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"focusin\", onFocus);\n      document.removeEventListener(\"keydown\", onKey);\n      closeLayer();\n      if (returnFocus?.isConnected && !returnFocus.closest(\"[inert]\"))\n        returnFocus.focus({ preventScroll: true });\n    };\n  }, [open, panel]);\n}\n"},{"path":"lib/scroll-lock.ts","type":"util","content":"\"use client\";\n\nimport { useEffect } from \"react\";\n\nexport interface ScrollLockOptions {\n  /**\n   * Pin the body with `position: fixed` and restore the scroll offset on\n   * release. iOS Safari still scrolls an `overflow: hidden` body under a\n   * touch drag, so full-screen sheets that take touch gestures need this.\n   */\n  fixed?: boolean;\n}\n\n// Reference-counted, so overlays that close out of order never unlock the\n// page under one that is still open. The first lock picks the technique.\nlet owners = 0;\nlet restore: (() => void) | null = null;\n\nfunction apply({ fixed = false }: ScrollLockOptions) {\n  const root = document.documentElement;\n  const body = document.body;\n  const scrollY = window.scrollY;\n  const previous = {\n    rootOverflow: root.style.overflow,\n    overflow: body.style.overflow,\n    position: body.style.position,\n    top: body.style.top,\n    left: body.style.left,\n    right: body.style.right,\n  };\n  root.style.overflow = \"hidden\";\n  body.style.overflow = \"hidden\";\n  if (fixed) {\n    body.style.position = \"fixed\";\n    body.style.top = `-${scrollY}px`;\n    body.style.left = \"0\";\n    body.style.right = \"0\";\n  }\n  return () => {\n    root.style.overflow = previous.rootOverflow;\n    body.style.overflow = previous.overflow;\n    if (!fixed) return;\n    body.style.position = previous.position;\n    body.style.top = previous.top;\n    body.style.left = previous.left;\n    body.style.right = previous.right;\n    window.scrollTo(0, scrollY);\n  };\n}\n\n/** Locks page scroll. Call the returned function to release this lock. */\nexport function lockScroll(options: ScrollLockOptions = {}) {\n  if (owners++ === 0) restore = apply(options);\n  let released = false;\n  return () => {\n    if (released) return;\n    released = true;\n    if (--owners === 0) {\n      restore?.();\n      restore = null;\n    }\n  };\n}\n\n/** Locks page scroll while `locked` is true. */\nexport function useScrollLock(locked: boolean, { fixed = false }: ScrollLockOptions = {}) {\n  useEffect(() => {\n    if (!locked) return;\n    return lockScroll({ fixed });\n  }, [locked, fixed]);\n}\n"},{"path":"lib/focusable.ts","type":"util","content":"/**\n * Elements that can usually take keyboard focus. The selector cannot see\n * everything focus() checks (an element under `display: none`, say), so a\n * caller that needs certainty tries focus() and checks where it landed.\n */\nexport const FOCUSABLE_SELECTOR = [\n  \"a[href]\",\n  \"button:not(:disabled)\",\n  \"input:not(:disabled):not([type='hidden'])\",\n  \"select:not(:disabled)\",\n  \"textarea:not(:disabled)\",\n  \"[tabindex]:not([tabindex='-1'])\",\n].join(\",\");\n\n/** Elements inside `container` that Tab can reach, in DOM order. */\nexport function focusablesIn(container: Element | null | undefined) {\n  return Array.from(\n    container?.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR) ?? [],\n  ).filter((element) => element.tabIndex >= 0 && !element.closest(\"[inert]\"));\n}\n\n/** Focuses the first tabbable element in `panel`, or the panel itself. */\nexport function focusFirstIn(panel: HTMLElement | null | undefined) {\n  (focusablesIn(panel)[0] ?? panel)?.focus({ preventScroll: true });\n}\n\n/**\n * Keeps a Tab keypress inside `panel`, wrapping from the last tabbable element\n * to the first and back. Give the panel `tabIndex={-1}` so it can hold focus\n * when it has nothing tabbable.\n */\nexport function cycleTab(event: KeyboardEvent, panel: HTMLElement | null) {\n  if (event.key !== \"Tab\" || !panel) return;\n  const elements = focusablesIn(panel);\n  const first = elements[0];\n  const last = elements[elements.length - 1];\n  const active = document.activeElement;\n  if (!first || !last) {\n    event.preventDefault();\n    panel.focus({ preventScroll: true });\n  } else if (event.shiftKey && (active === first || active === panel)) {\n    event.preventDefault();\n    last.focus();\n  } else if (!event.shiftKey && active === last) {\n    event.preventDefault();\n    first.focus();\n  }\n}\n"},{"path":"lib/layers.ts","type":"util","content":"/**\n * Every open overlay on the page, innermost last: focus traps, modal scopes\n * and dismissable menus all register here. Overlays have no shared z-order to\n * consult, and a menu inside a drawer portals out of it, so this stack is how\n * they agree on who answers Escape and where focus may go.\n */\n\nexport interface Layer {\n  /** Whether `target` belongs to this layer (its panel, portals, trigger). */\n  contains: (target: Node) => boolean;\n  /** True for focus traps and modal scopes, which pull stray focus back. */\n  traps?: boolean;\n  /** False for a layer that ignores Escape, so the key reaches the one below. */\n  escape?: boolean;\n}\n\nconst stack: Layer[] = [];\n// The innermost layer when each Escape began, read before any handler runs,\n// so a layer that closes itself mid-event can't hand the key to the one below.\nconst escapeOwners = new WeakMap<Event, Layer | undefined>();\nlet listening = false;\n\nfunction innermostEscapeLayer() {\n  for (let index = stack.length - 1; index >= 0; index--) {\n    if (stack[index].escape !== false) return stack[index];\n  }\n  return undefined;\n}\n\nfunction recordEscapeOwner(event: KeyboardEvent) {\n  if (event.key === \"Escape\") escapeOwners.set(event, innermostEscapeLayer());\n}\n\n/** Registers an open layer. Call the returned function when it closes. */\nexport function openLayer(layer: Layer) {\n  if (!listening) {\n    document.addEventListener(\"keydown\", recordEscapeOwner, true);\n    listening = true;\n  }\n  stack.push(layer);\n  return () => {\n    const index = stack.indexOf(layer);\n    if (index !== -1) stack.splice(index, 1);\n  };\n}\n\n/** Whether this Escape is `layer`'s to answer: it was innermost when the key went down. */\nexport function ownsEscape(layer: Layer, event: KeyboardEvent) {\n  if (event.defaultPrevented) return false;\n  const owner = escapeOwners.has(event)\n    ? escapeOwners.get(event)\n    : innermostEscapeLayer();\n  return owner === layer;\n}\n\n/** Whether `target` sits in a layer opened on top of `layer`. */\nexport function inLayerAbove(layer: Layer, target: Node) {\n  const index = stack.indexOf(layer);\n  return stack.slice(index + 1).some((above) => above.contains(target));\n}\n\n/** Whether a focus trap is open on top of `layer`; stray focus is that one's to pull back. */\nexport function trapAbove(layer: Layer) {\n  const index = stack.indexOf(layer);\n  return stack.slice(index + 1).some((above) => above.traps);\n}\n\n/**\n * Whether `target` belongs to any open layer other than `layer`. Pass\n * `traps: false` to count only dismissable overlays, not the traps under them.\n */\nexport function inOtherLayer(layer: Layer, target: Node, { traps = true } = {}) {\n  return stack.some(\n    (other) => other !== layer && (traps || !other.traps) && other.contains(target),\n  );\n}\n"},{"path":"components/previews/motion/animated-sidebar.preview.tsx","type":"preview","content":"\"use client\";\n\nimport {\n  Building2,\n  ChevronRight,\n  ChevronsUpDown,\n  CircleUserRound,\n  Command,\n  Inbox,\n  LayoutGrid,\n  ListTodo,\n  NotebookTabs,\n  PanelLeft,\n  Search,\n  Sparkles,\n  Target,\n  Workflow,\n  X,\n} from \"lucide-react\";\nimport { useState } from \"react\";\nimport {\n  AnimatedSidebar,\n  AnimatedSidebarClose,\n  AnimatedSidebarContent,\n  AnimatedSidebarFooter,\n  AnimatedSidebarGroup,\n  AnimatedSidebarGroupContent,\n  AnimatedSidebarGroupLabel,\n  AnimatedSidebarHeader,\n  AnimatedSidebarInset,\n  AnimatedSidebarMenu,\n  AnimatedSidebarMenuButton,\n  AnimatedSidebarMenuItem,\n  AnimatedSidebarMenuSub,\n  AnimatedSidebarMenuSubButton,\n  AnimatedSidebarMenuSubItem,\n  AnimatedSidebarProvider,\n  AnimatedSidebarRail,\n  AnimatedSidebarTrigger,\n} from \"@/components/motion/animated-sidebar\";\n\nconst destinations = [\n  {\n    label: \"People\",\n    icon: CircleUserRound,\n    children: [\"All people\", \"Recent activity\", \"Segments\"],\n  },\n  {\n    label: \"Companies\",\n    icon: Building2,\n  },\n  {\n    label: \"Opportunities\",\n    icon: Target,\n    children: [\"Pipeline\", \"Forecast\", \"Closed deals\"],\n  },\n  {\n    label: \"Tasks\",\n    icon: ListTodo,\n  },\n  {\n    label: \"Notes\",\n    icon: NotebookTabs,\n  },\n  {\n    label: \"Workflows\",\n    icon: Workflow,\n    children: [\"Automations\", \"Runs\", \"Templates\"],\n  },\n  {\n    label: \"Dashboard\",\n    icon: LayoutGrid,\n  },\n] satisfies {\n  label: string;\n  icon: typeof CircleUserRound;\n  children?: string[];\n}[];\n\nexport function AnimatedSidebarPreview() {\n  const [active, setActive] = useState(\"People\");\n  const [openSection, setOpenSection] = useState<string | null>(null);\n\n  return (\n    <div className=\"w-full px-0 py-2 sm:p-3\">\n      <AnimatedSidebarProvider className=\"h-[720px] min-h-0 overflow-hidden rounded-2xl border border-foreground/[0.08] bg-background\">\n        <AnimatedSidebar\n          ariaLabel=\"Solace workspace\"\n          collapsible=\"icon\"\n          className=\"min-h-0\"\n          panelClassName=\"h-full border-foreground/[0.08]\"\n        >\n          <AnimatedSidebarHeader className=\"p-3 pb-2\">\n            <div className=\"flex min-h-11 items-center gap-3 overflow-hidden px-2\">\n              <div className=\"grid size-7 shrink-0 place-items-center rounded-full bg-muted text-foreground\">\n                <Command aria-hidden=\"true\" className=\"size-4\" />\n              </div>\n              <button\n                type=\"button\"\n                className=\"flex min-w-0 flex-1 items-center gap-2 rounded-full text-left outline-none focus-visible:ring-2 focus-visible:ring-ring group-data-[state=collapsed]/sidebar:hidden\"\n              >\n                <span className=\"truncate text-sm font-medium text-foreground\">\n                  Acme Inc\n                </span>\n                <ChevronsUpDown\n                  aria-hidden=\"true\"\n                  className=\"size-3.5 shrink-0 text-muted-foreground\"\n                />\n              </button>\n              <AnimatedSidebarClose className=\"ml-auto text-muted-foreground hover:bg-muted md:hidden\">\n                <X aria-hidden=\"true\" className=\"size-4\" />\n              </AnimatedSidebarClose>\n            </div>\n          </AnimatedSidebarHeader>\n\n          <AnimatedSidebarContent className=\"px-2 pt-1\">\n            <AnimatedSidebarGroup className=\"pb-2\">\n              <AnimatedSidebarGroupContent>\n                <AnimatedSidebarMenu>\n                  <AnimatedSidebarMenuItem>\n                    <AnimatedSidebarMenuButton\n                      icon={<Search className=\"size-4\" />}\n                      onSelect={() => setActive(\"Search\")}\n                    >\n                      Search\n                    </AnimatedSidebarMenuButton>\n                  </AnimatedSidebarMenuItem>\n                  <AnimatedSidebarMenuItem>\n                    <AnimatedSidebarMenuButton\n                      icon={<Sparkles className=\"size-4\" />}\n                      onSelect={() => setActive(\"AI Assistant\")}\n                    >\n                      AI Assistant\n                    </AnimatedSidebarMenuButton>\n                  </AnimatedSidebarMenuItem>\n                  <AnimatedSidebarMenuItem>\n                    <AnimatedSidebarMenuButton\n                      icon={<Inbox className=\"size-4\" />}\n                      badge=\"4\"\n                      onSelect={() => setActive(\"Inbox\")}\n                    >\n                      Inbox\n                    </AnimatedSidebarMenuButton>\n                  </AnimatedSidebarMenuItem>\n                </AnimatedSidebarMenu>\n              </AnimatedSidebarGroupContent>\n            </AnimatedSidebarGroup>\n\n            <AnimatedSidebarGroup className=\"pt-1\">\n              <AnimatedSidebarGroupLabel>\n                Workspaces\n              </AnimatedSidebarGroupLabel>\n              <AnimatedSidebarGroupContent>\n                <AnimatedSidebarMenu>\n                  {destinations.map(({ label, icon: Icon, children }) => (\n                    <AnimatedSidebarMenuItem key={label}>\n                      <AnimatedSidebarMenuButton\n                        isActive={\n                          active === label ||\n                          children?.includes(active) === true\n                        }\n                        ariaExpanded={\n                          children ? openSection === label : undefined\n                        }\n                        icon={<Icon className=\"size-4\" />}\n                        onSelect={() => {\n                          setOpenSection((current) => {\n                            if (!children) {\n                              setActive(label);\n                              return null;\n                            }\n                            return current === label ? null : label;\n                          });\n                        }}\n                      >\n                        {label}\n                      </AnimatedSidebarMenuButton>\n                      {children ? (\n                        <AnimatedSidebarMenuSub\n                          open={openSection === label}\n                        >\n                          {children.map((child) => (\n                            <AnimatedSidebarMenuSubItem key={child}>\n                              <AnimatedSidebarMenuSubButton\n                                isActive={active === child}\n                                onSelect={() => setActive(child)}\n                              >\n                                {child}\n                              </AnimatedSidebarMenuSubButton>\n                            </AnimatedSidebarMenuSubItem>\n                          ))}\n                        </AnimatedSidebarMenuSub>\n                      ) : null}\n                    </AnimatedSidebarMenuItem>\n                  ))}\n                </AnimatedSidebarMenu>\n              </AnimatedSidebarGroupContent>\n            </AnimatedSidebarGroup>\n          </AnimatedSidebarContent>\n\n          <AnimatedSidebarFooter className=\"gap-3 border-none p-3\">\n\n            <button\n              type=\"button\"\n              className=\"flex min-h-11 w-full items-center gap-3 overflow-hidden rounded-full p-1 text-left outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring\"\n            >\n              <span className=\"grid size-9 shrink-0 place-items-center rounded-full bg-[#d5ff66] text-xs font-medium text-[#172000]\">\n                AS\n              </span>\n              <span className=\"min-w-0 flex-1 group-data-[state=collapsed]/sidebar:hidden\">\n                <span className=\"block truncate text-sm font-medium text-foreground\">\n                  Ava Stone\n                </span>\n                <span className=\"block truncate text-xs text-muted-foreground\">\n                  ava@solace.app\n                </span>\n              </span>\n              <ChevronRight\n                aria-hidden=\"true\"\n                className=\"size-4 shrink-0 text-muted-foreground group-data-[state=collapsed]/sidebar:hidden\"\n              />\n            </button>\n          </AnimatedSidebarFooter>\n\n          <AnimatedSidebarRail />\n        </AnimatedSidebar>\n\n        <AnimatedSidebarInset className=\"min-h-0 bg-background\">\n          <header className=\"flex h-16 shrink-0 items-center gap-3 border-border border-b px-4\">\n            <AnimatedSidebarTrigger className=\"text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\">\n              <PanelLeft aria-hidden=\"true\" className=\"size-4\" />\n            </AnimatedSidebarTrigger>\n            <div className=\"h-5 w-px bg-border\" />\n            <p className=\"text-sm font-medium text-foreground\">{active}</p>\n          </header>\n\n          <div className=\"flex min-h-0 flex-1 flex-col justify-between overflow-hidden p-5 sm:p-7\">\n            <div>\n              <p className=\"text-xs font-medium text-muted-foreground\">\n                Wednesday, July 29\n              </p>\n              <h3 className=\"mt-2 max-w-md text-xl font-medium tracking-tight text-foreground sm:text-2xl\">\n                Good morning, Ava.\n              </h3>\n              <p className=\"mt-2 max-w-md text-sm leading-6 text-muted-foreground\">\n                Your workspace stays in place while the navigation folds down\n                to a focused icon rail.\n              </p>\n            </div>\n\n            <div className=\"flex items-end justify-between border-border border-t pt-4\">\n              <div>\n                <p className=\"text-[11px] uppercase tracking-[0.16em] text-muted-foreground\">\n                  Active view\n                </p>\n                <p className=\"mt-1 text-sm font-medium text-foreground\">\n                  {active}\n                </p>\n              </div>\n              <p className=\"hidden text-xs text-muted-foreground sm:block\">\n                Press ⌘B to toggle\n              </p>\n            </div>\n          </div>\n        </AnimatedSidebarInset>\n      </AnimatedSidebarProvider>\n    </div>\n  );\n}\n"}]}