<commit_before>(function(){"use strict";function t(e){return e=e[0].map(function(t,n){return e.map(function(e){return e[n]})}),e}function n(e){return Array.apply(null,e)}function r(e){var t=e.rows,r=[];for(var i=0;i<t.length;i++)r[i]=n(t[i].cells);return r}function i(e){if(typeof e=="undefined"||typeof e.func=="undefined"||typeof e.arr=="undefined"||e.arr.length==0)return;typeof e.start=="undefined"&&(e.start=0),typeof e.end=="undefined"&&(e.end=e.arr.length-1),typeof e.dir=="undefined"&&(e.dir=e.end>e.start?1:-1),typeof e.funcContext=="undefined"&&(e.funcContext=null);var t=Math.min(e.start,e.end),n=Math.max(e.start,e.end),r=e.dir>0?t:n;while(r>=t&&r<=n)e.func.apply(e.funcContext,[e.arr[r],r]),r+=e.dir}function s(e){if(typeof e=="undefined"||typeof e.func=="undefined"||typeof e.arr=="undefined"||e.arr.length==0||!a(e.arr))return;typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=e.arr.length-1),typeof e.colEnd=="undefined"&&(e.colEnd=e.arr[0].length-1),typeof e.rowDir=="undefined"&&(e.rowDir=e.rowEnd>e.rowStart?1:-1),typeof e.colDir=="undefined"&&(e.colDir=e.colEnd>e.colStart?1:-1),typeof e.funcContext=="undefined"&&(e.funcContext=null),i({arr:e.arr,start:e.rowStart,end:e.rowEnd,dir:e.rowDir,func:function(t){i({arr:t,start:e.colStart,end:e.colEnd,dir:e.colDir,func:function(t){e.func.apply(e.funcContext,[t])}})}})}function o(e,t){var n=Object.prototype.toString,r="[object Array]",i=[],s=t&&e||e.slice(),o;if(!e.length)return i;o=s.pop();do n.call(o)===r?s.push.apply(s,o):i.push(o);while(s.length&&(o=s.pop())!==undefined);return i.reverse(),i}function u(e){typeof e.table!="undefined"&&(e.arr=r(e.table));var t=null,n=null,i=e.func,o=function(e,r){n=e,t||(t=e),i(e,r)};return e.func=o,s(e),{first:t,last:n}}function a(e){if(e instanceof Array){var t=e.length>0&&e[0]instanceof Array?e[0].length:0;for(var n=1;n<e.length;n++){var r=e[n];if(!(r instanceof Array))return!1;if(r.length!=t)return!1}return!0}return!1}function f(e){if(document.body.createTextRange){var t=document.body.createTextRange();t.moveToElementText(e),t.select()}else if(window.getSelection){var n=window.getSelection(),t=document.createRange();t.selectNodeContents(e),n.removeAllRanges(),n.addRange(t)}}function l(e){var t=0,n=null,r,i;if(window.getSelection)r=window.getSelection(),r.rangeCount&&(i=r.getRangeAt(0),i.commonAncestorContainer.parentNode==e&&(t=i.endOffset));else if(document.selection&&document.selection.createRange){i=document.selection.createRange();if(i.parentElement()==e){var s=document.createElement("span");e.insertBefore(s,e.firstChild);var o=i.duplicate();o.moveToElementText(s),o.setEndPoint("EndToEnd",i),t=o.text.length}}return t}function c(){document.selection?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()}function h(e){var t=$("tr",e).toArray(),n=t.map(function(e){return e.cells.length}),r=Math.max.apply(null,n);for(var i=0;i<t.length;i++){var s=t[i],o=$("td",s).toArray(),u=$("th",s).toArray(),a=r-(o.length+u.length);if(a>0){var f=o.length==0?"th":"td",l=new Array(a);for(var c=0;c<a;c++)l[c]=document.createElement(f);$(s).append(l)}}}function p(e){var t=e.options;if(t.maxRows>-1)while(e.getRowCount()>t.maxRows)e.removeRow(e.getRowCount()-1);if(t.maxCols>-1)while(e.getColCount()>t.maxCols)e.removeCol(e.getColCount()-1);while(e.getRowCount()<t.minRows)e.insertRow(e.getRowCount());while(e.getColCount()<t.minCols)e.insertCol(e.getColCount())}function d(e){var t=e.options,n=e.VectorManager,r=n.isClear(e.getRow(e.getRowCount()-1));!r&&e.rowsCanGrow()&&e.insertRow(e.getRowCount());var i=n.isClear(e.getCol(e.getColCount()-1));!i&&e.colsCanGrow()&&e.insertCol(e.getColCount())}function v(e){var t=e.options,n=e.VectorManager;if(t.shrinkRows)if(t.rowsAllowMiddleShrink){var r=0;while(e.getRowCount()>t.minRows){var i=e.getRowCount()-(t.growRows?2:1),s=i-r;s>=0&&n.isClear(e.getRow(s))?e.removeRow(s):r++;if(s==0)break}}else while(e.getRowCount()>t.minRows){var s=e.getRowCount()-(t.growRows?2:1);if(!(s>=0&&n.isClear(e.getRow(s))))break;e.removeRow(s)}if(t.shrinkCols)if(t.colsAllowMiddleShrink){var r=0;while(e.getColCount()>t.minCols){var o=e.getColCount()-(t.growCols?2:1),u=o-r;u>=0&&n.isClear(e.getCol(u))?e.removeCol(u):r++;if(u==0)break}}else while(e.getColCount()>t.minCols){var u=e.getColCount()-(t.growCols?2:1);if(!(u>=0&&n.isClear(e.getCol(u))))break;e.removeCol(u)}}function m(e){typeof jQuery=="function"&&e instanceof jQuery&&(e=e[0]);var t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=$(window).height()&&t.right<=$(window).width()}function g(e){m(e)||e.scrollIntoView()}var e=function(){var e=navigator.appVersion,t=navigator.userAgent,n="unknown",r="unknown",i=[{s:"Windows 3.11",r:/Win16/},{s:"Windows 95",r:/(Windows 95|Win95|Windows_95)/},{s:"Windows ME",r:/(Win 9x 4.90|Windows ME)/},{s:"Windows 98",r:/(Windows 98|Win98)/},{s:"Windows CE",r:/Windows CE/},{s:"Windows 2000",r:/(Windows NT 5.0|Windows 2000)/},{s:"Windows XP",r:/(Windows NT 5.1|Windows XP)/},{s:"Windows Server 2003",r:/Windows NT 5.2/},{s:"Windows Vista",r:/Windows NT 6.0/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows NT 4.0",r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},{s:"Windows ME",r:/Windows ME/},{s:"Android",r:/Android/},{s:"Open BSD",r:/OpenBSD/},{s:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:"QNX",r:/QNX/},{s:"UNIX",r:/UNIX/},{s:"BeOS",r:/BeOS/},{s:"OS/2",r:/OS\/2/},{s:"Search Bot",r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}];for(var s in i){var o=i[s];if(o.r.test(t)){r=o.s;break}}/Windows/.test(r)&&(n=/Windows (.*)/.exec(r)[1],r="Windows");switch(r){case"Mac OS X":n=/Mac OS X (10[\.\_\d]+)/.exec(t)[1];break;case"Android":n=/Android ([\.\_\d]+)/.exec(t)[1];break;case"iOS":n=/OS (\d+)_(\d+)_?(\d+)?/.exec(e),n=n[1]+"."+n[2]+"."+(n[3]|0)}return{name:r,versionString:n}};Number.prototype.mod=function(e){return(this%e+e)%e};var y=function(n,r){function i(e){typeof e.minRows=="undefined"&&(e.minRows=1),typeof e.minCols=="undefined"&&(e.minCols=1),typeof e.maxRows=="undefined"&&(e.maxRows=-1),typeof e.maxCols=="undefined"&&(e.maxCols=-1),typeof e.growRows=="undefined"&&(e.growRows=!1),typeof e.growCols=="undefined"&&(e.growCols=!1),typeof e.shrinkRows=="undefined"&&(e.shrinkRows=!1),typeof e.shrinkCols=="undefined"&&(e.shrinkCols=!1),typeof e.rowsAllowMiddleShrink=="undefined"&&(e.rowsAllowMiddleShrink=!1),typeof e.colsAllowMiddleShrink=="undefined"&&(e.colsAllowMiddleShrink=!1),typeof e.copyAsHTML=="undefined"&&(e.copyAsHTML=!0),typeof e.pasteAsHTML=="undefined"&&(e.pasteAsHTML=!1),typeof e.rotateWidePaste=="undefined"&&(e.rotateWidePaste=!1),typeof e.scrollSelectionIntoView=="undefined"&&(e.scrollSelectionIntoView=!0),e.minRows<0&&(e.minRows=0),e.minCols<0&&(e.minCols=0),e.maxRows!=-1&&e.minRows>e.maxRows&&(e.maxRows=e.minRows),e.maxCols!=-1&&e.minCols>e.maxCols&&(e.maxCols=e.minCols)}function s(e){var t,n=a.css("display")=="none";return a.hide(),t=document.elementFromPoint(e.clientX,e.clientY),n||a.show(),t}function m(e){if(!u.hasFocus()||u.Selection.isEditing())return;if(u.options.copyAsHTML){var t=u.getSelectedRows(),n=document.createElement("table");for(var r=0;r<t.length;r++){var i=t[r],s=document.createElement("tr");for(var o=0;o<i.length;o++){var a=i[o];s.appendChild($(a).clone()[0])}n.appendChild(s)}e.clipboardData.setData("text/html",n.outerHTML)}var f="",l=u.getSelectedRowValues();for(var r=0;r<l.length;r++){var c=l[r];for(var o=0;o<c.length;o++){var h=c[o];f+=h,o!=c.length-1&&(f+="	")}r!=l.length-1&&(f+="\n")}e.clipboardData.setData("text/plain",f),e.preventDefault()}function g(e){u.hasFocus()&&!u.Selection.isEditing()&&(m(e),u.clearSelection())}function y(e){if(!u.hasFocus())return;if(!u.Selection.isEditing()){e.preventDefault();var n,r,i=[],s=0,o=e.clipboardData.getData("text/html"),a=e.clipboardData.getData("text/plain"),f=u.getSelectedRows();if(o&&o!=""){if(window.DOMParser){var l=new DOMParser;n=l.parseFromString(o,"text/html")}else n=document.implementation.createHTMLDocument(),n.write(o);var c=n.getElementsByTagName("table");r=c.length>0?c[0]:null}if(r){var h=r.rows;for(var p=0;p<h.length;p++){var d=h[p],v=d.cells;v.length>s&&(s=v.length),i[p]=[];for(var m=0;m<v.length;m++){var g=v[m];i[p][m]=g.innerText}}}else if(a){var h=a.split("\n");for(var p=0;p<h.length;p++){var d=h[p],y=d.split("	");y.length>s&&(s=y.length),i[p]=[];for(var m=0;m<y.length;m++){var b=y[m];i[p][m]=b}}}if(i.length>0&&f.length>0){var w=u.Selection.getCoords(f[0][0]);if(u.options.rotateWidePaste){var E=u.options.maxCols==-1&&s+w[0]>u.getColCount()||u.options.maxCols>-1&&s+w[0]>u.options.maxCols,S=s>i.length,x=u.colsCanGrow();!x&&S&&E&&(i=t(i))}u.setRowValues(i,{rowStart:w[0],colStart:w[1]})}}else if(!u.options.pasteAsHTML){e.preventDefault();var b=e.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,b)}}var u=this;this.table=n,this.options=r||{},this.events={change:[]},h(this.table),i(this.options);var a=$("<div contenteditable></div>").css({cursor:"default",display:"table-row",opacity:"0",position:"absolute","z-index":"1",top:"0",bottom:"0",width:"100%"}).text("ediTable");$(this.table).css({position:"relative"}).append(a),this.CellManager={setEditable:function(e,t){typeof t=="undefined"&&(t=!0),e.contentEditable=t},isEditable:function(e){return e.isContentEditable||e.contentEditable=="true"},setHeader:function(e,t){typeof t=="undefined"&&(t=!0);if(t==this.isHeader(e))return;var n=t?"th":"td",r=e,i=$(r).contents().detach(),s=document.createElement(n);$.each(r.attributes,function(e){$(s).attr(r.attributes[e].name,r.attributes[e].value)}),$(s).append(i),$(r).replaceWith(s)},isHeader:function(e){return e.tagName.toLowerCase()=="th"},select:function(e){$(e).addClass("ediTable-cell-selected")},deselect:function(e){$(e).removeClass("ediTable-cell-selected").removeClass("ediTable-cell-selected-left").removeClass("ediTable-cell-selected-right").removeClass("ediTable-cell-selected-top").removeClass("ediTable-cell-selected-bottom")},isSelected:function(e){return $(e).hasClass("ediTable-cell-selected")},getValue:function(e){return e.innerText},setValue:function(e,t){if(!this.isEditable(e))return;u.options.pasteAsHTML?$(e).html(t):$(e).text(t)},clear:function(e){this.setValue(e,"")},isClear:function(e){return e.innerHTML==""}},this.VectorManager={getSelection:function(e){return e.filter(function(e){return u.CellManager.isSelected(e)})},getValues:function(e){return e.map(function(e){return u.CellManager.getValue(e)})},isHeader:function(e){for(var t=0;t<e.length;t++)if(!u.CellManager.isHeader(e[t]))return!1;return!0},isEditable:function(e){for(var t=0;t<e.length;t++)if(!u.CellManager.isEditable(e[t]))return!1;return!0},isClear:function(e){for(var t=0;t<e.length;t++)if(!u.CellManager.isClear(e[t]))return!1;return!0}},this.Selection=function(){var t,n=$(u.table),r=[],i=function(e){var t=e.name.indexOf("Mac")>-1;return t?function(e){return e.metaKey}:function(e){return e.ctrlKey}}(e()),h,p=function(){var e=(new Date).getTime(),t=e-h;return h=(new Date).getTime(),t<600&&t>0},m=function(e){var n=s(e),i=t.getCoords(n);u.lastClicked=n;var o=u.hasFocus();if(!i||!o)u.deselect(),t.exitEditMode();if(!o||!$.contains(u.table,n))return;if(e.type=="touchstart"&&p()){y(e);return}var a=e.which==3;if(i){var f=!a||a&&!u.hasSelection();if(!u.hasSelection()||!e.shiftKey&&u.hasSelection())r=i;t.isEditing()?n!=t.editingCell&&(t.exitEditMode(),f&&u.select({rowStart:r[0],rowEnd:i[0],colStart:r[1],colEnd:i[1]}),e.preventDefault()):f&&u.select({rowStart:r[0],rowEnd:i[0],colStart:r[1],colEnd:i[1]}),f&&$(document).on("mousemove",w).on("touchmove",w)}},g=function(e){!t.isEditing()&&$.contains(u.table,e.target)&&f(a[0])},y=function(e){if(!u.hasFocus())return;var n=s(e),r=t.getCoords(n);r&&t.setEditMode(n)},b=function(e){$(document).unbind("mousemove",w).unbind("touchmove",w)},w=function(e){var n=t.getCoords(s(e));if(e.changedTouches){var i=e.changedTouches,o,a;if(i.length>0){var f=i.item(0);o=f.clientX,a=f.clientY,n=t.getCoords(document.elementFromPoint(o,a))}}!t.isEditing()&&n&&(u.select({rowStart:r[0],rowEnd:n[0],colStart:r[1],colEnd:n[1]}),e.preventDefault())},E=function(e){a.blur();var n=u.hasFocus();if(!n)return;var r=u.hasSelection(),s=t.originCell==t.terminalCell,f=e.keyCode,c=i(e),h=e.shiftKey,p=f==9,d=f==13,v=f==27,m=f==46,g=f==8,y=f==37,b=f==38,w=f==39,E=f==40,S=f==36,x=f==35,T=t.editingCell,N=t.isEditing();if(p||d||v||b||E||y&&T&&l(T)==0||w&&T&&l(T)==T.innerText.length)e.preventDefault(),t.exitEditMode();if(!t.isEditing())if(c&&f==65)e.preventDefault(),h?u.deselect():u.select();else if(r){if(e.keyCode==93){t.originCell.focus();return}var C=!s&&(p||d),k=!h&&!C,L=!C,A=!h&&!C,O=t.getCoords(t.originCell),M=t.getCoords(t.terminalCell);if(v&&!N)u.deselect();else if(m||g)e.preventDefault(),u.hasSelection()&&u.clearSelection();else if(d||p){var _;p?_=o(s?u.getRows():u.getSelectedRows()):d&&(_=o(s?u.getCols():u.getSelectedCols()));var D=_.indexOf(s?t.originCell:T);if(s){var P=t.getCoords(_[(D+(h?-1:1)).mod(_.length)]);u.select({rowStart:P[0],rowEnd:P[0],colStart:P[1],colEnd:P[1]})}else C&&t.setEditMode(_[(D+(h?-1:1)).mod(_.length)])}else if(y||b||w||E||S||x){var H={x:0,y:0},B=L&&!A?M:O;switch(f){case 35:H.x=u.getColCount()-B[1]-1,c&&(H.y=u.getRowCount()-B[0]-1);break;case 36:H.x=-B[1],c&&(H.y=-B[0]);break;case 37:H.x=c?H.x=-B[1]:-1;break;case 38:H.y=c?H.y=-B[0]:-1;break;case 39:H.x=c?u.getColCount()-B[1]-1:1;break;case 40:H.y=c?u.getRowCount()-B[0]-1:1}if(O&&M){var j=function(e){return!(e[0]<0||e[0]>=u.getRowCount()||e[1]<0||e[1]>=u.getColCount())};if(k){var P=[O[0]+H.y,O[1]+H.x];j(P)&&(O=P)}if(A)M=O;else if(L){var P=[M[0]+H.y,M[1]+H.x];j(P)&&(M=P)}u.select({rowStart:O[0],rowEnd:M[0],colStart:O[1],colEnd:M[1]})}}}else if(p||d||S||x||y||b||w||E){var F=[0,0];x&&(F[1]=u.getColCount()-1,c&&(F[0]=u.getRowCount()-1)),u.select({rowStart:F[0],rowEnd:F[0],colStart:F[1],colEnd:F[1]})}},S=function(e){var n=u.hasFocus(),r=t.isEditing(),i=u.hasSelection();n&&i&&!r&&t.setEditMode(t.originCell)},x=function(e){var t=u.Selection.getCoords(e.target);v(u),d(u),u.fireEvent("change",{rowStart:t[0],rowEnd:t[0],colStart:t[1],colEnd:t[1]})};return $(document).on("mousedown",m).on("touchstart",m).on("contextmenu",g).on("dblclick",y).on("mouseup",b).on("touchend",b).on("keydown",E).on("keypress",S),t={originCell:null,terminalCell:null,editingCell:null,isEditing:function(){return this.editingCell!=null},setEditMode:function(e){var t=$(e);this.exitEditMode();if(!u.CellManager.isEditable(e))return;a.hide(),e.focus(),f(e),t.addClass("ediTable-cell-editing"),t.on("input",x),u.Selection.editingCell=e},exitEditMode:function(){this.isEditing()&&(this.editingCell.blur(),document.body.focus(),c(),$(this.editingCell).removeClass("ediTable-cell-editing").unbind("input",x),this.editingCell=null,a.show())},getCoords:function(e){if(!$.contains(u.table,e))return null;var t=$(e),n=t.closest("tr > td, tr > th")[0],r=t.closest("tr")[0],i=null;return n&&r&&$.contains(u.table,r)&&(i=[r.rowIndex,n.cellIndex]),i}},t}(),p(this),d(this),v(this),$(this.table).addClass("ediTable").focusin(function(e){if(!u.hasSelection()){var t=u.Selection.getCoords(e.target);if(!t)return;e.target.blur(),u.lastClicked=e.target,c(),u.select({rowStart:t[0],rowEnd:t[0],colStart:t[1],colEnd:t[1]})}}),this.lastClicked=null,this.table.addEventListener("dragstart",function(e){e.preventDefault()}),this.table.addEventListener("drop",function(e){e.preventDefault()}),document.addEventListener("copy",m),document.addEventListener("cut",g),document.addEventListener("paste",y)};y.prototype={addEventListener:function(e,t){this.events[e].push(t)},removeEventListener:function(e,t){var n=this.events[e].indexOf(t);n!=-1&&this.events[e].splice(n,1)},fireEvent:function(e,t){var n=this.events[e];if(n)for(var r=0;r<n.length;r++)n[r](t)},hasFocus:function(){var e=document.activeElement,t=this.lastClicked;return $(e).closest(this.table).length==1||$(t).closest(this.table).length==1||this.hasSelection()},getRowCount:function(){return this.table.rows.length},getColCount:function(){var e=0,t=this.table.rows;for(var n=0;n<t.length;n++)e=Math.max(e,t[n].cells.length);return e},setEditable:function(e,t){typeof e=="undefined"&&(e=!0),typeof t=="undefined"&&(t={}),typeof t.rowStart=="undefined"&&(t.rowStart=0),typeof t.rowEnd=="undefined"&&(t.rowEnd=this.getRowCount()-1),typeof t.colStart=="undefined"&&(t.colStart=0),typeof t.colEnd=="undefined"&&(t.colEnd=this.getColCount()-1);var n=this;t.table=this.table,t.func=function(t){n.CellManager.setEditable(t,e)},u(t)},isEditable:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=!0,n=this;return e.table=this.table,e.func=function(e){n.CellManager.isEditable(e)||(t=!1)},u(e),t},setHeader:function(e,t){typeof e=="undefined"&&(e=!0),typeof t=="undefined"&&(t={}),typeof t.rowStart=="undefined"&&(t.rowStart=0),typeof t.rowEnd=="undefined"&&(t.rowEnd=this.getRowCount()-1),typeof t.colStart=="undefined"&&(t.colStart=0),typeof t.colEnd=="undefined"&&(t.colEnd=this.getColCount()-1);var n=this;t.table=this.table,t.func=function(t){n.CellManager.setHeader(t,e)},u(t)},isHeader:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=!0,n=this;return e.table=this.table,e.func=function(e){n.CellManager.isHeader(e)||(t=!1)},u(e),t},select:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=this;this.deselect(),e.table=this.table,e.func=function(e){t.CellManager.select(e)};var n=u(e);this.Selection.originCell=n.first,this.Selection.terminalCell=n.last;var t=this;(function(){var n=t.table,r=t.table.rows,i=t.getRowCount(),s=t.getColCount(),o=t.CellManager;for(var u=0;u<i;u++){var a=t.table.rows[u];for(var f=0;f<s;f++){var l=a.cells[f],c=$(l);if(!o.isSelected(l))continue;c.toggleClass("ediTable-cell-selected-top",u==0||!o.isSelected(r[u-1].cells[f])),c.toggleClass("ediTable-cell-selected-bottom",u==i-1||!o.isSelected(r[u+1].cells[f])),c.toggleClass("ediTable-cell-selected-left",f==0||!o.isSelected(a.cells[f-1])),c.toggleClass("ediTable-cell-selected-right",f==s-1||!o.isSelected(a.cells[f+1]))}}})();if(this.options.scrollSelectionIntoView){var r=this.Selection.originCell,i=this.Selection.terminalCell;r!=i?g(i):g(r)}},deselect:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=this;e.table=this.table,e.func=function(e){t.CellManager.deselect(e)},u(e)},setRowValues:function(e,t){if(!a(e))throw new TypeError("values parameter must be 2D Array");typeof t=="undefined"&&(t={}),typeof t.rowStart=="undefined"&&(t.rowStart=0),typeof t.colStart=="undefined"&&(t.colStart=0),typeof t.silent=="undefined"&&(t.silent=!1);var n=t.rowStart+e.length,r=this.options.maxRows,i=this.getRowCount(),s=n-i;while((r==-1||i<r)&&s>0&&this.options.growRows)i=this.getRowCount(),s=n-i,this.insertRow(i);var o=t.colStart+e[0].length,u=this.options.maxCols,f=this.getColCount(),l=o-f;while((u==-1||f<u)&&l>0&&this.options.growCols)f=this.getColCount(),l=o-f,this.insertCol(f);var c=this.table.rows,n=0,o=0;for(var h=0;h<e.length&&h<c.length-t.rowStart;h++){var p=h+t.rowStart,m=c[p];for(var g=0;g<e[h].length&&g<m.cells.length-t.colStart;g++){var y=g+t.colStart,b=m.cells[y];this.CellManager.setValue(b,e[h][g]),o=Math.max(o,y)}n=Math.max(n,p)}v(this),d(this),t.silent||this.fireEvent("change",{rowStart:t.rowStart,rowEnd:n,colStart:t.colStart,colEnd:o})},setColValues:function(e,n){if(!a(e))throw new TypeError("values parameter must be 2D Array");typeof n=="undefined"&&(n={}),typeof n.rowStart=="undefined"&&(n.rowStart=0),typeof n.colStart=="undefined"&&(n.colStart=0),typeof n.silent=="undefined"&&(n.silent=!1),e=t(e),e.length==0&&(e[0]=[]),this.setRowValues(e,n)},clear:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1),typeof e.silent=="undefined"&&(e.silent=!1);var t=this;e.table=this.table,e.func=function(e){t.CellManager.clear(e)},u(e),v(this),e.silent||this.fireEvent("change",{rowStart:e.rowStart,rowEnd:e.rowEnd,colStart:e.colStart,colEnd:e.colEnd})},clearSelection:function(){var e=this.Selection,t=e.getCoords(e.originCell),n=e.getCoords(e.terminalCell);t&&n&&this.clear({rowStart:t[0],colStart:t[1],rowEnd:n[0],colEnd:n[1]})},isClear:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=!0;return e.table=this.table,e.func=function(e){ctx.CellManager.isClear(e)||(t=!1)},u(e),t},hasSelection:function(){return this.getSelectedRows().length>0},getSelectionBounds:function(){var e=this.Selection,t=e.getCoords(e.originCell),n=e.getCoords(e.terminalCell);return{origin:t,terminal:n}},getRow:function(e,t){typeof t=="undefined"&&(t={}),typeof t.colStart=="undefined"&&(t.colStart=0),typeof t.colEnd=="undefined"&&(t.colEnd=this.getColCount()-1);var n=[],r=this.table.rows[e];return i({arr:r.cells,start:t.colStart,end:t.colEnd,func:function(e){n.push(e)}}),n},getRows:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=this.table.rows,n=[],r=this;return i({arr:t,start:e.rowStart,end:e.rowEnd,func:function(t,i){n.push(r.getRow(i,e))}}),n},getSelectedRows:function(){var e=this;return this.getRows().map(function(t){return e.VectorManager.getSelection(t)}).filter(function(e){return e.length>0})},getRowValues:function(e){var t=this;return this.getRows(e).map(function(e){return t.VectorManager.getValues(e)})},getSelectedRowValues:function(){var e=this;return this.getSelectedRows().map(function(t){return e.VectorManager.getValues(t)})},getCol:function(e,t){typeof t=="undefined"&&(t={}),typeof t.rowStart=="undefined"&&(t.rowStart=0),typeof t.rowEnd=="undefined"&&(t.rowEnd=this.getRowCount()-1);var n=[];return t.table=this.table,t.colStart=e,t.colEnd=e,t.func=function(e){n.push(e)},u(t),n},getCols:function(e){return t(this.getRows(e))},getSelectedCols:function(){return t(this.getSelectedRows())},getColValues:function(e){return t(this.getRowValues(e))},getSelectedColValues:function(){return t(this.getSelectedRowValues())},canInsertRow:function(){return this.options.maxRows==-1||this.table.rows.length<this.options.maxRows},canInsertCol:function(){return this.options.maxCols==-1||this.table.rows[0].cells.length<this.options.maxCols},rowsCanGrow:function(){return this.options.growRows&&this.canInsertRow()},colsCanGrow:function(){var e=this.options;return e.growCols&&this.canInsertCol()},insertRow:function(e){if(!this.canInsertRow())return;var t=this.VectorManager,n=this.getCols(),r=this.table.insertRow(e),i=e>0?this.getRow(e-1):null,s=e<this.getRowCount()-1?this.getRow(e+1):null,o=(i?t.isEditable(i):!0)&&(s?t.isEditable(s):!0),u=(i?t.isHeader(i):!0)&&(s?t.isHeader(s):!0);for(var a=0;a<this.getColCount();a++){var f=r.insertCell(a),l=n[a],c=t.isEditable(l),h=t.isHeader(l);this.CellManager.setEditable(f,o||c),this.CellManager.setHeader(f,u||h)}},insertCol:function(e){if(!this.canInsertCol())return;var t=this.VectorManager,n=this.getRows(),r=e>0?this.getCol(e-1):null,i=e<this.getColCount()-1?this.getCol(e+1):null,s=(r?t.isEditable(r):!0)&&(i?t.isEditable(i):!0),o=(r?t.isHeader(r):!0)&&(i?t.isHeader(i):!0);for(var u=0;u<this.getRowCount();u++){var a=this.table.rows[u].insertCell(e),f=n[u],l=t.isEditable(f),c=t.isHeader(f);this.CellManager.setEditable(a,s||l),this.CellManager.setHeader(a,o||c)}},removeRow:function(e){var t=this.getSelectionBounds();this.table.deleteRow(e);if(t){var n=t.origin,r=t.terminal;if(n&&r){var i=n[1],s=n[0],o=r[1],u=r[0],a=Math.min(s,u),f=Math.max(s,u);if(e<=f&&e>=a){var l=this.getRowCount(),c=f>=l,h={colStart:i,colEnd:o};c?(h.rowStart=s-1>=0?s-1:0,h.rowEnd=u-1>=0?u-1:0):(h.rowStart=s,h.rowEnd=u),this.select(h)}}}},removeCol:function(e){var t=this.getSelectionBounds(),n=this.table.rows;for(var r=0;r<n.length;r++){var i=n[r];i.deleteCell(e)}if(t){var s=t.origin,o=t.terminal;if(s&&o){var u=s[1],a=s[0],f=o[1],l=o[0],c=Math.min(u,f),h=Math.max(u,f);if(e<=h&&e>=c){var p=this.getColCount(),d=h>=p,v={rowStart:a,rowEnd:l};d?(v.colStart=u-1>=0?u-1:0,v.colEnd=f-1>=0?f-1:0):(v.colStart=u,v.colEnd=f),this.select(v)}}}}},window.EdiTable=y})()
<commit_msg>Rebuilt for release.<commit_after>(function(){"use strict";function t(e){return e=e[0].map(function(t,n){return e.map(function(e){return e[n]})}),e}function n(e){return Array.apply(null,e)}function r(e){var t=e.rows,r=[];for(var i=0;i<t.length;i++)r[i]=n(t[i].cells);return r}function i(e){if(typeof e=="undefined"||typeof e.func=="undefined"||typeof e.arr=="undefined"||e.arr.length==0)return;typeof e.start=="undefined"&&(e.start=0),typeof e.end=="undefined"&&(e.end=e.arr.length-1),typeof e.dir=="undefined"&&(e.dir=e.end>e.start?1:-1),typeof e.funcContext=="undefined"&&(e.funcContext=null);var t=Math.min(e.start,e.end),n=Math.max(e.start,e.end),r=e.dir>0?t:n;while(r>=t&&r<=n)e.func.apply(e.funcContext,[e.arr[r],r]),r+=e.dir}function s(e){if(typeof e=="undefined"||typeof e.func=="undefined"||typeof e.arr=="undefined"||e.arr.length==0||!a(e.arr))return;typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=e.arr.length-1),typeof e.colEnd=="undefined"&&(e.colEnd=e.arr[0].length-1),typeof e.rowDir=="undefined"&&(e.rowDir=e.rowEnd>e.rowStart?1:-1),typeof e.colDir=="undefined"&&(e.colDir=e.colEnd>e.colStart?1:-1),typeof e.funcContext=="undefined"&&(e.funcContext=null),i({arr:e.arr,start:e.rowStart,end:e.rowEnd,dir:e.rowDir,func:function(t){i({arr:t,start:e.colStart,end:e.colEnd,dir:e.colDir,func:function(t){e.func.apply(e.funcContext,[t])}})}})}function o(e,t){var n=Object.prototype.toString,r="[object Array]",i=[],s=t&&e||e.slice(),o;if(!e.length)return i;o=s.pop();do n.call(o)===r?s.push.apply(s,o):i.push(o);while(s.length&&(o=s.pop())!==undefined);return i.reverse(),i}function u(e){typeof e.table!="undefined"&&(e.arr=r(e.table));var t=null,n=null,i=e.func,o=function(e,r){n=e,t||(t=e),i(e,r)};return e.func=o,s(e),{first:t,last:n}}function a(e){if(e instanceof Array){var t=e.length>0&&e[0]instanceof Array?e[0].length:0;for(var n=1;n<e.length;n++){var r=e[n];if(!(r instanceof Array))return!1;if(r.length!=t)return!1}return!0}return!1}function f(e){if(document.body.createTextRange){var t=document.body.createTextRange();t.moveToElementText(e),t.select()}else if(window.getSelection){var n=window.getSelection(),t=document.createRange();t.selectNodeContents(e),n.removeAllRanges(),n.addRange(t)}}function l(e){var t=0,n=null,r,i;if(window.getSelection)r=window.getSelection(),r.rangeCount&&(i=r.getRangeAt(0),i.commonAncestorContainer.parentNode==e?t=i.endOffset:i.commonAncestorContainer==e&&(t=i.endOffset));else if(document.selection&&document.selection.createRange){i=document.selection.createRange();if(i.parentElement()==e){var s=document.createElement("span");e.insertBefore(s,e.firstChild);var o=i.duplicate();o.moveToElementText(s),o.setEndPoint("EndToEnd",i),t=o.text.length}}return t}function c(){document.selection?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()}function h(e){var t=$("tr",e).toArray(),n=t.map(function(e){return e.cells.length}),r=Math.max.apply(null,n);for(var i=0;i<t.length;i++){var s=t[i],o=$("td",s).toArray(),u=$("th",s).toArray(),a=r-(o.length+u.length);if(a>0){var f=o.length==0?"th":"td",l=new Array(a);for(var c=0;c<a;c++)l[c]=document.createElement(f);$(s).append(l)}}}function p(e){var t=e.options;if(t.maxRows>-1)while(e.getRowCount()>t.maxRows)e.removeRow(e.getRowCount()-1);if(t.maxCols>-1)while(e.getColCount()>t.maxCols)e.removeCol(e.getColCount()-1);while(e.getRowCount()<t.minRows)e.insertRow(e.getRowCount());while(e.getColCount()<t.minCols)e.insertCol(e.getColCount())}function d(e){var t=e.options,n=e.VectorManager,r=n.isClear(e.getRow(e.getRowCount()-1));!r&&e.rowsCanGrow()&&e.insertRow(e.getRowCount());var i=n.isClear(e.getCol(e.getColCount()-1));!i&&e.colsCanGrow()&&e.insertCol(e.getColCount())}function v(e){var t=e.options,n=e.VectorManager;if(t.shrinkRows)if(t.rowsAllowMiddleShrink){var r=0;while(e.getRowCount()>t.minRows){var i=e.getRowCount()-(t.growRows?2:1),s=i-r;s>=0&&n.isClear(e.getRow(s))?e.removeRow(s):r++;if(s==0)break}}else while(e.getRowCount()>t.minRows){var s=e.getRowCount()-(t.growRows?2:1);if(!(s>=0&&n.isClear(e.getRow(s))))break;e.removeRow(s)}if(t.shrinkCols)if(t.colsAllowMiddleShrink){var r=0;while(e.getColCount()>t.minCols){var o=e.getColCount()-(t.growCols?2:1),u=o-r;u>=0&&n.isClear(e.getCol(u))?e.removeCol(u):r++;if(u==0)break}}else while(e.getColCount()>t.minCols){var u=e.getColCount()-(t.growCols?2:1);if(!(u>=0&&n.isClear(e.getCol(u))))break;e.removeCol(u)}}function m(e){typeof jQuery=="function"&&e instanceof jQuery&&(e=e[0]);var t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=$(window).height()&&t.right<=$(window).width()}function g(e){m(e)||e.scrollIntoView()}var e=function(){var e=navigator.appVersion,t=navigator.userAgent,n="unknown",r="unknown",i=[{s:"Windows 3.11",r:/Win16/},{s:"Windows 95",r:/(Windows 95|Win95|Windows_95)/},{s:"Windows ME",r:/(Win 9x 4.90|Windows ME)/},{s:"Windows 98",r:/(Windows 98|Win98)/},{s:"Windows CE",r:/Windows CE/},{s:"Windows 2000",r:/(Windows NT 5.0|Windows 2000)/},{s:"Windows XP",r:/(Windows NT 5.1|Windows XP)/},{s:"Windows Server 2003",r:/Windows NT 5.2/},{s:"Windows Vista",r:/Windows NT 6.0/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows NT 4.0",r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},{s:"Windows ME",r:/Windows ME/},{s:"Android",r:/Android/},{s:"Open BSD",r:/OpenBSD/},{s:"Sun OS",r:/SunOS/},{s:"Linux",r:/(Linux|X11)/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:"QNX",r:/QNX/},{s:"UNIX",r:/UNIX/},{s:"BeOS",r:/BeOS/},{s:"OS/2",r:/OS\/2/},{s:"Search Bot",r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}];for(var s in i){var o=i[s];if(o.r.test(t)){r=o.s;break}}/Windows/.test(r)&&(n=/Windows (.*)/.exec(r)[1],r="Windows");switch(r){case"Mac OS X":n=/Mac OS X (10[\.\_\d]+)/.exec(t)[1];break;case"Android":n=/Android ([\.\_\d]+)/.exec(t)[1];break;case"iOS":n=/OS (\d+)_(\d+)_?(\d+)?/.exec(e),n=n[1]+"."+n[2]+"."+(n[3]|0)}return{name:r,versionString:n}};Number.prototype.mod=function(e){return(this%e+e)%e};var y=function(n,r){function i(e){typeof e.minRows=="undefined"&&(e.minRows=1),typeof e.minCols=="undefined"&&(e.minCols=1),typeof e.maxRows=="undefined"&&(e.maxRows=-1),typeof e.maxCols=="undefined"&&(e.maxCols=-1),typeof e.growRows=="undefined"&&(e.growRows=!1),typeof e.growCols=="undefined"&&(e.growCols=!1),typeof e.shrinkRows=="undefined"&&(e.shrinkRows=!1),typeof e.shrinkCols=="undefined"&&(e.shrinkCols=!1),typeof e.rowsAllowMiddleShrink=="undefined"&&(e.rowsAllowMiddleShrink=!1),typeof e.colsAllowMiddleShrink=="undefined"&&(e.colsAllowMiddleShrink=!1),typeof e.copyAsHTML=="undefined"&&(e.copyAsHTML=!0),typeof e.pasteAsHTML=="undefined"&&(e.pasteAsHTML=!1),typeof e.rotateWidePaste=="undefined"&&(e.rotateWidePaste=!1),typeof e.scrollSelectionIntoView=="undefined"&&(e.scrollSelectionIntoView=!0),e.minRows<0&&(e.minRows=0),e.minCols<0&&(e.minCols=0),e.maxRows!=-1&&e.minRows>e.maxRows&&(e.maxRows=e.minRows),e.maxCols!=-1&&e.minCols>e.maxCols&&(e.maxCols=e.minCols)}function s(e){var t,n=a.css("display")=="none";return a.hide(),t=document.elementFromPoint(e.clientX,e.clientY),n||a.show(),t}function m(e){if(!u.hasFocus()||u.Selection.isEditing())return;if(u.options.copyAsHTML){var t=u.getSelectedRows(),n=document.createElement("table");for(var r=0;r<t.length;r++){var i=t[r],s=document.createElement("tr");for(var o=0;o<i.length;o++){var a=i[o];s.appendChild($(a).clone()[0])}n.appendChild(s)}e.clipboardData.setData("text/html",n.outerHTML)}var f="",l=u.getSelectedRowValues();for(var r=0;r<l.length;r++){var c=l[r];for(var o=0;o<c.length;o++){var h=c[o];f+=h,o!=c.length-1&&(f+="	")}r!=l.length-1&&(f+="\n")}e.clipboardData.setData("text/plain",f),e.preventDefault()}function g(e){u.hasFocus()&&!u.Selection.isEditing()&&(m(e),u.clearSelection())}function y(e){if(!u.hasFocus())return;if(!u.Selection.isEditing()){e.preventDefault();var n,r,i=[],s=0,o=e.clipboardData.getData("text/html"),a=e.clipboardData.getData("text/plain"),f=u.getSelectedRows();if(o&&o!=""){if(window.DOMParser){var l=new DOMParser;n=l.parseFromString(o,"text/html")}else n=document.implementation.createHTMLDocument(),n.write(o);var c=n.getElementsByTagName("table");r=c.length>0?c[0]:null}if(r){var h=r.rows;for(var p=0;p<h.length;p++){var d=h[p],v=d.cells;v.length>s&&(s=v.length),i[p]=[];for(var m=0;m<v.length;m++){var g=v[m];i[p][m]=g.innerText}}}else if(a){var h=a.split("\n");for(var p=0;p<h.length;p++){var d=h[p],y=d.split("	");y.length>s&&(s=y.length),i[p]=[];for(var m=0;m<y.length;m++){var b=y[m];i[p][m]=b}}}if(i.length>0&&f.length>0){var w=u.Selection.getCoords(f[0][0]);if(u.options.rotateWidePaste){var E=u.options.maxCols==-1&&s+w[0]>u.getColCount()||u.options.maxCols>-1&&s+w[0]>u.options.maxCols,S=s>i.length,x=u.colsCanGrow();!x&&S&&E&&(i=t(i))}u.setRowValues(i,{rowStart:w[0],colStart:w[1]})}}else if(!u.options.pasteAsHTML){e.preventDefault();var b=e.clipboardData.getData("text/plain");document.execCommand("insertHTML",!1,b)}}var u=this;this.table=n,this.options=r||{},this.events={change:[]},h(this.table),i(this.options);var a=$("<div contenteditable></div>").css({cursor:"default",display:"table-row",opacity:"0",position:"absolute","z-index":"1",top:"0",bottom:"0",width:"100%"}).text("ediTable");$(this.table).css({position:"relative"}).append(a),this.CellManager={setEditable:function(e,t){typeof t=="undefined"&&(t=!0),e.contentEditable=t},isEditable:function(e){return e.isContentEditable||e.contentEditable=="true"},setHeader:function(e,t){typeof t=="undefined"&&(t=!0);if(t==this.isHeader(e))return;var n=t?"th":"td",r=e,i=$(r).contents().detach(),s=document.createElement(n);$.each(r.attributes,function(e){$(s).attr(r.attributes[e].name,r.attributes[e].value)}),$(s).append(i),$(r).replaceWith(s)},isHeader:function(e){return e.tagName.toLowerCase()=="th"},select:function(e){$(e).addClass("ediTable-cell-selected")},deselect:function(e){$(e).removeClass("ediTable-cell-selected").removeClass("ediTable-cell-selected-left").removeClass("ediTable-cell-selected-right").removeClass("ediTable-cell-selected-top").removeClass("ediTable-cell-selected-bottom")},isSelected:function(e){return $(e).hasClass("ediTable-cell-selected")},getValue:function(e){return e.innerText},setValue:function(e,t){if(!this.isEditable(e))return;u.options.pasteAsHTML?$(e).html(t):$(e).text(t)},clear:function(e){this.setValue(e,"")},isClear:function(e){return e.innerHTML==""}},this.VectorManager={getSelection:function(e){return e.filter(function(e){return u.CellManager.isSelected(e)})},getValues:function(e){return e.map(function(e){return u.CellManager.getValue(e)})},isHeader:function(e){for(var t=0;t<e.length;t++)if(!u.CellManager.isHeader(e[t]))return!1;return!0},isEditable:function(e){for(var t=0;t<e.length;t++)if(!u.CellManager.isEditable(e[t]))return!1;return!0},isClear:function(e){for(var t=0;t<e.length;t++)if(!u.CellManager.isClear(e[t]))return!1;return!0}},this.Selection=function(){var t,n=$(u.table),r=[],i=function(e){var t=e.name.indexOf("Mac")>-1;return t?function(e){return e.metaKey}:function(e){return e.ctrlKey}}(e()),h,p=function(){var e=(new Date).getTime(),t=e-h;return h=(new Date).getTime(),t<600&&t>0},m=function(e){var n=s(e),i=t.getCoords(n);u.lastClicked=n;var o=u.hasFocus();if(!i||!o)u.deselect(),t.exitEditMode();if(!o||!$.contains(u.table,n))return;if(e.type=="touchstart"&&p()){y(e);return}var a=e.which==3;if(i){var f=!a||a&&!u.hasSelection();if(!u.hasSelection()||!e.shiftKey&&u.hasSelection())r=i;t.isEditing()?n!=t.editingCell&&(t.exitEditMode(),f&&u.select({rowStart:r[0],rowEnd:i[0],colStart:r[1],colEnd:i[1]}),e.preventDefault()):f&&u.select({rowStart:r[0],rowEnd:i[0],colStart:r[1],colEnd:i[1]}),f&&$(document).on("mousemove",w).on("touchmove",w)}},g=function(e){!t.isEditing()&&$.contains(u.table,e.target)&&f(a[0])},y=function(e){if(!u.hasFocus())return;var n=s(e),r=t.getCoords(n);r&&t.setEditMode(n)},b=function(e){$(document).unbind("mousemove",w).unbind("touchmove",w)},w=function(e){var n=t.getCoords(s(e));if(e.changedTouches){var i=e.changedTouches,o,a;if(i.length>0){var f=i.item(0);o=f.clientX,a=f.clientY,n=t.getCoords(document.elementFromPoint(o,a))}}!t.isEditing()&&n&&(u.select({rowStart:r[0],rowEnd:n[0],colStart:r[1],colEnd:n[1]}),e.preventDefault())},E=function(e){a.blur();var n=u.hasFocus();if(!n)return;var r=u.hasSelection(),s=t.originCell==t.terminalCell,f=e.keyCode,c=i(e),h=e.shiftKey,p=f==9,d=f==13,v=f==27,m=f==46,g=f==8,y=f==37,b=f==38,w=f==39,E=f==40,S=f==36,x=f==35,T=t.editingCell,N=t.isEditing();if(p||d||v||b||E||y&&T&&l(T)==0||w&&T&&l(T)==T.innerText.length)e.preventDefault(),t.exitEditMode();if(!t.isEditing())if(c&&f==65)e.preventDefault(),h?u.deselect():u.select();else if(r){if(e.keyCode==93){t.originCell.focus();return}var C=!s&&(p||d),k=!h&&!C,L=!C,A=!h&&!C,O=t.getCoords(t.originCell),M=t.getCoords(t.terminalCell);if(v&&!N)u.deselect();else if(m||g)e.preventDefault(),u.hasSelection()&&u.clearSelection();else if(d||p){var _;p?_=o(s?u.getRows():u.getSelectedRows()):d&&(_=o(s?u.getCols():u.getSelectedCols()));var D=_.indexOf(s?t.originCell:T);if(s){var P=t.getCoords(_[(D+(h?-1:1)).mod(_.length)]);u.select({rowStart:P[0],rowEnd:P[0],colStart:P[1],colEnd:P[1]})}else C&&t.setEditMode(_[(D+(h?-1:1)).mod(_.length)])}else if(y||b||w||E||S||x){var H={x:0,y:0},B=L&&!A?M:O;switch(f){case 35:H.x=u.getColCount()-B[1]-1,c&&(H.y=u.getRowCount()-B[0]-1);break;case 36:H.x=-B[1],c&&(H.y=-B[0]);break;case 37:H.x=c?H.x=-B[1]:-1;break;case 38:H.y=c?H.y=-B[0]:-1;break;case 39:H.x=c?u.getColCount()-B[1]-1:1;break;case 40:H.y=c?u.getRowCount()-B[0]-1:1}if(O&&M){var j=function(e){return!(e[0]<0||e[0]>=u.getRowCount()||e[1]<0||e[1]>=u.getColCount())};if(k){var P=[O[0]+H.y,O[1]+H.x];j(P)&&(O=P)}if(A)M=O;else if(L){var P=[M[0]+H.y,M[1]+H.x];j(P)&&(M=P)}u.select({rowStart:O[0],rowEnd:M[0],colStart:O[1],colEnd:M[1]})}}}else if(p||d||S||x||y||b||w||E){var F=[0,0];x&&(F[1]=u.getColCount()-1,c&&(F[0]=u.getRowCount()-1)),u.select({rowStart:F[0],rowEnd:F[0],colStart:F[1],colEnd:F[1]})}},S=function(e){var n=[37,38,39,40];if(e.ctrlKey||n.indexOf(e.keyCode)!=-1)return;var r=u.hasFocus(),i=t.isEditing(),s=u.hasSelection();r&&s&&!i&&t.setEditMode(t.originCell)},x=function(e){var t=u.Selection.getCoords(e.target);v(u),d(u),u.fireEvent("change",{rowStart:t[0],rowEnd:t[0],colStart:t[1],colEnd:t[1]})};return $(document).on("mousedown",m).on("touchstart",m).on("contextmenu",g).on("dblclick",y).on("mouseup",b).on("touchend",b).on("keydown",E).on("keypress",S),t={originCell:null,terminalCell:null,editingCell:null,isEditing:function(){return this.editingCell!=null},setEditMode:function(e){var t=$(e);this.exitEditMode();if(!u.CellManager.isEditable(e))return;a.hide(),e.focus(),f(e),t.addClass("ediTable-cell-editing"),t.on("input",x),u.Selection.editingCell=e},exitEditMode:function(){this.isEditing()&&(this.editingCell.blur(),document.body.focus(),c(),$(this.editingCell).removeClass("ediTable-cell-editing").unbind("input",x),this.editingCell=null,a.show())},getCoords:function(e){if(!$.contains(u.table,e))return null;var t=$(e),n=t.closest("tr > td, tr > th")[0],r=t.closest("tr")[0],i=null;return n&&r&&$.contains(u.table,r)&&(i=[r.rowIndex,n.cellIndex]),i}},t}(),p(this),d(this),v(this),$(this.table).addClass("ediTable").focusin(function(e){if(!u.hasSelection()){var t=u.Selection.getCoords(e.target);if(!t)return;e.target.blur(),u.lastClicked=e.target,c(),u.select({rowStart:t[0],rowEnd:t[0],colStart:t[1],colEnd:t[1]})}}),this.lastClicked=null,this.table.addEventListener("dragstart",function(e){e.preventDefault()}),this.table.addEventListener("drop",function(e){e.preventDefault()}),document.addEventListener("copy",m),document.addEventListener("cut",g),document.addEventListener("paste",y)};y.prototype={addEventListener:function(e,t){this.events[e].push(t)},removeEventListener:function(e,t){var n=this.events[e].indexOf(t);n!=-1&&this.events[e].splice(n,1)},fireEvent:function(e,t){var n=this.events[e];if(n)for(var r=0;r<n.length;r++)n[r](t)},hasFocus:function(){var e=document.activeElement,t=this.lastClicked;return $(e).closest(this.table).length==1||$(t).closest(this.table).length==1||this.hasSelection()},getRowCount:function(){return this.table.rows.length},getColCount:function(){var e=0,t=this.table.rows;for(var n=0;n<t.length;n++)e=Math.max(e,t[n].cells.length);return e},setEditable:function(e,t){typeof e=="undefined"&&(e=!0),typeof t=="undefined"&&(t={}),typeof t.rowStart=="undefined"&&(t.rowStart=0),typeof t.rowEnd=="undefined"&&(t.rowEnd=this.getRowCount()-1),typeof t.colStart=="undefined"&&(t.colStart=0),typeof t.colEnd=="undefined"&&(t.colEnd=this.getColCount()-1);var n=this;t.table=this.table,t.func=function(t){n.CellManager.setEditable(t,e)},u(t)},isEditable:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=!0,n=this;return e.table=this.table,e.func=function(e){n.CellManager.isEditable(e)||(t=!1)},u(e),t},setHeader:function(e,t){typeof e=="undefined"&&(e=!0),typeof t=="undefined"&&(t={}),typeof t.rowStart=="undefined"&&(t.rowStart=0),typeof t.rowEnd=="undefined"&&(t.rowEnd=this.getRowCount()-1),typeof t.colStart=="undefined"&&(t.colStart=0),typeof t.colEnd=="undefined"&&(t.colEnd=this.getColCount()-1);var n=this;t.table=this.table,t.func=function(t){n.CellManager.setHeader(t,e)},u(t)},isHeader:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=!0,n=this;return e.table=this.table,e.func=function(e){n.CellManager.isHeader(e)||(t=!1)},u(e),t},select:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=this;this.deselect(),e.table=this.table,e.func=function(e){t.CellManager.select(e)};var n=u(e);this.Selection.originCell=n.first,this.Selection.terminalCell=n.last;var t=this;(function(){var n=t.table,r=t.table.rows,i=t.getRowCount(),s=t.getColCount(),o=t.CellManager;for(var u=0;u<i;u++){var a=t.table.rows[u];for(var f=0;f<s;f++){var l=a.cells[f],c=$(l);if(!o.isSelected(l))continue;c.toggleClass("ediTable-cell-selected-top",u==0||!o.isSelected(r[u-1].cells[f])),c.toggleClass("ediTable-cell-selected-bottom",u==i-1||!o.isSelected(r[u+1].cells[f])),c.toggleClass("ediTable-cell-selected-left",f==0||!o.isSelected(a.cells[f-1])),c.toggleClass("ediTable-cell-selected-right",f==s-1||!o.isSelected(a.cells[f+1]))}}})();if(this.options.scrollSelectionIntoView){var r=this.Selection.originCell,i=this.Selection.terminalCell;r!=i?g(i):g(r)}},deselect:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=this;e.table=this.table,e.func=function(e){t.CellManager.deselect(e)},u(e)},setRowValues:function(e,t){if(!a(e))throw new TypeError("values parameter must be 2D Array");typeof t=="undefined"&&(t={}),typeof t.rowStart=="undefined"&&(t.rowStart=0),typeof t.colStart=="undefined"&&(t.colStart=0),typeof t.silent=="undefined"&&(t.silent=!1);var n=t.rowStart+e.length,r=this.options.maxRows,i=this.getRowCount(),s=n-i;while((r==-1||i<r)&&s>0&&this.options.growRows)i=this.getRowCount(),s=n-i,this.insertRow(i);var o=t.colStart+e[0].length,u=this.options.maxCols,f=this.getColCount(),l=o-f;while((u==-1||f<u)&&l>0&&this.options.growCols)f=this.getColCount(),l=o-f,this.insertCol(f);var c=this.table.rows,n=0,o=0;for(var h=0;h<e.length&&h<c.length-t.rowStart;h++){var p=h+t.rowStart,m=c[p];for(var g=0;g<e[h].length&&g<m.cells.length-t.colStart;g++){var y=g+t.colStart,b=m.cells[y];this.CellManager.setValue(b,e[h][g]),o=Math.max(o,y)}n=Math.max(n,p)}v(this),d(this),t.silent||this.fireEvent("change",{rowStart:t.rowStart,rowEnd:n,colStart:t.colStart,colEnd:o})},setColValues:function(e,n){if(!a(e))throw new TypeError("values parameter must be 2D Array");typeof n=="undefined"&&(n={}),typeof n.rowStart=="undefined"&&(n.rowStart=0),typeof n.colStart=="undefined"&&(n.colStart=0),typeof n.silent=="undefined"&&(n.silent=!1),e=t(e),e.length==0&&(e[0]=[]),this.setRowValues(e,n)},clear:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1),typeof e.silent=="undefined"&&(e.silent=!1);var t=this;e.table=this.table,e.func=function(e){t.CellManager.clear(e)},u(e),v(this),e.silent||this.fireEvent("change",{rowStart:e.rowStart,rowEnd:e.rowEnd,colStart:e.colStart,colEnd:e.colEnd})},clearSelection:function(){var e=this.Selection,t=e.getCoords(e.originCell),n=e.getCoords(e.terminalCell);t&&n&&this.clear({rowStart:t[0],colStart:t[1],rowEnd:n[0],colEnd:n[1]})},isClear:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=!0;return e.table=this.table,e.func=function(e){ctx.CellManager.isClear(e)||(t=!1)},u(e),t},hasSelection:function(){return this.getSelectedRows().length>0},getSelectionBounds:function(){var e=this.Selection,t=e.getCoords(e.originCell),n=e.getCoords(e.terminalCell);return{origin:t,terminal:n}},getRow:function(e,t){typeof t=="undefined"&&(t={}),typeof t.colStart=="undefined"&&(t.colStart=0),typeof t.colEnd=="undefined"&&(t.colEnd=this.getColCount()-1);var n=[],r=this.table.rows[e];return i({arr:r.cells,start:t.colStart,end:t.colEnd,func:function(e){n.push(e)}}),n},getRows:function(e){typeof e=="undefined"&&(e={}),typeof e.rowStart=="undefined"&&(e.rowStart=0),typeof e.rowEnd=="undefined"&&(e.rowEnd=this.getRowCount()-1),typeof e.colStart=="undefined"&&(e.colStart=0),typeof e.colEnd=="undefined"&&(e.colEnd=this.getColCount()-1);var t=this.table.rows,n=[],r=this;return i({arr:t,start:e.rowStart,end:e.rowEnd,func:function(t,i){n.push(r.getRow(i,e))}}),n},getSelectedRows:function(){var e=this;return this.getRows().map(function(t){return e.VectorManager.getSelection(t)}).filter(function(e){return e.length>0})},getRowValues:function(e){var t=this;return this.getRows(e).map(function(e){return t.VectorManager.getValues(e)})},getSelectedRowValues:function(){var e=this;return this.getSelectedRows().map(function(t){return e.VectorManager.getValues(t)})},getCol:function(e,t){typeof t=="undefined"&&(t={}),typeof t.rowStart=="undefined"&&(t.rowStart=0),typeof t.rowEnd=="undefined"&&(t.rowEnd=this.getRowCount()-1);var n=[];return t.table=this.table,t.colStart=e,t.colEnd=e,t.func=function(e){n.push(e)},u(t),n},getCols:function(e){return t(this.getRows(e))},getSelectedCols:function(){return t(this.getSelectedRows())},getColValues:function(e){return t(this.getRowValues(e))},getSelectedColValues:function(){return t(this.getSelectedRowValues())},canInsertRow:function(){return this.options.maxRows==-1||this.table.rows.length<this.options.maxRows},canInsertCol:function(){return this.options.maxCols==-1||this.table.rows[0].cells.length<this.options.maxCols},rowsCanGrow:function(){return this.options.growRows&&this.canInsertRow()},colsCanGrow:function(){var e=this.options;return e.growCols&&this.canInsertCol()},insertRow:function(e){if(!this.canInsertRow())return;var t=this.VectorManager,n=this.getCols(),r=this.table.insertRow(e),i=e>0?this.getRow(e-1):null,s=e<this.getRowCount()-1?this.getRow(e+1):null,o=(i?t.isEditable(i):!0)&&(s?t.isEditable(s):!0),u=(i?t.isHeader(i):!0)&&(s?t.isHeader(s):!0);for(var a=0;a<this.getColCount();a++){var f=r.insertCell(a),l=n[a],c=t.isEditable(l),h=t.isHeader(l);this.CellManager.setEditable(f,o||c),this.CellManager.setHeader(f,u||h)}},insertCol:function(e){if(!this.canInsertCol())return;var t=this.VectorManager,n=this.getRows(),r=e>0?this.getCol(e-1):null,i=e<this.getColCount()-1?this.getCol(e+1):null,s=(r?t.isEditable(r):!0)&&(i?t.isEditable(i):!0),o=(r?t.isHeader(r):!0)&&(i?t.isHeader(i):!0);for(var u=0;u<this.getRowCount();u++){var a=this.table.rows[u].insertCell(e),f=n[u],l=t.isEditable(f),c=t.isHeader(f);this.CellManager.setEditable(a,s||l),this.CellManager.setHeader(a,o||c)}},removeRow:function(e){var t=this.getSelectionBounds();this.table.deleteRow(e);if(t){var n=t.origin,r=t.terminal;if(n&&r){var i=n[1],s=n[0],o=r[1],u=r[0],a=Math.min(s,u),f=Math.max(s,u);if(e<=f&&e>=a){var l=this.getRowCount(),c=f>=l,h={colStart:i,colEnd:o};c?(h.rowStart=s-1>=0?s-1:0,h.rowEnd=u-1>=0?u-1:0):(h.rowStart=s,h.rowEnd=u),this.select(h)}}}},removeCol:function(e){var t=this.getSelectionBounds(),n=this.table.rows;for(var r=0;r<n.length;r++){var i=n[r];i.deleteCell(e)}if(t){var s=t.origin,o=t.terminal;if(s&&o){var u=s[1],a=s[0],f=o[1],l=o[0],c=Math.min(u,f),h=Math.max(u,f);if(e<=h&&e>=c){var p=this.getColCount(),d=h>=p,v={rowStart:a,rowEnd:l};d?(v.colStart=u-1>=0?u-1:0,v.colEnd=f-1>=0?f-1:0):(v.colStart=u,v.colEnd=f),this.select(v)}}}}},window.EdiTable=y})()

{'fraction_non_alphanumeric': 0.2820032763866136, 'fraction_numerical': 0.01780560106092519, 'mean_word_length': 14.229284229284229, 'pattern_counts': {'":': 12, '<': 95, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6112820', 'n_tokens_mistral': 22148, 'n_tokens_neox': 21849, 'n_words': 883}