import { ConfigService } from "../configService/index.mjs";
import { useUser } from "../utilities/auth/useUser.mjs";
import { useAxiosGet } from "../utilities/useAxiosGet.mjs";
import { PageContainer } from "../page/PageContainer/PageContainer.mjs";
import { useBuildEnvironment } from "../shell/ui/useBuildEnvironment.mjs";
import { UnitTypeEnums } from "../enums/workflowEnums.mjs";
import { WorkflowUiInterruptContent } from "./WorkflowUiInterruptContent.mjs";
import { SmsDisplay } from "../UI/components/dataDisplay/SmsDisplay.mjs";
import { EmailDisplay } from "../UI/components/dataDisplay/EmailDisplay.mjs";
import React, { useMemo } from "react";
import { makeStyles } from "@material-ui/core";
//#region src/workflow/WorkflowContent.jsx
const useStyles = makeStyles((theme) => ({ root: { height: "100%" } }));
const WorkflowContent = (props) => {
	const { selectedNode, workflow, reloadWorkflow, users, groups, handleClose, inquiryPageParams = {} } = props;
	const buildEnv = useBuildEnvironment();
	const classes = useStyles({
		...props,
		appRibbonSpace: buildEnv ? 25 : 0
	});
	const user = useUser();
	const [{ data: pageData, loading: pageLoading, error: pageError }] = useAxiosGet(ConfigService.tenantV1ApiUrl, `page/${selectedNode?.properties?.page?.id}`, {}, !!!selectedNode?.properties?.page?.id, false);
	const content = useMemo(() => {
		let res = null;
		if (selectedNode?.properties?.type === UnitTypeEnums.Scene) res = /* @__PURE__ */ React.createElement(WorkflowUiInterruptContent, {
			key: selectedNode.id,
			selectedNode,
			workflow,
			reloadWorkflow,
			users,
			groups,
			handleClose,
			inquiryPageParams
		});
		else if (selectedNode?.properties?.type === UnitTypeEnums.Sms) res = /* @__PURE__ */ React.createElement(SmsDisplay, {
			messages: [selectedNode?.properties?.sms?.body || ""],
			to: selectedNode?.properties?.sms?.to || "",
			from: selectedNode?.properties?.sms?.from || "",
			title: selectedNode?.properties?.nodeLabel || "",
			handleClose
		});
		else if (selectedNode?.properties?.type === UnitTypeEnums.Mail) res = /* @__PURE__ */ React.createElement(EmailDisplay, {
			html: selectedNode?.properties?.email?.html || selectedNode?.properties?.email?.text || "",
			to: selectedNode?.properties?.email?.to || "",
			from: selectedNode?.properties?.email?.from || "",
			title: selectedNode?.properties?.nodeLabel || "",
			handleClose
		});
		else if (selectedNode?.properties?.page?.id) res = /* @__PURE__ */ React.createElement(PageContainer, {
			user,
			key: selectedNode?.id,
			pageData,
			pageLoading,
			widgetParams: {
				pageId: pageData?.pageId,
				entityName: selectedNode?.properties?.page?.entity?.entityName,
				pbiReportCode: selectedNode?.properties?.page?.pbiReportCode,
				requiredFieldsMap: selectedNode?.properties?.page?.requiredFieldMapping,
				udpTagId: selectedNode?.properties?.page?.udpTagId,
				queryId: selectedNode?.properties?.page?.queryId,
				inquiryTreeId: selectedNode?.properties?.page?.inquiryTreeId
			},
			disableMargins: true,
			fromMenu: true
		});
		return res;
	}, [
		groups,
		pageData,
		pageLoading,
		reloadWorkflow,
		selectedNode,
		user,
		users,
		workflow,
		handleClose
	]);
	return /* @__PURE__ */ React.createElement("div", { className: classes.root }, content);
};
//#endregion
export { WorkflowContent };

//# sourceMappingURL=WorkflowContent.mjs.map