import { n as __exportAll } from "./chunk-B-1-B7_t.js";
import { n as Button_default } from "./button-B9CnnuTu.js";
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref, withCtx } from "vue";
import * as LucideIcons from "@lucide/vue";
//#region src/components/compositions/elements/action/ButtonGroupAction.vue?vue&type=script&setup=true&lang.ts
var _hoisted_1 = ["id", "data-element-name"];
var ButtonGroupAction_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
	__name: "ButtonGroupAction",
	props: {
		items: { default: () => [] },
		variant: { default: "default" },
		size: { default: "md" },
		block: { type: Boolean },
		id: {},
		name: {}
	},
	emits: ["action", "click"],
	setup(__props, { emit: __emit }) {
		/**
		* Props-driven button-group composition. Renders an array of child
		* actions as a row of Buttons, each capable of emitting a click or
		* navigating to its href.
		*
		*   <ButtonGroupAction
		*     :items="[
		*       { label: 'Edit', emit: 'edit' },
		*       { label: 'Delete', variant: 'destructive', emit: 'delete' },
		*     ]"
		*     @action="onAction"
		*   />
		*/
		const props = __props;
		const emit = __emit;
		const sizeMap = {
			sm: "sm",
			md: "default",
			lg: "lg"
		};
		const mappedSize = computed(() => sizeMap[props.size] ?? "default");
		const iconLibrary = LucideIcons;
		function resolveIcon(name) {
			if (!name) return;
			return iconLibrary[name.split(/[-_\s]/).filter(Boolean).map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join("")] ?? iconLibrary[name];
		}
		function variantFor(item) {
			return item.variant ?? props.variant;
		}
		function onClick(child, event) {
			emit("click", event, child);
			if (child.href) return;
			event.preventDefault();
			if (child.emit) emit("action", {
				name: child.emit,
				item: child
			});
		}
		return (_ctx, _cache) => {
			return openBlock(), createElementBlock("div", {
				id: __props.id,
				class: "inline-flex flex-wrap items-center gap-2",
				role: "group",
				"data-element-name": __props.name ?? void 0
			}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.items, (child, idx) => {
				return openBlock(), createBlock(unref(Button_default), {
					key: child.id ?? `${child.label}-${idx}`,
					as: child.href ? "a" : "button",
					href: child.href,
					target: child.href ? child.target : void 0,
					variant: variantFor(child),
					size: mappedSize.value,
					disabled: child.disabled,
					class: normalizeClass(__props.block ? "flex-1" : ""),
					"data-item-emit": child.emit,
					onClick: (e) => onClick(child, e)
				}, {
					default: withCtx(() => [resolveIcon(child.icon) ? (openBlock(), createBlock(resolveDynamicComponent(resolveIcon(child.icon)), {
						key: 0,
						class: "h-4 w-4"
					})) : createCommentVNode("", true), createElementVNode("span", null, toDisplayString(child.label), 1)]),
					_: 2
				}, 1032, [
					"as",
					"href",
					"target",
					"variant",
					"size",
					"disabled",
					"class",
					"data-item-emit",
					"onClick"
				]);
			}), 128))], 8, _hoisted_1);
		};
	}
});
//#endregion
//#region src/components/compositions/elements/action/ButtonGroupAction.vue
var ButtonGroupAction_exports = /* @__PURE__ */ __exportAll({ default: () => ButtonGroupAction_default });
var ButtonGroupAction_default = ButtonGroupAction_vue_vue_type_script_setup_true_lang_default;
//#endregion
export { ButtonGroupAction_exports as n, ButtonGroupAction_default as t };

//# sourceMappingURL=ButtonGroupAction-03S8USgW.js.map