"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useUpSetChartSizes = void 0;
var constants_1 = require("./constants");
var helpers_1 = require("./helpers");
var useUpSetChartSizes = function (_a) {
    var width = _a.width, height = _a.height, intersections = _a.intersections, sets = _a.sets;
    var minMatrixWidth = intersections.length * constants_1.MIN_MATRIX_COLUMN_WIDTH * 1.2;
    var matrixHeight = sets.length * constants_1.MATRIX_ROW_HEIGHT;
    var availableLabelsWidth = width - minMatrixWidth - constants_1.TEXT_GAP * 2 - constants_1.GAP_BEFORE_LEFT_BAR - constants_1.MIN_SETS_CHART_WIDTH;
    var _b = (0, helpers_1.truncateLabels)(sets, availableLabelsWidth), labels = _b.labels, labelsWidth = _b.maxWidth;
    var availableSetsChartWidth = width - minMatrixWidth - constants_1.TEXT_GAP * 2 - constants_1.GAP_BEFORE_LEFT_BAR - labelsWidth;
    var setsChartWidth = Math.min(Math.max(availableSetsChartWidth, constants_1.MIN_SETS_CHART_WIDTH), constants_1.MAX_SETS_CHART_WIDTH);
    var maxLabelsWidth = width - minMatrixWidth - constants_1.TEXT_GAP * 2 - constants_1.GAP_BEFORE_LEFT_BAR - setsChartWidth;
    var leftPadding = setsChartWidth + labelsWidth + constants_1.TEXT_GAP * 2 + constants_1.GAP_BEFORE_LEFT_BAR;
    var intersectionsChartWidth = Math.max(minMatrixWidth, width - leftPadding);
    var intersectionsChartHeight = Math.max(constants_1.MIN_INTERSECTION_CHART_HEIGHT, height - constants_1.TOP_GAP - matrixHeight - constants_1.GAP_BETWEEN_TABLE_AND_CHART);
    var svgWidth = leftPadding + intersectionsChartWidth;
    var svgHeight = intersectionsChartHeight + matrixHeight + constants_1.TOP_GAP + constants_1.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
    };
};
exports.useUpSetChartSizes = useUpSetChartSizes;
