import { computed, createVNode, defineComponent, inject, mergeProps, provide } from "vue";
import { Button } from "antdv-next";
//#region components/sender/components/ActionButton.tsx
var ActionButtonContextKey = Symbol("action-button-context");
function useActionButtonContext() {
	return inject(ActionButtonContextKey, computed(() => ({ prefixCls: "" })));
}
function provideActionButtonContext(value) {
	provide(ActionButtonContextKey, value);
}
var ActionButton = /* @__PURE__ */ defineComponent({
	name: "ActionButton",
	inheritAttrs: false,
	props: {
		action: {
			type: String,
			required: true
		},
		disabled: {
			type: Boolean,
			default: void 0
		},
		icon: {
			type: Object,
			default: void 0
		},
		type: {
			type: String,
			default: "text"
		},
		shape: {
			type: String,
			default: void 0
		},
		color: {
			type: String,
			default: void 0
		},
		variant: {
			type: String,
			default: void 0
		}
	},
	setup(props, { attrs }) {
		const context = useActionButtonContext();
		const mergedDisabled = computed(() => {
			if (props.disabled !== void 0) return props.disabled;
			if (context.value.disabled) return true;
			const disabledKey = `${props.action}Disabled`;
			return context.value[disabledKey] ?? false;
		});
		return () => {
			const { prefixCls } = context.value;
			return createVNode(Button, mergeProps({
				"type": props.type,
				"shape": props.shape,
				"color": props.color,
				"variant": props.variant
			}, attrs, {
				"icon": props.icon,
				"disabled": mergedDisabled.value,
				"class": [
					prefixCls,
					attrs.class,
					{ [`${prefixCls}-disabled`]: mergedDisabled.value }
				],
				"onClick": (e) => {
					if (mergedDisabled.value) return;
					const handler = context.value[props.action];
					if (typeof handler === "function") handler();
					attrs.onClick?.(e);
				}
			}), null);
		};
	}
});
//#endregion
export { ActionButtonContextKey, ActionButton as default, provideActionButtonContext, useActionButtonContext };
