/*
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 { IAxisAnnotationManager_$type } from "./IAxisAnnotationManager";
import { LabelPosition } from "./LabelPosition";
import { Base, runOn, delegateRemove, delegateCombine, fromEnum, markType } from "igniteui-react-core/ES2015/type";
export class AxisAnnotationManager extends Base {
    constructor() {
        super(...arguments);
        this._owner = null;
    }
    get owner() {
        return this._owner;
    }
    set owner(a) {
        this._owner = a;
    }
    onAddAnnotations(a) {
        let b = 0;
        for (let c = 0; c < a.al.count; c++) {
            b = this.a(a, a.al._inner[c], b);
        }
        for (let d = 0; d < a.ak.count; d++) {
            b = this.a(a, a.ak._inner[d], b);
        }
        a.bm.count = b;
        a.bn.count = b;
    }
    a(a, b, c) {
        let d = NaN;
        d = b.value;
        let e = new LabelPosition(a.d8(d));
        let f = e.d;
        if (a.ce) {
            if (e.d > a.it.bottom || e.d < a.it.top) {
                return c;
            }
        }
        else {
            if (e.d > a.it.right || e.d < a.it.left) {
                return c;
            }
        }
        let g = a.bm.item(c);
        let h = a.bn.item(c);
        let i = 100 + c * 2;
        c++;
        h.ak = b.resolveLabelValue();
        if (b.textColor != null) {
            h.am = b.textColor;
        }
        g._fill = b.background;
        g._stroke = b.outline;
        g.ac = b.strokeThickness;
        g.s = i;
        h.s = i + 1;
        b.checkForExtentReset(() => e.b = true);
        e.a = true;
        e.c = b.backgroundPadding;
        a.ct.add(e);
        a.cs.add1(h.ak);
        return c;
    }
    arrangeAnnotations(a, b, c, d, e, f, g, h, i, j) {
        for (let k = 0; k < a.bn.count; k++) {
            let l = a.bm.item(k);
            let m = -1;
            for (let n = c.count - 1; n >= 0; n--) {
                if (c._inner[n] == a.bn.item(k)) {
                    m = n;
                    break;
                }
            }
            if (m == -1) {
                continue;
            }
            if (e) {
                b.z(l, a.bn.item(k), a.ct._inner[m], d._inner[m], g, h, i, j);
                b.aq(l, a.bn.item(k), a.ct._inner[m], d._inner[m], g, h, i, j, f);
            }
            else {
                b.z(l, a.bn.item(k), a.ct._inner[m], d._inner[m], g, h, i, j);
            }
        }
    }
    b(a, b) {
        this.owner.cf = true;
        this.owner.gy();
    }
    c(a) {
        if (a.oldItems != null) {
            for (let b = 0; b < a.oldItems.count; b++) {
                let c = a.oldItems.item(b);
                if (c == null) {
                    continue;
                }
                let d = c;
                d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.b));
            }
        }
        if (a.newItems != null) {
            for (let e = 0; e < a.newItems.count; e++) {
                let f = a.newItems.item(e);
                if (f == null) {
                    continue;
                }
                let g = f;
                g.propertyChanged = delegateCombine(g.propertyChanged, runOn(this, this.b));
            }
        }
        this.owner.cf = true;
        this.owner.gy();
    }
    onAnnotionsChanged(a, b, c) {
        this.c(c);
    }
    onAnnotionsReset(a, b, c) {
        for (let d of fromEnum(b)) {
            d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.b));
        }
    }
    onAutoAnnotionsChanged(a, b, c) {
        this.c(c);
    }
    onAutoAnnotionsReset(a, b, c) {
        for (let d of fromEnum(b)) {
            d.propertyChanged = delegateRemove(d.propertyChanged, runOn(this, this.b));
        }
    }
}
AxisAnnotationManager.$t = markType(AxisAnnotationManager, 'AxisAnnotationManager', Base.$, [IAxisAnnotationManager_$type]);
