-
Notifications
You must be signed in to change notification settings - Fork 182
/
canvas-datagrid.js
2 lines (2 loc) · 97 KB
/
canvas-datagrid.js
1
2
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.canvasDatagrid=t():e.canvasDatagrid=t()}(this,function(){return function(e){function t(r){if(o[r])return o[r].exports;var n=o[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var o={};return t.m=e,t.c=o,t.d=function(e,o,r){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,o){var r,n;r=[o(1),o(2),o(3),o(4),o(5),o(6),o(7)],void 0!==(n=function(){"use strict";function t(e){e=e||{};var r={};return r.args=e,r.createGrid=t,o.forEach(function(e){e(r)}),r.init(),r.intf}var o=Array.prototype.slice.call(arguments);return!window||window.canvasDatagrid||window.require||(window.canvasDatagrid=t),e.exports=t,t}.apply(t,r))&&(e.exports=n)},function(e,t,o){var r,n;r=[],void 0!==(n=function(){"use strict";return function(e){function t(){var t=!0;Object.keys(e.htmlImageCache).forEach(function(o){e.htmlImageCache[o].complete||(t=!1)}),t&&e.draw()}function o(o){var r,n=o.innerHTML||o.formattedValue,l=o.x+e.canvasOffsetLeft,i=o.y+e.canvasOffsetTop;if(e.htmlImageCache[n]){if(r=e.htmlImageCache[n],r.height===o.height&&r.width===o.width){if(!r.complete)return;return e.ctx.drawImage(r,l,i)}e.htmlImageCache[n]=void 0}r=new Image(o.width,o.height),e.htmlImageCache[n]=r,r.onload=function(){e.ctx.drawImage(r,l,i),t()},r.src="data:image/svg+xml;base64,"+btoa('<svg xmlns="http://www.w3.org/2000/svg" width="'+o.width+'" height="'+o.height+'">\n<foreignObject class="node" x="0" y="0" width="100%" height="100%">\n<body xmlns="http://www.w3.org/1999/xhtml" style="margin:0;padding:0;">\n'+n+"\n</body></foreignObject>\n</svg>\n")}function r(t,o){return t+=e.canvasOffsetLeft,o+=e.canvasOffsetTop,e.ctx.fillStyle=e.style.columnHeaderOrderByArrowColor,e.ctx.strokeStyle=e.style.columnHeaderOrderByArrowBorderColor,e.ctx.beginPath(),t+=e.style.columnHeaderOrderByArrowMarginLeft,o+=e.style.columnHeaderOrderByArrowMarginTop,"asc"===e.orderDirection?(e.ctx.moveTo(t,o),e.ctx.lineTo(t+e.style.columnHeaderOrderByArrowWidth,o),e.ctx.lineTo(t+.5*e.style.columnHeaderOrderByArrowWidth,o+e.style.columnHeaderOrderByArrowHeight),e.ctx.moveTo(t,o)):(e.ctx.lineTo(t,o+e.style.columnHeaderOrderByArrowHeight),e.ctx.lineTo(t+e.style.columnHeaderOrderByArrowWidth,o+e.style.columnHeaderOrderByArrowHeight),e.ctx.lineTo(t+.5*e.style.columnHeaderOrderByArrowWidth,o),e.ctx.lineTo(t,o+e.style.columnHeaderOrderByArrowHeight)),e.ctx.stroke(),e.ctx.fill(),e.style.columnHeaderOrderByArrowMarginLeft+e.style.columnHeaderOrderByArrowWidth+e.style.columnHeaderOrderByArrowMarginRight}function n(t,o,r){return o+=e.canvasOffsetLeft,r+=e.canvasOffsetTop,e.ctx.fillStyle=e.style.treeArrowColor,e.ctx.strokeStyle=e.style.treeArrowBorderColor,e.ctx.beginPath(),o+=e.style.treeArrowMarginLeft,r+=e.style.treeArrowMarginTop,e.openChildren[t.data[e.uniqueId]]?(e.ctx.moveTo(o,r),e.ctx.lineTo(o+e.style.treeArrowWidth,r),e.ctx.lineTo(o+.5*e.style.treeArrowWidth,r+e.style.treeArrowHeight),e.ctx.moveTo(o,r)):(e.ctx.lineTo(o,r),e.ctx.lineTo(o+e.style.treeArrowHeight,r+.5*e.style.treeArrowWidth),e.ctx.lineTo(o,r+e.style.treeArrowWidth),e.ctx.lineTo(o,r)),e.ctx.stroke(),e.ctx.fill(),e.style.treeArrowMarginLeft+e.style.treeArrowWidth+e.style.treeArrowMarginRight}function l(t,o,r,n,l){t+=e.canvasOffsetLeft,o+=e.canvasOffsetTop;var i=t+r,s=o+n;e.ctx.beginPath(),e.ctx.moveTo(t+l,o),e.ctx.lineTo(i-l,o),e.ctx.quadraticCurveTo(i,o,i,o+l),e.ctx.lineTo(i,o+n-l),e.ctx.quadraticCurveTo(i,s,i-l,s),e.ctx.lineTo(t+l,s),e.ctx.quadraticCurveTo(t,s,t,s-l),e.ctx.lineTo(t,o+l),e.ctx.quadraticCurveTo(t,o,t+l,o)}function i(t,o,r,n){t+=e.canvasOffsetLeft,o+=e.canvasOffsetTop,e.ctx.fillRect(t,o,r,n)}function s(t,o,r,n){t+=e.canvasOffsetLeft,o+=e.canvasOffsetTop,e.ctx.strokeRect(t,o,r,n)}function a(t,o,r){o+=e.canvasOffsetLeft,r+=e.canvasOffsetTop,e.ctx.fillText(t,o,r)}function c(t,o){e.ctx.beginPath(),{t:function(){e.ctx.moveTo(t.x+e.canvasOffsetLeft,t.y+e.canvasOffsetTop),e.ctx.lineTo(t.x+e.canvasOffsetLeft+t.width,t.y+e.canvasOffsetTop)},r:function(){e.ctx.moveTo(t.x+e.canvasOffsetLeft+t.width,t.y+e.canvasOffsetTop),e.ctx.lineTo(t.x+e.canvasOffsetLeft+t.width,t.y+e.canvasOffsetTop+t.height)},b:function(){e.ctx.moveTo(t.x+e.canvasOffsetLeft,t.y+e.canvasOffsetTop+t.height),e.ctx.lineTo(t.x+e.canvasOffsetLeft+t.width,t.y+e.canvasOffsetTop+t.height)},l:function(){e.ctx.moveTo(t.x+e.canvasOffsetLeft,t.y+e.canvasOffsetTop),e.ctx.lineTo(t.x+e.canvasOffsetLeft,t.y+e.canvasOffsetTop+t.height)}}[o](),e.ctx.stroke()}function d(t,o){var r,n=0;return e.ellipsisCache[t]&&e.ellipsisCache[t][o]?e.ellipsisCache[t][o]:(n=e.ctx.measureText(t).width,e.ellipsisCache[t]=e.ellipsisCache[t]||{},r={value:t,width:n},e.ellipsisCache[t][o]=r,r)}function u(t){var o=e.style[t.style+"PaddingLeft"],r=e.style[t.style+"PaddingTop"],n=e.style[t.style+"PaddingRight"],l=e.style[t.style+"PaddingBottom"],i=r+t.height-.5*t.height,s=o+t.treeArrowWidth+t.orderByArrowWidth;t.text=d(t.formattedValue,t.width-n-o),t.text.height=t.fontHeight,"right"===t.horizontalAlignment?s=t.width-t.text.width-n:"center"===t.horizontalAlignment&&(s=t.width/2-t.text.width/2),"top"===t.verticalAlignment?i=r+t.text.height:"bottom"===t.verticalAlignment&&(i=t.height-l-t.text.height),t.text.x=t.x+s,t.text.y=t.y+i,a(t.text.value,t.text.x,t.text.y)}var h=[],f=0,g=20;e.htmlImageCache={},e.draw=function(t){function d(t,a,c){return function(d,h,f){var g,x,p,y=d.style||"cell",v=/HeaderCell/.test(y),b=/cornerCell/.test(y),S="rowHeaderCell"===y,T="columnHeaderCell"===y,O=e.selections[c]&&-1!==e.selections[c].indexOf(f),z=e.hovers[t[e.uniqueId]]&&-1!==e.hovers[t[e.uniqueId]].indexOf(f),P=e.activeCell.rowIndex===c&&e.activeCell.columnIndex===f,W="object"==typeof t[d.name]&&null!==t[d.name]&&void 0!==t[d.name],F=!(e.orders.rows[e.activeCell.rowIndex]!==c&&e.orders.columns[e.activeCell.columnIndex]!==f||-1!==f&&-1!==c)&&(S?"activeRowHeaderCell":"activeColumnHeaderCell"),D=e.formatters[d.type||"string"],j=0,G=0,q=e.sizes.columns[S?"cornerCell":d[e.uniqueId]]||d.width,V={value:t[d.name],row:t,header:d};if("headerCellCap"===y&&(q=L-M),void 0===q&&(q=e.style.columnWidth),M+q+e.style.cellBorderWidth<0&&(M+=q+e.style.cellBorderWidth),P&&(y="activeCell"),-1!==e.visibleRows.indexOf(a)||v||e.visibleRows.push(a),p=e.dispatchEvent("formatcellvalue",V),!e.dispatchEvent("beforerendercell",V))return w=M,C=H,"cornerCell"===y?(w=0,C=0):S?w=0:v&&(C=0),x={type:W?"canvas-datagrid-cell":d.type,style:y,nodeType:"canvas-datagrid-cell",x:w,y:C,horizontalAlignment:e.style[y+"HorizontalAlignment"],verticalAlignment:e.style[y+"VerticalAlignment"],offsetTop:e.canvasOffsetTop+C,offsetLeft:e.canvasOffsetLeft+w,scrollTop:e.scrollBox.scrollTop,scrollLeft:e.scrollBox.scrollLeft,active:P||F,hovered:z,selected:O,width:q,height:N,offsetWidth:q,offsetHeight:N,parentNode:e.intf.parentNode,offsetParent:e.intf.parentNode,data:t,isCorner:b,isHeader:v,isColumnHeader:T,isHeaderCellCap:!!d.isHeaderCellCap,isRowHeader:S,rowOpen:B,header:d,columnIndex:f,rowIndex:c,sortColumnIndex:h,sortRowIndex:a,isGrid:W,gridId:(e.attributes.name||"")+t[e.uniqueId]+":"+d[e.uniqueId],parentGrid:e.intf,innerHTML:"",activeHeader:F,value:v&&!S?d.title||d.name:t[d.name]},V.cell=x,x.userHeight=x.isHeader?e.sizes.rows[-1]:I,x.userWidth=x.isHeader?e.sizes.columns.cornerCell:e.sizes.columns[d[e.uniqueId]],x[e.uniqueId]=t[e.uniqueId],e.visibleCells.unshift(x),e.ctx.fillStyle=e.style[y+"BackgroundColor"],e.ctx.strokeStyle=e.style[y+"BorderColor"],e.ctx.lineWidth=e.style[y+"BorderWidth"],z&&(e.ctx.fillStyle=e.style[y+"HoverBackgroundColor"],e.ctx.strokeStyle=e.style[y+"HoverBorderColor"]),O&&(e.ctx.fillStyle=e.style[y+"SelectedBackgroundColor"],e.ctx.strokeStyle=e.style[y+"SelectedBorderColor"]),F&&(e.ctx.fillStyle=e.style[F+"BackgroundColor"]),e.dispatchEvent("rendercell",V),x.isGrid&&(x.height!==I&&(x.height=I||e.style.cellHeightWithChildGrid,m=!0),x.width=e.sizes.columns[d[e.uniqueId]]||e.style.cellWidthWithChildGrid),B&&!x.isRowHeader&&(x.height=e.sizes.rows[A[e.uniqueId]]||e.style.cellHeight),x.isGrid||(i(w,C,x.width,x.height),s(w,C,x.width,x.height)),e.ctx.save(),l(x.x,x.y,x.width,x.height,0),e.ctx.clip(),e.dispatchEvent("afterrendercell",V),x.height===N||B&&!x.isRowHeader||(e.sizes.rows[v?-1:t[e.uniqueId]]=x.height,m=!0),x.width!==q&&(e.sizes.columns[d[e.uniqueId]]=x.width,m=!0),S&&e.attributes.tree&&(e.dispatchEvent("rendertreearrow",V)||(G=n(x,e.style[y+"PaddingLeft"],C,0))),(e.attributes.showRowNumbers&&S||!S)&&(x.isGrid?(e.childGrids[x.gridId]||(g=e.args.childGridAttributes||e.args,g.name=e.attributes.saveAppearance?x.gridId:void 0,g.parentNode=x,g.data=t[d.name],e.childGrids[x.gridId]=e.createGrid(g),e.sizes.rows[A[e.uniqueId]]=e.sizes.rows[A[e.uniqueId]]||e.style.cellGridHeight,m=!0),x.grid=e.childGrids[x.gridId],x.grid.parentNode=x,x.grid.visible=!0,x.grid.draw(),e.dispatchEvent("rendercellgrid",V)):(e.childGrids[x.gridId]&&(e.childGrids[x.gridId].parentNode.offsetHeight=0),v&&e.orderBy===d.name&&(e.dispatchEvent("renderorderbyarrow",V)||(j=r(w+e.style[y+"PaddingLeft"],0))),e.ctx.fillStyle=e.style[y+"Color"],z&&(e.ctx.fillStyle=e.style[y+"HoverColor"]),O&&(e.ctx.fillStyle=e.style[y+"SelectedColor"]),F&&(e.ctx.fillStyle=e.style[F+"Color"]),e.ctx.font=e.style[y+"Font"],x.fontHeight=e.style[y+"FontHeight"],x.treeArrowWidth=G,x.orderByArrowWidth=j,p=void 0!==p?p:D?D(V):"",void 0!==p||D||(p="",console.warn("canvas-datagrid: Unknown format "+d.type+" add a cellFormater")),x.formattedValue=(void 0!==p&&null!==p?p:"").toString(),e.columnFilters&&void 0!==e.columnFilters[p]&&v&&(x.formattedValue=e.attributes.filterTextPrefix+p),e.dispatchEvent("rendertext",V)||(x.innerHTML||"html"===d.type?o(x):u(x)))),P&&(k=x),O&&!S&&(e.selections[x.rowIndex-1]&&-1!==e.selections[x.rowIndex-1].indexOf(x.columnIndex)&&0!==x.rowIndex||x.isHeader||R.push([x,"t"]),e.selections[x.rowIndex+1]&&-1!==e.selections[x.rowIndex+1].indexOf(x.columnIndex)||R.push([x,"b"]),e.selections[x.rowIndex]&&0!==x.columnIndex&&-1!==e.selections[x.rowIndex].indexOf(x.columnIndex-1)||R.push([x,"l"]),e.selections[x.rowIndex]&&x.columnIndex!==E.length&&-1!==e.selections[x.rowIndex].indexOf(x.columnIndex+1)||R.push([x,"r"])),e.ctx.restore(),M+=x.width+e.style.cellBorderWidth,x.width}}function x(t,o,r){var n;e.attributes.showRowHeaders&&(M=0,y={rowHeaderCell:o+1},y[e.uniqueId]=t[e.uniqueId],n={name:"rowHeaderCell",width:e.style.rowHeaderCellWidth,style:"rowHeaderCell",type:"string",data:t[e.uniqueId],index:-1},n[e.uniqueId]=t[e.uniqueId],B=e.openChildren[t[e.uniqueId]],d(y,o,r)(n,-1,-1))}function p(t,o){var r,n,l,i,s=E.length;if(H-2*N>O)return!1;if(A=e.data[t],B=e.openChildren[A[e.uniqueId]],l=e.sizes.rows[A[e.uniqueId]]||e.style.cellHeight,n=B?e.sizes.trees[A[e.uniqueId]]:0,I=l+n,H<-1*I)return!1;for(e.attributes.showRowHeaders&&(M+=j),N=I,i=e.scrollIndexLeft;i<s&&(r=e.orders.columns[i],!((M+=d(A,t,o)(E[r],r,i))>e.width));i+=1);return N=I,M=-1*e.scrollBox.scrollLeft+e.scrollPixelLeft+e.style.cellBorderWidth,b=e.childGrids[A[e.uniqueId]],t!==e.data.length&&B?(b.visible=!0,b.parentNode={offsetTop:H+l+e.canvasOffsetTop,offsetLeft:j-1+e.canvasOffsetLeft,offsetHeight:n,offsetWidth:e.width-j-e.style.scrollBarWidth-1,offsetParent:e.intf.parentNode,parentNode:e.intf.parentNode,style:e.style,nodeType:"canvas-datagrid-tree",scrollTop:e.scrollBox.scrollTop,scrollLeft:e.scrollBox.scrollLeft,rowIndex:t},e.visibleCells.unshift({rowIndex:M,columnIndex:0,y:b.parentNode.offsetTop,x:b.parentNode.offsetLeft,height:b.parentNode.offsetHeight,width:b.parentNode.offsetWidth,style:"tree-grid",type:b.parentNode.nodeType}),b.draw()):b&&(b.parentNode.offsetHeight=0,delete e.sizes.trees[A[e.uniqueId]]),P.push([A,t,o,H,I]),H+=N+e.style.cellBorderWidth,!0}if(!e.dispatchEvent("beforedraw",{})&&(e.isChildGrid||e.height&&e.width)){if(e.isChildGrid&&t)return void requestAnimationFrame(e.parentGrid.draw);if(!1!==e.intf.visible){var m,y,v,w,C,b,B,I,S,H,M,T,O,L,E,z,A,k,R=[],P=[],W=e.data.length,F=e.currentCell||{},D=e.getRowHeaderCellHeight(),j=e.getColumnHeaderCellWidth(),N=e.style.cellHeight;f+=1,v=performance.now(),e.data.length>e.orders.rows.length&&e.createRowOrders(),e.ctx.save(),function(){e.visibleRows=[],E=e.getVisibleSchema(),e.visibleCells=[],e.canvasOffsetTop=e.isChildGrid?e.parentNode.offsetTop:0,e.canvasOffsetLeft=e.isChildGrid?e.parentNode.offsetLeft:0,O=e.height,L=e.width,e.isChildGrid||e.ctx.scale(window.devicePixelRatio,window.devicePixelRatio)}(),function(){l(0,0,L,O,0),e.ctx.clip(),e.ctx.fillStyle=e.style.backgroundColor,i(0,0,L,O)}(),function(){var t,o,r,n=E.length;for(M=-1*e.scrollBox.scrollLeft+e.scrollPixelLeft+e.style.cellBorderWidth,H=-1*e.scrollBox.scrollTop+D+e.scrollPixelTop+e.style.cellBorderWidth,z=e.scrollIndexTop;z<W&&(o=e.orders.rows[z],p(o,z));z+=1);if(e.attributes.showNewRow){for(e.attributes.showRowHeaders&&(M+=j),I=N=e.style.cellHeight,B=!1,t=e.scrollIndexLeft;t<n&&(r=e.orders.columns[t],!((M+=d(e.newRow,e.data.length,e.data.length)(E[r],r,t))>e.width+e.scrollBox.scrollLeft));t+=1);P.push([e.newRow,e.data.length,e.data.length,H,I])}}(),function(){e.ctx.lineWidth=e.style.selectionOverlayBorderWidth,e.ctx.strokeStyle=e.style.selectionOverlayBorderColor,R.forEach(function(e){c(e[0],e[1])})}(),function(){k&&(e.attributes.rowSelectionMode?e.activeCell&&e.activeCell.rowIndex===k.rowIndex&&(e.ctx.lineWidth=e.style.activeCellOverlayBorderWidth,e.ctx.strokeStyle=e.style.activeCellOverlayBorderColor,s(0,k.y,e.getHeaderWidth()+j,I)):(e.ctx.lineWidth=e.style.activeCellOverlayBorderWidth,e.ctx.strokeStyle=e.style.activeCellOverlayBorderColor,s(k.x,k.y,k.width,k.height)))}(),function(){var t,o,r,n,l,i=E.length;if(P.forEach(function(e){H=e[3],N=e[4],x(e[0],e[1],e[2])}),e.attributes.showColumnHeaders){for(M=-1*e.scrollBox.scrollLeft+e.scrollPixelLeft,e.attributes.showRowHeaders&&(M+=j),H=0,N=e.getRowHeaderCellHeight(),r=e.scrollIndexLeft;r<i&&(o=e.orders.columns[r],l=E[o],t={title:l.title,name:l.name,width:l.width,style:"columnHeaderCell",type:"string",index:r,order:o},n={columnHeaderCell:l.title||l.name},n[e.uniqueId]="h"+l[e.uniqueId],t[e.uniqueId]=l[e.uniqueId],!((M+=d(n,-1,-1)(t,r,o))>e.width+e.scrollBox.scrollLeft));r+=1);M<L&&(T={name:"",width:e.style.scrollBarWidth,style:"headerCellCap",isHeaderCell:!0,isHeaderCellCap:!0,type:"string",index:E.length},T[e.uniqueId]="columnHeaderCell",d({endCap:""},-1,-1)(T,-1,-1)),e.attributes.showRowHeaders&&(S={cornerCell:""},S[e.uniqueId]="cornerCell",M=0,T={name:"cornerCell",width:e.style.rowHeaderCellWidth,style:"cornerCell",type:"string",index:-1},T[e.uniqueId]="cornerCell",d(S,-1,-1)(T,-1,-1))}}(),function(){if(e.reorderObject){var t={height:e.reorderObject.height,width:e.reorderObject.width,x:e.reorderObject.x+e.reorderObject.dragOffset.x,y:e.reorderObject.y+e.reorderObject.dragOffset.y},o={width:L,heigth:O,x:0,y:0};e.ctx.fillStyle=e.style.reorderMarkerBackgroundColor,e.ctx.lineWidth=e.style.reorderMarkerBorderWidth,e.ctx.strokeStyle=e.style.reorderMarkerBorderColor,"row-reorder"===e.dragMode?(t.width=L,t.x=0,o.width=L,o.y=e.currentCell.y,i(t.x,t.y,t.width,t.height),s(t.x,t.y,t.width,t.height),e.ctx.lineWidth=e.style.reorderMarkerIndexBorderWidth,e.ctx.strokeStyle=e.style.reorderMarkerIndexBorderColor,e.currentCell.rowIndex!==e.reorderObject.rowIndex&&e.currentCell.rowIndex-1!==e.reorderObject.rowIndex&&c(o,"t")):"column-reorder"===e.dragMode&&e.reorderObject&&(t.height=O,t.y=0,o.height=O,o.x=e.currentCell.x,i(t.x,t.y,t.width,t.height),s(t.x,t.y,t.width,t.height),e.ctx.lineWidth=e.style.reorderMarkerIndexBorderWidth,e.ctx.strokeStyle=e.style.reorderMarkerIndexBorderColor,e.currentCell.columnIndex!==e.reorderObject.columnIndex&&e.currentCell.columnIndex-1!==e.reorderObject.columnIndex&&c(o,"l"))}}(),function(){var t={x:0,y:0,height:0,width:0,style:"vertical-scroll-bar"},o={x:0,y:0,height:0,width:0,style:"horizontal-scroll-bar"},r={x:0,y:0,height:0,width:0,style:"vertical-scroll-box"},n={x:0,y:0,height:0,width:0,style:"horizontal-scroll-box"},a={x:0,y:0,height:0,width:0,isCorner:!0,isScrollBoxCorner:!0,style:"scroll-box-corner"},c=2*e.style.scrollBarBoxMargin,d=.5*e.style.scrollBarBoxMargin;e.ctx.strokeStyle=e.style.scrollBarBorderColor,e.ctx.lineWidth=e.style.scrollBarBorderWidth,t.x+=L-e.style.scrollBarWidth-e.style.scrollBarBorderWidth-d,t.y+=D,t.width=e.style.scrollBarWidth+e.style.scrollBarBorderWidth+d,t.height=O-D-e.style.scrollBarWidth-d-c,e.ctx.fillStyle=e.style.scrollBarBackgroundColor,i(t.x,t.y,t.width,t.height+c),s(t.x,t.y,t.width,t.height+c),r.x=t.x+e.style.scrollBarBoxMargin,r.y=D+e.style.scrollBarBoxMargin+(t.height-e.scrollBox.scrollBoxHeight)*(e.scrollBox.scrollTop/e.scrollBox.scrollHeight),r.width=e.style.scrollBarBoxWidth,r.height=e.scrollBox.scrollBoxHeight,e.ctx.fillStyle=e.style.scrollBarBoxColor,/vertical/.test(F.context)&&(e.ctx.fillStyle=e.style.scrollBarActiveColor),r.height<t.height&&(l(r.x,r.y,r.width,r.height,e.style.scrollBarBoxBorderRadius),e.ctx.stroke(),e.ctx.fill()),o.x+=j,o.y+=O-e.style.scrollBarWidth-d,o.width=L-e.style.scrollBarWidth-j-d-c,o.height=e.style.scrollBarWidth+e.style.scrollBarBorderWidth+d,e.ctx.fillStyle=e.style.scrollBarBackgroundColor,i(o.x,o.y,o.width+c,o.height),s(o.x,o.y,o.width+c,o.height),n.y=o.y+e.style.scrollBarBoxMargin,n.x=j+e.style.scrollBarBoxMargin+(o.width-e.scrollBox.scrollBoxWidth)*(e.scrollBox.scrollLeft/e.scrollBox.scrollWidth),n.width=e.scrollBox.scrollBoxWidth,n.height=e.style.scrollBarBoxWidth,e.ctx.fillStyle=e.style.scrollBarBoxColor,/horizontal/.test(F.context)&&(e.ctx.fillStyle=e.style.scrollBarActiveColor),n.width<o.width&&(l(n.x,n.y,n.width,n.height,e.style.scrollBarBoxBorderRadius),e.ctx.stroke(),e.ctx.fill()),e.ctx.strokeStyle=e.style.scrollBarCornerBorderColor,e.ctx.fillStyle=e.style.scrollBarCornerBackgroundColor,a.x=o.x+o.width+c,a.y=t.y+t.height+c,a.width=e.style.scrollBarWidth+e.style.scrollBarBorderWidth,a.height=e.style.scrollBarWidth+e.style.scrollBarBorderWidth,l(a.x,a.y,a.width,a.height,0),e.ctx.stroke(),e.ctx.fill(),e.visibleCells.unshift(t),e.visibleCells.unshift(r),e.visibleCells.unshift(o),e.visibleCells.unshift(n),e.visibleCells.unshift(a),e.scrollBox.bar={v:t,h:o},e.scrollBox.box={v:r,h:n}}(),m&&e.resize(!0),function(){e.ctx.lineWidth=e.style.gridBorderWidth,e.ctx.strokeStyle=e.style.gridBorderColor,s(0,0,e.width,e.height)}(),function(){h[f%g]=performance.now()-v;var t;e.attributes.debug&&(e.ctx.font="11px sans-serif",t={},t.perf=(h.reduce(function(e,t){return e+t},0)/h.length).toFixed(1)+"ms ("+h.map(function(e){return e.toFixed(1)}).join(", ")+")",t.htmlImages=Object.keys(e.htmlImageCache).length,t.scrollLeft=e.scrollBox.scrollLeft,t.scrollTop=e.scrollBox.scrollTop,t.scrollIndexTop=e.scrollIndexTop,t.scrollPixelTop=e.scrollPixelTop,t.scrollIndexLeft=e.scrollIndexLeft,t.scrollPixelLeft=e.scrollPixelLeft,t.canvasOffsetLeft=e.canvasOffsetLeft,t.canvasOffsetTop=e.canvasOffsetTop,t.width=e.width,t.height=e.height,t.mousex=e.mouse.x,t.mousey=e.mouse.y,t.touchx=e.touchStart?e.touchStart.x:0,t.touchy=e.touchStart?e.touchStart.y:0,t.entities=e.visibleCells.length,t.hasFocus=e.hasFocus,t.dragMode=e.dragMode,e.currentCell&&(t.columnIndex=e.currentCell.columnIndex,t.rowIndex=e.currentCell.rowIndex,t.sortColumnIndex=e.currentCell.sortColumnIndex,t.sortRowIndex=e.currentCell.sortRowIndex,t.context=e.currentCell.context,t.dragContext=e.currentCell.dragContext,t.style=e.currentCell.style,t.type=e.currentCell.type),e.ctx.save(),Object.keys(t).forEach(function(o,r){var n=o+": "+t[o];e.ctx.fillStyle="rgba(255, 255, 255, 0.8)",i(j,14+14*r,100,14),e.ctx.fillStyle="rgba(0, 0, 0, 1)",a(n,j+1,D+14*r)}),e.ctx.restore())}(),e.dispatchEvent("afterdraw",{})||e.ctx.restore()}}}}}.apply(t,r))&&(e.exports=n)},function(e,t,o){var r,n;r=[],void 0!==(n=function(){"use strict";return function(e){var t={x:0,y:0,scrollTop:0,scrollLeft:0},o={scrollLeft:0,scrollTop:0},r={scrollLeft:0,scrollTop:0},n=0,l=0,i=!1,s=!1,a=0;e.getTouchPos=function(t){var o=e.canvas.getBoundingClientRect(),r={x:t.touches[0].clientX-o.left,y:t.touches[0].clientY-o.top};return e.isChildGrid&&(r.x-=e.canvasOffsetLeft,r.y-=e.canvasOffsetTop),{x:r.x,y:r.y,rect:o}},e.calculatePPS=function(){n=(t.scrollLeft-r.scrollLeft)/(t.t-r.t),l=(t.scrollTop-r.scrollTop)/(t.t-r.t),r={scrollLeft:t.scrollLeft,scrollTop:t.scrollTop,t:performance.now()/1e3}},e.touchCell=function(o){return function(){clearInterval(e.touchCalcTimeout);var r=e.getTouchPos(o);Math.abs(t.x)+Math.abs(t.y)<e.attributes.touchDeadZone&&(i=e.getCellAt(r.x,r.y),e.mousemove(o,r),e.mousedown(o,r),e.mousemove(o,r),e.draw())}},e.touchstart=function(o){if(i=!1,e.touchStart=e.getTouchPos(o),s=e.getCellAt(e.touchStart.x,e.touchStart.y,!0),!e.dispatchEvent("touchstart",{NativeEvent:o,cell:e.startingCell})&&e.hasFocus){if(e.stopPropagation(o),o.preventDefault(),2===o.touches.length)return e.contextmenu(o,e.touchStart);e.touchScrollStart={scrollLeft:e.scrollBox.scrollLeft,scrollTop:e.scrollBox.scrollTop,t:performance.now()/1e3},t={x:e.touchStart.x,y:e.touchStart.y,scrollLeft:e.scrollBox.scrollLeft,scrollTop:e.scrollBox.scrollTop,t:0},e.touchmove(o),clearTimeout(e.touchTimeout),clearInterval(e.touchCalcTimeout),e.touchTimeout=setTimeout(e.touchCell(o),e.attributes.touchSelectTimeMs),e.touchCalcTimeout=setInterval(e.calculatePPS,20),e.touchHaltAnimation=!0,document.body.addEventListener("touchmove",e.touchmove,{passive:!1}),document.body.addEventListener("touchend",e.touchend,!1),document.body.addEventListener("touchcancel",e.touchcancel,!1)}},e.easing=function(e,t,o,r){return o*(e/r)*(2-e)+t},e.touchEndAnimation=function(){if(!e.canvas||!e.scrollBox.scrollTo)return requestAnimationFrame(e.touchEndAnimation);var r,n,l,i=performance.now()/1e3,s=e.attributes.touchReleaseAnimationDurationMs/1e3;if(t.t=t.t||i+s,(l=i-t.t+1)>1||e.touchHaltAnimation||a>1e3)return a=0,e.touchHaltAnimation=!1,void(o={scrollLeft:-1,scrollTop:-1});a+=1,r=e.easing(l,t.scrollLeft,-o.scrollLeft,s),n=e.easing(l,t.scrollTop,-o.scrollTop,s),e.scrollBox.scrollTo(r,n),requestAnimationFrame(e.touchEndAnimation)},e.touchend=function(r){if(!e.dispatchEvent("touchend",{NativeEvent:r})){var c=Math.abs(t.x)+Math.abs(t.y)<e.attributes.touchDeadZone,d={x:e.touchStart.x+t.x,y:e.touchStart.y+t.y},u=e.getCellAt(d.x,d.y);e.hasFocus&&(i?e.mouseup(r,e.touchStart):c&&(u.active?e.beginEditAt(u.columnIndex,u.rowIndex):(e.mousedown(r,e.touchStart),e.mouseup(r,e.touchStart),e.click(r,e.touchStart))),i=!1,document.body.removeEventListener("touchmove",e.touchmove,{passive:!1}),document.body.removeEventListener("touchend",e.touchend,!1),document.body.removeEventListener("touchcancel",e.touchcancel,!1),clearTimeout(e.touchTimeout),clearInterval(e.touchCalcTimeout),e.calculatePPS(),o.scrollLeft=n*e.attributes.touchReleaseAcceleration,o.scrollTop=l*e.attributes.touchReleaseAcceleration,e.touchHaltAnimation=!1,0!==a||/-scroll-/.test(s.style)||c||e.touchEndAnimation())}},e.touchmove=function(o){var r=e.getTouchPos(o);e.dispatchEvent("touchmove",{NativeEvent:o,cell:e.currentCell})||(e.stopPropagation(o),o.preventDefault(),e.hasFocus&&(t={x:r.x-e.touchStart.x,y:r.y-e.touchStart.y,scrollLeft:e.scrollBox.scrollLeft,scrollTop:e.scrollBox.scrollTop,t:0},/vertical-scroll-/.test(s.style)?e.scrollBox.scrollTop=e.scrollBox.scrollHeight*(r.y/e.height):/horizontal-scroll-/.test(s.style)?e.scrollBox.scrollLeft=e.scrollBox.scrollWidth*(r.x/e.width):i?(e.mousemove(o,r),e.draw()):0===a&&e.scrollBox.scrollTo(e.touchScrollStart.scrollLeft-t.x,e.touchScrollStart.scrollTop-t.y)))},e.touchcancel=function(t){e.dispatchEvent("touchcancel",{NativeEvent:t,cell:e.currentCell})||e.hasFocus&&(e.touchend(t),i=!1,document.body.removeEventListener("touchmove",e.touchmove,{passive:!1}),document.body.removeEventListener("touchend",e.touchend,!1),document.body.removeEventListener("touchcancel",e.touchcancel,!1))},e.stopPropagation=function(e){e.stopPropagation()},e.addEventListener=function(t,o){e.events[t]=e.events[t]||[],e.events[t].unshift(o)},e.removeEventListener=function(t,o){(e.events[t]||[]).forEach(function(r,n){o===r&&e.events[t].splice(n,1)})},e.dispatchEvent=function(t,o){function r(){n=!0}var n;if(e.events[t])return e.events[t].forEach(function(t){o.ctx=e.ctx,o.preventDefault=r,t.apply(e.intf,[o])}),n},e.resize=function(t){var o,r,n=2*e.style.cellBorderWidth,l=2*e.style.columnHeaderCellBorderWidth,i=e.getRowHeaderCellHeight(),s=e.getColumnHeaderCellWidth();return e.isChildGrid?(e.height=e.parentNode.offsetHeight,e.width=e.parentNode.offsetWidth):(e.parentNode=e.parentDOMNode,e.parentIsCanvas||(e.height=e.parentDOMNode.offsetHeight,e.width=e.parentDOMNode.offsetWidth,e.canvas.height=e.height*window.devicePixelRatio,e.canvas.width=e.width*window.devicePixelRatio,e.canvas.style.height=e.height+"px",e.canvas.style.width=e.width+"px"),e.canvasOffsetTop=e.args.canvasOffsetTop||0,e.canvasOffsetLeft=e.args.canvasOffsetLeft||0),o=e.data.reduce(function(t,o){return t+(e.sizes.rows[o[e.uniqueId]]||e.style.cellHeight)+(e.sizes.trees[o[e.uniqueId]]||0)+n},0)||0,r=e.getVisibleSchema().reduce(function(t,o){return o.hidden?t:t+(e.sizes.columns[o[e.uniqueId]]||o.width||e.style.columnWidth)+n},0)||0,e.attributes.showNewRow&&(o+=e.style.cellHeight+n),e.scrollBox.width=e.width-s,e.scrollBox.height=e.height-i-l,e.scrollBox.top=i+l,e.scrollBox.left=s,e.scrollBox.scrollHeight=o+e.style.scrollBarWidth-e.scrollBox.height,e.scrollBox.scrollWidth=r+e.style.scrollBarWidth-e.scrollBox.width,e.scrollBox.widthBoxRatio=(e.scrollBox.width-15)/(e.scrollBox.scrollWidth+e.scrollBox.width-15),e.scrollBox.scrollBoxWidth=e.scrollBox.width*e.scrollBox.widthBoxRatio-e.style.scrollBarWidth,e.scrollBox.heightBoxRatio=(e.scrollBox.height-30)/(e.scrollBox.scrollHeight+(e.scrollBox.height-30)),e.scrollBox.scrollBoxHeight=e.scrollBox.height*e.scrollBox.heightBoxRatio-e.style.scrollBarWidth,e.scrollBox.scrollBoxWidth=Math.max(e.scrollBox.scrollBoxWidth,e.style.scrollBarBoxMinSize),e.scrollBox.scrollBoxHeight=Math.max(e.scrollBox.scrollBoxHeight,e.style.scrollBarBoxMinSize),e.page=e.visibleRows.length-3-e.attributes.pageUpDownOverlap,e.resizeEditInput(),e.scroll(!0),t&&e.draw(!0),e.dispatchEvent("resize",{}),!0},e.resizeEditInput=function(){if(e.input){var t=e.canvas.getBoundingClientRect(),o=e.scrollOffset(e.canvas),r=2*e.style.cellBorderWidth,n=e.getVisibleCellByIndex(e.input.editCell.columnIndex,e.input.editCell.rowIndex)||{x:-100,y:-100,height:0,width:0};e.input.style.left=t.left+n.x-e.style.cellBorderWidth+e.canvasOffsetLeft-o.left+"px",e.input.style.top=t.top+n.y-r+e.canvasOffsetTop-o.top+"px",e.input.style.height=n.height-r-1+"px",e.input.style.width=n.width-r-e.style.cellPaddingLeft+"px",e.clipElement(e.input)}},e.scroll=function(t,o){var r=e.getVisibleSchema(),n=2*e.style.cellBorderWidth;for(e.scrollIndexTop=0,e.scrollPixelTop=0,e.scrollIndexLeft=0,e.scrollPixelLeft=0;e.scrollPixelTop<e.scrollBox.scrollTop&&e.scrollIndexTop<e.data.length;)e.scrollPixelTop+=(e.sizes.rows[e.data[e.scrollIndexTop][e.uniqueId]]||e.style.cellHeight)+(e.sizes.trees[e.data[e.scrollIndexTop][e.uniqueId]]||0)+n,e.scrollIndexTop+=1;for(;e.scrollPixelLeft<e.scrollBox.scrollLeft&&e.scrollIndexLeft<r.length;)e.scrollPixelLeft+=e.sizes.columns[r[e.scrollIndexLeft][e.uniqueId]]||r[e.scrollIndexLeft].width,e.scrollIndexLeft+=1;e.data.length>0&&(e.scrollIndexLeft=Math.max(e.scrollIndexLeft-1,0),e.scrollPixelLeft=Math.max(e.scrollPixelLeft-(e.sizes.columns[r[e.scrollIndexLeft][e.uniqueId]]||r[e.scrollIndexLeft].width),0),e.scrollIndexTop=Math.max(e.scrollIndexTop-1,0),e.scrollPixelTop=Math.max(e.scrollPixelTop-(e.sizes.rows[e.data[e.scrollIndexTop][e.uniqueId]]||e.style.cellHeight)-(e.sizes.trees[e.data[e.scrollIndexTop][e.uniqueId]]||0),0)),e.ellipsisCache={},o||e.draw(!0),requestAnimationFrame(e.resizeEditInput),e.dispatchEvent("scroll",{top:e.scrollBox.scrollTop,left:e.scrollBox.scrollLeft})},e.mousemove=function(t,o){if(!e.contextMenu&&!e.input){e.mouse=o||e.getLayerPos(t);var r,n,l,i,s=t.controlKey||t.metaKey||e.attributes.persistantSelectionMode,a=e.getSchema(),c=e.mouse.x,d=e.mouse.y,u=e.getCellAt(c,d),h={NativeEvent:t,cell:u,x:c,y:d},f=e.currentCell;if(clearTimeout(e.scrollTimer),e.isInGrid({x:c,y:d})||(e.hasFocus=!1),!e.dispatchEvent("mousemove",h)&&(u&&e.currentCell&&(e.currentCell.rowIndex!==u.rowIndex||e.currentCell.columnIndex!==u.columnIndex)&&(e.cellBoundaryCrossed=!0,h.cell=f,e.dispatchEvent("cellmouseout",h),h.cell=u,e.dispatchEvent("cellmouseover",h)),e.currentCell=u,e.hasFocus)){if(e.hovers={},!e.draggingItem&&u&&-1===e.scrollModes.indexOf(u.context)&&(e.dragItem=u,e.dragMode=u.dragContext,e.canvas.style.cursor=u.context,"cell"===u.context&&u.data&&(e.canvas.style.cursor="pointer",e.hovers[u.data[e.uniqueId]]=[u.columnIndex]),(e.selecting||e.reorderObject)&&"cell"===u.context&&u.data)){if(l=e.getSelectionBounds(),i={x:Math.abs(e.dragStart.x-c),y:Math.abs(e.dragStart.y-d)},-1!==e.dragStartObject.columnIndex&&t.shiftKey&&(e.dragStartObject={rowIndex:e.activeCell.rowIndex,columnIndex:e.activeCell.columnIndex}),n={top:Math.min(e.dragStartObject.rowIndex,u.rowIndex),left:Math.min(e.dragStartObject.columnIndex,u.columnIndex),bottom:Math.max(e.dragStartObject.rowIndex,u.rowIndex),right:Math.max(e.dragStartObject.columnIndex,u.columnIndex)},-1===e.dragStartObject.columnIndex&&(n.left=-1,n.right=a.length-1,n.top=Math.min(l.top,u.rowIndex),n.bottom=Math.max(l.bottom,u.rowIndex)),e.dragStartObject.rowIndex===u.rowIndex&&e.dragStartObject.columnIndex===u.columnIndex||(e.ignoreNextClick=!0),(e.cellBoundaryCrossed||0===i.x&&0===i.y||e.attributes.rowSelectionMode)&&(e.attributes.rowSelectionMode||-1===e.dragStartObject.columnIndex?e.selectRow(u.rowIndex,s,null,!0):e.dragAddToSelection||void 0===u.rowIndex?(e.selections[u.rowIndex]=e.selections[u.rowIndex]||[],-1===e.selections[u.rowIndex].indexOf(u.columnIndex)&&e.selections[u.rowIndex].push(u.columnIndex)):e.selections[u.rowIndex]&&-1!==e.selections[u.rowIndex].indexOf(u.columnIndex)&&e.selections[u.rowIndex].splice(e.selections[u.rowIndex].indexOf(u.columnIndex),1)),!(e.selectionBounds&&n.top===e.selectionBounds.top&&n.left===e.selectionBounds.left&&n.bottom===e.selectionBounds.bottom&&n.right===e.selectionBounds.right||s))if(e.selections=[],l=n,e.attributes.rowSelectionMode)for(r=l.top;r<=l.bottom;r+=1)e.selectRow(r,!0,null,!0);else e.selectArea(l,!0);e.autoScrollZone(t,c,d,s)}e.cellBoundaryCrossed=!1,e.draw(!0)}}},e.click=function(t,o){function r(){l&&e.dispatchEvent("selectionchanged",{selectedData:e.getSelectedData(),selections:e.selections,selectionBounds:e.selectionBounds})}var n,l,i=t.controlKey||t.metaKey||e.attributes.persistantSelectionMode,s=o||e.getLayerPos(t);if(e.currentCell=e.getCellAt(s.x,s.y),void 0===e.currentCell.grid){if(e.input&&e.endEdit(),e.ignoreNextClick)return void(e.ignoreNextClick=!1);if(n=e.currentCell,!e.dispatchEvent("click",{NativeEvent:t,cell:e.currentCell})&&e.hasFocus){if("cell"===e.currentCell.context){if("cornerCell"===e.currentCell.style)return e.order(e.uniqueId,"asc",e.sorters.number),e.setFilter(),void r();if("columnHeaderCell"===e.currentCell.style){if("sort"===e.attributes.columnHeaderClickBehavior)return e.orderBy===n.header.name?e.orderDirection="asc"===e.orderDirection?"desc":"asc":e.orderDirection="asc",e.order(n.header.name,e.orderDirection),void r();if("select"===e.attributes.columnHeaderClickBehavior)return e.selectColumn(n.header.index,i,t.shiftKey,!0),r(),void e.draw()}if(-1!==["rowHeaderCell","columnHeaderCell"].indexOf(e.currentCell.style)||i||e.setActiveCell(n.columnIndex,n.rowIndex),e.selections[n.rowIndex]=e.selections[n.rowIndex]||[],e.attributes.rowSelectionMode||"rowHeaderCell"===e.currentCell.style){if("rowHeaderCell"===e.currentCell.style&&e.attributes.tree&&s.x>0&&s.x-e.currentCell.x<e.style.treeArrowWidth+e.style.treeArrowMarginLeft+e.style.treeArrowMarginRight+e.style.treeArrowClickRadius&&s.y-e.currentCell.y<e.style.treeArrowHeight+e.style.treeArrowMarginTop+e.style.treeArrowClickRadius&&s.y>0)return void e.toggleTree(n.rowIndex);l=!0,e.selectRow(n.rowIndex,i,null,!0)}t.shiftKey&&!i&&(e.selectionBounds=e.getSelectionBounds(),e.selectArea(void 0,!1))}r(),e.draw(!0)}}},e.dragResizeColumn=function(t){var o,r,n;return o=e.getLayerPos(t),r=e.resizingStartingWidth+o.x-e.dragStart.x,n=e.resizingStartingHeight+o.y-e.dragStart.y,r<e.style.minColumnWidth&&(r=e.style.minColumnWidth),n<e.style.minRowHeight&&(n=e.style.minRowHeight),!e.dispatchEvent("resizecolumn",{x:r,y:n,draggingItem:e.draggingItem})&&(e.scrollBox.scrollLeft>e.scrollBox.scrollWidth-e.attributes.resizeScrollZone&&"ew-resize"===e.dragMode&&(e.resize(!0),e.scrollBox.scrollLeft+=r),"ew-resize"===e.dragMode?(e.sizes.columns["rowHeaderCell"===e.draggingItem.header.style?"cornerCell":e.draggingItem.header[e.uniqueId]]=r,-1!==["rowHeaderCell","cornerCell"].indexOf(e.draggingItem.header.style)&&e.resize(!0),void e.resizeChildGrids()):"ns-resize"===e.dragMode?(e.draggingItem.rowOpen?e.sizes.trees[e.draggingItem.data[e.uniqueId]]=n:e.attributes.globalRowResize?e.style.cellHeight=n:e.sizes.rows[e.draggingItem.data[e.uniqueId]]=n,e.dispatchEvent("resizerow",{row:n}),void e.resizeChildGrids()):void(e.ellipsisCache={}))},e.stopDragResize=function(){e.resize(),document.body.removeEventListener("mousemove",e.dragResizeColumn,!1),document.body.removeEventListener("mouseup",e.stopDragResize,!1),e.setStorageData(),e.draw(!0),e.ignoreNextClick=!0},e.scrollGrid=function(t){var o=e.getLayerPos(t);return e.attributes.scrollPointerLock&&e.pointerLockPosition&&-1!==["horizontal-scroll-box","vertical-scroll-box"].indexOf(e.scrollStartMode)&&(e.pointerLockPosition.x+=t.movementX,e.pointerLockPosition.y+=t.movementY,o=e.pointerLockPosition),e.scrollMode=e.getCellAt(o.x,o.y).context,"horizontal-scroll-box"===e.scrollMode&&"horizontal-scroll-box"!==e.scrollStartMode?(e.scrollStartMode="horizontal-scroll-box",e.dragStart=o,e.scrollStart.left=e.scrollBox.scrollLeft,void clearTimeout(e.scrollTimer)):"vertical-scroll-box"===e.scrollMode&&"vertical-scroll-box"!==e.scrollStartMode?(e.scrollStartMode="vertical-scroll-box",e.dragStart=o,e.scrollStart.top=e.scrollBox.scrollTop,void clearTimeout(e.scrollTimer)):("vertical-scroll-box"===e.scrollStartMode&&"vertical-scroll-box"!==e.scrollMode&&(e.scrollMode="vertical-scroll-box"),"horizontal-scroll-box"===e.scrollStartMode&&"horizontal-scroll-box"!==e.scrollMode&&(e.scrollMode="horizontal-scroll-box"),clearTimeout(e.scrollTimer),void(-1!==e.scrollModes.indexOf(e.scrollMode)&&("vertical-scroll-box"===e.scrollMode?e.scrollBox.scrollTop=e.scrollStart.top+(o.y-e.dragStart.y)/e.scrollBox.heightBoxRatio:"vertical-scroll-top"===e.scrollMode?(e.scrollBox.scrollTop-=e.page*e.style.cellHeight,e.scrollTimer=setTimeout(e.scrollGrid,e.attributes.scrollRepeatRate,t)):"vertical-scroll-bottom"===e.scrollMode&&(e.scrollBox.scrollTop+=e.page*e.style.cellHeight,e.scrollTimer=setTimeout(e.scrollGrid,e.attributes.scrollRepeatRate,t)),"horizontal-scroll-box"===e.scrollMode?e.scrollBox.scrollLeft=e.scrollStart.left+(o.x-e.dragStart.x)/e.scrollBox.widthBoxRatio:"horizontal-scroll-right"===e.scrollMode?(e.scrollBox.scrollLeft+=e.attributes.selectionScrollIncrement,e.scrollTimer=setTimeout(e.scrollGrid,e.attributes.scrollRepeatRate,t)):"horizontal-scroll-left"===e.scrollMode&&(e.scrollBox.scrollLeft-=e.attributes.selectionScrollIncrement,e.scrollTimer=setTimeout(e.scrollGrid,e.attributes.scrollRepeatRate,t)))))},e.stopScrollGrid=function(){clearTimeout(e.scrollTimer),document.exitPointerLock&&document.exitPointerLock(),document.body.removeEventListener("mousemove",e.scrollGrid,!1)},e.dragReorder=function(t){var o,r,n;o=e.getLayerPos(t),r=o.x-e.dragStart.x,n=o.y-e.dragStart.y,(e.attributes.allowColumnReordering||"column-reorder"!==e.dragMode)&&(e.attributes.allowRowReordering||"row-reorder"!==e.dragMode)&&(e.dispatchEvent("reordering",{NativeEvent:t,source:e.dragStartObject,target:e.currentCell,dragMode:e.dragMode})||(Math.abs(r)>e.attributes.reorderDeadZone||Math.abs(n)>e.attributes.reorderDeadZone)&&(e.reorderObject=e.dragStartObject,e.reorderTarget=e.currentCell,e.reorderObject.dragOffset={x:r,y:n},e.autoScrollZone(t,o.x,o.x,!1)))},e.stopDragReorder=function(t){var o={"row-reorder":e.orders.rows,"column-reorder":e.orders.columns},r={"row-reorder":"rowIndex","column-reorder":"columnIndex"}[e.dragMode];document.body.removeEventListener("mousemove",e.dragReorder,!1),document.body.removeEventListener("mouseup",e.stopDragReorder,!1),e.reorderObject&&e.reorderTarget&&(e.ignoreNextClick=!0,e.reorderObject[r]===e.reorderTarget[r]||e.dispatchEvent("reorder",{NativeEvent:t,source:e.reorderObject,target:e.reorderTarget,dragMode:e.dragMode})||(o[e.dragMode].splice(o[e.dragMode].indexOf(e.reorderObject[r]),1),o[e.dragMode].splice(o[e.dragMode].indexOf(e.reorderTarget[r]),0,e.reorderObject[r]),e.setStorageData())),e.reorderObject=void 0,e.reorderTarget=void 0,e.draw(!0)},e.mousedown=function(t,o){if(e.lastMouseDownTarget=t.target,!e.dispatchEvent("mousedown",{NativeEvent:t,cell:e.currentCell})&&e.hasFocus&&2!==t.button&&!e.input){var r=t.controlKey||t.metaKey;if(e.dragStart=o||e.getLayerPos(t),e.scrollStart={left:e.scrollBox.scrollLeft,top:e.scrollBox.scrollTop},e.dragStartObject=e.getCellAt(e.dragStart.x,e.dragStart.y),e.dragAddToSelection=!e.dragStartObject.selected,r||t.shiftKey||/(vertical|horizontal)-scroll-(bar|box)/.test(e.dragStartObject.context)||e.currentCell.isColumnHeader||(e.selections=[]),!e.dragStartObject.isGrid){if(-1!==e.scrollModes.indexOf(e.dragStartObject.context))return e.scrollMode=e.dragStartObject.context,e.scrollStartMode=e.dragStartObject.context,e.scrollGrid(t),e.attributes.scrollPointerLock&&-1!==["horizontal-scroll-box","vertical-scroll-box"].indexOf(e.scrollStartMode)&&(e.pointerLockPosition={x:e.dragStart.x,y:e.dragStart.y},e.canvas.requestPointerLock()),document.body.addEventListener("mousemove",e.scrollGrid,!1),document.body.addEventListener("mouseup",e.stopScrollGrid,!1),void(e.ignoreNextClick=!0);if("cell"===e.dragMode)return e.selecting=!0,e.attributes.rowSelectionMode&&e.selectRow(e.dragStartObject.rowIndex,r,null,!0),e.mousemove(t);-1!==["ns-resize","ew-resize"].indexOf(e.dragMode)&&(e.draggingItem=e.dragItem,e.draggingItem.rowOpen?e.resizingStartingHeight=e.sizes.trees[e.draggingItem.data[e.uniqueId]]:e.resizingStartingHeight=e.sizes.rows[e.draggingItem.data[e.uniqueId]]||e.style.cellHeight,e.resizingStartingWidth=e.sizes.columns["rowHeaderCell"===e.draggingItem.header.style?"cornerCell":e.draggingItem.header[e.uniqueId]]||e.draggingItem.header.width,document.body.addEventListener("mousemove",e.dragResizeColumn,!1),document.body.addEventListener("mouseup",e.stopDragResize,!1)),-1!==["row-reorder","column-reorder"].indexOf(e.dragMode)&&(e.draggingItem=e.dragItem,document.body.addEventListener("mousemove",e.dragReorder,!1),document.body.addEventListener("mouseup",e.stopDragReorder,!1))}}},e.mouseup=function(t){clearTimeout(e.scrollTimer),e.cellBoundaryCrossed=!0,e.selecting=void 0,e.draggingItem=void 0,e.dragStartObject=void 0,e.dispatchEvent("mouseup",{NativeEvent:t,cell:e.currentCell})||(e.hasFocus||t.target===e.canvas)&&(e.currentCell&&void 0!==e.currentCell.grid||e.contextMenu||e.input||(e.dragStart&&e.isInGrid(e.dragStart)&&e.controlInput.focus(),t.preventDefault()))},e.keydown=function(t){var o,r=e.activeCell.columnIndex,n=e.activeCell.rowIndex,l=t.controlKey||t.metaKey,i=e.data.length-1,s=e.getVisibleSchema().length-1;if(!e.dispatchEvent("keydown",{NativeEvent:t,cell:e.currentCell})&&e.hasFocus){if(e.page=e.visibleRows.length-3-e.attributes.pageUpDownOverlap,e.attributes.showNewRow&&(i+=1),9===t.keyCode&&t.preventDefault(),l&&65===t.keyCode?e.selectAll():40===t.keyCode?n+=1:38===t.keyCode?n-=1:37===t.keyCode||t.shiftKey&&9===t.keyCode?r-=1:39===t.keyCode||!t.shiftKey&&9===t.keyCode?r+=1:33===t.keyCode?(n-=e.page,t.preventDefault()):34===t.keyCode?(n+=e.page,t.preventDefault()):36===t.keyCode||l&&38===t.keyCode?n=0:35===t.keyCode||l&&40===t.keyCode?n=e.data.length-1:l&&39===t.keyCode?r=s:l&&37===t.keyCode&&(r=0),13===t.keyCode)return e.beginEditAt(r,n);if(32===t.keyCode){if(e.selections=[],e.selections[Math.max(n,0)]=[],e.selections[Math.max(n,0)].push(r),e.selectionBounds=e.getSelectionBounds(),e.attributes.rowSelectionMode)for(o=e.selectionBounds.top;o<=e.selectionBounds.bottom;o+=1)e.selectRow(o,l,null,!0);else e.selectArea(void 0,l);return t.preventDefault(),void e.draw(!0)}r<0&&(r=0),n>i&&(n=i),n<0&&(n=0),r>s&&(r=s),t.shiftKey&&-1!==[37,38,39,40].indexOf(t.keyCode)&&(e.selections[Math.max(n,0)]=e.selections[Math.max(n,0)]||[],e.selections[Math.max(n,0)].push(r),e.selectionBounds=e.getSelectionBounds(),e.selectArea(void 0,l),e.draw(!0)),r===e.activeCell.columnIndex&&n===e.activeCell.rowIndex||(e.scrollIntoView(r!==e.activeCell.columnIndex?r:void 0,n!==e.activeCell.rowIndex?n:void 0),e.setActiveCell(r,n),!t.shiftKey&&e.attributes.selectionFollowsActiveCell&&(l||(e.selections=[]),e.selections[n]=e.selections[n]||[],e.selections[n].push(r),e.dispatchEvent("selectionchanged",{selectedData:e.getSelectedData(),selections:e.selections,selectionBounds:e.selectionBounds})),e.draw(!0))}},e.keyup=function(t){e.dispatchEvent("keyup",{NativeEvent:t,cell:e.currentCell})||e.hasFocus&&(e.controlInput.value="")},e.keypress=function(t){e.hasFocus&&e.dispatchEvent("keypress",{NativeEvent:t,cell:e.currentCell})},e.dblclick=function(t){e.dispatchEvent("dblclick",{NativeEvent:t,cell:e.currentCell})||e.hasFocus&&("ew-resize"===e.currentCell.context&&"columnHeaderCell"===e.currentCell.style?e.fitColumnToValues(e.currentCell.header.name):"ew-resize"===e.currentCell.context&&"cornerCell"===e.currentCell.style?e.autosize():-1!==["cell","activeCell"].indexOf(e.currentCell.style)&&e.beginEditAt(e.currentCell.columnIndex,e.currentCell.rowIndex))},e.scrollWheel=function(t){if(!e.dispatchEvent("wheel",{NativeEvent:t})){e.touchHaltAnimation=!0;var o=e.scrollBox.scrollLeft,r=e.scrollBox.scrollTop;e.hasFocus&&(e.scrollBox.scrollTop+=t.deltaY,e.scrollBox.scrollLeft+=t.deltaX),r===e.scrollBox.scrollTop&&o===e.scrollBox.scrollLeft||t.preventDefault()}},e.copy=function(t){if(!e.dispatchEvent("copy",{NativeEvent:t})&&e.hasFocus&&t.clipboardData){var o=[],r=e.getSelectedData();r.length>0&&(r.forEach(function(e){if(e){var t=[];Object.keys(e).forEach(function(o){t.push('"'+e[o].replace(/"/g,'""')+'"')}),t.join(","),o.push(t)}}),t.clipboardData.setData("text/plain",o.join("\n")),t.preventDefault())}}}}.apply(t,r))&&(e.exports=n)},function(e,t,o){var r,n;r=[],void 0!==(n=function(){"use strict";return function(e){e.orders={rows:[],columns:[]},e.hasFocus=!1,e.activeCell={columnIndex:0,rowIndex:0},e.storageName="canvasDataGrid",e.invalidSearchExpClass="canvas-datagrid-invalid-search-regExp",e.localStyleLibraryStorageKey="canvas-datagrid-user-style-library",e.uniqueId="_canvasDataGridUniqueId",e.orderBy=e.uniqueId,e.orderDirection="asc",e.columnFilters={},e.filters={},e.ellipsisCache={},e.scrollBox={},e.visibleRows=[],e.sizes={rows:{},columns:{},trees:{}},e.currentFilter=function(){return!0},e.selections=[],e.hovers={},e.attributes={},e.style={},e.intf={},e.formatters={},e.sorters={},e.schemaHashes={},e.events={},e.uId=0,e.changes=[],e.scrollIndexTop=0,e.scrollPixelTop=0,e.scrollIndexLeft=0,e.scrollPixelLeft=0,e.childGrids={},e.openChildren={},e.scrollModes=["vertical-scroll-box","vertical-scroll-top","vertical-scroll-bottom","horizontal-scroll-box","horizontal-scroll-right","horizontal-scroll-left"],e.mouse={x:0,y:0},e.getSelectedData=function(t){var o=[],r=e.getSchema(),n=e.data.length;return e.selections.forEach(function(l,i){if(i!==n){if(0===l.length)return void(o[i]=null);o[i]={},t?r.forEach(function(t){o[i][t.name]=e.data[i][t.name]}):l.forEach(function(t){-1!==t&&(o[i][r[t].name]=e.data[i][r[t].name])})}}),o},e.scrollOffset=function(e){for(var t=0,o=0;e.parentNode;)"canvas-datagrid-tree"!==e.nodeType&&"canvas-datagrid-cell"!==e.nodeType&&(t-=e.scrollLeft,o-=e.scrollTop),e=e.parentNode;return{left:t,top:o}},e.position=function(t,o){for(var r,n,l=0,i=0,s=t;t.offsetParent;)l+=t.offsetLeft,i+=t.offsetTop,r=t.offsetHeight,n=t.offsetWidth,t=t.offsetParent;return o?{left:l,top:i,height:r,width:n}:(t=s,s=e.scrollOffset(t),{left:l+s.left,top:i+s.top,height:r,width:n})},e.getLayerPos=function(t){var o=e.canvas.getBoundingClientRect(),r={x:t.clientX-o.left,y:t.clientY-o.top};return e.isChildGrid&&(r.x-=e.canvasOffsetLeft,r.y-=e.canvasOffsetTop),{x:r.x,y:r.y,rect:o}},e.fillArray=function(e,t,o){o=o||1;var r,n=[];for(r=e;r<=t;r+=o)n[r]=r;return n},e.getRowHeaderCellHeight=function(){return e.attributes.showColumnHeaders?e.sizes.rows[-1]||e.style.columnHeaderCellHeight:0},e.getColumnHeaderCellWidth=function(){return e.attributes.showRowHeaders?e.sizes.columns.cornerCell||e.style.rowHeaderCellWidth:0},e.setStorageData=function(){e.attributes.saveAppearance&&localStorage.setItem(e.storageName+"-"+e.attributes.name,JSON.stringify({sizes:{rows:e.sizes.rows,columns:e.sizes.columns},orders:{rows:e.orders.rows,columns:e.orders.columns},orderBy:e.orderBy,orderDirection:e.orderDirection}))},e.getSchema=function(){return e.schema||e.tempSchema},e.createColumnOrders=function(){var t=e.getSchema();e.orders.columns=e.fillArray(0,t.length-1)},e.createRowOrders=function(){e.orders.rows=e.fillArray(0,e.data.length-1)},e.getVisibleSchema=function(){return e.getSchema().filter(function(e){return!e.hidden})},e.applyDefaultValue=function(t,o){var r=o.defaultValue||"";"function"==typeof r&&(r=r.apply(e.intf,[o])),t[o.name]=r},e.createNewRowData=function(){e.newRow={},e.newRow[e.uniqueId]=e.uId,e.uId+=1,e.getSchema().forEach(function(t){e.applyDefaultValue(e.newRow,t)})},e.getSchemaNameHash=function(t){for(var o=0;e.schemaHashes[t];)o+=1,t+=o;return t},e.filter=function(t){var o=e.filters[t];return o||void 0===t||(console.warn("Cannot find filter for type %s, falling back to substring match.",t),o=e.filters.string),o},e.getBestGuessDataType=function(t){var o,r,n=e.data.length;for(r=0;r<n;r+=1)if(-1!==[null,void 0].indexOf(e.data[r][t]))return o=typeof e.data[r],"object"===o?"string":o;return"string"},e.drawChildGrids=function(){Object.keys(e.childGrids).forEach(function(t){e.childGrids[t].draw()})},e.resizeChildGrids=function(){Object.keys(e.childGrids).forEach(function(t){e.childGrids[t].resize()})},e.getClippingRect=function(t){var o=e.position(e.parentNode),r=e.position(t),n=e.scrollOffset(e.canvas),l={x:0,y:0,h:0,w:0},i={x:-1/0,y:-1/0,h:1/0,w:1/0},s=e.getRowHeaderCellHeight(),a=e.getColumnHeaderCellWidth();return o.top-=n.top,o.left-=n.left,r.top-=n.top,r.left-=n.left,l.h=o.top+o.height-t.offsetTop-e.style.scrollBarWidth,l.w=o.left+o.width-t.offsetLeft-e.style.scrollBarWidth,l.x=o.left+-1*r.left+a,l.y=o.top+-1*r.top+s,{x:l.x>i.x?l.x:i.x,y:l.y>i.y?l.y:i.y,h:l.h<i.h?l.h:i.h,w:l.w<i.w?l.w:i.w}},e.clipElement=function(t){var o=e.getClippingRect(t);o.w<0&&(o.w=0),o.h<0&&(o.h=0),t.style.clip="rect("+o.y+"px,"+o.w+"px,"+o.h+"px,"+o.x+"px)"},e.autoScrollZone=function(t,o,r,n){var l,i=e.getColumnHeaderCellWidth(),s=e.getRowHeaderCellHeight();o>e.width-e.attributes.selectionScrollZone&&o<e.width&&(e.scrollBox.scrollLeft+=e.attributes.selectionScrollIncrement,l=!0),r>e.height-e.attributes.selectionScrollZone&&r<e.height&&(e.scrollBox.scrollTop+=e.attributes.selectionScrollIncrement,l=!0),o-e.attributes.selectionScrollZone-i<0&&(e.scrollBox.scrollLeft-=e.attributes.selectionScrollIncrement,l=!0),r-e.attributes.selectionScrollZone-s<0&&(e.scrollBox.scrollTop-=e.attributes.selectionScrollIncrement,l=!0),l&&!n&&e.currentCell&&-1!==e.currentCell.columnIndex&&(e.scrollTimer=setTimeout(e.mousemove,e.attributes.scrollRepeatRate,t))},e.refreshFromOrigialData=function(){e.data=e.originalData.filter(function(e){return!0})},e.validateColumn=function(e,t){if(!e.name)throw new Error("A column must contain at least a name.");if(t.filter(function(t){return t.name===e.name}).length>0)throw new Error("A column with the name "+e.name+" already exists and cannot be added again.");return!0},e.setDefaults=function(e,t,o,r){e[o]=void 0===t[o]?r:t[o]},e.setAttributes=function(){e.defaults.attributes.forEach(function(t){e.setDefaults(e.attributes,e.args,t[0],t[1])})},e.setStyle=function(){e.defaults.styles.forEach(function(t){e.setDefaults(e.style,e.args.style||{},t[0],t[1])})},e.autosize=function(t){e.getVisibleSchema().forEach(function(o){o.name!==t&&void 0!==t||e.fitColumnToValues(o.name)}),e.fitColumnToValues("cornerCell")},e.dispose=function(){!e.isChildGrid&&e.canvas&&e.canvas.parentNode&&e.canvas.parentNode.removeChild(e.canvas),e.eventParent.removeEventListener("mouseup",e.mouseup,!1),e.eventParent.removeEventListener("mousedown",e.mousedown,!1),e.eventParent.removeEventListener("dblclick",e.dblclick,!1),e.eventParent.removeEventListener("click",e.click,!1),e.eventParent.removeEventListener("mousemove",e.mousemove),e.eventParent.removeEventListener("wheel",e.scrollWheel,!1),e.canvas.removeEventListener("contextmenu",e.contextmenu,!1),e.canvas.removeEventListener("copy",e.copy),e.controlInput.removeEventListener("keypress",e.keypress,!1),e.controlInput.removeEventListener("keyup",e.keyup,!1),e.controlInput.removeEventListener("keydown",e.keydown,!1),window.removeEventListener("resize",e.resize),e.observer&&e.observer.disconnect&&e.observer.disconnect()},e.tryLoadStoredOrders=function(){var t;e.storedSettings&&"object"==typeof e.storedSettings.orders&&(e.storedSettings.orders.rows.length>=e.data.length&&(e.orders.rows=e.storedSettings.orders.rows),t=e.getSchema(),e.orders.columns=e.storedSettings.orders.columns,t.forEach(function(t,o){-1===e.orders.columns.indexOf(o)&&e.orders.columns.push(o)}),e.orderBy=void 0===e.storedSettings.orderBy?e.uniqueId:e.storedSettings.orderBy,e.orderDirection=void 0===e.storedSettings.orderDirection?e.uniqueId:e.storedSettings.orderDirection,e.getHeaderByName(e.orderBy)&&e.orderDirection&&e.order(e.orderBy,e.orderDirection))},e.getFontHeight=function(e){return parseFloat(e,10)},e.parseFont=function(t){/Font/.test(t)&&(e.style[t+"Height"]=e.getFontHeight(e.style[t]))},e.initProp=function(t){e.args[t]&&Object.keys(e.args[t]).forEach(function(o){e[t][o]=e.args[t][o]})},e.init=function(){var t={};if(e.setAttributes(),e.setStyle(),e.initScrollBox(),e.setDom(),e.type="canvas-datagrid",Object.keys(e.style).forEach(e.parseFont),e.intf.type=e.type,e.intf.addEventListener=e.addEventListener,e.intf.removeEventListener=e.removeEventListener,e.intf.dispatchEvent=e.dispatchEvent,e.intf.dispose=e.dispose,e.intf.appendTo=e.appendTo,e.intf.filters=e.filters,e.intf.sorters=e.sorters,e.intf.autosize=e.autosize,e.intf.beginEditAt=e.beginEditAt,e.intf.endEdit=e.endEdit,e.intf.setActiveCell=e.setActiveCell,e.intf.scrollIntoView=e.scrollIntoView,e.intf.clearChangeLog=e.clearChangeLog,e.intf.gotoCell=e.gotoCell,e.intf.gotoRow=e.gotoRow,e.intf.findColumnScrollLeft=e.findColumnScrollLeft,e.intf.findRowScrollTop=e.findRowScrollTop,e.intf.fitColumnToValues=e.fitColumnToValues,e.intf.findColumnMaxTextLength=e.findColumnMaxTextLength,e.intf.disposeContextMenu=e.disposeContextMenu,e.intf.getCellAt=e.getCellAt,e.intf.isCellVisible=e.isCellVisible,e.intf.order=e.order,e.intf.draw=e.draw,e.intf.selectArea=e.selectArea,e.intf.clipElement=e.clipElement,e.intf.getSchemaFromData=e.getSchemaFromData,e.intf.setFilter=e.setFilter,e.intf.selectRow=e.selectRow,e.intf.parentGrid=e.parentGrid,e.intf.toggleTree=e.toggleTree,e.intf.expandTree=e.expandTree,e.intf.collapseTree=e.collapseTree,e.intf.canvas=e.canvas,e.intf.context=e.ctx,e.intf.insertRow=e.insertRow,e.intf.deleteRow=e.deleteRow,e.intf.addRow=e.addRow,e.intf.insertColumn=e.insertColumn,e.intf.deleteColumn=e.deleteColumn,e.intf.addColumn=e.addColumn,e.intf.getClippingRect=e.getClippingRect,e.intf.setRowHeight=e.setRowHeight,e.intf.setColumnWidth=e.setColumnWidth,e.intf.resetColumnWidths=e.resetColumnWidths,e.intf.resetRowHeights=e.resetRowHeights,e.intf.resize=e.resize,e.intf.selectColumn=e.selectColumn,e.intf.selectRow=e.selectRow,e.intf.selectAll=e.selectAll,e.intf.drawChildGrids=e.drawChildGrids,e.intf.assertPxColor=e.assertPxColor,e.intf.clearPxColorAssertions=e.clearPxColorAssertions,e.intf.integerToAlpha=e.integerToAlpha,e.intf.copy=e.copy,e.intf.style={},Object.keys(e.style).forEach(function(o){t[o]=void 0,Object.defineProperty(t,o,{get:function(){return e.style[o]},set:function(t){e.parseFont(t),e.style[o]=t,e.draw(!0),e.dispatchEvent("stylechanged",{name:o,value:t})}})}),Object.defineProperty(e.intf,"activeCell",{get:function(){return e.activeCell}}),Object.defineProperty(e.intf,"hasFocus",{get:function(){return e.hasFocus}}),Object.defineProperty(e.intf,"style",{get:function(){return t},set:function(t){Object.keys(t).forEach(function(o){e.parseFont(t),e.style[o]=t[o]}),e.draw(!0),e.dispatchEvent("stylechanged",{name:"style",value:t})}}),Object.keys(e.attributes).forEach(function(t){Object.defineProperty(e.intf.attributes,t,{get:function(){return e.attributes[t]},set:function(o){e.attributes[t]=o,e.draw(!0),e.dispatchEvent("attributechanged",{name:t,value:o[t]})}})}),e.filters.string=function(t,o){if(!o)return!0;var r;e.invalidFilterRegEx=void 0;try{r=new RegExp(o,"ig")}catch(t){return void(e.invalidFilterRegEx=t)}return r.test(t)},e.filters.number=function(e,t){return!t||e===t},e.attributes.name&&e.attributes.saveAppearance){if(e.storedSettings=localStorage.getItem(e.storageName+"-"+e.attributes.name),e.storedSettings)try{e.storedSettings=JSON.parse(e.storedSettings)}catch(t){console.warn("could not read settings from localStore",t),e.storedSettings=void 0}e.storedSettings&&"object"==typeof e.storedSettings.sizes&&(e.sizes.rows=e.storedSettings.sizes.rows,e.sizes.columns=e.storedSettings.sizes.columns,["trees","columns","rows"].forEach(function(t){e.sizes[t]||(e.sizes[t]={})}))}["formatters","filters","sorters"].forEach(e.initProp),e.args.data&&(e.intf.data=e.args.data),e.data||(e.intf.data=[]),e.args.schema&&(e.intf.schema=e.args.schema),e.isChildGrid?requestAnimationFrame(function(){e.resize(!0)}):e.resize(!0)},e.intf.blur=function(t){e.hasFocus=!1},e.intf.focus=function(){e.hasFocus=!0,e.controlInput.focus()},Object.defineProperty(e.intf,"height",{get:function(){return e.parentNode.height},set:function(t){e.parentNode.height=t,e.resize(!0)}}),Object.defineProperty(e.intf,"width",{get:function(){return e.parentNode.width},set:function(t){e.parentNode.width=t,e.resize(!0)}}),Object.defineProperty(e.intf,"openChildren",{get:function(){return e.openChildren}}),Object.defineProperty(e.intf,"childGrids",{get:function(){return Object.keys(e.childGrids).map(function(t){return e.childGrids[t]})}}),Object.defineProperty(e.intf,"isChildGrid",{get:function(){return e.isChildGrid}}),Object.defineProperty(e.intf,"parentNode",{get:function(){return e.parentNode},set:function(t){e.parentNode=t}}),Object.defineProperty(e.intf,"offsetParent",{get:function(){return e.parentNode},set:function(t){e.parentNode=t}}),Object.defineProperty(e.intf,"offsetLeft",{get:function(){return e.parentNode.offsetLeft}}),Object.defineProperty(e.intf,"offsetTop",{get:function(){return e.parentNode.offsetTop}}),Object.defineProperty(e.intf,"scrollHeight",{get:function(){return e.scrollBox.scrollHeight}}),Object.defineProperty(e.intf,"scrollWidth",{get:function(){return e.scrollBox.scrollWidth}}),Object.defineProperty(e.intf,"scrollTop",{get:function(){return e.scrollBox.scrollTop},set:function(t){e.scrollBox.scrollTop=t}}),Object.defineProperty(e.intf,"scrollLeft",{get:function(){return e.scrollBox.scrollLeft},set:function(t){e.scrollBox.scrollLeft=t}}),Object.defineProperty(e.intf,"sizes",{get:function(){return e.sizes}}),Object.defineProperty(e.intf,"input",{get:function(){return e.input}}),Object.defineProperty(e.intf,"controlInput",{get:function(){return e.controlInput}}),Object.defineProperty(e.intf,"currentCell",{get:function(){return e.currentCell}}),Object.defineProperty(e.intf,"visibleCells",{get:function(){return e.visibleCells}}),Object.defineProperty(e.intf,"visibleRows",{get:function(){return e.visibleRows}}),Object.defineProperty(e.intf,"selections",{get:function(){return e.selections}}),Object.defineProperty(e.intf,"dragMode",{get:function(){return e.dragMode}}),Object.defineProperty(e.intf,"changes",{get:function(){return e.changes}}),e.intf.attributes={},e.intf.formatters=e.formatters,e.normalizeDataset=function(t){var o,r,n,l;if(null===t||""===t||void 0===t)return[];if("string"!=typeof t&&"number"!=typeof t&&"boolean"!=typeof t||(t=[{0:t}]),Array.isArray(t)||"object"!=typeof t||(t=[t]),!Array.isArray(t[0])&&"object"==typeof t[0]||Array.isArray(t)&&0===t.length)return t;if("function"==typeof t&&(o=t.apply(e.intf,[function(t){l&&console.warn("Detected a callback to the data setter function after the same function already returned a value synchronously."),e.normalizeDataset(t)}]))&&(l=!0,e.normalizeDataset(o)),Array.isArray(t)||"object"!=typeof t||(t=[t]),Array.isArray(t))return Array.isArray(t[0])||(t=[t]),n=0,r=[],t.forEach(function(e){n=Math.max(n,e.length)}),t.forEach(function(e,t){var o;for(r[t]={},o=0;o<n;o+=1)r[t][o]=e[o]||null}),r;throw new Error("Unsupported data type. Must be an array of arrays or an array of objects, function or string.")},Object.defineProperty(e.intf,"selectionBounds",{get:function(){return e.getSelectionBounds()}}),Object.defineProperty(e.intf,"selectedRows",{get:function(){return e.getSelectedData(!0)}}),Object.defineProperty(e.intf,"selectedCells",{get:function(){return e.getSelectedData()}}),Object.defineProperty(e.intf,"visibleSchema",{get:function(){return e.getVisibleSchema().map(function(e){return e})}}),Object.defineProperty(e.intf,"ctx",{get:function(){return e.ctx}}),Object.defineProperty(e.intf,"schema",{get:function(){return e.getSchema()},set:function(t){if(!Array.isArray(t)||"object"!=typeof t[0])throw new Error("Schema must be an array of objects.");if(void 0===t[0].name)throw new Error("Expected schema to contain an object with at least a name property.");e.schema=t.map(function(t,o){return t.width=t.width||e.style.columnWidth,t[e.uniqueId]=e.getSchemaNameHash(t.name),t.filter=t.filter||e.filter(t.type),t.type=t.type||"string",t.index=o,t.columnIndex=o,t.rowIndex=-1,t}),e.tempSchema=void 0,e.createNewRowData(),e.createColumnOrders(),e.tryLoadStoredOrders(),e.resize(!0),e.dispatchEvent("schemachanged",{schema:e.schema})}}),Object.defineProperty(e.intf,"data",{get:function(){return e.data.map(function(t){return delete t[e.uniqueId],t})},set:function(t){e.originalData=e.normalizeDataset(t).map(function(t){return t[e.uniqueId]=e.uId,e.uId+=1,t}),e.changes=[],e.data=e.originalData,!e.schema&&e.data.length>0&&(e.tempSchema=e.getSchemaFromData()),e.schema||0!==e.data.length||(e.tempSchema=[{name:""}],e.tempSchema[0][e.uniqueId]=e.getSchemaNameHash("")),e.tempSchema&&!e.schema&&(e.createColumnOrders(),e.tryLoadStoredOrders(),e.dispatchEvent("schemachanged",{schema:e.tempSchema})),e.createNewRowData(),e.attributes.autoResizeColumns&&e.data.length>0&&void 0===e.storedSettings&&e.autosize(),e.fitColumnToValues("cornerCell",!0),e.resize()&&e.isChildGrid||e.draw(!0),e.createRowOrders(),e.tryLoadStoredOrders(),e.dispatchEvent("datachanged",{data:e.data})}}),e.initScrollBox=function(){function t(t,o){if(isNaN(t))throw new Error("ScrollTop value must be a number");t<0&&(t=0),t>s&&(t=s),s<0&&(t=0),l=t,o||e.scroll()}function o(t,o){if(isNaN(t))throw new Error("ScrollLeft value must be a number");t<0&&(t=0),t>a&&(t=a),a<0&&(t=0),i=t,o||e.scroll()}var r=0,n=0,l=0,i=0,s=0,a=0,c=20,d=20;e.scrollBox.scrollTo=function(e,r){o(e,!0),t(r)},Object.defineProperty(e.scrollBox,"scrollBoxHeight",{get:function(){return c},set:function(e){c=e}}),Object.defineProperty(e.scrollBox,"scrollBoxWidth",{get:function(){return d},set:function(e){d=e}}),Object.defineProperty(e.scrollBox,"height",{get:function(){return r},set:function(e){s<e&&(l=0),r=e}}),Object.defineProperty(e.scrollBox,"width",{get:function(){return n},set:function(e){n=e}}),Object.defineProperty(e.scrollBox,"scrollTop",{get:function(){return l},set:t}),Object.defineProperty(e.scrollBox,"scrollLeft",{get:function(){return i},set:o}),Object.defineProperty(e.scrollBox,"scrollHeight",{get:function(){return s},set:function(e){l>e&&(l=Math.max(e,0)),s<r&&(l=0),s=e}}),Object.defineProperty(e.scrollBox,"scrollWidth",{get:function(){return a},set:function(e){i>e&&(i=Math.max(e,0)),a=e}})}}}.apply(t,r))&&(e.exports=n)},function(e,t,o){var r,n;r=[],void 0!==(n=function(){"use strict";return function(e){function t(o,r,l,s){function a(){l.forEach(function(r){function n(e){e.relatedTarget!==g&&r.contextMenu.container!==e.relatedTarget&&s!==e.relatedTarget&&a!==e.relatedTarget&&(r.contextMenu.dispose(),m.splice(m.indexOf(r.contextMenu),1),r.contextMenu=void 0,a.removeEventListener("mouseout",n),g.removeEventListener("mouseout",n),a.setAttribute("contextOpen","0"),a.setAttribute("opening","0"))}function l(l){if("1"===a.getAttribute("opening")&&"1"!==a.getAttribute("contextOpen")){var i=a.getBoundingClientRect();i={left:i.left+e.style.childContextMenuMarginLeft+g.offsetWidth,top:i.top+e.style.childContextMenuMarginTop,bottom:i.bottom,right:i.right},r.contextMenu=t(o,i,l,v),a.setAttribute("contextOpen","1"),a.addEventListener("mouseout",n),g.addEventListener("mouseout",n),m.push(r.contextMenu)}}function i(){var e;if("1"!==a.getAttribute("contextOpen")){if(a.setAttribute("opening","1"),"function"==typeof r.items)return void(void 0!==(e=r.items.apply(v,[function(e){l(e)}]))&&Array.isArray(e)&&l(e));l(r.items)}}var s,a=document.createElement("div");!function(t){function r(t){return"function"==typeof t?r(t(o)):"object"==typeof t?void a.appendChild(t):(e.createInlineStyle(a,"canvas-datagrid-context-menu-item"),a.addEventListener("mouseover",function(){e.createInlineStyle(a,"canvas-datagrid-context-menu-item:hover")}),a.addEventListener("mouseout",function(){e.createInlineStyle(a,"canvas-datagrid-context-menu-item")}),void(a.innerHTML=t))}r(t.title),t.contextItemContainer=a,t.items&&t.items.length>0&&(s=document.createElement("div"),e.createInlineStyle(s,"canvas-datagrid-context-child-arrow"),s.innerHTML=e.style.childContextMenuArrowHTML,a.appendChild(s),a.addEventListener("mouseover",i),a.addEventListener("mouseout",function(){a.setAttribute("opening","0")})),t.click&&a.addEventListener("click",function(o){t.click.apply(e,[o])})}(r),g.appendChild(a)})}function c(e){l[e].contextItemContainer.dispatchEvent(new Event("click"))}function d(){g.scrollTop>0?document.body.appendChild(x):x.parentNode&&x.parentNode.removeChild(x),g.scrollTop>=g.scrollHeight-g.offsetHeight&&p.parentNode?p.parentNode.removeChild(p):g.scrollHeight-g.offsetHeight>0&&!(g.scrollTop>=g.scrollHeight-g.offsetHeight)&&document.body.appendChild(p)}function u(t){return function o(){var r=e.attributes.contextHoverScrollAmount;"up"===t&&0===g.scrollTop||"down"===t&&g.scrollTop===g.scrollHeight||(g.scrollTop+="up"===t?-r:r,n=setTimeout(o,e.attributes.contextHoverScrollRateMs,t))}}function h(e){return function(){clearTimeout(n)}}var f,g=document.createElement("div"),x=document.createElement("div"),p=document.createElement("div"),m=[],y=-1,v={};if(!Array.isArray(l))throw new Error("createContextMenu expects an array.");return v.parentGrid=e.intf,v.parentContextMenu=s,v.container=g,function(){var t={},o=e.scrollOffset(e.canvas);a(),e.createInlineStyle(g,"canvas-datagrid-context-menu"),t.x=r.left-o.left,t.y=r.top-o.top,t.height=0,i+=1,g.style.position="absolute",x.style.color=e.style.contextMenuArrowColor,p.style.color=e.style.contextMenuArrowColor,[x,p].forEach(function(e){e.style.textAlign="center",e.style.position="absolute",e.style.zIndex=i+1}),g.style.zIndex=i,s&&s.inputDropdown&&(g.style.maxHeight=window.innerHeight-t.y-e.style.autocompleteBottomMargin+"px",g.style.minWidth=r.width+"px",t.y+=r.height),g.style.left=t.x+"px",g.style.top=t.y+"px",g.addEventListener("scroll",d),g.addEventListener("wheel",function(t){e.hasFocus&&(g.scrollTop+=t.deltaY,g.scrollLeft+=t.deltaX),d()}),x.innerHTML=e.style.contextMenuArrowUpHTML,p.innerHTML=e.style.contextMenuArrowDownHTML,g.appendChild(x),document.body.appendChild(p),document.body.appendChild(g),f=g.getBoundingClientRect(),!(f.bottom>window.innerHeight)||s&&s.inputDropdown||(t.y=window.innerHeight-g.offsetHeight,t.y<0&&(t.y=0),g.offsetHeight>window.innerHeight&&(g.style.height=window.innerHeight-e.style.contextMenuWindowMargin+"px")),f.right>window.innerWidth&&(t.x=s?s.container.offsetLeft-g.offsetWidth:window.innerWidth-g.offsetWidth),g.style.left=t.x+"px",g.style.top=t.y+"px",f=g.getBoundingClientRect(),x.style.top=f.top+"px",p.style.top=f.top+f.height-p.offsetHeight+"px",x.style.left=f.left+"px",p.style.left=f.left+"px",p.style.width=g.offsetWidth+"px",x.style.width=g.offsetWidth+"px",p.addEventListener("mouseover",u("down")),p.addEventListener("mouseout",h("down")),x.addEventListener("mouseover",u("up")),x.addEventListener("mouseout",h("up")),d()}(),v.clickIndex=c,v.rect=f,v.items=l,v.upArrow=x,v.downArrow=p,v.dispose=function(){clearTimeout(n),m.forEach(function(e){e.dispose()}),[p,x,g].forEach(function(e){e.parentNode&&e.parentNode.removeChild(e)})},Object.defineProperty(v,"selectedIndex",{get:function(){return y},set:function(t){if("number"!=typeof t||isNaN(t||!isFinite(t)))throw new Error("Context menu selected index must be a sane number.");y=t,y>l.length-1&&(y=l.length-1),y<0&&(y=0),l.forEach(function(t,o){if(o===y)return e.createInlineStyle(t.contextItemContainer,"canvas-datagrid-context-menu-item:hover");e.createInlineStyle(t.contextItemContainer,"canvas-datagrid-context-menu-item")})}}),v}function o(o){function r(){i={},e.data.forEach(function(t){var r=t[o.cell.header.name];i[r]||(i[r]={title:e.formatters[o.cell.header.type||"string"]({cell:{value:r}}),click:function(t){u.value=r,t.stopPropagation(),u.dispatchEvent(new Event("keyup")),e.disposeAutocomplete()}})}),i=Object.keys(i).map(function(e){return i[e]})}function n(e){e&&-1!==[40,38,13,9,27].indexOf(e.keyCode)||(r(),s=u.getBoundingClientRect(),l&&(l.dispose(),l=void 0),l=t(o,{left:s.left,top:s.top,right:s.right,bottom:s.bottom,height:s.height,width:s.width},i,{inputDropdown:!0}),l.selectedIndex=0)}var i,s,a=document.createElement("div"),c=document.createElement("div"),d=document.createElement("button"),u=document.createElement("input"),h=o.cell&&o.cell.header?o.cell.header.title||o.cell.header.name:"";e.createInlineStyle(c,"canvas-datagrid-context-menu-label"),e.createInlineStyle(d,"canvas-datagrid-context-menu-filter-button"),e.createInlineStyle(u,"canvas-datagrid-context-menu-filter-input"),u.onclick=e.disposeAutocomplete,u.addEventListener("keydown",function(t){40===t.keyCode&&(l.selectedIndex+=1),38===t.keyCode&&(l.selectedIndex-=1),13===t.keyCode&&(l.clickIndex(l.selectedIndex),e.disposeContextMenu()),9===t.keyCode&&(l.clickIndex(l.selectedIndex),t.preventDefault()),27===t.keyCode&&e.disposeContextMenu()}),u.addEventListener("keyup",function(){e.setFilter(o.cell.header.name,u.value)}),u.addEventListener("keyup",n),u.value=o.cell.header?e.columnFilters[o.cell.header.name]||"":"",c.innerHTML=e.attributes.filterOptionText.replace(/%s/g,h),d.onclick=function(){if(l)return e.disposeAutocomplete();n()},d.innerHTML=e.style.contextFilterButtonHTML,a.addEventListener("click",function(e){return e.stopPropagation()}),a.appendChild(c),a.appendChild(u),a.appendChild(d),o.items.push({title:a}),Object.keys(e.columnFilters).length&&Object.keys(e.columnFilters).forEach(function(t){var r=e.getHeaderByName(t);o.items.push({title:e.attributes.removeFilterOptionText.replace(/%s/g,r.title||r.name),click:function(o){o.preventDefault(),e.setFilter(t,""),e.controlInput.focus()}})})}function r(t){var r=!(t.cell.isBackground||t.cell.isHeaderCellCap||t.cell.isScrollBar||t.cell.isCorner||t.cell.isRowHeader)&&t.cell.header;e.attributes.showFilter&&r&&o(t),e.attributes.showCopy&&e.selections.reduce(function(e,t){return e+t.length},0)>0&&t.items.push({title:e.attributes.copyText,click:function(){document.execCommand("copy"),e.disposeContextMenu(),e.controlInput.focus()}}),e.attributes.saveAppearance&&e.attributes.showClearSettingsOption&&(Object.keys(e.sizes.rows).length>0||Object.keys(e.sizes.columns).length>0)&&t.items.push({title:e.attributes.clearSettingsOptionText,click:function(t){t.preventDefault(),e.sizes.rows={},e.sizes.columns={},e.createRowOrders(),e.createColumnOrders(),e.storedSettings=void 0,e.dispatchEvent("resizecolumn",{columnWidth:e.style.columnWidth}),e.dispatchEvent("resizerow",{cellHeight:e.style.cellHeight}),e.setStorageData(),e.resize(!0),e.disposeContextMenu(),e.controlInput.focus()}}),e.attributes.allowSorting&&e.attributes.showOrderByOption&&r&&(t.items.push({title:e.attributes.showOrderByOptionTextAsc.replace("%s",t.cell.header.title||t.cell.header.name),click:function(o){o.preventDefault(),e.order(t.cell.header.name,"asc"),e.controlInput.focus()}}),t.items.push({title:e.attributes.showOrderByOptionTextDesc.replace("%s",t.cell.header.title||t.cell.header.name),click:function(o){o.preventDefault(),e.order(t.cell.header.name,"desc"),e.disposeContextMenu(),e.controlInput.focus()}}))}var n,l,i=2;e.disposeAutocomplete=function(){l&&(l.dispose(),l=void 0)},e.disposeContextMenu=function(){document.removeEventListener("click",e.disposeContextMenu),i=2,e.disposeAutocomplete(),e.contextMenu&&e.contextMenu.dispose(),e.contextMenu=void 0},e.contextmenuEvent=function(o,n){if(e.hasFocus||o.target===e.canvas){var l=[],i=n||e.getLayerPos(o,!0),s={NativeEvent:o,cell:e.getCellAt(i.x,i.y),items:l};s.cell.isGrid||r(s),e.dispatchEvent("contextmenu",s)||s.cell.isGrid||(e.contextMenu&&e.disposeContextMenu(),e.contextMenu=t(s,{left:i.x+i.rect.left+e.style.contextMenuMarginLeft+e.canvasOffsetLeft,top:i.y+i.rect.top+e.style.contextMenuMarginTop+e.canvasOffsetTop,right:s.cell.width+s.cell.x+i.rect.left,bottom:s.cell.height+s.cell.y+i.rect.top,height:s.cell.height,width:s.cell.width},l),document.addEventListener("click",e.disposeContextMenu),o.preventDefault())}}}}.apply(t,r))&&(e.exports=n)},function(e,t,o){var r,n;r=[],void 0!==(n=function(){"use strict";return function(e){e.defaults={attributes:[["name",""],["tree",!1],["showNewRow",!1],["treeHorizontalScroll",!1],["saveAppearance",!0],["selectionFollowsActiveCell",!1],["multiLine",!1],["editable",!0],["allowColumnReordering",!0],["allowRowReordering",!1],["allowSorting",!0],["showFilter",!0],["globalRowResize",!1],["pageUpDownOverlap",1],["persistantSelectionMode",!1],["rowSelectionMode",!1],["autoResizeColumns",!1],["allowRowHeaderResize",!0],["allowColumnResize",!0],["allowRowResize",!0],["allowRowResizeFromCell",!1],["allowColumnResizeFromCell",!1],["debug",!1],["borderResizeZone",10],["showColumnHeaders",!0],["showRowNumbers",!0],["showRowHeaders",!0],["scrollRepeatRate",75],["selectionScrollZone",20],["resizeScrollZone",20],["contextHoverScrollRateMs",5],["contextHoverScrollAmount",2],["selectionScrollIncrement",20],["reorderDeadZone",3],["showClearSettingsOption",!0],["showOrderByOption",!0],["clearSettingsOptionText","Clear saved settings"],["showOrderByOptionTextAsc","Order by %s ascending"],["showOrderByOptionTextDesc","Order by %s descending"],["removeFilterOptionText","Remove filter on %s"],["filterOptionText","Filter %s"],["filterTextPrefix","(filtered) "],["touchReleaseAnimationDurationMs",1e3],["touchReleaseAcceleration",30],["touchDeadZone",3],["touchSelectTimeMs",800],["touchScrollZone",40],["copyText","Copy"],["showCopy",!0],["columnHeaderClickBehavior","sort"],["scrollPointerLock",!0]],styles:[["activeCellBackgroundColor","rgba(255, 255, 255, 1)"],["activeCellBorderColor","rgba(110, 168, 255, 1)"],["activeCellBorderWidth",.25],["activeCellColor","rgba(0, 0, 0, 1)"],["activeCellFont","16px sans-serif"],["activeCellHoverBackgroundColor","rgba(255, 255, 255, 1)"],["activeCellHoverColor","rgba(0, 0, 0, 1)"],["activeCellOverlayBorderColor","rgba(66, 133, 244, 1)"],["activeCellOverlayBorderWidth",.5],["activeCellPaddingBottom",5],["activeCellPaddingLeft",5],["activeCellPaddingRight",7],["activeCellPaddingTop",5],["activeCellSelectedBackgroundColor","rgba(236, 243, 255, 1)"],["activeCellSelectedColor","rgba(0, 0, 0, 1)"],["activeColumnHeaderCellBackgroundColor","rgba(225, 225, 225, 1)"],["activeColumnHeaderCellColor","rgba(0, 0, 0, 1)"],["activeRowHeaderCellBackgroundColor","rgba(225, 225, 225, 1)"],["activeRowHeaderCellColor","rgba(0, 0, 0, 1)"],["autocompleteBottomMargin",60],["autosizeHeaderCellPadding",8],["autosizePadding",5],["backgroundColor","rgba(240, 240, 240, 1)"],["cellAutoResizePadding",13],["cellBackgroundColor","rgba(255, 255, 255, 1)"],["cellBorderColor","rgba(195, 199, 202, 1)"],["cellBorderWidth",.5],["cellColor","rgba(0, 0, 0, 1)"],["cellFont","16px sans-serif"],["cellGridHeight",250],["cellHeight",24],["cellHeightWithChildGrid",150],["cellHorizontalAlignment","left"],["cellHoverBackgroundColor","rgba(255, 255, 255, 1)"],["cellHoverColor","rgba(0, 0, 0, 1)"],["cellPaddingBottom",5],["cellPaddingLeft",5],["cellPaddingRight",7],["cellPaddingTop",5],["cellSelectedBackgroundColor","rgba(236, 243, 255, 1)"],["cellSelectedColor","rgba(0, 0, 0, 1)"],["cellVerticalAlignment","center"],["cellWidthWithChildGrid",250],["childContextMenuArrowColor","rgba(43, 48, 43, 1)"],["childContextMenuArrowHTML","►"],["childContextMenuMarginLeft",-15],["childContextMenuMarginTop",0],["columnHeaderCellBackgroundColor","rgba(240, 240, 240, 1)"],["columnHeaderCellBorderColor","rgba(152, 152, 152, 1)"],["columnHeaderCellBorderWidth",.25],["columnHeaderCellColor","rgba(50, 50, 50, 1)"],["columnHeaderCellFont","16px sans-serif"],["columnHeaderCellHeight",25],["columnHeaderCellHorizontalAlignment","left"],["columnHeaderCellHoverBackgroundColor","rgba(235, 235, 235, 1)"],["columnHeaderCellHoverColor","rgba(0, 0, 0, 1)"],["columnHeaderCellPaddingBottom",5],["columnHeaderCellPaddingLeft",5],["columnHeaderCellPaddingRight",7],["columnHeaderCellPaddingTop",5],["columnHeaderCellVerticalAlignment","center"],["columnWidth",250],["contextFilterButtonBorder","solid 1px rgba(158, 163, 169, 1)"],["contextFilterButtonBorderRadius","3px"],["contextFilterButtonHTML","▼"],["contextFilterInputBackground","rgba(255,255,255,1)"],["contextFilterInputBorder","solid 1px rgba(158, 163, 169, 1)"],["contextFilterInputBorderRadius","0"],["contextFilterInputColor","rgba(0,0,0,1)"],["contextFilterInputFontFamily","sans-serif"],["contextFilterInputFontSize","14px"],["contextMenuArrowColor","rgba(43, 48, 43, 1)"],["contextMenuArrowDownHTML","▼"],["contextMenuArrowUpHTML","▲"],["contextMenuBackground","rgba(240, 240, 240, 1)"],["contextMenuBorder","solid 1px rgba(158, 163, 169, 1)"],["contextMenuBorderRadius","3px"],["contextMenuChildArrowFontSize","12px"],["contextMenuColor","rgba(43, 48, 43, 1)"],["contextMenuFilterButtonFontFamily","sans-serif"],["contextMenuFilterButtonFontSize","10px"],["contextMenuFilterInvalidExpresion","rgba(237, 155, 156, 1)"],["contextMenuFontFamily","sans-serif"],["contextMenuFontSize","16px"],["contextMenuHoverBackground","rgba(182, 205, 250, 1)"],["contextMenuHoverColor","rgba(43, 48, 153, 1)"],["contextMenuItemBorderRadius","3px"],["contextMenuItemMargin","2px"],["contextMenuLabelDisplay","inline-block"],["contextMenuLabelMargin","0 3px 0 0"],["contextMenuLabelMaxWidth","700px"],["contextMenuLabelMinWidth","75px"],["contextMenuMarginLeft",3],["contextMenuMarginTop",-3],["contextMenuOpacity","0.98"],["contextMenuPadding","2px"],["contextMenuWindowMargin",6],["cornerCellBackgroundColor","rgba(240, 240, 240, 1)"],["cornerCellBorderColor","rgba(202, 202, 202, 1)"],["editCellBackgroundColor","white"],["editCellBorder","solid 1px rgba(110, 168, 255, 1)"],["editCellBoxShadow","0 2px 5px rgba(0,0,0,0.4)"],["editCellColor","black"],["editCellFontFamily","sans-serif"],["editCellFontSize","16px"],["editCellPaddingLeft",4],["gridBorderColor","rgba(202, 202, 202, 1)"],["gridBorderWidth",1],["columnHeaderOrderByArrowBorderColor","rgba(195, 199, 202, 1)"],["columnHeaderOrderByArrowBorderWidth",1],["columnHeaderOrderByArrowColor","rgba(155, 155, 155, 1)"],["columnHeaderOrderByArrowHeight",8],["columnHeaderOrderByArrowMarginLeft",0],["columnHeaderOrderByArrowMarginRight",5],["columnHeaderOrderByArrowMarginTop",6],["columnHeaderOrderByArrowWidth",13],["minColumnWidth",45],["minHeight",24],["minRowHeight",24],["name","default"],["reorderMarkerBackgroundColor","rgba(0, 0, 0, 0.1)"],["reorderMarkerBorderColor","rgba(0, 0, 0, 0.2)"],["reorderMarkerBorderWidth",1.25],["reorderMarkerIndexBorderColor","rgba(66, 133, 244, 1)"],["reorderMarkerIndexBorderWidth",2.75],["rowHeaderCellBackgroundColor","rgba(240, 240, 240, 1)"],["rowHeaderCellBorderColor","rgba(200, 200, 200, 1)"],["rowHeaderCellBorderWidth",1],["rowHeaderCellColor","rgba(50, 50, 50, 1)"],["rowHeaderCellFont","16px sans-serif"],["rowHeaderCellHeight",25],["rowHeaderCellHorizontalAlignment","left"],["rowHeaderCellHoverBackgroundColor","rgba(235, 235, 235, 1)"],["rowHeaderCellHoverColor","rgba(0, 0, 0, 1)"],["rowHeaderCellPaddingBottom",5],["rowHeaderCellPaddingLeft",5],["rowHeaderCellPaddingRight",5],["rowHeaderCellPaddingTop",5],["rowHeaderCellSelectedBackgroundColor","rgba(217, 217, 217, 1)"],["rowHeaderCellSelectedColor","rgba(50, 50, 50, 1)"],["rowHeaderCellVerticalAlignment","center"],["rowHeaderCellWidth",57],["scrollBarActiveColor","rgba(125, 125, 125, 1)"],["scrollBarBackgroundColor","rgba(240, 240, 240, 1)"],["scrollBarBorderColor","rgba(202, 202, 202, 1)"],["scrollBarBorderWidth",.5],["scrollBarBoxBorderRadius",4.125],["scrollBarBoxColor","rgba(192, 192, 192, 1)"],["scrollBarBoxMargin",2],["scrollBarBoxMinSize",15],["scrollBarBoxWidth",8],["scrollBarCornerBackgroundColor","rgba(240, 240, 240, 1)"],["scrollBarCornerBorderColor","rgba(202, 202, 202, 1)"],["scrollBarWidth",11],["selectionOverlayBorderColor","rgba(66, 133, 244, 1)"],["selectionOverlayBorderWidth",.75],["treeArrowBorderColor","rgba(195, 199, 202, 1)"],["treeArrowBorderWidth",1],["treeArrowClickRadius",5],["treeArrowColor","rgba(155, 155, 155, 1)"],["treeArrowHeight",8],["treeArrowMarginLeft",0],["treeArrowMarginRight",5],["treeArrowMarginTop",6],["treeArrowWidth",13],["treeGridHeight",250]]}}}.apply(t,r))&&(e.exports=n)},function(e,t,o){var r,n;r=[],void 0!==(n=function(){"use strict";return function(e){e.endEdit=function(t){function o(){t=!0}var r=e.input.editCell,n=r.rowIndex;if(e.dispatchEvent("beforeendedit",{cell:r,newValue:e.input.value,oldValue:r.value,abort:o,input:e.input}))return!1;if(e.input.value!==r.value&&!t){if(e.changes[n]=e.changes[n]||{},e.changes[n][r.header.name]=e.input.value,r.data[r.header.name]=e.input.value,n===e.data.length){if(e.dispatchEvent("newrow",{value:e.input.value,defaultValue:r.value,aborted:t,cell:r,input:e.input}))return!1;e.uId+=1,e.addRow(r.data),e.createNewRowData()}e.draw(!0)}return document.body.removeChild(e.input),e.controlInput.focus(),e.dispatchEvent("endedit",{cell:r,value:e.input.value,aborted:t,input:e.input}),e.input=void 0,!0},e.beginEditAt=function(t,o){if(e.attributes.editable){var r,n=e.getVisibleCellByIndex(t,o),l=e.getVisibleSchema();if(e.dispatchEvent("beforebeginedit",{cell:n}))return!1;e.scrollIntoView(t,o),e.setActiveCell(t,o),n.header.enum?e.input=document.createElement("select"):e.input=document.createElement(e.attributes.multiLine?"textarea":"input"),function(){var i,s;n=e.getVisibleCellByIndex(t,o),n.header.enum&&("function"==typeof n.header.enum?r=n.header.enum.apply(e.intf,[{cell:n}]):Array.isArray(n.header.enum)&&(r=n.header.enum),r.forEach(function(t){var o,r,l=document.createElement("option");Array.isArray(t)?(o=t[0],r=t[1]):(o=t,r=t),o===n.value&&(s=!0),l.value=o,l.innerHTML=r,e.input.appendChild(l)}),s||(i=document.createElement("option"),i.value=n.value,i.innerHTML=n.value,e.input.appendChild(i)),e.input.addEventListener("change",function(){e.endEdit(),e.draw(!0)})),document.body.appendChild(e.input),e.createInlineStyle(e.input,"canvas-datagrid-edit-input"),e.input.style.position="absolute",e.input.editCell=n,e.resizeEditInput(),e.input.style.zIndex="2",e.input.value=n.value,e.input.focus(),e.input.addEventListener("click",e.stopPropagation),e.input.addEventListener("dblclick",e.stopPropagation),e.input.addEventListener("mouseup",e.stopPropagation),e.input.addEventListener("mousedown",e.stopPropagation),e.input.addEventListener("keydown",function(t){var o=n.columnIndex,r=n.rowIndex;if(27===t.keyCode)e.endEdit(!0),e.draw(!0);else if(13===t.keyCode&&(!e.attributes.multiLine||e.attributes.multiLine&&t.shiftKey))e.endEdit(),e.draw(!0);else if(9===t.keyCode){if(t.preventDefault(),!e.endEdit())return;t.shiftKey?o-=1:o+=1,o<0&&(o=l.length-1,r-=1),o>l.length-1&&(o=0,r+=1),r<0&&(r=e.data.length-1),r>e.data.length-1&&(r=0),e.scrollIntoView(o,r),e.beginEditAt(o,r)}})}(),e.dispatchEvent("beginedit",{cell:n,input:e.input})}},e.createInlineStyle=function(t,o){var r={"canvas-datagrid-context-menu-filter-input":{height:"19px",verticalAlign:"bottom",marginLeft:"2px",padding:"0",background:e.style.contextFilterInputBackground,color:e.style.contextFilterInputColor,border:e.style.contextFilterInputBorder,borderRadius:e.style.contextFilterInputBorderRadius,lineHeight:"normal",fontWeight:"normal",fontFamily:e.style.contextFilterInputFontFamily,fontSize:e.style.contextFilterInputFontSize},"canvas-datagrid-context-menu-filter-button":{height:"19px",verticalAlign:"bottom",marginLeft:"2px",padding:"0",background:e.style.contextMenuBackground,color:e.style.contextMenuColor,border:e.style.contextFilterButtonBorder,borderRadius:e.style.contextFilterButtonBorderRadius,lineHeight:"normal",fontWeight:"normal",fontFamily:e.style.contextMenuFilterButtonFontFamily,fontSize:e.style.contextMenuFilterButtonFontSize},"canvas-datagrid-context-child-arrow":{cssFloat:"right",color:e.style.childContextMenuArrowColor,fontSize:e.style.contextMenuChildArrowFontSize,fontFamily:e.style.contextMenuFontFamily,verticalAlign:"middle"},"canvas-datagrid-autocomplete":{fontFamily:e.style.contextMenuFontFamily,fontSize:e.style.contextMenuFontSize,background:e.style.contextMenuBackground,color:e.style.contextMenuColor,border:e.style.contextMenuBorder,padding:e.style.contextMenuPadding,borderRadius:e.style.contextMenuBorderRadius,opacity:e.style.contextMenuOpacity,position:"absolute",zIndex:3,overflow:"hidden"},"canvas-datagrid-autocomplete-item":{background:e.style.contextMenuBackground,color:e.style.contextMenuColor},"canvas-datagrid-autocomplete-item:hover":{background:e.style.contextMenuHoverBackground,color:e.style.contextMenuHoverColor},"canvas-datagrid-canvas":{position:"absolute",zIndex:"-1"},"canvas-datagrid":{position:"absolute",background:e.style.backgroundColor,zIndex:"1",boxSizing:"content-box",padding:"0"},"canvas-datagrid-control-input":{position:"fixed",top:"-5px",left:"-5px",border:"none",opacity:"0",cursor:"pointer",width:"1px",height:"1px",lineHeight:"normal",fontWeight:"normal",fontFamily:e.style.contextMenuFontFamily,fontSize:e.style.contextMenuFontSize},"canvas-datagrid-edit-input":{boxSizing:"content-box",outline:"none",margin:"0",padding:"0 0 0 "+e.style.editCellPaddingLeft+"px",lineHeight:"normal",fontWeight:"normal",fontFamily:e.style.editCellFontFamily,fontSize:e.style.editCellFontSize,boxShadow:e.style.editCellBoxShadow,border:e.style.editCellBorder,color:e.style.editCellColor,background:e.style.editCellBackgroundColor,appearance:"none",webkitAppearance:"none",mozAppearance:"none",borderRadius:"0"},"canvas-datagrid-context-menu-item":{lineHeight:"normal",fontWeight:"normal",fontFamily:e.style.contextMenuFontFamily,fontSize:e.style.contextMenuFontSize,color:"inherit",background:"inherit",margin:e.style.contextMenuItemMargin,borderRadius:e.style.contextMenuItemBorderRadius,verticalAlign:"middle"},"canvas-datagrid-context-menu-item:hover":{background:e.style.contextMenuHoverBackground,color:e.style.contextMenuHoverColor},"canvas-datagrid-context-menu-label":{margin:e.style.contextMenuLabelMargin,display:e.style.contextMenuLabelDisplay,minWidth:e.style.contextMenuLabelMinWidth,maxWidth:e.style.contextMenuLabelMaxWidth},"canvas-datagrid-context-menu":{lineHeight:"normal",fontWeight:"normal",fontFamily:e.style.contextMenuFontFamily,fontSize:e.style.contextMenuFontSize,background:e.style.contextMenuBackground,color:e.style.contextMenuColor,border:e.style.contextMenuBorder,padding:e.style.contextMenuPadding,borderRadius:e.style.contextMenuBorderRadius,opacity:e.style.contextMenuOpacity,overflow:"hidden"},"canvas-datagrid-invalid-search-regExp":{background:e.style.contextMenuFilterInvalidExpresion}};r[o]&&Object.keys(r[o]).map(function(e){t.style[e]=r[o][e]})},e.appendTo=function(t){e.parentNode=t,e.height=e.parentNode.offsetHeight,e.width=e.parentNode.offsetWidth,e.parentNode&&/canvas-datagrid-(cell|tree)/.test(e.parentNode.nodeType)?(e.isChildGrid=!0,e.parentGrid=e.parentNode.parentGrid,e.ctx=e.parentGrid.context,e.canvas=e.parentGrid.canvas,e.controlInput=e.parentGrid.controlInput,e.eventParent=e.canvas,e.intf.offsetParent=e.parentNode):(e.controlInput=document.createElement("input"),e.controlInput.onblur=e.intf.blur,e.createInlineStyle(e.controlInput,"canvas-datagrid-control-input"),e.isChildGrid=!1,e.parentDOMNode=e.parentNode,e.parentNode=e.parentDOMNode,e.parentIsCanvas=/canvas/i.test(e.parentDOMNode.tagName),e.parentIsCanvas?e.canvas=e.parentDOMNode:(e.canvas=document.createElement("canvas"),e.parentDOMNode.appendChild(e.canvas)),e.ctx=e.canvas.getContext("2d"),e.ctx.textBaseline="alphabetic",document.body.appendChild(e.controlInput),e.eventParent=e.canvas),e.controlInput.addEventListener("blur",function(t){t.target!==e.canvas&&(e.hasFocus=!1)}),window.addEventListener("resize",e.resize),MutationObserver&&(e.observer=new MutationObserver(function(t){t.forEach(function(t){e.resize(!0)})}),[e.canvas.parentNode].forEach(function(t){e.observer.observe(t,{attributes:!0})})),e.eventParent.addEventListener("scroll",e.resize,!1),e.eventParent.addEventListener("touchstart",e.touchstart,!1),e.eventParent.addEventListener("mouseup",e.mouseup,!1),e.eventParent.addEventListener("mousedown",e.mousedown,!1),e.eventParent.addEventListener("dblclick",e.dblclick,!1),e.eventParent.addEventListener("click",e.click,!1),e.eventParent.addEventListener("mousemove",e.mousemove),e.eventParent.addEventListener("wheel",e.scrollWheel,!1),e.canvas.addEventListener("contextmenu",e.contextmenuEvent,!1),(e.isChildGrid?e.parentGrid:document).addEventListener("copy",e.copy),e.controlInput.addEventListener("keypress",e.keypress,!1),e.controlInput.addEventListener("keyup",e.keyup,!1),e.controlInput.addEventListener("keydown",e.keydown,!1)},e.setDom=function(){e.appendTo(e.args.parentNode)}}}.apply(t,r))&&(e.exports=n)},function(e,t,o){var r,n;r=[],void 0!==(n=function(){"use strict";return function(e){e.integerToAlpha=function(e){for(var t="a".charCodeAt(0),o="z".charCodeAt(0),r=o-t+1,n="";e>=0;)n=String.fromCharCode(e%r+t)+n,e=Math.floor(e/r)-1;return n},e.insertColumn=function(t,o){var r=e.getSchema();if(r.length<o)throw new Error("Index is beyond the length of the schema.");e.validateColumn(t,r),r.splice(o,0,t),e.data.forEach(function(o){e.applyDefaultValue(o,t)}),e.intf.schema=r},e.deleteColumn=function(t){var o=e.getSchema();e.data.forEach(function(e){delete e[o[t].name]}),o.splice(t,1),e.intf.schema=o},e.addColumn=function(t){var o=e.getSchema();e.validateColumn(t,o),o.push(t),e.data.forEach(function(o){e.applyDefaultValue(o,t)}),e.intf.schema=o},e.deleteRow=function(t){e.originalData.splice(t,1),e.setFilter(),e.resize(!0)},e.insertRow=function(t,o){if(e.originalData.length<o)throw new Error("Index is beyond the length of the dataset.");e.originalData.splice(o,0,t),e.getSchema().forEach(function(r){void 0===t[r.name]&&e.applyDefaultValue(e.originalData[o],r)}),e.setFilter(),e.resize(!0)},e.addRow=function(t){e.originalData.push(t),e.getSchema().forEach(function(o){void 0===t[o.name]&&e.applyDefaultValue(e.originalData[e.originalData.length-1],o)}),e.setFilter(),e.resize(!0)},e.setRowHeight=function(t,o){e.sizes.rows[e.data[t][e.uniqueId]]=o,e.draw(!0)},e.setColumnWidth=function(t,o){var r=e.getSchema();e.sizes.columns[r[t][e.uniqueId]]=o,e.draw(!0)},e.resetColumnWidths=function(){e.sizes.columns={},e.draw(!0)},e.resetRowHeights=function(){e.sizes.rows={},e.draw(!0)},e.setFilter=function(t,o){function r(){e.refreshFromOrigialData(),Object.keys(e.columnFilters).forEach(function(o){var r=e.getHeaderByName(t);r&&(e.currentFilter=r.filter||e.filter(t.type||"string"),e.data=e.data.filter(function(t){return e.currentFilter(t[o],e.columnFilters[o])}))}),e.resize(),e.draw(!0)}if(void 0===t&&void 0===o)return e.columnFilters={},r();!t||""!==o&&void 0!==o?e.columnFilters[t]=o:delete e.columnFilters[t],r()},e.findRowScrollTop=function(t){var o=0,r=0,n=e.data.length,l=2*e.style.cellBorderWidth;if(e.attributes.showNewRow||(n-=1),t>n)throw new Error("Impossible row index");for(;r<t;)o+=(e.sizes.rows[e.data[r][e.uniqueId]]||e.style.cellHeight)+l,r+=1;return o-(e.sizes.rows[e.data[t][e.uniqueId]]||e.style.cellHeight)},e.findColumnScrollLeft=function(t){var o=0,r=0,n=e.getSchema();if(t>n.length-1)throw new Error("Impossible column index");for(;r<t;)o+=e.sizes.columns[n[r][e.uniqueId]]||n[r].width,r+=1;return o},e.gotoCell=function(t,o){void 0!==t&&(e.scrollBox.scrollLeft=e.findColumnScrollLeft(t)),void 0!==o&&(e.scrollBox.scrollTop=e.findRowScrollTop(o))},e.gotoRow=function(t){e.gotoCell(0,t)},e.scrollIntoView=function(t,o){0===e.visibleCells.filter(function(r){return(r.rowIndex===o||void 0===o)&&(r.columnIndex===t||void 0===t)&&r.x>0&&r.y>0&&r.x+r.width<e.width&&r.y+r.height<e.height}).length&&e.gotoCell(t,o)},e.setActiveCell=function(t,o){e.activeCell={rowIndex:o,columnIndex:t}},e.selectAll=function(){e.selectArea({top:0,left:0,right:e.getVisibleSchema().length-1,bottom:e.data.length-1})},e.isColumnSelected=function(t){var o=!0;return e.data.forEach(function(r,n){e.selections[n]&&-1!==e.selections[n].indexOf(e.orders.columns[t])||(o=!1)}),o},e.selectColumn=function(t,o,r,n){function l(t){e.data.forEach(function(o,r){e.selections[r]=e.selections[r]||[],-1===e.selections[r].indexOf(t)&&e.selections[r].push(t)})}var i,s,a;if(r){if(!e.activeCell)return;for(i=Math.min(e.activeCell.columnIndex,t),s=Math.max(e.activeCell.columnIndex,t),a=i;s>a;a+=1)l(a)}o||r||(e.selections=[],e.activeCell.columnIndex=t,e.activeCell.rowIndex=e.scrollIndexTop),o&&e.isColumnSelected(t)?function(t){e.data.forEach(function(o,r){e.selections[r]=e.selections[r]||[],-1!==e.selections[r].indexOf(t)&&e.selections[r].splice(e.selections[r].indexOf(t),1)})}(t):l(t),n||e.dispatchEvent("selectionchanged",{selectedData:e.getSelectedData(),selections:e.selections,selectionBounds:e.selectionBounds})},e.selectRow=function(t,o,r,n){function l(t){e.selections[t]=[],e.selections[t].push(-1),c.forEach(function(o){e.selections[t].push(o.index)})}var i,s,a,c=e.getSchema();if((!1===e.dragAddToSelection||void 0===e.dragObject)&&e.selections[t]&&e.selections[t].length-1===c.length&&o)return void(e.selections[t]=[]);if(!0===e.dragAddToSelection||void 0===e.dragObject)if(r&&void 0===e.dragObject){if(!e.activeCell)return;for(s=Math.min(e.activeCell.rowIndex,t),a=Math.max(e.activeCell.rowIndex,t),i=s;a>=i;i+=1)l(i)}else l(t);n||e.dispatchEvent("selectionchanged",{selectedData:e.getSelectedData(),selections:e.selections,selectionBounds:e.selectionBounds})},e.collapseTree=function(t){var o=e.data[t][e.uniqueId];e.dispatchEvent("collapsetree",{childGrid:e.childGrids[o],data:e.data[t],rowIndex:t}),e.openChildren[o].blur(),e.openChildren[o].dispose(),delete e.openChildren[o],delete e.sizes.trees[o],delete e.childGrids[o],e.dispatchEvent("resizerow",{cellHeight:e.style.cellHeight}),e.resize(!0),e.draw(!0)},e.expandTree=function(t){var o,r=e.getRowHeaderCellHeight(),n=e.sizes.columns.cornerCell||e.style.rowHeaderCellWidth,l=e.data[t][e.uniqueId],i=e.sizes.trees[l]||e.style.treeGridHeight;e.childGrids[l]||(o=e.createGrid({debug:e.attributes.debug,name:e.attributes.saveAppearance?e.attributes.name+"tree"+l:void 0,parentNode:{parentGrid:e.intf,nodeType:"canvas-datagrid-tree",offsetHeight:i,offsetWidth:e.width-n,header:{width:e.width-n},offsetLeft:n,offsetTop:r,offsetParent:e.intf.parentNode,parentNode:e.intf.parentNode,style:"tree",data:e.data[t]}}),e.childGrids[l]=o),o=e.childGrids[l],o.visible=!0,e.dispatchEvent("expandtree",{treeGrid:o,data:e.data[t],rowIndex:t}),e.openChildren[l]=o,e.sizes.trees[l]=i,e.dispatchEvent("resizerow",{height:e.style.cellHeight}),e.resize(!0)},e.toggleTree=function(t){if(e.openChildren[e.data[t][e.uniqueId]])return e.collapseTree(t);e.expandTree(t)},e.getHeaderByName=function(t){var o,r=e.getSchema();for(o=0;o<r.length;o+=1)if(r[o].name===t)return r[o]},e.fitColumnToValues=function(t,o){e.sizes.columns["cornerCell"===t?t:e.getHeaderByName(t)[e.uniqueId]]=e.findColumnMaxTextLength(t),o||(e.resize(),e.draw(!0))},e.isCellVisible=function(t){var o,r=e.visibleCells.length;for(o=0;o<r;o+=1)if(t.x===e.visibleCells[o].x&&t.y===e.visibleCells[o].y)return!0;return!1},e.order=function(t,o,r,n){var l,i=e.getSchema().filter(function(e){return e.name===t});if(e.orderBy=t,0===i.length)throw new Error("Cannot sort. No such column name");l=r||e.sorters[i[0].type],l||void 0===i[0].type||console.warn('Cannot sort type "%s" falling back to string sort.',i[0].type),e.data=e.data.sort("function"==typeof l?l(t,o):e.sorters.string),e.dispatchEvent("ordercolumn",{name:t,direction:o}),e.draw(!0),n||e.setStorageData()},e.isInGrid=function(t){return!(t.x<0||t.x>e.width||t.y<0||t.y>e.height)},e.getVisibleCellByIndex=function(t,o){return e.visibleCells.filter(function(e){return e.columnIndex===t&&e.rowIndex===o})[0]},e.getCellAt=function(t,o,r){var n,l,i=r?e.attributes.touchScrollZone:0,s=e.visibleCells.length;if(e.visibleCells&&e.visibleCells.length){if(e.hasFocus=!0,!(o<e.height&&o>0&&t<e.width&&t>0))return e.hasFocus=!1,{dragContext:"inherit",context:"inherit"};for(n=0;n<s;n+=1)if(l=e.visibleCells[n],r&&/(vertical|horizontal)-scroll-/.test(l.style)&&(l.x-=i,l.y-=i,l.height+=i,l.width+=i),l.x-e.style.cellBorderWidth<t&&l.x+l.width+e.style.cellBorderWidth>t&&l.y-e.style.cellBorderWidth<o&&l.y+l.height+e.style.cellBorderWidth>o)return/vertical-scroll-(bar|box)/.test(l.style)?(l.dragContext="vertical-scroll-box",l.context="vertical-scroll-box",l.isScrollBar=!0,l.isVerticalScrollBar=!0,o>e.scrollBox.box.v.y+e.scrollBox.scrollBoxHeight?(l.dragContext="vertical-scroll-bottom",l.context="vertical-scroll-bottom"):o<e.scrollBox.box.v.y&&(l.dragContext="vertical-scroll-top",l.context="vertical-scroll-top"),e.canvas.style.cursor="default",l):/horizontal-scroll-(bar|box)/.test(l.style)?(l.dragContext="horizontal-scroll-box",l.context="horizontal-scroll-box",l.isScrollBar=!0,l.isHorizontalScrollBar=!0,t>e.scrollBox.box.h.x+e.scrollBox.scrollBoxWidth?(l.dragContext="horizontal-scroll-right",l.context="horizontal-scroll-right"):t<e.scrollBox.box.h.x&&(l.dragContext="horizontal-scroll-left",l.context="horizontal-scroll-left"),e.canvas.style.cursor="default",l):l.x+l.width-.4*e.attributes.borderResizeZone<t&&l.x+l.width+.6*e.attributes.borderResizeZone>t&&e.attributes.allowColumnResize&&(e.attributes.allowColumnResizeFromCell&&"cell"===l.style||"cell"!==l.style)&&(e.attributes.allowRowHeaderResize&&-1!==["rowHeaderCell","cornerCell"].indexOf(l.style)||-1===["rowHeaderCell","cornerCell"].indexOf(l.style))?(l.context="ew-resize",l.dragContext="ew-resize",l):l.y+l.height-.4*e.attributes.borderResizeZone<o&&l.y+l.height+.6*e.attributes.borderResizeZone>o&&e.attributes.allowRowResize&&(e.attributes.allowRowResizeFromCell&&"cell"===l.style||"cell"!==l.style)&&"columnHeaderCell"!==l.style?(l.context="ns-resize",l.dragContext="ns-resize",l):"columnHeaderCell"===l.style?(l.context="cell",l.dragContext="column-reorder",l):"rowHeaderCell"===l.style?(l.context="cell",l.dragContext="row-reorder",l):l.isGrid?(e.hasFocus=!1,l.dragContext="cell-grid",l.context="cell-grid",l):"tree-grid"===l.style?(e.hasFocus=!1,l.dragContext="tree",l.context="tree",l):(l.dragContext="cell",l.context="cell",l);return e.hasFocus=!0,e.canvas.style.cursor="default",{dragContext:"background",context:"background",style:"background",isBackground:!0}}},e.getSelectionBounds=function(){var t={x:1/0,y:1/0},o={x:-1/0,y:-1/0};return e.data.forEach(function(r,n){var l,i;e.selections[n]&&e.selections[n].length&&(t.y=n<t.y?n:t.y,o.y=n>o.y?n:o.y,l=Math.max.apply(null,e.selections[n]),i=Math.min.apply(null,e.selections[n]),t.x=i<t.x?i:t.x,o.x=l>o.x?l:o.x)}),{top:t.y,left:t.x,bottom:o.y,right:o.x}},e.getSchemaFromData=function(){return Object.keys(e.data[0]||{" ":""}).map(function(t,o){var r=e.getBestGuessDataType(t),n={name:t,title:isNaN(parseInt(t,10))?t:e.integerToAlpha(t).toUpperCase(),width:e.style.columnWidth,index:o,type:r,filter:e.filter(r)};return t===e.uniqueId&&(n.hidden=!0),n[e.uniqueId]=e.getSchemaNameHash(t),n})},e.clearChangeLog=function(){e.changes=[]},e.selectArea=function(t,o){e.selectionBounds=t||e.selectionBounds;var r,n,l=e.getSchema();if(o||(e.selections=[]),e.selectionBounds.top<-1||e.selectionBounds.bottom>e.data.length||e.selectionBounds.left<-1||e.selectionBounds.right>l.length)throw new Error("Impossible selection area");for(r=e.selectionBounds.top;r<=e.selectionBounds.bottom;r+=1)for(e.selections[r]=[],n=e.selectionBounds.left;n<=e.selectionBounds.right;n+=1)-1===e.selections[r].indexOf(n)&&e.selections[r].push(n);e.dispatchEvent("selectionchanged",{selectedData:e.getSelectedData(),selections:e.selections,selectionBounds:e.selectionBounds})},e.findColumnMaxTextLength=function(t){var o=-1/0;return"cornerCell"===t?(e.ctx.font=e.style.rowHeaderCellFont,e.ctx.measureText((e.data.length+(e.attributes.showNewRow?1:0)).toString()).width+e.style.autosizePadding+e.style.autosizeHeaderCellPadding+e.style.rowHeaderCellPaddingRight+e.style.rowHeaderCellPaddingLeft+(e.attributes.tree?e.style.treeArrowWidth+e.style.treeArrowMarginLeft+e.style.treeArrowMarginRight:0)):(e.getSchema().forEach(function(r){if(r.name===t){e.ctx.font=e.style.columnHeaderCellFont;var n=e.ctx.measureText(r.title||r.name).width+e.style.headerCellPaddingRight+e.style.headerCellPaddingLeft;o=n>o?n:o}}),e.data.forEach(function(r){e.ctx.font=e.style.cellFont;var n=e.ctx.measureText(r[t]).width+e.style.cellPaddingRight+e.style.cellPaddingLeft+e.style.cellAutoResizePadding;o=n>o?n:o}),o)},e.getHeaderWidth=function(){return e.getVisibleSchema().reduce(function(e,t){return e+t.width},0)},e.formatters.string=function(e){return void 0!==e.cell.value?e.cell.value:""},e.formatters.rowHeaderCell=e.formatters.string,e.formatters.headerCell=e.formatters.string,e.formatters.number=e.formatters.string,e.formatters.int=e.formatters.string,e.formatters.html=e.formatters.string,e.sorters.string=function(e,t){var o="asc"===t;return function(t,r){return void 0===t[e]||null===t[e]?1:void 0===r[e]||null===r[e]?0:o?t[e].localeCompare?t[e].localeCompare(r[e]):1:r[e].localeCompare?r[e].localeCompare(t[e]):1}},e.sorters.number=function(e,t){var o="asc"===t;return function(t,r){return o?t[e]-r[e]:r[e]-t[e]}},e.sorters.date=function(e,t){var o="asc"===t;return function(t,r){return o?new Date(t[e]).getTime()-new Date(r[e]).getTime():new Date(r[e]).getTime()-new Date(t[e]).getTime()}}}}.apply(t,r))&&(e.exports=n)}])});
//# sourceMappingURL=canvas-datagrid.map