/*
*
* Wijmo Library 5.20183.567
* http://wijmo.com/
*
* Copyright(c) GrapeCity, Inc. All rights reserved.
*
* Licensed under the GrapeCity Commercial License.
* sales@wijmo.com
* wijmo.com/products/wijmo-5/license/
*
*/
"use strict";function tryGetModuleWijmoInput(){var e;return(e=__glob.wijmo)&&e.input}var __extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])};return function(t,o){function i(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(i.prototype=o.prototype,new i)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wjcCore=require("wijmo/wijmo"),__glob="undefined"!=typeof window?window:self,wjcSelfRef=require("wijmo/wijmo.grid"),wjcSelf=wjcSelfRef||exports;__glob.wijmo=__glob.wijmo||{},__glob.wijmo.grid=wjcSelf,wjcCore._addCultureInfo("FlexGrid",{groupHeaderFormat:"{name}: {value} ({count:n0} items)",ariaLabels:{toggleDropDown:"Toggle Dropdown",toggleGroup:"Toggle Group"}});var HeadersVisibility;!function(e){e[e.None=0]="None",e[e.Column=1]="Column",e[e.Row=2]="Row",e[e.All=3]="All"}(HeadersVisibility=exports.HeadersVisibility||(exports.HeadersVisibility={}));var FlexGrid=function(e){function t(t,o){var i=e.call(this,t,null,!0)||this;i._szClient=new wjcCore.Size(0,0),i._ptScrl=new wjcCore.Point(0,0),i._cellPadLeft=3,i._cellPadVert=0,i._clipToScreen=!1,i._autoGenCols=!0,i._autoClipboard=!0,i._autoScroll=!0,i._autoSearch=!1,i._readOnly=!1,i._indent=14,i._autoSizeMode=AutoSizeMode.Both,i._hdrVis=HeadersVisibility.All,i._alSorting=!0,i._alAddNew=!1,i._alDelete=!1,i._alResizing=AllowResizing.Columns,i._alDragging=AllowDragging.Columns,i._alMerging=AllowMerging.None,i._ssHdr=HeadersVisibility.None,i._shSort=!0,i._shGroups=!0,i._altStep=1,i._shErr=!0,i._shDropDown=!0,i._valEdt=!0,i._deferResizing=!1,i._pSel=!0,i._pOutline=!0,i._stickyHdr=!1,i._anchorCursor=!1,i._vt=0,i._vtRows=0,i._vtCols=0,i._reorderCells=!0,i._refreshOnEdit=!0,i._lazyRender=!1,i.itemsSourceChanging=new wjcCore.Event,i.itemsSourceChanged=new wjcCore.Event,i.scrollPositionChanged=new wjcCore.Event,i.selectionChanging=new wjcCore.Event,i.selectionChanged=new wjcCore.Event,i.loadingRows=new wjcCore.Event,i.loadedRows=new wjcCore.Event,i.updatingLayout=new wjcCore.Event,i.updatedLayout=new wjcCore.Event,i.resizingColumn=new wjcCore.Event,i.resizedColumn=new wjcCore.Event,i.autoSizingColumn=new wjcCore.Event,i.autoSizedColumn=new wjcCore.Event,i.draggingColumn=new wjcCore.Event,i.draggingColumnOver=new wjcCore.Event,i.draggedColumn=new wjcCore.Event,i.resizingRow=new wjcCore.Event,i.resizedRow=new wjcCore.Event,i.autoSizingRow=new wjcCore.Event,i.autoSizedRow=new wjcCore.Event,i.draggingRow=new wjcCore.Event,i.draggingRowOver=new wjcCore.Event,i.draggedRow=new wjcCore.Event,i.groupCollapsedChanging=new wjcCore.Event,i.groupCollapsedChanged=new wjcCore.Event,i.sortingColumn=new wjcCore.Event,i.sortedColumn=new wjcCore.Event,i.beginningEdit=new wjcCore.Event,i.prepareCellForEdit=new wjcCore.Event,i.cellEditEnding=new wjcCore.Event,i.cellEditEnded=new wjcCore.Event,i.rowEditStarting=new wjcCore.Event,i.rowEditStarted=new wjcCore.Event,i.rowEditEnding=new wjcCore.Event,i.rowEditEnded=new wjcCore.Event,i.rowAdded=new wjcCore.Event,i.deletingRow=new wjcCore.Event,i.deletedRow=new wjcCore.Event,i.copying=new wjcCore.Event,i.copied=new wjcCore.Event,i.pasting=new wjcCore.Event,i.pasted=new wjcCore.Event,i.pastingCell=new wjcCore.Event,i.pastedCell=new wjcCore.Event,i.formatItem=new wjcCore.Event(function(){i.invalidate()}),i.updatingView=new wjcCore.Event,i.updatedView=new wjcCore.Event,i._mappedColumns=null;var r=i.hostElement;wjcCore.isIE()&&(r.style.borderRadius="0");var n=i.getTemplate();i.applyTemplate("wj-control wj-content wj-flexgrid",n,{_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"});return[i._eRHdr,i._eCFtr,i._eCHdr,i._eBL,i._eTL].forEach(function(e){wjcCore.setAttribute(e,"aria-hidden",!0),wjcCore.setCss(e,{position:"absolute",overflow:"hidden",outline:"none"}),wjcCore.setCss(e.firstElementChild,{position:"relative"})}),[i._eFocus,i._eMarquee,i._fCt,i._eSz].forEach(function(e){wjcCore.setAttribute(e,"aria-hidden",!0)}),r.tabIndex=-1,i.deferUpdate(function(){var e=i._getDefaultRowHeight();i._rows=new RowCollection(i,e),i._cols=new ColumnCollection(i,4*e),i._hdrRows=new RowCollection(i,e),i._hdrCols=new ColumnCollection(i,Math.round(1.25*e)),i._ftrRows=new RowCollection(i,e);var t=CellType;i._gpTL=new GridPanel(i,t.TopLeft,i._hdrRows,i._hdrCols,i._eTLCt),i._gpCHdr=new GridPanel(i,t.ColumnHeader,i._hdrRows,i._cols,i._eCHdrCt),i._gpRHdr=new GridPanel(i,t.RowHeader,i._rows,i._hdrCols,i._eRHdrCt),i._gpCells=new GridPanel(i,t.Cell,i._rows,i._cols,i._eCt),i._gpBL=new GridPanel(i,t.BottomLeft,i._ftrRows,i._hdrCols,i._eBLCt),i._gpCFtr=new GridPanel(i,t.ColumnFooter,i._ftrRows,i._cols,i._eCFtrCt),i._hdrRows.push(new Row),i._hdrCols.push(new Column({align:"center"})),i._cf=new CellFactory,i._keyHdl=new _KeyboardHandler(i),i._mouseHdl=new _MouseHandler(i),i._edtHdl=new _EditHandler(i),i._selHdl=new _SelectionHandler(i),i._addHdl=new _AddNewHandler(i),i._mrgMgr=new MergeManager(i),i._bndSortConverter=i._sortConverter.bind(i),i._errorTip=new wjcCore.Tooltip({isContentHtml:!1,showDelay:0,cssClass:"wj-error-tip"}),wjcCore.setAttribute(i.cells.hostElement,"role","grid"),i.selectionMode=SelectionMode.CellRange,i.initialize(o)}),i.addEventListener(i._root,"scroll",function(e){i._updateScrollPosition()&&(i.finishEditing(),i._updateContent(!0))}),i.addEventListener(r,"focus",function(e){if(r.tabIndex>-1){var t=e.target;if(t instanceof HTMLElement&&t.tabIndex<0)return void i._setFocus(!0)}},!0),i}return __extends(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=wjcCore.asEnum(e,HeadersVisibility))!=this._hdrVis&&(this._hdrVis=e,this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stickyHeaders",{get:function(){return this._stickyHdr},set:function(e){e!=this._stickyHdr&&(this._stickyHdr=wjcCore.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=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"preserveOutlineState",{get:function(){return this._pOutline},set:function(e){this._pOutline=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"anchorCursor",{get:function(){return this._anchorCursor},set:function(e){this._anchorCursor=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"virtualizationThreshold",{get:function(){return this._vt},set:function(e){this._vt=e,wjcCore.isNumber(e)?this._vtRows=this._vtCols=wjcCore.asNumber(e):e?wjcCore.isArray(e)&&2==e.length?(this._vtRows=wjcCore.asNumber(e[0]),this._vtCols=wjcCore.asNumber(e[1])):wjcCore.assert(!1,"virtualizationThreshold should be a number or an array with two numbers."):this._vtRows=this._vtCols=0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoGenerateColumns",{get:function(){return this._autoGenCols},set:function(e){this._autoGenCols=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoClipboard",{get:function(){return this._autoClipboard},set:function(e){this._autoClipboard=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoScroll",{get:function(){return this._autoScroll},set:function(e){this._autoScroll=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoSearch",{get:function(){return this._autoSearch},set:function(e){this._autoSearch=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"columnLayout",{get:function(){var e=t._getSerializableProperties(Column),o=new Column,i=[];return this.columns.forEach(function(t){var r={};e.forEach(function(e){var i=t[e];i!=o[e]&&wjcCore.isPrimitive(i)&&"size"!=e&&(r[e]=i)}),i.push(r)}),JSON.stringify({columns:i})},set:function(e){var t=JSON.parse(wjcCore.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=wjcCore.asBoolean(e),this.finishEditing(),this.invalidate(!0),this._addHdl.updateNewRowTemplate(),wjcCore.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){if(wjcCore.asBoolean(e)!=this.imeEnabled&&this.finishEditing()){var t=this.containsFocus();this._imeHdl&&(this._imeHdl.dispose(),this._imeHdl=null),e&&(this._imeHdl=new _ImeHandler(this)),t&&this.focus()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowResizing",{get:function(){return this._alResizing},set:function(e){this._alResizing=wjcCore.asEnum(e,AllowResizing)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"deferResizing",{get:function(){return this._deferResizing},set:function(e){this._deferResizing=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoSizeMode",{get:function(){return this._autoSizeMode},set:function(e){this._autoSizeMode=wjcCore.asEnum(e,AutoSizeMode)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"quickAutoSize",{get:function(){return this._quickSize},set:function(e){this._quickSize=wjcCore.asBoolean(e,!0)},enumerable:!0,configurable:!0}),t.prototype._getQuickAutoSize=function(){return wjcCore.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=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowAddNew",{get:function(){return this._alAddNew},set:function(e){e!=this._alAddNew&&(this._alAddNew=wjcCore.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=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowDelete",{get:function(){return this._alDelete},set:function(e){e!=this._alDelete&&(this._alDelete=wjcCore.asBoolean(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowMerging",{get:function(){return this._alMerging},set:function(e){(e=wjcCore.asEnum(e,AllowMerging))!=this._alMerging&&(this._alMerging=e,this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showSelectedHeaders",{get:function(){return this._ssHdr},set:function(e){(e=wjcCore.asEnum(e,HeadersVisibility))!=this._ssHdr&&(this._ssHdr=e,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=wjcCore.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=wjcCore.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=wjcCore.asBoolean(e),this._bindGrid(!1))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"alternatingRowStep",{get:function(){return this._altStep},set:function(e){e!=this._altStep&&(this._altStep=wjcCore.asInt(e,!1,!0),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showAlternatingRows",{get:function(){return this._altStep>0},set:function(e){wjcCore._deprecated("showAlternatingRows","alternatingRowStep"),this.alternatingRowStep=e?1:0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showErrors",{get:function(){return this._shErr},set:function(e){e!=this._shErr&&(this._clearCells(),this._shErr=wjcCore.asBoolean(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"errorTip",{get:function(){return this._errorTip},set:function(e){e!=this._errorTip&&(this._clearCells(),this._errorTip=wjcCore.asType(e,wjcCore.Tooltip,!0))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"itemValidator",{get:function(){return this._itemValidator},set:function(e){e!=this.itemValidator&&(this._itemValidator=wjcCore.asFunction(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"validateEdits",{get:function(){return this._valEdt},set:function(e){this._valEdt=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"groupHeaderFormat",{get:function(){return this._gHdrFmt},set:function(e){e!=this._gHdrFmt&&(this._gHdrFmt=wjcCore.asString(e),this._bindGrid(!1))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowDragging",{get:function(){return this._alDragging},set:function(e){(e=wjcCore.asEnum(e,AllowDragging))!=this._alDragging&&(this._alDragging=e,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 wjcCore.CancelEventArgs;if(this.onItemsSourceChanging(t)){if(this._cv&&((o=wjcCore.tryCast(this._cv,wjcCore.CollectionView))&&o.sortConverter==this._bndSortConverter&&(o.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 o=wjcCore.tryCast(this._cv,wjcCore.CollectionView);o&&!o.sortConverter&&(o.sortConverter=this._bndSortConverter)}this._bindGrid(!0);var i=SelectionMode;this.selectionMode==i.ListBox&&(this.selectionMode=i.CellRange,this.selectionMode=i.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 wjcCore.tryCast(this._cv,"IEditableCollectionView")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){e!=this._childItemsPath&&(wjcCore.assert(null==e||wjcCore.isArray(e)||wjcCore.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=wjcCore.asString(e),this._rowHdrPath=e?new wjcCore.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&&(wjcCore.setText(this._fCt,null),this._fzClone=wjcCore.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=wjcCore.asNumber(e,!0),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"editColumnIndex",{get:function(){return this._editColIndex},set:function(e){e!=this._editColIndex&&(this._editColIndex=wjcCore.asNumber(e,!0),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scrollPosition",{get:function(){return this._ptScrl.clone()},set:function(e){var o=this._root,i=-e.x;if(this.rightToLeft)switch(t._getRtlMode()){case"rev":i=o.scrollWidth-o.clientWidth+e.x;break;case"neg":i=e.x;break;default:i=-e.x}o.scrollLeft=i,o.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=wjcCore.getElementRect(this._root)),this._rcBounds},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scrollSize",{get:function(){return new wjcCore.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=wjcCore.asType(e,CellFactory,!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=wjcCore.asFunction(e))},enumerable:!0,configurable:!0}),t.prototype.canEditCell=function(e,t){return this._edtHdl._allowEditing(e,t)},t.prototype.getCellData=function(e,t,o){return this.cells.getCellData(e,t,o)},t.prototype.getCellBoundingRect=function(e,t,o){return this.cells.getCellBoundingRect(e,t,o)},t.prototype.setCellData=function(e,t,o,i,r){return void 0===i&&(i=!0),void 0===r&&(r=!0),this.cells.setCellData(e,t,o,i,r)},t.prototype.hitTest=function(e,t){return wjcCore.isNumber(e)&&wjcCore.isNumber(t)&&(e=new wjcCore.Point(e,t)),wjcCore.isBoolean(t)&&t&&(this._rcBounds=null),new HitTestInfo(this,e)},t.prototype.getClipString=function(e,t,o,i){return this._edtHdl.getClipString(e,t,o,i)},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){if(void 0===t&&(t=!0),e.prototype.refresh.call(this,t),this.finishEditing(),t){this._updateColumnTypes(),this.scrollPosition=this._ptScrl;var o=this._getDefaultRowHeight();this._rows._setDefaultSize(o),this._cols._setDefaultSize(4*o),this._hdrRows._setDefaultSize(o),this._hdrCols._setDefaultSize(Math.round(1.25*o)),this._ftrRows._setDefaultSize(o),this._toInv&&(clearTimeout(this._toInv),this._toInv=null)}this.refreshCells(t),this._szCtl=new wjcCore.Size(this._e.offsetWidth,this._e.offsetHeight)},t.prototype.refreshCells=function(e,t,o){this.isUpdating||(e?this._updateLayout():this._updateContent(t,o))},t.prototype.autoSizeColumn=function(e,t,o){void 0===t&&(t=!1),void 0===o&&(o=4),this.autoSizeColumns(e,e,t,o)},t.prototype.autoSizeColumns=function(e,o,i,r){var n=this;void 0===i&&(i=!1),void 0===r&&(r=4);var s=0,l=i?this.topLeftCells:this.columnHeaders,a=i?this.bottomLeftCells:this.columnFooters,c=i?this.rowHeaders:this.cells,h=this.viewRange;e=null==e?0:wjcCore.asInt(e),o=null==o?c.columns.length-1:wjcCore.asInt(o),h.row=Math.max(0,h.row-1e3),h.row2=Math.min(h.row2+1e3,this.rows.length-1),this.finishEditing()&&this.columns.deferUpdate(function(){wjcCore.setCss(n._eCt,{width:n._gpCells.width});for(var i=wjcCore.createElement('
',c.hostElement),u=n._getCanvasContext(),d=e;d<=o&&d>-1&&d0&&(g.width=s+r+2)}}n.cellFactory.disposeCell(i),wjcCore.removeChild(i)})},t.prototype.autoSizeRow=function(e,t,o){void 0===t&&(t=!1),void 0===o&&(o=0),this.autoSizeRows(e,e,t,o)},t.prototype.autoSizeRows=function(e,o,i,r){var n=this;void 0===i&&(i=!1),void 0===r&&(r=0);var s=0,l=i?this.topLeftCells:this.rowHeaders,a=i?this.columnHeaders:this.cells;if(i=wjcCore.asBoolean(i),r=wjcCore.asNumber(r),e=null==e?0:wjcCore.asInt(e),o=null==o?a.rows.length-1:wjcCore.asInt(o),this.finishEditing()){wjcCore.setCss(this._eCt,{width:this._gpCells.width});var c=wjcCore.createElement('',a.hostElement);this.rows.deferUpdate(function(){for(var t={},i=e;i<=o&&i>-1&&i0&&(a.rows[i].height=s+r))}),this.cellFactory.disposeCell(c),wjcCore.removeChild(c)}},Object.defineProperty(t.prototype,"treeIndent",{get:function(){return this._indent},set:function(e){e!=this._indent&&(this._indent=wjcCore.asNumber(e,!1,!0),this.columns.onCollectionChanged())},enumerable:!0,configurable:!0}),t.prototype.collapseGroupsToLevel=function(e){var t=this;this.finishEditing()&&this.deferUpdate(function(){var o=t.rows;o.deferUpdate(function(){for(var t=0;t=e)}})})},Object.defineProperty(t.prototype,"selectionMode",{get:function(){return this._selHdl.selectionMode},set:function(e){(e=wjcCore.asEnum(e,SelectionMode))!=this.selectionMode&&(this._clearCells(),this._selHdl.selectionMode=e)},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==SelectionMode.ListBox)for(o=0;o-1&&o<=t.bottomRow;o++)e.push(this.rows[o]);return e},set:function(e){var t=this;wjcCore.assert(this.selectionMode==SelectionMode.ListBox,"This property can be set only in ListBox mode."),e=wjcCore.asArray(e),this.deferUpdate(function(){for(var o=0,i=!0;o-1;n&&i&&(i=!1,t.select(o,t.selection.col)),r.isSelected=n}})},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedItems",{get:function(){for(var e=this.selectedRows,t=0;t-1;n&&i&&(i=!1,t.select(o,t.selection.col)),r.isSelected=n}})},enumerable:!0,configurable:!0}),t.prototype.scrollIntoView=function(e,t,o){(null==this._maxOffsetY||this._rows._dirty||this._cols._dirty)&&this._updateLayout();var i=this.scrollPosition,r=this._szClient.width,n=this._szClient.height-this._gpCFtr.rows.getTotalSize(),s=this.cells._getFrozenPos();if((e=wjcCore.asInt(e))>-1&&e=this._rows.frozen){var l=this._rows[e],a=this.cells.height>n?Math.round(l.pos/(this.cells.height-n)*100)/100:0,c=Math.round(this._maxOffsetY*a),h=l.pos-c,u=h+l.renderSize;u>n-i.y&&(i.y=Math.max(-h,n-u)),h-s.y<-i.y&&(i.y=-(h-s.y))}if((t=wjcCore.asInt(t))>-1&&t=this._cols.frozen){var d=this._cols[t],g=d.pos+d.renderSize;g>-i.x+r&&(i.x=Math.max(-d.pos,r-g)),d.pos-s.x<-i.x&&(i.x=-(d.pos-s.x))}return!i.equals(this._ptScrl)&&(this.scrollPosition=i,o&&(this._updateScrollPosition(),this.refresh()),!0)},t.prototype.isRangeValid=function(e){return e.isValid&&e.bottomRow0
',document.body),e&&o.setAttribute("class",e.getAttribute("class")),t=o.children[0]);var i=t.offsetHeight;return(isNaN(i)||i<=6)&&(i=28),wjcCore.removeChild(o),i},t.prototype._getCollectionView=function(e){return wjcCore.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,o,i){for(var r=0,n=0,s=e.columns[o].dataType==wjcCore.DataType.Boolean,l=t.row;l<=t.row2;l++)if(e.rows[l].isVisible){var a=e.getCellData(l,o,!0),c=i.measureText(a).width,h=this.getMergedRange(e,l,o,!1);if(h&&h.columnSpan>1&&(c/=h.columnSpan),c>n&&(n=c,r=l),s)break}return r},t.prototype._getDesiredWidth=function(e,t,o,i){var r=this.getMergedRange(e,t,o,!1),n=i.style;return this.cellFactory.updateCell(e,t,o,i,r),n.width=n.top=n.left="",i.offsetWidth/(r&&r.columnSpan>1?r.columnSpan:1)},t.prototype._getDesiredHeight=function(e,t,o,i){var r=i.style,n=this.getMergedRange(e,t,o,!1),s=n?n.rowSpan:1;return this.cellFactory.updateCell(e,t,o,i,n),i.innerHTML.trim()||(i.innerHTML=" "),r.height=r.top=r.left="",i.offsetHeight/s},t.prototype._getDesiredRowHeight=function(e,t,o,i){for(var r=0,n=0;n1?l.rowSpan:1,content:s.dataType==wjcCore.DataType.Number?"1":e.getCellData(t,n,!0)},h=JSON.stringify(c);null==(a=i[h])&&(a=this._getDesiredHeight(e,t,n,o),i[h]=a)}else a=this._getDesiredHeight(e,t,n,o);r=Math.max(a,r)}}return r},t.prototype._getSortRowIndex=function(){return null!=this._sortRowIndex?this._sortRowIndex:this.columnHeaders.rows.length-1},t.prototype._getEditColumnIndex=function(){return null!=this._editColIndex?this._editColIndex:this.rowHeaders.columns.length-1},t.prototype._sortConverter=function(e,t,o,i){var r;if(i){if(this._mappedColumns=null,this._cv)for(var n=this._cv.sortDescriptions,s=0;s-1&&(r=this.columns[this._mouseHdl._htDown.col],this._mappedColumns&&r.dataMap&&(this._mappedColumns[r.binding]=r.dataMap))}if(this._mappedColumns){var l=this._mappedColumns[e.property];l&&l.sortByDisplayValues&&(o=l.getDisplayValue(o))}return o},t.prototype._bindGrid=function(e){var t=this;if(this.finishEditing(),this.deferUpdate(function(){t.autoGenerateColumns&&0==t._lastCount&&wjcCore.hasItems(t._cv)&&(e=!0);var o,i=t.selectionMode==SelectionMode.ListBox;t.preserveSelectedState&&i&&(o=t.selectedItems);var r;if(t.preserveOutlineState&&wjcCore.isFunction(window.Map)&&t.rows.maxGroupLevel>-1){r=new Map;for(h=0;h-1&&(t.rows[h].isSelected=!0,a++);if(i&&0==a&&t._lastCount>0)for(var c=t.selection,h=c.topRow;h<=c.bottomRow&&h>-1&&h-1)return this.rows.removeAt(r),void this._syncSelection(!1);wjcCore.assert(!1,"removed item not found on grid.")}this._bindGrid(!1)}}},t.prototype._cvCurrentChanged=function(e,t){this._syncSelection(!1)},t.prototype._syncSelection=function(e){if(this._cv&&this.selectionMode!=SelectionMode.None){var t=this._selHdl.selection,o=t.row>-1&&t.row-1){for(var t=this._cv.items[e];e-1?this.rows[o]:null;return i&&(i instanceof GroupRow||null==i.dataItem)?o:-1}return this.selection.row},t.prototype._getCvIndex=function(e){if(this._cv&&e>-1&&e-1;e--)if(t[e]===o)return e}return-1},t.prototype._findRow=function(e){for(var t=0;t0,this._rcBounds=null}this._eTL.style.top=this._eCHdr.style.top=e?-o+"px":"",wjcCore.toggleClass(this._eTL,t._WJS_STICKY,e),wjcCore.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._scroll.bind(this),!0):this.removeEventListener(window,"scroll"))},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;wjcCore.contains(e.target,this.hostElement)&&(this._clipToScreen&&(this._afClip&&cancelAnimationFrame(this._afClip),this._afClip=requestAnimationFrame(function(){t._afClip=null,t.finishEditing(),t._updateContent(!0)})),this._stickyHdr&&(this._afSticky&&cancelAnimationFrame(this._afSticky),this._afSticky=requestAnimationFrame(function(){t._afSticky=null;var e=new wjcCore.CancelEventArgs;t.onUpdatingLayout(e)&&(t._updateStickyHeaders(),t.onUpdatedLayout(e))})))},t.prototype._updateScrollPosition=function(){var e=this._root,o=e.scrollTop,i=e.scrollLeft;this.rightToLeft&&"rev"==t._getRtlMode()&&(i=e.scrollWidth-e.clientWidth-i);var r=new wjcCore.Point(-Math.abs(i),-o);return!this._ptScrl.equals(r)&&(this._ptScrl=r,this.onScrollPositionChanged(),!0)},t.prototype._updateContent=function(e,t){var o=this,i=this._root,r=this.hostElement,n=this.cells.hostElement,s=wjcCore.getActiveElement(),l=wjcCore.contains(r,s)?s:null,a=this._activeCell,c=new wjcCore.CancelEventArgs;if(this.onUpdatingView(c)){wjcCore.setAttribute(n,"role",this.rows.maxGroupLevel<0?"grid":"treegrid"),this._hasValidation=wjcCore.isFunction(this._itemValidator)||this._cv&&wjcCore.isFunction(this._cv.getError);var h=!t&&this._errorTip&&this._errorTip._tips.length;if(this._offsetY=0,this._heightBrowser>this._szClient.height){var u=Math.round(-this._ptScrl.y/(this._heightBrowser-this._szClient.height)*100)/100;this._offsetY=Math.round(this._maxOffsetY*u)}this._updateScrollPosition();var d=this._gpCells._updateContent(e,t,this._offsetY);if(this._hdrVis&HeadersVisibility.Column&&(!t||this._ssHdr&HeadersVisibility.Column)&&this._gpCHdr._updateContent(e,t,0),this._hdrVis&HeadersVisibility.Row&&(!t||this._ssHdr&HeadersVisibility.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 g=this._selHdl.selection,p=this._eMarquee;if(this.isRangeValid(g)){var f=this._getMarqueeRect(g),w=p.firstChild,_=p.offsetWidth-w.offsetWidth,C=p.offsetHeight-w.offsetHeight;wjcCore.setCss(p,{left:f.left+n.offsetLeft-_/2,top:f.top+n.offsetTop-C/2,width:f.width+_,height:f.height+C,visibility:f.width>0&&f.height>0?"":"collapse"})}else wjcCore.setCss(p,{left:0,top:0,width:0,height:0,visibility:"collapse"})}if(h&&this._errorTip&&this._errorTip._tips.length&&(this._toErrorTips&&clearTimeout(this._toErrorTips),this._toErrorTips=setTimeout(function(){o._errorTip.hide();for(var e=o._errorTip._tips,t=0;t=0,n=0;n=n&&i.top=n&&r.bottom=l&&i.right>s.left&&(i.left=s.left-i.width),e.rightCol>=l&&r.left>s.left&&(r.left=s.left)):(e.leftCol>=l&&i.left=l&&r.right0&&this.showGroups)for(i=0;i0}return!1},t.prototype._wantsInput=function(e){return this._isInputElement(e)&&!this.activeEditor&&!this._edtHdl._isNativeCheckbox(e)&&!wjcCore.hasClass(e,"wj-grid-ime")&&wjcCore.contains(document.body,e)},t._getMaxSupportedCssHeight=function(){if(!t._maxCssHeight){var e=335e5;wjcCore.isIE()?e=15e5:wjcCore.isFirefox()&&(e=175e5),t._maxCssHeight=e}return t._maxCssHeight},t._getRtlMode=function(){if(!t._rtlMode){var e=wjcCore.createElement('');document.body.appendChild(e);var o=e.scrollLeft;e.scrollLeft=-1e3;var i=e.scrollLeft;wjcCore.removeChild(e),t._rtlMode=i<0?"neg":o>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='',t}(wjcCore.Control);exports.FlexGrid=FlexGrid;var CellRangeEventArgs=function(e){function t(t,o,i){var r=e.call(this)||this;return r._p=wjcCore.asType(t,GridPanel,!0),r._rng=wjcCore.asType(o,CellRange,!0),r._data=i,r}return __extends(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}(wjcCore.CancelEventArgs);exports.CellRangeEventArgs=CellRangeEventArgs;var FormatItemEventArgs=function(e){function t(t,o,i){var r=e.call(this,t,o)||this;return r._cell=wjcCore.asType(i,HTMLElement),r}return __extends(t,e),Object.defineProperty(t.prototype,"cell",{get:function(){return this._cell},enumerable:!0,configurable:!0}),t}(CellRangeEventArgs);exports.FormatItemEventArgs=FormatItemEventArgs;var CellEditEndingEventArgs=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._stayInEditMode=!1,t._refresh=!0,t}return __extends(t,e),Object.defineProperty(t.prototype,"stayInEditMode",{get:function(){return this._stayInEditMode},set:function(e){this._stayInEditMode=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"refresh",{get:function(){return this._refresh},set:function(e){this._refresh=wjcCore.asBoolean(e)},enumerable:!0,configurable:!0}),t}(CellRangeEventArgs);exports.CellEditEndingEventArgs=CellEditEndingEventArgs;var CellType;!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"}(CellType=exports.CellType||(exports.CellType={}));var GridPanel=function(){function e(e,t,o,i,r){this._offsetY=0,this._rng=new CellRange,this._g=wjcCore.asType(e,FlexGrid),this._ct=wjcCore.asInt(t),this._rows=wjcCore.asType(o,RowCollection),this._cols=wjcCore.asType(i,ColumnCollection),this._e=wjcCore.asType(r,HTMLElement),this._vrb=new CellRange}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,o){var i,r=this._g,n=this._rows[wjcCore.asNumber(e,!1,!0)],s=null;if(wjcCore.isString(t)&&(t=this._cols.indexOf(t))<0)throw"Invalid column name or binding.";i=this._cols[wjcCore.asNumber(t,!1,!0)];var l=r?r._getBindingColumn(this,e,i):i,a=null;if(n instanceof GroupRow&&n.dataItem instanceof wjcCore.CollectionViewGroup&&!r.childItemsPath&&(a=n.dataItem),l.binding&&n.dataItem&&!a?s=l._binding.getValue(n.dataItem):n._ubv&&(s=n._ubv[i._hash]),null==s)switch(this._ct){case CellType.ColumnHeader:e!=this._rows.length-1&&l==i||(s=l.header);break;case CellType.ColumnFooter:if(l.aggregate!=wjcCore.Aggregate.None&&n instanceof GroupRow){var c=this._g.collectionView;if(c){var h=wjcCore.tryCast(c,wjcCore.CollectionView);s=h?h.getAggregate(l.aggregate,l.binding):wjcCore.getAggregate(l.aggregate,c.items,l.binding)}}break;case CellType.Cell:l.aggregate!=wjcCore.Aggregate.None&&n instanceof GroupRow&&a&&(s=a.getAggregate(l.aggregate,l.binding,this._g.collectionView))}return o&&(this.cellType==CellType.Cell&&l.dataMap&&(s=l.dataMap.getDisplayValue(s)),s=null!=s?wjcCore.Globalize.format(s,l.format||n.format):""),s},e.prototype.setCellData=function(e,t,o,i,r){void 0===i&&(i=!0),void 0===r&&(r=!0);var n,s=this._rows[wjcCore.asNumber(e,!1,!0)];if(wjcCore.isString(t)&&(t=this._cols.indexOf(t))<0)throw"Invalid column name or binding.";n=this._cols[wjcCore.asNumber(t,!1,!0)];var l=this._g?this._g._getBindingColumn(this,e,n):n;if(this._ct==CellType.Cell){if(l.dataMap&&null!=o&&(l.isRequired||""!=o)){var a=l.dataMap,c=a.getKeyValue(o);if(null==c&&null==a.getDisplayValue(null)){if(a.getDisplayValue(o)!=o);else if(!a.isEditable||a.displayMemberPath!=a.selectedValuePath)return!1}else o=c}var h=wjcCore.DataType.Object,u=l.dataType||s.dataType;if(u)h=u;else{var d=this.getCellData(e,t,!1);h=wjcCore.getType(d)}var g=l.getIsRequired(s),p=""===o||null==o;if(!g&&p)h!=wjcCore.DataType.String&&(o=null),i=!1;else if(g&&p&&i)return!1;if(i&&(o=wjcCore.changeType(o,h,l.format||s.format),h!=wjcCore.DataType.Object&&wjcCore.getType(o)!=h))return!1}if(s.dataItem&&l.binding){var f=l._binding,w=s.dataItem,_=f.getValue(w);if(o!==_&&!wjcCore.DateTime.equals(o,_)){f.setValue(w,o);var C=this._g.collectionView;if(C instanceof wjcCore.CollectionView&&w!=C.currentEditItem){var m=new wjcCore.NotifyCollectionChangedEventArgs(wjcCore.NotifyCollectionChangedAction.Change,w,C.items.indexOf(w));C.onCollectionChanged(m)}}}else s._ubv||(s._ubv={}),s._ubv[n._hash]=o;return r&&this._g&&this._g.invalidate(),!0},e.prototype.getCellBoundingRect=function(e,t,o){var i=this._g,r=this.rows[e],n=this.columns[t],s=new wjcCore.Rect(n.pos,r.pos,n.renderSize,r.renderSize);if(i.rightToLeft&&(s.left=this.hostElement.clientWidth-s.right,wjcCore.isIE()||wjcCore.isFirefox()||(s.left-=i._root.offsetWidth-i._root.clientWidth)),!o){var l=this.hostElement.getBoundingClientRect();s.left+=l.left,s.top+=l.top-this._offsetY}return e-1;f++)p=this._renderRow(f,u,t,p);for(;r.childElementCount>p;){var w=r.lastElementChild;r.removeChild(w),this._removeExtraCells(w,0)}return this._activeCell},e.prototype._clearCells=function(){for(var e=this.hostElement,t=e.childElementCount-1;t>=0;t--){var o=e.children[t];e.removeChild(o);for(var i=o.childElementCount-1;i>=0;i--)this._cf.disposeCell(o.children[i])}},e.prototype._reorderCells=function(e,t){if(this._g._reorderCells&&t.isValid&&e.isValid&&e.intersects(t)){if(e.row!=t.row){var o=this._e,i=e.row-t.row,r=Math.max(1,e.rowSpan-1);if(0!=i&&Math.abs(i)0){var l=n,a=Math.min(n+i,s-1);(u=this._createRange(o,l,a))&&an){d=o.children[n];o.insertBefore(u.extractContents(),d)}}}}if(e.col!=t.col){var o=this._e,i=e.col-t.col,r=Math.max(1,e.columnSpan-1);if(0!=i&&Math.abs(i)0){var l=n,a=Math.min(n+i,s-1);(u=this._createRange(h,l,a))&&an){var d=h.children[n];h.insertBefore(u.extractContents(),d)}}}}}}}},e.prototype._createRange=function(e,t,o){if(o>t&&o<=e.children.length&&t>-1){this._docRange||(this._docRange=document.createRange());var i=this._docRange;return i.setStart(e,t),i.setEnd(e,o),i}return null},e.prototype._renderColHdrRow=function(e,t){if(t)return 1;var o=this._e.children[0];o||(o=wjcCore.createElement('',this._e));var i=this._g,r=i?i.columnHeaders.rows.ariaLabel:null;wjcCore.setAttribute(o,"aria-label",r),wjcCore.setAttribute(o,"aria-selected",null);var n=0,s=this._g._getRowHeaderPath();s&&(n=this._renderRowHdrCell(o,-1,s.path));for(l=0;l-1;l++)n=this._renderColHdrCell(o,l,e,t,n);return this._removeExtraCells(o,n),1},e.prototype._renderColHdrCell=function(t,o,i,r,n){var s=this.grid,l=this.columns[o];if(l.renderSize<=0)return n;if(r)return n+1;var a=t.children[n];if(a||(a=wjcCore.createElement('',t)),wjcCore.setAttribute(a,"role","columnheader"),a&&this._recycle&&s._lazyRender){var c=a[e._INDEX_KEY];if(c&&-1==c.row&&c.col==o&&o>=this.columns.frozen)return n+1}if(a.textContent=this.columns[o].header,wjcCore.setCss(a,{position:"fixed",left:l.pos,top:-32e3,width:l.renderWidth,height:.1,overflow:"hidden",opacity:"0",pointerEvents:"none"}),l.describedById||this.columns.describedById){var h=[l.describedById,this.columns.describedById].join(" ").trim();wjcCore.setAttribute(a,"aria-describedby",h||null)}if(s.allowSorting){var u="none";switch(s._getBindingColumn(this,0,l).currentSort){case"+":u="ascending";break;case"-":u="descending"}wjcCore.setAttribute(a,"aria-sort",u)}return s.isReadOnly||(wjcCore.setAttribute(a,"aria-readonly",l.isReadOnly),wjcCore.setAttribute(a,"aria-required",l.getIsRequired())),a[e._INDEX_KEY]={row:-1,col:o,panel:this},n+1},e.prototype._renderRowHdrCell=function(t,o,i){var r=t.children[0];return r||(r=wjcCore.createElement('',t)),r.setAttribute("role",o<0?"columnheader":"rowheader"),r.textContent=i?i.toString():"",wjcCore.setCss(r,{position:"fixed",left:-32e3,top:-32e3,width:.1,height:.1,overflow:"hidden",opacity:"0"}),r[e._INDEX_KEY]={row:o,col:-1,panel:this},1},e.prototype._renderRow=function(e,t,o,i){var r=this._g,n=this.rows[e];if(n.renderSize<=0)return i;var s=this._e.children[i];if(s||(s=wjcCore.createElement('',this._e)),this._ct==CellType.Cell){s.setAttribute("role","row");var l=SelectionMode;switch(r.selectionMode){case l.Row:case l.RowRange:case l.ListBox:var a=n.isSelected||this._g._selHdl.selection.containsRow(e);wjcCore.setAttribute(s,"aria-selected",!!a)}wjcCore.setAttribute(s,"aria-level",n instanceof GroupRow?n.level+1:null),wjcCore.setAttribute(s,"aria-expanded",n instanceof GroupRow?!n.isCollapsed:null),this.rows.ariaLabel&&wjcCore.setAttribute(s,"aria-label",this.rows.ariaLabel)}var c=0;if(this._ct==CellType.Cell){var h=this._g._getRowHeaderPath();h&&(c=this._renderRowHdrCell(s,e,h.getValue(n.dataItem)))}for(u=0;u-1;u++)c=this._renderCell(s,e,u,t,o,c);return this._removeExtraCells(s,c),i+1},e.prototype._renderCell=function(t,o,i,r,n,s){var l=this._g,a=l.getMergedRange(this,o,i);if(a){for(c=Math.max(r.row,a.row);c=this.rows.frozen&&i>=this.columns.frozen&&(n=!0)}var g=SelectedState,p=this.getSelectedState(o,i,a),f=p==g.Cursor||p==g.Active;return u&&n?(wjcCore.toggleClass(u,"wj-state-active",f),wjcCore.toggleClass(u,"wj-state-selected",p==g.Cursor),wjcCore.toggleClass(u,"wj-state-multi-selected",p==g.Selected),wjcCore.setAttribute(u,"aria-selected",f||p!=g.None),f&&(this._activeCell=u),s+1):(u||((u=document.createElement("div")).tabIndex=-1,t.appendChild(u)),f&&(this._activeCell=u),this._ct==CellType.Cell&&(wjcCore.setAttribute(u,"role","gridcell"),wjcCore.setAttribute(u,"aria-selected",p!=g.None||f),wjcCore.setAttribute(u,"aria-readonly",!l.canEditCell(o,i)||null),wjcCore.setAttribute(u,"aria-required",h.getIsRequired())),l.cellFactory.updateCell(this,o,i,u,a),u[e._INDEX_KEY]={row:o,col:i,rng:a,panel:this},s+1)},e.prototype._removeExtraCells=function(e,t){for(;e.childElementCount>t;){var o=e.lastElementChild;e.removeChild(o),this._cf.disposeCell(o)}},e.prototype._getViewRange=function(){var e=this._g,t=e._ptScrl,o=this._rows,i=this._cols,r=new CellRange(0,0,o.length-1,i.length-1);if(this._ct==CellType.Cell||this._ct==CellType.RowHeader){var n=-t.y+this._offsetY,s=e._szClient.height;if((h=Math.min(o.frozen,o.length-1))>0&&(n+=u=o[h-1].pos,s-=u),r.row=Math.min(o.length-1,Math.max(o.frozen,o.getItemAt(n+1))),r.row2=o.getItemAt(n+s),e._clipToScreen){var l=e.hostElement.getBoundingClientRect();l.top<0&&(r.row=Math.max(r.row,o.getItemAt(-l.top-e._ptScrl.y)-1)),l.bottom>innerHeight&&(r.row2=Math.min(r.row2,o.getItemAt(-l.top-e._ptScrl.y+innerHeight)+1))}}if(this._ct==CellType.Cell||this._ct==CellType.ColumnHeader){var a=-t.x,c=e._szClient.width,h=Math.min(i.frozen,i.length-1);if(h>0){var u=i[h-1].pos;a+=u,c-=u}r.col=Math.min(i.length-1,Math.max(i.frozen,i.getItemAt(a+1))),r.col2=i.getItemAt(a+c)}return o.length<=o.frozen&&(r.row=r.row2=-1),i.length<=i.frozen&&(r.col=r.col2=-1),r},e.prototype._getFrozenPos=function(){var e=this._rows.frozen,t=this._cols.frozen,o=e>0?this._rows[e-1]:null,i=t>0?this._cols[t-1]:null,r=o?o.pos+o.renderSize:0,n=i?i.pos+i.renderSize:0;return new wjcCore.Point(n,r)},e._INDEX_KEY="wj-cell-index",e}();exports.GridPanel=GridPanel;var CellFactory=function(){function e(){}return e.prototype.updateCell=function(t,o,i,r,n,s){var l=t.grid,a=l.rightToLeft,c=CellType,h=t.rows,u=t.columns,d=h[o],g=u[i],p=o,f=i,w=d instanceof GroupRow?d:null,_=d instanceof _NewRowTemplate?d:null,C=g.renderWidth,m=d.renderHeight,y=t.cellType,v="wj-cell",b="",j={display:""};if(0!=s&&r.firstElementChild&&(1==r.childNodes.length&&"checkbox"==r.firstElementChild.type||(r.textContent="")),n&&!n.isSingleCell){o=n.row,i=n.col,p=n.row2,f=n.col2,d=h[o],g=u[i],w=d instanceof GroupRow?d:null;var R=n.getRenderSize(t);m=R.height,C=R.width}var S=l._getBindingColumn(t,o,g),E=S.dataType||d.dataType,x=S.dataMap&&0!=S.showDropDown||d.dataMap&&0!=d.showDropDown,z=E==wjcCore.DataType.Boolean&&!x,T=g.pos,H=d.pos;l._useFrozenDiv()&&y==c.Cell&&!l.editRange?(o=u.frozen&&(T+=l._ptScrl.x),i=h.frozen&&(H+=l._ptScrl.y)):(o-1&&i==l.columns.firstVisibleIndex&&l.treeIndent){var D=w?Math.max(0,w.level):l.rows.maxGroupLevel+1,O=l.treeIndent*D+l._cellPadLeft;a?j.paddingRight=O+"px":j.paddingLeft=O+"px"}if(0!=s){var N=t.getCellData(o,i,!1),B=t.getCellData(o,i,!0);if(y==c.Cell&&i==l.columns.firstVisibleIndex&&w&&w.hasChildren&&!this._isEditingCell(l,o,i)){Q=this._getTreeBtn(w);B=wjcCore.escapeHtml(B)||w.getGroupHeader(),r.innerHTML=Q.outerHTML+" "+B,b=""}else if(y==c.ColumnHeader&&S.currentSort&&l.showSort&&(p==l._getSortRowIndex()||S!=g))v+=" wj-sort-"+("+"==S.currentSort?"asc":"desc"),r.innerHTML=wjcCore.escapeHtml(B)+" "+this._getSortIcon(S);else if(y!=c.RowHeader||i!=l._getEditColumnIndex()||B)if(y!=c.Cell||E!=wjcCore.DataType.Boolean||x||w&&!wjcCore.isBoolean(N))if(y==c.Cell&&this._isEditingCell(l,o,i)){var F=S.inputType||d.inputType;if(F||(F=E!=wjcCore.DataType.Number||x?"text":"tel"),!x&&!S.mask&&!d.mask){var k=t.getCellData(o,i,!1);if(wjcCore.isNumber(k)){var V=k.toString(),G=S.format||d.format;if(G&&k!=Math.round(k)){var K=V.match(/\.(\d+)/)[1].length;G=G.replace(/([a-z])(\d*)(.*)/gi,"$01"+K+"$3")}B=wjcCore.Globalize.formatNumber(k,G,!0)}}r.innerHTML=(S.multiLine||d.multiLine)&&"checkbox"!=F?'':'';var W=r.children[0];wjcCore.addClass(W,"wj-grid-editor wj-form-control"),wjcCore.disableAutoComplete(W),W.value=B,W.required=S.getIsRequired(d),wjcCore.setAttribute(W,"aria-required",W.required);var q=S.maxLength||d.maxLength;q&&(W.maxLength=q),W.style.textAlign=S.getAlignment(d);var U=S.mask||d.mask;U&&new wjcCore._MaskProvider(W,U),l._edtHdl._edt=W}else y==c.Cell&&(d.isContentHtml||S.isContentHtml)?r.innerHTML=B:r.textContent=B||"";else{var Y=r.firstChild;Y instanceof HTMLInputElement&&"checkbox"==Y.type||(r.innerHTML='',Y=r.firstChild),Y.checked=1==N,Y.indeterminate=null==N,Y.disabled=!l.canEditCell(o,i),Y.disabled&&(Y.style.cursor="default"),l.editRange&&l.editRange.contains(o,i)&&(l._edtHdl._edt=Y)}else{var J=l.editableCollectionView,X=J?J.currentEditItem:null;X&&d.dataItem==X?r.innerHTML='':d instanceof _NewRowTemplate&&(r.innerHTML='')}if(y==c.Cell&&x&&tryGetModuleWijmoInput()&&l.showDropDown&&l.canEditCell(o,i)){if(!e._ddBtn){var Z=e._WJC_DROPDOWN,Q=wjcCore.createElement('');wjcCore.setAriaLabel(Q,wjcCore.culture.FlexGrid.ariaLabels.toggleDropDown),wjcCore.setAttribute(Q,"aria-expanded",!1),e._ddBtn=Q}var $=e._ddBtn.cloneNode(!0);r.appendChild($)}}if(y==c.RowHeader||y==c.ColumnHeader){var ee=y==c.RowHeader?!w&&!_&&d.allowDragging&&0!=(l.allowDragging&AllowDragging.Rows):g.allowDragging&&0!=(l.allowDragging&AllowDragging.Columns);wjcCore.setAttribute(r,"draggable",ee?"true":null)}v+=b,r.className!=v&&(r.className=v);var te=r.style;for(var oe in j)te[oe]!==j[oe]&&(te[oe]=j[oe]);if(l._edtHdl._edt&&l._edtHdl._edt.parentElement==r){var ie=l._root,re=ie.getBoundingClientRect(),ne=r.getBoundingClientRect(),se=re.top+ie.clientHeight-ne.top,le=re.left+ie.clientWidth-ne.left;ne.height>se&&(r.style.height=se+"px"),ne.width>le&&(r.style.width=le+"px")}if((y==c.Cell||y==c.RowHeader)&&l._getShowErrors()){var ae=l._getError(t,o,i);l._edtHdl._setCellError(r,ae)}if(l.itemFormatter&&l.itemFormatter(t,o,i,r),l.formatItem.hasHandlers){var ce=e._fmtRng;ce?ce.setRange(o,i,p,f):ce=e._fmtRng=new CellRange(o,i,p,f);var he=new FormatItemEventArgs(t,ce,r);l.onFormatItem(he)}},e.prototype.disposeCell=function(e){},e.prototype.getEditorValue=function(e){var t=e._edtHdl._edt;if(t instanceof HTMLInputElement&&"checkbox"==t.type)return t.checked;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){var o=t.maxLength;return wjcCore.isNumber(o)&&o>-1&&t.value.length>o?t.value.substr(0,o):t.value}return null},e.prototype._isEditingCell=function(e,t,o){return e.editRange&&e.editRange.contains(t,o)},e.prototype._getTreeBtn=function(t){var o=e._WJC_COLLAPSE,i=(t.isCollapsed?"":"down-")+(t.grid.rightToLeft?"left":"right"),r=wjcCore.createElement('');return wjcCore.setAriaLabel(r,wjcCore.culture.FlexGrid.ariaLabels.toggleGroup),wjcCore.setAttribute(r,"aria-expanded",!t.isCollapsed),r},e.prototype._getSortIcon=function(e){return''},e._WJC_COLLAPSE="wj-elem-collapse",e._WJC_DROPDOWN="wj-elem-dropdown",e}();exports.CellFactory=CellFactory;var CellRange=function(){function e(e,t,o,i){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===o&&(o=e),void 0===i&&(i=t),this.setRange(e,t,o,i)}return e.prototype.setRange=function(e,t,o,i){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===o&&(o=e),void 0===i&&(i=t),this._row=wjcCore.asInt(e),this._col=wjcCore.asInt(t),this._row2=wjcCore.asInt(o),this._col2=wjcCore.asInt(i)},Object.defineProperty(e.prototype,"row",{get:function(){return this._row},set:function(e){this._row=wjcCore.asInt(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"col",{get:function(){return this._col},set:function(e){this._col=wjcCore.asInt(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"row2",{get:function(){return this._row2},set:function(e){this._row2=wjcCore.asInt(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"col2",{get:function(){return this._col2},set:function(e){this._col2=wjcCore.asInt(e)},enumerable:!0,configurable:!0}),e.prototype.clone=function(){return new e(this._row,this._col,this._row2,this._col2)},e.prototype.copy=function(e){this.setRange(e._row,e._col,e._row2,e._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,o){var i=wjcCore.tryCast(t,e);if(i)return i.topRow>=this.topRow&&i.bottomRow<=this.bottomRow&&i.leftCol>=this.leftCol&&i.rightCol<=this.rightCol;if(wjcCore.isInt(t)&&wjcCore.isInt(o))return t>=this.topRow&&t<=this.bottomRow&&o>=this.leftCol&&o<=this.rightCol;throw"contains expects a CellRange or row/column indices."},e.prototype.containsRow=function(e){return wjcCore.asInt(e)>=this.topRow&&e<=this.bottomRow},e.prototype.containsColumn=function(e){return wjcCore.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.bottomRowe.bottomRow)},e.prototype.intersectsColumn=function(e){return e&&!(this.rightCole.rightCol)},e.prototype.getRenderSize=function(e){var t=new wjcCore.Size(0,0);if(this.isValid){for(var o=this.topRow;o<=this.bottomRow;o++)t.height+=e.rows[o].renderSize;for(var i=this.leftCol;i<=this.rightCol;i++)t.width+=e.columns[i].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}();exports.CellRange=CellRange;var RowColFlags;!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.MultiLine=4096]="MultiLine",e[e.HasTemplate=8192]="HasTemplate",e[e.RowDefault=3]="RowDefault",e[e.ColumnDefault=23]="ColumnDefault"}(RowColFlags=exports.RowColFlags||(exports.RowColFlags={}));var RowCol=function(){function e(){this._list=null,this._pos=0,this._idx=-1,this._vidx=-1,this.gridChanged=new wjcCore.Event}return Object.defineProperty(e.prototype,"dataType",{get:function(){return this._type},set:function(e){e=wjcCore.asEnum(e,wjcCore.DataType,!0),this._type!=e&&(this._type=e,this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputType",{get:function(){return this._inpType},set:function(e){this._inpType=wjcCore.asString(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mask",{get:function(){return this._mask},set:function(e){this._mask=wjcCore.asString(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxLength",{get:function(){return this._maxLen},set:function(e){this._maxLen=wjcCore.asNumber(e,!0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"align",{get:function(){return this._align},set:function(e){this._align!=e&&(this._align=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"format",{get:function(){return this._fmt},set:function(e){this._fmt!=e&&(this._fmt=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map!=e&&(this._map&&this._map.mapChanged.removeHandler(this.onPropertyChanged,this),wjcCore.isArray(e)&&(e=new DataMap(e,null,null)),this._map=wjcCore.asType(e,DataMap,!0),this._map&&this._map.mapChanged.addHandler(this.onPropertyChanged,this),this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showDropDown",{get:function(){return this._showDropDown},set:function(e){e!=this._showDropDown&&(this._showDropDown=wjcCore.asBoolean(e,!0),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dropDownCssClass",{get:function(){return this._ddCssClass},set:function(e){this._ddCssClass=wjcCore.asString(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"visible",{get:function(){return this._getFlag(RowColFlags.Visible)},set:function(e){this._setFlag(RowColFlags.Visible,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return!!this._getFlag(RowColFlags.Visible)&&(!this._getFlag(RowColFlags.ParentCollapsed)||this instanceof _NewRowTemplate)},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=wjcCore.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=t.defaultSize),null!=t.minSize&&et.maxSize&&(e=t.maxSize)),null!=this._szMin&ðis._szMax&&(e=this._szMax),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allowResizing",{get:function(){return this._getFlag(RowColFlags.AllowResizing)},set:function(e){this._setFlag(RowColFlags.AllowResizing,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allowDragging",{get:function(){return this._getFlag(RowColFlags.AllowDragging)},set:function(e){this._setFlag(RowColFlags.AllowDragging,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allowMerging",{get:function(){return this._getFlag(RowColFlags.AllowMerging)},set:function(e){this._setFlag(RowColFlags.AllowMerging,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSelected",{get:function(){return this._getFlag(RowColFlags.Selected)},set:function(e){if(this._setFlag(RowColFlags.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(RowColFlags.ReadOnly)},set:function(e){this._setFlag(RowColFlags.ReadOnly,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isRequired",{get:function(){return this._required},set:function(e){this._required=wjcCore.asBoolean(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isContentHtml",{get:function(){return this._getFlag(RowColFlags.HtmlContent)},set:function(e){this.isContentHtml!=e&&(this._setFlag(RowColFlags.HtmlContent,e),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wordWrap",{get:function(){return this._getFlag(RowColFlags.WordWrap)},set:function(e){this._setFlag(RowColFlags.WordWrap,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"multiLine",{get:function(){return this._getFlag(RowColFlags.MultiLine)},set:function(e){this._setFlag(RowColFlags.MultiLine,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cssClass",{get:function(){return this._cssClass},set:function(e){e!=this._cssClass&&(this._cssClass=wjcCore.asString(e),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cssClassAll",{get:function(){return this._cssClassAll},set:function(e){e!=this._cssClassAll&&(this._cssClassAll=wjcCore.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.onGridChanged=function(e){this.gridChanged.raise(this,e)},e.prototype._setList=function(e){e!=this._list&&(this._list=e,this.onGridChanged())},e.prototype._getFlag=function(e){return 0!=(this._f&e)},e.prototype._setFlag=function(e,t,o){return t!=this._getFlag(e)&&(this._f=t?this._f|e:this._f&~e,o||this.onPropertyChanged(),!0)},e}();exports.RowCol=RowCol;var Column=function(e){function t(o){var i=e.call(this)||this;return i._f=RowColFlags.ColumnDefault,i._hash=t._ctr.toString(36),t._ctr++,o&&wjcCore.copy(i,o),i}return __extends(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,"binding",{get:function(){return this._binding?this._binding.path:null},set:function(e){if(e!=this.binding){var t=wjcCore.asString(e);if(this._binding=t?new wjcCore.Binding(t):null,!this._type&&this.grid&&this._binding){var o=this.grid.collectionView;if(o&&o.sourceCollection&&o.sourceCollection.length){var i=o.sourceCollection[0];this._type=wjcCore.getType(this._binding.getValue(i))}}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=wjcCore.asString(e);this._bindingSort=t?new wjcCore.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=wjcCore.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=wjcCore.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=wjcCore.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=wjcCore.asBoolean(e,!0)},enumerable:!0,configurable:!0}),t.prototype._getQuickAutoSize=function(){return!!this.grid._getQuickAutoSize()&&(wjcCore.isBoolean(this._quickSize)?this._quickSize:!(this.isContentHtml||this.wordWrap||this.multiLine||this._getFlag(RowColFlags.HasTemplate)))},Object.defineProperty(t.prototype,"renderWidth",{get:function(){return this.renderSize},enumerable:!0,configurable:!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,"allowSorting",{get:function(){return this._getFlag(RowColFlags.AllowSorting)},set:function(e){this._setFlag(RowColFlags.AllowSorting,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentSort",{get:function(){var e=this.grid?this.grid.collectionView:null,t=e?e.sortDescriptions:null,o=t&&t.length?this._getBindingSort():null;if(o)for(var i=0;i0:!e||e.dataType!=wjcCore.DataType.String||(null!=e.dataMap||null!=e.mask&&e.mask.length>0)},t.prototype.getAlignment=function(e){if(null!=this._align)return this._align;if(e&&null!=e.align)return e.align;if(!this._map)switch(this.dataType){case wjcCore.DataType.Boolean:return"center";case wjcCore.DataType.Number:return"right"}if(e&&!e.dataMap)switch(e.dataType){case wjcCore.DataType.Boolean:return"center";case wjcCore.DataType.Number:return"right"}return""},t.prototype._getBindingSort=function(){return this.sortMemberPath?this.sortMemberPath:this.binding?this.binding:null},t._parseStarSize=function(e){if(wjcCore.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}(RowCol);exports.Column=Column;var Row=function(e){function t(t){var o=e.call(this)||this;return o._f=RowColFlags.ColumnDefault,o._data=t,o}return __extends(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}(RowCol);exports.Row=Row;var GroupRow=function(e){function t(){var t=e.call(this)||this;return t._level=-1,t.isReadOnly=!0,t}return __extends(t,e),Object.defineProperty(t.prototype,"level",{get:function(){return this._level},set:function(e){wjcCore.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.indexthis.level)}return!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isCollapsed",{get:function(){return this._getFlag(RowColFlags.Collapsed)},set:function(e){wjcCore.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||wjcCore.culture.FlexGrid.groupHeaderFormat,o=wjcCore.tryCast(this.dataItem,wjcCore.CollectionViewGroup);if(o&&t&&e.showGroups&&!e.childItemsPath){var i=o.groupDescription.propertyName,r=o.name,n=e.getColumn(i),s=this.isContentHtml;n?(s=s||n.isContentHtml,n.header&&(i=n.header),n.dataMap?r=n.dataMap.getDisplayValue(r):n.format&&(r=wjcCore.Globalize.format(r,n.format))):i=wjcCore.toHeaderCase(i);var l=o.getAggregate(wjcCore.Aggregate.CntAll,null,e.collectionView);return wjcCore.format(t,{name:wjcCore.escapeHtml(i),value:s?r:wjcCore.escapeHtml(r),level:o.level,count:l})}return""},t.prototype._setCollapsed=function(e){var o=this,i=this.grid,r=i.rows,n=this.getCellRange(),s=new CellRangeEventArgs(i.cells,new CellRange(this.index,-1));i.onGroupCollapsedChanging(s)&&(i.deferUpdate(function(){r.deferUpdate(function(){o._setFlag(RowColFlags.Collapsed,e,!0);for(var i=n.topRow+1;i<=n.bottomRow&&i>-1&&i0&&this[0].renderSize)return 0;e=Math.round(e);for(var t,o,i=this.length,r=0,n=i-1;r<=n;)if(t=r+n>>>1,(o=this[t])._pos>e&&t>0)n=t-1;else{if(!(o._pos+o.renderSize<=e&&t0&&!this[t].renderSize;)t--;for(;t0)return i;break;case r.Prev:for(i=e-1;i>=0;i--)if(this[i].renderSize>0)return i;break;case r.End:for(i=this.length-1;i>=0;i--)if(this[i].renderSize>0)return i;break;case r.Home:for(i=0;i0)return i;break;case r.NextPage:return(i=this.getItemAt(this[e].pos+this[e].renderSize+o))<0?this.getNextCell(e,SelMove.End,o):i==e&&i0&&this[i-1].renderSize?i-1:i}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 o=Math.min(e,t),i=Math.max(e,t),r=o;r<=i;r++)if(!this[r].allowDragging)return!1;return!(this[t]instanceof _NewRowTemplate)},t.prototype.moveElement=function(e,t){if(this.canMoveElement(e,t)){var o=this[e];this.removeAt(e),t<0&&(t=this.length),this.insert(t,o)}},t.prototype.onCollectionChanged=function(t){void 0===t&&(t=wjcCore.NotifyCollectionChangedEventArgs.reset),this._dirty=!0,this._g.invalidate(),e.prototype.onCollectionChanged.call(this,t)},t.prototype.push=function(t){return t._setList(this),e.prototype.push.call(this,t)},t.prototype.splice=function(t,o,i){for(var r=0;r0&&(t+=o,e++,r-1?this[t]:null},t.prototype.indexOf=function(t){if(t instanceof Column)return e.prototype.indexOf.call(this,t);for(o=0;o0?n._sz=r:(n._sz=Math.max(0,Math.round(Column._parseStarSize(n._szStar)/o*e)),r-=n.renderWidth))}return this._dirty=!0,this._update(),!0}return!1},t}(RowColCollection);exports.ColumnCollection=ColumnCollection;var RowCollection=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._maxLevel=-1,t}return __extends(t,e),Object.defineProperty(t.prototype,"ariaLabel",{get:function(){return this._ariaLabel},set:function(e){e!=this.ariaLabel&&(this._ariaLabel=wjcCore.asString(e),this._g&&this._g.refresh())},enumerable:!0,configurable:!0}),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;tthis._maxLevel&&(this._maxLevel=o.level)}return!0}return!1},t}(RowColCollection);exports.RowCollection=RowCollection;var HitTestInfo=function(){function e(t,o){this._row=-1,this._col=-1,this._edge=0;var i;if(o instanceof Element){if(wjcCore.closest(o,".wj-flexgrid")!=t.hostElement)return;t=o}if(!(t instanceof Element)||t instanceof FlexGrid){if(t instanceof FlexGrid)i=this._g=t;else{if(!(t instanceof GridPanel))throw"First parameter should be a FlexGrid or GridPanel.";this._p=t,i=this._g=this._p.grid}o instanceof MouseEvent&&"mousedown"==o.type&&(i._rcBounds=null),o=wjcCore.mouseToPage(o),this._pt=o.clone();var r=i.controlRect,n=i._szClient,s=i.topLeftCells,l=i._eTL,a=i.headersVisibility,c=HeadersVisibility,h=a&c.Row?s.columns.getTotalSize():0,u=a&c.Column?s.rows.getTotalSize():0,d=a&c.Column?u+l.offsetTop:0,g=i._eBL,p=g.offsetHeight;if(o.x-=r.left,o.y-=r.top,this._g.rightToLeft&&(o.x=r.width-o.x),!this._p&&o.x>=0&&o.y>=l.offsetTop&&n&&o.x<=n.width+h&&o.y<=n.height+d&&(o.ym.y||m.y<=0)&&(o.y-=i._ptScrl.y,o.y+=this._p._getOffsetY())):_!=C.BottomLeft&&_!=C.ColumnFooter||(o.y-=g.offsetTop),_!=C.ColumnHeader&&_!=C.Cell&&_!=C.ColumnFooter||(o.x-=h,(o.x>m.x||m.x<=0)&&(o.x-=i._ptScrl.x)),_!=C.ColumnHeader&&_!=C.TopLeft||(o.y-=d-u),this._edge=0;var b=e._SZEDGE[this._g.isTouching?1:0];if(this._g.isTouching&&(b=e._SZEDGE[1],o.x-=b/2),this._row=o.y>y?-1:f.getItemAt(o.y),this._col=o.x>v?-1:w.getItemAt(o.x),this._row<0||this._col<0)return void(this._p=null);if(this._col>-1){var j=w[this._col];o.x-j.pos<=b&&(this._edge|=1),j.pos+j.renderSize-o.x<=b&&(this._edge|=4)}if(this._row>-1){var R=f[this._row];o.y-R.pos<=b&&(this._edge|=2),R.pos+R.renderSize-o.y<=b&&(this._edge|=8)}}}else{var S=wjcCore.closest(t,".wj-cell"),E=S?S[GridPanel._INDEX_KEY]:null;E&&(this._row=E.row,this._col=E.col,this._rng=E.rng,this._p=E.panel,this._g=E.panel.grid)}}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:CellType.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 CellRange(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}();exports.HitTestInfo=HitTestInfo;var AllowMerging;!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"}(AllowMerging=exports.AllowMerging||(exports.AllowMerging={}));var MergeManager=function(){function e(e){this._g=e}return e.prototype.getMergedRange=function(e,t,o,i){void 0===i&&(i=!0);var r=this._g,n=e.cellType,s=e.columns,l=e.rows,a=l[t],c=s[o];if(a instanceof _NewRowTemplate)return null;if(r.showGroups&&!r.childItemsPath&&a instanceof GroupRow&&a.dataItem instanceof wjcCore.CollectionViewGroup&&n==CellType.Cell){u=new CellRange(t,o);if(c.aggregate==wjcCore.Aggregate.None){for(;u.col>0&&s[u.col-1].aggregate==wjcCore.Aggregate.None&&u.col!=s.frozen;)u.col--;for(;u.col2=l.frozen?!i||n!=CellType.Cell&&n!=CellType.RowHeader||r._vtRows=g&&this._mergeCell(e,f,o,t,o);f--)u.row=f;for(var w=t+1;w<=p&&this._mergeCell(e,t,o,w,o);w++)u.row2=w;for(;u.row=s.frozen?!i||n!=CellType.Cell&&n!=CellType.ColumnHeader||r._vtCols=_&&this._mergeCell(e,t,m,t,o);m--)u.col=m;for(var y=o+1;y<=C&&this._mergeCell(e,t,o,t,y);y++)u.col2=y;for(;u.col0&&(n.allowMerging&&this._mergeCell(e,t,o-1,t,o)||s.allowMerging&&this._mergeCell(e,i,o-1,i,o)))return!1;if(r-1?this._cv.sourceCollection[o][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 o=t.length-1;o>=0;o--){var i=t[o],r=i[this._keyPath],n=i[this._displayPath];this._hash[r]=n}}var s=this._hash[e];return null!=s?s:e},e.prototype.getDisplayValues=function(e){var t=[];if(this._cv&&this._displayPath)for(var o=this._cv.items,i=0;i-1&&!o.rows[r.row].isSelected&&(l=!1),l)t&&this._showSelection();else{var a=this._e;if(a._rng=r,a.cancel=!1,o.onSelectionChanging(a)){if(n&&(r.row!=i.row||r.rowSpan>1||i.rowSpan>1)&&o.rows.forEach(function(e,t){e._setFlag(RowColFlags.Selected,r.containsRow(t),!0)}),r.row=Math.min(r.row,o.rows.length-1),r.row2=Math.min(r.row2,o.rows.length-1),this._sel.copy(r),o.refreshCells(!1,!0,!0),t&&this._showSelection(),o.collectionView){var c=o._getCvIndex(r.row);o.collectionView.moveCurrentToPosition(c)}o.onSelectionChanged(a)}}},e.prototype.moveSelection=function(e,t,o){var i=this._g,r=this._sel,n=o&&i.anchorCursor?new CellRange(r.row2,r.col2):new CellRange(r.row,r.col);this._adjustReferenceCell(n,e,t);var s=n.row,l=n.col,a=i.rows,c=i.columns,h=Math.max(0,i._szClient.height-i.columnHeaders.height),u=SelMove;switch(t){case u.NextCell:(l=c.getNextCell(l,u.Next,h))==n.col&&(s=a.getNextCell(s,u.Next,h))>n.row&&(l=c.getNextCell(0,u.Next,h),l=c.getNextCell(l,u.Prev,h)),i.select(s,l);break;case u.PrevCell:(l=c.getNextCell(n.col,u.Prev,h))==n.col&&(s=a.getNextCell(s,u.Prev,h))wjcCore.Key.Space)if(this._startEditing(!1,e)&&o.activeEditor){var r=wjcCore.getActiveElement();if(r instanceof HTMLInputElement&&"checkbox"!=r.type||r instanceof HTMLTextAreaElement){var n=o._selHdl.selection,s=o.getCellData(n.row,n.col,!0),l=o.getCellData(n.row,n.col,!1),a=wjcCore.culture.Globalize.numberFormat["%"]||"%",c=String.fromCharCode(e.charCode),h=wjcCore.isNumber(l)&&s.indexOf(a)>-1||""==s&&r.value==a;r.value=c+(h?a:""),wjcCore.setSelectionRange(r,1),r.dispatchEvent(i._evtInput),i._keypress(e),i._edtValue=r.value!=s?r.value:null,e.preventDefault()}}else if(o.autoSearch){var u=!1,n=o._selHdl.selection;if(e.charCode>32||32==e.charCode&&this._search){e.preventDefault(),this._search+=String.fromCharCode(e.charCode).toLowerCase(),this._toSearch&&clearTimeout(this._toSearch),this._toSearch=setTimeout(function(){t._toSearch=null,t._search=""},wjcCore.Control._SEARCH_DELAY);var d=this._findNext(n.row,n.col);d<0&&this._search.length>1&&(this._search=this._search[this._search.length-1],d=this._findNext(n.row,n.col)),d>-1&&(u=!0,o.select(d,n.col))}u||(this._search="")}}},e.prototype._findNext=function(e,t){var o=this._g,i=o.rows.length;(e<0||1==this._search.length)&&e++;for(var r=0;r-1&&c<=i.bottomRow;c++)n.push(r[c]);break;case a.ListBox:for(c=0;c-1&&n.push(r[i.topRow]);break;case a.RowRange:for(var c=i.topRow;c>-1&&c<=i.bottomRow;c++)n.push(r[c])}if(n.length>0){if(t.deferUpdate(function(){o&&o.beginUpdate();for(var e=n.length-1;e>=0;e--){var i=n[e];s.setRange(i.index,-1),t.onDeletingRow(l)&&(o&&i.dataItem?o.remove(i.dataItem):t.rows.removeAt(i.index),t.onDeletedRow(l))}o&&o.endUpdate()}),t.selectionMode==a.ListBox){var h=t.selection.row;h>-1&&h '),i(o,"mousedown",function(o){if(e._rcBounds=null,!o.defaultPrevented&&0==o.button){var l=o.target;if(!e.containsFocus()){var a=l instanceof HTMLElement&&l.tabIndex>-1?l:e._eFocus;e._setFocusNoScroll(a)}setTimeout(function(){o.defaultPrevented||e.focus()});var c=wjcCore.closest(l,".wj-flexgrid");if(c&&c!=e.hostElement||!e.activeEditor&&e._isInputElement(l)){var h=e.hitTest(o);switch(h.cellType){case CellType.Cell:e.select(h.range,!1),l instanceof HTMLElement&&"root"!=l.getAttribute("wj-part")&&l.focus();break;case CellType.ColumnHeader:case CellType.ColumnFooter:e.scrollIntoView(-1,h.col);break;case CellType.RowHeader:e.scrollIntoView(h.row,-1)}return}var u=document;r(u,"mousemove"),r(u,"mouseup"),i(u,"mousemove",n),i(u,"mouseup",s),t._isDown=!0,t._mousedown(o)}});var n=function(e){t._mousemove(e)},s=function(e){t._isDown=!1,r(document,"mousemove"),r(document,"mouseup"),t._mouseup(e)};i(o,"mouseup",function(e){t._tsLast=Date.now()}),i(o,"mouseenter",function(t){e._rcBounds=null}),i(o,"mousemove",this._hover.bind(this)),i(o,"dblclick",this._dblclick.bind(this)),i(o,"click",this._click.bind(this)),i(o,"selectstart",function(t){e._isInputElement(t.target)||t.preventDefault()}),i(o,"wheel",function(t){if(!t.defaultPrevented&&t.deltaY&&!t.ctrlKey&&!t.metaKey){var o=e._root,i=t.deltaY,r=0;if(o.scrollHeight>o.offsetHeight&&wjcCore.closest(t.target,".wj-flexgrid")==e.hostElement){switch(t.deltaMode){case 1:r=e.rows.defaultSize*(i<0?-1:1);break;case 2:r=o.clientHeight*(i<0?-1:1);break;case 0:default:wjcCore.isSafari()&&(i=wjcCore.clamp(i,-150,150)),r=i}e.hostElement.focus(),o.scrollTop+=r,t.preventDefault()}}}),i(o,"dragstart",this._dragstart.bind(this)),i(o,"dragover",this._dragover.bind(this)),i(o,"dragleave",this._dragover.bind(this)),i(o,"drop",this._drop.bind(this)),i(o,"dragend",this._dragend.bind(this)),this._enableTouchResizing()}return e.prototype.resetMouseState=function(){this._updating&&(this._updating=!1,this._g.endUpdate()),this._dragSrc&&wjcCore.removeClass(this._dragSrc,_WJC_DRAGSRC),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,t._rcBounds=null},e.prototype._enableTouchResizing=function(){var e=this,t=this._g,o=t.hostElement,i="ontouchstart"in window?["touchstart","touchmove","touchend"]:"onpointerdown"in window?["pointerdown","pointermove","pointerup"]:null;i&&(t.addEventListener(o,i[0],function(i){if((null==i.pointerType||"touch"==i.pointerType)&&!wjcCore.closest(i.target,".wj-elem-filter")){var r=wjcCore.closest(i.target,".wj-cell");r instanceof HTMLElement&&(t._rcBounds=null,e._htDown=null,e._hover(i),e._szRowCol&&(r.removeAttribute("draggable"),o.style.touchAction="none",e._mousedown(i),i.preventDefault()))}}),t.addEventListener(o,i[1],function(t){null!=t.pointerType&&"touch"!=t.pointerType||e._szRowCol&&(e._mousemove(t),t.preventDefault())}),t.addEventListener(o,i[2],function(t){if((null==t.pointerType||"touch"==t.pointerType)&&e._szRowCol){if(e._szArgs)e._finishResizing(e._eMouse);else{var i=wjcCore.closest(t.target,".wj-cell");i instanceof HTMLElement&&i.click()}e.resetMouseState(),o.style.touchAction=""}}))},e.prototype._mousedown=function(e){var t=this._g,o=t.hitTest(e),i=o.cellType,r=e.ctrlKey||e.metaKey,n=e.target,s=CellType;if(this._selDown=t.selection,o.panel==t.cells){if(wjcCore.closestClass(n,CellFactory._WJC_DROPDOWN))return t._edtHdl._toggleListBox(e,o.range),void e.preventDefault();if(t.editRange&&t.editRange.contains(o.range))return}var l=wjcCore.getActiveElement();if(n!=l||!t._isInputElement(n)){if(i==s.None)return t.finishEditing(),void(n!=t._root&&n!=t._fCt&&t._edtHdl._commitRowEdits());if(this._htDown=o,this._eMouse=e,null!=this._szRowCol)return l!=t._eFocus&&(t._eFocus.tabIndex=0,t._eFocus.focus()),void this._handleResizing(e);if(!(i==s.RowHeader&&o.edgeBottom&&t.allowResizing&AllowResizing.Rows&&this._getResizeRow(o))){switch(i){case s.Cell:case s.RowHeader:r&&t.selectionMode==SelectionMode.ListBox&&this._startListBoxSelection(o.row),this._mouseSelect(e,e.shiftKey),i==s.RowHeader&&0==(t.allowDragging&AllowDragging.Rows)&&(e.preventDefault(),t.focus())}if(i==s.Cell&&t.rows.maxGroupLevel>-1&&wjcCore.closestClass(n,CellFactory._WJC_COLLAPSE)){var a=wjcCore.tryCast(t.rows[o.row],GroupRow);if(a)return r?t.collapseGroupsToLevel(a.isCollapsed?a.level+1:a.level):a.isCollapsed=!a.isCollapsed,void this.resetMouseState()}}}},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 CellType.Cell:this._mouseSelect(e,!0);break;case CellType.RowHeader:0==(this._g.allowDragging&AllowDragging.Rows)&&this._mouseSelect(e,!0)}}},e.prototype._mouseup=function(e){if(!this._g.isTouching||!(this._dragSrc||e.target instanceof HTMLHtmlElement)){var t=this._g,o=t.hitTest(e),i=this._htDown,r=SelectionMode;if(i&&!e.defaultPrevented)if(this._szArgs)this._finishResizing(e);else if(i.panel!=t.topLeftCells||this._szArgs)i.panel!=t.columnHeaders||e.dataTransfer?i.panel==t.cells&&(this._szRowCol||e.ctrlKey||e.metaKey||e.shiftKey||o.panel==i.panel&&o.range.equals(i.range)&&t.selection.equals(this._selDown)&&t._edtHdl.startEditing(!0,o.row,o.col,!0,e)):o.panel==i.panel&&o.col==i.col&&!o.edgeRight&&o.col>-1&&this._clickSort(e,o);else if(o.panel==i.panel&&o.row==i.row&&o.col==i.col&&t.rows.length&&t.columns.length)switch(t.selectionMode){case r.CellRange:case r.RowRange:case r.ListBox:t.select(new CellRange(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,o=e.target,i=new HitTestInfo(o,null),r=i.panel;if(!e.defaultPrevented&&i.grid==t&&!t._isInputElement(o))if(r==t.topLeftCells)t.select(new CellRange(0,0,t.rows.length-1,t.columns.length-1));else if(r==t.columnHeaders)this._clickSort(e,i);else if(r==t.rowHeaders)t.select(new CellRange(i.row,0,i.row,t.columns.length-1));else if(r==t.cells)if(i.row<0)this._clickSort(e,i);else if(wjcCore.closestClass(o,CellFactory._WJC_COLLAPSE)){var n=t.rows[i.row];n instanceof GroupRow&&(e.ctrlKey?t.collapseGroupsToLevel(n.isCollapsed?n.level+1:n.level):n.isCollapsed=!n.isCollapsed)}else wjcCore.closestClass(o,CellFactory._WJC_DROPDOWN)?t._edtHdl._toggleListBox(e,i.range):t.select(i.range)},e.prototype._clickSort=function(e,t){var o=this._g,i=o.collectionView,r=e.ctrlKey||e.metaKey;if(i&&i.canSort&&o.allowSorting){t.row;var n=t.panel.columns[t.col],s=o._getBindingColumn(t.panel,t.row,n),l=s?s._getBindingSort():null;if(s.allowSorting&&l){if(n==s){var a=o.getMergedRange(t.panel,t.row,t.col,!1);if(a&&a.columnSpan>1)return}for(var c=t.grid.collectionView.sortDescriptions,h=null,u=0;u=0&&e.target!=i._root&&(r=new HitTestInfo(i,e)).cellType!=CellType.Cell&&r.cellType!=CellType.RowHeader&&setTimeout(function(){o._isDown&&o._eMouse&&o._mouseSelect(o._eMouse,t)},100)}},e.prototype._handleResizing=function(t){if(t.preventDefault(),this._szRowCol instanceof Column){var o=this._g,i=wjcCore.mouseToPage(t).x,r=Math.round(Math.max(e._SZ_MIN,this._szStart+(i-this._htDown.point.x)*(o.rightToLeft?-1:1)));if(this._szRowCol.renderSize!=r){if(null==this._szArgs){s=o.rowHeaders.columns.indexOf(this._szRowCol)>-1?o.rowHeaders:o.cells;this._szArgs=new CellRangeEventArgs(s,new CellRange(-1,this._szRowCol.index))}this._szArgs.cancel=!1,o.onResizingColumn(this._szArgs)&&(o.deferResizing?this._showResizeMarker(r):this._szRowCol.width=r)}}if(this._szRowCol instanceof Row){var o=this._g,n=wjcCore.mouseToPage(t).y,r=Math.round(Math.max(e._SZ_MIN,this._szStart+(n-this._htDown.point.y)));if(this._szRowCol.renderSize!=r){if(null==this._szArgs){var s=o.columnHeaders.rows.indexOf(this._szRowCol)>-1?o.columnHeaders:o.cells;this._szArgs=new CellRangeEventArgs(s,new CellRange(this._szRowCol.index,-1))}this._szArgs.cancel=!1,o.onResizingRow(this._szArgs)&&(o.deferResizing?this._showResizeMarker(r):this._szRowCol.height=r)}}},e.prototype._dragstart=function(e){var t=this._g,o=this._htDown,i=AllowDragging;if(o){if(this._dragSrc=null,this._htDrag=null,!this._szRowCol){var r=new CellRangeEventArgs(o.panel,o.range);if(o.cellType==CellType.ColumnHeader&&t.allowDragging&i.Columns&&o.col>-1&&t.columns[o.col].allowDragging)t.onDraggingColumn(r)?this._dragSrc=e.target:e.preventDefault();else if(o.cellType==CellType.RowHeader&&t.allowDragging&i.Rows&&o.row>-1&&t.rows[o.row].allowDragging){var n=t.rows[o.row];n instanceof GroupRow||n instanceof _NewRowTemplate||(t.onDraggingRow(r)?this._dragSrc=e.target:e.preventDefault())}else o.cellType==CellType.TopLeft&&t.allowDragging&i.Columns&&o.col>-1&&t.topLeftCells.columns[o.col].allowDragging&&(t.onDraggingColumn(r)?this._dragSrc=e.target:e.preventDefault())}this._dragSrc&&e.dataTransfer&&!e.defaultPrevented&&(this._htDrag=o,wjcCore._startDrag(e.dataTransfer,"move"),e.stopPropagation(),wjcCore.addClass(this._dragSrc,_WJC_DRAGSRC),t.beginUpdate(),this._updating=!0)}},e.prototype._dragend=function(e){this._dragSrc=null,this._htDrag=null,this.resetMouseState()},e.prototype._dragover=function(e){var t=this._g,o=this._hitTest(e),i=this._dragSrc?this._htDrag:null,r=CellType,n=!1;if(i&&o.cellType==i.cellType){var s=new CellRangeEventArgs(o.panel,o.range,i);o.cellType==r.ColumnHeader?(s.cancel=!t.columns.canMoveElement(i.col,o.col),n=t.onDraggingColumnOver(s)):o.cellType==r.RowHeader?(s.cancel=!t.rows.canMoveElement(i.row,o.row),n=t.onDraggingRowOver(s)):o.cellType==r.TopLeft&&(s.cancel=!t.topLeftCells.columns.canMoveElement(i.col,o.col),n=t.onDraggingColumnOver(s))}if(n?(e.dataTransfer.dropEffect="move",this._showDragMarker(o),e.preventDefault(),e.stopPropagation()):this._showDragMarker(null),i&&t.autoScroll){var l=t.controlRect,a=t.scrollPosition,c=wjcCore.Control._DRAG_SCROLL_EDGE,h=wjcCore.Control._DRAG_SCROLL_STEP;i.panel==t.columnHeaders?(e.pageX-l.leftthis._htDown.col&&(n.left+=s.renderWidth),e.cellType==r.ColumnHeader&&e.colthis._htDown.row&&(n.top+=l.renderHeight),e.row-1){var l=r.col,a=wjcCore.mouseToPage(t).x,c=Math.round(Math.max(e._SZ_MIN,this._szStart+(a-this._htDown.point.x)*(this._g.rightToLeft?-1:1)));if(r.panel.columns[l].width=Math.round(c),o.onResizedColumn(r),n&&this._htDown.cellType==s.ColumnHeader&&i.containsColumn(l))for(var h=i.leftCol;h<=i.rightCol;h++)o.columns[h].allowResizing&&h!=l&&(r=new CellRangeEventArgs(o.cells,new CellRange(-1,h)),o.onResizingColumn(r)&&(o.columns[h].size=o.columns[l].size,o.onResizedColumn(r)))}if(r.row>-1){var l=r.row,u=wjcCore.mouseToPage(t).y,c=Math.round(Math.max(e._SZ_MIN,this._szStart+(u-this._htDown.point.y)));if(r.panel.rows[l].height=Math.round(c),o.onResizedRow(r),n&&this._htDown.cellType==s.RowHeader&&i.containsRow(l))for(var d=i.topRow;d<=i.bottomRow;d++)o.rows[d].allowResizing&&d!=l&&(r=new CellRangeEventArgs(o.cells,new CellRange(d,-1)),o.onResizingRow(r)&&(o.rows[d].size=o.rows[l].size,o.onResizedRow(r)))}}},e.prototype._startListBoxSelection=function(e){var t=this._g.rows,o=this._lbSelRows={};this._lbSelState=!t[e].isSelected,t.forEach(function(e,t){e.isSelected&&(o[t]=!0)})},e.prototype._handleSelection=function(e,t){var o=this,i=this._g,r=i.rows,n=i._selHdl.selection,s=new CellRange(e.row,e.col);if(e.row>-1&&e.col>-1)if(null!=this._lbSelRows){var l=!1;s=new CellRange(e.row,e.col,this._htDown.row,this._htDown.col),r.forEach(function(e,t){var r=s.containsRow(t)?o._lbSelState:null!=o._lbSelRows[t];if(r!=e.isSelected){var a=new CellRangeEventArgs(i.cells,new CellRange(t,n.col,t,n.col2));i.onSelectionChanging(a)&&(e._setFlag(RowColFlags.Selected,r,!0),i.onSelectionChanged(a),l=!0)}}),l&&i.refreshCells(!1,!0,!0),i.scrollIntoView(e.row,e.col)}else t&&(i.anchorCursor?(s.row=n.row,s.col=n.col):(s.row2=n.row2,s.col2=n.col2)),e.cellType==CellType.RowHeader?(s.col=0,s.col2=i.columns.length-1,i.select(s,!1),i.scrollIntoView(e.row,-1)):i.select(s)},e._SZ_MIN=0,e}();exports._MouseHandler=_MouseHandler;var _WJC_CHECKBOX="wj-cell-check",_PAGE_SIZE=4,_EditHandler=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),this._evtChange=document.createEvent("HTMLEvents"),this._evtChange.initEvent("change",!0,!1),e.selectionChanging.addHandler(function(o,i){if(t.finishEditing()){var r=e._selHdl.selection.row;if(r!=i.row){var n=e.rows.length;(r>-1&&r-1&&i.row-1:null==m&&(_=/^p/i.test(d.format))&&p.value.indexOf(C)<0&&(p.value+=C),_){var y=p.value;for(f=0,w=y.length;w>0&&(y[w-1]==C||" "==y[w-1]);)w--;for(;f-1;return!o&&t&&(o=e.indexOf('"')>-1||e.indexOf(",")>-1),o&&(!t&&e.match(/^".?"$/)||(e='"'+e+'"')),e},e.prototype.setClipString=function(e,t){var o=this,i=this._g,r=null==t,n=SelectionMode;if(!t)switch(t=i.selection,i.selectionMode){case n.Row:case n.RowRange:case n.ListBox:t.col=0,t.col2=i.columns.length-1}t=wjcCore.asType(t,CellRange);var s=this._parseClipString(wjcCore.asString(e));r&&!t.isSingleCell&&s.length&&this._expandClipRows(s,t);var l=new CellRange(t.topRow,t.leftCol,t.topRow+s.length-1,t.leftCol+s[0].length-1),a=new CellRangeEventArgs(i.cells,l);if(!i.onPasting(a))return!1;l=new CellRange(t.topRow,t.leftCol);var c=i.editableCollectionView,h=!1,u=t.topRow;i.deferUpdate(function(){c&&s.length>1&&c.beginUpdate();for(var e=0;e1&&c.endUpdate(),i.select(l),i.onPasted(a),h&&wjcCore.closest(i.hostElement,"form")){var m=wjcCore.createElement("",i.hostElement),y=document.createEvent("HTMLEvents");y.initEvent("change",!0,!1),m.dispatchEvent(y),wjcCore.removeChild(m)}})},e.prototype._isNativeCheckbox=function(e){return e instanceof HTMLInputElement&&"checkbox"==e.type&&!e.disabled&&!e.readOnly&&wjcCore.hasClass(e,_WJC_CHECKBOX)&&wjcCore.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$/,"");var o=0,i=0;for(o=0;o=" ",n=!1,s=!1;for(i=o;i1&&'"'==n[0]&&'"'==n[s-1]?n=(n=n.substr(1,s-2)).replace(/""/g,'"'):"\t"==n&&(n=""),e[e.length-1].push(n),r&&e.push([])},e.prototype._expandClipRows=function(e,t){for(var o=e.length,i=0,r=0;r1||l>1)&&(1==s&&(s=o),1==l&&(l=i),l%i==0&&s%o==0)){for(var c=i;c=o.rows.length||t<0||t>=o.columns.length)return!1;var i=o.rows[e];if(!i||i.isReadOnly||!i.isVisible)return!1;var r=o._getBindingColumn(o.cells,e,o.columns[t]);return!(!r||r.isReadOnly||!r.isVisible)},e.prototype._commitRowEdits=function(){var e=this._g;if(this.finishEditing()&&this._edItem){var t=e.editableCollectionView;if(t&&(t.currentEditItem||t.currentAddItem)){var o=new CellRangeEventArgs(e.cells,e.selection);e.onRowEditEnding(o),t.commitEdit(),e.onRowEditEnded(o)}this._edItem=null}},e.prototype._keydown=function(e){var t=this._edt;switch(e.keyCode){case wjcCore.Key.F2:return this._fullEdit=!this._fullEdit,e.preventDefault(),!0;case wjcCore.Key.F4:return this._toggleListBox(e),e.preventDefault(),!0;case wjcCore.Key.Space:return!t||"checkbox"!=t.type||t.disabled||t.readOnly||(t.checked=!t.checked,this.finishEditing(),e.preventDefault()),!0;case wjcCore.Key.Enter:if(e.preventDefault(),t&&e.altKey){var o=e.target;if(o instanceof HTMLTextAreaElement&&"soft"==o.wrap){var i=o.value,r=o.selectionStart,n=o.selectionEnd;o.value=i.substr(0,r)+"\n"+i.substr(n),wjcCore.setSelectionRange(o,r+1)}return!0}return!this.finishEditing();case wjcCore.Key.Tab:return e.preventDefault(),!this.finishEditing();case wjcCore.Key.Escape:return e.preventDefault(),this.finishEditing(!0),!0;case wjcCore.Key.Up:case wjcCore.Key.Down:case wjcCore.Key.Left:case wjcCore.Key.Right:case wjcCore.Key.PageUp:case wjcCore.Key.PageDown:case wjcCore.Key.Home:case wjcCore.Key.End:if(this._lbx)return this._keydownListBox(e);if(e.altKey)switch(e.keyCode){case wjcCore.Key.Up:case wjcCore.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 wjcCore.Key.Up:e.altKey?this._toggleListBox(e):this._lbx.selectedIndex>0&&this._lbx.selectedIndex--;break;case wjcCore.Key.Down:e.altKey?this._toggleListBox(e):this._lbx.selectedIndex++;break;case wjcCore.Key.Home:case wjcCore.Key.PageUp:this._lbx.selectedIndex=0;break;case wjcCore.Key.End:case wjcCore.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,o=e.charCode||32;if(t&&"checkbox"!=t.type&&wjcCore.getActiveElement()==t&&this._list&&this._list.length>0&&o>=32){var i=t.selectionStart,r=t.value.substr(0,i);e.target==t&&e.charCode&&(r+=String.fromCharCode(e.charCode),i++);var n=this._findString(this._list,r,!0);n<0&&(n=this._findString(this._list,r,!1)),n>-1&&(t.value=this._list[n],wjcCore.setSelectionRange(t,i,t.value.length),t.dispatchEvent(this._evtInput),e.preventDefault&&e.preventDefault())}},e.prototype._findString=function(e,t,o){o||(t=t.toLowerCase());for(var i=0;i-1){var a=e.selection;a.row==n&&e.select(a.row-1,a.col),o.removeAt(n)}else r&&(n<0?l=!0:n!=s&&(o.removeAt(n),l=!0),l&&(this._top?o.insert(0,i):o.push(i)),i&&(i._setFlag(RowColFlags.ParentCollapsed,!1),this._top&&e.selectionMode==SelectionMode.ListBox||i._setFlag(RowColFlags.Selected,!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!=wjcCore.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 o=e.rows[t.row];if(wjcCore.tryCast(o,_NewRowTemplate)){var i=e.editableCollectionView;if(i&&i.canAddNew)if(this._top){if(null==this._nrt.dataItem){var r=null,n=i.sourceCollection,s=i.newItemCreator;r=wjcCore.isFunction(s)?s():n&&n.length?new n[0].constructor:{},this._nrt.dataItem=r}}else{r=i.currentAddItem&&i.currentAddItem==o.dataItem?i.currentAddItem:i.addNew();i.moveCurrentTo(r);var l=this._nrt.isSelected;this.updateNewRowTemplate(),l&&t.row>-1&&(e.rows[t.row].isSelected=!0),e.refresh(!0),e.onRowAdded(t),t.cancel&&i.cancelNew()}}}},e.prototype._rowEditEnded=function(e,t){var o=this,i=e.editableCollectionView,r=this._nrt.dataItem;if(i&&!this._committing)if(i.isAddingNew)i.commitNew();else if(r&&!t.cancel){this._committing=!0,this._nrt.dataItem=null;var n=i.addNew();for(var s in r)n[s]=r[s];e.onRowAdded(t),t.cancel?i.cancelNew():i.commitNew(),setTimeout(function(){e.select(0,e.columns.firstVisibleIndex),o.updateNewRowTemplate()},20),this._committing=!1}},e}();exports._AddNewHandler=_AddNewHandler;var _NewRowTemplate=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(Row);exports._NewRowTemplate=_NewRowTemplate;var _ImeHandler=function(){function e(t){this._updateImeFocusBnd=this._updateImeFocus.bind(this),this._cmpstartBnd=this._compositionstart.bind(this),this._mousedownBnd=this._mousedown.bind(this),this._mouseupBnd=this._mouseup.bind(this),this._keydownBnd=this._keydown.bind(this),this._ignoreKey=!1,this._g=t;var o=wjcCore.createElement('');wjcCore.disableAutoComplete(o),wjcCore.setCss(o,e._cssHidden),this._tbx=o,t._root.appendChild(o),this._updateImeFocus();var i=t.hostElement,r=t.addEventListener.bind(t);r(o,"compositionstart",this._cmpstartBnd),r(i,"blur",this._updateImeFocusBnd,!0),r(i,"focus",this._updateImeFocusBnd),r(i,"mousedown",this._mousedownBnd,!0),r(i,"mouseup",this._mouseupBnd,!0),r(i,"keydown",this._keydownBnd,!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,o=this._tbx,i=e.removeEventListener.bind(e);i(o,"compositionstart",this._cmpstartBnd),i(t,"blur",this._updateImeFocusBnd),i(t,"focus",this._updateImeFocusBnd),i(t,"mousedown",this._mousedownBnd),i(t,"mouseup",this._mouseupBnd),i(t,"keydown",this._keydownBnd),e.cellEditEnded.removeHandler(this._cellEditEnded),e.selectionChanged.removeHandler(this._updateImeFocus),wjcCore.removeChild(o)},e.prototype._keydown=function(e){var t=this._g;this._ignoreKey=!1,t.activeEditor||"Space"!=e.code||(this._tbx.value="",e.shiftKey||e.ctrlKey?this._ignoreKey=!0:this._compositionstart())},e.prototype._compositionstart=function(){var e=this._g;if(!e.activeEditor&&!this._ignoreKey){var t=e._selHdl.selection;if(e.startEditing(!1,t.row,t.col,!1)&&e.activeEditor){t=e.editRange;var o=e.activeEditor,i=this._tbx,r=e.cells.hostElement,n=e.columns[t.col].pos+r.offsetLeft,s=e.rows[t.row].pos+r.offsetTop,l=e.getCellBoundingRect(t.row,t.col),a=wjcCore.closest(o,".wj-cell");l.width=a.offsetWidth,l.height=a.offsetHeight,t.row1&&!h){var g=parseFloat(u.lineHeight);isNaN(g)&&(g=1.2*parseFloat(u.fontSize)),d=Math.max(0,(l.height-g)/2)+"px"}wjcCore.setCss(i,{position:"absolute",left:n,top:s,width:l.width-1,height:l.height-1,paddingTop:d,paddingLeft:u.paddingLeft,paddingRight:u.paddingRight,textAlign:u.textAlign,zIndex:a.style.zIndex}),e._edtHdl._edt=i;var p=o.value;setTimeout(function(){" "!=i.value&&" "!=i.value||(i.value=p,wjcCore.setSelectionRange(i,p.length))},20),o.value=""}}},e.prototype._cellEditEnded=function(){var t=this;wjcCore.setCss(this._tbx,e._cssHidden),setTimeout(function(){t._tbx.value=""})},e.prototype._mousedown=function(e){this._isMouseDown=!0,this._updateImeFocus()},e.prototype._mouseup=function(e){this._isMouseDown=!1,this._updateImeFocus()},e.prototype._updateImeFocus=function(){var e=this._g,t=this._tbx,o=wjcCore.getActiveElement();e.activeEditor||wjcCore.closest(o,".wj-flexgrid")!=e.hostElement||(this._enableIme()?o!=t&&(t.disabled=!1,t.select(),t.focus()):(t.disabled=!0,t.value=""))},e.prototype._enableIme=function(){var e=this._g,t=e._selHdl.selection;if(!e.canEditCell(t.row,t.col))return!1;var o=t.isValid?e._getBindingColumn(e.cells,t.row,e.columns[t.col]):null;return!(!o||o.dataType==wjcCore.DataType.Boolean)},e._cssHidden={position:"fixed",left:-10,top:-10,width:"1px",overflow:"hidden"},e}();exports._ImeHandler=_ImeHandler;