import { cs } from "../utils/styles.js";
import { useStyleConfig } from "../core/theme.js";
import vui from "../core/vui.js";
import Icon from "../icon/icon.js";
import { useButtonContext } from "./context.js";
import { jsx } from "react/jsx-runtime";

//#region src/button/buttonIcon.tsx
const isConceptualIcon = (name) => name?.startsWith("con");
/** Displays an icon within the Button. */
const ButtonIcon = vui((props, ref) => {
	const { className, name, mr, ml, ...rest } = props;
	const buttonContext = useButtonContext();
	const styles = useStyleConfig("Button", buttonContext);
	const verifiedName = isConceptualIcon(name) ? void 0 : name;
	const isIconOnly = !buttonContext?.hasTextContent;
	const defaultMarginRight = isIconOnly ? 0 : styles.icon?.mr || 0;
	const defaultMarginLeft = isIconOnly ? 0 : styles.icon?.ml || 0;
	const marginRight = mr !== void 0 ? mr : `var(--vui-button-icon-mr, ${defaultMarginRight})`;
	const marginLeft = ml !== void 0 ? ml : `var(--vui-button-icon-ml, ${defaultMarginLeft})`;
	return /* @__PURE__ */ jsx(Icon, {
		className: cs("vui-buttonIcon", className),
		...styles.icon,
		fontSize: `var(--vui-button-icon-size, ${styles.icon?.fontSize || "1rem"})`,
		ml: marginLeft,
		mr: marginRight,
		name: verifiedName,
		ref,
		...rest
	});
});
ButtonIcon.displayName = "ButtonIcon";

//#endregion
export { ButtonIcon as default };
globalThis.__vuiVersion__ = "4.0.0-beta.1"
//# sourceMappingURL=buttonIcon.js.map