/*
    *
    * 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 tryGetModuleWijmoGridDetail(){var e,o;return(e=__glob.wijmo)&&(o=e.grid)&&o.detail}function tryGetModuleWijmoGridMultirow(){var e,o;return(e=__glob.wijmo)&&(o=e.grid)&&o.multirow}var __extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var l in o)o.hasOwnProperty(l)&&(e[l]=o[l])};return function(o,l){function r(){this.constructor=o}e(o,l),o.prototype=null===l?Object.create(l):(r.prototype=l.prototype,new r)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wjcGrid=require("wijmo/wijmo.grid"),wjcXlsx=require("wijmo/wijmo.xlsx"),wjcCore=require("wijmo/wijmo"),__glob="undefined"!=typeof window?window:self,wjcSelfRef=require("wijmo/wijmo.grid.xlsx"),wjcSelf=wjcSelfRef||exports;__glob.wijmo=__glob.wijmo||{},__glob.wijmo.grid=__glob.wijmo.grid||{},__glob.wijmo.grid.xlsx=wjcSelf;var FlexGridXlsxConverter=function(){function e(){}return e.save=function(e,o,l){var r=this._saveFlexGridToWorkbook(e,o);return l&&r.save(l),r},e.saveAsync=function(e,o,l,r,t){var n=this._saveFlexGridToWorkbook(e,o);return l&&n.saveAsync(l,r,t),n},e.load=function(e,o,l){var r=this;if(o instanceof Blob){var t=new FileReader;t.onload=function(){var o=wjcXlsx.Workbook._base64EncArr(new Uint8Array(t.result)),n=new wjcXlsx.Workbook;n.load(o),o=null,e.deferUpdate(function(){r._loadToFlexGrid(e,n,l),n=null})},t.readAsArrayBuffer(o)}else if(o instanceof wjcXlsx.Workbook)e.deferUpdate(function(){r._loadToFlexGrid(e,o,l),o=null});else{if(o instanceof ArrayBuffer)o=wjcXlsx.Workbook._base64EncArr(new Uint8Array(o));else if(!wjcCore.isString(o))throw"Invalid workbook.";var n=new wjcXlsx.Workbook;n.load(o),o=null,e.deferUpdate(function(){r._loadToFlexGrid(e,n,l),n=null})}},e.loadAsync=function(e,o,l,r,t){var n=this;if(o instanceof Blob){var s=new FileReader;s.onload=function(){var o=wjcXlsx.Workbook._base64EncArr(new Uint8Array(s.result)),i=new wjcXlsx.Workbook;i.loadAsync(o,function(t){o=null,i=null,e.deferUpdate(function(){n._loadToFlexGrid(e,t,l),r&&r(t),t=null})},t)},s.readAsArrayBuffer(o)}else if(o instanceof wjcXlsx.Workbook)e.deferUpdate(function(){n._loadToFlexGrid(e,o,l),r&&r(o),o=null});else{if(o instanceof ArrayBuffer)o=wjcXlsx.Workbook._base64EncArr(new Uint8Array(o));else if(!wjcCore.isString(o))throw"Invalid workbook.";(new wjcXlsx.Workbook).loadAsync(o,function(t){o=null,e.deferUpdate(function(){n._loadToFlexGrid(e,t,l),r&&r(t),t=null})},t)}},e._saveFlexGridToWorkbook=function(e,o){var l,r,t,n,s,i,a,c,d,u,w,f,h,p=new wjcXlsx.Workbook,m=new wjcXlsx.WorkSheet,g=(new wjcXlsx.WorkbookStyle,new wjcXlsx.WorkbookFrozenPane),x=!o||null==o.includeColumnHeaders||o.includeColumnHeaders,y=!(!o||null==o.includeRowHeaders)&&o.includeRowHeaders,b=!o||null==o.includeCellStyles||o.includeCellStyles,_=o?o.activeWorksheet:null,j=o?o.includeColumns:null,C=o?o.formatItem:null,v=0,k=0,S=0,W=0,T=[];if(null==this.hasCssText&&(this.hasCssText="cssText"in document.body.style),u=e.wj_sheetInfo,m.name=o?o.sheetName:"",m.visible=!o||!1!==o.sheetVisible,u&&u.tables&&u.tables.length>0)for(var R=0;R<u.tables.length;R++)m.tables.push(u.tables[R]);if(i=[],u||!b&&!C||((w=document.createElement("div")).style.visibility="hidden",w.setAttribute(wjcGrid.FlexGrid._WJS_MEASURE,"true"),e.hostElement.appendChild(w)),y){for(c=0,a=0;a<e.rowHeaders.rows.length;a++)if(!(e.rowHeaders.rows[a].renderSize<=0)){for(i[c]=[],d=0;d<e.rowHeaders.columns.length;d++)t=e._getBindingColumn(e.rowHeaders,a,e.rowHeaders.columns[d]),n=this._getColumnSetting(t,d,e.columnHeaders.columns),i[c][d]=n,0===c&&((s=new wjcXlsx.WorkbookColumn)._deserialize(n),m._addWorkbookColumn(s,d));c++}W=d}if(e.columnHeaders.rows.length>0){for(c=0,a=0;a<e.columnHeaders.rows.length;a++)if(!(e.columnHeaders.rows[a].renderSize<=0)){for(i[c]||(i[c]=[]),d=0;d<e.columnHeaders.columns.length;d++)t=e._getBindingColumn(e.columnHeaders,a,e.columnHeaders.columns[d]),n=this._getColumnSetting(t,d,e.columnHeaders.columns),i[c][W+d]=n,0===c&&(j&&!j(t)||((s=new wjcXlsx.WorkbookColumn)._deserialize(n),m._addWorkbookColumn(s)));x&&(W=0,l={},r=new wjcXlsx.WorkbookRow,y&&(W=this._parseFlexGridRowToSheetRow(e.topLeftCells,l,a,0,i,b,w,T,!1,0,j,C)),this._parseFlexGridRowToSheetRow(e.columnHeaders,l,a,W,i,b,w,T,!1,0,j,C),l.cells.length>0&&(r._deserialize(l),m._addWorkbookRow(r,c))),c++}k=x?c:0}for(a=0;a<e.cells.rows.length;a++)W=0,l={},r=new wjcXlsx.WorkbookRow,(f=e.rows[a])instanceof wjcGrid._NewRowTemplate||((h=f instanceof wjcGrid.GroupRow)?v=wjcCore.tryCast(f,wjcGrid.GroupRow).level:e.rows.maxGroupLevel>-1&&(v=e.rows.maxGroupLevel+1),y&&(W=this._parseFlexGridRowToSheetRow(e.rowHeaders,l,a,0,i,b,w,T,h,v,j,C)),this._parseFlexGridRowToSheetRow(e.cells,l,a,W,i,b,w,T,h,v,j,C),l.cells.length>0&&(r._deserialize(l),m._addWorkbookRow(r,k+a)));for(S=e.cells.rows.length,a=0;a<e.columnFooters.rows.length;a++)W=0,l={},r=new wjcXlsx.WorkbookRow,h=(f=e.columnFooters.rows[a])instanceof wjcGrid.GroupRow,y&&(W=this._parseFlexGridRowToSheetRow(e.rowHeaders,l,a,0,i,b,w,T,h,0,j,C)),this._parseFlexGridRowToSheetRow(e.columnFooters,l,a,W,i,b,w,T,h,0,j,C),l.cells.length>0&&(r._deserialize(l),m._addWorkbookRow(r,k+S+a));return g.rows=x?e.frozenRows+k:e.frozenRows,g.columns=y?e.frozenColumns+W:e.frozenColumns,m.frozenPane=g,p._addWorkSheet(m),u||!b&&!C||(e.hostElement.removeChild(w),T.forEach(function(e){return e.forEach(function(e){e&&e.parentElement&&e.parentElement.removeChild(e)})})),p.activeWorksheet=_,p},e._loadToFlexGrid=function(e,o,l){var r,t,n,s,i,a,c,d,u,w,f,h,p,m,g,x,y,b,_,j,C,v,k,S,W,T,R,X,G,A,F,D,B=!l||null==l.includeColumnHeaders||l.includeColumnHeaders,H=!l||null==l.includeColumnHeaders||l.includeColumnHeaders,N=l&&null!=l.sheetIndex&&!isNaN(l.sheetIndex)?l.sheetIndex:0,E=l?l.sheetName:null,I=!l||l.sheetVisible,M=null!=e.wj_sheetInfo,z=0,O=0,L=!1,P={};if(e.itemsSource=null,e.columns.clear(),e.rows.clear(),e.frozenColumns=0,e.frozenRows=0,T={},R=[],O=0,n=[],X=[],N<0||N>=o.sheets.length)throw"The sheet index option is out of the sheet range of current workbook.";if(null!=E)for(r=0;r<o.sheets.length;r++)if(E===o.sheets[r].name){f=o.sheets[r];break}if(null!=(f=f||o.sheets[N]).rows){for(B&&(O=1,f.rows.length<=1&&(H=!1,O=0),c=f.rows[0]),p=this._getColumnCount(f.rows),h=this._getRowCount(f.rows,p),b=f.summaryBelow,t=f.columns,z=0;z<p;z++)e.columns.push(new wjcGrid.Column),t[z]&&(isNaN(+t[z].width)||(e.columns[z].width=+t[z].width),t[z].visible||null==t[z].visible||(e.columns[z].visible=!!t[z].visible),t[z].style&&t[z].style.wordWrap&&(e.columns[z].wordWrap=t[z].style.wordWrap));for(;O<h;O++){if(m=!1,D=null,w=f.rows[O])for(x=O+1;x<f.rows.length;){if(y=f.rows[x]){(isNaN(w.groupLevel)&&!isNaN(y.groupLevel)||!isNaN(w.groupLevel)&&w.groupLevel<y.groupLevel)&&(m=!0);break}x++}for(m&&!b?(j&&(j.isCollapsed=L),(j=new wjcGrid.GroupRow).isReadOnly=!1,L=null!=w.collapsed&&w.collapsed,j.level=isNaN(w.groupLevel)?0:w.groupLevel,P[j.level]=L,this._checkParentCollapsed(P,j.level)&&j._setFlag(wjcGrid.RowColFlags.ParentCollapsed,!0),e.rows.push(j)):(_=new wjcGrid.Row,w&&this._checkParentCollapsed(P,w.groupLevel)&&_._setFlag(wjcGrid.RowColFlags.ParentCollapsed,!0),e.rows.push(_)),w&&w.height&&!isNaN(w.height)&&(e.rows[H?O-1:O].height=w.height),z=0;z<p;z++)if(w){if(g=w.cells[z],(k=g?g.formula:null)&&"="!==k[0]&&(k="="+k),g&&g.textRuns&&g.textRuns.length>0?(e.rows[H?O-1:O].isContentHtml=!0,e.setCellData(H?O-1:O,z,this._parseTextRunsToHTML(g.textRuns))):e.setCellData(H?O-1:O,z,k&&M?k:this._getItemValue(g)),m||this._setColumn(n,z,g),S=O*p+z,W=g?g.style:null,G=wjcXlsx.Workbook._parseExcelFormat(g),W){if(D=null==D?!!W.wordWrap:D&&!!W.wordWrap,A=this._getItemType(g),W.hAlign)F=wjcXlsx.Workbook._parseHAlignToString(wjcCore.asEnum(W.hAlign,wjcXlsx.HAlign));else switch(A){case wjcCore.DataType.Number:F="right";break;case wjcCore.DataType.Boolean:F="center";break;default:F=G&&0===G.search(/[n,c,p]/i)?"right":"left"}T[S]={fontWeight:W.font&&W.font.bold?"bold":"none",fontStyle:W.font&&W.font.italic?"italic":"none",textDecoration:W.font&&W.font.underline?"underline":"none",textAlign:F,fontFamily:W.font&&W.font.family?W.font.family:"",fontSize:W.font&&W.font.size?W.font.size+"px":"",color:W.font&&W.font.color?W.font.color:"",backgroundColor:W.fill&&W.fill.color?W.fill.color:"",whiteSpace:W.wordWrap?"pre-wrap":"normal",format:G},W.borders&&(W.borders.left&&(this._parseBorderStyle(W.borders.left.style,"Left",T[S]),T[S].borderLeftColor=W.borders.left.color),W.borders.right&&(this._parseBorderStyle(W.borders.right.style,"Right",T[S]),T[S].borderRightColor=W.borders.right.color),W.borders.top&&(this._parseBorderStyle(W.borders.top.style,"Top",T[S]),T[S].borderTopColor=W.borders.top.color),W.borders.bottom&&(this._parseBorderStyle(W.borders.bottom.style,"Bottom",T[S]),T[S].borderBottomColor=W.borders.bottom.color)),W.font&&-1===X.indexOf(W.font.family)&&X.push(W.font.family)}g&&wjcCore.isNumber(g.rowSpan)&&g.rowSpan>0&&wjcCore.isNumber(g.colSpan)&&g.colSpan>0&&(g.rowSpan>1||g.colSpan>1)&&R.push(new wjcGrid.CellRange(O,z,O+g.rowSpan-1,z+g.colSpan-1))}w&&(this._checkParentCollapsed(P,w.groupLevel)||w.visible||null==w.visible||(e.rows[H?O-1:O].visible=w.visible),e.rows[H?O-1:O].wordWrap=!!w.style&&!!w.style.wordWrap||!!D)}for(j&&(j.isCollapsed=L),f.frozenPane&&(C=f.frozenPane.columns,wjcCore.isNumber(C)&&!isNaN(C)&&(e.frozenColumns=C),v=f.frozenPane.rows,wjcCore.isNumber(v)&&!isNaN(v)&&(e.frozenRows=H&&v>0?v-1:v)),z=0;z<e.columnHeaders.columns.length;z++)s=n[z],(i=e.columns[z]).isRequired=!1,H&&((d=c?c.cells[z]:null)&&d.value?(u=wjcXlsx.Workbook._parseExcelFormat(d),a=wjcCore.Globalize.format(d.value,u)):a=""),i.header=a,s&&(s.dataType===wjcCore.DataType.Boolean&&(i.dataType=s.dataType),i.format=s.format,i.align=s.hAlign,i.wordWrap=i.wordWrap||!!s.wordWrap);M&&(e.wj_sheetInfo.name=f.name,e.wj_sheetInfo.visible=!0===I||!1!==f.visible,e.wj_sheetInfo.styledCells=T,e.wj_sheetInfo.mergedRanges=R,e.wj_sheetInfo.fonts=X,e.wj_sheetInfo.tables=f.tables)}},e._parseFlexGridRowToSheetRow=function(e,o,l,r,t,n,s,i,a,c,d,u){var w,f,h,p,m,g,x,y,b,_,j,C,v,k,S,W,T,R,X,G,A,F,D,B,H,N,E,I,M,z,O=!1,L=!1;for((X=(w=e.grid).wj_sheetInfo)&&(G=X.evaluateFormula),null==(f=e.rows[l]).recordIndex?(B=0,e.cellType===wjcGrid.CellType.ColumnHeader&&e.rows.length>1&&(B=l===t.length?l-1:l)):B=f.recordIndex,o.cells||(o.cells=[]),o.visible=f.isVisible,o.height=f.renderHeight||e.rows.defaultSize,o.groupLevel=c,a&&(o.collapsed=f.isCollapsed),f.wordWrap&&(o.style={wordWrap:f.wordWrap}),(f.constructor===wjcGrid.Row||f.constructor===wjcGrid._NewRowTemplate||tryGetModuleWijmoGridDetail()&&f.constructor===tryGetModuleWijmoGridDetail().DetailRow||tryGetModuleWijmoGridMultirow()&&f.constructor===tryGetModuleWijmoGridMultirow()._MultiRow)&&(O=!0),tryGetModuleWijmoGridDetail()&&f.constructor===tryGetModuleWijmoGridDetail().DetailRow&&(L=!0),p=0;p<e.columns.length;p++)if(m=null,R=1,T=1,M=0,D=!1,S=null,E=null,N=null,y=null,F=w._getBindingColumn(e,l,e.columns[p]),W=null,X&&e===w.cells?(k=l*e.columns.length+p,X.mergedRanges&&(W=this._getMergedRange(l,p,X.mergedRanges)),X.styledCells&&(S=X.styledCells[k])):n&&(N=this._getMeasureCell(e,p,s,i),S=(W=w.getMergedRange(e,l,p,!1))?this._getCellStyle(e,N,W.bottomRow,W.rightCol)||{}:this._getCellStyle(e,N,l,p)||{}),W||(W=w.getMergedRange(e,l,p,!1)),W?l===W.topRow&&p===W.leftCol&&(T=W.bottomRow-W.topRow+1,R=this._getColSpan(e,W,d),D=!0):D=!0,!d||d(F)){if(h=t[B]?t[B][p+r]:null,O||a?(x=D?e.getCellData(l,p,!0):null,b=D?e.getCellData(l,p,!1):null,j=!1,v=null,x&&wjcCore.isString(x)&&x.length>1&&"="===x[0]&&(j=!0),A=wjcCore.isDate(b),S&&S.format?(m=S.format,/[hsmyt\:]/i.test(m)&&(A=!0),g=wjcXlsx.Workbook._parseCellFormat(S.format,A)):h&&h.style&&h.style.format?(m=F.format,g=h.style.format):g=null,j&&null!=G&&wjcCore.isFunction(G)&&(v=G(x)),g||(A?g="m/d/yyyy":wjcCore.isNumber(b)&&!F.dataMap?g=wjcCore.isInt(b)?"#,##0":"#,##0.00":j?(C=x.toLowerCase()).indexOf("now()")>-1?(g="m/d/yyyy h:mm",A=!0):C.indexOf("today()")>-1||C.indexOf("date(")>-1?(g="m/d/yyyy",A=!0):C.indexOf("time(")>-1&&(g="h:mm AM/PM",A=!0):g="General")):(x=D?w.columnHeaders.getCellData(0,p,!0):null,g="General"),wjcCore.isString(x)&&-1!==x.indexOf("<span")&&(y=this._parseToTextRuns(x),x=null),E=this._parseCellStyle(S)||{},e===w.cells&&a&&f.hasChildren&&p===w.columns.firstVisibleIndex){if(j&&null!=v?_=v:x?_=x:D&&(_=f.getGroupHeader().replace(/<\/?\w+>/g,"").replace(/&#39;/g,"'")),null==_&&!S)continue;!(A=wjcCore.isDate(_))&&m&&"d"===m.toLowerCase()&&wjcCore.isInt(_)&&(g="0"),_=wjcCore.isString(_)?wjcXlsx.Workbook._unescapeXML(_):_,p===w.columns.firstVisibleIndex&&w.treeIndent&&(M=c),H={value:_,isDate:A,formula:j?this._parseToExcelFormula(x,A):null,colSpan:R,rowSpan:T,style:this._extend(E,{format:g,font:{bold:!0},hAlign:wjcXlsx.HAlign.Left,indent:M}),textRuns:y}}else x=wjcCore.isString(x)?wjcXlsx.Workbook._unescapeXML(x):x,b=wjcCore.isString(b)?wjcXlsx.Workbook._unescapeXML(b):b,!A&&m&&"d"===m.toLowerCase()&&wjcCore.isInt(b)&&(g="0"),I=E&&E.hAlign?E.hAlign:h&&h.style&&null!=h.style.hAlign?wjcCore.asEnum(h.style.hAlign,wjcXlsx.HAlign,!0):wjcCore.isDate(b)?wjcXlsx.HAlign.Left:wjcXlsx.HAlign.General,p!==w.columns.firstVisibleIndex||!w.treeIndent||I!==wjcXlsx.HAlign.Left&&I!==wjcXlsx.HAlign.General||(M=c),H={value:j?v:"General"===g?x:b,isDate:A,formula:j?this._parseToExcelFormula(x,A):null,colSpan:p<w.columns.firstVisibleIndex?1:R,rowSpan:T,style:this._extend(E,{format:g,hAlign:I,vAlign:T>1?e===w.cells||!1===w.centerHeadersVertically?wjcXlsx.VAlign.Top:wjcXlsx.VAlign.Center:null,indent:M}),textRuns:y},L&&(z=e.getCellElement(l,p))&&z.appendChild(f.detail);u&&u(new XlsxFormatItemEventArgs(e,new wjcGrid.CellRange(l,p),N,s,i,H)),o.cells.push(H)}return r+p},e._parseCellStyle=function(e,o){if(void 0===o&&(o=!1),null==e)return null;var l=e.fontSize;l=l?+l.substring(0,l.indexOf("px")):null,isNaN(l)&&(l=null);var r=e.fontWeight;r="bold"===r||+r>=700;var t="italic"===e.fontStyle,n=e.textDecorationStyle;null==n&&(n=e.textDecoration),n="underline"===n;var s=e.whiteSpace;return s=!!s&&s.indexOf("pre")>-1,{font:{bold:r,italic:t,underline:n,family:this._parseToExcelFontFamily(e.fontFamily),size:l,color:e.color},fill:{color:e.backgroundColor},borders:this._parseBorder(e,o),hAlign:wjcXlsx.Workbook._parseStringToHAlign(e.textAlign),wordWrap:s}},e._parseBorder=function(e,o){var l={};return l.left=this._parseEgdeBorder(e,"Left"),l.right=this._parseEgdeBorder(e,"Right"),l.top=this._parseEgdeBorder(e,"Top"),l.bottom=this._parseEgdeBorder(e,"Bottom"),o&&(l.vertical=this._parseEgdeBorder(e,"Vertical"),l.horizontal=this._parseEgdeBorder(e,"Horizontal")),l},e._parseEgdeBorder=function(e,o){var l,r=e["border"+o+"Style"],t=e["border"+o+"Width"];if(t&&t.length>2&&(t=+t.substring(0,t.length-2)),r&&"none"!==r&&"hidden"!==r){switch(l={},r=r.toLowerCase()){case"dotted":l.style=t>1?wjcXlsx.BorderStyle.MediumDashDotted:wjcXlsx.BorderStyle.Dotted;break;case"dashed":l.style=t>1?wjcXlsx.BorderStyle.MediumDashed:wjcXlsx.BorderStyle.Dashed;break;case"double":l.style=wjcXlsx.BorderStyle.Double;break;default:l.style=t>2?wjcXlsx.BorderStyle.Thick:t>1?wjcXlsx.BorderStyle.Medium:wjcXlsx.BorderStyle.Thin}l.color=e["border"+o+"Color"]}return l},e._parseBorderStyle=function(e,o,l){var r="border"+o+"Style",t="border"+o+"Width";switch(e){case wjcXlsx.BorderStyle.Dotted:case wjcXlsx.BorderStyle.Hair:l[r]="dotted",l[t]="1px";break;case wjcXlsx.BorderStyle.Dashed:case wjcXlsx.BorderStyle.ThinDashDotDotted:case wjcXlsx.BorderStyle.ThinDashDotted:l[r]="dashed",l[t]="1px";break;case wjcXlsx.BorderStyle.MediumDashed:case wjcXlsx.BorderStyle.MediumDashDotDotted:case wjcXlsx.BorderStyle.MediumDashDotted:case wjcXlsx.BorderStyle.SlantedMediumDashDotted:l[r]="dashed",l[t]="2px";break;case wjcXlsx.BorderStyle.Double:l[r]="double",l[t]="3px";break;case wjcXlsx.BorderStyle.Medium:l[r]="solid",l[t]="2px";break;default:l[r]="solid",l[t]="1px"}},e._parseToExcelFontFamily=function(e){var o;return e&&(o=e.split(","))&&o.length>0&&(e=o[0].replace(/\"|\'/g,"")),e},e._parseToExcelFormula=function(e,o){var l,r,t,n,s,i,a,c=/(floor|ceiling)\([+-]?\d+\.?\d*\)/gi,d=/text\(\"?\w+\"?\s*\,\s*\"\w+\"\)/gi,u=/\"?\w+\"?\s*\,\s*\"(\w+)\"/i;if(l=e.match(c))for(s=0;s<l.length;s++)a=(i=l[s]).substring(0,i.lastIndexOf(")"))+", 1)",e=e.replace(i,a);if(l=null,l=e.match(d))for(s=0;s<l.length;s++)(r=(i=l[s]).match(u))&&2===r.length&&(t=r[1],/^d{1,4}?$/.test(t)||(n=wjcXlsx.Workbook._parseCellFormat(t,o),a=i.replace(t,n),e=e.replace(i,a)));return e},e._parseToTextRuns=function(e){var o,l,r,t=e.split("<span "),n=[];for(o=0;o<t.length;o++)r=-1!==(l=t[o]).indexOf("</span>")?{text:l.substring(l.indexOf(">")+1,l.indexOf("</span>")),font:this._parseToTextRunFont(l.substring(l.indexOf('style="')+7,l.indexOf(';"')))}:{text:l},n.push(r);return n},e._parseToTextRunFont=function(e){var o,l,r,t,n,s,i,a,c,d=e.split(";");if(d.length>0){for(o=0;o<d.length;o++)if(2===(l=d[o].split(":")).length)switch(l[1]=l[1].trim(),l[0]){case"font-size":s=+l[1].substring(0,l[1].indexOf("px")),isNaN(s)&&(s=null);break;case"font-weight":r="bold"===l[1]||+l[1]>=700;break;case"font-style":t="italic"===l[1];break;case"text-decoration-style":case"text-decoration":n="underline"===l[1];break;case"font-family":i=this._parseToExcelFontFamily(l[1]);break;case"color":a=l[1]}c={bold:r,italic:t,underline:n,family:i,size:s,color:a}}return c},e._getMeasureCell=function(e,o,l,r){var t=r[e.cellType],n=t&&t[o],s=null==n;if(n){if(this.hasCssText){n.style;n.style.cssText="",n.style.visibility="hidden"}}else t||(r[e.cellType]=t=[]),t[o]=n=l.cloneNode();return!s&&n.parentElement||(e.hostElement.children.length>0?e.hostElement.children[0].appendChild(n):e.hostElement.appendChild(n)),n},e._getColumnSetting=function(e,o,l){var r;return r=null!=e.colspan?this._getColumnRenderWidth(o,l):e.renderWidth,r=r||l.defaultSize,{autoWidth:!0,width:r,visible:e.visible,style:{format:e.format?wjcXlsx.Workbook._parseCellFormat(e.format,e.dataType===wjcCore.DataType.Date):"",hAlign:wjcXlsx.Workbook._parseStringToHAlign(this._toExcelHAlign(e.getAlignment())),wordWrap:e.wordWrap}}},e._toExcelHAlign=function(e){return(e=e?e.trim().toLowerCase():e)?e.indexOf("center")>-1?"center":e.indexOf("right")>-1||e.indexOf("end")>-1?"right":e.indexOf("justify")>-1?"justify":"left":e},e._getColumnCount=function(e){for(var o,l=0,r=0,t=0;t<e.length;t++)(o=e[t]&&e[t].cells?e[t].cells:[])&&o.length>0&&(r=o.length,wjcCore.isInt(o[r-1].colSpan)&&o[r-1].colSpan>1&&(r=r+o[r-1].colSpan-1),r>l&&(l=r));return l},e._getRowCount=function(e,o){for(var l,r,t,n=e.length,s=n-1,i=0;i<o;i++)e:for(;s>=0;s--)if(l=e[s],r=l&&l.cells?l.cells:[],(t=r[i])&&(null!=t.value&&""!==t.value||wjcCore.isInt(t.rowSpan)&&t.rowSpan>1)){wjcCore.isInt(t.rowSpan)&&t.rowSpan>1&&s+t.rowSpan>n&&(n=s+t.rowSpan);break e}return n},e._numAlpha=function(e){var o=Math.floor(e/26)-1;return(o>-1?this._numAlpha(o):"")+String.fromCharCode(65+e%26)},e._getItemType=function(e){return null==e||null==e.value||isNaN(e.value)?null:wjcCore.getType(e.value)},e._setColumn=function(e,o,l){var r,t,n,s=e[o];s?(r=this._getItemType(l),s.dataType!==r&&s.dataType===wjcCore.DataType.Boolean&&r!==wjcCore.DataType.Boolean&&(s.dataType=r),!l||null==l.value||wjcCore.isString(l.value)&&wjcCore.isNullOrWhiteSpace(l.value)||(t=wjcXlsx.Workbook._parseExcelFormat(l))&&s.format!==t&&"General"!==t&&(s.format=t),l&&l.style&&(l.style.hAlign&&(n=wjcXlsx.Workbook._parseHAlignToString(wjcCore.asEnum(l.style.hAlign,wjcXlsx.HAlign))),null==s.wordWrap?s.wordWrap=!!l.style.wordWrap:s.wordWrap=s.wordWrap&&!!l.style.wordWrap),n||r!==wjcCore.DataType.Number||(n="right"),s.hAlign=n):e[o]={dataType:this._getItemType(l),format:wjcXlsx.Workbook._parseExcelFormat(l),hAlign:"",wordWrap:null}},e._getItemValue=function(e){if(null==e||null==e.value)return null;var o=e.value;return wjcCore.isNumber(o)&&isNaN(o)?"":o instanceof Date&&isNaN(o.getTime())?"":o},e._getCellStyle=function(e,o,l,r){try{e.grid.cellFactory.updateCell(e,l,r,o),o.className=o.className.replace("wj-state-selected",""),o.className=o.className.replace("wj-state-multi-selected","")}catch(e){return null}return window.getComputedStyle(o)},e._parseTextRunsToHTML=function(e){var o,l,r,t;for(r="",t=0;t<e.length;t++)r+=(l=(o=e[t]).font)?'<span style="'+(l.bold?"font-weight: bold;":"")+(l.italic?"font-style: italic;":"")+(l.underline?"text-decoration: underline;":"")+(l.family?"font-family: "+l.family+";":"")+(null!=l.size?"font-size: "+l.size+"px;":"")+(l.color?"color: "+l.color+";":"")+'">'+o.text+"</span>":o.text;return r},e._extend=function(e,o){for(var l in o){var r=o[l];wjcCore.isObject(r)&&e[l]?wjcCore.copy(e[l],r):e[l]=r}return e},e._checkParentCollapsed=function(e,o){var l=!1;return Object.keys(e).forEach(function(r){!0===e[r]&&!1===l&&!isNaN(o)&&+r<o&&(l=!0)}),l},e._getColSpan=function(e,o,l){for(var r=0,t=o.leftCol;t<=o.rightCol;t++)l&&!l(e.columns[t])||r++;return r},e._getColumnRenderWidth=function(e,o){var l;return e>=o.length?0:null!=(l=o[e]).renderWidth?l.renderWidth:o.defaultSize},e._getMergedRange=function(e,o,l){var r,t;for(r=0;r<l.length;r++)if(t=l[r],e>=t.topRow&&e<=t.bottomRow&&o>=t.leftCol&&o<=t.rightCol)return t;return null},e}();exports.FlexGridXlsxConverter=FlexGridXlsxConverter;var XlsxFormatItemEventArgs=function(e){function o(o,l,r,t,n,s){var i=e.call(this,o,l)||this;return i._cell=r,i._patternCell=t,i._xlsxCell=s,i._cellsCache=n,i}return __extends(o,e),Object.defineProperty(o.prototype,"cell",{get:function(){return this._cell},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"xlsxCell",{get:function(){return this._xlsxCell},set:function(e){this._xlsxCell=e},enumerable:!0,configurable:!0}),o.prototype.getFormattedCell=function(){return this._cell||(this._cell=FlexGridXlsxConverter._getMeasureCell(this.panel,this.col,this._patternCell,this._cellsCache),FlexGridXlsxConverter._getCellStyle(this.panel,this._cell,this.row,this.col)),this._cell},o}(wjcGrid.CellRangeEventArgs);exports.XlsxFormatItemEventArgs=XlsxFormatItemEventArgs;