"use client";
const require_rem = require("../../core/utils/units-converters/rem.cjs");
const require_get_safe_id = require("../../core/utils/get-safe-id/get-safe-id.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_Accordion_context = require("./Accordion.context.cjs");
const require_AccordionChevron = require("./AccordionChevron.cjs");
const require_Accordion_module = require("./Accordion.module.cjs");
const require_AccordionControl = require("./AccordionControl/AccordionControl.cjs");
const require_AccordionItem = require("./AccordionItem/AccordionItem.cjs");
const require_AccordionPanel = require("./AccordionPanel/AccordionPanel.cjs");
let _mantine_hooks = require("@mantine/hooks");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/Accordion/Accordion.tsx
const defaultProps = {
	multiple: false,
	disableChevronRotation: false,
	chevronPosition: "right",
	variant: "default",
	chevronSize: "auto",
	chevronIconSize: 16
};
const varsResolver = require_create_vars_resolver.createVarsResolver((_, { transitionDuration, chevronSize, radius }) => ({ root: {
	"--accordion-transition-duration": transitionDuration === void 0 ? void 0 : `${transitionDuration}ms`,
	"--accordion-chevron-size": chevronSize === void 0 ? void 0 : require_rem.rem(chevronSize),
	"--accordion-radius": radius === void 0 ? void 0 : require_get_size.getRadius(radius)
} }));
const Accordion = require_factory.genericFactory((_props) => {
	const props = require_use_props.useProps("Accordion", defaultProps, _props);
	const { classNames, className, style, styles, unstyled, vars, children, multiple, value, defaultValue, onChange, id, loop, transitionDuration, disableChevronRotation, chevronPosition, chevronSize, order, chevron, variant, radius, chevronIconSize, attributes, keepMounted, ...others } = props;
	const uid = (0, _mantine_hooks.useId)(id);
	const [_value, handleChange] = (0, _mantine_hooks.useUncontrolled)({
		value,
		defaultValue,
		finalValue: multiple ? [] : null,
		onChange
	});
	const isItemActive = (itemValue) => Array.isArray(_value) ? _value.includes(itemValue) : itemValue === _value;
	const handleItemChange = (itemValue) => {
		handleChange(Array.isArray(_value) ? _value.includes(itemValue) ? _value.filter((selectedValue) => selectedValue !== itemValue) : [..._value, itemValue] : itemValue === _value ? null : itemValue);
	};
	const getStyles = require_use_styles.useStyles({
		name: "Accordion",
		classes: require_Accordion_module.default,
		props,
		className,
		style,
		classNames,
		styles,
		unstyled,
		attributes,
		vars,
		varsResolver
	});
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Accordion_context.AccordionProvider, {
		value: {
			isItemActive,
			onChange: handleItemChange,
			getControlId: require_get_safe_id.getSafeId(`${uid}-control`, "Accordion.Item component was rendered with invalid value or without value"),
			getRegionId: require_get_safe_id.getSafeId(`${uid}-panel`, "Accordion.Item component was rendered with invalid value or without value"),
			chevron: chevron === null ? null : chevron || /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_AccordionChevron.AccordionChevron, { size: chevronIconSize }),
			transitionDuration,
			disableChevronRotation,
			chevronPosition,
			order,
			loop,
			getStyles,
			variant,
			unstyled,
			keepMounted
		},
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
			...getStyles("root"),
			id: uid,
			...others,
			variant,
			"data-accordion": true,
			children
		})
	});
});
Accordion.classes = require_Accordion_module.default;
Accordion.varsResolver = varsResolver;
Accordion.displayName = "@mantine/core/Accordion";
Accordion.Item = require_AccordionItem.AccordionItem;
Accordion.Panel = require_AccordionPanel.AccordionPanel;
Accordion.Control = require_AccordionControl.AccordionControl;
Accordion.Chevron = require_AccordionChevron.AccordionChevron;
//#endregion
exports.Accordion = Accordion;

//# sourceMappingURL=Accordion.cjs.map