import { isDevelopment } from "../../../utilities/env.mjs";
import isValueSelected from "../../../utilities/isValueSelected.mjs";
import { c } from "react-compiler-runtime";
import React, { Children, cloneElement, forwardRef, isValidElement } from "react";
import clsx from "clsx";
import PropTypes from "prop-types";
import { makeStyles } from "@material-ui/core/styles";
import { isFragment } from "react-is";
import { capitalize } from "@material-ui/core/utils";
//#region src/UI/inputs/buttons/AmbientToggleButtonGroup.jsx
const useStyles = makeStyles((theme) => ({
	item: { marginRight: 8 },
	root: {
		display: "inline-flex",
		padding: 0
	},
	vertical: { flexDirection: "column" },
	grouped: {},
	groupedHorizontal: {
		borderRadius: 25,
		padding: 0,
		paddingRight: 16,
		"&:not(:first-child)": {
			marginTop: 16,
			borderRadius: 25,
			paddingRight: 16,
			padding: 0
		},
		"&:not(:last-child)": {
			padding: 0,
			borderRadius: 25,
			paddingRight: 16
		}
	}
}));
const AmbientToggleButtonGroup = forwardRef(function AmbientToggleButton(props, ref) {
	const $ = c(42);
	let children;
	let className;
	let onChange;
	let other;
	let t0;
	let t1;
	let t2;
	let value;
	if ($[0] !== props) {
		({children, className, exclusive: t0, onChange, orientation: t1, size: t2, value, ...other} = props);
		$[0] = props;
		$[1] = children;
		$[2] = className;
		$[3] = onChange;
		$[4] = other;
		$[5] = t0;
		$[6] = t1;
		$[7] = t2;
		$[8] = value;
	} else {
		children = $[1];
		className = $[2];
		onChange = $[3];
		other = $[4];
		t0 = $[5];
		t1 = $[6];
		t2 = $[7];
		value = $[8];
	}
	const exclusive = t0 === void 0 ? false : t0;
	const orientation = t1 === void 0 ? "horizontal" : t1;
	const size = t2 === void 0 ? "medium" : t2;
	const classes = useStyles();
	let t3;
	if ($[9] !== onChange || $[10] !== value) {
		t3 = (event, buttonValue) => {
			if (!onChange) return;
			const index = value && value.indexOf(buttonValue);
			let newValue;
			if (value && index >= 0) {
				newValue = value.slice();
				newValue.splice(index, 1);
			} else newValue = value ? value.concat(buttonValue) : [buttonValue];
			onChange(event, newValue);
		};
		$[9] = onChange;
		$[10] = value;
		$[11] = t3;
	} else t3 = $[11];
	const handleChange = t3;
	let t4;
	if ($[12] !== onChange || $[13] !== value) {
		t4 = (event_0, buttonValue_0) => {
			if (!onChange) return;
			onChange(event_0, value === buttonValue_0 ? null : buttonValue_0);
		};
		$[12] = onChange;
		$[13] = value;
		$[14] = t4;
	} else t4 = $[14];
	const handleExclusiveChange = t4;
	const t5 = orientation === "vertical";
	let t6;
	if ($[15] !== className || $[16] !== classes.root || $[17] !== classes.vertical || $[18] !== t5) {
		t6 = clsx(classes.root, { [classes.vertical]: t5 }, className);
		$[15] = className;
		$[16] = classes.root;
		$[17] = classes.vertical;
		$[18] = t5;
		$[19] = t6;
	} else t6 = $[19];
	let t7;
	if ($[20] !== children || $[21] !== classes || $[22] !== exclusive || $[23] !== handleChange || $[24] !== handleExclusiveChange || $[25] !== orientation || $[26] !== size || $[27] !== value) {
		let t8;
		if ($[29] !== classes || $[30] !== exclusive || $[31] !== handleChange || $[32] !== handleExclusiveChange || $[33] !== orientation || $[34] !== size || $[35] !== value) {
			t8 = (child) => {
				if (!isValidElement(child)) return null;
				if (isDevelopment()) {
					if (isFragment(child)) console.error(["Material-UI: The ToggleButtonGroup component doesn't accept a Fragment as a child.", "Consider providing an array instead."].join("\n"));
				}
				return cloneElement(child, {
					className: clsx(classes.grouped, classes[`grouped${capitalize(orientation)}`], child.props.className),
					onChange: exclusive ? handleExclusiveChange : handleChange,
					selected: child.props.selected === void 0 ? isValueSelected(child.props.value, value) : child.props.selected,
					size: child.props.size || size
				});
			};
			$[29] = classes;
			$[30] = exclusive;
			$[31] = handleChange;
			$[32] = handleExclusiveChange;
			$[33] = orientation;
			$[34] = size;
			$[35] = value;
			$[36] = t8;
		} else t8 = $[36];
		t7 = Children.map(children, t8);
		$[20] = children;
		$[21] = classes;
		$[22] = exclusive;
		$[23] = handleChange;
		$[24] = handleExclusiveChange;
		$[25] = orientation;
		$[26] = size;
		$[27] = value;
		$[28] = t7;
	} else t7 = $[28];
	let t8;
	if ($[37] !== other || $[38] !== ref || $[39] !== t6 || $[40] !== t7) {
		t8 = /* @__PURE__ */ React.createElement("div", {
			role: "group",
			className: t6,
			ref,
			...other
		}, t7);
		$[37] = other;
		$[38] = ref;
		$[39] = t6;
		$[40] = t7;
		$[41] = t8;
	} else t8 = $[41];
	return t8;
});
AmbientToggleButtonGroup.propTypes = {
	children: PropTypes.node,
	classes: PropTypes.object,
	className: PropTypes.string,
	exclusive: PropTypes.bool,
	onChange: PropTypes.func,
	orientation: PropTypes.oneOf(["horizontal", "vertical"]),
	size: PropTypes.oneOf([
		"large",
		"medium",
		"small"
	]),
	value: PropTypes.any
};
//#endregion
export { AmbientToggleButtonGroup };

//# sourceMappingURL=AmbientToggleButtonGroup.mjs.map