"use client";
import { rem } from "../../core/utils/units-converters/rem.mjs";
import { getRadius } from "../../core/utils/get-size/get-size.mjs";
import { createVarsResolver } from "../../core/styles-api/create-vars-resolver/create-vars-resolver.mjs";
import { getThemeColor } from "../../core/MantineProvider/color-functions/get-theme-color/get-theme-color.mjs";
import { getContrastColor } from "../../core/MantineProvider/color-functions/get-contrast-color/get-contrast-color.mjs";
import { getAutoContrastValue } from "../../core/MantineProvider/color-functions/get-auto-contrast-value/get-auto-contrast-value.mjs";
import { useProps } from "../../core/MantineProvider/use-props/use-props.mjs";
import { useStyles } from "../../core/styles-api/use-styles/use-styles.mjs";
import { factory } from "../../core/factory/factory.mjs";
import { Box } from "../../core/Box/Box.mjs";
import { TimelineProvider } from "./Timeline.context.mjs";
import Timeline_module_default from "./Timeline.module.mjs";
import { TimelineItem } from "./TimelineItem/TimelineItem.mjs";
import { Children, cloneElement } from "react";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/Timeline/Timeline.tsx
const defaultProps = {
	active: -1,
	align: "left"
};
const varsResolver = createVarsResolver((theme, { bulletSize, lineWidth, radius, color, autoContrast }) => ({ root: {
	"--tl-bullet-size": rem(bulletSize),
	"--tl-line-width": rem(lineWidth),
	"--tl-radius": radius === void 0 ? void 0 : getRadius(radius),
	"--tl-color": color ? getThemeColor(color, theme) : void 0,
	"--tl-icon-color": getAutoContrastValue(autoContrast, theme) ? getContrastColor({
		color,
		theme,
		autoContrast
	}) : void 0
} }));
const Timeline = factory((_props) => {
	const props = useProps("Timeline", defaultProps, _props);
	const { classNames, className, style, styles, unstyled, vars, children, active, color, radius, bulletSize, align, lineWidth, reverseActive, mod, autoContrast, attributes, ...others } = props;
	const getStyles = useStyles({
		name: "Timeline",
		classes: Timeline_module_default,
		props,
		className,
		style,
		classNames,
		styles,
		unstyled,
		attributes,
		vars,
		varsResolver
	});
	const _children = Children.toArray(children);
	const items = _children.map((item, index) => cloneElement(item, {
		unstyled,
		__align: align,
		__active: item.props?.active || (reverseActive ? active >= _children.length - index - 1 : active >= index),
		__lineActive: item.props?.lineActive || (reverseActive ? active >= _children.length - index - 1 : active - 1 >= index)
	}));
	return /* @__PURE__ */ jsx(TimelineProvider, {
		value: { getStyles },
		children: /* @__PURE__ */ jsx(Box, {
			...getStyles("root"),
			mod: [{ align }, mod],
			...others,
			children: items
		})
	});
});
Timeline.classes = Timeline_module_default;
Timeline.varsResolver = varsResolver;
Timeline.displayName = "@mantine/core/Timeline";
Timeline.Item = TimelineItem;
//#endregion
export { Timeline };

//# sourceMappingURL=Timeline.mjs.map