"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.PolarHeatMapDataLabelProvider = void 0;
var Point_1 = require("../../../../../Core/Point");
var ECoordinateMode_1 = require("../../../Annotations/types/ECoordinateMode");
var annotationHelpers_1 = require("../../../Annotations/annotationHelpers");
var PolarLabelMode_1 = require("../../../Axis/Polar/types/PolarLabelMode");
var labelHelper_1 = require("../../../Helpers/labelHelper");
var DpiHelper_1 = require("../../../TextureManager/DpiHelper");
var HeatMapDataLabelProvider_1 = require("../../DataLabels/HeatMapDataLabelProvider");
var PolarHeatMapDataLabelProvider = /** @class */ (function (_super) {
    __extends(PolarHeatMapDataLabelProvider, _super);
    function PolarHeatMapDataLabelProvider(options) {
        var _this = this;
        var _a;
        _this = _super.call(this, options) || this;
        _this.polarLabelModeProperty = PolarLabelMode_1.EPolarLabelMode.Horizontal;
        _this.polarLabelModeProperty = (_a = options === null || options === void 0 ? void 0 : options.polarLabelMode) !== null && _a !== void 0 ? _a : _this.polarLabelModeProperty;
        return _this;
    }
    Object.defineProperty(PolarHeatMapDataLabelProvider.prototype, "polarLabelMode", {
        /**
         * Gets or sets polar label mode to use for calculating data label rotation. Default Horizontal
         * For a list of value, see {@link EPolarLabelMode}
         */
        get: function () {
            return this.polarLabelModeProperty;
        },
        set: function (value) {
            this.polarLabelModeProperty = value;
            this.invalidateParent();
        },
        enumerable: false,
        configurable: true
    });
    PolarHeatMapDataLabelProvider.prototype.shouldGenerate = function (textSize, cellWidth, cellHeight) {
        return true;
    };
    PolarHeatMapDataLabelProvider.prototype.shouldSkipLabel = function (xIndex, yIndex, label, cellWidth, cellHeight) {
        return false;
    };
    PolarHeatMapDataLabelProvider.prototype.toCartesian = function (angle, radius) {
        var xAxis = this.parentSeries.xAxis;
        return annotationHelpers_1.annotationHelpers.convertPolarToCartesian(xAxis, false, this.parentSeries.parentSurface.webAssemblyContext2D, ECoordinateMode_1.ECoordinateMode.Pixel, angle * DpiHelper_1.DpiHelper.PIXEL_RATIO, radius);
    };
    PolarHeatMapDataLabelProvider.prototype.getPosition = function (xIndex, yIndex, xVal, yVal, textSize, cellWidth, cellHeight, renderPassData) {
        var rs = this.parentSeries;
        var angularAxis = (renderPassData.isVerticalChart ? rs.yAxis : rs.xAxis);
        var xCoord = renderPassData.xCoordinateCalculator.getCoordinate(xVal);
        var xDirection = renderPassData.xCoordinateCalculator.hasFlippedCoordinates ? -1 : 1;
        xCoord -= (xDirection * cellWidth) / 2;
        var yCoord = renderPassData.yCoordinateCalculator.getCoordinate(yVal);
        var yDirection = renderPassData.yCoordinateCalculator.hasFlippedCoordinates ? -1 : 1;
        yCoord -= (yDirection * cellHeight) / 2;
        var angle = renderPassData.isVerticalChart ? yCoord : xCoord;
        var radius = renderPassData.isVerticalChart ? xCoord : yCoord;
        var _a = this.toCartesian(angle, radius), x = _a.x, y = _a.y;
        var rotationCenter = new Point_1.Point(x, y);
        x -= textSize.width / 2;
        y += textSize.height / 2;
        var rotationAngle = labelHelper_1.labelHelper.getPolarLabelRotation(this.polarLabelMode, angularAxis.startAngle + angle);
        return { position: new Point_1.Point(x, y), rotationCenter: rotationCenter, rotationAngle: rotationAngle };
    };
    Object.defineProperty(PolarHeatMapDataLabelProvider.prototype, "useRotation", {
        get: function () {
            return this.polarLabelMode !== PolarLabelMode_1.EPolarLabelMode.Horizontal;
        },
        enumerable: false,
        configurable: true
    });
    return PolarHeatMapDataLabelProvider;
}(HeatMapDataLabelProvider_1.HeatMapDataLabelProvider));
exports.PolarHeatMapDataLabelProvider = PolarHeatMapDataLabelProvider;
