
/* Smart UI v9.3.56 (2021-05-12) 
Copyright (c) 2011-2021 jQWidgets. 
License: https://htmlelements.com/license/ */ //

Smart.Utilities.Assign("Grid.Export",class{exportData(t,o){const e=this,a=new Smart.Utilities.DataExporter({exportHeader:e.dataExport.header}),r=[];if(a.expandChar=e.dataExport.expandChar,a.collapseChar=e.dataExport.collapseChar,a.pageOrientation=e.dataExport.pageOrientation,a.style=e.dataExport.style,a.filterBy=e.dataExport.filterBy,a.groupBy=e.dataExport.groupBy,a.header={columns:e.columns.toArray().slice(0),columngroups:e.columnGroups.slice(0)},!e.dataExport.style){const o=window.getComputedStyle(e),n=window.getComputedStyle(e.columns.length>0&&e.columns[0].element?e.columns[0].element:e.$.columnHeader),i=window.getComputedStyle(e.$.columnHeader);if(0!==e.offsetWidth&&0!==e.offsetHeight){const l=t=>{const o=t.fontSize,e=t.borderRightColor,a=t.backgroundColor,r=t.color,n=new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");function i(t){return(t=t.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/))?"#"+l(t[1])+l(t[2])+l(t[3]).toUpperCase():"#ffffff"}function l(t){return isNaN(t)?"00":n[(t-t%16)/16]+n[t%16]}return{borderColor:i(e),fontSize:o,fontFamily:"Helvetica",color:i(r),backgroundColor:i(a)}},d=l(o),c=l(n),p=l(i),s={height:e.$.columnHeader.offsetHeight+"px",border:"1px solid "+d.borderColor,fontFamily:p.fontFamily,fontSize:p.fontSize,color:p.color,backgroundColor:c.backgroundColor,fontWeight:"400"},u={border:"1px solid "+d.borderColor,fontFamily:d.fontFamily,fontSize:d.fontSize},f={height:e.rowMinHeight+"px"};for(let o=0;o<e.columns.length;o++){const a=e.columns[o];if(!a.allowExport)continue;if(!a.visible)continue;s[a.dataField]={textAlign:a.align,width:a.computedWidth+"px",format:a.cellsFormat||""};let n=a.cellsFormat||"";"date"===a.dataType?n="d":"dateTime"===a.dataType?n="D":"time"===a.dataType&&(n="t");const i={textAlign:a.cellsAlign,format:n};if(u[a.dataField]=i,e.dataExport.view&&-1!==["html","jpeg","pdf","png"].indexOf(t)&&(a.template||a.formatFunction))for(let t=0;t<e.rows.length;t++){const o=e.rows[t];let n=e.rows[t]["column_"+a.dataField];if(e.dataExport.viewStart&&t<e.dataExport.viewStart||e.dataExport.viewEnd&&t>e.dataExport.viewEnd)continue;if(!n||o&&o.element&&o.element.classList.contains("smart-hidden")){const t=e._rowElements[0];if(!t)continue;if(o.element=t,o.grid=e,o.render(),n=o["column_"+a.dataField],!n)continue}const l={};l.border=n.borderColor,l.background=n.background,l.color=n.color;const d=void 0!==e.dataExport.viewStart?t-e.dataExport.viewStart:t;r[t]=Object.assign({},o.data),r[t][a.dataField]=n.element.textContent,i[d]=l}}e.appearance.alternationCount>0&&(f.alternationCount=e.appearance.alternationCount,f.alternationStart=e.appearance.alternationStart,f.alternationEnd=e.appearance.alternationEnd,f.alternationIndex0Color=d.color,f.alternationIndex0BackgroundColor=d.backgroundColor,f.alternationIndex1Color=d.color,f.alternationIndex1BackgroundColor="#F5F5F5"),a.style={border:"1px solid "+d.borderColor,borderCollapse:"collapse",header:s,columns:u,rows:f}}}const n=!e.rowHierarchy||e.grouping.enabled?e.rows.toArray():e.rowHierarchy,i=e.dataExport.rowIds,l=null!==i;let d=[];if(e.dataExport.view)e._recyclingRows.forEach(((t,o)=>{if(e.dataExport.viewStart&&o<e.dataExport.viewStart||e.dataExport.viewEnd&&o>e.dataExport.viewEnd)return!0;r[o]?d.push(r[o]):d.push(t.data)}));else{for(let t=0;t<n.length;t++){const o=n[t];if(o.visible&&(!1!==o.filtered||void 0===o.filtered)){if(l&&-1===i.indexOf(o.id))continue;d.push(o.data)}}n!==e.rowHierarchy||l||(d=e.dataSource.boundHierarchy,a.hierarchical=!0)}!e.dataExport.groupBy&&e.grouping.enabled&&e.dataSource&&e.dataSource.groupBy&&(a.groupBy=e.dataSource.groupBy&&e.dataSource.groupBy.toArray?e.dataSource.groupBy.toArray():null),e.checkLicense(!0);const c=a.exportData(d,t,e.dataExport.fileName,o);return e.dataExport.view&&e._recycle(!1),c}print(){const t=this,o=t.dataExport.fileName;t.dataExport.fileName=null;const e=t.exportData("html"),a=window.open("","","width=800,height=500"),r=a.document.open(),n='<!DOCTYPE html><html><head><meta charset="utf-8" /><title>'+o+"</title></head><body>"+e+"</body></html>";try{r.write(n),r.close(),setTimeout((function(){a.print(),a.close()}),100)}catch(t){}t.dataExport.fileName=o}});