"use client";
const require_rem = require("../../core/utils/units-converters/rem.cjs");
const require_get_size = require("../../core/utils/get-size/get-size.cjs");
const require_create_vars_resolver = require("../../core/styles-api/create-vars-resolver/create-vars-resolver.cjs");
const require_use_props = require("../../core/MantineProvider/use-props/use-props.cjs");
const require_use_styles = require("../../core/styles-api/use-styles/use-styles.cjs");
const require_polymorphic_factory = require("../../core/factory/polymorphic-factory.cjs");
const require_Box = require("../../core/Box/Box.cjs");
const require_UnstyledButton = require("../UnstyledButton/UnstyledButton.cjs");
const require_Transition = require("../Transition/Transition.cjs");
const require_Loader = require("../Loader/Loader.cjs");
const require_Button_module = require("./Button.module.cjs");
const require_ButtonGroup = require("./ButtonGroup/ButtonGroup.cjs");
const require_ButtonGroupSection = require("./ButtonGroupSection/ButtonGroupSection.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/Button/Button.tsx
const loaderTransition = {
	in: {
		opacity: 1,
		transform: `translate(-50%, calc(-50% + ${require_rem.rem(1)}))`
	},
	out: {
		opacity: 0,
		transform: "translate(-50%, -200%)"
	},
	common: { transformOrigin: "center" },
	transitionProperty: "transform, opacity"
};
const varsResolver = require_create_vars_resolver.createVarsResolver((theme, { radius, color, gradient, variant, size, justify, autoContrast }) => {
	const colors = theme.variantColorResolver({
		color: color || theme.primaryColor,
		theme,
		gradient,
		variant: variant || "filled",
		autoContrast
	});
	return { root: {
		"--button-justify": justify,
		"--button-height": require_get_size.getSize(size, "button-height"),
		"--button-padding-x": require_get_size.getSize(size, "button-padding-x"),
		"--button-fz": size?.includes("compact") ? require_get_size.getFontSize(size.replace("compact-", "")) : require_get_size.getFontSize(size),
		"--button-radius": radius === void 0 ? void 0 : require_get_size.getRadius(radius),
		"--button-bg": color || variant ? colors.background : void 0,
		"--button-hover": color || variant ? colors.hover : void 0,
		"--button-color": colors.color,
		"--button-bd": color || variant ? colors.border : void 0,
		"--button-hover-color": color || variant ? colors.hoverColor : void 0
	} };
});
const Button = require_polymorphic_factory.polymorphicFactory((_props) => {
	const props = require_use_props.useProps("Button", null, _props);
	const { style, vars, className, color, disabled, children, leftSection, rightSection, fullWidth, variant, radius, loading, loaderProps, gradient, classNames, styles, unstyled, "data-disabled": dataDisabled, autoContrast, mod, attributes, ...others } = props;
	const getStyles = require_use_styles.useStyles({
		name: "Button",
		props,
		classes: require_Button_module.default,
		className,
		style,
		classNames,
		styles,
		unstyled,
		attributes,
		vars,
		varsResolver
	});
	const hasLeftSection = !!leftSection;
	const hasRightSection = !!rightSection;
	return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_UnstyledButton.UnstyledButton, {
		...getStyles("root", { active: !disabled && !loading && !dataDisabled }),
		unstyled,
		variant,
		disabled: disabled || loading,
		mod: [{
			disabled: disabled || dataDisabled,
			loading,
			block: fullWidth,
			"with-left-section": hasLeftSection,
			"with-right-section": hasRightSection
		}, mod],
		...others,
		children: [typeof loading === "boolean" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Transition.Transition, {
			mounted: loading,
			transition: loaderTransition,
			duration: 150,
			children: (transitionStyles) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
				component: "span",
				...getStyles("loader", { style: transitionStyles }),
				"aria-hidden": true,
				children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Loader.Loader, {
					color: "var(--button-color)",
					size: "calc(var(--button-height) / 1.8)",
					...loaderProps
				})
			})
		}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
			...getStyles("inner"),
			children: [
				leftSection && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
					component: "span",
					...getStyles("section"),
					mod: { position: "left" },
					children: leftSection
				}),
				/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
					component: "span",
					mod: { loading },
					...getStyles("label"),
					children
				}),
				rightSection && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
					component: "span",
					...getStyles("section"),
					mod: { position: "right" },
					children: rightSection
				})
			]
		})]
	});
});
Button.classes = require_Button_module.default;
Button.varsResolver = varsResolver;
Button.displayName = "@mantine/core/Button";
Button.Group = require_ButtonGroup.ButtonGroup;
Button.GroupSection = require_ButtonGroupSection.ButtonGroupSection;
//#endregion
exports.Button = Button;

//# sourceMappingURL=Button.cjs.map