"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.PolarDataLabelState = void 0;
var ECoordinateMode_1 = require("../../../Annotations/types/ECoordinateMode");
var annotationHelpers_1 = require("../../../Annotations/annotationHelpers");
var DpiHelper_1 = require("../../../TextureManager/DpiHelper");
var DataLabelState_1 = require("../../DataLabels/DataLabelState");
var PolarDataLabelState = /** @class */ (function (_super) {
    __extends(PolarDataLabelState, _super);
    function PolarDataLabelState() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PolarDataLabelState.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);
    };
    PolarDataLabelState.prototype.xCoord = function (index) {
        this.updateCache(index);
        return this.cartesianCache.x;
    };
    PolarDataLabelState.prototype.yCoord = function (index) {
        this.updateCache(index);
        return this.cartesianCache.y;
    };
    PolarDataLabelState.prototype.angleCoord = function (index) {
        return _super.prototype.xCoord.call(this, index);
    };
    PolarDataLabelState.prototype.radiusCoord = function (index) {
        return _super.prototype.yCoord.call(this, index);
    };
    PolarDataLabelState.prototype.updateCache = function (index) {
        var ind = index !== null && index !== void 0 ? index : this.index;
        if (!this.cartesianCache || this.cartesianCache.index !== ind) {
            var polarX = _super.prototype.xCoord.call(this);
            var polarY = _super.prototype.yCoord.call(this);
            var _a = this.toCartesian(polarX, polarY), x = _a.x, y = _a.y;
            this.cartesianCache = { index: ind, x: x, y: y };
        }
    };
    return PolarDataLabelState;
}(DataLabelState_1.DataLabelState));
exports.PolarDataLabelState = PolarDataLabelState;
