"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BasePointSeriesWrapped = void 0;
var IDataSeries_1 = require("../IDataSeries");
var BasePointSeriesWrapped = /** @class */ (function () {
    function BasePointSeriesWrapped(dataSeries, yValuesArray, valueType, valueNames, xValuesOverride) {
        var _a;
        this.type = IDataSeries_1.EDataSeriesType.XyN;
        this.yValuesArray = [];
        this.resampled = false;
        this.dataSeries = dataSeries;
        // xValuesOverride lets callers supply pre-computed X values (e.g. a stacked collection
        // that has unwound a FIFO circular buffer into logical order) instead of the raw
        // dataSeries X buffer.
        this.xValues = xValuesOverride !== null && xValuesOverride !== void 0 ? xValuesOverride : this.dataSeries.getXValues(valueType);
        if (!yValuesArray || yValuesArray.length === 0 || yValuesArray[0] === undefined) {
            this.count = dataSeries.count();
            // @ts-ignore
            this.yValuesArray = dataSeries.getYValuesArray(valueType);
        }
        else {
            this.count = yValuesArray.length;
            // Here we use yValuesArray.length not dataSeries.count() to make StackedMountainSeries work
            for (var i = 0; i < yValuesArray.length; i++) {
                // @ts-ignore
                this.yValuesArray.push((_a = yValuesArray[i]) !== null && _a !== void 0 ? _a : dataSeries.yValuesArray[i]);
            }
        }
        this.valueNamesProperty = valueNames !== null && valueNames !== void 0 ? valueNames : this.dataSeries.valueNames;
        this.fifoStartIndex = dataSeries.fifoStartIndex;
    }
    Object.defineProperty(BasePointSeriesWrapped.prototype, "indexes", {
        get: function () {
            if (!this.indexesProperty) {
                this.indexesProperty = this.dataSeries.getNativeIndexes();
            }
            return this.indexesProperty;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BasePointSeriesWrapped.prototype, "valueNames", {
        get: function () {
            return this.valueNamesProperty;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BasePointSeriesWrapped.prototype, "arrayCount", {
        get: function () {
            return this.dataSeries.arrayCount;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(BasePointSeriesWrapped.prototype, "yValues", {
        get: function () {
            return this.yValuesArray[0];
        },
        enumerable: false,
        configurable: true
    });
    BasePointSeriesWrapped.prototype.getYValues = function (i) {
        return this.yValuesArray[i !== null && i !== void 0 ? i : 0];
    };
    BasePointSeriesWrapped.prototype.getYValuesByName = function (name) {
        var index = this.valueNames.indexOf(name);
        if (index >= 0) {
            return this.yValuesArray[index];
        }
        else {
            return undefined;
        }
    };
    BasePointSeriesWrapped.prototype.delete = function () { };
    return BasePointSeriesWrapped;
}());
exports.BasePointSeriesWrapped = BasePointSeriesWrapped;
