/*
    *
    * Wijmo Library 5.20181.462
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
"use strict";var __extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wjcCore=require("wijmo/wijmo"),wjcSelfRef=require("wijmo/wijmo.nav"),wjcSelf=wjcSelfRef||exports;window.wijmo=window.wijmo||{},window.wijmo.nav=wjcSelf;var TreeView=function(e){function t(n,r){var i=e.call(this,n)||this;i._itmPath=new _BindingArray("items"),i._dspPath=new _BindingArray("header"),i._imgPath=new _BindingArray,i._html=!1,i._animated=!0,i._xpndOnClick=!0,i._autoColl=!0,i._showChk=!1,i._srch="",i._isReadOnly=!0,i.itemsSourceChanged=new wjcCore.Event,i.loadingItems=new wjcCore.Event,i.loadedItems=new wjcCore.Event,i.itemClicked=new wjcCore.Event,i.selectedItemChanged=new wjcCore.Event,i.checkedItemsChanged=new wjcCore.Event,i.isCollapsedChanging=new wjcCore.Event,i.isCollapsedChanged=new wjcCore.Event,i.isCheckedChanging=new wjcCore.Event,i.isCheckedChanged=new wjcCore.Event,i.formatItem=new wjcCore.Event,i.dragStart=new wjcCore.Event,i.dragOver=new wjcCore.Event,i.drop=new wjcCore.Event,i.dragEnd=new wjcCore.Event,i.nodeEditStarting=new wjcCore.Event,i.nodeEditStarted=new wjcCore.Event,i.nodeEditEnding=new wjcCore.Event,i.nodeEditEnded=new wjcCore.Event;var o=i.getTemplate();i.applyTemplate("wj-control wj-content wj-treeview",o,{_root:"root"});var s=i.hostElement;return wjcCore.setAttribute(s,"role","tree",!0),wjcCore.addClass(i._root,t._CNDL),wjcCore.setAttribute(i._root,"role","group",!0),i.addEventListener(s,"mousedown",i._mousedown.bind(i)),i.addEventListener(s,"click",i._click.bind(i)),i.addEventListener(s,"keydown",i._keydown.bind(i)),i.addEventListener(s,"keypress",i._keypress.bind(i)),i.addEventListener(s,"wheel",function(e){s.scrollHeight>s.offsetHeight&&(e.deltaY<0&&0==s.scrollTop||e.deltaY>0&&s.scrollTop+s.offsetHeight>=s.scrollHeight)&&(e.preventDefault(),e.stopPropagation())}),i.addEventListener(s,"blur",function(e){i._edtNode&&!wjcCore.contains(i._edtNode.element,wjcCore.getActiveElement())&&i.finishEditing()},!0),i.initialize(r),i.refresh(),i}return __extends(t,e),Object.defineProperty(t.prototype,"itemsSource",{get:function(){return this._items},set:function(e){this._items!=e&&(this._items=wjcCore.asArray(e),this.onItemsSourceChanged(),this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"childItemsPath",{get:function(){return this._itmPath.path},set:function(e){e!=this.childItemsPath&&(this._itmPath.path=e,this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"displayMemberPath",{get:function(){return this._dspPath.path},set:function(e){e!=this.displayMemberPath&&(this._dspPath.path=e,this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageMemberPath",{get:function(){return this._imgPath.path},set:function(e){e!=this.imageMemberPath&&(this._imgPath.path=e,this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isContentHtml",{get:function(){return this._html},set:function(e){e!=this._html&&(this._html=wjcCore.asBoolean(e),this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showCheckboxes",{get:function(){return this._showChk},set:function(e){e!=this._showChk&&(this._showChk=wjcCore.asBoolean(e),this._reload())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoCollapse",{get:function(){return this._autoColl},set:function(e){this._autoColl=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAnimated",{get:function(){return this._animated},set:function(e){e!=this._animated&&(this._animated=wjcCore.asBoolean(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isReadOnly",{get:function(){return this._isReadOnly},set:function(e){this._isReadOnly=wjcCore.asBoolean(e),wjcCore.toggleClass(this.hostElement,"wj-state-readonly",this.isReadOnly)},enumerable:!0,configurable:!0}),t.prototype.startEditing=function(e){if(this.isReadOnly)return!1;if(e||(e=this.selectedNode),!e||e.isDisabled)return!1;if(!this.finishEditing())return!1;var n=e.element.querySelector("."+t._CNDT);if(!n)return!1;var r=new TreeNodeEventArgs(e);if(!this.onNodeEditStarting(r))return!1;n.tabIndex=0,n.focus(),n.contentEditable="true",n.style.cursor="auto";var i=document.createRange();i.selectNodeContents(n);var o=getSelection();return o.removeAllRanges(),o.addRange(i),n.focus(),wjcCore.setAttribute(n,"autocomplete","off"),wjcCore.setAttribute(n,"autocorrect","off"),this._edtNode=e,this.onNodeEditStarted(r),!0},t.prototype.finishEditing=function(e){var n=this._edtNode;if(n){var r=n.element.querySelector("."+t._CNDT);if(!r)return!1;var i=new TreeNodeEventArgs(n);if(!this.onNodeEditEnding(i))return!1;var o=n.dataItem,s=n.level;this.isContentHtml?e?r.innerHTML=this._dspPath.getValue(o,s):this._dspPath.setValue(o,s,r.innerHTML):e?r.textContent=this._dspPath.getValue(o,s):this._dspPath.setValue(o,s,r.textContent),document.createRange().selectNodeContents(r),getSelection().removeAllRanges(),r.contentEditable="false",r.style.cursor="",this._edtNode=null,this.onNodeEditEnded(i)}return!0},Object.defineProperty(t.prototype,"allowDragging",{get:function(){return null!=this._dd},set:function(e){if(e!=this.allowDragging){wjcCore.asBoolean(e)?this._dd=new _TreeDragDropManager(this):(this._dd.dispose(),this._dd=null);for(var n=this.hostElement.querySelectorAll("."+t._CND),r=0;r<n.length;r++){var i=n[r];wjcCore.setAttribute(i,"draggable",!!this._dd||null)}}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"expandOnClick",{get:function(){return this._xpndOnClick},set:function(e){this._xpndOnClick=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedItem",{get:function(){return this._selNode?this._selNode.dataItem:null},set:function(e){e!=this.selectedItem&&(this.selectedNode=e?this.getNode(e):null)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedNode",{get:function(){return this._selNode},set:function(e){e!=this.selectedNode&&(this._prevSel=this._selNode,e?e.select():this._selNode&&(wjcCore.removeClass(this._selNode.element,t._CSEL),this._selNode=null,this.onSelectedItemChanged()))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedPath",{get:function(){for(var e=[],t=this.selectedNode;t;t=t.parentNode){var n=this._dspPath.getValue(t.dataItem,t.level);e.splice(0,0,n)}return e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"checkedItems",{get:function(){if(null==this._chkItems){var e=t,n="."+e._CND+"."+e._CEMP+" > input:checked."+e._CNDC,r=this._root.querySelectorAll(n);this._chkItems=[];for(var i=0;i<r.length;i++){var o=r[i].parentElement[e._DATAITEM_KEY];this._chkItems.push(o)}}return this._chkItems},set:function(e){if(this.showCheckboxes)for(var n=t,r="."+n._CND+"."+n._CEMP,i=this._root.querySelectorAll(r),o=0;o<i.length;o++){var s=new TreeNode(this,i[o]),a=e.indexOf(s.dataItem)>-1;s.isChecked!=a&&(s.isChecked=a)}},enumerable:!0,configurable:!0}),t.prototype.checkAllItems=function(e){if(this.showCheckboxes)for(var n=t,r="."+n._CND+"."+n._CEMP,i=this._root.querySelectorAll(r),o=0;o<i.length;o++){var s=new TreeNode(this,i[o]);s.isChecked!=e&&(s.isChecked=e)}},Object.defineProperty(t.prototype,"totalItemCount",{get:function(){return this.hostElement.querySelectorAll("."+t._CND).length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lazyLoadFunction",{get:function(){return this._lazyLoad},set:function(e){e!=this._lazyLoad&&(this._lazyLoad=wjcCore.asFunction(e),this._reload())},enumerable:!0,configurable:!0}),t.prototype.getFirstNode=function(e,n){var r=this.hostElement.querySelector("."+t._CND),i=r?new TreeNode(this,r):null;return e&&i&&!i.element.offsetHeight&&(i=i.next(e,n)),n&&i&&i.isDisabled&&(i=i.next(e,n)),i},t.prototype.getLastNode=function(e,n){var r=this.hostElement.querySelectorAll("."+t._CND+":last-child"),i=r.length?new TreeNode(this,r[r.length-1]):null;return e&&i&&!i.element.offsetHeight&&(i=i.previous(e,n)),n&&i&&i.isDisabled&&(i=i.previous(e,n)),i},Object.defineProperty(t.prototype,"nodes",{get:function(){return TreeNode._getChildNodes(this,this._root)},enumerable:!0,configurable:!0}),t.prototype.getNode=function(e){this._isDirty&&this._loadTree();for(var n=this.hostElement.querySelectorAll("."+t._CND),r=0;r<n.length;r++){var i=n[r];if(i[t._DATAITEM_KEY]==e)return new TreeNode(this,i)}return null},t.prototype.addChildNode=function(e,t){var n=this._createNode(t),r=this.nodes;return r?e<r.length?n.move(r[e],DropPosition.Before):n.move(r[r.length-1],DropPosition.After):n.move(this,DropPosition.Into),n},t.prototype.collapseToLevel=function(e){var t=this._animated,n=this._autoColl;this._animated=this._autoColl=!1,this._collapseToLevel(this.nodes,e,0),this._animated=t,this._autoColl=n},t.prototype.loadTree=function(e){this._loadTree(e)},t.prototype.onItemsSourceChanged=function(e){this.itemsSourceChanged.raise(this,e)},t.prototype.onLoadingItems=function(e){return this.loadingItems.raise(this,e),!e.cancel},t.prototype.onLoadedItems=function(e){this.loadedItems.raise(this,e)},t.prototype.onItemClicked=function(e){this.itemClicked.raise(this,e)},t.prototype.onSelectedItemChanged=function(e){this.selectedItemChanged.raise(this,e)},t.prototype.onCheckedItemsChanged=function(e){this._chkItems=null,this.checkedItemsChanged.raise(this,e)},t.prototype.onIsCollapsedChanging=function(e){return this.isCollapsedChanging.raise(this,e),!e.cancel},t.prototype.onIsCollapsedChanged=function(e){this.isCollapsedChanged.raise(this,e)},t.prototype.onIsCheckedChanging=function(e){return this.isCheckedChanging.raise(this,e),!e.cancel},t.prototype.onIsCheckedChanged=function(e){this.isCheckedChanged.raise(this,e)},t.prototype.onFormatItem=function(e){this.formatItem.raise(this,e)},t.prototype.onDragStart=function(e){return this.dragStart.raise(this,e),!e.cancel},t.prototype.onDragOver=function(e){return this.dragOver.raise(this,e),!e.cancel},t.prototype.onDrop=function(e){return this.drop.raise(this,e),!e.cancel},t.prototype.onDragEnd=function(e){this.dragEnd.raise(this,e)},t.prototype.onNodeEditStarting=function(e){return this.nodeEditStarting.raise(this,e),!e.cancel},t.prototype.onNodeEditStarted=function(e){this.nodeEditStarted.raise(this,e)},t.prototype.onNodeEditEnding=function(e){return this.nodeEditEnding.raise(this,e),!e.cancel},t.prototype.onNodeEditEnded=function(e){this.nodeEditEnded.raise(this,e)},t.prototype.refresh=function(t){void 0===t&&(t=!0),e.prototype.refresh.call(this,t),!this.isUpdating&&this._isDirty&&this._loadTree()},t.prototype._raiseCheckedItemsChanged=function(){var e=this;this._toItemsChanged&&clearTimeout(this._toItemsChanged),this._toItemsChanged=setTimeout(function(){e._toItemsChanged=null,e.onCheckedItemsChanged()},10)},t.prototype._reload=function(){this._isDirty=!0,this.invalidate()},t.prototype._createNode=function(e){return new t(document.createElement("div"),{childItemsPath:this.childItemsPath,displayMemberPath:this.displayMemberPath,imageMemberPath:this.imageMemberPath,isContentHtml:this.isContentHtml,showCheckboxes:this.showCheckboxes,itemsSource:[e]}).getFirstNode()},t.prototype._mousedown=function(e){if(!e.defaultPrevented){var n=wjcCore.closest(e.target,"input."+t._CNDC),r=wjcCore.closestClass(e.target,t._CND),i=r?new TreeNode(this,r):null;i&&!i.isDisabled&&(this.selectedNode=i),this._dnIndet=n&&n.indeterminate}},t.prototype._click=function(e){if(!e.defaultPrevented){var n=wjcCore.closestClass(e.target,t._CND);if(n){var r=new TreeNode(this,n),i=wjcCore.closest(e.target,"input."+t._CNDC);if(r.isDisabled)return;if(!i&&r.equals(this._edtNode))return;if(n.focus(),i&&(e.preventDefault(),e.stopPropagation(),setTimeout(function(){i.indeterminate=!1,r.isChecked=!r.isChecked})),!i){var o=e.target,s=(e.ctrlKey||e.metaKey)&&!r.hasPendingChildren,a=n.getBoundingClientRect(),l=!1;(this.rightToLeft?a.right-e.clientX:e.clientX-a.left)<=o.offsetHeight?(s?this.collapseToLevel(r.isCollapsed?r.level+1:r.level):r.isCollapsed=!r.isCollapsed,l=!0):this.expandOnClick&&r.isCollapsed&&(s?this.collapseToLevel(r.level):r.isCollapsed=!1,l=!0),l&&s&&this.selectedNode&&this.selectedNode.ensureVisible(),l||this.isReadOnly||this.selectedNode&&this.selectedNode.equals(this._prevSel)&&this.startEditing()}this.selectedItem&&this.onItemClicked()}}},t.prototype._keydown=function(e){if(!e.defaultPrevented){var t=this._selNode,n=void 0,r=e.keyCode,i=!0;if(t&&!t.isDisabled){switch(r){case wjcCore.Key.F2:this.startEditing(),e.preventDefault();break;case wjcCore.Key.Escape:this.finishEditing(!0),e.preventDefault();break;case wjcCore.Key.Up:case wjcCore.Key.Down:this.finishEditing();break;case wjcCore.Key.Enter:this._edtNode?(this.finishEditing(),r=wjcCore.Key.Down):(this.startEditing(),e.preventDefault())}if(this._edtNode)return;if(this.rightToLeft)switch(r){case wjcCore.Key.Left:r=wjcCore.Key.Right;break;case wjcCore.Key.Right:r=wjcCore.Key.Left}switch(r){case wjcCore.Key.Left:!t.isCollapsed&&t.hasChildren?t.setCollapsed(!0):(t=t.parentNode)&&t.select();break;case wjcCore.Key.Right:t.setCollapsed(!1);break;case wjcCore.Key.Up:n=t.previous(!0,!0);break;case wjcCore.Key.Down:n=t.next(!0,!0);break;case wjcCore.Key.Home:n=this.getFirstNode(!0,!0);break;case wjcCore.Key.End:n=this.getLastNode(!0,!0);break;case wjcCore.Key.Space:if(this.selectedItem){var o=t.checkBox;o&&(t.isChecked=!o.checked)}break;case wjcCore.Key.Enter:this.selectedItem&&this.onItemClicked();break;default:i=!1}i&&(e.preventDefault(),n&&n.select())}}},t.prototype._keypress=function(e){var n=this;if(!e.defaultPrevented){if(e.ctrlKey||e.metaKey||e.altKey)return;if(e.target instanceof HTMLInputElement)return;if(this._edtNode)return;if(e.charCode>32&&this.startEditing(this.selectedNode)){var r=wjcCore.getActiveElement();if(wjcCore.contains(this._edtNode.element,r)){r.textContent=String.fromCharCode(e.charCode),e.preventDefault();var i=document.createRange();i.selectNodeContents(r),i.collapse(!1);var o=getSelection();o.removeAllRanges(),o.addRange(i)}return}if(e.charCode>32||32==e.charCode&&this._srch){e.preventDefault(),this._srch+=String.fromCharCode(e.charCode).toLowerCase(),this._toSrch&&clearTimeout(this._toSrch),this._toSrch=setTimeout(function(){n._toSrch=null,n._srch=""},t._AS_DLY);var s=this._findNext();null==s&&this._srch.length>1&&(this._srch=this._srch[this._srch.length-1],s=this._findNext()),null!=s&&(this.selectedItem=s)}}},t.prototype._findNext=function(){if(this.hostElement&&this.selectedItem){var e=this.getNode(this.selectedItem),t=e,n=!1,r=!1;for(1==this._srch.length&&(r=!0);t;){if(!t.isDisabled&&!r&&0==t.element.textContent.trim().toLowerCase().indexOf(this._srch))return t.dataItem;var i=t.next(!0,!0);if(i==e&&n)break;i||n||(i=this.getFirstNode(!0,!0),n=!0),t=i,r=!1}}return null},t.prototype._loadTree=function(e){var n=this._root;if(n){if(!this.onLoadingItems(new wjcCore.CancelEventArgs))return;this._isDirty=!1;var r=this.containsFocus(),i=this.selectedItem;this.selectedItem=null,this._chkItems=null,this._ldLvl=-1;var o=void 0;if(e&&wjcCore.isFunction(window.Map)){o=new Map;for(var s=this.hostElement.querySelectorAll("."+t._CND),a=0;a<s.length;a++){l=s[a];wjcCore.hasClass(l,t._CCLD)&&o.set(l[t._DATAITEM_KEY],!0)}}if(n.innerHTML="",this._items)for(a=0;a<this._items.length;a++)this._addItem(n,0,this._items[a]);if(o)for(var s=this.hostElement.querySelectorAll("."+t._CND),a=0;a<s.length;a++){var l=s[a],d=TreeNode._isNodeList(l),h=o.get(l[t._DATAITEM_KEY]);wjcCore.toggleClass(l,t._CCLD,1==h),wjcCore.setAttribute(l,"aria-expanded",d?(!h).toString():null)}r&&!this.containsFocus()&&this.focus(),this.selectedItem=i,this.onLoadedItems(),this._ldLvl=-1}},t.prototype._addItem=function(e,n,r){var i=this._dspPath.getValue(r,n),o=this._imgPath.getValue(r,n),s=wjcCore.asArray(this._itmPath.getValue(r,n),!0),a=document.createElement("div");wjcCore.addClass(a,t._CND),a.tabIndex=0,wjcCore.setAttribute(a,"role","treeitem",!0);var l=document.createElement("span");if(this.isContentHtml?l.innerHTML=i:l.textContent=i,wjcCore.addClass(l,t._CNDT),a.appendChild(l),o){var d=document.createElement("img");d.src=o,a.insertBefore(d,a.firstChild)}if(this._showChk&&!this._lazyLoad){var h=document.createElement("input");h.type="checkbox",h.tabIndex=-1,wjcCore.addClass(h,t._CNDC),a.insertBefore(h,a.firstChild)}if(this._dd&&a.setAttribute("draggable","true"),e.appendChild(a),a[t._DATAITEM_KEY]=r,s&&0==s.length&&!this.lazyLoadFunction&&(s=null),s){var c=!0;if(n>this._ldLvl?(this._ldLvl=n,0==s.length&&(wjcCore.addClass(a,t._CCLD),c=!1)):(wjcCore.addClass(a,t._CCLD),c=!1,n<this._ldLvl&&(this._ldLvl=1e4)),s.length>0){var u=document.createElement("div");wjcCore.addClass(u,t._CNDL);for(var p=0;p<s.length;p++)this._addItem(u,n+1,s[p]);e.appendChild(u),wjcCore.setAttribute(a,"aria-expanded",c.toString(),!0),wjcCore.setAttribute(u,"role","group",!0)}}else wjcCore.addClass(a,t._CEMP);this.formatItem.hasHandlers&&this.onFormatItem(new FormatNodeEventArgs(r,a,n))},t.prototype._collapseToLevel=function(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];i.hasPendingChildren||(i.isCollapsed=n>=t,i.hasChildren&&this._collapseToLevel(i.nodes,t,n+1))}},t.prototype._lazyLoadNode=function(e){var n=this.hostElement;wjcCore.hasClass(n,t._CLDG)||(wjcCore.addClass(n,t._CLDG),wjcCore.addClass(e.element,t._CLDG),this.lazyLoadFunction(e,this._lazyLoadCallback.bind(e)))},t.prototype._lazyLoadCallback=function(e){var t=this;t.treeView._lazyLoadNodeDone(t,e)},t.prototype._lazyLoadNodeDone=function(e,n){var r=t;wjcCore.removeClass(e.element,r._CLDG),wjcCore.removeClass(this.hostElement,r._CLDG);var i=e.dataItem,o=e.level,s=wjcCore.asArray(n,!0);if(null==s||0==s.length)this._itmPath.setValue(i,o,null),wjcCore.addClass(e.element,r._CEMP);else if(s.length){this._itmPath.setValue(i,o,s);var a=document.createElement("div"),l=e.element;wjcCore.addClass(a,r._CNDL),l.parentElement.insertBefore(a,l.nextSibling);for(var d=0;d<s.length;d++)this._addItem(a,o+1,s[d]);e.isCollapsed=!1}},t._DATAITEM_KEY="wj-Data-Item",t._AS_DLY=600,t._AN_DLY=200,t._CND="wj-node",t._CNDL="wj-nodelist",t._CEMP="wj-state-empty",t._CNDT="wj-node-text",t._CNDC="wj-node-check",t._CSEL="wj-state-selected",t._CCLD="wj-state-collapsed",t._CCLG="wj-state-collapsing",t._CLDG="wj-state-loading",t.controlTemplate='<div wj-part="root"></div>',t}(wjcCore.Control);exports.TreeView=TreeView;var TreeNode=function(){function e(t,n){wjcCore.hasClass(n,"wj-treeview")?(t=wjcCore.Control.getControl(n),n=null):e._assertNode(n),this._t=t,this._e=n}return Object.defineProperty(e.prototype,"dataItem",{get:function(){return this._e[TreeView._DATAITEM_KEY]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"element",{get:function(){return this._e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"treeView",{get:function(){return this._t},enumerable:!0,configurable:!0}),e.prototype.ensureVisible=function(){for(var e=this.parentNode;e;e=e.parentNode)e.isCollapsed=!1;var t=this._t.hostElement,n=this.element.getBoundingClientRect(),r=t.getBoundingClientRect();n.bottom>r.bottom?t.scrollTop+=n.bottom-r.bottom:n.top<r.top&&(t.scrollTop-=r.top-n.top)},e.prototype.equals=function(e){return null!=e&&e.element==this.element},e.prototype.select=function(){var e=this._t,t=e._selNode;this.equals(t)||(t&&wjcCore.removeClass(t.element,TreeView._CSEL),e._selNode=this,wjcCore.addClass(this.element,TreeView._CSEL),this.ensureVisible(),e.containsFocus()&&this.element.focus(),e.onSelectedItemChanged())},Object.defineProperty(e.prototype,"index",{get:function(){for(var t=0,n=this._pse(this.element);n;n=this._pse(n))e._isNode(n)&&t++;return t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parentNode",{get:function(){var t=null;if(this._e){var n=this._e.parentElement;e._assertNodeList(n),t=this._pse(n)}return t?new e(this._t,t):null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"level",{get:function(){for(var e=-1,t=this;t;t=t.parentNode)e++;return e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasChildren",{get:function(){return e._isNode(this._e)&&!e._isEmpty(this._e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasPendingChildren",{get:function(){return this.isCollapsed&&this.hasChildren&&!e._isNodeList(this.element.nextElementSibling)&&wjcCore.isFunction(this._t.lazyLoadFunction)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"nodes",{get:function(){return this.hasChildren?e._getChildNodes(this._t,this._e.nextSibling):null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"checkBox",{get:function(){return this._e.querySelector("input."+TreeView._CNDC)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isCollapsed",{get:function(){return this.hasChildren&&wjcCore.hasClass(this._e,TreeView._CCLD)},set:function(e){if(e!=this.isCollapsed){var t=this._t,n=new TreeNodeEventArgs(this);t.onIsCollapsedChanging(n)&&(this.setCollapsed(wjcCore.asBoolean(e),t.isAnimated,t.autoCollapse),t.onIsCollapsedChanged(n))}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isChecked",{get:function(){var e=this.checkBox;return e&&!e.indeterminate?e.checked:null},set:function(e){if(e!=this.isChecked){var t=this._t,n=new TreeNodeEventArgs(this);t.onIsCheckedChanging(n)&&(this.setChecked(wjcCore.asBoolean(e),!0),t.onIsCheckedChanged(n))}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDisabled",{get:function(){return this._e&&null!=this._e.getAttribute("disabled")},set:function(e){(e=wjcCore.asBoolean(e,!0))!=this.isDisabled&&wjcCore.enable(this._e,!e)},enumerable:!0,configurable:!0}),e.prototype.previous=function(t,n){var r=this._pse(this._e);if(!r&&e._isNodeList(this._e.parentElement)&&(r=this._pse(this._e.parentElement)),e._isNodeList(r)){for(;e._isNodeList(r)&&r.childElementCount;)r=r.lastChild;e._isNodeList(r)&&(r=this._pse(r))}var i=e._isNode(r)?new e(this._t,r):null;return t&&i&&!i.element.offsetHeight&&(i=i.previous(t,n)),n&&i&&i.isDisabled&&(i=i.previous(t,n)),i},e.prototype.next=function(t,n){var r=this._e.nextSibling;if(e._isNodeList(r)&&(r=r.childElementCount?r.firstChild:r.nextSibling),!r)for(var i=this._e.parentElement;!r&&e._isNodeList(i);i=i.parentElement)r=i.nextSibling;var o=e._isNode(r)?new e(this._t,r):null;return t&&o&&!o.element.offsetHeight&&(o=o.next(t,n)),n&&o&&o.isDisabled&&(o=o.next(t,n)),o},e.prototype.previousSibling=function(){for(var t=this._pse(this.element);e._isNodeList(t);)t=this._pse(t);return t?new e(this._t,t):null},e.prototype.nextSibling=function(){var t=this.element.nextSibling;return e._isNodeList(t)&&(t=t.nextSibling),t?new e(this._t,t):null},e.prototype.setCollapsed=function(t,n,r){var i=this._t,o=this._e,s=this._e.nextElementSibling,a=e._isNodeList(s);if(wjcCore.setAttribute(o,"aria-expanded",a?(!t).toString():null),t!=this.isCollapsed)if(t||a||!wjcCore.isFunction(i.lazyLoadFunction)){if(null==n&&(n=i.isAnimated),null==r&&(r=i.autoCollapse),n){if(a){var l=s.offsetHeight,d=s.style;t?(wjcCore.toggleClass(o,TreeView._CCLG,!0),wjcCore.animate(function(e){e<1?(e=1-e,d.height=(e*l).toFixed(0)+"px"):(d.height=d.opacity="",wjcCore.toggleClass(o,TreeView._CCLD,!0),wjcCore.toggleClass(o,TreeView._CCLG,!1))},TreeView._AN_DLY)):(wjcCore.toggleClass(o,TreeView._CCLD,!1),d.height=d.opacity="0",wjcCore.animate(function(e){d.height=e>=1?d.opacity="":(e*l).toFixed(0)+"px"},TreeView._AN_DLY))}}else wjcCore.toggleClass(o,TreeView._CCLD,t);if(!t&&r){var h=o.parentElement;if(e._isNodeList(h))for(var c=0;c<h.children.length;c++){var u=h.children[c];u!=o&&e._isNode(u)&&(wjcCore.toggleClass(u,TreeView._CCLD,!0),u.setAttribute("aria-expanded","false"))}}}else i._lazyLoadNode(this)},e.prototype.setChecked=function(e,t){var n=this.checkBox,r=n.checked!=e;if(n.checked=e,n.indeterminate=!1,this.hasChildren)for(var i=this.nodes,o=0;o<i.length;o++)i[o].setChecked(e,!1);if(t){var s=this.parentNode;s&&s._updateCheckedState()}this._t&&r&&this._t._raiseCheckedItemsChanged()},e.prototype.remove=function(){var t=this._t,n=this.parentNode,r=this._getArray(),i=r.indexOf(this.dataItem);t.selectedNode==this&&(t.selectedNode=this.nextSibling()||this.previousSibling()||n);var o=this.element.nextSibling;e._isNodeList(o)&&wjcCore.removeChild(o),wjcCore.removeChild(this.element),n&&n._updateState(),r.splice(i,1),this._t=null},e.prototype.addChildNode=function(e,t){var n=this._t._createNode(t),r=this.nodes;return r?e<r.length?n.move(r[e],DropPosition.Before):n.move(r[r.length-1],DropPosition.After):n.move(this,DropPosition.Into),n},e.prototype.refresh=function(e){var t=this._getArray();e&&(t[this.index]=e),e=t[this.index];var n=this._t._createNode(e),r=this.hasChildren&&!this.hasPendingChildren?this.element.nextSibling:null;r&&wjcCore.removeChild(r),(r=n.hasChildren&&!n.hasPendingChildren?n.element.nextSibling:null)&&this.element.parentElement.insertBefore(r,this.element.nextSibling),this.element.innerHTML=n.element.innerHTML,this._updateState()},e.prototype.move=function(t,n){if(t instanceof e&&this._contains(t))return!1;var r=this.parentNode,i=this._getArray();this._moveElements(t,n);var o=this.parentNode,s=this._getArray();r&&r._updateState(),o&&o._updateState();var a=this.dataItem,l=i.indexOf(a);return i.splice(l,1),s.splice(this.index,0,a),t.treeView&&(this._t=t.treeView),!0},Object.defineProperty(e.prototype,"itemsSource",{get:function(){return this._getArray()},enumerable:!0,configurable:!0}),e.prototype._pse=function(e){return e.previousElementSibling},e.prototype._contains=function(e){for(;e;e=e.parentNode)if(e.element==this.element)return!0;return!1},e.prototype._getArray=function(){var e=this._t,t=this.parentNode,n=e.itemsSource;if(t){var r=e._itmPath;(n=r.getValue(t.dataItem,this.level))||(n=[],r.setValue(t.dataItem,this.level,n))}return n},e.prototype._moveElements=function(t,n){var r=document.createDocumentFragment(),i=this.hasChildren&&!this.hasPendingChildren?this.element.nextSibling:null;if(r.appendChild(this.element),i&&(e._assertNodeList(i),r.appendChild(i)),t instanceof TreeView)t._root.insertBefore(r,null);else{var o=t.element,s=o?o.parentElement:t.treeView._root;e._assertNodeList(s);var a=DropPosition;switch(n){case a.Before:s.insertBefore(r,o);break;case a.After:o=(t=t.nextSibling())?t.element:null,s.insertBefore(r,o);break;case a.Into:t.hasChildren&&!t.hasPendingChildren||(i=document.createElement("div"),wjcCore.addClass(i,TreeView._CNDL),s.insertBefore(i,o.nextSibling)),s=t.element.nextSibling,e._assertNodeList(s),s.insertBefore(r,null)}}},e.prototype._updateState=function(){this._updateEmptyState(),this._updateCheckedState()},e.prototype._updateEmptyState=function(){var t=this.element.nextSibling,n=!1;e._isNodeList(t)&&(t.childElementCount?n=!0:wjcCore.removeChild(t)),wjcCore.toggleClass(this.element,TreeView._CEMP,!n),n||this.element.removeAttribute("aria-expanded")},e.prototype._updateCheckedState=function(){var e=this.checkBox,t=this.nodes,n=0,r=0;if(e&&t){for(var i=0;i<t.length;i++)switch(t[i].isChecked){case!0:n++;break;case!1:r++}n==t.length?(e.checked=!0,e.indeterminate=!1):r==t.length?(e.checked=!1,e.indeterminate=!1):(e.checked=!1,e.indeterminate=!0)}var o=this.parentNode;o&&o._updateCheckedState()},e._getChildNodes=function(t,n){e._assertNodeList(n);var r=[];if(e._isNodeList(n))for(var i=n.children,o=0;o<i.length;o++){var s=i[o];e._isNode(s)&&r.push(new e(t,s))}return r},e._isNode=function(e){return e&&wjcCore.hasClass(e,TreeView._CND)},e._isNodeList=function(e){return e&&wjcCore.hasClass(e,TreeView._CNDL)},e._isEmpty=function(t){return e._isNode(t)&&wjcCore.hasClass(t,TreeView._CEMP)},e._isCollapsed=function(t){return e._isNode(t)&&!e._isEmpty(t)&&wjcCore.hasClass(t,TreeView._CCLD)},e._assertNode=function(t){wjcCore.assert(e._isNode(t),"node expected")},e._assertNodeList=function(t){wjcCore.assert(e._isNodeList(t),"nodeList expected")},e}();exports.TreeNode=TreeNode;var FormatNodeEventArgs=function(e){function t(t,n,r){var i=e.call(this)||this;return i._data=t,i._e=wjcCore.asType(n,HTMLElement),i._level=r,i}return __extends(t,e),Object.defineProperty(t.prototype,"dataItem",{get:function(){return this._data},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"element",{get:function(){return this._e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._level},enumerable:!0,configurable:!0}),t}(wjcCore.EventArgs);exports.FormatNodeEventArgs=FormatNodeEventArgs;var TreeNodeEventArgs=function(e){function t(t){var n=e.call(this)||this;return n._node=t,n}return __extends(t,e),Object.defineProperty(t.prototype,"node",{get:function(){return this._node},enumerable:!0,configurable:!0}),t}(wjcCore.CancelEventArgs);exports.TreeNodeEventArgs=TreeNodeEventArgs;var TreeNodeDragDropEventArgs=function(e){function t(t,n,r){var i=e.call(this)||this;return i._src=wjcCore.asType(t,TreeNode),i._tgt=wjcCore.asType(n,TreeNode),i._pos=r,i}return __extends(t,e),Object.defineProperty(t.prototype,"dragSource",{get:function(){return this._src},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dropTarget",{get:function(){return this._tgt},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._pos},set:function(e){this._pos=wjcCore.asEnum(e,DropPosition)},enumerable:!0,configurable:!0}),t}(wjcCore.CancelEventArgs);exports.TreeNodeDragDropEventArgs=TreeNodeDragDropEventArgs;var DropPosition;!function(e){e[e.Before=0]="Before",e[e.After=1]="After",e[e.Into=2]="Into"}(DropPosition=exports.DropPosition||(exports.DropPosition={}));var _TreeDragDropManager=function(){function e(e){this._tree=wjcCore.asType(e,TreeView),this._dragstartBnd=this._dragstart.bind(this),this._dragoverBnd=this._dragover.bind(this),this._dropBnd=this._drop.bind(this),this._dragendBnd=this._dragend.bind(this);var t=this._tree,n=t.hostElement;t.addEventListener(n,"dragstart",this._dragstartBnd),t.addEventListener(n,"dragover",this._dragoverBnd),t.addEventListener(n,"dragleave",this._dragoverBnd),t.addEventListener(n,"drop",this._dropBnd),t.addEventListener(n,"dragend",this._dragendBnd),t.addEventListener(n,"keydown",this._keydown)}return e.prototype.dispose=function(){var e=this._tree,t=e.hostElement;e.removeEventListener(t,"dragstart",this._dragstartBnd),e.removeEventListener(t,"dragover",this._dragoverBnd),e.removeEventListener(t,"dragleave",this._dragoverBnd),e.removeEventListener(t,"drop",this._dropBnd),e.removeEventListener(t,"dragend",this._dragendBnd),e.removeEventListener(t,"keydown",this._keydown),this._showDragMarker()},e.prototype._dragstart=function(t){if(!t.defaultPrevented){var n=this._tree,r=wjcCore.closestClass(t.target,TreeView._CND),i=e;if(i._drgSrc=TreeNode._isNode(r)?new TreeNode(n,r):null,i._drgSrc){var o=new TreeNodeEventArgs(i._drgSrc);n.onDragStart(o)||(i._drgSrc=null)}i._drgSrc&&t.dataTransfer?(wjcCore._startDrag(t.dataTransfer,"copyMove"),t.stopPropagation()):t.preventDefault()}},e.prototype._dragover=function(e){this._handleDragDrop(e,!1)},e.prototype._drop=function(e){this._handleDragDrop(e,!0)},e.prototype._dragend=function(t){e._drgSrc=null,this._showDragMarker(),this._tree.onDragEnd()},e.prototype._keydown=function(e){e.defaultPrevented||e.keyCode==wjcCore.Key.Escape&&this._dragendBnd(null)},e.prototype._handleDragDrop=function(t,n){var r,i,o=this._tree,s=e,a=DropPosition,l=a.Into;if(!t.defaultPrevented&&s._drgSrc){var d=document.elementFromPoint(t.clientX,t.clientY),h=wjcCore.closestClass(d,TreeView._CND);if(null==h){var c=wjcCore.Control.getControl(wjcCore.closest(d,".wj-treeview"));c instanceof TreeView&&0==c.totalItemCount&&(h=c.hostElement)}if(h==s._drgSrc.element&&(h=null),h){i=h.getBoundingClientRect();var u=new TreeNode(o,h),p=u.hasPendingChildren?i.height/2:i.height/3;null==u.element?((i=wjcCore.Rect.fromBoundingRect(i)).inflate(-12,-12),l=a.Before):t.clientY<i.top+p?l=a.Before:(t.clientY>i.bottom-p||u.hasPendingChildren)&&(l=a.After,!u.hasChildren||u.isCollapsed||u.hasPendingChildren||(l=a.Before,i=(h=(u=u.next(!0,!1)).element).getBoundingClientRect())),s._drgSrc._contains(u)?h=null:((r=new TreeNodeDragDropEventArgs(s._drgSrc,u,l)).cancel=s._drgSrc.treeView!=u.treeView,o.onDragOver(r)||(h=null))}if(h)if((l=r.position)==a.Before){var _=r.dragSource.next(!0,!1);_&&_.element==h&&(h=null)}else if(l==a.After){var C=r.dragSource.previous(!0,!1);C&&C.element==h&&(h=null)}if(h&&!n?(t.dataTransfer.dropEffect="move",t.preventDefault(),t.stopPropagation(),this._showDragMarker(i,l)):this._showDragMarker(),h&&n&&o.onDrop(r)){o.hostElement.focus();var f=r.dragSource;f.move(r.dropTarget,r.position),f.select()}}},e.prototype._showDragMarker=function(t,n){var r=this._tree,i=e._dMarker.parentElement;if(t){var o=r.hostElement.getBoundingClientRect(),s=n==DropPosition.After?t.bottom:t.top,a={top:Math.round(s-o.top+r.hostElement.scrollTop-2),width:"75%",height:n==DropPosition.Into?t.height:4,opacity:n==DropPosition.Into?"0.15":""};r.rightToLeft?a.right=Math.round(o.right-t.right):a.left=Math.round(t.left-o.left),wjcCore.setCss(e._dMarker,a),i!=r._root&&r._root.appendChild(e._dMarker)}else i&&i.removeChild(e._dMarker)},e._dMarker=wjcCore.createElement('<div class="wj-marker">&nbsp;</div>'),e}();exports._TreeDragDropManager=_TreeDragDropManager;var _BindingArray=function(){function e(e){this.path=e}return Object.defineProperty(e.prototype,"path",{get:function(){return this._path},set:function(e){if(this._path=e,wjcCore.isString(e))this._bindings=[new wjcCore.Binding(e)];else if(wjcCore.isArray(e)){this._bindings=[];for(var t=0;t<e.length;t++)this._bindings.push(new wjcCore.Binding(e[t]))}else null!=e&&wjcCore.assert(!1,"Path should be a string or an array of strings.");this._maxLevel=this._bindings?this._bindings.length-1:-1},enumerable:!0,configurable:!0}),e.prototype.getValue=function(e,t){var n=Math.min(t,this._maxLevel);return n>-1?this._bindings[n].getValue(e):null},e.prototype.setValue=function(e,t,n){var r=Math.min(t,this._maxLevel);r>-1&&this._bindings[r].setValue(e,n)},e}();exports._BindingArray=_BindingArray;var TabPanel=function(e){function t(t,n,r){var i=e.call(this,t,null,!0)||this;i._tabs=new wjcCore.ObservableArray,i._selectedIndex=-1,i._animated=!0,i._autoSwitch=!0,i.selectedIndexChanged=new wjcCore.Event;var o=i.hostElement,s=[];if(!r)for(;o.firstElementChild;){var a=o.firstElementChild;o.removeChild(a),s.push(a)}var l=i.getTemplate();return i.applyTemplate("wj-control wj-tabpanel",l,{_dRoot:"root",_dTabHeaders:"tabheaders",_dTabPanes:"tabpanes"}),i._tabIndex=o.tabIndex,o.tabIndex=-1,i._dRoot.tabIndex=i._dTabHeaders.tabIndex=i._dTabPanes.tabIndex=-1,i.addEventListener(o,"click",i._click.bind(i)),i.addEventListener(o,"keydown",i._keydown.bind(i)),i._tabs.collectionChanged.addHandler(i._populateControl.bind(i)),i.tabs.deferUpdate(function(){s.forEach(function(e){wjcCore.assert(2==e.childElementCount,"TabPanel children should contain header and pane elements"),i.tabs.push(new Tab(e.children[0],e.children[1]))})}),i.initialize(n),i.selectedIndex<0&&i.tabs.length?i.selectedIndex=0:i.onSelectedIndexChanged(),i}return __extends(t,e),Object.defineProperty(t.prototype,"tabs",{get:function(){return this._tabs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedIndex",{get:function(){return this._selectedIndex},set:function(e){(e=wjcCore.asInt(e,!1))!=this._selectedIndex?(this._selectedIndex=e,this._updateContent(),this.onSelectedIndexChanged()):this._updateContent()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedTab",{get:function(){var e=this._selectedIndex;return e>-1?this._tabs[e]:null},set:function(e){for(var t=-1,n=0;n<this._tabs.length&&t<0;n++)this._tabs[n]==e&&(t=n);this.selectedIndex=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAnimated",{get:function(){return this._animated},set:function(e){this._animated=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoSwitch",{get:function(){return this._autoSwitch},set:function(e){e!=this._autoSwitch&&(this._autoSwitch=wjcCore.asBoolean(e),this._updateContent())},enumerable:!0,configurable:!0}),t.prototype.getTab=function(e){for(t=0;t<this._tabs.length;t++)if((n=this._tabs[t]).header.id==e||n.pane.id==e)return n;for(var t=0;t<this._tabs.length;t++){var n=this._tabs[t];if(n.header.textContent==e)return n}return null},t.prototype.onSelectedIndexChanged=function(e){this.selectedIndexChanged.raise(this,e)},t.prototype._populateControl=function(){var e=this;this._removeChildren(this._dTabHeaders),this._removeChildren(this._dTabPanes);var t=-1;this._tabs.forEach(function(n,r){wjcCore.assert(n instanceof Tab,"tabs array must contain Tab objects."),n._setPanel(e);var i=n.header,o=n.pane;wjcCore.addClass(i,"wj-tabheader"),wjcCore.setAttribute(i,"role","tab"),wjcCore.setAttribute(i,"aria-controls",o.id?o.id:null),e._dTabHeaders.appendChild(i),wjcCore.addClass(o,"wj-tabpane"),wjcCore.setAttribute(o,"role","tabpanel"),wjcCore.setAttribute(o,"aria-labelledby",i.id?i.id:null),e._dTabPanes.appendChild(o),t<0&&(wjcCore.hasClass(i,"wj-state-active")||"true"==i.getAttribute("aria-selected"))&&(t=r)}),t<0&&this._tabs.length>0&&(t=0),t>-1?this.selectedIndex=t:this.selectedIndex>-1&&this.selectedIndex<this._tabs.length&&this._updateContent(),this._validateSelection()},t.prototype._validateSelection=function(){var e=this.selectedTab;if(e&&(e.isDisabled||!e.isVisible)){var t=this._getNextIndex(this.selectedIndex,1);t<0&&(t=this._getNextIndex(this.selectedIndex,-1)),this.selectedIndex=t}},t.prototype._updateContent=function(){var e=this,t=wjcCore.contains(this._dTabHeaders,wjcCore.getActiveElement()),n=this._dTabHeaders.children,r=this._dTabPanes.children,i=this._selectedIndex;if(i>-1&&i<r.length){var o=(d=r[i]).style;this.isAnimated?(o.opacity="0",this._toAnim&&clearInterval(this._toAnim),this._toAnim=wjcCore.animate(function(t){1==t?(o.opacity="",e._toAnim=null):o.opacity=t.toString()})):o.opacity=""}for(var s=0;s<n.length;s++){var a=s==i,l=n[s],d=r[s];wjcCore.setAttribute(l,"aria-selected",a),wjcCore.toggleClass(l,"wj-state-active",a),wjcCore.toggleClass(d,"wj-state-active",a),l.tabIndex=a||!this._autoSwitch?this._tabIndex:-1,a&&(t&&l.focus(),wjcCore.Control.invalidateAll(d))}},t.prototype._removeChildren=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},t.prototype._click=function(e){var t=this._getTabIndex(e.target);t>-1&&(this.selectedIndex=t)},t.prototype._keydown=function(e){if(!e.defaultPrevented){var t=this._getTabIndex(wjcCore.getActiveElement());if(t>-1){var n=e.keyCode;if(this.rightToLeft)switch(n){case wjcCore.Key.Left:n=wjcCore.Key.Right;break;case wjcCore.Key.Right:n=wjcCore.Key.Left}switch(n){case wjcCore.Key.Left:case wjcCore.Key.Up:case wjcCore.Key.Right:case wjcCore.Key.Down:case wjcCore.Key.Home:case wjcCore.Key.PageUp:case wjcCore.Key.End:case wjcCore.Key.PageDown:switch(n){case wjcCore.Key.Left:case wjcCore.Key.Up:t=this._getNextIndex(t,-1);break;case wjcCore.Key.Right:case wjcCore.Key.Down:t=this._getNextIndex(t,1);break;case wjcCore.Key.Home:case wjcCore.Key.PageUp:t=this._getNextIndex(-1,1);break;case wjcCore.Key.End:case wjcCore.Key.PageDown:t=this._getNextIndex(this._tabs.length,-1)}t>-1&&(this._autoSwitch?this.selectedIndex=t:this._tabs[t].header.focus()),e.preventDefault();break;case wjcCore.Key.Enter:case wjcCore.Key.Space:t>-1&&this._tabs[t].header.click(),e.preventDefault()}}}},t.prototype._getTabIndex=function(e){var t=wjcCore.closest(e,".wj-tabheader");if(t&&wjcCore.closest(t,".wj-tabpanel")==this.hostElement)for(var n=0;n<this._tabs.length;n++)if(this._tabs[n].header==t)return n;return-1},t.prototype._getNextIndex=function(e,t){for(var n=e+t;n>-1&&n<this._tabs.length;n+=t){var r=this._tabs[n];if(!r.isDisabled&&r.isVisible)return n}return-1},t.controlTemplate='<div wj-part="root"><div wj-part="tabheaders" class="wj-tabheaders" role="tablist"></div><div wj-part="tabpanes" class="wj-tabpanes"></div></div>',t}(wjcCore.Control);exports.TabPanel=TabPanel;var Tab=function(){function e(e,t){this._hdr=wjcCore.asType(wjcCore.getElement(e),HTMLElement),this._pane=wjcCore.asType(wjcCore.getElement(t),HTMLElement)}return Object.defineProperty(e.prototype,"tabPanel",{get:function(){return this._p},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"header",{get:function(){return this._hdr},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pane",{get:function(){return this._pane},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDisabled",{get:function(){return wjcCore.hasClass(this._hdr,"wj-state-disabled")},set:function(e){wjcCore.toggleClass(this._hdr,"wj-state-disabled",wjcCore.asBoolean(e)),this._p&&this._p._validateSelection()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return"none"!=this._hdr.style.display},set:function(e){this._hdr.style.display=wjcCore.asBoolean(e)?"":"none",this._p&&this._p._validateSelection()},enumerable:!0,configurable:!0}),e.prototype._setParts=function(e,t){if(e=wjcCore.asType(wjcCore.getElement(e),HTMLElement),t=wjcCore.asType(wjcCore.getElement(t),HTMLElement,!1),this._hdr!==e||this._pane!==t){var n=this.isDisabled,r=this.isVisible;this._hdr=e,this._pane=t,this.isDisabled=n,this.isVisible=r;var i=this.tabPanel;i&&!i.tabs.isUpdating&&i._populateControl()}},e.prototype._setPanel=function(e){this._p=e},e}();exports.Tab=Tab;