blob: 8af53261a61ba82f27ea11f9ba5996cc9c244f15 [file] [log] [blame]
define(function(require){var t=require("jquery"),e=require("numeral"),o={extension:{},plugins:{},helper:{}};return function($,o,i){"use strict";function n(){this.refCounter=0,this.init()}function s(){function t(){var t=this;t.registerTimeout("enableObserveChanges",function(){t.updateSettings({observeChanges:!0})},0)}function e(t){return function(e,o){return e[1]===o[1]?0:null===e[1]?1:null===o[1]?-1:e[1]<o[1]?t?-1:1:e[1]>o[1]?t?1:-1:0}}function o(t){return function(e,o){if(e[1]===o[1])return 0;if(null===e[1])return 1;if(null===o[1])return-1;var i=new Date(e[1]),n=new Date(o[1]);return n>i?t?-1:1:i>n?t?1:-1:0}}function i(t){return"undefined"!=typeof t.sortColumn}var n=this;this.init=function(e){var o,i,s=this,l=s.getSettings().columnSorting;if(s.sortingEnabled=!!l,s.sortingEnabled){s.sortIndex=[];var c=r.call(s);"undefined"!=typeof c?(o=c.sortColumn,i=c.sortOrder):(o=l.column,i=l.sortOrder),n.sortByColumn.call(s,o,i),s.sort=function(){var t=Array.prototype.slice.call(arguments);return n.sortByColumn.apply(s,t)},"undefined"==typeof s.getSettings().observeChanges&&t.call(s),"afterInit"==e&&(a.call(s),s.addHook("afterCreateRow",n.afterCreateRow),s.addHook("afterRemoveRow",n.afterRemoveRow),s.addHook("afterLoadData",n.init))}else delete s.sort,s.removeHook("afterCreateRow",n.afterCreateRow),s.removeHook("afterRemoveRow",n.afterRemoveRow),s.removeHook("afterLoadData",n.init)},this.setSortingColumn=function(t,e){var o=this;return"undefined"==typeof t?(delete o.sortColumn,void delete o.sortOrder):(o.sortColumn===t&&"undefined"==typeof e?o.sortOrder=!o.sortOrder:o.sortOrder="undefined"!=typeof e?e:!0,void(o.sortColumn=t))},this.sortByColumn=function(t,e){var o=this;n.setSortingColumn.call(o,t,e),"undefined"!=typeof o.sortColumn&&(o.PluginHooks.run("beforeColumnSort",o.sortColumn,o.sortOrder),n.sort.call(o),o.render(),s.call(o),o.PluginHooks.run("afterColumnSort",o.sortColumn,o.sortOrder))};var s=function(){var t=this,e={};"undefined"!=typeof t.sortColumn&&(e.sortColumn=t.sortColumn),"undefined"!=typeof t.sortOrder&&(e.sortOrder=t.sortOrder),(e.hasOwnProperty("sortColumn")||e.hasOwnProperty("sortOrder"))&&t.PluginHooks.run("persistentStateSave","columnSorting",e)},r=function(){var t=this,e={};return t.PluginHooks.run("persistentStateLoad","columnSorting",e),e.value},a=function(){function t(){var t=o.view.TBODY.querySelector("tr").querySelectorAll("th");return t.length}function e(e){var i=o.view.wt.wtDom.closest(e,"TH");return o.view.wt.wtDom.index(i)-t()}var o=this;o.rootElement.on("click.handsontable",".columnSorting",function(t){if(o.view.wt.wtDom.hasClass(t.target,"columnSorting")){var i=e(t.target);n.sortByColumn.call(o,i)}})};this.sort=function(){var t=this;if("undefined"!=typeof t.sortOrder){t.sortingEnabled=!1,t.sortIndex.length=0;for(var i=this.colOffset(),n=0,s=this.countRows()-t.getSettings().minSpareRows;s>n;n++)this.sortIndex.push([n,t.getDataAtCell(n,this.sortColumn+i)]);var r,a=t.getCellMeta(0,t.sortColumn);switch(a.type){case"date":r=o;break;default:r=e}this.sortIndex.sort(r(t.sortOrder));for(var n=this.sortIndex.length;n<t.countRows();n++)this.sortIndex.push([n,t.getDataAtCell(n,this.sortColumn+i)]);t.sortingEnabled=!0}},this.translateRow=function(t){var e=this;return e.sortingEnabled&&e.sortIndex&&e.sortIndex.length&&e.sortIndex[t]?e.sortIndex[t][0]:t},this.onBeforeGetSet=function(t){var e=this;t.row=n.translateRow.call(e,t.row)},this.untranslateRow=function(t){var e=this;if(e.sortingEnabled&&e.sortIndex&&e.sortIndex.length)for(var o=0;o<e.sortIndex.length;o++)if(e.sortIndex[o][0]==t)return o},this.getColHeader=function(t,e){this.getSettings().columnSorting&&this.view.wt.wtDom.addClass(e.querySelector(".colHeader"),"columnSorting")},this.afterCreateRow=function(t,e){var o=this;if(i(o)){for(var n=0;n<o.sortIndex.length;n++)o.sortIndex[n][0]>=t&&(o.sortIndex[n][0]+=e);for(var n=0;e>n;n++)o.sortIndex.splice(t+n,0,[t+n,o.getData()[t+n][o.sortColumn+o.colOffset()]]);s.call(o)}},this.afterRemoveRow=function(t,e){var o=this;if(i(o)){var r=n.translateRow.call(o,t);o.sortIndex.splice(t,e);for(var a=0;a<o.sortIndex.length;a++)o.sortIndex[a][0]>r&&(o.sortIndex[a][0]-=e);s.call(o)}},this.afterChangeSort=function(t){var e=this,o=!1,i={};if(t){for(var s=0;s<t.length;s++)if(t[s][1]==e.sortColumn){o=!0,i.row=n.translateRow.call(e,t[s][0]),i.col=t[s][1];break}o&&setTimeout(function(){n.sort.call(e),e.render(),e.selectCell(n.untranslateRow.call(e,i.row),i.col)},0)}}}function r(){var t,e,o,i,n,s=document.createElement("DIV"),r=s.style;s.className="ghost",r.position="absolute",r.top="25px",r.left=0,r.width="10px",r.height="10px",r.backgroundColor="#CCC",r.opacity=.7;var a=function(){var t=this;t.PluginHooks.run("persistentStateSave","manualColumnPositions",t.manualColumnPositions)},l=function(){var t=this,e={};return t.PluginHooks.run("persistentStateLoad","manualColumnPositions",e),e.value},c=function(){var l=this;l.rootElement.on("mousemove.manualColumnMove",function(e){t&&(r.left=n+e.pageX-i+6+"px","none"===r.display&&(r.display="block"))}),l.rootElement.on("mouseup.manualColumnMove",function(){t&&(o>e&&o--,l.getSettings().rowHeaders&&(e--,o--),l.manualColumnPositions.splice(o,0,l.manualColumnPositions.splice(e,1)[0]),$(".manualColumnMover.active").removeClass("active"),t=!1,l.forceFullRender=!0,l.view.render(),r.display="none",a.call(l),l.PluginHooks.run("afterColumnMove",e,o))}),l.rootElement.on("mousedown.manualColumnMove",".manualColumnMover",function(a){var c=a.currentTarget,h=l.view.wt.wtDom.closest(c,"TH");e=l.view.wt.wtDom.index(h)+l.colOffset(),o=e,t=!0,i=a.pageX;var u=l.$table[0];u.parentNode.appendChild(s),r.width=l.view.wt.wtDom.outerWidth(h)+"px",r.height=l.view.wt.wtDom.outerHeight(u)+"px",n=parseInt(l.view.wt.wtDom.offset(h).left-l.view.wt.wtDom.offset(u).left,10),r.left=n+6+"px"}),l.rootElement.on("mouseenter.manualColumnMove","td, th",function(){if(t){var e=l.view.THEAD.querySelector(".manualColumnMover.active");e&&l.view.wt.wtDom.removeClass(e,"active"),o=l.view.wt.wtDom.index(this)+l.colOffset();var i=l.view.THEAD.querySelectorAll("th"),n=i[o].querySelector(".manualColumnMover");l.view.wt.wtDom.addClass(n,"active")}}),l.addHook("afterDestroy",h)},h=function(){var t=this;t.rootElement.off("mouseup.manualColumnMove"),t.rootElement.off("mousemove.manualColumnMove"),t.rootElement.off("mousedown.manualColumnMove"),t.rootElement.off("mouseenter.manualColumnMove")};this.beforeInit=function(){this.manualColumnPositions=[]},this.init=function(t){var e=this,o=!!this.getSettings().manualColumnMove;if(o){var i=this.getSettings().manualColumnMove,n=l.call(e);"undefined"!=typeof n?this.manualColumnPositions=n:i instanceof Array?this.manualColumnPositions=i:this.manualColumnPositions=[],e.forceFullRender=!0,"afterInit"==t&&(c.call(this),this.manualColumnPositions.length>0&&(this.forceFullRender=!0,this.render()))}else h.call(this),this.manualColumnPositions=[]},this.modifyCol=function(t){return this.getSettings().manualColumnMove?("undefined"==typeof this.manualColumnPositions[t]&&(this.manualColumnPositions[t]=t),this.manualColumnPositions[t]):t},this.getColHeader=function(t,e){if(this.getSettings().manualColumnMove){var o=document.createElement("DIV");o.className="manualColumnMover",e.firstChild.appendChild(o)}}}function a(){function t(t){r=this,i=t;var e=this.view.wt.wtTable.getCoords(t)[1];if(e>=0){n=e;var o=this.view.wt.wtDom.offset(this.rootElement[0]).left,s=this.view.wt.wtDom.offset(t).left;h=s-o-6,u.style.left=h+parseInt(this.view.wt.wtDom.outerWidth(t),10)+"px",this.rootElement[0].appendChild(u)}}function e(){var t=this;c=parseInt(this.view.wt.wtDom.outerWidth(i),10),t.view.wt.wtDom.addClass(u,"active"),f.height=t.view.wt.wtDom.outerHeight(t.$table[0])+"px",o=t}var o,i,n,s,r,a,l,c,h,u=document.createElement("DIV"),d=document.createElement("DIV"),p=document.createElement("DIV"),f=p.style;u.className="manualColumnResizer",d.className="manualColumnResizerHandle",u.appendChild(d),p.className="manualColumnResizerLine",u.appendChild(p);var g=$(document);g.mousemove(function(t){o&&(s=c+(t.pageX-l),a=v(n,s),u.style.left=h+s+"px")}),g.mouseup(function(){o&&(r.view.wt.wtDom.removeClass(u,"active"),o=!1,a!=c&&(r.forceFullRender=!0,r.view.render(),m.call(r),r.PluginHooks.run("afterColumnResize",n,a)),t.call(r,i))});var m=function(){var t=this;t.PluginHooks.run("persistentStateSave","manualColumnWidths",t.manualColumnWidths)},w=function(){var t=this,e={};return t.PluginHooks.run("persistentStateLoad","manualColumnWidths",e),e.value},y=function(){var i=this,s=0,r=null;this.rootElement.on("mouseenter.handsontable","th",function(e){o||t.call(i,e.currentTarget)}),this.rootElement.on("mousedown.handsontable",".manualColumnResizer",function(){null==r&&(r=setTimeout(function(){s>=2&&(a=i.determineColumnWidth.call(i,n),v(n,a),i.forceFullRender=!0,i.view.render(),i.PluginHooks.run("afterColumnResize",n,a)),s=0,r=null},500)),s++}),this.rootElement.on("mousedown.handsontable",".manualColumnResizer",function(t){l=t.pageX,e.call(i),a=c})};this.beforeInit=function(){this.manualColumnWidths=[]},this.init=function(t){var e=this,o=!!this.getSettings().manualColumnResize;if(o){var i=this.getSettings().manualColumnResize,n=w.call(e);"undefined"!=typeof n?this.manualColumnWidths=n:i instanceof Array?this.manualColumnWidths=i:this.manualColumnWidths=[],"afterInit"==t&&(y.call(this),e.forceFullRender=!0,e.render())}};var v=function(t,e){return e=Math.max(e,20),t=r.PluginHooks.execute("modifyCol",t),r.manualColumnWidths[t]=e,e};this.getColWidth=function(t,e){this.getSettings().manualColumnResize&&this.manualColumnWidths[t]&&(e.width=this.manualColumnWidths[t])}}function l(t){var e,i=function(){o.localStorage[t+"__persistentStateKeys"]=JSON.stringify(e)},n=function(){var i=o.localStorage[t+"__persistentStateKeys"],n="string"==typeof i?JSON.parse(i):void 0;e=n?n:[]},s=function(){e=[],i()};n(),this.saveValue=function(n,s){o.localStorage[t+"_"+n]=JSON.stringify(s),-1==e.indexOf(n)&&(e.push(n),i())},this.loadValue=function(e,i){e="undefined"!=typeof e?e:i;var n=o.localStorage[t+"_"+e];return"undefined"==typeof n?void 0:JSON.parse(n)},this.reset=function(e){o.localStorage.removeItem(t+"_"+e)},this.resetAll=function(){for(var i=0;i<e.length;i++)o.localStorage.removeItem(t+"_"+e[i]);s()}}function c(){this.boundaries=null,this.callback=null}function h(){this.maxOuts=10}function u(t,e){var o;this.instance=t,this.settings=e,this.wtDom=this.instance.wtDom,this.main=document.createElement("div"),o=this.main.style,o.position="absolute",o.top=0,o.left=0;for(var i=0;5>i;i++){var n=document.createElement("DIV");n.className="wtBorder "+(e.className||""),o=n.style,o.backgroundColor=e.border.color,o.height=e.border.width+"px",o.width=e.border.width+"px",this.main.appendChild(n)}this.top=this.main.childNodes[0],this.left=this.main.childNodes[1],this.bottom=this.main.childNodes[2],this.right=this.main.childNodes[3],this.topStyle=this.top.style,this.leftStyle=this.left.style,this.bottomStyle=this.bottom.style,this.rightStyle=this.right.style,this.corner=this.main.childNodes[4],this.corner.className+=" corner",this.cornerStyle=this.corner.style,this.cornerStyle.width="5px",this.cornerStyle.height="5px",this.cornerStyle.border="2px solid #FFF",this.disappear(),t.wtTable.bordersHolder||(t.wtTable.bordersHolder=document.createElement("div"),t.wtTable.bordersHolder.className="htBorders",t.wtTable.hider.appendChild(t.wtTable.bordersHolder)),t.wtTable.bordersHolder.appendChild(this.main);var s=!1,r=$(document.body);r.on("mousedown.walkontable."+t.guid,function(){s=!0}),r.on("mouseup.walkontable."+t.guid,function(){s=!1}),$(this.main.childNodes).on("mouseenter",function(e){if(s&&t.getSetting("hideBorderOnMouseDownOver")){e.preventDefault(),e.stopImmediatePropagation();var o=this.getBoundingClientRect(),i=$(this);i.hide();var n=function(t){return t.clientY<Math.floor(o.top)?!0:t.clientY>Math.ceil(o.top+o.height)?!0:t.clientX<Math.floor(o.left)?!0:t.clientX>Math.ceil(o.left+o.width)?!0:void 0};r.on("mousemove.border."+t.guid,function(e){n(e)&&(r.off("mousemove.border."+t.guid),i.show())})}})}function d(){this.offset=0,this.total=0,this.fixedCount=0}function p(t){this.instance=t}function f(){this.cache=[]}function g(){this.countTH=0}function m(t,e,o,i){var n,s=0;for(p.apply(this,arguments),this.containerSizeFn=e,this.cellSizesSum=0,this.cellSizes=[],this.cellStretch=[],this.cellCount=0,this.remainingSize=0,this.strategy=i;;){if(n=o(s),void 0===n)break;if(this.cellSizesSum>=this.getContainerSize(this.cellSizesSum+n))break;this.cellSizes.push(n),this.cellSizesSum+=n,this.cellCount++,s++}var r=this.getContainerSize(this.cellSizesSum);this.remainingSize=this.cellSizesSum-r}function w(t){var e=this,o=[];if(this.guid="wt_"+b(),this.wtDom=new v,t.cloneSource?(this.cloneSource=t.cloneSource,this.cloneOverlay=t.cloneOverlay,this.wtSettings=t.cloneSource.wtSettings,this.wtTable=new O(this,t.table),this.wtScroll=new R(this),this.wtViewport=t.cloneSource.wtViewport):(this.wtSettings=new P(this,t),this.wtTable=new O(this,t.table),this.wtScroll=new R(this),this.wtViewport=new M(this),this.wtScrollbars=new k(this),this.wtWheel=new I(this),this.wtEvent=new C(this)),this.wtTable.THEAD.childNodes.length&&this.wtTable.THEAD.childNodes[0].childNodes.length){for(var i=0,n=this.wtTable.THEAD.childNodes[0].childNodes.length;n>i;i++)o.push(this.wtTable.THEAD.childNodes[0].childNodes[i].innerHTML);this.getSetting("columnHeaders").length||this.update("columnHeaders",[function(t,i){e.wtDom.fastInnerText(i,o[t])}])}this.selections={};var s=this.getSetting("selections");if(s)for(var r in s)s.hasOwnProperty(r)&&(this.selections[r]=new A(this,s[r]));this.drawn=!1,this.drawInterrupted=!1}function y(t){this.instance=t,this.init(),this.clone=this.makeClone("debug"),this.clone.wtTable.holder.style.opacity=.4,this.clone.wtTable.holder.style.textShadow="0 0 2px #ff0000";var e,o=this,i=0,n=0,s=o.clone.wtTable.holder.parentNode;$(document.body).on("mousemove."+this.instance.guid,function(t){o.instance.wtTable.holder.parentNode&&(t.clientX-i>-5&&t.clientX-i<5&&t.clientY-n>-5&&t.clientY-n<5||(i=t.clientX,n=t.clientY,v.prototype.addClass(s,"wtDebugHidden"),v.prototype.removeClass(s,"wtDebugVisible"),clearTimeout(e),e=setTimeout(function(){v.prototype.removeClass(s,"wtDebugHidden"),v.prototype.addClass(s,"wtDebugVisible")},1e3)))})}function v(){}function C(t){var e=this;this.instance=t,this.wtDom=this.instance.wtDom;var o,i=[null,null],n=[null,null],s=function(t){var o=e.parentCell(t.target);e.wtDom.hasClass(t.target,"corner")?e.instance.getSetting("onCellCornerMouseDown",t,t.target):o.TD&&"TD"===o.TD.nodeName&&e.instance.hasSetting("onCellMouseDown")&&e.instance.getSetting("onCellMouseDown",t,o.coords,o.TD),2!==t.button&&o.TD&&"TD"===o.TD.nodeName&&(i[0]=o.TD,clearTimeout(n[0]),n[0]=setTimeout(function(){i[0]=null},1e3))},r=function(t){if(e.instance.hasSetting("onCellMouseOver")){var i=e.instance.wtTable.TABLE,n=e.wtDom.closest(t.target,["TD","TH"],i);n&&n!==o&&e.wtDom.isChildOf(n,i)&&(o=n,"TD"===n.nodeName&&e.instance.getSetting("onCellMouseOver",t,e.instance.wtTable.getCoords(n),n))}},a=function(t){if(2!==t.button){var o=e.parentCell(t.target);o.TD===i[0]&&o.TD===i[1]?(e.wtDom.hasClass(t.target,"corner")?e.instance.getSetting("onCellCornerDblClick",t,o.coords,o.TD):o.TD&&e.instance.getSetting("onCellDblClick",t,o.coords,o.TD),i[0]=null,i[1]=null):o.TD===i[0]&&(i[1]=o.TD,clearTimeout(n[1]),n[1]=setTimeout(function(){i[1]=null},500))}};$(this.instance.wtTable.holder).on("mousedown",s),$(this.instance.wtTable.TABLE).on("mouseover",r),$(this.instance.wtTable.holder).on("mouseup",a)}function b(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+t()+t()}function S(){}function T(t,e,o){p.apply(this,arguments),this.containerSizeFn=e,this.sizeAtIndex=o,this.cellSizesSum=0,this.cellSizes=[],this.cellCount=0,this.remainingSize=-(1/0)}function R(t){this.instance=t}function E(){}function D(t){this.instance=t,this.init(),this.clone=this.makeClone("corner")}function H(t){this.instance=t,this.type="horizontal",this.cellSize=50,this.init(),this.clone=this.makeClone("left")}function x(t){this.instance=t,this.type="vertical",this.cellSize=23,this.init(),this.clone=this.makeClone("top")}function k(t){this.instance=t,t.getSetting("nativeScrollbars")?(t.update("scrollbarWidth",t.wtDom.getScrollbarWidth()),t.update("scrollbarHeight",t.wtDom.getScrollbarWidth()),this.vertical=new x(t),this.horizontal=new H(t),this.corner=new D(t),t.getSetting("debug")&&(this.debug=new y(t)),this.registerListeners()):(this.vertical=new K(t),this.horizontal=new X(t))}function A(t,e){this.instance=t,this.settings=e,this.selected=[],e.border&&(this.border=new u(t,e))}function P(t,e){var o=this;this.instance=t,this.defaults={table:void 0,debug:!1,scrollH:"auto",scrollV:"auto",nativeScrollbars:!1,stretchH:"hybrid",currentRowClassName:null,currentColumnClassName:null,data:void 0,offsetRow:0,offsetColumn:0,fixedColumnsLeft:0,fixedRowsTop:0,rowHeaders:function(){return[]},columnHeaders:function(){return[]},totalRows:void 0,totalColumns:void 0,width:null,height:null,cellRenderer:function(t,e,i){var n=o.getSetting("data",t,e);o.instance.wtDom.fastInnerText(i,void 0===n||null===n?"":n)},columnWidth:50,selections:null,hideBorderOnMouseDownOver:!1,onCellMouseDown:null,onCellMouseOver:null,onCellDblClick:null,onCellCornerMouseDown:null,onCellCornerDblClick:null,beforeDraw:null,onDraw:null,onScrollVertically:null,onScrollHorizontally:null,scrollbarWidth:10,scrollbarHeight:10},this.settings={};for(var i in this.defaults)if(this.defaults.hasOwnProperty(i))if(void 0!==e[i])this.settings[i]=e[i];else{if(void 0===this.defaults[i])throw new Error('A required setting "'+i+'" was not provided');this.settings[i]=this.defaults[i]}}function O(t,e){this.instance=t,this.TABLE=e,this.wtDom=this.instance.wtDom,this.wtDom.removeTextNodes(this.TABLE);var o=this.TABLE.parentNode;if(!o||1!==o.nodeType||!this.wtDom.hasClass(o,"wtHolder")){var i=document.createElement("DIV");i.className="wtSpreader",o&&o.insertBefore(i,this.TABLE),i.appendChild(this.TABLE)}if(this.spreader=this.TABLE.parentNode,o=this.spreader.parentNode,!o||1!==o.nodeType||!this.wtDom.hasClass(o,"wtHolder")){var n=document.createElement("DIV");n.className="wtHider",o&&o.insertBefore(n,this.spreader),n.appendChild(this.spreader)}if(this.hider=this.spreader.parentNode,this.hiderStyle=this.hider.style,this.hiderStyle.position="relative",o=this.hider.parentNode,!o||1!==o.nodeType||!this.wtDom.hasClass(o,"wtHolder")){var s=document.createElement("DIV");s.style.position="relative",s.className="wtHolder",o&&o.insertBefore(s,this.hider),s.appendChild(this.hider)}if(this.holder=this.hider.parentNode,this.TBODY=this.TABLE.getElementsByTagName("TBODY")[0],this.TBODY||(this.TBODY=document.createElement("TBODY"),this.TABLE.appendChild(this.TBODY)),this.THEAD=this.TABLE.getElementsByTagName("THEAD")[0],this.THEAD||(this.THEAD=document.createElement("THEAD"),this.TABLE.insertBefore(this.THEAD,this.TBODY)),this.COLGROUP=this.TABLE.getElementsByTagName("COLGROUP")[0],this.COLGROUP||(this.COLGROUP=document.createElement("COLGROUP"),this.TABLE.insertBefore(this.COLGROUP,this.THEAD)),this.instance.getSetting("columnHeaders").length&&!this.THEAD.childNodes.length){var r=document.createElement("TR");this.THEAD.appendChild(r)}this.colgroupChildrenLength=this.COLGROUP.childNodes.length,this.theadChildrenLength=this.THEAD.firstChild?this.THEAD.firstChild.childNodes.length:0,this.tbodyChildrenLength=this.TBODY.childNodes.length,this.oldCellCache=new f,this.currentCellCache=new f,this.rowFilter=new S,this.columnFilter=new g,this.verticalRenderReverse=!1}function M(t){if(this.instance=t,this.resetSettings(),this.instance.getSetting("nativeScrollbars")){var e=this;$(o).on("resize",function(){e.clientHeight=e.getWorkspaceHeight()})}}function I(t){t.getSetting("nativeScrollbars")||$(t.wtTable.spreader).on("mousewheel",function(e,o,i,n){i||n||!o||(n=o),(i||n)&&(n>0&&0===t.getSetting("offsetRow")||0>n&&t.wtTable.isLastRowFullyVisible()||0>i&&0===t.getSetting("offsetColumn")||i>0&&t.wtTable.isLastColumnFullyVisible()||(clearTimeout(t.wheelTimeout),t.wheelTimeout=setTimeout(function(){n?t.wtScrollbars.vertical.visible&&t.scrollVertical(-Math.ceil(n)).draw():i&&t.wtScrollbars.horizontal.visible&&t.scrollHorizontal(Math.ceil(i)).draw()},0),e.preventDefault()))})}Array.prototype.indexOf||(Array.prototype.indexOf=function(t){var e=this.length>>>0,o=Number(arguments[1])||0;for(o=0>o?Math.ceil(o):Math.floor(o),0>o&&(o+=e);e>o;o++)if(o in this&&this[o]===t)return o;return-1}),Array.prototype.filter||(Array.prototype.filter=function(t,e){function o(t){return/NodeList/i.test(t.item)}function i(t){for(var e=[],o=0,i=t.length;i>o;o++)e[o]=t[o];return e}if("undefined"==typeof this||null===this)throw new TypeError;if("function"!=typeof t)throw new TypeError;e=e||this,o(e)&&(e=i(e));var n,s,r=e.length,a=[];for(n=0;r>n;n+=1)e.hasOwnProperty(n)&&(s=e[n],t.call(e,s,n,e)&&a.push(s));return a}),"undefined"==typeof WeakMap&&!function(){var t=Object.defineProperty;try{var e=!0;t(function(){},"foo",{})}catch(i){e=!1}var n=+new Date%1e9,s=function(){this.name="__st"+(1e9*Math.random()>>>0)+(n++ +"__"),e||(this._wmCache=[])};e?s.prototype={set:function(e,o){var i=e[this.name];i&&i[0]===e?i[1]=o:t(e,this.name,{value:[e,o],writable:!0})},get:function(t){var e;return(e=t[this.name])&&e[0]===t?e[1]:void 0},"delete":function(t){this.set(t,void 0)}}:s.prototype={set:function(t,e){if("undefined"!=typeof t&&"undefined"!=typeof e){for(var o=0,i=this._wmCache.length;i>o;o++)if(this._wmCache[o].key==t)return void(this._wmCache[o].value=e);this._wmCache.push({key:t,value:e})}},get:function(t){if("undefined"!=typeof t)for(var e=0,o=this._wmCache.length;o>e;e++)if(this._wmCache[e].key==t)return this._wmCache[e].value},"delete":function(t){if("undefined"!=typeof t)for(var e=0,o=this._wmCache.length;o>e;e++)this._wmCache[e].key==t&&Array.prototype.slice.call(this._wmCache,e,1)}},o.WeakMap=s}(),i.activeGuid=null,i.Core=function(t,n){function s(){var t=!1;return{validatorsInQueue:0,addValidatorToQueue:function(){this.validatorsInQueue++,t=!1},removeValidatorFormQueue:function(){this.validatorsInQueue=this.validatorsInQueue-1<0?0:this.validatorsInQueue-1,this.checkIfQueueIsEmpty()},onQueueEmpty:function(){},checkIfQueueIsEmpty:function(){0==this.validatorsInQueue&&0==t&&(t=!0,this.onQueueEmpty())}}}function r(t,o,i){function n(){var e;t.length&&(e=m.PluginHooks.execute("beforeChange",t,o),"function"==typeof e?$.when(result).then(function(){i()}):e===!1&&t.splice(0,t.length)),"function"!=typeof e&&i()}var r=new s;r.onQueueEmpty=n;for(var a=t.length-1;a>=0;a--)if(null===t[a])t.splice(a,1);else{var l=t[a][0],c=u.propToCol(t[a][1]),h=m.runHooksAndReturn("modifyCol",c),d=m.getCellMeta(l,h);"numeric"===d.type&&"string"==typeof t[a][3]&&t[a][3].length>0&&/^-?[\d\s]*\.?\d*$/.test(t[a][3])&&(t[a][3]=e().unformat(t[a][3]||"0")),m.getCellValidator(d)&&(r.addValidatorToQueue(),m.validateCell(t[a][3],d,function(e,o){return function(i){if("boolean"!=typeof i)throw new Error("Validation error: result is not boolean");i===!1&&o.allowInvalid===!1&&(t.splice(e,1),o.valid=!0,--e),r.removeValidatorFormQueue()}}(a,d),o))}r.checkIfQueueIsEmpty()}function a(t,e){var o=t.length-1;if(!(0>o)){for(;o>=0;o--)if(null!==t[o]){if(h.settings.minSpareRows)for(;t[o][0]>m.countRows()-1;)u.createRow();if("array"===m.dataType&&h.settings.minSpareCols)for(;u.propToCol(t[o][1])>m.countCols()-1;)u.createCol();u.set(t[o][0],t[o][1],t[o][3])}else t.splice(o,1);m.forceFullRender=!0,d.adjustRowsAndCols(),p.refreshBorders(null,!0),m.PluginHooks.run("afterChange",t,e||"edit")}}function l(t,e,o){return"object"==typeof t?t:$.isPlainObject(o)?o:[[t,e,o]]}function c(t){if(t.hasOwnProperty("type")){var e,o={};if("object"==typeof t.type)e=t.type;else if("string"==typeof t.type&&(e=i.cellTypes[t.type],void 0===e))throw new Error('You declared cell type "'+t.type+'" as a string that is not mapped to a known object. Cell type must be an object or a string mapped to an object in Handsontable.cellTypes');for(var n in e)e.hasOwnProperty(n)&&!t.hasOwnProperty(n)&&(o[n]=e[n]);return o}}var h,u,d,p,f,g,m=this,w=function(){};i.helper.extend(w.prototype,N.prototype),i.helper.extend(w.prototype,n),i.helper.extend(w.prototype,c(n)),this.rootElement=t;var y=$(document.documentElement),v=$(document.body);this.guid="ht_"+i.helper.randomString(),this.rootElement[0].id||(this.rootElement[0].id=this.guid),h={cellSettings:[],columnSettings:[],columnsSettingConflicts:["data","width"],settings:new w,settingsFromDOM:{},selStart:new i.SelectionPoint,selEnd:new i.SelectionPoint,isPopulated:null,scrollable:null,extensions:{},firstRun:!0},d={alter:function(t,e,o,n,s){var r;switch(o=o||1,t){case"insert_row":r=u.createRow(e,o),r&&(h.selStart.exists()&&h.selStart.row()>=e?(h.selStart.row(h.selStart.row()+r),p.transformEnd(r,0)):p.refreshBorders());break;case"insert_col":if(r=u.createCol(e,o)){if(i.helper.isArray(m.getSettings().colHeaders)){var a=[e,0];a.length+=r,Array.prototype.splice.apply(m.getSettings().colHeaders,a)}h.selStart.exists()&&h.selStart.col()>=e?(h.selStart.col(h.selStart.col()+r),p.transformEnd(0,r)):p.refreshBorders()}break;case"remove_row":u.removeRow(e,o),h.cellSettings.splice(e,o),d.adjustRowsAndCols(),p.refreshBorders();break;case"remove_col":u.removeCol(e,o);for(var l=0,c=u.getAll().length;c>l;l++)l in h.cellSettings&&h.cellSettings[l].splice(e,o);i.helper.isArray(m.getSettings().colHeaders)&&("undefined"==typeof e&&(e=-1),m.getSettings().colHeaders.splice(e,o)),h.columnSettings.splice(e,o),d.adjustRowsAndCols(),p.refreshBorders();break;default:throw new Error('There is no such action "'+t+'"')}s||d.adjustRowsAndCols()},adjustRowsAndCols:function(){var t,e,o,i=m.countEmptyRows(!0);if(e=m.countRows(),e<h.settings.minRows)for(t=0;t<h.settings.minRows-e;t++)u.createRow(m.countRows(),1,!0);if(i<h.settings.minSpareRows)for(;i<h.settings.minSpareRows&&m.countRows()<h.settings.maxRows;i++)u.createRow(m.countRows(),1,!0);if(o=m.countEmptyCols(!0),!h.settings.columns&&m.countCols()<h.settings.minCols)for(;m.countCols()<h.settings.minCols;o++)u.createCol(m.countCols(),1,!0);if(!h.settings.columns&&"array"===m.dataType&&o<h.settings.minSpareCols)for(;o<h.settings.minSpareCols&&m.countCols()<h.settings.maxCols;o++)u.createCol(m.countCols(),1,!0);if(h.settings.enterBeginsEditing)for(;(h.settings.minRows||h.settings.minSpareRows)&&m.countRows()>h.settings.minRows&&h.settings.minSpareRows&&i>h.settings.minSpareRows;i--)u.removeRow();if(h.settings.enterBeginsEditing&&!h.settings.columns)for(;(h.settings.minCols||h.settings.minSpareCols)&&m.countCols()>h.settings.minCols&&h.settings.minSpareCols&&o>h.settings.minSpareCols;o--)u.removeCol();var n=m.countRows(),s=m.countCols();if((0===n||0===s)&&p.deselect(),h.selStart.exists()){var r,a=h.selStart.row(),l=h.selStart.col(),c=h.selEnd.row(),d=h.selEnd.col();a>n-1?(a=n-1,r=!0,c>a&&(c=a)):c>n-1&&(c=n-1,r=!0,a>c&&(a=c)),l>s-1?(l=s-1,r=!0,d>l&&(d=l)):d>s-1&&(d=s-1,r=!0,l>d&&(l=d)),r&&m.selectCell(a,l,c,d)}},populateFromArray:function(t,e,o,n,s){var r,a,l,c,u=[],d={};if(a=e.length,0===a)return!1;var p,f,g,w;switch(s){case"shift_down":for(p=o?o.col-t.col+1:0,f=o?o.row-t.row+1:0,e=i.helper.translateRowsToColumns(e),l=0,c=e.length,g=Math.max(c,p);g>l;l++)if(c>l){for(r=0,a=e[l].length;f-a>r;r++)e[l].push(e[l][r%a]);e[l].unshift(t.col+l,t.row,0),m.spliceCol.apply(m,e[l])}else e[l%c][0]=t.col+l,m.spliceCol.apply(m,e[l%c]);break;case"shift_right":for(p=o?o.col-t.col+1:0,f=o?o.row-t.row+1:0,r=0,a=e.length,w=Math.max(a,f);w>r;r++)if(a>r){for(l=0,c=e[r].length;p-c>l;l++)e[r].push(e[r][l%c]);e[r].unshift(t.row+r,t.col,0),m.spliceRow.apply(m,e[r])}else e[r%a][0]=t.row+r,m.spliceRow.apply(m,e[r%a]);break;case"overwrite":default:for(d.row=t.row,d.col=t.col,r=0;a>r&&!(o&&d.row>o.row||!h.settings.minSpareRows&&d.row>m.countRows()-1||d.row>=h.settings.maxRows);r++){for(d.col=t.col,c=e[r]?e[r].length:0,l=0;c>l&&!(o&&d.col>o.col||!h.settings.minSpareCols&&d.col>m.countCols()-1||d.col>=h.settings.maxCols);l++)m.getCellMeta(d.row,d.col).readOnly||u.push([d.row,d.col,e[r][l]]),d.col++,o&&l===c-1&&(l=-1);d.row++,o&&r===a-1&&(r=-1)}m.setDataAtCell(u,null,null,n||"populateFromArray")}},getCornerCoords:function(t){function e(t,e,o){function i(t){return t[o]}return Array.prototype.map?t.apply(Math,e.map(i)):t.apply(Math,$.map(e,i))}return{TL:{row:e(Math.min,t,"row"),col:e(Math.min,t,"col")},BR:{row:e(Math.max,t,"row"),col:e(Math.max,t,"col")}}},getCellsAtCoords:function(t,e){var o,i,n=d.getCornerCoords([t,e]),s=[];for(o=n.TL.row;o<=n.BR.row;o++)for(i=n.TL.col;i<=n.BR.col;i++)s.push(m.view.getCellAtCoords({row:o,col:i}));return s}},this.selection=p={inProgress:!1,begin:function(){m.selection.inProgress=!0},finish:function(){var t=m.getSelected();m.PluginHooks.run("afterSelectionEnd",t[0],t[1],t[2],t[3]),m.PluginHooks.run("afterSelectionEndByProp",t[0],m.colToProp(t[1]),t[2],m.colToProp(t[3])),m.selection.inProgress=!1},isInProgress:function(){return m.selection.inProgress},setRangeStart:function(t){h.selStart.coords(t),p.setRangeEnd(t)},setRangeEnd:function(t,e){m.selection.begin(),h.selEnd.coords(t),h.settings.multiSelect||h.selStart.coords(t),m.view.wt.selections.current.clear(),m.view.wt.selections.current.add(h.selStart.arr()),m.view.wt.selections.area.clear(),p.isMultiple()&&(m.view.wt.selections.area.add(h.selStart.arr()),m.view.wt.selections.area.add(h.selEnd.arr())),(h.settings.currentRowClassName||h.settings.currentColClassName)&&(m.view.wt.selections.highlight.clear(),m.view.wt.selections.highlight.add(h.selStart.arr()),m.view.wt.selections.highlight.add(h.selEnd.arr())),m.PluginHooks.run("afterSelection",h.selStart.row(),h.selStart.col(),h.selEnd.row(),h.selEnd.col()),m.PluginHooks.run("afterSelectionByProp",h.selStart.row(),u.colToProp(h.selStart.col()),h.selEnd.row(),u.colToProp(h.selEnd.col())),e!==!1&&m.view.scrollViewport(t),p.refreshBorders()},refreshBorders:function(t,e){e||f.destroyEditor(t),m.view.render(),p.isSelected()&&!e&&f.prepareEditor()},isMultiple:function(){return!(h.selEnd.col()===h.selStart.col()&&h.selEnd.row()===h.selStart.row())},transformStart:function(t,e,o){h.selStart.row()+t>m.countRows()-1?o&&h.settings.minSpareRows>0?m.alter("insert_row",m.countRows()):h.settings.autoWrapCol&&(t=1-m.countRows(),e=h.selStart.col()+e==m.countCols()-1?1-m.countCols():1):h.settings.autoWrapCol&&h.selStart.row()+t<0&&h.selStart.col()+e>=0&&(t=m.countRows()-1,e=h.selStart.col()+e==0?m.countCols()-1:-1),h.selStart.col()+e>m.countCols()-1?o&&h.settings.minSpareCols>0?m.alter("insert_col",m.countCols()):h.settings.autoWrapRow&&(t=h.selStart.row()+t==m.countRows()-1?1-m.countRows():1,e=1-m.countCols()):h.settings.autoWrapRow&&h.selStart.col()+e<0&&h.selStart.row()+t>=0&&(t=h.selStart.row()+t==0?m.countRows()-1:-1,e=m.countCols()-1);var i=m.countRows(),n=m.countCols(),s={row:h.selStart.row()+t,col:h.selStart.col()+e};s.row<0?s.row=0:s.row>0&&s.row>=i&&(s.row=i-1),s.col<0?s.col=0:s.col>0&&s.col>=n&&(s.col=n-1),p.setRangeStart(s)},transformEnd:function(t,e){if(h.selEnd.exists()){var o=m.countRows(),i=m.countCols(),n={row:h.selEnd.row()+t,col:h.selEnd.col()+e};n.row<0?n.row=0:n.row>0&&n.row>=o&&(n.row=o-1),n.col<0?n.col=0:n.col>0&&n.col>=i&&(n.col=i-1),p.setRangeEnd(n)}},isSelected:function(){return h.selEnd.exists()},inInSelection:function(t){if(!p.isSelected())return!1;var e=d.getCornerCoords([h.selStart.coords(),h.selEnd.coords()]);return e.TL.row<=t.row&&e.BR.row>=t.row&&e.TL.col<=t.col&&e.BR.col>=t.col},deselect:function(){p.isSelected()&&(m.selection.inProgress=!1,h.selEnd=new i.SelectionPoint,m.view.wt.selections.current.clear(),m.view.wt.selections.area.clear(),f.destroyEditor(),p.refreshBorders(),m.PluginHooks.run("afterDeselect"))},selectAll:function(){h.settings.multiSelect&&(p.setRangeStart({row:0,col:0}),p.setRangeEnd({row:m.countRows()-1,col:m.countCols()-1},!1))},empty:function(){if(p.isSelected()){var t,e,o=d.getCornerCoords([h.selStart.coords(),h.selEnd.coords()]),i=[];
for(t=o.TL.row;t<=o.BR.row;t++)for(e=o.TL.col;e<=o.BR.col;e++)m.getCellMeta(t,e).readOnly||i.push([t,e,""]);m.setDataAtCell(i)}}},this.autofill=g={handle:null,init:function(){g.handle?g.handle.disabled=!1:g.handle={}},disable:function(){g.handle.disabled=!0},selectAdjacent:function(){var t,e,o,i,n;t=p.isMultiple()?m.view.wt.selections.area.getCorners():m.view.wt.selections.current.getCorners(),e=u.getAll();t:for(o=t[2]+1;o<m.countRows();o++){for(n=t[1];n<=t[3];n++)if(e[o][n])break t;(e[o][t[1]-1]||e[o][t[3]+1])&&(i=o)}i&&(m.view.wt.selections.fill.clear(),m.view.wt.selections.fill.add([t[0],t[1]]),m.view.wt.selections.fill.add([i,t[3]]),g.apply())},apply:function(){var t,e,o,i,n;g.handle.isDragged=0,t=m.view.wt.selections.fill.getCorners(),t&&(m.view.wt.selections.fill.clear(),e=p.isMultiple()?m.view.wt.selections.area.getCorners():m.view.wt.selections.current.getCorners(),t[0]===e[0]&&t[1]<e[1]?(o={row:t[0],col:t[1]},i={row:t[2],col:e[1]-1}):t[0]===e[0]&&t[3]>e[3]?(o={row:t[0],col:e[3]+1},i={row:t[2],col:t[3]}):t[0]<e[0]&&t[1]===e[1]?(o={row:t[0],col:t[1]},i={row:e[0]-1,col:t[3]}):t[2]>e[2]&&t[1]===e[1]&&(o={row:e[2]+1,col:t[1]},i={row:t[2],col:t[3]}),o&&(n=SheetClip.parse(u.getText(h.selStart.coords(),h.selEnd.coords())),m.PluginHooks.run("beforeAutofill",o,i,n),d.populateFromArray(o,n,i,"autofill"),p.setRangeStart({row:t[0],col:t[1]}),p.setRangeEnd({row:t[2],col:t[3]})))},showBorder:function(t){t.row=t[0],t.col=t[1];var e=d.getCornerCoords([h.selStart.coords(),h.selEnd.coords()]);if("horizontal"!==h.settings.fillHandle&&(e.BR.row<t.row||e.TL.row>t.row))t=[t.row,e.BR.col];else{if("vertical"===h.settings.fillHandle)return;t=[e.BR.row,t.col]}m.view.wt.selections.fill.clear(),m.view.wt.selections.fill.add([h.selStart.coords().row,h.selStart.coords().col]),m.view.wt.selections.fill.add([h.selEnd.coords().row,h.selEnd.coords().col]),m.view.wt.selections.fill.add(t),m.view.render()}},this.init=function(){m.PluginHooks.run("beforeInit"),this.view=new i.TableView(this),f=new i.EditorManager(m,h,p,u),this.updateSettings(h.settings,!0),this.parseSettingsFromDOM(),this.forceFullRender=!0,this.view.render(),"object"==typeof h.firstRun&&(m.PluginHooks.run("afterChange",h.firstRun[0],h.firstRun[1]),h.firstRun=!1),m.PluginHooks.run("afterInit")},this.validateCell=function(t,e,o,i){var n=m.getCellValidator(e);"[object RegExp]"===Object.prototype.toString.call(n)&&(n=function(t){return function(e,o){o(t.test(e))}}(n)),"function"==typeof n?(t=m.PluginHooks.execute("beforeValidate",t,e.row,e.prop,i),setTimeout(function(){n.call(e,t,function(n){e.valid=n,n=m.PluginHooks.execute("afterValidate",n,t,e.row,e.prop,i),o(n)})})):(e.valid=!0,o(!0))},this.setDataAtCell=function(t,e,o,i){var n,s,c,h=l(t,e,o),d=[];for(n=0,s=h.length;s>n;n++){if("object"!=typeof h[n])throw new Error("Method `setDataAtCell` accepts row number or changes array of arrays as its first parameter");if("number"!=typeof h[n][1])throw new Error("Method `setDataAtCell` accepts row and column number as its parameters. If you want to use object property name, use method `setDataAtRowProp`");c=u.colToProp(h[n][1]),d.push([h[n][0],c,u.get(h[n][0],c),h[n][2]])}i||"object"!=typeof t||(i=e),r(d,i,function(){a(d,i)})},this.setDataAtRowProp=function(t,e,o,i){var n,s,c=l(t,e,o),h=[];for(n=0,s=c.length;s>n;n++)h.push([c[n][0],c[n][1],u.get(c[n][0],c[n][1]),c[n][2]]);i||"object"!=typeof t||(i=e),r(h,i,function(){a(h,i)})},this.listen=function(){i.activeGuid=m.guid,document.activeElement&&document.activeElement!==document.body?document.activeElement.blur():document.activeElement||document.body.focus()},this.unlisten=function(){i.activeGuid=null},this.isListening=function(){return i.activeGuid===m.guid},this.destroyEditor=function(t){p.refreshBorders(t)},this.populateFromArray=function(t,e,o,i,n,s,r){if("object"!=typeof o||"object"!=typeof o[0])throw new Error("populateFromArray parameter `input` must be an array of arrays");return d.populateFromArray({row:t,col:e},o,"number"==typeof i?{row:i,col:n}:null,s,r)},this.spliceCol=function(t,e,o){return u.spliceCol.apply(u,arguments)},this.spliceRow=function(t,e,o){return u.spliceRow.apply(u,arguments)},this.getCornerCoords=function(t){return d.getCornerCoords(t)},this.getSelected=function(){return p.isSelected()?[h.selStart.row(),h.selStart.col(),h.selEnd.row(),h.selEnd.col()]:void 0},this.parseSettingsFromDOM=function(){var t=this.rootElement.css("overflow");if("scroll"===t||"auto"===t?(this.rootElement[0].style.overflow="visible",h.settingsFromDOM.overflow=t):(void 0===h.settings.width||void 0===h.settings.height)&&(h.settingsFromDOM.overflow="auto"),void 0===h.settings.width?h.settingsFromDOM.width=this.rootElement.width():h.settingsFromDOM.width=void 0,h.settingsFromDOM.height=void 0,void 0===h.settings.height&&("scroll"===h.settingsFromDOM.overflow||"auto"===h.settingsFromDOM.overflow)){var e=this.rootElement[0].cloneNode(!1),i=this.rootElement[0].parentNode;if(i){e.removeAttribute("id"),i.appendChild(e);var n=parseInt(e.clientHeight,10),s=parseInt(o.getComputedStyle(e,null).getPropertyValue("paddingTop"),10)||0,r=parseInt(o.getComputedStyle(e,null).getPropertyValue("paddingBottom"),10)||0,a=n-s-r;isNaN(a)&&e.currentStyle&&(a=parseInt(e.currentStyle.height,10)),a>0&&(h.settingsFromDOM.height=a),i.removeChild(e)}}},this.render=function(){m.view&&(m.forceFullRender=!0,m.parseSettingsFromDOM(),p.refreshBorders(null,!0))},this.loadData=function(t){function e(){h.cellSettings.length=0}if("object"==typeof t&&null!==t)t.push&&t.splice||(t=[t]);else{if(null!==t)throw new Error("loadData only accepts array of objects or array of arrays ("+typeof t+" given)");t=[];for(var o,n=0,s=h.settings.startRows;s>n;n++){o=[];for(var r=0,a=h.settings.startCols;a>r;r++)o.push(null);t.push(o)}}h.isPopulated=!1,w.prototype.data=t,h.settings.dataSchema instanceof Array||t[0]instanceof Array?m.dataType="array":"function"==typeof h.settings.dataSchema?m.dataType="function":m.dataType="object",u=new i.DataMap(m,h,w),e(),d.adjustRowsAndCols(),m.PluginHooks.run("afterLoadData"),h.firstRun?h.firstRun=[null,"loadData"]:(m.PluginHooks.run("afterChange",null,"loadData"),m.render()),h.isPopulated=!0},this.getData=function(t,e,o,i){return"undefined"==typeof t?u.getAll():u.getRange({row:t,col:e},{row:o,col:i},u.DESTINATION_RENDERER)},this.getCopyableData=function(t,e,o,i){return u.getCopyableText({row:t,col:e},{row:o,col:i})},this.updateSettings=function(t,e){var o,n;if("undefined"!=typeof t.rows)throw new Error("'rows' setting is no longer supported. do you mean startRows, minRows or maxRows?");if("undefined"!=typeof t.cols)throw new Error("'cols' setting is no longer supported. do you mean startCols, minCols or maxCols?");for(o in t)"data"!==o&&(void 0!==m.PluginHooks.hooks[o]||void 0!==m.PluginHooks.legacy[o]?("function"==typeof t[o]||i.helper.isArray(t[o]))&&m.PluginHooks.add(o,t[o]):(!e&&t.hasOwnProperty(o)&&(w.prototype[o]=t[o]),i.extension[o]&&(h.extensions[o]=new i.extension[o](m,t[o]))));if(void 0===t.data&&void 0===h.settings.data?m.loadData(null):void 0!==t.data?m.loadData(t.data):void 0!==t.columns&&u.createMap(),n=m.countCols(),h.cellSettings.length=0,n>0){var s,r;for(o=0;n>o;o++)h.columnSettings[o]=i.helper.columnFactory(w,h.columnsSettingConflicts),s=h.columnSettings[o].prototype,w.prototype.columns&&(r=w.prototype.columns[o],i.helper.extend(s,r),i.helper.extend(s,c(r)))}"undefined"!=typeof t.fillHandle&&(g.handle&&t.fillHandle===!1?g.disable():g.handle||t.fillHandle===!1||g.init()),"undefined"!=typeof t.className&&(w.prototype.className&&m.rootElement.removeClass(w.prototype.className),t.className&&m.rootElement.addClass(t.className)),e||m.PluginHooks.run("afterUpdateSettings"),d.adjustRowsAndCols(),m.view&&!h.firstRun&&(m.forceFullRender=!0,p.refreshBorders(null,!0))},this.getValue=function(){var t=m.getSelected();if(w.prototype.getValue){if("function"==typeof w.prototype.getValue)return w.prototype.getValue.call(m);if(t)return m.getData()[t[0]][w.prototype.getValue]}else if(t)return m.getDataAtCell(t[0],t[1])},this.getSettings=function(){return h.settings},this.getSettingsFromDOM=function(){return h.settingsFromDOM},this.clear=function(){p.selectAll(),p.empty()},this.alter=function(t,e,o,i,n){d.alter(t,e,o,i,n)},this.getCell=function(t,e){return m.view.getCellAtCoords({row:t,col:e})},this.colToProp=function(t){return u.colToProp(t)},this.propToCol=function(t){return u.propToCol(t)},this.getDataAtCell=function(t,e){return u.get(t,u.colToProp(e))},this.getDataAtRowProp=function(t,e){return u.get(t,e)},this.getDataAtCol=function(t){return[].concat.apply([],u.getRange({row:0,col:t},{row:h.settings.data.length-1,col:t},u.DESTINATION_RENDERER))},this.getDataAtProp=function(t){return[].concat.apply([],u.getRange({row:0,col:u.propToCol(t)},{row:h.settings.data.length-1,col:u.propToCol(t)},u.DESTINATION_RENDERER))},this.getDataAtRow=function(t){return h.settings.data[t]},this.getCellMeta=function(t,e){function o(t){var e={row:t};return m.PluginHooks.execute("beforeGet",e),e.row}function n(t){return i.PluginHooks.execute(m,"modifyCol",t)}var s,r=u.colToProp(e);if(t=o(t),e=n(e),"undefined"==typeof h.columnSettings[e]&&(h.columnSettings[e]=i.helper.columnFactory(w,h.columnsSettingConflicts)),h.cellSettings[t]||(h.cellSettings[t]=[]),h.cellSettings[t][e]||(h.cellSettings[t][e]=new h.columnSettings[e]),s=h.cellSettings[t][e],s.row=t,s.col=e,s.prop=r,s.instance=m,m.PluginHooks.run("beforeGetCellMeta",t,e,s),i.helper.extend(s,c(s)),s.cells){var a=s.cells.call(s,t,e,r);a&&(i.helper.extend(s,a),i.helper.extend(s,c(a)))}return m.PluginHooks.run("afterGetCellMeta",t,e,s),s};var C=i.helper.cellMethodLookupFactory("renderer");this.getCellRenderer=function(t,e){var o=C.call(this,t,e);return i.renderers.getRenderer(o)},this.getCellEditor=i.helper.cellMethodLookupFactory("editor"),this.getCellValidator=i.helper.cellMethodLookupFactory("validator"),this.validateCells=function(t){var e=new s;e.onQueueEmpty=t;for(var o=m.countRows()-1;o>=0;){for(var i=m.countCols()-1;i>=0;)e.addValidatorToQueue(),m.validateCell(m.getDataAtCell(o,i),m.getCellMeta(o,i),function(){e.removeValidatorFormQueue()},"validateCells"),i--;o--}e.checkIfQueueIsEmpty()},this.getRowHeader=function(t){if(void 0===t){for(var e=[],o=0,i=m.countRows();i>o;o++)e.push(m.getRowHeader(o));return e}return"[object Array]"===Object.prototype.toString.call(h.settings.rowHeaders)&&void 0!==h.settings.rowHeaders[t]?h.settings.rowHeaders[t]:"function"==typeof h.settings.rowHeaders?h.settings.rowHeaders(t):h.settings.rowHeaders&&"string"!=typeof h.settings.rowHeaders&&"number"!=typeof h.settings.rowHeaders?t+1:h.settings.rowHeaders},this.hasRowHeaders=function(){return!!h.settings.rowHeaders},this.hasColHeaders=function(){if(void 0!==h.settings.colHeaders&&null!==h.settings.colHeaders)return!!h.settings.colHeaders;for(var t=0,e=m.countCols();e>t;t++)if(m.getColHeader(t))return!0;return!1},this.getColHeader=function(t){if(void 0===t){for(var e=[],o=0,n=m.countCols();n>o;o++)e.push(m.getColHeader(o));return e}return t=i.PluginHooks.execute(m,"modifyCol",t),h.settings.columns&&h.settings.columns[t]&&h.settings.columns[t].title?h.settings.columns[t].title:"[object Array]"===Object.prototype.toString.call(h.settings.colHeaders)&&void 0!==h.settings.colHeaders[t]?h.settings.colHeaders[t]:"function"==typeof h.settings.colHeaders?h.settings.colHeaders(t):h.settings.colHeaders&&"string"!=typeof h.settings.colHeaders&&"number"!=typeof h.settings.colHeaders?i.helper.spreadsheetColumnLabel(t):h.settings.colHeaders},this._getColWidthFromSettings=function(t){var e=m.getCellMeta(0,t),o=e.width;if((void 0===o||o===h.settings.width)&&(o=e.colWidths),void 0!==o&&null!==o){switch(typeof o){case"object":o=o[t];break;case"function":o=o(t)}"string"==typeof o&&(o=parseInt(o,10))}return o},this.getColWidth=function(t){t=i.PluginHooks.execute(m,"modifyCol",t);var e={width:m._getColWidthFromSettings(t)};return e.width||(e.width=50),m.PluginHooks.run("afterGetColWidth",t,e),e.width},this.countRows=function(){return h.settings.data.length},this.countCols=function(){return"object"===m.dataType||"function"===m.dataType?h.settings.columns&&h.settings.columns.length?h.settings.columns.length:u.colToPropCache.length:"array"===m.dataType?h.settings.columns&&h.settings.columns.length?h.settings.columns.length:h.settings.data&&h.settings.data[0]&&h.settings.data[0].length?h.settings.data[0].length:0:void 0},this.rowOffset=function(){return m.view.wt.getSetting("offsetRow")},this.colOffset=function(){return m.view.wt.getSetting("offsetColumn")},this.countVisibleRows=function(){return m.view.wt.drawn?m.view.wt.wtTable.rowStrategy.countVisible():-1},this.countVisibleCols=function(){return m.view.wt.drawn?m.view.wt.wtTable.columnStrategy.countVisible():-1},this.countEmptyRows=function(t){for(var e=m.countRows()-1,o=0;e>=0;){if(u.get(e,0),m.isEmptyRow(u.getVars.row))o++;else if(t)break;e--}return o},this.countEmptyCols=function(t){if(m.countRows()<1)return 0;for(var e=m.countCols()-1,o=0;e>=0;){if(m.isEmptyCol(e))o++;else if(t)break;e--}return o},this.isEmptyRow=function(t){return h.settings.isEmptyRow.call(m,t)},this.isEmptyCol=function(t){return h.settings.isEmptyCol.call(m,t)},this.selectCell=function(t,e,o,i,n){if("number"!=typeof t||0>t||t>=m.countRows())return!1;if("number"!=typeof e||0>e||e>=m.countCols())return!1;if("undefined"!=typeof o){if("number"!=typeof o||0>o||o>=m.countRows())return!1;if("number"!=typeof i||0>i||i>=m.countCols())return!1}return h.selStart.coords({row:t,col:e}),document.activeElement&&document.activeElement!==document.documentElement&&document.activeElement!==document.body&&document.activeElement.blur(),m.listen(),"undefined"==typeof o?p.setRangeEnd({row:t,col:e},n):p.setRangeEnd({row:o,col:i},n),m.selection.finish(),!0},this.selectCellByProp=function(t,e,o,i,n){return arguments[1]=u.propToCol(arguments[1]),"undefined"!=typeof arguments[3]&&(arguments[3]=u.propToCol(arguments[3])),m.selectCell.apply(m,arguments)},this.deselectCell=function(){p.deselect()},this.destroy=function(){m.clearTimeouts(),m.view&&m.view.wt.destroy(),m.rootElement.empty(),m.rootElement.removeData("handsontable"),m.rootElement.off(".handsontable"),$(o).off("."+m.guid),y.off("."+m.guid),v.off("."+m.guid),m.PluginHooks.run("afterDestroy")},this.getActiveEditor=function(){return f.getActiveEditor()},this.getInstance=function(){return m.rootElement.data("handsontable")},function(){m.PluginHooks=new i.PluginHookClass;var t=m.PluginHooks.run,e=m.PluginHooks.execute;m.PluginHooks.run=function(e,o,n,s,r,a){t.call(this,m,e,o,n,s,r,a),i.PluginHooks.run(m,e,o,n,s,r,a)},m.PluginHooks.execute=function(t,o,n,s,r,a){var l=i.PluginHooks.execute(m,t,o,n,s,r,a),c=e.call(this,m,t,l,n,s,r,a);return"undefined"==typeof c?l:c},m.addHook=function(){m.PluginHooks.add.apply(m.PluginHooks,arguments)},m.addHookOnce=function(){m.PluginHooks.once.apply(m.PluginHooks,arguments)},m.removeHook=function(){m.PluginHooks.remove.apply(m.PluginHooks,arguments)},m.runHooks=function(){m.PluginHooks.run.apply(m.PluginHooks,arguments)},m.runHooksAndReturn=function(){return m.PluginHooks.execute.apply(m.PluginHooks,arguments)}}(),this.timeouts={},this.registerTimeout=function(t,e,o){clearTimeout(this.timeouts[t]),this.timeouts[t]=setTimeout(e,o||0)},this.clearTimeouts=function(){for(var t in this.timeouts)this.timeouts.hasOwnProperty(t)&&clearTimeout(this.timeouts[t])},this.version="0.10.5"};var N=function(){};N.prototype={data:void 0,width:void 0,height:void 0,startRows:5,startCols:5,rowHeaders:null,colHeaders:null,minRows:0,minCols:0,maxRows:1/0,maxCols:1/0,minSpareRows:0,minSpareCols:0,multiSelect:!0,fillHandle:!0,fixedRowsTop:0,fixedColumnsLeft:0,outsideClickDeselects:!0,enterBeginsEditing:!0,enterMoves:{row:1,col:0},tabMoves:{row:0,col:1},autoWrapRow:!1,autoWrapCol:!1,copyRowsLimit:1e3,copyColsLimit:1e3,trimWhitespace:!1,pasteMode:"overwrite",currentRowClassName:void 0,currentColClassName:void 0,stretchH:"hybrid",isEmptyRow:function(t){for(var e,o=0,i=this.countCols();i>o;o++)if(e=this.getDataAtCell(t,o),""!==e&&null!==e&&"undefined"!=typeof e)return!1;return!0},isEmptyCol:function(t){for(var e,o=0,i=this.countRows();i>o;o++)if(e=this.getDataAtCell(o,t),""!==e&&null!==e&&"undefined"!=typeof e)return!1;return!0},observeDOMVisibility:!0,allowInvalid:!0,invalidCellClassName:"htInvalid",placeholderCellClassName:"htPlaceholder",readOnlyCellClassName:"htDimmed",fragmentSelection:!1,readOnly:!1,nativeScrollbars:!1,type:"text",copyable:!0,debug:!1},i.DefaultSettings=N,$.fn.handsontable=function(t){var e,o,n,s,r,a=this.first(),l=a.data("handsontable");if("string"!=typeof t)return r=t||{},l?l.updateSettings(r):(l=new i.Core(a,r),a.data("handsontable",l),l.init()),a;if(n=[],arguments.length>1)for(e=1,o=arguments.length;o>e;e++)n.push(arguments[e]);if(l){if("undefined"==typeof l[t])throw new Error("Handsontable do not provide action: "+t);s=l[t].apply(l,n)}return s},function(t){function e(){function t(t){return null!==t&&!o(t)&&("string"==typeof t||"number"==typeof t)}function e(t){return null!==t&&("object"==typeof t||"function"==typeof t)}function o(t){return t!==t}var i={arrayMap:[],weakMap:new WeakMap};return{get:function(o){return t(o)?i.arrayMap[o]:e(o)?i.weakMap.get(o):void 0},set:function(o,n){if(t(o))i.arrayMap[o]=n;else{if(!e(o))throw new Error("Invalid key type");i.weakMap.set(o,n)}},"delete":function(o){t(o)?delete i.arrayMap[o]:e(o)&&i.weakMap["delete"](o)}}}t.MultiMap||(t.MultiMap=e)}(o),i.TableView=function(t){var e=this,n=$(o),s=$(document.documentElement);this.instance=t,this.settings=t.getSettings(),this.settingsFromDOM=t.getSettingsFromDOM(),t.rootElement.data("originalStyle",t.rootElement[0].getAttribute("style")),t.rootElement.addClass("handsontable");var r=document.createElement("TABLE");r.className="htCore",this.THEAD=document.createElement("THEAD"),r.appendChild(this.THEAD),this.TBODY=document.createElement("TBODY"),r.appendChild(this.TBODY),t.$table=$(r),t.rootElement.prepend(t.$table),t.rootElement.on("mousedown.handsontable",function(t){e.isTextSelectionAllowed(t.target)||(l(),t.preventDefault(),o.focus())}),s.on("keyup."+t.guid,function(e){t.selection.isInProgress()&&!e.shiftKey&&t.selection.finish()});var a;s.on("mouseup."+t.guid,function(e){t.selection.isInProgress()&&1===e.which&&t.selection.finish(),a=!1,t.autofill.handle&&t.autofill.handle.isDragged&&(t.autofill.handle.isDragged>1&&t.autofill.apply(),t.autofill.handle.isDragged=0),i.helper.isOutsideInput(document.activeElement)&&t.unlisten()}),s.on("mousedown."+t.guid,function(o){var i=o.target;if(i!==e.wt.wtTable.spreader)for(;i!==document.documentElement;){if(null===i)return;if(i===t.rootElement[0]||"HANDSONTABLE-TABLE"===i.nodeName)return;i=i.parentNode}e.settings.outsideClickDeselects?t.deselectCell():t.destroyEditor()}),t.rootElement.on("mousedown.handsontable",".dragdealer",function(){t.destroyEditor()}),t.$table.on("selectstart",function(t){e.settings.fragmentSelection||t.preventDefault()});var l=function(){o.getSelection?o.getSelection().empty?o.getSelection().empty():o.getSelection().removeAllRanges&&o.getSelection().removeAllRanges():document.selection&&document.selection.empty()},c={debug:function(){return e.settings.debug},table:r,stretchH:this.settings.stretchH,data:t.getDataAtCell,totalRows:t.countRows,totalColumns:t.countCols,nativeScrollbars:this.settings.nativeScrollbars,offsetRow:0,offsetColumn:0,width:this.getWidth(),height:this.getHeight(),fixedColumnsLeft:function(){return e.settings.fixedColumnsLeft},fixedRowsTop:function(){return e.settings.fixedRowsTop},rowHeaders:function(){return t.hasRowHeaders()?[function(t,o){e.appendRowHeader(t,o)}]:[]},columnHeaders:function(){return t.hasColHeaders()?[function(t,o){e.appendColHeader(t,o)}]:[]},columnWidth:t.getColWidth,cellRenderer:function(t,o,i){var n=e.instance.colToProp(o),s=e.instance.getCellMeta(t,o),r=e.instance.getCellRenderer(s),a=e.instance.getDataAtRowProp(t,n);r(e.instance,i,t,o,n,a,s),e.instance.PluginHooks.run("afterRenderer",i,t,o,n,a,s)},selections:{current:{className:"current",border:{width:2,color:"#5292F7",style:"solid",cornerVisible:function(){return e.settings.fillHandle&&!e.isCellEdited()&&!t.selection.isMultiple()}}},area:{className:"area",border:{width:1,color:"#89AFF9",style:"solid",cornerVisible:function(){return e.settings.fillHandle&&!e.isCellEdited()&&t.selection.isMultiple()}}},highlight:{highlightRowClassName:e.settings.currentRowClassName,highlightColumnClassName:e.settings.currentColClassName},fill:{className:"fill",border:{width:1,color:"red",style:"solid"}}},hideBorderOnMouseDownOver:function(){return e.settings.fragmentSelection},onCellMouseDown:function(e,o,i){t.listen(),a=!0;var n={row:o[0],col:o[1]};2===e.button&&t.selection.inInSelection(n)||(e.shiftKey?t.selection.setRangeEnd(n):t.selection.setRangeStart(n)),t.PluginHooks.run("afterOnCellMouseDown",e,o,i)},onCellMouseOver:function(e,o,i){var n={row:o[0],col:o[1]};a?t.selection.setRangeEnd(n):t.autofill.handle&&t.autofill.handle.isDragged&&(t.autofill.handle.isDragged++,t.autofill.showBorder(o)),t.PluginHooks.run("afterOnCellMouseOver",e,o,i)},onCellCornerMouseDown:function(e){t.autofill.handle.isDragged=1,e.preventDefault(),t.PluginHooks.run("afterOnCellCornerMouseDown",e)},onCellCornerDblClick:function(){t.autofill.selectAdjacent()},beforeDraw:function(t){e.beforeRender(t)},onDraw:function(t){e.onDraw(t)},onScrollVertically:function(){t.runHooks("afterScrollVertically")},onScrollHorizontally:function(){t.runHooks("afterScrollHorizontally")}};t.PluginHooks.run("beforeInitWalkontable",c),this.wt=new w(c),n.on("resize."+t.guid,function(){t.registerTimeout("resizeTimeout",function(){t.parseSettingsFromDOM();var o=e.getWidth(),i=e.getHeight();(c.width!==o||c.height!==i)&&(t.forceFullRender=!0,e.render(),c.width=o,c.height=i)},60)}),$(e.wt.wtTable.spreader).on("mousedown.handsontable, contextmenu.handsontable",function(t){t.target===e.wt.wtTable.spreader&&3===t.which&&t.stopPropagation()}),s.on("click."+t.guid,function(){e.settings.observeDOMVisibility&&e.wt.drawInterrupted&&(e.instance.forceFullRender=!0,e.render())})},i.TableView.prototype.isTextSelectionAllowed=function(t){return i.helper.isInput(t)?!0:this.settings.fragmentSelection&&this.wt.wtDom.isChildOf(t,this.TBODY)?!0:!1},i.TableView.prototype.isCellEdited=function(){var t=this.instance.getActiveEditor();return t&&t.isOpened()},i.TableView.prototype.getWidth=function(){var t=void 0!==this.settings.width?this.settings.width:this.settingsFromDOM.width;return"function"==typeof t?t():t},i.TableView.prototype.getHeight=function(){var t=void 0!==this.settings.height?this.settings.height:this.settingsFromDOM.height;return"function"==typeof t?t():t},i.TableView.prototype.beforeRender=function(t){t&&(this.instance.PluginHooks.run("beforeRender",this.instance.forceFullRender),this.wt.update("width",this.getWidth()),this.wt.update("height",this.getHeight()))},i.TableView.prototype.onDraw=function(t){t&&this.instance.PluginHooks.run("afterRender",this.instance.forceFullRender)},i.TableView.prototype.render=function(){this.wt.draw(!this.instance.forceFullRender),this.instance.forceFullRender=!1,this.instance.rootElement.triggerHandler("render.handsontable")},i.TableView.prototype.getCellAtCoords=function(t){var e=this.wt.wtTable.getCell([t.row,t.col]);return 0>e?null:e},i.TableView.prototype.scrollViewport=function(t){this.wt.scrollViewport([t.row,t.col])},i.TableView.prototype.appendRowHeader=function(t,e){if(t>-1)this.wt.wtDom.fastInnerHTML(e,this.instance.getRowHeader(t));else{var o=document.createElement("DIV");o.className="relative",this.wt.wtDom.fastInnerText(o," "),this.wt.wtDom.empty(e),e.appendChild(o)}},i.TableView.prototype.appendColHeader=function(t,e){var o=document.createElement("DIV"),i=document.createElement("SPAN");o.className="relative",i.className="colHeader",this.wt.wtDom.fastInnerHTML(i,this.instance.getColHeader(t)),o.appendChild(i),this.wt.wtDom.empty(e),e.appendChild(o),this.instance.PluginHooks.run("afterGetColHeader",t,e)},i.TableView.prototype.maximumVisibleElementWidth=function(t){var e=this.wt.wtViewport.getWorkspaceWidth();return this.settings.nativeScrollbars?e:e-t},i.TableView.prototype.maximumVisibleElementHeight=function(t){var e=this.wt.wtViewport.getWorkspaceHeight();return this.settings.nativeScrollbars?e:e-t},function(t){function e(t){var e,o;o={},e=t,this.getInstance=function(t){return t.guid in o||(o[t.guid]=new e(t)),o[t.guid]}}var o={},i=new WeakMap;t.editors={registerEditor:function(t,n){var s=new e(n);"string"==typeof t&&(o[t]=s),i.set(n,s)},getEditor:function(t,e){var n;if("function"==typeof t)i.get(t)||this.registerEditor(null,t),n=i.get(t);else{if("string"!=typeof t)throw Error('Only strings and functions can be passed as "editor" parameter ');n=o[t]}if(!n)throw Error('No editor registered under name "'+t+'"');return n.getInstance(e)}}}(i),function(t){t.EditorManager=function(e,o,i){var n,s=this,r=$(document),a=t.helper.keyCode,l=function(){function l(r){if(e.isListening()&&(o.settings.beforeOnKeyDown&&o.settings.beforeOnKeyDown.call(e,r),e.PluginHooks.run("beforeKeyDown",r),!r.isImmediatePropagationStopped()&&(o.lastKeyCode=r.keyCode,i.isSelected()))){var l=(r.ctrlKey||r.metaKey)&&!r.altKey;if(!(n.isWaiting()||t.helper.isMetaKey(r.keyCode)||l||s.isEditorOpened()))return s.openEditor(""),void r.stopPropagation();var c=r.shiftKey?i.setRangeEnd:i.setRangeStart;switch(r.keyCode){case a.A:if(l){i.selectAll(),r.preventDefault(),r.stopPropagation();break}case a.ARROW_UP:s.isEditorOpened()&&!n.isWaiting()&&s.closeEditorAndSaveChanges(l),u(r.shiftKey),r.preventDefault(),r.stopPropagation();break;case a.ARROW_DOWN:s.isEditorOpened()&&!n.isWaiting()&&s.closeEditorAndSaveChanges(l),d(r.shiftKey),r.preventDefault(),r.stopPropagation();break;case a.ARROW_RIGHT:s.isEditorOpened()&&!n.isWaiting()&&s.closeEditorAndSaveChanges(l),p(r.shiftKey),r.preventDefault(),r.stopPropagation();break;case a.ARROW_LEFT:s.isEditorOpened()&&!n.isWaiting()&&s.closeEditorAndSaveChanges(l),f(r.shiftKey),r.preventDefault(),r.stopPropagation();break;case a.TAB:var g="function"==typeof o.settings.tabMoves?o.settings.tabMoves(r):o.settings.tabMoves;r.shiftKey?i.transformStart(-g.row,-g.col):i.transformStart(g.row,g.col,!0),r.preventDefault(),r.stopPropagation();break;case a.BACKSPACE:case a.DELETE:i.empty(r),s.prepareEditor(),r.preventDefault();break;case a.F2:s.openEditor(),r.preventDefault();break;case a.ENTER:s.isEditorOpened()?(n.state!==t.EditorState.WAITING&&s.closeEditorAndSaveChanges(l),h(r.shiftKey)):e.getSettings().enterBeginsEditing?s.openEditor():h(r.shiftKey),r.preventDefault(),r.stopImmediatePropagation();break;case a.ESCAPE:s.isEditorOpened()&&s.closeEditorAndRestoreOriginalValue(l),r.preventDefault();break;case a.HOME:c(r.ctrlKey||r.metaKey?{row:0,col:o.selStart.col()}:{row:o.selStart.row(),col:0}),r.preventDefault(),r.stopPropagation();break;case a.END:c(r.ctrlKey||r.metaKey?{row:e.countRows()-1,col:o.selStart.col()}:{row:o.selStart.row(),col:e.countCols()-1}),r.preventDefault(),r.stopPropagation();break;case a.PAGE_UP:i.transformStart(-e.countVisibleRows(),0),e.view.wt.scrollVertical(-e.countVisibleRows()),e.view.render(),r.preventDefault(),r.stopPropagation();break;case a.PAGE_DOWN:i.transformStart(e.countVisibleRows(),0),e.view.wt.scrollVertical(e.countVisibleRows()),e.view.render(),r.preventDefault(),r.stopPropagation()}}}function c(){s.openEditor()}function h(t){var e="function"==typeof o.settings.enterMoves?o.settings.enterMoves(event):o.settings.enterMoves;t?i.transformStart(-e.row,-e.col):i.transformStart(e.row,e.col,!0)}function u(t){t?i.transformEnd(-1,0):i.transformStart(-1,0)}function d(t){t?i.transformEnd(1,0):i.transformStart(1,0)}function p(t){t?i.transformEnd(0,1):i.transformStart(0,1)}function f(t){t?i.transformEnd(0,-1):i.transformStart(0,-1)}r.on("keydown.handsontable."+e.guid,l),e.view.wt.update("onCellDblClick",c),e.addHook("afterDestroy",function(){r.off("keydown.handsontable."+e.guid)})};this.destroyEditor=function(t){this.closeEditor(t)},this.getActiveEditor=function(){return n},this.prepareEditor=function(){if(n&&n.isWaiting())return void this.closeEditor(!1,!1,function(t){t&&s.prepareEditor()});var i=o.selStart.row(),r=o.selStart.col(),a=e.colToProp(r),l=e.getCell(i,r),c=e.getDataAtCell(i,r),h=e.getCellMeta(i,r),u=e.getCellEditor(h);n=t.editors.getEditor(u,e),n.prepare(i,r,a,l,c,h)},this.isEditorOpened=function(){return n.isOpened()},this.openEditor=function(t){n.cellProperties.readOnly||n.beginEditing(t)},this.closeEditor=function(t,e,o){n?n.finishEditing(t,e,o):o&&o(!1)},this.closeEditorAndSaveChanges=function(t){return this.closeEditor(!1,t)},this.closeEditorAndRestoreOriginalValue=function(t){return this.closeEditor(!0,t)},l()}}(i),function(t){var e={};t.renderers={registerRenderer:function(t,o){e[t]=o},getRenderer:function(t){if("function"==typeof t)return t;if("string"!=typeof t)throw Error('Only strings and functions can be passed as "renderer" parameter ');if(!(t in e))throw Error('No editor registered under name "'+t+'"');return e[t]}}}(i),i.Dom=new v,i.helper.isPrintableChar=function(t){return 32==t||t>=48&&57>=t||t>=96&&111>=t||t>=186&&192>=t||t>=219&&222>=t||t>=226||t>=65&&90>=t},i.helper.isMetaKey=function(t){var e=i.helper.keyCode,o=[e.ARROW_DOWN,e.ARROW_UP,e.ARROW_LEFT,e.ARROW_RIGHT,e.HOME,e.END,e.DELETE,e.BACKSPACE,e.F1,e.F2,e.F3,e.F4,e.F5,e.F6,e.F7,e.F8,e.F9,e.F10,e.F11,e.F12,e.TAB,e.PAGE_DOWN,e.PAGE_UP,e.ENTER,e.ESCAPE,e.SHIFT,e.CAPS_LOCK,e.ALT];return-1!=o.indexOf(t)},i.helper.isCtrlKey=function(t){var e=i.helper.keyCode;return-1!=[e.CONTROL_LEFT,224,e.COMMAND_LEFT,e.COMMAND_RIGHT].indexOf(t)},i.helper.stringify=function(t){switch(typeof t){case"string":case"number":return t+"";case"object":return null===t?"":t.toString();case"undefined":return"";default:return t.toString()}},i.helper.spreadsheetColumnLabel=function(t){for(var e,o=t+1,i="";o>0;)e=(o-1)%26,i=String.fromCharCode(65+e)+i,o=parseInt((o-e)/26,10);return i},i.helper.isNumeric=function(t){var e=typeof t;return"number"==e?!isNaN(t)&&isFinite(t):"string"==e?t.length?1==t.length?/\d/.test(t):/^\s*[+-]?\s*(?:(?:\d+(?:\.\d+)?(?:e[+-]?\d+)?)|(?:0x[a-f\d]+))\s*$/i.test(t):!1:"object"==e?!(!t||"number"!=typeof t.valueOf()||t instanceof Date):!1},i.helper.isArray=function(t){return null!==Object.prototype.toString.call(t).match(/array/i)},i.helper.isDescendant=function(t,e){for(var o=e.parentNode;null!=o;){if(o==t)return!0;o=o.parentNode}return!1},i.helper.randomString=function(){return b()},i.helper.inherit=function(t,e){return e.prototype.constructor=e,t.prototype=new e,t.prototype.constructor=t,t},i.helper.extend=function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])},i.helper.getPrototypeOf=function(t){var e;if("object"==typeof t.__proto__)e=t.__proto__;else{var o,i=t.constructor;"function"==typeof t.constructor&&(o=i,delete t.constructor&&(i=t.constructor,t.constructor=o)),e=i?i.prototype:null}return e},i.helper.columnFactory=function(t,e){function o(){}i.helper.inherit(o,t);for(var n=0,s=e.length;s>n;n++)o.prototype[e[n]]=void 0;return o},i.helper.translateRowsToColumns=function(t){var e,o,i,n,s=[],r=0;for(e=0,o=t.length;o>e;e++)for(i=0,n=t[e].length;n>i;i++)i==r&&(s.push([]),r++),s[i].push(t[e][i]);return s},i.helper.to2dArray=function(t){for(var e=0,o=t.length;o>e;)t[e]=[t[e]],e++},i.helper.extendArray=function(t,e){for(var o=0,i=e.length;i>o;)t.push(e[o]),o++},i.helper.isInput=function(t){var e=["INPUT","SELECT","TEXTAREA"];return e.indexOf(t.nodeName)>-1},i.helper.isOutsideInput=function(t){return i.helper.isInput(t)&&-1==t.className.indexOf("handsontableInput")},i.helper.keyCode={MOUSE_LEFT:1,MOUSE_RIGHT:3,MOUSE_MIDDLE:2,BACKSPACE:8,COMMA:188,DELETE:46,END:35,ENTER:13,ESCAPE:27,CONTROL_LEFT:91,COMMAND_LEFT:17,COMMAND_RIGHT:93,ALT:18,HOME:36,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,SPACE:32,SHIFT:16,CAPS_LOCK:20,TAB:9,ARROW_RIGHT:39,ARROW_LEFT:37,ARROW_UP:38,ARROW_DOWN:40,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,A:65,X:88,C:67,
V:86},i.helper.isObject=function(t){return"[object Object]"==Object.prototype.toString.call(t)},i.helper.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"==Object.prototype.toString.call(t)},i.helper.pivot=function(t){var e=[];if(!t||0==t.length||!t[0]||0==t[0].length)return e;for(var o=t.length,i=t[0].length,n=0;o>n;n++)for(var s=0;i>s;s++)e[s]||(e[s]=[]),e[s][n]=t[n][s];return e},i.helper.proxy=function(t,e){return function(){return t.apply(e,arguments)}},i.helper.cellMethodLookupFactory=function(t,e){function o(t){var e=i.cellTypes[t];if("undefined"==typeof e)throw new Error('You declared cell type "'+t+'" as a string that is not mapped to a known object. Cell type must be an object or a string mapped to an object in Handsontable.cellTypes');return e}return e="undefined"==typeof e?!0:e,function(n,s){return function r(n){if(n){if(n.hasOwnProperty(t)&&n[t])return n[t];if(n.hasOwnProperty("type")&&n.type){var s;if("string"!=typeof n.type)throw new Error("Cell type must be a string ");if(s=o(n.type),s.hasOwnProperty(t))return s[t];if(e)return}return r(i.helper.getPrototypeOf(n))}}("number"==typeof n?this.getCellMeta(n,s):n)}},i.helper.toString=function(t){return""+t},i.SelectionPoint=function(){this._row=null,this._col=null},i.SelectionPoint.prototype.exists=function(){return null!==this._row},i.SelectionPoint.prototype.row=function(t){return void 0!==t&&(this._row=t),this._row},i.SelectionPoint.prototype.col=function(t){return void 0!==t&&(this._col=t),this._col},i.SelectionPoint.prototype.coords=function(t){return void 0!==t&&(this._row=t.row,this._col=t.col),{row:this._row,col:this._col}},i.SelectionPoint.prototype.arr=function(t){return void 0!==t&&(this._row=t[0],this._col=t[1]),[this._row,this._col]},function(t){t.DataMap=function(t,e,o){this.instance=t,this.priv=e,this.GridSettings=o,this.dataSource=this.instance.getSettings().data,this.dataSource[0]?this.duckSchema=this.recursiveDuckSchema(this.dataSource[0]):this.duckSchema={},this.createMap(),this.getVars={},this.setVars={}},t.DataMap.prototype.DESTINATION_RENDERER=1,t.DataMap.prototype.DESTINATION_CLIPBOARD_GENERATOR=2,t.DataMap.prototype.recursiveDuckSchema=function(t){var e;if($.isPlainObject(t)){e={};for(var o in t)t.hasOwnProperty(o)&&($.isPlainObject(t[o])?e[o]=this.recursiveDuckSchema(t[o]):e[o]=null)}else e=[];return e},t.DataMap.prototype.recursiveDuckColumns=function(t,e,o){var i,n;if("undefined"==typeof e&&(e=0,o=""),$.isPlainObject(t))for(n in t)t.hasOwnProperty(n)&&(null===t[n]?(i=o+n,this.colToPropCache.push(i),this.propToColCache.set(i,e),e++):e=this.recursiveDuckColumns(t[n],e,n+"."));return e},t.DataMap.prototype.createMap=function(){if("undefined"==typeof this.getSchema())throw new Error("trying to create `columns` definition but you didnt' provide `schema` nor `data`");var t,e,o=this.getSchema();this.colToPropCache=[],this.propToColCache=new MultiMap;var i=this.instance.getSettings().columns;if(i)for(t=0,e=i.length;e>t;t++)"undefined"!=typeof i[t].data&&(this.colToPropCache[t]=i[t].data,this.propToColCache.set(i[t].data,t));else this.recursiveDuckColumns(o)},t.DataMap.prototype.colToProp=function(e){return e=t.PluginHooks.execute(this.instance,"modifyCol",e),this.colToPropCache&&"undefined"!=typeof this.colToPropCache[e]?this.colToPropCache[e]:e},t.DataMap.prototype.propToCol=function(e){var o;return o="undefined"!=typeof this.propToColCache.get(e)?this.propToColCache.get(e):e,o=t.PluginHooks.execute(this.instance,"modifyCol",o)},t.DataMap.prototype.getSchema=function(){var t=this.instance.getSettings().dataSchema;return t?"function"==typeof t?t():t:this.duckSchema},t.DataMap.prototype.createRow=function(t,e,o){var i,n,s=this.instance.countCols(),r=0;e||(e=1),("number"!=typeof t||t>=this.instance.countRows())&&(t=this.instance.countRows()),n=t;for(var a=this.instance.getSettings().maxRows;e>r&&this.instance.countRows()<a;){if("array"===this.instance.dataType){i=[];for(var l=0;s>l;l++)i.push(null)}else i="function"===this.instance.dataType?this.instance.getSettings().dataSchema(t):$.extend(!0,{},this.getSchema());t===this.instance.countRows()?this.dataSource.push(i):this.dataSource.splice(t,0,i),r++,n++}return this.instance.PluginHooks.run("afterCreateRow",t,r,o),this.instance.forceFullRender=!0,r},t.DataMap.prototype.createCol=function(e,o,i){if("object"===this.instance.dataType||this.instance.getSettings().columns)throw new Error("Cannot create new column. When data source in an object, you can only have as much columns as defined in first data row, data schema or in the 'columns' setting.If you want to be able to add new columns, you have to use array datasource.");var n,s,r=this.instance.countRows(),a=this.dataSource,l=0;o||(o=1),s=e;for(var c=this.instance.getSettings().maxCols;o>l&&this.instance.countCols()<c;){if(n=t.helper.columnFactory(this.GridSettings,this.priv.columnsSettingConflicts),"number"!=typeof e||e>=this.instance.countCols()){for(var h=0;r>h;h++)"undefined"==typeof a[h]&&(a[h]=[]),a[h].push(null);this.priv.columnSettings.push(n)}else{for(var h=0;r>h;h++)a[h].splice(s,0,null);this.priv.columnSettings.splice(s,0,n)}l++,s++}return this.instance.PluginHooks.run("afterCreateCol",e,l,i),this.instance.forceFullRender=!0,l},t.DataMap.prototype.removeRow=function(t,e){e||(e=1),"number"!=typeof t&&(t=-e),t=(this.instance.countRows()+t)%this.instance.countRows();var o=this.physicalRowsToLogical(t,e),i=this.instance.PluginHooks.execute("beforeRemoveRow",t,e);if(i!==!1){var n=this.dataSource,s=n.filter(function(t,e){return-1==o.indexOf(e)});n.length=0,Array.prototype.push.apply(n,s),this.instance.PluginHooks.run("afterRemoveRow",t,e),this.instance.forceFullRender=!0}},t.DataMap.prototype.removeCol=function(t,e){if("object"===this.instance.dataType||this.instance.getSettings().columns)throw new Error("cannot remove column with object data source or columns option specified");e||(e=1),"number"!=typeof t&&(t=-e),t=(this.instance.countCols()+t)%this.instance.countCols();var o=this.instance.PluginHooks.execute("beforeRemoveCol",t,e);if(o!==!1){for(var i=this.dataSource,n=0,s=this.instance.countRows();s>n;n++)i[n].splice(t,e);this.priv.columnSettings.splice(t,e),this.instance.PluginHooks.run("afterRemoveCol",t,e),this.instance.forceFullRender=!0}},t.DataMap.prototype.spliceCol=function(e,o,i){var n=4<=arguments.length?[].slice.call(arguments,3):[],s=this.instance.getDataAtCol(e),r=s.slice(o,o+i),a=s.slice(o+i);t.helper.extendArray(n,a);for(var l=0;i>l;)n.push(null),l++;return t.helper.to2dArray(n),this.instance.populateFromArray(o,e,n,null,null,"spliceCol"),r},t.DataMap.prototype.spliceRow=function(e,o,i){var n=4<=arguments.length?[].slice.call(arguments,3):[],s=this.instance.getDataAtRow(e),r=s.slice(o,o+i),a=s.slice(o+i);t.helper.extendArray(n,a);for(var l=0;i>l;)n.push(null),l++;return this.instance.populateFromArray(e,o,[n],null,null,"spliceRow"),r},t.DataMap.prototype.get=function(t,e){if(this.getVars.row=t,this.getVars.prop=e,this.instance.PluginHooks.run("beforeGet",this.getVars),"string"==typeof this.getVars.prop&&this.getVars.prop.indexOf(".")>-1){var o=this.getVars.prop.split("."),i=this.dataSource[this.getVars.row];if(!i)return null;for(var n=0,s=o.length;s>n;n++)if(i=i[o[n]],"undefined"==typeof i)return null;return i}return"function"==typeof this.getVars.prop?this.getVars.prop(this.dataSource.slice(this.getVars.row,this.getVars.row+1)[0]):this.dataSource[this.getVars.row]?this.dataSource[this.getVars.row][this.getVars.prop]:null};var e=t.helper.cellMethodLookupFactory("copyable",!1);t.DataMap.prototype.getCopyable=function(t,o){return e.call(this.instance,t,this.propToCol(o))?this.get(t,o):""},t.DataMap.prototype.set=function(t,e,o,i){if(this.setVars.row=t,this.setVars.prop=e,this.setVars.value=o,this.instance.PluginHooks.run("beforeSet",this.setVars,i||"datamapGet"),"string"==typeof this.setVars.prop&&this.setVars.prop.indexOf(".")>-1){for(var n=this.setVars.prop.split("."),s=this.dataSource[this.setVars.row],r=0,a=n.length-1;a>r;r++)s=s[n[r]];s[n[r]]=this.setVars.value}else"function"==typeof this.setVars.prop?this.setVars.prop(this.dataSource.slice(this.setVars.row,this.setVars.row+1)[0],this.setVars.value):this.dataSource[this.setVars.row][this.setVars.prop]=this.setVars.value},t.DataMap.prototype.physicalRowsToLogical=function(t,e){for(var o=this.instance.countRows(),i=(o+t)%o,n=[],s=e;o>i&&s;)this.get(i,0),n.push(this.getVars.row),s--,i++;return n},t.DataMap.prototype.clear=function(){for(var t=0;t<this.instance.countRows();t++)for(var e=0;e<this.instance.countCols();e++)this.set(t,this.colToProp(e),"")},t.DataMap.prototype.getAll=function(){return this.dataSource},t.DataMap.prototype.getRange=function(t,e,o){var i,n,s,r,a,l=[],c=o===this.DESTINATION_CLIPBOARD_GENERATOR?this.getCopyable:this.get;for(n=Math.max(t.row,e.row),r=Math.max(t.col,e.col),i=Math.min(t.row,e.row);n>=i;i++){for(a=[],s=Math.min(t.col,e.col);r>=s;s++)a.push(c.call(this,i,this.colToProp(s)));l.push(a)}return l},t.DataMap.prototype.getText=function(t,e){return SheetClip.stringify(this.getRange(t,e,this.DESTINATION_RENDERER))},t.DataMap.prototype.getCopyableText=function(t,e){return SheetClip.stringify(this.getRange(t,e,this.DESTINATION_CLIPBOARD_GENERATOR))}}(i),function(t){t.renderers.cellDecorator=function(t,e,o,i,n,s,r){r.readOnly&&t.view.wt.wtDom.addClass(e,r.readOnlyCellClassName),r.valid===!1&&r.invalidCellClassName&&t.view.wt.wtDom.addClass(e,r.invalidCellClassName),!s&&r.placeholder&&t.view.wt.wtDom.addClass(e,r.placeholderCellClassName)}}(i),function(t){var e=function(e,o,i,n,s,r,a){t.renderers.cellDecorator.apply(this,arguments),!r&&a.placeholder&&(r=a.placeholder);var l=t.helper.stringify(r);if(a.rendererTemplate){e.view.wt.wtDom.empty(o);var c=document.createElement("TEMPLATE");c.setAttribute("bind","{{}}"),c.innerHTML=a.rendererTemplate,HTMLTemplateElement.decorate(c),c.model=e.getDataAtRow(i),o.appendChild(c)}else e.view.wt.wtDom.fastInnerText(o,l)};t.renderers.TextRenderer=e,t.renderers.registerRenderer("text",e)}(i),function(t){var e=document.createElement("DIV");e.className="htAutocompleteWrapper";var o=document.createElement("DIV");o.className="htAutocompleteArrow",o.appendChild(document.createTextNode("▼"));var i=function(i,n,s,r,a,l,c){var h=(e.cloneNode(!0),o.cloneNode(!0));t.renderers.TextRenderer(i,n,s,r,a,l,c),n.appendChild(h),t.Dom.addClass(n,"htAutocomplete"),n.firstChild||n.appendChild(document.createTextNode(" ")),i.acArrowListener||(i.acArrowListener=function(){i.view.wt.getSetting("onCellDblClick")},i.rootElement.on("mousedown.htAutocompleteArrow",".htAutocompleteArrow",i.acArrowListener),i.addHookOnce("afterDestroy",function(){this.rootElement.off("mousedown.htAutocompleteArrow")}))};t.AutocompleteRenderer=i,t.renderers.AutocompleteRenderer=i,t.renderers.registerRenderer("autocomplete",i)}(i),function(t){var e=document.createElement("INPUT");e.className="htCheckboxRendererInput",e.type="checkbox",e.setAttribute("autocomplete","off");var o=function(o,i,n,s,r,a,l){"undefined"==typeof l.checkedTemplate&&(l.checkedTemplate=!0),"undefined"==typeof l.uncheckedTemplate&&(l.uncheckedTemplate=!1),o.view.wt.wtDom.empty(i);var c=e.cloneNode(!1);a===l.checkedTemplate||a===t.helper.stringify(l.checkedTemplate)?(c.checked=!0,i.appendChild(c)):a===l.uncheckedTemplate||a===t.helper.stringify(l.uncheckedTemplate)?i.appendChild(c):null===a?(c.className+=" noValue",i.appendChild(c)):o.view.wt.wtDom.fastInnerText(i,"#bad value#");var h=$(c);l.readOnly?h.on("click",function(t){t.preventDefault()}):(h.on("mousedown",function(t){t.stopPropagation()}),h.on("mouseup",function(t){t.stopPropagation()}),h.on("change",function(){this.checked?o.setDataAtRowProp(n,r,l.checkedTemplate):o.setDataAtRowProp(n,r,l.uncheckedTemplate)})),o.CheckboxRenderer&&o.CheckboxRenderer.beforeKeyDownHookBound||(o.CheckboxRenderer={beforeKeyDownHookBound:!0},o.addHook("beforeKeyDown",function(e){if(e.keyCode==t.helper.keyCode.SPACE)for(var i,n,s,r=o.getSelected(),a={row:Math.min(r[0],r[2]),col:Math.min(r[1],r[3])},l={row:Math.max(r[0],r[2]),col:Math.max(r[1],r[3])},c=a.row;c<=l.row;c++)for(var h=l.col;h<=l.col;h++)if(i=o.getCell(c,h),s=o.getCellMeta(c,h),n=i.querySelectorAll("input[type=checkbox]"),n.length>0&&!s.readOnly){e.isImmediatePropagationStopped()||(e.stopImmediatePropagation(),e.preventDefault());for(var u=0,d=n.length;d>u;u++)n[u].checked=!n[u].checked,$(n[u]).trigger("change")}}))};t.CheckboxRenderer=o,t.renderers.CheckboxRenderer=o,t.renderers.registerRenderer("checkbox",o)}(i),function(t){var o=function(o,i,n,s,r,a,l){t.helper.isNumeric(a)&&("undefined"!=typeof l.language&&e.language(l.language),a=e(a).format(l.format||"0"),o.view.wt.wtDom.addClass(i,"htNumeric")),t.renderers.TextRenderer(o,i,n,s,r,a,l)};t.NumericRenderer=o,t.renderers.NumericRenderer=o,t.renderers.registerRenderer("numeric",o)}(i),function(t){var e=function(t,e,o,n,s,r,a){i.renderers.TextRenderer.apply(this,arguments),r=e.innerHTML;var l,c=a.hashLength||r.length,h=a.hashSymbol||"*";for(l="";l.split(h).length-1<c;l+=h);t.view.wt.wtDom.fastInnerHTML(e,l)};t.PasswordRenderer=e,t.renderers.PasswordRenderer=e,t.renderers.registerRenderer("password",e)}(i),function(t){function e(e,o,i,n,s,r,a){t.renderers.cellDecorator.apply(this,arguments),t.Dom.fastInnerHTML(o,r)}t.renderers.registerRenderer("html",e),t.renderers.HtmlRenderer=e}(i),function(t){function e(e){this.instance=e,this.state=t.EditorState.VIRGIN,this._opened=!1,this._closeCallback=null,this.init()}t.EditorState={VIRGIN:"STATE_VIRGIN",EDITING:"STATE_EDITING",WAITING:"STATE_WAITING",FINISHED:"STATE_FINISHED"},e.prototype._fireCallbacks=function(t){this._closeCallback&&(this._closeCallback(t),this._closeCallback=null)},e.prototype.init=function(){},e.prototype.getValue=function(){throw Error("Editor getValue() method unimplemented")},e.prototype.setValue=function(t){throw Error("Editor setValue() method unimplemented")},e.prototype.open=function(){throw Error("Editor open() method unimplemented")},e.prototype.close=function(){throw Error("Editor close() method unimplemented")},e.prototype.prepare=function(e,o,i,n,s,r){this.TD=n,this.row=e,this.col=o,this.prop=i,this.originalValue=s,this.cellProperties=r,this.state=t.EditorState.VIRGIN},e.prototype.extend=function(){function t(){o.apply(this,arguments)}function e(t,e){function o(){}return o.prototype=e.prototype,t.prototype=new o,t.prototype.constructor=t,t}var o=this.constructor;return e(t,o)},e.prototype.saveValue=function(t,e){if(e){var o=this.instance.getSelected();this.instance.populateFromArray(o[0],o[1],t,o[2],o[3],"edit")}else this.instance.populateFromArray(this.row,this.col,t,null,null,"edit")},e.prototype.beginEditing=function(e){this.state==t.EditorState.VIRGIN&&(this.instance.view.scrollViewport({row:this.row,col:this.col}),this.instance.view.render(),this.state=t.EditorState.EDITING,e="string"==typeof e?e:this.originalValue,this.setValue(t.helper.stringify(e)),this.open(),this._opened=!0,this.focus(),this.instance.view.render())},e.prototype.finishEditing=function(e,o,i){if(i){var n=this._closeCallback;this._closeCallback=function(t){n&&n(t),i(t)}}if(!this.isWaiting()){if(this.state==t.EditorState.VIRGIN){var s=this;return void setTimeout(function(){s._fireCallbacks(!0)})}if(this.state==t.EditorState.EDITING){if(e)return void this.cancelChanges();var r=[this.instance.getSettings().trimWhitespace?[this.getValue()+""]:[String.prototype.trim.call(this.getValue())]];if(this.state=t.EditorState.WAITING,this.saveValue(r,o),this.instance.getCellValidator(this.cellProperties)){var s=this;this.instance.addHookOnce("afterValidate",function(e){s.state=t.EditorState.FINISHED,s.discardEditor(e)})}else this.state=t.EditorState.FINISHED,this.discardEditor(!0)}}},e.prototype.cancelChanges=function(){this.state=t.EditorState.FINISHED,this.discardEditor()},e.prototype.discardEditor=function(e){this.state===t.EditorState.FINISHED&&(e===!1&&this.cellProperties.allowInvalid!==!0?(this.instance.selectCell(this.row,this.col),this.focus(),this.state=t.EditorState.EDITING,this._fireCallbacks(!1)):(this.close(),this._opened=!1,this.state=t.EditorState.VIRGIN,this._fireCallbacks(!0)))},e.prototype.isOpened=function(){return this._opened},e.prototype.isWaiting=function(){return this.state===t.EditorState.WAITING},t.editors.BaseEditor=e}(i),function(t){var e=t.editors.BaseEditor.prototype.extend();e.prototype.init=function(){this.createElements(),this.bindEvents()},e.prototype.getValue=function(){return this.TEXTAREA.value},e.prototype.setValue=function(t){this.TEXTAREA.value=t};var o=function(e){var o=this,i=o.getActiveEditor(),n=t.helper.keyCode,s=(e.ctrlKey||e.metaKey)&&!e.altKey;if(e.target===i.TEXTAREA&&!e.isImmediatePropagationStopped()){if(17===e.keyCode||224===e.keyCode||91===e.keyCode||93===e.keyCode)return void e.stopImmediatePropagation();switch(e.keyCode){case n.ARROW_RIGHT:i.wtDom.getCaretPosition(i.TEXTAREA)!==i.TEXTAREA.value.length&&e.stopImmediatePropagation();break;case n.ARROW_LEFT:0!==i.wtDom.getCaretPosition(i.TEXTAREA)&&e.stopImmediatePropagation();break;case n.ENTER:var r=i.instance.getSelected(),a=!(r[0]===r[2]&&r[1]===r[3]);(s&&!a||e.altKey)&&(i.isOpened()?(i.setValue(i.getValue()+"\n"),i.focus()):i.beginEditing(i.originalValue+"\n"),e.stopImmediatePropagation()),e.preventDefault();break;case n.A:case n.X:case n.C:case n.V:if(s){e.stopImmediatePropagation();break}case n.BACKSPACE:case n.DELETE:case n.HOME:case n.END:e.stopImmediatePropagation()}}};e.prototype.open=function(){this.refreshDimensions(),this.instance.addHook("beforeKeyDown",o)},e.prototype.close=function(){this.textareaParentStyle.display="none",document.activeElement===this.TEXTAREA&&this.instance.listen(),this.instance.removeHook("beforeKeyDown",o)},e.prototype.focus=function(){this.TEXTAREA.focus(),this.wtDom.setCaretPosition(this.TEXTAREA,this.TEXTAREA.value.length)},e.prototype.createElements=function(){this.$body=$(document.body),this.wtDom=new v,this.TEXTAREA=document.createElement("TEXTAREA"),this.$textarea=$(this.TEXTAREA),this.wtDom.addClass(this.TEXTAREA,"handsontableInput"),this.textareaStyle=this.TEXTAREA.style,this.textareaStyle.width=0,this.textareaStyle.height=0,this.TEXTAREA_PARENT=document.createElement("DIV"),this.wtDom.addClass(this.TEXTAREA_PARENT,"handsontableInputHolder"),this.textareaParentStyle=this.TEXTAREA_PARENT.style,this.textareaParentStyle.top=0,this.textareaParentStyle.left=0,this.textareaParentStyle.display="none",this.TEXTAREA_PARENT.appendChild(this.TEXTAREA),this.instance.rootElement[0].appendChild(this.TEXTAREA_PARENT);var e=this;t.PluginHooks.add("afterRender",function(){e.instance.registerTimeout("refresh_editor_dimensions",function(){e.refreshDimensions()},0)})},e.prototype.refreshDimensions=function(){if(this.state===t.EditorState.EDITING&&(this.TD=this.instance.getCell(this.row,this.col),this.TD)){var e=$(this.TD),o=this.wtDom.offset(this.TD),i=this.wtDom.offset(this.instance.rootElement[0]),n=this.instance.rootElement.scrollTop(),s=this.instance.rootElement.scrollLeft(),r=o.top-i.top+n-1,a=o.left-i.left+s-1,l=this.instance.getSettings(),c=l.rowHeaders===!1?0:1,h=l.colHeaders===!1?0:1;0>r&&(r=0),0>a&&(a=0),c>0&&parseInt(e.css("border-top-width"),10)>0&&(r+=1),h>0&&parseInt(e.css("border-left-width"),10)>0&&(a+=1),this.textareaParentStyle.top=r+"px",this.textareaParentStyle.left=a+"px";var u=e.width(),d=this.instance.view.maximumVisibleElementWidth(a)-10,p=e.outerHeight()-4,f=this.instance.view.maximumVisibleElementHeight(r)-5;parseInt(e.css("border-top-width"),10)>0&&(p-=1),parseInt(e.css("border-left-width"),10)>0&&c>0&&(u-=1),this.$textarea.autoResize({minHeight:Math.min(p,f),maxHeight:f,minWidth:Math.min(u,d),maxWidth:d,animate:!1,extraSpace:0}),this.textareaParentStyle.display="block"}},e.prototype.bindEvents=function(){this.$textarea.on("cut.editor",function(t){t.stopPropagation()}),this.$textarea.on("paste.editor",function(t){t.stopPropagation()})},t.editors.TextEditor=e,t.editors.registerEditor("text",t.editors.TextEditor)}(i),function(t){var e=t.editors.BaseEditor.prototype.extend();e.prototype.beginEditing=function(){var t=this.TD.querySelector('input[type="checkbox"]');t&&$(t).trigger("click")},e.prototype.finishEditing=function(){},e.prototype.init=function(){},e.prototype.open=function(){},e.prototype.close=function(){},e.prototype.getValue=function(){},e.prototype.setValue=function(){},e.prototype.focus=function(){},t.editors.CheckboxEditor=e,t.editors.registerEditor("checkbox",e)}(i),function(t){var e=t.editors.TextEditor.prototype.extend();e.prototype.init=function(){if(!$.datepicker)throw new Error("jQuery UI Datepicker dependency not found. Did you forget to include jquery-ui.custom.js or its substitute?");t.editors.TextEditor.prototype.init.apply(this,arguments),this.isCellEdited=!1;var e=this;this.instance.addHook("afterDestroy",function(){e.destroyElements()})},e.prototype.createElements=function(){t.editors.TextEditor.prototype.createElements.apply(this,arguments),this.datePicker=document.createElement("DIV"),this.instance.view.wt.wtDom.addClass(this.datePicker,"htDatepickerHolder"),this.datePickerStyle=this.datePicker.style,this.datePickerStyle.position="absolute",this.datePickerStyle.top=0,this.datePickerStyle.left=0,this.datePickerStyle.zIndex=99,document.body.appendChild(this.datePicker),this.$datePicker=$(this.datePicker);var e=this,o={dateFormat:"yy-mm-dd",showButtonPanel:!0,changeMonth:!0,changeYear:!0,onSelect:function(t){e.setValue(t),e.finishEditing(!1)}};this.$datePicker.datepicker(o),this.$datePicker.on("mousedown",function(t){t.stopPropagation()}),this.hideDatepicker()},e.prototype.destroyElements=function(){this.$datePicker.datepicker("destroy"),this.$datePicker.remove()},e.prototype.open=function(){t.editors.TextEditor.prototype.open.call(this),this.showDatepicker()},e.prototype.finishEditing=function(e,o){this.hideDatepicker(),t.editors.TextEditor.prototype.finishEditing.apply(this,arguments)},e.prototype.showDatepicker=function(){var t=$(this.TD),e=t.offset();this.datePickerStyle.top=e.top+t.height()+"px",this.datePickerStyle.left=e.left+"px";var o={defaultDate:this.originalValue||void 0};$.extend(o,this.cellProperties),this.$datePicker.datepicker("option",o),this.originalValue&&this.$datePicker.datepicker("setDate",this.originalValue),this.datePickerStyle.display="block"},e.prototype.hideDatepicker=function(){this.datePickerStyle.display="none"},t.editors.DateEditor=e,t.editors.registerEditor("date",e)}(i),function(t){var e=t.editors.TextEditor.prototype.extend();e.prototype.createElements=function(){t.editors.TextEditor.prototype.createElements.apply(this,arguments);var e=document.createElement("DIV");e.className="handsontableEditor",this.TEXTAREA_PARENT.appendChild(e),this.$htContainer=$(e),this.$htContainer.handsontable()},e.prototype.prepare=function(e,o,i,n,s,r){t.editors.TextEditor.prototype.prepare.apply(this,arguments);var a=this,l={startRows:0,startCols:0,minRows:0,minCols:0,className:"listbox",copyPaste:!1,cells:function(){return{readOnly:!0}},fillHandle:!1,afterOnCellMouseDown:function(){var t=this.getValue();void 0!==t&&a.setValue(t),a.instance.destroyEditor()},beforeOnKeyDown:function(e){var o=this;switch(e.keyCode){case t.helper.keyCode.ESCAPE:a.instance.destroyEditor(!0),e.stopImmediatePropagation(),e.preventDefault();break;case t.helper.keyCode.ENTER:var i=o.getSelected(),n=this.getDataAtCell(i[0],i[1]);void 0!==n&&a.setValue(n),a.instance.destroyEditor();break;case t.helper.keyCode.ARROW_UP:o.getSelected()&&0==o.getSelected()[0]&&!a.cellProperties.strict&&(o.deselectCell(),a.instance.listen(),a.focus(),e.preventDefault(),e.stopImmediatePropagation())}}};this.cellProperties.handsontable&&(l=$.extend(l,r.handsontable)),this.$htContainer.handsontable("destroy"),this.$htContainer.handsontable(l)};var o=function(e){if(!e.isImmediatePropagationStopped()){var o=this.getActiveEditor(),i=o.$htContainer.handsontable("getInstance");if(e.keyCode==t.helper.keyCode.ARROW_DOWN){if(i.getSelected()){var n=i.getSelected()[0],s=n<i.countRows()-1?n+1:n;i.selectCell(s,0)}else i.selectCell(0,0);e.preventDefault(),e.stopImmediatePropagation()}}};e.prototype.open=function(){this.instance.addHook("beforeKeyDown",o),t.editors.TextEditor.prototype.open.apply(this,arguments),this.$htContainer.handsontable("render"),this.cellProperties.strict?(this.$htContainer.handsontable("selectCell",0,0),this.$textarea[0].style.visibility="hidden"):(this.$htContainer.handsontable("deselectCell"),this.$textarea[0].style.visibility="visible"),this.wtDom.setCaretPosition(this.$textarea[0],0,this.$textarea[0].value.length)},e.prototype.close=function(){this.instance.removeHook("beforeKeyDown",o),this.instance.listen(),t.editors.TextEditor.prototype.close.apply(this,arguments)},e.prototype.focus=function(){this.instance.listen(),t.editors.TextEditor.prototype.focus.apply(this,arguments)},e.prototype.beginEditing=function(e){var o=this.instance.getSettings().onBeginEditing;o&&o()===!1||t.editors.TextEditor.prototype.beginEditing.apply(this,arguments)},e.prototype.finishEditing=function(e,o){if(this.$htContainer.handsontable("isListening")&&this.instance.listen(),this.$htContainer.handsontable("getSelected")){var i=this.$htContainer.handsontable("getInstance").getValue();void 0!==i&&this.setValue(i)}return t.editors.TextEditor.prototype.finishEditing.apply(this,arguments)},t.editors.HandsontableEditor=e,t.editors.registerEditor("handsontable",e)}(i),function(t){var e=t.editors.HandsontableEditor.prototype.extend();e.prototype.init=function(){t.editors.HandsontableEditor.prototype.init.apply(this,arguments),this.query=null,this.choices=[]},e.prototype.createElements=function(){t.editors.HandsontableEditor.prototype.createElements.apply(this,arguments),this.$htContainer.addClass("autocompleteEditor")},e.prototype.bindEvents=function(){var e=this;this.$textarea.on("keydown.autocompleteEditor",function(o){t.helper.isMetaKey(o.keyCode)&&-1==[t.helper.keyCode.BACKSPACE,t.helper.keyCode.DELETE].indexOf(o.keyCode)?o.keyCode==t.helper.keyCode.ENTER&&e.cellProperties.strict!==!0&&e.$htContainer.handsontable("deselectCell"):setTimeout(function(){e.queryChoices(e.$textarea.val())})}),this.$htContainer.on("mouseleave",function(){e.cellProperties.strict===!0&&e.highlightBestMatchingChoice()}),this.$htContainer.on("mouseenter",function(){e.$htContainer.handsontable("deselectCell")}),t.editors.HandsontableEditor.prototype.bindEvents.apply(this,arguments)};var o;e.prototype.open=function(){t.editors.HandsontableEditor.prototype.open.apply(this,arguments),this.$textarea[0].style.visibility="visible",this.focus();var e=this.$htContainer.handsontable("getInstance"),i=this;e.updateSettings({colWidths:[this.wtDom.outerWidth(this.TEXTAREA)-2],afterRenderer:function(t,e,o,n,s){var r=this.getCellMeta(e,o).filteringCaseSensitive===!0,a=r?s.indexOf(this.query):s.toLowerCase().indexOf(i.query.toLowerCase());if(-1!=a){var l=s.substr(a,i.query.length);t.innerHTML=s.replace(l,"<strong>"+l+"</strong>")}}}),o=function(e){var o=this;e.keyCode==t.helper.keyCode.ARROW_UP&&o.getSelected()&&0==o.getSelected()[0]&&(parent.cellProperties.strict||o.deselectCell(),parent.instance.listen(),parent.focus(),e.preventDefault(),e.stopImmediatePropagation())},e.addHook("beforeKeyDown",o),this.queryChoices(this.TEXTAREA.value)},e.prototype.close=function(){this.$htContainer.handsontable("getInstance").removeHook("beforeKeyDown",o),t.editors.HandsontableEditor.prototype.close.apply(this,arguments)},e.prototype.queryChoices=function(e){if(this.query=e,"function"==typeof this.cellProperties.source){var o=this;this.cellProperties.source(e,function(t){o.updateChoicesList(t)})}else if(t.helper.isArray(this.cellProperties.source)){var i;if(e&&this.cellProperties.filter!==!1){var n=this.cellProperties.filteringCaseSensitive===!0,s=e.toLowerCase();i=this.cellProperties.source.filter(function(t){return n?-1!=t.indexOf(e):-1!=t.toLowerCase().indexOf(s)})}else i=this.cellProperties.source;this.updateChoicesList(i)}else this.updateChoicesList([])},e.prototype.updateChoicesList=function(e){this.choices=e,this.$htContainer.handsontable("loadData",t.helper.pivot([e])),this.cellProperties.strict===!0&&this.highlightBestMatchingChoice(),this.focus()},e.prototype.highlightBestMatchingChoice=function(){var t=this.findBestMatchingChoice();"undefined"==typeof t&&this.cellProperties.allowInvalid===!1&&(t=0),"undefined"==typeof t?this.$htContainer.handsontable("deselectCell"):this.$htContainer.handsontable("selectCell",t,0)},e.prototype.findBestMatchingChoice=function(){for(var t,e,o,i={},n=this.getValue().length,s=0,r=this.choices.length;r>s;s++)t=this.choices[s],e=n>0?t.indexOf(this.getValue()):t===this.getValue()?0:-1,-1!=e&&(o=t.length-e-n,("undefined"==typeof i.indexOfValue||i.indexOfValue>e||i.indexOfValue==e&&i.charsLeft>o)&&(i.indexOfValue=e,i.charsLeft=o,i.index=s));return i.index},t.editors.AutocompleteEditor=e,t.editors.registerEditor("autocomplete",e)}(i),function(t){var e=t.editors.TextEditor.prototype.extend(),o=new v;e.prototype.createElements=function(){t.editors.TextEditor.prototype.createElements.apply(this,arguments),this.TEXTAREA=document.createElement("input"),this.TEXTAREA.setAttribute("type","password"),this.TEXTAREA.className="handsontableInput",this.textareaStyle=this.TEXTAREA.style,this.textareaStyle.width=0,this.textareaStyle.height=0,this.$textarea=$(this.TEXTAREA),o.empty(this.TEXTAREA_PARENT),this.TEXTAREA_PARENT.appendChild(this.TEXTAREA)},t.editors.PasswordEditor=e,t.editors.registerEditor("password",e)}(i),function(t){var e=t.editors.BaseEditor.prototype.extend();e.prototype.init=function(){this.select=document.createElement("SELECT"),t.Dom.addClass(this.select,"htSelectEditor"),this.select.style.display="none",this.instance.rootElement[0].appendChild(this.select)},e.prototype.prepare=function(){t.editors.BaseEditor.prototype.prepare.apply(this,arguments);var e,o=this.cellProperties.selectOptions;e="function"==typeof o?this.prepareOptions(o(this.row,this.col,this.prop)):this.prepareOptions(o),t.Dom.empty(this.select);for(var i in e)if(e.hasOwnProperty(i)){var n=document.createElement("OPTION");n.value=i,t.Dom.fastInnerHTML(n,e[i]),this.select.appendChild(n)}},e.prototype.prepareOptions=function(e){var o={};if(t.helper.isArray(e))for(var i=0,n=e.length;n>i;i++)o[e[i]]=e[i];else"object"==typeof e&&(o=e);return o},e.prototype.getValue=function(){return this.select.value},e.prototype.setValue=function(t){this.select.value=t};var o=function(e){var o=this,i=o.getActiveEditor();switch(e.keyCode){case t.helper.keyCode.ARROW_UP:var n=i.select.find("option:selected").prev();1==n.length&&n.prop("selected",!0),e.stopImmediatePropagation(),e.preventDefault();break;case t.helper.keyCode.ARROW_DOWN:var s=i.select.find("option:selected").next();1==s.length&&s.prop("selected",!0),e.stopImmediatePropagation(),e.preventDefault()}};e.prototype.open=function(){var e=t.Dom.outerWidth(this.TD),i=t.Dom.outerHeight(this.TD),n=t.Dom.offset(this.instance.rootElement[0]),s=t.Dom.offset(this.TD);this.select.style.height=i+"px",this.select.style.minWidth=e+"px",this.select.style.top=s.top-n.top+"px",this.select.style.left=s.left-n.left-2+"px",this.select.style.display="",this.instance.addHook("beforeKeyDown",o)},e.prototype.close=function(){this.select.style.display="none",this.instance.removeHook("beforeKeyDown",o)},e.prototype.focus=function(){this.select.focus()},t.editors.SelectEditor=e,t.editors.registerEditor("select",e)}(i),function(t){var e=t.editors.AutocompleteEditor.prototype.extend();e.prototype.prepare=function(){t.editors.AutocompleteEditor.prototype.prepare.apply(this,arguments),this.cellProperties.filter=!1,this.cellProperties.strict=!0},t.editors.DropdownEditor=e,t.editors.registerEditor("dropdown",e)}(i),i.NumericValidator=function(t,e){null===t&&(t=""),e(/^-?\d*\.?\d*$/.test(t))};var V=function(t,e){var o=t,i="string"==typeof o?o.toLowerCase():null;return function(t){for(var n=!1,s=0,r=t.length;r>s;s++){if(o===t[s]){n=!0;break}if(i===t[s].toLowerCase()){n=!0;
break}}e(n)}};i.AutocompleteValidator=function(t,e){this.strict&&this.source?"function"==typeof this.source?this.source(t,V(t,e)):V(t,e)(this.source):e(!0)},i.AutocompleteCell={editor:i.editors.AutocompleteEditor,renderer:i.renderers.AutocompleteRenderer,validator:i.AutocompleteValidator},i.CheckboxCell={editor:i.editors.CheckboxEditor,renderer:i.renderers.CheckboxRenderer},i.TextCell={editor:i.editors.TextEditor,renderer:i.renderers.TextRenderer},i.NumericCell={editor:i.editors.TextEditor,renderer:i.renderers.NumericRenderer,validator:i.NumericValidator,dataType:"number"},i.DateCell={editor:i.editors.DateEditor,renderer:i.renderers.AutocompleteRenderer},i.HandsontableCell={editor:i.editors.HandsontableEditor,renderer:i.renderers.AutocompleteRenderer},i.PasswordCell={editor:i.editors.PasswordEditor,renderer:i.renderers.PasswordRenderer,copyable:!1},i.DropdownCell={editor:i.editors.DropdownEditor,renderer:i.renderers.AutocompleteRenderer,validator:i.AutocompleteValidator},i.cellTypes={text:i.TextCell,date:i.DateCell,numeric:i.NumericCell,checkbox:i.CheckboxCell,autocomplete:i.AutocompleteCell,handsontable:i.HandsontableCell,password:i.PasswordCell,dropdown:i.DropdownCell},i.cellLookup={validator:{numeric:i.NumericValidator,autocomplete:i.AutocompleteValidator}},function($){function t(o){return this.filter(t.resizableFilterSelector).each(function(){new e($(this),o)}),this}function e(e,o){this.clones||(this.config=$.extend({},t.defaults,o),this.el=e,this.nodeName=e[0].nodeName.toLowerCase(),this.previousScrollTop=null,"original"===o.maxWidth&&(o.maxWidth=e.width()),"original"===o.minWidth&&(o.minWidth=e.width()),"original"===o.maxHeight&&(o.maxHeight=e.height()),"original"===o.minHeight&&(o.minHeight=e.height()),"textarea"===this.nodeName&&e.css({resize:"none",overflowY:"none"}),e.data("AutoResizer",this),this.createClone(),this.injectClone(),this.bind())}t.defaults={onResize:function(){},animate:{duration:200,complete:function(){}},extraSpace:50,minHeight:"original",maxHeight:500,minWidth:"original",maxWidth:500},t.cloneCSSProperties=["lineHeight","textDecoration","letterSpacing","fontSize","fontFamily","fontStyle","fontWeight","textTransform","textAlign","direction","wordSpacing","fontSizeAdjust","padding"],t.cloneCSSValues={position:"absolute",top:-9999,left:-9999,opacity:0,overflow:"hidden",overflowX:"hidden",overflowY:"hidden",border:"1px solid black",padding:"0.49em"},t.resizableFilterSelector="textarea,input:not(input[type]),input[type=text],input[type=password]",t.AutoResizer=e,$.fn.autoResize=t,e.prototype={bind:function(){var t=$.proxy(function(){return this.check(),!0},this);this.unbind(),this.el.bind("keyup.autoResize",t).bind("change.autoResize",t),this.check(null,!0)},unbind:function(){this.el.unbind(".autoResize")},createClone:function(){var e=this.el,o=this,i=this.config;this.clones=$(),("original"!==i.minHeight||"original"!==i.maxHeight)&&(this.hClone=e.clone().height("auto"),this.clones=this.clones.add(this.hClone)),("original"!==i.minWidth||"original"!==i.maxWidth)&&(this.wClone=$("<div/>").width("auto").css({whiteSpace:"nowrap","float":"left"}),this.clones=this.clones.add(this.wClone)),$.each(t.cloneCSSProperties,function(t,i){o.clones.css(i,e.css(i))}),this.clones.removeAttr("name").removeAttr("id").attr("tabIndex",-1).css(t.cloneCSSValues).css("overflowY","scroll")},check:function(t,e){var o=this.config,i=this.wClone,n=this.hClone,s=this.el,r=s.val();if(i){i.text(r);var a=i.outerWidth(),l=a+o.extraSpace>=o.minWidth?a+o.extraSpace:o.minWidth,c=s.width();l=Math.min(l,o.maxWidth),(c>l&&l>=o.minWidth||l>=o.minWidth&&l<=o.maxWidth)&&(o.onResize.call(s),s.scrollLeft(0),o.animate&&!e?s.stop(1,1).animate({width:l},o.animate):s.width(l))}if(n){l&&n.width(l),n.height(0).val(r).scrollTop(1e4);var h=n[0].scrollTop+o.extraSpace;if(this.previousScrollTop===h)return;this.previousScrollTop=h,h>=o.maxHeight&&(h=o.maxHeight),h<o.minHeight&&(h=o.minHeight),h==o.maxHeight&&l==o.maxWidth?s.css("overflowY","scroll"):s.css("overflowY","hidden"),o.onResize.call(s),o.animate&&!e?s.stop(1,1).animate({height:h},o.animate):s.height(h)}},destroy:function(){this.unbind(),this.el.removeData("AutoResizer"),this.clones.remove(),delete this.el,delete this.hClone,delete this.wClone,delete this.clones},injectClone:function(){(t.cloneContainer||(t.cloneContainer=$("<arclones/>").appendTo("body"))).empty().append(this.clones)}}}(t),function(t){function e(t){return t.split('"').length-1}t.SheetClip={parse:function(t){var o,i,n,s,r,a,l,c=[],h=0;for(n=t.split("\n"),n.length>1&&""===n[n.length-1]&&n.pop(),o=0,i=n.length;i>o;o+=1){for(n[o]=n[o].split(" "),s=0,r=n[o].length;r>s;s+=1)c[h]||(c[h]=[]),a&&0===s?(l=c[h].length-1,c[h][l]=c[h][l]+"\n"+n[o][0],a&&1&e(n[o][0])&&(a=!1,c[h][l]=c[h][l].substring(0,c[h][l].length-1).replace(/""/g,'"'))):s===r-1&&0===n[o][s].indexOf('"')?(c[h].push(n[o][s].substring(1).replace(/""/g,'"')),a=!0):(c[h].push(n[o][s].replace(/""/g,'"')),a=!1);a||(h+=1)}return c},stringify:function(t){var e,o,i,n,s,r="";for(e=0,o=t.length;o>e;e+=1){for(i=0,n=t[e].length;n>i;i+=1)i>0&&(r+=" "),s=t[e][i],r+="string"==typeof s?s.indexOf("\n")>-1?'"'+s.replace(/"/g,'""')+'"':s:null===s||void 0===s?"":s;r+="\n"}return r}}}(o);var L=function(){var t;return{getInstance:function(){return t?t.hasBeenDestroyed()&&t.init():t=new n,t.refCounter++,t}}}();n.prototype.init=function(){var t,e,o=this;this.copyCallbacks=[],this.cutCallbacks=[],this.pasteCallbacks=[],this.listenerElement=document.documentElement,e=document.body,document.getElementById("CopyPasteDiv")?(this.elDiv=document.getElementById("CopyPasteDiv"),this.elTextarea=this.elDiv.firstChild):(this.elDiv=document.createElement("DIV"),this.elDiv.id="CopyPasteDiv",t=this.elDiv.style,t.position="fixed",t.top="-10000px",t.left="-10000px",e.appendChild(this.elDiv),this.elTextarea=document.createElement("TEXTAREA"),this.elTextarea.className="copyPaste",t=this.elTextarea.style,t.width="10000px",t.height="10000px",t.overflow="hidden",this.elDiv.appendChild(this.elTextarea),"undefined"!=typeof t.opacity&&(t.opacity=0)),this.keydownListener=function(t){var e=!1;if(t.metaKey?e=!0:t.ctrlKey&&-1===navigator.userAgent.indexOf("Mac")&&(e=!0),e){if(document.activeElement!==o.elTextarea&&(""!=o.getSelectionText()||-1!=["INPUT","SELECT","TEXTAREA"].indexOf(document.activeElement.nodeName)||"true"===$(document.activeElement).prop("contentEditable")))return;o.selectNodeText(o.elTextarea),setTimeout(function(){o.selectNodeText(o.elTextarea)},0)}!e||67!==t.keyCode&&86!==t.keyCode&&88!==t.keyCode||(88===t.keyCode?setTimeout(function(){o.triggerCut(t)},0):86===t.keyCode&&setTimeout(function(){o.triggerPaste(t)},0))},this._bindEvent(this.listenerElement,"keydown",this.keydownListener)},n.prototype.selectNodeText=function(t){t.select()},n.prototype.getSelectionText=function(){var t="";return o.getSelection?t=o.getSelection().toString():document.selection&&"Control"!=document.selection.type&&(t=document.selection.createRange().text),t},n.prototype.copyable=function(t){if("string"!=typeof t&&void 0===t.toString)throw new Error("copyable requires string parameter");this.elTextarea.value=t},n.prototype.onCut=function(t){this.cutCallbacks.push(t)},n.prototype.onPaste=function(t){this.pasteCallbacks.push(t)},n.prototype.removeCallback=function(t){var e,o;for(e=0,o=this.copyCallbacks.length;o>e;e++)if(this.copyCallbacks[e]===t)return this.copyCallbacks.splice(e,1),!0;for(e=0,o=this.cutCallbacks.length;o>e;e++)if(this.cutCallbacks[e]===t)return this.cutCallbacks.splice(e,1),!0;for(e=0,o=this.pasteCallbacks.length;o>e;e++)if(this.pasteCallbacks[e]===t)return this.pasteCallbacks.splice(e,1),!0;return!1},n.prototype.triggerCut=function(t){var e=this;e.cutCallbacks&&setTimeout(function(){for(var o=0,i=e.cutCallbacks.length;i>o;o++)e.cutCallbacks[o](t)},50)},n.prototype.triggerPaste=function(t,e){var o=this;o.pasteCallbacks&&setTimeout(function(){for(var i=(e||o.elTextarea.value).replace(/\n$/,""),n=0,s=o.pasteCallbacks.length;s>n;n++)o.pasteCallbacks[n](i,t)},50)},n.prototype.destroy=function(){this.hasBeenDestroyed()||0!=--this.refCounter||(this.elDiv&&this.elDiv.parentNode&&this.elDiv.parentNode.removeChild(this.elDiv),this._unbindEvent(this.listenerElement,"keydown",this.keydownListener))},n.prototype.hasBeenDestroyed=function(){return!this.refCounter},n.prototype._bindEvent=function(){return o.jQuery?function(t,e,o){$(t).on(e+".copypaste",o)}:function(t,e,o){t.addEventListener(e,o,!1)}}(),n.prototype._unbindEvent=function(){return o.jQuery?function(t,e,o){$(t).off(e+".copypaste",o)}:function(t,e,o){t.removeEventListener(e,o,!1)}}();var W;!function(t){function e(t){return-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")}function i(t,o){var n;for(var s in t)if(t.hasOwnProperty(s)){if(t[s]===o)return e(s)+"/";if("object"==typeof t[s]&&(n=i(t[s],o),""!=n))return e(s)+"/"+n}return""}function n(t,e){if(t===e)return"/";var o=i(t,e);if(""===o)throw new Error("Object not found in root");return"/"+o}function s(t){for(var e=0,o=y.length;o>e;e++)if(y[e].obj===t)return y[e]}function r(t,e){for(var o=0,i=t.observers.length;i>o;o++)if(t.observers[o].callback===e)return t.observers[o].observer}function a(t,e){for(var o=0,i=t.observers.length;i>o;o++)if(t.observers[o].observer===e)return void t.observers.splice(o,1)}function l(t,e){d(e),Object.observe?u(e,t):clearTimeout(e.next);var o=s(t);a(o,e)}function c(t,e){var i,a=[],l=t,c=s(t);if(c?i=r(c,e):(c=new v(t),y.push(c)),i)return i;if(Object.observe)i=function(o){u(i,t),h(i,t);for(var s=0,r=o.length;r>s;){if(("length"!==o[s].name||!S(o[s].object))&&"__Jasmine_been_here_before__"!==o[s].name){var c=o[s].type;switch(c){case"new":c="add";break;case"deleted":c="delete";break;case"updated":c="update"}w[c].call(o[s],a,n(l,o[s].object))}s++}a&&e&&e(a),i.patches=a,a=[]};else if(i={},c.value=JSON.parse(JSON.stringify(t)),e){i.callback=e,i.next=null;var p=this.intervals||[100,1e3,1e4,6e4],f=0,g=function(){d(i)},m=function(){clearTimeout(i.next),i.next=setTimeout(function(){g(),f=0,i.next=setTimeout(b,p[f++])},0)},b=function(){g(),f==p.length&&(f=p.length-1),i.next=setTimeout(b,p[f++])};"undefined"!=typeof o&&(o.addEventListener?(o.addEventListener("mousedown",m),o.addEventListener("mouseup",m),o.addEventListener("keydown",m)):(o.attachEvent("onmousedown",m),o.attachEvent("onmouseup",m),o.attachEvent("onkeydown",m))),i.next=setTimeout(b,p[f++])}return i.patches=a,i.object=t,c.observers.push(new C(e,i)),h(i,t)}function h(t,e){if(Object.observe){Object.observe(e,t);for(var o in e)if(e.hasOwnProperty(o)){var i=e[o];i&&"object"==typeof i&&h(t,i)}}return t}function u(t,e){if(Object.observe){Object.unobserve(e,t);for(var o in e)if(e.hasOwnProperty(o)){var i=e[o];i&&"object"==typeof i&&u(t,i)}}return t}function d(t){if(Object.observe)Object.deliverChangeRecords(t);else{for(var e,o=0,i=y.length;i>o;o++)if(y[o].obj===t.object){e=y[o];break}p(e.value,t.object,t.patches,"")}var n=t.patches;return n.length>0&&(t.patches=[],t.callback&&t.callback(n)),n}function p(t,o,i,n){for(var s=b(o),r=b(t),a=!1,l=!1,c=r.length-1;c>=0;c--){var h=r[c],u=t[h];if(o.hasOwnProperty(h)){var d=o[h];u instanceof Object?p(u,d,i,n+"/"+e(h)):u!=d&&(a=!0,i.push({op:"replace",path:n+"/"+e(h),value:d}),t[h]=d)}else i.push({op:"remove",path:n+"/"+e(h)}),delete t[h],l=!0}if(l||s.length!=r.length)for(var c=0;c<s.length;c++){var h=s[c];t.hasOwnProperty(h)||(i.push({op:"add",path:n+"/"+e(h),value:o[h]}),t[h]=JSON.parse(JSON.stringify(o[h])))}}function f(t,e){for(var o,i=!1,n=0,s=e.length;s>n;){o=e[n];for(var r=o.path.split("/"),a=t,l=1,c=r.length;;)if(S(a)){var h=parseInt(r[l],10);if(l++,l>=c){i=m[o.op].call(o,a,h,t);break}a=a[h]}else{var u=r[l];if(-1!=u.indexOf("~")&&(u=u.replace(/~1/g,"/").replace(/~0/g,"~")),l++,l>=c){i=g[o.op].call(o,a,u,t);break}a=a[u]}n++}return i}var g={add:function(t,e){return t[e]=this.value,!0},remove:function(t,e){return delete t[e],!0},replace:function(t,e){return t[e]=this.value,!0},move:function(t,e,o){var i={op:"_get",path:this.from};return f(o,[i]),f(o,[{op:"remove",path:this.from}]),f(o,[{op:"add",path:this.path,value:i.value}]),!0},copy:function(t,e,o){var i={op:"_get",path:this.from};return f(o,[i]),f(o,[{op:"add",path:this.path,value:i.value}]),!0},test:function(t,e){return JSON.stringify(t[e])===JSON.stringify(this.value)},_get:function(t,e){this.value=t[e]}},m={add:function(t,e){return t.splice(e,0,this.value),!0},remove:function(t,e){return t.splice(e,1),!0},replace:function(t,e){return t[e]=this.value,!0},move:g.move,copy:g.copy,test:g.test,_get:g._get},w={add:function(t,o){var i={op:"add",path:o+e(this.name),value:this.object[this.name]};t.push(i)},"delete":function(t,o){var i={op:"remove",path:o+e(this.name)};t.push(i)},update:function(t,o){var i={op:"replace",path:o+e(this.name),value:this.object[this.name]};t.push(i)}},y=[];t.intervals;var v=function(){function t(t){this.observers=[],this.obj=t}return t}(),C=function(){function t(t,e){this.callback=t,this.observer=e}return t}();t.unobserve=l,t.observe=c,t.generate=d;var b;b=Object.keys?Object.keys:function(t){var e=[];for(var o in t)t.hasOwnProperty(o)&&e.push(o);return e};var S;S=Array.isArray?Array.isArray:function(t){return t.push&&"number"==typeof t.length},t.apply=f}(W||(W={})),"undefined"!=typeof exports&&(exports.apply=W.apply,exports.observe=W.observe,exports.unobserve=W.unobserve,exports.generate=W.generate),i.PluginHookClass=function(){function t(){this.hooks=e(),this.legacy=o}var e=function(){return{beforeInitWalkontable:[],beforeInit:[],beforeRender:[],beforeChange:[],beforeRemoveCol:[],beforeRemoveRow:[],beforeValidate:[],beforeGet:[],beforeSet:[],beforeGetCellMeta:[],beforeAutofill:[],beforeKeyDown:[],beforeColumnSort:[],afterInit:[],afterLoadData:[],afterUpdateSettings:[],afterRender:[],afterRenderer:[],afterChange:[],afterValidate:[],afterGetCellMeta:[],afterGetColHeader:[],afterGetColWidth:[],afterDestroy:[],afterRemoveRow:[],afterCreateRow:[],afterRemoveCol:[],afterCreateCol:[],afterColumnResize:[],afterColumnMove:[],afterColumnSort:[],afterDeselect:[],afterSelection:[],afterSelectionByProp:[],afterSelectionEnd:[],afterSelectionEndByProp:[],afterCopyLimit:[],afterOnCellMouseDown:[],afterOnCellMouseOver:[],afterOnCellCornerMouseDown:[],afterScrollVertically:[],afterScrollHorizontally:[],modifyCol:[]}},o={onBeforeChange:"beforeChange",onChange:"afterChange",onCreateRow:"afterCreateRow",onCreateCol:"afterCreateCol",onSelection:"afterSelection",onCopyLimit:"afterCopyLimit",onSelectionEnd:"afterSelectionEnd",onSelectionByProp:"afterSelectionByProp",onSelectionEndByProp:"afterSelectionEndByProp"};return t.prototype.add=function(t,e){if(i.helper.isArray(e))for(var n=0,s=e.length;s>n;n++)this.add(t,e[n]);else t in o&&(t=o[t]),"undefined"==typeof this.hooks[t]&&(this.hooks[t]=[]),-1==this.hooks[t].indexOf(e)&&this.hooks[t].push(e);return this},t.prototype.once=function(t,e){if(i.helper.isArray(e))for(var o=0,n=e.length;n>o;o++)e[o].runOnce=!0,this.add(t,e[o]);else e.runOnce=!0,this.add(t,e)},t.prototype.remove=function(t,e){var i=!1;if(t in o&&(t=o[t]),"undefined"!=typeof this.hooks[t])for(var n=0,s=this.hooks[t].length;s>n;n++)if(this.hooks[t][n]==e){delete this.hooks[t][n].runOnce,this.hooks[t].splice(n,1),i=!0;break}return i},t.prototype.run=function(t,e,i,n,s,r,a){if(e in o&&(e=o[e]),"undefined"!=typeof this.hooks[e])for(var l=Array.prototype.slice.call(this.hooks[e]),c=0,h=l.length;h>c;c++)l[c].call(t,i,n,s,r,a),l[c].runOnce&&this.remove(e,l[c])},t.prototype.execute=function(t,e,i,n,s,r,a){var l,c;if(e in o&&(e=o[e]),"undefined"!=typeof this.hooks[e]){c=Array.prototype.slice.call(this.hooks[e]);for(var h=0,u=c.length;u>h;h++)if(l=c[h].call(t,i,n,s,r,a),void 0!==l&&(i=l),c[h].runOnce&&this.remove(e,c[h]),l===!1)return!1}return i},t}(),i.PluginHooks=new i.PluginHookClass,function(t){function e(){function e(t){var e=document,o=this;o.table=e.createElement("table"),o.theadTh=e.createElement("th"),o.table.appendChild(e.createElement("thead")).appendChild(e.createElement("tr")).appendChild(o.theadTh),o.tableStyle=o.table.style,o.tableStyle.tableLayout="auto",o.tableStyle.width="auto",o.tbody=e.createElement("tbody"),o.table.appendChild(o.tbody),o.container=e.createElement("div"),o.container.className=t.rootElement[0].className+" hidden",o.containerStyle=o.container.style,o.container.appendChild(o.table)}var i=this,n=5;this.beforeInit=function(){var t=this;t.autoColumnWidths=[],t.getSettings().autoColumnSize!==!1?t.autoColumnSizeTmp||(t.autoColumnSizeTmp={table:null,tableStyle:null,theadTh:null,tbody:null,container:null,containerStyle:null,determineBeforeNextRender:!0},t.addHook("beforeRender",o.determineIfChanged),t.addHook("afterGetColWidth",o.getColWidth),t.addHook("afterDestroy",o.afterDestroy),t.determineColumnWidth=i.determineColumnWidth):t.autoColumnSizeTmp&&(t.removeHook("beforeRender",o.determineIfChanged),t.removeHook("afterGetColWidth",o.getColWidth),t.removeHook("afterDestroy",o.afterDestroy),delete t.determineColumnWidth,i.afterDestroy.call(t))},this.determineIfChanged=function(t){t&&o.determineColumnsWidth.apply(this,arguments)},this.determineColumnWidth=function(o){var i=this,s=i.autoColumnSizeTmp;s.container||e.call(s,i),s.container.className=i.rootElement[0].className+" htAutoColumnSize",s.table.className=i.$table[0].className;for(var r=i.countRows(),a={},l=0,c=0;r>c;c++){var h=t.helper.stringify(i.getDataAtCell(c,o)),u=h.length;u>l&&(l=u),a[u]||(a[u]={needed:n,strings:[]}),a[u].needed&&(a[u].strings.push({value:h,row:c}),a[u].needed--)}var d=i.getSettings();d.colHeaders&&i.view.appendColHeader(o,s.theadTh),i.view.wt.wtDom.empty(s.tbody);for(var p in a)if(a.hasOwnProperty(p))for(var f=0,g=a[p].strings.length;g>f;f++){var m=a[p].strings[f].row,w=i.getCellMeta(m,o);w.col=o,w.row=m;var y=i.getCellRenderer(w),v=document.createElement("tr"),C=document.createElement("td");y(i,C,m,o,i.colToProp(o),a[p].strings[f].value,w),c++,v.appendChild(C),s.tbody.appendChild(v)}var b=i.rootElement[0].parentNode;b.appendChild(s.container);var S=i.view.wt.wtDom.outerWidth(s.table);if(b.removeChild(s.container),!d.nativeScrollbars){var T=i.view.wt.wtViewport.getViewportWidth()-2;S>T&&(S=T)}return S},this.determineColumnsWidth=function(){var t=this,e=this.getSettings();if(e.autoColumnSize||!e.colWidths)for(var o=this.countCols(),n=0;o>n;n++)t._getColWidthFromSettings(n)||(this.autoColumnWidths[n]=i.determineColumnWidth.call(t,n))},this.getColWidth=function(t,e){this.autoColumnWidths[t]&&this.autoColumnWidths[t]>e.width&&(e.width=this.autoColumnWidths[t])},this.afterDestroy=function(){var t=this;t.autoColumnSizeTmp&&t.autoColumnSizeTmp.container&&t.autoColumnSizeTmp.container.parentNode&&t.autoColumnSizeTmp.container.parentNode.removeChild(t.autoColumnSizeTmp.container),t.autoColumnSizeTmp=null}}var o=new e;t.PluginHooks.add("beforeInit",o.beforeInit),t.PluginHooks.add("afterUpdateSettings",o.beforeInit)}(i);var B=new s;i.PluginHooks.add("afterInit",function(){B.init.call(this,"afterInit")}),i.PluginHooks.add("afterUpdateSettings",function(){B.init.call(this,"afterUpdateSettings")}),i.PluginHooks.add("beforeGet",B.onBeforeGetSet),i.PluginHooks.add("beforeSet",B.onBeforeGetSet),i.PluginHooks.add("afterGetColHeader",B.getColHeader),function(t){function e(o,i){function n(){var e=$("body > .htContextMenu")[0];return e||(e=document.createElement("DIV"),t.Dom.addClass(e,"htContextMenu"),document.getElementsByTagName("body")[0].appendChild(e)),e}this.instance=o;var s=this;this.menu=n(),this.enabled=!0,this.bindMouseEvents(),this.bindTableEvents(),this.instance.addHook("afterDestroy",function(){s.destroy()}),this.defaultOptions={items:{row_above:{name:"Insert row above",callback:function(t,e){this.alter("insert_row",e.start.row())},disabled:function(){return this.countRows()>=this.getSettings().maxRows}},row_below:{name:"Insert row below",callback:function(t,e){this.alter("insert_row",e.end.row()+1)},disabled:function(){return this.countRows()>=this.getSettings().maxRows}},hsep1:e.SEPARATOR,col_left:{name:"Insert column on the left",callback:function(t,e){this.alter("insert_col",e.start.col())},disabled:function(){return this.countCols()>=this.getSettings().maxCols}},col_right:{name:"Insert column on the right",callback:function(t,e){this.alter("insert_col",e.end.col()+1)},disabled:function(){return this.countCols()>=this.getSettings().maxCols}},hsep2:e.SEPARATOR,remove_row:{name:"Remove row",callback:function(t,e){var o=e.end.row()-e.start.row()+1;this.alter("remove_row",e.start.row(),o)}},remove_col:{name:"Remove column",callback:function(t,e){var o=e.end.col()-e.start.col()+1;this.alter("remove_col",e.start.col(),o)}},hsep3:e.SEPARATOR,undo:{name:"Undo",callback:function(){this.undo()},disabled:function(){return this.undoRedo&&!this.undoRedo.isUndoAvailable()}},redo:{name:"Redo",callback:function(){this.redo()},disabled:function(){return this.undoRedo&&!this.undoRedo.isRedoAvailable()}}}},this.options={},t.helper.extend(this.options,this.defaultOptions),this.updateOptions(i)}function o(){var o=this,i=o.getSettings().contextMenu,n=t.helper.isObject(i)?i:{};i?(o.contextMenu||(o.contextMenu=new e(o,n)),o.contextMenu.enable(),t.helper.isArray(i)&&o.contextMenu.filterItems(i)):o.contextMenu&&(o.contextMenu.destroy(),delete o.contextMenu)}e.prototype.bindMouseEvents=function(){function o(o){o.preventDefault(),("TD"==o.target.nodeName||t.Dom.hasClass(o.target,"current")&&t.Dom.hasClass(o.target,"wtBorder"))&&(this.show(o.pageY,o.pageX),$(document).on("mousedown.htContextMenu",t.helper.proxy(e.prototype.close,this)))}this.instance.rootElement.on("contextmenu.htContextMenu",t.helper.proxy(o,this))},e.prototype.bindTableEvents=function(){var t=this;this._afterScrollCallback=function(){t.close()},this.instance.addHook("afterScrollVertically",this._afterScrollCallback),this.instance.addHook("afterScrollHorizontally",this._afterScrollCallback)},e.prototype.unbindTableEvents=function(){this._afterScrollCallback&&(this.instance.removeHook("afterScrollVertically",this._afterScrollCallback),this.instance.removeHook("afterScrollHorizontally",this._afterScrollCallback),this._afterScrollCallback=null)},e.prototype.performAction=function(){var t=$(this.menu).handsontable("getInstance"),o=t.getSelected()[0],i=t.getData()[o];if(i.disabled!==!0&&("function"!=typeof i.disabled||i.disabled.call(this.instance)!==!0)&&"function"==typeof i.callback){var n=this.instance.getSelected(),s=e.utils.normalizeSelection(n);i.callback.call(this.instance,i.key,s)}},e.prototype.unbindMouseEvents=function(){this.instance.rootElement.off("contextmenu.htContextMenu"),$(document).off("mousedown.htContextMenu")},e.prototype.show=function(o,i){this.menu.style.display="block",$(this.menu).off("mousedown.htContextMenu").on("mousedown.htContextMenu",t.helper.proxy(this.performAction,this)),$(this.menu).handsontable({data:e.utils.convertItemsToArray(this.getItems()),colHeaders:!1,colWidths:[160],readOnly:!0,copyPaste:!1,columns:[{data:"name",renderer:t.helper.proxy(this.renderer,this)}],beforeKeyDown:t.helper.proxy(this.onBeforeKeyDown,this)}),this.bindTableEvents(),this.setMenuPosition(o,i),$(this.menu).handsontable("listen")},e.prototype.close=function(){this.hide(),$(document).off("mousedown.htContextMenu"),this.unbindTableEvents(),this.instance.listen()},e.prototype.hide=function(){this.menu.style.display="none",$(this.menu).handsontable("destroy")},e.prototype.renderer=function(o,i,n,s,r,a,l){function c(t){return new RegExp(e.SEPARATOR,"i").test(t.name)}function h(t,e){return t.disabled===!0||"function"==typeof t.disabled&&t.disabled.call(u.instance)===!0}var u=this,d=o.getData()[n],p=document.createElement("DIV");t.Dom.empty(i),i.appendChild(p),c(d)?t.Dom.addClass(i,"htSeparator"):t.Dom.fastInnerText(p,a),h(d,u.instance)?(t.Dom.addClass(i,"htDisabled"),$(p).on("mouseenter",function(){o.deselectCell()})):(t.Dom.removeClass(i,"htDisabled"),$(p).on("mouseenter",function(){o.selectCell(n,s)}))},e.prototype.onBeforeKeyDown=function(o){function i(t){var o=t.getCell(0,0);e.utils.isSeparator(o)||e.utils.isDisabled(o)?s(0,0,t):t.selectCell(0,0)}function n(t){var o=t.countRows()-1,i=t.getCell(o,0);e.utils.isSeparator(i)||e.utils.isDisabled(i)?r(o,0,t):t.selectCell(o,0)}function s(t,o,i){var n=t+1,r=n<i.countRows()?i.getCell(n,o):null;r&&(e.utils.isSeparator(r)||e.utils.isDisabled(r)?s(n,o,i):i.selectCell(n,o))}function r(t,o,i){var n=t-1,s=n>=0?i.getCell(n,o):null;s&&(e.utils.isSeparator(s)||e.utils.isDisabled(s)?r(n,o,i):i.selectCell(n,o))}var a=this,l=$(a.menu).handsontable("getInstance"),c=l.getSelected();switch(o.keyCode){case t.helper.keyCode.ESCAPE:a.close(),o.preventDefault(),o.stopImmediatePropagation();break;case t.helper.keyCode.ENTER:l.getSelected()&&(a.performAction(),a.close());break;case t.helper.keyCode.ARROW_DOWN:c?s(c[0],c[1],l):i(l),o.preventDefault(),o.stopImmediatePropagation();break;case t.helper.keyCode.ARROW_UP:c?r(c[0],c[1],l):n(l),o.preventDefault(),o.stopImmediatePropagation()}},e.prototype.getItems=function(){function e(e){"string"==typeof e?this.name=e:t.helper.extend(this,e)}var o={};e.prototype=this.options;for(var i in this.options.items)!this.options.items.hasOwnProperty(i)||this.itemsFilter&&-1==this.itemsFilter.indexOf(i)||(o[i]=new e(this.options.items[i]));return o},e.prototype.updateOptions=function(e){if(e=e||{},e.items)for(var o in e.items){var i={};e.items.hasOwnProperty(o)&&this.defaultOptions.items.hasOwnProperty(o)&&t.helper.isObject(e.items[o])&&(t.helper.extend(i,this.defaultOptions.items[o]),t.helper.extend(i,e.items[o]),e.items[o]=i)}t.helper.extend(this.options,e)},e.prototype.setMenuPosition=function(t,e){var o={top:t,topRelative:t-document.documentElement.scrollTop,left:e,leftRelative:e-document.documentElement.scrollLeft};this.menuFitsBelowCursor(o)?this.positionMenuBelowCursor(o):this.positionMenuAboveCursor(o),this.menuFitsOnRightOfCursor(o)?this.positionMenuOnRightOfCursor(o):this.positionMenuOnLeftOfCursor(o)},e.prototype.menuFitsBelowCursor=function(t){return t.topRelative+this.menu.offsetHeight<=document.documentElement.scrollTop+document.documentElement.clientHeight},e.prototype.menuFitsOnRightOfCursor=function(t){return t.leftRelative+this.menu.offsetWidth<=document.documentElement.scrollLeft+document.documentElement.clientWidth},e.prototype.positionMenuBelowCursor=function(t){this.menu.style.top=t.top+"px"},e.prototype.positionMenuAboveCursor=function(t){this.menu.style.top=t.top-this.menu.offsetHeight+"px"},e.prototype.positionMenuOnRightOfCursor=function(t){this.menu.style.left=t.left+"px"},e.prototype.positionMenuOnLeftOfCursor=function(t){this.menu.style.left=t.left-this.menu.offsetWidth+"px"},e.utils={},e.utils.convertItemsToArray=function(t){var e,o=[];for(var i in t)if(t.hasOwnProperty(i)){if("string"==typeof t[i])e={name:t[i]};else{if(t[i].visible===!1)continue;e=t[i]}e.key=i,o.push(e)}return o},e.utils.normalizeSelection=function(e){var o={start:new t.SelectionPoint,end:new t.SelectionPoint};return o.start.row(Math.min(e[0],e[2])),o.start.col(Math.min(e[1],e[3])),o.end.row(Math.max(e[0],e[2])),o.end.col(Math.max(e[1],e[3])),o},e.utils.isSeparator=function(e){return t.Dom.hasClass(e,"htSeparator")},e.utils.isDisabled=function(e){return t.Dom.hasClass(e,"htDisabled")},e.prototype.enable=function(){this.enabled||(this.enabled=!0,this.bindMouseEvents())},e.prototype.disable=function(){this.enabled&&(this.enabled=!1,this.close(),this.unbindMouseEvents(),this.unbindTableEvents())},e.prototype.destroy=function(){this.close(),this.unbindMouseEvents(),this.unbindTableEvents(),this.isMenuEnabledByOtherHotInstance()||this.removeMenu()},e.prototype.isMenuEnabledByOtherHotInstance=function(){for(var t=$(".handsontable"),e=!1,o=0,i=t.length;i>o;o++){var n=$(t[o]).handsontable("getInstance");if(n&&n.getSettings().contextMenu){e=!0;break}}return e},e.prototype.removeMenu=function(){this.menu.parentNode&&this.menu.parentNode.removeChild(this.menu)},e.prototype.filterItems=function(t){this.itemsFilter=t},e.SEPARATOR="---------",t.PluginHooks.add("afterInit",o),t.PluginHooks.add("afterUpdateSettings",o),t.ContextMenu=e}(i),i.PluginHooks.add("beforeGetCellMeta",function(t,e,o){if(o.isWritable=!o.readOnly,o.autoComplete)throw new Error("Support for legacy autocomplete syntax was removed in Handsontable 0.10.0. Please remove the property named 'autoComplete' from your config. For replacement instructions, see wiki page https://github.com/warpech/jquery-handsontable/wiki/Migration-guide-to-0.10.x")});var z=new r;i.PluginHooks.add("beforeInit",z.beforeInit),i.PluginHooks.add("afterInit",function(){z.init.call(this,"afterInit")}),i.PluginHooks.add("afterUpdateSettings",function(){z.init.call(this,"afterUpdateSettings")}),i.PluginHooks.add("afterGetColHeader",z.getColHeader),i.PluginHooks.add("modifyCol",z.modifyCol);var F=new a;i.PluginHooks.add("beforeInit",F.beforeInit),i.PluginHooks.add("afterInit",function(){F.init.call(this,"afterInit")}),i.PluginHooks.add("afterUpdateSettings",function(){F.init.call(this,"afterUpdateSettings")}),i.PluginHooks.add("afterGetColWidth",F.getColWidth),function(){function t(){var t=this,o=t.getSettings().observeChanges;o?(t.observer&&n.call(t),e.call(t),r.call(t)):o||n.call(t)}function e(){var t=this;t.observeChangesActive=!0,t.pauseObservingChanges=function(){t.observeChangesActive=!1},t.resumeObservingChanges=function(){t.observeChangesActive=!0},t.observedData=t.getData(),t.observer=W.observe(t.observedData,function(e){t.observeChangesActive&&(o.call(t,e),t.render()),t.runHooks("afterChangesObserved")})}function o(t){function e(t){var e;return e=i(t),e=o(e)}function o(t){var e=[];return t.filter(function(t){var o=n(t.path);if(-1!=["add","remove"].indexOf(t.op)&&!isNaN(o.col)){if(-1!=e.indexOf(o.col))return!1;e.push(o.col)}return!0})}function i(t){return t.filter(function(t){return!/[/]length/gi.test(t.path)})}function n(t){var e=t.match(/^\/(\d+)\/?(.*)?$/);return{row:parseInt(e[1],10),col:/^\d*$/.test(e[2])?parseInt(e[2],10):e[2]}}for(var s=this,r=e(t),a=0,l=r.length;l>a;a++){var c=r[a],h=n(c.path);switch(c.op){case"add":isNaN(h.col)?s.runHooks("afterCreateRow",h.row):s.runHooks("afterCreateCol",h.col);break;case"remove":isNaN(h.col)?s.runHooks("afterRemoveRow",h.row,1):s.runHooks("afterRemoveCol",h.col,1);break;case"replace":s.runHooks("afterChange",[h.row,h.col,null,c.value],"external")}}}function n(){var t=this;t.observer&&(s.call(t),a.call(t))}function s(){var t=this;W.unobserve(t.observedData,t.observer),delete t.observeChangesActive,delete t.pauseObservingChanges,delete t.resumeObservingChanges}function r(){var t=this;t.addHook("afterDestroy",n),t.addHook("afterCreateRow",l),t.addHook("afterRemoveRow",l),t.addHook("afterCreateCol",l),t.addHook("afterRemoveCol",l),t.addHook("afterChange",function(t,e){"loadData"!=e&&l.call(this)})}function a(){var t=this;t.removeHook("afterDestroy",n),t.removeHook("afterCreateRow",l),t.removeHook("afterRemoveRow",l),t.removeHook("afterCreateCol",l),t.removeHook("afterRemoveCol",l),t.removeHook("afterChange",l)}function l(){var t=this;t.pauseObservingChanges(),t.addHookOnce("afterChangesObserved",function(){t.resumeObservingChanges()})}i.PluginHooks.add("afterLoadData",t),i.PluginHooks.add("afterUpdateSettings",t)}(),function(t){function e(){function e(){var t=this;for(var e in s)s.hasOwnProperty(e)&&!i.call(t,e)&&t.PluginHooks.add(e,s[e])}function o(){var t=this;for(var e in s)s.hasOwnProperty(e)&&i.call(t,e)&&t.PluginHooks.remove(e,s[e])}function i(t){var e=this;return e.PluginHooks.hooks.hasOwnProperty(t)}var n=this;this.init=function(){var i=this,s=i.getSettings().persistentState;return n.enabled=!!s,n.enabled?(i.storage||(i.storage=new t(i.rootElement[0].id)),i.resetState=n.resetValue,void e.call(i)):void o.call(i)},this.saveValue=function(t,e){var o=this;o.storage.saveValue(t,e)},this.loadValue=function(t,e){var o=this;e.value=o.storage.loadValue(t)},this.resetValue=function(t){var e=this;"undefined"!=typeof t?e.storage.reset(t):e.storage.resetAll()};var s={persistentStateSave:n.saveValue,persistentStateLoad:n.loadValue,
persistentStateReset:n.resetValue}}var o=new e;i.PluginHooks.add("beforeInit",o.init),i.PluginHooks.add("afterUpdateSettings",o.init)}(l),function(t){t.UndoRedo=function(e){var o=this;this.instance=e,this.doneActions=[],this.undoneActions=[],this.ignoreNewActions=!1,e.addHook("afterChange",function(e,i){if(e){var n=new t.UndoRedo.ChangeAction(e);o.done(n)}}),e.addHook("afterCreateRow",function(e,i,n){if(!n){var s=new t.UndoRedo.CreateRowAction(e,i);o.done(s)}}),e.addHook("beforeRemoveRow",function(e,i){var n=o.instance.getData();e=(n.length+e)%n.length;var s=n.slice(e,e+i),r=new t.UndoRedo.RemoveRowAction(e,s);o.done(r)}),e.addHook("afterCreateCol",function(e,i,n){if(!n){var s=new t.UndoRedo.CreateColumnAction(e,i);o.done(s)}}),e.addHook("beforeRemoveCol",function(i,n){var s=o.instance.getData();i=(o.instance.countCols()+i)%o.instance.countCols();for(var r=[],a=0,l=s.length;l>a;a++)r[a]=s[a].slice(i,i+n);var c;t.helper.isArray(e.getSettings().colHeaders)&&(c=e.getSettings().colHeaders.slice(i,i+r.length));var h=new t.UndoRedo.RemoveColumnAction(i,r,c);o.done(h)})},t.UndoRedo.prototype.done=function(t){this.ignoreNewActions||(this.doneActions.push(t),this.undoneActions.length=0)},t.UndoRedo.prototype.undo=function(){if(this.isUndoAvailable()){var t=this.doneActions.pop();this.ignoreNewActions=!0;var e=this;t.undo(this.instance,function(){e.ignoreNewActions=!1,e.undoneActions.push(t)})}},t.UndoRedo.prototype.redo=function(){if(this.isRedoAvailable()){var t=this.undoneActions.pop();this.ignoreNewActions=!0;var e=this;t.redo(this.instance,function(){e.ignoreNewActions=!1,e.doneActions.push(t)})}},t.UndoRedo.prototype.isUndoAvailable=function(){return this.doneActions.length>0},t.UndoRedo.prototype.isRedoAvailable=function(){return this.undoneActions.length>0},t.UndoRedo.prototype.clear=function(){this.doneActions.length=0,this.undoneActions.length=0},t.UndoRedo.Action=function(){},t.UndoRedo.Action.prototype.undo=function(){},t.UndoRedo.Action.prototype.redo=function(){},t.UndoRedo.ChangeAction=function(t){this.changes=t},t.helper.inherit(t.UndoRedo.ChangeAction,t.UndoRedo.Action),t.UndoRedo.ChangeAction.prototype.undo=function(t,e){for(var o=$.extend(!0,[],this.changes),i=0,n=o.length;n>i;i++)o[i].splice(3,1);t.addHookOnce("afterChange",e),t.setDataAtRowProp(o,null,null,"undo")},t.UndoRedo.ChangeAction.prototype.redo=function(t,e){for(var o=$.extend(!0,[],this.changes),i=0,n=o.length;n>i;i++)o[i].splice(2,1);t.addHookOnce("afterChange",e),t.setDataAtRowProp(o,null,null,"redo")},t.UndoRedo.CreateRowAction=function(t,e){this.index=t,this.amount=e},t.helper.inherit(t.UndoRedo.CreateRowAction,t.UndoRedo.Action),t.UndoRedo.CreateRowAction.prototype.undo=function(t,e){t.addHookOnce("afterRemoveRow",e),t.alter("remove_row",this.index,this.amount)},t.UndoRedo.CreateRowAction.prototype.redo=function(t,e){t.addHookOnce("afterCreateRow",e),t.alter("insert_row",this.index+1,this.amount)},t.UndoRedo.RemoveRowAction=function(t,e){this.index=t,this.data=e},t.helper.inherit(t.UndoRedo.RemoveRowAction,t.UndoRedo.Action),t.UndoRedo.RemoveRowAction.prototype.undo=function(t,e){var o=[this.index,0];Array.prototype.push.apply(o,this.data),Array.prototype.splice.apply(t.getData(),o),t.addHookOnce("afterRender",e),t.render()},t.UndoRedo.RemoveRowAction.prototype.redo=function(t,e){t.addHookOnce("afterRemoveRow",e),t.alter("remove_row",this.index,this.data.length)},t.UndoRedo.CreateColumnAction=function(t,e){this.index=t,this.amount=e},t.helper.inherit(t.UndoRedo.CreateColumnAction,t.UndoRedo.Action),t.UndoRedo.CreateColumnAction.prototype.undo=function(t,e){t.addHookOnce("afterRemoveCol",e),t.alter("remove_col",this.index,this.amount)},t.UndoRedo.CreateColumnAction.prototype.redo=function(t,e){t.addHookOnce("afterCreateCol",e),t.alter("insert_col",this.index+1,this.amount)},t.UndoRedo.RemoveColumnAction=function(t,e,o){this.index=t,this.data=e,this.amount=this.data[0].length,this.headers=o},t.helper.inherit(t.UndoRedo.RemoveColumnAction,t.UndoRedo.Action),t.UndoRedo.RemoveColumnAction.prototype.undo=function(t,e){for(var o,i,n=0,s=t.getData().length;s>n;n++)o=t.getDataAtRow(n),i=[this.index,0],Array.prototype.push.apply(i,this.data[n]),Array.prototype.splice.apply(o,i);"undefined"!=typeof this.headers&&(i=[this.index,0],Array.prototype.push.apply(i,this.headers),Array.prototype.splice.apply(t.getSettings().colHeaders,i)),t.addHookOnce("afterRender",e),t.render()},t.UndoRedo.RemoveColumnAction.prototype.redo=function(t,e){t.addHookOnce("afterRemoveCol",e),t.alter("remove_col",this.index,this.amount)}}(i),function(t){function e(){var e=this,r="undefined"==typeof e.getSettings().undo||e.getSettings().undo;r?e.undoRedo||(e.undoRedo=new t.UndoRedo(e),n(e),e.addHook("beforeKeyDown",o),e.addHook("afterChange",i)):e.undoRedo&&(delete e.undoRedo,s(e),e.removeHook("beforeKeyDown",o),e.removeHook("afterChange",i))}function o(t){var e=this,o=(t.ctrlKey||t.metaKey)&&!t.altKey;o&&(89===t.keyCode||t.shiftKey&&90===t.keyCode?(e.undoRedo.redo(),t.stopImmediatePropagation()):90===t.keyCode&&(e.undoRedo.undo(),t.stopImmediatePropagation()))}function i(t,e){var o=this;return"loadData"==e?o.undoRedo.clear():void 0}function n(t){t.undo=function(){return t.undoRedo.undo()},t.redo=function(){return t.undoRedo.redo()},t.isUndoAvailable=function(){return t.undoRedo.isUndoAvailable()},t.isRedoAvailable=function(){return t.undoRedo.isRedoAvailable()},t.clearUndo=function(){return t.undoRedo.clear()}}function s(t){delete t.undo,delete t.redo,delete t.isUndoAvailable,delete t.isRedoAvailable,delete t.clearUndo}t.PluginHooks.add("afterInit",e),t.PluginHooks.add("afterUpdateSettings",e)}(i),c.prototype.setBoundaries=function(t){this.boundaries=t},c.prototype.setCallback=function(t){this.callback=t},c.prototype.check=function(t,e){var o=0,i=0;e<this.boundaries.top?i=e-this.boundaries.top:e>this.boundaries.bottom&&(i=e-this.boundaries.bottom),t<this.boundaries.left?o=t-this.boundaries.left:t>this.boundaries.right&&(o=t-this.boundaries.right),this.callback(o,i)};var _,U=!1;if("undefined"!=typeof i){var j=function(t){var e=t.view.wt.wtScrollbars.vertical.scrollHandler;_=new c,e!==o&&(e?_.setBoundaries(e.getBoundingClientRect()):_.setBoundaries(t.$table[0].getBoundingClientRect()),_.setCallback(function(o,i){0>o?e?e.scrollLeft-=50:t.view.wt.scrollHorizontal(-1).draw():o>0&&(e?e.scrollLeft+=50:t.view.wt.scrollHorizontal(1).draw()),0>i?e?e.scrollTop-=20:t.view.wt.scrollVertical(-1).draw():i>0&&(e?e.scrollTop+=20:t.view.wt.scrollVertical(1).draw())}),U=!0)};i.PluginHooks.add("afterInit",function(){$(document).on("mouseup."+this.guid,function(){U=!1}),$(document).on("mousemove."+this.guid,function(t){U&&_.check(t.clientX,t.clientY)})}),i.PluginHooks.add("destroy",function(){$(document).off("."+this.guid)}),i.PluginHooks.add("afterOnCellMouseDown",function(){j(this)}),i.PluginHooks.add("afterOnCellCornerMouseDown",function(){j(this)}),i.plugins.DragToScroll=c}if(function(t,e,o){function i(i){function n(){i.isListening()&&i.selection.empty()}function s(t){if(i.isListening()&&i.selection.isSelected()){var e=t.replace(/^[\r\n]*/g,"").replace(/[\r\n]*$/g,""),n=o.parse(e),s=i.getSelected(),r=i.getCornerCoords([{row:s[0],col:s[1]},{row:s[2],col:s[3]}]),a=r.TL,l={row:Math.max(r.BR.row,n.length-1+r.TL.row),col:Math.max(r.BR.col,n[0].length-1+r.TL.col)};i.PluginHooks.once("afterChange",function(t,e){t&&t.length&&this.selectCell(a.row,a.col,l.row,l.col)}),i.populateFromArray(a.row,a.col,n,l.row,l.col,"paste",i.getSettings().pasteMode)}}function r(e){if(t.helper.isCtrlKey(e.keyCode)&&i.getSelected())return a.setCopyableText(),void e.stopImmediatePropagation();var o=(e.ctrlKey||e.metaKey)&&!e.altKey;e.keyCode==t.helper.keyCode.A&&o&&setTimeout(t.helper.proxy(a.setCopyableText,a))}this.copyPasteInstance=e.getInstance(),this.copyPasteInstance.onCut(n),this.copyPasteInstance.onPaste(s);var a=this;i.addHook("beforeKeyDown",r),this.destroy=function(){this.copyPasteInstance.removeCallback(n),this.copyPasteInstance.removeCallback(s),this.copyPasteInstance.destroy(),i.removeHook("beforeKeyDown",r)},i.addHook("afterDestroy",t.helper.proxy(this.destroy,this)),this.triggerPaste=t.helper.proxy(this.copyPasteInstance.triggerPaste,this.copyPasteInstance),this.triggerCut=t.helper.proxy(this.copyPasteInstance.triggerCut,this.copyPasteInstance),this.setCopyableText=function(){var t=i.getSelected(),e=i.getSettings(),o=e.copyRowsLimit,n=e.copyColsLimit,s=Math.min(t[0],t[2]),r=Math.min(t[1],t[3]),a=Math.max(t[0],t[2]),l=Math.max(t[1],t[3]),c=Math.min(a,s+o-1),h=Math.min(l,r+n-1);i.copyPaste.copyPasteInstance.copyable(i.getCopyableData(s,r,c,h)),(a!==c||l!==h)&&i.PluginHooks.run("afterCopyLimit",a-s+1,l-r+1,o,n)}}function n(){var t=this,e=t.getSettings().copyPaste!==!1;e&&!t.copyPaste?t.copyPaste=new i(t):!e&&t.copyPaste&&(t.copyPaste.destroy(),delete t.copyPaste)}t.PluginHooks.add("afterInit",n),t.PluginHooks.add("afterUpdateSettings",n)}(i,L,SheetClip),function(t){function e(){var e=this,o=!!e.getSettings().search;o?e.search=new t.Search(e):delete e.search}t.Search=function(e){this.query=function(o,i,n){var s=e.countRows(),r=e.countCols(),a=[];i||(i=t.Search.global.getDefaultCallback()),n||(n=t.Search.global.getDefaultQueryMethod());for(var l=0;s>l;l++)for(var c=0;r>c;c++){var h=e.getDataAtCell(l,c),u=e.getCellMeta(l,c),d=u.search.callback||i,p=u.search.queryMethod||n,f=p(o,h);if(f){var g={row:l,col:c,data:h};a.push(g)}d&&d(e,l,c,h,f)}return a}},t.Search.DEFAULT_CALLBACK=function(t,e,o,i,n){t.getCellMeta(e,o).isSearchResult=n},t.Search.DEFAULT_QUERY_METHOD=function(t,e){return"undefined"!=typeof t&&null!=t&&t.toLowerCase&&0!=t.length?-1!=e.toString().toLowerCase().indexOf(t.toLowerCase()):!1},t.Search.DEFAULT_SEARCH_RESULT_CLASS="htSearchResult",t.Search.global=function(){var e=t.Search.DEFAULT_CALLBACK,o=t.Search.DEFAULT_QUERY_METHOD,i=t.Search.DEFAULT_SEARCH_RESULT_CLASS;return{getDefaultCallback:function(){return e},setDefaultCallback:function(t){e=t},getDefaultQueryMethod:function(){return o},setDefaultQueryMethod:function(t){o=t},getDefaultSearchResultClass:function(){return i},setDefaultSearchResultClass:function(t){i=t}}}(),t.SearchCellDecorator=function(e,o,i,n,s,r,a){var l="object"==typeof a.search&&a.search.searchResultClass||t.Search.global.getDefaultSearchResultClass();a.isSearchResult?t.Dom.addClass(o,l):t.Dom.removeClass(o,l)};var o=t.renderers.cellDecorator;t.renderers.cellDecorator=function(e,i,n,s,r,a,l){o.apply(this,arguments),t.SearchCellDecorator.apply(this,arguments)},t.PluginHooks.add("afterInit",e),t.PluginHooks.add("afterUpdateSettings",e)}(i),h.prototype.init=function(){this.TABLE=this.instance.wtTable.TABLE,this.fixed=this.instance.wtTable.hider,this.fixedContainer=this.instance.wtTable.holder,this.fixed.style.position="absolute",this.fixed.style.left="0",this.scrollHandler=this.getScrollableElement(this.TABLE),this.$scrollHandler=$(this.scrollHandler)},h.prototype.makeClone=function(t){var e=document.createElement("DIV");e.className="ht_clone_"+t+" handsontable",e.style.position="fixed",e.style.overflow="hidden";var o=document.createElement("TABLE");return o.className=this.instance.wtTable.TABLE.className,e.appendChild(o),this.instance.wtTable.holder.parentNode.appendChild(e),new w({cloneSource:this.instance,cloneOverlay:this,table:o})},h.prototype.getScrollableElement=function(t){for(var e=t.parentNode;e&&e.style;){if("visible"!==e.style.overflow&&""!==e.style.overflow)return e;if(this instanceof H&&"visible"!==e.style.overflowX&&""!==e.style.overflowX)return e;e=e.parentNode}return o},h.prototype.prepare=function(){},h.prototype.onScroll=function(t){this.windowScrollPosition=this.getScrollPosition(),this.readSettings(),t&&(this.windowScrollPosition=t),this.resetFixedPosition()},h.prototype.availableSize=function(){var t;return t=this.windowScrollPosition>this.tableParentOffset?this.instance.wtTable.getLastVisibleRow()===this.total-1?this.instance.wtDom.outerHeight(this.TABLE):this.windowSize:this.windowSize-this.tableParentOffset},h.prototype.refresh=function(t){var e=this.getLastCell();this.measureBefore=this.sumCellSizes(0,this.offset),-1===e?this.measureAfter=0:this.measureAfter=this.sumCellSizes(e,this.total-e),this.applyToDOM(),this.clone&&this.clone.draw(t)},h.prototype.destroy=function(){this.$scrollHandler.off("."+this.instance.guid),$(o).off("."+this.instance.guid),$(document).off("."+this.instance.guid)},u.prototype.appear=function(t){var e,o,i,n,s,r,a,l,c,h,u,d;if(!this.disabled){var p,f,g,m,w,y,v,C=this.instance,b=!1,S=!1,T=!1,R=!1;for(C.wtTable.isRowInViewport(t[0])||(b=!0),C.wtTable.isRowInViewport(t[2])||(T=!0),y=C.wtTable.rowStrategy.countVisible(),w=0;y>w;w++)if(v=C.wtTable.rowFilter.visibleToSource(w),v>=t[0]&&v<=t[2]){p=v;break}for(w=y-1;w>=0;w--)if(v=C.wtTable.rowFilter.visibleToSource(w),v>=t[0]&&v<=t[2]){g=v;break}if(b&&T)S=!0,R=!0;else{for(C.wtTable.isColumnInViewport(t[1])||(S=!0),C.wtTable.isColumnInViewport(t[3])||(R=!0),y=C.wtTable.columnStrategy.countVisible(),w=0;y>w;w++)if(v=C.wtTable.columnFilter.visibleToSource(w),v>=t[1]&&v<=t[3]){f=v;break}for(w=y-1;w>=0;w--)if(v=C.wtTable.columnFilter.visibleToSource(w),v>=t[1]&&v<=t[3]){m=v;break}}if(void 0===p||void 0===f)return void this.disappear();e=p!==g||f!==m,o=C.wtTable.getCell([p,f]),i=e?C.wtTable.getCell([g,m]):o,n=this.wtDom.offset(o),s=e?this.wtDom.offset(i):n,r=this.wtDom.offset(C.wtTable.TABLE),l=n.top,u=s.top+this.wtDom.outerHeight(i)-l,h=n.left,d=s.left+this.wtDom.outerWidth(i)-h,a=l-r.top-1,c=h-r.left-1;var E=this.wtDom.getComputedStyle(o);parseInt(E.borderTopWidth,10)>0&&(a+=1,u=u>0?u-1:0),parseInt(E.borderLeftWidth,10)>0&&(c+=1,d=d>0?d-1:0),b?this.topStyle.display="none":(this.topStyle.top=a+"px",this.topStyle.left=c+"px",this.topStyle.width=d+"px",this.topStyle.display="block"),S?this.leftStyle.display="none":(this.leftStyle.top=a+"px",this.leftStyle.left=c+"px",this.leftStyle.height=u+"px",this.leftStyle.display="block");var D=Math.floor(this.settings.border.width/2);T?this.bottomStyle.display="none":(this.bottomStyle.top=a+u-D+"px",this.bottomStyle.left=c+"px",this.bottomStyle.width=d+"px",this.bottomStyle.display="block"),R?this.rightStyle.display="none":(this.rightStyle.top=a+"px",this.rightStyle.left=c+d-D+"px",this.rightStyle.height=u+1+"px",this.rightStyle.display="block"),T||R||!this.hasSetting(this.settings.border.cornerVisible)?this.cornerStyle.display="none":(this.cornerStyle.top=a+u-4+"px",this.cornerStyle.left=c+d-4+"px",this.cornerStyle.display="block")}},u.prototype.disappear=function(){this.topStyle.display="none",this.leftStyle.display="none",this.bottomStyle.display="none",this.rightStyle.display="none",this.cornerStyle.display="none"},u.prototype.hasSetting=function(t){return"function"==typeof t?t():!!t},d.prototype.source=function(t){return t},d.prototype.offsetted=function(t){return t+this.offset},d.prototype.unOffsetted=function(t){return t-this.offset},d.prototype.fixed=function(t){return t<this.fixedCount?t-this.offset:t},d.prototype.unFixed=function(t){return t<this.fixedCount?t+this.offset:t},d.prototype.visibleToSource=function(t){return this.source(this.offsetted(this.fixed(t)))},d.prototype.sourceToVisible=function(t){return this.source(this.unOffsetted(this.unFixed(t)))},p.prototype.getSize=function(t){return this.cellSizes[t]},p.prototype.getContainerSize=function(t){return"function"==typeof this.containerSizeFn?this.containerSizeFn(t):this.containerSizeFn},p.prototype.countVisible=function(){return this.cellCount},p.prototype.isLastIncomplete=function(){if(this.instance.getSetting("nativeScrollbars")){var t=this.instance.cloneFrom?this.instance.cloneFrom.wtScrollbars.vertical:this.instance.wtScrollbars.vertical;return this.remainingSize>t.sumCellSizes(t.offset,t.offset+t.curOuts+1)}return this.remainingSize>0},f.prototype.add=function(t,e,o){this.cache[t]||(this.cache[t]=[]),this.cache[t][e]||(this.cache[t][e]=[]),this.cache[t][e][o]=!0},f.prototype.test=function(t,e,o){return this.cache[t]&&this.cache[t][e]&&this.cache[t][e][o]},g.prototype=new d,g.prototype.readSettings=function(t){this.offset=t.wtSettings.settings.offsetColumn,this.total=t.getSetting("totalColumns"),this.fixedCount=t.getSetting("fixedColumnsLeft"),this.countTH=t.getSetting("rowHeaders").length},g.prototype.offsettedTH=function(t){return t-this.countTH},g.prototype.unOffsettedTH=function(t){return t+this.countTH},g.prototype.visibleRowHeadedColumnToSourceColumn=function(t){return this.visibleToSource(this.offsettedTH(t))},g.prototype.sourceColumnToVisibleRowHeadedColumn=function(t){return this.unOffsettedTH(this.sourceToVisible(t))},m.prototype=new p,m.prototype.getSize=function(t){return this.cellSizes[t]+(this.cellStretch[t]||0)},m.prototype.stretch=function(){var t=this.getContainerSize(this.cellSizesSum),e=0;if(this.remainingSize=this.cellSizesSum-t,this.cellStretch.length=0,"all"===this.strategy){if(this.remainingSize<0){for(var o,i=t/this.cellSizesSum;e<this.cellCount-1;)o=Math.floor(i*this.cellSizes[e]),this.remainingSize+=o-this.cellSizes[e],this.cellStretch[e]=o-this.cellSizes[e],e++;this.cellStretch[this.cellCount-1]=-this.remainingSize,this.remainingSize=0}}else"last"===this.strategy&&this.remainingSize<0&&t!==1/0&&(this.cellStretch[this.cellCount-1]=-this.remainingSize,this.remainingSize=0)},w.prototype.draw=function(t){return this.drawInterrupted=!1,t||this.wtDom.isVisible(this.wtTable.TABLE)?(this.getSetting("beforeDraw",!t),t=t&&this.getSetting("offsetRow")===this.lastOffsetRow&&this.getSetting("offsetColumn")===this.lastOffsetColumn,this.drawn&&(this.scrollVertical(0),this.scrollHorizontal(0)),this.lastOffsetRow=this.getSetting("offsetRow"),this.lastOffsetColumn=this.getSetting("offsetColumn"),this.wtTable.draw(t),this.cloneSource||this.getSetting("onDraw",!t),this):void(this.drawInterrupted=!0)},w.prototype.update=function(t,e){return this.wtSettings.update(t,e)},w.prototype.scrollVertical=function(t){var e=this.wtScroll.scrollVertical(t);return this.getSetting("onScrollVertically"),e},w.prototype.scrollHorizontal=function(t){var e=this.wtScroll.scrollHorizontal(t);return this.getSetting("onScrollHorizontally"),e},w.prototype.scrollViewport=function(t){return this.wtScroll.scrollViewport(t),this},w.prototype.getViewport=function(){return[this.wtTable.rowFilter.visibleToSource(0),this.wtTable.columnFilter.visibleToSource(0),this.wtTable.getLastVisibleRow(),this.wtTable.getLastVisibleColumn()]},w.prototype.getSetting=function(t,e,o,i){return this.wtSettings.getSetting(t,e,o,i)},w.prototype.hasSetting=function(t){return this.wtSettings.has(t)},w.prototype.destroy=function(){$(document.body).off("."+this.guid),this.wtScrollbars.destroy(),clearTimeout(this.wheelTimeout),this.wtEvent&&this.wtEvent.destroy()},y.prototype=new h,y.prototype.resetFixedPosition=function(){if(this.instance.wtTable.holder.parentNode){var t=this.clone.wtTable.holder.parentNode,e=this.instance.wtTable.holder.getBoundingClientRect();t.style.top=Math.ceil(e.top,10)+"px",t.style.left=Math.ceil(e.left,10)+"px"}},y.prototype.prepare=function(){},y.prototype.refresh=function(t){this.clone&&this.clone.draw(t)},y.prototype.getScrollPosition=function(){},y.prototype.getLastCell=function(){},y.prototype.applyToDOM=function(){},y.prototype.scrollTo=function(){},y.prototype.readWindowSize=function(){},y.prototype.readSettings=function(){},v.prototype.closest=function(t,e,o){for(;null!=t&&t!==o;){if(1===t.nodeType&&e.indexOf(t.nodeName)>-1)return t;t=t.parentNode}return null},v.prototype.isChildOf=function(t,e){for(var o=t.parentNode;null!=o;){if(o==e)return!0;o=o.parentNode}return!1},v.prototype.index=function(t){for(var e=0;t=t.previousSibling;)++e;return e},document.documentElement.classList?(v.prototype.hasClass=function(t,e){return t.classList.contains(e)},v.prototype.addClass=function(t,e){t.classList.add(e)},v.prototype.removeClass=function(t,e){t.classList.remove(e)}):(v.prototype.hasClass=function(t,e){return t.className.match(new RegExp("(\\s|^)"+e+"(\\s|$)"))},v.prototype.addClass=function(t,e){this.hasClass(t,e)||(t.className+=" "+e)},v.prototype.removeClass=function(t,e){if(this.hasClass(t,e)){var o=new RegExp("(\\s|^)"+e+"(\\s|$)");t.className=t.className.replace(o," ").trim()}}),v.prototype.removeTextNodes=function(t,e){if(3===t.nodeType)e.removeChild(t);else if(["TABLE","THEAD","TBODY","TFOOT","TR"].indexOf(t.nodeName)>-1)for(var o=t.childNodes,i=o.length-1;i>=0;i--)this.removeTextNodes(o[i],t)},v.prototype.empty=function(t){for(var e;e=t.lastChild;)t.removeChild(e)},v.prototype.HTML_CHARACTERS=/(<(.*)>|&(.*);)/,v.prototype.fastInnerHTML=function(t,e){this.HTML_CHARACTERS.test(e)?t.innerHTML=e:this.fastInnerText(t,e)},document.createTextNode("test").textContent?v.prototype.fastInnerText=function(t,e){var o=t.firstChild;o&&3===o.nodeType&&null===o.nextSibling?o.textContent=e:(this.empty(t),t.appendChild(document.createTextNode(e)))}:v.prototype.fastInnerText=function(t,e){var o=t.firstChild;o&&3===o.nodeType&&null===o.nextSibling?o.data=e:(this.empty(t),t.appendChild(document.createTextNode(e)))},v.prototype.isVisible=function(t){for(var e=t;e!==document.documentElement;){if(null===e)return!1;if(11===e.nodeType){if(e.host){if(e.host.impl)return v.prototype.isVisible(e.host.impl);if(e.host)return v.prototype.isVisible(e.host);throw new Error("Lost in Web Components world")}return!1}if("none"===e.style.display)return!1;e=e.parentNode}return!0},v.prototype.offset=function(t){if(this.hasCaptionProblem()&&t.firstChild&&"CAPTION"===t.firstChild.nodeName){var e=t.getBoundingClientRect();return{top:e.top+(o.pageYOffset||document.documentElement.scrollTop)-(document.documentElement.clientTop||0),left:e.left+(o.pageXOffset||document.documentElement.scrollLeft)-(document.documentElement.clientLeft||0)}}for(var i=t.offsetLeft,n=t.offsetTop,s=t;(t=t.offsetParent)&&t!==document.body;)i+=t.offsetLeft,n+=t.offsetTop,s=t;return s&&"fixed"===s.style.position&&(i+=o.pageXOffset||document.documentElement.scrollLeft,n+=o.pageYOffset||document.documentElement.scrollTop),{left:i,top:n}},v.prototype.getComputedStyle=function(t){return t.currentStyle||document.defaultView.getComputedStyle(t)},v.prototype.outerWidth=function(t){return t.offsetWidth},v.prototype.outerHeight=function(t){return this.hasCaptionProblem()&&t.firstChild&&"CAPTION"===t.firstChild.nodeName?t.offsetHeight+t.firstChild.offsetHeight:t.offsetHeight},function(){function t(){var t=document.createElement("TABLE");t.style.borderSpacing=0,t.style.borderWidth=0,t.style.padding=0;var e=document.createElement("TBODY");t.appendChild(e),e.appendChild(document.createElement("TR")),e.firstChild.appendChild(document.createElement("TD")),e.firstChild.firstChild.innerHTML="<tr><td>t<br>t</td></tr>";var i=document.createElement("CAPTION");i.innerHTML="c<br>c<br>c<br>c",i.style.padding=0,i.style.margin=0,t.insertBefore(i,e),document.body.appendChild(t),o=t.offsetHeight<2*t.lastChild.offsetHeight,document.body.removeChild(t)}function e(){var t=document.createElement("p");t.style.width="100%",t.style.height="200px";var e=document.createElement("div");e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.appendChild(t),(document.body||document.documentElement).appendChild(e);var o=t.offsetWidth;e.style.overflow="scroll";var i=t.offsetWidth;return o==i&&(i=e.clientWidth),(document.body||document.documentElement).removeChild(e),o-i}var o;v.prototype.hasCaptionProblem=function(){return void 0===o&&t(),o},v.prototype.getCaretPosition=function(t){if(t.selectionStart)return t.selectionStart;if(document.selection){t.focus();var e=document.selection.createRange();if(null==e)return 0;var o=t.createTextRange(),i=o.duplicate();return o.moveToBookmark(e.getBookmark()),i.setEndPoint("EndToStart",o),i.text.length}return 0},v.prototype.setCaretPosition=function(t,e,o){if(void 0===o&&(o=e),t.setSelectionRange)t.focus(),t.setSelectionRange(e,o);else if(t.createTextRange){var i=t.createTextRange();i.collapse(!0),i.moveEnd("character",o),i.moveStart("character",e),i.select()}};var i;v.prototype.getScrollbarWidth=function(){return void 0===i&&(i=e()),i}}(),C.prototype.parentCell=function(t){var e={},o=this.instance.wtTable.TABLE,i=this.wtDom.closest(t,["TD","TH"],o);return i&&this.wtDom.isChildOf(i,o)?(e.coords=this.instance.wtTable.getCoords(i),e.TD=i):this.wtDom.hasClass(t,"wtBorder")&&this.wtDom.hasClass(t,"current")&&(e.coords=this.instance.selections.current.selected[0],e.TD=this.instance.wtTable.getCell(e.coords)),e},C.prototype.destroy=function(){clearTimeout(this.dblClickTimeout0),clearTimeout(this.dblClickTimeout1)},o.requestAnimFrame=function(){return o.requestAnimationFrame||o.webkitRequestAnimationFrame||o.mozRequestAnimationFrame||o.oRequestAnimationFrame||o.msRequestAnimationFrame||function(t,e){return o.setTimeout(t,1e3/60)}}(),o.cancelRequestAnimFrame=function(){return o.cancelAnimationFrame||o.webkitCancelRequestAnimationFrame||o.mozCancelRequestAnimationFrame||o.oCancelRequestAnimationFrame||o.msCancelRequestAnimationFrame||clearTimeout}(),o.getComputedStyle||!function(){var t,e={getPropertyValue:function(e){return"float"==e&&(e="styleFloat"),t.currentStyle[e.toUpperCase()]||null}};o.getComputedStyle=function(o){return t=o,e}}(),!String.prototype.trim){var G=/^\s+|\s+$/g;String.prototype.trim=function(){return this.replace(G,"")}}S.prototype=new d,S.prototype.readSettings=function(t){t.cloneOverlay instanceof y?this.offset=0:this.offset=t.wtSettings.settings.offsetRow,this.total=t.getSetting("totalRows"),this.fixedCount=t.getSetting("fixedRowsTop")},T.prototype=new p,T.prototype.add=function(t,e,o){if(!this.isLastIncomplete()&&0!=this.remainingSize){var i=this.sizeAtIndex(t,e);if(void 0===i)return!1;var n=this.getContainerSize(this.cellSizesSum+i);return o?this.cellSizes.unshift(i):this.cellSizes.push(i),this.cellSizesSum+=i,this.cellCount++,this.remainingSize=this.cellSizesSum-n,o&&this.isLastIncomplete()?!1:!0}return!1},T.prototype.remove=function(){var t=this.cellSizes.pop();this.cellSizesSum-=t,this.cellCount--,this.remainingSize-=t},T.prototype.removeOutstanding=function(){for(;this.cellCount>0&&this.cellSizes[this.cellCount-1]<this.remainingSize;)this.remove()},R.prototype.scrollVertical=function(t){if(!this.instance.drawn)throw new Error("scrollVertical can only be called after table was drawn to DOM");var e,o=this.instance,i=o.getSetting("offsetRow"),n=o.getSetting("fixedRowsTop"),s=o.getSetting("totalRows"),r=o.wtViewport.getViewportHeight();return e=s>0?this.scrollLogicVertical(t,i,s,n,r,function(t){return n>t-i&&t-i>=0?o.getSetting("rowHeight",t-i):o.getSetting("rowHeight",t)},function(t){o.wtTable.verticalRenderReverse=t}):0,e!==i&&this.instance.wtScrollbars.vertical.scrollTo(e),o},R.prototype.scrollHorizontal=function(t){if(!this.instance.drawn)throw new Error("scrollHorizontal can only be called after table was drawn to DOM");var e,o=this.instance,i=o.getSetting("offsetColumn"),n=o.getSetting("fixedColumnsLeft"),s=o.getSetting("totalColumns"),r=o.wtViewport.getViewportWidth();return e=s>0?this.scrollLogicHorizontal(t,i,s,n,r,function(t){return n>t-i&&t-i>=0?o.getSetting("columnWidth",t-i):o.getSetting("columnWidth",t)}):0,e!==i&&this.instance.wtScrollbars.horizontal.scrollTo(e),o},R.prototype.scrollLogicVertical=function(t,e,o,i,n,s,r){var a=e+t;return a>=o-i&&(a=o-i-1,r(!0)),0>a&&(a=0),a},R.prototype.scrollLogicHorizontal=function(t,e,o,i,n,s){var r,a=e+t,l=0;if(a>i){for(a>=o-i&&(a=o-i-1),r=a;n>l&&o>r;)l+=s(r),r++;if(n>l)for(;a>0&&(l+=s(a-1),n>l);)a--}else 0>a&&(a=0);return a},R.prototype.scrollViewport=function(t){if(this.instance.drawn){var e=this.instance.getSetting("offsetRow"),i=(this.instance.getSetting("offsetColumn"),this.instance.wtTable.getLastVisibleRow()),n=this.instance.getSetting("totalRows"),s=this.instance.getSetting("totalColumns"),r=this.instance.getSetting("fixedRowsTop"),a=this.instance.getSetting("fixedColumnsLeft");if(this.instance.getSetting("nativeScrollbars")){var l=this.instance.wtTable.getCell(t);if("object"==typeof l){var c=v.prototype.offset(l),h=v.prototype.outerWidth(l),u=v.prototype.outerHeight(l),d=this.instance.wtScrollbars.horizontal.getScrollPosition(),p=this.instance.wtScrollbars.vertical.getScrollPosition(),f=v.prototype.outerWidth(this.instance.wtScrollbars.horizontal.scrollHandler),g=v.prototype.outerHeight(this.instance.wtScrollbars.vertical.scrollHandler);return this.instance.wtScrollbars.horizontal.scrollHandler!==o&&(c.left=c.left-v.prototype.offset(this.instance.wtScrollbars.horizontal.scrollHandler).left),this.instance.wtScrollbars.vertical.scrollHandler!==o&&(c.top=c.top-v.prototype.offset(this.instance.wtScrollbars.vertical.scrollHandler).top),f-=20,g-=20,f>h&&(c.left<d?this.instance.wtScrollbars.horizontal.setScrollPosition(c.left):c.left+h>d+f&&this.instance.wtScrollbars.horizontal.setScrollPosition(c.left-f+h)),void(g>u&&(c.top<p?this.instance.wtScrollbars.vertical.setScrollPosition(c.top):c.top+u>p+g&&this.instance.wtScrollbars.vertical.setScrollPosition(c.top-g+u)))}}if(t[0]<0||t[0]>n-1)throw new Error("row "+t[0]+" does not exist");if(t[1]<0||t[1]>s-1)throw new Error("column "+t[1]+" does not exist");if(t[0]>i?(this.scrollVertical(t[0]-r-e),this.instance.wtTable.verticalRenderReverse=!0):t[0]===i&&this.instance.wtTable.rowStrategy.isLastIncomplete()?(this.scrollVertical(t[0]-r-e),this.instance.wtTable.verticalRenderReverse=!0):t[0]-r<e?this.scrollVertical(t[0]-r-e):this.scrollVertical(0),this.instance.wtTable.isColumnBeforeViewport(t[1]))this.instance.wtScrollbars.horizontal.scrollTo(t[1]-a);else if(this.instance.wtTable.isColumnAfterViewport(t[1])||this.instance.wtTable.getLastVisibleColumn()===t[1]&&!this.instance.wtTable.isLastColumnFullyVisible()){for(var m=0,w=0;a>w;w++)m+=this.instance.getSetting("columnWidth",w);var y=t[1];m+=this.instance.getSetting("columnWidth",y);var C=this.instance.wtViewport.getViewportWidth();if(C>m)for(var b=this.instance.getSetting("columnWidth",y-1);C>=m+b&&y>=a;)y--,m+=b,b=this.instance.getSetting("columnWidth",y-1);this.instance.wtScrollbars.horizontal.scrollTo(y-a)}return this.instance}},E.prototype.init=function(){var t=this;this.$table=$(this.instance.wtTable.TABLE),this.slider=document.createElement("DIV"),this.sliderStyle=this.slider.style,this.sliderStyle.position="absolute",this.sliderStyle.top="0",this.sliderStyle.left="0",this.sliderStyle.display="none",this.slider.className="dragdealer "+this.type,this.handle=document.createElement("DIV"),this.handleStyle=this.handle.style,this.handle.className="handle",this.slider.appendChild(this.handle),this.container=this.instance.wtTable.holder,this.container.appendChild(this.slider);var e=!0;this.dragTimeout=null;var o,i=function(){t.onScroll(o)};this.dragdealer=new J(this.slider,{vertical:"vertical"===this.type,horizontal:"horizontal"===this.type,slide:!1,speed:100,animationCallback:function(n,s){return e?void(e=!1):(t.skipRefresh=!0,o="vertical"===t.type?s:n,void(null===t.dragTimeout&&(t.dragTimeout=setInterval(i,100),i())))},callback:function(e,i){t.skipRefresh=!1,clearInterval(t.dragTimeout),t.dragTimeout=null,o="vertical"===t.type?i:e,t.onScroll(o)}}),this.skipRefresh=!1},E.prototype.onScroll=function(t){if(this.instance.drawn&&(this.readSettings(),this.total>this.visibleCount)){var e=Math.round(this.handlePosition*this.total/this.sliderSize);1===t?"vertical"===this.type?this.instance.scrollVertical(1/0).draw():this.instance.scrollHorizontal(1/0).draw():e!==this.offset?"vertical"===this.type?this.instance.scrollVertical(e-this.offset).draw():this.instance.scrollHorizontal(e-this.offset).draw():this.refresh()}},E.prototype.getHandleSizeRatio=function(t,e){return!e||t>e||t==e?1:1/e},E.prototype.prepare=function(){if(!this.skipRefresh){var t=this.getHandleSizeRatio(this.visibleCount,this.total);(1===t||isNaN(t))&&"auto"===this.scrollMode||"none"===this.scrollMode?this.visible=!1:this.visible=!0}},E.prototype.refresh=function(){if(!this.skipRefresh){if(!this.visible)return void(this.sliderStyle.display="none");
var t,e,o,i,n=this.visibleCount,s=this.instance.wtViewport.getWorkspaceWidth(),r=this.instance.wtViewport.getWorkspaceHeight();s===1/0&&(s=this.instance.wtViewport.getWorkspaceActualWidth()),r===1/0&&(r=this.instance.wtViewport.getWorkspaceActualHeight()),"vertical"===this.type?(this.instance.wtTable.rowStrategy.isLastIncomplete()&&n--,e=r-2,this.sliderStyle.top=this.instance.wtDom.offset(this.$table[0]).top-this.instance.wtDom.offset(this.container).top+"px",this.sliderStyle.left=s-1+"px",this.sliderStyle.height=Math.max(e,0)+"px"):(e=s-2,this.sliderStyle.left=this.instance.wtDom.offset(this.$table[0]).left-this.instance.wtDom.offset(this.container).left+"px",this.sliderStyle.top=r-1+"px",this.sliderStyle.width=Math.max(e,0)+"px"),t=this.getHandleSizeRatio(n,this.total),o=Math.round(e*t),10>o&&(o=15),i=Math.floor(e*(this.offset/this.total)),o+i>e&&(i=e-o),"vertical"===this.type?(this.handleStyle.height=o+"px",this.handleStyle.top=i+"px"):(this.handleStyle.width=o+"px",this.handleStyle.left=i+"px"),this.sliderStyle.display="block"}},E.prototype.destroy=function(){clearInterval(this.dragdealer.interval)};var K=function(t){this.instance=t,this.type="vertical",this.init()};K.prototype=new E,K.prototype.scrollTo=function(t){this.instance.update("offsetRow",t)},K.prototype.readSettings=function(){this.scrollMode=this.instance.getSetting("scrollV"),this.offset=this.instance.getSetting("offsetRow"),this.total=this.instance.getSetting("totalRows"),this.visibleCount=this.instance.wtTable.rowStrategy.countVisible(),this.visibleCount>1&&this.instance.wtTable.rowStrategy.isLastIncomplete()&&this.visibleCount--,this.handlePosition=parseInt(this.handleStyle.top,10),this.sliderSize=parseInt(this.sliderStyle.height,10),this.fixedCount=this.instance.getSetting("fixedRowsTop")};var X=function(t){this.instance=t,this.type="horizontal",this.init()};X.prototype=new E,X.prototype.scrollTo=function(t){this.instance.update("offsetColumn",t)},X.prototype.readSettings=function(){this.scrollMode=this.instance.getSetting("scrollH"),this.offset=this.instance.getSetting("offsetColumn"),this.total=this.instance.getSetting("totalColumns"),this.visibleCount=this.instance.wtTable.columnStrategy.countVisible(),this.visibleCount>1&&this.instance.wtTable.columnStrategy.isLastIncomplete()&&this.visibleCount--,this.handlePosition=parseInt(this.handleStyle.left,10),this.sliderSize=parseInt(this.sliderStyle.width,10),this.fixedCount=this.instance.getSetting("fixedColumnsLeft")},X.prototype.getHandleSizeRatio=function(t,e){return!e||t>e||t==e?1:t/e},D.prototype=new h,D.prototype.resetFixedPosition=function(){if(this.instance.wtTable.holder.parentNode){var t,e=this.clone.wtTable.holder.parentNode;if(this.scrollHandler===o){t=this.instance.wtTable.hider.getBoundingClientRect();var i=Math.ceil(t.top,10),n=Math.ceil(t.bottom,10);0>i&&n>0?e.style.top="0":e.style.top=i+"px";var s=Math.ceil(t.left,10),r=Math.ceil(t.right,10);0>s&&r>0?e.style.left="0":e.style.left=s+"px"}else t=this.scrollHandler.getBoundingClientRect(),e.style.top=Math.ceil(t.top,10)+"px",e.style.left=Math.ceil(t.left,10)+"px";e.style.width=v.prototype.outerWidth(this.clone.wtTable.TABLE)+4+"px",e.style.height=v.prototype.outerHeight(this.clone.wtTable.TABLE)+4+"px"}},D.prototype.prepare=function(){},D.prototype.refresh=function(t){this.measureBefore=0,this.measureAfter=0,this.clone&&this.clone.draw(t)},D.prototype.getScrollPosition=function(){},D.prototype.getLastCell=function(){},D.prototype.applyToDOM=function(){},D.prototype.scrollTo=function(){},D.prototype.readWindowSize=function(){},D.prototype.readSettings=function(){},H.prototype=new h,H.prototype.resetFixedPosition=function(){if(this.instance.wtTable.holder.parentNode){var t,e=this.clone.wtTable.holder.parentNode;if(this.scrollHandler===o){t=this.instance.wtTable.hider.getBoundingClientRect();var i=Math.ceil(t.left,10),n=Math.ceil(t.right,10);0>i&&n>0?e.style.left="0":e.style.left=i+"px"}else t=this.scrollHandler.getBoundingClientRect(),e.style.top=Math.ceil(t.top,10)+"px",e.style.left=Math.ceil(t.left,10)+"px"}},H.prototype.react=function(){if(this.instance.wtTable.holder.parentNode){var t=this.clone.wtTable.holder.parentNode;if(this.instance.wtScrollbars.vertical.scrollHandler===o){var e=this.instance.wtTable.hider.getBoundingClientRect();t.style.top=Math.ceil(e.top,10)+"px",t.style.height=v.prototype.outerHeight(this.clone.wtTable.TABLE)+"px"}else this.clone.wtTable.holder.style.top=-(this.instance.wtScrollbars.vertical.windowScrollPosition-this.instance.wtScrollbars.vertical.measureBefore)+"px",t.style.height=this.instance.wtViewport.getWorkspaceHeight()+"px";t.style.width=v.prototype.outerWidth(this.clone.wtTable.TABLE)+4+"px"}},H.prototype.prepare=function(){},H.prototype.refresh=function(t){this.measureBefore=0,this.measureAfter=0,this.clone&&this.clone.draw(t)},H.prototype.getScrollPosition=function(){return this.scrollHandler===o?this.scrollHandler.scrollX:this.scrollHandler.scrollLeft},H.prototype.setScrollPosition=function(t){this.scrollHandler.scrollLeft=t},H.prototype.onScroll=function(){h.prototype.onScroll.apply(this,arguments),this.instance.getSetting("onScrollHorizontally")},H.prototype.getLastCell=function(){return this.instance.wtTable.getLastVisibleColumn()},H.prototype.applyToDOM=function(){this.fixedContainer.style.paddingLeft=this.measureBefore+"px",this.fixedContainer.style.paddingRight=this.measureAfter+"px"},H.prototype.scrollTo=function(t){this.$scrollHandler.scrollLeft(this.tableParentOffset+t*this.cellSize)},H.prototype.readWindowSize=function(){this.scrollHandler===o?(this.windowSize=document.documentElement.clientWidth,this.tableParentOffset=this.instance.wtTable.holderOffset.left):(this.windowSize=v.prototype.outerWidth(this.scrollHandler),this.tableParentOffset=0),this.windowScrollPosition=this.getScrollPosition()},H.prototype.readSettings=function(){this.offset=this.instance.getSetting("offsetColumn"),this.total=this.instance.getSetting("totalColumns")},x.prototype=new h,x.prototype.resetFixedPosition=function(){if(this.instance.wtTable.holder.parentNode){var t,e=this.clone.wtTable.holder.parentNode;if(this.scrollHandler===o){t=this.instance.wtTable.hider.getBoundingClientRect();var i=Math.ceil(t.top,10),n=Math.ceil(t.bottom,10);0>i&&n>0?e.style.top="0":e.style.top=i+"px"}else t=this.instance.wtScrollbars.horizontal.scrollHandler.getBoundingClientRect(),e.style.top=Math.ceil(t.top,10)+"px",e.style.left=Math.ceil(t.left,10)+"px";this.instance.wtScrollbars.horizontal.scrollHandler===o?e.style.width=this.instance.wtViewport.getWorkspaceActualWidth()+"px":e.style.width=v.prototype.outerWidth(this.instance.wtTable.holder.parentNode)+"px",e.style.height=v.prototype.outerHeight(this.clone.wtTable.TABLE)+4+"px"}},x.prototype.react=function(){if(this.instance.wtTable.holder.parentNode&&this.instance.wtScrollbars.horizontal.scrollHandler!==o){var t=this.clone.wtTable.holder.parentNode;t.firstChild.style.left=-this.instance.wtScrollbars.horizontal.windowScrollPosition+"px"}},x.prototype.getScrollPosition=function(){return this.scrollHandler===o?this.scrollHandler.scrollY:this.scrollHandler.scrollTop},x.prototype.setScrollPosition=function(t){this.scrollHandler.scrollTop=t},x.prototype.onScroll=function(t){h.prototype.onScroll.apply(this,arguments);var e,o=0;if(e=this.windowScrollPosition-this.tableParentOffset,Y=0,e>0){for(var i,n=0,s=0;s<this.total&&(i=this.instance.getSetting("rowHeight",s),n+=i,!(n>e));s++);this.offset>0&&(Y=n-e),o=s,o=Math.min(o,this.total)}this.curOuts=o>this.maxOuts?this.maxOuts:o,o-=this.curOuts,this.instance.update("offsetRow",o),this.readSettings(),this.instance.draw(),this.instance.getSetting("onScrollVertically")},x.prototype.getLastCell=function(){return this.instance.getSetting("offsetRow")+this.instance.wtTable.tbodyChildrenLength-1};var Y=0;x.prototype.sumCellSizes=function(t,e){for(var o=0;e>t;)o+=this.instance.getSetting("rowHeight",t),t++;return o},x.prototype.applyToDOM=function(){var t=this.instance.wtViewport.getColumnHeaderHeight();this.fixedContainer.style.height=t+this.sumCellSizes(0,this.total)+4+"px",this.fixed.style.top=this.measureBefore+"px",this.fixed.style.bottom=""},x.prototype.scrollTo=function(t){var e=this.tableParentOffset+t*this.cellSize;this.$scrollHandler.scrollTop(e),this.onScroll(e)},x.prototype.readWindowSize=function(){this.scrollHandler===o?(this.windowSize=document.documentElement.clientHeight,this.tableParentOffset=this.instance.wtTable.holderOffset.top):(this.windowSize=this.scrollHandler.clientHeight,this.tableParentOffset=0),this.windowScrollPosition=this.getScrollPosition()},x.prototype.readSettings=function(){this.offset=this.instance.getSetting("offsetRow"),this.total=this.instance.getSetting("totalRows")},k.prototype.registerListeners=function(){function t(){return l.instance.wtTable.holder.parentNode?(l.vertical.windowScrollPosition=l.vertical.getScrollPosition(),l.horizontal.windowScrollPosition=l.horizontal.getScrollPosition(),l.box=l.instance.wtTable.hider.getBoundingClientRect(),l.box.width===r&&l.box.height===a||!l.instance.rowHeightCache||(r=l.box.width,a=l.box.height,l.instance.draw()),void((l.vertical.windowScrollPosition!==e||l.horizontal.windowScrollPosition!==i||l.box.top!==n||l.box.left!==s)&&(l.vertical.onScroll(),l.horizontal.onScroll(),l.vertical.react(),l.horizontal.react(),e=l.vertical.windowScrollPosition,i=l.horizontal.windowScrollPosition,n=l.box.top,s=l.box.left))):void l.destroy()}var e,i,n,s,r,a,l=this,c=$(o);this.vertical.$scrollHandler.on("scroll."+this.instance.guid,t),this.vertical.scrollHandler!==this.horizontal.scrollHandler&&this.horizontal.$scrollHandler.on("scroll."+this.instance.guid,t),this.vertical.scrollHandler!==o&&this.horizontal.scrollHandler!==o&&c.on("scroll."+this.instance.guid,t),c.on("load."+this.instance.guid,t),c.on("resize."+this.instance.guid,t),$(document).on("ready."+this.instance.guid,t),setInterval(t,100)},k.prototype.destroy=function(){this.vertical&&this.vertical.destroy(),this.horizontal&&this.horizontal.destroy()},k.prototype.refresh=function(t){this.horizontal&&this.horizontal.readSettings(),this.vertical&&this.vertical.readSettings(),this.horizontal&&this.horizontal.prepare(),this.vertical&&this.vertical.prepare(),this.horizontal&&this.horizontal.refresh(t),this.vertical&&this.vertical.refresh(t),this.corner&&this.corner.refresh(t),this.debug&&this.debug.refresh(t)},A.prototype.add=function(t){this.selected.push(t)},A.prototype.clear=function(){this.selected.length=0},A.prototype.getCorners=function(){var t,e,o,i,n,s=this.selected.length;if(s>0&&(t=o=this.selected[0][0],e=i=this.selected[0][1],s>1))for(n=1;s>n;n++)this.selected[n][0]<t?t=this.selected[n][0]:this.selected[n][0]>o&&(o=this.selected[n][0]),this.selected[n][1]<e?e=this.selected[n][1]:this.selected[n][1]>i&&(i=this.selected[n][1]);return[t,e,o,i]},A.prototype.draw=function(){var t,e,o,i,n,s=this.instance.wtTable.rowStrategy.countVisible(),r=this.instance.wtTable.columnStrategy.countVisible();if(this.selected.length){for(t=this.getCorners(),e=0;s>e;e++)for(o=0;r>o;o++)i=this.instance.wtTable.rowFilter.visibleToSource(e),n=this.instance.wtTable.columnFilter.visibleToSource(o),i>=t[0]&&i<=t[2]&&n>=t[1]&&n<=t[3]?this.instance.wtTable.currentCellCache.add(e,o,this.settings.className):i>=t[0]&&i<=t[2]?this.instance.wtTable.currentCellCache.add(e,o,this.settings.highlightRowClassName):n>=t[1]&&n<=t[3]&&this.instance.wtTable.currentCellCache.add(e,o,this.settings.highlightColumnClassName);this.border&&this.border.appear(t)}else this.border&&this.border.disappear()},P.prototype.update=function(t,e){if(void 0===e)for(var o in t)t.hasOwnProperty(o)&&(this.settings[o]=t[o]);else this.settings[t]=e;return this.instance},P.prototype.getSetting=function(t,e,o,i){return this[t]?this[t](e,o,i):this._getSetting(t,e,o,i)},P.prototype._getSetting=function(t,e,o,i){return"function"==typeof this.settings[t]?this.settings[t](e,o,i):void 0!==e&&"[object Array]"===Object.prototype.toString.call(this.settings[t])?this.settings[t][e]:this.settings[t]},P.prototype.has=function(t){return!!this.settings[t]},P.prototype.rowHeight=function(t,e){if(this.instance.rowHeightCache||(this.instance.rowHeightCache=[]),void 0===this.instance.rowHeightCache[t]){var o=23;return e&&(o=this.instance.wtDom.outerHeight(e),this.instance.rowHeightCache[t]=o),o}return this.instance.rowHeightCache[t]},O.prototype.refreshHiderDimensions=function(){var t=this.instance.wtViewport.getWorkspaceHeight(),e=this.instance.wtViewport.getWorkspaceWidth(),o=this.spreader.style;t===1/0&&e===1/0||this.instance.getSetting("nativeScrollbars")?(o.position="relative",o.width="auto",o.height="auto"):(t===1/0&&(t=this.instance.wtViewport.getWorkspaceActualHeight()),e===1/0&&(e=this.instance.wtViewport.getWorkspaceActualWidth()),this.hiderStyle.overflow="hidden",o.position="absolute",o.top="0",o.left="0",this.instance.getSetting("nativeScrollbars")||(o.height="4000px",o.width="4000px"),0>t&&(t=0),this.hiderStyle.height=t+"px",this.hiderStyle.width=e+"px")},O.prototype.refreshStretching=function(){if(!this.instance.cloneSource){var t=this.instance,e=t.getSetting("stretchH"),o=t.getSetting("totalRows"),i=t.getSetting("totalColumns"),n=t.getSetting("offsetColumn"),s=function(t){var e=r.instance.wtViewport.getViewportWidth(t);return t>e&&r.instance.getSetting("nativeScrollbars")?1/0:e},r=this,a=function(e){var o=r.columnFilter.visibleToSource(e);return i>o?t.getSetting("columnWidth",o):void 0};"hybrid"===e&&(e=n>0?"last":"none");var l=function(t){return r.instance.getSetting("nativeScrollbars")?r.instance.cloneOverlay instanceof y?1/0:2*r.instance.wtViewport.getViewportHeight(t):r.instance.wtViewport.getViewportHeight(t)},c=function(t,e){if(r.instance.getSetting("nativeScrollbars"))return 20;var i=r.rowFilter.visibleToSource(t);return o>i?r.verticalRenderReverse&&0===t?r.instance.getSetting("rowHeight",i,e)-1:r.instance.getSetting("rowHeight",i,e):void 0};this.columnStrategy=new m(t,s,a,e),this.rowStrategy=new T(t,l,c)}},O.prototype.adjustAvailableNodes=function(){for(var t,e,o,i,n=this.instance.getSetting("rowHeaders"),s=n.length,r=this.instance.getSetting("columnHeaders");this.colgroupChildrenLength<s;)this.COLGROUP.appendChild(document.createElement("COL")),this.colgroupChildrenLength++;for(this.refreshStretching(),t=this.instance.cloneSource&&(this.instance.cloneOverlay instanceof H||this.instance.cloneOverlay instanceof D)?this.instance.getSetting("fixedColumnsLeft"):this.columnStrategy.cellCount;this.colgroupChildrenLength<t+s;)this.COLGROUP.appendChild(document.createElement("COL")),this.colgroupChildrenLength++;for(;this.colgroupChildrenLength>t+s;)this.COLGROUP.removeChild(this.COLGROUP.lastChild),this.colgroupChildrenLength--;if(e=this.THEAD.firstChild,r.length){for(e||(e=document.createElement("TR"),this.THEAD.appendChild(e)),this.theadChildrenLength=e.childNodes.length;this.theadChildrenLength<t+s;)e.appendChild(document.createElement("TH")),this.theadChildrenLength++;for(;this.theadChildrenLength>t+s;)e.removeChild(e.lastChild),this.theadChildrenLength--}else e&&this.wtDom.empty(e);for(i=0;i<this.colgroupChildrenLength;i++)s>i?this.wtDom.addClass(this.COLGROUP.childNodes[i],"rowHeader"):this.wtDom.removeClass(this.COLGROUP.childNodes[i],"rowHeader");if(r.length&&(e=this.THEAD.firstChild,s))for(o=e.firstChild,i=0;s>i;i++)n[i](-s+i,o),o=o.nextSibling;for(i=0;t>i;i++)r.length&&r[0](this.columnFilter.visibleToSource(i),e.childNodes[s+i])},O.prototype.adjustColumns=function(t,e){for(var o=t.childNodes.length;e>o;){var i=document.createElement("TD");t.appendChild(i),o++}for(;o>e;)t.removeChild(t.lastChild),o--},O.prototype.draw=function(t){return this.instance.getSetting("nativeScrollbars")&&(this.verticalRenderReverse=!1),this.rowFilter.readSettings(this.instance),this.columnFilter.readSettings(this.instance),t?this.instance.wtScrollbars&&this.instance.wtScrollbars.refresh(!0):(this.instance.getSetting("nativeScrollbars")?this.instance.cloneSource?this.tableOffset=this.instance.cloneSource.wtTable.tableOffset:(this.holderOffset=this.wtDom.offset(this.holder),this.tableOffset=this.wtDom.offset(this.TABLE),this.instance.wtScrollbars.vertical.readWindowSize(),this.instance.wtScrollbars.horizontal.readWindowSize(),this.instance.wtViewport.resetSettings()):(this.tableOffset=this.wtDom.offset(this.TABLE),this.instance.wtViewport.resetSettings()),this._doDraw()),this.refreshPositions(t),t||this.instance.getSetting("nativeScrollbars")&&(this.instance.cloneSource||(this.instance.wtScrollbars.vertical.resetFixedPosition(),this.instance.wtScrollbars.horizontal.resetFixedPosition(),this.instance.wtScrollbars.corner.resetFixedPosition(),this.instance.wtScrollbars.debug&&this.instance.wtScrollbars.debug.resetFixedPosition())),this.instance.drawn=!0,this},O.prototype._doDraw=function(){var t,e,o,i,n,s,r,a,l,c,h=0,u=this.instance.getSetting("offsetRow"),d=this.instance.getSetting("totalRows"),p=this.instance.getSetting("totalColumns"),f=this.instance.getSetting("rowHeaders"),g=f.length,m=!1;this.verticalRenderReverse&&(l=u);var w=!1;if(this.verticalRenderReverse&&(u===d-this.rowFilter.fixedCount-1?w=!0:(this.instance.update("offsetRow",u+1),this.rowFilter.readSettings(this.instance))),this.instance.cloneSource&&(this.columnStrategy=this.instance.cloneSource.wtTable.columnStrategy,this.rowStrategy=this.instance.cloneSource.wtTable.rowStrategy),p>0){t=this.rowFilter.visibleToSource(h);var v,C=this.instance.getSetting("fixedRowsTop");for(this.instance.cloneSource&&(this.instance.cloneOverlay instanceof x||this.instance.cloneOverlay instanceof D?v=C:this.instance.cloneOverlay instanceof H&&(v=this.rowStrategy.countVisible())),this.adjustAvailableNodes(),m=!0,i=this.instance.cloneSource&&(this.instance.cloneOverlay instanceof H||this.instance.cloneOverlay instanceof D)?this.instance.getSetting("fixedColumnsLeft"):this.columnStrategy.cellCount,this.instance.cloneSource||(a=this.instance.wtViewport.getWorkspaceWidth(),this.columnStrategy.stretch()),e=0;i>e;e++)this.COLGROUP.childNodes[e+g].style.width=this.columnStrategy.getSize(e)+"px";for(;d>t&&t>=0;){if(h>1e3)throw new Error("Security brake: Too much TRs. Please define height for your table, which will enforce scrollbars.");if(void 0!==v&&h===v)break;if(h>=this.tbodyChildrenLength||this.verticalRenderReverse&&h>=this.rowFilter.fixedCount){for(n=document.createElement("TR"),e=0;g>e;e++)n.appendChild(document.createElement("TH"));this.verticalRenderReverse&&h>=this.rowFilter.fixedCount?this.TBODY.insertBefore(n,this.TBODY.childNodes[this.rowFilter.fixedCount]||this.TBODY.firstChild):this.TBODY.appendChild(n),this.tbodyChildrenLength++}else n=0===h?this.TBODY.firstChild:n.nextSibling;for(r=n.firstChild,e=0;g>e;e++)"TD"==r.nodeName&&(s=r,r=document.createElement("TH"),n.insertBefore(r,s),n.removeChild(s)),f[e](t,r),r=r.nextSibling;for(this.adjustColumns(n,i+g),e=0;i>e;e++)o=this.columnFilter.visibleToSource(e),s=0===e?n.childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(o)]:s.nextSibling,"TH"==s.nodeName&&(r=s,s=document.createElement("TD"),n.insertBefore(s,r),n.removeChild(r)),s.className="",s.removeAttribute("style"),this.instance.getSetting("cellRenderer",t,o,s);if(u=this.instance.getSetting("offsetRow"),this.verticalRenderReverse&&w){if(-this.wtDom.outerHeight(n.firstChild)<this.rowStrategy.remainingSize){this.TBODY.removeChild(n),this.instance.update("offsetRow",u+1),this.tbodyChildrenLength--,this.rowFilter.readSettings(this.instance);break}this.instance.cloneSource||(c=this.rowStrategy.add(h,s,this.verticalRenderReverse),c===!1&&this.rowStrategy.removeOutstanding())}else if(!this.instance.cloneSource&&(c=this.rowStrategy.add(h,s,this.verticalRenderReverse),c===!1&&(this.instance.getSetting("nativeScrollbars")||this.rowStrategy.removeOutstanding()),this.rowStrategy.isLastIncomplete())){if(this.verticalRenderReverse&&!this.isRowInViewport(l))return this.verticalRenderReverse=!1,this.instance.update("offsetRow",l),void this.draw();break}if(this.instance.getSetting("nativeScrollbars")&&(this.instance.cloneSource?n.style.height=this.instance.getSetting("rowHeight",t)+"px":this.instance.getSetting("rowHeight",t,s)),this.verticalRenderReverse&&h>=this.rowFilter.fixedCount){if(0===u)break;this.instance.update("offsetRow",u-1),this.rowFilter.readSettings(this.instance)}else h++;t=this.rowFilter.visibleToSource(h)}}if(m||this.adjustAvailableNodes(),!(this.instance.cloneOverlay instanceof y))for(h=this.rowStrategy.countVisible();this.tbodyChildrenLength>h;)this.TBODY.removeChild(this.TBODY.lastChild),this.tbodyChildrenLength--;if(this.instance.wtScrollbars&&this.instance.wtScrollbars.refresh(!1),!this.instance.cloneSource&&a!==this.instance.wtViewport.getWorkspaceWidth())for(this.columnStrategy.stretch(),e=0;e<this.columnStrategy.cellCount;e++)this.COLGROUP.childNodes[e+g].style.width=this.columnStrategy.getSize(e)+"px";this.verticalRenderReverse=!1},O.prototype.refreshPositions=function(t){this.refreshHiderDimensions(),this.refreshSelections(t)},O.prototype.refreshSelections=function(t){var e,o,i,n,s,r,a=[],l=this.rowStrategy.countVisible(),c=this.columnStrategy.countVisible();if(this.oldCellCache=this.currentCellCache,this.currentCellCache=new f,this.instance.selections)for(o in this.instance.selections)this.instance.selections.hasOwnProperty(o)&&(this.instance.selections[o].draw(),this.instance.selections[o].settings.className&&a.push(this.instance.selections[o].settings.className),this.instance.selections[o].settings.highlightRowClassName&&a.push(this.instance.selections[o].settings.highlightRowClassName),this.instance.selections[o].settings.highlightColumnClassName&&a.push(this.instance.selections[o].settings.highlightColumnClassName));for(r=a.length,e=0;l>e;e++)for(i=0;c>i;i++)for(o=this.rowFilter.visibleToSource(e),n=this.columnFilter.visibleToSource(i),s=0;r>s;s++)this.currentCellCache.test(e,i,a[s])?this.wtDom.addClass(this.getCell([o,n]),a[s]):t&&this.oldCellCache.test(e,i,a[s])&&this.wtDom.removeClass(this.getCell([o,n]),a[s])},O.prototype.getCell=function(t){return this.isRowBeforeViewport(t[0])?-1:this.isRowAfterViewport(t[0])?-2:this.isColumnBeforeViewport(t[1])?-3:this.isColumnAfterViewport(t[1])?-4:this.TBODY.childNodes[this.rowFilter.sourceToVisible(t[0])].childNodes[this.columnFilter.sourceColumnToVisibleRowHeadedColumn(t[1])]},O.prototype.getCoords=function(t){return[this.rowFilter.visibleToSource(this.wtDom.index(t.parentNode)),this.columnFilter.visibleRowHeadedColumnToSourceColumn(t.cellIndex)]},O.prototype.getLastVisibleRow=function(){return this.rowFilter.visibleToSource(this.rowStrategy.cellCount-1)},O.prototype.getLastVisibleColumn=function(){return this.columnFilter.visibleToSource(this.columnStrategy.cellCount-1)},O.prototype.isRowBeforeViewport=function(t){return this.rowFilter.sourceToVisible(t)<this.rowFilter.fixedCount&&t>=this.rowFilter.fixedCount},O.prototype.isRowAfterViewport=function(t){return t>this.getLastVisibleRow()},O.prototype.isColumnBeforeViewport=function(t){return this.columnFilter.sourceToVisible(t)<this.columnFilter.fixedCount&&t>=this.columnFilter.fixedCount},O.prototype.isColumnAfterViewport=function(t){return t>this.getLastVisibleColumn()},O.prototype.isRowInViewport=function(t){return!this.isRowBeforeViewport(t)&&!this.isRowAfterViewport(t)},O.prototype.isColumnInViewport=function(t){return!this.isColumnBeforeViewport(t)&&!this.isColumnAfterViewport(t)},O.prototype.isLastRowFullyVisible=function(){return this.getLastVisibleRow()===this.instance.getSetting("totalRows")-1&&!this.rowStrategy.isLastIncomplete()},O.prototype.isLastColumnFullyVisible=function(){return this.getLastVisibleColumn()===this.instance.getSetting("totalColumns")-1&&!this.columnStrategy.isLastIncomplete()},M.prototype.getWorkspaceHeight=function(t){if(this.instance.getSetting("nativeScrollbars"))return this.instance.wtScrollbars.vertical.windowSize;var e=this.instance.getSetting("height");return(e===1/0||void 0===e||null===e||1>e)&&(e=this.instance.wtScrollbars.vertical instanceof h?this.instance.wtScrollbars.vertical.availableSize():1/0),e!==1/0&&(t>=e?e-=this.instance.getSetting("scrollbarHeight"):this.instance.wtScrollbars.horizontal.visible&&(e-=this.instance.getSetting("scrollbarHeight"))),e},M.prototype.getWorkspaceWidth=function(t){var e=this.instance.getSetting("width");return(e===1/0||void 0===e||null===e||1>e)&&(e=this.instance.wtScrollbars.horizontal instanceof h?this.instance.wtScrollbars.horizontal.availableSize():1/0),e!==1/0&&(t>=e?e-=this.instance.getSetting("scrollbarWidth"):this.instance.wtScrollbars.vertical.visible&&(e-=this.instance.getSetting("scrollbarWidth"))),e},M.prototype.getWorkspaceActualHeight=function(){return this.instance.wtDom.outerHeight(this.instance.wtTable.TABLE)},M.prototype.getWorkspaceActualWidth=function(){return this.instance.wtDom.outerWidth(this.instance.wtTable.TABLE)||this.instance.wtDom.outerWidth(this.instance.wtTable.TBODY)||this.instance.wtDom.outerWidth(this.instance.wtTable.THEAD)},M.prototype.getColumnHeaderHeight=function(){if(isNaN(this.columnHeaderHeight)){var t=this.instance.wtDom.offset(this.instance.wtTable.TBODY),e=this.instance.wtTable.tableOffset;this.columnHeaderHeight=t.top-e.top}return this.columnHeaderHeight},M.prototype.getViewportHeight=function(t){var e=this.getWorkspaceHeight(t);if(e===1/0)return e;var o=this.getColumnHeaderHeight();return o>0?e-o:e},M.prototype.getRowHeaderWidth=function(){if(this.instance.cloneSource)return this.instance.cloneSource.wtViewport.getRowHeaderWidth();if(isNaN(this.rowHeaderWidth)){var t=this.instance.getSetting("rowHeaders");if(t.length){var e=this.instance.wtTable.TABLE.querySelector("TH");this.rowHeaderWidth=0;for(var o=0,i=t.length;i>o;o++)e?(this.rowHeaderWidth+=this.instance.wtDom.outerWidth(e),e=e.nextSibling):this.rowHeaderWidth+=50}else this.rowHeaderWidth=0}return this.rowHeaderWidth},M.prototype.getViewportWidth=function(t){var e=this.getWorkspaceWidth(t);if(e===1/0)return e;var o=this.getRowHeaderWidth();return o>0?e-o:e},M.prototype.resetSettings=function(){this.rowHeaderWidth=NaN,this.columnHeaderHeight=NaN};var q={x:0,y:0,init:function(){this.setEvent("mouse"),this.setEvent("touch")},setEvent:function(t){var e=document["on"+t+"move"]||function(){};document["on"+t+"move"]=function(t){e(t),q.refresh(t)}},refresh:function(t){t||(t=o.event),"mousemove"==t.type?this.set(t):t.touches&&this.set(t.touches[0])},set:function(t){t.pageX||t.pageY?(this.x=t.pageX,this.y=t.pageY):document.body&&(t.clientX||t.clientY)&&(this.x=t.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,this.y=t.clientY+document.body.scrollTop+document.documentElement.scrollTop)}};q.init();var Q={get:function(t){var e=0,o=0;if(t.offsetParent)do o+=t.offsetLeft,e+=t.offsetTop;while(t=t.offsetParent);return[o,e]}},J=function(t,e){if("string"==typeof t&&(t=document.getElementById(t)),t){var o=t.getElementsByTagName("div")[0];o&&-1!=o.className.search(/(^|\s)handle(\s|$)/)&&(this.init(t,o,e||{}),this.setup())}};J.prototype={init:function(t,e,o){this.wrapper=t,this.handle=e,this.options=o,this.disabled=this.getOption("disabled",!1),this.horizontal=this.getOption("horizontal",!0),this.vertical=this.getOption("vertical",!1),this.slide=this.getOption("slide",!0),this.steps=this.getOption("steps",0),this.snap=this.getOption("snap",!1),this.loose=this.getOption("loose",!1),this.speed=this.getOption("speed",10)/100,this.xPrecision=this.getOption("xPrecision",0),this.yPrecision=this.getOption("yPrecision",0),this.callback=o.callback||null,this.animationCallback=o.animationCallback||null,this.bounds={left:o.left||0,right:-(o.right||0),top:o.top||0,bottom:-(o.bottom||0),x0:0,x1:0,xRange:0,y0:0,y1:0,yRange:0},this.value={prev:[-1,-1],current:[o.x||0,o.y||0],target:[o.x||0,o.y||0]},this.offset={wrapper:[0,0],mouse:[0,0],prev:[-999999,-999999],current:[0,0],target:[0,0]},this.change=[0,0],this.activity=!1,this.dragging=!1,this.tapping=!1},getOption:function(t,e){return void 0!==this.options[t]?this.options[t]:e},setup:function(){this.setWrapperOffset(),this.setBoundsPadding(),this.setBounds(),this.setSteps(),this.addListeners()},setWrapperOffset:function(){this.offset.wrapper=Q.get(this.wrapper)},setBoundsPadding:function(){this.bounds.left||this.bounds.right||(this.bounds.left=Q.get(this.handle)[0]-this.offset.wrapper[0],this.bounds.right=-this.bounds.left),this.bounds.top||this.bounds.bottom||(this.bounds.top=Q.get(this.handle)[1]-this.offset.wrapper[1],this.bounds.bottom=-this.bounds.top)},setBounds:function(){this.bounds.x0=this.bounds.left,this.bounds.x1=this.wrapper.offsetWidth+this.bounds.right,this.bounds.xRange=this.bounds.x1-this.bounds.x0-this.handle.offsetWidth,this.bounds.y0=this.bounds.top,this.bounds.y1=this.wrapper.offsetHeight+this.bounds.bottom,this.bounds.yRange=this.bounds.y1-this.bounds.y0-this.handle.offsetHeight,this.bounds.xStep=1/(this.xPrecision||Math.max(this.wrapper.offsetWidth,this.handle.offsetWidth)),this.bounds.yStep=1/(this.yPrecision||Math.max(this.wrapper.offsetHeight,this.handle.offsetHeight))},setSteps:function(){if(this.steps>1){this.stepRatios=[];for(var t=0;t<=this.steps-1;t++)this.stepRatios[t]=t/(this.steps-1)}},addListeners:function(){var t=this;this.wrapper.onselectstart=function(){return!1},this.handle.onmousedown=this.handle.ontouchstart=function(e){t.handleDownHandler(e)},this.wrapper.onmousedown=this.wrapper.ontouchstart=function(e){t.wrapperDownHandler(e)};var e=document.onmouseup||function(){};document.onmouseup=function(o){e(o),t.documentUpHandler(o)};var i=document.ontouchend||function(){};document.ontouchend=function(e){i(e),t.documentUpHandler(e)};var n=o.onresize||function(){};o.onresize=function(e){n(e),t.documentResizeHandler(e)},this.wrapper.onmousemove=function(e){t.activity=!0},this.wrapper.onclick=function(e){return!t.activity},this.interval=setInterval(function(){t.animate()},25),t.animate(!1,!0)},handleDownHandler:function(t){this.activity=!1,q.refresh(t),this.preventDefaults(t,!0),this.startDrag()},wrapperDownHandler:function(t){q.refresh(t),this.preventDefaults(t,!0),this.startTap()},documentUpHandler:function(t){this.stopDrag(),this.stopTap()},documentResizeHandler:function(t){this.setWrapperOffset(),this.setBounds(),this.update()},enable:function(){this.disabled=!1,this.handle.className=this.handle.className.replace(/\s?disabled/g,"")},disable:function(){this.disabled=!0,this.handle.className+=" disabled"},setStep:function(t,e,o){this.setValue(this.steps&&t>1?(t-1)/(this.steps-1):0,this.steps&&e>1?(e-1)/(this.steps-1):0,o)},setValue:function(t,e,o){this.setTargetValue([t,e||0]),o&&this.groupCopy(this.value.current,this.value.target)},startTap:function(t){this.disabled||(this.tapping=!0,this.setWrapperOffset(),this.setBounds(),void 0===t&&(t=[q.x-this.offset.wrapper[0]-this.handle.offsetWidth/2,q.y-this.offset.wrapper[1]-this.handle.offsetHeight/2]),this.setTargetOffset(t))},stopTap:function(){!this.disabled&&this.tapping&&(this.tapping=!1,this.setTargetValue(this.value.current),this.result())},startDrag:function(){this.disabled||(this.setWrapperOffset(),this.setBounds(),this.offset.mouse=[q.x-Q.get(this.handle)[0],q.y-Q.get(this.handle)[1]],this.dragging=!0)},stopDrag:function(){if(!this.disabled&&this.dragging){this.dragging=!1;var t=this.groupClone(this.value.current);if(this.slide){var e=this.change;t[0]+=4*e[0],t[1]+=4*e[1]}this.setTargetValue(t),this.result()}},feedback:function(){var t=this.value.current;this.snap&&this.steps>1&&(t=this.getClosestSteps(t)),this.groupCompare(t,this.value.prev)||("function"==typeof this.animationCallback&&this.animationCallback(t[0],t[1]),this.groupCopy(this.value.prev,t))},result:function(){"function"==typeof this.callback&&this.callback(this.value.target[0],this.value.target[1])},animate:function(t,e){if(!t||this.dragging){if(this.dragging){var o=this.groupClone(this.value.target),i=[q.x-this.offset.wrapper[0]-this.offset.mouse[0],q.y-this.offset.wrapper[1]-this.offset.mouse[1]];this.setTargetOffset(i,this.loose),this.change=[this.value.target[0]-o[0],this.value.target[1]-o[1]];
}(this.dragging||e)&&this.groupCopy(this.value.current,this.value.target),(this.dragging||this.glide()||e)&&(this.update(),this.feedback())}},glide:function(){var t=[this.value.target[0]-this.value.current[0],this.value.target[1]-this.value.current[1]];return t[0]||t[1]?(Math.abs(t[0])>this.bounds.xStep||Math.abs(t[1])>this.bounds.yStep?(this.value.current[0]+=t[0]*this.speed,this.value.current[1]+=t[1]*this.speed):this.groupCopy(this.value.current,this.value.target),!0):!1},update:function(){this.snap?this.offset.current=this.getOffsetsByRatios(this.getClosestSteps(this.value.current)):this.offset.current=this.getOffsetsByRatios(this.value.current),this.show()},show:function(){this.groupCompare(this.offset.current,this.offset.prev)||(this.horizontal&&(this.handle.style.left=String(this.offset.current[0])+"px"),this.vertical&&(this.handle.style.top=String(this.offset.current[1])+"px"),this.groupCopy(this.offset.prev,this.offset.current))},setTargetValue:function(t,e){var o=e?this.getLooseValue(t):this.getProperValue(t);this.groupCopy(this.value.target,o),this.offset.target=this.getOffsetsByRatios(o)},setTargetOffset:function(t,e){var o=this.getRatiosByOffsets(t),i=e?this.getLooseValue(o):this.getProperValue(o);this.groupCopy(this.value.target,i),this.offset.target=this.getOffsetsByRatios(i)},getLooseValue:function(t){var e=this.getProperValue(t);return[e[0]+(t[0]-e[0])/4,e[1]+(t[1]-e[1])/4]},getProperValue:function(t){var e=this.groupClone(t);return e[0]=Math.max(e[0],0),e[1]=Math.max(e[1],0),e[0]=Math.min(e[0],1),e[1]=Math.min(e[1],1),(!this.dragging&&!this.tapping||this.snap)&&this.steps>1&&(e=this.getClosestSteps(e)),e},getRatiosByOffsets:function(t){return[this.getRatioByOffset(t[0],this.bounds.xRange,this.bounds.x0),this.getRatioByOffset(t[1],this.bounds.yRange,this.bounds.y0)]},getRatioByOffset:function(t,e,o){return e?(t-o)/e:0},getOffsetsByRatios:function(t){return[this.getOffsetByRatio(t[0],this.bounds.xRange,this.bounds.x0),this.getOffsetByRatio(t[1],this.bounds.yRange,this.bounds.y0)]},getOffsetByRatio:function(t,e,o){return Math.round(t*e)+o},getClosestSteps:function(t){return[this.getClosestStep(t[0]),this.getClosestStep(t[1])]},getClosestStep:function(t){for(var e=0,o=1,i=0;i<=this.steps-1;i++)Math.abs(this.stepRatios[i]-t)<o&&(o=Math.abs(this.stepRatios[i]-t),e=i);return this.stepRatios[e]},groupCompare:function(t,e){return t[0]==e[0]&&t[1]==e[1]},groupCopy:function(t,e){t[0]=e[0],t[1]=e[1]},groupClone:function(t){return[t[0],t[1]]},preventDefaults:function(t,e){t||(t=o.event),t.preventDefault&&t.preventDefault(),t.returnValue=!1,e&&document.selection&&document.selection.empty()},cancelEvent:function(t){t||(t=o.event),t.stopPropagation&&t.stopPropagation(),t.cancelBubble=!0}}}(t,window,o),o});