/*
 Joel Espinosa Longi
 j.longi@gmail.com
 https://github.com/jlongi/DescartesJS
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2014-01-09
*/
var babel=function(a){if(a.loadLib)return 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="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto="whileExpr";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.cubo=a.cube=a.cub=a.kubo="cube";a["paralelep\u00edpedo"]=a.box=a["paral\u00b7lelep\u00edpede"]=
a.paralelepipedo=a["parall\u00e9l\u00e9pip\u00e8de"]="box";a.cono=a.cone=a.con=a.kono=a["c\u00f4ne"]="cone";a.cilindro=a.cylinder=a.cilindre=a.zilindro=a.cylindre="cylinder";a.esfera=a.sphere=a["sph\u00e8re"]="sphere";a.tetraedro=a.tetrahedron=a.tetraedre=a["t\u00e9tra\u00e8dre"]="tetrahedron";a.octaedro=a["octahedron="]=a.octaedre=a.oktaedro=a["octa\u00e8dre"]="octahedron";a.dodecaedro=a.dodecahedron=a.dodecaedre=a.dodekaedro=a["dod\u00e9ca\u00e8dre"]="dodecahedron";a.icosaedro=a.icosahedron=a.icosaedre=
a.ikosaedro=a["icosa\u00e8dre"]="icosahedron";a.elipsoide=a.ellipsoid=a["el\u00b7lipsoide"]=a["ellipso\u00efde"]=a["elips\u00f3ide"]="ellipsoid";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.tipo_de_macro=a.macro_type=a.tipus_de_macro=a.makro_mota=
a.type_de_macro=a.tipo_de_macro=a.tipo_de_macro=a.tipus_de_macro="macro_type";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="x";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["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";a.local=a.Local="local";a.loadLib=!0;return a}(babel||{}),descartesJS=function(a){function d(){var a,
b,c,e,g,d,f,k,m;Number.prototype.originalToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(l){l=l?l:0;l=0>l?0:parseInt(l);a=this.toString();g=a.indexOf("e");if(-1!==g)if(d=a.split("e"),k="-"===d[0][0]?"-":"",f="-"===k?parseFloat(d[0].substring(1)).originalToFixed(11):parseFloat(d[0]).originalToFixed(11),m=parseInt(d[1]),b=f.indexOf("."),0>b+m){b=0>b?1:b;var p=k+"0.",n;n=Math.abs(b+m);n=Array(n+1).join("0");a=p+n+f.replace(".","")}else f=f.replace(".",""),a=k+f+Array(m-f.length+2).join("0");
b=a.indexOf(".");c="";if(-1===b)0<l&&(c="."),c+=Array(l+1).join("0"),a+=c;else if(e=a.length-b-1,e>=l)11>=l&&(a=parseFloat(a).originalToFixed(l)),a=0<l?a.substring(0,b+1+l):a.substring(0,b);else{p=0;for(l-=e;p<l;p++)c+="0";a+=c}return a}}function h(a,b,c){a.fillStyle="#c0c0c0";a.fillRect(b.offsetLeft,b.offsetTop,b.offsetWidth,b.offsetHeight);f(a,b,c.controls)}function f(a,b,c){for(var e,g=c.length-1;0<=g;g--)e=c[g],a.drawImage(e.getScreenshot(),b.offsetLeft+e.x,b.offsetTop+e.y)}if(a.loadLib)return a;
var b=2*Math.PI,c=360/b,p=b/360,e=Math.floor,g,n,q,k,s,r,t,m,v,l;a.rangeOK=1;a.extend=function(a,b){if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var c in b.prototype)b.prototype.hasOwnProperty(c)&&(a.prototype[c]=b.prototype[c]);a.prototype.uber=b.prototype};a.radToDeg=function(a){return a*c};a.degToRad=function(a){return a*p};a.convertFont=function(a){if(""==a)return a;g=a.split(",");n="";"bold"==g[1].toLowerCase()?n+="Bold ":"italic"==g[1].toLowerCase()||"italics"==g[1].toLowerCase()?
n+="Italic ":"bold+italic"==g[1].toLowerCase()&&(n+="Italic Bold ");n+=g[2]+"px ";q=g[0].split(" ")[0].toLowerCase();return n="serif"===q||"times new roman"===q||"timesroman"===q||"times"===q?n+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===q||"arial"===q||"helvetica"===q?n+"Arial, Helvetica, 'Droid Sans', Sans-serif":n+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};a.drawLine=function(a,b,c,g,d,f,k){a.lineWidth=k||1;a.strokeStyle=f||"black";f=a.lineWidth%2?0.5:0;a.beginPath();
a.moveTo(e(b)+f,e(c)+f);a.lineTo(e(g)+f,e(d)+f);a.stroke()};a.getColor=function(a,b){if("string"==typeof b)return b;k=a.evalExpression(b);s=e(255*k[0][0]);r=e(255*k[0][1]);t=e(255*k[0][2]);m=1-k[0][3];return"rgba("+s+","+r+","+t+","+m+")"};a.getFeatures=function(){a.hasJavaSupport=navigator.javaEnabled();var b=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&window.hasOwnProperty("ontouchstart")||b.match("android")&&!0;a.hasTouchSupport=navigator.userAgent.toLowerCase().match("qt")?
!1:a.hasTouchSupport;a.isIOS=!(!navigator.userAgent.match(/iPad/i)&&!navigator.userAgent.match(/iPhone/i));b=document.createElement("canvas");a.hasCanvasSupport=b.getContext&&b.getContext("2d");a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"));d()};a.removeNeedlessDecimals=function(a){var b,c;if("string"==typeof a&&(b=a.indexOf("."),-1!=b)){c=a.substring(b);if(0==parseFloat(c))return a.substring(0,b);for(var e=c.length;0<e;e--)if(0!=c.charAt(e))return a.substring(0,b+e+
1)}return a};a.returnValue=function(a){return"number"===typeof a?parseFloat(a.toFixed(11)):a};a.whichButton=function(a){return null!==a.which?2>a.which?"L":2===a.which?"M":"R":2>a.button?"L":4===a.button?"M":"R"};a.getCursorPosition=function(a){a.touches?(a=a.touches[0],v=a.pageX,l=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(v=a.pageX,l=a.pageY):(v=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,l=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:v,
y:l}};a.getTextWidth=function(b,c){a.ctx.font=c;return Math.round(a.ctx.measureText(b).width)};var u=document.createElement("span");u.appendChild(document.createTextNode("\u00c1p"));var w=document.createElement("div");w.setAttribute("style","display: inline-block; w: 1px; h: 0px;");var z=document.createElement("div");z.setAttribute("style","margin: 0; padding: 0;");z.appendChild(u);z.appendChild(w);var C={};a.getFontMetrics=function(a){if(C[a])return C[a];u.setAttribute("style","font: "+a+"; margin: 0px; padding: 0px;");
document.body.appendChild(z);var b={ascent:0,descent:0,h:0,baseline:0};z.getBoundingClientRect?(w.style.verticalAlign="baseline",b.ascent=w.offsetTop-u.offsetTop,b.h=z.getBoundingClientRect().height||0):(w.style.verticalAlign="baseline",b.ascent=w.offsetTop-u.offsetTop,w.style.verticalAlign="bottom",b.h=w.offsetTop-u.offsetTop);b.descent=b.h-b.ascent;b.baseline=b.ascent;b.ascent=parseInt(b.ascent);b.descent=parseInt(b.descent);b.h=parseInt(b.h);b.baseline=parseInt(b.baseline);document.body.removeChild(z);
return C[a]=b};a.getFieldFontSize=function(a){a=Math.min(50,a);return a=24<=a?Math.floor(a/2+2-a/16):20<=a?12:17<=a?11:15<=a?10:9};a.getScreenshot=function(){var b=a.apps[0],c,e=document.createElement("canvas"),g=new Image;if(b){e.setAttribute("width",b.width);e.setAttribute("height",b.height);for(var d=e.getContext("2d"),k=0,l=b.spaces.length;k<l;k++)c=b.spaces[k],"R2"===c.type&&(d.drawImage(c.backgroundCanvas,c.x,c.y),d.drawImage(c.canvas,c.x,c.y),f(d,c.container,c.ctrs));0<b.northSpace.controls.length&&
h(d,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&h(d,b.southSpace.container,b.southSpace);0<b.eastSpace.controls.length&&h(d,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&h(d,b.westSpace.container,b.westSpace);g.src=e.toDataURL("image/png")}return g};a.showAbout=function(){var b="data:text/html;charset=utf-8,",b=a.creativeCommonsLicense?b+encodeURI("<html>\n<head>\n<style>\nbody{ text-align:center; }\niframe{ width:650px; height:73px; overflow:hidden; border:1px solid black; }\ndt{ font-weight:bold; margin-top:10px; }\n</style>\n</head>\n<body>\n<iframe src='http://arquimedes.matem.unam.mx/Descartes5/creditos/bannerPatrocinadores.html'></iframe>\n<h2> <a href='http://proyectodescartes.org/' target='_blank'>ProyectoDescartes.org</a> <br> <a href='http://descartesjs.org' target='_blank'>DescartesJS.org</a> </h2>\n<dl>\n<dt> Dise&ntilde;o funcional:</dt>\n<dd>\n<nobr>Jos&eacute; Luis Abreu Leon,</nobr>\n<nobr>Jos&eacute; R. Galo Sanchez,</nobr>\n<nobr>Juan Madrigal Muga</nobr>\n</dd>\n<dt>Autores del software:</dt>\n<dd>\n<nobr>Jos&eacute; Luis Abreu Leon,</nobr>\n<nobr>Marta Oliver&oacute; Serrat,</nobr>\n<nobr>Oscar Escamilla Gonz&aacute;lez,</nobr>\n<nobr>Joel Espinosa Longi</nobr>\n</dd>\n</dl>\n<p>\nEl software en Java est&aacute; bajo la licencia\n<a href='https://joinup.ec.europa.eu/software/page/eupl/licence-eupl'>EUPL v.1.1 </a>\n<br>\nEl software en JavaScript est&aacute; bajo licencia\n<a href='http://www.gnu.org/licenses/lgpl.html'>LGPL</a>\n</p>\n<p>\nLa documentaci&oacute;n y el c&oacute;digo fuente se encuentran en :\n<br>\n<a href='http://arquimedes.matem.unam.mx/Descartes5/'>http://arquimedes.matem.unam.mx/Descartes5/</a>\n</p><p>\nEste objeto, creado con Descartes, est&aacute; licenciado\npor sus autores como\n<a href='http://creativecommons.org/licenses/by-nc-sa/2.5/es/'><nobr>Creative Commons</nobr></a>\n<br>\n<a href='http://creativecommons.org/licenses/by-nc-sa/2.5/es/'><img src='http://i.creativecommons.org/l/by-nc-sa/3.0/es/88x31.png'></a>\n</p></body> </html>"):
b+encodeURI("<html>\n<head>\n<style>\nbody{ text-align:center; }\niframe{ width:650px; height:73px; overflow:hidden; border:1px solid black; }\ndt{ font-weight:bold; margin-top:10px; }\n</style>\n</head>\n<body>\n<iframe src='http://arquimedes.matem.unam.mx/Descartes5/creditos/bannerPatrocinadores.html'></iframe>\n<h2> <a href='http://proyectodescartes.org/' target='_blank'>ProyectoDescartes.org</a> <br> <a href='http://descartesjs.org' target='_blank'>DescartesJS.org</a> </h2>\n<dl>\n<dt> Dise&ntilde;o funcional:</dt>\n<dd>\n<nobr>Jos&eacute; Luis Abreu Leon,</nobr>\n<nobr>Jos&eacute; R. Galo Sanchez,</nobr>\n<nobr>Juan Madrigal Muga</nobr>\n</dd>\n<dt>Autores del software:</dt>\n<dd>\n<nobr>Jos&eacute; Luis Abreu Leon,</nobr>\n<nobr>Marta Oliver&oacute; Serrat,</nobr>\n<nobr>Oscar Escamilla Gonz&aacute;lez,</nobr>\n<nobr>Joel Espinosa Longi</nobr>\n</dd>\n</dl>\n<p>\nEl software en Java est&aacute; bajo la licencia\n<a href='https://joinup.ec.europa.eu/software/page/eupl/licence-eupl'>EUPL v.1.1 </a>\n<br>\nEl software en JavaScript est&aacute; bajo licencia\n<a href='http://www.gnu.org/licenses/lgpl.html'>LGPL</a>\n</p>\n<p>\nLa documentaci&oacute;n y el c&oacute;digo fuente se encuentran en :\n<br>\n<a href='http://arquimedes.matem.unam.mx/Descartes5/'>http://arquimedes.matem.unam.mx/Descartes5/</a>\n</p></body> </html>");
navigator.userAgent.match(/trident/gi)&&(b=a.creativeCommonsLicense?"http://arquimedes.matem.unam.mx/Descartes5/creditos/conCCL.html":"http://arquimedes.matem.unam.mx/Descartes5/creditos/sinCCL.html");window.open(b,"creditos","width=700,height=500,titlebar=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h;a._externalFilesContent={};a.openExternalFile=function(f){if(a._externalFilesContent[f])return a._externalFilesContent[f];
d=null;var b=!1;if(window.XMLHttpRequest)try{b=new XMLHttpRequest}catch(c){b=!1}else if(window.ActiveXObject)try{b=new ActiveXObject("Msxml2.XMLHTTP")}catch(p){try{b=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){b=!1}}h=b;h.open("GET",f,!1);try{h.send(null),d=h.responseText,d.match(String.fromCharCode(65533))&&(h.open("GET",f,!1),h.overrideMimeType("text/plain; charset=ISO-8859-1"),h.send(null),d=h.responseText)}catch(g){console.log("Error to load the file :",f),d=null}return d};a.addExternalFileContent=
function(d,b){a._externalFilesContent[d]=b};return a}(descartesJS||{}),descartesJS=function(a){function d(a){l=a.indexOf("--radial--");-1!=l&&(a=a.substring(0,l));c=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1),"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1)));"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1),c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=
!0,c=c.substring(1,c.length-1)));"*"===c.charAt(0)&&"*"!==c.charAt(c.length-1)?c=c.substring(1)+"$":"*"!==c.charAt(0)&&"*"===c.charAt(c.length-1)?c="^"+c.substring(0,c.length-1):"*"!==c.charAt(0)&&"*"!==c.charAt(c.length-1)?c="^"+c+"$":"*"===c.charAt(0)&&"*"===c.charAt(c.length-1)&&(c=c.substring(1,c.length-1));c=c.replace(/\?/g,"[\\S\\s]{1}");a.regExp=c;return a}function h(a,b){c=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=c.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),
expr:b.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),expr:b.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function f(a,b,c){b=parseFloat(b);n=a.expr[0];q=a.expr[1];k=c.evalExpression(n.expr);s=c.evalExpression(q.expr);r="("==n.type;t="["==n.type;m=")"==q.type;v="]"==q.type;return(r&&b>k||t&&b>=k)&&(m&&b<s||v&&b<=s)?1:0}function b(a){return a.toString().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")}if(a.loadLib)return a;var c,p,e,g,n,q,k,s,r,t,m,v,l;a.buildRegularExpresionsPatterns=function(a,b){"("===a.charAt(0)&&(")"===a.charAt(a.length-1)&&-1===a.indexOf(","))&&(a=a.substring(1,a.length-1));a=a.replace(/&squot;/g,"'").replace(/&amp;/g,"&").split("|");for(var g=0,f=a.length;g<f;g++){p=
a[g].split("&");e=[];for(var k=0,l=p.length;k<l;k++)c=p[k],-1===c.indexOf(",")||"("!==c.charAt(0)&&"["!==c.charAt(0)||")"!==c.charAt(c.length-1)&&"]"!==c.charAt(c.length-1)?e.push(d(c)):e.push(h(c,b));a[g]=e}return a};a.escorrecto=function(c,e,d,k){d=d||a.externalEvaluator;k=k||a.buildRegularExpresionsPatterns(c,d);e=b(e);c=0;for(var l=k.length;c<l;c++){p=k[c];g=!0;for(var m=0,n=p.length;m<n;m++)g=p[m].regExp?g&&!!e.match(RegExp(b(p[m].regExp),"i")):g&&f(p[m],e,d);if(g)return 1}return 0};a.esCorrecto=
function(e,d,k,l){k=k||a.externalEvaluator;l=l||a.buildRegularExpresionsPatterns(e,k);e=0;for(var m=l.length;e<m;e++){p=l[e];g=!0;for(var n=0,h=p.length;n<h;n++)(c=p[n].regExp)?(p[n].ignoreAcents&&(d=b(d),c=b(c)),p[n].ignoreCaps&&(d=d.toLowerCase(),c=b(c).toLowerCase()),g=g&&!!d.match(c)):g=g=g&&f(p[n],d,k);if(g)return 1}return 0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return 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;var d=Math.floor,h,f,b,c,p,e,g,n,q;a.Color=function(a,e){this.b=this.g=this.r=0;this.a=1;this.evaluator=e;if(a){if(babel[a]&&("net"===babel[a]&&(a="rojo"),a=babel[a],this.r=parseInt("0x"+a.substring(1,3),16),this.g=parseInt("0x"+a.substring(3,5),16),this.b=parseInt("0x"+a.substring(5,7),16),this.colorStr=a,this.getColor=this.getColorString),6===a.length&&(this.r=parseInt("0x"+a.substring(0,2),16),this.g=parseInt("0x"+
a.substring(2,4),16),this.b=parseInt("0x"+a.substring(4,6),16),this.colorStr="#"+a,this.getColor=this.getColorString),8===a.length&&(this.r=parseInt("0x"+a.substring(2,4),16),this.g=parseInt("0x"+a.substring(4,6),16),this.b=parseInt("0x"+a.substring(6,8),16),this.a=1-parseInt("0x"+a.substring(0,2),16)/255,this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString),"("===a[0]){f=[];b=this.splitComa(a.substring(1,a.length-1));for(var g=0,d=b.length;g<d;g++)c=
parseInt(b[g],16),b[g]!=c.toString(16)&&b[g]!=="0"+c.toString(16)?("["===b[g].charAt(0)&&"]"===b[g].charAt(b[g].length-1)&&(b[g]=b[g].substring(1,b[g].length-1)),f.push(this.evaluator.parser.parse(b[g]))):f.push(this.evaluator.parser.parse((c/255).toString()));this.rExpr=f[0];this.gExpr=f[1];this.bExpr=f[2];this.aExpr=f[3];this.getColor=this.getColorExpression}}else this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString};a.Color.prototype.splitComa=function(a){p=
[];for(var b=n=g=e=0,c=a.length;b<c;b++)q=a.charAt(b),"("===q?e++:")"===q?e--:"["===q?g++:"]"===q?g--:","===q&&(0===e&&0===g)&&(p.push(a.substring(n,b)),n=b+1);p.push(a.substring(n));return p};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){h=this.evaluator;this.r=d(255*h.evalExpression(this.rExpr));this.g=d(255*h.evalExpression(this.gExpr));this.b=d(255*h.evalExpression(this.bExpr));this.a=1-h.evalExpression(this.aExpr);return"rgba("+
this.r+","+this.g+","+this.b+","+this.a+")"};a.Color.prototype.borderColor=function(){return 380>this.r+this.g+this.b?"white":"black"};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=document.head,h=document.createElement("meta");h.setAttribute("http-equiv","X-UA-Compatible");h.setAttribute("content","chrome=1");d.appendChild(h);h=document.createElement("meta");h.setAttribute("name","viewport");h.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
d.appendChild(h);h=document.createElement("meta");h.setAttribute("name","apple-mobile-web-app-capable");h.setAttribute("content","yes");d.appendChild(h);h=document.createElement("meta");h.setAttribute("name","apple-mobile-web-app-status-bar-style");h.setAttribute("content","black-translucent");d.appendChild(h);(d=document.getElementById("StyleDescartesApps2"))&&d.parentNode.removeChild(d);d=document.createElement("style");d.type="text/css";d.id="StyleDescartesApps2";d.setAttribute("rel","stylesheet");
document.head.appendChild(d);d.innerHTML="body{ text-rendering:geometricPrecision; }\ncanvas{ image-rendering:optimizeSpeed; image-rendering:-moz-crisp-edges; image-rendering:-webkit-optimize-contrast; image-rendering:optimize-contrast; -ms-interpolation-mode:nearest-neighbor; }\ndiv.DescartesCatcher{ background-color:rgba(255, 255, 255, 0); cursor:pointer; position:absolute; }\ndiv.DescartesAppContainer{ border:0px solid black; position:relative; overflow:hidden; top:0px; left:0px; }\ndiv.DescartesLoader{ background-color :#efefef; position:absolute; overflow:hidden; -box-shadow:0px 0px 0px #888; background-image:linear-gradient(bottom, #bbb 0%, #efefef 50%, #bbb 100%); background-image:-o-linear-gradient(bottom, #bbb 0%, #efefef 50%, #bbb 100%); background-image:-moz-linear-gradient(bottom, #bbb 0%, #efefef 50%, #bbb 100%); background-image:-webkit-linear-gradient(bottom, #bbb 0%, #efefef 50%, #bbb 100%); background-image:-ms-linear-gradient(bottom, #bbb 0%, #efefef 50%, #bbb 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.DescartesButtonContainer{ position:absolute; }\ndiv.DescartesSpinnerContainer, div.DescartesTextFieldContainer, div.DescartesMenuContainer{ background:lightgray; position:absolute; overflow:hidden; }\ninput.DescartesSpinnerField, input.DescartesTextFieldField, input.DescartesMenuField, input.DescartesScrollbarField{ -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding:0px; border:solid #666 1px; position:absolute; top:0px; }\nlabel.DescartesSpinnerLabel, label.DescartesMenuLabel, label.DescartesScrollbarLabel, label.DescartesTextFieldLabel{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; 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, Helvetica, 'Droid Sans', Sans-serif; 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:#eee; overflow:hidden; position:absolute; }\n";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.sin,h=Math.floor,f=Math.random,b=Math.round,c=Math.abs,p=String.fromCharCode,e,g,n,q,k,s,r,t,m,v;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){e=[];for(var b=0;256>b;b++)e[b]=p(this.alfanum(h(c(7.5*(d(1*b-a)+d(1.4*b+a)+d(0.6*b-a)+d(2.2*b+a))))));return e.join("")};a.Krypto.prototype.encode=function(a){g=h(31*f());this.key=this.getKey(g);q=p(this.alfanum(g));return q+this.encripta(a)};
a.Krypto.prototype.decode=function(a){g=this.numalfa(a.charCodeAt(0));this.key=this.getKey(g);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;s=Array(3*a.length);for(var c=0,e=a.length;c<e;c++)m=256*h(a[c]+128)+b(255*f())+65536*b(255*f()),v=h((m<<this.shift(c))/256),s[3*c]=this.alfanum(v%32),s[3*c+1]=this.alfanum(v/32%
32),s[3*c+2]=this.alfanum(v/1024%32);return s};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;r=Array(a.length/3);for(var b=0,c=r.length;b<c;b++)v=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),m=h(256*v>>this.shift(b)),t=h(m/256)%256-128,0>t&&(t+=256),r[b]=t;return r};a.Krypto.prototype.alfanum=function(a){a=h(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){q=Array(a.length);for(var b=0,c=a.length;b<c;b++)q[b]=a.charCodeAt(b);return q};a.Krypto.prototype.bytesToString=function(a){for(var b=0,c=a.length;b<c;b++)a[b]=p(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){n=this.key.charCodeAt(a%this.key.length);q=this.numalfa(n);k=h(q/2%8);0==k&&(k=4);return k};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(d,h){this.parent=d;var f=d.evaluator,b=f.parser,c=new a.Auxiliary(d);this.delay=h.delay?b.parse(h.delay):b.parse("60");this.loop=h.loop?h.loop:!1;this.auto=void 0==h.auto?!0:h.auto;this.controls=h.controls;this.init=c.splitInstructions(b,h.init);this.doExpr=c.splitInstructions(b,h.doExpr);h.whileExpr&&(this.whileExpr=b.parse(h.whileExpr));var p=this,e,g,n=p.doExpr.length;this.animationExec=
function(){for(g=0;g<n;g++)f.evalExpression(p.doExpr[g]);p.parent.update();p.playing&&(0<f.evalExpression(p.whileExpr)||p.loop)?(e=f.evalExpression(p.delay),p.timer=setTimeout(p.animationExec,10>e?10:e)):(p.stop(),p.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,h=this.init.length;a<h;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,h){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(d,h){a.Action.call(this,d,h);this.parameter=(h||"").replace(/\\n/g,
"\n").replace(/&squot;/g,"'")};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(d,h){a.Action.call(this,d,h);var f=this.evaluator,b=f.parser;h=(h||"").replace(/&squot;/g,"'");h=h.replace(/;/g,"\\n");h=h.split("\\n")||[""];for(var c=[],p,e=0,g=h.length;e<g;e++)(p=b.parse(h[e],!0))&&c.push(p);g=c.length;this.execute=function(){for(e=0;e<g;e++)f.evalExpression(c[e])}};
a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(d,h){a.Action.call(this,d,h);this.parameter=h;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.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(d,h){a.Action.call(this,d,h);this.parameter=h;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));"_blank"!==this.target&&"_parent"!==this.target&&"_self"!==this.target&&"_top"!==this.target?this.actionExec=function(){window.parent.postMessage({type:"changeTarget",name:this.target,value:this.parameter},"*")}:"javascript"==this.parameter.substring(0,10)?(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,"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=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0")})};
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(d,h){a.Action.call(this,d,h);h||(this.urlAbout=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+h)};a.extend(a.About,a.Action);a.About.prototype.execute=function(){console.log("about");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(d,h){a.Action.call(this,d,h)};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(d,h){a.Action.call(this,d,h)};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(d,h){a.Action.call(this,d,h)};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(d,h){a.Action.call(this,d,h)};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(d,h){a.Action.call(this,d,h)};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;var d=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g;
a.PlayAudio=function(h,f){a.Action.call(this,h,f);f&&f.match(d)?this.filenameExpr=this.evaluator.parser.parse("'"+f.match(d)+"'"):this.filenameExpr=this.evaluator.parser.parse(f)};a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=function(){var a=this.theAudio=this.parent.getAudio(this.evaluator.evalExpression(this.filenameExpr));a.paused?a.play():(a.pause(),a.currentTime=0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Auxiliary=function(a,b){this.parent=
a;this.evaluator=this.parent.evaluator;this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var c in b)b.hasOwnProperty(c)&&(this[c]=b[c])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var d,h;a.Auxiliary.prototype.splitInstructions=function(a,b){h=[];b=b?b.split(";"):[""];for(var c=0,p=b.length;c<p;c++)(d=a.parse(b[c],!0))&&h.push(d);return h};a.Auxiliary.prototype.getPrivateVariables=function(a,b){h=[];b=b?b.split(/;|,/):[""];for(var c=0,
p=b.length;c<p;c++)(d=a.parse(b[c],!0))&&h.push(d);c=0;for(p=h.length;c<p;c++)h[c]="asign"===h[c].type?h[c].childs[0].value:"identifier"===h[c].type?h[c].value:"";return h};a.Auxiliary.prototype.parseExpressions=function(a){this.init=this.splitInstructions(a,this.init);this.privateVars=this.getPrivateVariables(a,this.local);this.doExpr=this.splitInstructions(a,this.doExpr);this.whileExpr=a.parse(this.whileExpr)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Variable=function(d,
h){a.Auxiliary.call(this,d,h);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(),this.parent.editableRegionVisible=!0)};a.extend(a.Variable,a.Auxiliary);a.Variable.prototype.registerTextField=function(){var a=document.createElement("div"),h=document.createElement("label");h.appendChild(document.createTextNode("___"+this.id+"=___"));var f=document.createElement("input");
f.value=this.expresionString;f.disabled=!this.editable;a.appendChild(h);a.appendChild(f);var b=this,c=b.evaluator.parser;f.onkeydown=function(a){13==a.keyCode&&(b.expresion=c.parse(this.value),c.setVariable(b.id,b.expresion),b.parent.update())};this.parent.editableRegion.textFields.push({container:a,type:"div"})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Constant=function(d,h){a.Auxiliary.call(this,d,h);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;var d,h,f;a.Vector=function(b,c){d=b.evaluator;h=d.parser;this.size=h.parse("3");a.Auxiliary.call(this,b,c);this.expresion=this.expresion.split(";");this.parseFile=h.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var b=this.expresion;
d=this.evaluator;h=d.parser;this.oldFile=this.file;if(f=d.evalExpression(this.parseFile))this.file=f;var c;if(this.file){c=(vectorElement=document.getElementById(this.file))&&"descartes/vectorFile"==vectorElement.type?vectorElement.text:a.openExternalFile(this.file);if(null!=c){c=c.replace(/\r/g,"").split("\n");for(var p=[],e=0,g=c.length;e<g;e++)""!=c[e]&&p.push(c[e]);c=p}null==c||1==c.length&&""==c[0]?this.size=0:(b=c,this.size=null);null===this.size&&(this.size=h.parse(b.length+""))}c=[];e=0;for(g=
b.length;e<g;e++)(p=h.parse(b[e],!0))&&"asign"!=p.type&&(p=h.parse(this.id+"["+e+"]="+b[e],!0)),c.push(p);b=[];e=0;for(g=d.evalExpression(this.size);e<g;e++)b.push(0);d.vectors[this.id]=b;d.setVariable(this.id+".long",d.evalExpression(this.size));e=0;for(g=c.length;e<g;e++)d.evalExpression(c[e])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(d,h){var f=d.evaluator,b=f.parser;this.rows=b.parse("3");this.columns=b.parse("3");a.Auxiliary.call(this,d,h);this.expresion=
this.splitInstructions(b,this.expresion);var b=f.evalExpression(this.rows),c=f.evalExpression(this.columns),p=[];p.type="matrix";for(var e,g=0;g<c;g++){e=[];for(var n=0,q=b;n<q;n++)e.push(0);p[g]=e}f.matrices[this.id]=p;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,h=a.evalExpression(this.rows),f=a.evalExpression(this.columns);a.setVariable(this.id+".filas",h);a.setVariable(this.id+".columnas",f);var b=a.matrices[this.id];b.rows=h;b.cols=f;
h=0;for(f=this.expresion.length;h<f;h++)a.evalExpression(this.expresion[h])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(d,h){a.Auxiliary.call(this,d,h);var f=this.evaluator,b=f.parser,c=this.id.indexOf("(");this.name=this.id.substring(0,c);this.params=this.id.substring(c+1,this.id.length-1);this.domain=this.range?b.parse(this.range):b.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||
(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(b);this.expresion=b.parse(this.expresion);var p=this;this.functionExec=function(){this.iterations=0;if(p.numberOfParams<=arguments.length){for(var b=[],c=0,d=p.privateVars.length;c<d;c++)b.push(f.getVariable(p.privateVars[c])),f.setVariable(p.privateVars[c],0);for(var h=[],c=0,d=p.params.length;c<d;c++)h[c]=f.getVariable(p.params[c]),f.setVariable(p.params[c],arguments[c]);c=0;for(d=p.init.length;c<d;c++)f.evalExpression(p.init[c]);do{c=
0;for(d=p.doExpr.length;c<d;c++)f.evalExpression(p.doExpr[c]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en la funci\u00f3n",this.id),0}while(0<f.evalExpression(p.whileExpr));var k=f.evalExpression(p.expresion);a.rangeOK=f.evalExpression(p.domain);c=0;for(d=p.params.length;c<d;c++)f.setVariable(p.params[c],h[c]);c=0;for(d=p.privateVars.length;c<d;c++)f.setVariable(p.privateVars[c],b[c]);return k}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.Algorithm=function(d,h){a.Auxiliary.call(this,d,h);var f=this.evaluator;this.parseExpressions(f.parser);this.algorithmExec=function(){for(var a=this.iterations=0,c=this.init.length;a<c;a++)f.evalExpression(this.init[a]);do{a=0;for(c=this.doExpr.length;a<c;a++)f.evalExpression(this.doExpr[a]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en el algoritmo",
this.id),0}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(d,h){a.Auxiliary.call(this,d,h);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;var d,h,f,b,c;a.Graphic=function(b,c){this.parent=b;this.evaluator=b.evaluator;var g=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=g.parse("1");this.abs_coord=!1;this.color=new a.Color("blue");2!==this.parent.version&&(this.color=new a.Color("20303a"),
this.parent.arquimedes&&(this.color=new a.Color("black")));this.trace="";this.expresion=g.parse("(0,0)");this.family="";this.family_interval=g.parse("[0,1]");this.family_steps=g.parse("8");this.editable=!1;this.font=5<=this.parent.version?"Monospaced,PLAIN,15":"Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=g.parse("2");for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);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);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10};a.Graphic.prototype.getSpace=function(){for(var a=this.parent.spaces,b,c=0,d=a.length;c<d;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic.prototype.getFamilyValues=function(){d=this.evaluator;h=d.evalExpression(this.family_interval);this.familyInf=h[0][0];this.familySup=h[0][1];this.fSteps=
Math.round(d.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,b,c){d=this.evaluator;this.getFamilyValues();f=d.getVariable(this.family);if(0<=this.fSteps)for(var n=0,h=this.fSteps;n<=h;n++)d.setVariable(this.family,this.familyInf+n*this.family_sep),0<d.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,c));d.setVariable("_Text_H_",0);d.setVariable(this.family,f)};a.Graphic.prototype.draw=
function(a,b){""!=this.family?this.drawFamilyAux(this.ctx,a,b):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.ctx,a,b))};a.Graphic.prototype.drawTrace=function(a,b){""!=this.family?this.drawFamilyAux(this.traceCtx,a,b):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,a,b))};a.Graphic.prototype.drawText=function(a,e,g,f,h,k,s,r,t,m,v){if("rtfNode"===e.type)a.fillStyle=h.getColor(),a.strokeStyle=h.getColor(),a.textBaseline="alphabetic",
e.draw(a,g,f,t,m,s,v,h.getColor());else for("simpleText"===e.type&&(e=e.toString(t,m).split("\\n")),g+=k.match("Arial")?-2:k.match("Times")?-2:0,d=this.evaluator,a.fillStyle=h.getColor(),a.font=k,a.textAlign=s,a.textBaseline=r,this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=3),c=1.2*this.fontSize||0,h=0,k=e.length;h<k;h++)b=e[h],this.border&&(a.lineJoin="round",a.strokeText(b,g,f+c*h)),a.fillText(b,g,f+c*h)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=
function(a,b){this.text=b=b.replace("&#x2013","\u2013").replace(/\&squot;/g,"'");this.textElements=[];this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var c="'",d=0,e=0,g=-1,h,q;d<b.length;)h=b.charAt(d),q=b.charAt(d-1),"["===h&&"\\"===q?(this.textElements.push(b.substring(e,d-1)+"["),this.textElementsMacros.push("'"+b.substring(e,d-1)+"['"),e=d+1):"]"===h&&"\\"===q?(this.textElements.push(b.substring(e,d-1)+"]"),this.textElementsMacros.push("'"+b.substring(e,
d-1)+"]'"),e=d+1):"["===h&&-1===g?(this.textElements.push(b.substring(e,d)),this.textElementsMacros.push("'"+b.substring(e,d)+"'"),e=d,g++):"["===h?g++:"]"===h&&0===g?(this.textElements.push(this.evaluator.parser.parse(b.substring(e,d+1))),this.textElementsMacros.push("["+b.substring(e,d+1)+"]"),e=d+1,g--):("]"==b.charAt(d)&&(g=0>g?g:g-1),c+=b.charAt(d)),d++;this.textElements.push(b.substring(e,d));this.textElementsMacros.push("'"+b.substring(e,d)+"'")};var d,h;a.SimpleText.prototype.toString=function(f,
b){d="";for(var c=0,p=this.textElements.length;c<p;c++)"string"===typeof this.textElements[c]?d+=this.textElements[c]:(h=this.evaluator.evalExpression(this.textElements[c])[0][0],""!==h&&("string"===typeof h?d+=h:(h=parseFloat(h),h=b?h.toFixed(f):a.removeNeedlessDecimals(h.toFixed(f)),d+=h.toString().replace(".",this.parent.decimal_symbol))));return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p,e,g,n,q,k,s,r,t,m,v,l,u,w,z,C,A,E,F,B,y,G;a.Equation=function(b,
c){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP="";a.Graphic.call(this,b,c);this.generateStroke();this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();s=new a.R2;r=new a.R2;t=new a.R2;l=new a.R2;m=new a.R2};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"===this.expresion.type){var b=this.expresion.childs[0],c=this.expresion.childs[1];"identifier"!=b.type||"y"!=
b.value||c.contains("y")?"identifier"!=c.type||"y"!=c.value||b.contains("y")?"identifier"!=b.type||"x"!=b.value||c.contains("x")?"identifier"!=c.type||("x"!=c.value||b.contains("x"))||(this.of_y=!0,this.funExpr=c,this.drawAux=this.drawAuxFun):(this.funExpr=c,this.of_y=!0,this.drawAux=this.drawAuxFun):(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):(this.funExpr=c,this.of_y=!1,this.drawAux=this.drawAuxFun)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.generateStroke=
function(){this.auxCanvas=document.createElement("canvas");this.oldWwidth=parseInt(this.evaluator.evalExpression(this.width));this.width_2=parseInt(this.oldWwidth/2)||1;this.auxCanvas.setAttribute("width",this.oldWwidth);this.auxCanvas.setAttribute("height",this.oldWwidth);this.auxCtx=this.auxCanvas.getContext("2d");this.auxCtx.fillStyle=this.color.getColor();this.auxCtx.fillRect(0,0,this.oldWwidth,this.oldWwidth)};var H;a.Equation.prototype.update=function(){H=parseInt(this.evaluator.evalExpression(this.width));
H!==this.oldWwidth&&this.generateStroke()};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.drawFamilyAux=function(a,b,c){h=this.evaluator;this.getFamilyValues();tempParam=h.getVariable(this.family);if(0<=this.fSteps)for(var e=0,g=this.fSteps;e<=g;e++)h.setVariable(this.family,this.familyInf+e*this.family_sep),this.update(),this.drawAux(a,b,c);h.setVariable(this.family,
tempParam)};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(K,I,x){K.lineWidth=1;h=this.evaluator;f=h.parser;b=this.space;c=h.evalExpression(this.width);K.fillStyle=x.getColor();K.translate(-parseInt(c/2),-parseInt(c/2));p=f.getVariable("x");e=f.getVariable("y");g=b.w;n=b.h;q=g/9;3>q&&(q=3);k=n/7;3>k&&(k=3);d=[];s.set(0,0);r.set(0,0);t.set(0,0);for(G=parseInt(k/2);G<n;G+=k)for(y=parseInt(q/2);y<g;y+=q)if(this.abs_coord?
(l.set(y,G),v=this.newt.findZero(l),h.setVariable("x",v.x),h.setVariable("y",v.y),m.set(v.x,v.y)):(l.set(b.getRelativeX(y),b.getRelativeY(G)),v=this.newt.findZero(l),h.setVariable("x",v.x),h.setVariable("y",v.y),m.set(b.getAbsoluteX(v.x),b.getAbsoluteY(v.y))),u=m.ix(),w=m.iy(),!(0>u||u>=g||0>w||w>=n||d[u+w*b.w])&&(d[u+w*b.w]=!0,a.rangeOK&&h.evalExpression(this.drawif)&&K.drawImage(this.auxCanvas,u,w),s.x=v.x,s.y=v.y,r.x=v.x,r.y=v.y,z=this.newt.getUnitNormal(),0!=z.x||0!=z.y))for(z.rotL90(),t.x=z.x,
t.y=z.y,A=C=0,E=!1;2>A;){E&&(t.x=-z.x,t.y=-z.y,v.x=s.x,v.y=s.y,r.x=v.x,r.y=v.y,this.abs_coord?m.set(v.x,v.y):m.set(b.getAbsoluteX(v.x),b.getAbsoluteY(v.y)),u=m.ix(),w=m.iy(),E=!1,C=0);this.abs_coord?(v.x+=t.x,v.y+=t.y):(v.x+=t.x/b.scale,v.y+=t.y/b.scale);v=this.newt.findZero(v);h.setVariable("x",v.x);h.setVariable("y",v.y);t.x=v.x-r.x;t.y=v.y-r.y;t.normalize();if(0==t.x&&0==t.y)break;r.x=v.x;r.y=v.y;this.abs_coord?m.set(v.x,v.y):m.set(b.getAbsoluteX(v.x),b.getAbsoluteY(v.y));F=parseInt(m.ix());B=
parseInt(m.iy());if(F!=u||B!=w)if(I=u,x=w,u=F,w=B,0<=u&&u<g&&0<=w&&w<n){C=0;var H=d[u+w*b.w];d[u+w*b.w]=!0;for(var D=1;8>D;D++){var J=I+Math.round((u-I)*D/8),M=x+Math.round((w-x)*D/8);0<=J&&(J<g&&0<=M&&M<n)&&(d[J+M*b.w]=!0)}a.rangeOK&&h.evalExpression(this.drawif)&&K.drawImage(this.auxCanvas,u,w);if(H)break}else E=!0,A++;else 4<++C&&(E=!0,A++)}K.setTransform(1,0,0,1,0,0)};a.Equation.prototype.X=function(a,b,c){c||(b=this.space.w/2+this.space.Ox+this.space.scale*b);b<-a&&(b=-a);b>this.space.w+a&&(b=
this.space.w+a);return b};a.Equation.prototype.Y=function(a,b,c){c||(b=this.space.h/2+this.space.Oy-this.space.scale*b);b<-a&&(b=-a);b>this.space.h+a&&(b=this.space.h+a);return b};a.Equation.prototype.XX=function(a,b,c){return Math.round(this.X(a,b,c))};a.Equation.prototype.YY=function(a,b,c){return Math.round(this.Y(a,b,c))};a.Equation.prototype.extrapolate=function(b,c,e,g,d,f){for(var k=this.evaluator.getVariable(c),m=f/2,h=0;1E-12<Math.abs(m);){var l=this.evaluator.getVariable(c),n=this.evaluator.getVariable(c)+
m;this.evaluator.setVariable(c,n);var p=!0,q=d;d=this.evaluator.evalExpression(this.funExpr);this.evaluator.setVariable(e,d);if(0<this.evaluator.evalExpression(b)){var r=new a.R2(Math.min(q,d),Math.max(q,d)),s=0,s=0<f?this.Singularity(Math.abs(m),c,g,l,q,n,d,r):this.Singularity(Math.abs(m),c,g,n,d,l,q,r);0<s&&(p=!1)}else p=!1;p?h+=m:this.evaluator.setVariable(c,l);m/=2}this.evaluator.setVariable(c,k);return new a.R2(h/Math.abs(f),d)};a.Equation.prototype.extrapolateOnSingularity=function(b,c,e,g,
d,f){g=this.evaluator.getVariable(c);for(var k=f/2,m=0,h=d;1E-12<Math.abs(k);){this.evaluator.setVariable(this.evaluator.getVariable(c)+k);var l=!0;0<this.evaluator.evalExpression(b)?(h=this.evaluator.evalExpression(this.funExpr),this.evaluator.setVariable(e,h),0>=this.evaluator.evalExpression(b)&&(l=!1)):l=!1;l?m+=k:this.evaluator.setVariable(this.evaluator.getVariable(c)-k);k/=2}if(0==m)for(k=f/2,m=f,h=d;1E-12<Math.abs(k);)this.evaluator.setVariable(this.evaluator.getVariable(c)-k),l=!0,0<this.evaluator.evalExpression(b)?
h=this.evaluator.evalExpression(this.funExpr):l=!1,l?m+=-k:this.evaluator.setVariable(this.evaluator.getVariable(c)+k),k/=2;this.evaluator.setVariable(g);return new a.R2(m/Math.abs(f),h)};a.Equation.prototype.Singularity=function(a,b,c,e,g,d,f,k){if(e>=d)return 2;var m=this.evaluator.getVariable(b),h=0;if(1E-12>Math.abs(d-e)||1E-8>Math.abs(d-e)&&Math.abs(f-g)>Math.abs(a))return this.evaluator.setVariable(b,m),1;var l=(e+d)/2;this.evaluator.setVariable(b,l);var n=this.evaluator.evalExpression(this.funExpr);
if(Math.abs(f-g)>a){this.evaluator.setVariable(b,e-1E-6);var p=this.evaluator.evalExpression(this.funExpr),p=(g-p)/1E-6;this.evaluator.setVariable(b,d+1E-6);var q=(this.evaluator.evalExpression(this.funExpr)-f)/1E-6,r=(f-g)/(d-e);if((10>Math.abs(q)||10>Math.abs(p))&&(0<=q&&0<=p||0>=q&&0>=p)&&8*Math.abs(q)<Math.abs(r))return this.evaluator.setVariable(b,m),2}k.x<=n&&n<=k.y||(this.evaluator.setVariable(b,l),k.x=Math.min(g,n),k.y=Math.max(g,n),e=this.Singularity(a/2,b,c,e,g,l,n,k),this.evaluator.setVariable(b,
d),k.x=Math.min(f,n),k.y=Math.max(f,n),a=this.Singularity(a/2,b,c,l,n,d,f,k),h=Math.max(e,a));this.evaluator.setVariable(b,m);return h};a.Equation.prototype.drawAuxFun=function(b,c,g){p=this.evaluator.parser.getVariable("x");e=this.evaluator.parser.getVariable("y");c="x";g="y";this.of_y&&(c="y",g="x");var d=this.drawif,f=this.evaluator.evalExpression(this.width),k=!1,m=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),m=this.of_y?m.ix():m.iy(),h=0,l=0,n=0,q=1/this.space.scale,r=
q*(this.of_y?-this.space.h+(this.space.h/2+this.space.Oy):-(this.space.w/2+this.space.Ox)),h=0;this.abs_coord&&(r=0,q=1);for(var s=this.of_y?this.space.h:this.space.w;l<s;){var u=!0,v=0;this.evaluator.setVariable(c,r);var t=this.evaluator.evalExpression(this.funExpr);if(isNaN(t))u=!1;else{this.evaluator.setVariable(g,t);if(0<this.evaluator.evalExpression(this.drawif)&&a.rangeOK){if(k){var v=Math.min(h,t),w=Math.max(h,t),w=new a.R2(v,w),v=this.Singularity(q,c,0,r-q,h,r,t,w);0===v?(h<=t?(h=w.x,t=w.y):
(t=w.x,h=w.y),v=this.of_y?this.XX(f,h,this.abs_coord):this.YY(f,h,this.abs_coord),h=this.abs_coord?Math.round(t):this.of_y?this.XX(f,t,this.abs_coord):this.YY(f,t,this.abs_coord),this.fillM&&h>m&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(m+1,this.space.h-l+0.5),b.lineTo(h,this.space.h-l+0.5)):(b.moveTo(l+0.5,m+1),b.lineTo(l+0.5,h)),b.stroke()),this.fillP&&h<m&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(m-1,this.space.h-
l+0.5),b.lineTo(h,this.space.h-l+0.5)):(b.moveTo(l+0.5,m-1),b.lineTo(l+0.5,h)),b.stroke()),b.lineWidth=f,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(v+0.5,this.space.h-n),b.lineTo(h+0.5,this.space.h-l)):(b.moveTo(n+0.5,v),b.lineTo(l+0.5,h)),b.stroke()):(1===v&&(this.evaluator.setVariable(c,r-q),n=this.extrapolate(d,c,g,0,h,q),this.YY(f,n.y,this.abs_coord),this.evaluator.setVariable(c,r),n=this.extrapolate(d,c,g,0,t,-q),this.YY(f,n.y,this.abs_coord)),this.YY(f,t,this.abs_coord))}else n=
this.extrapolateOnSingularity(d,c,g,0,t,-q),this.YY(f,n.y,this.abs_coord),this.YY(f,t,this.abs_coord);h=t}else u=!1;k&&!u&&(this.evaluator.setVariable(c,r-q),this.evaluator.setVariable(g,h),n=this.extrapolate(d,c,g,0,h,q),this.YY(f,n.y,this.abs_coord),this.evaluator.setVariable(c,r))}k=u;r+=q;n=l++}this.evaluator.parser.setVariable("x",p);this.evaluator.parser.setVariable("y",e)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=
!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parseExpression(),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round;a.Curve=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,
b,c);(this.visible=2==this.parent.version&&void 0==this.visible?!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);var h,f,b,c,p,e,g,n,q,k,s;a.Curve.prototype.update=function(){h=this.evaluator;f=h.evalExpression(this.parameter_interval);this.paraInf=f[0][0];this.paraSup=f[0][1];this.pSteps=h.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,t,m){h=this.evaluator;b=this.space;c=d(h.evalExpression(this.width));f.lineWidth=0<c?c:1E-6;f.lineCap="round";f.lineJoin="round";f.strokeStyle=m.getColor();p=h.getVariable(this.parameter);f.beginPath();h.setVariable(this.parameter,this.paraInf);e=h.evalExpression(this.expresion);this.exprX=this.abs_coord?d(e[0][0]):d(b.getAbsoluteX(e[0][0]));this.exprY=this.abs_coord?d(e[0][1]):
d(b.getAbsoluteY(e[0][1]));this.rotateExp&&(g=a.degToRad(h.evalExpression(this.rotateExp)),n=Math.cos(g),q=Math.sin(g),k=this.exprX*n-this.exprY*q,s=this.exprX*q+this.exprY*n,this.exprX=k,this.exprY=s);f.moveTo(this.exprX+0.5,this.exprY+0.5);for(m=1;m<=this.pSteps;m++)h.setVariable(this.parameter,this.paraInf+m*this.paraSep),e=h.evalExpression(this.expresion),this.exprX=this.abs_coord?d(e[0][0]):d(b.getAbsoluteX(e[0][0])),this.exprY=this.abs_coord?d(e[0][1]):d(b.getAbsoluteY(e[0][1])),this.rotateExp&&
(k=this.exprX*n-this.exprY*q,s=this.exprX*q+this.exprY*n,this.exprX=k,this.exprY=s),f.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&(f.fillStyle=t.getColor(),f.fill());f.stroke();h.setVariable(this.parameter,p)};a.Curve.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parent.update())};this.parent.editableRegion.textFields.push(a)};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI,h=Math.round,f,b,c,p,e,g,n,q,k,s,r,t,m;a.Sequence=function(b,c){this.size=b.evaluator.parser.parse("2");this.range=b.evaluator.parser.parse("[1, 100]");a.Graphic.call(this,b,c)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){f=this.evaluator;c=f.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(p=a.degToRad(f.evalExpression(this.rotateExp)),e=Math.cos(p),
g=Math.sin(p),n=this.exprX*e-this.exprY*g,q=this.exprX*g+this.exprY*e,this.exprX=n,this.exprY=q);r=f.evalExpression(this.range);this.rangeInf=r[0][0];this.rangeMax=r[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(a,e){f=this.evaluator;b=this.space;t=Math.ceil(f.evalExpression(this.size)-0.4);a.fillStyle=e.getColor();a.beginPath();
this.rangeInf>this.rangeMax&&(m=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=m);for(var g=f.getVariable("n"),n=this.rangeInf,q=this.rangeMax;n<=q;n++)f.setVariable("n",n),c=f.evalExpression(this.expresion),this.exprX=c[0][0],this.exprY=c[0][1],k=this.abs_coord?h(this.exprX):h(b.getAbsoluteX(this.exprX)),s=this.abs_coord?h(this.exprY):h(b.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(k,s,t,0,d,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,k+t,s-t,this.color,
this.font,"start","alphabetic",f.evalExpression(this.decimals),this.fixed,!0);f.setVariable("n",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI,h=Math.round,f,b,c,p,e,g,n,q,k,s,r,t;a.Point=function(b,c){this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Point,a.Graphic);a.Point.prototype.update=function(){f=this.evaluator;c=f.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(p=a.degToRad(f.evalExpression(this.rotateExp)),
e=Math.cos(p),g=Math.sin(p),n=this.exprX*e-this.exprY*g,q=this.exprX*g+this.exprY*e,this.exprX=n,this.exprY=q)};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(a,c){f=this.evaluator;b=this.space;r=h(f.evalExpression(this.size));t=r+1;a.fillStyle=c.getColor();k=this.abs_coord?h(this.exprX):h(b.getAbsoluteX(this.exprX));s=this.abs_coord?h(this.exprY):
h(b.getAbsoluteY(this.exprY));a.beginPath();a.arc(k,s,r,0,d,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,k+t+1,s-t,this.color,this.font,"start","alphabetic",f.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,h=2*Math.PI,f,b,c,p,e,g,n,q,k,s,r,t,m,v,l,u,w,z;a.Segment=function(b,c){this.width=b.evaluator.parser.parse("1");this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Segment,
a.Graphic);a.Segment.prototype.update=function(){f=this.evaluator;c=f.evalExpression(this.expresion);this.endPoints=[];for(var b=0,d=c.length;b<d;b++)this.endPoints[b]={x:c[b][0],y:c[b][1]};if(this.rotateExp)for(p=a.degToRad(f.evalExpression(this.rotateExp)),e=Math.cos(p),g=Math.sin(p),b=0,d=this.endPoints.length;b<d;b++)n=this.endPoints[b].x*e-this.endPoints[b].y*g,q=this.endPoints[b].x*g+this.endPoints[b].y*e,this.endPoints[b].x=n,this.endPoints[b].y=q};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(a,c,e){f=this.evaluator;b=this.space;k=d(f.evalExpression(this.width));a.lineWidth=0<k?k:1E-6;m=f.evalExpression(this.size);0>m&&(m=0);a.fillStyle=c.getColor();a.strokeStyle=e.getColor();a.lineCap="round";s=10+a.lineWidth;v=0==a.lineWidth%2?0:0.5;this.abs_coord?(l=d(this.endPoints[0].x),u=d(this.endPoints[0].y),w=d(this.endPoints[1].x),z=d(this.endPoints[1].y)):
(l=d(b.getAbsoluteX(this.endPoints[0].x)),u=d(b.getAbsoluteY(this.endPoints[0].y)),w=d(b.getAbsoluteX(this.endPoints[1].x)),z=d(b.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(l+v,u+v);a.lineTo(w+v,z+v);a.stroke();a.beginPath();a.arc(l,u,m,0,h,!0);a.arc(w,z,m,0,h,!0);a.fill();this.text!=[""]&&(r=parseInt((l+w)/2)-3,t=parseInt((u+z)/2)+3,this.uber.drawText.call(this,a,this.text,r+s,t-s,this.color,this.font,"start","alphabetic",f.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h=Math.round,f,b,c,p,e,g,n,q,k,s,r,t,m,v,l,u,w,z;a.Arrow=function(b,c){this.width=b.evaluator.parser.parse("5");this.size=b.evaluator.parser.parse("2");this.spear=b.evaluator.parser.parse("8");this.arrow=new a.Color("ee0022");a.Graphic.call(this,b,c)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){f=this.evaluator;b=f.evalExpression(this.expresion);this.endPoints=[];for(var d=0,k=b.length;d<k;d++)this.endPoints[d]=
{x:b[d][0],y:b[d][1]};if(this.rotateExp)for(c=a.degToRad(f.evalExpression(this.rotateExp)),p=Math.cos(c),e=Math.sin(c),d=0,k=this.endPoints.length;d<k;d++)g=this.endPoints[d].x*p-this.endPoints[d].y*e,n=this.endPoints[d].x*e+this.endPoints[d].y*p,this.endPoints[d].x=g,this.endPoints[d].y=n};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(b,
c,e){f=this.evaluator;q=this.space;f.evalExpression(this.size);r=f.evalExpression(this.width);0>r&&(r=0);t=Math.ceil(r/2);m=q.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);v=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);b.fillStyle=c.getColor();b.strokeStyle=e.getColor();b.lineWidth=2;this.abs_coord?(l=h(this.endPoints[0].x),u=h(this.endPoints[0].y),w=h(this.endPoints[1].x),z=h(this.endPoints[1].y)):
(l=h(q.getAbsoluteX(this.endPoints[0].x)),u=h(q.getAbsoluteY(this.endPoints[0].y)),w=h(q.getAbsoluteX(this.endPoints[1].x)),z=h(q.getAbsoluteY(this.endPoints[1].y)));c=f.evalExpression(this.spear);0>c&&(c=0);b.save();b.translate(l,u,v);this.abs_coord?0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?b.rotate(this.angle):b.rotate(-this.angle):(v*=m,0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?b.rotate(-this.angle):b.rotate(this.angle));b.beginPath();b.moveTo(-t,d(-t));
b.lineTo(d(v-c-r),d(-t));b.lineTo(d(v-2*c),d(-c-t));b.lineTo(d(v),0);b.lineTo(d(v-2*c),d(c+t));b.lineTo(d(v-c-r),d(t));b.lineTo(-t,d(t));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(k=parseInt((l+w)/2)-3,s=parseInt((u+z)/2)+3,this.uber.drawText.call(this,b,this.text,k,s,e,this.font,"start","alphabetic",f.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,h,f,b,c,p,e,g,n,q,k,s,r;a.Polygon=function(b,
c){this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,c);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){h=this.evaluator;b=h.evalExpression(this.expresion);for(var d=0,f=b.length;d<f;d++)this.endPoints[d]={x:b[d][0],y:b[d][1]};if(this.rotateExp)for(c=a.degToRad(h.evalExpression(this.rotateExp)),p=Math.cos(c),e=Math.sin(c),d=0,f=this.endPoints.length;d<f;d++)g=this.endPoints[d].x*p-this.endPoints[d].y*e,n=this.endPoints[d].x*e+this.endPoints[d].y*
p,this.endPoints[d].x=g,this.endPoints[d].y=n};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(a,b,c){h=this.evaluator;f=this.space;q=d(h.evalExpression(this.width));a.lineWidth=0<q?q:1E-6;a.strokeStyle=c.getColor();a.lineCap="round";a.lineJoin="round";k=0<q?0.5:0;s=this.abs_coord?d(this.endPoints[0].x):d(f.getAbsoluteX(this.endPoints[0].x));
r=this.abs_coord?d(this.endPoints[0].y):d(f.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(s+k,r+k);c=1;for(var e=this.endPoints.length;c<e;c++)s=this.abs_coord?d(this.endPoints[c].x):d(f.getAbsoluteX(this.endPoints[c].x)),r=this.abs_coord?d(this.endPoints[c].y):d(f.getAbsoluteY(this.endPoints[c].y)),a.lineTo(s+k,r+k);this.fill&&(a.fillStyle=b.getColor(),a.fill());a.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,h,f,b,c,p,e,g,n,q,k,s,
r,t,m,v,l,u,w,z,C,A;a.Arc=function(b,c){this.width=b.evaluator.parser.parse("1");this.fill="";this.center=b.evaluator.parser.parse("(0,0)");this.radius=b.evaluator.parser.parse("1");this.init=b.evaluator.parser.parse("0");this.end=b.evaluator.parser.parse("90");a.Graphic.call(this,b,c)};a.extend(a.Arc,a.Graphic);a.Arc.prototype.update=function(){h=this.evaluator;f=h.evalExpression(this.center);this.exprX=f[0][0];this.exprY=f[0][1];this.rotateExp&&(b=a.degToRad(h.evalExpression(this.rotateExp)),c=
Math.cos(b),p=Math.sin(b),e=this.exprX*c-this.exprY*p,g=this.exprX*p+this.exprY*c,this.exprX=e,this.exprY=g);var d=h.evalExpression(this.init),l=h.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?(n=d[0][0],q=d[0][1],k=l[0][0],s=l[0][1],this.vectors?this.abs_coord&&(q=-q,s=-s):this.abs_coord?(n-=this.exprX,q=-q+this.exprY,
k-=this.exprX,s=-s+this.exprY):(n-=this.exprX,q-=this.exprY,k-=this.exprX,s-=this.exprY),r=0==n?0>q?-Math.PI/2:Math.PI/2:Math.acos(1*n/Math.sqrt(n*n+q*q)),t=0==k?0>s?-Math.PI/2:Math.PI/2:Math.acos(1*k/Math.sqrt(k*k+s*s)),0<n&&(0<q&&this.abs_coord)&&(r=2*Math.PI-r),0<n&&(0>q&&!this.abs_coord)&&(r=2*Math.PI-r),0>n&&(0>q&&!this.abs_coord)&&(r=2*Math.PI-r),0>n&&(0<q&&this.abs_coord)&&(r=2*Math.PI-r),0<k&&(0<s&&this.abs_coord)&&(t=2*Math.PI-t),0<k&&(0>s&&!this.abs_coord)&&(t=2*Math.PI-t),0>k&&(0>s&&!this.abs_coord)&&
(t=2*Math.PI-t),0>k&&(0<s&&this.abs_coord)&&(t=2*Math.PI-t),m=Math.min(r,t),v=Math.max(r,t),r=m,t=v,t-r>Math.PI&&this.abs_coord&&(r=v,t=m),t-r<=Math.PI&&!this.abs_coord&&(r=v,t=m),this.iniAng=r,this.endAng=t,this.drawPoints=!0):(this.iniAng=a.degToRad(d),this.endAng=a.degToRad(l),this.drawAngle=!0)};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(a,
b,c){h=this.evaluator;l=this.space;z=h.evalExpression(this.radius);0>z&&(z=0);A=d(h.evalExpression(this.width));a.lineWidth=0<A?A:1E-6;a.lineCap="round";a.strokeStyle=c.getColor();this.drawAngle?(this.abs_coord?(u=d(this.exprX),w=d(this.exprY)):(u=d(l.getAbsoluteX(this.exprX)),w=d(l.getAbsoluteY(this.exprY)),z*=l.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&(C=this.iniAng,this.iniAng=this.endAng,this.endAng=C)):this.drawPoints&&(this.abs_coord?(u=d(this.exprX),
w=d(this.exprY)):(u=d(l.getAbsoluteX(this.exprX)),w=d(l.getAbsoluteY(this.exprY)),z*=l.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng));this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(u,w),a.arc(u,w,z,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();a.arc(u,w,z,this.iniAng,this.endAng,void 0);a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,u+4,w-2,this.color,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p,e,g,n,q,k,s,r,t,m,v,l,u;a.Text=function(b,c){this.width=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.align||(this.align="start");this.ascent=this.fontSize-Math.ceil(this.fontSize/7)-(this.font.match("Courier")?3:0);this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){d=this.evaluator;h=d.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1];this.rotateExp&&(f=a.degToRad(d.evalExpression(this.rotateExp)),
b=Math.cos(f),c=Math.sin(f),p=this.exprX*b-this.exprY*c,e=this.exprX*c+this.exprY*b,this.exprX=p,this.exprY=e)};a.Text.prototype.draw=function(){this.uber.draw.call(this,this.color)};a.Text.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.color)};a.Text.prototype.drawAux=function(a,b){u=this.evaluator.evalExpression(this.decimals);"rtfNode"===this.text.type?(k=this.text,this.ascent=0):k=this.splitText(this.text.toString(u,this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,
a,k,parseInt(this.exprX)+5,parseInt(this.exprY)+this.ascent,b,this.font,this.align,"alphabetic",u,this.fixed)};a.Text.prototype.splitText=function(a){d=this.evaluator;g=d.evalExpression(this.width);k=[];this.ctx.font=this.font;if(20<=g&&"undefined"!=a.type){for(var b=0,c=a.length;b<c;b++)n=a[b],q=this.ctx.measureText(n).width,q>g?k=k.concat(this.splitWords(n,g)):k.push(n);s=Math.floor(1.2*this.fontSize)*k.length;d.setVariable("_Text_H_",s);return k}d.setVariable("_Text_H_",0);d.setVariable("_Text_W_",
1E3);return a};a.Text.prototype.splitWords=function(a,b){r=a;t=[];m="";l=0;for(var c,e=0,d=a.length;e<d;e++)v=r.charAt(e)," "===v&&(lastIndexOfWhite=e),m+=v,Math.round(this.ctx.measureText(m).width)>b&&(c=a.substring(l,e+1)," "!==v&&(-1===c.indexOf(" ")?(lastIndexOfWhite=e,e--):e=lastIndexOfWhite),t.push(a.substring(l,lastIndexOfWhite)),m="",l=e+1);t.push(a.substring(l));return t};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,h,f,b,c,p,e,g,n,q,k,s,r,t,m;
a.Image=function(b,c){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);a.Image.prototype.update=function(){h=this.evaluator;f=h.evalExpression(this.expresion);this.exprX=f[0][0];this.exprY=f[0][1];this.rotateExp&&(b=a.degToRad(h.evalExpression(this.rotateExp)),c=Math.cos(b),p=Math.sin(b),e=this.exprX*c-this.exprY*p,g=this.exprX*p+this.exprY*c,this.exprX=e,this.exprY=g);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((n=h.evalExpression(this.file))||""==n)this.img=this.parent.getImage(n)};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(b){h=this.evaluator;q=this.space;this.img&&(this.img.ready&&this.img.complete)&&(k=this.centered?0:this.img.width/2,s=this.centered?0:this.img.height/2,r=this.abs_coord?d(this.exprX):d(q.getAbsoluteX(this.exprX)),t=this.abs_coord?d(this.exprY):d(q.getAbsoluteY(this.exprY)),m=a.degToRad(-h.evalExpression(this.inirot)),b.translate(r+k,t+s),b.rotate(m),b.scale(this.scaleX,this.scaleY),this.opacity&&(b.globalAlpha=h.evalExpression(this.opacity)),b.drawImage(this.img,-this.img.width/2,-this.img.height/
2),b.setTransform(1,0,0,1,0,0),b.globalAlpha=1)};return a}(descartesJS||{}),descartesJS=function(a){function d(a,b,c){g=4*(b+c*a.width);return{r:a.data[g],g:a.data[g+1],b:a.data[g+2],a:a.data[g+3]}}if(a.loadLib)return a;var h,f,b,c,p,e,g;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){h=this.evaluator.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,
this.color)};a.Fill.prototype.drawTrace=function(){};a.Fill.prototype.drawAux=function(a,h){h.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(f=parseInt(this.exprX),b=parseInt(this.exprY)):(f=parseInt(this.space.getAbsoluteX(this.exprX)),b=parseInt(this.space.getAbsoluteY(this.exprY)));if(!(0>f||0>b||f>=this.space.w||b>=this.space.h)){c=[{x:f,y:b}];for(e=d(imageData,f,b);0<c.length;){p=c.pop();f=p.x;b=p.y;var k=d(imageData,f,b);if(e.r===k.r&&e.g===k.g&&e.b===
k.b&&e.a===k.a){var k=imageData,s=h;g=4*(f+b*k.width);k.data[g+0]=s.r;k.data[g+1]=s.g;k.data[g+2]=s.b;k.data[g+3]=255-s.a;0<f&&c.push({x:f-1,y:b});f<imageData.width-1&&c.push({x:f+1,y:b});c.push({x:f,y:b-1});c.push({x:f,y:b+1})}}this.ctx.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a,d){if(a.loadLib)return a;var h=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,f;a.Macro=function(b,c){this.expresion=void 0;this.inirot=b.evaluator.parser.parse("0");this.inipos=b.evaluator.parser.parse("(0,0)");
a.Graphic.call(this,b,c);for(var f in c)c.hasOwnProperty(f)&&(this[f]=c[f]);this.graphics=[];f=b.lessonParser;var e=new a.Tokenizer;if(void 0!=this.expresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var g=this.evaluator.evalExpression(this.expresion),n;g&&((n=document.getElementById(g))&&"descartes/macro"==n.type?n=n.text:(n=a.openExternalFile(g))&&!n.match(/tipo_de_macro/g)&&(n=null));var q,k;if(n){k=n.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,"&").replace(/\r/g,"").split("\n");n=[];for(var g=0,s=k.length;g<s;g++)if(q=k[g].indexOf("="),-1!==
q){q=f.split(k[g]);for(var r=0,t=q.length;r<t;r++)q[r]&&1<q.length&&("id"!==d[q[r][0]]&&"type"!==d[q[r][0]]||n.push(q))}for(var m,v,g=0,s=n.length;g<s;g++)for(t=(r=n[g]||[])&&r[0]&&"id"===r[0][0],k=0,q=r.length;k<q;k++)if(m=r[k][0].indexOf("."),-1===m||t?m=d[r[k][0]]:(m=d[r[k][0].substring(m+1)],r[k][0]=this.name+"."+r[k][0]),!("font"===m||("fill"===m||"color"===m||"arrow"===m)&&"("!==r[k][1].charAt(0)||"file"===m&&r[k][1].match(h)||"id"!==m&&void 0!==d[r[k][1]]))if("text"==m)if(r[k][1].match(/\{\\rtf1/)){m=
r[k][1];var l=this;v=function(a,b){for(var c=e.tokenize(b.replace(/\&squot;/g,"'")),d=0,g=c.length;d<g;d++)"identifier"!=c[d].type||"-rnd-pi-e-sqr-ra\u00edz-sqrt-exp-log-log10-abs-ent-sgn-ind-sen-sin-cos-tan-cot-sec-csc-senh-sinh-cosh-tanh-coth-sech-csch-asen-asin-acos-atan-min-max-_Num_-_Trace_-_Stop_Audios_-esCorrecto-escorrecto-_GetValues_-_GetMatrix_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_Rojo_-_Verde_-_Azul_-".match("-"+c[d].value+"-")||(c[d].value=l.name+"."+c[d].value);return(a.match(/^\\expr/)?
"\\expr ":"\\decimals ")+e.flatTokens(c)};m=m.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,v);m=m.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,v);r[k][1]=m}else{v=f.parseText(r[k][1]).textElementsMacros;for(var u=0,w=v.length;u<w;u++){m=e.tokenize(v[u].replace(/\&squot;/g,"'"));for(var z=0,C=m.length;z<C;z++)"identifier"!==m[z].type||"-rnd-pi-e-sqr-ra\u00edz-sqrt-exp-log-log10-abs-ent-sgn-ind-sen-sin-cos-tan-cot-sec-csc-senh-sinh-cosh-tanh-coth-sech-csch-asen-asin-acos-atan-min-max-_Num_-_Trace_-_Stop_Audios_-esCorrecto-escorrecto-_GetValues_-_GetMatrix_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_Rojo_-_Verde_-_Azul_-".match("-"+
m[z].value+"-")||(m[z].value=this.name+"."+m[z].value);m=e.flatTokens(m).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");v[u]=m.substring(1,m.length-1)}r[k][1]=v.join("")}else{v=r[k][1].replace(/\&squot;/g,"'").split(";");u=0;for(w=v.length;u<w;u++){m=e.tokenize(v[u]);z=0;for(C=m.length;z<C;z++)"identifier"!==m[z].type||"-rnd-pi-e-sqr-ra\u00edz-sqrt-exp-log-log10-abs-ent-sgn-ind-sen-sin-cos-tan-cot-sec-csc-senh-sinh-cosh-tanh-coth-sech-csch-asen-asin-acos-atan-min-max-_Num_-_Trace_-_Stop_Audios_-esCorrecto-escorrecto-_GetValues_-_GetMatrix_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_Rojo_-_Verde_-_Azul_-".match("-"+
m[z].value+"-")||(m[z].value=this.name+"."+m[z].value);v[u]=e.flatTokens(m)}r[k][1]=v.join(";")}g=0;for(s=n.length;g<s;g++)if(n[g][0]){r="";t=!1;k=0;for(q=n[g].length;k<q;k++)"type"===d[n[g][k][0]]&&(r="espacio='"+this.spaceID+"' ",t=!0),r=r+n[g][k][0]+"='"+n[g][k][1]+"' ";n[g]=r;t?this.graphics.push(f.parseGraphic(n[g],this.abs_coord,this.background,this.inirot)):f.parseAuxiliar(n[g])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){f=this.evaluator.evalExpression(this.inipos);
this.iniPosX=f[0][0];this.iniPosY=f[0][1]};a.Macro.prototype.drawAux=function(a){for(var c=0,d=this.graphics.length;c<d;c++)this.graphics[c]&&(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||{},babel),descartesJS=function(a){if(a.loadLib)return a;var d=Math.sqrt,h=Math.sin,f=Math.cos,b,c,p,e,g,n,q,k,s,r,t,m,v,l,u;a.norm3D=function(a){return d(a.x*
a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(c){b=a.norm3D(c);if(0===b)return{x:0,y:0,z:0};if(1===b)return{x:c.x,y:c.y,z:c.z};b=1/b;return{x:c.x*b,y:c.y*b,z:c.z*b}};a.dotProduct3D=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};a.crossProduct3D=function(a,b){return{x:a.y*b.z-a.z*b.y,y:a.z*b.x-a.x*b.z,z:a.x*b.y-a.y*b.x}};a.scalarProduct3D=function(a,b){return{x:a.x*b,y:a.y*b,z:a.z*b}};a.subtract3D=function(a,b){return{x:a.x-b.x,y:a.y-b.y,z:a.z-b.z}};a.add3D=function(a,b){return{x:a.x+b.x,y:a.y+b.y,z:a.z+
b.z}};a.equals3DEpsilon=function(a,b,c){return Math.abs(a.x-b.x)<=c&&Math.abs(a.y-b.y)<=c&&Math.abs(a.z-b.z)<=c};a.Vector4D=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e||0};a.Matrix4x4=function(a,b,c,e,d,g,f,k,h,m,l,n,q,p,r,s){this.a00=a||0;this.a01=b||0;this.a02=c||0;this.a03=e||0;this.a10=d||0;this.a11=g||0;this.a12=f||0;this.a13=k||0;this.a20=h||0;this.a21=m||0;this.a22=l||0;this.a23=n||0;this.a30=q||0;this.a31=p||0;this.a32=r||0;this.a33=s||0};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.multiplyVector4=function(b){return new a.Vector4D(b.x*this.a00+b.y*this.a10+b.z*this.a20+b.w*this.a30,b.x*this.a01+b.y*this.a11+b.z*this.a21+b.w*this.a31,b.x*this.a02+b.y*this.a12+b.z*this.a22+b.w*this.a32,b.x*this.a03+b.y*this.a13+b.z*this.a23+b.w*this.a33)};a.Matrix4x4.prototype.translate=function(b){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*b.x+this.a10*b.y+this.a20*b.z+this.a30,this.a01*b.x+this.a11*b.y+this.a21*b.z+this.a31,this.a02*b.x+this.a12*b.y+this.a22*b.z+this.a32,this.a03*b.x+this.a13*b.y+this.a23*b.z+this.a33)};a.Matrix4x4.prototype.rotateX=function(b){c=h(b);p=f(b);k=this.a10;s=this.a11;r=this.a12;t=this.a13;m=this.a20;v=this.a21;l=this.a22;u=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,k*p+m*
c,s*p+v*c,r*p+l*c,t*p+u*c,k*-c+m*p,s*-c+v*p,r*-c+l*p,t*-c+u*p,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){c=h(b);p=f(b);e=this.a00;g=this.a01;n=this.a02;q=this.a03;m=this.a20;v=this.a21;l=this.a22;u=this.a23;return new a.Matrix4x4(e*p+m*-c,g*p+v*-c,n*p+l*-c,q*p+u*-c,this.a10,this.a11,this.a12,this.a13,e*c+m*p,g*c+v*p,n*c+l*p,q*c+u*p,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(b){c=h(b);p=f(b);e=this.a00;g=this.a01;n=this.a02;q=this.a03;
k=this.a10;s=this.a11;r=this.a12;t=this.a13;return new a.Matrix4x4(e*p+k*c,g*p+s*c,n*p+r*c,q*p+t*c,e*-c+k*p,g*-c+s*p,n*-c+r*p,q*-c+t*p,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33)};return a}(descartesJS||{}),descartesJS=function(a){function d(a){a.lineWidth=1;a.fillStyle=this.backColor;a.strokeStyle=this.frontColor;a.beginPath();a.arc(this.newV[0].x,this.newV[0].y,this.size+0.5,0,p);a.fill();a.stroke()}function h(a,b){a.lineCap=e;a.lineJoin=g;a.beginPath();a.moveTo(this.newV[0].x,
this.newV[0].y);for(var c=1,d=this.newV.length;c<d;c++)a.lineTo(this.newV[c].x,this.newV[c].y);a.closePath();"color"===this.model?(a.fillStyle=0<=this.direction?this.backColor:this.frontColor,a.fill()):"light"===this.model||"metal"===this.model?(a.fillStyle=0<=this.direction?b.computeColor(this.backColor,this,"metal"===this.model):b.computeColor(this.frontColor,this,"metal"===this.model),a.fill()):"wire"===this.model&&(a.lineWidth=1.25,a.strokeStyle=this.frontColor,a.stroke());this.edges&&"wire"!==
this.model&&(a.lineWidth=1,a.strokeStyle="#808080",a.stroke())}function f(a){t=this.evaluator.getVariable(this.family);this.evaluator.setVariable(this.family,this.familyValue);this.drawText(a,this.text,this.newV[0].x,this.newV[0].y+this.displace,this.frontColor,this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,t)}function b(a){a.lineCap=e;a.lineJoin=g;a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor;a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);
a.lineTo(this.newV[1].x,this.newV[1].y);a.stroke()}function c(b,c,e){n=a.subtract3D(b,c);q=a.subtract3D(b,e);return a.normalize3D(a.crossProduct3D(n,q))}if(a.loadLib)return a;var p=2*Math.PI,e="round",g="round",n,q,k,s,r,t;a.Primitive3D=function(a,e){this.space=e;for(var g in a)a.hasOwnProperty(g)&&(this[g]=a[g]);this.newV=[];this.spaceVertices=[];"vertex"===this.type?this.draw=d:"face"===this.type?(this.normal=c(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=h):"text"===this.type?
(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,this.draw=f):"edge"===this.type&&(this.draw=b);this.isText&&(this.computeDepth=function(){this.newV=this.vertices;this.depth=this.vertices[0].z;this.average=this.vertices[0]})};a.Primitive3D.prototype.computeDepth=function(b){this.average={x:0,y:0,z:0};this.removeDoubles();this.normal={x:0,y:1,z:0};this.direction={x:1,y:0,z:0};for(var e=0,d=this.vertices.length;e<d;e++)this.newV[e]=b.rotateVertex(this.vertices[e]),
this.spaceVertices[e]=b.rotateVertex(this.vertices[e]),this.average.x+=this.newV[e].x,this.average.y+=this.newV[e].y,this.average.z+=this.newV[e].z;this.average=a.scalarProduct3D(this.average,1/d);this.averageP=b.project(this.average);this.depth=this.averageP.z;2<this.vertices.length&&(this.normal=c(this.newV[0],this.newV[1],this.newV[2]),this.direction=a.dotProduct3D(this.normal,a.normalize3D(b.eye)));e=0;for(d=this.vertices.length;e<d;e++)this.newV[e]=b.project(this.newV[e])};var m;a.Primitive3D.prototype.removeDoubles=
function(){m=[];for(var a=0,b=this.vertices.length;a<b;a++)this.vertices[a].x===this.vertices[(a+1)%b].x&&this.vertices[a].y===this.vertices[(a+1)%b].y&&this.vertices[a].z===this.vertices[(a+1)%b].z&&this.vertices[a].w===this.vertices[(a+1)%b].w||m.push(this.vertices[a]);0===m.length&&m.push(this.vertices[0]);this.vertices=m};a.Primitive3D.prototype.drawText=function(b,c,e,d,g,f,h,m,n,q,p){if("rtfNode"==c.type)b.fillStyle=g,b.strokeStyle=g,b.textBaseline="alphabetic",c.draw(b,e,d,n,q,h,p);else for("simpleText"===
c.type&&(c=c.toString(n,q).split("\\n")),e+=f.match("Arial")?-2:f.match("Times")?-2:0,k=this.evaluator,b.fillStyle=a.getColor(k,g),b.font=f,b.textAlign=h,b.textBaseline=m,s=1.2*this.fontSize||0,g=0,f=c.length;g<f;g++)r=c[g],this.border&&b.strokeText(r,e,d+s*g),b.fillText(r,e,d+s*g)};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){for(var c=null,e=null,d=0,g=0,f=0,k=b.vertices.length;f<k;f++){var h=this.intersection(b.vertices[f],b.vertices[(f+1)%k]);if(null!==h)if(null===c){if(c=
h,d=f,2===b.vertices.length){e=c;break}}else if(!a.equals3DEpsilon(h,c,1E-8)){e=h;g=f;break}}if(null!==c&&null!==e){var f=this.isInterior(c)||this.isInterior(e),m=null,n=null;if(!f&&3<=b.vertices.length)for(var k=0,q=this.vertices.length;k<q;k++)if(h=b.intersection(this.vertices[k],this.vertices[(k+1)%q]),null!==h)if(null===m)m=h;else if(!a.equals3DEpsilon(h,m,1E-8)){n=h;break}if(f||null!==m&&null!==n&&b.isInterior(m)&&b.isInterior(n)){n=!0;q=b.vertices;m=h=null;if(2===q.length)a.equals(c,q[0],1E-8)||
a.equals(c,q[1],1E-8)?n=!1:(h=[],h[0]=q[0],h[1]=c,m=[],m[0]=c,m[1]=q[1]);else for(var h=[],m=[],p=0,f=k=0;f<q.length;f++)f<d?h[p++]=q[f]:f==d?(h[p++]=q[f],h[p++]=c,m[k++]=c):f<g?m[k++]=q[f]:f==g?(m[k++]=q[f],m[k++]=e,h[p++]=e):h[p++]=q[f];if(n)return c=[],c[0]=new a.Primitive3D({vertices:h,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model},this.space),c[0].normal=b.normal,c[1]=new a.Primitive3D({vertices:m,type:"face",frontColor:b.frontColor,backColor:b.backColor,
edges:b.edges,model:b.model},this.space),c[1].normal=b.normal,c}}}return[b]};a.Primitive3D.prototype.intersects=function(a){return this.intersectsPlane(a)&&a.intersectsPlane(this)};a.Primitive3D.prototype.intersectsPlane=function(b){var c=a.dotProduct3D(b.vertices[0],b.normal),e=a.dotProduct3D(this.vertices[0],b.normal);if(1E-8>Math.abs(c-e))return!0;for(var d=1,g=this.vertices.length;d<g;d++){var f=a.dotProduct3D(this.vertices[d],b.normal);if(1E-8>Math.abs(c-f)||f>c&&e<c||f<c&&e>c)return!0}return!1};
a.Primitive3D.prototype.intersection=function(b,c){if(0<this.vertices.length){var e=a.subtract3D(c,b),d=a.dotProduct3D(e,this.normal);if(0!==d&&(d=a.dotProduct3D(a.subtract3D(this.vertices[0],b),this.normal)/d,-1E-8<d&&1.00000001>d))return a.add3D(b,a.scalarProduct3D(e,d))}return null};a.Primitive3D.prototype.isInterior=function(b){if(0<this.vertices.length)for(var c=0,e=a.subtract3D(this.vertices[0],b),d=0,g=this.vertices.length;d<g;d++){var f=a.subtract3D(this.vertices[(d+1)%g],b),k=a.dotProduct3D(a.crossProduct3D(e,
f),this.normal);if(1E-8>Math.abs(k)){if(0>a.dotProduct3D(e,f))break}else{if(0>c&&0<k||0<c&&0>k)return!1;e=f;c=k}}return!0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d={x:0,y:0,z:0},h,f,b,c,p,e,g,n;a.Graphic3D=function(b,c){this.parent=b;this.evaluator=b.evaluator;var e=b.evaluator.parser;this.spaceID="E0";this.background=!1;this.type="";this.color=new a.Color("eeffaa");this.backcolor=new a.Color("6090a0");this.Nu=this.evaluator.parser.parse("7");this.Nv=this.evaluator.parser.parse("7");
this.drawif=e.parse("1");this.abs_coord=!1;this.family="";this.family_interval=e.parse("[0,1]");this.family_steps=e.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=e.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=e.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=e.parse("(0,0,0)");this.model="color";for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=e.parse("(0,0)"));
this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10;this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&(this.endrot=this.endrot.replace("Euler",""),this.endrotEuler=!0);this.inirot=e.parse(this.inirot);this.endrot=e.parse(this.endrot);
this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4};a.Graphic3D.prototype.getSpace=function(){for(var a=this.parent.spaces,b,c=0,e=a.length;c<e;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){h=
this.evaluator;f=h.evalExpression(this.family_interval);this.familyInf=f[0][0];this.familySup=f[0][1];this.fSteps=Math.round(h.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){h=this.evaluator;this.getFamilyValues();b=h.getVariable(this.family);if(0<=this.fSteps)for(var a=0,c=this.fSteps;a<=c;a++)h.setVariable(this.family,this.familyInf+a*this.family_sep),this.familyValue=this.familyInf+
a*this.family_sep,h.evalExpression(this.drawif)&&this.buildPrimitives();h.setVariable(this.family,b)};a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.evalExpression(this.drawif)&&(this.family||this.buildPrimitives());this.family&&this.buildFamilyPrimitives()};a.Graphic3D.prototype.updateMVMatrix=function(){p=this.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(p[0][0])),this.inirotM=
this.inirotM.rotateX(a.degToRad(p[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(p[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(p[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(p[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(p[0][2])));p=this.evaluator.evalExpression(this.inipos);d={x:p[0][0],y:p[0][1],z:p[0][2]};this.iniposM=this.iniposM.setIdentity().translate(d);p=this.evaluator.evalExpression(this.endrot);this.endrotEuler?
(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(p[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(p[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(p[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(p[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(p[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(p[0][2])));p=this.evaluator.evalExpression(this.endpos);d={x:p[0][0],y:p[0][1],z:p[0][2]};
this.endposM=this.endposM.setIdentity().translate(d)};a.Graphic3D.prototype.transformVertex=function(a){this.macroChildren&&(a=this.applyMacroTransform(a));this.inirotEuler?c=this.inirotM.multiplyVector4(a):(c=this.inirotM_X.multiplyVector4(a),c=this.inirotM_Y.multiplyVector4(c),c=this.inirotM_Z.multiplyVector4(c));c=this.iniposM.multiplyVector4(c);this.endrotEuler?c=this.endrotM.multiplyVector4(c):(c=this.endrotM_X.multiplyVector4(c),c=this.endrotM_Y.multiplyVector4(c),c=this.endrotM_Z.multiplyVector4(c));
return c=this.endposM.multiplyVector4(c)};a.Graphic3D.prototype.applyMacroTransform=function(a){this.macro_inirotEuler?c=this.macro_inirotM.multiplyVector4(a):(c=this.macro_inirotM_X.multiplyVector4(a),c=this.macro_inirotM_Y.multiplyVector4(c),c=this.macro_inirotM_Z.multiplyVector4(c));c=this.macro_iniposM.multiplyVector4(c);this.macro_endrotEuler?c=this.macro_endrotM.multiplyVector4(c):(c=this.macro_endrotM_X.multiplyVector4(c),c=this.macro_endrotM_Y.multiplyVector4(c),c=this.macro_endrotM_Z.multiplyVector4(c));
return c=this.macro_endposM.multiplyVector4(c)};a.Graphic3D.prototype.parseExpression=function(){p=this.expresion.split("=");e=p[0];g=[];for(var a=1;a<p.length;a++)e+="=",n=p[a].lastIndexOf(" "),e+=-1!==n?p[a].substring(0,n):p[a],g.push(this.evaluator.parser.parse(e,!0)),e=p[a].substring(n+1);return g};var q;a.Graphic3D.prototype.splitFace=function(a){for(var b=0,c=this.primitives.length;b<c;b++)if(q=[],"face"===this.primitives[b].type){for(var e=0,d=a.primitives.length;e<d;e++)"face"===a.primitives[e].type?
q=q.concat(this.primitives[b].splitFace(a.primitives[e])):q.push(a.primitives[e]);a.primitives=q}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c;a.Point3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){d=this.evaluator;this.updateMVMatrix();h=d.evalExpression(this.expresion);f=h[0][0];b=h[0][1];c=h[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(f,
b,c,1))],type:"vertex",backColor:this.backcolor.getColor(),frontColor:this.color.getColor(),size:d.evalExpression(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(f,b,c,1))],type:"text",frontColor:this.color.getColor(),font:this.font,decimals:d.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize,evaluator:d,text:this.text,family:this.family,familyValue:this.familyValue},this.space))};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var d,h,f,b,c,p;a.Segment3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c)};a.extend(a.Segment3D,a.Graphic3D);a.Segment3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);d=expr[0][0];h=expr[0][1];f=expr[0][2];b=expr[1][0];c=expr[1][1];p=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,h,f,1)),this.transformVertex(new a.Vector4D(b,
c,p,1))],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.evalExpression(this.width)},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p,e;a.Surface3D=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");a.Graphic3D.call(this,b,c);this.expresion=this.parseExpression()};a.extend(a.Surface3D,a.Graphic3D);a.Surface3D.prototype.buildPrimitives=function(){d=
this.evaluator;this.updateMVMatrix();f=d.getVariable("x");f=d.getVariable("y");f=d.getVariable("z");h=d.getVariable("u");f=d.getVariable("v");d.setVariable("u",0);d.setVariable("v",0);b=d.evalExpression(this.Nu);c=d.evalExpression(this.Nv);p=[];for(var g=0;g<=b;g++){d.setVariable("u",g/b);for(var n=0;n<=c;n++){d.setVariable("v",n/c);for(var q=0,k=this.expresion.length;q<k;q++)d.evalExpression(this.expresion[q]);p.push(this.transformVertex(new a.Vector4D(d.getVariable("x"),d.getVariable("y"),d.getVariable("z"),
1)))}}for(g=0;g<b;g++)for(n=0;n<c;n++)e=[],e.push(p[n+g*c+g]),e.push(p[n+1+g*c+g]),e.push(p[n+2+(g+1)*c+g]),e.push(p[n+1+(g+1)*c+g]),this.primitives.push(new a.Primitive3D({vertices:e,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space));d.setVariable("x",void 0);d.setVariable("y",void 0);d.setVariable("z",void 0);d.setVariable("u",h);d.setVariable("v",f)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d,h,f,b,c,p;a.Polygon3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c)};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);for(var e=0,g=expr.length-1;e<g;e++)d=expr[e][0],h=expr[e][1],f=expr[e][2],b=expr[e+1][0],c=expr[e+1][1],p=expr[e+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,h,f,1)),
this.transformVertex(new a.Vector4D(b,c,p,1))],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.evalExpression(this.width)},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p;a.Curve3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c);this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();b=
evaluator.getVariable("x");c=evaluator.getVariable("y");p=evaluator.getVariable("z");f=evaluator.getVariable("u");evaluator.setVariable("u",0);h=evaluator.evalExpression(this.Nu);d=[];for(var e=0;e<=h;e++){evaluator.setVariable("u",e/h);for(var g=0,n=this.expresion.length;g<n;g++)evaluator.evalExpression(this.expresion[g]);d.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}e=0;for(g=d.length-1;e<g;e++)this.primitives.push(new a.Primitive3D({vertices:[d[e],
d[e+1]],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.evalExpression(this.width)},this.space));evaluator.setVariable("x",b);evaluator.setVariable("y",p);evaluator.setVariable("z",c);evaluator.setVariable("u",f)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p,e,g,n;a.Triangle3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();
expr=evaluator.evalExpression(this.expresion);d=expr[0][0];h=expr[0][1];f=expr[0][2];b=expr[1][0];c=expr[1][1];p=expr[1][2];e=expr[2][0];g=expr[2][1];n=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,h,f,1)),this.transformVertex(new a.Vector4D(e,g,n,1)),this.transformVertex(new a.Vector4D(b,c,p,1))],type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.Face3D=function(d,f){a.Graphic3D.call(this,d,f)};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);d=[];for(var h=expr.length-1;0<=h;h--)d.push(this.transformVertex(new a.Vector4D(expr[h][0],expr[h][1],expr[h][2],1)));this.primitives.push(new a.Primitive3D({vertices:d,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),
edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c;a.Polireg3D=function(b,c){this.width=b.evaluator.parser.parse("2");this.length=b.evaluator.parser.parse("2");a.Graphic3D.call(this,b,c)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();d=evaluator.evalExpression(this.Nu);h=[this.transformVertex(new a.Vector4D(0,0,0,1))];f=evaluator.evalExpression(this.width)/
2;b=evaluator.evalExpression(this.length)/2;c=2*Math.PI/d;for(var p=0;p<d;p++)h.push(this.transformVertex(new a.Vector4D(f*Math.cos(c*p),b*Math.sin(c*p),0,1)));for(p=0;p<d;p++)this.primitives.push(new a.Primitive3D({vertices:[h[0],p+2<=d?h[p+2]:h[1],h[p+1]],type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b;a.Text3D=function(b,d){a.Graphic3D.call(this,
b,d)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=function(){d=this.evaluator;h=d.evalExpression(this.expresion);f=h[0][0];b=h[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(f,b,0,1)],type:"text",frontColor:this.color.getColor(),font:this.font,decimals:d.evalExpression(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:d,text:this.text,family:this.family,familyValue:this.familyValue,joel:"hola"},this.space))};return a}(descartesJS||{}),descartesJS=
function(a,d){if(a.loadLib)return a;var h=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,f,b;a.Macro3D=function(b,f){this.expresion=void 0;this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=b.evaluator.parser.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=b.evaluator.parser.parse("(0,0,0)");a.Graphic.call(this,b,f);for(var e in f)f.hasOwnProperty(e)&&(this[e]=f[e]);this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&
(this.endrot=this.endrot.replace("Euler",""),this.endrotEuler=!0);this.inirot=this.evaluator.parser.parse(this.inirot);this.endrot=this.evaluator.parser.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4;this.graphics=[];e=b.lessonParser;
var g=new a.Tokenizer;if(void 0!=this.expresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var n=this.evaluator.evalExpression(this.expresion),q;n&&((q=document.getElementById(n))&&"descartes/macro"==q.type?q=q.text:(q=a.openExternalFile(n))&&!q.match(/tipo_de_macro/g)&&(q=null));var k,s;if(q){s=q.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,"&").replace(/\r/g,"").split("\n");q=[];for(var n=0,r=s.length;n<r;n++)k=s[n].indexOf("="),-1!==k&&(k=s[n].substring(0,k),"id"!==d[k]&&"type"!==d[k]||q.push(e.split(s[n])));for(var t,m,v,l,n=0,r=q.length;n<r;n++)for(l=(t=
q[n]||[])&&t[0]&&"id"===t[0][0],s=0,k=t.length;s<k;s++)if(m=t[s][0].indexOf("."),-1===m||l?m=d[t[s][0]]:(m=d[t[s][0].substring(m+1)],t[s][0]=this.name+"."+t[s][0]),!("font"===m||("fill"===m||"color"===m||"arrow"===m)&&"("!==t[s][1].charAt(0)||"file"===m&&t[s][1].match(h)||"id"!==m&&void 0!==d[t[s][1]])||"width"===m||"height"===m||"length"===m)if("text"==m)if(t[s][1].match(/\{\\rtf1/)){m=t[s][1];var u=this;v=function(a,b){for(var c=g.tokenize(b.replace(/\&squot;/g,"'")),e=0,d=c.length;e<d;e++)"identifier"!=
c[e].type||"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+c[e].value+"-")||(c[e].value=u.name+"."+c[e].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+g.flatTokens(c)};m=m.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,v);m=m.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,v);t[s][1]=m}else{v=e.parseText(t[s][1]).textElementsMacro3Ds;
for(var w=0,z=v.length;w<z;w++){m=g.tokenize(v[w].replace(/\&squot;/g,"'"));for(var C=0,A=m.length;C<A;C++)"identifier"!==m[C].type||"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+m[C].value+"-")||(m[C].value=this.name+"."+m[C].value);m=g.flatTokens(m).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");v[w]=m.substring(1,m.length-1)}t[s][1]=v.join("")}else{m=g.tokenize(t[s][1]);
v=0;for(w=m.length;v<w;v++)"identifier"!==m[v].type||"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+m[v].value+"-")||(m[v].value=this.name+"."+m[v].value);t[s][1]=g.flatTokens(m)}n=0;for(r=q.length;n<r;n++)if(q[n][0]){t="";l=!1;s=0;for(k=q[n].length;s<k;s++)"type"===d[q[n][s][0]]&&(t="espacio='"+this.spaceID+"' ",l=!0),t=t+q[n][s][0]+"='"+q[n][s][1]+"' ";q[n]=t;l?this.graphics.push(e.parse3DGraphic(q[n],
this.abs_coord,this.background,this.inirot)):e.parseAuxiliar(q[n])}}n=0;for(r=this.graphics.length;n<r;n++)this.graphics[n].macroChildren=!0}};a.extend(a.Macro3D,a.Graphic);a.Macro3D.prototype.update=function(){this.updateTransformation();if(this.inipos){var a=this.evaluator.evalExpression(this.inipos);this.iniPosX=a[0][0];this.iniPosY=a[0][1]}this.primitives=[];for(var a=0,d=this.graphics.length;a<d;a++)f=this.graphics[a],f.macro_inirotEuler=this.inirotEuler,f.macro_inirotM=this.inirotM,f.macro_inirotM_X=
this.inirotM_X,f.macro_inirotM_Y=this.inirotM_Y,f.macro_inirotM_Z=this.inirotM_Z,f.macro_iniposM=this.iniposM,f.macro_endrotEuler=this.endrotEuler,f.macro_endrotM=this.endrotM,f.macro_endrotM_X=this.endrotM_X,f.macro_endrotM_Y=this.endrotM_Y,f.macro_endrotM_Z=this.endrotM_Z,f.macro_endposM=this.endposM,f.update();a=0;for(d=this.graphics.length;a<d;a++){f=this.graphics[a];if(f.split||this.split)for(var e=a+1;e<d;e++)b=this.graphics[e],(b.split||this.split)&&f.splitFace(b);this.primitives=this.primitives.concat(f.primitives||
[])}};a.Macro3D.prototype.updateTransformation=function(){tmpExpr=this.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(tmpExpr[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(tmpExpr[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(tmpExpr[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(tmpExpr[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(tmpExpr[0][1])),
this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(tmpExpr[0][2])));tmpExpr=this.evaluator.evalExpression(this.inipos);translate={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.iniposM=this.iniposM.setIdentity().translate(translate);tmpExpr=this.evaluator.evalExpression(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(tmpExpr[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(tmpExpr[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(tmpExpr[0][2]))):
(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(tmpExpr[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(tmpExpr[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(tmpExpr[0][2])));tmpExpr=this.evaluator.evalExpression(this.endpos);translate={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.endposM=this.endposM.setIdentity().translate(translate)};a.Macro3D.prototype.drawAux=function(a){};return a}(descartesJS||{},babel),descartesJS=function(a){function d(a,
b,c,e,d){h.call(this,a/1.8,a/1.8,a/1.8,e,d)}function h(a,b,c,e,d){a/=2;b/=2;c/=2;this.changeGeometry(a,b,c,e,d)||(this.vertices=[new m(a,c,b,1),new m(a,-c,b,1),new m(a,c,-b,1),new m(a,-c,-b,1),new m(-a,c,b,1),new m(-a,-c,b,1),new m(-a,c,-b,1),new m(-a,-c,-b,1)],this.faces=[[2,3,1,0],[1,5,4,0],[5,7,6,4],[6,7,3,2],[4,6,2,0],[3,7,5,1]],this.updateValues(a,b,c,e,d))}function f(a,b,c,e,d){a/=2;this.changeGeometry(a,b,c,e,d)||(this.vertices=[new m(0,0,a,1),new m(-0.49*a,-0.86*a,-0.32*a,1),new m(-0.49*a,
0.86*a,-0.32*a,1),new m(1*a,0,-0.32*a,1)],this.faces=[[3,2,1],[1,2,0],[2,3,0],[3,1,0]],this.updateValues(a,b,c,e,d))}function b(a,b,c,e,d){a/=2;this.changeGeometry(a,b,c,e,d)||(this.vertices=[new m(0,0,a,1),new m(a,0,0,1),new m(-a,0,0,1),new m(0,a,0,1),new m(0,-a,0,1),new m(0,0,-a,1)],this.faces=[[3,1,0],[2,3,0],[1,4,0],[4,2,0],[1,3,5],[3,2,5],[4,1,5],[2,4,5]],this.updateValues(a,b,c,e,d))}function c(b,c,e,d,g){b/=3.4;if(!this.changeGeometry(b,c,e,d,g)){F=b/E;B=b*E;this.vertices=[new m(b,b,b,1),new m(b,
b,-b,1),new m(b,-b,b,1),new m(b,-b,-b,1),new m(-b,b,b,1),new m(-b,b,-b,1),new m(-b,-b,b,1),new m(-b,-b,-b,1),new m(0,F,B,1),new m(0,F,-B,1),new m(0,-F,B,1),new m(0,-F,-B,1),new m(F,B,0,1),new m(F,-B,0,1),new m(-F,B,0,1),new m(-F,-B,0,1),new m(B,0,F,1),new m(B,0,-F,1),new m(-B,0,F,1),new m(-B,0,-F,1)];y=(new a.Matrix4x4).setIdentity().rotateY(-r/6);for(var f=0,h=this.vertices.length;f<h;f++)this.vertices[f]=y.multiplyVector4(this.vertices[f]);this.faces=[[0,16,2,10,8],[12,1,17,16,0],[8,4,14,12,0],
[2,16,17,3,13],[13,15,6,10,2],[6,18,4,8,10],[3,17,1,9,11],[13,3,11,7,15],[1,12,14,5,9],[11,9,5,19,7],[5,14,4,18,19],[6,15,7,19,18]];this.updateValues(b,c,e,d,g)}}function p(b,c,e,d,g){b/=4;if(!this.changeGeometry(b,c,e,d,g)){B=b*E;this.vertices=[new m(0,b,B,1),new m(0,b,-B,1),new m(0,-b,B,1),new m(0,-b,-B,1),new m(b,B,0,1),new m(b,-B,0,1),new m(-b,B,0,1),new m(-b,-B,0,1),new m(B,0,b,1),new m(B,0,-b,1),new m(-B,0,b,1),new m(-B,0,-b,1)];this.faces=[[10,0,2],[0,8,2],[8,5,2],[5,7,2],[7,10,2],[6,0,10],
[11,6,10],[7,11,10],[7,3,11],[5,3,7],[9,3,5],[8,9,5],[4,9,8],[0,4,8],[6,4,0],[11,3,1],[6,11,1],[4,6,1],[9,4,1],[3,9,1]];y=(new a.Matrix4x4).setIdentity().rotateY(-1.029);for(var f=0,h=this.vertices.length;f<h;f++)this.vertices[f]=y.multiplyVector4(this.vertices[f]);this.updateValues(b,c,e,d,g)}}function e(a,b,c,e,d){a/=2;this.isSphere?c=b=a:(b/=2,c/=2);if(!this.changeGeometry(a,b,c,e,d)){this.vertices=[new m(0,0,b,1)];for(var g=1;g<e;g++){A=g*r/e;for(var f=0;f<d;f++)C=f*t/d,u=a*k(A)*s(C),w=c*k(A)*
k(C),z=b*s(A),this.vertices.push(new m(u,w,z,1))}this.vertices.push(new m(0,0,-b,1));this.faces=[];for(g=0;g<d;g++)this.faces.push([0,(g+1)%d+1,g%d+1]);for(g=1;g<e-1;g++)for(f=0;f<d;f++)this.faces.push([f+1+(g-1)*d,(f+1)%d+1+(g-1)*d,(f+1)%d+1+g*d,f+1+g*d]);for(g=0;g<d;g++)this.faces.push([this.vertices.length-1,this.vertices.length-1-d+g,this.vertices.length-1-d+(g+1)%d]);this.updateValues(a,b,c,e,d)}}function g(a,b,c,e,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,e,d)){this.vertices=[];for(var g=
0;g<d;g++)for(var f=0;f<e;f++)u=a*(d-g)/d*s(f*t/e),w=c*(d-g)/d*k(f*t/e),z=b-2*g*b/d,this.vertices.push(new m(u,w,z,1));this.vertices.push(new m(0,0,-b,1));this.faces=[];for(g=0;g<d-1;g++)for(f=0;f<e;f++)this.faces.push([f+g*e,(f+1)%e+g*e,(f+1)%e+(g+1)*e,f+(g+1)*e]);for(g=0;g<e;g++)this.faces.push([this.vertices.length-1,this.vertices.length-1-e+g,this.vertices.length-1-e+(g+1)%e]);this.updateValues(a,b,c,e,d)}}function n(a,b,c,e,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,e,d)){this.vertices=
[];for(var g=0;g<d+1;g++)for(var f=0;f<e;f++)u=a*s(f*t/e),w=c*k(f*t/e),z=b-2*g*b/d,this.vertices.push(new m(u,w,z,1));this.faces=[];for(g=0;g<d;g++)for(f=0;f<e;f++)this.faces.push([f+g*e,(f+1)%e+g*e,(f+1)%e+(g+1)*e,f+(g+1)*e]);this.updateValues(a,b,c,e,d)}}function q(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];for(var c=0,e=this.fileData.length;c<e;c++)G=this.fileData[c],G.match(/^V\(/)?(H=G.substring(2,G.length-1).split(",").map(b),this.vertices.push(new m(H[0]||
0,H[1]||0,H[2]||0,1))):G.match(/^F\(/)&&(H=G.substring(2,G.length-1).split(",").map(a),this.faces.push(H.reverse()))}if(a.loadLib)return a;var k=Math.sin,s=Math.cos,r=Math.PI,t=2*r,m,v,l,u,w,z,C,A,E=1.6180339887,F,B,y,G,H;a.OtherGeometry=function(k,l){this.width=k.evaluator.parser.parse("2");this.height=k.evaluator.parser.parse("2");this.length=k.evaluator.parser.parse("2");m=a.Vector4D;a.Graphic3D.call(this,k,l);switch(this.type){case "cube":this.buildGeometry=d;break;case "box":this.buildGeometry=
h;break;case "tetrahedron":this.buildGeometry=f;break;case "octahedron":this.buildGeometry=b;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=e;break;case "dodecahedron":this.buildGeometry=c;break;case "icosahedron":this.buildGeometry=p;break;case "cone":this.buildGeometry=g;break;case "cylinder":this.buildGeometry=n;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=q}};a.extend(a.OtherGeometry,a.Graphic3D);
a.OtherGeometry.prototype.buildPrimitives=function(){v=this.evaluator;this.updateMVMatrix();this.buildGeometry(v.evalExpression(this.width),v.evalExpression(this.height),v.evalExpression(this.length),v.evalExpression(this.Nu),v.evalExpression(this.Nv));for(var b=0,c=this.faces.length;b<c;b++){l=[];for(var e=0,d=this.faces[b].length;e<d;e++)l.push(this.transformVertex(this.vertices[this.faces[b][e]]));this.primitives.push(new a.Primitive3D({vertices:l,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),
edges:this.edges,model:this.model},this.space))}};a.OtherGeometry.prototype.changeGeometry=function(a,b,c,e,d){return this.oldWidth===a&&this.oldHeight===b&&this.oldLength===c&&this.oldNu===e&&this.oldNv===d};a.OtherGeometry.prototype.updateValues=function(a,b,c,e,d){this.oldWidth=a;this.oldHeight=b;this.oldLength=c;this.oldNv=d;this.oldNu=e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.max,h=Math.min,f=Math.PI,b=Math.cos,c=Math.sin,p=Math.abs,e,g,n,q,k,s,r,
t,m,v,l,u,w,z,C,A,E,F;a.R2=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.set=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.copy=function(){return new a.R2(this.x,this.y)};a.R2.prototype.ix=function(){return Math.round(d(h(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(d(h(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){g=this.copy();g.sub(a);return g.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(){e=this.norm();0!=e&&this.div(e)};a.R2.prototype.rotR90=
function(){e=this.x;this.x=this.y;this.y=-e};a.R2.prototype.rotL90=function(){e=this.x;this.x=-this.y;this.y=e};a.R2.prototype.rot=function(a){n=this.copy();s=b(a);r=c(a);this.x=n.x*s-n.y*r;this.y=n.x*r+n.y*s};a.R2.prototype.rot=function(a){this.rot(a*f/180)};a.R2.prototype.intersection=function(b,c,e,g){t=c.x-b.x;m=e.x-g.x;v=e.x-b.x;l=c.y-b.y;u=e.y-g.y;w=e.y-b.y;F=t*u-m*l;return 1E-6<p(F)?(q=(v*u-w*m)/F,k=(-v*l+w*t)/F,0<=q&&1>=q&&0<=k&&1>=k?new a.R2(b.x+t*q,b.y+l*q):null):(c.x-e.x)*w!=(c.y-e.y)*
v?null:b.x!=c.x?(z=h(b.x,c.x),C=d(b.x,c.x),z<=e.x&&e.x<=C?e:z<=g.x&&g.x<=C?g:null):e.x!=g.x?(A=h(e.x,g.x),E=d(e.x,g.x),A<=b.x&&b.x<=E?b:A<=c.x&&c.x<=E?c:null):b.y!=c.y?(z=h(b.y,c.y),C=d(b.y,c.y),z<=e.y&&e.y<=C?e:z<=g.y&&g.y<=C?g:null):e.y!=g.y?(A=h(e.y,g.y),E=d(e.y,g.y),A<=b.y&&b.y<=E?b:A<=c.y&&c.y<=E?c:null):b.x==e.x&&b.y==e.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p,e,g;a.R2Newton=function(b,c){this.evaluator=b;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];p=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return this.normal.copy()};a.R2Newton.prototype.gradient=function(a){d=
this.evaluator;e=d.getVariable("x");g=d.getVariable("y");d.setVariable("x",a.x);d.setVariable("y",a.y);this.f0=d.evalExpression(this.constraint);d.setVariable("x",d.getVariable("x")+1E-12);h=d.evalExpression(this.constraint);p.x=(h-this.f0)/1E-12;p.x=isNaN(p.x)?Infinity:p.x;d.setVariable("x",d.getVariable("x")-1E-12);d.setVariable("y",d.getVariable("y")+1E-12);h=d.evalExpression(this.constraint);p.y=(h-this.f0)/1E-12;p.y=isNaN(p.y)?Infinity:p.y;d.setVariable("x",e);d.setVariable("y",g);return p};
a.R2Newton.prototype.findZero=function(a){d=this.evaluator;c=a.copy();e=d.getVariable("x");g=d.getVariable("y");d.setVariable("x",a.x);d.setVariable("y",a.y);this.f0=d.evalExpression(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return c;d.setVariable("x",e);d.setVariable("y",g);for(var h=0;256>h;h++)if(f=c.x,b=c.y,this.normal=this.gradient(c),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),c.x=f+this.normal.x,c.y=b+this.normal.y,1E-6>this.normal.norm()){0===
this.normal.x&&0===this.normal.y&&(this.normal.x=c.x-a.x,this.normal.y=c.y-a.y);break}return c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,h){this.x=a;this.y=h};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;var d=Math.floor,h=Math.round,f,b,c,p,e,g,n,q,k,s,r,t,m,v,l,u,w,z,C,A;a.Control=function(b,c){this.parent=b;this.evaluator=b.evaluator;var e=this.parser=b.evaluator.parser;this.id="graphic"!==c.type?"C":"G";this.gui=this.type="";this.region="south";this.y=this.x=0;this.w="video"!==c.type?100:350;this.h="video"!==c.type?23:120;"graphic"!==c.type&&"audio"!==c.type&&"video"!==c.type?"text"!==
c.type?this.expresion=e.parse("(0,0,100,23)"):(this.expresion=e.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=e.parse("(0,0)");this.fixed=2!=this.parent.version?!1:!0;this.visible=!0;this.color=4>this.parent.version?new a.Color("000000"):new a.Color("222222");this.colorInt="graphic"!==c.type?new a.Color("f0f8ff"):new a.Color("cc0022");this.underlined=this.italics=this.bold="";this.font_size=4>this.parent.version?-1:e.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";
this.drawif=e.parse("1");this.activeif=e.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=e.parse("0");this.decimals=e.parse("2");this.min=e.parse("-Infinity");this.max=e.parse("Infinity");this.incr=e.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);"video"!==this.type&&"audio"!==this.type||"interior"===this.region||(this.region=
"interior");void 0==this.name&&(this.name=2==this.parent.version?this.id:"_nada_");this.name="_._"==this.name||"_nada_"==this.name||"_void_"==this.name?"":this.name;e=this.evaluator.evalExpression(this.expresion);this.x=h(e[0][0]);this.y=h(e[0][1]);4==e[0].length&&(this.w=h(e[0][2]),this.h=h(e[0][3]));this.actionExec=b.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,b;if("interior"===this.region)for(var c=0,e=a.length;c<e;c++){if(b=a[c],b.id===this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,b.numericalControlContainer}else{if("external"===this.region)return this.parent.externalSpace.addCtr(this),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};a.Control.prototype.addControlContainer=function(a){var b=this.getContainer();b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a);b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){c=p=e=g=
!1;n=this.evaluator.evalExpression(this.expresion);q=h(n[0][0]);c=h(this.x)!==q;this.x=q;q=h(n[0][1]);p=h(this.y)!==q;this.y=q;4===n[0].length&&(q=h(n[0][2]),e=h(this.w)!==q,this.w=q,q=h(n[0][3]),g=h(this.h)!==q,this.h=q);if(e||g||c||p)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){m=this.parent;k=a+"";s=this.evaluator.evalExpression(this.decimals);r=k.indexOf(".");-1!=r&&(t=k.substring(r+1),t.length>s&&(k=parseFloat(k).toFixed(s)));this.fixed&&(2!==m.version||2===m.version&&
!this.exponentialif)&&(k=parseFloat(a).toFixed(s));this.exponentialif&&0!=parseFloat(k)&&(k=this.fixed&&2!==m.version?parseFloat(k).toExponential(s):parseFloat(k).toExponential(),k=k.toUpperCase(),k=k.replace("+",""));return k=k.replace(".",m.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();"init"===this.action&&(this.click=!1);this.actionExec.execute();"animate"!==this.action&&this.parent.update()};a.Control.prototype.createGradient=function(a,c){this.linearGradient=
this.ctx.createLinearGradient(0,0,0,c);f=c*c;for(var e=0;e<c;e++)b=d(e-35*c/100),this.linearGradient.addColorStop(e/c,"rgba(0,0,0,"+192*b*b/f/255+")")};a.Control.prototype.getScreenshot=function(){u=this;v=document.createElement("canvas");v.setAttribute("width",u.w);v.setAttribute("height",u.h);l=v.getContext("2d");l.font=u.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";u.canvas&&(w=u.canvas.offsetLeft,z=u.canvas.offsetTop,l.drawImage(u.canvas,w,z));u.label&&(w=u.label.offsetLeft,z=
u.label.offsetTop,C=u.label.offsetWidth,A=u.label.offsetHeight,l.fillStyle="#e0e4e8",l.fillRect(w,z,C,A),l.fillStyle="black",l.textAlign="center",l.textBaseline="middle",l.fillText(u.name,w+C/2,z+A/2));u.field&&(w=u.field.offsetLeft,z=u.field.offsetTop,C=u.field.offsetWidth,A=u.field.offsetHeight,l.fillStyle="white",l.strokeStyle="#666666",l.lineWidth=1,l.fillRect(w,0,C,A),l.strokeRect(w+0.5,0.5,C-1,A-1),l.fillStyle="black",l.textAlign="center",l.textAlign="left",l.fillText(u.field.value,w+2,A/2));
u.select&&(w=u.select.offsetLeft,z=u.select.offsetTop,C=u.select.offsetWidth,A=u.select.offsetHeight,l.fillStyle="#e0e4e8",l.strokeStyle="#666666",l.lineWidth=1,l.fillRect(w,0,C,A),l.strokeRect(w+0.5,0.5,C,A-1),l.fillStyle="black",l.textAlign="center",l.textAlign="left",l.fillText(u.select.value,w+2,A/2),l.fillStyle="#c0c0c0",l.fillRect(w+C-15+0.5,0.5,15,A-1),l.strokeRect(w+C-15+0.5,0.5,15,A-1),l.fillStyle="black",l.beginPath(),l.moveTo(w+C-15+4.5,A/2-2.5),l.lineTo(w+C-15+8,A/2+2.5),l.lineTo(w+C-
15+11.5,A/2-2.5),l.closePath(),l.fill());return v};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h,f,b,c,p,e,g,n,q,k,s,r,t=2E3,m=/[\w\.\-//]*(\.gif)/gi;a.Button=function(b,c){this.imageSrc="";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;a.Control.call(this,b,c);-1===this.font_size&&(this.fontSizeNotSet=!0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-
1)):this.name=this.parser.parse("'"+this.name+"'");var e;this.imageSrc.match("_COLORES_")&&(e=this.imageSrc.split("_"),this.colorInt=new a.Color(e[2]),this.color=new a.Color(e[3]),this.font_size=this.parser.parse(e[5]),this.imageSrc="");this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");e=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=e){var d=e.substr(0,e.lastIndexOf(".")),g=e.substr(e.lastIndexOf("."));e.toLowerCase().match(/vacio.gif$/)?(this.imageSrc=this.parser.parse("'vacio.gif'"),
this.image.ready=1,3===this.parent.version&&(this.name=this.parser.parse("")),this.emptyImage={ready:!0},this.parser.parse("'vacio.gif'")):(this.image=this.parent.getImage(e),this.imageOver=this.parent.getImage(d+"_over"+g),this.imageDown=this.parent.getImage(d+"_down"+g))}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.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.ctx.mozImageSmoothingEnabled=!1;this.ctx.webkitImageSmoothingEnabled=!1;this.addControlContainer(this.canvas);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=function(){h=this.evaluator;f=this.canvas;c=h.evalExpression(this.expresion);this.x=c[0][0];this.y=c[0][1];4==c[0].length&&
(this.w=parseInt(c[0][2]),this.h=parseInt(c[0][3]));f.setAttribute("width",this.w+"px");f.setAttribute("height",this.h+"px");f.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+"; display: block; background-repeat: no-repeat;");this.fontSizeNotSet&&(this.font_size=h.parser.parse(a.getFieldFontSize(this.h)+""));this.createGradient(this.w,this.h);f.style.display=0<h.evalExpression(this.drawif)?"block":"none"};a.Button.prototype.update=function(){h=this.evaluator;f=
this.canvas;this.activeIfValue=0<h.evalExpression(this.activeif);(this.drawIfValue=0<h.evalExpression(this.drawif))?(f.style.display="block",this.draw()):(this.click=!1,f.style.display="none");this.canvas.style.cursor=this.activeIfValue?"pointer":"not-allowed";this.updatePositionAndSize()};a.Button.prototype.draw=function(){h=this.evaluator;b=this.ctx;p=h.evalExpression(this.font_size);e=h.evalExpression(this.name);g=h.evalExpression(this.imageSrc);n="vacio.gif"===g?this.emptyImage:this.parent.getImage(g);
b.clearRect(0,0,this.w,this.h);k=q=0;this.click&&(k=q=1);n&&n.ready?n!==this.emptyImage&&n.complete&&(this.image.src.match(m)?(this.canvas.style.backgroundImage="url("+this.image.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-n.width)/2)+q+"px "+(parseInt((this.h-n.height)/2)+k)+"px"):b.drawImage(n,parseInt((this.w-n.width)/2)+q,parseInt((this.h-n.height)/2)+k)):(b.fillStyle=this.colorInt.getColor(),b.fillRect(0,0,this.w,this.h),this.click||(a.drawLine(b,this.w-1,0,this.w-1,this.h,
"rgba(0,0,0,"+128/255+")"),a.drawLine(b,0,0,0,this.h,"rgba(0,0,0,"+24/255+")"),a.drawLine(b,1,0,1,this.h,"rgba(0,0,0,"+8/255+")")),b.fillStyle=this.linearGradient,b.fillRect(0,0,this.w,this.h));this.activeIfValue&&(""!=this.imageOver.src&&this.imageOver.ready&&this.over)&&(this.image.src.match(m)?(this.canvas.style.backgroundImage="url("+this.imageOver.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-n.width)/2)+q+"px "+(parseInt((this.h-n.height)/2)+k)+"px"):b.drawImage(this.imageOver,
parseInt((this.w-n.width)/2)+q,parseInt((this.h-n.height)/2)+k));this.activeIfValue&&""!=this.imageDown.src&&this.imageDown.ready&&this.click?this.image.src.match(m)?(this.canvas.style.backgroundImage="url("+this.imageDown.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-n.width)/2)+q+"px "+(parseInt((this.h-n.height)/2)+k)+"px"):b.drawImage(this.imageDown,parseInt((this.w-n.width)/2)+q,parseInt((this.h-n.height)/2)+k):this.click&&!n&&(a.drawLine(b,0,0,0,this.h-2,"gray"),a.drawLine(b,
0,0,this.w-1,0,"gray"),b.fillStyle="rgba(0, 0, 0,"+24/255+")",b.fillRect(0,0,this.w,this.h));b.fillStyle=this.color.getColor();b.font=this.italics+" "+this.bold+" "+p+"px Arial";b.textAlign="center";b.textBaseline="middle";this.colorInt.getColor()!=this.color.getColor()&&(b.lineJoin="round",b.lineWidth=parseInt(p/6),b.strokeStyle=this.colorInt.getColor(),b.strokeText(e,d(this.w/2+q)+0.5,d(this.h/2+k)+0.5));b.fillText(e,d(this.w/2+q)+0.5,d(this.h/2+k)+0.5);this.underlined&&(s=b.measureText(e).width,
b.strokeStyle=this.color.getColor(),b.lineWidth=d(p/10)||2,b.lineCap="round",b.beginPath(),b.moveTo(parseInt((this.w-s)/2)+q,d((this.h+p)/2)+d(p/5)-1.5+k),b.lineTo(parseInt((this.w+s)/2)+q,d((this.h+p)/2)+d(p/5)-1.5+k),b.stroke());this.activeIfValue||(b.fillStyle="rgba(240,240,240,"+160/255+")",b.fillRect(0,0,this.w,this.h))};a.Button.prototype.bottonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function b(a,c,e){clearInterval(h);f.click&&
(c.call(f),a=e?a:100,h=setTimeout(function(){b(a,c)},a))}function c(d){document.body.focus();d.preventDefault();d.stopPropagation();document.activeElement!=document.body&&document.activeElement.blur();f.whichButton=a.whichButton(d);"L"==f.whichButton&&f.activeIfValue&&(f.click=!0,f.draw(),f.evaluator.setVariable(f.id,f.evaluator.evalExpression(f.valueExpr)),"calculate"==f.action&&b(t,f.bottonPressed,!0),r?window.addEventListener("touchend",e):window.addEventListener("mouseup",e))}function e(a){document.body.focus();
if(f.activeIfValue||f.click)f.click=!1,f.draw(),"calculate"!=f.action&&f.bottonPressed(),a.preventDefault(),a.stopPropagation(),r?window.removeEventListener("touchend",e,!1):window.removeEventListener("mouseup",e,!1)}function d(a){f.over=!0;f.draw()}function g(a){f.over=!1;f.click=!1;f.draw()}r=a.hasTouchSupport;var f=this,h;f.canvas.oncontextmenu=function(){return!1};this.over=this.click=!1;r?this.canvas.addEventListener("touchstart",c):(this.canvas.addEventListener("mousedown",c),this.canvas.addEventListener("mouseover",
d),this.canvas.addEventListener("mouseout",g))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p,e,g,n,q,k,s,r,t,m,v,l;a.Spinner=function(b,c){a.Control.call(this,b,c);this.tabindex=++this.parent.tabindex;"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");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.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.addControlContainer(this.containerControl);
this.originalIncr=this.incr;if(0>=this.evaluator.evalExpression(this.decimals)){var e=this.evaluator.evalExpression(this.incr);0<e?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(e).toString()):this.incr=this.evaluator.parser.parse("1")}this.registerMouseAndTouchEvents();this.init()};a.extend(a.Spinner,a.Control);a.Spinner.prototype.init=function(){d=this.evaluator;var b=d.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(d.evalExpression(this.valueExpr));
var c=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var e=2!==this.parent.version?"":"_____",g=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),f=2+parseInt(this.h/2),h=parseInt(this.w/2-f/2),e=a.getTextWidth(b+e,this.fieldFontSize+"px Arial");this.visible||(h=this.w-f,g=0);h<e&&(h=e);""==b&&(h=0);this.w-h-f<g&&(h=this.w-f-g);0>h&&(h=0);b=this.w-(h+f);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.setAttribute("id",this.id);this.canvas.setAttribute("width",f+"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","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+f+"px; height : "+
this.h/2+"px; left: "+h+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+f+"px; height : "+this.h/2+"px; left: "+h+"px; top: "+this.h/2+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_spinner");this.field.setAttribute("class","DescartesSpinnerField");this.field.setAttribute("style","font-family: Arial; font-size: "+this.fieldFontSize+"px; width : "+b+"px; height : "+this.h+
"px; left: "+(f+h)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+h+"px; height: "+this.h+"px; line-height: "+this.h+"px;");d.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){d=this.evaluator;this.label.innerHTML=d.evalExpression(this.name).toString();0>=d.evalExpression(this.decimals)?
(h=d.evalExpression(this.incr),0<h?this.originalIncr=this.incr=d.parser.parse(parseInt(h).toString()):this.incr=d.parser.parse("1")):this.incr=this.originalIncr;this.activeIfValue=0<d.evalExpression(this.activeif);this.drawIfValue=0<d.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();this.parent.animation.playing&&document.activeElement==
this.field||(f=this.field.value,b=this.value,this.value=this.validateValue(d.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value==b&&this.field.value!=f&&(this.value=this.validateValue(f),this.field.value=this.formatOutputValue(this.value)),d.setVariable(this.id,this.value))};a.Spinner.prototype.draw=function(){c=this.ctx;p=this.canvas.width;e=this.canvas.height;c.fillStyle="#f0f8ff";c.fillRect(0,0,p,e);c.fillStyle=this.linearGradient;c.fillRect(0,0,p,e);this.up?(g=
"gray",n="#f0f8ff"):(g="#f0f8ff",n="gray");a.drawLine(c,0,0,p,0,g);a.drawLine(c,0,0,0,e/2,g);a.drawLine(c,0,e/2,p,e/2,n);this.down?(g="gray",n="#f0f8ff"):(g="#f0f8ff",n="gray");a.drawLine(c,0,e/2+1,p,e/2+1,g);a.drawLine(c,0,e/2+1,0,e,g);a.drawLine(c,0,e-1,p,e-1,n);q=[parseInt(p/2+1),parseInt(p/5+1),parseInt(p-p/5+1)];k=[parseInt(e/8+1),parseInt(e/8+1+e/4),parseInt(e/8+1+e/4)];c.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";c.beginPath();c.moveTo(q[0],k[0]);c.lineTo(q[1],k[1]);c.lineTo(q[2],k[2]);
c.fill();k=[parseInt(e-e/8),parseInt(e-e/8-e/4),parseInt(e-e/8-e/4)];c.fillStyle=this.activeIfValue?"#d00018":"#aa8888";c.beginPath();c.moveTo(q[0],k[0]);c.lineTo(q[1],k[1]);c.lineTo(q[2],k[2]);c.fill();c.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&c.fillRect(0,0,p,e/2);this.down&&c.fillRect(0,e/2,p,e)};a.Spinner.prototype.validateValue=function(a){d=this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=a.toString();s=parseFloat(d.evalExpression(d.parser.parse(a.replace(this.parent.decimal_symbol,
"."))));isNaN(s)&&(s=0);m=d.evalExpression(this.min);v=d.evalExpression(this.max);""===m&&(m=-Infinity);""===v&&(v=Infinity);s<m&&(s=m);s>v&&(s=v);this.discrete&&(r=d.evalExpression(this.incr),s=0==r?0:r*Math.round(s/r));t=d.evalExpression(this.decimals);0>=t&&(t=0);return s=parseFloat(parseFloat(s).toFixed(t))};a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-
this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.changeValue=function(a){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Spinner.prototype.registerMouseAndTouchEvents=function(){function b(a,c,e){clearInterval(n);if(k.up||k.down)c.call(k),a=e?a:30,n=setTimeout(function(){b(a,c)},a)}function c(e){e.preventDefault();k.whichButton=a.whichButton(e);"L"==
k.whichButton&&k.activeIfValue&&(k.up=!0,b(m,k.increase,!0),k.draw())}function e(c){c.preventDefault();k.whichButton=a.whichButton(c);"L"==k.whichButton&&k.activeIfValue&&(k.down=!0,b(m,k.decrease,!0),k.draw())}function d(a){k.up=!1;clearInterval(n);k.draw();a.preventDefault()}function g(a){k.down=!1;clearInterval(n);k.draw();a.preventDefault()}function f(a){k.up=!1;clearInterval(n);k.draw();a.preventDefault()}function h(a){k.down=!1;clearInterval(n);k.draw();a.preventDefault()}l=a.hasTouchSupport;
var k=this,m=l?500:200,n;k.divUp.oncontextmenu=k.divDown.oncontextmenu=k.field.oncontextmenu=k.label.oncontextmenu=function(){return!1};l?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&&k.changeValue(k.field.value)});l?this.divUp.addEventListener("touchstart",c):this.divUp.addEventListener("mousedown",c);l?this.divDown.addEventListener("touchstart",
e):this.divDown.addEventListener("mousedown",e);l||this.divUp.addEventListener("mouseout",d);l||this.divDown.addEventListener("mouseout",g);l?(this.divUp.addEventListener("touchend",f),window.addEventListener("touchend",f)):(this.divUp.addEventListener("mouseup",f),window.addEventListener("mouseup",f));l?(this.divDown.addEventListener("touchend",h),window.addEventListener("touchend",h)):(this.divDown.addEventListener("mouseup",h),window.addEventListener("mouseup",h));k.field.addEventListener("click",
function(a){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p,e;a.TextField=function(b,c){a.Control.call(this,b,c);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");void 0===this.valueExprString&&(this.valueExprString=this.onlyText?"0":"");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.answer=a.buildRegularExpresionsPatterns(this.answer,this.evaluator),this.onlyText){var e=this.answerPattern.indexOf("|");this.firstAnswer=-1==e?this.answerPattern:this.answerPattern.substring(0,e)}else this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(",")));this.onlyText&&(this.valueExprString.match(/^'/)&&this.valueExprString.match(/'$/)||
(this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'")),this.validateValue=function(a){return"''"==a||"'"==a?"":a&&a.match(/^'/)&&a.match(/'$/)?a.substring(1,a.length-1):a},this.formatOutputValue=function(a){return a.toString()});""==name.trim()&&(name="");this.containerControl=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);
this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){d=this.evaluator;var b=d.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(d.evalExpression(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var e=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),f=parseInt(this.w/2),h=a.getTextWidth(b,this.fieldFontSize+
"px Arial");f<h&&(f=h);""==b&&(f=0);this.w-f<e&&(f=this.w-e);0>f&&(f=0);b=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.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"TextField");this.field.setAttribute("class","DescartesTextFieldField");this.field.setAttribute("style","font-size: "+
this.fieldFontSize+"px; width : "+b+"px; height : "+this.h+"px; left: "+f+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;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;");this.evaluate&&(this.ok=this.evaluateAnswer());this.evaluator.setVariable(this.id,this.value);this.evaluator.setVariable(this.id+".ok",this.ok);this.oldValue=
this.value;this.update()};a.TextField.prototype.update=function(){d=this.evaluator;this.label.innerHTML=d.evalExpression(this.name).toString();this.activeIfValue=0<d.evalExpression(this.activeif);this.drawIfValue=0<d.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize();this.parent.animation.playing&&document.activeElement==this.field||(h=this.field.value,f=this.value,this.value=this.validateValue(d.getVariable(this.id)),
this.field.value=this.formatOutputValue(this.value),this.value===f&&this.field.value!=h&&(this.value=this.validateValue(h),this.field.value=this.formatOutputValue(this.value)),d.setVariable(this.id,this.value))};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";d=this.evaluator;b=parseFloat(d.evalExpression(d.parser.parse(a.toString().replace(this.parent.decimal_symbol,"."))));isNaN(b)&&(b=0);c=d.evalExpression(this.min);""==c&&(c=-Math.Infinity);p=d.evalExpression(this.max);
""==p&&(p=Math.Infinity);this.discrete&&(a=d.evalExpression(this.incr),b=0==a?0:a*Math.round(b/a));return b=parseFloat(parseFloat(b).toFixed(d.evalExpression(this.decimals)))};a.TextField.prototype.formatOutputValue=function(a){return""===a?"":this.uber.formatOutputValue.call(this,a)};a.TextField.prototype.changeValue=function(a,b){this.activeIfValue&&(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.updateAndExecAction())};a.TextField.prototype.evaluateAnswer=function(){return a.esCorrecto(this.answer,this.value,this.evaluator,this.answer)};a.TextField.prototype.getFirstAnswer=function(){return this.answer?this.onlyText?this.firstAnswer:this.evaluator.evalExpression(this.firstAnswer):""};a.TextField.prototype.registerMouseAndTouchEvents=function(){e=a.hasTouchSupport;var b=this;b.field.oncontextmenu=b.label.oncontextmenu=function(){return!1};
e?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(a){b.changeValue(b.field.value,!0)});this.field.addEventListener("keydown",function(a){b.activeIfValue&&13==a.keyCode&&b.changeValue(b.field.value,!0)});b.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d=Math.abs,h,f,b,c,p,e,g,n,q,k,s;a.Menu=function(b,c){this.options="";a.Control.call(this,b,c);h=this.parser;f=this.evaluator;this.ok=0;this.tabindex=++this.parent.tabindex;this.answer&&(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answer=parseInt(this.answer.split(",")[0].replace("[",""))||0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=
this.parser.parse("'"+this.name+"'");this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var e,d=0,g=this.options.length;d<g;d++)e=this.customSplit(this.options[d]),1==e.length?(this.menuOptions.push(e[0]),this.strValue.push(d.toString())):2==e.length&&(this.menuOptions.push(e[0]),""==e[1]?this.strValue.push(d.toString()):this.strValue.push(e[1]));d=0;for(g=this.menuOptions.length;d<g;d++)this.menuOptions[d].match(/^\[/)&&this.menuOptions[d].match(/\]$/)?this.menuOptions[d]=
h.parse(this.menuOptions[d].substring(1,this.menuOptions[d].length-1)):this.menuOptions[d]=h.parse("'"+this.menuOptions[d]+"'");d=0;for(g=this.strValue.length;d<g;d++)this.strValue[d].match(/^\[/)&&this.strValue[d].match(/\]$/)?this.strValue[d]=h.parse(this.strValue[d].substring(1,this.strValue[d].length-1)):this.strValue[d]=h.parse(this.strValue[d]);this.containerControl=document.createElement("div");this.label=document.createElement("label");this.select=document.createElement("select");d=0;for(g=
this.menuOptions.length;d<g;d++)e=document.createElement("option"),e.innerHTML=f.evalExpression(this.menuOptions[d]),this.select.appendChild(e);this.field=document.createElement("input");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Menu,a.Control);a.Menu.prototype.init=function(){f=this.evaluator;
var b=f.evalExpression(this.name).toString();this.label.innerHTML=b;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var c=0,e=0,d=0;this.value=f.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var g=0,h=this.menuOptions.length;g<h;g++)d=a.getTextWidth(f.evalExpression(this.menuOptions[g]).toString(),this.fieldFontSize+"px Arial"),d>c&&(c=d,e=g);c+=25;d=a.getTextWidth(this.formatOutputValue(f.evalExpression(this.strValue[e])),this.fieldFontSize+
"px Arial")+7;e=a.getTextWidth(b,this.fieldFontSize+"px Arial")+10;""==b&&(e=0);this.visible||(d=0);for(b=this.w-d-e;b<c&&0<e;)e--,b++;for(;b<c&&0<d;)d--,b++;for(;e+b+d+1<this.w;)b++,d++;c=e;g=c+b;d=this.w-g;h=this.formatOutputValue(f.evalExpression(this.strValue[this.indexValue]));this.containerControl.setAttribute("class","DescartesMenuContainer");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.label.setAttribute("class","DescartesMenuLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+e+"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=h;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+d+"px; height : "+this.h+"px; left: "+g+"px;");this.field.setAttribute("tabindex",
this.tabindex);this.select.setAttribute("id",this.id+"menuSelect");this.select.setAttribute("class","DescartesMenuSelect");this.select.setAttribute("style","text-align: left; font-size: "+this.fieldFontSize+"px; line-height: "+this.h+"px; width : "+b+"px; height : "+this.h+"px; left: "+c+"px; border-color: #7a8a99; border-width: 1.5px; border-style: solid; background-color: #eeeeee;");this.select.setAttribute("tabindex",this.tabindex);this.select.selectedIndex=this.indexValue;f.setVariable(this.id,
parseFloat(h));this.update()};a.Menu.prototype.update=function(){f=this.evaluator;this.label.innerHTML=f.evalExpression(this.name).toString();this.activeIfValue=0<f.evalExpression(this.activeif);this.drawIfValue=0<f.evalExpression(this.drawif);this.field.disabled=this.activeIfValue?!1:!0;this.select.disabled=this.activeIfValue?!1:!0;this.drawIfValue?this.containerControl.style.display="block":(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();if(!this.parent.animation.playing||
document.activeElement!=this.select){for(var a=0,b=this.menuOptions.length;a<b;a++)this.select.options[a].innerHTML=f.evalExpression(this.menuOptions[a]);this.value=f.getVariable(this.id);isNaN(this.value)&&(this.value=0);this.field.value=this.formatOutputValue(this.value);f.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))}this.ok=this.value==this.answer?1:0;this.evaluator.setVariable(this.id+".ok",this.ok)};a.Menu.prototype.customSplit=function(a){g=
!1;n="";q=0;for(k=-1;q<a.length;){s=a.charAt(q);a.charAt(q-1);if("["===s&&-1===k){if(g||""!=n)n+="\u00a6";k++}else"["===s?k++:"]"===s&&0===k?(g=!0,k--):"]"==a.charAt(q)&&(k=0>k?k:k-1);n+=a.charAt(q);q++}return n.split("\u00a6")};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));b=-1;c=Infinity;for(var e=0,g=this.strValue.length;e<g;e++)p=d(a-parseFloat(this.evaluator.evalExpression(this.strValue[e]))),p<=c&&(c=p,b=e);return b};a.Menu.prototype.changeValue=
function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){e=a.hasTouchSupport;var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=function(){return!1};e?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(a){b.value=
b.evaluator.evalExpression(b.strValue[this.selectedIndex]);b.field.value=b.formatOutputValue(b.value);b.evaluator.setVariable(b.id,b.field.value);b.changeValue();a.preventDefault()});this.field.addEventListener("keydown",function(a){13==a.keyCode&&(b.indexValue=b.getIndex(b.field.value),b.value=b.evaluator.evalExpression(b.strValue[b.indexValue]),b.field.value=b.formatOutputValue(b.indexValue),b.select.selectedIndex=b.indexValue,b.changeValue())});b.field.addEventListener("click",function(a){this.select();
this.focus()});b.select.addEventListener("click",function(a){this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h="h",f,b,c,p,e,g,n,q,k,s,r,t,m,v,l,u,w,z,C,A,E;a.Scrollbar=function(b,c){a.Control.call(this,b,c);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.orientation=this.w>=this.h?h:"v";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.scrollManipulator=document.createElement("div");this.label=document.createElement("label");this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.containerControl.appendChild(this.field);
this.containerControl.appendChild(this.scrollManipulator);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){f=this.evaluator;this.findOffset();0==f.evalExpression(this.decimals)?this.incr=1:this.incr=(f.evalExpression(this.max)-f.evalExpression(this.min))/100;this.value=this.validateValue(f.evalExpression(this.valueExpr));c=this.formatOutputValue(this.value);p=this.evaluator.evalExpression(this.expresion);
this.x=p[0][0];this.y=p[0][1];4==p[0].length&&(this.w=p[0][2],this.h=p[0][3]);this.orientation=this.w>=this.h?h:"v";this.initScroll(c);this.changeScrollPositionFromValue();this.prePos=this.pos;f.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(c){b=this;f=b.evaluator;var e=f.evalExpression(b.name).toString();b.label.innerHTML=e;var d="v"===b.orientation?parseInt(19+5*(b.h-100)/100):b.h;b.fieldFontSize="v"===b.orientation?d-parseInt(b.h/20)-1:2!==b.parent.version?a.getFieldFontSize(d):
10;var g=a.getTextWidth(c+"_",b.fieldFontSize+"px Arial"),h=b.parent.getSpaceById(b.spaceID).h;b.labelHeight=""==e?0:d;b.fieldHeight=""==b.visible?0:d;if("v"===b.orientation)b.canvasWidth=b.w,b.canvasHeight=b.h-b.labelHeight-b.fieldHeight,18<=b.canvasHeight+b.y-h&&(b.canvasHeight=h),e=0,e=b.fieldHeight,g=e+b.canvasHeight,b.canvasX=0,b.canvasY=b.fieldHeight,b.labelWidth=b.w,b.labelY=g,b.upWidth=b.downW=b.w,b.upHeight=b.downH=15,b.upX=0,b.upY=b.fieldHeight,b.downX=0,b.downY=g-b.downH,b.fieldWidth=b.w,
b.fieldX=0,b.scrollManipulatorW=b.w,b.scrollManipulatorH=parseInt((b.canvasHeight-b.upHeight-b.downH-b.labelHeight-b.fieldHeight)/10),b.scrollManipulatorH=15>b.scrollManipulatorH?15:b.scrollManipulatorH,b.scrollManipulatorLimInf=g-b.downH-b.scrollManipulatorH,b.scrollManipulatorLimSup=e+b.downH;else{d=a.getTextWidth(e,b.fieldFontSize+"px Arial")+10;b.labelWidth=d;b.fieldWidth=g;""==e&&(b.labelWidth=0);b.visible||(b.fieldWidth=0);for(g=b.w-b.fieldWidth-b.labelWidth;58>g&&0<b.labelWidth;)b.labelWidth--,
g++;for(;58>g&&0<b.fieldWidth;)b.fieldWidth--,g++;e=b.labelWidth;d=e+g;b.fieldWidth=b.w-d;b.canvasWidth=g;b.canvasHeight=b.h;b.canvasX=b.labelWidth;b.canvasY=0;b.fieldX=b.canvasWidth+b.labelWidth;b.labelHeight=b.h;b.labelY=0;b.upWidth=b.downW=15;b.upHeight=b.downH=b.h;b.upX=d-b.downW;b.upY=0;b.downX=b.labelWidth;b.downY=0;b.scrollManipulatorW=parseInt((b.canvasWidth-b.upWidth-b.downW)/10);b.scrollManipulatorW=15>b.scrollManipulatorW?15:b.scrollManipulatorW;b.scrollManipulatorH=b.h;b.scrollManipulatorLimInf=
e+b.downW;b.scrollManipulatorLimSup=e+b.canvasWidth-b.downW-b.scrollManipulatorW}b.containerControl.setAttribute("class","DescartesScrollbarContainer");b.containerControl.setAttribute("style","width: "+b.w+"px; height: "+b.h+"px; left: "+b.x+"px; top: "+b.y+"px; z-index: "+b.zIndex+";");b.canvas.setAttribute("width",b.w+"px");b.canvas.setAttribute("height",b.h+"px");b.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");b.ctx=b.canvas.getContext("2d");b.divUp.setAttribute("class",
"DescartesCatcher");b.divUp.setAttribute("style","width : "+b.upWidth+"px; height : "+b.upHeight+"px; left: "+b.upX+"px; top: "+b.upY+"px;");b.divDown.setAttribute("class","DescartesCatcher");b.divDown.setAttribute("style","width : "+b.downW+"px; height : "+b.downH+"px; left: "+b.downX+"px; top: "+b.downY+"px;");b.scrollManipulator.setAttribute("class","DescartesCatcher");b.scrollManipulator.setAttribute("style","width : "+b.scrollManipulatorW+"px; height : "+b.scrollManipulatorH+"px;");b.scrollManipulator.style.top=
("v"===b.orientation?b.scrollManipulatorLimInf:0)+"px";b.scrollManipulator.style.left=("v"===b.orientation?0:b.scrollManipulatorLimInf)+"px";b.field.setAttribute("type","text");b.field.setAttribute("id",b.id+"scrollbar");b.field.setAttribute("class","DescartesScrollbarField");b.field.setAttribute("style","font-size: "+b.fieldFontSize+"px; width : "+b.fieldWidth+"px; height : "+b.fieldHeight+"px; left: "+b.fieldX+"px; top: 0px;");b.field.value=c;0===b.fieldHeight&&(b.field.style.display="none");b.label.setAttribute("class",
"DescartesScrollbarLabel");b.label.setAttribute("style","font-size:"+b.fieldFontSize+"px; width: "+b.labelWidth+"px; height: "+b.labelHeight+"px; line-height: "+b.labelHeight+"px; left: 0px; top:"+b.labelY+"px;")};a.Scrollbar.prototype.update=function(){f=this.evaluator;this.label.innerHTML=f.evalExpression(this.name).toString();0==f.evalExpression(this.decimals)?this.incr=1:this.incr=(f.evalExpression(this.max)-f.evalExpression(this.min))/100;this.activeIfValue=0<f.evalExpression(this.activeif);
this.drawIfValue=0<f.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";this.updatePositionAndSize();var a=this.validateValue(f.getVariable(this.id));a==this.value||0<Math.abs(a-this.value)&&1E-9>Math.abs(a-this.value)||(this.value=a,this.changeScrollPositionFromValue(),this.prePos=this.pos);this.value=a;this.field.value=this.formatOutputValue(this.value);f.setVariable(this.id,
this.value)};a.Scrollbar.prototype.draw=function(){b=this;e=b.ctx;n=d(this.w);g=d(this.h);e.fillStyle="#e0e4e8";e.fillRect(0,0,n,g);e.strokeStyle="#7a8a99";b.down&&(e.fillStyle="#ccdcec",e.fillRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1));e.strokeRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1);b.up&&(e.fillStyle="#ccdcec",e.fillRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1));e.strokeRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1);q=4;e.fillStyle="black";e.beginPath();b.orientation===h?(e.moveTo(b.downX+
q,b.downH/2),e.lineTo(b.downX+b.downW-q,q),e.lineTo(b.downX+b.downW-q,b.downH-q),e.moveTo(b.upX+b.upWidth-q,b.downH/2),e.lineTo(b.upX+q,q),e.lineTo(b.upX+q,b.downH-q),e.fill(),b.activeIfValue&&(k=d(b.pos),e.fillStyle="#ccdcec",e.fillRect(k+0.5,0,d(b.scrollManipulatorW),g),e.strokeStyle="#6382bf",e.strokeRect(k+0.5,0,d(b.scrollManipulatorW),g),s=d(b.scrollManipulatorW/2),e.beginPath(),e.moveTo(k+s+0.5-2,3),e.lineTo(k+s+0.5-2,g-3),e.moveTo(k+s+0.5,3),e.lineTo(k+s+0.5,g-3),e.moveTo(k+s+0.5+2,3),e.lineTo(k+
s+0.5+2,g-3),e.stroke())):(e.moveTo(b.downX+b.downW/2,b.downY+b.downH-q),e.lineTo(b.downX+q,b.downY+q),e.lineTo(b.downX+b.downW-q,b.downY+q),e.moveTo(b.upX+b.upWidth/2,b.upY+q),e.lineTo(b.upX+q,b.upY+b.upHeight-q),e.lineTo(b.upX+b.upWidth-q,b.upY+b.upHeight-q),e.fill(),b.activeIfValue&&(k=d(b.pos),e.fillStyle="#ccdcec",e.fillRect(0,k+0.5,n,d(b.scrollManipulatorH)),e.strokeStyle="#6382bf",e.strokeRect(0,k+0.5,n,d(b.scrollManipulatorH)),s=d(b.scrollManipulatorH/2),e.beginPath(),e.moveTo(3,k+s+0.5-2),
e.lineTo(n-3,k+s+0.5-2),e.moveTo(3,k+s+0.5),e.lineTo(n-3,k+s+0.5),e.moveTo(3,k+s+0.5+2),e.lineTo(n-3,k+s+0.5+2),e.stroke()));e.strokeRect(0.5,0.5,n-1,g-1);b.activeIfValue||(e.fillStyle="rgba(240,240,240,"+160/255+")",e.fillRect(0,0,n,g.h))};a.Scrollbar.prototype.validateValue=function(a){f=this.evaluator;r=a.toString();r=parseFloat(r.replace(this.parent.decimal_symbol,"."));isNaN(r)&&(r=0);this.minimo=f.evalExpression(this.min);r<this.minimo&&(this.value=null,r=this.minimo);this.maximo=f.evalExpression(this.max);
r>this.maximo&&(this.value=null,r=this.maximo);t=this.incr;r=0!=t?r*t/t:0;this.fixed&&(r=parseFloat(parseFloat(r).toFixed(f.evalExpression(this.decimals))));return r};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(){q=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==
h?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+q):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+q)};a.Scrollbar.prototype.decrease10=function(){q=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==h?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-q):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-q)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&
(m=this.validateValue(a),m!=this.value&&(this.value=m,this.field.value=this.formatOutputValue(m),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){f=this.evaluator;v=this.scrollManipulatorLimInf;l=this.scrollManipulatorLimSup;u=f.evalExpression(this.min);w=f.evalExpression(this.max);t=this.incr;m=d((this.pos-v)*(w-u)/(l-v)/t)*t+u;m!=this.value&&(this.value=
m,this.field.value=this.formatOutputValue(m),f.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){f=this.evaluator;v=this.scrollManipulatorLimInf;l=this.scrollManipulatorLimSup;u=f.evalExpression(this.min);w=f.evalExpression(this.max);t=this.incr;this.pos=(this.value-u)*(l-v)/(w-u)+v;this.orientation==h?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=
this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=function(){function b(a,c,e,d){clearInterval(w);(t.up||t.down||t.canvasClick)&&1E-7<Math.abs(t.value-d)&&(c.call(t),a=e?a:30,w=setTimeout(function(){b(a,c,!1,d)},a))}function c(e){e.preventDefault();t.whichButton=a.whichButton(e);"L"==t.whichButton&&t.activeIfValue&&(t.clickPos=t.getCursorPosition(e),t.canvasClick=!0,t.orientation==h?t.clickPos.x<t.prePos?b(v,t.decrease10,!0,t.minimo):b(v,t.increase10,!0,t.maximo):t.clickPos.y<t.prePos?
b(v,t.increase10,!0,t.maximo):b(v,t.decrease10,!0,t.minimo))}function e(a){t.canvasClick=!1;clearInterval(w);a.preventDefault()}function d(a){!0==t.canvasClick&&(t.clickPos=t.getCursorPosition(a),a.preventDefault())}function g(a){t.activeIfValue&&(t.scrollClick=!0,t.initPos=t.getCursorPosition(a),window.addEventListener("mouseup",k),window.addEventListener("mousemove",n),a.preventDefault())}function f(a){t.activeIfValue&&(t.scrollClick=!0,t.initPos=t.getCursorPosition(a),window.addEventListener("touchend",
m),window.addEventListener("touchmove",onToucheMove_scrollManipulator),a.preventDefault())}function k(a){t.scrollClick=!1;t.prePos=t.pos;window.removeEventListener("mouseup",k,!1);window.removeEventListener("mousemove",n,!1);a.preventDefault()}function m(a){t.scrollClick=!1;t.prePos=t.pos;window.removeEventListener("touchend",m,!1);window.removeEventListener("touchmove",n,!1);a.preventDefault()}function n(a){var b=t.getCursorPosition(a);t.orientation==h?(t.pos=t.prePos-(t.initPos.x-b.x),t.pos<t.scrollManipulatorLimInf&&
(t.pos=t.scrollManipulatorLimInf),t.pos>t.scrollManipulatorLimSup&&(t.pos=t.scrollManipulatorLimSup),t.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+t.scrollManipulatorW+"px; height : "+t.h+"px; left: "+t.pos+"px; top: 0px;")):(t.pos=t.prePos-(t.initPos.y-b.y),t.pos>t.scrollManipulatorLimInf&&(t.pos=t.scrollManipulatorLimInf),t.pos<t.scrollManipulatorLimSup&&(t.pos=t.scrollManipulatorLimSup),t.scrollManipulator.setAttribute("style",
"background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+t.w+"px; height : "+t.scrollManipulatorH+"px; left: 0px; top: "+t.pos+"px;"));t.changeValueForScrollMovement();a.preventDefault()}function q(c){c.preventDefault();t.whichButton=a.whichButton(c);"L"==t.whichButton&&t.activeIfValue&&(t.up=!0,b(v,t.increase,!0,t.maximo))}function p(c){c.preventDefault();t.whichButton=a.whichButton(c);"L"==t.whichButton&&t.activeIfValue&&(t.down=!0,b(v,t.decrease,!0,t.minimo))}function l(a){t.up=
!1;clearInterval(w);a.preventDefault()}function s(a){t.down=!1;clearInterval(w);a.preventDefault()}function r(a){t.up=!1;clearInterval(w);a.preventDefault();t.draw()}function u(a){t.down=!1;clearInterval(w);a.preventDefault();t.draw()}z=a.hasTouchSupport;var t=this,v=z?500:200,w;t.canvas.oncontextmenu=t.divUp.oncontextmenu=t.divDown.oncontextmenu=t.label.oncontextmenu=t.field.oncontextmenu=t.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==
a.keyCode&&t.changeValue(t.field.value)});z?this.canvas.addEventListener("touchstart",c):this.canvas.addEventListener("mousedown",c);z||this.divDown.addEventListener("mouseout",s);z?window.addEventListener("touchend",e):window.addEventListener("mouseup",e);z?this.canvas.addEventListener("touchmove",d):this.canvas.addEventListener("mousemove",d);z?this.scrollManipulator.addEventListener("touchstart",f):this.scrollManipulator.addEventListener("mousedown",g);z?this.divUp.addEventListener("touchstart",
q):this.divUp.addEventListener("mousedown",q);z?this.divDown.addEventListener("touchstart",p):this.divDown.addEventListener("mousedown",p);z||this.divUp.addEventListener("mouseout",l);z||this.divDown.addEventListener("mouseout",s);z?window.addEventListener("touchend",r):window.addEventListener("mouseup",r);z?window.addEventListener("touchend",u):window.addEventListener("mouseup",u)};a.Scrollbar.prototype.findOffset=function(){C=this.containerControl;this.offsetTop=this.offsetLeft=0;A=this.containerControl.style.display;
for(this.containerControl.style.display="block";C;)this.offsetLeft+=C.offsetLeft||0,this.offsetTop+=C.offsetTop||0,C=C.parentNode;this.containerControl.style.display=A};a.Scrollbar.prototype.getCursorPosition=function(b){E=a.getCursorPosition(b);return{x:E.x-this.offsetLeft,y:E.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.Audio=function(d,b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,d,b);var c=this,h=c.evaluator.evalExpression(c.expresion);
4==h[0].length?(c.w=h[0][2],c.h=h[0][3]):(c.w=200,c.h=28);c.audio=c.parent.getAudio(c.file);c.autoplay&&(c.audio.setAttribute("autoplay","autoplay"),c.audio.play());c.loop&&c.audio.setAttribute("loop","loop");c.controls&&c.audio.setAttribute("controls","controls");c.audio.setAttribute("style","position: absolute; width: "+c.w+"px; left: "+c.x+"px; top: "+c.y+"px; z-index: "+c.zIndex+";");c.addControlContainer(c.audio);c.evaluator.setFunction(c.id+".play",function(){c.audio.play()});c.evaluator.setFunction(c.id+
".pause",function(){c.audio.pause()});c.evaluator.setFunction(c.id+".stop",function(){c.audio.pause();c.audio.currentTime=0});c.audio.addEventListener("timeupdate",function(a){c.evaluator.setVariable(c.id+".currentTime",c.audio.currentTime)})};a.extend(a.Audio,a.Control);a.Audio.prototype.init=function(){this.audio.style.left=this.x+"px";this.audio.style.top=this.y+"px";this.update()};var h;a.Audio.prototype.update=function(){d=this.evaluator;(h=0<d.evalExpression(this.drawif))?this.audio.style.display=
"block":(this.audio.style.display="none",h!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=h;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.Video=function(f,b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,f,b);var c=this;d=c.evaluator;var h=c.evaluator.evalExpression(c.expresion);4==h[0].length?(c.w=h[0][2],c.h=h[0][3]):(c.w=null,c.h=null);c.video=document.createElement("video");c.autoplay&&c.video.setAttribute("autoplay",
"autoplay");c.loop&&c.video.setAttribute("loop","loop");c.controls&&c.video.setAttribute("controls","controls");c.poster&&c.video.setAttribute("poster",c.poster);c.w&&(c.video.setAttribute("width",c.w),c.video.setAttribute("height",c.h));c.video.setAttribute("style","position: absolute; overflow: hidden; left: "+c.x+"px; top: "+c.y+"px;");var h=c.file,e=h.lastIndexOf(".");-1!=e&&(h=c.file.substring(0,e));c.video.canPlayType("video/mp4")&&(e=document.createElement("source"),e.setAttribute("src",h+
".mp4"),e.setAttribute("type","video/mp4"),c.video.appendChild(e));c.video.canPlayType("video/ogg")&&(e=document.createElement("source"),e.setAttribute("src",h+".ogg"),e.setAttribute("type","video/ogg"),c.video.appendChild(e),e=document.createElement("source"),e.setAttribute("src",h+".ogv"),e.setAttribute("type","video/ogg"),c.video.appendChild(e));c.video.canPlayType("video/webm")&&(e=document.createElement("source"),e.setAttribute("src",h+".webm"),e.setAttribute("type","video/webm"),c.video.appendChild(e));
c.addControlContainer(c.video);c.evaluator.setFunction(c.id+".play",function(){c.video.play()});c.evaluator.setFunction(c.id+".pause",function(){c.video.pause()});c.evaluator.setFunction(c.id+".stop",function(){c.video.pause();c.video.currentTime=0});c.video.addEventListener("timeupdate",function(a){c.evaluator.setVariable(c.id+".currentTime",c.video.currentTime)})};a.extend(a.Video,a.Control);a.Video.prototype.init=function(){this.video.style.left=this.x+"px";this.video.style.top=this.y+"px";this.update()};
var h;a.Video.prototype.update=function(){d=this.evaluator;h=0<d.evalExpression(this.drawif);0<d.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display="none",h!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=h;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h;a.TextArea=function(d,b){this.font="Monospaced,PLAIN,12";a.Control.call(this,d,b);this.region="interior";this.tabindex=++this.parent.tabindex;
if(this.answer){this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7)));var c=this.parent.lessonParser.parseText(this.answer)}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);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=void 0==this.text||"simpleText"==this.text.type?this.rawText||"":this.text.hasFormula?this.rawText:this.text.toHTML();c&&"simpleText"!=c.type&&(this.answer=this.text.hasFormula?"":c.toHTML());this.evaluator.setVariable(this.id,this.text);this.drawButton();this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextArea,
a.Control);a.TextArea.prototype.init=function(){h=this.answer?28:8;d=this.evaluator;var f;f=this.text.match(/<span/)?this.text:this.text.replace(/\\n/g,"<br/>");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<d.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-h)+"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;' >"+f+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");
this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-h)+"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.style.display=this.answer?"block":"none";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.update()};a.TextArea.prototype.drawButton=function(){var d=document.createElement("canvas");d.setAttribute("width",
20);d.setAttribute("height",16);var b=d.getContext("2d");this.canvas=d;this.ctx=b;this.createGradient(20,16);b.lineWidth=1;b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(b,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(b,1,0,1,16,"rgba(0,0,0,"+8/255+")");this.imageUnPush=d.toDataURL();b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,
0,0,0,14,"gray");a.drawLine(b,0,0,19,0,"gray");b.fillStyle="rgba(0, 0, 0,"+24/255+")";b.fillRect(0,0,this.w,this.h);this.imagePush=d.toDataURL()};a.TextArea.prototype.update=function(){d=this.evaluator;this.activeIfValue=0<d.evalExpression(this.activeif);this.drawIfValue=0<d.evalExpression(this.drawif);var a;a=this.text.match(/<span/)?this.rawText:this.text;d.setVariable(this.id,a);this.activeCover.style.display=this.activeIfValue?"none":"block";this.containerControl.style.display=this.drawIfValue?
"block":"none";this.updatePositionAndSize()};a.TextArea.prototype.registerMouseAndTouchEvents=function(){function a(c){c.preventDefault();b.showButton.style.backgroundImage="url("+b.imageUnPush+")"}var b=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();b.showAnswer=!b.showAnswer;b.textAreaAnswer.style.display=b.showAnswer?"block":"none";b.showButton.childNodes[0].childNodes[0].textContent=b.showAnswer?"T":"S";b.showButton.style.backgroundImage="url("+b.imagePush+")"});
this.showButton.addEventListener("mouseup",a);this.showButton.addEventListener("mouseout",a)};a.TextArea.prototype.getScreenshot=function(){var a=document.createElement("canvas");a.setAttribute("width",this.w);a.setAttribute("height",this.h);var b=a.getContext("2d");b.fillStyle="white";b.strokeStyle="black";b.lineWidth=1;b.fillRect(0,0,this.w,this.h);b.strokeRect(0,0,this.w,this.h);return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI,h,f,b,c,p,e,g,n,q;
a.GraphicControl=function(b,c){f=b.evaluator.parser;this.text=this.spaceID="";this.size=f.parse("4");this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";a.Control.call(this,b,c);this.touchId=null;this.font=a.convertFont(this.font);this.constraintExpr&&(this.constraint=f.parse(this.constraintExpr),"(expr)"==this.constraint.type&&(this.constraint=f.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,n=new a.R2(0,0));this.container=this.getContainer();this.mouseCacher=document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("dragged",!0);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);this.registerMouseAndTouchEvents();this.xString=this.id+
".x";this.yString=this.id+".y";this.activoString=this.id+".activo";this.activeString=this.id+".active";""!==this.space.id&&2!==b.version?(this.mxString=this.space.id+".mouse_x",this.myString=this.space.id+".mouse_y",this.mclickedString=this.space.id+".mouse_clicked",this.mclicizquierdoString=this.space.id+".clic_izquierdo"):(this.mxString="mouse_x",this.myString="mouse_y",this.mclickedString="mouse_clicked",this.mclicizquierdoString="clic_izquierdo");this.init()};a.GraphicControl.prototype.init=function(){h=
this.evaluator;q=a.hasTouchSupport;var b=h.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];h.setVariable(this.xString,this.x);h.setVariable(this.yString,this.y);""==this.imageSrc||this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.width=2*h.evalExpression(this.size),this.height=2*h.evalExpression(this.size)):(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,this.height=this.image.height);this._w=q&&70>this.width?70:this.width;this._h=q&&70>this.height?70:
this.height;this.mouseCacher.setAttribute("style","cursor: pointer; 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";h.setVariable(this.activoString,0);h.setVariable(this.activeString,0);this.setImage=!1;this.update()};a.GraphicControl.prototype.update=function(){h=
this.evaluator;this.activeIfValue=0<h.evalExpression(this.activeif);this.drawIfValue=0<h.evalExpression(this.drawif);this.x=h.getVariable(this.xString);this.y=h.getVariable(this.yString);b=this.space.getAbsoluteX(this.x);c=this.space.getAbsoluteY(this.y);this.mouseCacher.style.display=this.activeIfValue?"block":"none";this.mouseCacher.style.left=parseInt(b-this._w/2)+"px";this.mouseCacher.style.top=parseInt(c-this._h/2)+"px";this.constraint&&this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=
function(){h=this.evaluator;this.drawIfValue&&(e=this.ctx,g=this.space.backgroundCtx,b=parseInt(this.space.getAbsoluteX(this.x))+0.5,c=parseInt(this.space.getAbsoluteY(this.y))+0.5,""!=this.text&&this.drawText(b,c),this.image.ready?(this.image.complete&&!this.setImage&&e.drawImage(this.image,parseInt(b-this.image.width/2),parseInt(c-this.image.height/2)),this.trace&&(g.save(),g.translate(b,c),g.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),g.beginPath(),g.arc(0,0,1,0,d,!1),g.restore(),
g.lineWidth=1,g.strokeStyle=this.trace.getColor(),g.stroke())):(e.beginPath(),e.arc(b,c,parseInt(this.width/2),0,d,!1),e.fillStyle=this.colorInt.getColor(),e.fill(),e.lineWidth=1,e.strokeStyle=this.color.getColor(),e.stroke(),this.active&&(e.beginPath(),e.arc(b,c,parseInt(this.width/2)-2,0,d,!1),e.strokeStyle=this.colorInt.borderColor(),e.stroke()),this.trace&&(g.lineWidth=1,g.strokeStyle=this.trace.getColor(),g.beginPath(),g.arc(b,c,parseInt(this.width/2),0,d,!1),g.stroke())))};a.GraphicControl.prototype.evalConstraint=
function(a,b){n.set(this.x,this.y);p=this.newt.findZero(n);this.x=p.x;this.y=p.y;this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,this.y)};a.GraphicControl.prototype.drawText=function(a,b){e=this.ctx;h=this.evaluator;e.fillStyle=this.color.getColor();e.font=this.font;e.textBaseline="alphabetic";e.fillText(h.evalExpression(this.text[0],h.evalExpression(this.decimals),this.fixed),parseInt(a+1+this.width/2),parseInt(b-1-this.height/2))};a.GraphicControl.prototype.getContainer=
function(){for(var a=this.parent.spaces,b,c=0,e=a.length;c<e;c++)if(b=a[c],b.id==this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,this.space=b,b.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.activoString,0);this.evaluator.setVariable(this.activeString,0)};a.GraphicControl.prototype.registerMouseAndTouchEvents=function(){function b(c){document.body.focus();
c.preventDefault();n.whichButton=a.whichButton(c);"L"==n.whichButton&&(n.activeIfValue&&n.over)&&(n.parent.deactivateGraphiControls(),n.click=!0,n.active=!0,n.evaluator.setVariable(n.activoString,1),n.evaluator.setVariable(n.activeString,1),n.evaluator.setVariable(n.mclickedString,0),n.evaluator.setVariable(n.mclicizquierdoString,0),n.posAnte=n.getCursorPosition(c),n.prePos={x:n.space.getAbsoluteX(n.x),y:n.space.getAbsoluteY(n.y)},n.evaluator.setVariable(n.mxString,n.space.getRelativeX(n.posAnte.x)),
n.evaluator.setVariable(n.myString,n.space.getRelativeY(n.posAnte.y)),n.parent.update(),window.addEventListener("mouseup",e),window.addEventListener("mousemove",d))}function c(a){document.body.focus();a.preventDefault();n.activeIfValue&&(n.parent.deactivateGraphiControls(),n.click=!0,n.active=!0,n.evaluator.setVariable(n.activoString,1),n.evaluator.setVariable(n.activeString,1),n.evaluator.setVariable(n.mclickedString,0),n.evaluator.setVariable(n.mclicizquierdoString,0),n.posAnte=n.getCursorPosition(a),
n.prePos={x:n.space.getAbsoluteX(n.x),y:n.space.getAbsoluteY(n.y)},n.evaluator.setVariable(n.mxString,n.space.getRelativeX(n.posAnte.x)),n.evaluator.setVariable(n.myString,n.space.getRelativeY(n.posAnte.y)),n.parent.update(),window.addEventListener("touchmove",d),window.addEventListener("touchend",e))}function e(b){document.body.focus();b.preventDefault();n.touchId=null;n.evaluator.setVariable(n.mclickedString,1);n.evaluator.setVariable(n.mclicizquierdoString,1);if(n.activeIfValue||n.active)n.click=
!1,a.hasTouchSupport?(window.removeEventListener("touchmove",d,!1),window.removeEventListener("touchend",e,!1)):(window.removeEventListener("mouseup",e,!1),window.removeEventListener("mousemove",d,!1)),n.evaluator.setVariable(n.mxString,n.space.getRelativeX(n.posAnte.x)+n.x),n.evaluator.setVariable(n.myString,n.space.getRelativeY(n.posAnte.y)+n.y),n.parent.update(),n.mouseCacher.style.left=n.space.getAbsoluteX(n.x)-n._w/2+"px",n.mouseCacher.style.top=n.space.getAbsoluteY(n.y)-n._h/2+"px"}function d(a){a.preventDefault();
a.touchId=n.touchId;n.evaluator.setVariable(n.mclickedString,0);n.evaluator.setVariable(n.mclicizquierdoString,0);q=n.getCursorPosition(a);n.posX=n.prePos.x-(n.posAnte.x-q.x);n.posY=n.prePos.y-(n.posAnte.y-q.y);n.evaluator.setVariable(n.xString,n.space.getRelativeX(n.posX));n.evaluator.setVariable(n.yString,n.space.getRelativeY(n.posY));n.evaluator.setVariable(n.mxString,n.space.getRelativeX(n.posAnte.x)+n.space.getRelativeX(n.posX));n.evaluator.setVariable(n.myString,n.space.getRelativeY(n.posAnte.y)+
n.space.getRelativeY(n.posY));10<Date.now()-h&&(n.parent.updateControls(),n.parent.update(),h=Date.now())}function g(a){n.over=!0}function f(a){n.over=!1;n.click=!1}var h=0,n=this;this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=function(){return!1};a.hasTouchSupport?this.mouseCacher.addEventListener("touchstart",c):(this.mouseCacher.addEventListener("mousedown",b),this.mouseCacher.addEventListener("mouseover",g),this.mouseCacher.addEventListener("mouseout",f));var q};a.GraphicControl.prototype.getCursorPosition=
function(a){if(a.touches){var b;if(a.touchId)for(c=0,e=a.touches.length;c<e;c++){if(a.touches[c].identifier==a.touchId){b=a.touches[c];break}}else for(var c=0,e=a.touches.length;c<e;c++)if(a.target==a.touches[c].target){b=a.touches[c];this.touchId=b.identifier;break}mouseX=b.pageX;mouseY=b.pageY}else void 0!=a.pageX&&void 0!=a.pageY?(mouseX=a.pageX,mouseY=a.pageY):(mouseX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,mouseY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);
return{x:mouseX-(this.space.container.offsetLeft+this.space.container.parentNode.offsetLeft),y:mouseY-(this.space.container.offsetTop+this.space.container.parentNode.offsetTop)}};return a}(descartesJS||{}),descartesJS=function(a,d){var h,f,b,c,p,e,g,n,q,k;if(a.loadLib)return a;var s,r,t,m,v,l,u,w,z=/[\w-//]*(\.png|\.jpg|\.gif|\.svg)/gi,C,A,E,F,B,y,G,H,K,I,x,L,D,J,M,O,R,S,P,Q,N;a.LessonParser=function(b){this.parent=b;this.parser=b.evaluator.parser;this.RTFparser=new a.RTFParser(b.evaluator)};a.LessonParser.prototype.parseButtonsConfig=
function(a){var b={rowsNorth:0,rowsSouth:0,widthEast:125,widthWest:125,height:23};a=this.split(a);for(var c=0,e=a.length;c<e;c++)switch(t=a[c][0],m=a[c][1],r=d[t],r){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[r]=parseInt(m);break;case "about":case "config":case "init":case "clear":b[r]="true"===d[m];break;default:console.log("----- attributo de space no identificado: <"+t+"> valor: <"+m+"> -----")}return b};a.LessonParser.prototype.parseSpace=function(b){v=
{};b=this.split(b);for(var c=0,e=b.length;c<e;c++)switch(t=b[c][0],m=b[c][1],r=d[t],r){case "type":case "id":case "cID":case "file":v[r]=m;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":v[r]="true"===d[m];break;case "bg_display":case "render":v[r]=d[m];break;case "net":case "net10":case "axes":case "text":v[r]="false"===d[m]?"":new a.Color(m,this.parent.evaluator);break;case "x_axis":case "y_axis":v[r]="false"===d[m]?"":m;break;case "O.x":v.OxExpr=m;break;
case "O.y":v.OyExpr=m;break;case "image":v.imageSrc=m;break;case "x":s=m;s="%"===s[s.length-1]?(this.parent.container.width*parseFloat(s)/100).toString():m;v.xExpr=this.parser.parse(s);break;case "y":s=m;s="%"===s[s.length-1]?(this.parent.container.height*parseFloat(s)/100).toString():m;v.yExpr=this.parser.parse(s);break;case "width":s=m;"%"===s[s.length-1]?(v.wExpr=s,s=this.parent.container.width*parseFloat(s)/100):(s=parseFloat(m),s!=m&&(s=this.parent.container.width));v.w=s;break;case "height":s=
m;"%"===s[s.length-1]?(v.hExpr=s,s=this.parent.container.height*parseFloat(s)/100):(s=parseFloat(m),s!=m&&(s=this.parent.container.height));v.h=s;break;case "drawif":v.drawif=this.parser.parse(m);break;case "scale":s=parseFloat(m);isNaN(s)&&(s=48);v.scale=s;break;case "background":v.background=new a.Color(m,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+t+"> valor: <"+m+"> -----")}switch(v.type){case "R2":return new a.Space2D(this.parent,v);case "R3":return new a.Space3D(this.parent,
v);case "AP":return new a.SpaceAP(this.parent,v);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,v);default:return new a.Space2D(this.parent,v)}};a.LessonParser.prototype.parseControl=function(b){l={type:"numeric"};b=this.split(b);for(var c=0,e=b.length;c<e;c++)switch(t=b[c][0],m=b[c][1],r=d[t],r){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":l[r]=m;break;
case "gui":case "region":case "action":case "msg_pos":case "poster":l[r]=d[m];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":l[r]="true"===d[m];break;case "color":case "colorInt":case "trace":l[r]=new a.Color(m,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":l[r]=this.parser.parse(m);break;case "constraint":l.constraintExpr=m;break;case "image":l.imageSrc=
m;break;case "space":l.spaceID=m;break;case "type":l.type=d[m.trim()];break;case "expresion":l.expresion=this.parser.parse(m.replace(")(",","));break;case "bold":"false"!=d[m]&&(l.bold="bold");break;case "italics":"false"!=d[m]&&(l.italics="italic");break;case "underlined":"false"!=d[m]&&(l.underlined=!0);break;case "value":var g=m.replace(/&squot;/g,"'");g.match(/^\|/)&&(g="'"+g.substring(1),g.match(/\|$/)&&(g=g.substring(0,g.length-1)+"'"));l.valueExpr=this.parser.parse(g);l.valueExprString=g;break;
case "incr":0!=m&&(l.incr=this.parser.parse(m));break;case "exponentialif":l.exponentialif=parseFloat(m);break;case "text":l.rawText=m;for(var g=this.parseText(m),f=0,h=g.length;f<h;f++)g[f]=this.parser.parse(g[f],!1);l.text=g;break;default:f=t.indexOf(".");g=d[t.substring(0,f)];f=d[t.substring(f+1)];if("parameter"===g&&"font"===f){l.parameterFont=m;break}else if("Explanation"===g&&"font"===f){l.ExplanationFont=m;break}else if("tooltip"===g&&"font"===f){l.tooltipFont=m;break}console.log("----- attributo de control no identificado: <"+
t+"> valor: <"+m+"> -----")}if("numeric"===l.type)switch(l.gui){case "spinner":return new a.Spinner(this.parent,l);case "button":return new a.Button(this.parent,l);case "textfield":return new a.TextField(this.parent,l);case "menu":return new a.Menu(this.parent,l);case "scrollbar":return new a.Scrollbar(this.parent,l);default:return new a.Spinner(this.parent,l)}else{if("video"===l.type)return new a.Video(this.parent,l);if("audio"===l.type)return new a.Audio(this.parent,l);if("graphic"===l.type)return new a.GraphicControl(this.parent,
l);if("text"===l.type)return new a.TextArea(this.parent,l)}};a.LessonParser.prototype.parseGraphic=function(b,c,e,g){u={rotateExp:g,parameter:"t"};b=this.split(b);g=0;for(var f=b.length;g<f;g++)switch(t=b[g][0],m=b[g][1],r=d[t],r){case "type":case "align":u[r]=d[m];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":u[r]="true"===d[m];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":u[r]="false"===d[m]?"":new a.Color(m,
this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":u[r]=m;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "init":case "end":case "opacity":case "inirot":case "inipos":case "range":u[r]=this.parser.parse(m);break;case "space":u.spaceID=m;break;case "expresion":"macro"!=u.type?(u.expresion=this.parser.parse(m),u.expresionString=m):u.expresion=m;break;case "text":u.text=this.parseText(m);break;case "file":var h=
m.replace(/&squot;/g,"'");"["===h.charAt(0)&&"]"===h.charAt(h.length-1)&&(h=h.substring(1,h.length-1));h.match(z)&&(h="'"+h+"'");u.file=this.parser.parse(h);break;case "border":"false"!=d[m]&&(u.border=new a.Color(m,this.parent.evaluator));break;default:if(void 0!=u.family&&t.substring(0,u.family.length+1)===u.family+"."){switch(d[t.substring(u.family.length+1)]){case "interval":u.family_interval=this.parser.parse(m);break;case "steps":u.family_steps=this.parser.parse(m)}break}if(void 0!=u.parameter&&
t.match(u.parameter+".")){u.parameter!==t.substring(0,t.indexOf(u.parameter)+u.parameter.length)&&(u.parameter=t.substring(0,t.indexOf(u.parameter)+u.parameter.length));switch(d[t.substring(u.parameter.length+1)]){case "interval":u.parameter_interval=this.parser.parse(m);break;case "steps":u.parameter_steps=this.parser.parse(m)}break}console.log("----- attributo del graphic no identificado: <"+t+"> valor: <"+m+"> -----")}c&&(u.abs_coord=c);e&&(u.background=e);switch(u.type){case "text":return new a.Text(this.parent,
u);case "image":return new a.Image(this.parent,u);case "point":return new a.Point(this.parent,u);case "polygon":return new a.Polygon(this.parent,u);case "arc":return new a.Arc(this.parent,u);case "segment":return new a.Segment(this.parent,u);case "arrow":return new a.Arrow(this.parent,u);case "macro":return new a.Macro(this.parent,u);case "curve":return new a.Curve(this.parent,u);case "equation":return new a.Equation(this.parent,u);case "sequence":return new a.Sequence(this.parent,u);case "fill":return new a.Fill(this.parent,
u)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,e,g){u={rotateExp:g,parameter:"t"};b=this.split(b);c=0;for(e=b.length;c<e;c++)switch(t=b[c][0],m=b[c][1],r=d[t],r){case "type":case "model":u[r]=d[m];break;case "background":case "fixed":case "edges":u[r]="true"===d[m];break;case "color":case "backcolor":u[r]=new a.Color(m,this.parent.evaluator);break;case "type":case "model":u[r]=d[m];break;case "background":case "fixed":case "edges":case "split":u[r]="true"===d[m];break;case "color":case "backcolor":u[r]=
new a.Color(m,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":u[r]=this.parser.parse(m);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":u[r]=m;break;case "space":u.spaceID=m;break;case "expresion":"macro"!=u.type&&"curve"!=u.type&&"surface"!=u.type?(u.expresion=this.parser.parse(m),u.expresionString=m):u.expresion=m.replace(/\\n/g," ").replace(/;/g," ");break;
case "text":g=this.parseText(m);for(var f=0,h=g.length;f<h;f++)g[f]=this.parser.parse(g[f],!1);u.text=g;break;case "file":g=m.replace(/&squot;/g,"'");"["===g.charAt(0)&&"]"===g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/./)&&(g="'"+g+"'");u.file=this.parser.parse(g);break;case "drawif":case "width":case "length":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":u[r]=this.parser.parse(m);break;case "family":case "parameter":case "font":case "name":u[r]=
m;break;case "space":u.spaceID=m;break;case "expresion":"macro"!=u.type&&"curve"!=u.type&&"surface"!=u.type?(u.expresion=this.parser.parse(m),u.expresionString=m):u.expresion=m;break;case "text":g=this.parseText(m);f=0;for(h=g.length;f<h;f++)g[f]=this.parser.parse(g[f],!1);u.text=g;break;case "file":g=m.replace(/&squot;/g,"'");"["===g.charAt(0)&&"]"===g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/./)&&(g="'"+g+"'");u.file=this.parser.parse(g);break;default:if(void 0!==u.family&&t.substring(0,
u.family.length+1)===u.family+"."){"interval"===d[t.substring(u.family.length+1)]?u.family_interval=this.parser.parse(m):u.family_steps=this.parser.parse(m);break}console.log("----- attributo del graphic3D no identificado: <"+t+"> valor: <"+m+"> -----")}switch(u.type){case "point":return new a.Point3D(this.parent,u);case "segment":return new a.Segment3D(this.parent,u);case "polygon":return new a.Polygon3D(this.parent,u);case "curve":return new a.Curve3D(this.parent,u);case "triangle":return new a.Triangle3D(this.parent,
u);case "face":return new a.Face3D(this.parent,u);case "polireg":return new a.Polireg3D(this.parent,u);case "surface":return new a.Surface3D(this.parent,u);case "text":return new a.Text3D(this.parent,u);case "cube":case "box":case "tetrahedron":case "octahedron":case "sphere":case "dodecahedron":case "icosahedron":case "ellipsoid":case "cone":case "cylinder":case "mesh":return new a.OtherGeometry(this.parent,u);case "macro":return new a.Macro3D(this.parent,u);default:console.log(u.type)}};a.LessonParser.prototype.parseAuxiliar=
function(b){w={};b=this.split(b);for(var c=0,e=b.length;c<e;c++)b[c][1]=b[c][1].replace(/&squot;/g,"'");c=0;for(e=b.length;c<e;c++)switch(t=b[c][0],m=b[c][1],r=d[t],r){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":w[r]=m.replace(/&squot;/g,"'");break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":w[r]="true"===d[m];break;case "size":case "rows":case "columns":w[r]=
this.parser.parse(m);break;case "evaluate":case "execution":case "msg_pos":case "action":w[r]=d[m];break;default:var g=t.indexOf("."),f=d[t.substring(0,g)],g=d[t.substring(g+1)];if("parameter"===f&&"font"===g){w.parameterFont=m;break}console.log("----- attributo de auxiliar no identificado: <"+t+"> valor: <"+m+"> -----")}w.sequence?new a.Function(this.parent,w):w.constant?(b=new a.Constant(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.algorithm&&w.evaluate?(b=
new a.Algorithm(this.parent,w),this.parent.auxiliaries.push(b)):w.array&&!w.matrix&&")"!=w.id.charAt(w.id.length-1)?(b=new a.Vector(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.matrix&&")"!=w.id.charAt(w.id.length-1)?(b=new a.Matrix(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.event&&")"!=w.id.charAt(w.id.length-1)?this.parent.events.push(new a.Event(this.parent,w)):")"===w.id.charAt(w.id.length-1)?new a.Function(this.parent,
w):new a.Variable(this.parent,w)};a.LessonParser.prototype.parseAction=function(b){C=b.action;A=b.parent;E=b.parameter;if(C)switch(C){case "message":return new a.Message(A,E);case "calculate":return new a.Calculate(A,E);case "openURL":return new a.OpenURL(A,E);case "openScene":return new a.OpenScene(A,E);case "about":return new a.About(A,E);case "config":return new a.Config(A,E);case "init":return new a.Init(A,E);case "clear":return new a.Clear(A,E);case "animate":return new a.Animate(A,E);case "initAnimation":return new a.InitAnimation(A,
E);case "playAudio":return new a.PlayAudio(A,E);default:console.log("----- Accion no soportada aun: <"+C+"> -----")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(b){var c={};b=this.split(b);for(var e=0,g=b.length;e<g;e++)switch(t=b[e][0],m=b[e][1],r=d[t],r){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[r]=m.replace(/&squot;/g,"'");break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[r]="true"===d[m];break;default:console.log("----- attributo de la animacion no identificado: <"+
t+">  <"+m+"> -----")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(d,l){d=this.split(d);f=h="";b=0;c="#536891";p="white";e="left";g="";n="SansSerif,BOLD,20";q="SansSerif,PLAIN,18";k=void 0;for(var s=0,r=d.length;s<r;s++)switch(t=d[s][0],m=d[s][1],t){case "title":h=m;break;case "subtitle":f=m;break;case "subtitlines":b=m;break;case "bgcolor":""!=m&&(c=(new a.Color(m,this.parent.evaluator)).getColor());break;case "fgcolor":""!=m&&(p=(new a.Color(m,this.parent.evaluator)).getColor());
break;case "align":""!=m&&(e=m);break;case "titleimage":g=m;break;case "titlefont":n=""!=m?a.convertFont(m):a.convertFont(n);break;case "subtitlefont":q=""!=m?a.convertFont(m):a.convertFont(q);break;default:console.log("----- attributo de la pleca no identificado: <"+t+">  <"+m+"> -----")}if(""===h&&""===f)return document.createElement("div");I=q.substring(0,q.indexOf("px"));I=I.substring(I.lastIndexOf(" "));""!=g&&(x=this.parent.getImage(g),L=x.height);k=document.createElement("div");k.setAttribute("id",
"descartesPleca");L?(k.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+e+"; width: "+(l-30)+"px; height: "+(L-16)+"px; background: "+c+"; color: "+p+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),x.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),k.appendChild(x)):k.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+
e+"; width: "+(l-30)+"px; background: "+c+"; color: "+p+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");D=document.createElement("div");D.setAttribute("style","padding: 0px; margin: 0px; font: "+n+"; overflow: hidden; white-space: nowrap;");D.innerHTML=h;J=document.createElement("div");if(1===parseInt(b)){P=0;M=document.createElement("div");M.innerHTML=f;document.body.appendChild(M);R=I;do R-=P,M.setAttribute("style","padding: 0px; margin: 0px; font: "+
q+"; font-size: "+R+"px; width: "+(l-30)+"px; line-height: "+R+"px;"),O=M.offsetHeight,S=O/R,P=1;while(1<S&&8<R);document.body.removeChild(M);J.setAttribute("style","padding: 0px; margin: 0px; font: "+q+"; font-size: "+R+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else J.setAttribute("style","padding: 0px; margin: 0px; font: "+q+"; line-height: 110%;");J.innerHTML=f;k.appendChild(D);k.appendChild(J);k.imageHeight=L;return k};a.LessonParser.prototype.split=function(a){if("string"!=
typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");F=[];y=B=0;G=!1;H=0;for(K=!1;B<a.length;)" "!==a.charAt(B)||G||B++," "===a.charAt(B)||G||(G=!0,H=B),"="!==a.charAt(B)||("'"!==a.charAt(B+1)||K)||(K=!0,F[y]=[a.substring(H,B)],H=B+2,B+=2),K&&"'"===a.charAt(B)&&(G=K=!1,F[y].push(a.substring(H,B)),y++),"="!==a.charAt(B)||("'"===a.charAt(B+1)||K)||(F[y]=[a.substring(H,B)],H=B+1,B++,Q=a.substring(B).indexOf("="),-1===Q?N=Q=a.length:(Q+=B,N=a.substring(B,Q).lastIndexOf(" "),N=-1===N?a.length:N+B),F[y].push(a.substring(H,
N)),y++,G=!1,B=N),B++;return F};a.LessonParser.prototype.parseText=function(b){return b.match(/^\{\\rtf1/)?this.RTFparser.parse(b.substring(10)):new a.SimpleText(this.parent,b)};return a}(descartesJS||{},babel),descartesJS=function(a){function d(a,b){t=[];t.type="matrix";t.rows=a;t.cols=b;var c;v=0;for(l=b;v<l;v++){c=[];m=0;for(u=a;m<u;m++)c.push(0);t[v]=c}return t}function h(a,b){s=a.rows;r=a.cols;t=d(s,r);var c;for(v=0;v<s;v++)for(m=0;m<r;m++){for(l=c=0;l<r;l++)c+=a[l][v]*b[m][l];t[m][v]=c}return t}
function f(a,b,c){for(var e=d(c.length-1,c.length-1),g=0,f=e.length;g<f;g++)for(var h=0;h<f;h++)e[g][h]=g<a?h<b?c[g][h]:c[g][h+1]:g<b?c[g+1][h]:c[g+1][h+1];return e}function b(a){if(1<a.cols){for(var c=0,e=1,d=0,g=a.cols;d<g;d++)c+=e*a[0][d]*b(f(0,d,a)),e=-e;return c}return a[0][0]}if(a.loadLib)return a;var c,p={},e=Math.floor,g,n,q,k;a.fullDecimals=!1;a.Node=function(a,b){this.sep="";this.type=a;this.value=b;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){g=this.childs.length-1;lastChild=this.childs[g];lastChild.parent=null;this.childs[g]=a;a.parent=this;return a};a.Node.prototype.contains=function(a){if(this.value===a)return!0;for(var b=0,c=this.childs.length;b<c;b++)if(this.childs[b].contains(a))return!0;return!1};a.Node.prototype.equalToMinus=function(){return"compOperator"===this.type?(this.type="operator",
this.value="-",q=new a.Node("compOperator","=="),k=new a.Node("number","0"),q.addChild(this),q.addChild(k),n=this.getRoot(),n.setAllEvaluateFunction(),n):this};a.Node.prototype.setAllEvaluateFunction=function(){this.setEvaluateFunction();for(var a=0,b=this.childs.length;a<b;a++)this.childs[a].setAllEvaluateFunction()};a.Node.prototype.setEvaluateFunction=function(){if("number"===this.type)this.evaluate=function(a){return parseFloat(this.value)};else if("string"===this.type)this.evaluate=function(a){return this.value};
else if("identifier"===this.type&&0===this.childs.length)if("rnd"==this.value)this.evaluate=function(a){return Math.random()};else{var a;this.evaluate=function(b,c){a=b.variables[this.value];if("object"===typeof a)return a.evaluate(b);void 0==a&&(c||b.matrices[this.value])&&(a=b.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 g,n;this.evaluate=function(a){g=this.childs[0].childs[0].evaluate(a);
try{return n=a.vectors[this.value][0>g?0:e(g)],void 0!==n?n:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var k,q;this.evaluate=function(a){k=this.childs[0].childs[0].evaluate(a);q=this.childs[0].childs[1].evaluate(a);try{return n=a.matrices[this.value][0>k?0:e(k)][0>q?0:e(q)],void 0!==n?n:0}catch(b){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var l;this.evaluate=function(a){l=[];
for(var b=0,e=this.childs[0].childs.length;b<e;b++)l[b]=this.childs[0].childs[b].evaluate(a);return"_Eval_"===this.value?(l[0]=0<l.length?l[0].toString():"",c=l[0].replace(a.parent.decimal_symbol_regexp,"."),void 0==p[c]&&(p[c]=a.parser.parse(c)),a.evalExpression(p[c])):a.functions[this.value].apply(a,l)}}else if("operator"===this.type){var u,y,G;"+"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);y=this.childs[1].evaluate(a,!0);if("matrix"!==u.type||"matrix"!==y.type)return u+
y;a=u;var b=y;s=a.rows;r=a.cols;t=d(s,r);for(v=0;v<s;v++)for(m=0;m<r;m++)t[m][v]=a[m][v]+b[m][v];return t}:"-"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);y=this.childs[1].evaluate(a,!0);if("matrix"!==u.type||"matrix"!==y.type)return u-y;a=u;var b=y;s=a.rows;r=a.cols;t=d(s,r);for(v=0;v<s;v++)for(m=0;m<r;m++)t[m][v]=a[m][v]-b[m][v];return t}:"*"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);y=this.childs[1].evaluate(a,!0);return"matrix"!==u.type||
"matrix"!==y.type?u*y:h(u,y)}:"/"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);y=this.childs[1].evaluate(a,!0);if("matrix"!==u.type||"matrix"!==y.type)return u/y;a=u;var c;c=y;var e=d(c.length,c.length),g=b(c);if(0===g)c=0;else{var g=1/g,n;if(1<c.length)for(var k=0,m=c.length;k<m;k++){n=g;for(var q=0;q<m;q++)e[q][k]=n*b(f(k,q,c)),n=-n;g=-g}else e[0][0]=g;c=e}a=0===c?d(a.rows,a.cols):h(a,c);return a}:"%"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a);
y=this.childs[1].evaluate(a);return u-e(u/y)*y}:"^"===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(u=this.childs[0].evaluate(a)?1:0)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?
this.evaluate=function(a){return(u=this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){u=this.childs[0].evaluate(a)?1:0;return!u+0});else if("conditional"===this.type)this.evaluate=function(a){u=this.childs[0].evaluate(a);return 0<u?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,b){return this.childs[0].evaluate(a,b)};else if("(expr)"===this.type||"[expr]"===this.type){var H,K;this.evaluate=function(a){H=this.childs.length;G=[];if(1===H&&1===this.childs[0].childs.length&&"(expr)"===this.type)G=this.childs[0].childs[0].evaluate(a);else for(var b=0;b<H;b++){K=[];for(var c=0,e=this.childs[b].childs.length;c<e;c++)K.push(this.childs[b].childs[c].evaluate(a));G[b]=K}return G}}else if("asign"===this.type){var I,x,L,D,J,
M;this.evaluate=function(a){I=this.childs[0];x=this.childs[1];1===I.childs.length&&"square_bracket"===I.childs[0].type?(g=I.childs[0].childs,1===g.length?(L=g[0].evaluate(a),L=0>L?0:e(L),a.vectors[I.value][L]=x.evaluate(a)):2===g.length&&(D=g[0].evaluate(a),J=g[1].evaluate(a),D=0>D?0:e(D),J=0>J?0:e(J),a.matrices[I.value][D]||(a.matrices[I.value][D]=[]),a.matrices[I.value][D][J]=x.evaluate(a))):(M=x.evaluate(a),M.type?a.matrices[I.value]=M:"object"!==typeof a.variables[I.value]&&(a.variables[I.value]=
M))}}};var s,r,t,m,v,l,u;a.Node.prototype.toString=function(){var a="tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:"");for(var b=0,c=this.childs.length;b<c;b++)a+=this.sep+this.childs[b].toString();return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p,e,g,n,q=/^\s+/,k=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,s=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,r=/^==|^!=|^<=|^<|^>=|^>|^#/,
t=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,m=/^=/,v=/^[\?\:]/,l=/^[\+\-\*\/\%\^]/,u=/^\[|^\]/,w=/^\(|^\)/,z=/^,/,C=/^;/,A=/\|/g,E=/\|\*/g,F=/\*\|/g;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function y(a,c,e){h.push({type:a,value:c});p=p.slice(e);b+=e;g++;n=a}if(d=a){a=a.replace(/\\u(\S+) /g,function(a,b){return String.fromCharCode(parseInt(b,16))});a=a.replace(/\&sup(.+);/g,"^ $1 ");a=a.replace(/&squot;/g,"'");a.match(/\=\|\*/g)&&(a=a.replace(E,"'").replace(F,"'"));a.match(/\=\|/g)&&
(a=a.replace(A,"'"));var B=a.trim();"|"==B.charAt(0)&&"|"==B.charAt(B.length-1)&&(a=B.replace(A,"'"))}h=[];f=!1;b=0;p=a;g=0;for(n="";a&&b<a.length;)if(f=b,"'"==p[0]){for(e=1;"'"!=p[e];)if(e<p.length)e++;else{console.log(">Error, unknown symbol: ["+p+"], in the string <<"+d+">>");return}c=p.substring(1,e);y("string",c,c.length+2)}else if(c=p.match(q))p=p.slice(c[0].length),b+=c[0].length,g++;else if(c=p.match(k))"number"===n&&h.push({type:"operator",value:"*"}),y("identifier",c[0],c[0].length);else if(c=
p.match(s))y("number",c[0],c[0].length);else if(c=p.match(r))B=c[0],"#"==B&&(B="!="),y("compOperator",B,c[0].length);else if(c=p.match(t))B=c[0],"||"==B?B="|":"&&"==B?B="&":"~"==B&&(B="!"),y("boolOperator",B,c[0].length);else if((c=p.match(m))&&!p.match(/^==/))y("asign",c[0],c[0].length);else if(c=p.match(v))y("conditional",c[0],c[0].length);else if(c=p.match(l))y("operator",c[0],c[0].length);else if(c=p.match(u))y("square_bracket",c[0],c[0].length);else if(c=p.match(w))"("==c&&"number"===n&&h.push({type:"operator",
value:"*"}),y("parentheses",c[0],c[0].length);else if(c=p.match(z))y("separator",c[0],c[0].length);else if(178===p.charCodeAt(0))h.push({type:"operator",value:"^"}),y("number",2,1);else if(179===p.charCodeAt(0))h.push({type:"operator",value:"^"}),y("number",3,1);else if(c=p.match(C))y("final_of_expresion",c[0],c[0].length);else if(f==b){console.log("Error, simbolo no conocido: ["+p+"], en la cadena <<"+d+">>");return}return h};var B,y=/rnd|pi|e|Infinity|-Infinity|sqr|sqrt|ra\u00edz|exp|log|log10|abs|ent|sgn|ind|sin|sen|cos|tan|cot|sec|csc|sinh|senh|cosh|tanh|coth|sech|csch|asin|asen|acos|atan|min|max/;
a.Tokenizer.prototype.flatTokens=function(a,b){a=a||[];b=b||"";B="";for(var c=0,e=a.length;c<e;c++)B="string"==a[c].type?B+"&squot;"+a[c].value+"&squot;":"identifier"!=a[c].type||a[c].value.match(y)?B+a[c].value:B+b+a[c].value;return B};return a}(descartesJS||{}),descartesJS=function(a){function d(a){return isNaN(parseFloat(a))?a.replace(/^\s|\s$/g,"").replace(/^'|'$/g,""):parseFloat(a)}if(a.loadLib)return a;a.Parser=function(b){this.evaluator=b;this.tokenizer=new a.Tokenizer;this.vectors={};this.matrices=
{};this.variables={};this.functions={};this.registerDefaultValues()};a.Parser.prototype.setVariable=function(a,b){this.variables[a]=b};a.Parser.prototype.getVariable=function(a){return this.variables[a]};a.Parser.prototype.setVector=function(a,b,c){this.vectors[a][b]=c};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,b,c,e){this.matrices[a][b][c]=e};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,b){this.functions[a]=b};a.Parser.prototype.getFunction=function(a){this.functions.hasOwnProperty(a)||(this.functions[a]=function(){return 0});return this.functions[a]};var h,f,b,c,p,e,g,n,q,k,s,r;a.Parser.prototype.parse=function(d,m){(b=this.tokenizer.tokenize(d))||(b=[]);c=null;m=!m||!1;h=n=g=e=0;for(f=b.length;h<f;h++)if(q=b[h],k=q.value,s=q.type,"identifier"===s&&(h+1<f&&"parentheses"===
b[h+1].type&&"("===b[h+1].value?this.getFunction(k):h+1<f&&"square_bracket"===b[h+1].type&&"["===b[h+1].value?b[h+3]&&"square_bracket"===b[h+3].type&&"]"===b[h+3].value?this.getVector(k):this.getMatrix(k):this.getVariable(k)),"asign"===s&&m&&(s="compOperator",k="=="),"asign"===s)if(p=new a.Node(s,k),null!=c)if("identifier"===c.type)c.parent&&c.parent.replaceLastChild(p),p.addChild(c),c=p,m=!0;else if("square_bracket"===c.type)p.addChild(c.parent),c=p,m=!0;else{p.type="compOperator";p.value="==";for(m=
!0;c.parent&&this.getPrecedence(c.parent.value)>=this.getPrecedence(p.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(p);p.addChild(c);c=p}else{console.log("Error1: en la expresion <<"+d+">>, en el token {valor: "+k+", tipo: "+s+"}");break}else if("parentheses"===s&&"("===k||"square_bracket"===s&&"["===k)if(p=new a.Node(s,k),"("===k&&e++,"["===k&&g++,null===c)"("===k&&(new a.Node("(expr)","(expr)")).addChild(p),"["===k&&(new a.Node("[expr]","[expr]")).addChild(p),c=p;else if("operator"===c.type||
"boolOperator"===c.type||"compOperator"===c.type||"conditional"===c.type||"asign"===c.type)c.addChild(p),c=p;else if("sign"===c.type)c.addChild(p),c=p;else if("parentheses"===c.type&&"("===c.value)c.addChild(p),c=p;else if("square_bracket"===c.type&&"["===c.value)c.addChild(p),c=p;else if("parentheses"===c.type&&"()"===c.value)c.parent.addChild(p),c=p;else if("square_bracket"===c.type&&"[]"===c.value)c.parent.addChild(p),c=p;else if("identifier"===c.type)c.addChild(p),c=p;else{console.log("Error2: en la expresion <<"+
d+">>, en el token ["+h+"] {valor: "+k+", tipo: "+s+"}");break}else if("parentheses"===s&&")"===k)if(e--,null===c)console.log("Error3: en la expresion <<"+d+">>, en el token (valor:"+k+", tipo:"+s);else{for(;c&&c.parent&&"("!=c.value;)c=c.parent;if(c&&"("===c.value)c.value="()";else{console.log("Error4: en la expresion <<"+d+">>, en el token {valor: "+k+", tipo: "+s+"}");break}}else if("square_bracket"===s&&"]"===k)if(g--,null===c)console.log("Error5: en la expresion <<"+d+">>, en el token (valor:"+
k+", tipo:"+s);else{for(;c&&c.parent&&"["!=c.value;)c=c.parent;if(c&&"["===c.value)c.value="[]";else{console.log("Error6: en la expresion <<"+d+">>, en el token {valor: "+k+", tipo: "+s+"}");break}}else if("number"===s||"string"===s||"identifier"===s)if(p=new a.Node(s,k),null===c)c=p;else if("operator"===c.type||"compOperator"===c.type||"boolOperator"===c.type||"parentheses"===c.type&&"("===c.value||"square_bracket"===c.type&&"["===c.value||"sign"===c.type||"conditional"===c.type||"asign"===c.type)c.addChild(p),
c=p;else{console.log("Error7: en la expresion <<"+d+">>, en el token {valor: "+k+", tipo: "+s+"}");break}else if("operator"===s||"compOperator"===s||"boolOperator"===s)if(p=new a.Node(s,k),null===c)if("-"===k||"+"===k)p.type="sign",p.value="sign"+k,c=p;else if("!"===k)c=p;else{console.log("Error8: en la expresion <<"+d+">>, en el token {valor: "+k+", tipo: "+s+"}");break}else if("operator"===c.type||"compOperator"===c.type||"boolOperator"===c.type||"asign"===c.type||"conditional"===c.type||"square_bracket"===
c.type&&"["===c.value&&("-"===k||"+"===k||"!"===k)||"parentheses"===c.type&&"("===c.value&&("-"===k||"+"===k||"!"===k)){if("-"===k||"+"===k)p.type="sign",p.value="sign"+k;c.addChild(p);c=p}else if("number"===c.type||"parentheses"===c.type&&"()"===c.value||"square_bracket"===c.type&&"[]"===c.value||"string"===c.type||"identifier"===c.type||"conditional"===c.type||"asign"===c.type){for(;c.parent&&this.getPrecedence(c.parent.value)>=this.getPrecedence(p.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(p);
p.addChild(c);c=p}else{console.log("Error9: en la expresion <<"+d+">>, en el token {valor: "+k+", tipo: "+s+"}");break}else if("conditional"===s)if(p=new a.Node(s,k),null!=c)if("?"===p.value){for(n++;c.parent&&this.getPrecedence(c.parent.value)>this.getPrecedence(p.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(p);p.addChild(c);c=p}else{for(n--;c&&c.parent&&"?"!=c.value;)c=c.parent;if(c&&"?"===c.value)c.value="?:";else{console.log("Error10: en la expresion <<"+d+">>, en el token {valor: "+
k+", tipo: "+s+"}");break}}else{console.log("Error11: en la expresion <<"+d+">>, en el token {valor: "+k+", tipo: "+s+"}");break}else if("separator"===s)if(null!=c)for(;c.parent&&"("!=c.value&&"["!=c.value;)c=c.parent;else{console.log("Error12: en la expresion <<"+d+">>, en el token {valor: "+k+", tipo: "+s+"}");break}else{console.log("Error13: en la expresion <<"+d+">>, en el token {valor: "+k+", tipo: "+s+"}");break}0<e&&alert("Error, faltan parentesis por cerrar: "+d);0>e&&alert("Error, faltan parentesis por abrir: "+
d);0<g&&alert("Error, faltan square bracketss por cerrar: "+d);0>g&&alert("Error, faltan square bracketss por abrir: "+d);0!=n&&alert("Error, condicional incompleta: "+d);(r=c?c.getRoot():null)&&r.setAllEvaluateFunction();return r};a.Parser.prototype.getPrecedence=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 7;case "<":return 5;case "<=":return 5;case ">":return 5;case ">=":return 5;
case "==":return 5;case "!=":return 5;case "+":return 6;case "-":return 6;case "/":return 7;case "*":return 7;case "sign-":return 7;case "sign+":return 7;case "!":return 8;case "%":return 8;case "^":return 9;default:return 9}};a.Parser.prototype.registerDefaultValues=function(){function b(a,c){for(var e in c)c.hasOwnProperty(e)&&(a[e]=c[e])}this.variables.rnd=Math.random;this.variables.pi=a.returnValue(Math.PI);this.variables.e=a.returnValue(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._Num_=function(a){return"number"==typeof a?"NaN":parseFloat(a)==a?parseFloat(a):"NaN"};var c=this;this.functions._Trace_=function(a){console.log(a)};this.functions._Stop_Audios_=function(){c.evaluator.parent.stopAudios()};this.functions.esCorrecto=function(b,
e,d){return a.esCorrecto(b,e,c.evaluator,d)};this.functions.escorrecto=function(b,e,d){return a.escorrecto(b,e,c.evaluator,d)};window.parent!==window&&(this.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",name:a,value:b},"*");return 0},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*");return 0},this.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",name:a,value:b},"*");return 0});this.functions._GetValues_=
function(b,e){var d;if(b){d=(d=document.getElementById(b))&&"descartes/archivo"==d.type?d.text.replace(/&brvbar;/g,String.fromCharCode("166")):a.openExternalFile(b);var g=[],f=!1;if(d){d=d.replace(/\r/g,"").split("\n");for(var h=0,n=d.length;h<n;h++)d[h].match("<"+e+">")?(f=d[h].trim().split("<"+e+">"),2==f.length&&""!=f[1]&&(g=g.concat(f[1].split(String.fromCharCode("166")))),f=!0):d[h].match("</"+e+">")?(f=d[h].trim().split("</"+e+">"),2==f.length&&""!=f[0]&&(g=g.concat(f[0].split(String.fromCharCode("166")))),
f=!1):f&&(g=g.concat(d[h].split(String.fromCharCode("166"))));h=0;for(n=g.length;h<n;h++)f=g[h].split("="),f[0]=f[0].trim(),2==f.length&&""!=f[0]&&(isNaN(parseFloat(f[1]))?c.setVariable(f[0],f[1].replace(/^\s|\s$/g,"").replace(/^'|'$/g,"")):c.setVariable(f[0],parseFloat(f[1])))}return 0}};this.functions._GetMatrix_=function(b,e){var g;if(b){g=(g=document.getElementById(b))&&"descartes/archivo"==g.type?g.text.replace(/&brvbar;/g,String.fromCharCode("166")):a.openExternalFile(b);var f=[],h=!1;f.type=
"matrix";if(g){g=g.replace(/\r/g,"").split("\n");for(var n=0,k=g.length;n<k;n++)g[n].match("<"+e+">")?(h=g[n].trim().split("<"+e+">"),2==h.length&&""!=h[1]&&f.push(h[1].split(String.fromCharCode("166")).map(d)),h=!0):g[n].match("</"+e+">")?(h=g[n].trim().split("</"+e+">"),2==h.length&&""!=h[0]&&f.push(h[0].split(String.fromCharCode("166")).map(d)),h=!1):h&&f.push(g[n].split(String.fromCharCode("166")).map(d));c.matrices[e]=f;c.setVariable(e+".filas",f[0].length);c.setVariable(e+".columnas",f.length)}return 0}};
var e=document.createElement("a"),g;this.functions._Save_=function(a,b){document.body.appendChild(e);g=new Blob([b.replace(/\\n/g,"\n").replace(/\\q/g,"'")],{type:"text/plain"});e.setAttribute("download",a);e.setAttribute("href",window.URL.createObjectURL(g));e.click();document.body.removeChild(e);return 0};var f,h,n,k,q=document.createElement("input");q.setAttribute("type","file");onHandleFileSelect=function(b){f=b.target.files;h=new FileReader;h.onload=function(b){a.addExternalFileContent(f[0].name,
b.target.result);c.setVariable(n,f[0].name);c.getFunction(k)&&(c.getFunction(k).apply(c.evaluator,[]),c.evaluator.parent.update())};0<f.length&&h.readAsText(f[0])};q.addEventListener("change",onHandleFileSelect);this.functions._Open_=function(a,b){n=a;k=b;q.click();return 0};this.functions._SaveState_=function(){this.functions._Save_("state.txt",JSON.stringify({variables:this.variables,vectors:this.vectors,matrices:this.matrices}));return 0};var p,s,r=document.createElement("input");r.setAttribute("type",
"file");onHandleFileSelect2=function(a){a.stopPropagation();a.preventDefault();p=a.target.files;s=new FileReader;s.onload=function(a){var e={};try{e=JSON.parse(a.target.result)}catch(d){}e.variables&&b(c.variables,e.variables);e.vectors&&b(c.vectors,e.vectors);e.matrices&&b(c.matrices,e.matrices);c.evaluator.parent.update()};0<p.length&&s.readAsText(p[0])};r.removeEventListener("change",onHandleFileSelect2);r.addEventListener("change",onHandleFileSelect2);this.functions._OpenState_=function(){r.click();
return 0};this.functions._Rojo_=function(b){return(new a.Color(b)).r/255};this.functions._Verde_=function(b){return(new a.Color(b)).g/255};this.functions._Azul_=function(b){return(new a.Color(b)).b/255};this.functions._AnchoDeCadena_=function(b,c,e,d){return a.getTextWidth(b,a.convertFont(c+","+e+","+d))};this.functions._GetDay_=function(){return(new Date).getDate()};this.functions._GetMonth_=function(){return(new Date).getMonth()+1};this.functions._GetYear_=function(){return(new Date).getFullYear()};
this.functions._GetHours_=function(){return(new Date).getHours()};this.functions._GetMinutes_=function(){return(new Date).getMinutes()};this.functions._GetSeconds_=function(){return(new Date).getSeconds()};this.functions._MatrixToStr_=function(a){var b=this.matrices[a];if(b){strM="<"+a+">\\n";for(var c=0,e=b.rows;c<e;c++){for(var d=0,g=b.cols;d<g;d++)strM+=b[c][d]+(d<g-1?" "+String.fromCharCode("166")+" ":"");strM+="\\n"}return strM+="</"+a+">"}return""}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d=Math.floor;a.Evaluator=function(d){this.parent=d;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,d){this.variables[a]=d};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,f,b){f=0>f?0:d(f);this.vectors[a][f]=b};a.Evaluator.prototype.getVector=function(a,f){f=
0>f?0:d(f);return this.vectors[a][f]};a.Evaluator.prototype.setMatrix=function(a,f,b,c){f=0>f?0:d(f);b=0>b?0:d(b);this.matrices[a][f][b]=c};a.Evaluator.prototype.getMatrix=function(a,f,b){f=0>f?0:d(f);b=0>b?0:d(b);return this.matrices[a][f][b]};a.Evaluator.prototype.setFunction=function(a,d){this.functions[a]=d};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a){return a?a.evaluate(this):0};a.externalEvaluator=new a.Evaluator;return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d=2,h=!1,f;a.RTFNode=function(a,b,c,d){this.evaluator=a;this.type="rtfNode";this.value=b;this.nodeType=c;this.style=d;this.styleString=d.toString();this.color=d.textColor;this.underline=d.textUnderline;this.overline=d.textOverline;this.parent=null;this.children=[];switch(this.nodeType){case "textBlock":this.draw=this.drawTextBlock;break;case "textLineBlock":this.draw=this.drawTextLineBlock;break;case "formula":this.draw=this.drawFormula;break;
case "superIndex":this.draw=this.drawSuperIndex;break;case "subIndex":this.draw=this.drawSubIndex;break;case "dynamicText":this.draw=this.drawDynamicText;this.decimal_symbol=this.evaluator.parent.decimal_symbol;break;case "fraction":this.draw=this.drawFraction;break;case "numerator":case "denominator":this.draw=this.drawNumDen;break;case "radical":this.draw=this.drawRadical;break;case "limit":this.draw=this.drawLimit;break;case "integral":this.draw=this.drawIntegral;break;case "sum":this.draw=this.drawSum;
break;case "matrix":this.draw=this.drawMatrix;break;case "defparts":this.draw=this.drawDefparts;break;case "text":case "newLine":this.draw=this.drawText;break;case "hyperlink":this.draw=this.drawHyperlink;break;case "mathSymbol":this.draw=this.drawMathSymbol;break;case "index":case "radicand":case "from":case "to":case "what":case "element":this.draw=this.drawGenericBlock;break;case "componentNumCtrl":this.draw=this.drawComponentNumCtrl;break;case "componentSpace":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.children.push(a)};var b=0,c=0,p=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var e=0,g=this.children.length;e<g;e++)this.children[e].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 f=a.getFontMetrics(this.styleString);this.baseline=f.baseline;this.descent=f.descent;this.ascent=f.ascent;this.w=0;this.h=f.h}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);this.baseline=f.baseline;this.descent=f.descent;this.ascent=f.ascent;var e=this.value,q;"string"!=typeof this.value&&(g=void 0==this.decimals?
d:this.evaluator.evalExpression(this.decimals),q=void 0==this.fixed?h:this.fixed,e=this.evaluator.evalExpression(this.value,g,q),parseFloat(e).toString()===e.toString()&&(e=q?parseFloat(e).toFixed(g):a.removeNeedlessDecimals(parseFloat(e).toFixed(g)),e=(""+e).replace(".",this.decimal_symbol)),e+=" ");this.w=a.getTextWidth(e,this.styleString);this.h=f.h}else if("formula"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("hyperlink"===this.nodeType){e=
a.getFontMetrics(this.styleString);this.baseline=e.baseline;this.descent=e.descent;this.ascent=e.ascent;this.w=a.getTextWidth(this.value,this.styleString);this.h=e.h;this.clickCacher=document.createElement("div");this.clickCacher.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; cursor: pointer;");var k=this;this.clickCacher.addEventListener("click",function(a){k.click=!0;window.open(k.URL,k.URL)})}else if("superIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",
this.styleString),g=b,f=c,q=p,e=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=e.ascent,this.descent=e.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),e=q/2-f+this.h,this.superIndexPos=e-this.ascent,this.ascent=e,this.descent=f,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,f=c,q=p,e=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&
(this.ascent=e.ascent,this.descent=e.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),this.subIndexPos=f+1,this.ascent=g,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("fraction"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);var s=this.children[0],r=this.children[1],e=a.getFontMetrics(s.styleString);s.getBlockMetric();r.getBlockMetric();g=b;f=c;q=p;0>s.h&&(s.h=e.h,s.w=this.spaceWidth);0>r.h&&(r.h=
e.h,r.w=this.spaceWidth);this.h=s.h+r.h-1;this.ascent=s.h+Math.round(q/2)-f;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=Math.max(s.w,r.w)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator," ","radicand",f),this.children[1].addChild(this.children[0]),this.children[0]=new a.RTFNode(this.evaluator," ","index",f);else if("index"!==
this.children[0].nodeType||"radicand"!==this.children[1].nodeType){q=new a.RTFNode(this.evaluator,"","radicand",f);e=0;for(g=this.children.length;e<g;e++)q.addChild(this.children[e]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",f);this.children[1]=q}e=this.children[0];g=this.children[1];0>=e.children.length&&(f=this.style.clone(),f.fontSize=parseInt(f.fontSize-0.2*f.fontSize),e.addChild(new a.RTFNode(this.evaluator," ","text",f)));0>=g.children.length&&g.addChild(new a.RTFNode(this.evaluator,
" ","text",this.style.clone()));e.getBlockMetric();g.getBlockMetric();this.ascent=g.h/2<e.h?g.h/2+e.h+2-g.descent:g.ascent+4;this.descent=g.descent;this.baseline=this.ascent;this.h=this.ascent+this.descent;this.w=e.w+g.w+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,f=c,q=p,f=this.children[0],g=this.children[1],q=this.children[2],f.getBlockMetric(),g.getBlockMetric(),q.getBlockMetric(),-1==f.ascent&&(s=a.getFontMetrics(f.styleString),f.ascent=
s.ascent,f.descent=s.descent,f.h=s.h),-1==g.ascent&&(s=a.getFontMetrics(g.styleString),g.ascent=s.ascent,g.descent=s.descent,g.h=s.h),e=a.getFontMetrics(this.styleString),this.ascent=e.h+g.h>q.ascent?e.h-e.descent+g.h:q.ascent,this.descent=f.h>q.descent?f.h+e.descent:q.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,e=this.style.clone(),e.fontType="Times New Roman",e.Bold="bold",e=e.toString(),e=a.getTextWidth(String.fromCharCode(8721),e),this.w=Math.max(f.w,g.w,e)+Math.max(q.w,
this.spaceWidth)+this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,f=c,q=p,f=this.children[0],g=this.children[1],q=this.children[2],f.getBlockMetric(),g.getBlockMetric(),q.getBlockMetric(),-1==f.ascent&&(s=a.getFontMetrics(f.styleString),f.ascent=s.ascent,f.descent=s.descent,f.h=s.h),-1==g.ascent&&(s=a.getFontMetrics(g.styleString),g.ascent=s.ascent,g.descent=s.descent,g.h=s.h),e=a.getFontMetrics(this.styleString),this.ascent=e.h+g.h>q.ascent?
e.h-e.descent+g.h:q.ascent,this.descent=f.h>q.descent?f.h+e.descent:q.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,e=this.style.clone(),e.fontSize*=1.5,e.fontType="Times New Roman",e.Bold="bold",e=e.toString(),e=a.getTextWidth(String.fromCharCode(8747),e),this.w=Math.max(f.w,g.w,e)+Math.max(q.w,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,f=c,q=p,f=this.children[0],g=this.children[1],q=this.children[2],
e=a.getFontMetrics(this.styleString),f.getBlockMetric(),g.getBlockMetric(),q.getBlockMetric(),-1==f.ascent&&(s=a.getFontMetrics(f.styleString),f.ascent=s.ascent,f.descent=s.descent,f.h=s.h),-1==g.ascent&&(s=a.getFontMetrics(g.styleString),g.ascent=s.ascent,g.descent=s.descent,g.h=s.h),-1==q.ascent&&(s=a.getFontMetrics(q.styleString),q.ascent=s.ascent,q.descent=s.descent,q.h=s.h),this.ascent=q.ascent,this.descent=Math.max(e.h,q.descent),this.baseline=this.ascent,this.h=this.ascent+this.descent,e=a.getTextWidth(" "+
String.fromCharCode(8594),this.styleString),0==f.w&&(f.w=this.spaceWidth),0==g.w&&(g.w=this.spaceWidth),0==q.w&&(q.w=this.spaceWidth),this.w=g.w+f.w+q.w+e+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);e=a.getFontMetrics(this.styleString);g=b;f=c;q=p;q=e.ascent;for(var s=e.descent,r=e.h,t=this.spaceWidth,m,v,e=0,g=this.children.length;e<g;e++)this.children[e].getBlockMetric(),m=this.children[e].h,v=this.children[e].w,r<m&&(r=m,q=this.children[e].ascent,
s=this.children[e].descent),t<v&&(t=v);this.childWidth=t+2*this.spaceWidth;this.childh=r;this.childAscent=q;this.childDescent=s;this.h=this.rows*r;this.ascent=this.h/2+f;this.descent=this.h-this.ascent;this.w=this.columns*this.childWidth+this.spaceWidth}else if("defparts"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);e=a.getFontMetrics(this.styleString);g=b;f=c;q=p;q=e.ascent;s=e.descent;r=e.h;t=this.spaceWidth;e=0;for(g=this.children.length;e<g;e++)this.children[e].getBlockMetric(),
m=this.children[e].h,v=this.children[e].w,r<m&&(r=m,q=this.children[e].ascent,s=this.children[e].descent),t<v&&(t=v);this.childWidth=t+2*this.spaceWidth;this.childh=r;this.childAscent=q;this.childDescent=s;this.h=this.parts*r;this.ascent=this.h/2+f;this.descent=this.h-this.ascent;this.w=t+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),f=a.getFontMetrics(this.styleString),this.baseline=f.baseline,this.descent=f.descent,this.ascent=f.ascent,this.w=
a.getTextWidth(this.value,this.styleString)+this.spaceWidth,this.h=f.h):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),f=this.componentNumCtrl.h||0,this.baseline=Math.round(3*f/5),this.descent=Math.round(2*f/5),this.ascent=this.baseline,this.h=f,this.w=this.componentNumCtrl.w):"componentSpace"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentSpace=this.evaluator.parent.getSpaceByCId(this.value),
this.h=this.ascent=this.descent=this.baseline=0,this.w=this.componentSpace.w):console.log("Element i=unknown",this.nodeType)};a.RTFNode.prototype.getBlockMetric=function(){this.w=0;for(var a=-1,d=-1,f,h=0,k=this.children.length;h<k;h++){f=this.children[h];f.getTextMetrics();childAscent=f.ascent;childDescent=f.descent;this.w+=f.w;var s=childDescent;f=f.h;b=childAscent;c=s;p=f;d<childAscent&&(d=childAscent);a<childDescent&&(a=childDescent)}this.ascent=d;this.descent=a;this.baseline=this.ascent;this.h=
this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,b,c,q,k,p,r,t){f=t;this.stableWidth||(d=q,h=k,this.getTextMetrics());r=r?-this.children[0].ascent:0;k=q=0;for(p=this.children.length;k<p;k++)0<k&&(q+=this.children[k-1].h),this.children[k].draw(a,b+0,c+r+q)};a.RTFNode.prototype.drawTextLineBlock=function(a,b,c){for(var d=0,h=0,p=this.children.length;h<p;h++)a.strokeStyle=f,a.fillStyle=f,0<h&&(d+=this.children[h-1].w,"formula"==this.children[h-1].nodeType&&(d+=2*this.children[h-
1].spaceWidth)),this.children[h].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,c){for(var d=0,f=0,h=this.children.length;f<h;f++)0<f&&(d+=this.children[f-1].w),this.children[f].draw(a,b+this.spaceWidth+d,c)};a.RTFNode.prototype.drawText=function(a,b,c){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,c);if(this.underline){var d="bold"==this.style.textBold,f=d?1:0.5;a.lineWidth=d?
2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b-1,parseInt(c+this.descent/2)+f);a.lineTo(b-1+this.w,parseInt(c+this.descent/2)+f);a.stroke()}this.overline&&(f=(d="bold"==this.style.textBold)?2:1.5,a.lineWidth=d?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(b-1,parseInt(c-this.ascent)+f),a.lineTo(b-1+this.w,parseInt(c-this.ascent)+f),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,c,f){var q=Math.floor(0.5*this.spaceWidth),k=void 0==this.decimals?
d:this.evaluator.evalExpression(this.decimals),p=void 0==this.fixed?h:this.fixed,r=this.evaluator.evalExpression(this.value);parseFloat(r).toString()===r.toString()&&(r=p?parseFloat(r).toFixed(k):a.removeNeedlessDecimals(parseFloat(r).toFixed(k)),r=(""+r).replace(".",this.decimal_symbol));null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";this.w=a.getTextWidth(r,this.styleString);b.fillText(r,q+c,f);this.underline&&(p=(k="bold"==this.style.textBold)?
1:0.5,b.lineWidth=k?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(q+c-1,parseInt(f+this.descent/2)+p),b.lineTo(q+c-1+this.w,parseInt(f+this.descent/2)+p),b.stroke());this.overline&&(p=(k="bold"==this.style.textBold)?2:1.5,b.lineWidth=k?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(q+c-1,parseInt(f-this.ascent)+p),b.lineTo(q+c-1+this.w,parseInt(f-this.ascent)+p),b.stroke());this.w+=2*q};a.RTFNode.prototype.drawHyperlink=function(a,b,c){this.clickCacher.parentNode||
(a.canvas.nextSibling.className?a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling.nextSibling):a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling),this.clickCacher.style.left=b-2+"px",this.clickCacher.style.top=c-this.ascent-2+"px");a.save();this.click?(a.fillStyle="red",a.strokeStyle="red"):(a.fillStyle="blue",a.strokeStyle="blue");a.font=this.styleStr;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,c);var d="bold"==this.style.textBold,
f=d?1:0.5;a.lineWidth=d?2:1;a.beginPath();a.moveTo(b-1,Math.ceil(c+this.descent/2)+f-2);a.lineTo(b-1+this.w,Math.ceil(c+this.descent/2)+f-2);a.stroke();a.restore()};a.RTFNode.prototype.drawRadical=function(a,b,c){var d=Math.floor(this.spaceWidth);this.children[0].draw(a,b,Math.floor(c+this.children[1].descent-this.children[1].h/2-this.children[0].descent));this.children[1].draw(a,b+1.5*d+this.children[0].w,c);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b,Math.floor(c+
this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w,Math.floor(c+this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w+0.5*d,c+this.children[1].descent);a.lineTo(b+this.children[0].w+1*d,c-this.children[1].ascent);a.lineTo(b+this.children[0].w+2*d+this.children[1].w,c-this.children[1].ascent);a.stroke()};a.RTFNode.prototype.drawFraction=function(a,b,c){this.children[0].draw(a,b+(this.w-this.children[0].w)/2,c-this.ascent);this.children[1].draw(a,b+
(this.w-this.children[1].w)/2,c-this.ascent+this.children[0].h-1);var d=Math.floor(0.5*this.spaceWidth);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b+d,parseInt(c-this.ascent+this.children[0].h)-0.5);a.lineTo(b-d+this.w-1,parseInt(c-this.ascent+this.children[0].h)-0.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,b,c){for(var d=0,f=0,h=this.children.length;f<h;f++)0<f&&(d+=this.children[f-1].w),this.children[f].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawSubIndex=
function(a,b,c){for(var d=0,f=0,h=this.children.length;f<h;f++)0<f&&(d+=this.children[f-1].w),this.children[f].draw(a,b+d,c+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,c){for(var d=0,f=0,h=this.children.length;f<h;f++)0<f&&(d+=this.children[f-1].w),this.children[f].draw(a,b+d,c-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,c,d){var f=a.getFontMetrics(this.styleString),h=" "+String.fromCharCode(8594),p=a.getTextWidth(h,this.styleString);this.children[0].draw(b,
c,d+f.descent+this.children[0].ascent);this.children[1].draw(b,c+this.children[0].w+p,d+f.descent+this.children[1].ascent);this.children[2].draw(b,c+p+this.children[0].w+this.children[1].w,d);null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",c+this.children[0].w,d);b.fillText(h,c+this.children[0].w,d+f.descent+this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(b,c,d){var f=this.style.clone();f.fontSize*=
1.5;f.fontType="Times New Roman";f.Bold="bold";var f=f.toString(),h=a.getTextWidth(String.fromCharCode(8747),f),p=a.getFontMetrics(f),r=Math.max(this.children[0].w,this.children[1].w,Math.floor(1.5*h));this.children[0].draw(b,c+h,d+p.descent+this.children[0].ascent);this.children[1].draw(b,c+h+this.spaceWidth/2,d-this.ascent+this.children[1].ascent);this.children[2].draw(b,c+r+h,d);null!=this.color&&(b.fillStyle=this.color);b.font=f;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),
c,d+p.descent/2)};a.RTFNode.prototype.drawSum=function(b,c,d){var f=this.style.clone();f.fontType="Times New Roman";f.Bold="bold";var f=f.toString(),h=a.getTextWidth(String.fromCharCode(8721),f),p=a.getFontMetrics(this.styleString),r=Math.max(this.children[0].w,this.children[1].w,h);this.children[0].draw(b,c+(r-this.children[0].w)/2,d+p.descent+this.children[0].ascent);this.children[1].draw(b,c+(r-this.children[1].w)/2,d-p.ascent-this.children[1].descent);this.children[2].draw(b,c+r,d);null!=this.color&&
(b.fillStyle=this.color);b.font=f;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),c+Math.floor((r-h)/2),d-5)};a.RTFNode.prototype.drawMatrix=function(a,b,c){for(var d,f,h=0,p=this.children.length;h<p;h++)d=h%this.columns,f=Math.floor(h/this.columns),this.children[h].draw(a,2*this.spaceWidth+b+d*this.childWidth,c-this.ascent+this.childAscent+f*this.childh);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(b+this.spaceWidth)+
0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,c+this.descent+0.5);a.lineTo(Math.floor(b+this.spaceWidth)+0.5,c+this.descent+0.5);a.moveTo(Math.floor(b+this.w-this.spaceWidth)-0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/2)-0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/2)-0.5,c+this.descent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth)-0.5,c+this.descent+0.5);a.stroke()};
a.RTFNode.prototype.drawDefparts=function(a,b,c){for(var d=0,f=this.children.length;d<f;d++)this.children[d].draw(a,b+3*this.spaceWidth,c-this.ascent+this.childAscent+d%this.parts*this.childh);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(parseInt(b+2*this.spaceWidth)+0.5,c-this.ascent+0.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c-this.ascent+4.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-this.h/2-4.5);a.lineTo(b-0.5,c+this.descent-this.h/2);
a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-this.h/2+4.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-4.5);a.lineTo(parseInt(b+2*this.spaceWidth)+0.5,c+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawMathSymbol=function(a,b,c){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("(",b,c)):")"==this.value?(a.font=this.styleString,
a.textAlign="start",a.textBaseline="alphabetic",a.fillText(")",b+this.spaceWidth,c)):(a.font=this.styleString,a.textAlign="center",a.textBaseline="alphabetic",a.fillText(this.value,b+this.w/2,c))};a.RTFNode.prototype.drawGenericBlock=function(a,b,c){for(var d=0,f=0,h=this.children.length;f<h;f++)0<f&&(d+=this.children[f-1].w),this.children[f].draw(a,b+d,c)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,b,c){this.parent.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+
b+","+(c-this.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,b,c){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(b+"");this.componentSpace.yExpr=this.evaluator.parser.parse(c-this.parent.ascent+"")};a.RTFNode.prototype.draw=function(a,b,c){console.log(">>> Dibujo desconocido ",this.nodeType)};a.RTFNode.prototype.toHTML=function(){var a="";if("textLineBlock"===this.nodeType||"textBlock"===this.nodeType)for(var b=
0,c=this.children.length;b<c;b++)a+=this.children[b].toHTML();else"text"===this.nodeType?a="<span "+this.style.toCSS()+">"+this.value+"</span>":"newLine"===this.nodeType&&(a="<span "+this.style.toCSS()+">"+this.value+"<br /></span>");return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=String.fromCharCode,h,f,b,c,p,e,g,n,q,k,s;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=function(a){if(a)a=a.replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&quote;/g,
"''").replace(/\&squot;/g,"'").replace(/\\rquote /g,"'").replace(/\\endash /g,"-").replace(/\n/g," ").replace(/\r/g,"").replace(/\\uc(\d+) /g,"").replace(/\\uc(\d+)/g,"");else return[];h=[];f=a.length;h=[];b="";p=c=0;g=a.charAt(0);n=!1;for(q="text";c<f;)e=g,g=a.charAt(c+1),n?"\\"===g||"{"===g||"}"===g||" "===g||";"===g?(n=!1,b+=e," "===g&&(c++,g=a.charAt(c+1)),(k=b.match(/^\'([0-9a-f]{2})/))?(s="","text"===q&&(s=h.pop().value),b=s+=d(parseInt(k[1],16))+b.substring(3)):(k=b.match(/^u[0-9]+/))?(s="",
"text"===q&&(s=h.pop().value),b=s+=d(k[0].substring(1))):("{"===b||"}"===b?(h.push({type:"text",value:b}),q="text"):(h.push({type:"controlWord",value:b}),q="controlWord"),b="")):b+=e:"\\"===e?(n=!0,""!==b&&(h.push({type:"text",value:b}),q="text"),b=""):"{"===e?(p++,""!==b&&h.push({type:"text",value:b}),b="",h.push({type:"openBlock",value:p}),q="openBlock"):"}"===e?(""!==b&&h.push({type:"text",value:b}),b="",h.push({type:"closeBlock",value:p}),q="closeBlock",p--):b+=e,c++;""!==b&&h.push({type:"text",
value:b});return h};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p,e,g,n,q,k,s,r,t,m,v,l,u,w,z,C,A,E,F,B,y,G,H,K,I;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=new a.RTFTokenizer};a.RTFParser.prototype.parse=function(x){x=d=this.tokenizer.tokenize(x);for(var L=[],D=!1,J=!1,M=[],O=0,R=x.length;O<R;O++)if("openBlock"==x[O].type&&M.push(x[O].value),"closeBlock"==x[O].type&&(M.pop(),0>=M.length&&(D=!1)),"controlWord"!=x[O].type||"expr"!=x[O].value&&
"decimals"!=x[O].value||(J=!0),"controlWord"==x[O].type&&"mjaformula"==x[O].value&&(D=!0),"text"==x[O].type&&D&&!J){for(var S=0,P=x[O].value,Q="",N=0,V=P.length;N<V;N++)if("("==P.charAt(N)||")"==P.charAt(N)||"+"==P.charAt(N)||"-"==P.charAt(N)||"*"==P.charAt(N)||"="==P.charAt(N))Q=P.substring(S,N),""!=Q&&L.push({type:"text",value:Q}),L.push({type:P.charAt(N),value:P.charAt(N)}),S=N+1;Q=P.substring(S,N);""!=Q&&L.push({type:"text",value:Q})}else L.push(x[O]),"text"==x[O].type&&J&&(J=!1);d=L;h={};b=2;
if("openBlock"==d[0].type&&"fonttbl"==d[1].value){for(f=d[0].value;"closeBlock"!=d[b].type&&d[b].value!=f;)h[d[b].value]=d[b+2].value.substring(0,d[b+2].value.length-1),b+=3;b++}c={};p=0;if("openBlock"==d[b].type&&"colortbl"==d[b+1].value){f=d[b++].value;for(b++;"closeBlock"!=d[b].type&&d[b].value!=f;)e=parseInt(d[b++].value.substring(3)).toString(16),g=parseInt(d[b++].value.substring(5)).toString(16),n=parseInt(d[b++].value.substring(4)).toString(16),";"===d[b].value&&b++,c[p++]="#"+(2>e.length?
"0"+e:e)+(2>g.length?"0"+g:g)+(2>n.length?"0"+n:n);b++}q=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");k=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");q.addChild(k);t=r=s=null;z=w=u=l=v=m=!1;C=[new a.FontStyle(20,"Arial","","",!1,!1,null)];A=C[0];E=!0;B=F=-1;y=[];I=K=H=G=!1;x=b;for(L=d.length;x<L;x++)if("controlWord"==d[x].type&&h[d[x].value])A.fontType=h[d[x].value];else if("controlWord"==d[x].type&&d[x].value.match(/^fs(\d+)/))A.fontSize=parseInt(d[x].value.match(/^fs(\d+)/)[1]/
2);else if("controlWord"==d[x].type&&"b"==d[x].value)A.textBold="bold";else if("controlWord"==d[x].type&&"b0"==d[x].value)A.textBold="";else if("controlWord"==d[x].type&&"i"==d[x].value)A.textItalic="italic";else if("controlWord"==d[x].type&&"i0"==d[x].value)A.textItalic="";else if("controlWord"==d[x].type&&"ul"==d[x].value)A.textUnderline=!0;else if("controlWord"==d[x].type&&"ulnone"==d[x].value)A.textUnderline=!1;else if("controlWord"==d[x].type&&"ol"==d[x].value)A.textOverline=!0;else if("controlWord"==
d[x].type&&"olnone"==d[x].value)A.textOverline=!1;else if("controlWord"==d[x].type&&d[x].value.match(/^cf(\d+)/))A.textColor=c[parseInt(d[x].value.substring(2))],0<y.length&&(y[y.length-1].style.textColor=A.textColor);else if("openBlock"==d[x].type)F=d[x].value,A=A.clone(),C.push(A),y.push(null);else if("closeBlock"==d[x].type)d[x].value==B&&(B=-1,m=!1,k=k.parent),C.pop(),A=C[C.length-1],y.pop();else if("controlWord"==d[x].type&&"par"==d[x].value){k.addChild(new a.RTFNode(this.evaluator,"","newLine",
A.clone()));q=new a.RTFNode(this.evaluator,"","textLineBlock",A.clone());if("textBlock"!=k.nodeType)for(k=k.parent;"textBlock"!=k.nodeType;)k=k.parent;k.addChild(q);k=q}else if("controlWord"==d[x].type&&"mjaformula"==d[x].value)G=!0,B=F,m=!0,q=new a.RTFNode(this.evaluator,"","formula",A.clone()),k.addChild(q),k=q,y[y.length-1]=q;else if("controlWord"==d[x].type&&("fraction"==d[x].value||"radicand"==d[x].value||"radical"==d[x].value||"what"==d[x].value||"sum"==d[x].value||"integral"==d[x].value||"limit"==
d[x].value))D=y[y.length-2].style.clone(),q=new a.RTFNode(this.evaluator,"",d[x].value,D),y[y.length-2].addChild(q),y[y.length-1]=q;else if("controlWord"==d[x].type&&"index"==d[x].value||"to"==d[x].value||"from"==d[x].value)D=y[y.length-2].style.clone(),D.fontSize=parseInt(D.fontSize-0.2*D.fontSize),8>D.fontSize&&(D.fontSize=8),q=new a.RTFNode(this.evaluator,"",d[x].value,D),y[y.length-2].addChild(q),y[y.length-1]=q;else if("controlWord"==d[x].type&&("num"==d[x].value||"den"==d[x].value))D=y[y.length-
2].style.clone(),D.fontSize=Math.round(D.fontSize-0.1*D.fontSize),8>D.fontSize&&(D.fontSize=8),"num"==d[x].value?q=new a.RTFNode(this.evaluator,"","numerator",D):"den"==d[x].value&&(q=new a.RTFNode(this.evaluator,"","denominator",D)),y[y.length-2].addChild(q),y[y.length-1]=q;else if("controlWord"==d[x].type&&("subix"==d[x].value||"supix"==d[x].value))D=y[y.length-2].style.clone(),D.fontSize=Math.floor(D.fontSize-D.fontSize/3),8>D.fontSize&&(D.fontSize=8),"subix"==d[x].value?q=new a.RTFNode(this.evaluator,
"","subIndex",D):"supix"==d[x].value&&(q=new a.RTFNode(this.evaluator,"","superIndex",D)),q.originalStyle=y[y.length-2].style.clone(),y[y.length-2].addChild(q),y[y.length-1]=q;else if("controlWord"==d[x].type&&("defparts"==d[x].value||"matrix"==d[x].value||"element"==d[x].value))D=y[y.length-2].style.clone(),q=new a.RTFNode(this.evaluator,"",d[x].value,D),y[y.length-2].addChild(q),y[y.length-1]=q,"defparts"==d[x].value?t=q:"matrix"==d[x].value&&(r=q);else if("controlWord"==d[x].type&&"parts"==d[x].value)z=
!0;else if("text"==d[x].type&&z)t.parts=parseInt(d[x].value),z=!1;else if("controlWord"==d[x].type&&"rows"==d[x].value)u=!0;else if("text"==d[x].type&&u)r.rows=parseInt(d[x].value),u=!1;else if("controlWord"==d[x].type&&"columns"==d[x].value)w=!0;else if("text"==d[x].type&&w)r.columns=parseInt(d[x].value),w=!1;else if("controlWord"==d[x].type&&"expr"==d[x].value)E=!1,v=!0;else if("controlWord"==d[x].type&&"decimals"==d[x].value)l=!0;else if("text"==d[x].type&&l)s.decimals=this.evaluator.parser.parse(d[x].value+
""),l=!1;else if("controlWord"==d[x].type&&"fixed1"==d[x].value)s.fixed=!0;else if("controlWord"==d[x].type&&"fixed0"==d[x].value)s.fixed=!1;else if("controlWord"!=d[x].type||"component"!=d[x].value)if("controlWord"==d[x].type&&"NumCtrl"==d[x].value)H=!0;else if("controlWord"==d[x].type&&"Space"==d[x].value)K=!0;else if("controlWord"==d[x].type&&"hyperlink"==d[x].value)I=!0;else if("text"==d[x].type&&I){textContent=d[x].value.split("|")[0];D=A.clone();q=new a.RTFNode(this.evaluator,textContent,"hyperlink",
D);q.URL=d[x].value.split("|")[1];if("textLineBlock"!=k.nodeType)for(k=k.parent;"textLineBlock"!=k.nodeType;)k=k.parent;k.addChild(q);I=!1}else if("text"==d[x].type&&H)q=new a.RTFNode(this.evaluator,d[x].value,"componentNumCtrl",A.clone()),k.addChild(q),H=!1;else if("text"==d[x].type&&K)q=new a.RTFNode(this.evaluator,d[x].value,"componentSpace",A.clone()),k.addChild(q),K=!1;else if("text"==d[x].type&&v)D=y[y.length-2].style.clone(),textContent=this.evaluator.parser.parse(d[x].value),q=new a.RTFNode(this.evaluator,
textContent,"dynamicText",D),y[y.length-2].addChild(q),s=y[y.length-1]=q,v=!1;else if("text"==d[x].type&&!v&&!m){textContent=d[x].value;q=new a.RTFNode(this.evaluator,textContent,"text",A.clone());if("textLineBlock"!=k.nodeType)for(k=k.parent;"textLineBlock"!=k.nodeType;)k=k.parent;k.addChild(q)}else if("text"==d[x].type&&!v&&m)textContent=d[x].value,q=new a.RTFNode(this.evaluator,textContent,"text",y[y.length-1].style.clone()),y[y.length-1].addChild(q);else if("("==d[x].type||")"==d[x].type)D=y[y.length-
1].style.clone(),D.textItalic="",q=new a.RTFNode(this.evaluator,d[x].type,"mathSymbol",D),y[y.length-1].addChild(q);else if("+"==d[x].type||"-"==d[x].type||"*"==d[x].type||"="==d[x].type)q=new a.RTFNode(this.evaluator,d[x].type,"mathSymbol",y[y.length-1].style.clone()),y[y.length-1].addChild(q);if(null!=k){var U=k.getRoot();U.stableWidth=E;U.getTextMetrics();U.hasFormula=G}return U};a.FontStyle=function(a,b,c,d,f,e,g){this.fontSize=a;this.fontType=b;this.textItalic=c;this.textBold=d;this.textUnderline=
f;this.textOverline=e;this.textColor=g};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: "+this.fontSize+"px "+this.fontType+"; ";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)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b,c,p,e,g,n,q,k,s,r,t;a.Space=function(b,c){this.parent=b;h=this.evaluator=this.parent.evaluator;f=h.parser;this.id="";this.values=c;this.type="R2";this.xExpr=f.parse("0");this.yExpr=f.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=f.parse("1");this.fixed=2!=b.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"===b.code||b.arquimedes?new a.Color("f0f8fa"):new a.Color("ffffff");this.net=2!=b.version?new a.Color("c0c0c0"):"";this.net10=2!=b.version?new a.Color("808080"):"";this.axes=2!=b.version?new a.Color("808080"):"";this.text=new a.Color("ffafaf");this.numbers=!1;this.x_axis=2!=b.version?"":" ";this.y_axis=2!=b.version?"":" ";this.sensitive_to_mouse_movements=
!1;this.cID="";this.mouse_y=this.mouse_x=0;this.ctrs=[];this.graphicsCtr=[];this.graphics=[];this.backgroundGraphics=[];this.zIndex=b.zIndex;this.plecaHeight=b.plecaHeight||0;this.displaceRegionNorth=b.displaceRegionNorth||0;this.displaceRegionWest=b.displaceRegionWest||0;for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.init()};a.Space.prototype.init=function(){d=this.parent;h=this.evaluator;b=this.id;this.displaceRegionNorth=d.displaceRegionNorth||0;this.displaceRegionWest=d.displaceRegionWest||
0;void 0!=this.wExpr&&(this.w=(parseInt(d.container.width)-this.displaceRegionWest)*parseFloat(this.wExpr)/100);void 0!=this.hExpr&&(this.h=(parseInt(d.container.height)-this.displaceRegionNorth)*parseFloat(this.hExpr)/100);e=parseInt(d.container.height);g=parseInt(d.container.width);this.x=h.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=h.evalExpression(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+"px",this.container.style.top=
this.y+"px");0<=this.y?(c=e-this.y,this.h>c&&(this.h=c)):(c=this.h+this.y,this.h=c>=e?e:c);0<=this.x?(p=g-this.x,this.w>p&&(this.w=p)):(p=this.w+this.x,this.w=p>=g?g:p);""==this.imageSrc&&this.imageSrc.trim().toLowerCase().match(/vacio.gif$/)||(this.image=d.getImage(this.imageSrc));this.OxExpr&&(q=this.OxExpr,"%"===q[q.length-1]?this.Ox=this.w*parseFloat(q)/100:(n=parseFloat(q),n!=q&&(n=0),this.Ox=n));this.OyExpr&&(k=this.OyExpr,"%"===k[k.length-1]?this.Oy=this.h*parseFloat(k)/100:(n=parseFloat(k),
n!=k&&(n=0),this.Oy=n));""!==this.id&&2!==d.version?(h.setVariable(b+"._w",this.w),h.setVariable(b+"._h",this.h),h.setVariable(b+".escala",this.scale),h.setVariable(b+".Ox",this.Ox),h.setVariable(b+".Oy",this.Oy),h.setVariable(b+".mouse_x",0),h.setVariable(b+".mouse_y",0),h.setVariable(b+".mouse_pressed",0),h.setVariable(b+".mouse_clicked",0),h.setVariable(b+".clic_izquierdo",0)):(n=h.getVariable("_w"),void 0===n&&(n=this.w),h.setVariable("_w",n),n=h.getVariable("_h"),void 0===n&&(n=this.h),h.setVariable("_h",
n),n=h.getVariable("escala"),void 0===n&&(n=this.scale),h.setVariable("escala",n),n=h.getVariable("Ox"),void 0===n&&(n=this.Ox),h.setVariable("Ox",n),n=h.getVariable("Oy"),void 0===n&&(n=this.Oy),h.setVariable("Oy",n),h.setVariable("mouse_x",0),h.setVariable("mouse_y",0),h.setVariable("mouse_pressed",0),h.setVariable("mouse_clicked",0),h.setVariable("clic_izquierdo",0),""===this.x_axis&&(""===this.y_axis&&2==d.version)&&(this.axes=""));this.w_2=this.w/2;this.h_2=this.h/2};a.Space.prototype.addCtr=
function(a){"graphic"===a.type?this.graphicsCtr.push(a):this.ctrs.push(a)};a.Space.prototype.addGraph=function(a){a.background&&"R3"!==this.type?this.backgroundGraphics.push(a):this.graphics.push(a)};a.Space.prototype.clearClick=function(){this.evaluator.setVariable(this.mclickedString,0);this.evaluator.setVariable(this.mclicizquierdoString,0)};a.Space.prototype.getRelativeX=function(a){return(parseInt(a)-this.w_2-this.Ox)/this.scale};a.Space.prototype.getRelativeY=function(a){return(-parseInt(a)+
this.h_2+this.Oy)/this.scale};a.Space.prototype.getAbsoluteX=function(a){return a*this.scale+this.w_2+this.Ox};a.Space.prototype.getAbsoluteY=function(a){return-a*this.scale+this.h_2+this.Oy};a.Space.prototype.findOffset=function(){s=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(r=this.container.style.display);this.container.style.display="block";if(s.getBoundingClientRect){var a=s.getBoundingClientRect();this.offsetLeft=a.left;this.offsetTop=a.top}else for(;s;)s.tagName&&
"html"!==s.tagName.toLowerCase()?(this.offsetLeft+=s.offsetLeft||0,this.offsetTop+=s.offsetTop||0,s=s.parentNode):s=null;this.container&&this.container.style&&(this.container.style.display=r)};a.Space.prototype.getCursorPosition=function(b){t=a.getCursorPosition(b);return{x:t.x-this.offsetLeft,y:t.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.SpaceExternal=function(a){d=this;d.parent=a;d.width=228;d.vSpace=25;d.container=document.createElement("div");
d.container.setAttribute("id","_DescartesExternalRegion_");d.container.setAttribute("style","-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; border-style: ridge; border-width: 5px; border-color: gray; box-shadow: 0px 0px 25px 5px #000; overflow-y: scroll; overflow-x: hidden; position: absolute; left: 0px; top: 0px; z-index: 10000; width: "+(d.width+27)+"px; height: 460px; background-color: #63b4fb");d.moveManipulator=document.createElement("div");d.moveManipulator.setAttribute("style",
" position: absolute; left: 0px; top: 0px; width: "+(d.width+27)+"; height: "+d.vSpace+"px; line-height: "+d.vSpace+"px; background-color: ddd; cursor: move; padding-left: 75px; font-family: Sans-Serif; font-size: 18px;");d.moveManipulator.innerHTML="Descartes";d.container.appendChild(d.moveManipulator);d.ctrs=[]};a.SpaceExternal.prototype.init=function(){function h(b){d.newPosition=a.getCursorPosition(b);d.container.style.left=d.initialPosition.x+(d.newPosition.x-d.oldPosition.x)+"px";d.container.style.top=
d.initialPosition.y+(d.newPosition.y-d.oldPosition.y)+"px"}function f(a){a.preventDefault();d.findOffset();document.body.removeEventListener("mousemove",h);document.body.removeEventListener("mouseup",f)}document.body.appendChild(this.container);d=this;var b=d.parent.evaluator.parser,c;c=0;for(var p=d.ctrs.length;c<p;c++)d.ctrs[c].expresion=b.parse("(0,"+(d.vSpace+23+35*c)+","+d.width+",35)"),d.ctrs[c].update();d.numCtr=p;c="espa\u00f1ol"==d.language?"cr\u00e9ditos":"english"==d.language?"about":"cr\u00e9ditos";
c=new a.Button(d.parent,{region:"external",name:c,font_size:b.parse("15"),expresion:b.parse("(0,"+d.vSpace+","+d.width/2+",25)")});c.actionExec={execute:a.showAbout};c.update();(new a.Button(d.parent,{region:"external",name:"config",font_size:b.parse("15"),action:"config",expresion:b.parse("("+d.width/2+","+d.vSpace+","+d.width/2+",25)")})).update();c="espa\u00f1ol"==d.language?"inicio":"english"==d.language?"init":"inicio";(new a.Button(d.parent,{region:"external",name:c,font_size:b.parse("15"),
action:"init",expresion:b.parse("(0,"+(d.vSpace+23+35*p)+","+d.width/2+",25)")})).update();c="espa\u00f1ol"==d.language?"limpiar":"english"==d.language?"clear":"limpiar";(new a.Button(d.parent,{region:"external",name:c,font_size:b.parse("15"),action:"clear",expresion:b.parse("("+d.width/2+","+(d.vSpace+23+35*p)+","+d.width/2+",25)")})).update();c="espa\u00f1ol"==d.language?"cerrar":"close";b=new a.Button(d.parent,{region:"external",name:c,font_size:b.parse("15"),expresion:b.parse("("+d.width/4+","+
(d.vSpace+46+35*p)+","+d.width/2+",25)")});b.update();b.canvas.addEventListener("click",function(a){d.hide()});d.setPositionAndSize();d.moveManipulator.addEventListener("mousedown",function(b){b.preventDefault();d.oldPosition=a.getCursorPosition(b);d.initialPosition={x:d.container.offsetLeft,y:d.container.offsetTop};document.body.addEventListener("mousemove",h);document.body.addEventListener("mouseup",f)});d.findOffset();d.hide()};a.SpaceExternal.prototype.addCtr=function(a){this.ctrs.push(a)};a.SpaceExternal.prototype.show=
function(){this.setPositionAndSize();this.container.style.display="block"};a.SpaceExternal.prototype.hide=function(){this.container.style.display="none"};a.SpaceExternal.prototype.setPositionAndSize=function(){var a=this.vSpace+46+35*this.numCtr+25+10;this.container.style.left=Math.max(parseInt(window.innerWidth-this.width)/2,0)+"px";this.container.style.top="5px";this.container.style.height=window.innerHeight<this.vSpace+75?this.vSpace+75+"px":a>window.innerHeight-10?window.innerHeight-10:a+"px"};
a.SpaceExternal.prototype.findOffset=function(){tmpContainer=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(tmpDisplay=this.container.style.display);this.container.style.display="block";if(tmpContainer.getBoundingClientRect){var a=tmpContainer.getBoundingClientRect();this.offsetLeft=a.left;this.offsetTop=a.top}else for(;tmpContainer;)tmpContainer.tagName&&"html"!==tmpContainer.tagName.toLowerCase()?(this.offsetLeft+=tmpContainer.offsetLeft||0,this.offsetTop+=
tmpContainer.offsetTop||0,tmpContainer=tmpContainer.parentNode):tmpContainer=null;this.container&&this.container.style&&(this.container.style.display=tmpDisplay);for(var a=0,d=this.ctrs.length;a<d;a++)this.ctrs[a].findOffset&&this.ctrs[a].findOffset()};return a}(descartesJS||{}),descartesJS=function(a){var d,h;if(a.loadLib)return a;var f=Math.floor,b=Math.round,c=2*Math.PI,p=a.convertFont("SansSerif,PLAIN,12"),e=a.convertFont("Monospaced,PLAIN,12"),g,n,q,k,s,r,t,m,v,l,u,w,z,C,A,E,F,B,y,G,H,K,I,x,
L,D,J,M,O;a.Space2D=function(b,c){a.Space.call(this,b,c);g=this;g.backgroundCanvas=document.createElement("canvas");g.backgroundCanvas.setAttribute("id",g.id+"_background");g.backgroundCanvas.setAttribute("width",g.w+"px");g.backgroundCanvas.setAttribute("height",g.h+"px");g.backgroundCtx=g.backgroundCanvas.getContext("2d");g.backgroundCtx.imageSmoothingEnabled=!1;g.backgroundCtx.mozImageSmoothingEnabled=!1;g.backgroundCtx.webkitImageSmoothingEnabled=!1;g.canvas=document.createElement("canvas");g.canvas.setAttribute("id",
g.id+"_canvas");g.canvas.setAttribute("width",g.w+"px");g.canvas.setAttribute("height",g.h+"px");g.canvas.setAttribute("class","DescartesSpace2DCanvas");g.canvas.setAttribute("style","z-index: "+g.zIndex+";");g.ctx=g.canvas.getContext("2d");g.ctx.imageSmoothingEnabled=!1;g.ctx.mozImageSmoothingEnabled=!1;g.ctx.webkitImageSmoothingEnabled=!1;g.graphicControlContainer=document.createElement("div");g.graphicControlContainer.setAttribute("id",g.id+"_graphicControls");g.graphicControlContainer.setAttribute("style",
"position: absolute; left: 0px; top: 0px; z-index: "+g.zIndex+";");g.numericalControlContainer=document.createElement("div");g.numericalControlContainer.setAttribute("id",g.id+"_numericalControls");g.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+g.zIndex+";");g.container=document.createElement("div");g.container.setAttribute("id",g.id);g.container.setAttribute("class","DescartesSpace2DContainer");g.container.setAttribute("style","left: "+g.x+"px; top: "+
g.y+"px; z-index: "+g.zIndex+";");g.parent.arquimedes&&"#f0f8fa"===g.background.getColor()&&(g.container.style.border="1px solid #b8c4c8");g.container.appendChild(g.backgroundCanvas);g.container.appendChild(g.canvas);g.container.appendChild(g.graphicControlContainer);g.container.appendChild(g.numericalControlContainer);b.container.insertBefore(g.container,b.loader);g.parent.images[g.id+".image"]=g.canvas;g.parent.images[g.id+".image"].ready=1;g.parent.images[g.id+".image"].complete=!0;g.evaluator.setVariable(g.id+
".image",g.id+".image");g.parent.images[g.id+".back"]=g.backgroundCanvas;g.parent.images[g.id+".back"].ready=1;g.parent.images[g.id+".back"].complete=!0;g.evaluator.setVariable(g.id+".back",g.id+".back");""!==g.id&&2!==b.version?(g.OxString=g.id+".Ox",g.OyString=g.id+".Oy",g.scaleString=g.id+".escala",g.wString=g.id+"._w",g.hString=g.id+"._h",g.mxString=g.id+".mouse_x",g.myString=g.id+".mouse_y",g.mpressedString=g.id+".mouse_pressed",g.mclickedString=g.id+".mouse_clicked",g.mclicizquierdoString=g.id+
".clic_izquierdo"):(g.OxString="Ox",g.OyString="Oy",g.scaleString="escala",g.wString="_w",g.hString="_h",g.mxString="mouse_x",g.myString="mouse_y",g.mpressedString="mouse_pressed",g.mclickedString="mouse_clicked",g.mclicizquierdoString="clic_izquierdo");g.click=0;g.registerMouseAndTouchEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){g=this;g.uber.init.call(g);g.canvas&&(g.backgroundCanvas.setAttribute("width",g.w+"px"),g.backgroundCanvas.setAttribute("height",g.h+"px"),g.canvas.setAttribute("width",
g.w+"px"),g.canvas.setAttribute("height",g.h+"px"));g.container&&g.findOffset()};a.Space2D.prototype.update=function(a){g=this;n=g.evaluator;q=g.parent;n.setVariable(g.wString,g.w);n.setVariable(g.hString,g.h);g.drawIfValue=0<n.evalExpression(g.drawif);if(g.drawIfValue){s=g.x!==n.evalExpression(g.xExpr)+g.displaceRegionWest;r=g.y!==n.evalExpression(g.yExpr)+q.plecaHeight+g.displaceRegionNorth;g.spaceChange=a||s||r||g.drawBefore!==g.drawIfValue||g.Ox!==n.getVariable(g.OxString)||g.Oy!==n.getVariable(g.OyString)||
g.scale!==n.getVariable(g.scaleString);g.x=s?n.evalExpression(g.xExpr)+g.displaceRegionWest:g.x;g.y=r?n.evalExpression(g.yExpr)+q.plecaHeight+g.displaceRegionNorth:g.y;g.Ox=n.getVariable(g.OxString);g.Oy=n.getVariable(g.OyString);g.scale=n.getVariable(g.scaleString);g.drawBefore=g.drawIfValue;1E-6>g.scale?(g.scale=1E-6,n.setVariable(g.scaleString,1E-6)):1E6<g.scale&&(g.scale=1E6,n.setVariable(g.scaleString,1E6));if(s||r)g.container.style.left=g.x+"px",g.container.style.top=g.y+"px",g.findOffset();
g.container.style.display="block";g.drawTrace=!g.spaceChange&&(!g.fixed&&!g.click||g.fixed);g.spaceChange&&g.drawBackground();g.draw()}else g.container.style.display="none"};a.Space2D.prototype.drawBackground=function(){n=this.evaluator;k=this.backgroundCtx;k.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);k.fillStyle=this.background.getColor();k.fillRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&
("topleft"===this.bg_display?k.drawImage(this.image,0,0):"stretch"===this.bg_display?k.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?(k.fillStyle=k.createPattern(this.image,"repeat"),k.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&k.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));m=this.scale;v=0;for(l=0>this.w+this.h?0:this.w+this.h;m>l;)m/=10,v++;for(;m<l/10;)m*=10;k.lineWidth=1;""!==this.net&&(k.strokeStyle=this.net.getColor(),
this.drawMarks(k,m/10,-1));if(2!==this.parent.version&&""!==this.net10||2===this.parent.version&&""!==this.net&&""!==this.net10)k.strokeStyle=this.net10.getColor(),this.drawMarks(k,m,-1);if(""!==this.axes){k.strokeStyle=this.axes.getColor();k.beginPath();if(""!==this.x_axis||2!==this.parent.version)k.moveTo(0,f(this.h/2+this.Oy)+0.5),k.lineTo(this.w,f(this.h/2+this.Oy)+0.5);if(""!==this.y_axis||2!==this.parent.version)k.moveTo(f(this.w/2+this.Ox)+0.5,0),k.lineTo(f(this.w/2+this.Ox)+0.5,this.h);k.stroke();
this.drawMarks(k,m,4);this.drawMarks(k,m/2,2);this.drawMarks(k,m/10,1)}if(""!==this.x_axis||""!==this.y_axis)k.fillStyle=""!==this.axes?this.axes.getColor():"black",k.font=p,k.textAlign="right",k.textBaseline="alphabetic",k.fillText(this.x_axis,f(this.w)-2,f(this.h/2+this.Oy)+12),k.fillText(this.y_axis,f(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(k.fillStyle=this.axes.getColor(),k.font=p,k.textAlign="start",k.textBaseline="bottom",m>(this.w+this.h)/2?this.drawNumbers(k,m/5,m<=this.scale?
v+1:v):m>(this.w+this.h)/4?this.drawNumbers(k,m/2,m<=this.scale?v+1:v):this.drawNumbers(k,m,v));for(var a=0,b=this.backgroundGraphics.length;a<b;a++)this.backgroundGraphics[a].draw()};a.Space2D.prototype.draw=function(){k=this.ctx;k.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=0,b=this.graphics.length;a<b;a++)t=this.graphics[a],""!==t.trace&&this.drawTrace&&t.drawTrace(),t.draw();a=0;for(b=this.graphicsCtr.length;a<b;a++)this.graphicsCtr[a].update(),this.graphicsCtr[a].draw();""!=
this.text&&(this.click&&"L"===this.whichButton)&&(k.fillStyle=this.text.getColor(),k.strokeStyle=k.fillStyle,k.lineWidth=1,k.font=e,k.textAlign="center",k.textBaseline="alphabetic",H=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),I="("+H+","+K+")",x=f(k.measureText(I).width/2),L=this.getAbsoluteX(this.mouse_x),D=this.getAbsoluteY(this.mouse_y),J=f(L),M=f(D-10),J+x>this.w?
J=this.w-x:0>J-x&&(J=x),M+1>this.h?M=this.h:0>M-14&&(M=15),k.fillText(I,J,M),k.beginPath(),k.arc(L,D,2.5,0,c,!0),k.stroke())};a.Space2D.prototype.drawMarks=function(a,c,d){u=this.w;w=this.h;F=0;B=u;y=0;G=w;A=f(u/2+this.Ox);E=f(w/2+this.Oy);0<=d&&(F=A-d,B=A+d,y=E-d,G=E+d);a.beginPath();for(d=-b(A/c);(z=A+b(d*c))<u;d++)a.moveTo(z+0.5,y+0.5),a.lineTo(z+0.5,G+0.5);for(d=-b(E/c);(C=E+b(d*c))<w;d++)a.moveTo(F+0.5,C+0.5),a.lineTo(B+0.5,C+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,c,d){u=
this.w;w=this.h;A=f(u/2+this.Ox);E=f(w/2+this.Oy);for(d=-b(A/c);(z=A+b(d*c))<u;d++)a.fillText(parseFloat((d*c/this.scale).toFixed(4)),z+1,E-2);for(d=-b(E/c);(C=E+b(d*c))<w;d++)0!==parseFloat(-d*c/this.scale)&&a.fillText(parseFloat((-d*c/this.scale).toFixed(4)),A+5,C+5)};a.Space2D.prototype.registerMouseAndTouchEvents=function(){function b(a){document.body.focus();l.parent.clearClick();l.click=1;l.evaluator.setVariable(l.mpressedString,1);l.evaluator.setVariable(l.mclickedString,0);l.evaluator.setVariable(l.mclicizquierdoString,
0);l.parent.deactivateGraphiControls();k(a);window.addEventListener("touchmove",n);window.addEventListener("touchend",c);a.stopPropagation();a.preventDefault()}function c(a){document.body.focus();l.click=0;l.evaluator.setVariable(l.mpressedString,0);l.evaluator.setVariable(l.mclickedString,1);l.evaluator.setVariable(l.mclicizquierdoString,1);window.removeEventListener("touchmove",n,!1);window.removeEventListener("touchend",c,!1);a.preventDefault();l.parent.update()}function e(b){document.body.focus();
b.stopPropagation();b.preventDefault();l.parent.clearClick();l.click=1;l.parent.deactivateGraphiControls();l.whichButton=a.whichButton(b);"R"===l.whichButton&&(window.addEventListener("mouseup",g),l.clickPosForZoom=l.getCursorPosition(b).y,l.clickPosForZoomNew=l.clickPosForZoom,l.fixed||(l.tempScale=l.scale,window.addEventListener("mousemove",m)));"L"===l.whichButton&&(l.evaluator.setVariable(l.mpressedString,1),l.evaluator.setVariable(l.mclickedString,0),l.evaluator.setVariable(l.mclicizquierdoString,
0),k(b),window.addEventListener("mousemove",n),window.addEventListener("mouseup",g))}function g(a){document.body.focus();a.stopPropagation();a.preventDefault();l.click=0;l.evaluator.setVariable(l.mpressedString,0);l.evaluator.setVariable(l.mclickedString,1);l.evaluator.setVariable(l.mclicizquierdoString,1);"R"===l.whichButton&&(window.removeEventListener("mousemove",m,!1),l.clickPosForZoom==l.clickPosForZoomNew&&l.parent.externalSpace.show());window.removeEventListener("mousemove",n,!1);window.removeEventListener("mouseup",
g,!1);l.parent.update()}function k(a){l.posAnte=l.getCursorPosition(a);l.mouse_x=l.getRelativeX(l.posAnte.x);l.mouse_y=l.getRelativeY(l.posAnte.y);l.evaluator.setVariable(l.mxString,l.mouse_x);l.evaluator.setVariable(l.myString,l.mouse_y);l.evaluator.setVariable(l.mclickedString,0);l.evaluator.setVariable(l.mclicizquierdoString,0);10<Date.now()-p&&(l.parent.update(),p=Date.now())}function m(a){a.preventDefault();l.clickPosForZoomNew=l.getCursorPosition(a).y;l.evaluator.setVariable(l.scaleString,l.tempScale+
l.tempScale/45*((l.clickPosForZoom-l.clickPosForZoomNew)/10));l.parent.update()}function n(a){a.preventDefault();a.stopPropagation();l.fixed||(l.posNext=l.getCursorPosition(a),d=f(l.posAnte.x-l.posNext.x),h=f(l.posAnte.y-l.posNext.y),l.evaluator.setVariable(l.OxString,l.Ox-d),l.evaluator.setVariable(l.OyString,l.Oy-h),l.posAnte.x-=d,l.posAnte.y-=h);k(a)}var p=0,l=this;O=a.hasTouchSupport;l.canvas.oncontextmenu=function(){return!1};O&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",
k),this.canvas.addEventListener("touchstart",b));O||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",k),this.canvas.addEventListener("mousedown",e))};return a}(descartesJS||{}),descartesJS=function(a){var d,h,f;function b(a,b){return b.depth-a.depth}function c(b,c){Z=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));W=a.add3D(b,a.scalarProduct3D(Z,-2));X=a.norm3D(W);return 0!==X?a.scalarProduct3D(W,1/X):a.scalarProduct3D(b,-1)}if(a.loadLib)return a;var p=Math.floor,
e=Math.round,g=Math.max,n=Math.cos,q=Math.sin,k=Math.sqrt,s=15*Math.PI/180,r=Math.cos(s),t=Math.sin(s),m,v,l,u,w,z,C,A,E,F,B,y,G,H,K,I,x,L,D,J,M,O,R,S=[],P,Q,N,V,U,Y,Z,W,X;a.Space3D=function(b,c){a.Space.call(this,b,c);l=this;l.backgroundCanvas=document.createElement("canvas");l.backgroundCanvas.setAttribute("id",l.id+"_background");l.backgroundCanvas.setAttribute("width",l.w+"px");l.backgroundCanvas.setAttribute("height",l.h+"px");l.canvas=document.createElement("canvas");l.canvas.setAttribute("id",
l.id+"_canvas");l.canvas.setAttribute("width",l.w+"px");l.canvas.setAttribute("height",l.h+"px");l.canvas.setAttribute("class","DescartesSpace3DCanvas");l.canvas.setAttribute("style","z-index: "+l.zIndex+";");l.ctx=l.canvas.getContext("2d");l.ctx.imageSmoothingEnabled=!1;l.ctx.mozImageSmoothingEnabled=!1;l.ctx.webkitImageSmoothingEnabled=!1;l.graphicControlContainer=document.createElement("div");l.graphicControlContainer.setAttribute("id",l.id+"_graphicControls");l.graphicControlContainer.setAttribute("style",
"position: absolute; left: 0px; top: 0px; z-index: "+l.zIndex+";");l.numericalControlContainer=document.createElement("div");l.numericalControlContainer.setAttribute("id",l.id+"_numericalControls");l.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+l.zIndex+";");l.container=document.createElement("div");l.container.setAttribute("id",l.id);l.container.setAttribute("class","DescartesSpace3DContainer");l.container.setAttribute("style","left: "+l.x+"px; top: "+
l.y+"px; z-index: "+l.zIndex+";");l.container.appendChild(l.backgroundCanvas);l.container.appendChild(l.canvas);l.container.appendChild(l.graphicControlContainer);l.container.appendChild(l.numericalControlContainer);b.container.insertBefore(l.container,b.loader);l.eye={x:0,y:0,z:0};l.lights=[{x:50,y:50,z:70},{x:50,y:-50,z:30},{x:20,y:0,z:-80},{x:0,y:0,z:0}];for(var d=0,f=l.lights.length;d<f;d++)l.lights[d]=a.normalize3D(l.lights[d]);l.light3={x:0,y:0,z:0};l.intensity=[0.4,0.5,0.3,0];l.userIntensity=
0;l.dim=1;l.tmpIntensity=[];l.OxStr=l.id+".Ox";l.OyStr=l.id+".Oy";l.scaleStr=l.id+".escala";l.wStr=l.id+"._w";l.hStr=l.id+"._h";l.obsStr=l.id+".observador";l.rotZStr=l.id+".rot.z";l.rotYStr=l.id+".rot.y";l.userI_Dim_Str=l.id+".userIlum.dim";l.userI_I_Str=l.id+".userIlum.I";l.userI_x_Str=l.id+".userIlum.x";l.userI_y_Str=l.id+".userIlum.y";l.userI_z_Str=l.id+".userIlum.z";l.evaluator.setVariable(l.rotZStr,0);l.evaluator.setVariable(l.rotYStr,0);l.evaluator.setVariable(l.userI_Dim_Str,l.dim);l.evaluator.setVariable(l.userI_I_Str,
l.userIntensity);l.evaluator.setVariable(l.userI_x_Str,0);l.evaluator.setVariable(l.userI_y_Str,0);l.evaluator.setVariable(l.userI_z_Str,0);l.registerMouseAndTouchEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(a){l=this;l.uber.init.call(l);l.canvas&&(l.canvas.setAttribute("width",l.w+"px"),l.canvas.setAttribute("height",l.h+"px"));l.container&&l.findOffset();l.w_2=l.w/2;l.h_2=l.h/2;l.oldMouse={x:0,y:0}};a.Space3D.prototype.update=function(a){l=this;m=l.evaluator;v=l.parent;
m.setVariable(l.wStr,l.w);m.setVariable(l.hStr,l.h);l.drawIfValue=0<m.evalExpression(l.drawif);if(l.drawIfValue){E=l.x!==m.evalExpression(l.xExpr)+l.displaceRegionWest;F=l.y!==m.evalExpression(l.yExpr)+v.plecaHeight+l.displaceRegionNorth;l.spaceChange=a||E||F||l.drawBefore!==l.drawIfValue||l.Ox!==m.getVariable(l.OxStr)||l.Oy!==m.getVariable(l.OyStr)||l.scale!==m.getVariable(l.scaleStr);l.x=E?m.evalExpression(l.xExpr)+l.displaceRegionWest:l.x;l.y=F?m.evalExpression(l.yExpr)+v.plecaHeight+l.displaceRegionNorth:
l.y;l.Ox=m.getVariable(l.OxStr);l.Oy=m.getVariable(l.OyStr);l.scale=m.getVariable(l.scaleStr);l.drawBefore=l.drawIfValue;if(a||void 0==l.observer){var b;a=0;for(var c=l.parent.controls.length;a<c;a++)l.parent.controls[a].id===l.obsStr&&(b=!0);l.observer=b?m.getVariable(l.obsStr)||0.5*(l.w+l.h):2.5*(l.w+l.h);l.observer=g(l.observer,0.1*(l.w+l.h));m.setVariable(l.obsStr,l.observer);l.eye={x:l.observer/l.scale*r,y:0,z:l.observer/l.scale*t};l.D=l.scale*l.eye.x/r;l.XE=e(l.scale*l.eye.y+0.5);l.YE=e(l.scale*
l.eye.z+0.5)}l.observer=g(m.getVariable(l.obsStr),0.1*(l.w+l.h));m.setVariable(l.obsStr,l.observer);1E-6>l.scale?(l.scale=1E-6,m.setVariable(l.scaleStr,1E-6)):1E6<l.scale&&(l.scale=1E6,m.setVariable(l.scaleStr,1E6));if(E||F)l.container.style.left=l.x+"px",l.container.style.top=l.y+"px",l.findOffset();l.container.style.display="block";l.dim=m.getVariable(l.userI_Dim_Str);l.userIntensity=m.getVariable(l.userI_I_Str);l.light3={x:parseInt(m.getVariable(l.userI_x_Str)),y:parseInt(m.getVariable(l.userI_y_Str)),
z:parseInt(m.getVariable(l.userI_z_Str))};l.updateCamera();l.draw()}else l.container.style.display="none"};a.Space3D.prototype.draw=function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.fillStyle=this.background.getColor();this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?this.ctx.drawImage(this.image,0,0):"stretch"===this.bg_display?this.ctx.drawImage(this.image,
0,0,this.w,this.h):"patch"===this.bg_display?(this.ctx.fillStyle=ctx.createPattern(this.image,"repeat"),this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&this.ctx.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));for(var a=0,c=this.graphics.length;a<c;a++)this.graphics[a].update();this.primitives=[];a=0;for(c=this.graphics.length;a<c;a++){u=this.graphics[a];if(u.split||this.split)for(var d=a+1;d<c;d++)w=this.graphics[d],(w.split||
this.split)&&u.splitFace(w);this.primitives=this.primitives.concat(u.primitives||[])}z=this.primitives;C=z.length;for(a=0;a<C;a++)z[a].computeDepth(this);if("painter"===this.render)this.drawPainter(z);else for(z=z.sort(b),a=0;a<C;a++)z[a].draw(this.ctx,this);a=0;for(c=this.graphicsCtr.length;a<c;a++)this.graphicsCtr[a].draw()};var T;a.renderNode=function(a){this.value=a;this.front=this.back=null};a.renderNode.prototype.inOrder=function(){var a=[];this.back&&(a=a.concat(this.back.inOrder()));a.push(this.value);
this.front&&(a=a.concat(this.front.inOrder()));return a};a.Space3D.prototype.buildTree=function(b){if(0===b.length)return null;var c,d=[],f=[];T=b.shift();for(var e=0,g=b.length;e<g;e++){c=null;for(var h=0,l=b[e].spaceVertices.length;h<l;h++)whereIs=2<T.spaceVertices.length?this.inPlane2(T.spaceVertices[0],T.normal,b[e].spaceVertices[h]):0,whereIs=0<T.direction?-whereIs:whereIs,null===c?0>whereIs?c="front":0<whereIs&&(c="back"):0>whereIs?"back"===c&&(c="cross"):0<whereIs&&"front"===c&&(c="cross");
if("back"===c)d.push(b[e]);else if("front"===c)f.push(b[e]);else if(null==c)d.push(b[e]);else{c=null;h=0;for(l=T.spaceVertices.length;h<l;h++)whereIs=2<b[e].spaceVertices.length?this.inPlane2(b[e].spaceVertices[0],b[e].normal,T.spaceVertices[h]):-1,whereIs=0<b[e].direction?-whereIs:whereIs,null===c?0>whereIs?c="front":0<whereIs&&(c="back"):0>whereIs?"back"===c&&(c="cross"):0<whereIs&&"front"===c&&(c="cross");"front"===c?d.push(b[e]):f.push(b[e])}}b=new a.renderNode(T);b.back=this.buildTree(d);b.front=
this.buildTree(f);return b};a.Space3D.prototype.drawPainter=function(a){a=this.buildTree(a).inOrder();for(var b=0;b<a.length;b++)a[b].draw(this.ctx,this)};a.Space3D.prototype.inPlane=function(a,b,c,d){return parseFloat(((d.x-a.x)*(b.y-a.y)*(c.z-a.z)+(d.y-a.y)*(b.z-a.z)*(c.x-a.x)+(d.z-a.z)*(b.x-a.x)*(c.y-a.y)-(d.z-a.z)*(b.y-a.y)*(c.x-a.x)-(d.y-a.y)*(b.x-a.x)*(c.z-a.z)-(d.x-a.x)*(b.z-a.z)*(c.y-a.y)).toFixed(8))};a.Space3D.prototype.inPlane2=function(a,b,c){return parseFloat((b.x*(c.x-a.x)+b.y*(c.y-
a.y)+b.z*(c.z-a.z)).originalToFixed(8))};a.Space3D.prototype.updateCamera=function(){l=this;l.D=l.observer;l.eye.x=l.D/l.scale;l.eye.y=l.XE/l.scale;l.eye.z=l.YE/l.scale};a.Space3D.prototype.rotateVertex=function(b){x=a.degToRad(l.evaluator.getVariable(l.rotZStr));L=n(x);D=q(x);d=b.x*L-b.y*D;h=b.x*D+b.y*L;f=b.z;x=a.degToRad(l.evaluator.getVariable(l.rotYStr));L=n(x);D=q(x);return{x:f*D+d*L,y:h,z:f*L-d*D}};a.Space3D.prototype.project=function(a){l=this;G=l.eye.x-a.x;H=l.eye.y-a.y;K=l.eye.z-a.z;var b=
k(G*G+H*H+K*K);I=-a.x/b||0;G=this.w_2+this.Ox+l.scale*(a.y+I*(l.eye.y-a.y));H=this.h_2+this.Oy-l.scale*(a.z+I*(l.eye.z-a.z));return{x:G,y:H,z:b}};a.Space3D.prototype.computeColor=function(b,d,f){if(b.match("rgba")){var e=b,e=e.substring(5,e.length-1).split(",");b=parseInt(e[0]).toString(16);var g=parseInt(e[1]).toString(16),h=parseInt(e[2]).toString(16),e=(255-parseInt(255*parseFloat(e[3]))).toString(16);b=1==b.length?"0"+b:b;g=1==g.length?"0"+g:g;h=1==h.length?"0"+h:h;e=1==e.length?"0"+e:e;b=new a.Color(e+
b+g+h)}else b.match("#")&&(b=new a.Color(b.substring(1)));V=a.subtract3D(this.eye,d.average);U=a.norm3D(V);Y=a.scalarProduct3D(V,1/U);this.lights[3]=a.subtract3D(this.light3,d.average);R=a.norm3D(this.lights[3]);g=0;for(h=this.intensity.length-1;g<h;g++)S[g]=this.intensity[g]*this.dim;S[3]=this.userIntensity*this.userIntensity/R||0;P=f?this.dim/2:this.dim/4;Q=0;N=0<=d.direction?d.normal:a.scalarProduct3D(d.normal,-1);g=0;for(h=this.lights.length;g<h;g++)f?(Q=Math.max(0,a.dotProduct3D(c(this.lights[g],
N),Y)),Q*=Q*Q):Q=Math.max(0,a.dotProduct3D(this.lights[g],N)),P+=S[g]*Q;P=Math.min(P,1);J=p(b.r*P);M=p(b.g*P);O=p(b.b*P);return"rgba("+J+","+M+","+O+","+b.a+")"};a.Space3D.prototype.registerMouseAndTouchEvents=function(){function b(a){document.body.focus();k.click=1;k.evaluator.setVariable(k.id+".mouse_pressed",1);k.parent.deactivateGraphiControls();k.posAnte=k.getCursorPosition(a);k.oldMouse.x=k.getRelativeX(k.posAnte.x);k.oldMouse.y=k.getRelativeY(k.posAnte.y);g(a);window.addEventListener("touchmove",
l);window.addEventListener("touchend",c);a.preventDefault()}function c(a){document.body.focus();k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);window.removeEventListener("touchmove",l,!1);window.removeEventListener("touchend",c,!1);a.preventDefault()}function d(b){document.body.focus();k.click=1;k.parent.deactivateGraphiControls();k.whichButton=a.whichButton(b);"R"===k.whichButton?(window.addEventListener("mouseup",f),k.clickPosForZoom=k.getCursorPosition(b).y,k.clickPosForZoomNew=k.clickPosForZoom,
k.fixed||(k.tempScale=k.scale,window.addEventListener("mousemove",h))):"L"==k.whichButton&&(k.evaluator.setVariable(k.id+".mouse_pressed",1),k.posAnte=k.getCursorPosition(b),k.oldMouse.x=k.getRelativeX(k.posAnte.x),k.oldMouse.y=k.getRelativeY(k.posAnte.y),g(b),window.addEventListener("mousemove",l),window.addEventListener("mouseup",f));b.preventDefault()}function f(a){document.body.focus();k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);a.preventDefault();"R"===k.whichButton&&(window.removeEventListener("mousemove",
h,!1),k.clickPosForZoom==k.clickPosForZoomNew&&k.parent.externalSpace.show());window.removeEventListener("mousemove",l,!1);window.removeEventListener("mouseup",f,!1)}function g(a){k.posAnte=k.getCursorPosition(a);k.mouse_x=k.getRelativeX(k.posAnte.x);k.mouse_y=k.getRelativeY(k.posAnte.y);k.evaluator.setVariable(k.id+".mouse_x",k.mouse_x);k.evaluator.setVariable(k.id+".mouse_y",k.mouse_y);70<Date.now()-m&&(k.parent.update(),m=Date.now())}function h(a){a.preventDefault();k.clickPosForZoomNew=k.getCursorPosition(a).y;
k.evaluator.setVariable(k.scaleStr,k.tempScale+k.tempScale/45*((k.clickPosForZoom-k.clickPosForZoomNew)/10));k.parent.update()}function l(b){if(!k.fixed&&k.click){B=parseInt(50*(k.oldMouse.x-k.mouse_x));y=parseInt(50*(k.oldMouse.y-k.mouse_y));if(B!==k.disp.x||y!==k.disp.y)k.alpha=a.degToRad(k.evaluator.getVariable(k.rotZStr)),k.beta=a.degToRad(-k.evaluator.getVariable(k.rotYStr)),k.alpha=e(a.radToDeg(k.alpha)-B),k.beta=e(a.radToDeg(k.beta)-y),k.evaluator.setVariable(k.rotZStr,k.alpha),k.evaluator.setVariable(k.rotYStr,
-k.beta),k.disp.x=B,k.disp.y=y,k.oldMouse.x=k.getRelativeX(k.posAnte.x),k.oldMouse.y=k.getRelativeY(k.posAnte.y);g(b);b.preventDefault()}}var k=this,m=0;A=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};A&&this.canvas.addEventListener("touchstart",b);A||this.canvas.addEventListener("mousedown",d);this.disp={x:0,y:0}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.SpaceAP=function(h,f){a.Space.call(this,h,f);this.exportarVars=this.importarVars=null;
d=h.evaluator;this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=d.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=d.parser.parse(this.file):this.file=d.parser.parse("'"+this.file+"'");this.oldFile=d.evalExpression(this.file);this.initFile()};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var d;if(this.oldFile){var f=document.getElementById(this.oldFile);d=f&&"descartes/spaceApFile"==f.type?
f.text:a.openExternalFile(this.oldFile);null!=d&&(d=d.split("\n"))}if(d&&d.toString().match(/<applet/gi)){for(var f="",b=!1,c=0,p=d.length;c<p&&(d[c].match("<applet")&&(b=!0),b&&(f+=d[c]),!d[c].match("</applet"));c++);c=document.createElement("div");c.innerHTML=f;c.firstChild.setAttribute("width",this.w);c.firstChild.setAttribute("height",this.h);f=this.descApp?this.descApp.container:null;this.descApp=new a.DescartesApp(c.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+";");f?this.parent.container.replaceChild(this.descApp.container,f):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);f=this.descApp.spaces;c=0;for(p=f.length;c<p;c++)f[c].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?
"block":"none";var e=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();e.exportar()}}else f=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),c="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?c+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?c+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?c+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(c+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",
c),f?this.parent.container.replaceChild(this.descApp.container,f):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),d=this.y!=this.evaluator.evalExpression(this.yExpr)+this.plecaHeight;
this.x=a?this.evaluator.evalExpression(this.xExpr):this.x;this.y=d?this.evaluator.evalExpression(this.yExpr)+this.plecaHeight:this.y;a&&(this.descApp.container.style.left=this.x+"px");d&&(this.descApp.container.style.top=this.y+"px");if(a||d)for(var a=this.descApp.spaces,d=0,b=a.length;d<b;d++)a[d].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 c in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(c)&&
c.match(/^public./)&&this.importarVars.push({varName:c,value:this.evaluator.getVariable(c)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,d=!1,b=0,c=this.importarVars.length;b<c;b++)a=this.evaluator.getVariable(this.importarVars[b].varName),a!=this.importarVars[b].value&&(this.importarVars[b].value=a,this.descApp.evaluator.setVariable(this.importarVars[b].varName,this.importarVars[b].value),d=!0);d&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,f,b;a.SpaceHTML_IFrame=function(b,d){a.Space.call(this,b,d);var e=this.parent.evaluator;window.navigator.userAgent.toLowerCase().match(/firefox/);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=e.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=e.parser.parse(this.file):this.file=e.parser.parse("'"+this.file+"'");this.oldFile=e.evalExpression(this.file);
this.MyIFrame=document.createElement("iframe");0!=this.oldFile&&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: static; left: 0px; top: 0px;");this.container=document.createElement("div");a.isIOS?this.container.setAttribute("style","overflow: scroll; -webkit-overflow-scrolling: touch; position: absolute; width: "+
this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";"):this.container.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.container.appendChild(this.MyIFrame);this.parent.container.insertBefore(this.container,this.parent.loader);var f=this;this.MyIFrame.onload=function(a){var b=this;f.evaluator.setFunction(f.id+".set",function(a,c){b.contentWindow.postMessage({type:"set",
name:a,value:c},"*");return 0});f.evaluator.setFunction(f.id+".update",function(){b.contentWindow.postMessage({type:"update"},"*");return 0});f.evaluator.setFunction(f.id+".exec",function(a,c){b.contentWindow.postMessage({type:"exec",name:a,value:c},"*");return 0})};this.update=this.iframeUpdate;this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.init=function(){self=this;self.uber.init.call(self);self.MyIFrame&&(self.MyIFrame.style.width=
self.w+"px",self.MyIFrame.style.height=self.h+"px",self.MyIFrame.style.left=self.x+"px",self.MyIFrame.style.top=self.y+"px")};a.SpaceHTML_IFrame.prototype.iframeUpdate=function(a){d=this.evaluator;this.drawIfValue=0<d.evalExpression(this.drawif);this.container.style.display=this.drawIfValue?"block":"none";if(this.drawIfValue){a&&(this.y=this.x=Math.Infinity);h=this.x!==d.evalExpression(this.xExpr)+this.displaceRegionWest;f=this.y!==d.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;
this.x=h?d.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=f?d.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(h||f)this.MyIFrame.style.left=this.x+"px",this.MyIFrame.style.top=this.y+"px";b=d.evalExpression(this.file);b!==this.oldFile&&(this.oldFile=b,this.MyIFrame.setAttribute("src",b));this.scrollVar=d.getVariable(this.id+"._scroll");1==this.scrollVar?(this.MyIFrame.setAttribute("scrolling","yes"),this.MyIFrame.style.overflow=""):-1==this.scrollVar?
(this.MyIFrame.setAttribute("scrolling","no"),this.MyIFrame.style.overflow="hidden"):(this.MyIFrame.setAttribute("scrolling","auto"),this.MyIFrame.style.overflow="")}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;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 b=
a.image_loader?a.image_loader:p(a.loader.width,a.loader.height);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("+b+"); 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(80);this.barHeight=Math.floor(a.loader.height/70);var c=this;this.timer=setInterval(function(){c.drawLoaderBar(c.loaderBar.ctx,a.width,a.height)},10);a.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var b=this.children,
c=this.images,d=this.audios,f=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,h=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav)/gi;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 p,r,t,m,v,l;t=0;for(v=b.length;t<v;t++)if("rtf"!==b[t].name){if(b[t].value.match(/'macro'|'makro'/g)){p="";var u;r=this.lessonParser.split(b[t].value);
l=0;for(var w=r.length;l<w;l++)"expresion"===babel[r[l][0]]&&(p=r[l][1]);p&&((u=document.getElementById(p))&&"descartes/macro"==u.type?u=u.text:(u=a.openExternalFile(p))&&!u.match(/tipo_de_macro/g)&&(u=null));if(u&&(p=u.match(f)))for(l=p.length;m<l;m++)r=p[m],r.toLowerCase().match(/vacio.gif$/)||""==r.substring(0,r.length-4)||(c[r]=new Image,c[r].addEventListener("load",function(){this.ready=1}),c[r].addEventListener("error",function(){this.errorload=1}),c[r].src=r)}if(p=b[t].value.match(f))for(m=
0,l=p.length;m<l;m++)r=p[m],r.toLowerCase().match(/vacio.gif$/)||""==r.substring(0,r.length-4)||(c[r]=new Image,c[r].addEventListener("load",function(){this.ready=1}),c[r].addEventListener("error",function(){this.errorload=1}),c[r].src=r);if(p=b[t].value.match(h))for(m=0,r=p.length;m<r;m++)this.initAudio(p[m])}for(var z in c)c.hasOwnProperty(z)&&this.images.length++;for(z in d)d.hasOwnProperty(z)&&this.audios.length++;var C=this,A=this.images.length+this.audios.length,E=function(){C.readys=0;for(var a in c)c.hasOwnProperty(a)&&
(c[a].ready||c[a].errorload)&&C.readys++;for(a in C.audios)d.hasOwnProperty(a)&&(d[a].ready||d[a].errorload)&&C.readys++;C.readys!=A?setTimeout(E,30):(clearTimeout(C.timer),C.descartesApp.initBuildApp())};E()};a.DescartesLoader.prototype.initAudio=function(b){var c=this.audios;c[b]=new Audio(b);c[b].filename=b;var d=function(){this.ready=1},f=function(){this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))||"mp3"!=this.filename.substring(this.filename.length-3)?(console.log("El archivo '"+
b+"' no puede ser reproducido"),this.errorload=1):(c[b]=new Audio(this.filename.replace("mp3","ogg")),c[b].filename=this.filename.replace("mp3","ogg"),c[b].addEventListener("canplaythrough",d),c[b].addEventListener("load",d),c[b].addEventListener("error",f),c[b].load())};c[b].addEventListener("canplaythrough",d);c[b].addEventListener("load",d);c[b].addEventListener("error",f);a.hasTouchSupport?(c[b].load(),c[b].play(),setTimeout(function(){console.log("detenido");c[b].pause()},10),c[b].ready=1):c[b].load()};
var h,f,b,c;a.DescartesLoader.prototype.drawLoaderBar=function(a,g,p){h=this.barWidth;f=this.barHeight;b=this.images.length+this.audios.length;c=2*(h-2)/b;a.translate(g/2,(p-65*d)/2+90*d);a.scale(d,d);a.strokeRect(-h,-f,2*h,f);a.fillStyle="gray";a.fillRect(-h+2,-f+2,2*(h-2),f-4);a.fillStyle="#1f375d";a.fillRect(-h+2,-f+2,this.readys*c,f-4);a.setTransform(1,0,0,1,0,0)};var p=function(a,b){var c=document.createElement("canvas");c.width=a;c.height=b;var f=c.getContext("2d");f.save();f.strokeStyle="#1f375d";
f.fillStyle="#1f375d";f.lineCap="round";f.lineWidth=2;f.beginPath();d=a<b?a/360:b/195;d=2.5<d?2.5:d;f.translate((a-120*d)/2,(b-65*d)/2);f.scale(d,d);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, Helvetica, 'Droid Sans', Sans-serif";f.fillText("escartes",45,33);f.fillText("JS",98,64);f.restore();return c.toDataURL()};return a}(descartesJS||{}),descartesJS=function(a){function d(a){for(var b="[",c=0,p=a.length;c<p;c++)a[c]instanceof Array?b+=d(a[c]):(h=a[c],"undefined"!=typeof h&&h||(h=0),"string"==typeof h&&(h="'"+h+"'"),b+=h),c<p-1&&(b+=",");return b+"]"}if(a.loadLib)return a;
a.DescartesApp=function(d){this.animation={playing:!1};this.applet=d;this.parentContainer=d.parentNode;this.width=parseFloat(d.getAttribute("width"));this.height=parseFloat(d.getAttribute("height"));this.decimal_symbol=".";this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");this.children=d.getElementsByTagName("param");a.creativeCommonsLicense=!0;for(var b=0,c=this.children.length;b<c;b++)"CreativeCommonsLicense"==this.children[b].name&&(a.creativeCommonsLicense="no"==this.children[b].value?
!1:!0);this.code=d.getAttribute("code");this.saveState=[];this.images={};this.images.length=-1;this.audios={};this.audios.length=-1;this.firstRun=!0;this.init()};a.DescartesApp.prototype.init=function(){this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.arquimedes=!!this.code.match("descinst.DescartesWeb2_0.class","i")||!!this.code.match("Arquimedes","i")||!!this.code.match("Discurso","i");this.licenseA=a.creativeCommonsLicense?"{\\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, {\\*\\hyperlink Creditos|http://arquimedes.matem.unam.mx/Descartes5/creditos/conCCL.html}\\par }":
"";for(var d=this.children,b,c=0,h=0,e=a.creativeCommonsLicense?90:0,g=0,n=d.length;g<n;g++)b=d[g],"rtf_height"==b.name&&(c=parseInt(b.value)),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),h=this.buttonsConfig.height),"image_loader"==b.name&&(this.image_loader=b.value);this.arquimedes&&c&&(this.height=c+h+e);this.spaces=[];this.externalSpace&&document.body.removeChild(this.externalSpace.container);this.externalSpace=new a.SpaceExternal(this);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.cacheVars={};this.getVarsNames={};
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 d=this.children,b=this.lessonParser,c=[],h=[],e=[],g=[],n=[],q=[],k,s=0,r=d.length;s<r;s++)if(k=d[s],"pleca"==k.name)k=b.parsePleca(k.value,this.width),
this.container.insertBefore(k,this.loader),this.plecaHeight=k.imageHeight?k.imageHeight:k.offsetHeight;else if("Buttons"==babel[k.name])this.buttonsConfig=b.parseButtonsConfig(k.value);else if("decimal_symbol"==babel[k.name])this.decimal_symbol=k.value,this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");else if("version"==babel[k.name])this.version=parseInt(k.value);else if("language"==babel[k.name])this.language=k.value;else if("rtf"==k.name){var t=(this.width-780)/2,m=parseInt(this.height)-
this.plecaHeight-this.buttonsConfig.height-45;g.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+k.value.replace(/'/g,"&squot;")+"'");g.push("space='descartesJS_scenario' type='text' expresion='["+t+","+(m-25)+"]' background='yes' text='"+this.licenseA+"'");a.creativeCommonsLicense&&g.push("space='descartesJS_scenario' type='image' expresion='["+(t+15)+","+m+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==k.name.charAt(0)?
(k.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,c.push(k.value)):"C"==k.name.charAt(0)&&"_"==k.name.charAt(1)?h.push(k.value):"A"==k.name.charAt(0)&&"_"==k.name.charAt(1)?e.push(k.value):"G"==k.name.charAt(0)?g.push(k.value):"S"==k.name.charAt(0)?n.push(k.value):"Animation"==babel[k.name]&&q.push(k.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));s=0;for(r=c.length;s<r;s++)d=b.parseSpace(c[s]),this.arquimedes&&this.scenarioRegion.container.appendChild(d.container),this.spaces.push(d),this.zIndex++;s=0;for(r=g.length;s<r;s++)if(c=b.parseGraphic(g[s]))c.visible&&(this.editableRegionVisible=
!0),c.space.addGraph(c);s=0;for(r=n.length;s<r;s++)(c=b.parse3DGraphic(n[s]))&&c.space.addGraph(c);s=0;for(r=h.length;s<r;s++)this.controls.push(b.parseControl(h[s]));s=0;for(r=e.length;s<r;s++)b.parseAuxiliar(e[s]);s=0;for(r=q.length;s<r;s++)this.animation=b.parseAnimation(q[s]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();s=0;for(r=this.controls.length;s<r;s++)this.controls[s].init();this.updateControls();this.updateSpaces(!0);var v=this;this.numberOfIframes?setTimeout(function(){v.finishInit()},
300*this.numberOfIframes):this.finishInit()};a.DescartesApp.prototype.finishInit=function(){this.update();this.loader.style.display="none";window.parent!==window&&(this.parentContainer.style.margin="0px",this.parentContainer.style.padding="0px",window.parent.postMessage({type:"reportSize",href:window.location.href,width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready"},"*"),a.onResize());window.opener&&window.opener.postMessage({type:"isResizeNeeded",href:window.location.href},
"*");this.externalSpace.init()};a.DescartesApp.prototype.adjustSize=function(){document.body.style.margin="0px";document.body.style.padding="0px";this.parentContainer.style.margin="0px";this.parentContainer.style.padding="0px";var d=parseInt(this.width)+30,b=parseInt(this.height)+90;window.moveTo((parseInt(screen.width)-d)/2,(parseInt(screen.height)-b)/2);window.resizeTo(d,b);a.onResize()};a.DescartesApp.prototype.configRegions=function(){var d=this.evaluator.parser,b=this.buttonsConfig,c=this.container;
if(2!=this.version)var h="15",e=100,g=100,n=100,q=100;else h="14",e=63,g=50,n=44,q=53;var k=0,s=0,r=0,t=r=0,m=0,v=0,l=0,u=0,v=this.northSpace.controls,w=this.southSpace.controls,z=this.eastSpace.controls,C=this.westSpace.controls;if(0<b.rowsNorth||0<v.length||b.about||b.config){0>=b.rowsNorth?(k=b.height,b.rowsNorth=1):k=b.height*b.rowsNorth;m=this.northSpace.container;m.setAttribute("id","descartesJS_northRegion");m.setAttribute("style","width:"+c.width+"px; height:"+k+"px; background:#c0c0c0; position:absolute; left:0px; top: "+
this.plecaHeight+"px; z-index:100;");c.insertBefore(m,this.loader);var m=c.width,A=0;b.about&&(A=e,m-=A);b.config&&(m-=g);for(var E=Math.ceil(v.length/b.rowsNorth),F=m/E,r=0,B=v.length;r<B;r++)v[r].expresion=d.parse("("+(A+F*(r%E))+","+b.height*Math.floor(r/E)+","+F+","+b.height+")"),v[r].drawif=d.parse("1"),v[r].init();b.about&&(r="espa\u00f1ol"==this.language?"cr\u00e9ditos":"english"==this.language?"about":"cr\u00e9ditos",r=new a.Button(this,{region:"north",name:r,font_size:d.parse(h),expresion:d.parse("(0, 0, "+
e+", "+k+")")}),r.actionExec={execute:a.showAbout},r.update());b.config&&(new a.Button(this,{region:"north",name:"config",font_size:d.parse(h),action:"config",expresion:d.parse("("+(m+e)+", 0, "+g+", "+k+")")})).update()}if(0<b.rowsSouth||0<w.length||b.init||b.clear){0>=b.rowsSouth?(s=b.height,b.rowsSouth=1):s=b.height*b.rowsSouth;v=c.width;A=0;b.init&&(A=n,v-=A);b.clear&&(v-=q);m=this.southSpace.container;m.setAttribute("id","descartesJS_southRegion");m.setAttribute("style","width:"+c.width+"px; height:"+
s+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(c.height-s)+"px; z-index:100;");c.insertBefore(m,this.loader);E=Math.ceil(w.length/b.rowsSouth);F=v/E;r=0;for(B=w.length;r<B;r++)w[r].expresion=d.parse("("+(A+F*(r%E))+","+b.height*Math.floor(r/E)+","+F+","+b.height+")"),w[r].drawif=d.parse("1"),w[r].init();b.init&&(r="espa\u00f1ol"==this.language?"inicio":"english"==this.language?"init":"inicio",(new a.Button(this,{region:"south",name:r,font_size:d.parse(h),action:"init",expresion:d.parse("(0, 0, "+
n+", "+s+")")})).update());b.clear&&(r="espa\u00f1ol"==this.language?"limpiar":"english"==this.language?"clear":"limpiar",(new a.Button(this,{region:"south",name:r,font_size:d.parse(h),action:"clear",expresion:d.parse("("+(v+n)+", 0, "+q+", "+s+")")})).update())}if(0<z.length)for(r=c.height-k-s,l=b.widthEast,m=this.eastSpace.container,m.setAttribute("id","descartesJS_eastRegion"),m.setAttribute("style","width:"+l+"px; height:"+r+"px; background:#c0c0c0; position:absolute; left:"+(c.width-l)+"px; top:"+
k+"px; z-index:100;"),c.insertBefore(m,this.loader),r=0,B=z.length;r<B;r++)z[r].expresion=d.parse("(0,"+b.height*r+","+l+","+b.height+")"),z[r].drawif=d.parse("1"),z[r].init();if(0<C.length)for(r=c.height-k-s,u=b.widthWest,m=this.westSpace.container,m.setAttribute("id","descartesJS_westRegion"),m.setAttribute("style","width: "+u+"px; height: "+r+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+k+"px; z-index: 100;"),c.insertBefore(m,this.loader),r=0,B=C.length;r<B;r++)C[r].expresion=
d.parse("(0,"+b.height*r+","+u+","+b.height+")"),C[r].drawif=d.parse("1"),C[r].init();if(this.editableRegionVisible)for(t=b.height,m=this.editableRegion.container,m.setAttribute("id","descartesJS_editableRegion"),m.setAttribute("style","width:"+c.width+"px; height:"+t+"px; position:absolute; left:0px; top:"+(c.height-s-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;"),c.insertBefore(m,this.loader),d=this.editableRegion.textFields,b=c.width/d.length,h=a.getFieldFontSize(t),r=0,B=d.length;r<
B;r++)"div"==d[r].type?(m.appendChild(d[r].container),d[r].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(b-4)+"px; height: "+t+"px; position: absolute; left: "+r*b+"px; top: 0px;"),e=d[r].container.firstChild,e.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+h+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+t+"px; text-align: center; line-height: "+t+
"px;"),g=e.offsetWidth,e.style.width=g+"px",e.firstChild.textContent=e.firstChild.textContent.substring(3,e.firstChild.textContent.length-3),d[r].container.lastChild.setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+h+"px; width:"+(b-g)+"px; height:"+t+"px; position:absolute; left:"+g+"px; top:0px; border:2px groove white;")):(m.appendChild(d[r]),d[r].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+
h+"px; width:"+b+"px; height:"+t+"px; position:absolute; left:"+r*b+"px; top:0px; border:2px groove white;"));this.displaceRegionNorth=k;this.displaceRegionWest=u;c.width-=l;c.height=c.height-s-t;r=0;for(B=this.spaces.length;r<B;r++)this.spaces[r].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateControls();this.updateEvents();this.updateSpaces()};a.DescartesApp.prototype.clearClick=function(){for(var a=0,b=this.spaces.length;a<b;a++)this.spaces[a].clearClick()};
a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,b=0,c=this.controls.length;b<c;b++)a=this.controls[b],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,b=this.auxiliaries.length;a<b;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=function(){for(var a=0,b=this.events.length;a<b;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,b=this.controls.length;a<b;a++)this.controls[a].update()};
a.DescartesApp.prototype.updateSpaces=function(a){for(var b=0,c=this.spaces.length;b<c;b++)this.spaces[b].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,b=this.spaces.length;a<b;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground&&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.play()};a.DescartesApp.prototype.stopAudios=function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),this.audios[a].currentTime=0)};a.DescartesApp.prototype.getImage=function(a){var b=this.images;if(a)return b[a]||(b[a]=new Image,b[a].addEventListener("load",function(){this.ready=1}),b[a].addEventListener("error",function(){this.errorload=1}),b[a].src=a),b[a]};a.DescartesApp.prototype.getAudio=function(a){var b=this.audios;
if(a){if(!b[a]){var c=a.lastIndexOf("."),c=-1===c?a.lenght:c;a.substring(0,c);b[a]=new Audio(a);var d=function(a){this.ready=1};b[a].addEventListener("canplaythrough",d);var e=function(c){this.canPlayType("audio/"+a.substring(a.length-3))||"mp3"!=a.substring(a.length-3)?(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1):(b[a]=new Audio(a.replace("mp3","ogg")),b[a].addEventListener("canplaythrough",d),b[a].addEventListener("load",d),b[a].addEventListener("error",e),b[a].load())};
b[a].addEventListener("error",e);b[a].play();setTimeout(function(){b[a].pause()},15)}return b[a]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var b,c=0,d=this.controls.length;c<d;c++)if(b=this.controls[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var b,c=0,d=this.controls.length;c<d;c++)if(b=this.controls[c],b.id==a)return b;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var b,
c=0,d=this.spaces.length;c<d;c++)if(b=this.spaces[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var b,c=0,d=this.spaces.length;c<d;c++)if(b=this.spaces[c],b.id==a)return b;return{update:function(){},w:0}};var h;a.DescartesApp.prototype.getState=function(){var a,b="",c=this.evaluator.variables,h;for(h in c)c.hasOwnProperty(h)&&(a=c[h],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=h&&"pi"!=h&&"e"!=h&&"Infinity"!=h&&"-Infinity"!=h&&
"object"!=typeof a)&&(b=""!=b?b+"\n"+h+"="+a:h+"="+a));var c=this.evaluator.vectors,e;for(e in c)c.hasOwnProperty(e)&&(a=c[e],b=b+"\n"+e+"="+d(a));e=this.evaluator.matrices;for(var g in e)e.hasOwnProperty(g)&&(a=e[g],b=b+"\n"+g+"="+d(a));return b};a.DescartesApp.prototype.setState=function(a,b){for(var c=a.split("\n"),d,e,g=0,h=c.length;g<h;g++)d=c[g].split("="),2<=d.length&&(e=eval(d[1]),-1!=d[1].indexOf("[[")?(this.evaluator.matrices[d[0]]=e,this.evaluator.matrices[d[0]].rows=e.length,this.evaluator.matrices[d[0]].cols=
e[0].length):-1!=d[1].indexOf("[")?(this.evaluator.vectors[d[0]]=e,this.evaluator.variables[d[0]+".long"]=e.length):this.evaluator.variables[d[0]]=e);b||this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,b=0,c="",d=0,e=this.controls.length;d<e;d++)"textfield"==this.controls[d].gui&&this.controls[d].evaluate&&(a++,b+=this.controls[d].ok,this.controls[d].value=""==this.controls[d].value?"''":this.controls[d].value,c+=" \\n "+this.controls[d].id+"="+this.controls[d].value+"|"+
this.controls[d].ok);return"questions="+a+" \\n correct="+b+" \\n wrong="+(a-b)+c};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,b=0,c=a.length;b<c;b++)"textfield"==a[b].gui&&a[b].evaluate&&a[b].changeValue(a[b].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,b=this.saveState.length;a<b;a++)this.evaluator.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||{}),descartesJS=function(a){function d(){var a=document.getElementById("StyleDescartesApps");
a&&a.parentNode.removeChild(a);a=document.createElement("style");a.id="StyleDescartesApps";a.type="text/css";a.setAttribute("rel","stylesheet");a.innerHTML="applet.DescartesJS {display:none;} applet {display:none;} ajs.DescartesJS {display:none;} ajs {display:none;}";document.head.appendChild(a)}function h(d){a.getFeatures();if(a.hasCanvasSupport){window.scrollTo(0,10);d=document.getElementsByTagName("*");for(var b=[],c=0,h=d.length;c<h;c++)"DescartesAppContainer"==d[c].className&&b.push(d[c]);c=
0;for(h=b.length;c<h;c++)b[c].parentNode.removeChild(b[c]);b=document.getElementsByTagName("applet");c=document.getElementsByTagName("ajs");d=[];for(var e=0,g=b.length;e<g;e++)h=b[e],(h.getAttribute("code").match("DescartesJS")||h.getAttribute("code").match("descinst.DescartesWeb2_0.class")||h.getAttribute("code").match("Descartes")||h.getAttribute("code").match("Arquimedes")||h.getAttribute("code").match("Discurso"))&&d.push(h);e=0;for(g=c.length;e<g;e++)h=c[e],(h.getAttribute("code").match("DescartesJS")||
h.getAttribute("code").match("descinst.DescartesWeb2_0.class")||h.getAttribute("code").match("Descartes")||h.getAttribute("code").match("Arquimedes")||h.getAttribute("code").match("Discurso"))&&d.push(h);b=0;for(c=d.length;b<c;b++)a.apps.push(new a.DescartesApp(d[b])),d[b].className="DescartesJS";window.addEventListener("resize",a.onResize);window.scrollTo(0,2);document.body.setAttribute("tabIndex",1E6)}else document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:block;} applet {display:block;} ajs.DescartesJS {display:block;} ajs {display:block;}"}
if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};window.hasOwnProperty("debugDescartesJS")&&debugDescartesJS||d();a.onResize=function(d){for(var b=0,c=a.apps.length;b<c;b++){d=a.apps[b].spaces;for(var h=0,e=d.length;h<e;h++)d[h].findOffset()}};a.receiveMessage=function(d){if(0<a.apps.length){var b=d.data;if(b)if("set"===b.type)a.apps[0].evaluator.setVariable(b.name,b.value);else if("update"===b.type)a.apps[0].update();else if("exec"===b.type){d=a.apps[0].evaluator.getFunction(b.name);
var c=[];""!==b.value&&(c=b.value.toString().split(","));d&&d.apply(a.apps[0].evaluator,c)}else"isResizeNeeded"===b.type?d.source.postMessage({type:"doResize"},"*"):"doResize"===b.type&&0<a.apps.length&&a.apps[0].adjustSize()}};void 0==a.loadLib&&(a.loadLib=!0,window.addEventListener("load",h),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||{});
