import ActionsMenu from "./ActionsMenu.js";
import { computed, createVNode, defineComponent } from "vue";
import { Tooltip } from "antdv-next";
//#region components/actions/Item.tsx
var keySeed = 0;
var Item = /* @__PURE__ */ defineComponent({
	name: "XActionsActionItem",
	props: {
		item: {
			type: Object,
			required: true
		},
		onClick: {
			type: Function,
			default: void 0
		},
		dropdownProps: {
			type: Object,
			default: void 0
		},
		prefixCls: {
			type: String,
			default: "antd-actions"
		},
		classes: {
			type: Object,
			default: () => ({})
		},
		styles: {
			type: Object,
			default: () => ({})
		}
	},
	setup(props) {
		const fallbackKey = `actions-item-${++keySeed}`;
		const itemKey = computed(() => {
			if (props.item?.key === void 0 || props.item?.key === null) return fallbackKey;
			return String(props.item.key);
		});
		const onItemClick = (domEvent) => {
			if (props.item.onItemClick) {
				props.item.onItemClick(props.item);
				return;
			}
			props.onClick?.({
				key: itemKey.value,
				item: props.item,
				keyPath: [itemKey.value],
				domEvent
			});
		};
		return () => {
			if (!props.item) return null;
			if (props.item.actionRender !== void 0) return typeof props.item.actionRender === "function" ? props.item.actionRender(props.item) : props.item.actionRender;
			if (props.item.subItems?.length) return createVNode(ActionsMenu, {
				"item": props.item,
				"onClick": props.onClick,
				"dropdownProps": props.dropdownProps,
				"prefixCls": props.prefixCls,
				"classes": props.classes,
				"styles": props.styles
			}, null);
			return createVNode("div", {
				"class": [
					`${props.prefixCls}-item`,
					props.classes?.item,
					{ [`${props.prefixCls}-list-danger`]: props.item?.danger }
				],
				"style": props.styles?.item,
				"onClick": onItemClick
			}, [createVNode(Tooltip, { "title": props.item.label }, { default: () => [createVNode("div", { "class": `${props.prefixCls}-icon` }, [props.item?.icon])] })]);
		};
	}
});
//#endregion
export { Item as default };
