/*
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 { XNode } from "./XNode";
import { XName } from "./XName";
import { XmlUtils } from "./XmlUtils";
import { typeCast, markType } from "./type";
import { List$1 } from "./List$1";
import { XAttribute } from "./XAttribute";
export class XContainer extends XNode {
    constructor(a) {
        super(a);
    }
    h(a) {
        let b = null;
        let c = this.backingNode;
        let d = c.childNodes;
        let e = d.length;
        let f = a.c;
        let g = a.d;
        for (let h = 0; h < e; h++) {
            let i = d.item(h);
            if (i.namespaceURI == g && i.nodeType == 1 && XmlUtils.d(i) == f) {
                b = i;
            }
        }
        if (b == null) {
            return null;
        }
        else {
            return new XElement(0, b);
        }
    }
    d() {
        return this.f(null);
    }
    e(a) {
        return this.f(a);
    }
    f(a) {
        let b = new List$1(XElement.$, 0);
        for (let c = 0; c < this.backingNode.childNodes.length; c++) {
            let d = this.backingNode.childNodes.item(c);
            if (d.nodeType == 1) {
                let e = false;
                if (a != null) {
                    if (XmlUtils.d(d) == a.c && d.namespaceURI == a.d) {
                        e = true;
                    }
                }
                else {
                    e = true;
                }
                if (e) {
                    b.add(new XElement(0, d));
                }
            }
        }
        return b;
    }
    g(a) {
        let b = this.backingNode;
        let c;
        if (typeCast(XDocument.$, this) !== null) {
            c = this.backingNode;
        }
        else {
            c = this.backingNode.ownerDocument;
        }
        if (typeCast(XAttribute.$, a) !== null) {
            a.e(b);
        }
        else if (typeCast(XElement.$, a) !== null) {
            a.j(b, c);
        }
    }
}
XContainer.$t = markType(XContainer, 'XContainer', XNode.$);
export class XDocument extends XContainer {
    constructor(a, ..._rest) {
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    let c = _rest[0];
                    super(c);
                }
                break;
            case 1:
                {
                    super(XmlUtils.j());
                }
                break;
        }
    }
    get_c() {
        return 9;
    }
    get c() {
        return this.get_c();
    }
    static i(a) {
        return new XDocument(0, XmlUtils.n(a));
    }
}
XDocument.$t = markType(XDocument, 'XDocument', XContainer.$);
export class XElement extends XContainer {
    constructor(a, ..._rest) {
        a = (a == void 0) ? 0 : a;
        switch (a) {
            case 0:
                {
                    let c = _rest[0];
                    super(c);
                }
                break;
            case 1:
                {
                    let c = _rest[0];
                    let d = [c, null];
                    {
                        let f = d[0];
                        let g = d[1];
                        super(XmlUtils.o(f.c, f.d));
                        let h = g == null ? "" : g.toString();
                        this.i = h;
                    }
                }
                break;
            case 2:
                {
                    let c = _rest[0];
                    let d = _rest[1];
                    super(XmlUtils.o(c.c, c.d));
                    let e = d == null ? "" : d.toString();
                    this.i = e;
                }
                break;
        }
    }
    get i() {
        return XmlUtils.c(this.backingNode);
    }
    set i(a) {
        XmlUtils.h(this.backingNode, a);
    }
    get_c() {
        return 1;
    }
    get c() {
        return this.get_c();
    }
    get l() {
        return XName.e(XmlUtils.d(this.backingNode), this.backingNode.namespaceURI);
    }
    k(a) {
        return new XAttribute(XmlUtils.i(this.backingNode, a.c, a.d));
    }
    j(a, b) {
        if (this.backingNode.ownerDocument != b) {
            this.backingNode = XmlUtils.p(b, this.backingNode);
        }
        a.appendChild(this.backingNode);
    }
}
XElement.$t = markType(XElement, 'XElement', XContainer.$);
//# sourceMappingURL=XContainer_combined.js.map