(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;n0&&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;n0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(var i=0;ir?s:r,c=i>l?i:l;for(o=0;o=u&&o0&&r++}return t},obj.getJsonRow=function(e){for(var o=obj.options.data[e],t=obj.options.columns.length,n={},r=0;r200)&&(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;r1?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];b0||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;t1?s-1:0);null==o?i<=e&&a>=e&&t.push(n[r]):o?i=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;r1?s-1:0);null==o?i<=e&&a>=e&&t.push(n[r]):o?i=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;r0&&(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;c0)for(var i=0;i200)?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=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;o0?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)1&&(ji&&(i=j+p-1)),h&&(bc&&(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;e0)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+aobj.content.scrollTop+30&&jobj.content.scrollLeft+b&&d0&&("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=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;nr?-1:nr?1:no>e))).unshift(e)}if(window?.tp?.table?.options?.table_foot){const e=r.length-1;(r=r.filter((o=>o0)obj.page(0);else if(1==obj.options.lazyLoading)obj.loadPage(0);else for(t=0;t0){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=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=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;n0)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;i0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(f=0;f1){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;l0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(var b=0;b0){for(var e=0,o=obj.rows.length-1;o>=0;o--){for(var t=!1,n=0;n0&&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;o0&&obj.insertColumn(obj.options.minSpareCols-r)}if("function"==typeof obj.options.updateTable){for(obj.options.detachForUpdates&&el.removeChild(obj.content),o=0;oe+1&&(obj.filter.children[e+1].style.display="");for(var o=0;oe+1&&(obj.filter.children[e+1].style.display="none");for(var o=0;o0)if(chainLoopProtection[n])obj.records[o][e].innerHTML="#ERROR",obj.formula[n]="";else{chainLoopProtection[n]=!0;for(var r=0;r-1)return console.error("Self Reference detected"),"#ERROR";var formulaExpressions={};if(tokens)for(var i=0;i0&&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=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]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;tt;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;t0&&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=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;lt&&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)),t100&&(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=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;l0?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-1?(o0&&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;s0&&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",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;y0)for(b=obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0]?obj.options.nestedHeaders:[obj.options.nestedHeaders],y=0;y=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;o0&&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;r0)if(obj.options.nestedHeaders[0]&&obj.options.nestedHeaders[0][0])for(l=0;l=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;l0?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;u0)for(var t=o.shift(),n=0;n0&&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;o50)for(var o=0;o0&&"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;t0?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;o200)&&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"==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;r0&&(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;ie.offsetX?(jexcel.current.dragging.columne.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.left0){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]))};(tl.r||nl.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;a0)for(n.mergeCells=[],r=0;r0&&(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]||h701?(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;r0&&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;n50?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 tr, :scope > tbody > tr");for(a=0;a0&&(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;a0&&(o.footers=w)}if(1==o.parseTableAutoCellType){var F=[];for(n=0;n25&&(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;n701?(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;n0&&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;cl&&(l=t)}for(var d=0;d