/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_settings = require("../../settings.js");
const require_UserProfileImage = require("../UserProfileImage/UserProfileImage.js");
let react = require("react");
react = require_runtime.__toESM(react);
let prop_types = require("prop-types");
prop_types = require_runtime.__toESM(prop_types);
let _carbon_react_icons = require("@carbon/react/icons");
//#region src/components/AddSelect/AddSelectFormControl.jsx
/**
* Copyright IBM Corp. 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
const componentName = "AddSelectFormControl";
const blockClass = `${require_settings.pkg.prefix}--add-select__selections`;
let AddSelectFormControl = ({ item, onClick, selected, type }) => {
	const controlProps = {
		onClick,
		className: `${blockClass}-form-control-wrapper ${blockClass}-form-control-wrapper--${type}`,
		size: 20,
		[`aria-labelledby`]: `control-label-${item.id}`
	};
	const getCheckbox = () => {
		if (selected) return /* @__PURE__ */ react.default.createElement(_carbon_react_icons.CheckboxCheckedFilled, controlProps);
		return /* @__PURE__ */ react.default.createElement(_carbon_react_icons.Checkbox, controlProps);
	};
	const getRadio = () => {
		if (selected) return /* @__PURE__ */ react.default.createElement(_carbon_react_icons.RadioButtonChecked, controlProps);
		return /* @__PURE__ */ react.default.createElement(_carbon_react_icons.RadioButton, controlProps);
	};
	const getFormControl = () => {
		if (!item) return;
		if (type === "checkbox") return getCheckbox();
		else return getRadio();
	};
	const getAvatarProps = ({ src, alt, icon, backgroundColor, theme }) => ({
		className: `${blockClass}-cell-avatar`,
		size: "lg",
		theme,
		image: src,
		imageDescription: alt,
		icon,
		backgroundColor
	});
	const getItemIcon = ({ icon: Icon }) => /* @__PURE__ */ react.default.createElement(Icon, null);
	return /* @__PURE__ */ react.default.createElement("div", { className: `${blockClass}-form-control` }, getFormControl(), /* @__PURE__ */ react.default.createElement("div", { className: `${blockClass}-form-control-label-wrapper` }, item.avatar && /* @__PURE__ */ react.default.createElement(require_UserProfileImage.UserProfileImage, getAvatarProps(item.avatar)), item.icon && /* @__PURE__ */ react.default.createElement("div", { className: `${blockClass}-cell-icon` }, getItemIcon(item)), /* @__PURE__ */ react.default.createElement("div", { className: `${blockClass}-form-control-label-text` }, /* @__PURE__ */ react.default.createElement("span", {
		className: `${blockClass}-cell-title`,
		id: `control-label-${item.id}`
	}, item.title), item.subtitle && /* @__PURE__ */ react.default.createElement("span", { className: `${blockClass}-cell-subtitle` }, item.subtitle))));
};
AddSelectFormControl.propTypes = {
	item: prop_types.default.object,
	onClick: prop_types.default.func,
	selected: prop_types.default.bool,
	type: prop_types.default.oneOf(["checkbox", "radio"])
};
AddSelectFormControl.displayName = componentName;
//#endregion
exports.AddSelectFormControl = AddSelectFormControl;
