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 { withStyles } from "@material-ui/core/styles";
import { isFragment } from "react-is";
import { capitalize } from "@material-ui/core/utils";
//#region src/UI/inputs/buttons/AmbientToggleButtonGroupDefault.jsx
const styles = (theme) => ({
	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
		}
	},
	groupedVertical: {
		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 AmbientToggleButtonGroupDefault = forwardRef(function AmbientToggleButton(props, ref) {
	const $ = c(43);
	let children;
	let className;
	let classes;
	let onChange;
	let other;
	let t0;
	let t1;
	let t2;
	let value;
	if ($[0] !== props) {
		({children, classes, className, exclusive: t0, onChange, orientation: t1, size: t2, value, ...other} = props);
		$[0] = props;
		$[1] = children;
		$[2] = className;
		$[3] = classes;
		$[4] = onChange;
		$[5] = other;
		$[6] = t0;
		$[7] = t1;
		$[8] = t2;
		$[9] = value;
	} else {
		children = $[1];
		className = $[2];
		classes = $[3];
		onChange = $[4];
		other = $[5];
		t0 = $[6];
		t1 = $[7];
		t2 = $[8];
		value = $[9];
	}
	const exclusive = t0 === void 0 ? false : t0;
	const orientation = t1 === void 0 ? "horizontal" : t1;
	const size = t2 === void 0 ? "medium" : t2;
	let t3;
	if ($[10] !== onChange || $[11] !== 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);
		};
		$[10] = onChange;
		$[11] = value;
		$[12] = t3;
	} else t3 = $[12];
	const handleChange = t3;
	let t4;
	if ($[13] !== onChange || $[14] !== value) {
		t4 = (event_0, buttonValue_0) => {
			if (!onChange) return;
			onChange(event_0, value === buttonValue_0 ? null : buttonValue_0);
		};
		$[13] = onChange;
		$[14] = value;
		$[15] = t4;
	} else t4 = $[15];
	const handleExclusiveChange = t4;
	const t5 = orientation === "vertical";
	let t6;
	if ($[16] !== className || $[17] !== classes.root || $[18] !== classes.vertical || $[19] !== t5) {
		t6 = clsx(classes.root, { [classes.vertical]: t5 }, className);
		$[16] = className;
		$[17] = classes.root;
		$[18] = classes.vertical;
		$[19] = t5;
		$[20] = t6;
	} else t6 = $[20];
	let t7;
	if ($[21] !== children || $[22] !== classes || $[23] !== exclusive || $[24] !== handleChange || $[25] !== handleExclusiveChange || $[26] !== orientation || $[27] !== size || $[28] !== value) {
		let t8;
		if ($[30] !== classes || $[31] !== exclusive || $[32] !== handleChange || $[33] !== handleExclusiveChange || $[34] !== orientation || $[35] !== size || $[36] !== 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
				});
			};
			$[30] = classes;
			$[31] = exclusive;
			$[32] = handleChange;
			$[33] = handleExclusiveChange;
			$[34] = orientation;
			$[35] = size;
			$[36] = value;
			$[37] = t8;
		} else t8 = $[37];
		t7 = Children.map(children, t8);
		$[21] = children;
		$[22] = classes;
		$[23] = exclusive;
		$[24] = handleChange;
		$[25] = handleExclusiveChange;
		$[26] = orientation;
		$[27] = size;
		$[28] = value;
		$[29] = t7;
	} else t7 = $[29];
	let t8;
	if ($[38] !== other || $[39] !== ref || $[40] !== t6 || $[41] !== t7) {
		t8 = /* @__PURE__ */ React.createElement("div", {
			role: "group",
			className: t6,
			ref,
			...other
		}, t7);
		$[38] = other;
		$[39] = ref;
		$[40] = t6;
		$[41] = t7;
		$[42] = t8;
	} else t8 = $[42];
	return t8;
});
AmbientToggleButtonGroupDefault.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
};
/**
* Explicitly cast the HOC to any to avoid non-portable inferred React types in declaration output.
* @type {any}
*/
const AmbientToggleButtonGroupDefaultExport = withStyles(styles, { name: "MuiToggleButtonGroup" })(AmbientToggleButtonGroupDefault);
//#endregion
export { AmbientToggleButtonGroupDefaultExport as default };

//# sourceMappingURL=AmbientToggleButtonGroupDefault.mjs.map