/**
 * 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_index = require('../../../node_modules/classnames/index.js');
const require_util = require('../utils/util.js');
const require_useTranslations = require('../utils/useTranslations.js');
const require_ConditionBuilderItem = require('../ConditionBuilderItem/ConditionBuilderItem.js');
const require_ConditionConnector = require('../ConditionBuilderConnector/ConditionConnector.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/ConditionBuilder/ConditionPreview/ConditionPreview.tsx
/**
* 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.
*/
var import_classnames = /* @__PURE__ */ require_runtime.__toESM(require_index.default);
const ConditionPreview = ({ previewType, group, colorIndex, className }) => {
	const [animate, setAnimate] = (0, react.useState)(false);
	const [propertyText, operatorText, valueText, ifText] = require_useTranslations.useTranslations([
		"valueText",
		"operatorText",
		"propertyText",
		"ifText"
	]);
	(0, react.useEffect)(() => {
		setAnimate(true);
	}, []);
	const getConditionSection = () => {
		return /* @__PURE__ */ react.default.createElement("div", { className: `${require_util.blockClass}__preview-condition` }, /* @__PURE__ */ react.default.createElement(require_ConditionBuilderItem.ConditionBuilderItem, {
			label: propertyText,
			renderIcon: _carbon_react_icons.Bee
		}), /* @__PURE__ */ react.default.createElement(require_ConditionBuilderItem.ConditionBuilderItem, { label: operatorText }), /* @__PURE__ */ react.default.createElement(require_ConditionBuilderItem.ConditionBuilderItem, { label: valueText }));
	};
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, previewType == "newGroup" && /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: (0, import_classnames.default)([`${require_util.blockClass}__group__row ${require_util.blockClass}__group-preview ${className}`, { [`${require_util.blockClass}__group-preview-animate`]: animate }]) }, /* @__PURE__ */ react.default.createElement(require_ConditionBuilderItem.ConditionBuilderItem, {
		className: `${require_util.blockClass}__statement-button`,
		label: group.groupOperator
	})), /* @__PURE__ */ react.default.createElement("div", {
		"data-color-index": colorIndex,
		"aria-hidden": true,
		className: (0, import_classnames.default)([`${require_util.blockClass}__group  ${require_util.blockClass}__condition-wrapper ${require_util.blockClass}__group-preview ${require_util.blockClass}__group-wrapper ${className}`, { [`${require_util.blockClass}__group-preview-animate`]: animate }])
	}, /* @__PURE__ */ react.default.createElement("div", { className: `${require_util.blockClass}__gap` }, /* @__PURE__ */ react.default.createElement(require_ConditionBuilderItem.ConditionBuilderItem, {
		className: `${require_util.blockClass}__statement-button`,
		label: ifText
	})), getConditionSection())), previewType == "subGroup" && /* @__PURE__ */ react.default.createElement("div", { className: (0, import_classnames.default)([`${require_util.blockClass}__group__row ${require_util.blockClass}__group-preview ${require_util.blockClass}__gap-bottom`, { [`${require_util.blockClass}__group-preview-animate`]: animate }]) }, /* @__PURE__ */ react.default.createElement("div", { className: `${require_util.blockClass}__condition-block  ${require_util.blockClass}__gap` }, /* @__PURE__ */ react.default.createElement(require_ConditionBuilderItem.ConditionBuilderItem, {
		label: group.groupOperator,
		className: `${require_util.blockClass}__statement-button`,
		popOverClassName: `${require_util.blockClass}__gap`
	}), /* @__PURE__ */ react.default.createElement("div", { className: `${require_util.blockClass}__group ${require_util.blockClass}__condition-wrapper` }, /* @__PURE__ */ react.default.createElement(require_ConditionConnector.default, {
		className: `${require_util.blockClass}__gap ${require_util.blockClass}__groupConnector`,
		operator: ifText
	}), getConditionSection()))), previewType == "condition" && /* @__PURE__ */ react.default.createElement("div", { className: (0, import_classnames.default)([`${require_util.blockClass}__group__row ${require_util.blockClass}__group-preview ${require_util.blockClass}__gap-bottom`, { [`${require_util.blockClass}__group-preview-animate`]: animate }]) }, /* @__PURE__ */ react.default.createElement("div", { className: `${require_util.blockClass}__condition-block  ${require_util.blockClass}__gap` }, /* @__PURE__ */ react.default.createElement(require_ConditionBuilderItem.ConditionBuilderItem, {
		label: group.groupOperator,
		className: `${require_util.blockClass}__statement-button`,
		popOverClassName: `${require_util.blockClass}__gap`
	}), getConditionSection())));
};
ConditionPreview.propTypes = {
	className: prop_types.default.string,
	colorIndex: prop_types.default.number,
	group: prop_types.default.object,
	previewType: prop_types.default.oneOf([
		"condition",
		"subGroup",
		"newGroup"
	])
};

//#endregion
exports.default = ConditionPreview;