/**
 * 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.
 */

import { pkg } from "../../settings.js";
import React, { isValidElement } from "react";
import PropTypes from "prop-types";
import { Button } from "@carbon/react";
import { Close } from "@carbon/react/icons";

//#region src/components/AddSelect/AddSelectMetaPanel.jsx
const blockClass = `${pkg.prefix}--add-select__meta-panel`;
const componentName = "AddSelectMetaPanel";
let AddSelectMetaPanel = ({ closeIconDescription, meta, setDisplayMetaPanel, title }) => {
	const onCloseHandler = () => {
		setDisplayMetaPanel({});
	};
	return /* @__PURE__ */ React.createElement("div", { className: blockClass }, /* @__PURE__ */ React.createElement("div", { className: `${blockClass}-header` }, /* @__PURE__ */ React.createElement("p", { className: `${blockClass}-title` }, title), /* @__PURE__ */ React.createElement(Button, {
		renderIcon: (props) => /* @__PURE__ */ React.createElement(Close, {
			size: 16,
			...props
		}),
		className: `${blockClass}-close`,
		iconDescription: closeIconDescription,
		tooltipPosition: "left",
		tooltipAlignment: "center",
		hasIconOnly: true,
		onClick: onCloseHandler,
		kind: "ghost",
		size: "sm"
	})), isValidElement(meta) ? meta : meta.map((entry) => /* @__PURE__ */ React.createElement("div", {
		key: entry?.id,
		className: `${blockClass}-entry`
	}, /* @__PURE__ */ React.createElement("p", { className: `${blockClass}-entry-title` }, entry?.title), /* @__PURE__ */ React.createElement("p", { className: `${blockClass}-entry-body` }, entry?.value))));
};
AddSelectMetaPanel.propTypes = {
	closeIconDescription: PropTypes.string.isRequired,
	meta: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.shape({
		id: PropTypes.string,
		title: PropTypes.string,
		value: PropTypes.string
	})), PropTypes.node]).isRequired,
	setDisplayMetaPanel: PropTypes.func.isRequired,
	title: PropTypes.string.isRequired
};
AddSelectMetaPanel.displayName = componentName;

//#endregion
export { AddSelectMetaPanel };