"use client";
const require_keys = require("../../core/utils/keys/keys.cjs");
const require_px = require("../../core/utils/units-converters/px.cjs");
const require_rem = require("../../core/utils/units-converters/rem.cjs");
const require_filter_props = require("../../core/utils/filter-props/filter-props.cjs");
const require_get_size = require("../../core/utils/get-size/get-size.cjs");
const require_get_sorted_breakpoints = require("../../core/utils/get-sorted-breakpoints/get-sorted-breakpoints.cjs");
const require_get_base_value = require("../../core/utils/get-base-value/get-base-value.cjs");
const require_MantineThemeProvider = require("../../core/MantineProvider/MantineThemeProvider/MantineThemeProvider.cjs");
const require_InlineStyles = require("../../core/InlineStyles/InlineStyles.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/SimpleGrid/SimpleGridVariables.tsx
function getMinColWidthValue(value) {
	if (value === void 0) return;
	if (typeof value === "number") return require_rem.rem(value);
	return value;
}
function SimpleGridMediaVariables({ spacing, verticalSpacing, cols, minColWidth, autoRows, selector }) {
	const theme = require_MantineThemeProvider.useMantineTheme();
	const _verticalSpacing = verticalSpacing === void 0 ? spacing : verticalSpacing;
	const useAutoColumns = minColWidth !== void 0;
	const baseStyles = require_filter_props.filterProps({
		"--sg-spacing-x": require_get_size.getSpacing(require_get_base_value.getBaseValue(spacing)),
		"--sg-spacing-y": require_get_size.getSpacing(require_get_base_value.getBaseValue(_verticalSpacing)),
		"--sg-auto-rows": autoRows,
		...useAutoColumns ? { "--sg-min-col-width": getMinColWidthValue(minColWidth) } : { "--sg-cols": require_get_base_value.getBaseValue(cols)?.toString() }
	});
	const queries = require_keys.keys(theme.breakpoints).reduce((acc, breakpoint) => {
		if (!acc[breakpoint]) acc[breakpoint] = {};
		if (typeof spacing === "object" && spacing[breakpoint] !== void 0) acc[breakpoint]["--sg-spacing-x"] = require_get_size.getSpacing(spacing[breakpoint]);
		if (typeof _verticalSpacing === "object" && _verticalSpacing[breakpoint] !== void 0) acc[breakpoint]["--sg-spacing-y"] = require_get_size.getSpacing(_verticalSpacing[breakpoint]);
		if (!useAutoColumns && typeof cols === "object" && cols[breakpoint] !== void 0) acc[breakpoint]["--sg-cols"] = cols[breakpoint];
		return acc;
	}, {});
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_InlineStyles.InlineStyles, {
		styles: baseStyles,
		media: require_get_sorted_breakpoints.getSortedBreakpoints(require_keys.keys(queries), theme.breakpoints).filter((breakpoint) => require_keys.keys(queries[breakpoint.value]).length > 0).map((breakpoint) => ({
			query: `(min-width: ${theme.breakpoints[breakpoint.value]})`,
			styles: queries[breakpoint.value]
		})),
		selector
	});
}
function getBreakpoints(values) {
	if (typeof values === "object" && values !== null) return require_keys.keys(values);
	return [];
}
function sortBreakpoints(breakpoints) {
	return breakpoints.sort((a, b) => require_px.px(a) - require_px.px(b));
}
function getUniqueBreakpoints({ spacing, verticalSpacing, cols, minColWidth }) {
	return sortBreakpoints(Array.from(new Set([
		...getBreakpoints(spacing),
		...getBreakpoints(verticalSpacing),
		...minColWidth !== void 0 ? [] : getBreakpoints(cols)
	])));
}
function SimpleGridContainerVariables({ spacing, verticalSpacing, cols, minColWidth, autoRows, selector }) {
	const _verticalSpacing = verticalSpacing === void 0 ? spacing : verticalSpacing;
	const useAutoColumns = minColWidth !== void 0;
	const baseStyles = require_filter_props.filterProps({
		"--sg-spacing-x": require_get_size.getSpacing(require_get_base_value.getBaseValue(spacing)),
		"--sg-spacing-y": require_get_size.getSpacing(require_get_base_value.getBaseValue(_verticalSpacing)),
		"--sg-auto-rows": autoRows,
		...useAutoColumns ? { "--sg-min-col-width": getMinColWidthValue(minColWidth) } : { "--sg-cols": require_get_base_value.getBaseValue(cols)?.toString() }
	});
	const uniqueBreakpoints = getUniqueBreakpoints({
		spacing,
		verticalSpacing,
		cols,
		minColWidth
	});
	const queries = uniqueBreakpoints.reduce((acc, breakpoint) => {
		if (!acc[breakpoint]) acc[breakpoint] = {};
		if (typeof spacing === "object" && spacing[breakpoint] !== void 0) acc[breakpoint]["--sg-spacing-x"] = require_get_size.getSpacing(spacing[breakpoint]);
		if (typeof _verticalSpacing === "object" && _verticalSpacing[breakpoint] !== void 0) acc[breakpoint]["--sg-spacing-y"] = require_get_size.getSpacing(_verticalSpacing[breakpoint]);
		if (!useAutoColumns && typeof cols === "object" && cols[breakpoint] !== void 0) acc[breakpoint]["--sg-cols"] = cols[breakpoint];
		return acc;
	}, {});
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_InlineStyles.InlineStyles, {
		styles: baseStyles,
		container: uniqueBreakpoints.map((breakpoint) => ({
			query: `simple-grid (min-width: ${breakpoint})`,
			styles: queries[breakpoint]
		})),
		selector
	});
}
//#endregion
exports.SimpleGridContainerVariables = SimpleGridContainerVariables;
exports.SimpleGridMediaVariables = SimpleGridMediaVariables;

//# sourceMappingURL=SimpleGridVariables.cjs.map