import { a as D, v as u, x as k } from "./vendor-preact-DThS2ZQ_.js";
import { n as cn, t as LoadingIcon } from "./loadingIcon-B0ysgiNq.js";
//#region src/shared/button/button.tsx
var LOADER_SIZE = 30;
var variantClass = {
	primary: "IncodeButtonPrimary",
	secondary: "IncodeButtonSecondary",
	link: "IncodeButtonLink"
};
var sizeClass = {
	L: "IncodeButtonL",
	M: "IncodeButtonM",
	S: "IncodeButtonS"
};
var Button = D((props, ref) => {
	const { isLoading = false, variant = "primary", size = "L", icon, class: className, type = "button", children, disabled, ...rest } = props;
	const iconOnly = !children && !!icon;
	const showLoader = isLoading && size === "L";
	const renderContent = () => {
		if (showLoader) return /* @__PURE__ */ u(LoadingIcon, { size: LOADER_SIZE });
		if (iconOnly) return icon;
		if (icon) return /* @__PURE__ */ u(k, { children: [children, icon] });
		return children;
	};
	return /* @__PURE__ */ u("button", {
		ref,
		...rest,
		class: cn("IncodeButton", variantClass[variant], sizeClass[size], showLoader ? "IncodeButtonLoading" : "", iconOnly ? "IncodeButtonIconOnly" : "", className),
		disabled: disabled || showLoader,
		type,
		children: renderContent()
	});
});
//#endregion
export { Button as t };
