/*
    *
    * Wijmo Library 5.20183.550
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
"use strict";function tryGetModuleWijmoGrid(){let e;return(e=__glob.wijmo)&&e.grid}function tryGetModuleWijmoGridMultirow(){let e,t;return(e=__glob.wijmo)&&(t=e.grid)&&t.multirow}function tryGetModuleWijmoGridSheet(){let e,t;return(e=__glob.wijmo)&&(t=e.grid)&&t.sheet}function tryGetModuleWijmoOlap(){let e;return(e=__glob.wijmo)&&e.olap}function tryGetModuleWijmoGridDetail(){let e,t;return(e=__glob.wijmo)&&(t=e.grid)&&t.detail}function _merge(e,t,r=!1){if(!e&&t&&(e={}),t&&e)for(var o in t){var i=t[o],l=e[o];if(wjcCore.isObject(i)){if(void 0===l||!wjcCore.isObject(l)&&r){if(wjcCore.isFunction(i.clone)){e[o]=l=i.clone();continue}e[o]=l={}}wjcCore.isObject(l)&&_merge(e[o],i,r)}else(void 0===l||r&&void 0!==i)&&(e[o]=i)}return e}function getFakeCell(){return _fc||((_fc=document.createElement("div")).setAttribute(tryGetModuleWijmoGrid().FlexGrid._WJS_MEASURE,"true"),document&&document.body&&document.body.appendChild(_fc)),_fc.className="",_fc.innerHTML="",_fc.style.cssText="",_fc.style.visibility="hidden",_fc}function _removeFakeCell(){_fc&&(wjcCore.removeChild(_fc),_fc=null)}function bufToStr(e){for(var t=new Uint16Array(e),r="",o=0,i=t.length;o<i;o++)r+=String.fromCharCode(t[o]);return r}function strToBuf(e){for(var t=new ArrayBuffer(2*e.length),r=new Uint16Array(t),o=0,i=e.length;o<i;o++)r[o]=e.charCodeAt(o);return t}function blobToBuf(e,t){wjcCore.asFunction(t);var r=new FileReader;r.onload=function(e){t(e.target.result)},r.readAsArrayBuffer(e)}Object.defineProperty(exports,"__esModule",{value:!0});const wjcPdf=require("wijmo/wijmo.pdf"),wjcCore=require("wijmo/wijmo");var __glob="undefined"!=typeof window?window:self;const wjcSelfRef=require("wijmo/wijmo.grid.pdf");var wjcSelf=wjcSelfRef||exports;__glob.wijmo=__glob.wijmo||{},__glob.wijmo.grid=__glob.wijmo.grid||{},__glob.wijmo.grid.pdf=wjcSelf;var ScaleMode;!function(e){e[e.ActualSize=0]="ActualSize",e[e.PageWidth=1]="PageWidth",e[e.SinglePage=2]="SinglePage"}(ScaleMode=exports.ScaleMode||(exports.ScaleMode={}));var ExportMode;!function(e){e[e.All=0]="All",e[e.Selection=1]="Selection"}(ExportMode=exports.ExportMode||(exports.ExportMode={}));var _CellType;!function(e){e[e.None=0]="None",e[e.Cell=1]="Cell",e[e.ColumnHeader=2]="ColumnHeader",e[e.RowHeader=3]="RowHeader",e[e.TopLeft=4]="TopLeft",e[e.ColumnFooter=5]="ColumnFooter",e[e.BottomLeft=6]="BottomLeft"}(_CellType=exports._CellType||(exports._CellType={}));class PdfFormatItemEventArgs extends wjcCore.CancelEventArgs{constructor(e,t,r,o,i,l,s,n,a){super(),this.cancelBorders=!1,this._p=e,this._rng=t,this._cell=wjcCore.asType(r,HTMLElement,!0),this._canvas=o,this._clientRect=i,this._contentRect=l,this._textTop=s,this._style=n,this._getFormattedCell=a}get panel(){return this._p}get range(){return this._rng.clone()}get row(){return this._rng.row}get col(){return this._rng.col}get data(){return this._data}set data(e){this._data=e}get canvas(){return this._canvas}get cell(){return this._cell}get clientRect(){return this._clientRect}get contentRect(){return this._contentRect}getFormattedCell(){return wjcCore.asFunction(this._getFormattedCell)()}get style(){return this._style}get textTop(){return this._textTop}}exports.PdfFormatItemEventArgs=PdfFormatItemEventArgs,exports._merge=_merge;class _FlexGridPdfConverterCore{static draw(e,t,r,o,i,l){wjcCore.assert(!!e,"The flex argument cannot be null."),wjcCore.assert(!!t,"The doc argument cannot be null."),null==(l=this._applyDefaultDrawSettings(l)).scaleMode&&(l.scaleMode=null==o?ScaleMode.ActualSize:null==i?ScaleMode.PageWidth:ScaleMode.SinglePage),this._drawInternal(e,t,r,o,i,l)}static _applyDefaultDrawSettings(e){return _merge(_merge({},e),_FlexGridPdfConverterCore.DefaultDrawSettings)}static _drawInternal(e,t,r,o,i,l){var s=null!=r,n=new wjcCore.Size(t.width,t.height);r||(r=new wjcCore.Point(0,t.y)),wjcCore.isArray(l.embeddedFonts)&&l.embeddedFonts.forEach(e=>{t.registerFont(e)});var a=this._getRowsToRender(e,l),d=new FlexGridRenderer(e,l,a,this.BorderWidth,!0),h=new wjcCore.Rect(r.x||0,r.y||0,o||n.width,i||n.height),g=this._getScaleFactor(d,l.scaleMode,h),c=this._getPages(d,a,h,l,s,g),u=(l.progress?this._getCellsCount(e,l,c):0)/l._progressMax,w=0,_=0,f=l.progress?()=>{++w-_>=50&&(_=w,l.progress(w/u))}:null;l.progress&&l.progress(0);for(var p=0;p<c.length;p++){p>0&&t.addPage();var C=c[p],m=0===C.pageCol?h.left:0,R=0===C.pageRow?h.top:0;t.saveState(),t.paths.rect(0,0,n.width,n.height).clip(),t.scale(g,g,new wjcCore.Point(m,R)),t.translate(m,R);var x=new FlexGridRenderer(e,l,C.range,this.BorderWidth,p===c.length-1);x.render(t,f),t.restoreState(),t.x=m,t.y=R+x.renderSize.height*g}l.progress&&0<l._progressMax&&l.progress(l._progressMax)}static _getCellsCount(e,t,r){for(var o=0,i=0;i<r.length;i++)o+=new FlexGridRenderer(e,t,r[i].range,0,!1).getCellsCount();return o}static _getRowsToRender(e,t){var r=[];t.exportMode===ExportMode.All?r.push(new _CellRange(null,0,0,e.rows.length-1,e.columns.length-1)):r=e.getSelection();var o=new RowRange(r);if(!t.drawDetailRows){var i=[];o.forEach(e.cells,(t,r,o)=>{if(!e.isDetailRow(t)){var l=i.length;l&&i[l-1].bottomRow+1===o?i[l-1].row2++:i.push(new _CellRange(null,o,r.col,o,r.col2))}}),o=new RowRange(i)}return o}static _getScaleFactor(e,t,r){var o=1;if(t===ScaleMode.ActualSize)return o;var i=e.renderSize;if(t===ScaleMode.SinglePage)(l=Math.min(r.width/i.width,r.height/i.height))<1&&(o=l);else{var l=r.width/i.width;l<1&&(o=l)}return o}static _getPages(e,t,r,o,i,l){var s=[],n=[],a=wjcPdf.pxToPt,d=e.flex,h=e.showColumnHeader,g=e.showColumnFooter,c=e.showRowHeader,u=h?a(d.columnHeaders.height):0,w=g?a(d.columnFooters.height):0,_=c?a(d.rowHeaders.width):0,f=o.scaleMode===ScaleMode.ActualSize||o.scaleMode===ScaleMode.PageWidth,p=o.scaleMode===ScaleMode.ActualSize,C=(r.width-r.left)*(1/l),m=(r.height-r.top)*(1/l),R=r.width*(1/l),x=r.height*(1/l),b=u+w,y=_,v=i&&o.scaleMode==ScaleMode.ActualSize;if(f){var S=0;t.forEach(d.cells,(t,r,o,i)=>{var l=s.length?x:m;if(e.isRenderableRow(t)){var n=a(t.renderHeight);S++,b+=n,(h||S>1)&&(b-=this.BorderWidth),b>l&&(u+n>l||v?(s.push(i),b=u):(s.push(i-1),b=u+n),h&&(b-=this.BorderWidth))}})}var G=t.length()-1;if(G<0&&(G=0),s.length&&s[s.length-1]===G||s.push(G),p)for(var P=0,M=t.leftCol;M<=t.rightCol;M++){var T=d.columns[M];if(T.isVisible){var j=a(T.renderWidth),W=n.length?R:C;P++,y+=j,(c||P>1)&&(y-=this.BorderWidth),y>W&&(_+j>W||v?(n.push(M),y=_):(n.push(M-1),y=_+j),c&&(y-=this.BorderWidth))}}n.length&&n[n.length-1]===t.rightCol||n.push(t.rightCol);for(var F=[],H=!1,z=1,A=i&&o.maxPages>0?1:o.maxPages,M=0;M<s.length&&!H;M++)for(var L=0;L<n.length&&!H;L++,z++)if(!(H=z>A)){var D=0==M?0:s[M-1]+1,E=0==L?t.leftCol:n[L-1]+1;F.push(new PdfPageRowRange(t.subrange(D,s[M]-D+1,E,n[L]),L,M))}return F}}_FlexGridPdfConverterCore.BorderWidth=1,_FlexGridPdfConverterCore.DefFont=new wjcPdf.PdfFont,_FlexGridPdfConverterCore.DefaultDrawSettings={customCellContent:!1,drawDetailRows:!1,exportMode:ExportMode.All,maxPages:Number.MAX_VALUE,repeatMergedValuesAcrossPages:!0,recalculateStarWidths:!0,styles:{cellStyle:{font:{family:_FlexGridPdfConverterCore.DefFont.family,size:_FlexGridPdfConverterCore.DefFont.size,style:_FlexGridPdfConverterCore.DefFont.style,weight:_FlexGridPdfConverterCore.DefFont.weight},padding:1.5,verticalAlign:"middle"},headerCellStyle:{font:{weight:"bold"}}},_progressMax:1},exports._FlexGridPdfConverterCore=_FlexGridPdfConverterCore;class FlexGridRenderer{constructor(e,t,r,o,i){this._flex=e,this._borderWidth=o,this._lastPage=i,this._settings=t||{},this._topLeft=new PanelSectionRenderer(this,e.topLeftCells,new RowRange(this.showRowHeader&&this.showColumnHeader?[new _CellRange(null,0,0,e.topLeftCells.rows.length-1,e.topLeftCells.columns.length-1)]:[]),o),this._rowHeader=new PanelSectionRenderer(this,e.rowHeaders,this.showRowHeader?r.clone(0,e.rowHeaders.columns.length-1):new RowRange([]),o),this._columnHeader=new PanelSectionRenderer(this,e.columnHeaders,new RowRange(this.showColumnHeader?[new _CellRange(null,0,r.leftCol,e.columnHeaders.rows.length-1,r.rightCol)]:[]),o),this._cells=new PanelSectionRenderer(this,e.cells,r,o),this._bottomLeft=new PanelSectionRenderer(this,e.bottomLeftCells,new RowRange(this.showRowHeader&&this.showColumnFooter?[new _CellRange(null,0,0,e.bottomLeftCells.rows.length-1,e.bottomLeftCells.columns.length-1)]:[]),o),this._columnFooter=new PanelSectionRenderer(this,e.columnFooters,new RowRange(this.showColumnFooter?[new _CellRange(null,0,r.leftCol,e.columnFooters.rows.length-1,r.rightCol)]:[]),o)}get settings(){return this._settings}isRenderableRow(e){return e.isVisible&&!this._flex.isNewRow(e)}getCellsCount(){return this._topLeft.getCellsCount()+this._rowHeader.getCellsCount()+this._columnHeader.getCellsCount()+this._cells.getCellsCount()+this._bottomLeft.getCellsCount()+this._columnFooter.getCellsCount()}render(e,t){var r=Math.max(0,Math.max(this._topLeft.renderSize.width,this._rowHeader.renderSize.width)-this._borderWidth),o=Math.max(0,Math.max(this._topLeft.renderSize.height,this._columnHeader.renderSize.height)-this._borderWidth);this._topLeft.render(e,0,0,t),this._rowHeader.render(e,0,o,t),this._columnHeader.render(e,r,0,t),this._cells.render(e,r,o,t),o=Math.max(0,o+this._cells.renderSize.height-this._borderWidth),this._bottomLeft.render(e,0,o,t),this._columnFooter.render(e,r,o,t)}get flex(){return this._flex}get renderSize(){var e=Math.max(this._topLeft.renderSize.height,this._columnHeader.renderSize.height)+Math.max(this._rowHeader.renderSize.height,this._cells.renderSize.height)+Math.max(this._bottomLeft.renderSize.height,this._columnFooter.renderSize.height),t=Math.max(this._topLeft.renderSize.width,this._rowHeader.renderSize.width)+Math.max(this._columnHeader.renderSize.width,this._cells.renderSize.width);return this._columnHeader.visibleRows>0&&(e-=this._borderWidth),this._columnFooter.visibleRows>0&&(e-=this._borderWidth),this._rowHeader.visibleColumns>0&&(t-=this._borderWidth),new wjcCore.Size(t,e)}get showColumnHeader(){return this._flex.showColumnHeader}get showRowHeader(){return this._flex.showRowHeader}get showColumnFooter(){return this._lastPage&&this._flex.showColumnFooter}alignMergedTextToTheTopRow(e){return this._flex.alignMergedTextToTheTopRow(e)}getColumn(e,t,r){return this._flex.getColumn(e,t,r)}isAlternatingRow(e){return this._flex.isAlternatingRow(e)}isGroupRow(e){return this._flex.isGroupRow(e)}isNewRow(e){return this._flex.isNewRow(e)}isExpandableGroupRow(e){return this._flex.isExpandableGroupRow(e)}isBooleanCell(e,t,r){return this._flex.isBooleanCell(e,t,r)}getCellStyle(e,t,r){return this._flex.getCellStyle(e,t,r)}}class PanelSection{constructor(e,t){this._panel=e,this._range=t.clone()}get visibleRows(){return null==this._visibleRows&&(this._visibleRows=0,this._range.forEach(this._panel,e=>{this.isRenderableRow(e)&&this._visibleRows++})),this._visibleRows}get visibleColumns(){if(null==this._visibleColumns&&(this._visibleColumns=0,this._range.isValid))for(var e=this._range.leftCol;e<=this._range.rightCol;e++)this._panel.columns[e].isVisible&&this._visibleColumns++;return this._visibleColumns}get size(){if(null==this._size){var e=this._range.getRenderSize(this._panel);this._size=new wjcCore.Size(wjcPdf.pxToPt(e.width),wjcPdf.pxToPt(e.height))}return this._size}get range(){return this._range}get panel(){return this._panel}isRenderableRow(e){return e.isVisible}}class PanelSectionRenderer extends PanelSection{constructor(e,t,r,o){super(t,r),this._gr=e,this._borderWidth=o}get gr(){return this._gr}get renderSize(){return null==this._renderSize&&(this._renderSize=this.size.clone(),this.visibleColumns>1&&(this._renderSize.width-=this._borderWidth*(this.visibleColumns-1)),this.visibleRows>1&&(this._renderSize.height-=this._borderWidth*(this.visibleRows-1))),this._renderSize}getRangeWidth(e,t){for(var r=0,o=0,i=this.panel,l=e;l<=t;l++){var s=i.columns[l];s.isVisible&&(o++,r+=s.renderWidth)}return r=wjcPdf.pxToPt(r),o>1&&(r-=this._borderWidth*(o-1)),r}getRangeHeight(e,t){for(var r=0,o=0,i=this.panel,l=e;l<=t;l++){var s=i.rows[l];this.isRenderableRow(s)&&(o++,r+=s.renderHeight)}return r=wjcPdf.pxToPt(r),o>1&&(r-=this._borderWidth*(o-1)),r}getCellsCount(){var e=0,t=this.range,r=this.panel,o=new GetMergedRangeProxy(this._gr.flex);return t.isValid?(t.forEach(r,(i,l,s)=>{if(this.isRenderableRow(i))for(var n=t.leftCol;n<=t.rightCol;n++){var a=!1,d=void 0;if(this.gr.getColumn(r,s,n).isVisible){var h=null;(h=o.getMergedRange(r,s,n))?h.topRow!==h.bottomRow?h.firstVisibleRow!==s&&s!==l.topRow||(a=!0):(a=!0,d=Math.min(t.rightCol,h.rightCol)):a=!0,a&&e++,d&&(n=d)}}}),e):e}render(e,t,r,o){var i=this.range,l=this.panel,s=new GetMergedRangeProxy(this._gr.flex),n=new _CellRange(l,0,0,0,0),a=new CellRenderer(this,e,this._borderWidth);if(i.isValid){for(var d={},h=i.leftCol;h<=i.rightCol;h++)d[h]=r;i.forEach(l,(e,r,h)=>{if(this.isRenderableRow(e))for(var g=t,c=i.leftCol;c<=i.rightCol;c++){var u,w=this.gr.getColumn(l,h,c),_=void 0,f=void 0,p=!1,C=void 0;if(w.isVisible){var m=this._gr.flex.getCellContent(this.panel,e,w,c),R=null;if(R=s.getMergedRange(l,h,c))if(n.copyFrom(R),R.topRow!==R.bottomRow)R.firstVisibleRow===h||h===r.topRow?(p=!0,u=this.gr.settings.repeatMergedValuesAcrossPages?m:R.firstVisibleRow===h?m:"",_=this.getRangeHeight(h,Math.min(R.bottomRow,r.bottomRow)),f=this.getRangeWidth(c,c)):f=this.getRangeWidth(c,c);else{p=!0,u=this.gr.settings.repeatMergedValuesAcrossPages?m:c===R.leftCol?m:"",_=this.getRangeHeight(h,h),f=this.getRangeWidth(Math.max(i.leftCol,R.leftCol),Math.min(i.rightCol,R.rightCol)),C=Math.min(i.rightCol,R.rightCol);for(var x=c+1;x<=C;x++)d[x]+=_-this._borderWidth}else n.setRange(h,c,h,c),p=!0,u=m,_=this.getRangeHeight(h,h),f=this.getRangeWidth(c,c);p&&(a.renderCell(u,e,w,n,new wjcCore.Rect(g,d[c],f,_)),o&&o()),_&&(d[c]+=_-this._borderWidth),f&&(g+=f-this._borderWidth),C&&(c=C)}}})}}isRenderableRow(e){return this._gr.isRenderableRow(e)}}class CellRenderer{constructor(e,t,r){this._pr=e,this._area=t,this._borderWidth=r}renderCell(e,t,r,o,i){var l,s=this._pr.gr.flex,n=this._pr.panel,a=()=>s.getCell(n,o.topRow,o.leftCol),d=null,h=this._pr.gr.getCellStyle(n,t,r);if(this._pr.gr.settings.customCellContent){var g=s.getComputedStyle(d=a());h.color=g.color,h.backgroundColor=g.backgroundColor,h.borderColor=g.borderColor||g.borderRightColor||g.borderBottomColor||g.borderLeftColor||g.borderTopColor,h.font=new wjcPdf.PdfFont(g.fontFamily,wjcPdf._asPt(g.fontSize,!0,void 0),g.fontStyle,g.fontWeight),h.textAlign=g.textAlign}if(h.font&&!(h.font instanceof wjcPdf.PdfFont)){let e=h.font;h.font=new wjcPdf.PdfFont(e.family,e.size,e.style,e.weight)}if(h.boxSizing="border-box",h.borderWidth=this._borderWidth,h.borderStyle="solid",h.textAlign||s.isGroupRow(t)&&!r.aggregate||(h.textAlign=r.getAlignment()),n.cellType===_CellType.Cell&&s.rows.maxGroupLevel>=0&&o.leftCol===s.columns.firstVisibleIndex){var c=s.isGroupRow(t)?Math.max(t.level,0):s.rows.maxGroupLevel+1,u=wjcPdf._asPt(h.paddingLeft||h.padding),w=wjcPdf.pxToPt(c*s.treeIndent);console.log(c),h.paddingLeft=u+w}var _,f=this._measureCell(e,n,t,r,h,i),p=o.rowSpan>1&&o.visibleRowsCount>1&&this._pr.gr.alignMergedTextToTheTopRow(n);p&&(_=new wjcCore.Rect(f.contentRect.left,f.contentRect.top,f.contentRect.width,f.contentRect.height/(o.visibleRowsCount||1)),f.textRect=this._calculateTextRect(e,n,t,r,_,h)),wjcCore.isFunction(this._pr.gr.settings.formatItem)&&((l=new PdfFormatItemEventArgs(n,o,d,this._area,f.rect,f.contentRect,f.textRect.top,h,()=>d||a())).data=e,this._pr.gr.settings.formatItem(l),l.data!==e&&(e=wjcCore.asString(l.data),f.textRect=this._calculateTextRect(e,n,t,r,p?_:f.contentRect,h))),this._renderCell(e,t,r,o,f,h,!l||!l.cancel,!l||!l.cancelBorders)}_renderCell(e,t,r,o,i,l,s,n){(s||n)&&(this._isBooleanCellAndValue(e,this._pr.panel,t,r)?this._renderBooleanCell(e,i,l,s,n):this._renderTextCell(e,i,l,s,n))}_isBooleanCellAndValue(e,t,r,o){return this._pr.gr.isBooleanCell(t,r,o)&&this._isBoolean(e)}_isBoolean(e){var t=wjcCore.isString(e)&&e.toLowerCase();return"true"===t||"false"===t||!0===e||!1===e}_measureCell(e,t,r,o,i,l){this._decompositeStyle(i);var s=l.left,n=l.top,a=l.height,d=l.width,h=this._parseBorder(i),g=h.left.width,c=h.top.width,u=h.bottom.width,w=h.right.width,_=this._parsePadding(i),f=0,p=0,C=0,m=0;if("content-box"===i.boxSizing||void 0===i.boxSizing)f=_.top+a+_.bottom,p=_.left+d+_.right,C=a,m=d;else{if("border-box"!==i.boxSizing)throw"Invalid value: "+i.boxSizing;wjcPdf._IE&&i instanceof CSSStyleDeclaration?(f=_.top+_.bottom+a,p=_.left+_.right+d):(f=a-c-u,p=d-g-w),C=f-_.top-_.bottom,m=p-_.left-_.right}var l=new wjcCore.Rect(s,n,d,a),R=new wjcCore.Rect(s+g,n+c,p,f),x=new wjcCore.Rect(s+g+_.left,n+c+_.top,m,C);return{rect:l,clientRect:R,contentRect:x,textRect:this._calculateTextRect(e,t,r,o,x,i)}}_decompositeStyle(e){if(e){var t;(t=e.borderColor)&&(e.borderLeftColor||(e.borderLeftColor=t),e.borderRightColor||(e.borderRightColor=t),e.borderTopColor||(e.borderTopColor=t),e.borderBottomColor||(e.borderBottomColor=t)),(t=e.borderWidth)&&(e.borderLeftWidth||(e.borderLeftWidth=t),e.borderRightWidth||(e.borderRightWidth=t),e.borderTopWidth||(e.borderTopWidth=t),e.borderBottomWidth||(e.borderBottomWidth=t)),(t=e.borderStyle)&&(e.borderLeftStyle||(e.borderLeftStyle=t),e.borderRightStyle||(e.borderRightStyle=t),e.borderTopStyle||(e.borderTopStyle=t),e.borderBottomStyle||(e.borderBottomStyle=t)),(t=e.padding)&&(e.paddingLeft||(e.paddingLeft=t),e.paddingRight||(e.paddingRight=t),e.paddingTop||(e.paddingTop=t),e.paddingBottom||(e.paddingBottom=t))}}_parseBorder(e){var t={left:{width:0},top:{width:0},bottom:{width:0},right:{width:0}};return"none"!==e.borderLeftStyle&&(t.left={width:wjcPdf._asPt(e.borderLeftWidth),style:e.borderLeftStyle,color:e.borderLeftColor}),"none"!==e.borderTopStyle&&(t.top={width:wjcPdf._asPt(e.borderTopWidth),style:e.borderTopStyle,color:e.borderTopColor}),"none"!==e.borderBottomStyle&&(t.bottom={width:wjcPdf._asPt(e.borderBottomWidth),style:e.borderBottomStyle,color:e.borderBottomColor}),"none"!==e.borderRightStyle&&(t.right={width:wjcPdf._asPt(e.borderRightWidth),style:e.borderRightStyle,color:e.borderRightColor}),t}_parsePadding(e){return{left:wjcPdf._asPt(e.paddingLeft),top:wjcPdf._asPt(e.paddingTop),bottom:wjcPdf._asPt(e.paddingBottom),right:wjcPdf._asPt(e.paddingRight)}}_renderEmptyCell(e,t,r,o){var i=e.rect.left,l=e.rect.top,s=e.clientRect.width,n=e.clientRect.height,a=e.clientRect.left-e.rect.left,d=e.clientRect.top-e.rect.top,h=e.rect.top+e.rect.height-(e.clientRect.top+e.clientRect.height),g=e.rect.left+e.rect.width-(e.clientRect.left+e.clientRect.width);if(o&&(a||g||h||d)){var c=t.borderLeftColor||t.borderColor,u=t.borderRightColor||t.borderColor,w=t.borderTopColor||t.borderColor,_=t.borderBottomColor||t.borderColor;if(a&&d&&h&&g&&a===g&&a===h&&a===d&&c===u&&c===_&&c===w){var f=a,p=f/2;this._area.paths.rect(i+p,l+p,s+f,n+f).stroke(new wjcPdf.PdfPen(c,f))}else a&&this._area.paths.polygon([[i,l],[i+a,l+d],[i+a,l+d+n],[i,l+d+n+h]]).fill(c),d&&this._area.paths.polygon([[i,l],[i+a,l+d],[i+a+s,l+d],[i+a+s+g,l]]).fill(w),g&&this._area.paths.polygon([[i+a+s+g,l],[i+a+s,l+d],[i+a+s,l+d+n],[i+a+s+g,l+d+n+h]]).fill(u),h&&this._area.paths.polygon([[i,l+d+n+h],[i+a,l+d+n],[i+a+s,l+d+n],[i+a+s+g,l+d+n+h]]).fill(_)}r&&t.backgroundColor&&s>0&&n>0&&this._area.paths.rect(i+a,l+d,s,n).fill(t.backgroundColor)}_renderBooleanCell(e,t,r,o,i){if(this._renderEmptyCell(t,r,o,i),o){var l=t.textRect.left,s=t.textRect.top,n=t.textRect.height;if(this._area.paths.rect(l,s,n,n).fillAndStroke(wjcCore.Color.fromRgba(255,255,255),new wjcPdf.PdfPen(void 0,.5)),!0===wjcCore.changeType(e,wjcCore.DataType.Boolean,"")){var a=n/20,d=n-.5-2*a,h=n/8;this._area.document.saveState(),this._area.translate(l+.25+a,s+.25+a).paths.moveTo(h/2,.6*d).lineTo(d-.6*d,d-h).lineTo(d-h/2,h/2).stroke(new wjcPdf.PdfPen(void 0,h)),this._area.document.restoreState()}}}_renderTextCell(e,t,r,o,i){this._renderEmptyCell(t,r,o,i),o&&e&&this._area.drawText(e,t.textRect.left,t.textRect.top,{brush:r.color,font:r.font,height:t.textRect.height,width:t.textRect.width,align:"center"===r.textAlign?wjcPdf.PdfTextHorizontalAlign.Center:"right"===r.textAlign?wjcPdf.PdfTextHorizontalAlign.Right:"justify"===r.textAlign?wjcPdf.PdfTextHorizontalAlign.Justify:wjcPdf.PdfTextHorizontalAlign.Left})}_calculateTextRect(e,t,r,o,i,l){var s=i.clone();if(this._isBooleanCellAndValue(e,t,r,o)){var n=this._getTextLineHeight(l.font);switch(l.verticalAlign){case"middle":s.top=i.top+i.height/2-n/2;break;case"bottom":s.top=i.top+i.height-n}switch(l.textAlign){case"justify":case"center":s.left=i.left+i.width/2-n/2;break;case"right":s.left=i.left+i.width-n}s.height=s.width=n}else if(s.height>0&&s.width>0){switch(l.verticalAlign){case"bottom":(a=this._area.measureText(e,l.font,{height:s.height,width:s.width})).size.height<s.height&&(s.top+=s.height-a.size.height,s.height=a.size.height);break;case"middle":var a=this._area.measureText(e,l.font,{height:s.height,width:s.width});a.size.height<s.height&&(s.top+=s.height/2-a.size.height/2,s.height=a.size.height)}o.wordWrap||(s.height=this._getTextLineHeight(l.font))}return s}_extractCheckboxValue(e){var t=e.querySelector("input.wj-cell-check[type=checkbox]");if(t){var r=window.getComputedStyle(t);if("none"!==r.display&&"hidden"!==r.visibility)return t.checked}}_getTextLineHeight(e){return this._area.lineHeight(e)}}class GetMergedRangeProxy{constructor(e){this._columns={},this._flex=e}getMergedRange(e,t,r){var o=this._columns[r];if(o&&t>=o.topRow&&t<=o.bottomRow)return o;var i=this._flex.getMergedRange(e,t,r);return this._columns[r]=i?new _CellRange(e,i):null}}class _CellRange{constructor(e,t,r,o,i){if("number"==typeof t?(this._row=t,this._col=r,this._row2=o,this._col2=i):(this._row=t.row,this._col=t.col,this._row2=t.row2,this._col2=t.col2),this.firstVisibleRow=-1,this.visibleRowsCount=0,e){var l=this.topRow,s=this.bottomRow,n=e.rows.length;if(n>0)for(var a=l;a<=s&&a<n;a++)e.rows[a].isVisible&&(this.firstVisibleRow<0&&(this.firstVisibleRow=a),this.visibleRowsCount++)}}get row(){return this._row}set row(e){this._row=e}get col(){return this._col}set col(e){this._col=e}get row2(){return this._row2}set row2(e){this._row2=e}get col2(){return this._col2}set col2(e){this._col2=e}get topRow(){return Math.min(this._row,this._row2)}get bottomRow(){return Math.max(this._row,this._row2)}get leftCol(){return Math.min(this._col,this._col2)}get rightCol(){return Math.max(this._col,this._col2)}get rowSpan(){return Math.abs(this._row2-this._row)+1}get isValid(){return this._row>-1&&this._col>-1&&this._row2>-1&&this._col2>-1}copyFrom(e){this.setRange(e.row,e.col,e.row2,e.col2),this.firstVisibleRow=e.firstVisibleRow,this.visibleRowsCount=e.visibleRowsCount}clone(){return new _CellRange(null,this._row,this._col,this._row2,this._col2)}getRenderSize(e){let t=new wjcCore.Size(0,0);if(this.isValid){for(let r=this.topRow;r<=this.bottomRow;r++)t.height+=e.rows[r].renderHeight;for(let r=this.leftCol;r<=this.rightCol;r++)t.width+=e.columns[r].renderWidth}return t}setRange(e=-1,t=-1,r=e,o=t){this._row=wjcCore.asInt(e),this._col=wjcCore.asInt(t),this._row2=wjcCore.asInt(r),this._col2=wjcCore.asInt(o)}}exports._CellRange=_CellRange;class RowRange{constructor(e){this._ranges=e||[]}length(){for(var e=0,t=0;t<this._ranges.length;t++){var r=this._ranges[t];r.isValid&&(e+=r.bottomRow-r.topRow+1)}return e}get isValid(){return this._ranges.length&&this._ranges[0].isValid}get leftCol(){return this._ranges.length?this._ranges[0].leftCol:-1}get rightCol(){return this._ranges.length?this._ranges[0].rightCol:-1}clone(e,t){for(var r=[],o=0;o<this._ranges.length;o++){var i=this._ranges[o].clone();arguments.length>0&&(i.col=e),arguments.length>1&&(i.col2=t),r.push(i)}return new RowRange(r)}getRenderSize(e){for(var t=new wjcCore.Size(0,0),r=0;r<this._ranges.length;r++){var o=this._ranges[r].getRenderSize(e);t.width=Math.max(t.width,o.width),t.height+=o.height}return t}forEach(e,t){for(var r=0,o=0;o<this._ranges.length;o++){var i=this._ranges[o];if(i.isValid)for(var l=i.topRow;l<=i.bottomRow;l++)t(e.rows[l],i,l,r++)}}subrange(e,t,r,o){var i=[];if(e>=0&&t>0)for(var l=0,s=0,n=0;n<this._ranges.length&&t>0;n++,l=s+1){var a=this._ranges[n];if(s=l+(a.bottomRow-a.topRow),!(e>s)){var d=e>l?a.topRow+(e-l):a.topRow,h=Math.min(a.bottomRow,d+t-1),g=arguments.length>2?r:a.leftCol,c=arguments.length>2?o:a.rightCol;i.push(new _CellRange(null,d,g,h,c)),t-=h-d+1}}return new RowRange(i)}}class PdfPageRowRange{constructor(e,t,r){this._col=t,this._row=r,this._range=e}get range(){return this._range}get pageCol(){return this._col}get pageRow(){return this._row}}var _fc;exports._removeFakeCell=_removeFakeCell;class FlexGridPdfConverter{static draw(e,t,r,o,i){this.drawToPosition(e,t,null,r,o,i)}static drawToPosition(e,t,r,o,i,l){wjcCore.assert(!!e,"The flex argument cannot be null."),wjcCore.assert(!!t,"The doc argument cannot be null.");let s=void 0!==tryGetModuleWijmoGrid().FlexGrid&&e instanceof tryGetModuleWijmoGrid().FlexGrid;try{l=_FlexGridPdfConverterCore._applyDefaultDrawSettings(l);let n=e;s&&(l&&l.recalculateStarWidths&&e.columns._updateStarSizes(wjcPdf.ptToPx(t.width)),n=this._getFlexGridAdapter(e,l)),_FlexGridPdfConverterCore.draw(n,t,r,o,i,l)}finally{_removeFakeCell(),s&&l&&l.recalculateStarWidths&&e.invalidate(!0)}}static export(e,t,r){wjcCore.assert(!!e,"The flex argument cannot be null."),wjcCore.assert(!!t,"The fileName argument cannot be empty.");var o=(r=this._applyDefaultExportSettings(r)).documentOptions.ended;r.documentOptions.ended=((e,l)=>{r.progress&&r.progress(1),o&&!1===o.apply(i,[e,l])||wjcPdf.saveBlob(l.blob,t),e.dispose()});var i=new wjcPdf.PdfDocument(r.documentOptions);this.drawToPosition(e,i,null,null,null,r),i.end()}static _getFlexGridAdapter(e,t){return new(tryGetModuleWijmoGridMultirow()&&e instanceof tryGetModuleWijmoGridMultirow().MultiRow&&MultiRowAdapter||tryGetModuleWijmoGridSheet()&&e instanceof tryGetModuleWijmoGridSheet().FlexSheet&&FlexSheetAdapter||tryGetModuleWijmoOlap()&&e instanceof tryGetModuleWijmoOlap().PivotGrid&&PivotGridAdapter||FlexGridAdapter)(e,t)}static _applyDefaultExportSettings(e){return _merge(_merge({},e),this._DefaultExportSettings)}}FlexGridPdfConverter._DefaultExportSettings=_merge({scaleMode:ScaleMode.PageWidth,documentOptions:{compress:!1,pageSettings:{margins:{left:36,right:36,top:18,bottom:18}}},_progressMax:.9},_FlexGridPdfConverterCore.DefaultDrawSettings),exports.FlexGridPdfConverter=FlexGridPdfConverter;class FlexGridAdapter{constructor(e,t){this._flex=e,this._settings=t}get flex(){return this._flex}get settings(){return this._settings}get columns(){return this._flex.columns}get rows(){return this._flex.rows}get bottomLeftCells(){return this._flex.bottomLeftCells}get cells(){return this._flex.cells}get columnFooters(){return this._flex.columnFooters}get columnHeaders(){return this._flex.columnHeaders}get rowHeaders(){return this._flex.rowHeaders}get topLeftCells(){return this._flex.topLeftCells}get treeIndent(){return this._flex.treeIndent}getSelection(){var e=[],t=this._flex.selection;switch(this._flex.selectionMode){case tryGetModuleWijmoGrid().SelectionMode.None:break;case tryGetModuleWijmoGrid().SelectionMode.Cell:case tryGetModuleWijmoGrid().SelectionMode.CellRange:e.push(t);break;case tryGetModuleWijmoGrid().SelectionMode.Row:e.push(new(tryGetModuleWijmoGrid().CellRange)(t.topRow,0,t.topRow,this._flex.cells.columns.length-1));break;case tryGetModuleWijmoGrid().SelectionMode.RowRange:e.push(new(tryGetModuleWijmoGrid().CellRange)(t.topRow,0,t.bottomRow,this._flex.cells.columns.length-1));break;case tryGetModuleWijmoGrid().SelectionMode.ListBox:for(var r=-1,o=0;o<this._flex.rows.length;o++)this._flex.rows[o].isSelected?(r<0&&(r=o),o===this._flex.rows.length-1&&e.push(new(tryGetModuleWijmoGrid().CellRange)(r,0,o,this._flex.cells.columns.length-1))):(r>=0&&e.push(new(tryGetModuleWijmoGrid().CellRange)(r,0,o-1,this._flex.cells.columns.length-1)),r=-1)}return e}getCell(e,t,r){var o=e.getCellElement(t,r);return o||(o=getFakeCell(),this._flex.cellFactory.updateCell(e,t,r,o)),o}getComputedStyle(e){return e.className=e.className.replace("wj-state-selected",""),e.className=e.className.replace("wj-state-multi-selected",""),window.getComputedStyle(e)}getMergedRange(e,t,r){return this._flex.getMergedRange(e,t,r,!1)}get showColumnHeader(){return!!(this._flex.headersVisibility&tryGetModuleWijmoGrid().HeadersVisibility.Column)}get showRowHeader(){return!!(this._flex.headersVisibility&tryGetModuleWijmoGrid().HeadersVisibility.Row)}get showColumnFooter(){return this._flex.columnFooters.rows.length>0}alignMergedTextToTheTopRow(e){return!1}getCellData(e,t,r){return e.getCellData(r,t,!0)}getCellContent(e,t,r,o){var i=this.getCellData(e,o,t.index),l=r.isContentHtml;if(!i&&e.cellType===tryGetModuleWijmoGrid().CellType.Cell){var s=t;s instanceof tryGetModuleWijmoGrid().GroupRow&&s.dataItem&&s.dataItem.groupDescription&&r.index===e.columns.firstVisibleIndex&&(l=!0,i=s.getGroupHeader())}if(l){let e=getFakeCell();e.innerHTML=i,i=e.textContent.trim()}else if(this.settings.customCellContent){let l=this.getCell(e,t.index,o);!(i=l.textContent.trim())&&this.isBooleanCell(e,t,r)&&(i=this._extractCheckboxValue(l)+"")}return i}isBooleanCell(e,t,r){return r.dataType===wjcCore.DataType.Boolean&&e.cellType===tryGetModuleWijmoGrid().CellType.Cell&&!this.isExpandableGroupRow(t)}getColumn(e,t,r){return e.columns[r]}isAlternatingRow(e){return e.index%2!=0}isGroupRow(e){return e instanceof tryGetModuleWijmoGrid().GroupRow}isNewRow(e){return e instanceof tryGetModuleWijmoGrid()._NewRowTemplate}isDetailRow(e){return tryGetModuleWijmoGridDetail()&&e instanceof tryGetModuleWijmoGridDetail().DetailRow}isExpandableGroupRow(e){return e instanceof tryGetModuleWijmoGrid().GroupRow&&e.hasChildren}getCellStyle(e,t,r){var o=this.settings.styles,i=_merge({},o.cellStyle),l=this._flex;switch(e.cellType){case tryGetModuleWijmoGrid().CellType.Cell:this.isExpandableGroupRow(t)?_merge(i,o.groupCellStyle,!0):this.isAlternatingRow(t)&&_merge(i,o.altCellStyle,!0);break;case tryGetModuleWijmoGrid().CellType.ColumnHeader:case tryGetModuleWijmoGrid().CellType.RowHeader:case tryGetModuleWijmoGrid().CellType.TopLeft:case tryGetModuleWijmoGrid().CellType.BottomLeft:_merge(i,o.headerCellStyle,!0);break;case tryGetModuleWijmoGrid().CellType.ColumnFooter:_merge(i,o.headerCellStyle,!0),_merge(i,o.footerCellStyle,!0)}return!this.settings.customCellContent&&l._getShowErrors()&&l._getError(e,t.index,r.index)&&_merge(i,o.errorCellStyle,!0),i}_extractCheckboxValue(e){var t=e.querySelector("input.wj-cell-check[type=checkbox]");if(t){var r=window.getComputedStyle(t);if("none"!==r.display&&"hidden"!==r.visibility)return t.checked}}}class FlexSheetAdapter extends FlexGridAdapter{getCellData(e,t,r){return e.cellType===tryGetModuleWijmoGrid().CellType.Cell?e.rows[r]instanceof tryGetModuleWijmoGridSheet().HeaderRow?this.flex.columnHeaders.getCellData(r,t,!0):this.flex.getCellValue(r,t,!0):super.getCellData(e,t,r)}getCellStyle(e,t,r){var o=super.getCellStyle(e,t,r),i=this.flex.selectedSheet.findTable(t.index,r.index);if(i){var l=i.getRange(),s=t.index-l.topRow,n=r.index-l.leftCol,a=i._getTableCellAppliedStyles(s,n);a&&(a.font=new wjcPdf.PdfFont(a.fontFamily,wjcPdf._asPt(a.fontSize,!0,void 0),a.fontStyle,a.fontWeight)),_merge(o,a,!0)}return o}get showColumnHeader(){return!1}get showRowHeader(){return!1}get showColumnFooter(){return!1}}class MultiRowAdapter extends FlexGridAdapter{getColumn(e,t,r){return this.flex.getBindingColumn(e,t,r)}isAlternatingRow(e){return e instanceof tryGetModuleWijmoGridMultirow()._MultiRow?e.dataIndex%2!=0:super.isAlternatingRow(e)}}class PivotGridAdapter extends FlexGridAdapter{alignMergedTextToTheTopRow(e){return!this.flex.centerHeadersVertically&&(e.cellType===tryGetModuleWijmoGrid().CellType.ColumnHeader||e.cellType===tryGetModuleWijmoGrid().CellType.RowHeader)}}var PdfWebWorkerResponseStatus;!function(e){e[e.Done=1]="Done",e[e.Progress=2]="Progress"}(PdfWebWorkerResponseStatus||(PdfWebWorkerResponseStatus={}));const DefGridName="";class PdfWebWorkerExportDoneEventArgs extends wjcCore.EventArgs{constructor(e){super(),this._buf=e}get blob(){return this._blob||(this._blob=new Blob([new Uint8Array(this._buf)],{type:"application/pdf"})),this._blob}get buffer(){return this._buf}}exports.PdfWebWorkerExportDoneEventArgs=PdfWebWorkerExportDoneEventArgs;class PdfWebWorkerClient{static exportGrid(e,t,r,o,i,l){(o=_merge({},o)).progress=o.progress||l,this.addGrid(e,t,"",o),this.export(e,o.documentOptions,e=>{wjcCore.isFunction(i)&&!1===i(e)||wjcPdf.saveBlob(e.blob,r)},l)}static export(e,t,r,o){e.addEventListener("message",function t(i){let l=i.data;switch(l.status){case PdfWebWorkerResponseStatus.Done:e.removeEventListener("message",t),wjcCore.isFunction(r)&&r(new PdfWebWorkerExportDoneEventArgs(l.data));break;case PdfWebWorkerResponseStatus.Progress:o&&o(l.data);break;default:throw`Unknown status: ${l.status}`}});let i=this._clientDataToArrayBuffer(e);e.postMessage({content:i,settings:t},[i]),this._clearClientData(e)}static addGrid(e,t,r,o){let i=this._gridToJson(t,o);this._addClientData(e,JSON.stringify(i),r,o,!0)}static addImage(e,t,r,o){let i=wjcCore.isString(t)&&t.indexOf("data:image/svg")>=0?t:wjcPdf._PdfImageHelper.getDataUri(t);this._addClientData(e,i,r,o)}static addString(e,t,r){this._addClientData(e,t,r,null)}static serializeGrid(e,t){let r=this._gridToJson(e,t);return strToBuf(JSON.stringify(r))}static _addClientData(e,t,r,o,i=!1){wjcCore.asType(e,Worker),wjcCore.asString(r),wjcCore.asString(t,!0);let l=e;l.clientData=l.clientData||{},l.clientData[r]={content:t,settings:o?JSON.stringify(o):null};var s=l.clientData[r];i&&(s.isGrid=!0,s.progressMessaging=wjcCore.isFunction(o.progress))}static _clearClientData(e){delete e.clientData}static _clientDataToArrayBuffer(e){let t=e;return strToBuf(JSON.stringify(t.clientData||{}))}static _gridToJson(e,t){t=FlexGridPdfConverter._applyDefaultExportSettings(t);let r;try{r=new wjcPdf.PdfDocument(t.documentOptions),t&&t.recalculateStarWidths&&e.columns._updateStarSizes(wjcPdf.ptToPx(r.width));let o=this._getJsonConverter(e,t).convert();strToBuf(JSON.stringify(o));return o}finally{_removeFakeCell(),t&&t.recalculateStarWidths&&e.invalidate(!0),null!=r&&(r.dispose(),r=null)}}static _getJsonConverter(e,t){return new(tryGetModuleWijmoGridMultirow()&&e instanceof tryGetModuleWijmoGridMultirow().MultiRow&&MultiRowJsonConverter||tryGetModuleWijmoOlap()&&e instanceof tryGetModuleWijmoOlap().PivotGrid&&PivotGridJsonConverter||FlexGridJsonConverter)(e,FlexGridPdfConverter._getFlexGridAdapter(e,t))}}exports.PdfWebWorkerClient=PdfWebWorkerClient;class PdfWebWorker{static initExportGrid(){this.initExport((e,t)=>{var r=t[""];r.progressMessaging&&(r.settings._progressMax=FlexGridPdfConverter._DefaultExportSettings._progressMax,r.settings.progress=(e=>{this.sendExportProgress(e)}),e.ended.addHandler(()=>{this.sendExportProgress(1)})),FlexGridPdfConverter.draw(r.content,e,null,null,r.settings),e.end()})}static initExport(e){self.addEventListener("message",function t(r){self.removeEventListener("message",t);let o=r.data,i=JSON.parse(bufToStr(o.content)),l=o.settings||{};l.ended=((e,t)=>{blobToBuf(t.blob,e=>{self.postMessage({data:e,status:PdfWebWorkerResponseStatus.Done},[e])})});let s=new wjcPdf.PdfDocument(l);Object.keys(i).forEach(e=>{let t=i[e];t.settings&&(t.settings=JSON.parse(t.settings)),t.isGrid&&(t.settings&&PdfWebWorker._disableUnsupportedFeatures(t.settings),t.content=PdfWebWorker._deserializeGridFromString(t.content,t.settings))}),e(s,i)})}static sendExportProgress(e){e=wjcCore.clamp(e,0,1),self.postMessage({data:e,status:PdfWebWorkerResponseStatus.Progress})}static deserializeGrid(e,t){return this._deserializeGridFromString(bufToStr(e),t)}static _deserializeGridFromString(e,t){return this._getJsonAdapter(JSON.parse(e),FlexGridPdfConverter._applyDefaultExportSettings(t))}static _disableUnsupportedFeatures(e){e.customCellContent=!1}static _getJsonAdapter(e,t){switch(e.typeName){case"MultiRow":return new MultiRowJsonAdapter(e,t);case"PivotGrid":return new PivotGridJsonAdapter(e,t);default:return new FlexGridJsonAdapter(e,t)}}}exports.PdfWebWorker=PdfWebWorker;var RowState;!function(e){e[e.None=0]="None",e[e.Alternate=1]="Alternate",e[e.Group=2]="Group",e[e.ExpandableGroup=4]="ExpandableGroup",e[e.New=8]="New",e[e.Visible=16]="Visible",e[e.Detail=32]="Detail"}(RowState||(RowState={}));var ColState;!function(e){e[e.None=0]="None",e[e.Visible=1]="Visible"}(ColState||(ColState={}));class FlexGridJsonConverter{constructor(e,t){this._flex=e,this._adapter=t}convert(){var e={};return e.typeName=this._getTypeName(this._flex),e.selection=this._serializeSelection(),e.showColumnFooter=this.adapter.showColumnFooter,e.showColumnHeader=this.adapter.showColumnHeader,e.showRowHeader=this.adapter.showRowHeader,e.treeIndent=this._flex.treeIndent,e.bottomLeftCells=this._serializePanel(this._flex.bottomLeftCells),e.cells=this._serializePanel(this._flex.cells),e.columnFooters=this._serializePanel(this._flex.columnFooters),e.columnHeaders=this._serializePanel(this._flex.columnHeaders),e.rowHeaders=this._serializePanel(this._flex.rowHeaders),e.topLeftCells=this._serializePanel(this._flex.topLeftCells),e}get adapter(){return this._adapter}get flex(){return this._flex}_getTypeName(e){return e.constructor.toString().match(/function\s*(\w+)/)[1]}_getRowState(e){var t=RowState.None;return this.adapter.isAlternatingRow(e)&&(t|=RowState.Alternate),e instanceof tryGetModuleWijmoGrid().GroupRow&&(t|=RowState.Group),this.adapter.isDetailRow(e)&&(t|=RowState.Detail),this.adapter.isExpandableGroupRow(e)&&(t|=RowState.ExpandableGroup),e instanceof tryGetModuleWijmoGrid()._NewRowTemplate&&(t|=RowState.New),e.isVisible&&(t|=RowState.Visible),t}_getColumnState(e){var t=ColState.None;return e.isVisible&&(t|=ColState.Visible),t}_serializeSelection(){let e=this.adapter.getSelection(),t=[];for(let o=0;o<e.length;o++){var r=e[o];t.push([r.row,r.col,r.row2,r.col2])}return t}_serializeColumns(e){let t=[];for(let r=0,o=(e||[]).length;r<o;r++){let o=e[r],i={aggregate:o.aggregate,alignment:o.getAlignment(),dataType:o.dataType,renderWidth:o.renderWidth,wordWrap:o.wordWrap},l=this._getColumnState(o);l!=ColState.None&&(i.state=l),t.push(i)}return t}_serializePanel(e){var t={cellType:e.cellType,height:e.height,width:e.width};t.mergedRanges=this._serializeMergedRanges(e),t.columns=this._serializeColumns(e.columns),t.columnsFirstVisibleIndex=e.columns.firstVisibleIndex,t.rows=[],t.rowsMaxGroupLevel=e.rows.maxGroupLevel;for(let r=0,o=e.rows.length,i=e.columns.length;r<o;r++){let o=e.rows[r],l={renderHeight:o.renderHeight};t.rows.push(l),o instanceof tryGetModuleWijmoGrid().GroupRow&&(l.level=o.level);let s=this._getRowState(o);s!=RowState.None&&(l.state=s),l.cells=[];for(let t=0;t<i;t++)l.cells[t]=this._adapter.getCellContent(e,e.rows[r],e.columns[t],t)}return t}_serializeMergedRanges(e){for(var t=[],r=[],o=0;o<e.columns.length;o++)r[o]=0;for(var i=0;i<e.rows.length;i++)for(var l=0;l<e.columns.length;l++)if(!(i<r[l])){var s=e.grid.getMergedRange(e,i,l);if(null!=s&&!s.isSingleCell){t.push([s.row,s.col,s.row2,s.col2]);for(var n=s.col;n<=s.col2;n++)r[n]=s.row2+1;s.col==s.col2||(l=s.col2)}}return t}}class MultiRowJsonConverter extends FlexGridJsonConverter{convert(){let e=super.convert();return e.rowsPerItem=this.flex.rowsPerItem,e}_serializePanel(e){let t=super._serializePanel(e);return t.cellGroups=this._serializeCellGroup(e),t}_serializeCellGroup(e){let t=[],r=[],o=this.flex.rowsPerItem;e.cellType!=tryGetModuleWijmoGrid().CellType.TopLeft&&e.cellType!=tryGetModuleWijmoGrid().CellType.ColumnHeader||(o=e.rows.length);for(let i=0;i<o;i++){r[i]=[];for(let o=0;o<e.columns.length;o++){let l=this.flex.getBindingColumn(e,i,o),s=t.indexOf(l);r[i][o]=s<0?t.push(l)-1:s}}return{bindingColumns:this._serializeColumns(t),mappings:r}}}class PivotGridJsonConverter extends FlexGridJsonConverter{convert(){let e=super.convert();return e.centerHeadersVertically=this.flex.centerHeadersVertically,e}}class RowJson{constructor(e,t){this._index=t,this._level=e.level,this._renderHeight=e.renderHeight,this._state=e.state,this._cells=e.cells}get cells(){return this._cells}get index(){return this._index}get isAlternatingRow(){return(this._state&RowState.Alternate)!=RowState.None}get isGroupRow(){return(this._state&RowState.Group)!=RowState.None}get isDetailRow(){return(this._state&RowState.Detail)!=RowState.None}get isExpandableGroupRow(){return(this._state&RowState.ExpandableGroup)!=RowState.None}get isNewRow(){return(this._state&RowState.New)!=RowState.None}get isVisible(){return(this._state&RowState.Visible)!=RowState.None}get level(){return this._level}get renderHeight(){return this._renderHeight}}class ColumnJson{constructor(e,t){this._aggregate=e.aggregate,this._alignment=e.alignment,this._dataType=e.dataType,this._index=t,this._renderWidth=e.renderWidth,this._state=e.state,this._wordWrap=e.wordWrap}get aggregate(){return this._aggregate}get dataType(){return this._dataType}getAlignment(){return this._alignment}get index(){return this._index}get isVisible(){return(this._state&ColState.Visible)!=ColState.None}get renderWidth(){return this._renderWidth}get wordWrap(){return this._wordWrap}}class RowJsonCollection{constructor(e,t=-1){this._maxGroupLevel=t,this._length=e.length;for(let t=0;t<e.length;t++)this[t]=new RowJson(e[t],t)}get length(){return this._length}get maxGroupLevel(){return this._maxGroupLevel}}class ColumnJsonCollection{constructor(e,t=-1){this._firstVisibleIndex=t,this._length=e.length;for(let t=0;t<e.length;t++)this[t]=new ColumnJson(e[t],t)}get length(){return this._length}get firstVisibleIndex(){return this._firstVisibleIndex}}class GridJsonPanel{constructor(e){this._height=e.height,this._width=e.width,this._cellType=e.cellType,this._columns=new ColumnJsonCollection(e.columns,e.columnsFirstVisibleIndex),this._rows=new RowJsonCollection(e.rows,e.rowsMaxGroupLevel),this._mergedRanges=this._deserializeMergedRanges(e.mergedRanges)}get cellType(){return this._cellType}get height(){return this._height}get width(){return this._width}get columns(){return this._columns}get rows(){return this._rows}getMergedRange(e,t){let r=this._mergedRanges[e];if(r)for(let e=0,i=r.length;e<i;e++){var o=r[e];if(t>=o.col&&t<=o.col2)return o}return null}_deserializeMergedRanges(e){let t=[];e=e||[];for(let e=0,r=this._rows.length;e<r;e++)t[e]=[];for(let r=0,o=e.length;r<o;r++){let o=e[r],i=new _CellRange(null,o[0],o[1],o[2],o[3]);for(let e=i.row;e<=i.row2;e++)t[e].push(i)}return t}}class FlexGridJsonAdapter{constructor(e,t){this._settings=t,this._bottomLeftCells=this.deserializePanel(e.bottomLeftCells),this._cells=this.deserializePanel(e.cells),this._columnFooters=this.deserializePanel(e.columnFooters),this._columnHeaders=this.deserializePanel(e.columnHeaders),this._rowHeaders=this.deserializePanel(e.rowHeaders),this._topLeftCells=this.deserializePanel(e.topLeftCells),this._treeIndent=e.treeIndent,this._showColumnFooter=e.showColumnFooter,this._showColumnHeader=e.showColumnHeader,this._showRowHeader=e.showRowHeader,this._selection=[];for(let t=0;t<e.selection.length;t++){let r=e.selection[t];this._selection.push(new _CellRange(null,r[0],r[1],r[2],r[3]))}}get settings(){return this._settings}get columns(){return this._cells.columns}get rows(){return this._cells.rows}get bottomLeftCells(){return this._bottomLeftCells}get cells(){return this._cells}get columnFooters(){return this._columnFooters}get columnHeaders(){return this._columnHeaders}get rowHeaders(){return this._rowHeaders}get topLeftCells(){return this._topLeftCells}get treeIndent(){return this._treeIndent}getSelection(){return this._selection}getCell(e,t,r){throw"Not implemented"}getComputedStyle(e){throw"Not implemented"}getMergedRange(e,t,r){return e.getMergedRange(t,r)}get showColumnFooter(){return this._showColumnFooter}get showColumnHeader(){return this._showColumnHeader}get showRowHeader(){return this._showRowHeader}alignMergedTextToTheTopRow(e){return!1}getCellData(e,t,r){return e.rows[r].cells[t]}getCellContent(e,t,r,o){return this.getCellData(e,o,t.index)}isBooleanCell(e,t,r){return r.dataType===wjcCore.DataType.Boolean&&e.cellType===_CellType.Cell&&!this.isExpandableGroupRow(t)}getColumn(e,t,r){return e.columns[r]}isAlternatingRow(e){return e.isAlternatingRow}isGroupRow(e){return e.isGroupRow}isNewRow(e){return e.isNewRow}isDetailRow(e){return e.isDetailRow}isExpandableGroupRow(e){return e.isExpandableGroupRow}getCellStyle(e,t,r){var o=this.settings.styles,i=_merge({},o.cellStyle);switch(e.cellType){case _CellType.Cell:this.isExpandableGroupRow(t)?_merge(i,o.groupCellStyle,!0):this.isAlternatingRow(t)&&_merge(i,o.altCellStyle,!0);break;case _CellType.ColumnHeader:case _CellType.RowHeader:case _CellType.TopLeft:case _CellType.BottomLeft:_merge(i,o.headerCellStyle,!0);break;case _CellType.ColumnFooter:_merge(i,o.headerCellStyle,!0),_merge(i,o.footerCellStyle,!0)}return i}deserializePanel(e){return new GridJsonPanel(e)}}class PivotGridJsonAdapter extends FlexGridJsonAdapter{constructor(e,t){super(e,t),this._centerHeadersVertically=e.centerHeadersVertically}alignMergedTextToTheTopRow(e){return!this._centerHeadersVertically&&(e.cellType===_CellType.ColumnHeader||e.cellType===_CellType.RowHeader)}}class MultiRowJsonPanel extends GridJsonPanel{constructor(e){super(e),e.cellGroups&&(this._cellGroups={bindingColumns:new ColumnJsonCollection(e.cellGroups.bindingColumns),mappings:e.cellGroups.mappings})}getColumn(e,t,r){return this._cellGroups?(this.cellType!==_CellType.ColumnHeader&&this.cellType!==_CellType.BottomLeft&&(e%=r),this._cellGroups.bindingColumns[this._cellGroups.mappings[e][t]]):this.columns[t]}}class MultiRowJsonAdapter extends FlexGridJsonAdapter{constructor(e,t){super(e,t),this._rowsPerItem=e.rowsPerItem}deserializePanel(e){return new MultiRowJsonPanel(e)}getColumn(e,t,r){return e.getColumn(t,r,this._rowsPerItem)}}