/*
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 { GridCellBase } from "./GridCellBase";
import { GridSortIndicator } from "./GridSortIndicator";
import { GridFilterDialog } from "./GridFilterDialog";
import { ColumnOptionsIconBehavior_$type } from "./ColumnOptionsIconBehavior";
import { ColumnOptionsIconAlignment_$type } from "./ColumnOptionsIconAlignment";
import { enumGetBox, runOn, delegateCombine, markType } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
var TextHeaderCell = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(TextHeaderCell, _super);
    function TextHeaderCell(a) {
        var _this = _super.call(this, a) || this;
        _this.cj = null;
        _this.cf = null;
        _this.cd = null;
        _this.b9 = 0;
        _this.b8 = 0;
        _this.cb = 3;
        _this.cl = null;
        _this.co = -1;
        _this.cn = -1;
        _this.ch = false;
        _this.ck = null;
        _this.ci = false;
        _this.cj = a.createElement("span");
        _this.z.setRawStyleProperty("text-align", "left");
        _this.z.setRawStyleProperty("vertical-align", "middle");
        _this.cj.setRawStyleProperty("display", "inline-block");
        _this.cj.setRawStyleProperty("line-height", "normal");
        _this.cj.setRawStyleProperty("vertical-align", "middle");
        _this.cj.setRawStyleProperty("overflow", "hidden");
        _this.cj.setRawStyleProperty("white-space", "nowrap");
        _this.cj.setRawStyleProperty("text-overflow", "ellipsis");
        _this.z.append(_this.cj);
        var b = 18;
        var c = 18;
        var d = a.createElement("div");
        d.setAttribute("aria-hidden", "true");
        d.setRawStyleProperty("display", "none");
        d.setRawStyleProperty("vertical-align", "middle");
        d.setRawStyleProperty("width", b + "px");
        d.setRawStyleProperty("height", c + "px");
        _this.ck = d;
        var e = a.getSubRenderer(d);
        _this.cd = new GridFilterDialog();
        _this.cd.bf(e, _this.z, a);
        _this.z.append(d);
        _this.cd.a8(b, c);
        _this.cd.af = 24;
        var f = _this.cd.x;
        _this.cd.x = false;
        _this.cd.a5();
        _this.cd.x = f;
        var g = 18;
        var h = 18;
        d = a.createElement("div");
        d.setAttribute("aria-hidden", "true");
        d.setRawStyleProperty("display", "inline-block");
        d.setRawStyleProperty("vertical-align", "middle");
        d.setRawStyleProperty("width", "0px");
        d.setRawStyleProperty("height", h + "px");
        d.setRawStyleProperty("margin", "0 0 0 5px");
        _this.cl = d;
        e = a.getSubRenderer(d);
        _this.cf = new GridSortIndicator();
        _this.cf.l = false;
        _this.cf.ax(e);
        _this.z.append(d);
        _this.cf.ar(g, h);
        var i = _this.cf;
        i.propertyChanged = delegateCombine(i.propertyChanged, runOn(_this, _this.cr));
        var j = _this.cd;
        j.dialogOpening = delegateCombine(j.dialogOpening, runOn(_this, _this.cs));
        var k = _this.cd;
        k.filterChanging = delegateCombine(k.filterChanging, runOn(_this, _this.cu));
        var l = _this.cd;
        l.filterChanged = delegateCombine(l.filterChanged, runOn(_this, _this.ct));
        _this.z.listen("mouseenter", runOn(_this, _this.cy));
        _this.z.listen("mouseleave", runOn(_this, _this.cx));
        return _this;
    }
    Object.defineProperty(TextHeaderCell.prototype, "cm", {
        get: function () {
            return this.cj;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TextHeaderCell.prototype, "cg", {
        get: function () {
            return this.cf;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TextHeaderCell.prototype, "ce", {
        get: function () {
            return this.cd;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TextHeaderCell.prototype, "cc", {
        get: function () {
            return this.cb;
        },
        set: function (a) {
            var b = this.cb;
            this.cb = a;
            this.bh("ColumnOptionsIconBehavior", enumGetBox(ColumnOptionsIconBehavior_$type, b), enumGetBox(ColumnOptionsIconBehavior_$type, this.cb));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TextHeaderCell.prototype, "ca", {
        get: function () {
            return this.b9;
        },
        set: function (a) {
            var b = this.b9;
            this.b9 = a;
            this.bh("ColumnOptionsIconAlignment", enumGetBox(ColumnOptionsIconAlignment_$type, b), enumGetBox(ColumnOptionsIconAlignment_$type, this.b9));
        },
        enumerable: true,
        configurable: true
    });
    TextHeaderCell.prototype.s = function (a) {
        return true;
    };
    TextHeaderCell.prototype.bx = function (a, b) {
        _super.prototype.bx.call(this, a, b);
        a -= 21;
        if (this.ci) {
            a -= 15;
        }
        var c = Math.max(0, a - b);
        if (c != this.co) {
            this.co = c;
            this.cj.setRawStyleProperty("max-width", c.toString() + "px");
        }
    };
    TextHeaderCell.prototype.br = function (a, b) {
        _super.prototype.br.call(this, a, b);
        var c = Math.max(0, a - b);
        if (this.cn != c) {
            this.cn = c;
            this.cj.setRawStyleProperty("max-height", c.toString() + "px");
        }
    };
    TextHeaderCell.prototype.by = function (a, b, c, d) {
        this.cd.a7();
    };
    TextHeaderCell.prototype.cr = function (a, b) {
        switch (b.propertyName) {
            case "CurrentOpacity":
                if (this.cg.r > 0) {
                    this.cl.setRawStyleProperty("width", "18px");
                    if (this.b8 == 2) {
                        this.cl.setRawStyleProperty("margin", "0 5px 0 0");
                    }
                    else {
                        this.cl.setRawStyleProperty("margin", "0 0 0 5px");
                    }
                }
                else {
                    this.cl.setRawStyleProperty("width", "0px");
                    this.cl.setRawStyleProperty("margin", "0");
                }
                break;
        }
    };
    TextHeaderCell.prototype.cy = function (a) {
        if (this.b.isGridDragging) {
            return;
        }
        switch (this.cc) {
            case 2:
            case 3:
                this.cd.bk();
                break;
        }
    };
    TextHeaderCell.prototype.cx = function (a) {
        switch (this.cc) {
            case 2:
            case 3:
                this.cd.a5();
                break;
        }
    };
    TextHeaderCell.prototype.ct = function (a, b) {
        this.b.columnFilterChanged(b.a);
    };
    TextHeaderCell.prototype.cu = function (a, b) {
        this.b.columnFilterChanging(b.a);
    };
    TextHeaderCell.prototype.cs = function (a, b) {
        if (this.b != null) {
            b.a = this.d.getColumn();
            this.b.cancelEditMode(false);
        }
    };
    TextHeaderCell.prototype.bf = function (a, b, c) {
        _super.prototype.bf.call(this, a, b, c);
        this.b8 = c;
        this.cd.k = c;
        if (c == 2) {
            this.z.removeChild(this.cl);
            this.z.removeChild(this.ck);
            this.cj.before(this.ck);
            this.ck.before(this.cl);
            if (this.ca == 1) {
                this.ck.setRawStyleProperty("margin", "0 5px 0 0");
                this.cd.l = this.b8;
            }
            else {
                this.ck.setRawStyleProperty("margin", "0");
                this.cd.l = 0;
            }
        }
        else {
            this.z.removeChild(this.cl);
            this.z.removeChild(this.cj);
            this.ck.before(this.cj);
            this.ck.before(this.cl);
            if (this.ca == 1) {
                this.ck.setRawStyleProperty("margin", "0 0 0 5px");
                this.cd.l = this.b8;
            }
            else {
                this.ck.setRawStyleProperty("margin", "0");
                this.cd.l = 2;
            }
        }
    };
    TextHeaderCell.prototype.bv = function (a, b, c, d) {
        _super.prototype.bv.call(this, a, b, c, d);
        this.cd.ai = a;
        this.cd.aj = c;
    };
    TextHeaderCell.prototype.cw = function () {
        if (this.ca == 2 || this.ca == 0) {
            if (this.b8 == 2) {
                this.cd.l = 0;
            }
            else {
                this.cd.l = 2;
            }
        }
        else {
            this.cd.l = this.b8;
            if (this.b8 == 2) {
                this.ck.setRawStyleProperty("margin", "0 5px 0 0");
            }
            else {
                this.ck.setRawStyleProperty("margin", "0 0 0 5px");
            }
        }
    };
    TextHeaderCell.prototype.cv = function () {
        switch (this.cc) {
            case 1:
                this.cd.x = false;
                this.cd.bk();
                break;
            case 2:
                this.cd.x = false;
                break;
            case 3:
                this.cd.x = true;
                break;
        }
    };
    TextHeaderCell.prototype.bh = function (a, b, c) {
        _super.prototype.bh.call(this, a, b, c);
        switch (a) {
            case "ColumnOptionsIconAlignment":
                this.cw();
                break;
            case "ColumnOptionsIconBehavior":
                this.cv();
                break;
        }
    };
    TextHeaderCell.prototype.onContactStarted = function (e_, a) {
        if (e_.button == 2) {
            return;
        }
        var filterIconCanvas_ = this.cd.aq();
        var b = (e_.originalEvent.srcElement === filterIconCanvas_ || e_.originalEvent.target === filterIconCanvas_);
        if (b) {
            this.ch = true;
            return;
        }
        if (this.cd.y) {
            this.cd.a2();
        }
        _super.prototype.onContactStarted.call(this, e_, a);
    };
    TextHeaderCell.prototype.onContactCompleted = function (e_, a) {
        if (!this.ch) {
            _super.prototype.onContactCompleted.call(this, e_, a);
        }
        this.ch = false;
    };
    TextHeaderCell.prototype.get_q = function () {
        return true;
    };
    TextHeaderCell.$t = markType(TextHeaderCell, 'TextHeaderCell', GridCellBase.$);
    return TextHeaderCell;
}(GridCellBase));
export { TextHeaderCell };
//# sourceMappingURL=TextHeaderCell.js.map
