"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SeriesInfo = void 0;
var Point_1 = require("../../../Core/Point");
var SeriesType_1 = require("../../../types/SeriesType");
/**
 * SeriesInfo is a data-structure which provides enriched information about a hit-test operation.
 * It's derived by calling {@link BaseRenderableSeries.hitTestProvider.hitTest} (returns {@link HitTestInfo}) and then
 * enriched by calling {@link BaseRenderableSeries.getSeriesInfo}. There is a class hierachy for {@link SeriesInfo} which
 * is a different class depending on series type, e.g. line, mountain, scatter series has {@link XySeriesInfo},
 * heatmap series as {@link HeatmapSeriesInfo} etc.
 */
var SeriesInfo = /** @class */ (function () {
    function SeriesInfo(renderableSeries, hitTestInfo) {
        this.renderableSeries = renderableSeries;
        this.seriesName = renderableSeries.seriesName;
        this.stroke = renderableSeries.stroke;
        this.dataSeriesType = hitTestInfo.dataSeriesType;
        this.dataSeriesIndex = hitTestInfo.dataSeriesIndex;
        this.isHit = hitTestInfo.isHit;
        this.isWithinDataBounds = hitTestInfo.isWithinDataBounds;
        this.hitTestPointValues = hitTestInfo.hitTestPointValues;
        this.xValue = hitTestInfo.isCategoryAxis ? hitTestInfo.xCategoryValue : hitTestInfo.xValue;
        this.point2xValue = hitTestInfo.point2xValue;
        this.yValue = hitTestInfo.yValue;
        this.point2yValue = hitTestInfo.point2yValue;
        this.xCoordinate = hitTestInfo.xCoord;
        this.yCoordinate = hitTestInfo.yCoord;
        this.point2xCoordinate = hitTestInfo.point2xCoord;
        this.point2yCoordinate = hitTestInfo.point2yCoord;
        this.pointMetadata = hitTestInfo.metadata;
        this.point2metadata = hitTestInfo.point2metadata;
        this.distance = hitTestInfo.distance;
        if (renderableSeries.type === SeriesType_1.ESeriesType.ColumnSeries) {
            this.fill = renderableSeries.fill;
        }
        else if (renderableSeries.type === SeriesType_1.ESeriesType.MountainSeries) {
            this.fill = renderableSeries.fill;
        }
        else if (renderableSeries.type === SeriesType_1.ESeriesType.BandSeries) {
            this.fill = renderableSeries.fill;
        }
        this.hitTestInfo = hitTestInfo;
    }
    Object.defineProperty(SeriesInfo.prototype, "isVisible", {
        get: function () {
            return this.renderableSeries.isVisible;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SeriesInfo.prototype, "formattedYValue", {
        get: function () {
            return this.getYCursorFormattedValue(this.yValue);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SeriesInfo.prototype, "formattedXValue", {
        get: function () {
            return this.getXCursorFormattedValue(this.xValue);
        },
        enumerable: false,
        configurable: true
    });
    SeriesInfo.prototype.getYCursorFormattedValue = function (value) {
        return this.renderableSeries.yAxis.labelProvider.formatCursorLabel(value);
    };
    SeriesInfo.prototype.getXCursorFormattedValue = function (value) {
        return this.renderableSeries.xAxis.labelProvider.formatCursorLabel(value);
    };
    SeriesInfo.prototype.equals = function (other) {
        if (!other)
            return false;
        return (other &&
            this.renderableSeries.id === other.renderableSeries.id &&
            this.isHit === other.isHit &&
            Point_1.Point.isEqual(this.hitTestPointValues, other.hitTestPointValues) &&
            this.formattedYValue === other.formattedYValue &&
            this.formattedXValue === other.formattedXValue &&
            this.pointMetadata === other.pointMetadata);
    };
    SeriesInfo.prototype.getValuesWithLabels = function (title, xLabel, yLabel, isXYGrouped) {
        var res = [];
        if (title)
            res.push(title);
        return res;
    };
    SeriesInfo.prototype.concatValueWithLabel = function (value, label) {
        return "".concat(label, ": ").concat(value);
    };
    SeriesInfo.prototype.concatTwoValuesWithLabels = function (xValue, yValue, xLabel, yLabel) {
        if (xLabel) {
            var yLabel2 = yLabel !== null && yLabel !== void 0 ? yLabel : "Y";
            return "".concat(xLabel, ": ").concat(xValue, " ").concat(yLabel2, ": ").concat(yValue);
        }
        else {
            var yLabel2 = yLabel ? "".concat(yLabel, ": ") : "";
            return "".concat(yLabel2).concat(yValue);
        }
    };
    return SeriesInfo;
}());
exports.SeriesInfo = SeriesInfo;
