/*
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 { 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
 */
export let TextHeaderCell = /*@__PURE__*/ (() => {
    class TextHeaderCell extends GridCellBase {
        constructor(a) {
            super(a);
            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);
            let b = 18;
            let c = 18;
            let 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;
            let 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;
            let f = this.cd.x;
            this.cd.x = false;
            this.cd.a5();
            this.cd.x = f;
            let g = 18;
            let 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);
            let i = this.cf;
            i.propertyChanged = delegateCombine(i.propertyChanged, runOn(this, this.cr));
            let j = this.cd;
            j.dialogOpening = delegateCombine(j.dialogOpening, runOn(this, this.cs));
            let k = this.cd;
            k.filterChanging = delegateCombine(k.filterChanging, runOn(this, this.cu));
            let 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));
        }
        get cm() {
            return this.cj;
        }
        get cg() {
            return this.cf;
        }
        get ce() {
            return this.cd;
        }
        get cc() {
            return this.cb;
        }
        set cc(a) {
            let b = this.cb;
            this.cb = a;
            this.bh("ColumnOptionsIconBehavior", enumGetBox(ColumnOptionsIconBehavior_$type, b), enumGetBox(ColumnOptionsIconBehavior_$type, this.cb));
        }
        get ca() {
            return this.b9;
        }
        set ca(a) {
            let b = this.b9;
            this.b9 = a;
            this.bh("ColumnOptionsIconAlignment", enumGetBox(ColumnOptionsIconAlignment_$type, b), enumGetBox(ColumnOptionsIconAlignment_$type, this.b9));
        }
        s(a) {
            return true;
        }
        bx(a, b) {
            super.bx(a, b);
            a -= 21;
            if (this.ci) {
                a -= 15;
            }
            let c = Math.max(0, a - b);
            if (c != this.co) {
                this.co = c;
                this.cj.setRawStyleProperty("max-width", c.toString() + "px");
            }
        }
        br(a, b) {
            super.br(a, b);
            let c = Math.max(0, a - b);
            if (this.cn != c) {
                this.cn = c;
                this.cj.setRawStyleProperty("max-height", c.toString() + "px");
            }
        }
        by(a, b, c, d) {
            this.cd.a7();
        }
        cr(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;
            }
        }
        cy(a) {
            if (this.b.isGridDragging) {
                return;
            }
            switch (this.cc) {
                case 2:
                case 3:
                    this.cd.bk();
                    break;
            }
        }
        cx(a) {
            switch (this.cc) {
                case 2:
                case 3:
                    this.cd.a5();
                    break;
            }
        }
        ct(a, b) {
            this.b.columnFilterChanged(b.a);
        }
        cu(a, b) {
            this.b.columnFilterChanging(b.a);
        }
        cs(a, b) {
            if (this.b != null) {
                b.a = this.d.getColumn();
                this.b.cancelEditMode(false);
            }
        }
        bf(a, b, c) {
            super.bf(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;
                }
            }
        }
        bv(a, b, c, d) {
            super.bv(a, b, c, d);
            this.cd.ai = a;
            this.cd.aj = c;
        }
        cw() {
            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");
                }
            }
        }
        cv() {
            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;
            }
        }
        bh(a, b, c) {
            super.bh(a, b, c);
            switch (a) {
                case "ColumnOptionsIconAlignment":
                    this.cw();
                    break;
                case "ColumnOptionsIconBehavior":
                    this.cv();
                    break;
            }
        }
        onContactStarted(e_, a) {
            if (e_.button == 2) {
                return;
            }
            let filterIconCanvas_ = this.cd.aq();
            let b = (e_.originalEvent.srcElement === filterIconCanvas_ || e_.originalEvent.target === filterIconCanvas_);
            if (b) {
                this.ch = true;
                return;
            }
            if (this.cd.y) {
                this.cd.a2();
            }
            super.onContactStarted(e_, a);
        }
        onContactCompleted(e_, a) {
            if (!this.ch) {
                super.onContactCompleted(e_, a);
            }
            this.ch = false;
        }
        get_q() {
            return true;
        }
    }
    TextHeaderCell.$t = /*@__PURE__*/ markType(TextHeaderCell, 'TextHeaderCell', GridCellBase.$);
    return TextHeaderCell;
})();
//# sourceMappingURL=TextHeaderCell.js.map
