/**
 * 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 { __toESM } from "../../../_virtual/_rolldown/runtime.js";
import { require_classnames } from "../../../node_modules/classnames/index.js";
import { blockClass } from "../utils/util.js";
import { useTranslations } from "../utils/useTranslations.js";
import { ConditionBuilderItem } from "../ConditionBuilderItem/ConditionBuilderItem.js";
import ConditionConnector from "../ConditionBuilderConnector/ConditionConnector.js";
import React, { useEffect, useState } from "react";
import PropTypes from "prop-types";
import { Bee } from "@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__ */ __toESM(require_classnames());
const ConditionPreview = ({ previewType, group, colorIndex, className }) => {
	const [animate, setAnimate] = useState(false);
	const [propertyText, operatorText, valueText, ifText] = useTranslations([
		"valueText",
		"operatorText",
		"propertyText",
		"ifText"
	]);
	useEffect(() => {
		setAnimate(true);
	}, []);
	const getConditionSection = () => {
		return /* @__PURE__ */ React.createElement("div", { className: `${blockClass}__preview-condition` }, /* @__PURE__ */ React.createElement(ConditionBuilderItem, {
			label: propertyText,
			renderIcon: Bee
		}), /* @__PURE__ */ React.createElement(ConditionBuilderItem, { label: operatorText }), /* @__PURE__ */ React.createElement(ConditionBuilderItem, { label: valueText }));
	};
	return /* @__PURE__ */ React.createElement(React.Fragment, null, previewType == "newGroup" && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: (0, import_classnames.default)([`${blockClass}__group__row ${blockClass}__group-preview ${className}`, { [`${blockClass}__group-preview-animate`]: animate }]) }, /* @__PURE__ */ React.createElement(ConditionBuilderItem, {
		className: `${blockClass}__statement-button`,
		label: group.groupOperator
	})), /* @__PURE__ */ React.createElement("div", {
		"data-color-index": colorIndex,
		"aria-hidden": true,
		className: (0, import_classnames.default)([`${blockClass}__group  ${blockClass}__condition-wrapper ${blockClass}__group-preview ${blockClass}__group-wrapper ${className}`, { [`${blockClass}__group-preview-animate`]: animate }])
	}, /* @__PURE__ */ React.createElement("div", { className: `${blockClass}__gap` }, /* @__PURE__ */ React.createElement(ConditionBuilderItem, {
		className: `${blockClass}__statement-button`,
		label: ifText
	})), getConditionSection())), previewType == "subGroup" && /* @__PURE__ */ React.createElement("div", { className: (0, import_classnames.default)([`${blockClass}__group__row ${blockClass}__group-preview ${blockClass}__gap-bottom`, { [`${blockClass}__group-preview-animate`]: animate }]) }, /* @__PURE__ */ React.createElement("div", { className: `${blockClass}__condition-block  ${blockClass}__gap` }, /* @__PURE__ */ React.createElement(ConditionBuilderItem, {
		label: group.groupOperator,
		className: `${blockClass}__statement-button`,
		popOverClassName: `${blockClass}__gap`
	}), /* @__PURE__ */ React.createElement("div", { className: `${blockClass}__group ${blockClass}__condition-wrapper` }, /* @__PURE__ */ React.createElement(ConditionConnector, {
		className: `${blockClass}__gap ${blockClass}__groupConnector`,
		operator: ifText
	}), getConditionSection()))), previewType == "condition" && /* @__PURE__ */ React.createElement("div", { className: (0, import_classnames.default)([`${blockClass}__group__row ${blockClass}__group-preview ${blockClass}__gap-bottom`, { [`${blockClass}__group-preview-animate`]: animate }]) }, /* @__PURE__ */ React.createElement("div", { className: `${blockClass}__condition-block  ${blockClass}__gap` }, /* @__PURE__ */ React.createElement(ConditionBuilderItem, {
		label: group.groupOperator,
		className: `${blockClass}__statement-button`,
		popOverClassName: `${blockClass}__gap`
	}), getConditionSection())));
};
ConditionPreview.propTypes = {
	className: PropTypes.string,
	colorIndex: PropTypes.number,
	group: PropTypes.object,
	previewType: PropTypes.oneOf([
		"condition",
		"subGroup",
		"newGroup"
	])
};

//#endregion
export { ConditionPreview as default };