import { useWorkflow as e } from "../../../hooks/useWorkflows.js";
import { useRunWorkflow as t } from "../../../hooks/useProcessor.js";
import { require_enums as n } from "../../../packages/contracts/dist/enums/index.js";
import { useFilterDocuments as r } from "../../../hooks/useDocuments.js";
import { useCallback as i, useMemo as a } from "react";
//#region src/features/workbench/hooks/useWorkflowData.ts
var o = n();
function s({ workflowId: n, showFullMessageHistory: s }) {
	let c = e(n), l = r(n), u = t(), d = i((e) => {
		let t = e.meta, n = e.ui, r = t?.hidden || n?.hidden || !!t?.hideAtPlaces?.includes(c.data?.place ?? "");
		return !s && e.tags?.includes("internal") && (r = !0), !r;
	}, [c.data, s]), f = a(() => l.data ? l.data.filter(d) : [], [l.data, d]), p = i((e, t) => {
		u.mutate({
			workflowId: n,
			runWorkflowPayloadDto: { transition: {
				id: e,
				workflowId: n,
				payload: t
			} }
		});
	}, [u, n]), m = u.isPending || c.data?.status === o.WorkflowState.Running;
	return {
		workflow: c.data,
		workflowLoading: c.isLoading,
		workflowReady: c.isSuccess,
		workflowError: c.data?.errorMessage,
		documents: f,
		documentsLoading: l.isLoading,
		documentsReady: l.isSuccess,
		documentsError: l.error,
		isLoading: m,
		handleRun: p
	};
}
//#endregion
export { s as useWorkflowData };
