"use client";
import { cn } from "./index3.js";
import { useControllableState } from "./index11.js";
import { createSafeContext } from "./index21.js";
import { Switch } from "./index37.js";
import { Kbd } from "./index83.js";
import { PopoverPopup, PopoverRoot, PopoverTrigger } from "./index467.js";
import { cva } from "class-variance-authority";
import { ChevronRight, LogOut } from "lucide-react";
import * as React from "react";
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
//#region src/components/templates/NavAccountMenu/NavAccountMenu.tsx
var [NavAccountMenuContext, useNavAccountMenuContext] = createSafeContext("NavAccountMenu");
function NavAccountMenu({ type = "card", open: controlledOpen, defaultOpen = false, onOpenChange, children }) {
	const [open, handleOpenChange] = useControllableState({
		value: controlledOpen,
		defaultValue: defaultOpen,
		onChange: onOpenChange
	});
	const contextValue = React.useMemo(() => ({
		type,
		open,
		onOpenChange: handleOpenChange
	}), [
		type,
		open,
		handleOpenChange
	]);
	return /* @__PURE__ */ jsx(NavAccountMenuContext.Provider, {
		value: contextValue,
		children: /* @__PURE__ */ jsx(PopoverRoot, {
			open,
			onOpenChange: handleOpenChange,
			children: /* @__PURE__ */ jsx("div", {
				"data-slot": "nav-account-menu",
				children
			})
		})
	});
}
var triggerVariants = cva("flex items-center gap-4 w-full text-left cursor-pointer transition-colors duration-200 ease-smooth outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none", {
	variants: { type: {
		card: "bg-card-alt border border-border rounded-xl shadow-xs p-3 hover:bg-card-hover",
		simple: "border-t border-border pt-5 hover:bg-card-hover rounded-lg px-2"
	} },
	defaultVariants: { type: "card" }
});
function NavAccountMenuTrigger({ avatar, name, email, badge, showLogoutButton, onLogout, compact = false, className }) {
	const { type, open } = useNavAccountMenuContext();
	const handleLogoutClick = (e) => {
		e.stopPropagation();
		onLogout?.();
	};
	return /* @__PURE__ */ jsxs(PopoverTrigger, {
		render: /* @__PURE__ */ jsx("button", {
			type: "button",
			"data-slot": "nav-account-menu-trigger",
			"aria-haspopup": "true",
			"aria-label": compact ? `${name} account menu` : void 0,
			className: cn(triggerVariants({ type }), "group/trigger", compact ? "w-auto justify-center" : "w-[280px]", className)
		}),
		children: [avatar && /* @__PURE__ */ jsx("div", {
			className: "shrink-0",
			children: avatar
		}), !compact && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("div", {
			className: "flex flex-col min-w-0 flex-1",
			children: [/* @__PURE__ */ jsxs("div", {
				className: "flex items-center gap-2",
				children: [/* @__PURE__ */ jsx("span", {
					className: "text-sm font-semibold text-foreground truncate",
					children: name
				}), badge]
			}), email && /* @__PURE__ */ jsx("span", {
				className: "text-sm text-muted-foreground truncate",
				children: email
			})]
		}), type === "simple" && showLogoutButton ? /* @__PURE__ */ jsx("button", {
			type: "button",
			onClick: handleLogoutClick,
			className: "shrink-0 p-1.5 rounded-md hover:bg-muted text-quaternary-foreground hover:text-secondary-foreground transition-colors duration-200 ease-smooth focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none",
			"aria-label": "Sign out",
			children: /* @__PURE__ */ jsx(LogOut, { className: "size-5" })
		}) : /* @__PURE__ */ jsx(ChevronRight, { className: cn("size-4 shrink-0 text-muted-foreground transition-transform duration-200 ease-smooth motion-reduce:transition-none", open ? "rotate-180" : "rtl:rotate-180") })] })]
	});
}
function NavAccountMenuContent({ side = "right", align = "end", sideOffset = 8, children, className }) {
	return /* @__PURE__ */ jsx(PopoverPopup, {
		side,
		align,
		sideOffset,
		"aria-label": "Account menu",
		"data-slot": "nav-account-menu-content",
		className: cn("w-[300px] max-w-[calc(100vw-2rem)] p-0 gap-0 bg-popover border border-border rounded-[14px] overflow-hidden", "shadow-[0px_12px_16px_-4px_color-mix(in_srgb,var(--foreground)_8%,transparent),0px_4px_6px_-2px_color-mix(in_srgb,var(--foreground)_3%,transparent),0px_2px_2px_-1px_color-mix(in_srgb,var(--foreground)_4%,transparent)]", "data-open:animate-in data-closed:animate-out", "data-closed:fade-out-0 data-open:fade-in-0", "data-closed:zoom-out-95 data-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", "duration-200 motion-reduce:animate-none", className),
		children: /* @__PURE__ */ jsx("div", {
			className: "flex flex-col py-5",
			role: "menu",
			"aria-label": "Account menu",
			children
		})
	});
}
function NavAccountMenuHeader({ title, subtitle, className }) {
	return /* @__PURE__ */ jsxs("div", {
		"data-slot": "nav-account-menu-header",
		className: cn("px-6 pb-3 delight-fade-in", className),
		children: [/* @__PURE__ */ jsx("p", {
			className: "text-base font-semibold text-foreground",
			children: title
		}), subtitle && (typeof subtitle === "string" ? /* @__PURE__ */ jsx("p", {
			className: "mt-2 text-sm text-muted-foreground",
			children: subtitle
		}) : /* @__PURE__ */ jsx("div", {
			className: "mt-2",
			children: subtitle
		}))]
	});
}
function NavAccountMenuSection({ label, bordered = false, children, className }) {
	return /* @__PURE__ */ jsxs("div", {
		"data-slot": "nav-account-menu-section",
		role: "group",
		"aria-label": label,
		className: cn("flex flex-col gap-1 py-1.5", bordered && "border-t border-border", className),
		children: [label && /* @__PURE__ */ jsx("div", {
			className: "px-3 pt-1.5 pb-1",
			children: /* @__PURE__ */ jsx("span", {
				className: "text-xs font-semibold text-muted-foreground",
				children: label
			})
		}), children]
	});
}
function NavAccountMenuItem({ icon, shortcut, destructive = false, disabled = false, onSelect, render, children, className }) {
	const { onOpenChange } = useNavAccountMenuContext();
	const handleClick = () => {
		if (disabled) return;
		onSelect?.();
		onOpenChange(false);
	};
	const content = /* @__PURE__ */ jsxs("div", {
		className: "flex flex-1 gap-2 items-center overflow-hidden p-2 rounded-md transition-[background-color] duration-200 ease-smooth delight-selection-press motion-reduce:transition-none",
		children: [/* @__PURE__ */ jsxs("div", {
			className: "flex flex-1 gap-2 items-center min-w-0",
			children: [icon && /* @__PURE__ */ jsx("span", {
				className: cn("shrink-0 [&>svg]:size-4 transition-transform duration-200 ease-smooth group-hover/menuitem:translate-x-0.5 motion-reduce:transition-none", destructive ? "text-destructive" : "text-foreground"),
				children: icon
			}), /* @__PURE__ */ jsx("span", {
				className: cn("flex-1 text-sm truncate", destructive ? "text-destructive" : "text-secondary-foreground"),
				children
			})]
		}), shortcut && /* @__PURE__ */ jsx(Kbd, {
			variant: "outline",
			size: "xs",
			className: "shrink-0",
			children: shortcut
		})]
	});
	const baseClassName = cn("group/menuitem flex items-center px-1.5 py-0 w-full text-left cursor-pointer outline-none", "hover:[&>div]:bg-muted focus-visible:[&>div]:bg-muted", "focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring", disabled && "pointer-events-none opacity-50", className);
	if (render) return render({
		className: baseClassName,
		onClick: handleClick,
		children: content
	});
	return /* @__PURE__ */ jsx("button", {
		type: "button",
		role: "menuitem",
		"data-slot": "nav-account-menu-item",
		className: baseClassName,
		onClick: handleClick,
		disabled,
		"aria-disabled": disabled || void 0,
		children: content
	});
}
function NavAccountMenuAccount({ avatar, name, email, selected = false, onSelect, className }) {
	return /* @__PURE__ */ jsx("div", {
		"data-slot": "nav-account-menu-account",
		className: cn("flex items-center px-1.5 py-0 w-full", className),
		children: /* @__PURE__ */ jsxs("button", {
			type: "button",
			role: "menuitemradio",
			"aria-checked": selected,
			"aria-label": `Switch to ${name} (${email})`,
			className: cn("relative flex flex-1 gap-2 items-center overflow-hidden px-2 py-1.5 rounded-md cursor-pointer outline-none", "hover:bg-muted focus-visible:bg-muted", "transition-colors duration-200 ease-smooth motion-reduce:transition-none", "focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring", "text-left", selected && "bg-card-hover"),
			onClick: onSelect,
			children: [
				avatar && /* @__PURE__ */ jsx("div", {
					className: "shrink-0",
					children: avatar
				}),
				/* @__PURE__ */ jsxs("div", {
					className: "flex flex-col min-w-0 flex-1",
					children: [/* @__PURE__ */ jsx("span", {
						className: "text-sm font-semibold text-foreground truncate",
						children: name
					}), /* @__PURE__ */ jsx("span", {
						className: "text-sm text-muted-foreground truncate",
						children: email
					})]
				}),
				/* @__PURE__ */ jsx("div", {
					"aria-hidden": "true",
					className: cn("size-4 rounded-full border-2 shrink-0 flex items-center justify-center transition-colors duration-200 ease-smooth motion-reduce:transition-none", selected ? "bg-primary border-bg-brand-solid" : "border-border bg-transparent"),
					children: selected && /* @__PURE__ */ jsx("div", { className: "size-1.5 rounded-full bg-fg-white delight-check-bounce" })
				})
			]
		})
	});
}
function NavAccountMenuSeparator({ className }) {
	return /* @__PURE__ */ jsx("hr", {
		"data-slot": "nav-account-menu-separator",
		className: cn("h-px border-0 bg-border mx-5", className)
	});
}
function NavAccountMenuFooter({ children, className }) {
	return /* @__PURE__ */ jsx("div", {
		"data-slot": "nav-account-menu-footer",
		className: cn("flex items-center justify-center px-5 pt-4", className),
		children
	});
}
function NavAccountMenuThemeSwitch({ variant = "theme-gradient", size = "sm", checked, onCheckedChange, label, className }) {
	return /* @__PURE__ */ jsx("div", {
		"data-slot": "nav-account-menu-theme-switch",
		className: cn("flex items-center px-1.5 py-0", className),
		children: /* @__PURE__ */ jsxs("label", {
			className: "flex items-center gap-2.5 p-2 cursor-pointer",
			children: [/* @__PURE__ */ jsx(Switch, {
				variant,
				size,
				checked,
				onCheckedChange,
				"aria-label": label ? void 0 : "Theme selector"
			}), label && /* @__PURE__ */ jsx("span", {
				className: "text-sm text-secondary-foreground",
				children: label
			})]
		})
	});
}
NavAccountMenu.displayName = "NavAccountMenu";
NavAccountMenuTrigger.displayName = "NavAccountMenuTrigger";
NavAccountMenuContent.displayName = "NavAccountMenuContent";
NavAccountMenuHeader.displayName = "NavAccountMenuHeader";
NavAccountMenuSection.displayName = "NavAccountMenuSection";
NavAccountMenuItem.displayName = "NavAccountMenuItem";
NavAccountMenuAccount.displayName = "NavAccountMenuAccount";
NavAccountMenuSeparator.displayName = "NavAccountMenuSeparator";
NavAccountMenuFooter.displayName = "NavAccountMenuFooter";
NavAccountMenuThemeSwitch.displayName = "NavAccountMenuThemeSwitch";
//#endregion
export { NavAccountMenu, NavAccountMenuAccount, NavAccountMenuContent, NavAccountMenuFooter, NavAccountMenuHeader, NavAccountMenuItem, NavAccountMenuSection, NavAccountMenuSeparator, NavAccountMenuThemeSwitch, NavAccountMenuTrigger, triggerVariants };

//# sourceMappingURL=index480.js.map