/*
 Joel Espinosa Longi
 j.longi@gmail.com
 https://github.com/jlongi/DescartesJS
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-11-07
*/
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(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,m=c.length-1;0<=m;m--)e=c[m],a.drawImage(e.getScreenshot(),b.offsetLeft+e.x,b.offsetTop+e.y)}if(a.loadLib)return a;var h=2*Math.PI,b=360/h,c=h/360,n=Math.floor,e,g,r,l,j,p,q,u,k,s;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*b};a.degToRad=function(a){return a*c};a.convertFont=function(a){if(""==a)return a;e=a.split(",");g="";"bold"==e[1].toLowerCase()?g+="Bold ":"italic"==e[1].toLowerCase()||"italics"==e[1].toLowerCase()?g+="Italic ":"bold+italic"==e[1].toLowerCase()&&(g+="Italic Bold ");g+=e[2]+"px ";r=e[0].split(" ")[0].toLowerCase();return g="serif"===r||"times new roman"===r||"timesroman"===r||"times"===r?g+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===
r||"arial"===r||"helvetica"===r?g+"Arial, Helvetica, 'Droid Sans', Sans-serif":g+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};a.drawLine=function(a,b,c,e,m,g,d){a.lineWidth=d||1;a.strokeStyle=g||"black";g=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(n(b)+g,n(c)+g);a.lineTo(n(e)+g,n(m)+g);a.stroke()};a.getColor=function(a,b){if("string"==typeof b)return b;l=a.evalExpression(b);j=n(255*l[0][0]);p=n(255*l[0][1]);q=n(255*l[0][2]);u=1-l[0][3];return"rgba("+j+","+p+","+q+","+u+")"};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"));
var c,e,m,g,d,h,j,n,k;Number.prototype.originalToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(a){a=a?a:0;a=0>a?0:parseInt(a);c=this.toString();d=c.indexOf("e");if(-1!==d)if(h=c.split("e"),n="-"===h[0][0]?"-":"",j="-"===n?parseFloat(h[0].substring(1)).originalToFixed(11):parseFloat(h[0]).originalToFixed(11),k=parseInt(h[1]),e=j.indexOf("."),0>e+k){e=0>e?1:e;var b=n+"0.",f;f=Math.abs(e+k);f=Array(f+1).join("0");c=b+f+j.replace(".","")}else j=j.replace(".",""),c=n+j+Array(k-j.length+
2).join("0");e=c.indexOf(".");m="";if(-1===e)0<a&&(m="."),m+=Array(a+1).join("0"),c+=m;else if(g=c.length-e-1,g>=a)11>=a&&(c=parseFloat(c).originalToFixed(a)),c=0<a?c.substring(0,e+1+a):c.substring(0,e);else{b=0;for(a-=g;b<a;b++)m+="0";c+=m}return c}};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],k=a.pageX,s=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(k=a.pageX,s=a.pageY):(k=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,s=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:k,y:s}};a.getTextWidth=function(b,
c){a.ctx.font=c;return Math.round(a.ctx.measureText(b).width)};var m=document.createElement("span");m.appendChild(document.createTextNode("\u00c1p"));var t=document.createElement("div");t.setAttribute("style","display: inline-block; w: 1px; h: 0px;");var v=document.createElement("div");v.setAttribute("style","margin: 0; padding: 0;");v.appendChild(m);v.appendChild(t);var y={};a.getFontMetrics=function(a){if(y[a])return y[a];m.setAttribute("style","font: "+a+"; margin: 0px; padding: 0px;");document.body.appendChild(v);
var b={ascent:0,descent:0,h:0,baseline:0};v.getBoundingClientRect?(t.style.verticalAlign="baseline",b.ascent=t.offsetTop-m.offsetTop,b.h=v.getBoundingClientRect().height||0):(t.style.verticalAlign="baseline",b.ascent=t.offsetTop-m.offsetTop,t.style.verticalAlign="bottom",b.h=t.offsetTop-m.offsetTop);b.descent=b.h-b.ascent;b.baseline=b.ascent;document.body.removeChild(v);return y[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"),m=new Image;if(b){e.setAttribute("width",b.width);e.setAttribute("height",b.height);for(var g=e.getContext("2d"),h=0,j=b.spaces.length;h<j;h++)c=b.spaces[h],"R2"===c.type&&(g.drawImage(c.backgroundCanvas,c.x,c.y),g.drawImage(c.canvas,c.x,c.y),f(g,c.container,c.ctrs));0<b.northSpace.controls.length&&d(g,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&d(g,b.southSpace.container,b.southSpace);0<b.eastSpace.controls.length&&
d(g,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&d(g,b.westSpace.container,b.westSpace);m.src=e.toDataURL("image/png")}return m};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>");
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,f;a._externalFilesContent={};a.openExternalFile=function(h){if(a._externalFilesContent[h])return a._externalFilesContent[h];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(n){try{b=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){b=
!1}}f=b;f.open("GET",h,!1);try{f.send(null),d=f.responseText,d.match(String.fromCharCode(65533))&&(f.open("GET",h,!1),f.overrideMimeType("text/plain; charset=ISO-8859-1"),f.send(null),d=f.responseText)}catch(g){console.log("Error to load the file :",h),d=null}return d};a.addExternalFileContent=function(d,b){a._externalFilesContent[d]=b};return a}(descartesJS||{}),descartesJS=function(a){function d(a){a=a.substring(0,a.indexOf("--radial--"));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 f(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 h(a,
b,c){b=parseFloat(b);r=a.expr[0];l=a.expr[1];j=c.evalExpression(r.expr);p=c.evalExpression(l.expr);q="("==r.type;u="["==r.type;k=")"==l.type;s="]"==l.type;return(q&&b>j||u&&b>=j)&&(k&&b<p||s&&b<=p)?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,n,e,g,r,l,j,p,q,u,k,s;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,h=a.length;g<h;g++){n=a[g].split("&");e=[];for(var j=0,k=n.length;j<k;j++)c=n[j],-1!==c.indexOf(",")&&("("===c.charAt(0)||"["===c.charAt(0))&&(")"===c.charAt(c.length-1)||"]"===c.charAt(c.length-1))?e.push(f(c,b)):e.push(d(c));
a[g]=e}return a};a.escorrecto=function(c,e,d,j){d=d||a.externalEvaluator;j=j||a.buildRegularExpresionsPatterns(c,d);e=b(e);c=0;for(var k=j.length;c<k;c++){n=j[c];g=!0;for(var f=0,r=n.length;f<r;f++)g=n[f].regExp?g&&!!e.match(RegExp(b(n[f].regExp),"i")):g&&h(n[f],e,d);if(g)return 1}return 0};a.esCorrecto=function(e,d,j,k){j=j||a.externalEvaluator;k=k||a.buildRegularExpresionsPatterns(e,j);e=0;for(var f=k.length;e<f;e++){n=k[e];g=!0;for(var r=0,l=n.length;r<l;r++)(c=n[r].regExp)?(n[r].ignoreAcents&&
(d=b(d),c=b(c)),n[r].ignoreCaps&&(d=d.toLowerCase(),c=b(c).toLowerCase()),g=g&&!!d.match(c)):g=g=g&&h(n[r],d,j);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,f,h,b,c,n,e,g,r,l;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]){h=[];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)),h.push(this.evaluator.parser.parse(b[g]))):h.push(this.evaluator.parser.parse((c/255).toString()));this.rExpr=h[0];this.gExpr=h[1];this.bExpr=h[2];this.aExpr=h[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){n=
[];for(var b=r=g=e=0,c=a.length;b<c;b++)l=a.charAt(b),"("===l?e++:")"===l?e--:"["===l?g++:"]"===l?g--:","===l&&(0===e&&0===g)&&(n.push(a.substring(r,b)),r=b+1);n.push(a.substring(r));return n};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){f=this.evaluator;this.r=d(255*f.evalExpression(this.rExpr));this.g=d(255*f.evalExpression(this.gExpr));this.b=d(255*f.evalExpression(this.bExpr));this.a=1-f.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,f=document.createElement("meta");f.setAttribute("http-equiv","X-UA-Compatible");f.setAttribute("content","chrome=1");d.appendChild(f);f=document.createElement("meta");f.setAttribute("name","viewport");f.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
d.appendChild(f);f=document.createElement("meta");f.setAttribute("name","apple-mobile-web-app-capable");f.setAttribute("content","yes");d.appendChild(f);f=document.createElement("meta");f.setAttribute("name","apple-mobile-web-app-status-bar-style");f.setAttribute("content","black-translucent");d.appendChild(f);(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,f=Math.floor,h=Math.random,b=Math.round,c=Math.abs,n=String.fromCharCode,e,g,r,l,j,p,q,u,k,s;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]=n(this.alfanum(f(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=f(31*h());this.key=this.getKey(g);l=n(this.alfanum(g));return l+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;p=Array(3*a.length);for(var c=0,e=a.length;c<e;c++)k=256*f(a[c]+128)+b(255*h())+65536*b(255*h()),s=f((k<<this.shift(c))/256),p[3*c]=this.alfanum(s%32),p[3*c+1]=this.alfanum(s/32%
32),p[3*c+2]=this.alfanum(s/1024%32);return p};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;q=Array(a.length/3);for(var b=0,c=q.length;b<c;b++)s=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),k=f(256*s>>this.shift(b)),u=f(k/256)%256-128,0>u&&(u+=256),q[b]=u;return q};a.Krypto.prototype.alfanum=function(a){a=f(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){l=Array(a.length);for(var b=0,c=a.length;b<c;b++)l[b]=a.charCodeAt(b);return l};a.Krypto.prototype.bytesToString=function(a){for(var b=0,c=a.length;b<c;b++)a[b]=n(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){r=this.key.charCodeAt(a%this.key.length);l=this.numalfa(r);j=f(l/2%8);0==j&&(j=4);return j};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,f){this.parent=d;var h=d.evaluator,b=h.parser,c=new a.Auxiliary(d);this.delay=f.delay?b.parse(f.delay):b.parse("60");this.loop=f.loop?f.loop:!1;this.auto=void 0==f.auto?!0:f.auto;this.controls=f.controls;this.init=c.splitInstructions(b,f.init);this.doExpr=c.splitInstructions(b,f.doExpr);f.whileExpr&&(this.whileExpr=b.parse(f.whileExpr));var n=this,e,g,r=n.doExpr.length;this.animationExec=
function(){for(g=0;g<r;g++)h.evalExpression(n.doExpr[g]);n.parent.update();n.playing&&(0<h.evalExpression(n.whileExpr)||n.loop)?(e=h.evalExpression(n.delay),n.timer=setTimeout(n.animationExec,10>e?10:e)):(n.stop(),n.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,f=this.init.length;a<f;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a){this.parent=a;this.evaluator=this.parent.evaluator};a.Action.prototype.execute=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Message=function(d,f){a.Action.call(this,d,f);this.parameter=(f||"").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,f){a.Action.call(this,d,f);var h=this.evaluator,b=h.parser;f=(f||"").replace(/&squot;/g,"'");f=f.replace(/;/g,"\\n");f=f.split("\\n")||[""];for(var c=[],n,e=0,g=f.length;e<g;e++)(n=b.parse(f[e],!0))&&c.push(n);g=c.length;this.execute=function(){for(e=0;e<g;e++)h.evalExpression(c[e])}};
a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(d,f){a.Action.call(this,d,f);this.parameter=f;this.target="_blank";var h=this.parameter.indexOf("target");-1!=h&&(this.target=this.parameter.substring(h),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,h-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,f){a.Action.call(this,d,f);this.parameter=f;this.target=
"_blank";var h=this.parameter.indexOf("target");-1!=h&&(this.target=this.parameter.substring(h),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,h-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,f){a.Action.call(this,d,f);f||(this.urlAbout=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+f)};a.extend(a.About,a.Action);a.About.prototype.execute=function(){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,f){a.Action.call(this,d,f)};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,f){a.Action.call(this,d,f)};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,f){a.Action.call(this,d,f)};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,f){a.Action.call(this,d,f)};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,f){a.Action.call(this,d,f)};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(f,h){a.Action.call(this,f,h);this.filenameExpr=h&&h.match(d)?this.evaluator.parser.parse("'"+h.match(d)+"'"):this.evaluator.parser.parse(h)};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,f;a.Auxiliary.prototype.splitInstructions=function(a,b){f=[];b=b?b.split(";"):[""];for(var c=0,n=b.length;c<n;c++)(d=a.parse(b[c],!0))&&f.push(d);return f};a.Auxiliary.prototype.getPrivateVariables=function(a,b){f=[];b=b?b.split(/;|,/):[""];for(var c=0,n=b.length;c<n;c++)(d=a.parse(b[c],!0))&&
f.push(d);c=0;for(n=f.length;c<n;c++)f[c]="asign"===f[c].type?f[c].childs[0].value:"identifier"===f[c].type?f[c].value:"";return f};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,f){a.Auxiliary.call(this,d,f);var h=
this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=h.parse(this.expresionString))&&h.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"),f=document.createElement("label");f.appendChild(document.createTextNode("___"+this.id+"=___"));var h=document.createElement("input");h.value=this.expresionString;
h.disabled=!this.editable;a.appendChild(f);a.appendChild(h);var b=this,c=b.evaluator.parser;h.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,f){a.Auxiliary.call(this,d,f);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,f,h;a.Vector=function(b,c){d=b.evaluator;f=d.parser;this.size=f.parse("3");a.Auxiliary.call(this,b,c);this.expresion=this.expresion.split(";");this.parseFile=f.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var b=this.expresion;d=this.evaluator;
f=d.parser;this.oldFile=this.file;if(h=d.evalExpression(this.parseFile))this.file=h;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 n=[],e=0,g=c.length;e<g;e++)""!=c[e]&&n.push(c[e]);c=n}null==c||1==c.length&&""==c[0]?this.size=0:(b=c,this.size=null);null===this.size&&(this.size=f.parse(b.length+""))}c=[];e=0;for(g=b.length;e<g;e++)(n=
f.parse(b[e],!0))&&"asign"!=n.type&&(n=f.parse(this.id+"["+e+"]="+b[e],!0)),c.push(n);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,f){var h=d.evaluator,b=h.parser;this.rows=b.parse("3");this.columns=b.parse("3");a.Auxiliary.call(this,d,f);this.expresion=this.splitInstructions(b,
this.expresion);var b=h.evalExpression(this.rows),c=h.evalExpression(this.columns),n=[];n.type="matrix";for(var e,g=0;g<c;g++){e=[];for(var r=0,l=b;r<l;r++)e.push(0);n[g]=e}h.matrices[this.id]=n;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,f=a.evalExpression(this.rows),h=a.evalExpression(this.columns);a.setVariable(this.id+".filas",f);a.setVariable(this.id+".columnas",h);var b=a.matrices[this.id];b.rows=f;b.cols=h;f=0;for(h=this.expresion.length;f<
h;f++)a.evalExpression(this.expresion[f])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(d,f){a.Auxiliary.call(this,d,f);var h=this.evaluator,b=h.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 n=this;this.functionExec=function(){this.iterations=0;if(n.numberOfParams<=arguments.length){for(var b=[],c=0,d=n.privateVars.length;c<d;c++)b.push(h.getVariable(n.privateVars[c])),h.setVariable(n.privateVars[c],0);for(var f=[],c=0,d=n.params.length;c<d;c++)f[c]=h.getVariable(n.params[c]),h.setVariable(n.params[c],arguments[c]);c=0;for(d=n.init.length;c<d;c++)h.evalExpression(n.init[c]);do{c=0;for(d=n.doExpr.length;c<
d;c++)h.evalExpression(n.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<h.evalExpression(n.whileExpr));var j=h.evalExpression(n.expresion);a.rangeOK=h.evalExpression(n.domain);c=0;for(d=n.params.length;c<d;c++)h.setVariable(n.params[c],f[c]);c=0;for(d=n.privateVars.length;c<d;c++)h.setVariable(n.privateVars[c],b[c]);return j}return 0};h.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,f){a.Auxiliary.call(this,d,f);var h=this.evaluator;this.parseExpressions(h.parser);this.algorithmExec=function(){for(var a=this.iterations=0,c=this.init.length;a<c;a++)h.evalExpression(this.init[a]);do{a=0;for(c=this.doExpr.length;a<c;a++)h.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<h.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,f){a.Auxiliary.call(this,d,f);var h=this.evaluator;this.condition=h.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=
function(){0<h.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<h.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<h.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,f,h,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;f=d.evalExpression(this.family_interval);this.familyInf=f[0][0];this.familySup=f[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();h=d.getVariable(this.family);if(0<=this.fSteps)for(var f=0,l=this.fSteps;f<=l;f++)d.setVariable(this.family,this.familyInf+f*this.family_sep),0<d.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,c));d.setVariable("_Text_H_",0);d.setVariable(this.family,h)};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,h,f,j,p,q,u,k,s){if("rtfNode"===e.type)a.fillStyle=f.getColor(),a.strokeStyle=f.getColor(),a.textBaseline="alphabetic",e.draw(a,g,h,u,k,p,s,f.getColor());else{"simpleText"===
e.type&&(e=e.toString(u,k).split("\\n"));g+=j.match("Arial")?-2:j.match("Times")?-2:0;d=this.evaluator;a.fillStyle=f.getColor();a.font=j;a.textAlign=p;a.textBaseline=q;this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=3);c=1.2*this.fontSize||0;f=0;for(j=e.length;f<j;f++)b=e[f],this.border&&(a.lineJoin="round",a.strokeText(b,g,h+c*f)),a.fillText(b,g,h+c*f)}};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,f,l;d<b.length;)f=b.charAt(d),l=b.charAt(d-1),"["===f&&"\\"===l?(this.textElements.push(b.substring(e,d-1)+"["),this.textElementsMacros.push("'"+b.substring(e,d-1)+"['"),e=d+1):"]"===f&&"\\"===l?(this.textElements.push(b.substring(e,d-1)+"]"),this.textElementsMacros.push("'"+b.substring(e,d-1)+"]'"),e=d+1):"["===f&&-1===g?(this.textElements.push(b.substring(e,
d)),this.textElementsMacros.push("'"+b.substring(e,d)+"'"),e=d,g++):"["===f?g++:"]"===f&&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,f;a.SimpleText.prototype.toString=function(h,b){d="";for(var c=0,n=this.textElements.length;c<n;c++)"string"===
typeof this.textElements[c]?d+=this.textElements[c]:(f=this.evaluator.evalExpression(this.textElements[c])[0][0],""!==f&&("string"===typeof f?d+=f:(f=parseFloat(f),f=b?f.toFixed(h):a.removeNeedlessDecimals(f.toFixed(h)),d+=f.toString().replace(".",this.parent.decimal_symbol))));return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,f,h,b,c,n,e,g,r,l,j,p,q,u,k,s,m,t,v,y,B,z,D,E,A,x,F;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();p=new a.R2;q=new a.R2;u=new a.R2;m=new a.R2;k=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")?(this.funExpr=c,this.of_y=!1,this.drawAux=
this.drawAuxFun):"identifier"==c.type&&"y"==c.value&&!b.contains("y")?(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):"identifier"==b.type&&"x"==b.value&&!c.contains("x")?(this.funExpr=c,this.of_y=!0,this.drawAux=this.drawAuxFun):"identifier"==c.type&&("x"==c.value&&!b.contains("x"))&&(this.of_y=!0,this.funExpr=c,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 G;a.Equation.prototype.update=function(){G=parseInt(this.evaluator.evalExpression(this.width));G!==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){f=this.evaluator;this.getFamilyValues();tempParam=f.getVariable(this.family);if(0<=this.fSteps)for(var e=0,d=this.fSteps;e<=d;e++)f.setVariable(this.family,this.familyInf+e*this.family_sep),this.update(),this.drawAux(a,b,c);f.setVariable(this.family,tempParam)};a.Equation.prototype.drawTrace=
function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(J,H,w){J.lineWidth=1;f=this.evaluator;h=f.parser;b=this.space;c=f.evalExpression(this.width);J.fillStyle=w.getColor();J.translate(-parseInt(c/2),-parseInt(c/2));n=h.getVariable("x");e=h.getVariable("y");g=b.w;r=b.h;l=g/9;3>l&&(l=3);j=r/7;3>j&&(j=3);d=[];p.set(0,0);q.set(0,0);u.set(0,0);for(F=parseInt(j/2);F<r;F+=j)for(x=parseInt(l/2);x<g;x+=l)if(this.abs_coord?(m.set(x,F),s=this.newt.findZero(m),
f.setVariable("x",s.x),f.setVariable("y",s.y),k.set(s.x,s.y)):(m.set(b.getRelativeX(x),b.getRelativeY(F)),s=this.newt.findZero(m),f.setVariable("x",s.x),f.setVariable("y",s.y),k.set(b.getAbsoluteX(s.x),b.getAbsoluteY(s.y))),t=k.ix(),v=k.iy(),!(0>t||t>=g||0>v||v>=r||d[t+v*b.w]))if(d[t+v*b.w]=!0,a.rangeOK&&f.evalExpression(this.drawif)&&J.drawImage(this.auxCanvas,t,v),p.x=s.x,p.y=s.y,q.x=s.x,q.y=s.y,y=this.newt.getUnitNormal(),!(0==y.x&&0==y.y)){y.rotL90();u.x=y.x;u.y=y.y;z=B=0;for(D=!1;2>z;){D&&(u.x=
-y.x,u.y=-y.y,s.x=p.x,s.y=p.y,q.x=s.x,q.y=s.y,this.abs_coord?k.set(s.x,s.y):k.set(b.getAbsoluteX(s.x),b.getAbsoluteY(s.y)),t=k.ix(),v=k.iy(),D=!1,B=0);this.abs_coord?(s.x+=u.x,s.y+=u.y):(s.x+=u.x/b.scale,s.y+=u.y/b.scale);s=this.newt.findZero(s);f.setVariable("x",s.x);f.setVariable("y",s.y);u.x=s.x-q.x;u.y=s.y-q.y;u.normalize();if(0==u.x&&0==u.y)break;q.x=s.x;q.y=s.y;this.abs_coord?k.set(s.x,s.y):k.set(b.getAbsoluteX(s.x),b.getAbsoluteY(s.y));E=parseInt(k.ix());A=parseInt(k.iy());if(E!=t||A!=v)if(H=
t,w=v,t=E,v=A,0<=t&&t<g&&0<=v&&v<r){B=0;var G=d[t+v*b.w];d[t+v*b.w]=!0;for(var C=1;8>C;C++){var I=H+Math.round((t-H)*C/8),L=w+Math.round((v-w)*C/8);0<=I&&(I<g&&0<=L&&L<r)&&(d[I+L*b.w]=!0)}a.rangeOK&&f.evalExpression(this.drawif)&&J.drawImage(this.auxCanvas,t,v);if(G)break}else D=!0,z++;else 4<++B&&(D=!0,z++)}}J.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,d,g,m){for(var h=this.evaluator.getVariable(c),j=m/2,f=0;1E-12<Math.abs(j);){var k=this.evaluator.getVariable(c),n=this.evaluator.getVariable(c)+j;this.evaluator.setVariable(c,
n);var r=!0,l=g;g=this.evaluator.evalExpression(this.funExpr);this.evaluator.setVariable(e,g);if(0<this.evaluator.evalExpression(b)){var s=new a.R2(Math.min(l,g),Math.max(l,g)),q=0,q=0<m?this.Singularity(Math.abs(j),c,d,k,l,n,g,s):this.Singularity(Math.abs(j),c,d,n,g,k,l,s);0<q&&(r=!1)}else r=!1;r?f+=j:this.evaluator.setVariable(c,k);j/=2}this.evaluator.setVariable(c,h);return new a.R2(f/Math.abs(m),g)};a.Equation.prototype.extrapolateOnSingularity=function(b,c,e,d,g,m){d=this.evaluator.getVariable(c);
for(var h=m/2,j=0,f=g;1E-12<Math.abs(h);){this.evaluator.setVariable(this.evaluator.getVariable(c)+h);var k=!0;0<this.evaluator.evalExpression(b)?(f=this.evaluator.evalExpression(this.funExpr),this.evaluator.setVariable(e,f),0>=this.evaluator.evalExpression(b)&&(k=!1)):k=!1;k?j+=h:this.evaluator.setVariable(this.evaluator.getVariable(c)-h);h/=2}if(0==j){h=m/2;j=m;for(f=g;1E-12<Math.abs(h);)this.evaluator.setVariable(this.evaluator.getVariable(c)-h),k=!0,0<this.evaluator.evalExpression(b)?f=this.evaluator.evalExpression(this.funExpr):
k=!1,k?j+=-h:this.evaluator.setVariable(this.evaluator.getVariable(c)+h),h/=2}this.evaluator.setVariable(d);return new a.R2(j/Math.abs(m),f)};a.Equation.prototype.Singularity=function(a,b,c,e,d,g,m,h){if(e>=g)return 2;var j=this.evaluator.getVariable(b),f=0;if(1E-12>Math.abs(g-e)||1E-8>Math.abs(g-e)&&Math.abs(m-d)>Math.abs(a))return this.evaluator.setVariable(b,j),1;var k=(e+g)/2;this.evaluator.setVariable(b,k);var n=this.evaluator.evalExpression(this.funExpr);if(Math.abs(m-d)>a){this.evaluator.setVariable(b,
e-1E-6);var r=this.evaluator.evalExpression(this.funExpr),r=(d-r)/1E-6;this.evaluator.setVariable(b,g+1E-6);var l=(this.evaluator.evalExpression(this.funExpr)-m)/1E-6,s=(m-d)/(g-e);if(10>Math.abs(l)||10>Math.abs(r))if((0<=l&&0<=r||0>=l&&0>=r)&&8*Math.abs(l)<Math.abs(s))return this.evaluator.setVariable(b,j),2}h.x<=n&&n<=h.y||(this.evaluator.setVariable(b,k),h.x=Math.min(d,n),h.y=Math.max(d,n),e=this.Singularity(a/2,b,c,e,d,k,n,h),this.evaluator.setVariable(b,g),h.x=Math.min(m,n),h.y=Math.max(m,n),
a=this.Singularity(a/2,b,c,k,n,g,m,h),f=Math.max(e,a));this.evaluator.setVariable(b,j);return f};a.Equation.prototype.drawAuxFun=function(b){n=this.evaluator.parser.getVariable("x");e=this.evaluator.parser.getVariable("y");var c="x",g="y";this.of_y&&(c="y",g="x");var d=this.drawif,m=this.evaluator.evalExpression(this.width),h=!1,j=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),j=this.of_y?j.ix():j.iy(),f=0,k=0,r=0,l=1/this.space.scale,s=l*(this.of_y?-this.space.h+(this.space.h/
2+this.space.Oy):-(this.space.w/2+this.space.Ox)),f=0;this.abs_coord&&(s=0,l=1);for(var q=this.of_y?this.space.h:this.space.w;k<q;){var p=!0,u=0;this.evaluator.setVariable(c,s);var v=this.evaluator.evalExpression(this.funExpr);if(isNaN(v))p=!1;else{this.evaluator.setVariable(g,v);if(0<this.evaluator.evalExpression(this.drawif)&&a.rangeOK){if(h){var u=Math.min(f,v),t=Math.max(f,v),t=new a.R2(u,t),u=this.Singularity(l,c,0,s-l,f,s,v,t);0===u?(f<=v?(f=t.x,v=t.y):(v=t.x,f=t.y),u=this.of_y?this.XX(m,f,
this.abs_coord):this.YY(m,f,this.abs_coord),f=this.abs_coord?Math.round(v):this.of_y?this.XX(m,v,this.abs_coord):this.YY(m,v,this.abs_coord),this.fillM&&f>j&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(j+1,this.space.h-k+0.5),b.lineTo(f,this.space.h-k+0.5)):(b.moveTo(k+0.5,j+1),b.lineTo(k+0.5,f)),b.stroke()),this.fillP&&f<j&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(j-1,this.space.h-k+0.5),b.lineTo(f,this.space.h-
k+0.5)):(b.moveTo(k+0.5,j-1),b.lineTo(k+0.5,f)),b.stroke()),b.lineWidth=m,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(u+0.5,this.space.h-r),b.lineTo(f+0.5,this.space.h-k)):(b.moveTo(r+0.5,u),b.lineTo(k+0.5,f)),b.stroke()):(1===u&&(this.evaluator.setVariable(c,s-l),r=this.extrapolate(d,c,g,0,f,l),this.YY(m,r.y,this.abs_coord),this.evaluator.setVariable(c,s),r=this.extrapolate(d,c,g,0,v,-l),this.YY(m,r.y,this.abs_coord)),this.YY(m,v,this.abs_coord))}else r=this.extrapolateOnSingularity(d,
c,g,0,v,-l),this.YY(m,r.y,this.abs_coord),this.YY(m,v,this.abs_coord);f=v}else p=!1;h&&!p&&(this.evaluator.setVariable(c,s-l),this.evaluator.setVariable(g,f),r=this.extrapolate(d,c,g,0,f,l),this.YY(m,r.y,this.abs_coord),this.evaluator.setVariable(c,s))}h=p;s+=l;r=k++}this.evaluator.parser.setVariable("x",n);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 f,h,b,c,n,e,g,r,l,j,p;a.Curve.prototype.update=function(){f=this.evaluator;h=f.evalExpression(this.parameter_interval);this.paraInf=h[0][0];this.paraSup=h[0][1];this.pSteps=f.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(h,u,k){f=this.evaluator;b=this.space;c=d(f.evalExpression(this.width));h.lineWidth=0<c?c:1E-6;h.lineCap="round";h.lineJoin="round";h.strokeStyle=k.getColor();n=f.getVariable(this.parameter);h.beginPath();f.setVariable(this.parameter,this.paraInf);e=f.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(f.evalExpression(this.rotateExp)),r=Math.cos(g),l=Math.sin(g),j=this.exprX*r-this.exprY*l,p=this.exprX*l+this.exprY*r,this.exprX=j,this.exprY=p);h.moveTo(this.exprX+0.5,this.exprY+0.5);for(k=1;k<=this.pSteps;k++)f.setVariable(this.parameter,this.paraInf+k*this.paraSep),e=f.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&&(j=this.exprX*r-this.exprY*
l,p=this.exprX*l+this.exprY*r,this.exprX=j,this.exprY=p),h.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&(h.fillStyle=u.getColor(),h.fill());h.stroke();f.setVariable(this.parameter,n)};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,f=Math.round,h,b,c,n,e,g,r,l,j,p,q,u,k;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(){h=this.evaluator;c=h.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(n=a.degToRad(h.evalExpression(this.rotateExp)),e=Math.cos(n),g=Math.sin(n),r=this.exprX*
e-this.exprY*g,l=this.exprX*g+this.exprY*e,this.exprX=r,this.exprY=l);q=h.evalExpression(this.range);this.rangeInf=q[0][0];this.rangeMax=q[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){h=this.evaluator;b=this.space;u=Math.ceil(h.evalExpression(this.size)-0.4);a.fillStyle=e.getColor();a.beginPath();this.rangeInf>this.rangeMax&&
(k=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=k);for(var g=h.getVariable("n"),n=this.rangeInf,r=this.rangeMax;n<=r;n++)h.setVariable("n",n),c=h.evalExpression(this.expresion),this.exprX=c[0][0],this.exprY=c[0][1],j=this.abs_coord?f(this.exprX):f(b.getAbsoluteX(this.exprX)),p=this.abs_coord?f(this.exprY):f(b.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(j,p,u,0,d,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,j+u,p-u,this.color,this.font,"start","alphabetic",
h.evalExpression(this.decimals),this.fixed,!0);h.setVariable("n",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI,f=Math.round,h,b,c,n,e,g,r,l,j,p,q,u;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(){h=this.evaluator;c=h.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(n=a.degToRad(h.evalExpression(this.rotateExp)),
e=Math.cos(n),g=Math.sin(n),r=this.exprX*e-this.exprY*g,l=this.exprX*g+this.exprY*e,this.exprX=r,this.exprY=l)};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){h=this.evaluator;b=this.space;q=f(h.evalExpression(this.size));u=q+1;a.fillStyle=c.getColor();j=this.abs_coord?f(this.exprX):f(b.getAbsoluteX(this.exprX));p=this.abs_coord?f(this.exprY):
f(b.getAbsoluteY(this.exprY));a.beginPath();a.arc(j,p,q,0,d,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,j+u+1,p-u,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=Math.round,f=2*Math.PI,h,b,c,n,e,g,r,l,j,p,q,u,k,s,m,t,v,y;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(){h=this.evaluator;c=h.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){n=a.degToRad(h.evalExpression(this.rotateExp));e=Math.cos(n);g=Math.sin(n);b=0;for(d=this.endPoints.length;b<d;b++)r=this.endPoints[b].x*e-this.endPoints[b].y*g,l=this.endPoints[b].x*g+this.endPoints[b].y*e,this.endPoints[b].x=r,this.endPoints[b].y=l}};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){h=this.evaluator;b=this.space;j=d(h.evalExpression(this.width));a.lineWidth=0<j?j:1E-6;k=h.evalExpression(this.size);0>k&&(k=0);a.fillStyle=c.getColor();a.strokeStyle=e.getColor();a.lineCap="round";p=10+a.lineWidth;s=0==a.lineWidth%2?0:0.5;this.abs_coord?(m=d(this.endPoints[0].x),t=d(this.endPoints[0].y),v=d(this.endPoints[1].x),y=d(this.endPoints[1].y)):
(m=d(b.getAbsoluteX(this.endPoints[0].x)),t=d(b.getAbsoluteY(this.endPoints[0].y)),v=d(b.getAbsoluteX(this.endPoints[1].x)),y=d(b.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(m+s,t+s);a.lineTo(v+s,y+s);a.stroke();a.beginPath();a.arc(m,t,k,0,f,!0);a.arc(v,y,k,0,f,!0);a.fill();this.text!=[""]&&(q=parseInt((m+v)/2)-3,u=parseInt((t+y)/2)+3,this.uber.drawText.call(this,a,this.text,q+p,u-p,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=Math.floor,f=Math.round,h,b,c,n,e,g,r,l,j,p,q,u,k,s,m,t,v,y;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(){h=this.evaluator;b=h.evalExpression(this.expresion);this.endPoints=[];for(var d=0,m=b.length;d<m;d++)this.endPoints[d]=
{x:b[d][0],y:b[d][1]};if(this.rotateExp){c=a.degToRad(h.evalExpression(this.rotateExp));n=Math.cos(c);e=Math.sin(c);d=0;for(m=this.endPoints.length;d<m;d++)g=this.endPoints[d].x*n-this.endPoints[d].y*e,r=this.endPoints[d].x*e+this.endPoints[d].y*n,this.endPoints[d].x=g,this.endPoints[d].y=r}};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){h=this.evaluator;l=this.space;h.evalExpression(this.size);q=h.evalExpression(this.width);0>q&&(q=0);u=Math.ceil(q/2);k=l.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);s=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?(m=f(this.endPoints[0].x),t=f(this.endPoints[0].y),v=f(this.endPoints[1].x),y=f(this.endPoints[1].y)):
(m=f(l.getAbsoluteX(this.endPoints[0].x)),t=f(l.getAbsoluteY(this.endPoints[0].y)),v=f(l.getAbsoluteX(this.endPoints[1].x)),y=f(l.getAbsoluteY(this.endPoints[1].y)));c=h.evalExpression(this.spear);0>c&&(c=0);b.save();b.translate(m,t,s);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):(s*=k,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(-u,d(-u));
b.lineTo(d(s-c-q),d(-u));b.lineTo(d(s-2*c),d(-c-u));b.lineTo(d(s),0);b.lineTo(d(s-2*c),d(c+u));b.lineTo(d(s-c-q),d(u));b.lineTo(-u,d(u));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(j=parseInt((m+v)/2)-3,p=parseInt((t+y)/2)+3,this.uber.drawText.call(this,b,this.text,j,p,e,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,f,h,b,c,n,e,g,r,l,j,p,q;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(){f=this.evaluator;b=f.evalExpression(this.expresion);for(var d=0,h=b.length;d<h;d++)this.endPoints[d]={x:b[d][0],y:b[d][1]};if(this.rotateExp){c=a.degToRad(f.evalExpression(this.rotateExp));n=Math.cos(c);e=Math.sin(c);d=0;for(h=this.endPoints.length;d<h;d++)g=this.endPoints[d].x*n-this.endPoints[d].y*e,r=this.endPoints[d].x*e+this.endPoints[d].y*
n,this.endPoints[d].x=g,this.endPoints[d].y=r}};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){f=this.evaluator;h=this.space;l=d(f.evalExpression(this.width));a.lineWidth=0<l?l:1E-6;a.strokeStyle=c.getColor();a.lineCap="round";a.lineJoin="round";j=0<l?0.5:0;p=this.abs_coord?d(this.endPoints[0].x):d(h.getAbsoluteX(this.endPoints[0].x));
q=this.abs_coord?d(this.endPoints[0].y):d(h.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(p+j,q+j);c=1;for(var e=this.endPoints.length;c<e;c++)p=this.abs_coord?d(this.endPoints[c].x):d(h.getAbsoluteX(this.endPoints[c].x)),q=this.abs_coord?d(this.endPoints[c].y):d(h.getAbsoluteY(this.endPoints[c].y)),a.lineTo(p+j,q+j);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,f,h,b,c,n,e,g,r,l,j,p,
q,u,k,s,m,t,v,y,B,z;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(){f=this.evaluator;h=f.evalExpression(this.center);this.exprX=h[0][0];this.exprY=h[0][1];this.rotateExp&&(b=a.degToRad(f.evalExpression(this.rotateExp)),c=
Math.cos(b),n=Math.sin(b),e=this.exprX*c-this.exprY*n,g=this.exprX*n+this.exprY*c,this.exprX=e,this.exprY=g);var d=f.evalExpression(this.init),m=f.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?(r=d[0][0],l=d[0][1],j=m[0][0],p=m[0][1],this.vectors?this.abs_coord&&(l=-l,p=-p):this.abs_coord?(r-=this.exprX,l=-l+this.exprY,
j-=this.exprX,p=-p+this.exprY):(r-=this.exprX,l-=this.exprY,j-=this.exprX,p-=this.exprY),q=Math.acos((1*r+0*l)/Math.sqrt(r*r+l*l)),u=Math.acos((1*j+0*p)/Math.sqrt(j*j+p*p)),0<r&&(0<l&&this.abs_coord)&&(q=2*Math.PI-q),0<r&&(0>l&&!this.abs_coord)&&(q=2*Math.PI-q),0>r&&(0>l&&!this.abs_coord)&&(q=2*Math.PI-q),0>r&&(0<l&&this.abs_coord)&&(q=2*Math.PI-q),0<j&&(0<p&&this.abs_coord)&&(u=2*Math.PI-u),0<j&&(0>p&&!this.abs_coord)&&(u=2*Math.PI-u),0>j&&(0>p&&!this.abs_coord)&&(u=2*Math.PI-u),0>j&&(0<p&&this.abs_coord)&&
(u=2*Math.PI-u),k=Math.min(q,u),s=Math.max(q,u),q=k,u=s,u-q>Math.PI&&this.abs_coord&&(q=s,u=k),u-q<=Math.PI&&!this.abs_coord&&(q=s,u=k),this.iniAng=q,this.endAng=u,this.drawPoints=!0):(this.iniAng=a.degToRad(d),this.endAng=a.degToRad(m),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){f=this.evaluator;m=this.space;y=f.evalExpression(this.radius);
0>y&&(y=0);z=d(f.evalExpression(this.width));a.lineWidth=0<z?z:1E-6;a.lineCap="round";a.strokeStyle=c.getColor();this.drawAngle?(this.abs_coord?(t=d(this.exprX),v=d(this.exprY)):(t=d(m.getAbsoluteX(this.exprX)),v=d(m.getAbsoluteY(this.exprY)),y*=m.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&(B=this.iniAng,this.iniAng=this.endAng,this.endAng=B)):this.drawPoints&&(this.abs_coord?(t=d(this.exprX),v=d(this.exprY)):(t=d(m.getAbsoluteX(this.exprX)),v=d(m.getAbsoluteY(this.exprY)),
y*=m.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng));this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(t,v),a.arc(t,v,y,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();a.arc(t,v,y,this.iniAng,this.endAng,void 0);a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,t+4,v-2,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,f,h,b,c,n,e,g,r,
l,j,p,q,u,k,s,m,t;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;f=d.evalExpression(this.expresion);this.exprX=f[0][0];this.exprY=f[0][1];this.rotateExp&&(h=a.degToRad(d.evalExpression(this.rotateExp)),b=Math.cos(h),c=Math.sin(h),n=this.exprX*b-
this.exprY*c,e=this.exprX*c+this.exprY*b,this.exprX=n,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){t=this.evaluator.evalExpression(this.decimals);"rtfNode"===this.text.type?(j=this.text,this.ascent=0):j=this.splitText(this.text.toString(t,this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,a,j,parseInt(this.exprX)+5,parseInt(this.exprY)+
this.ascent,b,this.font,this.align,"alphabetic",t,this.fixed)};a.Text.prototype.splitText=function(a){d=this.evaluator;g=d.evalExpression(this.width);j=[];this.ctx.font=this.font;if(20<=g&&"undefined"!=a.type){for(var b=0,c=a.length;b<c;b++)r=a[b],l=this.ctx.measureText(r).width,l>g?j=j.concat(this.splitWords(r,g)):j.push(r);p=Math.floor(1.2*this.fontSize)*j.length;d.setVariable("_Text_H_",p);return j}d.setVariable("_Text_H_",0);d.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=
function(a,b){q=a;u=[];k="";m=0;for(var c,e=0,d=a.length;e<d;e++)s=q.charAt(e)," "===s&&(lastIndexOfWhite=e),k+=s,Math.round(this.ctx.measureText(k).width)>b&&(c=a.substring(m,e+1)," "!==s&&(-1===c.indexOf(" ")?(lastIndexOfWhite=e,e--):e=lastIndexOfWhite),u.push(a.substring(m,lastIndexOfWhite)),k="",m=e+1);u.push(a.substring(m));return u};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,f,h,b,c,n,e,g,r,l,j,p,q,u,k;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(){f=this.evaluator;h=f.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1];this.rotateExp&&(b=a.degToRad(f.evalExpression(this.rotateExp)),c=Math.cos(b),n=Math.sin(b),e=this.exprX*c-this.exprY*n,g=this.exprX*n+this.exprY*c,this.exprX=e,this.exprY=g);4==h[0].length&&(this.centered=!0,this.scaleX=h[0][2],0==
this.scaleX&&(this.scaleX=1E-5),this.scaleY=h[0][3],0==this.scaleY&&(this.scaleY=1E-5));h[1]&&2==h[1].length&&(this.centered=!0,this.scaleX=h[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=h[1][1],0==this.scaleY&&(this.scaleY=1E-5));if((r=f.evalExpression(this.file))||""==r)this.img=this.parent.getImage(r)};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){f=this.evaluator;
l=this.space;this.img&&(this.img.ready&&this.img.complete)&&(j=this.centered?0:this.img.width/2,p=this.centered?0:this.img.height/2,q=this.abs_coord?d(this.exprX):d(l.getAbsoluteX(this.exprX)),u=this.abs_coord?d(this.exprY):d(l.getAbsoluteY(this.exprY)),k=a.degToRad(-f.evalExpression(this.inirot)),b.translate(q+j,u+p),b.rotate(k),b.scale(this.scaleX,this.scaleY),this.opacity&&(b.globalAlpha=f.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 f,h,b,c,n,e,g;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){f=this.evaluator.evalExpression(this.expresion);this.exprX=f[0][0];this.exprY=f[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,f){f.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(h=parseInt(this.exprX),b=parseInt(this.exprY)):(h=parseInt(this.space.getAbsoluteX(this.exprX)),b=parseInt(this.space.getAbsoluteY(this.exprY)));if(!(0>h||0>b||h>=this.space.w||b>=this.space.h)){c=[{x:h,y:b}];for(e=d(imageData,h,b);0<c.length;){n=c.pop();h=n.x;b=n.y;var j=d(imageData,h,b);if(e.r===j.r&&e.g===j.g&&e.b===j.b&&e.a===j.a){var j=imageData,p=f;
g=4*(h+b*j.width);j.data[g+0]=p.r;j.data[g+1]=p.g;j.data[g+2]=p.b;j.data[g+3]=255-p.a;0<h&&c.push({x:h-1,y:b});h<imageData.width-1&&c.push({x:h+1,y:b});c.push({x:h,y:b-1});c.push({x:h,y:b+1})}}this.ctx.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a,d){if(a.loadLib)return a;var f=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,h;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 h in c)c.hasOwnProperty(h)&&(this[h]=c[h]);this.graphics=[];h=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),r;g&&((r=document.getElementById(g))&&"descartes/macro"==r.type?r=r.text:(r=a.openExternalFile(g))&&!r.match(/tipo_de_macro/g)&&(r=null));var l,j;if(r){j=r.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");r=[];for(var g=0,p=j.length;g<p;g++)if(l=j[g].indexOf("="),-1!==l){l=h.split(j[g]);for(var q=0,
u=l.length;q<u;q++)l[q]&&1<l.length&&("id"===d[l[q][0]]||"type"===d[l[q][0]])&&r.push(l)}for(var k,s,g=0,p=r.length;g<p;g++){u=(q=r[g]||[])&&q[0]&&"id"===q[0][0];j=0;for(l=q.length;j<l;j++)if(k=q[j][0].indexOf("."),-1!==k&&!u?(k=d[q[j][0].substring(k+1)],q[j][0]=this.name+"."+q[j][0]):k=d[q[j][0]],!("font"===k||("fill"===k||"color"===k||"arrow"===k)&&"("!==q[j][1].charAt(0)||"file"===k&&q[j][1].match(f)||"id"!==k&&void 0!==d[q[j][1]]))if("text"==k)if(q[j][1].match(/\{\\rtf1/)){k=q[j][1];var m=this;
s=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=m.name+"."+c[d].value);return(a.match(/^\\expr/)?
"\\expr ":"\\decimals ")+e.flatTokens(c)};k=k.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,s);k=k.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,s);q[j][1]=k}else{s=h.parseText(q[j][1]).textElementsMacros;for(var t=0,v=s.length;t<v;t++){k=e.tokenize(s[t].replace(/\&squot;/g,"'"));for(var y=0,B=k.length;y<B;y++)"identifier"===k[y].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("-"+
k[y].value+"-")&&(k[y].value=this.name+"."+k[y].value);k=e.flatTokens(k).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");s[t]=k.substring(1,k.length-1)}q[j][1]=s.join("")}else{s=q[j][1].replace(/\&squot;/g,"'").split(";");t=0;for(v=s.length;t<v;t++){k=e.tokenize(s[t]);y=0;for(B=k.length;y<B;y++)"identifier"===k[y].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("-"+
k[y].value+"-")&&(k[y].value=this.name+"."+k[y].value);s[t]=e.flatTokens(k)}q[j][1]=s.join(";")}}g=0;for(p=r.length;g<p;g++)if(r[g][0]){q="";u=!1;j=0;for(l=r[g].length;j<l;j++)"type"===d[r[g][j][0]]&&(q="espacio='"+this.spaceID+"' ",u=!0),q=q+r[g][j][0]+"='"+r[g][j][1]+"' ";r[g]=q;u?this.graphics.push(h.parseGraphic(r[g],this.abs_coord,this.background,this.inirot)):h.parseAuxiliar(r[g])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){h=this.evaluator.evalExpression(this.inipos);
this.iniPosX=h[0][0];this.iniPosY=h[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,f=Math.sin,h=Math.cos,b,c,n,e,g,r,l,j,p,q,u,k,s,m,t;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,m,h,j,f,k,n,r,l,p,q){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=m||0;this.a13=h||0;this.a20=j||0;this.a21=f||0;this.a22=k||0;this.a23=n||0;this.a30=r||0;this.a31=l||0;this.a32=p||0;this.a33=q||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=f(b);n=h(b);j=this.a10;p=this.a11;q=this.a12;u=this.a13;k=this.a20;s=this.a21;m=this.a22;t=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,j*n+k*
c,p*n+s*c,q*n+m*c,u*n+t*c,j*-c+k*n,p*-c+s*n,q*-c+m*n,u*-c+t*n,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){c=f(b);n=h(b);e=this.a00;g=this.a01;r=this.a02;l=this.a03;k=this.a20;s=this.a21;m=this.a22;t=this.a23;return new a.Matrix4x4(e*n+k*-c,g*n+s*-c,r*n+m*-c,l*n+t*-c,this.a10,this.a11,this.a12,this.a13,e*c+k*n,g*c+s*n,r*c+m*n,l*c+t*n,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(b){c=f(b);n=h(b);e=this.a00;g=this.a01;r=this.a02;l=this.a03;
j=this.a10;p=this.a11;q=this.a12;u=this.a13;return new a.Matrix4x4(e*n+j*c,g*n+p*c,r*n+q*c,l*n+u*c,e*-c+j*n,g*-c+p*n,r*-c+q*n,l*-c+u*n,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.getColor();a.strokeStyle=this.frontColor.getColor();a.beginPath();a.arc(this.newV[0].x,this.newV[0].y,this.size+0.5,0,n);a.fill();a.stroke()}function f(a,b){a.lineCap=e;a.lineJoin=g;this.frontColor.getColor();
this.backColor.getColor();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.getColor():this.frontColor.getColor(),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.getColor(),a.stroke());this.edges&&"wire"!==this.model&&(a.lineWidth=1,a.strokeStyle="#808080",a.stroke())}function h(a){u=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.getColor(),this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,u)}function b(a){a.lineCap=e;a.lineJoin=
g;a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor.getColor();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){r=a.subtract3D(b,c);l=a.subtract3D(b,e);return a.normalize3D(a.crossProduct3D(r,l))}if(a.loadLib)return a;var n=2*Math.PI,e="round",g="round",r,l,j,p,q,u;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=f):"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,this.draw=h):"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);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=this.depth=0;for(d=this.vertices.length;e<d;e++)this.newV[e]=b.project(this.newV[e]),this.depth+=this.newV[e].z;this.depth/=d};var k;a.Primitive3D.prototype.removeDoubles=function(){k=[];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)&&k.push(this.vertices[a]);0===k.length&&k.push(this.vertices[0]);this.vertices=k};
a.Primitive3D.prototype.drawText=function(b,c,e,d,g,h,f,k,n,r,l){if("rtfNode"==c.type)b.fillStyle=g,b.strokeStyle=g,b.textBaseline="alphabetic",c.draw(b,e,d,n,r,f,l);else{"simpleText"===c.type&&(c=c.toString(n,r).split("\\n"));e+=h.match("Arial")?-2:h.match("Times")?-2:0;j=this.evaluator;b.fillStyle=a.getColor(j,g);b.font=h;b.textAlign=f;b.textBaseline=k;p=1.2*this.fontSize||0;g=0;for(h=c.length;g<h;g++)q=c[g],this.border&&b.strokeText(q,e,d+p*g),b.fillText(q,e,d+p*g)}};a.Primitive3D.prototype.splitFace=
function(b){if(this.intersects(b)){for(var c=null,e=null,d=0,g=0,h=0,j=b.vertices.length;h<j;h++){var f=this.intersection(b.vertices[h],b.vertices[(h+1)%j]);if(null!==f)if(null===c){if(c=f,d=h,2===b.vertices.length){e=c;break}}else if(!a.equals3DEpsilon(f,c,1E-8)){e=f;g=h;break}}if(null!==c&&null!==e){var h=this.isInterior(c)||this.isInterior(e),k=null,n=null;if(!h&&3<=b.vertices.length)for(var j=0,r=this.vertices.length;j<r;j++)if(f=b.intersection(this.vertices[j],this.vertices[(j+1)%r]),null!==
f)if(null===k)k=f;else if(!a.equals3DEpsilon(f,k,1E-8)){n=f;break}if(h||null!==k&&null!==n&&b.isInterior(k)&&b.isInterior(n)){n=!0;r=b.vertices;k=f=null;if(2===r.length)a.equals(c,r[0],1E-8)||a.equals(c,r[1],1E-8)?n=!1:(f=[],f[0]=r[0],f[1]=c,k=[],k[0]=c,k[1]=r[1]);else for(var f=[],k=[],l=0,h=j=0;h<r.length;h++)h<d?f[l++]=r[h]:h==d?(f[l++]=r[h],f[l++]=c,k[j++]=c):h<g?k[j++]=r[h]:h==g?(k[j++]=r[h],k[j++]=e,f[l++]=e):f[l++]=r[h];if(n)return c=[],c[0]=new a.Primitive3D({vertices:f,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:k,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 h=a.dotProduct3D(this.vertices[d],b.normal);if(1E-8>Math.abs(c-h)||h>c&&e<c||h<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 h=a.subtract3D(this.vertices[(d+1)%g],b),j=a.dotProduct3D(a.crossProduct3D(e,h),this.normal);if(1E-8>Math.abs(j)){if(0>a.dotProduct3D(e,h))break}else{if(0>c&&0<j||0<c&&0>j)return!1;e=h;c=j}}return!0};a.Primitive3D.prototype.inFrontOf=function(a,b,c){for(var e=0;3>e;e++){var d=null;switch(e){case 0:d=this.intersections(b);break;case 1:d=b.verticesContainedIn(this);break;case 2:d=this.verticesContainedIn(b)}if(null!=
d&&0<d.length){for(var g=0;g<d.length;g++)a.push(d[g]);for(g=0;g<d.length;g++){var h=d[g],h=this.space.rayFromEye(h.x,h.y);try{var j=this.distanceToEyeAlong(h)-b.distanceToEyeAlong(h);if(j<=-c)return!0;if(j>=c)return!1}catch(f){console.log("Error: inFrontOf")}}}}return!1};a.Primitive3D.prototype.intersections=function(b){for(var c=[],e=new a.R2,d=0;d<this.spaceVertices.length;d++)for(var g=this.spaceVertices[d],h=this.spaceVertices[(d+1)%this.spaceVertices.length],j=0;j<b.spaceVertices.length;j++){var f=
b.spaceVertices[j],k=b.spaceVertices[(j+1)%b.spaceVertices.length];!a.equals3DEpsilon(g,f,1E-8)&&(!a.equals3DEpsilon(g,k,1E-8)&&!a.equals3DEpsilon(h,f,1E-8)&&!a.equals3DEpsilon(h,k,1E-8))&&(f=e.intersection(this.newV[d],this.newV[(d+1)%this.newV.length],b.newV[j],b.newV[(j+d)%b.newV.length]),null!=f&&c.push(f))}return c};a.Primitive3D.prototype.distanceToEyeAlong=function(b){this.normal=this.normal||{x:0,y:1,z:0};b=a.dotProduct3D(this.normal,b);var c=a.dotProduct3D(a.subtract3D(this.average,this.space.eye),
this.normal);return 1E-6<Math.abs(b)?c/b:null};a.Primitive3D.prototype.verticesContainedIn=function(a){for(var b=[],c=0;c<this.spaceVertices.length;c++)!a.isVertex(this.spaceVertices[c])&&a.appearsToContain(this.newV[c])&&b.push(this.newV[c]);return b};a.Primitive3D.prototype.appearsToContain=function(a){for(var b=0,c=0;c<this.spaceVertices.length;c++){var e=(this.newV[c].x-a.x)*(this.newV[(c+1)%this.newV.length].y-a.y)-(this.newV[(c+1)%this.newV.length].x-a.x)*(this.newV[c].y-a.y);if(0!=b)if(1E-8>
Math.abs(e)){if(1E-8<Math.abs(this.newV[c].x-this.newV[(c+1)%this.newV.length].x))return Math.min(this.newV[c].x,this.newV[(c+1)%this.newV.length].x)<=a.x+1E-8&&a.x<=Math.max(this.newV[c].x,this.newV[(c+1)%this.newV.length].x)+1E-8;if(1E-8<Math.abs(this.newV[c].y-this.newV[(c+1)%this.newV.length].y))return Math.min(this.newV[c].y,this.newV[(c+1)%this.newV.length].y)<=a.y+1E-8&&a.y<=Math.max(this.newV[c].y,this.newV[(c+1)%this.newV.length].y)+1E-8}else if(0<b&&0>e||0>b&&0<e)return!1;b=e}return!0};
a.Primitive3D.prototype.isVertex=function(b){for(var c=0;c<this.spaceVertices.length;c++)if(a.equals3DEpsilon(b,this.spaceVertices[c],1E-8))return!0;return!1};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d={x:0,y:0,z:0},f,h,b,c,n,e,g,r;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(){f=this.evaluator;h=f.evalExpression(this.family_interval);this.familyInf=h[0][0];this.familySup=h[0][1];this.fSteps=Math.round(f.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){f=this.evaluator;this.getFamilyValues();b=f.getVariable(this.family);if(0<=this.fSteps)for(var a=0,c=this.fSteps;a<=c;a++)f.setVariable(this.family,this.familyInf+
a*this.family_sep),this.familyValue=this.familyInf+a*this.family_sep,f.evalExpression(this.drawif)&&this.buildPrimitives();f.setVariable(this.family,b)};a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.evalExpression(this.drawif)&&(this.family?this.buildFamilyPrimitives():this.buildPrimitives())};a.Graphic3D.prototype.updateMVMatrix=function(){n=this.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(n[0][0])),
this.inirotM=this.inirotM.rotateX(a.degToRad(n[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(n[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(n[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(n[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(n[0][2])));n=this.evaluator.evalExpression(this.inipos);d={x:n[0][0],y:n[0][1],z:n[0][2]};this.iniposM=this.iniposM.setIdentity().translate(d);n=this.evaluator.evalExpression(this.endrot);
this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(n[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(n[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(n[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(n[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(n[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(n[0][2])));n=this.evaluator.evalExpression(this.endpos);d={x:n[0][0],
y:n[0][1],z:n[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(){n=this.expresion.split("=");e=n[0];g=[];for(var a=1;a<n.length;a++)e+="=",r=n[a].lastIndexOf(" "),e+=-1!==r?n[a].substring(0,r):n[a],g.push(this.evaluator.parser.parse(e,!0)),e=n[a].substring(r+1);return g};var l;a.Graphic3D.prototype.splitFace=function(a){for(var b=0,c=this.primitives.length;b<c;b++)if(l=[],"face"===this.primitives[b].type){for(var e=0,d=a.primitives.length;e<d;e++)"face"===a.primitives[e].type?
l=l.concat(this.primitives[b].splitFace(a.primitives[e])):l.push(a.primitives[e]);a.primitives=l}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,f,h,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();f=d.evalExpression(this.expresion);h=f[0][0];b=f[0][1];c=f[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,
b,c,1))],type:"vertex",backColor:this.backcolor,frontColor:this.color,size:d.evalExpression(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,b,c,1))],type:"text",frontColor:this.color,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,f,h,b,c,n;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];f=expr[0][1];h=expr[0][2];b=expr[1][0];c=expr[1][1];n=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,f,h,1)),this.transformVertex(new a.Vector4D(b,c,
n,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,f,h,b,c,n,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();h=d.getVariable("x");h=d.getVariable("y");h=d.getVariable("z");f=d.getVariable("u");h=d.getVariable("v");d.setVariable("u",0);d.setVariable("v",0);b=d.evalExpression(this.Nu);c=d.evalExpression(this.Nv);n=[];for(var g=0;g<=b;g++){d.setVariable("u",g/b);for(var r=0;r<=c;r++){d.setVariable("v",r/c);for(var l=0,j=this.expresion.length;l<j;l++)d.evalExpression(this.expresion[l]);n.push(this.transformVertex(new a.Vector4D(d.getVariable("x"),d.getVariable("y"),d.getVariable("z"),1)))}}for(g=
0;g<b;g++)for(r=0;r<c;r++)e=[],e.push(n[r+g*c+g]),e.push(n[r+1+g*c+g]),e.push(n[r+2+(g+1)*c+g]),e.push(n[r+1+(g+1)*c+g]),this.primitives.push(new a.Primitive3D({vertices:e,type:"face",frontColor:this.color,backColor:this.backcolor,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",f);d.setVariable("v",h)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,f,h,b,c,n;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],f=expr[e][1],h=expr[e][2],b=expr[e+1][0],c=expr[e+1][1],n=expr[e+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,f,h,1)),this.transformVertex(new a.Vector4D(b,
c,n,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,f,h,b,c,n;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");
n=evaluator.getVariable("z");h=evaluator.getVariable("u");evaluator.setVariable("u",0);f=evaluator.evalExpression(this.Nu);d=[];for(var e=0;e<=f;e++){evaluator.setVariable("u",e/f);for(var g=0,r=this.expresion.length;g<r;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,lineWidth:evaluator.evalExpression(this.width)},this.space));evaluator.setVariable("x",b);evaluator.setVariable("y",n);evaluator.setVariable("z",c);evaluator.setVariable("u",h)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,f,h,b,c,n,e,g,r;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];f=expr[0][1];h=expr[0][2];b=expr[1][0];c=expr[1][1];n=expr[1][2];e=expr[2][0];g=expr[2][1];r=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,f,h,1)),this.transformVertex(new a.Vector4D(e,g,r,1)),this.transformVertex(new a.Vector4D(b,c,n,1))],type:"face",frontColor:this.color,backColor:this.backcolor,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,h){a.Graphic3D.call(this,d,h)};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);d=[];for(var f=expr.length-1;0<=f;f--)d.push(this.transformVertex(new a.Vector4D(expr[f][0],expr[f][1],expr[f][2],1)));this.primitives.push(new a.Primitive3D({vertices:d,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model},this.space))};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d,f,h,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);f=[this.transformVertex(new a.Vector4D(0,0,0,1))];h=evaluator.evalExpression(this.width)/2;b=evaluator.evalExpression(this.length)/2;c=
2*Math.PI/d;for(var n=0;n<d;n++)f.push(this.transformVertex(new a.Vector4D(h*Math.cos(c*n),b*Math.sin(c*n),0,1)));for(n=0;n<d;n++)this.primitives.push(new a.Primitive3D({vertices:[f[0],n+2<=d?f[n+2]:f[1],f[n+1]],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,f,h,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;f=d.evalExpression(this.expresion);h=f[0][0];b=f[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(h,b,0,1)],type:"text",frontColor:this.color,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 f=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,
h,b;a.Macro3D=function(b,h){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,h);for(var e in h)h.hasOwnProperty(e)&&(this[e]=h[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 r=this.evaluator.evalExpression(this.expresion),l;r&&((l=document.getElementById(r))&&"descartes/macro"==l.type?l=l.text:(l=a.openExternalFile(r))&&!l.match(/tipo_de_macro/g)&&(l=null));var j,p;if(l){p=l.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");l=[];for(var r=0,q=p.length;r<q;r++)j=p[r].indexOf("="),-1!==j&&(j=p[r].substring(0,j),("id"===d[j]||"type"===d[j])&&l.push(e.split(p[r])));for(var u,k,s,m,r=0,q=l.length;r<q;r++){m=(u=l[r]||[])&&u[0]&&"id"===u[0][0];p=0;for(j=u.length;p<j;p++)if(k=
u[p][0].indexOf("."),-1!==k&&!m?(k=d[u[p][0].substring(k+1)],u[p][0]=this.name+"."+u[p][0]):k=d[u[p][0]],!("font"===k||("fill"===k||"color"===k||"arrow"===k)&&"("!==u[p][1].charAt(0)||"file"===k&&u[p][1].match(f)||"id"!==k&&void 0!==d[u[p][1]])||!("width"!==k&&"height"!==k&&"length"!==k))if("text"==k)if(u[p][1].match(/\{\\rtf1/)){k=u[p][1];var t=this;s=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=t.name+"."+c[e].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+g.flatTokens(c)};k=k.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,s);k=k.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,s);u[p][1]=k}else{s=e.parseText(u[p][1]).textElementsMacro3Ds;for(var v=0,y=s.length;v<y;v++){k=g.tokenize(s[v].replace(/\&squot;/g,"'"));for(var B=0,z=k.length;B<z;B++)"identifier"===k[B].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("-"+
k[B].value+"-")&&(k[B].value=this.name+"."+k[B].value);k=g.flatTokens(k).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");s[v]=k.substring(1,k.length-1)}u[p][1]=s.join("")}else{k=g.tokenize(u[p][1]);s=0;for(v=k.length;s<v;s++)"identifier"===k[s].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("-"+k[s].value+"-")&&(k[s].value=this.name+"."+k[s].value);u[p][1]=g.flatTokens(k)}}r=
0;for(q=l.length;r<q;r++)if(l[r][0]){u="";m=!1;p=0;for(j=l[r].length;p<j;p++)"type"===d[l[r][p][0]]&&(u="espacio='"+this.spaceID+"' ",m=!0),u=u+l[r][p][0]+"='"+l[r][p][1]+"' ";l[r]=u;m?this.graphics.push(e.parse3DGraphic(l[r],this.abs_coord,this.background,this.inirot)):e.parseAuxiliar(l[r])}}r=0;for(q=this.graphics.length;r<q;r++)this.graphics[r].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++)h=this.graphics[a],h.macro_inirotEuler=this.inirotEuler,h.macro_inirotM=this.inirotM,h.macro_inirotM_X=this.inirotM_X,h.macro_inirotM_Y=this.inirotM_Y,h.macro_inirotM_Z=this.inirotM_Z,h.macro_iniposM=this.iniposM,h.macro_endrotEuler=this.endrotEuler,h.macro_endrotM=this.endrotM,h.macro_endrotM_X=this.endrotM_X,h.macro_endrotM_Y=this.endrotM_Y,h.macro_endrotM_Z=this.endrotM_Z,h.macro_endposM=this.endposM,
h.update();a=0;for(d=this.graphics.length;a<d;a++){h=this.graphics[a];if(h.split||this.split)for(var e=a+1;e<d;e++)b=this.graphics[e],(b.split||this.split)&&h.splitFace(b);this.primitives=this.primitives.concat(h.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(){};return a}(descartesJS||{},babel),descartesJS=function(a){function d(a,b,c,e,d){f.call(this,a/1.8,a/1.8,a/1.8,e,d)}function f(a,b,c,e,d){a/=2;b/=2;c/=2;this.changeGeometry(a,b,c,e,d)||(this.vertices=[new k(a,c,b,1),new k(a,-c,b,1),new k(a,c,-b,1),new k(a,-c,-b,1),new k(-a,c,b,1),new k(-a,-c,b,1),new k(-a,c,-b,1),new k(-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 h(a,b,c,e,d){a/=2;this.changeGeometry(a,b,c,e,d)||(this.vertices=[new k(0,0,a,1),new k(-0.49*a,-0.86*a,-0.32*a,1),new k(-0.49*a,0.86*a,-0.32*a,1),new k(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 k(0,0,a,1),new k(a,0,0,1),new k(-a,0,0,1),new k(0,a,0,1),new k(0,-a,0,1),new k(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)){E=b/D;A=b*D;this.vertices=[new k(b,b,b,1),new k(b,b,-b,1),new k(b,-b,b,1),new k(b,-b,-b,1),new k(-b,b,b,1),new k(-b,b,-b,1),new k(-b,-b,b,1),new k(-b,-b,-b,1),new k(0,E,A,1),new k(0,E,-A,1),new k(0,-E,A,1),new k(0,-E,-A,1),new k(E,A,0,1),new k(E,-A,0,1),new k(-E,A,0,1),new k(-E,-A,0,1),new k(A,0,E,1),new k(A,0,-E,1),new k(-A,
0,E,1),new k(-A,0,-E,1)];x=(new a.Matrix4x4).setIdentity().rotateY(-q/6);for(var h=0,f=this.vertices.length;h<f;h++)this.vertices[h]=x.multiplyVector4(this.vertices[h]);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 n(b,c,e,d,g){b/=4;if(!this.changeGeometry(b,c,e,d,g)){A=b*D;this.vertices=[new k(0,b,A,1),new k(0,b,-A,1),
new k(0,-b,A,1),new k(0,-b,-A,1),new k(b,A,0,1),new k(b,-A,0,1),new k(-b,A,0,1),new k(-b,-A,0,1),new k(A,0,b,1),new k(A,0,-b,1),new k(-A,0,b,1),new k(-A,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]];x=(new a.Matrix4x4).setIdentity().rotateY(-1.029);for(var h=0,f=this.vertices.length;h<f;h++)this.vertices[h]=x.multiplyVector4(this.vertices[h]);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 k(0,0,b,1)];for(var g=1;g<e;g++){z=g*q/e;for(var h=0;h<d;h++)B=h*u/d,t=a*j(z)*p(B),v=c*j(z)*j(B),y=b*p(z),this.vertices.push(new k(t,v,y,1))}this.vertices.push(new k(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(h=0;h<d;h++)this.faces.push([h+1+(g-1)*d,(h+1)%d+1+(g-1)*d,(h+1)%d+1+g*d,h+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 h=0;h<e;h++)t=a*(d-g)/d*p(h*u/e),v=c*(d-g)/d*j(h*u/e),y=b-2*g*b/d,this.vertices.push(new k(t,v,y,1));this.vertices.push(new k(0,0,-b,1));this.faces=[];for(g=0;g<d-1;g++)for(h=0;h<e;h++)this.faces.push([h+g*e,(h+1)%e+g*e,(h+1)%e+(g+1)*e,h+(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 r(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 h=0;h<e;h++)t=a*p(h*u/e),v=c*j(h*u/e),y=b-2*g*b/d,this.vertices.push(new k(t,v,y,1));this.faces=[];for(g=0;g<d;g++)for(h=0;h<e;h++)this.faces.push([h+g*e,(h+1)%e+g*e,(h+1)%e+(g+1)*e,h+(g+1)*e]);this.updateValues(a,b,c,e,d)}}function l(){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++)F=this.fileData[c],F.match(/^V\(/)?(G=F.substring(2,F.length-1).split(",").map(b),this.vertices.push(new k(G[0]||0,G[1]||0,G[2]||0,1))):F.match(/^F\(/)&&(G=F.substring(2,F.length-1).split(",").map(a),this.faces.push(G.reverse()))}if(a.loadLib)return a;var j=Math.sin,p=Math.cos,q=Math.PI,u=2*q,k,s,m,t,v,y,B,z,D=1.6180339887,E,A,x,F,G;a.OtherGeometry=function(j,m){this.width=j.evaluator.parser.parse("2");this.height=j.evaluator.parser.parse("2");
this.length=j.evaluator.parser.parse("2");k=a.Vector4D;a.Graphic3D.call(this,j,m);switch(this.type){case "cube":this.buildGeometry=d;break;case "box":this.buildGeometry=f;break;case "tetrahedron":this.buildGeometry=h;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=n;break;case "cone":this.buildGeometry=g;break;case "cylinder":this.buildGeometry=
r;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=l}};a.extend(a.OtherGeometry,a.Graphic3D);a.OtherGeometry.prototype.buildPrimitives=function(){s=this.evaluator;this.updateMVMatrix();this.buildGeometry(s.evalExpression(this.width),s.evalExpression(this.height),s.evalExpression(this.length),s.evalExpression(this.Nu),s.evalExpression(this.Nv));for(var b=0,c=this.faces.length;b<c;b++){m=[];for(var e=0,d=this.faces[b].length;e<
d;e++)m.push(this.transformVertex(this.vertices[this.faces[b][e]]));this.primitives.push(new a.Primitive3D({vertices:m,type:"face",frontColor:this.color,backColor:this.backcolor,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,f=Math.min,h=Math.PI,b=Math.cos,c=Math.sin,n=Math.abs,e,g,r,l,j,p,q,u,k,s,m,t,v,y,B,z,D,E;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(f(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(d(f(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){r=this.copy();p=b(a);q=c(a);this.x=r.x*p-r.y*q;this.y=r.x*q+r.y*p};a.R2.prototype.rot=function(a){this.rot(a*h/180)};a.R2.prototype.intersection=function(b,c,e,g){u=c.x-b.x;k=
e.x-g.x;s=e.x-b.x;m=c.y-b.y;t=e.y-g.y;v=e.y-b.y;E=u*t-k*m;return 1E-6<n(E)?(l=(s*t-v*k)/E,j=(-s*m+v*u)/E,0<=l&&1>=l&&0<=j&&1>=j?new a.R2(b.x+u*l,b.y+m*l):null):(c.x-e.x)*v!=(c.y-e.y)*s?null:b.x!=c.x?(y=f(b.x,c.x),B=d(b.x,c.x),y<=e.x&&e.x<=B?e:y<=g.x&&g.x<=B?g:null):e.x!=g.x?(z=f(e.x,g.x),D=d(e.x,g.x),z<=b.x&&b.x<=D?b:z<=c.x&&c.x<=D?c:null):b.y!=c.y?(y=f(b.y,c.y),B=d(b.y,c.y),y<=e.y&&e.y<=B?e:y<=g.y&&g.y<=B?g:null):e.y!=g.y?(z=f(e.y,g.y),D=d(e.y,g.y),z<=b.y&&b.y<=D?b:z<=c.y&&c.y<=D?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,f,h,b,c,n,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];n=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);f=d.evalExpression(this.constraint);n.x=(f-this.f0)/1E-12;n.x=!isNaN(n.x)?n.x:Infinity;d.setVariable("x",d.getVariable("x")-
1E-12);d.setVariable("y",d.getVariable("y")+1E-12);f=d.evalExpression(this.constraint);n.y=(f-this.f0)/1E-12;n.y=!isNaN(n.y)?n.y:Infinity;d.setVariable("x",e);d.setVariable("y",g);return n};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 f=0;256>f;f++)if(h=c.x,b=c.y,this.normal=this.gradient(c),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),c.x=h+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,f){this.x=a;this.y=f};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,f=Math.round,h,b,c,n,e,g,r,l,j,p,q,u,k,s,m,t,v,y,B,z;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]);if(("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=f(e[0][0]);this.y=f(e[0][1]);4==e[0].length&&(this.w=
f(e[0][2]),this.h=f(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=n=e=g=!1;r=this.evaluator.evalExpression(this.expresion);l=f(r[0][0]);c=f(this.x)!==l;this.x=l;l=f(r[0][1]);n=f(this.y)!==l;this.y=l;4===r[0].length&&(l=f(r[0][2]),e=f(this.w)!==l,this.w=l,l=f(r[0][3]),g=f(this.h)!==l,this.h=l);if(e||g||c||n)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){k=
this.parent;j=a+"";p=this.evaluator.evalExpression(this.decimals);q=j.indexOf(".");-1!=q&&(u=j.substring(q+1),u.length>p&&(j=parseFloat(j).toFixed(p)));if(this.fixed&&(2!==k.version||2===k.version&&!this.exponentialif))j=parseFloat(a).toFixed(p);this.exponentialif&&0!=parseFloat(j)&&(j=this.fixed&&2!==k.version?parseFloat(j).toExponential(p):parseFloat(j).toExponential(),j=j.toUpperCase(),j=j.replace("+",""));return j=j.replace(".",k.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);h=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/h/255+")")};a.Control.prototype.getScreenshot=function(){t=this;s=document.createElement("canvas");s.setAttribute("width",t.w);s.setAttribute("height",t.h);m=s.getContext("2d");m.font=
t.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";t.canvas&&(v=t.canvas.offsetLeft,y=t.canvas.offsetTop,m.drawImage(t.canvas,v,y));t.label&&(v=t.label.offsetLeft,y=t.label.offsetTop,B=t.label.offsetWidth,z=t.label.offsetHeight,m.fillStyle="#e0e4e8",m.fillRect(v,y,B,z),m.fillStyle="black",m.textAlign="center",m.textBaseline="middle",m.fillText(t.name,v+B/2,y+z/2));t.field&&(v=t.field.offsetLeft,y=t.field.offsetTop,B=t.field.offsetWidth,z=t.field.offsetHeight,m.fillStyle="white",m.strokeStyle=
"#666666",m.lineWidth=1,m.fillRect(v,0,B,z),m.strokeRect(v+0.5,0.5,B-1,z-1),m.fillStyle="black",m.textAlign="center",m.textAlign="left",m.fillText(t.field.value,v+2,z/2));t.select&&(v=t.select.offsetLeft,y=t.select.offsetTop,B=t.select.offsetWidth,z=t.select.offsetHeight,m.fillStyle="#e0e4e8",m.strokeStyle="#666666",m.lineWidth=1,m.fillRect(v,0,B,z),m.strokeRect(v+0.5,0.5,B,z-1),m.fillStyle="black",m.textAlign="center",m.textAlign="left",m.fillText(t.select.value,v+2,z/2),m.fillStyle="#c0c0c0",m.fillRect(v+
B-15+0.5,0.5,15,z-1),m.strokeRect(v+B-15+0.5,0.5,15,z-1),m.fillStyle="black",m.beginPath(),m.moveTo(v+B-15+4.5,z/2-2.5),m.lineTo(v+B-15+8,z/2+2.5),m.lineTo(v+B-15+11.5,z/2-2.5),m.closePath(),m.fill());return s};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,f,h,b,c,n,e,g,r,l,j,p,q,u=2E3;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="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");var 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(){f=this.evaluator;h=this.canvas;c=f.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]));h.setAttribute("width",this.w+"px");h.setAttribute("height",this.h+"px");h.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=f.parser.parse(a.getFieldFontSize(this.h)+""));this.createGradient(this.w,this.h);
h.style.display=0<f.evalExpression(this.drawif)?"block":"none"};a.Button.prototype.update=function(){f=this.evaluator;h=this.canvas;this.activeIfValue=0<f.evalExpression(this.activeif);(this.drawIfValue=0<f.evalExpression(this.drawif))?(h.style.display="block",this.draw()):(this.click=!1,h.style.display="none");this.canvas.style.cursor=this.activeIfValue?"pointer":"not-allowed";this.updatePositionAndSize()};a.Button.prototype.draw=function(){f=this.evaluator;b=this.ctx;n=f.evalExpression(this.font_size);
e=f.evalExpression(this.name);g=f.evalExpression(this.imageSrc);r="vacio.gif"===g?this.emptyImage:this.parent.getImage(g);b.clearRect(0,0,this.w,this.h);j=l=0;this.click&&(j=l=1);r&&r.ready?r!==this.emptyImage&&r.complete&&(this.canvas.style.backgroundImage="url("+this.image.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-r.width)/2)+l+"px "+(parseInt((this.h-r.height)/2)+j)+"px"):(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.canvas.style.backgroundImage="url("+this.imageOver.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-r.width)/2)+l+"px "+(parseInt((this.h-r.height)/2)+j)+"px");this.activeIfValue&&""!=this.imageDown.src&&
this.imageDown.ready&&this.click?(this.canvas.style.backgroundImage="url("+this.imageDown.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-r.width)/2)+l+"px "+(parseInt((this.h-r.height)/2)+j)+"px"):this.click&&!r&&(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+" "+n+"px Arial";b.textAlign="center";b.textBaseline="middle";
this.colorInt.getColor()!=this.color.getColor()&&(b.lineJoin="round",b.lineWidth=parseInt(n/6),b.strokeStyle=this.colorInt.getColor(),b.strokeText(e,d(this.w/2+l)+0.5,d(this.h/2+j)+0.5));b.fillText(e,d(this.w/2+l)+0.5,d(this.h/2+j)+0.5);this.underlined&&(p=b.measureText(e).width,b.strokeStyle=this.color.getColor(),b.lineWidth=d(n/10)||2,b.lineCap="round",b.beginPath(),b.moveTo(parseInt((this.w-p)/2)+l,d((this.h+n)/2)+d(n/5)-1.5+j),b.lineTo(parseInt((this.w+p)/2)+l,d((this.h+n)/2)+d(n/5)-1.5+j),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(f);h.click&&(c.call(h),a=e?a:100,f=setTimeout(function(){b(a,c)},a))}function c(d){document.body.focus();d.preventDefault();d.stopPropagation();document.activeElement!=document.body&&document.activeElement.blur();h.whichButton=a.whichButton(d);
"L"==h.whichButton&&h.activeIfValue&&(h.click=!0,h.draw(),h.evaluator.setVariable(h.id,h.evaluator.evalExpression(h.valueExpr)),"calculate"==h.action&&b(u,h.bottonPressed,!0),q?window.addEventListener("touchend",e):window.addEventListener("mouseup",e))}function e(a){document.body.focus();if(h.activeIfValue||h.click)h.click=!1,h.draw(),"calculate"!=h.action&&h.bottonPressed(),a.preventDefault(),a.stopPropagation(),q?window.removeEventListener("touchend",e,!1):window.removeEventListener("mouseup",e,
!1)}function d(){h.over=!0;h.draw()}function g(){h.over=!1;h.click=!1;h.draw()}q=a.hasTouchSupport;var h=this,f;h.canvas.oncontextmenu=function(){return!1};this.over=this.click=!1;q?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,
f,h,b,c,n,e,g,r,l,j,p,q,u,k,s,m;a.Spinner=function(b,c){a.Control.call(this,b,c);this.tabindex=++this.parent.tabindex;this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");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"),h=2+parseInt(this.h/2),f=parseInt(this.w/2-h/2),e=a.getTextWidth(b+e,this.fieldFontSize+"px Arial");this.visible||(f=this.w-h,g=0);f<e&&(f=e);""==b&&(f=0);this.w-f-h<g&&(f=this.w-h-g);0>f&&(f=0);b=this.w-(f+h);this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.setAttribute("id",this.id);this.canvas.setAttribute("width",
h+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+f+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.divUp.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+h+"px; height : "+this.h/2+"px; left: "+f+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+h+"px; height : "+this.h/
2+"px; left: "+f+"px; top: "+this.h/2+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_spinner");this.field.setAttribute("class","DescartesSpinnerField");this.field.setAttribute("style","font-family: Arial; font-size: "+this.fieldFontSize+"px; width : "+b+"px; height : "+this.h+"px; left: "+(h+f)+"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: "+f+"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)?(f=d.evalExpression(this.incr),0<f?this.originalIncr=this.incr=d.parser.parse(parseInt(f).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();if(!this.parent.animation.playing||document.activeElement!=this.field)h=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!=h&&(this.value=
this.validateValue(h),this.field.value=this.formatOutputValue(this.value)),d.setVariable(this.id,this.value)};a.Spinner.prototype.draw=function(){c=this.ctx;n=this.canvas.width;e=this.canvas.height;c.fillStyle="#f0f8ff";c.fillRect(0,0,n,e);c.fillStyle=this.linearGradient;c.fillRect(0,0,n,e);this.up?(g="gray",r="#f0f8ff"):(g="#f0f8ff",r="gray");a.drawLine(c,0,0,n,0,g);a.drawLine(c,0,0,0,e/2,g);a.drawLine(c,0,e/2,n,e/2,r);this.down?(g="gray",r="#f0f8ff"):(g="#f0f8ff",r="gray");a.drawLine(c,0,e/2+1,
n,e/2+1,g);a.drawLine(c,0,e/2+1,0,e,g);a.drawLine(c,0,e-1,n,e-1,r);l=[parseInt(n/2+1),parseInt(n/5+1),parseInt(n-n/5+1)];j=[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(l[0],j[0]);c.lineTo(l[1],j[1]);c.lineTo(l[2],j[2]);c.fill();j=[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(l[0],j[0]);c.lineTo(l[1],j[1]);c.lineTo(l[2],j[2]);c.fill();
c.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&c.fillRect(0,0,n,e/2);this.down&&c.fillRect(0,e/2,n,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();p=parseFloat(d.evalExpression(d.parser.parse(a.replace(this.parent.decimal_symbol,"."))));isNaN(p)&&(p=0);k=d.evalExpression(this.min);s=d.evalExpression(this.max);""===k&&(k=-Infinity);""===s&&(s=Infinity);p<k&&(p=k);p>s&&(p=s);this.discrete&&
(q=d.evalExpression(this.incr),p=0==q?0:q*Math.round(p/q));u=d.evalExpression(this.decimals);0>=u&&(u=0);return p=parseFloat(parseFloat(p).toFixed(u))};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(j.up||j.down)c.call(j),a=e?a:30,n=setTimeout(function(){b(a,c)},a)}function c(e){e.preventDefault();j.whichButton=a.whichButton(e);"L"==j.whichButton&&j.activeIfValue&&(j.up=!0,b(k,j.increase,!0),j.draw())}function e(c){c.preventDefault();j.whichButton=a.whichButton(c);"L"==j.whichButton&&j.activeIfValue&&
(j.down=!0,b(k,j.decrease,!0),j.draw())}function d(a){j.up=!1;clearInterval(n);j.draw();a.preventDefault()}function g(a){j.down=!1;clearInterval(n);j.draw();a.preventDefault()}function h(a){j.up=!1;clearInterval(n);j.draw();a.preventDefault()}function f(a){j.down=!1;clearInterval(n);j.draw();a.preventDefault()}m=a.hasTouchSupport;var j=this,k=m?500:200,n;j.divUp.oncontextmenu=j.divDown.oncontextmenu=j.field.oncontextmenu=j.label.oncontextmenu=function(){return!1};m?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&&j.changeValue(j.field.value)});m?this.divUp.addEventListener("touchstart",c):this.divUp.addEventListener("mousedown",c);m?this.divDown.addEventListener("touchstart",e):this.divDown.addEventListener("mousedown",e);m||this.divUp.addEventListener("mouseout",d);m||this.divDown.addEventListener("mouseout",g);m?(this.divUp.addEventListener("touchend",
h),window.addEventListener("touchend",h)):(this.divUp.addEventListener("mouseup",h),window.addEventListener("mouseup",h));m?(this.divDown.addEventListener("touchend",f),window.addEventListener("touchend",f)):(this.divDown.addEventListener("mouseup",f),window.addEventListener("mouseup",f));j.field.addEventListener("click",function(){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,f,h,b,c,n,e;a.TextField=function(b,c){a.Control.call(this,
b,c);this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");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(",")));if(this.onlyText){if(!this.valueExprString.match(/^'/)||!this.valueExprString.match(/'$/))this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'");this.validateValue=function(a){return"''"==a||"'"==a?"":a&&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"),h=parseInt(this.w/2),f=a.getTextWidth(b,this.fieldFontSize+"px Arial");h<f&&(h=f);""==b&&(h=0);this.w-h<e&&(h=this.w-e);0>h&&(h=0);b=this.w-h;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: "+h+"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: "+h+"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();if(!this.parent.animation.playing||document.activeElement!=this.field)f=this.field.value,h=this.value,this.value=this.validateValue(d.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value===h&&this.field.value!=f&&(this.value=this.validateValue(f),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);n=d.evalExpression(this.max);""==n&&(n=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){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(){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(){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.abs,f,h,b,c,n,e,g,r,l,j,p;a.Menu=function(b,c){this.options="";a.Control.call(this,b,c);f=this.parser;h=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="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");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]=this.menuOptions[d].match(/^\[/)&&this.menuOptions[d].match(/\]$/)?f.parse(this.menuOptions[d].substring(1,this.menuOptions[d].length-1)):f.parse("'"+this.menuOptions[d]+"'");d=0;for(g=this.strValue.length;d<g;d++)this.strValue[d]=this.strValue[d].match(/^\[/)&&
this.strValue[d].match(/\]$/)?f.parse(this.strValue[d].substring(1,this.strValue[d].length-1)):f.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=h.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(){h=this.evaluator;var b=h.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=h.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);
for(var g=0,f=this.menuOptions.length;g<f;g++)d=a.getTextWidth(h.evalExpression(this.menuOptions[g]).toString(),this.fieldFontSize+"px Arial"),d>c&&(c=d,e=g);c+=25;d=a.getTextWidth(this.formatOutputValue(h.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;f=this.formatOutputValue(h.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=
f;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;h.setVariable(this.id,parseFloat(f));this.update()};a.Menu.prototype.update=function(){h=this.evaluator;this.label.innerHTML=h.evalExpression(this.name).toString();this.activeIfValue=0<h.evalExpression(this.activeif);this.drawIfValue=0<h.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=h.evalExpression(this.menuOptions[a]);this.value=h.getVariable(this.id);isNaN(this.value)&&(this.value=0);this.field.value=this.formatOutputValue(this.value);
h.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;r="";l=0;for(j=-1;l<a.length;){p=a.charAt(l);a.charAt(l-1);if("["===p&&-1===j){if(g||""!=r)r+="\u00a6";j++}else"["===p?j++:"]"===p&&0===j?(g=!0,j--):"]"==a.charAt(l)&&(j=0>j?j:j-1);r+=a.charAt(l);l++}return r.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++)n=d(a-parseFloat(this.evaluator.evalExpression(this.strValue[e]))),n<=c&&(c=n,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(){this.select();this.focus()});b.select.addEventListener("click",function(){this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,f="h",h,b,c,n,e,g,r,l,j,p,q,u,k,s,m,t,v,y,B,z,D;a.Scrollbar=function(b,c){a.Control.call(this,
b,c);this.name="["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.parser.parse(this.name.substring(1,this.name.length-1)):this.parser.parse("'"+this.name+"'");this.orientation=this.w>=this.h?f:"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(){h=this.evaluator;
this.findOffset();this.incr=0==h.evalExpression(this.decimals)?1:(h.evalExpression(this.max)-h.evalExpression(this.min))/100;this.value=this.validateValue(h.evalExpression(this.valueExpr));c=this.formatOutputValue(this.value);n=this.evaluator.evalExpression(this.expresion);this.x=n[0][0];this.y=n[0][1];4==n[0].length&&(this.w=n[0][2],this.h=n[0][3]);this.orientation=this.w>=this.h?f:"v";this.initScroll(c);this.changeScrollPositionFromValue();this.prePos=this.pos;h.setVariable(this.id,this.value)};
a.Scrollbar.prototype.initScroll=function(c){b=this;h=b.evaluator;var e=h.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"),f=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-f&&(b.canvasHeight=f),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(){h=this.evaluator;this.label.innerHTML=h.evalExpression(this.name).toString();this.incr=0==h.evalExpression(this.decimals)?1:(h.evalExpression(this.max)-h.evalExpression(this.min))/100;this.activeIfValue=0<h.evalExpression(this.activeif);this.drawIfValue=0<h.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(h.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);h.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){b=this;e=b.ctx;r=d(this.w);g=d(this.h);e.fillStyle="#e0e4e8";e.fillRect(0,0,r,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);l=4;e.fillStyle="black";e.beginPath();b.orientation===f?(e.moveTo(b.downX+l,b.downH/2),e.lineTo(b.downX+b.downW-l,l),e.lineTo(b.downX+b.downW-l,b.downH-l),e.moveTo(b.upX+b.upWidth-l,b.downH/2),e.lineTo(b.upX+l,l),e.lineTo(b.upX+l,b.downH-l),e.fill(),b.activeIfValue&&
(j=d(b.pos),e.fillStyle="#ccdcec",e.fillRect(j+0.5,0,d(b.scrollManipulatorW),g),e.strokeStyle="#6382bf",e.strokeRect(j+0.5,0,d(b.scrollManipulatorW),g),p=d(b.scrollManipulatorW/2),e.beginPath(),e.moveTo(j+p+0.5-2,3),e.lineTo(j+p+0.5-2,g-3),e.moveTo(j+p+0.5,3),e.lineTo(j+p+0.5,g-3),e.moveTo(j+p+0.5+2,3),e.lineTo(j+p+0.5+2,g-3),e.stroke())):(e.moveTo(b.downX+b.downW/2,b.downY+b.downH-l),e.lineTo(b.downX+l,b.downY+l),e.lineTo(b.downX+b.downW-l,b.downY+l),e.moveTo(b.upX+b.upWidth/2,b.upY+l),e.lineTo(b.upX+
l,b.upY+b.upHeight-l),e.lineTo(b.upX+b.upWidth-l,b.upY+b.upHeight-l),e.fill(),b.activeIfValue&&(j=d(b.pos),e.fillStyle="#ccdcec",e.fillRect(0,j+0.5,r,d(b.scrollManipulatorH)),e.strokeStyle="#6382bf",e.strokeRect(0,j+0.5,r,d(b.scrollManipulatorH)),p=d(b.scrollManipulatorH/2),e.beginPath(),e.moveTo(3,j+p+0.5-2),e.lineTo(r-3,j+p+0.5-2),e.moveTo(3,j+p+0.5),e.lineTo(r-3,j+p+0.5),e.moveTo(3,j+p+0.5+2),e.lineTo(r-3,j+p+0.5+2),e.stroke()));e.strokeRect(0.5,0.5,r-1,g-1);b.activeIfValue||(e.fillStyle="rgba(240,240,240,"+
160/255+")",e.fillRect(0,0,r,g.h))};a.Scrollbar.prototype.validateValue=function(a){h=this.evaluator;q=a.toString();q=parseFloat(q.replace(this.parent.decimal_symbol,"."));isNaN(q)&&(q=0);this.minimo=h.evalExpression(this.min);q<this.minimo&&(this.value=null,q=this.minimo);this.maximo=h.evalExpression(this.max);q>this.maximo&&(this.value=null,q=this.maximo);u=this.incr;q=0!=u?q*u/u:0;this.fixed&&(q=parseFloat(parseFloat(q).toFixed(h.evalExpression(this.decimals))));return q};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(){l=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==f?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+l):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+l)};a.Scrollbar.prototype.decrease10=function(){l=(this.evaluator.evalExpression(this.max)-
this.evaluator.evalExpression(this.min))/10;this.orientation==f?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-l):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-l)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&(k=this.validateValue(a),k!=this.value&&(this.value=k,this.field.value=this.formatOutputValue(k),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};
a.Scrollbar.prototype.changeValueForScrollMovement=function(){h=this.evaluator;s=this.scrollManipulatorLimInf;m=this.scrollManipulatorLimSup;t=h.evalExpression(this.min);v=h.evalExpression(this.max);u=this.incr;k=d((this.pos-s)*(v-t)/(m-s)/u)*u+t;k!=this.value&&(this.value=k,this.field.value=this.formatOutputValue(k),h.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){h=this.evaluator;
s=this.scrollManipulatorLimInf;m=this.scrollManipulatorLimSup;t=h.evalExpression(this.min);v=h.evalExpression(this.max);u=this.incr;this.pos=(this.value-t)*(m-s)/(v-t)+s;this.orientation==f?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(v);if((s.up||s.down||s.canvasClick)&&1E-7<Math.abs(s.value-d))c.call(s),a=e?a:30,v=setTimeout(function(){b(a,c,!1,d)},a)}
function c(e){e.preventDefault();s.whichButton=a.whichButton(e);"L"==s.whichButton&&s.activeIfValue&&(s.clickPos=s.getCursorPosition(e),s.canvasClick=!0,s.orientation==f?s.clickPos.x<s.prePos?b(t,s.decrease10,!0,s.minimo):b(t,s.increase10,!0,s.maximo):s.clickPos.y<s.prePos?b(t,s.increase10,!0,s.maximo):b(t,s.decrease10,!0,s.minimo))}function e(a){s.canvasClick=!1;clearInterval(v);a.preventDefault()}function d(a){!0==s.canvasClick&&(s.clickPos=s.getCursorPosition(a),a.preventDefault())}function g(a){s.activeIfValue&&
(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("mouseup",j),window.addEventListener("mousemove",k),a.preventDefault())}function h(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("touchend",m),window.addEventListener("touchmove",onToucheMove_scrollManipulator),a.preventDefault())}function j(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("mouseup",j,!1);window.removeEventListener("mousemove",k,!1);a.preventDefault()}
function m(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("touchend",m,!1);window.removeEventListener("touchmove",k,!1);a.preventDefault()}function k(a){var b=s.getCursorPosition(a);s.orientation==f?(s.pos=s.prePos-(s.initPos.x-b.x),s.pos<s.scrollManipulatorLimInf&&(s.pos=s.scrollManipulatorLimInf),s.pos>s.scrollManipulatorLimSup&&(s.pos=s.scrollManipulatorLimSup),s.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+
s.scrollManipulatorW+"px; height : "+s.h+"px; left: "+s.pos+"px; top: 0px;")):(s.pos=s.prePos-(s.initPos.y-b.y),s.pos>s.scrollManipulatorLimInf&&(s.pos=s.scrollManipulatorLimInf),s.pos<s.scrollManipulatorLimSup&&(s.pos=s.scrollManipulatorLimSup),s.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+s.w+"px; height : "+s.scrollManipulatorH+"px; left: 0px; top: "+s.pos+"px;"));s.changeValueForScrollMovement();a.preventDefault()}
function n(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.up=!0,b(t,s.increase,!0,s.maximo))}function r(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.down=!0,b(t,s.decrease,!0,s.minimo))}function l(a){s.up=!1;clearInterval(v);a.preventDefault()}function p(a){s.down=!1;clearInterval(v);a.preventDefault()}function q(a){s.up=!1;clearInterval(v);a.preventDefault();s.draw()}function u(a){s.down=!1;clearInterval(v);
a.preventDefault();s.draw()}y=a.hasTouchSupport;var s=this,t=y?500:200,v;s.canvas.oncontextmenu=s.divUp.oncontextmenu=s.divDown.oncontextmenu=s.label.oncontextmenu=s.field.oncontextmenu=s.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&s.changeValue(s.field.value)});y?this.canvas.addEventListener("touchstart",c):this.canvas.addEventListener("mousedown",c);y||this.divDown.addEventListener("mouseout",p);y?window.addEventListener("touchend",
e):window.addEventListener("mouseup",e);y?this.canvas.addEventListener("touchmove",d):this.canvas.addEventListener("mousemove",d);y?this.scrollManipulator.addEventListener("touchstart",h):this.scrollManipulator.addEventListener("mousedown",g);y?this.divUp.addEventListener("touchstart",n):this.divUp.addEventListener("mousedown",n);y?this.divDown.addEventListener("touchstart",r):this.divDown.addEventListener("mousedown",r);y||this.divUp.addEventListener("mouseout",l);y||this.divDown.addEventListener("mouseout",
p);y?window.addEventListener("touchend",q):window.addEventListener("mouseup",q);y?window.addEventListener("touchend",u):window.addEventListener("mouseup",u)};a.Scrollbar.prototype.findOffset=function(){B=this.containerControl;this.offsetTop=this.offsetLeft=0;z=this.containerControl.style.display;for(this.containerControl.style.display="block";B;)this.offsetLeft+=B.offsetLeft||0,this.offsetTop+=B.offsetTop||0,B=B.parentNode;this.containerControl.style.display=z};a.Scrollbar.prototype.getCursorPosition=
function(b){D=a.getCursorPosition(b);return{x:D.x-this.offsetLeft,y:D.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,f=c.evaluator.evalExpression(c.expresion);4==f[0].length?(c.w=f[0][2],c.h=f[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(){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 f;a.Audio.prototype.update=function(){d=this.evaluator;(f=0<d.evalExpression(this.drawif))?this.audio.style.display="block":(this.audio.style.display="none",f!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=f;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d;a.Video=function(h,b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,h,b);var c=this;d=c.evaluator;var f=c.evaluator.evalExpression(c.expresion);4==f[0].length?(c.w=f[0][2],c.h=f[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 f=c.file,e=f.lastIndexOf(".");-1!=e&&(f=c.file.substring(0,e));c.video.canPlayType("video/mp4")&&(e=document.createElement("source"),e.setAttribute("src",f+".mp4"),e.setAttribute("type","video/mp4"),c.video.appendChild(e));c.video.canPlayType("video/ogg")&&(e=document.createElement("source"),e.setAttribute("src",f+".ogg"),e.setAttribute("type","video/ogg"),
c.video.appendChild(e),e=document.createElement("source"),e.setAttribute("src",f+".ogv"),e.setAttribute("type","video/ogg"),c.video.appendChild(e));c.video.canPlayType("video/webm")&&(e=document.createElement("source"),e.setAttribute("src",f+".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(){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 f;a.Video.prototype.update=function(){d=this.evaluator;f=0<d.evalExpression(this.drawif);0<d.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display=
"none",f!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=f;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,f;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(){f=this.answer?28:8;d=this.evaluator;var h;h=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-f)+"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;' >"+h+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-f)+"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,f,h,b,c,n,e,g,r,l;a.GraphicControl=function(b,c){h=b.evaluator.parser;this.text=this.spaceID="";this.size=h.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=h.parse(this.constraintExpr),"(expr)"==this.constraint.type&&(this.constraint=h.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,r=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(){f=this.evaluator;l=a.hasTouchSupport;var b=f.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];f.setVariable(this.xString,this.x);f.setVariable(this.yString,this.y);""!=this.imageSrc&&!this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.image=this.parent.getImage(this.imageSrc),
this.width=this.image.width,this.height=this.image.height):(this.width=2*f.evalExpression(this.size),this.height=2*f.evalExpression(this.size));this._w=l&&70>this.width?70:this.width;this._h=l&&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";f.setVariable(this.activoString,0);f.setVariable(this.activeString,0);this.setImage=!1;this.update()};a.GraphicControl.prototype.update=function(){f=this.evaluator;this.activeIfValue=0<f.evalExpression(this.activeif);this.drawIfValue=0<f.evalExpression(this.drawif);this.x=f.getVariable(this.xString);this.y=f.getVariable(this.yString);b=this.space.getAbsoluteX(this.x);c=this.space.getAbsoluteY(this.y);this.mouseCacher.style.display=!this.activeIfValue?
"none":"block";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(){f=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(){r.set(this.x,this.y);n=this.newt.findZero(r);this.x=n.x;this.y=n.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;f=this.evaluator;e.fillStyle=
this.color.getColor();e.font=this.font;e.textBaseline="alphabetic";e.fillText(f.evalExpression(this.text[0],f.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();f.whichButton=a.whichButton(c);"L"==f.whichButton&&(f.activeIfValue&&f.over)&&(f.parent.deactivateGraphiControls(),f.click=!0,f.active=!0,f.evaluator.setVariable(f.activoString,1),f.evaluator.setVariable(f.activeString,
1),f.evaluator.setVariable(f.mclickedString,0),f.evaluator.setVariable(f.mclicizquierdoString,0),f.posAnte=f.getCursorPosition(c),f.prePos={x:f.space.getAbsoluteX(f.x),y:f.space.getAbsoluteY(f.y)},f.evaluator.setVariable(f.mxString,f.space.getRelativeX(f.posAnte.x)),f.evaluator.setVariable(f.myString,f.space.getRelativeY(f.posAnte.y)),f.parent.update(),window.addEventListener("mouseup",e),window.addEventListener("mousemove",d))}function c(a){document.body.focus();a.preventDefault();f.activeIfValue&&
(f.parent.deactivateGraphiControls(),f.click=!0,f.active=!0,f.evaluator.setVariable(f.activoString,1),f.evaluator.setVariable(f.activeString,1),f.evaluator.setVariable(f.mclickedString,0),f.evaluator.setVariable(f.mclicizquierdoString,0),f.posAnte=f.getCursorPosition(a),f.prePos={x:f.space.getAbsoluteX(f.x),y:f.space.getAbsoluteY(f.y)},f.evaluator.setVariable(f.mxString,f.space.getRelativeX(f.posAnte.x)),f.evaluator.setVariable(f.myString,f.space.getRelativeY(f.posAnte.y)),f.parent.update(),window.addEventListener("touchmove",
d),window.addEventListener("touchend",e))}function e(b){document.body.focus();b.preventDefault();f.touchId=null;f.evaluator.setVariable(f.mclickedString,1);f.evaluator.setVariable(f.mclicizquierdoString,1);if(f.activeIfValue||f.active)f.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",d,!1),window.removeEventListener("touchend",e,!1)):(window.removeEventListener("mouseup",e,!1),window.removeEventListener("mousemove",d,!1)),f.evaluator.setVariable(f.mxString,f.space.getRelativeX(f.posAnte.x)+
f.x),f.evaluator.setVariable(f.myString,f.space.getRelativeY(f.posAnte.y)+f.y),f.parent.update(),f.mouseCacher.style.left=f.space.getAbsoluteX(f.x)-f._w/2+"px",f.mouseCacher.style.top=f.space.getAbsoluteY(f.y)-f._h/2+"px"}function d(a){a.preventDefault();a.touchId=f.touchId;f.evaluator.setVariable(f.mclickedString,0);f.evaluator.setVariable(f.mclicizquierdoString,0);n=f.getCursorPosition(a);f.posX=f.prePos.x-(f.posAnte.x-n.x);f.posY=f.prePos.y-(f.posAnte.y-n.y);f.evaluator.setVariable(f.xString,f.space.getRelativeX(f.posX));
f.evaluator.setVariable(f.yString,f.space.getRelativeY(f.posY));f.evaluator.setVariable(f.mxString,f.space.getRelativeX(f.posAnte.x)+f.space.getRelativeX(f.posX));f.evaluator.setVariable(f.myString,f.space.getRelativeY(f.posAnte.y)+f.space.getRelativeY(f.posY));f.parent.updateControls();f.parent.update()}function g(){f.over=!0}function h(){f.over=!1;f.click=!1}var f=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",h));var n};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var b;if(a.touchId){c=0;for(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 f,h,b,c,n,e,g,r,l,j;if(a.loadLib)return a;var p,q,u,
k,s,m,t,v,y=/[\w-//]*(\.png|\.jpg|\.gif|\.svg)/gi,B,z,D,E,A,x,F,G,J,H,w,K,C,I,L,N,Q,R,O,P,M;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(u=a[c][0],k=a[c][1],q=d[u],q){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[q]=
parseInt(k);break;case "about":case "config":case "init":case "clear":b[q]="true"===d[k];break;default:console.log("----- attributo de space no identificado: <"+u+"> valor: <"+k+"> -----")}return b};a.LessonParser.prototype.parseSpace=function(b){s={};b=this.split(b);for(var c=0,e=b.length;c<e;c++)switch(u=b[c][0],k=b[c][1],q=d[u],q){case "type":case "id":case "cID":case "file":s[q]=k;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":s[q]="true"===d[k];break;
case "bg_display":case "render":s[q]=d[k];break;case "net":case "net10":case "axes":case "text":s[q]="false"===d[k]?"":new a.Color(k,this.parent.evaluator);break;case "x_axis":case "y_axis":s[q]="false"===d[k]?"":k;break;case "O.x":s.OxExpr=k;break;case "O.y":s.OyExpr=k;break;case "image":s.imageSrc=k;break;case "x":p=k;p="%"===p[p.length-1]?(this.parent.container.width*parseFloat(p)/100).toString():k;s.xExpr=this.parser.parse(p);break;case "y":p=k;p="%"===p[p.length-1]?(this.parent.container.height*
parseFloat(p)/100).toString():k;s.yExpr=this.parser.parse(p);break;case "width":p=k;"%"===p[p.length-1]?(s.wExpr=p,p=this.parent.container.width*parseFloat(p)/100):(p=parseFloat(k),p!=k&&(p=this.parent.container.width));s.w=p;break;case "height":p=k;"%"===p[p.length-1]?(s.hExpr=p,p=this.parent.container.height*parseFloat(p)/100):(p=parseFloat(k),p!=k&&(p=this.parent.container.height));s.h=p;break;case "drawif":s.drawif=this.parser.parse(k);break;case "scale":p=parseFloat(k);isNaN(p)&&(p=48);s.scale=
p;break;case "background":s.background=new a.Color(k,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+u+"> valor: <"+k+"> -----")}switch(s.type){case "R2":return new a.Space2D(this.parent,s);case "R3":return new a.Space3D(this.parent,s);case "AP":return new a.SpaceAP(this.parent,s);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,s);default:return new a.Space2D(this.parent,s)}};a.LessonParser.prototype.parseControl=function(b){m={type:"numeric"};
b=this.split(b);for(var c=0,e=b.length;c<e;c++)switch(u=b[c][0],k=b[c][1],q=d[u],q){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":m[q]=k;break;case "gui":case "region":case "action":case "msg_pos":case "poster":m[q]=d[k];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":m[q]="true"===d[k];break;
case "color":case "colorInt":case "trace":m[q]=new a.Color(k,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":m[q]=this.parser.parse(k);break;case "constraint":m.constraintExpr=k;break;case "image":m.imageSrc=k;break;case "space":m.spaceID=k;break;case "type":m.type=d[k.trim()];break;case "expresion":m.expresion=this.parser.parse(k.replace(")(",","));break;case "bold":"false"!=d[k]&&(m.bold="bold");break;case "italics":"false"!=
d[k]&&(m.italics="italic");break;case "underlined":"false"!=d[k]&&(m.underlined=!0);break;case "value":var g=k.replace(/&squot;/g,"'");g.match(/^\|/)&&(g="'"+g.substring(1),g.match(/\|$/)&&(g=g.substring(0,g.length-1)+"'"));m.valueExpr=this.parser.parse(g);m.valueExprString=g;break;case "incr":0!=k&&(m.incr=this.parser.parse(k));break;case "exponentialif":m.exponentialif=parseFloat(k);break;case "text":m.rawText=k;for(var g=this.parseText(k),f=0,h=g.length;f<h;f++)g[f]=this.parser.parse(g[f],!1);
m.text=g;break;default:f=u.indexOf(".");g=d[u.substring(0,f)];f=d[u.substring(f+1)];if("parameter"===g&&"font"===f){m.parameterFont=k;break}else if("Explanation"===g&&"font"===f){m.ExplanationFont=k;break}else if("tooltip"===g&&"font"===f){m.tooltipFont=k;break}console.log("----- attributo de control no identificado: <"+u+"> valor: <"+k+"> -----")}if("numeric"===m.type)switch(m.gui){case "spinner":return new a.Spinner(this.parent,m);case "button":return new a.Button(this.parent,m);case "textfield":return new a.TextField(this.parent,
m);case "menu":return new a.Menu(this.parent,m);case "scrollbar":return new a.Scrollbar(this.parent,m);default:return new a.Spinner(this.parent,m)}else{if("video"===m.type)return new a.Video(this.parent,m);if("audio"===m.type)return new a.Audio(this.parent,m);if("graphic"===m.type)return new a.GraphicControl(this.parent,m);if("text"===m.type)return new a.TextArea(this.parent,m)}};a.LessonParser.prototype.parseGraphic=function(b,c,e,g){t={rotateExp:g,parameter:"t"};b=this.split(b);g=0;for(var f=b.length;g<
f;g++)switch(u=b[g][0],k=b[g][1],q=d[u],q){case "type":case "align":t[q]=d[k];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":t[q]="true"===d[k];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":t[q]="false"===d[k]?"":new a.Color(k,this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":t[q]=k;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":t[q]=
this.parser.parse(k);break;case "space":t.spaceID=k;break;case "expresion":"macro"!=t.type?(t.expresion=this.parser.parse(k),t.expresionString=k):t.expresion=k;break;case "text":t.text=this.parseText(k);break;case "file":var h=k.replace(/&squot;/g,"'");"["===h.charAt(0)&&"]"===h.charAt(h.length-1)&&(h=h.substring(1,h.length-1));h.match(y)&&(h="'"+h+"'");t.file=this.parser.parse(h);break;case "border":"false"!=d[k]&&(t.border=new a.Color(k,this.parent.evaluator));break;default:if(void 0!=t.family&&
u.substring(0,t.family.length+1)===t.family+"."){switch(d[u.substring(t.family.length+1)]){case "interval":t.family_interval=this.parser.parse(k);break;case "steps":t.family_steps=this.parser.parse(k)}break}if(void 0!=t.parameter&&u.match(t.parameter+".")){t.parameter!==u.substring(0,u.indexOf(t.parameter)+t.parameter.length)&&(t.parameter=u.substring(0,u.indexOf(t.parameter)+t.parameter.length));switch(d[u.substring(t.parameter.length+1)]){case "interval":t.parameter_interval=this.parser.parse(k);
break;case "steps":t.parameter_steps=this.parser.parse(k)}break}console.log("----- attributo del graphic no identificado: <"+u+"> valor: <"+k+"> -----")}c&&(t.abs_coord=c);e&&(t.background=e);switch(t.type){case "text":return new a.Text(this.parent,t);case "image":return new a.Image(this.parent,t);case "point":return new a.Point(this.parent,t);case "polygon":return new a.Polygon(this.parent,t);case "arc":return new a.Arc(this.parent,t);case "segment":return new a.Segment(this.parent,t);case "arrow":return new a.Arrow(this.parent,
t);case "macro":return new a.Macro(this.parent,t);case "curve":return new a.Curve(this.parent,t);case "equation":return new a.Equation(this.parent,t);case "sequence":return new a.Sequence(this.parent,t);case "fill":return new a.Fill(this.parent,t)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,e,g){t={rotateExp:g,parameter:"t"};b=this.split(b);c=0;for(e=b.length;c<e;c++)switch(u=b[c][0],k=b[c][1],q=d[u],q){case "type":case "model":t[q]=d[k];break;case "background":case "fixed":case "edges":t[q]=
"true"===d[k];break;case "color":case "backcolor":t[q]=new a.Color(k,this.parent.evaluator);break;case "type":case "model":t[q]=d[k];break;case "background":case "fixed":case "edges":case "split":t[q]="true"===d[k];break;case "color":case "backcolor":t[q]=new a.Color(k,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":t[q]=this.parser.parse(k);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":t[q]=
k;break;case "space":t.spaceID=k;break;case "expresion":"macro"!=t.type&&"curve"!=t.type&&"surface"!=t.type?(t.expresion=this.parser.parse(k),t.expresionString=k):t.expresion=k.replace(/\\n/g,"");break;case "text":g=this.parseText(k);for(var f=0,h=g.length;f<h;f++)g[f]=this.parser.parse(g[f],!1);t.text=g;break;case "file":g=k.replace(/&squot;/g,"'");"["===g.charAt(0)&&"]"===g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/./)&&(g="'"+g+"'");t.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":t[q]=
this.parser.parse(k);break;case "family":case "parameter":case "font":case "name":t[q]=k;break;case "space":t.spaceID=k;break;case "expresion":"macro"!=t.type&&"curve"!=t.type&&"surface"!=t.type?(t.expresion=this.parser.parse(k),t.expresionString=k):t.expresion=k;break;case "text":g=this.parseText(k);f=0;for(h=g.length;f<h;f++)g[f]=this.parser.parse(g[f],!1);t.text=g;break;case "file":g=k.replace(/&squot;/g,"'");"["===g.charAt(0)&&"]"===g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/./)&&
(g="'"+g+"'");t.file=this.parser.parse(g);break;default:if(void 0!==t.family&&u.substring(0,t.family.length+1)===t.family+"."){"interval"===d[u.substring(t.family.length+1)]?t.family_interval=this.parser.parse(k):t.family_steps=this.parser.parse(k);break}console.log("----- attributo del graphic3D no identificado: <"+u+"> valor: <"+k+"> -----")}switch(t.type){case "point":return new a.Point3D(this.parent,t);case "segment":return new a.Segment3D(this.parent,t);case "polygon":return new a.Polygon3D(this.parent,
t);case "curve":return new a.Curve3D(this.parent,t);case "triangle":return new a.Triangle3D(this.parent,t);case "face":return new a.Face3D(this.parent,t);case "polireg":return new a.Polireg3D(this.parent,t);case "surface":return new a.Surface3D(this.parent,t);case "text":return new a.Text3D(this.parent,t);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,
t);case "macro":return new a.Macro3D(this.parent,t);default:console.log(t.type)}};a.LessonParser.prototype.parseAuxiliar=function(b){v={};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(u=b[c][0],k=b[c][1],q=d[u],q){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":v[q]=k.replace(/&squot;/g,"'");break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":v[q]=
"true"===d[k];break;case "size":case "rows":case "columns":v[q]=this.parser.parse(k);break;case "evaluate":case "execution":case "msg_pos":case "action":v[q]=d[k];break;default:var g=u.indexOf("."),f=d[u.substring(0,g)],g=d[u.substring(g+1)];if("parameter"===f&&"font"===g){v.parameterFont=k;break}console.log("----- attributo de auxiliar no identificado: <"+u+"> valor: <"+k+"> -----")}v.sequence?new a.Function(this.parent,v):v.constant?(b=new a.Constant(this.parent,v),v.evaluate&&"always"===v.evaluate&&
this.parent.auxiliaries.push(b)):v.algorithm&&v.evaluate?(b=new a.Algorithm(this.parent,v),this.parent.auxiliaries.push(b)):v.array&&!v.matrix&&")"!=v.id.charAt(v.id.length-1)?(b=new a.Vector(this.parent,v),v.evaluate&&"always"===v.evaluate&&this.parent.auxiliaries.push(b)):v.matrix&&")"!=v.id.charAt(v.id.length-1)?(b=new a.Matrix(this.parent,v),v.evaluate&&"always"===v.evaluate&&this.parent.auxiliaries.push(b)):v.event&&")"!=v.id.charAt(v.id.length-1)?this.parent.events.push(new a.Event(this.parent,
v)):")"===v.id.charAt(v.id.length-1)?new a.Function(this.parent,v):new a.Variable(this.parent,v)};a.LessonParser.prototype.parseAction=function(b){B=b.action;z=b.parent;D=b.parameter;if(B)switch(B){case "message":return new a.Message(z,D);case "calculate":return new a.Calculate(z,D);case "openURL":return new a.OpenURL(z,D);case "openScene":return new a.OpenScene(z,D);case "about":return new a.About(z,D);case "config":return new a.Config(z,D);case "init":return new a.Init(z,D);case "clear":return new a.Clear(z,
D);case "animate":return new a.Animate(z,D);case "initAnimation":return new a.InitAnimation(z,D);case "playAudio":return new a.PlayAudio(z,D);default:console.log("----- Accion no soportada aun: <"+B+"> -----")}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(u=b[e][0],k=b[e][1],q=d[u],q){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[q]=k.replace(/&squot;/g,"'");break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[q]=
"true"===d[k];break;default:console.log("----- attributo de la animacion no identificado: <"+u+">  <"+k+"> -----")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(d,m){d=this.split(d);h=f="";b=0;c="#536891";n="white";e="left";g="";r="SansSerif,BOLD,20";l="SansSerif,PLAIN,18";j=void 0;for(var p=0,s=d.length;p<s;p++)switch(u=d[p][0],k=d[p][1],u){case "title":f=k;break;case "subtitle":h=k;break;case "subtitlines":b=k;break;case "bgcolor":""!=k&&(c=(new a.Color(k,this.parent.evaluator)).getColor());
break;case "fgcolor":""!=k&&(n=(new a.Color(k,this.parent.evaluator)).getColor());break;case "align":""!=k&&(e=k);break;case "titleimage":g=k;break;case "titlefont":r=""!=k?a.convertFont(k):a.convertFont(r);break;case "subtitlefont":l=""!=k?a.convertFont(k):a.convertFont(l);break;default:console.log("----- attributo de la pleca no identificado: <"+u+">  <"+k+"> -----")}if(""===f&&""===h)return document.createElement("div");H=l.substring(0,l.indexOf("px"));H=H.substring(H.lastIndexOf(" "));""!=g&&
(w=this.parent.getImage(g),K=w.height);j=document.createElement("div");j.setAttribute("id","descartesPleca");K?(j.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+e+"; width: "+(m-30)+"px; height: "+(K-16)+"px; background: "+c+"; color: "+n+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),w.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),
j.appendChild(w)):j.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+e+"; width: "+(m-30)+"px; background: "+c+"; color: "+n+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");C=document.createElement("div");C.setAttribute("style","padding: 0px; margin: 0px; font: "+r+"; overflow: hidden; white-space: nowrap;");C.innerHTML=f;I=document.createElement("div");if(1===parseInt(b)){O=0;L=document.createElement("div");
L.innerHTML=h;document.body.appendChild(L);Q=H;do Q-=O,L.setAttribute("style","padding: 0px; margin: 0px; font: "+l+"; font-size: "+Q+"px; width: "+(m-30)+"px; line-height: "+Q+"px;"),N=L.offsetHeight,R=N/Q,O=1;while(1<R&&8<Q);document.body.removeChild(L);I.setAttribute("style","padding: 0px; margin: 0px; font: "+l+"; font-size: "+Q+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else I.setAttribute("style","padding: 0px; margin: 0px; font: "+l+"; line-height: 110%;");I.innerHTML=
h;j.appendChild(C);j.appendChild(I);j.imageHeight=K;return j};a.LessonParser.prototype.split=function(a){if("string"!=typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");E=[];x=A=0;F=!1;G=0;for(J=!1;A<a.length;)" "===a.charAt(A)&&!F&&A++," "!==a.charAt(A)&&!F&&(F=!0,G=A),"="===a.charAt(A)&&("'"===a.charAt(A+1)&&!J)&&(J=!0,E[x]=[a.substring(G,A)],G=A+2,A+=2),J&&"'"===a.charAt(A)&&(F=J=!1,E[x].push(a.substring(G,A)),x++),"="===a.charAt(A)&&("'"!==a.charAt(A+1)&&!J)&&(E[x]=[a.substring(G,A)],G=A+1,
A++,P=a.substring(A).indexOf("="),-1===P?M=P=a.length:(P+=A,M=a.substring(A,P).lastIndexOf(" "),M=-1===M?a.length:M+A),E[x].push(a.substring(G,M)),x++,F=!1,A=M),A++;return E};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){u=[];u.type="matrix";u.rows=a;u.cols=b;var c;s=0;for(m=b;s<m;s++){c=[];k=0;for(t=a;k<t;k++)c.push(0);u[s]=c}return u}
function f(a,b){p=a.rows;q=a.cols;u=d(p,q);var c;for(s=0;s<p;s++)for(k=0;k<q;k++){for(m=c=0;m<q;m++)c+=a[m][s]*b[k][m];u[k][s]=c}return u}function h(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(h(0,d,a)),e=-e;return c}return a[0][0]}if(a.loadLib)return a;var c,n={},e=Math.floor,g,r,l,j;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="-",l=new a.Node("compOperator","=="),j=new a.Node("number","0"),l.addChild(this),l.addChild(j),r=this.getRoot(),r.setAllEvaluateFunction(),r):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(){return parseFloat(this.value)};else if("string"===this.type)this.evaluate=function(){return this.value};else if("identifier"===this.type&&0===this.childs.length)if("rnd"==this.value)this.evaluate=function(){return Math.random()};else{var a;this.evaluate=function(b,c){a=b.variables[this.value];if("object"===typeof a)return a.evaluate(b);if(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,j;this.evaluate=function(a){g=this.childs[0].childs[0].evaluate(a);try{return j=a.vectors[this.value][0>g?0:e(g)],void 0!==j?j:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var r,l;this.evaluate=function(a){r=this.childs[0].childs[0].evaluate(a);l=this.childs[0].childs[1].evaluate(a);try{return j=a.matrices[this.value][0>r?0:e(r)][0>l?0:e(l)],void 0!==j?j:0}catch(b){return 0}}}else if("identifier"===
this.type&&"parentheses"===this.childs[0].type){var m;this.evaluate=function(a){m=[];for(var b=0,e=this.childs[0].childs.length;b<e;b++)m[b]=this.childs[0].childs[b].evaluate(a);return"_Eval_"===this.value?(m[0]=0<m.length?m[0].toString():"",c=m[0].replace(a.parent.decimal_symbol_regexp,"."),void 0==n[c]&&(n[c]=a.parser.parse(c)),a.evalExpression(n[c])):a.functions[this.value].apply(a,m)}}else if("operator"===this.type){var t,x,F;"+"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,
!0);x=this.childs[1].evaluate(a,!0);if("matrix"!==t.type||"matrix"!==x.type)return t+x;a=t;var b=x;p=a.rows;q=a.cols;u=d(p,q);for(s=0;s<p;s++)for(k=0;k<q;k++)u[k][s]=a[k][s]+b[k][s];return u}:"-"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,!0);x=this.childs[1].evaluate(a,!0);if("matrix"!==t.type||"matrix"!==x.type)return t-x;a=t;var b=x;p=a.rows;q=a.cols;u=d(p,q);for(s=0;s<p;s++)for(k=0;k<q;k++)u[k][s]=a[k][s]-b[k][s];return u}:"*"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,
!0);x=this.childs[1].evaluate(a,!0);return"matrix"!==t.type||"matrix"!==x.type?t*x:f(t,x)}:"/"===this.value?this.evaluate=function(a){t=this.childs[0].evaluate(a,!0);x=this.childs[1].evaluate(a,!0);if("matrix"!==t.type||"matrix"!==x.type)return t/x;a=t;var c;c=x;var e=d(c.length,c.length),g=b(c);if(0===g)c=0;else{var g=1/g,j;if(1<c.length)for(var k=0,n=c.length;k<n;k++){j=g;for(var r=0;r<n;r++)e[r][k]=j*b(h(k,r,c)),j=-j;g=-g}else e[0][0]=g;c=e}a=0===c?d(a.rows,a.cols):f(a,c);return a}:"%"===this.value?
this.evaluate=function(a){t=this.childs[0].evaluate(a);x=this.childs[1].evaluate(a);return t-e(t/x)*x}:"^"===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(t=this.childs[0].evaluate(a)?
1:0)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return(t=this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){t=this.childs[0].evaluate(a)?1:0;return!t+0});else if("conditional"===this.type)this.evaluate=function(a){t=this.childs[0].evaluate(a);return 0<t?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 G,J;this.evaluate=function(a){G=this.childs.length;F=[];if(1===G&&1===this.childs[0].childs.length&&"(expr)"===this.type)F=this.childs[0].childs[0].evaluate(a);else for(var b=0;b<G;b++){J=[];for(var c=0,e=this.childs[b].childs.length;c<e;c++)J.push(this.childs[b].childs[c].evaluate(a));F[b]=J}return F}}else if("asign"===
this.type){var H,w,K,C,I,L;this.evaluate=function(a){H=this.childs[0];w=this.childs[1];1===H.childs.length&&"square_bracket"===H.childs[0].type?(g=H.childs[0].childs,1===g.length?(K=g[0].evaluate(a),K=0>K?0:e(K),a.vectors[H.value][K]=w.evaluate(a)):2===g.length&&(C=g[0].evaluate(a),I=g[1].evaluate(a),C=0>C?0:e(C),I=0>I?0:e(I),a.matrices[H.value][C]||(a.matrices[H.value][C]=[]),a.matrices[H.value][C][I]=w.evaluate(a))):(L=w.evaluate(a),L.type?a.matrices[H.value]=L:"object"!==typeof a.variables[H.value]&&
(a.variables[H.value]=L))}}};var p,q,u,k,s,m,t;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,f,h,b,c,n,e,g,r,l=/^\s+/,j=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,p=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,
q=/^==|^!=|^<=|^<|^>=|^>|^#/,u=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,k=/^=/,s=/^[\?\:]/,m=/^[\+\-\*\/\%\^]/,t=/^\[|^\]/,v=/^\(|^\)/,y=/^,/,B=/^;/,z=/\|/g,D=/\|\*/g,E=/\*\|/g;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function x(a,c,e){f.push({type:a,value:c});n=n.slice(e);b+=e;g++;r=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(D,"'").replace(E,
"'"));a.match(/\=\|/g)&&(a=a.replace(z,"'"));var A=a.trim();"|"==A.charAt(0)&&"|"==A.charAt(A.length-1)&&(a=A.replace(z,"'"))}f=[];h=!1;b=0;n=a;g=0;for(r="";a&&b<a.length;)if(h=b,"'"==n[0]){for(e=1;"'"!=n[e];)if(e<n.length)e++;else{console.log(">Error, unknown symbol: ["+n+"], in the string <<"+d+">>");return}c=n.substring(1,e);x("string",c,c.length+2)}else if(c=n.match(l))n=n.slice(c[0].length),b+=c[0].length,g++;else if(c=n.match(j))"number"===r&&f.push({type:"operator",value:"*"}),x("identifier",
c[0],c[0].length);else if(c=n.match(p))x("number",c[0],c[0].length);else if(c=n.match(q))A=c[0],"#"==A&&(A="!="),x("compOperator",A,c[0].length);else if(c=n.match(u))A=c[0],"||"==A?A="|":"&&"==A?A="&":"~"==A&&(A="!"),x("boolOperator",A,c[0].length);else if((c=n.match(k))&&!n.match(/^==/))x("asign",c[0],c[0].length);else if(c=n.match(s))x("conditional",c[0],c[0].length);else if(c=n.match(m))x("operator",c[0],c[0].length);else if(c=n.match(t))x("square_bracket",c[0],c[0].length);else if(c=n.match(v))"("==
c&&"number"===r&&f.push({type:"operator",value:"*"}),x("parentheses",c[0],c[0].length);else if(c=n.match(y))x("separator",c[0],c[0].length);else if(178===n.charCodeAt(0))f.push({type:"operator",value:"^"}),x("number",2,1);else if(179===n.charCodeAt(0))f.push({type:"operator",value:"^"}),x("number",3,1);else if(c=n.match(B))x("final_of_expresion",c[0],c[0].length);else if(h==b){console.log("Error, simbolo no conocido: ["+n+"], en la cadena <<"+d+">>");return}return f};var A,x=/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||"";A="";for(var c=0,e=a.length;c<e;c++)A="string"==a[c].type?A+"&squot;"+a[c].value+"&squot;":"identifier"==a[c].type&&!a[c].value.match(x)?A+b+a[c].value:A+a[c].value;return A};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 f,h,b,c,n,e,g,r,l,j,p,q;a.Parser.prototype.parse=function(d,k){(b=this.tokenizer.tokenize(d))||(b=[]);c=null;k=!k||!1;f=r=g=e=0;for(h=b.length;f<h;f++)if(l=b[f],j=l.value,p=l.type,"identifier"===p&&(f+1<h&&"parentheses"===
b[f+1].type&&"("===b[f+1].value?this.getFunction(j):f+1<h&&"square_bracket"===b[f+1].type&&"["===b[f+1].value?b[f+3]&&"square_bracket"===b[f+3].type&&"]"===b[f+3].value?this.getVector(j):this.getMatrix(j):this.getVariable(j)),"asign"===p&&k&&(p="compOperator",j="=="),"asign"===p)if(n=new a.Node(p,j),null!=c)if("identifier"===c.type)c.parent&&c.parent.replaceLastChild(n),n.addChild(c),c=n,k=!0;else if("square_bracket"===c.type)n.addChild(c.parent),c=n,k=!0;else{n.type="compOperator";n.value="==";for(k=
!0;c.parent&&this.getPrecedence(c.parent.value)>=this.getPrecedence(n.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(n);n.addChild(c);c=n}else{console.log("Error1: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else if("parentheses"===p&&"("===j||"square_bracket"===p&&"["===j)if(n=new a.Node(p,j),"("===j&&e++,"["===j&&g++,null===c)"("===j&&(new a.Node("(expr)","(expr)")).addChild(n),"["===j&&(new a.Node("[expr]","[expr]")).addChild(n),c=n;else if("operator"===c.type||
"boolOperator"===c.type||"compOperator"===c.type||"conditional"===c.type||"asign"===c.type)c.addChild(n),c=n;else if("sign"===c.type)c.addChild(n),c=n;else if("parentheses"===c.type&&"("===c.value)c.addChild(n),c=n;else if("square_bracket"===c.type&&"["===c.value)c.addChild(n),c=n;else if("parentheses"===c.type&&"()"===c.value)c.parent.addChild(n),c=n;else if("square_bracket"===c.type&&"[]"===c.value)c.parent.addChild(n),c=n;else if("identifier"===c.type)c.addChild(n),c=n;else{console.log("Error2: en la expresion <<"+
d+">>, en el token ["+f+"] {valor: "+j+", tipo: "+p+"}");break}else if("parentheses"===p&&")"===j)if(e--,null===c)console.log("Error3: en la expresion <<"+d+">>, en el token (valor:"+j+", tipo:"+p);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: "+j+", tipo: "+p+"}");break}}else if("square_bracket"===p&&"]"===j)if(g--,null===c)console.log("Error5: en la expresion <<"+d+">>, en el token (valor:"+
j+", tipo:"+p);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: "+j+", tipo: "+p+"}");break}}else if("number"===p||"string"===p||"identifier"===p)if(n=new a.Node(p,j),null===c)c=n;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(n),
c=n;else{console.log("Error7: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else if("operator"===p||"compOperator"===p||"boolOperator"===p)if(n=new a.Node(p,j),null===c)if("-"===j||"+"===j)n.type="sign",n.value="sign"+j,c=n;else if("!"===j)c=n;else{console.log("Error8: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else if("operator"===c.type||"compOperator"===c.type||"boolOperator"===c.type||"asign"===c.type||"conditional"===c.type||"square_bracket"===
c.type&&"["===c.value&&("-"===j||"+"===j||"!"===j)||"parentheses"===c.type&&"("===c.value&&("-"===j||"+"===j||"!"===j)){if("-"===j||"+"===j)n.type="sign",n.value="sign"+j;c.addChild(n);c=n}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(n.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(n);
n.addChild(c);c=n}else{console.log("Error9: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else if("conditional"===p)if(n=new a.Node(p,j),null!=c)if("?"===n.value){for(r++;c.parent&&this.getPrecedence(c.parent.value)>this.getPrecedence(n.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(n);n.addChild(c);c=n}else{for(r--;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: "+
j+", tipo: "+p+"}");break}}else{console.log("Error11: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");break}else if("separator"===p)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: "+j+", tipo: "+p+"}");break}else{console.log("Error13: en la expresion <<"+d+">>, en el token {valor: "+j+", tipo: "+p+"}");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!=r&&alert("Error, condicional incompleta: "+d);(q=c?c.getRoot():null)&&q.setAllEvaluateFunction();return q};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 parseFloat(a)};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,"\u00a6"):a.openExternalFile(b);var g=[],f=!1;if(d){d=d.replace(/\r/g,"").split("\n");for(var h=0,j=d.length;h<j;h++)d[h].match("<"+e+">")?(f=d[h].trim().split("<"+e+">"),2==f.length&&""!=f[1]&&(g=g.concat(f[1].split("\u00a6"))),f=!0):d[h].match("</"+e+">")?(f=d[h].trim().split("</"+e+">"),2==f.length&&""!=f[0]&&(g=g.concat(f[0].split("\u00a6"))),f=!1):f&&(g=g.concat(d[h].split("\u00a6")));h=0;for(j=g.length;h<j;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,"\u00a6"):a.openExternalFile(b);var f=[],h=!1;f.type="matrix";if(g){g=g.replace(/\r/g,"").split("\n");for(var j=0,n=g.length;j<n;j++)g[j].match("<"+e+">")?(h=g[j].trim().split("<"+e+">"),2==h.length&&
""!=h[1]&&f.push(h[1].split("\u00a6").map(d)),h=!0):g[j].match("</"+e+">")?(h=g[j].trim().split("</"+e+">"),2==h.length&&""!=h[0]&&f.push(h[0].split("\u00a6").map(d)),h=!1):h&&f.push(g[j].split("\u00a6").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,j,n,r=document.createElement("input");r.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(j,f[0].name);c.getFunction(n)&&(c.getFunction(n).apply(c.evaluator,[]),c.evaluator.parent.update())};0<f.length&&h.readAsText(f[0])};r.addEventListener("change",onHandleFileSelect);
this.functions._Open_=function(a,b){j=a;n=b;r.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 l,p,q=document.createElement("input");q.setAttribute("type","file");onHandleFileSelect2=function(a){a.stopPropagation();a.preventDefault();l=a.target.files;p=new FileReader;p.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<l.length&&p.readAsText(l[0])};q.removeEventListener("change",onHandleFileSelect2);q.addEventListener("change",onHandleFileSelect2);this.functions._OpenState_=function(){q.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))}};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,h,b){h=0>h?0:d(h);this.vectors[a][h]=b};a.Evaluator.prototype.getVector=function(a,h){h=0>h?0:d(h);return this.vectors[a][h]};a.Evaluator.prototype.setMatrix=function(a,h,b,c){h=0>h?0:d(h);b=0>b?0:d(b);this.matrices[a][h][b]=c};a.Evaluator.prototype.getMatrix=function(a,h,b){h=0>h?0:d(h);b=0>b?0:d(b);return this.matrices[a][h][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,f=!1,h;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,n=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 h=a.getFontMetrics(this.styleString);this.baseline=h.baseline;this.descent=h.descent;this.ascent=h.ascent;this.w=0;this.h=h.h}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);h=a.getFontMetrics(this.styleString);this.baseline=h.baseline;this.descent=h.descent;
this.ascent=h.ascent;var e=this.value,l;"string"!=typeof this.value&&(g=void 0==this.decimals?d:this.evaluator.evalExpression(this.decimals),l=void 0==this.fixed?f:this.fixed,e=this.evaluator.evalExpression(this.value,g,l),parseFloat(e).toString()===e.toString()&&(e=l?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=h.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 j=this;this.clickCacher.addEventListener("click",function(){j.click=!0;window.open(j.URL,
j.URL)})}else if("superIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,h=c,l=n,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=l/2-h+this.h,this.superIndexPos=e-this.ascent,this.ascent=e,this.descent=h,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),
g=b,h=c,l=n,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=h+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 p=this.children[0],q=this.children[1],e=a.getFontMetrics(p.styleString);p.getBlockMetric();
q.getBlockMetric();g=b;h=c;l=n;0>p.h&&(p.h=e.h,p.w=this.spaceWidth);0>q.h&&(q.h=e.h,q.w=this.spaceWidth);this.h=p.h+q.h-1;this.ascent=p.h+Math.round(l/2)-h;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=Math.max(p.w,q.w)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);h=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator," ","radicand",h),this.children[1].addChild(this.children[0]),
this.children[0]=new a.RTFNode(this.evaluator," ","index",h);else if("index"!==this.children[0].nodeType||"radicand"!==this.children[1].nodeType){l=new a.RTFNode(this.evaluator,"","radicand",h);e=0;for(g=this.children.length;e<g;e++)l.addChild(this.children[e]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",h);this.children[1]=l}e=this.children[0];g=this.children[1];0>=e.children.length&&(h=this.style.clone(),h.fontSize=parseInt(h.fontSize-0.2*h.fontSize),e.addChild(new a.RTFNode(this.evaluator,
" ","text",h)));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,h=c,l=n,h=this.children[0],g=this.children[1],l=this.children[2],h.getBlockMetric(),g.getBlockMetric(),
l.getBlockMetric(),-1==h.ascent&&(p=a.getFontMetrics(h.styleString),h.ascent=p.ascent,h.descent=p.descent,h.h=p.h),-1==g.ascent&&(p=a.getFontMetrics(g.styleString),g.ascent=p.ascent,g.descent=p.descent,g.h=p.h),e=a.getFontMetrics(this.styleString),this.ascent=e.h+g.h>l.ascent?e.h-e.descent+g.h:l.ascent,this.descent=h.h>l.descent?h.h+e.descent:l.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(h.w,g.w,e)+Math.max(l.w,this.spaceWidth)+this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,h=c,l=n,h=this.children[0],g=this.children[1],l=this.children[2],h.getBlockMetric(),g.getBlockMetric(),l.getBlockMetric(),-1==h.ascent&&(p=a.getFontMetrics(h.styleString),h.ascent=p.ascent,h.descent=p.descent,h.h=p.h),-1==g.ascent&&(p=a.getFontMetrics(g.styleString),g.ascent=p.ascent,g.descent=p.descent,g.h=p.h),e=a.getFontMetrics(this.styleString),
this.ascent=e.h+g.h>l.ascent?e.h-e.descent+g.h:l.ascent,this.descent=h.h>l.descent?h.h+e.descent:l.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(h.w,g.w,e)+Math.max(l.w,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,h=c,l=n,h=this.children[0],g=this.children[1],
l=this.children[2],e=a.getFontMetrics(this.styleString),h.getBlockMetric(),g.getBlockMetric(),l.getBlockMetric(),-1==h.ascent&&(p=a.getFontMetrics(h.styleString),h.ascent=p.ascent,h.descent=p.descent,h.h=p.h),-1==g.ascent&&(p=a.getFontMetrics(g.styleString),g.ascent=p.ascent,g.descent=p.descent,g.h=p.h),-1==l.ascent&&(p=a.getFontMetrics(l.styleString),l.ascent=p.ascent,l.descent=p.descent,l.h=p.h),this.ascent=l.ascent,this.descent=Math.max(e.h,l.descent),this.baseline=this.ascent,this.h=this.ascent+
this.descent,e=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==h.w&&(h.w=this.spaceWidth),0==g.w&&(g.w=this.spaceWidth),0==l.w&&(l.w=this.spaceWidth),this.w=g.w+h.w+l.w+e+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);e=a.getFontMetrics(this.styleString);g=b;h=c;l=n;l=e.ascent;for(var p=e.descent,q=e.h,u=this.spaceWidth,k,s,e=0,g=this.children.length;e<g;e++)this.children[e].getBlockMetric(),k=this.children[e].h,s=this.children[e].w,
q<k&&(q=k,l=this.children[e].ascent,p=this.children[e].descent),u<s&&(u=s);this.childWidth=u+2*this.spaceWidth;this.childh=q;this.childAscent=l;this.childDescent=p;this.h=this.rows*q;this.ascent=this.h/2+h;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;h=c;l=n;l=e.ascent;p=e.descent;q=e.h;u=this.spaceWidth;e=0;for(g=this.children.length;e<
g;e++)this.children[e].getBlockMetric(),k=this.children[e].h,s=this.children[e].w,q<k&&(q=k,l=this.children[e].ascent,p=this.children[e].descent),u<s&&(u=s);this.childWidth=u+2*this.spaceWidth;this.childh=q;this.childAscent=l;this.childDescent=p;this.h=this.parts*q;this.ascent=this.h/2+h;this.descent=this.h-this.ascent;this.w=u+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),h=a.getFontMetrics(this.styleString),this.baseline=h.baseline,this.descent=
h.descent,this.ascent=h.ascent,this.w=a.getTextWidth(this.value,this.styleString)+this.spaceWidth,this.h=h.h):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),h=this.componentNumCtrl.h||0,this.baseline=Math.round(3*h/5),this.descent=Math.round(2*h/5),this.ascent=this.baseline,this.h=h,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,h,f=0,j=this.children.length;f<j;f++){h=this.children[f];h.getTextMetrics();childAscent=h.ascent;childDescent=h.descent;this.w+=h.w;var p=childDescent;h=h.h;b=childAscent;c=p;n=h;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,n,j,p,q,u){h=u;this.stableWidth||(d=n,f=j,this.getTextMetrics());q=q?-this.children[0].ascent:0;j=n=0;for(p=this.children.length;j<p;j++)0<j&&(n+=this.children[j-1].h),this.children[j].draw(a,b+0,c+q+n)};a.RTFNode.prototype.drawTextLineBlock=function(a,b,c){for(var d=0,f=0,n=this.children.length;f<n;f++)a.strokeStyle=h,a.fillStyle=h,0<f&&(d+=this.children[f-1].w,"formula"==
this.children[f-1].nodeType&&(d+=2*this.children[f-1].spaceWidth)),this.children[f].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,c){for(var d=0,h=0,f=this.children.length;h<f;h++)0<h&&(d+=this.children[h-1].w),this.children[h].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,h=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)+h);a.lineTo(b-1+this.w,parseInt(c+this.descent/2)+h);a.stroke()}this.overline&&(h=(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)+h),a.lineTo(b-1+this.w,parseInt(c-this.ascent)+h),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,c,
h){var n=Math.floor(0.5*this.spaceWidth),j=void 0==this.decimals?d:this.evaluator.evalExpression(this.decimals),p=void 0==this.fixed?f:this.fixed,q=this.evaluator.evalExpression(this.value);parseFloat(q).toString()===q.toString()&&(q=p?parseFloat(q).toFixed(j):a.removeNeedlessDecimals(parseFloat(q).toFixed(j)),q=(""+q).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(q,this.styleString);
b.fillText(q,n+c,h);this.underline&&(p=(j="bold"==this.style.textBold)?1:0.5,b.lineWidth=j?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(n+c-1,parseInt(h+this.descent/2)+p),b.lineTo(n+c-1+this.w,parseInt(h+this.descent/2)+p),b.stroke());this.overline&&(p=(j="bold"==this.style.textBold)?2:1.5,b.lineWidth=j?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(n+c-1,parseInt(h-this.ascent)+p),b.lineTo(n+c-1+this.w,parseInt(h-this.ascent)+p),b.stroke());this.w+=
2*n};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,h=d?1:0.5;a.lineWidth=d?2:1;a.beginPath();a.moveTo(b-1,Math.ceil(c+this.descent/2)+h-2);a.lineTo(b-1+this.w,Math.ceil(c+this.descent/2)+h-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,h=0,f=this.children.length;h<
f;h++)0<h&&(d+=this.children[h-1].w),this.children[h].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,c){for(var d=0,h=0,f=this.children.length;h<f;h++)0<h&&(d+=this.children[h-1].w),this.children[h].draw(a,b+d,c+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,c){for(var d=0,h=0,f=this.children.length;h<f;h++)0<h&&(d+=this.children[h-1].w),this.children[h].draw(a,b+d,c-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,c,d){var h=a.getFontMetrics(this.styleString),
f=" "+String.fromCharCode(8594),n=a.getTextWidth(f,this.styleString);this.children[0].draw(b,c,d+h.descent+this.children[0].ascent);this.children[1].draw(b,c+this.children[0].w+n,d+h.descent+this.children[1].ascent);this.children[2].draw(b,c+n+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(f,c+this.children[0].w,d+h.descent+this.children[0].ascent)};
a.RTFNode.prototype.drawIntegral=function(b,c,d){var h=this.style.clone();h.fontSize*=1.5;h.fontType="Times New Roman";h.Bold="bold";var h=h.toString(),f=a.getTextWidth(String.fromCharCode(8747),h),n=a.getFontMetrics(h),q=Math.max(this.children[0].w,this.children[1].w,Math.floor(1.5*f));this.children[0].draw(b,c+f,d+n.descent+this.children[0].ascent);this.children[1].draw(b,c+f+this.spaceWidth/2,d-this.ascent+this.children[1].ascent);this.children[2].draw(b,c+q+f,d);null!=this.color&&(b.fillStyle=
this.color);b.font=h;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),c,d+n.descent/2)};a.RTFNode.prototype.drawSum=function(b,c,d){var h=this.style.clone();h.fontType="Times New Roman";h.Bold="bold";var h=h.toString(),f=a.getTextWidth(String.fromCharCode(8721),h),n=a.getFontMetrics(this.styleString),q=Math.max(this.children[0].w,this.children[1].w,f);this.children[0].draw(b,c+(q-this.children[0].w)/2,d+n.descent+this.children[0].ascent);this.children[1].draw(b,
c+(q-this.children[1].w)/2,d-n.ascent-this.children[1].descent);this.children[2].draw(b,c+q,d);null!=this.color&&(b.fillStyle=this.color);b.font=h;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),c+Math.floor((q-f)/2),d-5)};a.RTFNode.prototype.drawMatrix=function(a,b,c){for(var d,h,f=0,n=this.children.length;f<n;f++)d=f%this.columns,h=Math.floor(f/this.columns),this.children[f].draw(a,2*this.spaceWidth+b+d*this.childWidth,c-this.ascent+this.childAscent+h*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,h=this.children.length;d<h;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,h=0,f=this.children.length;h<f;h++)0<h&&(d+=this.children[h-1].w),this.children[h].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(){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,f,h,b,c,n,e,g,r,l,j,p;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[];f=[];h=a.length;f=[];b="";n=c=0;g=a.charAt(0);r=!1;for(l="text";c<h;)e=g,g=a.charAt(c+1),r?"\\"===g||"{"===g||"}"===g||" "===g||";"===g?(r=!1,b+=e," "===g&&(c++,g=a.charAt(c+1)),(j=b.match(/^\'([0-9a-f]{2})/))?(p="","text"===l&&(p=
f.pop().value),b=p+=d(parseInt(j[1],16))+b.substring(3)):(j=b.match(/^u[0-9]+/))?(p="","text"===l&&(p=f.pop().value),b=p+=d(j[0].substring(1))):("{"===b||"}"===b?(f.push({type:"text",value:b}),l="text"):(f.push({type:"controlWord",value:b}),l="controlWord"),b="")):b+=e:"\\"===e?(r=!0,""!==b&&(f.push({type:"text",value:b}),l="text"),b=""):"{"===e?(n++,""!==b&&f.push({type:"text",value:b}),b="",f.push({type:"openBlock",value:n}),l="openBlock"):"}"===e?(""!==b&&f.push({type:"text",value:b}),b="",f.push({type:"closeBlock",
value:n}),l="closeBlock",n--):b+=e,c++;""!==b&&f.push({type:"text",value:b});return f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,f,h,b,c,n,e,g,r,l,j,p,q,u,k,s,m,t,v,y,B,z,D,E,A,x,F,G,J,H;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=new a.RTFTokenizer};a.RTFParser.prototype.parse=function(w){w=d=this.tokenizer.tokenize(w);for(var K=[],C=!1,I=!1,L=[],N=0,Q=w.length;N<Q;N++){"openBlock"==w[N].type&&L.push(w[N].value);"closeBlock"==w[N].type&&(L.pop(),0>=
L.length&&(C=!1));if("controlWord"==w[N].type&&("expr"==w[N].value||"decimals"==w[N].value))I=!0;"controlWord"==w[N].type&&"mjaformula"==w[N].value&&(C=!0);if("text"==w[N].type&&C&&!I){for(var R=0,O=w[N].value,P="",M=0,T=O.length;M<T;M++)if("("==O.charAt(M)||")"==O.charAt(M)||"+"==O.charAt(M)||"-"==O.charAt(M)||"*"==O.charAt(M)||"="==O.charAt(M))P=O.substring(R,M),""!=P&&K.push({type:"text",value:P}),K.push({type:O.charAt(M),value:O.charAt(M)}),R=M+1;P=O.substring(R,M);""!=P&&K.push({type:"text",
value:P})}else K.push(w[N]),"text"==w[N].type&&I&&(I=!1)}d=K;f={};b=2;if("openBlock"==d[0].type&&"fonttbl"==d[1].value){for(h=d[0].value;"closeBlock"!=d[b].type&&d[b].value!=h;)f[d[b].value]=d[b+2].value.substring(0,d[b+2].value.length-1),b+=3;b++}c={};n=0;if("openBlock"==d[b].type&&"colortbl"==d[b+1].value){h=d[b++].value;for(b++;"closeBlock"!=d[b].type&&d[b].value!=h;)e=parseInt(d[b++].value.substring(3)).toString(16),g=parseInt(d[b++].value.substring(5)).toString(16),r=parseInt(d[b++].value.substring(4)).toString(16),
";"===d[b].value&&b++,c[n++]="#"+(2>e.length?"0"+e:e)+(2>g.length?"0"+g:g)+(2>r.length?"0"+r:r);b++}l=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");j=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");l.addChild(j);u=q=p=null;y=v=t=m=s=k=!1;B=[new a.FontStyle(20,"Arial","","",!1,!1,null)];z=B[0];D=!0;A=E=-1;x=[];H=J=G=F=!1;w=b;for(K=d.length;w<K;w++)if("controlWord"==d[w].type&&f[d[w].value])z.fontType=f[d[w].value];else if("controlWord"==d[w].type&&d[w].value.match(/^fs(\d+)/))z.fontSize=
parseInt(d[w].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==d[w].type&&"b"==d[w].value)z.textBold="bold";else if("controlWord"==d[w].type&&"b0"==d[w].value)z.textBold="";else if("controlWord"==d[w].type&&"i"==d[w].value)z.textItalic="italic";else if("controlWord"==d[w].type&&"i0"==d[w].value)z.textItalic="";else if("controlWord"==d[w].type&&"ul"==d[w].value)z.textUnderline=!0;else if("controlWord"==d[w].type&&"ulnone"==d[w].value)z.textUnderline=!1;else if("controlWord"==d[w].type&&"ol"==d[w].value)z.textOverline=
!0;else if("controlWord"==d[w].type&&"olnone"==d[w].value)z.textOverline=!1;else if("controlWord"==d[w].type&&d[w].value.match(/^cf(\d+)/))z.textColor=c[parseInt(d[w].value.substring(2))],0<x.length&&(x[x.length-1].style.textColor=z.textColor);else if("openBlock"==d[w].type)E=d[w].value,z=z.clone(),B.push(z),x.push(null);else if("closeBlock"==d[w].type)d[w].value==A&&(A=-1,k=!1,j=j.parent),B.pop(),z=B[B.length-1],x.pop();else if("controlWord"==d[w].type&&"par"==d[w].value){j.addChild(new a.RTFNode(this.evaluator,
"","newLine",z.clone()));l=new a.RTFNode(this.evaluator,"","textLineBlock",z.clone());if("textBlock"!=j.nodeType)for(j=j.parent;"textBlock"!=j.nodeType;)j=j.parent;j.addChild(l);j=l}else if("controlWord"==d[w].type&&"mjaformula"==d[w].value)F=!0,A=E,k=!0,l=new a.RTFNode(this.evaluator,"","formula",z.clone()),j.addChild(l),j=l,x[x.length-1]=l;else if("controlWord"==d[w].type&&("fraction"==d[w].value||"radicand"==d[w].value||"radical"==d[w].value||"what"==d[w].value||"sum"==d[w].value||"integral"==
d[w].value||"limit"==d[w].value))C=x[x.length-2].style.clone(),l=new a.RTFNode(this.evaluator,"",d[w].value,C),x[x.length-2].addChild(l),x[x.length-1]=l;else if("controlWord"==d[w].type&&"index"==d[w].value||"to"==d[w].value||"from"==d[w].value)C=x[x.length-2].style.clone(),C.fontSize=parseInt(C.fontSize-0.2*C.fontSize),8>C.fontSize&&(C.fontSize=8),l=new a.RTFNode(this.evaluator,"",d[w].value,C),x[x.length-2].addChild(l),x[x.length-1]=l;else if("controlWord"==d[w].type&&("num"==d[w].value||"den"==
d[w].value))C=x[x.length-2].style.clone(),C.fontSize=Math.round(C.fontSize-0.1*C.fontSize),8>C.fontSize&&(C.fontSize=8),"num"==d[w].value?l=new a.RTFNode(this.evaluator,"","numerator",C):"den"==d[w].value&&(l=new a.RTFNode(this.evaluator,"","denominator",C)),x[x.length-2].addChild(l),x[x.length-1]=l;else if("controlWord"==d[w].type&&("subix"==d[w].value||"supix"==d[w].value))C=x[x.length-2].style.clone(),C.fontSize=Math.floor(C.fontSize-C.fontSize/3),8>C.fontSize&&(C.fontSize=8),"subix"==d[w].value?
l=new a.RTFNode(this.evaluator,"","subIndex",C):"supix"==d[w].value&&(l=new a.RTFNode(this.evaluator,"","superIndex",C)),l.originalStyle=x[x.length-2].style.clone(),x[x.length-2].addChild(l),x[x.length-1]=l;else if("controlWord"==d[w].type&&("defparts"==d[w].value||"matrix"==d[w].value||"element"==d[w].value))C=x[x.length-2].style.clone(),l=new a.RTFNode(this.evaluator,"",d[w].value,C),x[x.length-2].addChild(l),x[x.length-1]=l,"defparts"==d[w].value?u=l:"matrix"==d[w].value&&(q=l);else if("controlWord"==
d[w].type&&"parts"==d[w].value)y=!0;else if("text"==d[w].type&&y)u.parts=parseInt(d[w].value),y=!1;else if("controlWord"==d[w].type&&"rows"==d[w].value)t=!0;else if("text"==d[w].type&&t)q.rows=parseInt(d[w].value),t=!1;else if("controlWord"==d[w].type&&"columns"==d[w].value)v=!0;else if("text"==d[w].type&&v)q.columns=parseInt(d[w].value),v=!1;else if("controlWord"==d[w].type&&"expr"==d[w].value)D=!1,s=!0;else if("controlWord"==d[w].type&&"decimals"==d[w].value)m=!0;else if("text"==d[w].type&&m)p.decimals=
this.evaluator.parser.parse(d[w].value+""),m=!1;else if("controlWord"==d[w].type&&"fixed1"==d[w].value)p.fixed=!0;else if("controlWord"==d[w].type&&"fixed0"==d[w].value)p.fixed=!1;else if(!("controlWord"==d[w].type&&"component"==d[w].value))if("controlWord"==d[w].type&&"NumCtrl"==d[w].value)G=!0;else if("controlWord"==d[w].type&&"Space"==d[w].value)J=!0;else if("controlWord"==d[w].type&&"hyperlink"==d[w].value)H=!0;else if("text"==d[w].type&&H){textContent=d[w].value.split("|")[0];C=z.clone();l=new a.RTFNode(this.evaluator,
textContent,"hyperlink",C);l.URL=d[w].value.split("|")[1];if("textLineBlock"!=j.nodeType)for(j=j.parent;"textLineBlock"!=j.nodeType;)j=j.parent;j.addChild(l);H=!1}else if("text"==d[w].type&&G)l=new a.RTFNode(this.evaluator,d[w].value,"componentNumCtrl",z.clone()),j.addChild(l),G=!1;else if("text"==d[w].type&&J)l=new a.RTFNode(this.evaluator,d[w].value,"componentSpace",z.clone()),j.addChild(l),J=!1;else if("text"==d[w].type&&s)C=x[x.length-2].style.clone(),textContent=this.evaluator.parser.parse(d[w].value),
l=new a.RTFNode(this.evaluator,textContent,"dynamicText",C),x[x.length-2].addChild(l),p=x[x.length-1]=l,s=!1;else if("text"==d[w].type&&!s&&!k){textContent=d[w].value;l=new a.RTFNode(this.evaluator,textContent,"text",z.clone());if("textLineBlock"!=j.nodeType)for(j=j.parent;"textLineBlock"!=j.nodeType;)j=j.parent;j.addChild(l)}else if("text"==d[w].type&&!s&&k)textContent=d[w].value,l=new a.RTFNode(this.evaluator,textContent,"text",x[x.length-1].style.clone()),x[x.length-1].addChild(l);else if("("==
d[w].type||")"==d[w].type)C=x[x.length-1].style.clone(),C.textItalic="",l=new a.RTFNode(this.evaluator,d[w].type,"mathSymbol",C),x[x.length-1].addChild(l);else if("+"==d[w].type||"-"==d[w].type||"*"==d[w].type||"="==d[w].type)l=new a.RTFNode(this.evaluator,d[w].type,"mathSymbol",x[x.length-1].style.clone()),x[x.length-1].addChild(l);if(null!=j){var S=j.getRoot();S.stableWidth=D;S.getTextMetrics();S.hasFormula=F}return S};a.FontStyle=function(a,b,c,d,e,h,g){this.fontSize=a;this.fontType=b;this.textItalic=
c;this.textBold=d;this.textUnderline=e;this.textOverline=h;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,f,h,b,c,n,e,g,r,l,j,p,q,u;a.Space=function(b,c){this.parent=b;f=this.evaluator=this.parent.evaluator;h=f.parser;this.id="";this.values=c;this.type="R2";this.xExpr=h.parse("0");this.yExpr=h.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=h.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;f=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=f.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=f.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?(n=g-this.x,this.w>n&&(this.w=n)):(n=this.w+this.x,this.w=n>=g?g:n);if(""!=this.imageSrc||!this.imageSrc.trim().toLowerCase().match(/vacio.gif$/))this.image=d.getImage(this.imageSrc);this.OxExpr&&(l=this.OxExpr,"%"===l[l.length-1]?this.Ox=this.w*parseFloat(l)/100:(r=parseFloat(l),r!=l&&(r=0),this.Ox=r));this.OyExpr&&(j=this.OyExpr,"%"===j[j.length-1]?this.Oy=this.h*
parseFloat(j)/100:(r=parseFloat(j),r!=j&&(r=0),this.Oy=r));""!==this.id&&2!==d.version?(f.setVariable(b+"._w",this.w),f.setVariable(b+"._h",this.h),f.setVariable(b+".escala",this.scale),f.setVariable(b+".Ox",this.Ox),f.setVariable(b+".Oy",this.Oy),f.setVariable(b+".mouse_x",0),f.setVariable(b+".mouse_y",0),f.setVariable(b+".mouse_pressed",0),f.setVariable(b+".mouse_clicked",0),f.setVariable(b+".clic_izquierdo",0)):(r=f.getVariable("_w"),void 0===r&&(r=this.w),f.setVariable("_w",r),r=f.getVariable("_h"),
void 0===r&&(r=this.h),f.setVariable("_h",r),r=f.getVariable("escala"),void 0===r&&(r=this.scale),f.setVariable("escala",r),r=f.getVariable("Ox"),void 0===r&&(r=this.Ox),f.setVariable("Ox",r),r=f.getVariable("Oy"),void 0===r&&(r=this.Oy),f.setVariable("Oy",r),f.setVariable("mouse_x",0),f.setVariable("mouse_y",0),f.setVariable("mouse_pressed",0),f.setVariable("mouse_clicked",0),f.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(){p=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(q=this.container.style.display);this.container.style.display="block";if(p.getBoundingClientRect){var a=p.getBoundingClientRect();this.offsetLeft=a.left;
this.offsetTop=a.top}else for(;p;)p.tagName&&"html"!==p.tagName.toLowerCase()?(this.offsetLeft+=p.offsetLeft||0,this.offsetTop+=p.offsetTop||0,p=p.parentNode):p=null;this.container&&this.container.style&&(this.container.style.display=q)};a.Space.prototype.getCursorPosition=function(b){u=a.getCursorPosition(b);return{x:u.x-this.offsetLeft,y:u.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 f(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 h(a){a.preventDefault();d.findOffset();document.body.removeEventListener("mousemove",f);document.body.removeEventListener("mouseup",h)}document.body.appendChild(this.container);d=this;var b=d.parent.evaluator.parser,c;c=0;for(var n=d.ctrs.length;c<n;c++)d.ctrs[c].expresion=b.parse("(0,"+(d.vSpace+23+35*c)+","+d.width+",35)"),d.ctrs[c].update();d.numCtr=
n;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*n)+","+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*n)+","+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*n)+","+d.width/2+",25)")});b.update();b.canvas.addEventListener("click",function(){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",f);document.body.addEventListener("mouseup",h)});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,f;if(a.loadLib)return a;var h=Math.floor,b=Math.round,c=2*Math.PI,n=a.convertFont("SansSerif,PLAIN,12"),e=a.convertFont("Monospaced,PLAIN,12"),
g,r,l,j,p,q,u,k,s,m,t,v,y,B,z,D,E,A,x,F,G,J,H,w,K,C,I,L,N;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;r=g.evaluator;l=g.parent;r.setVariable(g.wString,g.w);r.setVariable(g.hString,g.h);g.drawIfValue=0<r.evalExpression(g.drawif);if(g.drawIfValue){p=g.x!==r.evalExpression(g.xExpr)+g.displaceRegionWest;q=g.y!==r.evalExpression(g.yExpr)+l.plecaHeight+g.displaceRegionNorth;g.spaceChange=
a||p||q||g.drawBefore!==g.drawIfValue||g.Ox!==r.getVariable(g.OxString)||g.Oy!==r.getVariable(g.OyString)||g.scale!==r.getVariable(g.scaleString);g.x=p?r.evalExpression(g.xExpr)+g.displaceRegionWest:g.x;g.y=q?r.evalExpression(g.yExpr)+l.plecaHeight+g.displaceRegionNorth:g.y;g.Ox=r.getVariable(g.OxString);g.Oy=r.getVariable(g.OyString);g.scale=r.getVariable(g.scaleString);g.drawBefore=g.drawIfValue;1E-6>g.scale?(g.scale=1E-6,r.setVariable(g.scaleString,1E-6)):1E6<g.scale&&(g.scale=1E6,r.setVariable(g.scaleString,
1E6));if(p||q)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(){r=this.evaluator;j=this.backgroundCtx;j.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);j.fillStyle=this.background.getColor();j.fillRect(0,0,this.backgroundCanvas.width,
this.backgroundCanvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?j.drawImage(this.image,0,0):"stretch"===this.bg_display?j.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?(j.fillStyle=j.createPattern(this.image,"repeat"),j.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&j.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));k=this.scale;s=0;for(m=0>this.w+
this.h?0:this.w+this.h;k>m;)k/=10,s++;for(;k<m/10;)k*=10;j.lineWidth=1;""!==this.net&&(j.strokeStyle=this.net.getColor(),this.drawMarks(j,k/10,-1));if(2!==this.parent.version&&""!==this.net10||2===this.parent.version&&""!==this.net&&""!==this.net10)j.strokeStyle=this.net10.getColor(),this.drawMarks(j,k,-1);if(""!==this.axes){j.strokeStyle=this.axes.getColor();j.beginPath();if(""!==this.x_axis||2!==this.parent.version)j.moveTo(0,h(this.h/2+this.Oy)+0.5),j.lineTo(this.w,h(this.h/2+this.Oy)+0.5);if(""!==
this.y_axis||2!==this.parent.version)j.moveTo(h(this.w/2+this.Ox)+0.5,0),j.lineTo(h(this.w/2+this.Ox)+0.5,this.h);j.stroke();this.drawMarks(j,k,4);this.drawMarks(j,k/2,2);this.drawMarks(j,k/10,1)}if(""!==this.x_axis||""!==this.y_axis)j.fillStyle=""!==this.axes?this.axes.getColor():"black",j.font=n,j.textAlign="right",j.textBaseline="alphabetic",j.fillText(this.x_axis,h(this.w)-2,h(this.h/2+this.Oy)+12),j.fillText(this.y_axis,h(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(j.fillStyle=this.axes.getColor(),
j.font=n,j.textAlign="start",j.textBaseline="bottom",k>(this.w+this.h)/2?this.drawNumbers(j,k/5,k<=this.scale?s+1:s):k>(this.w+this.h)/4?this.drawNumbers(j,k/2,k<=this.scale?s+1:s):this.drawNumbers(j,k,s));for(var a=0,b=this.backgroundGraphics.length;a<b;a++)this.backgroundGraphics[a].draw()};a.Space2D.prototype.draw=function(){j=this.ctx;j.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=0,b=this.graphics.length;a<b;a++)u=this.graphics[a],""!==u.trace&&this.drawTrace&&u.drawTrace(),
u.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)&&(j.fillStyle=this.text.getColor(),j.strokeStyle=j.fillStyle,j.lineWidth=1,j.font=e,j.textAlign="center",j.textBaseline="alphabetic",G=1>=this.scale?this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length),J=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),H="("+G+","+J+")",w=h(j.measureText(H).width/
2),K=this.getAbsoluteX(this.mouse_x),C=this.getAbsoluteY(this.mouse_y),I=h(K),L=h(C-10),I+w>this.w?I=this.w-w:0>I-w&&(I=w),L+1>this.h?L=this.h:0>L-14&&(L=15),j.fillText(H,I,L),j.beginPath(),j.arc(K,C,2.5,0,c,!0),j.stroke())};a.Space2D.prototype.drawMarks=function(a,c,d){t=this.w;v=this.h;E=0;A=t;x=0;F=v;z=h(t/2+this.Ox);D=h(v/2+this.Oy);0<=d&&(E=z-d,A=z+d,x=D-d,F=D+d);a.beginPath();for(d=-b(z/c);(y=z+b(d*c))<t;d++)a.moveTo(y+0.5,x+0.5),a.lineTo(y+0.5,F+0.5);for(d=-b(D/c);(B=D+b(d*c))<v;d++)a.moveTo(E+
0.5,B+0.5),a.lineTo(A+0.5,B+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,c){t=this.w;v=this.h;z=h(t/2+this.Ox);D=h(v/2+this.Oy);for(var d=-b(z/c);(y=z+b(d*c))<t;d++)a.fillText(parseFloat((d*c/this.scale).toFixed(4)),y+1,D-2);for(d=-b(D/c);(B=D+b(d*c))<v;d++)0!==parseFloat(-d*c/this.scale)&&a.fillText(parseFloat((-d*c/this.scale).toFixed(4)),z+5,B+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();n(a);window.addEventListener("touchmove",k);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",k,!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",j)));"L"===l.whichButton&&(l.evaluator.setVariable(l.mpressedString,1),l.evaluator.setVariable(l.mclickedString,
0),l.evaluator.setVariable(l.mclicizquierdoString,0),n(b),window.addEventListener("mousemove",k),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",j,!1),l.clickPosForZoom==l.clickPosForZoomNew&&l.parent.externalSpace.show());window.removeEventListener("mousemove",
k,!1);window.removeEventListener("mouseup",g,!1);l.parent.update()}function n(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()-m&&(l.parent.update(),m=Date.now())}function j(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 k(a){a.preventDefault();a.stopPropagation();l.fixed||(l.posNext=l.getCursorPosition(a),d=h(l.posAnte.x-l.posNext.x),f=h(l.posAnte.y-l.posNext.y),l.evaluator.setVariable(l.OxString,l.Ox-d),l.evaluator.setVariable(l.OyString,l.Oy-f),l.posAnte.x-=d,l.posAnte.y-=f);n(a)}var m=0,l=this;N=a.hasTouchSupport;l.canvas.oncontextmenu=function(){return!1};N&&(this.sensitive_to_mouse_movements&&
this.canvas.addEventListener("touchmove",n),this.canvas.addEventListener("touchstart",b));N||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",n),this.canvas.addEventListener("mousedown",e))};return a}(descartesJS||{}),descartesJS=function(a){var d,f,h;function b(a,b){return b.depth-a.depth}function c(b,c){X=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));U=a.add3D(b,a.scalarProduct3D(X,-2));V=a.norm3D(U);return 0!==V?a.scalarProduct3D(U,1/V):a.scalarProduct3D(b,
-1)}if(a.loadLib)return a;var n=Math.floor,e=Math.round,g=Math.max,r=Math.cos,l=Math.sin,j=Math.sqrt,p=15*Math.PI/180,q=Math.cos(p),u=Math.sin(p),k,s,m,t,v,y,B,z,D,E,A,x,F,G,J,H,w,K,C,I,L,N,Q,R=[],O,P,M,T,S,W,X,U,V;a.Space3D=function(b,c){a.Space.call(this,b,c);m=this;m.backgroundCanvas=document.createElement("canvas");m.backgroundCanvas.setAttribute("id",m.id+"_background");m.backgroundCanvas.setAttribute("width",m.w+"px");m.backgroundCanvas.setAttribute("height",m.h+"px");m.canvas=document.createElement("canvas");
m.canvas.setAttribute("id",m.id+"_canvas");m.canvas.setAttribute("width",m.w+"px");m.canvas.setAttribute("height",m.h+"px");m.canvas.setAttribute("class","DescartesSpace3DCanvas");m.canvas.setAttribute("style","z-index: "+m.zIndex+";");m.ctx=m.canvas.getContext("2d");m.ctx.imageSmoothingEnabled=!1;m.ctx.mozImageSmoothingEnabled=!1;m.ctx.webkitImageSmoothingEnabled=!1;m.graphicControlContainer=document.createElement("div");m.graphicControlContainer.setAttribute("id",m.id+"_graphicControls");m.graphicControlContainer.setAttribute("style",
"position: absolute; left: 0px; top: 0px; z-index: "+m.zIndex+";");m.numericalControlContainer=document.createElement("div");m.numericalControlContainer.setAttribute("id",m.id+"_numericalControls");m.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+m.zIndex+";");m.container=document.createElement("div");m.container.setAttribute("id",m.id);m.container.setAttribute("class","DescartesSpace3DContainer");m.container.setAttribute("style","left: "+m.x+"px; top: "+
m.y+"px; z-index: "+m.zIndex+";");m.container.appendChild(m.backgroundCanvas);m.container.appendChild(m.canvas);m.container.appendChild(m.graphicControlContainer);m.container.appendChild(m.numericalControlContainer);b.container.insertBefore(m.container,b.loader);m.eye={x:0,y:0,z:0};m.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,h=m.lights.length;d<h;d++)m.lights[d]=a.normalize3D(m.lights[d]);m.light3={x:0,y:0,z:0};m.intensity=[0.4,0.5,0.3,0];m.userIntensity=
0;m.dim=1;m.tmpIntensity=[];m.OxStr=m.id+".Ox";m.OyStr=m.id+".Oy";m.scaleStr=m.id+".escala";m.wStr=m.id+"._w";m.hStr=m.id+"._h";m.obsStr=m.id+".observador";m.rotZStr=m.id+".rot.z";m.rotYStr=m.id+".rot.y";m.userI_Dim_Str=m.id+".userIlum.dim";m.userI_I_Str=m.id+".userIlum.I";m.userI_x_Str=m.id+".userIlum.x";m.userI_y_Str=m.id+".userIlum.y";m.userI_z_Str=m.id+".userIlum.z";m.evaluator.setVariable(m.rotZStr,0);m.evaluator.setVariable(m.rotYStr,0);m.evaluator.setVariable(m.userI_Dim_Str,m.dim);m.evaluator.setVariable(m.userI_I_Str,
m.userIntensity);m.evaluator.setVariable(m.userI_x_Str,0);m.evaluator.setVariable(m.userI_y_Str,0);m.evaluator.setVariable(m.userI_z_Str,0);m.registerMouseAndTouchEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(){m=this;m.uber.init.call(m);m.canvas&&(m.canvas.setAttribute("width",m.w+"px"),m.canvas.setAttribute("height",m.h+"px"));m.container&&m.findOffset();m.w_2=m.w/2;m.h_2=m.h/2;m.oldMouse={x:0,y:0}};a.Space3D.prototype.update=function(a){m=this;k=m.evaluator;s=m.parent;
k.setVariable(m.wStr,m.w);k.setVariable(m.hStr,m.h);m.drawIfValue=0<k.evalExpression(m.drawif);if(m.drawIfValue){D=m.x!==k.evalExpression(m.xExpr)+m.displaceRegionWest;E=m.y!==k.evalExpression(m.yExpr)+s.plecaHeight+m.displaceRegionNorth;m.spaceChange=a||D||E||m.drawBefore!==m.drawIfValue||m.Ox!==k.getVariable(m.OxStr)||m.Oy!==k.getVariable(m.OyStr)||m.scale!==k.getVariable(m.scaleStr);m.x=D?k.evalExpression(m.xExpr)+m.displaceRegionWest:m.x;m.y=E?k.evalExpression(m.yExpr)+s.plecaHeight+m.displaceRegionNorth:
m.y;m.Ox=k.getVariable(m.OxStr);m.Oy=k.getVariable(m.OyStr);m.scale=k.getVariable(m.scaleStr);m.drawBefore=m.drawIfValue;if(a||void 0==m.observer){var b;a=0;for(var c=m.parent.controls.length;a<c;a++)m.parent.controls[a].id===m.obsStr&&(b=!0);m.observer=b?k.getVariable(m.obsStr)||0.5*(m.w+m.h):2.5*(m.w+m.h);m.observer=g(m.observer,0.1*(m.w+m.h));k.setVariable(m.obsStr,m.observer);m.eye={x:m.observer/m.scale*q,y:0,z:m.observer/m.scale*u};m.D=m.scale*m.eye.x/q;m.XE=e(m.scale*m.eye.y+0.5);m.YE=e(m.scale*
m.eye.z+0.5)}m.observer=g(k.getVariable(m.obsStr),0.1*(m.w+m.h));k.setVariable(m.obsStr,m.observer);1E-6>m.scale?(m.scale=1E-6,k.setVariable(m.scaleStr,1E-6)):1E6<m.scale&&(m.scale=1E6,k.setVariable(m.scaleStr,1E6));if(D||E)m.container.style.left=m.x+"px",m.container.style.top=m.y+"px",m.findOffset();m.container.style.display="block";m.dim=k.getVariable(m.userI_Dim_Str);m.userIntensity=k.getVariable(m.userI_I_Str);m.light3={x:parseInt(k.getVariable(m.userI_x_Str)),y:parseInt(k.getVariable(m.userI_y_Str)),
z:parseInt(k.getVariable(m.userI_z_Str))};m.updateCamera();m.draw()}else m.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++){t=this.graphics[a];if(t.split||this.split)for(var d=a+1;d<c;d++)v=this.graphics[d],(v.split||
this.split)&&t.splitFace(v);this.primitives=this.primitives.concat(t.primitives||[])}y=this.primitives;B=y.length;for(a=0;a<B;a++)y[a].computeDepth(this);y=y.sort(b);if("painter"===this.render)this.drawPainter2(y);else for(a=0;a<B;a++)y[a].draw(this.ctx,this);a=0;for(c=this.graphicsCtr.length;a<c;a++)this.graphicsCtr[a].draw()};a.Space3D.prototype.drawPainter2=function(a){for(var b=[],c=0,d=a.length;c<d;c++)a[c].drawn=!1;for(var d=a.length,h=0.0010;;){for(var e=d,c=0;c<a.length;c++)if(!a[c].drawn){for(var g=
!0,f=0;f<a.length;f++)if(f!=c&&!a[f].drawn&&a[c].inFrontOf(b,a[f],h)){g=!1;break}g&&(d--,a[c].draw(this.ctx,this),a[c].drawn=!0)}if(0==d)break;else if(d==e){if(h*=10,0.1<h){console.log("Error in Painter Algorithm");for(c=0;c<a.length;c++)a[c].drawn||(a[c].draw(this.ctx,this),a[c].drawn=!0);break}}else h=0.0010}};a.Space3D.prototype.updateCamera=function(){m=this;m.D=m.observer;m.eye.x=m.D/m.scale;m.eye.y=m.XE/m.scale;m.eye.z=m.YE/m.scale};a.Space3D.prototype.rotateVertex=function(b){w=a.degToRad(m.evaluator.getVariable(m.rotZStr));
K=r(w);C=l(w);d=b.x*K-b.y*C;f=b.x*C+b.y*K;h=b.z;w=a.degToRad(m.evaluator.getVariable(m.rotYStr));K=r(w);C=l(w);return{x:h*C+d*K,y:f,z:h*K-d*C}};a.Space3D.prototype.project=function(a){m=this;F=m.eye.x-a.x;G=m.eye.y-a.y;J=m.eye.z-a.z;H=-a.x/j(F*F+G*G+J*J)||0;F=parseInt(this.w_2+this.Ox+m.scale*(a.y+H*(m.eye.y-a.y)));G=parseInt(this.h_2+this.Oy-m.scale*(a.z+H*(m.eye.z-a.z)));return{x:F,y:G,z:H}};a.Space3D.prototype.computeColor=function(b,d,h){T=a.subtract3D(this.eye,d.average);S=a.norm3D(T);W=a.scalarProduct3D(T,
1/S);this.lights[3]=a.subtract3D(this.light3,d.average);Q=a.norm3D(this.lights[3]);for(var e=0,g=this.intensity.length-1;e<g;e++)R[e]=this.intensity[e]*this.dim;R[3]=this.userIntensity*this.userIntensity/Q||0;O=h?this.dim/2:this.dim/4;P=0;M=0<=d.direction?d.normal:a.scalarProduct3D(d.normal,-1);e=0;for(g=this.lights.length;e<g;e++)h?(P=Math.max(0,a.dotProduct3D(c(this.lights[e],M),W)),P*=P*P):P=Math.max(0,a.dotProduct3D(this.lights[e],M)),O+=R[e]*P;O=Math.min(O,1);I=n(b.r*O);L=n(b.g*O);N=n(b.b*O);
return"rgba("+I+","+L+","+N+","+b.a+")"};a.Space3D.prototype.rayFromEye=function(a,b){return{x:-this.eye.x,y:(a-this.w_2-this.Ox)/this.scale-this.eye.y,z:(this.h_2+this.Oy-b)/this.scale-this.eye.z}};a.Space3D.prototype.registerMouseAndTouchEvents=function(){function b(a){document.body.focus();j.click=1;j.evaluator.setVariable(j.id+".mouse_pressed",1);j.parent.deactivateGraphiControls();j.posAnte=j.getCursorPosition(a);j.oldMouse.x=j.getRelativeX(j.posAnte.x);j.oldMouse.y=j.getRelativeY(j.posAnte.y);
g(a);window.addEventListener("touchmove",n);window.addEventListener("touchend",c);a.preventDefault()}function c(a){document.body.focus();j.click=0;j.evaluator.setVariable(j.id+".mouse_pressed",0);window.removeEventListener("touchmove",n,!1);window.removeEventListener("touchend",c,!1);a.preventDefault()}function d(b){document.body.focus();j.click=1;j.parent.deactivateGraphiControls();j.whichButton=a.whichButton(b);"R"===j.whichButton?(window.addEventListener("mouseup",h),j.clickPosForZoom=j.getCursorPosition(b).y,
j.clickPosForZoomNew=j.clickPosForZoom,j.fixed||(j.tempScale=j.scale,window.addEventListener("mousemove",f))):"L"==j.whichButton&&(j.evaluator.setVariable(j.id+".mouse_pressed",1),j.posAnte=j.getCursorPosition(b),j.oldMouse.x=j.getRelativeX(j.posAnte.x),j.oldMouse.y=j.getRelativeY(j.posAnte.y),g(b),window.addEventListener("mousemove",n),window.addEventListener("mouseup",h));b.preventDefault()}function h(a){document.body.focus();j.click=0;j.evaluator.setVariable(j.id+".mouse_pressed",0);a.preventDefault();
"R"===j.whichButton&&(window.removeEventListener("mousemove",f,!1),j.clickPosForZoom==j.clickPosForZoomNew&&j.parent.externalSpace.show());window.removeEventListener("mousemove",n,!1);window.removeEventListener("mouseup",h,!1)}function g(a){j.posAnte=j.getCursorPosition(a);j.mouse_x=j.getRelativeX(j.posAnte.x);j.mouse_y=j.getRelativeY(j.posAnte.y);j.evaluator.setVariable(j.id+".mouse_x",j.mouse_x);j.evaluator.setVariable(j.id+".mouse_y",j.mouse_y);70<Date.now()-k&&(j.parent.update(),k=Date.now())}
function f(a){a.preventDefault();j.clickPosForZoomNew=j.getCursorPosition(a).y;j.evaluator.setVariable(j.scaleStr,j.tempScale+j.tempScale/45*((j.clickPosForZoom-j.clickPosForZoomNew)/10));j.parent.update()}function n(b){if(!j.fixed&&j.click){A=parseInt(50*(j.oldMouse.x-j.mouse_x));x=parseInt(50*(j.oldMouse.y-j.mouse_y));if(A!==j.disp.x||x!==j.disp.y)j.alpha=a.degToRad(j.evaluator.getVariable(j.rotZStr)),j.beta=a.degToRad(-j.evaluator.getVariable(j.rotYStr)),j.alpha=e(a.radToDeg(j.alpha)-A),j.beta=
e(a.radToDeg(j.beta)-x),j.evaluator.setVariable(j.rotZStr,j.alpha),j.evaluator.setVariable(j.rotYStr,-j.beta),j.disp.x=A,j.disp.y=x,j.oldMouse.x=j.getRelativeX(j.posAnte.x),j.oldMouse.y=j.getRelativeY(j.posAnte.y);g(b);b.preventDefault()}}var j=this,k=0;z=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};z&&this.canvas.addEventListener("touchstart",b);z||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(f,h){a.Space.call(this,f,h);this.exportarVars=this.importarVars=null;d=f.evaluator;this.file=this.file.match(/^\[/)&&this.file.match(/\]$/)?d.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?d.parser.parse(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 h=
document.getElementById(this.oldFile);d=h&&"descartes/spaceApFile"==h.type?h.text:a.openExternalFile(this.oldFile);null!=d&&(d=d.split("\n"))}if(d&&d.toString().match(/<applet/gi)){for(var h="",b=!1,c=0,n=d.length;c<n&&!(d[c].match("<applet")&&(b=!0),b&&(h+=d[c]),d[c].match("</applet"));c++);c=document.createElement("div");c.innerHTML=h;c.firstChild.setAttribute("width",this.w);c.firstChild.setAttribute("height",this.h);h=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+";");h?this.parent.container.replaceChild(this.descApp.container,h):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);h=this.descApp.spaces;c=0;for(n=h.length;c<n;c++)h[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 h=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),h?this.parent.container.replaceChild(this.descApp.container,h):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,f,h,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=this.file.match(/^\[/)&&this.file.match(/\]$/)?e.parser.parse(this.file.substring(1,
this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?e.parser.parse(this.file):e.parser.parse("'"+this.file+"'");this.oldFile=e.evalExpression(this.file);this.MyIFrame=document.createElement("iframe");this.MyIFrame.setAttribute("src",this.oldFile);this.MyIFrame.setAttribute("id",this.id);this.MyIFrame.setAttribute("marginheight",0);this.MyIFrame.setAttribute("marginwidth",0);this.MyIFrame.setAttribute("frameborder",0);this.MyIFrame.setAttribute("scrolling","auto");this.MyIFrame.setAttribute("style",
"position: 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 h=this;this.MyIFrame.onload=function(){var a=this;h.evaluator.setFunction(h.id+".set",function(b,c){a.contentWindow.postMessage({type:"set",name:b,value:c},"*");return 0});h.evaluator.setFunction(h.id+".update",function(){a.contentWindow.postMessage({type:"update"},"*");return 0});h.evaluator.setFunction(h.id+".exec",function(b,c){a.contentWindow.postMessage({type:"exec",name:b,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);f=this.x!==d.evalExpression(this.xExpr)+this.displaceRegionWest;h=this.y!==d.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=f?d.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=h?d.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(f||h)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;if(a.image_loader)b=a.image_loader;else{b=a.loader.width;var c=a.loader.height,h=document.createElement("canvas");h.width=b;h.height=c;var f=h.getContext("2d");f.save();f.strokeStyle="#1f375d";f.fillStyle="#1f375d";f.lineCap="round";f.lineWidth=2;f.beginPath();d=b<c?b/360:c/195;d=2.5<d?2.5:
d;f.translate((b-120*d)/2,(c-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();b=h.toDataURL()}this.imageLoader=document.createElement("div");this.imageLoader.width=a.width;this.imageLoader.height=a.height;this.imageLoader.setAttribute("class","DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image: url("+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 j=this;this.timer=setInterval(function(){j.drawLoaderBar(j.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,h=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,f=/[\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 j,p,q,u,k,s;q=0;for(k=b.length;q<k;q++)if("rtf"!==b[q].name){if(b[q].value.match(/'macro'|'makro'/g)){j=
"";var m;p=this.lessonParser.split(b[q].value);s=0;for(var t=p.length;s<t;s++)"expresion"===babel[p[s][0]]&&(j=p[s][1]);j&&((m=document.getElementById(j))&&"descartes/macro"==m.type?m=m.text:(m=a.openExternalFile(j))&&!m.match(/tipo_de_macro/g)&&(m=null));if(m&&(j=m.match(h)))for(s=j.length;u<s;u++)p=j[u],!p.toLowerCase().match(/vacio.gif$/)&&""!=p.substring(0,p.length-4)&&(c[p]=new Image,c[p].addEventListener("load",function(){this.ready=1}),c[p].addEventListener("error",function(){this.errorload=
1}),c[p].src=p)}if(j=b[q].value.match(h)){u=0;for(s=j.length;u<s;u++)p=j[u],!p.toLowerCase().match(/vacio.gif$/)&&""!=p.substring(0,p.length-4)&&(c[p]=new Image,c[p].addEventListener("load",function(){this.ready=1}),c[p].addEventListener("error",function(){this.errorload=1}),c[p].src=p)}if(j=b[q].value.match(f)){u=0;for(p=j.length;u<p;u++)this.initAudio(j[u])}}for(var v in c)c.hasOwnProperty(v)&&this.images.length++;for(v in d)d.hasOwnProperty(v)&&this.audios.length++;var y=this,B=this.images.length+
this.audios.length,z=function(){y.readys=0;for(var a in c)c.hasOwnProperty(a)&&(c[a].ready||c[a].errorload)&&y.readys++;for(a in y.audios)d.hasOwnProperty(a)&&(d[a].ready||d[a].errorload)&&y.readys++;y.readys!=B?setTimeout(z,30):(clearTimeout(y.timer),y.descartesApp.initBuildApp())};z()};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},h=function(){!this.canPlayType("audio/"+this.filename.substring(this.filename.length-
3))&&"mp3"==this.filename.substring(this.filename.length-3)?(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",h),c[b].load()):(console.log("El archivo '"+b+"' no puede ser reproducido"),this.errorload=1)};c[b].addEventListener("canplaythrough",d);c[b].addEventListener("load",d);c[b].addEventListener("error",h);a.hasTouchSupport?(c[b].load(),c[b].play(),
c[b].ready=1):c[b].load()};var f,h,b,c;a.DescartesLoader.prototype.drawLoaderBar=function(a,e,g){f=this.barWidth;h=this.barHeight;b=this.images.length+this.audios.length;c=2*(f-2)/b;a.translate(e/2,(g-65*d)/2+90*d);a.scale(d,d);a.strokeRect(-f,-h,2*f,h);a.fillStyle="gray";a.fillRect(-f+2,-h+2,2*(f-2),h-4);a.fillStyle="#1f375d";a.fillRect(-f+2,-h+2,this.readys*c,h-4);a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{}),descartesJS=function(a){function d(a){for(var b="[",c=0,n=a.length;c<n;c++){if(a[c]instanceof
Array)b+=d(a[c]);else{f=a[c];if("undefined"==typeof f||!f)f=0;"string"==typeof f&&(f="'"+f+"'");b+=f}c<n-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,f=0,e=a.creativeCommonsLicense?90:0,g=0,r=d.length;g<r;g++)b=d[g],"rtf_height"==b.name&&(c=parseInt(b.value)),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),f=this.buttonsConfig.height),"image_loader"==b.name&&(this.image_loader=b.value);this.arquimedes&&c&&(this.height=c+f+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=[],f=[],e=[],g=[],r=[],l=[],j,p=0,q=d.length;p<q;p++)if(j=d[p],"pleca"==j.name)j=b.parsePleca(j.value,this.width),
this.container.insertBefore(j,this.loader),this.plecaHeight=j.imageHeight?j.imageHeight:j.offsetHeight;else if("Buttons"==babel[j.name])this.buttonsConfig=b.parseButtonsConfig(j.value);else if("decimal_symbol"==babel[j.name])this.decimal_symbol=j.value,this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");else if("version"==babel[j.name])this.version=parseInt(j.value);else if("language"==babel[j.name])this.language=j.value;else if("rtf"==j.name){var u=(this.width-780)/2,k=parseInt(this.height)-
this.plecaHeight-this.buttonsConfig.height-45;g.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+j.value.replace(/'/g,"&squot;")+"'");g.push("space='descartesJS_scenario' type='text' expresion='["+u+","+(k-25)+"]' background='yes' text='"+this.licenseA+"'");a.creativeCommonsLicense&&g.push("space='descartesJS_scenario' type='image' expresion='["+(u+15)+","+k+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==j.name.charAt(0)?
(j.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,c.push(j.value)):"C"==j.name.charAt(0)&&"_"==j.name.charAt(1)?f.push(j.value):"A"==j.name.charAt(0)&&"_"==j.name.charAt(1)?e.push(j.value):"G"==j.name.charAt(0)?g.push(j.value):"S"==j.name.charAt(0)?r.push(j.value):"Animation"==babel[j.name]&&l.push(j.value);this.scenarioRegion={container:document.createElement("div"),scroll:0};this.scenarioRegion.container.setAttribute("id","descartesJS_Scenario_Region");this.scenarioRegion.scenarioSpace=this.lessonParser.parseSpace("tipo='R2' id='descartesJS_scenario' 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));p=0;for(q=c.length;p<q;p++)d=b.parseSpace(c[p]),this.arquimedes&&this.scenarioRegion.container.appendChild(d.container),this.spaces.push(d),this.zIndex++;p=0;for(q=g.length;p<q;p++)if(c=b.parseGraphic(g[p]))c.visible&&(this.editableRegionVisible=
!0),c.space.addGraph(c);p=0;for(q=r.length;p<q;p++)(c=b.parse3DGraphic(r[p]))&&c.space.addGraph(c);p=0;for(q=f.length;p<q;p++)this.controls.push(b.parseControl(f[p]));p=0;for(q=e.length;p<q;p++)b.parseAuxiliar(e[p]);p=0;for(q=l.length;p<q;p++)this.animation=b.parseAnimation(l[p]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();p=0;for(q=this.controls.length;p<q;p++)this.controls[p].init();this.updateControls();this.updateSpaces(!0);var s=this;this.numberOfIframes?setTimeout(function(){s.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 f="15",e=100,g=100,r=100,l=100;else f="14",e=63,g=50,r=44,l=53;var j=0,p=0,q=0,u=q=0,k=0,s=0,m=0,t=0,s=this.northSpace.controls,v=this.southSpace.controls,y=this.eastSpace.controls,B=this.westSpace.controls;if(0<b.rowsNorth||0<s.length||b.about||b.config){0>=b.rowsNorth?(j=b.height,b.rowsNorth=1):j=b.height*b.rowsNorth;k=this.northSpace.container;k.setAttribute("id","descartesJS_northRegion");k.setAttribute("style","width:"+c.width+"px; height:"+j+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");
c.insertBefore(k,this.loader);var k=c.width,z=0;b.about&&(z=e,k-=z);b.config&&(k-=g);for(var D=Math.ceil(s.length/b.rowsNorth),E=k/D,q=0,A=s.length;q<A;q++)s[q].expresion=d.parse("("+(z+E*(q%D))+","+b.height*Math.floor(q/D)+","+E+","+b.height+")"),s[q].drawif=d.parse("1"),s[q].init();b.about&&(q="espa\u00f1ol"==this.language?"cr\u00e9ditos":"english"==this.language?"about":"cr\u00e9ditos",q=new a.Button(this,{region:"north",name:q,font_size:d.parse(f),expresion:d.parse("(0, 0, "+e+", "+j+")")}),q.actionExec=
{execute:a.showAbout},q.update());b.config&&(new a.Button(this,{region:"north",name:"config",font_size:d.parse(f),action:"config",expresion:d.parse("("+(k+e)+", 0, "+g+", "+j+")")})).update()}if(0<b.rowsSouth||0<v.length||b.init||b.clear){0>=b.rowsSouth?(p=b.height,b.rowsSouth=1):p=b.height*b.rowsSouth;s=c.width;z=0;b.init&&(z=r,s-=z);b.clear&&(s-=l);k=this.southSpace.container;k.setAttribute("id","descartesJS_southRegion");k.setAttribute("style","width:"+c.width+"px; height:"+p+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+
(c.height-p)+"px; z-index:100;");c.insertBefore(k,this.loader);D=Math.ceil(v.length/b.rowsSouth);E=s/D;q=0;for(A=v.length;q<A;q++)v[q].expresion=d.parse("("+(z+E*(q%D))+","+b.height*Math.floor(q/D)+","+E+","+b.height+")"),v[q].drawif=d.parse("1"),v[q].init();b.init&&(q="espa\u00f1ol"==this.language?"inicio":"english"==this.language?"init":"inicio",(new a.Button(this,{region:"south",name:q,font_size:d.parse(f),action:"init",expresion:d.parse("(0, 0, "+r+", "+p+")")})).update());b.clear&&(q="espa\u00f1ol"==
this.language?"limpiar":"english"==this.language?"clear":"limpiar",(new a.Button(this,{region:"south",name:q,font_size:d.parse(f),action:"clear",expresion:d.parse("("+(s+r)+", 0, "+l+", "+p+")")})).update())}if(0<y.length){q=c.height-j-p;m=b.widthEast;k=this.eastSpace.container;k.setAttribute("id","descartesJS_eastRegion");k.setAttribute("style","width:"+m+"px; height:"+q+"px; background:#c0c0c0; position:absolute; left:"+(c.width-m)+"px; top:"+j+"px; z-index:100;");c.insertBefore(k,this.loader);
q=0;for(A=y.length;q<A;q++)y[q].expresion=d.parse("(0,"+b.height*q+","+m+","+b.height+")"),y[q].drawif=d.parse("1"),y[q].init()}if(0<B.length){q=c.height-j-p;t=b.widthWest;k=this.westSpace.container;k.setAttribute("id","descartesJS_westRegion");k.setAttribute("style","width: "+t+"px; height: "+q+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+j+"px; z-index: 100;");c.insertBefore(k,this.loader);q=0;for(A=B.length;q<A;q++)B[q].expresion=d.parse("(0,"+b.height*q+","+t+","+b.height+")"),
B[q].drawif=d.parse("1"),B[q].init()}if(this.editableRegionVisible){u=b.height;k=this.editableRegion.container;k.setAttribute("id","descartesJS_editableRegion");k.setAttribute("style","width:"+c.width+"px; height:"+u+"px; position:absolute; left:0px; top:"+(c.height-p-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;");c.insertBefore(k,this.loader);d=this.editableRegion.textFields;b=c.width/d.length;f=a.getFieldFontSize(u);q=0;for(A=d.length;q<A;q++)"div"==d[q].type?(k.appendChild(d[q].container),
d[q].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(b-4)+"px; height: "+u+"px; position: absolute; left: "+q*b+"px; top: 0px;"),e=d[q].container.firstChild,e.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+f+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+u+"px; text-align: center; line-height: "+u+"px;"),g=e.offsetWidth,e.style.width=g+"px",e.firstChild.textContent=
e.firstChild.textContent.substring(3,e.firstChild.textContent.length-3),d[q].container.lastChild.setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+f+"px; width:"+(b-g)+"px; height:"+u+"px; position:absolute; left:"+g+"px; top:0px; border:2px groove white;")):(k.appendChild(d[q]),d[q].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+f+"px; width:"+b+"px; height:"+u+"px; position:absolute; left:"+
q*b+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=j;this.displaceRegionWest=t;c.width-=m;c.height=c.height-p-u;q=0;for(A=this.spaces.length;q<A;q++)this.spaces[q].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(){this.ready=1};b[a].addEventListener("canplaythrough",d);var e=function(){!this.canPlayType("audio/"+a.substring(a.length-3))&&"mp3"==a.substring(a.length-3)?(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()):(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1)};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 f;a.DescartesApp.prototype.getState=function(){var a,b="",c=this.evaluator.variables,f;for(f in c)c.hasOwnProperty(f)&&(a=c[f],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=f&&"pi"!=f&&"e"!=f&&"Infinity"!=f&&"-Infinity"!=f&&"object"!=typeof a)&&(b=""!=b?b+"\n"+
f+"="+a:f+"="+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){a=a.split("\n");for(var b,c,d=0,e=a.length;d<e;d++)b=a[d].split("="),2<=b.length&&(c=eval(b[1]),-1!=b[1].indexOf("[[")?(this.evaluator.matrices[b[0]]=c,this.evaluator.matrices[b[0]].rows=c.length,this.evaluator.matrices[b[0]].cols=c[0].length):
-1!=b[1].indexOf("[")?(this.evaluator.vectors[b[0]]=c,this.evaluator.variables[b[0]+".long"]=c.length):this.evaluator.variables[b[0]]=c),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(){a.getFeatures();if(a.hasCanvasSupport){window.scrollTo(0,
10);for(var d=document.getElementsByTagName("*"),b=[],c=0,f=d.length;c<f;c++)"DescartesAppContainer"==d[c].className&&b.push(d[c]);c=0;for(f=b.length;c<f;c++)b[c].parentNode.removeChild(b[c]);for(var b=document.getElementsByTagName("applet"),c=document.getElementsByTagName("ajs"),d=[],e=0,g=b.length;e<g;e++)f=b[e],(f.getAttribute("code").match("DescartesJS")||f.getAttribute("code").match("descinst.DescartesWeb2_0.class")||f.getAttribute("code").match("Descartes")||f.getAttribute("code").match("Arquimedes")||
f.getAttribute("code").match("Discurso"))&&d.push(f);e=0;for(g=c.length;e<g;e++)f=c[e],(f.getAttribute("code").match("DescartesJS")||f.getAttribute("code").match("descinst.DescartesWeb2_0.class")||f.getAttribute("code").match("Descartes")||f.getAttribute("code").match("Arquimedes")||f.getAttribute("code").match("Discurso"))&&d.push(f);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};if(!window.hasOwnProperty("debugDescartesJS")||!debugDescartesJS){var f=document.getElementById("StyleDescartesApps");f&&f.parentNode.removeChild(f);f=document.createElement("style");f.id="StyleDescartesApps";f.type="text/css";f.setAttribute("rel",
"stylesheet");f.innerHTML="applet.DescartesJS {display:none;} applet {display:none;} ajs.DescartesJS {display:none;} ajs {display:none;}";document.head.appendChild(f)}a.onResize=function(){for(var d,b=0,c=a.apps.length;b<c;b++){d=a.apps[b].spaces;for(var f=0,e=d.length;f<e;f++)d[f].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",d),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||{});
