/*
 Joel Espinosa Longi
 joel.espinosa@amite.mx
 j.longi@gmail.com
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-02-11
*/
var descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,c=360/e,f=e/360,d=Math.floor;a.rangeOK=1;a.radToDeg=function(a){return a*c};a.degToRad=function(a){return a*f};a.extend=function(a,e){if(a.prototype.__proto__)a.prototype.__proto__=e.prototype;else for(var c in e.prototype)e.prototype.hasOwnProperty(c)&&(a.prototype[c]=e.prototype[c]);a.prototype.uber=e.prototype};a.convertFont=function(a){if(""==a)return a;var e=a.split(",");a="";"bold"==e[1].toLowerCase()?a+="Bold ":"italic"==e[1].toLowerCase()||
"italics"==e[1].toLowerCase()?a+="Italic ":"bold+italic"==e[1].toLowerCase()&&(a+="Italic Bold ");a+=e[2]+"px ";e=e[0].split(" ")[0].toLowerCase();return"serif"==e||"times new roman"==e||"timesroman"==e?a+"'Times New Roman'":"sansserif"==e||"arial"==e||"helvetica"==e?a+"Arial":a+"'Courier New'"};a.drawLine=function(a,e,c,f,h,q,l){a.lineWidth=l||1;a.strokeStyle=q||"black";q=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(d(e)+q,d(c)+q);a.lineTo(d(f)+q,d(h)+q);a.stroke()};a.getColor=function(a,e){if("string"==
typeof e)return e;var c=a.evalExpression(e),f=d(255*c[0][0]),h=d(255*c[0][1]),q=d(255*c[0][2]);return"rgba("+f+","+h+","+q+","+(1-c[0][3])+")"};a.getFeatures=function(){a.hasJavaSupport=navigator.javaEnabled();var e=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&window.hasOwnProperty("ontouchstart")||e.match("android")&&!0;a.hasTouchSupport=navigator.userAgent.toLowerCase().match("qt")?!1:a.hasTouchSupport;var c=document.createElement("canvas");a.hasCanvasSupport=c.getContext&&
c.getContext("2d");a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"));e.match("chrome")&&(Number.prototype.toFixed=function(a){a=0>a?0:parseInt(a);var e=this.toString(),c=e.indexOf("."),d="";if(-1===c){0<a&&(d=".");for(c=0;c<a;c++)d+="0";return e+d}var f=e.length-c-1;if(f>=a)return e.substring(0,c+1+a);for(c=0;c<a-f;c++)d+="0";return e+d})};a.openExternalFile=function(a){var e=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(f){try{c=new ActiveXObject("Microsoft.XMLHTTP")}catch(h){c=!1}}c.open("GET",a,!1);try{c.send(null),e=c.responseText,e.match(String.fromCharCode(65533))&&(c.open("GET",a,!1),c.overrideMimeType("text/plain; charset=ISO-8859-1"),c.send(null),e=c.responseText)}catch(l){console.log("El archivo ",a," no se pudo abrir"),e=null}return e};a.getCursorPosition=function(a){var e;a.touches?(a=a.touches[0],e=a.pageX,a=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(e=a.pageX,
a=a.pageY):(e=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,a=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:e,y:a}};a.buildSimpleRegularExpressionPattern=function(e){var c=e.trim();e={ignoreAcents:!1,ignoreCaps:!1,regExp:null};if(c.match(/\(/)||c.match(/\)/)||c.match(/\[/)||c.match(/\]/))return e.regExp=a.buildRangeExpresions(c),e.type="numeric",e;c[0]==c[c.length-1]&&"'"==c[0]&&(e.ignoreCaps=!0,c=c.substring(1,c.length-1),"`"==c[0]&&"\u00b4"==
c[c.length-1]&&(e.ignoreAcents=!0,c=c.substring(1,c.length-1)));"`"==c[0]&&"\u00b4"==c[c.length-1]&&(e.ignoreAcents=!0,c=c.substring(1,c.length-1),c[0]==c[c.length-1]&&"'"==c[0]&&(e.ignoreCaps=!0,c=c.substring(1,c.length-1)));"*"==c[0]&&"*"!=c[c.length-1]&&(c=c.substring(1)+"$");"*"!=c[0]&&"*"==c[c.length-1]&&(c="^"+c.substring(0,c.length-1));"*"==c[0]&&"*"==c[c.length-1]&&(c=c.substring(1,c.length-1));c=c.replace(/\?/g,"[\\S\\s]{1}");e.regExp=c;e.type="textual";return e};a.buildRangeExpresions=function(a){var e;
a=a.split(",");h?(e=a[0].trim(),a[0]={type:e[0],expression:parseFloat(h.evalExpression(h.parser.parse(e.substring(1))))},e=a[1].trim(),a[1]={type:e[e.length-1],expression:parseFloat(h.evalExpression(h.parser.parse(e.substring(0,e.length-1))))}):(e=a[0].trim(),a[0]={type:e[0],expression:parseFloat(e.substring(1))},e=a[1].trim(),a[1]={type:e[e.length-1],expression:parseFloat(e.substring(0,e.length-1))});return a};a.evalRangeExpresion=function(a,e){var c=parseFloat(e),d=a.regExp[0].expression,f=a.regExp[1].expression,
h="("===a.regExp[0].type,l="["===a.regExp[0].type,p=")"===a.regExp[1].type,u="]"===a.regExp[1].type;return h&&p&&c>d&&c<f||h&&u&&c>d&&c<=f||l&&p&&c>=d&&c<f||l&&u&&c>=d&&c<=f?1:0};a.buildRegularExpresionsPatterns=function(e){e=e.replace(/&squot;/g,"'").replace(/&amp;/g,"&").split("|");for(var c,d,f=0,h=e.length;f<h;f++){c=e[f].split("&");d=[];for(var q=0,l=c.length;q<l;q++)d.push(a.buildSimpleRegularExpressionPattern(c[q]));e[f]=d}return e};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")};var h;a.escorrecto=function(e,c,d){h=d;e=a.buildRegularExpresionsPatterns(e);var f;c=removeAcents(c).toLowerCase();for(var n=0,q=e.length;n<q;n++){d=e[n];f=!0;for(var l=0,p=d.length;l<p;l++)"textual"===d[l].type?(d[l].regExp=removeAcents(d[l].regExp).toLowerCase(),
f=f&&!!c.match(d[l].regExp)):f=f&&a.evalRangeExpresion(d[l],c);if(f)return 1}return 0};a.esCorrecto=function(e,c,d){h=d;e=a.buildRegularExpresionsPatterns(e);for(var f,n=0,q=e.length;n<q;n++){d=e[n];f=!0;for(var l=0,p=d.length;l<p;l++)"textual"===d[l].type?(d[l].ignoreAcents&&(c=removeAcents(c),d[l].regExp=removeAcents(d[l].regExp)),d[l].ignoreCaps&&(c=c.toLowerCase(),d[l].regExp=d[l].regExp.toLowerCase()),f=f&&!!c.match(d[l].regExp)):f=f&&a.evalRangeExpresion(d[l],c);if(f)return 1}return 0};a.getTextWidth=
function(e,c){a.ctx.font=c;return a.ctx.measureText(e).width};a.getFieldFontSize=function(a){return 14>=a?8:14<a&&16>=a?9:16<a&&19>=a?10:19<a&&22>=a?11:22<a?parseInt(a-11):Math.floor(a-0.25*a)};a.getCreativeCommonsLicenseImage=function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAABHNCSVQICAgIfAhkiAAACpVJREFUaIHtWm1sU9cZfu61iUYnPP/bJgdhhDbFkVYcCrR0tLHXrVNL01wvgUJDh820tivrkpQQtpEvA4HGhDoe/dCmNfbaVa1WKszX2oUO3xC0OHESm9Hi/FhloyQq1aY5OGgq8ce7H9f3xI7txKFsdKyPdHSPz8dzz33Oe77eY46IVBzHXcUXuOkgIo4DQABwuucUeJ4Hz/NQKBTgeQUUPA9ekXryPDiOB89x4DgO4DiZBQQCJQlJSiKZlEIikZCeyQQSiSSSyQTLS1KSlSciuTEsfjtgY+UmAAAHgGRxFQqFFHjFTFyhkPJ4RUpkDhzHp+ubEiclbFISM5FIhfR4IlPkZDLJhE0X+nbBxspNUALIFFehhDLjKYWTx0/B4/FgcHAQU9GpDKIlqiVYu3YtjN8xouLRR5BIKsDzcalDEjw4cJD6cgaUJGkkANIY4iRxR3x+uN9xIxgMZpTX6XQQqgSsWlNW0Md9Xng4APSns+9BqVQyUZVKpRQUSvSK52B73oaJiYmCGqTRaND4i0aUl9+PeCKBRCKOeDwVEnHE4wlm4emW/PHExzjS9SJGg6MAAIPBAL1eDwAIBAIQRREAUKIrwY7aHfja17+a8/1XPv4ELzle+lzwbKzcJAn8fu8ZKBXKGWGVi7BIqURrcxvcx9ysglqthiAI0Gq1KC8vBwD09vYiHA7D7XZjcnKSlRVMAhoad2LxHYsRj8cRi8cRj8cQj8czpwxK4mrkKn769LOIRqMQBAF2ux1arTajseFwGPX19XC73VCpVGi3tWd91LXoNdTuqPvc8MjzMJ3tO0t9/eeo39dPQwEfXfggQIJJIEiDl9RqNbW1tVEkEqG54HQ6Sa1Ws3oluhI6399HQ4Eh8g71U1//OfL0naUzYg+99+d36XTPKTrx7nHS6XQEgMxmcwafzDP7HTL328f/kBFKdCU5eRx2Oz3+2ObPxDM2Nkbe/n7y9vfT2NhYQTwAiAcARWoOVioUUCoyLVev18Pv96O1tRVqtTprGKTDbDYjFAqxoTQaHEWn7XDGXM6zHYm0G/F5fQgGgxAEAY27ds3JL79DEASMBkcx4vOz9BGfH6PBUawqK8O996xj6b/q6sLzNhtOnj6N3Q27MD4+XhBPent+/9prMKy/DzWbt6Bm8xYY1t+HMz09c/Kkg/q8feQd8tLIhWFyHHEwy9Hr9fNabS5EIhHS6/WMx/Gig0b+OkIDw1467+0jz3nJit99/4+kK5WsNxQKFcwfCoUIAOl0OmYt8igo+cY3acUyLZV/ez09/eMnCQC1tbXRwQMHCQAdffvtgnjk9nj7+yW+u9fRj7ZZqHFnA61YpqUVy7TksNvz8uSwYMmKbc/bAEjzrdPpnNdqc0GtVsPj8bC6toO21F46ZcFcak/N8wheCsJgMGTNcRaLhVm5xWLJyNNqtTAYDBkrezAo8VRUVGDjpk0YHx/HmZ4erFimxb+mrmHrE1tx6cMPUVVdXRCPVqtFNBpF0H8RAFAp/AC/dXWjo/MQ9rQ0AwBc3c68PDJ4AKlhK23F5N1CXV0dG+o3ArVaDbvdDgCYmJjAyROn2IFFEplj27Rc73G5XDnjMnLV0ev1sB3uxEFbB954601UVVfjo8th2A53YunSpXB1OxG8dKkgHhntL0gG95vfvcrSvvfggwCAaDSKT65cycsDpASWrcnj8QCQxKmtrWWFRFGEyWSC0WiE0WiE1WrNm9fV1cXyzGYzs2LPWU+a9XLg+BmB/xO4+5570NF5CGNjY2jc2YCyb92Jd44eRcXDG1CzeQubQ+eCSqWCw+HAHaoleOWVV3KW+fTT63NySAcNjgPPcRgcHAQACILAhBFFEUajMaOSKIoQRRG1tbUwmUxZeRcuXIDT6WRcLpcLg4OD0gkwJawkriRwIBDIapjZbGaWazabs/Jz1ZmdFo1GcaanBx2dh2C+ZEHFwxsAAANeLwa8XhQXF4NbpJyTZ5FSicaGBtyxeDFLG/B6WXyZdlne9gDMgqUPlk9oK1euZAXq6+sBSPNMKBSCx+OBVqvFtm3bmCXr9XqEQiEcO3YsY48MgMWnolPSe8ClPYHS0lKIoohwOJzRMLmDZscBaQ8qiiJ0Oh1L0+l0WTw/efIptO/dh1V3rkTN5i346HIYVdXV6Og8hJqtWwviGR8fR1tLKx5/bDPa9+5D+959aGlqAgDs2r07b3syBAaHjOGaPp/IPWM2m9lkHgqFYDabWZ58+BAEgeXJSF+8JKPNPDZvfExadOSOLARyWaFKYGlyPJ2no/MQLNu348o//o6/hUJw2O3Y09KMqupqWPfvQ9ma1fPyWLZvh2X7dgCAs7sbzu5uXP/0OjZUPIItNY/nbY+M7PHxX8a69eugK9XB7XbDYrFkWetsyKenEl1Jhh9g1ZoylOhKMniKi4uxp6UZX1q8GCPDw/hZXd0N8expacb3H3oIly+HAUijTldaOiePDMmCKdOLlT6fyNbscrkwOTmJQCCA5cuXw2q1sjz5mJyeJyN9yEpnM3l7PIPmtmaoVCq4XC6YTCZWh9K8bOFwGCaTCV1dXVCpVNhRuyPrY3b/sjEnz85dDXjjrTc/E8/qNatRVV2Nqupq6EpLC+IBUs4e38ggioqKsP7e+zAVnYLZbGaW5Ha7sxYyQJoyKisr8+bJ9evr69HV1YUlqiU4/5c+TE9PYzo2jVg8hlgsLjmDEnFE/jmJA9YDbC+p1+uh1+uhVqshiiLr9PmcNNei19BxwMacNLeShzl7BoYHUFRUBGuLFe5jbqjVakQiEVZQFEU4HA7mzDEYDGhtbWUd4HA4WNn0PABYvnw5wuEwHvjuAzhs78T16WnEZgks+42TiSR8Az4cO3rr3Yw3g4cJ7B3qx6JFRTh/7jxqn5X2v3a7HXVpc9aNwOVysVPY/gP78fCGhzAdm8Z0LIZ4LIZYfJbAORzw/8vYWLlJmoPlKx2DsRwajQYAYLVas7ZOC8Hk5CRbXTUaTcoRn7rFSCaRTM3FlLpyul3BA0CSkkgkpHu0fe17AUgCmUymDB9voZicnITRaGR1G3/emHKwJ2ZETrsyYovsrMX2dgEBoKbWJvKNDFLgop+e+OETGR41v9+/IE9XuidNMAkUuOgn38gg7W3fy9L/j8LMj7rnamnI76PADTjcI5EItbW1ZTjc16xdQxc+CNBQwEdNrU23+kNvSWDX9jKaW5tQaRKgVCpx2HYYr7/2Ostb6JWRdV8b4vE4BgYG8cxTz2A+pE8P8smSiDJOmbN/5+PJV0d+R6GOpnxtWhDH7NDc2iRZ8kU/dbteJY1GU3CPaTQachxxUOCin4YCPnr51y8XXJeI5oynp83HM1/9QrhylVkoR5YFy6h7rhY1W2vYVY/o6cWJ4yfmvLZ/VHgUBkM5u9A8fvwE9lv3F9DHEnJZS3reQqyO47i8z4VgtrXOXoTn48srMACsuqsMza0tKF6qSbuNSHc3ImPfKv/xZGJ8HC902nGu99yCP+azTA35eABkCbxQsXN1UiEccwos4/7y+7GhYgPuWn0XvqJSpf46Jb9ZetHVaBTDQ8M4ffL0goVN/wjWsJtgwbl+L2T+nG9NuGkCf4EbB09EX77VjbhdQUTcvwFtwhQyXNo3TwAAAABJRU5ErkJggg==";
return a};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="canvas { image-rendering: optimizeSpeed; image-rendering: -moz-crisp-edges; image-rendering: -webkit-optimize-contrast; image-rendering: optimize-contrast; -ms-interpolation-mode: nearest-neighbor; }\ndiv.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: solid #666666 1px; position: absolute; top: 0px; }\nlabel.DescartesSpinnerLabel, label.DescartesMenuLabel, label.DescartesScrollbarLabel, label.DescartesTextFieldLabel{ font-family: Arial; font-weight: normal; text-align: center; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; }\ndiv.DescartesGraphicControl{ border-style: none; position: absolute; }\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,f=Math.random,d=Math.round,h=String.fromCharCode;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){for(var d=Array(256),f=0;256>f;f++)d[f]=h(this.alfanum(c(Math.abs(7.5*(e(1*f-a)+e(1.4*f+a)+e(0.6*f-a)+e(2.2*f+a))))));return d.join("")};a.Krypto.prototype.encode=function(a){var e=c(31*f());this.key=this.getKey(e);return h(this.alfanum(e))+this.encripta(a)};
a.Krypto.prototype.decode=function(a){var e=this.numalfa(a.charCodeAt(0));this.key=this.getKey(e);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),h,m=0,n=a.length;m<n;m++)h=256*c(a[m]+128)+d(255*f())+65536*d(255*f()),h=c((h<<this.shift(m))/256),e[3*m]=this.alfanum(h%32),e[3*m+1]=this.alfanum(h/
32%32),e[3*m+2]=this.alfanum(h/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 e=Array(a.length/3),d,f=0,h=e.length;f<h;f++)d=this.numalfa(a[3*f])+32*this.numalfa(a[3*f+1])+1024*this.numalfa(a[3*f+2]),d=c(256*d>>this.shift(f)),d=c(d/256)%256-128,0>d&&(d+=256),e[f]=d;return e};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 e=Array(a.length),c=0,d=a.length;c<d;c++)e[c]=a.charCodeAt(c);return e};a.Krypto.prototype.bytesToString=function(a){for(var e=0,c=a.length;e<c;e++)a[e]=h(a[e]);return a.join("")};a.Krypto.prototype.shift=function(a){a=this.key.charCodeAt(a%this.key.length);a=this.numalfa(a);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 f=e.evaluator,d=f.parser,h=new a.Auxiliary(e);this.delay=c.delay?d.parse(c.delay):d.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=h.splitInstructions(d,c.init);this.doExpr=h.splitInstructions(d,c.doExpr);c.whileExpr&&(this.whileExpr=d.parse(c.whileExpr));var g=this;this.animationExec=
function(){for(var a=0,e=g.doExpr.length;a<e;a++)f.evalExpression(g.doExpr[a]);g.parent.update();g.playing&&(0<f.evalExpression(g.whileExpr)||g.loop)?g.timer=setTimeout(g.animationExec,f.evalExpression(g.delay)):(g.stop(),g.parent.update())};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 f=this.evaluator,d=f.parser;this.parameter=c.replace(/&squot;/g,"'");this.parameter=this.parameter.replace(/;/g,"\\n");this.parameter=this.parameter.split("\\n")||[""];for(var h=[],g,j=0,k=this.parameter.length;j<k;j++)(g=d.parse(this.parameter[j],!0))&&h.push(g);this.parameter=h;this.actionExec=function(){for(var a=
0,e=this.parameter.length;a<e;a++)f.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 f=this.parameter.indexOf("target");-1!=f&&(this.target=this.parameter.substring(f),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,
f-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";this.target="popup";var f=this.parameter.indexOf("target");-1!=f&&(this.target=this.parameter.substring(f),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,f-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(){this.window=window.open(this.parameter,this.target,"width="+this.parent.width+",height="+this.parent.height+",left="+(window.screen.width-this.parent.width)/2+", top="+(window.screen.height-this.parent.height)/2+"location=no,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no");this.window.onload=
function(){try{var a=this.window.document,e=a.getElementsByTagName("applet");e&&0<e.length&&(this.window.innerWidth=e[0].width,this.window.height=e[0].height,a.style.margin="0px",a.style.padding="0px")}catch(c){}}}):this.actionExec=function(){this.window=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 f=a.evaluator.parser;this.expresion=this.id="";this.evaluate="onlyOnce";this.size=f.parse("3");
this.rows=f.parse("3");this.columns=f.parse("3");for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};a.Auxiliary.prototype.splitInstructions=function(a,c){var f,d=[];c=c?c.split(";"):[""];for(var h=0,g=c.length;h<g;h++)(f=a.parse(c[h],!0))&&d.push(f);return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Variable=function(e,c){a.Auxiliary.call(this,e,c);var f=this.evaluator.parser;this.expresionString=
this.expresion;(this.expresion=f.parse(this.expresionString))&&f.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 f=document.createElement("input");f.value=this.expresionString;f.disabled=!this.editable;a.appendChild(c);a.appendChild(f);var d=this;f.onkeydown=
function(a){13==a.keyCode&&(d.expresion=d.evaluator.parser.parse(this.value),d.evaluator.parser.setVariable(d.id,d.expresion),d.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 f=this.evaluator,d=f.parser;this.expresion=this.expresion.split(";");var h;if(this.file){var g=document.getElementById(this.file);g&&"descartes/vectorFile"==g.type?(h=g.text,"\n"==h[0]&&(h=h.substring(1))):h=a.openExternalFile(this.file);null!=h&&(h=h.split("\n"));null==h||1==h.length&&""==h[0]?(h=[],this.size=0):(this.expresion=
[],this.size=null);for(var j,k=0,g=0,m=h.length;g<m;g++)h[g].match(/./)&&(this.expresion[k]=this.id+"["+k+"]="+h[g],k++,(j=h[g].match(/[\w-//]*(.png|.jpg|.gif|.svg|.PNG|.JPG|.GIF|.SVG)/g))&&this.parent.getImage(j));null==this.size&&(this.size=d.parse(this.expresion.length+""))}g=0;for(m=this.expresion.length;g<m;g++)(h=d.parse(this.expresion[g],!0))&&"asign"!=h.type&&(h=d.parse(this.id+"["+g+"]="+this.expresion[g],!0)),this.expresion[g]=h;m=f.evalExpression(this.size);d=[];for(g=0;g<m;g++)d.push(0);
f.vectors[this.id]=d;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,f=this.expresion.length;c<f;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 f=this.evaluator;this.expresion=this.splitInstructions(f.parser,this.expresion);var d=f.evalExpression(this.rows),
h=f.evalExpression(this.columns),g=[];g.type="matrix";for(var j,k=0;k<h;k++){j=[];for(var m=0,n=d;m<n;m++)j.push(0);g[k]=j}f.matrices[this.id]=g;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,c=a.evalExpression(this.rows),f=a.evalExpression(this.columns);a.setVariable(this.id+".filas",c);a.setVariable(this.id+".columnas",f);var d=a.matrices[this.id];d.rows=c;d.cols=f;c=0;for(f=this.expresion.length;c<f;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 f=this.evaluator,d=f.parser,h=this.id.indexOf("(");this.name=this.id.substring(0,h);this.params=this.id.substring(h+1,this.id.length-1);this.domain=this.range?d.parse(this.range):d.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.init=this.splitInstructions(d,this.init);this.doExpr=this.splitInstructions(d,this.doExpr);
this.whileExpr&&(this.whileExpr=d.parse(this.whileExpr));this.expresion=d.parse(this.expresion);var g=this;this.functionExec=this.algorithm?function(){if(g.numberOfParams==arguments.length){for(var e=[],c=0,d=g.params.length;c<d;c++)e[c]=f.getVariable(g.params[c]),f.setVariable(g.params[c],arguments[c]);c=0;for(d=g.init.length;c<d;c++)f.evalExpression(g.init[c]);do{c=0;for(d=g.doExpr.length;c<d;c++)f.evalExpression(g.doExpr[c])}while(0<f.evalExpression(g.whileExpr));var h=f.evalExpression(g.expresion);
a.rangeOK=f.evalExpression(g.domain);c=0;for(d=g.params.length;c<d;c++)f.setVariable(g.params[c],e[c]);return h}return 0}:function(){if(g.numberOfParams==arguments.length){for(var e=[],c=0,d=g.params.length;c<d;c++)e[c]=f.getVariable(g.params[c]),f.setVariable(g.params[c],arguments[c]);var h=f.evalExpression(g.expresion);a.rangeOK=f.evalExpression(g.domain);c=0;for(d=g.params.length;c<d;c++)f.setVariable(g.params[c],e[c]);return h}return 0};f.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 f=this.evaluator,d=f.parser,h=this.id.indexOf("(");this.name=this.id.substring(0,h);this.params=this.id.substring(h+1,this.id.length-1);this.domain=this.range?d.parse(this.range):d.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.init=this.splitInstructions(d,this.init);this.doExpr=this.splitInstructions(d,
this.doExpr);this.whileExpr&&(this.whileExpr=d.parse(this.whileExpr));this.expresion=d.parse(this.expresion);var g=this;this.functionExec=this.algorithm?function(){if(g.numberOfParams==arguments.length){for(var c=[],e=0,d=g.params.length;e<d;e++)c[e]=f.getVariable(g.params[e]),f.setVariable(g.params[e],arguments[e]);e=0;for(d=g.init.length;e<d;e++)f.evalExpression(g.init[e]);do{e=0;for(d=g.doExpr.length;e<d;e++)f.evalExpression(g.doExpr[e])}while(0<f.evalExpression(g.whileExpr));var h=f.evalExpression(g.expresion);
a.rangeOK=f.evalExpression(g.domain);e=0;for(d=g.params.length;e<d;e++)f.setVariable(g.params[e],c[e]);return h}return 0}:function(){if(g.numberOfParams==arguments.length){for(var e=[],c=0,d=g.params.length;c<d;c++)e[c]=f.getVariable(g.params[c]),f.setVariable(g.params[c],arguments[c]);var h=f.evalExpression(g.expresion);a.rangeOK=f.evalExpression(g.domain);c=0;for(d=g.params.length;c<d;c++)f.setVariable(g.params[c],e[c]);return h}return 0};f.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 f=this.evaluator,d=f.parser;this.init=this.splitInstructions(d,this.init);this.doExpr=this.splitInstructions(d,this.doExpr);this.whileExpr&&(this.whileExpr=d.parse(this.whileExpr));this.algorithmExec=function(){for(var a=0,e=this.init.length;a<e;a++)f.evalExpression(this.init[a]);do{a=0;for(e=this.doExpr.length;a<e;a++)f.evalExpression(this.doExpr[a])}while(0<
f.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 f=this.evaluator;this.condition=f.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){0<
f.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<f.evalExpression(this.condition);3==this.parent.version?a!=this.lastEvaluation&&(this.action.execute(),this.lastEvaluation=a?!0:!1):a&&!this.lastEvaluation?(this.action.execute(),this.lastEvaluation=!0):!a&&this.lastEvaluation&&(this.lastEvaluation=!1)});"always"==this.execution&&(this.eventExec=function(){0<f.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 f=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=f.parse("1");this.abs_coord=!1;this.family=this.trace=
"";this.family_interval=f.parse("[0,1]");this.family_steps=f.parse("8");this.parameter="t";this.parameter_interval=f.parse("[0,1]");this.parameter_steps=f.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=f.parse("2");this.text="";this.decimals=f.parse("2");this.spear=f.parse("8");this.arrow="#ee0022";this.center=f.parse("(0,0)");this.radius=f.parse("1");this.init=f.parse("0");this.end=f.parse("90");this.file=
"";this.inirot=f.parse("0");for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=f.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,f=0,d=a.length;f<d;f++)if(c=
a[f],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,f){var d=this.evaluator;this.getFamilyValues();var h=d.getVariable(this.family);if(0<=this.fSteps)for(var g=0,j=this.fSteps;g<=
j;g++)d.setVariable(this.family,this.familyInf+g*this.family_sep),0<d.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,c,f));d.setVariable("_Text_H_",0);d.setVariable(this.family,h)};a.Graphic.prototype.draw=function(a,c){""!=this.family?this.drawFamilyAux(this.ctx,a,c):0<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):0<this.evaluator.evalExpression(this.drawif)&&
(this.update(),this.drawAux(this.traceCtx,a,c))};a.Graphic.prototype.drawText=function(e,c,f,d,h,g,j,k,m,n){if("rtfNode"==c.type)e.fillStyle=h,e.strokeStyle=h,e.textBaseline="alphabetic",c.draw(e,f,d,m,n,j);else{"simpleText"===c.type&&(c=c.toString(m,n).split("\\n"));f+=g.match("Arial")?-2:g.match("Times")?-2:0;m=this.evaluator;e.fillStyle=a.getColor(m,h);e.font=g;e.textAlign=j;e.textBaseline=k;this.fontSize=(this.fontSize=g.match(/(\d+)px/))?this.fontSize[1]:"10";this.border&&(e.strokeStyle=a.getColor(m,
this.border),e.lineWidth=parseFloat(this.fontSize)/12);g=1.2*this.fontSize;j=0;for(k=c.length;j<k;j++)h=c[j],this.border&&e.strokeText(h,f,d+g*j),e.fillText(h,f,d+g*j)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=function(a,c){this.text=a;this.textElements=[];this.textElementsMacros=[];this.parent=c;this.evaluator=c.evaluator;this.type="simpleText";for(var f="'",d=0,h=0,g=-1,j,k;d<a.length;)j=a.charAt(d),k=a.charAt(d-1),"["===j&&"\\"===k?(this.textElements.push(a.substring(h,
d-1)+"["),this.textElementsMacros.push("'"+a.substring(h,d-1)+"['"),h=d+1):"]"===j&&"\\"===k?(this.textElements.push(a.substring(h,d-1)+"]"),this.textElementsMacros.push("'"+a.substring(h,d-1)+"]'"),h=d+1):"["===j&&-1==g?(this.textElements.push(a.substring(h,d)),this.textElementsMacros.push("'"+a.substring(h,d)+"'"),h=d,g++):"["===j?g++:"]"===j&&0==g?(this.textElements.push(this.evaluator.parser.parse(a.substring(h,d+1))),this.textElementsMacros.push("["+a.substring(h,d+1)+"]"),h=d+1,g--):("]"==a.charAt(d)&&
(g=0>g?g:g-1),f+=a.charAt(d)),d++;this.textElements.push(a.substring(h,d));this.textElementsMacros.push("'"+a.substring(h,d)+"'")};a.SimpleText.prototype.toString=function(a,c){for(var f="",d,h=0,g=this.textElements.length;h<g;h++)"string"===typeof this.textElements[h]?f+=this.textElements[h]:(d=this.evaluator.evalExpression(this.textElements[h])[0][0],""!==d&&("string"===typeof d?f+=d:(d=parseFloat(d),d=c?d.toFixed(a):parseFloat(d.toFixed(a)),f+=d.toString().replace(".",this.parent.decimal_symbol))));
return f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,c=2*Math.PI;a.Equation=function(c,e){a.Graphic.call(this,c,e);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],
e=this.expresion.childs[1];"identifier"==c.type&&"y"==c.value&&!e.contains("y")?(this.funExpr=e,this.drawAux=this.drawAuxFunY):"identifier"==e.type&&"y"==e.value&&!c.contains("y")?(this.funExpr=c,this.drawAux=this.drawAuxFunY):"identifier"==c.type&&"x"==c.value&&!e.contains("x")?(this.funExpr=e,this.drawAux=this.drawAuxFunX):"identifier"==e.type&&("x"==e.value&&!c.contains("x"))&&(this.funExpr=e,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)};var f,d,h,g,j,k,m,n,q,l,p,u,s,t,r,v,x,z,w,y,C,B,D;a.Equation.prototype.drawAux=function(c,A,G){c.lineWidth=1;f=this.evaluator;d=f.parser;h=this.space;a.getColor(f,this.color);c.fillStyle=G;g=f.evalExpression(this.width);g=e(g)/2;d.getVariable("x");d.getVariable("y");j=h.w;k=h.h;m=e(j/8);3>m&&(m=3);n=e(k/8);3>n&&(n=3);b=[];
q=new a.R2;l=new a.R2;p=new a.R2;for(D=e(n/2);D<k;D+=n)for(B=e(m/2);B<j;B+=m)if(this.abs_coord?(s=this.newt.findZero(new a.R2(B,D)),f.setVariable("x",s.x),f.setVariable("y",s.y),u=new a.R2(s.x,s.y)):(s=this.newt.findZero(new a.R2(h.getRelativeX(B),h.getRelativeY(D))),f.setVariable("x",s.x),f.setVariable("y",s.y),u=new a.R2(h.getAbsoluteX(s.x),h.getAbsoluteY(s.y))),t=e(u.ix()),r=e(u.iy()),!(0>t||t>=j||0>r||r>=k||b[t+r*h.w]))if(b[t+r*h.w]=!0,q.x=s.x,q.y=s.y,l.x=s.x,l.y=s.y,v=this.newt.getUnitNormal(),
!(0==v.x&&0==v.y)){v.rotL90();p.x=v.x;p.y=v.y;z=x=0;for(w=!1;2>z;){w&&(p.x=-v.x,p.y=-v.y,s.x=q.x,s.y=q.y,l.x=s.x,l.y=s.y,u=this.abs_coord?new a.R2(s.x,s.y):new a.R2(h.getAbsoluteX(s.x),h.getAbsoluteY(s.y)),t=u.ix(),r=u.iy(),w=!1,x=0);this.abs_coord?(s.x+=p.x,s.y+=p.y):(s.x+=p.x/h.scale,s.y+=p.y/h.scale);s=this.newt.findZero(s);f.setVariable("x",s.x);f.setVariable("y",s.y);p.x=s.x-l.x;p.y=s.y-l.y;p.normalize();if(0==p.x&&0==p.y)break;l.x=s.x;l.y=s.y;u=this.abs_coord?new a.R2(s.x,s.y):new a.R2(h.getAbsoluteX(s.x),
h.getAbsoluteY(s.y));y=e(u.ix());C=e(u.iy());if(y!=t||C!=r)if(t=y,r=C,0<=t&&t<j&&0<=r&&r<k)if(x=0,b[t+r*h.w])break;else b[t+r*h.w]=!0,a.rangeOK&&c.drawImage(this.auxCanvas,t-this.width_2,r-this.width_2);else w=!0,z++;else 4<++x&&(w=!0,z++)}}};a.Equation.prototype.drawAuxFunY=function(c){var e=this.evaluator,d=this.space,f=d.w,h=1/d.scale,g=d.getAbsoluteY(0),n=e.evalExpression(this.width),p=a.getColor(e,this.color),j=a.getColor(e,this.fillM),l=a.getColor(e,this.fillP);c.fillStyle=p;var k=d.getRelativeX(0),
q,m,u,s;e.setVariable("x",k);for(var r=d.getAbsoluteX(k),t=d.getAbsoluteY(e.evalExpression(this.funExpr)),w=0,x,y,v=1;v<f;v++){q=k+v*h;e.setVariable("x",q);m=e.evalExpression(this.funExpr);e.setVariable("y",m);u=d.getAbsoluteX(q);s=d.getAbsoluteY(m);x=Math.min(w,m);y=Math.max(w,m);x={min:x,max:y};if(void 0!==m&&(a.rangeOK&&e.evalExpression(this.drawif))&&!this.hasSingularity(h,q,"x",q-h,w,q,m,x)){if(this.fillM||this.fillP)c.lineWidth=1,c.strokeStyle=s>g?j:l,c.beginPath(),c.moveTo(u+0.5,s),c.lineTo(u+
0.5,g),c.stroke();c.lineWidth=n;c.strokeStyle=p;c.beginPath();c.moveTo(r,t);c.lineTo(u,s);c.stroke()}w=m||0;r=u;t=s}};a.Equation.prototype.drawAuxFunX=function(c){var e=this.evaluator,d=this.space,f=d.h,h=1/d.scale,g=d.getAbsoluteX(0),n=e.evalExpression(this.width),p=a.getColor(e,this.color),j=a.getColor(e,this.fillM),l=a.getColor(e,this.fillP);c.fillStyle=p;var k=d.getRelativeY(f),q,m,u,s;e.setVariable("y",k);for(var r=d.getAbsoluteX(e.evalExpression(this.funExpr)),w=d.getAbsoluteY(k),t=0,x,y,v=
1;v<f;v++){q=k+v*h;e.setVariable("y",q);m=e.evalExpression(this.funExpr);e.setVariable("x",m);u=d.getAbsoluteX(m);s=d.getAbsoluteY(q);x=Math.min(t,m);y=Math.max(t,m);x={min:x,max:y};if(void 0!==q&&(a.rangeOK&&e.evalExpression(this.drawif))&&!this.hasSingularity(h,q,"y",q-h,t,q,m,x)){if(this.fillM||this.fillP)c.lineWidth=1,c.strokeStyle=u>g?j:l,c.beginPath(),c.moveTo(u,s+0.5),c.lineTo(g,s+0.5),c.stroke();c.lineWidth=n;c.strokeStyle=p;c.beginPath();c.moveTo(r,w);c.lineTo(u,s);c.stroke()}t=m||0;r=u;
w=s}};a.Equation.prototype.hasSingularity=function(a,c,e,d,f,h,g,n){if(1E-12>Math.abs(h-d)||1E-8>Math.abs(h-d)&&Math.abs(g-f)>Math.abs(a))return!0;var p=!1,p=(d+h)/2;this.evaluator.setVariable(e,p);var j=this.evaluator.evalExpression(this.funExpr);n.min<=j&&j<=n.max?p=!1:(n.x=Math.min(n.min,j),n.y=Math.max(n.max,j),p=this.hasSingularity(a,c,e,d,f,p,j,n)||this.hasSingularity(a,c,e,p,j,h,g,n));this.evaluator.setVariable(e,c);return p};a.drawPixel=function(a,e,d,f){a.moveTo(e,d);a.arc(e,d,f,0,c,!1)};
a.Equation.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.parseExpresion(),c.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Curve=function(c,e){a.Graphic.call(this,c,e);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);var c,f,d,h,g,j,k,m,n,q,l;a.Curve.prototype.update=function(){c=this.evaluator;f=c.evalExpression(this.parameter_interval);this.paraInf=f[0][0];this.paraSup=f[0][1];this.pSteps=c.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(f,u,s){c=this.evaluator;d=this.space;h=e(c.evalExpression(this.width));f.lineWidth=0<h?h:1E-6;f.lineCap="round";f.lineJoin="round";f.fillStyle=a.getColor(c,u);f.strokeStyle=a.getColor(c,s);g=c.getVariable(this.parameter);f.beginPath();c.setVariable(this.parameter,this.paraInf);j=c.evalExpression(this.expresion);this.exprX=this.abs_coord?e(j[0][0]):e(d.getAbsoluteX(j[0][0]));
this.exprY=this.abs_coord?e(j[0][1]):e(d.getAbsoluteY(j[0][1]));this.rotateExp&&(k=a.degToRad(this.evaluator.evalExpression(this.rotateExp)),m=Math.cos(k),n=Math.sin(k),q=this.exprX*m-this.exprY*n,l=this.exprX*n+this.exprY*m,this.exprX=q,this.exprY=l);f.moveTo(this.exprX+0.5,this.exprY+0.5);for(u=1;u<=this.pSteps;u++)c.setVariable(this.parameter,this.paraInf+u*this.paraSep),j=c.evalExpression(this.expresion),this.exprX=this.abs_coord?e(j[0][0]):e(d.getAbsoluteX(j[0][0])),this.exprY=this.abs_coord?
e(j[0][1]):e(d.getAbsoluteY(j[0][1])),this.rotateExp&&(q=this.exprX*m-this.exprY*n,l=this.exprX*n+this.exprY*m,this.exprX=q,this.exprY=l),f.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&f.fill();f.stroke();c.setVariable(this.parameter,g)};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,e){a.Graphic.call(this,c,e)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){var c=this.evaluator,e=c.evalExpression(this.expresion);this.exprX=e[0][0];this.exprY=e[0][1];if(this.rotateExp){var d=a.degToRad(c.evalExpression(this.rotateExp)),e=Math.cos(d),h=Math.sin(d),d=this.exprX*e-this.exprY*h,e=this.exprX*h+this.exprY*
e;this.exprX=d;this.exprY=e}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,f){var d=this.evaluator,h,g,j,k=Math.ceil(d.evalExpression(this.size)-0.4);c.fillStyle=a.getColor(d,f);c.beginPath();this.rangeInf>this.rangeMax&&(j=this.rangeInf,this.rangeInf=
this.rangeMax,this.rangeMax=j);for(var m=d.getVariable("n"),n=this.rangeInf,q=this.rangeMax;n<=q;n++)d.setVariable("n",n),j=d.evalExpression(this.expresion),this.exprX=j[0][0],this.exprY=j[0][1],this.abs_coord?h=j[0][1]:(h=this.space.getAbsoluteX(j[0][0]),g=this.space.getAbsoluteY(j[0][1])),c.moveTo(h,g),c.arc(h,g,k,0,e,!0);d.setVariable("n",m);c.fill();this.text!=[""]&&this.uber.drawText.call(this,c,this.text,h+k,g-k,this.color,this.font,"start","alphabetic",d.evalExpression(this.decimals),this.fixed)};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,c=Math.round;a.Point=function(c,e){a.Graphic.call(this,c,e)};a.extend(a.Point,a.Graphic);var f,d,h,g,j,k,m,n,q,l,p;a.Point.prototype.update=function(){f=this.evaluator;h=f.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1];this.rotateExp&&(g=a.degToRad(f.evalExpression(this.rotateExp)),j=Math.cos(g),k=Math.sin(g),m=this.exprX*j-this.exprY*k,n=this.exprX*k+this.exprY*j,this.exprX=m,this.exprY=
n)};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(h,g){f=this.evaluator;d=this.space;p=c(f.evalExpression(this.size));h.fillStyle=a.getColor(f,g);q=this.abs_coord?c(this.exprX):c(d.getAbsoluteX(this.exprX));l=this.abs_coord?c(this.exprY):c(d.getAbsoluteY(this.exprY));h.beginPath();h.arc(q,l,p,0,e,!0);h.fill();this.text!=[""]&&this.uber.drawText.call(this,
h,this.text,q+p,l-p,this.color,this.font,"start","alphabetic",f.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,e){a.Graphic.call(this,c,e);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,e=c.evalExpression(this.expresion);this.endPoints=[];for(var d=0,h=e.length;d<h;d++)this.endPoints[d]=
{x:e[d][0],y:e[d][1]};if(this.rotateExp)for(var d=a.degToRad(c.evalExpression(this.rotateExp)),c=Math.cos(d),e=Math.sin(d),g,j,d=0,h=this.endPoints.length;d<h;d++)g=this.endPoints[d].x*c-this.endPoints[d].y*e,j=this.endPoints[d].x*e+this.endPoints[d].y*c,this.endPoints[d].x=g,this.endPoints[d].y=j};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,f,d){var h=this.evaluator,g=h.evalExpression(this.width);0>=g&&(g=1E-6);c.lineWidth=g;g=h.evalExpression(this.size);c.fillStyle=a.getColor(h,f);c.strokeStyle=a.getColor(h,d);c.lineCap="round";f=10+c.lineWidth;d=0==c.lineWidth%2?0:0.5;var j,k,m,n;this.abs_coord?(j=this.endPoints[0].x,k=this.endPoints[0].y,m=this.endPoints[1].x,n=this.endPoints[1].y):(j=this.space.getAbsoluteX(this.endPoints[0].x),k=this.space.getAbsoluteY(this.endPoints[0].y),m=this.space.getAbsoluteX(this.endPoints[1].x),
n=this.space.getAbsoluteY(this.endPoints[1].y));g=h.evalExpression(this.size);0>g&&(g=0);c.beginPath();c.moveTo(j+d,k+d);c.lineTo(m+d,n+d);this.text!=[""]&&this.uber.drawText.call(this,c,this.text,(j+m)/2+f,(k+n)/2-f,this.color,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed);c.stroke();c.beginPath();c.arc(j,k,g,0,e,!0);c.arc(m,n,g,0,e,!0);c.fill()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,c=Math.round;a.Arrow=function(c,e){a.Graphic.call(this,
c,e);this.width=-1==this.width?this.evaluator.parser.parse("5"):this.width};a.extend(a.Arrow,a.Graphic);var f,d,h,g,j,k,m,n,q,l,p,u,s,t,r,v,x,z;a.Arrow.prototype.update=function(){f=this.evaluator;d=f.evalExpression(this.expresion);this.endPoints=[];for(var c=0,e=d.length;c<e;c++)this.endPoints[c]={x:d[c][0],y:d[c][1]};if(this.rotateExp){h=a.degToRad(f.evalExpression(this.rotateExp));g=Math.cos(h);j=Math.sin(h);c=0;for(e=this.endPoints.length;c<e;c++)k=this.endPoints[c].x*g-this.endPoints[c].y*j,
m=this.endPoints[c].x*j+this.endPoints[c].y*g,this.endPoints[c].x=k,this.endPoints[c].y=m}};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(d,h,g){f=this.evaluator;n=this.space;f.evalExpression(this.size);p=f.evalExpression(this.width);1>p&&(p=1);u=Math.ceil(p/2);s=n.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,
this.endPoints[1].y-this.endPoints[0].y);t=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);d.fillStyle=a.getColor(f,h);d.strokeStyle=a.getColor(f,g);d.lineWidth=2;this.abs_coord?(r=c(this.endPoints[0].x),v=c(this.endPoints[0].y),x=c(this.endPoints[1].x),z=c(this.endPoints[1].y)):(r=c(n.getAbsoluteX(this.endPoints[0].x)),v=c(n.getAbsoluteY(this.endPoints[0].y)),x=c(n.getAbsoluteX(this.endPoints[1].x)),z=c(n.getAbsoluteY(this.endPoints[1].y)));h=f.evalExpression(this.spear);
0>h&&(h=0);d.save();d.translate(r,v,t);this.abs_coord?0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?d.rotate(this.angle):d.rotate(-this.angle):(t*=s,0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?d.rotate(-this.angle):d.rotate(this.angle));d.beginPath();d.moveTo(-u,e(-u));d.lineTo(e(t-h-p),e(-u));d.lineTo(e(t-2*h),e(-h-u));d.lineTo(e(t),0);d.lineTo(e(t-2*h),e(h+u));d.lineTo(e(t-h-p),e(u));d.lineTo(-u,e(u));d.closePath();d.stroke();d.fill();d.restore();this.text!=[""]&&
(q=(r+x)/2,l=(v+z)/2,this.uber.drawText.call(this,d,this.text,q,l,g,this.font,"start","alphabetic",f.evalExpression(this.decimals),this.fixed))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Polygon=function(c,e){a.Graphic.call(this,c,e);this.width=-1==this.width?this.evaluator.parser.parse("1"):this.width;this.endPoints=[]};a.extend(a.Polygon,a.Graphic);var c,f,d,h,g,j,k,m,n,q,l;a.Polygon.prototype.update=function(){c=this.evaluator;d=c.evalExpression(this.expresion);
for(var e=0,f=d.length;e<f;e++)this.endPoints[e]={x:d[e][0],y:d[e][1]};if(this.rotateExp){h=a.degToRad(c.evalExpression(this.rotateExp));g=Math.cos(h);j=Math.sin(h);e=0;for(f=this.endPoints.length;e<f;e++)k=this.endPoints[e].x*g-this.endPoints[e].y*j,m=this.endPoints[e].x*j+this.endPoints[e].y*g,this.endPoints[e].x=k,this.endPoints[e].y=m}};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(d,h,g){c=this.evaluator;f=this.space;n=e(c.evalExpression(this.width));d.lineWidth=0<n?n:1E-6;d.fillStyle=a.getColor(c,h);d.strokeStyle=a.getColor(c,g);d.lineCap="round";d.lineJoin="round";q=this.abs_coord?e(this.endPoints[0].x):e(f.getAbsoluteX(this.endPoints[0].x));l=this.abs_coord?e(this.endPoints[0].y):e(f.getAbsoluteY(this.endPoints[0].y));d.beginPath();d.moveTo(q+0.5,l+0.5);h=1;for(g=this.endPoints.length;h<g;h++)q=this.abs_coord?e(this.endPoints[h].x):
e(f.getAbsoluteX(this.endPoints[h].x)),l=this.abs_coord?e(this.endPoints[h].y):e(f.getAbsoluteY(this.endPoints[h].y)),d.lineTo(q+0.5,l+0.5);this.fill&&d.fill();d.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Arc=function(c,e){a.Graphic.call(this,c,e);this.width=-1==this.width?this.evaluator.parser.parse("1"):this.width};a.extend(a.Arc,a.Graphic);var c,f,d,h,g,j,k,m,n,q,l,p,u,s,t,r,v,x,z,w,y,C;a.Arc.prototype.update=function(){c=this.evaluator;
f=c.evalExpression(this.center);this.exprX=f[0][0];this.exprY=f[0][1];this.rotateExp&&(d=a.degToRad(c.evalExpression(this.rotateExp)),h=Math.cos(d),g=Math.sin(d),j=this.exprX*h-this.exprY*g,k=this.exprX*g+this.exprY*h,this.exprX=j,this.exprY=k);m=c.evalExpression(this.init);n=c.evalExpression(this.end);"(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,q=m[0][0],l=m[0][1],p=n[0][0],u=n[0][1],s=Math.acos((1*q+0*l)/Math.sqrt(q*q+l*l)),t=Math.acos((1*p+0*u)/Math.sqrt(p*p+u*u)),0<q&&(0<l&&!this.abs_coord)&&(s=2*Math.PI-s),0<q&&(0>l&&this.abs_coord)&&(s=2*Math.PI-s),0>q&&(0>l&&this.abs_coord)&&(s=2*Math.PI-s),0>q&&(0<l&&!this.abs_coord)&&(s=2*Math.PI-s),0<p&&(0<u&&!this.abs_coord)&&(t=2*Math.PI-t),0<p&&(0>u&&this.abs_coord)&&(t=2*Math.PI-t),0>p&&(0>u&&this.abs_coord)&&(t=2*Math.PI-t),0>p&&(0<u&&!this.abs_coord)&&(t=2*Math.PI-t),r=Math.min(s,
t),v=Math.max(s,t),s=r,t=v,t-s>Math.PI&&this.abs_coord&&(s=v,t=r),t-s<=Math.PI&&!this.abs_coord&&(s=v,t=r),this.iniAng=s,this.endAng=t):(this.vectors=!1,this.iniAng=a.degToRad(m),this.endAng=a.degToRad(n))};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(d,f,h){c=this.evaluator;x=this.space;z=this.abs_coord?e(this.exprX):e(x.getAbsoluteX(this.exprX));
w=this.abs_coord?e(this.exprY):e(x.getAbsoluteY(this.exprY));y=c.evalExpression(this.radius);!this.vectors&&this.iniAng>this.endAng&&(C=this.iniAng,this.iniAng=this.endAng,this.endAng=C);0>y&&(y=0);var g=!1;this.abs_coord||(y*=x.scale,this.vectors||(this.iniAng=-this.iniAng,this.endAng=-this.endAng,g=!0));this.vectors&&(g=this.abs_coord?!1:!0);var n=e(c.evalExpression(this.width));d.lineWidth=0<n?n:1E-6;d.lineCap="round";d.fillStyle=a.getColor(c,f);d.strokeStyle=a.getColor(c,h);this.fill&&(d.beginPath(),
d.moveTo(z,w),d.arc(z,w,y,this.iniAng,this.endAng,g),d.fill());d.beginPath();d.arc(z,w,y,this.iniAng,this.endAng,g);d.stroke();this.text!=[""]&&this.uber.drawText.call(this,d,this.text,z+1,w-1,this.color,this.font,"start","alphabetic",c.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(c,e){a.Graphic.call(this,c,e);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);var e,c,f,d,h,g,j,k,m,n,q,l,p,u,s,t,r,v,x;a.Text.prototype.update=function(){e=this.evaluator;
c=e.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(f=a.degToRad(e.evalExpression(this.rotateExp)),d=Math.cos(f),h=Math.sin(f),g=this.exprX*d-this.exprY*h,j=this.exprX*h+this.exprY*d,this.exprX=g,this.exprY=j)};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){k="rtfNode"===this.text.type?this.text:this.splitText(this.text.toString(this.evaluator.evalExpression(this.decimals),
this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,a,k,parseFloat(this.exprX)+5,parseFloat(this.exprY),c,this.font,this.align,"hanging")};a.Text.prototype.splitText=function(a){m=this.evaluator.evalExpression(this.width);k=[];this.ctx.font=this.font;this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?this.fontSize[1]:"10";if(20<=m&&"undefined"!=a.type){for(var c=0,e=a.length;c<e;c++)n=a[c],q=this.ctx.measureText(n).width,q>m?k=k.concat(this.splitWords(n,m)):k.push(n);l=Math.floor(1.2*
this.fontSize)*k.length;this.evaluator.setVariable("_Text_H_",l);return k}this.evaluator.setVariable("_Text_H_",0);this.evaluator.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=function(a,c){p=a;u=[];x=!1;do r=Math.floor(p.length*(c/this.ctx.measureText(p).width))+1,s=p.slice(0,r),""!=s&&" "==s[0]&&(p=p.slice(1),s=p.slice(0,r)),x=p[r-1]&&p[r]&&" "!=p[r-1]&&" "!=p[r],v=s.lastIndexOf(" "),t=this.ctx.measureText(s).width,t>=c?(r=-1!=v?v:r-1,s=p.slice(0,r)):x&&-1!=v&&(r=v,s=p.slice(0,
r)),u.push(s),p=p.slice(r);while(""!=p);return u};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Image=function(c,e){a.Graphic.call(this,c,e);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);var c,f,d,h,g,j,k,m,n,q,l,p,u,s;a.Image.prototype.update=function(){c=this.evaluator;f=c.evalExpression(this.expresion);this.exprX=f[0][0];this.exprY=f[0][1];this.rotateExp&&(d=a.degToRad(c.evalExpression(this.rotateExp)),h=Math.cos(d),
g=Math.sin(d),j=this.exprX*h-this.exprY*g,k=this.exprX*g+this.exprY*h,this.exprX=j,this.exprY=k);4==f[0].length&&(this.centered=!0,this.scaleX=f[0][2],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=f[0][3],0==this.scaleY&&(this.scaleY=1E-5));f[1]&&2==f[1].length&&(this.centered=!0,this.scaleX=f[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=f[1][1],0==this.scaleY&&(this.scaleY=1E-5));if((m=c.evalExpression(this.file))||""==m)this.img=this.parent.getImage(m)};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(d){c=this.evaluator;n=this.space;this.img&&(this.img.ready&&this.img.complete)&&(q=this.centered?0:this.img.width/2,l=this.centered?0:this.img.height/2,p=this.abs_coord?e(this.exprX):e(n.getAbsoluteX(this.exprX)),u=this.abs_coord?e(this.exprY):e(n.getAbsoluteY(this.exprY)),s=a.degToRad(-c.evalExpression(this.inirot)),d.translate(p+q,u+l),d.rotate(s),d.scale(this.scaleX,this.scaleY),this.opacity&&
(d.globalAlpha=c.evalExpression(this.opacity)),d.drawImage(this.img,-this.img.width/2,-this.img.height/2),d.setTransform(1,0,0,1,0,0),d.globalAlpha=1)};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.Macro=function(e,c){a.Graphic.call(this,e,c);this.graphics=[];var f=e.lessonParser,d=new a.Tokenizer,h;for(h in c)c.hasOwnProperty(h)&&(this[h]=c[h]);if(void 0!=this.expresion){this.expresion.match("'")||(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);h=this.expresion.value;var g,j=2;h&&((g=document.getElementById(h))&&"descartes/macro"==
g.type?(g=g.text,j=3):(g=a.openExternalFile(h),g.match("tipo_de_macro")||(g=null)));var k="|";if(g){g=g.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(j);var m,n;h=0;for(j=g.length;h<j;h++)g[h]&&(g[h]=f.split(g[h]),g[h]&&(g[h][0]&&g[h][0][0]&&"id"==g[h][0][0])&&(m=g[h][0][1],n=m.indexOf("("),-1!=n&&(m=m.substring(0,n)),k+=m+"|"));var q,l,p,u;h=0;for(j=g.length;h<j;h++){q=g[h]||[];m=0;for(n=q.length;m<n;m++)if(l=babel[q[m][0]],p=q[m][0].indexOf("."),-1!=p&&(l=babel[q[m][0].substring(p+1)]),!("id"!=l&&"text"!=l&&"expresion"!=l&&"interval"!=l&&"steps"!=l&&"drawif"!=l&&"size"!=l&&"width"!=l&&"center"!=l&&
"radius"!=l&&"init"!=l&&"end"!=l&&"inirot"!=l&&"do"!=l&&"while"!=l&&"file"!=l&&"fill"!=l&&"color"!=l))if("text"==l)if(q[m][1].match(/\{\\rtf1/)){l=q[m][1];var s=this;u=function(a,c){for(var e=d.tokenize(c.replace(/\&squot;/g,"'")),f=0,h=e.length;f<h;f++)if("identifier"==e[f].type&&k.match("\\|"+e[f].value+"\\|"))e[f].value=s.name+"."+e[f].value;else if("identifier"==e[f].type&&-1!=(p=e[f].value.indexOf("."))&&k.match("\\|"+e[f].value.substring(0,p)+"\\|"))e[f].value=s.name+"."+e[f].value;return(a.match(/^\\expr/)?
"\\expr ":"\\decimals ")+d.flatTokens(e)};l=l.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,u);l=l.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,u);q[m][1]=l}else{u=f.parseText(q[m][1]).textElementsMacros;for(var t=0,r=u.length;t<r;t++){l=d.tokenize(u[t].replace(/\&squot;/g,"'"));for(var v=0,x=l.length;v<x;v++)"identifier"==l[v].type&&k.match("\\|"+l[v].value+"\\|")&&(l[v].value=this.name+"."+l[v].value);l=d.flatTokens(l).replace(/&squot;/g,"'").replace(/'\+\(/g,
"[").replace(/\)\+'/g,"]");u[t]=l.substring(1,l.length-1)}q[m][1]=u.join("")}else{l=d.tokenize(q[m][1].replace(/\&squot;/g,"'"));u=0;for(t=l.length;u<t;u++)if("identifier"==l[u].type&&k.match("\\|"+l[u].value+"\\|"))l[u].value=this.name+"."+l[u].value;else if("identifier"==l[u].type&&-1!=(p=l[u].value.indexOf("."))&&k.match("\\|"+l[u].value.substring(0,p)+"\\|"))l[u].value=this.name+"."+l[u].value;q[m][1]=d.flatTokens(l)}}h=0;for(j=g.length;h<j;h++)if(g[h][0]){q="";m=0;for(n=g[h].length;m<n;m++)g[h][m]=
"type"!=babel[g[h][m][0]]?g[h][m][0]+"='"+g[h][m][1]+"' ":"espacio='"+this.spaceID+"' "+g[h][m][0]+"='"+g[h][m][1]+"' ",q+=g[h][m];g[h]=q;q.match(/^espacio/)?this.graphics.push(f.parseGraphic(g[h],this.abs_coord,this.background,this.inirot)):f.parseAuxiliar(g[h])}}}};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,f=this.graphics.length;c<
f;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;a.RenderMath={};a.RenderMath.inverseSqrt=function(){return 1/Math.sqrt(number)};a.Vector2D=function(a,c){this.x=a||0;this.y=c||0};a.Vector2D.prototype.clone=function(){return new a.Vector2D(this.x,this.y)};a.Vector2D.prototype.add=
function(e){return new a.Vector2D(this.x+e.x,this.y+e.y)};a.Vector2D.prototype.substract=function(e){return new a.Vector2D(this.x-e.x,this.y-e.y)};a.Vector2D.prototype.multiply=function(e){return new a.Vector2D(this.x*e.x,this.y*e.y)};a.Vector2D.prototype.divide=function(e){return new a.Vector2D(this.x/e.x,this.y/e.y)};a.Vector2D.prototype.scale=function(e){return new a.Vector2D(this.x*e,this.y*e)};a.Vector2D.prototype.dist=function(a){var c=a.x-this.x;a=a.y-this.y;return Math.sqrt(c*c+a*a)};a.Vector2D.prototype.negate=
function(){return new a.Vector2D(-this.x,-this.y)};a.Vector2D.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.Vector2D.prototype.squaredLength=function(){return this.x*this.x+this.y*this.y};a.Vector2D.prototype.normalize=function(){var e=this.squaredLength();return 0<e?(e=Math.sqrt(e),new a.Vector2D(this.x/e,this.y/e)):new a.Vector2D(0,0)};a.Vector2D.prototype.crossProduct=function(a){return this.x*a.y-this.y*a.x};a.Vector2D.prototype.dot=function(a){return this.x*a.x+
this.y*a.y};a.Vector2D.prototype.direction=function(e){var c=this.x-e.x;e=this.y-e.y;var f=c*c+e*e;if(!f)return new a.Vector2D(0,0);f=1/Math.sqrt(f);return new a.Vector2D(c*f,e*f)};a.Vector2D.prototype.lerp=function(e,c){return new a.Vector2D(this.x+c*(e.x-this.x),this.y+c*(e.y-this.y))};a.Vector3D=function(a,c,f){this.x=a||0;this.y=c||0;this.z=f||0};a.Vector3D.prototype.set=function(a,c,f){this.x=a;this.y=c;this.z=f;return this};a.Vector3D.prototype.toVector4D=function(){return new a.Vector4D(this.x,
this.y,this.z,1)};a.Vector3D.prototype.copy=function(){return new a.Vector3D(this.x,this.y,this.z)};a.Vector3D.prototype.add=function(e){return new a.Vector3D(this.x+e.x,this.y+e.y,this.z+e.z)};a.Vector3D.prototype.substract=function(e){return new a.Vector3D(this.x-e.x,this.y-e.y,this.z-e.z)};a.Vector3D.prototype.multiply=function(e){return new a.Vector3D(this.x*e.x,this.y*e.y,this.z*e.z)};a.Vector3D.prototype.negate=function(){return new a.Vector3D(-this.x,-this.y,-this.z)};a.Vector3D.prototype.scale=
function(e){return new a.Vector3D(this.x*e,this.y*e,this.z*e)};a.Vector3D.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)};a.Vector3D.prototype.squaredLength=function(){return this.x*this.x+this.y*this.y+this.z*this.z};a.Vector3D.prototype.normalize=function(){var e=this.length();if(0==e)return new a.Vector3D(0,0,0);if(1==e)return new a.Vector3D(this.x,this.y,this.z);e=1/e;return new a.Vector3D(this.x*e,this.y*e,this.z*e)};a.Vector3D.prototype.crossProduct=
function(e){return new a.Vector3D(this.y*e.z-this.z*e.y,this.z*e.x-this.x*e.z,this.x*e.y-this.y*e.x)};a.Vector3D.prototype.dotProduct=function(e){return new a.Vector3D(this.x*e.x+this.y*e.y+this.z*e.z)};a.Vector3D.prototype.direction=function(e){var c=this.x-e.x,f=this.y-e.y;e=this.z-e.z;var d=Math.sqrt(c*c+f*f+e*e);if(0==d)return new a.Vector3D(0,0,0);d=1/d;return new a.Vector3D(c*d,f*d,e*d)};a.Vector3D.prototype.lerp=function(e,c){return new a.Vector3D(this.x+c*(e.x-this.x),this.y+c*(e.y-this.y),
this.z+c*(e.z-this.z))};a.Vector3D.prototype.distance=function(a){var c=a.x-this.x,f=a.y-this.y;a=a.z-this.z;return Math.sqrt(c*c+f*f+a*a)};a.Vector3D.prototype.unproject=function(e,c,f){var d=new a.Vector4D(2*(this.x-f.x)/f.width-1,2*(this.y-f.y)/f.height-1,2*this.z-1,d[3]=1);e=c.multiply(e);if(!e.inverse())return null;d=e.multiplyVector4(d);return 0==d.w?null:new a.Vector3D(d.x/d.w,d.y/d.w,d.z/d.w)};a.Vector3D.prototype.rotationTo=function(e){var c=new a.Vector3D(1,0,0),f=new a.Vector3D(0,1,0),
d=new a.Vector3D(0,0,1),h=this.dotProduct(e),g=new a.Quaternion;1<=h?g.setIdentity():-0.999999>h?(axis=c.crossProduct(this),1E-6>axis.length()&&(axis=f.crossProduct(this)),1E-6>axis.length()&&(axis=d.crossProduct(this)),axis=axis.normalize(),g=Quaternion.fromAngleAxis(Math.PI,axis)):(c=Math.squrt(2*(1+h)),f=1/c,axis=this.crossProduct(e),g.x=axis.x*f,g.y=axis.y*f,g.z=axis.z*f,g.w=0.5*c,g=Quaternion.normalize());1<g.w?g.w=1:-1>g.w&&(g.w=-1);return g};a.Vector4D=function(a,c,f,d){this.x=a||0;this.y=
c||0;this.z=f||0;this.w=d||0};a.Vector4D.prototype.set=function(a,c,f,d){this.x=a;this.y=c;this.z=f;this.w=d;return this};a.Vector4D.prototype.toVector3D=function(){var e=0!==this.w?1/this.w:0;return new a.Vector3D(this.x*e,this.y*e,this.z*e)};a.Vector4D.prototype.clone=function(){return new a.Vector4D(this.x,this.y,this.z,this.w)};a.Vector4D.prototype.add=function(e){return new a.Vector4D(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)};a.Vector4D.prototype.substract=function(e){return new a.Vector4D(this.x-
e.x,this.y-e.y,this.z-e.z,this.w-e.w)};a.Vector4D.prototype.multiply=function(e){return new a.Vector4D(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)};a.Vector4D.prototype.divide=function(e){return new a.Vector4D(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)};a.Vector4D.prototype.scale=function(e){return new a.Vector4D(this.x*e,this.y*e,this.z*e,this.w*e)};a.Vector4D.prototype.negate=function(){return new a.Vector4D(-this.x,-this.y,-this.z,-this.w)};a.Vector4D.prototype.length=function(){return Math.sqrt(this.x*
this.x+this.y*this.y+this.z*this.z+this.w*this.w)};a.Vector4D.prototype.squaredLength=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w};a.Vector4D.prototype.lerp=function(e,c){return new a.Vector4D(this.x+c*(e.x-this.x),this.y+c*(e.y-this.y),this.z+c*(e.z-this.z),this.w+c*(e.w-this.w))};a.Matrix2x2=function(a,c,f,d){this.a00=a||0;this.a01=c||0;this.a10=f||0;this.a11=d||0};a.Matrix2x2.prototype.clone=function(){return new a.Matrix2x2(this.a00,this.a01,this.a10,this.a11)};a.Matrix2x2.prototype.setIdentity=
function(){this.a00=1;this.a10=this.a01=0;this.a11=1;return this};a.Matrix2x2.prototype.transpose=function(){return new a.Matrix2x2(this.a00,this.a10,this.a01,this.a11)};a.Matrix2x2.prototype.determinant=function(){return this.a00*this.a11-this.a10*this.a01};a.Matrix2x2.prototype.inverse=function(){var e=this.determinant();if(!e)return null;e=1/e;return new a.Matrix2x2(this.a11*e,-this.a10*e,-this.a01*e,this.a00*e)};a.Matrix2x2.prototype.multiply=function(e){return new a.Matrix2x2(this.a00*e.a00+
this.a01*e.a10,this.a00*e.a01+this.a01*e.a11,this.a10*e.a00+this.a11*e.a10,this.a10*e.a01+this.a11*e.a11)};a.Matrix2x2.prototype.rotate=function(e){var c=Math.sin(e);e=Math.cos(e);return new a.Matrix2x2(this.a00*e+this.a01*c,this.a00*-c+this.a01*e,this.a10*e+this.a11*c,this.a10*-c+this.a11*e)};a.Matrix2x2.prototype.multiplyVector2=function(e){return new a.Vector2D(e.x*this.a00+e.y*this.a01,e.x*this.a10+e.y*this.a11)};a.Matrix2x2.prototype.scale=function(e){return new a.Matrix2x2(this.a00*e.x,this.a01*
e.y,this.a10*e.x,this.a11*e.y)};a.Matrix3x3=function(a,c,f,d,h,g,j,k,m){this.a00=a||0;this.a01=c||0;this.a02=f||0;this.a10=d||0;this.a11=h||0;this.a12=g||0;this.a20=j||0;this.a21=k||0;this.a22=m||0};a.Matrix3x3.prototype.copy=function(){return new a.Matrix3x3(this.a00,this.a01,this.a02,this.a10,this.a11,this.a12,this.a20,this.a21,this.a22)};a.Matrix3x3.prototype.determinant=function(){var a=this.a10,c=this.a11,f=this.a12,d=this.a20,h=this.a21,g=this.a22;return this.a00*(g*c-f*h)+this.a01*(-g*a+f*
d)+this.a02*(h*a-c*d)};a.Matrix3x3.prototype.inverse=function(){var e=this.a00,c=this.a01,f=this.a02,d=this.a10,h=this.a11,g=this.a12,j=this.a20,k=this.a21,m=this.a22,n=m*h-g*k,q=-m*d+g*j,l=k*d-h*j,p=e*n+c*q+f*l;if(!p)return null;p=1/p;return new a.Matrix3x3(n*p,(-m*c+f*k)*p,(g*c-f*h)*p,q*p,(m*e-f*j)*p,(-g*e+f*d)*p,l*p,(-k*e+c*j)*p,(h*e-c*d)*p)};a.Matrix3x3.prototype.multply=function(e){var c=this.a00,f=this.a01,d=this.a02,h=this.a10,g=this.a11,j=this.a12,k=this.a20,m=this.a21,n=this.a22,q=e.a00,
l=e.a01,p=e.a02,u=e.a10,s=e.a11,t=e.a12,r=e.a20,v=e.a21;e=e.a22;return new a.Matrix3x3(q*c+l*h+p*k,q*f+l*g+p*m,q*d+l*j+p*n,u*c+s*h+t*k,u*f+s*g+t*m,u*d+s*j+t*n,r*c+v*h+e*k,r*f+v*g+e*m,r*d+v*j+e*n)};a.Matrix3x3.prototype.multiplyVector2=function(e){return new a.Vector2D(e.x*this.a00+e.y*this.a10+this.a20,e.x*this.a01+e.y*this.a11+this.a21)};a.Matrix3x3.prototype.multiplyVector3=function(e){return new a.Vector3D(e.x*this.a00+e.y*this.a10+e.z*this.a20,e.x*this.a01+e.y*this.a11+e.z*this.a21,e.x*this.a02+
e.y*this.a12+e.z*this.a22)};a.Matrix3x3.prototype.setIdentity=function(){this.a00=1;this.a10=this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a12=0;this.a22=1;return this};a.Matrix3x3.prototype.transpose=function(){return new a.Matrix3x3(this.a00,this.a10,this.a20,this.a01,this.a11,this.a21,this.a02,this.a12,this.a22)};a.Matrix3x3.prototype.toMatrix4x4=function(){return new a.Matrix4x4(this.a00,this.a01,this.a02,0,this.a10,this.a11,this.a12,0,this.a20,this.a21,this.a22,0,0,0,0,1)};a.Matrix4x4=
function(a,c,f,d,h,g,j,k,m,n,q,l,p,u,s,t){this.a00=a||0;this.a01=c||0;this.a02=f||0;this.a03=d||0;this.a10=h||0;this.a11=g||0;this.a12=j||0;this.a13=k||0;this.a20=m||0;this.a21=n||0;this.a22=q||0;this.a23=l||0;this.a30=p||0;this.a31=u||0;this.a32=s||0;this.a33=t||0};a.Matrix4x4.prototype.copy=function(){return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.setIdentity=
function(){this.a00=1;this.a10=this.a03=this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a13=this.a12=0;this.a22=1;this.a32=this.a31=this.a30=this.a23=0;this.a33=1;return this};a.Matrix4x4.prototype.transpose=function(){return new a.Matrix3x3(this.a00,this.a10,this.a20,this.a30,this.a01,this.a11,this.a21,this.a31,this.a02,this.a12,this.a22,this.a32,this.a03,this.a13,this.a23,this.a33)};a.Matrix4x4.prototype.determinant=function(){var a=this.a00,c=this.a01,f=this.a02,d=this.a03,h=this.a10,g=this.a11,
j=this.a12,k=this.a13,m=this.a20,n=this.a21,q=this.a22,l=this.a23,p=this.a30,u=this.a31,s=this.a32,t=this.a33;return p*n*j*d-m*u*j*d-p*g*q*d+h*u*q*d+m*g*s*d-h*n*s*d-p*n*f*k+m*u*f*k+p*c*q*k-a*u*q*k-m*c*s*k+a*n*s*k+p*g*f*l-h*u*f*l-p*c*j*l+a*u*j*l+h*c*s*l-a*g*s*l-m*g*f*t+h*n*f*t+m*c*j*t-a*n*j*t-h*c*q*t+a*g*q*t};a.Matrix4x4.prototype.inverse=function(){var e=this.a00,c=this.a01,f=this.a02,d=this.a03,h=this.a10,g=this.a11,j=this.a12,k=this.a13,m=this.a20,n=this.a21,q=this.a22,l=this.a23,p=this.a30,u=this.a31,
s=this.a32,t=this.a33,r=e*g-c*h,v=e*j-f*h,x=e*k-d*h,z=c*j-f*g,w=c*k-d*g,y=f*k-d*j,C=m*u-n*p,B=m*s-q*p,D=m*t-l*p,E=n*s-q*u,A=n*t-l*u,G=q*t-l*s,F=r*G-v*A+x*E+z*D-w*B+y*C;if(!F)return null;F=1/F;return new a.Matrix4x4((g*G-j*A+k*E)*F,(-c*G+f*A-d*E)*F,(u*y-s*w+t*z)*F,(-n*y+q*w-l*z)*F,(-h*G+j*D-k*B)*F,(e*G-f*D+d*B)*F,(-p*y+s*x-t*v)*F,(m*y-q*x+l*v)*F,(h*A-g*D+k*C)*F,(-e*A+c*D-d*C)*F,(p*w-u*x+t*r)*F,(-m*w+n*x-l*r)*F,(-h*E+g*B-j*C)*F,(e*E-c*B+f*C)*F,(-p*z+u*v-s*r)*F,(m*z-n*v+q*r)*F)};a.Matrix4x4.prototype.toRotationMat=
function(){return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,0,0,0,1)};a.Matrix4x4.prototype.toMatrix3x3=function(){return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a10,this.a11,this.a12,this.a20,this.a21,this.a22)};a.Matrix4x4.prototype.toInverseMat3=function(){var e=this.a00,c=this.a01,f=this.a02,d=this.a10,h=this.a11,g=this.a12,j=this.a20,k=this.a21,m=this.a22,n=m*h-g*k,q=-m*d+g*j,l=k*d-h*j;return!(e*n+c*q+f*
l)?null:new a.Matrix3x3(n*id,(-m*c+f*k)*id,(g*c-f*h)*id,q*id,(m*e-f*j)*id,(-g*e+f*d)*id,l*id,(-k*e+c*j)*id,(h*e-c*d)*id)};a.Matrix4x4.prototype.multiply=function(e){var c=this.a00,f=this.a01,d=this.a02,h=this.a03,g=this.a10,j=this.a11,k=this.a12,m=this.a13,n=this.a20,q=this.a21,l=this.a22,p=this.a23,u=this.a30,s=this.a31,t=this.a32,r=this.a33,v=e.a00,x=e.a01,z=e.a02,w=e.a03,y=e.a10,C=e.a11,B=e.a12,D=e.a13,E=e.a20,A=e.a21,G=e.a22,F=e.a23,H=e.a30,I=e.a31,J=e.a32;e=e.a33;return new a.Matrix4x4(v*c+x*
g+z*n+w*u,v*f+x*j+z*q+w*s,v*d+x*k+z*l+w*t,v*h+x*m+z*p+w*r,y*c+C*g+B*n+D*u,y*f+C*j+B*q+D*s,y*d+C*k+B*l+D*t,y*h+C*m+B*p+D*r,E*c+A*g+G*n+F*u,E*f+A*j+G*q+F*s,E*d+A*k+G*l+F*t,E*h+A*m+G*p+F*r,H*c+I*g+J*n+e*u,H*f+I*j+J*q+e*s,H*d+I*k+J*l+e*t,H*h+I*m+J*p+e*r)};a.Matrix4x4.prototype.multiplyVector3=function(e){return new a.Vector3D(e.x*this.a00+e.y*this.a10+e.z*this.a20+this.a30,e.x*this.a01+e.y*this.a11+e.z*this.a21+this.a31,e.x*this.a02+e.y*this.a12+e.z*this.a22+this.a32)};a.Matrix4x4.prototype.multiplyVector4=
function(e){return new a.Vector4D(e.x*this.a00+e.y*this.a10+e.z*this.a20+e.w*this.a30,e.x*this.a01+e.y*this.a11+e.z*this.a21+e.w*this.a31,e.x*this.a02+e.y*this.a12+e.z*this.a22+e.w*this.a32,e.x*this.a03+e.y*this.a13+e.z*this.a23+e.w*this.a33)};a.Matrix4x4.prototype.translate=function(e){return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a00*e.x+this.a10*e.y+this.a20*e.z+this.a30,this.a01*e.x+this.a11*e.y+this.a21*
e.z+this.a31,this.a02*e.x+this.a12*e.y+this.a22*e.z+this.a32,this.a03*e.x+this.a13*e.y+this.a23*e.z+this.a33)};a.Matrix4x4.prototype.scale=function(e){return new a.Matrix4x4(this.a00*e.x,this.a01*e.x,this.a02*e.x,this.a03*e.x,this.a10*e.y,this.a11*e.y,this.a12*e.y,this.a13*e.y,this.a20*e.z,this.a21*e.z,this.a22*e.z,this.a23*e.z,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotate=function(e,c){var f=Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z);if(!f)return null;1!==f&&(f=1/f,c.x*=f,c.y*=f,c.z*=
f);var d=Math.sin(e),h=Math.cos(e),g=1-h,f=this.a00,j=this.a01,k=this.a02,m=this.a03,n=this.a10,q=this.a11,l=this.a12,p=this.a13,u=this.a20,s=this.a21,t=this.a22,r=this.a23,v=c.x*c.x*g+h,x=c.y*c.x*g+c.z*d,z=c.z*c.x*g-c.y*d,w=c.x*c.y*g-c.z*d,y=c.y*c.y*g+h,C=c.z*c.y*g+c.x*d,B=c.x*c.z*g+c.y*d,d=c.y*c.z*g-c.x*d,h=c.z*c.z*g+h;return new a.Matrix4x4(f*v+n*x+u*z,j*v+q*x+s*z,k*v+l*x+t*z,m*v+p*x+r*z,f*w+n*y+u*C,j*w+q*y+s*C,k*w+l*y+t*C,m*w+p*y+r*C,f*B+n*d+u*h,j*B+q*d+s*h,k*B+l*d+t*h,m*B+p*d+r*h,this.a30,this.a31,
this.a32,this.a33)};a.Matrix4x4.prototype.rotateX=function(e){var c=Math.sin(e);e=Math.cos(e);var f=this.a10,d=this.a11,h=this.a12,g=this.a13,j=this.a20,k=this.a21,m=this.a22,n=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,f*e+j*c,d*e+k*c,h*e+m*c,g*e+n*c,f*-c+j*e,d*-c+k*e,h*-c+m*e,g*-c+n*e,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(e){var c=Math.sin(e);e=Math.cos(e);var f=this.a00,d=this.a01,h=this.a02,g=this.a03,j=this.a20,k=this.a21,m=this.a22,
n=this.a23;return new a.Matrix4x4(f*e+j*-c,d*e+k*-c,h*e+m*-c,g*e+n*-c,this.a10,this.a11,this.a12,this.a13,f*c+j*e,d*c+k*e,h*c+m*e,g*c+n*e,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(e){var c=Math.sin(e);e=Math.cos(e);var f=this.a00,d=this.a01,h=this.a02,g=this.a03,j=this.a10,k=this.a11,m=this.a12,n=this.a13;return new a.Matrix4x4(f*e+j*c,d*e+k*c,h*e+m*c,g*e+n*c,f*-c+j*e,d*-c+k*e,h*-c+m*e,g*-c+n*e,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33)};
a.Matrix4x4.prototype.frustum=function(e,c,f,d,h,g){var j=c-e,k=d-f,m=g-h;return new a.Matrix4x4(2*h/j,0,0,0,0,2*h/k,0,0,(c+e)/j,(d+f)/k,-(g+h)/m,-1,0,0,-(2*g*h)/m,0)};a.Matrix4x4.prototype.perspective=function(a,c,f,d){a=f*Math.tan(a*Math.PI/360);c*=a;return this.frustum(-c,c,-a,a,f,d)};a.Matrix4x4.prototype.ortho=function(e,c,f,d,h,g){var j=c-e,k=d-f,m=g-h;return new a.Matrix4x4(2/j,0,0,0,0,2/k,0,0,0,0,-2/m,0,-(e+c)/j,-(d+f)/k,-(g+h)/m,1)};a.Matrix4x4.prototype.lookAt=function(e,c,f){if(e.x===c.x&&
e.y===c.y&&e.z===c.z)return(new a.Matrix4x4).setIdentity();var d=e.x-c.x,h=e.y-c.y;c=e.z-c.z;var g=1/Math.sqrt(d*d+h*h+c*c),d=d*g,h=h*g;c*=g;var j=f.y*c-f.z*h,k=f.z*d-f.x*c;f=f.x*h-f.y*d;(g=Math.sqrt(j*j+k*k+f*f))?(g=1/g,j*=g,k*=g,f*=g):f=k=j=0;var m=h*f-c*k,n=c*j-d*f,q=d*k-h*j;(g=Math.sqrt(m*m+n*n+q*q))?(g=1/g,m*=g,n*=g,q*=g):q=n=m=0;return new a.Matrix4x4(j,m,d,0,k,n,h,0,f,q,c,0,-(j*e.x+k*e.y+f*e.z),-(m*e.x+n*e.y+q*e.z),-(d*e.x+h*e.y+c*e.z),1)};a.Matrix4x4.prototype.fromRotationTranslation=function(e){var c=
2*this.x,f=2*this.y,d=2*this.z,h=this.x*c,g=this.x*f,j=this.x*d,k=this.y*f,m=this.y*d,n=this.z*d,c=this.w*c,f=this.w*f,d=this.w*d;return new a.Matrix4x4(1-(k+n),g+d,j-f,0,g-d,1-(h+n),m+c,0,j+f,m-c,1-(h+k),0,e.x,e.y,e.z,1)};a.Quaternion=function(a,c,f,d){this.x=a||0;this.y=c||0;this.z=f||0;this.w=d||0};a.Quaternion.prototype.clone=function(){return new a.Quaternion(this.x,this.y,this.z,this.w)};a.Quaternion.prototype.setIdentity=function(){this.z=this.y=this.x=0;this.w=1;return this};a.Quaternion.prototype.calculateW=
function(){return new a.Quaternion(this.x,this.y,this.z,-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z)))};a.Quaternion.prototype.dot=function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w};a.Quaternion.prototype.inverse=function(){var e=this.dot(this),c=0;0!=e&&(c=1/e);return new a.Quaternion(-this.x*c,-this.y*c,-this.z*c,this.w*c)};a.Quaternion.prototype.conjugate=function(){return new a.Quaternion(-this.x,-this.y,-this.z,this.w)};a.Quaternion.prototype.length=function(){return Math.sqrt(this.x*
this.x+this.y*this.y+this.z*this.z+this.w*this.w)};a.Quaternion.prototype.normalize=function(){var e=this.length();if(0===e)return new a.Quaternion;e=1/e;return new a.Quaternion(this.x*e,this.y*e,this.z*e,this.w*e)};a.Quaternion.prototype.add=function(e){return new a.Quaternion(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)};a.Quaternion.prototype.multiply=function(e){return new a.Quaternion(this.x*e.w+this.w*e.x+this.y*e.z-this.z*e.y,this.y*e.w+this.w*e.y+this.z*e.x-this.x*e.z,this.z*e.w+this.w*e.z+
this.x*e.y-this.y*e.x,this.w*e.w-this.x*e.x-this.y*e.y-this.z*e.z)};a.Quaternion.prototype.multiplyVector3=function(e){var c=this.w*e.x+this.y*e.z-this.z*e.y,f=this.w*e.y+this.z*e.x-this.x*e.z,d=this.w*e.z+this.x*e.y-this.y*e.x;e=-this.x*e.x-this.y*e.y-this.z*e.z;return new a.Vector3D(c*this.w+e*-this.x+f*-this.z-d*-this.y,f*this.w+e*-this.y+d*-this.x-c*-this.z,d*this.w+e*-this.z+c*-this.y-f*-this.x)};a.Quaternion.prototype.scale=function(e){return new a.Quaternion(this.x*e,this.y*e,this.z*e,this.w*
e)};a.Quaternion.prototype.toMatrix3x3=function(){var e=this.x+this.x,c=this.y+this.y,f=this.z+this.z,d=this.x*e,h=this.x*c,g=this.x*f,j=this.y*c,k=this.y*f,m=this.z*f,e=this.w*e,c=this.w*c,f=this.w*f;return new a.Matrix3x3(1-(j+m),h+f,g-c,h-f,1-(d+m),k+e,g+c,k-e,1-(d+j))};a.Quaternion.prototype.toMat4=function(){var e=this.x+this.x,c=this.y+this.y,f=this.z+this.z,d=this.x*e,h=this.x*c,g=this.x*f,j=this.y*c,k=this.y*f,m=this.z*f,e=this.w*e,c=this.w*c,f=this.w*f;return new a.Matrix4x4(1-(j+m),h+f,
g-c,0,h-f,1-(d+m),k+e,0,g+c,k-e,1-(d+j),0,0,0,0,1)};a.Quaternion.prototype.slerp=function(e,c){var f=this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w;if(1<=Math.abs(f))return new a.Quaternion(this.x,this.y,this.z,this.w);var d=Math.acos(f),h=Math.sqrt(1-f*f);if(0.0010>Math.abs(h))return new a.Quaternion(0.5*this.x+0.5*e.x,0.5*this.y+0.5*e.y,0.5*this.z+0.5*e.z,0.5*this.w+0.5*e.w);f=Math.sin((1-c)*d)/h;d=Math.sin(c*d)/h;return new a.Quaternion(this.x*f+e.x*d,this.y*f+e.y*d,this.z*f+e.z*d,this.w*f+e.w*d)};
a.Quaternion.prototype.fromRotationMatrix=function(e){var c=new a.Quaternion;fTrace=e.a00+e.a11+e.a22;var f;if(0<fTrace)f=Math.sqrt(fTrace+1),c.w=0.5*f,f=0.5/f,c.x=(e.a21-e.a12)*f,c.y=(e.a02-e.a20)*f,c.z=(e.a10-e.a01)*f;else{f=[1,2,0];var d=0;e=[e.a00,e.a01,e.a02,e.a10,e.a11,e.a12,e.a20,e.a21,e.a22];e[4]>e[0]&&(d=1);e[8]>e[3*d+d]&&(d=2);var h=f[d],g=f[h];f=Math.sqrt(e[3*d+d]-e[3*h+h]-e[3*g+g]+1);0==d?c.x=0.5*f:1==d?c.y=0.5*f:c.z=0.5*f;f=0.5/f;c.w=(e[3*g+h]-e[3*h+g])*f;0==h?c.x=(e[3*h+d]+e[3*d+h])*
f:1==h?c.y=(e[3*h+d]+e[3*d+h])*f:c.z=(e[3*h+d]+e[3*d+h])*f;0==h?c.x=(e[3*g+d]+e[3*d+g])*f:1==h?c.y=(e[3*g+d]+e[3*d+g])*f:c.z=(e[3*g+d]+e[3*d+g])*f}return c};a.Quaternion.prototype.setIdentity=function(){this.z=this.y=this.x=0;this.w=1;return this};a.Quaternion.prototype.fromAngleAxis=function(e,c){var f=0.5*e,d=Math.sin(f);return new a.Quaternion(Math.cos(f),d*c.x,d*c.y,d*c.z)};a.Quaternion.prototype.toAngleAxis=function(){var e=this.x*this.x+this.y*this.y+this.z*this.z,c=new a.Vector4D;0<e?(c.w=
2*Math.acos(this.w),e=a.RenderMath.inverseSqrt(e),c.x=this.x*e,c.y=this.y*e,c.z=this.z*e):(c.x=1,c.y=0,c.z=0,c.w=0);return c};a.Matrix4x4.prototype.toArray=function(){return[this.a00,this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33]};return a}(descartesJS||{}),descartesJS=function(a){function e(a,c){return c.depth-a.depth}if(a.loadLib)return a;a.Scene=function(a){this.parent=a;this.graphics=[]};a.Scene.prototype.add=
function(a){this.graphics.push(a)};a.Scene.prototype.draw=function(){for(var a=0,c=this.graphics.length;a<c;a++)this.graphics[a].transformVertices(this.parent);this.graphics=this.graphics.sort(e);a=0;for(c=this.graphics.length;a<c;a++)this.graphics[a].draw()};a.Primitive3D=function(e,j,k,m,n){this.vertices=e;this.type=j;this.style=k;this.mvMatrix=m;this.ctx=n;this.transformedVertices=[];this.centroid=new a.Vector4D(0,0,0,1);"vertex"===j?this.draw=c:"triangle"===j?this.draw=drawTriangle:"face"===j?
this.draw=f:"text"===j?this.draw=d:"segment"===j&&(this.draw=h)};a.Primitive3D.prototype.transformVertices=function(a){for(var c=this.depth=0,e=this.vertices.length;c<e;c++)this.transformedVertices[c]=a.perspectiveMatrix.multiplyVector4(this.vertices[c]).toVector3D(),this.depth+=this.transformedVertices[c].z,this.transformedVertices[c].x=a.transformCoordinateX(this.transformedVertices[c].x),this.transformedVertices[c].y=a.transformCoordinateY(this.transformedVertices[c].y);this.depth/=e};a.Primitive3D.prototype.setStyle=
function(){for(var a in this.style)this.ctx[a]=this.style[a]};var c=function(){},f=function(){var a=this.ctx;this.setStyle();a.beginPath();a.moveTo(this.transformedVertices[0].x,this.transformedVertices[0].y);for(var c=1,e=this.transformedVertices.length;c<e;c++)a.lineTo(this.transformedVertices[c].x,this.transformedVertices[c].y);a.closePath();"wire"==this.style.model?(a.lineWidth=1,a.strokeStyle=this.fillStyle,a.stroke()):this.style.edges&&a.stroke();a.fill()},d=function(){},h=function(){};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.Graphic3D=function(e,c){this.parent=e;var f=this.parent.evaluator.parser;this.evaluator=e.evaluator;this.spaceID="E0";this.type="";this.background=!1;this.color="#eeffaa";this.backcolor="#6090a0";this.Nu=this.evaluator.parser.parse("7");this.Nv=this.evaluator.parser.parse("7");this.drawif=f.parse("1");this.abs_coord=!1;this.family=this.trace="";this.family_interval=f.parse("[0,1]");this.family_steps=f.parse("8");this.parameter="t";this.parameter_interval=
f.parse("[0,1]");this.parameter_steps=f.parse("8");this.fillM=this.fillP=this.fill="";this.length=this.width=-1;this.editable=!1;this.info="";this.font="Monospaced,PLAIN,12";this.fixed=!0;this.size=f.parse("2");this.text="";this.decimals=f.parse("2");this.spear=f.parse("8");this.arrow="#ee0022";this.center=f.parse("(0,0)");this.radius=f.parse("1");this.init=f.parse("0");this.end=f.parse("90");this.file="";this.inirot=f.parse("0");for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);void 0==this.expresion&&
"macro"!=this.type&&(this.expresion=f.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.Graphic3D.prototype.getSpace=function(){for(var a=this.parent.spaces,c,f=0,d=a.length;f<d;f++)if(c=a[f],c.id==this.spaceID)return c;return a[0]};a.Graphic3D.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.Graphic3D.prototype.drawFamilyAux=function(a,c,f){var d=this.evaluator;this.getFamilyValues();var h=d.getVariable(this.family);if(0<=this.fSteps)for(var g=0,j=this.fSteps;g<=j;g++)d.setVariable(this.family,this.familyInf+g*this.family_sep),d.evalExpression(this.drawif)&&
(this.update(),this.drawAux(a,c,f));d.setVariable("_Text_H_",0);d.setVariable(this.family,h)};a.Graphic3D.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.Graphic3D.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.Graphic3D.prototype.drawText=function(e,
c,f,d,h,g,j,k,m,n){if("rtfNode"==c.type)e.fillStyle=h,e.strokeStyle=h,e.textBaseline="alphabetic",c.draw(e,f,d,m,n,j);else{f+=g.match("Arial")?-2:g.match("Times")?-2:0;var q=this.evaluator;e.fillStyle=a.getColor(q,h);e.font=g;e.textAlign=j;e.textBaseline=k;this.fontSize=(this.fontSize=g.match(/(\d+)px/))?this.fontSize[1]:"10";this.border&&(e.strokeStyle=a.getColor(q,this.border),e.lineWidth=parseFloat(this.fontSize)/12);g=1.2*this.fontSize;if(c[0]&&c[0].type){j=0;for(k=c.length;j<k;j++)h=q.evalExpression(c[j],
m,n),this.border&&e.strokeText(h,f,d+g*j),e.fillText(h,f,d+g*j)}else{j=0;for(k=c.length;j<k;j++)h=c[j],this.border&&e.strokeText(h,f,d+g*j),e.fillText(h,f,d+g*j)}}};a.Graphic3D.prototype.findExpresionX=function(a){return(a=a.split(/x=/)[1])?(a=a.split(/y=/)[0],a=a.split(/z=/)[0]):""};a.Graphic3D.prototype.findExpresionY=function(a){return(a=a.split(/y=/)[1])?(a=a.split(/x=/)[0],a=a.split(/z=/)[0]):""};a.Graphic3D.prototype.findExpresionZ=function(a){return(a=a.split(/z=/)[1])?(a=a.split(/x=/)[0],
a=a.split(/y=/)[0]):""};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Surface3D=function(c,e){a.Graphic3D.call(this,c,e);var d=this.evaluator.parser;this.width=-1==this.width?d.parse("1"):this.width;this.mvMatrix=(new a.Matrix4x4).setIdentity();this.exprX=d.parse(this.findExpresionX(this.expresion));this.exprY=d.parse(this.findExpresionY(this.expresion));this.exprZ=d.parse(this.findExpresionZ(this.expresion))};a.extend(a.Surface3D,a.Graphic3D);var e,c,f,d,h,g,j,k,m;a.Surface3D.prototype.update=
function(){e=this.evaluator;e.getVariable("u");e.getVariable("v");e.setVariable("u",0);e.setVariable("v",0);c=e.evalExpression(this.Nu);f=e.evalExpression(this.Nv);m=a.getColor(e,this.color);j=[];for(var n=0;n<=c;n++){e.setVariable("u",n/c);for(var q=0;q<=f;q++)e.setVariable("v",q/f),d=e.evalExpression(this.exprX),h=e.evalExpression(this.exprY),e.setVariable("x",d),e.setVariable("y",h),g=e.evalExpression(this.exprZ),j.push(new a.Vector4D(d,h,g,1))}for(n=0;n<c;n++)for(q=0;q<f;q++)k=[],k.push(j[q+n*
f+n]),k.push(j[q+1+n*f+n]),k.push(j[q+2+(n+1)*f+n]),k.push(j[q+1+(n+1)*f+n]),this.space.scene.add(new a.Primitive3D(k,"face",{lineWidth:2,fillStyle:m,strokeStyle:"#808080",lineCap:"round",lineJoin:"round",edges:this.edges},this.mvMatrix,this.ctx))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Mesh3D=function(c,e){a.Graphic3D.call(this,c,e);var h=this.evaluator.parser;this.width=-1==this.width?h.parse("1"):this.width;this.mvMatrix=(new a.Matrix4x4).setIdentity();h=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/);
this.vertices=[];this.faces=[];for(var g=function(a){return parseInt(a)},j=0,k=h.length;j<k;j++)h[j].match(/^V\(/)?this.vertices.push(this.evaluator.parser.parse(h[j].substring(1),!1,this.name)):h[j].match(/^F\(/)?this.faces.push(h[j].substring(2,h[j].length-1).split(",").map(g)):h[j].match(/^VAR\(/)&&this.evaluator.evalExpression(this.evaluator.parser.parse(h[j].substring(4,h[j].length-1),!0,this.name))};a.extend(a.Mesh3D,a.Graphic3D);var e,c;a.Mesh3D.prototype.update=function(){e=this.evaluator;
c=a.getColor(e,this.color);for(var f,d,h=0,g=this.faces.length;h<g;h++){f=[];for(var j=0,k=this.faces[h].length;j<k;j++)d=this.evaluator.evalExpression(this.vertices[this.faces[h][j]])[0],f.push(new a.Vector4D(d[0],d[1],d[2],1));this.space.scene.add(new a.Primitive3D(f,"face",{lineWidth:2,fillStyle:c,strokeStyle:"#808080",lineCap:"round",lineJoin:"round",edges:this.edges},this.mvMatrix,this.ctx))}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.max,c=Math.min;
a.R2=function(a,c){this.x=a||0;this.y=c||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 c=this.copy();
c.sub(a);return c.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 c=this.copy(),e=Math.cos(a);a=Math.sin(a);this.x=c.x*e-c.y*a;this.y=c.x*a+c.y*e};a.R2.prototype.rot=function(a){this.rot(a*Math.PI/180)};a.R2.prototype.intersection=function(f,d,h,g){var j=d.x-f.x,k=h.x-g.x,m=h.x-f.x,n=d.y-f.y,q=h.y-g.y,l=h.y-f.y,p=j*q-k*n;return 1E-6<Math.abs(p)?(d=(m*q-l*k)/p,h=(-m*n+l*j)/p,0<=d&&1>=d&&0<=h&&1>=h?new a.R2(f.x+j*d,f.y+n*d):null):(d.x-h.x)*l!=(d.y-h.y)*m?
null:f.x!=d.x?(j=c(f.x,d.x),f=e(f.x,d.x),j<=h.x&&h.x<=f?h:j<=g.x&&g.x<=f?g:null):h.x!=g.x?(j=c(h.x,g.x),h=e(h.x,g.x),j<=f.x&&f.x<=h?f:j<=d.x&&d.x<=h?d:null):f.y!=d.y?(j=c(f.y,d.y),f=e(f.y,d.y),j<=h.y&&h.y<=f?h:j<=g.y&&g.y<=f?g:null):h.y!=g.y?(j=c(h.y,g.y),h=e(h.y,g.y),j<=f.y&&f.y<=h?f:j<=d.y&&d.y<=h?d:null):f.x==h.x&&f.y==h.y?f: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,
f=new a.R2(0,0),d=c.getVariable("x"),h=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")+1E-12);e=c.evalExpression(this.constraint);f.x=(e-this.f0)/1E-12;f.x=!isNaN(f.x)?f.x:Infinity;c.setVariable("x",c.getVariable("x")-1E-12);c.setVariable("y",c.getVariable("y")+1E-12);e=c.evalExpression(this.constraint);f.y=(e-this.f0)/1E-12;f.y=!isNaN(f.y)?f.y:Infinity;c.setVariable("x",d);c.setVariable("y",h);return f};
a.R2Newton.prototype.findZero=function(a){var c=this.evaluator,f=a.copy(),d=c.getVariable("x"),h=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 f;c.setVariable("x",d);c.setVariable("y",h);for(h=0;256>h;h++)if(c=f.x,d=f.y,this.normal=this.gradient(f),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),f.x=c+this.normal.x,f.y=d+this.normal.y,1E-6>this.normal.norm()){0==
this.normal.x&&0==this.normal.y&&(this.normal.x=f.x-a.x,this.normal.y=f.y-a.y);break}return f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI;a.GraphicControl=function(c,e){this.parent=c;this.evaluator=c.evaluator;var d=this.evaluator.parser;this.id="G";this.type="";this.spaceID="E0";this.text="";this.expresion=d.parse("(0,0)");this.y=this.x=0;this.size=d.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=d.parse("1");this.activeif=d.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.decimals=d.parse("2");this.zIndex=-1;for(var h in e)e.hasOwnProperty(h)&&(this[h]=e[h]);this.font=a.convertFont(this.font);this.constraintExpr&&(this.constraint=d.parse(this.constraintExpr),"(expr)"==this.constraint.type&&(this.constraint=
d.parse(this.constraintExpr.substring(1,this.constraintExpr.length-1))),"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=0<c.evalExpression(this.drawif)?"block":"none";var e=c.evalExpression(this.expresion);this.x=e[0][0];this.y=e[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&&(e=this.newt.findZero(new a.R2(this.x,this.y)),this.x=e.x,this.y=e.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 e=this.space.getAbsoluteX(this.x),d=this.space.getAbsoluteY(this.y);this.mouseCacher.style.left=e-this._w/2+"px";this.mouseCacher.style.top=d-this._h/2+"px";this.mouseCacher.style.display=
0<c.evalExpression(this.activeif)?"block":"none";this.constraint&&(e=this.newt.findZero(new a.R2(this.x,this.y)),this.x=e.x,this.y=e.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(0<c.evalExpression(this.drawif)){var f=this.ctx,d=this.space.backgroundCtx,h=this.space.getAbsoluteX(this.x),g=this.space.getAbsoluteY(this.y);""!=this.text&&this.drawText(h,g);this.image.ready?(this.image.complete&&
f.drawImage(this.image,h-this.image.width/2,g-this.image.height/2),this.trace&&(d.save(),d.translate(h,g),d.scale(this.image.width/2,this.image.height/2),d.beginPath(),d.arc(0,0,1,0,e,!1),d.restore(),d.lineWidth=1,d.strokeStyle=a.getColor(c,this.trace),d.stroke())):(f.beginPath(),f.arc(h,g,this.width/2,0,e,!1),f.fillStyle=a.getColor(c,this.colorInt),f.fill(),f.lineWidth=1,f.strokeStyle=a.getColor(c,this.color),f.stroke(),this.active&&(f.beginPath(),f.arc(h,g,this.width/2-2,0,e,!1),f.strokeStyle="black",
f.stroke()),this.trace&&(d.lineWidth=1,d.strokeStyle=a.getColor(c,this.trace),d.beginPath(),d.arc(h,g,this.width/2,0,e,!1),d.stroke()))}};a.GraphicControl.prototype.drawText=function(c,e){var d=this.ctx,h=this.evaluator;d.fillStyle=a.getColor(h,this.color);d.font=this.font;d.textBaseline="alphabetic";h=h.evalExpression(this.text[0],h.evalExpression(this.decimals),this.fixed);d.fillText(h,c+1+this.width/2,e-1-this.height/2)};a.GraphicControl.prototype.getContainer=function(){for(var a=this.parent.spaces,
e,d=0,h=a.length;d<h;d++)if(e=a[d],e.id==this.spaceID)return e.addCtr(this),this.zIndex=e.zIndex,e.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,e=0,d=a.length;e<d;e++)if(a[e].id==this.spaceID)return a[e];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();k.whichButton=null==c.which?2>c.button?"LEFT":4==c.button?"MIDDLE":"RIGHT":2>c.which?"LEFT":2==c.which?"MIDDLE":"RIGHT";"LEFT"==k.whichButton&&(0<k.evaluator.evalExpression(k.activeif)&&k.over)&&(k.parent.deactivateGraphiControls(),k.click=!0,k.active=!0,k.evaluator.setVariable(k.id+".activo",1),k.posAnte=k.getCursorPosition(c),k.prePos={x:k.space.getAbsoluteX(k.x),y:k.space.getAbsoluteY(k.y)},a.hasTouchSupport?(window.addEventListener("touchmove",h,!1),
window.addEventListener("touchend",d,!1)):(window.addEventListener("mouseup",d,!1),window.addEventListener("mousemove",h,!1)))}function e(c){c.preventDefault();0<k.evaluator.evalExpression(k.activeif)&&(k.parent.deactivateGraphiControls(),k.click=!0,k.active=!0,k.posAnte=k.getCursorPosition(c),k.prePos={x:k.space.getAbsoluteX(k.x),y:k.space.getAbsoluteY(k.y)},a.hasTouchSupport?(window.addEventListener("touchmove",h,!1),window.addEventListener("touchend",d,!1)):(window.addEventListener("mouseup",d,
!1),window.addEventListener("mousemove",h,!1)))}function d(c){c.preventDefault();if(0<k.evaluator.evalExpression(k.activeif)||k.active)k.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",h,!1),window.removeEventListener("touchend",d,!1)):(window.removeEventListener("mouseup",d,!1),window.removeEventListener("mousemove",h,!1)),k.parent.update(),k.mouseCacher.style.left=k.space.getAbsoluteX(k.x)-k._w/2+"px",k.mouseCacher.style.top=k.space.getAbsoluteY(k.y)-k._h/2+"px"}function h(c){c.preventDefault();
c=k.getCursorPosition(c);k.posX=k.prePos.x-(k.posAnte.x-c.x);k.posY=k.prePos.y-(k.posAnte.y-c.y);if(k.constraint){c=k.space.getRelativeX(k.posX);var e=k.space.getRelativeY(k.posY);c=k.newt.findZero(new a.R2(c,e));k.x=c.x;k.y=c.y;k.evaluator.setVariable(k.id+".x",k.x);k.evaluator.setVariable(k.id+".y",k.y)}else k.evaluator.setVariable(k.id+".x",k.space.getRelativeX(k.posX)),k.evaluator.setVariable(k.id+".y",k.space.getRelativeY(k.posY));k.parent.updateControls();k.parent.update()}function g(){k.over=
!0;k.mouseCacher.style.cursor="pointer"}function j(){k.over=!1;k.mouseCacher.style.cursor="";k.click=!1}this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=function(){return!1};var k=this;a.hasTouchSupport?this.mouseCacher.addEventListener("touchstart",e,!1):(this.mouseCacher.addEventListener("mousedown",c,!1),this.mouseCacher.addEventListener("mouseover",g,!1),this.mouseCacher.addEventListener("mouseout",j,!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 f=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=f.parse("(0,0,100,23)"):(this.expresion=f.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=f.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=f.parse("1");this.activeif=f.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=f.parse("0");this.decimals=f.parse("2");this.min=f.parse("-Infinity");this.max=f.parse("Infinity");this.incr=f.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var d in c)c.hasOwnProperty(d)&&
(this[d]=c[d]);void 0==this.name&&(this.name=2==this.parent.version?this.id:"_nada_");f=this.evaluator.evalExpression(this.expresion);this.x=f[0][0];this.y=f[0][1];4==f[0].length&&(this.w=f[0][2],this.h=f[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 f=0,d=a.length;f<d;f++){if(c=a[f],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.cID?(this.expresion=this.evaluator.parser.parse("(0,-1000,"+this.w+","+this.h+")"),this.parent.scenarioRegion.scenarioSpace.addCtr(this),this.zIndex=this.parent.scenarioRegion.scenarioSpace.zIndex,
this.parent.scenarioRegion.scenarioSpace.numericalControlContainer):this.parent.externalSpace.container;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,e){a.Control.call(this,c,e);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 d;this.imageSrc.match("_COLORES_")&&(d=this.imageSrc.split("_"),this.colorInt=d[2],this.color=d[3],this.font_size=this.parser.parse(d[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+"'");d=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=d){var h=d.substr(0,d.lastIndexOf(".")),g=d.substr(d.lastIndexOf("."));d.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(d),this.imageOver=this.parent.getImage(h+"_over"+g),this.imageDown=this.parent.getImage(h+"_down"+g))}d=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=0<this.evaluator.evalExpression(this.drawif)?"block":"none";this.ctx=this.canvas.getContext("2d");d.childNodes[0]?d.insertBefore(this.canvas,d.childNodes[0]):d.appendChild(this.canvas);this.registerMouseEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=function(){var a=this.canvas,e=this.evaluator.evalExpression(this.expresion);this.x=e[0][0];this.y=e[0][1];4==e[0].length&&(this.w=
parseInt(e[0][2]),this.h=parseInt(e[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,e=!1,d=!1,h=!1;0<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 g=this.evaluator.evalExpression(this.expresion),a=this.x!=g[0][0],e=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],h=this.h!=g[0][3],this.w=g[0][2],this.h=g[0][3]);(d||h)&&this.createGradient(this.canvas.width,this.canvas.height);if(d||h||a||e)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,f){this.linearGradient=this.ctx.createLinearGradient(0,0,0,f);for(var d=f*f,h,g=0;g<f;g++)h=e(g-35*f/100),this.linearGradient.addColorStop(g/f,"rgba(0,0,0,"+192*h*h/d/255+")")};a.Button.prototype.draw=function(){var c=this.evaluator.evalExpression(this.font_size),f=this.evaluator.evalExpression(this.name),d=this.evaluator.evalExpression(this.imageSrc),h;h="vacio.gif"==d?{ready:!0}:this.parent.getImage(d);var g=this.ctx;g.clearRect(0,0,this.w,this.h);var j=0,k=0;this.click&&(k=j=1);h&&h.ready?
(""!=h.src||!d.toLowerCase().match(/vacio.gif$/))&&h.complete&&g.drawImage(h,(this.w-h.width)/2+j,(this.h-h.height)/2+k):(g.fillStyle=a.getColor(this.evaluator,this.colorInt),g.fillRect(0,0,this.w,this.h),this.click||(a.drawLine(g,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,"+128/255+")"),a.drawLine(g,0,0,0,this.h,"rgba(0,0,0,"+24/255+")"),a.drawLine(g,1,0,1,this.h,"rgba(0,0,0,"+8/255+")")),g.fillStyle=this.linearGradient,g.fillRect(0,0,this.w,this.h));""!=this.imageOver.src&&(this.imageOver.ready&&this.over)&&
g.drawImage(this.imageOver,(this.w-h.width)/2+j,(this.h-h.height)/2+k);""!=this.imageDown.src&&this.imageDown.ready&&this.click?g.drawImage(this.imageDown,(this.w-h.width)/2+j,(this.h-h.height)/2+k):this.click&&(g.save(),a.drawLine(g,0,0,0,this.h-2,"gray"),a.drawLine(g,0,0,this.w-1,0,"gray"),g.fillStyle="rgba(0, 0, 0,"+24/255+")",g.fillRect(0,0,this.w,this.h),g.restore());g.fillStyle=a.getColor(this.evaluator,this.color);g.font=this.italics+" "+this.bold+" "+c+"px Arial";g.textAlign="center";g.textBaseline=
"middle";g.strokeStyle=a.getColor(this.evaluator,this.colorInt);g.lineWidth=c/12;this.stroke!=this.fillStyle&&g.strokeText(f,e(this.w/2+j)+0.5,e(this.h/2+k)+0.5);g.fillText(f,e(this.w/2+j)+0.5,e(this.h/2+k)+0.5);this.underlined&&(f=g.measureText(f).width,g.strokeStyle=a.getColor(this.evaluator,this.color),g.lineWidth=e(c/10),g.lineCap="round",g.beginPath(),g.moveTo((this.w-f)/2+j,e(this.h+c)/2+g.lineWidth/2-1.5+k),g.lineTo((this.w+f)/2+j,e(this.h+c)/2+g.lineWidth/2-1.5+k),g.stroke());this.evaluator.evalExpression(this.activeif)||
(g.fillStyle="rgba(240,240,240,"+160/255+")",g.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,e,d){k.click?(e.call(k),a=d?a:30,n=setTimeout(function(){c(a,e)},a)):clearInterval(n)}function e(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&&0<k.evaluator.evalExpression(k.activeif)&&(k.click=!0,k.draw(),k.evaluator.setVariable(k.id,k.evaluator.evalExpression(k.valueExpr)),"calculate"==k.action&&c(m,k.bottonPressed,!0),j?window.addEventListener("touchend",d,!1):window.addEventListener("mouseup",d,!1))}function d(a){if(0<k.evaluator.evalExpression(k.activeif)||k.click)k.click=!1,k.draw(),"calculate"!=k.action&&k.bottonPressed(),a.preventDefault(),
j?window.removeEventListener("touchend",d,!1):window.removeEventListener("mouseup",d,!1)}function h(){k.over=!0;k.draw()}function g(){k.over=!1;k.click=!1;k.draw()}var j=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};var k=this,m=900,n;this.over=this.click=!1;j?this.canvas.addEventListener("touchstart",e,!1):(this.canvas.addEventListener("mousedown",e,!1),this.canvas.addEventListener("mouseover",h,!1),this.canvas.addEventListener("mouseout",g,!1))};return a}(descartesJS||{}),descartesJS=
function(a){function e(a,c,e,d){a.fillStyle=d||"black";a.beginPath();a.moveTo(c[0],e[0]);d=1;for(var f=c.length;d<f;d++)a.lineTo(c[d],e[d]);a.fill()}if(a.loadLib)return a;var c;a.Spinner=function(c,e){a.Control.call(this,c,e);this.tabindex=++this.parent.tabindex;var d=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.trim()&&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);d.childNodes[0]?d.insertBefore(this.containerControl,d.childNodes[0]):d.appendChild(this.containerControl);this.originalIncr=
this.incr;0>=this.evaluator.evalExpression(this.decimals)&&(d=this.evaluator.evalExpression(this.incr),0<d?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(d).toString()):this.incr=this.evaluator.parser.parse("1"));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 e=this.formatOutputValue(this.value);this.fieldFontSize=2!=this.parent.version?
a.getFieldFontSize(this.h):10;var d=2!=this.parent.version?"":"mmmmm",f=a.getTextWidth(e+"m",this.fieldFontSize+"px Arial"),h=2+this.h/2,g=this.w/2-h/2,d=a.getTextWidth(this.name+d,this.fieldFontSize+"px Arial");this.visible||(g=this.w-h,f=0);g<d&&(g=d);""==this.name&&(g=0);this.w-g-h<f&&(g=this.w-h-f);0>g&&(g=0);d=this.w-(g+h);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=0<c.evalExpression(this.drawif)?"block":"none";this.canvas.setAttribute("width",h+"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","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+h+"px; height : "+this.h/2+"px; left: "+
g+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+h+"px; height : "+this.h/2+"px; left: "+g+"px; top: "+this.h/2+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_spinner");this.field.value=e;this.field.setAttribute("class","DescartesSpinnerField");this.field.setAttribute("style","font-family: Arial; font-size: "+this.fieldFontSize+"px; width : "+(d-2)+"px; height : "+(this.h-
2)+"px; left: "+(h+g)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.disabled=j?!1:!0;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+g+"px; height: "+this.h+"px; line-height: "+this.h+"px;");c.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};var f,d,h,g,j=0;a.Spinner.prototype.update=function(){var a=this.evaluator;if(0>=a.evalExpression(this.decimals)){var c=this.evaluator.evalExpression(this.incr);
0<c?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(c).toString()):this.incr=this.evaluator.parser.parse("1")}else this.incr=this.originalIncr;g=h=d=f=!1;j=0<a.evalExpression(this.activeif);this.field.disabled=j?!1:!0;0<a.evalExpression(this.drawif)?(this.containerControl.style.display="block",this.draw()):(this.click=!1,this.containerControl.style.display="none");c=a.evalExpression(this.expresion);f=this.x!=c[0][0];d=this.y!=c[0][1];this.x=c[0][0];this.y=c[0][1];4==c[0].length&&
(h=this.w!=c[0][2],g=this.h!=c[0][3],this.w=c[0][2],this.h=c[0][3]);(h||g)&&this.createGradient(this.canvas.width,this.canvas.height);var c=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!=c&&(this.value=this.validateValue(c),this.field.value=this.formatOutputValue(this.value));if(h||g||f||d)this.init(),this.draw();a.setVariable(this.id,this.value)};a.Spinner.prototype.createGradient=
function(a,c){this.linearGradient=this.ctx.createLinearGradient(0,0,0,c);for(var e=c*c,d,f=0;f<c;f++)d=Math.floor(f-40*c/100),this.linearGradient.addColorStop(f/c,"rgba(0,0,0,"+192*d*d/e/255+")")};a.Spinner.prototype.draw=function(){var c=this.ctx,d=this.canvas.width,f=this.canvas.height;c.save();c.fillStyle="#f0f8ff";c.fillRect(0,0,d,f);c.fillStyle=this.linearGradient;c.fillRect(0,0,d,f);var h,g;this.up?(h="gray",g="#f0f8ff"):(h="#f0f8ff",g="gray");a.drawLine(c,0,0,d,0,h);a.drawLine(c,0,0,0,f/2,
h);a.drawLine(c,0,f/2,d,f/2,g);this.down?(h="gray",g="#f0f8ff"):(h="#f0f8ff",g="gray");a.drawLine(c,0,f/2+1,d,f/2+1,h);a.drawLine(c,0,f/2+1,0,f,h);a.drawLine(c,0,f-1,d,f-1,g);h=[d/2,d/5-1,d-d/5+1];g=[f/8+1,f/8+1+f/4,f/8+1+f/4];e(c,h,g,j?"#2244cc":"#8888aa");g=[f-f/8,f-f/8-f/4,f-f/8-f/4];e(c,h,g,j?"#d00018":"#aa8888");c.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&c.fillRect(0,0,d,f/2);this.down&&c.fillRect(0,f/2,d,f)};a.Spinner.prototype.validateValue=function(a){var e=this.evaluator;(a=parseFloat(e.evalExpression(e.parser.parse(a.toString().replace(this.parent.decimal_symbol,
".")))))||(a=0);a<e.evalExpression(this.min)&&(a=e.evalExpression(this.min));a>e.evalExpression(this.max)&&(a=e.evalExpression(this.max));if(this.discrete){var d=e.evalExpression(this.incr);a=0==d?0:d*Math.round(a/d)}c=e.evalExpression(this.decimals);0>=c&&(c=0);return a=parseFloat(parseFloat(a).toFixed(c))};a.Spinner.prototype.formatOutputValue=function(a){var e=a+"",d=e.indexOf(".");-1!=d&&e.substring(d+1).length>c&&(e=parseFloat(e).toFixed(c));if(this.fixed&&(2!=this.parent.version||2==this.parent.version&&
!this.exponentialif))e=parseFloat(a).toFixed(c);this.exponentialif&&0!=parseFloat(e)&&(e=this.fixed&&2!=this.parent.version?parseFloat(e).toExponential(c):parseFloat(e).toExponential(),e=e.toUpperCase(),e=e.replace("+",""));return e=e.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){j&&(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,e,d){t.up||t.down?(e.call(t),a=d?a:30,v=setTimeout(function(){c(a,e)},a)):clearInterval(v)}
function e(a){a.preventDefault();t.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==t.whichButton&&j&&(t.up=!0,c(r,t.increase,!0),t.draw())}function d(a){a.preventDefault();t.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==t.whichButton&&j&&(t.down=!0,c(r,t.decrease,!0),t.draw())}function f(a){t.up=!1;clearInterval(v);t.draw();a.preventDefault()}
function h(a){t.down=!1;clearInterval(v);t.draw();a.preventDefault()}function g(a){t.up=!1;clearInterval(v);t.draw();a.preventDefault()}function u(a){t.down=!1;clearInterval(v);t.draw();a.preventDefault()}var s=a.hasTouchSupport;this.divUp.oncontextmenu=function(){return!1};this.divDown.oncontextmenu=function(){return!1};var t=this,r=s?500:200,v;this.label.oncontextmenu=function(){return!1};s?this.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):this.label.addEventListener("mousedown",
function(a){a.preventDefault();return!1});this.field.addEventListener("keydown",function(a){13==a.keyCode&&t.changeValue(t.field.value)},!1);s?this.divUp.addEventListener("touchstart",e,!1):this.divUp.addEventListener("mousedown",e,!1);s?this.divDown.addEventListener("touchstart",d,!1):this.divDown.addEventListener("mousedown",d,!1);s||this.divUp.addEventListener("mouseout",f,!1);s||this.divDown.addEventListener("mouseout",h,!1);s?(this.divUp.addEventListener("touchend",g,!1),window.addEventListener("touchend",
g,!1)):(this.divUp.addEventListener("mouseup",g,!1),window.addEventListener("mouseup",g,!1));s?(this.divDown.addEventListener("touchend",u,!1),window.addEventListener("touchend",u,!1)):(this.divDown.addEventListener("mouseup",u,!1),window.addEventListener("mouseup",u,!1))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.TextField=function(e,c){a.Control.call(this,e,c);void 0===this.valueExprString&&(this.valueExprString="");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 f=this.answerPattern.indexOf("|");this.firstAnswer=-1==f?this.answerPattern:this.answerPattern.substring(0,f)}else this.buildRangeExpresions(),this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(",")));if(this.onlyText){if(!this.valueExprString.match(/^'/)||
!this.valueExprString.match(/^'/))this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'");this.validateValue=function(a){return"''"==a||"'"==a?"":a};this.formatOutputValue=function(a){return a.toString()};this.evaluateAnswer=this.evaluateTextualAnswer}f=this.getContainer();""==this.name.trim()&&(this.name="");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);f.childNodes[0]?f.insertBefore(this.containerControl,f.childNodes[0]):f.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=a.getFieldFontSize(this.h);var c=a.getTextWidth(e+"0",this.fieldFontSize+"px Arial"),f=this.w/2,d=a.getTextWidth(this.name,this.fieldFontSize+"px Arial");f<d&&(f=d);""==this.name&&(f=0);this.w-f<c&&(f=this.w-c);0>f&&(f=0);c=this.w-f;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=
0<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 : "+(c-2)+"px; height : "+(this.h-2)+"px; left: "+f+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.disabled=0<evaluator.evalExpression(this.activeif)?!1:!0;this.label.setAttribute("class",
"DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+f+"px; height: "+this.h+"px; line-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,f=!1,d=!1;this.field.disabled=0<evaluator.evalExpression(this.activeif)?!1:!0;0<evaluator.evalExpression(this.drawif)?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display=
"none";var h=evaluator.evalExpression(this.expresion),a=this.x!=h[0][0],c=this.y!=h[0][1];this.x=h[0][0];this.y=h[0][1];4==h[0].length&&(f=this.w!=h[0][2],d=this.h!=h[0][3],this.w=h[0][2],this.h=h[0][3]);(f||d||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 f=c.evalExpression(this.incr);a=0==f?0:f*Math.round(a/f)}return a=parseFloat(parseFloat(a).toFixed(c.evalExpression(this.decimals)))};a.TextField.prototype.formatOutputValue=
function(a){if(""===a)return"";var c=a+"",f=this.evaluator.evalExpression(this.decimals),d=c.indexOf(".");-1!=d&&c.substring(d+1).length>f&&(c=parseFloat(c).toFixed(f));this.fixed&&(c=parseFloat(a).toFixed(f));this.exponentialif&&(c=c.toExponential(f),c=c.toUpperCase(),c=c.replace("+",""));return c=c.replace(".",this.parent.decimal_symbol)};a.TextField.prototype.changeValue=function(a){0<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,f,d,h,g,j,k,m=0,n=this.answer.length;m<n;m++)if(h=this.answer[m][0],j=this.answer[m][1],
c=a.evalExpression(h.expression),f=a.evalExpression(j.expression),d="("==h.type,h="["==h.type,g=")"==j.type,j="]"==j.type,k=this.value,d&&g&&k>c&&k<f||d&&j&&k>c&&k<=f||h&&g&&k>=c&&k<f||h&&j&&k>=c&&k<=f)return 1;return 0};a.TextField.prototype.buildRangeExpresions=function(){var a;this.answer=this.answer.split("|");for(var c=0,f=this.answer.length;c<f;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,f,d,h=0,g=this.answer.length;h<g;h++){f=this.answer[h];d=!0;for(var j=0,k=f.length;j<k;j++)c=f[j],c.ignoreAcents&&(e=a.replaceAcents(e),c.regExp=a.replaceAcents(c.regExp)),c.ignoreCaps&&(e=e.toLowerCase(),c.regExp=c.regExp.toLowerCase()),d=d&&!!e.match(c.regExp);if(d)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 e=a.hasTouchSupport,c=this;this.label.oncontextmenu=function(){return!1};e?this.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):this.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(){c.update()},!1);this.field.addEventListener("keydown",
function(a){0<c.evaluator.evalExpression(c.activeif)&&13==a.keyCode&&c.changeValue(c.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 f=this.parser;this.options=this.options?this.options.split(","):[];this.menuOptions=[];this.strValue=[];for(var d,h=0,g=this.options.length;h<g;h++)d=this.options[h].split(/[\[\]]/,2),1==d.length?(this.menuOptions.push(d[0]),this.strValue.push(h.toString())):2==d.length&&
(this.menuOptions.push(d[0]),""==d[1]?this.strValue.push(h.toString()):this.strValue.push(d[1]));h=0;for(g=this.strValue.length;h<g;h++)this.strValue[h]=f.parse(this.strValue[h]);f=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");h=0;for(g=this.menuOptions.length;h<g;h++)d=document.createElement("option"),
d.innerHTML=this.menuOptions[h],this.select.appendChild(d);this.field=document.createElement("input");this.init();this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);f.childNodes[0]?f.insertBefore(this.containerControl,f.childNodes[0]):f.appendChild(this.containerControl);this.registerMouseEvents()};a.extend(a.Menu,a.Control);a.Menu.prototype.init=function(){var e=this.evaluator;this.fieldFontSize=
2!=this.parent.version?a.getFieldFontSize(this.h):10;var c=0,f=0,d=0;this.value=e.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var h=0,g=this.menuOptions.length;h<g;h++)d=a.getTextWidth(this.menuOptions[h],this.fieldFontSize+"px Arial"),d>c&&(c=d,f=h);c+=25;d=a.getTextWidth(this.formatOutputValue(e.evalExpression(this.strValue[f])),this.fieldFontSize+"px Arial")+7;f=a.getTextWidth(this.name,this.fieldFontSize+"px Arial")+10;""==this.name&&(f=0);this.visible||(d=0);
for(h=this.w-d-f;h<c&&0<f;)f--,h++;for(;h<c&&0<d;)d--,h++;for(;f+h+d+1<this.w;)h++,d++;var c=f,g=c+h,d=this.w-g,j=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=0<e.evalExpression(this.drawif)?"block":"none";this.label.setAttribute("class",
"DescartesMenuLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+f+"px; height: "+this.h+"px;  line-height: "+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"menu");this.field.value=j;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(d-2)+"px; height : "+(this.h-2)+"px; left: "+g+"px;");this.field.disabled=0<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 : "+h+"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=0<e.evalExpression(this.activeif)?!1:!0;e.setVariable(this.id,parseFloat(j))};a.Menu.prototype.update=
function(){var a=this.evaluator,c=!1,f=!1,d=!1,h=!1,c=0<a.evalExpression(this.activeif);this.field.disabled=c?!1:!0;this.select.disabled=c?!1:!0;0<a.evalExpression(this.drawif)?(this.containerControl.style.display="block",this.draw()):(this.click=!1,this.containerControl.style.display="none");var g=a.evalExpression(this.expresion),c=this.x!=g[0][0],f=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],h=this.h!=g[0][3],this.w=g[0][2],this.h=g[0][3]);if(d||h||c||f)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){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));for(var c=-1,f=Infinity,d,h=0,g=this.strValue.length;h<g;h++)d=Math.abs(a-parseFloat(this.evaluator.evalExpression(this.strValue[h]))),d<=f&&(f=d,c=h);return c};a.Menu.prototype.formatOutputValue=
function(a){var c=a+"",f=this.evaluator.evalExpression(this.decimals),d=c.indexOf(".");-1!=d&&c.substring(d+1).length>f&&(c=parseFloat(c).toFixed(f));this.fixed&&(c=parseFloat(a).toFixed(f));this.exponentialif&&(c=c.toExponential(f),c=c.toUpperCase(),c=c.replace("+",""));return c=c.replace(".",this.parent.decimal_symbol)};a.Menu.prototype.changeValue=function(){0<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 e=a.hasTouchSupport,c=this;this.select.oncontextmenu=function(){return!1};this.label.oncontextmenu=function(){return!1};e?this.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):this.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(a){c.value=c.evaluator.evalExpression(c.strValue[this.selectedIndex]);
c.field.value=c.formatOutputValue(c.value);c.evaluator.setVariable(c.id,c.field.value);c.changeValue();a.preventDefault()},!1);this.field.addEventListener("keydown",function(a){13==a.keyCode&&(c.indexValue=c.getIndex(c.field.value),c.value=c.evaluator.evalExpression(c.strValue[c.indexValue]),c.field.value=c.formatOutputValue(c.indexValue),c.select.selectedIndex=c.indexValue,c.changeValue())},!1)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Scrollbar=
function(c,e){a.Control.call(this,c,e);this.orientation=this.w>=this.h?"horizontal":"vertical";var d=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);d.childNodes[0]?d.insertBefore(this.containerControl,d.childNodes[0]):d.appendChild(this.containerControl);this.init();this.registerMouseEvents();this.draw()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=
function(){var a=this.evaluator;this.incr=0==a.evalExpression(this.decimals)?1:(a.evalExpression(this.max)-a.evalExpression(this.min))/100;this.value=this.validateValue(a.evalExpression(this.valueExpr));var e=this.formatOutputValue(this.value),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.orientation=this.w>=this.h?"horizontal":"vertical";"vertical"==this.orientation?this.initVertical(e):this.initHorizontal(e);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");var f=this.parent.getSpaceById(this.spaceID).h;this.labelHeight=""==this.name?0:23;var d=""==this.visible?0:23;this.canvasHeight=this.h-this.labelHeight-d;18<=this.canvasHeight+this.y-f&&(this.canvasHeight=f);f=d+this.canvasHeight;this.upHeight=
this.downHeight=15;this.scrollManipulatorHeight=parseInt((this.canvasHeight-this.upHeight-this.downHeight-this.labelHeight)/10);this.scrollManipulatorHeight=15>this.scrollManipulatorHeight?15:this.scrollManipulatorHeight;this.scrollManipulatorLimInf=f-this.downHeight-this.scrollManipulatorHeight;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=0<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: "+(f-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: 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.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=0<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: "+f+"px;");this.txtLabel=document.createTextNode(this.name)};a.Scrollbar.prototype.initHorizontal=function(c){this.fieldFontSize=e(this.h-0.25*this.h);var f=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||(f=0);for(var d=this.w-f-this.labelWidth;58>d&&0<this.labelWidth;)this.labelWidth--,d++;for(;58>d&&
0<f;)f--,d++;var h=this.labelWidth,g=h+d,f=this.w-g;this.canvasWidth=d;this.upWidth=this.downWidth=15;this.scrollManipulatorWidth=parseInt((this.canvasWidth-this.upWidth-this.downWidth)/10);this.scrollManipulatorWidth=15>this.scrollManipulatorWidth?15:this.scrollManipulatorWidth;this.scrollManipulatorLimInf=h+this.downWidth;this.scrollManipulatorLimSup=h+this.canvasWidth-this.downWidth-this.scrollManipulatorWidth;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=0<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: "+h+"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: "+(g-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 : "+f+"px; height : "+(this.h-2)+"px; left: "+(this.canvasWidth+this.labelWidth)+"px;");this.field.disabled=0<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,e=!1,d=!1,h=!1,g=!1;this.incr=0==a.evalExpression(this.decimals)?1:(a.evalExpression(this.max)-a.evalExpression(this.min))/100;this.field.disabled=0<a.evalExpression(this.activeif)?!1:!0;0<a.evalExpression(this.drawif)?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";var j=a.evalExpression(this.expresion),
e=this.x!=j[0][0],d=this.y!=j[0][1];this.x=j[0][0];this.y=j[0][1];4==j[0].length&&(h=this.w!=j[0][2],g=this.h!=j[0][3],this.w=j[0][2],this.h=j[0][3]);this.value=this.validateValue(a.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);if(h||g||e||d)this.init(),this.draw();a.setVariable(this.id,this.value);this.draw()};a.Scrollbar.prototype.createGradient=function(a,f){this.linearGradient=this.ctx.createLinearGradient(0,0,0,f);for(var d=f*f,h,g=0;g<f;g++)h=e(g-40*f/100),this.linearGradient.addColorStop(g/
f,"rgba(0,0,0,"+192*h*h/d/255+")")};a.Scrollbar.prototype.draw=function(){var a=this.ctx;if("horizontal"==this.orientation){var f=e(this.h),d=e(this.upWidth),h=e(this.canvasWidth-this.upWidth);a.clearRect(0,0,this.canvasWidth,this.h);a.strokeStyle="#7a8a99";a.strokeRect(0,0,d+0.5,f);a.strokeRect(h+0.5,0,d,f);var g=4;a.fillStyle=this.up?"black":"#333333";a.beginPath();a.moveTo(g,f/2);a.lineTo(d-g,f/2-7);a.lineTo(d-g,f/2+7);a.closePath();a.moveTo(h+1+d-g,f/2);a.lineTo(h+1+g,f/2-7);a.lineTo(h+1+g,f/
2+7);a.closePath();a.fill();a.strokeRect(0,0.5,this.canvasWidth+0.5,f-1);g=e(this.pos-this.labelWidth);a.fillStyle="#ccdcec";a.fillRect(g+0.5,0,e(this.scrollManipulatorWidth),f);a.strokeStyle="#6382bf";a.strokeRect(g+0.5,0,e(this.scrollManipulatorWidth),f);d=e(this.scrollManipulatorWidth/2);a.beginPath();a.moveTo(g+d+0.5-2,3);a.lineTo(g+d+0.5-2,f-3);a.moveTo(g+d+0.5,3);a.lineTo(g+d+0.5,f-3);a.moveTo(g+d+0.5+2,3);a.lineTo(g+d+0.5+2,f-3)}else f=e(this.w),d=e(this.upHeight),h=e(this.canvasHeight-this.upHeight),
a.clearRect(0,0,this.w,this.canvasHeight),a.strokeStyle="#7a8a99",a.strokeRect(0.5,2.5,f-0.5,d),a.strokeRect(0.5,h-0.5,f-0.5,d),g=4,a.fillStyle=this.down?"black":"#333333",a.beginPath(),a.moveTo(f/2,g+2),a.lineTo(f/2-7,d-g+2),a.lineTo(f/2+7,d-g+2),a.closePath(),a.moveTo(f/2,h+d-g),a.lineTo(f/2-7,h+g),a.lineTo(f/2+7,h+g),a.closePath(),a.fill(),a.strokeRect(0.5,1.5,f-0.5,this.canvasHeight-1.5),g=e(this.pos),a.fillStyle="#ccdcec",a.fillRect(0,g+0.5,this.w,e(this.scrollManipulatorHeight)),a.strokeStyle=
"#6382bf",a.strokeRect(0,g+0.5,this.w,e(this.scrollManipulatorHeight)),d=e(this.scrollManipulatorHeight/2),a.beginPath(),a.moveTo(3,g+d+0.5-2),a.lineTo(f-3,g+d+0.5-2),a.moveTo(3,g+d+0.5),a.lineTo(f-3,g+d+0.5),a.moveTo(3,g+d+0.5+2),a.lineTo(f-3,g+d+0.5+2);a.stroke()};a.Scrollbar.prototype.validateValue=function(a){var e=this.evaluator;a=a.toString();(a=parseFloat(a.replace(this.parent.decimal_symbol,".")))||(a=0);this.minimo=e.evalExpression(this.min);a<this.minimo&&(this.value=null,a=this.minimo);
this.maximo=e.evalExpression(this.max);a>this.maximo&&(this.value=null,a=this.maximo);var d=this.incr;a=0!=d?a*d/d:0;this.fixed&&(a=parseFloat(parseFloat(a).toFixed(e.evalExpression(this.decimals))));return a};a.Scrollbar.prototype.formatOutputValue=function(a){var e=a+"",d=this.evaluator.evalExpression(this.decimals),h=e.indexOf(".");-1!=h&&e.substring(h+1).length>d&&(e=parseFloat(e).toFixed(d));this.fixed&&(e=parseFloat(a).toFixed(d));this.exponentialif&&(e=e.toExponential(d),e=e.toUpperCase(),
e=e.replace("+",""));return e=e.replace(".",this.parent.decimal_symbol)};a.Scrollbar.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.incr)};a.Scrollbar.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-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){0<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,f=this.scrollManipulatorLimInf,d=this.scrollManipulatorLimSup,h=a.evalExpression(this.min),g=a.evalExpression(this.max),j=this.incr,
f=e((this.pos-f)*(g-h)/(d-f)/j)*j+h;f!=this.value&&(this.value=f,this.field.value=this.formatOutputValue(f),a.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){var a=this.evaluator,e=this.scrollManipulatorLimInf,d=this.scrollManipulatorLimSup,h=a.evalExpression(this.min),a=a.evalExpression(this.max);this.pos=(this.value-h)*(d-e)/(a-h)+e;"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,e,d,f){(r.up||r.down||r.canvasClick)&&
1E-7<Math.abs(r.value-f)?(e.call(r),a=d?a:30,z=setTimeout(function(){c(a,e,!1,f)},a)):clearInterval(z)}function e(a){a.preventDefault();r.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==r.whichButton&&0<r.evaluator.evalExpression(r.activeif)&&(r.clickPos=r.getCursorPosition(a),r.canvasClick=!0,"horizontal"==r.orientation?r.clickPos.x<r.prePos?c(x,r.decrease10,!0,r.minimo):c(x,r.increase10,!0,r.maximo):r.clickPos.y<r.prePos?
c(x,r.increase10,!0,r.maximo):c(x,r.decrease10,!0,r.minimo))}function d(a){r.canvasClick=!1;clearInterval(z);a.preventDefault()}function h(a){!0==r.canvasClick&&(r.clickPos=r.getCursorPosition(a),a.preventDefault())}function g(a){0<r.evaluator.evalExpression(r.activeif)&&(r.scrollClick=!0,r.initPos=r.getCursorPosition(a),window.addEventListener("mouseup",k,!1),window.addEventListener("mousemove",n,!1),a.preventDefault())}function j(a){0<r.evaluator.evalExpression(r.activeif)&&(r.scrollClick=!0,r.initPos=
r.getCursorPosition(a),window.addEventListener("touchend",m,!1),window.addEventListener("touchmove",onToucheMove_scrollManipulator,!1),a.preventDefault())}function k(a){r.scrollClick=!1;r.prePos=r.pos;window.removeEventListener("mouseup",k,!1);window.removeEventListener("mousemove",n,!1);a.preventDefault()}function m(a){r.scrollClick=!1;r.prePos=r.pos;window.removeEventListener("touchend",m,!1);window.removeEventListener("touchmove",n,!1);a.preventDefault()}function n(a){var c=r.getCursorPosition(a);
"horizontal"==r.orientation?(r.pos=r.prePos-(r.initPos.x-c.x),r.pos<r.scrollManipulatorLimInf&&(r.pos=r.scrollManipulatorLimInf),r.pos>r.scrollManipulatorLimSup&&(r.pos=r.scrollManipulatorLimSup),r.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+r.scrollManipulatorWidth+"px; height : "+r.h+"px; left: "+r.pos+"px; top: 0px;")):(r.pos=r.prePos-(r.initPos.y-c.y),r.pos>r.scrollManipulatorLimInf&&(r.pos=r.scrollManipulatorLimInf),
r.pos<r.scrollManipulatorLimSup&&(r.pos=r.scrollManipulatorLimSup),r.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+r.w+"px; height : "+r.scrollManipulatorHeight+"px; left: 0px; top: "+r.pos+"px;"));r.changeValueForScrollMovement();a.preventDefault()}function q(a){a.preventDefault();r.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==r.whichButton&&
0<r.evaluator.evalExpression(r.activeif)&&(r.up=!0,c(x,r.increase,!0,r.maximo))}function l(a){a.preventDefault();r.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==r.whichButton&&0<r.evaluator.evalExpression(r.activeif)&&(r.down=!0,c(x,r.decrease,!0,r.minimo))}function p(a){r.up=!1;clearInterval(z);a.preventDefault()}function u(a){r.down=!1;clearInterval(z);a.preventDefault()}function s(a){r.up=!1;clearInterval(z);a.preventDefault()}
function t(a){r.down=!1;clearInterval(z);a.preventDefault()}var r=this,v=a.hasTouchSupport,x=v?500:200,z;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&&r.changeValue(r.field.value)},!1);v?this.canvas.addEventListener("touchstart",e,!1):this.canvas.addEventListener("mousedown",e,!1);v||this.divDown.addEventListener("mouseout",u,!1);v?window.addEventListener("touchend",
d,!1):window.addEventListener("mouseup",d,!1);v?this.canvas.addEventListener("touchmove",h,!1):this.canvas.addEventListener("mousemove",h,!1);v?this.scrollManipulator.addEventListener("touchstart",j,!1):this.scrollManipulator.addEventListener("mousedown",g,!1);v?this.divUp.addEventListener("touchstart",q,!1):this.divUp.addEventListener("mousedown",q,!1);v?this.divDown.addEventListener("touchstart",l,!1):this.divDown.addEventListener("mousedown",l,!1);v||this.divUp.addEventListener("mouseout",p,!1);
v||this.divDown.addEventListener("mouseout",u,!1);v?window.addEventListener("touchend",s,!1):window.addEventListener("mouseup",s,!1);v?window.addEventListener("touchend",t,!1):window.addEventListener("mouseup",t,!1)};a.Scrollbar.prototype.getCursorPosition=function(c){c=a.getCursorPosition(c);return{x:c.x-(this.containerControl.offsetLeft+this.containerControl.parentNode.offsetLeft+this.containerControl.parentNode.parentNode.offsetLeft),y:c.y-(this.containerControl.offsetTop+this.containerControl.parentNode.offsetTop+
this.containerControl.parentNode.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 f=this.getContainer(),d=this.evaluator.evalExpression(this.expresion);4==d[0].length?(this.w=d[0][2],this.h=d[0][3]):(this.w=100,this.h=28);if(d=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");d?(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+";");f.childNodes[0]?d?f.insertBefore(this.audioContainer,f.childNodes[0]):f.insertBefore(this.audio,f.childNodes[0]):d?f.appendChild(this.audioContainer):f.appendChild(this.audio)};a.extend(a.Audio,a.Control);a.Audio.prototype.update=function(){var a=this.evaluator;0<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 f=this.evaluator,d=this.getContainer(),h=this.evaluator.evalExpression(this.expresion);4==h[0].length?(this.w=h[0][2],this.h=h[0][3]):this.h=this.w=null;this.video=document.createElement("video");0<f.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;");f=this.file;h=this.file.lastIndexOf(".");-1!=h&&(f=this.file.substring(0,h));h=document.createElement("source");
h.setAttribute("src",f+".ogg");h.setAttribute("type","video/ogg");this.video.appendChild(h);h=document.createElement("source");h.setAttribute("src",f+".mp4");h.setAttribute("type","video/mp4");this.video.appendChild(h);h=document.createElement("source");h.setAttribute("src",f+".webm");h.setAttribute("type","video/webm");this.video.appendChild(h);d.childNodes[0]?d.insertBefore(this.video,d.childNodes[0]):d.appendChild(this.video)};a.extend(a.Video,a.Control);a.Video.prototype.update=function(){var a=
this.evaluator;0<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,e){a.Control.call(this,c,e);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 d=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);
d.childNodes[0]?d.insertBefore(this.containerControl,d.childNodes[0]):d.appendChild(this.containerControl);this.showAnswer=!1;this.text=void 0==this.text.type?this.rawText:this.text.hasFormula?this.rawText:this.text.toHTML();d=this.parent.lessonParser.parseText(this.answer);void 0!=d.type&&!this.text.hasFormula&&(this.answer=d.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=0<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=0<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 f=c.getContext("2d"),d=f.createLinearGradient(0,0,0,16),h,g=0;16>g;g++)h=e(g-5.6),d.addColorStop(g/16,"rgba(0,0,0,"+192*h*h/256/255+")");f.lineWidth=1;f.fillStyle="white";f.fillRect(0,0,20,16);f.fillStyle=d;f.fillRect(0,0,20,16);a.drawLine(f,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(f,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(f,1,0,1,16,"rgba(0,0,0,"+8/255+")");this.imageUnPush=c.toDataURL();f.fillStyle="white";f.fillRect(0,0,20,16);f.fillStyle=d;f.fillRect(0,0,20,16);a.drawLine(f,
0,0,0,14,"gray");a.drawLine(f,0,0,19,0,"gray");f.fillStyle="rgba(0, 0, 0,"+24/255+")";f.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,e=!1,d=!1,h=!1;this.activeCover.style.display=0<evaluator.evalExpression(this.activeif)?"none":"block";this.containerControl.style.display=0<evaluator.evalExpression(this.drawif)?"block":"none";var g=evaluator.evalExpression(this.expresion),
a=this.x!=g[0][0],e=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],h=this.h!=g[0][3],this.w=g[0][2],this.h=g[0][3]);(d||h||a||e)&&this.init()};a.TextArea.prototype.registerMouseEvents=function(){function a(c){c.preventDefault();e.showButton.style.backgroundImage="url("+e.imageUnPush+")"}var e=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();e.showAnswer=!e.showAnswer;e.textAreaAnswer.style.display=e.showAnswer?"block":"none";e.showButton.childNodes[0].childNodes[0].textContent=
e.showAnswer?"T":"S";e.showButton.style.backgroundImage="url("+e.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){var c={rowsNorth:0,rowsSouth:0,widthEast:125,widthWest:125,height:23};a=this.split(a);for(var f,d,h=0,g=a.length;h<
g;h++)switch(f=a[h][0],d=a[h][1],babel[f]){case "rowsNorth":c.rowsNorth=parseInt(d);break;case "rowsSouth":c.rowsSouth=parseInt(d);break;case "widthEast":c.widthEast=parseInt(d);break;case "widthWest":c.widthWest=parseInt(d);break;case "height":c.height=parseInt(d);break;case "about":c.about="true"==babel[d];break;case "config":c.config="true"==babel[d];break;case "init":c.init="true"==babel[d];break;case "clear":c.clear="true"==babel[d];break;default:console.log("----- attributo de Espacio no identificado: <"+
f+"> valor: <"+d+"> -----")}return c};a.LessonParser.prototype.parseSpace=function(e){var c={},f;e=this.split(e);for(var d,h=0,g=e.length;h<g;h++)switch(f=e[h][0],d=e[h][1],babel[f]){case "type":c.type=d;break;case "id":c.id=d;break;case "x":f=d;f="%"==f[f.length-1]?(this.parent.container.width*parseFloat(f)/100).toString():d;c.xExpr=this.parser.parse(f);break;case "y":f=d;f="%"==f[f.length-1]?(this.parent.container.height*parseFloat(f)/100).toString():d;c.yExpr=this.parser.parse(f);break;case "width":f=
d;"%"==f[f.length-1]?f=this.parent.container.width*parseFloat(f)/100:(f=parseFloat(d),f!=d&&(f=this.parent.container.width));c.w=f;break;case "height":f=d;"%"==f[f.length-1]?f=this.parent.container.height*parseFloat(f)/100:(f=parseFloat(d),f!=d&&(f=this.parent.container.height));c.h=f;break;case "drawif":c.drawif=this.parser.parse(d);break;case "fixed":c.fixed="true"==babel[d];break;case "scale":f=parseFloat(d);f!=d&&(f=48);c.scale=f;break;case "O.x":c.OxExpr=d;break;case "O.y":c.OyExpr=d;break;case "image":c.imageSrc=
d;break;case "bg_display":c.bg_display=babel[d];break;case "background":c.background=this.convertColor(d);break;case "net":c.net="false"==babel[d]?"":this.convertColor(d);break;case "net10":c.net10="false"==babel[d]?"":this.convertColor(d);break;case "axes":c.axes="false"==babel[d]?"":this.convertColor(d);break;case "text":c.text="false"==babel[d]?"":this.convertColor(d);break;case "numbers":c.numbers="true"==babel[d];break;case "x-axis":c.x_axis="false"==babel[d]?"":d;break;case "y-axis":c.y_axis=
"false"==babel[d]?"":d;break;case "sensitive_to_mouse_movements":c.sensitive_to_mouse_movements="true"==babel[d];break;case "cID":c.cID=d;break;case "R3":c.R3="true"==babel[d];break;case "render":c.render=babel[d];break;case "split":c.split="true"==babel[d];break;case "file":c.file=d;break;default:console.log("----- attributo de Espacio no identificado: <"+f+"> valor: <"+d+"> -----")}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){var c={};e=this.split(e);for(var f,d,h=0,g=e.length;h<g;h++)switch(f=e[h][0],d=e[h][1],babel[f]){case "id":c.id=d;break;case "type":c.type=babel[d.trim()];break;case "gui":c.gui=babel[d];break;case "region":c.region=babel[d];break;case "space":c.spaceID=d;break;case "name":c.name=d;break;case "expresion":c.expresion=this.parser.parse(d.replace(")(",
","));break;case "fixed":c.fixed="true"==babel[d];break;case "visible":c.visible="true"==babel[d];break;case "color":c.color=this.convertColor(d);break;case "colorInt":c.colorInt=this.convertColor(d);break;case "bold":"false"!=babel[d]&&(c.bold="bold");break;case "italics":"false"!=babel[d]&&(c.italics="italic");break;case "underlined":"false"!=babel[d]&&(c.underlined=!0);break;case "font_size":c.font_size=this.parser.parse(d);break;case "image":c.imageSrc=d;break;case "action":c.action=babel[d];
break;case "parameter":c.parameter=d;break;case "drawif":c.drawif=this.parser.parse(d);break;case "activeif":c.activeif=this.parser.parse(d);break;case "tooltip":c.tooltip=d;break;case "tooltipFont":c.tooltipFont=d;break;case "Explanation":c.Explanation=d;break;case "ExplanationFont":c.ExplanationFont=d;break;case "msg_pos":c.msg_pos=babel[d];break;case "cID":c.cID=d;break;case "value":f=d.replace(/&squot;/g,"'");f.match(/^\|/)&&(f="'"+f.substring(1),f.match(/\|$/)&&(f=f.substring(0,f.length-1)+"'"));
c.valueExpr=this.parser.parse(f);c.valueExprString=f;break;case "decimals":c.decimals=this.parser.parse(d);break;case "min":c.min=this.parser.parse(d);break;case "max":c.max=this.parser.parse(d);break;case "incr":0!=d&&(c.incr=this.parser.parse(d));break;case "discrete":c.discrete="true"==babel[d];break;case "onlyText":c.onlyText="true"==babel[d];break;case "evaluate":c.evaluate="true"==babel[d];break;case "answer":c.answer=d;break;case "exponentialif":c.exponentialif=parseFloat(d);break;case "size":c.size=
this.parser.parse(d);break;case "constraint":c.constraintExpr=d;break;case "text":c.rawText=d;f=this.parseText(d);d=0;for(var j=f.length;d<j;d++)f[d]=this.parser.parse(f[d],!1);c.text=f;break;case "trace":c.trace=this.convertColor(d);break;case "options":c.options=d;break;case "font":c.font=d;break;case "file":c.file=d;break;case "autoplay":c.autoplay="true"==babel[d];break;case "loop":c.loop="true"==babel[d];break;case "controls":c.controls="true"==babel[d];break;case "poster":c.poster=babel[d];
break;default:var k=f.indexOf("."),j=babel[f.substring(0,k)],k=babel[f.substring(k+1)];if("parameter"==j&&"font"==k){c.parameterFont=d;break}else if("Explanation"==j&&"font"==k){c.ExplanationFont=d;break}else if("tooltip"==j&&"font"==k){c.tooltipFont=d;break}console.log("----- attributo de control no identificado: <"+f+"> valor: <"+d+"> -----")}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,f,d){d={rotateExp:d,parameter:"t"};e=this.split(e);for(var h,g,j=
0,k=e.length;j<k;j++)switch(h=e[j][0],g=e[j][1],babel[h]){case "space":d.spaceID=g;break;case "type":d.type=babel[g];break;case "background":d.background="true"==babel[g];break;case "color":d.color=this.convertColor(g);break;case "drawif":d.drawif=this.parser.parse(g);break;case "abs_coord":d.abs_coord="true"==babel[g];break;case "expresion":"macro"!=d.type?(d.expresion=this.parser.parse(g),d.expresionString=g):d.expresion=g;break;case "trace":d.trace=this.convertColor(g);break;case "family":d.family=
g;break;case "parameter":d.parameter=g;break;case "fill":d.fill=this.convertColor(g);break;case "fillP":d.fillP=this.convertColor(g);break;case "fillM":d.fillM=this.convertColor(g);break;case "width":d.width=this.parser.parse(g);break;case "visible":d.visible="true"==babel[g];break;case "editable":d.editable="true"==babel[g];break;case "info":d.info=g;break;case "text":d.text=this.parseText(g);break;case "font":d.font=g;break;case "fixed":d.fixed="true"==babel[g];break;case "decimals":d.decimals=
this.parser.parse(g);break;case "size":d.size=this.parser.parse(g);break;case "spear":d.spear=this.parser.parse(g);break;case "arrow":d.arrow=this.convertColor(g);break;case "center":d.center=this.parser.parse(g);break;case "radius":d.radius=this.parser.parse(g);break;case "init":d.init=this.parser.parse(g);break;case "end":d.end=this.parser.parse(g);break;case "vectors":d.vectors="true"==babel[g];break;case "file":h=g.replace(/&squot;/g,"'");"["==h.charAt(0)&&"]"==h.charAt(h.length-1)&&(h=h.substring(1,
h.length-1));h.match(/.jpg$|.png$|.gif$|.svg$/)&&(h="'"+h+"'");d.file=this.parser.parse(h);break;case "inirot":d.inirot=this.parser.parse(g);break;case "opacity":d.opacity=this.parser.parse(g);break;case "inipos":d.inipos=this.parser.parse(g);break;case "name":d.name=g;break;case "range":d.range=this.parser.parse(g);break;case "border":"false"!=babel[g]&&(d.border=this.convertColor(g));break;case "align":d.align=babel[g];break;default:if(void 0!=d.family&&h.substring(0,d.family.length+1)==d.family+
"."){switch(babel[h.substring(d.family.length+1)]){case "interval":d.family_interval=this.parser.parse(g);break;case "steps":d.family_steps=this.parser.parse(g)}break}if(void 0!=d.parameter&&h.substring(0,d.parameter.length+1)==d.parameter+"."){switch(babel[h.substring(d.parameter.length+1)]){case "interval":d.parameter_interval=this.parser.parse(g);break;case "steps":d.parameter_steps=this.parser.parse(g)}break}console.log("----- attributo del grafico no identificado: <"+h+"> valor: <"+g+"> -----")}c&&
(d.abs_coord=c);f&&(d.background=f);if("equation"==d.type)return new a.Equation(this.parent,d);if("curve"==d.type)return new a.Curve(this.parent,d);if("sequence"==d.type)return new a.Sequence(this.parent,d);if("point"==d.type)return new a.Point(this.parent,d);if("segment"==d.type)return new a.Segment(this.parent,d);if("arrow"==d.type)return new a.Arrow(this.parent,d);if("polygon"==d.type)return new a.Polygon(this.parent,d);if("arc"==d.type)return new a.Arc(this.parent,d);if("text"==d.type)return new a.Text(this.parent,
d);if("image"==d.type)return new a.Image(this.parent,d);if("macro"==d.type)return new a.Macro(this.parent,d);if("fill"==d.type)return new a.Fill(this.parent,d)};a.LessonParser.prototype.parse3DGraphic=function(e,c,f,d){c={rotateExp:d,parameter:"t"};e=this.split(e);var h,g;f=0;for(d=e.length;f<d;f++)switch(h=e[f][0],g=e[f][1],babel[h]){case "space":c.spaceID=g;break;case "type":c.type=babel[g];break;case "background":c.background="true"==babel[g];break;case "color":c.color=this.convertColor(g);break;
case "drawif":c.drawif=this.parser.parse(g);break;case "expresion":"macro"!=c.type&&"curve"!=c.type&&"surface"!=c.type?(c.expresion=this.parser.parse(g),c.expresionString=g):c.expresion=g;break;case "family":c.family=g;break;case "parameter":c.parameter=g;break;case "width":c.width=this.parser.parse(g);break;case "length":c.length=this.parser.parse(g);break;case "text":h=this.parseText(g);g=0;for(var j=h.length;g<j;g++)h[g]=this.parser.parse(h[g],!1);c.text=h;break;case "font":c.font=g;break;case "fixed":c.fixed=
"true"==babel[g];break;case "decimals":c.decimals=this.parser.parse(g);break;case "file":h=g.replace(/&squot;/g,"'");"["==h.charAt(0)&&"]"==h.charAt(h.length-1)&&(h=h.substring(1,h.length-1));h.match(/./)&&(h="'"+h+"'");c.file=this.parser.parse(h);break;case "model":c.model=babel[g];break;case "edges":c.edges="true"==babel[g];break;case "Nu":c.Nu=this.parser.parse(g);break;case "Nv":c.Nv=this.parser.parse(g);break;case "name":c.name=g;break;case "backcolor":c.backcolor=this.convertColor(g);break;
case "inirot":c.inirot=this.parser.parse(g);break;case "endrot":c.endrot=this.parser.parse(g);break;case "inipos":c.inipos=this.parser.parse(g);break;case "endpos":c.endpos=this.parser.parse(g);break;default:if(void 0!=c.family&&h.substring(0,c.family.length+1)==c.family+"."){switch(babel[h.substring(c.family.length+1)]){case "interval":c.family_interval=this.parser.parse(g);break;case "steps":c.family_steps=this.parser.parse(g)}break}if(void 0!=c.parameter&&h.substring(0,c.parameter.length+1)==c.parameter+
"."){switch(babel[h.substring(c.parameter.length+1)]){case "interval":c.parameter_interval=this.parser.parse(g);break;case "steps":c.parameter_steps=this.parser.parse(g)}break}console.log("----- attributo del grafico no identificado: <"+h+"> valor: <"+g+"> -----")}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);if("mesh"==c.type)return new a.Mesh3D(this.parent,c);console.log(c.type)};a.LessonParser.prototype.parseAuxiliar=function(e){var c={};e=this.split(e);for(var f=0,d=e.length;f<d;f++)e[f][1]=e[f][1].replace(/&squot;/g,"'");for(var h,
g,f=0,d=e.length;f<d;f++)switch(h=e[f][0],g=e[f][1],babel[h]){case "id":c.id=g;break;case "editable":c.editable="true"==babel[g];break;case "constant":c.constant="true"==babel[g];break;case "array":c.array="true"==babel[g];break;case "file":c.file=g;break;case "matrix":c.matrix="true"==babel[g];break;case "rows":c.rows=this.parser.parse(g);break;case "columns":c.columns=this.parser.parse(g);break;case "algorithm":c.algorithm="true"==babel[g];break;case "init":c.init=g;break;case "do":c.doExpr=g;break;
case "while":c.whileExpr=g;break;case "range":c.range=g;break;case "expresion":c.expresion=g;break;case "size":c.size=this.parser.parse(g);break;case "evaluate":c.evaluate=babel[g];break;case "event":c.event=babel[g];break;case "condition":c.condition=g;break;case "execution":c.execution=babel[g];break;case "msg_pos":c.msg_pos=babel[g];break;case "action":c.action=babel[g];break;case "parameter":c.parameter=g;break;case "sequence":c.sequence="true"==babel[g];break;default:var j=h.indexOf("."),k=babel[h.substring(0,
j)],j=babel[h.substring(j+1)];if("parameter"==k&&"font"==j){c.parameterFont=g;break}console.log("----- attributo de auxiliar no identificado: <"+h+"> valor: <"+g+"> -----")}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?(c=new a.Algorithm(this.parent,c),this.parent.auxiliaries.push(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)?(c=new a.Event(this.parent,c),this.parent.events.push(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,f=e.parent;e=e.parameter;if(c)switch(c){case "message":return new a.Message(f,
e);case "calculate":return new a.Calculate(f,e);case "openURL":return new a.OpenURL(f,e);case "openScene":return new a.OpenScene(f,e);case "about":return new a.About(f,e);case "config":return new a.Config(f,e);case "init":return new a.Init(f,e);case "clear":return new a.Clear(f,e);case "animate":return new a.Animate(f,e);case "initAnimation":return new a.InitAnimation(f,e);case "playAudio":return new a.PlayAudio(f,e);default:console.log("----- Accion no soportada aun: <"+c+"> -----")}else return{execute:function(){}}};
a.LessonParser.prototype.parseAnimation=function(e){var c={};e=this.split(e);for(var f,d,h=0,g=e.length;h<g;h++)switch(f=e[h][0],d=e[h][1],babel[f]){case "delay":c.delay=d;break;case "controls":c.controls="true"==babel[d];break;case "auto":c.auto="true"==babel[d];break;case "loop":c.loop="true"==babel[d];break;case "init":c.init=d;break;case "do":c.doExpr=d;break;case "while":c.whileExpr=d;break;case "id":c.id=d;break;case "algorithm":c.algorithm="true"==babel[d];break;case "evaluate":c.evaluate=
"true"==babel[d];break;default:console.log("----- attributo de la animacion no identificado: <"+f+">  <"+d+"> -----")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(e,c){e=this.split(e);var f,d,h,g,j,k,m,n,q;d=f="";h=0;g="#536891";j="white";k="left";m="";n="SansSerif,BOLD,20";q="SansSerif,PLAIN,18";for(var l,p,u=0,s=e.length;u<s;u++)switch(l=e[u][0],p=e[u][1],l){case "title":f=p;break;case "subtitle":d=p;break;case "subtitlines":h=p;break;case "bgcolor":""!==p&&
(g="#"+a.getColor(this.evaluator,p));break;case "fgcolor":""!==p&&(j="#"+a.getColor(this.evaluator,p));break;case "align":""!==p&&(k=p);break;case "titleimage":m=p;break;case "titlefont":n=""!==p?a.convertFont(p):a.convertFont(n);break;case "subtitlefont":q=""!==p?a.convertFont(p):a.convertFont(q);break;default:console.log("----- attributo de la pleca no identificado: <"+l+">  <"+p+"> -----")}l=q.substring(0,q.indexOf("px"));l=l.substring(l.lastIndexOf(" "));var t,r;""!=m&&(t=this.parent.getImage(m),
r=t.height);m=document.createElement("div");m.setAttribute("id","descartesPleca");r?(m.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+k+"; width: "+(c-30)+"px; height: "+(r-16)+"px; background: "+g+"; color: "+j+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),t.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),m.appendChild(t)):m.setAttribute("style",
"position: absolute; left: 0px; top: 0px; text-align: "+k+"; width: "+(c-30)+"px; background: "+g+"; color: "+j+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");g=document.createElement("div");g.setAttribute("style","padding: 0px; margin: 0px; font: "+n+"; overflow: hidden; white-space: nowrap;");g.innerHTML=f;f=document.createElement("div");if(1==parseInt(h)){j=0;h=document.createElement("div");h.innerHTML=d;document.body.appendChild(h);
n=l;do n-=j,h.setAttribute("style","padding: 0px; margin: 0px; font: "+q+"; font-size: "+n+"px; width: "+(c-30)+"px; line-height: "+n+"px;"),j=h.offsetHeight,k=j/n,j=1;while(1<k&&8<n);document.body.removeChild(h);f.setAttribute("style","padding: 0px; margin: 0px; font: "+q+"; font-size: "+n+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else f.setAttribute("style","padding: 0px; margin: 0px; font: "+q+"; line-height: 110%;");f.innerHTML=d;m.appendChild(g);m.appendChild(f);m.imageHeight=
r;return m};a.LessonParser.prototype.split=function(a){if("string"!=typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");for(var c=[],f=0,d=0,h=!1,g=0,j=!1;f<a.length;){" "==a.charAt(f)&&!h&&f++;" "!=a.charAt(f)&&!h&&(h=!0,g=f);"="==a.charAt(f)&&("'"==a.charAt(f+1)&&!j)&&(j=!0,c[d]=[a.substring(g,f)],g=f+2,f+=2);j&&"'"==a.charAt(f)&&(h=j=!1,c[d].push(a.substring(g,f)),d++);if("="==a.charAt(f)&&"'"!=a.charAt(f+1)&&!j){c[d]=[a.substring(g,f)];g=f+1;f++;var h=a.substring(f).indexOf("="),k;-1==h?k=a.length:
(h+=f,k=a.substring(f,h).lastIndexOf(" "),k=-1==k?a.length:k+f);c[d].push(a.substring(g,k));d++;h=!1;f=k}f++}return c};a.LessonParser.prototype.splitComa=function(a){for(var c=[],f=[],d=0,h=0,g=a.length;h<g;h++)"("==a.charAt(h)?f.push(h):")"==a.charAt(h)?f.pop():","==a.charAt(h)&&0==f.length&&(c.push(a.substring(d,h)),d=h+1);c.push(a.substring(d));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]){var c="(";a=this.splitComa(a.substring(1,a.length-1));for(var f,d=0,h=a.length;d<h;d++)f=parseInt(a[d],16),a[d]!=f.toString(16)?("["==a[d].charAt(0)&&"]"==a[d].charAt(a[d].length-1)&&(a[d]=a[d].substring(1,a[d].length-1)),c=c+a[d]+(d<h-1?",":")")):c=c+f/255+(d<h-1?",":")");return this.parser.parse(c)}return"#aa0000"};a.LessonParser.prototype.parseText=
function(e){return e.match(/^\{\\rtf1/)?(new a.RTFParser(this.parent.evaluator)).parse(e.substring(10,e.length-1)):new a.SimpleText(e,this.parent)};return a}(descartesJS||{}),descartesJS=function(a){function e(a,c){k=[];k.type="matrix";k.rows=a;k.cols=c;var d;n=0;for(q=c;n<q;n++){d=[];m=0;for(l=a;m<l;m++)d.push(0);k[n]=d}return k}function c(a,c){g=a.rows;j=a.cols;k=e(g,j);var d;for(n=0;n<g;n++)for(m=0;m<j;m++){for(q=d=0;q<j;q++)d+=a[q][n]*c[m][q];k[m][n]=d}return k}function f(a,c,d){for(var f=e(d.length-
1,d.length-1),h=0,g=f.length;h<g;h++)for(var n=0;n<g;n++)f[h][n]=h<a?n<c?d[h][n]:d[h][n+1]:h<c?d[h+1][n]:d[h+1][n+1];return f}function d(a){if(1<a.cols){for(var c=0,e=1,h=0,g=a.cols;h<g;h++)c+=e*a[0][h]*d(f(0,h,a)),e=-e;return c}return a[0][0]}if(a.loadLib)return a;var h=Math.floor;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.setAllEvaluateFunction=function(){this.setEvaluateFunction();for(var a=0,c=this.childs.length;a<c;a++)this.childs[a].setAllEvaluateFunction()};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(){var c;if("compOperator"===this.type){this.type="operator";this.value="-";c=new a.Node("compOperator","==");var d=new a.Node("number","0");c.addChild(this);c.addChild(d);c=this.getRoot();c.setAllEvaluateFunction();return c}return this};a.Node.prototype.setEvaluateFunction=
function(){if("number"===this.type)this.evaluate=function(){return parseFloat(this.value)};else if("string"===this.type)this.evaluate=function(){return this.value};else if("identifier"===this.type&&0===this.childs.length)if("rnd"==this.value)this.evaluate=function(){return Math.random()};else{var a;this.evaluate=function(c,d){a=c.variables[this.value];if("object"===typeof a)return a.evaluate(c);void 0==a&&d&&(a=c.matrices[this.value]);return void 0!==a?a:0}}else if("identifier"===this.type&&"square_bracket"===
this.childs[0].type&&1===this.childs[0].childs.length){var l,q;this.evaluate=function(a){l=this.childs[0].childs[0].evaluate(a);try{return q=a.vectors[this.value][0>l?0:h(l)],void 0!==q?q:0}catch(c){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var t,r;this.evaluate=function(a){t=this.childs[0].childs[0].evaluate(a);r=this.childs[0].childs[1].evaluate(a);try{return q=a.matrices[this.value][0>t?0:h(t)][0>r?0:h(r)],void 0!==q?q:
0}catch(c){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var v;this.evaluate=function(a){v=[];for(var c=0,d=this.childs[0].childs.length;c<d;c++)v.push(this.childs[0].childs[c].evaluate(a));return"_Eval_"===this.value?a.evalExpression(a.parser.parse(v[0])):a.functions[this.value].apply(a,v)}}else if("operator"===this.type){var x,z,w;"+"===this.value?this.evaluate=function(a){x=this.childs[0].evaluate(a,!0);z=this.childs[1].evaluate(a,!0);if("matrix"!==x.type||"matrix"!==
z.type)return x+z;a=x;var c=z;g=a.rows;j=a.cols;k=e(g,j);for(n=0;n<g;n++)for(m=0;m<j;m++)k[m][n]=a[m][n]+c[m][n];return k}:"-"===this.value?this.evaluate=function(a){x=this.childs[0].evaluate(a,!0);z=this.childs[1].evaluate(a,!0);if("matrix"!==x.type||"matrix"!==z.type)return x-z;a=x;var c=z;g=a.rows;j=a.cols;k=e(g,j);for(n=0;n<g;n++)for(m=0;m<j;m++)k[m][n]=a[m][n]-c[m][n];return k}:"*"===this.value?this.evaluate=function(a){x=this.childs[0].evaluate(a,!0);z=this.childs[1].evaluate(a,!0);return"matrix"!==
x.type||"matrix"!==z.type?x*z:c(x,z)}:"/"===this.value?this.evaluate=function(a){x=this.childs[0].evaluate(a,!0);z=this.childs[1].evaluate(a,!0);if("matrix"!==x.type||"matrix"!==z.type)return x/z;a=x;var h;h=z;var g=e(h.length,h.length),n=d(h);if(0===n)h=0;else{var n=1/n,j;if(1<h.length)for(var l=0,q=h.length;l<q;l++){j=n;for(var p=0;p<q;p++)g[p][l]=j*d(f(l,p,h)),j=-j;n=-n}else g[0][0]=n;h=g}a=0===h?e(a.rows,a.cols):c(a,h);return a}:"%"===this.value?this.evaluate=function(a){x=this.childs[0].evaluate(a);
z=this.childs[1].evaluate(a);return x-h(x/z)*z}:"^"===this.value&&(this.evaluate=function(a){return Math.pow(this.childs[0].evaluate(a),this.childs[1].evaluate(a))})}else if("compOperator"===this.type)"<"===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<this.childs[1].evaluate(a))+0}:"<="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<=this.childs[1].evaluate(a))+0}:">"===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>this.childs[1].evaluate(a))+
0}:">="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>=this.childs[1].evaluate(a))+0}:"=="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)===this.childs[1].evaluate(a))+0}:"!="===this.value&&(this.evaluate=function(a){return(this.childs[0].evaluate(a)!=this.childs[1].evaluate(a))+0});else if("boolOperator"===this.type)"&"===this.value?this.evaluate=function(a){return(x=this.childs[0].evaluate(a)?1:0)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?
this.evaluate=function(a){return(x=this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){x=this.childs[0].evaluate(a)?1:0;return!x+0});else if("conditional"===this.type)this.evaluate=function(a){x=this.childs[0].evaluate(a);return 0<x?this.childs[1].evaluate(a):this.childs[2].evaluate(a)};else if("sign"===this.type)this.evaluate="sign+"===this.value?function(a){return this.childs[0].evaluate(a)}:function(a){return-this.childs[0].evaluate(a)};
else if("parentheses"===this.type)this.evaluate=function(a,c){return this.childs[0].evaluate(a,c)};else if("(expr)"===this.type||"[expr]"===this.type){var y,C;this.evaluate=function(a){y=this.childs.length;w=[];if(1===y&&1===this.childs[0].childs.length&&"(expr)"===this.type)w=this.childs[0].childs[0].evaluate(a);else for(var c=0;c<y;c++){C=[];for(var d=0,e=this.childs[c].childs.length;d<e;d++)C.push(this.childs[c].childs[d].evaluate(a));w[c]=C}return w}}else if("asign"===this.type){var B,D,E,A,G,
F;this.evaluate=function(a){B=this.childs[0];D=this.childs[1];1===B.childs.length&&"square_bracket"===B.childs[0].type?(l=B.childs[0].childs,1===l.length?(E=l[0].evaluate(a),E=0>E?0:h(E),a.vectors[B.value][E]=D.evaluate(a)):2===l.length&&(A=l[0].evaluate(a),G=l[1].evaluate(a),A=0>A?0:h(A),G=0>G?0:h(G),a.matrices[B.value][A][G]=D.evaluate(a))):(F=D.evaluate(a),F.type?a.matrices[B.value]=F:a.variables[B.value]=F)}}};var g,j,k,m,n,q,l;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(/\\u(\S+) /g,function(a,c){return String.fromCharCode(parseInt(c,16))}),a=a.replace(/\&sup(.+);/g,"^$1 "),a=a.replace(/&squot;/g,"'"),a.match(/\=\|\*/g)&&(a=a.replace("|*","'","g").replace("*|","'","g")));for(var f=[],d=!1,h=0,g,j=a,k=0,m="",n=function(a,c,d){f.push({type:a,value:c});j=j.slice(d);h+=d;k++;m=a};a&&h<a.length;)if(d=h,"'"==j[0]){for(g=1;"'"!=j[g];)if(g<j.length)g++;else{console.log(">Error, simbolo no conocido: ["+
j+"], en la cadena <<"+c+">>");return}g=j.substring(1,g);n("string",g,g.length+2)}else if(g=j.match(/^\s+/))j=j.slice(g[0].length),h+=g[0].length,k++;else if(g=j.match(/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/))"number"===m&&f.push({type:"operator",value:"*"}),n("identifier",g[0],g[0].length);else if(g=j.match(/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/))n("number",g[0],g[0].length);else if(g=j.match(/^==|^!=|^<=|^<|^>=|^>|^#/))d=g[0],"#"==d&&(d="!="),n("compOperator",
d,g[0].length);else if(g=j.match(/^\!|^\~|^\&\&|^\&|^\|\||^\|/))d=g[0],"||"==d?d="|":"&&"==d?d="&":"~"==d&&(d="!"),n("boolOperator",d,g[0].length);else if((g=j.match(/^=/))&&!j.match(/^==/))n("asign",g[0],g[0].length);else if(g=j.match(/^[\?\:]/))n("conditional",g[0],g[0].length);else if(g=j.match(/^[\+\-\*\/\%\^]/))n("operator",g[0],g[0].length);else if(g=j.match(/^\[|^\]/))n("square_bracket",g[0],g[0].length);else if(g=j.match(/^\(|^\)/))"number"===m&&"("===g[0]&&f.push({type:"operator",value:"*"}),
n("parentheses",g[0],g[0].length);else if(g=j.match(/^,/))n("separator",g[0],g[0].length);else if(g=j.match(/^;/))n("final_of_expresion",g[0],g[0].length);else if(d==h){console.log("Error, simbolo no conocido: ["+j+"], en la cadena <<"+c+">>");return}return f};a.Tokenizer.prototype.flatTokens=function(a){a=a||[];for(var c="",f=0,d=a.length;f<d;f++)c="string"==a[f].type?c+"&squot;"+a[f].value+"&squot;":c+a[f].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._Trace_=function(a){console.log(a);return 0};this.functions.esCorrecto=function(c,f){return a.esCorrecto(c,f,e)};this.functions.escorrecto=function(c,f){return a.escorrecto(c,f,e)};window.parent.location.href!==window.location.href&&(this.functions["parent.set"]=function(a,e){window.parent.postMessage({type:"set",name:a,value:e},"*")},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*")},this.functions["parent.get"]=function(a,e){window.parent.postMessage({type:"get",
name:a,value:e},"*")},this.functions["parent.exec"]=function(a,e){window.parent.postMessage({type:"exec",name:a,value:e},"*")})};a.Parser.prototype.setVariable=function(a,c){this.variables[a]=c};a.Parser.prototype.getVariable=function(a){return this.variables[a]};a.Parser.prototype.setVector=function(a,c,f){this.vectors[a][c]=f};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,f,d){this.matrices[a][c][f]=
d};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,f){f=f?f+".":"";var d=this.tokenizer.tokenize(e);d||(d=[]);var h=null,g;c=!c||!1;for(var j=0,k=0,m=0,n,q,l=
0,p=d.length;l<p;l++)if(g=d[l],n=g.value,q=g.type,"identifier"==q&&(l+1<p&&"parentheses"==d[l+1].type&&"("==d[l+1].value?this.getFunction(n):l+1<p&&"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(n):this.getMatrix(n):this.getVariable(f+n)),"asign"==q&&c&&(q="compOperator",n="=="),"asign"==q)if(g=new a.Node(q,n),null!=h)if("identifier"==h.type)h.parent&&h.parent.replaceLastChild(g),g.addChild(h),h=g,c=!0;else if("square_bracket"==
h.type)g.addChild(h.parent),h=g,c=!0;else{g.type="compOperator";g.value="==";for(c=!0;h.parent&&this.precedence(h.parent.value)>=this.precedence(g.value);)h=h.parent;h.parent&&h.parent.replaceLastChild(g);g.addChild(h);h=g}else{console.log("Error1: en la expresion <<"+e+">>, en el token {valor: "+n+", tipo: "+q+"}");break}else if("parentheses"==q&&"("==n||"square_bracket"==q&&"["==n)if(g=new a.Node(q,n),"("==n&&j++,"["==n&&k++,null==h)"("==n&&(h=new a.Node("(expr)","(expr)"),h.addChild(g)),"["==n&&
(h=new a.Node("[expr]","[expr]"),h.addChild(g)),h=g;else if("operator"==h.type||"boolOperator"==h.type||"compOperator"==h.type||"conditional"==h.type||"asign"==h.type)h.addChild(g),h=g;else if("sign"==h.type)h.addChild(g),h=g;else if("parentheses"==h.type&&"("==h.value)h.addChild(g),h=g;else if("square_bracket"==h.type&&"["==h.value)h.addChild(g),h=g;else if("parentheses"==h.type&&"()"==h.value)h.parent.addChild(g),h=g;else if("square_bracket"==h.type&&"[]"==h.value)h.parent.addChild(g),h=g;else if("identifier"==
h.type)h.addChild(g),h=g;else{console.log("Error2: en la expresion <<"+e+">>, en el token ["+l+"] {valor: "+n+", tipo: "+q+"}");break}else if("parentheses"==q&&")"==n)if(j--,null==h)console.log("Error3: en la expresion <<"+e+">>, en el token (valor:"+n+", tipo:"+q);else{for(;h&&h.parent&&"("!=h.value;)h=h.parent;if(h&&"("==h.value)h.value="()";else{console.log("Error4: en la expresion <<"+e+">>, en el token {valor: "+n+", tipo: "+q+"}");break}}else if("square_bracket"==q&&"]"==n)if(k--,null==h)console.log("Error5: en la expresion <<"+
e+">>, en el token (valor:"+n+", tipo:"+q);else{for(;h&&h.parent&&"["!=h.value;)h=h.parent;if(h&&"["==h.value)h.value="[]";else{console.log("Error6: en la expresion <<"+e+">>, en el token {valor: "+n+", tipo: "+q+"}");break}}else if("number"==q||"string"==q||"identifier"==q)if(g="identifier"==q?new a.Node(q,f+n):new a.Node(q,n),null==h)h=g;else if("operator"==h.type||"compOperator"==h.type||"boolOperator"==h.type||"parentheses"==h.type&&"("==h.value||"square_bracket"==h.type&&"["==h.value||"sign"==
h.type||"conditional"==h.type||"asign"==h.type)h.addChild(g),h=g;else{console.log("Error7: en la expresion <<"+e+">>, en el token {valor: "+n+", tipo: "+q+"}");break}else if("operator"==q||"compOperator"==q||"boolOperator"==q)if(g=new a.Node(q,n),null==h)if("-"==n||"+"==n)g.type="sign",g.value="sign"+n,h=g;else if("!"==n)h=g;else{console.log("Error8: en la expresion <<"+e+">>, en el token {valor: "+n+", tipo: "+q+"}");break}else if("operator"==h.type||"compOperator"==h.type||"boolOperator"==h.type||
"asign"==h.type||"conditional"==h.type||"square_bracket"==h.type&&"["==h.value&&("-"==n||"+"==n||"!"==n)||"parentheses"==h.type&&"("==h.value&&("-"==n||"+"==n||"!"==n)){if("-"==n||"+"==n)g.type="sign",g.value="sign"+n;h.addChild(g);h=g}else if("number"==h.type||"parentheses"==h.type&&"()"==h.value||"square_bracket"==h.type&&"[]"==h.value||"string"==h.type||"identifier"==h.type||"conditional"==h.type||"asign"==h.type){for(;h.parent&&this.precedence(h.parent.value)>=this.precedence(g.value);)h=h.parent;
h.parent&&h.parent.replaceLastChild(g);g.addChild(h);h=g}else{console.log("Error9: en la expresion <<"+e+">>, en el token {valor: "+n+", tipo: "+q+"}");break}else if("conditional"==q)if(g=new a.Node(q,n),null!=h)if("?"==g.value){for(m++;h.parent&&this.precedence(h.parent.value)>this.precedence(g.value);)h=h.parent;h.parent&&h.parent.replaceLastChild(g);g.addChild(h);h=g}else{for(m--;h&&h.parent&&"?"!=h.value;)h=h.parent;if(h&&"?"==h.value)h.value="?:";else{console.log("Error10: en la expresion <<"+
e+">>, en el token {valor: "+n+", tipo: "+q+"}");break}}else{console.log("Error11: en la expresion <<"+e+">>, en el token {valor: "+n+", tipo: "+q+"}");break}else if("separator"==q)if(null!=h)for(;h.parent&&"("!=h.value&&"["!=h.value;)h=h.parent;else{console.log("Error12: en la expresion <<"+e+">>, en el token {valor: "+n+", tipo: "+q+"}");break}else{console.log("Error13: en la expresion <<"+e+">>, en el token {valor: "+n+", tipo: "+q+"}");break}0<j&&console.log("Error, faltan parentesis por cerrar: "+
e);0>j&&console.log("Error, faltan parentesis por abrir: "+e);0<k&&console.log("Error, faltan corchetes por cerrar: "+e);0>k&&console.log("Error, faltan corchetes por abrir: "+e);0!=m&&console.log("Error, condicional incompleta: "+e);(e=h?h.getRoot():null)&&e.setAllEvaluateFunction();return e};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);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,e){this.variables[a]=e};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,f,d){f=0>f?0:e(f);this.vectors[a][f]=d};a.Evaluator.prototype.getVector=function(a,f){f=0>f?0:e(f);return this.vectors[a][f]};a.Evaluator.prototype.setMatrix=function(a,f,d,h){f=0>f?0:e(f);d=0>d?0:e(d);this.matrices[a][f][d]=h};a.Evaluator.prototype.getMatrix=
function(a,f,d){f=0>f?0:e(f);d=0>d?0:e(d);return this.matrices[a][f][d]};a.Evaluator.prototype.setFunction=function(a,e){this.functions[a]=e};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a){return a?a.evaluate(this):0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2,c=!1;a.RTFNode=function(a,c,d,e){this.evaluator=a;this.type="rtfNode";this.value=c;this.nodeType=d;this.style=e;this.styleString=
e.toString();this.color=e.textColor;this.underline=e.textUnderline;this.overline=e.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)};var f=0,d=0,h=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var g=0,j=this.childs.length;g<j;g++)this.childs[g].getTextMetrics()}else if("textLineBlock"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("newLine"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);var l=a.getFontMetrics(this.styleString);this.baseline=
l.baseline;this.descent=l.descent;this.ascent=l.ascent;this.width=l.width;this.height=l.height}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);l=a.getFontMetrics(this.styleString);this.baseline=l.baseline;this.descent=l.descent;this.ascent=l.ascent;var g=this.value,k;"string"!=typeof this.value&&(j=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),k=void 0==this.fixed?c:this.fixed,g=this.evaluator.evalExpression(this.value,
j,k),parseFloat(g)==g&&(g=parseFloat(g).toFixed(j),g=k?g:parseFloat(g),g=g.toString().replace(".",this.decimal_symbol)),g+=" ");this.width=a.getTextWidth(g,this.styleString);this.height=l.height}else if("formula"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("superIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),j=f,l=d,j=h,g=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.height&&(this.ascent=g.ascent,this.descent=
g.descent,this.height=this.ascent+this.descent,this.width=1.5*this.spaceWidth),g=j/2-l+this.height,this.superIndexPos=g-this.ascent,this.ascent=g,this.descent=l,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),j=f,l=d,g=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.height&&(this.ascent=g.ascent,this.descent=g.descent,this.height=this.ascent+this.descent,this.width=1.5*this.spaceWidth),
this.subIndexPos=l+1,this.ascent=j,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("fraction"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);l=d;j=h;k=this.childs[0];var m=this.childs[1],g=a.getFontMetrics(k.styleString);k.getBlockMetric();m.getBlockMetric();0>k.height&&(k.height=g.height,k.width=this.spaceWidth);0>m.height&&(m.height=g.height,m.width=this.spaceWidth);this.height=k.height+m.height-1;this.ascent=
k.height+j/2-l;this.descent=this.height-this.ascent;this.baseline=this.ascent;this.width=Math.max(k.width,m.width)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);l=this.childs[0].style.clone();if(1===this.childs.length)this.childs[1]=new a.RTFNode(this.evaluator,"","radicand",l),this.childs[1].addChild(this.childs[0]),this.childs[0]=new a.RTFNode(this.evaluator,"","index",l);else if("index"!==this.childs[0].nodeType||"radicand"!==this.childs[1].nodeType){k=
new a.RTFNode(this.evaluator,"","radicand",l);g=0;for(j=this.childs.length;g<j;g++)k.addChild(this.childs[g]);this.childs=[];this.childs[0]=new a.RTFNode(this.evaluator,"","index",l);this.childs[1]=k}l=this.childs[0];g=this.childs[1];l.getBlockMetric();g.getBlockMetric();this.ascent=g.height/2<l.height?g.height/2+l.height+2-g.descent:g.ascent+4;this.descent=g.descent;this.baseline=this.ascent;this.height=this.ascent+this.descent;this.width=l.width+g.width+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=
a.getTextWidth(" ",this.styleString),l=this.childs[0],j=this.childs[1],k=this.childs[2],l.getBlockMetric(),j.getBlockMetric(),k.getBlockMetric(),-1==l.ascent&&(m=a.getFontMetrics(l.styleString),l.ascent=m.ascent,l.descent=m.descent,l.height=m.height),-1==j.ascent&&(m=a.getFontMetrics(j.styleString),j.ascent=m.ascent,j.descent=m.descent,j.height=m.height),g=a.getFontMetrics(this.styleString),this.ascent=g.height+j.height>k.ascent?g.height-g.descent+j.height:k.ascent,this.descent=l.height>k.descent?
l.height+g.descent:k.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent,g=this.style.clone(),g.fontType="Times New Roman",g.Bold="bold",g=g.toString(),g=a.getTextWidth(String.fromCharCode(8721),g),this.width=Math.max(l.width,j.width,g)+Math.max(k.width,this.spaceWidth)+this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),l=this.childs[0],j=this.childs[1],k=this.childs[2],l.getBlockMetric(),j.getBlockMetric(),k.getBlockMetric(),
-1==l.ascent&&(m=a.getFontMetrics(l.styleString),l.ascent=m.ascent,l.descent=m.descent,l.height=m.height),-1==j.ascent&&(m=a.getFontMetrics(j.styleString),j.ascent=m.ascent,j.descent=m.descent,j.height=m.height),g=a.getFontMetrics(this.styleString),this.ascent=g.height+j.height>k.ascent?g.height-g.descent+j.height:k.ascent,this.descent=l.height>k.descent?l.height+g.descent:k.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent,g=this.style.clone(),g.fontSize*=1.5,g.fontType="Times New Roman",
g.Bold="bold",g=g.toString(),g=a.getTextWidth(String.fromCharCode(8747),g),this.width=Math.max(l.width,j.width,g)+Math.max(k.width,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),l=this.childs[0],j=this.childs[1],k=this.childs[2],g=a.getFontMetrics(this.styleString),l.getBlockMetric(),j.getBlockMetric(),k.getBlockMetric(),-1==l.ascent&&(m=a.getFontMetrics(l.styleString),l.ascent=m.ascent,l.descent=m.descent,l.height=m.height),
-1==j.ascent&&(m=a.getFontMetrics(j.styleString),j.ascent=m.ascent,j.descent=m.descent,j.height=m.height),-1==k.ascent&&(m=a.getFontMetrics(k.styleString),k.ascent=m.ascent,k.descent=m.descent,k.height=m.height),this.ascent=k.ascent,this.descent=Math.max(g.height,k.descent),this.baseline=this.ascent,this.height=this.ascent+this.descent,g=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==l.width&&(l.width=this.spaceWidth),0==j.width&&(j.width=this.spaceWidth),0==k.width&&(k.width=this.spaceWidth),
this.width=j.width+l.width+k.width+g+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);g=a.getFontMetrics(this.styleString);l=d;k=g.ascent;for(var m=g.descent,s=g.height,t=this.spaceWidth,r,v,g=0,j=this.childs.length;g<j;g++)this.childs[g].getBlockMetric(),r=this.childs[g].height,v=this.childs[g].width,s<r&&(s=r,k=this.childs[g].ascent,m=this.childs[g].descent),t<v&&(t=v);this.childWidth=t+2*this.spaceWidth;this.childHeight=s;this.childAscent=k;
this.childDescent=m;this.height=this.rows*s;this.ascent=this.height/2+l;this.descent=this.height-this.ascent;this.width=this.columns*this.childWidth+this.spaceWidth}else if("defparts"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);g=a.getFontMetrics(this.styleString);l=d;k=g.ascent;m=g.descent;s=g.height;t=this.spaceWidth;g=0;for(j=this.childs.length;g<j;g++)this.childs[g].getBlockMetric(),r=this.childs[g].height,v=this.childs[g].width,s<r&&(s=r,k=this.childs[g].ascent,m=this.childs[g].descent),
t<v&&(t=v);this.childWidth=t+2*this.spaceWidth;this.childHeight=s;this.childAscent=k;this.childDescent=m;this.height=this.parts*s;this.ascent=this.height/2+l;this.descent=this.height-this.ascent;this.width=t+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),l=a.getFontMetrics(this.styleString),this.baseline=l.baseline,this.descent=l.descent,this.ascent=l.ascent,this.width=a.getTextWidth(this.value,this.styleString)+a.getTextWidth(" ",this.styleString),
this.height=l.height):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),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.spaceWidth=a.getTextWidth(" ",this.styleString),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,c=-1,e,g=0,j=this.childs.length;g<j;g++){e=this.childs[g];e.getTextMetrics();childAscent=e.ascent;childDescent=e.descent;this.width+=e.width;var k=childDescent;e=e.height;f=childAscent;d=k;h=e;c<childAscent&&(c=childAscent);a<childDescent&&(a=childDescent)}this.ascent=c;this.descent=a;this.baseline=this.ascent;this.height=this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=
function(a,d,f,g,h,j){this.stableWidth||(this.getTextMetrics(),e=g,c=h);for(var k=h=g=0,m=this.childs.length;k<m;k++)0<k&&(h+=this.childs[k-1].height),"center"==j?g=-this.childs[k].width/2:"right"==j&&(g=-this.childs[k].width),this.childs[k].draw(a,d+g,f+h)};a.RTFNode.prototype.drawTextLineBlock=function(c,d,e){for(var f=0,g=0,h=this.childs.length;g<h;g++)0<g&&(f+=this.childs[g-1].width,"formula"==this.childs[g-1].nodeType&&(f+=2*a.getTextWidth(" ",this.childs[g].styleString))),this.childs[g].draw(c,
d+f,e+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,c,d){for(var e=0,f=0,g=this.childs.length;f<g;f++)0<f&&(e+=this.childs[f-1].width),this.childs[f].draw(a,c+this.spaceWidth+e,d)};a.RTFNode.prototype.drawText=function(a,c,d){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,c-1,d);if(this.underline){var e="bold"==this.style.textBold,f=e?1:0.5;a.lineWidth=e?2:1;null!=this.color&&(a.strokeStyle=this.color);
a.beginPath();a.moveTo(c-1,parseInt(d+this.descent/2)+f);a.lineTo(c-1+this.width,parseInt(d+this.descent/2)+f);a.stroke()}this.overline&&(f=(e="bold"==this.style.textBold)?2:1.5,a.lineWidth=e?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(c-1,parseInt(d-this.ascent)+f),a.lineTo(c-1+this.width,parseInt(d-this.ascent)+f),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(d,f,g){var h=Math.floor(0.5*this.spaceWidth),j=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),
k=void 0==this.fixed?c:this.fixed,m=this.evaluator.evalExpression(this.value,j,k);parseFloat(m)==m&&(m=k?parseFloat(m).toFixed(j):parseFloat(parseFloat(m).toFixed(j)),m=(""+m).replace(".",this.decimal_symbol));null!=this.color&&(d.fillStyle=this.color);d.font=this.styleString;d.textAlign="start";d.textBaseline="alphabetic";this.width=a.getTextWidth(m,this.styleString);d.fillText(m,h+f,g);this.underline&&(k=(j="bold"==this.style.textBold)?1:0.5,d.lineWidth=j?2:1,null!=this.color&&(d.strokeStyle=this.color),
d.beginPath(),d.moveTo(h+f-1,parseInt(g+this.descent/2)+k),d.lineTo(h+f-1+this.width,parseInt(g+this.descent/2)+k),d.stroke());this.overline&&(k=(j="bold"==this.style.textBold)?2:1.5,d.lineWidth=j?2:1,null!=this.color&&(d.strokeStyle=this.color),d.beginPath(),d.moveTo(h+f-1,parseInt(g-this.ascent)+k),d.lineTo(h+f-1+this.width,parseInt(g-this.ascent)+k),d.stroke());this.width+=2*h};a.RTFNode.prototype.drawRadical=function(a,c,d){var e=Math.floor(this.spaceWidth);this.childs[0].draw(a,c,Math.floor(d+
this.childs[1].descent-this.childs[1].height/2-this.childs[0].descent));this.childs[1].draw(a,c+1.5*e+this.childs[0].width,d);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(c,Math.floor(d+this.childs[1].descent-this.childs[1].height/2));a.lineTo(c+this.childs[0].width,Math.floor(d+this.childs[1].descent-this.childs[1].height/2));a.lineTo(c+this.childs[0].width+0.5*e,d+this.childs[1].descent);a.lineTo(c+this.childs[0].width+1*e,d-this.childs[1].ascent);a.lineTo(c+
this.childs[0].width+2*e+this.childs[1].width,d-this.childs[1].ascent);a.stroke()};a.RTFNode.prototype.drawFraction=function(a,c,d){this.childs[0].draw(a,c+(this.width-this.childs[0].width)/2,d-this.ascent);this.childs[1].draw(a,c+(this.width-this.childs[1].width)/2,d-this.ascent+this.childs[0].height-1);var e=Math.floor(0.5*this.spaceWidth);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(c+e,parseInt(d-this.ascent+this.childs[0].height)+0.5);a.lineTo(c-e+this.width-
1,parseInt(d-this.ascent+this.childs[0].height)+0.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,c,d){for(var e=0,f=0,g=this.childs.length;f<g;f++)0<f&&(e+=this.childs[f-1].width),this.childs[f].draw(a,c+e,d+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,c,d){for(var e=0,f=0,g=this.childs.length;f<g;f++)0<f&&(e+=this.childs[f-1].width),this.childs[f].draw(a,c+e,d+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,c,d){for(var e=0,f=0,g=this.childs.length;f<g;f++)0<
f&&(e+=this.childs[f-1].width),this.childs[f].draw(a,c+e,d-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(c,d,e){var f=a.getFontMetrics(this.styleString),g=" "+String.fromCharCode(8594),h=a.getTextWidth(g,this.styleString);this.childs[0].draw(c,d,e+f.descent+this.childs[0].ascent);this.childs[1].draw(c,d+this.childs[0].width+h,e+f.descent+this.childs[1].ascent);this.childs[2].draw(c,d+h+this.childs[0].width+this.childs[1].width,e);null!=this.color&&(c.fillStyle=this.color);c.font=this.styleString;
c.textAlign="start";c.textBaseline="alphabetic";c.fillText("l\u00edm",d+this.childs[0].width,e);c.fillText(g,d+this.childs[0].width,e+f.descent+this.childs[0].ascent)};a.RTFNode.prototype.drawIntegral=function(c,d,e){var f=this.style.clone();f.fontSize*=1.5;f.fontType="Times New Roman";f.Bold="bold";var f=f.toString(),g=a.getTextWidth(String.fromCharCode(8747),f),h=a.getFontMetrics(f),j=Math.max(this.childs[0].width,this.childs[1].width,Math.floor(1.5*g));this.childs[0].draw(c,d+g,e+h.descent+this.childs[0].ascent);
this.childs[1].draw(c,d+g+this.spaceWidth/2,e-this.ascent+this.childs[1].ascent);this.childs[2].draw(c,d+j+g,e);null!=this.color&&(c.fillStyle=this.color);c.font=f;c.textAlign="start";c.textBaseline="alphabetic";c.fillText(String.fromCharCode(8747),d,e+h.descent/2)};a.RTFNode.prototype.drawSum=function(c,d,e){var f=this.style.clone();f.fontType="Times New Roman";f.Bold="bold";var f=f.toString(),g=a.getTextWidth(String.fromCharCode(8721),f),h=a.getFontMetrics(this.styleString),j=Math.max(this.childs[0].width,
this.childs[1].width,g);this.childs[0].draw(c,d+(j-this.childs[0].width)/2,e+h.descent+this.childs[0].ascent);this.childs[1].draw(c,d+(j-this.childs[1].width)/2,e-h.ascent-this.childs[1].descent);this.childs[2].draw(c,d+j,e);null!=this.color&&(c.fillStyle=this.color);c.font=f;c.textAlign="start";c.textBaseline="alphabetic";c.fillText(String.fromCharCode(8721),d+Math.floor((j-g)/2),e-5)};a.RTFNode.prototype.drawMatrix=function(a,c,d){for(var e,f,g=0,h=this.childs.length;g<h;g++)e=g%this.columns,f=
Math.floor(g/this.columns),this.childs[g].draw(a,2*this.spaceWidth+c+e*this.childWidth,d-this.ascent+this.childAscent+f*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(c+this.spaceWidth)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.spaceWidth/2)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.spaceWidth/2)+0.5,d+this.descent+0.5);a.lineTo(Math.floor(c+this.spaceWidth)+0.5,d+this.descent+0.5);a.moveTo(Math.floor(c+this.width-this.spaceWidth)-
0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.width-this.spaceWidth/2)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.width-this.spaceWidth/2)-0.5,d+this.descent+0.5);a.lineTo(Math.floor(c+this.width-this.spaceWidth)-0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawDefparts=function(a,c,d){for(var e=0,f=this.childs.length;e<f;e++)this.childs[e].draw(a,c+this.spaceWidth/4,d-this.ascent+this.childAscent+e%this.parts*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=
this.color);a.beginPath();a.moveTo(Math.floor(c+this.spaceWidth/3)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.spaceWidth/6)+0.5,d-this.ascent+0.5+(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(c+this.spaceWidth/6)+0.5,d+this.descent-this.height/2-(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(c+0.5,d+this.descent-this.height/2);a.lineTo(Math.floor(c+this.spaceWidth/6)+0.5,d+this.descent-this.height/2+(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(c+this.spaceWidth/
6)+0.5,d+this.descent+0.5-(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(c+this.spaceWidth/3)+0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawMathSymbol=function(a,c,d){a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color,a.fillStyle=this.color);a.beginPath();"("==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText("(",c,d)):")"==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText(")",
c+this.spaceWidth,d)):(a.font=this.styleString,a.textAlign="center",a.textBaseline="alphabetic",a.fillText(this.value,c+this.width/2,d))};a.RTFNode.prototype.drawGenericBlock=function(a,c,d){for(var e=0,f=0,g=this.childs.length;f<g;f++)0<f&&(e+=this.childs[f-1].width),this.childs[f].draw(a,c+e,d)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,c,d){this.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+c+","+(d-this.parent.ascent)+","+this.componentNumCtrl.w+","+
this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,c,d){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(c+"");this.componentSpace.yExpr=this.evaluator.parser.parse(d-this.parent.ascent+"")};a.RTFNode.prototype.draw=function(a,c,d){console.log(">>> Dibujo desconocido ",this.nodeType);this.childs[0].draw(a,c,d)};var g=document.createElement("span");g.appendChild(document.createTextNode("\u00c1p Texto"));var j=document.createElement("div");j.setAttribute("style",
"display: inline-block; width: 1px; height: 0px;");var k=document.createElement("div");k.setAttribute("style","margin: 0; padding: 0;");k.appendChild(g);k.appendChild(j);var m={};a.getFontMetrics=function(a){if(m[a])return m[a];g.setAttribute("style","font: "+a+"; margin: 0; padding: 0;");document.body.appendChild(k);var c={};j.style.verticalAlign="baseline";c.ascent=j.offsetTop-g.offsetTop;j.style.verticalAlign="bottom";c.height=j.offsetTop-g.offsetTop;c.descent=c.height-c.ascent;c.baseline=c.ascent;
document.body.removeChild(k);return m[a]=c};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,c){return String.fromCharCode(parseInt(c))}),a=a.replace(/\\{/g,String.fromCharCode(0)),a=a.replace(/\\}/g,String.fromCharCode(1)),a=a.replace(/&squot;/g,"'"),a=a.replace(/&amp;/g,"&"),a=a.replace(/&lt;/g,"<"),a=a.replace(/&gt;/g,
">"));for(var c=[],f=a,d=0,h=0,g,j,k,m,n=function(a,e,g){c.push({type:a,value:e});f=f.slice(g);d+=g};a&&d<a.length;)if(j=d,"{"==f.charAt(0))h++,n("openBlock",h,1);else if("}"==f.charAt(0))n("closeBlock",h,1),h--,""==f&&(d=a.length);else if((g=f.match(/^\\([\w\*]*)\\/))&&g[1])g=g[1],n("controlWord",g,g.length+1),d-=1;else if((g=f.match(/^\\(\w*)\s/))&&g[1])g=g[1],n("controlWord",g,g.length+2);else if((g=f.match(/^\\(\w*)\{/))&&g[1])g=g[1],n("controlWord",g,g.length+1),d-=1;else if((g=f.match(/^\\(\w*)\}/))&&
g[1])g=g[1],n("controlWord",g,g.length+1),d-=1;else if((g=f.match(/^\\(\w*)\;\\/))&&g[1])g=g[1],n("controlWord",g,g.length+2),d-=1;else if((g=f.match(/^\\(\w*)\;\}/))&&g[1])g=g[1],n("controlWord",g,g.length+2),d-=1;else if((g=f.match(/^\\(\w*)/))&&g[1])g=g[1],n("controlWord",g,g.length+1),d=a.length;else if("{"!=f.charAt(0)&&"}"!=f.charAt(0)&&"\\"!=f.charAt(0))g=f.indexOf("{"),j=f.indexOf("}"),k=f.indexOf("\\"),m=f.length,g=-1==g?m+1:g,j=-1==j?m+1:j,k=-1==k?m+1:k,g=Math.min(g,j,k),-1!=g&&0!=g?(n("text",
f.substring(0,g).replace(String.fromCharCode(0),"{").replace(String.fromCharCode(1),"}"),g),""==f&&(d=a.length)):(n("text",f.replace(String.fromCharCode(0),"{").replace(String.fromCharCode(1),"}"),f.length+1),d=a.length);else if(j==d){console.log("Error, simbolo no conocido: <<["+f+"]>>");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){e=this.tokenizer.tokenize(e);
e=checkMathSymboslInFormula(e);var c={},f,d=2;if("openBlock"==e[0].type&&"fonttbl"==e[1].value){for(f=e[0].value;"closeBlock"!=e[d].type&&e[d].value!=f;)c[e[d].value]=e[d+2].value.substring(0,e[d+2].value.length-1),d+=3;d++}var h={},g=0,j,k,m;if("openBlock"==e[d].type&&"colortbl"==e[d+1].value){f=e[d++].value;for(d++;"closeBlock"!=e[d].type&&e[d].value!=f;)j=parseInt(e[d++].value.substring(3)).toString(16),k=parseInt(e[d++].value.substring(5)).toString(16),m=parseInt(e[d++].value.substring(4)).toString(16),
h[g++]="#"+(2>j.length?"0"+j:j)+(2>k.length?"0"+k:k)+(2>m.length?"0"+m:m);d++}f=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");g=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");f.addChild(g);for(var n,q,l,p=m=k=j=!1,u=!1,s=!1,t=[new a.FontStyle(20,"Arial","","",!1,!1,null)],r=t[0],v=!0,x=-1,z=-1,w=[],y=!1,C=!1,B=!1,D=!1,E=e.length;d<E;d++)if("controlWord"==e[d].type&&c[e[d].value])r.fontType=c[e[d].value];else if("controlWord"==e[d].type&&e[d].value.match(/^fs(\d+)/))r.fontSize=parseInt(e[d].value.match(/^fs(\d+)/)[1]/
2);else if("controlWord"==e[d].type&&"b"==e[d].value)r.textBold="bold";else if("controlWord"==e[d].type&&"b0"==e[d].value)r.textBold="";else if("controlWord"==e[d].type&&"i"==e[d].value)r.textItalic="italic";else if("controlWord"==e[d].type&&"i0"==e[d].value)r.textItalic="";else if("controlWord"==e[d].type&&"ul"==e[d].value)r.textUnderline=!0;else if("controlWord"==e[d].type&&"ulnone"==e[d].value)r.textUnderline=!1;else if("controlWord"==e[d].type&&"ol"==e[d].value)r.textOverline=!0;else if("controlWord"==
e[d].type&&"olnone"==e[d].value)r.textOverline=!1;else if("controlWord"==e[d].type&&e[d].value.match(/^cf(\d+)/))r.textColor=h[parseInt(e[d].value.substring(2))];else if("openBlock"==e[d].type)x=e[d].value,r=r.clone(),t.push(r),w.push(null);else if("closeBlock"==e[d].type)e[d].value==z&&(z=-1,j=!1,g=g.parent),t.pop(),r=t[t.length-1],w.pop();else if("controlWord"==e[d].type&&"par"==e[d].value){g.addChild(new a.RTFNode(this.evaluator,"","newLine",r.clone()));f=new a.RTFNode(this.evaluator,"","textLineBlock",
r.clone());if("textBlock"!=g.nodeType)for(g=g.parent;"textBlock"!=g.nodeType;)g=g.parent;g.addChild(f);g=f}else if("controlWord"==e[d].type&&"mjaformula"==e[d].value)y=!0,z=x,j=!0,f=new a.RTFNode(this.evaluator,"","formula",r.clone()),g.addChild(f),g=f,w[w.length-1]=f;else if("controlWord"==e[d].type&&("fraction"==e[d].value||"radicand"==e[d].value||"radical"==e[d].value||"what"==e[d].value||"sum"==e[d].value||"integral"==e[d].value||"limit"==e[d].value)){var A=w[w.length-2].style.clone();f=new a.RTFNode(this.evaluator,
"",e[d].value,A);w[w.length-2].addChild(f);w[w.length-1]=f}else if("controlWord"==e[d].type&&"index"==e[d].value||"to"==e[d].value||"from"==e[d].value)A=w[w.length-2].style.clone(),A.fontSize=parseInt(A.fontSize-0.2*A.fontSize),8>A.fontSize&&(A.fontSize=8),f=new a.RTFNode(this.evaluator,"",e[d].value,A),w[w.length-2].addChild(f),w[w.length-1]=f;else if("controlWord"==e[d].type&&("num"==e[d].value||"den"==e[d].value))A=w[w.length-2].style.clone(),A.fontSize=Math.round(A.fontSize-0.1*A.fontSize),8>
A.fontSize&&(A.fontSize=8),"num"==e[d].value?f=new a.RTFNode(this.evaluator,"","numerator",A):"den"==e[d].value&&(f=new a.RTFNode(this.evaluator,"","denominator",A)),w[w.length-2].addChild(f),w[w.length-1]=f;else if("controlWord"==e[d].type&&("subix"==e[d].value||"supix"==e[d].value))A=w[w.length-2].style.clone(),A.fontSize=Math.floor(A.fontSize-A.fontSize/3),8>A.fontSize&&(A.fontSize=8),"subix"==e[d].value?f=new a.RTFNode(this.evaluator,"","subIndex",A):"supix"==e[d].value&&(f=new a.RTFNode(this.evaluator,
"","superIndex",A)),f.originalStyle=w[w.length-2].style.clone(),w[w.length-2].addChild(f),w[w.length-1]=f;else if("controlWord"==e[d].type&&("defparts"==e[d].value||"matrix"==e[d].value||"element"==e[d].value))A=w[w.length-2].style.clone(),f=new a.RTFNode(this.evaluator,"",e[d].value,A),w[w.length-2].addChild(f),w[w.length-1]=f,"defparts"==e[d].value?l=f:"matrix"==e[d].value&&(q=f);else if("controlWord"==e[d].type&&"parts"==e[d].value)s=!0;else if("text"==e[d].type&&s)l.parts=parseInt(e[d].value),
s=!1;else if("controlWord"==e[d].type&&"rows"==e[d].value)p=!0;else if("text"==e[d].type&&p)q.rows=parseInt(e[d].value),p=!1;else if("controlWord"==e[d].type&&"columns"==e[d].value)u=!0;else if("text"==e[d].type&&u)q.columns=parseInt(e[d].value),u=!1;else if("controlWord"==e[d].type&&"expr"==e[d].value)v=!1,k=!0;else if("controlWord"==e[d].type&&"decimals"==e[d].value)m=!0;else if("text"==e[d].type&&m)n.decimals=this.evaluator.parser.parse(parseInt(e[d].value)+""),m=!1;else if("controlWord"==e[d].type&&
"fixed1"==e[d].value)n.fixed=!0;else if("controlWord"==e[d].type&&"fixed0"==e[d].value)n.fixed=!1;else if(!("controlWord"==e[d].type&&"component"==e[d].value))if("controlWord"==e[d].type&&"NumCtrl"==e[d].value)C=!0;else if("controlWord"==e[d].type&&"Space"==e[d].value)B=!0;else if("controlWord"==e[d].type&&"hyperlink"==e[d].value)D=!0;else if("text"==e[d].type&&D){textContent=e[d].value.split("|")[0];A=r.clone();A.textUnderline=!0;A.textColor="blue";f=new a.RTFNode(this.evaluator,textContent,"text",
A);if("textLineBlock"!=g.nodeType)for(g=g.parent;"textLineBlock"!=g.nodeType;)g=g.parent;g.addChild(f);D=!1}else if("text"==e[d].type&&C)f=new a.RTFNode(this.evaluator,e[d].value,"componentNumCtrl",r.clone()),g.addChild(f),C=!1;else if("text"==e[d].type&&B)f=new a.RTFNode(this.evaluator,e[d].value,"componentSpace",r.clone()),g.addChild(f),B=!1;else if("text"==e[d].type&&k)A=w[w.length-2].style.clone(),textContent=this.evaluator.parser.parse("''+("+e[d].value+")"),f=new a.RTFNode(this.evaluator,textContent,
"dynamicText",A),w[w.length-2].addChild(f),n=w[w.length-1]=f,k=!1;else if("text"==e[d].type&&!k&&!j){textContent=e[d].value;f=new a.RTFNode(this.evaluator,textContent,"text",r.clone());if("textLineBlock"!=g.nodeType)for(g=g.parent;"textLineBlock"!=g.nodeType;)g=g.parent;g.addChild(f)}else if("text"==e[d].type&&!k&&j)textContent=e[d].value,f=new a.RTFNode(this.evaluator,textContent,"text",w[w.length-1].style.clone()),w[w.length-1].addChild(f);else if("("==e[d].type||")"==e[d].type)A=w[w.length-1].style.clone(),
A.textItalic="",f=new a.RTFNode(this.evaluator,e[d].type,"mathSymbol",A),w[w.length-1].addChild(f);else if("+"==e[d].type||"-"==e[d].type||"*"==e[d].type||"="==e[d].type)f=new a.RTFNode(this.evaluator,e[d].type,"mathSymbol",w[w.length-1].style.clone()),w[w.length-1].addChild(f);if(null!=g){var G=g.getRoot();G.stableWidth=v;G.getTextMetrics();G.hasFormula=y}return G};a.FontStyle=function(a,c,f,d,h,g,j){this.fontSize=a;this.fontType=c;this.textItalic=f;this.textBold=d;this.textUnderline=h;this.textOverline=
g;this.textColor=j};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=[],f=!1,d=!1,h=[],g=0,j=a.length;g<j;g++){"openBlock"==a[g].type&&h.push(a[g].value);"closeBlock"==a[g].type&&(h.pop(),0>=h.length&&(f=!1));if("controlWord"==a[g].type&&("expr"==a[g].value||"decimals"==a[g].value))d=!0;"controlWord"==a[g].type&&"mjaformula"==a[g].value&&(f=!0);if("text"==a[g].type&&f&&!d){for(var k=0,m=a[g].value,n="",q=0,l=m.length;q<l;q++)if("("==m.charAt(q)||")"==m.charAt(q)||
"+"==m.charAt(q)||"-"==m.charAt(q)||"*"==m.charAt(q)||"="==m.charAt(q))n=m.substring(k,q),""!=n&&c.push({type:"text",value:n}),c.push({type:m.charAt(q),value:m.charAt(q)}),k=q+1;n=m.substring(k,q);""!=n&&c.push({type:"text",value:n})}else c.push(a[g]),"text"==a[g].type&&d&&(d=!1)}return c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Space=function(a,e){this.parent=a;this.evaluator=this.parent.evaluator;var d=this.evaluator.parser;this.values=e;this.type=
"R2";this.xExpr=d.parse("0");this.yExpr=d.parse("0");this.w=parseInt(a.container.width);this.h=parseInt(a.container.height);this.drawif=d.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||this.parent.arquimedes?"#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.x_axis=2!=this.parent.version?"":" ";this.y_axis=2!=this.parent.version?"":" ";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 h in e)e.hasOwnProperty(h)&&
(this[h]=e[h]);this.init()};a.Space.prototype.init=function(){this.displaceRegionNorth=this.parent.displaceRegionNorth||0;this.displaceRegionWest=this.parent.displaceRegionWest||0;var a=this.parent,e=this.evaluator,d=this.id,h,g=parseInt(this.parent.container.height),j=parseInt(this.parent.container.width);e.setVariable(d+"._w",this.w);e.setVariable(d+"._h",this.h);this.x=e.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=e.evalExpression(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;
this.container&&(this.container.style.left=this.x+"px",this.container.style.top=this.y+"px");"_BASE_"==this.id&&(0<=this.y?(h=g-this.y,this.h>h&&(this.h=h)):(h=this.h+this.y,this.h=h>=g?g:h),0<=this.x?(h=j-this.x,this.w>h&&(this.w=h)):(h=this.w+this.x,this.w=h>=j?j:h));if(""!=this.imageSrc||!this.imageSrc.toLowerCase().match(/vacio.gif$/))this.image=a.getImage(this.imageSrc);this.OxExpr&&(j=this.OxExpr,"%"==j[j.length-1]?this.Ox=this.w*parseFloat(j)/100:(a=parseFloat(j),a!=j&&(a=0),this.Ox=a));this.OyExpr&&
(j=this.OyExpr,"%"==j[j.length-1]?this.Oy=this.h*parseFloat(j)/100:(a=parseFloat(j),a!=j&&(a=0),this.Oy=a));2!=this.parent.version?(e.setVariable(d+"._w",this.w),e.setVariable(d+"._h",this.h),e.setVariable(d+".escala",this.scale),e.setVariable(d+".Ox",this.Ox),e.setVariable(d+".Oy",this.Oy),e.setVariable(d+".mouse_x",0),e.setVariable(d+".mouse_y",0),e.setVariable(d+".mouse_pressed",0)):(d=this.evaluator.getVariable("_w"),void 0==d&&(d=this.w),e.setVariable("_w",d),d=this.evaluator.getVariable("_h"),
void 0==d&&(d=this.h),e.setVariable("_h",d),d=this.evaluator.getVariable("escala"),void 0==d&&(d=this.w),e.setVariable("escala",d),d=this.evaluator.getVariable("Ox"),void 0==d&&(d=this.Ox),e.setVariable("Ox",d),d=this.evaluator.getVariable("Oy"),void 0==d&&(d=this.Oy),e.setVariable("Oy",d),e.setVariable("mouse_x",0),e.setVariable("mouse_y",0),e.setVariable("mouse_pressed",0),""==this.x_axis&&""==this.y_axis&&(this.axes=""))};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,e;for(this.offsetTop=this.offsetLeft=0;a;){e=null;a.getAttribute&&
(e=a.getAttribute("class"));if(e&&("DescartesSpace2DContainer"==e||"DescartesAppContainer"==e))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,f=2*Math.PI;a.Space2D=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","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.parent.arquimedes&&"#f0f8fa"===a.getColor(this.evaluator,this.background)&&this.container.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+
"; border: 1px solid #b8c4c8;");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.findOffset();this.parent.images[this.id+".image"]=this.canvas;this.parent.images[this.id+".image"].ready=1;this.parent.images[this.id+".image"].complete=!0;this.evaluator.setVariable(this.id+".image",this.id+
".image");this.parent.images[this.id+".back"]=this.backgroundCanvas;this.parent.images[this.id+".back"].ready=1;this.parent.images[this.id+".back"].complete=!0;this.evaluator.setVariable(this.id+".back",this.id+".back");this.drawBefore=0<this.evaluator.evalExpression(this.drawif);"descartesJS_scenario"!==this.id&&this.registerMouseEvents()};a.extend(a.Space2D,a.Space);var d;a.Space2D.prototype.update=function(a){var c=2!=this.parent.version?this.id+".Ox":"Ox",e=2!=this.parent.version?this.id+".Oy":
"Oy",f=2!=this.parent.version?this.id+".escala":"escala",m=this.evaluator;m.setVariable(this.id+"._w",this.w);m.setVariable(this.id+"._h",this.h);var n=this.x!=m.evalExpression(this.xExpr)+this.displaceRegionWest,q=this.y!=m.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.spaceChange=a||n||q||this.drawBefore!=0<m.evalExpression(this.drawif)||this.Ox!=m.getVariable(c)||this.Oy!=m.getVariable(e)||this.scale!=m.getVariable(f);this.x=n?m.evalExpression(this.xExpr)+this.displaceRegionWest:
this.x;this.y=q?m.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;this.Ox=m.getVariable(c);this.Oy=m.getVariable(e);this.scale=m.getVariable(f);this.drawBefore=0<m.evalExpression(this.drawif);1E-6>this.scale?(this.scale=1E-6,m.setVariable(f,0)):1E6<this.scale&&(this.scale=1E6,m.setVariable(f,1E6));n&&(this.container.style.left=this.x+"px");q&&(this.container.style.top=this.y+"px");(n||q)&&this.findOffset();if(0<m.evalExpression(this.drawif)){this.container.style.display=
"block";a=0;for(c=this.graphics.length;a<c;a++)d=this.graphics[a],""!=d.trace&&(!this.spaceChange&&!this.click&&!d.background)&&d.drawTrace();this.drawBackground();this.draw()}else this.container.style.display="none"};a.Space2D.prototype.drawBackground=function(){if(this.spaceChange){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));for(var f=this.scale,k=0,m=0>this.w+this.h?0:this.w+this.h;f>m;)f/=
10,k++;for(;f<m/10;)f*=10;d.lineWidth=1;""!=this.net&&(d.strokeStyle=a.getColor(c,this.net),this.drawMarks(d,f/10,-1));if(2!=this.parent.version&&""!=this.net10||2==this.parent.version&&""!=this.net&&""!=this.net10)d.strokeStyle=a.getColor(c,this.net10),this.drawMarks(d,f,-1);if(""!=this.axes){d.strokeStyle=a.getColor(c,this.axes);d.beginPath();if(""!=this.x_axis||2!=this.parent.version)d.moveTo(0,e(this.h/2+this.Oy)+0.5),d.lineTo(this.w,e(this.h/2+this.Oy)+0.5);if(""!=this.y_axis||2!=this.parent.version)d.moveTo(e(this.w/
2+this.Ox)+0.5,0),d.lineTo(e(this.w/2+this.Ox)+0.5,this.h);d.stroke();this.drawMarks(d,f,4);this.drawMarks(d,f/2,2);this.drawMarks(d,f/2/5,1)}if(""!=this.x_axis||""!=this.y_axis)d.fillStyle=a.getColor(c,this.axes),d.font="12px Arial",d.textAlign="right",d.textBaseline="top",d.fillText(this.x_axis,e(this.w)-2,e(this.h/2+this.Oy)),d.fillText(this.y_axis,e(this.w/2+this.Ox)-2,0);this.numbers&&""!=this.axes&&(d.fillStyle=a.getColor(c,this.axes),d.font="12px Arial",d.textAlign="start",d.textBaseline="bottom",
f>(this.w+this.h)/2?this.drawNumbers(d,f/5,f<=this.scale?k+1:k):f>(this.w+this.h)/4?this.drawNumbers(d,f/2,f<=this.scale?k+1:k):this.drawNumbers(d,f,k));c=0;for(d=this.graphics.length;c<d;c++)f=this.graphics[c],f.background&&f.draw()}};a.Space2D.prototype.draw=function(){var d=this.ctx,c;d.clearRect(0,0,this.canvas.width,this.canvas.height);for(var j=0,k=this.graphics.length;j<k;j++)c=this.graphics[j],c.background||c.draw();j=0;for(k=this.ctrs.length;j<k;j++)c=this.ctrs[j],"graphic"==c.type&&c.draw();
if(""!=this.text&&this.click&&"LEFT"==this.whichButton){d.fillStyle=a.getColor(this.evaluator,this.text);d.strokeStyle=d.fillStyle;d.lineWidth=1;d.font="12px Courier New";d.textAlign="center";d.textBaseline="bottom";j=1>=this.scale?this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length);k=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length);j="("+j+","+k+")";k=d.measureText(j).width;c=this.getAbsoluteX(this.mouse_x);var m=this.getAbsoluteY(this.mouse_y),
n=e(c),q=e(m-10);n+k/2>this.w?n=this.w-k/2:0>n-k/2&&(n=k/2);q+1>this.h?q=this.h:0>q-14&&(q=15);d.fillText(j,n,q);d.beginPath();d.arc(c,m,2.5,0,f,!0);d.stroke()}};a.Space2D.prototype.drawMarks=function(a,d,f){var k=this.w,m=this.h,n,q=0,l=k,p=0,u=m,s=e(k/2+this.Ox),t=e(m/2+this.Oy);0<=f&&(q=s-f,l=s+f,p=t-f,u=t+f);a.beginPath();for(f=-c(s/d);(n=s+c(f*d))<k;f++)a.moveTo(n+0.5,p+0.5),a.lineTo(n+0.5,u+0.5);for(f=-c(t/d);(k=t+c(f*d))<m;f++)a.moveTo(q+0.5,k+0.5),a.lineTo(l+0.5,k+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=
function(a,d){for(var f=this.w,k=this.h,m,n=e(f/2+this.Ox),q=e(k/2+this.Oy),l=-c(n/d);(m=n+c(l*d))<f;l++)a.fillText(parseFloat((l*d/this.scale).toFixed(4)),m+2,q-2);for(l=-c(q/d);(f=q+c(l*d))<k;l++)a.fillText(parseFloat((-l*d/this.scale).toFixed(4)),n+2,f-2)};a.Space2D.prototype.registerMouseEvents=function(){function d(a){l.click=1;l.parent.evaluator.setVariable(l.id+".mouse_pressed",1);l.parent.deactivateGraphiControls();m(a);window.addEventListener("touchmove",q,!1);window.addEventListener("touchend",
c,!1);(!l.fixed||l.sensitive_to_mouse_movements)&&a.preventDefault()}function c(a){l.click=0;l.parent.evaluator.setVariable(l.id+".mouse_pressed",0);window.removeEventListener("touchmove",q,!1);window.removeEventListener("touchend",c,!1);a.preventDefault();l.parent.update()}function f(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",k,!1),l.fixed||(l.clickPosForZoom=l.getCursorPosition(a).y,l.tempScale=l.scale,window.addEventListener("mousemove",n,!1)));"LEFT"==l.whichButton&&(l.parent.evaluator.setVariable(l.id+".mouse_pressed",1),m(a),window.addEventListener("mousemove",q,!1),window.addEventListener("mouseup",k,!1));a.preventDefault()}function k(a){l.click=0;l.parent.evaluator.setVariable(l.id+".mouse_pressed",0);a.preventDefault();"RIGHT"==l.whichButton&&window.removeEventListener("mousemove",
n,!1);l.sensitive_to_mouse_movements||window.removeEventListener("mousemove",q,!1);window.removeEventListener("mouseup",k,!1);l.parent.update()}function m(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 n(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 q(a){if(!l.fixed){l.posNext=l.getCursorPosition(a);var d=e(l.posAnte.x-l.posNext.x),c=e(l.posAnte.y-l.posNext.y),f=2!=l.parent.version?l.id+".Oy":"Oy";l.parent.evaluator.setVariable(2!=l.parent.version?l.id+".Ox":"Ox",l.Ox-d);l.parent.evaluator.setVariable(f,l.Oy-c);l.posAnte.x-=d;l.posAnte.y-=c}l.click&&m(a);(!l.fixed||l.sensitive_to_mouse_movements)&&a.preventDefault()}
var l=this,p=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};p&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",m,!1),this.canvas.addEventListener("touchstart",d,!1));p||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",m,!1),this.canvas.addEventListener("mousedown",f,!1))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,c=Math.cos,f=Math.sin;a.Space3D=function(d,e){a.Space.call(this,
d,e);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);d.container.insertBefore(this.container,d.loader);this.findOffset();this.eye=new a.Vector3D(0,0,0);this.center=new a.Vector3D(0,0,0);this.yUpEye=new a.Vector3D(0,0,1);this.distanceEyeCenter=10;this.alpha=Math.PI/4;this.beta=-Math.PI/5;this.lookAtMatrix=new a.Matrix4x4;this.perspectiveMatrix=new a.Matrix4x4;this.perspective=(new a.Matrix4x4).perspective(45,this.w/this.h,0.01,1E3);cosAlpha=c(-this.alpha);sinAlpha=f(-this.alpha);cosBeta=c(this.beta);
sinBeta=f(this.beta);this.eye.set(this.distanceEyeCenter*cosAlpha*cosBeta,this.distanceEyeCenter*sinAlpha*cosBeta,-this.distanceEyeCenter*sinBeta);this.yUpEye=this.yUpEye.set(c(-this.alpha-Math.PI/2),f(-this.alpha-Math.PI/2),0).crossProduct(this.eye).normalize();this.lookAtMatrix=this.lookAtMatrix.setIdentity().lookAt(this.eye,this.center,this.yUpEye);this.perspectiveMatrix=this.perspective.multiply(this.lookAtMatrix);this.registerMouseEvents();this.update()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.update=
function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.fillStyle=a.getColor(this.evaluator,this.background);this.ctx.fillRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);if(!this.click){this.scene=new a.Scene(this);for(var d=0,c=this.graphics.length;d<c;d++)this.graphics[d].update()}this.scene.draw()};a.Space3D.prototype.transformCoordinateX=function(a){var c=this.w/2;return e(a*c+c+this.Ox)};a.Space3D.prototype.transformCoordinateY=function(a){var c=this.h/
2;return e(-a*c+c+this.Oy)};a.Space3D.prototype.registerMouseEvents=function(){var d,e;function g(a){p.click=1;p.parent.evaluator.setVariable(p.id+".mouse_pressed",1);n(a);window.addEventListener("touchmove",l,!1);window.addEventListener("touchend",j,!1);(!p.fixed||p.sensitive_to_mouse_movements)&&a.preventDefault()}function j(a){p.click=0;p.parent.evaluator.setVariable(p.id+".mouse_pressed",0);window.removeEventListener("touchmove",l,!1);window.removeEventListener("touchend",j,!1);a.preventDefault()}
function k(a){p.click=1;p.whichButton=null==a.which?2>a.button?"LEFT":4==a.button?"MIDDLE":"RIGHT":2>a.which?"LEFT":2==a.which?"MIDDLE":"RIGHT";"LEFT"==p.whichButton&&(p.parent.evaluator.setVariable(p.id+".mouse_pressed",1),p.posAnte=p.getCursorPosition(a),d=p.getRelativeX(p.posAnte.x),e=p.getRelativeY(p.posAnte.y),n(a),window.addEventListener("mousemove",l,!1),window.addEventListener("mouseup",m,!1));a.preventDefault()}function m(a){p.click=0;p.parent.evaluator.setVariable(p.id+".mouse_pressed",
0);a.preventDefault();"RIGHT"==p.whichButton&&window.removeEventListener("mousemove",q,!1);window.removeEventListener("mouseup",m,!1)}function n(a){p.posAnte=p.getCursorPosition(a);p.mouse_x=p.getRelativeX(p.posAnte.x);p.mouse_y=p.getRelativeY(p.posAnte.y);p.parent.evaluator.setVariable(p.id+".mouse_x",p.mouse_x);p.parent.evaluator.setVariable(p.id+".mouse_y",p.mouse_y);p.parent.update()}function q(){}function l(a){p.click&&(n(a),p.alpha+=p.mouse_x-d,p.beta+=p.mouse_y-e,s=c(-p.alpha),t=f(-p.alpha),
r=c(p.beta),v=f(p.beta),p.eye.set(p.distanceEyeCenter*s*r,p.distanceEyeCenter*t*r,-p.distanceEyeCenter*v),p.yUpEye=p.yUpEye.set(c(-p.alpha-Math.PI/2),f(-p.alpha-Math.PI/2),0).crossProduct(p.eye).normalize(),p.lookAtMatrix=p.lookAtMatrix.setIdentity().lookAt(p.eye,p.center,p.yUpEye),p.perspectiveMatrix=p.perspective.multiply(p.lookAtMatrix),d=p.mouse_x,e=p.mouse_y)}var p=this,u=a.hasTouchSupport;e=d=0;this.canvas.oncontextmenu=function(){return!1};u&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",
n,!1),this.canvas.addEventListener("touchstart",g,!1));u||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",n,!1),this.canvas.addEventListener("mousedown",k,!1));var s,t,r,v};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;var f=e.evaluator;this.file=this.file.match(/^\[/)&&this.file.match(/\]$/)?f.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&
this.file.match(/\'$/)?f.parser.parse(this.file):f.parser.parse("'"+this.file+"'");this.oldFile=f.evalExpression(this.file);this.initFile()};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var e;if(this.oldFile){var c=document.getElementById(this.oldFile);e=c&&"descartes/spaceApFile"==c.type?c.text:a.openExternalFile(this.oldFile);null!=e&&(e=e.split("\n"))}if(e&&e.toString().match(/<applet/gi)){for(var c="",f=!1,d=0,h=e.length;d<h&&!(e[d].match("<applet")&&
(f=!0),f&&(c+=e[d]),e[d].match("</applet"));d++);d=document.createElement("div");d.innerHTML=c;d.firstChild.setAttribute("width",this.w);d.firstChild.setAttribute("height",this.h);c=this.descApp?this.descApp.container:null;this.descApp=new a.DescartesApp(d.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+";");c?this.parent.container.replaceChild(this.descApp.container,c):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);c=this.descApp.spaces;d=0;for(h=c.length;d<h;d++)c[d].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var g=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();g.exportar()}}else c=
this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),d="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?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?
d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?d+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",d),c?this.parent.container.replaceChild(this.descApp.container,c):this.parent.container.insertBefore(this.descApp.container,this.parent.loader),
this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none"};a.SpaceAP.prototype.update=function(){var a=this.evaluator.evalExpression(this.file);if(this.oldFile!=a)this.oldFile=a,this.initFile();else{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,f=a.length;c<f;c++)a[c].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";if(this.firstUpdate&&(this.firstUpdate=!1,null==this.importarVars)){this.importarVars=[];for(var d in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(d)&&d.match(/^public./)&&this.importarVars.push({varName:d,value:this.evaluator.getVariable(d)})}this.importar()}};
a.SpaceAP.prototype.importar=function(){for(var a,c=!1,f=0,d=this.importarVars.length;f<d;f++)a=this.evaluator.getVariable(this.importarVars[f].varName),a!=this.importarVars[f].value&&(this.importarVars[f].value=a,this.descApp.evaluator.setVariable(this.importarVars[f].varName,this.importarVars[f].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);var f=this.parent.evaluator;this.file=this.file.match(/^\[/)&&this.file.match(/\]$/)?f.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?f.parser.parse(this.file):f.parser.parse("'"+this.file+"'");this.oldFile=f.evalExpression(this.file);this.MyIFrame=document.createElement("iframe");this.MyIFrame.setAttribute("src",this.oldFile);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;");this.MyIFrame.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";this.parent.container.insertBefore(this.MyIFrame,this.parent.loader);var d=this;this.MyIFrame.onload=function(){var a=this;d.evaluator.setFunction(d.id+".set",function(d,c){a.contentWindow.postMessage({type:"set",
name:d,value:c},"*")});d.evaluator.setFunction(d.id+".update",function(){a.contentWindow.postMessage({type:"update"},"*")});d.evaluator.setFunction(d.id+".get",function(d,c){a.contentWindow.postMessage({type:"get",name:d,value:c},"*")});d.evaluator.setFunction(d.id+".exec",function(d,c){a.contentWindow.postMessage({type:"exec",name:d,value:c},"*")})};this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.update=function(a){a&&(this.y=this.x=
Math.Infinity);a=this.evaluator;var c=this.x!=a.evalExpression(this.xExpr)+this.displaceRegionWest,f=this.y!=a.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=c?a.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=f?a.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;var d=a.evalExpression(this.file);this.oldFile=d;this.MyIFrame.setAttribute("src",d);c&&(this.MyIFrame.style.left=this.x+"px");f&&(this.MyIFrame.style.top=
this.y+"px");this.MyIFrame.style.display=0<a.evalExpression(this.drawif)?"block":"none";this.scrollVar=a.getVariable(this.id+"._scroll");1==this.scrollVar?this.MyIFrame.setAttribute("scrolling","yes"):-1==this.scrollVar?this.MyIFrame.setAttribute("scrolling","no"):this.MyIFrame.setAttribute("scrolling","auto")};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";a.malla=a.mesh="mesh";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.DescartesLoader=function(a){this.children=a.children;this.lessonParser=a.lessonParser;
this.images=a.images;this.images.length=a.images.length;this.audios=a.audios;this.audios.length=a.audios.length;this.arquimedes=a.arquimedes;this.descartesApp=a;var d;if(a.image_loader)d=a.image_loader;else{d=a.loader.width;var c=a.loader.height,e=document.createElement("canvas");e.width=d;e.height=c;var f=e.getContext("2d");f.save();f.strokeStyle="#1f375d";f.fillStyle="#1f375d";f.lineCap="round";f.lineWidth=2;f.beginPath();f.translate((d-360)/2,(c-195)/2);f.scale(3,3);f.moveTo(3,25);f.lineTo(3,1);
f.lineTo(21,1);f.bezierCurveTo(33,1,41,15,41,25);f.stroke();f.beginPath();f.moveTo(1,63);f.lineTo(1,64);f.moveTo(5,62);f.lineTo(5,64);f.moveTo(9,61);f.lineTo(9,64);f.moveTo(13,60);f.lineTo(13,64);f.moveTo(17,58);f.lineTo(17,64);f.moveTo(21,56);f.lineTo(21,64);f.moveTo(25,53);f.lineTo(25,64);f.moveTo(29,50);f.lineTo(29,64);f.moveTo(33,46);f.lineTo(33,64);f.moveTo(37,41);f.lineTo(37,64);f.moveTo(41,32);f.lineTo(41,64);f.stroke();f.font="20px Arial";f.fillText("escartes",45,33);f.fillText("JS",98,64);
f.restore();d=e.toDataURL()}this.imageLoader=document.createElement("div");this.imageLoader.width=a.width;this.imageLoader.height=a.height;this.imageLoader.setAttribute("class","DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image: url("+d+"); width: "+a.width+"px; height:"+a.height+"px;");a.loader.appendChild(this.imageLoader);this.loaderBar=document.createElement("canvas");this.loaderBar.width=a.width;this.loaderBar.height=a.height;this.loaderBar.setAttribute("class","DescartesLoaderBar");
this.loaderBar.setAttribute("style","width: "+a.width+"px; height:"+a.height+"px;");this.loaderBar.ctx=this.loaderBar.getContext("2d");a.loader.appendChild(this.loaderBar);this.barWidth=Math.floor(a.loader.width/10);this.barHeight=Math.floor(a.loader.height/70);var n=this;this.timer=setInterval(function(){n.drawLoaderBar(n.loaderBar.ctx,a.width,a.height)},10);a.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var d=this.children,c=this.images,e=this.audios,f=
/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,m=/[\w-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g,n=/vector|array|bektore|vecteur|matriz/g,q=/archivo|file|fitxer|artxibo|fichier|arquivo/g;this.arquimedes&&(c["lib/DescartesCCLicense.png"]=a.getCreativeCommonsLicenseImage(),c["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=1}),c["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=1}));var l,p,u,s,t,r;s=0;for(t=d.length;s<
t;s++){if(l=d[s].value.match(f)){u=0;for(r=l.length;u<r;u++)p=l[u],!p.toLowerCase().match(/vacio.gif$/)&&""!=p.substring(0,p.length-4)&&(c[p]=new Image,c[p].addEventListener("load",function(){this.ready=1}),c[p].addEventListener("error",function(){this.errorload=1}),c[p].src=p)}if(l=d[s].value.match(m)){u=0;for(p=l.length;u<p;u++)this.initAudio(l[u])}(u=d[s].value.match(n)&&d[s].value.match(q))&&this.lessonParser.parseAuxiliar(d[s].value)}for(var v in c)c.hasOwnProperty(v)&&this.images.length++;for(v in e)e.hasOwnProperty(v)&&
this.audios.length++;var x=this,z=this.images.length+this.audios.length,w=function(){x.readys=0;for(var a in c)c.hasOwnProperty(a)&&(c[a].ready||c[a].errorload)&&x.readys++;for(a in x.audios)e.hasOwnProperty(a)&&(e[a].ready||e[a].errorload)&&x.readys++;x.readys!=z?setTimeout(w,30):(clearTimeout(x.timer),x.descartesApp.initBuildApp())};w()};a.DescartesLoader.prototype.initAudio=function(d){var c=this.audios;c[d]=new Audio(d);c[d].filename=d;var e=function(){this.ready=1},f=function(){!this.canPlayType("audio/"+
this.filename.substring(this.filename.length-3))&&"mp3"==this.filename.substring(this.filename.length-3)?(c[d]=new Audio(this.filename.replace("mp3","ogg")),c[d].filename=this.filename.replace("mp3","ogg"),c[d].addEventListener("canplaythrough",e),c[d].addEventListener("load",e),c[d].addEventListener("error",f),c[d].load()):(console.log("El archivo '"+d+"' no puede ser reproducido"),this.errorload=1)};c[d].addEventListener("canplaythrough",e);c[d].addEventListener("load",e);c[d].addEventListener("error",
f);a.hasTouchSupport?(c[d].load(),c[d].play(),c[d].ready=1):c[d].load()};var e,c,f,d;a.DescartesLoader.prototype.drawLoaderBar=function(a,g,j){e=this.barWidth;c=this.barHeight;f=this.images.length+this.audios.length;d=2*(e-2)/f;a.translate(g/2,j-50);a.scale(2,2);a.strokeRect(-e,-c,2*e,c);a.fillStyle="gray";a.fillRect(-e+2,-c+2,2*(e-2),c-4);a.fillStyle="#1f375d";a.fillRect(-e+2,-c+2,this.readys*d,c-4);a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{}),descartesJS=function(a){function e(a){for(var d=
"[",h=0,g=a.length;h<g;h++){if(a[h]instanceof Array)d+=e(a[h]);else{c=a[h];if("undefined"==typeof c||!c)c=0;"string"==typeof c&&(c="'"+c+"'");d+=c}h<g-1&&(d+=",")}return d+"]"}if(a.loadLib)return a;a.DescartesApp=function(c){this.applet=c;this.parentContainer=c.parentNode;this.width=parseFloat(c.getAttribute("width"));this.height=parseFloat(c.getAttribute("height"));this.decimal_symbol=".";this.children=c.getElementsByTagName("param");this.code=c.getAttribute("code");this.saveState=[];this.images=
{};this.images.length=-1;this.audios={};this.audios.length=-1;this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.firstRun=!0;this.arquimedes=!!this.code.match("descinst.DescartesWeb2_0.class");this.licenseW2="{\\rtf1\\uc0{\\fonttbl\\f0\\fcharset0 Arial;\\f1\\fcharset0 Arial;\\f2\\fcharset0 Arial;\\f3\\fcharset0 Arial;\\f4\\fcharset0 Arial;}{\\f0\\fs34 __________________________________________________________________________________ \\par \\fs22                                        Los contenidos de esta unidad did\u00e1ctica interactiva est\u00e1n bajo una  {\\*\\hyperlink licencia Creative Commons|http://creativecommons.org/licenses/by-nc-sa/2.5/es/}, si no se indica lo contrario.\\par                                        La unidad did\u00e1ctica fue creada con DescartesWeb2.0, que es un producto de c\u00f3digo abierto del  {\\*\\hyperlink Ministerio de Educaci\u00f3n de Espa\u00f1a|http://recursostic.educacion.es/descartes/web/DescartesWeb2.0/} y\\par                                        el {\\*\\hyperlink Instituto de Matem\u00e1ticas|http://arquimedes.matem.unam.mx/} de la Universidad Nacional Aut\u00f3noma de M\u00e9xico, cedido bajo licencia {\\*\\hyperlink EUPL v 1.1|/resources/eupl_v1.1es.pdf}, con {\\*\\hyperlink c\u00f3digo en Java|http://recursostic.educacion.es/descartes/web/source/}.}";
this.licenseA="{\\rtf1\\uc0{\\fonttbl\\f0\\fcharset0 Arial;\\f1\\fcharset0 Arial;\\f2\\fcharset0 Arial;\\f3\\fcharset0 Arial;\\f4\\fcharset0 Arial;}{\\f0\\fs34 __________________________________________________________________________________ \\par \\fs22                                        Los contenidos de esta unidad did\u00e1ctica interactiva est\u00e1n bajo una  {\\*\\hyperlink licencia Creative Commons|http://creativecommons.org/licenses/by-nc-sa/2.5/es/}, si no se indica lo contrario.\\par                                        La unidad did\u00e1ctica fue creada con Arqu\u00edmedes, que es un producto de c\u00f3digo abierto del  {\\*\\hyperlink Ministerio de Educaci\u00f3n de Espa\u00f1a|http://recursostic.educacion.es/descartes/web/DescartesWeb2.0/} y\\par                                        el {\\*\\hyperlink Instituto de Matem\u00e1ticas|http://arquimedes.matem.unam.mx/} de la Universidad Nacional Aut\u00f3noma de M\u00e9xico, cedido bajo licencia {\\*\\hyperlink EUPL v 1.1|/resources/eupl_v1.1es.pdf}, con {\\*\\hyperlink c\u00f3digo en Java|http://recursostic.educacion.es/descartes/web/source/}.}";
c=this.children;for(var d,e=0,g=0,j=0,k=c.length;j<k;j++)d=c[j],"rtf_height"==d.name&&(e=parseInt(d.value)),"Buttons"==babel[d.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(d.value),g=this.buttonsConfig.height),"image_loader"==d.name&&(this.image_loader=d.value);this.arquimedes&&e&&(this.height=e+g+70);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.numberOfIframes=this.plecaHeight=this.tabindex=this.zIndex=0;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; z-index:1000;");this.firstRun?this.descartesLoader=new a.DescartesLoader(this):this.initBuildApp()};a.DescartesApp.prototype.initBuildApp=function(){for(var a=this.children,d=this.lessonParser,c=[],e=[],j=[],k=[],m=[],n=[],q,l=0,p=a.length;l<p;l++)if(q=a[l],"pleca"==q.name)q=d.parsePleca(q.value,this.width),this.container.insertBefore(q,this.loader),this.plecaHeight=
q.imageHeight?q.imageHeight:q.offsetHeight;else if("Buttons"==babel[q.name])this.buttonsConfig=d.parseButtonsConfig(q.value);else if("decimal_symbol"==babel[q.name])this.decimal_symbol=q.value;else if("version"==babel[q.name])this.version=parseInt(q.value);else if("language"==babel[q.name])this.language=q.value;else if("rtf"==q.name){var u=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;k.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+
q.value.replace(/'/g,"&squot;")+"'");k.push("space='descartesJS_scenario' type='text' expresion='[10,"+(u-25)+"]' background='yes' text='"+this.licenseA+"'");k.push("space='descartesJS_scenario' type='image' expresion='[15,"+u+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==q.name.charAt(0)?(q.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,c.push(q.value)):"C"==q.name.charAt(0)&&"_"==q.name.charAt(1)?e.push(q.value):"A"==q.name.charAt(0)&&"_"==q.name.charAt(1)?
j.push(q.value):"G"==q.name.charAt(0)?k.push(q.value):"S"==q.name.charAt(0)?m.push(q.value):"Animation"==babel[q.name]&&n.push(q.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' fondo='blanco' 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));l=0;for(p=c.length;l<p;l++)a=d.parseSpace(c[l]),this.arquimedes&&this.scenarioRegion.container.appendChild(a.container),this.spaces.push(a),this.zIndex++;l=0;for(p=k.length;l<p;l++)if(c=d.parseGraphic(k[l]))c.visible&&(this.editableRegionVisible=!0),c.space.addGraph(c);l=0;for(p=
m.length;l<p;l++)(c=d.parse3DGraphic(m[l]))&&c.space.addGraph(c);l=0;for(p=e.length;l<p;l++)this.controls.push(d.parseControl(e[l]));l=0;for(p=j.length;l<p;l++)d.parseAuxiliar(j[l]);l=0;for(p=n.length;l<p;l++)this.animation=d.parseAnimation(n[l]);this.configRegions();this.updateAuxiliaries();l=0;for(p=this.controls.length;l<p;l++)this.controls[l].init();this.updateControls();this.updateSpaces(!0);var s=this;this.numberOfIframes?setTimeout(function(){s.finishInit()},250*this.numberOfIframes):this.finishInit()};
a.DescartesApp.prototype.finishInit=function(){this.update();this.loader.style.display="none";this.parentContainer.style="overflow:hidden;"};a.DescartesApp.prototype.configRegions=function(){var c=this.evaluator.parser,d=this.buttonsConfig,e=this.container;if(2!=this.version)var g="15",j=100,k=100,m=100,n=100;else g="14",j=63,k=50,m=44,n=53;var q=0,l=0,p=0,u=p=0,s=0,t=0,r=0,v=0,t=this.northSpace.controls,x=this.southSpace.controls,z=this.eastSpace.controls,w=this.westSpace.controls;if(0<d.rowsNorth||
0<t.length||d.about||d.config){0>=d.rowsNorth?(q=d.height,d.rowsNorth=1):q=d.height*d.rowsNorth;var y=this.northSpace.container;y.setAttribute("id","descartesJS_northRegion");y.setAttribute("style","width:"+e.width+"px; height:"+q+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");e.insertBefore(y,this.loader);var s=e.width,C=0;d.about&&(C=j,s-=C);d.config&&(s-=k);for(var y=Math.ceil(t.length/d.rowsNorth),B=s/y,p=0,D=t.length;p<D;p++)t[p].expresion=c.parse("("+(C+B*(p%y))+
","+d.height*Math.floor(p/y)+","+B+","+d.height+")"),t[p].drawif=c.parse("1");if(d.about){var E;"espa\u00f1ol"==this.language?E="cr\u00e9ditos":"english"==this.language&&(E="about");new a.Button(this,{region:"north",name:E,font_size:c.parse(g),expresion:c.parse("(0, 0, "+j+", "+q+")")})}d.config&&(E="config",new a.Button(this,{region:"north",name:E,font_size:c.parse(g),action:"config",expresion:c.parse("("+(s+j)+", 0, "+k+", "+q+")")}))}if(0<d.rowsSouth||0<x.length||d.init||d.clear){0>=d.rowsSouth?
(l=d.height,d.rowsSouth=1):l=d.height*d.rowsSouth;t=e.width;C=0;d.init&&(C=m,t-=C);d.clear&&(t-=n);y=this.southSpace.container;y.setAttribute("id","descartesJS_southRegion");y.setAttribute("style","width:"+e.width+"px; height:"+l+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(e.height-l)+"px; z-index:100;");e.insertBefore(y,this.loader);y=Math.ceil(x.length/d.rowsSouth);B=t/y;p=0;for(D=x.length;p<D;p++)x[p].expresion=c.parse("("+(C+B*(p%y))+","+d.height*Math.floor(p/y)+","+B+","+d.height+
")"),x[p].drawif=c.parse("1");d.init&&("espa\u00f1ol"==this.language?E="inicio":"english"==this.language&&(E="init"),new a.Button(this,{region:"south",name:E,font_size:c.parse(g),action:"init",expresion:c.parse("(0, 0, "+m+", "+l+")")}));d.clear&&("espa\u00f1ol"==this.language?E="limpiar":"english"==this.language&&(E="clear"),new a.Button(this,{region:"south",name:E,font_size:c.parse(g),action:"clear",expresion:c.parse("("+(t+m)+", 0, "+n+", "+l+")")}))}if(0<z.length){p=e.height-q-l;r=d.widthEast;
y=this.eastSpace.container;y.setAttribute("id","descartesJS_eastRegion");y.setAttribute("style","width:"+r+"; height:"+p+"px; background:#c0c0c0; position:absolute; left:"+(e.width-r)+"px; top:"+q+"px; z-index:100;");e.insertBefore(y,this.loader);p=0;for(D=z.length;p<D;p++)z[p].expresion=c.parse("(0,"+d.height*p+","+r+","+d.height+")"),z[p].drawif=c.parse("1")}if(0<w.length){p=e.height-q-l;v=d.widthWest;y=this.westSpace.container;y.setAttribute("id","descartesJS_westRegion");y.setAttribute("style",
"width: "+v+"; height: "+p+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+q+"px; z-index: 100;");e.insertBefore(y,this.loader);p=0;for(D=w.length;p<D;p++)w[p].expresion=c.parse("(0,"+d.height*p+","+v+","+d.height+")"),w[p].drawif=c.parse("1")}if(this.editableRegionVisible){u=d.height;y=this.editableRegion.container;y.setAttribute("id","descartesJS_editableRegion");y.setAttribute("style","width:"+e.width+"px; height:"+u+"px; position:absolute; left:0px; top:"+(e.height-l-d.height)+
"px; z-index:100; background:#c0c0c0; overflow:hidden;");e.insertBefore(y,this.loader);c=this.editableRegion.textFields;d=e.width/c.length;p=0;for(D=c.length;p<D;p++)"div"==c[p].type?(y.appendChild(c[p].container),c[p].container.setAttribute("style","font-family:Arial; width:"+(d-4)+"px; height:"+(u-5)+"px; position:absolute; left:"+p*d+"px; top:0px; border:2px groove white;"),g=c[p].container.firstChild,j=g.offsetWidth,g.setAttribute("style","font-family:Arial; padding-top:0%; background-color:lightgray; position:absolute; left:0px; top:0px; width:"+
j+"px;"),g.firstChild.textContent=g.firstChild.textContent.substring(1,g.firstChild.textContent.length-1),c[p].container.lastChild.setAttribute("style","font-family:'Courier New'; width:"+(d-j-8)+"px; height:"+(u-9)+"px; position:absolute; left:"+j+"px; top:0px; border:2px groove white;")):(y.appendChild(c[p]),c[p].setAttribute("style","font-family:'Courier New'; width:"+d+"px; height:"+u+"px; position:absolute; left:"+p*d+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=q;this.displaceRegionWest=
v;e.width-=r;e.height=e.height-l-u;p=0;for(D=this.spaces.length;p<D;p++)this.spaces[p].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,c=0,e=this.controls.length;c<e;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,e=this.spaces.length;c<e;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.getImage=function(a){var c=this.images;if(a)return c[a]||(c[a]=new Image,c[a].addEventListener("load",function(){this.ready=1}),c[a].addEventListener("error",function(){this.errorload=1}),c[a].src=a),c[a]};a.DescartesApp.prototype.getAudio=function(a){var c=
this.audios;if(a){if(!c[a]){c[a]=new Audio(a);var e=function(){this.ready=1};c[a].addEventListener("canplaythrough",e);var g=function(){!this.canPlayType("audio/"+a.substring(a.length-3))&&"mp3"==a.substring(a.length-3)?(c[a]=new Audio(a.replace("mp3","ogg")),c[a].addEventListener("canplaythrough",e),c[a].addEventListener("load",e),c[a].addEventListener("error",g),c[a].load()):(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1)};c[a].addEventListener("error",g);c[a].play();
setTimeout(function(){c[a].pause()},15)}return c[a]}};a.DescartesApp.prototype.getControlByCId=function(a){for(var c,e=0,g=this.controls.length;e<g;e++)if(c=this.controls[e],c.cID==a)return c;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var c,e=0,g=this.controls.length;e<g;e++)if(c=this.controls[e],c.id==a)return c;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var c,e=0,g=this.spaces.length;e<g;e++)if(c=this.spaces[e],
c.cID==a)return c;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var c,e=0,g=this.spaces.length;e<g;e++)if(c=this.spaces[e],c.id==a)return c;return{update:function(){},w:0}};var c;a.DescartesApp.prototype.getState=function(){var a,c="",h=this.evaluator.variables,g;for(g in h)h.hasOwnProperty(g)&&(a=h[g],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=g&&"pi"!=g&&"e"!=g&&"Infinity"!=g&&"-Infinity"!=g&&"object"!=typeof a)&&(c=""!=c?c+"\n"+g+"="+a:g+"="+a));
var h=this.evaluator.vectors,j;for(j in h)h.hasOwnProperty(j)&&(a=h[j],c=c+"\n"+j+"="+e(a));j=this.evaluator.matrices;for(var k in j)j.hasOwnProperty(k)&&(a=j[k],c=c+"\n"+k+"="+e(a));return c};a.DescartesApp.prototype.setState=function(a){a=a.split("\n");for(var c,e,g=0,j=a.length;g<j;g++)c=a[g].split("="),2<=c.length&&(e=eval(c[1]),-1!=c[1].indexOf("[[")?(this.evaluator.matrices[c[0]]=e,this.evaluator.matrices[c[0]].rows=e.length,this.evaluator.matrices[c[0]].cols=e[0].length):-1!=c[1].indexOf("[")?
(this.evaluator.vectors[c[0]]=e,this.evaluator.variables[c[0]+".long"]=e.length):this.evaluator.variables[c[0]]=e),this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,c=0,e="",g=0,j=this.controls.length;g<j;g++)"textfield"==this.controls[g].gui&&this.controls[g].evaluate&&(a++,c+=this.controls[g].ok,this.controls[g].value=""==this.controls[g].value?"''":this.controls[g].value,e+=" \\n "+this.controls[g].id+"="+this.controls[g].value+"|"+this.controls[g].ok);return"questions="+
a+" \\n correct="+c+" \\n wrong="+(a-c)+e};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,c=0,e=a.length;c<e;c++)"textfield"==a[c].gui&&a[c].evaluate&&a[c].changeValue(a[c].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(){for(var c,e=0,f=a.apps.length;e<f;e++){c=a.apps[e].spaces;
for(var j=0,k=c.length;j<k;j++)c[j].findOffset()}}function c(){a.getFeatures();if(a.hasCanvasSupport){for(var c=document.getElementsByTagName("*"),f=[],g=0,j=c.length;g<j;g++)"DescartesAppContainer"==c[g].className&&f.push(c[g]);g=0;for(j=f.length;g<j;g++)f[g].parentNode.removeChild(f[g]);for(var f=document.getElementsByTagName("applet"),c=[],j=0,k=f.length;j<k;j++)g=f[j],(g.getAttribute("code").match("DescartesJS")||g.getAttribute("code").match("Descartes.class")||g.getAttribute("code").match("descinst.DescartesWeb2_0.class"))&&
c.push(g);f=0;for(g=c.length;f<g;f++)a.apps.push(new a.DescartesApp(c[f])),c[f].className="DescartesJS";document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:none;}";window.addEventListener("resize",e)}else document.getElementById("StyleDescartesApps").innerHTML="applet {display:block;}"}a.apps=[];a.getDescartesApps=function(){return a.apps};if(!window.hasOwnProperty("debugDescartesJS")||!debugDescartesJS){var f=document.getElementById("StyleDescartesApps");f&&f.parentNode.removeChild(f);
f=document.createElement("style");f.id="StyleDescartesApps";f.type="text/css";f.setAttribute("rel","stylesheet");f.innerHTML="applet.DescartesJS {display:none;} applet {display:none;}";document.head.appendChild(f)}a.receiveMessage=function(c){if(0<a.apps.length)if((c=c.data)&&"set"===c.type)a.apps[0].evaluator.setVariable(c.name,c.value);else if(c&&"update"===c.type)a.apps[0].update();else if(c&&"exec"===c.type){var e=a.apps[0].evaluator.getFunction(c.name),f=[];""!==c.value&&(f=c.value.toString().split(","));
e&&e.apply(a.apps[0].evaluator,f)}};void 0===a.loadLib&&(a.loadLib=!0,window.addEventListener("load",c),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||{});
