import React, { useMemo } from 'react';
import { MultiGraph } from 'graphology';
import { mergeDeepRight } from 'ramda';
import { SigmaContainer } from '@react-sigma/core';
import { createNodeCompoundProgram } from 'sigma/rendering/webgl/programs/common/node';
import { createEdgeCompoundProgram } from 'sigma/rendering/webgl/programs/common/edge';
import LineEdgeProgram from 'sigma/rendering/webgl/programs/edge';
import { SigmaCustomRenderersContainer } from '../SigmaCustomRenderersContainer';
import { SigmaGraphResizer } from '../SigmaGraphResizer';
import { drawHover } from '../rendering/canvas/hover';
import { drawLabel } from '../rendering/canvas/label';
import { NodeDashedBorderProgram } from '../rendering/webgl/node.dashed.border';
import { NodeImageProgram } from '../rendering/webgl/node.image';
import EdgeArrowHeadProgram from '../rendering/webgl/edge.arrowHead';
import EdgeReversedArrowHeadProgram from '../rendering/webgl/edge.reversedArrowHead';
import EdgeClampedProgram from '../rendering/webgl/edge.clamped';
import DashedEdgeProgram from '../rendering/webgl/edge.dashed';
import { useStyles } from './styles';
export var SigmaGraphContainer = function (_a) {
    var children = _a.children, initialSettingsProp = _a.initialSettings;
    useStyles();
    var initialSettings = useMemo(function () {
        return mergeDeepRight({
            allowInvalidContainer: true,
            defaultNodeType: 'image',
            hoverRenderer: drawHover,
            labelRenderer: drawLabel,
            nodeProgramClasses: {
                image: createNodeCompoundProgram([NodeImageProgram, NodeDashedBorderProgram])
            },
            edgeProgramClasses: {
                line: LineEdgeProgram,
                arrow: createEdgeCompoundProgram([EdgeClampedProgram, EdgeArrowHeadProgram]),
                doubleArrow: createEdgeCompoundProgram([
                    EdgeClampedProgram,
                    EdgeArrowHeadProgram,
                    EdgeReversedArrowHeadProgram
                ]),
                dashed: DashedEdgeProgram
            },
            labelFont: 'Roboto',
            labelSize: 13,
            labelColor: {
                color: 'rgba(0, 0, 0, 0.87)',
                attribute: 'labelColor'
            },
            secondaryLabelColor: {
                color: 'rgba(0, 0, 0, 0.54)',
                attribute: 'secondaryLabelColor'
            }
        }, initialSettingsProp || {});
    }, [initialSettingsProp]);
    return (React.createElement(SigmaContainer, { graph: MultiGraph, style: { background: 'transparent' }, settings: initialSettings },
        React.createElement(SigmaCustomRenderersContainer, null,
            React.createElement(SigmaGraphResizer, null),
            children)));
};
