"use client";
import { getSpacing } from "../../core/utils/get-size/get-size.mjs";
import { createVarsResolver } from "../../core/styles-api/create-vars-resolver/create-vars-resolver.mjs";
import { useProps } from "../../core/MantineProvider/use-props/use-props.mjs";
import { useStyles } from "../../core/styles-api/use-styles/use-styles.mjs";
import { polymorphicFactory } from "../../core/factory/polymorphic-factory.mjs";
import { Paper } from "../Paper/Paper.mjs";
import { CardProvider } from "./Card.context.mjs";
import Card_module_default from "./Card.module.mjs";
import { CardSection } from "./CardSection/CardSection.mjs";
import { Children, cloneElement } from "react";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/Card/Card.tsx
const varsResolver = createVarsResolver((_, { padding }) => ({ root: { "--card-padding": getSpacing(padding) } }));
const defaultProps = { orientation: "vertical" };
const Card = polymorphicFactory((_props) => {
	const props = useProps("Card", defaultProps, _props);
	const { classNames, className, style, styles, unstyled, vars, children, padding, attributes, orientation, ...others } = props;
	const getStyles = useStyles({
		name: "Card",
		props,
		classes: Card_module_default,
		className,
		style,
		classNames,
		styles,
		unstyled,
		attributes,
		vars,
		varsResolver
	});
	const _children = Children.toArray(children);
	const content = _children.map((child, index) => {
		if (typeof child === "object" && child && "type" in child && (child.type === CardSection || child.type?.displayName === "@mantine/core/CardSection")) return cloneElement(child, {
			"data-orientation": orientation,
			"data-first-section": index === 0 || void 0,
			"data-last-section": index === _children.length - 1 || void 0
		});
		return child;
	});
	return /* @__PURE__ */ jsx(CardProvider, {
		value: { getStyles },
		children: /* @__PURE__ */ jsx(Paper, {
			unstyled,
			"data-orientation": orientation,
			...getStyles("root"),
			...others,
			children: content
		})
	});
});
Card.classes = Card_module_default;
Card.varsResolver = varsResolver;
Card.displayName = "@mantine/core/Card";
Card.Section = CardSection;
//#endregion
export { Card };

//# sourceMappingURL=Card.mjs.map