import { ConfigService } from "../configService/index.mjs";
import { apiMutate } from "../utilities/useAxiosMutate.mjs";
import { useActionStore } from "../stores/actionStore.mjs";
import { useShellStore } from "../stores/shellStore.mjs";
import { useActionState } from "../hooks/useActions.mjs";
import { ActionSplitScreen } from "./ActionSplitScreen.mjs";
import { PageSubHeaderActionsTarget } from "../utilities/page/PageSubHeaderAction.mjs";
import { c } from "react-compiler-runtime";
import React, { useEffect, useState } from "react";
import { useSnackbar } from "notistack";
//#region src/actions/PageActionWrapper.jsx
const PageActionWrapper = (props) => {
	const $ = c(20);
	const { children, forPageContainer: t0, splitScreenStateKey: t1 } = props;
	const forPageContainer = t0 === void 0 ? false : t0;
	const splitScreenStateKey = t1 === void 0 ? "pageSplitScreen" : t1;
	const [actionPanel, setActionPanel] = useState(null);
	const { enqueueSnackbar } = useSnackbar();
	const actionState = useActionState();
	const selectedNode = useActionStore(_temp);
	const currentContainerId = useShellStore(_temp2);
	let selectedAction = null;
	if (actionState) {
		if (actionState.pageSplitScreen?.action) selectedAction = actionState.pageSplitScreen.action;
	}
	const action = selectedAction;
	const executeAction = _temp3;
	let t2;
	let t3;
	if ($[0] !== action || $[1] !== actionState || $[2] !== currentContainerId) {
		t2 = () => {
			if (action && actionState) setActionPanel(actionState?.actionPanels[currentContainerId || 0]?.find((ap) => ap.panelActions.find((pa) => pa.actionId === action.actionId)));
		};
		t3 = [
			action,
			actionState,
			currentContainerId
		];
		$[0] = action;
		$[1] = actionState;
		$[2] = currentContainerId;
		$[3] = t2;
		$[4] = t3;
	} else {
		t2 = $[3];
		t3 = $[4];
	}
	useEffect(t2, t3);
	let t4;
	if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
		t4 = /* @__PURE__ */ React.createElement(PageSubHeaderActionsTarget, null);
		$[5] = t4;
	} else t4 = $[5];
	const t5 = actionState?.[splitScreenStateKey]?.open;
	const t6 = actionState?.[splitScreenStateKey]?.action;
	const t7 = actionState?.[splitScreenStateKey]?.type;
	const t8 = actionState?.[splitScreenStateKey]?.params;
	const t9 = selectedNode?.nodeObj;
	const t10 = actionState?.menuListState?.menuList;
	const t11 = actionState?.inquiryParams[currentContainerId || 0]?.selectedNode;
	const t12 = actionState?.inquiryParams[currentContainerId || 0]?.selectedNodeParent;
	const t13 = actionState?.inquiryParams[currentContainerId || 0]?.refreshTree;
	let t14;
	if ($[6] !== actionPanel || $[7] !== children || $[8] !== enqueueSnackbar || $[9] !== forPageContainer || $[10] !== t10 || $[11] !== t11 || $[12] !== t12 || $[13] !== t13 || $[14] !== t5 || $[15] !== t6 || $[16] !== t7 || $[17] !== t8 || $[18] !== t9) {
		t14 = /* @__PURE__ */ React.createElement(React.Fragment, null, t4, /* @__PURE__ */ React.createElement(ActionSplitScreen, {
			body: children,
			open: t5,
			action: t6,
			type: t7,
			params: t8,
			executeAction,
			actionPanel,
			enqueueSnackbar,
			selectedNodeObj: t9,
			menuNodeList: t10,
			forPage: true,
			forPageContainer,
			selectedNode: t11,
			selectedNodeParent: t12,
			refreshTree: t13
		}));
		$[6] = actionPanel;
		$[7] = children;
		$[8] = enqueueSnackbar;
		$[9] = forPageContainer;
		$[10] = t10;
		$[11] = t11;
		$[12] = t12;
		$[13] = t13;
		$[14] = t5;
		$[15] = t6;
		$[16] = t7;
		$[17] = t8;
		$[18] = t9;
		$[19] = t14;
	} else t14 = $[19];
	return t14;
};
function _temp(state) {
	return state.selectedNode;
}
function _temp2(state_0) {
	return state_0.currentContainerId;
}
async function _temp3(data, id) {
	return apiMutate(ConfigService.integrationV1ApiUrl, `apimethod/executeQueryWithParameters/${id}`, { method: "post" }, data);
}
//#endregion
export { PageActionWrapper };

//# sourceMappingURL=PageActionWrapper.mjs.map