forked from Spreadsheets/WickedGrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wickedgrid.min.js
1 lines (1 loc) · 186 KB
/
wickedgrid.min.js
1
var jQuery=window.jQuery||{};var Sheet=(function(d,k,f,a,o,r,s,g,b,p){var j={Loader:{},Plugin:{},defaultTheme:0,themeRollerTheme:0,bootstrapTheme:1,customTheme:2,excelSelectModel:0,googleDriveSelectModel:1,openOfficeSelectModel:2,defaultColumnWidth:120,defaultRowHeight:20,domRows:40,domColumns:35,calcStack:0,formulaParserUrl:"../parser/formula/formula.js",threadScopeUrl:"../Sheet/threadScope.js",defaultFormulaParser:null,spareFormulaParsers:[],formulaParser:function(u){var t;if(u>-1){t=this.spareFormulaParsers[u];if(t===undefined){t=this.spareFormulaParsers[u]=Formula()}}else{t=j.defaultFormulaParser}t.yy.types=[];return t},parseFormulaSlow:function(v,u){if(j.defaultFormulaParser===null){j.defaultFormulaParser=Formula()}var t=j.formulaParser(j.calcStack);u(t.parse(v))},parseFormula:function(v,u){var t=j.thread();if(t.busy){t.stash.push(function(){t.busy=true;t.parseFormula(v,function(w){t.busy=false;u(w);if(t.stash.length>0){t.stash.shift()()}})})}else{t.busy=true;t.parseFormula(v,function(w){t.busy=false;u(w);if(t.stash.length>0){t.stash.shift()()}})}}};j.fn=(function(v){v=v||function(){};function u(y){var B=this.jS,F=B.s.loader,E=k.createElement("div"),A=this.td,D,C=k.body;C.appendChild(E);function z(H,I){if(!H){if(I){H=0}else{H=""}}else{if(I){H=c.toNumbers(H)}else{H=c.flatten(H)}}return H}y=d.extend({x:{legend:"",data:[0]},y:{legend:"",data:[0]},title:"",data:[0],legend:""},y);E.className=B.cl.chart;E.onmousedown=function(){d(A).mousedown()};E.onmousemove=function(){d(A).mousemove();return false};y.data=z(y.data,true);y.x.data=z(y.x.data,true);y.y.data=z(y.y.data,true);y.legend=z(y.legend);y.x.legend=z(y.x.legend);y.y.legend=z(y.y.legend);y.legend=(y.legend?y.legend:y.data);var x=F.getWidth(this.sheetIndex,this.columnIndex),G=F.getHeight(this.sheetIndex,this.rowIndex),w=Raphael(E);if(y.title){w.text(x/2,10,y.title).attr({"font-size":20})}switch(y.type){case"bar":D=w.barchart(x/8,G/8,x*0.8,G*0.8,y.data,y.legend).hover(function(){this.flag=w.popup(this.bar.x,this.bar.y,this.bar.value||"0").insertBefore(this)},function(){this.flag.animate({opacity:0},300,function(){this.remove()})});break;case"hbar":D=w.hbarchart(x/8,G/8,x*0.8,G*0.8,y.data,y.legend).hover(function(){this.flag=w.popup(this.bar.x,this.bar.y,this.bar.value||"0").insertBefore(this)},function(){this.flag.animate({opacity:0},300,function(){this.remove()})});break;case"line":D=w.linechart(x/8,G/8,x*0.8,G*0.8,y.x.data,y.y.data,{nostroke:false,axis:"0 0 1 1",symbol:"circle",smooth:true}).hoverColumn(function(){this.tags=w.set();if(this.symbols.length){for(var H=0,I=this.y.length;H<I;H++){this.tags.push(w.tag(this.x,this.y[H],this.values[H],160,10).insertBefore(this).attr([{fill:"#fff"},{fill:this.symbols[H].attr("fill")}]))}}},function(){this.tags&&this.tags.remove()});break;case"pie":D=w.piechart(x/2,G/2,(x<G?x:G)/2,y.data,{legend:y.legend}).hover(function(){this.sector.stop();this.sector.scale(1.1,1.1,this.cx,this.cy);if(this.label){this.label[0].stop();this.label[0].attr({r:7.5});this.label[1].attr({"font-weight":800})}},function(){this.sector.animate({transform:"s1 1 "+this.cx+" "+this.cy},500,"bounce");if(this.label){this.label[0].animate({r:5},500,"bounce");this.label[1].attr({"font-weight":400})}});break;case"dot":D=w.dotchart(x/8,G/8,x*0.8,G*0.8,y.x.data,y.y.data,y.data,{symbol:"o",max:10,heat:true,axis:"0 0 1 1",axisxstep:y.x.data.length-1,axisystep:y.y.data.length-1,axisxlabels:(y.x.legend?y.x.legend:y.x.data),axisylabels:(y.y.legend?y.y.legend:y.y.data),axisxtype:" ",axisytype:" "}).hover(function(){this.marker=this.marker||w.tag(this.x,this.y,this.value,0,this.r+2).insertBefore(this);this.marker.show()},function(){this.marker&&this.marker.hide()});break}D.mousedown(function(){d(A).mousedown().mouseup()});C.removeChild(E);return E}var t={ISNUMBER:function(x){var w;if(!isNaN(x.valueOf())){w=new s(true);w.html="TRUE";return w}w=new s(false);w.html="FALSE";return w},N:function(w){if(w==null){return 0}if(w instanceof a){return w.getTime()}if(typeof(w)=="object"){w=w.toString()}if(typeof(w)=="string"){w=parseFloat(w.replace(/[\$,\s]/g,""))}if(isNaN(w)){return 0}if(typeof(w)=="number"){return w}if(w==true){return 1}return 0},VERSION:function(){return this.jS.version},ABS:function(w){return g.abs(t.N(w))},CEILING:function(x,w){w=w||1;return(parseInt(x/w)*w)+w},EVEN:function(w){w=g.round(w);var x=(w%2==0);if(!x){if(w>0){w++}else{w--}}return w},EXP:function(w){return g.exp(w)},FLOOR:function(y,x){x=x||1;if((y<0&&x>0)||(y>0&&x<0)){var w=new r(0);w.html="#NUM";return w}if(y>=0){return g.floor(y/x)*x}else{return g.ceil(y/x)*x}},INT:function(w){return g.floor(t.N(w))},LN:function(w){return g.log(w)},LOG:function(w,x){x=x||10;return g.log(w)/g.log(x)},LOG10:function(w){return t.LOG(w)},MOD:function(w,A){var z=w%A;if(A<0){z*=-1}return z},ODD:function(w){var y=false;if(w>0){w=g.floor(g.round(w));y=true}else{w=g.ceil(w)}var x=g.abs(w);if((x%2)==0){x++}if(y){return x}else{return -x}},PI:function(){return g.PI},POWER:function(w,z){return g.pow(w,z)},SQRT:function(w){return g.sqrt(w)},RAND:function(){return g.random()},RND:function(){return g.random()},ROUND:function(y,x){var w=g.pow(10,x||0);return g.round(y*w)/w},ROUNDDOWN:function(x,w){var y=(x<0);x=g.abs(x);w=w||0;x=g.floor(x*g.pow(10,w))/g.pow(10,w);return(y?-x:x)},ROUNDUP:function(x,w){var y=(x<0);x=g.abs(x);w=w||0;x=g.ceil(x*g.pow(10,w))/g.pow(10,w);return(y?-x:x)},SUM:function(){var A=0,y=c.flatten(arguments),x,z=0,w=y.length,B=isNaN;for(;z<w;z++){x=y[z];if(x===null||x===undefined){continue}x=x.valueOf();if(!B(x)){switch(typeof x){case"string":A+=(x*1);break;default:A+=x}}}return A},TRUNC:function(w,x){x=x||0;w=w+"";if(x==0){return w.split(".").shift()}if(w.match(".")){if(x==1){w=w.substr(0,w.length-1)}else{if(x==-1){w=w.split(".").shift();w=w.substr(0,w.length-1)+"0"}}}return w},AVERAGE:function(){return t.SUM.apply(this,arguments)/t.COUNT.apply(this,arguments)},AVG:function(){return t.AVERAGE.apply(this,arguments)},COUNT:function(){var y=0,w=c.toNumbers(arguments),x=w.length-1;if(x<0){return y}do{if(w[x]!==null){y++}}while(x--);return y},COUNTA:function(){var y=0,w=c.flatten(arguments),x=w.length-1;if(x<0){return y}do{if(w[x]){y++}}while(x--);return y},MAX:function(){var x=c.toNumbers(arguments),w=x[0],y=x.length-1;if(y<0){return 0}do{w=(x[y]>w?x[y]:w)}while(y--);return w},MIN:function(){var w=c.toNumbers(arguments),y=w[0],x=w.length-1;if(x<0){return 0}do{y=(w[x]<y?w[x]:y)}while(x--);return y},ASC:function(w){return w.charCodeAt(0)},CHAR:function(w){return o.fromCharCode(w)},CLEAN:function(w){var x=new b("[cG\x1BcLcJcMcIcK\x07\x1B\f\n\r\t\v]","g");return w.replace(x,"")},CODE:function(w){return t.ASC(w)},CONCATENATE:function(){var y=c.flatten(arguments),x="",w=this;jQuery.each(y,function(z){x+=y[z]});return x},DOLLAR:function(y,x,A){x=x||2;A=A||"$";var w=new r(y),z=t.FIXED(y,x,false);if(y>=0){w.html=A+z}else{w.html="("+A+z.slice(1)+")"}return w},FIXED:function(z,y,x){y=(y===undefined?2:y);var A=g.pow(10,y),w,z=g.round(z*A)/A;w=new o(z.toFixed(y));w.html=Globalize.format(z,"n"+y);if(x){w.html=w.html.replace(Globalize.culture().numberFormat[","],"")}return w},LEFT:function(w,x){w=w.valueOf().toString();x=x||1;return w.substring(0,x)},LEN:function(w){if(!w){return 0}return w.length},LOWER:function(w){return w.toLowerCase()},MID:function(y,z,x){if(!y||!z||!x){var w=new r(0);w.html="ERROR";return w}return y.substring(z-1,x+z-1)},REPLACE:function(x,A,y,z){if(!x||!A||!y||!z){var w=new o("");w.html="ERROR";return w}var w=x.split("");w.splice(A-1,y);w.splice(A-1,0,z);return w.join("")},REPT:function(x,z){var w="";for(var y=0;y<z;y++){w+=x}return w},RIGHT:function(w,x){x=x||1;return w.substring(w.length-x,w.length)},SEARCH:function(z,x,A){A=A||0;if(A){x=x.split("");x.splice(0,A-1);x=x.join("")}var y=x.search(z);if(y<0){var w=new o("");w.html="#VALUE!";return w}return A+(A?0:1)+y},SUBSTITUTE:function(z,w,y,A){A=A||0;w=new b(w,"g");var x=1;z=z.replace(w,function(C,E,F,D){var B=C;if(A){if(x>=A){B=y}}else{B=y}x++;return B});return z},TEXT:function(x,w){return x},UPPER:function(w){return w.toUpperCase()},VALUE:function(x){if(jQuery.isNumeric(x)){return x*=1}else{var w=new o("");w.html="#VALUE!";return w}},NOW:function(){var w=new a();w.html=e.toString(w);return w},TODAY:function(){var x=new a(),w=new r(e.toCentury(x)-1);w.html=e.toString(x,"d");return w},WEEKENDING:function(x){var w=new a();w=new a(w.getFullYear(),w.getMonth(),w.getDate()+5-w.getDay()-((x||0)*7));w.html=e.toString(w,"d");return w},WEEKDAY:function(x,y){x=e.get(x);var w=x.getDay();y=(y?y:1);switch(y){case 3:switch(w){case 0:return 7;case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 5:return 5;case 6:return 6}break;case 2:switch(w){case 0:return 6;case 1:return 0;case 2:return 1;case 3:return 2;case 4:return 3;case 5:return 4;case 6:return 5}break;case 1:w++;break}return w},WEEKNUM:function(w){w=e.get(w);return e.week(w)+1},YEAR:function(w){w=e.get(w);return w.getFullYear()},DAYSFROM:function(x,y,w){return g.floor((new a()-new a(x,(y-1),w))/e.dayDiv)},DAYS:function(A,y){var x=e.get(A),w=e.get(y),z=1000*60*60*24;return g.round(g.abs(x.getTime()-w.getTime())/z)},DAY:function(w){w=e.get(w);return w.getDate()},DAYS360:function(B,y,D){B=e.get(B);y=e.get(y);var w=B.getDate(),A=y.getDate(),z=e.isLastDayOfMonth(B),C=e.isLastDayOfMonth(y),x=e.diffMonths(B,y);if(D){w=g.min(w,30);A=g.min(A,30)}else{if(z){w=30}if(C){if(w<30){x++;A=1}else{A=30}}}return(x*30)+(A-w)},DATE:function(z,A,x){var y=new a(z,A-1,x),w=new r(e.toCentury(y));w.html=e.toString(y,"d");return w},DATEVALUE:function(x){x=e.get(x);var w=new r(e.toCentury(x));w.html=e.toString(x,"d");return w},EDATE:function(y,x){y=e.get(y);y.setMonth(y.getMonth()+x);var w=new r(e.toCentury(y));w.html=e.toString(y,"d");return w},EOMONTH:function(y,x){y=e.get(y);y.setMonth(y.getMonth()+x+1);y=new a(y.getFullYear(),y.getMonth(),0);var w=new r(e.toCentury(y));w.html=e.toString(y,"d");return w},HOUR:function(w){w=h.fromMath(w);return w.hour},MINUTE:function(w){return h.fromMath(w).minute},MONTH:function(w){w=e.get(w);return w.getMonth()+1},SECOND:function(w){return h.fromMath(w).second},TIME:function(w,B,x){x=(x?x:0);B=(B?B:0);w=(w?w:0);if(x&&x>60){var y=(((x/60)+"").split(".")[0])*1;x=x-(y*60);B+=y}if(B&&B>60){var A=(((B/60)+"").split(".")[0])*1;B=B-(A*60);w+=A}var z=(w*60*60*1000)+(B*60*1000)+(x*1000);return z/e.dayDiv},TIMEVALUE:function(w){if(!isNaN(w)){return w}if(/([0]?[1-9]|1[0-2])[:][0-5][0-9]([:][0-5][0-9])?[ ]?(AM|am|aM|Am|PM|pm|pM|Pm)/.test(w)){return h.fromString(w,true)}else{if(/([0]?[0-9]|1[0-9]|2[0-3])[:][0-5][0-9]([:][0-5][0-9])?/.test(w)){return h.fromString(w)}}return 0},WORKDAY:function(x,A,z){var B={1:true,2:true,3:true,4:true,5:true},x=e.get(x),A=(A&&!isNaN(A)?A:0),C=0,y=0,w=x,E;if(z){if(!jQuery.isArray(z)){z=[z]}z=c.flatten(z);var D={};jQuery.each(z,function(F){if(z[F]){D[e.toString(e.get(z[F]),"d")]=true}});z=D}else{z={}}while(y<A){w=new a(w.setDate(w.getDate()+1));if(B[w.getDay()]){if(!z[e.toString(w,"d")]){y++}}C++}E=new r(e.toCentury(w));E.html=e.toString(w,"d");return E},YEARFRAC:function(x,B,A){x=e.get(x);B=e.get(B);if(!x||!B){var w=new o("");w.html="#VALUE!";return w}A=(A?A:0);this.html=[];var z=e.diff(x,B,A),y=e.calcAnnualBasis(x,B,A);return z/y},AND:function(){var x,y=0,w=arguments.length;for(;y<w;y++){x=arguments[y];if(x===undefined||(x.valueOf!==undefined&&x.valueOf()!=true)||x!=true){return t.FALSE()}}return t.TRUE()},FALSE:function(){var w=new s(false);w.html="FALSE";return w},IF:function(A,y,x){var w=A.valueOf(),z;switch(typeof w){case"boolean":if(w===true){return y}else{return x}break;case"number":if(w!==0){return y}else{return x}break;case"string":z=w.toUpperCase();if(z==="TRUE"){return y}else{if(z==="FALSE"){return x}else{if(z.replace(/ /g,"").length>0){return y}}}break}if(w){return y}return y},NOT:function(x){var w;if(!x.valueOf()){w=new s(true);w.html="TRUE"}else{w=new s(false);w.html="FALSE"}return w},OR:function(){var y=arguments,w,z=y.length-1,x;if(z>-1){do{x=y[z].valueOf();if(x){w=new s(true);w.html="TRUE";return w}}while(z--)}w=new s(false);w.html="FALSE";return w},TRUE:function(){var w=new s(true);w.html="TRUE";return w},GREATER:function(y,x){var w;if(y>x){w=new s(true);w.html="TRUE"}else{w=new s(false);w.html="FALSE"}return w},LESS:function(y,x){var w;if(y<x){w=new s(true);w.html="TRUE"}else{w=new s(false);w.html="FALSE"}return w},EQUAL:function(z,y){var w,A,x;if(z===undefined||z===null){z=""}if(y===undefined||y===null){y=""}A=z+"";x=y+"";if(A==x){w=new s(true);w.html="TRUE"}else{w=new s(false);w.html="FALSE"}return w},GREATER_EQUAL:function(y,x){var w;if(y>=x){w=new s(true);w.html="TRUE"}else{w=new s(false);w.html="FALSE"}return w},LESS_EQUAL:function(y,x){var w;if(y<=x){w=new s(true);w.html="TRUE"}else{w=new s(false);w.html="FALSE"}return w},IMG:function(x){var w=new o("");w.html=d(k.createElement("img")).attr("src",x);return w},TRIM:function(w){if(typeof(w)=="string"){w=d.trim(w)}return w},HYPERLINK:function(x,y){y=y||"LINK";var w=new o(y.valueOf()),z=k.createElement("a");z.setAttribute("href",x);z.setAttribute("target","_new");z.innerText=z.textContent=y;w.html=z;return w},DROPDOWN:function(){var G=this,B=this.jS,y=this.td,E,F,A,D,x,H,z=0,C;if(y!==null){d(y).children().detach();A=G.value.html}if(A===undefined||G.needsUpdated||A.length<1){F=c.flatten(arguments);F=c.unique(F);if(this.id!==null){x=this.id+"-dropdown"}else{if(y!==null){x="dropdown"+this.sheetIndex+"_"+this.rowIndex+"_"+this.columnIndex+"_"+B.I}}D=k.createElement("select");D.setAttribute("name",x);D.setAttribute("id",x);D.className="jSDropdown";D.cell=this;D.onmouseup=function(){if(this.cell.td!==null){B.cellEdit(this.cell.td)}};D.onchange=function(){E=new o(this.value);E.html=D;E.cell=G;G.value=E;G.setNeedsUpdated(false);B.resolveCell(G);B.trigger("sheetCellEdited",[G])};C=(F.length<=50?F.length:50);for(;z<C;z++){if(F[z]){var w=k.createElement("option");w.setAttribute("value",F[z]);w.text=w.innerText=F[z];D.appendChild(w)}}if(!B.s.editable){D.setAttribute("disabled",true)}else{B.s.parent.bind("sheetKill",function(){y.innerText=y.textContent=G.value.valueOf()})}D.value=G.value||F[0]}if(typeof G.value!=="object"){H=new o(G.value)}else{H=G.value}H.html=D;return H},RADIO:function(){var G=this,B=this.jS,y=this.td,F,E,A,x,w,H;if(y!==null){A=G.value.html;d(y).children().detach()}if(A===undefined||A.length<1||G.needsUpdated){F=c.flatten(arguments);F=c.unique(F);if(this.id!==null){w=this.id+"-radio"}else{if(y!==null){w="radio"+this.sheetIndex+"_"+this.rowIndex+"_"+this.columnIndex+"_"+B.I}}A=k.createElement("span");A.className="jSRadio";A.onmousedown=function(){if(this.cell.td!==null){B.cellEdit(G.td)}};A.cell=G;for(var z=0;z<(F.length<=25?F.length:25);z++){if(F[z]){var D=k.createElement("input"),C=k.createElement("span");D.setAttribute("type","radio");D.setAttribute("name",w);D.className=w;D.value=F[z];if(!B.s.editable){D.setAttribute("disabled","disabled")}D.onchange=function(){E=new o(this.value);E.html=A;E.cell=G;G.value=E;G.setNeedsUpdated(false);B.resolveCell(G);B.trigger("sheetCellEdited",[G])};if(F[z].valueOf()===G.value.valueOf()){D.checked=true}C.textContent=C.innerText=F[z];A.appendChild(D);C.input=D;C.onmousedown=function(){d(this.input).click()};A.appendChild(C);A.appendChild(k.createElement("br"))}}B.s.parent.bind("sheetKill",function(){y.textContent=y.innerText=G.value.valueOf()})}if(typeof G.value!=="object"){H=new o(G.value)}else{H=G.value}H.html=A;return H},CHECKBOX:function(D){if(d.isArray(D)){D=D[0]}var E=this,z=this.jS,x=this.td,y,B,A,w,C,F;if(x!==null){y=E.value.html;d(x).children().detach()}if(y===undefined||y.length<1||E.needsUpdated){if(this.id!==null){w=this.id+"-checkbox"}else{if(x!==null){w="checkbox"+this.sheetIndex+"_"+this.rowIndex+"_"+this.columnIndex+"_"+z.I}}A=k.createElement("input");A.setAttribute("type","checkbox");A.setAttribute("name",w);A.setAttribute("id",w);A.className=w;A.value=D;A.onchange=function(){if(this.checked){C=new o(D)}else{C=new o("")}C.html=y;C.cell=E;E.value=C;E.setNeedsUpdated(false);z.resolveCell(E);z.trigger("sheetCellEdited",[E])};if(!z.s.editable){A.setAttribute("disabled","true")}else{z.s.parent.bind("sheetKill",function(){E.value=(E.value=="true"||A.checked?D:"");if(E.td!==null){E.td.innerText=E.td.textContent=E.value.valueOf()}})}y=k.createElement("span");y.className="jSCheckbox";y.appendChild(A);B=k.createElement("span");B.textContent=B.innerText=D;y.appendChild(B);y.appendChild(k.createElement("br"));y.onmousedown=function(){if(this.cell.td!==null){z.cellEdit(this.cell.td)}};y.cell=E;switch(E.value.valueOf()){case D.valueOf():case"true":A.checked=true}}if(E.value==="true"||A.checked){F=new o(D)}else{F=new o("")}F.html=y;return F},BARCHART:function(x,y,z){var w=new o("");w.html=u.call(this,{type:"bar",data:x,legend:y,title:z});return w},HBARCHART:function(x,y,z){var w=new o("");w.html=u.call(this,{type:"hbar",data:x,legend:y,title:z});return w},LINECHART:function(y,x){var w=new o("");w.html=u.call(this,{type:"line",x:{data:y},y:{data:x},title:""});return w},PIECHART:function(x,y,z){var w=new o("");w.html=u.call(this,{type:"pie",data:x,legend:y,title:z});return w},DOTCHART:function(C,A,x,z,y,B){var w=new o("");w.html=u.call(this,{type:"dot",data:(x?x:C),x:{data:C,legend:z},y:{data:(A?A:C),legend:(y?y:z)},title:B});return w},CELLREF:function(w){return(this.jS.spreadsheets[w]?this.jS.spreadsheets[w]:"Cell Reference Not Found")},HLOOKUP:function(C,z,y,E){if(C===undefined){return null}var A=this.jS,D,w,F="",x=0,B=z.length;y=y||1;E=E!==undefined?E:true;if(C!==undefined||((isNaN(C)&&C!="#REF!")||C.length===0)){for(;x<B;x++){if(z[x].toString()==C){D=z[x];break}}}else{c.getClosestNum(C,z,function(H,G){if(E){D=H}else{if(H==C){D=H}}})}if(D!==undefined){w=D.cell;w=A.getCell(w.sheetIndex,y,w.columnIndex);if(w!==null){F=w.updateValue()}else{F=""}}else{F=new o();F.html="#N/A"}return F},VLOOKUP:function(C,z,y,E){if(C===undefined){return null}var A=this.jS,D,w,F,x=0,B=z.length;E=E!==undefined?E:true;if((isNaN(C)&&C!="#REF!")||C.length===0){for(;x<B;x++){if(z[x].toString()==C){D=z[x];break}}}else{c.getClosestNum(C,z,function(H,G){if(E){D=H}else{if(H==C){D=H}}})}if(D!==undefined){w=D.cell;w=A.getCell(w.sheetIndex,w.rowIndex,y);if(w!==null){F=w.value}else{F=""}}else{F=new o();F.html="#N/A"}return F},TRANSPOSE:function(I){var N=0,D=this.jS,C=this.sheetIndex,G=I[0],y=G.cell,z=I[I.length-1],K=z.cell,w=y.rowIndex,B=y.columnIndex,F,O,x,A=[],H,E=[],J,M=I.length,L,P=false;for(;N<M;N++){J=I[N];x=J.cell;F=this.rowIndex+(x.columnIndex-B);O=this.columnIndex+(x.rowIndex-w);H=D.getCell(this.sheetIndex,F,O);if(H!==null&&H!==this){if(H.value!=""){P=true}E.push(H);A.push(x)}}if(P){L=new o("");L.html="#REF!";return L}N=0;M=E.length;for(;N<M;N++){H=E[N];if(H!==this){x=A[N];H.setNeedsUpdated();H.defer=x;H.updateValue();H.addDependency(this)}}return G.valueOf()},THISROWCELL:function(w){var x=this.jS;if(isNaN(w)){w=x.cellHandler.columnLabelIndex(w)}return x.getCell(this.sheetIndex,this.rowIndex,w).updateValue()},THISCOLCELL:function(x){var w=this.jS;return w.getCell(this.sheetIndex,x,this.columnIndex).updateValue()}};return t})(f.Raphael);d.fn.extend({sheet:function(u){var v=isNaN,t=d.sheet.events;d(this).each(function(){var z=d(this),B=d.extend(true,{},d.sheet.defaults,u||{}),A=this.jS;B.useStack=(f.thaw===undefined?false:B.useStack);B.useMultiThreads=(f.operative===undefined?false:B.useMultiThreads);if(A){var x=z.children().detach();A.kill();z.html(x);for(var y in t){if(t.hasOwnProperty(y)){z.unbind(t[y])}}}B.parent=z;if((this.className||"").match(/\bnot-editable\b/i)!=null){B.editable=false}for(var w in t){if(t.hasOwnProperty(w)){z.bind(t[w],B[t[w]])}}z.children().each(function(D){var E=this.getAttribute("data-frozenatrow")*1,C=this.getAttribute("data-frozenatcol")*1;if(!B.frozenAt[D]){B.frozenAt[D]={row:0,col:0}}if(E){B.frozenAt[A.i].row=E}if(C){B.frozenAt[A.i].col=C}});if(!d.sheet.instance.length){d.sheet.instance=[]}this.jS=A=d.sheet.createInstance(B,d.sheet.instance.length);d.sheet.instance.push(A)});return this},disableSelectionSpecial:function(){this.each(function(){this.onselectstart=function(){return false};this.unselectable="on";this.style["-moz-user-select"]="none"});return this},getSheet:function(){var t=this[0],u=(t.jS||{});return u},getCellValue:function(u,z,v,y){var w=this[0],x=(w.jS||{}),t;if(x.getCell){t=x.getCell(u,z,v);if(t!==null){t.updateValue(y)}}return this},setCellValue:function(x,w,y,B,A){var v=this[0],t=(v.jS||{}),z;B=(B||0);if(t.getCell&&(z=t.getCell(B,w,y))){try{if((x+"").charAt(0)=="="){z.valueOverride=z.value="";z.formula=x.substring(1)}else{z.value=x;z.valueOverride=z.formula=""}z.updateValue(A)}catch(u){}}return this},setCellFormula:function(v,x,y,B,A){var w=this[0],t=(w.jS||{}),z;B=(B||0);if(t.getCell){try{z=t.getCell(B,x,y);if(z!==null){z.formula=v;z.valueOverride=z.value="";z.updateValue(A)}}catch(u){}}return this},isSheetFullScreen:function(){var t=this[0],u=(t.jS||{});if(u.obj){return u.obj.fullScreen().is(":visible")}return false},serializeCellInputs:function(u){var v=this[0],w=(v.jS||{}),t=w.obj.tables().find(":input");if(u){return t.serializeArray()}else{return t.serialize()}},viewSource:function(t){var u="";d(this).each(function(){if(t){u+=d(this).toPrettySource()}else{u+=d(this).toCompactSource()}});d.printSource(u);return u},toCompactSource:function(){var x=this[0];var u="";if(x.nodeType==1){u+="<"+x.tagName.toLowerCase();var z=x.attributes.length;for(var w=0;w<z;w++){var v=x.attributes[w].name,y=x.getAttribute(v);if(y){if(v=="contentEditable"&&y=="inherit"){continue}if(typeof(y)=="string"){u+=" "+v+'="'+y.replace(/"/g,"'")+'"'}else{if(v=="style"&&y.cssText){u+=' style="'+y.cssText+'"'}}}}if(x.tagName=="COL"){u+="/>"}else{u+=">";var t="";d(x.childNodes).each(function(){t+=d(this).toCompactSource()});u+=t;u+="</"+x.tagName.toLowerCase()+">"}}else{if(x.nodeType==3){u+=x.data.replace(/^\s*(.*)\s*$/g,"$1")}}return u},toPrettySource:function(y){var x=this[0],A,w;y=y||"";var u="";if(x.nodeType==1){u+="\n"+y+"<"+x.tagName.toLowerCase();A=x.attributes.length;for(w=0;w<A;w++){var v=x.attributes[w].name,z=x.getAttribute(v);if(z){if(v=="contentEditable"&&z=="inherit"){continue}if(typeof(z)=="string"){u+=" "+v+'="'+d.trim(z.replace(/"/g,"'"))+'"'}else{if(v=="style"&&z.cssText){u+=' style="'+d.trim(z.cssText)+'"'}}}}if(x.childNodes.length<=0){if(x.tagName=="COL"){u+="/>"}else{u+="></"+x.tagName.toLowerCase()+">"}}else{u+=">";var t="";A=x.childNodes.length;for(w=0;w<A;w++){t+=d(x.childNodes[w]).toPrettySource(y+" ")}u+=t;if(t.indexOf("\n")>=0){u+="\n"+y}u+="</"+x.tagName.toLowerCase()+">"}}else{if(x.nodeType==3){u+=x.data.replace(/^\s*(.*)\s*$/g,"$1")}}return u}});d.sheet={defaults:{editable:true,editableNames:true,barMenus:true,freezableCells:true,allowToggleState:true,menu:null,newColumnWidth:120,title:null,calcOff:false,lockFormulas:false,parent:null,colMargin:20,boxModelCorrection:2,formulaFunctions:{},formulaVariables:{},cellSelectModel:j.excelSelectModel,autoAddCells:true,resizableCells:true,resizableSheet:true,autoFiller:true,error:function(t){return t.error},endOfNumber:false,frozenAt:[],contextmenuTop:{"Insert column after":function(t){t.controlFactory.addColumn(false,t.colLast);return false},"Insert column before":function(t){t.controlFactory.addColumn(true,t.colLast);return false},"Add column to end":function(t){t.controlFactory.addColumn(true);return false},"Delete this column":function(t){t.deleteColumn();return false},"Hide column":function(t){t.toggleHideColumn();return false},"Show all columns":function(t){t.columnShowAll()},"Toggle freeze columns to here":function(v){var t=v.getTdLocation(v.obj.tdActive()).col,u=v.obj.pane().actionUI;u.frozenAt.col=(u.frozenAt.col==t?0:t)}},contextmenuLeft:{"Insert row after":function(t){t.controlFactory.addRow(true,t.rowLast);return false},"Insert row before":function(t){t.controlFactory.addRow(false,t.rowLast);return false},"Add row to end":function(t){t.controlFactory.addRow(true);return false},"Delete this row":function(t){t.deleteRow();return false},"Hide row":function(t){t.toggleHideRow(t.rowLast);return false},"Show all rows":function(t){t.rowShowAll()},"Toggle freeze rows to here":function(u){var v=u.getTdLocation(u.obj.tdActive()).row,t=u.obj.pane().actionUI;t.frozenAt.row=(t.frozenAt.row==v?0:v)}},contextmenuCell:{"Insert row after":function(t){t.controlFactory.addRow(true,t.rowLast);return false},"Insert row before":function(t){t.controlFactory.addRow(false,t.rowLast);return false},"Add row to end":function(t){t.controlFactory.addRow(true);return false},"Delete this row":function(t){t.deleteRow();return false},line2:"line","Insert column after":function(t){t.controlFactory.addColumn(true,t.colLast);return false},"Insert column before":function(t){t.controlFactory.addColumn(false,t.colLast);return false},"Add column to end":function(t){t.controlFactory.addColumn(true);return false},"Delete this column":function(t){t.deleteColumn();return false},line3:"line","Add spreadsheet":function(t){t.addSheet()},"Delete spreadsheet":function(t){t.deleteSheet()}},alert:function(t){alert(t)},prompt:function(u,v,t){v(prompt(u,t))},confirm:function(v,t,u){if(confirm(v)){t()}else{if(u){u()}}},loader:null,useStack:true,useMultiThreads:true},instance:[],dependencies:{coreCss:{css:"jquery.sheet.css"},jQueryUI:{script:"jquery-ui/jquery-ui.min.js",thirdParty:true},jQueryUIThemeRoller:{css:"jquery-ui/themes/smoothness/jquery-ui.min.css",thirdParty:true},globalize:{script:"globalize/lib/globalize.js",thirdParty:true},nearest:{script:"jquery-nearest/src/jquery.nearest.min.js",thirdParty:true},mousewheel:{script:"MouseWheel/MouseWheel.js",thirdParty:true},operative:{script:"operative/dist/operative.js",thirdParty:true}},optional:{advancedFn:{script:"plugins/jquery.sheet.advancedfn.js"},financeFn:{script:"plugins/jquery.sheet.financefn.js"},colorPicker:{css:"really-simple-color-picker/colorPicker.css",script:"really-simple-color-picker/jquery.colorPicker.min.js",thirdParty:true},elastic:{script:"jquery-elastic/jquery.elastic.source.js",thirdParty:true},globalizeCultures:{script:"globalize/lib/cultures/globalize.cultures.js",thirdParty:true},raphael:{script:"raphael/raphael.js",thirdParty:true},gRaphael:{script:"graphael/g.raphael.js",thirdParty:true},gRaphaelBar:{script:"graphael/g.bar.js",thirdParty:true},gRaphaelDot:{script:"graphael/g.dot.js",thirdParty:true},gRaphaelLine:{script:"graphael/g.line.js",thirdParty:true},gRaphaelPie:{script:"graphael/g.pie.js",thirdParty:true},thaw:{script:"thaw.js/thaw.js",thirdParty:true},undoManager:{script:"Javascript-Undo-Manager/js/undomanager.js",thirdParty:true},zeroClipboard:{script:"zeroclipboard/dist/ZeroClipboard.min.js",thirdParty:true}},events:["sheetAddRow","sheetAddColumn","sheetSwitch","sheetRename","sheetTabSortStart","sheetTabSortUpdate","sheetCellEdit","sheetCellEdited","sheetCalculation","sheetAdd","sheetDelete","sheetDeleteRow","sheetDeleteColumn","sheetOpen","sheetAllOpened","sheetSave","sheetFullScreen","sheetFormulaKeydown"],preLoad:function(w,v){w=w||"";v=d.extend({skip:["globalizeCultures"],thirdPartyDirectory:"bower_components/"},v);var u=d("script:first"),t=function(){var x;if(this.script!==undefined){x=k.createElement("script");x.src=w+(this.thirdParty?v.thirdPartyDirectory:"")+this.script;u.after(x)}if(this.css!==undefined){x=k.createElement("link");x.rel="stylesheet";x.type="text/css";x.href=w+(this.thirdParty?v.thirdPartyDirectory:"")+this.css;u.after(x)}};d.each(this.dependencies,t);d.each(this.optional,t)},createInstance:function(J,D){var t=d(f),w=d(k),B=k.body,y=d(B),E=function(){},H=undefined,C=g,v=isNaN,G=NaN,z=(d.sheet.defaults.useStack&&f.thaw!==H?f.thaw:function(I,L){L=L||{};var M=0,u=I.length,N,O=L.each||function(){},K=L.done||function(){};if(I[0].call!==H){for(;M<u;M++){N=I[M];N()}}else{for(;M<u;M++){N=I[M];O.apply(N)}K()}}),A={version:"4.x",i:0,I:D,sheetCount:0,spreadsheets:[],controls:{autoFiller:[],bar:{helper:[],corner:[],x:{controls:[],handleFreeze:[],menu:[],menuParent:[],parent:[],th:[],ths:function(){var I=[],L=0,K=this.th[A.i],u=K.length;for(;L<u;L++){I.push(K[L])}return I}},y:{controls:[],handleFreeze:[],menu:[],parent:[],th:[],ths:function(){var I=[],L=0,K=this.th[A.i],u=K.length;for(;L<u;L++){I.push(K[L])}return I}}},barMenuLeft:[],barMenuTop:[],barLeft:[],barTop:[],barTopParent:[],chart:[],tdMenu:[],cellsEdited:[],enclosures:[],formula:null,fullScreen:null,header:null,inPlaceEdit:[],inputs:[],label:null,menu:[],menus:[],pane:[],panes:null,scrolls:null,sheetAdder:null,tab:[],tabContainer:null,tabs:null,title:null,toggleHide:{x:[],y:[]},ui:null},obj:{autoFiller:function(){return A.controls.autoFiller[A.i]||null},barCorner:function(){return A.controls.bar.corner[A.i]||d([])},barHelper:function(){return A.controls.bar.helper[A.i]||(A.controls.bar.helper[A.i]=d([]))},barLeft:function(u){return(A.controls.bar.y.th[A.i]&&A.controls.bar.y.th[A.i][u]?A.controls.bar.y.th[A.i][u]:[])},barLeftControls:function(){return A.controls.bar.y.controls[A.i]||d([])},barLefts:function(){return A.controls.bar.y.ths()},barHandleFreezeLeft:function(){return A.controls.bar.y.handleFreeze[A.i]||d([])},barMenuLeft:function(){return A.controls.bar.y.menu[A.i]||d([])},barTop:function(u){return(A.controls.bar.x.th[A.i]&&A.controls.bar.x.th[A.i][u]?A.controls.bar.x.th[A.i][u]:[])},barTopControls:function(){return A.controls.bar.x.controls[A.i]||d([])},barTops:function(){return A.controls.bar.x.ths()},barTopParent:function(){return A.controls.bar.x.parent[A.i]||d([])},barHandleFreezeTop:function(){return A.controls.bar.x.handleFreeze[A.i]||d([])},barMenuParentTop:function(){return A.controls.bar.x.menuParent[A.i]||d([])},barMenuTop:function(){return A.controls.bar.x.menu[A.i]||d([])},tdActive:function(){return A.cellLast!==null?A.cellLast.td:null},cellActive:function(){return A.cellLast},tdMenu:function(){return A.controls.tdMenu[A.i]||d([])},cellsEdited:function(){return(A.controls.cellsEdited!==H?A.controls.cellsEdited:A.controls.cellsEdited=[])},chart:function(){return A.controls.chart[A.i]||d([])},enclosure:function(){return A.controls.enclosures[A.i]||[]},enclosures:function(){return A.controls.enclosures||[]},formula:function(){return A.controls.formula||d([])},fullScreen:function(){return A.controls.fullScreen||d([])},header:function(){return A.controls.header||d([])},highlighted:function(){return A.highlighter.last||d([])},inPlaceEdit:function(){return A.controls.inPlaceEdit[A.i]||d([])},inputs:function(){return A.controls.inputs[A.i]||d([])},label:function(){return A.controls.label||d([])},menus:function(){return A.controls.menus[A.i]||d([])},menu:function(){return A.controls.menu[A.i]||d([])},pane:function(){return A.controls.pane[A.i]||{}},panes:function(){return A.controls.panes||d([])},parent:function(){return J.parent},scrolls:function(){return A.controls.scrolls||d([])},sheetAdder:function(){return A.controls.sheetAdder||d([])},tab:function(){return A.controls.tab[A.i]||d([])},tabs:function(){return A.controls.tabs||d([])},tabContainer:function(){return A.controls.tabContainer||d([])},title:function(){return A.controls.title||d([])}},id:"jS_"+D+"_",cl:{autoFiller:"jSAutoFiller",autoFillerHandle:"jSAutoFillerHandle",autoFillerCover:"jSAutoFillerCover",barCorner:"jSBarCorner",barController:"jSBarController",barControllerChild:"jSBarControllerChild",barHelper:"jSBarHelper",barLeft:"jSBarLeft",barHandleFreezeLeft:"jSBarHandleFreezeLeft",barTop:"jSBarTop",barTopMenuButton:"jSBarTopMenuButton",barHandleFreezeTop:"jSBarHandleFreezeTop",chart:"jSChart",formula:"jSFormula",formulaParent:"jSFormulaParent",header:"jSHeader",fullScreen:"jSFullScreen",inPlaceEdit:"jSInPlaceEdit",menu:"jSMenu",menuFixed:"jSMenuFixed",parent:"jSParent",scroll:"jSScroll",sheetAdder:"jSSheetAdder",table:"jS",label:"jSLoc",pane:"jSEditPane",tab:"jSTab",tabContainer:"jSTabContainer",tabContainerScrollable:"jSTabContainerScrollable",tdMenu:"jSTdMenu",title:"jSTitle",enclosure:"jSEnclosure",ui:"jSUI"},msg:{addRowMulti:"How many rows would you like to add?",addColumnMulti:"How many columns would you like to add?",cellFind:"What are you looking for in this spreadsheet?",cellNoFind:"No results found.",dragToFreezeCol:"Drag to freeze column",dragToFreezeRow:"Drag to freeze row",addSheet:"Add a spreadsheet",openSheet:"Are you sure you want to open a different sheet? All unsaved changes will be lost.",toggleHideRow:"No row selected.",toggleHideColumn:"No column selected.",loopDetected:"Loop Detected",newSheetTitle:"What would you like the sheet's title to be?",notFoundColumn:"Column not found",notFoundRow:"Row not found",notFoundSheet:"Sheet not found",setCellRef:"Enter the name you would like to reference the cell by.",sheetTitleDefault:"Spreadsheet {index}",cellLoading:"Loading..."},kill:function(){if(!A){return false}d(k).unbind("keydown");this.obj.fullScreen().remove();(this.obj.inPlaceEdit().destroy||E)();J.parent.trigger("sheetKill").removeClass(A.theme.parent).html("");delete J.parent[0].jS;this.obj.menus().remove();var u=d.sheet.events.length;for(var I=0;I<u;I++){J.parent.unbind(d.sheet.events[I])}d.sheet.instance.splice(D,1);return true},trigger:function(u,I){I=I||[];return J.parent.triggerHandler(u,[A].concat(I))},getCell:function(K,N,L){var I,M,u;if((I=A.spreadsheets[K])===H||(M=I[N])===H||(u=M[L])===H){u=J.loader.jitCell(K,N,L)}if(u===H||u===null){return null}if(u.typeName!=="Sheet.Cell"){throw new p("Wrong Constructor")}u.sheetIndex=K;u.rowIndex=N;u.columnIndex=L;return u},getCellById:function(L,I,M){var u=J.loader,K;if(typeof I==="function"){K=-1;M=I}else{K=I;if(typeof K==="string"){K=u.getSpreadsheetIndexByTitle(K)}}if(A.isBusy()){A.whenNotBusy(function(){u.jitCellById(L,K,M)})}else{u.jitCellById(L,K,M)}return this},getCells:function(u,Q,R){var K=0,N=u.length,I=N-1,O,T,P,S=[],M=0,L;if(typeof Q==="function"){L=-1;R=Q}else{L=Q;if(typeof L==="string"){L=loader.getSpreadsheetIndexByTitle(L)}}A.whenNotBusy(function(){for(;K<N;K++){O=u[K];if(typeof O==="string"){(function(U){A.getCellById(O,L,function(V){S[U]=V;M++;if(M===N){R.apply(A,S)}})})(K)}else{T=O;P=A.getCell(T.sheet,T.rowIndex,T.columnIndex);if(P!==null){S[K]=P;M++;if(M===N){R.apply(A,S)}}}}});return this},updateCells:function(K,u,L){var I;if(typeof u==="function"){I=-1;L=u}else{I=u;if(typeof I==="string"){I=loader.getSpreadsheetIndexByTitle(I)}}A.getCells(K,I,function(){var O=arguments,M=O.length,Q=M-1,N=[],P=0;for(;P<M;P++){(function(R){O[R].updateValue(function(S){Q--;N[R]=S;if(Q<0){L.apply(A,N)}})})(P)}});return this},nav:false,setNav:function(K){var u=d.sheet.instance;for(var I=0;I<u.length;I++){(u[I]||{}).nav=false}A.nav=K},controlFactory:{addRowMulti:function(L,K,u){function I(N){var M=0;if(N>0){for(;M<N;M++){A.addColumn(L,u,true)}A.trigger("sheetAddRow",[L,u,N])}}if(!K){J.prompt(A.msg.addRowMulti,I)}else{I(K)}},addColumnMulti:function(I,L,u){function K(N){var M=0;if(N>0){for(;M<N;M++){A.addColumn(I,u,true)}A.trigger("sheetAddColumn",[I,u,N])}}if(!L){J.prompt(A.msg.addColumnMulti,K)}else{K(L)}},addRow:function(S,N,M){var O=J.loader,L=0,R=O.size(A.i),u=R.cols,I=A.spreadsheets[A.i],Q=[],P=A.i,K=A.obj.pane();if(N===undefined){N=R.rows-1}if(S){N++}for(;L<u;L++){Q.push(new j.Cell(P,null,A,A.cellHandler))}I.splice(N,0,Q);O.addRow(A.i,N,Q);K.actionUI.redrawRows();if(M!==true){A.trigger("sheetAddRow",[N,S,1])}},addColumn:function(U,M,N){var P=J.loader,O=0,T=P.size(A.i),u=T.rows,S,L=[],Q,I=A.spreadsheets[A.i],R=A.i,K=A.obj.pane();if(M===undefined){M=T.cols-1}if(U){M++}for(;O<u;O++){Q=new j.Cell(R,null,A,A.cellHandler);L.push(Q);S=I[O];S.splice(M,0,Q)}P.addColumn(A.i,M,L);K.actionUI.redrawColumns();if(N!==true){A.trigger("sheetAddColumn",[M,U,1])}},barHandleFreeze:{top:function(O,M){if(A.isBusy()){return false}var I=M.actionUI,T=M.tBody,U=I.frozenAt,R=I.scrolledArea;if(!(R.col<=(U.col+1))){return false}A.obj.barHelper().remove();var S,Q=T.children[0].children[U.col+1],u=M.getBoundingClientRect(),N=u.top+k.body.scrollTop,K=u.left+k.body.scrollLeft,P=k.createElement("div"),L=M.freezeHandleTop=d(P).appendTo(M).addClass(A.theme.barHandleFreezeTop+" "+A.cl.barHelper+" "+A.cl.barHandleFreezeTop).height(Q.clientHeight-1).css("left",(Q.offsetLeft-P.clientWidth)+"px").attr("title",A.msg.dragToFreezeCol);A.controls.bar.helper[A.i]=A.obj.barHelper().add(P);A.controls.bar.x.handleFreeze[A.i]=L;A.draggable(L,{axis:"x",start:function(){A.setBusy(true);S=d(k.createElement("div")).appendTo(M).css("position","absolute").addClass(A.theme.barFreezeIndicator+" "+A.cl.barHelper).height(Q.clientHeight-1).fadeTo(0,0.33)},drag:function(){var V=A.nearest(L,Q.parentNode.children).prev();if(V.length&&V.position){S.width(V.position().left+V.width())}},stop:function(X,V){S.remove();A.setBusy(false);A.setDirty(true);var W=A.nearest(L,Q.parentNode.children);A.obj.barHelper().remove();R.col=I.frozenAt.col=A.getTdLocation(W[0]).col-1;A.autoFillerHide()},containment:[K,N,K+M.clientWidth-f.scrollBarSize.width,N]});return true},left:function(O,M){if(A.isBusy()){return false}var I=M.actionUI,V=M.table,T=M.tBody,U=I.frozenAt,R=I.scrolledArea;if(!(R.row<=(U.row+1))){return false}A.obj.barHelper().remove();var Q=T.children[U.row+1].children[0],u=M.getBoundingClientRect(),N=u.top+k.body.scrollTop,K=u.left+k.body.scrollLeft,P=k.createElement("div"),L=M.freezeHandleLeft=d(P).appendTo(M).addClass(A.theme.barHandleFreezeLeft+" "+A.cl.barHelper+" "+A.cl.barHandleFreezeLeft).width(Q.clientWidth).css("top",(Q.offsetTop-P.clientHeight+1)+"px").attr("title",A.msg.dragToFreezeRow),S;A.controls.bar.helper[A.i]=A.obj.barHelper().add(P);A.controls.bar.y.handleFreeze[A.i]=L;A.draggable(L,{axis:"y",start:function(){A.setBusy(true);S=d(k.createElement("div")).appendTo(M).css("position","absolute").addClass(A.theme.barFreezeIndicator+" "+A.cl.barHelper).width(P.clientWidth).fadeTo(0,0.33)},drag:function(){var W=A.nearest(L,Q.parentNode.parentNode.children).prev();if(W.length&&W.position){S.height(W.position().top+W.height())}},stop:function(Y,W){S.remove();A.setBusy(false);A.setDirty(true);var X=A.nearest(L,Q.parentNode.parentNode.children);A.obj.barHelper().remove();R.row=I.frozenAt.row=C.max(A.getTdLocation(X.children(0)[0]).row-1,0);A.autoFillerHide()},containment:[K,N,K,N+M.clientHeight-f.scrollBarSize.height]});return true},corner:function(){}},menu:function(K,u){var N,I=d([]),M=A.theme.menuHover;switch(K){case"top":N=d(k.createElement("div")).addClass(A.theme.menu+" "+A.cl.tdMenu);A.controls.bar.x.menu[A.i]=N;break;case"left":N=d(k.createElement("div")).addClass(A.theme.menu+" "+A.cl.tdMenu);A.controls.bar.y.menu[A.i]=N;break;case"cell":N=d(k.createElement("div")).addClass(A.theme.menu+" "+A.cl.tdMenu);A.controls.tdMenu[A.i]=N;break}A.controls.menus[A.i]=A.obj.menus().add(N);N.mouseleave(function(){N.hide()}).bind("contextmenu",function(){return false}).appendTo(y).hide().disableSelectionSpecial();for(var L in u){if(u[L]){if(d.isFunction(u[L])){I.pushStack(d(k.createElement("div")).text(L).data("msg",L).click(function(){u[d(this).data("msg")].call(this,A);N.hide();return false}).appendTo(N).hover(function(){I.removeClass(M);d(this).addClass(M)},function(){d(this).removeClass(M)}))}else{if(u[L]=="line"){d(k.createElement("hr")).appendTo(N)}}}}return N},barMenu:{top:function(K,u,I){if(A.isBusy()){return false}var M=A.obj.barMenuTop().hide();if(!M.length){M=A.controlFactory.menu("top",J.contextmenuTop)}A.obj.menus().hide();if(!I){M.css("left",(K.pageX-5)+"px").css("top",(K.pageY-5)+"px").show();return M}var L=A.obj.barMenuParentTop().hide();if(!L.length){L=d(k.createElement("div")).addClass(A.theme.barMenuTop+" "+A.cl.barHelper+" "+A.cl.barTopMenuButton).append(d(k.createElement("span")).addClass("ui-icon ui-icon-triangle-1-s")).mousedown(function(N){L.parent().mousedown().mouseup();var O=L.offset();M.css("left",(N.pageX-5)+"px").css("top",(N.pageY-5)+"px").show()}).blur(function(){if(M){M.hide()}});L.get(0).destroy=function(){L.remove();A.controls.bar.x.menuParent[A.i]=null};A.controls.bar.x.menuParent[A.i]=L}L.prependTo(I).show()},left:function(I,u){if(A.isBusy()){return false}A.obj.barMenuLeft().hide();if(u){A.obj.barHandleFreezeLeft().remove()}var K;K=A.obj.barMenuLeft();if(!K.length){K=A.controlFactory.menu("left",J.contextmenuLeft)}A.obj.menus().hide();K.css("left",(I.pageX-5)+"px").css("top",(I.pageY-5)+"px").show();return true},corner:function(){}},tdMenu:function(u){if(A.isBusy()){return false}A.obj.tdMenu().hide();var I=A.obj.tdMenu();if(!I.length){I=A.controlFactory.menu("cell",J.contextmenuCell)}A.obj.menus().hide();I.css("left",(u.pageX-5)+"px").css("top",(u.pageY-5)+"px").show();return true},header:function(){A.obj.header().remove();A.obj.sheetAdder().remove();A.obj.tabContainer().remove();var O=k.createElement("div"),Q,L,R=k.createElement("h4"),S,K,u,P,I;O.className=A.cl.header+" "+A.theme.control;A.controls.header=d(O);if(J.title){if(d.isFunction(J.title)){J.title=A.title(A,D)}R.className=A.cl.title;A.controls.title=d(R).html(J.title)}else{d(R).hide()}O.appendChild(R);if(A.isSheetEditable()){if(J.menu){K=k.createElement("div");u=d(K);K.className=A.cl.menu+" "+A.cl.menuFixed+" "+A.theme.menuFixed;O.appendChild(K);A.controls.menu[A.i]=u.append(J.menu).children().addClass(A.theme.menuFixed);u.find("img").load(function(){A.sheetSyncSize()})}S=k.createElement("td");S.className=A.cl.label+" "+A.theme.control;A.controls.label=d(S);P=k.createElement("textarea");P.className=A.cl.formula+" "+A.theme.controlTextBox;P.onkeydown=A.evt.formula.keydown;P.onkeyup=function(){A.obj.inPlaceEdit().value=this.value};P.onchange=function(){A.obj.inPlaceEdit().value=this.value};P.onpaste=A.evt.pasteOverCells;P.onfocus=function(){A.setNav(false)};P.onfocusout=function(){A.setNav(true)};P.onblur=function(){A.setNav(true)};A.controls.formula=d(P);var N=k.createElement("span");N.appendChild(P);Q=k.createElement("table");L=k.createElement("tr");Q.appendChild(L);O.appendChild(Q);I=k.createElement("td");I.className=A.cl.formulaParent;I.appendChild(N);L.appendChild(S);L.appendChild(I);L.appendChild(k.createElement("td"));A.resizableSheet(d(N),{minHeight:A.controls.formula.height(),maxHeight:78,handles:"s",resize:function(V,U){A.controls.formula.height(U.size.height)},stop:function(){A.sheetSyncSize()}});var T=d.sheet.instance;for(var M=0;M<T.length;M++){(T||{}).nav=false}A.setNav(true);d(k).keydown(A.evt.document.keydown)}return O},ui:function(){var u=k.createElement("div");u.setAttribute("class",A.cl.ui);A.obj.ui=u;return u},sheetAdder:function(){var u=k.createElement("span");if(A.isSheetEditable()){u.setAttribute("class",A.cl.sheetAdder+" "+A.cl.tab+" "+A.theme.tab);u.setAttribute("title",A.msg.addSheet);u.innerHTML="+";u.onmousedown=function(){A.addSheet();return false};u.i=-1}return A.controls.sheetAdder=d(u)},tabContainer:function(){var u=k.createElement("span"),I;u.setAttribute("class",A.cl.tabContainer);u.onmousedown=function(L){L=L||f.event;var K=(L.target||L.srcElement).i;if(K>=0){A.trigger("sheetSwitch",[K])}return false};u.ondblclick=function(L){L=L||f.event;var K=(L.target||L.srcElement).i;if(K>=0){A.trigger("sheetRename",[K])}return false};if(A.isSheetEditable()&&d.fn.sortable){return A.controls.tabContainer=d(u).sortable({placeholder:"ui-state-highlight",axis:"x",forceHelperSize:true,forcePlaceholderSize:true,opacity:0.6,start:function(L,K){I=K.item.index();A.trigger("sheetTabSortStart",[L,K])},update:function(L,K){A.trigger("sheetTabSortUpdate",[L,K,I])}})}return A.controls.tabContainer=d(u)},sheetUI:function(M,K){A.i=K;var N=A.controlFactory.enclosure(),P=N.pane,L=d(P),I=function(T){T=T||f.event;if(A.isBusy()){return false}if(A.isBar(T.target)){var S=T.target,R=S.index,Q=S.entity;if(R<0){return false}if(A.evt.barInteraction.first===A.evt.barInteraction.last){A.controlFactory.barMenu[Q](T,R)}}else{A.controlFactory.tdMenu(T)}return false};M.appendChild(N);if(A.isSheetEditable()){A.controlFactory.autoFiller(P)}if(A.isSheetEditable()){var O=A.obj.formula(),u="";L.mousedown(function(Q){A.setNav(true);if(A.isBusy()){return false}if(A.isCell(Q.target)){if(Q.button==2){I.call(this,Q);A.evt.cellOnMouseDown(Q);return true}A.evt.cellOnMouseDown(Q);return false}if(A.isBar(Q.target)){if(Q.button==2){I.call(this,Q)}u=Q.target.entity;A.evt.barInteraction.select(Q.target);return false}return true});P.onmouseup=function(){u=""};P.onmouseover=function(U){U=U||f.event;var T=U.target||U.srcElement;if(A.isBusy()){return false}if(!A.isBar(T)){return false}var S=T,Q=S.entity,R=S.index;if(R<0){return false}if(A.evt.barInteraction.selecting&&S===u){A.evt.barInteraction.last=R;A.cellSetActiveBar(Q,A.evt.barInteraction.first,A.evt.barInteraction.last)}else{A.resizeBar[Q](S,R,P);if(A.isSheetEditable()){A.controlFactory.barHandleFreeze[Q](R,P);if(Q=="top"){A.controlFactory.barMenu[Q](U,R,S)}}}return true};P.ondblclick=A.evt.cellOnDblClick;L.bind("contextmenu",I).disableSelectionSpecial().bind("cellEdit",A.evt.cellEdit)}A.controlFactory.tab();A.setChanged(true)},enclosure:function(){var K=k.createElement("div"),I=d(K),u=new j.ActionUI(A,K,A.cl.scroll,A.s.frozenAt[A.i]),L=u.pane;L.setAttribute("class",A.cl.pane+" "+A.theme.pane);K.setAttribute("class",A.cl.enclosure);K.pane=L;L.enclosure=K;L.$enclosure=I;A.controls.pane[A.i]=L;A.controls.panes=A.obj.panes().add(L);A.controls.enclosures[A.i]=K;return K},tab:function(){var u=k.createElement("span"),I=A.controls.tab[A.i]=d(u).appendTo(A.obj.tabContainer());u.setAttribute("class",A.cl.tab+" "+A.theme.tab);A.sheetTab(true,function(K){u.innerHTML=K});u.i=A.i;A.controls.tabs=A.obj.tabs().add(I);return u},customTab:function(K){var u=k.createElement("span"),I=d(u).appendTo(A.obj.tabContainer());u.setAttribute("class",A.cl.tab+" "+A.theme.tab);u.innerHTML=K;return I},inPlaceEdit:function(O,I){O=O||A.obj.cellActive().td||null;if(O===null){O=A.rowTds(null,1)[1];A.cellEdit(O)}if(O===null){return}(A.obj.inPlaceEdit().destroy||E)();var N=A.obj.formula(),K=N.val(),u,M,L=A.obj.pane();if(!O.isHighlighted){return}u=k.createElement("textarea");M=d(u);L.inPlaceEdit=u;u.i=A.i;u.className=A.cl.inPlaceEdit+" "+A.theme.inPlaceEdit;u.td=O;u.table=O.parentNode.parentNode.parentNode;u.goToTd=function(){this.offset=d(O).position();if(!this.offset.left&&!this.offset.right){d(u).hide()}else{this.setAttribute("style","left:"+(this.offset.left-1)+"px;top:"+(this.offset.top-1)+"px;width:"+this.td.clientWidth+"px;height:"+this.td.clientHeight+"px;min-width:"+this.td.clientWidth+"px;min-height:"+this.td.clientHeight+"px;")}};u.goToTd();u.onkeydown=A.evt.inPlaceEdit.keydown;u.onchange=u.onkeyup=function(){N[0].value=u.value};u.onfocus=function(){A.setNav(false)};u.onblur=u.onfocusout=function(){A.setNav(true)};u.onpaste=A.evt.pasteOverCells;u.destroy=function(){L.inPlaceEdit=null;A.cellLast.isEdit=(u.value!=K);u.parentNode.removeChild(u);A.controls.inPlaceEdit[u.i]=false};L.appendChild(u);u.onfocus();A.controls.inPlaceEdit[A.i]=u;M.focus().val("").val(N[0].value);if(I){M.select()}if(d.fn.elastic){d(u).elastic()}},autoFiller:function(L){if(!J.autoFiller){return false}var I=k.createElement("div"),u=k.createElement("div"),K=k.createElement("div");I.i=A.i;I.className=A.cl.autoFiller+" "+A.theme.autoFiller;u.className=A.cl.autoFillerHandle;K.className=A.cl.autoFillerCover;I.onmousedown=function(){var N=A.obj.tdActive();if(N){var M=A.getTdLocation(N);A.cellSetActive(N,M,true,A.autoFillerNotGroup,function(){var P=A.highlighted(),O=A.getTdLocation(P.last());A.fillUpOrDown(O.row<M.row||O.col<M.col);A.autoFillerGoToTd(N);A.autoFillerNotGroup=false})}return false};L.autoFiller=A.controls.autoFiller[A.i]=I;L.appendChild(I);return true}},autoFillerNotGroup:true,tsv:new TSV(),updateCellsAfterPasteToFormula:function(S){var Q=0,P=A.obj.formula(),R=A.cellLast;S=S||P.val();var I=P.val(),K=I;if((R.rowIndex==0&&R.columnIndex==0)||I.length===0){return false}var O=A.tsv.parse(I);if(!d.isArray(O)){P.val(O);A.fillUpOrDown(false,O);return true}var N=0,M,L,u,U,T;for(;N<O.length;N++){R.isEdit=true;L=O[N];for(M=0;M<L.length;M++){Q++;if(!(u=A.spreadsheets[A.i])||!(U=u[N+R.rowIndex])||!(T=U[M+R.columnIndex])){continue}if(T){(function(V,W){J.parent.one("sheetPreCalculation",function(){if((W+"").charAt(0)=="="){V.formula=W.substring(1);V.value=""}else{V.formula="";V.value=W}})})(T,L[M]);A.resolveCell(T);if(N==0&&M==0){K=L[M]}}}}if(I!=K){P.val(K)}A.fillUpOrDown(false,K);A.evt.cellEditDone(true);return true},evt:{inPlaceEdit:{enter:function(u){if(u.shiftKey){return true}return A.evt.cellSetActiveFromKeyCode(u,true)},tab:function(u){if(u.shiftKey){return true}return A.evt.cellSetActiveFromKeyCode(u,true)},keydown:function(u){u=u||f.event;A.trigger("sheetFormulaKeydown",[true]);switch(u.keyCode){case q.ENTER:return A.evt.inPlaceEdit.enter(u);break;case q.TAB:return A.evt.inPlaceEdit.tab(u);break;case q.ESCAPE:A.evt.cellEditAbandon();return false;break}}},formula:{keydown:function(u){u=u||f.event;if(A.readOnly[A.i]){return false}if(A.cellLast===null){return false}if(A.cellLast.rowIndex<0||A.cellLast.columnIndex<0){return false}A.trigger("sheetFormulaKeydown",[false]);switch(u.keyCode){case q.C:if(u.ctrlKey){return A.evt.document.copy(u)}case q.X:if(u.ctrlKey){return A.evt.document.cut(u)}case q.Y:if(u.ctrlKey){A.evt.document.redo(u);return false}break;case q.Z:if(u.ctrlKey){A.evt.document.undo(u);return false}break;case q.ESCAPE:A.evt.cellEditAbandon();return true;break;case q.ENTER:A.evt.cellSetActiveFromKeyCode(u,true);return false;break;case q.UNKNOWN:return false}A.cellLast.isEdit=true},If:function(I,u){if(I){d(A.obj.tdActive()).dblclick();return true}return false}},document:{enter:function(u){if(!A.cellLast.isEdit&&!u.ctrlKey){d(A.obj.tdActive()).dblclick()}return false},tab:function(u){A.evt.cellSetActiveFromKeyCode(u)},findCell:function(u){if(u.ctrlKey){A.cellFind();return false}return true},redo:function(u){if(u.ctrlKey&&!A.cellLast.isEdit){A.undo.manager.redo();return false}return true},undo:function(u){if(u.ctrlKey&&!A.cellLast.isEdit){A.undo.manager.undo();return false}return true},copy:function(M,I){var L=A.highlighted(true),N=A.obj.formula(),K=N.val(),u=A.toTsv(L,I);N.val(u).focus().select();w.one("keyup",function(){if(I){N.val("")}else{N.val(K)}});return true},cut:function(u){return this.copy(u,true)},pageUpDown:function(u){var L=A.sheetSize(),P=A.obj.pane(),K=P.clientHeight,M=0,N=0,O,I;if(u){for(I=A.cellLast.rowIndex;I>0&&M<K;I--){O=A.getTd(-1,I,1);if(O!==null&&!O.getAttribute("data-hidden")&&d(O).is(":hidden")){d(O).show()}M+=O.parentNode.clientHeight}}else{for(I=A.cellLast.rowIndex;I<L.rows&&M<K;I++){O=A.getTd(-1,I,1);if(O===null){continue}M+=O.parentNode.clientHeight}}A.cellEdit(O);return false},keydown:function(u){u=u||f.event;if(A.readOnly[A.i]){return false}if(A.cellLast===null){return}if(A.cellLast.rowIndex<0||A.cellLast.columnIndex<0){return false}var I=A.cellLast.td;if(A.nav){switch(u.keyCode){case q.DELETE:A.toTsv(null,true);A.obj.formula().val("");A.cellLast.isEdit=true;break;case q.TAB:A.evt.document.tab(u);break;case q.ENTER:A.evt.cellSetActiveFromKeyCode(u);break;case q.LEFT:case q.UP:case q.RIGHT:case q.DOWN:(u.shiftKey?A.evt.cellSetHighlightFromKeyCode(u):A.evt.cellSetActiveFromKeyCode(u));break;case q.PAGE_UP:A.evt.document.pageUpDown(true);break;case q.PAGE_DOWN:A.evt.document.pageUpDown();break;case q.HOME:case q.END:A.evt.cellSetActiveFromKeyCode(u);break;case q.V:if(u.ctrlKey){return A.evt.formula.If(!A.evt.pasteOverCells(u),u)}else{d(I).trigger("cellEdit");return true}break;case q.Y:if(u.ctrlKey){A.evt.document.redo(u);return false}else{d(I).trigger("cellEdit");return true}break;case q.Z:if(u.ctrlKey){A.evt.document.undo(u);return false}else{d(I).trigger("cellEdit");return true}break;case q.ESCAPE:A.evt.cellEditAbandon();break;case q.F:if(u.ctrlKey){return A.evt.formula.If(A.evt.document.findCell(u),u)}else{d(I).trigger("cellEdit");return true}break;case q.CAPS_LOCK:case q.SHIFT:case q.ALT:break;case q.CONTROL:A.obj.formula().focus().select();return true;break;default:if(A.obj.inPlaceEdit().td!==I){d(I).trigger("cellEdit")}return true;break}return false}}},pasteOverCells:function(I){I=I||f.event;if(I.ctrlKey||I.type=="paste"){var u=function(){A.updateCellsAfterPasteToFormula()};var K=w.one("keyup",function(){u();u=function(){};K.mouseup()}).one("mouseup",function(){u();u=function(){};K.keyup()});A.setDirty(true);A.setChanged(true);return true}return false},cellEditDone:function(u){var I=A.obj.inPlaceEdit(),K=d(I).is(":focus"),S=A.cellLast,R;(I.destroy||E)();if(S!==null&&(S.isEdit||u)){R=A.getCell(S.sheetIndex,S.rowIndex,S.columnIndex);var N=(K?d(I):A.obj.formula()),L=R.td;if(A.isFormulaEditable(L)){if(L!==null&&R.rowIndex>0&&R.columnIndex>0){var Q=N.val(),M=0,P=J.loader,O;if(!R.edited){R.edited=true;A.obj.cellsEdited().push(R)}J.parent.one("sheetPreCalculation",function(){R.parsedFormula=null;if(Q.charAt(0)=="="){R.formula=Q=Q.substring(1)}else{R.value=Q;R.formula="";if((O=R.loadedFrom)!==null){P.setCellAttributes(O,{cache:H,formula:"",value:Q,parsedFormula:null})}}R.setNeedsUpdated()});A.resolveCell(R);R.isEdit=false;A.trigger("sheetCellEdited",[R])}}}},cellEditAbandon:function(I){(A.obj.inPlaceEdit().destroy||E)();A.highlighter.clearBar().clear();var u=A.cellLast;if(!I&&u!==null){u.updateValue()}A.cellLast=null;A.rowLast=0;A.colLast=0;A.highlighter.startRowIndex=0;A.highlighter.startColumnIndex=0;A.highlighter.endRowIndex=0;A.highlighter.endColumnIndex=0;A.labelUpdate("");A.obj.formula().val("").blur();A.autoFillerHide();return false},cellSetHighlightFromKeyCode:function(M){var K=A.orderedGrid(A.highlighter),I=A.sheetSize(),L=A.cellActive,u=A.highlighter;if(L===null){return false}switch(M.keyCode){case q.UP:if(K.startRowIndex<L.rowIndex){K.startRowIndex--;K.startRowIndex=K.startRowIndex>0?K.startRowIndex:1;break}K.endRowIndex--;K.endRowIndex=K.endRowIndex>0?K.endRowIndex:1;break;case q.DOWN:if(K.startRowIndex===K.endRowIndex){K.startRowIndex++;K.startRowIndex=K.startRowIndex<I.rows?K.startRowIndex:I.rows;break}if(K.startRowIndex<cell.rowIndex){K.startRowIndex++;K.startRowIndex=K.startRowIndex>0?K.startRowIndex:1;break}K.endRowIndex++;K.endRowIndex=K.endRowIndex<I.rows?K.endRowIndex:I.rows;break;case q.LEFT:if(K.startColumnIndex<cell.columnIndex){K.startColumnIndex--;K.startColumnIndex=K.startColumnIndex>0?K.startColumnIndex:1;break}K.endColumnIndex--;K.endColumnIndex=K.endColumnIndex>0?K.endColumnIndex:1;break;case q.RIGHT:if(K.startColumnIndex<cell.columnIndex){K.startColumnIndex++;K.startColumnIndex=K.startColumnIndex<I.cols?K.startColumnIndex:I.cols;break}K.endColumnIndex++;K.endColumnIndex=K.endColumnIndex<I.cols?K.endColumnIndex:I.cols;break}u.startRowIndex=K.startRowIndex;u.startColumnIndex=K.startColumnIndex;u.endRowIndex=K.endRowIndex;u.endColumnIndex=K.endColumnIndex;A.cycleCellArea(function(N){u.set(N.td)},K);return false},cellSetActiveFromKeyCode:function(O,L){if(A.cellLast===null){return false}var P=A.cellLast,N={rowIndex:P.rowIndex,columnIndex:P.columnIndex},I,R,Q,M=false,K,u=false;switch(O.keyCode){case q.UP:N.rowIndex--;break;case q.DOWN:N.rowIndex++;break;case q.LEFT:N.columnIndex--;break;case q.RIGHT:N.columnIndex++;break;case q.ENTER:N=A.evt.incrementAndStayInGrid(A.orderedGrid(A.highlighter),N,true,O.shiftKey);M=true;K=A.highlighted();if(K.length>1){u=true}else{if(!L){N.rowIndex+=(O.shiftKey?-1:1)}}break;case q.TAB:N=A.evt.incrementAndStayInGrid(A.orderedGrid(A.highlighter),N,false,O.shiftKey);M=true;K=A.highlighted();if(K.length>1){u=true}else{if(!L){N.columnIndex+=(O.shiftKey?-1:1)}}break;case q.HOME:N.columnIndex=1;break;case q.END:N.columnIndex=A.obj.tdActive().parentNode.children.length-2;break}N.columnIndex=N.columnIndex||1;N.rowIndex=N.rowIndex||1;if(!P.isEdit||M){if((I=A.spreadsheets[A.i])===H){return false}if((R=I[N.rowIndex])===H){return false}if((Q=R[N.columnIndex])===H){return false}if(Q!==null){A.cellEdit(Q.td,null,u);return false}}return true},incrementAndStayInGrid:function(I,L,K,u){if(K){if(u){L.rowIndex--;if(L.rowIndex<I.startRowIndex){L.rowIndex=I.endRowIndex;L.columnIndex--}if(L.columnIndex<I.startColumnIndex){L.columnIndex=I.endColumnIndex}}else{L.rowIndex++;if(L.rowIndex>I.endRowIndex){L.rowIndex=I.startRowIndex;L.columnIndex++}if(L.columnIndex>I.endColumnIndex){L.columnIndex=I.startColumnIndex}}}else{if(u){L.columnIndex--;if(L.columnIndex<I.startColumnIndex){L.columnIndex=I.endColumnIndex;L.rowIndex--}if(L.rowIndex<I.startRowIndex){L.rowIndex=I.endRowIndex}}else{L.columnIndex++;if(L.columnIndex>I.endColumnIndex){L.columnIndex=I.startColumnIndex;L.rowIndex++}if(L.rowIndex>I.endRowIndex){L.rowIndex=I.startRowIndex}}}return L},cellOnMouseDown:function(u){A.obj.formula().blur();if(u.shiftKey){A.getTdRange(u,A.obj.formula().val())}else{A.cellEdit(u.target,true)}},cellOnDblClick:function(u){if(A.isBusy()){return false}A.controlFactory.inPlaceEdit();return true},cellEdit:function(u){if(A.isBusy()){return false}A.controlFactory.inPlaceEdit(null,true);return true},barInteraction:{first:null,last:null,selecting:false,select:function(L){if(!L){return}if(!L.type==="bar"){return}var K=L,u=K.entity,I=K.index;if(I<0){return false}A.evt.barInteraction.last=A.evt.barInteraction.first=A[u+"Last"]=I;A.cellSetActiveBar(u,A.evt.barInteraction.first,A.evt.barInteraction.last);A.evt.barInteraction.selecting=true;w.one("mouseup",function(){A.evt.barInteraction.selecting=false});return false}}},refreshColumnLabels:function(N){N=N||0;var I=A.obj.barMenuParentTop();if((I)&&(I.length)){var M=I.get(0);if(d.isFunction(M.destroy)){M.destroy()}}var u=A.controls.bar.x.th[A.i],L;if(!u){return}for(var K=g.max(N,0);K<u.length;K++){if(K>0){L=u[K];L.innerHTML=L.label=A.cellHandler.columnLabelString(L.cellIndex)}}},refreshRowLabels:function(M,u){M=M||0;var I=A.controls.bar.y.th[A.i],L;if(!I){return}u=u||I.length;for(var K=M;K<u;K++){if(K>0&&(L=I[K])!==H){L.innerHTML=L.label=L.parentNode.rowIndex}}},isCell:function(u){if(u&&u.jSCell!==H){return true}return false},isBar:function(u){if(u.tagName=="TH"){return true}return false},readOnly:[],isSheetEditable:function(u){u=u||A.i;return(J.editable==true&&!A.readOnly[u])},isFormulaEditable:function(u){if(J.lockFormulas){if(u.data("formula")!==H){return false}}return true},toggleFullScreen:function(){if(!A){return}A.evt.cellEditDone();var K=A.obj.fullScreen(),N=A.obj.pane();if(K.is(":visible")){t.unbind("jSResize");y.removeClass("bodyNoScroll");J.parent=K[0].origParent;J.parent.prepend(K.children());K.remove();A.sheetSyncSize();if(N.inPlaceEdit){N.inPlaceEdit.goToTd()}A.trigger("sheetFullScreen",[false])}else{y.addClass("bodyNoScroll");var L=d(J.parent),K=k.createElement("div"),I=d._data(J.parent[0],"events");K.className=A.cl.fullScreen+" "+A.theme.fullScreen+" "+A.cl.parent;K.origParent=L;J.parent=A.controls.fullScreen=d(K).append(L.children()).appendTo(y);t.bind("resize",function(){t.trigger("jSResize")}).bind("jSResize",function(){this.w=t.width();this.h=t.height();J.parent.width(this.w).height(this.h);A.sheetSyncSize();if(N.inPlaceEdit){N.inPlaceEdit.goToTd()}}).trigger("jSResize");L.trigger("sheetFullScreen",[true]);for(var M in I){for(var u=0;u<I[M].length;u++){J.parent.bind(M,I[M][u].handler)}}}},renameSheet:function(u){if(v(u)){return false}if(u>-1){A.sheetTab()}return true},switchSheet:function(u){if(v(u)){return false}if(u==-1){A.addSheet()}else{if(u!=A.i){A.setActiveSheet(u);if(J.loader===null){A.calc(u)}}}return true},toggleHideRow:function(u){if(u===undefined){u=A.rowLast}if(u===undefined){return}var I=A.obj.pane().actionUI;if(I.hiddenRows.indexOf(u)>-1){I.showRow(u)}else{I.hideRow(u)}A.autoFillerGoToTd()},toggleHideRowRange:function(K,I){var u=A.obj.pane().actionUI;if(u.hiddenRows.indexOf(K)>-1){u.showRowRange(K,I)}else{u.hideRowRange(K,I)}A.autoFillerGoToTd()},toggleHideColumn:function(u){if(u===undefined){u=A.colLast}if(u===undefined){return}var I=A.obj.pane().actionUI;if(I.hiddenColumns.indexOf(u)>-1){I.showColumn(u)}else{I.hideColumn(u)}A.autoFillerGoToTd()},toggleHideColumnRange:function(K,I){var u=A.obj.pane().actionUI;if(u.hiddenColumns.indexOf(K)>-1){u.showColumnRange(K,I)}else{u.hideColumnRange(K,I)}A.autoFillerGoToTd()},rowShowAll:function(){A.obj.pane().actionUI.rowShowAll()},columnShowAll:function(){A.obj.pane().actionUI.columnShowAll()},merge:function(O){O=O||A.highlighted();if(!O.length){return}var M=[],u=O[0],L=O[O.length-1],T=A.getTdLocation(u),I=A.getTdLocation(L),V={},R={},Q=0,S=0,N=O.length-1,U,W,K,P;if(T.row){A.setDirty(true);A.setChanged(true);if(T.row<I.row){V.row=T.row;R.row=I.row;K=u}else{V.row=I.row;R.row=T.row;K=L}if(K.hasAttribute("rowSpan")||K.hasAttribute("colSpan")){return false}if(T.col<I.col){V.col=T.col;R.col=I.col}else{V.col=I.col;R.col=T.col}S=(R.row-V.row)+1;Q=(R.col-V.col)+1;P=A.getTdLocation(K);do{W=O[N];U=W.jSCell;if(U.formula||U.value){M.unshift(U.formula?"("+U.formula.substring(1)+")":U.value)}J.parent.one("sheetPreCalculation",function(){if(W.cellIndex!=P.col||W.parentNode.rowIndex!=P.row){U.formula="";U.value="";U.defer=K.jSCell;W.innerHTML="";W.style.visibility="collapse"}});A.resolveCell(U)}while(N--);K.jSCell.value=d.trim(M.join(" "));K.jSCell.formula=d.trim(K.jSCell.formula?M.join(" "):"");K.setAttribute("rowSpan",S);K.setAttribute("colSpan",Q);K.style.display="";K.style.visibility="";K.style.position="";K.style.height=K.clientHeight+"px";K.style.width=K.clientWidth+"px";K.style.position="absolute";A.resolveCell(K.jSCell);A.evt.cellEditDone();A.autoFillerGoToTd(K);A.cellSetActive(K,P)}return true},unmerge:function(I){I=I||A.highlighted();if(!I){return}var N=A.getTdLocation(I),O=new a(),Q=C.max(I.getAttribute("rowSpan")*1,1)-1,u=C.max(I.getAttribute("colSpan")*1,1)-1,M=Q+N.row,K,P,L=[];if(Q==0&&u==0){return false}do{K=N.col+u;do{P=A.getTd(-1,M,K);if(P===null){continue}P.style.display="";P.style.visibility="";P.removeAttribute("colSpan");P.removeAttribute("rowSpan");P.jSCell.defer=null;A.resolveCell(P.jSCell,O);L.push(P)}while(K-->N.col)}while(M-->N.row);A.evt.cellEditDone();A.autoFillerGoToTd(I);A.cellSetActive(I,N);A.highlighter.set(L);return true},fillUpOrDown:function(P,Q,S){A.evt.cellEditDone();S=S||A.highlighted(true);if(S.length<1){return false}var M=A.obj.tdActive();if(S.length<1){return false}var N=A.getTdLocation(S[0].td),T=A.getTdLocation(S[S.length-1].td),u=A.getTdLocation(M),K={row:0,col:0},I=Q||M.jSCell.value,R=false,L=S.length-1,O=function(){};Q=Q||M.jSCell.value;if(L>=0){if(Q.charAt&&Q.charAt(0)=="="){if(L>=0){do{if(!P){K.row=u.row-T.row;K.col=u.col-T.col}else{K.row=u.row-N.row;K.col=u.col-N.col}I=A.reparseFormula(Q,K);J.parent.one("sheetPreCalculation",function(){S[L].formula=I;S[L].value=""});A.resolveCell(S[L])}while(L--);return true}}else{if((R=!v(I))||I.length>0){if(R&&I!=""){I*=1;if(P){I-=S.length-1}O=function(){I++}}}do{J.parent.one("sheetPreCalculation",function(){S[L].formula="";S[L].value=I+""});A.resolveCell(S[L]);O()}while(L--);return true}}return false},toTsv:function(S,L,Q){S=S||A.highlighted(true);if(S.type){S=[S]}Q=Q||function(V,U){if(L){J.parent.one("sheetPreCalculation",function(){U.formula="";U.value=""});A.resolveCell(U)}};var O=[],R,N,I={},K=S.length-1,T,u;if(K>=0){R=A.getTdLocation(S[0].td);N=A.getTdLocation(S[S.length-1].td);I.row=C.min(R.row,N.row);I.col=C.min(R.col,N.col);do{var M=A.getTdLocation(S[K].td),P=(S[K].formula?"="+S[K].formula:S[K].value);T=C.abs(M.row-I.row);u=C.abs(M.col-I.col);if(!O[T]){O[T]=[]}if((P+="").match(/\n/)){P='"'+P+'"'}O[T][u]=(P||"");Q.call(S[K].td,M,S[K])}while(K-->0);K=O.length-1;do{O[K]=O[K].join("\t")}while(K-->0);return O.join("\n")}return""},offsetFormulas:function(O,N,K,M){var I=A.sheetSize(),L={first:{row:0,col:0},last:{row:I.rows,col:I.cols}},u=[];A.cycleCells(function(){var P=this;if(this.formula&&typeof this.formula=="string"&&A.isFormulaEditable(this.td)){this.formula=A.reparseFormula(this.formula,N,O,K,M)}u.push(function(){A.resolveCell(P,true)})},L.first,L.last);while(u.length){u.pop()()}A.evt.cellEditDone()},cellRegex:/(\$?[a-zA-Z]+|[#]REF[!])(\$?[0-9]+|[#]REF[!])/gi,reparseFormula:function(M,L,K,u,I){return M.replace(this.cellRegex,function(O,P,T,U){if(P=="SHEET"){return O}L=L||{loc:-1,row:-1};var N={row:T*1,col:A.cellHandler.columnLabelIndex(P)},S,R,Q={row:T,col:P,use:false};if(K){if(I){if(u){if(N.col&&N.col==K.col-1){Q.col="#REF!";Q.use=true}if(N.row&&N.row==K.row-1){Q.row="#REF!";Q.use=true}if(N.col>=K.col){S=true}if(N.row>=K.row){R=true}}else{if(K.col&&N.col==K.col){Q.col="#REF!";Q.use=true}if(K.row&&N.row==K.row){Q.row="#REF!";Q.use=true}if(K.col&&N.col>K.col){S=true}if(K.row&&N.row>K.row){R=true}}if(Q.use){return Q.col+Q.row}if(S){N.col+=L.col;return A.makeFormula(N)}if(R){N.row+=L.row;return A.makeFormula(N)}}else{if(u){if(K.col&&N.col>=K.col){S=true}if(K.row&&N.row>=K.row){R=true}}else{if(K.col&&N.col>K.col){S=true}if(K.row&&N.row>K.row){R=true}}if(S){N.col+=L.col;return A.makeFormula(N)}if(R){N.row+=L.row;return A.makeFormula(N)}}}else{return A.makeFormula(N,L)}return O})},makeFormula:function(I,u){u=d.extend({row:0,col:0},u);I.col+=u.col;I.row+=u.row;if(I.col<0){I.col=0}if(I.row<0){I.row=0}return A.cellHandler.parseCellName(I.col,I.row)},cycleCells:function(M,P,K,I){I=I||A.i;P=P||{rowIndex:0,col:0};if(!K){var R=A.sheetSize();K={row:R.rows,col:R.cols}}var u=A.spreadsheets[I],L,O,Q,N;for(O=P.col;O<K.col;O++){for(L=P.row;L<K.row;L++){if((Q=u[L])===H){continue}if((N=Q[O])===H){continue}N.rowIndex=L;N.columnIndex=O;M.call(N,I,L,O)}}},cycleCellsAll:function(L){var M=A.i,K,I,u;for(K=0;K<=A.sheetCount;K++){A.i=K;I=A.sheetSize();u={row:I.rows,col:I.cols};A.cycleCells(L,{row:0,col:0},u,K)}A.i=M},cycleCellArea:function(O,u){var N,M,Q,P,L=A.i,K={cell:[],td:[]},I=A.spreadsheets[L];for(N=u.startRowIndex;N<=u.endRowIndex;N++){if((Q=I[N])===H){continue}for(M=u.startColumnIndex;M<=u.endColumnIndex;M++){if((P=Q[M])===H){continue}K.cell.push(P);K.td.push(P.td)}}if(O){O(K)}},theme:null,highlighter:null,resizable:function(I,u){if(!I.data("resizable")){I.resizable(u)}},busy:[],setBusy:function(u){if(u){A.busy.push(u)}else{A.busy.pop()}if(A.busy.length<1&&A.whenNotBusyStack.length>0){A.whenNotBusyStack.shift()()}},isBusy:function(){return(A.busy.length>0)},whenNotBusyStack:[],whenNotBusy:function(u){if(A.isBusy()){A.whenNotBusyStack.push(u)}else{u()}},draggable:function(I,u){if(!I.data("jSdraggable")){I.data("jSdraggable",true).draggable(u)}},nearest:function(I,u){return d(I).nearest(u)},resizeBar:{top:function(K,u,N){A.obj.barTopControls().remove();var I=k.createElement("div"),M=d(I).addClass(A.cl.barController+" "+A.theme.barResizer).width(K.clientWidth).prependTo(K),L;A.controls.bar.x.controls[A.i]=A.obj.barTopControls().add(M);A.resizableCells(M,{handles:"e",start:function(P,O){A.autoFillerHide();A.setBusy(true);if(N.freezeHandleTop){N.freezeHandleTop.remove()}},resize:function(P,O){K.col.style.width=O.size.width+"px";if(N.inPlaceEdit){N.inPlaceEdit.goToTd()}},stop:function(P,O){A.setBusy(false);if(N.inPlaceEdit){N.inPlaceEdit.goToTd()}A.followMe();A.setDirty(true)},minWidth:32});L=I.children[0];L.style.height=K.clientHeight+"px";L.style.position="absolute"},left:function(R,M,L){A.obj.barLeftControls().remove();var u=R.getBoundingClientRect(),N=u.top+k.body.scrollTop,O=u.left+k.body.scrollLeft,S=k.createElement("div"),Q=d(S).addClass(A.cl.barController+" "+A.theme.barResizer).prependTo(R).offset({top:N,left:O}),T=R.parentNode,K=k.createElement("div"),I=d(K).addClass(A.cl.barControllerChild).height(R.clientHeight).prependTo(Q),P;A.controls.bar.y.controls[A.i]=A.obj.barLeftControls().add(Q);A.resizableCells(I,{handles:"s",start:function(){A.autoFillerHide();A.setBusy(true);if(L.freezeHandleLeft){L.freezeHandleLeft.remove()}},resize:function(V,U){S.style.height=R.style.height=T.style.height=U.size.height+"px";if(L.inPlaceEdit){L.inPlaceEdit.goToTd()}},stop:function(V,U){A.setBusy(false);if(L.inPlaceEdit){L.inPlaceEdit.goToTd()}A.followMe();A.setDirty(true)},minHeight:15});P=K.children[0];P.style.width=R.offsetWidth+"px";P.style.position="absolute"},corner:function(){}},labelUpdate:function(u){if(u instanceof j.Cell){var I=A.cellHandler.parseCellName(u.columnIndex,u.rowIndex);A.obj.label().text(I)}else{A.obj.label().text(u)}},cellEdit:function(M,L,K){A.autoFillerNotGroup=true;A.evt.cellEditDone();if(M===null){return}var u=M.jSCell,I;if(u===H||u===null){return}if(u.uneditable){return}A.trigger("sheetCellEdit",[u]);if(A.cellLast!==null&&M!==A.cellLast.td){A.followMe(M)}else{A.autoFillerGoToTd(M)}A.labelUpdate(u);if(u.formula.length>0){I="="+u.formula}else{I=u.value}A.obj.formula().val(I).blur();A.cellSetActive(u,L,false,null,K)},cellSetActive:function(S,I,T,N,K){var M=S.td;A.cellLast=S;A.rowLast=S.rowIndex;A.colLast=S.columnIndex;if(!K){A.highlighter.set(S.td).setStart(S).setEnd(S)}A.highlighter.setBar("left",M.parentNode.children[0]).setBar("top",M.parentNode.parentNode.children[0].children[M.cellIndex]);var P,U;switch(J.cellSelectModel){case j.excelSelectModel:case j.googleDriveSelectModel:P=function(){};U=function(){};break;case j.openOfficeSelectModel:P=function(V){if(A.isCell(V)){A.cellEdit(V)}};U=function(){};break}if(I){var L=A.obj.pane(),R=A.highlighter,u={startRowIndex:S.rowIndex,startColumnIndex:S.columnIndex,endRowIndex:0,endColumnIndex:0},O=S.rowIndex,Q=S.columnIndex;L.onmousemove=function(ad){ad=ad||f.event;var ae=ad.target||ad.srcElement;if(A.isBusy()){return false}if(ae.jSCell===H){return false}var V=ae.jSCell,af=true;u.endColumnIndex=V.columnIndex;u.endRowIndex=V.rowIndex;if(T){af=(S.columnIndex===V.columnIndex||S.rowIndex===V.rowIndex)}if((Q!==V.columnIndex||O!==V.rowIndex)&&af){P(ae);A.cycleCellArea(function(ag){R.set(ag.td)},A.orderedGrid(u))}A.followMe(ae);var Y=ad.clientY,Z=ad.clientX,aa=L.$enclosure.offset(),ab=V.rowIndex,X=V.columnIndex,W=false,ac;if(v(ab)||v(X)){return false}if(Y>aa.top){W=true;ab--}if(Z>aa.left){W=true;X--}if(W){if(ab<1||X<1){return false}ac=A.spreadsheets[A.i][ab][X];A.followMe(ac.td,true)}Q=V.columnIndex;O=V.rowIndex;return true};k.onmouseup=function(){L.onmousemove=null;L.onmousemove=null;L.onmouseup=null;k.onmouseup=null;if(N){N()}}}},colLast:0,rowLast:0,cellLast:null,orderedGrid:function(u){var I={startRowIndex:(u.startRowIndex<u.endRowIndex?u.startRowIndex:u.endRowIndex),startColumnIndex:(u.startColumnIndex<u.endColumnIndex?u.startColumnIndex:u.endColumnIndex),endRowIndex:(u.endRowIndex>u.startRowIndex?u.endRowIndex:u.startRowIndex),endColumnIndex:(u.endColumnIndex>u.startColumnIndex?u.endColumnIndex:u.startColumnIndex)};return I},cellStyleToggle:function(O,N,L){L=L||A.highlighted();if(L.length<1){return false}A.setDirty(true);var P,M,K=L.length-1,u=A.obj.cellsEdited(),I;if(K>=0){I=L[0].className.match(O);do{P=L[K];M=d(P);if(N){M.removeClass(N)}if(I){M.removeClass(O)}else{M.addClass(O)}if(!P.jSCell.edited){P.jSCell.edited=true;u.push(P.jSCell)}}while(K--);return true}return false},cellTypeToggle:function(M,K){K=K||A.highlighted(true);if(K.length<1){return}var L=K.length-1,I=K[L].cellType==M,u;if(L>=0){do{u=K[L];if(I){u.cellType=null}else{u.cellType=M}u.updateValue()}while(L--)}},fontReSize:function(N,M){M=M||A.highlighted();if(M.length<1){return false}var I=0;switch(N){case"up":I=1;break;case"down":I=-1;break}var P,O,L=M.length-1,K,u=A.obj.cellsEdited();if(L>=0){do{P=M[L];O=d(P);K=(O.css("font-size")+"").replace("px","")*1;O.css("font-size",((K||10)+I)+"px");if(!P.jSCell.edited){P.jSCell.edited=true;u.push(P.jSCell)}}while(L--);return true}return false},cellHandler:null,calc:function(K,L){K=(K===H?A.i:K);if(A.readOnly[K]||A.isChanged(K)===false&&!L){return false}var I=J.loader,u;I.cycleCells(K,function(M,O,N){u=I.jitCell(M,O,N);u.updateValue()});A.trigger("sheetCalculation",[{which:"spreadsheet",index:K}]);A.setChanged(false);return true},calcAll:function(K){var I=0,u;u=J.loader.count;for(;I<u;I++){A.calc(I,K)}},resolveCell:function(u,I){var K=!u.needsUpdated;if(!I){A.undo.createCells([u],function(L){A.trigger("sheetPreCalculation",[{which:"cell",cell:u}]);A.setDirty(true);A.setChanged(true);u.updateValue(function(){A.trigger("sheetCalculation",[{which:"cell",cell:u}]);if(K){u.updateDependencies()}});return L})}else{A.trigger("sheetPreCalculation",[{which:"cell",cell:u}]);A.setDirty(true);A.setChanged(true);u.updateValue(function(){A.trigger("sheetCalculation",[{which:"cell",cell:u}]);if(K){u.updateDependencies()}})}},addSheet:function(){A.evt.cellEditAbandon();A.setDirty(true);J.loader.addSpreadsheet(null,A.sheetCount);A.controlFactory.sheetUI(A.obj.ui,A.sheetCount);A.setActiveSheet(A.sheetCount);A.sheetCount++;A.sheetSyncSize();var u=A.obj.pane();if(u.inPlaceEdit){u.inPlaceEdit.goToTd()}A.trigger("sheetAdd",[A.i])},insertSheet:null,deleteSheet:function(I){var M=I||A.i,L=A.controls.enclosure,u;L.splice(M,1);A.obj.barHelper().remove();d(A.obj.enclosure()).remove();A.obj.menus().remove();A.obj.tabContainer().children().eq(A.i).remove();A.spreadsheets.splice(M,1);A.controls.autoFiller.splice(M,1);A.controls.bar.helper.splice(M,1);A.controls.bar.corner.splice(M,1);A.controls.bar.x.controls.splice(M,1);A.controls.bar.x.handleFreeze.splice(M,1);A.controls.bar.x.controls.splice(M,1);A.controls.bar.x.menu.splice(M,1);if(A.controls.bar.x.menuParent&&A.controls.bar.x.menuParent[M]){A.controls.bar.x.menuParent.splice(M,1)}A.controls.bar.x.parent.splice(M,1);A.controls.bar.x.th.splice(M,1);A.controls.bar.y.controls.splice(M,1);A.controls.bar.y.handleFreeze.splice(M,1);A.controls.bar.y.controls.splice(M,1);A.controls.bar.y.menu.splice(M,1);if(A.controls.bar.y.menuParent&&A.controls.bar.y.menuParent[M]){A.controls.bar.y.menuParent.splice(M,1)}A.controls.bar.y.parent.splice(M,1);A.controls.bar.y.th.splice(M,1);A.controls.barMenuLeft.splice(M,1);A.controls.barMenuTop.splice(M,1);A.controls.barLeft.splice(M,1);A.controls.barTop.splice(M,1);A.controls.barTopParent.splice(M,1);A.controls.chart.splice(M,1);A.controls.tdMenu.splice(M,1);A.controls.enclosure.splice(M,1);A.controls.fullScreen=null;A.controls.inPlaceEdit.splice(M,1);A.controls.menus.splice(M,1);A.controls.menu.splice(M,1);A.controls.pane.splice(M,1);A.controls.tables.splice(M,1);A.controls.table.splice(M,1);for(u=M+1;u<A.controls.tab.length;++u){var K=A.controls.tab[u].get(0);K.i--}A.controls.tab.splice(M,1);A.controls.toggleHide.x.splice(M,1);A.controls.toggleHide.y.splice(M,1);A.readOnly.splice(M,1);A.i=0;A.sheetCount--;A.sheetCount=C.max(A.sheetCount,0);if(A.sheetCount==0){A.addSheet()}A.setActiveSheet(A.i);A.setDirty(true);A.setChanged(true);A.trigger("sheetDelete",[M])},deleteRow:function(O){O=O||A.rowLast;var N=A.obj.pane(),M=A.spreadsheets[A.i].splice(O,1)[0],K=0,I,L=M.length,u=J.loader;A.setChanged(true);A.offsetFormulas({row:O,col:0},{row:-1,col:0},false,true);u.deleteRow(A.i,O);for(;K<L;K++){I=M[K];I.setNeedsUpdated(false);I.updateDependencies()}A.setDirty(true);A.evt.cellEditAbandon();if(N.inPlaceEdit){N.inPlaceEdit.goToTd()}A.trigger("sheetDeleteRow",O)},deleteColumn:function(K){K=K||A.colLast;var O=A.obj.pane(),N=0,I,M=A.spreadsheets[A.i],u=J.loader,L=u.size(A.i);A.setChanged(true);A.offsetFormulas({row:0,col:K},{row:-1,col:0},false,true);u.deleteColumn(A.i,K);for(;N<L;N++){I=M[N].splice(K,1)[0];I.setNeedsUpdated(false);I.updateDependencies()}A.setDirty(true);A.evt.cellEditAbandon();if(O.inPlaceEdit){O.inPlaceEdit.goToTd()}A.trigger("sheetDeleteColumn",K)},sheetTab:function(I,K){var u="";if(I){u=J.loader.title(A.i)||A.msg.sheetTitleDefault.replace(/[{]index[}]/gi,A.i+1);if(K){K(u)}return u}else{if(A.isSheetEditable()&&J.editableNames){J.prompt(A.msg.newSheetTitle,function(L){if(!L){u=J.loader.title(A.i);L=(u?u:A.msg.sheetTitleDefault.replace(/[{]index[}]/gi,A.i+1))}else{A.setDirty(true);A.obj.table().attr("title",L);A.obj.tab().html(L);u=L}if(K){K(d(k.createElement("div")).text(u).html())}},A.sheetTab(true));return null}}},followMe:function(L,u){L=L||A.obj.tdActive();if(L===null){return}var K=A.obj.pane(),I=K.actionUI;A.setBusy(true);A.setBusy(false);if(!u){A.autoFillerGoToTd(L)}},autoFillerGoToTd:function(L,I,u){if(!J.autoFiller){return}if(L===H&&A.cellLast!==null){L=A.cellLast.td}if(L&&L.type=="cell"){I=I||L.clientHeight;u=u||L.clientWidth;if(!L.offsetHeight||!L.offsetWidth||!L.clientHeight||!L.clientWidth){A.autoFillerHide();return}var K=d(L).position();A.autoFillerShow(((K.top+(I||L.clientHeight)-3)+"px"),((K.left+(u||L.clientWidth)-3)+"px"))}},autoFillerHide:function(){if(!J.autoFiller){return}var I=A.obj.autoFiller(),u=I.parentNode;if(u!==null){u.removeChild(I)}},autoFillerShow:function(M,L){if(!J.autoFiller){return}var K=A.obj.autoFiller(),I=A.obj.pane(),u=K.style;u.top=M;u.left=L;I.insertBefore(K,I.firstChild)},setActiveSheet:function(L,I){if(I!==H){L=I.i}else{L=L||0}if(A.cellLast!==null&&(A.cellLast.rowIndex>0||A.cellLast.columnIndex>0)){A.evt.cellEditDone();A.obj.formula().val("")}var M=A.obj.panes(),K=0,u=M.length,O,N;A.autoFillerHide();for(;K<u;K++){if(L!=K){O=M[K];O.actionUI.hide()}}A.i=L;N=A.obj.enclosure();A.highlighter.setTab(A.obj.tab());O=N.pane;O.actionUI.show();if(O.inPlaceEdit){O.inPlaceEdit.goToTd()}},getSpreadsheetIndexByTitle:function(I){var u=J.loader.getSpreadsheetIndexByTitle(I);return u},getSpreadsheetTitleByIndex:function(u){return J.loader.json[u].title},openSheet:function(u){var K=u.count,L=K-1,I=function(){A.setBusy(true);A.s.loader=u;var S=A.controlFactory.header(),R=A.controlFactory.ui(),M=A.controlFactory.sheetAdder(),O=A.controlFactory.tabContainer(),Q,P={initChildren:function(U,T){A.controlFactory.sheetUI(U,T);A.trigger("sheetOpened",[T])},done:function(T){A.sheetSyncSize();A.setActiveSheet(0);A.setDirty(false);A.setBusy(false);A.trigger("sheetAllOpened")},lastIndex:L},N;S.ui=R;S.tabContainer=O;R.header=S;R.sheetAdder=M;R.tabContainer=O;O.header=S;O.ui=R;J.parent.append(S).append(R).append(M).append(O);A.resizableSheet(J.parent,{minWidth:J.parent.width()*0.1,minHeight:J.parent.height()*0.1,start:function(){A.setBusy(true);A.obj.ui.removeChild(A.obj.enclosure());R.sheetAdder.hide();R.tabContainer.hide()},stop:function(){A.obj.ui.appendChild(A.obj.enclosure());R.sheetAdder.show();R.tabContainer.show();A.setBusy(false);A.sheetSyncSize();var T=A.obj.pane();if(T.inPlaceEdit){T.inPlaceEdit.goToTd()}}});A.insertSheet=function(W,T,V){A.sheetCount++;W=W||null;V=V!==H?V:true;T=T||A.sheetCount-1;if(W!==null){J.loader.addSpreadsheet(W)}var X=function(){A.setBusy(true);var Y=new j.SpreadsheetUI(T,R,P);A.setActiveSheet(-1,Y);A.setBusy(false);A.sheetSyncSize()},U;if(V){X();return}U=A.controlFactory.customTab(u.title(T)).mousedown(function(){X();A.obj.tab().insertBefore(this);d(this).remove();return false});if(J.loader.isHidden(T)){U.hide()}};N=new j.SpreadsheetUI(0,R,P);A.sheetCount++;if(K>0){for(Q=1;Q<K;Q++){A.insertSheet(null,Q,false)}A.i=0;N.loaded()}};if(A.isDirty){J.confirm(A.msg.openSheet,I)}else{I()}},newSheet:function(){J.parent.html(d.sheet.makeTable()).sheet(J)},sheetSyncSize:function(){var S=J.parent,O=S[0],U=O.clientHeight,P=O.clientWidth,T=A.obj.tabContainer(),V=T[0],u=V.style,Y=f.scrollBarSize.width,I,X,R,Q,M=A.obj.ui.style,N,Z,L,W,K;if(!U){U=400;S.height(U)}else{if(U<200){U=200;S.height(U)}}K=V.scrollLeft;u.width="";I=V.clientWidth;X=(P-(J.colMargin+Y));R=(P-J.colMargin*2)+"px";Q=((J.colMargin+Y)+"px");if(I>X){u.height=Q;T.addClass(A.cl.tabContainerScrollable);U-=Y}else{u.height=null;T.removeClass(A.cl.tabContainerScrollable)}u.width=R;V.scrollLeft=K;U-=A.obj.header().outerHeight()+J.boxModelCorrection;U-=V.clientHeight+J.boxModelCorrection;N=(U-f.scrollBarSize.height-J.boxModelCorrection)+"px";Z=(P-f.scrollBarSize.width)+"px";L=(U+"px");W=(P+"px");A.obj.panes().each(function(){var ac=this.style,ab=this.scroll.style,aa=this.enclosure.style;ac.height=N;ac.width=Z;aa.height=ab.height=L;aa.width=ab.width=W});M.height=L;M.width=W},showSheets:function(){A.obj.tabContainer().children().each(function(u){d(this).show();J.loader.setHidden(u,false)})},showSheet:function(u){A.obj.tabContainer().children().eq(u).show();J.loader.setHidden(u,false)},hideSheet:function(u){A.obj.tabContainer().children().eq(u).hide();J.loader.setHidden(u,true)},cellChangeStyle:function(K,L,u){u=u||A.highlighted(true);if(u.length<1){return false}A.setDirty(this);var I=u.length-1;if(I>=0){A.undo.createCells(u,function(M){do{M[I].td.css(K,L)}while(I--);return M});return true}return false},cellFind:function(u){function I(L){var K=A.obj.table().children("tbody").children("tr");if(L){var M=K.children('td:contains("'+L+'")');if(M.length<1){M=K.children('td:contains("'+L.toLowerCase()+'")')}if(M.length<1){M=K.children('td:contains("'+L.toUpperCase()+'")')}M=M.eq(0);if(M.length>0){A.cellEdit(M)}else{J.alert(A.msg.cellNoFind)}}}if(!u){J.prompt(A.msg.cellFind,I)}else{I(u)}},cellSetActiveBar:function(Q,I,L){var X=J.loader.size(),U,N,u={},S={},T,W=function(Y){switch(J.cellSelectModel){case j.openOfficeSelectModel:this.row=Y.startRowIndex;this.col=Y.startColumnIndex;this.td=A.getTd(-1,this.row,this.col);if(this.td!==null&&(A.cellLast!==null&&this.td!==A.cellLast.td)){A.cellEdit(this.td,false,true)}break;default:this.row=Y.endRowIndex;this.col=Y.endColumnIndex;this.td=A.getTd(-1,this.row,this.col);if(this.td!==null&&(A.cellLast!==null&&this.td!==A.cellLast.td)){A.cellEdit(this.td,false,true)}break}},M=[],P=A.obj.pane().actionUI.scrolledArea,O,V,K,R=A.highlighter;switch(Q){case"top":u.row=P.row;S.row=P.row;if(I<L){R.startColumnIndex=O=U=u.col=I;R.endColumnIndex=N=S.col=L}else{T=true;R.startColumnIndex=O=U=u.col=L;R.endColumnIndex=N=S.col=I}R.startRowIndex=0;R.endRowIndex=X.rows;M.push(I);for(;O<N;O++){M.push(M[M.length-1].nextSibling)}break;case"left":u.row=first;u.col=P.col;S.row=last;S.col=P.col;R.startRowIndex=first;R.startColumnIndex=0;R.endRowIndex=last;R.endColumnIndex=X.cols;V=last;do{K=A.getTd(-1,V,0);if(K===null){continue}M.push(K.parentNode)}while(V-->first);break;case"corner":u.row=0;u.col=0;S.col=X.cols;S.row=X.rows;M.push(sheet[0]);break}new W(R);A.highlighter.set(M)},getTdRange:function(L,Q,O,P){A.cellLast.isEdit=true;var I=function(S){if(S.first.col>S.last.col||S.first.row>S.last.row){return{first:A.cellHandler.parseCellName(S.last.col,S.last.row),last:A.cellHandler.parseCellName(S.first.col,S.first.row)}}else{return{first:A.cellHandler.parseCellName(S.first.col,S.first.row),last:A.cellHandler.parseCellName(S.last.col,S.last.row)}}},N=function(V){var S=I(V),U=Q+"";U=(U.match(/=/)?U:"="+U);if(O||U.charAt(U.length-1)!="("){U=U+(O?O:"")+"("}var W,T="";if(S.first!=S.last){W=S.first+":"+S.last}else{W=S.first}if(U.charAt(U.length-1)=="("){T=")"}return U+W+T},u="",K,M,R;if(L){K={first:A.getTdLocation([L.target])};M=A.obj.table().mousemove(function(S){K.last=A.getTdLocation([S.target]);u=N(K);if(!P){A.obj.formula().val(u);A.obj.inPlaceEdit().val(u)}});w.one("mouseup",function(){M.unbind("mousemove");return u})}else{R=A.highlighted().not(A.obj.tdActive());if(R.length){K={first:A.getTdLocation(R.first()),last:A.getTdLocation(R.last())};u=N(K);if(!P){A.obj.formula().val(u);A.obj.inPlaceEdit().val(u)}return u}else{return""}}return""},getTd:function(K,I,L){if(K<0){K=A.i}var u=J.loader.jitCell(K,I,L);if(u===null){return u}return u.td||null},getTdLocation:function(L){var u={col:0,row:0},I=0,K=A.obj.pane();if(L===H||L===null){return u}if(L.parentNode===H||(L.parentNode.rowIndex+I)<0){return u}return{col:L.cellIndex,row:L.parentNode.rowIndex+I}},time:{now:new a(),last:new a(),diff:function(){return C.abs(C.ceil(this.last.getTime()-this.now.getTime())/1000).toFixed(5)},set:function(){this.last=this.now;this.now=new a()},get:function(){return this.now.getHours()+":"+this.now.getMinutes()+":"+this.now.getSeconds()}},changed:[],isChanged:function(u){return A.changed[u||A.i]},setChanged:function(u){A.changed[A.i]=u},isDirty:false,setDirty:function(u){A.dirty=u},appendToFormula:function(u){var K=A.obj.formula(),I=K.val();if(I.charAt(0)!="="){I="="+I}K.val(I+u)},undo:{manager:(f.UndoManager?new UndoManager():{undo:E,redo:E,register:E}),cells:[],id:-1,createCells:function(u,I,M){if(M===H){A.undo.id++;M=A.undo.id}var K=(new j.CellRange(u)).clone().cells,L=(I!==H?(new j.CellRange(I(u)).clone()).cells:K);K.id=M;L.id=M;A.undo.manager.add({undo:function(){A.undo.removeCells(K,M)},redo:function(){A.undo.createCells(L,null,M)}});if(M!==A.undo.id){A.undo.draw(L)}return true},removeCells:function(I,L){var K=0,u=-1;if(I.id===L){u=K}if(u!==-1){A.undo.cells.splice(u,1)}A.undo.draw(I)},draw:function(K){var I,N,M,u,L;for(I=0;I<K.length;I++){M=K[I];L=A.getTdLocation(M.td);u=A.spreadsheets[M.sheetIndex][L.row][L.col];u.value=M.value;u.formula=M.formula;N=u.td=M.td;u.dependencies=M.dependencies;u.needsUpdated=M.needsUpdated;u.calcCount=M.calcCount;u.sheetIndex=M.sheetIndex;u.rowIndex=L.row;u.columnIndex=L.col;u.state=M.state;u.jS=M.jS;N.setAttribute("style",M.style);N.setAttribute("class",M.cl);u.setNeedsUpdated();u.updateValue()}}},cols:function(u){u=u||A.obj.table()[0];if(!u){return[]}if(!u.colGroup){return[]}if(!u.colGroup.children){return[]}return u.colGroup.children},tables:function(R,M){R=R||A.obj.tables();var Q=[],K=R.length-1,I,T,P,u,U,L,S,N,O;do{T=(M?k.body.removeChild(R[K]):R[K].cloneNode(true));if((u=T.children[0])&&(U=u.children[0])){u.removeChild(U)}if(P=T.children[1]){N=P.children;S=N[0];P.removeChild(S);I=N.length-1;do{O=N[I];L=O.children[0];O.removeChild(L)}while(I-->0)}Q[K]=T}while(K-->0);return A.sheetDecorateRemove(false,d(Q))},col:function(I,u){I=I||A.obj.table()[0];var K=A.cols(I);if(u===H){u=K.length-1}return K[u]},rowTds:function(I,u){I=I||A.obj.table();var K=A.rows(I);if(!K.length){return[]}if(u==H){u=K.length-1}if(!K[u]){return[]}if(!K[u].children){return[]}return K[u].children},rows:function(u){u=u||A.obj.table()[0];if(u===H){return[]}if(u.tBody===H){return[]}if(u.tBody.children===H){return[]}return u.tBody.children},highlighted:function(I){var L=A.highlighter.last||d([]),M=[],u,K;if(!(u=L)||!L.length||!(u=u[0])||!u.tagName){return I?M:d(M)}switch(u.tagName){case"TD":K=L.length-1;do{M.unshift(I?L[K].jSCell:L[K])}while(K-->0);break;case"TR":K=L.length-1;do{if(L[K].tds){M=M.concat(I?L[K].jSCells:L[K].tds)}}while(K-->0);break;case"COL":L=L.filter("col");K=L.length-1;do{if(L[K].tds){M=M.concat(I?L[K].jSCells:L[K].tds)}}while(K-->0);break;case"TABLE":M=(I?u.jSCells:u.tds);break}return I?M:d(M)},sheetSize:function(u){if(u===undefined){u=A.i}return J.loader.size(u)},sortVerticalSelectAscending:function(){if(confirm("Do you want to extend your selection?")){A.sortVertical();return true}else{A.sortVerticalSingle(false);return true}},sortVerticalSelectDescending:function(){if(confirm("Do you want to extend your selection?")){A.sortVertical();return false}else{A.sortVerticalSingle(true);return false}},sortVertical:function(R){var P=A.highlighted(true),M=P[0].td.parent().prev(),u=P.length,K=new a(),O=true,S=[],U=[],N,Q=0,T,I,L;while(Q<u){T=P[Q];L=T.td;if(!isNaN(T.value)){I=(new r(T.value.valueOf()))}else{O=false;I=(new o(T.value.valueOf()))}I.loc=A.getTdLocation(L);I.row=L.parentNode;I.col=L;I.cell=T;S.push(I);Q++}if(R){if(O==false){S.sort(function(W,V){return V-W})}else{S.sort();S.reverse()}}else{if(O==true){S.sort(function(W,V){return W-V})}else{S.sort()}}A.undo.createCells(P);while(N=S.length){I=S.pop();U=A.spreadsheets[A.i].splice(I.row.rowIndex,1);T=I.cell;T.value=I.valueOf();I.row.parentNode.removeChild(I.row);M.after(I.row);I.row.children[0].innerHTML=M[0].rowIndex+N;A.spreadsheets[A.i].splice(M[0].rowIndex+1,0,U[0]);A.track.call(T,true)}A.undo.createCells(P)},sortVerticalSingle:function(N){var L=A.highlighted(true),M=L.length,K=0,I=[],u;while(K<M){I.push(L[K].value);K++}if(N){I.sort(function(P,O){return O-P})}else{I.sort(function(P,O){return P-O})}while(L.length){u=L.pop();u.value=I[L.length];u.updateValue()}},sortHorizontalSelectAscending:function(){if(confirm("Do you want to extend your selection?")){A.sortHorizontal();return true}else{A.sortHorizontalSingle(false);return true}},sortHorizontalSelectDescending:function(){if(confirm("Do you want to extend your selection?")){A.sortHorizontal();return false}else{A.sortHorizontalSingle(true);return false}},sortHorizontal:function(M){var U=A.highlighted(true),V=A.obj.pane(),Y=V.table,L=U[0].td,K=L.jSCell,u=K.cellIndex,W=Y.colGroup,T=A.sheetSize().rows,N=U.length,S=true,R=[],O,X=0,Q,K,Z,I,P;while(X<N){Q=0;K=U[X];P=K.td;if(!isNaN(K.value)){Z=new r(K.value.valueOf())}else{S=false;Z=new o(K.value.valueOf())}Z.tds=[];Z.loc=A.getTdLocation(P);Z.tr=P.parentNode;Z.td=P;Z.cell=K;while(Q<=T){Z.tds.push(A.obj.pane().table.children[1].children[Q].children[P.cellIndex]);Q++}R.push(Z);X++}if(M){if(S==false){R.sort(function(ab,aa){return aa-ab})}else{R.sort();R.reverse()}}else{if(S==true){R.sort(function(ab,aa){return ab-aa})}else{R.sort()}}A.undo.createCells(U);while(R.length){Z=R.pop();while(Z.tds.length>1){P=Z.tds.pop();I=P.parentNode;K=A.spreadsheets[A.i][I.rowIndex].splice(P.cellIndex,1);I.insertBefore(P,I.children[u]);P.col=W.children[R.length+P.cellIndex-1];P.barTop=P.col.bar;K.value=P.jSCell.value;A.spreadsheets[A.i][I.rowIndex].splice(P.cellIndex,0,K[0]);A.resolveCell(K,true)}}A.undo.createCells(U)},sortHorizontalSingle:function(N){var L=A.highlighted(true),M=L.length,K=0,I=[],u;while(K<M){I.push(L[K].value);K++}if(N){I.sort(function(P,O){return O-P})}else{I.sort(function(P,O){return P-O})}while(L.length){u=L.pop();u.value=I[L.length];u.updateValue()}},tableSize:function(R,O){var Q,K,P,u,M,I=R.pane,S=0,L=0,N=0;R=R||A.obj.table()[0];if((Q=R.tBody)!==H&&(K=Q.children)!==H&&(P=K[K.length-1])!==H&&(u=P.children)!==H&&(M=u[u.length-1])!==H){if(O===true){S=P.rowIndex}else{S=P.rowIndex+N}L=M.cellIndex}else{return{}}return{cols:L,rows:S}},toggleState:function(u){if(J.allowToggleState){var I=u||A.tables();if(J.editable){A.evt.cellEditAbandon();A.trigger("sheetSave",[I])}A.setDirty(false);A.setChanged(true);J.editable=!J.editable;A.kill();J.parent.html(I).sheet(J);J=null}},setCellRef:function(K){function I(M){if(M){A.s.formulaVariables[M]=u.updateValue()}}var L=A.obj.tdActive(),u=L.jSCell;if(K){I(K)}else{J.prompt(A.msg.setCellRef,I)}},parseFormula:null,print:function(u,I){u=u||A.i;var L=f.open(),K;if(L!==H){K=L.document;K.write('<html> <head id="head"></head> <body> <div id="entry" class="'+A.cl.parent+'" style="overflow: show;"> </div> </body></html>');if(I!==true){d(K.getElementById("head")).append(d("style,link").clone())}d(K.getElementById("entry")).append(A.obj.pane().cloneNode(true));K.close();L.focus();L.print()}}},x=[],F;A.setBusy(true);J.parent[0].jS=A;if(!f.console){f.console={log:function(){}}}if(f.scrollBarSize===H){f.scrollBarSize=l()}A.cellHandler=new j.CellHandler(A,j.fn);A.theme=new j.Theme(J.theme);A.highlighter=new j.Highlighter(A.theme.tdHighlighted,A.theme.barHighlight,A.theme.tabActive,function(){});J.origHtml=J.parent.children().detach();J.parent.addClass(A.cl.parent);J.parent.bind("sheetSwitch",function(K,I,u){A.switchSheet(u)}).bind("sheetRename",function(K,I,u){A.renameSheet(u)});J.width=(J.width?J.width:J.parent.width());J.height=(J.height?J.height:J.parent.height());if(!d.nearest){A.nearest=E}A.resizableCells=A.resizableSheet=A.resizable;if(!d.ui){A.resizable=A.resizableCells=A.resizableSheet=A.draggable=E}else{if(!J.resizableCells){A.resizableCells=E}if(!J.resizableSheet){A.resizableSheet=E}}if(!d.support.boxModel){J.boxModelCorrection=0}if(!J.barMenus){A.controlFactory.barMenuTop=A.controlFactory.barMenuLeft=E}if(!J.freezableCells){A.controlFactory.barHandleFreeze.top=A.controlFactory.barHandleFreeze.left=E}if(J.calcOff){A.calc=E}t.resize(function(){if(A&&!A.isBusy()){J.width=J.parent.width();J.height=J.parent.height();A.sheetSyncSize()}}).unload(function(){j.thread.kill()});j.fn=d.extend(j.fn,J.formulaFunctions);if(j.financefn){j.fn=d.extend(j.fn,j.financefn)}J.title=J.title||J.parent.attr("title")||"";A.s=J;A.parseFormula=(J.useMultiThreads?j.parseFormula:j.parseFormulaSlow);J.parent.addClass(A.theme.parent);if(J.loader===null){J.loader=(new j.Loader.HTML(J.origHtml))}J.loader.bindJS(A).bindHandler(A.cellHandler);A.openSheet(J.loader);A.setBusy(false);return A},makeTable:function(F,v,t){var D=k;F=F||{rows:25,cols:10};v=v||120;t=t||15;var E=k.createElement("table"),u=k.createElement("colgroup"),C=k.createElement("tbody"),z="width:"+v+"px;",x="height:"+t+"px;",B,w,A,y;A=F.cols;do{w=k.createElement("col");w.setAttribute("style",z);u.appendChild(w)}while(A-->1);A=F.rows;do{B=k.createElement("tr");B.setAttribute("style",x);y=F.cols;do{B.appendChild(k.createElement("td"))}while(y-->1);C.appendChild(B)}while(A-->1);E.appendChild(u);E.appendChild(C);return E},killAll:function(){if(d.sheet){var t=d.sheet.instance;if(t){for(var u=0;u<t.length;u++){if(t[u]&&t[u].kill){t[u].kill()}}d.sheet.instance=[]}}},scrollLocker:function(u){var t=d.sheet.instance;t[u].obj.panes().each(function(v){var w;d(w=this.scrollUI).scroll(function(y){var x=t.length-1,z;if(x>-1){do{z=t[x].controls.enclosures[v].scrollUI;if(this!==z){z.scrollLeft=w.scrollLeft;z.scrollTop=w.scrollTop}}while(x--)}})})},switchSheetLocker:function(t){d.each(d.sheet.instance,function(){this.s.parent.bind("sheetSwitch",function(w,v,u){d.each(d.sheet.instance,function(){this.setActiveSheet(u)})})})},I:function(){var t=0;if(this.instance){t=(this.instance.length===0?0:this.instance.length-1)}else{this.instance=[]}return t}};j.thread=(function(u){var v=0,w=[];function t(){var y=w[v],x=t.limit;if(y===undefined){y=w[v]=t.create()}else{y=w[v]}v++;if(v>x){v=0}return y}t.limit=10;t.create=function(){var x=u({parseFormula:function(y){formulaParser.yy.types=[];return formulaParser.parse(y)},streamJSONSheet:function(y,z,A){Promise.all([gR(y+z)]).then(function(G){var E=G[0],D=JSON.parse(E),F,B,C=0;if(D.pop!==undefined){D=D[0]}F=D.rows;B=F.length;D.rows=[];A("sheet",JSON.stringify(D));for(;C<B;C++){A("row",JSON.stringify(F[C]))}A()},function(B){A("error",B)})},streamJSONRows:function(z,C,D){var B=0,y=C.length,A=[];if(typeof C==="string"){A.push(gR(z+C))}else{for(;B<y;B++){A.push(gR(z+C[B]))}}Promise.all(A).then(function(J){var G=0,F,L,I,H=J,E=H.length,K;for(;G<E;G++){I=JSON.parse(H[G]);K=I.length;for(F=0;F<K;F++){L=I[F];D("row",JSON.stringify(L))}}D()},function(E){D("error",E)})},streamJSONSheetRows:function(A,z,B,E){var D=0,y=B.length,C=[gR(A+z)];if(typeof B==="string"){C.push(gR(A+B))}else{for(;D<y;D++){C.push(gR(A+B[D]))}}Promise.all(C).then(function(K){E("sheet",K[0]);var H=1,G,M,J,I=K,F=I.length,L;for(;H<F;H++){J=JSON.parse(I[H]);L=J.length;for(G=0;G<L;G++){M=J[G];E("row",JSON.stringify(M))}}E()},function(F){E("error",F)})}},[j.formulaParserUrl,j.threadScopeUrl]);x.stash=[];x.busy=false;return x};t.kill=function(){var y=0,x=w.length;for(;y<x;y++){w[y].terminate()}};return t})(f.operative);var q={BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,ALT:18,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,C:67,F:70,V:86,X:88,Y:89,Z:90,UNKNOWN:229},c=f.arrHelpers={math:g,toNumbers:function(t){t=this.flatten(t);var u=t.length-1;if(u<0){return[]}do{if(t[u]){t[u]=d.trim(t[u]);if(isNaN(t[u])){t[u]=0}else{t[u]=t[u]*1}}else{t[u]=0}}while(u--);return t},unique:function(t){var x={},v,u=t.length,w=[];for(v=0;v<u;v+=1){x[t[v]]=t[v]}for(v in x){w.push(x[v])}return w},flatten:function(u){var x=[],w,v=0,t=u.length;for(;v<t;v++){w=u[v];if(w instanceof Array){x=x.concat(this.flatten(w))}else{x=x.concat(w)}}return x},insertAt:function(t,v,u){d(v).each(function(){if(u>-1&&u<=t.length){t.splice(u,0,this)}});return t},indexOfNearestLessThan:function(z,y){if(z.length===0){return -1}var w=z.length-1,t=0,u,v,x=-1;if(z[w]<y){return w}while(t<=w){u=(t+w)>>1;v=z[u];if(v>y){w=u-1}else{if(v<y){x=u;t=u+1}else{x=t;break}}}return x},ofSet:function(C,w){if(C.length===0){return null}var u=C.length-1,z=u,v=C[u],A=C[0],D=0,E,F,B=-1,y,x=-1,t=-1;if(C[u]<w||C[0]>w){return null}else{while(D<=u){E=(D+u)>>1;F=C[E];if(F>w){B=E;u=E-1}else{if(F<w){D=E+1}else{B=u;break}}}}if(B>-1){y=B;while(y<=z){if(C[y]+1===C[y+1]){y++}else{x=C[y];break}}if(x===-1){x=v}y=B;while(y>=0){if(C[y]-1===C[y-1]){y--}else{t=C[y];break}}if(t===-1){t=A}}return{start:t,end:x}},closest:function(y,u,v,t){v=v||0;t=t||y.length-1;var x,w;while(true){x=((v+t)>>1);w=y[x];if((x===t||x===v)&&w!==u){return w}if(w>u){t=x}else{if(w<u){v=x}else{return w}}}},getClosestNum:function(v,t,x){var w=0,u,A,z,y;if(t.length){A=t[0];u=w;for(w;w<t.length;w++){z=g.abs(v-A);y=g.abs(v-t[w]);if(y<z){u=w;A=t[w]}z=null;y=null}if(x){return x(A,u)}return A}return false},levenshtein:(function(){var t=[];return function(D,C){if(D===C){return 0}else{var A=D.length,y=C.length;if(A&&y){var v=0,u=0,B,z,x,w,E=t;while(v<A){E[v]=++v}while(u<y){w=C.charCodeAt(u);B=u;++u;z=u;for(v=0;v<A;++v){x=B+(D.charCodeAt(v)===w?0:1);B=E[v];z=z<B?(z<x?z+1:x):(B<x?B+1:x);E[v]=z}}return z}else{return A+y}}}})(),lSearch:function(u,y){var v=0,w,t=u.length,x=-1,z;for(;v<t;v++){w=u[v];z=new r(this.levenshtein(w,y));z.item=w;if(z<x){x=z}}return(z!==undefined?z.item:null)}},e={dayDiv:86400000,math:g,toCentury:function(t,u){u=u||86400000;return this.math.round(this.math.abs((new a(1900,0,-1))-t)/u)},get:function(u,v){v=v||86400000;if(u.getMonth){return u}else{if(isNaN(u)){return new a(Globalize.parseDate(u))}else{u*=v;var t=(new a(1900,0,-1))*1;u+=t;u=new a(u);return u}}},week:function(t,v){v=v||86400000;var u=new a(t.getFullYear(),0,1);return this.math.ceil((((t-u)/v)+u.getDay()+1)/7)},toString:function(t,u){if(!u){return Globalize.format(t)}return Globalize.format(t,Globalize.culture().calendar.patterns[u])},diff:function(x,u,w,v){v=v||86400000;switch(w){case 0:return this.days360Nasd(x,u,0,true);case 1:case 2:case 3:var t=this.math.abs(u-x)/v;return t;case 4:return this.days360Euro(x,u)}return 0},diffMonths:function(v,u){var t;t=(u.getFullYear()-v.getFullYear())*12;t-=v.getMonth()+1;t+=u.getMonth()+1;return t},days360:function(v,y,w,u,t,x){return((y-v)*360)+((u-w)*30)+(x-t)},days360Nasd:function(u,x,t,v){var w=u.getDate(),B=u.getMonth(),A=u.getFullYear(),z=x.getDate(),y=x.getMonth(),C=x.getFullYear();if((y==2&&this.isEndOfMonth(z,y,C))&&((B==2&&this.isEndOfMonth(w,B,A))||t==3)){z=30}if(z==31&&(w>=30||t==3)){z=30}if(w==31){w=30}if(v&&B==2&&this.isEndOfMonth(w,B,A)){w=30}return this.days360(A,C,B,y,w,z)},days360Euro:function(A,v){var t=A.getDate(),x=A.getMonth(),w=A.getFullYear(),y=v.getDate(),u=v.getMonth(),z=v.getFullYear();if(t==31){t=30}if(y==31){y=30}return this.days360(w,z,x,u,t,y)},isEndOfMonth:function(t,v,u){return t==(new a(u,v+1,0,23,59,59)).getDate()},isLeapYear:function(t){return new a(t,1,29).getMonth()==1},calcAnnualBasis:function(t,v,z){switch(z){case 0:case 2:case 4:return 360;case 3:return 365;case 1:var u=t.getDate(),B=t.getMonth(),y=t.getFullYear(),w=v.getDate(),x=v.getMonth(),C=v.getFullYear(),D=0;if(y==C){if(this.isLeapYear(y)){D=366}else{D=365}}else{if(((C-1)==y)&&((B>x)||((B==x)&&u>=w))){if(this.isLeapYear(y)){if(B<2||(B==2&&u<=29)){D=366}else{D=365}}else{if(this.isLeapYear(C)){if(x>2||(x==2&&w==29)){D=366}else{D=365}}else{D=365}}}else{for(var A=y;A<=C;A++){if(this.isLeapYear(A)){D+=366}else{D+=365}}D=D/(C-y+1)}}return D}return 0},lastDayOfMonth:function(t){t.setDate(0);return t.getDate()},isLastDayOfMonth:function(t){return(t.getDate()==this.lastDayOfMonth(t))}},h=f.times={math:g,fromMath:function(v){var t={},u=this;t.hour=((v*24)+"").split(".")[0]*1;t.minute=function(w){w=u.math.round(w*24*100)/100;w=(w+"").split(".");var x=0;if(w[1]){if(w[1].length<2){w[1]+="0"}x=w[1]*0.6}return u.math.round(x)}(v);t.second=function(z){z=u.math.round(z*24*10000)/10000;z=(z+"").split(".");var x=0;if(z[1]){for(var y=0;y<4;y++){if(!z[1].charAt(y)){z[1]+="0"}}var w=((z[1]*0.006)+"").split(".");if(w[1]){if(w[1]&&w[1].length>2){w[1]=w[1].substr(0,2)}return u.math.round(w[1]*0.6)}}return x}(v);return t},fromString:function(v,z){var w=new a(),A=v,t,y,x,u,B;if(z){B=A.substr(-2).toLowerCase();A=A.replace(/(am|pm)/i,"")}A=A.split(":");y=A[0]*1;x=A[1]*1;u=(A[2]?A[2]:0)*1;if(z&&B=="pm"){y+=12}return jFN.TIME(y,x,u)}};d.extend(g,{log10:function(t){return g.log(t)/2.302585092994046},signum:function(t){return(t/g.abs(t))||t},log1p:function(t){var u=0,w=50;if(t<=-1){return"-INF"}if(t<0||t>1){return g.log(1+t)}for(var v=1;v<w;v++){if((v%2)===0){u-=g.pow(t,v)/v}else{u+=g.pow(t,v)/v}}return u}});function m(u,v){var t;for(t in v){if(v.hasOwnProperty(t)){u[t]=v[t]}}return u}function l(){var z=k,C=d(k.createElement("p")).css({width:"100%",height:"100%"}),B=d(k.createElement("div")).css({position:"absolute",width:"100px",height:"100px",top:"0",left:"0",visibility:"hidden",overflow:"hidden"}).append(C);d(k.body).append(B);var v=C.width(),y=C.height();B.css("overflow","scroll");var t=C.width(),x=C.height();if(v==t&&B[0].clientWidth){t=B[0].clientWidth}if(y==x&&B[0].clientHeight){x=B[0].clientHeight}B.detach();var A=v-t,u=y-x;return{width:A||15,height:u||15}}function i(){var t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",v=d(k.createElement("span")).html(t).appendTo("body"),u={width:v.width()/t.length,height:v.height()};v.remove();return u}function n(t,A,v,u,z){u=u||"#"+g.floor(g.random()*16777215).toString(16);if(v){var w=d([]);w=w.add(n(v.left,v.top,null,u,"top-left"));w=w.add(n(v.right,v.top,null,u,"top-right"));w=w.add(n(v.left,v.bottom,null,u,"bottom-left"));w=w.add(n(v.right,v.bottom,null,u,"bottom-right"));return w}return d('<div style="width: 10px; height: 10px; position: absolute;"></div>').css("top",(A-5)+"px").css("left",(t+5)+"px").css("background-color",u).click(function(){console.log(z||"none")}).appendTo("body")}d.printSource=function(u){var t=win.open();t.document.write("<html><body><xmp>"+u+"\n</xmp></body></html>");t.document.close()};j.Loader.HTML=(function(v,t,u){function w(x){if(x!==undefined){this.tables=x;this.count=x.length}else{this.tables=[];this.count=0}this.cellIds={};this.jS=null;this.handler=null}w.prototype={bindJS:function(x){this.jS=x;return this},bindHandler:function(x){this.handler=x;return this},bindActionUI:function(y,x){x.loadedFrom=this.tables[y]},size:function(B){var z={cols:0,rows:0},y=this.tables,A,C,D,x;if((A=y[B])===undefined){return z}if((C=A.querySelectorAll("tr"))===undefined){return z}if((D=C[0])===undefined){return z}if((x=D.children)===undefined){return z}return{rows:C.length,cols:x.length}},getWidth:function(x,B){var z=this.tables,C=z[x],y,A;y=C.querySelectorAll("col");if(y.length>B){A=y[B].style.width.replace("px","")||j.defaultColumnWidth;return A*1}return j.defaultColumnWidth},getHeight:function(y,D){var z=this.tables,A=z[y],B,C,x;B=A.querySelectorAll("tr");if(B.length>D){C=B[D];x=C.style.height.replace("px","")||j.defaultRowHeight;return x*1}return j.defaultRowHeight},isHidden:function(x){var y=this.tables,z=y[x];return z.style.display==="none"},setHidden:function(x,z){var y=this.tables,A=y[x];if(z){A.style.display="none"}else{A.style.display=""}return this},addRow:function(D,A,C){var E=this.tables[D],z=0,H=this.size(D),x=H.cols,y=H.rows,G,F=t.createElement("tr"),B;if(E===undefined){return this}B=E.querySelector("tBody");G=B.children;for(;z<x;z++){F.appendChild(C[z].loadedFrom=t.createElement("td"))}if(A===undefined){B.appendChild(F)}else{if(A<y){B.insertBefore(F,G[A+1])}}return this},addColumn:function(E,A,D){var F=this.tables[E],B=0,I,H,z,G=this.size(E),x=G.rows,y=G.cols,C;if(F===undefined){return this}C=F.querySelector("tBody");I=C.children;if(A===undefined){for(;B<x;B++){H=I[B];z=t.createElement("td");D[B].loadedFrom=z;H.append(z)}}else{if(A<y){for(;B<x;B++){H=I[B];z=t.createElement("td");D[B].loadedFrom=z;H.insertBefore(z,H.children[A+1])}}}return this},deleteRow:function(y,D){var A=this.tables[y],B,C,z,x;if(A===undefined){return this}x=A.querySelector("tBody");B=x.children;if(B.length>D){x.removeChild(B[D])}if(A.hasAttribute("data-hiddenrows")(C=A.getAttribute("data-hiddenrows").split(","))&&(z=C.indexOf(D))>-1){C.splice(z,1);A.setAttribute("data-hiddenrows",C.join(","))}return this},deleteColumn:function(E,A){var F=this.tables[E],H,G,y,C=0,x,B,z,D;if(F===undefined){return this}D=F.querySelector("tBody");H=D.children;x=H.length;for(;C<x;C++){G=H[C];y=G.children;if(A.length>A){G.removeChild(y[A])}}if(F.hasAttribute("data-hiddencolumns")&&(B=F.getAttribute("data-hiddencolumns").split(","))&&(z=B.indexOf(A))>-1){B.splice(z,1);F.setAttribute("data-hiddencolumns",B.join(","))}return this},setupTD:function(I,C){if(I.covered){C.style.visibility="hidden";return this}var F=this.jS,E=I.loadedFrom,A=false,J=0,z=0,D,B,x,y,H=I.rowIndex,G=I.columnIndex,K;if(E.hasAttribute("class")){C.className=I.className}if(E.hasAttribute("style")){C.setAttribute("style",E.getAttribute("style"))}if(E.hasAttribute("rowspan")){C.setAttribute("rowspan",D=E.getAttribute("rowspan"));x=H+(D*1);A=true}if(E.hasAttribute("colspan")){C.setAttribute("colspan",B=E.getAttribute("colspan"));y=G+(B*1);A=true}if(A){if(x===undefined){x=H+1}if(y===undefined){y=y+1}C.style.position="absolute";C.style.borderBottomWidth=C.style.borderRightWidth="1px";for(;H<x;H++){J+=this.getHeight(I.sheetIndex,H)+2;if(I.rowIndex!==H&&(K=F.getCell(I.sheetIndex,H,I.columnIndex))!==null){K.covered=true;K.defer=I}}for(;G<y;G++){z+=this.getWidth(I.sheetIndex,G);if(I.columnIndex!==G&&(K=F.getCell(I.sheetIndex,I.rowIndex,G))!==null){K.covered=true;K.defer=I}}J-=1;z-=1;C.style.width=z+"px";C.style.height=J+"px"}return this},getCell:function(y,E,A){var z=this.tables,B,C,D,x;if((B=z[y])===undefined){return null}if((C=B.querySelectorAll("tr"))===undefined){return null}if((D=C[E])===undefined){return null}if((x=D.children[A])===undefined){return null}return x},jitCell:function(J,D,B){var x=this.getCell(J,D,B);if(x===null){return null}if(x.getCell!==undefined){return x.getCell()}var I,y,G,C,E,L,H,K,z,F,A;y=x.getAttribute("id");G=x.innerHTML;C=x.getAttribute("data-formula");E=x.getAttribute("data-celltype");L=x.getAttribute("data-uneditable");H=y!==null;K=G.length>0;z=C!==null;F=E!==null;A=L!==null;I=new j.Cell(J,null,this.jS,this.handler);I.rowIndex=D;I.columnIndex=B;I.loadedFrom=x;I.loader=this;if(H){I.id=y}if(z){I.formula=C}if(F){I.cellType=E}if(A){I.uneditable=L}if(K){I.value=new u(G)}else{I.value=new u()}I.value.cell=I;x.getCell=function(){return I};return I},jitCellById:function(z,J,H){switch(this.cellIds[z]){case undefined:break;case null:return this;default:H(this.cellIds[z].requestCell());break}var F=this,I=this.tables,C=(J<0?I.length-1:J+1),K,E,x,M,L,D,y,B,A,G;if(J<0){J=0}for(;J<C;J++){K=I[J];M=K.querySelectorAll("tr");if(M.length<1){continue}E=0;x=M.length;for(;E<x;E++){L=M[E];B=L.children;D=0;y=B.length;for(;D<y;D++){A=B[D];if(A===null){continue}if(A.id!==null&&A.id.length>0){this.cellIds[A.id]={cell:A,sheetIndex:J,rowIndex:E,columnIndex:D,requestCell:function(){return F.jitCell(this.sheetIndex,this.rowIndex,this.columnIndex)}}}}}}if(this.cellIds[z]!==undefined){G=this.cellIds[z].requestCell();H(G)}else{this.cellIds[z]=null}return this},title:function(x){var y=this.tables,z;if((z=y[x])===undefined){return""}return z.getAttribute("title")},hideRow:function(y,A){var x=y.loadedFrom,z;if(x.hasAttribute("data-hiddenrows")){z=c.toNumbers(x.getAttribute("data-hiddenrows").split(","))}else{z=[]}if(z.indexOf(A)<0){z.push(A);z.sort(function(C,B){return C-B})}x.setAttribute("data-hiddenrows",z.join(","));return z},hideColumn:function(z,x){var y=z.loadedFrom,A;if(y.hasAttribute("data-hiddencolumns")){A=c.toNumbers(y.getAttribute("data-hiddencolumns").split(","))}else{A=[]}if(A.indexOf(x)<0){A.push(x);A.sort(function(C,B){return C-B})}y.setAttribute("data-hiddencolumns",A.join(","));return A},showRow:function(z,B){var y=z.loadedFrom,A,x;if(y.hasAttribute("data-hiddenrows")){A=c.toNumbers(y.getAttribute("data-hiddenrows").split(","))}else{A=[]}if((x=A.indexOf(B))>-1){A.splice(x,1)}y.setAttribute("data-hiddenrows",A.join(","));return A},showColumn:function(A,y){var z=A.loadedFrom,B,x;if(z.hasAttribute("data-hiddencolumns")){B=c.toNumbers(z.getAttribute("data-hiddencolumns").split(","))}else{B=[]}if((x=B.indexOf(y))>-1){B.splice(x,1)}z.setAttribute("data-hiddencolumns",B.join(","));return B},hiddenRows:function(y){var x=y.loadedFrom.getAttribute("data-hiddenrows"),z=null;if(x!==null){z=c.toNumbers(x.split(","))}else{z=[]}return z},hiddenColumns:function(y){var x=y.loadedFrom.getAttribute("data-hiddencolumns"),z=null;if(x!==null){z=c.toNumbers(x.split(","))}else{z=[]}return z},hasSpreadsheetAtIndex:function(x){return(this.tables[x]!==undefined)},getSpreadsheetIndexByTitle:function(B){var A=this.tables,x=this.count,z=0,y;B=B.toLowerCase();for(;z<x;z++){if(A[z]!==undefined){y=A[z].getAttribute("title");if(y!==undefined&&y!==null&&y.toLowerCase()==B){return z}}}return -1},addSpreadsheet:function(y,x){y=y||t.createElement("table");if(x===undefined){this.tables.push(y)}else{this.tables.splice(x,0,y)}this.count=this.tables.length},getCellAttribute:function(x,y){return x.getAttribute(y)},setCellAttribute:function(x,y,z){x.setAttribute(y,z)},setCellAttributes:function(x,y){var z;for(z in y){if(z!==undefined&&y.hasOwnProperty(z)){x.setAttribute(z,y[z])}}return this},setDependencies:function(x){return this},addDependency:function(x,y){return this},cycleCells:function(D,A){var C=this.tables,E,G,x,B,F,z,y;if((E=C[D])===undefined){return}if((z=(G=E.querySelectorAll("tr")).length)<1){return}if(G[0].children.length<1){return}z--;do{F=G[z];x=F.children;y=x.length;do{B=x[y];A.call(B,D,z,y)}while(y-->0)}while(z-->0);return this},cycleCellsAll:function(z){var y=this.tables,x=y.length;if(x<0){return}do{this.cycleCells(x,z)}while(x-->0);return this},toTables:function(){return this.tables},fromSheet:function(B){B=(B==undefined?false:B);var N=[],I=this.jS,T=1*I.i,P,G,C=I.spreadsheets.length-1,K,U,F,Q,E,H,A,L,x,J,y,R,M,O,S,D,z;if(C<0){return N}do{S=false;I.i=C;I.evt.cellEditDone();P=I.obj.pane();U=t.createElement("table");F=t.createElement("tBody");Q=t.createElement("colGroup");U.setAttribute("title",I.obj.table().attr("title"));U.setAttribute("data-frozenatrow",P.action.frozenAt.row);U.setAttribute("data-frozenatcol",P.action.frozenAt.col);U.appendChild(Q);U.appendChild(F);N.unshift(U);G=I.spreadsheets[C];H=G.length;do{D=G[H][1].td.parentNode;z=D.style.height;x=t.createElement("tr");x.style.height=(z?z:I.s.colMargin+"px");A=G[H].length;do{y=G[H][A];J=t.createElement("td");R=y.td.attributes;if(B||S||R["class"]||y.formula||y.value||R.style){S=true;M=(R["class"]?v.trim((R["class"].value||"").replace(I.cl.uiCellActive,"").replace(I.cl.uiCellHighlighted,"")):"");O=y.td.parentNode;x.insertBefore(J,x.firstChild);if(!x.style.height){x.style.height=(O.style.height?O.style.height:I.s.colMargin+"px")}if(y.formula){J.setAttribute("data-formula",y.formula)}if(y.cellType){J.setAttribute("cellType",y.cellType)}if(y.value){J.setAttribute("value",y.value)}if(y.uneditable){J.setAttribute("uneditable",y.uneditable)}if(y.cache){J.setAttribute("cache",y.cache)}if(y.id){J.setAttribute("id",y.id)}if(R.style&&R.style.value){J.setAttribute("style",R.style.value)}if(M.length){J.className=M}if(R.rowspan){J.rowspan=R.rowspan.value}if(R.colspan){J.colspan=R.colspan.value}if(H*1==1){E=t.createElement("col");E.style.width=v(I.col(null,A)).css("width");Q.insertBefore(E,Q.firstChild)}}}while(A-->1);if(S){F.insertBefore(x,F.firstChild)}}while(H-->1)}while(C--);I.i=T;return this.json=N},type:w,typeName:"Sheet.Loader.HTML",clearCaching:function(){return this}};w.maxStoredDependencies=100;return w})(jQuery,k,o);j.Loader.JSON=(function(w,t,u){function v(x){if(x!==undefined){this.json=x;this.count=x.length}else{this.json=[];this.count=0}this.cellIds={};this.jS=null;this.handler=null}v.prototype={bindJS:function(x){this.jS=x;return this},bindHandler:function(x){this.handler=x;return this},bindActionUI:function(y,x){x.loadedFrom=this.json[y]},size:function(A){var z={cols:0,rows:0},y=this.json,C,B,D,x;if((C=y[A])===undefined){return z}if((B=C.rows)===undefined){return z}if((D=B[0])===undefined){return z}if((x=D.columns)===undefined){return z}return{rows:B.length,cols:x.length}},getWidth:function(x,B){var z=this.json,D=z[x]||{},y=D.metadata||{},C=y.widths||[],A=C[B]||j.defaultColumnWidth;return A*1},getHeight:function(y,D){var z=this.json,B=z[y]||{},A=B.rows||[],C=A[D]||{},x=C.height||j.defaultRowHeight;return x*1},isHidden:function(x){var z=this.json,A=z[x]||{},y=A.metadata||{};return y.hidden===true},setHidden:function(x,A){var z=this.json,B=z[x]||{},y=B.metadata||{};y.hidden=A;return this},addRow:function(D,B,C){var E=this.json[D],A=0,x=this.size(D).cols,G,F={columns:[]},y,z=F.columns;if(E===undefined){return this}G=E.rows;for(;A<x;A++){y={};C[A]=y;z.push(y)}if(B===undefined){G.push(F)}else{if(B<G.length){G.splice(B,0,F)}}return this},addColumn:function(D,A,C){var E=this.json[D],B=0,F,z,G=this.size(D),x=G.rows,y=G.cols;if(E===undefined){return this}F=E.rows;if(A===undefined){for(;B<x;B++){z={};C[B].loadedFrom=z;F[B].columns.push(z)}}else{if(A<y){for(;B<x;B++){z={};C[B].loadedFrom=z;F[B].columns.splice(A,0,z)}}}return this},deleteRow:function(x,D){var A=this.json[x],B,z,C,y;if(A===undefined){return this}B=A.rows;if(B.length>D){B.splice(D,1)}if((z=A.metadata)!==undefined&&(C=z.hiddenRows)!==undefined&&(y=C.indexOf(D))>-1){C.splice(y,1)}return this},deleteColumn:function(E,A){var F=this.json[E],H,G,y,D=0,x,C,B,z;if(F===undefined){return this}H=F.rows;x=H.length;for(;D<x;D++){G=H[D];y=G.columns;if(A.length>A){y.splice(A,1)}}if((C=F.metadata)!==undefined&&(B=C.hiddenColumns)!==undefined&&(z=B.indexOf(A))>-1){B.splice(z,1)}return this},setupTD:function(I,D){if(I.covered){D.style.visibility="hidden";return this}var F=this.jS,A=I.loadedFrom,B=false,J=0,z=0,E,C,x,y,H=I.rowIndex,G=I.columnIndex,K;if(A["class"]!==undefined){D.className=A["class"]}if(A.id!==undefined){D.setAttribute("id",A.id)}if(A.style!==undefined){D.setAttribute("style",A.style)}if(A.rowspan!==undefined){D.setAttribute("rowspan",E=A.rowspan);x=H+(E*1);B=true}if(A.colspan!==undefined){D.setAttribute("colspan",C=A.colspan);y=G+(C*1);B=true}if(B){if(x===undefined){x=H+1}if(y===undefined){y=y+1}D.style.position="absolute";D.style.borderBottomWidth=D.style.borderRightWidth="1px";for(;H<x;H++){J+=this.getHeight(I.sheetIndex,H)+2;if(I.rowIndex!==H&&(K=F.getCell(I.sheetIndex,H,I.columnIndex))!==null){K.covered=true;K.defer=I}}for(;G<y;G++){z+=this.getWidth(I.sheetIndex,G);if(I.columnIndex!==G&&(K=F.getCell(I.sheetIndex,I.rowIndex,G))!==null){K.covered=true;K.defer=I}}J-=1;z-=1;D.style.width=z+"px";D.style.height=J+"px"}return this},getCell:function(y,E,A){var z=this.json,C,B,D,x;if((C=z[y])===undefined){return}if((B=C.rows)===undefined){return}if((D=B[E])===undefined){return}if((x=D.columns[A])===undefined){return}if(x===null){x=D.columns[A]={}}return x},jitCell:function(E,H,T){var F=this.getCell(E,H,T);if(F===undefined){return null}if(F.getCell!==undefined){return F.getCell()}var S,R,L,Q,N,J,x,z,O,V,M,I,D,U,B,A,C,K,P,y,G;L=F.id;N=F.value;J=F.cache;x=F.formula;z=F.parsedFormula;O=F.cellType;V=F.uneditable;I=F.dependencies;U=(L!==undefined&&L!==null);B=(N!==undefined&&N!==null);A=(J!==undefined&&J!==null&&(J+"").length>0);C=(x!==undefined&&x!==null&&x!=="");K=(z!==undefined&&z!==null);P=(O!==undefined&&O!==null);y=(V!==undefined&&V!==null);G=(I!==undefined&&I!==null);S=new j.Cell(E,null,this.jS,this.handler);S.rowIndex=H;S.columnIndex=T;S.loadedFrom=F;S.loader=this;if(U){S.id=L}if(C){S.formula=x}if(K){S.parsedFormula=z}if(P){S.cellType=O}if(y){S.uneditable=V}if(B){S.value=new u(N)}else{S.value=new u()}if(A){S.value.html=J;S.needsUpdated=false}else{S.needsUpdated=(C||P||S.hasOperator.test(N))}if(G){Q=I.length;for(R=0;R<Q;R++){D=I[R];M=this.jitCell(D.s,D.r,D.c);if(M!==null){S.dependencies.push(M)}else{S.dependencies=[];F.dependencies=[];S.setNeedsUpdated(true);S.value=new u()}}}S.value.cell=S;F.getCell=function(){return S};return S},jitCellById:function(z,J,I){switch(this.cellIds[z]){case undefined:break;case null:return this;default:I(this.cellIds[z].requestCell());break}var G=this,K=this.json,C=(J<0?K.length-1:J+1),E,F,x,M,L,D,y,B,A,H;if(J<0){J=0}for(;J<C;J++){E=K[J];M=E.rows;if(M.length<1){continue}F=0;x=M.length;for(;F<x;F++){L=M[F];B=L.columns;D=0;y=B.length;for(;D<y;D++){A=B[D];if(A===null){continue}if(typeof A.id==="string"){this.cellIds[A.id]={cell:A,sheetIndex:J,rowIndex:F,columnIndex:D,requestCell:function(){return G.jitCell(this.sheetIndex,this.rowIndex,this.columnIndex)}}}}}}if(this.cellIds[z]!==undefined){H=this.cellIds[z].requestCell();I(H)}else{this.cellIds[z]=null}return this},title:function(x){var y=this.json,z;if((z=y[x])===undefined){return""}return z.title||""},hideRow:function(z,B){var y=z.loadedFrom,x=y.metadata||(y.metadata={}),A=x.hiddenRows||(x.hiddenRows=[]);if(A.indexOf(B)<0){A.push(B);A.sort(function(D,C){return D-C})}return A},hideColumn:function(A,z){var y=A.loadedFrom,x=y.metadata||(y.metadata={}),B=x.hiddenColumns||(x.hiddenColumns=[]);if(B.indexOf(z)<0){B.push(z);B.sort(function(D,C){return D-C})}return B},showRow:function(A,C){var z=A.loadedFrom,y=z.metadata||(z.metadata={}),B=y.hiddenRows||(y.hiddenRows=[]),x;if((x=B.indexOf(C))>-1){B.splice(x,1)}return B},showColumn:function(B,A){var z=B.loadedFrom,y=z.metadata||(z.metadata={}),C=y.hiddenColumns||(y.hiddenColumns=[]),x;if((x=C.indexOf(A))>-1){C.splice(x,1)}return C},hiddenRows:function(C){var B=C.loadedFrom,A=B.metadata||(B.metadata={}),D=A.hiddenRows||(A.hiddenRows=[]),y=D.length,x=[],z=0;for(;z<y;z++){x.push(D[z])}return x},hiddenColumns:function(C){var B=C.loadedFrom,A=B.metadata||(B.metadata={}),D=A.hiddenColumns||(A.hiddenColumns=[]),y=D.length,x=[],z=0;for(;z<y;z++){x.push(D[z])}return x},hasSpreadsheetAtIndex:function(x){return(this.json[x]!==undefined)},getSpreadsheetIndexByTitle:function(B){var z=this.json,x=this.count,y=0,A;B=B.toLowerCase();for(;y<x;y++){if(z[y]!==undefined){A=z[y].title;if(A!==undefined&&A!==null&&A.toLowerCase()==B){return y}}}return -1},addSpreadsheet:function(y,x){y=y||{};if(x===undefined){this.json.push(y)}else{this.json.splice(x,0,y)}this.count=this.json.length},getCellAttribute:function(x,y){return x[y]},setCellAttribute:function(x,y,z){x[y]=z},setCellAttributes:function(x,y){var z;for(z in y){if(z!==undefined&&y.hasOwnProperty(z)){x[z]=y[z]}}return this},setDependencies:function(y){if(y.dependencies.length>v.maxStoredDependencies){delete y.loadedFrom.dependencies;return this}var B=0,D=y.loadedFrom,C=y.dependencies,A,x=C.length,z=D.dependencies=[];for(;B<x;B++){A=C[B];z.push({s:A.sheetIndex,r:A.rowIndex,c:A.columnIndex})}return this},addDependency:function(x,y){var z=x.loadedFrom;if(z.dependencies===undefined){z.dependencies=[]}z.dependencies.push({s:y.sheetIndex,r:y.rowIndex,c:y.columnIndex});return this},cycleCells:function(D,C){var E=this.json,A,G,y,x,F,B,z;if((A=E[D])===undefined){return}if((B=(G=A.rows).length)<1){return}if(G[0].columns.length<1){return}do{F=G[B];y=F.columns;z=y.length-1;do{x=y[z];C.call(x,D,B,z)}while(z-->=0)}while(B-->=0);return this},cycleCellsAll:function(z){var y=this.json,x=y.length-1;if(x<0){return}do{this.cycleCells(x,z)}while(x-->0);return this},toTables:function(){var R=this.json,Q=this.count,G=w([]),C,I,D,z,A,K,J,M,x,T,F,L,S,H,B,y,E,P=0,O,N;for(;P<Q;P++){C=R[P];S=w(t.createElement("table"));if(C.title){S.attr("title",C.title||"")}G=G.add(S);I=C.rows;for(O=0;O<I.length;O++){D=I[O];if(L=(D.height+"").replace("px","")){y=w(t.createElement("tr")).attr("height",L).css("height",L+"px").appendTo(S)}z=D.columns;for(N=0;N<z.length;N++){A=z[N];E=w(t.createElement("td")).appendTo(y);if(A["class"]){E.attr("class",A["class"]||"")}if(A.style){E.attr("style",A.style||"")}if(A.formula){E.attr("data-formula",(A.formula?"="+A.formula:""))}if(A.cellType){E.attr("data-celltype",A.cellType||"")}if(A.value){E.html(A.value||"")}if(A.uneditable){E.html(A.uneditable||"")}if(A.rowspan){E.attr("rowspan",A.rowspan||"")}if(A.colspan){E.attr("colspan",A.colspan||"")}if(A.id){E.attr("id",A.id||"")}if(A.cache){E.html(A.cache)}}}if(K=C.metadata){if(J=K.widths){H=w(t.createElement("colgroup")).prependTo(S);for(N=0;N<J.length;N++){M=(J[N]+"").replace("px","");B=w(t.createElement("col")).attr("width",M).css("width",M+"px").appendTo(H)}}if(x=K.frozenAt){if(x.row){S.attr("data-frozenatrow",x.row)}if(x.col){S.attr("data-frozenatcol",x.col)}}if(T=K.hiddenRows){S.attr("data-hiddenrows",T.join(","))}if(F=K.hiddenColumns){S.attr("data-hiddencolumns",F.join(","))}}}return G},fromSheet:function(B){B=(B==undefined?false:B);var J=[],G=this.jS,P=1*G.i,L,C=G.spreadsheets.length-1,Q,E,F,A,H,O,z,x,M,I,K,N,D,y;if(C<0){return J}do{N=false;G.i=C;G.evt.cellEditDone();L=G.obj.pane();Q={title:(G.obj.table().attr("title")||""),rows:[],metadata:{widths:[],frozenAt:{row:L.actionUI.frozenAt.row,col:L.actionUI.frozenAt.col}}};J.unshift(Q);E=G.spreadsheets[C];F=E.length-1;do{D=E[F][1].td.parentNode;y=D.style.height;O={columns:[],height:(y?y.replace("px",""):G.s.colMargin)};A=E[F].length-1;do{x=E[F][A];z={};M=x.td.attributes;if(B||N||M["class"]||x.formula||x.value||M.style){N=true;I=(M["class"]?w.trim((M["class"].value||"").replace(G.cl.uiCellActive,"").replace(G.cl.uiCellHighlighted,"")):"");K=x.td.parentNode;O.columns.unshift(z);if(!O.height){O.height=(K.style.height?K.style.height.replace("px",""):G.s.colMargin)}if(x.formula){z.formula=x.formula}if(x.cellType){z.cellType=x.cellType}if(x.value){z.value=x.value}if(x.uneditable){z.uneditable=x.uneditable}if(x.cache){z.cache=x.cache}if(x.id){z.id=x.id}if(M.style&&M.style.value){z.style=M.style.value}if(I.length){z["class"]=I}if(M.rowspan){z.rowspan=M.rowspan.value}if(M.colspan){z.colspan=M.colspan.value}if(F*1==1){Q.metadata.widths.unshift(w(G.col(null,A)).css("width").replace("px",""))}}}while(A-->1);if(N){Q.rows.unshift(O)}}while(F-->1)}while(C--);G.i=P;return this.json=J},type:v,typeName:"Sheet.JSONLoader",clearCaching:function(){var G=this.json,z,H,I,A,B,F=0,E,D,C=G.length,x,y;for(;F<C;F++){z=G[F];I=z.rows;x=I.length;for(E=0;E<x;E++){H=I[E];B=H.columns;y=B.length;for(D=0;D<y;D++){A=B[D];if(A===null){continue}delete A.cache;delete A.dependencies;delete A.parsedFormula}}}return this},download:function(E){E=E||500;var K=f.open(),D,J,L=this.json,B=0,I=L.length-1,y;if(K!==undefined){D=K.document;D.write('<html> <head id="head"></head> <body> <div id="entry"> </div> </body></html>');J=w(D.getElementById("entry"));while(B<=I){y=L[B];if(y.rows.length>E){var H={title:y.title,metadata:y.metadata,rows:[]},C=[],G=0,N,M=y.rows,F=M.length,A=1,x=0,z=function(P,O){J.append(t.createElement("br"));J.append(w(t.createElement("a")).attr("download",y.title+"-part"+O+".json").attr("href",URL.createObjectURL(new Blob([JSON.stringify(P)],{type:"application/json"}))).text(y.title+" - part "+O))};z(H,A);while(G<F){if(x===E){x=0;A++;z(C,A);C=[]}C.push(M[G]);x++;G++}if(C.length>0){A++;z(C,A)}}else{J.append(t.createElement("br")).append(w(t.createElement("a")).attr("download",y.title+".json").attr("href",URL.createObjectURL(new Blob([JSON.stringify(y)],{type:"application/json"}))).text(y.title))}B++}D.close();K.focus()}}};v.maxStoredDependencies=100;return v})(jQuery,k,o);j.Loader.XML=(function(u,t){function v(w){if(w!==undefined){this.xml=u.parseXML(w);this.spreadsheets=this.xml.getElementsByTagName("spreadsheets")[0].getElementsByTagName("spreadsheet");this.count=this.xml.length}else{this.xml=null;this.spreadsheets=null;this.count=0}}v.prototype={size:function(y){var w=this.xml[y],z=w.rows,A=z[0],x=A.columns;return{rows:z.length,cols:x.length}},setWidth:function(E,B,z){var A=this.spreadsheets,D=A[E],C=D.getElementsByTagName("metadata")[0]||{},x=C.getElementsByTagName("width")||[],y=x[B],w=(y.textContent||y.text);z.style.width=w+"px"},setRowHeight:function(x,D,B){var z=this.spreadsheets,y,A,C,w;if((y=z[x])===undefined){return}if((A=y.getElementsByTagName("rows")[0].getElementsByTagName("row"))===undefined){return}if((C=A[D])===undefined){return}if((w=C.attributes.height.nodeValue)===undefined){return}B.style.height=w+"px"},setupCell:function(E,z,y,w,A){var x=this.spreadsheets,D,F,B,C;if((D=x[E])===undefined){return false}if((F=D.getElementsByTagName("rows")[0].getElementsByTagName("row")[z-1])===undefined){return false}if((B=F.getElementsByTagName("columns")[0].getElementsByTagName("column")[y-1])===undefined){return false}w.cellType=B.attributes.cellType.nodeValue||"";if((C=B.jitCell)!==undefined){w.html=C.html;w.state=C.state;w.cellType=C.cellType;w.value=C.value;w.uneditable=C.uneditable;w.sheet=C.sheet;w.dependencies=C.dependencies}if(B.attributes.formula){w.formula=B.attributes.formula.nodeValue||"";A.setAttribute("data-formula",B.attributes.formula.nodeValue||"")}else{A.innerHTML=w.value=B.attributes.value.nodeValue||""}A.className=B.attributes["class"].nodeValue||"";A.setAttribute("style",B.attributes.style.nodeValue||"");if(B.attributes.rowspan){A.setAttribute("rowspan",B.attributes.rowspan.nodeValue||"")}if(B.attributes.colspan){A.setAttribute("colspan",B.attributes.colspan.nodeValue||"")}return true},getCell:function(w,y,x){return null},jitCell:function(x,C,A){var z=this.spreadsheets,y,B,w;if((y=z[x])===undefined){return false}if((B=y.getElementsByTagName("rows")[0].getElementsByTagName("row")[C-1])===undefined){return false}if((w=B.getElementsByTagName("columns")[0].getElementsByTagName("column")[A-1])===undefined){return false}return{td:{cellIndex:A,parentNode:{rowIndex:C},html:function(){}},html:[],state:[],cellType:w.attributes.cellType.nodeValue||"",formula:w.attributes.formula.nodeValue||"",value:w.attributes.value.nodeValue||"",type:"cell",sheet:x,id:null}},title:function(x){var y=this.spreadsheets,w;if((w=y[x])===undefined){return""}return(w.attributes.title?w.attributes.title.nodeValue:"")},getSpreadsheetIndexByTitle:function(w){},addSpreadsheet:function(w,x){if(x===undefined){this.spreadsheets.append.push(jsonSpreadsheet)}else{this.json.splice(x,0,jsonSpreadsheet)}this.count=this.json.length},setCellAttribute:function(w,x,y){},toTables:function(){var D=this.xml,H=u([]),B=D.getElementsByTagName("spreadsheets")[0].getElementsByTagName("spreadsheet"),E,L,F,z,C,U,O,aa,N,K,M,R,P;for(var X=0;X<B.length;X++){E=B[X];var Z=u(t.createElement("table")).attr("title",(E.attributes.title?E.attributes.title.nodeValue:"")),J=u(t.createElement("colgroup")).appendTo(Z),x=u(t.createElement("tbody")).appendTo(Z);H=H.add(Z);L=E.getElementsByTagName("rows")[0].getElementsByTagName("row");O=E.getElementsByTagName("metadata")[0];for(var V=0;V<L.length;V++){F=L[V];var y=u(t.createElement("tr")).appendTo(x);if(P=F.attributes.height){P=(P.nodeValue||"").replace("px","");y.css("height",P).attr("height",P+"px")}z=F.getElementsByTagName("columns")[0].getElementsByTagName("column");for(var T=0;T<z.length;T++){C=z[T];var G=u(t.createElement("td")).appendTo(y),w=C.getElementsByTagName("formula")[0],W=C.getElementsByTagName("cellType")[0],S=C.getElementsByTagName("value")[0],Y=C.getElementsByTagName("style")[0],I=C.getElementsByTagName("class")[0],ab=C.getElementsByTagName("rowspan")[0],A=C.getElementsByTagName("colspan")[0],Q=C.getElementsByTagName("id")[0];if(w){G.attr("data-formula","="+(w.textContent||w.text))}if(W){G.attr("data-celltype",W.textContent||W.text)}if(S){G.html(S.textContent||S.text)}if(Y){G.attr("style",Y.textContent||Y.text)}if(I){G.attr("class",I.textContent||I.text)}if(ab){G.attr("rowspan",ab.textContent||ab.text)}if(A){G.attr("colspan",A.textContent||A.text)}if(Q){G.attr("id",Q.textContent||Q.text)}}}M=O.getElementsByTagName("width");for(var V=0;V<M.length;V++){R=(M[V].textContent||M[V].text).replace("px","");u(t.createElement("col")).attr("width",R).css("width",R+"px").appendTo(J)}aa=O.getElementsByTagName("frozenAt")[0];if(aa){K=aa.getElementsByTagName("col")[0];N=aa.getElementsByTagName("row")[0];if(K){Z.attr("data-frozenatcol",(K.textContent||K.text)*1)}if(N){Z.attr("data-frozenatrow",(N.textContent||N.text)*1)}}}return H},fromSheet:function(I,C,D){C=(C==undefined?false:C);var L="",S=1*I.i,E=I.spreadsheets.length-1,x,G,H,B,J,Q,R,z,y,O,K,M,w,P,N,F,A;if(E<0){return L}do{P=false;I.i=E;I.evt.cellEditDone();w=u.extend({},I.obj.pane().actionUI.frozenAt);N=[];G=I.spreadsheets[E];H=G.length-1;Q="";do{z="";B=G[H].length-1;do{R="";y=G[H][B];O=y.td[0].attributes;K=(O["class"]?u.trim((O["class"].value||"").replace(I.cl.uiCellActive,"").replace(I.cl.uiCellHighlighted,"")):"");if(C||P||K||y.formula||y.value||O.style){P=true;R+="<column>";if(y.formula){R+="<formula>"+y.formula+"</formula>"}if(y.cellType){R+="<cellType>"+y.cellType+"</cellType>"}if(y.value){R+="<value>"+y.value+"</value>"}if(O.style){R+="<style>"+O.style.value+"</style>"}if(K){R+="<class>"+K+"</class>"}if(O.rowspan){R+="<rowspan>"+O.rowspan.value+"</rowspan>"}if(O.colspan){R+="<colspan>"+O.colspan.value+"</colspan>"}if(O.id){R+="<id>"+O.id.value+"</id>"}R+="</column>";z=R+z;if(H*1==1){N[B]="<width>"+u(I.col(null,B)).css("width").replace("px","")+"</width>"}}}while(B-->1);if(z){F=G[H][1].td[0].parentNode;A=F.style.height;Q='<row height="'+(A?A.replace("px",""):I.s.colMargin)+'"><columns>'+z+"</columns></row>"+Q}}while(H-->1);x='<spreadsheet title="'+(I.obj.table().attr("title")||"")+'"><rows>'+Q+"</rows><metadata>"+(w.row||w.col?"<frozenAt>"+(w.row?"<row>"+w.row+"</row>":"")+(w.col?"<col>"+w.col+"</col>":"")+"</frozenAt>":"")+"<widths>"+N.join("")+"</widths></metadata></spreadsheet>";L=x+L}while(E--);I.i=S;L='<?xml version="1.0" encoding="UTF-8"?><spreadsheets xmlns="http://www.w3.org/1999/xhtml">'+L+"</spreadsheets>";if(D!==true){this.xml=u.parseXML(L)}return L},type:v,typeName:"Sheet.XMLLoader"};return v})(jQuery,k);j.ActionUI=(function(t,w,u,v,y){var x=function(G,F,L,M){this.jS=G;this.enclosure=F;this.pane=t.createElement("div");this.active=true;F.appendChild(this.pane);if(!(this.frozenAt=M)){this.frozenAt={row:0,col:0}}this.frozenAt.row=u.max(this.frozenAt.row,0);this.frozenAt.col=u.max(this.frozenAt.col,0);G.s.loader.bindActionUI(G.i,this);this.hiddenRows=G.s.loader.hiddenRows(this);this.visibleRows=[];this.hiddenColumns=G.s.loader.hiddenColumns(this);this.visibleColumns=[];this.loader=G.s.loader;this.setupVisibleRows().setupVisibleColumns();var H=this,K=this.loader,J,B,z=this.pane,A,D,I=this.scrolledArea={row:u.max(this.frozenAt.row,1),col:u.max(this.frozenAt.col,1)},E=this.megaTable=new MegaTable({columns:j.domColumns,rows:j.domRows,element:z,updateCell:this._updateCell=function(N,R,P){var T=(H.visibleRows.length===0?N:H.visibleRows[N]),S=(H.visibleColumns===0?R:H.visibleColumns[R]),Q;if(typeof P.jSCell==="object"&&P.jSCell!==null){P.jSCell.td=null}var U=G.getCell(G.i,T,S);if(U===null){return}var O=G.spreadsheets[G.i]||(G.spreadsheets[G.i]=[]),V=O[T]||(O[T]=[]);if(!V[S]){V[S]=U}Q=U.td;if(Q!==null){while(Q.lastChild!==null){Q.removeChild(Q.lastChild)}}U.td=P;P.jSCell=U;K.setupTD(U,P);U.updateValue()},updateCorner:this._updateCorner=function(O,N){O.index=-1;O.entity="corner";O.col=N;O.className=G.cl.barCorner+" "+G.theme.bar},updateRowHeader:this._updateRowHeader=function(Q,P){var O,N;if(H.visibleRows.length===0){O=Q;N=t.createTextNode(O+1)}else{if(Q>=H.visibleRows.length){O=Q+H.hiddenRows.length}else{O=H.visibleRows[Q]}N=t.createTextNode(O+1)}P.index=O;P.entity="left";P.className=G.cl.barLeft+" "+G.theme.bar;P.appendChild(N);P.parentNode.style.height=P.style.height=K.getHeight(G.i,O)+"px"},updateColumnHeader:this._updateColumnHeader=function(N,R,P){var Q,O;if(H.visibleColumns.length===0){Q=N;O=t.createTextNode(G.cellHandler.columnLabelString(Q))}else{if(N>=H.visibleColumns.length){Q=N+H.hiddenColumns.length}else{Q=H.visibleColumns[N]}O=t.createTextNode(G.cellHandler.columnLabelString(Q))}R.index=Q;R.th=R;R.col=P;R.entity="top";R.className=G.cl.barTop+" "+G.theme.bar;R.appendChild(O);P.style.width=K.getWidth(G.i,Q)+"px"}}),C=this.infiniscroll=new Infiniscroll(z,{scroll:function(O,N){setTimeout(function(){I.col=O;I.row=N;E.update(N,O)},0)},verticalScrollDensity:15,horizontalScrollDensity:25});new MouseWheel(z,C._out);E.table.className+=" "+G.cl.table+" "+G.theme.table;E.table.setAttribute("cellSpacing","0");E.table.setAttribute("cellPadding","0");z.scroll=C._out;z.actionUI=this;z.table=E.table;z.tBody=E.tBody};x.prototype={putTdInView:function(E){var A=0,z=0,D=0,C,B;while((C=this.directionToSeeTd(E))!==null){B=this.scrolledArea;if(C.left){z--;this.scrollTo("x",0,B.col-1)}else{if(C.right){z++;this.scrollTo("x",0,B.col+1)}}if(C.up){D--;this.scrollTo("y",0,B.row-1)}else{if(C.down){D++;this.scrollTo("y",0,B.row+1)}}A++;if(A<25){break}}},directionToSeeTd:function(A){var z=this.pane,J={top:0,bottom:z.clientHeight,left:0,right:z.clientWidth},F=A.clientWidth,D=A.clientHeight,H={top:A.offsetTop,bottom:A.offsetTop+D,left:A.offsetLeft,right:A.offsetLeft+F},B=A.parentNode,G=this.scrolledArea;if(!A.col){return null}var I=A.barTop.cellIndex<G.col,C=B.rowIndex<G.row,E={up:C,down:H.bottom>J.bottom&&D<=z.clientHeight,left:I,right:H.right>J.right&&F<=z.clientWidth};if(E.up||E.down||E.left||E.right){return E}return null},hide:function(){var B=this.jS,A=B.obj.ui,D=this.pane,z=D.parentNode,C=this.infiniscroll;if(D!==undefined&&z.parentNode!==null){this.deactivate();C.saveLT();A.removeChild(D.parentNode)}return this},show:function(){var B=this.jS,A=B.obj.ui,D=this.pane,z=D.parentNode,C=this.infiniscroll;if(D!==undefined&&z.parentNode===null){A.appendChild(D.parentNode);C.applyLT();this.activate()}return this},deactivate:function(){var z=this.megaTable;this.active=false;z.updateCell=z.updateCorner=z.updateRowHeader=z.updateColumnHeader=function(){};return this},activate:function(){var z=this.megaTable;this.active=true;z.updateCell=this._updateCell;z.updateCorner=this._updateCorner;z.updateRowHeader=this._updateRowHeader;z.updateColumnHeader=this._updateColumnHeader;return this},hideRow:function(A){this.hiddenRows=this.loader.hideRow(this,A);var z;if((z=this.visibleRows.indexOf(A))>-1){this.visibleRows.splice(z,1)}this.megaTable.forceRedrawRows();return this},showRow:function(z){this.hiddenRows=this.loader.showRow(this,z);if(this.visibleRows.indexOf(z)<0){this.visibleRows.push(z);this.visibleRows.sort(function(B,A){return B-A})}this.megaTable.forceRedrawRows();return this},hideRowRange:function(C,B){var z=this.loader,A;for(;C<=B;C++){this.hiddenRows=z.hideRow(this,C);if((A=this.visibleRows.indexOf(C))>-1){this.visibleRows.splice(A,1)}}this.megaTable.forceRedrawRows();return this},showRowRange:function(B,A){var z=this.loader;for(;B<=A;B++){this.hiddenRows=z.showRow(this,B);if(this.visibleRows.indexOf(B)<0){this.visibleRows.push(B)}}this.visibleRows.sort(function(D,C){return D-C});this.megaTable.forceRedrawRows();return this},rowShowAll:function(){this.hiddenRows=[];this.visibleRows=[];this.megaTable.forceRedrawRows();return this},hideColumn:function(A){this.hiddenColumns=this.loader.hideColumn(this,A);var z;if((z=this.hiddenColumns.indexOf(A))>-1){this.hiddenColumns.splice(z,1)}this.megaTable.forceRedrawRows();return this},showColumn:function(z){this.hiddenColumns=this.loader.showColumn(this,z);if(this.visibleColumns.indexOf(z)<0){this.visibleColumns.push(z);this.visibleColumns.sort(function(B,A){return B-A})}this.megaTable.forceRedrawColumns();return this},hideColumnRange:function(C,B){var z=this.loader,A;for(;C<=B;C++){this.hiddenColumns=z.hideColumn(this,C);if((A=this.visibleColumns.indexOf(C))>-1){this.visibleColumns.splice(A,1)}}this.megaTable.forceRedrawColumns();return this},showColumnRange:function(B,A){var z=this.loader;for(;B<=A;B++){this.hiddenColumns=z.showColumn(this,B);if(this.visibleColumns.indexOf(B)<0){this.visibleColumns.push(B)}}this.visibleColumns.sort(function(D,C){return D-C});this.megaTable.forceRedrawColumns();return this},columnShowAll:function(){this.hiddenColumns=[];this.visibleColumns=[];this.megaTable.forceRedrawColumns();return this},remove:function(){throw new p("Not yet implemented")},scrollToCell:function(z,A){throw new p("Not yet implemented")},setupVisibleRows:function(){var A=0,C=this.visibleRows=[],B=this.hiddenRows,z=this.loader.size(this.jS.i).rows;for(;A<z;A++){if(B.indexOf(A)<0){C.push(A)}}return this},setupVisibleColumns:function(){var B=0,A=this.visibleColumns=[],C=this.hiddenColumns,z=this.loader.size(this.jS.i).cols;for(;B<z;B++){if(C.indexOf(B)<0){A.push(B)}}return this},redrawRows:function(){this.megaTable.forceRedrawRows()},redrawColumns:function(){this.megaTable.forceRedrawColumns()},pixelScrollDensity:30,maximumVisibleRows:65,maximumVisibleColumns:35};return x})(k,f,g,r,d);j.Cell=(function(){var t=undefined;function v(u,y,x,w){if(v.cellLoading===null){v.cellLoading=x.msg.cellLoading}if(y!==undefined&&y!==null){this.td=y;y.jSCell=this}else{this.td=null}this.dependencies=[];this.formula="";this.cellType=null;this.value="";this.valueOverride=null;this.calcCount=0;this.sheetIndex=u;this.rowIndex=null;this.columnIndex=null;this.jS=(x!==undefined?x:null);this.state=[];this.needsUpdated=true;this.uneditable=false;this.id=null;this.loader=null;this.loadedFrom=null;this.cellHandler=w;this.waitingCallbacks=[];this.parsedFormula=null;this.defer=null;this.isEdit=false;this.edited=false;this.covered=false}v.prototype={clone:function(){var w=new v(this.sheetIndex,this.td,this.jS,this.cellHandler),u;for(u in this){if(u!==undefined&&this.hasOwnProperty(u)){if(this[u]!==null&&this[u].call===undefined){w[u]=this[u]}else{if(this[u]===null){w[u]=this[u]}}}}return w},addDependency:function(u){if(u===undefined||u===null){return}if(u.type!==j.Cell){throw new p("Wrong Type")}if(this.dependencies.indexOf(u)<0&&this!==u){this.dependencies.push(u);if(this.loader!==null){this.loader.addDependency(this,u)}}},updateValue:function(G){if(!this.needsUpdated&&this.value.cell!==t&&this.defer===null){var H=(this.valueOverride!==null?this.valueOverride:this.value);this.displayValue();if(G!==t){G.call(this,H)}if(this.waitingCallbacks.length>0){while(this.waitingCallbacks.length>0){this.waitingCallbacks.pop().call(this,H)}}return}if(this.cellType===null&&this.defer===null&&this.formula.length<1){if(this.value!==undefined&&((this.value+"").length<1||!this.hasOperator.test(this.value))){if(this.td!==null){this.td.innerHTML=this.encode(this.value)}this.value=new o(this.value);this.value.cell=this;this.needsUpdated=false;this.updateDependencies();if(G!==t){G.call(this,this.value)}if(this.waitingCallbacks.length>0){while(this.waitingCallbacks.length>0){this.waitingCallbacks.pop().call(this,this.value)}}return}}var A,F=this,w,D=this.value,B=this.formula,C=this.cellType,x,u=this.defer,E,z=function(I){F.parsedFormula=I;F.resolveFormula(I,function(J){if(J!==t&&J!==null){if(J.cell!==t&&J.cell!==F){J=J.valueOf()}j.calcStack--;if(C!==null&&(x=j.CellTypeHandlers[C])!==t){J=x(F,J)}y.call(F,J)}else{y.call(F,null)}})},y=function(I){if(I===t||I===null){I=new o()}if(I.cell===t){switch(typeof(I)){case"object":break;case"undefined":I=new o();break;case"number":I=new r(I);break;case"boolean":I=new s(I);break;case"string":default:I=new o(I);break}I.cell=F}F.value=I;w=F.displayValue().valueOf();F.state.shift();if(F.loader!==null){F.loader.setCellAttributes(F.loadedFrom,{cache:(typeof w!=="object"?w:null),formula:F.formula,parsedFormula:F.parsedFormula,value:F.value+"",cellType:F.cellType,uneditable:F.uneditable}).setDependencies(F)}F.needsUpdated=false;E=F.valueOverride!==null?F.valueOverride:F.value;if(G!==t){G.call(F,E)}if(F.waitingCallbacks.length>0){while(F.waitingCallbacks.length>0){F.waitingCallbacks.pop().call(F,E)}}F.updateDependencies()};if(this.state.length>0){if(G!==t){this.waitingCallbacks.push(G)}return}if(u!==null){u.updateValue(function(I){I=I.valueOf();switch(typeof(I)){case"object":break;case"undefined":I=new o();break;case"number":I=new r(I);break;case"boolean":I=new s(I);break;case"string":default:I=new o(I);break}I.cell=F;F.value=I;F.updateDependencies();F.needsUpdated=false;F.displayValue();if(G!==t){G.call(F,I)}if(F.waitingCallbacks.length>0){while(F.waitingCallbacks.length>0){F.waitingCallbacks.pop().call(F,I)}}});return}this.oldValue=D;this.state.unshift("updating");this.fnCount=0;this.valueOverride=null;this.calcCount++;if(B.length>0){if(B.charAt(0)==="="){F.formula=B=B.substring(1)}if(F.td!==null){while(F.td.lastChild!==null){F.td.removeChild(F.td.lastChild)}F.td.appendChild(k.createTextNode(v.cellLoading))}j.calcStack++;if(this.parsedFormula!==null){z(this.parsedFormula)}else{this.jS.parseFormula(B,z)}}else{if(D!==t&&D!==null&&C!==null&&(x=j.CellTypeHandlers[C])!==t){D=x(F,D);y(D)}else{switch(typeof D.valueOf()){case"string":A=F.startOperators[D.charAt(0)];if(A!==t){F.valueOverride=A.call(F,D)}else{A=F.endOperators[D.charAt(D.length-1)];if(A!==t){F.valueOverride=A.call(F,D)}}break;case"undefined":D="";break}y(D)}}},updateDependencies:function(){var x,u,w;x=this.dependencies;this.dependencies=[];w=x.length-1;if(w>-1){this.state.unshift("updatingDependencies");do{u=x[w];u.updateValue()}while(w-->0);this.state.shift()}if(this.dependencies.length===0){this.dependencies=x}},displayValue:function(){var w=this.value,z=this.td,y=typeof w,u=w.html,x;if(u===t){if(y==="string"||(w!==null&&y==="object"&&w.toUpperCase!==t)&&w.length>0){u=this.encode(w)}else{u=w}}if(z===t||z===null){return u}switch(typeof u){case"object":if(u===null){while(z.lastChild!==null){z.removeChild(z.lastChild)}}else{if(u.appendChild!==t){if(u.parentNode===null){while(z.lastChild!==null){z.removeChild(z.lastChild)}z.appendChild(u)}return""}}case"string":default:while(z.lastChild!==null){z.removeChild(z.lastChild)}z.appendChild(k.createTextNode(u))}return z.innerHTML},resolveFormula:function(G,E){if(typeof G==="string"){E(G)}var D=this,z=[],x=0,A=G.length,y,F=this.cellHandler,C=[],B=function(I,K){var L=[],H,J=K.length-1;if(J<0){return}do{H=K[J];switch(typeof H){case"number":L[J]=C[H];break;case"string":L[J]=H;break;case"object":if(H instanceof Array){L[J]=w(H);break}default:L[J]=H}}while(J-->0);L.unshift(I);return L},w=function(J){var K=[],I=J.length-1,H;if(I<0){return}do{H=J[I];switch(typeof H){case"number":K[I]=C[H];break;case"string":K[I]=H;break;case"object":if(H.hasOwnProperty("args")){K[I]=H;K[I].a=w(H.a);break}else{if(H instanceof Array){K[I]=w(H);break}}default:K[I]=H}}while(I-->0);return K},u;if(D.jS.s.useStack){u=function(K){var J=v.thawIndex,L=v.thaws,I,H=(typeof L[J]==="undefined");if(H){I=v.thaws[J]=new Thaw([])}else{I=L[J]}v.thawIndex++;if(v.thawIndex>v.thawLimit){v.thawIndex=0}I.add(function(){if(z.length>0){z.shift()()}else{E(D.value=(K!==t?K:null))}})}}else{u=function(H){if(z.length>0){z.shift()()}else{E(D.value=(H!==t?H:null))}}}for(;x<A;x++){y=G[x];switch(y.t){case"m":(function(H,I){z.push(function(){u(C[I]=F[H.m].apply(F,B(D,H.a)))})})(y,x);break;case"l":(function(H,I){z.push(function(){var J=B(D,H.a);J.push(function(K){u(C[I]=K)});F[H.m].apply(F,J)})})(y,x);break;case"v":(function(H,I){z.push(function(){u(C[I]=H.v)})})(y,x);break;case"cell":(function(H,I){z.push(function(){C[I]=H;u()})})(y,x);break;case t:C[x]=y;break;default:C[x]=null;throw new p("Not implemented:"+y.t);break}}u()},recurseDependencies:function(y,A){if(A>v.maxRecursion){this.recurseDependenciesFlat(y);return this}var x=0,z=this.dependencies,w,u=z.length;if(A===undefined){A=0}for(;x<u;x++){w=z[x];y.call(w);w.recurseDependencies(y,A)}return this},recurseDependenciesFlat:function(z){var A=this.dependencies,x=A.length-1,w,u,y=[];if(x<0){return}do{y.push(A[x])}while(x-->0);do{w=y[y.length-1];y.length--;z.call(w);u=w.dependencies;x=u.length-1;if(x>-1){do{y.push(u[x])}while(x-->0)}}while(y.length>0)},getAllDependencies:function(){var u=[];this.recurseDependencies(function(){u.push(this)});return u},setNeedsUpdated:function(u){if(u!==t){this.needsUpdated=u}else{this.needsUpdated=true}this.recurseDependencies(function(){this.needsUpdated=true})},encode:function(u){switch(typeof u){case"object":if(u.getMonth!==t){return globalize.format(u,"d")}return u}if(!u){return u||""}if(!u.replace){return u||""}return u.replace(/&/gi,"&").replace(/>/gi,">").replace(/</gi,"<").replace(/\t/g,"   ").replace(/ /g," ")},setAttribute:function(u,w){var x=this.td;if(x!==t){x[u]=w}this.loader.setCellAttribute(this.loadedFrom,u,w);return this},setAttributes:function(u){var x=this.td,w;if(x!==t){for(w in u){if(u.hasOwnProperty(w)){x[u]=u[w]}}}this.loader.setCellAttributes(this.loadedFrom,u);return this},addClass:function(u){var z=this.td,x,w,y=this.loadedFrom;if(z!==t){if(z.classList){z.classList.add(u)}else{z.className+=" "+u}}if(y!==t){x=(this.loader.getCellAttribute(y,"class")||"");w=x.split(" ").indexOf(u);if(w<0){x+=" "+u;this.loader.setCellAttribute(y,"class",x)}}return this},removeClass:function(u){var z=this.td,x,w,y=this.loadedFrom;if(z!==t){if(z.classList){z.classList.remove(u)}else{x=(z.className+"").split(" ");w=x.indexOf(u);if(w>-1){x.splice(w,1);z.className=x.join(" ")}}}if(y!==t){x=(this.loader.getCellAttribute(y,"class")||"").split(" ");w=x.indexOf(u);if(w>-1){x.splice(w,1);this.loader.setCellAttribute(y,"class",x.join(" "))}}return this},hasOperator:/(^[$£])|([%]$)/,startOperators:{"$":function(w,u){return this.cellHandler.fn.DOLLAR.call(this,w.substring(1).replace(Globalize.culture().numberFormat[","],""),2,u||"$")},"£":function(u){return this.startOperators["$"].call(this,u,"£")}},endOperators:{"%":function(u){return u.substring(0,this.value.length-1)/100}},type:v,typeName:"Sheet.Cell"};v.thaws=[];v.thawLimit=500;v.thawIndex=0;v.cellLoading=null;v.maxRecursion=10;return v})();j.CellHandler=(function(v){function y(u){return !isNaN(u)}var t=undefined,x=NaN;function w(z,u){this.jS=z;this.fn=u}w.prototype={variable:function(E,C){if(arguments.length){var B=C[0],z=C[1],D=this.jS.s.formulaVariables,A,u;switch(B.toLowerCase()){case"true":u=new s(true);u.html="TRUE";u.cell=E;return u;case"false":u=new s(false);u.html="FALSE";u.cell=E;return u}if(A=D[B]&&!z){return A}else{if(A&&z){return A[z]}else{return""}}}},time:function(u,A,z){return h.fromString(A,z)},number:function(z,u){if(isNaN(u)||u===null){u=0}switch(typeof u){case"number":return u;case"string":if(y(u)){return u*1}case"object":if(u.getMonth){return e.toCentury(u)}}return u},invertNumber:function(B,A){if(isNaN(A)){A=0}var z=this.number(B,A),u=new r(z.valueOf()*-1);if(z.html){u.html=z.html}return u},performMath:function(u,F,E,D){if(E===t||E===null){E=0}if(D===t||D===null){D=0}var C,B,G=true,z=true,I=[],H,A=function(J){return J};if(E.hasOwnProperty("cell")){E.cell.addDependency(u)}if(D.hasOwnProperty("cell")){D.cell.addDependency(u)}switch(C=(typeof E.valueOf())){case"number":break;case"string":if(y(E)){E*=1}else{G=false}break;case"object":if(E.getMonth){E=e.toCentury(E);A=e.get}else{G=false}break;default:G=false}switch(B=(typeof D.valueOf())){case"number":break;case"string":if(y(D)){D*=1}else{z=false}break;case"object":if(D.getMonth){D=e.toCentury(D)}else{z=false}break;default:z=false}if(!G&&F!=="+"){I.push("not a number: "+E);E=0}if(!z){I.push("not a number: "+D);D=0}if(I.length){}switch(F){case"+":H=E+D;break;case"-":H=E-D;break;case"/":H=E/D;if(H==Infinity||H==x){H=0}break;case"*":H=E*D;break;case"^":H=v.pow(E,D);break}return A(H)},not:function(B,A,z){var u;if(A.valueOf()!=z.valueOf()){u=new s(true);u.html="TRUE";u.cell=B}else{u=new s(false);u.html="FALSE";u.cell=B}return u},concatenate:function(A,z,u){if(z===null){z=""}if(u===null){u=""}return z.toString()+u.toString()},cellValue:function(A,z,D){var B=this.jS,C=this.parseLocation(z.c,z.r),u;u=B.getCell(A.sheetIndex,C.row,C.col);if(u!==null){u.addDependency(A);u.updateValue(D)}else{if(D!==t){D.call(A,0)}}return this},cellRangeValue:function(z,B,u,A){return this.remoteCellRangeValue(z,z.sheetIndex,B,u,A)},remoteCellValue:function(C,B,A,F){var D=this.jS,E=this.parseLocation(A.c,A.r),z=this.parseSheetLocation(B),u;if(z<0){z=D.getSpreadsheetIndexByTitle(B)}u=D.getCell(z,E.row,E.col);if(u!==null){u.addDependency(C);u.updateValue(F)}else{if(F!==t){F.call(C,0)}}return this},remoteCellRangeValue:function(T,V,D,z,E){var F=(typeof V==="string"?this.parseSheetLocation(V):V),U=this.parseLocation(D.c,D.r),J=this.parseLocation(z.c,z.r),K=(U.row<J.row?U.row:J.row),C=(U.row<J.row?J.row:U.row),S=(U.col<J.col?U.col:J.col),M=S,A=(U.col<J.col?J.col:U.col),R=(A-(S-1))*(C-(K-1)),N=0,H=this.jS,L=[],I,O,u,G,W,Q=0,P,B;if(F<0){F=H.getSpreadsheetIndexByTitle(V)}if(F<0){L=new o("");L.html="#NAME?";E.call(T,L);return this}W=F+"!"+D.c+D.r+":"+z.c+z.r;I=w.cellRangeCache[W];if(I!==t){O=true;P=I.length;for(Q=0;Q<P;Q++){if(I[Q].needsUpdated){O=false}}if(O){E.call(T,w.cellRangeCache[W]);return this}}B=H.spreadsheets[F];if(B===t){H.spreadsheets[F]=B=[]}L.rowCount=(C-K)+1;L.columnCount=(A-M)+1;for(;K<=C;K++){M=S;G=(B[K]!==t?B[K]:null);for(;M<=A;M++){if(G===null||(u=G[M])===t){u=H.getCell(F,K,M)}else{u.sheetIndex=F;u.rowIndex=K;u.columnIndex=M}if(u!==null){u.addDependency(T);(function(X){u.updateValue(function(Y){L[X]=Y;N++;if(N===R){w.cellRangeCache[W]=L;E.call(T,L)}})})(Q++)}}}if(Q!==R){}return this},callFunction:function(B,A,z){A=A.toUpperCase();z=z||[];var C=this.fn[A],u;if(C!==t){B.fnCount++;u=C.apply(B,z)}else{u=new o();u.html="Function "+A+" Not Found"}return u},formulaParser:function(z){var u;if(z>-1){u=this.spareFormulaParsers[z];if(u===t){u=this.spareFormulaParsers[z]=Formula(this)}}else{u=this.jS.formulaParser}return u},parseLocation:function(u,z){return{row:z-1,col:this.columnLabelIndex(u)}},parseSheetLocation:function(z){var u=((z+"").replace(/SHEET/i,"")*1)-1;return isNaN(u)?-1:u},parseCellName:function(u,A){var z="";if(A!==undefined){A++;z=A.toString()}return this.columnLabelString(u)+z},alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),columnLabels:{},columnLabelIndex:function(u){return this.columnLabels[u.toUpperCase()]},columnIndexes:[],columnLabelString:function(B){if(!this.columnIndexes.length){var D="",C,A,z,u;C=A=z=-1;for(u=0;u<16385;++u){D="";++z;if(z==26){z=0;++A;if(A==26){A=0;++C}}if(C>=0){D+=this.alphabet[C]}if(A>=0){D+=this.alphabet[A]}if(z>=0){D+=this.alphabet[z]}this.columnIndexes[u]=D;this.columnLabels[D]=u}}return this.columnIndexes[B]||""}};w.cellRangeCache={};return w})(g);j.CellTypeHandlers=(function(){var u=isNaN,t={percent:function(w,y){if(y!==y){return 0}var x=(u(y)?Globalize.parseFloat(y):y*1),v;if(!u(x)){v=new r(x);v.html=Globalize.format(x,"p");return v}return y},date:function(v,x){if(x!==x){return 0}var w=Globalize.parseDate(x);if(w===null){return x}else{v.valueOverride=w;v.html=Globalize.format(w,"d");return x}},time:function(v,x){if(x!==x){return 0}var w=Globalize.parseDate(x);if(w===null){return x}else{w.html=Globalize.format(w,"t");return w}},currency:function(w,y){if(y!==y){return 0}var x=(u(y)?Globalize.parseFloat(y):y*1),v;if(!u(x)){v=new r(x);v.html=Globalize.format(x,"c");return v}return y},number:function(w,y){if(y!==y){return 0}var x,v;if(!t.endOfNumber){x=Globalize.culture().numberFormat["."];t.endOfNumber=new b("(["+(x=="."?".":x)+"])([0-9]*?[1-9]+)?(0)*$")}if(!u(y)){v=new r(y);v.html=Globalize.format(y+"","n10").replace(t.endOfNumber,function(B,A,z){return(z?A:"")+(z||"")});return v}return y}};return t})();j.CellRange=(function(){function t(u){this.cells=u||[]}t.prototype={clone:function(){var y=[],w=this.cells,v=w.length,u,z;for(var x=0;x<v;x++){u=w[x];z=u.clone();y.push(z)}return new t(y)},type:t,typeName:"Sheet.CellRange"};return t})();j.Highlighter=(function(t,u,v){var w=function(y,A,x,z){this.cssClass=y;this.cssClassBars=A;this.cssClassTabs=x;this.callBack=z||function(){};this.last=v([]);this.lastTop=v([]);this.lastLeft=v([]);this.lastTab=v([]);this.startRowIndex=0;this.startColumnIndex=0;this.endRowIndex=0;this.endColumnIndex=0};w.prototype={set:function(z){if(z.parentNode!==undefined){z=[z]}var x,y=this.last;if(y&&y.length>0){x=y.length-1;do{y[x].isHighlighted=false}while(x-->0)}if(z.length>0){x=z.length-1;do{if(!z[x].isHighlighted){z[x].isHighlighted=true;if(!z[x].className.match(this.cssClass)){z[x].className+=" "+this.cssClass}}}while(x-->0)}this.clear(y);this.last=z;this.callBack();return this},is:function(){return this.last.length>0},clear:function(y){if(this.is()){y=y||this.last;if(y&&y.length){var x=y.length-1;do{if(!y[x].isHighlighted){y[x].className=y[x].className.replace(this.cssClass,"");y[x].isHighlighted=false}}while(x-->0)}}this.last=v([]);return this},setBar:function(x,y){switch(x){case"top":this.lastTop.removeClass(this.cssClassBars);this.lastTop=v(y).addClass(this.cssClassBars);break;case"left":this.lastLeft.removeClass(this.cssClassBars);this.lastLeft=v(y).addClass(this.cssClassBars);break}return this},clearBar:function(){this.lastTop.removeClass(this.cssClassBars);this.lastTop=v([]);this.lastLeft.removeClass(this.cssClassBars);this.lastLeft=v([]);return this},setTab:function(x){this.clearTab();this.lastTab=x.addClass(this.cssClassTabs);return this},clearTab:function(){this.lastTab.removeClass(this.cssClassTabs);return this},setStart:function(x){this.startRowIndex=x.rowIndex+0;this.startColumnIndex=x.columnIndex+0;return this},setEnd:function(x){this.endRowIndex=x.rowIndex+0;this.endColumnIndex=x.columnIndex+0;return this}};return w})(k,f,jQuery);j.SpreadsheetUI=(function(){var t=[];function u(w,x,v){v=v||{};this.i=w;this.ui=x;this.isLast=v.lastIndex===w;this.enclosure=null;this.pane=null;this.spreadsheet=null;this.initChildren=v.initChildren||function(){};this.done=v.done||function(){};this.load()}u.prototype={load:function(w,x,v){this.initChildren(this.ui,this.i);this.enclosure=w;this.pane=x;this.spreadsheet=v;t.push(this.i);if(this.isLast){this.loaded()}},loaded:function(){this.done(t,this)}};return u})();j.Theme=(function(t){function u(v){v=v||j.defaultTheme;switch(v){case j.customTheme:this.cl=u.customClasses;break;case j.bootstrapTheme:this.cl=u.bootstrapClasses;break;default:case j.themeRollerTheme:this.cl=u.themeRollerClasses;break}m(this,this.cl)}u.themeRollerClasses={autoFiller:"ui-state-active",bar:"ui-widget-header",barHighlight:"ui-state-active",barHandleFreezeLeft:"ui-state-default",barHandleFreezeTop:"ui-state-default",barMenuTop:"ui-state-default",tdActive:"ui-state-active",tdHighlighted:"ui-state-highlight",control:"ui-widget-header ui-corner-top",controlTextBox:"ui-widget-content",fullScreen:"ui-widget-content ui-corner-all",inPlaceEdit:"ui-state-highlight",menu:"ui-widget-header",menuFixed:"",menuUl:"ui-widget-header",menuLi:"ui-widget-header",menuHover:"ui-state-highlight",pane:"ui-widget-content",parent:"ui-widget-content ui-corner-all",table:"ui-widget-content",tab:"ui-widget-header",tabActive:"ui-state-highlight",barResizer:"ui-state-highlight",barFreezer:"ui-state-highlight",barFreezeIndicator:"ui-state-highlight"};u.bootstrapClasses={autoFiller:"btn-info",bar:"input-group-addon",barHighlight:"label-info",barHandleFreezeLeft:"bg-warning",barHandleFreezeTop:"bg-warning",barMenuTop:"bg-warning",tdActive:"active",tdHighlighted:"bg-info disabled",control:"panel-heading",controlTextBox:"form-control",fullScreen:"",inPlaceEdit:"form-control",menu:"panel panel-default",menuFixed:"nav navbar-nav",menuUl:"panel-info",menuLi:"active",menuHover:"bg-primary active",pane:"well",parent:"panel panel-default",table:"table table-bordered table-condensed",tab:"btn-default btn-xs",tabActive:"active",barResizer:"bg-info",barFreezer:"bg-warning",barFreezeIndicator:"bg-warning"};u.customClasses={autoFiller:"",bar:"",barHighlight:"",barHandleFreezeLeft:"",barHandleFreezeTop:"",barMenuTop:"",tdActive:"",tdHighlighted:"",control:"",controlTextBox:"",fullScreen:"",inPlaceEdit:"",menu:"",menuFixed:"",menuUl:"",menuLi:"",menuHover:"",pane:"",parent:"",table:"",tab:"",tabActive:"",barResizer:"",barFreezer:"",barFreezeIndicator:""};return u})(jQuery);if(!Object.getPrototypeOf){Object.getPrototypeOf=function(t){return t||{}}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(v,w){for(var u=(w||0),t=this.length;u<t;u++){if(this[u]===v){return u}}return -1}}return j})(jQuery,document,window,Date,String,Number,Boolean,Math,RegExp,Error);var parser=(function(){var S=function(W,V,X,U){for(X=X||{},U=W.length;U--;X[W[U]]=V){}return X},m=[1,5],l=[1,6],k=[1,8],j=[1,9],i=[1,10],h=[1,13],f=[1,11],d=[1,12],c=[1,14],b=[1,15],R=[1,20],Q=[1,18],P=[1,21],O=[1,22],N=[1,17],M=[1,24],L=[1,25],K=[1,26],J=[1,27],I=[1,28],H=[1,29],G=[1,30],F=[1,31],E=[1,32],D=[4,13,14,15,17,18,19,20,21,22,23,35,36],C=[1,35],B=[1,36],z=[1,37],y=[4,13,14,15,17,18,19,20,21,22,23,35,36,38],x=[4,13,14,15,17,18,19,20,21,22,23,35,36,39],w=[4,13,14,15,17,18,19,20,21,22,23,29,35,36],v=[4,14,15,17,18,19,20,35,36],u=[1,71],t=[4,14,17,18,19,35,36],s=[4,14,15,17,18,19,20,21,22,35,36],r=[17,35,36];var A={trace:function q(){},yy:{},symbols_:{error:2,expressions:3,EOF:4,expression:5,variableSequence:6,TIME_AMPM:7,TIME_24:8,number:9,STRING:10,ESCAPED_STRING:11,LETTERS:12,"&":13,"=":14,"+":15,"(":16,")":17,"<":18,">":19,"-":20,"*":21,"/":22,"^":23,E:24,FUNCTION:25,expseq:26,cellRange:27,cell:28,":":29,SHEET:30,"!":31,NUMBER:32,"$":33,REF:34,";":35,",":36,VARIABLE:37,DECIMAL:38,"%":39,"$accept":0,"$end":1},terminals_:{2:"error",4:"EOF",7:"TIME_AMPM",8:"TIME_24",10:"STRING",11:"ESCAPED_STRING",12:"LETTERS",13:"&",14:"=",15:"+",16:"(",17:")",18:"<",19:">",20:"-",21:"*",22:"/",23:"^",24:"E",25:"FUNCTION",29:":",30:"SHEET",31:"!",32:"NUMBER",33:"$",34:"REF",35:";",36:",",37:"VARIABLE",38:"DECIMAL",39:"%"},productions_:[0,[3,1],[3,2],[5,1],[5,1],[5,1],[5,1],[5,1],[5,1],[5,1],[5,3],[5,3],[5,3],[5,3],[5,4],[5,4],[5,4],[5,3],[5,3],[5,3],[5,3],[5,3],[5,3],[5,2],[5,2],[5,1],[5,3],[5,4],[5,1],[27,1],[27,3],[27,3],[27,5],[28,2],[28,3],[28,3],[28,4],[28,1],[28,2],[28,2],[28,2],[28,3],[28,3],[28,3],[28,3],[28,3],[28,3],[28,4],[28,4],[28,4],[26,1],[26,2],[26,2],[26,3],[26,3],[6,1],[6,3],[9,1],[9,3],[9,2]],performAction:function p(W,Y,o,Z,ab,ac,U){var V=ac.length-1;switch(ab){case 1:return null;break;case 2:var X=Z.types;Z.types=[];return X;break;case 3:var aa={t:"m",m:"variable",a:[ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 4:var aa={t:"m",m:"time",a:[ac[V],true]};this.$=Z.types.length;Z.types.push(aa);break;case 5:var aa={t:"m",m:"time",a:[ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 6:var aa={t:"m",m:"number",a:[ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 7:var aa={t:"v",v:Z.escape(ac[V].substring(1,ac[V].length-1))};this.$=Z.types.length;Z.types.push(aa);break;case 8:var aa={t:"v",v:Z.escape(ac[V].substring(2,ac[V].length-2))};this.$=Z.types.length;Z.types.push(aa);break;case 9:var aa={t:"v",v:ac[V]};Z.types.push(aa);break;case 10:var aa={t:"m",m:"concatenate",a:[ac[V-2],ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 11:var aa={t:"m",m:"callFunction",a:["EQUAL",[ac[V-2],ac[V]]]};this.$=Z.types.length;Z.types.push(aa);break;case 12:var aa={t:"m",m:"performMath",a:["+",ac[V-2],ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 13:this.$=ac[V-1];break;case 14:var aa={t:"m",m:"callFunction",a:["LESS_EQUAL",[ac[V-3],ac[V]]]};this.$=Z.types.length;Z.types.push(aa);break;case 15:var aa={t:"m",m:"callFunction",a:["GREATER_EQUAL",[ac[V-3],ac[V]]]};this.$=Z.types.length;Z.types.push(aa);break;case 16:var aa={t:"m",m:"not",a:[ac[V-3],ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 17:var aa={t:"m",m:"callFunction",a:["GREATER",[ac[V-2],ac[V]]]};this.$=Z.types.length;Z.types.push(aa);break;case 18:var aa={t:"m",m:"callFunction",a:["LESS",[ac[V-2],ac[V]]]};this.$=Z.types.length;Z.types.push(aa);break;case 19:var aa={t:"m",m:"performMath",a:["-",ac[V-2],ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 20:var aa={t:"m",m:"performMath",a:["*",ac[V-2],ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 21:var aa={t:"m",m:"performMath",a:["/",ac[V-2],ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 22:var aa={t:"m",m:"performMath",a:["^",ac[V-2],ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 23:var aa={t:"m",m:"invertNumber",a:[ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 24:var aa={t:"m",m:"number",a:[ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 25:break;case 26:var aa={t:"m",m:"callFunction",a:[ac[V-2]]};this.$=Z.types.length;Z.types.push(aa);break;case 27:var aa={t:"m",m:"callFunction",a:[ac[V-3],ac[V-1]]};this.$=Z.types.length;Z.types.push(aa);break;case 29:var aa={t:"l",m:"cellValue",a:[ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 30:var aa={t:"l",m:"cellRangeValue",a:[ac[V-2],ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 31:var aa={t:"l",m:"remoteCellValue",a:[ac[V-2],ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 32:var aa={t:"l",m:"remoteCellRangeValue",a:[ac[V-4],ac[V-2],ac[V]]};this.$=Z.types.length;Z.types.push(aa);break;case 33:var aa={t:"cell",c:ac[V-1],r:ac[V]};this.$=Z.types.length;Z.types.push(aa);break;case 34:var aa={t:"cell",c:ac[V-1],r:ac[V]};this.$=Z.types.length;Z.types.push(aa);break;case 35:case 36:var aa={t:"cell",c:ac[V-2],r:ac[V]};this.$=Z.types.length;Z.types.push(aa);break;case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 48:case 49:return"#REF!";break;case 50:this.$=[ac[V]];break;case 53:ac[V-2].push(ac[V]);this.$=ac[V-2];break;case 54:ac[V-2].push(ac[V]);this.$=ac[V-2];break;case 55:this.$=[ac[V]];break;case 56:this.$=(ac[V-2] instanceof Array?ac[V-2]:[ac[V-2]]);this.$.push(ac[V]);break;case 57:this.$=ac[V];break;case 58:this.$=ac[V-2]+"."+ac[V];break;case 59:this.$=(ac[V-1]*0.01)+"";break}},table:[{3:1,4:[1,2],5:3,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{1:[3]},{1:[2,1]},{4:[1,23],13:M,14:L,15:K,18:J,19:I,20:H,21:G,22:F,23:E},S(D,[2,3],{38:[1,33]}),S(D,[2,4]),S(D,[2,5]),S(D,[2,6],{39:[1,34]}),S(D,[2,7]),S(D,[2,8]),S(D,[2,9],{32:C,33:B,34:z}),{5:38,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:39,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:40,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},S(D,[2,25]),{16:[1,41]},S(D,[2,28]),S(y,[2,55]),S(x,[2,57],{38:[1,42]}),S(D,[2,29],{29:[1,43]}),{31:[1,44]},{12:[1,45],34:[1,46]},S(w,[2,37],{32:[1,47],33:[1,49],34:[1,48]}),{1:[2,2]},{5:50,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:51,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:52,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:55,6:4,7:m,8:l,9:7,10:k,11:j,12:i,14:[1,53],15:h,16:f,19:[1,54],20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:57,6:4,7:m,8:l,9:7,10:k,11:j,12:i,14:[1,56],15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:58,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:59,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:60,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:61,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{37:[1,62]},S(x,[2,59]),S(w,[2,33]),{32:[1,63],34:[1,64]},S(w,[2,39]),{13:M,14:L,15:K,17:[1,65],18:J,19:I,20:H,21:G,22:F,23:E},S(v,[2,23],{13:M,21:G,22:F,23:E}),S(v,[2,24],{13:M,21:G,22:F,23:E}),{5:68,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,17:[1,66],20:d,24:c,25:b,26:67,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{32:[1,69]},{12:u,28:70,33:P,34:O},{12:u,28:72,33:P,34:O},{32:[1,73],33:[1,74],34:[1,75]},{32:[1,76],33:[1,78],34:[1,77]},S(w,[2,38]),S(w,[2,40]),{32:[1,79],34:[1,80]},S([4,17,35,36],[2,10],{13:M,14:L,15:K,18:J,19:I,20:H,21:G,22:F,23:E}),S([4,14,17,35,36],[2,11],{13:M,15:K,18:J,19:I,20:H,21:G,22:F,23:E}),S(v,[2,12],{13:M,21:G,22:F,23:E}),{5:81,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},{5:82,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},S(t,[2,18],{13:M,15:K,20:H,21:G,22:F,23:E}),{5:83,6:4,7:m,8:l,9:7,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,27:16,28:19,30:R,32:Q,33:P,34:O,37:N},S(t,[2,17],{13:M,15:K,20:H,21:G,22:F,23:E}),S(v,[2,19],{13:M,21:G,22:F,23:E}),S(s,[2,20],{13:M,23:E}),S(s,[2,21],{13:M,23:E}),S([4,14,15,17,18,19,20,21,22,23,35,36],[2,22],{13:M}),S(y,[2,56]),S(w,[2,35]),S(w,[2,45]),S(D,[2,13]),S(D,[2,26]),{17:[1,84],35:[1,85],36:[1,86]},S(r,[2,50],{13:M,14:L,15:K,18:J,19:I,20:H,21:G,22:F,23:E}),S(x,[2,58]),S(D,[2,30]),{32:C,33:B,34:z},S(D,[2,31],{29:[1,87]}),S(w,[2,34]),{32:[1,88]},S(w,[2,42]),S(w,[2,41]),S(w,[2,43]),{32:[1,89],34:[1,90]},S(w,[2,44]),S(w,[2,46]),S(t,[2,14],{13:M,15:K,20:H,21:G,22:F,23:E}),S(t,[2,16],{13:M,15:K,20:H,21:G,22:F,23:E}),S(t,[2,15],{13:M,15:K,20:H,21:G,22:F,23:E}),S(D,[2,27]),S(r,[2,51],{6:4,9:7,27:16,28:19,5:91,7:m,8:l,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,30:R,32:Q,33:P,34:O,37:N}),S(r,[2,52],{6:4,9:7,27:16,28:19,5:92,7:m,8:l,10:k,11:j,12:i,15:h,16:f,20:d,24:c,25:b,30:R,32:Q,33:P,34:O,37:N}),{12:u,28:93,33:P,34:O},S(w,[2,36]),S(w,[2,47]),S(w,[2,49]),S(r,[2,53],{13:M,14:L,15:K,18:J,19:I,20:H,21:G,22:F,23:E}),S(r,[2,54],{13:M,14:L,15:K,18:J,19:I,20:H,21:G,22:F,23:E}),S(D,[2,32])],defaultActions:{2:[2,1],23:[2,2]},parseError:function g(U,o){if(o.recoverable){this.trace(U)}else{throw new Error(U)}},parse:function n(af){var an=this,ac=[0],am=[],ay=[null],ah=[],aA=this.table,V="",ag=0,aw=0,X=0,ae=2,al=1;var Y=ah.slice.call(arguments,1);var o=Object.create(this.lexer);var az={yy:{}};for(var av in this.yy){if(Object.prototype.hasOwnProperty.call(this.yy,av)){az.yy[av]=this.yy[av]}}o.setInput(af,az.yy);az.yy.lexer=o;az.yy.parser=this;if(typeof o.yylloc=="undefined"){o.yylloc={}}var W=o.yylloc;ah.push(W);var Z=o.options&&o.options.ranges;if(typeof az.yy.parseError==="function"){this.parseError=az.yy.parseError}else{this.parseError=Object.getPrototypeOf(this).parseError}function ak(aD){ac.length=ac.length-2*aD;ay.length=ay.length-aD;ah.length=ah.length-aD}_token_stack:function aj(){var aD;aD=o.lex()||al;if(typeof aD!=="number"){aD=an.symbols_[aD]||aD}return aD}var au,ap,ab,at,aC,ai,ar={},ao,ax,U,ad;while(true){ab=ac[ac.length-1];if(this.defaultActions[ab]){at=this.defaultActions[ab]}else{if(au===null||typeof au=="undefined"){au=aj()}at=aA[ab]&&aA[ab][au]}_handle_error:if(typeof at==="undefined"||!at.length||!at[0]){var aa;var aq="";function aB(aE){var aD=ac.length-1;var aF=0;for(;;){if((ae.toString()) in aA[aE]){return aF}if(aE===0||aD<2){return false}aD-=2;aE=ac[aD];++aF}}if(!X){aa=aB(ab);ad=[];for(ao in aA[ab]){if(this.terminals_[ao]&&ao>ae){ad.push("'"+this.terminals_[ao]+"'")}}if(o.showPosition){aq="Parse error on line "+(ag+1)+":\n"+o.showPosition()+"\nExpecting "+ad.join(", ")+", got '"+(this.terminals_[au]||au)+"'"}else{aq="Parse error on line "+(ag+1)+": Unexpected "+(au==al?"end of input":("'"+(this.terminals_[au]||au)+"'"))}return this.parseError(aq,{text:o.match,token:this.terminals_[au]||au,line:o.yylineno,loc:W,expected:ad,recoverable:(aa!==false)})}else{if(ap!==al){aa=aB(ab)}}if(X==3){if(au===al||ap===al){throw new Error(aq||"Parsing halted while starting to recover from another error.")}aw=o.yyleng;V=o.yytext;ag=o.yylineno;W=o.yylloc;au=aj()}if(aa===false){throw new Error(aq||"Parsing halted. No suitable error recovery rule available.")}ak(aa);ap=(au==ae?null:au);au=ae;ab=ac[ac.length-1];at=aA[ab]&&aA[ab][ae];X=3}if(at[0] instanceof Array&&at.length>1){throw new Error("Parse Error: multiple actions possible at state: "+ab+", token: "+au)}switch(at[0]){case 1:ac.push(au);ay.push(o.yytext);ah.push(o.yylloc);ac.push(at[1]);au=null;if(!ap){aw=o.yyleng;V=o.yytext;ag=o.yylineno;W=o.yylloc;if(X>0){X--}}else{au=ap;ap=null}break;case 2:ax=this.productions_[at[1]][1];ar.$=ay[ay.length-ax];ar._$={first_line:ah[ah.length-(ax||1)].first_line,last_line:ah[ah.length-1].last_line,first_column:ah[ah.length-(ax||1)].first_column,last_column:ah[ah.length-1].last_column};if(Z){ar._$.range=[ah[ah.length-(ax||1)].range[0],ah[ah.length-1].range[1]]}ai=this.performAction.apply(ar,[V,aw,ag,az.yy,at[1],ay,ah].concat(Y));if(typeof ai!=="undefined"){return ai}if(ax){ac=ac.slice(0,-1*ax*2);ay=ay.slice(0,-1*ax);ah=ah.slice(0,-1*ax)}ac.push(this.productions_[at[1]][0]);ay.push(ar.$);ah.push(ar._$);U=aA[ac[ac.length-2]][ac[ac.length-1]];ac.push(U);break;case 3:return true}}return true}};var e=function(){var V=function(){};V.prototype=A.lexer;var U=function(){this.lexer=new V();this.yy={types:[],escape:function(W){return W.replace(/&/gi,"&").replace(/>/gi,">").replace(/</gi,"<").replace(/\n/g,"\n<br>").replace(/\t/g,"   ").replace(/ /g," ")},parseError:function(Y,X){this.done=true;var W=new String();W.html="<pre>"+Y+"</pre>";W.hash=X;return W}}};U.prototype=A;var o=new U();return o};if(typeof(window)!=="undefined"){window.Formula=e}else{A.Formula=e}var T=(function(){var V=({EOF:1,parseError:function W(ae,ad){if(this.yy.parser){this.yy.parser.parseError(ae,ad)}else{throw new Error(ae)}},setInput:function(ad,ae){this.yy=ae||this.yy||{};this._input=new a.InputReader(ad);this._more=this._backtrack=this.done=false;this.yylineno=this.yyleng=0;this.yytext=this.match="";this.conditionStack=["INITIAL"];this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0};if(this.options.ranges){this.yylloc.range=[0,0]}this.offset=0;return this},input:function(){var ae=this._input.ch();this.yytext+=ae;this.yyleng++;this.offset++;this.match+=ae;var ad=ae.match(/(?:\r\n?|\n).*/g);if(ad){this.yylineno++;this.yylloc.last_line++}else{this.yylloc.last_column++}if(this.options.ranges){this.yylloc.range[1]++}return ae},unput:function(af){var ad=af.length;var ae=af.split(/(?:\r\n?|\n)/g);this._input.unCh(ad,af);this.yytext=this.yytext.substr(0,this.yytext.length-ad);this.offset-=ad;var ah=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1);if(ae.length-1){this.yylineno-=ae.length-1}var ag=this.yylloc.range;this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:ae?(ae.length===ah.length?this.yylloc.first_column:0)+ah[ah.length-ae.length].length-ae[0].length:this.yylloc.first_column-ad};if(this.options.ranges){this.yylloc.range=[ag[0],ag[0]+this.yyleng-ad]}this.yyleng=this.yytext.length;return this},more:function(){this._more=true;return this},reject:function(){if(this.options.backtrack_lexer){this._backtrack=true}else{return this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})}return this},less:function(ad){this.unput(this.match.slice(ad))},pastInput:function(){var ad=this._input.toString();var ae=ad.substr(0,ad.length-this.match.length);return(ae.length>20?"...":"")+ae.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var ad=this._input.input.substr(this._input.position,this._input.input.length-1);return(ad.substr(0,20)+(ad.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var ad=this.pastInput();var ae=new Array(ad.length+1).join("-");return ad+this.upcomingInput()+"\n"+ae+"^"},test_match:function(ah,af){var ai,ad,ag,ae;if(this.options.backtrack_lexer){ag={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,yyleng:this.yyleng,offset:this.offset,_more:this._more,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done};if(this.options.ranges){ag.yylloc.range=this.yylloc.range.slice(0)}}ad=ah.match(/(?:\r\n?|\n).*/g);if(ad){this.yylineno+=ad.length}this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:ad!==null?ad[ad.length-1].length-ad[ad.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+ah.length};this.yytext+=ah;this.match+=ah;this.matches=ah;this.yyleng=this.yytext.length;if(this.options.ranges){this.yylloc.range=[this.offset,this.offset+=this.yyleng]}this._more=false;this._backtrack=false;this._input.addMatch(ah);ai=this.performAction.call(this,this.yy,this,af,this.conditionStack[this.conditionStack.length-1]);if(this.done&&!this._input.done){this.done=false}if(ai){return ai}else{if(this._backtrack){for(ae in ag){if(ag.hasOwnProperty(ae)){this[ae]=ag[ae]}}return null}}return null},next:function(){if(this.done){return this.EOF}if(this._input.done){this.done=true}var ah,af,ad,ae;if(!this._more){this.yytext="";this.match=""}var ai=this._currentRules();for(var ag=0;ag<ai.length;ag++){ad=this._input.match(this.rules[ai[ag]]);if(ad!==null&&(af===undefined||ad[0].length>af.length)){af=ad[0];ae=ag;if(this.options.backtrack_lexer){ah=this.test_match(ad[0],ai[ag]);if(ah!==null){return ah}else{if(this._backtrack){af=undefined;continue}else{return null}}}else{if(!this.options.flex){break}}}}if(af!==undefined){ah=this.test_match(af,ai[ae]);if(ah!==null){return ah}return null}if(this._input.done){return this.EOF}else{return this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})}},lex:function o(){var ad=this.next();if(ad!==null){return ad}else{return this.lex()}},begin:function U(ad){this.conditionStack.push(ad)},popState:function X(){var ad=this.conditionStack.length-1;if(ad>0){return this.conditionStack.pop()}else{return this.conditionStack[0]}},_currentRules:function ac(){if(this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules}else{return this.conditions.INITIAL.rules}},topState:function aa(ad){ad=this.conditionStack.length-1-Math.abs(ad||0);if(ad>=0){return this.conditionStack[ad]}else{return"INITIAL"}},pushState:function Z(ad){this.begin(ad)},stateStackSize:function Y(){return this.conditionStack.length},options:{},performAction:function ab(ah,ae,ag,ad){var af=ad;switch(ag){case 0:break;case 1:return 25;break;case 2:return 7;break;case 3:return 8;break;case 4:return 30;break;case 5:ae.yytext=ae.yytext.substring(1,ae.yytext.length-1);return 30;break;case 6:return 10;break;case 7:return 10;break;case 8:return 11;break;case 9:return 11;break;case 10:return 12;break;case 11:return 37;break;case 12:return 37;break;case 13:return 32;break;case 14:return 33;break;case 15:return 13;break;case 16:return" ";break;case 17:return 38;break;case 18:return 29;break;case 19:return 35;break;case 20:return 36;break;case 21:return 21;break;case 22:return 22;break;case 23:return 20;break;case 24:return 15;break;case 25:return 23;break;case 26:return 16;break;case 27:return 17;break;case 28:return 19;break;case 29:return 18;break;case 30:return"PI";break;case 31:return 24;break;case 32:return'"';break;case 33:return"'";break;case 34:return'"';break;case 35:return"'";break;case 36:return"!";break;case 37:return 14;break;case 38:return 39;break;case 39:return 34;break;case 40:return"#";break;case 41:return 4;break}},rules:[/^(?:\s+)/,/^(?:([A-Za-z]{1,})([A-Za-z_0-9]+)?(?=[(]))/,/^(?:([0]?[1-9]|1[0-2])[:][0-5][0-9]([:][0-5][0-9])?[ ]?(AM|am|aM|Am|PM|pm|pM|Pm))/,/^(?:([0]?[0-9]|1[0-9]|2[0-3])[:][0-5][0-9]([:][0-5][0-9])?)/,/^(?:(([A-Za-z0-9]+))(?=[!]))/,/^(?:((['](\\[']|[^'])*['])|(["](\\["]|[^"])*["]))(?=[!]))/,/^(?:((['](\\[']|[^'])*['])))/,/^(?:((["](\\["]|[^"])*["])))/,/^(?:(([\\]['].+?[\\]['])))/,/^(?:(([\\]["].+?[\\]["])))/,/^(?:[A-Z]+(?=[0-9$]))/,/^(?:[A-Za-z]{1,}[A-Za-z_0-9]+)/,/^(?:[A-Za-z_]+)/,/^(?:[0-9]+)/,/^(?:\$)/,/^(?:&)/,/^(?: )/,/^(?:[.])/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:\*)/,/^(?:\/)/,/^(?:-)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\))/,/^(?:>)/,/^(?:<)/,/^(?:PI\b)/,/^(?:E\b)/,/^(?:")/,/^(?:')/,/^(?:\\")/,/^(?:\\')/,/^(?:!)/,/^(?:=)/,/^(?:%)/,/^(?:#REF!)/,/^(?:[#])/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41],inclusive:true}}});return V})();A.lexer=T;function a(){this.yy={}}a.prototype=A;a.InputReader=(function(V,U,Y){var X=RegExp.prototype.sticky!==undefined,ag,ad,ae,Z;function ah(ai){this.done=false;this.input=ai;this.length=ai.length;this.matches=[];this.position=0}if(X){ah.prototype={addMatch:function af(ai){this.matches.push(ai);this.position+=ai.length;this.done=(this.position>=this.length)},ch:function o(){var ai=this.input[this.position];this.addMatch(ai);return ai},unCh:function ac(ai){this.position-=ai;this.position=V.max(0,this.position);this.done=(this.position>=this.length)},substring:function ab(aj,ai){aj=(aj!=0?this.position+aj:this.position);ai=(ai!=0?aj+ai:this.length);return this.input.substring(aj,ai)},match:function aa(aj){var ai;aj.lastIndex=this.position;if((ai=aj.exec(this.input))!==null){return ai}return null},toString:function W(){return this.matches.join("")}};ag=Y.rules;ae=ag.length;Z=0;for(;Z<ae;Z++){ad=ag[Z];ag[Z]=new RegExp(ad.source.substring(1),"y")}}else{ah.prototype={addMatch:function af(ai){this.input=this.input.slice(ai.length);this.matches.push(ai);this.position+=ai.length;this.done=(this.position>=this.length)},ch:function o(){var ai=this.input[0];this.addMatch(ai);return ai},unCh:function ac(aj,ai){this.position-=aj;this.position=V.max(0,this.position);this.input=ai+this.input;this.done=(this.position>=this.length)},substring:function ab(aj,ai){aj=(aj!=0?this.position+aj:this.position);ai=(ai!=0?aj+ai:this.length);return this.input.substring(aj,ai)},match:function aa(ak){var aj,ai=this.input;if((aj=ai.match(ak))!==null){return aj}return null},toString:function W(){return this.matches.join("")}}}return ah})(Math,A,T);A.Parser=a;return new a})();if(typeof require!=="undefined"&&typeof exports!=="undefined"){exports.parser=parser;exports.Parser=parser.Parser;exports.parse=function(){return parser.parse.apply(parser,arguments)};exports.main=function commonjsMain(a){if(!a[1]){console.log("Usage: "+a[0]+" FILE");process.exit(1)}var b=require("fs").readFileSync(require("path").normalize(a[1]),"utf8");return exports.parser.parse(b)};if(typeof module!=="undefined"&&require.main===module){exports.main(process.argv.slice(1))}}var parser=(function(){var n=function(w,u,x,t){for(x=x||{},t=w.length;t--;x[w[t]]=u){}return x},l=[1,10],j=[1,11],i=[1,12],h=[1,13],g=[5,7,8,9,10],f=[1,19],c=[1,20],a=[5,7,8,9,10,12,13],s=[1,21],r=[5,7,8,9,10,12,13,14,16];var k={trace:function p(){},yy:{},symbols_:{error:2,grid:3,rows:4,EOF:5,row:6,END_OF_LINE:7,END_OF_LINE_WITH_EMPTY_NEXT_FIRST_COLUMN:8,END_OF_LINE_WITH_NO_COLUMNS:9,END_OF_LINE_WITH_EMPTY_COLUMN:10,string:11,COLUMN_EMPTY:12,COLUMN_STRING:13,CHAR:14,QUOTE_ON:15,QUOTE_OFF:16,"$accept":0,"$end":1},terminals_:{2:"error",5:"EOF",7:"END_OF_LINE",8:"END_OF_LINE_WITH_EMPTY_NEXT_FIRST_COLUMN",9:"END_OF_LINE_WITH_NO_COLUMNS",10:"END_OF_LINE_WITH_EMPTY_COLUMN",12:"COLUMN_EMPTY",13:"COLUMN_STRING",14:"CHAR",15:"QUOTE_ON",16:"QUOTE_OFF"},productions_:[0,[3,2],[3,1],[4,1],[4,1],[4,1],[4,1],[4,1],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[6,1],[6,1],[6,2],[6,3],[6,1],[6,2],[6,3],[11,1],[11,2],[11,3]],performAction:function e(o,v,w,z,y,u,x){var t=u.length-1;switch(y){case 1:return u[t-1];break;case 2:return[[""]];break;case 3:this.$=[u[t]];break;case 4:this.$=[];break;case 5:this.$=[""];break;case 6:this.$=[""];break;case 7:this.$=[""];break;case 8:this.$=u[t-1];break;case 9:u[t-1].push([""]);this.$=u[t-1];break;case 10:u[t-1].push([""]);this.$=u[t-1];break;case 11:u[t-1][u[t-1].length-1].push("");this.$=u[t-1];break;case 12:u[t-2].push(u[t]);this.$=u[t-2];break;case 13:u[t].unshift("");u[t-2].push(u[t]);this.$=u[t-2];break;case 14:u[t-2].push([""]);u[t-2].push(u[t]);this.$=u[t-2];break;case 15:u[t-2][u[t-2].length-1].push("");u[t-2].push(u[t]);this.$=u[t-2];break;case 16:this.$=[u[t].join("")];break;case 17:this.$=[""];break;case 18:u[t-1].push("");this.$=u[t-1];break;case 19:u[t-2].push("");u[t-2].push(u[t].join(""));this.$=u[t-2];break;case 20:break;case 21:break;case 22:u[t-2].push(u[t].join(""));this.$=u[t-2];break;case 23:this.$=[u[t]];break;case 24:u[t-1].push(u[t]);this.$=u[t-1];break;case 25:this.$=u[t-1];break}},table:[{3:1,4:2,5:[1,3],6:4,7:[1,5],8:[1,6],9:[1,7],10:[1,8],11:9,12:l,13:j,14:i,15:h},{1:[3]},{5:[1,14],7:[1,15],8:[1,16],9:[1,17],10:[1,18]},{1:[2,2]},n(g,[2,3],{12:f,13:c}),n(g,[2,4]),n(g,[2,5]),n(g,[2,6]),n(g,[2,7]),n(a,[2,16],{14:s}),n(a,[2,17]),n(a,[2,20]),n(r,[2,23]),{11:22,14:i,15:h},{1:[2,1]},n(g,[2,8],{11:9,6:23,12:l,13:j,14:i,15:h}),n(g,[2,9],{11:9,6:24,12:l,13:j,14:i,15:h}),n(g,[2,10],{11:9,6:25,12:l,13:j,14:i,15:h}),n(g,[2,11],{11:9,6:26,12:l,13:j,14:i,15:h}),n(a,[2,18],{11:27,14:i,15:h}),n(a,[2,21],{11:28,14:i,15:h}),n(r,[2,24]),{14:s,16:[1,29]},n(g,[2,12],{12:f,13:c}),n(g,[2,13],{12:f,13:c}),n(g,[2,14],{12:f,13:c}),n(g,[2,15],{12:f,13:c}),n(a,[2,19],{14:s}),n(a,[2,22],{14:s}),n(r,[2,25])],defaultActions:{3:[2,2],14:[2,1]},parseError:function q(t,o){if(o.recoverable){this.trace(t)}else{throw new Error(t)}},parse:function m(D){var L=this,A=[0],K=[],V=[null],F=[],X=this.table,u="",E=0,T=0,w=0,C=2,J=1;var x=F.slice.call(arguments,1);var o=Object.create(this.lexer);var W={yy:{}};for(var S in this.yy){if(Object.prototype.hasOwnProperty.call(this.yy,S)){W.yy[S]=this.yy[S]}}o.setInput(D,W.yy);W.yy.lexer=o;W.yy.parser=this;if(typeof o.yylloc=="undefined"){o.yylloc={}}var v=o.yylloc;F.push(v);var y=o.options&&o.options.ranges;if(typeof W.yy.parseError==="function"){this.parseError=W.yy.parseError}else{this.parseError=Object.getPrototypeOf(this).parseError}function I(Z){A.length=A.length-2*Z;V.length=V.length-Z;F.length=F.length-Z}_token_stack:function H(){var Z;Z=o.lex()||J;if(typeof Z!=="number"){Z=L.symbols_[Z]||Z}return Z}var R,N,z,Q,Y,G,P={},M,U,t,B;while(true){z=A[A.length-1];if(this.defaultActions[z]){Q=this.defaultActions[z]}else{if(R===null||typeof R=="undefined"){R=H()}Q=X[z]&&X[z][R]}if(typeof Q==="undefined"||!Q.length||!Q[0]){var O="";B=[];for(M in X[z]){if(this.terminals_[M]&&M>C){B.push("'"+this.terminals_[M]+"'")}}if(o.showPosition){O="Parse error on line "+(E+1)+":\n"+o.showPosition()+"\nExpecting "+B.join(", ")+", got '"+(this.terminals_[R]||R)+"'"}else{O="Parse error on line "+(E+1)+": Unexpected "+(R==J?"end of input":"'"+(this.terminals_[R]||R)+"'")}this.parseError(O,{text:o.match,token:this.terminals_[R]||R,line:o.yylineno,loc:v,expected:B})}if(Q[0] instanceof Array&&Q.length>1){throw new Error("Parse Error: multiple actions possible at state: "+z+", token: "+R)}switch(Q[0]){case 1:A.push(R);V.push(o.yytext);F.push(o.yylloc);A.push(Q[1]);R=null;if(!N){T=o.yyleng;u=o.yytext;E=o.yylineno;v=o.yylloc;if(w>0){w--}}else{R=N;N=null}break;case 2:U=this.productions_[Q[1]][1];P.$=V[V.length-U];P._$={first_line:F[F.length-(U||1)].first_line,last_line:F[F.length-1].last_line,first_column:F[F.length-(U||1)].first_column,last_column:F[F.length-1].last_column};if(y){P._$.range=[F[F.length-(U||1)].range[0],F[F.length-1].range[1]]}G=this.performAction.apply(P,[u,T,E,W.yy,Q[1],V,F].concat(x));if(typeof G!=="undefined"){return G}if(U){A=A.slice(0,-1*U*2);V=V.slice(0,-1*U);F=F.slice(0,-1*U)}A.push(this.productions_[Q[1]][0]);V.push(P.$);F.push(P._$);t=X[A[A.length-2]][A[A.length-1]];A.push(t);break;case 3:return true}}return true}};if(typeof GLOBAL!=="undefined"){GLOBAL.window=GLOBAL}if(typeof window.TSV==="undefined"){var m=k.parse;k.parse=function(o){var t=this.lexer.setInput;this.lexer.setInput=function(u){t.call(this,u);this.begin("BOF");return this};this.parse=m;return m.call(this,o)};window.TSV=function(t){var v=function(){};v.prototype=k.lexer;var u=function(){this.lexer=new v();this.yy={}};u.prototype=k;var o=new u;o.setObj=function(w){o.yy.obj=w};o.yy.handler=t;return o}}var b=(function(){var u=({EOF:1,parseError:function v(D,C){if(this.yy.parser){this.yy.parser.parseError(D,C)}else{throw new Error(D)}},setInput:function(C,D){this.yy=D||this.yy||{};this._input=C;this._more=this._backtrack=this.done=false;this.yylineno=this.yyleng=0;this.yytext=this.matched=this.match="";this.conditionStack=["INITIAL"];this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0};if(this.options.ranges){this.yylloc.range=[0,0]}this.offset=0;return this},input:function(){var D=this._input[0];this.yytext+=D;this.yyleng++;this.offset++;this.match+=D;this.matched+=D;var C=D.match(/(?:\r\n?|\n).*/g);if(C){this.yylineno++;this.yylloc.last_line++}else{this.yylloc.last_column++}if(this.options.ranges){this.yylloc.range[1]++}this._input=this._input.slice(1);return D},unput:function(E){var C=E.length;var D=E.split(/(?:\r\n?|\n)/g);this._input=E+this._input;this.yytext=this.yytext.substr(0,this.yytext.length-C);this.offset-=C;var G=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1);this.matched=this.matched.substr(0,this.matched.length-1);if(D.length-1){this.yylineno-=D.length-1}var F=this.yylloc.range;this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:D?(D.length===G.length?this.yylloc.first_column:0)+G[G.length-D.length].length-D[0].length:this.yylloc.first_column-C};if(this.options.ranges){this.yylloc.range=[F[0],F[0]+this.yyleng-C]}this.yyleng=this.yytext.length;return this},more:function(){this._more=true;return this},reject:function(){if(this.options.backtrack_lexer){this._backtrack=true}else{return this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})}return this},less:function(C){this.unput(this.match.slice(C))},pastInput:function(){var C=this.matched.substr(0,this.matched.length-this.match.length);return(C.length>20?"...":"")+C.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var C=this.match;if(C.length<20){C+=this._input.substr(0,20-C.length)}return(C.substr(0,20)+(C.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var C=this.pastInput();var D=new Array(C.length+1).join("-");return C+this.upcomingInput()+"\n"+D+"^"},test_match:function(G,E){var H,C,F;if(this.options.backtrack_lexer){F={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done};if(this.options.ranges){F.yylloc.range=this.yylloc.range.slice(0)}}C=G[0].match(/(?:\r\n?|\n).*/g);if(C){this.yylineno+=C.length}this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:C?C[C.length-1].length-C[C.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+G[0].length};this.yytext+=G[0];this.match+=G[0];this.matches=G;this.yyleng=this.yytext.length;if(this.options.ranges){this.yylloc.range=[this.offset,this.offset+=this.yyleng]}this._more=false;this._backtrack=false;this._input=this._input.slice(G[0].length);this.matched+=G[0];H=this.performAction.call(this,this.yy,this,E,this.conditionStack[this.conditionStack.length-1]);if(this.done&&this._input){this.done=false}if(H){return H}else{if(this._backtrack){for(var D in F){this[D]=F[D]}return false}}return false},next:function(){if(this.done){return this.EOF}if(!this._input){this.done=true}var G,E,C,D;if(!this._more){this.yytext="";this.match=""}var H=this._currentRules();for(var F=0;F<H.length;F++){C=this._input.match(this.rules[H[F]]);if(C&&(!E||C[0].length>E[0].length)){E=C;D=F;if(this.options.backtrack_lexer){G=this.test_match(C,H[F]);if(G!==false){return G}else{if(this._backtrack){E=false;continue}else{return false}}}else{if(!this.options.flex){break}}}}if(E){G=this.test_match(E,H[D]);if(G!==false){return G}return false}if(this._input===""){return this.EOF}else{return this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})}},lex:function o(){var C=this.next();if(C){return C}else{return this.lex()}},begin:function t(C){this.conditionStack.push(C)},popState:function w(){var C=this.conditionStack.length-1;if(C>0){return this.conditionStack.pop()}else{return this.conditionStack[0]}},_currentRules:function B(){if(this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules}else{return this.conditions.INITIAL.rules}},topState:function z(C){C=this.conditionStack.length-1-Math.abs(C||0);if(C>=0){return this.conditionStack[C]}else{return"INITIAL"}},pushState:function y(C){this.begin(C)},stateStackSize:function x(){return this.conditionStack.length},options:{},performAction:function A(G,D,F,C){var E=C;switch(F){case 0:return 14;break;case 1:this.popState();return 16;break;case 2:if(D.yytext==this.quoteChar){this.popState();this.begin("STRING");return 16}else{return 14}break;case 3:this.popState();this.begin("STRING");return 14;break;case 4:this.popState();this.quoteChar=D.yytext.substring(0);this.begin("QUOTE");return 15;break;case 5:this.quoteChar=D.yytext;this.popState();this.begin("QUOTE");return 15;break;case 6:this.begin("PRE_QUOTE");return 13;break;case 7:this.begin("PRE_QUOTE");return 7;break;case 8:return 14;break;case 9:this.popState();return 8;break;case 10:this.popState();return 9;break;case 11:this.popState();return 7;break;case 12:this.popState();return 13;break;case 13:return 14;break;case 14:this.popState();break;case 15:return"BUFFIN";break;case 16:return 9;break;case 17:return 10;break;case 18:return 12;break;case 19:return 7;break;case 20:this.begin("STRING");return 14;break;case 21:return 5;break}},rules:[/^(?:(\n|\\n))/,/^(?:([\'\"])(?=$))/,/^(?:([\'\"]))/,/^(?:(?=(\t)))/,/^(?:([\'\"]))/,/^(?:([\'\"]))/,/^(?:(\t|\\t)(?=[\'\"]))/,/^(?:(\n|\\n)(?=[\'\"]))/,/^(?:([a-zA-Z0-9_ ]+|.))/,/^(?:(\n\t|\\n\\t))/,/^(?:(\n\n|\\n\\n))/,/^(?:(\n|\\n))/,/^(?:(\t|\\t))/,/^(?:([a-zA-Z0-9_ ]+|.))/,/^(?:)/,/^(?:(\n\t|\\n\\t)(?=.))/,/^(?:(\n\n|\\n\\n))/,/^(?:(\t\n))/,/^(?:(\t))/,/^(?:(\n))/,/^(?:([a-zA-Z0-9_ ]+|.))/,/^(?:$)/],conditions:{BOF:{rules:[4,6,7,14,15,16,17,18,19,20,21],inclusive:true},PRE_QUOTE:{rules:[5,6,7,15,16,17,18,19,20,21],inclusive:true},QUOTE:{rules:[0,1,2,3,6,7,8,15,16,17,18,19,20,21],inclusive:true},STRING:{rules:[6,7,9,10,11,12,13,15,16,17,18,19,20,21],inclusive:true},INITIAL:{rules:[6,7,15,16,17,18,19,20,21],inclusive:true}}});return u})();k.lexer=b;function d(){this.yy={}}d.prototype=k;k.Parser=d;return new d})();if(typeof require!=="undefined"&&typeof exports!=="undefined"){exports.parser=parser;exports.Parser=parser.Parser;exports.parse=function(){return parser.parse.apply(parser,arguments)};exports.main=function commonjsMain(a){if(!a[1]){console.log("Usage: "+a[0]+" FILE");process.exit(1)}var b=require("fs").readFileSync(require("path").normalize(a[1]),"utf8");return exports.parser.parse(b)};if(typeof module!=="undefined"&&require.main===module){exports.main(process.argv.slice(1))}};