/*
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 * as tslib_1 from "tslib";
import { HorizontalRangeCategorySeries } from "./HorizontalRangeCategorySeries";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { Type, typeCast, runOn, markType, fromEnum } from "igniteui-react-core/ES5/type";
import { Rect } from "igniteui-react-core/ES5/Rect";
import { ScalerParams } from "./ScalerParams";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Pool$1 } from "igniteui-react-core/ES5/Pool$1";
import { Rectangle } from "igniteui-react-core/ES5/Rectangle";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { isNaN_, isInfinity } from "igniteui-react-core/ES5/number";
import { RangeCategorySeriesView } from "./RangeCategorySeriesView";
/**
 * @hidden
 */
var RangeColumnSeries = /** @class */ (function (_super) {
    tslib_1.__extends(RangeColumnSeries, _super);
    function RangeColumnSeries() {
        var _this = _super.call(this) || this;
        _this.ab = RangeColumnSeries.$;
        return _this;
    }
    RangeColumnSeries.prototype.bf = function () {
        return new RangeColumnSeriesView(this);
    };
    RangeColumnSeries.prototype.im = function (a) {
        _super.prototype.im.call(this, a);
        this.pc = a;
    };
    RangeColumnSeries.prototype.get_no = function () {
        return true;
    };
    RangeColumnSeries.prototype.preferredCategoryMode = function (a) {
        return 2;
    };
    RangeColumnSeries.prototype.ln = function (a) {
        if (this.xAxis == null || this.yAxis == null) {
            return Rect.empty;
        }
        var b = this.k9(a);
        var c = this.bi.bs;
        var d = this.bi.br;
        var e = this.getEffectiveViewport1(this.bi);
        var f = new ScalerParams(0, c, d, this.yAxis.b8, e);
        f.b = this.ee();
        var g = this.aj(this.mz(), this.m0.f, this.n0(this.bi), this.n1(this.bi), 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.jk(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.dg = function (a, b) {
        if (this.dj(a, b)) {
            return true;
        }
        if (this.lx(a, b)) {
            return true;
        }
        return false;
    };
    RangeColumnSeries.prototype.hp = function (a, b) {
        _super.prototype.hp.call(this, a, b);
        var c = b;
        if (a && c.cz != null) {
            c.cz.count = 0;
        }
    };
    RangeColumnSeries.prototype.ed = function () {
        return this.xAxis.jk(this.bi.bs, this.bi.br, this.getEffectiveViewport1(this.bi));
    };
    RangeColumnSeries.prototype.oh = function (a, b) {
        _super.prototype.oh.call(this, a, b);
        var c = typeCast(RangeColumnSeriesView.$, b);
        var d = a.f;
        var e = b.bs;
        var f = b.br;
        var g = this.getEffectiveViewport1(b);
        var h = this.xAxis.jk(e, f, g);
        if (isNaN_(h) || isInfinity(h)) {
            c.cz.count = 0;
            return;
        }
        this.m7.x(this, this.ns(), this.xAxis, runOn(this, this.mt), this.n0(b), this.n1(b));
        this.m7.p = this.pd;
        this.m7.q = this.pe;
        this.m7.j = this.pd;
        this.m7.k = this.pe;
        var i = false;
        var j = this.m7.c;
        if (j != null) {
            i = true;
        }
        var k = this.xAxis.cc;
        var l = this.lowColumn.count;
        var m = this.xAxis;
        var n = new ScalerParams(0, e, f, this.xAxis.b8, 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)) {
                continue;
            }
            var u = c.cz.item(o);
            o++;
            u.width = h;
            u.height = t;
            if (i) {
                this.od(d, p, l, m, n, b.n);
            }
            this.m7.ae(u, false, false, false, false);
            u.al = this.m7.j;
            u.am = this.m7.k;
            c.c4(u, q, r);
        }
        c.cz.count = o;
        b.cu(a);
    };
    Object.defineProperty(RangeColumnSeries.prototype, "useHighMarkerFidelity", {
        get: function () {
            return this.nv;
        },
        enumerable: true,
        configurable: true
    });
    RangeColumnSeries.$t = markType(RangeColumnSeries, 'RangeColumnSeries', HorizontalRangeCategorySeries.$);
    return RangeColumnSeries;
}(HorizontalRangeCategorySeries));
export { RangeColumnSeries };
Type.dep(DependencyProperty, PropertyMetadata, RangeColumnSeries, 'raisePropertyChanged', ['RadiusX:pd:ph', [1, 2], 'RadiusY:pe:pi', [1, 2]]);
/**
 * @hidden
 */
var RangeColumnSeriesView = /** @class */ (function (_super) {
    tslib_1.__extends(RangeColumnSeriesView, _super);
    function RangeColumnSeriesView(a) {
        var _this = _super.call(this, a) || this;
        _this.cy = null;
        _this.cz = null;
        _this.c0 = null;
        _this.c5 = new Rectangle();
        _this.cy = a;
        _this.cz = ((function () {
            var $ret = new Pool$1(Rectangle.$);
            $ret.create = runOn(_this, _this.c6);
            $ret.activate = runOn(_this, _this.c1);
            $ret.disactivate = runOn(_this, _this.c3);
            $ret.destroy = runOn(_this, _this.c2);
            return $ret;
        })());
        return _this;
    }
    RangeColumnSeriesView.prototype.ap = function () {
        _super.prototype.ap.call(this);
        this.c0 = new List$1(Rectangle.$, 0);
        if (!this.n) {
            this.e.er = 4;
            this.e.bj = 1;
        }
    };
    RangeColumnSeriesView.prototype.c6 = function () {
        var a = new Rectangle();
        this.c0.add(a);
        a._visibility = 1;
        return a;
    };
    RangeColumnSeriesView.prototype.c1 = function (a) {
        a._visibility = 0;
    };
    RangeColumnSeriesView.prototype.c3 = function (a) {
        a._visibility = 1;
    };
    RangeColumnSeriesView.prototype.c2 = function (a) {
        this.c0.remove(a);
    };
    RangeColumnSeriesView.prototype.c4 = function (a, b, c) {
        if (!this.isDirty) {
            this.an();
        }
        a.o = c;
        a.n = b;
    };
    RangeColumnSeriesView.prototype.z = function (a) {
        return this.c0._inner[a];
    };
    RangeColumnSeriesView.prototype.y = function (a) {
        var b = this.c0._inner[a];
        this.c5._visibility = b._visibility;
        this.c5.n = b.n;
        this.c5.o = b.o;
        this.c5.width = b.width;
        this.c5.height = b.height;
        var c = this.bm(a);
        this.c5._fill = c;
        this.c5._stroke = c;
        this.c5.ac = this.e.ev + 3;
        return this.c5;
    };
    RangeColumnSeriesView.prototype.a3 = function (a, b) {
        _super.prototype.a3.call(this, a, b);
        if (a.d) {
            for (var c = 0; c < this.c0.count; c++) {
                var d = this.x(c, b);
                this.ba(d, c, b);
                a.v(d);
            }
        }
    };
    RangeColumnSeriesView.prototype.ai = function (a) {
        var e_1, _a, e_2, _b;
        _super.prototype.ai.call(this, a);
        var b = 0;
        var c = new List$1(Rectangle.$, 0);
        try {
            for (var _c = tslib_1.__values(fromEnum(this.cz.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 = tslib_1.__values(fromEnum(c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var e = _f.value;
                this.e.a2.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 };
