import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/**
 * Copyright (c) 2020-present, Goldman Sachs
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { observer } from 'mobx-react-lite';
import { EXECUTION_PLAN_VIEW_MODE, } from '../../stores/execution-plan/ExecutionPlanState.js';
import { PartialClassResultType, PropertyGraphFetchTree, RootGraphFetchTree, } from '@finos/legend-graph';
import { PanelListItem, PanelDivider, Button, PanelContent, TreeView, } from '@finos/legend-art';
import { guaranteeType, isNonNullable } from '@finos/legend-shared';
import { buildGraphFetchTreeData, buildPropertyGraphFetchTreeData, } from '../../stores/fetch-structure/graph-fetch/QueryBuilderGraphFetchTreeUtil.js';
import { QueryBuilderGraphFetchTreeNodeContainer } from '../fetch-structure/QueryBuilderGraphFetchTreePanel.js';
import { PartialClassResultTypeViewer } from './PartialClassResultViewer.js';
export const StoreMappingGlobalGraphFetchExecutionNodeViewer = observer((props) => {
    const { storeMappingNode, executionPlanState } = props;
    let treeData = undefined;
    try {
        if (storeMappingNode.graphFetchTree instanceof RootGraphFetchTree) {
            treeData = buildGraphFetchTreeData(guaranteeType(storeMappingNode.graphFetchTree, RootGraphFetchTree), true);
        }
        else if (storeMappingNode.graphFetchTree instanceof PropertyGraphFetchTree) {
            treeData = buildPropertyGraphFetchTreeData(storeMappingNode.graphFetchTree);
        }
    }
    catch {
        //do nothing
    }
    const getChildNodes = (node) => node.childrenIds
        .map((id) => {
        if (treeData) {
            return treeData.nodes.get(id);
        }
        return null;
    })
        .filter(isNonNullable);
    const isReadOnly = true;
    const applicationStore = executionPlanState.applicationStore;
    return (_jsx(PanelContent, { darkMode: !applicationStore.layoutService.TEMPORARY__isLightColorThemeEnabled, children: _jsxs("div", { className: "query-builder__store-mapping-global-graph-fetch__container", children: [_jsx(PanelListItem, { className: "query-builder__store-mapping-global-graph-fetch__container__label", children: "Store Mapping Global Graph Fetch Execution Node Details" }), _jsx(PanelDivider, {}), _jsxs("table", { className: "query-builder__store-mapping-global-graph-fetch__container__table table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "table__cell--left", children: "Property" }), _jsx("th", { className: "table__cell--left", children: "Details" })] }) }), _jsxs("tbody", { children: [storeMappingNode.parentIndex !== undefined && (_jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: " ParentIndex" }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.parentIndex })] })), storeMappingNode.enableConstraints !== undefined && (_jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: "EnableConstraints" }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.enableConstraints.toString() })] })), storeMappingNode.checked !== undefined && (_jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: "Checked" }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.checked.toString() })] })), storeMappingNode.authDependent !== undefined && (_jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: "AuthDependent" }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.authDependent.toString() })] })), storeMappingNode.store && (_jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: "Store" }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.store })] })), _jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: "LocalTreeIndices" }), _jsx("td", { className: "table__cell--left", children: `[${storeMappingNode.localTreeIndices.toString()}]` })] }), _jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: "DependencyIndices" }), _jsx("td", { className: "table__cell--left", children: `[${storeMappingNode.dependencyIndices.toString()}]` })] })] })] }), _jsx(PanelDivider, {}), treeData && (_jsxs(_Fragment, { children: [_jsx(PanelListItem, { className: "query-builder__store-mapping-global-graph-fetch__container__label2", children: "Graph Fetch Tree" }), _jsx("div", { className: "query-builder__store-mapping-global-graph-fetch__container__config-group__content", children: _jsx("div", { className: "query-builder__store-mapping-global-graph-fetch__container__config-group__item", children: _jsx(TreeView, { components: {
                                        TreeNodeContainer: QueryBuilderGraphFetchTreeNodeContainer,
                                    }, className: "query-builder-graph-fetch-tree__container__tree", treeData: treeData, getChildNodes: getChildNodes, innerProps: {
                                        isReadOnly,
                                    } }) }) }), _jsx(PanelDivider, {})] })), storeMappingNode.xStorePropertyFetchDetails && (_jsxs(_Fragment, { children: [_jsx(PanelListItem, { className: "query-builder__store-mapping-global-graph-fetch__container__xstore", children: "xStorePropertyFetchDetails" }), _jsx(PanelDivider, {}), _jsxs("table", { className: "query-builder__store-mapping-global-graph-fetch__container__table table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "table__cell--left", children: "Property" }), _jsx("th", { className: "table__cell--left", children: "Details" })] }) }), _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: " propertyPath " }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.xStorePropertyFetchDetails.propertyPath })] }), _jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: " sourceMappingId " }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.xStorePropertyFetchDetails
                                                        .sourceMappingId })] }), _jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: " sourceSetId " }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.xStorePropertyFetchDetails.sourceSetId })] }), _jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: " subTree " }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.xStorePropertyFetchDetails.subTree })] }), _jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: " supportsCaching " }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.xStorePropertyFetchDetails.supportsCaching.toString() })] }), _jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: " targetMappingId " }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.xStorePropertyFetchDetails
                                                        .targetMappingId })] }), _jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: " targetSetId" }), _jsx("td", { className: "table__cell--left", children: storeMappingNode.xStorePropertyFetchDetails.targetSetId })] }), _jsxs("tr", { children: [_jsx("td", { className: "table__cell--left", children: "targetPropertiesOrdered" }), _jsx("td", { className: "table__cell--left", children: `[${storeMappingNode.xStorePropertyFetchDetails.targetPropertiesOrdered.toString()}]` })] })] })] })] })), storeMappingNode.resultType instanceof PartialClassResultType && (_jsx(PartialClassResultTypeViewer, { resultType: storeMappingNode.resultType })), _jsx(PanelDivider, {}), _jsx("div", { className: "query-builder__store-mapping-global-graph-fetch__container__btn", children: _jsx(Button, { className: "btn--dark execution-node-viewer__unsupported-view__to-text-mode__btn", onClick: () => executionPlanState.setViewMode(EXECUTION_PLAN_VIEW_MODE.JSON), text: "View JSON" }) }), _jsx(PanelDivider, {})] }) }));
});
//# sourceMappingURL=StoreMappingGlobalGraphFetchExecutionNodeViewer.js.map