"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WorkflowDefinitionsProvider = exports.WorkflowDefinitionsContext = void 0;
var react_1 = __importDefault(require("react"));
var useWorkflowDefinitions_1 = require("../../features/workflow/hooks/useWorkflowDefinitions");
var useWorkflowCheckPermission_1 = require("../../features/workflow/hooks/useWorkflowCheckPermission");
var MdmModuleContext_1 = require("../MdmModuleContext");
exports.WorkflowDefinitionsContext = react_1.default.createContext({
    definitions: [],
    loading: false
});
exports.WorkflowDefinitionsContext.displayName = 'WorkflowDefinitionsContext';
var WorkflowDefinitionsProvider = function (_a) {
    var children = _a.children;
    var isWorkflowEnabled = (0, MdmModuleContext_1.useMdmIsWorkflowEnabled)();
    var checkWorkflowPermission = (0, useWorkflowCheckPermission_1.useWorkflowCheckPermission)();
    var canViewProcessDefinitions = checkWorkflowPermission('VIEW_PROCESS_DEFINITIONS');
    var canViewDefinitions = isWorkflowEnabled && canViewProcessDefinitions;
    var workflowDefinitions = (0, useWorkflowDefinitions_1.useWorkflowDefinitions)({ all: true, canViewDefinitions: canViewDefinitions });
    return (react_1.default.createElement(exports.WorkflowDefinitionsContext.Provider, { value: workflowDefinitions }, children));
};
exports.WorkflowDefinitionsProvider = WorkflowDefinitionsProvider;
