    /*

    Siesta 5.3.0
    Copyright(c) 2009-2019 Bryntum AB
    https://bryntum.com/contact
    https://bryntum.com/products/siesta/license

    */
    Role('Siesta.Util.Role.CanInstallCQRootPseudo', {

        methods : {

            // add :root pseudo CQ selector to be able to identify 'root' level components that don't have
            // parent containers. value is 1-based
            installRootPseudoCQ : function (Ext) {
                if (!Ext) return

                var CQ      = Ext.ComponentQuery

                if (!CQ) return

                var pseudos = CQ.pseudos

                if (!pseudos.root || !pseudos.root.__IS_ROOT_PSEUDO_OVERRIDE__) {

                    var rootPseudo = function (items, value) {
                        var i = 0, l = items.length, c, result = [];
                        var findAllRoots = value === undefined

                        if (!findAllRoots) {
                            value = Number(value) - 1;
                        }

                        for (; i < l; i++) {
                            c = items[i].up();
                            var hasParentContainer = c && c.contains && c.contains(items[i]);

                            if (!hasParentContainer) {
                                result.push(items[i]);
                            }
                        }

                        if (!findAllRoots) {
                            result = result[value] ? [result[value]] : [];
                        }

                        return result;
                    }

                    rootPseudo.__IS_ROOT_PSEUDO_OVERRIDE__ = true

                    pseudos.root = rootPseudo
                }

                if (!pseudos[ "ariadne-nth-child" ]) {

                    pseudos[ "ariadne-nth-child" ] = function (items, selector) {
                        var result      = []

                        var pos         = Number(selector) - 1
                        var len         = items.length

                        for (var i = 0; i < len; i++) {
                            var cmp         = items[ i ]
                            var parentCt    = cmp.getRefOwner && cmp.getRefOwner() || cmp.ownerCt

                            var parentCtItems       = parentCt && parentCt.items

                            // parentCt could be an Ext ActionColumn which has 'items' but isn't a true container
                            if (parentCtItems && parentCtItems.getCount) {
                                var innerItemsLen   = parentCtItems.getCount()

                                if (pos < innerItemsLen) {
                                    if (parentCtItems.getAt(pos) === cmp)
                                        result.push(cmp)
                                } else {
                                    var refItems    = parentCt.getRefItems()

                                    if (refItems[ pos ] === cmp) result.push(cmp)
                                }
                            }
                        }

                        return result;
                    }
                }

                var version     = Ext.getVersion && Ext.getVersion('ext')

                if (version && version.major == 4 && !CQ.__CQ4_PATCHED__) {
                    // install workarounds for ExtJS 4 which does not pay any attention to attribute values
                    // escaping/unescaping
                    Ext.dom.Query.operators[ '=' ] = function (a, b) {
                        return a == Siesta.Sizzle.unescape(b)
                    }

                    var prevQuery   = CQ.query

                    // also ExtJS4 CQ just "split" the query by "," even that comma can be part of string expression
                    CQ.query        = function (query, root) {
                        if (/\\,/.test(query))
                            return prevQuery.call(this, { split : function () { return [ query ] } }, root)
                        else
                            return prevQuery.call(this, query, root)
                    }

                    CQ.__CQ4_PATCHED__ = true
                }
            }
        }
    });