/*
    *
    * Wijmo Library 5.20181.436
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
System.register(["wijmo/wijmo.grid","wijmo/wijmo","wijmo/wijmo.grid.detail"],function(e,t){"use strict";var i,n,o,l,r,a,s,c,d=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();t&&t.id;return{setters:[function(e){i=e},function(e){n=e},function(e){o=e}],execute:function(){l=o||exports,window.wijmo=window.wijmo||{},window.wijmo.grid=window.wijmo.grid||{},window.wijmo.grid.detail=l,function(e){e[e.Code=0]="Code",e[e.Selection=1]="Selection",e[e.ExpandSingle=2]="ExpandSingle",e[e.ExpandMulti=3]="ExpandMulti"}(r||(r={})),e("DetailVisibilityMode",r),a=function(){function e(e,t){var i=this;this._mode=r.ExpandSingle,this._animated=!1,this._g=e,e.mergeManager=new s(e),e.rowHeaders.hostElement.addEventListener("click",this._hdrClick.bind(this)),e.formatItem.addHandler(this._formatItem,this),e.selectionChanged.addHandler(this._selectionChanged,this),e.resizedRow.addHandler(this._resizedRow,this),e.loadingRows.addHandler(function(){i.hideDetail()}),e.draggingRow.addHandler(function(e,t){t.row<e.rows.length-1&&e.rows[t.row+1]instanceof c&&(t.cancel=!0,i.hideDetail(t.row))}),e.formatItem.addHandler(function(e,t){t.panel==e.cells&&e.rows[t.row]instanceof c&&(t.cell.style.left="0")}),t&&n.copy(this,t)}return Object.defineProperty(e.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"detailVisibilityMode",{get:function(){return this._mode},set:function(e){(e=n.asEnum(e,r))!=this._mode&&(this._mode=e,this.hideDetail(),this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxHeight",{get:function(){return this._maxHeight},set:function(e){this._maxHeight=n.asNumber(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAnimated",{get:function(){return this._animated},set:function(e){e!=this._animated&&(this._animated=n.asBoolean(e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"createDetailCell",{get:function(){return this._createDetailCellFn},set:function(e){this._createDetailCellFn=n.asFunction(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"disposeDetailCell",{get:function(){return this._disposeDetailCellFn},set:function(e){this._disposeDetailCellFn=n.asFunction(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rowHasDetail",{get:function(){return this._rowHasDetailFn},set:function(e){this._rowHasDetailFn=n.asFunction(e,!0)},enumerable:!0,configurable:!0}),e.prototype.getDetailRow=function(e){var t=this._g.rows;return e=this._toIndex(e),t[e]instanceof c?t[e]:e<t.length-1&&t[e+1]instanceof c?t[e+1]:null},e.prototype.isDetailVisible=function(e){return null!=this.getDetailRow(e)},e.prototype.isDetailAvailable=function(e){this._g.rows;return e=this._toIndex(e),this._hasDetail(e)},e.prototype.hideDetail=function(e){var t=this._g.rows;if(null!=e){!(t[e=this._toIndex(e)]instanceof c)&&e<t.length-1&&t[e+1]instanceof c&&e++;var i=t[e];i instanceof c&&(this.disposeDetailCell&&this.disposeDetailCell(i),n.Control.disposeAll(i.detail),t.removeAt(e))}else for(var o=0;o<t.length;o++)t[o]instanceof c&&this.hideDetail(o)},e.prototype.showDetail=function(e,t){void 0===t&&(t=!1);var i=this._g,o=i.rows;if((e=this._toIndex(e))>0&&o[e]instanceof c&&e--,t){for(var l=i.selection,r=!1,a=0;a<o.length-1;a++)a!=e&&o[a+1]instanceof c&&(this.hideDetail(a),a<e&&e--,a<l.row&&(l.row--,l.row2--,r=!0));r&&i.select(l,!1)}if(!this.isDetailVisible(e)&&this._hasDetail(e)){var s=new c(o[e]);if(s.detail=this._createDetailCell(o[e]),s.detail)if(o.insert(e+1,s),this._animated){var d=s.detail.style;d.transform="translateY(-100%)",d.opacity="0",n.animate(function(t){t<1?(d.transform="translateY("+(100*-(1-t)).toFixed(0)+"%)",d.opacity=(t*t).toString()):(d.transform="",d.opacity="",n.Control.invalidateAll(s.detail),i.scrollIntoView(e+1,-1))})}else i.scrollIntoView(e+1,-1)}},e.prototype._toIndex=function(e){return e instanceof i.Row&&(e=e.index),n.asNumber(e,!1,!0)},e.prototype._hdrClick=function(e){if(!e.defaultPrevented)switch(this._mode){case r.ExpandMulti:case r.ExpandSingle:var t=this._g,n=t.hitTest(e);if(n.row>-1){t.rows[n.row];this.isDetailVisible(n.row)?this.hideDetail(n.row):(t.select(new i.CellRange(n.row,0,n.row,t.columns.length-1)),this.showDetail(n.row,this._mode==r.ExpandSingle)),e.preventDefault()}}},e.prototype._selectionChanged=function(e,t){var i=this;this._mode==r.Selection&&(this._toSel&&clearTimeout(this._toSel),this._toSel=setTimeout(function(){e.selection.row>-1?i.showDetail(e.selection.row,!0):i.hideDetail()},300))},e.prototype._formatItem=function(e,t){var i=this._g,o=t.panel.rows[t.row];if(t.panel==i.cells&&o instanceof c&&null!=o.detail)if(n.addClass(t.cell,"wj-detail"),t.cell.textContent="",t.cell.style.textAlign="",t.cell.appendChild(o.detail),null==o.height){n.Control.refreshAll(t.cell);var l=getComputedStyle(t.cell),a=o.detail.scrollHeight+parseInt(l.paddingTop)+parseInt(l.paddingBottom);this._maxHeight>0&&a>this._maxHeight&&(a=this._maxHeight),o.height=a,o.detail.style.height||(o.detail.style.height="100%");var s=o.detail.querySelector(".wj-flexgrid");s&&!s.style.height&&(s.style.height="100%")}else setTimeout(function(){n.Control.refreshAll(o.detail)});if((this._mode==r.ExpandMulti||this._mode==r.ExpandSingle)&&t.panel==i.rowHeaders&&0==t.col&&this._hasDetail(t.row)){var d=t.row<i.rows.length-1&&i.rows[t.row+1]instanceof c;t.cell.innerHTML=d?'<span class="wj-glyph-minus"></span>':'<span class="wj-glyph-plus"></span>'}},e.prototype._resizedRow=function(e,t){var i=t.panel.rows[t.row];i instanceof c&&i.detail&&n.Control.refreshAll(i.detail)},e.prototype._hasVisibleDetail=function(e){return!(e instanceof c||e instanceof i.GroupRow||e instanceof i._NewRowTemplate)},e.prototype._hasDetail=function(e){return!n.isFunction(this._rowHasDetailFn)||this._rowHasDetailFn(this._g.rows[e])},e.prototype._createDetailCell=function(e,t){return this.createDetailCell?this.createDetailCell(e,t):null},e}(),e("FlexGridDetailProvider",a),s=function(e){function t(t){return e.call(this,t)||this}return d(t,e),t.prototype.getMergedRange=function(t,n,o,l){switch(void 0===l&&(l=!0),t.cellType){case i.CellType.Cell:if(t.rows[n]instanceof c)return new i.CellRange(n,0,n,t.columns.length-1);break;case i.CellType.RowHeader:if(t.rows[n]instanceof c)return new i.CellRange(n-1,o,n,o);if(n<t.rows.length-1&&t.rows[n+1]instanceof c)return new i.CellRange(n,o,n+1,o)}return e.prototype.getMergedRange.call(this,t,n,o,l)},t}(i.MergeManager),e("DetailMergeManager",s),c=function(e){function t(t){var i=e.call(this)||this;return i.isReadOnly=!0,i}return d(t,e),Object.defineProperty(t.prototype,"detail",{get:function(){return this._detail},set:function(e){this._detail=e},enumerable:!0,configurable:!0}),t}(i.Row),e("DetailRow",c)}}});