/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends, __values } from "tslib";
import { HorizontalRangeCategorySeries } from "./HorizontalRangeCategorySeries";
import { DependencyProperty } from "igniteui-react-core";
import { Defaults } from "./Defaults";
import { typeCast, runOn, markType, markDep, fromEnum } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { List$1 } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { Rectangle } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_, isInfinity } from "igniteui-react-core";
import { RangeCategorySeriesView } from "./RangeCategorySeriesView";
/**
 * @hidden
 */
var RangeColumnSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RangeColumnSeries, _super);
    function RangeColumnSeries() {
        var _this = _super.call(this) || this;
        _this.ab = RangeColumnSeries.$;
        return _this;
    }
    RangeColumnSeries.prototype.bc = function () {
        return new RangeColumnSeries();
    };
    RangeColumnSeries.prototype.get_ee = function () {
        return true;
    };
    RangeColumnSeries.prototype.get_ez = function () {
        return true;
    };
    RangeColumnSeries.prototype.iq = function () {
        if (!isNaN_(this.ip)) {
            return _super.prototype.iq.call(this);
        }
        return Defaults.h;
    };
    RangeColumnSeries.prototype.cd = function () {
        return new RangeColumnSeriesView(this);
    };
    RangeColumnSeries.prototype.o2 = function (a) {
        _super.prototype.o2.call(this, a);
        this.ym = a;
    };
    RangeColumnSeries.prototype.get_dv = function () {
        return true;
    };
    RangeColumnSeries.prototype.preferredCategoryMode = function (a) {
        return 2;
    };
    RangeColumnSeries.prototype.tu = function (a) {
        if (this.xAxis == null || this.yAxis == null) {
            return Rect.empty;
        }
        var b = this.te(a);
        var c = this.cg.by;
        var d = this.cg.bx;
        var e = this.getEffectiveViewport1(this.cg);
        var f = new ScalerParams(0, c, d, this.yAxis.ch, e);
        f.b = this.h3();
        var g = this.aj(this.vn(), this.vo.f, this.wp(this.cg), this.wq(this.cg), a, true);
        if (g == null) {
            return Rect.empty;
        }
        var h = g[0];
        var i = g[1];
        var j = Math.abs(b.x - h[0]);
        var k = Math.abs(b.x - i[0]);
        var l = this.xAxis.k4(c, d, e);
        if (j < k) {
            var m = h[0] - 0.5 * l;
            var n = h[1];
            var o = h[2];
            return new Rect(0, m, Math.min(n, o), l, Math.max(n, o) - Math.min(n, o));
        }
        else {
            var p = i[0] - 0.5 * l;
            var q = i[1];
            var r = i[2];
            return new Rect(0, p, Math.min(q, r), l, Math.max(q, r) - Math.min(q, r));
        }
    };
    RangeColumnSeries.prototype.f5 = function (a, b) {
        if (this.f8(a, b)) {
            return true;
        }
        if (this.uf(a, b)) {
            return true;
        }
        return false;
    };
    RangeColumnSeries.prototype.nk = function (a, b) {
        _super.prototype.nk.call(this, a, b);
        var c = b;
        if (a && c.c6 != null) {
            c.c6.count = 0;
        }
    };
    RangeColumnSeries.prototype.h1 = function () {
        return this.xAxis.k4(this.cg.by, this.cg.bx, this.getEffectiveViewport1(this.cg));
    };
    RangeColumnSeries.prototype.w7 = function (a, b) {
        _super.prototype.w7.call(this, a, b);
        var c = typeCast(RangeColumnSeriesView.$, b);
        var d = a.f;
        var e = b.by;
        var f = b.bx;
        var g = this.getEffectiveViewport1(b);
        var h = this.xAxis.k4(e, f, g);
        if (isNaN_(h) || isInfinity(h)) {
            c.c6.count = 0;
            return;
        }
        this.vw.a2(this, this.wg(), runOn(this, this.vh), this.wp(b), this.wq(b));
        this.vw.r = this.yn;
        this.vw.s = this.yo;
        this.vw.k = this.yn;
        this.vw.l = this.yo;
        var i = false;
        var j = this.vw.b;
        if (j != null) {
            i = true;
        }
        var k = this.xAxis.cn;
        var l = this.lowColumn.count;
        var m = this.xAxis;
        var n = new ScalerParams(0, e, f, this.xAxis.ch, g);
        var o = 0;
        for (var p = 0; p < d.count; ++p) {
            var q = d._inner[p][0] - 0.5 * h;
            var r = Math.min(d._inner[p][1], d._inner[p][2]);
            var s = Math.max(d._inner[p][1], d._inner[p][2]);
            var t = Math.abs(s - r);
            if (isInfinity(t) || isNaN_(t)) {
                continue;
            }
            var u = c.c6.item(o);
            o++;
            u.width = h;
            u.height = t;
            if (i) {
                this.w3(d, p, l, m, n, b.q);
            }
            this.vw.ad(u, false, false, false, false);
            u.ap = this.vw.k;
            u.aq = this.vw.l;
            c.db(u, q, r);
        }
        c.c6.count = o;
        b.c1(a);
    };
    Object.defineProperty(RangeColumnSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.wk;
        },
        enumerable: false,
        configurable: true
    });
    RangeColumnSeries.$t = markType(RangeColumnSeries, 'RangeColumnSeries', HorizontalRangeCategorySeries.$);
    RangeColumnSeries.$$p = markDep(DependencyProperty, PropertyMetadata, RangeColumnSeries, 'raisePropertyChanged', ['RadiusX:yn:yr', [1, 0], 'RadiusY:yo:ys', [1, 0]]);
    return RangeColumnSeries;
}(HorizontalRangeCategorySeries));
export { RangeColumnSeries };
/**
 * @hidden
 */
var RangeColumnSeriesView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(RangeColumnSeriesView, _super);
    function RangeColumnSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.c5 = null;
        _this.c6 = null;
        _this.c7 = null;
        _this.dc = new Rectangle();
        _this.c5 = a;
        _this.c6 = ((function () {
            var $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(_this, _this.dd);
            $ret.activate = runOn(_this, _this.c8);
            $ret.disactivate = runOn(_this, _this.da);
            $ret.destroy = runOn(_this, _this.c9);
            return $ret;
        })());
        return _this;
    }
    RangeColumnSeriesView.prototype.au = function () {
        _super.prototype.au.call(this);
        this.c7 = new List$1(Rectangle.$, 0);
        if (!this.q) {
            this.c5.uc = Defaults.c;
            this.c5.iv = Defaults.i;
        }
    };
    RangeColumnSeriesView.prototype.dd = function () {
        var a = new Rectangle();
        this.c7.add(a);
        a._visibility = 1;
        return a;
    };
    RangeColumnSeriesView.prototype.c8 = function (a) {
        a._visibility = 0;
    };
    RangeColumnSeriesView.prototype.da = function (a) {
        a._visibility = 1;
    };
    RangeColumnSeriesView.prototype.c9 = function (a) {
        this.c7.remove(a);
    };
    RangeColumnSeriesView.prototype.db = function (a, b, c) {
        if (!this.isDirty) {
            this.as();
        }
        a.o = c;
        a.n = b;
    };
    RangeColumnSeriesView.prototype.ac = function (a) {
        return this.c7._inner[a];
    };
    RangeColumnSeriesView.prototype.ab = function (a) {
        var b = this.c7._inner[a];
        this.dc._visibility = b._visibility;
        this.dc.n = b.n;
        this.dc.o = b.o;
        this.dc.width = b.width;
        this.dc.height = b.height;
        var c = this.bs(a);
        this.dc._fill = c;
        this.dc._stroke = c;
        this.dc.ad = this.e.hl + 3;
        return this.dc;
    };
    RangeColumnSeriesView.prototype.a8 = function (a, b) {
        _super.prototype.a8.call(this, a, b);
        if (a.d) {
            for (var c = 0; c < this.c7.count; c++) {
                var d = this.aa(c, b);
                this.bf(d, c, b);
                a.w(d);
            }
        }
    };
    RangeColumnSeriesView.prototype.an = function (a) {
        var e_1, _a, e_2, _b;
        _super.prototype.an.call(this, a);
        var b = 0;
        var c = new List$1(Rectangle.$, 0);
        try {
            for (var _c = __values(fromEnum(this.c6.a)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var d = _d.value;
                c.add(d);
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
        c.aa(function (e, f) {
            if (e.n < f.n) {
                return -1;
            }
            else if (e.n > f.n) {
                return 1;
            }
            else {
                return 0;
            }
        });
        try {
            for (var _e = __values(fromEnum(c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var e = _f.value;
                this.e.a5.exportRectangleData(a, e, "column" + b, ["Main", "Fill"]);
            }
        }
        catch (e_2_1) {
            e_2 = { error: e_2_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_2)
                    throw e_2.error;
            }
        }
        b++;
    };
    RangeColumnSeriesView.$t = markType(RangeColumnSeriesView, 'RangeColumnSeriesView', RangeCategorySeriesView.$);
    return RangeColumnSeriesView;
}(RangeCategorySeriesView));
export { RangeColumnSeriesView };
