import { GAP_BEFORE_LEFT_BAR, GAP_BETWEEN_TABLE_AND_CHART, MATRIX_ROW_HEIGHT, MAX_SETS_CHART_WIDTH, MIN_INTERSECTION_CHART_HEIGHT, MIN_MATRIX_COLUMN_WIDTH, MIN_SETS_CHART_WIDTH, TEXT_GAP, TOP_GAP } from './constants';
import { truncateLabels } from './helpers';
export var useUpSetChartSizes = function (_a) {
    var width = _a.width, height = _a.height, intersections = _a.intersections, sets = _a.sets;
    var minMatrixWidth = intersections.length * MIN_MATRIX_COLUMN_WIDTH * 1.2;
    var matrixHeight = sets.length * MATRIX_ROW_HEIGHT;
    var availableLabelsWidth = width - minMatrixWidth - TEXT_GAP * 2 - GAP_BEFORE_LEFT_BAR - MIN_SETS_CHART_WIDTH;
    var _b = truncateLabels(sets, availableLabelsWidth), labels = _b.labels, labelsWidth = _b.maxWidth;
    var availableSetsChartWidth = width - minMatrixWidth - TEXT_GAP * 2 - GAP_BEFORE_LEFT_BAR - labelsWidth;
    var setsChartWidth = Math.min(Math.max(availableSetsChartWidth, MIN_SETS_CHART_WIDTH), MAX_SETS_CHART_WIDTH);
    var maxLabelsWidth = width - minMatrixWidth - TEXT_GAP * 2 - GAP_BEFORE_LEFT_BAR - setsChartWidth;
    var leftPadding = setsChartWidth + labelsWidth + TEXT_GAP * 2 + GAP_BEFORE_LEFT_BAR;
    var intersectionsChartWidth = Math.max(minMatrixWidth, width - leftPadding);
    var intersectionsChartHeight = Math.max(MIN_INTERSECTION_CHART_HEIGHT, height - TOP_GAP - matrixHeight - GAP_BETWEEN_TABLE_AND_CHART);
    var svgWidth = leftPadding + intersectionsChartWidth;
    var svgHeight = intersectionsChartHeight + matrixHeight + TOP_GAP + GAP_BETWEEN_TABLE_AND_CHART;
    var matrixY = svgHeight - matrixHeight - 1;
    return {
        labels: labels,
        svgWidth: svgWidth,
        svgHeight: svgHeight,
        intersectionsChartWidth: intersectionsChartWidth,
        intersectionsChartHeight: intersectionsChartHeight,
        matrixY: matrixY,
        matrixHeight: matrixHeight,
        maxLabelsWidth: maxLabelsWidth,
        leftPadding: leftPadding,
        setsChartWidth: setsChartWidth
    };
};
