"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 __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PolarColumnRenderableSeries = void 0;
var SeriesType_1 = require("../../../../types/SeriesType");
var BaseRenderableSeries_1 = require("../BaseRenderableSeries");
var PointMarkerDrawingProvider_1 = require("../DrawingProviders/PointMarkerDrawingProvider");
var PolarColumnSeriesDrawingProvider_1 = require("./DrawingProviders/PolarColumnSeriesDrawingProvider");
var ColumnMode_1 = require("../../../../types/ColumnMode");
var DataPointWidthMode_1 = require("../../../../types/DataPointWidthMode");
var PolarColumnSeriesDataLabelProvider_1 = require("./DataLabels/PolarColumnSeriesDataLabelProvider");
var FastRectangleRenderableSeries_1 = require("../FastRectangleRenderableSeries");
var RectangleSeriesHitTestProvider_1 = require("../HitTest/RectangleSeriesHitTestProvider");
var constants_1 = require("../constants");
/**
 * Defines a JavaScript Polar Column-series chart type in the SciChart's High Performance Real-time
 * {@link https://www.scichart.com/javascript-chart-features | JavaScript Charts}
 * @remarks
 * To add a polar column series to a {@link SciChartPolarSurface} you need to declare both the {@link PolarColumnRenderableSeries | RenderableSeries}
 * and a {@link XyDataSeries | DataSeries}. Simplified code sample below:
 *
 * ```ts
 * const { sciChartSurface, wasmContext } = SciChartPolarSurface.create(rootId);
 *
 * // Create the renderableSeries
 * const polarColumnSeries = new PolarColumnRenderableSeries(wasmContext, {
 *    dataSeries: XyDataSeries(wasmContext, {
 *       xValues: [0, 1, 2, 3],
 *       yValues: [10, 20, 30, 40],
 *    }),
 *    stroke: "blue",
 * });
 *
 * // append to the SciChartSurface
 * sciChartPolarSurface.renderableSeries.add(polarColumnSeries);
 * ```
 *
 * ---
 * 📚 Docs: {@link https://www.scichart.com/documentation/js/v4/2d-charts/chart-types/polar-column-renderable-series/}
 */
var PolarColumnRenderableSeries = /** @class */ (function (_super) {
    __extends(PolarColumnRenderableSeries, _super);
    /**
     * Creates an instance of the {@link PolarColumnRenderableSeries}
     * @param webAssemblyContext The {@link TSciChart | SciChart WebAssembly Context} containing
     * native methods and access to our WebGL2 WebAssembly Drawing Engine
     * @param options optional parameters of type {@link IPolarColumnRenderableSeriesOptions} applied when constructing the series type
     *
     * ---
     * 📚 Docs: {@link https://www.scichart.com/documentation/js/v4/2d-charts/chart-types/polar-column-renderable-series/}
     */
    function PolarColumnRenderableSeries(webAssemblyContext, options) {
        var _this = this;
        var _a, _b, _c;
        _this = _super.call(this, webAssemblyContext, __assign(__assign({}, options), { dataLabelProvider: (_a = options === null || options === void 0 ? void 0 : options.dataLabelProvider) !== null && _a !== void 0 ? _a : new PolarColumnSeriesDataLabelProvider_1.PolarColumnSeriesDataLabelProvider(options === null || options === void 0 ? void 0 : options.dataLabels) })) || this;
        /** @inheritDoc */
        _this.type = SeriesType_1.ESeriesType.PolarColumnSeries;
        _this.isPolar = true;
        // Must be called here for the series type to be available
        if ((_b = _this.paletteProvider) === null || _b === void 0 ? void 0 : _b.onAttached) {
            (_c = _this.paletteProvider) === null || _c === void 0 ? void 0 : _c.onAttached(_this);
        }
        return _this;
    }
    Object.defineProperty(PolarColumnRenderableSeries.prototype, "defaultY1", {
        /**
         * Gets or Sets zero line. Default 0
         */
        get: function () {
            return this.defaultY1Property;
        },
        set: function (value) {
            this.defaultY1Property = value;
            this.notifyPropertyChanged(constants_1.PROPERTY.DEFAULT_Y1);
        },
        enumerable: false,
        configurable: true
    });
    /** @inheritDoc */
    PolarColumnRenderableSeries.prototype.addDrawingProviders = function (webAssemblyContext, options) {
        this.drawingProviders.push(new PolarColumnSeriesDrawingProvider_1.PolarColumnSeriesDrawingProvider(webAssemblyContext, this));
        this.drawingProviders.push(new PointMarkerDrawingProvider_1.PointMarkerDrawingProvider(webAssemblyContext, this));
    };
    /** @inheritDoc */
    PolarColumnRenderableSeries.prototype.toJSON = function (excludeData) {
        if (excludeData === void 0) { excludeData = false; }
        var json = _super.prototype.toJSON.call(this, excludeData);
        var options = {};
        Object.assign(json.options, options);
        return json;
    };
    /** @inheritDoc */
    PolarColumnRenderableSeries.prototype.getDataPointWidth = function (xCoordCalc, widthFraction, widthMode) {
        var xValues = this.dataSeries.getNativeXValues();
        var seriesViewRectWidth = xCoordCalc.viewportDimension;
        var isCategoryAxis = xCoordCalc.isCategoryCoordinateCalculator;
        if (widthMode === DataPointWidthMode_1.EDataPointWidthMode.Range) {
            var range = xCoordCalc.visibleMax - xCoordCalc.visibleMin;
            // This treats dataPointWidth as "xRange per column"
            return (xCoordCalc.viewportDimension / range) * widthFraction;
        }
        else if (widthMode === DataPointWidthMode_1.EDataPointWidthMode.Absolute) {
            return widthFraction;
        }
        else {
            // Relative
            return (0, BaseRenderableSeries_1.getDataPointWidth)(xValues, xCoordCalc, seriesViewRectWidth, widthFraction, isCategoryAxis, this.dataSeries.dataDistributionCalculator.isSortedAscending, this.webAssemblyContext);
        }
    };
    Object.defineProperty(PolarColumnRenderableSeries.prototype, "columnYMode", {
        /** @inheritDoc */
        get: function () {
            return ColumnMode_1.EColumnYMode.TopBottom;
        },
        /**
         * Setting columnYMode is not supported for PolarColumnRenderableSeries
         */
        set: function (value) {
            throw Error("columnYMode is not supported for PolarColumnRenderableSeries");
        },
        enumerable: false,
        configurable: true
    });
    /** @inheritDoc */
    PolarColumnRenderableSeries.prototype.newHitTestProvider = function () {
        return new RectangleSeriesHitTestProvider_1.RectangleSeriesHitTestProvider(this, this.webAssemblyContext);
    };
    return PolarColumnRenderableSeries;
}(FastRectangleRenderableSeries_1.FastRectangleRenderableSeries));
exports.PolarColumnRenderableSeries = PolarColumnRenderableSeries;
