(function(){function g(a){var b;if((b=a.parent)&&b.lastChild==a)return a.previousSibling}function k(a,b,d){if(!d){a&&a._syncIcon();var c;(c=b.parent)&&c.lastChild==b&&(c=b.previousSibling)&&c._syncIcon()}}var l=zul.sel.Treechildren=zk.$extends(zul.Widget,{bind_:function(a,b,d){this.$supers(l,"bind_",arguments);zWatch.listen({onResponse:this});var c=this;d.push(function(){var a=c.getTree(),b;a&&a._nativebar&&(b=a.frozen)&&b._syncFrozen()})},unbind_:function(){zWatch.unlisten({onResponse:this});this.$supers(l,
"unbind_",arguments)},onResponse:function(){if(this.desktop){var a=this.getTree();a&&a.frozen&&(a._shallSyncFrozen=!0,a.onSize())}},getTree:function(){return this.isTopmost()?this.parent:this.parent?this.parent.getTree():null},getLinkedTreerow:function(){return this.parent?this.parent.treerow:null},isTopmost:function(){return this.parent&&this.parent.$instanceof(zul.sel.Tree)},isRealElement:function(){return!1},insertBefore:function(a,b,d){var c=g(a);if(this.$supers("insertBefore",arguments))return k(c,
a,d),!0},appendChild:function(a,b){var d=g(a);if(this.$supers("appendChild",arguments))return this.insertingBefore_||k(d,a,b),!0},insertChildHTML_:function(a,b,d){var c,e=this.isTopmost();b&&(b=b.$n()?b.getFirstNode_():null);b||e||(c=this.getCaveNode()||this.parent.getCaveNode());b?jq(b).before(a.redrawHTML_()):c?jq(c).after(a.redrawHTML_()):e?jq(this.parent.$n("rows")).append(a.redrawHTML_()):jq(this).append(a.redrawHTML_());a.bind(d)},getCaveNode:function(){for(var a,b=this.lastChild;b;b=b.previousSibling)if(a=
b.getCaveNode())return b.treechildren&&(b=b.treechildren.getCaveNode())&&(a=b),a},isRealVisible:function(){return this._isRealVisible()&&this.$supers("isRealVisible",arguments)},_isRealVisible:function(){var a;return this.isVisible()&&(this.isTopmost()||(a=this.parent)&&a.isOpen()&&a._isRealVisible())},getItems:function(a,b){a=a||[];for(var d=b&&b.skipHidden,c=this.firstChild;c;c=c.nextSibling)if(!d||c.isVisible())a.push(c),!c.treechildren||d&&!c.isOpen()||c.treechildren.getItems(a,b);return a},getItemCount:function(a){for(var b=
0,d=a&&a.skipHidden,c=this.firstChild;c;c=c.nextSibling)if(!d||c.isVisible())b++,!c.treechildren||d&&!c.isOpen()||(b+=c.treechildren.getItemCount(a));return b},beforeParentChanged_:function(a){var b=this.getTree();b&&b._onTreechildrenRemoved(this);a&&(b=a.$instanceof(zul.sel.Tree)?a:a.getTree())&&b._onTreechildrenAdded(this);this.$supers("beforeParentChanged_",arguments)},removeHTML_:function(a){for(var b,d=this.firstChild;d;d=d.nextSibling)(b=d.$n())&&d.removeHTML_(b);this.$supers("removeHTML_",
arguments)},getOldWidget_:function(a){var b=this.$supers("getOldWidget_",arguments);return b&&b.$instanceof(zul.sel.Treerow)?(b=b.parent)?b.treechildren:null:b},$n:function(a){return this.isTopmost()?this.getTree().$n("rows"):this.firstChild?a?this.firstChild.$n(a):this.firstChild.$n():null},replaceWidget:function(a){for(;this.firstChild!=this.lastChild;)this.lastChild.detach();this.firstChild&&this.firstChild.treechildren&&this.firstChild.treechildren.detach();zul.sel.Treeitem._syncSelItems(this,
a);this.$supers("replaceWidget",arguments)},onChildAdded_:function(a){this.$supers("onChildAdded_",arguments);this.desktop&&this.getTree()._syncSize()},onChildRemoved_:function(a){this.$supers("onChildRemoved_",arguments);this.desktop&&this.getTree()._syncSize()},replaceChildHTML_:function(a,b,d,c,e){var f=a.getOldWidget_(b);f?f.unbind(c):this.shallChildROD_(a)&&this.$class._unbindrod(a);e=a.redrawHTML_(c,e);if(zk.ie11_||zk.edge){b=jq(b);var h=e.length;f=b[0];if(1048576<h){var g=e.lastIndexOf("</tr>",
h/2);h=e.substr(0,g);e=e.substr(g);f.insertAdjacentHTML("afterend",e);f.insertAdjacentHTML("afterend",h)}else f.insertAdjacentHTML("afterend",e);b.remove()}else jq(b).replaceWith(e);a.bind(d,c)}})})();
