/* Tabulator v4.6.3 (c) Oliver Folkerd */ var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Export=function(t){this.table=t,this.config={},this.cloneTableStyle=!0,this.colVisProp=""};Export.prototype.genereateTable=function(t,e,o,n){this.cloneTableStyle=e,this.config=t||{},this.colVisProp=n;var r=document.createElement("table");return r.classList.add("tabulator-print-table"),!1!==this.config.columnHeaders&&r.appendChild(this.generateHeaderElements()),r.appendChild(this.generateBodyElements(this.rowLookup(o))),this.mapElementStyles(this.table.element,r,["border-top","border-left","border-right","border-bottom"]),r},Export.prototype.rowLookup=function(t){var e=this,o=[];if("function"==typeof t)t.call(this.table).forEach(function(t){(t=e.table.rowManager.findRow(t))&&o.push(t)});else switch(t){case!0:case"visible":o=this.table.rowManager.getVisibleRows(!0);break;case"all":o=this.table.rowManager.rows;break;case"selected":o=this.table.modules.selectRow.selectedRows;break;case"active":default:o=this.table.rowManager.getDisplayRows()}return Object.assign([],o)},Export.prototype.generateColumnGroupHeaders=function(){var t=this,e=[];return(!1!==this.config.columnGroups?this.table.columnManager.columns:this.table.columnManager.columnsByIndex).forEach(function(o){var n=t.processColumnGroup(o);n&&e.push(n)}),e},Export.prototype.processColumnGroup=function(t){var e=this,o=t.columns,n=0,r={title:t.definition.title,column:t,depth:1};if(o.length){if(r.subGroups=[],r.width=0,o.forEach(function(t){var o=e.processColumnGroup(t);o&&(r.width+=o.width,r.subGroups.push(o),o.depth>n&&(n=o.depth))}),r.depth+=n,!r.width)return!1}else{if(!this.columnVisCheck(t))return!1;r.width=1}return r},Export.prototype.groupHeadersToRows=function(t){function e(t,r){var l=n-r;void 0===o[r]&&(o[r]=[]),t.height=t.subGroups?1:l-t.depth+1,o[r].push(t),t.subGroups&&t.subGroups.forEach(function(t){e(t,r+1)})}var o=[],n=0;return t.forEach(function(t){t.depth>n&&(n=t.depth)}),t.forEach(function(t){e(t,0)}),o},Export.prototype.generateHeaderElements=function(){var t=this,e=document.createElement("thead");return this.groupHeadersToRows(this.generateColumnGroupHeaders()).forEach(function(o){var n=document.createElement("tr");t.mapElementStyles(t.table.columnManager.getHeadersElement(),e,["border-top","border-left","border-right","border-bottom","background-color","color","font-weight","font-family","font-size"]),o.forEach(function(e){var o=document.createElement("th"),r=e.column.definition.cssClass?e.column.definition.cssClass.split(" "):[];o.colSpan=e.width,o.rowSpan=e.height,o.innerHTML=e.column.definition.title,t.cloneTableStyle&&(o.style.boxSizing="border-box"),r.forEach(function(t){o.classList.add(t)}),t.mapElementStyles(e.column.getElement(),o,["text-align","border-top","border-left","border-right","border-bottom","background-color","color","font-weight","font-family","font-size"]),t.mapElementStyles(e.column.contentElement,o,["padding-top","padding-left","padding-right","padding-bottom"]),e.column.visible?t.mapElementStyles(e.column.getElement(),o,["width"]):e.column.definition.width&&(o.style.width=e.column.definition.width+"px"),e.column.parent&&t.mapElementStyles(e.column.parent.groupElement,o,["border-top"]),n.appendChild(o)}),e.appendChild(n)}),e},Export.prototype.generateBodyElements=function(t){},Export.prototype.generateBodyElements=function(t){var e,o,n,r,l,a,i,s,d,c,u=this;c=this.table.options["rowFormatter"+(this.colVisProp.charAt(0).toUpperCase()+this.colVisProp.slice(1))],c=null!==c?c:this.table.options.rowFormatter,this.cloneTableStyle&&window.getComputedStyle&&(e=this.table.element.querySelector(".tabulator-row-odd:not(.tabulator-group):not(.tabulator-calcs)"),o=this.table.element.querySelector(".tabulator-row-even:not(.tabulator-group):not(.tabulator-calcs)"),n=this.table.element.querySelector(".tabulator-row.tabulator-calcs"),r=this.table.element.querySelector(".tabulator-row:not(.tabulator-group):not(.tabulator-calcs)"),a=this.table.element.getElementsByClassName("tabulator-group")[0],r&&(i=r.getElementsByClassName("tabulator-cell"),l=i[0],i[i.length-1]));var p=document.createElement("tbody"),m=[];return!1!==this.config.columnCalcs&&this.table.modExists("columnCalcs")&&(this.table.modules.columnCalcs.topInitialized&&t.unshift(this.table.modules.columnCalcs.topRow),this.table.modules.columnCalcs.botInitialized&&t.push(this.table.modules.columnCalcs.botRow)),this.table.columnManager.columnsByIndex.forEach(function(t){u.columnVisCheck(t)&&m.push(t)}),this.table.options.dataTree&&!1!==this.config.dataTree&&this.table.modExists("columnCalcs")&&(d=this.table.modules.dataTree.elementField),t=t.filter(function(t){switch(t.type){case"group":return!1!==u.config.rowGroups;case"calc":return!1!==u.config.columnCalcs}return!0}),t.length>1e3&&console.warn("It may take a long time to render an HTML table with more than 1000 rows"),t.forEach(function(t,r){var i=t.getData(u.colVisProp),f=document.createElement("tr");switch(f.classList.add("tabulator-print-table-row"),t.type){case"group":var h=document.createElement("td");h.colSpan=m.length,h.innerHTML=t.key,f.classList.add("tabulator-print-table-group"),u.mapElementStyles(a,f,["border-top","border-left","border-right","border-bottom","color","font-weight","font-family","font-size","background-color"]),u.mapElementStyles(a,h,["padding-top","padding-left","padding-right","padding-bottom"]),f.appendChild(h);break;case"calc":f.classList.add("tabulator-print-table-calcs");case"row":if(u.table.options.dataTree&&!1===u.config.dataTree&&t.modules.dataTree.parent)return;if(m.forEach(function(e,o){var n=document.createElement("td"),r=e.getFieldValue(i),a={modules:{},getValue:function(){return r},getField:function(){return e.definition.field},getElement:function(){return n},getColumn:function(){return e.getComponent()},getData:function(){return i},getRow:function(){return t.getComponent()},getComponent:function(){return a},column:e};if((e.definition.cssClass?e.definition.cssClass.split(" "):[]).forEach(function(t){n.classList.add(t)}),u.table.modExists("format")&&!1!==u.config.formatCells)r=u.table.modules.format.formatExportValue(a,u.colVisProp);else switch(void 0===r?"undefined":_typeof(r)){case"object":r=JSON.stringify(r);break;case"undefined":case"null":r="";break;default:r=r}r instanceof Node?n.appendChild(r):n.innerHTML=r,l&&(u.mapElementStyles(l,n,["padding-top","padding-left","padding-right","padding-bottom","border-top","border-left","border-right","border-bottom","color","font-weight","font-family","font-size"]),e.definition.align&&(n.style.textAlign=e.definition.align)),u.table.options.dataTree&&!1!==u.config.dataTree&&(d&&d==e.field||!d&&0==o)&&(t.modules.dataTree.controlEl&&n.insertBefore(t.modules.dataTree.controlEl.cloneNode(!0),n.firstChild),t.modules.dataTree.branchEl&&n.insertBefore(t.modules.dataTree.branchEl.cloneNode(!0),n.firstChild)),f.appendChild(n),a.modules.format&&a.modules.format.renderedCallback&&a.modules.format.renderedCallback()}),s="calc"==t.type?n:r%2&&o?o:e,u.mapElementStyles(s,f,["border-top","border-left","border-right","border-bottom","color","font-weight","font-family","font-size","background-color"]),c&&!1!==u.config.formatCells){var b=t.getComponent();b.getElement=function(){return f},c(b)}}p.appendChild(f)}),p},Export.prototype.columnVisCheck=function(t){return!1!==t.definition[this.colVisProp]&&(t.visible||!t.visible&&t.definition[this.colVisProp])},Export.prototype.getHtml=function(t,e,o,n){var r=document.createElement("div");return r.appendChild(this.genereateTable(o||this.table.options.htmlOutputConfig,e,t,n||"htmlOutput")),r.innerHTML},Export.prototype.mapElementStyles=function(t,e,o){if(this.cloneTableStyle&&t&&e){var n={"background-color":"backgroundColor",color:"fontColor",width:"width","font-weight":"fontWeight","font-family":"fontFamily","font-size":"fontSize","text-align":"textAlign","border-top":"borderTop","border-left":"borderLeft","border-right":"borderRight","border-bottom":"borderBottom","padding-top":"paddingTop","padding-left":"paddingLeft","padding-right":"paddingRight","padding-bottom":"paddingBottom"};if(window.getComputedStyle){var r=window.getComputedStyle(t);o.forEach(function(t){e.style[n[t]]=r.getPropertyValue(t)})}}},Tabulator.prototype.registerModule("export",Export);