PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
← All changes | admin/js/build/jspreadsheet.js +1 -1 2.2.3 → 3.4 View file →
@@ -1 +1 @@
1 -(function(){var __webpack_exports__={},global,factory;global=window,factory=function(){"use strict";var Version=(info={title:"Jspreadsheet",version:"4.13.3",type:"CE",host:"https://bossanova.uk/jspreadsheet",license:"MIT",print:function(){return[this.title+" "+this.type+" "+this.version,this.host,this.license].join("\r\n")}},function(){return info}),info,isFormula=function(e){var o=(""+e)[0];return"="==o||"#"==o},getMask=function(e){if(e.format||e.mask||e.locale){var o={};return e.mask?o.mask=e.mask:e.format?o.mask=e.format:(o.locale=e.locale,o.options=e.options),e.decimal&&(o.options||(o.options={}),o.options={decimal:e.decimal}),o}return null},jexcel=function(el,options){var obj={options:{}};if(!(el instanceof Element||el instanceof HTMLDocument))return console.error("Jspreadsheet: el is not a valid DOM element"),!1;if("TABLE"==el.tagName){if(!(options=jexcel.createFromTable(el,options)))return console.error("Jspreadsheet: el is not a valid DOM element"),!1;var div=document.createElement("div");el.parentNode.insertBefore(div,el),el.remove(),el=div}var defaults={url:null,method:"GET",requestVariables:null,data:null,sorting:null,copyCompatibility:!1,root:null,rows:[],columns:[],colHeaders:[],colWidths:[],colAlignments:[],nestedHeaders:null,defaultColWidth:50,defaultColAlign:"center",defaultRowHeight:null,minSpareRows:0,minSpareCols:0,minDimensions:[0,0],allowExport:!0,includeHeadersOnDownload:!1,includeHeadersOnCopy:!1,columnSorting:!0,columnDrag:!1,columnResize:!0,rowResize:!1,rowDrag:!0,editable:!0,allowInsertRow:!0,allowManualInsertRow:!0,allowInsertColumn:!0,allowManualInsertColumn:!0,allowDeleteRow:!0,allowDeletingAllRows:!1,allowDeleteColumn:!0,allowRenameColumn:!0,allowComments:!1,wordWrap:!1,imageOptions:null,csv:null,csvFileName:"jspreadsheet",csvHeaders:!0,csvDelimiter:",",parseTableFirstRowAsHeader:!1,parseTableAutoCellType:!1,selectionCopy:!0,mergeCells:{},toolbar:null,search:!1,pagination:!1,paginationOptions:null,fullscreen:!1,lazyLoading:!1,loadingSpin:!1,tableOverflow:!1,tableHeight:"300px",tableWidth:null,textOverflow:!1,meta:null,style:null,classes:null,parseFormulas:!0,autoIncrement:!0,autoCasting:!0,secureFormulas:!0,stripHTML:!0,stripHTMLOnCopy:!1,filters:!1,footers:null,onundo:null,onredo:null,onload:null,onchange:null,oncomments:null,onbeforechange:null,onafterchanges:null,onbeforeinsertrow:null,oninsertrow:null,onbeforeinsertcolumn:null,oninsertcolumn:null,onbeforedeleterow:null,ondeleterow:null,onbeforedeletecolumn:null,ondeletecolumn:null,onmoverow:null,onmovecolumn:null,onresizerow:null,onresizecolumn:null,onsort:null,onselection:null,oncopy:null,onpaste:null,onbeforepaste:null,onmerge:null,onfocus:null,onblur:null,onchangeheader:null,oncreateeditor:null,oneditionstart:null,oneditionend:null,onchangestyle:null,onchangemeta:null,onchangepage:null,onbeforesave:null,onsave:null,onevent:null,persistance:!1,updateTable:null,detachForUpdates:!1,freezeColumns:null,text:{noRecordsFound:"No records found",showingPage:"Showing page {0} of {1} entries",show:"Show ",search:"Search",entries:" entries",columnName:"Column name",insertANewColumnBefore:"Insert a new column before",insertANewColumnAfter:"Insert a new column after",deleteSelectedColumns:"Delete selected columns",renameThisColumn:"Rename this column",orderAscending:"Order ascending",orderDescending:"Order descending",insertANewRowBefore:"Insert a new row before",insertANewRowAfter:"Insert a new row after",deleteSelectedRows:"Delete selected rows",editComments:"Edit comments",addComments:"Add comments",comments:"Comments",clearComments:"Clear comments",copy:"Copy...",paste:"Paste...",saveAs:"Save as...",about:"About",areYouSureToDeleteTheSelectedRows:"Are you sure to delete the selected rows?",areYouSureToDeleteTheSelectedColumns:"Are you sure to delete the selected columns?",thisActionWillDestroyAnyExistingMergedCellsAreYouSure:"This action will destroy any existing merged cells. Are you sure?",thisActionWillClearYourSearchResultsAreYouSure:"This action will clear your search results. Are you sure?",thereIsAConflictWithAnotherMergedCell:"There is a conflict with another merged cell",invalidMergeProperties:"Invalid merged properties",cellAlreadyMerged:"Cell already merged",noCellsSelected:"No cells selected"},about:!0};for(var property in defaults)if(options&&options.hasOwnProperty(property))if("text"===property)for(var textKey in obj.options[property]=defaults[property],options[property])options[property].hasOwnProperty(textKey)&&(obj.options[property][textKey]=options[property][textKey]);else obj.options[property]=options[property];else obj.options[property]=defaults[property];obj.el=el,obj.corner=null,obj.contextMenu=null,obj.textarea=null,obj.ads=null,obj.content=null,obj.table=null,obj.thead=null,obj.tbody=null,obj.rows=[],obj.results=null,obj.searchInput=null,obj.toolbar=null,obj.pagination=null,obj.pageNumber=null,obj.headerContainer=null,obj.colgroupContainer=null,obj.headers=[],obj.records=[],obj.history=[],obj.formula=[],obj.colgroup=[],obj.selection=[],obj.highlighted=[],obj.selectedCell=null,obj.selectedContainer=null,obj.style=[],obj.data=null,obj.filter=null,obj.filters=[],obj.cursor=null,obj.historyIndex=-1,obj.ignoreEvents=!1,obj.ignoreHistory=!1,obj.edition=null,obj.hashString=null,obj.resizing=null,obj.dragging=null,1==obj.options.lazyLoading&&0==obj.options.tableOverflow&&0==obj.options.fullscreen&&(console.error("Jspreadsheet: The lazyloading only works when tableOverflow = yes or fullscreen = yes"),obj.options.lazyLoading=!1),obj.fullscreen=function(e){null==e&&(e=!obj.options.fullscreen),obj.options.fullscreen!=e&&(obj.options.fullscreen=e,1==e?el.classList.add("fullscreen"):el.classList.remove("fullscreen"))},obj.dispatch=function(e){if(!obj.ignoreEvents){if("function"==typeof obj.options.onevent)var o=obj.options.onevent.apply(this,arguments);"function"==typeof obj.options[e]&&(o=obj.options[e].apply(this,Array.prototype.slice.call(arguments,1)))}if("onafterchanges"==e&&obj.options.persistance){var t=1==obj.options.persistance?obj.options.url:obj.options.persistance,n=obj.prepareJson(arguments[2]);obj.save(t,n)}return o},obj.prepareTable=function(){var e=obj.options.columns.length;if(obj.options.data&&void 0!==obj.options.data[0]){var o=Object.keys(obj.options.data[0]);o.length>e&&(e=o.length)}obj.options.minDimensions[0]>e&&(e=obj.options.minDimensions[0]);for(var t=[],n=0;n<e;n++)obj.options.colHeaders[n]||(obj.options.colHeaders[n]=""),obj.options.colWidths[n]||(obj.options.colWidths[n]=obj.options.defaultColWidth),obj.options.colAlignments[n]||(obj.options.colAlignments[n]=obj.options.defaultColAlign),obj.options.columns[n]?obj.options.columns[n].type||(obj.options.columns[n].type="text"):obj.options.columns[n]={type:"text"},obj.options.columns[n].name||(obj.options.columns[n].name=o&&o[n]?o[n]:n),obj.options.columns[n].source||(obj.options.columns[n].source=[]),obj.options.columns[n].options||(obj.options.columns[n].options=[]),obj.options.columns[n].editor||(obj.options.columns[n].editor=null),obj.options.columns[n].allowEmpty||(obj.options.columns[n].allowEmpty=!1),obj.options.columns[n].title||(obj.options.columns[n].title=obj.options.colHeaders[n]?obj.options.colHeaders[n]:""),obj.options.columns[n].width||(obj.options.columns[n].width=obj.options.colWidths[n]?obj.options.colWidths[n]:obj.options.defaultColWidth),obj.options.columns[n].align||(obj.options.columns[n].align=obj.options.colAlignments[n]?obj.options.colAlignments[n]:"center"),"autocomplete"==obj.options.columns[n].type||"dropdown"==obj.options.columns[n].type?obj.options.columns[n].url&&t.push({url:obj.options.columns[n].url,index:n,method:"GET",dataType:"json",success:function(e){for(var o=0;o<e.length;o++)obj.options.columns[this.index].source.push(e[o])}}):"calendar"==obj.options.columns[n].type&&(obj.options.columns[n].options.format||(obj.options.columns[n].options.format="DD/MM/YYYY"));t.length?jSuites.ajax(t,(function(){obj.createTable()})):obj.createTable()},obj.createTable=function(){obj.table=document.createElement("table"),obj.thead=document.createElement("thead"),obj.tbody=document.createElement("tbody"),obj.headers=[],obj.colgroup=[],obj.content=document.createElement("div"),obj.content.classList.add("jexcel_content"),obj.content.onscroll=function(e){obj.scrollControls(e)},obj.content.onwheel=function(e){obj.wheelControls(e)},obj.toolbar=document.createElement("div"),obj.toolbar.classList.add("jexcel_toolbar");var e=document.createElement("div"),o=document.createTextNode(obj.options.text.search+": ");obj.searchInput=document.createElement("input"),obj.searchInput.classList.add("jexcel_search"),e.appendChild(o),e.appendChild(obj.searchInput),obj.searchInput.onfocus=function(){obj.resetSelection()};var t=document.createElement("div");if(obj.options.pagination>0&&obj.options.paginationOptions&&obj.options.paginationOptions.length>0){obj.paginationDropdown=document.createElement("select"),obj.paginationDropdown.classList.add("jexcel_pagination_dropdown"),obj.paginationDropdown.onchange=function(){obj.options.pagination=parseInt(this.value),obj.page(0)};for(var n=0;n<obj.options.paginationOptions.length;n++){var r=document.createElement("option");r.value=obj.options.paginationOptions[n],r.innerHTML=obj.options.paginationOptions[n],obj.paginationDropdown.appendChild(r)}obj.paginationDropdown.value=obj.options.pagination,t.appendChild(document.createTextNode(obj.options.text.show)),t.appendChild(obj.paginationDropdown),t.appendChild(document.createTextNode(obj.options.text.entries))}var l,s=document.createElement("div");if(s.classList.add("jexcel_filter"),s.appendChild(t),s.appendChild(e),obj.colgroupContainer=document.createElement("colgroup"),(l=document.createElement("col")).setAttribute("width","50"),obj.colgroupContainer.appendChild(l),obj.options.nestedHeaders&&obj.options.nestedHeaders.length>0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(var i=0;i<obj.options.nestedHeaders.length;i++)obj.thead.appendChild(obj.createNestedHeader(obj.options.nestedHeaders[i]));else obj.thead.appendChild(obj.createNestedHeader(obj.options.nestedHeaders));for(obj.headerContainer=document.createElement("tr"),(l=document.createElement("td")).classList.add("jexcel_selectall"),obj.headerContainer.appendChild(l),n=0;n<obj.options.columns.length;n++)obj.createCellHeader(n),obj.headerContainer.appendChild(obj.headers[n]),obj.colgroupContainer.appendChild(obj.colgroup[n]);if(obj.thead.appendChild(obj.headerContainer),1==obj.options.filters){obj.filter=document.createElement("tr");var a=document.createElement("td");for(obj.filter.appendChild(a),n=0;n<obj.options.columns.length;n++)(a=document.createElement("td")).innerHTML="&nbsp;",a.setAttribute("data-x",n),a.className="jexcel_column_filter","hidden"==obj.options.columns[n].type&&(a.style.display="none"),obj.filter.appendChild(a);obj.thead.appendChild(obj.filter)}obj.table=document.createElement("table"),obj.table.classList.add("jexcel"),obj.table.setAttribute("cellpadding","0"),obj.table.setAttribute("cellspacing","0"),obj.table.setAttribute("unselectable","yes"),obj.table.appendChild(obj.colgroupContainer),obj.table.appendChild(obj.thead),obj.table.appendChild(obj.tbody),obj.options.textOverflow||obj.table.classList.add("jexcel_overflow"),obj.corner=document.createElement("div"),obj.corner.className="jexcel_corner",obj.corner.setAttribute("unselectable","on"),obj.corner.setAttribute("onselectstart","return false"),0==obj.options.selectionCopy&&(obj.corner.style.display="none"),obj.textarea=document.createElement("textarea"),obj.textarea.className="jexcel_textarea",obj.textarea.id="jexcel_textarea",obj.textarea.tabIndex="-1",obj.contextMenu=document.createElement("div"),obj.contextMenu.className="jexcel_contextmenu",jSuites.contextmenu(obj.contextMenu,{onclick:function(){obj.contextMenu.contextmenu.close(!1)}});var c=document.createElement("a");c.setAttribute("href","https://bossanova.uk/jspreadsheet/"),obj.ads=document.createElement("div"),obj.ads.className="jexcel_about";var u=document.createElement("span");u.innerHTML="Jspreadsheet CE",c.appendChild(u),obj.ads.appendChild(c),document.createElement("div").classList.add("jexcel_table"),obj.pagination=document.createElement("div"),obj.pagination.classList.add("jexcel_pagination");var d=document.createElement("div"),j=document.createElement("div");if(obj.pagination.appendChild(d),obj.pagination.appendChild(j),obj.options.pagination||(obj.pagination.style.display="none"),1==obj.options.search&&el.appendChild(s),obj.content.appendChild(obj.table),obj.content.appendChild(obj.corner),obj.content.appendChild(obj.textarea),el.appendChild(obj.toolbar),el.appendChild(obj.content),el.appendChild(obj.pagination),el.appendChild(obj.contextMenu),el.appendChild(obj.ads),el.classList.add("jexcel_container"),obj.options.toolbar&&obj.options.toolbar.length&&obj.createToolbar(),1==obj.options.fullscreen?el.classList.add("fullscreen"):1==obj.options.tableOverflow&&(obj.options.tableHeight&&(obj.content.style["overflow-y"]="auto",obj.content.style["box-shadow"]="rgb(221 221 221) 2px 2px 5px 0.1px",obj.content.style.maxHeight=obj.options.tableHeight),obj.options.tableWidth&&(obj.content.style["overflow-x"]="auto",obj.content.style.width=obj.options.tableWidth)),1!=obj.options.tableOverflow&&obj.options.toolbar&&el.classList.add("with-toolbar"),1==obj.options.columnDrag&&obj.thead.classList.add("draggable"),1==obj.options.columnResize&&obj.thead.classList.add("resizable"),1==obj.options.rowDrag&&obj.tbody.classList.add("draggable"),1==obj.options.rowResize&&obj.tbody.classList.add("resizable"),obj.setData(),obj.options.style&&obj.setStyle(obj.options.style,null,null,1,1),obj.options.classes){var b=Object.keys(obj.options.classes);for(n=0;n<b.length;n++){var p=jexcel.getIdFromColumnName(b[n],!0);obj.records[p[1]][p[0]].classList.add(obj.options.classes[b[n]])}}},obj.refresh=function(){obj.options.url?(1==obj.options.loadingSpin&&jSuites.loading.show(),jSuites.ajax({url:obj.options.url,method:obj.options.method,data:obj.options.requestVariables,dataType:"json",success:function(e){obj.options.data=e.data?e.data:e,obj.setData(),1==obj.options.loadingSpin&&jSuites.loading.hide()}})):obj.setData()},obj.setData=function(e){if(e&&("string"==typeof e&&(e=JSON.parse(e)),obj.options.data=e),obj.options.data||(obj.options.data=[]),obj.options.data&&obj.options.data[0]&&!Array.isArray(obj.options.data[0])){e=[];for(var o=0;o<obj.options.data.length;o++){for(var t=[],n=0;n<obj.options.columns.length;n++)t[n]=obj.options.data[o][obj.options.columns[n].name];e.push(t)}obj.options.data=e}o=0,n=0;var r=obj.options.columns.length,l=obj.options.data.length,s=obj.options.minDimensions[0],i=obj.options.minDimensions[1],a=s>r?s:r,c=i>l?i:l;for(o=0;o<c;o++)for(n=0;n<a;n++)null==obj.options.data[o]&&(obj.options.data[o]=[]),null==obj.options.data[o][n]&&(obj.options.data[o][n]="");if(obj.rows=[],obj.results=null,obj.records=[],obj.history=[],obj.historyIndex=-1,obj.tbody.innerHTML="",1==obj.options.lazyLoading){var u=0,d=obj.options.data.length<100?obj.options.data.length:100;obj.options.pagination&&(obj.options.pagination=!1,console.error("Jspreadsheet: Pagination will be disable due the lazyLoading"))}else obj.options.pagination?(obj.pageNumber||(obj.pageNumber=0),obj.options.pagination,u=obj.options.pagination*obj.pageNumber,d=obj.options.pagination*obj.pageNumber+obj.options.pagination,obj.options.data.length<d&&(d=obj.options.data.length)):(u=0,d=obj.options.data.length);for(o=0;o<obj.options.data.length;o++){var j=obj.createRow(o,obj.options.data[o]);o>=u&&o<d&&obj.tbody.appendChild(j)}if(1==obj.options.lazyLoading||obj.options.pagination&&obj.updatePagination(),obj.options.mergeCells){var b=Object.keys(obj.options.mergeCells);for(n=0;n<b.length;n++){var p=obj.options.mergeCells[b[n]];obj.setMerge(b[n],p[0],p[1],1)}}obj.updateTable(),obj.dispatch("onload",el,obj)},obj.getData=function(e,o){for(var t=[],n=0,r=0,l=1==o||0==obj.options.copyCompatibility,s=obj.options.columns.length,i=obj.options.data.length,a=0;a<i;a++){n=0;for(var c=0;c<s;c++)e&&!obj.records[a][c].classList.contains("highlight")||(t[r]||(t[r]=[]),t[r][n]=l?obj.options.data[a][c]:obj.records[a][c].innerHTML,n++);n>0&&r++}return t},obj.getJsonRow=function(e){for(var o=obj.options.data[e],t=obj.options.columns.length,n={},r=0;r<t;r++)obj.options.columns[r].name||(obj.options.columns[r].name=r),n[obj.options.columns[r].name]=o[r];return n},obj.getJson=function(e){for(var o=[],t=obj.options.columns.length,n=obj.options.data.length,r=0;r<n;r++){for(var l=null,s=0;s<t;s++)e&&!obj.records[r][s].classList.contains("highlight")||(null==l&&(l={}),obj.options.columns[s].name||(obj.options.columns[s].name=s),l[obj.options.columns[s].name]=obj.options.data[r][s]);null!=l&&o.push(l)}return o},obj.prepareJson=function(e){for(var o=[],t=0;t<e.length;t++){var n=e[t].x,r=e[t].y,l=obj.options.columns[n].name?obj.options.columns[n].name:n;o[r]||(o[r]={row:r,data:{}}),o[r].data[l]=e[t].newValue}return o.filter((function(e){return null!=e}))},obj.save=function(e,o){var t=obj.dispatch("onbeforesave",el,obj,o);if(t)o=t;else if(!1===t)return!1;jSuites.ajax({url:e,method:"POST",dataType:"json",data:{data:JSON.stringify(o)},success:function(e){obj.dispatch("onsave",el,obj,o)}})},obj.getRowData=function(e){return obj.options.data[e]},obj.setRowData=function(e,o){for(var t=0;t<obj.headers.length;t++){var n=jexcel.getColumnNameFromId([t,e]);null!=o[t]&&obj.setValue(n,o[t])}},obj.getColumnData=function(e){for(var o=[],t=0;t<obj.options.data.length;t++)o.push(obj.options.data[t][e]);return o},obj.setColumnData=function(e,o){for(var t=0;t<obj.rows.length;t++){var n=jexcel.getColumnNameFromId([e,t]);null!=o[t]&&obj.setValue(n,o[t])}},obj.createRow=function(e,o){obj.records[e]||(obj.records[e]=[]),o||(o=obj.options.data[e]),obj.rows[e]=document.createElement("tr"),obj.rows[e].setAttribute("data-y",e);var t=null;obj.options.defaultRowHeight&&(obj.rows[e].style.height=obj.options.defaultRowHeight+"px"),obj.options.rows[e]&&(obj.options.rows[e].height&&(obj.rows[e].style.height=obj.options.rows[e].height),obj.options.rows[e].title&&(t=obj.options.rows[e].title)),t||(t=parseInt(e+1));var n=document.createElement("td");n.innerHTML=t,n.setAttribute("data-y",e),n.className="jexcel_row",obj.rows[e].appendChild(n);for(var r=0;r<obj.options.columns.length;r++)obj.records[e][r]=obj.createCell(r,e,o[r]),obj.rows[e].appendChild(obj.records[e][r]);return obj.rows[e]},obj.parseValue=function(e,o,t,n){"="==(""+t).substr(0,1)&&1==obj.options.parseFormulas&&(t=obj.executeFormula(t,e,o));var r=obj.options.columns[e];if(r&&!isFormula(t)){var l=null;if(l=getMask(r)){t&&t==Number(t)&&(t=Number(t));var s=jSuites.mask.render(t,l,!0);if(n&&l.mask){var i=l.mask.split(";");i[1]&&(i[1].match(new RegExp("\\[Red\\]","gi"))&&(t<0?n.classList.add("red"):n.classList.remove("red")),i[1].match(new RegExp("\\(","gi"))&&t<0&&(s="("+s+")"))}s&&(t=s)}}return t};var validDate=function(e){return"-"==(e=""+e).substr(4,1)&&"-"==e.substr(7,1)||4==(e=e.split("-"))[0].length&&e[0]==Number(e[0])&&2==e[1].length&&e[1]==Number(e[1])};obj.createCell=function(e,o,t){var n=document.createElement("td");if(n.setAttribute("data-x",e),n.setAttribute("data-y",o),"="==(""+t).substr(0,1)&&1==obj.options.secureFormulas){var r=secureFormula(t);r!=t&&(t=r)}if(obj.options.columns[e].editor)!1===obj.options.stripHTML||!1===obj.options.columns[e].stripHTML?n.innerHTML=t:n.textContent=t,"function"==typeof obj.options.columns[e].editor.createCell&&(n=obj.options.columns[e].editor.createCell(n));else if("hidden"==obj.options.columns[e].type)n.style.display="none",n.textContent=t;else if("checkbox"==obj.options.columns[e].type||"radio"==obj.options.columns[e].type){var l=document.createElement("input");l.type=obj.options.columns[e].type,l.name="c"+e,l.checked=1==t||1==t||"true"==t,l.onclick=function(){obj.setValue(n,this.checked)},1!=obj.options.columns[e].readOnly&&0!=obj.options.editable||l.setAttribute("disabled","disabled"),n.appendChild(l),obj.options.data[o][e]=l.checked}else if("calendar"==obj.options.columns[e].type){var s=null;if(!validDate(t)){var i=jSuites.calendar.extractDateFromString(t,obj.options.columns[e].options.format);i&&(s=i)}n.textContent=jSuites.calendar.getDateString(s||t,obj.options.columns[e].options.format)}else if("dropdown"==obj.options.columns[e].type||"autocomplete"==obj.options.columns[e].type)n.classList.add("jexcel_dropdown"),n.textContent=obj.getDropDownValue(e,t);else if("color"==obj.options.columns[e].type)if("square"==obj.options.columns[e].render){var a=document.createElement("div");a.className="color",a.style.backgroundColor=t,n.appendChild(a)}else n.style.color=t,n.textContent=t;else if("image"==obj.options.columns[e].type){if(t&&"data:image"==t.substr(0,10)){var c=document.createElement("img");c.src=t,n.appendChild(c)}}else if("html"==obj.options.columns[e].type)n.innerHTML=stripScript(obj.parseValue(e,o,t,n));else if(!1===obj.options.stripHTML||!1===obj.options.columns[e].stripHTML)n.innerHTML=stripScript(obj.parseValue(e,o,t,n));else{var u=document.createElement("div");u.textContent=obj.parseValue(e,o,t,n),n.appendChild(u)}1==obj.options.columns[e].readOnly&&(n.className="readonly");var d=obj.options.columns[e].align?obj.options.columns[e].align:"center";return n.style.textAlign=d,0!=obj.options.columns[e].wordWrap&&(1==obj.options.wordWrap||1==obj.options.columns[e].wordWrap||n.innerHTML.length>200)&&(n.style.whiteSpace="pre-wrap"),e>0&&1==this.options.textOverflow&&(t||n.innerHTML?obj.records[o][e-1].style.overflow="hidden":e==obj.options.columns.length-1&&(n.style.overflow="hidden")),n},obj.createCellHeader=function(e){var o=obj.options.columns[e].width?obj.options.columns[e].width:obj.options.defaultColWidth,t=obj.options.columns[e].align?obj.options.columns[e].align:obj.options.defaultColAlign;obj.headers[e]=document.createElement("td"),obj.options.stripHTML?obj.headers[e].textContent=obj.options.columns[e].title?obj.options.columns[e].title:jexcel.getColumnName(e):obj.headers[e].innerHTML=obj.options.columns[e].title?obj.options.columns[e].title:jexcel.getColumnName(e),obj.headers[e].setAttribute("data-x",e),obj.headers[e].style.textAlign=t,obj.options.columns[e].title&&obj.headers[e].setAttribute("title",obj.headers[e].innerText),obj.options.columns[e].id&&obj.headers[e].setAttribute("id",obj.options.columns[e].id),obj.colgroup[e]=document.createElement("col"),obj.colgroup[e].setAttribute("width",o),"hidden"==obj.options.columns[e].type&&(obj.headers[e].style.display="none",obj.colgroup[e].style.display="none")},obj.updateNestedHeader=function(e,o,t){obj.options.nestedHeaders[o][e].title&&(obj.options.nestedHeaders[o][e].title=t,obj.options.nestedHeaders[o].element.children[e+1].textContent=t)},obj.createNestedHeader=function(e){var o=document.createElement("tr");o.classList.add("jexcel_nested");var t=document.createElement("td");o.appendChild(t),e.element=o;for(var n=0,r=0;r<e.length;r++){e[r].colspan||(e[r].colspan=1),e[r].align||(e[r].align="center"),e[r].title||(e[r].title=""),e[r].id||(e[r].id="");for(var l=e[r].colspan,s=[],i=0;i<l;i++)obj.options.columns[n]&&"hidden"==obj.options.columns[n].type&&l++,s.push(n),n++;(t=document.createElement("td")).setAttribute("data-column",s.join(",")),t.setAttribute("colspan",e[r].colspan),t.setAttribute("align",e[r].align),t.setAttribute("id",e[r].id),t.textContent=e[r].title,o.appendChild(t)}return o},obj.createToolbar=function(e){e?obj.options.toolbar=e:e=obj.options.toolbar;for(var o=0;o<e.length;o++)if("i"==e[o].type)(l=document.createElement("i")).classList.add("jexcel_toolbar_item"),l.classList.add("material-icons"),l.setAttribute("data-k",e[o].k),l.setAttribute("data-v",e[o].v),l.setAttribute("id",e[o].id),e[o].tooltip&&l.setAttribute("title",e[o].tooltip),e[o].onclick&&(e[o].onclick,1)?l.onclick=function(o){var t=o;return function(){e[t].onclick(el,obj,this)}}(o):l.onclick=function(){var e=this.getAttribute("data-k"),o=this.getAttribute("data-v");obj.setStyle(obj.highlighted,e,o)},l.textContent=e[o].content,obj.toolbar.appendChild(l);else if("select"==e[o].type){var t=!1;(l=document.createElement("select")).classList.add("jexcel_toolbar_item"),l.setAttribute("data-k",e[o].k),e[o].tooltip&&l.setAttribute("title",e[o].tooltip),e[o].onchange&&(e[o].onchange,1)?(l.onchange=e[o].onchange,t=!0):l.onchange=function(){var e=this.getAttribute("data-k");obj.setStyle(obj.highlighted,e,this.value)};for(var n=0;n<e[o].v.length;n++){var r=document.createElement("option");r.value=e[o].v[n],r.textContent=e[o].v[n],e[o].selectedValue&&r.value===e[o].selectedValue&&(r.selected=!0),l.appendChild(r)}t&&l.dispatchEvent(new Event("change")),obj.toolbar.appendChild(l)}else if("color"==e[o].type){var l;(l=document.createElement("i")).classList.add("jexcel_toolbar_item"),l.classList.add("material-icons"),l.setAttribute("data-k",e[o].k),l.setAttribute("data-v",""),e[o].tooltip&&l.setAttribute("title",e[o].tooltip),obj.toolbar.appendChild(l),l.textContent=e[o].content,jSuites.color(l,{onchange:function(e,o){var t=e.getAttribute("data-k");obj.setStyle(obj.highlighted,t,o)}})}},obj.setMerge=function(e,o,t,n){var r=!1;if(!e){if(!obj.highlighted.length)return alert(obj.options.text.noCellsSelected),null;var l=parseInt(obj.highlighted[0].getAttribute("data-x")),s=parseInt(obj.highlighted[0].getAttribute("data-y")),i=parseInt(obj.highlighted[obj.highlighted.length-1].getAttribute("data-x")),a=parseInt(obj.highlighted[obj.highlighted.length-1].getAttribute("data-y"));e=jexcel.getColumnNameFromId([l,s]),o=i-l+1,t=a-s+1}var c=jexcel.getIdFromColumnName(e,!0);if(obj.options.mergeCells[e])obj.records[c[1]][c[0]].getAttribute("data-merged")&&(r=obj.options.text.cellAlreadyMerged);else if((!o||o<2)&&(!t||t<2))r=obj.options.text.invalidMergeProperties;else for(var u=c[1];u<c[1]+t;u++)for(var d=c[0];d<c[0]+o;d++)jexcel.getColumnNameFromId([d,u]),obj.records[u][d].getAttribute("data-merged")&&(r=obj.options.text.thereIsAConflictWithAnotherMergedCell);if(r)alert(r);else{o>1?obj.records[c[1]][c[0]].setAttribute("colspan",o):o=1,t>1?obj.records[c[1]][c[0]].setAttribute("rowspan",t):t=1,obj.options.mergeCells[e]=[o,t,[]],obj.records[c[1]][c[0]].setAttribute("data-merged","true"),obj.records[c[1]][c[0]].style.overflow="hidden";for(var j=[],b=c[1];b<c[1]+t;b++)for(var p=c[0];p<c[0]+o;p++)c[0]==p&&c[1]==b||(j.push(obj.options.data[b][p]),obj.updateCell(p,b,"",!0),obj.options.mergeCells[e][2].push(obj.records[b][p]),obj.records[b][p].style.display="none",obj.records[b][p]=obj.records[c[1]][c[0]]);obj.updateSelection(obj.records[c[1]][c[0]]),n||(obj.setHistory({action:"setMerge",column:e,colspan:o,rowspan:t,data:j}),obj.dispatch("onmerge",el,e,o,t))}},obj.getMerge=function(e){var o={};if(e)o=obj.options.mergeCells[e]?[obj.options.mergeCells[e][0],obj.options.mergeCells[e][1]]:null;else if(obj.options.mergeCells){obj.options.mergeCells;for(var t=Object.keys(obj.options.mergeCells),n=0;n<t.length;n++)o[t[n]]=[obj.options.mergeCells[t[n]][0],obj.options.mergeCells[t[n]][1]]}return o},obj.removeMerge=function(e,o,t){if(obj.options.mergeCells[e]){var n=jexcel.getIdFromColumnName(e,!0);obj.records[n[1]][n[0]].removeAttribute("colspan"),obj.records[n[1]][n[0]].removeAttribute("rowspan"),obj.records[n[1]][n[0]].removeAttribute("data-merged");for(var r=obj.options.mergeCells[e],l=0,s=0;s<r[1];s++)for(var i=0;i<r[0];i++)(s>0||i>0)&&(obj.records[n[1]+s][n[0]+i]=r[2][l],obj.records[n[1]+s][n[0]+i].style.display="",o&&o[l]&&obj.updateCell(n[0]+i,n[1]+s,o[l]),l++);obj.updateSelection(obj.records[n[1]][n[0]],obj.records[n[1]+s-1][n[0]+i-1]),t||delete obj.options.mergeCells[e]}},obj.destroyMerged=function(e){if(obj.options.mergeCells){obj.options.mergeCells;for(var o=Object.keys(obj.options.mergeCells),t=0;t<o.length;t++)obj.removeMerge(o[t],null,e)}},obj.isColMerged=function(e,o){var t=[];if(obj.options.mergeCells)for(var n=Object.keys(obj.options.mergeCells),r=0;r<n.length;r++){var l=jexcel.getIdFromColumnName(n[r],!0),s=obj.options.mergeCells[n[r]][0],i=l[0],a=l[0]+(s>1?s-1:0);null==o?i<=e&&a>=e&&t.push(n[r]):o?i<e&&a>=e&&t.push(n[r]):i<=e&&a>e&&t.push(n[r])}return t},obj.isRowMerged=function(e,o){var t=[];if(obj.options.mergeCells)for(var n=Object.keys(obj.options.mergeCells),r=0;r<n.length;r++){var l=jexcel.getIdFromColumnName(n[r],!0),s=obj.options.mergeCells[n[r]][1],i=l[1],a=l[1]+(s>1?s-1:0);null==o?i<=e&&a>=e&&t.push(n[r]):o?i<e&&a>=e&&t.push(n[r]):i<=e&&a>e&&t.push(n[r])}return t},obj.openFilter=function(e){if(obj.options.filters){e=parseInt(e),obj.resetSelection();var o=[];if("checkbox"==obj.options.columns[e].type)o.push({id:"true",name:"True"}),o.push({id:"false",name:"False"});else{for(var t=[],n=!1,r=0;r<obj.options.data.length;r++){var l=obj.options.data[r][e],s=obj.records[r][e].innerHTML;l&&s?t[l]=s:n=!0}var i=Object.keys(t);for(o=[],r=0;r<i.length;r++)o.push({id:i[r],name:t[i[r]]});n&&o.push({value:"",id:"",name:"(Blanks)"})}var a=document.createElement("div");obj.filter.children[e+1].innerHTML="",obj.filter.children[e+1].appendChild(a),obj.filter.children[e+1].style.paddingLeft="0px",obj.filter.children[e+1].style.paddingRight="0px",obj.filter.children[e+1].style.overflow="initial";var c={data:o,multiple:!0,autocomplete:!0,opened:!0,value:void 0!==obj.filters[e]?obj.filters[e]:null,width:"100%",position:1==obj.options.tableOverflow||1==obj.options.fullscreen,onclose:function(o){obj.resetFilters(),obj.filters[e]=o.dropdown.getValue(!0),obj.filter.children[e+1].innerHTML=o.dropdown.getText(),obj.filter.children[e+1].style.paddingLeft="",obj.filter.children[e+1].style.paddingRight="",obj.filter.children[e+1].style.overflow="",obj.closeFilter(e),obj.refreshSelection()}};jSuites.dropdown(a,c)}else console.log("Jspreadsheet: filters not enabled.")},obj.resetFilters=function(){if(obj.options.filters)for(var e=0;e<obj.filter.children.length;e++)obj.filter.children[e].innerHTML="&nbsp;",obj.filters[e]=null;obj.results=null,obj.updateResult()},obj.closeFilter=function(e){if(!e)for(var o=0;o<obj.filter.children.length;o++)obj.filters[o]&&(e=o);var t=function(e,o,t){for(var n=0;n<e.length;n++){var r=""+obj.options.data[t][o],l=""+obj.records[t][o].innerHTML;if(e[n]==r||e[n]==l)return!0}return!1},n=obj.filters[e];obj.results=[];for(var r=0;r<obj.options.data.length;r++)t(n,e,r)&&obj.results.push(r);obj.results.length||(obj.results=null),obj.updateResult()},obj.openEditor=function(e,o,t){var n=e.getAttribute("data-y"),r=e.getAttribute("data-x");obj.dispatch("oneditionstart",el,e,r,n),r>0&&(obj.records[n][r-1].style.overflow="hidden");var l=function(o){var t=e.getBoundingClientRect(),l=document.createElement(o);return l.style.width=t.width-6+"px",l.style.height=t.height-6+"px",l.style.minHeight=t.height-6+"px",e.classList.add("editor"),e.innerHTML="",e.appendChild(l),obj.dispatch("oncreateeditor",el,e,r,n,l),l};if(1==e.classList.contains("readonly"));else if(obj.edition=[obj.records[n][r],obj.records[n][r].innerHTML,r,n],obj.options.columns[r].editor)obj.options.columns[r].editor.openEditor(e,el,o,t);else if("hidden"==obj.options.columns[r].type);else if("checkbox"==obj.options.columns[r].type||"radio"==obj.options.columns[r].type){var s=!e.children[0].checked;obj.setValue(e,s),obj.edition=null}else if("dropdown"==obj.options.columns[r].type||"autocomplete"==obj.options.columns[r].type){if(s=obj.options.data[n][r],obj.options.columns[r].multiple&&!Array.isArray(s)&&(s=s.split(";")),"function"==typeof obj.options.columns[r].filter)var i=obj.options.columns[r].filter(el,e,r,n,obj.options.columns[r].source);else i=obj.options.columns[r].source;for(var a=[],c=0;c<i.length;c++)a.push(i[c]);var u=l("div"),d={data:a,multiple:!!obj.options.columns[r].multiple,autocomplete:!(!obj.options.columns[r].autocomplete&&"autocomplete"!=obj.options.columns[r].type),opened:!0,value:s,width:"100%",height:u.style.minHeight,position:1==obj.options.tableOverflow||1==obj.options.fullscreen,onclose:function(){obj.closeEditor(e,!0)}};obj.options.columns[r].options&&obj.options.columns[r].options.type&&(d.type=obj.options.columns[r].options.type),jSuites.dropdown(u,d)}else if("calendar"==obj.options.columns[r].type||"color"==obj.options.columns[r].type)s=obj.options.data[n][r],(u=l("input")).value=s,1!=obj.options.tableOverflow&&1!=obj.options.fullscreen||(obj.options.columns[r].options.position=!0),obj.options.columns[r].options.value=obj.options.data[n][r],obj.options.columns[r].options.opened=!0,obj.options.columns[r].options.onclose=function(o,t){obj.closeEditor(e,!0)},"color"==obj.options.columns[r].type?jSuites.color(u,obj.options.columns[r].options):jSuites.calendar(u,obj.options.columns[r].options),u.focus();else if("html"==obj.options.columns[r].type){s=obj.options.data[n][r],(u=l("div")).style.position="relative",(p=document.createElement("div")).classList.add("jexcel_richtext"),u.appendChild(p),jSuites.editor(p,{focus:!0,value:s});var j=e.getBoundingClientRect(),b=p.getBoundingClientRect();window.innerHeight<j.bottom+b.height?p.style.top=j.top-(b.height+2)+"px":p.style.top=j.top+"px"}else if("image"==obj.options.columns[r].type){var p,h=e.children[0];(u=l("div")).style.position="relative",(p=document.createElement("div")).classList.add("jclose"),h&&h.src&&p.appendChild(h),u.appendChild(p),jSuites.image(p,obj.options.imageOptions),j=e.getBoundingClientRect(),b=p.getBoundingClientRect(),window.innerHeight<j.bottom+b.height?p.style.top=j.top-(b.height+2)+"px":p.style.top=j.top+"px"}else{e.classList.add("editing");var g=e.getBoundingClientRect().height;if(obj.rows[n].style.setProperty("--table-editor-line-clamp-editing",Math.floor((g-10)/14)),obj.updateCornerPosition(),s=1==o?"":obj.options.data[n][r],0==obj.options.columns[r].wordWrap||1!=obj.options.wordWrap&&1!=obj.options.columns[r].wordWrap)u=l("input");else u=l("textarea");u.focus(),u.value=s,d=obj.options.columns[r];var f=null;if(!isFormula(s)&&(f=getMask(d))){if(!d.disabledMaskOnEdition)if(d.mask){var m=d.mask.split(";");u.setAttribute("data-mask",m[0])}else d.locale&&u.setAttribute("data-locale",d.locale);f.input=u,u.mask=f,jSuites.mask.render(s,f,!1)}u.onblur=function(){obj.closeEditor(e,!0)},u.scrollLeft=u.scrollWidth}},obj.closeEditor=function(e,o){var t=parseInt(e.getAttribute("data-x")),n=parseInt(e.getAttribute("data-y"));if(e.classList.remove("editing"),obj.rows[n].style.removeProperty("--table-editor-line-clamp-editing"),obj.updateCornerPosition(),1==o){if(obj.options.columns[t].editor)var r=obj.options.columns[t].editor.closeEditor(e,o);else if("checkbox"==obj.options.columns[t].type||"radio"==obj.options.columns[t].type||"hidden"==obj.options.columns[t].type);else if("dropdown"==obj.options.columns[t].type||"autocomplete"==obj.options.columns[t].type)r=e.children[0].dropdown.close(!0);else if("calendar"==obj.options.columns[t].type)r=e.children[0].calendar.close(!0);else if("color"==obj.options.columns[t].type)r=e.children[0].color.close(!0);else if("html"==obj.options.columns[t].type)r=e.children[0].children[0].editor.getData();else if("image"==obj.options.columns[t].type){var l=e.children[0].children[0].children[0];r=l&&"IMG"==l.tagName?l.src:""}else if("numeric"==obj.options.columns[t].type)"="!=(""+(r=e.children[0].value)).substr(0,1)&&""==r&&(r=obj.options.columns[t].allowEmpty?"":0),e.children[0].onblur=null;else{r=e.children[0].value,e.children[0].onblur=null;var s,i=obj.options.columns[t];if((s=getMask(i))&&""!==r&&!isFormula(r)&&"number"!=typeof r){var a=jSuites.mask.extract(r,s,!0);a&&""!==a.value&&(r=a.value)}}obj.options.data[n][t]==r?e.innerHTML=obj.edition[1]:obj.setValue(e,r)}else obj.options.columns[t].editor?obj.options.columns[t].editor.closeEditor(e,o):"dropdown"==obj.options.columns[t].type||"autocomplete"==obj.options.columns[t].type?e.children[0].dropdown.close(!0):"calendar"==obj.options.columns[t].type?e.children[0].calendar.close(!0):"color"==obj.options.columns[t].type?e.children[0].color.close(!0):e.children[0].onblur=null,e.innerHTML=obj.edition&&obj.edition[1]?obj.edition[1]:"";obj.dispatch("oneditionend",el,e,t,n,r,o),e.classList.remove("editor"),obj.edition=null},obj.getCell=function(e){var o=(e=jexcel.getIdFromColumnName(e,!0))[0],t=e[1];return obj.records[t][o]},obj.getColumnOptions=function(e,o){var t=obj.options.columns[e];return t||(t={type:"text"}),t},obj.getCellFromCoords=function(e,o){return obj.records[o][e]},obj.getLabel=function(e){var o=(e=jexcel.getIdFromColumnName(e,!0))[0],t=e[1];return obj.records[t][o].innerHTML},obj.getLabelFromCoords=function(e,o){return obj.records[o][e].innerHTML},obj.getValue=function(e,o){if("object"==typeof e)var t=e.getAttribute("data-x"),n=e.getAttribute("data-y");else t=(e=jexcel.getIdFromColumnName(e,!0))[0],n=e[1];var r=null;return null!=t&&null!=n&&(obj.records[n]&&obj.records[n][t]&&(o||1==obj.options.copyCompatibility)?r=obj.records[n][t].innerHTML:obj.options.data[n]&&"undefined"!=obj.options.data[n][t]&&(r=obj.options.data[n][t])),r},obj.getValueFromCoords=function(e,o,t){var n=null;return null!=e&&null!=o&&(obj.records[o]&&obj.records[o][e]&&t||1==obj.options.copyCompatibility?n=obj.records[o][e].innerHTML:obj.options.data[o]&&"undefined"!=obj.options.data[o][e]&&(n=obj.options.data[o][e])),n},obj.setValue=function(e,o,t){var n=[];if("string"==typeof e){var r=(a=jexcel.getIdFromColumnName(e,!0))[0],l=a[1];n.push(obj.updateCell(r,l,o,t)),obj.updateFormulaChain(r,l,n)}else if(r=null,l=null,e&&e.getAttribute&&(r=e.getAttribute("data-x"),l=e.getAttribute("data-y")),null!=r&&null!=l)n.push(obj.updateCell(r,l,o,t)),obj.updateFormulaChain(r,l,n);else{var s=Object.keys(e);if(s.length>0)for(var i=0;i<s.length;i++){var a;"string"==typeof e[i]?(r=(a=jexcel.getIdFromColumnName(e[i],!0))[0],l=a[1]):null!=e[i].x&&null!=e[i].y?(r=e[i].x,l=e[i].y,null!=e[i].newValue?o=e[i].newValue:null!=e[i].value&&(o=e[i].value)):(r=e[i].getAttribute("data-x"),l=e[i].getAttribute("data-y")),null!=r&&null!=l&&(n.push(obj.updateCell(r,l,o,t)),obj.updateFormulaChain(r,l,n))}}obj.setHistory({action:"setValue",records:n,selection:obj.selectedCell}),obj.updateTable(),obj.onafterchanges(el,n)},obj.setValueFromCoords=function(e,o,t,n){var r=[];r.push(obj.updateCell(e,o,t,n)),obj.updateFormulaChain(e,o,r),obj.setHistory({action:"setValue",records:r,selection:obj.selectedCell}),obj.updateTable(),obj.onafterchanges(el,r)},obj.setCheckRadioValue=function(){for(var e=[],o=Object.keys(obj.highlighted),t=0;t<o.length;t++){var n=obj.highlighted[t].getAttribute("data-x"),r=obj.highlighted[t].getAttribute("data-y");"checkbox"!=obj.options.columns[n].type&&"radio"!=obj.options.columns[n].type||e.push(obj.updateCell(n,r,!obj.options.data[r][n]))}e.length&&(obj.setHistory({action:"setValue",records:e,selection:obj.selectedCell}),obj.onafterchanges(el,e))};var stripScript=function(e){var o=new Option;o.innerHTML=e;var t=null;for(e=o.getElementsByTagName("script");t=e[0];)t.parentNode.removeChild(t);return o.innerHTML};obj.updateCell=function(e,o,t,n){if(1!=obj.records[o][e].classList.contains("readonly")||n){var r;"="==(""+t).substr(0,1)&&1==obj.options.secureFormulas&&(r=secureFormula(t))!=t&&(t=r),null!=(r=obj.dispatch("onbeforechange",el,obj.records[o][e],e,o,t))&&(t=r),obj.options.columns[e].editor&&"function"==typeof obj.options.columns[e].editor.updateCell&&(t=obj.options.columns[e].editor.updateCell(obj.records[o][e],t,n)),d={x:e,y:o,col:e,row:o,newValue:t,oldValue:obj.options.data[o][e]};let j=obj.options.columns[e].editor;if(j)obj.options.data[o][e]=t,"function"==typeof j.setValue&&j.setValue(obj.records[o][e],t);else if("checkbox"==obj.options.columns[e].type||"radio"==obj.options.columns[e].type){if("radio"==obj.options.columns[e].type)for(var l=0;l<obj.options.data.length;l++)obj.options.data[l][e]=!1;obj.records[o][e].children[0].checked=1==t||1==t||"true"==t||"TRUE"==t,obj.options.data[o][e]=obj.records[o][e].children[0].checked}else if("dropdown"==obj.options.columns[e].type||"autocomplete"==obj.options.columns[e].type)obj.options.data[o][e]=t,obj.records[o][e].textContent=obj.getDropDownValue(e,t);else if("calendar"==obj.options.columns[e].type){var s=null;if(!validDate(t)){var i=jSuites.calendar.extractDateFromString(t,obj.options.columns[e].options.format);i&&(s=i)}obj.options.data[o][e]=t,obj.records[o][e].textContent=jSuites.calendar.getDateString(s||t,obj.options.columns[e].options.format)}else if("color"==obj.options.columns[e].type)if(obj.options.data[o][e]=t,"square"==obj.options.columns[e].render){var a=document.createElement("div");a.className="color",a.style.backgroundColor=t,obj.records[o][e].textContent="",obj.records[o][e].appendChild(a)}else obj.records[o][e].style.color=t,obj.records[o][e].textContent=t;else if("image"==obj.options.columns[e].type){if(t=""+t,obj.options.data[o][e]=t,obj.records[o][e].innerHTML="",t&&"data:image"==t.substr(0,10)){var c=document.createElement("img");c.src=t,obj.records[o][e].appendChild(c)}}else{if(obj.options.data[o][e]=t,"html"==obj.options.columns[e].type)obj.records[o][e].innerHTML=stripScript(obj.parseValue(e,o,t));else if(!1===obj.options.stripHTML||!1===obj.options.columns[e].stripHTML)obj.records[o][e].innerHTML=stripScript(obj.parseValue(e,o,t,obj.records[o][e]));else{var u=document.createElement("div");u.textContent=obj.parseValue(e,o,t,obj.records[o][e]),obj.records[o][e].textContent="",obj.records[o][e].appendChild(u)}0!=obj.options.columns[e].wordWrap&&(1==obj.options.wordWrap||1==obj.options.columns[e].wordWrap||obj.records[o][e].innerHTML.length>200)?obj.records[o][e].style.whiteSpace="pre-wrap":obj.records[o][e].style.whiteSpace=""}e>0&&(obj.records[o][e-1].style.overflow=t?"hidden":""),obj.dispatch("onchange",el,obj.records[o]&&obj.records[o][e]?obj.records[o][e]:null,e,o,t,d.oldValue)}else var d={x:e,y:o,col:e,row:o};return d},obj.copyData=function(e,o){var t=obj.getData(!0,!0),n=obj.selectedContainer,r=parseInt(e.getAttribute("data-x")),l=parseInt(e.getAttribute("data-y")),s=parseInt(o.getAttribute("data-x")),i=parseInt(o.getAttribute("data-y")),a=[],c=!1;if(n[0]==r){if(l<n[1])var u=l-n[1];else u=1;var d=0}else d=r<n[0]?r-n[0]:1,u=0;for(var j=0,b=0,p=l;p<=i;p++)if(!obj.rows[p]||"none"!=obj.rows[p].style.display){null==t[b]&&(b=0),j=0,n[0]!=r&&(d=r<n[0]?r-n[0]:1);for(var h=r;h<=s;h++){if(obj.records[p][h]&&!obj.records[p][h].classList.contains("readonly")&&"none"!=obj.records[p][h].style.display&&0==c){if(!obj.selection.length&&""!=obj.options.data[p][h]){c=!0;continue}(null==t[b]||null==t[b][j])&&(j=0);var g=t[b][j];if(g&&!t[1]&&1==obj.options.autoIncrement)if("text"==obj.options.columns[h].type||"number"==obj.options.columns[h].type)if("="==(""+g).substr(0,1)){var f=g.match(/([A-Z]+[0-9]+)/g);if(f){for(var m=[],C=0;C<f.length;C++){var x=jexcel.getIdFromColumnName(f[C],1);x[0]+=d,x[1]+=u,x[1]<0&&(x[1]=0);var v=jexcel.getColumnNameFromId([x[0],x[1]]);v!=f[C]&&(m[f[C]]=v)}m&&(g=obj.updateFormula(g,m))}}else g==Number(g)&&(g=Number(g)+u);else if("calendar"==obj.options.columns[h].type){var y=new Date(g);y.setDate(y.getDate()+u),g=y.getFullYear()+"-"+jexcel.doubleDigitFormat(parseInt(y.getMonth()+1))+"-"+jexcel.doubleDigitFormat(y.getDate())+" 00:00:00"}a.push(obj.updateCell(h,p,g)),obj.updateFormulaChain(h,p,a)}j++,n[0]!=r&&d++}b++,u++}obj.setHistory({action:"setValue",records:a,selection:obj.selectedCell}),obj.updateTable(),obj.onafterchanges(el,a)},obj.refreshSelection=function(){obj.selectedCell&&obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3])},obj.conditionalSelectionUpdate=function(e,o,t){if(1==e){if(obj.selectedCell&&(o>=obj.selectedCell[1]&&o<=obj.selectedCell[3]||t>=obj.selectedCell[1]&&t<=obj.selectedCell[3]))return void obj.resetSelection()}else if(obj.selectedCell&&(o>=obj.selectedCell[0]&&o<=obj.selectedCell[2]||t>=obj.selectedCell[0]&&t<=obj.selectedCell[2]))return void obj.resetSelection()},obj.resetSelection=function(e){if(obj.highlighted.length){c=1;for(var o=0;o<obj.highlighted.length;o++){obj.highlighted[o].classList.remove("highlight"),obj.highlighted[o].classList.remove("highlight-left"),obj.highlighted[o].classList.remove("highlight-right"),obj.highlighted[o].classList.remove("highlight-top"),obj.highlighted[o].classList.remove("highlight-bottom"),obj.highlighted[o].classList.remove("highlight-selected");var t=parseInt(obj.highlighted[o].getAttribute("data-x")),n=parseInt(obj.highlighted[o].getAttribute("data-y"));if(obj.highlighted[o].getAttribute("data-merged"))var r=parseInt(obj.highlighted[o].getAttribute("colspan")),l=parseInt(obj.highlighted[o].getAttribute("rowspan")),s=r>0?t+(r-1):t,i=l>0?n+(l-1):n;else s=t,i=n;for(var a=t;a<=s;a++)obj.headers[a]&&obj.headers[a].classList.remove("selected");for(a=n;a<=i;a++)obj.rows[a]&&obj.rows[a].classList.remove("selected")}}else var c=0;return obj.highlighted=[],obj.selectedCell=null,obj.corner.style.top="-2000px",obj.corner.style.left="-2000px",1==e&&1==c&&obj.dispatch("onblur",el),c},obj.updateSelection=function(e,o,t){var n=e.getAttribute("data-x"),r=e.getAttribute("data-y");if(o)var l=o.getAttribute("data-x"),s=o.getAttribute("data-y");else l=n,s=r;obj.updateSelectionFromCoords(n,r,l,s,t)},obj.updateSelectionFromCoords=function(e,o,t,n,r){var l=obj.resetSelection();if(null==o&&(o=0,n=obj.rows.length-1),null==t&&(t=e),null==n&&(n=o),e>=obj.headers.length&&(e=obj.headers.length-1),o>=obj.rows.length&&(o=obj.rows.length-1),t>=obj.headers.length&&(t=obj.headers.length-1),n>=obj.rows.length&&(n=obj.rows.length-1),obj.selectedCell=[e,o,t,n],null!=e){if(obj.records[o][e]&&obj.records[o][e].classList.add("highlight-selected"),parseInt(e)<parseInt(t))var s=parseInt(e),i=parseInt(t);else s=parseInt(t),i=parseInt(e);if(parseInt(o)<parseInt(n))var a=parseInt(o),c=parseInt(n);else a=parseInt(n),c=parseInt(o);for(var u=s;u<=i;u++)for(var d=a;d<=c;d++)if(obj.records[d][u]&&obj.records[d][u].getAttribute("data-merged")){var j=parseInt(obj.records[d][u].getAttribute("data-x")),b=parseInt(obj.records[d][u].getAttribute("data-y")),p=parseInt(obj.records[d][u].getAttribute("colspan")),h=parseInt(obj.records[d][u].getAttribute("rowspan"));p>1&&(j<s&&(s=j),j+p>i&&(i=j+p-1)),h&&(b<a&&(a=b),b+h>c&&(c=b+h-1))}var g=null,f=null,m=null,C=null;for(d=a;d<=c;d++)"none"!=obj.rows[d].style.display&&(null==m&&(m=d),C=d);for(u=s;u<=i;u++){for(d=a;d<=c;d++)"none"!=obj.rows[d].style.display&&"none"!=obj.records[d][u].style.display&&(obj.records[d][u].classList.add("highlight"),obj.highlighted.push(obj.records[d][u]));"hidden"!=obj.options.columns[u].type&&(null==g&&(g=u),f=u)}for(g||(g=0),f||(f=0),u=g;u<=f;u++)"hidden"!=obj.options.columns[u].type&&(obj.records[m]&&obj.records[m][u]&&obj.records[m][u].classList.add("highlight-top"),obj.records[C]&&obj.records[C][u]&&obj.records[C][u].classList.add("highlight-bottom"),obj.headers[u].classList.add("selected"));for(d=m;d<=C;d++)obj.rows[d]&&"none"!=obj.rows[d].style.display&&(obj.records[d][g].classList.add("highlight-left"),obj.records[d][f].classList.add("highlight-right"),obj.rows[d].classList.add("selected"));obj.selectedContainer=[g,m,f,C]}0==l&&(obj.dispatch("onfocus",el),obj.removeCopyingSelection()),obj.dispatch("onselection",el,g,m,f,C,r),obj.updateCornerPosition()},obj.removeCopySelection=function(){for(var e=0;e<obj.selection.length;e++)obj.selection[e].classList.remove("selection"),obj.selection[e].classList.remove("selection-left"),obj.selection[e].classList.remove("selection-right"),obj.selection[e].classList.remove("selection-top"),obj.selection[e].classList.remove("selection-bottom");obj.selection=[]},obj.updateCopySelection=function(e,o){obj.removeCopySelection();var t=obj.selectedContainer[0],n=obj.selectedContainer[1],r=obj.selectedContainer[2],l=obj.selectedContainer[3];if(null!=e&&null!=o){if(e-r>0)var s=parseInt(r)+1,i=parseInt(e);else s=parseInt(e),i=parseInt(t)-1;if(o-l>0)var a=parseInt(l)+1,c=parseInt(o);else a=parseInt(o),c=parseInt(n)-1;i-s<=c-a?(s=parseInt(t),i=parseInt(r)):(a=parseInt(n),c=parseInt(l));for(var u=a;u<=c;u++)for(var d=s;d<=i;d++)obj.records[u][d]&&"none"!=obj.rows[u].style.display&&"none"!=obj.records[u][d].style.display&&(obj.records[u][d].classList.add("selection"),obj.records[a][d].classList.add("selection-top"),obj.records[c][d].classList.add("selection-bottom"),obj.records[u][s].classList.add("selection-left"),obj.records[u][i].classList.add("selection-right"),obj.selection.push(obj.records[u][d]))}},obj.updateCornerPosition=function(){if(obj.highlighted.length){var e=obj.highlighted[obj.highlighted.length-1],o=e.getAttribute("data-x"),t=obj.content.getBoundingClientRect(),n=t.left,r=t.top,l=e.getBoundingClientRect(),s=l.left,i=l.top,a=l.width,c=l.height,u=s-n+obj.content.scrollLeft+a-4,d=i-r+obj.content.scrollTop+c-4;if(obj.corner.style.top=d+"px",obj.corner.style.left=u+"px",obj.options.freezeColumns){var j=obj.getFreezeWidth();o>obj.options.freezeColumns-1&&s-n+a<j?obj.corner.style.display="none":1==obj.options.selectionCopy&&(obj.corner.style.display="")}else 1==obj.options.selectionCopy&&(obj.corner.style.display="")}else obj.corner.style.top="-2000px",obj.corner.style.left="-2000px"},obj.updateScroll=function(e){var o=obj.content.getBoundingClientRect(),t=o.left,n=o.top,r=o.width,l=o.height,s=obj.records[obj.selectedCell[3]][obj.selectedCell[2]].getBoundingClientRect(),i=s.left,a=s.top,c=s.width,u=s.height;if(0==e||1==e)var d=i-t+obj.content.scrollLeft,j=a-n+obj.content.scrollTop-2;else d=i-t+obj.content.scrollLeft+c,j=a-n+obj.content.scrollTop+u;j>obj.content.scrollTop+30&&j<obj.content.scrollTop+l||(j<obj.content.scrollTop+30?obj.content.scrollTop=j-u:obj.content.scrollTop=j-(l-2));var b=obj.getFreezeWidth();d>obj.content.scrollLeft+b&&d<obj.content.scrollLeft+r||(d<obj.content.scrollLeft+30?(obj.content.scrollLeft=d,obj.content.scrollLeft<50&&(obj.content.scrollLeft=0)):d<obj.content.scrollLeft+b?obj.content.scrollLeft=d-b-1:obj.content.scrollLeft=d-(r-20))},obj.getWidth=function(e){if(void 0===e)for(var o=[],t=0;t<obj.headers.length;t++)o.push(obj.options.columns[t].width);else"object"==typeof e&&(e=e.getAttribute("data-x")),o=obj.colgroup[e].getAttribute("width");return o},obj.setWidth=function(e,o,t){if(o){if(Array.isArray(e)){t||(t=[]);for(var n=0;n<e.length;n++){t[n]||(t[n]=obj.colgroup[e[n]].getAttribute("width"));var r=Array.isArray(o)&&o[n]?o[n]:o;obj.colgroup[e[n]].setAttribute("width",r),obj.options.columns[e[n]].width=r}}else t||(t=obj.colgroup[e].getAttribute("width")),obj.colgroup[e].setAttribute("width",o),obj.options.columns[e].width=o;obj.setHistory({action:"setWidth",column:e,oldValue:t,newValue:o}),obj.dispatch("onresizecolumn",el,e,o,t),obj.updateCornerPosition()}},obj.setHeight=function(e,o,t){o>0&&("object"==typeof e&&(e=e.getAttribute("data-y")),t||(t=obj.rows[e].getAttribute("height"))||(t=obj.rows[e].getBoundingClientRect().height),o=parseInt(o),obj.rows[e].style.setProperty("--table-editor-line-clamp",Math.floor((o-10)/14)),obj.options.rows[e]||(obj.options.rows[e]={}),obj.options.rows[e].height=o,obj.setHistory({action:"setHeight",row:e,oldValue:t,newValue:o}),obj.dispatch("onresizerow",el,e,o,t),obj.updateCornerPosition())},obj.getHeight=function(e){if(void 0===e)for(var o=[],t=0;t<obj.rows.length;t++){var n=obj.rows[t].style.height;n&&(o[t]=n)}else"object"==typeof e&&(e=$(e).getAttribute("data-y")),o=obj.rows[e].style.height;return o},obj.setFooter=function(e){if(e&&(obj.options.footers=e),obj.options.footers){obj.tfoot||(obj.tfoot=document.createElement("tfoot"),obj.table.appendChild(obj.tfoot));for(var o=0;o<obj.options.footers.length;o++){if(obj.tfoot.children[o])var t=obj.tfoot.children[o];else{t=document.createElement("tr");var n=document.createElement("td");t.appendChild(n),obj.tfoot.appendChild(t)}for(var r=0;r<obj.headers.length;r++){if(obj.options.footers[o][r]||(obj.options.footers[o][r]=""),obj.tfoot.children[o].children[r+1])n=obj.tfoot.children[o].children[r+1];else{n=document.createElement("td"),t.appendChild(n);var l=obj.options.columns[r].align?obj.options.columns[r].align:"center";n.style.textAlign=l}n.textContent=obj.parseValue(+obj.records.length+r,o,obj.options.footers[o][r]),n.style.display=obj.colgroup[r].style.display}}}},obj.getHeader=function(e){return obj.headers[e].textContent},obj.setHeader=function(e,o){if(obj.headers[e]){var t=obj.headers[e].textContent;o||(o=prompt(obj.options.text.columnName,t)),o&&(obj.headers[e].textContent=o,obj.headers[e].setAttribute("title",o),obj.options.columns[e].title=o),obj.setHistory({action:"setHeader",column:e,oldValue:t,newValue:o}),obj.dispatch("onchangeheader",el,e,t,o)}},obj.getHeaders=function(e){for(var o=[],t=0;t<obj.headers.length;t++)o.push(obj.getHeader(t));return e?o:o.join(obj.options.csvDelimiter)},obj.getMeta=function(e,o){return e?o?obj.options.meta[e]&&obj.options.meta[e][o]?obj.options.meta[e][o]:null:obj.options.meta[e]?obj.options.meta[e]:null:obj.options.meta},obj.setMeta=function(e,o,t){if(obj.options.meta||(obj.options.meta={}),o&&t)obj.options.meta[e]||(obj.options.meta[e]={}),obj.options.meta[e][o]=t;else for(var n=Object.keys(e),r=0;r<n.length;r++){obj.options.meta[n[r]]||(obj.options.meta[n[r]]={});for(var l=Object.keys(e[n[r]]),s=0;s<l.length;s++)obj.options.meta[n[r]][l[s]]=e[n[r]][l[s]]}obj.dispatch("onchangemeta",el,e,o,t)},obj.updateMeta=function(e){if(obj.options.meta){for(var o={},t=Object.keys(obj.options.meta),n=0;n<t.length;n++)e[t[n]]?o[e[t[n]]]=obj.options.meta[t[n]]:o[t[n]]=obj.options.meta[t[n]];obj.options.meta=o}},obj.getStyle=function(e,o){if(e)return e=jexcel.getIdFromColumnName(e,!0),o?obj.records[e[1]][e[0]].style[o]:obj.records[e[1]][e[0]].getAttribute("style");for(var t={},n=obj.options.data[0].length,r=obj.options.data.length,l=0;l<r;l++)for(var s=0;s<n;s++){var i=o?obj.records[l][s].style[o]:obj.records[l][s].getAttribute("style");i&&(t[jexcel.getColumnNameFromId([s,l])]=i)}return t},obj.resetStyle=function(e,o){for(var t=Object.keys(e),n=0;n<t.length;n++){var r=jexcel.getIdFromColumnName(t[n],!0);obj.records[r[1]]&&obj.records[r[1]][r[0]]&&obj.records[r[1]][r[0]].setAttribute("style","")}obj.setStyle(e,null,null,null,o)},obj.setStyle=function(e,o,t,n,r){var l={},s={},i=function(e,o,t){var r=jexcel.getIdFromColumnName(e,!0);if(obj.records[r[1]]&&obj.records[r[1]][r[0]]&&(0==obj.records[r[1]][r[0]].classList.contains("readonly")||n)){var i=obj.records[r[1]][r[0]].style[o];i!=t||n?obj.records[r[1]][r[0]].style[o]=t:(t="",obj.records[r[1]][r[0]].style[o]=""),s[e]||(s[e]=[]),l[e]||(l[e]=[]),s[e].push([o+":"+i]),l[e].push([o+":"+t])}};if(o&&t)if("string"==typeof e)i(e,o,t);else for(var a=[],c=0;c<e.length;c++){var u=e[c].getAttribute("data-x"),d=e[c].getAttribute("data-y"),j=jexcel.getColumnNameFromId([u,d]);a[j]||(i(j,o,t),a[j]=!0)}else{var b=Object.keys(e);for(c=0;c<b.length;c++){var p=e[b[c]];"string"==typeof p&&(p=p.split(";"));for(var h=0;h<p.length;h++)"string"==typeof p[h]&&(p[h]=p[h].split(":")),p[h][0].trim()&&i(b[c],p[h][0].trim(),p[h][1])}}for(b=Object.keys(s),c=0;c<b.length;c++)s[b[c]]=s[b[c]].join(";");for(b=Object.keys(l),c=0;c<b.length;c++)l[b[c]]=l[b[c]].join(";");r||obj.setHistory({action:"setStyle",oldValue:s,newValue:l}),obj.dispatch("onchangestyle",el,e,o,t)},obj.getComments=function(e,o){if(e)return"string"==typeof e&&(e=jexcel.getIdFromColumnName(e,!0)),o?[obj.records[e[1]][e[0]].getAttribute("title"),obj.records[e[1]][e[0]].getAttribute("author")]:obj.records[e[1]][e[0]].getAttribute("title")||"";for(var t={},n=0;n<obj.options.data.length;n++)for(var r=0;r<obj.options.columns.length;r++){var l=obj.records[n][r].getAttribute("title");l&&(t[e=jexcel.getColumnNameFromId([r,n])]=l)}return t},obj.setComments=function(e,o,t){if("string"==typeof e)var n=jexcel.getIdFromColumnName(e,!0);else n=e;var r=obj.records[n[1]][n[0]].getAttribute("title"),l=[r,t=obj.records[n[1]][n[0]].getAttribute("data-author")];obj.records[n[1]][n[0]].setAttribute("title",o||""),obj.records[n[1]][n[0]].setAttribute("data-author",t||""),o?obj.records[n[1]][n[0]].classList.add("jexcel_comments"):obj.records[n[1]][n[0]].classList.remove("jexcel_comments"),obj.setHistory({action:"setComments",column:e,newValue:[o,t],oldValue:l}),obj.dispatch("oncomments",el,o,r,n,n[0],n[1])},obj.getConfig=function(){var e=obj.options;return e.style=obj.getStyle(),e.mergeCells=obj.getMerge(),e.comments=obj.getComments(),e},obj.orderBy=function(e,o){if(e>=0){if(Object.keys(obj.options.mergeCells).length>0){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}o=null==o?obj.headers[e].classList.contains("arrow-down")?1:0:o?1:0;var t=[];if("number"==obj.options.columns[e].type||"numeric"==obj.options.columns[e].type||"percentage"==obj.options.columns[e].type||"autonumber"==obj.options.columns[e].type||"color"==obj.options.columns[e].type)for(var n=0;n<obj.options.data.length;n++)t[n]=[n,Number(obj.options.data[n][e])];else if("calendar"==obj.options.columns[e].type||"checkbox"==obj.options.columns[e].type||"radio"==obj.options.columns[e].type)for(n=0;n<obj.options.data.length;n++)t[n]=[n,obj.options.data[n][e]];else for(n=0;n<obj.options.data.length;n++)t[n]=[n,obj.records[n][e].textContent.toLowerCase()];"function"!=typeof obj.options.sorting&&(obj.options.sorting=function(e){return function(o,t){var n=o[1],r=t[1];return e?""===n&&""!==r?1:""!==n&&""===r||n>r?-1:n<r?1:0:""===n&&""!==r?1:""!==n&&""===r?-1:n>r?1:n<r?-1:0}}),t=t.sort(obj.options.sorting(o));var r=[];for(n=0;n<t.length;n++)r[n]=t[n][0];if(window?.tp?.table?.options?.table_head){const e=0;(r=r.filter((o=>o>e))).unshift(e)}if(window?.tp?.table?.options?.table_foot){const e=r.length-1;(r=r.filter((o=>o<e))).push(e)}return obj.setHistory({action:"orderBy",rows:r,column:e,order:o}),obj.updateOrderArrow(e,o),obj.updateOrder(r),obj.dispatch("onsort",el,e,o),!0}},obj.updateOrderArrow=function(e,o){for(var t=0;t<obj.headers.length;t++)obj.headers[t].classList.remove("arrow-up"),obj.headers[t].classList.remove("arrow-down");o?obj.headers[e].classList.add("arrow-up"):obj.headers[e].classList.add("arrow-down")},obj.updateOrder=function(e){for(var o=[],t=0;t<e.length;t++)o[t]=obj.options.data[e[t]];for(obj.options.data=o,o=[],t=0;t<e.length;t++)o[t]=obj.records[e[t]];for(obj.records=o,o=[],t=0;t<e.length;t++)o[t]=obj.rows[e[t]];if(obj.rows=o,obj.updateTableReferences(),obj.results&&obj.results.length)obj.searchInput.value?obj.search(obj.searchInput.value):obj.closeFilter();else if(obj.results=null,obj.pageNumber=0,obj.options.pagination>0)obj.page(0);else if(1==obj.options.lazyLoading)obj.loadPage(0);else for(t=0;t<obj.rows.length;t++)obj.tbody.appendChild(obj.rows[t])},obj.moveRow=function(e,o,t){if(Object.keys(obj.options.mergeCells).length>0){if(e>o)var n=1;else n=0;if(obj.isRowMerged(e).length||obj.isRowMerged(o,n).length){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}}if(1==obj.options.search){if(obj.results&&obj.results.length!=obj.rows.length){if(!confirm(obj.options.text.thisActionWillClearYourSearchResultsAreYouSure))return!1;obj.resetSearch()}obj.results=null}t||(Array.prototype.indexOf.call(obj.tbody.children,obj.rows[o])>=0?e>o?obj.tbody.insertBefore(obj.rows[e],obj.rows[o]):obj.tbody.insertBefore(obj.rows[e],obj.rows[o].nextSibling):obj.tbody.removeChild(obj.rows[e])),obj.rows.splice(o,0,obj.rows.splice(e,1)[0]),obj.records.splice(o,0,obj.records.splice(e,1)[0]),obj.options.data.splice(o,0,obj.options.data.splice(e,1)[0]),obj.options.pagination>0&&obj.tbody.children.length!=obj.options.pagination&&obj.page(obj.pageNumber),obj.setHistory({action:"moveRow",oldValue:e,newValue:o}),obj.updateTableReferences(),obj.dispatch("onmoverow",el,e,o)},obj.insertRow=function(e,o,t){if(1==obj.options.allowInsertRow){var n=[];if(e>0)var r=e;else r=1,e&&(n=e);t=!!t;var l=obj.options.data.length-1;if((null==o||o>=parseInt(l)||o<0)&&(o=l),!1===obj.dispatch("onbeforeinsertrow",el,o,r,t))return!1;if(Object.keys(obj.options.mergeCells).length>0&&obj.isRowMerged(o,t).length){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}if(1==obj.options.search){if(obj.results&&obj.results.length!=obj.rows.length){if(!confirm(obj.options.text.thisActionWillClearYourSearchResultsAreYouSure))return!1;obj.resetSearch()}obj.results=null}for(var s=t?o:o+1,i=obj.records.splice(s),a=obj.options.data.splice(s),c=obj.rows.splice(s),u=[],d=[],j=[],b=s;b<r+s;b++){obj.options.data[b]=[];for(var p=0;p<obj.options.columns.length;p++)obj.options.data[b][p]=n[p]?n[p]:"";var h=obj.createRow(b,obj.options.data[b]);c[0]?Array.prototype.indexOf.call(obj.tbody.children,c[0])>=0&&obj.tbody.insertBefore(h,c[0]):Array.prototype.indexOf.call(obj.tbody.children,obj.rows[o])>=0&&obj.tbody.appendChild(h),u.push(obj.records[b]),d.push(obj.options.data[b]),j.push(h)}Array.prototype.push.apply(obj.records,i),Array.prototype.push.apply(obj.options.data,a),Array.prototype.push.apply(obj.rows,c),obj.options.pagination>0&&obj.page(obj.pageNumber),obj.setHistory({action:"insertRow",rowNumber:o,numOfRows:r,insertBefore:t,rowRecords:u,rowData:d,rowNode:j}),obj.updateTableReferences(),obj.dispatch("oninsertrow",el,o,r,u,t)}},obj.deleteRow=function(e,o){if(1==obj.options.allowDeleteRow)if(1==obj.options.allowDeletingAllRows||obj.options.data.length>1){if(null==e){var t=obj.getSelectedRows();t[0]?(e=parseInt(t[0].getAttribute("data-y")),o=t.length):(e=obj.options.data.length-1,o=1)}var n=obj.options.data.length-1;if((null==e||e>n||e<0)&&(e=n),o||(o=1),e+o>=obj.options.data.length&&(o=obj.options.data.length-e),!1===obj.dispatch("onbeforedeleterow",el,e,o))return!1;if(parseInt(e)>-1){var r=!1;if(Object.keys(obj.options.mergeCells).length>0)for(var l=e;l<e+o;l++)obj.isRowMerged(l,!1).length&&(r=!0);if(r){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}if(1==obj.options.search){if(obj.results&&obj.results.length!=obj.rows.length){if(!confirm(obj.options.text.thisActionWillClearYourSearchResultsAreYouSure))return!1;obj.resetSearch()}obj.results=null}for(0==obj.options.allowDeletingAllRows&&n+1===o&&(o--,console.error("Jspreadsheet: It is not possible to delete the last row")),l=e;l<e+o;l++)Array.prototype.indexOf.call(obj.tbody.children,obj.rows[l])>=0&&(obj.rows[l].className="",obj.rows[l].parentNode.removeChild(obj.rows[l]));var s=obj.records.splice(e,o),i=obj.options.data.splice(e,o),a=obj.rows.splice(e,o);obj.options.pagination>0&&obj.tbody.children.length!=obj.options.pagination&&obj.page(obj.pageNumber),obj.conditionalSelectionUpdate(1,e,e+o-1),obj.setHistory({action:"deleteRow",rowNumber:e,numOfRows:o,insertBefore:1,rowRecords:s,rowData:i,rowNode:a}),obj.updateTableReferences(),obj.dispatch("ondeleterow",el,e,o,s)}}else console.error("Jspreadsheet: It is not possible to delete the last row")},obj.moveColumn=function(e,o){if(Object.keys(obj.options.mergeCells).length>0){if(e>o)var t=1;else t=0;if(obj.isColMerged(e).length||obj.isColMerged(o,t).length){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}}if((e=parseInt(e))>(o=parseInt(o))){obj.headerContainer.insertBefore(obj.headers[e],obj.headers[o]),obj.colgroupContainer.insertBefore(obj.colgroup[e],obj.colgroup[o]);for(var n=0;n<obj.rows.length;n++)obj.rows[n].insertBefore(obj.records[n][e],obj.records[n][o])}else for(obj.headerContainer.insertBefore(obj.headers[e],obj.headers[o].nextSibling),obj.colgroupContainer.insertBefore(obj.colgroup[e],obj.colgroup[o].nextSibling),n=0;n<obj.rows.length;n++)obj.rows[n].insertBefore(obj.records[n][e],obj.records[n][o].nextSibling);for(obj.options.columns.splice(o,0,obj.options.columns.splice(e,1)[0]),obj.headers.splice(o,0,obj.headers.splice(e,1)[0]),obj.colgroup.splice(o,0,obj.colgroup.splice(e,1)[0]),n=0;n<obj.rows.length;n++)obj.options.data[n].splice(o,0,obj.options.data[n].splice(e,1)[0]),obj.records[n].splice(o,0,obj.records[n].splice(e,1)[0]);if(obj.options.footers)for(n=0;n<obj.options.footers.length;n++)obj.options.footers[n].splice(o,0,obj.options.footers[n].splice(e,1)[0]);obj.setHistory({action:"moveColumn",oldValue:e,newValue:o}),obj.updateTableReferences(),obj.dispatch("onmovecolumn",el,e,o)},obj.insertColumn=function(e,o,t,n){if(1==obj.options.allowInsertColumn){var r=[];if(e>0)var l=e;else l=1,e&&(r=e);t=!!t;var s=obj.options.columns.length-1;if((null==o||o>=parseInt(s)||o<0)&&(o=s),!1===obj.dispatch("onbeforeinsertcolumn",el,o,l,t))return!1;if(Object.keys(obj.options.mergeCells).length>0&&obj.isColMerged(o,t).length){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}n||(n=[]);for(var i=0;i<l;i++)n[i]||(n[i]={type:"text",source:[],options:[],width:obj.options.defaultColWidth,align:obj.options.defaultColAlign});var a=t?o:o+1;obj.options.columns=jexcel.injectArray(obj.options.columns,a,n);for(var c=obj.headers.splice(a),u=obj.colgroup.splice(a),d=[],j=[],b=[],p=[],h=[],g=a;g<l+a;g++)obj.createCellHeader(g),obj.headerContainer.insertBefore(obj.headers[g],obj.headerContainer.children[g+1]),obj.colgroupContainer.insertBefore(obj.colgroup[g],obj.colgroupContainer.children[g+1]),d.push(obj.headers[g]),j.push(obj.colgroup[g]);if(obj.options.footers)for(var f=0;f<obj.options.footers.length;f++){for(h[f]=[],i=0;i<l;i++)h[f].push("");obj.options.footers[f].splice(a,0,h[f])}for(var m=0;m<obj.options.data.length;m++){var C=obj.options.data[m].splice(a),x=obj.records[m].splice(a);for(p[m]=[],b[m]=[],g=a;g<l+a;g++){var v=r[m]?r[m]:"";obj.options.data[m][g]=v;var y=obj.createCell(g,m,obj.options.data[m][g]);obj.records[m][g]=y,obj.rows[m]&&obj.rows[m].insertBefore(y,obj.rows[m].children[g+1]),p[m].push(v),b[m].push(y)}Array.prototype.push.apply(obj.options.data[m],C),Array.prototype.push.apply(obj.records[m],x)}if(Array.prototype.push.apply(obj.headers,c),Array.prototype.push.apply(obj.colgroup,u),obj.options.nestedHeaders&&obj.options.nestedHeaders.length>0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(f=0;f<obj.options.nestedHeaders.length;f++){var w=parseInt(obj.options.nestedHeaders[f][obj.options.nestedHeaders[f].length-1].colspan)+l;obj.options.nestedHeaders[f][obj.options.nestedHeaders[f].length-1].colspan=w,obj.thead.children[f].children[obj.thead.children[f].children.length-1].setAttribute("colspan",w);var A=obj.thead.children[f].children[obj.thead.children[f].children.length-1].getAttribute("data-column");for(A=A.split(","),g=a;g<l+a;g++)A.push(g);obj.thead.children[f].children[obj.thead.children[f].children.length-1].setAttribute("data-column",A)}else w=parseInt(obj.options.nestedHeaders[0].colspan)+l,obj.options.nestedHeaders[0].colspan=w,obj.thead.children[0].children[obj.thead.children[0].children.length-1].setAttribute("colspan",w);obj.setHistory({action:"insertColumn",columnNumber:o,numOfColumns:l,insertBefore:t,columns:n,headers:d,colgroup:j,records:b,footers:h,data:p}),obj.updateTableReferences(),obj.dispatch("oninsertcolumn",el,o,l,b,t)}},obj.deleteColumn=function(e,o){if(1==obj.options.allowDeleteColumn)if(obj.headers.length>1){if(null==e){var t=obj.getSelectedColumns(!0);t.length?(e=parseInt(t[0]),o=parseInt(t.length)):(e=obj.headers.length-1,o=1)}var n=obj.options.data[0].length-1;if((null==e||e>n||e<0)&&(e=n),o||(o=1),o>obj.options.data[0].length-e&&(o=obj.options.data[0].length-e),!1===obj.dispatch("onbeforedeletecolumn",el,e,o))return!1;if(parseInt(e)>-1){var r=!1;if(Object.keys(obj.options.mergeCells).length>0)for(var l=e;l<e+o;l++)obj.isColMerged(l,!1).length&&(r=!0);if(r){if(!confirm(obj.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;obj.destroyMerged()}var s=obj.options.columns.splice(e,o);for(l=e;l<e+o;l++)obj.colgroup[l].className="",obj.headers[l].className="",obj.colgroup[l].parentNode.removeChild(obj.colgroup[l]),obj.headers[l].parentNode.removeChild(obj.headers[l]);for(var i=obj.headers.splice(e,o),a=obj.colgroup.splice(e,o),c=[],u=[],d=[],j=0;j<obj.options.data.length;j++)for(l=e;l<e+o;l++)obj.records[j][l].className="",obj.records[j][l].parentNode.removeChild(obj.records[j][l]);for(j=0;j<obj.options.data.length;j++)u[j]=obj.options.data[j].splice(e,o),c[j]=obj.records[j].splice(e,o);if(obj.options.footers)for(j=0;j<obj.options.footers.length;j++)d[j]=obj.options.footers[j].splice(e,o);if(obj.conditionalSelectionUpdate(0,e,e+o-1),obj.options.nestedHeaders&&obj.options.nestedHeaders.length>0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(var b=0;b<obj.options.nestedHeaders.length;b++){var p=parseInt(obj.options.nestedHeaders[b][obj.options.nestedHeaders[b].length-1].colspan)-o;obj.options.nestedHeaders[b][obj.options.nestedHeaders[b].length-1].colspan=p,obj.thead.children[b].children[obj.thead.children[b].children.length-1].setAttribute("colspan",p)}else p=parseInt(obj.options.nestedHeaders[0].colspan)-o,obj.options.nestedHeaders[0].colspan=p,obj.thead.children[0].children[obj.thead.children[0].children.length-1].setAttribute("colspan",p);obj.setHistory({action:"deleteColumn",columnNumber:e,numOfColumns:o,insertBefore:1,columns:s,headers:i,colgroup:a,records:c,footers:d,data:u}),obj.updateTableReferences(),obj.dispatch("ondeletecolumn",el,e,o,c)}}else console.error("Jspreadsheet: It is not possible to delete the last column")},obj.getSelectedRows=function(e){for(var o=[],t=0;t<obj.rows.length;t++)obj.rows[t].classList.contains("selected")&&(e?o.push(t):o.push(obj.rows[t]));return o},obj.getSelectedColumns=function(){for(var e=[],o=0;o<obj.headers.length;o++)obj.headers[o].classList.contains("selected")&&e.push(o);return e},obj.getHighlighted=function(){return obj.highlighted},obj.updateTableReferences=function(){for(var e=0;e<obj.headers.length;e++)(l=obj.headers[e].getAttribute("data-x"))!=e&&(obj.headers[e].setAttribute("data-x",e),obj.headers[e].getAttribute("title")||(obj.headers[e].innerHTML=jexcel.getColumnName(e)));for(var o=0;o<obj.rows.length;o++)obj.rows[o]&&(s=obj.rows[o].getAttribute("data-y"))!=o&&(obj.rows[o].setAttribute("data-y",o),obj.rows[o].children[0].setAttribute("data-y",o),obj.rows[o].children[0].innerHTML=o+1);var t=[],n=[],r=function(e,o,n,r){if(e!=n&&obj.records[r][n].setAttribute("data-x",n),o!=r&&obj.records[r][n].setAttribute("data-y",r),e!=n||o!=r){var l=jexcel.getColumnNameFromId([e,o]),s=jexcel.getColumnNameFromId([n,r]);t[l]=s}};for(o=0;o<obj.records.length;o++)for(e=0;e<obj.records[0].length;e++)if(obj.records[o][e]){var l=obj.records[o][e].getAttribute("data-x"),s=obj.records[o][e].getAttribute("data-y");if(obj.records[o][e].getAttribute("data-merged")){var i=jexcel.getColumnNameFromId([l,s]),a=jexcel.getColumnNameFromId([e,o]);if(null==n[i])if(i==a)n[i]=!1;else{var c=parseInt(e-l),u=parseInt(o-s);n[i]=[a,c,u]}}else r(l,s,e,o)}var d=Object.keys(n);if(d.length)for(e=0;e<d.length;e++)if(n[d[e]]){var j=jexcel.getIdFromColumnName(d[e],!0);for(r(l=j[0],s=j[1],l+n[d[e]][1],s+n[d[e]][2]),i=d[e],a=n[d[e]][0],o=0;o<obj.options.mergeCells[i][2].length;o++)l=parseInt(obj.options.mergeCells[i][2][o].getAttribute("data-x")),s=parseInt(obj.options.mergeCells[i][2][o].getAttribute("data-y")),obj.options.mergeCells[i][2][o].setAttribute("data-x",l+n[d[e]][1]),obj.options.mergeCells[i][2][o].setAttribute("data-y",s+n[d[e]][2]);obj.options.mergeCells[a]=obj.options.mergeCells[i],delete obj.options.mergeCells[i]}obj.updateFormulas(t),obj.updateMeta(t),obj.refreshSelection(),obj.updateTable()},obj.updateTable=function(){if(obj.options.minSpareRows>0){for(var e=0,o=obj.rows.length-1;o>=0;o--){for(var t=!1,n=0;n<obj.headers.length;n++)obj.options.data[o][n]&&(t=!0);if(t)break;e++}obj.options.minSpareRows-e>0&&obj.insertRow(obj.options.minSpareRows-e)}if(obj.options.minSpareCols>0){var r=0;for(n=obj.headers.length-1;n>=0;n--){for(t=!1,o=0;o<obj.rows.length;o++)obj.options.data[o][n]&&(t=!0);if(t)break;r++}obj.options.minSpareCols-r>0&&obj.insertColumn(obj.options.minSpareCols-r)}if("function"==typeof obj.options.updateTable){for(obj.options.detachForUpdates&&el.removeChild(obj.content),o=0;o<obj.rows.length;o++)for(n=0;n<obj.headers.length;n++)obj.options.updateTable(el,obj.records[o][n],n,o,obj.options.data[o][n],obj.records[o][n].textContent,jexcel.getColumnNameFromId([n,o]));obj.options.detachForUpdates&&el.insertBefore(obj.content,obj.pagination)}obj.options.footers&&obj.setFooter(),setTimeout((function(){obj.updateCornerPosition()}),0)},obj.isReadOnly=function(e){if(e=obj.getCell(e))return!!e.classList.contains("readonly")},obj.setReadOnly=function(e,o){(e=obj.getCell(e))&&(o?e.classList.add("readonly"):e.classList.remove("readonly"))},obj.showRow=function(e){obj.rows[e].style.display=""},obj.hideRow=function(e){obj.rows[e].style.display="none"},obj.showColumn=function(e){obj.headers[e].style.display="",obj.colgroup[e].style.display="",obj.filter&&obj.filter.children.length>e+1&&(obj.filter.children[e+1].style.display="");for(var o=0;o<obj.options.data.length;o++)obj.records[o][e].style.display="";obj.options.footers&&obj.setFooter(),obj.resetSelection()},obj.hideColumn=function(e){obj.headers[e].style.display="none",obj.colgroup[e].style.display="none",obj.filter&&obj.filter.children.length>e+1&&(obj.filter.children[e+1].style.display="none");for(var o=0;o<obj.options.data.length;o++)obj.records[o][e].style.display="none";obj.options.footers&&obj.setFooter(),obj.resetSelection()},obj.showIndex=function(){obj.table.classList.remove("jexcel_hidden_index")},obj.hideIndex=function(){obj.table.classList.add("jexcel_hidden_index")};var chainLoopProtection=[];obj.updateFormulaChain=function(e,o,t){var n=jexcel.getColumnNameFromId([e,o]);if(obj.formula[n]&&obj.formula[n].length>0)if(chainLoopProtection[n])obj.records[o][e].innerHTML="#ERROR",obj.formula[n]="";else{chainLoopProtection[n]=!0;for(var r=0;r<obj.formula[n].length;r++){var l=jexcel.getIdFromColumnName(obj.formula[n][r],!0),s=""+obj.options.data[l[1]][l[0]];"="==s.substr(0,1)?t.push(obj.updateCell(l[0],l[1],s,!0)):Object.keys(obj.formula)[r]=null,obj.updateFormulaChain(l[0],l[1],t)}}chainLoopProtection=[]},obj.updateFormulas=function(e){for(var o=0;o<obj.options.data.length;o++)for(var t=0;t<obj.options.data[0].length;t++)if("="==(i=""+obj.options.data[o][t]).substr(0,1)){var n=obj.updateFormula(i,e);n!=i&&obj.updateCell(t,o,n)}var r=[],l=Object.keys(obj.formula);for(o=0;o<l.length;o++){var s=l[o],i=obj.formula[s];for(e[s]&&(s=e[s]),r[s]=[],t=0;t<i.length;t++){var a=i[t];e[a]&&(a=e[a]),r[s].push(a)}}obj.formula=r},obj.updateFormula=function(e,o){for(var t=/[A-Z]/,n=/[0-9]/,r="",l=null,s=null,i="",a=0;a<e.length;a++)t.exec(e[a])?(l=1,s=0,i+=e[a]):n.exec(e[a])?(s=l?1:0,i+=e[a]):(l&&s&&(i=o[i]?o[i]:i),r+=i,r+=e[a],l=0,s=0,i="");return i&&(l&&s&&(i=o[i]?o[i]:i),r+=i),r};var secureFormula=function(e){for(var o="",t=0,n=0;n<e.length;n++)'"'==e[n]&&(t=0==t?1:0),o+=1==t?e[n]:e[n].toUpperCase();return o};obj.executeFormula=function(expression,x,y){var formulaResults=[],formulaLoopProtection=[],execute=function(expression,x,y){var parentId=jexcel.getColumnNameFromId([x,y]);if(formulaLoopProtection[parentId])return console.error("Reference loop detected"),"#ERROR";formulaLoopProtection[parentId]=!0;var tokensUpdate=function(e){for(var o=0;o<e.length;o++){var t=[],n=e[o].split(":"),r=jexcel.getIdFromColumnName(n[0],!0),l=jexcel.getIdFromColumnName(n[1],!0);if(r[0]<=l[0])var s=r[0],i=l[0];else s=l[0],i=r[0];if(r[1]<=l[1])var a=r[1],c=l[1];else a=l[1],c=r[1];for(var u=a;u<=c;u++)for(var d=s;d<=i;d++)t.push(jexcel.getColumnNameFromId([d,u]));expression=expression.replace(e[o],t.join(","))}};expression=expression.replace(/\$?([A-Z]+)\$?([0-9]+)/g,"$1$2");var tokens=expression.match(/([A-Z]+[0-9]+)\:([A-Z]+[0-9]+)/g);tokens&&tokens.length&&tokensUpdate(tokens);var tokens=expression.match(/([A-Z]+[0-9]+)/g);if(tokens&&tokens.indexOf(parentId)>-1)return console.error("Self Reference detected"),"#ERROR";var formulaExpressions={};if(tokens)for(var i=0;i<tokens.length;i++)if(obj.formula[tokens[i]]||(obj.formula[tokens[i]]=[]),obj.formula[tokens[i]].indexOf(parentId)<0&&obj.formula[tokens[i]].push(parentId),eval("typeof("+tokens[i]+') == "undefined"')){var position=jexcel.getIdFromColumnName(tokens[i],1);if(void 0!==obj.options.data[position[1]]&&void 0!==obj.options.data[position[1]][position[0]])var value=obj.options.data[position[1]][position[0]];else var value="";if("="==(""+value).substr(0,1)&&(void 0!==formulaResults[tokens[i]]?value=formulaResults[tokens[i]]:(value=execute(value,position[0],position[1]),formulaResults[tokens[i]]=value)),""==(""+value).trim())formulaExpressions[tokens[i]]=null;else if(value==Number(value)&&1==obj.options.autoCasting)formulaExpressions[tokens[i]]=Number(value);else{var number=obj.parseNumber(value,position[0]);1==obj.options.autoCasting&&number?formulaExpressions[tokens[i]]=number:formulaExpressions[tokens[i]]='"'+value+'"'}}try{var res=jexcel.formula(expression.substr(1),formulaExpressions,x,y,obj)}catch(e){var res="#ERROR";console.log(e)}return res};return execute(expression,x,y)},obj.parseNumber=function(e,o){var t=o&&obj.options.columns[o].decimal?obj.options.columns[o].decimal:".",n=""+e;if((n=n.split(t))[0]=n[0].match(/[+-]?[0-9]/g),n[0]&&(n[0]=n[0].join("")),n[1]&&(n[1]=n[1].match(/[0-9]*/g).join("")),n[0]&&Number.isInteger(Number(n[0])))if(n[1])e=Number(n[0]+"."+n[1]);else e=Number(n[0]+".00");else e=null;return e},obj.row=function(e){},obj.col=function(e){},obj.up=function(e,o){if(e?obj.selectedCell[3]>0&&obj.up.visible(1,o?0:1):(obj.selectedCell[1]>0&&obj.up.visible(0,o?0:1),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),1==obj.options.lazyLoading)if(0==obj.selectedCell[1]||0==obj.selectedCell[3])obj.loadPage(0),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]);else if(obj.loadValidation())obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]);else{var t=parseInt(obj.tbody.firstChild.getAttribute("data-y"));obj.selectedCell[1]-t<30&&(obj.loadUp(),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]))}else if(obj.options.pagination>0){var n=obj.whichPage(obj.selectedCell[3]);n!=obj.pageNumber&&obj.page(n)}obj.updateScroll(1)},obj.up.visible=function(e,o){if(0==e)var t=parseInt(obj.selectedCell[0]),n=parseInt(obj.selectedCell[1]);else t=parseInt(obj.selectedCell[2]),n=parseInt(obj.selectedCell[3]);if(0==o){for(var r=0;r<n;r++)if("none"!=obj.records[r][t].style.display&&"none"!=obj.rows[r].style.display){n=r;break}}else n=obj.up.get(t,n);0==e?(obj.selectedCell[0]=t,obj.selectedCell[1]=n):(obj.selectedCell[2]=t,obj.selectedCell[3]=n)},obj.up.get=function(e,o){e=parseInt(e);for(var t=(o=parseInt(o))-1;t>=0;t--)if("none"!=obj.records[t][e].style.display&&"none"!=obj.rows[t].style.display){if(obj.records[t][e].getAttribute("data-merged")&&obj.records[t][e]==obj.records[o][e])continue;o=t;break}return o},obj.down=function(e,o){if(e?obj.selectedCell[3]<obj.records.length-1&&obj.down.visible(1,o?0:1):(obj.selectedCell[1]<obj.records.length-1&&obj.down.visible(0,o?0:1),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),1==obj.options.lazyLoading)obj.selectedCell[1]==obj.records.length-1||obj.selectedCell[3]==obj.records.length-1?(obj.loadPage(-1),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3])):obj.loadValidation()?obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]):parseInt(obj.tbody.lastChild.getAttribute("data-y"))-obj.selectedCell[3]<30&&(obj.loadDown(),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]));else if(obj.options.pagination>0){var t=obj.whichPage(obj.selectedCell[3]);t!=obj.pageNumber&&obj.page(t)}obj.updateScroll(3)},obj.down.visible=function(e,o){if(0==e)var t=parseInt(obj.selectedCell[0]),n=parseInt(obj.selectedCell[1]);else t=parseInt(obj.selectedCell[2]),n=parseInt(obj.selectedCell[3]);if(0==o){for(var r=obj.rows.length-1;r>n;r--)if("none"!=obj.records[r][t].style.display&&"none"!=obj.rows[r].style.display){n=r;break}}else n=obj.down.get(t,n);0==e?(obj.selectedCell[0]=t,obj.selectedCell[1]=n):(obj.selectedCell[2]=t,obj.selectedCell[3]=n)},obj.down.get=function(e,o){e=parseInt(e);for(var t=(o=parseInt(o))+1;t<obj.rows.length;t++)if("none"!=obj.records[t][e].style.display&&"none"!=obj.rows[t].style.display){if(obj.records[t][e].getAttribute("data-merged")&&obj.records[t][e]==obj.records[o][e])continue;o=t;break}return o},obj.right=function(e,o){e?obj.selectedCell[2]<obj.headers.length-1&&obj.right.visible(1,o?0:1):(obj.selectedCell[0]<obj.headers.length-1&&obj.right.visible(0,o?0:1),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),obj.updateScroll(2)},obj.right.visible=function(e,o){if(0==e)var t=parseInt(obj.selectedCell[0]),n=parseInt(obj.selectedCell[1]);else t=parseInt(obj.selectedCell[2]),n=parseInt(obj.selectedCell[3]);if(0==o){for(var r=obj.headers.length-1;r>t;r--)if("none"!=obj.records[n][r].style.display){t=r;break}}else t=obj.right.get(t,n);0==e?(obj.selectedCell[0]=t,obj.selectedCell[1]=n):(obj.selectedCell[2]=t,obj.selectedCell[3]=n)},obj.right.get=function(e,o){e=parseInt(e),o=parseInt(o);for(var t=e+1;t<obj.headers.length;t++)if("none"!=obj.records[o][t].style.display){if(obj.records[o][t].getAttribute("data-merged")&&obj.records[o][t]==obj.records[o][e])continue;e=t;break}return e},obj.left=function(e,o){e?obj.selectedCell[2]>0&&obj.left.visible(1,o?0:1):(obj.selectedCell[0]>0&&obj.left.visible(0,o?0:1),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),obj.updateScroll(0)},obj.left.visible=function(e,o){if(0==e)var t=parseInt(obj.selectedCell[0]),n=parseInt(obj.selectedCell[1]);else t=parseInt(obj.selectedCell[2]),n=parseInt(obj.selectedCell[3]);if(0==o){for(var r=0;r<t;r++)if("none"!=obj.records[n][r].style.display){t=r;break}}else t=obj.left.get(t,n);0==e?(obj.selectedCell[0]=t,obj.selectedCell[1]=n):(obj.selectedCell[2]=t,obj.selectedCell[3]=n)},obj.left.get=function(e,o){e=parseInt(e),o=parseInt(o);for(var t=e-1;t>=0;t--)if("none"!=obj.records[o][t].style.display){if(obj.records[o][t].getAttribute("data-merged")&&obj.records[o][t]==obj.records[o][e])continue;e=t;break}return e},obj.first=function(e,o){if(e?o?obj.selectedCell[3]=0:obj.left.visible(1,0):(o?obj.selectedCell[1]=0:obj.left.visible(0,0),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),1!=obj.options.lazyLoading||0!=obj.selectedCell[1]&&0!=obj.selectedCell[3]){if(obj.options.pagination>0){var t=obj.whichPage(obj.selectedCell[3]);t!=obj.pageNumber&&obj.page(t)}}else obj.loadPage(0);obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),obj.updateScroll(1)},obj.last=function(e,o){if(e?o?obj.selectedCell[3]=obj.records.length-1:obj.right.visible(1,0):(o?obj.selectedCell[1]=obj.records.length-1:obj.right.visible(0,0),obj.selectedCell[2]=obj.selectedCell[0],obj.selectedCell[3]=obj.selectedCell[1]),1!=obj.options.lazyLoading||obj.selectedCell[1]!=obj.records.length-1&&obj.selectedCell[3]!=obj.records.length-1){if(obj.options.pagination>0){var t=obj.whichPage(obj.selectedCell[3]);t!=obj.pageNumber&&obj.page(t)}}else obj.loadPage(-1);obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3]),obj.updateScroll(3)},obj.selectAll=function(){obj.selectedCell||(obj.selectedCell=[]),obj.selectedCell[0]=0,obj.selectedCell[1]=0,obj.selectedCell[2]=obj.headers.length-1,obj.selectedCell[3]=obj.records.length-1,obj.updateSelectionFromCoords(obj.selectedCell[0],obj.selectedCell[1],obj.selectedCell[2],obj.selectedCell[3])},obj.loadPage=function(e){if(1!=obj.options.search&&1!=obj.options.filters||!obj.results)o=obj.rows;else var o=obj.results;var t=100;null!=e&&-1!=e||(e=Math.ceil(o.length/t)-1);var n=e*t,r=e*t+t;r>o.length&&(r=o.length),(n=r-100)<0&&(n=0);for(var l=n;l<r;l++)1!=obj.options.search&&1!=obj.options.filters||!obj.results?obj.tbody.appendChild(obj.rows[l]):obj.tbody.appendChild(obj.rows[o[l]]),obj.tbody.children.length>t&&obj.tbody.removeChild(obj.tbody.firstChild)},obj.loadUp=function(){if(1!=obj.options.search&&1!=obj.options.filters||!obj.results)e=obj.rows;else var e=obj.results;var o=0;if(e.length>100){var t=parseInt(obj.tbody.firstChild.getAttribute("data-y"));if(1!=obj.options.search&&1!=obj.options.filters||!obj.results||(t=e.indexOf(t)),t>0)for(var n=0;n<30;n++)(t-=1)>-1&&(1!=obj.options.search&&1!=obj.options.filters||!obj.results?obj.tbody.insertBefore(obj.rows[t],obj.tbody.firstChild):obj.tbody.insertBefore(obj.rows[e[t]],obj.tbody.firstChild),obj.tbody.children.length>100&&(obj.tbody.removeChild(obj.tbody.lastChild),o=1))}return o},obj.loadDown=function(){if(1!=obj.options.search&&1!=obj.options.filters||!obj.results)e=obj.rows;else var e=obj.results;var o=0;if(e.length>100){var t=parseInt(obj.tbody.lastChild.getAttribute("data-y"));if(1!=obj.options.search&&1!=obj.options.filters||!obj.results||(t=e.indexOf(t)),t<obj.rows.length-1)for(var n=0;n<=30;n++)t<e.length&&(1!=obj.options.search&&1!=obj.options.filters||!obj.results?obj.tbody.appendChild(obj.rows[t]):obj.tbody.appendChild(obj.rows[e[t]]),obj.tbody.children.length>100&&(obj.tbody.removeChild(obj.tbody.firstChild),o=1)),t+=1}return o},obj.loadValidation=function(){if(obj.selectedCell){var e=parseInt(obj.tbody.firstChild.getAttribute("data-y"))/100,o=parseInt(obj.selectedCell[3]/100),t=parseInt(obj.rows.length/100);if(e!=o&&o<=t&&!Array.prototype.indexOf.call(obj.tbody.children,obj.rows[obj.selectedCell[3]]))return obj.loadPage(o),!0}return!1},obj.resetSearch=function(){obj.searchInput.value="",obj.search(""),obj.results=null},obj.search=function(e){if(obj.options.filters&&obj.resetFilters(),obj.resetSelection(),obj.pageNumber=0,obj.results=[],e){var o=function(e){-1==obj.results.indexOf(e)&&obj.results.push(e)},t=e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");t=new RegExp(t,"i"),obj.options.data.forEach((function(e,n){if(function(e,o,t){for(var n=0;n<e.length;n++)if((""+e[n]).toLowerCase().search(o)>=0||(""+obj.records[t][n].innerHTML).toLowerCase().search(o)>=0)return!0;return!1}(e,t,n)){var r=obj.isRowMerged(n);if(r.length)for(var l=0;l<r.length;l++)for(var s=jexcel.getIdFromColumnName(r[l],!0),i=0;i<obj.options.mergeCells[r[l]][1];i++)o(s[1]+i);else o(n)}}))}else obj.results=null;return obj.updateResult()},obj.updateResult=function(){var e,o=0;for(e=1==obj.options.lazyLoading?100:obj.options.pagination>0?obj.options.pagination:obj.results?obj.results.length:obj.rows.length;obj.tbody.firstChild;)obj.tbody.removeChild(obj.tbody.firstChild);for(var t=0;t<obj.rows.length;t++)!obj.results||obj.results.indexOf(t)>-1?(o<e&&(obj.tbody.appendChild(obj.rows[t]),o++),obj.rows[t].style.display=""):obj.rows[t].style.display="none";return obj.options.pagination>0&&obj.updatePagination(),obj.updateCornerPosition(),e},obj.whichPage=function(e){return 1!=obj.options.search&&1!=obj.options.filters||!obj.results||(e=obj.results.indexOf(e)),Math.ceil((parseInt(e)+1)/parseInt(obj.options.pagination))-1},obj.page=function(e){var o=obj.pageNumber;if(1!=obj.options.search&&1!=obj.options.filters||!obj.results)t=obj.rows;else var t=obj.results;var n=parseInt(obj.options.pagination);null!=e&&-1!=e||(e=Math.ceil(t.length/n)-1),obj.pageNumber=e;var r=e*n,l=e*n+n;for(l>t.length&&(l=t.length),r<0&&(r=0);obj.tbody.firstChild;)obj.tbody.removeChild(obj.tbody.firstChild);for(var s=r;s<l;s++)1!=obj.options.search&&1!=obj.options.filters||!obj.results?obj.tbody.appendChild(obj.rows[s]):obj.tbody.appendChild(obj.rows[t[s]]);obj.options.pagination>0&&obj.updatePagination(),obj.updateCornerPosition(),obj.dispatch("onchangepage",el,e,o)},obj.updatePagination=function(){if(obj.pagination.children[0].innerHTML="",obj.pagination.children[1].innerHTML="",obj.options.pagination){if(1!=obj.options.search&&1!=obj.options.filters||!obj.results)e=obj.rows.length;else var e=obj.results.length;if(e){var o=Math.ceil(e/obj.options.pagination);if(obj.pageNumber<6)var t=1,n=o<10?o:10;else o-obj.pageNumber<5?(n=o,(t=o-9)<1&&(t=1)):(t=obj.pageNumber-4,n=obj.pageNumber+5);t>1&&((l=document.createElement("div")).className="jexcel_page",l.innerHTML="<",l.title=1,obj.pagination.children[1].appendChild(l));for(var r=t;r<=n;r++){var l;(l=document.createElement("div")).className="jexcel_page",l.innerHTML=r,obj.pagination.children[1].appendChild(l),obj.pageNumber==r-1&&l.classList.add("jexcel_page_selected")}n<o&&((l=document.createElement("div")).className="jexcel_page",l.innerHTML=">",l.title=o,obj.pagination.children[1].appendChild(l)),obj.pagination.children[0].innerHTML=function(e){var o=Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,(function(e,t){return void 0!==o[t]?o[t]:e}))}(obj.options.text.showingPage,obj.pageNumber+1,o)}else obj.pagination.children[0].innerHTML=obj.options.text.noRecordsFound}},obj.download=function(e){if(0==obj.options.allowExport)console.error("Export not allowed");else{var o="";o+=obj.copy(!1,obj.options.csvDelimiter,!0,e,!0);var t=new Blob(["\ufeff"+o],{type:"text/csv;charset=utf-8;"});if(window.navigator&&window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(t,obj.options.csvFileName+".csv");else{var n=document.createElement("a"),r=URL.createObjectURL(t);n.href=r,n.setAttribute("download",obj.options.csvFileName+".csv"),document.body.appendChild(n),n.click(),n.parentNode.removeChild(n)}}},obj.setHistory=function(e){if(1!=obj.ignoreHistory){var o=++obj.historyIndex;obj.history=obj.history=obj.history.slice(0,o+1),obj.history[o]=e}},obj.copy=function(e,o,t,n,r){o||(o="\t");for(var l=new RegExp(o,"ig"),s=[],i=[],a=[],c=[],u=[],d=obj.options.data[0].length,j=obj.options.data.length,b="",p=!1,h="",g="",f=0,m=0,C=0,x=0,v=!0,y=0;y<j;y++)for(var w=0;w<d;w++)e&&!obj.records[y][w].classList.contains("highlight")||(C<=w&&(C=w),x<=y&&(x=y));if(d===C+1&&j===x+1&&(v=!1),r&&1==obj.options.includeHeadersOnDownload||!r&&1==obj.options.includeHeadersOnCopy&&!v||n){if(obj.options.nestedHeaders&&obj.options.nestedHeaders.length>0)for(b=obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0]?obj.options.nestedHeaders:[obj.options.nestedHeaders],y=0;y<b.length;y++){var A=[];for(w=0;w<b[y].length;w++){var F=parseInt(b[y][w].colspan);A.push(b[y][w].title);for(var E=0;E<F-1;E++)A.push("")}g+=A.join(o)+"\r\n"}p=!0}for(obj.style=[],y=0;y<j;y++){for(i=[],a=[],w=0;w<d;w++)if(!e||obj.records[y][w].classList.contains("highlight")){1==p&&s.push(obj.headers[w].textContent);var L=obj.options.data[y][w];if(L.match&&(L.match(l)||L.includes(o)||L.includes("\n"))&&(L.includes('"')&&(L=L.replace(new RegExp('"',"g"),'""')),L='"'+L+'"'),i.push(L),"checkbox"==obj.options.columns[w].type||"radio"==obj.options.columns[w].type)var D=L;else(D=1==obj.options.stripHTMLOnCopy?obj.records[y][w].textContent:obj.records[y][w].innerHTML).match&&(D.match(l)||D.match(/,/g)||D.match(/\n/)||D.match(/\"/))&&(D='"'+(D=D.replace(new RegExp('"',"g"),'""'))+'"');a.push(D),b=(b=obj.records[y][w].getAttribute("style")).replace("display: none;",""),obj.style.push(b||"")}i.length&&(p&&(f=i.length,c.push(s.join(o))),c.push(i.join(o))),a.length&&(m++,p&&(u.push(s.join(o)),p=!1),u.push(a.join(o)))}d==f&&j==m&&(h=g);var S=h+c.join("\r\n"),I=h+u.join("\r\n");if(t||(1==obj.options.copyCompatibility?obj.textarea.value=I:obj.textarea.value=S,obj.textarea.select(),document.execCommand("copy")),1==obj.options.copyCompatibility?obj.data=I:obj.data=S,obj.hashString=obj.hash(obj.data),!t){if(obj.removeCopyingSelection(),obj.highlighted)for(w=0;w<obj.highlighted.length;w++)obj.highlighted[w].classList.add("copying"),obj.highlighted[w].classList.contains("highlight-left")&&obj.highlighted[w].classList.add("copying-left"),obj.highlighted[w].classList.contains("highlight-right")&&obj.highlighted[w].classList.add("copying-right"),obj.highlighted[w].classList.contains("highlight-top")&&obj.highlighted[w].classList.add("copying-top"),obj.highlighted[w].classList.contains("highlight-bottom")&&obj.highlighted[w].classList.add("copying-bottom");obj.dispatch("oncopy",el,1==obj.options.copyCompatibility?u:c,obj.hashString)}return obj.data},obj.paste=function(e,o,t){var n=obj.dispatch("onbeforepaste",el,t,e,o);if(!1===n)return!1;n&&(t=n);var r=obj.hash(t),l=r==obj.hashString?obj.style:null;if(1==obj.options.copyCompatibility&&r==obj.hashString&&(t=obj.data),t=obj.parseCSV(t,"\t"),null!=e&&null!=o&&t){for(var s=0,i=0,a=[],c={},u={},d=0,j=parseInt(e),b=parseInt(o),p=null;p=t[i];){for(s=0,j=parseInt(e);null!=p[s];){var h=obj.updateCell(j,b,p[s]);if(a.push(h),obj.updateFormulaChain(j,b,a),l&&l[d]){var g=jexcel.getColumnNameFromId([j,b]);c[g]=l[d],u[g]=obj.getStyle(g),obj.records[b][j].setAttribute("style",l[d]),d++}if(null!=p[++s]){if(j>=obj.headers.length-1){if(1!=obj.options.allowInsertColumn)break;obj.insertColumn()}j=obj.right.get(j,b)}}if(t[++i]){if(b>=obj.rows.length-1){if(1!=obj.options.allowInsertRow)break;obj.insertRow()}b=obj.down.get(e,b)}}obj.updateSelectionFromCoords(e,o,j,b),obj.setHistory({action:"setValue",records:a,selection:obj.selectedCell,newStyle:c,oldStyle:u}),obj.updateTable(),obj.dispatch("onpaste",el,t),obj.onafterchanges(el,a)}obj.removeCopyingSelection()},obj.removeCopyingSelection=function(){for(var e=document.querySelectorAll(".jexcel .copying"),o=0;o<e.length;o++)e[o].classList.remove("copying"),e[o].classList.remove("copying-left"),e[o].classList.remove("copying-right"),e[o].classList.remove("copying-top"),e[o].classList.remove("copying-bottom")},obj.historyProcessRow=function(e,o){var t=o.insertBefore?+o.rowNumber:o.rowNumber+1;if(1==obj.options.search&&obj.results&&obj.results.length!=obj.rows.length&&obj.resetSearch(),1==e){for(var n=o.numOfRows,r=t;r<n+t;r++)obj.rows[r].parentNode.removeChild(obj.rows[r]);obj.records.splice(t,n),obj.options.data.splice(t,n),obj.rows.splice(t,n),obj.conditionalSelectionUpdate(1,t,n+t-1)}else{obj.records=jexcel.injectArray(obj.records,t,o.rowRecords),obj.options.data=jexcel.injectArray(obj.options.data,t,o.rowData),obj.rows=jexcel.injectArray(obj.rows,t,o.rowNode);var l=0;for(r=t;r<o.numOfRows+t;r++)obj.tbody.insertBefore(o.rowNode[l],obj.tbody.children[r]),l++}obj.options.pagination>0&&obj.page(obj.pageNumber),obj.updateTableReferences()},obj.historyProcessColumn=function(e,o){var t=o.insertBefore?o.columnNumber:o.columnNumber+1;if(1==e){var n=o.numOfColumns;obj.options.columns.splice(t,n);for(var r=t;r<n+t;r++)obj.headers[r].parentNode.removeChild(obj.headers[r]),obj.colgroup[r].parentNode.removeChild(obj.colgroup[r]);obj.headers.splice(t,n),obj.colgroup.splice(t,n);for(var l=0;l<o.data.length;l++){for(r=t;r<n+t;r++)obj.records[l][r].parentNode.removeChild(obj.records[l][r]);obj.records[l].splice(t,n),obj.options.data[l].splice(t,n)}if(obj.options.footers)for(l=0;l<obj.options.footers.length;l++)obj.options.footers[l].splice(t,n)}else{obj.options.columns=jexcel.injectArray(obj.options.columns,t,o.columns),obj.headers=jexcel.injectArray(obj.headers,t,o.headers),obj.colgroup=jexcel.injectArray(obj.colgroup,t,o.colgroup);var s=0;for(r=t;r<o.numOfColumns+t;r++)obj.headerContainer.insertBefore(o.headers[s],obj.headerContainer.children[r+1]),obj.colgroupContainer.insertBefore(o.colgroup[s],obj.colgroupContainer.children[r+1]),s++;for(l=0;l<o.data.length;l++)for(obj.options.data[l]=jexcel.injectArray(obj.options.data[l],t,o.data[l]),obj.records[l]=jexcel.injectArray(obj.records[l],t,o.records[l]),s=0,r=t;r<o.numOfColumns+t;r++)obj.rows[l].insertBefore(o.records[l][s],obj.rows[l].children[r+1]),s++;if(obj.options.footers)for(l=0;l<obj.options.footers.length;l++)obj.options.footers[l]=jexcel.injectArray(obj.options.footers[l],t,o.footers[l])}if(obj.options.nestedHeaders&&obj.options.nestedHeaders.length>0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(l=0;l<obj.options.nestedHeaders.length;l++){if(1==e)var i=parseInt(obj.options.nestedHeaders[l][obj.options.nestedHeaders[l].length-1].colspan)-o.numOfColumns;else i=parseInt(obj.options.nestedHeaders[l][obj.options.nestedHeaders[l].length-1].colspan)+o.numOfColumns;obj.options.nestedHeaders[l][obj.options.nestedHeaders[l].length-1].colspan=i,obj.thead.children[l].children[obj.thead.children[l].children.length-1].setAttribute("colspan",i)}else i=1==e?parseInt(obj.options.nestedHeaders[0].colspan)-o.numOfColumns:parseInt(obj.options.nestedHeaders[0].colspan)+o.numOfColumns,obj.options.nestedHeaders[0].colspan=i,obj.thead.children[0].children[obj.thead.children[0].children.length-1].setAttribute("colspan",i);obj.updateTableReferences()},obj.undo=function(){var e=!!obj.ignoreEvents,o=!!obj.ignoreHistory;obj.ignoreEvents=!0,obj.ignoreHistory=!0;var t=[];if(obj.historyIndex>=0){var n=obj.history[obj.historyIndex--];if("insertRow"==n.action)obj.historyProcessRow(1,n);else if("deleteRow"==n.action)obj.historyProcessRow(0,n);else if("insertColumn"==n.action)obj.historyProcessColumn(1,n);else if("deleteColumn"==n.action)obj.historyProcessColumn(0,n);else if("moveRow"==n.action)obj.moveRow(n.newValue,n.oldValue);else if("moveColumn"==n.action)obj.moveColumn(n.newValue,n.oldValue);else if("setMerge"==n.action)obj.removeMerge(n.column,n.data);else if("setStyle"==n.action)obj.setStyle(n.oldValue,null,null,1);else if("setWidth"==n.action)obj.setWidth(n.column,n.oldValue);else if("setHeight"==n.action)obj.setHeight(n.row,n.oldValue);else if("setHeader"==n.action)obj.setHeader(n.column,n.oldValue);else if("setComments"==n.action)obj.setComments(n.column,n.oldValue[0],n.oldValue[1]);else if("orderBy"==n.action){for(var r=[],l=0;l<n.rows.length;l++)r[n.rows[l]]=l;obj.updateOrderArrow(n.column,n.order?0:1),obj.updateOrder(r)}else if("setValue"==n.action){for(var s=0;s<n.records.length;s++)t.push({x:n.records[s].x,y:n.records[s].y,newValue:n.records[s].oldValue}),n.oldStyle&&obj.resetStyle(n.oldStyle);obj.setValue(t),n.selection&&obj.updateSelectionFromCoords(n.selection[0],n.selection[1],n.selection[2],n.selection[3])}}obj.ignoreEvents=e,obj.ignoreHistory=o,obj.dispatch("onundo",el,n)},obj.redo=function(){var e=!!obj.ignoreEvents,o=!!obj.ignoreHistory;if(obj.ignoreEvents=!0,obj.ignoreHistory=!0,obj.historyIndex<obj.history.length-1){var t=obj.history[++obj.historyIndex];if("insertRow"==t.action)obj.historyProcessRow(0,t);else if("deleteRow"==t.action)obj.historyProcessRow(1,t);else if("insertColumn"==t.action)obj.historyProcessColumn(0,t);else if("deleteColumn"==t.action)obj.historyProcessColumn(1,t);else if("moveRow"==t.action)obj.moveRow(t.oldValue,t.newValue);else if("moveColumn"==t.action)obj.moveColumn(t.oldValue,t.newValue);else if("setMerge"==t.action)obj.setMerge(t.column,t.colspan,t.rowspan,1);else if("setStyle"==t.action)obj.setStyle(t.newValue,null,null,1);else if("setWidth"==t.action)obj.setWidth(t.column,t.newValue);else if("setHeight"==t.action)obj.setHeight(t.row,t.newValue);else if("setHeader"==t.action)obj.setHeader(t.column,t.newValue);else if("setComments"==t.action)obj.setComments(t.column,t.newValue[0],t.newValue[1]);else if("orderBy"==t.action)obj.updateOrderArrow(t.column,t.order),obj.updateOrder(t.rows);else if("setValue"==t.action){obj.setValue(t.records);for(var n=0;n<t.records.length;n++)t.oldStyle&&obj.resetStyle(t.newStyle);t.selection&&obj.updateSelectionFromCoords(t.selection[0],t.selection[1],t.selection[2],t.selection[3])}}obj.ignoreEvents=e,obj.ignoreHistory=o,obj.dispatch("onredo",el,t)},obj.getDropDownValue=function(e,o){var t=[];if(obj.options.columns[e]&&obj.options.columns[e].source){for(var n=[],r=obj.options.columns[e].source,l=0;l<r.length;l++)"object"==typeof r[l]?n[r[l].id]=r[l].name:n[r[l]]=r[l];var s=Array.isArray(o)?o:(""+o).split(";");for(l=0;l<s.length;l++)"object"==typeof s[l]?t.push(n[s[l].id]):n[s[l]]&&t.push(n[s[l]])}else console.error("Invalid column");return t.length>0?t.join("; "):""},obj.parseCSV=function(e,o){e=e.replace(/\r?\n$|\r$|\n$/g,""),e+="\n",o=o||",";const t=new RegExp("^"+" \t\v\0".replace(o,"")+"*");let n=[],r=[],l=0,s="",i=!1,a=!1;const c=e.length;for(let u=0;u<c;u++){let d=e[u],j=u+1<c?e[u+1]:"";if('"'===d)if(i)if('"'===j)s+=d,++u;else if(j!==o&&"\r"!==j&&"\n"!==j){let n=u+1;for(;void 0!==e[n]&&""===e[n].replace(t,"");n++);e[n]===o?(i=!1,u=n):(s+=d,i=!1)}else i=!1;else""===s.replace(t,"")?(i=!0,a=!0):s+=d;else d!==o&&"\n"!==d&&"\r"!==d||i?s+=d:(r[l]=a?s:s.trim(),s="",a=!1,++l,"\n"!==d&&"\r"!==d||(n.push(r),r=[],l=0,"\r"===d&&"\n"===j&&++u))}return n},obj.hash=function(e){var o,t=0;if(0===e.length)return t;for(o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;return t},obj.onafterchanges=function(e,o){obj.dispatch("onafterchanges",e,o)},obj.destroy=function(){jexcel.destroy(el)},obj.init=function(){jexcel.current=obj,"function"==typeof jexcel.build&&(obj.options.root?jexcel.build(obj.options.root):(jexcel.build(document),jexcel.build=null)),el.setAttribute("tabindex",1),el.addEventListener("focus",(function(e){jexcel.current&&!obj.selectedCell&&(obj.updateSelectionFromCoords(0,0,0,0),obj.left())})),obj.options.csv?(1==obj.options.loadingSpin&&jSuites.loading.show(),jSuites.ajax({url:obj.options.csv,method:obj.options.method,data:obj.options.requestVariables,dataType:"text",success:function(e){var o=obj.parseCSV(e,obj.options.csvDelimiter);if(1==obj.options.csvHeaders&&o.length>0)for(var t=o.shift(),n=0;n<t.length;n++)obj.options.columns[n]||(obj.options.columns[n]={type:"text",align:obj.options.defaultColAlign,width:obj.options.defaultColWidth}),void 0===obj.options.columns[n].title&&(obj.options.columns[n].title=t[n]);obj.options.data=o,obj.prepareTable(),1==obj.options.loadingSpin&&jSuites.loading.hide()}})):obj.options.url?(1==obj.options.loadingSpin&&jSuites.loading.show(),jSuites.ajax({url:obj.options.url,method:obj.options.method,data:obj.options.requestVariables,dataType:"json",success:function(e){obj.options.data=e.data?e.data:e,obj.prepareTable(),1==obj.options.loadingSpin&&jSuites.loading.hide()}})):obj.prepareTable()},options&&null!=options.contextMenu?obj.options.contextMenu=options.contextMenu:obj.options.contextMenu=function(e,o,t,n){var r=[];if(null==t)1==obj.options.allowInsertColumn&&r.push({title:obj.options.text.insertANewColumnBefore,onclick:function(){obj.insertColumn(1,parseInt(o),1)}}),1==obj.options.allowInsertColumn&&r.push({title:obj.options.text.insertANewColumnAfter,onclick:function(){obj.insertColumn(1,parseInt(o),0)}}),1==obj.options.allowDeleteColumn&&r.push({title:obj.options.text.deleteSelectedColumns,onclick:function(){obj.deleteColumn(obj.getSelectedColumns().length?void 0:parseInt(o))}}),1==obj.options.allowRenameColumn&&r.push({title:obj.options.text.renameThisColumn,onclick:function(){obj.setHeader(o)}}),1==obj.options.columnSorting&&(r.push({type:"line"}),r.push({title:obj.options.text.orderAscending,onclick:function(){obj.orderBy(o,0)}}),r.push({title:obj.options.text.orderDescending,onclick:function(){obj.orderBy(o,1)}}));else if(1==obj.options.allowInsertRow&&(r.push({title:obj.options.text.insertANewRowBefore,onclick:function(){obj.insertRow(1,parseInt(t),1)}}),r.push({title:obj.options.text.insertANewRowAfter,onclick:function(){obj.insertRow(1,parseInt(t))}})),1==obj.options.allowDeleteRow&&r.push({title:obj.options.text.deleteSelectedRows,onclick:function(){obj.deleteRow(obj.getSelectedRows().length?void 0:parseInt(t))}}),o&&1==obj.options.allowComments){r.push({type:"line"});var l=obj.records[t][o].getAttribute("title")||"";r.push({title:l?obj.options.text.editComments:obj.options.text.addComments,onclick:function(){var e=prompt(obj.options.text.comments,l);e&&obj.setComments([o,t],e)}}),l&&r.push({title:obj.options.text.clearComments,onclick:function(){obj.setComments([o,t],"")}})}return r.push({type:"line"}),r.push({title:obj.options.text.copy,shortcut:"Ctrl + C",onclick:function(){obj.copy(!0)}}),navigator&&navigator.clipboard&&r.push({title:obj.options.text.paste,shortcut:"Ctrl + V",onclick:function(){obj.selectedCell&&navigator.clipboard.readText().then((function(e){e&&jexcel.current.paste(obj.selectedCell[0],obj.selectedCell[1],e)}))}}),obj.options.allowExport&&r.push({title:obj.options.text.saveAs,shortcut:"Ctrl + S",onclick:function(){obj.download()}}),obj.options.about&&r.push({title:obj.options.text.about,onclick:function(){!0===obj.options.about?alert(Version().print()):alert(obj.options.about)}}),r},obj.scrollControls=function(e){obj.wheelControls(),obj.options.freezeColumns>0&&obj.content.scrollLeft!=scrollLeft&&obj.updateFreezePosition(),1!=obj.options.lazyLoading&&1!=obj.options.tableOverflow||obj.edition&&"jdropdown"!=e.target.className.substr(0,9)&&obj.closeEditor(obj.edition[0],!0)},obj.wheelControls=function(e){1==obj.options.lazyLoading&&null==jexcel.timeControlLoading&&(jexcel.timeControlLoading=setTimeout((function(){obj.content.scrollTop+obj.content.clientHeight>=obj.content.scrollHeight-10?obj.loadDown()&&(obj.content.scrollTop+obj.content.clientHeight>obj.content.scrollHeight-10&&(obj.content.scrollTop=obj.content.scrollTop-obj.content.clientHeight),obj.updateCornerPosition()):obj.content.scrollTop<=obj.content.clientHeight&&obj.loadUp()&&(obj.content.scrollTop<10&&(obj.content.scrollTop=obj.content.scrollTop+obj.content.clientHeight),obj.updateCornerPosition()),jexcel.timeControlLoading=null}),100))},obj.getFreezeWidth=function(){var e=0;if(obj.options.freezeColumns>0)for(var o=0;o<obj.options.freezeColumns;o++)e+=parseInt(obj.options.columns[o].width);return e};var scrollLeft=0;return obj.updateFreezePosition=function(){var e=0;if((scrollLeft=obj.content.scrollLeft)>50)for(var o=0;o<obj.options.freezeColumns;o++){o>0&&"hidden"!==obj.options.columns[o-1].type&&(e+=parseInt(obj.options.columns[o-1].width)),obj.headers[o].classList.add("jexcel_freezed"),obj.headers[o].style.left=e+"px";for(var t=0;t<obj.rows.length;t++)if(obj.rows[t]&&obj.records[t][o]){var n=scrollLeft+(o>0?obj.records[t][o-1].style.width:0)-51+"px";obj.records[t][o].classList.add("jexcel_freezed"),obj.records[t][o].style.left=n}}else for(o=0;o<obj.options.freezeColumns;o++)for(obj.headers[o].classList.remove("jexcel_freezed"),obj.headers[o].style.left="",t=0;t<obj.rows.length;t++)obj.records[t][o]&&(obj.records[t][o].classList.remove("jexcel_freezed"),obj.records[t][o].style.left="");obj.updateCornerPosition()},el.addEventListener("DOMMouseScroll",obj.wheelControls),el.addEventListener("mousewheel",obj.wheelControls),el.jexcel=obj,el.jspreadsheet=obj,obj.init(),obj};jexcel.setDictionary=function(e){jSuites.setDictionary(e)},jexcel.setExtensions=function(e){for(var o=Object.keys(e),t=0;t<o.length;t++)"function"==typeof e[o[t]]&&(jexcel[o[t]]=e[o[t]],jexcel.license&&"function"==typeof e[o[t]].license&&e[o[t]].license(jexcel.license))},"undefined"!=typeof formula&&(jexcel.formula=formula),jexcel.version=Version,jexcel.current=null,jexcel.timeControl=null,jexcel.timeControlLoading=null;const destroyEvents=function(e){e.removeEventListener("mouseup",jexcel.mouseUpControls),e.removeEventListener("mousedown",jexcel.mouseDownControls),e.removeEventListener("mousemove",jexcel.mouseMoveControls),e.removeEventListener("mouseover",jexcel.mouseOverControls),e.removeEventListener("dblclick",jexcel.doubleClickControls),e.removeEventListener("paste",jexcel.pasteControls),e.removeEventListener("contextmenu",jexcel.contextMenuControls),e.removeEventListener("touchstart",jexcel.touchStartControls),e.removeEventListener("touchend",jexcel.touchEndControls),e.removeEventListener("touchcancel",jexcel.touchEndControls),document.removeEventListener("keydown",jexcel.keyDownControls)};var component;return jexcel.destroy=function(e,o){if(e.jexcel){var t=e.jexcel.options.root?e.jexcel.options.root:document;e.removeEventListener("DOMMouseScroll",e.jexcel.scrollControls),e.removeEventListener("mousewheel",e.jexcel.scrollControls),e.jexcel=null,e.innerHTML="",o&&(destroyEvents(t),jexcel=null)}},jexcel.build=function(e){destroyEvents(e),e.addEventListener("mouseup",jexcel.mouseUpControls),e.addEventListener("mousedown",jexcel.mouseDownControls),e.addEventListener("mousemove",jexcel.mouseMoveControls),e.addEventListener("mouseover",jexcel.mouseOverControls),e.addEventListener("dblclick",jexcel.doubleClickControls),e.addEventListener("paste",jexcel.pasteControls),e.addEventListener("contextmenu",jexcel.contextMenuControls),e.addEventListener("touchstart",jexcel.touchStartControls),e.addEventListener("touchend",jexcel.touchEndControls),e.addEventListener("touchcancel",jexcel.touchEndControls),e.addEventListener("touchmove",jexcel.touchEndControls),document.addEventListener("keydown",jexcel.keyDownControls)},jexcel.keyDownControls=function(e){if(jexcel.current){if(jexcel.current.edition)if(27==e.which)jexcel.current.edition&&jexcel.current.closeEditor(jexcel.current.edition[0],!1),e.preventDefault();else if(13==e.which){if("calendar"==jexcel.current.options.columns[jexcel.current.edition[2]].type)jexcel.current.closeEditor(jexcel.current.edition[0],!0);else if("dropdown"==jexcel.current.options.columns[jexcel.current.edition[2]].type||"autocomplete"==jexcel.current.options.columns[jexcel.current.edition[2]].type);else if((1==jexcel.current.options.wordWrap||1==jexcel.current.options.columns[jexcel.current.edition[2]].wordWrap||jexcel.current.options.data[jexcel.current.edition[3]][jexcel.current.edition[2]].length>200)&&e.altKey){var o=jexcel.current.edition[0].children[0],t=jexcel.current.edition[0].children[0].value,n=o.selectionStart;t=t.slice(0,n)+"\n"+t.slice(n),o.value=t,o.focus(),o.selectionStart=n+1,o.selectionEnd=n+1}}else 9==e.which&&(["calendar","html"].includes(jexcel.current.options.columns[jexcel.current.edition[2]].type)?jexcel.current.closeEditor(jexcel.current.edition[0],!0):jexcel.current.edition[0].children[0].blur());if(!jexcel.current.edition&&jexcel.current.selectedCell)if(37==e.which)jexcel.current.left(e.shiftKey,e.ctrlKey),e.preventDefault();else if(39==e.which)jexcel.current.right(e.shiftKey,e.ctrlKey),e.preventDefault();else if(38==e.which)jexcel.current.up(e.shiftKey,e.ctrlKey),e.preventDefault();else if(40==e.which)jexcel.current.down(e.shiftKey,e.ctrlKey),e.preventDefault();else if(36==e.which)jexcel.current.first(e.shiftKey,e.ctrlKey),e.preventDefault();else if(35==e.which)jexcel.current.last(e.shiftKey,e.ctrlKey),e.preventDefault();else if(46==e.which)1==jexcel.current.options.editable&&(jexcel.current.selectedRow?1==jexcel.current.options.allowDeleteRow&&confirm(jexcel.current.options.text.areYouSureToDeleteTheSelectedRows)&&jexcel.current.deleteRow():jexcel.current.selectedHeader?1==jexcel.current.options.allowDeleteColumn&&confirm(jexcel.current.options.text.areYouSureToDeleteTheSelectedColumns)&&jexcel.current.deleteColumn():jexcel.current.setValue(jexcel.current.highlighted,""));else if(13==e.which)e.shiftKey?jexcel.current.up():(1==jexcel.current.options.allowInsertRow&&1==jexcel.current.options.allowManualInsertRow&&jexcel.current.selectedCell[1]==jexcel.current.options.data.length-1&&jexcel.current.insertRow(),jexcel.current.down()),e.preventDefault();else if(9==e.which)e.shiftKey?0==jexcel.current.selectedCell[0]?(jexcel.current.up(),jexcel.current.last()):jexcel.current.left():(1==jexcel.current.options.allowInsertColumn&&1==jexcel.current.options.allowManualInsertColumn&&jexcel.current.selectedCell[0]==jexcel.current.options.data[0].length-1&&jexcel.current.insertColumn(),jexcel.current.selectedCell[0]==jexcel.current.options.data[0].length-1?(jexcel.current.down(),jexcel.current.first()):jexcel.current.right()),e.preventDefault();else if(!e.ctrlKey&&!e.metaKey||e.shiftKey){if(jexcel.current.selectedCell&&1==jexcel.current.options.editable){var r=jexcel.current.selectedCell[1],l=jexcel.current.selectedCell[0];"readonly"!=jexcel.current.options.columns[l].type&&(32==e.keyCode?(e.preventDefault(),"checkbox"==jexcel.current.options.columns[l].type||"radio"==jexcel.current.options.columns[l].type?jexcel.current.setCheckRadioValue():jexcel.current.openEditor(jexcel.current.records[r][l],!0)):113==e.keyCode?jexcel.current.openEditor(jexcel.current.records[r][l],!1):(8==e.keyCode||e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=111||e.keyCode>=187&&e.keyCode<=190||(String.fromCharCode(e.keyCode)==e.key||String.fromCharCode(e.keyCode).toLowerCase()==e.key.toLowerCase())&&jexcel.validLetter(String.fromCharCode(e.keyCode)))&&(jexcel.current.openEditor(jexcel.current.records[r][l],!0),"calendar"==jexcel.current.options.columns[l].type&&e.preventDefault()))}}else 65==e.which?(jexcel.current.selectAll(),e.preventDefault()):83==e.which?(jexcel.current.download(),e.preventDefault()):89==e.which?(jexcel.current.redo(),e.preventDefault()):90==e.which?(jexcel.current.undo(),e.preventDefault()):67==e.which?(jexcel.current.copy(!0),e.preventDefault()):88==e.which?(1==jexcel.current.options.editable?jexcel.cutControls():jexcel.copyControls(),e.preventDefault()):86==e.which&&jexcel.pasteControls();else e.target.classList.contains("jexcel_search")&&(jexcel.timeControl&&clearTimeout(jexcel.timeControl),jexcel.timeControl=setTimeout((function(){jexcel.current.search(e.target.value)}),200))}},jexcel.isMouseAction=!1,jexcel.mouseDownControls=function(e){if((e=e||window.event).buttons)var o=e.buttons;else o=e.button?e.button:e.which;var t=jexcel.getElement(e.target);if(t[0]?jexcel.current!=t[0].jexcel&&(jexcel.current&&(jexcel.current.edition&&jexcel.current.closeEditor(jexcel.current.edition[0],!0),jexcel.current.resetSelection()),jexcel.current=t[0].jexcel):jexcel.current&&(jexcel.current.edition&&jexcel.current.closeEditor(jexcel.current.edition[0],!0),jexcel.current.resetSelection(!0),jexcel.current=null),jexcel.current&&1==o){if(e.target.classList.contains("jexcel_selectall"))jexcel.current&&jexcel.current.selectAll();else if(e.target.classList.contains("jexcel_corner"))1==jexcel.current.options.editable&&(jexcel.current.selectedCorner=!0);else{if(1==t[1]){if(b=e.target.getAttribute("data-x")){var n=e.target.getBoundingClientRect();if(1==jexcel.current.options.columnResize&&n.width-e.offsetX<12){jexcel.current.resizing={mousePosition:e.pageX,column:b,width:n.width},jexcel.current.headers[b].classList.add("resizing");for(var r=0;r<jexcel.current.records.length;r++)jexcel.current.records[r][b]&&jexcel.current.records[r][b].classList.add("resizing")}else if(1==jexcel.current.options.columnDrag&&n.height-e.offsetY<12)if(jexcel.current.isColMerged(b).length)console.error("Jspreadsheet: This column is part of a merged cell.");else for(jexcel.current.resetSelection(),jexcel.current.dragging={element:e.target,column:b,destination:b},jexcel.current.headers[b].classList.add("dragging"),r=0;r<jexcel.current.records.length;r++)jexcel.current.records[r][b]&&jexcel.current.records[r][b].classList.add("dragging");else{if(jexcel.current.selectedHeader&&(e.shiftKey||e.ctrlKey))var l=jexcel.current.selectedHeader,s=b;else jexcel.current.selectedHeader==b&&1==jexcel.current.options.allowRenameColumn&&(jexcel.timeControl=setTimeout((function(){jexcel.current.setHeader(b)}),800)),jexcel.current.selectedHeader=b,l=b,s=b;jexcel.current.updateSelectionFromCoords(l,0,s,jexcel.current.options.data.length-1)}}else if(e.target.parentNode.classList.contains("jexcel_nested")){if(e.target.getAttribute("data-column"))var i=e.target.getAttribute("data-column").split(","),a=parseInt(i[0]),c=parseInt(i[i.length-1]);else a=0,c=jexcel.current.options.columns.length-1;jexcel.current.updateSelectionFromCoords(a,0,c,jexcel.current.options.data.length-1)}}else jexcel.current.selectedHeader=!1;if(2==t[1]){var u=e.target.getAttribute("data-y");if(e.target.classList.contains("jexcel_row"))n=e.target.getBoundingClientRect(),1==jexcel.current.options.rowResize&&n.height-e.offsetY<12?(jexcel.current.resizing={element:e.target.parentNode,mousePosition:e.pageY,row:u,height:n.height},e.target.parentNode.classList.add("resizing")):1==jexcel.current.options.rowDrag&&n.width-e.offsetX<18?jexcel.current.isRowMerged(u).length?console.error("Jspreadsheet: This row is part of a merged cell"):1==jexcel.current.options.search&&jexcel.current.results?console.error("Jspreadsheet: Please clear your search before perform this action"):(jexcel.current.resetSelection(),jexcel.current.dragging={element:e.target.parentNode,row:u,destination:u},e.target.parentNode.classList.add("dragging")):(jexcel.current.selectedRow&&(e.shiftKey||e.ctrlKey)?(l=jexcel.current.selectedRow,s=u):(jexcel.current.selectedRow=u,l=u,s=u),jexcel.current.updateSelectionFromCoords(0,l,jexcel.current.options.data[0].length-1,s));else if(e.target.classList.contains("jclose")&&e.target.clientWidth-e.offsetX<50&&e.offsetY<50)jexcel.current.closeEditor(jexcel.current.edition[0],!0);else{var d=function(e){var o=e.getAttribute("data-x"),t=e.getAttribute("data-y");return o&&t?[o,t]:e.parentNode?d(e.parentNode):void 0},j=d(e.target);if(j){var b=j[0];u=j[1],jexcel.current.edition&&(jexcel.current.edition[2]==b&&jexcel.current.edition[3]==u||jexcel.current.closeEditor(jexcel.current.edition[0],!0)),jexcel.current.edition||(e.shiftKey?jexcel.current.updateSelectionFromCoords(jexcel.current.selectedCell[0],jexcel.current.selectedCell[1],b,u):jexcel.current.updateSelectionFromCoords(b,u)),jexcel.current.selectedHeader=null,jexcel.current.selectedRow=null}}}else jexcel.current.selectedRow=!1;e.target.classList.contains("jexcel_page")&&("<"==e.target.textContent?jexcel.current.page(0):">"==e.target.textContent?jexcel.current.page(e.target.getAttribute("title")-1):jexcel.current.page(e.target.textContent-1))}jexcel.current.edition?jexcel.isMouseAction=!1:jexcel.isMouseAction=!0}else jexcel.isMouseAction=!1},jexcel.mouseUpControls=function(e){if(jexcel.current)if(jexcel.current.resizing){if(jexcel.current.resizing.column){var o=jexcel.current.colgroup[jexcel.current.resizing.column].getAttribute("width"),t=jexcel.current.getSelectedColumns();if(t.length>1){for(var n=[],r=0;r<t.length;r++)n.push(parseInt(jexcel.current.colgroup[t[r]].getAttribute("width")));n[t.indexOf(parseInt(jexcel.current.resizing.column))]=jexcel.current.resizing.width,jexcel.current.setWidth(t,o,n)}else jexcel.current.setWidth(jexcel.current.resizing.column,o,jexcel.current.resizing.width);jexcel.current.headers[jexcel.current.resizing.column].classList.remove("resizing");for(var l=0;l<jexcel.current.records.length;l++)jexcel.current.records[l][jexcel.current.resizing.column]&&jexcel.current.records[l][jexcel.current.resizing.column].classList.remove("resizing")}else{jexcel.current.rows[jexcel.current.resizing.row].children[0].classList.remove("resizing");var s=jexcel.current.rows[jexcel.current.resizing.row].getAttribute("height");jexcel.current.setHeight(jexcel.current.resizing.row,s,jexcel.current.resizing.height),jexcel.current.resizing.element.classList.remove("resizing")}jexcel.current.resizing=null}else if(jexcel.current.dragging){if(jexcel.current.dragging){if(jexcel.current.dragging.column){var i=e.target.getAttribute("data-x");for(jexcel.current.headers[jexcel.current.dragging.column].classList.remove("dragging"),l=0;l<jexcel.current.rows.length;l++)jexcel.current.records[l][jexcel.current.dragging.column]&&jexcel.current.records[l][jexcel.current.dragging.column].classList.remove("dragging");for(r=0;r<jexcel.current.headers.length;r++)jexcel.current.headers[r].classList.remove("dragging-left"),jexcel.current.headers[r].classList.remove("dragging-right");i&&jexcel.current.dragging.column!=jexcel.current.dragging.destination&&jexcel.current.moveColumn(jexcel.current.dragging.column,jexcel.current.dragging.destination)}else{if(jexcel.current.dragging.element.nextSibling){var a=parseInt(jexcel.current.dragging.element.nextSibling.getAttribute("data-y"));jexcel.current.dragging.row<a&&(a-=1)}else a=parseInt(jexcel.current.dragging.element.previousSibling.getAttribute("data-y"));jexcel.current.dragging.row!=jexcel.current.dragging.destination&&jexcel.current.moveRow(jexcel.current.dragging.row,a,!0),jexcel.current.dragging.element.classList.remove("dragging")}jexcel.current.dragging=null}}else jexcel.current.selectedCorner&&(jexcel.current.selectedCorner=!1,jexcel.current.selection.length>0&&(jexcel.current.copyData(jexcel.current.selection[0],jexcel.current.selection[jexcel.current.selection.length-1]),jexcel.current.removeCopySelection()));jexcel.timeControl&&(clearTimeout(jexcel.timeControl),jexcel.timeControl=null),jexcel.isMouseAction=!1},jexcel.mouseMoveControls=function(e){if((e=e||window.event).buttons)var o=e.buttons;else o=e.button?e.button:e.which;if(o||(jexcel.isMouseAction=!1),jexcel.current)if(1==jexcel.isMouseAction){if(jexcel.current.resizing)if(jexcel.current.resizing.column){var t=e.pageX-jexcel.current.resizing.mousePosition;if(jexcel.current.resizing.width+t>0){var n=jexcel.current.resizing.width+t;jexcel.current.colgroup[jexcel.current.resizing.column].setAttribute("width",n),jexcel.current.updateCornerPosition()}}else{var r=e.pageY-jexcel.current.resizing.mousePosition;if(jexcel.current.resizing.height+r>0){var l=jexcel.current.resizing.height+r;jexcel.current.rows[jexcel.current.resizing.row].setAttribute("height",l),jexcel.current.rows[jexcel.current.resizing.row].style.setProperty("--table-editor-line-clamp",Math.floor((l-10)/14)),jexcel.current.updateCornerPosition()}}else if(jexcel.current.dragging)if(jexcel.current.dragging.column){var s=e.target.getAttribute("data-x");if(s)if(jexcel.current.isColMerged(s).length)console.error("Jspreadsheet: This column is part of a merged cell.");else{for(var i=0;i<jexcel.current.headers.length;i++)jexcel.current.headers[i].classList.remove("dragging-left"),jexcel.current.headers[i].classList.remove("dragging-right");jexcel.current.dragging.column==s?jexcel.current.dragging.destination=parseInt(s):e.target.clientWidth/2>e.offsetX?(jexcel.current.dragging.column<s?jexcel.current.dragging.destination=parseInt(s)-1:jexcel.current.dragging.destination=parseInt(s),jexcel.current.headers[s].classList.add("dragging-left")):(jexcel.current.dragging.column<s?jexcel.current.dragging.destination=parseInt(s):jexcel.current.dragging.destination=parseInt(s)+1,jexcel.current.headers[s].classList.add("dragging-right"))}}else{var a=e.target.getAttribute("data-y");if(a)if(jexcel.current.isRowMerged(a).length)console.error("Jspreadsheet: This row is part of a merged cell.");else{var c=e.target.clientHeight/2>e.offsetY?e.target.parentNode.nextSibling:e.target.parentNode;jexcel.current.dragging.element!=c&&(e.target.parentNode.parentNode.insertBefore(jexcel.current.dragging.element,c),jexcel.current.dragging.destination=Array.prototype.indexOf.call(jexcel.current.dragging.element.parentNode.children,jexcel.current.dragging.element))}}}else{var u=e.target.getAttribute("data-x"),d=e.target.getAttribute("data-y"),j=e.target.getBoundingClientRect();jexcel.current.cursor&&(jexcel.current.cursor.style.cursor="",jexcel.current.cursor=null),e.target.parentNode.parentNode&&e.target.parentNode.parentNode.className&&(e.target.parentNode.parentNode.classList.contains("resizable")&&(e.target&&u&&!d&&j.width-(e.clientX-j.left)<12?(jexcel.current.cursor=e.target,jexcel.current.cursor.style.cursor="col-resize"):e.target&&!u&&d&&j.height-(e.clientY-j.top)<12&&(jexcel.current.cursor=e.target,jexcel.current.cursor.style.cursor="row-resize")),e.target.parentNode.parentNode.classList.contains("draggable")&&(e.target&&!u&&d&&j.width-(e.clientX-j.left)<18||e.target&&u&&!d&&j.height-(e.clientY-j.top)<12&&e.clientX-j.left<j.width-24)&&(jexcel.current.cursor=e.target,jexcel.current.cursor.style.cursor="move"))}},jexcel.mouseOverControls=function(e){if((e=e||window.event).buttons)var o=e.buttons;else o=e.button?e.button:e.which;if(o||(jexcel.isMouseAction=!1),jexcel.current&&1==jexcel.isMouseAction){var t=jexcel.getElement(e.target);if(t[0]){if(jexcel.current!=t[0].jexcel&&jexcel.current)return!1;var n=e.target.getAttribute("data-x"),r=e.target.getAttribute("data-y");if(jexcel.current.resizing||jexcel.current.dragging);else{if(1==t[1]&&jexcel.current.selectedHeader){n=e.target.getAttribute("data-x");var l=jexcel.current.selectedHeader,s=n;jexcel.current.updateSelectionFromCoords(l,0,s,jexcel.current.options.data.length-1)}2==t[1]&&(e.target.classList.contains("jexcel_row")?jexcel.current.selectedRow&&(l=jexcel.current.selectedRow,s=r,jexcel.current.updateSelectionFromCoords(0,l,jexcel.current.options.data[0].length-1,s)):jexcel.current.edition||n&&r&&(jexcel.current.selectedCorner?jexcel.current.updateCopySelection(n,r):jexcel.current.selectedCell&&jexcel.current.updateSelectionFromCoords(jexcel.current.selectedCell[0],jexcel.current.selectedCell[1],n,r)))}}}jexcel.timeControl&&(clearTimeout(jexcel.timeControl),jexcel.timeControl=null)},jexcel.doubleClickControls=function(e){if(jexcel.current)if(e.target.classList.contains("jexcel_corner")){if(jexcel.current.highlighted.length>0){var o=jexcel.current.highlighted[0].getAttribute("data-x"),t=parseInt(jexcel.current.highlighted[jexcel.current.highlighted.length-1].getAttribute("data-y"))+1,n=jexcel.current.highlighted[jexcel.current.highlighted.length-1].getAttribute("data-x"),r=jexcel.current.records.length-1;jexcel.current.copyData(jexcel.current.records[t][o],jexcel.current.records[r][n])}}else if(e.target.classList.contains("jexcel_column_filter")){var l=e.target.getAttribute("data-x");jexcel.current.openFilter(l)}else{var s=jexcel.getElement(e.target);if(1==s[1]&&1==jexcel.current.options.columnSorting&&(l=e.target.getAttribute("data-x"))&&jexcel.current.orderBy(l),2==s[1]&&1==jexcel.current.options.editable&&!jexcel.current.edition){var i=function(e){if(e.parentNode){var o=e.getAttribute("data-x"),t=e.getAttribute("data-y");return o&&t?e:i(e.parentNode)}},a=i(e.target);a&&a.classList.contains("highlight")&&jexcel.current.openEditor(a)}}},jexcel.copyControls=function(e){jexcel.current&&jexcel.copyControls.enabled&&(jexcel.current.edition||jexcel.current.copy(!0))},jexcel.cutControls=function(e){jexcel.current&&(jexcel.current.edition||(jexcel.current.copy(!0),1==jexcel.current.options.editable&&jexcel.current.setValue(jexcel.current.highlighted,"")))},jexcel.pasteControls=function(e){jexcel.current&&jexcel.current.selectedCell&&(jexcel.current.edition||1==jexcel.current.options.editable&&(e&&e.clipboardData?(jexcel.current.paste(jexcel.current.selectedCell[0],jexcel.current.selectedCell[1],e.clipboardData.getData("text")),e.preventDefault()):window.clipboardData&&jexcel.current.paste(jexcel.current.selectedCell[0],jexcel.current.selectedCell[1],window.clipboardData.getData("text"))))},jexcel.contextMenuControls=function(e){if("buttons"in(e=e||window.event)?e.buttons:e.which||e.button,jexcel.current&&jexcel.current.options.contextMenu&&(jexcel.current.contextMenu.contextmenu.close(),jexcel.current)){var o="DIV"===e.target.tagName||"TEXTAREA"===e.target.tagName?e.target.parentNode:e.target,t=o.getAttribute("data-x"),n=o.getAttribute("data-y");if(t||n){const o=jexcel.current.selectedCell,l={l:Math.min(parseInt(o[0]),parseInt(o[2])),r:Math.max(parseInt(o[0]),parseInt(o[2])),t:Math.min(parseInt(o[1]),parseInt(o[3])),b:Math.max(parseInt(o[1]),parseInt(o[3]))};(t<l.l||t>l.r||n<l.t||n>l.b)&&jexcel.current.updateSelectionFromCoords(t,n,t,n);var r=jexcel.current.options.contextMenu(jexcel.current,t,n,e);jexcel.current.contextMenu.contextmenu.open(e,r),e.preventDefault()}}},jexcel.touchStartControls=function(e){var o=jexcel.getElement(e.target);if(o[0]?jexcel.current!=o[0].jexcel&&(jexcel.current&&jexcel.current.resetSelection(),jexcel.current=o[0].jexcel):jexcel.current&&(jexcel.current.resetSelection(),jexcel.current=null),jexcel.current&&!jexcel.current.edition){var t=e.target.getAttribute("data-x"),n=e.target.getAttribute("data-y");t&&n&&(jexcel.current.updateSelectionFromCoords(t,n),jexcel.timeControl=setTimeout((function(){"color"==jexcel.current.options.columns[t].type?jexcel.tmpElement=null:jexcel.tmpElement=e.target,jexcel.current.openEditor(e.target,!1,e)}),500))}},jexcel.touchEndControls=function(e){jexcel.timeControl&&(clearTimeout(jexcel.timeControl),jexcel.timeControl=null,jexcel.tmpElement&&"INPUT"==jexcel.tmpElement.children[0].tagName&&jexcel.tmpElement.children[0].focus(),jexcel.tmpElement=null)},jexcel.tabs=function(e,o){var t=[];if(e.classList.contains("jexcel_tabs"))r=e.children[0],l=e.children[1];else{e.innerHTML="",e.classList.add("jexcel_tabs"),e.jexcel=[];var n=document.createElement("div"),r=e.appendChild(n),l=(n=document.createElement("div"),e.appendChild(n))}for(var s=[],i=[],a=0;a<o.length;a++){s[a]=document.createElement("div"),s[a].classList.add("jexcel_tab");var c=jexcel(s[a],o[a]);l.appendChild(s[a]),t[a]=e.jexcel.push(c),i[a]=document.createElement("div"),i[a].classList.add("jexcel_tab_link"),i[a].setAttribute("data-spreadsheet",e.jexcel.length-1),i[a].innerHTML=o[a].sheetName,i[a].onclick=function(){for(var e=0;e<r.children.length;e++)r.children[e].classList.remove("selected"),l.children[e].style.display="none";var o=this.getAttribute("data-spreadsheet");l.children[o].style.display="block",r.children[o].classList.add("selected")},r.appendChild(i[a])}for(var u=0;u<r.children.length;u++)r.children[u].classList.remove("selected"),l.children[u].style.display="none";return r.children[r.children.length-1].classList.add("selected"),l.children[r.children.length-1].style.display="block",t},jexcel.createTabs=jexcel.tabs,jexcel.fromSpreadsheet=function(e,o){var t,n=function(e){var o=[];return e.SheetNames.forEach((function(t){var n={rows:[],columns:[],data:[],style:{}};if(n.sheetName=t,(j=e.Sheets[t]["!cols"])&&j.length)for(var r=0;r<j.length;r++)n.columns[r]={},j[r]&&j[r].wpx&&(n.columns[r].width=j[r].wpx+"px");if((j=e.Sheets[t]["!rows"])&&j.length)for(r=0;r<j.length;r++)j[r]&&j[r].hpx&&(n.rows[r]={},n.rows[r].height=j[r].hpx+"px");if((j=e.Sheets[t]["!merges"])&&j.length>0)for(n.mergeCells=[],r=0;r<j.length;r++){var l=j[r].s.c,s=j[r].s.r,i=j[r].e.c,a=j[r].e.r,c=jexcel.getColumnNameFromId([l,s]);n.mergeCells[c]=[i-l+1,a-s+1]}var u=0,d=0,j=Object.keys(e.Sheets[t]);for(r=0;r<j.length;r++)if("!"!=j[r].substr(0,1)){var b=e.Sheets[t][j[r]],p=jexcel.getIdFromColumnName(j[r],!0);n.data[p[1]]||(n.data[p[1]]=[]),n.data[p[1]][p[0]]=b.f?"="+b.f:b.w,u<p[0]&&(u=p[0]),d<p[1]&&(d=p[1]),b.style&&Object.keys(b.style).length>0&&(n.style[j[r]]=b.style),b.s&&b.s.fgColor&&(n.style[j[r]]&&(n.style[j[r]]+=";"),n.style[j[r]]+="background-color:#"+b.s.fgColor.rgb)}for(var h=n.columns,g=0;g<=d;g++)for(r=0;r<=u;r++)n.data[g]||(n.data[g]=[]),n.data[g][r]||h<r&&(n.data[g][r]="");o.push(n)})),o};(t=new XMLHttpRequest).open("GET",e,!0),"undefined"!=typeof Uint8Array?(t.responseType="arraybuffer",t.onload=function(e){var r=t.response,l=new Uint8Array(r),s=XLSX.read(l,{type:"array",cellFormula:!0,cellStyles:!0});o(n(s))}):(t.setRequestHeader("Accept-Charset","x-user-defined"),t.onreadystatechange=function(){if(4==t.readyState&&200==t.status){var e=convertResponseBodyToText(t.responseBody),r=XLSX.read(e,{type:"binary",cellFormula:!0,cellStyles:!0});o(n(r))}}),t.send()},jexcel.validLetter=function(e){return e.match(/([\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC-\u0400-\u04FF']+)/g)?1:0},jexcel.injectArray=function(e,o,t){return e.slice(0,o).concat(t).concat(e.slice(o))},jexcel.getColumnName=function(e){var o="";return e>701?(o+=String.fromCharCode(64+parseInt(e/676)),o+=String.fromCharCode(64+parseInt(e%676/26))):e>25&&(o+=String.fromCharCode(64+parseInt(e/26))),o+String.fromCharCode(65+e%26)},jexcel.getIdFromColumnName=function(e,o){var t=/^[a-zA-Z]+/.exec(e);if(t){for(var n=0,r=0;r<t[0].length;r++)n+=parseInt(t[0].charCodeAt(r)-64)*Math.pow(26,t[0].length-1-r);--n<0&&(n=0);var l=parseInt(/[0-9]+$/.exec(e));l>0&&l--,e=1==o?[n,l]:n+"-"+l}return e},jexcel.getColumnNameFromId=function(e){return Array.isArray(e)||(e=e.split("-")),jexcel.getColumnName(parseInt(e[0]))+(parseInt(e[1])+1)},jexcel.getElement=function(e){var o=0,t=0;return function e(n){n.className&&n.classList.contains("jexcel_container")&&(t=n),"THEAD"==n.tagName?o=1:"TBODY"==n.tagName&&(o=2),n.parentNode&&(t||e(n.parentNode))}(e),[t,o]},jexcel.doubleDigitFormat=function(e){return 1==(e=""+e).length&&(e="0"+e),e},jexcel.createFromTable=function(e,o){if("TABLE"==e.tagName){o||(o={}),o.columns=[],o.data=[];var t=e.querySelectorAll("colgroup > col");if(t.length)for(var n=0;n<t.length;n++){if(!(r=t[n].style.width))var r=t[n].getAttribute("width");r&&(o.columns[n]||(o.columns[n]={}),o.columns[n].width=r)}var l=function(e){var t=e.getBoundingClientRect(),r=t.width>50?t.width:50;o.columns[n]||(o.columns[n]={}),e.getAttribute("data-celltype")?o.columns[n].type=e.getAttribute("data-celltype"):o.columns[n].type="text",o.columns[n].width=r+"px",o.columns[n].title=e.innerHTML,o.columns[n].align=e.style.textAlign||"center",(t=e.getAttribute("name"))&&(o.columns[n].name=t),(t=e.getAttribute("id"))&&(o.columns[n].id=t),(t=e.getAttribute("data-mask"))&&(o.columns[n].mask=t)},s=[],i=e.querySelectorAll(":scope > thead > tr");if(i.length){for(var a=0;a<i.length-1;a++){var c=[];for(n=0;n<i[a].children.length;n++){var u={title:i[a].children[n].textContent,colspan:i[a].children[n].getAttribute("colspan")||1};c.push(u)}s.push(c)}for(i=i[i.length-1].children,n=0;n<i.length;n++)l(i[n])}var d=0,j={},b={},p={},h={},g=e.querySelectorAll(":scope > tr, :scope > tbody > tr");for(a=0;a<g.length;a++)if(o.data[d]=[],1!=o.parseTableFirstRowAsHeader||i.length||0!=a){for(n=0;n<g[a].children.length;n++){if(f=g[a].children[n].getAttribute("data-formula"))"="!=f.substr(0,1)&&(f="="+f);else var f=g[a].children[n].innerHTML;o.data[d].push(f);var m=jexcel.getColumnNameFromId([n,a]),C=g[a].children[n].getAttribute("class");C&&(h[m]=C);var x=parseInt(g[a].children[n].getAttribute("colspan"))||0,v=parseInt(g[a].children[n].getAttribute("rowspan"))||0;(x||v)&&(j[m]=[x||1,v||1]),g[a].children[n].style&&"none"==g[a].children[n].style.display&&(g[a].children[n].style.display="");var y=g[a].children[n].getAttribute("style");y&&(p[m]=y),g[a].children[n].classList.contains("styleBold")&&(p[m]?p[m]+="; font-weight:bold;":p[m]="font-weight:bold;")}g[a].style&&g[a].style.height&&(b[a]={height:g[a].style.height}),d++}else for(n=0;n<g[a].children.length;n++)l(g[a].children[n]);if(Object.keys(s).length>0&&(o.nestedHeaders=s),Object.keys(p).length>0&&(o.style=p),Object.keys(j).length>0&&(o.mergeCells=j),Object.keys(b).length>0&&(o.rows=b),Object.keys(h).length>0&&(o.classes=h),(g=e.querySelectorAll("tfoot tr")).length){var w=[];for(a=0;a<g.length;a++){var A=[];for(n=0;n<g[a].children.length;n++)A.push(g[a].children[n].textContent);w.push(A)}Object.keys(w).length>0&&(o.footers=w)}if(1==o.parseTableAutoCellType){var F=[];for(n=0;n<o.columns.length;n++){var E=!0,L=!0;for(F[n]=[],a=0;a<o.data.length;a++)f=o.data[a][n],F[n][f]||(F[n][f]=0),F[n][f]++,f.length>25&&(E=!1),10==f.length&&"-"==f.substr(4,1)&&"-"==f.substr(7,1)||(L=!1);var D=Object.keys(F[n]).length;L?o.columns[n].type="calendar":1==E&&D>1&&D<=parseInt(.1*o.data.length)&&(o.columns[n].type="dropdown",o.columns[n].source=Object.keys(F[n]))}}return o}console.log("Element is not a table")},jexcel.helpers=(component={getCaretIndex:function(e){if(this.config.root)var o=this.config.root;else o=window;var t=0,n=o.getSelection();if(n&&0!==n.rangeCount){var r=n.getRangeAt(0),l=r.cloneRange();l.selectNodeContents(e),l.setEnd(r.endContainer,r.endOffset),t=l.toString().length}return t},invert:function(e){for(var o=[],t=Object.keys(e),n=0;n<t.length;n++)o[e[t[n]]]=t[n];return o},getColumnName:function(e){var o="";return e>701?(o+=String.fromCharCode(64+parseInt(e/676)),o+=String.fromCharCode(64+parseInt(e%676/26))):e>25&&(o+=String.fromCharCode(64+parseInt(e/26))),o+String.fromCharCode(65+e%26)},getColumnNameFromCoords:function(e,o){return component.getColumnName(parseInt(e))+(parseInt(o)+1)},getCoordsFromColumnName:function(e){var o=/^[a-zA-Z]+/.exec(e);if(o){for(var t=0,n=0;n<o[0].length;n++)t+=parseInt(o[0].charCodeAt(n)-64)*Math.pow(26,o[0].length-1-n);--t<0&&(t=0);var r=parseInt(/[0-9]+$/.exec(e))||null;return r>0&&r--,[t,r]}},createFromTable:function(){},injectArray:function(e,o,t){return e.slice(0,o).concat(t).concat(e.slice(o))},parseCSV:function(e,o){o=o||",";for(var t=0,n=0,r=[[]],l=0,s=null,i=!1,a=!1,c=0;c<e.length;c++)if(r[n]||(r[n]=[]),r[n][t]||(r[n][t]=""),"\r"!=e[c])if("\n"!=e[c]&&e[c]!=o||0!=i&&1!=a&&s){if('"'==e[c]&&(i=!i),null===s){if(1==(s=i))continue}else if(!0===s&&!a&&'"'==e[c]){'"'==e[c+1]?(i=!0,r[n][t]+=e[c],c++):a=!0;continue}r[n][t]+=e[c]}else{if(s=null,i=!1,a=!1,'"'==r[n][t][0]){var u=r[n][t].trim();'"'==u[u.length-1]&&(r[n][t]=u.substr(1,u.length-2))}"\n"==e[c]?(t=0,n++):++t>l&&(l=t)}for(var d=0;d<r.length;d++)for(c=0;c<=l;c++)void 0===r[d][c]&&(r[d][c]="");return r}},component),"undefined"!=typeof jQuery&&function(e){e.fn.jspreadsheet=e.fn.jexcel=function(o){var t=e(this).get(0);return t.jexcel?Array.isArray(t.jexcel)?t.jexcel[o][arguments[1]].apply(this,Array.prototype.slice.call(arguments,2)):t.jexcel[o].apply(this,Array.prototype.slice.call(arguments,1)):jexcel(e(this).get(0),arguments[0])}}(jQuery),jexcel},global.jspreadsheet=global.jexcel=factory()})();
1 +(()=>{var e;(e=window).jspreadsheet=e.jexcel=function(){"use strict";var e,t=(e={title:"Jspreadsheet",version:"4.15.0",type:"CE",host:"https://bossanova.uk/jspreadsheet",license:"MIT",print:function(){return[this.title+" "+this.type+" "+this.version,this.host,this.license].join("\r\n")}},function(){return e}),o=function(e){var t=(""+e)[0];return"="==t||"#"==t},n=function(e){if(e.format||e.mask||e.locale){var t={};return e.mask?t.mask=e.mask:e.format?t.mask=e.format:(t.locale=e.locale,t.options=e.options),e.decimal&&(t.options||(t.options={}),t.options={decimal:e.decimal}),t}return null},r=function(e,s){var l={options:{}};if(!(e instanceof Element||e instanceof HTMLDocument))return console.error("Jspreadsheet: el is not a valid DOM element"),!1;if("TABLE"==e.tagName){if(!(s=r.createFromTable(e,s)))return console.error("Jspreadsheet: el is not a valid DOM element"),!1;var i=document.createElement("div");e.parentNode.insertBefore(i,e),e.remove(),e=i}var a={url:null,method:"GET",requestVariables:null,data:null,sorting:null,copyCompatibility:!1,root:null,rows:[],columns:[],colHeaders:[],colWidths:[],colAlignments:[],nestedHeaders:null,defaultColWidth:50,defaultColAlign:"center",defaultRowHeight:null,minSpareRows:0,minSpareCols:0,minDimensions:[0,0],allowExport:!0,includeHeadersOnDownload:!1,includeHeadersOnCopy:!1,columnSorting:!0,columnDrag:!1,columnResize:!0,rowResize:!1,rowDrag:!0,editable:!0,allowInsertRow:!0,allowManualInsertRow:!0,allowInsertColumn:!0,allowManualInsertColumn:!0,allowDeleteRow:!0,allowDeletingAllRows:!1,allowDeleteColumn:!0,allowRenameColumn:!0,allowComments:!1,wordWrap:!1,imageOptions:null,csv:null,csvFileName:"jspreadsheet",csvHeaders:!0,csvDelimiter:",",parseTableFirstRowAsHeader:!1,parseTableAutoCellType:!1,selectionCopy:!0,mergeCells:{},toolbar:null,search:!1,pagination:!1,paginationOptions:null,fullscreen:!1,lazyLoading:!1,loadingSpin:!1,tableOverflow:!1,tableHeight:"300px",tableWidth:null,textOverflow:!1,meta:null,style:null,classes:null,parseFormulas:!0,autoIncrement:!0,autoCasting:!0,secureFormulas:!0,stripHTML:!0,stripHTMLOnCopy:!1,filters:!1,footers:null,onundo:null,onredo:null,onload:null,onchange:null,oncomments:null,onbeforechange:null,onafterchanges:null,onbeforeinsertrow:null,oninsertrow:null,onbeforeinsertcolumn:null,oninsertcolumn:null,onbeforedeleterow:null,ondeleterow:null,onbeforedeletecolumn:null,ondeletecolumn:null,onmoverow:null,onmovecolumn:null,onresizerow:null,onresizecolumn:null,onsort:null,onselection:null,oncopy:null,onpaste:null,onbeforepaste:null,onmerge:null,onfocus:null,onblur:null,onchangeheader:null,oncreateeditor:null,oneditionstart:null,oneditionend:null,onchangestyle:null,onchangemeta:null,onchangepage:null,onbeforesave:null,onsave:null,onevent:null,persistance:!1,updateTable:null,detachForUpdates:!1,freezeColumns:null,text:{noRecordsFound:"No records found",showingPage:"Showing page {0} of {1} entries",show:"Show ",search:"Search",entries:" entries",columnName:"Column name",insertANewColumnBefore:"Insert a new column before",insertANewColumnAfter:"Insert a new column after",deleteSelectedColumns:"Delete selected columns",renameThisColumn:"Rename this column",orderAscending:"Order ascending",orderDescending:"Order descending",insertANewRowBefore:"Insert a new row before",insertANewRowAfter:"Insert a new row after",deleteSelectedRows:"Delete selected rows",editComments:"Edit comments",addComments:"Add comments",comments:"Comments",clearComments:"Clear comments",copy:"Copy...",paste:"Paste...",saveAs:"Save as...",about:"About",areYouSureToDeleteTheSelectedRows:"Are you sure to delete the selected rows?",areYouSureToDeleteTheSelectedColumns:"Are you sure to delete the selected columns?",thisActionWillDestroyAnyExistingMergedCellsAreYouSure:"This action will destroy any existing merged cells. Are you sure?",thisActionWillClearYourSearchResultsAreYouSure:"This action will clear your search results. Are you sure?",thereIsAConflictWithAnotherMergedCell:"There is a conflict with another merged cell",invalidMergeProperties:"Invalid merged properties",cellAlreadyMerged:"Cell already merged",noCellsSelected:"No cells selected"},about:!0};for(var c in a)if(s&&s.hasOwnProperty(c))if("text"===c)for(var u in l.options[c]=a[c],s[c])s[c].hasOwnProperty(u)&&(l.options[c][u]=s[c][u]);else l.options[c]=s[c];else l.options[c]=a[c];l.el=e,l.corner=null,l.contextMenu=null,l.textarea=null,l.ads=null,l.content=null,l.table=null,l.thead=null,l.tbody=null,l.rows=[],l.results=null,l.searchInput=null,l.toolbar=null,l.pagination=null,l.pageNumber=null,l.headerContainer=null,l.colgroupContainer=null,l.headers=[],l.records=[],l.history=[],l.formula=[],l.colgroup=[],l.selection=[],l.highlighted=[],l.selectedCell=null,l.selectedContainer=null,l.style=[],l.data=null,l.filter=null,l.filters=[],l.cursor=null,l.historyIndex=-1,l.ignoreEvents=!1,l.ignoreHistory=!1,l.edition=null,l.hashString=null,l.resizing=null,l.dragging=null,1==l.options.lazyLoading&&0==l.options.tableOverflow&&0==l.options.fullscreen&&(console.error("Jspreadsheet: The lazyloading only works when tableOverflow = yes or fullscreen = yes"),l.options.lazyLoading=!1),l.fullscreen=function(t){null==t&&(t=!l.options.fullscreen),l.options.fullscreen!=t&&(l.options.fullscreen=t,1==t?e.classList.add("fullscreen"):e.classList.remove("fullscreen"))},l.dispatch=function(e){if(!l.ignoreEvents){if("function"==typeof l.options.onevent)var t=l.options.onevent.apply(this,arguments);"function"==typeof l.options[e]&&(t=l.options[e].apply(this,Array.prototype.slice.call(arguments,1)))}if("onafterchanges"==e&&l.options.persistance){var o=1==l.options.persistance?l.options.url:l.options.persistance,n=l.prepareJson(arguments[2]);l.save(o,n)}return t},l.prepareTable=function(){var e=l.options.columns.length;if(l.options.data&&void 0!==l.options.data[0]){var t=Object.keys(l.options.data[0]);t.length>e&&(e=t.length)}l.options.minDimensions[0]>e&&(e=l.options.minDimensions[0]);for(var o=[],n=0;n<e;n++)l.options.colHeaders[n]||(l.options.colHeaders[n]=""),l.options.colWidths[n]||(l.options.colWidths[n]=l.options.defaultColWidth),l.options.colAlignments[n]||(l.options.colAlignments[n]=l.options.defaultColAlign),l.options.columns[n]?l.options.columns[n].type||(l.options.columns[n].type="text"):l.options.columns[n]={type:"text"},l.options.columns[n].name||(l.options.columns[n].name=t&&t[n]?t[n]:n),l.options.columns[n].source||(l.options.columns[n].source=[]),l.options.columns[n].options||(l.options.columns[n].options=[]),l.options.columns[n].editor||(l.options.columns[n].editor=null),l.options.columns[n].allowEmpty||(l.options.columns[n].allowEmpty=!1),l.options.columns[n].title||(l.options.columns[n].title=l.options.colHeaders[n]?l.options.colHeaders[n]:""),l.options.columns[n].width||(l.options.columns[n].width=l.options.colWidths[n]?l.options.colWidths[n]:l.options.defaultColWidth),l.options.columns[n].align||(l.options.columns[n].align=l.options.colAlignments[n]?l.options.colAlignments[n]:"center"),"autocomplete"==l.options.columns[n].type||"dropdown"==l.options.columns[n].type?l.options.columns[n].url&&o.push({url:l.options.columns[n].url,index:n,method:"GET",dataType:"json",success:function(e){for(var t=0;t<e.length;t++)l.options.columns[this.index].source.push(e[t])}}):"calendar"==l.options.columns[n].type&&(l.options.columns[n].options.format||(l.options.columns[n].options.format="DD/MM/YYYY"));o.length?jSuites.ajax(o,function(){l.createTable()}):l.createTable()},l.createTable=function(){l.table=document.createElement("table"),l.thead=document.createElement("thead"),l.tbody=document.createElement("tbody"),l.headers=[],l.colgroup=[],l.content=document.createElement("div"),l.content.classList.add("jexcel_content"),l.content.onscroll=function(e){l.scrollControls(e)},l.content.onwheel=function(e){l.wheelControls(e)},l.toolbar=document.createElement("div"),l.toolbar.classList.add("jexcel_toolbar");var t=document.createElement("div"),o=document.createTextNode(l.options.text.search+": ");l.searchInput=document.createElement("input"),l.searchInput.classList.add("jexcel_search"),t.appendChild(o),t.appendChild(l.searchInput),l.searchInput.onfocus=function(){l.resetSelection()};var n=document.createElement("div");if(l.options.pagination>0&&l.options.paginationOptions&&l.options.paginationOptions.length>0){l.paginationDropdown=document.createElement("select"),l.paginationDropdown.classList.add("jexcel_pagination_dropdown"),l.paginationDropdown.onchange=function(){l.options.pagination=parseInt(this.value),l.page(0)};for(var s=0;s<l.options.paginationOptions.length;s++){var i=document.createElement("option");i.value=l.options.paginationOptions[s],i.innerHTML=l.options.paginationOptions[s],l.paginationDropdown.appendChild(i)}l.paginationDropdown.value=l.options.pagination,n.appendChild(document.createTextNode(l.options.text.show)),n.appendChild(l.paginationDropdown),n.appendChild(document.createTextNode(l.options.text.entries))}var a,c=document.createElement("div");if(c.classList.add("jexcel_filter"),c.appendChild(n),c.appendChild(t),l.colgroupContainer=document.createElement("colgroup"),(a=document.createElement("col")).setAttribute("width","50"),l.colgroupContainer.appendChild(a),l.options.nestedHeaders&&l.options.nestedHeaders.length>0)if(l.options.nestedHeaders[0]&&l.options.nestedHeaders[0][0])for(var u=0;u<l.options.nestedHeaders.length;u++)l.thead.appendChild(l.createNestedHeader(l.options.nestedHeaders[u]));else l.thead.appendChild(l.createNestedHeader(l.options.nestedHeaders));for(l.headerContainer=document.createElement("tr"),(a=document.createElement("td")).classList.add("jexcel_selectall"),l.headerContainer.appendChild(a),s=0;s<l.options.columns.length;s++)l.createCellHeader(s),l.headerContainer.appendChild(l.headers[s]),l.colgroupContainer.appendChild(l.colgroup[s]);if(l.thead.appendChild(l.headerContainer),1==l.options.filters){l.filter=document.createElement("tr");var d=document.createElement("td");for(l.filter.appendChild(d),s=0;s<l.options.columns.length;s++)(d=document.createElement("td")).innerHTML="&nbsp;",d.setAttribute("data-x",s),d.className="jexcel_column_filter","hidden"==l.options.columns[s].type&&(d.style.display="none"),l.filter.appendChild(d);l.thead.appendChild(l.filter)}l.table=document.createElement("table"),l.table.classList.add("jexcel"),l.table.setAttribute("cellpadding","0"),l.table.setAttribute("cellspacing","0"),l.table.setAttribute("unselectable","yes"),l.table.appendChild(l.colgroupContainer),l.table.appendChild(l.thead),l.table.appendChild(l.tbody),l.options.textOverflow||l.table.classList.add("jexcel_overflow"),l.corner=document.createElement("div"),l.corner.className="jexcel_corner",l.corner.setAttribute("unselectable","on"),l.corner.setAttribute("onselectstart","return false"),0==l.options.selectionCopy&&(l.corner.style.display="none"),l.textarea=document.createElement("textarea"),l.textarea.className="jexcel_textarea",l.textarea.id="jexcel_textarea",l.textarea.tabIndex="-1",l.contextMenu=document.createElement("div"),l.contextMenu.className="jexcel_contextmenu",jSuites.contextmenu(l.contextMenu,{onclick:function(){l.contextMenu.contextmenu.close(!1)}});var p=document.createElement("a");p.setAttribute("href","https://bossanova.uk/jspreadsheet/"),l.ads=document.createElement("div"),l.ads.className="jexcel_about";var h=document.createElement("span");h.innerHTML="Jspreadsheet CE",p.appendChild(h),l.ads.appendChild(p),document.createElement("div").classList.add("jexcel_table"),l.pagination=document.createElement("div"),l.pagination.classList.add("jexcel_pagination");var g=document.createElement("div"),f=document.createElement("div");if(l.pagination.appendChild(g),l.pagination.appendChild(f),l.options.pagination||(l.pagination.style.display="none"),1==l.options.search&&e.appendChild(c),l.content.appendChild(l.table),l.content.appendChild(l.corner),l.content.appendChild(l.textarea),e.appendChild(l.toolbar),e.appendChild(l.content),e.appendChild(l.pagination),e.appendChild(l.contextMenu),e.appendChild(l.ads),e.classList.add("jexcel_container"),l.options.toolbar&&l.options.toolbar.length&&l.createToolbar(),1==l.options.fullscreen?e.classList.add("fullscreen"):1==l.options.tableOverflow&&(l.options.tableHeight&&(l.content.style["overflow-y"]="auto",l.content.style["box-shadow"]="rgb(221 221 221) 2px 2px 5px 0.1px",l.content.style.maxHeight=l.options.tableHeight),l.options.tableWidth&&(l.content.style["overflow-x"]="auto",l.content.style.width=l.options.tableWidth)),1!=l.options.tableOverflow&&l.options.toolbar&&e.classList.add("with-toolbar"),1==l.options.columnDrag&&l.thead.classList.add("draggable"),1==l.options.columnResize&&l.thead.classList.add("resizable"),1==l.options.rowDrag&&l.tbody.classList.add("draggable"),1==l.options.rowResize&&l.tbody.classList.add("resizable"),l.setData(),l.options.style&&l.setStyle(l.options.style,null,null,1,1),l.options.classes){var m=Object.keys(l.options.classes);for(s=0;s<m.length;s++){var C=r.getIdFromColumnName(m[s],!0);l.records[C[1]][C[0]].classList.add(l.options.classes[m[s]])}}},l.refresh=function(){l.options.url?(1==l.options.loadingSpin&&jSuites.loading.show(),jSuites.ajax({url:l.options.url,method:l.options.method,data:l.options.requestVariables,dataType:"json",success:function(e){l.options.data=e.data?e.data:e,l.setData(),1==l.options.loadingSpin&&jSuites.loading.hide()}})):l.setData()},l.setData=function(t){if(t&&("string"==typeof t&&(t=JSON.parse(t)),l.options.data=t),l.options.data||(l.options.data=[]),l.options.data&&l.options.data[0]&&!Array.isArray(l.options.data[0])){t=[];for(var o=0;o<l.options.data.length;o++){for(var n=[],r=0;r<l.options.columns.length;r++)n[r]=l.options.data[o][l.options.columns[r].name];t.push(n)}l.options.data=t}o=0,r=0;var s=l.options.columns.length,i=l.options.data.length,a=l.options.minDimensions[0],c=l.options.minDimensions[1],u=a>s?a:s,d=c>i?c:i;for(o=0;o<d;o++)for(r=0;r<u;r++)null==l.options.data[o]&&(l.options.data[o]=[]),null==l.options.data[o][r]&&(l.options.data[o][r]="");if(l.rows=[],l.results=null,l.records=[],l.history=[],l.historyIndex=-1,l.tbody.innerHTML="",1==l.options.lazyLoading){var p=0,h=l.options.data.length<100?l.options.data.length:100;l.options.pagination&&(l.options.pagination=!1,console.error("Jspreadsheet: Pagination will be disable due the lazyLoading"))}else l.options.pagination?(l.pageNumber||(l.pageNumber=0),l.options.pagination,p=l.options.pagination*l.pageNumber,h=l.options.pagination*l.pageNumber+l.options.pagination,l.options.data.length<h&&(h=l.options.data.length)):(p=0,h=l.options.data.length);for(o=0;o<l.options.data.length;o++){var g=l.createRow(o,l.options.data[o]);o>=p&&o<h&&l.tbody.appendChild(g)}if(1==l.options.lazyLoading||l.options.pagination&&l.updatePagination(),l.options.mergeCells){var f=Object.keys(l.options.mergeCells);for(r=0;r<f.length;r++){var m=l.options.mergeCells[f[r]];l.setMerge(f[r],m[0],m[1],1)}}l.updateTable(),l.dispatch("onload",e,l)},l.getData=function(e,t){for(var o=[],n=0,r=0,s=1==t||0==l.options.copyCompatibility,i=l.options.columns.length,a=l.options.data.length,c=0;c<a;c++){n=0;for(var u=0;u<i;u++)e&&!l.records[c][u].classList.contains("highlight")||(o[r]||(o[r]=[]),o[r][n]=s?l.options.data[c][u]:l.records[c][u].innerHTML,n++);n>0&&r++}return o},l.getJsonRow=function(e){for(var t=l.options.data[e],o=l.options.columns.length,n={},r=0;r<o;r++)l.options.columns[r].name||(l.options.columns[r].name=r),n[l.options.columns[r].name]=t[r];return n},l.getJson=function(e){for(var t=[],o=l.options.columns.length,n=l.options.data.length,r=0;r<n;r++){for(var s=null,i=0;i<o;i++)e&&!l.records[r][i].classList.contains("highlight")||(null==s&&(s={}),l.options.columns[i].name||(l.options.columns[i].name=i),s[l.options.columns[i].name]=l.options.data[r][i]);null!=s&&t.push(s)}return t},l.prepareJson=function(e){for(var t=[],o=0;o<e.length;o++){var n=e[o].x,r=e[o].y,s=l.options.columns[n].name?l.options.columns[n].name:n;t[r]||(t[r]={row:r,data:{}}),t[r].data[s]=e[o].newValue}return t.filter(function(e){return null!=e})},l.save=function(t,o){var n=l.dispatch("onbeforesave",e,l,o);if(n)o=n;else if(!1===n)return!1;jSuites.ajax({url:t,method:"POST",dataType:"json",data:{data:JSON.stringify(o)},success:function(t){l.dispatch("onsave",e,l,o)}})},l.getRowData=function(e){return l.options.data[e]},l.setRowData=function(e,t){for(var o=0;o<l.headers.length;o++){var n=r.getColumnNameFromId([o,e]);null!=t[o]&&l.setValue(n,t[o])}},l.getColumnData=function(e){for(var t=[],o=0;o<l.options.data.length;o++)t.push(l.options.data[o][e]);return t},l.setColumnData=function(e,t){for(var o=0;o<l.rows.length;o++){var n=r.getColumnNameFromId([e,o]);null!=t[o]&&l.setValue(n,t[o])}},l.createRow=function(e,t){l.records[e]||(l.records[e]=[]),t||(t=l.options.data[e]),l.rows[e]=document.createElement("tr"),l.rows[e].setAttribute("data-y",e);var o=null;l.options.defaultRowHeight&&(l.rows[e].style.height=l.options.defaultRowHeight+"px"),l.options.rows[e]&&(l.options.rows[e].height&&(l.rows[e].style.height=l.options.rows[e].height),l.options.rows[e].title&&(o=l.options.rows[e].title)),o||(o=parseInt(e+1));var n=document.createElement("td");n.innerHTML=o,n.setAttribute("data-y",e),n.className="jexcel_row",l.rows[e].appendChild(n);for(var r=0;r<l.options.columns.length;r++)l.records[e][r]=l.createCell(r,e,t[r]),l.rows[e].appendChild(l.records[e][r]);return l.rows[e]},l.parseValue=function(e,t,r,s){"="==(""+r).substr(0,1)&&1==l.options.parseFormulas&&(r=l.executeFormula(r,e,t));var i=l.options.columns[e];if(i&&!o(r)){var a=null;if(a=n(i)){r&&r==Number(r)&&(r=Number(r));var c=jSuites.mask.render(r,a,!0);if(s&&a.mask){var u=a.mask.split(";");u[1]&&(u[1].match(new RegExp("\\[Red\\]","gi"))&&(r<0?s.classList.add("red"):s.classList.remove("red")),u[1].match(new RegExp("\\(","gi"))&&r<0&&(c="("+c+")"))}c&&(r=c)}}return r};var d=function(e){return"-"==(e=""+e).substr(4,1)&&"-"==e.substr(7,1)||4==(e=e.split("-"))[0].length&&e[0]==Number(e[0])&&2==e[1].length&&e[1]==Number(e[1])};l.createCell=function(e,t,o){var n=document.createElement("td");if(n.setAttribute("data-x",e),n.setAttribute("data-y",t),"="==(""+o).substr(0,1)&&1==l.options.secureFormulas){var r=g(o);r!=o&&(o=r)}if(l.options.columns[e].editor)!1===l.options.stripHTML||!1===l.options.columns[e].stripHTML?n.innerHTML=o:n.textContent=o,"function"==typeof l.options.columns[e].editor.createCell&&(n=l.options.columns[e].editor.createCell(n));else if("hidden"==l.options.columns[e].type)n.style.display="none",n.textContent=o;else if("checkbox"==l.options.columns[e].type||"radio"==l.options.columns[e].type){var s=document.createElement("input");s.type=l.options.columns[e].type,s.name="c"+e,s.checked=1==o||1==o||"true"==o,s.onclick=function(){l.setValue(n,this.checked)},1!=l.options.columns[e].readOnly&&0!=l.options.editable||s.setAttribute("disabled","disabled"),n.appendChild(s),l.options.data[t][e]=s.checked}else if("calendar"==l.options.columns[e].type){var i=null;if(!d(o)){var a=jSuites.calendar.extractDateFromString(o,l.options.columns[e].options.format);a&&(i=a)}n.textContent=jSuites.calendar.getDateString(i||o,l.options.columns[e].options.format)}else if("dropdown"==l.options.columns[e].type||"autocomplete"==l.options.columns[e].type)n.classList.add("jexcel_dropdown"),n.textContent=l.getDropDownValue(e,o);else if("color"==l.options.columns[e].type)if("square"==l.options.columns[e].render){var c=document.createElement("div");c.className="color",c.style.backgroundColor=o,n.appendChild(c)}else n.style.color=o,n.textContent=o;else if("image"==l.options.columns[e].type){if(o&&"data:image"==o.substr(0,10)){var u=document.createElement("img");u.src=o,n.appendChild(u)}}else if("html"==l.options.columns[e].type)n.innerHTML=p(l.parseValue(e,t,o,n));else if(!1===l.options.stripHTML||!1===l.options.columns[e].stripHTML)n.innerHTML=p(l.parseValue(e,t,o,n));else{var h=document.createElement("div");h.textContent=l.parseValue(e,t,o,n),n.appendChild(h)}1==l.options.columns[e].readOnly&&(n.className="readonly");var f=l.options.columns[e].align?l.options.columns[e].align:"center";return n.style.textAlign=f,0!=l.options.columns[e].wordWrap&&(1==l.options.wordWrap||1==l.options.columns[e].wordWrap||n.innerHTML.length>200)&&(n.style.whiteSpace="pre-wrap"),e>0&&1==this.options.textOverflow&&(o||n.innerHTML?l.records[t][e-1].style.overflow="hidden":e==l.options.columns.length-1&&(n.style.overflow="hidden")),n},l.createCellHeader=function(e){var t=l.options.columns[e].width?l.options.columns[e].width:l.options.defaultColWidth,o=l.options.columns[e].align?l.options.columns[e].align:l.options.defaultColAlign;l.headers[e]=document.createElement("td"),l.options.stripHTML?l.headers[e].textContent=l.options.columns[e].title?l.options.columns[e].title:r.getColumnName(e):l.headers[e].innerHTML=l.options.columns[e].title?l.options.columns[e].title:r.getColumnName(e),l.headers[e].setAttribute("data-x",e),l.headers[e].style.textAlign=o,l.options.columns[e].title&&l.headers[e].setAttribute("title",l.headers[e].innerText),l.options.columns[e].id&&l.headers[e].setAttribute("id",l.options.columns[e].id),l.colgroup[e]=document.createElement("col"),l.colgroup[e].setAttribute("width",t),"hidden"==l.options.columns[e].type&&(l.headers[e].style.display="none",l.colgroup[e].style.display="none")},l.updateNestedHeader=function(e,t,o){l.options.nestedHeaders[t][e].title&&(l.options.nestedHeaders[t][e].title=o,l.options.nestedHeaders[t].element.children[e+1].textContent=o)},l.createNestedHeader=function(e){var t=document.createElement("tr");t.classList.add("jexcel_nested");var o=document.createElement("td");t.appendChild(o),e.element=t;for(var n=0,r=0;r<e.length;r++){e[r].colspan||(e[r].colspan=1),e[r].align||(e[r].align="center"),e[r].title||(e[r].title=""),e[r].id||(e[r].id="");for(var s=e[r].colspan,i=[],a=0;a<s;a++)l.options.columns[n]&&"hidden"==l.options.columns[n].type&&s++,i.push(n),n++;(o=document.createElement("td")).setAttribute("data-column",i.join(",")),o.setAttribute("colspan",e[r].colspan),o.setAttribute("align",e[r].align),o.setAttribute("id",e[r].id),o.textContent=e[r].title,t.appendChild(o)}return t},l.createToolbar=function(t){t?l.options.toolbar=t:t=l.options.toolbar;for(var o=0;o<t.length;o++)if("i"==t[o].type)(i=document.createElement("i")).classList.add("jexcel_toolbar_item"),i.classList.add("material-icons"),i.setAttribute("data-k",t[o].k),i.setAttribute("data-v",t[o].v),i.setAttribute("id",t[o].id),t[o].tooltip&&i.setAttribute("title",t[o].tooltip),t[o].onclick&&(t[o].onclick,1)?i.onclick=function(o){var n=o;return function(){t[n].onclick(e,l,this)}}(o):i.onclick=function(){var e=this.getAttribute("data-k"),t=this.getAttribute("data-v");l.setStyle(l.highlighted,e,t)},i.textContent=t[o].content,l.toolbar.appendChild(i);else if("select"==t[o].type){var n=!1;(i=document.createElement("select")).classList.add("jexcel_toolbar_item"),i.setAttribute("data-k",t[o].k),t[o].tooltip&&i.setAttribute("title",t[o].tooltip),t[o].onchange&&(t[o].onchange,1)?(i.onchange=t[o].onchange,n=!0):i.onchange=function(){var e=this.getAttribute("data-k");l.setStyle(l.highlighted,e,this.value)};for(var r=0;r<t[o].v.length;r++){var s=document.createElement("option");s.value=t[o].v[r],s.textContent=t[o].v[r],t[o].selectedValue&&s.value===t[o].selectedValue&&(s.selected=!0),i.appendChild(s)}n&&i.dispatchEvent(new Event("change")),l.toolbar.appendChild(i)}else if("color"==t[o].type){var i;(i=document.createElement("i")).classList.add("jexcel_toolbar_item"),i.classList.add("material-icons"),i.setAttribute("data-k",t[o].k),i.setAttribute("data-v",""),t[o].tooltip&&i.setAttribute("title",t[o].tooltip),l.toolbar.appendChild(i),i.textContent=t[o].content,jSuites.color(i,{onchange:function(e,t){var o=e.getAttribute("data-k");l.setStyle(l.highlighted,o,t)}})}},l.setMerge=function(t,o,n,s){var i=!1;if(!t){if(!l.highlighted.length)return alert(l.options.text.noCellsSelected),null;var a=parseInt(l.highlighted[0].getAttribute("data-x")),c=parseInt(l.highlighted[0].getAttribute("data-y")),u=parseInt(l.highlighted[l.highlighted.length-1].getAttribute("data-x")),d=parseInt(l.highlighted[l.highlighted.length-1].getAttribute("data-y"));t=r.getColumnNameFromId([a,c]),o=u-a+1,n=d-c+1}var p=r.getIdFromColumnName(t,!0);if(l.options.mergeCells[t])l.records[p[1]][p[0]].getAttribute("data-merged")&&(i=l.options.text.cellAlreadyMerged);else if((!o||o<2)&&(!n||n<2))i=l.options.text.invalidMergeProperties;else for(var h=p[1];h<p[1]+n;h++)for(var g=p[0];g<p[0]+o;g++)r.getColumnNameFromId([g,h]),l.records[h][g].getAttribute("data-merged")&&(i=l.options.text.thereIsAConflictWithAnotherMergedCell);if(i)alert(i);else{o>1?l.records[p[1]][p[0]].setAttribute("colspan",o):o=1,n>1?l.records[p[1]][p[0]].setAttribute("rowspan",n):n=1,l.options.mergeCells[t]=[o,n,[]],l.records[p[1]][p[0]].setAttribute("data-merged","true"),l.records[p[1]][p[0]].style.overflow="hidden";for(var f=[],m=p[1];m<p[1]+n;m++)for(var C=p[0];C<p[0]+o;C++)p[0]==C&&p[1]==m||(f.push(l.options.data[m][C]),l.updateCell(C,m,"",!0),l.options.mergeCells[t][2].push(l.records[m][C]),l.records[m][C].style.display="none",l.records[m][C]=l.records[p[1]][p[0]]);l.updateSelection(l.records[p[1]][p[0]]),s||(l.setHistory({action:"setMerge",column:t,colspan:o,rowspan:n,data:f}),l.dispatch("onmerge",e,t,o,n))}},l.getMerge=function(e){var t={};if(e)t=l.options.mergeCells[e]?[l.options.mergeCells[e][0],l.options.mergeCells[e][1]]:null;else if(l.options.mergeCells){l.options.mergeCells;for(var o=Object.keys(l.options.mergeCells),n=0;n<o.length;n++)t[o[n]]=[l.options.mergeCells[o[n]][0],l.options.mergeCells[o[n]][1]]}return t},l.removeMerge=function(e,t,o){if(l.options.mergeCells[e]){var n=r.getIdFromColumnName(e,!0);l.records[n[1]][n[0]].removeAttribute("colspan"),l.records[n[1]][n[0]].removeAttribute("rowspan"),l.records[n[1]][n[0]].removeAttribute("data-merged");for(var s=l.options.mergeCells[e],i=0,a=0;a<s[1];a++)for(var c=0;c<s[0];c++)(a>0||c>0)&&(l.records[n[1]+a][n[0]+c]=s[2][i],l.records[n[1]+a][n[0]+c].style.display="",t&&t[i]&&l.updateCell(n[0]+c,n[1]+a,t[i]),i++);l.updateSelection(l.records[n[1]][n[0]],l.records[n[1]+a-1][n[0]+c-1]),o||delete l.options.mergeCells[e]}},l.destroyMerged=function(e){if(l.options.mergeCells){l.options.mergeCells;for(var t=Object.keys(l.options.mergeCells),o=0;o<t.length;o++)l.removeMerge(t[o],null,e)}},l.isColMerged=function(e,t){var o=[];if(l.options.mergeCells)for(var n=Object.keys(l.options.mergeCells),s=0;s<n.length;s++){var i=r.getIdFromColumnName(n[s],!0),a=l.options.mergeCells[n[s]][0],c=i[0],u=i[0]+(a>1?a-1:0);null==t?c<=e&&u>=e&&o.push(n[s]):t?c<e&&u>=e&&o.push(n[s]):c<=e&&u>e&&o.push(n[s])}return o},l.isRowMerged=function(e,t){var o=[];if(l.options.mergeCells)for(var n=Object.keys(l.options.mergeCells),s=0;s<n.length;s++){var i=r.getIdFromColumnName(n[s],!0),a=l.options.mergeCells[n[s]][1],c=i[1],u=i[1]+(a>1?a-1:0);null==t?c<=e&&u>=e&&o.push(n[s]):t?c<e&&u>=e&&o.push(n[s]):c<=e&&u>e&&o.push(n[s])}return o},l.openFilter=function(e){if(l.options.filters){e=parseInt(e),l.resetSelection();var t=[];if("checkbox"==l.options.columns[e].type)t.push({id:"true",name:"True"}),t.push({id:"false",name:"False"});else{for(var o=[],n=!1,r=0;r<l.options.data.length;r++){var s=l.options.data[r][e],i=l.records[r][e].innerHTML;s&&i?o[s]=i:n=!0}var a=Object.keys(o);for(t=[],r=0;r<a.length;r++)t.push({id:a[r],name:o[a[r]]});n&&t.push({value:"",id:"",name:"(Blanks)"})}var c=document.createElement("div");l.filter.children[e+1].innerHTML="",l.filter.children[e+1].appendChild(c),l.filter.children[e+1].style.paddingLeft="0px",l.filter.children[e+1].style.paddingRight="0px",l.filter.children[e+1].style.overflow="initial";var u={data:t,multiple:!0,autocomplete:!0,opened:!0,value:void 0!==l.filters[e]?l.filters[e]:null,width:"100%",position:1==l.options.tableOverflow||1==l.options.fullscreen,onclose:function(t){l.resetFilters(),l.filters[e]=t.dropdown.getValue(!0),l.filter.children[e+1].innerHTML=t.dropdown.getText(),l.filter.children[e+1].style.paddingLeft="",l.filter.children[e+1].style.paddingRight="",l.filter.children[e+1].style.overflow="",l.closeFilter(e),l.refreshSelection()}};jSuites.dropdown(c,u)}else console.log("Jspreadsheet: filters not enabled.")},l.resetFilters=function(){if(l.options.filters)for(var e=0;e<l.filter.children.length;e++)l.filter.children[e].innerHTML="&nbsp;",l.filters[e]=null;l.results=null,l.updateResult()},l.closeFilter=function(e){if(!e)for(var t=0;t<l.filter.children.length;t++)l.filters[t]&&(e=t);var o=function(e,t,o){for(var n=0;n<e.length;n++){var r=""+l.options.data[o][t],s=""+l.records[o][t].innerHTML;if(e[n]==r||e[n]==s)return!0}return!1},n=l.filters[e];l.results=[];for(var r=0;r<l.options.data.length;r++)o(n,e,r)&&l.results.push(r);l.results.length||(l.results=null),l.updateResult()},l.openEditor=function(t,r,s){var i=t.getAttribute("data-y"),a=t.getAttribute("data-x");l.dispatch("oneditionstart",e,t,a,i),a>0&&(l.records[i][a-1].style.overflow="hidden");var c=function(o){var n=t.getBoundingClientRect(),r=document.createElement(o);return r.style.width=n.width-6+"px",r.style.height=n.height-6+"px",r.style.minHeight=n.height-6+"px",t.classList.add("editor"),t.innerHTML="",t.appendChild(r),l.dispatch("oncreateeditor",e,t,a,i,r),r};if(1==t.classList.contains("readonly"));else if(l.edition=[l.records[i][a],l.records[i][a].innerHTML,a,i],l.options.columns[a].editor)l.options.columns[a].editor.openEditor(t,e,r,s);else if("hidden"==l.options.columns[a].type);else if("checkbox"==l.options.columns[a].type||"radio"==l.options.columns[a].type){var u=!t.children[0].checked;l.setValue(t,u),l.edition=null}else if("dropdown"==l.options.columns[a].type||"autocomplete"==l.options.columns[a].type){if(u=l.options.data[i][a],l.options.columns[a].multiple&&!Array.isArray(u)&&(u=u.split(";")),"function"==typeof l.options.columns[a].filter)var d=l.options.columns[a].filter(e,t,a,i,l.options.columns[a].source);else d=l.options.columns[a].source;for(var p=[],h=0;h<d.length;h++)p.push(d[h]);var g=c("div"),f={data:p,multiple:!!l.options.columns[a].multiple,autocomplete:!(!l.options.columns[a].autocomplete&&"autocomplete"!=l.options.columns[a].type),opened:!0,value:u,width:"100%",height:g.style.minHeight,position:1==l.options.tableOverflow||1==l.options.fullscreen,onclose:function(){l.closeEditor(t,!0)}};l.options.columns[a].options&&l.options.columns[a].options.type&&(f.type=l.options.columns[a].options.type),jSuites.dropdown(g,f)}else if("calendar"==l.options.columns[a].type||"color"==l.options.columns[a].type)u=l.options.data[i][a],(g=c("input")).value=u,1!=l.options.tableOverflow&&1!=l.options.fullscreen||(l.options.columns[a].options.position=!0),l.options.columns[a].options.value=l.options.data[i][a],l.options.columns[a].options.opened=!0,l.options.columns[a].options.onclose=function(e,o){l.closeEditor(t,!0)},"color"==l.options.columns[a].type?jSuites.color(g,l.options.columns[a].options):jSuites.calendar(g,l.options.columns[a].options),g.focus();else if("html"==l.options.columns[a].type){u=l.options.data[i][a],(g=c("div")).style.position="relative",(y=document.createElement("div")).classList.add("jexcel_richtext"),g.appendChild(y),jSuites.editor(y,{focus:!0,value:u});var m=t.getBoundingClientRect(),C=y.getBoundingClientRect();window.innerHeight<m.bottom+C.height?y.style.top=m.top-(C.height+2)+"px":y.style.top=m.top+"px"}else if("image"==l.options.columns[a].type){var y,v=t.children[0];(g=c("div")).style.position="relative",(y=document.createElement("div")).classList.add("jclose"),v&&v.src&&y.appendChild(v),g.appendChild(y),jSuites.image(y,l.options.imageOptions),m=t.getBoundingClientRect(),C=y.getBoundingClientRect(),window.innerHeight<m.bottom+C.height?y.style.top=m.top-(C.height+2)+"px":y.style.top=m.top+"px"}else{t.classList.add("editing");var b=t.getBoundingClientRect().height;if(l.rows[i].style.setProperty("--table-editor-line-clamp-editing",Math.floor((b-10)/14)),l.updateCornerPosition(),u=1==r?"":l.options.data[i][a],0==l.options.columns[a].wordWrap||1!=l.options.wordWrap&&1!=l.options.columns[a].wordWrap)g=c("input");else g=c("textarea");g.focus(),g.value=u,f=l.options.columns[a];var w=null;if(!o(u)&&(w=n(f))){if(!f.disabledMaskOnEdition)if(f.mask){var A=f.mask.split(";");g.setAttribute("data-mask",A[0])}else f.locale&&g.setAttribute("data-locale",f.locale);w.input=g,g.mask=w,jSuites.mask.render(u,w,!1)}g.onblur=function(){l.closeEditor(t,!0)},g.scrollLeft=g.scrollWidth}},l.closeEditor=function(t,r){var s=parseInt(t.getAttribute("data-x")),i=parseInt(t.getAttribute("data-y"));if(t.classList.remove("editing"),l.rows[i].style.removeProperty("--table-editor-line-clamp-editing"),l.updateCornerPosition(),1==r){if(l.options.columns[s].editor)var a=l.options.columns[s].editor.closeEditor(t,r);else if("checkbox"==l.options.columns[s].type||"radio"==l.options.columns[s].type||"hidden"==l.options.columns[s].type);else if("dropdown"==l.options.columns[s].type||"autocomplete"==l.options.columns[s].type)a=t.children[0].dropdown.close(!0);else if("calendar"==l.options.columns[s].type)a=t.children[0].calendar.close(!0);else if("color"==l.options.columns[s].type)a=t.children[0].color.close(!0);else if("html"==l.options.columns[s].type)a=t.children[0].children[0].editor.getData();else if("image"==l.options.columns[s].type){var c=t.children[0].children[0].children[0];a=c&&"IMG"==c.tagName?c.src:""}else if("numeric"==l.options.columns[s].type)"="!=(""+(a=t.children[0].value)).substr(0,1)&&""==a&&(a=l.options.columns[s].allowEmpty?"":0),t.children[0].onblur=null;else{a=t.children[0].value,t.children[0].onblur=null;var u,d=l.options.columns[s];if((u=n(d))&&""!==a&&!o(a)&&"number"!=typeof a){var p=jSuites.mask.extract(a,u,!0);p&&""!==p.value&&(a=p.value)}}l.options.data[i][s]==a?t.innerHTML=l.edition[1]:l.setValue(t,a)}else l.options.columns[s].editor?l.options.columns[s].editor.closeEditor(t,r):"dropdown"==l.options.columns[s].type||"autocomplete"==l.options.columns[s].type?t.children[0].dropdown.close(!0):"calendar"==l.options.columns[s].type?t.children[0].calendar.close(!0):"color"==l.options.columns[s].type?t.children[0].color.close(!0):t.children[0].onblur=null,t.innerHTML=l.edition&&l.edition[1]?l.edition[1]:"";l.dispatch("oneditionend",e,t,s,i,a,r),t.classList.remove("editor"),l.edition=null},l.getCell=function(e){var t=(e=r.getIdFromColumnName(e,!0))[0],o=e[1];return l.records[o][t]},l.getColumnOptions=function(e,t){var o=l.options.columns[e];return o||(o={type:"text"}),o},l.getCellFromCoords=function(e,t){return l.records[t][e]},l.getLabel=function(e){var t=(e=r.getIdFromColumnName(e,!0))[0],o=e[1];return l.records[o][t].innerHTML},l.getLabelFromCoords=function(e,t){return l.records[t][e].innerHTML},l.getValue=function(e,t){if("object"==typeof e)var o=e.getAttribute("data-x"),n=e.getAttribute("data-y");else o=(e=r.getIdFromColumnName(e,!0))[0],n=e[1];var s=null;return null!=o&&null!=n&&(l.records[n]&&l.records[n][o]&&(t||1==l.options.copyCompatibility)?s=l.records[n][o].innerHTML:l.options.data[n]&&"undefined"!=l.options.data[n][o]&&(s=l.options.data[n][o])),s},l.getValueFromCoords=function(e,t,o){var n=null;return null!=e&&null!=t&&(l.records[t]&&l.records[t][e]&&o||1==l.options.copyCompatibility?n=l.records[t][e].innerHTML:l.options.data[t]&&"undefined"!=l.options.data[t][e]&&(n=l.options.data[t][e])),n},l.setValue=function(t,o,n){var s=[];if("string"==typeof t){var i=(d=r.getIdFromColumnName(t,!0))[0],a=d[1];s.push(l.updateCell(i,a,o,n)),l.updateFormulaChain(i,a,s)}else if(i=null,a=null,t&&t.getAttribute&&(i=t.getAttribute("data-x"),a=t.getAttribute("data-y")),null!=i&&null!=a)s.push(l.updateCell(i,a,o,n)),l.updateFormulaChain(i,a,s);else{var c=Object.keys(t);if(c.length>0)for(var u=0;u<c.length;u++){var d;"string"==typeof t[u]?(i=(d=r.getIdFromColumnName(t[u],!0))[0],a=d[1]):null!=t[u].x&&null!=t[u].y?(i=t[u].x,a=t[u].y,null!=t[u].newValue?o=t[u].newValue:null!=t[u].value&&(o=t[u].value)):(i=t[u].getAttribute("data-x"),a=t[u].getAttribute("data-y")),null!=i&&null!=a&&(s.push(l.updateCell(i,a,o,n)),l.updateFormulaChain(i,a,s))}}l.setHistory({action:"setValue",records:s,selection:l.selectedCell}),l.updateTable(),l.onafterchanges(e,s)},l.setValueFromCoords=function(t,o,n,r){var s=[];s.push(l.updateCell(t,o,n,r)),l.updateFormulaChain(t,o,s),l.setHistory({action:"setValue",records:s,selection:l.selectedCell}),l.updateTable(),l.onafterchanges(e,s)},l.setCheckRadioValue=function(){for(var t=[],o=Object.keys(l.highlighted),n=0;n<o.length;n++){var r=l.highlighted[n].getAttribute("data-x"),s=l.highlighted[n].getAttribute("data-y");"checkbox"!=l.options.columns[r].type&&"radio"!=l.options.columns[r].type||t.push(l.updateCell(r,s,!l.options.data[s][r]))}t.length&&(l.setHistory({action:"setValue",records:t,selection:l.selectedCell}),l.onafterchanges(e,t))};var p=function(e){var t=new Option;t.innerHTML=e;var o=null;for(e=t.getElementsByTagName("script");o=e[0];)o.parentNode.removeChild(o);return t.innerHTML};l.updateCell=function(t,o,n,r){if(1!=l.records[o][t].classList.contains("readonly")||r){var s;"="==(""+n).substr(0,1)&&1==l.options.secureFormulas&&(s=g(n))!=n&&(n=s),null!=(s=l.dispatch("onbeforechange",e,l.records[o][t],t,o,n))&&(n=s),l.options.columns[t].editor&&"function"==typeof l.options.columns[t].editor.updateCell&&(n=l.options.columns[t].editor.updateCell(l.records[o][t],n,r)),m={x:t,y:o,col:t,row:o,newValue:n,oldValue:l.options.data[o][t]};let C=l.options.columns[t].editor;if(C)l.options.data[o][t]=n,"function"==typeof C.setValue&&C.setValue(l.records[o][t],n);else if("checkbox"==l.options.columns[t].type||"radio"==l.options.columns[t].type){if("radio"==l.options.columns[t].type)for(var i=0;i<l.options.data.length;i++)l.options.data[i][t]=!1;l.records[o][t].children[0].checked=1==n||1==n||"true"==n||"TRUE"==n,l.options.data[o][t]=l.records[o][t].children[0].checked}else if("dropdown"==l.options.columns[t].type||"autocomplete"==l.options.columns[t].type)l.options.data[o][t]=n,l.records[o][t].textContent=l.getDropDownValue(t,n);else if("calendar"==l.options.columns[t].type){var a=null;if(!d(n)){var c=jSuites.calendar.extractDateFromString(n,l.options.columns[t].options.format);c&&(a=c)}l.options.data[o][t]=n,l.records[o][t].textContent=jSuites.calendar.getDateString(a||n,l.options.columns[t].options.format)}else if("color"==l.options.columns[t].type)if(l.options.data[o][t]=n,"square"==l.options.columns[t].render){var u=document.createElement("div");u.className="color",u.style.backgroundColor=n,l.records[o][t].textContent="",l.records[o][t].appendChild(u)}else l.records[o][t].style.color=n,l.records[o][t].textContent=n;else if("image"==l.options.columns[t].type){if(n=""+n,l.options.data[o][t]=n,l.records[o][t].innerHTML="",n&&"data:image"==n.substr(0,10)){var h=document.createElement("img");h.src=n,l.records[o][t].appendChild(h)}}else{if(l.options.data[o][t]=n,"html"==l.options.columns[t].type)l.records[o][t].innerHTML=p(l.parseValue(t,o,n));else if(!1===l.options.stripHTML||!1===l.options.columns[t].stripHTML)l.records[o][t].innerHTML=p(l.parseValue(t,o,n,l.records[o][t]));else{var f=document.createElement("div");f.textContent=l.parseValue(t,o,n,l.records[o][t]),l.records[o][t].textContent="",l.records[o][t].appendChild(f)}0!=l.options.columns[t].wordWrap&&(1==l.options.wordWrap||1==l.options.columns[t].wordWrap||l.records[o][t].innerHTML.length>200)?l.records[o][t].style.whiteSpace="pre-wrap":l.records[o][t].style.whiteSpace=""}t>0&&(l.records[o][t-1].style.overflow=n?"hidden":""),l.dispatch("onchange",e,l.records[o]&&l.records[o][t]?l.records[o][t]:null,t,o,n,m.oldValue)}else var m={x:t,y:o,col:t,row:o};return m},l.copyData=function(t,o){var n=l.getData(!0,!0),s=l.selectedContainer,i=parseInt(t.getAttribute("data-x")),a=parseInt(t.getAttribute("data-y")),c=parseInt(o.getAttribute("data-x")),u=parseInt(o.getAttribute("data-y")),d=[],p=!1;if(s[0]==i){if(a<s[1])var h=a-s[1];else h=1;var g=0}else g=i<s[0]?i-s[0]:1,h=0;for(var f=0,m=0,C=a;C<=u;C++)if(!l.rows[C]||"none"!=l.rows[C].style.display){null==n[m]&&(m=0),f=0,s[0]!=i&&(g=i<s[0]?i-s[0]:1);for(var y=i;y<=c;y++){if(l.records[C][y]&&!l.records[C][y].classList.contains("readonly")&&"none"!=l.records[C][y].style.display&&0==p){if(!l.selection.length&&""!=l.options.data[C][y]){p=!0;continue}(null==n[m]||null==n[m][f])&&(f=0);var v=n[m][f];if(v&&!n[1]&&1==l.options.autoIncrement)if("text"==l.options.columns[y].type||"number"==l.options.columns[y].type)if("="==(""+v).substr(0,1)){var b=v.match(/([A-Z]+[0-9]+)/g);if(b){for(var w=[],A=0;A<b.length;A++){var x=r.getIdFromColumnName(b[A],1);x[0]+=g,x[1]+=h,x[1]<0&&(x[1]=0);var F=r.getColumnNameFromId([x[0],x[1]]);F!=b[A]&&(w[b[A]]=F)}w&&(v=l.updateFormula(v,w))}}else v==Number(v)&&(v=Number(v)+h);else if("calendar"==l.options.columns[y].type){var E=new Date(v);E.setDate(E.getDate()+h),v=E.getFullYear()+"-"+r.doubleDigitFormat(parseInt(E.getMonth()+1))+"-"+r.doubleDigitFormat(E.getDate())+" 00:00:00"}d.push(l.updateCell(y,C,v)),l.updateFormulaChain(y,C,d)}f++,s[0]!=i&&g++}m++,h++}l.setHistory({action:"setValue",records:d,selection:l.selectedCell}),l.updateTable(),l.onafterchanges(e,d)},l.refreshSelection=function(){l.selectedCell&&l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3])},l.conditionalSelectionUpdate=function(e,t,o){if(1==e){if(l.selectedCell&&(t>=l.selectedCell[1]&&t<=l.selectedCell[3]||o>=l.selectedCell[1]&&o<=l.selectedCell[3]))return void l.resetSelection()}else if(l.selectedCell&&(t>=l.selectedCell[0]&&t<=l.selectedCell[2]||o>=l.selectedCell[0]&&o<=l.selectedCell[2]))return void l.resetSelection()},l.resetSelection=function(t){if(l.highlighted.length){d=1;for(var o=0;o<l.highlighted.length;o++){l.highlighted[o].classList.remove("highlight"),l.highlighted[o].classList.remove("highlight-left"),l.highlighted[o].classList.remove("highlight-right"),l.highlighted[o].classList.remove("highlight-top"),l.highlighted[o].classList.remove("highlight-bottom"),l.highlighted[o].classList.remove("highlight-selected");var n=parseInt(l.highlighted[o].getAttribute("data-x")),r=parseInt(l.highlighted[o].getAttribute("data-y"));if(l.highlighted[o].getAttribute("data-merged"))var s=parseInt(l.highlighted[o].getAttribute("colspan")),i=parseInt(l.highlighted[o].getAttribute("rowspan")),a=s>0?n+(s-1):n,c=i>0?r+(i-1):r;else a=n,c=r;for(var u=n;u<=a;u++)l.headers[u]&&l.headers[u].classList.remove("selected");for(u=r;u<=c;u++)l.rows[u]&&l.rows[u].classList.remove("selected")}}else var d=0;return l.highlighted=[],l.selectedCell=null,l.corner.style.top="-2000px",l.corner.style.left="-2000px",1==t&&1==d&&l.dispatch("onblur",e),d},l.updateSelection=function(e,t,o){var n=e.getAttribute("data-x"),r=e.getAttribute("data-y");if(t)var s=t.getAttribute("data-x"),i=t.getAttribute("data-y");else s=n,i=r;l.updateSelectionFromCoords(n,r,s,i,o)},l.updateSelectionFromCoords=function(t,o,n,r,s){var i=l.resetSelection();if(null==o&&(o=0,r=l.rows.length-1),null==n&&(n=t),null==r&&(r=o),t>=l.headers.length&&(t=l.headers.length-1),o>=l.rows.length&&(o=l.rows.length-1),n>=l.headers.length&&(n=l.headers.length-1),r>=l.rows.length&&(r=l.rows.length-1),l.selectedCell=[t,o,n,r],null!=t){if(l.records[o][t]&&l.records[o][t].classList.add("highlight-selected"),parseInt(t)<parseInt(n))var a=parseInt(t),c=parseInt(n);else a=parseInt(n),c=parseInt(t);if(parseInt(o)<parseInt(r))var u=parseInt(o),d=parseInt(r);else u=parseInt(r),d=parseInt(o);for(var p=a;p<=c;p++)for(var h=u;h<=d;h++)if(l.records[h][p]&&l.records[h][p].getAttribute("data-merged")){var g=parseInt(l.records[h][p].getAttribute("data-x")),f=parseInt(l.records[h][p].getAttribute("data-y")),m=parseInt(l.records[h][p].getAttribute("colspan")),C=parseInt(l.records[h][p].getAttribute("rowspan"));m>1&&(g<a&&(a=g),g+m>c&&(c=g+m-1)),C&&(f<u&&(u=f),f+C>d&&(d=f+C-1))}var y=null,v=null,b=null,w=null;for(h=u;h<=d;h++)"none"!=l.rows[h].style.display&&(null==b&&(b=h),w=h);for(p=a;p<=c;p++){for(h=u;h<=d;h++)"none"!=l.rows[h].style.display&&"none"!=l.records[h][p].style.display&&(l.records[h][p].classList.add("highlight"),l.highlighted.push(l.records[h][p]));"hidden"!=l.options.columns[p].type&&(null==y&&(y=p),v=p)}for(y||(y=0),v||(v=0),p=y;p<=v;p++)"hidden"!=l.options.columns[p].type&&l.colgroup[p].style&&"none"!=l.colgroup[p].style.display&&(l.records[b]&&l.records[b][p]&&l.records[b][p].classList.add("highlight-top"),l.records[w]&&l.records[w][p]&&l.records[w][p].classList.add("highlight-bottom"),l.headers[p].classList.add("selected"));for(h=b;h<=w;h++)l.rows[h]&&"none"!=l.rows[h].style.display&&(l.records[h][y].classList.add("highlight-left"),l.records[h][v].classList.add("highlight-right"),l.rows[h].classList.add("selected"));l.selectedContainer=[y,b,v,w]}0==i&&(l.dispatch("onfocus",e),l.removeCopyingSelection()),l.dispatch("onselection",e,y,b,v,w,s),l.updateCornerPosition()},l.removeCopySelection=function(){for(var e=0;e<l.selection.length;e++)l.selection[e].classList.remove("selection"),l.selection[e].classList.remove("selection-left"),l.selection[e].classList.remove("selection-right"),l.selection[e].classList.remove("selection-top"),l.selection[e].classList.remove("selection-bottom");l.selection=[]},l.updateCopySelection=function(e,t){l.removeCopySelection();var o=l.selectedContainer[0],n=l.selectedContainer[1],r=l.selectedContainer[2],s=l.selectedContainer[3];if(null!=e&&null!=t){if(e-r>0)var i=parseInt(r)+1,a=parseInt(e);else i=parseInt(e),a=parseInt(o)-1;if(t-s>0)var c=parseInt(s)+1,u=parseInt(t);else c=parseInt(t),u=parseInt(n)-1;a-i<=u-c?(i=parseInt(o),a=parseInt(r)):(c=parseInt(n),u=parseInt(s));for(var d=c;d<=u;d++)for(var p=i;p<=a;p++)l.records[d][p]&&"none"!=l.rows[d].style.display&&"none"!=l.records[d][p].style.display&&(l.records[d][p].classList.add("selection"),l.records[c][p].classList.add("selection-top"),l.records[u][p].classList.add("selection-bottom"),l.records[d][i].classList.add("selection-left"),l.records[d][a].classList.add("selection-right"),l.selection.push(l.records[d][p]))}},l.updateCornerPosition=function(){if(l.highlighted.length){var e=l.highlighted[l.highlighted.length-1],t=e.getAttribute("data-x"),o=l.content.getBoundingClientRect(),n=o.left,r=o.top,s=e.getBoundingClientRect(),i=s.left,a=s.top,c=s.width,u=s.height,d=i-n+l.content.scrollLeft+c-4,p=a-r+l.content.scrollTop+u-4;if(l.corner.style.top=p+"px",l.corner.style.left=d+"px",l.options.freezeColumns){var h=l.getFreezeWidth();t>l.options.freezeColumns-1&&i-n+c<h?l.corner.style.display="none":1==l.options.selectionCopy&&(l.corner.style.display="")}else 1==l.options.selectionCopy&&(l.corner.style.display="")}else l.corner.style.top="-2000px",l.corner.style.left="-2000px"},l.updateScroll=function(e){var t=l.content.getBoundingClientRect(),o=t.left,n=t.top,r=t.width,s=t.height,i=l.records[l.selectedCell[3]][l.selectedCell[2]].getBoundingClientRect(),a=i.left,c=i.top,u=i.width,d=i.height;if(0==e||1==e)var p=a-o+l.content.scrollLeft,h=c-n+l.content.scrollTop-2;else p=a-o+l.content.scrollLeft+u,h=c-n+l.content.scrollTop+d;h>l.content.scrollTop+30&&h<l.content.scrollTop+s||(h<l.content.scrollTop+30?l.content.scrollTop=h-d:l.content.scrollTop=h-(s-2));var g=l.getFreezeWidth();p>l.content.scrollLeft+g&&p<l.content.scrollLeft+r||(p<l.content.scrollLeft+30?(l.content.scrollLeft=p,l.content.scrollLeft<50&&(l.content.scrollLeft=0)):p<l.content.scrollLeft+g?l.content.scrollLeft=p-g-1:l.content.scrollLeft=p-(r-20))},l.getWidth=function(e){if(void 0===e)for(var t=[],o=0;o<l.headers.length;o++)t.push(l.options.columns[o].width);else"object"==typeof e&&(e=e.getAttribute("data-x")),t=l.colgroup[e].getAttribute("width");return t},l.setWidth=function(t,o,n){if(o){if(Array.isArray(t)){n||(n=[]);for(var r=0;r<t.length;r++){n[r]||(n[r]=l.colgroup[t[r]].getAttribute("width"));var s=Array.isArray(o)&&o[r]?o[r]:o;l.colgroup[t[r]].setAttribute("width",s),l.options.columns[t[r]].width=s}}else n||(n=l.colgroup[t].getAttribute("width")),l.colgroup[t].setAttribute("width",o),l.options.columns[t].width=o;l.setHistory({action:"setWidth",column:t,oldValue:n,newValue:o}),l.dispatch("onresizecolumn",e,t,o,n),l.updateCornerPosition()}},l.setHeight=function(t,o,n){o>0&&("object"==typeof t&&(t=t.getAttribute("data-y")),n||(n=l.rows[t].getAttribute("height"))||(n=l.rows[t].getBoundingClientRect().height),o=parseInt(o),l.rows[t].style.setProperty("--table-editor-line-clamp",Math.floor((o-10)/14)),l.options.rows[t]||(l.options.rows[t]={}),l.options.rows[t].height=o,l.setHistory({action:"setHeight",row:t,oldValue:n,newValue:o}),l.dispatch("onresizerow",e,t,o,n),l.updateCornerPosition())},l.getHeight=function(e){if(void 0===e)for(var t=[],o=0;o<l.rows.length;o++){var n=l.rows[o].style.height;n&&(t[o]=n)}else"object"==typeof e&&(e=$(e).getAttribute("data-y")),t=l.rows[e].style.height;return t},l.setFooter=function(e){if(e&&(l.options.footers=e),l.options.footers){l.tfoot||(l.tfoot=document.createElement("tfoot"),l.table.appendChild(l.tfoot));for(var t=0;t<l.options.footers.length;t++){if(l.tfoot.children[t])var o=l.tfoot.children[t];else{o=document.createElement("tr");var n=document.createElement("td");o.appendChild(n),l.tfoot.appendChild(o)}for(var r=0;r<l.headers.length;r++){if(l.options.footers[t][r]||(l.options.footers[t][r]=""),l.tfoot.children[t].children[r+1])n=l.tfoot.children[t].children[r+1];else{n=document.createElement("td"),o.appendChild(n);var s=l.options.columns[r].align?l.options.columns[r].align:"center";n.style.textAlign=s}n.textContent=l.parseValue(+l.records.length+r,t,l.options.footers[t][r]),n.style.display=l.colgroup[r].style.display}}}},l.getHeader=function(e){return l.headers[e].textContent},l.setHeader=function(t,o){if(l.headers[t]){var n=l.headers[t].textContent;o||(o=prompt(l.options.text.columnName,n)),o&&(l.headers[t].textContent=o,l.headers[t].setAttribute("title",o),l.options.columns[t].title=o),l.setHistory({action:"setHeader",column:t,oldValue:n,newValue:o}),l.dispatch("onchangeheader",e,t,n,o)}},l.getHeaders=function(e){for(var t=[],o=0;o<l.headers.length;o++)t.push(l.getHeader(o));return e?t:t.join(l.options.csvDelimiter)},l.getMeta=function(e,t){return e?t?l.options.meta[e]&&l.options.meta[e][t]?l.options.meta[e][t]:null:l.options.meta[e]?l.options.meta[e]:null:l.options.meta},l.setMeta=function(t,o,n){if(l.options.meta||(l.options.meta={}),o&&n)l.options.meta[t]||(l.options.meta[t]={}),l.options.meta[t][o]=n;else for(var r=Object.keys(t),s=0;s<r.length;s++){l.options.meta[r[s]]||(l.options.meta[r[s]]={});for(var i=Object.keys(t[r[s]]),a=0;a<i.length;a++)l.options.meta[r[s]][i[a]]=t[r[s]][i[a]]}l.dispatch("onchangemeta",e,t,o,n)},l.updateMeta=function(e){if(l.options.meta){for(var t={},o=Object.keys(l.options.meta),n=0;n<o.length;n++)e[o[n]]?t[e[o[n]]]=l.options.meta[o[n]]:t[o[n]]=l.options.meta[o[n]];l.options.meta=t}},l.getStyle=function(e,t){if(e)return e=r.getIdFromColumnName(e,!0),t?l.records[e[1]][e[0]].style[t]:l.records[e[1]][e[0]].getAttribute("style");for(var o={},n=l.options.data[0].length,s=l.options.data.length,i=0;i<s;i++)for(var a=0;a<n;a++){var c=t?l.records[i][a].style[t]:l.records[i][a].getAttribute("style");c&&(o[r.getColumnNameFromId([a,i])]=c)}return o},l.resetStyle=function(e,t){for(var o=Object.keys(e),n=0;n<o.length;n++){var s=r.getIdFromColumnName(o[n],!0);l.records[s[1]]&&l.records[s[1]][s[0]]&&l.records[s[1]][s[0]].setAttribute("style","")}l.setStyle(e,null,null,null,t)},l.setStyle=function(t,o,n,s,i){var a={},c={},u=function(e,t,o){var n=r.getIdFromColumnName(e,!0);if(l.records[n[1]]&&l.records[n[1]][n[0]]&&(0==l.records[n[1]][n[0]].classList.contains("readonly")||s)){var i=l.records[n[1]][n[0]].style[t];i!=o||s?l.records[n[1]][n[0]].style[t]=o:(o="",l.records[n[1]][n[0]].style[t]=""),c[e]||(c[e]=[]),a[e]||(a[e]=[]),c[e].push([t+":"+i]),a[e].push([t+":"+o])}};if(o&&n)if("string"==typeof t)u(t,o,n);else for(var d=[],p=0;p<t.length;p++){var h=t[p].getAttribute("data-x"),g=t[p].getAttribute("data-y"),f=r.getColumnNameFromId([h,g]);d[f]||(u(f,o,n),d[f]=!0)}else{var m=Object.keys(t);for(p=0;p<m.length;p++){var C=t[m[p]];"string"==typeof C&&(C=C.split(";"));for(var y=0;y<C.length;y++)"string"==typeof C[y]&&(C[y]=C[y].split(":")),C[y][0].trim()&&u(m[p],C[y][0].trim(),C[y][1])}}for(m=Object.keys(c),p=0;p<m.length;p++)c[m[p]]=c[m[p]].join(";");for(m=Object.keys(a),p=0;p<m.length;p++)a[m[p]]=a[m[p]].join(";");i||l.setHistory({action:"setStyle",oldValue:c,newValue:a}),l.dispatch("onchangestyle",e,t,o,n)},l.getComments=function(e,t){if(e)return"string"==typeof e&&(e=r.getIdFromColumnName(e,!0)),t?[l.records[e[1]][e[0]].getAttribute("title"),l.records[e[1]][e[0]].getAttribute("author")]:l.records[e[1]][e[0]].getAttribute("title")||"";for(var o={},n=0;n<l.options.data.length;n++)for(var s=0;s<l.options.columns.length;s++){var i=l.records[n][s].getAttribute("title");i&&(o[e=r.getColumnNameFromId([s,n])]=i)}return o},l.setComments=function(t,o,n){if("string"==typeof t)var s=r.getIdFromColumnName(t,!0);else s=t;var i=l.records[s[1]][s[0]].getAttribute("title"),a=[i,n=l.records[s[1]][s[0]].getAttribute("data-author")];l.records[s[1]][s[0]].setAttribute("title",o||""),l.records[s[1]][s[0]].setAttribute("data-author",n||""),o?l.records[s[1]][s[0]].classList.add("jexcel_comments"):l.records[s[1]][s[0]].classList.remove("jexcel_comments"),l.setHistory({action:"setComments",column:t,newValue:[o,n],oldValue:a}),l.dispatch("oncomments",e,o,i,s,s[0],s[1])},l.getConfig=function(){var e=l.options;return e.style=l.getStyle(),e.mergeCells=l.getMerge(),e.comments=l.getComments(),e},l.orderBy=function(t,o){if(t>=0){if(Object.keys(l.options.mergeCells).length>0){if(!confirm(l.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;l.destroyMerged()}o=null==o?l.headers[t].classList.contains("arrow-down")?1:0:o?1:0;var n=[];if("number"==l.options.columns[t].type||"numeric"==l.options.columns[t].type||"percentage"==l.options.columns[t].type||"autonumber"==l.options.columns[t].type||"color"==l.options.columns[t].type)for(var r=0;r<l.options.data.length;r++)n[r]=[r,Number(l.options.data[r][t])];else if("calendar"==l.options.columns[t].type||"checkbox"==l.options.columns[t].type||"radio"==l.options.columns[t].type)for(r=0;r<l.options.data.length;r++)n[r]=[r,l.options.data[r][t]];else for(r=0;r<l.options.data.length;r++)n[r]=[r,l.records[r][t].textContent.toLowerCase()];"function"!=typeof l.options.sorting&&(l.options.sorting=function(e){return function(t,o){var n=t[1],r=o[1];return e?""===n&&""!==r?1:""!==n&&""===r||n>r?-1:n<r?1:0:""===n&&""!==r?1:""!==n&&""===r?-1:n>r?1:n<r?-1:0}}),n=n.sort(l.options.sorting(o));var s=[];for(r=0;r<n.length;r++)s[r]=n[r][0];if(window?.tp?.table?.options?.table_head>0){const e=window?.tp?.table?.options?.table_head-1;(s=s.filter(t=>t>e)).unshift(...Array(window?.tp?.table?.options?.table_head).keys())}if(window?.tp?.table?.options?.table_foot>0){const e=s.length-1,t=s.length-window?.tp?.table?.options?.table_foot;s=s.filter(e=>e<t);for(let o=t;o<=e;o++)s.push(o)}return l.setHistory({action:"orderBy",rows:s,column:t,order:o}),l.updateOrderArrow(t,o),l.updateOrder(s),l.dispatch("onsort",e,t,o),!0}},l.updateOrderArrow=function(e,t){for(var o=0;o<l.headers.length;o++)l.headers[o].classList.remove("arrow-up"),l.headers[o].classList.remove("arrow-down");t?l.headers[e].classList.add("arrow-up"):l.headers[e].classList.add("arrow-down")},l.updateOrder=function(e){for(var t=[],o=0;o<e.length;o++)t[o]=l.options.data[e[o]];for(l.options.data=t,t=[],o=0;o<e.length;o++)t[o]=l.records[e[o]];for(l.records=t,t=[],o=0;o<e.length;o++)t[o]=l.rows[e[o]];if(l.rows=t,l.updateTableReferences(),l.results&&l.results.length)l.searchInput.value?l.search(l.searchInput.value):l.closeFilter();else if(l.results=null,l.pageNumber=0,l.options.pagination>0)l.page(0);else if(1==l.options.lazyLoading)l.loadPage(0);else for(o=0;o<l.rows.length;o++)l.tbody.appendChild(l.rows[o])},l.moveRow=function(t,o,n){if(Object.keys(l.options.mergeCells).length>0){if(t>o)var r=1;else r=0;if(l.isRowMerged(t).length||l.isRowMerged(o,r).length){if(!confirm(l.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;l.destroyMerged()}}if(1==l.options.search){if(l.results&&l.results.length!=l.rows.length){if(!confirm(l.options.text.thisActionWillClearYourSearchResultsAreYouSure))return!1;l.resetSearch()}l.results=null}n||(Array.prototype.indexOf.call(l.tbody.children,l.rows[o])>=0?t>o?l.tbody.insertBefore(l.rows[t],l.rows[o]):l.tbody.insertBefore(l.rows[t],l.rows[o].nextSibling):l.tbody.removeChild(l.rows[t])),l.rows.splice(o,0,l.rows.splice(t,1)[0]),l.records.splice(o,0,l.records.splice(t,1)[0]),l.options.data.splice(o,0,l.options.data.splice(t,1)[0]),l.options.pagination>0&&l.tbody.children.length!=l.options.pagination&&l.page(l.pageNumber),l.setHistory({action:"moveRow",oldValue:t,newValue:o}),l.updateTableReferences(),l.dispatch("onmoverow",e,t,o)},l.insertRow=function(t,o,n){if(1==l.options.allowInsertRow){var r=[];if(t>0)var s=t;else s=1,t&&(r=t);n=!!n;var i=l.options.data.length-1;if((null==o||o>=parseInt(i)||o<0)&&(o=i),!1===l.dispatch("onbeforeinsertrow",e,o,s,n))return!1;if(Object.keys(l.options.mergeCells).length>0&&l.isRowMerged(o,n).length){if(!confirm(l.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;l.destroyMerged()}if(1==l.options.search){if(l.results&&l.results.length!=l.rows.length){if(!confirm(l.options.text.thisActionWillClearYourSearchResultsAreYouSure))return!1;l.resetSearch()}l.results=null}for(var a=n?o:o+1,c=l.records.splice(a),u=l.options.data.splice(a),d=l.rows.splice(a),p=[],h=[],g=[],f=a;f<s+a;f++){l.options.data[f]=[];for(var m=0;m<l.options.columns.length;m++)l.options.data[f][m]=r[m]?r[m]:"";var C=l.createRow(f,l.options.data[f]);d[0]?Array.prototype.indexOf.call(l.tbody.children,d[0])>=0&&l.tbody.insertBefore(C,d[0]):Array.prototype.indexOf.call(l.tbody.children,l.rows[o])>=0&&l.tbody.appendChild(C),p.push(l.records[f]),h.push(l.options.data[f]),g.push(C)}Array.prototype.push.apply(l.records,c),Array.prototype.push.apply(l.options.data,u),Array.prototype.push.apply(l.rows,d),l.options.pagination>0&&l.page(l.pageNumber),l.setHistory({action:"insertRow",rowNumber:o,numOfRows:s,insertBefore:n,rowRecords:p,rowData:h,rowNode:g}),l.updateTableReferences(),l.dispatch("oninsertrow",e,o,s,p,n)}},l.deleteRow=function(t,o){if(1==l.options.allowDeleteRow)if(1==l.options.allowDeletingAllRows||l.options.data.length>1){if(null==t){var n=l.getSelectedRows();n[0]?(t=parseInt(n[0].getAttribute("data-y")),o=n.length):(t=l.options.data.length-1,o=1)}var r=l.options.data.length-1;if((null==t||t>r||t<0)&&(t=r),o||(o=1),t+o>=l.options.data.length&&(o=l.options.data.length-t),!1===l.dispatch("onbeforedeleterow",e,t,o))return!1;if(parseInt(t)>-1){var s=!1;if(Object.keys(l.options.mergeCells).length>0)for(var i=t;i<t+o;i++)l.isRowMerged(i,!1).length&&(s=!0);if(s){if(!confirm(l.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;l.destroyMerged()}if(1==l.options.search){if(l.results&&l.results.length!=l.rows.length){if(!confirm(l.options.text.thisActionWillClearYourSearchResultsAreYouSure))return!1;l.resetSearch()}l.results=null}for(0==l.options.allowDeletingAllRows&&r+1===o&&(o--,console.error("Jspreadsheet: It is not possible to delete the last row")),i=t;i<t+o;i++)Array.prototype.indexOf.call(l.tbody.children,l.rows[i])>=0&&(l.rows[i].className="",l.rows[i].parentNode.removeChild(l.rows[i]));var a=l.records.splice(t,o),c=l.options.data.splice(t,o),u=l.rows.splice(t,o);l.options.pagination>0&&l.tbody.children.length!=l.options.pagination&&l.page(l.pageNumber),l.conditionalSelectionUpdate(1,t,t+o-1),l.setHistory({action:"deleteRow",rowNumber:t,numOfRows:o,insertBefore:1,rowRecords:a,rowData:c,rowNode:u}),l.updateTableReferences(),l.dispatch("ondeleterow",e,t,o,a)}}else console.error("Jspreadsheet: It is not possible to delete the last row")},l.moveColumn=function(t,o){if(Object.keys(l.options.mergeCells).length>0){if(t>o)var n=1;else n=0;if(l.isColMerged(t).length||l.isColMerged(o,n).length){if(!confirm(l.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;l.destroyMerged()}}if((t=parseInt(t))>(o=parseInt(o))){l.headerContainer.insertBefore(l.headers[t],l.headers[o]),l.colgroupContainer.insertBefore(l.colgroup[t],l.colgroup[o]);for(var r=0;r<l.rows.length;r++)l.rows[r].insertBefore(l.records[r][t],l.records[r][o])}else for(l.headerContainer.insertBefore(l.headers[t],l.headers[o].nextSibling),l.colgroupContainer.insertBefore(l.colgroup[t],l.colgroup[o].nextSibling),r=0;r<l.rows.length;r++)l.rows[r].insertBefore(l.records[r][t],l.records[r][o].nextSibling);for(l.options.columns.splice(o,0,l.options.columns.splice(t,1)[0]),l.headers.splice(o,0,l.headers.splice(t,1)[0]),l.colgroup.splice(o,0,l.colgroup.splice(t,1)[0]),r=0;r<l.rows.length;r++)l.options.data[r].splice(o,0,l.options.data[r].splice(t,1)[0]),l.records[r].splice(o,0,l.records[r].splice(t,1)[0]);if(l.options.footers)for(r=0;r<l.options.footers.length;r++)l.options.footers[r].splice(o,0,l.options.footers[r].splice(t,1)[0]);l.setHistory({action:"moveColumn",oldValue:t,newValue:o}),l.updateTableReferences(),l.dispatch("onmovecolumn",e,t,o)},l.insertColumn=function(t,o,n,s){if(1==l.options.allowInsertColumn){var i=[];if(t>0)var a=t;else a=1,t&&(i=t);n=!!n;var c=l.options.columns.length-1;if((null==o||o>=parseInt(c)||o<0)&&(o=c),!1===l.dispatch("onbeforeinsertcolumn",e,o,a,n))return!1;if(Object.keys(l.options.mergeCells).length>0&&l.isColMerged(o,n).length){if(!confirm(l.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;l.destroyMerged()}s||(s=[]);for(var u=0;u<a;u++)s[u]||(s[u]={type:"text",source:[],options:[],width:l.options.defaultColWidth,align:l.options.defaultColAlign});var d=n?o:o+1;l.options.columns=r.injectArray(l.options.columns,d,s);for(var p=l.headers.splice(d),h=l.colgroup.splice(d),g=[],f=[],m=[],C=[],y=[],v=d;v<a+d;v++)l.createCellHeader(v),l.headerContainer.insertBefore(l.headers[v],l.headerContainer.children[v+1]),l.colgroupContainer.insertBefore(l.colgroup[v],l.colgroupContainer.children[v+1]),g.push(l.headers[v]),f.push(l.colgroup[v]);if(l.options.footers)for(var b=0;b<l.options.footers.length;b++){for(y[b]=[],u=0;u<a;u++)y[b].push("");l.options.footers[b].splice(d,0,y[b])}for(var w=0;w<l.options.data.length;w++){var A=l.options.data[w].splice(d),x=l.records[w].splice(d);for(C[w]=[],m[w]=[],v=d;v<a+d;v++){var F=i[w]?i[w]:"";l.options.data[w][v]=F;var E=l.createCell(v,w,l.options.data[w][v]);l.records[w][v]=E,l.rows[w]&&l.rows[w].insertBefore(E,l.rows[w].children[v+1]),C[w].push(F),m[w].push(E)}Array.prototype.push.apply(l.options.data[w],A),Array.prototype.push.apply(l.records[w],x)}if(Array.prototype.push.apply(l.headers,p),Array.prototype.push.apply(l.colgroup,h),l.options.nestedHeaders&&l.options.nestedHeaders.length>0)if(l.options.nestedHeaders[0]&&l.options.nestedHeaders[0][0])for(b=0;b<l.options.nestedHeaders.length;b++){var L=parseInt(l.options.nestedHeaders[b][l.options.nestedHeaders[b].length-1].colspan)+a;l.options.nestedHeaders[b][l.options.nestedHeaders[b].length-1].colspan=L,l.thead.children[b].children[l.thead.children[b].children.length-1].setAttribute("colspan",L);var D=l.thead.children[b].children[l.thead.children[b].children.length-1].getAttribute("data-column");for(D=D.split(","),v=d;v<a+d;v++)D.push(v);l.thead.children[b].children[l.thead.children[b].children.length-1].setAttribute("data-column",D)}else L=parseInt(l.options.nestedHeaders[0].colspan)+a,l.options.nestedHeaders[0].colspan=L,l.thead.children[0].children[l.thead.children[0].children.length-1].setAttribute("colspan",L);l.setHistory({action:"insertColumn",columnNumber:o,numOfColumns:a,insertBefore:n,columns:s,headers:g,colgroup:f,records:m,footers:y,data:C}),l.updateTableReferences(),l.dispatch("oninsertcolumn",e,o,a,m,n)}},l.deleteColumn=function(t,o){if(1==l.options.allowDeleteColumn)if(l.headers.length>1){if(null==t){var n=l.getSelectedColumns(!0);n.length?(t=parseInt(n[0]),o=parseInt(n.length)):(t=l.headers.length-1,o=1)}var r=l.options.data[0].length-1;if((null==t||t>r||t<0)&&(t=r),o||(o=1),o>l.options.data[0].length-t&&(o=l.options.data[0].length-t),!1===l.dispatch("onbeforedeletecolumn",e,t,o))return!1;if(parseInt(t)>-1){var s=!1;if(Object.keys(l.options.mergeCells).length>0)for(var i=t;i<t+o;i++)l.isColMerged(i,!1).length&&(s=!0);if(s){if(!confirm(l.options.text.thisActionWillDestroyAnyExistingMergedCellsAreYouSure))return!1;l.destroyMerged()}var a=l.options.columns.splice(t,o);for(i=t;i<t+o;i++)l.colgroup[i].className="",l.headers[i].className="",l.colgroup[i].parentNode.removeChild(l.colgroup[i]),l.headers[i].parentNode.removeChild(l.headers[i]);for(var c=l.headers.splice(t,o),u=l.colgroup.splice(t,o),d=[],p=[],h=[],g=0;g<l.options.data.length;g++)for(i=t;i<t+o;i++)l.records[g][i].className="",l.records[g][i].parentNode.removeChild(l.records[g][i]);for(g=0;g<l.options.data.length;g++)p[g]=l.options.data[g].splice(t,o),d[g]=l.records[g].splice(t,o);if(l.options.footers)for(g=0;g<l.options.footers.length;g++)h[g]=l.options.footers[g].splice(t,o);if(l.conditionalSelectionUpdate(0,t,t+o-1),l.options.nestedHeaders&&l.options.nestedHeaders.length>0)if(l.options.nestedHeaders[0]&&l.options.nestedHeaders[0][0])for(var f=0;f<l.options.nestedHeaders.length;f++){var m=parseInt(l.options.nestedHeaders[f][l.options.nestedHeaders[f].length-1].colspan)-o;l.options.nestedHeaders[f][l.options.nestedHeaders[f].length-1].colspan=m,l.thead.children[f].children[l.thead.children[f].children.length-1].setAttribute("colspan",m)}else m=parseInt(l.options.nestedHeaders[0].colspan)-o,l.options.nestedHeaders[0].colspan=m,l.thead.children[0].children[l.thead.children[0].children.length-1].setAttribute("colspan",m);l.setHistory({action:"deleteColumn",columnNumber:t,numOfColumns:o,insertBefore:1,columns:a,headers:c,colgroup:u,records:d,footers:h,data:p}),l.updateTableReferences(),l.dispatch("ondeletecolumn",e,t,o,d)}}else console.error("Jspreadsheet: It is not possible to delete the last column")},l.getSelectedRows=function(e){for(var t=[],o=0;o<l.rows.length;o++)l.rows[o].classList.contains("selected")&&(e?t.push(o):t.push(l.rows[o]));return t},l.getSelectedColumns=function(){for(var e=[],t=0;t<l.headers.length;t++)l.headers[t].classList.contains("selected")&&e.push(t);return e},l.getHighlighted=function(){return l.highlighted},l.updateTableReferences=function(){for(var e=0;e<l.headers.length;e++)(i=l.headers[e].getAttribute("data-x"))!=e&&(l.headers[e].setAttribute("data-x",e),l.headers[e].getAttribute("title")||(l.headers[e].innerHTML=r.getColumnName(e)));for(var t=0;t<l.rows.length;t++)l.rows[t]&&(a=l.rows[t].getAttribute("data-y"))!=t&&(l.rows[t].setAttribute("data-y",t),l.rows[t].children[0].setAttribute("data-y",t),l.rows[t].children[0].innerHTML=t+1);var o=[],n=[],s=function(e,t,n,s){if(e!=n&&l.records[s][n].setAttribute("data-x",n),t!=s&&l.records[s][n].setAttribute("data-y",s),e!=n||t!=s){var i=r.getColumnNameFromId([e,t]),a=r.getColumnNameFromId([n,s]);o[i]=a}};for(t=0;t<l.records.length;t++)for(e=0;e<l.records[0].length;e++)if(l.records[t][e]){var i=l.records[t][e].getAttribute("data-x"),a=l.records[t][e].getAttribute("data-y");if(l.records[t][e].getAttribute("data-merged")){var c=r.getColumnNameFromId([i,a]),u=r.getColumnNameFromId([e,t]);if(null==n[c])if(c==u)n[c]=!1;else{var d=parseInt(e-i),p=parseInt(t-a);n[c]=[u,d,p]}}else s(i,a,e,t)}var h=Object.keys(n);if(h.length)for(e=0;e<h.length;e++)if(n[h[e]]){var g=r.getIdFromColumnName(h[e],!0);for(s(i=g[0],a=g[1],i+n[h[e]][1],a+n[h[e]][2]),c=h[e],u=n[h[e]][0],t=0;t<l.options.mergeCells[c][2].length;t++)i=parseInt(l.options.mergeCells[c][2][t].getAttribute("data-x")),a=parseInt(l.options.mergeCells[c][2][t].getAttribute("data-y")),l.options.mergeCells[c][2][t].setAttribute("data-x",i+n[h[e]][1]),l.options.mergeCells[c][2][t].setAttribute("data-y",a+n[h[e]][2]);l.options.mergeCells[u]=l.options.mergeCells[c],delete l.options.mergeCells[c]}l.updateFormulas(o),l.updateMeta(o),l.refreshSelection(),l.updateTable()},l.updateTable=function(){if(l.options.minSpareRows>0){for(var t=0,o=l.rows.length-1;o>=0;o--){for(var n=!1,s=0;s<l.headers.length;s++)l.options.data[o][s]&&(n=!0);if(n)break;t++}l.options.minSpareRows-t>0&&l.insertRow(l.options.minSpareRows-t)}if(l.options.minSpareCols>0){var i=0;for(s=l.headers.length-1;s>=0;s--){for(n=!1,o=0;o<l.rows.length;o++)l.options.data[o][s]&&(n=!0);if(n)break;i++}l.options.minSpareCols-i>0&&l.insertColumn(l.options.minSpareCols-i)}if("function"==typeof l.options.updateTable){for(l.options.detachForUpdates&&e.removeChild(l.content),o=0;o<l.rows.length;o++)for(s=0;s<l.headers.length;s++)l.options.updateTable(e,l.records[o][s],s,o,l.options.data[o][s],l.records[o][s].textContent,r.getColumnNameFromId([s,o]));l.options.detachForUpdates&&e.insertBefore(l.content,l.pagination)}l.options.footers&&l.setFooter(),setTimeout(function(){l.updateCornerPosition()},0)},l.isReadOnly=function(e){if(e=l.getCell(e))return!!e.classList.contains("readonly")},l.setReadOnly=function(e,t){(e=l.getCell(e))&&(t?e.classList.add("readonly"):e.classList.remove("readonly"))},l.showRow=function(e){l.rows[e].style.display=""},l.hideRow=function(e){l.rows[e].style.display="none"},l.showColumn=function(e){l.headers[e].style.display="",l.colgroup[e].style.display="",l.filter&&l.filter.children.length>e+1&&(l.filter.children[e+1].style.display="");for(var t=0;t<l.options.data.length;t++)l.records[t][e].style.display="";l.options.footers&&l.setFooter(),l.resetSelection()},l.hideColumn=function(e){l.headers[e].style.display="none",l.colgroup[e].style.display="none",l.filter&&l.filter.children.length>e+1&&(l.filter.children[e+1].style.display="none");for(var t=0;t<l.options.data.length;t++)l.records[t][e].style.display="none";l.options.footers&&l.setFooter(),l.resetSelection()},l.showIndex=function(){l.table.classList.remove("jexcel_hidden_index")},l.hideIndex=function(){l.table.classList.add("jexcel_hidden_index")};var h=[];l.updateFormulaChain=function(e,t,o){var n=r.getColumnNameFromId([e,t]);if(l.formula[n]&&l.formula[n].length>0)if(h[n])l.records[t][e].innerHTML="#ERROR",l.formula[n]="";else{h[n]=!0;for(var s=0;s<l.formula[n].length;s++){var i=r.getIdFromColumnName(l.formula[n][s],!0),a=""+l.options.data[i[1]][i[0]];"="==a.substr(0,1)?o.push(l.updateCell(i[0],i[1],a,!0)):Object.keys(l.formula)[s]=null,l.updateFormulaChain(i[0],i[1],o)}}h=[]},l.updateFormulas=function(e){for(var t=0;t<l.options.data.length;t++)for(var o=0;o<l.options.data[0].length;o++)if("="==(a=""+l.options.data[t][o]).substr(0,1)){var n=l.updateFormula(a,e);n!=a&&l.updateCell(o,t,n)}var r=[],s=Object.keys(l.formula);for(t=0;t<s.length;t++){var i=s[t],a=l.formula[i];for(e[i]&&(i=e[i]),r[i]=[],o=0;o<a.length;o++){var c=a[o];e[c]&&(c=e[c]),r[i].push(c)}}l.formula=r},l.updateFormula=function(e,t){for(var o=/[A-Z]/,n=/[0-9]/,r="",s=null,l=null,i="",a=0;a<e.length;a++)o.exec(e[a])?(s=1,l=0,i+=e[a]):n.exec(e[a])?(l=s?1:0,i+=e[a]):(s&&l&&(i=t[i]?t[i]:i),r+=i,r+=e[a],s=0,l=0,i="");return i&&(s&&l&&(i=t[i]?t[i]:i),r+=i),r};var g=function(e){for(var t="",o=0,n=0;n<e.length;n++)'"'==e[n]&&(o=0==o?1:0),t+=1==o?e[n]:e[n].toUpperCase();return t};l.executeFormula=function(e,t,o){var n=[],s=[],i=function(e,t,o){var a=r.getColumnNameFromId([t,o]);if(s[a])return console.error("Reference loop detected"),"#ERROR";s[a]=!0;var c;if((c=(e=e.replace(/\$?([A-Z]+)\$?([0-9]+)/g,"$1$2")).match(/([A-Z]+[0-9]+)\:([A-Z]+[0-9]+)/g))&&c.length&&function(t){for(var o=0;o<t.length;o++){var n=[],s=t[o].split(":"),l=r.getIdFromColumnName(s[0],!0),i=r.getIdFromColumnName(s[1],!0);if(l[0]<=i[0])var a=l[0],c=i[0];else a=i[0],c=l[0];if(l[1]<=i[1])var u=l[1],d=i[1];else u=i[1],d=l[1];for(var p=u;p<=d;p++)for(var h=a;h<=c;h++)n.push(r.getColumnNameFromId([h,p]));e=e.replace(t[o],n.join(","))}}(c),(c=e.match(/([A-Z]+[0-9]+)/g))&&c.indexOf(a)>-1)return console.error("Self Reference detected"),"#ERROR";var u={};if(c)for(var d=0;d<c.length;d++)if(l.formula[c[d]]||(l.formula[c[d]]=[]),l.formula[c[d]].indexOf(a)<0&&l.formula[c[d]].push(a),void 0===globalThis[c[d]]){var p=r.getIdFromColumnName(c[d],1);if(void 0!==l.options.data[p[1]]&&void 0!==l.options.data[p[1]][p[0]])var h=l.options.data[p[1]][p[0]];else h="";if("="==(""+h).substr(0,1)&&(void 0!==n[c[d]]?h=n[c[d]]:(h=i(h,p[0],p[1]),n[c[d]]=h)),""==(""+h).trim())u[c[d]]=null;else if(h==Number(h)&&1==l.options.autoCasting)u[c[d]]=Number(h);else{var g=l.parseNumber(h,p[0]);1==l.options.autoCasting&&g?u[c[d]]=g:u[c[d]]='"'+h+'"'}}try{var f=r.formula(e.substr(1),u,t,o,l)}catch(e){f="#ERROR",console.log(e)}return f};return i(e,t,o)},l.parseNumber=function(e,t){var o=t&&l.options.columns[t].decimal?l.options.columns[t].decimal:".",n=""+e;if((n=n.split(o))[0]=n[0].match(/[+-]?[0-9]/g),n[0]&&(n[0]=n[0].join("")),n[1]&&(n[1]=n[1].match(/[0-9]*/g).join("")),n[0]&&Number.isInteger(Number(n[0])))if(n[1])e=Number(n[0]+"."+n[1]);else e=Number(n[0]+".00");else e=null;return e},l.row=function(e){},l.col=function(e){},l.up=function(e,t){if(e?l.selectedCell[3]>0&&l.up.visible(1,t?0:1):(l.selectedCell[1]>0&&l.up.visible(0,t?0:1),l.selectedCell[2]=l.selectedCell[0],l.selectedCell[3]=l.selectedCell[1]),l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]),1==l.options.lazyLoading)if(0==l.selectedCell[1]||0==l.selectedCell[3])l.loadPage(0),l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]);else if(l.loadValidation())l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]);else{var o=parseInt(l.tbody.firstChild.getAttribute("data-y"));l.selectedCell[1]-o<30&&(l.loadUp(),l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]))}else if(l.options.pagination>0){var n=l.whichPage(l.selectedCell[3]);n!=l.pageNumber&&l.page(n)}l.updateScroll(1)},l.up.visible=function(e,t){if(0==e)var o=parseInt(l.selectedCell[0]),n=parseInt(l.selectedCell[1]);else o=parseInt(l.selectedCell[2]),n=parseInt(l.selectedCell[3]);if(0==t){for(var r=0;r<n;r++)if("none"!=l.records[r][o].style.display&&"none"!=l.rows[r].style.display){n=r;break}}else n=l.up.get(o,n);0==e?(l.selectedCell[0]=o,l.selectedCell[1]=n):(l.selectedCell[2]=o,l.selectedCell[3]=n)},l.up.get=function(e,t){e=parseInt(e);for(var o=(t=parseInt(t))-1;o>=0;o--)if("none"!=l.records[o][e].style.display&&"none"!=l.rows[o].style.display){if(l.records[o][e].getAttribute("data-merged")&&l.records[o][e]==l.records[t][e])continue;t=o;break}return t},l.down=function(e,t){if(e?l.selectedCell[3]<l.records.length-1&&l.down.visible(1,t?0:1):(l.selectedCell[1]<l.records.length-1&&l.down.visible(0,t?0:1),l.selectedCell[2]=l.selectedCell[0],l.selectedCell[3]=l.selectedCell[1]),l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]),1==l.options.lazyLoading)l.selectedCell[1]==l.records.length-1||l.selectedCell[3]==l.records.length-1?(l.loadPage(-1),l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3])):l.loadValidation()?l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]):parseInt(l.tbody.lastChild.getAttribute("data-y"))-l.selectedCell[3]<30&&(l.loadDown(),l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]));else if(l.options.pagination>0){var o=l.whichPage(l.selectedCell[3]);o!=l.pageNumber&&l.page(o)}l.updateScroll(3)},l.down.visible=function(e,t){if(0==e)var o=parseInt(l.selectedCell[0]),n=parseInt(l.selectedCell[1]);else o=parseInt(l.selectedCell[2]),n=parseInt(l.selectedCell[3]);if(0==t){for(var r=l.rows.length-1;r>n;r--)if("none"!=l.records[r][o].style.display&&"none"!=l.rows[r].style.display){n=r;break}}else n=l.down.get(o,n);0==e?(l.selectedCell[0]=o,l.selectedCell[1]=n):(l.selectedCell[2]=o,l.selectedCell[3]=n)},l.down.get=function(e,t){e=parseInt(e);for(var o=(t=parseInt(t))+1;o<l.rows.length;o++)if("none"!=l.records[o][e].style.display&&"none"!=l.rows[o].style.display){if(l.records[o][e].getAttribute("data-merged")&&l.records[o][e]==l.records[t][e])continue;t=o;break}return t},l.right=function(e,t){e?l.selectedCell[2]<l.headers.length-1&&l.right.visible(1,t?0:1):(l.selectedCell[0]<l.headers.length-1&&l.right.visible(0,t?0:1),l.selectedCell[2]=l.selectedCell[0],l.selectedCell[3]=l.selectedCell[1]),l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]),l.updateScroll(2)},l.right.visible=function(e,t){if(0==e)var o=parseInt(l.selectedCell[0]),n=parseInt(l.selectedCell[1]);else o=parseInt(l.selectedCell[2]),n=parseInt(l.selectedCell[3]);if(0==t){for(var r=l.headers.length-1;r>o;r--)if("none"!=l.records[n][r].style.display){o=r;break}}else o=l.right.get(o,n);0==e?(l.selectedCell[0]=o,l.selectedCell[1]=n):(l.selectedCell[2]=o,l.selectedCell[3]=n)},l.right.get=function(e,t){e=parseInt(e),t=parseInt(t);for(var o=e+1;o<l.headers.length;o++)if("none"!=l.records[t][o].style.display){if(l.records[t][o].getAttribute("data-merged")&&l.records[t][o]==l.records[t][e])continue;e=o;break}return e},l.left=function(e,t){e?l.selectedCell[2]>0&&l.left.visible(1,t?0:1):(l.selectedCell[0]>0&&l.left.visible(0,t?0:1),l.selectedCell[2]=l.selectedCell[0],l.selectedCell[3]=l.selectedCell[1]),l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]),l.updateScroll(0)},l.left.visible=function(e,t){if(0==e)var o=parseInt(l.selectedCell[0]),n=parseInt(l.selectedCell[1]);else o=parseInt(l.selectedCell[2]),n=parseInt(l.selectedCell[3]);if(0==t){for(var r=0;r<o;r++)if("none"!=l.records[n][r].style.display){o=r;break}}else o=l.left.get(o,n);0==e?(l.selectedCell[0]=o,l.selectedCell[1]=n):(l.selectedCell[2]=o,l.selectedCell[3]=n)},l.left.get=function(e,t){e=parseInt(e),t=parseInt(t);for(var o=e-1;o>=0;o--)if("none"!=l.records[t][o].style.display){if(l.records[t][o].getAttribute("data-merged")&&l.records[t][o]==l.records[t][e])continue;e=o;break}return e},l.first=function(e,t){if(e?t?l.selectedCell[3]=0:l.left.visible(1,0):(t?l.selectedCell[1]=0:l.left.visible(0,0),l.selectedCell[2]=l.selectedCell[0],l.selectedCell[3]=l.selectedCell[1]),1!=l.options.lazyLoading||0!=l.selectedCell[1]&&0!=l.selectedCell[3]){if(l.options.pagination>0){var o=l.whichPage(l.selectedCell[3]);o!=l.pageNumber&&l.page(o)}}else l.loadPage(0);l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]),l.updateScroll(1)},l.last=function(e,t){if(e?t?l.selectedCell[3]=l.records.length-1:l.right.visible(1,0):(t?l.selectedCell[1]=l.records.length-1:l.right.visible(0,0),l.selectedCell[2]=l.selectedCell[0],l.selectedCell[3]=l.selectedCell[1]),1!=l.options.lazyLoading||l.selectedCell[1]!=l.records.length-1&&l.selectedCell[3]!=l.records.length-1){if(l.options.pagination>0){var o=l.whichPage(l.selectedCell[3]);o!=l.pageNumber&&l.page(o)}}else l.loadPage(-1);l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3]),l.updateScroll(3)},l.selectAll=function(){l.selectedCell||(l.selectedCell=[]),l.selectedCell[0]=0,l.selectedCell[1]=0,l.selectedCell[2]=l.headers.length-1,l.selectedCell[3]=l.records.length-1,l.updateSelectionFromCoords(l.selectedCell[0],l.selectedCell[1],l.selectedCell[2],l.selectedCell[3])},l.loadPage=function(e){if(1!=l.options.search&&1!=l.options.filters||!l.results)t=l.rows;else var t=l.results;var o=100;null!=e&&-1!=e||(e=Math.ceil(t.length/o)-1);var n=e*o,r=e*o+o;r>t.length&&(r=t.length),(n=r-100)<0&&(n=0);for(var s=n;s<r;s++)1!=l.options.search&&1!=l.options.filters||!l.results?l.tbody.appendChild(l.rows[s]):l.tbody.appendChild(l.rows[t[s]]),l.tbody.children.length>o&&l.tbody.removeChild(l.tbody.firstChild)},l.loadUp=function(){if(1!=l.options.search&&1!=l.options.filters||!l.results)e=l.rows;else var e=l.results;var t=0;if(e.length>100){var o=parseInt(l.tbody.firstChild.getAttribute("data-y"));if(1!=l.options.search&&1!=l.options.filters||!l.results||(o=e.indexOf(o)),o>0)for(var n=0;n<30;n++)(o-=1)>-1&&(1!=l.options.search&&1!=l.options.filters||!l.results?l.tbody.insertBefore(l.rows[o],l.tbody.firstChild):l.tbody.insertBefore(l.rows[e[o]],l.tbody.firstChild),l.tbody.children.length>100&&(l.tbody.removeChild(l.tbody.lastChild),t=1))}return t},l.loadDown=function(){if(1!=l.options.search&&1!=l.options.filters||!l.results)e=l.rows;else var e=l.results;var t=0;if(e.length>100){var o=parseInt(l.tbody.lastChild.getAttribute("data-y"));if(1!=l.options.search&&1!=l.options.filters||!l.results||(o=e.indexOf(o)),o<l.rows.length-1)for(var n=0;n<=30;n++)o<e.length&&(1!=l.options.search&&1!=l.options.filters||!l.results?l.tbody.appendChild(l.rows[o]):l.tbody.appendChild(l.rows[e[o]]),l.tbody.children.length>100&&(l.tbody.removeChild(l.tbody.firstChild),t=1)),o+=1}return t},l.loadValidation=function(){if(l.selectedCell){var e=parseInt(l.tbody.firstChild.getAttribute("data-y"))/100,t=parseInt(l.selectedCell[3]/100),o=parseInt(l.rows.length/100);if(e!=t&&t<=o&&!Array.prototype.indexOf.call(l.tbody.children,l.rows[l.selectedCell[3]]))return l.loadPage(t),!0}return!1},l.resetSearch=function(){l.searchInput.value="",l.search(""),l.results=null},l.search=function(e){if(l.options.filters&&l.resetFilters(),l.resetSelection(),l.pageNumber=0,l.results=[],e){var t=function(e){-1==l.results.indexOf(e)&&l.results.push(e)},o=e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");o=new RegExp(o,"i"),l.options.data.forEach(function(e,n){if(function(e,t,o){for(var n=0;n<e.length;n++)if((""+e[n]).toLowerCase().search(t)>=0||(""+l.records[o][n].innerHTML).toLowerCase().search(t)>=0)return!0;return!1}(e,o,n)){var s=l.isRowMerged(n);if(s.length)for(var i=0;i<s.length;i++)for(var a=r.getIdFromColumnName(s[i],!0),c=0;c<l.options.mergeCells[s[i]][1];c++)t(a[1]+c);else t(n)}})}else l.results=null;return l.updateResult()},l.updateResult=function(){var e,t=0;for(e=1==l.options.lazyLoading?100:l.options.pagination>0?l.options.pagination:l.results?l.results.length:l.rows.length;l.tbody.firstChild;)l.tbody.removeChild(l.tbody.firstChild);for(var o=0;o<l.rows.length;o++)!l.results||l.results.indexOf(o)>-1?(t<e&&(l.tbody.appendChild(l.rows[o]),t++),l.rows[o].style.display=""):l.rows[o].style.display="none";return l.options.pagination>0&&l.updatePagination(),l.updateCornerPosition(),e},l.whichPage=function(e){return 1!=l.options.search&&1!=l.options.filters||!l.results||(e=l.results.indexOf(e)),Math.ceil((parseInt(e)+1)/parseInt(l.options.pagination))-1},l.page=function(t){var o=l.pageNumber;if(1!=l.options.search&&1!=l.options.filters||!l.results)n=l.rows;else var n=l.results;var r=parseInt(l.options.pagination);null!=t&&-1!=t||(t=Math.ceil(n.length/r)-1),l.pageNumber=t;var s=t*r,i=t*r+r;for(i>n.length&&(i=n.length),s<0&&(s=0);l.tbody.firstChild;)l.tbody.removeChild(l.tbody.firstChild);for(var a=s;a<i;a++)1!=l.options.search&&1!=l.options.filters||!l.results?l.tbody.appendChild(l.rows[a]):l.tbody.appendChild(l.rows[n[a]]);l.options.pagination>0&&l.updatePagination(),l.updateCornerPosition(),l.dispatch("onchangepage",e,t,o)},l.updatePagination=function(){if(l.pagination.children[0].innerHTML="",l.pagination.children[1].innerHTML="",l.options.pagination){if(1!=l.options.search&&1!=l.options.filters||!l.results)e=l.rows.length;else var e=l.results.length;if(e){var t=Math.ceil(e/l.options.pagination);if(l.pageNumber<6)var o=1,n=t<10?t:10;else t-l.pageNumber<5?(n=t,(o=t-9)<1&&(o=1)):(o=l.pageNumber-4,n=l.pageNumber+5);o>1&&((s=document.createElement("div")).className="jexcel_page",s.innerHTML="<",s.title=1,l.pagination.children[1].appendChild(s));for(var r=o;r<=n;r++){var s;(s=document.createElement("div")).className="jexcel_page",s.innerHTML=r,l.pagination.children[1].appendChild(s),l.pageNumber==r-1&&s.classList.add("jexcel_page_selected")}n<t&&((s=document.createElement("div")).className="jexcel_page",s.innerHTML=">",s.title=t,l.pagination.children[1].appendChild(s));l.pagination.children[0].innerHTML=function(e){var t=Array.prototype.slice.call(arguments,1);return e.replace(/{(\d+)}/g,function(e,o){return void 0!==t[o]?t[o]:e})}(l.options.text.showingPage,l.pageNumber+1,t)}else l.pagination.children[0].innerHTML=l.options.text.noRecordsFound}},l.download=function(e){if(0==l.options.allowExport)console.error("Export not allowed");else{var t="";t+=l.copy(!1,l.options.csvDelimiter,!0,e,!0);var o=new Blob(["\ufeff"+t],{type:"text/csv;charset=utf-8;"});if(window.navigator&&window.navigator.msSaveOrOpenBlob)window.navigator.msSaveOrOpenBlob(o,l.options.csvFileName+".csv");else{var n=document.createElement("a"),r=URL.createObjectURL(o);n.href=r,n.setAttribute("download",l.options.csvFileName+".csv"),document.body.appendChild(n),n.click(),n.parentNode.removeChild(n)}}},l.tablePressToolbarUndoRedoState={undoDisabled:!0,redoDisabled:!0},l.updateTablePressToolbarUndoRedoState=function(){const e={undoDisabled:-1===l.historyIndex,redoDisabled:l.historyIndex===l.history.length-1};e.undoDisabled===l.tablePressToolbarUndoRedoState.undoDisabled&&e.redoDisabled===l.tablePressToolbarUndoRedoState.redoDisabled||(l.tablePressToolbarUndoRedoState=e,wp?.hooks?.doAction?.("tablepress.toolbarUndoRedoStateUpdate",e))},l.setHistory=function(e){if(1!=l.ignoreHistory){var t=++l.historyIndex;l.history=l.history=l.history.slice(0,t+1),l.history[t]=e,l.updateTablePressToolbarUndoRedoState()}},l.copy=function(t,o,n,r,s){o||(o="\t");for(var i=new RegExp(o,"ig"),a=[],c=[],u=[],d=[],p=[],h=l.options.data[0].length,g=l.options.data.length,f="",m=!1,C="",y="",v=0,b=0,w=0,A=0,x=!0,F=0;F<g;F++)for(var E=0;E<h;E++)t&&!l.records[F][E].classList.contains("highlight")||(w<=E&&(w=E),A<=F&&(A=F));if(h===w+1&&g===A+1&&(x=!1),s&&1==l.options.includeHeadersOnDownload||!s&&1==l.options.includeHeadersOnCopy&&!x||r){if(l.options.nestedHeaders&&l.options.nestedHeaders.length>0)for(f=l.options.nestedHeaders[0]&&l.options.nestedHeaders[0][0]?l.options.nestedHeaders:[l.options.nestedHeaders],F=0;F<f.length;F++){var L=[];for(E=0;E<f[F].length;E++){var D=parseInt(f[F][E].colspan);L.push(f[F][E].title);for(var S=0;S<D-1;S++)L.push("")}y+=L.join(o)+"\r\n"}m=!0}for(l.style=[],F=0;F<g;F++){for(c=[],u=[],E=0;E<h;E++)if(!t||l.records[F][E].classList.contains("highlight")){1==m&&a.push(l.headers[E].textContent);var I=l.options.data[F][E];if(I.match&&(I.match(i)||I.includes(o)||I.includes("\n"))&&(I.includes('"')&&(I=I.replace(new RegExp('"',"g"),'""')),I='"'+I+'"'),c.push(I),"checkbox"==l.options.columns[E].type||"radio"==l.options.columns[E].type)var B=I;else(B=1==l.options.stripHTMLOnCopy?l.records[F][E].textContent:l.records[F][E].innerHTML).match&&(B.match(i)||B.match(/,/g)||B.match(/\n/)||B.match(/\"/))&&(B='"'+(B=B.replace(new RegExp('"',"g"),'""'))+'"');u.push(B),f=(f=l.records[F][E].getAttribute("style")).replace("display: none;",""),l.style.push(f||"")}c.length&&(m&&(v=c.length,d.push(a.join(o))),d.push(c.join(o))),u.length&&(b++,m&&(p.push(a.join(o)),m=!1),p.push(u.join(o)))}h==v&&g==b&&(C=y);var H=C+d.join("\r\n"),N=C+p.join("\r\n");if(n||(1==l.options.copyCompatibility?l.textarea.value=N:l.textarea.value=H,l.textarea.select(),document.execCommand("copy")),1==l.options.copyCompatibility?l.data=N:l.data=H,l.hashString=l.hash(l.data),!n){if(l.removeCopyingSelection(),l.highlighted)for(E=0;E<l.highlighted.length;E++)l.highlighted[E].classList.add("copying"),l.highlighted[E].classList.contains("highlight-left")&&l.highlighted[E].classList.add("copying-left"),l.highlighted[E].classList.contains("highlight-right")&&l.highlighted[E].classList.add("copying-right"),l.highlighted[E].classList.contains("highlight-top")&&l.highlighted[E].classList.add("copying-top"),l.highlighted[E].classList.contains("highlight-bottom")&&l.highlighted[E].classList.add("copying-bottom");l.dispatch("oncopy",e,1==l.options.copyCompatibility?p:d,l.hashString)}return l.data},l.paste=function(t,o,n){var s=parseInt(t),i=parseInt(o),a=parseInt(l.selectedCell[2]),c=parseInt(l.selectedCell[3]),u=a-s+1,d=c-i+1;a<s&&(t=a.toString(),u=s-a+1),c<i&&(o=c.toString(),d=i-c+1);var p=l.dispatch("onbeforepaste",e,n,t,o);if(!1===p)return!1;p&&(n=p);var h=l.hash(n),g=h==l.hashString?l.style:null;if(1==l.options.copyCompatibility&&h==l.hashString&&(n=l.data),n=l.parseCSV(n,"\t"),u>1&Number.isInteger(u/n[0].length)){g=null,m=u/n[0].length;var f=n.map(function(e,t){var o=Array.apply(null,{length:m*e.length}).map(function(t,o){return e[o%e.length]});return o});n=f}if(d>1&Number.isInteger(d/n.length)){g=null;var m=d/n.length;f=Array.apply(null,{length:m*n.length}).map(function(e,t){return n[t%n.length]}),n=f}if(null!=t&&null!=o&&n){for(var C=0,y=0,v=[],b={},w={},A=0,x=parseInt(t),F=parseInt(o),E=null;E=n[y];){for(C=0,x=parseInt(t);null!=E[C];){var L=l.updateCell(x,F,E[C]);if(v.push(L),l.updateFormulaChain(x,F,v),g&&g[A]){var D=r.getColumnNameFromId([x,F]);b[D]=g[A],w[D]=l.getStyle(D),l.records[F][x].setAttribute("style",g[A]),A++}if(null!=E[++C]){if(x>=l.headers.length-1){if(1!=l.options.allowInsertColumn)break;l.insertColumn()}x=l.right.get(x,F)}}if(y++,n[y]){if(F>=l.rows.length-1){if(1!=l.options.allowInsertRow)break;l.insertRow()}F=l.down.get(t,F)}}l.updateSelectionFromCoords(t,o,x,F),l.setHistory({action:"setValue",records:v,selection:l.selectedCell,newStyle:b,oldStyle:w}),l.updateTable(),l.dispatch("onpaste",e,n),l.onafterchanges(e,v)}l.removeCopyingSelection()},l.removeCopyingSelection=function(){for(var e=document.querySelectorAll(".jexcel .copying"),t=0;t<e.length;t++)e[t].classList.remove("copying"),e[t].classList.remove("copying-left"),e[t].classList.remove("copying-right"),e[t].classList.remove("copying-top"),e[t].classList.remove("copying-bottom")},l.historyProcessRow=function(e,t){var o=t.insertBefore?+t.rowNumber:t.rowNumber+1;if(1==l.options.search&&l.results&&l.results.length!=l.rows.length&&l.resetSearch(),1==e){for(var n=t.numOfRows,s=o;s<n+o;s++)l.rows[s].parentNode.removeChild(l.rows[s]);l.records.splice(o,n),l.options.data.splice(o,n),l.rows.splice(o,n),l.conditionalSelectionUpdate(1,o,n+o-1)}else{l.records=r.injectArray(l.records,o,t.rowRecords),l.options.data=r.injectArray(l.options.data,o,t.rowData),l.rows=r.injectArray(l.rows,o,t.rowNode);var i=0;for(s=o;s<t.numOfRows+o;s++)l.tbody.insertBefore(t.rowNode[i],l.tbody.children[s]),i++}l.options.pagination>0&&l.page(l.pageNumber),l.updateTableReferences()},l.historyProcessColumn=function(e,t){var o=t.insertBefore?t.columnNumber:t.columnNumber+1;if(1==e){var n=t.numOfColumns;l.options.columns.splice(o,n);for(var s=o;s<n+o;s++)l.headers[s].parentNode.removeChild(l.headers[s]),l.colgroup[s].parentNode.removeChild(l.colgroup[s]);l.headers.splice(o,n),l.colgroup.splice(o,n);for(var i=0;i<t.data.length;i++){for(s=o;s<n+o;s++)l.records[i][s].parentNode.removeChild(l.records[i][s]);l.records[i].splice(o,n),l.options.data[i].splice(o,n)}if(l.options.footers)for(i=0;i<l.options.footers.length;i++)l.options.footers[i].splice(o,n)}else{l.options.columns=r.injectArray(l.options.columns,o,t.columns),l.headers=r.injectArray(l.headers,o,t.headers),l.colgroup=r.injectArray(l.colgroup,o,t.colgroup);var a=0;for(s=o;s<t.numOfColumns+o;s++)l.headerContainer.insertBefore(t.headers[a],l.headerContainer.children[s+1]),l.colgroupContainer.insertBefore(t.colgroup[a],l.colgroupContainer.children[s+1]),a++;for(i=0;i<t.data.length;i++)for(l.options.data[i]=r.injectArray(l.options.data[i],o,t.data[i]),l.records[i]=r.injectArray(l.records[i],o,t.records[i]),a=0,s=o;s<t.numOfColumns+o;s++)l.rows[i].insertBefore(t.records[i][a],l.rows[i].children[s+1]),a++;if(l.options.footers)for(i=0;i<l.options.footers.length;i++)l.options.footers[i]=r.injectArray(l.options.footers[i],o,t.footers[i])}if(l.options.nestedHeaders&&l.options.nestedHeaders.length>0)if(l.options.nestedHeaders[0]&&l.options.nestedHeaders[0][0])for(i=0;i<l.options.nestedHeaders.length;i++){if(1==e)var c=parseInt(l.options.nestedHeaders[i][l.options.nestedHeaders[i].length-1].colspan)-t.numOfColumns;else c=parseInt(l.options.nestedHeaders[i][l.options.nestedHeaders[i].length-1].colspan)+t.numOfColumns;l.options.nestedHeaders[i][l.options.nestedHeaders[i].length-1].colspan=c,l.thead.children[i].children[l.thead.children[i].children.length-1].setAttribute("colspan",c)}else c=1==e?parseInt(l.options.nestedHeaders[0].colspan)-t.numOfColumns:parseInt(l.options.nestedHeaders[0].colspan)+t.numOfColumns,l.options.nestedHeaders[0].colspan=c,l.thead.children[0].children[l.thead.children[0].children.length-1].setAttribute("colspan",c);l.updateTableReferences()},l.undo=function(){var t=!!l.ignoreEvents,o=!!l.ignoreHistory;l.ignoreEvents=!0,l.ignoreHistory=!0;var n=[];if(l.historyIndex>=0){var r=l.history[l.historyIndex--];if("insertRow"==r.action)l.historyProcessRow(1,r);else if("deleteRow"==r.action)l.historyProcessRow(0,r);else if("insertColumn"==r.action)l.historyProcessColumn(1,r);else if("deleteColumn"==r.action)l.historyProcessColumn(0,r);else if("moveRow"==r.action)l.moveRow(r.newValue,r.oldValue);else if("moveColumn"==r.action)l.moveColumn(r.newValue,r.oldValue);else if("setMerge"==r.action)l.removeMerge(r.column,r.data);else if("setStyle"==r.action)l.setStyle(r.oldValue,null,null,1);else if("setWidth"==r.action)l.setWidth(r.column,r.oldValue);else if("setHeight"==r.action)l.setHeight(r.row,r.oldValue);else if("setHeader"==r.action)l.setHeader(r.column,r.oldValue);else if("setComments"==r.action)l.setComments(r.column,r.oldValue[0],r.oldValue[1]);else if("orderBy"==r.action){for(var s=[],i=0;i<r.rows.length;i++)s[r.rows[i]]=i;l.updateOrderArrow(r.column,r.order?0:1),l.updateOrder(s)}else if("setValue"==r.action){for(var a=0;a<r.records.length;a++)n.push({x:r.records[a].x,y:r.records[a].y,newValue:r.records[a].oldValue}),r.oldStyle&&l.resetStyle(r.oldStyle);l.setValue(n),r.selection&&l.updateSelectionFromCoords(r.selection[0],r.selection[1],r.selection[2],r.selection[3])}}l.ignoreEvents=t,l.ignoreHistory=o,l.dispatch("onundo",e,r),l.updateTablePressToolbarUndoRedoState()},l.redo=function(){var t=!!l.ignoreEvents,o=!!l.ignoreHistory;if(l.ignoreEvents=!0,l.ignoreHistory=!0,l.historyIndex<l.history.length-1){var n=l.history[++l.historyIndex];if("insertRow"==n.action)l.historyProcessRow(0,n);else if("deleteRow"==n.action)l.historyProcessRow(1,n);else if("insertColumn"==n.action)l.historyProcessColumn(0,n);else if("deleteColumn"==n.action)l.historyProcessColumn(1,n);else if("moveRow"==n.action)l.moveRow(n.oldValue,n.newValue);else if("moveColumn"==n.action)l.moveColumn(n.oldValue,n.newValue);else if("setMerge"==n.action)l.setMerge(n.column,n.colspan,n.rowspan,1);else if("setStyle"==n.action)l.setStyle(n.newValue,null,null,1);else if("setWidth"==n.action)l.setWidth(n.column,n.newValue);else if("setHeight"==n.action)l.setHeight(n.row,n.newValue);else if("setHeader"==n.action)l.setHeader(n.column,n.newValue);else if("setComments"==n.action)l.setComments(n.column,n.newValue[0],n.newValue[1]);else if("orderBy"==n.action)l.updateOrderArrow(n.column,n.order),l.updateOrder(n.rows);else if("setValue"==n.action){l.setValue(n.records);for(var r=0;r<n.records.length;r++)n.oldStyle&&l.resetStyle(n.newStyle);n.selection&&l.updateSelectionFromCoords(n.selection[0],n.selection[1],n.selection[2],n.selection[3])}}l.ignoreEvents=t,l.ignoreHistory=o,l.dispatch("onredo",e,n),l.updateTablePressToolbarUndoRedoState()},l.getDropDownValue=function(e,t){var o=[];if(l.options.columns[e]&&l.options.columns[e].source){for(var n=[],r=l.options.columns[e].source,s=0;s<r.length;s++)"object"==typeof r[s]?n[r[s].id]=r[s].name:n[r[s]]=r[s];var i=Array.isArray(t)?t:(""+t).split(";");for(s=0;s<i.length;s++)"object"==typeof i[s]?o.push(n[i[s].id]):n[i[s]]&&o.push(n[i[s]])}else console.error("Invalid column");return o.length>0?o.join("; "):""},l.parseCSV=function(e,t){e=e.replace(/\r?\n$|\r$|\n$/g,""),e+="\n",t=t||",";const o=new RegExp("^"+" \t\v\0".replace(t,"")+"*");let n=[],r=[],s=0,l="",i=!1,a=!1;const c=e.length;for(let u=0;u<c;u++){let d=e[u],p=u+1<c?e[u+1]:"";if('"'===d)if(i)if('"'===p)l+=d,++u;else if(p!==t&&"\r"!==p&&"\n"!==p){let n=u+1;for(;void 0!==e[n]&&""===e[n].replace(o,"");n++);e[n]===t?(i=!1,u=n):(l+=d,i=!1)}else i=!1;else""===l.replace(o,"")?(i=!0,a=!0):l+=d;else d!==t&&"\n"!==d&&"\r"!==d||i?l+=d:(r[s]=a?l:l.trim(),l="",a=!1,++s,"\n"!==d&&"\r"!==d||(n.push(r),r=[],s=0,"\r"===d&&"\n"===p&&++u))}return n},l.hash=function(e){var t,o=0;if(0===e.length)return o;for(t=0;t<e.length;t++)o=(o<<5)-o+e.charCodeAt(t),o|=0;return o},l.onafterchanges=function(e,t){l.dispatch("onafterchanges",e,t)},l.destroy=function(){r.destroy(e)},l.init=function(){r.current=l,"function"==typeof r.build&&(l.options.root?r.build(l.options.root):(r.build(document),r.build=null)),e.setAttribute("tabindex",1),e.addEventListener("focus",function(e){r.current&&!l.selectedCell&&(l.updateSelectionFromCoords(0,0,0,0),l.left())}),l.options.csv?(1==l.options.loadingSpin&&jSuites.loading.show(),jSuites.ajax({url:l.options.csv,method:l.options.method,data:l.options.requestVariables,dataType:"text",success:function(e){var t=l.parseCSV(e,l.options.csvDelimiter);if(1==l.options.csvHeaders&&t.length>0)for(var o=t.shift(),n=0;n<o.length;n++)l.options.columns[n]||(l.options.columns[n]={type:"text",align:l.options.defaultColAlign,width:l.options.defaultColWidth}),void 0===l.options.columns[n].title&&(l.options.columns[n].title=o[n]);l.options.data=t,l.prepareTable(),1==l.options.loadingSpin&&jSuites.loading.hide()}})):l.options.url?(1==l.options.loadingSpin&&jSuites.loading.show(),jSuites.ajax({url:l.options.url,method:l.options.method,data:l.options.requestVariables,dataType:"json",success:function(e){l.options.data=e.data?e.data:e,l.prepareTable(),1==l.options.loadingSpin&&jSuites.loading.hide()}})):l.prepareTable()},s&&null!=s.contextMenu?l.options.contextMenu=s.contextMenu:l.options.contextMenu=function(e,o,n,s){var i=[];if(null==n)1==l.options.allowInsertColumn&&i.push({title:l.options.text.insertANewColumnBefore,onclick:function(){l.insertColumn(1,parseInt(o),1)}}),1==l.options.allowInsertColumn&&i.push({title:l.options.text.insertANewColumnAfter,onclick:function(){l.insertColumn(1,parseInt(o),0)}}),1==l.options.allowDeleteColumn&&i.push({title:l.options.text.deleteSelectedColumns,onclick:function(){l.deleteColumn(l.getSelectedColumns().length?void 0:parseInt(o))}}),1==l.options.allowRenameColumn&&i.push({title:l.options.text.renameThisColumn,onclick:function(){l.setHeader(o)}}),1==l.options.columnSorting&&(i.push({type:"line"}),i.push({title:l.options.text.orderAscending,onclick:function(){l.orderBy(o,0)}}),i.push({title:l.options.text.orderDescending,onclick:function(){l.orderBy(o,1)}}));else if(1==l.options.allowInsertRow&&(i.push({title:l.options.text.insertANewRowBefore,onclick:function(){l.insertRow(1,parseInt(n),1)}}),i.push({title:l.options.text.insertANewRowAfter,onclick:function(){l.insertRow(1,parseInt(n))}})),1==l.options.allowDeleteRow&&i.push({title:l.options.text.deleteSelectedRows,onclick:function(){l.deleteRow(l.getSelectedRows().length?void 0:parseInt(n))}}),o&&1==l.options.allowComments){i.push({type:"line"});var a=l.records[n][o].getAttribute("title")||"";i.push({title:a?l.options.text.editComments:l.options.text.addComments,onclick:function(){var e=prompt(l.options.text.comments,a);e&&l.setComments([o,n],e)}}),a&&i.push({title:l.options.text.clearComments,onclick:function(){l.setComments([o,n],"")}})}return i.push({type:"line"}),i.push({title:l.options.text.copy,shortcut:"Ctrl + C",onclick:function(){l.copy(!0)}}),navigator&&navigator.clipboard&&i.push({title:l.options.text.paste,shortcut:"Ctrl + V",onclick:function(){l.selectedCell&&navigator.clipboard.readText().then(function(e){e&&r.current.paste(l.selectedCell[0],l.selectedCell[1],e)})}}),l.options.allowExport&&i.push({title:l.options.text.saveAs,shortcut:"Ctrl + S",onclick:function(){l.download()}}),l.options.about&&i.push({title:l.options.text.about,onclick:function(){!0===l.options.about?alert(t().print()):alert(l.options.about)}}),i},l.scrollControls=function(e){l.wheelControls(),l.options.freezeColumns>0&&l.content.scrollLeft!=f&&l.updateFreezePosition(),1!=l.options.lazyLoading&&1!=l.options.tableOverflow||l.edition&&"jdropdown"!=e.target.className.substr(0,9)&&l.closeEditor(l.edition[0],!0)},l.wheelControls=function(e){1==l.options.lazyLoading&&null==r.timeControlLoading&&(r.timeControlLoading=setTimeout(function(){l.content.scrollTop+l.content.clientHeight>=l.content.scrollHeight-10?l.loadDown()&&(l.content.scrollTop+l.content.clientHeight>l.content.scrollHeight-10&&(l.content.scrollTop=l.content.scrollTop-l.content.clientHeight),l.updateCornerPosition()):l.content.scrollTop<=l.content.clientHeight&&l.loadUp()&&(l.content.scrollTop<10&&(l.content.scrollTop=l.content.scrollTop+l.content.clientHeight),l.updateCornerPosition()),r.timeControlLoading=null},100))},l.getFreezeWidth=function(){var e=0;if(l.options.freezeColumns>0)for(var t=0;t<l.options.freezeColumns;t++)e+=parseInt(l.options.columns[t].width);return e};var f=0;return l.updateFreezePosition=function(){var e=0;if((f=l.content.scrollLeft)>50)for(var t=0;t<l.options.freezeColumns;t++){t>0&&"hidden"!==l.options.columns[t-1].type&&(e+=parseInt(l.options.columns[t-1].width)),l.headers[t].classList.add("jexcel_freezed"),l.headers[t].style.left=e+"px";for(var o=0;o<l.rows.length;o++)if(l.rows[o]&&l.records[o][t]){var n=f+(t>0?l.records[o][t-1].style.width:0)-51+"px";l.records[o][t].classList.add("jexcel_freezed"),l.records[o][t].style.left=n}}else for(t=0;t<l.options.freezeColumns;t++)for(l.headers[t].classList.remove("jexcel_freezed"),l.headers[t].style.left="",o=0;o<l.rows.length;o++)l.records[o][t]&&(l.records[o][t].classList.remove("jexcel_freezed"),l.records[o][t].style.left="");l.updateCornerPosition()},e.addEventListener("DOMMouseScroll",l.wheelControls),e.addEventListener("mousewheel",l.wheelControls),e.jexcel=l,e.jspreadsheet=l,l.init(),l};r.setDictionary=function(e){jSuites.setDictionary(e)},r.setExtensions=function(e){for(var t=Object.keys(e),o=0;o<t.length;o++)"function"==typeof e[t[o]]&&(r[t[o]]=e[t[o]],r.license&&"function"==typeof e[t[o]].license&&e[t[o]].license(r.license))},"undefined"!=typeof formula&&(r.formula=formula),r.version=t,r.current=null,r.timeControl=null,r.timeControlLoading=null;const s=function(e){e.removeEventListener("mouseup",r.mouseUpControls),e.removeEventListener("mousedown",r.mouseDownControls),e.removeEventListener("mousemove",r.mouseMoveControls),e.removeEventListener("mouseover",r.mouseOverControls),e.removeEventListener("dblclick",r.doubleClickControls),e.removeEventListener("paste",r.pasteControls),e.removeEventListener("contextmenu",r.contextMenuControls),e.removeEventListener("touchstart",r.touchStartControls),e.removeEventListener("touchend",r.touchEndControls),e.removeEventListener("touchcancel",r.touchEndControls),document.removeEventListener("keydown",r.keyDownControls)};var l;return r.destroy=function(e,t){if(e.jexcel){var o=e.jexcel.options.root?e.jexcel.options.root:document;e.removeEventListener("DOMMouseScroll",e.jexcel.scrollControls),e.removeEventListener("mousewheel",e.jexcel.scrollControls),e.jexcel=null,e.innerHTML="",t&&(s(o),r=null)}},r.build=function(e){s(e),e.addEventListener("mouseup",r.mouseUpControls),e.addEventListener("mousedown",r.mouseDownControls),e.addEventListener("mousemove",r.mouseMoveControls),e.addEventListener("mouseover",r.mouseOverControls),e.addEventListener("dblclick",r.doubleClickControls),e.addEventListener("paste",r.pasteControls),e.addEventListener("contextmenu",r.contextMenuControls),e.addEventListener("touchstart",r.touchStartControls),e.addEventListener("touchend",r.touchEndControls),e.addEventListener("touchcancel",r.touchEndControls),e.addEventListener("touchmove",r.touchEndControls),document.addEventListener("keydown",r.keyDownControls)},r.keyDownControls=function(e){if(r.current){if(r.current.edition)if(27==e.which)r.current.edition&&r.current.closeEditor(r.current.edition[0],!1),e.preventDefault();else if(13==e.which){if("calendar"==r.current.options.columns[r.current.edition[2]].type)r.current.closeEditor(r.current.edition[0],!0);else if("dropdown"==r.current.options.columns[r.current.edition[2]].type||"autocomplete"==r.current.options.columns[r.current.edition[2]].type);else if((1==r.current.options.wordWrap||1==r.current.options.columns[r.current.edition[2]].wordWrap||r.current.options.data[r.current.edition[3]][r.current.edition[2]].length>200)&&e.altKey){var t=r.current.edition[0].children[0],o=r.current.edition[0].children[0].value,n=t.selectionStart;o=o.slice(0,n)+"\n"+o.slice(n),t.value=o,t.focus(),t.selectionStart=n+1,t.selectionEnd=n+1}}else 9==e.which&&(["calendar","html"].includes(r.current.options.columns[r.current.edition[2]].type)?r.current.closeEditor(r.current.edition[0],!0):r.current.edition[0].children[0].blur());if(!r.current.edition&&r.current.selectedCell)if(37==e.which)r.current.left(e.shiftKey,e.ctrlKey),e.preventDefault();else if(39==e.which)r.current.right(e.shiftKey,e.ctrlKey),e.preventDefault();else if(38==e.which)r.current.up(e.shiftKey,e.ctrlKey),e.preventDefault();else if(40==e.which)r.current.down(e.shiftKey,e.ctrlKey),e.preventDefault();else if(36==e.which)r.current.first(e.shiftKey,e.ctrlKey),e.preventDefault();else if(35==e.which)r.current.last(e.shiftKey,e.ctrlKey),e.preventDefault();else if(46==e.which||8==e.which)1==r.current.options.editable&&(r.current.selectedRow?1==r.current.options.allowDeleteRow&&confirm(r.current.options.text.areYouSureToDeleteTheSelectedRows)&&r.current.deleteRow():r.current.selectedHeader?1==r.current.options.allowDeleteColumn&&confirm(r.current.options.text.areYouSureToDeleteTheSelectedColumns)&&r.current.deleteColumn():r.current.setValue(r.current.highlighted,""));else if(13==e.which)e.shiftKey?r.current.up():(1==r.current.options.allowInsertRow&&1==r.current.options.allowManualInsertRow&&r.current.selectedCell[1]==r.current.options.data.length-1&&r.current.insertRow(),r.current.down()),e.preventDefault();else if(9==e.which)e.shiftKey?0==r.current.selectedCell[0]?(r.current.up(),r.current.last()):r.current.left():(1==r.current.options.allowInsertColumn&&1==r.current.options.allowManualInsertColumn&&r.current.selectedCell[0]==r.current.options.data[0].length-1&&r.current.insertColumn(),r.current.selectedCell[0]==r.current.options.data[0].length-1?(r.current.down(),r.current.first()):r.current.right()),e.preventDefault();else if(!e.ctrlKey&&!e.metaKey||e.shiftKey){if(r.current.selectedCell&&1==r.current.options.editable){var s=r.current.selectedCell[1],l=r.current.selectedCell[0];"readonly"!=r.current.options.columns[l].type&&(32==e.keyCode?(e.preventDefault(),"checkbox"==r.current.options.columns[l].type||"radio"==r.current.options.columns[l].type?r.current.setCheckRadioValue():r.current.openEditor(r.current.records[s][l],!0)):113==e.keyCode?r.current.openEditor(r.current.records[s][l],!1):(8==e.keyCode||e.keyCode>=48&&e.keyCode<=57||e.keyCode>=96&&e.keyCode<=111||e.keyCode>=187&&e.keyCode<=190||(String.fromCharCode(e.keyCode)==e.key||String.fromCharCode(e.keyCode).toLowerCase()==e.key.toLowerCase())&&r.validLetter(String.fromCharCode(e.keyCode)))&&(r.current.openEditor(r.current.records[s][l],!0),"calendar"==r.current.options.columns[l].type&&e.preventDefault()))}}else 65==e.which?(r.current.selectAll(),e.preventDefault()):83==e.which?(r.current.download(),e.preventDefault()):89==e.which?(r.current.redo(),e.preventDefault()):90==e.which?(r.current.undo(),e.preventDefault()):67==e.which?(r.current.copy(!0),e.preventDefault()):88==e.which?(1==r.current.options.editable?r.cutControls():r.copyControls(),e.preventDefault()):86==e.which&&r.pasteControls();else e.target.classList.contains("jexcel_search")&&(r.timeControl&&clearTimeout(r.timeControl),r.timeControl=setTimeout(function(){r.current.search(e.target.value)},200))}},r.isMouseAction=!1,r.mouseDownControls=function(e){if((e=e||window.event).buttons)var t=e.buttons;else t=e.button?e.button:e.which;var o=r.getElement(e.target);if(o[0]?r.current!=o[0].jexcel&&(r.current&&(r.current.edition&&r.current.closeEditor(r.current.edition[0],!0),r.current.resetSelection()),r.current=o[0].jexcel):r.current&&(r.current.edition&&r.current.closeEditor(r.current.edition[0],!0),r.current.resetSelection(!0),r.current=null),r.current&&1==t){if(e.target.classList.contains("jexcel_selectall"))r.current&&r.current.selectAll();else if(e.target.classList.contains("jexcel_corner"))1==r.current.options.editable&&(r.current.selectedCorner=!0);else{if(1==o[1]){if(g=e.target.getAttribute("data-x")){var n=e.target.getBoundingClientRect();if(1==r.current.options.columnResize&&n.width-e.offsetX<12){r.current.resizing={mousePosition:e.pageX,column:g,width:n.width},r.current.headers[g].classList.add("resizing");for(var s=0;s<r.current.records.length;s++)r.current.records[s][g]&&r.current.records[s][g].classList.add("resizing")}else if(1==r.current.options.columnDrag&&n.height-e.offsetY<12)if(r.current.isColMerged(g).length)console.error("Jspreadsheet: This column is part of a merged cell.");else for(r.current.resetSelection(),r.current.dragging={element:e.target,column:g,destination:g},r.current.headers[g].classList.add("dragging"),s=0;s<r.current.records.length;s++)r.current.records[s][g]&&r.current.records[s][g].classList.add("dragging");else{if(r.current.selectedHeader&&(e.shiftKey||e.ctrlKey))var l=r.current.selectedHeader,i=g;else r.current.selectedHeader==g&&1==r.current.options.allowRenameColumn&&(r.timeControl=setTimeout(function(){r.current.setHeader(g)},800)),r.current.selectedHeader=g,l=g,i=g;r.current.updateSelectionFromCoords(l,0,i,r.current.options.data.length-1)}}else if(e.target.parentNode.classList.contains("jexcel_nested")){if(e.target.getAttribute("data-column"))var a=e.target.getAttribute("data-column").split(","),c=parseInt(a[0]),u=parseInt(a[a.length-1]);else c=0,u=r.current.options.columns.length-1;r.current.updateSelectionFromCoords(c,0,u,r.current.options.data.length-1)}}else r.current.selectedHeader=!1;if(2==o[1]){var d=e.target.getAttribute("data-y");if(e.target.classList.contains("jexcel_row"))n=e.target.getBoundingClientRect(),1==r.current.options.rowResize&&n.height-e.offsetY<12?(r.current.resizing={element:e.target.parentNode,mousePosition:e.pageY,row:d,height:n.height},e.target.parentNode.classList.add("resizing")):1==r.current.options.rowDrag&&n.width-e.offsetX<18?r.current.isRowMerged(d).length?console.error("Jspreadsheet: This row is part of a merged cell"):1==r.current.options.search&&r.current.results?console.error("Jspreadsheet: Please clear your search before perform this action"):(r.current.resetSelection(),r.current.dragging={element:e.target.parentNode,row:d,destination:d},e.target.parentNode.classList.add("dragging")):(r.current.selectedRow&&(e.shiftKey||e.ctrlKey)?(l=r.current.selectedRow,i=d):(r.current.selectedRow=d,l=d,i=d),r.current.updateSelectionFromCoords(0,l,r.current.options.data[0].length-1,i));else if(e.target.classList.contains("jclose")&&e.target.clientWidth-e.offsetX<50&&e.offsetY<50)r.current.closeEditor(r.current.edition[0],!0);else{var p=function(e){var t=e.getAttribute("data-x"),o=e.getAttribute("data-y");return t&&o?[t,o]:e.parentNode?p(e.parentNode):void 0},h=p(e.target);if(h){var g=h[0];d=h[1],r.current.edition&&(r.current.edition[2]==g&&r.current.edition[3]==d||r.current.closeEditor(r.current.edition[0],!0)),r.current.edition||(e.shiftKey?r.current.updateSelectionFromCoords(r.current.selectedCell[0],r.current.selectedCell[1],g,d):r.current.updateSelectionFromCoords(g,d)),r.current.selectedHeader=null,r.current.selectedRow=null}}}else r.current.selectedRow=!1;e.target.classList.contains("jexcel_page")&&("<"==e.target.textContent?r.current.page(0):">"==e.target.textContent?r.current.page(e.target.getAttribute("title")-1):r.current.page(e.target.textContent-1))}r.current.edition?r.isMouseAction=!1:r.isMouseAction=!0}else r.isMouseAction=!1},r.mouseUpControls=function(e){if(r.current)if(r.current.resizing){if(r.current.resizing.column){var t=r.current.colgroup[r.current.resizing.column].getAttribute("width"),o=r.current.getSelectedColumns();if(o.length>1){for(var n=[],s=0;s<o.length;s++)n.push(parseInt(r.current.colgroup[o[s]].getAttribute("width")));n[o.indexOf(parseInt(r.current.resizing.column))]=r.current.resizing.width,r.current.setWidth(o,t,n)}else r.current.setWidth(r.current.resizing.column,t,r.current.resizing.width);r.current.headers[r.current.resizing.column].classList.remove("resizing");for(var l=0;l<r.current.records.length;l++)r.current.records[l][r.current.resizing.column]&&r.current.records[l][r.current.resizing.column].classList.remove("resizing")}else{r.current.rows[r.current.resizing.row].children[0].classList.remove("resizing");var i=r.current.rows[r.current.resizing.row].getAttribute("height");r.current.setHeight(r.current.resizing.row,i,r.current.resizing.height),r.current.resizing.element.classList.remove("resizing")}r.current.resizing=null}else if(r.current.dragging){if(r.current.dragging){if(r.current.dragging.column){var a=e.target.getAttribute("data-x");for(r.current.headers[r.current.dragging.column].classList.remove("dragging"),l=0;l<r.current.rows.length;l++)r.current.records[l][r.current.dragging.column]&&r.current.records[l][r.current.dragging.column].classList.remove("dragging");for(s=0;s<r.current.headers.length;s++)r.current.headers[s].classList.remove("dragging-left"),r.current.headers[s].classList.remove("dragging-right");a&&r.current.dragging.column!=r.current.dragging.destination&&r.current.moveColumn(r.current.dragging.column,r.current.dragging.destination)}else{if(r.current.dragging.element.nextSibling){var c=parseInt(r.current.dragging.element.nextSibling.getAttribute("data-y"));r.current.dragging.row<c&&(c-=1)}else c=parseInt(r.current.dragging.element.previousSibling.getAttribute("data-y"));r.current.dragging.row!=r.current.dragging.destination&&r.current.moveRow(r.current.dragging.row,c,!0),r.current.dragging.element.classList.remove("dragging")}r.current.dragging=null}}else r.current.selectedCorner&&(r.current.selectedCorner=!1,r.current.selection.length>0&&(r.current.copyData(r.current.selection[0],r.current.selection[r.current.selection.length-1]),r.current.removeCopySelection()));r.timeControl&&(clearTimeout(r.timeControl),r.timeControl=null),r.isMouseAction=!1},r.mouseMoveControls=function(e){if((e=e||window.event).buttons)var t=e.buttons;else t=e.button?e.button:e.which;if(t||(r.isMouseAction=!1),r.current)if(1==r.isMouseAction){if(r.current.resizing)if(r.current.resizing.column){var o=e.pageX-r.current.resizing.mousePosition;if(r.current.resizing.width+o>0){var n=r.current.resizing.width+o;r.current.colgroup[r.current.resizing.column].setAttribute("width",n),r.current.updateCornerPosition()}}else{var s=e.pageY-r.current.resizing.mousePosition;if(r.current.resizing.height+s>0){var l=r.current.resizing.height+s;r.current.rows[r.current.resizing.row].setAttribute("height",l),r.current.rows[r.current.resizing.row].style.setProperty("--table-editor-line-clamp",Math.floor((l-10)/14)),r.current.updateCornerPosition()}}else if(r.current.dragging)if(r.current.dragging.column){var i=e.target.getAttribute("data-x");if(i)if(r.current.isColMerged(i).length)console.error("Jspreadsheet: This column is part of a merged cell.");else{for(var a=0;a<r.current.headers.length;a++)r.current.headers[a].classList.remove("dragging-left"),r.current.headers[a].classList.remove("dragging-right");r.current.dragging.column==i?r.current.dragging.destination=parseInt(i):e.target.clientWidth/2>e.offsetX?(r.current.dragging.column<i?r.current.dragging.destination=parseInt(i)-1:r.current.dragging.destination=parseInt(i),r.current.headers[i].classList.add("dragging-left")):(r.current.dragging.column<i?r.current.dragging.destination=parseInt(i):r.current.dragging.destination=parseInt(i)+1,r.current.headers[i].classList.add("dragging-right"))}}else{var c=e.target.getAttribute("data-y");if(c)if(r.current.isRowMerged(c).length)console.error("Jspreadsheet: This row is part of a merged cell.");else{var u=e.target.clientHeight/2>e.offsetY?e.target.parentNode.nextSibling:e.target.parentNode;r.current.dragging.element!=u&&(e.target.parentNode.parentNode.insertBefore(r.current.dragging.element,u),r.current.dragging.destination=Array.prototype.indexOf.call(r.current.dragging.element.parentNode.children,r.current.dragging.element))}}}else{var d=e.target.getAttribute("data-x"),p=e.target.getAttribute("data-y"),h=e.target.getBoundingClientRect();r.current.cursor&&(r.current.cursor.style.cursor="",r.current.cursor=null),e.target.parentNode.parentNode&&e.target.parentNode.parentNode.className&&(e.target.parentNode.parentNode.classList.contains("resizable")&&(e.target&&d&&!p&&h.width-(e.clientX-h.left)<12?(r.current.cursor=e.target,r.current.cursor.style.cursor="col-resize"):e.target&&!d&&p&&h.height-(e.clientY-h.top)<12&&(r.current.cursor=e.target,r.current.cursor.style.cursor="row-resize")),e.target.parentNode.parentNode.classList.contains("draggable")&&(e.target&&!d&&p&&h.width-(e.clientX-h.left)<18||e.target&&d&&!p&&h.height-(e.clientY-h.top)<12&&e.clientX-h.left<h.width-24)&&(r.current.cursor=e.target,r.current.cursor.style.cursor="move"))}},r.mouseOverControls=function(e){if((e=e||window.event).buttons)var t=e.buttons;else t=e.button?e.button:e.which;if(t||(r.isMouseAction=!1),r.current&&1==r.isMouseAction){var o=r.getElement(e.target);if(o[0]){if(r.current!=o[0].jexcel&&r.current)return!1;var n=e.target.getAttribute("data-x"),s=e.target.getAttribute("data-y");if(r.current.resizing||r.current.dragging);else{if(1==o[1]&&r.current.selectedHeader){n=e.target.getAttribute("data-x");var l=r.current.selectedHeader,i=n;r.current.updateSelectionFromCoords(l,0,i,r.current.options.data.length-1)}2==o[1]&&(e.target.classList.contains("jexcel_row")?r.current.selectedRow&&(l=r.current.selectedRow,i=s,r.current.updateSelectionFromCoords(0,l,r.current.options.data[0].length-1,i)):r.current.edition||n&&s&&(r.current.selectedCorner?r.current.updateCopySelection(n,s):r.current.selectedCell&&r.current.updateSelectionFromCoords(r.current.selectedCell[0],r.current.selectedCell[1],n,s)))}}}r.timeControl&&(clearTimeout(r.timeControl),r.timeControl=null)},r.doubleClickControls=function(e){if(r.current)if(e.target.classList.contains("jexcel_corner")){if(r.current.highlighted.length>0){var t=r.current.highlighted[0].getAttribute("data-x"),o=parseInt(r.current.highlighted[r.current.highlighted.length-1].getAttribute("data-y"))+1,n=r.current.highlighted[r.current.highlighted.length-1].getAttribute("data-x"),s=r.current.records.length-1;r.current.copyData(r.current.records[o][t],r.current.records[s][n])}}else if(e.target.classList.contains("jexcel_column_filter")){var l=e.target.getAttribute("data-x");r.current.openFilter(l)}else{var i=r.getElement(e.target);if(1==i[1]&&1==r.current.options.columnSorting&&(l=e.target.getAttribute("data-x"))&&r.current.orderBy(l),2==i[1]&&1==r.current.options.editable&&!r.current.edition){var a=function(e){if(e.parentNode){var t=e.getAttribute("data-x"),o=e.getAttribute("data-y");return t&&o?e:a(e.parentNode)}},c=a(e.target);c&&c.classList.contains("highlight")&&r.current.openEditor(c)}}},r.copyControls=function(e){r.current&&r.copyControls.enabled&&(r.current.edition||r.current.copy(!0))},r.cutControls=function(e){r.current&&(r.current.edition||(r.current.copy(!0),1==r.current.options.editable&&r.current.setValue(r.current.highlighted,"")))},r.pasteControls=function(e){r.current&&r.current.selectedCell&&(r.current.edition||1==r.current.options.editable&&(e&&e.clipboardData?(r.current.paste(r.current.selectedCell[0],r.current.selectedCell[1],e.clipboardData.getData("text")),e.preventDefault()):window.clipboardData&&r.current.paste(r.current.selectedCell[0],r.current.selectedCell[1],window.clipboardData.getData("text"))))},r.contextMenuControls=function(e){if("buttons"in(e=e||window.event)?e.buttons:e.which||e.button,r.current&&r.current.options.contextMenu&&(r.current.contextMenu.contextmenu.close(),r.current)){var t="DIV"===e.target.tagName||"TEXTAREA"===e.target.tagName?e.target.parentNode:e.target,o=t.getAttribute("data-x"),n=t.getAttribute("data-y");if(o||n){const t=r.current.selectedCell,l={l:Math.min(parseInt(t[0]),parseInt(t[2])),r:Math.max(parseInt(t[0]),parseInt(t[2])),t:Math.min(parseInt(t[1]),parseInt(t[3])),b:Math.max(parseInt(t[1]),parseInt(t[3]))};(o<l.l||o>l.r||n<l.t||n>l.b)&&r.current.updateSelectionFromCoords(o,n,o,n);var s=r.current.options.contextMenu(r.current,o,n,e);r.current.contextMenu.contextmenu.open(e,s),e.preventDefault()}}},r.touchStartControls=function(e){var t=r.getElement(e.target);if(t[0]?r.current!=t[0].jexcel&&(r.current&&r.current.resetSelection(),r.current=t[0].jexcel):r.current&&(r.current.resetSelection(),r.current=null),r.current&&!r.current.edition){var o=e.target.getAttribute("data-x"),n=e.target.getAttribute("data-y");o&&n&&(r.current.updateSelectionFromCoords(o,n),r.timeControl=setTimeout(function(){"color"==r.current.options.columns[o].type?r.tmpElement=null:r.tmpElement=e.target,r.current.openEditor(e.target,!1,e)},500))}},r.touchEndControls=function(e){r.timeControl&&(clearTimeout(r.timeControl),r.timeControl=null,r.tmpElement&&"INPUT"==r.tmpElement.children[0].tagName&&r.tmpElement.children[0].focus(),r.tmpElement=null)},r.tabs=function(e,t){var o=[];if(e.classList.contains("jexcel_tabs"))s=e.children[0],l=e.children[1];else{e.innerHTML="",e.classList.add("jexcel_tabs"),e.jexcel=[];var n=document.createElement("div"),s=e.appendChild(n),l=(n=document.createElement("div"),e.appendChild(n))}for(var i=[],a=[],c=0;c<t.length;c++){i[c]=document.createElement("div"),i[c].classList.add("jexcel_tab");var u=r(i[c],t[c]);l.appendChild(i[c]),o[c]=e.jexcel.push(u),a[c]=document.createElement("div"),a[c].classList.add("jexcel_tab_link"),a[c].setAttribute("data-spreadsheet",e.jexcel.length-1),a[c].innerHTML=t[c].sheetName,a[c].onclick=function(){for(var e=0;e<s.children.length;e++)s.children[e].classList.remove("selected"),l.children[e].style.display="none";var t=this.getAttribute("data-spreadsheet");l.children[t].style.display="block",s.children[t].classList.add("selected")},s.appendChild(a[c])}for(var d=0;d<s.children.length;d++)s.children[d].classList.remove("selected"),l.children[d].style.display="none";return s.children[s.children.length-1].classList.add("selected"),l.children[s.children.length-1].style.display="block",o},r.createTabs=r.tabs,r.fromSpreadsheet=function(e,t){var o,n=function(e){var t=[];return e.SheetNames.forEach(function(o){var n={rows:[],columns:[],data:[],style:{}};if(n.sheetName=o,(h=e.Sheets[o]["!cols"])&&h.length)for(var s=0;s<h.length;s++)n.columns[s]={},h[s]&&h[s].wpx&&(n.columns[s].width=h[s].wpx+"px");if((h=e.Sheets[o]["!rows"])&&h.length)for(s=0;s<h.length;s++)h[s]&&h[s].hpx&&(n.rows[s]={},n.rows[s].height=h[s].hpx+"px");if((h=e.Sheets[o]["!merges"])&&h.length>0)for(n.mergeCells=[],s=0;s<h.length;s++){var l=h[s].s.c,i=h[s].s.r,a=h[s].e.c,c=h[s].e.r,u=r.getColumnNameFromId([l,i]);n.mergeCells[u]=[a-l+1,c-i+1]}var d=0,p=0,h=Object.keys(e.Sheets[o]);for(s=0;s<h.length;s++)if("!"!=h[s].substr(0,1)){var g=e.Sheets[o][h[s]],f=r.getIdFromColumnName(h[s],!0);n.data[f[1]]||(n.data[f[1]]=[]),n.data[f[1]][f[0]]=g.f?"="+g.f:g.w,d<f[0]&&(d=f[0]),p<f[1]&&(p=f[1]),g.style&&Object.keys(g.style).length>0&&(n.style[h[s]]=g.style),g.s&&g.s.fgColor&&(n.style[h[s]]&&(n.style[h[s]]+=";"),n.style[h[s]]+="background-color:#"+g.s.fgColor.rgb)}for(var m=n.columns,C=0;C<=p;C++)for(s=0;s<=d;s++)n.data[C]||(n.data[C]=[]),n.data[C][s]||m<s&&(n.data[C][s]="");t.push(n)}),t};(o=new XMLHttpRequest).open("GET",e,!0),"undefined"!=typeof Uint8Array?(o.responseType="arraybuffer",o.onload=function(e){var r=o.response,s=new Uint8Array(r),l=XLSX.read(s,{type:"array",cellFormula:!0,cellStyles:!0});t(n(l))}):(o.setRequestHeader("Accept-Charset","x-user-defined"),o.onreadystatechange=function(){if(4==o.readyState&&200==o.status){var e=convertResponseBodyToText(o.responseBody),r=XLSX.read(e,{type:"binary",cellFormula:!0,cellStyles:!0});t(n(r))}}),o.send()},r.validLetter=function(e){return e.match(/([\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC-\u0400-\u04FF']+)/g)?1:0},r.injectArray=function(e,t,o){return e.slice(0,t).concat(o).concat(e.slice(t))},r.getColumnName=function(e){return r.helpers.getColumnName(e)},r.getIdFromColumnName=function(e,t){var o=/^[a-zA-Z]+/.exec(e);if(o){for(var n=0,r=0;r<o[0].length;r++)n+=parseInt(o[0].charCodeAt(r)-64)*Math.pow(26,o[0].length-1-r);--n<0&&(n=0);var s=parseInt(/[0-9]+$/.exec(e));s>0&&s--,e=1==t?[n,s]:n+"-"+s}return e},r.getColumnNameFromId=function(e){return Array.isArray(e)||(e=e.split("-")),r.getColumnName(parseInt(e[0]))+(parseInt(e[1])+1)},r.getElement=function(e){var t=0,o=0;return function e(n){n.className&&n.classList.contains("jexcel_container")&&(o=n),"THEAD"==n.tagName?t=1:"TBODY"==n.tagName&&(t=2),n.parentNode&&(o||e(n.parentNode))}(e),[o,t]},r.doubleDigitFormat=function(e){return 1==(e=""+e).length&&(e="0"+e),e},r.createFromTable=function(e,t){if("TABLE"==e.tagName){t||(t={}),t.columns=[],t.data=[];var o=e.querySelectorAll("colgroup > col");if(o.length)for(var n=0;n<o.length;n++){if(!(s=o[n].style.width))var s=o[n].getAttribute("width");s&&(t.columns[n]||(t.columns[n]={}),t.columns[n].width=s)}var l=function(e){var o=e.getBoundingClientRect(),r=o.width>50?o.width:50;t.columns[n]||(t.columns[n]={}),e.getAttribute("data-celltype")?t.columns[n].type=e.getAttribute("data-celltype"):t.columns[n].type="text",t.columns[n].width=r+"px",t.columns[n].title=e.innerHTML,t.columns[n].align=e.style.textAlign||"center",(o=e.getAttribute("name"))&&(t.columns[n].name=o),(o=e.getAttribute("id"))&&(t.columns[n].id=o),(o=e.getAttribute("data-mask"))&&(t.columns[n].mask=o)},i=[],a=e.querySelectorAll(":scope > thead > tr");if(a.length){for(var c=0;c<a.length-1;c++){var u=[];for(n=0;n<a[c].children.length;n++){var d={title:a[c].children[n].textContent,colspan:a[c].children[n].getAttribute("colspan")||1};u.push(d)}i.push(u)}for(a=a[a.length-1].children,n=0;n<a.length;n++)l(a[n])}var p=0,h={},g={},f={},m={},C=e.querySelectorAll(":scope > tr, :scope > tbody > tr");for(c=0;c<C.length;c++)if(t.data[p]=[],1!=t.parseTableFirstRowAsHeader||a.length||0!=c){for(n=0;n<C[c].children.length;n++){if(y=C[c].children[n].getAttribute("data-formula"))"="!=y.substr(0,1)&&(y="="+y);else var y=C[c].children[n].innerHTML;t.data[p].push(y);var v=r.getColumnNameFromId([n,c]),b=C[c].children[n].getAttribute("class");b&&(m[v]=b);var w=parseInt(C[c].children[n].getAttribute("colspan"))||0,A=parseInt(C[c].children[n].getAttribute("rowspan"))||0;(w||A)&&(h[v]=[w||1,A||1]),C[c].children[n].style&&"none"==C[c].children[n].style.display&&(C[c].children[n].style.display="");var x=C[c].children[n].getAttribute("style");x&&(f[v]=x),C[c].children[n].classList.contains("styleBold")&&(f[v]?f[v]+="; font-weight:bold;":f[v]="font-weight:bold;")}C[c].style&&C[c].style.height&&(g[c]={height:C[c].style.height}),p++}else for(n=0;n<C[c].children.length;n++)l(C[c].children[n]);if(Object.keys(i).length>0&&(t.nestedHeaders=i),Object.keys(f).length>0&&(t.style=f),Object.keys(h).length>0&&(t.mergeCells=h),Object.keys(g).length>0&&(t.rows=g),Object.keys(m).length>0&&(t.classes=m),(C=e.querySelectorAll("tfoot tr")).length){var F=[];for(c=0;c<C.length;c++){var E=[];for(n=0;n<C[c].children.length;n++)E.push(C[c].children[n].textContent);F.push(E)}Object.keys(F).length>0&&(t.footers=F)}if(1==t.parseTableAutoCellType){var L=[];for(n=0;n<t.columns.length;n++){var D=!0,S=!0;for(L[n]=[],c=0;c<t.data.length;c++)y=t.data[c][n],L[n][y]||(L[n][y]=0),L[n][y]++,y.length>25&&(D=!1),10==y.length&&"-"==y.substr(4,1)&&"-"==y.substr(7,1)||(S=!1);var I=Object.keys(L[n]).length;S?t.columns[n].type="calendar":1==D&&I>1&&I<=parseInt(.1*t.data.length)&&(t.columns[n].type="dropdown",t.columns[n].source=Object.keys(L[n]))}}return t}console.log("Element is not a table")},r.helpers=l={getCaretIndex:function(e){if(this.config.root)var t=this.config.root;else t=window;var o=0,n=t.getSelection();if(n&&0!==n.rangeCount){var r=n.getRangeAt(0),s=r.cloneRange();s.selectNodeContents(e),s.setEnd(r.endContainer,r.endOffset),o=s.toString().length}return o},invert:function(e){for(var t=[],o=Object.keys(e),n=0;n<o.length;n++)t[e[o[n]]]=o[n];return t},getColumnName:function(e){let t,o=e+1,n="";for(;o>0;)t=(o-1)%26,n=String.fromCharCode(65+t).toString()+n,o=parseInt((o-t)/26);return n},getColumnNameFromCoords:function(e,t){return l.getColumnName(parseInt(e))+(parseInt(t)+1)},getCoordsFromColumnName:function(e){var t=/^[a-zA-Z]+/.exec(e);if(t){for(var o=0,n=0;n<t[0].length;n++)o+=parseInt(t[0].charCodeAt(n)-64)*Math.pow(26,t[0].length-1-n);--o<0&&(o=0);var r=parseInt(/[0-9]+$/.exec(e))||null;return r>0&&r--,[o,r]}},createFromTable:function(){},injectArray:function(e,t,o){return e.slice(0,t).concat(o).concat(e.slice(t))},parseCSV:function(e,t){t=t||",";for(var o=0,n=0,r=[[]],s=0,l=null,i=!1,a=!1,c=0;c<e.length;c++)if(r[n]||(r[n]=[]),r[n][o]||(r[n][o]=""),"\r"!=e[c])if("\n"!=e[c]&&e[c]!=t||0!=i&&1!=a&&l){if('"'==e[c]&&(i=!i),null===l){if(1==(l=i))continue}else if(!0===l&&!a&&'"'==e[c]){'"'==e[c+1]?(i=!0,r[n][o]+=e[c],c++):a=!0;continue}r[n][o]+=e[c]}else{if(l=null,i=!1,a=!1,'"'==r[n][o][0]){var u=r[n][o].trim();'"'==u[u.length-1]&&(r[n][o]=u.substr(1,u.length-2))}"\n"==e[c]?(o=0,n++):++o>s&&(s=o)}for(var d=0;d<r.length;d++)for(c=0;c<=s;c++)void 0===r[d][c]&&(r[d][c]="");return r}},"undefined"!=typeof jQuery&&function(e){e.fn.jspreadsheet=e.fn.jexcel=function(t){var o=e(this).get(0);return o.jexcel?Array.isArray(o.jexcel)?o.jexcel[t][arguments[1]].apply(this,Array.prototype.slice.call(arguments,2)):o.jexcel[t].apply(this,Array.prototype.slice.call(arguments,1)):r(e(this).get(0),arguments[0])}}(jQuery),r}()})();