/* YUI 3.17.2 (build 9c3c78e) Copyright 2014 Yahoo! Inc. All rights reserved. Licensed under the BSD License. http://yuilibrary.com/license/ */ YUI.add("tree",function(e,t){var n=e.Lang,r="add",i="clear",s="remove",o=e.Base.create("tree",e.Base,[],{nodeClass:e.Tree.Node,nodeExtensions:[],_isYUITree:!0,_rootNodeConfig:{canHaveChildren:!0},initializer:function(e){e||(e={}),e.nodeClass&&(this.nodeClass=e.nodeClass),e.nodeExtensions&&(this.nodeExtensions=this.nodeExtensions.concat(e.nodeExtensions)),this._published||(this._published={}),this._nodeMap={},this.onceAfter("initializedChange",function(){this._composeNodeClass(),this.clear(e.rootNode,{silent:!0}),e.nodes&&this.insertNode(this.rootNode,e.nodes,{silent:!0})})},destructor:function(){this.destroyNode(this.rootNode,{silent:!0}),this.children=null,this.rootNode=null,this._nodeClass=null,this._nodeMap=null,this._published=null},appendNode:function(t,n,r){return this.insertNode(t,n,e.merge(r,{index:t.children.length,src:"append"}))},clear:function(e,t){return this._fireTreeEvent(i,{rootNode:this.createNode(e||this._rootNodeConfig),src:t&&t.src},{defaultFn:this._defClearFn,silent:t&&t.silent})},createNode:function(t){t||(t={});if(t._isYUITreeNode)return t.state.destroyed?(e.error("Cannot insert a node that has already been destroyed.",null,"tree"),null):(this._adoptNode(t),t);if(t.children){var n=[];for(var r=0,i=t.children.length;r-1;--i)r[i]=this.removeNode(n[i],t);return r},findNode:function(e,t,n,r){var i=null;return typeof t=="function"&&(r=n,n=t,t={}),this.traverseNode(e,t,function(e){if(n.call(r,e))return i=e,o.STOP_TRAVERSAL}),i},getNodeById:function(e){return this._nodeMap[e]},insertNode:function(e,t,i){i||(i={}),e||(e=this.rootNode);if("length"in t&&n.isArray(t)){var s="index"in i,o=[],u;for(var a=0,f=t.length;a0){var f=u?n:{depth:n.depth-1};for(var l=0,c=a.length;l-1){var r=t.children;n===r.length-1?r.pop():(r.splice(n,1),t._isIndexStale=!0),e.parent=null}}},_defAddFn:function(e){var t=e.index,n=e.node,r=e.parent,i;if(n.parent){if(n.parent===r){i=r.indexOf(n);if(i===t)return;i