/*
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 { Base, Point_$type, fromEnum, markType } from "igniteui-angular-core";
import { PointList } from "./PointList";
import { PointCollection } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-core";
import { intDivide, isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var SliceAppearance = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(SliceAppearance, _super);
    function SliceAppearance() {
        var _this = _super.call(this) || this;
        _this.l = 0;
        _this.k = 0;
        _this.az = null;
        _this.a0 = null;
        _this.a = null;
        _this.b = null;
        _this.bb = null;
        _this.ba = null;
        _this.a1 = null;
        _this.ay = null;
        _this.ax = null;
        _this.bi = null;
        _this.ai = null;
        _this.an = null;
        _this.aj = null;
        _this.ak = null;
        _this.y = null;
        _this.aw = null;
        _this.g = false;
        _this.z = null;
        _this.x = null;
        _this.bk = 1;
        _this.n = 1;
        _this.m = 0.5;
        _this.au = null;
        _this.av = null;
        _this.v = 0;
        _this.be = Rect.empty;
        _this.bf = Rect.empty;
        _this.al = null;
        _this.am = null;
        _this.bl = 0;
        _this.h = false;
        _this.u = 0;
        _this.o = 1;
        _this.ax = { $type: Point_$type, x: 0, y: 0 };
        _this.ay = { $type: Point_$type, x: 0, y: 0 };
        _this.a0 = { $type: Point_$type, x: 0, y: 0 };
        _this.a1 = { $type: Point_$type, x: 0, y: 0 };
        _this.az = { $type: Point_$type, x: 0, y: 0 };
        return _this;
    }
    Object.defineProperty(SliceAppearance.prototype, "q", {
        get: function () {
            return this.l;
        },
        set: function (a) {
            this.l = a;
            this.ag();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "p", {
        get: function () {
            return this.k;
        },
        set: function (a) {
            this.k = a;
            this.ag();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "a7", {
        get: function () {
            return this.az;
        },
        set: function (a) {
            this.az = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "a8", {
        get: function () {
            return this.a0;
        },
        set: function (a) {
            this.a0 = a;
            this.ag();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "c", {
        get: function () {
            return this.a;
        },
        set: function (a) {
            this.a = a;
            this.ag();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "e", {
        get: function () {
            return this.b;
        },
        set: function (a) {
            this.b = a;
            this.ag();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "bd", {
        get: function () {
            return this.bb;
        },
        set: function (a) {
            this.bb = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "bc", {
        get: function () {
            return this.ba;
        },
        set: function (a) {
            this.ba = a;
        },
        enumerable: false,
        configurable: true
    });
    SliceAppearance.prototype.ah = function () {
        this.ag();
    };
    SliceAppearance.prototype.ag = function () {
    };
    SliceAppearance.prototype.ad = function () {
        var e_1, _a, e_2, _b;
        var a = new PointCollection(0);
        var b = !isNaN_(this.s);
        var c = b ? new PointCollection(0) : null;
        if (this.e != null) {
            try {
                for (var _c = __values(fromEnum(this.e)), _d = _c.next(); !_d.done; _d = _c.next()) {
                    var d = _d.value;
                    a.add(d);
                    if (b && d.y < this.a2.y) {
                        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;
                }
            }
        }
        else {
            a.add(this.a8);
            a.add(this.a9);
            if (b) {
                c.add(this.a2);
                c.add(this.a3);
            }
        }
        if (this.c != null) {
            try {
                for (var _e = __values(fromEnum(this.c)), _f = _e.next(); !_f.done; _f = _e.next()) {
                    var e = _f.value;
                    a.add(e);
                    if (b && e.y > this.a2.y) {
                        c.add(e);
                    }
                }
            }
            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;
                }
            }
            if (this.e != null && this.e.count > 0) {
                a.add(this.e._inner[0]);
                if (b && c.count > 0) {
                    c.add(c._inner[0]);
                }
            }
        }
        else {
            a.add(this.a6);
            a.add(this.a5);
            a.add(this.a8);
            if (b) {
                c.add(this.a6);
                c.add(this.a5);
                c.add(this.a2);
            }
        }
        var f = 0, g = Math.min(intDivide(a.count, 2), 5);
        if (g > 1) {
            var h = a._inner[0];
            var i = 0, j = h.x, k = h.y;
            while (++f < g && i < 2) {
                h = a._inner[f];
                i = Math.abs(h.x - j) + Math.abs(h.y - k);
                if (i > 1) {
                    a.add({ $type: Point_$type, x: h.x, y: h.y });
                }
            }
        }
        this.bd = a;
        this.bc = c;
    };
    Object.defineProperty(SliceAppearance.prototype, "a9", {
        get: function () {
            return this.a1;
        },
        set: function (a) {
            this.a1 = a;
            this.ag();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "a6", {
        get: function () {
            return this.ay;
        },
        set: function (a) {
            this.ay = a;
            this.ag();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "a5", {
        get: function () {
            return this.ax;
        },
        set: function (a) {
            this.ax = a;
            this.ag();
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "bj", {
        get: function () {
            return this.bi;
        },
        set: function (a) {
            this.bi = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "ao", {
        get: function () {
            return this.ai;
        },
        set: function (a) {
            this.ai = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "at", {
        get: function () {
            return this.an;
        },
        set: function (a) {
            this.an = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "ap", {
        get: function () {
            return this.aj;
        },
        set: function (a) {
            this.aj = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "aq", {
        get: function () {
            return this.ak;
        },
        set: function (a) {
            this.ak = a;
        },
        enumerable: false,
        configurable: true
    });
    SliceAppearance.prototype.ae = function (a, b, c, d) {
        if (a == null) {
            this.ao = null;
            this.ap = null;
        }
        else {
            this.ap = a;
            if (d) {
                this.ao = BrushUtil.s(a, c);
            }
            else {
                this.ao = a;
            }
        }
        if (b == null) {
            this.at = null;
            this.aq = null;
        }
        else {
            this.aq = b;
            if (d) {
                this.at = BrushUtil.s(b, c);
            }
            else {
                this.at = b;
            }
        }
    };
    Object.defineProperty(SliceAppearance.prototype, "ab", {
        get: function () {
            return this.y;
        },
        set: function (a) {
            this.y = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "a4", {
        get: function () {
            return this.aw;
        },
        set: function (a) {
            this.aw = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "i", {
        get: function () {
            return this.g && this.y != null;
        },
        set: function (a) {
            this.g = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "item", {
        get: function () {
            return this.z;
        },
        set: function (a) {
            this.z = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "aa", {
        get: function () {
            return this.x;
        },
        set: function (a) {
            this.x = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "bm", {
        get: function () {
            return this.bk;
        },
        set: function (a) {
            this.bk = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "s", {
        get: function () {
            return this.n;
        },
        set: function (a) {
            this.n = a;
        },
        enumerable: false,
        configurable: true
    });
    SliceAppearance.prototype.af = function () {
        if (this.x == null || isNaN_(this.x) || this.z == null || isNaN_(this.z) || this.bm != 0) {
            this.s = 1;
            return;
        }
        this.s = Math.min(1, Math.max(0, Math.abs(this.x / this.z)));
    };
    Object.defineProperty(SliceAppearance.prototype, "r", {
        get: function () {
            return this.m;
        },
        set: function (a) {
            this.m = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "a2", {
        get: function () {
            return this.au;
        },
        set: function (a) {
            this.au = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "a3", {
        get: function () {
            return this.av;
        },
        set: function (a) {
            this.av = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "w", {
        get: function () {
            return this.v;
        },
        set: function (a) {
            this.v = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "bg", {
        get: function () {
            return this.be;
        },
        set: function (a) {
            this.be = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "bh", {
        get: function () {
            return this.bf;
        },
        set: function (a) {
            this.bf = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "ar", {
        get: function () {
            return this.al;
        },
        set: function (a) {
            this.al = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "as", {
        get: function () {
            return this.am;
        },
        set: function (a) {
            this.am = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "bn", {
        get: function () {
            return this.bl;
        },
        set: function (a) {
            this.bl = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "j", {
        get: function () {
            return this.h;
        },
        set: function (a) {
            this.h = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(SliceAppearance.prototype, "t", {
        get: function () {
            return this.o;
        },
        set: function (a) {
            this.o = a;
        },
        enumerable: false,
        configurable: true
    });
    SliceAppearance.f = function (a, b, c, d, e) {
        if (a == null) {
            a = new SliceAppearance();
        }
        a.i = c.i;
        a.ab = c.ab;
        if (b.i && c.i) {
            a.a4 = { $type: Point_$type, x: (b.a4.x * e) + (c.a4.x * d), y: (b.a4.y * e) + (c.a4.y * d) };
        }
        else if (c.i) {
            a.a4 = { $type: Point_$type, x: c.a4.x * d, y: c.a4.y * d };
        }
        a.a5 = { $type: Point_$type, x: (b.a5.x * e) + (c.a5.x * d), y: (b.a5.y * e) + (c.a5.y * d) };
        a.a6 = { $type: Point_$type, x: (b.a6.x * e) + (c.a6.x * d), y: (b.a6.y * e) + (c.a6.y * d) };
        a.a8 = { $type: Point_$type, x: (b.a8.x * e) + (c.a8.x * d), y: (b.a8.y * e) + (c.a8.y * d) };
        a.a9 = { $type: Point_$type, x: (b.a9.x * e) + (c.a9.x * d), y: (b.a9.y * e) + (c.a9.y * d) };
        a.a7 = { $type: Point_$type, x: (b.a7.x * e) + (c.a7.x * d), y: (b.a7.y * e) + (c.a7.y * d) };
        a.a2 = { $type: Point_$type, x: (b.a2.x * e) + (c.a2.x * d), y: (b.a2.y * e) + (c.a2.y * d) };
        a.a3 = { $type: Point_$type, x: (b.a3.x * e) + (c.a3.x * d), y: (b.a3.y * e) + (c.a3.y * d) };
        if (c.c != null) {
            var f = b.c;
            if (f == null) {
                f = new PointList();
                f.add(b.a8);
                f.add(b.a5);
            }
            a.c = SliceAppearance.d(a.c, f, c.c, d, e);
        }
        else {
            a.c = null;
        }
        if (c.e != null) {
            var g = b.e;
            if (g == null) {
                g = new PointList();
                g.add(b.a6);
                g.add(b.a9);
            }
            a.e = SliceAppearance.d(a.e, g, c.e, d, e);
        }
        else {
            a.e = null;
        }
        a.bj = c.bj;
        a.item = c.item;
        a.aa = c.aa;
        a.bm = (b.bm == 0 || c.bm == 0) ? 0 : 1;
        if (a.bm == 0 && c.bm != 0) {
            a.ao = b.ao;
            a.at = b.at;
        }
        else {
            a.ao = c.ao;
            a.at = c.at;
        }
        a.w = c.w;
        a.ad();
        return a;
    };
    SliceAppearance.d = function (a, b, c, d, e) {
        if (a == null) {
            a = new PointList();
        }
        if (b == null) {
            b = new PointList();
        }
        var f = b.count;
        var g = c.count;
        var h = Math.max(f, g);
        if (a.count < h) {
            a.s(a.count, new Array(h - a.count));
        }
        if (a.count > h) {
            a.v(h, a.count - h);
        }
        for (var i = 0; i < Math.min(f, g); ++i) {
            a._inner[i] = { $type: Point_$type, x: (b._inner[i].x * e) + (c._inner[i].x * d), y: (b._inner[i].y * e) + (c._inner[i].y * d) };
        }
        if (f < g) {
            var j = f > 0 ? b._inner[f - 1] : { $type: Point_$type, x: 0, y: 0 };
            for (var k = f; k < g; ++k) {
                a._inner[k] = { $type: Point_$type, x: (j.x * e) + (c._inner[k].x * d), y: (j.y * e) + (c._inner[k].y * d) };
            }
        }
        if (f > g) {
            var l = g > 0 ? c._inner[g - 1] : { $type: Point_$type, x: 0, y: 0 };
            for (var m = g; m < f; ++m) {
                a._inner[m] = { $type: Point_$type, x: (b._inner[m].x * e) + (l.x * d), y: (b._inner[m].y * e) + (l.y * d) };
            }
        }
        return a;
    };
    SliceAppearance.$t = markType(SliceAppearance, 'SliceAppearance');
    return SliceAppearance;
}(Base));
export { SliceAppearance };
