/*
    *
    * Wijmo Library 5.20173.409
    * 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/
    *
    */
System.register(["wijmo/wijmo","wijmo/wijmo.grid"],function(e,t){"use strict";function i(){var e;return(e=window.wijmo)&&e.input}var o,n,r,s,l,a,h,c,u,d,g,p,f,_,w,m,y,v,C,b,R,E,S,z,x,H,P,M,T,D,L,O,j,I,A,N,k,B,V,F,K=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();t&&t.id;return{setters:[function(e){o=e},function(e){n=e}],execute:function(){window.wijmo=window.wijmo||{},window.wijmo.grid=n,o.culture.FlexGrid=window.wijmo.culture.FlexGrid||{groupHeaderFormat:"{name}: <b>{value}</b> ({count:n0} items)"},function(e){e[e.None=0]="None",e[e.Column=1]="Column",e[e.Row=2]="Row",e[e.All=3]="All"}(r||(r={})),e("HeadersVisibility",r),s=function(e){function t(t,i){var n=e.call(this,t,null,!0)||this;n._szClient=new o.Size(0,0),n._ptScrl=new o.Point(0,0),n._cellPadding=3,n._clipToScreen=!1,n._autoGenCols=!0,n._autoClipboard=!0,n._readOnly=!1,n._indent=14,n._autoSizeMode=j.Both,n._hdrVis=r.All,n._alSorting=!0,n._alAddNew=!1,n._alDelete=!1,n._alResizing=O.Columns,n._alDragging=I.Columns,n._alMerging=R.None,n._ssHdr=r.None,n._shSort=!0,n._shGroups=!0,n._shAlt=!0,n._shErr=!0,n._shDropDown=!0,n._valEdt=!0,n._deferResizing=!1,n._pSel=!0,n._pOutline=!0,n._vt=0,n.itemsSourceChanging=new o.Event,n.itemsSourceChanged=new o.Event,n.scrollPositionChanged=new o.Event,n.selectionChanging=new o.Event,n.selectionChanged=new o.Event,n.loadingRows=new o.Event,n.loadedRows=new o.Event,n.updatingLayout=new o.Event,n.updatedLayout=new o.Event,n.resizingColumn=new o.Event,n.resizedColumn=new o.Event,n.autoSizingColumn=new o.Event,n.autoSizedColumn=new o.Event,n.draggingColumn=new o.Event,n.draggingColumnOver=new o.Event,n.draggedColumn=new o.Event,n.resizingRow=new o.Event,n.resizedRow=new o.Event,n.autoSizingRow=new o.Event,n.autoSizedRow=new o.Event,n.draggingRow=new o.Event,n.draggingRowOver=new o.Event,n.draggedRow=new o.Event,n.groupCollapsedChanging=new o.Event,n.groupCollapsedChanged=new o.Event,n.sortingColumn=new o.Event,n.sortedColumn=new o.Event,n.beginningEdit=new o.Event,n.prepareCellForEdit=new o.Event,n.cellEditEnding=new o.Event,n.cellEditEnded=new o.Event,n.rowEditStarting=new o.Event,n.rowEditStarted=new o.Event,n.rowEditEnding=new o.Event,n.rowEditEnded=new o.Event,n.rowAdded=new o.Event,n.deletingRow=new o.Event,n.deletedRow=new o.Event,n.copying=new o.Event,n.copied=new o.Event,n.pasting=new o.Event,n.pasted=new o.Event,n.pastingCell=new o.Event,n.pastedCell=new o.Event,n.formatItem=new o.Event,n.updatingView=new o.Event,n.updatedView=new o.Event,n._mappedColumns=null;var s=n.hostElement;o.isIE()&&(s.style.borderRadius="0px");var l=n.getTemplate();n.applyTemplate("wj-control wj-flexgrid wj-content",l,{_root:"root",_eSz:"sz",_eCt:"cells",_fCt:"fcells",_eTL:"tl",_eBL:"bl",_eCHdr:"ch",_eRHdr:"rh",_eCFtr:"cf",_eTLCt:"tlcells",_eBLCt:"blcells",_eCHdrCt:"chcells",_eCFtrCt:"cfcells",_eRHdrCt:"rhcells",_eMarquee:"marquee",_eFocus:"focus"}),n._tabIndex=s.tabIndex,s.tabIndex=-1;var a=n._getDefaultRowHeight();return n.deferUpdate(function(){n._rows=new C(n,a),n._cols=new v(n,4*a),n._hdrRows=new C(n,a),n._hdrCols=new v(n,Math.round(1.25*a)),n._ftrRows=new C(n,a),n._gpTL=new u(n,c.TopLeft,n._hdrRows,n._hdrCols,n._eTLCt),n._gpCHdr=new u(n,c.ColumnHeader,n._hdrRows,n._cols,n._eCHdrCt),n._gpRHdr=new u(n,c.RowHeader,n._rows,n._hdrCols,n._eRHdrCt),n._gpCells=new u(n,c.Cell,n._rows,n._cols,n._eCt),n._gpBL=new u(n,c.BottomLeft,n._ftrRows,n._hdrCols,n._eBLCt),n._gpCFtr=new u(n,c.ColumnFooter,n._ftrRows,n._cols,n._eCFtrCt),n._hdrRows.push(new w),n._hdrCols.push(new _),n._hdrCols[0].align="center",n._cf=new d,n._keyHdl=new T(n),n._mouseHdl=new A(n),n._edtHdl=new k(n),n._selHdl=new P(n),n._addHdl=new B(n),n._mrgMgr=new E(n),n._bndSortConverter=n._sortConverter.bind(n),n._bndScroll=n._scroll.bind(n),o.setAttribute(n.cells.hostElement,"role","grid",!0),n.selectionMode=z.CellRange,n.initialize(i)}),n.addEventListener(n._root,"scroll",function(e){n._updateScrollPosition()&&(n.finishEditing(),n._updateContent(!0))}),n.addEventListener(s,"focus",function(e){if(s.tabIndex>-1){var t=e.target;if(t instanceof HTMLElement&&t.tabIndex<0)return void n._setFocus(!0)}},!0),n}return K(t,e),t.prototype._handleResize=function(){this._rcBounds=null,e.prototype._handleResize.call(this)},Object.defineProperty(t.prototype,"headersVisibility",{get:function(){return this._hdrVis},set:function(e){e!=this._hdrVis&&(this._hdrVis=o.asEnum(e,r),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stickyHeaders",{get:function(){return this._stickyHdr},set:function(e){e!=this._stickyHdr&&(this._stickyHdr=o.asBoolean(e),this._updateStickyHeaders(),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"preserveSelectedState",{get:function(){return this._pSel},set:function(e){this._pSel=o.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"preserveOutlineState",{get:function(){return this._pOutline},set:function(e){this._pOutline=o.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"virtualizationThreshold",{get:function(){return this._vt},set:function(e){this._vt=o.asNumber(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoGenerateColumns",{get:function(){return this._autoGenCols},set:function(e){this._autoGenCols=o.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoClipboard",{get:function(){return this._autoClipboard},set:function(e){this._autoClipboard=o.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"columnLayout",{get:function(){for(var e=t._getSerializableProperties(_),i=new _,n=[],r=0;r<this.columns.length;r++){for(var s=this.columns[r],l={},a=0;a<e.length;a++){var h=e[a],c=s[h];c!=i[h]&&o.isPrimitive(c)&&"size"!=h&&(l[h]=c)}n.push(l)}return JSON.stringify({columns:n})},set:function(e){var t=JSON.parse(o.asString(e));if(!t||null==t.columns)throw"Invalid columnLayout data.";this.columns.clear(),this.initialize(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isReadOnly",{get:function(){return this._readOnly},set:function(e){e!=this._readOnly&&(this._readOnly=o.asBoolean(e),this.finishEditing(),this.invalidate(!0),this._addHdl.updateNewRowTemplate(),o.toggleClass(this.hostElement,"wj-state-readonly",this.isReadOnly),this._setAria("readonly",this.isReadOnly?"true":null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imeEnabled",{get:function(){return null!=this._imeHdl},set:function(e){e!=this.imeEnabled&&(this._imeHdl&&(this._imeHdl.dispose(),this._imeHdl=null),e&&(this._imeHdl=new F(this)))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowResizing",{get:function(){return this._alResizing},set:function(e){this._alResizing=o.asEnum(e,O)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"deferResizing",{get:function(){return this._deferResizing},set:function(e){this._deferResizing=o.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoSizeMode",{get:function(){return this._autoSizeMode},set:function(e){this._autoSizeMode=o.asEnum(e,j)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"quickAutoSize",{get:function(){return this._quickSize},set:function(e){this._quickSize=o.asBoolean(e,!0)},enumerable:!0,configurable:!0}),t.prototype._getQuickAutoSize=function(){return o.isBoolean(this._quickSize)?this._quickSize:!this.formatItem.hasHandlers&&null==this.itemFormatter},Object.defineProperty(t.prototype,"allowSorting",{get:function(){return this._alSorting},set:function(e){this._alSorting=o.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowAddNew",{get:function(){return this._alAddNew},set:function(e){e!=this._alAddNew&&(this._alAddNew=o.asBoolean(e),this._addHdl.updateNewRowTemplate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"newRowAtTop",{get:function(){return this._addHdl.newRowAtTop},set:function(e){this._addHdl.newRowAtTop=o.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowDelete",{get:function(){return this._alDelete},set:function(e){e!=this._alDelete&&(this._alDelete=o.asBoolean(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowMerging",{get:function(){return this._alMerging},set:function(e){e!=this._alMerging&&(this._alMerging=o.asEnum(e,R),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showSelectedHeaders",{get:function(){return this._ssHdr},set:function(e){e!=this._ssHdr&&(this._ssHdr=o.asEnum(e,r),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showMarquee",{get:function(){return!this._eMarquee.style.display},set:function(e){if(e!=this.showMarquee){var t=this._eMarquee.style;t.visibility="collapse",t.display=o.asBoolean(e)?"":"none",this.invalidate()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showSort",{get:function(){return this._shSort},set:function(e){e!=this._shSort&&(this._shSort=o.asBoolean(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showGroups",{get:function(){return this._shGroups},set:function(e){e!=this._shGroups&&(this._shGroups=o.asBoolean(e),this._bindGrid(!1))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showAlternatingRows",{get:function(){return this._shAlt},set:function(e){e!=this._shAlt&&(this._shAlt=o.asBoolean(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showErrors",{get:function(){return this._shErr},set:function(e){e!=this._shErr&&(this._clearCells(),this._shErr=o.asBoolean(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"itemValidator",{get:function(){return this._itemValidator},set:function(e){e!=this.itemValidator&&(this._itemValidator=o.asFunction(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"validateEdits",{get:function(){return this._valEdt},set:function(e){this._valEdt=o.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"groupHeaderFormat",{get:function(){return this._gHdrFmt},set:function(e){e!=this._gHdrFmt&&(this._gHdrFmt=o.asString(e),this._bindGrid(!1))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowDragging",{get:function(){return this._alDragging},set:function(e){e!=this._alDragging&&(this._alDragging=o.asEnum(e,I),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"itemsSource",{get:function(){return this._items},set:function(e){if(e!=this._items){var t=new o.CancelEventArgs;if(this.onItemsSourceChanging(t)){if(this._cv&&((i=o.tryCast(this._cv,o.CollectionView))&&i.sortConverter==this._bndSortConverter&&(i.sortConverter=null),this._cv.currentChanged.removeHandler(this._cvCurrentChanged,this),this._cv.collectionChanged.removeHandler(this._cvCollectionChanged,this),this._cv=null),this._items=e,this._cv=this._getCollectionView(e),this._lastCount=0,this._cv){this._cv.currentChanged.addHandler(this._cvCurrentChanged,this),this._cv.collectionChanged.addHandler(this._cvCollectionChanged,this);var i=o.tryCast(this._cv,o.CollectionView);i&&!i.sortConverter&&(i.sortConverter=this._bndSortConverter)}this._bindGrid(!0);var n=z;this.selectionMode==n.ListBox&&(this.selectionMode=n.CellRange,this.selectionMode=n.ListBox),this.onItemsSourceChanged(t)}}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collectionView",{get:function(){return this._cv},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"editableCollectionView",{get:function(){return o.tryCast(this._cv,"IEditableCollectionView")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){e!=this._childItemsPath&&(o.assert(null==e||o.isArray(e)||o.isString(e),"childItemsPath should be an array or a string."),this._childItemsPath=e,this._bindGrid(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowHeaderPath",{get:function(){return this._rowHdrPath?this._rowHdrPath.path:null},set:function(e){e!=this.rowHeaderPath&&(e=o.asString(e),this._rowHdrPath=e?new o.Binding(e):null,this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cells",{get:function(){return this._gpCells},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"columnHeaders",{get:function(){return this._gpCHdr},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"columnFooters",{get:function(){return this._gpCFtr},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowHeaders",{get:function(){return this._gpRHdr},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"topLeftCells",{get:function(){return this._gpTL},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottomLeftCells",{get:function(){return this._gpBL},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rows",{get:function(){return this._rows},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"columns",{get:function(){return this._cols},enumerable:!0,configurable:!0}),t.prototype.getColumn=function(e){return this.columns.getColumn(e)},Object.defineProperty(t.prototype,"frozenRows",{get:function(){return this.rows.frozen},set:function(e){this.rows.frozen=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"frozenColumns",{get:function(){return this.columns.frozen},set:function(e){this.columns.frozen=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cloneFrozenCells",{get:function(){return this._fzClone},set:function(e){e!=this.cloneFrozenCells&&(this._fzClone=o.asBoolean(e,!0),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sortRowIndex",{get:function(){return this._sortRowIndex},set:function(e){e!=this._sortRowIndex&&(this._sortRowIndex=o.asNumber(e,!0),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scrollPosition",{get:function(){return this._ptScrl.clone()},set:function(e){var i=this._root,o=-e.x;if(this.rightToLeft)switch(t._getRtlMode()){case"rev":o=i.scrollWidth-i.clientWidth+e.x;break;case"neg":o=e.x;break;default:o=-e.x}i.scrollLeft=o,i.scrollTop=-e.y},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"clientSize",{get:function(){return this._szClient},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"controlRect",{get:function(){return this._rcBounds||(this._rcBounds=o.getElementRect(this._root)),this._rcBounds},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scrollSize",{get:function(){return new o.Size(this._gpCells.width,this._heightBrowser)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"viewRange",{get:function(){return this._gpCells.viewRange},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cellFactory",{get:function(){return this._cf},set:function(e){e!=this._cf&&(this._clearCells(),this._cf=o.asType(e,d,!1))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"itemFormatter",{get:function(){return this._itemFormatter},set:function(e){e!=this._itemFormatter&&(this._clearCells(),this._itemFormatter=o.asFunction(e))},enumerable:!0,configurable:!0}),t.prototype.canEditCell=function(e,t){return this._edtHdl._allowEditing(e,t)},t.prototype.getCellData=function(e,t,i){return this.cells.getCellData(e,t,i)},t.prototype.getCellBoundingRect=function(e,t,i){return this.cells.getCellBoundingRect(e,t,i)},t.prototype.setCellData=function(e,t,i,o,n){return void 0===o&&(o=!0),void 0===n&&(n=!0),this.cells.setCellData(e,t,i,o,n)},t.prototype.hitTest=function(e,t){return o.isNumber(e)&&o.isNumber(t)&&(e=new o.Point(e,t)),o.isBoolean(t)&&t&&(this._rcBounds=null),new b(this,e)},t.prototype.getClipString=function(e){return this._edtHdl.getClipString(e)},t.prototype.setClipString=function(e,t){this._edtHdl.setClipString(e,t)},t.prototype.focus=function(){this._setFocus(!1)},t.prototype.dispose=function(){this.finishEditing(!0),this.itemsSource=null,e.prototype.dispose.call(this)},t.prototype.refresh=function(t){void 0===t&&(t=!0),e.prototype.refresh.call(this,t),this.finishEditing(),t&&(this._updateColumnTypes(),this.scrollPosition=this._ptScrl),this.refreshCells(t)},t.prototype.refreshCells=function(e,t,i){this.isUpdating||(e?this._updateLayout():this._updateContent(t,i))},t.prototype.autoSizeColumn=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=4),this.autoSizeColumns(e,e,t,i)},t.prototype.autoSizeColumns=function(e,i,n,r){var s=this;void 0===n&&(n=!1),void 0===r&&(r=4);var l=0,a=n?this.topLeftCells:this.columnHeaders,h=n?this.bottomLeftCells:this.columnFooters,c=n?this.rowHeaders:this.cells,u=this.viewRange;e=null==e?0:o.asInt(e),i=null==i?c.columns.length-1:o.asInt(i),u.row=Math.max(0,u.row-1e3),u.row2=Math.min(u.row2+1e3,this.rows.length-1),this.finishEditing()&&this.columns.deferUpdate(function(){o.setCss(s._eCt,{width:s._gpCells.width});var n=document.createElement("div");n.setAttribute(t._WJS_MEASURE,"true"),n.style.visibility="hidden",c.hostElement.parentElement.appendChild(n);for(var d=s._getCanvasContext(),g=e;g<=i&&g>-1&&g<c.columns.length;g++){var p=c.columns[g];if(p.isVisible){if(l=0,s.autoSizeMode&j.Headers){for(f=0;f<a.rows.length;f++)if(a.rows[f].isVisible){_=s._getDesiredWidth(a,f,g,n);l=Math.max(l,_)}for(f=0;f<h.rows.length;f++)if(h.rows[f].isVisible){_=s._getDesiredWidth(h,f,g,n);l=Math.max(l,_)}}if(s.autoSizeMode&j.Cells&&u.isValid)if(p._getQuickAutoSize()){var f=s._getWidestRow(c,u,g,d),_=s._getDesiredWidth(c,f,g,n);l=Math.max(l,_)}else for(f=u.row;f<=u.row2&&f<c.rows.length;f++)if(c.rows[f].isVisible){_=s._getDesiredWidth(c,f,g,n);l=Math.max(l,_)}p.width=l+r+2}}s.cellFactory.disposeCell(n),o.removeChild(n)})},t.prototype.autoSizeRow=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=0),this.autoSizeRows(e,e,t,i)},t.prototype.autoSizeRows=function(e,i,n,r){var s=this;void 0===n&&(n=!1),void 0===r&&(r=0);var l=0,a=n?this.topLeftCells:this.rowHeaders,h=n?this.columnHeaders:this.cells;n=o.asBoolean(n),r=o.asNumber(r),e=null==e?0:o.asInt(e),i=null==i?h.rows.length-1:o.asInt(i),this.finishEditing()&&this.rows.deferUpdate(function(){o.setCss(s._eCt,{width:s._gpCells.width});var n=document.createElement("div");n.setAttribute(t._WJS_MEASURE,"true"),n.style.visibility="hidden",h.hostElement.appendChild(n);for(var c={},u=e;u<=i&&u>-1&&u<h.rows.length;u++)if(h.rows[u].isVisible){if(l=0,s.autoSizeMode&j.Headers)for(g=0;g<a.columns.length;g++)if(a.columns[g].isVisible>0){_=s._getDesiredHeight(a,u,g,n);l=Math.max(l,_)}if(s.autoSizeMode&j.Cells)for(var d=!0,g=0;g<h.columns.length;g++){var p=h.columns[g],f=p._getQuickAutoSize();if(p.isVisible&&(d||p.wordWrap||p.cssClass||p.dataType==o.DataType.Boolean||!f)){var _=void 0;if(f){var w={col:g,content:p.dataType==o.DataType.Number?"1":h.getCellData(u,g,!0)},m=JSON.stringify(w);null==(_=c[m])&&(_=s._getDesiredHeight(h,u,g,n),c[m]=_)}else _=s._getDesiredHeight(h,u,g,n);l=Math.max(l,_),d=!1}}h.rows[u].height=l+r}s.cellFactory.disposeCell(n),o.removeChild(n)})},Object.defineProperty(t.prototype,"treeIndent",{get:function(){return this._indent},set:function(e){e!=this._indent&&(this._indent=o.asNumber(e,!1,!0),this.columns.onCollectionChanged())},enumerable:!0,configurable:!0}),t.prototype.collapseGroupsToLevel=function(e){if(this.finishEditing()){var t=this.rows;t.deferUpdate(function(){for(var i=0;i<t.length;i++){var n=o.tryCast(t[i],m);n&&(n.isCollapsed=n.level>=e)}})}},Object.defineProperty(t.prototype,"selectionMode",{get:function(){return this._selHdl.selectionMode},set:function(e){e!=this.selectionMode&&(this._clearCells(),this._selHdl.selectionMode=o.asEnum(e,z))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selection",{get:function(){return this._selHdl.selection.clone()},set:function(e){this._selHdl.selection=e},enumerable:!0,configurable:!0}),t.prototype.select=function(e,t){void 0===t&&(t=!0),this._selHdl.select(e,t)},t.prototype.getSelectedState=function(e,t){return this.cells.getSelectedState(e,t,null)},Object.defineProperty(t.prototype,"selectedRows",{get:function(){var e=[];if(this.selectionMode==z.ListBox)for(i=0;i<this.rows.length;i++)this.rows[i].isSelected&&e.push(this.rows[i]);else if(this.rows.length)for(var t=this.selection,i=t.topRow;i>-1&&i<=t.bottomRow;i++)e.push(this.rows[i]);return e},set:function(e){var t=this;o.assert(this.selectionMode==z.ListBox,"This property can be set only in ListBox mode."),e=o.asArray(e),this.deferUpdate(function(){for(var i=0,o=!0;i<t.rows.length;i++){var n=t.rows[i],r=e&&e.indexOf(n)>-1;r&&o&&(o=!1,t.select(i,t.selection.col)),n.isSelected=r}})},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedItems",{get:function(){for(var e=this.selectedRows,t=0;t<e.length;t++)e[t]=e[t].dataItem;return e},set:function(e){var t=this;o.assert(this.selectionMode==z.ListBox,"This property can be set only in ListBox mode."),e=o.asArray(e),this.deferUpdate(function(){for(var i=0,o=!0;i<t.rows.length;i++){var n=t.rows[i],r=e&&e.indexOf(n.dataItem)>-1;r&&o&&(o=!1,t.select(i,t.selection.col)),n.isSelected=r}})},enumerable:!0,configurable:!0}),t.prototype.scrollIntoView=function(e,t,i){null==this._maxOffsetY&&this._updateLayout();var n=this.scrollPosition,r=this._szClient.width,s=this._szClient.height-this._gpCFtr.rows.getTotalSize(),l=this.cells._getFrozenPos();if((e=o.asInt(e))>-1&&e<this._rows.length&&e>=this._rows.frozen){var a=this._rows[e],h=this.cells.height>s?Math.round(a.pos/(this.cells.height-s)*100)/100:0,c=Math.round(this._maxOffsetY*h),u=a.pos-c,d=u+a.renderSize;d>s-n.y&&(n.y=Math.max(-u,s-d)),u-l.y<-n.y&&(n.y=-(u-l.y))}if((t=o.asInt(t))>-1&&t<this._cols.length&&t>=this._cols.frozen){var g=this._cols[t],p=g.pos+g.renderSize;p>-n.x+r&&(n.x=Math.max(-g.pos,r-p)),g.pos-l.x<-n.x&&(n.x=-(g.pos-l.x))}return!n.equals(this._ptScrl)&&(this.scrollPosition=n,i&&(this._updateScrollPosition(),this.refresh()),!0)},t.prototype.isRangeValid=function(e){return e.isValid&&e.bottomRow<this.rows.length&&e.rightCol<this.columns.length},t.prototype.startEditing=function(e,t,i,o){return void 0===e&&(e=!0),this._edtHdl.startEditing(e,t,i,o)},t.prototype.finishEditing=function(e){return void 0===e&&(e=!1),this._edtHdl.finishEditing(e)},Object.defineProperty(t.prototype,"activeEditor",{get:function(){return this._edtHdl.activeEditor},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"editRange",{get:function(){return this._edtHdl.editRange},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mergeManager",{get:function(){return this._mrgMgr},set:function(e){e!=this._mrgMgr&&(this._mrgMgr=o.asType(e,E,!0),this.invalidate())},enumerable:!0,configurable:!0}),t.prototype.getMergedRange=function(e,t,i,o){return void 0===o&&(o=!0),this._mrgMgr?this._mrgMgr.getMergedRange(e,t,i,o):null},Object.defineProperty(t.prototype,"keyActionTab",{get:function(){return this._keyHdl._kaTab},set:function(e){this._keyHdl._kaTab=o.asEnum(e,M)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keyActionEnter",{get:function(){return this._keyHdl._kaEnter},set:function(e){this._keyHdl._kaEnter=o.asEnum(e,M)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showDropDown",{get:function(){return this._shDropDown},set:function(e){e!=this._shDropDown&&(this._shDropDown=o.asBoolean(e,!0),this.invalidate())},enumerable:!0,configurable:!0}),t.prototype.toggleDropDownList=function(){this._tglDropDown||(this._tglDropDown=!0,this._edtHdl._toggleListBox(null),this._tglDropDown=!1)},t.prototype.onItemsSourceChanging=function(e){return this.itemsSourceChanging.raise(this,e),!e.cancel},t.prototype.onItemsSourceChanged=function(e){this.itemsSourceChanged.raise(this,e)},t.prototype.onScrollPositionChanged=function(e){this.scrollPositionChanged.raise(this,e)},t.prototype.onSelectionChanging=function(e){return this.selectionChanging.raise(this,e),!e.cancel},t.prototype.onSelectionChanged=function(e){this.selectionChanged.raise(this,e)},t.prototype.onLoadingRows=function(e){return this.loadingRows.raise(this,e),!e.cancel},t.prototype.onLoadedRows=function(e){this.loadedRows.raise(this,e)},t.prototype.onUpdatingLayout=function(e){return this.updatingLayout.raise(this,e),!e.cancel},t.prototype.onUpdatedLayout=function(e){this.updatedLayout.raise(this,e)},t.prototype.onResizingColumn=function(e){return this.resizingColumn.raise(this,e),!e.cancel},t.prototype.onResizedColumn=function(e){this.resizedColumn.raise(this,e)},t.prototype.onAutoSizingColumn=function(e){return this.autoSizingColumn.raise(this,e),!e.cancel},t.prototype.onAutoSizedColumn=function(e){this.autoSizedColumn.raise(this,e)},t.prototype.onDraggingColumn=function(e){return this.draggingColumn.raise(this,e),!e.cancel},t.prototype.onDraggingColumnOver=function(e){return this.draggingColumnOver.raise(this,e),!e.cancel},t.prototype.onDraggedColumn=function(e){this.draggedColumn.raise(this,e)},t.prototype.onResizingRow=function(e){return this.resizingRow.raise(this,e),!e.cancel},t.prototype.onResizedRow=function(e){this.resizedRow.raise(this,e)},t.prototype.onAutoSizingRow=function(e){return this.autoSizingRow.raise(this,e),!e.cancel},t.prototype.onAutoSizedRow=function(e){this.autoSizedRow.raise(this,e)},t.prototype.onDraggingRow=function(e){return this.draggingRow.raise(this,e),!e.cancel},t.prototype.onDraggingRowOver=function(e){return this.draggingRowOver.raise(this,e),!e.cancel},t.prototype.onDraggedRow=function(e){this.draggedRow.raise(this,e)},t.prototype.onGroupCollapsedChanging=function(e){return this.groupCollapsedChanging.raise(this,e),!e.cancel},t.prototype.onGroupCollapsedChanged=function(e){this.groupCollapsedChanged.raise(this,e)},t.prototype.onSortingColumn=function(e){return this.sortingColumn.raise(this,e),!e.cancel},t.prototype.onSortedColumn=function(e){this.sortedColumn.raise(this,e)},t.prototype.onBeginningEdit=function(e){return this.beginningEdit.raise(this,e),!e.cancel},t.prototype.onPrepareCellForEdit=function(e){this.prepareCellForEdit.raise(this,e)},t.prototype.onCellEditEnding=function(e){return this.cellEditEnding.raise(this,e),!e.cancel&&!e.stayInEditMode},t.prototype.onCellEditEnded=function(e){this.cellEditEnded.raise(this,e)},t.prototype.onRowEditStarting=function(e){this.rowEditStarting.raise(this,e)},t.prototype.onRowEditStarted=function(e){this.rowEditStarted.raise(this,e)},t.prototype.onRowEditEnding=function(e){this.rowEditEnding.raise(this,e)},t.prototype.onRowEditEnded=function(e){this.rowEditEnded.raise(this,e)},t.prototype.onRowAdded=function(e){return this.rowAdded.raise(this,e),!e.cancel},t.prototype.onDeletingRow=function(e){return this.deletingRow.raise(this,e),!e.cancel},t.prototype.onDeletedRow=function(e){this.deletedRow.raise(this,e)},t.prototype.onCopying=function(e){return this.copying.raise(this,e),!e.cancel},t.prototype.onCopied=function(e){this.copied.raise(this,e)},t.prototype.onPasting=function(e){return this.pasting.raise(this,e),!e.cancel},t.prototype.onPasted=function(e){this.pasted.raise(this,e)},t.prototype.onPastingCell=function(e){return this.pastingCell.raise(this,e),!e.cancel},t.prototype.onPastedCell=function(e){this.pastedCell.raise(this,e)},t.prototype.onFormatItem=function(e){this.formatItem.raise(this,e)},t.prototype.onUpdatingView=function(e){return this.updatingView.raise(this,e),!e.cancel},t.prototype.onUpdatedView=function(e){this.updatedView.raise(this,e)},t.prototype._getShowErrors=function(){return this.showErrors&&this._hasValidation},t.prototype._getHasValidation=function(){return this._hasValidation},t.prototype._getError=function(e,t,i){if(o.isFunction(this.itemValidator)){if(e==this.cells)return this.itemValidator(t,i);if(e==this.rowHeaders)for(i=0;i<this.columns.length;i++)if(c=this.itemValidator(t,i))return c}var n=this._cv,r=n?n.getError:null;if(o.isFunction(r)){var s=e.rows,l=this.columns,a=s[t].dataItem;if(a)for(;t<s.length&&s[t].dataItem==a;t++){if(e==this.cells)return r(a,(h=this._getBindingColumn(this.cells,t,l[i])).binding);if(e==this.rowHeaders)for(i=0;i<l.length;i++){var h=this._getBindingColumn(this.cells,t,l[i]),c=r(a,h.binding);if(c)return c}}}return null},t.prototype._setAria=function(e,t){o.setAttribute(this.cells.hostElement,"aria-"+e,t)},t.prototype._setFocus=function(e){if(this.hostElement&&(e||!this.containsFocus())){var t=o.getActiveElement(),i=this._eFocus,n="tabindex";this.activeEditor?o.contains(this.activeEditor,t)||(this.activeEditor.focus(),i.removeAttribute(n)):this._activeCell?o.contains(this._activeCell,t)||t!=this._root&&(this._activeCell.tabIndex=this._tabIndex,this._activeCell.focus(),i.removeAttribute(n)):o.contains(i,t)||(i.tabIndex=this._tabIndex,i.focus()),this.containsFocus()||(i.tabIndex=this._tabIndex,i.focus())}},t.prototype._setFocusNoScroll=function(e){var t=this.scrollPosition,i=e.style,o=i.position;i.position="fixed",e.tabIndex=this._tabIndex,e.focus(),i.position=o,this.scrollPosition=t;var n=this.hostElement;n.scrollTop=n.scrollLeft=0},t.prototype._getDefaultRowHeight=function(){var e=this.hostElement,t=document.body,i=null;if(t&&!o.contains(t,e)){for(var n=e;n;n=n.parentElement)i=n;i&&t.appendChild(i)}var r=this._eFocus.scrollHeight+2;return(r<=6||isNaN(r))&&(r=28),i&&o.removeChild(i),r},t.prototype._getDefaultCellPadding=function(){var e=getComputedStyle(this._eFocus);return parseInt(this.rightToLeft?e.paddingRight:e.paddingLeft)},t.prototype._getCollectionView=function(e){return o.asCollectionView(e)},t.prototype._getCanvasContext=function(){var e=document.createElement("canvas").getContext("2d"),t=getComputedStyle(this.hostElement);return e.font=t.fontSize+" "+t.fontFamily.split(",")[0],e},t.prototype._getWidestRow=function(e,t,i,n){for(var r=0,s=0,l=e.columns[i].dataType==o.DataType.Boolean,a=t.row;a<=t.row2;a++)if(e.rows[a].isVisible){var h=e.getCellData(a,i,!0),c=n.measureText(h).width;if(c>s&&(s=c,r=a),l)break}return r},t.prototype._getDesiredWidth=function(e,t,i,o){var n=this.getMergedRange(e,t,i),r=o.style;return this.cellFactory.updateCell(e,t,i,o,n),r.width=r.top=r.left="",o.offsetWidth/(n&&n.columnSpan>1?n.columnSpan:1)},t.prototype._getDesiredHeight=function(e,t,i,o){var n=this.getMergedRange(e,t,i),r=o.style;return this.cellFactory.updateCell(e,t,i,o,n),r.height=r.top=r.left="",o.offsetHeight/(n&&n.rowSpan>1?n.rowSpan:1)},t.prototype._getSortRowIndex=function(){return null!=this._sortRowIndex?this._sortRowIndex:this.columnHeaders.rows.length-1},t.prototype._sortConverter=function(e,t,i,o){var n;if(o){if(this._mappedColumns=null,this._cv)for(var r=this._cv.sortDescriptions,s=0;s<r.length;s++)(n=this.getColumn(r[s].property))&&n.dataMap&&(this._mappedColumns||(this._mappedColumns={}),this._mappedColumns[n.binding]=n.dataMap);this._mouseHdl._htDown&&this._mouseHdl._htDown.col>-1&&(n=this.columns[this._mouseHdl._htDown.col],this._mappedColumns&&n.dataMap&&(this._mappedColumns[n.binding]=n.dataMap))}if(this._mappedColumns){var l=this._mappedColumns[e.property];l&&l.sortByDisplayValues&&(i=l.getDisplayValue(i))}return i},t.prototype._bindGrid=function(e){var t=this;if(this.deferUpdate(function(){0==t._lastCount&&o.hasItems(t._cv)&&(e=!0);var i,n=t.selectionMode==z.ListBox;t.preserveSelectedState&&n&&!t.childItemsPath&&(i=t.selectedItems);var r;if(t.preserveOutlineState&&o.isFunction(window.Map)&&t.rows.maxGroupLevel>-1){r=new Map;for(u=0;u<t.rows.length;u++){var s=t.rows[u];if(s instanceof m&&s.isCollapsed&&s.dataItem){var l=s.dataItem;l instanceof o.CollectionViewGroup&&(l=l._path),r.set(l,!0)}}}e&&t.columns.deferUpdate(function(){t._bindColumns()});var a=new o.CancelEventArgs;t.onLoadingRows(a)&&(t.rows.deferUpdate(function(){t._bindRows()}),t.onLoadedRows(a));var h=0;if(i&&i.length)for(u=0;u<t.rows.length&&h<i.length;u++)i.indexOf(t.rows[u].dataItem)>-1&&(t.rows[u].isSelected=!0,h++);if(n&&0==h&&t._lastCount>0)for(var c=t.selection,u=c.topRow;u<=c.bottomRow&&u>-1&&u<t.rows.length;u++)t.rows[u].isSelected=!0;r&&t.rows.deferUpdate(function(){for(var e=0;e<t.rows.length;e++){var i=t.rows[e];if(i instanceof m){var n=i.dataItem;n instanceof o.CollectionViewGroup&&(n=n._path),r.get(n)&&(i.isCollapsed=!0)}}}),!t._lastCount&&t._cv&&t._cv.items&&(t._lastCount=t._cv.items.length)}),!this.rows.length){var i=this._selHdl.selection;i.row=i.row2=-1}this._cv&&this._syncSelection(!0)},t.prototype._cvCollectionChanged=function(e,t){if(this.autoGenerateColumns&&0==this.columns.length)this._bindGrid(!0);else if(this.childItemsPath&&t.action!=o.NotifyCollectionChangedAction.Change)this._bindGrid(!1);else{switch(t.action){case o.NotifyCollectionChangedAction.Change:return void this.invalidate();case o.NotifyCollectionChangedAction.Add:if(t.index==this._cv.items.length-1){var i=this.rows.length;return this.rows[i-1]instanceof V&&i--,void this.rows.insert(i,new w(t.item))}o.assert(!1,"added item should be the last one.");break;case o.NotifyCollectionChangedAction.Remove:var n=this._findRow(t.item);if(n>-1)return this.rows.removeAt(n),void this._syncSelection(!1);o.assert(!1,"removed item not found in grid.")}this._bindGrid(!1)}},t.prototype._cvCurrentChanged=function(e,t){this._syncSelection(!1)},t.prototype._syncSelection=function(e){if(this._cv&&this.selectionMode!=z.None){var t=this.selection,i=t.row>-1&&t.row<this.rows.length?this.rows[t.row].dataItem:null;if(i instanceof o.CollectionViewGroup&&(i=null),(i!=this._cv.currentItem||e)&&(!this.childItemsPath||!this.editableCollectionView||!this.editableCollectionView.currentAddItem)){var n=this._getRowIndex(this._cv.currentPosition);n==t.row&&this.childItemsPath||(t.row=t.row2=n,this.select(t,!1),this.selectionMode&&this.scrollIntoView(t.row,-1))}}},t.prototype._getRowIndex=function(e){if(this._cv){if(e>-1){for(var t=this._cv.items[e];e<this.rows.length;e++)if(this.rows[e].dataItem===t)return e;return-1}if(1==this.rows.length&&this.rows[0]instanceof V)return 0;var i=this.selection.row,o=i>-1?this.rows[i]:null;return o&&(o instanceof m||null==o.dataItem)?i:-1}return this.selection.row},t.prototype._getCvIndex=function(e){if(this._cv&&e>-1&&e<this.rows.length){var t=this._cv.items,i=this.rows[e].dataItem;for(e=Math.min(e,t.length-1);e>-1;e--)if(t[e]===i)return e}return-1},t.prototype._findRow=function(e){for(var t=0;t<this.rows.length;t++)if(this.rows[t].dataItem==e)return t;return-1},t.prototype._updateLayout=function(){var e=new o.CancelEventArgs;if(this.onUpdatingLayout(e)){this._hasValidation=o.isFunction(this._itemValidator)||this._cv&&o.isFunction(this._cv.getError);var i=this._hdrVis&r.Row?this._hdrCols.getTotalSize():0,n=this._hdrVis&r.Column?this._hdrRows.getTotalSize():0,s=this._ftrRows.getTotalSize(),l=this._rows.getTotalSize()+s;l<1&&(l=1),this._heightBrowser=Math.min(l,t._getMaxSupportedCssHeight()),this._maxOffsetY=Math.max(0,l-this._heightBrowser),this._cellPadding=this._getDefaultCellPadding();var a=this._heightBrowser+n-s,h=this._gpCells.width,c=this._heightBrowser;!h&&this.rows.length&&(h=.1),!c&&this.columns.length&&(c=.1),this.rightToLeft?(o.setCss(this._eTL,{right:0,top:0,width:i,height:n}),o.setCss(this._eCHdr,{right:i,top:0,height:n}),o.setCss(this._eRHdr,{right:0,top:n,width:i}),o.setCss(this._eCt,{right:i,top:n,width:h,height:c}),o.setCss(this._fCt,{right:i,top:n}),o.setCss(this._eBL,{right:0,top:a,width:i,height:s}),o.setCss(this._eCFtr,{right:i,top:a,height:s})):(o.setCss(this._eTL,{left:0,top:0,width:i,height:n}),o.setCss(this._eCHdr,{left:i,top:0,height:n}),o.setCss(this._eRHdr,{left:0,top:n,width:i}),o.setCss(this._eCt,{left:i,top:n,width:h,height:c}),o.setCss(this._fCt,{left:i,top:n}),o.setCss(this._eBL,{left:0,top:a,width:i,height:s}),o.setCss(this._eCFtr,{left:i,top:a,height:s})),this._stickyHdr&&this._updateStickyHeaders();var u=this.frozenRows||this.frozenColumns?"3":"";o.setCss([this._eTL,this._eBL,this._eCHdr,this._eCFtr,this._eRHdr,this._eMarquee],{zIndex:u});var d=this._root,g=d.offsetWidth-d.clientWidth,p=d.offsetHeight-d.clientHeight;o.setCss(this._eSz,{width:i+g+this._gpCells.width,height:n+p+this._heightBrowser});var f=null;this.columns._updateStarSizes(d.clientWidth-i)&&(f=d.clientWidth,o.setCss(this._eCt,{width:this._gpCells.width})),this._szClient=new o.Size(d.clientWidth-i,d.clientHeight-n),this._rcBounds=null,this._updateScrollHandler(),this._updateContent(!1),g=d.offsetWidth-d.clientWidth,p=d.offsetHeight-d.clientHeight,o.setCss(this._eSz,{width:i+g+this._gpCells.width,height:n+p+this._heightBrowser}),this._szClient=new o.Size(d.clientWidth-i,d.clientHeight-n),f&&f!=d.clientWidth&&this.columns._updateStarSizes(d.clientWidth-i)&&(o.setCss(this._eCt,{width:this._gpCells.width}),this._updateContent(!1)),o.setCss([this._eCHdr,this._eCFtr,this._fCt],{width:this._szClient.width}),o.setCss([this._eRHdr,this._fCt],{height:this._szClient.height}),s&&(a=Math.min(a,this._szClient.height+n-s),o.setCss([this._eBL,this._eCFtr],{top:a})),this.onUpdatedLayout(e)}},t.prototype._updateStickyHeaders=function(){var e=!1,i=0;if(this._stickyHdr){for(var n=0,r=null,s=this.hostElement;s;s=s.parentElement){var l=s.getBoundingClientRect();null==r&&(r=l.top),n=Math.max(n,l.top)}i=-(r=Math.max(0,n-r-1)),e=r>0,this._rcBounds=null}this._eTL.style.top=this._eCHdr.style.top=e?-i+"px":"",o.toggleClass(this._eTL,t._WJS_STICKY,e),o.toggleClass(this._eCHdr,t._WJS_STICKY,e)},t.prototype._updateScrollHandler=function(){this._clipToScreen=this._getClipToScreen();var e=this._stickyHdr||this._clipToScreen;e!=this._scrollHandlerAttached&&(this._scrollHandlerAttached=e,e?this.addEventListener(window,"scroll",this._bndScroll,!0):this.removeEventListener(window,"scroll",this._bndScroll,!0))},t.prototype._getClipToScreen=function(){if(this.rows.length<=t._MIN_VIRT_ROWS)return!1;if(this._root.clientHeight!=this._root.scrollHeight)return!1;for(var e=this.hostElement;e&&e!=document.documentElement;e=e.parentElement)if("auto"==getComputedStyle(e).overflow)return!1;return!0},t.prototype._scroll=function(e){var t=this;o.contains(e.target,this.hostElement)&&(this._clipToScreen&&(this._afScrl&&cancelAnimationFrame(this._afScrl),this._afScrl=requestAnimationFrame(function(){t._afScrl=null,t.finishEditing(),t._updateContent(!0)})),this._stickyHdr&&(this._afSticky&&cancelAnimationFrame(this._afSticky),this._afSticky=requestAnimationFrame(function(){t._afSticky=null;var e=new o.CancelEventArgs;t.onUpdatingLayout(e)&&(t._updateStickyHeaders(),t.onUpdatedLayout(e))})))},t.prototype._updateScrollPosition=function(){var e=this._root,i=e.scrollTop,n=e.scrollLeft;this.rightToLeft&&"rev"==t._getRtlMode()&&(n=e.scrollWidth-e.clientWidth-n);var r=new o.Point(-Math.abs(n),-i);return!this._ptScrl.equals(r)&&(this._ptScrl=r,this.onScrollPositionChanged(),!0)},t.prototype._updateContent=function(e,t){var i=o.getActiveElement(),n=this.hostElement,s=o.contains(n,i)?i:null,l=this._activeCell,a=new o.CancelEventArgs;if(this.onUpdatingView(a)){if(this._offsetY=0,this._heightBrowser>this._szClient.height){var h=Math.round(-this._ptScrl.y/(this._heightBrowser-this._szClient.height)*100)/100;this._offsetY=Math.round(this._maxOffsetY*h)}this._updateScrollPosition();var c=this._gpCells._updateContent(e,t,this._offsetY);if(this._hdrVis&r.Column&&(!t||this._ssHdr&r.Column)&&this._gpCHdr._updateContent(e,t,0),this._hdrVis&r.Row&&(!t||this._ssHdr&r.Row)&&this._gpRHdr._updateContent(e,t,this._offsetY),this._hdrVis&&!t&&this._gpTL._updateContent(e,t,0),this._gpCFtr.rows.length&&(this._gpBL._updateContent(e,t,0),this._gpCFtr._updateContent(e,t,0)),this.showMarquee){var u=this._selHdl.selection,d=this._eMarquee;if(this.isRangeValid(u)){var g=this._getMarqueeRect(u),p=this.cells.hostElement,f=d.firstChild,_=d.offsetWidth-f.offsetWidth,w=d.offsetHeight-f.offsetHeight;o.setCss(d,{left:g.left+p.offsetLeft-_/2,top:g.top+p.offsetTop-w/2,width:g.width+_,height:g.height+w,visibility:g.width>0&&g.height>0?"":"collapse"})}else o.setCss(d,{left:0,top:0,width:0,height:0,visibility:"collapse"})}if(this._useFrozenDiv()&&(this._updateFrozenCells(t),c&&o.hasClass(c,"wj-frozen")&&(c=null)),this._activeCell=c,s)if(s!=this._root&&s!=this._eFocus&&o.contains(this.hostElement,s)&&!o.contains(this.cells.hostElement,s)){if(document.activeElement!=s&&s.focus(),o.isIE()&&s instanceof HTMLInputElement&&!s.type.match(/checkbox|radio|range/i)){var m=s.selectionStart,y=s.selectionEnd;s.setSelectionRange(m,y)}}else{var v=c!=l;this._setFocus(v)}n&&(n.scrollTop&&(n.scrollTop=0),n.firstElementChild.scrollTop&&(n.firstElementChild.scrollTop=0)),!s&&c&&(c.tabIndex=this._tabIndex),l&&l!=c&&l.removeAttribute("tabindex"),this._rcBounds=null,this.onUpdatedView(a)}},t.prototype._clearCells=function(){for(var e in this)if("_"==e[0]){var t=this[e];t instanceof u&&t._clearCells()}this.invalidate()},t.prototype._useFrozenDiv=function(){return o.isBoolean(this._fzClone)?this._fzClone:o.isIE()||o.isFirefox()||o.isMobile()},t.prototype._updateFrozenCells=function(e){if(this.frozenRows||this.frozenColumns){var t=this._eCt.querySelectorAll(".wj-frozen");if(e&&this._fCt.children.length==t.length){for(i=0;i<t.length;i++)this._fCt.children[i].className=t[i].className;return}if(o.setText(this._fCt,null),!this.activeEditor)for(var i=0;i<t.length;i++){var n=t[i].cloneNode(!0);n.style.pointerEvents="auto",this._fCt.appendChild(n)}}else o.setText(this._fCt,null)},t.prototype._getMarqueeRect=function(e){var t=this.getMergedRange(this.cells,e.topRow,e.leftCol)||new g(e.topRow,e.leftCol),i=this.getMergedRange(this.cells,e.bottomRow,e.rightCol)||new g(e.bottomRow,e.rightCol),n=this.cells.getCellBoundingRect(t.topRow,t.leftCol,!0),r=this.cells.getCellBoundingRect(i.bottomRow,i.rightCol,!0);if(this.rows.frozen){var s=Math.min(this.rows.length,this.rows.frozen),l=this.cells.getCellBoundingRect(s-1,0,!0);e.topRow>=s&&n.top<l.bottom&&(n.top=l.bottom),e.bottomRow>=s&&r.bottom<l.bottom&&(r.height=l.bottom-r.top)}if(this.columns.frozen){var a=Math.min(this.columns.length,this.columns.frozen),l=this.cells.getCellBoundingRect(0,a-1,!0);this.rightToLeft?(e.leftCol>=a&&n.right>l.left&&(n.left=l.left-n.width),e.rightCol>=a&&r.left>l.left&&(r.left=l.left)):(e.leftCol>=a&&n.left<l.right&&(n.left=l.right),e.rightCol>=a&&r.right<l.right&&(r.width=l.right-r.left))}return this.rightToLeft?new o.Rect(r.left,n.top,n.right-r.left,r.bottom-n.top):new o.Rect(n.left,n.top,r.right-n.left,r.bottom-n.top)},t.prototype._bindColumns=function(){for(var e=0;e<this.columns.length;e++)(a=this.columns[e])._getFlag(p.AutoGenerated)&&(this.columns.removeAt(e),e--);var t=this._cv,i=t?t.sourceCollection:null,n=i&&i.length?i[0]:null;if(n&&this.autoGenerateColumns)for(var r in n)for(var s=null,l=0;l<i.length&&l<1e3&&null==s;l++)if(s=i[l][r],o.isPrimitive(s)){var a=new _;a._setFlag(p.AutoGenerated,!0),a.binding=a.name=r,a.header=o.toHeaderCase(r),a.dataType=o.getType(s),a.dataType==o.DataType.Number&&(a.width=80);var h=Object.getOwnPropertyDescriptor(n,r);!h||h.writable||o.isFunction(h.set)||a._setFlag(p.ReadOnly,!0),this.columns.push(a)}this._updateColumnTypes()},t.prototype._updateColumnTypes=function(){var e=this._cv;if(o.hasItems(e))for(var t=e.items[0],i=this.columns,n=0;n<i.length;n++){var r=i[n];null==r.dataType&&r._binding&&(r.dataType=o.getType(r._binding.getValue(t)))}},t.prototype._getBindingColumn=function(e,t,i){return i},t.prototype._getRowHeaderPath=function(){return this._rowHdrPath},t.prototype._bindRows=function(){this.rows.clear();var e=this._cv;if(e&&e.items){var t=e.items,i=e.groups;if(this.childItemsPath)for(o=0;o<t.length;o++)this._addNode(t,o,0);else if(null!=i&&i.length>0&&this.showGroups)for(o=0;o<i.length;o++)this._addGroup(i[o]);else for(var o=0;o<t.length;o++)this._addBoundRow(t,o)}},t.prototype._addBoundRow=function(e,t){this.rows.push(new w(e[t]))},t.prototype._addNode=function(e,t,i){var n=new m,r=this.childItemsPath,s=o.isArray(r)?r[i]:r,l=e[t],a=l[s];if(n.dataItem=l,n.level=i,this.rows.push(n),o.isArray(a))for(var h=0;h<a.length;h++)this._addNode(a,h,i+1)},t.prototype._addGroup=function(e){var t=new m;if(t.level=e.level,t.dataItem=e,this.rows.push(t),e.isBottomLevel)for(var i=e.items,o=0;o<i.length;o++)this._addBoundRow(i,o);else for(o=0;o<e.groups.length;o++)this._addGroup(e.groups[o])},t._getSerializableProperties=function(e){var t=[];for(e=e.prototype;e!=Object.prototype;e=Object.getPrototypeOf(e))for(var i=Object.getOwnPropertyNames(e),o=0;o<i.length;o++){var n=i[o],r=Object.getOwnPropertyDescriptor(e,n);r&&r.set&&r.get&&"_"!=n[0]&&!n.match(/disabled|required/)&&t.push(n)}return t},t.prototype._copy=function(e,t){if("columns"==e){this.columns.clear();for(var i=o.asArray(t),n=0;n<i.length;n++){var r=new _;o.copy(r,i[n]),this.columns.push(r)}return!0}return!1},t.prototype._isInputElement=function(e){if(e instanceof HTMLElement){if("true"==e.contentEditable)return!0;var t=e.tagName.match(/^(BUTTON|A|INPUT|TEXTAREA|SELECT|OPTION)$/i);return t&&t.length>0}return!1},t.prototype._wantsInput=function(e){return this._isInputElement(e)&&!this.activeEditor&&!this._edtHdl._isNativeCheckbox(e)&&!o.hasClass(e,"wj-grid-ime")&&o.contains(document.body,e)},t._getMaxSupportedCssHeight=function(){if(!t._maxCssHeight){var e=335e5;o.isIE()?e=15e5:o.isFirefox()&&(e=175e5),t._maxCssHeight=e}return t._maxCssHeight},t._getRtlMode=function(){if(!t._rtlMode){var e=o.createElement('<div dir="rtl" style="visibility:hidden;width:100px;height:100px;overflow:auto"><div style="width:2000px;height:2000px"></div></div>');document.body.appendChild(e);var i=e.scrollLeft;e.scrollLeft=-1e3;var n=e.scrollLeft;o.removeChild(e),t._rtlMode=n<0?"neg":i>0?"rev":"std"}return t._rtlMode},t._WJS_STICKY="wj-state-sticky",t._WJS_MEASURE="wj-state-measuring",t._WJS_UPDATING="wj-state-updating",t._MIN_VIRT_ROWS=200,t.controlTemplate='<div style="position:relative;width:100%;height:100%;overflow:hidden;max-width:inherit;max-height:inherit"><div wj-part="focus" aria-hidden="true" class="wj-cell" style="position:fixed;opacity:0;pointer-events:none;left:-10px">0</div><div wj-part="root" style="position:absolute;width:100%;height:100%;overflow:auto;-webkit-overflow-scrolling:touch;max-width:inherit;max-height:inherit"><div wj-part="cells" class="wj-cells" style="position:absolute"></div><div wj-part="marquee" aria-hidden="true" class="wj-marquee" style="display:none;pointer-events:none;"><div style="width:100%;height:100%"></div></div></div><div wj-part="fcells" aria-hidden="true" class="wj-cells" style="position:absolute;pointer-events:none;overflow:hidden"></div><div wj-part="rh" aria-hidden="true" style="position:absolute;overflow:hidden;outline:none"><div wj-part="rhcells" class="wj-rowheaders" style="position:relative"></div></div><div wj-part="cf" aria-hidden="true" style="position:absolute;overflow:hidden;outline:none"><div wj-part="cfcells" class="wj-colfooters" style="position:relative"></div></div><div wj-part="ch" aria-hidden="true" style="position:absolute;overflow:hidden;outline:none"><div wj-part="chcells" class="wj-colheaders" style="position:relative"></div></div><div wj-part="bl" aria-hidden="true" style="position:absolute;overflow:hidden;outline:none"><div wj-part="blcells" class="wj-bottomleft" style="position:relative"></div></div><div wj-part="tl" aria-hidden="true" style="position:absolute;overflow:hidden;outline:none"><div wj-part="tlcells" class="wj-topleft" style="position:relative"></div></div><div wj-part="sz" aria-hidden="true" style="position:relative;visibility:hidden"></div></div>',t}(o.Control),e("FlexGrid",s),l=function(e){function t(t,i,n){var r=e.call(this)||this;return r._p=o.asType(t,u),r._rng=o.asType(i,g),r._data=n,r}return K(t,e),Object.defineProperty(t.prototype,"panel",{get:function(){return this._p},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"range",{get:function(){return this._rng.clone()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"row",{get:function(){return this._rng.row},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"col",{get:function(){return this._rng.col},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"data",{get:function(){return this._data},set:function(e){this._data=e},enumerable:!0,configurable:!0}),t}(o.CancelEventArgs),e("CellRangeEventArgs",l),a=function(e){function t(t,i,n){var r=e.call(this,t,i)||this;return r._cell=o.asType(n,HTMLElement),r}return K(t,e),Object.defineProperty(t.prototype,"cell",{get:function(){return this._cell},enumerable:!0,configurable:!0}),t}(l),e("FormatItemEventArgs",a),h=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._stayInEditMode=!1,t._refresh=!0,t}return K(t,e),Object.defineProperty(t.prototype,"stayInEditMode",{get:function(){return this._stayInEditMode},set:function(e){this._stayInEditMode=o.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"refresh",{get:function(){return this._refresh},set:function(e){this._refresh=o.asBoolean(e)},enumerable:!0,configurable:!0}),t}(l),e("CellEditEndingEventArgs",h),function(e){e[e.None=0]="None",e[e.Cell=1]="Cell",e[e.ColumnHeader=2]="ColumnHeader",e[e.RowHeader=3]="RowHeader",e[e.TopLeft=4]="TopLeft",e[e.ColumnFooter=5]="ColumnFooter",e[e.BottomLeft=6]="BottomLeft"}(c||(c={})),e("CellType",c),u=function(){function e(e,t,i,n,r){this._offsetY=0,this._g=o.asType(e,s),this._ct=o.asInt(t),this._rows=o.asType(i,C),this._cols=o.asType(n,v),this._e=o.asType(r,HTMLElement),this._vrb=new g}return Object.defineProperty(e.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cellType",{get:function(){return this._ct},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewRange",{get:function(){return this._getViewRange()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._cols.getTotalSize()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._rows.getTotalSize()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._rows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columns",{get:function(){return this._cols},enumerable:!0,configurable:!0}),e.prototype.getCellData=function(e,t,i){var n,r=this._rows[o.asNumber(e,!1,!0)],s=null;if(o.isString(t)&&(t=this._cols.indexOf(t))<0)throw"Invalid column name or binding.";n=this._cols[o.asNumber(t,!1,!0)];var l=this._g?this._g._getBindingColumn(this,e,n):n;if(!l.binding||!r.dataItem||r.dataItem instanceof o.CollectionViewGroup?r._ubv&&(s=r._ubv[n._hash]):s=l._binding.getValue(r.dataItem),null==s)switch(this._ct){case c.ColumnHeader:e!=this._rows.length-1&&l==n||(s=l.header);break;case c.ColumnFooter:if(l.aggregate!=o.Aggregate.None&&r instanceof m){var a=this._g.collectionView;if(a){var h=o.tryCast(a,o.CollectionView);s=h?h.getAggregate(l.aggregate,l.binding):o.getAggregate(l.aggregate,a.items,l.binding)}}break;case c.Cell:if(l.aggregate!=o.Aggregate.None&&r instanceof m){var u=o.tryCast(r.dataItem,o.CollectionViewGroup);u&&(s=u.getAggregate(l.aggregate,l.binding,this._g.collectionView))}}return i&&(this.cellType==c.Cell&&l.dataMap&&(s=l.dataMap.getDisplayValue(s)),s=null!=s?o.Globalize.format(s,l.format):""),s},e.prototype.setCellData=function(e,t,i,n,r){void 0===n&&(n=!0),void 0===r&&(r=!0);var s,l=this._rows[o.asNumber(e,!1,!0)];if(o.isString(t)&&(t=this._cols.indexOf(t))<0)throw"Invalid column name or binding.";s=this._cols[o.asNumber(t,!1,!0)];var a=this._g?this._g._getBindingColumn(this,e,s):s;if(this._ct==c.Cell){if(a.dataMap&&null!=i&&(a.isRequired||""!=i)){var h=a.dataMap,u=h.getKeyValue(i);if(null==u&&null==h.getDisplayValue(null)){if(!h.isEditable||h.displayMemberPath!=h.selectedValuePath)return!1}else i=u}var d=o.DataType.Object;if(a.dataType)d=a.dataType;else{var g=this.getCellData(e,t,!1);d=o.getType(g)}if(o.isBoolean(a.isRequired))if(a.isRequired||""!==i&&null!==i){if(a.isRequired&&(""===i||null===i))return!1}else i=null,n=!1;if(n&&(i=o.changeType(i,d,a.format),d!=o.DataType.Object&&o.getType(i)!=d))return!1}if(l.dataItem&&a.binding){var p=a._binding,f=l.dataItem,_=p.getValue(f);if(i!==_&&!o.DateTime.equals(i,_)){p.setValue(f,i);var w=this._g.collectionView;if(w instanceof o.CollectionView&&f!=w.currentEditItem){var m=new o.NotifyCollectionChangedEventArgs(o.NotifyCollectionChangedAction.Change,f,w.items.indexOf(f));w.onCollectionChanged(m)}}}else l._ubv||(l._ubv={}),l._ubv[s._hash]=i;return r&&this._g&&this._g.invalidate(),!0},e.prototype.getCellBoundingRect=function(e,t,i){var n=this.rows[e],r=this.columns[t],s=new o.Rect(r.pos,n.pos,r.renderSize,n.renderSize);if(this._g.rightToLeft&&(s.left=this.hostElement.clientWidth-s.right,!o.isIE()&&!o.isFirefox())){var l=this.hostElement.parentElement;s.left-=l.offsetWidth-l.clientWidth}if(!i){var a=this.hostElement.getBoundingClientRect();s.left+=a.left,s.top+=a.top-this._offsetY}return e<this.rows.frozen&&(s.top-=this._g.scrollPosition.y),t<this.columns.frozen&&(s.left-=this._g.scrollPosition.x*(this._g.rightToLeft?-1:1)),s},e.prototype.getCellElement=function(t,i){for(var o=this.hostElement.children,n=Math.min(t+2,o.length),r=0;r<n;r++)for(var s=o[r].children,l=Math.min(i+2,s.length),a=0;a<l;a++){var h=s[a],c=h[e._INDEX_KEY];if(c&&(c.row==t&&c.col==i||c.rng&&c.rng.contains(t,i)))return h}return null},e.prototype.getSelectedState=function(e,t,i){var o=this._g,n=o.selectionMode,s=o._selHdl.selection,l=z,a=x;if(n!=l.None)switch(this._ct){case c.Cell:if(i||(i=o.getMergedRange(this,e,t)),i){if(i.contains(s.row,s.col))return o.showMarquee?a.None:a.Cursor;if(i.intersects(s))return a.Selected}if(s.row==e&&s.col==t)return o.showMarquee?a.None:a.Cursor;if(o.rows[e].isSelected||o.columns[t].isSelected)return a.Selected;if(i)switch(n){case l.Row:case l.RowRange:case l.ListBox:if(i.containsRow(s.row))return a.Selected}return s=o._selHdl._adjustSelection(s),n==z.ListBox?a.None:s.containsRow(e)&&s.containsColumn(t)?a.Selected:a.None;case c.ColumnHeader:if(o.showSelectedHeaders&r.Column&&(o.columns[t].isSelected||s.containsColumn(t)||s.intersectsColumn(i))&&(i&&(e=i.bottomRow),e==this.rows.length-1))return a.Selected;break;case c.RowHeader:if(o.showSelectedHeaders&r.Row&&(o.rows[e].isSelected||s.containsRow(e)||s.intersectsRow(i))&&(i&&(t=i.rightCol),t==this.columns.length-1))return a.Selected}return a.None},Object.defineProperty(e.prototype,"hostElement",{get:function(){return this._e},enumerable:!0,configurable:!0}),e.prototype._getOffsetY=function(){return this._offsetY},e.prototype._updateContent=function(e,t,i){var o=this._g,n=this._e,r=this._rows,s=this._cols,l=this._ct;if(l==c.ColumnHeader||l==c.ColumnFooter||l==c.RowHeader){var a=o._ptScrl,h=n.style;l==c.RowHeader?h.top=a.y+"px":o.rightToLeft?h.right=a.x+"px":h.left=a.x+"px"}this._offsetY!=i&&(e=!1,this._offsetY=i);var u=this._getViewRange(),d=u;if(r.length<=o.virtualizationThreshold)d=new g(0,0,r.length-1,s.length-1);else if(d.isValid&&o.isTouching){d=new g(Math.max(u.row-6,r.frozen),Math.max(u.col-1,s.frozen),Math.min(u.row2+6,r.length-1),Math.min(u.col2+1,s.length-1))}if(e&&!t&&this._vrb.contains(u)&&!r.frozen&&!s.frozen)return this._activeCell;e&&d.equals(this._vrb)||(t=!1),e&&!t&&this._ct!=c.TopLeft&&this._reorderCells(d,this._vrb),this._activeCell=null,this._vru=u,this._vrb=d,this._cf=o.cellFactory;var p=0;this._ct==c.Cell&&(p=this._renderColHdrRow(d,t));for(f=0;f<r.frozen&&f<r.length;f++)p=this._renderRow(f,d,t,p);for(var f=d.topRow;f<=d.bottomRow&&f>-1;f++)p=this._renderRow(f,d,t,p);for(;n.childElementCount>p;){var _=n.lastElementChild;n.removeChild(_),this._removeExtraCells(_,0)}return this._activeCell},e.prototype._updateScrollPosition=function(){var e=this._g,t=e._ptScrl,i=this.hostElement.style;this.cellType==c.RowHeader?i.top=t.y+"px":e.rightToLeft?i.right=t.x+"px":i.left=t.x+"px"},e.prototype._clearCells=function(){for(var e=this.hostElement,t=e.childElementCount-1;t>=0;t--){var i=e.children[t];e.removeChild(i);for(var o=i.childElementCount-1;o>=0;o--)this._cf.disposeCell(i.children[o])}},e.prototype._reorderCells=function(e,t){if(!(this._rows.frozen>0||this._cols.frozen>0||e.columnSpan!=t.columnSpan||e.rowSpan!=t.rowSpan)&&t.isValid&&e.isValid&&e.intersects(t)&&e.row!=t.row){var i=e.row-t.row,o=Math.max(1,e.rowSpan-1),n=this._e;if(0!=i&&Math.abs(i)<o){var r=this._ct==c.Cell?1:0,s=n.childElementCount;if(i>0){var l=r,a=Math.min(r+i,s-1);(h=this._createRange(l,a))&&a<s-1&&n.appendChild(h.extractContents())}if(i<0){var a=s,l=Math.max(r,a+i),h=this._createRange(l,a);if(h&&l>r){var u=n.children[r];n.insertBefore(h.extractContents(),u)}}}}},e.prototype._createRange=function(e,t){var i,o=this._e.childElementCount;return t>e&&t<=o&&e>-1&&((i=document.createRange()).setStart(this._e,e),i.setEnd(this._e,t)),i},e.prototype._renderColHdrRow=function(e,t){var i=this._e.children[0];i||(i=o.createElement('<div class="wj-row" tabindex="-1" role="row"></div>',this._e)),o.setAttribute(i,"aria-selected",null);var n=0,r=this._g._getRowHeaderPath();r&&(n=this._renderRowHdrCell(i,-1,r.path));for(s=0;s<this.columns.frozen&&s<this.columns.length;s++)n=this._renderColHdrCell(i,s,e,t,n);for(var s=e.leftCol;s<=e.rightCol&&s>-1;s++)n=this._renderColHdrCell(i,s,e,t,n);return this._removeExtraCells(i,n),1},e.prototype._renderColHdrCell=function(t,i,n,r,s){var l=this.columns[i];if(l.renderSize<=0)return s;var a=t.children[s];a||(a=o.createElement('<div class="wj-cell" tabindex="-1" role="columnheader"></div>',t)),r||(a.textContent=this.columns[i].header,o.setCss(a,{position:"fixed",top:-32e3,height:.1,left:l.pos,width:l.renderWidth,overflow:"hidden",opacity:"0",pointerEvents:"none"}));var h=this.grid;if(h.allowSorting){var c="none";switch(h._getBindingColumn(this,0,l).currentSort){case"+":c="ascending";break;case"-":c="descending"}o.setAttribute(a,"aria-sort",c)}return a[e._INDEX_KEY]={row:-1,col:i,panel:this},s+1},e.prototype._renderRowHdrCell=function(t,i,n){var r=t.children[0];return r||(r=o.createElement('<div class="wj-cell" tabindex="-1"></div>',t)),r.setAttribute("role",i<0?"columnheader":"rowheader"),r.textContent=n?n.toString():"",o.setCss(r,{position:"fixed",left:-32e3,top:-32e3,width:.1,height:.1,overflow:"hidden",opacity:"0"}),r[e._INDEX_KEY]={row:i,col:-1,panel:this},1},e.prototype._renderRow=function(e,t,i,n){var r=this._g,s=this.rows[e];if(s.renderSize<=0)return n;var l=this._e.children[n];if(l||(l=o.createElement('<div class="wj-row" tabindex="-1"></div>',this._e),this._ct==c.Cell&&l.setAttribute("role","row")),this._ct==c.Cell){var a=z;switch(r.selectionMode){case a.Row:case a.RowRange:case a.ListBox:var h=s.isSelected||this._g._selHdl.selection.containsRow(e);o.setAttribute(l,"aria-selected",!!h)}}var u=0;if(this._ct==c.Cell){var d=this._g._getRowHeaderPath();d&&(u=this._renderRowHdrCell(l,e,d.getValue(s.dataItem)))}for(g=0;g<this.columns.frozen&&g<this.columns.length;g++)u=this._renderCell(l,e,g,t,i,u);for(var g=t.leftCol;g<=t.rightCol&&g>-1;g++)u=this._renderCell(l,e,g,t,i,u);return this._removeExtraCells(l,u),n+1},e.prototype._renderCell=function(t,i,n,r,s,l){var a=this._g,h=a.getMergedRange(this,i,n);if(h){for(u=Math.max(r.row,h.row);u<i;u++)if(this.rows[u].isVisible)return l;for(var u=Math.max(r.col,h.col);u<n;u++)if(this.columns[u].isVisible)return l}if(this.columns[n].renderSize<=0&&(!h||h.getRenderSize(this).width<=0))return l;var d=!1;if(this.cellType==c.Cell){var g=a._selHdl.selection;d=g.row==i&&g.col==n||h&&h.contains(g.row,g.col)}var p=t.children[l],f=this.getSelectedState(i,n,h),_=x;return p&&s?(o.toggleClass(p,"wj-state-selected",f==_.Cursor),o.toggleClass(p,"wj-state-multi-selected",f==_.Selected),d&&(this._activeCell=p),l+1):(p||((p=document.createElement("div")).tabIndex=-1,this._ct==c.Cell&&p.setAttribute("role","gridcell"),t.appendChild(p)),d&&(this._activeCell=p),a.cellFactory.updateCell(this,i,n,p,h),p[e._INDEX_KEY]={row:i,col:n,rng:h,panel:this},l+1)},e.prototype._removeExtraCells=function(e,t){for(;e.childElementCount>t;){var i=e.lastElementChild;e.removeChild(i),this._cf.disposeCell(i)}},e.prototype._getViewRange=function(){var e=this._g,t=e._ptScrl,i=this._rows,o=this._cols,n=new g(0,0,i.length-1,o.length-1);if(this._ct==c.Cell||this._ct==c.RowHeader){var r=-t.y+this._offsetY,s=e._szClient.height;if((u=Math.min(i.frozen,i.length-1))>0&&(r+=d=i[u-1].pos,s-=d),n.row=Math.min(i.length-1,Math.max(i.frozen,i.getItemAt(r+1))),n.row2=i.getItemAt(r+s+1),e._clipToScreen){var l=e.hostElement.getBoundingClientRect();l.top<0&&(n.row=Math.max(n.row,i.getItemAt(-l.top-e._ptScrl.y)-1)),l.bottom>innerHeight&&(n.row2=Math.min(n.row2,i.getItemAt(-l.top-e._ptScrl.y+innerHeight)+1))}}if(this._ct==c.Cell||this._ct==c.ColumnHeader){var a=-t.x,h=e._szClient.width,u=Math.min(o.frozen,o.length-1);if(u>0){var d=o[u-1].pos;a+=d,h-=d}n.col=Math.min(o.length-1,Math.max(o.frozen,o.getItemAt(a+1))),n.col2=o.getItemAt(a+h+1)}return i.length<=i.frozen&&(n.row=n.row2=-1),o.length<=o.frozen&&(n.col=n.col2=-1),n},e.prototype._getFrozenPos=function(){var e=this._rows.frozen,t=this._cols.frozen,i=e>0?this._rows[e-1]:null,n=t>0?this._cols[t-1]:null,r=i?i.pos+i.renderSize:0,s=n?n.pos+n.renderSize:0;return new o.Point(s,r)},e._INDEX_KEY="wj-cell-index",e}(),e("GridPanel",u),d=function(){function e(){}return e.prototype.updateCell=function(t,n,r,s,l,h){var u=t.grid,d=u.rightToLeft,p=t.cellType,f=t.rows,_=t.columns,w=f[n],y=_[r],v=n,C=r,b=w instanceof m?w:null,R=w instanceof V?w:null,E=y.renderWidth,S=w.renderHeight,z="wj-cell",H={display:""};if(0!=h&&s.firstElementChild&&(1==s.childNodes.length&&"checkbox"==s.firstElementChild.type||(s.textContent="")),l&&!l.isSingleCell){n=l.row,r=l.col,v=l.row2,C=l.col2,w=f[n],y=_[r],b=w instanceof m?w:null;var P=l.getRenderSize(t);S=P.height,E=P.width}var M=u._getBindingColumn(t,n,y),T=M.dataType==o.DataType.Boolean&&!M.dataMap,D=y.pos,L=w.pos;if(u._useFrozenDiv()&&p==c.Cell&&!u.editRange?(n<f.frozen&&r>=_.frozen&&(D+=u._ptScrl.x),r<_.frozen&&n>=f.frozen&&(L+=u._ptScrl.y)):(n<f.frozen&&(L-=u._ptScrl.y),r<_.frozen&&(D-=u._ptScrl.x)),d?H.right=D+"px":H.left=D+"px",H.top=L-t._getOffsetY()+"px",H.width=E+"px",H.height=S+"px",H.zIndex="",(n<f.frozen||r<_.frozen)&&(H.zIndex=n<f.frozen&&r<_.frozen?2:1),p==c.Cell?(b&&(z+=" wj-group"),u.showAlternatingRows&&w.visibleIndex%2!=0&&(l&&l.row!=l.row2||(z+=" wj-alt")),(n<f.frozen||r<_.frozen)&&(z+=" wj-frozen"),R&&(z+=" wj-new"),w.cssClass&&(z+=" "+w.cssClass),M.cssClass&&(z+=" "+M.cssClass)):(z+=" wj-header",u.showAlternatingRows&&n%2!=0&&(z+=" wj-header-alt")),(p==c.Cell||p==c.RowHeader)&&u._getShowErrors()){var O=u._getError(t,n,r);o.setAttribute(s,"title",O),O&&(z+=" wj-state-invalid")}var j=t.getSelectedState(n,r,l);switch(j!=x.None&&p==c.Cell&&!T&&u.editRange&&u.editRange.contains(n,r)&&(j=x.None),j){case x.Cursor:z+=" wj-state-selected";break;case x.Selected:z+=" wj-state-multi-selected"}if(v==f.frozen-1&&(z+=" wj-frozen-row"),C==_.frozen-1&&(z+=" wj-frozen-col"),(M.wordWrap||w.wordWrap)&&(z+=" wj-wrap"),H.textAlign=M.getAlignment(),H.paddingLeft=H.paddingRight=H.paddingTop=H.paddingBottom="",p==c.Cell&&u.rows.maxGroupLevel>-1&&r==u.columns.firstVisibleIndex&&u.treeIndent){var A=b?Math.max(0,b.level):u.rows.maxGroupLevel+1,N=u.treeIndent*A+u._cellPadding;d?H.paddingRight=N+"px":H.paddingLeft=N+"px"}if(0!=h){var k=t.getCellData(n,r,!1),B=t.getCellData(n,r,!0);if(p==c.Cell&&r==u.columns.firstVisibleIndex&&b&&b.hasChildren&&!this._isEditingCell(u,n,r))B||(B=b.getGroupHeader()),s.innerHTML=this._getTreeIcon(b)+" "+B,H.textAlign="";else if(p==c.ColumnHeader&&M.currentSort&&u.showSort&&(v==u._getSortRowIndex()||M!=y))z+=" wj-sort-"+("+"==M.currentSort?"asc":"desc"),s.innerHTML=o.escapeHtml(B)+"&nbsp;"+this._getSortIcon(M);else if(p!=c.RowHeader||r!=u.rowHeaders.columns.length-1||B)if(p!=c.Cell||M.dataType!=o.DataType.Boolean||M.dataMap||b&&!o.isBoolean(k))if(p==c.Cell&&this._isEditingCell(u,n,r)){var F=M.inputType;if(M.inputType||(F=M.dataType!=o.DataType.Number||M.dataMap?"text":"tel"),!M.dataMap&&!M.mask){var K=t.getCellData(n,r,!1);if(o.isNumber(K)){var W=K.toString(),G=M.format;if(G&&K!=Math.round(K)){var q=W.match(/\.(\d+)/)[1].length;G=G.replace(/([a-z])(\d*)(.*)/gi,"$01"+q+"$3")}B=o.Globalize.formatNumber(K,G,!0)}}s.innerHTML='<input type="'+F+'" class="wj-grid-editor wj-form-control">';var U=s.children[0];U.value=B,U.required=M.getIsRequired(),M.maxLength&&(U.maxLength=M.maxLength),U.style.textAlign=M.getAlignment(),H.paddingTop=H.paddingBottom="0px",M.mask&&new o._MaskProvider(U,M.mask),u._edtHdl._edt=U}else p==c.Cell&&(w.isContentHtml||M.isContentHtml)?s.innerHTML=B:s.textContent=B||"";else{var Y=s.firstChild;Y instanceof HTMLInputElement&&"checkbox"==Y.type||(s.innerHTML='<input type="checkbox" class="wj-cell-check" tabindex="-1"/>',Y=s.firstChild),Y.checked=1==k,Y.indeterminate=null==k,Y.disabled=!u.canEditCell(n,r),Y.disabled&&(Y.style.cursor="default"),u.editRange&&u.editRange.contains(n,r)&&(u._edtHdl._edt=Y)}else{var J=u.editableCollectionView,X=J?J.currentEditItem:null;X&&w.dataItem==X?s.innerHTML='<span class="wj-glyph-pencil"></span>':w instanceof V&&(s.innerHTML='<span class="wj-glyph-asterisk"></span>')}if(p==c.Cell&&i()&&M.dataMap&&u.showDropDown&&0!=M.showDropDown&&u.canEditCell(n,r)){e._ddIcon||(e._ddIcon=o.createElement('<div role="button" class="'+e._WJC_DROPDOWN+'"><span class="wj-glyph-down"></span></div>'));var Z=e._ddIcon.cloneNode(!0);s.appendChild(Z)}}var Q=!1;switch(p){case c.RowHeader:Q=!b&&!R&&w.allowDragging&&0!=(u.allowDragging&I.Rows),o.setAttribute(s,"draggable",Q?"true":null);break;case c.ColumnHeader:Q=y.allowDragging&&0!=(u.allowDragging&I.Columns),o.setAttribute(s,"draggable",Q?"true":null)}s.className!=z&&(s.className=z);var $=s.style;for(var ee in H)$[ee]=H[ee];if(u._edtHdl._edt&&u._edtHdl._edt.parentElement==s){var te=u._root,ie=te.getBoundingClientRect(),oe=s.getBoundingClientRect(),ne=ie.top+te.clientHeight-oe.top,re=ie.left+te.clientWidth-oe.left;oe.height>ne&&(s.style.height=ne+"px"),oe.width>re&&(s.style.width=re+"px")}if(u.itemFormatter&&u.itemFormatter(t,n,r,s),u.formatItem.hasHandlers){var se=e._fmtRng;se?se.setRange(n,r,v,C):se=e._fmtRng=new g(n,r,v,C);var le=new a(t,se,s);u.onFormatItem(le)}},e.prototype.disposeCell=function(e){},e.prototype.getEditorValue=function(e){var t=e._edtHdl._edt;if(t instanceof HTMLInputElement){if("checkbox"==t.type)return t.checked;var i=t.maxLength;return o.isNumber(i)&&i>-1&&t.value.length>i?t.value.substr(0,i):t.value}return null},e.prototype._isEditingCell=function(e,t,i){return e.editRange&&e.editRange.contains(t,i)},e.prototype._getTreeIcon=function(t){var i="wj-glyph-"+(t.isCollapsed?"":"down-")+(t.grid.rightToLeft?"left":"right");return'<span role="button" class="'+e._WJC_COLLAPSE+" "+i+'"></span>'},e.prototype._getSortIcon=function(e){return'<span class="wj-glyph-'+("+"==e.currentSort?"up":"down")+'"></span>'},e._WJC_COLLAPSE="wj-elem-collapse",e._WJC_DROPDOWN="wj-elem-dropdown",e}(),e("CellFactory",d),g=function(){function e(e,t,i,o){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===i&&(i=e),void 0===o&&(o=t),this.setRange(e,t,i,o)}return e.prototype.setRange=function(e,t,i,n){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===i&&(i=e),void 0===n&&(n=t),this._row=o.asInt(e),this._col=o.asInt(t),this._row2=o.asInt(i),this._col2=o.asInt(n)},Object.defineProperty(e.prototype,"row",{get:function(){return this._row},set:function(e){this._row=o.asInt(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"col",{get:function(){return this._col},set:function(e){this._col=o.asInt(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"row2",{get:function(){return this._row2},set:function(e){this._row2=o.asInt(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"col2",{get:function(){return this._col2},set:function(e){this._col2=o.asInt(e)},enumerable:!0,configurable:!0}),e.prototype.clone=function(){return new e(this._row,this._col,this._row2,this._col2)},Object.defineProperty(e.prototype,"rowSpan",{get:function(){return Math.abs(this._row2-this._row)+1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columnSpan",{get:function(){return Math.abs(this._col2-this._col)+1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topRow",{get:function(){return Math.min(this._row,this._row2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomRow",{get:function(){return Math.max(this._row,this._row2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftCol",{get:function(){return Math.min(this._col,this._col2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightCol",{get:function(){return Math.max(this._col,this._col2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this._row>-1&&this._col>-1&&this._row2>-1&&this._col2>-1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSingleCell",{get:function(){return this._row==this._row2&&this._col==this._col2},enumerable:!0,configurable:!0}),e.prototype.contains=function(t,i){var n=o.tryCast(t,e);if(n)return n.topRow>=this.topRow&&n.bottomRow<=this.bottomRow&&n.leftCol>=this.leftCol&&n.rightCol<=this.rightCol;if(o.isInt(t)&&o.isInt(i))return t>=this.topRow&&t<=this.bottomRow&&i>=this.leftCol&&i<=this.rightCol;throw"contains expects a CellRange or row/column indices."},e.prototype.containsRow=function(e){return o.asInt(e)>=this.topRow&&e<=this.bottomRow},e.prototype.containsColumn=function(e){return o.asInt(e)>=this.leftCol&&e<=this.rightCol},e.prototype.intersects=function(e){return this.intersectsRow(e)&&this.intersectsColumn(e)},e.prototype.intersectsRow=function(e){return e&&!(this.bottomRow<e.topRow||this.topRow>e.bottomRow)},e.prototype.intersectsColumn=function(e){return e&&!(this.rightCol<e.leftCol||this.leftCol>e.rightCol)},e.prototype.getRenderSize=function(e){var t=new o.Size(0,0);if(this.isValid){for(var i=this.topRow;i<=this.bottomRow;i++)t.height+=e.rows[i].renderSize;for(var n=this.leftCol;n<=this.rightCol;n++)t.width+=e.columns[n].renderSize}return t},e.prototype.equals=function(t){return t instanceof e&&this._row==t._row&&this._col==t._col&&this._row2==t._row2&&this._col2==t._col2},e}(),e("CellRange",g),function(e){e[e.Visible=1]="Visible",e[e.AllowResizing=2]="AllowResizing",e[e.AllowDragging=4]="AllowDragging",e[e.AllowMerging=8]="AllowMerging",e[e.AllowSorting=16]="AllowSorting",e[e.AutoGenerated=32]="AutoGenerated",e[e.Collapsed=64]="Collapsed",e[e.ParentCollapsed=128]="ParentCollapsed",e[e.Selected=256]="Selected",e[e.ReadOnly=512]="ReadOnly",e[e.HtmlContent=1024]="HtmlContent",e[e.WordWrap=2048]="WordWrap",e[e.HasTemplate=4096]="HasTemplate",e[e.RowDefault=3]="RowDefault",e[e.ColumnDefault=23]="ColumnDefault"}(p||(p={})),e("RowColFlags",p),f=function(){function e(){this._list=null,this._pos=0,this._idx=-1,this._vidx=-1}return Object.defineProperty(e.prototype,"visible",{get:function(){return this._getFlag(p.Visible)},set:function(e){this._setFlag(p.Visible,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return!!this._getFlag(p.Visible)&&(!this._getFlag(p.ParentCollapsed)||this instanceof V)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pos",{get:function(){return this._list&&this._list._dirty&&this._list._update(),this._pos},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"index",{get:function(){return this._list&&this._list._dirty&&this._list._update(),this._idx},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"visibleIndex",{get:function(){return this._list&&this._list._dirty&&this._list._update(),this.isVisible?this._vidx:-1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this._sz},set:function(e){e!=this._sz&&(this._sz=o.asNumber(e,!0),this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderSize",{get:function(){if(!this.isVisible)return 0;var e=this._sz,t=this._list;return t&&((null==e||e<0)&&(e=Math.round(t.defaultSize)),null!=t.minSize&&e<t.minSize&&(e=t.minSize),null!=t.maxSize&&e>t.maxSize&&(e=t.maxSize)),null!=this._szMin&&e<this._szMin&&(e=this._szMin),null!=this._szMax&&e>this._szMax&&(e=this._szMax),Math.round(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allowResizing",{get:function(){return this._getFlag(p.AllowResizing)},set:function(e){this._setFlag(p.AllowResizing,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allowDragging",{get:function(){return this._getFlag(p.AllowDragging)},set:function(e){this._setFlag(p.AllowDragging,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allowMerging",{get:function(){return this._getFlag(p.AllowMerging)},set:function(e){this._setFlag(p.AllowMerging,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSelected",{get:function(){return this._getFlag(p.Selected)},set:function(e){if(this._setFlag(p.Selected,e,!0)){var t=this.grid;t&&t.refreshCells(!1,!0,!0)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isReadOnly",{get:function(){return this._getFlag(p.ReadOnly)},set:function(e){this._setFlag(p.ReadOnly,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isContentHtml",{get:function(){return this._getFlag(p.HtmlContent)},set:function(e){this.isContentHtml!=e&&(this._setFlag(p.HtmlContent,e),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wordWrap",{get:function(){return this._getFlag(p.WordWrap)},set:function(e){this._setFlag(p.WordWrap,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cssClass",{get:function(){return this._cssClass},set:function(e){e!=this._cssClass&&(this._cssClass=o.asString(e),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){return this._list?this._list._g:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"collectionView",{get:function(){return this.grid?this.grid.collectionView:null},enumerable:!0,configurable:!0}),e.prototype.onPropertyChanged=function(){this._list&&(this._list._dirty=!0,this.grid.invalidate())},e.prototype._getFlag=function(e){return 0!=(this._f&e)},e.prototype._setFlag=function(e,t,i){return t!=this._getFlag(e)&&(this._f=t?this._f|e:this._f&~e,i||this.onPropertyChanged(),!0)},e}(),e("RowCol",f),_=function(e){function t(i){var n=e.call(this)||this;return n._f=p.ColumnDefault,n._hash=t._ctr.toString(36),t._ctr++,i&&o.copy(n,i),n}return K(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataType",{get:function(){return this._type},set:function(e){this._type!=e&&(this._type=o.asEnum(e,o.DataType),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRequired",{get:function(){return this._required},set:function(e){this._required=o.asBoolean(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showDropDown",{get:function(){return this._showDropDown},set:function(e){e!=this._showDropDown&&(this._showDropDown=o.asBoolean(e,!0),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dropDownCssClass",{get:function(){return this._ddCssClass},set:function(e){this._ddCssClass=o.asString(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputType",{get:function(){return this._inpType},set:function(e){this._inpType=o.asString(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mask",{get:function(){return this._mask},set:function(e){this._mask=o.asString(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxLength",{get:function(){return this._maxLen},set:function(e){this._maxLen=o.asNumber(e,!0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"binding",{get:function(){return this._binding?this._binding.path:null},set:function(e){if(e!=this.binding){var t=o.asString(e);if(this._binding=t?new o.Binding(t):null,!this._type&&this.grid&&this._binding){var i=this.grid.collectionView;if(i&&i.sourceCollection&&i.sourceCollection.length){var n=i.sourceCollection[0];this._type=o.getType(this._binding.getValue(n))}}this.onPropertyChanged()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sortMemberPath",{get:function(){return this._bindingSort?this._bindingSort.path:null},set:function(e){if(e!=this.sortMemberPath){var t=o.asString(e);this._bindingSort=t?new o.Binding(t):null,this.onPropertyChanged()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return null!=this._szStar?this._szStar:this.size},set:function(e){null!=t._parseStarSize(e)?(this._szStar=e,this.onPropertyChanged()):(this._szStar=null,this.size=o.asNumber(e,!0))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minWidth",{get:function(){return this._szMin},set:function(e){e!=this._szMin&&(this._szMin=o.asNumber(e,!0,!0),this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxWidth",{get:function(){return this._szMax},set:function(e){e!=this._szMax&&(this._szMax=o.asNumber(e,!0,!0),this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"quickAutoSize",{get:function(){return this._quickSize},set:function(e){this._quickSize=o.asBoolean(e,!0)},enumerable:!0,configurable:!0}),t.prototype._getQuickAutoSize=function(){return!!this.grid._getQuickAutoSize()&&(o.isBoolean(this._quickSize)?this._quickSize:!this.isContentHtml&&!this._getFlag(p.HasTemplate))},Object.defineProperty(t.prototype,"renderWidth",{get:function(){return this.renderSize},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"align",{get:function(){return this._align},set:function(e){this._align!=e&&(this._align=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),t.prototype.getAlignment=function(){var e=this._align;if(null==e&&(e="",!this._map))switch(this._type){case o.DataType.Boolean:e="center";break;case o.DataType.Number:e="right"}return e},t.prototype.getIsRequired=function(){return null!=this._required?this._required:this.dataType!=o.DataType.String||(null!=this.dataMap||this._mask&&this._mask.length>0)},Object.defineProperty(t.prototype,"header",{get:function(){return this._hdr?this._hdr:this.binding},set:function(e){this._hdr!=e&&(this._hdr=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map!=e&&(this._map&&this._map.mapChanged.removeHandler(this.onPropertyChanged,this),o.isArray(e)&&(e=new S(e,null,null)),this._map=o.asType(e,S,!0),this._map&&this._map.mapChanged.addHandler(this.onPropertyChanged,this),this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"format",{get:function(){return this._fmt},set:function(e){this._fmt!=e&&(this._fmt=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowSorting",{get:function(){return this._getFlag(p.AllowSorting)},set:function(e){this._setFlag(p.AllowSorting,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentSort",{get:function(){if(this.grid&&this.grid.collectionView&&this.grid.collectionView.canSort)for(var e=this.grid.collectionView.sortDescriptions,t=0;t<e.length;t++)if(e[t].property==this._getBindingSort())return e[t].ascending?"+":"-";return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aggregate",{get:function(){return null!=this._agg?this._agg:o.Aggregate.None},set:function(e){e!=this._agg&&(this._agg=o.asEnum(e,o.Aggregate),this.onPropertyChanged())},enumerable:!0,configurable:!0}),t.prototype._getBindingSort=function(){return this.sortMemberPath?this.sortMemberPath:this.binding?this.binding:null},t._parseStarSize=function(e){if(o.isString(e)&&e.length>0&&"*"==e[e.length-1]){var t=1==e.length?1:1*e.substr(0,e.length-1);if(t>0&&!isNaN(t))return t}return null},t._ctr=0,t}(f),e("Column",_),w=function(e){function t(t){var i=e.call(this)||this;return i._f=p.ColumnDefault,i._data=t,i}return K(t,e),Object.defineProperty(t.prototype,"dataItem",{get:function(){return this._data},set:function(e){this._data=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.size},set:function(e){this.size=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderHeight",{get:function(){return this.renderSize},enumerable:!0,configurable:!0}),t}(f),e("Row",w),m=function(e){function t(){var t=e.call(this)||this;return t._level=-1,t.isReadOnly=!0,t}return K(t,e),Object.defineProperty(t.prototype,"level",{get:function(){return this._level},set:function(e){o.asInt(e),e!=this._level&&(this._level=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasChildren",{get:function(){if(null!=this.grid&&null!=this._list){this._list._update();var e=this.index<this._list.length-1?this._list[this.index+1]:null,i=o.tryCast(e,t),n=o.tryCast(e,V);return null!=e&&null==n&&(null==i||i.level>this.level)}return!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isCollapsed",{get:function(){return this._getFlag(p.Collapsed)},set:function(e){o.asBoolean(e),e!=this.isCollapsed&&null!=this._list&&this._setCollapsed(e)},enumerable:!0,configurable:!0}),t.prototype.getGroupHeader=function(){var e=this.grid,t=e.groupHeaderFormat?e.groupHeaderFormat:o.culture.FlexGrid.groupHeaderFormat,i=o.tryCast(this.dataItem,o.CollectionViewGroup);if(i&&t){var n=i.groupDescription.propertyName,r=i.name,s=e.getColumn(n),l=this.isContentHtml;s&&(l=l||s.isContentHtml,s.header&&(n=s.header),s.dataMap?r=s.dataMap.getDisplayValue(r):s.format&&(r=o.Globalize.format(r,s.format)));var a=i.getAggregate(o.Aggregate.CntAll,null,e.collectionView);return o.format(t,{name:o.escapeHtml(n),value:l?r:o.escapeHtml(r),level:i.level,count:a})}return""},t.prototype._setCollapsed=function(e){var i,n=this,r=this.grid,s=r.rows,a=this.getCellRange(),h=new l(r.cells,new g(this.index,-1));r.onGroupCollapsedChanging(h),h.cancel||(r.deferUpdate(function(){n._setFlag(p.Collapsed,e);for(var r=a.topRow+1;r<=a.bottomRow&&r>-1&&r<s.length;r++)s[r]._setFlag(p.ParentCollapsed,e),null!=(i=o.tryCast(s[r],t))&&i.isCollapsed&&(r=i.getCellRange().bottomRow)}),r.onGroupCollapsedChanged(h))},t.prototype.getCellRange=function(){for(var e=this._list,i=this.index,n=e.length-1,r=i+1;r<=n;r++){var s=o.tryCast(e[r],t);if(null!=s&&s.level<=this.level){n=r-1;break}}return new g(i,0,n,this.grid.columns.length-1)},t}(w),e("GroupRow",m),y=function(e){function t(t,i){var n=e.call(this)||this;return n._frozen=0,n._vlen=0,n._szDef=28,n._szTot=0,n._dirty=!1,n._g=o.asType(t,s),n._szDef=o.asNumber(i,!1,!0),n}return K(t,e),Object.defineProperty(t.prototype,"defaultSize",{get:function(){return this._szDef},set:function(e){this._szDef!=e&&(this._szDef=o.asNumber(e,!1,!0),this._dirty=!0,this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"frozen",{get:function(){return this._frozen},set:function(e){e!=this._frozen&&(this._frozen=o.asNumber(e,!1,!0),this._dirty=!0,this._g.invalidate())},enumerable:!0,configurable:!0}),t.prototype.isFrozen=function(e){return e<this.frozen},Object.defineProperty(t.prototype,"minSize",{get:function(){return this._szMin},set:function(e){e!=this._szMin&&(this._szMin=o.asNumber(e,!0,!0),this._dirty=!0,this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxSize",{get:function(){return this._szMax},set:function(e){e!=this._szMax&&(this._szMax=o.asNumber(e,!0,!0),this._dirty=!0,this._g.invalidate())},enumerable:!0,configurable:!0}),t.prototype.getTotalSize=function(){return this._dirty&&this._update(),this._szTot},Object.defineProperty(t.prototype,"visibleLength",{get:function(){return this._dirty&&this._update(),this._vlen},enumerable:!0,configurable:!0}),t.prototype.getItemAt=function(e){if(this._dirty&&this._update(),e<=0&&this.length>0)return 0;e=Math.round(e);for(var t,i,o=this.length,n=0,r=o-1;n<=r;)if(t=n+r>>>1,(i=this[t])._pos>e&&t>0)r=t-1;else{if(!(i._pos+i.renderSize<=e&&t<o-1)){for(;t>0&&!this[t].visible;)t--;for(;t<o-1&&!this[t].visible;)t++;return t}n=t+1}return r},t.prototype.getNextCell=function(e,t,i){var o;switch(t){case H.Next:for(o=e+1;o<this.length;o++)if(this[o].renderSize>0)return o;break;case H.Prev:for(o=e-1;o>=0;o--)if(this[o].renderSize>0)return o;break;case H.End:for(o=this.length-1;o>=0;o--)if(this[o].renderSize>0)return o;break;case H.Home:for(o=0;o<this.length;o++)if(this[o].renderSize>0)return o;break;case H.NextPage:return(o=this.getItemAt(this[e].pos+i))<0?this.getNextCell(e,H.End,i):o==e&&o<this.length-1?o+1:o;case H.PrevPage:return(o=this.getItemAt(this[e].pos-i))<0?this.getNextCell(e,H.Home,i):o==e&&o>0?o-1:o}return e},t.prototype.canMoveElement=function(e,t){if(t==e)return!1;if(e<0||e>=this.length||t>=this.length)return!1;t<0&&(t=this.length-1);for(var i=Math.min(e,t),o=Math.max(e,t),n=i;n<=o;n++)if(!this[n].allowDragging)return!1;return!(this[t]instanceof V)},t.prototype.moveElement=function(e,t){if(this.canMoveElement(e,t)){var i=this[e];this.removeAt(e),t<0&&(t=this.length),this.insert(t,i)}},t.prototype.onCollectionChanged=function(t){void 0===t&&(t=o.NotifyCollectionChangedEventArgs.reset),this._dirty=!0,this._g.invalidate(),e.prototype.onCollectionChanged.call(this,t)},t.prototype.push=function(t){return t._list=this,e.prototype.push.call(this,t)},t.prototype.splice=function(t,i,o){return o&&(o._list=this),e.prototype.splice.call(this,t,i,o)},t.prototype.beginUpdate=function(){this._update(),e.prototype.beginUpdate.call(this)},t.prototype._update=function(){if(this._dirty&&!this.isUpdating){this._dirty=!1;for(var e=0,t=0,i=void 0,o=void 0,n=0;n<this.length;n++)(o=this[n])._idx=n,o._vidx=e,o._list=this,o._pos=t,(i=o.renderSize)>0&&(t+=i,e++);return this._vlen=e,this._szTot=t,!0}return!1},t}(o.ObservableArray),e("RowColCollection",y),v=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._firstVisible=-1,t}return K(t,e),t.prototype.getColumn=function(e){var t=o.isNumber(e)?e:this.indexOf(e);return t>-1?this[t]:null},t.prototype.indexOf=function(t){if(t instanceof _)return e.prototype.indexOf.call(this,t);for(i=0;i<this.length;i++)if(this[i].name==t)return i;for(var i=0;i<this.length;i++)if(this[i].binding==t)return i;return-1},Object.defineProperty(t.prototype,"firstVisibleIndex",{get:function(){return this._dirty&&this._update(),this._firstVisible},enumerable:!0,configurable:!0}),t.prototype._update=function(){if(e.prototype._update.call(this)){this._firstVisible=-1;for(var t=0;t<this.length;t++)if(this[t].visible){this._firstVisible=t;break}return!0}return!1},t.prototype._updateStarSizes=function(e){for(var t,i=0,o=0;o<this.length;o++)(r=this[o]).isVisible&&(r._szStar?(i+=_._parseStarSize(r._szStar),t=r):e-=r.renderWidth);if(t){for(var n=e,o=0;o<this.length;o++){var r=this[o];r.isVisible&&r._szStar&&(r==t&&n>0?r._sz=n:(r._sz=Math.max(0,Math.round(_._parseStarSize(r._szStar)/i*e)),n-=r.renderWidth))}return this._dirty=!0,this._update(),!0}return!1},t}(y),e("ColumnCollection",v),C=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._maxLevel=-1,t}return K(t,e),Object.defineProperty(t.prototype,"maxGroupLevel",{get:function(){return this._dirty&&this._update(),this._maxLevel},enumerable:!0,configurable:!0}),t.prototype._update=function(){if(e.prototype._update.call(this)){this._maxLevel=-1;for(var t=0;t<this.length;t++){var i=o.tryCast(this[t],m);i&&i.level>this._maxLevel&&(this._maxLevel=i.level)}return!0}return!1},t}(y),e("RowCollection",C),b=function(){function e(t,i){this._row=-1,this._col=-1,this._edge=0;var n;if(t instanceof Element)(D=(T=o.closest(t,".wj-cell"))?T[u._INDEX_KEY]:null)&&(this._row=D.row,this._col=D.col,this._rng=D.rng,this._p=D.panel,this._g=D.panel.grid);else{if(t instanceof s)n=this._g=t;else{if(!(t instanceof u))throw"First parameter should be a FlexGrid or GridPanel.";this._p=t,n=this._g=this._p.grid}var l;i instanceof MouseEvent&&(l=i,"mousedown"==i.type&&(n._rcBounds=null)),i=o.mouseToPage(i),this._pt=i.clone();var a=n.controlRect,h=n._szClient,d=n.topLeftCells,g=n._eTL,p=n.headersVisibility,f=r,_=p&f.Row?d.columns.getTotalSize():0,w=p&f.Column?d.rows.getTotalSize():0,m=p&f.Column?w+g.offsetTop:0,y=n._eBL,v=y.offsetHeight;if(i.x-=a.left,i.y-=a.top,this._g.rightToLeft&&(i.x=a.width-i.x),!this._p&&i.x>=0&&i.y>=g.offsetTop&&h&&i.x<=h.width+_&&i.y<=h.height+m&&(i.y<m?this._p=i.x<_?n.topLeftCells:n.columnHeaders:i.y<y.offsetTop?this._p=i.x<_?n.rowHeaders:n.cells:this._p=i.x<_?n.bottomLeftCells:n.columnFooters),null!=this._p){var C=this._p.rows,b=this._p.columns,R=this._p.cellType,E=c,S=this._p._getFrozenPos(),z=R==E.TopLeft||R==E.ColumnHeader?w:R==E.BottomLeft||R==E.ColumnFooter?v:C.getTotalSize(),x=R==E.TopLeft||R==E.BottomLeft||R==E.RowHeader?_:b.getTotalSize();R==E.RowHeader||R==E.Cell?(i.y-=w,(i.y>S.y||S.y<=0)&&(i.y-=n._ptScrl.y,i.y+=this._p._getOffsetY())):R!=E.BottomLeft&&R!=E.ColumnFooter||(i.y-=y.offsetTop),R!=E.ColumnHeader&&R!=E.Cell&&R!=E.ColumnFooter||(i.x-=_,(i.x>S.x||S.x<=0)&&(i.x-=n._ptScrl.x)),R!=E.ColumnHeader&&R!=E.TopLeft||(i.y-=m-w),this._edge=0;var H=e._SZEDGE[this._g.isTouching?1:0];if(this._g.isTouching&&(H=e._SZEDGE[1],i.x-=H/2),this._row=i.y>z?-1:C.getItemAt(i.y),this._col=i.x>x?-1:b.getItemAt(i.x),this._row<0||this._col<0)return void(this._p=null);if(this._col>-1){var P=b[this._col];i.x-P.pos<=H&&(this._edge|=1),P.pos+P.renderSize-i.x<=H&&(this._edge|=4)}if(this._row>-1){var M=C[this._row];i.y-M.pos<=H&&(this._edge|=2),M.pos+M.renderSize-i.y<=H&&(this._edge|=8)}}if(!(8&this._edge)&&l instanceof MouseEvent){var T=o.closest(l.target,".wj-cell"),D=T?T[u._INDEX_KEY]:null;D&&!D.rng&&D.panel==this._p&&this._row!=D.row&&(this._row=D.row)}}}return Object.defineProperty(e.prototype,"point",{get:function(){return this._pt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cellType",{get:function(){return this._p?this._p.cellType:c.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"panel",{get:function(){return this._p},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){return this._p?this._p.grid:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"row",{get:function(){return this._row},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"col",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"range",{get:function(){return this._rng||(this._rng=new g(this._row,this._col)),this._rng},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"edgeLeft",{get:function(){return 0!=(1&this._edge)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"edgeTop",{get:function(){return 0!=(2&this._edge)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"edgeRight",{get:function(){return 0!=(4&this._edge)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"edgeBottom",{get:function(){return 0!=(8&this._edge)},enumerable:!0,configurable:!0}),e._SZEDGE=[5,30],e}(),e("HitTestInfo",b),function(e){e[e.None=0]="None",e[e.Cells=1]="Cells",e[e.ColumnHeaders=2]="ColumnHeaders",e[e.RowHeaders=4]="RowHeaders",e[e.AllHeaders=6]="AllHeaders",e[e.All=7]="All"}(R||(R={})),e("AllowMerging",R),E=function(){function e(e){this._g=e}return e.prototype.getMergedRange=function(e,t,i,n){void 0===n&&(n=!0);var r,s,l=e.cellType,a=e.columns,h=e.rows,u=h[t],d=a[i];if(u instanceof V)return null;if(u instanceof m&&u.dataItem instanceof o.CollectionViewGroup){if(r=new g(t,i),d.aggregate==o.Aggregate.None){for(;r.col>0&&a[r.col-1].aggregate==o.Aggregate.None&&r.col!=a.frozen;)r.col--;for(;r.col2<a.length-1&&a[r.col2+1].aggregate==o.Aggregate.None&&r.col2+1!=a.frozen;)r.col2++}for(;r.col<i&&!a[r.col].visible;)r.col++;return r.isSingleCell?null:r}var p=!1;switch(this._g.allowMerging){case R.None:p=!0;break;case R.Cells:p=l!=c.Cell;break;case R.ColumnHeaders:p=l!=c.ColumnHeader&&l!=c.TopLeft;break;case R.RowHeaders:p=l!=c.RowHeader&&l!=c.TopLeft;break;case R.AllHeaders:p=l==c.Cell}if(p)return null;if(a[i].allowMerging){r=new g(t,i);var f=0,_=h.length-1;t>=h.frozen?!n||l!=c.Cell&&l!=c.RowHeader||(f=(s=e._getViewRange()).topRow,_=s.bottomRow):_=h.frozen-1;for(var w=t-1;w>=f&&this._mergeCell(e,w,i,t,i);w--)r.row=w;for(var y=t+1;y<=_&&this._mergeCell(e,t,i,y,i);y++)r.row2=y;for(;r.row<t&&!h[r.row].visible;)r.row++;if(!r.isSingleCell)return r}if(h[t].allowMerging){r=new g(t,i);var v=0,C=a.length-1;i>=a.frozen?!n||l!=c.Cell&&l!=c.ColumnHeader||(v=(s=e._getViewRange()).leftCol,C=s.rightCol):C=a.frozen-1;for(var b=i-1;b>=v&&this._mergeCell(e,t,b,t,i);b--)r.col=b;for(var E=i+1;E<=C&&this._mergeCell(e,t,i,t,E);E++)r.col2=E;for(;r.col<i&&!a[r.col].visible;)r.col++;if(!r.isSingleCell)return r}return null},e.prototype._mergeCell=function(e,t,i,o,n){var r=e.rows[t],s=e.rows[o];if(r instanceof m||r instanceof V||s instanceof m||s instanceof V)return!1;if(t!=o&&e.rows.isFrozen(t)!=e.rows.isFrozen(o))return!1;if(i!=n&&e.columns.isFrozen(i)!=e.columns.isFrozen(n))return!1;if(t!=o){if(i>0&&(r.allowMerging&&this._mergeCell(e,t,i-1,t,i)||s.allowMerging&&this._mergeCell(e,o,i-1,o,i)))return!1;if(n<e.columns.length-1&&(r.allowMerging&&this._mergeCell(e,t,n,t,n+1)||s.allowMerging&&this._mergeCell(e,o,n,o,n+1)))return!1}return e.getCellData(t,i,!0)==e.getCellData(o,n,!0)},e}(),e("MergeManager",E),S=function(){function e(e,t,i){if(this.mapChanged=new o.Event,o.isArray(e)&&!t&&!i){for(var n=[],r=0;r<e.length;r++)n.push({value:e[r]});e=n,t=i="value"}this._cv=o.asCollectionView(e),this._keyPath=o.asString(t,!1),this._displayPath=o.asString(i,!1),this._cv.collectionChanged.addHandler(this.onMapChanged,this)}return Object.defineProperty(e.prototype,"sortByDisplayValues",{get:function(){return 1!=this._sortByKey},set:function(e){this._sortByKey=!o.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"collectionView",{get:function(){return this._cv},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectedValuePath",{get:function(){return this._keyPath},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayMemberPath",{get:function(){return this._displayPath},enumerable:!0,configurable:!0}),e.prototype.getKeyValue=function(e){var t=this._indexOf(e,this._displayPath,!1);return t>-1?this._cv.sourceCollection[t][this._keyPath]:null},e.prototype.getDisplayValue=function(e){if(!this._hash){this._hash={};var t=this._cv.sourceCollection;if(t&&this._keyPath&&this._displayPath)for(var i=t.length-1;i>=0;i--){var o=t[i],n=o[this._keyPath],r=o[this._displayPath];this._hash[n]=r}}var s=this._hash[e];return null!=s?s:e},e.prototype.getDisplayValues=function(e){var t=[];if(this._cv&&this._displayPath)for(var i=this._cv.items,o=0;o<i.length;o++)t.push(i[o][this._displayPath]);return t},e.prototype.getKeyValues=function(){var e=[];if(this._cv&&this._keyPath)for(var t=this._cv.items,i=0;i<t.length;i++)e.push(t[i][this._keyPath]);return e},Object.defineProperty(e.prototype,"isEditable",{get:function(){return this._editable},set:function(e){this._editable=o.asBoolean(e)},enumerable:!0,configurable:!0}),e.prototype.onMapChanged=function(e){this._hash=null,this.mapChanged.raise(this,e)},e.prototype._indexOf=function(e,t,i){var o=-1,n=-1;if(this._cv&&t)for(var r=null!=e?e.toString():"",s=i?r:r.toLowerCase(),l=this._cv.sourceCollection,a=0;a<l.length;a++){var h=l[a],c=h[t];if(c==e?o=a:i||c.length!=s.length||c.toLowerCase()!=s?null!=c&&c.toString()==r&&(o=a):o=a,o==a){if(!this._cv.filter||this._cv.filter(h))return o;n<0&&(n=o)}}return n},e}(),e("DataMap",S),function(e){e[e.None=0]="None",e[e.Cell=1]="Cell",e[e.CellRange=2]="CellRange",e[e.Row=3]="Row",e[e.RowRange=4]="RowRange",e[e.ListBox=5]="ListBox"}(z||(z={})),e("SelectionMode",z),function(e){e[e.None=0]="None",e[e.Selected=1]="Selected",e[e.Cursor=2]="Cursor"}(x||(x={})),e("SelectedState",x),function(e){e[e.None=0]="None",e[e.Next=1]="Next",e[e.Prev=2]="Prev",e[e.NextPage=3]="NextPage",e[e.PrevPage=4]="PrevPage",e[e.Home=5]="Home",e[e.End=6]="End",e[e.NextCell=7]="NextCell",e[e.PrevCell=8]="PrevCell"}(H||(H={})),e("SelMove",H),P=function(){function e(e){this._sel=new g(0,0),this._mode=z.CellRange,this._g=e}return Object.defineProperty(e.prototype,"selectionMode",{get:function(){return this._mode},set:function(e){if(e!=this._mode){var t=z;if(e==t.ListBox||this._mode==t.ListBox)for(var i=this._g.rows,o=0;o<i.length;o++){var n=i[o],r=e==z.ListBox&&this._sel.containsRow(o);n._setFlag(p.Selected,r,!0)}switch(e){case t.None:this._sel.setRange(-1,-1);break;case t.Cell:this._sel.row2=this._sel.row,this._sel.col2=this._sel.col;break;case t.Row:this._sel.row2=this._sel.row}this._mode=e,this._g.invalidate()}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){return this._sel},set:function(e){this.select(e)},enumerable:!0,configurable:!0}),e.prototype.select=function(e,t){void 0===t&&(t=!0),o.isNumber(e)&&o.isNumber(t)&&(e=new g(e,t),t=!0),e=o.asType(e,g);var i=this._g,n=this._sel,r=e,s=!1,a=z;switch(i.selectionMode){case a.Cell:e.row2=e.row,e.col2=e.col;break;case a.Row:e.row2=e.row;break;case a.ListBox:s=!0}var h=r.equals(n);if(s&&r.row>-1&&!i.rows[r.row].isSelected&&(h=!1),h)t&&i.scrollIntoView(r.row,r.col);else{var c=new l(i.cells,r);if(i.onSelectionChanging(c)){if(s&&(r.row!=n.row||r.rowSpan>1||n.rowSpan>1)){for(var u=0;u<i.rows.length;u++)i.rows[u]._setFlag(p.Selected,r.containsRow(u),!0);i.refreshCells(!1,!0,!0)}if(r.row=Math.min(r.row,i.rows.length-1),r.row2=Math.min(r.row2,i.rows.length-1),this._sel=r,i.refreshCells(!1,!0,!0),t&&i.scrollIntoView(r.row,r.col),i.collectionView){var d=i._getCvIndex(r.row);i.collectionView.moveCurrentToPosition(d)}i.onSelectionChanged(c)}}},e.prototype.moveSelection=function(e,t,i){var o,n,r=this._g,s=r.rows,l=r.columns,a=this._getReferenceCell(e,t,i),h=Math.max(0,r._szClient.height-r.columnHeaders.height);if(t==H.NextCell)n=l.getNextCell(a.col,H.Next,h),o=a.row,n==a.col&&(o=s.getNextCell(o,H.Next,h))>a.row&&(n=l.getNextCell(0,H.Next,h),n=l.getNextCell(n,H.Prev,h)),r.select(o,n);else if(t==H.PrevCell)n=l.getNextCell(a.col,H.Prev,h),o=a.row,n==a.col&&(o=s.getNextCell(o,H.Prev,h))<a.row&&(n=l.getNextCell(l.length-1,H.Prev,h),n=l.getNextCell(n,H.Next,h)),r.select(o,n);else if(o=s.getNextCell(a.row,e,h),n=l.getNextCell(a.col,t,h),i){var c=r._selHdl._sel;r.select(new g(o,n,c.row2,c.col2))}else r.select(o,n)},e.prototype._getReferenceCell=function(e,t,i){var o=this._g,n=o._selHdl._sel,r=o.getMergedRange(o.cells,n.row,n.col);if(!r||r.isSingleCell)return n;switch(r=r.clone(),e){case H.Next:case H.NextCell:r.row=r.bottomRow;break;case H.None:r.row=n.row}switch(t){case H.Next:case H.NextCell:r.col=r.rightCol;break;case H.None:r.col=n.col}return r},e.prototype._adjustSelection=function(e){switch(this._mode){case z.Cell:return new g(e.row,e.col,e.row,e.col);case z.Row:return new g(e.row,0,e.row,this._g.columns.length-1);case z.RowRange:case z.ListBox:return new g(e.row,0,e.row2,this._g.columns.length-1)}return e},e}(),e("_SelectionHandler",P),function(e){e[e.None=0]="None",e[e.MoveDown=1]="MoveDown",e[e.MoveAcross=2]="MoveAcross",e[e.Cycle=3]="Cycle",e[e.CycleOut=4]="CycleOut"}(M||(M={})),e("KeyAction",M),T=function(){function e(e){this._kaTab=M.None,this._kaEnter=M.MoveDown,this._g=e;var t=e.hostElement;e.addEventListener(t,"keypress",this._keypress.bind(this)),e.addEventListener(t,"keydown",this._keydown.bind(this))}return e.prototype._keydown=function(e){var t=this._g,i=t.selection,n=e.ctrlKey||e.metaKey,r=e.shiftKey,s=(e.target,!0);if(this._altDown=!1,!t._wantsInput(e.target)&&t.isRangeValid(i)&&!e.defaultPrevented&&(!t.activeEditor||!t._edtHdl._keydown(e))){var a=o.tryCast(t.rows[i.row],m),h=t.editableCollectionView,c=e.keyCode;if(t.autoClipboard){if(n&&(67==c||45==c)){var u=new l(t.cells,i);if(t.onCopying(u)){var d=t.getClipString()+"\r\n";o.Clipboard.copy(d),t.onCopied(u)}return void e.stopPropagation()}if(n&&86==c||r&&45==c){if(!t.isReadOnly){var p=new l(t.cells,i);t.onPasting(p)&&o.Clipboard.paste(function(e){t.setClipString(e),t.onPasted(p)})}return void e.stopPropagation()}}if(t.rightToLeft)switch(c){case o.Key.Left:c=o.Key.Right;break;case o.Key.Right:c=o.Key.Left}var f=H,_=z;switch(c){case o.Key.Space:if(r&&i.isValid)switch(t.selectionMode){case _.CellRange:case _.Row:case _.RowRange:case _.ListBox:t.select(new g(i.row,0,i.row,t.columns.length-1))}else if(n&&i.isValid)switch(t.selectionMode){case _.CellRange:t.select(new g(0,i.col,t.rows.length-1,i.col))}else(s=this._startEditing(!0,e))&&setTimeout(function(){var e=t.activeEditor;e&&(e.disabled||e.readOnly?t.finishEditing():"checkbox"==e.type?(e.checked=!e.checked,t.finishEditing()):o.setSelectionRange(e,e.value.length))});break;case 65:if(n)switch(t.selectionMode){case _.CellRange:case _.Row:case _.RowRange:case _.ListBox:t.select(new g(0,0,t.rows.length-1,t.columns.length-1))}else s=!1;break;case o.Key.Left:n||e.altKey?s=!1:i.isValid&&0==i.col&&null!=a&&!a.isCollapsed&&a.hasChildren?a.isCollapsed=!0:this._moveSel(f.None,n?f.Home:f.Prev,r);break;case o.Key.Right:n||e.altKey?s=!1:i.isValid&&0==i.col&&null!=a&&a.isCollapsed?a.isCollapsed=!1:this._moveSel(f.None,n?f.End:f.Next,r);break;case o.Key.Up:n?s=!1:(this._altDown=e.altKey,e.altKey?s=t._edtHdl._toggleListBox(e):this._moveSel(f.Prev,f.None,r));break;case o.Key.Down:n?s=!1:(this._altDown=e.altKey,e.altKey?s=t._edtHdl._toggleListBox(e):this._moveSel(f.Next,f.None,r));break;case o.Key.PageUp:this._altDown=e.altKey,this._moveSel(e.altKey?f.Home:f.PrevPage,f.None,r);break;case o.Key.PageDown:this._altDown=e.altKey,this._moveSel(e.altKey?f.End:f.NextPage,f.None,r);break;case o.Key.Home:this._moveSel(n?f.Home:f.None,f.Home,r);break;case o.Key.End:this._moveSel(n?f.End:f.None,f.End,r);break;case o.Key.Tab:s=this._performKeyAction(t.keyActionTab,r);break;case o.Key.Enter:s=this._performKeyAction(t.keyActionEnter,r),!r&&h&&null!=h.currentEditItem&&t._edtHdl._commitRowEdits();break;case o.Key.Escape:if(s=!1,h&&(h.currentAddItem||h.currentEditItem)){var w=new l(t.cells,t.selection);w.cancel=!0,t.onRowEditEnding(w),h.currentAddItem&&h.cancelNew(),h.currentEditItem&&h.cancelEdit(),t.onRowEditEnded(w),s=!0}t._mouseHdl.resetMouseState();break;case o.Key.Delete:case o.Key.Back:s=this._deleteSel(e);break;case o.Key.F2:s=this._startEditing(!0,e);break;case o.Key.F4:s=t._edtHdl._toggleListBox(e);break;default:s=!1}s&&(t.containsFocus()||t.focus(),e.preventDefault(),e.stopPropagation())}},e.prototype._performKeyAction=function(e,t){var i=M,o=H;switch(e){case i.MoveDown:return this._moveSel(t?o.Prev:o.Next,o.None,!1),!0;case i.MoveAcross:return this._moveSel(o.None,t?o.Prev:o.Next,!1),!0;case i.Cycle:return this._moveSel(o.None,t?o.PrevCell:o.NextCell,!1),!0;case i.CycleOut:var n=this._g.selection;return this._moveSel(o.None,t?o.PrevCell:o.NextCell,!1),!n.equals(this._g.selection)}return!1},e.prototype._keypress=function(e){var t=this._g;if(!t._wantsInput(e.target)&&!e.defaultPrevented)if(this._altDown)e.preventDefault();else if(t.activeEditor)t._edtHdl._keypress(e);else if(e.charCode>o.Key.Space&&this._startEditing(!1,e)&&t.activeEditor){var i=o.getActiveElement();if(i instanceof HTMLInputElement&&"checkbox"!=i.type){var n=t._selHdl.selection,r=t.getCellData(n.row,n.col,!0),s=t.getCellData(n.row,n.col,!1);i.value=String.fromCharCode(e.charCode),o.isNumber(s)&&r.indexOf("%")>-1&&(i.value+="%"),o.setSelectionRange(i,1),i.dispatchEvent(t._edtHdl._evtInput),t._edtHdl._keypress(e),e.preventDefault()}}},e.prototype._moveSel=function(e,t,i){this._g.selectionMode!=z.None&&this._g._selHdl.moveSelection(e,t,i)},e.prototype._deleteSel=function(e){var t=this._g,i=t.editableCollectionView,o=t.selection,n=t.rows,r=[],s=new g,l=new h(t.cells,s,e),a=z;if(t.allowDelete&&!t.isReadOnly&&(null==i||i.canRemove&&!i.isAddingNew&&!i.isEditingItem))switch(t.selectionMode){case a.CellRange:if(0==o.leftCol&&o.rightCol==t.columns.length-1)for(c=o.topRow;c>-1&&c<=o.bottomRow;c++)r.push(n[c]);break;case a.ListBox:for(c=0;c<n.length;c++)n[c].isSelected&&r.push(n[c]);break;case a.Row:o.topRow>-1&&r.push(n[o.topRow]);break;case a.RowRange:for(var c=o.topRow;c>-1&&c<=o.bottomRow;c++)r.push(n[c])}if(r.length>0){if(t.deferUpdate(function(){i&&i.beginUpdate();for(var e=r.length-1;e>=0;e--){var o=r[e];s.setRange(o.index,-1),t.onDeletingRow(l)&&(i&&o.dataItem?i.remove(o.dataItem):t.rows.removeAt(o.index),t.onDeletedRow(l))}i&&i.endUpdate()}),t.selectionMode==a.ListBox){var u=t.selection.row;u>-1&&u<t.rows.length&&(t.rows[u].isSelected=!0)}return t.childItemsPath&&t.collectionView&&t.collectionView.refresh(),!0}if(!t.isReadOnly&&0==r.length){var d=!1,p=t.scrollPosition;return t.deferUpdate(function(){for(var e=o.topRow;e<=o.bottomRow;e++){var n=t.rows[e];if(!n.isReadOnly)for(var r=o.leftCol;r<=o.rightCol;r++){var a=t._getBindingColumn(t.cells,e,t.columns[r]);a.getIsRequired()||a.isReadOnly||t.getCellData(e,r,!0)&&(s.setRange(e,r),l.cancel=!1,t.onBeginningEdit(l)&&(i&&(d||(d=!0,i.beginUpdate()),i.editItem(n.dataItem),t._edtHdl._edItem=i.currentEditItem),t.setCellData(e,r,"",!0,!1),t.onCellEditEnding(l),t.onCellEditEnded(l)))}}t.selection=o,t.scrollPosition=p,d&&i.endUpdate()}),!0}return!1},e.prototype._startEditing=function(e,t,i,o){return this._g._edtHdl.startEditing(e,i,o,!0,t)},e}(),e("_KeyboardHandler",T),D=4,L="wj-state-dragsrc",function(e){e[e.None=0]="None",e[e.Columns=1]="Columns",e[e.Rows=2]="Rows",e[e.Both=3]="Both",e[e.ColumnsAllCells=e.Columns|D]="ColumnsAllCells",e[e.RowsAllCells=e.Rows|D]="RowsAllCells",e[e.BothAllCells=e.Both|D]="BothAllCells"}(O||(O={})),e("AllowResizing",O),function(e){e[e.None=0]="None",e[e.Headers=1]="Headers",e[e.Cells=2]="Cells",e[e.Both=3]="Both"}(j||(j={})),e("AutoSizeMode",j),function(e){e[e.None=0]="None",e[e.Columns=1]="Columns",e[e.Rows=2]="Rows",e[e.Both=3]="Both"}(I||(I={})),e("AllowDragging",I),A=function(){function e(e){var t=this;this._tsLast=0;var i=e.hostElement;this._g=e,this._dvMarker=o.createElement('<div class="wj-marker">&nbsp;</div>'),e.addEventListener(i,"mousedown",function(i){if(e._rcBounds=null,!i.defaultPrevented&&0==i.button){var s=i.target;if(!e.containsFocus()){var l=s instanceof HTMLElement&&s.tabIndex>-1?s:e._eFocus;e._setFocusNoScroll(l)}if(setTimeout(function(){i.defaultPrevented||e.focus()}),o.closest(i.target,".wj-flexgrid")!=e.hostElement||!e.activeEditor&&e._isInputElement(s)){var a=e.hitTest(i);switch(a.cellType){case c.Cell:e.select(a.range);break;case c.ColumnHeader:case c.ColumnFooter:e.scrollIntoView(-1,a.col);break;case c.RowHeader:e.scrollIntoView(a.row,-1)}return}e.removeEventListener(document,"mousemove"),e.removeEventListener(document,"mouseup"),e.addEventListener(document,"mousemove",n),e.addEventListener(document,"mouseup",r),t._isDown=!0,t._mousedown(i)}});var n=function(e){t._mousemove(e)},r=function(i){t._isDown=!1,e.removeEventListener(document,"mousemove"),e.removeEventListener(document,"mouseup"),t._mouseup(i)};e.addEventListener(i,"mouseup",function(e){t._tsLast=Date.now()}),e.addEventListener(i,"mouseenter",function(t){e._rcBounds=null}),e.addEventListener(i,"mousemove",this._hover.bind(this)),e.addEventListener(i,"dblclick",this._dblclick.bind(this)),e.addEventListener(i,"click",this._click.bind(this)),e.addEventListener(i,"selectstart",function(t){e._isInputElement(t.target)||t.preventDefault()}),e.addEventListener(i,"wheel",function(t){var i=e.cells.hostElement.parentElement,n=t.deltaY;if(n&&!t.ctrlKey&&!t.metaKey&&i.scrollHeight>i.offsetHeight&&o.closest(t.target,".wj-flexgrid")==e.hostElement){switch(t.deltaMode){case 1:i.scrollTop+=e.rows.defaultSize*(n<0?-1:1);break;case 2:i.scrollTop+=i.clientHeight*(n<0?-1:1);break;case 0:default:o.isSafari()&&(n=o.clamp(n,-150,150)),i.scrollTop+=n}t.preventDefault(),t.stopImmediatePropagation()}}),e.addEventListener(i,"dragstart",this._dragstart.bind(this)),e.addEventListener(i,"dragover",this._dragover.bind(this)),e.addEventListener(i,"dragleave",this._dragover.bind(this)),e.addEventListener(i,"drop",this._drop.bind(this)),e.addEventListener(i,"dragend",this._dragend.bind(this)),this._enableTouchResizing()}return e.prototype.resetMouseState=function(){this._dragSource&&o.removeClass(this._dragSource,L),this._showDragMarker(null);var e=this._g.hostElement;e&&(e.style.cursor="");var t=this._g;t.removeEventListener(document,"mousemove"),t.removeEventListener(document,"mouseup"),this._tsLast=Date.now(),this._eMouse=null,this._isDown=null,this._htDown=null,this._lbSelRows=null,this._szRowCol=null,this._szArgs=null,this._dragSource=null},e.prototype._enableTouchResizing=function(){var e=this,t=this._g,i=t.hostElement,n="ontouchstart"in window?["touchstart","touchmove","touchend"]:"onpointerdown"in window?["pointerdown","pointermove","pointerup"]:null;n&&(t.addEventListener(i,n[0],function(n){if((null==n.pointerType||"touch"==n.pointerType)&&!o.closest(n.target,".wj-elem-filter")){var r=o.closest(n.target,".wj-cell");r instanceof HTMLElement&&(t._rcBounds=null,e._htDown=null,e._hover(n),e._szRowCol&&(r.removeAttribute("draggable"),i.style.touchAction="none",e._mousedown(n),n.preventDefault()))}}),t.addEventListener(i,n[1],function(t){null!=t.pointerType&&"touch"!=t.pointerType||e._szRowCol&&(e._mousemove(t),t.preventDefault())}),t.addEventListener(i,n[2],function(t){if(o.Control._touching=!1,(null==t.pointerType||"touch"==t.pointerType)&&e._szRowCol){if(e._szArgs)e._finishResizing(e._eMouse);else{var n=o.closest(t.target,".wj-cell");n instanceof HTMLElement&&n.click()}e.resetMouseState(),i.style.touchAction=""}}))},e.prototype._mousedown=function(e){var t=this._g,i=t.hitTest(e),n=i.cellType,r=e.ctrlKey||e.metaKey;if(this._selDown=t.selection,i.panel==t.cells){if(o.closestClass(e.target,d._WJC_DROPDOWN))return t._edtHdl._toggleListBox(e,i.range),void e.preventDefault();if(t.editRange&&t.editRange.contains(i.range))return}var s=o.getActiveElement();if(e.target!=s||!t._isInputElement(e.target))if(n!=c.None){if(this._htDown=i,this._eMouse=e,null!=this._szRowCol)return s!=t._eFocus&&(t._eFocus.tabIndex=0,t._eFocus.focus()),void this._handleResizing(e);switch(n){case c.Cell:r&&t.selectionMode==z.ListBox&&this._startListBoxSelection(i.row),this._mouseSelect(e,e.shiftKey);break;case c.RowHeader:0==(this._g.allowDragging&I.Rows)&&(r&&t.selectionMode==z.ListBox&&this._startListBoxSelection(i.row),this._mouseSelect(e,e.shiftKey))}if(n==c.Cell&&t.rows.maxGroupLevel>-1&&o.closestClass(e.target,d._WJC_COLLAPSE)){var l=o.tryCast(t.rows[i.row],m);if(l)return r?t.collapseGroupsToLevel(l.isCollapsed?l.level+1:l.level):l.isCollapsed=!l.isCollapsed,void this.resetMouseState()}}else t._edtHdl._commitRowEdits()},e.prototype._mousemove=function(e){if(null!=this._htDown){if(0==e.buttons&&this._eMouse&&e.timeStamp-this._eMouse.timeStamp>600)return void this.resetMouseState();if(this._eMouse=e,this._szRowCol)this._handleResizing(e);else switch(this._htDown.cellType){case c.Cell:this._mouseSelect(e,!0);break;case c.RowHeader:0==(this._g.allowDragging&I.Rows)&&this._mouseSelect(e,!0)}}},e.prototype._mouseup=function(e){if(!this._g.isTouching||!(this._dragSource||e.target instanceof HTMLHtmlElement)){var t=this._g,i=t.hitTest(e),o=this._htDown,n=z;if(o&&!e.defaultPrevented)if(this._szArgs)this._finishResizing(e);else if(o.panel!=t.topLeftCells||this._szArgs)o.panel!=t.columnHeaders||e.dataTransfer?o.panel==t.cells&&(e.ctrlKey||e.metaKey||e.shiftKey||i.panel==o.panel&&i.range.equals(o.range)&&t.selection.equals(this._selDown)&&t._edtHdl.startEditing(!0,i.row,i.col,!0,e)):i.panel==o.panel&&i.col==o.col&&!i.edgeRight&&i.col>-1&&this._clickSort(e,i);else if(i.panel==o.panel&&i.row==o.row&&i.col==o.col&&t.rows.length&&t.columns.length)switch(t.selectionMode){case n.CellRange:case n.RowRange:case n.ListBox:t.select(new g(0,0,t.rows.length-1,t.columns.length-1))}this.resetMouseState()}},e.prototype._click=function(e){Date.now()-this._tsLast>50&&!e.pointerType&&this._handleClick(e)},e.prototype._handleClick=function(e){var t=this._g,i=e.target,n=new b(i,null);if(!e.defaultPrevented&&n.grid==t&&!t._isInputElement(i))if(n.panel==t.topLeftCells)t.select(new g(0,0,t.rows.length-1,t.columns.length-1));else if(n.panel==t.columnHeaders)this._clickSort(e,n);else if(n.panel==t.rowHeaders)t.select(new g(n.row,0,n.row,t.columns.length-1));else if(n.panel==t.cells)if(n.row<0)this._clickSort(e,n);else if(o.closestClass(i,d._WJC_COLLAPSE)){var r=t.rows[n.row];r instanceof m&&(e.ctrlKey?t.collapseGroupsToLevel(r.isCollapsed?r.level+1:r.level):r.isCollapsed=!r.isCollapsed)}else o.closestClass(i,d._WJC_DROPDOWN)?t._edtHdl._toggleListBox(e,n.range):t.select(n.range)},e.prototype._clickSort=function(e,t){var i=this._g,n=i.collectionView,r=e.ctrlKey||e.metaKey;if(n&&n.canSort&&i.allowSorting){t.range.bottomRow;var s=t.panel.columns[t.col],a=i._getBindingColumn(t.panel,t.row,s),h=a?a._getBindingSort():null;if(a.allowSorting&&h){for(var c=t.grid.collectionView.sortDescriptions,u=null,d=0;d<c.length;d++)if(c[d].property==h){u=!c[d].ascending;break}if(null==u){if(r)return;u=!0}var g=new l(t.panel,t.range);i.onSortingColumn(g)&&(i._edtHdl._commitRowEdits(),r?c.clear():c.splice(0,c.length,new o.SortDescription(h,u)),i.onSortedColumn(g))}}},e.prototype._dblclick=function(e){var t,i=this._g,o=i.hitTest(e),n=o.cellType,r=i.selection,s=o.range;if(!e.defaultPrevented)if(o.edgeRight&&i.allowResizing&O.Columns){if(n==c.ColumnHeader||n==c.Cell&&i.allowResizing&D){e.preventDefault(),e.ctrlKey&&r.containsColumn(o.col)&&(s=r);for(var a=s.leftCol;a<=s.rightCol;a++)i.columns[a].allowResizing&&(t=new l(i.cells,new g(-1,a)),i.onAutoSizingColumn(t)&&i.onResizingColumn(t)&&(i.autoSizeColumn(a),i.onResizedColumn(t),i.onAutoSizedColumn(t)))}else n==c.TopLeft&&o.panel.columns[o.col].allowResizing&&(e.preventDefault(),t=new l(o.panel,new g(-1,o.col)),i.onAutoSizingColumn(t)&&i.onResizingColumn(t)&&(i.autoSizeColumn(o.col,!0),i.onAutoSizedColumn(t),i.onResizedColumn(t)));this.resetMouseState()}else if(o.edgeBottom&&i.allowResizing&O.Rows){if(n==c.RowHeader||n==c.Cell&&i.allowResizing&D){e.ctrlKey&&r.containsRow(o.row)&&(s=r);for(var h=s.topRow;h<=s.bottomRow;h++)i.rows[h].allowResizing&&(t=new l(i.cells,new g(h,-1)),i.onAutoSizingRow(t)&&i.onResizingRow(t)&&(i.autoSizeRow(h),i.onResizedRow(t),i.onAutoSizedRow(t)))}else n==c.TopLeft&&o.panel.rows[o.row].allowResizing&&(t=new l(o.panel,new g(o.row,-1)),i.onAutoSizingRow(t)&&i.onResizingRow(t)&&(i.autoSizeRow(o.row,!0),i.onResizedRow(t),i.onAutoSizedRow(t)));this.resetMouseState()}else;},e.prototype._hover=function(e){if(null==this._htDown){var t=this._g,i=t.hitTest(e),o=(i.panel,i.cellType),n="";return this._szRowCol=null,(o==c.ColumnHeader||o==c.TopLeft||o==c.Cell&&t.allowResizing&D)&&i.edgeRight&&0!=(t.allowResizing&O.Columns)&&(this._szRowCol=this._getResizeCol(i)),(o==c.RowHeader||o==c.TopLeft||o==c.Cell&&t.allowResizing&D)&&i.edgeBottom&&0!=(t.allowResizing&O.Rows)&&(this._szRowCol=this._getResizeRow(i)),this._szRowCol instanceof _?n="col-resize":this._szRowCol instanceof w&&(n="row-resize"),this._szStart=this._szRowCol?this._szRowCol.renderSize:0,t.hostElement.style.cursor=n,i}return null},e.prototype._getResizeCol=function(e){for(var t=e.panel.columns,i=t[e.col],o=e.col+1;o<t.length;o++)if((n=t[o]).visible){n.size<1&&(i=n);break}if(e.col==t.length-1&&(e.cellType==c.TopLeft||e.cellType==c.RowHeader)){t=this._g.columns;for(o=0;o<t.length;o++){var n=t[o];if(n.visible){n.size<1&&(i=n);break}}}return i.allowResizing?i:null},e.prototype._getResizeRow=function(e){for(var t=e.panel.rows,i=t[e.row],o=e.row+1;o<t.length;o++)if((n=t[o]).visible){n.size<1&&(i=n);break}if(e.row==t.length-1&&(e.cellType==c.TopLeft||e.cellType==c.ColumnHeader)){t=this._g.rows;for(o=0;o<t.length;o++){var n=t[o];if(n.visible){n.size<1&&(i=n);break}}}return i.allowResizing?i:null},e.prototype._mouseSelect=function(e,t){var i=this,n=this._g;if(this._htDown&&this._htDown.panel&&n.selectionMode!=z.None){var r=new b(this._htDown.panel,e);this._handleSelection(r,t),!o.isIE9()&&e.button>=0&&e.target!=n._root&&(r=new b(n,e)).cellType!=c.Cell&&r.cellType!=c.RowHeader&&setTimeout(function(){i._mouseSelect(i._eMouse,t)},100)}},e.prototype._handleResizing=function(t){if(t.preventDefault(),this._szRowCol instanceof _){var i=this._g,n=o.mouseToPage(t).x,r=Math.round(Math.max(e._SZ_MIN,this._szStart+(n-this._htDown.point.x)*(i.rightToLeft?-1:1)));if(this._szRowCol.renderSize!=r){if(null==this._szArgs){a=i.rowHeaders.columns.indexOf(this._szRowCol)>-1?i.rowHeaders:i.cells;this._szArgs=new l(a,new g(-1,this._szRowCol.index))}this._szArgs.cancel=!1,i.onResizingColumn(this._szArgs)&&(i.deferResizing?this._showResizeMarker(r):this._szRowCol.width=r)}}if(this._szRowCol instanceof w){var i=this._g,s=o.mouseToPage(t).y,r=Math.round(Math.max(e._SZ_MIN,this._szStart+(s-this._htDown.point.y)));if(this._szRowCol.renderSize!=r){if(null==this._szArgs){var a=i.columnHeaders.rows.indexOf(this._szRowCol)>-1?i.columnHeaders:i.cells;this._szArgs=new l(a,new g(this._szRowCol.index,-1))}this._szArgs.cancel=!1,i.onResizingRow(this._szArgs)&&(i.deferResizing?this._showResizeMarker(r):this._szRowCol.height=r)}}},e.prototype._dragstart=function(e){var t=this._g,i=this._htDown;if(i){if(this._dragSource=null,!this._szRowCol){var n=new l(i.panel,i.range);if(i.cellType==c.ColumnHeader&&t.allowDragging&I.Columns&&i.col>-1&&t.columns[i.col].allowDragging)t.onDraggingColumn(n)?this._dragSource=e.target:e.preventDefault();else if(i.cellType==c.RowHeader&&t.allowDragging&I.Rows&&i.row>-1&&t.rows[i.row].allowDragging){var r=t.rows[i.row];r instanceof m||r instanceof V||(t.onDraggingRow(n)?this._dragSource=e.target:e.preventDefault())}}this._dragSource&&e.dataTransfer&&!e.defaultPrevented&&(o._startDrag(e.dataTransfer,"move"),e.stopPropagation(),o.addClass(this._dragSource,L),t.beginUpdate(),this._updating=!0)}},e.prototype._dragend=function(e){this._updating&&(this._g.endUpdate(),this._updating=!1),this.resetMouseState()},e.prototype._dragover=function(e){var t=this._g,i=t.hitTest(e),o=!1,n=new l(t.cells,i.range);this._htDown&&i.cellType==this._htDown.cellType&&(i.cellType==c.ColumnHeader?(n.cancel=!t.columns.canMoveElement(this._htDown.col,i.col),o=t.onDraggingColumnOver(n)):i.cellType==c.RowHeader&&(n.cancel=!t.rows.canMoveElement(this._htDown.row,i.row),o=t.onDraggingRowOver(n))),o?(e.dataTransfer.dropEffect="move",this._showDragMarker(i),e.preventDefault(),e.stopPropagation()):this._showDragMarker(null)},e.prototype._drop=function(e){var t=this._g,i=t.hitTest(e);if(this._htDown&&i.cellType==this._htDown.cellType){var o=t.selection,n=new l(t.cells,i.range,this._htDown);i.cellType==c.ColumnHeader?(t.columns.moveElement(this._htDown.col,i.col),t.select(o.row,i.col),t.onDraggedColumn(n)):i.cellType==c.RowHeader&&(t.rows.moveElement(this._htDown.row,i.row),t.select(i.row,o.col),t.onDraggedRow(n))}this.resetMouseState()},e.prototype._showResizeMarker=function(e){var t=this._g,i=this._dvMarker,n=t.cells.hostElement;i.parentElement!=n&&n.appendChild(i);var r,s=this._szArgs.panel.cellType;this._szRowCol instanceof _?(r={left:this._szRowCol.pos+e-1,top:-1e3,right:"",bottom:0,width:3,height:""},t.rightToLeft&&(r.left=n.clientWidth-r.left-r.width),s!=c.TopLeft&&s!=c.RowHeader||(r.left-=t.topLeftCells.hostElement.offsetWidth)):(r={left:-1e3,top:this._szRowCol.pos+e-1,right:0,bottom:"",width:"",height:3},s!=c.TopLeft&&s!=c.ColumnHeader||(r.top-=t.topLeftCells.hostElement.offsetHeight)),o.setCss(i,r)},e.prototype._showDragMarker=function(e){var t=this._g,i=this._dvMarker;if(!e||!e.panel)return o.removeChild(i),void(this._rngTarget=null);if(!e.range.equals(this._rngTarget)){this._rngTarget=e.range;var n=e.panel.hostElement;i.parentElement!=n&&n.appendChild(i);var r={left:0,top:0,width:6,height:6,right:"",bottom:""};switch(e.cellType){case c.ColumnHeader:r.height=e.panel.height;var s=t.columns[e.col];r.left=s.pos-r.width/2,e.col>this._htDown.col&&(r.left+=s.renderWidth),t.rightToLeft&&(r.left=i.parentElement.clientWidth-r.left-r.width);break;case c.RowHeader:r.width=e.panel.width;var l=t.rows[e.row];r.top=l.pos-r.height/2,e.row>this._htDown.row&&(r.top+=l.renderHeight)}o.setCss(i,r)}},e.prototype._finishResizing=function(t){var i=this._g,n=i.selection,r=this._szArgs,s=this._eMouse&&this._eMouse.ctrlKey;if(r&&!r.cancel){if(r.col>-1){var a=r.col,h=o.mouseToPage(t).x,u=Math.round(Math.max(e._SZ_MIN,this._szStart+(h-this._htDown.point.x)*(this._g.rightToLeft?-1:1)));if(r.panel.columns[a].width=Math.round(u),i.onResizedColumn(r),s&&this._htDown.cellType==c.ColumnHeader&&n.containsColumn(a))for(var d=n.leftCol;d<=n.rightCol;d++)i.columns[d].allowResizing&&d!=a&&(r=new l(i.cells,new g(-1,d)),i.onResizingColumn(r)&&(i.columns[d].size=i.columns[a].size,i.onResizedColumn(r)))}if(r.row>-1){var a=r.row,p=o.mouseToPage(t).y,u=Math.round(Math.max(e._SZ_MIN,this._szStart+(p-this._htDown.point.y)));if(r.panel.rows[a].height=Math.round(u),i.onResizedRow(r),s&&this._htDown.cellType==c.RowHeader&&n.containsRow(a))for(var f=n.topRow;f<=n.bottomRow;f++)i.rows[f].allowResizing&&f!=a&&(r=new l(i.cells,new g(f,-1)),i.onResizingRow(r)&&(i.rows[f].size=i.rows[a].size,i.onResizedRow(r)))}}},e.prototype._startListBoxSelection=function(e){var t=this._g.rows;this._lbSelState=!t[e].isSelected,this._lbSelRows={};for(var i=0;i<t.length;i++)t[i].isSelected&&(this._lbSelRows[i]=!0)},e.prototype._handleSelection=function(e,t){var i=this._g,o=i.rows,n=i._selHdl.selection,r=new g(e.row,e.col);if(e.row>-1&&e.col>-1)if(null!=this._lbSelRows){var s=!1;r=new g(e.row,e.col,this._htDown.row,this._htDown.col);for(var a=0;a<o.length;a++){var h=r.containsRow(a)?this._lbSelState:null!=this._lbSelRows[a];if(h!=o[a].isSelected){var u=new l(i.cells,new g(a,n.col,a,n.col2));i.onSelectionChanging(u)&&(o[a]._setFlag(p.Selected,h,!0),s=!0,i.onSelectionChanged(u))}}s&&i.refreshCells(!1,!0,!0),i.scrollIntoView(e.row,e.col)}else e.cellType==c.RowHeader&&(r.col=0,r.col2=i.columns.length-1),t&&(r.row2=n.row2,r.col2=n.col2),i.select(r)},e._SZ_MIN=0,e}(),e("_MouseHandler",A),N="wj-cell-check",k=function(){function e(e){var t=this;this._fullEdit=!1,this._list=null,this._g=e,this._evtInput=document.createEvent("HTMLEvents"),this._evtInput.initEvent("input",!0,!1),e.selectionChanging.addHandler(function(i,o){if(t.finishEditing()){var n=e._selHdl.selection.row;if(n!=o.row){var r=e.rows.length;(n>-1&&n<r?e.rows[n].dataItem:null)!=(o.row>-1&&o.row<r?e.rows[o.row].dataItem:null)&&t._commitRowEdits()}}else o.cancel=!0}),e.lostFocus.addHandler(function(){if(!e.containsFocus()){var i=o.getActiveElement();i&&"fixed"==getComputedStyle(i).position||t._commitRowEdits()}}),e.addEventListener(e.hostElement,"mousedown",function(i){if(!i.defaultPrevented&&0==i.button&&!e._mouseHdl._szRowCol){e.selection;var n=e.hitTest(i);if(n.cellType!=c.Cell&&n.cellType!=c.None)t.finishEditing();else if(n.cellType!=c.None){var r=o.tryCast(i.target,HTMLInputElement);t._isNativeCheckbox(r)&&(r!=t.activeEditor&&(i.preventDefault(),t.startEditing(!1,n.row,n.col,!0,i)&&(r=t.activeEditor)),!r||"checkbox"!=r.type||r.disabled||r.readOnly||(r.checked=!r.checked,r.focus(),t.finishEditing()))}}},!0),e.addEventListener(e.hostElement,"click",function(e){t._isNativeCheckbox(e.target)&&e.preventDefault()})}return e.prototype.startEditing=function(e,t,i,n,r){void 0===e&&(e=!0);var s=this._g;if(t=o.asNumber(t,!0,!0),i=o.asNumber(i,!0,!0),null==t&&(t=s.selection.row),null==i&&(i=s.selection.col),null==n&&(n=!0),!this._allowEditing(t,i))return!1;var a=s.getMergedRange(s.cells,t,i,!1);a||(a=new g(t,i));var h=s.rows[t].dataItem;if(s.select(a,!0),!s.rows[t]||h!=s.rows[t].dataItem)return!1;if(a.equals(this._rng))return!0;if(this.activeEditor&&!this.finishEditing())return!1;var c=new l(s.cells,a,r);if(!s.onBeginningEdit(c))return!1;var u=s.editableCollectionView,d=!1;u&&((d=(h=s.rows[t].dataItem)!=u.currentEditItem)&&s.onRowEditStarting(c),u.editItem(h),d&&(s.onRowEditStarted(c),this._edItem=h)),this._fullEdit=o.asBoolean(e),this._rng=a,this._list=null;var p=s.columns[i].dataMap;p&&(this._list=p.getDisplayValues(h)),a.isSingleCell?this._updateEditorCell(t,i,d):s.refresh(!1);var f=this._edt;if(f){if("checkbox"==f.type)this._fullEdit=!1;else if(n){if(o.isNumber(s.getCellData(t,i,!1))&&f.value.indexOf("%")>-1){for(var _=f.value,w=0,m=_.length;m>0&&"%"==_[m-1];)m--;for(;w<m&&"%"==_[w];)w++;o.setSelectionRange(f,w,m)}else o.setSelectionRange(f,0,f.value.length);s._setFocusNoScroll(f)}if(s.onPrepareCellForEdit(c),f.disabled||f.readOnly)return!1}return null!=f&&!f.disabled&&!f.readOnly},e.prototype.finishEditing=function(e){void 0===e&&(e=!1);var t=this._edt;if(!t)return this._removeListBox(),!0;var i=this._g,n=this._rng,r=new h(i.cells,n),s=i.containsFocus(),l=i.hostElement.querySelector(".wj-control.wj-state-focused");if(l){var a=o.Control.getControl(l);a&&a.onLostFocus(r)}if(r.cancel=e,!e&&i.validateEdits){var c=this._getValidationError();if(c){r.cancel=!0;var u=t.parentElement;u&&(o.toggleClass(u,"wj-state-invalid",!0),u.title=c,r.stayInEditMode=!0)}}if(!i.onCellEditEnding(r)&&r.stayInEditMode)return s?setTimeout(function(){t.select()}):t.select(),!1;if(!r.cancel){r.data=i.cells.getCellData(n.topRow,n.leftCol,!1);for(var d=i.cellFactory.getEditorValue(i),g=n.topRow;g<=n.bottomRow&&g<i.rows.length;g++)for(var p=n.leftCol;p<=n.rightCol&&p<i.columns.length;p++)i.cells.setCellData(g,p,d,!0,!1)}this._edt=null,this._rng=null,this._list=null,this._removeListBox();var f=o.closest(t,".wj-cell");return o.contains(f,o.getActiveElement())&&f.focus(),r.cancel||!r.refresh?this._updateEditorCell(n.row,n.col,!1):i.refresh(!1),s&&i.focus(),i.onCellEditEnded(r),!0},Object.defineProperty(e.prototype,"activeEditor",{get:function(){return this._edt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"editRange",{get:function(){return this._rng},enumerable:!0,configurable:!0}),e.prototype.getClipString=function(e){var t=this._g,i="",n=!0,r=z;if(!e)switch(e=t.selection,t.selectionMode){case r.Row:case r.RowRange:e.col=0,e.col2=t.columns.length-1;break;case r.ListBox:e.col=0,e.col2=t.columns.length-1;for(var s=0;s<t.rows.length;s++)t.rows[s].isSelected&&t.rows[s].isVisible&&(e.row=e.row2=s,i&&(i+="\n"),i+=this.getClipString(e));return i}for(var l=(e=o.asType(e,g)).topRow;l<=e.bottomRow;l++)if(t.rows[l].isVisible){n||(i+="\n"),n=!1;for(var a=e.leftCol,h=!0;a<=e.rightCol;a++)if(t.columns[a].isVisible){h||(i+="\t"),h=!1;var c=t.cells.getCellData(l,a,!0).toString();(c=c.replace(/\t/g," ")).indexOf("\n")>-1&&(c='"'+c.replace(/"/g,'""')+'"'),i+=c}}return i},e.prototype.setClipString=function(e,t){var i=this,n=this._g,r=null==t,s=z;if(!t)switch(t=n.selection,n.selectionMode){case s.Row:case s.RowRange:case s.ListBox:t.col=0,t.col2=n.columns.length-1}t=o.asType(t,g);var a=this._parseClipString(o.asString(e));r&&!t.isSingleCell&&a.length&&this._expandClipRows(a,t);var h,c=new g(t.topRow,t.leftCol),u=n.editableCollectionView,d=t.topRow,p=!1;n.deferUpdate(function(){u&&u.beginUpdate();for(var e=0;e<a.length&&d<n.rows.length;e++,d++)if(n.rows[d].isVisible)for(var o=a[e],r=t.leftCol,s=0;s<o.length&&r<n.columns.length;s++,r++)n.columns[r].isVisible?i._allowEditing(d,r)&&(h=new l(n.cells,new g(d,r),o[s]),n.onPastingCell(h)&&(u&&(u.editItem(n.rows[d].dataItem),i._edItem=u.currentEditItem),n.cells.setCellData(d,r,h.data)&&(n.onPastedCell(h),p=!0)),c.row2=Math.max(c.row2,d),c.col2=Math.max(c.col2,r)):s--;else e--;u&&u.endUpdate(),n.select(c)})},e.prototype._isNativeCheckbox=function(e){return e instanceof HTMLInputElement&&"checkbox"==e.type&&!e.disabled&&!e.readOnly&&o.hasClass(e,N)&&o.closest(e,".wj-flexgrid")==this._g.hostElement},e.prototype._parseClipString=function(e){var t=[];e=(e=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n")).replace(/\n+$/g,"");var i=0,o=0;for(i=0;i<e.length;i++){var n='"'==e[i]&&e[i+1]>=" ",r=!1,s=!1;for(o=i;o<e.length&&!s;o++){var l=e[o];switch(l){case'"':n&&(r=!r);break;case"\t":case"\n":r||(this._parseClipCell(t,e,i,o,"\n"==l),i=o,s=!0)}}if(o==e.length){this._parseClipCell(t,e,i,e.length,!1);break}}return 0==t.length&&t.push([""]),t},e.prototype._parseClipCell=function(e,t,i,o,n){e.length||e.push([]);var r=t.substr(i,o-i),s=r.length;s>1&&'"'==r[0]&&'"'==r[s-1]&&(r=(r=r.substr(1,s-2)).replace(/""/g,'"')),e[e.length-1].push(r),n&&e.push([])},e.prototype._expandClipRows=function(e,t){for(var i=e.length,o=0,n=0;n<i;n++)o=Math.max(o,e[n].length);for(var r=this._g,s=0,l=0,a=t.topRow;a<=t.bottomRow;a++)r.rows[a].isVisible&&s++;for(h=t.leftCol;h<=t.rightCol;h++)r.columns[h].isVisible&&l++;if((s>1||l>1)&&(1==s&&(s=i),1==l&&(l=o),l%o==0&&s%i==0)){for(var h=o;h<l;h++)for(a=0;a<i;a++)e[a].push(e[a%i][h%o]);for(a=i;a<s;a++)e.push(e[a%i])}},e.prototype._updateEditorCell=function(e,t,i){var o=this._g,n=o.cells.getCellElement(e,t),s=o._useFrozenDiv()&&(e<o.frozenRows||t<o.frozenColumns);if(!n||s||o._hasPendingUpdates())o.refresh(!1);else if(this._updateCell(n),(i=i||o._getHasValidation())&&o.headersVisibility&r.Row){var l=o.rowHeaders,a=l.columns.length-1,h=l.getCellElement(e,a);h&&this._updateCell(h)}},e.prototype._updateCell=function(e){var t=new b(e,null),i=s._WJS_UPDATING;t.panel&&(o.addClass(e,i),t.grid.cellFactory.updateCell(t.panel,t.row,t.col,e,t.range),o.removeClass(e,i))},e.prototype._getValidationError=function(){var e=this._g;if(e._getHasValidation()){var t=this._rng.row,i=this._rng.col,o=e.cellFactory.getEditorValue(e),n=e.getCellData(t,i,!1);if(e.setCellData(t,i,o,!0,!1)){var r=e._getError(e.cells,t,i);return e.setCellData(t,i,n,!0,!1),r}}return null},e.prototype._allowEditing=function(e,t){var i=this._g;if(i.isReadOnly||i.selectionMode==z.None)return!1;if(e<0||e>=i.rows.length||i.rows[e].isReadOnly||!i.rows[e].isVisible)return!1;if(t<0||t>=i.columns.length)return!1;var o=i._getBindingColumn(i.cells,e,i.columns[t]);return!(!o||o.isReadOnly||!o.isVisible)},e.prototype._commitRowEdits=function(){var e=this._g;if(this.finishEditing()&&this._edItem){var t=e.editableCollectionView;if(t&&t.currentEditItem){var i=new l(e.cells,e.selection);e.onRowEditEnding(i),t.commitEdit(),e.onRowEditEnded(i)}this._edItem=null}},e.prototype._keydown=function(e){switch(e.keyCode){case o.Key.F2:return this._fullEdit=!this._fullEdit,e.preventDefault(),!0;case o.Key.F4:return this._toggleListBox(e),e.preventDefault(),!0;case o.Key.Space:var t=this._edt;return!t||"checkbox"!=t.type||t.disabled||t.readOnly||(t.checked=!t.checked,this.finishEditing(),e.preventDefault()),!0;case o.Key.Enter:case o.Key.Tab:return e.preventDefault(),!this.finishEditing();case o.Key.Escape:return e.preventDefault(),this.finishEditing(!0),!0;case o.Key.Up:case o.Key.Down:case o.Key.Left:case o.Key.Right:case o.Key.PageUp:case o.Key.PageDown:case o.Key.Home:case o.Key.End:if(this._lbx)return this._keydownListBox(e);if(e.altKey)switch(e.keyCode){case o.Key.Up:case o.Key.Down:return this._toggleListBox(e),e.preventDefault(),!0}if(!this._fullEdit&&this.finishEditing())return!1}return!0},e.prototype._keydownListBox=function(e){var t=!0;if(this._lbx)switch(e.keyCode){case o.Key.Up:e.altKey?this._toggleListBox(e):this._lbx.selectedIndex>0&&this._lbx.selectedIndex--;break;case o.Key.Down:e.altKey?this._toggleListBox(e):this._lbx.selectedIndex++;break;case o.Key.Home:case o.Key.PageUp:this._lbx.selectedIndex=0;break;case o.Key.End:case o.Key.PageDown:this._lbx.selectedIndex=this._lbx.collectionView.items.length-1;break;default:t=!1}return!!t&&(e.preventDefault(),!0)},e.prototype._keypress=function(e){var t=this._edt;if(t&&"checkbox"!=t.type&&this._list&&this._list.length>0&&e.charCode>=32){var i=t.selectionStart,n=t.value.substr(0,i);e.target==t&&(i++,n+=String.fromCharCode(e.charCode)),n=n.toLowerCase();for(var r=0;r<this._list.length;r++)if(0==this._list[r].toLowerCase().indexOf(n)){t.value=this._list[r],o.setSelectionRange(t,i,this._list[r].length),t.dispatchEvent(this._evtInput),e.preventDefault();break}}},e.prototype._toggleListBox=function(e,t){var o=this._g,n=o._selHdl.selection;if(t||(t=n),this._lbx&&(this._removeListBox(),n.contains(t)))return o.activeEditor?o.activeEditor.focus():o.containsFocus()||o.focus(),!0;var r=o.isTouching,s=o._getBindingColumn(o.cells,t.row,o.columns[t.col]);return!(!i()||!s.dataMap||!1===s.showDropDown)&&(!(!i()||!this.startEditing(!0,t.row,t.col,!r,e))&&(this._lbx=this._createListBox(),this._lbx.showSelection(),r&&this._lbx.focus(),!0))},e.prototype._createListBox=function(){var e=this,t=this._g,n=this._rng,r=t.rows[n.row],s=t._getBindingColumn(t.cells,n.row,t.columns[n.col]),l=document.createElement("div"),a=new(i().ListBox)(l);this._removeListBox(),o.addClass(l,"wj-dropdown-panel wj-grid-listbox"),a.maxHeight=4*r.renderHeight,a.isContentHtml=s.isContentHtml,a.itemsSource=s.dataMap.getDisplayValues(r.dataItem),a.selectedValue=t.activeEditor?t.activeEditor.value:t.getCellData(n.row,n.col,!0),o.addClass(l,s.dropDownCssClass),a.addEventListener(a.hostElement,"click",function(){e._removeListBox(),t.focus(),e.finishEditing()}),a.lostFocus.addHandler(function(){e._removeListBox()}),a.selectedIndexChanged.addHandler(function(){var i=t.activeEditor;i&&(i.value=e._lbx.selectedValue,i.dispatchEvent(e._evtInput),o.setSelectionRange(i,0,i.value.length))});var h=t.cells.getCellElement(n.row,n.col);return h?o.showPopup(l,h,!1,!1,!1):(o.showPopup(l,t.getCellBoundingRect(n.row,n.col)),l[o.Control._OWNR_KEY]=t.hostElement),a},e.prototype._removeListBox=function(){var e=this._lbx;e&&(this._lbx=null,o.hidePopup(e.hostElement,function(){e.dispose()}))},e}(),e("_EditHandler",k),B=function(){function e(e){this._nrt=new V,this._g=e,this._keydownBnd=this._keydown.bind(this),this._attach()}return Object.defineProperty(e.prototype,"newRowAtTop",{get:function(){return this._top},set:function(e){e!=this.newRowAtTop&&(this._top=o.asBoolean(e),this.updateNewRowTemplate())},enumerable:!0,configurable:!0}),e.prototype.updateNewRowTemplate=function(){var e=this._g,t=e.editableCollectionView,i=e.rows,o=t&&t.canAddNew&&e.allowAddNew&&!e.isReadOnly,n=i.indexOf(this._nrt),r=this._top?0:i.length-1,s=!1;if(!o&&n>-1){var l=e.selection;l.row==n&&e.select(l.row-1,l.col),i.removeAt(n)}else o&&(n<0?s=!0:n!=r&&(i.removeAt(n),s=!0),s&&(this._top?i.insert(0,this._nrt):i.push(this._nrt)),this._nrt&&this._nrt._setFlag(p.ParentCollapsed,!1))},e.prototype._attach=function(){var e=this._g;e&&(e.beginningEdit.addHandler(this._beginningEdit,this),e.pastingCell.addHandler(this._beginningEdit,this),e.rowEditEnded.addHandler(this._rowEditEnded,this),e.loadedRows.addHandler(this.updateNewRowTemplate,this),e.hostElement.addEventListener("keydown",this._keydownBnd,!0))},e.prototype._detach=function(){var e=this._g;e&&(e.beginningEdit.removeHandler(this._beginningEdit),e.pastingCell.removeHandler(this._beginningEdit),e.rowEditEnded.removeHandler(this._rowEditEnded),e.loadedRows.removeHandler(this.updateNewRowTemplate),e.hostElement.removeEventListener("keydown",this._keydownBnd,!0))},e.prototype._keydown=function(e){e.defaultPrevented||e.keyCode!=o.Key.Escape||null==this._g.activeEditor&&this._top&&this._nrt.dataItem&&(this._nrt.dataItem=null,this._g.invalidate())},e.prototype._beginningEdit=function(e,t){if(!t.cancel){var i=this._g.rows[t.row];if(o.tryCast(i,V)){var n=this._g.editableCollectionView;if(n&&n.canAddNew)if(this._top){if(null==this._nrt.dataItem){var r=null,s=n.sourceCollection,l=n.newItemCreator;r=o.isFunction(l)?l():s&&s.length?new s[0].constructor:{},this._nrt.dataItem=r}}else{r=n.currentAddItem&&n.currentAddItem==i.dataItem?n.currentAddItem:n.addNew();n.moveCurrentTo(r),this.updateNewRowTemplate(),this._g.refresh(!0),this._g.onRowAdded(t),t.cancel&&n.cancelNew()}}}},e.prototype._rowEditEnded=function(e,t){var i=this,o=this._g.editableCollectionView,n=this._nrt.dataItem;if(o)if(o.isAddingNew)o.commitNew();else if(n&&!t.cancel){this._nrt.dataItem=null;var r=o.addNew();for(var s in n)r[s]=n[s];this._g.onRowAdded(t),t.cancel?o.cancelNew():o.commitNew(),setTimeout(function(){i._g.select(0,i._g.columns.firstVisibleIndex),i.updateNewRowTemplate()},20)}},e}(),e("_AddNewHandler",B),V=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return K(t,e),t}(w),e("_NewRowTemplate",V),F=function(){function e(t){this._g=t,this._tbx=o.createElement('<input class="wj-grid-editor wj-form-control wj-grid-ime"/>'),o.setCss(this._tbx,e._cssHidden),t.cells.hostElement.parentElement.appendChild(this._tbx),this._updateImeFocus();var i=t.hostElement;t.addEventListener(this._tbx,"compositionstart",this._compositionstart.bind(this)),t.addEventListener(i,"blur",this._updateImeFocus.bind(this),!0),t.addEventListener(i,"focus",this._updateImeFocus.bind(this),!0),t.addEventListener(i,"mousedown",this._mousedown.bind(this),!0),t.addEventListener(i,"mouseup",this._mouseup.bind(this),!0),t.cellEditEnded.addHandler(this._cellEditEnded,this),t.selectionChanged.addHandler(this._updateImeFocus,this)}return e.prototype.dispose=function(){var e=this._g,t=e.hostElement;e.removeEventListener(this._tbx,"compositionstart"),e.removeEventListener(t,"blur"),e.removeEventListener(t,"focus"),e.removeEventListener(t,"mousedown"),e.removeEventListener(t,"mouseup"),e.cellEditEnded.removeHandler(this._cellEditEnded),e.selectionChanged.removeHandler(this._updateImeFocus),o.removeChild(this._tbx)},e.prototype._cellEditEnded=function(){o.setCss(this._tbx,e._cssHidden),this._tbx.value=""},e.prototype._compositionstart=function(){var e=this,t=this._g;if(null==t.activeEditor){var i=t._selHdl.selection;if(t.startEditing(!1,i.row,i.col,!1)){i=t.editRange;var n=t.cells.hostElement,r=t.columns[i.col].pos+n.offsetLeft,s=t.rows[i.row].pos+n.offsetTop,l=t.getCellBoundingRect(i.row,i.col);if(!i.isSingleCell){var a=t.cells.getCellElement(i.row,i.col);l.width=a.offsetWidth,l.height=a.offsetHeight}i.row<t.frozenRows&&(s+=n.parentElement.scrollTop),i.col<t.frozenColumns&&(r+=n.parentElement.scrollLeft);var h=t.activeEditor,c=h&&h.parentElement?h.parentElement.style.zIndex:"";o.setCss(this._tbx,{position:"absolute",pointerEvents:"",opacity:"",left:r,top:s,width:l.width-1,height:l.height-1,zIndex:c}),h instanceof HTMLInputElement&&["minLength","maxLength","pattern"].forEach(function(t){o.setAttribute(e._tbx,t,h.getAttribute(t))}),t._edtHdl._edt=this._tbx}}},e.prototype._mousedown=function(e){this._mouseDown=!0,this._updateImeFocus()},e.prototype._mouseup=function(e){this._mouseDown=!1,this._updateImeFocus()},e.prototype._updateImeFocus=function(){var e=this._g,t=o.getActiveElement();if(!e.activeEditor&&!e.isTouching&&!this._mouseDown&&o.contains(e.hostElement,t)){var i=this._tbx;this._enableIme()?t!=i&&(i.disabled=!1,i.select()):i.disabled=!0}},e.prototype._enableIme=function(){var e=this._g,t=e.selection,i=t.isValid?e._getBindingColumn(e.cells,t.row,e.columns[t.col]):null;return!!e.canEditCell(t.row,t.col)&&!(!i||i.dataType==o.DataType.Boolean)},e._cssHidden={position:"fixed",pointerEvents:"none",opacity:0,left:-10,top:-10,width:0},e}(),e("_ImeHandler",F)}}});