"use client";
import { cn } from "./index3.js";
import { useControllableState } from "./index11.js";
import { createSafeContext } from "./index21.js";
import { Check, ChevronRight } from "lucide-react";
import * as React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { Menu as Menu$1 } from "@base-ui/react/menu";
//#region src/components/organisms/menus/ContextMenu/ContextMenu.tsx
var [ContextMenuContext, useContextMenuContext] = createSafeContext("ContextMenu");
function Root({ children, open: controlledOpen, defaultOpen = false, onOpenChange }) {
	const [position, setPosition] = React.useState({
		x: 0,
		y: 0
	});
	const [open, setOpen] = useControllableState({
		value: controlledOpen,
		defaultValue: defaultOpen,
		onChange: onOpenChange
	});
	return /* @__PURE__ */ jsx(ContextMenuContext.Provider, {
		value: {
			open,
			setOpen,
			position,
			setPosition
		},
		children: /* @__PURE__ */ jsx(Menu$1.Root, {
			"data-slot": "context-menu",
			open,
			onOpenChange: setOpen,
			children
		})
	});
}
Root.displayName = "ContextMenu.Root";
function Trigger({ children, className, disabled = false, onKeyDown: onKeyDownProp, ...props }) {
	const { setOpen, setPosition } = useContextMenuContext();
	return /* @__PURE__ */ jsx("div", {
		"data-slot": "context-menu-trigger",
		tabIndex: 0,
		onContextMenu: React.useCallback((event) => {
			if (disabled) return;
			event.preventDefault();
			setPosition({
				x: event.clientX,
				y: event.clientY
			});
			setOpen(true);
		}, [
			disabled,
			setOpen,
			setPosition
		]),
		onKeyDown: React.useCallback((event) => {
			onKeyDownProp?.(event);
			if (event.defaultPrevented) return;
			if (disabled) return;
			if (event.key === "F10" && event.shiftKey) {
				event.preventDefault();
				const rect = event.currentTarget.getBoundingClientRect();
				setPosition({
					x: rect.left + rect.width / 2,
					y: rect.top + rect.height / 2
				});
				setOpen(true);
			}
		}, [
			disabled,
			onKeyDownProp,
			setOpen,
			setPosition
		]),
		className,
		...props,
		children
	});
}
Trigger.displayName = "ContextMenu.Trigger";
function Portal({ ...props }) {
	return /* @__PURE__ */ jsx(Menu$1.Portal, {
		"data-slot": "context-menu-portal",
		...props
	});
}
Portal.displayName = "ContextMenu.Portal";
function Popup({ alignOffset = 0, sideOffset = 0, className, ...props }) {
	const { position } = useContextMenuContext();
	const virtualAnchor = React.useMemo(() => ({ getBoundingClientRect: () => ({
		x: position.x,
		y: position.y,
		width: 0,
		height: 0,
		top: position.y,
		right: position.x,
		bottom: position.y,
		left: position.x,
		toJSON: () => ({})
	}) }), [position.x, position.y]);
	return /* @__PURE__ */ jsx(Menu$1.Portal, { children: /* @__PURE__ */ jsx(Menu$1.Positioner, {
		className: "isolate z-50 outline-none",
		anchor: virtualAnchor,
		side: "bottom",
		align: "start",
		sideOffset,
		alignOffset,
		collisionPadding: 8,
		children: /* @__PURE__ */ jsx(Menu$1.Popup, {
			"data-slot": "context-menu-popup",
			className: cn("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 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-md p-1 shadow-md ring-1 duration-100 z-50 max-h-(--available-height) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden motion-reduce:animate-none", className),
			...props
		})
	}) });
}
Popup.displayName = "ContextMenu.Popup";
function Group({ ...props }) {
	return /* @__PURE__ */ jsx(Menu$1.Group, {
		"data-slot": "context-menu-group",
		...props
	});
}
Group.displayName = "ContextMenu.Group";
function Label({ className, inset, ...props }) {
	return /* @__PURE__ */ jsx(Menu$1.GroupLabel, {
		"data-slot": "context-menu-label",
		"data-inset": inset,
		className: cn("text-muted-foreground px-2 py-1.5 text-xs font-medium data-[inset]:ps-8", className),
		...props
	});
}
Label.displayName = "ContextMenu.Label";
function Item({ className, inset, variant = "default", ...props }) {
	return /* @__PURE__ */ jsx(Menu$1.Item, {
		"data-slot": "context-menu-item",
		"data-inset": inset,
		"data-variant": variant,
		className: cn("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground gap-2 rounded-sm px-2 py-2 text-sm [&_svg:not([class*='size-'])]:size-4 group/context-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[inset]:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 transition-[color,background-color,transform] duration-150 active:scale-[0.99]", className),
		...props
	});
}
Item.displayName = "ContextMenu.Item";
function Sub({ ...props }) {
	return /* @__PURE__ */ jsx(Menu$1.SubmenuRoot, {
		"data-slot": "context-menu-sub",
		...props
	});
}
Sub.displayName = "ContextMenu.Sub";
function SubTrigger({ className, inset, children, ...props }) {
	return /* @__PURE__ */ jsxs(Menu$1.SubmenuTrigger, {
		"data-slot": "context-menu-sub-trigger",
		"data-inset": inset,
		className: cn("focus:bg-accent focus:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground gap-2 rounded-sm px-2 py-2 text-sm [&_svg:not([class*='size-'])]:size-4 group/ctx-sub flex cursor-default items-center outline-hidden select-none data-[inset]:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 transition-[color,background-color,transform] duration-150 active:scale-[0.99]", className),
		...props,
		children: [children, /* @__PURE__ */ jsx(ChevronRight, { className: "ms-auto rtl:rotate-180 transition-transform duration-150 group-data-open/ctx-sub:translate-x-0.5" })]
	});
}
SubTrigger.displayName = "ContextMenu.SubTrigger";
function SubPopup({ className, ...props }) {
	return /* @__PURE__ */ jsx(Menu$1.Portal, { children: /* @__PURE__ */ jsx(Menu$1.Positioner, {
		className: "isolate z-50 outline-none",
		side: "right",
		align: "start",
		sideOffset: 0,
		alignOffset: -3,
		children: /* @__PURE__ */ jsx(Menu$1.Popup, {
			"data-slot": "context-menu-sub-popup",
			className: cn("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 ring-foreground/10 bg-popover text-popover-foreground min-w-[96px] rounded-md p-1 shadow-lg ring-1 duration-100 w-auto motion-reduce:animate-none", className),
			...props
		})
	}) });
}
SubPopup.displayName = "ContextMenu.SubPopup";
function CheckboxItem({ className, children, checked, ...props }) {
	return /* @__PURE__ */ jsxs(Menu$1.CheckboxItem, {
		"data-slot": "context-menu-checkbox-item",
		className: cn("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground gap-2 rounded-sm py-2 pe-8 ps-2 text-sm [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 transition-colors duration-150", className),
		checked,
		...props,
		children: [/* @__PURE__ */ jsx("span", {
			className: "pointer-events-none absolute end-2 flex items-center justify-center",
			"data-slot": "context-menu-checkbox-item-indicator",
			children: /* @__PURE__ */ jsx(Menu$1.CheckboxItemIndicator, {
				className: "animate-in zoom-in-75 duration-150 motion-reduce:animate-none",
				children: /* @__PURE__ */ jsx(Check, {})
			})
		}), children]
	});
}
CheckboxItem.displayName = "ContextMenu.CheckboxItem";
function RadioGroup({ ...props }) {
	return /* @__PURE__ */ jsx(Menu$1.RadioGroup, {
		"data-slot": "context-menu-radio-group",
		...props
	});
}
RadioGroup.displayName = "ContextMenu.RadioGroup";
function RadioItem({ className, children, ...props }) {
	return /* @__PURE__ */ jsxs(Menu$1.RadioItem, {
		"data-slot": "context-menu-radio-item",
		className: cn("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground gap-2 rounded-sm py-2 pe-8 ps-2 text-sm [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 transition-colors duration-150", className),
		...props,
		children: [/* @__PURE__ */ jsx("span", {
			className: "pointer-events-none absolute end-2 flex items-center justify-center",
			"data-slot": "context-menu-radio-item-indicator",
			children: /* @__PURE__ */ jsx(Menu$1.RadioItemIndicator, {
				className: "animate-in zoom-in-75 duration-150 motion-reduce:animate-none",
				children: /* @__PURE__ */ jsx(Check, {})
			})
		}), children]
	});
}
RadioItem.displayName = "ContextMenu.RadioItem";
function Separator({ className, ...props }) {
	return /* @__PURE__ */ jsx(Menu$1.Separator, {
		"data-slot": "context-menu-separator",
		className: cn("bg-border -mx-1 my-1 h-px", className),
		...props
	});
}
Separator.displayName = "ContextMenu.Separator";
function Shortcut({ className, ...props }) {
	return /* @__PURE__ */ jsx("span", {
		"data-slot": "context-menu-shortcut",
		className: cn("text-muted-foreground group-focus/context-menu-item:text-accent-foreground ms-auto text-xs tracking-widest transition-colors duration-150", className),
		...props
	});
}
Shortcut.displayName = "ContextMenu.Shortcut";
var ContextMenu = Object.assign(Root, {
	Root,
	Trigger,
	Portal,
	Popup,
	Group,
	Label,
	Item,
	Sub,
	SubTrigger,
	SubPopup,
	CheckboxItem,
	RadioGroup,
	RadioItem,
	Separator,
	Shortcut
});
//#endregion
export { CheckboxItem, ContextMenu, Group, Item, Label, Popup, Portal, RadioGroup, RadioItem, Root, Separator, Shortcut, Sub, SubPopup, SubTrigger, Trigger };

//# sourceMappingURL=index460.js.map