/*
    *
    * Wijmo Library 5.20182.500
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
function tryGetModuleWijmoGridDetail(){let e,t;return(e=window.wijmo)&&(t=e.grid)&&t.detail}function tryGetModuleWijmoGridMultirow(){let e,t;return(e=window.wijmo)&&(t=e.grid)&&t.multirow}function tryGetModuleWijmoGridSheet(){let e,t;return(e=window.wijmo)&&(t=e.grid)&&t.sheet}function tryGetModuleWijmoOlap(){let e;return(e=window.wijmo)&&e.olap}function _merge(e,t,r=!1){if(t&&e)for(var i in t){var o=t[i],l=e[i];if(wjcCore.isObject(o)){if(void 0===l||!wjcCore.isObject(l)&&r){if(wjcCore.isFunction(o.clone)){e[i]=l=o.clone();continue}e[i]=l={}}wjcCore.isObject(l)&&_merge(e[i],o,r)}else(void 0===l||r&&void 0!==o)&&(e[i]=o)}return e}import*as wjcPdf from"wijmo/wijmo.pdf";import*as wjcGrid from"wijmo/wijmo.grid";import*as wjcCore from"wijmo/wijmo";import*as wjcSelfRef from"wijmo/wijmo.grid.pdf";var wjcSelf=wjcSelfRef||exports;window.wijmo=window.wijmo||{},window.wijmo.grid=window.wijmo.grid||{},window.wijmo.grid.pdf=wjcSelf;export var ScaleMode;!function(e){e[e.ActualSize=0]="ActualSize",e[e.PageWidth=1]="PageWidth",e[e.SinglePage=2]="SinglePage"}(ScaleMode||(ScaleMode={}));export var ExportMode;!function(e){e[e.All=0]="All",e[e.Selection=1]="Selection"}(ExportMode||(ExportMode={}));export class PdfFormatItemEventArgs extends wjcGrid.CellRangeEventArgs{constructor(e,t,r,i,o,l,n,s,a){super(e,t),this.cancelBorders=!1,this._cell=wjcCore.asType(r,HTMLElement,!0),this._canvas=i,this._clientRect=o,this._contentRect=l,this._textTop=n,this._style=s,this._getFormattedCell=a}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}};var globCell;export class FlexGridPdfConverter{static draw(e,t,r,i,o){this.drawToPosition(e,t,null,r,i,o)}static drawToPosition(e,t,r,i,o,l){wjcCore.assert(!!e,"The flex argument cannot be null."),wjcCore.assert(!!t,"The doc argument cannot be null.");var n=_merge({},l);_merge(n,this.DefaultDrawSettings),n.scaleMode=null==i?ScaleMode.ActualSize:null==o?ScaleMode.PageWidth:ScaleMode.SinglePage,this._prepareGridAndDraw(e,t,r,i,o,n)}static export(e,t,r){wjcCore.assert(!!e,"The flex argument cannot be null."),wjcCore.assert(!!t,"The fileName argument cannot be empty."),_merge(r=_merge({},r),this.DefaultExportSettings);var i=r.documentOptions.ended;r.documentOptions.ended=((e,r)=>{i&&!1===i.apply(o,[e,r])||wjcPdf.saveBlob(r.blob,t),e.dispose()});var o=new wjcPdf.PdfDocument(r.documentOptions);this._prepareGridAndDraw(e,o,null,null,null,r,!0)}static _prepareGridAndDraw(e,t,r,i,o,l,n=!1){try{l.recalculateStarWidths&&e.columns._updateStarSizes(wjcPdf.ptToPx(t.width)),this._draw(e,t,r,i,o,l),n&&t.end()}finally{l.recalculateStarWidths&&e.invalidate(!0)}}static _draw(e,t,r,i,o,l){var n=null!=r,s=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=RowRange.getSelection(e,l.exportMode);!l.drawDetailRows&&tryGetModuleWijmoGridDetail()&&e.mergeManager&&e.mergeManager instanceof tryGetModuleWijmoGridDetail().DetailMergeManager&&(a=this._excludeDetailRows(a,e));var d=this._getGridRenderer(e,l,a,this.BorderWidth,!0),h=new wjcCore.Rect(r.x||0,r.y||0,i||s.width,o||s.height),c=this._getScaleFactor(d,l.scaleMode,h),g=this._getPages(d,a,h,l,n,c);(globCell=document.createElement("div")).setAttribute(wjcGrid.FlexGrid._WJS_MEASURE,"true"),globCell.style.visibility="hidden",e.hostElement.appendChild(globCell);try{for(var w=0;w<g.length;w++){w>0&&t.addPage();var u=g[w],f=0===u.pageCol?h.left:0,p=0===u.pageRow?h.top:0;t.saveState(),t.paths.rect(0,0,s.width,s.height).clip(),t.scale(c,c,new wjcCore.Point(f,p)),t.translate(f,p);var m=this._getGridRenderer(e,l,u.range,this.BorderWidth,w===g.length-1);m.render(t),t.restoreState(),t.x=f,t.y=p+m.renderSize.height*c}}finally{globCell&&(wjcCore.removeChild(globCell),globCell=null)}}static _excludeDetailRows(e,t){var r=[];return e.forEach(t.cells,(e,t,i)=>{e instanceof tryGetModuleWijmoGridDetail().DetailRow||r.push(new wjcGrid.CellRange(i,t.col,i,t.col2))}),new RowRange(t,r)}static _getScaleFactor(e,t,r){var i=1;if(t===ScaleMode.ActualSize)return i;var o=e.renderSize;if(t===ScaleMode.SinglePage)(l=Math.min(r.width/o.width,r.height/o.height))<1&&(i=l);else{var l=r.width/o.width;l<1&&(i=l)}return i}static _getPages(e,t,r,i,o,l){var n=[],s=[],a=wjcPdf.pxToPt,d=e.flex,h=e.showColumnHeader,c=e.showColumnFooter,g=e.showRowHeader,w=h?a(d.columnHeaders.height):0,u=c?a(d.columnFooters.height):0,f=g?a(d.rowHeaders.width):0,p=i.scaleMode===ScaleMode.ActualSize||i.scaleMode===ScaleMode.PageWidth,m=i.scaleMode===ScaleMode.ActualSize,C=(r.width-r.left)*(1/l),R=(r.height-r.top)*(1/l),_=r.width*(1/l),b=r.height*(1/l),S=w+u,v=f,x=o&&i.scaleMode==ScaleMode.ActualSize;if(p){var j=0;t.forEach(d.cells,(e,t,r,i)=>{var o=n.length?b:R;if(PanelSection.isRenderableRow(e)){var l=a(e.renderHeight);j++,S+=l,(h||j>1)&&(S-=this.BorderWidth),S>o&&(w+l>o||x?(n.push(i),S=w):(n.push(i-1),S=w+l),h&&(S-=this.BorderWidth))}})}var y=t.length()-1;if(y<0&&(y=0),n.length&&n[n.length-1]===y||n.push(y),m)for(var P=0,G=t.leftCol;G<=t.rightCol;G++){var M=d.columns[G];if(M.isVisible){var T=a(M.renderWidth),W=s.length?_:C;P++,v+=T,(g||P>1)&&(v-=this.BorderWidth),v>W&&(f+T>W||x?(s.push(G),v=f):(s.push(G-1),v=f+T),g&&(v-=this.BorderWidth))}}s.length&&s[s.length-1]===t.rightCol||s.push(t.rightCol);for(var z=[],H=!1,A=1,F=o&&i.maxPages>0?1:i.maxPages,G=0;G<n.length&&!H;G++)for(var L=0;L<s.length&&!H;L++,A++)if(!(H=A>F)){var B=0==G?0:n[G-1]+1,V=0==L?t.leftCol:s[L-1]+1;z.push(new PdfPageRowRange(t.subrange(B,n[G]-B+1,V,s[L]),L,G))}return z}static _getGridRenderer(e,t,r,i,o){return new(tryGetModuleWijmoGridMultirow()&&e instanceof tryGetModuleWijmoGridMultirow().MultiRow&&MultiRowRenderer||tryGetModuleWijmoGridSheet()&&e instanceof tryGetModuleWijmoGridSheet().FlexSheet&&FlexSheetRenderer||tryGetModuleWijmoOlap()&&e instanceof tryGetModuleWijmoOlap().PivotGrid&&PivotGridRenderer||FlexGridRenderer)(e,t,r,i,o)}};FlexGridPdfConverter.BorderWidth=1,FlexGridPdfConverter.DefaultDrawSettings={customCellContent:!1,drawDetailRows:!1,exportMode:ExportMode.All,maxPages:Number.MAX_VALUE,repeatMergedValuesAcrossPages:!0,recalculateStarWidths:!0,styles:{cellStyle:{font:new wjcPdf.PdfFont,padding:1.5,verticalAlign:"middle"},headerCellStyle:{font:{weight:"bold"}}}},FlexGridPdfConverter.DefaultExportSettings=_merge({scaleMode:ScaleMode.PageWidth,documentOptions:{compress:!1,pageSettings:{margins:{left:36,right:36,top:18,bottom:18}}}},FlexGridPdfConverter.DefaultDrawSettings);class FlexGridRenderer{constructor(e,t,r,i,o){this._flex=e,this._borderWidth=i,this._lastPage=o,this._settings=t||{},this._topLeft=new PanelSectionRenderer(this,e.topLeftCells,this.showRowHeader&&this.showColumnHeader?new RowRange(e,[new wjcGrid.CellRange(0,0,e.topLeftCells.rows.length-1,e.topLeftCells.columns.length-1)]):new RowRange(e,[]),i),this._rowHeader=new PanelSectionRenderer(this,e.rowHeaders,this.showRowHeader?r.clone(0,e.rowHeaders.columns.length-1):new RowRange(e,[]),i),this._columnHeader=new PanelSectionRenderer(this,e.columnHeaders,this.showColumnHeader?new RowRange(e,[new wjcGrid.CellRange(0,r.leftCol,e.columnHeaders.rows.length-1,r.rightCol)]):new RowRange(e,[]),i),this._cells=new PanelSectionRenderer(this,e.cells,r,i),this._bottomLeft=new PanelSectionRenderer(this,e.bottomLeftCells,this.showRowHeader&&this.showColumnFooter?new RowRange(e,[new wjcGrid.CellRange(0,0,e.bottomLeftCells.rows.length-1,e.bottomLeftCells.columns.length-1)]):new RowRange(e,[]),i),this._columnFooter=new PanelSectionRenderer(this,e.columnFooters,this.showColumnFooter?new RowRange(e,[new wjcGrid.CellRange(0,r.leftCol,e.columnFooters.rows.length-1,r.rightCol)]):new RowRange(e,[]),i)}get settings(){return this._settings}render(e){var t=Math.max(0,Math.max(this._topLeft.renderSize.width,this._rowHeader.renderSize.width)-this._borderWidth),r=Math.max(0,Math.max(this._topLeft.renderSize.height,this._columnHeader.renderSize.height)-this._borderWidth);this._topLeft.render(e,0,0),this._rowHeader.render(e,0,r),this._columnHeader.render(e,t,0),this._cells.render(e,t,r),r=Math.max(0,r+this._cells.renderSize.height-this._borderWidth),this._bottomLeft.render(e,0,r),this._columnFooter.render(e,t,r)}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.headersVisibility&wjcGrid.HeadersVisibility.Column)}get showRowHeader(){return!!(this._flex.headersVisibility&wjcGrid.HeadersVisibility.Row)}get showColumnFooter(){return this._lastPage&&this._flex.columnFooters.rows.length>0}alignMergedTextToTheTopRow(e){return!1}getCellValue(e,t,r){return e.getCellData(r,t,!0)}getColumn(e,t,r){return e.columns[t]}isAlternatingRow(e){return e.index%2!=0}isGroupRow(e){return e instanceof wjcGrid.GroupRow&&e.hasChildren}isMergeableCell(e,t){return!0}getCellStyle(e,t,r){var i=this.settings.styles,o=_merge({},i.cellStyle),l=this._flex;switch(e.cellType){case wjcGrid.CellType.Cell:this.isGroupRow(t)?_merge(o,i.groupCellStyle,!0):this.isAlternatingRow(t)&&_merge(o,i.altCellStyle,!0);break;case wjcGrid.CellType.ColumnHeader:case wjcGrid.CellType.RowHeader:case wjcGrid.CellType.TopLeft:case wjcGrid.CellType.BottomLeft:_merge(o,i.headerCellStyle,!0);break;case wjcGrid.CellType.ColumnFooter:_merge(o,i.headerCellStyle,!0),_merge(o,i.footerCellStyle,!0)}return!this.settings.customCellContent&&l._getShowErrors()&&l._getError(e,t.index,r.index)&&_merge(o,i.errorCellStyle,!0),o}}class FlexSheetRenderer extends FlexGridRenderer{constructor(e,t,r,i,o){super(e,t,r,i,o)}getCellValue(e,t,r){return e.cellType===wjcGrid.CellType.Cell?e.rows[r]instanceof tryGetModuleWijmoGridSheet().HeaderRow?this.flex.columnHeaders.getCellData(r,t,!0):this.flex.getCellValue(r,t,!0):super.getCellValue(e,t,r)}getCellStyle(e,t,r){var i=super.getCellStyle(e,t,r),o=this.flex.selectedSheet.findTable(t.index,r.index);if(o){var l=o.getRange(),n=t.index-l.topRow,s=r.index-l.leftCol,a=o._getTableCellAppliedStyles(n,s);a&&(a.font=new wjcPdf.PdfFont(a.fontFamily,wjcPdf._asPt(a.fontSize,!0,void 0),a.fontStyle,a.fontWeight)),_merge(i,a,!0)}return i}get showColumnHeader(){return!1}get showRowHeader(){return!1}get showColumnFooter(){return!1}}class MultiRowRenderer extends FlexGridRenderer{constructor(e,t,r,i,o){super(e,t,r,i,o)}getColumn(e,t,r){return this.flex.getBindingColumn(e,r,t)}isAlternatingRow(e){return e instanceof tryGetModuleWijmoGridMultirow()._MultiRow?e.dataIndex%2!=0:super.isAlternatingRow(e)}isMergeableCell(e,t){return!0}}class PivotGridRenderer extends FlexGridRenderer{constructor(e,t,r,i,o){super(e,t,r,i,o)}alignMergedTextToTheTopRow(e){return!this.flex.centerHeadersVertically&&(e.cellType===wjcGrid.CellType.ColumnHeader||e.cellType===wjcGrid.CellType.RowHeader)}}class PanelSection{static isRenderableRow(e){return e.isVisible&&!(e instanceof wjcGrid._NewRowTemplate)}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 PanelSection.isRenderableRow(e)}}class PanelSectionRenderer extends PanelSection{constructor(e,t,r,i){super(t,r),this._gr=e,this._borderWidth=i}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,i=0,o=this.panel,l=e;l<=t;l++){var n=o.columns[l];n.isVisible&&(i++,r+=n.renderWidth)}return r=wjcPdf.pxToPt(r),i>1&&(r-=this._borderWidth*(i-1)),r}getRangeHeight(e,t){for(var r=0,i=0,o=this.panel,l=e;l<=t;l++){var n=o.rows[l];this.isRenderableRow(n)&&(i++,r+=n.renderHeight)}return r=wjcPdf.pxToPt(r),i>1&&(r-=this._borderWidth*(i-1)),r}render(e,t,r){var i=this.range,o=this.panel,l=new GetMergedRangeProxy(this._gr.flex),n=new CellRangeExt(o,0,0,0,0),s=new CellRenderer(this,e,this._borderWidth);if(i.isValid){for(var a={},d=i.leftCol;d<=i.rightCol;d++)a[d]=r;i.forEach(o,(e,r,d)=>{if(this.isRenderableRow(e))for(var h=t,c=i.leftCol;c<=i.rightCol;c++){var g,w=this.gr.getColumn(o,c,d),u=void 0,f=void 0,p=!1,m=void 0;if(w.isVisible){var C=this._getCellValue(c,d),R=null;if(this.gr.isMergeableCell(w,e)&&(R=l.getMergedRange(o,d,c)))if(n.copyFrom(R),R.topRow!==R.bottomRow)R.firstVisibleRow===d||d===r.topRow?(p=!0,g=this.gr.settings.repeatMergedValuesAcrossPages?C:R.firstVisibleRow===d?C:"",u=this.getRangeHeight(d,Math.min(R.bottomRow,r.bottomRow)),f=this.getRangeWidth(c,c)):f=this.getRangeWidth(c,c);else{p=!0,g=this.gr.settings.repeatMergedValuesAcrossPages?C:c===R.leftCol?C:"",u=this.getRangeHeight(d,d),f=this.getRangeWidth(Math.max(i.leftCol,R.leftCol),Math.min(i.rightCol,R.rightCol)),m=Math.min(i.rightCol,R.rightCol);for(var _=c+1;_<=m;_++)a[_]+=u-this._borderWidth}else n.setRange(d,c,d,c),p=!0,g=C,u=this.getRangeHeight(d,d),f=this.getRangeWidth(c,c);p&&s.renderCell(g,e,w,n,new wjcCore.Rect(h,a[c],f,u)),u&&(a[c]+=u-this._borderWidth),f&&(h+=f-this._borderWidth),m&&(c=m)}}})}}_getCellValue(e,t){var r=this.panel,i=this.gr.getCellValue(r,e,t),o=r.columns[e].isContentHtml;if(!i&&r.cellType===wjcGrid.CellType.Cell){var l=r.rows[t];l instanceof wjcGrid.GroupRow&&l.dataItem&&l.dataItem.groupDescription&&e===r.columns.firstVisibleIndex&&(o=!0,i=l.getGroupHeader())}return o&&(this._cvtHtml||(this._cvtHtml=document.createElement("div")),this._cvtHtml.innerHTML=i,i=this._cvtHtml.textContent),i}}class CellRenderer{constructor(e,t,r){this._pr=e,this._area=t,this._borderWidth=r}renderCell(e,t,r,i,o){var l,n=t.grid,s=this._pr.panel,a=()=>{var e=i.topRow,t=i.leftCol,r=s.getCellElement(e,t);return r||(globCell.innerHTML="",globCell.className="",globCell.style.cssText="",globCell.style.visibility="hidden",n.cellFactory.updateCell(s,e,t,globCell)),r||globCell},d=!!this._pr.gr.settings.customCellContent,h=null,c=this._pr.gr.getCellStyle(s,t,r);if(d&&(h=a()),d&&!(e=h.textContent.trim())&&this._isBooleanCell(r,t,s)&&(e=this._extractCheckboxValue(h)+""),d){var g=(e=>(e.className=e.className.replace("wj-state-selected",""),e.className=e.className.replace("wj-state-multi-selected",""),window.getComputedStyle(e)))(h);c.color=g.color,c.backgroundColor=g.backgroundColor,c.borderColor=g.borderColor||g.borderRightColor||g.borderBottomColor||g.borderLeftColor||g.borderTopColor,c.font=new wjcPdf.PdfFont(g.fontFamily,wjcPdf._asPt(g.fontSize,!0,void 0),g.fontStyle,g.fontWeight),c.textAlign=g.textAlign}if(c.boxSizing="border-box",c.borderWidth=this._borderWidth,c.borderStyle="solid",c.textAlign||t instanceof wjcGrid.GroupRow&&!r.aggregate||(c.textAlign=r.getAlignment()),s.cellType===wjcGrid.CellType.Cell&&n.rows.maxGroupLevel>=0&&i.leftCol===n.columns.firstVisibleIndex){var w=t instanceof wjcGrid.GroupRow?Math.max(t.level,0):n.rows.maxGroupLevel+1,u=wjcPdf._asPt(c.paddingLeft||c.padding),f=wjcPdf.pxToPt(w*n.treeIndent);c.paddingLeft=u+f}var p,m=this._measureCell(e,r,t,s,c,o),C=i.rowSpan>1&&i.visibleRowsCount>1&&this._pr.gr.alignMergedTextToTheTopRow(s);C&&(p=new wjcCore.Rect(m.contentRect.left,m.contentRect.top,m.contentRect.width,m.contentRect.height/(i.visibleRowsCount||1)),m.textRect=this._calculateTextRect(e,r,t,s,p,c)),wjcCore.isFunction(this._pr.gr.settings.formatItem)&&((l=new PdfFormatItemEventArgs(s,i,h,this._area,m.rect,m.contentRect,m.textRect.top,c,()=>h||a())).data=e,this._pr.gr.settings.formatItem(l),l.data!==e&&(e=wjcCore.asString(l.data),m.textRect=this._calculateTextRect(e,r,t,s,C?p:m.contentRect,c))),this._renderCell(e,t,r,i,m,c,!l||!l.cancel,!l||!l.cancelBorders)}_renderCell(e,t,r,i,o,l,n,s){(n||s)&&(this._isBooleanCellAndValue(e,r,t,this._pr.panel)?this._renderBooleanCell(e,o,l,n,s):this._renderTextCell(e,o,l,n,s))}_isBooleanCellAndValue(e,t,r,i){return this._isBooleanCell(t,r,i)&&this._isBoolean(e)}_isBooleanCell(e,t,r){return e.dataType===wjcCore.DataType.Boolean&&r.cellType===wjcGrid.CellType.Cell&&!this._pr.gr.isGroupRow(t)}_isBoolean(e){var t=wjcCore.isString(e)&&e.toLowerCase();return"true"===t||"false"===t||!0===e||!1===e}_measureCell(e,t,r,i,o,l){this._decompositeStyle(o);var n=l.left,s=l.top,a=l.height,d=l.width,h=this._parseBorder(o),c=h.left.width,g=h.top.width,w=h.bottom.width,u=h.right.width,f=this._parsePadding(o),p=0,m=0,C=0,R=0;if("content-box"===o.boxSizing||void 0===o.boxSizing)p=f.top+a+f.bottom,m=f.left+d+f.right,C=a,R=d;else{if("border-box"!==o.boxSizing)throw"Invalid value: "+o.boxSizing;wjcPdf._IE&&o instanceof CSSStyleDeclaration?(p=f.top+f.bottom+a,m=f.left+f.right+d):(p=a-g-w,m=d-c-u),C=p-f.top-f.bottom,R=m-f.left-f.right}var l=new wjcCore.Rect(n,s,d,a),_=new wjcCore.Rect(n+c,s+g,m,p),b=new wjcCore.Rect(n+c+f.left,s+g+f.top,R,C);return{rect:l,clientRect:_,contentRect:b,textRect:this._calculateTextRect(e,t,r,i,b,o)}}_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,i){var o=e.rect.left,l=e.rect.top,n=e.clientRect.width,s=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),c=e.rect.left+e.rect.width-(e.clientRect.left+e.clientRect.width);if(i&&(a||c||h||d)){var g=t.borderLeftColor||t.borderColor,w=t.borderRightColor||t.borderColor,u=t.borderTopColor||t.borderColor,f=t.borderBottomColor||t.borderColor;if(a&&d&&h&&c&&a===c&&a===h&&a===d&&g===w&&g===f&&g===u){var p=a,m=p/2;this._area.paths.rect(o+m,l+m,n+p,s+p).stroke(new wjcPdf.PdfPen(g,p))}else a&&this._area.paths.polygon([[o,l],[o+a,l+d],[o+a,l+d+s],[o,l+d+s+h]]).fill(g),d&&this._area.paths.polygon([[o,l],[o+a,l+d],[o+a+n,l+d],[o+a+n+c,l]]).fill(u),c&&this._area.paths.polygon([[o+a+n+c,l],[o+a+n,l+d],[o+a+n,l+d+s],[o+a+n+c,l+d+s+h]]).fill(w),h&&this._area.paths.polygon([[o,l+d+s+h],[o+a,l+d+s],[o+a+n,l+d+s],[o+a+n+c,l+d+s+h]]).fill(f)}r&&t.backgroundColor&&n>0&&s>0&&this._area.paths.rect(o+a,l+d,n,s).fill(t.backgroundColor)}_renderBooleanCell(e,t,r,i,o){if(this._renderEmptyCell(t,r,i,o),i){var l=t.textRect.left,n=t.textRect.top,s=t.textRect.height;if(this._area.paths.rect(l,n,s,s).fillAndStroke(wjcCore.Color.fromRgba(255,255,255),new wjcPdf.PdfPen(void 0,.5)),!0===wjcCore.changeType(e,wjcCore.DataType.Boolean,"")){var a=s/20,d=s-.5-2*a,h=s/8;this._area.document.saveState(),this._area.translate(l+.25+a,n+.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,i,o){this._renderEmptyCell(t,r,i,o),i&&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,i,o,l){var n=o.clone();if(this._isBooleanCellAndValue(e,t,r,i)){var s=this._getTextLineHeight(l.font);switch(l.verticalAlign){case"middle":n.top=o.top+o.height/2-s/2;break;case"bottom":n.top=o.top+o.height-s}switch(l.textAlign){case"justify":case"center":n.left=o.left+o.width/2-s/2;break;case"right":n.left=o.left+o.width-s}n.height=n.width=s}else if(n.height>0&&n.width>0){switch(l.verticalAlign){case"bottom":(a=this._area.measureText(e,l.font,{height:n.height,width:n.width})).size.height<n.height&&(n.top+=n.height-a.size.height,n.height=a.size.height);break;case"middle":var a=this._area.measureText(e,l.font,{height:n.height,width:n.width});a.size.height<n.height&&(n.top+=n.height/2-a.size.height/2,n.height=a.size.height)}t.wordWrap||(n.height=this._getTextLineHeight(l.font))}return n}_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 i=this._columns[r];if(i&&t>=i.topRow&&t<=i.bottomRow)return i;var o=this._flex.getMergedRange(e,t,r,!1);return this._columns[r]=o?new CellRangeExt(e,o):null}}class CellRangeExt extends wjcGrid.CellRange{constructor(e,t,r,i,o){t instanceof wjcGrid.CellRange?super(t.row,t.col,t.row2,t.col2):super(t,r,i,o),this.firstVisibleRow=-1,this.visibleRowsCount=0;var l=this.topRow,n=this.bottomRow,s=e.rows.length;if(s>0)for(var a=l;a<=n&&a<s;a++)e.rows[a].isVisible&&(this.firstVisibleRow<0&&(this.firstVisibleRow=a),this.visibleRowsCount++)}copyFrom(e){this.setRange(e.row,e.col,e.row2,e.col2),this.firstVisibleRow=e.firstVisibleRow,this.visibleRowsCount=e.visibleRowsCount}}class RowRange{static getSelection(e,t){var r=[];if(t===ExportMode.All)r.push(new wjcGrid.CellRange(0,0,e.rows.length-1,e.columns.length-1));else{var i=e.selection;switch(e.selectionMode){case wjcGrid.SelectionMode.None:break;case wjcGrid.SelectionMode.Cell:case wjcGrid.SelectionMode.CellRange:r.push(i);break;case wjcGrid.SelectionMode.Row:r.push(new wjcGrid.CellRange(i.topRow,0,i.topRow,e.cells.columns.length-1));break;case wjcGrid.SelectionMode.RowRange:r.push(new wjcGrid.CellRange(i.topRow,0,i.bottomRow,e.cells.columns.length-1));break;case wjcGrid.SelectionMode.ListBox:for(var o=-1,l=0;l<e.rows.length;l++)e.rows[l].isSelected?(o<0&&(o=l),l===e.rows.length-1&&r.push(new wjcGrid.CellRange(o,0,l,e.cells.columns.length-1))):(o>=0&&r.push(new wjcGrid.CellRange(o,0,l-1,e.cells.columns.length-1)),o=-1)}}return new RowRange(e,r)}constructor(e,t){this._flex=e,this._ranges=t||[]}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=[],i=0;i<this._ranges.length;i++){var o=this._ranges[i].clone();arguments.length>0&&(o.col=e),arguments.length>1&&(o.col2=t),r.push(o)}return new RowRange(this._flex,r)}getRenderSize(e){for(var t=new wjcCore.Size(0,0),r=0;r<this._ranges.length;r++){var i=this._ranges[r].getRenderSize(e);t.width=Math.max(t.width,i.width),t.height+=i.height}return t}forEach(e,t){for(var r=0,i=0;i<this._ranges.length;i++){var o=this._ranges[i];if(o.isValid)for(var l=o.topRow;l<=o.bottomRow;l++)t(e.rows[l],o,l,r++)}}subrange(e,t,r,i){var o=[];if(e>=0&&t>0)for(var l=0,n=0,s=0;s<this._ranges.length&&t>0;s++,l=n+1){var a=this._ranges[s];if(n=l+(a.bottomRow-a.topRow),!(e>n)){var d=e>l?a.topRow+(e-l):a.topRow,h=Math.min(a.bottomRow,d+t-1),c=arguments.length>2?r:a.leftCol,g=arguments.length>2?i:a.rightCol;o.push(new wjcGrid.CellRange(d,c,h,g)),t-=h-d+1}}return new RowRange(this._flex,o)}}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}}