"use client";
const require_rem = require("../../core/utils/units-converters/rem.cjs");
const require_noop = require("../../core/utils/noop/noop.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_factory = require("../../core/factory/factory.cjs");
const require_Box = require("../../core/Box/Box.cjs");
const require_UnstyledButton = require("../UnstyledButton/UnstyledButton.cjs");
const require_TableOfContents_module = require("./TableOfContents.module.cjs");
let _mantine_hooks = require("@mantine/hooks");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/TableOfContents/TableOfContents.tsx
const defaultProps = { getControlProps: ({ data }) => ({ children: data.value }) };
const varsResolver = require_create_vars_resolver.createVarsResolver((theme, { color, size, variant, autoContrast, depthOffset, radius }) => {
	const colors = theme.variantColorResolver({
		color: color || theme.primaryColor,
		theme,
		variant: variant || "filled",
		autoContrast
	});
	return { root: {
		"--toc-bg": variant !== "none" ? colors.background : void 0,
		"--toc-color": variant !== "none" ? colors.color : void 0,
		"--toc-size": require_get_size.getFontSize(size),
		"--toc-depth-offset": require_rem.rem(depthOffset),
		"--toc-radius": require_get_size.getRadius(radius)
	} };
});
const TableOfContents = require_factory.factory((_props) => {
	const props = require_use_props.useProps("TableOfContents", defaultProps, _props);
	const { classNames, className, style, styles, unstyled, vars, color, autoContrast, scrollSpyOptions, initialData, getControlProps, minDepthToOffset, depthOffset, variant, radius, reinitializeRef, attributes, ...others } = props;
	const getStyles = require_use_styles.useStyles({
		name: "TableOfContents",
		classes: require_TableOfContents_module.default,
		props,
		className,
		style,
		classNames,
		styles,
		unstyled,
		attributes,
		vars,
		varsResolver
	});
	const idBase = (0, _mantine_hooks.useId)();
	const spy = (0, _mantine_hooks.useScrollSpy)(scrollSpyOptions);
	(0, _mantine_hooks.assignRef)(reinitializeRef, spy.reinitialize);
	const controls = (spy.initialized ? spy.data : initialData || []).map((data, index) => {
		const controlProps = getControlProps?.({
			active: index === spy.active,
			data: {
				...data,
				getNode: data.getNode || require_noop.noop
			}
		});
		return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_UnstyledButton.UnstyledButton, {
			__vars: { "--depth-offset": `${data.depth - (minDepthToOffset || 1)}` },
			"data-active": index === spy.active || void 0,
			variant,
			...controlProps,
			...getStyles("control", {
				className: controlProps?.className,
				style: controlProps?.style
			})
		}, data.id || `${idBase}-${index}`);
	});
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
		variant,
		...getStyles("root"),
		...others,
		children: controls
	});
});
TableOfContents.displayName = "@mantine/core/TableOfContents";
TableOfContents.classes = require_TableOfContents_module.default;
TableOfContents.varsResolver = varsResolver;
//#endregion
exports.TableOfContents = TableOfContents;

//# sourceMappingURL=TableOfContents.cjs.map