"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.PolarHeatmapDrawingProvider = void 0;
var UniformHeatmapDrawingProvider_1 = require("../../DrawingProviders/UniformHeatmapDrawingProvider");
var PolarHeatmapDrawingProvider = /** @class */ (function (_super) {
    __extends(PolarHeatmapDrawingProvider, _super);
    function PolarHeatmapDrawingProvider() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    /**
     * @inheritDoc
     */
    PolarHeatmapDrawingProvider.prototype.draw = function (renderContext, renderPassData) {
        var _a, _b, _c;
        var heatTexture = (_a = this.heatTextureCache) === null || _a === void 0 ? void 0 : _a.value;
        if (heatTexture) {
            var dataSeries = this.parentSeries.dataSeries;
            var xStartValue = dataSeries.xStart;
            var xStartCoord = renderPassData.xCoordinateCalculator.getCoordinate(xStartValue);
            var zSizeOnX = (_c = (_b = dataSeries.getZValues()[0]) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
            var xEndValue = xStartValue + dataSeries.xStep * zSizeOnX;
            var xEndCoord = renderPassData.xCoordinateCalculator.getCoordinate(xEndValue);
            var zValuesVector = dataSeries.getNormalizedVector(this.parentSeries.colorMap, this.parentSeries.fillValuesOutOfRange);
            this.packedFloatParams = this.webAssemblyContext.SCRTFillTextureFloat32(heatTexture, dataSeries.arrayWidth, dataSeries.arrayHeight, zValuesVector);
            this.packedFloatParams.x = 0;
            this.packedFloatParams.y = 1;
            var yRange = dataSeries.yRange;
            var innerRadius = renderPassData.yCoordinateCalculator.getCoordinate(yRange.min);
            var outerRadius = renderPassData.yCoordinateCalculator.getCoordinate(yRange.max);
            // const totalAngle = renderPassData.xCoordinateCalculator.viewportDimension;
            var nativeContext = renderContext.getNativeContext();
            // Draw the heatmap at the specified locations
            // TODO: figure out what todo with this TSRVector4
            var v4 = this.packedFloatParams;
            var contourParams = new this.webAssemblyContext.SCRTContourParams();
            var nativeDrawingProvider = new this.webAssemblyContext.SCRTHeatmapSeriesDrawingProvider();
            this.recreatePalette();
            var axis = this.parentSeries.xAxis;
            var polarTransform = axis.getTransform();
            nativeDrawingProvider.DrawPolarHeatmap(polarTransform, innerRadius, outerRadius, xStartCoord, this.paletteTexture.getTexture(), // this.paletteTexture.getTexture
            heatTexture, v4, contourParams, xEndCoord);
            contourParams.delete();
            v4.delete();
        }
    };
    return PolarHeatmapDrawingProvider;
}(UniformHeatmapDrawingProvider_1.UniformHeatmapDrawingProvider));
exports.PolarHeatmapDrawingProvider = PolarHeatmapDrawingProvider;
