/*
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, __read, __spreadArray } from "tslib";
import { Base, runOn, markType, INotifyPropertyChanged_$type, PropertyChangedEventArgs, enumGetBox } from "./type";
import { Size } from "./Size";
import { ElevationHelper } from "./ElevationHelper";
import { CornerRadius } from "./CornerRadius";
import { NativeUI } from "./NativeUI";
import { PopupPointerPosition_$type } from "./PopupPointerPosition";
import { Popup_OuterAnimationInfo } from "./Popup_OuterAnimationInfo";
import { Popup_InnerAnimationInfo } from "./Popup_InnerAnimationInfo";
import { AnimationKeyFrameEffect } from "./AnimationKeyFrameEffect";
import { AnimationKeyFrameEffectTiming } from "./AnimationKeyFrameEffectTiming";
import { KeyFrameAnimationFactory } from "./KeyFrameAnimationFactory";
import { Rect } from "./Rect";
import { PopupAnimationType_$type } from "./PopupAnimationType";
import { stringFormat } from "./stringExtended";
import { isNaN_, truncate } from "./number";
import { stringEmpty } from "./string";
import { OnClosedEventArgs } from "./OnClosedEventArgs";
import { MouseEventArgs } from "./MouseEventArgs";
import { FocusEventArgs } from "./FocusEventArgs";
import { List$1 } from "./List$1";
import { AnimationKeyFrameProperty } from "./AnimationKeyFrameProperty";
import { TranslateTransform } from "./TranslateTransform";
import { OnPopupEventArgs } from "./OnPopupEventArgs";
import { PopupAnimation } from "./PopupAnimation";
import { DeviceUtils } from "./DeviceUtils";
import { PopupVisualModelExport } from "./PopupVisualModelExport";
import { AppearanceHelper } from "./AppearanceHelper";
import { BrushUtil } from "./BrushUtil";
/**
 * @hidden
 */
var PopupView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(PopupView, _super);
    function PopupView() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.ad = null;
        _this.f = null;
        _this.al = null;
        _this.ak = null;
        _this.aj = null;
        _this.ag = null;
        _this.ai = null;
        _this.ah = null;
        _this.an = null;
        _this.s = 0;
        _this.t = 0;
        _this.r = 0;
        _this.l = false;
        _this.u = 0;
        _this.p = 0;
        _this.q = 0;
        _this.n = 0;
        _this.o = 0;
        _this.af = null;
        _this.am = null;
        _this.bk = new Size(1, 0, 0);
        _this.k = true;
        _this.m = false;
        return _this;
    }
    Object.defineProperty(PopupView.prototype, "ac", {
        get: function () {
            return this.g.a1;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupView.prototype, "z", {
        get: function () {
            return this.ac / 2;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupView.prototype, "y", {
        get: function () {
            return this.ac * 1.414;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupView.prototype, "x", {
        get: function () {
            return this.y / 2;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupView.prototype, "aa", {
        get: function () {
            return (this.bl.width / 2 - this.z);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupView.prototype, "ab", {
        get: function () {
            return (this.bl.height / 2 - this.z);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupView.prototype, "g", {
        get: function () {
            return this.f;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PopupView.prototype, "ae", {
        get: function () {
            return this.ad;
        },
        enumerable: false,
        configurable: true
    });
    PopupView.prototype.a3 = function () {
        this.al.setStyleProperty("height", "0%");
        this.al.setStyleProperty("width", "0%");
        this.ag = this.ad.createElement("div");
        this.ag.setStyleProperty("position", "absolute");
        this.ag.setStyleProperty("z-index", "10000");
        this.ai = this.ad.createElement("div");
        this.ai.setStyleProperty("height", 20 * 1.414 / 2 + "px");
        this.ah = this.ad.createElement("div");
        this.ah.setStyleProperty("position", "relative");
        this.ah.setStyleProperty("width", this.ac + "px");
        this.ah.setStyleProperty("height", this.ac + "px");
        this.ah.setStyleProperty("z-index", "1");
        this.ah.setStyleProperty("clip-path", stringFormat("path(\"M0,0l{0},{0}l0,-{0}l-{0},0Z\")", this.ac));
        this.ai.append(this.ah);
        this.ak = this.ad.createElement("div");
        this.ak.setStyleProperty("position", "relative");
        this.ak.setStyleProperty("overflow", "hidden");
        this.ak.setAttribute("key", "popupContentAreaOuter");
        this.bb(this.g.aq);
        this.ag.listen("mouseenter", runOn(this, this.a4));
        this.ag.listen("mouseleave", runOn(this, this.a5));
        this.ag.listen("focusin", runOn(this, this.a1));
        this.ag.listen("focusout", runOn(this, this.a2));
        this.aj = this.ad.createElement("div");
        this.aj.setAttribute("key", "popupContentAreaInner");
        this.ak.append(this.aj);
        this.ag.append(this.ak);
    };
    PopupView.prototype.bh = function () {
        var a = this.g;
        var b = ElevationHelper.e(a.a4, a.cm, a.cl, a.ck);
        this.ak.setStyleProperty("box-shadow", b);
    };
    PopupView.prototype.bf = function () {
        if (this.g.cn != null) {
            this.ak.setStyleProperty("background-color", this.g.cn._fill);
            this.ah.setStyleProperty("background-color", this.g.cn._fill);
        }
        if (this.g.cr != null) {
            this.ah.setStyleProperty("background-color", this.g.cr._fill);
        }
    };
    PopupView.prototype.bg = function () {
        if (!isNaN_(this.g.ay)) {
            NativeUI.n(this.ak, new CornerRadius(0, this.g.ay));
        }
    };
    PopupView.prototype.bi = function () {
        if (null == this.al) {
            return;
        }
        this.bh();
        this.bf();
        this.bg();
    };
    PopupView.prototype.a4 = function (a) {
        this.g.b5();
    };
    PopupView.prototype.a5 = function (a) {
        this.g.b6();
    };
    PopupView.prototype.a1 = function (a) {
        this.g.b3();
    };
    PopupView.prototype.a2 = function (a) {
        this.g.b4(a.originalEvent.relatedTarget);
    };
    PopupView.prototype.aq = function () {
        if (null != this.ag) {
            this.bi();
            this.ak.setStyleProperty("height", "0px");
            var a = this.ag.getNativeElement();
            if (false == this.l) {
                this.ai.remove();
                if (this.g.as) {
                    var b = this.g.s();
                    if (b == 1) {
                        this.ag.setStyleProperty("display", "block");
                        var c = this.ag.getNativeElement();
                        var d = this.ai.getNativeElement();
                        var e = this.ak.getNativeElement();
                        c.insertBefore(d, e);
                    }
                    else if (b == 2) {
                        this.ag.setStyleProperty("display", "block");
                        this.ag.append(this.ai);
                    }
                    else if (b == 3) {
                        this.ag.setStyleProperty("display", "flex");
                        var f = this.ag.getNativeElement();
                        var g = this.ai.getNativeElement();
                        var h = this.ak.getNativeElement();
                        f.insertBefore(g, h);
                        this.ai.setStyleProperty("height", "unset");
                        this.ai.setStyleProperty("width", 20 * 1.414 / 2 + "px");
                    }
                    else if (b == 4) {
                        this.ag.setStyleProperty("display", "flex");
                        this.ag.append(this.ai);
                        this.ai.setStyleProperty("height", "unset");
                        this.ai.setStyleProperty("width", 20 * 1.414 / 2 + "px");
                    }
                }
                document.body.appendChild(a);
                this.l = true;
                if (this.k) {
                    this.ay();
                }
            }
        }
    };
    PopupView.prototype.ar = function (a, b) {
        this.ag.setStyleProperty("top", PopupView.ao(a.f));
        this.ak.setStyleProperty("height", PopupView.ap(a.h));
        this.ag.setStyleProperty("top", PopupView.ap(b.b));
        this.aj.setStyleProperty("opacity", "1");
        this.aj.setStyleProperty("transform", stringEmpty());
        this.u = 0;
        if (this.m) {
            this.be();
        }
        if (this.g.av) {
            this.am.observe(this.af.getNativeElement());
        }
        else {
            this.am.disconnect();
        }
        if (this.g.an) {
            this.bc(this.g.ar);
        }
        return {
            p0: a,
            p1: b
        };
    };
    PopupView.prototype.as = function (a) {
        this.u = a;
        if (this.g.an) {
            this.bc(false);
        }
        if (this.g.as) {
            var b = 0;
            var c = 0;
            switch (this.g.s()) {
                case 3:
                    b = -135;
                    c = this.z;
                    this.s = c;
                    this.t = a / 2 - this.z;
                    break;
                case 4:
                    b = 45;
                    c = -this.z;
                    this.s = c;
                    this.t = a / 2 - this.z;
                    break;
            }
            this.r = b;
            this.ah.setStyleProperty("transform", "translate(" + this.s + "px, " + this.t + "px) rotate(" + this.r + "deg)");
        }
    };
    PopupView.prototype.a9 = function () {
        if (null != this.ag && this.l) {
            var a = this.ag.getNativeElement();
            document.body.removeChild(a);
            this.l = false;
        }
    };
    PopupView.prototype.at = function (a) {
        this.af = a;
        this.aj.append(this.af);
        this.am = new ResizeObserver(runOn(this, this.a0));
    };
    PopupView.prototype.a0 = function (a) {
        if (this.l) {
            if (this.g.ao() && this.g.o == 0) {
                return;
            }
            this.g.b0();
        }
    };
    PopupView.prototype.j = function (a) {
        var b = this.ag.getNativeElement();
        return b.contains(a);
    };
    PopupView.prototype.a8 = function (a) {
        this.af = null;
        this.am.disconnect();
        this.am = null;
        a.remove();
    };
    PopupView.prototype.d = function (a) {
        return new AnimationKeyFrameEffect(0, this.aj, 0, null, a);
    };
    PopupView.prototype.e = function (a) {
        return new AnimationKeyFrameEffect(0, this.ak, 0, null, a);
    };
    PopupView.prototype.av = function () {
        if (KeyFrameAnimationFactory.h == null) {
            KeyFrameAnimationFactory.h = this.ae;
        }
    };
    PopupView.prototype.c = function (a) {
        return new AnimationKeyFrameEffect(0, this.ag, 0, null, a);
    };
    PopupView.prototype.b = function (a) {
        return new AnimationKeyFrameEffect(0, this.ak, 0, null, a);
    };
    PopupView.prototype.a = function (a) {
        return new AnimationKeyFrameEffect(0, this.ag, 0, null, a);
    };
    PopupView.prototype.i = function () {
        return 12;
    };
    PopupView.prototype.h = function () {
        return 11;
    };
    Object.defineProperty(PopupView.prototype, "bl", {
        get: function () {
            if (this.k) {
                this.ay();
            }
            return this.bk;
        },
        enumerable: false,
        configurable: true
    });
    PopupView.prototype.v = function (a, b, c) {
        var d;
        switch (b) {
            case 3:
                d = a.left - (this.bl.width + (this.g.as ? this.x : 0));
                break;
            case 4:
                d = a.right;
                break;
            case 0:
            case 2:
            case 1:
            default:
                switch (c) {
                    case 2:
                        d = a.right - this.bl.width;
                        break;
                    case 3:
                        d = a.right - (a.width / 2) - (this.bl.width / 2);
                        break;
                    case 0:
                    case 1:
                    default:
                        d = a.left;
                        break;
                }
                break;
        }
        return d;
    };
    PopupView.prototype.w = function (a, b, c) {
        var d;
        switch (b) {
            case 3:
            case 4:
                switch (c) {
                    case 2:
                        d = a.bottom - this.bl.height;
                        break;
                    case 3:
                        d = a.top - (this.bl.height / 2) + (a.height / 2);
                        break;
                    case 0:
                    case 1:
                    default:
                        d = a.top;
                        break;
                }
                break;
            case 2:
                d = a.top - (this.bl.height + (this.g.as ? this.x : 0));
                break;
            case 0:
            case 1:
            default:
                d = a.bottom;
                break;
        }
        return d;
    };
    PopupView.ap = function (a) {
        return stringFormat("{0}px", a);
    };
    PopupView.ao = function (a) {
        return stringFormat("{0}px", a);
    };
    PopupView.prototype.bd = function () {
        if (this.g.q == 1 || this.g.q == 2) {
            switch (this.g.i) {
                case 3:
                    this.s = this.aa + (this.p - this.n);
                    break;
            }
        }
        else if (this.g.q == 3 || this.g.q == 4) {
            switch (this.g.i) {
                case 3:
                    this.t = this.ab + (this.q - this.o);
                    break;
            }
        }
        this.ah.setStyleProperty("transform", "translate(" + this.s + "px, " + this.t + "px) rotate(" + this.r + "deg)");
    };
    PopupView.prototype.au = function (a, b, c, d) {
        this.p = a;
        this.q = b;
        if (this.g.q == 1 || this.g.q == 2) {
            var e = (window.innerWidth);
            var f = a;
            var g = f + c;
            if (f < 5) {
                a = 5;
            }
            else if (g > e - 5) {
                a = f - (g - (e - 5));
            }
        }
        else if (this.g.q == 3 || this.g.q == 4) {
            var h = (window.innerHeight);
            var i = b;
            var j = i + d;
            if (i < 5) {
                b = 5;
            }
            else if (j > h - 5) {
                b = i - (j - (h - 5));
            }
        }
        return {
            p0: a,
            p1: b
        };
    };
    PopupView.prototype.bj = function (a, b, c) {
        var d = this.w(a, b, c);
        var e = this.v(a, b, c);
        var f = this.au(e, d, this.bl.width, this.bl.height);
        e = f.p0;
        d = f.p1;
        this.ba(e, d);
        if (b == 2 || c == 2) {
            var g = 10;
            while (g > 0) {
                var h = this.w(a, b, c);
                var i = this.v(a, b, c);
                var j = this.au(i, h, this.bl.width, this.bl.height);
                i = j.p0;
                h = j.p1;
                if (h == d && i == e) {
                    g = 0;
                    break;
                }
                d = h;
                e = i;
                this.ba(e, d);
                g--;
            }
        }
        this.bd();
        return new Rect(0, e, d, this.bl.width, this.bl.height);
    };
    PopupView.prototype.ay = function () {
        if (this.l) {
            this.ak.setStyleProperty("width", stringEmpty());
            this.ak.setStyleProperty("height", stringEmpty());
            this.ag.setStyleProperty("width", stringEmpty());
            this.ag.setStyleProperty("height", stringEmpty());
            this.bk = new Size(1, this.aj.outerWidth(), this.aj.outerHeight());
            this.k = false;
            this.be();
        }
        else {
            this.k = true;
        }
    };
    PopupView.prototype.ba = function (a, b) {
        var c = stringFormat("{0}px", a);
        var d = stringFormat("{0}px", b);
        this.ag.setStyleProperty("left", c);
        this.ag.setStyleProperty("top", d);
        this.n = a;
        this.o = b;
    };
    PopupView.prototype.a6 = function (a) {
        var _this = this;
        if (a == null) {
            this.ad = null;
            if (this.ag != null) {
                this.ag.unlistenAll();
            }
            return;
        }
        this.ad = a;
        var b = a.rootWrapper;
        this.aw(b);
        this.ad.getPortal(this.aj, "ChildContent", function (c) {
            var comp_ = c.componentRef;
            _this.an = comp_;
        }, true);
    };
    PopupView.prototype.be = function () {
        var a = new Size(1, this.bl.width, this.bl.height);
        if (!this.l || !this.g.av) {
            a.height = 0;
        }
        var b = a.width;
        var c = a.height;
        var d = stringFormat("{0}px", b);
        var e = stringFormat("{0}px", c);
        if (this.g.as) {
            var f = 0;
            var g = 0;
            switch (this.g.s()) {
                case 2:
                    f = 135;
                    g = -this.z;
                    this.s = b / 2 - this.z;
                    this.t = g;
                    d = stringFormat("{0}px", b);
                    e = stringFormat("{0}px", this.x + c);
                    break;
                case 1:
                    f = -45;
                    g = this.x - this.z;
                    this.s = b / 2 - this.z;
                    this.t = g;
                    d = stringFormat("{0}px", b);
                    e = stringFormat("{0}px", this.x + c);
                    break;
                case 3:
                    f = -135;
                    g = this.x - this.z;
                    this.s = g;
                    this.t = c / 2 - this.z;
                    d = stringFormat("{0}px", this.x + b);
                    e = stringFormat("{0}px", c);
                    break;
                case 4:
                    f = 45;
                    g = -this.z;
                    this.s = g;
                    this.t = c / 2 - this.z;
                    d = stringFormat("{0}px", this.x + b);
                    e = stringFormat("{0}px", c);
                    break;
            }
            this.r = f;
            this.ah.setStyleProperty("transform", "translate(" + this.s + "px, " + this.t + "px) rotate(" + this.r + "deg)");
        }
        if (this.f.ao()) {
            if (this.u == c) {
                return;
            }
            this.f.bw();
            this.m = true;
            return;
        }
        this.m = false;
        var h = stringFormat("{0}px", b);
        var i = stringFormat("{0}px", c);
        this.ak.setStyleProperty("width", h);
        this.ak.setStyleProperty("height", i);
        this.ag.setStyleProperty("width", d);
        this.ag.setStyleProperty("height", e);
    };
    PopupView.prototype.aw = function (a) {
        this.al = a;
        this.a3();
    };
    PopupView.prototype.ax = function (a) {
        this.f = a;
    };
    PopupView.prototype.az = function () {
    };
    PopupView.prototype.a7 = function () {
        this.aq();
        if (this.g.av) {
            return;
        }
        this.be();
    };
    PopupView.prototype.bc = function (a) {
        if (this.ag != null) {
            this.ag.setStyleProperty("pointer-events", a ? "auto" : "none");
        }
    };
    PopupView.prototype.bb = function (a) {
        if (this.ag != null) {
            this.ag.setAttribute("tabindex", a ? "-1" : "");
        }
    };
    PopupView.$t = markType(PopupView, 'PopupView');
    return PopupView;
}(Base));
export { PopupView };
/**
 * @hidden
 */
var Popup = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(Popup, _super);
    function Popup() {
        var _this = _super.call(this) || this;
        _this.p = 0;
        _this.h = 0;
        _this.az = 0;
        _this.cu = null;
        _this.cs = null;
        _this.aa = null;
        _this.ab = null;
        _this.onClosed = null;
        _this.onPopup = null;
        _this.propertyChanged = null;
        _this.popupMouseEnter = null;
        _this.popupMouseLeave = null;
        _this.popupGotFocus = null;
        _this.popupLostFocus = null;
        _this.v = null;
        _this.ag = false;
        _this.a5 = 50;
        _this.ak = true;
        _this.n = 0;
        _this.a3 = -1;
        _this.a2 = Popup.a7;
        _this.au = false;
        _this.ch = Popup.cq;
        _this.cg = Popup.cp;
        _this.cf = Popup.co;
        _this.ci = null;
        _this.aw = 0;
        _this.ah = true;
        _this.ae = false;
        _this.ai = false;
        _this.r = 0;
        _this.cj = null;
        _this.ax = 20;
        _this.aj = false;
        _this.af = false;
        _this.j = null;
        var a = _this.u();
        _this.v = a;
        a.ax(_this);
        return _this;
    }
    Object.defineProperty(Popup.prototype, "cv", {
        get: function () {
            return this.cu;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "ct", {
        get: function () {
            return this.cs;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "q", {
        get: function () {
            return this.p;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "i", {
        get: function () {
            return this.h;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "a0", {
        get: function () {
            return this.az;
        },
        enumerable: false,
        configurable: true
    });
    Popup.prototype.b7 = function (a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        this.b9(a, b, c);
    };
    Popup.prototype.b5 = function () {
        if (this.popupMouseEnter != null) {
            this.popupMouseEnter(this, new MouseEventArgs());
        }
    };
    Popup.prototype.b6 = function () {
        if (this.popupMouseLeave != null) {
            this.popupMouseLeave(this, new MouseEventArgs());
        }
    };
    Popup.prototype.b3 = function () {
        if (this.popupGotFocus != null) {
            this.popupGotFocus(this, new FocusEventArgs());
        }
    };
    Popup.prototype.b4 = function (a) {
        if (this.popupLostFocus != null) {
            this.popupLostFocus(this, ((function () {
                var $ret = new FocusEventArgs();
                $ret.a = a;
                return $ret;
            })()));
        }
    };
    Object.defineProperty(Popup.prototype, "aq", {
        get: function () {
            return this.ag;
        },
        set: function (a) {
            var b = this.ag;
            this.ag = a;
            if (b != this.ag) {
                this.b7("IsFocusable", b, this.ag);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "a6", {
        get: function () {
            return this.a5;
        },
        set: function (a) {
            var b = this.a5;
            this.a5 = a;
            if (b != this.a5) {
                this.b7("AnimationDuration", b, a);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "al", {
        get: function () {
            return this.ak;
        },
        set: function (a) {
            var b = this.ak;
            this.ak = a;
            if (b != this.ak) {
                this.b7("AnimationEnabled", b, a);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "o", {
        get: function () {
            return this.n;
        },
        set: function (a) {
            var b = this.n;
            this.n = a;
            if (b != this.n) {
                this.b7("AnimationType", enumGetBox(PopupAnimationType_$type, b), enumGetBox(PopupAnimationType_$type, this.n));
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "a8", {
        get: function () {
            return this.a3;
        },
        set: function (a) {
            var b = this.a3;
            this.a3 = a;
            if (b != this.a3) {
                this.b7("Elevation", b, a);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "a4", {
        get: function () {
            return this.a2;
        },
        set: function (a) {
            var b = this.a2;
            this.a2 = a;
            if (b != this.a2) {
                this.b7("ActualElevation", b, a);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "av", {
        get: function () {
            return this.au;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "cm", {
        get: function () {
            return this.ch;
        },
        set: function (a) {
            var b = this.ch;
            this.ch = a;
            if (b != this.ch) {
                this.b7("ActualUmbraShadowColor", b, a);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "cl", {
        get: function () {
            return this.cg;
        },
        set: function (a) {
            var b = this.cg;
            this.cg = a;
            if (b != this.cg) {
                this.b7("ActualPenumbraShadowColor", b, a);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "ck", {
        get: function () {
            return this.cf;
        },
        set: function (a) {
            var b = this.cf;
            this.cf = a;
            if (b != this.cf) {
                this.b7("ActualAmbientShadowColor", b, a);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "cn", {
        get: function () {
            return this.ci;
        },
        set: function (a) {
            var b = this.ci;
            this.ci = a;
            if (b != this.ci) {
                this.b7("Background", b, this.ci);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "ay", {
        get: function () {
            return this.aw;
        },
        set: function (a) {
            var b = this.aw;
            this.aw = a;
            if (b != this.aw) {
                this.b7("CornerRadius", b, this.aw);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "ar", {
        get: function () {
            return this.ah;
        },
        set: function (a) {
            var b = this.ah;
            this.ah = a;
            if (b != this.ah) {
                this.b7("IsHitTestVisible", b, this.ah);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "an", {
        get: function () {
            return this.ae;
        },
        set: function (a) {
            var b = this.ae;
            this.ae = a;
            if (b != this.ae) {
                this.b7("DisableHitTestDuringAnimation", b, this.ae);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "as", {
        get: function () {
            return this.ai;
        },
        set: function (a) {
            var b = this.ai;
            this.ai = a;
            if (b != this.ai) {
                this.b7("IsPointerEnabled", b, this.ai);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "t", {
        get: function () {
            return this.r;
        },
        set: function (a) {
            var b = this.r;
            this.r = a;
            if (b != this.r) {
                this.b7("PointerPosition", enumGetBox(PopupPointerPosition_$type, b), enumGetBox(PopupPointerPosition_$type, this.r));
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "cr", {
        get: function () {
            return this.cj;
        },
        set: function (a) {
            var b = this.cj;
            this.cj = a;
            if (b != this.cj) {
                this.b7("PointerBackground", b, this.cj);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "a1", {
        get: function () {
            return this.ax;
        },
        set: function (a) {
            var b = this.ax;
            this.ax = a;
            if (b != this.ax) {
                this.b7("PointerSize", b, this.ax);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "at", {
        get: function () {
            return this.aj;
        },
        set: function (a) {
            this.aj = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Popup.prototype, "ap", {
        get: function () {
            return this.af;
        },
        set: function (a) {
            this.af = a;
        },
        enumerable: false,
        configurable: true
    });
    Popup.prototype.u = function () {
        return new PopupView();
    };
    Popup.prototype.b9 = function (a, b, c) {
        switch (a) {
            case "IsShown":
                if (false == this.av) {
                    this.v.a9();
                }
                break;
            case "Elevation":
                this.a4 = this.a8 == -1 ? Popup.a7 : this.a8;
                break;
            case "ActualElevation":
            case "ActualUmbraShadowColor":
            case "ActualPenumbraShadowColor":
            case "ActualAmbientShadowColor":
            case "Background":
            case "CornerRadius":
                this.v.bi();
                break;
            case "AnimationEnabled":
                if (false == this.al) {
                    this.bw();
                }
                break;
            case "IsHitTestVisible":
                this.v.bc(this.ar);
                break;
            case "IsFocusable":
                this.v.bb(this.aq);
                break;
        }
    };
    Popup.prototype.bw = function () {
        if (this.ao()) {
            if (null != this.ab && this.ab.playState == 1) {
                this.ab.cancel();
            }
            if (null != this.aa && this.aa.playState == 1) {
                this.aa.cancel();
            }
        }
    };
    Popup.prototype.y = function (a) {
        var b = this.f(a);
        var c = a ? this.b() : this.a();
        var d = this.v.d(c);
        var e = new List$1(AnimationKeyFrameProperty.$, 0);
        var f = new List$1(AnimationKeyFrameProperty.$, 0);
        var g = new TranslateTransform();
        g.k = b.a;
        var h = new TranslateTransform();
        h.k = b.b;
        var i = new AnimationKeyFrameProperty(14, g);
        var j = new AnimationKeyFrameProperty(14, h);
        e.add(i);
        f.add(j);
        d.m.apply(d, __spreadArray([], __read(e.toArray()), false));
        d.m.apply(d, __spreadArray([], __read(f.toArray()), false));
        return KeyFrameAnimationFactory.f.c(d);
    };
    Popup.prototype.z = function (a) {
        var b = this.g(a);
        this.v.as(b.h);
        var c = a ? this.b() : this.a();
        var d = this.v.e(c);
        var e = new List$1(AnimationKeyFrameProperty.$, 0);
        var f = new List$1(AnimationKeyFrameProperty.$, 0);
        var g = new AnimationKeyFrameProperty(10, b.g);
        var h = new AnimationKeyFrameProperty(10, b.h);
        e.add(g);
        f.add(h);
        if (this.p == 2) {
            var i = b.c;
            var j = b.f;
            var k = new AnimationKeyFrameProperty(12, i);
            var l = new AnimationKeyFrameProperty(12, j);
            e.add(k);
            f.add(l);
        }
        d.m.apply(d, __spreadArray([], __read(e.toArray()), false));
        d.m.apply(d, __spreadArray([], __read(f.toArray()), false));
        return KeyFrameAnimationFactory.f.c(d);
    };
    Popup.prototype.a = function () {
        var a = new AnimationKeyFrameEffectTiming();
        a.g = this.a6;
        a.b = 3;
        return a;
    };
    Popup.prototype.b = function () {
        var a = new AnimationKeyFrameEffectTiming();
        a.g = this.a6;
        a.b = 3;
        return a;
    };
    Popup.prototype.bz = function () {
        this.v.av();
    };
    Popup.prototype.f = function (a) {
        var b = truncate(this.v.bl.height);
        if (b <= 0) {
            b = 500;
        }
        var c = a ? -b : 0;
        var d = a ? 0 : -b;
        if (this.p == 2) {
            c = 0;
            d = 0;
        }
        var e = ((function () {
            var $ret = new Popup_InnerAnimationInfo();
            $ret.a = c;
            $ret.b = d;
            return $ret;
        })());
        return e;
    };
    Popup.prototype.g = function (a) {
        var b = truncate(this.v.bl.height);
        if (b <= 0) {
            b = 500;
        }
        var c = a ? 0 : b;
        var d = a ? b : 0;
        var e = this.cu.top;
        var f = this.cu.top;
        var g = this.cu.left;
        var h = g;
        switch (this.p) {
            case 2:
                e = a ? this.cu.bottom : this.cu.top;
                f = a ? this.cu.top : this.cu.bottom;
                g = this.cu.left;
                h = g;
                break;
            case 1:
                e = this.cu.top;
                f = this.cu.top;
                g = this.cu.left;
                h = g;
                break;
            case 3:
            case 4:
                e = this.cu.top;
                f = e;
                g = this.cu.left;
                h = g;
                break;
        }
        var i = ((function () {
            var $ret = new Popup_OuterAnimationInfo();
            $ret.g = c;
            $ret.h = d;
            $ret.c = e;
            $ret.f = f;
            $ret.a = g;
            $ret.d = h;
            return $ret;
        })());
        return i;
    };
    Popup.prototype.ao = function () {
        if (null == this.ab && null == this.aa) {
            return false;
        }
        if (null != this.ab && this.ab.playState == 1) {
            return true;
        }
        if (null != this.aa && this.aa.playState == 1) {
            return true;
        }
        return false;
    };
    Popup.prototype.b0 = function () {
        this.v.ay();
        if (this.av) {
            this.cu = this.v.bj(this.cs, this.p, this.h);
        }
    };
    Popup.prototype.b8 = function (a, b, c) {
        this.cs = a;
        this.p = b;
        this.h = c;
        this.az = 0;
        this.v.a7();
        this.cu = this.v.bj(a, b, c);
    };
    Popup.prototype.cc = function (a, b, c) {
        if (this.au) {
            this.au = false;
            this.b7("IsShown", true, this.au);
        }
        this.b8(a, b, c);
        this.cd(true);
    };
    Popup.prototype.cd = function (a) {
        var _this = this;
        this.bw();
        var b = this.au;
        this.au = a;
        this.at = a;
        this.ap = !a;
        var c = this.g(a);
        var d = this.f(a);
        if (false == this.al) {
            var e = this.v.ar(c, d);
            c = e.p0;
            d = e.p1;
            return;
        }
        this.bz();
        this.j = this.k(this.o, this.au);
        this.j.d(function () {
            _this.j.c();
            _this.b7("IsShown", b, _this.au);
            if (_this.au) {
                if (_this.onPopup != null) {
                    _this.onPopup(_this, new OnPopupEventArgs());
                }
            }
            else {
                if (_this.onClosed != null) {
                    _this.onClosed(_this, new OnClosedEventArgs());
                }
            }
            _this.at = false;
            _this.ap = false;
            var f = _this.v.ar(c, d);
            c = f.p0;
            d = f.p1;
        });
    };
    Popup.prototype.k = function (a, b) {
        switch (a) {
            case 0: return this.m(b);
            case 1: return this.l(b);
            default: return this.m(b);
        }
    };
    Popup.prototype.m = function (a) {
        var b = this.y(a);
        var c = this.z(a);
        var d = new PopupAnimation();
        d.a.add(b);
        d.a.add(c);
        return d;
    };
    Popup.prototype.l = function (a) {
        var b = this.g(a);
        this.v.as(a ? b.h : b.g);
        var c = this.b();
        var d = this.v.c(c);
        var e = DeviceUtils.g(30);
        var f = this.v.i();
        var g = b.f - e;
        var h = b.f;
        switch (this.p) {
            case 2:
                g = a ? b.f + e : b.c + e;
                h = a ? b.f : b.c;
                f = this.v.i();
                break;
            case 1:
                g = b.f - e;
                h = b.f;
                f = this.v.i();
                break;
            case 3:
                g = b.d + e;
                h = b.d;
                f = this.v.h();
                break;
            case 4:
                g = b.d - e;
                h = b.d;
                f = this.v.h();
                break;
        }
        d.m(new AnimationKeyFrameProperty(f, a ? g : h));
        d.m(new AnimationKeyFrameProperty(f, a ? h : g));
        var i = this.v.a(c);
        i.m(new AnimationKeyFrameProperty(1, a ? 0 : 1));
        i.m(new AnimationKeyFrameProperty(1, a ? 1 : 0));
        var j = this.v.b(c);
        j.m(new AnimationKeyFrameProperty(10, (a ? b.h : b.g)));
        j.m(new AnimationKeyFrameProperty(10, (a ? b.h : b.g)));
        var k = new PopupAnimation();
        k.a.add(KeyFrameAnimationFactory.f.c(d));
        k.a.add(KeyFrameAnimationFactory.f.c(i));
        k.a.add(KeyFrameAnimationFactory.f.c(j));
        return k;
    };
    Popup.prototype.contains = function (a) {
        return this.v.j(a);
    };
    Popup.prototype.appendPopupContent = function (a) {
        this.v.at(a);
    };
    Popup.prototype.removePopupContent = function (a) {
        this.v.a8(a);
    };
    Popup.prototype.bx = function () {
        if (!this.au) {
            return;
        }
        this.cd(false);
    };
    Popup.prototype.destroy = function () {
        this.provideRenderer(null);
    };
    Popup.prototype.showRelativeToExclusionRect = function (a, b, c) {
        this.cc(a, b, c);
    };
    Popup.prototype.b1 = function (a) {
        this.cs = a;
        this.cu = this.v.bj(a, this.p, this.h);
    };
    Popup.prototype.notifySizeChanged = function () {
    };
    Popup.prototype.provideRenderer = function (a) {
        this.v.a6(a);
    };
    Popup.prototype.a9 = function () {
        return this.c();
    };
    Popup.prototype.bl = function () {
        var a = this.c();
        return a.f();
    };
    Popup.prototype.c = function () {
        var a = new PopupVisualModelExport();
        a.e = this.a4;
        a.d = this.av;
        a.c = AppearanceHelper.a(this.cm);
        a.b = AppearanceHelper.a(this.cl);
        a.a = AppearanceHelper.a(this.ck);
        return a;
    };
    Popup.prototype.s = function () {
        var a = this.t;
        if (a == 0) {
            switch (this.q) {
                case 4:
                    a = 3;
                    break;
                case 3:
                    a = 4;
                    break;
                case 2:
                    a = 2;
                    break;
                case 1:
                    a = 1;
                    break;
            }
        }
        return a;
    };
    Popup.$t = markType(Popup, 'Popup', Base.$, [INotifyPropertyChanged_$type]);
    Popup.a7 = 2;
    Popup.cq = BrushUtil.g(66, 0, 0, 0);
    Popup.cp = BrushUtil.g(30, 0, 0, 0);
    Popup.co = BrushUtil.g(20, 0, 0, 0);
    return Popup;
}(Base));
export { Popup };
