"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.PolarCategoryAxis = void 0;
var NumberRange_1 = require("../../../../Core/NumberRange");
var AxisType_1 = require("../../../../types/AxisType");
var PolarTickCoordinatesProvider_1 = require("../../../Numerics/TickCoordinateProviders/PolarTickCoordinatesProvider");
var NumericTickProvider_1 = require("../../../Numerics/TickProviders/NumericTickProvider");
var CategoryAxis_1 = require("../CategoryAxis");
var CategoryDeltaCalculator_1 = require("../DeltaCalculator/CategoryDeltaCalculator");
var DateLabelProvider_1 = require("../LabelProvider/DateLabelProvider");
var TextLabelProvider_1 = require("../LabelProvider/TextLabelProvider");
var PolarAxisBase_1 = require("./PolarAxisBase");
/**
 * @summary A 2D Chart Category Axis type for use with Polar Charts.
 * @description A category axis uses the X-index not the X-value to measure data-points on the XAxis.
 * For example this can be used in stock chart applications to ensure weekend or overnight gaps are collapsed
 * and each data-point is spaced equidistantly
 * @remarks
 * Set a {@link PolarCategoryAxis} on the {@link SciChartPolarSurface.xAxes} or {@link SciChartPolarSurface.yAxes} property.
 *
 * ---
 * 📚 Docs: {@link https://www.scichart.com/documentation/js/v4/2d-charts/axis-api/axis-types/polar-category-axis/}
 */
var PolarCategoryAxis = /** @class */ (function (_super) {
    __extends(PolarCategoryAxis, _super);
    /**
     * Creates an instance of a {@link PolarCategoryAxis}
     * @param webAssemblyContext The {@link TSciChart | SciChart 2D WebAssembly Context} containing native methods and
     * access to our WebGL2 Engine and WebAssembly numerical methods
     * @param options Optional parameters of type {@link IPolarCategoryAxisOptions} used to configure the axis at instantiation time
     *
     * ---
     * 📚 Docs: {@link https://www.scichart.com/documentation/js/v4/2d-charts/axis-api/axis-types/polar-category-axis/}
     */
    function PolarCategoryAxis(webAssemblyContext, options) {
        var _this = this;
        var _a, _b, _c;
        _this = _super.call(this, webAssemblyContext, options) || this;
        _this.type = AxisType_1.EAxisType.PolarCategoryAxis;
        _this.defaultXValuesProperty = [];
        _this.defaultXStartProperty = 0;
        _this.defaultXStepProperty = 1;
        _this.defaultXValuesProperty = (_a = options === null || options === void 0 ? void 0 : options.defaultXValues) !== null && _a !== void 0 ? _a : _this.defaultXValuesProperty;
        _this.defaultXStartProperty = (_b = options === null || options === void 0 ? void 0 : options.defaultXStart) !== null && _b !== void 0 ? _b : _this.defaultXStartProperty;
        _this.defaultXStepProperty = (_c = options === null || options === void 0 ? void 0 : options.defaultXStep) !== null && _c !== void 0 ? _c : _this.defaultXStepProperty;
        _this.tickProvider = new NumericTickProvider_1.NumericTickProvider(_this.webAssemblyContext2D);
        _this.deltaCalculator = new CategoryDeltaCalculator_1.CategoryDeltaCalculator(_this.webAssemblyContext2D);
        _this.defaultBaseXValues = new _this.webAssemblyContext2D.SCRTDoubleVector();
        _this.tickCoordinatesProvider = new PolarTickCoordinatesProvider_1.PolarTickCoordinatesProvider();
        if (options === null || options === void 0 ? void 0 : options.labelProvider) {
            _this.labelProvider = options === null || options === void 0 ? void 0 : options.labelProvider;
        }
        else if (options === null || options === void 0 ? void 0 : options.labels) {
            _this.labelProvider = new TextLabelProvider_1.TextLabelProvider(options);
        }
        else {
            _this.labelProvider = new DateLabelProvider_1.DateLabelProvider(options);
        }
        return _this;
    }
    Object.defineProperty(PolarCategoryAxis.prototype, "isCategoryAxis", {
        /** @inheritDoc */
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PolarCategoryAxis.prototype, "defaultXValues", {
        /**
         * The default x values to use if no series or data is added to the chart.
         * The tick values shown will depend on the visible range, which for category axis is by index, not by value.
         * eg if you want default values [10, 20, 30, 40] you would need to set visibleRange: new NumberRange(0,3)
         * By default it will start at 0 and increment by 1, up to the size of the visible range.
         * To change the start and step set defaultXStart and defaultXStep
         */
        get: function () {
            return this.defaultXValuesProperty;
        },
        /**
         * The default x values to use if no series or data is added to the chart.
         * The tick values shown will depend on the visible range, which for category axis is by index, not by value.
         * eg if you want default values [10, 20, 30, 40] you would need to set visibleRange: new NumberRange(0,3)
         * By default it will start at 0 and increment by 1, up to the size of the visible range.
         * To change the start and step set defaultXStart and defaultXStep
         */
        set: function (values) {
            this.defaultXValuesProperty = values;
            if (this.invalidateParentCallback)
                this.invalidateParentCallback();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PolarCategoryAxis.prototype, "defaultXStart", {
        /**
         * The starting value for default x values.  See defaultXValues
         */
        get: function () {
            return this.defaultXStartProperty;
        },
        /**
         * The starting value for default x values.  See defaultXValues
         */
        set: function (value) {
            this.defaultXStartProperty = value;
            if (this.invalidateParentCallback)
                this.invalidateParentCallback();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PolarCategoryAxis.prototype, "defaultXStep", {
        /**
         * The step size for default x values.  See defaultXValues
         */
        get: function () {
            return this.defaultXStepProperty;
        },
        /**
         * The step size for default x values.  See defaultXValues
         */
        set: function (value) {
            this.defaultXStepProperty = value;
            if (this.invalidateParentCallback)
                this.invalidateParentCallback();
        },
        enumerable: false,
        configurable: true
    });
    /** @inheritDoc */
    PolarCategoryAxis.prototype.prepareRenderData = function () {
        CategoryAxis_1.CategoryAxis.prototype.prepareRenderData.call(this);
    };
    /** @inheritDoc */
    PolarCategoryAxis.prototype.delete = function () {
        _super.prototype.delete.call(this);
        CategoryAxis_1.CategoryAxis.prototype.delete.call(this);
    };
    /** @inheritDoc */
    PolarCategoryAxis.prototype.getCurrentCoordinateCalculatorInternal = function () {
        // @ts-ignore
        return CategoryAxis_1.CategoryAxis.prototype.getCurrentCoordinateCalculatorInternal.call(this);
    };
    /** @inheritDoc */
    PolarCategoryAxis.prototype.getXDataRange = function () {
        var maxRange;
        if (this.parentSurface) {
            this.getVisibleRenderableSeriesByXAxis().forEach(function (rSeries) {
                // using indices instead of xValues
                var indicesCount = rSeries.getDataSeriesValuesCount();
                // No extra value for polar
                var xRange = new NumberRange_1.NumberRange(0, indicesCount - 1);
                if (xRange) {
                    maxRange = !maxRange ? xRange : maxRange.union(xRange);
                }
            });
        }
        return maxRange;
    };
    PolarCategoryAxis.prototype.getMaxAutoTicks = function () {
        // @ts-ignore
        return CategoryAxis_1.CategoryAxis.prototype.getMaxAutoTicks.call(this);
    };
    PolarCategoryAxis.prototype.generateDefaultXValuesForCategoryAxis = function (defaultXStart, defaultXStep) {
        // @ts-ignore
        return CategoryAxis_1.CategoryAxis.prototype.generateDefaultXValuesForCategoryAxis.call(this, defaultXStart, defaultXStep);
    };
    PolarCategoryAxis.prototype.updateBaseXValues = function (coordCalc) {
        // @ts-ignore
        return CategoryAxis_1.CategoryAxis.prototype.updateBaseXValues.call(this, coordCalc);
    };
    return PolarCategoryAxis;
}(PolarAxisBase_1.PolarAxisBase));
exports.PolarCategoryAxis = PolarCategoryAxis;
