/*
    *
    * Wijmo Library 5.20182.500
    * 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/
    *
    */
var __extends=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)}}();define(["require","exports","wijmo/wijmo","wijmo/wijmo.grid","wijmo/wijmo.grid.detail"],function(e,t,i,n,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var l=o||t;window.wijmo=window.wijmo||{},window.wijmo.grid=window.wijmo.grid||{},window.wijmo.grid.detail=l,i._addCultureInfo("FlexGridDetailProvider",{ariaLabels:{toggleDetail:"Toggle Row Detail"}});var r;!function(e){e[e.None=0]="None",e[e.ToggleDetail=1]="ToggleDetail"}(r=t.KeyAction||(t.KeyAction={}));var a;!function(e){e[e.Code=0]="Code",e[e.Selection=1]="Selection",e[e.ExpandSingle=2]="ExpandSingle",e[e.ExpandMulti=3]="ExpandMulti"}(a=t.DetailVisibilityMode||(t.DetailVisibilityMode={}));var s=function(){function e(e,t){var n=this;this._mode=a.ExpandSingle,this._animated=!1,this._keyActionEnter=r.None,this._g=e,e.mergeManager=new c(e),e.rowHeaders.hostElement.addEventListener("click",this._hdrClick.bind(this)),e.rowHeaders.hostElement.addEventListener("mousedown",function(t){var i=e.editableCollectionView;(e.activeEditor||i&&i.currentEditItem)&&(n._hdrClick(t),t.preventDefault())}),e.formatItem.addHandler(this._formatItem,this),e.selectionChanged.addHandler(this._selectionChanged,this),e.resizedRow.addHandler(this._resizedRow,this),e.loadingRows.addHandler(function(){n.hideDetail()}),e.draggingRow.addHandler(function(e,t){t.row<e.rows.length-1&&e.rows[t.row+1]instanceof d&&(t.cancel=!0,n.hideDetail(t.row))}),e.hostElement.addEventListener("keydown",function(e){if(e.keyCode==i.Key.Enter&&n._keyActionEnter==r.ToggleDetail){var t=n._g.selection.row;n._toggleRowDetail(t)&&e.preventDefault()}},!0),t&&i.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=i.asEnum(e,a))!=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=i.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=i.asBoolean(e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"keyActionEnter",{get:function(){return this._keyActionEnter},set:function(e){this._keyActionEnter=i.asEnum(e,r)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"createDetailCell",{get:function(){return this._createDetailCellFn},set:function(e){this._createDetailCellFn=i.asFunction(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"disposeDetailCell",{get:function(){return this._disposeDetailCellFn},set:function(e){this._disposeDetailCellFn=i.asFunction(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rowHasDetail",{get:function(){return this._rowHasDetailFn},set:function(e){this._rowHasDetailFn=i.asFunction(e,!0)},enumerable:!0,configurable:!0}),e.prototype.getDetailRow=function(e){e=this._toIndex(e);var t=this._g.rows;return t[e]instanceof d?t[e]:e<t.length-1&&t[e+1]instanceof d?t[e+1]:null},e.prototype.isDetailVisible=function(e){return null!=this.getDetailRow(e)},e.prototype.isDetailAvailable=function(e){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 d)&&e<t.length-1&&t[e+1]instanceof d&&e++;var n=t[e];n instanceof d&&(this.disposeDetailCell&&this.disposeDetailCell(n),i.Control.disposeAll(n.detail),t.removeAt(e))}else for(var o=0;o<t.length;o++)t[o]instanceof d&&this.hideDetail(o)},e.prototype.showDetail=function(e,t){void 0===t&&(t=!1);var n=this._g,o=n.rows;if((e=this._toIndex(e))>0&&o[e]instanceof d&&e--,t){for(var l=n.selection,r=!1,a=0;a<o.length-1;a++)a!=e&&o[a+1]instanceof d&&(this.hideDetail(a),a<e&&e--,a<l.row&&(l.row--,l.row2--,r=!0));r&&n.select(l,!1)}if(!this.isDetailVisible(e)&&this._hasDetail(e)){var s=new d(o[e]);if(s.detail=this._createDetailCell(o[e]),s.detail)if(o.insert(e+1,s),this._animated){var c=s.detail.style;c.transform="translateY(-100%)",c.opacity="0",i.animate(function(t){t<1?(c.transform="translateY("+(100*-(1-t)).toFixed(0)+"%)",c.opacity=(t*t).toString()):(c.transform="",c.opacity="",i.Control.invalidateAll(s.detail),n.scrollIntoView(e+1,-1))})}else n.scrollIntoView(e+1,-1)}},e.prototype._toIndex=function(e){return e instanceof n.Row&&(e=e.index),i.asNumber(e,!1,!0)},e.prototype._hdrClick=function(t){if(!t.defaultPrevented&&0==t.button&&i.closestClass(t.target,e._WJC_DETAIL))switch(this._mode){case a.ExpandMulti:case a.ExpandSingle:var n=this._g,o=n.hitTest(t.target);o.panel||(o=n.hitTest(t)),o.panel&&this._toggleRowDetail(o.row)&&t.preventDefault()}},e.prototype._toggleRowDetail=function(e){if(e>-1&&this._hasDetail(e)){if(this.isDetailVisible(e))this.hideDetail(e);else{var t=this._g;t.select(new n.CellRange(e,0,e,t.columns.length-1)),this.showDetail(e,this._mode==a.ExpandSingle)}return!0}return!1},e.prototype._selectionChanged=function(e,t){var i=this;this._mode==a.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(t,n){var o=this._g,l=n.panel.rows[n.row];if(n.panel==o.cells&&l instanceof d&&null!=l.detail&&n.col==o.cells.columns.frozen)if(i.addClass(n.cell,"wj-detail"),n.cell.textContent="",n.cell.style.textAlign="",n.cell.appendChild(l.detail),null==l.height){i.Control.refreshAll(n.cell);var r=getComputedStyle(n.cell),s=parseInt(r.paddingTop)+parseInt(r.paddingBottom),c=l.detail.scrollHeight+s;this._maxHeight>0&&c>this._maxHeight&&(c=this._maxHeight),l.height=c,l.detail.style.height||(l.detail.style.height="100%");var h=l.detail.querySelector(".wj-flexgrid");h&&!h.style.height&&(h.style.height="100%")}else setTimeout(function(){i.Control.refreshAll(l.detail)});if(n.panel==o.rowHeaders&&0==n.col&&this._hasDetail(n.row))switch(n.cell.style.cursor="",this._mode){case a.ExpandMulti:case a.ExpandSingle:var u=n.cell,f=o.rows[n.row+1]instanceof d,p=f?"minus":"plus",g=e._WJC_DETAIL;u.innerHTML='<button class="wj-btn wj-btn-glyph '+g+'" type="button" tabindex="-1"><span class="wj-glyph-'+p+'"></span></button>';var w=u.children[0],_=i.culture.FlexGridDetailProvider.ariaLabels.toggleDetail;i.setAriaLabel(w,_),i.setAttribute(w,"aria-expanded",f)}},e.prototype._resizedRow=function(e,t){var n=t.panel.rows[t.row];n instanceof d&&n.detail&&i.Control.refreshAll(n.detail)},e.prototype._hasDetail=function(e){var t=this._g.rows[e];return i.isFunction(this._rowHasDetailFn)?this._rowHasDetailFn(t):this._isRegularRow(t)},e.prototype._isRegularRow=function(e){return!(e instanceof n.GroupRow||e instanceof n._NewRowTemplate)},e.prototype._createDetailCell=function(e,t){return this.createDetailCell?this.createDetailCell(e,t):null},e._WJC_DETAIL="wj-elem-detail",e}();t.FlexGridDetailProvider=s;var c=function(e){function t(t){return e.call(this,t)||this}return __extends(t,e),t.prototype.getMergedRange=function(t,i,o,l){switch(void 0===l&&(l=!0),t.cellType){case n.CellType.Cell:if(t.rows[i]instanceof d){var r=t.columns,a=Math.min(r.length,r.frozen);return o<a?new n.CellRange(i,0,i,a-1):new n.CellRange(i,a,i,r.length-1)}break;case n.CellType.RowHeader:if(t.rows[i]instanceof d)return new n.CellRange(i-1,o,i,o);if(i<t.rows.length-1&&t.rows[i+1]instanceof d)return new n.CellRange(i,o,i+1,o)}return e.prototype.getMergedRange.call(this,t,i,o,l)},t}(n.MergeManager);t.DetailMergeManager=c;var d=function(e){function t(t){var i=e.call(this)||this;return i.isReadOnly=!0,i}return __extends(t,e),Object.defineProperty(t.prototype,"detail",{get:function(){return this._detail},set:function(e){this._detail=e},enumerable:!0,configurable:!0}),t}(n.Row);t.DetailRow=d});