/*
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 { Base, Point_$type, markType, INotifyPropertyChanged_$type, PropertyChangedEventArgs, runOn, delegateCombine } from "igniteui-webcomponents-core";
import { RenderingContext } from "igniteui-webcomponents-core";
import { List$1 } from "igniteui-webcomponents-core";
import { Path } from "igniteui-webcomponents-core";
import { DoubleAnimator } from "igniteui-webcomponents-core";
import { CanvasViewRenderer } from "igniteui-webcomponents-core";
import { Brush } from "igniteui-webcomponents-core";
import { Color } from "igniteui-webcomponents-core";
import { TransformGroup } from "igniteui-webcomponents-core";
import { TranslateTransform } from "igniteui-webcomponents-core";
import { RotateTransform } from "igniteui-webcomponents-core";
import { truncate, isNaN_ } from "igniteui-webcomponents-core";
import { EasingFunctions } from "igniteui-webcomponents-core";
import { Geometry } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
var GridExpansionIndicatorView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(GridExpansionIndicatorView, _super);
    function GridExpansionIndicatorView(a) {
        var _this = _super.call(this) || this;
        _this.k = null;
        _this.f = 1;
        _this.e = 0;
        _this.d = 0;
        _this.c = new List$1(Path.$, 0);
        _this.m = null;
        _this.b = null;
        _this.l = null;
        _this.j = 0;
        _this.g = 0;
        _this.i = 0;
        _this.h = 0;
        _this.a = null;
        _this.a = a;
        return _this;
    }
    GridExpansionIndicatorView.prototype.o = function (a) {
        if (a == null) {
            this.m = null;
            this.l = null;
            this.b = null;
            if (this.k != null) {
                window.removeEventListener("resize", this.k, false);
                this.k = null;
            }
            return;
        }
        this.f = (isNaN_(this.a.m) ? this.a.j : this.a.m);
        var b = a;
        this.l = b;
        this.a.c.u(this.l);
        this.l.rootWrapper.addClass("ui-expansion-indicator-container");
        var c = this.f;
        var d = Math.round(b.rootWrapper.width());
        var e = Math.round(b.rootWrapper.height());
        var f = d * c;
        var g = e * c;
        var h = this.l.createElement("canvas");
        h.setStyleProperty("position", "absolute");
        this.l.append(h);
        this.e = truncate(Math.round(f));
        this.d = truncate(Math.round(g));
        h.setAttribute("width", f.toString());
        h.setAttribute("height", g.toString());
        h.setStyleProperty("width", d.toString() + "px");
        h.setStyleProperty("height", e.toString() + "px");
        this.j = d;
        this.g = e;
        this.m = h;
        var i = this.l.get2DCanvasContext(this.m);
        this.b = new RenderingContext(new CanvasViewRenderer(), i);
        if (isNaN_(this.a.m)) {
            this.a.j = window.devicePixelRatio;
            this.f = this.a.j;
        }
        this.q();
    };
    GridExpansionIndicatorView.prototype.p = function (a, b) {
        this.j = a;
        this.g = b;
        this.q();
    };
    GridExpansionIndicatorView.prototype.s = function () {
        if (this.a.ae != null) {
            return this.a.ae;
        }
        return ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(138, 0, 0, 0);
            return $ret;
        })());
    };
    GridExpansionIndicatorView.prototype.r = function () {
        this.q();
    };
    GridExpansionIndicatorView.prototype.n = function () {
        this.c.clear();
        this.a.x(this.j, this.g, this.c);
    };
    GridExpansionIndicatorView.prototype.q = function () {
        var _this = this;
        if (this.m == null || this.b == null) {
            return;
        }
        if (this.i != this.j || this.h != this.g) {
            this.n();
            this.i = this.j;
            this.h = this.g;
        }
        if (this.c.count > 0) {
            var a_1 = { $type: Point_$type, x: this.j / 2, y: this.g / 2 };
            var b = new TransformGroup();
            b.j.add(((function () {
                var $ret = new TranslateTransform();
                $ret.j = -a_1.x;
                $ret.k = -a_1.y;
                return $ret;
            })()));
            b.j.add(((function () {
                var $ret = new RotateTransform();
                $ret.j = _this.a.k;
                return $ret;
            })()));
            b.j.add(((function () {
                var $ret = new TranslateTransform();
                $ret.j = a_1.x;
                $ret.k = a_1.y;
                return $ret;
            })()));
            this.c._inner[0].j = b;
        }
        var c = Math.round(this.j * this.f);
        var d = Math.round(this.g * this.f);
        if (this.e != c || this.d != d) {
            this.m.setAttribute("width", c.toString());
            this.m.setAttribute("height", d.toString());
            this.m.setStyleProperty("width", this.j.toString() + "px");
            this.m.setStyleProperty("height", this.g.toString() + "px");
            this.m.setStyleProperty("top", "0px");
            this.m.setStyleProperty("left", "0px");
            this.e = truncate(Math.round(c));
            this.d = truncate(Math.round(d));
        }
        if (this.b.d && this.f != 1) {
            this.b.z();
            this.b.aa(this.f, this.f);
        }
        this.b.k(0, 0, this.j, this.g);
        this.b.z();
        for (var e = 0; e < this.c.count; e++) {
            this.b.j(this.c._inner[e].j);
            var f = this.s();
            if (this.a.ae != null) {
                f = this.a.ae;
            }
            this.c._inner[e]._stroke = f;
            this.b.s(this.c._inner[e]);
        }
        this.b.y();
        if (this.b.d && this.f != 1) {
            this.b.y();
        }
    };
    GridExpansionIndicatorView.$t = markType(GridExpansionIndicatorView, 'GridExpansionIndicatorView');
    return GridExpansionIndicatorView;
}(Base));
export { GridExpansionIndicatorView };
/**
 * @hidden
 */
var GridExpansionIndicator = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(GridExpansionIndicator, _super);
    function GridExpansionIndicator() {
        var _this = _super.call(this) || this;
        _this.a = null;
        _this.o = null;
        _this.e = false;
        _this.ad = null;
        _this.d = false;
        _this.propertyChanged = null;
        _this.b = null;
        _this.i = NaN;
        _this.h = 1;
        _this.k = 0;
        _this.l = 0;
        _this.n = 0;
        _this.k = 0;
        _this.a = new GridExpansionIndicatorView(_this);
        _this.b = new DoubleAnimator(0, 1, 400);
        _this.b.b = EasingFunctions.cubicEase;
        var a = _this.b;
        a.propertyChanged = delegateCombine(a.propertyChanged, runOn(_this, _this.w));
        return _this;
    }
    Object.defineProperty(GridExpansionIndicator.prototype, "p", {
        get: function () {
            return this.o;
        },
        set: function (a) {
            this.o = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridExpansionIndicator.prototype, "g", {
        get: function () {
            return this.e;
        },
        set: function (a) {
            var b = this.e;
            this.e = a;
            if (b != this.e) {
                this.z("IsExpanded", b, this.e);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridExpansionIndicator.prototype, "ae", {
        get: function () {
            return this.ad;
        },
        set: function (a) {
            var b = this.ad;
            this.ad = a;
            if (b != this.ad) {
                this.z("IconColor", b, this.ad);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridExpansionIndicator.prototype, "f", {
        get: function () {
            return this.d;
        },
        set: function (a) {
            var b = this.d;
            this.d = a;
            if (b != this.d) {
                this.z("IsAnimationEnabled", b, this.d);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridExpansionIndicator.prototype, "c", {
        get: function () {
            return this.b;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridExpansionIndicator.prototype, "m", {
        get: function () {
            return this.i;
        },
        set: function (a) {
            var b = this.i;
            this.i = a;
            this.z("PixelScalingRatio", b, this.i);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(GridExpansionIndicator.prototype, "j", {
        get: function () {
            return this.h;
        },
        set: function (a) {
            var b = this.h;
            this.h = a;
            this.z("ActualPixelScalingRatio", b, this.h);
        },
        enumerable: true,
        configurable: true
    });
    GridExpansionIndicator.prototype.z = function (a, b, c) {
        this.aa(a, b, c);
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
    };
    GridExpansionIndicator.prototype.aa = function (a, b, c) {
        switch (a) {
            case "PixelScalingRatio":
                this.j = this.m;
                break;
            case "ActualPixelScalingRatio":
                this.a.r();
                break;
            case "IconColor":
                this.a.r();
                break;
            case "IsExpanded":
                if (this.f || this.b.f()) {
                    this.b.w();
                }
                this.l = this.k;
                this.n = this.g ? 90 : 0;
                if (this.f) {
                    this.b.v();
                }
                else {
                    this.k = this.n;
                    this.a.r();
                }
                break;
        }
    };
    GridExpansionIndicator.prototype.w = function (a, b) {
        this.k = this.l + this.b.o * (this.n - this.l);
        this.a.r();
    };
    GridExpansionIndicator.prototype.x = function (a, b, c) {
        var _this = this;
        var d = Geometry.a("M 10.18 6.343 l 5.64 5.675 -5.64 5.639");
        c.add(((function () {
            var $ret = new Path();
            $ret.ak = d;
            $ret.aj = 2;
            $ret.stroke = _this.a.s();
            $ret.ac = 2;
            return $ret;
        })()));
    };
    GridExpansionIndicator.prototype.ab = function (a) {
        this.a.o(a);
    };
    GridExpansionIndicator.prototype.ac = function (a) {
        this.c.u(a);
    };
    GridExpansionIndicator.prototype.q = function () {
        return this.a.m.getNativeElement();
    };
    GridExpansionIndicator.prototype.y = function (a, b) {
        this.a.p(a, b);
    };
    GridExpansionIndicator.$t = markType(GridExpansionIndicator, 'GridExpansionIndicator', Base.$, [INotifyPropertyChanged_$type]);
    return GridExpansionIndicator;
}(Base));
export { GridExpansionIndicator };
//# sourceMappingURL=GridExpansionIndicatorView_combined.js.map
