/*
 joel.espinosa@amite.mx
 @preserve 120728
 @license LGPL - http://www.gnu.org/licenses/lgpl.html
*/
var descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,c=360/e,d=e/360,b=Math.floor;a.rangeOK=1;a.radToDeg=function(a){return a*c};a.degToRad=function(a){return a*d};a.extend=function(a,b){if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var c in b.prototype)b.prototype.hasOwnProperty(c)&&(a.prototype[c]=b.prototype[c]);a.prototype.uber=b.prototype};a.convertFont=function(a){var b=a.split(","),a="";"bold"==b[1].toLowerCase()?a+="Bold ":"italic"==b[1].toLowerCase()||"italics"==
b[1].toLowerCase()?a+="Italic ":"bold+italic"==b[1].toLowerCase()&&(a+="Italic Bold ");a+=b[2]+"px ";b=b[0].split(" ")[0].toLowerCase();return"serif"==b||"times new roman"==b||"timesroman"==b?a+"'Times New Roman'":"sansserif"==b||"arial"==b||"helvetica"==b?a+"Arial":a+"'Courier New'"};a.drawLine=function(a,c,d,e,j,k,l){a.lineWidth=l||1;a.strokeStyle=k||"black";k=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(b(c)+k,b(d)+k);a.lineTo(b(e)+k,b(j)+k);a.stroke()};a.getColor=function(a,c){if("string"==typeof c)return c;
var d=a.evalExpression(c),e=b(255*d[0][0]),j=b(255*d[0][1]),k=b(255*d[0][2]);return"rgba("+e+","+j+","+k+","+(1-d[0][3])+")"};a.getFeatures=function(){a.hasJavaSupport=navigator.javaEnabled();var b=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&window.hasOwnProperty("ontouchstart")||b.match("android")&&!0;a.hasTouchSupport=navigator.userAgent.toLowerCase().match("qt")?!1:a.hasTouchSupport;b=document.createElement("canvas");a.hasCanvasSupport=b.getContext&&b.getContext("2d");
a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"))};a.openExternalFile=function(a){var b=null,c;c=!1;if(window.XMLHttpRequest)try{c=new XMLHttpRequest}catch(d){c=!1}else if(window.ActiveXObject)try{c=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{c=new ActiveXObject("Microsoft.XMLHTTP")}catch(k){c=!1}}c.open("GET",a,!1);try{c.send(null),b=c.responseText,b.match(String.fromCharCode(65533))&&(c.open("GET",a,!1),c.overrideMimeType("text/plain; charset=ISO-8859-1"),c.send(null),
b=c.responseText)}catch(l){console.log("El archivo ",a," no se pudo abrir"),b=null}return b};a.getCursorPosition=function(a){var b;a.touches?(a=a.touches[0],b=a.pageX,a=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(b=a.pageX,a=a.pageY):(b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,a=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:b,y:a}};a.buildSimpleRegularExpressionPattern=function(a){var b=a.trim(),a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};
b[0]==b[b.length-1]&&"'"==b[0]&&(a.ignoreCaps=!0,b=b.substring(1,b.length-1),"`"==b[0]&&"\u00b4"==b[b.length-1]&&(a.ignoreAcents=!0,b=b.substring(1,b.length-1)));"`"==b[0]&&"\u00b4"==b[b.length-1]&&(a.ignoreAcents=!0,b=b.substring(1,b.length-1),b[0]==b[b.length-1]&&"'"==b[0]&&(a.ignoreCaps=!0,b=b.substring(1,b.length-1)));"*"==b[0]&&"*"!=b[b.length-1]&&(b=b.substring(1)+"$");"*"!=b[0]&&"*"==b[b.length-1]&&(b="^"+b.substring(0,b.length-1));"*"==b[0]&&"*"==b[b.length-1]&&(b=b.substring(1,b.length-1));
b=b.replace(/\?/g,"[\\S\\s]{1}");a.regExp=b;return a};a.buildRegularExpresionsPatterns=function(b){for(var b=b.replace(/&squot;/g,"'").replace(/&amp;/g,"&").split("|"),c,d,e=0,j=b.length;e<j;e++){c=b[e].split("&");d=[];for(var k=0,l=c.length;k<l;k++)d.push(a.buildSimpleRegularExpressionPattern(c[k]));b[e]=d}return b};removeAcents=function(a){a=a.toString();return a.replace(/\u00e1/g,"a").replace(/\u00e9/g,"e").replace(/\u00ed/g,"i").replace(/\u00f3/g,"o").replace(/\u00fa/g,"u").replace(/\u00c1/g,
"A").replace(/\u00c9/g,"E").replace(/\u00cd/g,"I").replace(/\u00d3/g,"O").replace(/\u00da/g,"U").replace(/\u00f1/g,"n").replace(/\u00d1/g,"N")};a.escorrecto=function(b,c){for(var d=a.buildRegularExpresionsPatterns(b),e,j,c=removeAcents(c).toLowerCase(),k=0,l=d.length;k<l;k++){e=d[k];j=!0;for(var m=0,p=e.length;m<p;m++)e[m].regExp=removeAcents(e[m].regExp).toLowerCase(),j=j&&!!c.match(e[m].regExp);if(j)return 1}return 0};a.esCorrecto=function(b,c){for(var d=a.buildRegularExpresionsPatterns(b),e,j,
k=0,l=d.length;k<l;k++){e=d[k];j=!0;for(var m=0,p=e.length;m<p;m++)e[m].ignoreAcents&&(c=removeAcents(c),e[m].regExp=removeAcents(e[m].regExp)),e[m].ignoreCaps&&(c=c.toLowerCase(),e[m].regExp=e[m].regExp.toLowerCase()),j=j&&!!c.match(e[m].regExp);if(j)return 1}return 0};a.getTextWidth=function(b,c){a.ctx.font=c;return a.ctx.measureText(b).width};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.addCSSrules=function(){var a=document.createElement("meta");a.setAttribute("name",
"viewport");a.setAttribute("content","width=device-width, initial-scale=1.0, maximum-scale=10.0, user-scalable=yes");document.head.appendChild(a);(a=document.getElementById("StyleDescartesApps2"))&&a.parentNode.removeChild(a);a=document.createElement("style");a.type="text/css";a.id="StyleDescartesApps2";a.setAttribute("rel","stylesheet");document.head.appendChild(a);a.innerHTML="div.DescartesAppContainer{ border: 0px solid black; position: relative; overflow: hidden; top: 0px; left: 0px; }\ndiv.DescartesLoader{ background-color : #efefef; position: absolute; overflow: hidden; -moz-box-shadow: 0px 0px 0px #888; -webkit-box-shadow: 0px 0px 100px #888; box-shadow: 0px 0px 100px #888; background-image: linear-gradient(bottom, rgb(187,187,187) 0%, rgb(239,239,239) 50%, rgb(187,187,187) 100%); background-image: -o-linear-gradient(bottom, rgb(187,187,187) 0%, rgb(239,239,239) 50%, rgb(187,187,187) 100%); background-image: -moz-linear-gradient(bottom, rgb(187,187,187) 0%, rgb(239,239,239) 50%, rgb(187,187,187) 100%); background-image: -webkit-linear-gradient(bottom, rgb(187,187,187) 0%, rgb(239,239,239) 50%, rgb(187,187,187) 100%); background-image: -ms-linear-gradient(bottom, rgb(187,187,187) 0%, rgb(239,239,239) 50%, rgb(187,187,                   187) 100%); top: 0px; left: 0px; }\ndiv.DescartesLoaderImage{ background-repeat: no-repeat; background-position: center; position: absolute; overflow: hidden; top: 0px; left: 0px; }\ncanvas.DescartesLoaderBar{ position: absolute; overflow: hidden; top: 0px; left: 0px; }\ncanvas.DescartesSpace2DCanvas, canvas.DescartesSpace3DCanvas, div.blocker{ position: absolute; overflow: hidden; left: 0px; top: 0px; }\ndiv.DescartesSpace2DContainer, div.DescartesSpace3DContainer{ position: absolute; overflow: hidden; line-height: 0px; }\ncanvas.DescartesButton{ position: absolute; cursor: pointer; }\ndiv.DescartesSpinnerContainer, div.DescartesTextFieldContainer{ background: lightgray; position: absolute; overflow: hidden; }\ninput.DescartesSpinnerField, input.DescartesTextFieldField, input.DescartesMenuField, input.DescartesScrollbarField{ font-family: Arial; padding: 0px; border: 1px inset #666666; position: absolute; top: 0px; }\nlabel.DescartesSpinnerLabel, label.DescartesMenuLabel, label.DescartesScrollbarLabel{ line-height: normal; font-family: Arial; padding-top: 0%; text-align: center; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; background-color: lightgray; position: absolute; left: 0px; top: 0px; }\ndiv.DescartesGraphicControl{ border-style: none; position: absolute; }\nlabel.DescartesTextFieldLabel{ line-height: normal; font-family: Arial; padding-top: 0%; padding-bottom: 0%; text-align: center; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; }\ndiv.DescartesTextAreaContainer{ position: absolute; overflow: hidden; background: #c0d0d8; }\nselect.DescartesMenuSelect{ font-family: Arial; padding-top: 0%; text-align: center; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; background-color: white; position: absolute; left: 0px; top: 0px; }\ndiv.DescartesScrollbarContainer{ background: #eeeeee; overflow: hidden; position: absolute; }\n"};
a.addCSSrules();return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sin,c=Math.floor,d=Math.random,b=Math.round,g=String.fromCharCode;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){for(var b=Array(256),d=0;256>d;d++)b[d]=g(this.alfanum(c(Math.abs(7.5*(e(1*d-a)+e(1.4*d+a)+e(0.6*d-a)+e(2.2*d+a))))));return b.join("")};a.Krypto.prototype.encode=function(a){var b=c(31*d());this.key=this.getKey(b);return g(this.alfanum(b))+this.encripta(a)};
a.Krypto.prototype.decode=function(a){this.key=this.getKey(this.numalfa(a.charCodeAt(0)));return this.desencripta(a.substring(1))};a.Krypto.prototype.encripta=function(a){return this.bytesToString(this.encriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.encriptaAux=function(a){if(null==a||null==this.key)return null;for(var e=Array(3*a.length),g,j=0,k=a.length;j<k;j++)g=256*c(a[j]+128)+b(255*d())+65536*b(255*d()),g=c((g<<this.shift(j))/256),e[3*j]=this.alfanum(g%32),e[3*j+1]=this.alfanum(g/32%
32),e[3*j+2]=this.alfanum(g/1024%32);return e};a.Krypto.prototype.desencripta=function(a){return this.bytesToString(this.desencriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.desencriptaAux=function(a){if(null==a||null==this.key)return null;for(var b=Array(a.length/3),d,e=0,g=b.length;e<g;e++)d=this.numalfa(a[3*e])+32*this.numalfa(a[3*e+1])+1024*this.numalfa(a[3*e+2]),d=c(256*d>>this.shift(e)),d=c(d/256)%256-128,0>d&&(d+=256),b[e]=d;return b};a.Krypto.prototype.alfanum=function(a){a=c(a);return 10>
a?48+a:87+a};a.Krypto.prototype.numalfa=function(a){return 58>a?a-48:a-87};a.Krypto.prototype.stringToBytes=function(a){for(var b=Array(a.length),c=0,d=a.length;c<d;c++)b[c]=a.charCodeAt(c);return b};a.Krypto.prototype.bytesToString=function(a){for(var b=0,c=a.length;b<c;b++)a[b]=g(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){a=this.numalfa(this.key.charCodeAt(a%this.key.length));a=c(a/2%8);0==a&&(a=4);return a};a.Krypto.prototype.parseByte=function(a){a=parseInt(a);a=0>a?0:a;return 255<
a?255:a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Animation=function(e,c){this.parent=e;var d=e.evaluator,b=d.parser,g=new a.Auxiliary(e);this.delay=c.delay?b.parse(c.delay):b.parse("60");this.loop=c.loop?c.loop:!1;this.auto=void 0==c.auto&&2==this.parent.version?!0:c.auto;this.controls=c.controls;this.init=g.splitInstructions(b,c.init);this.doExpr=g.splitInstructions(b,c.doExpr);c.whileExpr&&(this.whileExpr=b.parse(c.whileExpr));var f=this;this.animationExec=function(){for(var a=
0,b=f.doExpr.length;a<b;a++)d.evalExpression(f.doExpr[a]);f.parent.update();f.playing&&(d.evalExpression(f.whileExpr)||f.loop)?f.timer=setTimeout(f.animationExec,d.evalExpression(f.delay)):f.stop()};this.playing=!1;this.auto&&this.play()};a.Animation.prototype.play=function(){this.playing?this.stop():(this.reinit(),this.playing=!0,this.timer=setTimeout(this.animationExec,this.parent.evaluator.evalExpression(this.delay)))};a.Animation.prototype.stop=function(){this.playing=!1;clearInterval(this.timer)};
a.Animation.prototype.reinit=function(){for(var a=0,c=this.init.length;a<c;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a){this.parent=a;this.evaluator=this.parent.evaluator};a.Action.prototype.execute=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Message=function(e,c){a.Action.call(this,e,c);this.parameter=c};a.extend(a.Message,a.Action);a.Message.prototype.execute=
function(){alert(this.parameter)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Calculate=function(e,c){a.Action.call(this,e,c);var d=this.evaluator,b=d.parser;this.parameter=c.replace(/&squot;/g,"'");this.parameter=this.parameter.replace(/;/g,"\\n");this.parameter=this.parameter.split("\\n")||[""];for(var g=[],f,i=0,h=this.parameter.length;i<h;i++)(f=b.parse(this.parameter[i],!0))&&g.push(f);this.parameter=g;this.actionExec=function(){for(var a=0,b=this.parameter.length;a<
b;a++)d.evalExpression(this.parameter[a])}};a.extend(a.Calculate,a.Action);a.Calculate.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(e,c){a.Action.call(this,e,c);this.parameter=c;this.target="_blank";var d=this.parameter.indexOf("target");-1!=d&&(this.target=this.parameter.substring(d),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,d-1));"javascript"==
this.parameter.substring(0,10)?(this.javascript=!0,this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),this.actionExec=function(){eval(this.parameter)}):("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,this.target)})};a.extend(a.OpenURL,a.Action);a.OpenURL.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),
descartesJS=function(a){if(a.loadLib)return a;a.OpenScene=function(e,c){a.Action.call(this,e,c);this.parameter=c;this.target="_blank";var d=this.parameter.indexOf("target");-1!=d&&(this.target=this.parameter.substring(d),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,d-1));"javascript"==this.parameter.substring(0,10)?(this.javascript=!0,this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),this.actionExec=function(){eval(this.parameter)}):
("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,this.target)})};a.extend(a.OpenScene,a.Action);a.OpenScene.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.About=function(e,c){a.Action.call(this,e,c);this.urlAbout=null;""!=c&&(this.urlAbout=window.location.href.substring(0,
window.location.href.lastIndexOf("/")+1)+c)};a.extend(a.About,a.Action);a.About.prototype.execute=function(){console.log(this.urlAbout);if(this.urlAbout)var a=window.open(this.urlAbout,"_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes");else a=window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes"),a.document.write("<hmtl><head><title>Cr\u00e9ditos</title></head><body><h1>Aqu\u00ed van los cr\u00e9ditos</h1></body></html>")};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.Config=function(e,c){a.Action.call(this,e,c)};a.extend(a.Config,a.Action);a.Config.prototype.execute=function(){window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'>"+this.parent.applet.outerHTML+"</xmp>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Init=function(e,c){a.Action.call(this,e,c)};a.extend(a.Init,a.Action);
a.Init.prototype.execute=function(){this.parent.init()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Clear=function(e,c){a.Action.call(this,e,c)};a.extend(a.Clear,a.Action);a.Clear.prototype.execute=function(){this.parent.clear()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Animate=function(e,c){a.Action.call(this,e,c)};a.extend(a.Animate,a.Action);a.Animate.prototype.execute=function(){this.parent.play()};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;a.InitAnimation=function(e,c){a.Action.call(this,e,c)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.PlayAudio=function(e,c){a.Action.call(this,e,c);this.filenameExpr=this.evaluator.parser.parse("'"+c.split(" ")[0].trim()+"'");this.filename=this.evaluator.evalExpression(this.filenameExpr);this.theAudio=this.parent.getAudio(this.filename)};
a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=function(){this.filename=this.evaluator.evalExpression(this.filenameExpr);theAudio=this.parent.getAudio(this.filename);theAudio.paused?theAudio.play():(theAudio.pause(),theAudio.currentTime=0.1)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Auxiliary=function(a,c){this.parent=a;this.evaluator=this.parent.evaluator;var d=a.evaluator.parser;this.expresion=this.id="";this.evaluate="onlyOnce";this.size=d.parse("3");
this.rows=d.parse("3");this.columns=d.parse("3");for(var b in c)c.hasOwnProperty(b)&&(this[b]=c[b])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};a.Auxiliary.prototype.splitInstructions=function(a,c){for(var d,b=[],c=c?c.split(";"):[""],g=0,f=c.length;g<f;g++)(d=a.parse(c[g],!0))&&b.push(d);return b};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Variable=function(e,c){a.Auxiliary.call(this,e,c);var d=this.evaluator.parser;this.expresionString=
this.expresion;(this.expresion=d.parse(this.expresionString))&&d.setVariable(this.id,this.expresion);this.editable&&this.registerTextField()};a.extend(a.Variable,a.Auxiliary);a.Variable.prototype.registerTextField=function(){var a=document.createElement("div"),c=document.createElement("label");c.appendChild(document.createTextNode("_"+this.id+"=_"));var d=document.createElement("input");d.value=this.expresionString;d.disabled=!this.editable;a.appendChild(c);a.appendChild(d);var b=this;d.onkeydown=
function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.evaluator.parser.setVariable(b.id,b.expresion),b.parent.update())};this.parent.editableRegion.textFields.push({container:a,type:"div"})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Constant=function(e,c){a.Auxiliary.call(this,e,c);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=function(){this.evaluator.setVariable(this.id,
this.evaluator.evalExpression(this.expresion))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector=function(e,c){a.Auxiliary.call(this,e,c);var d=this.evaluator,b=d.parser;this.expresion=this.expresion.split(";");var g;if(this.file){g=a.openExternalFile(this.file);null!=g&&(g=g.split("\n"));null==g||1==g.length&&""==g[0]?(g=[],this.size=0):(this.expresion=[],this.size=b.parse(g.length.toString()));for(var f,i=0,h=g.length;i<h;i++)this.expresion[i]=this.id+"["+i+"]="+
g[i],(f=g[i].match(/[\w-//]*(.png|.jpg|.gif|.svg|.PNG|.JPG|.GIF|.SVG)/g))&&this.parent.getImage(f)}i=0;for(h=this.expresion.length;i<h;i++)(g=b.parse(this.expresion[i],!0))&&"asign"!=g.type&&(g=b.parse(this.id+"["+i+"]="+this.expresion[i],!0)),this.expresion[i]=g;h=d.evalExpression(this.size);b=[];for(i=0;i<h;i++)b.push(0);d.vectors[this.id]=b;this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var a=this.evaluator;a.setVariable(this.id+".long",a.evalExpression(this.size));
for(var c=0,d=this.expresion.length;c<d;c++)a.evalExpression(this.expresion[c])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(e,c){a.Auxiliary.call(this,e,c);var d=this.evaluator;this.expresion=this.splitInstructions(d.parser,this.expresion);for(var b=d.evalExpression(this.rows),g=[],f,i=0,h=d.evalExpression(this.columns);i<h;i++){f=[];for(var j=0,k=b;j<k;j++)f.push(0);g[i]=f}d.matrices[this.id]=g;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=
function(){var a=this.evaluator;a.setVariable(this.id+".filas",a.evalExpression(this.rows));a.setVariable(this.id+".columnas",a.evalExpression(this.columns));for(var c=0,d=this.expresion.length;c<d;c++)a.evalExpression(this.expresion[c])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(e,c){a.Auxiliary.call(this,e,c);var d=this.evaluator,b=d.parser,g=this.id.indexOf("(");this.name=this.id.substring(0,g);this.params=this.id.substring(g+1,this.id.length-
1);this.domain=this.range?b.parse(this.range):b.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.init=this.splitInstructions(b,this.init);this.doExpr=this.splitInstructions(b,this.doExpr);this.whileExpr&&(this.whileExpr=b.parse(this.whileExpr));this.expresion=b.parse(this.expresion);var f=this;this.functionExec=this.algorithm?function(){if(f.numberOfParams==arguments.length){for(var b=[],c=0,e=f.params.length;c<e;c++){b[c]=d.getVariable(f.params[c]);
d.setVariable(f.params[c],arguments[c])}c=0;for(e=f.init.length;c<e;c++)d.evalExpression(f.init[c]);do{c=0;for(e=f.doExpr.length;c<e;c++)d.evalExpression(f.doExpr[c])}while(d.evalExpression(f.whileExpr));var g=d.evalExpression(f.expresion);a.rangeOK=d.evalExpression(f.domain);c=0;for(e=f.params.length;c<e;c++)d.setVariable(f.params[c],b[c]);return g}return 0}:function(){if(f.numberOfParams==arguments.length){for(var b=[],c=0,e=f.params.length;c<e;c++){b[c]=d.getVariable(f.params[c]);d.setVariable(f.params[c],
arguments[c])}var g=d.evalExpression(f.expresion);a.rangeOK=d.evalExpression(f.domain);c=0;for(e=f.params.length;c<e;c++)d.setVariable(f.params[c],b[c]);return g}return 0};d.setFunction(this.name,this.functionExec)};a.extend(a.Function,a.Auxiliary);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.AuxSequence=function(e,c){a.Auxiliary.call(this,e,c);var d=this.evaluator,b=d.parser,g=this.id.indexOf("(");this.name=this.id.substring(0,g);this.params=this.id.substring(g+1,this.id.length-
1);this.domain=this.range?b.parse(this.range):b.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.init=this.splitInstructions(b,this.init);this.doExpr=this.splitInstructions(b,this.doExpr);this.whileExpr&&(this.whileExpr=b.parse(this.whileExpr));this.expresion=b.parse(this.expresion);var f=this;this.functionExec=this.algorithm?function(){if(f.numberOfParams==arguments.length){for(var b=[],c=0,e=f.params.length;c<e;c++){b[c]=d.getVariable(f.params[c]);
d.setVariable(f.params[c],arguments[c])}c=0;for(e=f.init.length;c<e;c++)d.evalExpression(f.init[c]);do{c=0;for(e=f.doExpr.length;c<e;c++)d.evalExpression(f.doExpr[c])}while(d.evalExpression(f.whileExpr));var g=d.evalExpression(f.expresion);a.rangeOK=d.evalExpression(f.domain);c=0;for(e=f.params.length;c<e;c++)d.setVariable(f.params[c],b[c]);return g}return 0}:function(){if(f.numberOfParams==arguments.length){for(var b=[],c=0,e=f.params.length;c<e;c++){b[c]=d.getVariable(f.params[c]);d.setVariable(f.params[c],
arguments[c])}var g=d.evalExpression(f.expresion);a.rangeOK=d.evalExpression(f.domain);c=0;for(e=f.params.length;c<e;c++)d.setVariable(f.params[c],b[c]);return g}return 0};d.setFunction(this.name,this.functionExec)};a.extend(a.AuxSequence,a.Auxiliary);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Algorithm=function(e,c){a.Auxiliary.call(this,e,c);var d=this.evaluator,b=d.parser;this.init=this.splitInstructions(b,this.init);this.doExpr=this.splitInstructions(b,this.doExpr);
this.whileExpr&&(this.whileExpr=b.parse(this.whileExpr));this.algorithmExec=function(){for(var a=0,b=this.init.length;a<b;a++)d.evalExpression(this.init[a]);do{a=0;for(b=this.doExpr.length;a<b;a++)d.evalExpression(this.doExpr[a])}while(d.evalExpression(this.whileExpr))}};a.extend(a.Algorithm,a.Auxiliary);a.Algorithm.prototype.update=function(){this.algorithmExec();"onlyOnce"==this.evaluate&&(this.update=function(){})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Event=
function(e,c){a.Auxiliary.call(this,e,c);var d=this.evaluator;this.condition=d.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){d.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=d.evalExpression(this.condition);if(this.parent.version==3){if(a!=this.lastEvaluation){this.action.execute();
this.lastEvaluation=a?true:false}}else if(a&&!this.lastEvaluation){this.action.execute();this.lastEvaluation=true}else if(!a&&this.lastEvaluation)this.lastEvaluation=false});"always"==this.execution&&(this.eventExec=function(){d.evalExpression(this.condition)&&this.action.execute()})};a.extend(a.Event,a.Auxiliary);a.Event.prototype.update=function(){this.eventExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Graphic=function(e,c){this.parent=e;var d=this.parent.evaluator.parser;
this.evaluator=e.evaluator;this.spaceID="E0";this.type="";this.background=!1;2!=this.parent.version?(this.color="#20303a",this.parent.arquimedes&&(this.color="black")):this.color="blue";this.drawif=d.parse("1");this.abs_coord=!1;this.family=this.trace="";this.family_interval=d.parse("[0,1]");this.family_steps=d.parse("8");this.parameter="t";this.parameter_interval=d.parse("[0,1]");this.parameter_steps=d.parse("8");this.fillM=this.fillP=this.fill="";this.width=-1;this.editable=!1;this.info="";this.font=
"Monospaced,PLAIN,12";this.fixed=!0;this.size=d.parse("2");this.text="";this.decimals=d.parse("2");this.spear=d.parse("8");this.arrow="#ee0022";this.center=d.parse("(0,0)");this.radius=d.parse("1");this.init=d.parse("0");this.end=d.parse("90");this.file="";this.inirot=d.parse("0");for(var b in c)c.hasOwnProperty(b)&&(this[b]=c[b]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=d.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;
this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backgroundCanvas.getContext("2d"));this.font=a.convertFont(this.font)};a.Graphic.prototype.getSpace=function(){for(var a=this.parent.spaces,c,d=0,b=a.length;d<b;d++)if(c=a[d],c.id==this.spaceID)return c;return a[0]};a.Graphic.prototype.getFamilyValues=function(){var a=this.evaluator,c=a.evalExpression(this.family_interval);this.familyInf=c[0][0];this.familySup=c[0][1];this.fSteps=Math.round(a.evalExpression(this.family_steps));
this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,c,d){var b=this.evaluator;this.getFamilyValues();var g=b.getVariable(this.family);if(0<=this.fSteps)for(var f=0,i=this.fSteps;f<=i;f++)b.setVariable(this.family,this.familyInf+f*this.family_sep),b.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,c,d));b.setVariable("_Text_H_",0);b.setVariable(this.family,g)};a.Graphic.prototype.draw=function(a,c){""!=this.family?this.drawFamilyAux(this.ctx,
a,c):this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.ctx,a,c))};a.Graphic.prototype.drawTrace=function(a,c){""!=this.family?this.drawFamilyAux(this.traceCtx,a,c):this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,a,c))};a.Graphic.prototype.drawText=function(e,c,d,b,g,f,i,h,j,k){if("rtfNode"==c.type)e.fillStyle=g,e.strokeStyle=g,e.textBaseline="alphabetic",c.draw(e,d,b,j,k,i);else{var d=d+(f.match("Arial")?-2:f.match("Times")?-2:0),l=
this.evaluator;e.fillStyle=a.getColor(l,g);e.font=f;e.textAlign=i;e.textBaseline=h;this.fontSize=(this.fontSize=f.match(/(\d+)px/))?this.fontSize[1]:"10";this.border&&(e.strokeStyle=a.getColor(l,this.border),e.lineWidth=parseFloat(this.fontSize)/12);f=1.2*this.fontSize;if(c[0]&&c[0].type){i=0;for(h=c.length;i<h;i++)g=l.evalExpression(c[i],j,k),this.border&&e.strokeText(g,d,b+f*i),e.fillText(g,d,b+f*i)}else{i=0;for(h=c.length;i<h;i++)g=c[i],this.border&&e.strokeText(g,d,b+f*i),e.fillText(g,d,b+f*i)}}};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,c=2*Math.PI;a.Equation=function(c,b){a.Graphic.call(this,c,b);this.width=-1==this.width?this.evaluator.parser.parse("1"):this.width;this.generateStroke();this.parseExpresion();(this.visible=2==this.parent.version&&void 0==this.visible?!0:!1)&&this.registerTextField()};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpresion=function(){if("compOperator"==this.expresion.type){var c=this.expresion.childs[0],
b=this.expresion.childs[1];"identifier"==c.type&&"y"==c.value&&!b.contains("y")?(this.funExpr=b,this.drawAux=this.drawAuxFunY):"identifier"==b.type&&"y"==b.value&&!c.contains("y")?(this.funExpr=c,this.drawAux=this.drawAuxFunY):"identifier"==c.type&&"x"==c.value&&!b.contains("x")?(this.funExpr=b,this.drawAux=this.drawAuxFunX):"identifier"==b.type&&"x"==b.value&&!c.contains("x")&&(this.funExpr=b,this.drawAux=this.drawAuxFunX)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.generateStroke=
function(){this.auxCanvas=document.createElement("canvas");var a=parseInt(this.evaluator.evalExpression(this.width));this.width_2=parseInt(a/2)||1;this.auxCanvas.setAttribute("width",a);this.auxCanvas.setAttribute("height",a);this.auxCtx=this.auxCanvas.getContext("2d");this.auxCtx.beginPath();this.auxCtx.arc(this.width_2,this.width_2,this.width_2,0,2*Math.PI,!1);this.auxCtx.fill()};a.Equation.prototype.update=function(){};a.Equation.prototype.draw=function(){""!=this.family?this.drawFamilyAux(this.ctx,
this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,this.color))};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(c,b,g){c.lineWidth=1;var b=this.evaluator,f=b.parser,i=this.space;a.getColor(b,this.color);c.fillStyle=g;g=b.evalExpression(this.width);e(g);f.getVariable("x");f.getVariable("y");var g=i.w,f=i.h,h=e(g/8);3>h&&(h=3);var j=e(f/8);3>j&&(j=3);for(var k=[],l=new a.R2,m=new a.R2,p=new a.R2,
o,q,s,n,t,w,v,r,y,x=e(j/2);x<f;x+=j)for(var z=e(h/2);z<g;z+=h)if(this.abs_coord?(q=this.newt.findZero(new a.R2(z,x)),b.setVariable("x",q.x),b.setVariable("y",q.y),o=new a.R2(q.x,q.y)):(q=this.newt.findZero(new a.R2(i.getRelativeX(z),i.getRelativeY(x))),b.setVariable("x",q.x),b.setVariable("y",q.y),o=new a.R2(i.getAbsoluteX(q.x),i.getAbsoluteY(q.y))),s=e(o.ix()),n=e(o.iy()),!(0>s||s>=g||0>n||n>=f||k[s+n*i.w]))if(k[s+n*i.w]=!0,l.x=q.x,l.y=q.y,m.x=q.x,m.y=q.y,t=this.newt.getUnitNormal(),!(0==t.x&&0==
t.y)){t.rotL90();p.x=t.x;p.y=t.y;v=w=0;for(r=!1;2>v;){r&&(p.x=-t.x,p.y=-t.y,q.x=l.x,q.y=l.y,m.x=q.x,m.y=q.y,o=this.abs_coord?new a.R2(q.x,q.y):new a.R2(i.getAbsoluteX(q.x),i.getAbsoluteY(q.y)),s=o.ix(),n=o.iy(),r=!1,w=0);this.abs_coord?(q.x+=p.x,q.y+=p.y):(q.x+=p.x/i.scale,q.y+=p.y/i.scale);q=this.newt.findZero(q);b.setVariable("x",q.x);b.setVariable("y",q.y);p.x=q.x-m.x;p.y=q.y-m.y;p.normalize();if(0==p.x&&0==p.y)break;m.x=q.x;m.y=q.y;o=this.abs_coord?new a.R2(q.x,q.y):new a.R2(i.getAbsoluteX(q.x),
i.getAbsoluteY(q.y));y=e(o.ix());o=e(o.iy());if(y!=s||o!=n)if(s=y,n=o,0<=s&&s<g&&0<=n&&n<f)if(w=0,k[s+n*i.w])break;else k[s+n*i.w]=!0,a.rangeOK&&c.drawImage(this.auxCanvas,s-this.width_2,n-this.width_2);else r=!0,v++;else 4<++w&&(r=!0,v++)}}};a.Equation.prototype.drawAuxFunY=function(c){var b=this.evaluator,e=this.space,f=e.w,i=1/e.scale,h=e.getAbsoluteY(0),j=b.evalExpression(this.width),k=a.getColor(b,this.color),l=a.getColor(b,this.fillM),m=a.getColor(b,this.fillP);c.fillStyle=k;var p=e.getRelativeX(0),
o,q,s,n;b.setVariable("x",p);for(var t=e.getAbsoluteX(p),w=e.getAbsoluteY(b.evalExpression(this.funExpr)),v=0,r,y,x=1;x<f;x++){o=p+x*i;b.setVariable("x",o);q=b.evalExpression(this.funExpr);b.setVariable("y",q);s=e.getAbsoluteX(o);n=e.getAbsoluteY(q);r=Math.min(v,q);y=Math.max(v,q);r=new a.R2(r,y);if(void 0!==q&&a.rangeOK&&b.evalExpression(this.drawif)&&!this.hasSingularity(i,o,"x",o-i,v,o,q,r)){if(this.fillM||this.fillP)c.lineWidth=1,c.strokeStyle=n>h?l:m,c.beginPath(),c.moveTo(s+0.5,n),c.lineTo(s+
0.5,h),c.stroke();c.lineWidth=j;c.strokeStyle=k;c.beginPath();c.moveTo(t,w);c.lineTo(s,n);c.stroke()}v=q||0;t=s;w=n}};a.Equation.prototype.drawAuxFunX=function(c){var b=this.evaluator,e=this.space,f=e.w,i=1/e.scale,h=e.getAbsoluteX(0),j=b.evalExpression(this.width),k=a.getColor(b,this.color),l=a.getColor(b,this.fillM),m=a.getColor(b,this.fillP);c.fillStyle=k;var p=e.getRelativeX(0),o,q,s,n;b.setVariable("x",p);for(var t=e.getAbsoluteX(b.evalExpression(this.funExpr)),w=e.getAbsoluteY(p),v=0,r,y,x=
1;x<f;x++)if(o=p+x*i,b.setVariable("y",o),q=b.evalExpression(this.funExpr),b.setVariable("x",q),s=e.getAbsoluteX(q),n=e.getAbsoluteY(o),r=Math.min(v,q),y=Math.max(v,q),r=new a.R2(r,y),void 0!==o&&a.rangeOK&&b.evalExpression(this.drawif)){if(!this.hasSingularity(i,o,"y",o-i,v,o,q,r)){if(this.fillM||this.fillP)c.lineWidth=1,c.strokeStyle=s>h?l:m,c.beginPath(),c.moveTo(s,n+0.5),c.lineTo(h,n+0.5),c.stroke();c.lineWidth=j;c.strokeStyle=k;c.beginPath();c.moveTo(t,w);c.lineTo(s,n);c.stroke()}v=q||0;t=s;
w=n}};a.Equation.prototype.hasSingularity=function(a,b,c,e,i,h,j,k){if(1.0E-12>Math.abs(h-e)||1.0E-8>Math.abs(h-e)&&Math.abs(j-i)>Math.abs(a))return!0;var l=!1,m=(e+h)/2;this.evaluator.setVariable(c,m);var p=this.evaluator.evalExpression(this.funExpr);try{k.x<=p&&p<=k.y?l=!1:(k.x=Math.min(k.x,p),k.y=Math.max(k.y,p),l=this.hasSingularity(a,b,c,e,i,m,p,k)||this.hasSingularity(a,b,c,m,p,h,j,k))}catch(o){l=!0}return l};a.drawPixel=function(a,b,e,f){a.moveTo(b,e);a.arc(b,e,f,0,c,!1)};a.Equation.prototype.registerTextField=
function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parseExpresion(),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Curve=function(e,c){a.Graphic.call(this,e,c);this.width=-1==this.width?this.evaluator.parser.parse("1"):this.width;(this.visible=2==this.parent.version&&
void 0==this.visible?!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);a.Curve.prototype.update=function(){var a=this.evaluator,c=a.evalExpression(this.parameter_interval);this.paraInf=c[0][0];this.paraSup=c[0][1];this.pSteps=a.evalExpression(this.parameter_steps);this.paraSep=0<this.pSteps?Math.abs(this.paraSup-this.paraInf)/this.pSteps:0};a.Curve.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Curve.prototype.drawTrace=function(){this.uber.drawTrace.call(this,
this.fill,this.trace)};a.Curve.prototype.drawAux=function(e,c,d){var b=this.evaluator,g=this.space,f=this.evaluator.evalExpression(this.width);0>=f&&(f=1.0E-6);e.lineWidth=f;e.lineCap="round";e.lineJoin="round";e.fillStyle=a.getColor(b,c);e.strokeStyle=a.getColor(b,d);c=b.getVariable(this.parameter);e.beginPath();b.setVariable(this.parameter,this.paraInf);f=b.evalExpression(this.expresion);this.exprX=this.abs_coord?f[0][0]:g.getAbsoluteX(f[0][0]);this.exprY=this.abs_coord?f[0][1]:g.getAbsoluteY(f[0][1]);
var i,h,j;this.rotateExp&&(i=a.degToRad(this.evaluator.evalExpression(this.rotateExp)),h=Math.cos(i),i=Math.sin(i),f=this.exprX*h-this.exprY*i,j=this.exprX*i+this.exprY*h,this.exprX=f,this.exprY=j);e.moveTo(this.exprX+0.5,this.exprY+0.5);for(d=1;d<=this.pSteps;d++)b.setVariable(this.parameter,this.paraInf+d*this.paraSep),f=b.evalExpression(this.expresion),this.exprX=this.abs_coord?f[0][0]:g.getAbsoluteX(f[0][0]),this.exprY=this.abs_coord?f[0][1]:g.getAbsoluteY(f[0][1]),this.rotateExp&&(f=this.exprX*
h-this.exprY*i,j=this.exprX*i+this.exprY*h,this.exprX=f,this.exprY=j),e.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&e.fill();e.stroke();b.setVariable(this.parameter,c)};a.Curve.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var c=this;a.onkeydown=function(a){13==a.keyCode&&(c.expresion=c.evaluator.parser.parse(this.value),c.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI;a.Sequence=function(c,d){a.Graphic.call(this,c,d)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){var c=this.evaluator,d=c.evalExpression(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1];if(this.rotateExp){var b=a.degToRad(c.evalExpression(this.rotateExp)),d=Math.cos(b),e=Math.sin(b),b=this.exprX*d-this.exprY*e,d=this.exprX*e+this.exprY*d;this.exprX=b;this.exprY=d}c=c.evalExpression(this.range);this.rangeInf=
c[0][0];this.rangeMax=c[0][1]};a.Sequence.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Sequence.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Sequence.prototype.drawAux=function(c,d){var b=this.evaluator,g,f,i,h=Math.ceil(b.evalExpression(this.size)-0.4);c.fillStyle=a.getColor(b,d);c.beginPath();this.rangeInf>this.rangeMax&&(i=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=i);for(var j=b.getVariable("n"),k=this.rangeInf,
l=this.rangeMax;k<=l;k++)b.setVariable("n",k),i=b.evalExpression(this.expresion),this.exprX=i[0][0],this.exprY=i[0][1],this.abs_coord?g=i[0][1]:(g=this.space.getAbsoluteX(i[0][0]),f=this.space.getAbsoluteY(i[0][1])),c.moveTo(g,f),c.arc(g,f,h,0,e,!0);b.setVariable("n",j);c.fill();this.text!=[""]&&this.uber.drawText.call(this,c,this.text,g+h,f-h,this.color,this.font,"start","alphabetic",b.evalExpression(this.decimals),this.fixed)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e=2*Math.PI;a.Point=function(c,d){a.Graphic.call(this,c,d)};a.extend(a.Point,a.Graphic);a.Point.prototype.update=function(){var c=this.evaluator,d=c.evalExpression(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1];if(this.rotateExp){var d=a.degToRad(c.evalExpression(this.rotateExp)),c=Math.cos(d),b=Math.sin(d),d=this.exprX*c-this.exprY*b,c=this.exprX*b+this.exprY*c;this.exprX=d;this.exprY=c}};a.Point.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Point.prototype.drawTrace=
function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Point.prototype.drawAux=function(c,d){var b=this.evaluator,g=this.abs_coord?this.exprX:this.space.getAbsoluteX(this.exprX),f=this.abs_coord?this.exprY:this.space.getAbsoluteY(this.exprY),i=Math.ceil(b.evalExpression(this.size)-0.4);c.fillStyle=a.getColor(b,d);c.beginPath();c.arc(g,f,i,0,e,!0);c.fill();this.text!=[""]&&this.uber.drawText.call(this,c,this.text,g+i,f-i,this.color,this.font,"start","alphabetic",b.evalExpression(this.decimals),
this.fixed)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI;a.Segment=function(c,d){a.Graphic.call(this,c,d);this.width=-1==this.width?this.evaluator.parser.parse("1"):this.width};a.extend(a.Segment,a.Graphic);a.Segment.prototype.update=function(){var c=this.evaluator,d=c.evalExpression(this.expresion);this.endPoints=[];for(var b=0,e=d.length;b<e;b++)this.endPoints[b]={x:d[b][0],y:d[b][1]};if(this.rotateExp)for(var b=a.degToRad(c.evalExpression(this.rotateExp)),
c=Math.cos(b),d=Math.sin(b),f,i,b=0,e=this.endPoints.length;b<e;b++)f=this.endPoints[b].x*c-this.endPoints[b].y*d,i=this.endPoints[b].x*d+this.endPoints[b].y*c,this.endPoints[b].x=f,this.endPoints[b].y=i};a.Segment.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Segment.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Segment.prototype.drawAux=function(c,d,b){var g=this.evaluator,f=g.evalExpression(this.width);0>=f&&(f=1.0E-6);c.lineWidth=
f;f=g.evalExpression(this.size);c.fillStyle=a.getColor(g,d);c.strokeStyle=a.getColor(g,b);c.lineCap="round";var d=10+c.lineWidth,b=0==c.lineWidth%2?0:0.5,i,h,j,k;this.abs_coord?(i=this.endPoints[0].x,h=this.endPoints[0].y,j=this.endPoints[1].x,k=this.endPoints[1].y):(i=this.space.getAbsoluteX(this.endPoints[0].x),h=this.space.getAbsoluteY(this.endPoints[0].y),j=this.space.getAbsoluteX(this.endPoints[1].x),k=this.space.getAbsoluteY(this.endPoints[1].y));f=g.evalExpression(this.size);0>f&&(f=0);c.beginPath();
c.moveTo(i+b,h+b);c.lineTo(j+b,k+b);this.text!=[""]&&this.uber.drawText.call(this,c,this.text,(i+j)/2+d,(h+k)/2-d,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed);c.stroke();c.beginPath();c.arc(i,h,f,0,e,!0);c.arc(j,k,f,0,e,!0);c.fill()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Arrow=function(c,d){a.Graphic.call(this,c,d);this.width=-1==this.width?this.evaluator.parser.parse("5"):this.width};a.extend(a.Arrow,a.Graphic);
a.Arrow.prototype.update=function(){var c=this.evaluator,d=c.evalExpression(this.expresion);this.endPoints=[];for(var b=0,e=d.length;b<e;b++)this.endPoints[b]={x:d[b][0],y:d[b][1]};if(this.rotateExp)for(var b=a.degToRad(c.evalExpression(this.rotateExp)),c=Math.cos(b),d=Math.sin(b),f,i,b=0,e=this.endPoints.length;b<e;b++)f=this.endPoints[b].x*c-this.endPoints[b].y*d,i=this.endPoints[b].x*d+this.endPoints[b].y*c,this.endPoints[b].x=f,this.endPoints[b].y=i};a.Arrow.prototype.draw=function(){this.uber.draw.call(this,
this.arrow,this.color)};a.Arrow.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.arrow,this.trace)};a.Arrow.prototype.drawAux=function(c,d,b){var g=this.evaluator,f=this.space;g.evalExpression(this.size);var i=g.evalExpression(this.width);1>i&&(i=1);var h=Math.ceil(i/2),j=f.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);var k=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);c.fillStyle=
a.getColor(g,d);c.strokeStyle=a.getColor(g,b);c.lineWidth=1;var l,m,p;this.abs_coord?(d=this.endPoints[0].x,l=this.endPoints[0].y,m=this.endPoints[1].x,f=this.endPoints[1].y):(d=f.getAbsoluteX(this.endPoints[0].x),l=f.getAbsoluteY(this.endPoints[0].y),m=f.getAbsoluteX(this.endPoints[1].x),f=f.getAbsoluteY(this.endPoints[1].y));p=g.evalExpression(this.spear);0>p&&(p=0);c.save();c.translate(d,l,k);this.abs_coord?0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?c.rotate(this.angle):c.rotate(-this.angle):
(k*=j,0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?c.rotate(-this.angle):c.rotate(this.angle));c.beginPath();c.moveTo(-h+0.5,e(-h)+0.5);c.lineTo(e(k-p-i)+0.5,e(-h)+0.5);c.lineTo(e(k-2*p)+0.5,e(-p-h)+0.5);c.lineTo(e(k)+0.5,0);c.lineTo(e(k-2*p)+0.5,e(p+h)-0.5);c.lineTo(e(k-p-i)+0.5,e(h)-0.5);c.lineTo(-h+0.5,e(h)-0.5);c.closePath();c.stroke();c.fill();c.restore();this.text!=[""]&&this.uber.drawText.call(this,c,this.text,(d+m)/2,(l+f)/2,b,this.font,"start","alphabetic",g.evalExpression(this.decimals),
this.fixed)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Polygon=function(e,c){a.Graphic.call(this,e,c);this.width=-1==this.width?this.evaluator.parser.parse("1"):this.width};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){var e=this.evaluator,c=e.evalExpression(this.expresion);this.endPoints=[];for(var d=0,b=c.length;d<b;d++)this.endPoints[d]={x:c[d][0],y:c[d][1]};if(this.rotateExp)for(var d=a.degToRad(e.evalExpression(this.rotateExp)),e=Math.cos(d),
c=Math.sin(d),g,f,d=0,b=this.endPoints.length;d<b;d++)g=this.endPoints[d].x*e-this.endPoints[d].y*c,f=this.endPoints[d].x*c+this.endPoints[d].y*e,this.endPoints[d].x=g,this.endPoints[d].y=f};a.Polygon.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Polygon.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Polygon.prototype.drawAux=function(e,c,d){var b=this.evaluator,g=b.evalExpression(this.width);0>=g&&(g=1.0E-6);e.lineWidth=g;e.fillStyle=
a.getColor(b,c);e.strokeStyle=a.getColor(b,d);e.lineCap="round";e.lineJoin="round";c=0==this.ctx.lineWidth%2?0:0.5;d=this.abs_coord?this.endPoints[0].x:this.space.getAbsoluteX(this.endPoints[0].x);b=this.abs_coord?this.endPoints[0].y:this.space.getAbsoluteY(this.endPoints[0].y);e.beginPath();e.moveTo(d+c,b+c);for(var g=1,f=this.endPoints.length;g<f;g++)d=this.abs_coord?this.endPoints[g].x:this.space.getAbsoluteX(this.endPoints[g].x),b=this.abs_coord?this.endPoints[g].y:this.space.getAbsoluteY(this.endPoints[g].y),
e.lineTo(d+c,b+c);this.fill&&e.fill();e.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Arc=function(c,d){a.Graphic.call(this,c,d);this.width=-1==this.width?this.evaluator.parser.parse("1"):this.width};a.extend(a.Arc,a.Graphic);a.Arc.prototype.update=function(){var c=this.evaluator,d=c.evalExpression(this.center);this.exprX=d[0][0];this.exprY=d[0][1];if(this.rotateExp){var b=a.degToRad(c.evalExpression(this.rotateExp)),d=Math.cos(b),e=Math.sin(b),
b=this.exprX*d-this.exprY*e,d=this.exprX*e+this.exprY*d;this.exprX=b;this.exprY=d}b=c.evalExpression(this.init);d=c.evalExpression(this.end);if("(expr)"==this.init.type&&"(expr)"==this.end.type||"[expr]"==this.init.type&&"[expr]"==this.end.type||"(expr)"==this.init.type&&"[expr]"==this.end.type||"[expr]"==this.init.type&&"(expr)"==this.end.type){this.vectors=!0;var c=b[0][0],e=b[0][1],f=d[0][0],i=d[0][1],d=Math.acos((1*c+0*e)/Math.sqrt(c*c+e*e)),b=Math.acos((1*f+0*i)/Math.sqrt(f*f+i*i));0<c&&0<e&&
!this.abs_coord&&(d=2*Math.PI-d);0<c&&0>e&&this.abs_coord&&(d=2*Math.PI-d);0>c&&0>e&&this.abs_coord&&(d=2*Math.PI-d);0>c&&0<e&&!this.abs_coord&&(d=2*Math.PI-d);0<f&&0<i&&!this.abs_coord&&(b=2*Math.PI-b);0<f&&0>i&&this.abs_coord&&(b=2*Math.PI-b);0>f&&0>i&&this.abs_coord&&(b=2*Math.PI-b);0>f&&0<i&&!this.abs_coord&&(b=2*Math.PI-b);c=Math.min(d,b);e=Math.max(d,b);d=c;b=e;b-d>Math.PI&&this.abs_coord&&(d=e,b=c);b-d<=Math.PI&&!this.abs_coord&&(d=e,b=c);this.iniAng=d;this.endAng=b}else this.vectors=!1,this.iniAng=
a.degToRad(b),this.endAng=a.degToRad(d)};a.Arc.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Arc.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Arc.prototype.drawAux=function(c,d,b){var g=this.evaluator,f=this.space,i=this.abs_coord?e(this.exprX)+0.5:e(f.getAbsoluteX(this.exprX))+0.5,h=this.abs_coord?e(this.exprY)+0.5:e(f.getAbsoluteY(this.exprY))+0.5,j=g.evalExpression(this.radius);if(!this.vectors&&this.iniAng>this.endAng){var k=
this.iniAng;this.iniAng=this.endAng;this.endAng=k}0>j&&(j=0);k=!1;this.abs_coord||(j*=f.scale,this.vectors||(this.iniAng=-this.iniAng,this.endAng=-this.endAng,k=!0));this.vectors&&(k=this.abs_coord?!1:!0);f=g.evalExpression(this.width);0>=f&&(f=1.0E-6);c.lineWidth=f;c.lineCap="round";c.fillStyle=a.getColor(g,d);c.strokeStyle=a.getColor(g,b);this.fill&&(c.beginPath(),c.moveTo(i,h),c.arc(i,h,j,this.iniAng,this.endAng,k),c.fill());c.beginPath();c.arc(i,h,j,this.iniAng,this.endAng,k);c.stroke();this.text!=
[""]&&this.uber.drawText.call(this,c,this.text,i+1,h-1,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Fill=function(e,c){a.Graphic.call(this,e,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Fill.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Fill.prototype.drawAux=
function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Text=function(e,c){a.Graphic.call(this,e,c);this.align||(this.align="start");-1==this.width&&(this.width=this.evaluator.parser.parse("0"));this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){var e=this.evaluator,c=e.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];if(this.rotateExp){var c=a.degToRad(e.evalExpression(this.rotateExp)),e=Math.cos(c),d=Math.sin(c),c=
this.exprX*e-this.exprY*d,e=this.exprX*d+this.exprY*e;this.exprX=c;this.exprY=e}};a.Text.prototype.draw=function(){this.uber.draw.call(this,this.color)};a.Text.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.color)};a.Text.prototype.drawAux=function(a,c){var d=this.splitText(this.text);this.text!=[""]&&this.uber.drawText.call(this,a,d,parseFloat(this.exprX)+5,parseFloat(this.exprY),c,this.font,this.align,"hanging",this.evaluator.evalExpression(this.decimals),this.fixed)};a.Text.prototype.splitText=
function(a){var c=this.evaluator.evalExpression(this.width),d,b,g=[];this.ctx.font=this.font;this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?this.fontSize[1]:"10";if(20<=c&&"undefined"!=a.type){for(var f=0,i=a.length;f<i;f++)d=this.evaluator.evalExpression(a[f],this.evaluator.evalExpression(this.decimals),this.fixed).trim(),b=this.ctx.measureText(d).width,b>c?g=g.concat(this.splitWords(d,c)):g.push(d);a=Math.floor(1.2*this.fontSize)*g.length;this.evaluator.setVariable("_Text_H_",a);return g}this.evaluator.setVariable("_Text_H_",
0);this.evaluator.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=function(a,c){var d=a,b=[],g,f,i,h,j=!1;do i=Math.floor(d.length*(c/this.ctx.measureText(d).width))+1,g=d.slice(0,i),""!=g&&" "==g[0]&&(d=d.slice(1),g=d.slice(0,i)),j=d[i-1]&&d[i]&&" "!=d[i-1]&&" "!=d[i],h=g.lastIndexOf(" "),f=this.ctx.measureText(g).width,f>=c?(i=-1!=h?h:i-1,g=d.slice(0,i)):j&&-1!=h&&(i=h,g=d.slice(0,i)),b.push(g),d=d.slice(i);while(""!=d);return b};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.Image=function(e,c){a.Graphic.call(this,e,c);this.img=new Image;this.img.ready=0;this.img.onload=function(){this.ready=1;this.onload=function(){}};this.img.src=this.evaluator.evalExpression(this.file);this.scaleY=this.scaleX=1};a.extend(a.Image,a.Graphic);a.Image.prototype.update=function(){var e=this.evaluator,c=e.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];if(this.rotateExp){var d=a.degToRad(e.evalExpression(this.rotateExp)),b=Math.cos(d),g=Math.sin(d),d=this.exprX*b-
this.exprY*g,b=this.exprX*g+this.exprY*b;this.exprX=d;this.exprY=b}if(4==c[0].length&&(this.centered=!0,this.scaleX=c[0][2],0==this.scaleX&&(this.scaleX=1.0E-5),this.scaleY=c[0][3],0==this.scaleY))this.scaleY=1.0E-5;if(c[1]&&2==c[1].length&&(this.centered=!0,this.scaleX=c[1][0],0==this.scaleX&&(this.scaleX=1.0E-5),this.scaleY=c[1][1],0==this.scaleY))this.scaleY=1.0E-5;if((e=e.evalExpression(this.file))||""==e)this.img=this.parent.getImage(e)};a.Image.prototype.draw=function(){this.uber.draw.call(this)};
a.Image.prototype.drawTrace=function(){this.uber.drawTrace.call(this)};a.Image.prototype.drawAux=function(e){var c=this.evaluator;if(this.img&&this.img.ready&&this.img.complete){var d=this.centered?0:this.img.width/2,b=this.centered?0:this.img.height/2,g=this.abs_coord?this.exprX:this.space.getAbsoluteX(this.exprX),f=this.abs_coord?this.exprY:this.space.getAbsoluteY(this.exprY),i=a.degToRad(-c.evalExpression(this.inirot));e.translate(g+d,f+b);e.rotate(i);e.scale(this.scaleX,this.scaleY);this.opacity&&
(e.globalAlpha=c.evalExpression(this.opacity));e.drawImage(this.img,-this.img.width/2,-this.img.height/2);e.setTransform(1,0,0,1,0,0);e.globalAlpha=1}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Macro=function(e,c){a.Graphic.call(this,e,c);this.graphics=[];var d=e.lessonParser,b=new a.Tokenizer,g;for(g in c)c.hasOwnProperty(g)&&(this[g]=c[g]);if(void 0!=this.expresion){this.expresion.match("'")||(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);
g=this.expresion.value;var f,i=2;g&&((f=document.getElementById(g))&&"descartes/macro"==f.type?(f=f.text,i=3):(f=a.openExternalFile(g),f.match("tipo_de_macro")||(f=null)));var h="|";if(f){f=f.replace(/&aacute;/g,"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,
"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&amp;/g,"&").split("\n").slice(i);var j,k;g=0;for(i=f.length;g<i;g++)f[g]&&(f[g]=d.split(f[g]),f[g]&&f[g][0]&&f[g][0][0]&&"id"==f[g][0][0]&&(j=f[g][0][1],k=j.indexOf("("),-1!=k&&(j=j.substring(0,k)),h+=j+"|"));var l,m,p,o;g=0;for(i=f.length;g<i;g++){l=f[g]||[];j=0;for(k=l.length;j<k;j++)if(m=babel[l[j][0]],p=l[j][0].indexOf("."),-1!=p&&(m=babel[l[j][0].substring(p+1)]),!("id"!=m&&"text"!=m&&"expresion"!=
m&&"interval"!=m&&"steps"!=m&&"drawif"!=m&&"size"!=m&&"width"!=m&&"center"!=m&&"radius"!=m&&"init"!=m&&"end"!=m&&"inirot"!=m&&"do"!=m&&"while"!=m&&"file"!=m&&"fill"!=m&&"color"!=m))if("text"==m)if(l[j][1].match(/\{\\rtf1/)){m=l[j][1];var q=this;o=function(a,c){for(var d=b.tokenize(c.replace(/\&squot;/g,"'")),e=0,f=d.length;e<f;e++)if(d[e].type=="identifier"&&h.match("\\|"+d[e].value+"\\|"))d[e].value=q.name+"."+d[e].value;else if(d[e].type=="identifier"&&(p=d[e].value.indexOf("."))!=-1&&h.match("\\|"+
d[e].value.substring(0,p)+"\\|"))d[e].value=q.name+"."+d[e].value;return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+b.flatTokens(d)};m=m.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,o);m=m.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,o);l[j][1]=m}else{o=d.parseText(l[j][1]);for(var s=0,n=o.length;s<n;s++){m=b.tokenize(o[s].replace(/\&squot;/g,"'"));for(var t=0,w=m.length;t<w;t++)"identifier"==m[t].type&&h.match("\\|"+m[t].value+"\\|")&&(m[t].value=this.name+
"."+m[t].value);m=b.flatTokens(m).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");o[s]=m.substring(1,m.length-1)}l[j][1]=o.join("\\n")}else{m=b.tokenize(l[j][1].replace(/\&squot;/g,"'"));o=0;for(s=m.length;o<s;o++)if("identifier"==m[o].type&&h.match("\\|"+m[o].value+"\\|"))m[o].value=this.name+"."+m[o].value;else if("identifier"==m[o].type&&-1!=(p=m[o].value.indexOf("."))&&h.match("\\|"+m[o].value.substring(0,p)+"\\|"))m[o].value=this.name+"."+m[o].value;l[j][1]=b.flatTokens(m)}}g=
0;for(i=f.length;g<i;g++)if(f[g][0]){l="";j=0;for(k=f[g].length;j<k;j++)f[g][j]="type"!=babel[f[g][j][0]]?f[g][j][0]+"='"+f[g][j][1]+"' ":"espacio='"+this.spaceID+"' "+f[g][j][0]+"='"+f[g][j][1]+"' ",l+=f[g][j];f[g]=l;l.match(/^espacio/)?this.graphics.push(d.parseGraphic(f[g],this.abs_coord,this.background,this.inirot)):d.parseAuxiliar(f[g])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){if(this.inipos){var a=this.evaluator.evalExpression(this.inipos);this.iniPosX=a[0][0];this.iniPosY=
a[0][1]}};a.Macro.prototype.drawAux=function(a){for(var c=0,d=this.graphics.length;c<d;c++)this.inipos&&(this.graphics[c].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale)),this.graphics[c].draw(),a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.max,c=Math.min;a.R2=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.copy=function(){return new a.R2(this.x,this.y)};
a.R2.prototype.ix=function(){return Math.round(e(c(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(e(c(this.y,32E3),-32E3))};a.R2.prototype.equals=function(a){return this.x==a.x&&this.y==a.y};a.R2.prototype.norm2=function(){return this.x*this.x+this.y*this.y};a.R2.prototype.norm=function(){return Math.sqrt(this.norm2())};a.R2.prototype.distance=function(a){var b=this.copy();b.sub(a);return b.norm()};a.R2.prototype.dot=function(a){return this.x*a.x+this.y*a.y};a.R2.prototype.det=
function(a){return this.x*a.y-this.y*a.x};a.R2.prototype.mul=function(a){this.x*=a;this.y*=a};a.R2.prototype.div=function(a){this.x/=a;this.y/=a};a.R2.prototype.add=function(a){this.x+=a.x;this.y+=a.y};a.R2.prototype.sub=function(a){this.x-=a.x;this.y-=a.y};a.R2.prototype.normalize=function(){var a=this.norm();0!=a&&this.div(a)};a.R2.prototype.rotR90=function(){var a=this.x;this.x=this.y;this.y=-a};a.R2.prototype.rotL90=function(){var a=this.x;this.x=-this.y;this.y=a};a.R2.prototype.rot=function(a){var b=
this.copy(),c=Math.cos(a),a=Math.sin(a);this.x=b.x*c-b.y*a;this.y=b.x*a+b.y*c};a.R2.prototype.rot=function(a){this.rot(a*Math.PI/180)};a.R2.prototype.intersection=function(d,b,g,f){var i=b.x-d.x,h=g.x-f.x,j=g.x-d.x,k=b.y-d.y,l=g.y-f.y,m=g.y-d.y,p=i*l-h*k;return 1.0E-6<Math.abs(p)?(b=(j*l-m*h)/p,g=(-j*k+m*i)/p,0<=b&&1>=b&&0<=g&&1>=g?new a.R2(d.x+i*b,d.y+k*b):null):(b.x-g.x)*m!=(b.y-g.y)*j?null:d.x!=b.x?(i=c(d.x,b.x),d=e(d.x,b.x),i<=g.x&&g.x<=d?g:i<=f.x&&f.x<=d?f:null):g.x!=f.x?(i=c(g.x,f.x),g=e(g.x,
f.x),i<=d.x&&d.x<=g?d:i<=b.x&&b.x<=g?b:null):d.y!=b.y?(i=c(d.y,b.y),d=e(d.y,b.y),i<=g.y&&g.y<=d?g:i<=f.y&&f.y<=d?f:null):g.y!=f.y?(i=c(g.y,f.y),g=e(g.y,f.y),i<=d.y&&d.y<=g?d:i<=b.y&&b.y<=g?b:null):d.x==g.x&&d.y==g.y?d:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.R2Newton=function(a,c){this.evaluator=a;this.constraint=c;if("=="==this.constraint.value||"<"==this.constraint.value||"<="==this.constraint.value||">"==this.constraint.value||">="==this.constraint.value)this.sign=
"<"==this.constraint.value||"<="==this.constraint.value?"menor":">"==this.constraint.value||">="==this.constraint.value?"mayor":"igual",this.constraint=this.constraint.equalToMinus(),this.constraint=this.constraint.childs[0]};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return this.normal.copy()};a.R2Newton.prototype.gradient=function(e){var c=this.evaluator,d=new a.R2(0,0),b=c.getVariable("x"),g=c.getVariable("y");c.setVariable("x",e.x);c.setVariable("y",e.y);this.f0=c.evalExpression(this.constraint);
c.setVariable("x",c.getVariable("x")+1.0E-12);e=c.evalExpression(this.constraint);d.x=(e-this.f0)/1.0E-12;d.x=NaN!=d.x?d.x:Infinity;c.setVariable("x",c.getVariable("x")-1.0E-12);c.setVariable("y",c.getVariable("y")+1.0E-12);e=c.evalExpression(this.constraint);d.y=(e-this.f0)/1.0E-12;d.y=NaN!=d.y?d.y:Infinity;c.setVariable("x",b);c.setVariable("y",g);return d};a.R2Newton.prototype.findZero=function(a){var c=this.evaluator,d=a.copy(),b=c.getVariable("x"),g=c.getVariable("y");c.setVariable("x",a.x);
c.setVariable("y",a.y);this.f0=c.evalExpression(this.constraint);if("menor"==this.sign&&0>=this.f0||"mayor"==this.sign&&0<=this.f0)return d;c.setVariable("x",b);c.setVariable("y",g);for(g=0;256>g;g++)if(c=d.x,b=d.y,this.normal=this.gradient(d),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),d.x=c+this.normal.x,d.y=b+this.normal.y,1.0E-6>this.normal.norm()){0==this.normal.x&&0==this.normal.y&&(this.normal.x=d.x-a.x,this.normal.y=d.y-a.y);break}return d};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI;a.GraphicControl=function(c,d){this.parent=c;this.evaluator=c.evaluator;var b=this.evaluator.parser;this.id="G";this.type="";this.spaceID="E0";this.text="";this.expresion=b.parse("(0,0)");this.y=this.x=0;this.size=b.parse("4");this.fixed=2!=this.parent.version?!1:!0;this.color="#0000ff";this.colorInt="#ff0000";this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";this.drawif=
b.parse("1");this.activeif=b.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.decimals=b.parse("2");this.zIndex=-1;for(var e in d)d.hasOwnProperty(e)&&(this[e]=d[e]);this.font=a.convertFont(this.font);this.constraintExpr&&(this.constraint=b.parse(this.constraintExpr),"compOperator"==this.constraint.type?this.newt=new a.R2Newton(this.evaluator,this.constraint):this.constraint=null);this.container=this.getContainer();this.space=
this.getSpace();this.mouseCacher=document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);this.init();this.registerMouseEvents()};a.GraphicControl.prototype.init=function(){var c=this.evaluator;this.mouseCacher.style.display=c.evalExpression(this.drawif)?"block":"none";var d=c.evalExpression(this.expresion);
this.x=d[0][0];this.y=d[0][1];c.setVariable(this.id+".x",this.x);c.setVariable(this.id+".y",this.y);""!=this.imageSrc&&!this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,this.height=this.image.height):(this.width=2*c.evalExpression(this.size),this.height=2*c.evalExpression(this.size));this._w=a.hasTouchSupport&&70>this.width?70:this.width;this._h=a.hasTouchSupport&&70>this.height?70:this.height;this.constraint&&(d=this.newt.findZero(new a.R2(this.x,
this.y)),this.x=d.x,this.y=d.y,c.setVariable(this.id+".x",this.x),c.setVariable(this.id+".y",this.y));this.mouseCacher.setAttribute("style","background-color: rgba(255, 255, 255, 0); width: "+this._w+"px; height: "+this._h+"px; z-index: "+this.zIndex+";");this.mouseCacher.style.left=parseInt(this.space.getAbsoluteX(this.x)-this._w/2)+"px";this.mouseCacher.style.top=parseInt(this.space.getAbsoluteY(this.y)-this._h/2)+"px";c.setVariable(this.id+".activo",0)};a.GraphicControl.prototype.update=function(){var c=
this.evaluator;this.x=c.getVariable(this.id+".x");this.y=c.getVariable(this.id+".y");var d=this.space.getAbsoluteX(this.x),b=this.space.getAbsoluteY(this.y);this.mouseCacher.style.left=d-this._w/2+"px";this.mouseCacher.style.top=b-this._h/2+"px";this.mouseCacher.style.display=c.evalExpression(this.activeif)?"block":"none";this.constraint&&(d=this.newt.findZero(new a.R2(this.x,this.y)),this.x=d.x,this.y=d.y,c.setVariable(this.id+".x",this.x),c.setVariable(this.id+".y",this.y));this.draw()};a.GraphicControl.prototype.draw=
function(){var c=this.evaluator;if(c.evalExpression(this.drawif)){var d=this.ctx,b=this.space.backgroundCtx,g=this.space.getAbsoluteX(this.x),f=this.space.getAbsoluteY(this.y);""!=this.text&&this.drawText(g,f);if(this.image.ready)this.image.complete&&d.drawImage(this.image,g-this.image.width/2,f-this.image.height/2),this.trace&&(b.save(),b.translate(g,f),b.scale(this.image.width/2,this.image.height/2),b.beginPath(),b.arc(0,0,1,0,e,!1),b.restore(),b.lineWidth=1,b.strokeStyle=a.getColor(c,this.trace),
b.stroke());else if(d.beginPath(),d.arc(g,f,this.width/2,0,e,!1),d.fillStyle=a.getColor(c,this.colorInt),d.fill(),d.lineWidth=1,d.strokeStyle=a.getColor(c,this.color),d.stroke(),this.active&&(d.beginPath(),d.arc(g,f,this.width/2-2,0,e,!1),d.strokeStyle="black",d.stroke()),this.trace)b.lineWidth=1,b.strokeStyle=a.getColor(c,this.trace),b.beginPath(),b.arc(g,f,this.width/2,0,e,!1),b.stroke()}};a.GraphicControl.prototype.drawText=function(c,d){var b=this.ctx,e=this.evaluator;b.fillStyle=a.getColor(e,
this.color);b.font=this.font;b.textBaseline="alphabetic";e=e.evalExpression(this.text[0],e.evalExpression(this.decimals),this.fixed);b.fillText(e,c+1+this.width/2,d-1-this.height/2)};a.GraphicControl.prototype.getContainer=function(){for(var a=this.parent.spaces,d,b=0,e=a.length;b<e;b++)if(d=a[b],d.id==this.spaceID)return d.addCtr(this),this.zIndex=d.zIndex,d.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;return a[0].graphicControlContainer};a.GraphicControl.prototype.getSpace=
function(){for(var a=this.parent.spaces,d=0,b=a.length;d<b;d++)if(a[d].id==this.spaceID)return a[d];return a[0]};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.id+".activo",0)};a.GraphicControl.prototype.registerMouseEvents=function(){function c(c){c.preventDefault();h.whichButton=null==c.which?2>c.button?"LEFT":4==c.button?"MIDDLE":"RIGHT":2>c.which?"LEFT":2==c.which?"MIDDLE":"RIGHT";"LEFT"==h.whichButton&&h.evaluator.evalExpression(h.activeif)&&h.over&&
(h.parent.deactivateGraphiControls(),h.click=!0,h.active=!0,h.evaluator.setVariable(h.id+".activo",1),h.posAnte=h.getCursorPosition(c),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},a.hasTouchSupport?(window.addEventListener("touchmove",e,!1),window.addEventListener("touchend",b,!1)):(window.addEventListener("mouseup",b,!1),window.addEventListener("mousemove",e,!1)))}function d(c){h.evaluator.evalExpression(h.activeif)&&(h.parent.deactivateGraphiControls(),h.click=!0,h.active=
!0,h.posAnte=h.getCursorPosition(c),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},a.hasTouchSupport?(window.addEventListener("touchmove",e,!1),window.addEventListener("touchend",b,!1)):(window.addEventListener("mouseup",b,!1),window.addEventListener("mousemove",e,!1)));c.preventDefault()}function b(c){if(h.evaluator.evalExpression(h.activeif)||h.active)h.click=!1,c.preventDefault(),a.hasTouchSupport?(window.removeEventListener("touchmove",e,!1),window.removeEventListener("touchend",
b,!1)):(window.removeEventListener("mouseup",b,!1),window.removeEventListener("mousemove",e,!1)),h.parent.update(),h.mouseCacher.style.left=h.space.getAbsoluteX(h.x)-h._w/2+"px",h.mouseCacher.style.top=h.space.getAbsoluteY(h.y)-h._h/2+"px"}function e(b){var c=h.getCursorPosition(b);h.posX=h.prePos.x-(h.posAnte.x-c.x);h.posY=h.prePos.y-(h.posAnte.y-c.y);if(h.constraint){var c=h.space.getRelativeX(h.posX),d=h.space.getRelativeY(h.posY),c=h.newt.findZero(new a.R2(c,d));h.x=c.x;h.y=c.y;h.evaluator.setVariable(h.id+
".x",h.x);h.evaluator.setVariable(h.id+".y",h.y)}else h.evaluator.setVariable(h.id+".x",h.space.getRelativeX(h.posX)),h.evaluator.setVariable(h.id+".y",h.space.getRelativeY(h.posY));h.parent.updateControls();h.parent.update();b.preventDefault()}function f(){h.over=!0;h.mouseCacher.style.cursor="pointer"}function i(){h.over=!1;h.mouseCacher.style.cursor="";h.click=!1}this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=function(){return!1};var h=this;a.hasTouchSupport?this.mouseCacher.addEventListener("touchstart",
d,!1):(this.mouseCacher.addEventListener("mousedown",c,!1),this.mouseCacher.addEventListener("mouseover",f,!1),this.mouseCacher.addEventListener("mouseout",i,!1));this.mouseCacher.addEventListener("blur",function(){console.log("en blur")},!1)};a.GraphicControl.prototype.getCursorPosition=function(c){c=a.getCursorPosition(c);return{x:c.x-(this.space.container.offsetLeft+this.space.container.parentNode.offsetLeft),y:c.y-(this.space.container.offsetTop+this.space.container.parentNode.offsetTop)}};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.Control=function(a,c){this.parent=a;this.evaluator=a.evaluator;var d=this.parser=a.evaluator.parser;this.id="C";this.gui=this.type="";this.region="south";this.y=this.x=0;this.w=100;this.h=23;"text"!=c.type?this.expresion=d.parse("(0,0,100,23)"):(this.expresion=d.parse("(0,0,300,200)"),this.w=300,this.h=200);this.fixed=2!=this.parent.version?!1:!0;this.visible=!0;this.color="#222222";this.colorInt="#f0f8ff";this.underlined=this.italics=this.bold=
"";this.font_size=d.parse("12");this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";this.imageOver=new Image;this.imageOver.onload=function(){this.ready=1};this.imageDown=new Image;this.imageDown.onload=function(){this.ready=1};this.parameter=this.action="";this.parameterFont="Monospace 12px";this.drawif=d.parse("1");this.activeif=d.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos=
"";this.valueExpr=d.parse("0");this.decimals=d.parse("2");this.min=d.parse("-Infinity");this.max=d.parse("Infinity");this.incr=d.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var b in c)c.hasOwnProperty(b)&&(this[b]=c[b]);void 0==this.name&&(this.name=2==this.parent.version?this.id:"_nada_");d=this.evaluator.evalExpression(this.expresion);this.x=d[0][0];this.y=d[0][1];4==d[0].length&&(this.w=d[0][2],this.h=d[0][3]);this.name="_._"==this.name||"_nada_"==this.name||"_void_"==this.name?
"":this.name;this.actionExec=this.parent.lessonParser.parseAction(this)};a.Control.prototype.init=function(){};a.Control.prototype.update=function(){};a.Control.prototype.draw=function(){};a.Control.prototype.getContainer=function(){var a=this.parent.spaces,c;if("interior"==this.region)for(var d=0,b=a.length;d<b;d++){if(c=a[d],c.id==this.spaceID)return c.addCtr(this),this.zIndex=c.zIndex,c.numericalControlContainer}else{if("external"==this.region)return this.parent.externalSpace.container;if("scenario"==
this.region)return this.parent.scenarioRegion.scenarioSpace.addCtr(this),this.zIndex=this.parent.scenarioRegion.scenarioSpace.zIndex,this.parent.scenarioRegion.scenarioSpace.numericalControlContainer;if("north"==this.region)return this.parent.northSpace.controls.push(this),this.parent.northSpace.container;if("south"==this.region)return this.parent.southSpace.controls.push(this),this.parent.southSpace.container;if("east"==this.region)return this.parent.eastSpace.controls.push(this),this.parent.eastSpace.container;
if("west"==this.region)return this.parent.westSpace.controls.push(this),this.parent.westSpace.container;if("special"==this.region)return this.parent.specialSpace.controls.push(this),this.parent.specialSpace.container}a[0].addCtr(this);this.zIndex=a[0].zIndex;return a[0].numericalControlContainer};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Button=function(c,d){a.Control.call(this,c,d);this.name="["==this.name.charAt(0)&&this.name.charAt(this.name.length-
1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");var b;this.imageSrc.match("_COLORES_")&&(b=this.imageSrc.split("_"),this.colorInt=b[2],this.color=b[3],this.font_size=this.parser.parse(b[5]),this.imageSrc="");this.imageSrc="["==this.imageSrc.charAt(0)&&this.imageSrc.charAt(this.imageSrc.length-1)?this.parser.parse(this.imageSrc.substring(1,this.imageSrc.length-1)):this.parser.parse("'"+this.imageSrc+"'");b=this.evaluator.evalExpression(this.imageSrc);
if(""!=b){var e=b.substr(0,b.lastIndexOf(".")),f=b.substr(b.lastIndexOf("."));b.toLowerCase().match(/vacio.gif$/)?(this.image.ready=1,3==this.parent.version&&(this.name=this.parser.parse("")),this.parser.parse("'vacio.gif'")):(this.image=this.parent.getImage(b),this.imageOver=this.parent.getImage(e+"_over"+f),this.imageDown=this.parent.getImage(e+"_down"+f))}b=this.getContainer();this.canvas=document.createElement("canvas");this.canvas.setAttribute("class","DescartesButton");this.canvas.setAttribute("id",
this.id);this.canvas.setAttribute("width",this.w+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.canvas.style.display=this.evaluator.evalExpression(this.drawif)?"block":"none";this.ctx=this.canvas.getContext("2d");b.childNodes[0]?b.insertBefore(this.canvas,b.childNodes[0]):b.appendChild(this.canvas);this.registerMouseEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=
function(){var a=this.canvas,d=this.evaluator.evalExpression(this.expresion);this.x=d[0][0];this.y=d[0][1];4==d[0].length&&(this.w=parseInt(d[0][2]),this.h=parseInt(d[0][3]));a.setAttribute("width",this.w+"px");a.setAttribute("height",this.h+"px");a.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.createGradient(this.w,this.h);this.draw()};a.Button.prototype.update=function(){var a=!1,d=!1,b=!1,e=!1;this.evaluator.evalExpression(this.drawif)?(this.canvas.style.display=
"block",this.draw()):(this.click=!1,this.canvas.style.display="none");this.evaluator.evalExpression(this.activeif);var f=this.evaluator.evalExpression(this.expresion),a=this.x!=f[0][0],d=this.y!=f[0][1];this.x=f[0][0];this.y=f[0][1];4==f[0].length&&(b=this.w!=f[0][2],e=this.h!=f[0][3],this.w=f[0][2],this.h=f[0][3]);(b||e)&&this.createGradient(this.canvas.width,this.canvas.height);if(b||e||a||d)this.canvas.setAttribute("width",this.w+"px"),this.canvas.setAttribute("height",this.h+"px"),this.canvas.setAttribute("style",
"left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";"),this.draw()};a.Button.prototype.createGradient=function(a,d){this.linearGradient=this.ctx.createLinearGradient(0,0,0,d);for(var b=d*d,g,f=0;f<d;f++)g=e(f-35*d/100),this.linearGradient.addColorStop(f/d,"rgba(0,0,0,"+192*g*g/b/255+")")};a.Button.prototype.draw=function(){var c=this.evaluator.evalExpression(this.font_size),d=this.evaluator.evalExpression(this.name),b=this.evaluator.evalExpression(this.imageSrc),g;g="vacio.gif"==b?{ready:!0}:
this.parent.getImage(b);var f=this.ctx;f.clearRect(0,0,this.w,this.h);var i=0,h=0;this.click&&(h=i=1);g&&g.ready?(""!=g.src||!b.toLowerCase().match(/vacio.gif$/))&&g.complete&&f.drawImage(g,(this.w-g.width)/2+i,(this.h-g.height)/2+h):(f.fillStyle=a.getColor(this.evaluator,this.colorInt),f.fillRect(0,0,this.w,this.h),this.click||(a.drawLine(f,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,"+128/255+")"),a.drawLine(f,0,0,0,this.h,"rgba(0,0,0,"+24/255+")"),a.drawLine(f,1,0,1,this.h,"rgba(0,0,0,"+8/255+")")),
f.fillStyle=this.linearGradient,f.fillRect(0,0,this.w,this.h));""!=this.imageOver.src&&this.imageOver.ready&&this.over&&f.drawImage(this.imageOver,(this.w-g.width)/2+i,(this.h-g.height)/2+h);""!=this.imageDown.src&&this.imageDown.ready&&this.click?f.drawImage(this.imageDown,(this.w-g.width)/2+i,(this.h-g.height)/2+h):this.click&&(f.save(),a.drawLine(f,0,0,0,this.h-2,"gray"),a.drawLine(f,0,0,this.w-1,0,"gray"),f.fillStyle="rgba(0, 0, 0,"+24/255+")",f.fillRect(0,0,this.w,this.h),f.restore());f.fillStyle=
a.getColor(this.evaluator,this.color);f.font=this.italics+" "+this.bold+" "+c+"px Arial";f.textAlign="center";f.textBaseline="middle";f.strokeStyle=a.getColor(this.evaluator,this.colorInt);f.lineWidth=c/12;this.stroke!=this.fillStyle&&f.strokeText(d,e(this.w/2+i)+0.5,e(this.h/2+h)+0.5);f.fillText(d,e(this.w/2+i)+0.5,e(this.h/2+h)+0.5);this.underlined&&(d=f.measureText(d).width,f.strokeStyle=a.getColor(this.evaluator,this.color),f.lineWidth=e(c/10),f.lineCap="round",f.beginPath(),f.moveTo((this.w-
d)/2+i,e(this.h+c)/2+f.lineWidth/2-1.5+h),f.lineTo((this.w+d)/2+i,e(this.h+c)/2+f.lineWidth/2-1.5+h),f.stroke());this.evaluator.evalExpression(this.activeif)||(f.fillStyle="rgba(240,240,240,"+160/255+")",f.fillRect(0,0,this.w,this.h))};a.Button.prototype.bottonPressed=function(){this.parent.updateControls();"init"==this.action&&(this.click=!1);this.actionExec.execute();this.parent.updateControls();"animate"!=this.action&&this.parent.update()};a.Button.prototype.registerMouseEvents=function(){function c(a,
b,d){h.click?(b.call(h),a=d?a:30,k=setTimeout(function(){c(a,b)},a)):clearInterval(k)}function d(a){a.preventDefault();h.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==h.whichButton&&h.evaluator.evalExpression(h.activeif)&&(h.click=!0,h.draw(),h.evaluator.setVariable(h.id,h.evaluator.evalExpression(h.valueExpr)),"calculate"==h.action&&c(j,h.bottonPressed,!0),i?window.addEventListener("touchend",b,!1):window.addEventListener("mouseup",
b,!1))}function b(a){if(h.evaluator.evalExpression(h.activeif)||h.click)h.click=!1,h.draw(),"calculate"!=h.action&&h.bottonPressed(),a.preventDefault(),i?window.removeEventListener("touchend",b,!1):window.removeEventListener("mouseup",b,!1)}function e(){h.over=!0;h.draw()}function f(){h.over=!1;h.click=!1;h.draw()}var i=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};var h=this,j=900,k;this.over=this.click=!1;i?this.canvas.addEventListener("touchstart",d,!1):(this.canvas.addEventListener("mousedown",
d,!1),this.canvas.addEventListener("mouseover",e,!1),this.canvas.addEventListener("mouseout",f,!1))};return a}(descartesJS||{}),descartesJS=function(a){function e(a,d,b,e){a.fillStyle=e||"black";a.beginPath();a.moveTo(d[0],b[0]);for(var e=1,f=d.length;e<f;e++)a.lineTo(d[e],b[e]);a.fill()}if(a.loadLib)return a;a.Spinner=function(c,d){a.Control.call(this,c,d);this.tabindex=++this.parent.tabindex;var b=this.getContainer();this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");
this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);""!=this.name&&this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);
b.childNodes[0]?b.insertBefore(this.containerControl,b.childNodes[0]):b.appendChild(this.containerControl);this.init();this.registerMouseEvents();this.draw()};a.extend(a.Spinner,a.Control);a.Spinner.prototype.init=function(){var c=this.evaluator;this.value=this.validateValue(c.evalExpression(this.valueExpr));var d=this.formatOutputValue(this.value);this.fieldFontSize=Math.floor(this.h-0.25*this.h);var b=a.getTextWidth(d+"0",this.fieldFontSize+"px Arial"),e=2+this.h/2,f=this.w/2-e/2,i=a.getTextWidth(this.name,
this.fieldFontSize+"px Arial");this.visible||(f=this.w-e,b=0);f<i&&(f=i);""==this.name&&(f=0);this.w-f-e<b&&(f=this.w-e-b);0>f&&(f=0);b=this.w-(f+e);this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=c.evalExpression(this.drawif)?"block":"none";this.canvas.setAttribute("width",e+"px");this.canvas.setAttribute("height",
this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+f+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.divUp.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+e+"px; height : "+this.h/2+"px; left: "+f+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+e+"px; height : "+this.h/2+"px; left: "+f+"px; top: "+this.h/2+"px;");
this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_spinner");this.field.value=d;this.field.setAttribute("class","DescartesSpinnerField");this.field.setAttribute("style","font-family: Arial; font-size: "+this.fieldFontSize+"px; width : "+(b-2)+"px; height : "+(this.h-2)+"px; left: "+(e+f)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.disabled=c.evalExpression(this.activeif)?!1:!0;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style",
"font-family: Arial; font-size:"+this.fieldFontSize+"px; width: "+f+"px; height: "+this.h+"px;");c.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){var a=this.evaluator,d=changeY=changeW=changeH=!1;this.field.disabled=a.evalExpression(this.activeif)?!1:!0;a.evalExpression(this.drawif)?(this.containerControl.style.display="block",this.draw()):(this.click=!1,this.containerControl.style.display="none");var b=a.evalExpression(this.expresion),
d=this.x!=b[0][0];changeY=this.y!=b[0][1];this.x=b[0][0];this.y=b[0][1];4==b[0].length&&(changeW=this.w!=b[0][2],changeH=this.h!=b[0][3],this.w=b[0][2],this.h=b[0][3]);(changeW||changeH)&&this.createGradient(this.canvas.width,this.canvas.height);var b=this.field.value,e=this.value;this.value=this.validateValue(a.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value==e&&this.field.value!=b&&(this.value=this.validateValue(b),this.field.value=this.formatOutputValue(this.value));
if(changeW||changeH||d||changeY)this.init(),this.draw();a.setVariable(this.id,this.value)};a.Spinner.prototype.createGradient=function(a,d){this.linearGradient=this.ctx.createLinearGradient(0,0,0,d);for(var b=d*d,e,f=0;f<d;f++)e=Math.floor(f-40*d/100),this.linearGradient.addColorStop(f/d,"rgba(0,0,0,"+192*e*e/b/255+")")};a.Spinner.prototype.draw=function(){var c=this.ctx,d=this.canvas.width,b=this.canvas.height;c.save();c.fillStyle="#f0f8ff";c.fillRect(0,0,d,b);c.fillStyle=this.linearGradient;c.fillRect(0,
0,d,b);var g,f;this.up?(g="gray",f="#f0f8ff"):(g="#f0f8ff",f="gray");a.drawLine(c,0,0,d,0,g);a.drawLine(c,0,0,0,b/2,g);a.drawLine(c,0,b/2,d,b/2,f);this.down?(g="gray",f="#f0f8ff"):(g="#f0f8ff",f="gray");a.drawLine(c,0,b/2+1,d,b/2+1,g);a.drawLine(c,0,b/2+1,0,b,g);a.drawLine(c,0,b-1,d,b-1,f);g=[d/2,d/5-1,d-d/5+1];f=[b/8+1,b/8+1+b/4,b/8+1+b/4];var i=this.evaluator.evalExpression(this.activeif);e(c,g,f,i?"#2244cc":"#8888aa");f=[b-b/8,b-b/8-b/4,b-b/8-b/4];e(c,g,f,i?"#d00018":"#aa8888");c.fillStyle="rgba(0,0,0,"+
24/255+")";this.up&&c.fillRect(0,0,d,b/2);this.down&&c.fillRect(0,b/2,d,b)};a.Spinner.prototype.validateValue=function(a){var d=this.evaluator;(a=parseFloat(d.evalExpression(d.parser.parse(a.toString().replace(this.parent.decimal_symbol,".")))))||(a=0);a<d.evalExpression(this.min)&&(a=d.evalExpression(this.min));a>d.evalExpression(this.max)&&(a=d.evalExpression(this.max));if(this.discrete)var b=d.evalExpression(this.incr),a=0==b?0:b*Math.round(a/b);return a=parseFloat(parseFloat(a).toFixed(d.evalExpression(this.decimals)))};
a.Spinner.prototype.formatOutputValue=function(a){var d=a+"",b=this.evaluator.evalExpression(this.decimals),e=d.indexOf(".");-1!=e&&d.substring(e+1).length>b&&(d=parseFloat(d).toFixed(b));if(this.fixed&&(2!=this.parent.version||2==this.parent.version&&!this.exponentialif))d=parseFloat(a).toFixed(b);this.exponentialif&&0!=parseFloat(d)&&(d=this.fixed&&2!=this.parent.version?parseFloat(d).toExponential(b):parseFloat(d).toExponential(),d=d.toUpperCase(),d=d.replace("+",""));return d=d.replace(".",this.parent.decimal_symbol)};
a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.changeValue=function(a){this.evaluator.evalExpression(this.activeif)&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluator.setVariable(this.id,this.value),this.parent.updateControls(),"init"==
this.action&&(this.click=!1),this.actionExec.execute(),this.parent.updateControls(),"animate"!=this.action&&this.parent.update())};a.Spinner.prototype.registerMouseEvents=function(){function c(a,b,d){k.up||k.down?(b.call(k),a=d?a:30,m=setTimeout(function(){c(a,b)},a)):clearInterval(m)}function d(a){a.preventDefault();k.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==k.whichButton&&k.evaluator.evalExpression(k.activeif)&&
(k.up=!0,c(l,k.increase,!0),k.draw())}function b(a){a.preventDefault();k.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==k.whichButton&&k.evaluator.evalExpression(k.activeif)&&(k.down=!0,c(l,k.decrease,!0),k.draw())}function e(a){k.up=!1;clearInterval(m);k.draw();a.preventDefault()}function f(a){k.down=!1;clearInterval(m);k.draw();a.preventDefault()}function i(a){k.up=!1;clearInterval(m);k.draw();a.preventDefault()}function h(a){k.down=
!1;clearInterval(m);k.draw();a.preventDefault()}var j=a.hasTouchSupport;this.divUp.oncontextmenu=function(){return!1};this.divDown.oncontextmenu=function(){return!1};var k=this,l=j?500:200,m;this.field.addEventListener("keydown",function(a){13==a.keyCode&&k.changeValue(k.field.value)},!1);j?this.divUp.addEventListener("touchstart",d,!1):this.divUp.addEventListener("mousedown",d,!1);j?this.divDown.addEventListener("touchstart",b,!1):this.divDown.addEventListener("mousedown",b,!1);j||this.divUp.addEventListener("mouseout",
e,!1);j||this.divDown.addEventListener("mouseout",f,!1);j?(this.divUp.addEventListener("touchend",i,!1),window.addEventListener("touchend",i,!1)):(this.divUp.addEventListener("mouseup",i,!1),window.addEventListener("mouseup",i,!1));j?(this.divDown.addEventListener("touchend",h,!1),window.addEventListener("touchend",h,!1)):(this.divDown.addEventListener("mouseup",h,!1),window.addEventListener("mouseup",h,!1))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.TextField=function(e,
c){a.Control.call(this,e,c);this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;if(this.answer)if(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answerPattern=this.answer,this.onlyText){this.answer=a.buildRegularExpresionsPatterns(this.answer);var d=this.answerPattern.indexOf("|");this.firstAnswer=-1==d?this.answerPattern:this.answerPattern.substring(0,d)}else this.buildRangeExpresions(),this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,
this.answerPattern.indexOf(",")));this.onlyText&&(this.validateValue=function(a){return"''"==a||"'"==a?"":a},this.formatOutputValue=function(a){return a.toString()},this.evaluateAnswer=this.evaluateTextualAnswer);d=this.getContainer();this.containerControl=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.containerControl.appendChild(this.label);
this.containerControl.appendChild(this.field);d.childNodes[0]?d.insertBefore(this.containerControl,d.childNodes[0]):d.appendChild(this.containerControl);this.init();this.registerMouseEvents();this.draw()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){evaluator=this.evaluator;this.value=evaluator.evalExpression(this.valueExpr);this.value=this.validateValue(this.value);var e=this.formatOutputValue(this.value);this.fieldFontSize=Math.floor(this.h-0.25*this.h);var c=this.w/2,d=
a.getTextWidth(e+"0",this.fieldFontSize+"px Arial"),b=a.getTextWidth(this.name,this.fieldFontSize+"px Arial");c<b&&(c=b);""==this.name&&(c=0);this.w-c<d&&(c=this.w-d);0>c&&(c=0);d=this.w-c;this.containerControl.setAttribute("class","DescartesTextFieldContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=evaluator.evalExpression(this.drawif)?"block":"none";
this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"TextField");this.field.value=e;this.field.setAttribute("class","DescartesTextFieldField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+d+"px; height : "+(this.h-2)+"px; left: "+c+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.disabled=evaluator.evalExpression(this.activeif)?!1:!0;this.label.setAttribute("class","DescartesTextFieldLabel");this.label.setAttribute("style",
"font-size:"+this.fieldFontSize+"px; width: "+c+"px; height: "+this.h+"px;");evaluator.setVariable(this.id,this.value);this.oldValue=this.value};a.TextField.prototype.update=function(){evaluator=this.evaluator;var a=!1,c=!1,d=!1,b=!1;this.field.disabled=evaluator.evalExpression(this.activeif)?!1:!0;evaluator.evalExpression(this.drawif)?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";var g=evaluator.evalExpression(this.expresion),a=this.x!=g[0][0],
c=this.y!=g[0][1];this.x=g[0][0];this.y=g[0][1];4==g[0].length&&(d=this.w!=g[0][2],b=this.h!=g[0][3],this.w=g[0][2],this.h=g[0][3]);(d||b||a||c)&&this.init();a=this.field.value;c=this.value;this.value=this.validateValue(evaluator.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value===c&&this.field.value!=a&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value));evaluator.setVariable(this.id,this.value)};a.TextField.prototype.validateValue=
function(a){if(""===a||"''"==a)return"";var c=this.evaluator;(a=parseFloat(c.evalExpression(c.parser.parse(a.toString().replace(this.parent.decimal_symbol,".")))))||(a=0);a<c.evalExpression(this.min)&&(a=c.evalExpression(this.min));a>c.evalExpression(this.max)&&(a=c.evalExpression(this.max));if(this.discrete)var d=c.evalExpression(this.incr),a=0==d?0:d*Math.round(a/d);return a=parseFloat(parseFloat(a).toFixed(c.evalExpression(this.decimals)))};a.TextField.prototype.formatOutputValue=function(a){if(""===
a)return"";var c=a+"",d=this.evaluator.evalExpression(this.decimals),b=c.indexOf(".");-1!=b&&c.substring(b+1).length>d&&(c=parseFloat(c).toFixed(d));this.fixed&&(c=parseFloat(a).toFixed(d));this.exponentialif&&(c=c.toExponential(d),c=c.toUpperCase(),c=c.replace("+",""));return c=c.replace(".",this.parent.decimal_symbol)};a.TextField.prototype.changeValue=function(a){this.evaluator.evalExpression(this.activeif)&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),
this.evaluate&&(this.ok=this.evaluateAnswer()),this.evaluator.setVariable(this.id,this.value),this.evaluator.setVariable(this.id+".ok",this.ok),this.parent.updateControls(),"init"==this.action&&(this.click=!1),this.actionExec.execute(),this.parent.updateControls(),"animate"!=this.action&&this.parent.update())};a.TextField.prototype.evaluateAnswer=function(){var a=this.evaluator;parseFloat(this.value);for(var c,d,b,g,f,i,h,j=0,k=this.answer.length;j<k;j++)if(g=this.answer[j][0],i=this.answer[j][1],
c=a.evalExpression(g.expression),d=a.evalExpression(i.expression),b="("==g.type,g="["==g.type,f=")"==i.type,i="]"==i.type,h=this.value,b&&f&&h>c&&h<d||b&&i&&h>c&&h<=d||g&&f&&h>=c&&h<d||g&&i&&h>=c&&h<=d)return 1;return 0};a.TextField.prototype.buildRangeExpresions=function(){var a;this.answer=this.answer.split("|");for(var c=0,d=this.answer.length;c<d;c++)this.answer[c]=this.answer[c].trim(),this.answer[c]=this.answer[c].split(","),a=this.answer[c][0].trim(),this.answer[c][0]={type:a[0],expression:this.evaluator.parser.parse(a.substring(1))},
a=this.answer[c][1].trim(),this.answer[c][1]={type:a[a.length-1],expression:this.evaluator.parser.parse(a.substring(0,a.length-1))}};a.TextField.prototype.evaluateTextualAnswer=function(){for(var e=this.value,c,d,b,g=0,f=this.answer.length;g<f;g++){d=this.answer[g];b=!0;for(var i=0,h=d.length;i<h;i++)c=d[i],c.ignoreAcents&&(e=a.replaceAcents(e),c.regExp=a.replaceAcents(c.regExp)),c.ignoreCaps&&(e=e.toLowerCase(),c.regExp=c.regExp.toLowerCase()),b=b&&!!e.match(c.regExp);if(b)return 1}return 0};a.TextField.prototype.getFirstAnswer=
function(){return this.answer?this.onlyText?this.firstAnswer:this.evaluator.evalExpression(this.firstAnswer):""};a.TextField.prototype.registerMouseEvents=function(){var a=this;this.field.addEventListener("blur",function(){a.update()},!1);this.field.addEventListener("keydown",function(c){a.evaluator.evalExpression(a.activeif)&&13==c.keyCode&&a.changeValue(a.field.value,!0)},!1)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Menu=function(e,c){a.Control.call(this,e,c);
var d=this.parser;this.options=this.options?this.options.split(","):[];this.menuOptions=[];this.strValue=[];for(var b,g=0,f=this.options.length;g<f;g++)b=this.options[g].split(/[\[\]]/,2),1==b.length?(this.menuOptions.push(b[0]),this.strValue.push(g.toString())):2==b.length&&(this.menuOptions.push(b[0]),""==b[1]?this.strValue.push(g.toString()):this.strValue.push(b[1]));g=0;for(f=this.strValue.length;g<f;g++)this.strValue[g]=d.parse(this.strValue[g]);d=this.getContainer();this.containerControl=document.createElement("div");
this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.select=document.createElement("select");g=0;for(f=this.menuOptions.length;g<f;g++)b=document.createElement("option"),b.innerHTML=this.menuOptions[g],this.select.appendChild(b);this.field=document.createElement("input");this.init();this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);
d.childNodes[0]?d.insertBefore(this.containerControl,d.childNodes[0]):d.appendChild(this.containerControl);this.registerMouseEvents()};a.extend(a.Menu,a.Control);a.Menu.prototype.init=function(){var e=this.evaluator;this.fieldFontSize=Math.floor(this.h-3-0.25*(this.h-3));var c=0,d=0,b=0;this.value=e.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var g=0,f=this.menuOptions.length;g<f;g++)b=a.getTextWidth(this.menuOptions[g],this.fieldFontSize+"px Arial"),b>c&&(c=b,d=g);
c+=25;b=a.getTextWidth(this.formatOutputValue(e.evalExpression(this.strValue[d])),this.fieldFontSize+"px Arial")+7;d=a.getTextWidth(this.name,this.fieldFontSize+"px Arial")+10;""==this.name&&(d=0);this.visible||(b=0);for(g=this.w-b-d;g<c&&0<d;)d--,g++;for(;g<c&&0<b;)b--,g++;for(;d+g+b+1<this.w;)g++,b++;var c=d,f=c+g,b=this.w-f,i=this.formatOutputValue(e.evalExpression(this.strValue[this.indexValue]));this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style",
"width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=e.evalExpression(this.drawif)?"block":"none";this.label.setAttribute("class","DescartesMenuLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+d+"px; height: "+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"menu");this.field.value=i;this.field.setAttribute("class","DescartesMenuField");
this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+b+"px; height : "+(this.h-2)+"px; left: "+f+"px;");this.field.disabled=e.evalExpression(this.activeif)?!1:!0;this.select.setAttribute("id",this.id+"menuSelect");this.select.setAttribute("class","DescartesMenuSelect");this.select.setAttribute("style","text-align: left; font-size: "+this.fieldFontSize+"px; width : "+g+"px; height : "+this.h+"px; left: "+c+"px; border-color: #7a8a99; border-width: 1.5px; border-style: solid; background-color: #eeeeee;");
this.select.selectedIndex=this.indexValue;this.select.disabled=e.evalExpression(this.activeif)?!1:!0;e.setVariable(this.id,parseFloat(i))};a.Menu.prototype.update=function(){var a=this.evaluator,c=!1,d=!1,b=!1,g=!1,c=a.evalExpression(this.activeif);this.field.disabled=c?!1:!0;this.select.disabled=c?!1:!0;a.evalExpression(this.drawif)?(this.containerControl.style.display="block",this.draw()):(this.click=!1,this.containerControl.style.display="none");var f=a.evalExpression(this.expresion),c=this.x!=
f[0][0],d=this.y!=f[0][1];this.x=f[0][0];this.y=f[0][1];4==f[0].length&&(b=this.w!=f[0][2],g=this.h!=f[0][3],this.w=f[0][2],this.h=f[0][3]);if(b||g||c||d)this.init(),this.draw();this.value=a.getVariable(this.id);this.field.value=this.formatOutputValue(this.value);a.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))};a.Menu.prototype.getIndex=function(a){for(var a=parseFloat(a.toString().replace(this.parent.decimal_symbol,".")),c=-1,d=Infinity,
b,g=0,f=this.strValue.length;g<f;g++)b=Math.abs(a-parseFloat(this.evaluator.evalExpression(this.strValue[g]))),b<=d&&(d=b,c=g);return c};a.Menu.prototype.formatOutputValue=function(a){var c=a+"",d=this.evaluator.evalExpression(this.decimals),b=c.indexOf(".");-1!=b&&c.substring(b+1).length>d&&(c=parseFloat(c).toFixed(d));this.fixed&&(c=parseFloat(a).toFixed(d));this.exponentialif&&(c=c.toExponential(d),c=c.toUpperCase(),c=c.replace("+",""));return c=c.replace(".",this.parent.decimal_symbol)};a.Menu.prototype.changeValue=
function(){this.evaluator.evalExpression(this.activeif)&&(this.evaluator.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.updateControls(),"animate"!=this.action&&this.parent.update())};a.Menu.prototype.registerMouseEvents=function(){var a=this;this.select.oncontextmenu=function(){return!1};this.select.addEventListener("change",function(c){a.value=a.evaluator.evalExpression(a.strValue[this.selectedIndex]);a.field.value=a.formatOutputValue(a.value);
a.evaluator.setVariable(a.id,a.field.value);a.changeValue();c.preventDefault()},!1);this.field.addEventListener("keydown",function(c){13==c.keyCode&&(a.indexValue=a.getIndex(a.field.value),a.value=a.evaluator.evalExpression(a.strValue[a.indexValue]),a.field.value=a.formatOutputValue(a.indexValue),a.select.selectedIndex=a.indexValue,a.changeValue())},!1)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Scrollbar=function(c,d){a.Control.call(this,c,d);this.orientation=
this.w>=this.h?"horizontal":"vertical";var b=this.getContainer();this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.scrollManipulator=document.createElement("div");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.containerControl.appendChild(this.label);
this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.scrollManipulator);b.childNodes[0]?b.insertBefore(this.containerControl,b.childNodes[0]):b.appendChild(this.containerControl);this.init();this.registerMouseEvents();this.draw()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){var a=this.evaluator,d=(a.evalExpression(this.max)-
a.evalExpression(this.min))/100;this.incr=a.parser.parse(""+d);this.value=this.validateValue(a.evalExpression(this.valueExpr));var d=this.formatOutputValue(this.value),b=this.evaluator.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];4==b[0].length&&(this.w=b[0][2],this.h=b[0][3]);this.orientation=this.w>=this.h?"horizontal":"vertical";"vertical"==this.orientation?this.initVertical(d):this.initHorizontal(d);a.setVariable(this.id,this.value);a=this.value;this.value=null;this.changeValue(a);
this.prePos=this.pos;this.draw()};a.Scrollbar.prototype.initVertical=function(c){this.fieldFontSize=e(this.w-0.25*this.w);this.fieldFontSize=17.25;a.getTextWidth(c+"0",this.fieldFontSize+"px Arial");this.labelHeight=""==this.name?0:23;var d=""==this.visible?0:23;this.canvasHeight=this.h-this.labelHeight-d;this.downHeight=this.upHeight=15;var b=d+this.canvasHeight;this.scrollManipulatorHeight=15;this.scrollManipulatorLimInf=d+this.canvasHeight-this.upHeight-this.downHeight;this.scrollManipulatorLimSup=
d+this.downHeight;this.containerControl.setAttribute("class","DescartesScrollbarContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=this.evaluator.evalExpression(this.drawif)?"block":"none";this.canvas.setAttribute("width",this.w+"px");this.canvas.setAttribute("height",this.canvasHeight+"px");this.canvas.setAttribute("style","position: absolute; left: 0px; top: "+
d+"px;");this.ctx=this.canvas.getContext("2d");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+this.w+"px; height : "+this.upHeight+"px; left: 0px; top: "+(b-this.downHeight)+"px;");this.divUp.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+this.w+"px; height : "+this.downHeight+"px; left: 0px; top: "+this.labelHeight+"px;");this.scrollManipulator.setAttribute("style",
"background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+this.w+"px; height : "+this.scrollManipulatorHeight+"px; left: 0px; top: "+this.scrollManipulatorLimInf+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"scrollbar");this.field.value=c;this.field.setAttribute("class","DescartesScrollbarField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+this.w+"px; height : "+d+"px; left: 0px; top: 0px;");
this.field.disabled=this.evaluator.evalExpression(this.activeif)?!1:!0;this.label.setAttribute("class","DescartesScrollbarLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+this.w+"px; height: "+this.labelHeight+"px; left: 0px; top: "+b+"px;");this.txtLabel=document.createTextNode(this.name)};a.Scrollbar.prototype.initHorizontal=function(c){this.fieldFontSize=e(this.h-0.25*this.h);var d=a.getTextWidth(c+"0",this.fieldFontSize+"px Arial");this.labelWidth=a.getTextWidth(this.name,
this.fieldFontSize+"px Arial");""==this.name&&(this.labelWidth=0);this.visible||(d=0);for(var b=this.w-d-this.labelWidth;58>b&&0<this.labelWidth;)this.labelWidth--,b++;for(;58>b&&0<d;)d--,b++;var g=this.labelWidth,f=g+b,d=this.w-f;this.canvasWidth=b;this.scrollManipulatorWidth=this.downWidth=this.upWidth=15;this.scrollManipulatorLimInf=g+this.downWidth;this.scrollManipulatorLimSup=g+this.canvasWidth-this.upWidth-this.downWidth;this.containerControl.setAttribute("class","DescartesScrollbarContainer");
this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=this.evaluator.evalExpression(this.drawif)?"block":"none";this.canvas.setAttribute("width",this.canvasWidth+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+g+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.divUp.setAttribute("style",
"cursor: pointer; position: absolute; width : "+this.upWidth+"px; height : "+this.h+"px; left: "+(f-this.downWidth)+"px; top: 0px;");this.divDown.setAttribute("style","cursor: pointer; position: absolute; width : "+this.downWidth+"px; height : "+this.h+"px; left: "+this.labelWidth+"px; top: 0px;");this.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+this.scrollManipulatorWidth+"px; height : "+this.h+"px; left: "+this.scrollManipulatorLimInf+
"px; top: 0px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"scrollbar");this.field.value=c;this.field.setAttribute("class","DescartesScrollbarField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+d+"px; height : "+(this.h-2)+"px; left: "+(this.canvasWidth+this.labelWidth)+"px;");this.field.disabled=this.evaluator.evalExpression(this.activeif)?!1:!0;this.label.setAttribute("class","DescartesScrollbarLabel");this.label.setAttribute("style",
"font-size:"+this.fieldFontSize+"px; width: "+this.labelWidth+"px; height: "+this.h+"px;");this.txtLabel=document.createTextNode(this.name)};a.Scrollbar.prototype.update=function(){var a=this.evaluator,d=!1,b=!1,e=!1,f=!1;this.field.disabled=a.evalExpression(this.activeif)?!1:!0;a.evalExpression(this.drawif)?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";var i=a.evalExpression(this.expresion),d=this.x!=i[0][0],b=this.y!=i[0][1];this.x=i[0][0];
this.y=i[0][1];4==i[0].length&&(e=this.w!=i[0][2],f=this.h!=i[0][3],this.w=i[0][2],this.h=i[0][3]);this.value=this.validateValue(a.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);if(e||f||d||b)this.init(),this.draw();a.setVariable(this.id,this.value);this.draw()};a.Scrollbar.prototype.createGradient=function(a,d){this.linearGradient=this.ctx.createLinearGradient(0,0,0,d);for(var b=d*d,g,f=0;f<d;f++)g=e(f-40*d/100),this.linearGradient.addColorStop(f/d,"rgba(0,0,0,"+192*g*
g/b/255+")")};a.Scrollbar.prototype.draw=function(){var a=this.ctx;if("horizontal"==this.orientation){var d=e(this.h),b=e(this.upWidth),g=e(this.canvasWidth-this.upWidth);a.clearRect(0,0,this.canvasWidth,this.h);a.strokeStyle="#7a8a99";a.strokeRect(0,0,b+0.5,d);a.strokeRect(g+0.5,0,b,d);var f=4;a.fillStyle=this.up?"black":"#333333";a.beginPath();a.moveTo(f,d/2);a.lineTo(b-f,d/2-7);a.lineTo(b-f,d/2+7);a.closePath();a.moveTo(g+1+b-f,d/2);a.lineTo(g+1+f,d/2-7);a.lineTo(g+1+f,d/2+7);a.closePath();a.fill();
a.strokeRect(0,0.5,this.canvasWidth+0.5,d-1);f=e(this.pos-this.labelWidth);a.fillStyle="#ccdcec";a.fillRect(f+0.5,0,e(this.scrollManipulatorWidth),d);a.strokeStyle="#6382bf";a.strokeRect(f+0.5,0,e(this.scrollManipulatorWidth),d);b=e(this.scrollManipulatorWidth/2);a.beginPath();a.moveTo(f+b+0.5-2,3);a.lineTo(f+b+0.5-2,d-3);a.moveTo(f+b+0.5,3);a.lineTo(f+b+0.5,d-3);a.moveTo(f+b+0.5+2,3);a.lineTo(f+b+0.5+2,d-3)}else d=e(this.w),b=e(this.upHeight),g=e(this.canvasHeight-this.upHeight),a.clearRect(0,0,
this.w,this.canvasHeight),a.strokeStyle="#7a8a99",a.strokeRect(0.5,2.5,d-0.5,b),a.strokeRect(0.5,g-0.5,d-0.5,b),f=4,a.fillStyle=this.down?"black":"#333333",a.beginPath(),a.moveTo(d/2,f+2),a.lineTo(d/2-7,b-f+2),a.lineTo(d/2+7,b-f+2),a.closePath(),a.moveTo(d/2,g+b-f),a.lineTo(d/2-7,g+f),a.lineTo(d/2+7,g+f),a.closePath(),a.fill(),a.strokeRect(0.5,1.5,d-0.5,this.canvasHeight-1.5),f=e(this.pos-this.labelHeight),a.fillStyle="#ccdcec",a.fillRect(0,f+0.5,this.w,e(this.scrollManipulatorHeight)),a.strokeStyle=
"#6382bf",a.strokeRect(0,f+0.5,this.w,e(this.scrollManipulatorHeight)),b=e(this.scrollManipulatorHeight/2),a.beginPath(),a.moveTo(3,f+b+0.5-2),a.lineTo(d-3,f+b+0.5-2),a.moveTo(3,f+b+0.5),a.lineTo(d-3,f+b+0.5),a.moveTo(3,f+b+0.5+2),a.lineTo(d-3,f+b+0.5+2);a.stroke()};a.Scrollbar.prototype.validateValue=function(a){var d=this.evaluator,a=a.toString();(a=parseFloat(a.replace(this.parent.decimal_symbol,".")))||(a=0);a<d.evalExpression(this.min)&&(this.value=null,a=d.evalExpression(this.min));a>d.evalExpression(this.max)&&
(this.value=null,a=d.evalExpression(this.max));var b=d.evalExpression(this.incr),a=0!=b?e(a/b)*b:0;this.fixed&&(a=parseFloat(parseFloat(a).toFixed(d.evalExpression(this.decimals))));return a};a.Scrollbar.prototype.formatOutputValue=function(a){var d=a+"",b=this.evaluator.evalExpression(this.decimals),e=d.indexOf(".");-1!=e&&d.substring(e+1).length>b&&(d=parseFloat(d).toFixed(b));this.fixed&&(d=parseFloat(a).toFixed(b));this.exponentialif&&(d=d.toExponential(b),d=d.toUpperCase(),d=d.replace("+",""));
return d=d.replace(".",this.parent.decimal_symbol)};a.Scrollbar.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.evalExpression(this.incr))};a.Scrollbar.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.evaluator.evalExpression(this.incr))};a.Scrollbar.prototype.increase10=function(){var a=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;"horizontal"==this.orientation?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+
a):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+a)};a.Scrollbar.prototype.decrease10=function(){var a=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;"horizontal"==this.orientation?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-a):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-a)};a.Scrollbar.prototype.changeValue=function(a){this.evaluator.evalExpression(this.activeif)&&(a=this.validateValue(a),
a!=this.value&&(this.value=a,this.field.value=this.formatOutputValue(a),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.updateControls(),"animate"!=this.action&&this.parent.update()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){var a=this.evaluator,d=this.scrollManipulatorLimInf,b=this.scrollManipulatorLimSup,g=a.evalExpression(this.min),f=a.evalExpression(this.max),
i=a.evalExpression(this.incr),d=e((this.pos-d)*(f-g)/(b-d)/i)*i;d!=this.value&&(this.value=d,this.field.value=this.formatOutputValue(d),a.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){var a=this.evaluator,d=this.scrollManipulatorLimInf,b=this.scrollManipulatorLimSup,e=a.evalExpression(this.min),f=a.evalExpression(this.max);a.evalExpression(this.incr);this.pos=this.value*(b-
d)/(f-e)+d;"horizontal"==this.orientation?this.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+this.scrollManipulatorWidth+"px; height : "+this.h+"px; left: "+this.pos+"px; top: 0px;"):this.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+this.w+"px; height : "+this.scrollManipulatorHeight+"px; left: 0px; top: "+this.pos+"px;")};a.Scrollbar.prototype.registerMouseEvents=
function(){function c(a,b,d){n.up||n.down||n.canvasClick?(b.call(n),a=d?a:30,v=setTimeout(function(){c(a,b)},a)):clearInterval(v)}function d(a){a.preventDefault();n.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==n.whichButton&&n.evaluator.evalExpression(n.activeif)&&(n.clickPos=n.getCursorPosition(a),n.canvasClick=!0,"horizontal"==n.orientation?n.clickPos.x<n.prePos?c(w,n.decrease10,!0):c(w,n.increase10,!0):n.clickPos.y<
n.prePos?c(w,n.increase10,!0):c(w,n.decrease10,!0))}function b(a){n.canvasClick=!1;clearInterval(v);a.preventDefault()}function e(a){!0==n.canvasClick&&(n.clickPos=n.getCursorPosition(a),a.preventDefault())}function f(a){n.evaluator.evalExpression(n.activeif)&&(n.scrollClick=!0,n.initPos=n.getCursorPosition(a),window.addEventListener("mouseup",h,!1),window.addEventListener("mousemove",k,!1),a.preventDefault())}function i(a){n.evaluator.evalExpression(n.activeif)&&(n.scrollClick=!0,n.initPos=n.getCursorPosition(a),
window.addEventListener("touchend",j,!1),window.addEventListener("touchmove",onToucheMove_scrollManipulator,!1),a.preventDefault())}function h(a){n.scrollClick=!1;n.prePos=n.pos;window.removeEventListener("mouseup",h,!1);window.removeEventListener("mousemove",k,!1);a.preventDefault()}function j(a){n.scrollClick=!1;n.prePos=n.pos;window.removeEventListener("touchend",j,!1);window.removeEventListener("touchmove",k,!1);a.preventDefault()}function k(a){var b=n.getCursorPosition(a);"horizontal"==n.orientation?
(n.pos=n.prePos-(n.initPos.x-b.x),n.pos<n.scrollManipulatorLimInf&&(n.pos=n.scrollManipulatorLimInf),n.pos>n.scrollManipulatorLimSup&&(n.pos=n.scrollManipulatorLimSup),n.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+n.scrollManipulatorWidth+"px; height : "+n.h+"px; left: "+n.pos+"px; top: 0px;")):(n.pos=n.prePos-(n.initPos.y-b.y),n.pos>n.scrollManipulatorLimInf&&(n.pos=n.scrollManipulatorLimInf),n.pos<n.scrollManipulatorLimSup&&
(n.pos=n.scrollManipulatorLimSup),n.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+n.w+"px; height : "+n.scrollManipulatorHeight+"px; left: 0px; top: "+n.pos+"px;"));n.changeValueForScrollMovement();a.preventDefault()}function l(a){a.preventDefault();n.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==n.whichButton&&n.evaluator.evalExpression(n.activeif)&&
(n.up=!0,c(w,n.increase,!0))}function m(a){a.preventDefault();n.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==n.whichButton&&n.evaluator.evalExpression(n.activeif)&&(n.down=!0,c(w,n.decrease,!0))}function p(a){n.up=!1;clearInterval(v);a.preventDefault()}function o(a){n.down=!1;clearInterval(v);a.preventDefault()}function q(a){n.up=!1;clearInterval(v);a.preventDefault()}function s(a){n.down=!1;clearInterval(v);a.preventDefault()}
var n=this,t=a.hasTouchSupport,w=t?500:200,v;this.canvas.oncontextmenu=function(){return!1};this.divUp.oncontextmenu=function(){return!1};this.divDown.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&n.changeValue(n.field.value)},!1);t?this.canvas.addEventListener("touchstart",d,!1):this.canvas.addEventListener("mousedown",d,!1);t||this.divDown.addEventListener("mouseout",o,!1);t?window.addEventListener("touchend",b,!1):window.addEventListener("mouseup",
b,!1);t?this.canvas.addEventListener("touchmove",e,!1):this.canvas.addEventListener("mousemove",e,!1);t?this.scrollManipulator.addEventListener("touchstart",i,!1):this.scrollManipulator.addEventListener("mousedown",f,!1);t?this.divUp.addEventListener("touchstart",l,!1):this.divUp.addEventListener("mousedown",l,!1);t?this.divDown.addEventListener("touchstart",m,!1):this.divDown.addEventListener("mousedown",m,!1);t||this.divUp.addEventListener("mouseout",p,!1);t||this.divDown.addEventListener("mouseout",
o,!1);t?window.addEventListener("touchend",q,!1):window.addEventListener("mouseup",q,!1);t?window.addEventListener("touchend",s,!1):window.addEventListener("mouseup",s,!1)};a.Scrollbar.prototype.getCursorPosition=function(c){c=a.getCursorPosition(c);return{x:c.x-(this.containerControl.offsetLeft+this.containerControl.parentNode.offsetLeft),y:c.y-(this.containerControl.offsetTop+this.containerControl.parentNode.offsetTop)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Audio=
function(e,c){a.Control.call(this,e,c);var d=this.getContainer(),b=this.evaluator.evalExpression(this.expresion);4==b[0].length?(this.w=b[0][2],this.h=b[0][3]):(this.w=100,this.h=28);if(b=navigator.userAgent.toLowerCase().match("firefox")&&!0)this.audioContainer=document.createElement("div"),this.audioContainer.setAttribute("style","overflow: hidden; position: absolute; width: "+this.w+"px; height: 35px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.audio=this.parent.getAudio(this.file);
this.autoplay&&(this.audio.setAttribute("autoplay","autoplay"),this.audio.play());this.loop&&this.audio.setAttribute("loop","loop");this.audio.setAttribute("controls","controls");b?(this.audio.setAttribute("style","position: absolute; width: "+this.w+"px; height: 100px; left: 0px; top: -65px;"),this.audioContainer.appendChild(this.audio)):this.audio.setAttribute("style","position: absolute; width: "+this.w+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");d.childNodes[0]?b?d.insertBefore(this.audioContainer,
d.childNodes[0]):d.insertBefore(this.audio,d.childNodes[0]):b?d.appendChild(this.audioContainer):d.appendChild(this.audio)};a.extend(a.Audio,a.Control);a.Audio.prototype.update=function(){var a=this.evaluator;a.evalExpression(this.drawif)?this.audio.style.display="block":(this.audio.style.display="none",this.audio.pause());a=a.evalExpression(this.expresion);this.x=a[0][0];this.y=a[0][1];4==a[0].length&&(this.w=a[0][2],this.h=a[0][3])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.Video=function(e,c){a.Control.call(this,e,c);var d=this.evaluator,b=this.getContainer(),g=this.evaluator.evalExpression(this.expresion);4==g[0].length?(this.w=g[0][2],this.h=g[0][3]):this.h=this.w=null;this.video=document.createElement("video");d.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display="none",this.video.pause());this.autoplay&&this.video.setAttribute("autoplay","autoplay");this.loop&&this.video.setAttribute("loop","loop");this.video.setAttribute("controls",
"controls");this.poster&&this.video.setAttribute("poster",this.poster);this.w&&(this.video.setAttribute("width",this.w),this.video.setAttribute("height",this.h));this.video.setAttribute("style","position: absolute; overflow: hidden; left: "+this.x+"px; top: "+this.y+"px;");d=this.file;g=this.file.lastIndexOf(".");-1!=g&&(d=this.file.substring(0,g));g=document.createElement("source");g.setAttribute("src",d+".ogg");g.setAttribute("type","video/ogg");this.video.appendChild(g);g=document.createElement("source");
g.setAttribute("src",d+".mp4");g.setAttribute("type","video/mp4");this.video.appendChild(g);g=document.createElement("source");g.setAttribute("src",d+".webm");g.setAttribute("type","video/webm");this.video.appendChild(g);b.childNodes[0]?b.insertBefore(this.video,b.childNodes[0]):b.appendChild(this.video)};a.extend(a.Video,a.Control);a.Video.prototype.update=function(){var a=this.evaluator;a.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display="none",this.video.pause());
a=a.evalExpression(this.expresion);this.x=a[0][0];this.y=a[0][1];4==a[0].length&&(this.w=a[0][2],this.h=a[0][3])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.TextArea=function(c,d){a.Control.call(this,c,d);this.region="interior";this.tabindex=++this.parent.tabindex;this.answer&&this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7)));var b=this.getContainer();this.containerControl=document.createElement("div");this.textArea=
document.createElement("div");this.textAreaAnswer=document.createElement("div");this.showButton=document.createElement("div");this.activeCover=document.createElement("div");this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);this.containerControl.appendChild(this.activeCover);b.childNodes[0]?b.insertBefore(this.containerControl,b.childNodes[0]):b.appendChild(this.containerControl);this.showAnswer=
!1;this.text=void 0==this.text.type?this.rawText:this.text.hasFormula?this.rawText:this.text.toHTML();b=this.parent.lessonParser.parseText(this.answer);void 0!=b.type&&!this.text.hasFormula&&(this.answer=b.toHTML());this.evaluator.setVariable(this.id,this.text);this.drawButton();this.init();this.registerMouseEvents()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){var c=this.answer?28:8;evaluator=this.evaluator;this.text=evaluator.getVariable(this.id);this.containerControl.setAttribute("class",
"DescartesTextAreaContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=evaluator.evalExpression(this.drawif)?"block":"none";this.containerControl.setAttribute("spellcheck","false");this.textArea.setAttribute("class","DescartesTextAreaContainer");this.textArea.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-c)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+
a.convertFont(this.font)+";");this.textArea.setAttribute("contenteditable","true");this.textArea.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;' >"+this.text+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-c)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textAreaAnswer.style.display=
this.showAnswer?"block":"none";this.textAreaAnswer.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;'>"+this.answer+"</span>";this.showButton.setAttribute("style","width: 20px; height: 16px; position: absolute; bottom: 4px; right: 4px; cursor: pointer;");this.showButton.style.backgroundImage="url("+this.imageUnPush+")";this.showButton.innerHTML="<span style='position: relative; top: 2px; text-align: center; font: 9px Arial'> S </span>";this.activeCover.setAttribute("style",
"position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px;");this.activeCover.style.display=evaluator.evalExpression(this.activeif)?"none":"block"};a.TextArea.prototype.drawButton=function(){var c=document.createElement("canvas");c.setAttribute("width",20);c.setAttribute("height",16);for(var d=c.getContext("2d"),b=d.createLinearGradient(0,0,0,16),g,f=0;16>f;f++)g=e(f-5.6),b.addColorStop(f/16,"rgba(0,0,0,"+192*g*g/256/255+")");d.lineWidth=1;d.fillStyle="white";
d.fillRect(0,0,20,16);d.fillStyle=b;d.fillRect(0,0,20,16);a.drawLine(d,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(d,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(d,1,0,1,16,"rgba(0,0,0,"+8/255+")");this.imageUnPush=c.toDataURL();d.fillStyle="white";d.fillRect(0,0,20,16);d.fillStyle=b;d.fillRect(0,0,20,16);a.drawLine(d,0,0,0,14,"gray");a.drawLine(d,0,0,19,0,"gray");d.fillStyle="rgba(0, 0, 0,"+24/255+")";d.fillRect(0,0,this.w,this.h);this.imagePush=c.toDataURL()};a.TextArea.prototype.update=function(){evaluator=
this.evaluator;evaluator.setVariable(this.id,this.text);var a=!1,d=!1,b=!1,e=!1;this.activeCover.style.display=evaluator.evalExpression(this.activeif)?"none":"block";this.containerControl.style.display=evaluator.evalExpression(this.drawif)?"block":"none";var f=evaluator.evalExpression(this.expresion),a=this.x!=f[0][0],d=this.y!=f[0][1];this.x=f[0][0];this.y=f[0][1];4==f[0].length&&(b=this.w!=f[0][2],e=this.h!=f[0][3],this.w=f[0][2],this.h=f[0][3]);(b||e||a||d)&&this.init()};a.TextArea.prototype.registerMouseEvents=
function(){function a(b){b.preventDefault();d.showButton.style.backgroundImage="url("+d.imageUnPush+")"}var d=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();d.showAnswer=!d.showAnswer;d.textAreaAnswer.style.display=d.showAnswer?"block":"none";d.showButton.childNodes[0].childNodes[0].textContent=d.showAnswer?"T":"S";d.showButton.style.backgroundImage="url("+d.imagePush+")"});this.showButton.addEventListener("mouseup",a);this.showButton.addEventListener("mouseout",
a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.LessonParser=function(a){this.parent=a;this.parser=this.parent.evaluator.parser};a.LessonParser.prototype.parseButtonsConfig=function(a){for(var c={rowsNorth:0,rowsSouth:0,widthEast:125,widthWest:125,height:23},a=this.split(a),d,b,g=0,f=a.length;g<f;g++)switch(d=a[g][0],b=a[g][1],babel[d]){case "rowsNorth":c.rowsNorth=parseInt(b);break;case "rowsSouth":c.rowsSouth=parseInt(b);break;case "widthEast":c.widthEast=parseInt(b);
break;case "widthWest":c.widthWest=parseInt(b);break;case "height":c.height=parseInt(b);break;case "about":c.about="true"==babel[b];break;case "config":c.config="true"==babel[b];break;case "init":c.init="true"==babel[b];break;case "clear":c.clear="true"==babel[b];break;default:console.log("----- attributo de Espacio no identificado: <"+d+"> valor: <"+b+"> -----")}return c};a.LessonParser.prototype.parseSpace=function(e){for(var c={},d,e=this.split(e),b,g=0,f=e.length;g<f;g++)switch(d=e[g][0],b=e[g][1],
babel[d]){case "type":c.type=b;break;case "id":c.id=b;break;case "x":d=b;d="%"==d[d.length-1]?(this.parent.container.width*parseFloat(d)/100).toString():b;c.xExpr=this.parser.parse(d);break;case "y":d=b;d="%"==d[d.length-1]?(this.parent.container.height*parseFloat(d)/100).toString():b;c.yExpr=this.parser.parse(d);break;case "width":d=b;"%"==d[d.length-1]?d=this.parent.container.width*parseFloat(d)/100:(d=parseFloat(b),d!=b&&(d=this.parent.container.width));c.w=d;break;case "height":d=b;"%"==d[d.length-
1]?d=this.parent.container.height*parseFloat(d)/100:(d=parseFloat(b),d!=b&&(d=this.parent.container.height));c.h=d;break;case "drawif":c.drawif=this.parser.parse(b);break;case "fixed":c.fixed="true"==babel[b];break;case "scale":d=parseFloat(b);d!=b&&(d=48);c.scale=d;break;case "O.x":c.OxExpr=b;break;case "O.y":c.OyExpr=b;break;case "image":c.imageSrc=b;break;case "bg_display":c.bg_display=babel[b];break;case "background":c.background=this.convertColor(b);break;case "net":c.net="false"==babel[b]?"":
this.convertColor(b);break;case "net10":c.net10="false"==babel[b]?"":this.convertColor(b);break;case "axes":c.axes="false"==babel[b]?"":this.convertColor(b);break;case "text":c.text="false"==babel[b]?"":this.convertColor(b);break;case "numbers":c.numbers="true"==babel[b];break;case "x-axis":c.x_axis=b;break;case "y-axis":c.y_axis=b;break;case "sensitive_to_mouse_movements":c.sensitive_to_mouse_movements="true"==babel[b];break;case "cID":c.cID=b;break;case "R3":c.R3="true"==babel[b];break;case "render":c.render=
babel[b];break;case "split":c.split="true"==babel[b];break;case "file":c.file=b;break;default:console.log("----- attributo de Espacio no identificado: <"+d+"> valor: <"+b+"> -----")}if("R2"==c.type||2==this.parent.version)return new a.Space2D(this.parent,c);if("R3"==c.type)return new a.Space3D(this.parent,c);if("AP"==c.type)return new a.SpaceAP(this.parent,c);if("HTMLIFrame"==c.type)return new a.SpaceHTML_IFrame(this.parent,c)};a.LessonParser.prototype.parseControl=function(e){for(var c={},e=this.split(e),
d,b,g=0,f=e.length;g<f;g++)switch(d=e[g][0],b=e[g][1],babel[d]){case "id":c.id=b;break;case "type":c.type=babel[b];break;case "gui":c.gui=babel[b];break;case "region":c.region=babel[b];break;case "space":c.spaceID=b;break;case "name":c.name=b;break;case "expresion":c.expresion=this.parser.parse(b.replace(")(",","));break;case "fixed":c.fixed="true"==babel[b];break;case "visible":c.visible="true"==babel[b];break;case "color":c.color=this.convertColor(b);break;case "colorInt":c.colorInt=this.convertColor(b);
break;case "bold":"false"!=babel[b]&&(c.bold="bold");break;case "italics":"false"!=babel[b]&&(c.italics="italic");break;case "underlined":"false"!=babel[b]&&(c.underlined=!0);break;case "font_size":c.font_size=this.parser.parse(b);break;case "image":c.imageSrc=b;break;case "action":c.action=babel[b];break;case "parameter":c.parameter=b;break;case "drawif":c.drawif=this.parser.parse(b);break;case "activeif":c.activeif=this.parser.parse(b);break;case "tooltip":c.tooltip=b;break;case "tooltipFont":c.tooltipFont=
b;break;case "Explanation":c.Explanation=b;break;case "ExplanationFont":c.ExplanationFont=b;break;case "msg_pos":c.msg_pos=babel[b];break;case "cID":c.cID=b;break;case "value":d=b.replace(/&squot;/g,"'");d.match(/^\|/)&&(d="'"+d.substring(1),d.match(/\|$/)&&(d=d.substring(0,d.length-1)+"'"));c.valueExpr=this.parser.parse(d);break;case "decimals":c.decimals=this.parser.parse(b);break;case "min":c.min=this.parser.parse(b);break;case "max":c.max=this.parser.parse(b);break;case "incr":c.incr=this.parser.parse(b);
break;case "discrete":c.discrete="true"==babel[b];break;case "onlyText":c.onlyText="true"==babel[b];break;case "evaluate":c.evaluate="true"==babel[b];break;case "answer":c.answer=b;break;case "exponentialif":c.exponentialif=parseFloat(b);break;case "size":c.size=this.parser.parse(b);break;case "constraint":c.constraintExpr=b;break;case "text":c.rawText=b;d=this.parseText(b);b=0;for(var i=d.length;b<i;b++)d[b]=this.parser.parse(d[b],!1);c.text=d;break;case "trace":c.trace=this.convertColor(b);break;
case "options":c.options=b;break;case "font":c.font=b;break;case "file":c.file=b;break;case "autoplay":c.autoplay="true"==babel[b];break;case "loop":c.loop="true"==babel[b];break;case "controls":c.controls="true"==babel[b];break;case "poster":c.poster=babel[b];break;default:var h=d.indexOf("."),i=babel[d.substring(0,h)],h=babel[d.substring(h+1)];if("parameter"==i&&"font"==h){c.parameterFont=b;break}else if("Explanation"==i&&"font"==h){c.ExplanationFont=b;break}else if("tooltip"==i&&"font"==h){c.tooltipFont=
b;break}console.log("----- attributo de control no identificado: <"+d+"> valor: <"+b+"> -----")}if("numeric"==c.type){if(void 0==c.gui||"spinner"==c.gui)return new a.Spinner(this.parent,c);if("button"==c.gui)return new a.Button(this.parent,c);if("textfield"==c.gui)return new a.TextField(this.parent,c);if("menu"==c.gui)return new a.Menu(this.parent,c);if("scrollbar"==c.gui)return new a.Scrollbar(this.parent,c)}else{if("video"==c.type)return new a.Video(this.parent,c);if("audio"==c.type)return new a.Audio(this.parent,
c);if("graphic"==c.type)return new a.GraphicControl(this.parent,c);if("text"==c.type)return new a.TextArea(this.parent,c)}};a.LessonParser.prototype.parseGraphic=function(e,c,d,b){for(var b={rotateExp:b,parameter:"t"},e=this.split(e),g,f,i=0,h=e.length;i<h;i++)switch(g=e[i][0],f=e[i][1],babel[g]){case "space":b.spaceID=f;break;case "type":b.type=babel[f];break;case "background":b.background="true"==babel[f];break;case "color":b.color=this.convertColor(f);break;case "drawif":b.drawif=this.parser.parse(f);
break;case "abs_coord":b.abs_coord="true"==babel[f];break;case "expresion":"macro"!=b.type?(b.expresion=this.parser.parse(f),b.expresionString=f):b.expresion=f;break;case "trace":b.trace=this.convertColor(f);break;case "family":b.family=f;break;case "parameter":b.parameter=f;break;case "fill":b.fill=this.convertColor(f);break;case "fillP":b.fillP=this.convertColor(f);break;case "fillM":b.fillM=this.convertColor(f);break;case "width":b.width=this.parser.parse(f);break;case "visible":b.visible="true"==
babel[f];break;case "editable":b.editable="true"==babel[f];break;case "info":b.info=f;break;case "text":g=this.parseText(f);f=0;for(var j=g.length;f<j;f++)g[f]=this.parser.parse(g[f],!1);b.text=g;break;case "font":b.font=f;break;case "fixed":b.fixed="true"==babel[f];break;case "decimals":b.decimals=this.parser.parse(f);break;case "size":b.size=this.parser.parse(f);break;case "spear":b.spear=this.parser.parse(f);break;case "arrow":b.arrow=this.convertColor(f);break;case "center":b.center=this.parser.parse(f);
break;case "radius":b.radius=this.parser.parse(f);break;case "init":b.init=this.parser.parse(f);break;case "end":b.end=this.parser.parse(f);break;case "vectors":b.vectors="true"==babel[f];break;case "file":g=f.replace(/&squot;/g,"'");"["==g.charAt(0)&&"]"==g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/.jpg$|.png$|.gif$|.svg$/)&&(g="'"+g+"'");b.file=this.parser.parse(g);break;case "inirot":b.inirot=this.parser.parse(f);break;case "opacity":b.opacity=this.parser.parse(f);break;case "inipos":b.inipos=
this.parser.parse(f);break;case "name":b.name=f;break;case "range":b.range=this.parser.parse(f);break;case "border":"false"!=babel[f]&&(b.border=this.convertColor(f));break;case "align":b.align=babel[f];break;default:if(void 0!=b.family&&g.substring(0,b.family.length+1)==b.family+"."){switch(babel[g.substring(b.family.length+1)]){case "interval":b.family_interval=this.parser.parse(f);break;case "steps":b.family_steps=this.parser.parse(f)}break}if(void 0!=b.parameter&&g.substring(0,b.parameter.length+
1)==b.parameter+"."){switch(babel[g.substring(b.parameter.length+1)]){case "interval":b.parameter_interval=this.parser.parse(f);break;case "steps":b.parameter_steps=this.parser.parse(f)}break}console.log("----- attributo del grafico no identificado: <"+g+"> valor: <"+f+"> -----")}c&&(b.abs_coord=c);d&&(b.background=d);if("equation"==b.type)return new a.Equation(this.parent,b);if("curve"==b.type)return new a.Curve(this.parent,b);if("sequence"==b.type)return new a.Sequence(this.parent,b);if("point"==
b.type)return new a.Point(this.parent,b);if("segment"==b.type)return new a.Segment(this.parent,b);if("arrow"==b.type)return new a.Arrow(this.parent,b);if("polygon"==b.type)return new a.Polygon(this.parent,b);if("arc"==b.type)return new a.Arc(this.parent,b);if("text"==b.type)return new a.Text(this.parent,b);if("image"==b.type)return new a.Image(this.parent,b);if("macro"==b.type)return new a.Macro(this.parent,b)};a.LessonParser.prototype.parse3DGraphic=function(e,c,d,b){for(var c={rotateExp:b,parameter:"t"},
e=this.split(e),g,f,d=0,b=e.length;d<b;d++)switch(g=e[d][0],f=e[d][1],babel[g]){case "space":c.spaceID=f;break;case "type":c.type=babel[f];break;case "background":c.background="true"==babel[f];break;case "color":c.color=this.convertColor(f);break;case "drawif":c.drawif=this.parser.parse(f);break;case "expresion":"macro"!=c.type&&"curve"!=c.type&&"surface"!=c.type?(c.expresion=this.parser.parse(f),c.expresionString=f):c.expresion=f;break;case "family":c.family=f;break;case "parameter":c.parameter=
f;break;case "width":c.width=this.parser.parse(f);break;case "length":c.length=this.parser.parse(f);break;case "text":g=this.parseText(f);f=0;for(var i=g.length;f<i;f++)g[f]=this.parser.parse(g[f],!1);c.text=g;break;case "font":c.font=f;break;case "fixed":c.fixed="true"==babel[f];break;case "decimals":c.decimals=this.parser.parse(f);break;case "model":c.model=babel[f];break;case "edges":c.edges="true"==babel[f];break;case "Nu":c.Nu=this.parser.parse(f);break;case "Nv":c.Nu=this.parser.parse(f);break;
case "name":c.name=f;break;case "backcolor":c.backcolor=this.convertColor(f);break;case "inirot":c.inirot=this.parser.parse(f);break;case "endrot":c.endrot=this.parser.parse(f);break;case "inipos":c.inipos=this.parser.parse(f);break;case "endpos":c.endpos=this.parser.parse(f);break;default:if(void 0!=c.family&&g.substring(0,c.family.length+1)==c.family+"."){switch(babel[g.substring(c.family.length+1)]){case "interval":c.family_interval=this.parser.parse(f);break;case "steps":c.family_steps=this.parser.parse(f)}break}if(void 0!=
c.parameter&&g.substring(0,c.parameter.length+1)==c.parameter+"."){switch(babel[g.substring(c.parameter.length+1)]){case "interval":c.parameter_interval=this.parser.parse(f);break;case "steps":c.parameter_steps=this.parser.parse(f)}break}console.log("----- attributo del grafico no identificado: <"+g+"> valor: <"+f+"> -----")}if("point"==c.type)return new a.Point3D(this.parent,c);if("segment"==c.type)return new a.Segment3D(this.parent,c);if("polygon"==c.type)return new a.Polygon3D(this.parent,c);if("curve"==
c.type)return new a.Curve3D(this.parent,c);if("triangle"==c.type)return new a.Triangle3D(this.parent,c);if("face"==c.type)return new a.Face3D(this.parent,c);if("polireg"==c.type)return new a.Polireg3D(this.parent,c);if("surface"==c.type)return new a.Surface3D(this.parent,c);if("text"==c.type)return new a.Text3D(this.parent,c);console.log(c.type)};a.LessonParser.prototype.parseAuxiliar=function(e){for(var c={},e=this.split(e),d=0,b=e.length;d<b;d++)e[d][1]=e[d][1].replace(/&squot;/g,"'");for(var g,
f,d=0,b=e.length;d<b;d++)switch(g=e[d][0],f=e[d][1],babel[g]){case "id":c.id=f;break;case "editable":c.editable="true"==babel[f];break;case "constant":c.constant="true"==babel[f];break;case "array":c.array="true"==babel[f];break;case "file":c.file=f;break;case "matrix":c.matrix="true"==babel[f];break;case "rows":c.rows=this.parser.parse(f);break;case "columns":c.columns=this.parser.parse(f);break;case "algorithm":c.algorithm="true"==babel[f];break;case "init":c.init=f;break;case "do":c.doExpr=f;break;
case "while":c.whileExpr=f;break;case "range":c.range=f;break;case "expresion":c.expresion=f;break;case "size":c.size=this.parser.parse(f);break;case "evaluate":c.evaluate=babel[f];break;case "event":c.event=babel[f];break;case "condition":c.condition=f;break;case "execution":c.execution=babel[f];break;case "msg_pos":c.msg_pos=babel[f];break;case "action":c.action=babel[f];break;case "parameter":c.parameter=f;break;case "sequence":c.sequence="true"==babel[f];break;default:var i=g.indexOf("."),h=babel[g.substring(0,
i)],i=babel[g.substring(i+1)];if("parameter"==h&&"font"==i){c.parameterFont=f;break}console.log("----- attributo de auxiliar no identificado: <"+g+"> valor: <"+f+"> -----")}c.sequence?new a.AuxSequence(this.parent,c):c.constant?(e=new a.Constant(this.parent,c),c.evaluate&&"always"==c.evaluate&&this.parent.auxiliaries.push(e)):c.algorithm&&c.evaluate?this.parent.auxiliaries.push(new a.Algorithm(this.parent,c)):c.array&&!c.matrix&&")"!=c.id.charAt(c.id.length-1)?(e=new a.Vector(this.parent,c),c.evaluate&&
"always"==c.evaluate&&this.parent.auxiliaries.push(e)):c.matrix&&")"!=c.id.charAt(c.id.length-1)?(e=new a.Matrix(this.parent,c),c.evaluate&&"always"==c.evaluate&&this.parent.auxiliaries.push(e)):c.event&&")"!=c.id.charAt(c.id.length-1)?this.parent.events.push(new a.Event(this.parent,c)):")"==c.id.charAt(c.id.length-1)?new a.Function(this.parent,c):new a.Variable(this.parent,c)};a.LessonParser.prototype.parseAction=function(e){var c=e.action,d=e.parent,e=e.parameter;if(c)switch(c){case "message":return new a.Message(d,
e);case "calculate":return new a.Calculate(d,e);case "openURL":return new a.OpenURL(d,e);case "openScene":return new a.OpenScene(d,e);case "about":return new a.About(d,e);case "config":return new a.Config(d,e);case "init":return new a.Init(d,e);case "clear":return new a.Clear(d,e);case "animate":return new a.Animate(d,e);case "initAnimation":return new a.InitAnimation(d,e);case "playAudio":return new a.PlayAudio(d,e);default:console.log("----- Accion no soportada aun: <"+c+"> -----")}else return{execute:function(){}}};
a.LessonParser.prototype.parseAnimation=function(e){for(var c={},e=this.split(e),d,b,g=0,f=e.length;g<f;g++)switch(d=e[g][0],b=e[g][1],babel[d]){case "delay":c.delay=b;break;case "controls":c.controls="true"==babel[b];break;case "auto":c.auto="true"==babel[b];break;case "loop":c.loop="true"==babel[b];break;case "init":c.init=b;break;case "do":c.doExpr=b;break;case "while":c.whileExpr=b;break;case "id":c.id=b;break;case "algorithm":c.algorithm="true"==babel[b];break;case "evaluate":c.evaluate="true"==
babel[b];break;default:console.log("----- attributo de la animacion no identificado: <"+d+">  <"+b+"> -----")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(e,c){var e=this.split(e),d,b,g,f,i,h,j,k,l;b=d="";g=0;f="white";i="black";h="left";j="";k="SansSerif,PLAIN,22";l="SansSerif,PLAIN,20";for(var m,p,o=0,q=e.length;o<q;o++)switch(m=e[o][0],p=e[o][1],m){case "title":d=p;break;case "subtitle":b=p;break;case "subtitlines":g=p;break;case "bgcolor":f="#"+a.getColor(this.evaluator,
p);break;case "fgcolor":i="#"+a.getColor(this.evaluator,p);break;case "align":h=p;break;case "titleimage":j=p;break;case "titlefont":k=a.convertFont(p);break;case "subtitlefont":l=a.convertFont(p);break;default:console.log("----- attributo de la pleca no identificado: <"+m+">  <"+p+"> -----")}m=l.substring(0,l.indexOf("px"));m=m.substring(m.lastIndexOf(" "));var s,n;""!=j&&(s=this.parent.getImage(j),n=s.height);j=document.createElement("div");j.setAttribute("id","descartesPleca");n?(j.setAttribute("style",
"position: absolute; left: 0px; top: 0px; text-align: "+h+"; width: "+(c-30)+"px; height: "+(n-16)+"px; background: "+f+"; color: "+i+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),s.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),j.appendChild(s)):j.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+h+"; width: "+(c-30)+"px; background: "+
f+"; color: "+i+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");f=document.createElement("div");f.setAttribute("style","padding: 0px; margin: 0px; font: "+k+"; overflow: hidden; white-space: nowrap;");f.innerHTML=d;d=document.createElement("div");if(1==parseInt(g)){i=0;g=document.createElement("div");g.innerHTML=b;document.body.appendChild(g);k=m;do k-=i,g.setAttribute("style","padding: 0px; margin: 0px; font: "+l+"; font-size: "+k+"px; width: "+
(c-30)+"px; line-height: "+k+"px;"),i=g.offsetHeight,h=i/k,i=1;while(1<h&&8<k);document.body.removeChild(g);d.setAttribute("style","padding: 0px; margin: 0px; font: "+l+"; font-size: "+k+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else d.setAttribute("style","padding: 0px; margin: 0px; font: "+l+"; line-height: 110%;");d.innerHTML=b;j.appendChild(f);j.appendChild(d);j.imageHeight=n;return j};a.LessonParser.prototype.split=function(a){for(var a=(a||"").replace(/\\'/g,"\u2019"),
c=[],d=0,b=0,g=!1,f=0,i=!1,h=!1;d<a.length;)" "==a.charAt(d)&&!g&&d++," "!=a.charAt(d)&&!g&&(g=!0,f=d),"="==a.charAt(d)&&"'"==a.charAt(d+1)&&!i&&(i=!0,c[b]=[a.substring(f,d)],f=d+2,d+=2),i&&"'"==a.charAt(d)&&(g=i=!1,c[b].push(a.substring(f,d)),b++),"="==a.charAt(d)&&"'"!=a.charAt(d+1)&&!i&&(h=!0,c[b]=[a.substring(f,d)],f=d+1,d++),h&&" "==a.charAt(d)&&(g=h=!1,c[b].push(a.substring(f,d)),b++),h&&d==a.length-1&&c[b].push(a.substring(f,a.length)),d++;return c};a.LessonParser.prototype.splitComa=function(a){for(var c=
[],d=[],b=0,g=0,f=a.length;g<f;g++)"("==a.charAt(g)?d.push(g):")"==a.charAt(g)?d.pop():","==a.charAt(g)&&0==d.length&&(c.push(a.substring(b,g)),b=g+1);c.push(a.substring(b));return c};a.LessonParser.prototype.convertColor=function(a){if(babel[a])return"net"==babel[a]?"red":babel[a];if(6==a.length)return"#"+a;if(8==a.length)return"rgba("+parseInt("0x"+a.substring(2,4),16)+","+parseInt("0x"+a.substring(4,6),16)+","+parseInt("0x"+a.substring(6,8),16)+","+(1-parseInt("0x"+a.substring(0,2),16)/255)+")";
if("("==a[0]){for(var c="(",a=this.splitComa(a.substring(1,a.length-1)),d,b=0,g=a.length;b<g;b++)d=parseInt(a[b],16),a[b]!=d.toString(16)?("["==a[b].charAt(0)&&"]"==a[b].charAt(a[b].length-1)&&(a[b]=a[b].substring(1,a[b].length-1)),c=c+a[b]+(b<g-1?",":")")):c=c+d/255+(b<g-1?",":")");return this.parser.parse(c)}return"#aa0000"};a.LessonParser.prototype.parseText=function(e){if(e.match(/^\{\\rtf1/))return(new a.RTFParser(this.parent.evaluator)).parse(e.substring(10,e.length-1));for(var e=e.split("\\n"),
c=0,d=e.length;c<d;c++)e[c]=this.parseTextElement(e[c]);return e};a.LessonParser.prototype.parseTextElement=function(a){for(var a=a.replace(/&squot;/g,"'"),c="'",d=0,b=-1;d<a.length;)"["==a.charAt(d)&&"\\"==a.charAt(d-1)?c=c.substring(0,c.length-1)+"[":"]"==a.charAt(d)&&"\\"==a.charAt(d-1)?c=c.substring(0,c.length-1)+"]":"["==a.charAt(d)&&-1==b?(b++,c+="'+("):"["==a.charAt(d)?(b++,c+=a.charAt(d)):"]"==a.charAt(d)&&0==b?(b--,c+=")+'"):("]"==a.charAt(d)&&(b=0>b?b:b-1),c+=a.charAt(d)),d++;return c+"'"};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Node=function(a,c){this.sep="";this.type=a;this.value=c;this.parent=null;this.childs=[]};a.Node.prototype.getRoot=function(){return null==this.parent?this:this.parent.getRoot()};a.Node.prototype.addChild=function(a){a.parent=this;this.childs.push(a)};a.Node.prototype.replaceLastChild=function(a){var c=this.childs.length-1;this.childs[c].parent=null;this.childs[c]=a;a.parent=this;return a};a.Node.prototype.toString=function(){var a=
"tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:"");for(var c=0,d=this.childs.length;c<d;c++)a+=this.sep+this.childs[c].toString();return a};a.Node.prototype.contains=function(a){if(this.value==a)return!0;for(var c=0,d=this.childs.length;c<d;c++)if(this.childs[c].contains(a))return!0;return!1};a.Node.prototype.equalToMinus=function(){if("compOperator"==this.type){this.type="operator";this.value="-";var e=new a.Node("compOperator","=="),c=new a.Node("number",
"0");e.addChild(this);e.addChild(c);return this.getRoot()}return this};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){var c=a;a&&(a=a.replace(/\&sup(.+);/g,"^$1 "),a=a.replace(/&squot;/g,"'"),a.match(/\=\|\*/g)&&(a=a.replace("|*","'","g").replace("*|","'","g")));for(var d=[],b=!1,g=0,f,i=a,h=0,j=function(a,b,c){d.push({type:a,value:b});i=i.slice(c);g=g+c;h++};a&&g<a.length;)if(b=g,"'"==i[0]){for(f=1;"'"!=
i[f];)if(f<i.length)f++;else{console.log(">Error, simbolo no conocido: ["+i+"], en la cadena <<"+c+">>");return}f=i.substring(1,f);j("string",f,f.length+2)}else if(f=i.match(/^\s+/))i=i.slice(f[0].length),g+=f[0].length,h++;else if(f=i.match(/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/))j("identifier",f[0],f[0].length);else if(f=i.match(/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/))j("number",f[0],f[0].length);else if(f=i.match(/^==|^!=|^<=|^<|^>=|^>|^#/))b=
f[0],"#"==b&&(b="!="),j("compOperator",b,f[0].length);else if(f=i.match(/^\!|^\~|^\&\&|^\&|^\|\||^\|/))b=f[0],"||"==b?b="|":"&&"==b?b="&":"~"==b&&(b="!"),j("boolOperator",b,f[0].length);else if((f=i.match(/^=/))&&!i.match(/^==/))j("asign",f[0],f[0].length);else if(f=i.match(/^[\?\:]/))j("conditional",f[0],f[0].length);else if(f=i.match(/^[\+\-\*\/\%\^]/))j("operator",f[0],f[0].length);else if(f=i.match(/^\[|^\]/))j("square_bracket",f[0],f[0].length);else if(f=i.match(/^\(|^\)/))j("parentheses",f[0],
f[0].length);else if(f=i.match(/^,/))j("separator",f[0],f[0].length);else if(f=i.match(/^;/))j("final_of_expresion",f[0],f[0].length);else if(b==g){console.log("Error, simbolo no conocido: ["+i+"], en la cadena <<"+c+">>");return}return d};a.Tokenizer.prototype.flatTokens=function(a){for(var a=a||[],c="",d=0,b=a.length;d<b;d++)c="string"==a[d].type?c+"&squot;"+a[d].value+"&squot;":c+a[d].value;return c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Parser=function(e){this.evaluator=
e;this.tokenizer=new a.Tokenizer;this.vectors={};this.matrices={};this.variables={};this.functions={};this.variables.rnd=Math.random;this.variables.pi=Math.PI;this.variables.e=Math.E;this.variables.Infinity=Infinity;this.variables["-Infinity"]=-Infinity;this.functions.sqr=function(a){return a*a};this.functions.sqrt=this.functions["ra\u00edz"]=Math.sqrt;this.functions.exp=Math.exp;this.functions.log=Math.log;this.functions.log10=function(a){return Math.log(a)/Math.log(10)};this.functions.abs=Math.abs;
this.functions.ent=Math.floor;this.functions.sgn=function(a){return 0<a?1:0>a?-1:0};this.functions.ind=function(a){return a?1:0};this.functions.sin=this.functions.sen=Math.sin;this.functions.cos=Math.cos;this.functions.tan=Math.tan;this.functions.cot=function(a){return 1/Math.tan(a)};this.functions.sec=function(a){return 1/Math.cos(a)};this.functions.csc=function(a){return 1/Math.sin(a)};this.functions.sinh=this.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};this.functions.cosh=function(a){return(Math.exp(a)+
Math.exp(-a))/2};this.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/(Math.exp(a)+Math.exp(-a))};this.functions.coth=function(a){return 1/this.functions.tanh(a)};this.functions.sech=function(a){return 1/this.functions.cosh(a)};this.functions.csch=function(a){return 1/this.functions.sinh(a)};this.functions.asin=this.functions.asen=Math.asin;this.functions.acos=Math.acos;this.functions.atan=Math.atan;this.functions.min=Math.min;this.functions.max=Math.max;this.functions.esCorrecto=function(c,
d){return a.esCorrecto(c,d)};this.functions.escorrecto=function(c,d){return a.escorrecto(c,d)}};a.Parser.prototype.setVariable=function(a,c){this.variables[a]=c};a.Parser.prototype.getVariable=function(a){this.variables.hasOwnProperty(a)||(this.variables[a]=0);return this.variables[a]};a.Parser.prototype.setVector=function(a,c,d){this.vectors[a][c]=d};a.Parser.prototype.getVector=function(a){this.vectors.hasOwnProperty(a)||(this.vectors[a]=[0,0,0]);return this.vectors[a]};a.Parser.prototype.setMatrix=
function(a,c,d,b){this.matrices[a][c][d]=b};a.Parser.prototype.getMatrix=function(a){this.matrices.hasOwnProperty(a)||(this.matrices[a]=[[0,0,0],[0,0,0],[0,0,0]]);return this.matrices[a]};a.Parser.prototype.setFunction=function(a,c){this.functions[a]=c};a.Parser.prototype.getFunction=function(a){this.functions.hasOwnProperty(a)||(this.functions[a]=function(){return 0});return this.functions[a]};a.Parser.prototype.parse=function(e,c){var d=this.tokenizer.tokenize(e);d||(d=[]);for(var b=null,g,c=!c||
!1,f=0,i=0,h=0,j,k,l=0,m=d.length;l<m;l++)if(g=d[l],j=g.value,k=g.type,"identifier"==k&&(l+1<m&&"parentheses"==d[l+1].type&&"("==d[l+1].value?this.getFunction(j):l+1<m&&"square_bracket"==d[l+1].type&&"["==d[l+1].value?d[l+3]&&"square_bracket"==d[l+3].type&&"]"==d[l+3].value?this.getVector(j):this.getMatrix(j):this.getVariable(j)),"asign"==k&&c&&(k="compOperator",j="=="),"asign"==k)if(g=new a.Node(k,j),null!=b)if("identifier"==b.type)b.parent&&b.parent.replaceLastChild(g),g.addChild(b),b=g,c=!0;else if("square_bracket"==
b.type)g.addChild(b.parent),b=g,c=!0;else{g.type="compOperator";g.value="==";for(c=!0;b.parent&&this.precedence(b.parent.value)>=this.precedence(g.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(g);g.addChild(b);b=g}else{console.log("Error1: en la expresion <<"+e+">>, en el token {valor: "+j+", tipo: "+k+"}");break}else if("parentheses"==k&&"("==j||"square_bracket"==k&&"["==j)if(g=new a.Node(k,j),"("==j&&f++,"["==j&&i++,null==b)"("==j&&(b=new a.Node("(expr)","(expr)"),b.addChild(g)),"["==j&&
(b=new a.Node("[expr]","[expr]"),b.addChild(g)),b=g;else if("operator"==b.type||"boolOperator"==b.type||"compOperator"==b.type||"conditional"==b.type||"asign"==b.type)b.addChild(g),b=g;else if("sign"==b.type)b.addChild(g),b=g;else if("parentheses"==b.type&&"("==b.value)b.addChild(g),b=g;else if("square_bracket"==b.type&&"["==b.value)b.addChild(g),b=g;else if("parentheses"==b.type&&"()"==b.value)b.parent.addChild(g),b=g;else if("square_bracket"==b.type&&"[]"==b.value)b.parent.addChild(g),b=g;else if("identifier"==
b.type)b.addChild(g),b=g;else{console.log("Error2: en la expresion <<"+e+">>, en el token ["+l+"] {valor: "+j+", tipo: "+k+"}");break}else if("parentheses"==k&&")"==j)if(f--,null==b)console.log("Error3: en la expresion <<"+e+">>, en el token (valor:"+j+", tipo:"+k);else{for(;b&&b.parent&&"("!=b.value;)b=b.parent;if(b&&"("==b.value)b.value="()";else{console.log("Error4: en la expresion <<"+e+">>, en el token {valor: "+j+", tipo: "+k+"}");break}}else if("square_bracket"==k&&"]"==j)if(i--,null==b)console.log("Error5: en la expresion <<"+
e+">>, en el token (valor:"+j+", tipo:"+k);else{for(;b&&b.parent&&"["!=b.value;)b=b.parent;if(b&&"["==b.value)b.value="[]";else{console.log("Error6: en la expresion <<"+e+">>, en el token {valor: "+j+", tipo: "+k+"}");break}}else if("number"==k||"string"==k||"identifier"==k)if(g=new a.Node(k,j),null==b)b=g;else if("operator"==b.type||"compOperator"==b.type||"boolOperator"==b.type||"parentheses"==b.type&&"("==b.value||"square_bracket"==b.type&&"["==b.value||"sign"==b.type||"conditional"==b.type||"asign"==
b.type)b.addChild(g),b=g;else{console.log("Error7: en la expresion <<"+e+">>, en el token {valor: "+j+", tipo: "+k+"}");break}else if("operator"==k||"compOperator"==k||"boolOperator"==k)if(g=new a.Node(k,j),null==b)if("-"==j||"+"==j)g.type="sign",g.value="sign"+j,b=g;else if("!"==j)b=g;else{console.log("Error8: en la expresion <<"+e+">>, en el token {valor: "+j+", tipo: "+k+"}");break}else if("operator"==b.type||"compOperator"==b.type||"boolOperator"==b.type||"asign"==b.type||"conditional"==b.type||
"square_bracket"==b.type&&"["==b.value&&("-"==j||"+"==j||"!"==j)||"parentheses"==b.type&&"("==b.value&&("-"==j||"+"==j||"!"==j)){if("-"==j||"+"==j)g.type="sign",g.value="sign"+j;b.addChild(g);b=g}else if("number"==b.type||"parentheses"==b.type&&"()"==b.value||"square_bracket"==b.type&&"[]"==b.value||"string"==b.type||"identifier"==b.type||"conditional"==b.type||"asign"==b.type){for(;b.parent&&this.precedence(b.parent.value)>=this.precedence(g.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(g);
g.addChild(b);b=g}else{console.log("Error9: en la expresion <<"+e+">>, en el token {valor: "+j+", tipo: "+k+"}");break}else if("conditional"==k)if(g=new a.Node(k,j),null!=b)if("?"==g.value){for(h++;b.parent&&this.precedence(b.parent.value)>this.precedence(g.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(g);g.addChild(b);b=g}else{for(h--;b&&b.parent&&"?"!=b.value;)b=b.parent;if(b&&"?"==b.value)b.value="?:";else{console.log("Error10: en la expresion <<"+e+">>, en el token {valor: "+j+", tipo: "+
k+"}");break}}else{console.log("Error11: en la expresion <<"+e+">>, en el token {valor: "+j+", tipo: "+k+"}");break}else if("separator"==k)if(null!=b)for(;b.parent&&"("!=b.value&&"["!=b.value;)b=b.parent;else{console.log("Error12: en la expresion <<"+e+">>, en el token {valor: "+j+", tipo: "+k+"}");break}else{console.log("Error13: en la expresion <<"+e+">>, en el token {valor: "+j+", tipo: "+k+"}");break}0<f&&alert("Error, faltan parentesis por cerrar: "+e);0>f&&alert("Error, faltan parentesis por abrir: "+
e);0<i&&alert("Error, faltan corchetes por cerrar: "+e);0>i&&alert("Error, faltan corchetes por abrir: "+e);0!=h&&alert("Error, condicional incompleta: "+e);return b?b.getRoot():null};a.Parser.prototype.precedence=function(a){switch(a){case "=":return 1;case "(":return 2;case "[":return 2;case "?":return 2;case ":":return 3;case "?:":return 3;case "&":return 6;case "|":return 6;case "<":return 4;case "<=":return 4;case ">":return 4;case ">=":return 4;case "==":return 4;case "!=":return 4;case "+":return 5;
case "-":return 5;case "/":return 6;case "*":return 6;case "sign-":return 6;case "sign+":return 6;case "!":return 7;case "^":return 7;case "%":return 7;default:return 8}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Evaluator=function(c){this.parent=c;this.parser=new a.Parser;this.variables=this.parser.variables;this.functions=this.parser.functions;this.vectors=this.parser.vectors;this.matrices=this.parser.matrices};a.Evaluator.prototype.setVariable=
function(a,d){this.variables[a]=d};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,d,b){d=0>d?0:e(d);this.vectors[a][d]=b};a.Evaluator.prototype.getVector=function(a,d){d=0>d?0:e(d);return this.vectors[a][d]};a.Evaluator.prototype.setMatrix=function(a,d,b,g){d=0>d?0:e(d);b=0>b?0:e(b);this.matrices[a][d][b]=g};a.Evaluator.prototype.getMatrix=function(a,d,b){d=0>d?0:e(d);b=0>b?0:e(b);return this.matrices[a][d][b]};a.Evaluator.prototype.setFunction=
function(a,d){this.functions[a]=d};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a,d,b){this.decimals=void 0==d||0>d?2:d;this.fixed=b||!1;a=this.evalAux(a);return void 0==a?0:a};a.Evaluator.prototype.evalAux=function(a){if(null==a)return 0;var d=a.type,b=a.childs,g=a.value;if("number"==d)return parseFloat(g);if("string"==d)return g;if("identifier"==d&&0==b.length){if("rnd"==g)return Math.random();b=this.variables[g];return"object"==
typeof b?this.evalAux(b):b}if("square_bracket"==d)return this.evalAux(b[0]);if("identifier"==d&&"square_bracket"==b[0].type&&1==b[0].childs.length){var f=this.evalAux(b[0].childs[0]);try{return this.vectors[g][0>f?0:e(f)]}catch(i){return 0}}else if("identifier"==d&&"square_bracket"==b[0].type&&1<b[0].childs.length){f=this.evalAux(b[0].childs[0]);b=this.evalAux(b[0].childs[1]);try{return this.matrices[g][0>f?0:e(f)][0>b?0:e(b)]}catch(h){return 0}}else{if("identifier"==d&&"parentheses"==b[0].type){for(var j=
[],d=0,f=b[0].childs.length;d<f;d++)j.push(this.evalAux(b[0].childs[d]));if("_Eval_"==g){if(!a.previousExpression||a.previousExpression!=j[0])a.previousExpression=j[0],a.previousParse=this.parser.parse(j[0]);return this.evalAux(a.previousParse)}return this.functions[g].apply(this,j)}if("operator"==d){f=this.evalAux(b[0]);b=this.evalAux(b[1]);if("+"==g)return"string"===typeof f&&"number"==typeof b?(b=this.fixed?b.toFixed(parseFloat(this.decimals)):parseFloat(b.toFixed(parseFloat(this.decimals))),b=
(""+b).replace(".",this.parent.decimal_symbol)+"",f+b):"number"===typeof f&&"string"==typeof b?(g=this.fixed?f.toFixed(parseFloat(this.decimals)):parseFloat(f.toFixed(parseFloat(this.decimals))),g=(""+g).replace(".",this.parent.decimal_symbol)+"",g+b):f+b;if("-"==g)return f-b;if("*"==g)return f*b;if("/"==g)return f/b;if("%"==g)return f-e(f/b)*b;if("^"==g)return Math.pow(f,b)}else if("compOperator"==d){f=this.evalAux(b[0]);b=this.evalAux(b[1]);if("<"==g)return(f<b)+0;if("<="==g)return(f<=b)+0;if(">"==
g)return(f>b)+0;if(">="==g)return(f>=b)+0;if("=="==g)return(f==b)+0;if("!="==g)return(f!=b)+0}else if("boolOperator"==d){f=1==this.evalAux(b[0])?1:0;if("&"==g)return f?1==this.evalAux(b[1])?1:0:0;if("|"==g)return f?1:1==this.evalAux(b[1])?1:0;if("!"==g)return!f+0}else{if("conditional"==d)return(f=this.evalAux(b[0]))?this.evalAux(b[1]):this.evalAux(b[2]);if("sign"==d)return"sign+"==g?this.evalAux(b[0]):-this.evalAux(b[0]);if("parentheses"==d)return this.evalAux(b[0]);if("(expr)"==d||"[expr]"==d){f=
b.length;g=[];if(1==f&&1==b[0].childs.length&&"(expr)"==d)g=this.evalAux(b[0].childs[0]);else for(d=0;d<f;d++){for(var a=[],j=0,k=b[d].childs.length;j<k;j++)a.push(this.evalAux(b[d].childs[j]));g[d]=a}return g}"asign"==d?(g=b[0],b=b[1],1==g.childs.length&&"square_bracket"==g.childs[0].type?(f=g.childs[0].childs,1==f.length?(f=this.evalAux(f[0]),f=0>f?0:e(f),this.vectors[g.value][f]=this.evalAux(b)):2==f.length&&(d=this.evalAux(f[0]),f=this.evalAux(f[1]),d=0>d?0:e(d),f=0>f?0:e(f),this.matrices[g.value][d][f]=
this.evalAux(b))):this.variables[g.value]=this.evalAux(b)):console.log("Error en la evaluacion, expresion desconocida <"+g+"> \n"+a)}}};return a}(descartesJS||{}),descartesJS=function(a){var e,c,d;if(a.loadLib)return a;var b=2,g=!1;a.RTFNode=function(a,b,c,d){this.evaluator=a;this.type="rtfNode";this.value=b;this.nodeType=c;this.style=d;this.styleString=d.toString();this.color=d.textColor;this.underline=d.textUnderline;this.overline=d.textOverline;this.parent=null;this.childs=[];"textBlock"==this.nodeType?
this.draw=this.drawTextBlock:"textLineBlock"==this.nodeType?this.draw=this.drawTextLineBlock:"formula"==this.nodeType?this.draw=this.drawFormula:"superIndex"==this.nodeType?this.draw=this.drawSuperIndex:"subIndex"==this.nodeType?this.draw=this.drawSubIndex:"dynamicText"==this.nodeType?(this.draw=this.drawDynamicText,this.decimal_symbol=this.evaluator.parent.decimal_symbol):"fraction"==this.nodeType?this.draw=this.drawFraction:"numerator"==this.nodeType||"denominator"==this.nodeType?this.draw=this.drawNumDen:
"radical"==this.nodeType?this.draw=this.drawRadical:"limit"==this.nodeType?this.draw=this.drawLimit:"integral"==this.nodeType?this.draw=this.drawIntegral:"sum"==this.nodeType?this.draw=this.drawSum:"matrix"==this.nodeType?this.draw=this.drawMatrix:"defparts"==this.nodeType?this.draw=this.drawDefparts:"text"==this.nodeType||"newLine"==this.nodeType?this.draw=this.drawText:"mathSymbol"==this.nodeType?this.draw=this.drawMathSymbol:"index"==this.nodeType||"radicand"==this.nodeType||"from"==this.nodeType||
"to"==this.nodeType||"what"==this.nodeType||"element"==this.nodeType?this.draw=this.drawGenericBlock:"componentNumCtrl"==this.nodeType?this.draw=this.drawComponentNumCtrl:"componentSpace"==this.nodeType&&(this.draw=this.drawComponentSpace)};a.RTFNode.prototype.getRoot=function(){return null==this.parent?this:this.parent.getRoot()};a.RTFNode.prototype.addChild=function(a){a.parent=this;this.childs.push(a)};a.RTFNode.prototype.toHTML=function(){var a="";if("textLineBlock"===this.nodeType||"textBlock"===
this.nodeType)for(var b=0,c=this.childs.length;b<c;b++)a+=this.childs[b].toHTML();else"text"===this.nodeType?a="<span "+this.style.toCSS()+">"+this.value+"</span>":"newLine"===this.nodeType&&(a="<br />");return a};d=c=e=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType)for(var f=0,i=this.childs.length;f<i;f++)this.childs[f].getTextMetrics();else if("textLineBlock"==this.nodeType)this.getBlockMetric();else if("text"==this.nodeType||"newLine"==this.nodeType||"dynamicText"==
this.nodeType){var h=a.getFontMetrics(this.styleString);this.baseline=h.baseline;this.descent=h.descent;this.ascent=h.ascent;var j=this.value,k;"string"!=typeof this.value&&(f=void 0==this.decimals?b:this.evaluator.evalExpression(this.decimals),k=void 0==this.fixed?g:this.fixed,j=this.evaluator.evalExpression(this.value,f,k),parseFloat(j)==j&&(j=parseFloat(j).toFixed(f),j=k?j:parseFloat(j),j=j.toString().replace(".",this.decimal_symbol)),j+=" ");this.width=a.getTextWidth(j,this.styleString);this.height=
h.height}else if("formula"==this.nodeType)this.getBlockMetric();else if("superIndex"==this.nodeType)k=e,j=c,k=d,f=a.getFontMetrics(this.styleString),h=a.getTextWidth(" ",this.styleString),this.getBlockMetric(),0>this.height&&(this.ascent=f.ascent,this.descent=f.descent,this.height=this.ascent+this.descent,this.width=1.5*h),h=k/2-j+this.height,this.superIndexPos=h-this.ascent,this.ascent=h,this.descent=j,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("subIndex"==this.nodeType)k=
e,j=c,f=a.getFontMetrics(this.styleString),h=a.getTextWidth(" ",this.styleString),this.getBlockMetric(),0>this.height&&(this.ascent=f.ascent,this.descent=f.descent,this.height=this.ascent+this.descent,this.width=1.5*h),this.subIndexPos=j+1,this.ascent=k,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("fraction"==this.nodeType){j=c;k=d;var l=this.childs[0],i=this.childs[1],f=a.getFontMetrics(l.styleString),h=a.getTextWidth(" ",this.styleString);
l.getBlockMetric();i.getBlockMetric();0>l.height&&(l.height=f.height,l.width=h);0>i.height&&(i.height=f.height,i.width=h);this.height=l.height+i.height-1;this.ascent=l.height+k/2-j;this.descent=this.height-this.ascent;this.baseline=this.ascent;this.width=Math.max(l.width,i.width)+h+8}else if("radical"==this.nodeType)j=this.childs[0],f=this.childs[1],j.getBlockMetric(),f.getBlockMetric(),this.ascent=f.height/2<j.height?f.height/2+j.height+2-f.descent:f.ascent+4,this.descent=f.descent,this.baseline=
this.ascent,this.height=this.ascent+this.descent,h=a.getTextWidth(" ",this.styleString),this.width=j.width+f.width+4*h;else if("sum"==this.nodeType)j=this.childs[0],k=this.childs[1],l=this.childs[2],j.getBlockMetric(),k.getBlockMetric(),l.getBlockMetric(),-1==j.ascent&&(h=a.getFontMetrics(j.styleString),j.ascent=h.ascent,j.descent=h.descent,j.height=h.height),-1==k.ascent&&(h=a.getFontMetrics(k.styleString),k.ascent=h.ascent,k.descent=h.descent,k.height=h.height),f=a.getFontMetrics(this.styleString),
this.ascent=f.height+k.height>l.ascent?f.height-f.descent+k.height:l.ascent,this.descent=j.height>l.descent?j.height+f.descent:l.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent,h=this.style.clone(),h.fontType="Times New Roman",h.Bold="bold",h=h.toString(),f=a.getTextWidth(String.fromCharCode(8721),h),h=a.getTextWidth(" ",this.styleString),this.width=Math.max(j.width,k.width,f)+Math.max(l.width,h)+h;else if("integral"==this.nodeType)j=this.childs[0],k=this.childs[1],l=this.childs[2],
j.getBlockMetric(),k.getBlockMetric(),l.getBlockMetric(),-1==j.ascent&&(h=a.getFontMetrics(j.styleString),j.ascent=h.ascent,j.descent=h.descent,j.height=h.height),-1==k.ascent&&(h=a.getFontMetrics(k.styleString),k.ascent=h.ascent,k.descent=h.descent,k.height=h.height),f=a.getFontMetrics(this.styleString),this.ascent=f.height+k.height>l.ascent?f.height-f.descent+k.height:l.ascent,this.descent=j.height>l.descent?j.height+f.descent:l.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent,
h=this.style.clone(),h.fontSize*=1.5,h.fontType="Times New Roman",h.Bold="bold",h=h.toString(),f=a.getTextWidth(String.fromCharCode(8747),h),h=a.getTextWidth(" ",this.styleString),this.width=Math.max(j.width,k.width,f)+Math.max(l.width,h)+2*h;else if("limit"==this.nodeType)j=this.childs[0],k=this.childs[1],l=this.childs[2],f=a.getFontMetrics(this.styleString),j.getBlockMetric(),k.getBlockMetric(),l.getBlockMetric(),-1==j.ascent&&(h=a.getFontMetrics(j.styleString),j.ascent=h.ascent,j.descent=h.descent,
j.height=h.height),-1==k.ascent&&(h=a.getFontMetrics(k.styleString),k.ascent=h.ascent,k.descent=h.descent,k.height=h.height),-1==l.ascent&&(h=a.getFontMetrics(l.styleString),l.ascent=h.ascent,l.descent=h.descent,l.height=h.height),this.ascent=l.ascent,this.descent=Math.max(f.height,l.descent),this.baseline=this.ascent,this.height=this.ascent+this.descent,h=a.getTextWidth(" ",this.styleString),f=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==j.width&&(j.width=h),0==k.width&&(k.width=
h),0==l.width&&(l.width=h),this.width=k.width+j.width+l.width+f+h;else if("matrix"==this.nodeType){h=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);j=c;k=f.ascent;for(var l=f.descent,m=f.height,p=h,o,q,f=0,i=this.childs.length;f<i;f++)this.childs[f].getBlockMetric(),o=this.childs[f].height,q=this.childs[f].width,m<o&&(m=o,k=this.childs[f].ascent,l=this.childs[f].descent),p<q&&(p=q);this.childWidth=p+2*h;this.childHeight=m;this.childAscent=k;this.childDescent=l;this.height=
this.rows*m;this.ascent=this.height/2+j;this.descent=this.height-this.ascent;this.width=this.columns*this.childWidth+h}else if("defparts"==this.nodeType){h=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);j=c;k=f.ascent;l=f.descent;m=f.height;p=h;f=0;for(i=this.childs.length;f<i;f++)this.childs[f].getBlockMetric(),o=this.childs[f].height,q=this.childs[f].width,m<o&&(m=o,k=this.childs[f].ascent,l=this.childs[f].descent),p<q&&(p=q);this.childWidth=p+2*h;this.childHeight=m;this.childAscent=
k;this.childDescent=l;this.height=this.parts*m;this.ascent=this.height/2+j;this.descent=this.height-this.ascent;this.width=p+h/2}else"mathSymbol"==this.nodeType?(h=a.getFontMetrics(this.styleString),this.baseline=h.baseline,this.descent=h.descent,this.ascent=h.ascent,this.width=a.getTextWidth(this.value,this.styleString)+a.getTextWidth(" ",this.styleString),this.height=h.height):"componentNumCtrl"==this.nodeType?(this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),this.height=
this.ascent=this.descent=this.baseline=0,this.width=this.componentNumCtrl.w):"componentSpace"==this.nodeType?(this.componentSpace=this.evaluator.parent.getSpaceByCId(this.value),this.height=this.ascent=this.descent=this.baseline=0,this.width=this.componentSpace.w):console.log("elemento no conocido",this.nodeType)};a.RTFNode.prototype.getBlockMetric=function(){this.width=0;for(var a=-1,b=-1,g,j=0,k=this.childs.length;j<k;j++){g=this.childs[j];g.getTextMetrics();childAscent=g.ascent;childDescent=g.descent;
this.width+=g.width;var l=childDescent;g=g.height;e=childAscent;c=l;d=g;b<childAscent&&(b=childAscent);a<childDescent&&(a=childDescent)}this.ascent=b;this.descent=a;this.baseline=this.ascent;this.height=this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,c,d,e,k,l){this.stableWidth||(this.getTextMetrics(),b=e,g=k);for(var m=k=e=0,p=this.childs.length;m<p;m++)0<m&&(k+=this.childs[m-1].height),"center"==l?e=-this.childs[m].width/2:"right"==l&&(e=-this.childs[m].width),this.childs[m].draw(a,
c+e,d+k)};a.RTFNode.prototype.drawTextLineBlock=function(b,c,d){for(var e=0,g=0,l=this.childs.length;g<l;g++)0<g&&(e+=this.childs[g-1].width,"formula"==this.childs[g-1].nodeType&&(e+=2*a.getTextWidth(" ",this.childs[g].styleString))),this.childs[g].draw(b,c+e,d+this.baseline)};a.RTFNode.prototype.drawFormula=function(b,c,d){for(var e=a.getTextWidth(" ",this.styleString),g=0,l=0,m=this.childs.length;l<m;l++)0<l&&(g+=this.childs[l-1].width),this.childs[l].draw(b,c+e+g,d)};a.RTFNode.prototype.drawText=
function(a,b,c){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,c);if(this.underline){var d="bold"==this.style.textBold,e=d?1:0.5;a.lineWidth=d?2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b-1,parseInt(c+this.descent/2)+e);a.lineTo(b-1+this.width,parseInt(c+this.descent/2)+e);a.stroke()}this.overline&&(e=(d="bold"==this.style.textBold)?2:1.5,a.lineWidth=d?2:1,null!=this.color&&(a.strokeStyle=
this.color),a.beginPath(),a.moveTo(b-1,parseInt(c-this.ascent)+e),a.lineTo(b-1+this.width,parseInt(c-this.ascent)+e),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(c,d,e){var j=Math.floor(0.5*a.getTextWidth(" ",this.styleString)),k=void 0==this.decimals?b:this.evaluator.evalExpression(this.decimals),l=void 0==this.fixed?g:this.fixed,m=this.evaluator.evalExpression(this.value,k,l);parseFloat(m)==m&&(m=l?parseFloat(m).toFixed(k):parseFloat(parseFloat(m).toFixed(k)),m=(""+m).replace(".",this.decimal_symbol));
null!=this.color&&(c.fillStyle=this.color);c.font=this.styleString;c.textAlign="start";c.textBaseline="alphabetic";this.width=a.getTextWidth(m,this.styleString);c.fillText(m,j+d,e);this.underline&&(l=(k="bold"==this.style.textBold)?1:0.5,c.lineWidth=k?2:1,null!=this.color&&(c.strokeStyle=this.color),c.beginPath(),c.moveTo(j+d-1,parseInt(e+this.descent/2)+l),c.lineTo(j+d-1+this.width,parseInt(e+this.descent/2)+l),c.stroke());this.overline&&(l=(k="bold"==this.style.textBold)?2:1.5,c.lineWidth=k?2:1,
null!=this.color&&(c.strokeStyle=this.color),c.beginPath(),c.moveTo(j+d-1,parseInt(e-this.ascent)+l),c.lineTo(j+d-1+this.width,parseInt(e-this.ascent)+l),c.stroke());this.width+=2*j};a.RTFNode.prototype.drawRadical=function(b,c,d){var e=Math.floor(a.getTextWidth(" ",this.styleString));this.childs[0].draw(b,c,Math.floor(d+this.childs[1].descent-this.childs[1].height/2-this.childs[0].descent));this.childs[1].draw(b,c+1.5*e+this.childs[0].width,d);b.lineWidth=1;null!=this.color&&(b.strokeStyle=this.color);
b.beginPath();b.moveTo(c,Math.floor(d+this.childs[1].descent-this.childs[1].height/2));b.lineTo(c+this.childs[0].width,Math.floor(d+this.childs[1].descent-this.childs[1].height/2));b.lineTo(c+this.childs[0].width+0.5*e,d+this.childs[1].descent);b.lineTo(c+this.childs[0].width+1*e,d-this.childs[1].ascent);b.lineTo(c+this.childs[0].width+2*e+this.childs[1].width,d-this.childs[1].ascent);b.stroke()};a.RTFNode.prototype.drawFraction=function(b,c,d){this.childs[0].draw(b,c+(this.width-this.childs[0].width)/
2,d-this.ascent);this.childs[1].draw(b,c+(this.width-this.childs[1].width)/2,d-this.ascent+this.childs[0].height-1);var e=Math.floor(0.5*a.getTextWidth(" ",this.styleString));b.lineWidth=1;null!=this.color&&(b.strokeStyle=this.color);b.beginPath();b.moveTo(c+e,parseInt(d-this.ascent+this.childs[0].height)+0.5);b.lineTo(c-e+this.width-1,parseInt(d-this.ascent+this.childs[0].height)+0.5);b.stroke()};a.RTFNode.prototype.drawNumDen=function(a,b,c){for(var d=0,e=0,g=this.childs.length;e<g;e++)0<e&&(d+=
this.childs[e-1].width),this.childs[e].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,c){for(var d=0,e=0,g=this.childs.length;e<g;e++)0<e&&(d+=this.childs[e-1].width),this.childs[e].draw(a,b+d,c+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,c){for(var d=0,e=0,g=this.childs.length;e<g;e++)0<e&&(d+=this.childs[e-1].width),this.childs[e].draw(a,b+d,c-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,c,d){a.getTextWidth(" ",this.styleString);
var e=a.getFontMetrics(this.styleString),g=" "+String.fromCharCode(8594),l=a.getTextWidth(g,this.styleString);this.childs[0].draw(b,c,d+e.descent+this.childs[0].ascent);this.childs[1].draw(b,c+this.childs[0].width+l,d+e.descent+this.childs[1].ascent);this.childs[2].draw(b,c+l+this.childs[0].width+this.childs[1].width,d);null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",c+this.childs[0].width,d);b.fillText(g,c+this.childs[0].width,
d+e.descent+this.childs[0].ascent)};a.RTFNode.prototype.drawIntegral=function(b,c,d){var e=this.style.clone();e.fontSize*=1.5;e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),g=a.getTextWidth(String.fromCharCode(8747),e),l=a.getFontMetrics(e),m=Math.max(this.childs[0].width,this.childs[1].width,Math.floor(1.5*g)),p=a.getTextWidth(" ",this.styleString);this.childs[0].draw(b,c+g,d+l.descent+this.childs[0].ascent);this.childs[1].draw(b,c+g+p/2,d-this.ascent+this.childs[1].ascent);this.childs[2].draw(b,
c+m+g,d);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),c,d+l.descent/2)};a.RTFNode.prototype.drawSum=function(b,c,d){var e=this.style.clone();e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),g=a.getTextWidth(String.fromCharCode(8721),e),l=a.getFontMetrics(this.styleString),m=Math.max(this.childs[0].width,this.childs[1].width,g);this.childs[0].draw(b,c+(m-this.childs[0].width)/2,d+l.descent+this.childs[0].ascent);
this.childs[1].draw(b,c+(m-this.childs[1].width)/2,d-l.ascent-this.childs[1].descent);this.childs[2].draw(b,c+m,d);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),c+Math.floor((m-g)/2),d-5)};a.RTFNode.prototype.drawMatrix=function(b,c,d){for(var e,g,l=a.getTextWidth(" ",this.styleString),m=0,p=this.childs.length;m<p;m++)e=m%this.columns,g=Math.floor(m/this.columns),this.childs[m].draw(b,2*l+c+e*this.childWidth,
d-this.ascent+this.childAscent+g*this.childHeight);b.lineWidth=1;null!=this.color&&(b.strokeStyle=this.color);b.beginPath();b.moveTo(Math.floor(c+l)+0.5,d-this.ascent+0.5);b.lineTo(Math.floor(c+l/2)+0.5,d-this.ascent+0.5);b.lineTo(Math.floor(c+l/2)+0.5,d+this.descent+0.5);b.lineTo(Math.floor(c+l)+0.5,d+this.descent+0.5);b.moveTo(Math.floor(c+this.width-l)-0.5,d-this.ascent+0.5);b.lineTo(Math.floor(c+this.width-l/2)-0.5,d-this.ascent+0.5);b.lineTo(Math.floor(c+this.width-l/2)-0.5,d+this.descent+0.5);
b.lineTo(Math.floor(c+this.width-l)-0.5,d+this.descent+0.5);b.stroke()};a.RTFNode.prototype.drawDefparts=function(b,c,d){for(var e=a.getTextWidth(" ",this.styleString),g=0,l=this.childs.length;g<l;g++)this.childs[g].draw(b,c+e/4,d-this.ascent+this.childAscent+g%this.parts*this.childHeight);b.lineWidth=1;null!=this.color&&(b.strokeStyle=this.color);b.beginPath();b.moveTo(Math.floor(c+e/3)+0.5,d-this.ascent+0.5);b.lineTo(Math.floor(c+e/6)+0.5,d-this.ascent+0.5+(e/3-e/6));b.lineTo(Math.floor(c+e/6)+
0.5,d+this.descent-this.height/2-(e/3-e/6));b.lineTo(c+0.5,d+this.descent-this.height/2);b.lineTo(Math.floor(c+e/6)+0.5,d+this.descent-this.height/2+(e/3-e/6));b.lineTo(Math.floor(c+e/6)+0.5,d+this.descent+0.5-(e/3-e/6));b.lineTo(Math.floor(c+e/3)+0.5,d+this.descent+0.5);b.stroke()};a.RTFNode.prototype.drawMathSymbol=function(b,c,d){var e=a.getTextWidth(" ",this.styleString);b.lineWidth=1;null!=this.color&&(b.strokeStyle=this.color,b.fillStyle=this.color);b.beginPath();"("==this.value?(b.moveTo(c+
e,d-this.parent.ascent+this.height/10),b.quadraticCurveTo(c+e/5,d+this.parent.descent-this.parent.height/2,c+e,d+this.parent.descent-this.height/10),b.stroke()):")"==this.value?(b.moveTo(c+e,d-this.parent.ascent+this.height/10),b.quadraticCurveTo(c+e+4*e/5,d+this.parent.descent-this.parent.height/2,c+e,d+this.parent.descent-this.height/10),b.stroke()):(b.font=this.styleString,b.textAlign="center",b.textBaseline="alphabetic",b.fillText(this.value,c+this.width/2,d))};a.RTFNode.prototype.drawGenericBlock=
function(a,b,c){for(var d=0,e=0,g=this.childs.length;e<g;e++)0<e&&(d+=this.childs[e-1].width),this.childs[e].draw(a,b+d,c)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,b,c){this.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+b+","+(c-this.parent.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,b,c){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(b+"");this.componentSpace.yExpr=
this.evaluator.parser.parse(c-this.parent.ascent+"")};a.RTFNode.prototype.draw=function(a,b,c){console.log(">>> Dibujo desconocido ",this.nodeType);this.childs[0].draw(a,b,c)};a.getFontMetrics=function(a){var b=document.createElement("span");b.setAttribute("style","font: "+a+"; margin: 0; padding: 0;");b.appendChild(document.createTextNode("\u00c1p Texto"));a=document.createElement("div");a.setAttribute("style","display: inline-block; width: 1px; height: 0px;");var c=document.createElement("div");
c.setAttribute("style","margin: 0; padding: 0;");c.appendChild(b);c.appendChild(a);document.body.appendChild(c);var d={};a.style.verticalAlign="baseline";d.ascent=a.offsetTop-b.offsetTop;a.style.verticalAlign="bottom";d.height=a.offsetTop-b.offsetTop;d.descent=d.height-d.ascent;d.baseline=d.ascent;document.body.removeChild(c);return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=function(a){a&&(a=a.replace(/(\\\w+)(\\u\d+)/g,
"$1 $2"),a=a.replace(/\\u(\d+) /g,function(a,b){return String.fromCharCode(parseInt(b))}),a=a.replace(/\'/g,"&squot;"),a=a.replace(/&amp;/g,"&"),a=a.replace(/&lt;/g,"<"),a=a.replace(/&gt;/g,">"));for(var c=[],d=a,b=0,g=0,f,i,h,j,k=function(a,e,f){c.push({type:a,value:e});d=d.slice(f);b=b+f};a&&b<a.length;)if(i=b,"{"==d[0])g++,k("openBlock",g,1);else if("}"==d[0])k("closeBlock",g,1),g--,""==d&&(b=a.length);else if((f=d.match(/^\\([\w\*]*)\\/))&&f[1])f=f[1],k("controlWord",f,f.length+1),b-=1;else if((f=
d.match(/^\\(\w*)\s/))&&f[1])f=f[1],k("controlWord",f,f.length+2);else if((f=d.match(/^\\(\w*)\{/))&&f[1])f=f[1],k("controlWord",f,f.length+1),b-=1;else if((f=d.match(/^\\(\w*)\}/))&&f[1])f=f[1],k("controlWord",f,f.length+1),b-=1;else if((f=d.match(/^\\(\w*)\;\\/))&&f[1])f=f[1],k("controlWord",f,f.length+2),b-=1;else if((f=d.match(/^\\(\w*)\;\}/))&&f[1])f=f[1],k("controlWord",f,f.length+2),b-=1;else if((f=d.match(/^\\(\w*)/))&&f[1])f=f[1],k("controlWord",f,f.length+1),b=a.length;else if("{"!=d[0]&&
"}"!=d[0]&&"\\"!=d[0])f=d.indexOf("{"),i=d.indexOf("}"),h=d.indexOf("\\"),j=d.length,f=-1==f?j+1:f,i=-1==i?j+1:i,h=-1==h?j+1:h,f=Math.min(f,i,h),-1!=f&&0!=f?(k("text",d.substring(0,f),f),""==d&&(b=a.length)):(k("text",d,d.length+1),b=a.length);else if(i==b){console.log("Error, simbolo no conocido: <<["+d+"]>>");return}return c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.RTFParser=function(e){this.evaluator=e;this.tokenizer=new a.RTFTokenizer};a.RTFParser.prototype.parse=
function(e){var e=this.tokenizer.tokenize(e),e=checkMathSymboslInFormula(e),c={},d,b=2;if("openBlock"==e[0].type&&"fonttbl"==e[1].value){for(d=e[0].value;"closeBlock"!=e[b].type&&e[b].value!=d;)c[e[b].value]=e[b+2].value.substring(0,e[b+2].value.length-1),b+=3;b++}var g={},f=0,i,h,j;if("openBlock"==e[b].type&&"colortbl"==e[b+1].value){d=e[b++].value;for(b++;"closeBlock"!=e[b].type&&e[b].value!=d;)i=parseInt(e[b++].value.substring(3)).toString(16),h=parseInt(e[b++].value.substring(5)).toString(16),
j=parseInt(e[b++].value.substring(4)).toString(16),g[f++]="#"+(2>i.length?"0"+i:i)+(2>h.length?"0"+h:h)+(2>j.length?"0"+j:j);b++}d=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");f=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");d.addChild(f);for(var k,l,m,p=j=h=i=!1,o=!1,q=!1,s=[new a.FontStyle(20,"Arial","","",!1,!1,null)],n=s[0],t=!0,w=-1,v=-1,r=[],y=!1,x=!1,z=!1,B=e.length;b<B;b++)if("controlWord"==e[b].type&&c[e[b].value])n.fontType=c[e[b].value];else if("controlWord"==e[b].type&&
e[b].value.match(/^fs(\d+)/))n.fontSize=parseInt(e[b].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==e[b].type&&"b"==e[b].value)n.textBold="bold";else if("controlWord"==e[b].type&&"b0"==e[b].value)n.textBold="";else if("controlWord"==e[b].type&&"i"==e[b].value)n.textItalic="italic";else if("controlWord"==e[b].type&&"i0"==e[b].value)n.textItalic="";else if("controlWord"==e[b].type&&"ul"==e[b].value)n.textUnderline=!0;else if("controlWord"==e[b].type&&"ulnone"==e[b].value)n.textUnderline=!1;else if("controlWord"==
e[b].type&&"ol"==e[b].value)n.textOverline=!0;else if("controlWord"==e[b].type&&"olnone"==e[b].value)n.textOverline=!1;else if("controlWord"==e[b].type&&e[b].value.match(/^cf(\d+)/))n.textColor=g[parseInt(e[b].value.substring(2))];else if("openBlock"==e[b].type)w=e[b].value,n=n.clone(),s.push(n),r.push(null);else if("closeBlock"==e[b].type)e[b].value==v&&(v=-1,i=!1),s.pop(),n=s[s.length-1],r.pop();else if("controlWord"==e[b].type&&"par"==e[b].value){f.addChild(new a.RTFNode(this.evaluator,"","newLine",
n));d=new a.RTFNode(this.evaluator,"","textLineBlock",n);if("textBlock"!=f.nodeType)for(f=f.parent;"textBlock"!=f.nodeType;)f=f.parent;f.addChild(d);f=d}else if("controlWord"==e[b].type&&"mjaformula"==e[b].value)y=!0,v=w,i=!0,d=new a.RTFNode(this.evaluator,"","formula",n.clone()),f.addChild(d),f=d,r[r.length-1]=d;else if("controlWord"==e[b].type&&("fraction"==e[b].value||"radicand"==e[b].value||"radical"==e[b].value||"what"==e[b].value||"sum"==e[b].value||"integral"==e[b].value||"limit"==e[b].value)){var u=
r[r.length-2].style.clone();d=new a.RTFNode(this.evaluator,"",e[b].value,u);r[r.length-2].addChild(d);r[r.length-1]=d}else if("controlWord"==e[b].type&&"index"==e[b].value||"to"==e[b].value||"from"==e[b].value)u=r[r.length-2].style.clone(),u.fontSize=parseInt(u.fontSize-0.2*u.fontSize),8>u.fontSize&&(u.fontSize=8),d=new a.RTFNode(this.evaluator,"",e[b].value,u),r[r.length-2].addChild(d),r[r.length-1]=d;else if("controlWord"==e[b].type&&("num"==e[b].value||"den"==e[b].value))u=r[r.length-2].style.clone(),
u.fontSize=Math.round(u.fontSize-0.1*u.fontSize),8>u.fontSize&&(u.fontSize=8),"num"==e[b].value?d=new a.RTFNode(this.evaluator,"","numerator",u):"den"==e[b].value&&(d=new a.RTFNode(this.evaluator,"","denominator",u)),r[r.length-2].addChild(d),r[r.length-1]=d;else if("controlWord"==e[b].type&&("subix"==e[b].value||"supix"==e[b].value))u=r[r.length-2].style.clone(),u.fontSize=Math.floor(u.fontSize-u.fontSize/3),8>u.fontSize&&(u.fontSize=8),"subix"==e[b].value?d=new a.RTFNode(this.evaluator,"","subIndex",
u):"supix"==e[b].value&&(d=new a.RTFNode(this.evaluator,"","superIndex",u)),d.originalStyle=r[r.length-2].style.clone(),r[r.length-2].addChild(d),r[r.length-1]=d;else if("controlWord"==e[b].type&&("defparts"==e[b].value||"matrix"==e[b].value||"element"==e[b].value))u=r[r.length-2].style.clone(),d=new a.RTFNode(this.evaluator,"",e[b].value,u),r[r.length-2].addChild(d),r[r.length-1]=d,"defparts"==e[b].value?m=d:"matrix"==e[b].value&&(l=d);else if("controlWord"==e[b].type&&"parts"==e[b].value)q=!0;else if("text"==
e[b].type&&q)m.parts=parseInt(e[b].value),q=!1;else if("controlWord"==e[b].type&&"rows"==e[b].value)p=!0;else if("text"==e[b].type&&p)l.rows=parseInt(e[b].value),p=!1;else if("controlWord"==e[b].type&&"columns"==e[b].value)o=!0;else if("text"==e[b].type&&o)l.columns=parseInt(e[b].value),o=!1;else if("controlWord"==e[b].type&&"expr"==e[b].value)t=!1,h=!0;else if("controlWord"==e[b].type&&"decimals"==e[b].value)j=!0;else if("text"==e[b].type&&j)k.decimals=this.evaluator.parser.parse(e[b].value),j=!1;
else if("controlWord"==e[b].type&&"fixed1"==e[b].value)k.fixed=!0;else if("controlWord"==e[b].type&&"fixed0"==e[b].value)k.fixed=!1;else if(!("controlWord"==e[b].type&&"component"==e[b].value))if("controlWord"==e[b].type&&"NumCtrl"==e[b].value)x=!0;else if("controlWord"==e[b].type&&"Space"==e[b].value)z=!0;else if("text"==e[b].type&&x)d=new a.RTFNode(this.evaluator,e[b].value,"componentNumCtrl",n.clone()),f.addChild(d),x=!1;else if("text"==e[b].type&&z)d=new a.RTFNode(this.evaluator,e[b].value,"componentSpace",
n.clone()),f.addChild(d),z=!1;else if("text"==e[b].type&&h)u=r[r.length-2].style.clone(),textContent=this.evaluator.parser.parse("''+("+e[b].value+")"),d=new a.RTFNode(this.evaluator,textContent,"dynamicText",u),r[r.length-2].addChild(d),k=r[r.length-1]=d,h=!1;else if("text"==e[b].type&&!h&&!i){textContent=e[b].value;d=new a.RTFNode(this.evaluator,textContent,"text",n.clone());if("textLineBlock"!=f.nodeType)for(f=f.parent;"textLineBlock"!=f.nodeType;)f=f.parent;f.addChild(d)}else if("text"==e[b].type&&
!h&&i)textContent=e[b].value,d=new a.RTFNode(this.evaluator,textContent,"text",r[r.length-1].style.clone()),r[r.length-1].addChild(d);else if("("==e[b].type||")"==e[b].type||"+"==e[b].type||"-"==e[b].type||"*"==e[b].type||"="==e[b].type)d=new a.RTFNode(this.evaluator,e[b].type,"mathSymbol",r[r.length-1].style.clone()),r[r.length-1].addChild(d);if(null!=f){var A=f.getRoot();A.stableWidth=t;A.getTextMetrics();A.hasFormula=y}return A};a.FontStyle=function(a,c,d,b,g,f,i){this.fontSize=a;this.fontType=
c;this.textItalic=d;this.textBold=b;this.textUnderline=g;this.textOverline=f;this.textColor=i};a.FontStyle.prototype.toString=function(){return(this.textBold+" "+this.textItalic+" "+this.fontSize+"px "+this.fontType).trim()};a.FontStyle.prototype.toCSS=function(){var a="style='font-family: "+this.fontType+"; font-size: "+this.fontSize+"px; ";this.textUnderline&&!this.textOverline&&(a+="text-decoration: underline; ");!this.textUnderline&&this.textOverline&&(a+="text-decoration: overline; ");this.textUnderline&&
this.textOverline&&(a+="text-decoration: underline overline; ");this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: bold; ");!this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: normal; ");this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: bold; ");!this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: normal; ");this.textColor&&(a+="color: "+this.textColor+"; ");return a+"'"};a.FontStyle.prototype.clone=function(){return new a.FontStyle(this.fontSize,
this.fontType,this.textItalic,this.textBold,this.textUnderline,this.textOverline,this.textColor)};checkMathSymboslInFormula=function(a){for(var c=[],d=!1,b=!1,g=[],f=0,i=a.length;f<i;f++){"openBlock"==a[f].type&&g.push(a[f].value);"closeBlock"==a[f].type&&(g.pop(),0>=g.length&&(d=!1));if("controlWord"==a[f].type&&("expr"==a[f].value||"decimals"==a[f].value))b=!0;"controlWord"==a[f].type&&"mjaformula"==a[f].value&&(d=!0);if("text"==a[f].type&&d&&!b){for(var h=0,j=a[f].value,k="",l=0,m=j.length;l<m;l++)if("("==
j.charAt(l)||")"==j.charAt(l)||"+"==j.charAt(l)||"-"==j.charAt(l)||"*"==j.charAt(l)||"="==j.charAt(l))k=j.substring(h,l),""!=k&&c.push({type:"text",value:k}),c.push({type:j.charAt(l),value:j.charAt(l)}),h=l+1;k=j.substring(h,l);""!=k&&c.push({type:"text",value:k})}else c.push(a[f]),"text"==a[f].type&&b&&(b=!1)}return c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Space=function(a,d){this.parent=a;this.evaluator=this.parent.evaluator;var b=this.evaluator.parser;
this.values=d;this.type="R2";this.xExpr=b.parse("0");this.yExpr=b.parse("0");this.w=parseInt(a.container.width);this.h=parseInt(a.container.height);this.drawif=b.parse("1");this.fixed=2!=this.parent.version?!1:!0;this.scale=48;this.Oy=this.Ox=0;this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";this.bg_display="topleft";this.background="descinst.com.mja.descartes.DescartesJS.class"==this.parent.code?"#f0f8fa":"#ffffff";this.net=2!=this.parent.version?"#c0c0c0":"";this.net10=
2!=this.parent.version?"#808080":"";this.axes=2!=this.parent.version?"#808080":"";this.text="#ffafaf";this.numbers=!1;this.y_axis=this.x_axis="";this.sensitive_to_mouse_movements=!1;this.cID="";this.mouse_y=this.mouse_x=0;this.ctrs=[];this.graphics=[];this.zIndex=a.zIndex;this.plecaHeight=this.parent.plecaHeight||0;this.displaceRegionNorth=this.parent.displaceRegionNorth||0;this.displaceRegionWest=this.parent.displaceRegionWest||0;for(var e in d)d.hasOwnProperty(e)&&(this[e]=d[e]);this.init()};a.Space.prototype.init=
function(){this.displaceRegionNorth=this.parent.displaceRegionNorth||0;this.displaceRegionWest=this.parent.displaceRegionWest||0;var a=this.parent,d=this.evaluator,b=this.id,e,f=parseInt(this.parent.container.height),i=parseInt(this.parent.container.width);d.setVariable(b+"._w",this.w);d.setVariable(b+"._h",this.h);this.x=d.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=d.evalExpression(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+
"px",this.container.style.top=this.y+"px");0<=this.y?(e=f-this.y,this.h>e&&(this.h=e)):(e=this.h+this.y,this.h=e>=f?f:e);0<=this.x?(e=i-this.x,this.w>e&&(this.w=e)):(e=this.w+this.x,this.w=e>=i?i:e);if(""!=this.imageSrc||!this.imageSrc.toLowerCase().match(/vacio.gif$/))this.image=a.getImage(this.imageSrc);this.OxExpr&&(i=this.OxExpr,"%"==i[i.length-1]?this.Ox=this.w*parseFloat(i)/100:(a=parseFloat(i),a!=i&&(a=0),this.Ox=a));this.OyExpr&&(i=this.OyExpr,"%"==i[i.length-1]?this.Oy=this.h*parseFloat(i)/
100:(a=parseFloat(i),a!=i&&(a=0),this.Oy=a));2!=this.parent.version?(d.setVariable(b+"._w",this.w),d.setVariable(b+"._h",this.h),d.setVariable(b+".escala",this.scale),d.setVariable(b+".Ox",this.Ox),d.setVariable(b+".Oy",this.Oy),d.setVariable(b+".mouse_x",0),d.setVariable(b+".mouse_y",0),d.setVariable(b+".mouse_pressed",0)):(d.setVariable("_w",this.w),d.setVariable("_h",this.h),d.setVariable("escala",this.scale),d.setVariable("Ox",this.Ox),d.setVariable("Oy",this.Oy),d.setVariable("mouse_x",0),d.setVariable("mouse_y",
0),d.setVariable("mouse_pressed",0))};a.Space.prototype.addCtr=function(a){this.ctrs.push(a)};a.Space.prototype.addGraph=function(a){this.graphics.push(a)};a.Space.prototype.getRelativeX=function(a){return(a-e(this.w/2+this.Ox))/this.scale};a.Space.prototype.getRelativeY=function(a){return(-a+e(this.h/2+this.Oy))/this.scale};a.Space.prototype.getAbsoluteX=function(a){return a*this.scale+e(this.w/2+this.Ox)};a.Space.prototype.getAbsoluteY=function(a){return-a*this.scale+e(this.h/2+this.Oy)};a.Space.prototype.findOffset=
function(){var a=this.container,d;for(this.offsetTop=this.offsetLeft=0;a;){d=null;a.getAttribute&&(d=a.getAttribute("class"));if(d&&("DescartesSpace2DContainer"==d||"DescartesAppContainer"==d))this.offsetLeft+=a.offsetLeft,this.offsetTop+=a.offsetTop;a=a.parentNode}};a.Space.prototype.getCursorPosition=function(c){c=a.getCursorPosition(c);return{x:c.x-this.offsetLeft,y:c.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,c=Math.round,d=2*Math.PI;
a.Space2D=function(b,c){a.Space.call(this,b,c);this.backgroundCanvas=document.createElement("canvas");this.backgroundCanvas.setAttribute("id",this.id+"_background");this.backgroundCanvas.setAttribute("width",this.w+"px");this.backgroundCanvas.setAttribute("height",this.h+"px");this.backgroundCtx=this.backgroundCanvas.getContext("2d");this.canvas=document.createElement("canvas");this.canvas.setAttribute("id",this.id+"_canvas");this.canvas.setAttribute("width",this.w+"px");this.canvas.setAttribute("height",
this.h+"px");this.canvas.setAttribute("class","DescartesSpace2DCanvas");this.canvas.setAttribute("style","z-index: "+this.zIndex+";");this.ctx=this.canvas.getContext("2d");this.graphicControlContainer=document.createElement("div");this.graphicControlContainer.setAttribute("id",this.id+"_graphicControls");this.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+this.zIndex+";");this.numericalControlContainer=document.createElement("div");this.numericalControlContainer.setAttribute("id",
this.id+"_numericalControls");this.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+this.zIndex+";");this.container=document.createElement("div");this.container.setAttribute("id",this.id);this.container.setAttribute("class","DescartesSpace2DContainer");this.container.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.container.appendChild(this.backgroundCanvas);this.container.appendChild(this.canvas);this.container.appendChild(this.graphicControlContainer);
this.container.appendChild(this.numericalControlContainer);b.container.insertBefore(this.container,b.loader);this.findOffset();this.drawBefore=this.evaluator.evalExpression(this.drawif);this.registerMouseEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.update=function(a){var c=2!=this.parent.version?this.id+".Ox":"Ox",d=2!=this.parent.version?this.id+".Oy":"Oy",e=2!=this.parent.version?this.id+".escala":"escala",h=this.evaluator;h.setVariable(this.id+"._w",this.w);h.setVariable(this.id+"._h",
this.h);var j=this.x!=h.evalExpression(this.xExpr)+this.displaceRegionWest,k=this.y!=h.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.spaceChange=a||j||k||this.drawBefore!=h.evalExpression(this.drawif)||this.Ox!=h.getVariable(c)||this.Oy!=h.getVariable(d)||this.scale!=h.getVariable(e);this.x=j?h.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=k?h.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;this.Ox=h.getVariable(c);
this.Oy=h.getVariable(d);this.scale=h.getVariable(e);this.drawBefore=h.evalExpression(this.drawif);1.0E-6>this.scale?(this.scale=1.0E-6,h.setVariable(e,0)):1E6<this.scale&&(this.scale=1E6,h.setVariable(e,1E6));j&&(this.container.style.left=this.x+"px");k&&(this.container.style.top=this.y+"px");(j||k)&&this.findOffset();if(h.evalExpression(this.drawif)){this.container.style.display="block";c=0;for(d=this.graphics.length;c<d;c++)a=this.graphics[c],""!=a.trace&&!this.spaceChange&&!this.click&&!a.background&&
a.drawTrace();this.drawBackground();this.draw()}else this.container.style.display="none"};a.Space2D.prototype.drawBackground=function(){if(this.spaceChange){var b=this.evaluator,c=this.backgroundCtx;c.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);c.fillStyle=a.getColor(b,this.background);c.fillRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);this.image&&""!=this.image.src&&this.image.ready&&this.image.complete&&("topleft"==this.bg_display?c.drawImage(this.image,
0,0):"stretch"==this.bg_display?c.drawImage(this.image,0,0,this.w,this.h):"patch"==this.bg_display?(c.fillStyle=c.createPattern(this.image,"repeat"),c.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"==this.bg_display&&c.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));for(var d=this.scale,i=0;d>this.w+this.h;)d/=10,i++;for(;d<(this.w+this.h)/10;)d*=10;c.lineWidth=1;""!=this.net&&(c.strokeStyle=a.getColor(b,this.net),this.drawMarks(c,d/10,-1));""!=this.net10&&
(c.strokeStyle=a.getColor(b,this.net10),this.drawMarks(c,d,-1));""!=this.axes&&(c.strokeStyle=a.getColor(b,this.axes),c.beginPath(),c.moveTo(e(this.w/2+this.Ox)+0.5,0),c.lineTo(e(this.w/2+this.Ox)+0.5,this.h),c.moveTo(0,e(this.h/2+this.Oy)+0.5),c.lineTo(this.w,e(this.h/2+this.Oy)+0.5),c.stroke(),this.drawMarks(c,d,4),this.drawMarks(c,d/2,2),this.drawMarks(c,d/2/5,1));if(""!=this.x_axis||""!=this.y_axis)c.fillStyle=a.getColor(b,this.axes),c.font="12px Arial",c.textAlign="right",c.textBaseline="top",
c.fillText(this.x_axis,e(this.w)-2,e(this.h/2+this.Oy)),c.fillText(this.y_axis,e(this.w/2+this.Ox)-2,0);this.numbers&&""!=this.axes&&(c.fillStyle=a.getColor(b,this.axes),c.font="12px Arial",c.textAlign="start",c.textBaseline="bottom",d>(this.w+this.h)/2?this.drawNumbers(c,d/5,d<=this.scale?i+1:i):d>(this.w+this.h)/4?this.drawNumbers(c,d/2,d<=this.scale?i+1:i):this.drawNumbers(c,d,i));b=0;for(c=this.graphics.length;b<c;b++)d=this.graphics[b],d.background&&d.draw()}};a.Space2D.prototype.draw=function(){var b=
this.ctx;b.clearRect(0,0,this.canvas.width,this.canvas.height);for(var c=0,f=this.graphics.length;c<f;c++){var i=this.graphics[c];i.background||i.draw()}c=0;for(f=this.ctrs.length;c<f;c++)i=this.ctrs[c],"graphic"==i.type&&i.draw();if(""!=this.text&&this.click&&"LEFT"==this.whichButton){b.fillStyle=a.getColor(this.evaluator,this.text);b.strokeStyle=b.fillStyle;b.font="12px Courier New";b.textAlign="center";b.textBaseline="bottom";var c=1>=this.scale?this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length),
f=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),c="("+c+","+f+")",f=b.measureText(c).width,i=this.getAbsoluteX(this.mouse_x),h=this.getAbsoluteY(this.mouse_y),j=e(i),k=e(h-10);j+f/2>this.w?j=this.w-f/2:0>j-f/2&&(j=f/2);k+1>this.h?k=this.h:0>k-14&&(k=15);b.fillText(c,j,k);b.beginPath();b.arc(i,h,2.5,0,d,!0);b.stroke()}};a.Space2D.prototype.drawMarks=function(a,d,f){var i=this.w,h=this.h,j,k=0,l=i,m=0,p=h,o=e(i/2+this.Ox),q=e(h/2+this.Oy);0<=f&&(k=o-f,l=o+
f,m=q-f,p=q+f);a.beginPath();for(f=-c(o/d);(j=o+c(f*d))<i;f++)a.moveTo(j+0.5,m+0.5),a.lineTo(j+0.5,p+0.5);for(f=-c(q/d);(i=q+c(f*d))<h;f++)a.moveTo(k+0.5,i+0.5),a.lineTo(l+0.5,i+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,d){for(var f=this.w,i=this.h,h,j=e(f/2+this.Ox),k=e(i/2+this.Oy),l=-c(j/d);(h=j+c(l*d))<f;l++)a.fillText(parseFloat((l*d/this.scale).toFixed(4)),h+2,k-2);for(l=-c(k/d);(f=k+c(l*d))<i;l++)a.fillText(parseFloat((-l*d/this.scale).toFixed(4)),j+2,f-2)};a.Space2D.prototype.registerMouseEvents=
function(){function b(a){l.click=1;l.parent.evaluator.setVariable(l.id+".mouse_pressed",1);l.parent.deactivateGraphiControls();h(a);l.parent.update();window.addEventListener("touchmove",k,!1);window.addEventListener("touchend",c,!1);a.preventDefault()}function c(a){l.click=0;l.parent.evaluator.setVariable(l.id+".mouse_pressed",0);window.removeEventListener("touchmove",k,!1);window.removeEventListener("touchend",c,!1);l.parent.update();a.preventDefault();l.parent.update()}function d(a){l.click=1;l.parent.evaluator.setVariable(l.id+
".mouse_pressed",1);l.parent.deactivateGraphiControls();l.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"RIGHT"==l.whichButton&&(window.addEventListener("mouseup",i,!1),l.fixed||(l.clickPosForZoom=l.getCursorPosition(a).y,l.tempScale=l.scale,window.addEventListener("mousemove",j,!1)));"LEFT"==l.whichButton&&(l.parent.evaluator.setVariable(l.id+".mouse_pressed",1),h(a),window.addEventListener("mousemove",k,!1),window.addEventListener("mouseup",
i,!1));a.preventDefault()}function i(a){l.click=0;l.parent.evaluator.setVariable(l.id+".mouse_pressed",0);a.preventDefault();"RIGHT"==l.whichButton&&window.removeEventListener("mousemove",j,!1);l.sensitive_to_mouse_movements||window.removeEventListener("mousemove",k,!1);window.removeEventListener("mouseup",i,!1);l.parent.update();l.parent.update()}function h(a){l.posAnte=l.getCursorPosition(a);l.mouse_x=l.getRelativeX(l.posAnte.x);l.mouse_y=l.getRelativeY(l.posAnte.y);l.parent.evaluator.setVariable(l.id+
".mouse_x",l.mouse_x);l.parent.evaluator.setVariable(l.id+".mouse_y",l.mouse_y);l.parent.update()}function j(a){l.clickPosForZoomNew=l.getCursorPosition(a).y;l.evaluator.setVariable(2!=l.parent.version?l.id+".escala":"escala",l.tempScale+l.tempScale/45*((l.clickPosForZoom-l.clickPosForZoomNew)/10));l.parent.update();a.preventDefault()}function k(a){if(!l.fixed){l.posNext=l.getCursorPosition(a);var b=e(l.posAnte.x-l.posNext.x),c=e(l.posAnte.y-l.posNext.y),d=2!=l.parent.version?l.id+".Oy":"Oy";l.parent.evaluator.setVariable(2!=
l.parent.version?l.id+".Ox":"Ox",l.Ox-b);l.parent.evaluator.setVariable(d,l.Oy-c);l.posAnte.x-=b;l.posAnte.y-=c}l.click&&h(a);a.preventDefault()}var l=this,m=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};m&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",h,!1),this.canvas.addEventListener("touchstart",b,!1));m||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",h,!1),this.canvas.addEventListener("mousedown",d,!1))};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Space3D=function(c,d){a.Space.call(this,c,d);this.backgroundCanvas=document.createElement("canvas");this.backgroundCanvas.setAttribute("id",this.id+"_background");this.backgroundCanvas.setAttribute("width",this.w+"px");this.backgroundCanvas.setAttribute("height",this.h+"px");this.backgroundCtx=this.backgroundCanvas.getContext("2d");this.canvas=document.createElement("canvas");this.canvas.setAttribute("id",this.id+"_canvas");this.canvas.setAttribute("width",
this.w+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("class","DescartesSpace3DCanvas");this.canvas.setAttribute("style","z-index: "+this.zIndex+";");this.ctx=this.canvas.getContext("2d");this.graphicControlContainer=document.createElement("div");this.graphicControlContainer.setAttribute("id",this.id+"_graphicControls");this.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+this.zIndex+";");this.numericalControlContainer=
document.createElement("div");this.numericalControlContainer.setAttribute("id",this.id+"_numericalControls");this.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+this.zIndex+";");this.container=document.createElement("div");this.container.setAttribute("id",this.id);this.container.setAttribute("class","DescartesSpace3DContainer");this.container.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.container.appendChild(this.backgroundCanvas);
this.container.appendChild(this.canvas);this.container.appendChild(this.graphicControlContainer);this.container.appendChild(this.numericalControlContainer);c.container.insertBefore(this.container,c.loader);this.eye=new a.Vector3D(this.scale/4,2,5);this.center=new a.Vector3D(0,0,0);this.yUpEye=new a.Vector3D(0,0,1);this.lookAtMatrix=(new a.Matrix4x4).lookAt(this.eye,this.center,this.yUpEye);this.perspectiveMatrix=(new a.Matrix4x4).perspective(45,this.w/this.h,0.01,1E3).multiply(this.lookAtMatrix);
(new a.Matrix4x4).setIdentity();this.update()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.update=function(){this.evaluator.evalExpression(this.drawif)?(this.container.style.display="block",this.drawBackground(),this.draw()):this.container.style.display="none"};a.Space3D.prototype.drawBackground=function(){var c=this.evaluator,d=this.backgroundCtx;d.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);d.fillStyle=a.getColor(c,this.background);d.fillRect(0,0,this.backgroundCanvas.width,
this.backgroundCanvas.height);this.image&&""!=this.image.src&&this.image.ready&&this.image.complete&&("topleft"==this.bg_display?d.drawImage(this.image,0,0):"stretch"==this.bg_display?d.drawImage(this.image,0,0,this.w,this.h):"patch"==this.bg_display?(d.fillStyle=d.createPattern(this.image,"repeat"),d.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"==this.bg_display&&d.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2))};a.Space3D.prototype.draw=function(){this.ctx.clearRect(0,
0,this.canvas.width,this.canvas.height);for(var a=0,d=this.graphics.length;a<d;a++){var b=this.graphics[a];b.background||b.draw()}};a.Space3D.prototype.transformCoordinateX=function(a){var d=this.w/2;return e(a*d+d+this.Ox)};a.Space3D.prototype.transformCoordinateY=function(a){var d=this.h/2;return e(-a*d+d+this.Oy)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SpaceAP=function(e,c){a.Space.call(this,e,c);this.exportarVars=this.importarVars=null;this.firstUpdate=!0;var d;
this.file&&(d=a.openExternalFile(this.file),null!=d&&(d=d.split("\n")));if(d){for(var b="",g=!1,f=0,i=d.length;f<i&&!(d[f].match("<applet")&&(g=!0),g&&(b+=d[f]),d[f].match("</applet"));f++);f=document.createElement("div");f.innerHTML=b;f.firstChild.setAttribute("width",this.w);f.firstChild.setAttribute("height",this.h);this.descApp=new a.DescartesApp(f.firstChild);this.descApp.container.setAttribute("class","DescartesAppContainer");this.descApp.container.setAttribute("style","position: absolute; overflow: hidden; background-color: "+
this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.parent.container.insertBefore(this.descApp.container,this.parent.loader);b=this.descApp.spaces;f=0;for(i=b.length;f<i;f++)b[f].findOffset();this.descApp.container.style.display=this.evaluator.evalExpression(this.drawif)?"block":"none";var h=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();h.exportar()}}else this.descApp=
{},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),b="position: absolute; overflow: hidden; background-color: "+this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";",this.image&&("topleft"==this.bg_display?b+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?b+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":
"patch"==this.bg_display?b+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(b+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",b),this.parent.container.insertBefore(this.descApp.container,this.parent.loader),this.descApp.container.style.display=this.evaluator.evalExpression(this.drawif)?"block":"none",this.update=function(){}};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.update=
function(){var a=this.x!=this.evaluator.evalExpression(this.xExpr),c=this.y!=this.evaluator.evalExpression(this.yExpr)+this.plecaHeight;this.x=a?this.evaluator.evalExpression(this.xExpr):this.x;this.y=c?this.evaluator.evalExpression(this.yExpr)+this.plecaHeight:this.y;a&&(this.descApp.container.style.left=this.x+"px");c&&(this.descApp.container.style.top=this.y+"px");if(a||c)for(var a=this.descApp.spaces,c=0,d=a.length;c<d;c++)a[c].findOffset();this.descApp.container.style.display=this.evaluator.evalExpression(this.drawif)?
"block":"none";if(this.firstUpdate&&(this.firstUpdate=!1,null==this.importarVars)){this.importarVars=[];for(var b in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(b)&&b.match(/^public./)&&this.importarVars.push({varName:b,value:this.evaluator.getVariable(b)})}this.importar()};a.SpaceAP.prototype.importar=function(){for(var a,c=!1,d=0,b=this.importarVars.length;d<b;d++)a=this.evaluator.getVariable(this.importarVars[d].varName),a!=this.importarVars[d].value&&(this.importarVars[d].value=
a,this.descApp.evaluator.setVariable(this.importarVars[d].varName,this.importarVars[d].value),c=!0);c&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SpaceHTML_IFrame=function(e,c){a.Space.call(this,e,c);this.MyIFrame=document.createElement("iframe");this.MyIFrame.setAttribute("src",this.file);this.MyIFrame.setAttribute("id",this.id);this.MyIFrame.setAttribute("marginheight",0);this.MyIFrame.setAttribute("marginwidth",
0);this.MyIFrame.setAttribute("frameborder",0);this.MyIFrame.setAttribute("scrolling","auto");this.MyIFrame.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.MyIFrame.style.display=this.evaluator.evalExpression(this.drawif)?"block":"none";this.parent.container.insertBefore(this.MyIFrame,this.parent.loader);var d=this;this.MyIFrame.onload=function(){d.evaluator.setFunction(d.id+".exec",function(a,
c){c=c.toString().split(",");d.MyIFrame.contentWindow[a].apply(null,c)})}};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.update=function(){var a=this.x!=this.evaluator.evalExpression(this.xExpr),c=this.y!=this.evaluator.evalExpression(this.yExpr);this.x=a?this.evaluator.evalExpression(this.xExpr):this.x;this.y=c?this.evaluator.evalExpression(this.yExpr):this.y;a&&(this.MyIFrame.style.left=this.x+"px");c&&(this.MyIFrame.style.top=this.y+"px");this.MyIFrame.style.display=this.evaluator.evalExpression(this.drawif)?
"block":"none"};return a}(descartesJS||{}),babel=function(a){a.falso=a["false"]=a.fals=a.gezurra=a.faux=a.fals="false";a.verdadero=a["true"]=a.veritable=a.egia=a.vrai=a.verdadeiro=a.veritable="true";a.no=a.ez=a.non=a["n\u00e3o"]="false";a["s\u00ed"]=a.yes=a.bai=a.oui=a.si=a["sim "]="true";a.negro=a.black=a.negre=a.beltza=a.noir=a.preto="#000000";a.maxenta=a.magenta="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise="#00ffff";a.verde=a.green=a.verd=a.berdea=
a.vert="#00ff00";a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho="#ff0000";a.pink=a.rosa=a.arrosa=a.rose="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro="#404040";a.gris=a.gray=a.grisa=a.cinza="#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro="#c0c0c0";a.blanco=a.white=a.blanc=
a.zuria=a.branco="#ffffff";a.escala=a.scale=a.eskala=a["\u00e9chelle"]="scale";a.nombre=a.name=a.nom=a.izena=a.nome="name";a.ikusgai=a["vis\u00edvel"]=a.visible="visible";a.rastro=a.trace=a.rastre=a.arrastoa="trace";a.fondo=a.background=a.fons=a.hondoa=a.fond=a.fundo="background";a.colour=a.color=a.kolorea=a.couleur=a.cor="color";a["par\u00e1metro"]=a.parameter=a.parametroa=a["par\u00e2metro"]=a["par\u00e0metre"]="parameter";a["sucesi\u00f3n"]=a.sequence=a["successi\u00f3"]=a.segida=a.succession=
a["seq\u00fc\u00eancia"]="sequence";a["tama\u00f1o"]=a.size=a.neurria=a.taille=a.tamanho=a["grand\u00e0ria"]="size";a.decimales=a.decimals=a.hamartarra=a["d\u00e9cimales"]=a.decimais="decimals";a.red=a.net=a.xarxa=a.sarea=a["r\u00e9seau"]=a.rede=a.malha="net";a.red10=a.net10=a.xarxa10=a.sarea10=a["r\u00e9seau10"]=a.rede10=a.malha10="net10";a.ejes=a.axes=a.eixos=a.ardatzak=a.eixes="axes";a.texto=a.text=a.testua=a.texte="text";a["cr\u00e9ditos"]=a.about=a["cr\u00e8dits"]=a.kreditoak=a["cr\u00e9dits"]=
a.sobre="about";a.config=a.konfig=a["configura\u00e7\u00e3o"]="config";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.limpiar=a.clear=a.neteja=a.ezabatu=a.nettoye=a.limpar="clear";a.incr=a.gehi=a.incremento="incr";a.min=a.inf="min";a.max=a.sup=a["m\u00e1x"]="max";a.relleno=a.fill=a.ple=a.betea=a.plein=a.recheo=a.preencher="fill";a["relleno+"]=a["fill+"]=a["ple+"]=a["betea+"]=a["plein+"]=a["recheo+"]=a["preencher+"]="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=a["betea-"]=
a["plein-"]=a["recheo-"]=a["preencher-"]="fillM";a.flecha=a.arrow=a.fletxa=a.gezia=a["fl\u00e8che"]=a.frecha=a.seta="arrow";a.ancho=a.width=a.ample=a.zabalera=a.large=a.largura="width";a.punta=a.spear=a.muturra=a.pointe=a.ponta="spear";a["regi\u00f3n"]=a.region=a["regi\u00f3"]=a.eskualde=a["r\u00e9gion"]=a["rexi\u00f3n"]=a["regi\u00e3o"]="region";a.norte=a.north=a.nord=a.ipar="north";a.sur=a.south=a.sud=a.hego=a.sul="south";a.este=a.east=a.est=a.ekialde=a.leste="east";a.oeste=a.west=a.oest=a.hegoalde=
a.ouest="west";a.exterior=a.external=a.kanpoalde=a.externo="external";a["expresi\u00f3n"]=a.expresion=a["expresi\u00f3"]=a.adierazpen=a["express\u00e3o"]="expresion";a.tipo=a.type=a.tipus=a.mota="type";a["posici\u00f3n"]=a.position=a["posici\u00f3"]=a.posizio=a["posi\u00e7\u00e3o"]="position";a["constricci\u00f3n"]=a.constraint=a["constricci\u00f3"]=a.beharte=a.constriction=a["constrici\u00f3n"]=a["restri\u00e7\u00e3o"]="constraint";a.valor=a.value=a.balio=a.valeur="value";a["ecuaci\u00f3n"]=a.equation=
a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.curva=a.curve=a.corba=a.kurba=a.courbe="curve";a.texto=a.text=a.testu=a.texte="text";a.punto=a.point=a.punt=a.puntu=a.ponto="point";a.segmento=a.segment=a.zuzenki="segment";a.arco=a.arc=a.arku="arc";a["pol\u00edgono"]=a.polygon=a["pol\u00edgon"]=a.poligono=a.polygone="polygon";a.imagen=a.image=a.imatge=a.irudi=a.imaxe=a.imagem="image";a["Versi\u00f3n"]=a.Version=a["Versi\u00f3"]=a["Vers\u00e3o"]="version";a.Idioma=
a.Language=a.Hizkuntza=a.Langue="language";a["O.x"]="O.x";a["O.y"]="O.y";a.Botones=a.Buttons=a.Botons=a.Botoiak=a.Boutons=a["Bot\u00f3ns"]=a["Bot\u00f5es"]=a.Botons="Buttons";a["Animaci\u00f3n"]=a.Animation=a["Animaci\u00f3"]=a.Animazio=a["Anima\u00e7\u00e3o"]="Animation";a.constante=a.constant=a.Konstante="constant";a.fuente=a.font=a.iturri=a.source=a.fonte="font";a["num\u00e9rico"]=a.numeric=a["num\u00e8ric"]=a.zenbakizko=a["num\u00e9rique"]="numeric";a["gr\u00e1fico"]=a.graphic=a["gr\u00e0fic"]=
a.grafiko=a.graphique="graphic";a.texto=a.text=a.testu=a.texte="text";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.hacer=a["do"]=a.fer=a.egin=a.faire=a.facer=a.fazer="do";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto="while";a.evaluar=a.evaluate=a.avalua=a.ebaluatu=a["\u00e9valuer"]=a.avaliar="evaluate";a.variable=a.aldagaia=a["vari\u00e1vel"]="variable";a["funci\u00f3n"]=a["function"]=a["funci\u00f3"]=a.funtzio=a.fonction=a["fun\u00e7\u00e3o"]=
"function";a.algoritmo=a.algorithm=a.algorisme=a.algorithme="algorithm";a.vector=a.array=a.bektore=a.vecteur=a.matriz="array";a["dibujar-si"]=a["draw-if"]=a["marraztu-baldin"]=a["dessiner-si"]=a["debuxar-se"]=a["desenhar-se"]=a["dibuixa-si"]="drawif";a.dominio=a.range=a.domini=a["izate-eremua"]=a.domain=a["dom\u00ednio"]="range";a.pausa=a.delay=a.eten="delay";a["eje-x"]=a["x-axis"]=a["eix-x"]=a["x-ardatza"]=a["axe-x"]=a["eixe-x"]=a["eixo-x"]="x-axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=
a["axe-y"]=a["eixe-y"]=a["eixo-y"]="y-axis";a["n\u00fameros"]=a.numbers=a.nombres=a.zenbakiak="numbers";a["exponencial-si"]=a["exponential-if"]=a["esponentzial-baldin"]=a["exponentiel-si"]=a["exponencial-se"]="exponentialif";a.familia=a.family=a["fam\u00edlia"]=a.famille="family";a.intervalo=a.interval=a.tarte=a.intervalle="interval";a.pasos=a.steps=a.passos=a.pausoak=a.pas="steps";a.centro=a.center=a.centre=a.zentro="center";a.radio=a.radius=a.radi=a.erradio=a.rayon=a.raio="radius";a.fin=a.end=a.fi=
a.bukaera=a.fim="end";a["una-sola-vez"]=a["only-once"]=a["una-sola-vegada"]=a["behin-bakarrik"]=a["une-seule-fois"]=a["unha-soa-vez"]=a["apenas-uma-vez"]="onlyOnce";a.siempre=a.always=a.sempre=a.beti=a.toujours="always";a["color-int"]=a["int-colour"]=a["barruko-kolore"]=a["couleur-int"]=a["cor-int"]="colorInt";a.repetir=a.loop=a.repeteix=a.errepikatu=a["r\u00e9p\u00e9ter"]="loop";a.controles=a.controls=a.kontrolak=a["contr\u00f4les"]=a.controis="controls";a.animar=a.animate=a.anima=a.animatu=a.animer=
"animate";a.auto="auto";a.alto=a.height=a.alt=a.altu=a.haut=a.altura="height";a.x=a.left="x";a.y=a.top="y";a.espacio=a.space=a.espai=a.espazio=a.espace=a.espazo=a["espa\u00e7o"]="space";a.Nu="Nu";a.Nv="Nv";a.ancho=a.depth=a.amplada=a.zabalera=a.largeur=a.ancho=a.profundidade=a.amplada="width";a.largo=a.length=a.llargada=a.luzera=a.longueur=a.longo=a.comprimento=a.llargada="length";a.alto=a.height=a["al\u00e7ada"]=a.altu=a.hauteur=a.alto=a.altura=a["al\u00e7ada"]="height";a.color_reverso=a.backcolor=
a.color_revers=a["atzealde kolorea"]=a.couleur_revers=a.cor_reverso=a.cor_de_fundo="backcolor";a.aristas=a.edges=a.arestes=a.ertzak=a["ar\u00eates"]=a.arestas="edges";a.rotini=a.inirot="inirot";a.posini=a.inipos="inipos";a["tri\u00e1ngulo"]=a.triangle=a.hirukia=a["tri\u00e2ngulo"]="triangle";a.cara=a.face=a.aurpegi="face";a.polireg=a.regpoly=a["pol\u00edgonoRegular"]="polireg";a.superficie=a.surface=a["superf\u00edcie"]=a.azalera="surface";a.macro=a.makro="macro";a.id="id";a.modelo=a.model=a.eredu=
a["mod\u00e8le"]="model";a.color=a.kolore=a.couleur=a.cor="color";a.luz=a.light=a.llum=a.argia=a["lumi\u00e8re"]="light";a.metal=a.metall=a["m\u00e9tal"]="metal";a.alambre=a.wire=a.filferro=a.alanbre=a["fil de fer"]=a.arame="wire";a.cortar=a.split=a.talla=a.moztu=a.couper=a.dividir="split";a.despliegue=a.render=a.desplegament=a.zabaltze=a["d\u00e8ploiement"]=a.despregamento=a.processar="render";a.orden=a.sort=a.ordre=a.ordena=a.orde=a.ordenar="sort";a.pintor=a.painter=a.margolari=a.peintre="painter";
a["trazado de rayos"]=a["ray trace"]=a["tra\u00e7at de raigs"]=a["izpi trazadura"]=a["trace de rayons"]=a["trazado de raios"]=a["tra\u00e7ado de raios"]="raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo="image";a.despl_imagen=a.bg_display=a.despl_imatge=a["irudi desplazamendu"]=a.despl_image=a.despr_imaxe=a["apresenta\u00e7\u00e3o_de_imagem"]="bg_display";a["arr-izq"]=a.topleft=a["dalt-esq"]=a["goi-ezk"]=a["au-dessus-gau"]=a["arr-esq"]=a["acima-esquerda"]="topleft";a["expand."]=
a.stretch=a.hedatu=a["expandir "]="stretch";a.mosaico=a.patch=a.mosaic=a.mosaiko=a["mosa\u00efque"]="patch";a.centrada=a.center=a.zentratu=a["centr\u00e9e"]=a.centrado="center";a.archivo=a.file=a.fitxer=a.artxibo=a.fichier=a.arquivo="file";a.filas_norte=a.rows_north=a.files_nord=a["HTML kodea"]=a.files_nord=a.filas_norte=a.linhas_norte=a.files_nord="rowsNorth";a.filas_sur=a.rows_south=a.files_sud=a.ipar_lerro=a.files_sud=a.filas_sur=a.linhas_sul=a.files_sud="rowsSouth";a.ancho_este=a.width_east=a.ample_est=
a.hego_lerro=a.ample_est=a.ancho_leste=a.largura_leste=a.ample_est="widthEast";a.ancho_oeste=a.width_west=a.ample_oest=a.ekialde_zabalera=a.ample_ouest=a.ancho_oeste=a.largura_oeste=a.ample_oest="widthWest";a.fijo=a.fixed=a.fix=a.hegoalde_zabalera=a.fixe=a.fixo="fixed";a["Reiniciar Animaci\u00f3n"]=a["Init Animation"]=a["Reinicia Animaci\u00f3"]=a.finko=a["Recommencer l'Animation"]=a["Reiniciar Anima\u00e7\u00e3o"]="initAnimation";a["Explicaci\u00f3n"]=a.Explanation=a.Azalpena=a.Explication=a["Explica\u00e7\u00e3o"]=
a["Explicaci\u00f3"]="Explanation";a.tooltip=a.dica="tooltip";a.discreto=a.discrete=a.discret=a.diskretu="discrete";a.interfaz=a.gui=a["interf\u00edcie"]=a.interfaze=a["interface"]="gui";a.pulsador=a.spinner=a.polsador=a.pultsadore=a.bouton="spinner";a["campo de texto"]=a.textfield=a["camp de text"]=a["testu esarrua"]=a["champ de texte"]="textfield";a["men\u00fa"]=a.choice=a.menu=a.escolha="menu";a.barra=a.scrollbar=a.barre="scrollbar";a.opciones=a.options=a.opcions=a.aukerak=a["opci\u00f3ns"]=a["op\u00e7\u00f5es"]=
"options";a.interior=a.barruko=a["int\u00e9rieur"]="interior";a["condici\u00f3n"]=a.condition=a["condici\u00f3"]=a.baldintza=a["condi\u00e7\u00e3o"]="condition";a["acci\u00f3n"]=a.action=a["acci\u00f3"]=a.ekintza=a["a\u00e7\u00e3o"]="action";a.evento=a.event=a.esdeveniment=a.gertaera=a["\u00e9v\u00e9nement"]="event";a["abrir URL"]=a["open URL"]=a["obre URL"]=a["URL zabaldu"]=a["ouvrir URL"]="openURL";a["abrir Escena"]=a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]=
"openScene";a["bot\u00f3n"]=a.button=a["bot\u00f3"]=a.botoi=a.bouton=a["bot\u00e3o"]="button";a.mensaje=a.message=a.mezua=a.mensaxe=a.mensagem=a.missatge="message";a.alternar=a.alternate=a.alterna=a.txandakatu=a.alterner="alternate";a["ejecuci\u00f3n"]=a.execution=a["execuci\u00f3"]=a.gauzatze=a["ex\u00e9cution"]=a["execuci\u00f3n"]=a["execu\u00e7\u00e3o"]="execution";a.calcular=a.calculate=a.calcula=a.kalkulatu=a.calculer="calculate";a.coord_abs=a.abs_coord=a.koor_abs="abs_coord";a.negrita=a.bold=
a.negreta=a.lodi=a["caract\u00e8re gras"]=a.negra=a.negrito="bold";a.cursiva=a.italics=a.etzana=a.italique=a["it\u00e1lico"]="italics";a.subrayada=a.underlined=a.subratllat=a.azpimarratua=a.soulignement=a["subli\u00f1ada"]=a.sublinhado="underlined";a.imagen=a.image=a.imatge=a.irundia=a.imaxe=a.imagem="image";a.pos_mensajes=a.msg_pos=a.pos_missatges=a.mezuen_pos=a.pos_messages=a.pos_mensaxes="msg_pos";a.izquierda=a.left=a.esquerra=a.eskerrean=a.gauche=a.esquerda=a.esquerda=a.esquerra="left";a.derecha=
a.right=a.dreta=a.eskuinan=a.droite=a.dereita=a.direita=a.dreta="right";a["sensible_a_los_movimientos_del_rat\u00f3n"]=a.sensitive_to_mouse_movements=a["sensible_als_moviments_del_ratol\u00ed"]=a["xagu mugimenduarekiko sentikorra"]=a.sensible_aux_mouvements_du_souris=a.sensible_aos_movementos_do_rato=a["sens\u00edvel_aos_movimentos_do_mouse"]="sensitive_to_mouse_movements";a.reproducir=a.play=a.reprodueix=a.erreproduzitu=a.reproduire=a.reproduzir="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=
a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]="activeif";a.rotfin=a.finrot=a.bukrot="endrot";a.posfin=a.finpos=a.bukpos="endpos";a.editable=a.editagarria=a["edit\u00e1vel"]="editable";a.tipo=a.type=a.tipus=a.mota="type";a.R2="R2";a.R3="R3";a.vectores=a.bektoreak=a.vecteurs=a.vetores=a.vectors="vectors";a["fuente puntos"]=a["font size"]=a["font punts"]=a["puntu iturria"]=a["source points"]=a["fonte puntos"]=a["fonte pontos"]="font_size";a.SansSerif="SansSerif";a.Serif="Serif";a.Monoespaciada=
a.Monospaced=a.Monoespazada="Monospaced";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.punto=a.dot=a.punt=a.puntu=a.point=a.ponto="point";a.escenario=a.scenario=a.escenari=a.agertoki=a["sc\u00e8ne"]=a["cen\u00e1rio"]="scenario";a.cID="cID";a.matriz=a.matrix=a.matriu=a.matrice="matrix";a.filas=a.rows=a.files="rows";a.columnas=a.columns=a.colonnes="columns";a.solo_texto=a.only_text=a.seulement_texte=a["s\u00f3_texto"]=a.tan_sols_texte=
"onlyText";a.evaluar=a.evaluate="evaluate";a.respuesta=a.answer="answer";a.decimal_symbol=a["signo decimal"]=a["decimal symbol"]="decimal_symbol";a.info="info";a.color_contorn_text=a.color_text_border=a.color_borde_texto=a.muga_testuaren_kolorea=a.couleur_contour_texte=a.cor_borde_texto=a.colore_bordo_testo=a.cor_borda_texto=a.color_contorn_text="border";a.video=a["vid\u00e9o"]="video";a.audio=a["\u00e0udio"]="audio";a.autoplay="autoplay";a.loop="loop";a.poster="poster";a.opacidad=a.opacity=a["opacit\u00e9"]=
a.opacitat=a.opacidade="opacity";a.alinear=a.align=a["ali\u00f1ar"]=a.aligner="align";return a}(babel||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,c){this.x=a;this.y=c};a.Vector2D.AXIS_X=new a.Vector2D(1,0);a.Vector2D.AXIS_Y=new a.Vector2D(0,1);a.Vector2D.prototype.vectorLength=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.Vector2D.prototype.dotProduct=function(a){return this.x*a.x+this.y*a.y};a.Vector2D.prototype.angleBetweenVectors=function(a){return Math.acos(this.dotProduct(a)/
(this.vectorLength()*a.vectorLength()))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.DescartesApp=function(a){this.applet=a;this.parentContainer=a.parentNode;this.width=a.getAttribute("width");this.height=a.getAttribute("height");this.decimal_symbol=".";this.childs=a.getElementsByTagName("param");this.code=a.getAttribute("code");this.saveState=[];this.images={};this.images.length=-1;this.audios={};this.audios.length=-1;this.firstRun=!0;this.arquimedes=this.code.match("descinst.DescartesWeb2_0.class");
this.init()};a.DescartesApp.prototype.init=function(){this.spaces=[];this.externalSpace={container:document.createElement("div"),controls:[]};this.northSpace={container:document.createElement("div"),controls:[]};this.southSpace={container:document.createElement("div"),controls:[]};this.eastSpace={container:document.createElement("div"),controls:[]};this.westSpace={container:document.createElement("div"),controls:[]};this.specialSpace={container:document.createElement("div"),controls:[]};this.editableRegion=
{container:document.createElement("div"),textFields:[]};this.controls=[];this.auxiliaries=[];this.events=[];this.evaluator=new a.Evaluator(this);this.plecaHeight=this.tabindex=this.zIndex=0;this.lessonParser=new a.LessonParser(this);void 0!=this.container&&this.parentContainer.removeChild(this.container);this.container=document.createElement("div");this.loader=document.createElement("div");this.parentContainer.appendChild(this.container);this.container.width=this.width;this.container.height=this.height;
this.container.setAttribute("class","DescartesAppContainer");this.container.setAttribute("style","width: "+this.width+"px; height:"+this.height+"px;");this.container.appendChild(this.loader);this.loader.width=this.width;this.loader.height=this.height;this.loader.setAttribute("class","DescartesLoader");this.loader.setAttribute("style","width: "+this.width+"px; height:"+this.height+"px;");if(this.firstRun){var e=this,c="url("+drawDescartesLogo(this.loader.width,this.loader.height)+")";this.imageLoader=
document.createElement("div");this.imageLoader.width=this.width;this.imageLoader.height=this.height;this.imageLoader.setAttribute("class","DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image: "+c+"; width: "+this.width+"px; height:"+this.height+"px;");this.loader.appendChild(this.imageLoader);c=new Image;c.onload=function(){e.imageLoader.setAttribute("style","background-image: url("+this.src+"); width: "+e.width+"px; height:"+e.height+"px; top: 0px; left: 0px")};c.src="images/DescartesLoader.png";
this.loaderBar=document.createElement("canvas");this.loaderBar.width=this.width;this.loaderBar.height=this.height;this.loaderBar.setAttribute("class","DescartesLoaderBar");this.loaderBar.setAttribute("style","width: "+this.width+"px; height:"+this.height+"px;");this.loaderBar.ctx=this.loaderBar.getContext("2d");this.loader.appendChild(this.loaderBar);this.barWidth=Math.floor(this.loader.width/10);this.barHeight=Math.floor(this.loader.height/70);this.timer=setInterval(function(){e.drawLoaderGraph(e.loaderBar.ctx,
e.loaderBar.width,e.loaderBar.height)},10);this.firstRun=!1;this.initPreloader()}else this.initBuildApp()};a.DescartesApp.prototype.initAudio=function(e){var c=this;this.audios[e]=new Audio(e);this.audios[e].filename=e;var d=function(){this.ready=1},b=function(){!this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))&&"mp3"==this.filename.substring(this.filename.length-3)?(c.audios[e]=new Audio(this.filename.replace("mp3","ogg")),c.audios[e].filename=this.filename.replace("mp3",
"ogg"),c.audios[e].addEventListener("canplaythrough",d,!1),c.audios[e].addEventListener("load",d,!1),c.audios[e].addEventListener("error",b,!1),c.audios[e].load()):(console.log("El archivo '"+e+"' no puede ser reproducido"),this.errorload=1)};this.audios[e].addEventListener("canplaythrough",d,!1);this.audios[e].addEventListener("load",d,!1);this.audios[e].addEventListener("error",b,!1);a.hasTouchSupport?(this.audios[e].load(),this.audios[e].play(),setTimeout(function(){console.log("detenido");c.audios[e].pause()},
10),this.audios[e].ready=1):this.audios[e].load()};a.DescartesApp.prototype.initPreloader=function(){for(var a=0,c=this.childs.length;a<c;a++){var d=this.childs[a].value.match(/[\w-//]*(.png|.jpg|.gif|.svg|.PNG|.JPG|.GIF|.SVG)/g);if(d)for(var b,g=0,f=d.length;g<f;g++)b=d[g],!b.toLowerCase().match(/vacio.gif$/)&&""!=b.substring(0,b.length-4)&&(this.images[b]=new Image,this.images[b].addEventListener("load",function(){this.ready=1},!1),this.images[b].addEventListener("error",function(){this.errorload=
1},!1),this.images[b].src=b);if(d=this.childs[a].value.match(/[\w-//]*(.mp3|.wav|.MP3|.WAV)/g)){g=0;for(f=d.length;g<f;g++)b=d[g],this.initAudio(b)}this.childs[a].value.match(/vector|array|bektore|vecteur|matriz/g)&&this.childs[a].value.match(/archivo|file|fitxer|artxibo|fichier|arquivo/g)&&this.lessonParser.parseAuxiliar(this.childs[a].value)}var i=this,h;for(h in this.images)this.images.hasOwnProperty(h)&&this.images.length++;for(h in this.audios)this.audios.hasOwnProperty(h)&&this.audios.length++;
var j=function(){i.readys=0;var a=i.images.length,b;for(b in i.images)i.images.hasOwnProperty(b)&&(i.images[b].ready||i.images[b].errorload)&&i.readys++;var c=i.audios.length;for(b in i.audios)i.audios.hasOwnProperty(b)&&(i.audios[b].ready||i.audios[b].errorload)&&i.readys++;i.readys!=a+c?setTimeout(j,30):i.initBuildApp()};j()};a.DescartesApp.prototype.getImage=function(a){if(a)return this.images[a]||(this.images[a]=new Image,this.images[a].src=a,this.images[a].addEventListener("load",function(){this.ready=
1},!1),this.images[a].addEventListener("error",function(){this.errorload=1},!1)),this.images[a]};a.DescartesApp.prototype.getAudio=function(a){var c=this;if(!this.audios[a]){this.audios[a]=new Audio(a);this.audios[a].addEventListener("canplaythrough",function(){this.ready=1},!1);var d=function(){!this.canPlayType("audio/"+a.substring(a.length-3))&&"mp3"==a.substring(a.length-3)?(c.audios[a]=new Audio(a.replace("mp3","ogg")),c.audios[a].addEventListener("canplaythrough",onCanPlayThrough,!1),c.audios[a].addEventListener("load",
onCanPlayThrough,!1),c.audios[a].addEventListener("error",d,!1),c.audios[a].load()):(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1)};this.audios[a].addEventListener("error",d,!1);this.audios[a].play();setTimeout(function(){c.audios[a].pause()},10)}return this.audios[a]};a.DescartesApp.prototype.drawLoaderGraph=function(a,c,d){var b=2*(this.barWidth-2)/(this.images.length+this.audios.length);a.translate(c/2,d-50);a.scale(2,2);a.strokeRect(-this.barWidth,-this.barHeight,
2*this.barWidth,this.barHeight);a.fillStyle="gray";a.fillRect(-this.barWidth+2,-this.barHeight+2,2*(this.barWidth-2),this.barHeight-4);a.fillStyle="#1f375d";a.fillRect(-this.barWidth+2,-this.barHeight+2,this.readys*b,this.barHeight-4);a.setTransform(1,0,0,1,0,0)};drawDescartesLogo=function(a,c){var d=document.createElement("canvas");d.width=a;d.height=c;var b=d.getContext("2d");b.save();b.strokeStyle="#1f375d";b.fillStyle="#1f375d";b.lineCap="round";b.lineWidth=2;b.beginPath();b.translate((a-360)/
2,(c-195)/2);b.scale(3,3);b.moveTo(3,25);b.lineTo(3,1);b.lineTo(21,1);b.bezierCurveTo(33,1,41,15,41,25);b.stroke();b.beginPath();b.moveTo(1,63);b.lineTo(1,64);b.moveTo(5,62);b.lineTo(5,64);b.moveTo(9,61);b.lineTo(9,64);b.moveTo(13,60);b.lineTo(13,64);b.moveTo(17,58);b.lineTo(17,64);b.moveTo(21,56);b.lineTo(21,64);b.moveTo(25,53);b.lineTo(25,64);b.moveTo(29,50);b.lineTo(29,64);b.moveTo(33,46);b.lineTo(33,64);b.moveTo(37,41);b.lineTo(37,64);b.moveTo(41,32);b.lineTo(41,64);b.stroke();b.font="20px Arial";
b.fillText("escartes",45,33);b.fillText("JS",98,64);b.restore();return d.toDataURL()};a.DescartesApp.prototype.initBuildApp=function(){for(var a=this.childs,c=this.lessonParser,d=[],b=[],g=[],f=[],i=[],h=[],j,k=0,l=a.length;k<l;k++){j=a[k];if("pleca"==j.name){var m=c.parsePleca(j.value,this.width);this.container.insertBefore(m,this.loader);this.plecaHeight=m.imageHeight?m.imageHeight:m.offsetHeight}"Buttons"==babel[j.name]?this.buttonsConfig=c.parseButtonsConfig(j.value):"decimal_symbol"==babel[j.name]?
this.decimal_symbol=j.value:"version"==babel[j.name]?this.version=parseInt(j.value):"language"==babel[j.name]?this.language=j.value:"enable"==babel[j.getAttribute("enable")]?this.enable=babel[j.getAttribute("enable")]:j.name.match("rtf")?f.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+j.value+"'"):"E"==j.name.charAt(0)?d.push(j.value):"C"==j.name.charAt(0)&&"_"==j.name.charAt(1)?b.push(j.value):"A"==j.name.charAt(0)&&"Animation"!=babel[j.name]?g.push(j.value):
"G"==j.name.charAt(0)?f.push(j.value):"S"==j.name.charAt(0)?i.push(j.value):"Animation"==babel[j.name]&&h.push(j.value)}this.scenarioRegion={container:document.createElement("div"),scroll:0};this.scenarioRegion.container.setAttribute("id","descartesJS_Scenario_Region");this.scenarioRegion.scenarioSpace=this.lessonParser.parseSpace("tipo='R2' id='descartesJS_scenario' x='0' y='0' fijo='yes' red='no' red10='no' ejes='no' text='no' ancho='"+this.width+"' alto='"+this.height+"'");this.scenarioRegion.container.appendChild(this.scenarioRegion.scenarioSpace.container);
this.arquimedes&&(this.container.appendChild(this.scenarioRegion.container),this.spaces.push(this.scenarioRegion.scenarioSpace));k=0;for(l=d.length;k<l;k++)a=c.parseSpace(d[k]),this.arquimedes&&this.scenarioRegion.container.appendChild(a.container),this.spaces.push(a),this.zIndex++;k=0;for(l=f.length;k<l;k++)if(d=c.parseGraphic(f[k]))d.visible&&(this.editableRegionVisible=!0),d.space.addGraph(d);k=0;for(l=i.length;k<l;k++)(d=c.parse3DGraphic(i[k]))&&d.space.addGraph(d);k=0;for(l=b.length;k<l;k++)this.controls.push(c.parseControl(b[k]));
k=0;for(l=g.length;k<l;k++)c.parseAuxiliar(g[k]);k=0;for(l=h.length;k<l;k++)this.animation=c.parseAnimation(h[k]);this.configRegions();this.updateAuxiliaries();k=0;for(l=this.controls.length;k<l;k++)this.controls[k].init();this.updateControls();this.updateSpaces(!0);this.update();this.loader.style.display="none";this.parentContainer.style="overflow: hidden;";clearTimeout(this.timer);this.enable&&(this.blocker=document.createElement("div"),this.blocker.setAttribute("class","blocker"),this.blocker.setAttribute("style",
"width: "+this.width+"px; height: "+this.height+"px"),this.container.appendChild(this.blocker))};a.DescartesApp.prototype.configRegions=function(){var e=this.evaluator.parser,c=this.buttonsConfig,d=this.container,b=southRegionHeight=eastRegionHeight=westRegionHeight=editableRegionHeight=0,g=southRegionWidht=0,f=westRegionWidth=0,i=this.northSpace.controls,h=this.southSpace.controls,j=this.eastSpace.controls,k=this.westSpace.controls;if(0<c.rowsNorth||0<i.length||c.about||c.config){0>=c.rowsNorth?
(b=c.height,c.rowsNorth=1):b=c.height*c.rowsNorth;g=this.northSpace.container;g.setAttribute("id","descartesJS_northRegion");g.setAttribute("style","width: "+d.width+"; height: "+b+"px; background: #c0c0c0; position: absolute; left: 0px; top: 0px; z-index: 100;");d.appendChild(g);var g=d.width,l=0;c.about&&(l=100,g-=l);c.config&&(g-=100);for(var m=Math.ceil(i.length/c.rowsNorth),p=g/m,o=0,q=i.length;o<q;o++)i[o].expresion=e.parse("("+(l+p*(o%m))+","+c.height*Math.floor(o/m)+","+p+","+c.height+")"),
i[o].drawif=e.parse("1");if(c.about){var s;"espa\u00f1ol"==this.language?s="cr\u00e9ditos":"english"==this.language&&(s="about");new a.Button(this,{region:"north",name:s,font_size:e.parse("15"),expresion:e.parse("(0, 0, 100, "+b+")")})}c.config&&("espa\u00f1ol"==this.language?s="config":"english"==this.language&&(s="config"),new a.Button(this,{region:"north",name:s,font_size:e.parse("15"),action:"config",expresion:e.parse("("+(g+100)+", 0, 100, "+b+")")}))}if(0<c.rowsSouth||0<h.length||c.init||c.clear){0>=
c.rowsSouth?(southRegionHeight=c.height,c.rowsSouth=1):southRegionHeight=c.height*c.rowsSouth;southRegionWidht=d.width;l=0;c.init&&(l=100,southRegionWidht-=l);c.clear&&(southRegionWidht-=100);g=this.southSpace.container;g.setAttribute("id","descartesJS_southRegion");g.setAttribute("style","width: "+d.width+"; height: "+southRegionHeight+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+(d.height-southRegionHeight)+"px; z-index: 100;");d.appendChild(g);m=Math.ceil(h.length/c.rowsSouth);
p=southRegionWidht/m;o=0;for(q=h.length;o<q;o++)h[o].expresion=e.parse("("+(l+p*(o%m))+","+c.height*Math.floor(o/m)+","+p+","+c.height+")"),h[o].drawif=e.parse("1");c.init&&("espa\u00f1ol"==this.language?s="inicio":"english"==this.language&&(s="init"),new a.Button(this,{region:"south",name:s,font_size:e.parse("15"),action:"init",expresion:e.parse("(0, 0, 100, "+southRegionHeight+")")}));c.clear&&("espa\u00f1ol"==this.language?s="limpiar":"english"==this.language&&(s="clear"),new a.Button(this,{region:"south",
name:s,font_size:e.parse("15"),action:"clear",expresion:e.parse("("+(southRegionWidht+100)+", 0, 100, "+southRegionHeight+")")}))}if(0<j.length){eastRegionHeight=d.height-b-southRegionHeight;f=c.widthEast;g=this.eastSpace.container;g.setAttribute("id","descartesJS_eastRegion");g.setAttribute("style","width: "+f+"; height: "+eastRegionHeight+"px; background: #c0c0c0; position: absolute; left: "+(d.width-f)+"px; top: "+b+"px; z-index: 100;");d.appendChild(g);o=0;for(q=j.length;o<q;o++)j[o].expresion=
e.parse("(0,"+c.height*o+","+f+","+c.height+")"),j[o].drawif=e.parse("1")}if(0<k.length){westRegionHeight=d.height-b-southRegionHeight;westRegionWidth=c.widthWest;g=this.westSpace.container;g.setAttribute("id","descartesJS_westRegion");g.setAttribute("style","width: "+westRegionWidth+"; height: "+westRegionHeight+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+b+"px; z-index: 100;");d.appendChild(g);o=0;for(q=k.length;o<q;o++)k[o].expresion=e.parse("(0,"+c.height*o+","+westRegionWidth+
","+c.height+")"),k[o].drawif=e.parse("1")}if(this.editableRegionVisible){editableRegionHeight=c.height;g=this.editableRegion.container;g.setAttribute("id","descartesJS_editableRegion");g.setAttribute("style","width: "+d.width+"px; height: "+editableRegionHeight+"px; position: absolute; left: 0px; top: "+(d.height-southRegionHeight-c.height)+"px; z-index: 100; background: #c0c0c0; overflow: hidden;");d.appendChild(g);e=this.editableRegion.textFields;c=d.width/e.length;o=0;for(q=e.length;o<q;o++)"div"==
e[o].type?(g.appendChild(e[o].container),e[o].container.setAttribute("style","font-family: Arial; width: "+(c-4)+"px; height: "+(editableRegionHeight-5)+"px; position: absolute; left: "+o*c+"px; top: 0px; border: 2px groove white;"),i=e[o].container.firstChild,h=i.offsetWidth,i.setAttribute("style","font-family: Arial; padding-top: 0%; background-color: lightgray; position: absolute; left: 0px; top: 0px; width: "+h+"px;"),i.firstChild.textContent=i.firstChild.textContent.substring(1,i.firstChild.textContent.length-
1),e[o].container.lastChild.setAttribute("style","font-family: 'Courier New'; width: "+(c-h-8)+"px; height: "+(editableRegionHeight-9)+"px; position: absolute; left: "+h+"px; top: 0px; border: 2px groove white;")):(g.appendChild(e[o]),e[o].setAttribute("style","font-family: 'Courier New'; width: "+c+"px; height: "+editableRegionHeight+"px; position: absolute; left: "+o*c+"px; top: 0px; border: 2px groove white;"))}this.displaceRegionNorth=b;this.displaceRegionWest=westRegionWidth;d.width-=f;d.height=
d.height-southRegionHeight-editableRegionHeight;o=0;for(q=this.spaces.length;o<q;o++)this.spaces[o].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,c=0,d=this.controls.length;c<d;c++)a=this.controls[c],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,c=this.auxiliaries.length;a<c;a++)this.auxiliaries[a].update()};
a.DescartesApp.prototype.updateEvents=function(){for(var a=0,c=this.events.length;a<c;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,c=this.controls.length;a<c;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var c=0,d=this.spaces.length;c<d;c++)this.spaces[c].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,c=this.spaces.length;a<c;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=
function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.reinit()};a.DescartesApp.prototype.getControlById=function(a){for(var c,d=0,b=this.controls.length;d<b;d++)if(c=this.controls[d],c.id==a)return c;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var c,d=0,b=this.spaces.length;d<b;d++)if(c=this.spaces[d],
c.cID==a)return c;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlByCId=function(a){for(var c,d=0,b=this.controls.length;d<b;d++)if(c=this.controls[d],c.cID==a)return c;return{update:function(){},w:0}};a.DescartesApp.prototype.getState=function(){var a=this.evaluator.variables,c,d="",b;for(b in a)a.hasOwnProperty(b)&&(c=a[b],"string"==typeof c&&(c="'"+c+"'"),"rnd"!=b&&"pi"!=b&&"e"!=b&&"Infinity"!=b&&"-Infinity"!=b&&"object"!=typeof c&&(d=""!=d?d+"\n"+b+"="+c:b+"="+c));return d};
a.DescartesApp.prototype.setState=function(a){for(var a=a.split("\\n"),c,d=0,b=a.length;d<b;d++)c=this.evaluator.parser.parse(a[d],!0),this.evaluator.evalExpression(c),this.saveState.push(c)};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,c=0,d="",b=0,g=this.controls.length;b<g;b++)"textfield"==this.controls[b].gui&&this.controls[b].evaluate&&(a++,c+=this.controls[b].ok,this.controls[b].value=""==this.controls[b].value?"''":this.controls[b].value,d+=" \\n "+this.controls[b].id+"="+
this.controls[b].value+"|"+this.controls[b].ok);return"questions="+a+" \\n correct="+c+" \\n wrong="+(a-c)+d};a.DescartesApp.prototype.showSolution=function(){for(var a=0,c=this.controls.length;a<c;a++)"textfield"==this.controls[a].gui&&this.controls[a].evaluate&&this.controls[a].changeValue(this.controls[a].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,c=this.saveState.length;a<c;a++)this.evaluator.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||
{}),descartesJS=function(a){function e(){var a=document.getElementById("StyleDescartesApps");a&&a.parentNode.removeChild(a);a=document.createElement("style");a.id="StyleDescartesApps";a.type="text/css";a.setAttribute("rel","stylesheet");a.innerHTML="applet.DescartesJS {display:none;} applet {display:none;}";document.head.appendChild(a)}function c(){for(var b=0,c=a.apps.length;b<c;b++)for(var d=0,e=a.apps[b].spaces.length;d<e;d++)a.apps[b].spaces[d].findOffset()}function d(){a.getFeatures();if(a.hasCanvasSupport){for(var b=
document.getElementsByTagName("*"),d=[],f=0,e=b.length;f<e;f++)"DescartesAppContainer"==b[f].className&&d.push(b[f]);f=0;for(e=d.length;f<e;f++)d[f].parentNode.removeChild(d[f]);for(var d=document.getElementsByTagName("applet"),b=[],e=0,h=d.length;e<h;e++)f=d[e],f.getAttribute("code").match("DescartesJS")&&b.push(f);f=0;for(e=b.length;f<e;f++)d=b[f],a.apps.push(new a.DescartesApp(d)),d.className="DescartesJS";document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:none;}";
window.addEventListener("resize",c,!1)}else document.getElementById("StyleDescartesApps").innerHTML="applet {display:block;}"}a.apps=[];a.getDescartesApps=function(){return a.apps};(!window.hasOwnProperty("debugDescartesJS")||!debugDescartesJS)&&e();void 0===a.loadLib&&(a.loadLib=!0,window.addEventListener("load",d,!1));return a}(descartesJS||{});
