/*
    *
    * Wijmo Library 5.20181.462
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
"use strict";function tryGetModuleWijmoGridDetail(){let e,t;return(e=window.wijmo)&&(t=e.grid)&&t.detail}function tryGetModuleWijmoInput(){let e;return(e=window.wijmo)&&e.input}Object.defineProperty(exports,"__esModule",{value:!0});const wjcGrid=require("wijmo/wijmo.grid"),wjcCore=require("wijmo/wijmo"),core_1=require("@angular/core"),core_2=require("@angular/core"),core_3=require("@angular/core"),common_1=require("@angular/common"),forms_1=require("@angular/forms"),wijmo_angular2_directiveBase_1=require("wijmo/wijmo.angular2.directiveBase");exports.wjFlexGridMeta={selector:"wj-flex-grid",template:`<div><ng-content></ng-content></div>`,inputs:["wjModelProperty","isDisabled","newRowAtTop","allowAddNew","allowDelete","allowDragging","allowMerging","allowResizing","allowSorting","quickAutoSize","autoScroll","autoSizeMode","autoGenerateColumns","childItemsPath","groupHeaderFormat","headersVisibility","showSelectedHeaders","showMarquee","itemFormatter","isReadOnly","imeEnabled","mergeManager","selectionMode","showGroups","showSort","showDropDown","showAlternatingRows","showErrors","validateEdits","treeIndent","itemsSource","autoClipboard","frozenRows","frozenColumns","cloneFrozenCells","deferResizing","sortRowIndex","stickyHeaders","preserveSelectedState","preserveOutlineState","keyActionTab","keyActionEnter","rowHeaderPath","virtualizationThreshold"],outputs:["initialized","gotFocusNg: gotFocus","lostFocusNg: lostFocus","beginningEditNg: beginningEdit","cellEditEndedNg: cellEditEnded","cellEditEndingNg: cellEditEnding","prepareCellForEditNg: prepareCellForEdit","formatItemNg: formatItem","resizingColumnNg: resizingColumn","resizedColumnNg: resizedColumn","autoSizingColumnNg: autoSizingColumn","autoSizedColumnNg: autoSizedColumn","draggingColumnNg: draggingColumn","draggingColumnOverNg: draggingColumnOver","draggedColumnNg: draggedColumn","sortingColumnNg: sortingColumn","sortedColumnNg: sortedColumn","resizingRowNg: resizingRow","resizedRowNg: resizedRow","autoSizingRowNg: autoSizingRow","autoSizedRowNg: autoSizedRow","draggingRowNg: draggingRow","draggingRowOverNg: draggingRowOver","draggedRowNg: draggedRow","deletingRowNg: deletingRow","deletedRowNg: deletedRow","loadingRowsNg: loadingRows","loadedRowsNg: loadedRows","rowEditStartingNg: rowEditStarting","rowEditStartedNg: rowEditStarted","rowEditEndingNg: rowEditEnding","rowEditEndedNg: rowEditEnded","rowAddedNg: rowAdded","groupCollapsedChangedNg: groupCollapsedChanged","groupCollapsedChangingNg: groupCollapsedChanging","itemsSourceChangedNg: itemsSourceChanged","selectionChangingNg: selectionChanging","selectionChangedNg: selectionChanged","scrollPositionChangedNg: scrollPositionChanged","updatingViewNg: updatingView","updatedViewNg: updatedView","updatingLayoutNg: updatingLayout","updatedLayoutNg: updatedLayout","pastingNg: pasting","pastedNg: pasted","pastingCellNg: pastingCell","pastedCellNg: pastedCell","copyingNg: copying","copiedNg: copied"],providers:[{provide:forms_1.NG_VALUE_ACCESSOR,useFactory:wijmo_angular2_directiveBase_1.WjValueAccessorFactory,multi:!0,deps:["WjComponent"]}]};class WjFlexGrid extends wjcGrid.FlexGrid{constructor(e,t,l,o){super(wijmo_angular2_directiveBase_1.WjDirectiveBehavior.getHostElement(e,t)),this.isInitialized=!1;this._wjBehaviour=wijmo_angular2_directiveBase_1.WjDirectiveBehavior.attach(this,e,t,l);new DirectiveCellFactory(this,o),this.deferUpdate(()=>{if(this.rows.defaultSize<10){let e=this.hostElement,t=getComputedStyle(e),l=getComputedStyle(document.body),o=2*parseInt(t.fontSize&&wjcCore.contains(document.body,e)?t.fontSize:l.fontSize);this.rows.defaultSize=o,this.columns.defaultSize=4*o,this.columnHeaders.rows.defaultSize=o,this.rowHeaders.columns.defaultSize=Math.round(1.25*o)}}),this.created()}created(){}ngOnInit(){this._wjBehaviour.ngOnInit()}ngAfterViewInit(){this._wjBehaviour.ngAfterViewInit()}ngOnDestroy(){this._wjBehaviour.ngOnDestroy()}addEventListener(e,t,l,o=!1){let i=wijmo_angular2_directiveBase_1.WjDirectiveBehavior,r=i.ngZone;r&&i.outsideZoneEvents[t]?r.runOutsideAngular(()=>{super.addEventListener(e,t,l,o)}):super.addEventListener(e,t,l,o)}}WjFlexGrid.meta={outputs:exports.wjFlexGridMeta.outputs},WjFlexGrid.decorators=[{type:core_1.Component,args:[{selector:exports.wjFlexGridMeta.selector,template:exports.wjFlexGridMeta.template,inputs:exports.wjFlexGridMeta.inputs,outputs:exports.wjFlexGridMeta.outputs,providers:[{provide:"WjComponent",useExisting:core_2.forwardRef(()=>WjFlexGrid)},...exports.wjFlexGridMeta.providers]}]}],WjFlexGrid.ctorParameters=(()=>[{type:core_2.ElementRef,decorators:[{type:core_3.Inject,args:[core_2.ElementRef]}]},{type:core_2.Injector,decorators:[{type:core_3.Inject,args:[core_2.Injector]}]},{type:void 0,decorators:[{type:core_3.Inject,args:["WjComponent"]},{type:core_3.SkipSelf},{type:core_2.Optional}]},{type:core_3.ChangeDetectorRef,decorators:[{type:core_3.Inject,args:[core_3.ChangeDetectorRef]}]}]),exports.WjFlexGrid=WjFlexGrid,exports.wjFlexGridColumnMeta={selector:"wj-flex-grid-column",template:`<div><ng-content></ng-content></div>`,inputs:["asyncBindings","wjProperty","name","dataMap","dataType","binding","sortMemberPath","format","header","width","maxLength","minWidth","maxWidth","align","allowDragging","allowSorting","allowResizing","allowMerging","aggregate","isReadOnly","cssClass","isContentHtml","isSelected","visible","wordWrap","multiLine","mask","inputType","isRequired","showDropDown","dropDownCssClass","quickAutoSize"],outputs:["initialized","isSelectedChangePC: isSelectedChange"],providers:[]};class WjFlexGridColumn extends wjcGrid.Column{constructor(e,t,l){super(),this.isInitialized=!1,this.wjProperty="columns";let o=(this._wjBehaviour=wijmo_angular2_directiveBase_1.WjDirectiveBehavior.attach(this,e,t,l)).parentBehavior.directive;o.autoGenerateColumns&&(o.autoGenerateColumns=!1,o.columns.clear()),this.created()}created(){}ngOnInit(){this._wjBehaviour.ngOnInit()}ngAfterViewInit(){this._wjBehaviour.ngAfterViewInit()}ngOnDestroy(){this._wjBehaviour.ngOnDestroy()}}WjFlexGridColumn.meta={outputs:exports.wjFlexGridColumnMeta.outputs,changeEvents:{"grid.selectionChanged":["isSelected"]}},WjFlexGridColumn.decorators=[{type:core_1.Component,args:[{selector:exports.wjFlexGridColumnMeta.selector,template:exports.wjFlexGridColumnMeta.template,inputs:exports.wjFlexGridColumnMeta.inputs,outputs:exports.wjFlexGridColumnMeta.outputs,providers:[{provide:"WjComponent",useExisting:core_2.forwardRef(()=>WjFlexGridColumn)},...exports.wjFlexGridColumnMeta.providers]}]}],WjFlexGridColumn.ctorParameters=(()=>[{type:core_2.ElementRef,decorators:[{type:core_3.Inject,args:[core_2.ElementRef]}]},{type:core_2.Injector,decorators:[{type:core_3.Inject,args:[core_2.Injector]}]},{type:void 0,decorators:[{type:core_3.Inject,args:["WjComponent"]},{type:core_3.SkipSelf},{type:core_2.Optional}]}]),exports.WjFlexGridColumn=WjFlexGridColumn;class WjFlexGridCellTemplate{constructor(e,t,l,o,i,r,n){this.viewContainerRef=e,this.templateRef=t,this.elRef=l,this.domRenderer=i,this.cdRef=n,this.autoSizeRows=!0,this.forceFullEdit=!0,o instanceof WjFlexGrid?this.grid=o:o instanceof WjFlexGridColumn&&(this.column=o,this.grid=wijmo_angular2_directiveBase_1.WjDirectiveBehavior.getBehavior(o).parentBehavior.directive)}static _getTemplContextProp(e){return"$__cellTempl"+CellTemplateType[e]}ngOnInit(){this.ownerControl=this.column&&this.column.grid===this.grid?this.column:this.grid,this._attachToControl()}ngOnDestroy(){this.cellTypeStr&&(this.viewContainerRef.clear(),this.ownerControl[WjFlexGridCellTemplate._getTemplContextProp(this.cellType)]=null,this.grid.invalidate())}_instantiateTemplate(e,t){return wijmo_angular2_directiveBase_1.WjDirectiveBehavior.instantiateTemplate(e,this.viewContainerRef,this.templateRef,this.domRenderer,!1,t)}_attachToControl(){if(!this.cellTypeStr)return;let e=this.cellType=wjcCore.asEnum(this.cellTypeStr,CellTemplateType),t=this.ownerControl;t[WjFlexGridCellTemplate._getTemplContextProp(e)]=this,t instanceof wjcGrid.Column&&(e===CellTemplateType.Cell||e===CellTemplateType.ColumnHeader||e===CellTemplateType.ColumnFooter)&&t._setFlag(wjcGrid.RowColFlags.HasTemplate,!0),this.grid.invalidate()}}WjFlexGridCellTemplate.decorators=[{type:core_2.Directive,args:[{selector:"[wjFlexGridCellTemplate]",inputs:["wjFlexGridCellTemplate","cellTypeStr: cellType","cellOverflow","valuePaths","autoSizeRows","forceFullEdit"],exportAs:"wjFlexGridCellTemplate",providers:[{provide:"WjComponent",useExisting:core_2.forwardRef(()=>WjFlexGridCellTemplate)}]}]}],WjFlexGridCellTemplate.ctorParameters=(()=>[{type:core_2.ViewContainerRef,decorators:[{type:core_3.Inject,args:[core_2.ViewContainerRef]}]},{type:core_2.TemplateRef,decorators:[{type:core_3.Inject,args:[core_2.TemplateRef]},{type:core_2.Optional}]},{type:core_2.ElementRef,decorators:[{type:core_3.Inject,args:[core_2.ElementRef]}]},{type:void 0,decorators:[{type:core_3.Inject,args:["WjComponent"]},{type:core_3.SkipSelf},{type:core_2.Optional}]},{type:core_2.Renderer,decorators:[{type:core_3.Inject,args:[core_2.Renderer]}]},{type:core_2.Injector,decorators:[{type:core_3.Inject,args:[core_2.Injector]}]},{type:core_3.ChangeDetectorRef,decorators:[{type:core_3.Inject,args:[core_3.ChangeDetectorRef]}]}]),exports.WjFlexGridCellTemplate=WjFlexGridCellTemplate;var CellTemplateType;!function(e){e[e.Cell=0]="Cell",e[e.CellEdit=1]="CellEdit",e[e.ColumnHeader=2]="ColumnHeader",e[e.RowHeader=3]="RowHeader",e[e.RowHeaderEdit=4]="RowHeaderEdit",e[e.TopLeft=5]="TopLeft",e[e.GroupHeader=6]="GroupHeader",e[e.Group=7]="Group",e[e.NewCellTemplate=8]="NewCellTemplate",e[e.ColumnFooter=9]="ColumnFooter",e[e.BottomLeft=10]="BottomLeft"}(CellTemplateType=exports.CellTemplateType||(exports.CellTemplateType={}));class DirectiveCellFactory extends wjcGrid.CellFactory{constructor(e,t){if(super(),this._needsCdCheck=!1,this._lastApplyTimeStamp=0,this._noApplyLag=!1,this._startingEditing=!1,this._cellStampCounter=0,this._composing=!1,this.grid=e,this._gridCdRef=t,!DirectiveCellFactory._templateTypes){DirectiveCellFactory._templateTypes=[];for(var l in CellTemplateType)isNaN(l)&&DirectiveCellFactory._templateTypes.push(l)}var o=this;this._baseCf=e.cellFactory,e.cellFactory=this,this._evtInput=document.createEvent("HTMLEvents"),this._evtInput.initEvent("input",!0,!1),this._evtBlur=document.createEvent("HTMLEvents"),this._evtBlur.initEvent("blur",!1,!1),e.prepareCellForEdit.addHandler(function(e,t){o._noApplyLag=!0}),e.cellEditEnded.addHandler(function(t,l){(l.range.col<0||l.range.col<e.columns.length&&!e.columns[l.range.col][WjFlexGridCellTemplate._getTemplContextProp(CellTemplateType.CellEdit)])&&(o._editChar=null),setTimeout(function(){o._noApplyLag=!1},300)}),e.beginningEdit.addHandler(function(e,t){o._startingEditing=!0}),e.hostElement.addEventListener("keydown",function(e){o._startingEditing=!1},!0),e.hostElement.addEventListener("keypress",function(t){var l=t.charCode>32?String.fromCharCode(t.charCode):null;l&&wjcCore.closest(t.target,".wj-flexgrid")===e.hostElement&&(!e.activeEditor||o._startingEditing?o._editChar=l:o._editChar&&(o._editChar+=l))},!0),e.hostElement.addEventListener("compositionstart",function(e){o._composing=!0},!0),e.hostElement.addEventListener("compositionend",function(e){o._composing=!1},!0),e.updatedView.addHandler(()=>{this._needsCdCheck&&(this._needsCdCheck=!1,this._gridCdRef.markForCheck())},this)}updateCell(e,t,l,o,i){this._cellStampCounter=(this._cellStampCounter+1)%1e7;let r=o[DirectiveCellFactory._cellStampProp]=this._cellStampCounter;o.style.overflow&&(o.style.overflow="");let n=t,a=l;i&&!i.isSingleCell&&(t=i.row,l=i.col);let s,d=this,c=e.grid,p=c.editRange,u=e.rows[t],g=u.dataItem,m=!1,C=!1,w=!1,h=!1;switch(e.cellType){case wjcGrid.CellType.Cell:if(p&&p.row===t&&p.col===l)s=CellTemplateType.CellEdit,C=w=!0;else if(u instanceof wjcGrid.GroupRow){var _=!((h=g instanceof wjcCore.CollectionViewGroup)||u.hasChildren);l==e.columns.firstVisibleIndex?s=_?CellTemplateType.Cell:CellTemplateType.GroupHeader:(s=_?CellTemplateType.Cell:CellTemplateType.Group,C=!0)}else u instanceof wjcGrid._NewRowTemplate?s=CellTemplateType.NewCellTemplate:tryGetModuleWijmoGridDetail()&&tryGetModuleWijmoGridDetail().DetailRow&&u instanceof tryGetModuleWijmoGridDetail().DetailRow||(s=CellTemplateType.Cell);break;case wjcGrid.CellType.ColumnHeader:s=CellTemplateType.ColumnHeader;break;case wjcGrid.CellType.RowHeader:s=c.collectionView&&c.collectionView.currentEditItem===g?CellTemplateType.RowHeaderEdit:CellTemplateType.RowHeader,m=!0;break;case wjcGrid.CellType.TopLeft:s=CellTemplateType.TopLeft,m=!0;break;case wjcGrid.CellType.ColumnFooter:s=CellTemplateType.ColumnFooter,C=!0;break;case wjcGrid.CellType.BottomLeft:s=CellTemplateType.BottomLeft,m=!0}var f=!1;if(null!=s){var v=h&&s==CellTemplateType.GroupHeader?c.columns.getColumn(g.groupDescription.propertyName):l>=0&&l<e.columns.length?e.columns[l]:null;if(v){var j=WjFlexGridCellTemplate._getTemplContextProp(s),y=(m?c:v)[j];if(y||(s===CellTemplateType.RowHeaderEdit?(s=CellTemplateType.RowHeader,j=WjFlexGridCellTemplate._getTemplContextProp(s),y=c[j]):s!==CellTemplateType.Group&&s!==CellTemplateType.GroupHeader||h||(s=CellTemplateType.Cell,j=WjFlexGridCellTemplate._getTemplContextProp(s),y=v[j])),y){var E;C&&(E=e.getCellData(t,l,!1));{f=!0;let l=o.getAttribute(wjcGrid.FlexGrid._WJS_MEASURE),s=l&&"true"===l.toLowerCase();w&&this._baseCf.updateCell(e,n,a,o,i,!0);let p,m=o[j]||{},C=m.column!==v||!m.viewRef||m.templateContextProperty!==j||o.firstChild!=m.rootElement,h=w&&this._composing&&c.imeEnabled;if(C){if(w){var T=o.firstElementChild;T&&(h||o.focus(),T.style.display="none")}else o.textContent="";this._doDisposeCell(o);let e={};p=this._setViewRefContext(e,u,v,g,E,y.valuePaths);let t=y._instantiateTemplate(o,e);m.column=v,m.viewRef=t.viewRef,m.rootElement=t.rootElement,m.templateContextProperty=j,o[j]=m}else p=this._setViewRefContext(m.viewRef.context,u,v,g,E,y.valuePaths);if(y.cellOverflow&&(o.style.overflow=y.cellOverflow),s?y.cdRef.detectChanges():y.autoSizeRows&&!h?setTimeout(()=>{if(r===o[DirectiveCellFactory._cellStampProp]){var l=o.scrollHeight,n=e.rows,a=i&&i.rowSpan||1;if(t<n.length&&n[t].renderHeight*a<l-1){if(n.defaultSize=l/a,w){let e=d._isFullEdit();return c.refresh(),void c.startEditing(e)}}else w&&this._initEditInput(m,y,null)}},0):w&&setTimeout(()=>{h?this._initImeEditInput(m,y):this._initEditInput(m,y,null)},0),w){d._cellEditorVars=p.localVars;var x=function(e,t){if(c.cellEditEnding.removeHandler(x),!t.stayInEditMode){let e=wjcCore.getActiveElement();e&&e.dispatchEvent(d._evtBlur),o.focus()}if(d._triggerEditorEvents(o),!t.cancel&&!t.stayInEditMode){let e=p.localVars,t=Object.getOwnPropertyNames(p.bindings);for(let l of t)p.bindings[l].setValue(e,p.localVars.values[l])}var l=o.querySelectorAll(".wj-dropdown");[].forEach.call(l,function(e){var t=wjcCore.Control.getControl(e);t&&tryGetModuleWijmoInput()&&t instanceof tryGetModuleWijmoInput().DropDown&&(t.isDroppedDown=!1)})};let e=function(t,l){c.cellEditEnded.removeHandler(e),d._cellEditorVars=null};c.cellEditEnding.addHandler(x),c.cellEditEnded.addHandler(e)}else this._baseCf.updateCell(e,n,a,o,i,!1)}}}}f||(this._doDisposeCell(o),this._baseCf.updateCell(e,n,a,o,i))}getEditorValue(e){if(this._cellEditorVars){let t=e.editRange;return t&&t.isValid&&this._triggerEditorEvents(e.cells.getCellElement(t.row,t.col)),this._cellEditorVars.value}return super.getEditorValue(e)}disposeCell(e){this._doDisposeCell(e)}_doDisposeCell(e){for(var t=DirectiveCellFactory._templateTypes,l=0;l<t.length;l++){var o=WjFlexGridCellTemplate._getTemplContextProp(CellTemplateType[t[l]]),i=e[o];if(i&&i.viewRef){let t=(i.column||this.grid)[o];if(t){let e=t.viewContainerRef.indexOf(i.viewRef);e>-1&&t.viewContainerRef.remove(e)}i.viewRef=null,i.rootElement=null,i.column=null,i.templateContextProperty=null,e[o]=null}}}_setViewRefContext(e,t,l,o,i,r){this._needsCdCheck=!0,e.row=t,e.col=l,e.item=o;let n={},a=e.cell||{},s={},d={localVars:a,bindings:s};if(a.row=t,a.col=l,a.item=o,a.value=i,a.values=n,r){let e=Object.getOwnPropertyNames(r);for(let t of e){let e=new wjcCore.Binding(r[t]);s[t]=e,n[t]=e.getValue(a)}}return e.cell!==a&&(e.cell=a),d}_initEditInput(e,t,l){this._setFullEdit(t);let o=this._findInitialInput(e);if(o){var i=()=>{o.removeEventListener("focus",i),setTimeout(()=>{let e=null!=l?l:this._editChar;e&&(o.value=e,this._editChar=null,DirectiveCellFactory._setSelectionRange(o,e.length,e.length),o.dispatchEvent(this._evtInput))},DirectiveCellFactory._FOCUS_INTERVAL)};o.addEventListener("focus",i),o.focus()}}_initImeEditInput(e,t){let l=wjcCore.getActiveElement();if(l&&l instanceof HTMLInputElement&&wjcCore.hasClass(l,"wj-grid-ime")){let o=i=>{l.removeEventListener("compositionend",o),wjcCore.setCss(l,wjcGrid._ImeHandler._cssHidden),this._initEditInput(e,t,l.value)};l.addEventListener("compositionend",o);let i=this._findInitialInput(e);if(i){let e=i.getBoundingClientRect(),t=l.getBoundingClientRect(),o=window.getComputedStyle(l),r=parseFloat(o.left),n=parseFloat(o.top);wjcCore.setCss(l,{left:r+e.left-t.left+"px",top:n+e.top-t.top+"px",width:e.width+"px",height:e.height+"px"})}}}_findInitialInput(e){let t=e&&e.rootElement&&e.rootElement.querySelectorAll("input,textarea");if(t)for(var l=0;l<t.length;l++){var o=t[l],i=window.getComputedStyle(o);if("none"!==i.display&&"visible"===i.visibility)return o}return null}static _setSelectionRange(e,t,l=t){if(wjcCore.contains(document.body,e)&&!e.disabled&&"none"!=e.style.display)try{e.setSelectionRange(wjcCore.asNumber(t),wjcCore.asNumber(l),wjcCore.isIE()?null:"backward"),e.focus()}catch(e){}}_triggerEditorEvents(e){if(e){let t=e.querySelectorAll(".wj-control");for(let e=0;e<t.length;e++){let l=t[e],o=wjcCore.Control.getControl(l);if(o){let e=wijmo_angular2_directiveBase_1.WjDirectiveBehavior.getBehavior(o);e&&e.flushPendingEvents()}}}}_isFullEdit(){let e=this.grid;return!e.activeEditor||e._edtHdl._fullEdit}_setFullEdit(e){let t=this.grid;e.forceFullEdit&&t.activeEditor&&(t._edtHdl._fullEdit=!0)}}DirectiveCellFactory._cellStampProp="__wjCellStamp",DirectiveCellFactory._FOCUS_INTERVAL=wjcCore.Control._FOCUS_INTERVAL+20;let moduleExports=[WjFlexGrid,WjFlexGridColumn,WjFlexGridCellTemplate];class WjGridModule{}WjGridModule.decorators=[{type:core_1.NgModule,args:[{imports:[wijmo_angular2_directiveBase_1.WjDirectiveBaseModule,common_1.CommonModule],declarations:[...moduleExports],exports:[...moduleExports]}]}],WjGridModule.ctorParameters=(()=>[]),exports.WjGridModule=WjGridModule;