"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseSeriesDrawingProvider = void 0;
var app_1 = require("../../../../constants/app");
var DeletableEntity_1 = require("../../../../Core/DeletableEntity");
var Deleter_1 = require("../../../../Core/Deleter");
var Guard_1 = require("../../../../Core/Guard");
var ValueName_1 = require("../../../../types/ValueName");
var colorUtil_1 = require("../../../../utils/colorUtil");
var number_1 = require("../../../../utils/number");
var parseColor_1 = require("../../../../utils/parseColor");
var performance_1 = require("../../../../utils/performance");
var vectorToArray_1 = require("../../../../utils/vectorToArray");
var PaletteCache_1 = require("../../../Drawing/PaletteCache");
var IPaletteProvider_1 = require("../../../Model/IPaletteProvider");
var createSolidBrush_1 = require("../../Helpers/createSolidBrush");
var constants_1 = require("../constants");
/**
 * Used internally - a drawing provider performs drawing for a specific chart-type or series using
 * our WebAssembly WebGL rendering engine
 */
var BaseSeriesDrawingProvider = /** @class */ (function (_super) {
    __extends(BaseSeriesDrawingProvider, _super);
    /**
     * Creates an instance of the {@link BaseSeriesDrawingProvider}
     * @param webAssemblyContext The {@link TSciChart | SciChart 2D WebAssembly Context} containing native methods and
     * access to our WebGL2 Engine and WebAssembly numerical methods
     * @param parentSeries the parent {@link IRenderableSeries | Renderable Series} which this drawing provider is attached to
     */
    function BaseSeriesDrawingProvider(webAssemblyContext, parentSeries, ySelector, xSelector) {
        var _this = this;
        var _a;
        _this = _super.call(this) || this;
        Guard_1.Guard.notNull(webAssemblyContext, "webAssemblyContext");
        Guard_1.Guard.notNull(parentSeries, "parentSeries");
        _this.webAssemblyContext = webAssemblyContext;
        _this.parentSeries = parentSeries;
        if (xSelector) {
            _this.xSelector = xSelector;
        }
        if (ySelector) {
            _this.ySelector = ySelector;
        }
        _this.palettingState = {
            palettedColors: undefined,
            palettedColorsHashCode: 0,
            gradientPaletting: false,
            paletteTextureCache: new PaletteCache_1.PaletteCache(webAssemblyContext),
            requiresUpdate: true
        };
        _this.seriesHasDataChanges = _this.seriesHasDataChanges.bind(_this);
        _this.parentDataSeries = _this.parentSeries.dataSeries;
        (_a = _this.parentDataSeries) === null || _a === void 0 ? void 0 : _a.dataChanged.subscribe(_this.seriesHasDataChanges);
        return _this;
    }
    BaseSeriesDrawingProvider.prototype.xSelector = function (ps) {
        return ps.xValues;
    };
    BaseSeriesDrawingProvider.prototype.ySelector = function (ps) {
        var filter = this.parentSeries.yArrayFilter;
        if (filter) {
            // return first y values if no match to support fallback from XyN resampled to XyN wrapped
            if (typeof filter === "number") {
                return ps.getYValues(filter, false);
            }
            else {
                return ps.getYValuesByName(filter, false);
            }
        }
        else {
            return ps.yValues;
        }
    };
    /**
     * Returns the startIndex and count to be passed to the native drawing provider.
     * If renderPassData exists and contains an indexRange, this will be used, otherwise the full size of the xValues will be used
     * @param renderPassData
     * @param xValues
     * @returns
     */
    BaseSeriesDrawingProvider.prototype.getStartAndCount = function (renderPassData, xValues) {
        var _a, _b, _c;
        var pointSeries = renderPassData === null || renderPassData === void 0 ? void 0 : renderPassData.pointSeries;
        var xAxis = (_a = this.parentSeries) === null || _a === void 0 ? void 0 : _a.xAxis;
        var shouldClip = (_b = xAxis === null || xAxis === void 0 ? void 0 : xAxis.clipToXRange) !== null && _b !== void 0 ? _b : true; // fo the sake of tests
        var xCount = xValues.size();
        var count = Math.min(pointSeries ? pointSeries.xValues.size() : xCount, xCount);
        var startIndex = 0;
        if (shouldClip && !(pointSeries === null || pointSeries === void 0 ? void 0 : pointSeries.resampled) && ((_c = renderPassData === null || renderPassData === void 0 ? void 0 : renderPassData.indexRange) === null || _c === void 0 ? void 0 : _c.diff) >= 0) {
            if (renderPassData.indexRange.diff + 1 < count) {
                startIndex = renderPassData.indexRange.min;
            }
            count = Math.min(renderPassData.indexRange.diff + 1, count);
        }
        return { startIndex: startIndex, count: count };
    };
    /**
     * Helper function to apply color-paletting to a {@link UIntVector} - where each element in the vector
     * is an ARGB color that defines stroke of the series
     * @param strokePen the current pen, as type {@link SCRTPen}
     * @param renderPassData optional renderPassData.  If not supplied, the current renderPassData for the parent series will be used
     * @returns the new {@link UIntVector} with ARGB colors
     */
    BaseSeriesDrawingProvider.prototype.applyStrokePaletting = function (strokePen, renderPassData) {
        var _a, _b, _c, _d, _e, _f, _g;
        var mark = performance_1.PerformanceDebugHelper.mark(performance_1.EPerformanceMarkType.PaletteProviderStart, {
            contextId: this.parentSeries.id,
            parentContextId: (_a = this.parentSeries.parentSurface) === null || _a === void 0 ? void 0 : _a.id,
            level: performance_1.EPerformanceDebugLevel.Verbose
        });
        var advancedPP = this.parentSeries.paletteProvider;
        var hasPP = this.parentSeries.hasStrokePaletteProvider() || advancedPP.applyPaletting !== undefined;
        if (hasPP) {
            var strokeColorArgb = (0, colorUtil_1.uintArgbColorMultiplyOpacity)((0, parseColor_1.parseColorToUIntArgb)(this.parentSeries.stroke), this.parentSeries.opacity);
            if (isNaN(strokeColorArgb)) {
                throw Error("applyStrokePaletting(): renderSeries.stroke " +
                    this.parentSeries.stroke +
                    " cannot be converted to a valid color");
            }
            var strokePaletteProvider = this.parentSeries.paletteProvider;
            var dataSeries = this.parentSeries.dataSeries;
            renderPassData = renderPassData !== null && renderPassData !== void 0 ? renderPassData : this.parentSeries.getCurrentRenderPassData();
            var pointSeries = renderPassData === null || renderPassData === void 0 ? void 0 : renderPassData.pointSeries;
            var xValues = (_b = (pointSeries ? this.xSelector(pointSeries) : undefined)) !== null && _b !== void 0 ? _b : dataSeries.getNativeXValues();
            var yValues = (_c = (pointSeries ? this.ySelector(pointSeries) : undefined)) !== null && _c !== void 0 ? _c : dataSeries.getNativeYValues();
            var _h = this.getStartAndCount(renderPassData, xValues), startIndex = _h.startIndex, count = _h.count;
            if (!this.palettingState.palettedColors) {
                this.palettingState.palettedColors = new this.webAssemblyContext.UIntVector();
            }
            strokePen.m_bGradient = strokePaletteProvider.strokePaletteMode === IPaletteProvider_1.EStrokePaletteMode.GRADIENT;
            var otherValues = new Map();
            for (var _i = 0, _j = dataSeries.valueNames; _i < _j.length; _i++) {
                var valueName = _j[_i];
                if (valueName !== ValueName_1.EValueName.Y) {
                    otherValues.set(valueName, (0, vectorToArray_1.vectorToArrayViewF64)(dataSeries.getYValuesByName(valueName), this.webAssemblyContext));
                }
            }
            if (advancedPP.applyPaletting) {
                advancedPP.applyPaletting(this.palettingState, xValues, yValues, (_d = pointSeries === null || pointSeries === void 0 ? void 0 : pointSeries.indexes) !== null && _d !== void 0 ? _d : dataSeries.getNativeIndexes(), startIndex, count, otherValues);
                // Advanced palette providers write colours directly in native ABGR format; no conversion here.
                return;
            }
            this.shouldUpdatePalette(renderPassData, strokePaletteProvider, startIndex, count, false);
            if (!this.palettingState.requiresUpdate) {
                return;
            }
            this.palettingState.palettedColors.resize(count, 0);
            var dsCount = dataSeries.count();
            var hasPSIndexes = pointSeries && pointSeries.indexes.size() > 0;
            var indexView = (0, vectorToArray_1.vectorToArrayViewF64)(pointSeries === null || pointSeries === void 0 ? void 0 : pointSeries.indexes, this.webAssemblyContext);
            var xView = (0, vectorToArray_1.vectorToArrayViewF64)(xValues, this.webAssemblyContext);
            var yView = (0, vectorToArray_1.vectorToArrayViewF64)(yValues, this.webAssemblyContext);
            var paletteView = (0, vectorToArray_1.vectorToArrayViewUi32)(this.palettingState.palettedColors, this.webAssemblyContext);
            var paletteIndex = 0;
            for (var index = startIndex; index < startIndex + count; index++) {
                var originalDataIndex = hasPSIndexes ? indexView[index] : index;
                if (originalDataIndex < 0)
                    originalDataIndex = 0;
                else if (originalDataIndex >= dsCount)
                    originalDataIndex = dsCount - 1;
                var xValue = xView[index];
                var yValue = yValues ? yView[index] : undefined;
                var overrideColor = strokePaletteProvider.overrideStrokeArgb(xValue, yValue, originalDataIndex, this.parentSeries.opacity, dataSeries.getMetadataAt(originalDataIndex), otherValues);
                paletteView[paletteIndex] = (0, colorUtil_1.uintArgbColorToAbgr)(overrideColor ? overrideColor : strokeColorArgb);
                paletteIndex++;
            }
            this.palettingState.requiresUpdate = false;
        }
        else {
            (_e = this.palettingState.palettedColors) === null || _e === void 0 ? void 0 : _e.clear();
        }
        // Due to pass-by-pointer limitations of WASM binding, we pass an empty vector rather than null
        if (!this.palettingState.palettedColors) {
            this.palettingState.palettedColors = new this.webAssemblyContext.UIntVector();
        }
        performance_1.PerformanceDebugHelper.mark(performance_1.EPerformanceMarkType.PaletteProviderEnd, {
            contextId: this.parentSeries.id,
            parentContextId: (_f = this.parentSeries.parentSurface) === null || _f === void 0 ? void 0 : _f.id,
            relatedId: (_g = mark === null || mark === void 0 ? void 0 : mark.detail) === null || _g === void 0 ? void 0 : _g.relatedId,
            level: performance_1.EPerformanceDebugLevel.Verbose
        });
    };
    BaseSeriesDrawingProvider.prototype.applyStrokeFillPaletting = function (stroke, strokePen, fill, fillBrush, opacity, usePalette, resetPenBrushColors, renderPassData) {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j;
        if (usePalette === void 0) { usePalette = false; }
        if (resetPenBrushColors === void 0) { resetPenBrushColors = true; }
        var mark = performance_1.PerformanceDebugHelper.mark(performance_1.EPerformanceMarkType.PaletteProviderStart, {
            contextId: this.parentSeries.id,
            parentContextId: (_a = this.parentSeries.parentSurface) === null || _a === void 0 ? void 0 : _a.id,
            level: performance_1.EPerformanceDebugLevel.Verbose
        });
        var hasStrokePaletteProvider = this.parentSeries.hasStrokePaletteProvider();
        var hasFillPaletteProvider = this.parentSeries.hasFillPaletteProvider();
        var hasPointMarkerPaletteProvider = this.parentSeries.hasPointMarkerPaletteProvider();
        var strokePaletteProvider = this.parentSeries.paletteProvider;
        var advancedPP = this.parentSeries.paletteProvider;
        var hasAdvancedPP = (advancedPP === null || advancedPP === void 0 ? void 0 : advancedPP.applyPaletting) !== undefined;
        var hasPP = hasStrokePaletteProvider || hasFillPaletteProvider || hasPointMarkerPaletteProvider || hasAdvancedPP;
        if (hasPP) {
            var strokeColor = void 0;
            var fillColor = void 0;
            // Palette (this.palettingState.paletteTextureCache) is used only for band and mountain series
            if (usePalette) {
                strokeColor = fillColor = app_1.NEUTRAL_COLOR;
            }
            else {
                var hasOpacity = opacity !== undefined;
                strokeColor =
                    stroke && hasOpacity
                        ? (0, colorUtil_1.uintArgbColorMultiplyOpacity)((0, parseColor_1.parseColorToUIntArgb)(stroke), opacity)
                        : app_1.NEUTRAL_COLOR;
                fillColor =
                    fill && hasOpacity
                        ? (0, colorUtil_1.uintArgbColorMultiplyOpacity)((0, parseColor_1.parseColorToUIntArgb)(fill), opacity)
                        : app_1.NEUTRAL_COLOR;
            }
            if (isNaN(strokeColor)) {
                throw Error("updatePalette(): parentSeries.stroke " + stroke + " cannot be converted to a valid color");
            }
            if (isNaN(fillColor)) {
                throw Error("updatePalette(): fillColor " + fillColor + " cannot be converted to a valid color");
            }
            var dataSeries = this.parentSeries.dataSeries;
            renderPassData = renderPassData !== null && renderPassData !== void 0 ? renderPassData : this.parentSeries.getCurrentRenderPassData();
            var pointSeries = renderPassData === null || renderPassData === void 0 ? void 0 : renderPassData.pointSeries;
            var xValues = (_b = (pointSeries ? this.xSelector(pointSeries) : undefined)) !== null && _b !== void 0 ? _b : dataSeries.getNativeXValues();
            var yValues = (_c = (pointSeries ? this.ySelector(pointSeries) : undefined)) !== null && _c !== void 0 ? _c : dataSeries.getNativeYValues();
            var _k = this.getStartAndCount(renderPassData, xValues), startIndex = _k.startIndex, count = _k.count;
            if (!this.palettingState.palettedColors) {
                this.palettingState.palettedColors = new this.webAssemblyContext.UIntVector();
            }
            var otherValues = new Map();
            for (var _i = 0, _l = dataSeries.valueNames; _i < _l.length; _i++) {
                var valueName = _l[_i];
                if (valueName !== ValueName_1.EValueName.Y) {
                    otherValues.set(valueName, (0, vectorToArray_1.vectorToArrayViewF64)(dataSeries.getYValuesByName(valueName), this.webAssemblyContext));
                }
            }
            if (advancedPP.applyPaletting) {
                advancedPP.applyPaletting(this.palettingState, xValues, yValues, (_d = pointSeries === null || pointSeries === void 0 ? void 0 : pointSeries.indexes) !== null && _d !== void 0 ? _d : dataSeries.getNativeIndexes(), startIndex, count, otherValues);
                // Advanced palette providers write colours directly in native ABGR format; no conversion here.
                return;
            }
            this.shouldUpdatePalette(renderPassData, strokePaletteProvider, startIndex, count, true);
            if (!this.palettingState.requiresUpdate) {
                return;
            }
            this.palettingState.paletteTextureCache.reset();
            this.palettingState.palettedColors.resize(count * 2, 0);
            if (resetPenBrushColors) {
                if (strokePen && hasStrokePaletteProvider) {
                    strokePen.m_bGradient = strokePaletteProvider.strokePaletteMode === IPaletteProvider_1.EStrokePaletteMode.GRADIENT;
                }
            }
            // Override stroke and fill colors
            var hashCode = 0;
            var hasPSIndexes = pointSeries && pointSeries.indexes.size() > 0;
            var indexView = (0, vectorToArray_1.vectorToArrayViewF64)(pointSeries === null || pointSeries === void 0 ? void 0 : pointSeries.indexes, this.webAssemblyContext);
            var xView = (0, vectorToArray_1.vectorToArrayViewF64)(xValues, this.webAssemblyContext);
            var yView = (0, vectorToArray_1.vectorToArrayViewF64)(yValues, this.webAssemblyContext);
            var paletteView = (0, vectorToArray_1.vectorToArrayViewUi32)(this.palettingState.palettedColors, this.webAssemblyContext);
            var paletteIndex = 0;
            var dsCount = dataSeries.count();
            for (var index = startIndex; index < startIndex + count; index++) {
                var originalDataIndex = hasPSIndexes ? indexView[index] : index;
                if (originalDataIndex < 0)
                    originalDataIndex = 0;
                else if (originalDataIndex >= dsCount)
                    originalDataIndex = dsCount - 1;
                var xValue = xView[index];
                var yValue = yValues ? yView[index] : undefined;
                var overriddenColors = this.overridePaletteProviderColors(this.parentSeries, xValue, yValue, originalDataIndex, opacity, dataSeries.getMetadataAt(originalDataIndex), otherValues);
                //const overriddenColors = { stroke: undefined, fill: undefined } as TPointMarkerArgb;
                var overrideStrokeColor = (_e = overriddenColors.stroke) !== null && _e !== void 0 ? _e : strokeColor;
                var overrideFillColor = (_f = overriddenColors.fill) !== null && _f !== void 0 ? _f : fillColor;
                //this.palettingState.palettedColors.push_back(overrideStrokeColor);
                //this.palettingState.palettedColors.push_back(overrideFillColor);
                paletteView[paletteIndex] = (0, colorUtil_1.uintArgbColorToAbgr)(overrideStrokeColor);
                paletteIndex++;
                paletteView[paletteIndex] = (0, colorUtil_1.uintArgbColorToAbgr)(overrideFillColor);
                paletteIndex++;
                if (usePalette) {
                    hashCode = (0, number_1.numericHashCode)(hashCode, overrideStrokeColor);
                    hashCode = (0, number_1.numericHashCode)(hashCode, overrideFillColor);
                }
            }
            // Palette is used only for band and mountain series
            if (usePalette) {
                if (this.palettingState.palettedColorsHashCode !== hashCode) {
                    this.palettingState.paletteTextureCache.reset();
                }
                this.palettingState.paletteTextureCache.create(this.palettingState.palettedColors);
                this.palettingState.palettedColorsHashCode = hashCode;
            }
            this.palettingState.requiresUpdate = false;
        }
        else {
            this.palettingState.paletteTextureCache.reset();
            (_g = this.palettingState.palettedColors) === null || _g === void 0 ? void 0 : _g.clear();
        }
        // Due to pass-by-pointer limitations of WASM binding, we pass an empty vector rather than null
        if (!this.palettingState.palettedColors) {
            this.palettingState.palettedColors = new this.webAssemblyContext.UIntVector();
        }
        // Set gradient for the fill color
        this.palettingState.gradientPaletting = this.isGradientFillPaletting(this.parentSeries);
        performance_1.PerformanceDebugHelper.mark(performance_1.EPerformanceMarkType.PaletteProviderEnd, {
            contextId: this.parentSeries.id,
            parentContextId: (_h = this.parentSeries.parentSurface) === null || _h === void 0 ? void 0 : _h.id,
            relatedId: (_j = mark === null || mark === void 0 ? void 0 : mark.detail) === null || _j === void 0 ? void 0 : _j.relatedId,
            level: performance_1.EPerformanceDebugLevel.Verbose
        });
    };
    /**
     * Creates a native {@link SCRTBrush} Solid Color Brush from html color code string passed in
     * @param htmlColorCode The HTML Color code
     * @param opacity The opacity factor
     */
    BaseSeriesDrawingProvider.prototype.createSolidBrush = function (htmlColorCode, opacity) {
        return (0, createSolidBrush_1.createSolidBrush)(this.webAssemblyContext, htmlColorCode, opacity);
    };
    /**
     * @inheritDoc
     */
    BaseSeriesDrawingProvider.prototype.delete = function () {
        var _a;
        if (this.palettingState.palettedColors) {
            this.palettingState.palettedColors = (0, Deleter_1.deleteSafe)(this.palettingState.palettedColors);
        }
        this.palettingState.paletteTextureCache = (0, Deleter_1.deleteSafe)(this.palettingState.paletteTextureCache);
        this.parentDataSeries = this.parentSeries.dataSeries;
        (_a = this.parentDataSeries) === null || _a === void 0 ? void 0 : _a.dataChanged.unsubscribe(this.seriesHasDataChanges);
    };
    /**
     * @inheritDoc
     */
    BaseSeriesDrawingProvider.prototype.onSeriesPropertyChange = function (propertyName) {
        var _a, _b;
        if (propertyName === constants_1.PROPERTY.DATA_SERIES) {
            (_a = this.parentDataSeries) === null || _a === void 0 ? void 0 : _a.dataChanged.unsubscribe(this.seriesHasDataChanges);
            this.parentDataSeries = this.parentSeries.dataSeries;
            (_b = this.parentDataSeries) === null || _b === void 0 ? void 0 : _b.dataChanged.subscribe(this.seriesHasDataChanges);
            this.palettingState.requiresUpdate = true;
        }
    };
    /**
     * @inheritDoc
     */
    BaseSeriesDrawingProvider.prototype.onDpiChanged = function (args) {
        // Override in derived class to be notified of Dpi changes
    };
    /**
     * @inheritDoc
     */
    BaseSeriesDrawingProvider.prototype.onAttachSeries = function () {
        // Override in derived class to be notified of series being attached to sciChartSurface
    };
    /**
     * @inheritDoc
     */
    BaseSeriesDrawingProvider.prototype.onDetachSeries = function () {
        // Override in derived class to be notified of series being detached from sciChartSurface
    };
    /** A hook so derived classes can change the args */
    BaseSeriesDrawingProvider.prototype.updateArgs = function (renderPassData) { };
    BaseSeriesDrawingProvider.prototype.seriesHasDataChanges = function () {
        this.palettingState.requiresUpdate = true;
        // TODO override in derived class.
    };
    BaseSeriesDrawingProvider.prototype.shouldUpdatePalette = function (renderPassData, paletteProvider, startIndex, count, isDoubled) {
        var _a, _b, _c, _d, _e, _f;
        if (((_a = renderPassData === null || renderPassData === void 0 ? void 0 : renderPassData.pointSeries) === null || _a === void 0 ? void 0 : _a.resampled) &&
            (renderPassData === null || renderPassData === void 0 ? void 0 : renderPassData.resamplingHash) !== this.palettingState.lastResamplingHash) {
            this.palettingState.lastResamplingHash = renderPassData === null || renderPassData === void 0 ? void 0 : renderPassData.resamplingHash;
            this.palettingState.requiresUpdate = true;
        }
        if (!((_b = paletteProvider.isRangeIndependant) !== null && _b !== void 0 ? _b : false)) {
            // Range dependant (the default) so recalculate if start and count have changed
            if (((_c = this.palettingState.lastStartIndex) !== null && _c !== void 0 ? _c : 0) !== startIndex ||
                ((_d = this.palettingState.lastCount) !== null && _d !== void 0 ? _d : 0) !== count) {
                this.palettingState.lastStartIndex = startIndex;
                this.palettingState.lastCount = count;
                this.palettingState.requiresUpdate = true;
                this.palettingState.paletteStartIndex = 0;
            }
        }
        else {
            if (((_e = this.palettingState.lastStartIndex) !== null && _e !== void 0 ? _e : Number.MAX_SAFE_INTEGER) > startIndex ||
                ((_f = this.palettingState.lastCount) !== null && _f !== void 0 ? _f : 0) < count ||
                startIndex + count > this.palettingState.lastStartIndex + this.palettingState.lastCount) {
                // Range has grown so recalcualte and start from 0
                this.palettingState.lastStartIndex = startIndex;
                this.palettingState.lastCount = count;
                this.palettingState.requiresUpdate = true;
                this.palettingState.paletteStartIndex = 0;
            }
            else {
                // Range is same or smaller so adjust palette startIndex
                this.palettingState.paletteStartIndex =
                    startIndex * (isDoubled ? 2 : 1) - this.palettingState.lastStartIndex;
            }
        }
        // Default to always update for back compatability
        if (!paletteProvider.shouldUpdatePalette || paletteProvider.shouldUpdatePalette()) {
            this.palettingState.requiresUpdate = true;
        }
    };
    BaseSeriesDrawingProvider.prototype.overridePaletteProviderColors = function (rs, xValue, yValue, index, opacity, metadata, otherValues) {
        var stroke;
        var fill;
        if (rs.hasStrokePaletteProvider()) {
            var strokePaletteProvider = rs.paletteProvider;
            stroke = strokePaletteProvider.overrideStrokeArgb(xValue, yValue, index, opacity, metadata, otherValues);
        }
        if (rs.hasFillPaletteProvider()) {
            var fillPaletteProvider = rs.paletteProvider;
            fill = fillPaletteProvider.overrideFillArgb(xValue, yValue, index, opacity, metadata, otherValues);
        }
        return { stroke: stroke, fill: fill };
    };
    BaseSeriesDrawingProvider.prototype.isGradientFillPaletting = function (rs) {
        if (rs.hasFillPaletteProvider()) {
            var fillPaletteProvider = rs.paletteProvider;
            return fillPaletteProvider.fillPaletteMode === IPaletteProvider_1.EFillPaletteMode.GRADIENT;
        }
        return false;
    };
    return BaseSeriesDrawingProvider;
}(DeletableEntity_1.DeletableEntity));
exports.BaseSeriesDrawingProvider = BaseSeriesDrawingProvider;
