/*
 Joel Espinosa Longi
 j.longi@gmail.com
 https://github.com/jlongi/DescartesJS
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2014-03-03
*/
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=a["#000000"]="#000000";a.maxenta=a.magenta=a["#ff00ff"]="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu=a["#0000ff"]="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise=a["#00ffff"]="#00ffff";
a.verde=a.green=a.verd=a.berdea=a.vert=a["#00ff00"]="#00ff00";a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo=a["#ffff00"]="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa=a["#ffc800"]="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho=a["#ff0000"]="#ff0000";a.pink=a.rosa=a.arrosa=a.rose=a["#ffafaf"]="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro=a["#404040"]="#404040";a.gris=a.gray=a.grisa=a.cinza=a["#808080"]=
"#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro=a["#c0c0c0"]="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=a["#ffffff"]="#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.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+"]=
a.fillP="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=a["betea-"]=a["plein-"]=a["recheo-"]=a["preencher-"]=a.fillM="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"]=a.version="version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=a.language="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.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=a.doExpr="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto=a.whileExpr="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"]=a.drawif="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"]=a.x_axis="x_axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=a["eixo-y"]=a.y_axis="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"]=a.exponentialif="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"]=a.onlyOnce="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"]=a.colorInt="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=a.width="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"]=a.raytrace="raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo=a.image="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=a.rowsNorth="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=
a.rowsSouth="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=a.widthEast="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=a.widthWest="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"]=
a.initAnimation="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"]=a.openURL="openURL";a["abrir Escena"]=a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]=a.openScene="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=a.x="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=a.playAudio="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]=a.activeif="activeif";a.rotfin=a.finrot=a.bukrot=a.endrot="endrot";a.posfin=a.finpos=a.bukpos=a.endpos="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"]=a.font_size="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=a.onlyText="onlyText";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=a.border="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;a["LANG_espa\u00f1ol"]={decimal_symbol:"Simbolo decimal",language:"Lenguaje",about:"Cr\u00e9ditos",config:"Configuraci\u00f3n",init:"Inicio",clear:"Limpiar"};a.LANG_english={};a["LANG_catal\u00e0"]={};a.LANG_euskera={};a["LANG_fran\u00e7ais"]={};a.LANG_galego={};a["LANG_portugu\u00eas"]=
{};a["LANG_valenci\u00e0"]={};a.translate=function(a,h){return h.charAt(0).toUpperCase()+h.substring(1)};return a}(babel||{}),descartesJS=function(a){function d(){var a,b,c,f,e,d,g,p,l;Number.prototype.originalToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(m){m=m?m:0;m=0>m?0:parseInt(m);a=this.toString();e=a.indexOf("e");if(-1!==e)if(d=a.split("e"),p="-"===d[0][0]?"-":"",g="-"===p?parseFloat(d[0].substring(1)).originalToFixed(11):parseFloat(d[0]).originalToFixed(11),l=parseInt(d[1]),
b=g.indexOf("."),0>b+l){b=0>b?1:b;var n=p+"0.",h;h=Math.abs(b+l);h=Array(h+1).join("0");a=n+h+g.replace(".","")}else g=g.replace(".",""),a=p+g+Array(l-g.length+2).join("0");b=a.indexOf(".");c="";if(-1===b)0<m&&(c="."),c+=Array(m+1).join("0"),a+=c;else if(f=a.length-b-1,f>=m)11>=m&&(a=parseFloat(a).originalToFixed(m)),a=0<m?a.substring(0,b+1+m):a.substring(0,b);else{n=0;for(m-=f;n<m;n++)c+="0";a+=c}return a}}function h(a,b,c){a.fillStyle="#c0c0c0";a.fillRect(b.offsetLeft,b.offsetTop,b.offsetWidth,
b.offsetHeight);g(a,b,c.controls)}function g(a,b,c){for(var f,e=c.length-1;0<=e;e--)f=c[e],a.drawImage(f.getScreenshot(),b.offsetLeft+f.x,b.offsetTop+f.y)}if(a.loadLib)return a;var b=2*Math.PI,c=360/b,n=b/360,f=Math.floor,p,e,q,r,k,t,s,l,u,m;a.rangeOK=1;a.extend=function(a,b){if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var c in b.prototype)b.prototype.hasOwnProperty(c)&&(a.prototype[c]=b.prototype[c]);a.prototype.uber=b.prototype};a.radToDeg=function(a){return a*c};a.degToRad=
function(a){return a*n};a.convertFont=function(a){if(""==a)return a;p=a.split(",");e="";"bold"==p[1].toLowerCase()?e+="Bold ":"italic"==p[1].toLowerCase()||"italics"==p[1].toLowerCase()?e+="Italic ":"bold+italic"==p[1].toLowerCase()&&(e+="Italic Bold ");q=p[0].split(" ")[0].toLowerCase();e+=p[2]+"px ";return e="serif"===q||"times new roman"===q||"timesroman"===q||"times"===q?e+"'Times New Roman', Times, serif":"sansserif"===q||"arial"===q||"helvetica"===q?e+"Arial, Helvetica, Sans-serif":e+"'Courier New', Courier, Monospace"};
a.drawLine=function(a,b,c,e,d,g,m){a.lineWidth=m||1;a.strokeStyle=g||"black";g=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(f(b)+g,f(c)+g);a.lineTo(f(e)+g,f(d)+g);a.stroke()};a.getColor=function(a,b){if("string"==typeof b)return b;r=a.evalExpression(b);k=f(255*r[0][0]);t=f(255*r[0][1]);s=f(255*r[0][2]);l=1-r[0][3];return"rgba("+k+","+t+","+s+","+l+")"};a.getFeatures=function(){a.hasJavaSupport=navigator.javaEnabled();var b=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&
window.hasOwnProperty("ontouchstart")||b.match("android")&&!0;a.hasTouchSupport=navigator.userAgent.toLowerCase().match("qt")?!1:a.hasTouchSupport;a.isIOS=!(!navigator.userAgent.match(/iPad/i)&&!navigator.userAgent.match(/iPhone/i));b=document.createElement("canvas");a.hasCanvasSupport=b.getContext&&b.getContext("2d");a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"));d()};a.removeNeedlessDecimals=function(a){var b,c;if("string"==typeof a&&(b=a.indexOf("."),-1!=b)){c=a.substring(b);
if(0==parseFloat(c))return a.substring(0,b);for(var f=c.length;0<f;f--)if(0!=c.charAt(f))return a.substring(0,b+f+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],u=a.pageX,m=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(u=a.pageX,m=a.pageY):(u=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,
m=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:u,y:m}};a.getTextWidth=function(b,c){a.ctx.font=c;return Math.round(a.ctx.measureText(b).width)};var v=document.createElement("span");v.appendChild(document.createTextNode("\u00c1p"));var w=document.createElement("div");w.setAttribute("style","display: inline-block; w: 1px; h: 0px;");var y=document.createElement("div");y.setAttribute("style","margin: 0; padding: 0;");y.appendChild(v);y.appendChild(w);var C={};a.getFontMetrics=
function(a){if(C[a])return C[a];v.setAttribute("style","font: "+a+"; margin: 0px; padding: 0px;");document.body.appendChild(y);var b={ascent:0,descent:0,h:0,baseline:0};y.getBoundingClientRect?(w.style.verticalAlign="baseline",b.ascent=w.offsetTop-v.offsetTop,b.h=y.getBoundingClientRect().height||0):(w.style.verticalAlign="baseline",b.ascent=w.offsetTop-v.offsetTop,w.style.verticalAlign="bottom",b.h=w.offsetTop-v.offsetTop);b.descent=b.h-b.ascent;b.baseline=b.ascent;b.ascent=parseInt(b.ascent);b.descent=
parseInt(b.descent);b.h=parseInt(b.h);b.baseline=parseInt(b.baseline);document.body.removeChild(y);return C[a]=b};a.getFieldFontSize=function(a){a=Math.min(50,a);return a=24<=a?Math.floor(a/2+2-a/16):20<=a?12:17<=a?11:15<=a?10:9};a.getScreenshot=function(){var b=a.apps[0],c,f=document.createElement("canvas"),e=new Image;if(b){f.setAttribute("width",b.width);f.setAttribute("height",b.height);for(var d=f.getContext("2d"),m=0,p=b.spaces.length;m<p;m++)c=b.spaces[m],"R2"===c.type&&(d.drawImage(c.backgroundCanvas,
c.x,c.y),d.drawImage(c.canvas,c.x,c.y),g(d,c.container,c.ctrs));0<b.northSpace.controls.length&&h(d,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&h(d,b.southSpace.container,b.southSpace);0<b.eastSpace.controls.length&&h(d,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&h(d,b.westSpace.container,b.westSpace);e.src=f.toDataURL("image/png")}return e};a.showAbout=function(){var b;b=a.creativeCommonsLicense?"<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>\n<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>":
"<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>\n</body> </html>";
var c=window.open("","creditos","width=700,height=500,titlebar=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0");c.document.write(b);c.document.close()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h;a._externalFilesContent={};a.openExternalFile=function(g){if(a._externalFilesContent[g])return a._externalFilesContent[g];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(f){b=!1}}h=b;h.open("GET",g,!1);try{h.send(null),d=h.responseText,d.match(String.fromCharCode(65533))&&(h.open("GET",g,!1),h.overrideMimeType("text/plain; charset=ISO-8859-1"),h.send(null),d=h.responseText)}catch(p){console.log("Error to load the file :",g),d=null}return d};a.addExternalFileContent=function(d,b){a._externalFilesContent[d]=b};return a}(descartesJS||{}),descartesJS=function(a){function d(a){m=a.indexOf("--radial--");-1!=m&&(a=a.substring(0,
m));c=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1),"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1)));"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1),c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1)));"*"===c.charAt(0)&&"*"!==c.charAt(c.length-1)?c=c.substring(1)+"$":"*"!==c.charAt(0)&&"*"===c.charAt(c.length-1)?c="^"+
c.substring(0,c.length-1):"*"!==c.charAt(0)&&"*"!==c.charAt(c.length-1)?c="^"+c+"$":"*"===c.charAt(0)&&"*"===c.charAt(c.length-1)&&(c=c.substring(1,c.length-1));c=c.replace(/\?/g,"[\\S\\s]{1}");a.regExp=c;return a}function h(a,b){c=(a||"").trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=c.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:b.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),
expr:b.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function g(a,b,c){b=parseFloat(b);e=a.expr[0];q=a.expr[1];r=c.evalExpression(e.expr);k=c.evalExpression(q.expr);t="("==e.type;s="["==e.type;l=")"==q.type;u="]"==q.type;return(t&&b>r||s&&b>=r)&&(l&&b<k||u&&b<=k)?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,f,p,e,q,r,k,t,s,l,u,m;a.buildRegularExpresionsPatterns=function(a,b){a=a||"";"("===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 e=0,g=a.length;e<g;e++){n=a[e].split("&");f=[];for(var m=0,p=n.length;m<p;m++)c=n[m],-1===c.indexOf(",")||"("!==c.charAt(0)&&"["!==
c.charAt(0)||")"!==c.charAt(c.length-1)&&"]"!==c.charAt(c.length-1)?f.push(d(c)):f.push(h(c,b));a[e]=f}return a};a.escorrecto=function(c,f,e,d){e=e||a.externalEvaluator;d=d||a.buildRegularExpresionsPatterns(c,e);f=b(f);c=0;for(var m=d.length;c<m;c++){n=d[c];p=!0;for(var l=0,h=n.length;l<h;l++)p=n[l].regExp?p&&!!f.match(RegExp(b(n[l].regExp),"i")):p&&g(n[l],f,e);if(p)return 1}return 0};a.esCorrecto=function(f,e,d,m){d=d||a.externalEvaluator;m=m||a.buildRegularExpresionsPatterns(f,d);f=0;for(var l=
m.length;f<l;f++){n=m[f];p=!0;for(var h=0,r=n.length;h<r;h++)(c=n[h].regExp)?(n[h].ignoreAcents&&(e=b(e),c=b(c)),n[h].ignoreCaps&&(e=e.toLowerCase(),c=b(c).toLowerCase()),p=p&&!!e.match(c)):p=p=p&&g(n[h],e,d);if(p)return 1}return 0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.getCreativeCommonsLicenseImage=function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAABHNCSVQICAgIfAhkiAAACpVJREFUaIHtWm1sU9cZfu61iUYnPP/bJgdhhDbFkVYcCrR0tLHXrVNL01wvgUJDh820tivrkpQQtpEvA4HGhDoe/dCmNfbaVa1WKszX2oUO3xC0OHESm9Hi/FhloyQq1aY5OGgq8ce7H9f3xI7txKFsdKyPdHSPz8dzz33Oe77eY46IVBzHXcUXuOkgIo4DQABwuucUeJ4Hz/NQKBTgeQUUPA9ekXryPDiOB89x4DgO4DiZBQQCJQlJSiKZlEIikZCeyQQSiSSSyQTLS1KSlSciuTEsfjtgY+UmAAAHgGRxFQqFFHjFTFyhkPJ4RUpkDhzHp+ubEiclbFISM5FIhfR4IlPkZDLJhE0X+nbBxspNUALIFFehhDLjKYWTx0/B4/FgcHAQU9GpDKIlqiVYu3YtjN8xouLRR5BIKsDzcalDEjw4cJD6cgaUJGkkANIY4iRxR3x+uN9xIxgMZpTX6XQQqgSsWlNW0Md9Xng4APSns+9BqVQyUZVKpRQUSvSK52B73oaJiYmCGqTRaND4i0aUl9+PeCKBRCKOeDwVEnHE4wlm4emW/PHExzjS9SJGg6MAAIPBAL1eDwAIBAIQRREAUKIrwY7aHfja17+a8/1XPv4ELzle+lzwbKzcJAn8fu8ZKBXKGWGVi7BIqURrcxvcx9ysglqthiAI0Gq1KC8vBwD09vYiHA7D7XZjcnKSlRVMAhoad2LxHYsRj8cRi8cRj8cQj8czpwxK4mrkKn769LOIRqMQBAF2ux1arTajseFwGPX19XC73VCpVGi3tWd91LXoNdTuqPvc8MjzMJ3tO0t9/eeo39dPQwEfXfggQIJJIEiDl9RqNbW1tVEkEqG54HQ6Sa1Ws3oluhI6399HQ4Eh8g71U1//OfL0naUzYg+99+d36XTPKTrx7nHS6XQEgMxmcwafzDP7HTL328f/kBFKdCU5eRx2Oz3+2ObPxDM2Nkbe/n7y9vfT2NhYQTwAiAcARWoOVioUUCoyLVev18Pv96O1tRVqtTprGKTDbDYjFAqxoTQaHEWn7XDGXM6zHYm0G/F5fQgGgxAEAY27ds3JL79DEASMBkcx4vOz9BGfH6PBUawqK8O996xj6b/q6sLzNhtOnj6N3Q27MD4+XhBPent+/9prMKy/DzWbt6Bm8xYY1t+HMz09c/Kkg/q8feQd8tLIhWFyHHEwy9Hr9fNabS5EIhHS6/WMx/Gig0b+OkIDw1467+0jz3nJit99/4+kK5WsNxQKFcwfCoUIAOl0OmYt8igo+cY3acUyLZV/ez09/eMnCQC1tbXRwQMHCQAdffvtgnjk9nj7+yW+u9fRj7ZZqHFnA61YpqUVy7TksNvz8uSwYMmKbc/bAEjzrdPpnNdqc0GtVsPj8bC6toO21F46ZcFcak/N8wheCsJgMGTNcRaLhVm5xWLJyNNqtTAYDBkrezAo8VRUVGDjpk0YHx/HmZ4erFimxb+mrmHrE1tx6cMPUVVdXRCPVqtFNBpF0H8RAFAp/AC/dXWjo/MQ9rQ0AwBc3c68PDJ4AKlhK23F5N1CXV0dG+o3ArVaDbvdDgCYmJjAyROn2IFFEplj27Rc73G5XDnjMnLV0ev1sB3uxEFbB954601UVVfjo8th2A53YunSpXB1OxG8dKkgHhntL0gG95vfvcrSvvfggwCAaDSKT65cycsDpASWrcnj8QCQxKmtrWWFRFGEyWSC0WiE0WiE1WrNm9fV1cXyzGYzs2LPWU+a9XLg+BmB/xO4+5570NF5CGNjY2jc2YCyb92Jd44eRcXDG1CzeQubQ+eCSqWCw+HAHaoleOWVV3KW+fTT63NySAcNjgPPcRgcHAQACILAhBFFEUajMaOSKIoQRRG1tbUwmUxZeRcuXIDT6WRcLpcLg4OD0gkwJawkriRwIBDIapjZbGaWazabs/Jz1ZmdFo1GcaanBx2dh2C+ZEHFwxsAAANeLwa8XhQXF4NbpJyTZ5FSicaGBtyxeDFLG/B6WXyZdlne9gDMgqUPlk9oK1euZAXq6+sBSPNMKBSCx+OBVqvFtm3bmCXr9XqEQiEcO3YsY48MgMWnolPSe8ClPYHS0lKIoohwOJzRMLmDZscBaQ8qiiJ0Oh1L0+l0WTw/efIptO/dh1V3rkTN5i346HIYVdXV6Og8hJqtWwviGR8fR1tLKx5/bDPa9+5D+959aGlqAgDs2r07b3syBAaHjOGaPp/IPWM2m9lkHgqFYDabWZ58+BAEgeXJSF+8JKPNPDZvfExadOSOLARyWaFKYGlyPJ2no/MQLNu348o//o6/hUJw2O3Y09KMqupqWPfvQ9ma1fPyWLZvh2X7dgCAs7sbzu5uXP/0OjZUPIItNY/nbY+M7PHxX8a69eugK9XB7XbDYrFkWetsyKenEl1Jhh9g1ZoylOhKMniKi4uxp6UZX1q8GCPDw/hZXd0N8expacb3H3oIly+HAUijTldaOiePDMmCKdOLlT6fyNbscrkwOTmJQCCA5cuXw2q1sjz5mJyeJyN9yEpnM3l7PIPmtmaoVCq4XC6YTCZWh9K8bOFwGCaTCV1dXVCpVNhRuyPrY3b/sjEnz85dDXjjrTc/E8/qNatRVV2Nqupq6EpLC+IBUs4e38ggioqKsP7e+zAVnYLZbGaW5Ha7sxYyQJoyKisr8+bJ9evr69HV1YUlqiU4/5c+TE9PYzo2jVg8hlgsLjmDEnFE/jmJA9YDbC+p1+uh1+uhVqshiiLr9PmcNNei19BxwMacNLeShzl7BoYHUFRUBGuLFe5jbqjVakQiEVZQFEU4HA7mzDEYDGhtbWUd4HA4WNn0PABYvnw5wuEwHvjuAzhs78T16WnEZgks+42TiSR8Az4cO3rr3Yw3g4cJ7B3qx6JFRTh/7jxqn5X2v3a7HXVpc9aNwOVysVPY/gP78fCGhzAdm8Z0LIZ4LIZYfJbAORzw/8vYWLlJmoPlKx2DsRwajQYAYLVas7ZOC8Hk5CRbXTUaTcoRn7rFSCaRTM3FlLpyul3BA0CSkkgkpHu0fe17AUgCmUymDB9voZicnITRaGR1G3/emHKwJ2ZETrsyYovsrMX2dgEBoKbWJvKNDFLgop+e+OETGR41v9+/IE9XuidNMAkUuOgn38gg7W3fy9L/j8LMj7rnamnI76PADTjcI5EItbW1ZTjc16xdQxc+CNBQwEdNrU23+kNvSWDX9jKaW5tQaRKgVCpx2HYYr7/2Ostb6JWRdV8b4vE4BgYG8cxTz2A+pE8P8smSiDJOmbN/5+PJV0d+R6GOpnxtWhDH7NDc2iRZ8kU/dbteJY1GU3CPaTQachxxUOCin4YCPnr51y8XXJeI5oynp83HM1/9QrhylVkoR5YFy6h7rhY1W2vYVY/o6cWJ4yfmvLZ/VHgUBkM5u9A8fvwE9lv3F9DHEnJZS3reQqyO47i8z4VgtrXOXoTn48srMACsuqsMza0tKF6qSbuNSHc3ImPfKv/xZGJ8HC902nGu99yCP+azTA35eABkCbxQsXN1UiEccwos4/7y+7GhYgPuWn0XvqJSpf46Jb9ZetHVaBTDQ8M4ffL0goVN/wjWsJtgwbl+L2T+nG9NuGkCf4EbB09EX77VjbhdQUTcvwFtwhQyXNo3TwAAAABJRU5ErkJggg==";
return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h,g,b,c,n,f,p,e,q,r,k,t,s;a.Color=function(a,f){this.b=this.g=this.r=0;this.a=1;this.evaluator=f;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]){g=[];b=this.splitComa(a.substring(1,a.length-1));for(var e=0,d=b.length;e<d;e++)c=
parseInt(b[e],16),b[e]!=c.toString(16)&&b[e]!=="0"+c.toString(16)?("["===b[e].charAt(0)&&"]"===b[e].charAt(b[e].length-1)&&(b[e]=b[e].substring(1,b[e].length-1)),g.push(this.evaluator.parser.parse(b[e]))):g.push(this.evaluator.parser.parse((c/255).toString()));this.rExpr=g[0];this.gExpr=g[1];this.bExpr=g[2];this.aExpr=g[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=e=p=f=0,c=a.length;b<c;b++)q=a.charAt(b),"("===q?f++:")"===q?f--:"["===q?p++:"]"===q?p--:","===q&&0===f&&0===p&&(n.push(a.substring(e,b)),e=b+1);n.push(a.substring(e));return n};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){h=this.evaluator;this.r=d(255*h.evalExpression(this.rExpr));this.g=d(255*h.evalExpression(this.gExpr));this.b=d(255*h.evalExpression(this.bExpr));this.a=1-h.evalExpression(this.aExpr);return"rgba("+
this.r+","+this.g+","+this.b+","+this.a+")"};a.Color.prototype.borderColor=function(){return 380>this.r+this.g+this.b?"#ffffff":"#000000"};a.RGBAToHexColor=function(b){b=b.substring(5,b.length-1).split(",");r=parseInt(b[0]).toString(16);k=parseInt(b[1]).toString(16);t=parseInt(b[2]).toString(16);s=(255-parseInt(255*parseFloat(b[3]))).toString(16);r=1==r.length?"0"+r:r;k=1==k.length?"0"+k:k;t=1==t.length?"0"+t:t;s=1==s.length?"0"+s:s;return new a.Color(s+r+k+t)};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var d=document.head,h=document.createElement("meta");h.setAttribute("http-equiv","X-UA-Compatible");h.setAttribute("content","chrome=1");d.appendChild(h);h=document.createElement("meta");h.setAttribute("name","viewport");h.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");d.appendChild(h);h=document.createElement("meta");h.setAttribute("name","apple-mobile-web-app-capable");h.setAttribute("content","yes");d.appendChild(h);h=document.createElement("meta");
h.setAttribute("name","apple-mobile-web-app-status-bar-style");h.setAttribute("content","black-translucent");d.appendChild(h);(d=document.getElementById("StyleDescartesApps2"))&&d.parentNode.removeChild(d);d=document.createElement("style");d.type="text/css";d.id="StyleDescartesApps2";d.setAttribute("rel","stylesheet");document.head.appendChild(d);d.innerHTML="body{ text-rendering:optimizeLegibility; image-rendering:optimizeQuality; }\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:0px; 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; }\ndiv.DescartesEditorContainer{ font-family:Arial,Helvetica,'Droid Sans',Sans-serif; position:fixed; left:0px; top:0px; width:100%; height:100%; background-color:#2e2e2e; z-index:10001; }\ndiv.DescartesEditorTabContainer{ width:100%; height:100%; position:absolute; padding:0px;  }\n.DescartesTabs{ height: 37px; }\n.DescartesTabs > ul{ font-size:18px; list-style:none; padding:0 1px 1px; margin-left:4px; text-align:center; }\n.DescartesTabs > ul > li{ margin-right:1px; padding:8px 8px; float:left; color:#fff; -webkit-user-select:none; -moz-user-select:none; user-select:none; border-radius:7px 7px 0px 0px; background:#0C91EC; background:-moz-linear-gradient(top, #0C91EC 0%, #257AB6 100%); background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#0C91EC), color-stop(100%,#257AB6)); }\n.DescartesTabs > ul > li:hover{ background:#fff; background:-moz-linear-gradient(top, #FFFFFF 0%, #F3F3F3 10%, #F3F3F3 50%, #FFFFFF 100%); background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#FFFFFF), color-stop(10%,#F3F3F3), color-stop(50%,#F3F3F3), color-stop(100%,#FFFFFF)); cursor:pointer; color:#000; }\n.DescartesTabs > ul > li.tabActiveHeader{ background:#fff; background:-moz-linear-gradient(top, #FFFFFF 0%, #F3F3F3 10%, #F3F3F3 50%, #FFFFFF 100%); background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#FFFFFF), color-stop(10%,#F3F3F3), color-stop(50%,#F3F3F3), color-stop(100%,#FFFFFF)); cursor:pointer; color:#000; }\n.DescartesTabscontent{ position:absolute; left:5px; right:5px; top:55px; bottom:45px; overflow:y-scroll; padding:10px 10px 25px; background:#000; background:-moz-linear-gradient(top, #FFFFFF 0%, #FFFFFF 90%, #e4e9ed 100%); background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#FFFFFF), color-stop(90%,#FFFFFF), color-stop(100%,#e4e9ed)); margin:0px; color:#000; background-color:#000; }\ndiv.DescartesConfigPanel{ position:absolute; left:10px; right:10px; top:10px; bottom:10px; overflow:y-scroll; border:solid 1px #000; border-radius:5px; font-size:18px; padding:10px; line-height:1.5em; overflow:auto; }\ndiv.DescartesLeftPanelClass{ position:absolute; left:10px; top:10px; bottom:10px; width:200px; background-color:; border:1px solid black; overflow:auto; }\ndiv.DescartesLeftPanelClass li:nth-child(odd){ background-color:#6495ED; }\ndiv.DescartesLeftPanelClass li:nth-child(even){ background-color:#ED6495; }\ndiv.DescartesLeftPanelClass > div > ul{ list-style:none; background:#bbb; padding:5px; }\ndiv.DescartesLeftPanelClass > div > ul > li{ padding:5px; -webkit-user-select:none; -moz-user-select:none; user-select:none; cursor:pointer; white-space: nowrap; overflow: hidden; }\ndiv.DescartesRightPanelClass{ position:absolute; left:220px; right: 10px; top:10px; bottom:10px; background-color:; border:1px solid black; overflow:auto; }\ndiv.DescartesLabelAndElementContainer{ padding:4px 8px; margin:4px; display:inline-block; background-color:lightgray; border-radius:3px; }\ndiv.DescartesLabelAndElementContainer > select{ font-family:Monospace; font-size:18px; }\ndiv.DescartesLabelAndElementContainer > input{ font-family:Monospace; font-size:18px; }\ndiv.DescarteslistContainer{ font-family:Monospace; font-size:20px; position:absolute; left:10px; right:10px; top:10px; bottom:10px; border-radius:5px; background-color:white; overflow:auto; }\ndiv.DescarteslistContainer > ul{ margin:5px; padding:5px; list-style:none; }\ndiv.DescarteslistContainer > ul > li{ padding:7px; margin:1px; }\ndiv.DescarteslistContainer li:nth-child(odd){ background-color:#BBB; }\ndiv.DescarteslistContainer li:nth-child(even){ background-color:#999; }\nspan.DescartesSpanName{ background-color:lightblue; margin:5px; }\nspan.DescartesSpanValue{ background-color:white; margin:3px; padding:3px; border-radius:3px; line-height:1.5em; }\n.DescartesButtonsPlace{ -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box; text-align:center; border-radius:4px 4px 4px 4px;  position:fixed; left:5px; right:5px; bottom:0px; height:40px; min-width:290px; background: #ccc; padding:4px; }\ninput.DescartesEditorButton{ cursor:pointer; width:130px; height:30px; padding:5px 25px; background:#257AB6; border:1px solid #fff; border-radius:7px; box-shadow: inset 0px 1px 0px #3e9cbf, 0px 2px 0px 0px #205c73, 0px 4px 5px #999; color:#fff; font-size:1em; }\ninput.DescartesEditorButton:hover, input.DescartesEditorButton:focus{ background-color:#0C91EC; box-shadow:0 0 1px rgba(0,0,0, .75); }\n";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.sin,h=Math.floor,g=Math.random,b=Math.round,c=Math.abs,n=String.fromCharCode,f,p,e,q,r,k,t,s,l,u;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){f=[];for(var b=0;256>b;b++)f[b]=n(this.alfanum(h(c(7.5*(d(1*b-a)+d(1.4*b+a)+d(0.6*b-a)+d(2.2*b+a))))));return f.join("")};a.Krypto.prototype.encode=function(a){p=h(31*g());this.key=this.getKey(p);q=n(this.alfanum(p));return q+this.encripta(a)};
a.Krypto.prototype.decode=function(a){p=this.numalfa(a.charCodeAt(0));this.key=this.getKey(p);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;k=Array(3*a.length);for(var c=0,f=a.length;c<f;c++)l=256*h(a[c]+128)+b(255*g())+65536*b(255*g()),u=h((l<<this.shift(c))/256),k[3*c]=this.alfanum(u%32),k[3*c+1]=this.alfanum(u/32%
32),k[3*c+2]=this.alfanum(u/1024%32);return k};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;t=Array(a.length/3);for(var b=0,c=t.length;b<c;b++)u=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),l=h(256*u>>this.shift(b)),s=h(l/256)%256-128,0>s&&(s+=256),t[b]=s;return t};a.Krypto.prototype.alfanum=function(a){a=h(a);return 10>
a?48+a:87+a};a.Krypto.prototype.numalfa=function(a){return 58>a?a-48:a-87};a.Krypto.prototype.stringToBytes=function(a){q=Array(a.length);for(var b=0,c=a.length;b<c;b++)q[b]=a.charCodeAt(b);return q};a.Krypto.prototype.bytesToString=function(a){for(var b=0,c=a.length;b<c;b++)a[b]=n(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){e=this.key.charCodeAt(a%this.key.length);q=this.numalfa(e);r=h(q/2%8);0==r&&(r=4);return r};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;window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;window.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame;a.Animation=function(d,h){this.parent=d;var g=d.evaluator,b=g.parser,c=new a.Auxiliary(d);this.start=null;this.delay=h.delay?b.parse(h.delay):b.parse("60");this.loop=
h.loop?h.loop:!1;this.auto=void 0==h.auto?!0:h.auto;this.controls=h.controls;this.init=c.splitInstructions(b,h.init);this.doExpr=c.splitInstructions(b,h.doExpr);h.whileExpr&&(this.whileExpr=b.parse(h.whileExpr));var n=this,f,p,e=n.doExpr.length;this.animationExec=function(){for(p=0;p<e;p++)g.evalExpression(n.doExpr[p]);n.parent.update();n.playing&&(0<g.evalExpression(n.whileExpr)||n.loop)?(f=g.evalExpression(n.delay),window.requestAnimationFrame||(n.timer=setTimeout(n.animationExec,10>f?10:f))):(n.stop(),
n.parent.update())};this.playing=!1;this.auto&&this.play()};a.Animation.prototype.play=function(){var a=this;this.playing?this.stop():(this.reinit(),this.playing=!0,delay=this.parent.evaluator.evalExpression(this.delay),this.timer=window.requestAnimationFrame?requestAnimationFrame(function(h){a.step(h)}):setTimeout(this.animationExec,10>delay?10:delay))};a.Animation.prototype.stop=function(){this.playing=!1;window.requestAnimationFrame?window.cancelAnimationFrame(this.timer):clearInterval(this.timer)};
a.Animation.prototype.reinit=function(){for(var a=0,h=this.init.length;a<h;a++)this.parent.evaluator.evalExpression(this.init[a])};a.Animation.prototype.step=function(a){var h=this;null===h.start&&(h.start=a);delay=h.parent.evaluator.evalExpression(h.delay);delay=10>delay?10:delay;a-h.start>delay&&(h.animationExec(),h.start=null);0<h.parent.evaluator.evalExpression(h.whileExpr)&&(h.timer=requestAnimationFrame(function(a){h.step(a)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.Action=function(a,h){this.parent=a;this.evaluator=this.parent.evaluator};a.Action.prototype.execute=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Message=function(d,h){a.Action.call(this,d,h);this.parameter=(h||"").replace(/\\n/g,"\n").replace(/&squot;/g,"'")};a.extend(a.Message,a.Action);a.Message.prototype.execute=function(){alert(this.parameter)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Calculate=function(d,h){a.Action.call(this,
d,h);var g=this.evaluator,b=g.parser;h=(h||"").replace(/&squot;/g,"'");h=h.replace(/;/g,"\\n");h=h.split("\\n")||[""];for(var c=[],n,f=0,p=h.length;f<p;f++)(n=b.parse(h[f],!0))&&c.push(n);p=c.length;this.execute=function(){for(f=0;f<p;f++)g.evalExpression(c[f])}};a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(d,h){a.Action.call(this,d,h);this.parameter=h;this.target="_blank";var g=this.parameter.indexOf("target");-1!=g&&(this.target=
this.parameter.substring(g),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,g-1));"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),this.actionExec=function(){eval(this.parameter)}):("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,
this.target)})};a.extend(a.OpenURL,a.Action);a.OpenURL.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenScene=function(d,h){a.Action.call(this,d,h);this.parameter=h;this.target="_blank";var g=this.parameter.indexOf("target");-1!=g&&(this.target=this.parameter.substring(g),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,g-1));"_blank"!==this.target&&"_parent"!==this.target&&
"_self"!==this.target&&"_top"!==this.target?this.actionExec=function(){window.parent.postMessage({type:"changeTarget",name:this.target,value:this.parameter},"*")}:"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),this.actionExec=function(){eval(this.parameter)}):("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,
this.target,"width="+this.parent.width+",height="+this.parent.height+",left="+(window.screen.width-this.parent.width)/2+", top="+(window.screen.height-this.parent.height)/2+"location=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0")})};a.extend(a.OpenScene,a.Action);a.OpenScene.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.About=function(d,h){a.Action.call(this,d,h);h||(this.urlAbout=window.location.href.substring(0,
window.location.href.lastIndexOf("/")+1)+h)};a.extend(a.About,a.Action);a.About.prototype.execute=function(){console.log("about");if(this.urlAbout)var a=window.open(this.urlAbout,"_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes");else a=window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes"),a.document.write("<hmtl><head><title>Cr\u00e9ditos</title></head><body><h1>Aqu\u00ed van los cr\u00e9ditos</h1></body></html>")};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.Config=function(d,h){a.Action.call(this,d,h)};a.extend(a.Config,a.Action);a.Config.prototype.execute=function(){this.parent.editor?this.parent.editor.show():window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'><script type='text/javascript' src='http://arquimedes.matem.unam.mx/Descartes5/lib/descartes-min.js'>\x3c/script>\n"+this.parent.applet.outerHTML.replace(/<applet/g,
"<ajs").replace(/<\/applet/g,"</ajs")+"</xmp>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Init=function(d,h){a.Action.call(this,d,h)};a.extend(a.Init,a.Action);a.Init.prototype.execute=function(){this.parent.init()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Clear=function(d,h){a.Action.call(this,d,h)};a.extend(a.Clear,a.Action);a.Clear.prototype.execute=function(){this.parent.clear()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.Animate=function(d,h){a.Action.call(this,d,h)};a.extend(a.Animate,a.Action);a.Animate.prototype.execute=function(){this.parent.play()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.InitAnimation=function(d,h){a.Action.call(this,d,h)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g;
a.PlayAudio=function(h,g){a.Action.call(this,h,g);g&&g.match(d)?this.filenameExpr=this.evaluator.parser.parse("'"+g.match(d)+"'"):this.filenameExpr=this.evaluator.parser.parse(g)};a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=function(){var a=this.theAudio=this.parent.getAudio(this.evaluator.evalExpression(this.filenameExpr));a.paused?a.play():(a.pause(),a.currentTime=0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Auxiliary=function(a,b){this.parent=
a;this.evaluator=this.parent.evaluator;this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var c in b)b.hasOwnProperty(c)&&(this[c]=b[c])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var d,h;a.Auxiliary.prototype.splitInstructions=function(a,b){h=[];b=b?b.split(";"):[""];for(var c=0,n=b.length;c<n;c++)(d=a.parse(b[c],!0))&&h.push(d);return h};a.Auxiliary.prototype.getPrivateVariables=function(a,b){h=[];b=b?b.split(/;|,/):[""];for(var c=0,
n=b.length;c<n;c++)(d=a.parse(b[c],!0))&&h.push(d);c=0;for(n=h.length;c<n;c++)h[c]="asign"===h[c].type?h[c].childs[0].value:"identifier"===h[c].type?h[c].value:"";return h};a.Auxiliary.prototype.parseExpressions=function(a){this.init=this.splitInstructions(a,this.init);this.privateVars=this.getPrivateVariables(a,this.local);this.doExpr=this.splitInstructions(a,this.doExpr);this.whileExpr=a.parse(this.whileExpr)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Variable=function(d,
h){a.Auxiliary.call(this,d,h);var g=this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=g.parse(this.expresionString))&&g.setVariable(this.id,this.expresion);this.editable&&(this.registerTextField(),this.parent.editableRegionVisible=!0)};a.extend(a.Variable,a.Auxiliary);a.Variable.prototype.registerTextField=function(){var a=document.createElement("div"),h=document.createElement("label");h.appendChild(document.createTextNode("___"+this.id+"=___"));var g=document.createElement("input");
g.value=this.expresionString;g.disabled=!this.editable;a.appendChild(h);a.appendChild(g);var b=this,c=b.evaluator.parser;g.onkeydown=function(a){13==a.keyCode&&(b.expresion=c.parse(this.value),c.setVariable(b.id,b.expresion),b.parent.update())};this.parent.editableRegion.textFields.push({container:a,type:"div"})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Constant=function(d,h){a.Auxiliary.call(this,d,h);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};
a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=function(){this.evaluator.setVariable(this.id,this.evaluator.evalExpression(this.expresion))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g;a.Vector=function(b,c){d=b.evaluator;h=d.parser;this.size=h.parse("3");a.Auxiliary.call(this,b,c);this.expresion=this.expresion.split(";");this.parseFile=h.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var b=this.expresion;
d=this.evaluator;h=d.parser;this.oldFile=this.file;if(g=d.evalExpression(this.parseFile))this.file=g;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=[],f=0,p=c.length;f<p;f++)""!=c[f]&&n.push(c[f]);c=n}null==c||1==c.length&&""==c[0]?this.size=0:(b=c,this.size=null);null===this.size&&(this.size=h.parse(b.length+""))}c=[];f=0;for(p=
b.length;f<p;f++)(n=h.parse(b[f],!0))&&"asign"!=n.type&&(n=h.parse(this.id+"["+f+"]="+b[f],!0)),c.push(n);b=[];f=0;for(p=d.evalExpression(this.size);f<p;f++)b.push(0);d.vectors[this.id]=b;d.setVariable(this.id+".long",d.evalExpression(this.size));f=0;for(p=c.length;f<p;f++)d.evalExpression(c[f])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(d,h){var g=d.evaluator,b=g.parser;this.rows=b.parse("3");this.columns=b.parse("3");a.Auxiliary.call(this,d,h);this.expresion=
this.splitInstructions(b,this.expresion);var b=g.evalExpression(this.rows),c=g.evalExpression(this.columns),n=[];n.type="matrix";for(var f,p=0;p<c;p++){f=[];for(var e=0,q=b;e<q;e++)f.push(0);n[p]=f}g.matrices[this.id]=n;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,h=a.evalExpression(this.rows),g=a.evalExpression(this.columns);a.setVariable(this.id+".filas",h);a.setVariable(this.id+".columnas",g);var b=a.matrices[this.id];b.rows=h;b.cols=g;
h=0;for(g=this.expresion.length;h<g;h++)a.evalExpression(this.expresion[h])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(d,h){a.Auxiliary.call(this,d,h);var g=this.evaluator,b=g.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,e=n.privateVars.length;c<e;c++)b.push(g.getVariable(n.privateVars[c])),g.setVariable(n.privateVars[c],0);for(var d=[],c=0,e=n.params.length;c<e;c++)d[c]=g.getVariable(n.params[c])||0,g.setVariable(n.params[c],arguments[c]);c=0;for(e=n.init.length;c<e;c++)g.evalExpression(n.init[c]);
do{c=0;for(e=n.doExpr.length;c<e;c++)g.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<g.evalExpression(n.whileExpr));var h=g.evalExpression(n.expresion);a.rangeOK=g.evalExpression(n.domain);c=0;for(e=n.params.length;c<e;c++)g.setVariable(n.params[c],d[c]);c=0;for(e=n.privateVars.length;c<e;c++)g.setVariable(n.privateVars[c],b[c]);return h}return 0};g.setFunction(this.name,this.functionExec)};
a.extend(a.Function,a.Auxiliary);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Algorithm=function(d,h){a.Auxiliary.call(this,d,h);var g=this.evaluator;this.parseExpressions(g.parser);this.algorithmExec=function(){for(var a=this.iterations=0,c=this.init.length;a<c;a++)g.evalExpression(this.init[a]);do{a=0;for(c=this.doExpr.length;a<c;a++)g.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<g.evalExpression(this.whileExpr))}};a.extend(a.Algorithm,a.Auxiliary);a.Algorithm.prototype.update=function(){this.algorithmExec();"onlyOnce"===this.evaluate&&(this.update=function(){})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Event=function(d,h){a.Auxiliary.call(this,d,h);var g=this.evaluator;this.condition=g.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&
(this.eventExec=function(){0<g.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<g.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<
g.evalExpression(this.condition)&&this.action.execute()})};a.extend(a.Event,a.Auxiliary);a.Event.prototype.update=function(){this.eventExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c;a.Graphic=function(b,c){this.parent=b;this.evaluator=b.evaluator;var d=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=d.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=d.parse("(0,0)");this.family="";this.family_interval=d.parse("[0,1]");this.family_steps=d.parse("8");this.editable=!1;this.font=5<=this.parent.version?"Monospaced,PLAIN,15":"Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=d.parse("2");for(var e in c)c.hasOwnProperty(e)&&(this[e]=c[e]);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/))?parseFloat(this.fontSize[1]):10};a.Graphic.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.Graphic.prototype.getFamilyValues=function(){d=this.evaluator;h=d.evalExpression(this.family_interval);this.familyInf=h[0][0];this.familySup=h[0][1];this.fSteps=
Math.round(d.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,b,c){d=this.evaluator;this.getFamilyValues();g=d.getVariable(this.family);if(0<=this.fSteps)for(var e=0,h=this.fSteps;e<=h;e++)d.setVariable(this.family,this.familyInf+e*this.family_sep),0<d.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,c));d.setVariable("_Text_H_",0);d.setVariable(this.family,g)};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,f,g,e,h,r,k,t,s,l,u){if("rtfNode"===f.type)a.fillStyle=h.getColor(),a.strokeStyle=h.getColor(),a.textBaseline="alphabetic",
f.draw(a,g,e,s,l,k,u,h.getColor());else for("simpleText"===f.type&&(f=f.toString(s,l).split("\\n")),g+=r.match("Arial")?-2:r.match("Times")?-2:0,d=this.evaluator,a.fillStyle=h.getColor(),a.font=r,a.textAlign=k,a.textBaseline=t,this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=3),c=1.2*this.fontSize||0,h=0,r=f.length;h<r;h++)b=f[h],this.border&&(a.lineJoin="round",a.strokeText(b,g,e+c*h)),a.fillText(b,g,e+c*h)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=
function(a,b){this.text=b=b.replace("&#x2013","\u2013").replace(/\&squot;/g,"'");this.textElements=[];this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var c="'",d=0,f=0,h=-1,e,q;d<b.length;)e=b.charAt(d),q=b.charAt(d-1),"["===e&&"\\"===q?(this.textElements.push(b.substring(f,d-1)+"["),this.textElementsMacros.push("'"+b.substring(f,d-1)+"['"),f=d+1):"]"===e&&"\\"===q?(this.textElements.push(b.substring(f,d-1)+"]"),this.textElementsMacros.push("'"+b.substring(f,
d-1)+"]'"),f=d+1):"["===e&&-1===h?(this.textElements.push(b.substring(f,d)),this.textElementsMacros.push("'"+b.substring(f,d)+"'"),f=d,h++):"["===e?h++:"]"===e&&0===h?(this.textElements.push(this.evaluator.parser.parse(b.substring(f,d+1))),this.textElementsMacros.push("["+b.substring(f,d+1)+"]"),f=d+1,h--):("]"==b.charAt(d)&&(h=0>h?h:h-1),c+=b.charAt(d)),d++;this.textElements.push(b.substring(f,d));this.textElementsMacros.push("'"+b.substring(f,d)+"'")};var d,h;a.SimpleText.prototype.toString=function(g,
b){d="";for(var c=0,n=this.textElements.length;c<n;c++)"string"===typeof this.textElements[c]?d+=this.textElements[c]:(h=this.evaluator.evalExpression(this.textElements[c])[0][0],""!==h&&("string"===typeof h?d+=h:(h=parseFloat(h),h=b?h.toFixed(g):a.removeNeedlessDecimals(h.toFixed(g)),d+=h.toString().replace(".",this.parent.decimal_symbol))));return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f,p,e,q,r,k,t,s,l,u,m,v,w,y,C,B,D,F,A,z,H;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();k=new a.R2;t=new a.R2;s=new a.R2;m=new a.R2;l=new a.R2};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"===this.expresion.type){var b=this.expresion.childs[0],c=this.expresion.childs[1];"identifier"!=b.type||"y"!=
b.value||c.contains("y")?"identifier"!=c.type||"y"!=c.value||b.contains("y")?"identifier"!=b.type||"x"!=b.value||c.contains("x")?"identifier"!=c.type||"x"!=c.value||b.contains("x")||(this.of_y=!0,this.funExpr=c,this.drawAux=this.drawAuxFun):(this.funExpr=c,this.of_y=!0,this.drawAux=this.drawAuxFun):(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):(this.funExpr=c,this.of_y=!1,this.drawAux=this.drawAuxFun)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.generateStroke=
function(){this.auxCanvas=document.createElement("canvas");this.oldWwidth=parseInt(this.evaluator.evalExpression(this.width));this.width_2=parseInt(this.oldWwidth/2)||1;this.auxCanvas.setAttribute("width",this.oldWwidth);this.auxCanvas.setAttribute("height",this.oldWwidth);this.auxCtx=this.auxCanvas.getContext("2d");this.auxCtx.fillStyle=this.color.getColor();this.auxCtx.fillRect(0,0,this.oldWwidth,this.oldWwidth)};var 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){h=this.evaluator;this.getFamilyValues();tempParam=h.getVariable(this.family);if(0<=this.fSteps)for(var f=0,e=this.fSteps;f<=e;f++)h.setVariable(this.family,this.familyInf+f*this.family_sep),this.update(),this.drawAux(a,b,c);h.setVariable(this.family,
tempParam)};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(I,L,x){I.lineWidth=1;h=this.evaluator;g=h.parser;b=this.space;c=h.evalExpression(this.width);I.fillStyle=x.getColor();I.translate(-parseInt(c/2),-parseInt(c/2));n=g.getVariable("x");f=g.getVariable("y");p=b.w;e=b.h;q=p/9;3>q&&(q=3);r=e/7;3>r&&(r=3);d=[];k.set(0,0);t.set(0,0);s.set(0,0);for(H=parseInt(r/2);H<e;H+=r)for(z=parseInt(q/2);z<p;z+=q)if(this.abs_coord?
(m.set(z,H),u=this.newt.findZero(m),h.setVariable("x",u.x),h.setVariable("y",u.y),l.set(u.x,u.y)):(m.set(b.getRelativeX(z),b.getRelativeY(H)),u=this.newt.findZero(m),h.setVariable("x",u.x),h.setVariable("y",u.y),l.set(b.getAbsoluteX(u.x),b.getAbsoluteY(u.y))),v=l.ix(),w=l.iy(),!(0>v||v>=p||0>w||w>=e||d[v+w*b.w])&&(d[v+w*b.w]=!0,a.rangeOK&&h.evalExpression(this.drawif)&&I.drawImage(this.auxCanvas,v,w),k.x=u.x,k.y=u.y,t.x=u.x,t.y=u.y,y=this.newt.getUnitNormal(),0!=y.x||0!=y.y))for(y.rotL90(),s.x=y.x,
s.y=y.y,B=C=0,D=!1;2>B;){D&&(s.x=-y.x,s.y=-y.y,u.x=k.x,u.y=k.y,t.x=u.x,t.y=u.y,this.abs_coord?l.set(u.x,u.y):l.set(b.getAbsoluteX(u.x),b.getAbsoluteY(u.y)),v=l.ix(),w=l.iy(),D=!1,C=0);this.abs_coord?(u.x+=s.x,u.y+=s.y):(u.x+=s.x/b.scale,u.y+=s.y/b.scale);u=this.newt.findZero(u);h.setVariable("x",u.x);h.setVariable("y",u.y);s.x=u.x-t.x;s.y=u.y-t.y;s.normalize();if(0==s.x&&0==s.y)break;t.x=u.x;t.y=u.y;this.abs_coord?l.set(u.x,u.y):l.set(b.getAbsoluteX(u.x),b.getAbsoluteY(u.y));F=parseInt(l.ix());A=
parseInt(l.iy());if(F!=v||A!=w)if(L=v,x=w,v=F,w=A,0<=v&&v<p&&0<=w&&w<e){C=0;var J=d[v+w*b.w];d[v+w*b.w]=!0;for(var E=1;8>E;E++){var G=L+Math.round((v-L)*E/8),N=x+Math.round((w-x)*E/8);0<=G&&G<p&&0<=N&&N<e&&(d[G+N*b.w]=!0)}a.rangeOK&&h.evalExpression(this.drawif)&&I.drawImage(this.auxCanvas,v,w);if(J)break}else D=!0,B++;else 4<++C&&(D=!0,B++)}I.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,f,e,d,g){for(var h=this.evaluator.getVariable(c),l=g/2,m=0;1E-12<Math.abs(l);){var p=this.evaluator.getVariable(c),r=this.evaluator.getVariable(c)+
l;this.evaluator.setVariable(c,r);var n=!0,q=d;d=this.evaluator.evalExpression(this.funExpr);this.evaluator.setVariable(f,d);if(0<this.evaluator.evalExpression(b)){var k=new a.R2(Math.min(q,d),Math.max(q,d)),t=0,t=0<g?this.Singularity(Math.abs(l),c,e,p,q,r,d,k):this.Singularity(Math.abs(l),c,e,r,d,p,q,k);0<t&&(n=!1)}else n=!1;n?m+=l:this.evaluator.setVariable(c,p);l/=2}this.evaluator.setVariable(c,h);return new a.R2(m/Math.abs(g),d)};a.Equation.prototype.extrapolateOnSingularity=function(b,c,f,e,
d,g){e=this.evaluator.getVariable(c);for(var h=g/2,l=0,m=d;1E-12<Math.abs(h);){this.evaluator.setVariable(this.evaluator.getVariable(c)+h);var p=!0;0<this.evaluator.evalExpression(b)?(m=this.evaluator.evalExpression(this.funExpr),this.evaluator.setVariable(f,m),0>=this.evaluator.evalExpression(b)&&(p=!1)):p=!1;p?l+=h:this.evaluator.setVariable(this.evaluator.getVariable(c)-h);h/=2}if(0==l)for(h=g/2,l=g,m=d;1E-12<Math.abs(h);)this.evaluator.setVariable(this.evaluator.getVariable(c)-h),p=!0,0<this.evaluator.evalExpression(b)?
m=this.evaluator.evalExpression(this.funExpr):p=!1,p?l+=-h:this.evaluator.setVariable(this.evaluator.getVariable(c)+h),h/=2;this.evaluator.setVariable(e);return new a.R2(l/Math.abs(g),m)};a.Equation.prototype.Singularity=function(a,b,c,f,e,d,g,h){if(f>=d)return 2;var l=this.evaluator.getVariable(b),m=0;if(1E-12>Math.abs(d-f)||1E-8>Math.abs(d-f)&&Math.abs(g-e)>Math.abs(a))return this.evaluator.setVariable(b,l),1;var p=(f+d)/2;this.evaluator.setVariable(b,p);var r=this.evaluator.evalExpression(this.funExpr);
if(Math.abs(g-e)>a){this.evaluator.setVariable(b,f-1E-6);var n=this.evaluator.evalExpression(this.funExpr),n=(e-n)/1E-6;this.evaluator.setVariable(b,d+1E-6);var q=(this.evaluator.evalExpression(this.funExpr)-g)/1E-6,k=(g-e)/(d-f);if((10>Math.abs(q)||10>Math.abs(n))&&(0<=q&&0<=n||0>=q&&0>=n)&&8*Math.abs(q)<Math.abs(k))return this.evaluator.setVariable(b,l),2}h.x<=r&&r<=h.y||(this.evaluator.setVariable(b,p),h.x=Math.min(e,r),h.y=Math.max(e,r),f=this.Singularity(a/2,b,c,f,e,p,r,h),this.evaluator.setVariable(b,
d),h.x=Math.min(g,r),h.y=Math.max(g,r),a=this.Singularity(a/2,b,c,p,r,d,g,h),m=Math.max(f,a));this.evaluator.setVariable(b,l);return m};a.Equation.prototype.drawAuxFun=function(b,c,e){n=this.evaluator.parser.getVariable("x");f=this.evaluator.parser.getVariable("y");a.rangeOK=1;c="x";e="y";this.of_y&&(c="y",e="x");var d=this.drawif,g=this.evaluator.evalExpression(this.width),h=!1,l=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),l=this.of_y?l.ix():l.iy(),m=0,p=0,r=0,q=1/this.space.scale,
k=q*(this.of_y?-this.space.h+(this.space.h/2+this.space.Oy):-(this.space.w/2+this.space.Ox)),m=0;this.abs_coord&&(k=0,q=1);for(var t=this.of_y?this.space.h:this.space.w;p<t;){var u=!0,v=0;this.evaluator.setVariable(c,k);var s=this.evaluator.evalExpression(this.funExpr);if(isNaN(s))u=!1;else{this.evaluator.setVariable(e,s);if(0<this.evaluator.evalExpression(this.drawif)&&a.rangeOK){if(h){var v=Math.min(m,s),w=Math.max(m,s),w=new a.R2(v,w),v=this.Singularity(q,c,0,k-q,m,k,s,w);0===v?(m<=s?(m=w.x,s=
w.y):(s=w.x,m=w.y),v=this.of_y?this.XX(g,m,this.abs_coord):this.YY(g,m,this.abs_coord),m=this.abs_coord?Math.round(s):this.of_y?this.XX(g,s,this.abs_coord):this.YY(g,s,this.abs_coord),this.fillM&&m>l&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(l+1,this.space.h-p+0.5),b.lineTo(m,this.space.h-p+0.5)):(b.moveTo(p+0.5,l+1),b.lineTo(p+0.5,m)),b.stroke()),this.fillP&&m<l&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(l-1,this.space.h-
p+0.5),b.lineTo(m,this.space.h-p+0.5)):(b.moveTo(p+0.5,l-1),b.lineTo(p+0.5,m)),b.stroke()),b.lineWidth=g,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(v+0.5,this.space.h-r),b.lineTo(m+0.5,this.space.h-p)):(b.moveTo(r+0.5,v),b.lineTo(p+0.5,m)),b.stroke()):(1===v&&(this.evaluator.setVariable(c,k-q),r=this.extrapolate(d,c,e,0,m,q),this.YY(g,r.y,this.abs_coord),this.evaluator.setVariable(c,k),r=this.extrapolate(d,c,e,0,s,-q),this.YY(g,r.y,this.abs_coord)),this.YY(g,s,this.abs_coord))}else r=
this.extrapolateOnSingularity(d,c,e,0,s,-q),this.YY(g,r.y,this.abs_coord),this.YY(g,s,this.abs_coord);m=s}else u=!1;h&&!u&&(this.evaluator.setVariable(c,k-q),this.evaluator.setVariable(e,m),r=this.extrapolate(d,c,e,0,m,q),this.YY(g,r.y,this.abs_coord),this.evaluator.setVariable(c,k))}h=u;k+=q;r=p++}this.evaluator.parser.setVariable("x",n);this.evaluator.parser.setVariable("y",f)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=
!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parseExpression(),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round;a.Curve=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,
b,c);(this.visible=2==this.parent.version&&void 0==this.visible?!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);var h,g,b,c,n,f,p,e,q,r,k;a.Curve.prototype.update=function(){h=this.evaluator;g=h.evalExpression(this.parameter_interval);this.paraInf=g[0][0];this.paraSup=g[0][1];this.pSteps=h.evalExpression(this.parameter_steps);this.paraSep=0<this.pSteps?Math.abs(this.paraSup-this.paraInf)/this.pSteps:0};a.Curve.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};
a.Curve.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Curve.prototype.drawAux=function(g,s,l){h=this.evaluator;b=this.space;c=d(h.evalExpression(this.width));g.lineWidth=0<c?c:1E-6;g.lineCap="round";g.lineJoin="round";g.strokeStyle=l.getColor();n=h.getVariable(this.parameter);g.beginPath();h.setVariable(this.parameter,this.paraInf);f=h.evalExpression(this.expresion);this.exprX=this.abs_coord?d(f[0][0]):d(b.getAbsoluteX(f[0][0]));this.exprY=this.abs_coord?d(f[0][1]):
d(b.getAbsoluteY(f[0][1]));this.rotateExp&&(p=a.degToRad(h.evalExpression(this.rotateExp)),e=Math.cos(p),q=Math.sin(p),r=this.exprX*e-this.exprY*q,k=this.exprX*q+this.exprY*e,this.exprX=r,this.exprY=k);g.moveTo(this.exprX+0.5,this.exprY+0.5);for(l=1;l<=this.pSteps;l++)h.setVariable(this.parameter,this.paraInf+l*this.paraSep),f=h.evalExpression(this.expresion),this.exprX=this.abs_coord?d(f[0][0]):d(b.getAbsoluteX(f[0][0])),this.exprY=this.abs_coord?d(f[0][1]):d(b.getAbsoluteY(f[0][1])),this.rotateExp&&
(r=this.exprX*e-this.exprY*q,k=this.exprX*q+this.exprY*e,this.exprX=r,this.exprY=k),g.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&(g.fillStyle=s.getColor(),g.fill());g.stroke();h.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,h=Math.round,g,b,c,n,f,p,e,q,r,k,t,s,l,u;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(){g=this.evaluator;c=g.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(n=a.degToRad(g.evalExpression(this.rotateExp)),f=Math.cos(n),
p=Math.sin(n),e=this.exprX*f-this.exprY*p,q=this.exprX*p+this.exprY*f,this.exprX=e,this.exprY=q);t=g.evalExpression(this.range);this.rangeInf=t[0][0];this.rangeMax=t[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,f){g=this.evaluator;b=this.space;l=s=Math.ceil(g.evalExpression(this.size)-0.4);a.fillStyle=f.getColor();a.beginPath();
this.rangeInf>this.rangeMax&&(u=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=u);for(var e=g.getVariable("n"),p=this.rangeInf,q=this.rangeMax;p<=q;p++)g.setVariable("n",p),c=g.evalExpression(this.expresion),this.exprX=c[0][0],this.exprY=c[0][1],r=this.abs_coord?h(this.exprX):h(b.getAbsoluteX(this.exprX)),k=this.abs_coord?h(this.exprY):h(b.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(r,k,s,0,d,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,r+l,k-l,this.color,
this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0);g.setVariable("n",e)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI,h=Math.round,g,b,c,n,f,p,e,q,r,k,t,s;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(){g=this.evaluator;c=g.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(n=a.degToRad(g.evalExpression(this.rotateExp)),
f=Math.cos(n),p=Math.sin(n),e=this.exprX*f-this.exprY*p,q=this.exprX*p+this.exprY*f,this.exprX=e,this.exprY=q)};a.Point.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Point.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Point.prototype.drawAux=function(a,c){g=this.evaluator;b=this.space;t=h(g.evalExpression(this.size));s=t+1;a.fillStyle=c.getColor();r=this.abs_coord?h(this.exprX):h(b.getAbsoluteX(this.exprX));k=this.abs_coord?h(this.exprY):
h(b.getAbsoluteY(this.exprY));a.beginPath();a.arc(r,k,t,0,d,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,r+s+1,k-s,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,h=2*Math.PI,g,b,c,n,f,p,e,q,r,k,t,s,l,u,m,v,w,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(){g=this.evaluator;c=g.evalExpression(this.expresion);this.endPoints=[];for(var b=0,d=c.length;b<d;b++)this.endPoints[b]={x:c[b][0],y:c[b][1]};if(this.rotateExp)for(n=a.degToRad(g.evalExpression(this.rotateExp)),f=Math.cos(n),p=Math.sin(n),b=0,d=this.endPoints.length;b<d;b++)e=this.endPoints[b].x*f-this.endPoints[b].y*p,q=this.endPoints[b].x*p+this.endPoints[b].y*f,this.endPoints[b].x=e,this.endPoints[b].y=q};a.Segment.prototype.draw=function(){this.uber.draw.call(this,
this.color,this.color)};a.Segment.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Segment.prototype.drawAux=function(a,c,f){g=this.evaluator;b=this.space;r=d(g.evalExpression(this.width));a.lineWidth=0<r?r:1E-6;l=g.evalExpression(this.size);0>l&&(l=0);a.fillStyle=c.getColor();a.strokeStyle=f.getColor();a.lineCap="round";k=10+a.lineWidth;u=0==a.lineWidth%2?0:0.5;this.abs_coord?(m=d(this.endPoints[0].x),v=d(this.endPoints[0].y),w=d(this.endPoints[1].x),y=d(this.endPoints[1].y)):
(m=d(b.getAbsoluteX(this.endPoints[0].x)),v=d(b.getAbsoluteY(this.endPoints[0].y)),w=d(b.getAbsoluteX(this.endPoints[1].x)),y=d(b.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(m+u,v+u);a.lineTo(w+u,y+u);a.stroke();a.beginPath();a.arc(m,v,l,0,h,!0);a.arc(w,y,l,0,h,!0);a.fill();this.text!=[""]&&(t=parseInt((m+w)/2)-3,s=parseInt((v+y)/2)+3,this.uber.drawText.call(this,a,this.text,t+k,s-k,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h=Math.round,g,b,c,n,f,p,e,q,r,k,t,s,l,u,m,v,w,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(){g=this.evaluator;b=g.evalExpression(this.expresion);this.endPoints=[];for(var d=0,h=b.length;d<h;d++)this.endPoints[d]=
{x:b[d][0],y:b[d][1]};if(this.rotateExp)for(c=a.degToRad(g.evalExpression(this.rotateExp)),n=Math.cos(c),f=Math.sin(c),d=0,h=this.endPoints.length;d<h;d++)p=this.endPoints[d].x*n-this.endPoints[d].y*f,e=this.endPoints[d].x*f+this.endPoints[d].y*n,this.endPoints[d].x=p,this.endPoints[d].y=e};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,f){g=this.evaluator;q=this.space;g.evalExpression(this.size);t=g.evalExpression(this.width);0>t&&(t=0);s=Math.ceil(t/2);l=q.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);u=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);b.fillStyle=c.getColor();b.strokeStyle=f.getColor();b.lineWidth=2;this.abs_coord?(m=h(this.endPoints[0].x),v=h(this.endPoints[0].y),w=h(this.endPoints[1].x),y=h(this.endPoints[1].y)):
(m=h(q.getAbsoluteX(this.endPoints[0].x)),v=h(q.getAbsoluteY(this.endPoints[0].y)),w=h(q.getAbsoluteX(this.endPoints[1].x)),y=h(q.getAbsoluteY(this.endPoints[1].y)));c=g.evalExpression(this.spear);0>c&&(c=0);b.save();b.translate(m,v,u);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):(u*=l,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(-s,d(-s));
b.lineTo(d(u-c-t),d(-s));b.lineTo(d(u-2*c),d(-c-s));b.lineTo(d(u),0);b.lineTo(d(u-2*c),d(c+s));b.lineTo(d(u-c-t),d(s));b.lineTo(-s,d(s));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(r=parseInt((m+w)/2)-3,k=parseInt((v+y)/2)+3,this.uber.drawText.call(this,b,this.text,r,k,f,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,h,g,b,c,n,f,p,e,q,r,k,t;a.Polygon=function(b,
c){this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,c);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){h=this.evaluator;b=h.evalExpression(this.expresion);for(var d=0,g=b.length;d<g;d++)this.endPoints[d]={x:b[d][0],y:b[d][1]};if(this.rotateExp)for(c=a.degToRad(h.evalExpression(this.rotateExp)),n=Math.cos(c),f=Math.sin(c),d=0,g=this.endPoints.length;d<g;d++)p=this.endPoints[d].x*n-this.endPoints[d].y*f,e=this.endPoints[d].x*f+this.endPoints[d].y*
n,this.endPoints[d].x=p,this.endPoints[d].y=e};a.Polygon.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Polygon.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Polygon.prototype.drawAux=function(a,b,c){h=this.evaluator;g=this.space;q=d(h.evalExpression(this.width));a.lineWidth=0<q?q:1E-6;a.strokeStyle=c.getColor();a.lineCap="round";a.lineJoin="round";r=0<q?0.5:0;k=this.abs_coord?d(this.endPoints[0].x):d(g.getAbsoluteX(this.endPoints[0].x));
t=this.abs_coord?d(this.endPoints[0].y):d(g.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(k+r,t+r);c=1;for(var f=this.endPoints.length;c<f;c++)k=this.abs_coord?d(this.endPoints[c].x):d(g.getAbsoluteX(this.endPoints[c].x)),t=this.abs_coord?d(this.endPoints[c].y):d(g.getAbsoluteY(this.endPoints[c].y)),a.lineTo(k+r,t+r);this.fill&&(a.fillStyle=b.getColor(),a.fill());a.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,h,g,b,c,n,f,p,e,q,r,k,
t,s,l,u,m,v,w,y,C,B;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="0";this.end="90";a.Graphic.call(this,b,c);this.init.match(/^_\(/)&&(this.initFlag=!0,this.init=this.init.substring(1));this.end.match(/^_\(/)&&(this.endFlag=!0,this.end=this.end.substring(1));this.initExpr=b.evaluator.parser.parse(this.init);this.endExpr=b.evaluator.parser.parse(this.end)};a.extend(a.Arc,a.Graphic);
a.Arc.prototype.update=function(){h=this.evaluator;g=h.evalExpression(this.center);this.exprX=g[0][0];this.exprY=g[0][1];b=0;this.rotateExp&&(b=a.degToRad(h.evalExpression(this.rotateExp)),c=Math.cos(b),n=Math.sin(b),f=this.exprX*c-this.exprY*n,p=this.exprX*n+this.exprY*c,this.exprX=f,this.exprY=p);var d=h.evalExpression(this.initExpr),m=h.evalExpression(this.endExpr);"(expr)"==this.initExpr.type&&"(expr)"==this.endExpr.type||"[expr]"==this.initExpr.type&&"[expr]"==this.endExpr.type||"(expr)"==this.initExpr.type&&
"[expr]"==this.endExpr.type||"[expr]"==this.initExpr.type&&"(expr)"==this.endExpr.type?(e=d[0][0],q=d[0][1],r=m[0][0],k=m[0][1],this.vectors?this.abs_coord&&(q=-q,k=-k):this.abs_coord?(e-=this.exprX,q=-q+this.exprY,r-=this.exprX,k=-k+this.exprY):(e-=this.exprX,q-=this.exprY,r-=this.exprX,k-=this.exprY),t=0==e?0>q?-Math.PI/2:Math.PI/2:Math.acos(1*e/Math.sqrt(e*e+q*q)),s=0==r?0>k?-Math.PI/2:Math.PI/2:Math.acos(1*r/Math.sqrt(r*r+k*k)),t+=b,s+=b,0<e&&0<q&&this.abs_coord&&(t=2*Math.PI-t),0<e&&0>q&&!this.abs_coord&&
(t=2*Math.PI-t),0>e&&0>q&&!this.abs_coord&&(t=2*Math.PI-t),0>e&&0<q&&this.abs_coord&&(t=2*Math.PI-t),0<r&&0<k&&this.abs_coord&&(s=2*Math.PI-s),0<r&&0>k&&!this.abs_coord&&(s=2*Math.PI-s),0>r&&0>k&&!this.abs_coord&&(s=2*Math.PI-s),0>r&&0<k&&this.abs_coord&&(s=2*Math.PI-s),l=Math.min(t,s),u=Math.max(t,s),t=l,s=u,s-t>Math.PI&&this.abs_coord&&(t=u,s=l),s-t<=Math.PI&&!this.abs_coord&&(t=u,s=l),this.iniAng=t,this.endAng=s,this.drawPoints=!0):(this.iniAng=a.degToRad(d)+b,this.endAng=a.degToRad(m)+b,this.drawAngle=
!0)};a.Arc.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Arc.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Arc.prototype.drawAux=function(a,b,c){h=this.evaluator;m=this.space;y=h.evalExpression(this.radius);0>y&&(y=0);B=d(h.evalExpression(this.width));a.lineWidth=0<B?B:1E-6;a.lineCap="round";a.strokeStyle=c.getColor();this.drawAngle?(this.abs_coord?(v=d(this.exprX),w=d(this.exprY)):(v=d(m.getAbsoluteX(this.exprX)),w=d(m.getAbsoluteY(this.exprY)),
y*=m.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&(C=this.iniAng,this.iniAng=this.endAng,this.endAng=C)):this.drawPoints&&(this.abs_coord?(v=d(this.exprX),w=d(this.exprY)):(v=d(m.getAbsoluteX(this.exprX)),w=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(v,w),a.arc(v,w,y,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();a.arc(v,w,y,this.iniAng,this.endAng,
void 0);a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,v+4,w-2,this.color,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f,p,e,q,r,k,t,s,l,u,m,v;a.Text=function(b,c){this.width=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.align||(this.align="start");this.ascent=this.fontSize-Math.ceil(this.fontSize/7)-(this.font.match("Courier")?3:0);this.abs_coord=
!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){d=this.evaluator;h=d.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1];this.rotateExp&&(g=a.degToRad(d.evalExpression(this.rotateExp)),b=Math.cos(g),c=Math.sin(g),n=this.exprX*b-this.exprY*c,f=this.exprX*c+this.exprY*b,this.exprX=n,this.exprY=f)};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){v=this.evaluator.evalExpression(this.decimals);"rtfNode"===this.text.type?(r=this.text,this.ascent=0):r=this.splitText(this.text.toString(v,this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,a,r,parseInt(this.exprX)+5,parseInt(this.exprY)+this.ascent,b,this.font,this.align,"alphabetic",v,this.fixed)};a.Text.prototype.splitText=function(a){d=this.evaluator;p=d.evalExpression(this.width);r=[];this.ctx.font=this.font;if(20<=p&&"undefined"!=a.type){for(var b=0,c=a.length;b<
c;b++)e=a[b],q=this.ctx.measureText(e).width,q>p?r=r.concat(this.splitWords(e,p)):r.push(e);k=Math.floor(1.2*this.fontSize)*r.length;d.setVariable("_Text_H_",k);return r}d.setVariable("_Text_H_",0);d.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=function(a,b){t=a;s=[];l="";m=0;for(var c,f=0,e=a.length;f<e;f++)u=t.charAt(f)," "===u&&(lastIndexOfWhite=f),l+=u,Math.round(this.ctx.measureText(l).width)>b&&(c=a.substring(m,f+1)," "!==u&&(-1===c.indexOf(" ")?(lastIndexOfWhite=f,f--):
f=lastIndexOfWhite),s.push(a.substring(m,lastIndexOfWhite)),l="",m=f+1);s.push(a.substring(m));return s};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,h,g,b,c,n,f,p,e,q,r,k,t,s,l;a.Image=function(b,c){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);a.Image.prototype.update=function(){h=this.evaluator;g=h.evalExpression(this.expresion);
this.exprX=g[0][0];this.exprY=g[0][1];this.rotateExp&&(b=a.degToRad(h.evalExpression(this.rotateExp)),c=Math.cos(b),n=Math.sin(b),f=this.exprX*c-this.exprY*n,p=this.exprX*n+this.exprY*c,this.exprX=f,this.exprY=p);4==g[0].length&&(this.centered=!0,this.scaleX=g[0][2],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=g[0][3],0==this.scaleY&&(this.scaleY=1E-5));g[1]&&2==g[1].length&&(this.centered=!0,this.scaleX=g[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=g[1][1],0==this.scaleY&&(this.scaleY=
1E-5));if((e=h.evalExpression(this.file))||""==e)this.img=this.parent.getImage(e)};a.Image.prototype.draw=function(){this.uber.draw.call(this)};a.Image.prototype.drawTrace=function(){this.uber.drawTrace.call(this)};a.Image.prototype.drawAux=function(b){h=this.evaluator;q=this.space;this.img&&this.img.ready&&this.img.complete&&(r=this.centered?0:this.img.width/2,k=this.centered?0:this.img.height/2,t=this.abs_coord?d(this.exprX):d(q.getAbsoluteX(this.exprX)),s=this.abs_coord?d(this.exprY):d(q.getAbsoluteY(this.exprY)),
l=a.degToRad(-h.evalExpression(this.inirot)),b.translate(t+r,s+k),b.rotate(l),b.scale(this.scaleX,this.scaleY),this.opacity&&(b.globalAlpha=h.evalExpression(this.opacity)),b.drawImage(this.img,-this.img.width/2,-this.img.height/2),b.setTransform(1,0,0,1,0,0),b.globalAlpha=1)};return a}(descartesJS||{}),descartesJS=function(a){function d(a,b,c){p=4*(b+c*a.width);return{r:a.data[p],g:a.data[p+1],b:a.data[p+2],a:a.data[p+3]}}if(a.loadLib)return a;var h,g,b,c,n,f,p;a.Fill=function(b,c){a.Graphic.call(this,
b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){h=this.evaluator.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Fill.prototype.drawTrace=function(){};a.Fill.prototype.drawAux=function(a,h){h.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(g=parseInt(this.exprX),b=parseInt(this.exprY)):(g=parseInt(this.space.getAbsoluteX(this.exprX)),
b=parseInt(this.space.getAbsoluteY(this.exprY)));if(!(0>g||0>b||g>=this.space.w||b>=this.space.h)){c=[{x:g,y:b}];for(f=d(imageData,g,b);0<c.length;){n=c.pop();g=n.x;b=n.y;var r=d(imageData,g,b);if(f.r===r.r&&f.g===r.g&&f.b===r.b&&f.a===r.a){var r=imageData,k=h;p=4*(g+b*r.width);r.data[p+0]=k.r;r.data[p+1]=k.g;r.data[p+2]=k.b;r.data[p+3]=255-k.a;0<g&&c.push({x:g-1,y:b});g<imageData.width-1&&c.push({x:g+1,y:b});c.push({x:g,y:b-1});c.push({x:g,y:b+1})}}this.ctx.putImageData(imageData,0,0)}};return a}(descartesJS||
{}),descartesJS=function(a,d){if(a.loadLib)return a;var h=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,g;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 g in c)c.hasOwnProperty(g)&&(this[g]=c[g]);this.graphics=[];g=b.lessonParser;var f=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 p=this.evaluator.evalExpression(this.expresion),e;p&&((e=document.getElementById(p))&&"descartes/macro"==e.type?e=e.text:(e=a.openExternalFile(p))&&!e.match(/tipo_de_macro/g)&&(e=null));var q,r;if(e){r=e.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");e=[];for(var p=0,k=r.length;p<k;p++)if(q=r[p].indexOf("="),-1!==q){q=g.split(r[p]);for(var t=0,s=q.length;t<s;t++)q[t]&&1<q.length&&("id"!==d[q[t][0]]&&"type"!==d[q[t][0]]||e.push(q))}for(var l,u,p=0,k=e.length;p<k;p++)for(s=(t=e[p]||[])&&t[0]&&"id"===t[0][0],r=0,q=t.length;r<q;r++)if(l=t[r][0].indexOf("."),-1===l||s?l=d[t[r][0]]:(l=d[t[r][0].substring(l+1)],t[r][0]=
this.name+"."+t[r][0]),!("font"===l||("fill"===l||"color"===l||"arrow"===l)&&"("!==t[r][1].charAt(0)||"file"===l&&t[r][1].match(h)||"id"!==l&&void 0!==d[t[r][1]]))if("text"==l)if(t[r][1].match(/\{\\rtf1/)){l=t[r][1];var m=this;u=function(a,b){for(var c=f.tokenize(b.replace(/\&squot;/g,"'")),e=0,d=c.length;e<d;e++)"identifier"!=c[e].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[e].value+"-")||(c[e].value=m.name+"."+c[e].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+f.flatTokens(c)};l=l.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,u);l=l.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,u);t[r][1]=l}else{u=g.parseText(t[r][1]).textElementsMacros;for(var v=0,w=u.length;v<w;v++){l=f.tokenize(u[v].replace(/\&squot;/g,"'"));for(var y=0,C=l.length;y<C;y++)"identifier"!==l[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("-"+
l[y].value+"-")||(l[y].value=this.name+"."+l[y].value);l=f.flatTokens(l).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");u[v]=l.substring(1,l.length-1)}t[r][1]=u.join("")}else{u=t[r][1].replace(/\&squot;/g,"'").split(";");v=0;for(w=u.length;v<w;v++){l=f.tokenize(u[v]);y=0;for(C=l.length;y<C;y++)"identifier"!==l[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("-"+
l[y].value+"-")||(l[y].value=this.name+"."+l[y].value);u[v]=f.flatTokens(l)}t[r][1]=u.join(";")}p=0;for(k=e.length;p<k;p++)if(e[p][0]){t="";s=!1;r=0;for(q=e[p].length;r<q;r++)"type"===d[e[p][r][0]]&&(t="espacio='"+this.spaceID+"' ",s=!0),t=t+e[p][r][0]+"='"+e[p][r][1]+"' ";e[p]=t;s?this.graphics.push(g.parseGraphic(e[p],this.abs_coord,this.background,this.inirot)):g.parseAuxiliar(e[p])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){g=this.evaluator.evalExpression(this.inipos);
this.iniPosX=g[0][0];this.iniPosY=g[0][1]};a.Macro.prototype.drawAux=function(a){for(var c=0,d=this.graphics.length;c<d;c++)this.graphics[c]&&(this.graphics[c].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale),this.graphics[c].draw(),a.setTransform(1,0,0,1,0,0))};return a}(descartesJS||{},babel),descartesJS=function(a){if(a.loadLib)return a;var d=Math.sqrt,h=Math.sin,g=Math.cos,b,c,n,f,p,e,q,r,k,t,s,l,u,m,v;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,f){this.x=a||0;this.y=b||0;this.z=c||0;this.w=f||0};a.Matrix4x4=function(a,b,c,f,e,d,g,h,p,l,m,r,q,n,k,t){this.a00=a||0;this.a01=b||0;this.a02=c||0;this.a03=f||0;this.a10=e||0;this.a11=d||0;this.a12=g||0;this.a13=h||0;this.a20=p||0;this.a21=l||0;this.a22=m||0;this.a23=r||0;this.a30=q||0;this.a31=n||0;this.a32=k||0;this.a33=t||0};a.Matrix4x4.prototype.setIdentity=
function(){this.a00=1;this.a10=this.a03=this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a13=this.a12=0;this.a22=1;this.a32=this.a31=this.a30=this.a23=0;this.a33=1;return this};a.Matrix4x4.prototype.multiplyVector4=function(b){return new a.Vector4D(b.x*this.a00+b.y*this.a10+b.z*this.a20+b.w*this.a30,b.x*this.a01+b.y*this.a11+b.z*this.a21+b.w*this.a31,b.x*this.a02+b.y*this.a12+b.z*this.a22+b.w*this.a32,b.x*this.a03+b.y*this.a13+b.z*this.a23+b.w*this.a33)};a.Matrix4x4.prototype.translate=function(b){return new a.Matrix4x4(this.a00,
this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a00*b.x+this.a10*b.y+this.a20*b.z+this.a30,this.a01*b.x+this.a11*b.y+this.a21*b.z+this.a31,this.a02*b.x+this.a12*b.y+this.a22*b.z+this.a32,this.a03*b.x+this.a13*b.y+this.a23*b.z+this.a33)};a.Matrix4x4.prototype.rotateX=function(b){c=h(b);n=g(b);r=this.a10;k=this.a11;t=this.a12;s=this.a13;l=this.a20;u=this.a21;m=this.a22;v=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,r*n+l*
c,k*n+u*c,t*n+m*c,s*n+v*c,r*-c+l*n,k*-c+u*n,t*-c+m*n,s*-c+v*n,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){c=h(b);n=g(b);f=this.a00;p=this.a01;e=this.a02;q=this.a03;l=this.a20;u=this.a21;m=this.a22;v=this.a23;return new a.Matrix4x4(f*n+l*-c,p*n+u*-c,e*n+m*-c,q*n+v*-c,this.a10,this.a11,this.a12,this.a13,f*c+l*n,p*c+u*n,e*c+m*n,q*c+v*n,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(b){c=h(b);n=g(b);f=this.a00;p=this.a01;e=this.a02;q=this.a03;
r=this.a10;k=this.a11;t=this.a12;s=this.a13;return new a.Matrix4x4(f*n+r*c,p*n+k*c,e*n+t*c,q*n+s*c,f*-c+r*n,p*-c+k*n,e*-c+t*n,q*-c+s*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){0!==parseInt(this.size)&&(a.lineWidth=1,a.fillStyle=this.backColor,a.strokeStyle=this.frontColor,a.beginPath(),a.arc(this.newV[0].x,this.newV[0].y,this.size+0.5,0,n),a.fill(),a.stroke())}function h(a,b){a.lineCap=f;a.lineJoin=p;
a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);for(var c=1,e=this.newV.length;c<e;c++)a.lineTo(this.newV[c].x,this.newV[c].y);a.closePath();"color"===this.model?(a.fillStyle=0<=this.direction?this.backColor:this.frontColor,a.fill()):"light"===this.model||"metal"===this.model?(a.fillStyle=0<=this.direction?b.computeColor(this.backColor,this,"metal"===this.model):b.computeColor(this.frontColor,this,"metal"===this.model),a.fill()):"wire"===this.model&&(a.lineWidth=1.25,a.strokeStyle=this.frontColor,
a.stroke());this.edges&&"wire"!==this.model&&(a.lineWidth=1,a.strokeStyle="#808080",a.stroke())}function g(a){s=this.evaluator.getVariable(this.family);this.evaluator.setVariable(this.family,this.familyValue);this.drawText(a,this.text,this.newV[0].x,this.newV[0].y+this.displace,this.frontColor,this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,s)}function b(a){a.lineCap=f;a.lineJoin=p;a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor;a.beginPath();
a.moveTo(this.newV[0].x,this.newV[0].y);a.lineTo(this.newV[1].x,this.newV[1].y);a.stroke()}function c(b,c,f){e=a.subtract3D(b,c);q=a.subtract3D(b,f);return a.normalize3D(a.crossProduct3D(e,q))}if(a.loadLib)return a;var n=2*Math.PI,f="round",p="round",e,q,r,k,t,s;a.Primitive3D=function(a,f){this.space=f;for(var e in a)a.hasOwnProperty(e)&&(this[e]=a[e]);this.newV=[];this.spaceVertices=[];"vertex"===this.type?this.draw=d:"face"===this.type?(this.normal=c(this.vertices[0],this.vertices[1],this.vertices[2]),
this.draw=h):"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,this.draw=g):"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 f=0,e=this.vertices.length;f<e;f++)this.newV[f]=
b.rotateVertex(this.vertices[f]),this.spaceVertices[f]=b.rotateVertex(this.vertices[f]),this.average.x+=this.newV[f].x,this.average.y+=this.newV[f].y,this.average.z+=this.newV[f].z;this.average=a.scalarProduct3D(this.average,1/e);this.averageP=b.project(this.average);this.depth=this.averageP.z;2<this.vertices.length&&(this.normal=c(this.newV[0],this.newV[1],this.newV[2]),this.direction=a.dotProduct3D(this.normal,a.normalize3D(b.eye)));f=0;for(e=this.vertices.length;f<e;f++)this.newV[f]=b.project(this.newV[f])};
var l;a.Primitive3D.prototype.removeDoubles=function(){if("edge"!==this.type){l=[];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||l.push(this.vertices[a]);0===l.length&&l.push(this.vertices[0]);this.vertices=l}};a.Primitive3D.prototype.drawText=function(b,c,f,e,d,g,h,p,l,q,n){if("rtfNode"==c.type)b.fillStyle=d,b.strokeStyle=
d,b.textBaseline="alphabetic",c.draw(b,f,e,l,q,h,n);else for("simpleText"===c.type&&(c=c.toString(l,q).split("\\n")),f+=g.match("Arial")?-2:g.match("Times")?-2:0,r=this.evaluator,b.fillStyle=a.getColor(r,d),b.font=g,b.textAlign=h,b.textBaseline=p,k=1.2*this.fontSize||0,d=0,g=c.length;d<g;d++)t=c[d],this.border&&b.strokeText(t,f,e+k*d),b.fillText(t,f,e+k*d)};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){for(var c=null,f=null,e=0,d=0,g=0,h=b.vertices.length;g<h;g++){var l=this.intersection(b.vertices[g],
b.vertices[(g+1)%h]);if(null!==l)if(null===c){if(c=l,e=g,2===b.vertices.length){f=c;break}}else if(!a.equals3DEpsilon(l,c,1E-8)){f=l;d=g;break}}if(null!==c&&null!==f){var g=this.isInterior(c)||this.isInterior(f),p=null,r=null;if(!g&&3<=b.vertices.length)for(var h=0,q=this.vertices.length;h<q;h++)if(l=b.intersection(this.vertices[h],this.vertices[(h+1)%q]),null!==l)if(null===p)p=l;else if(!a.equals3DEpsilon(l,p,1E-8)){r=l;break}if(g||null!==p&&null!==r&&b.isInterior(p)&&b.isInterior(r)){r=!0;q=b.vertices;
p=l=null;if(2===q.length)a.equals(c,q[0],1E-8)||a.equals(c,q[1],1E-8)?r=!1:(l=[],l[0]=q[0],l[1]=c,p=[],p[0]=c,p[1]=q[1]);else for(var l=[],p=[],n=0,g=h=0;g<q.length;g++)g<e?l[n++]=q[g]:g==e?(l[n++]=q[g],l[n++]=c,p[h++]=c):g<d?p[h++]=q[g]:g==d?(p[h++]=q[g],p[h++]=f,l[n++]=f):l[n++]=q[g];if(r)return c=[],c[0]=new a.Primitive3D({vertices:l,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:p,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),f=a.dotProduct3D(this.vertices[0],b.normal);if(1E-8>Math.abs(c-f))return!0;for(var e=1,d=this.vertices.length;e<d;e++){var g=a.dotProduct3D(this.vertices[e],b.normal);if(1E-8>Math.abs(c-
g)||g>c&&f<c||g<c&&f>c)return!0}return!1};a.Primitive3D.prototype.intersection=function(b,c){if(0<this.vertices.length){var f=a.subtract3D(c,b),e=a.dotProduct3D(f,this.normal);if(0!==e&&(e=a.dotProduct3D(a.subtract3D(this.vertices[0],b),this.normal)/e,-1E-8<e&&1.00000001>e))return a.add3D(b,a.scalarProduct3D(f,e))}return null};a.Primitive3D.prototype.isInterior=function(b){if(0<this.vertices.length)for(var c=0,f=a.subtract3D(this.vertices[0],b),e=0,d=this.vertices.length;e<d;e++){var g=a.subtract3D(this.vertices[(e+
1)%d],b),h=a.dotProduct3D(a.crossProduct3D(f,g),this.normal);if(1E-8>Math.abs(h)){if(0>a.dotProduct3D(f,g))break}else{if(0>c&&0<h||0<c&&0>h)return!1;f=g;c=h}}return!0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d={x:0,y:0,z:0},h,g,b,c,n,f,p,e;a.Graphic3D=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=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=f.parse("1");this.abs_coord=!1;this.family="";this.family_interval=f.parse("[0,1]");this.family_steps=f.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=f.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=f.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=f.parse("(0,0,0)");this.model="color";for(var e in c)c.hasOwnProperty(e)&&(this[e]=c[e]);void 0==this.expresion&&"macro"!=
this.type&&(this.expresion=f.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.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=
f.parse(this.inirot);this.endrot=f.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,f=a.length;c<f;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};
a.Graphic3D.prototype.getFamilyValues=function(){h=this.evaluator;g=h.evalExpression(this.family_interval);this.familyInf=g[0][0];this.familySup=g[0][1];this.fSteps=Math.round(h.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){h=this.evaluator;this.getFamilyValues();b=h.getVariable(this.family);if(0<=this.fSteps)for(var a=0,c=this.fSteps;a<=c;a++)h.setVariable(this.family,this.familyInf+
a*this.family_sep),this.familyValue=this.familyInf+a*this.family_sep,h.evalExpression(this.drawif)&&this.buildPrimitives();h.setVariable(this.family,b)};a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.evalExpression(this.drawif)&&(this.family||this.buildPrimitives());this.family&&this.buildFamilyPrimitives()};a.Graphic3D.prototype.updateMVMatrix=function(){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("=");f=n[0];p=[];for(var a=1;a<n.length;a++)f+="=",e=n[a].lastIndexOf(" "),f+=-1!==e?n[a].substring(0,e):n[a],p.push(this.evaluator.parser.parse(f,!0)),f=n[a].substring(e+1);return p};var q;a.Graphic3D.prototype.splitFace=function(a){for(var b=0,c=this.primitives.length;b<c;b++)if(q=[],"face"===this.primitives[b].type){for(var f=0,e=a.primitives.length;f<
e;f++)"face"===a.primitives[f].type?q=q.concat(this.primitives[b].splitFace(a.primitives[f])):q.push(a.primitives[f]);a.primitives=q}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c;a.Point3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){d=this.evaluator;this.updateMVMatrix();h=d.evalExpression(this.expresion);g=h[0][0];b=h[0][1];c=h[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(g,
b,c,1))],type:"vertex",backColor:this.backcolor.getColor(),frontColor:this.color.getColor(),size:d.evalExpression(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(g,b,c,1))],type:"text",frontColor:this.color.getColor(),font:this.font,decimals:d.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize,evaluator:d,text:this.text,family:this.family,familyValue:this.familyValue},this.space))};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f;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();f=evaluator.getVariable("u");evaluator.setVariable("u",this.Nu);expr=evaluator.evalExpression(this.expresion);d=expr[0][0];h=expr[0][1];g=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,
h,g,1)),this.transformVertex(new a.Vector4D(b,c,n,1))],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.evalExpression(this.width)},this.space));evaluator.setVariable("u",f)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f;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();g=d.getVariable("x");g=d.getVariable("y");g=d.getVariable("z");h=d.getVariable("u");g=d.getVariable("v");d.setVariable("u",0);d.setVariable("v",0);b=d.evalExpression(this.Nu);c=d.evalExpression(this.Nv);n=[];for(var p=0;p<=b;p++){d.setVariable("u",p/b);for(var e=0;e<=c;e++){d.setVariable("v",e/c);for(var q=0,r=this.expresion.length;q<r;q++)d.evalExpression(this.expresion[q]);n.push(this.transformVertex(new a.Vector4D(d.getVariable("x"),
d.getVariable("y"),d.getVariable("z"),1)))}}for(p=0;p<b;p++)for(e=0;e<c;e++)f=[],f.push(n[e+p*c+p]),f.push(n[e+1+p*c+p]),f.push(n[e+2+(p+1)*c+p]),f.push(n[e+1+(p+1)*c+p]),this.primitives.push(new a.Primitive3D({vertices:f,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space));d.setVariable("x",void 0);d.setVariable("y",void 0);d.setVariable("z",void 0);d.setVariable("u",h);d.setVariable("v",g)};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var d,h,g,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 f=0,p=expr.length-1;f<p;f++)d=expr[f][0],h=expr[f][1],g=expr[f][2],b=expr[f+1][0],c=expr[f+1][1],n=expr[f+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,
h,g,1)),this.transformVertex(new a.Vector4D(b,c,n,1))],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.evalExpression(this.width)},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,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");g=evaluator.getVariable("u");evaluator.setVariable("u",0);h=evaluator.evalExpression(this.Nu);d=[];for(var f=0;f<=h;f++){evaluator.setVariable("u",f/h);for(var p=0,e=this.expresion.length;p<e;p++)evaluator.evalExpression(this.expresion[p]);d.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}f=0;for(p=d.length-1;f<p;f++)this.primitives.push(new a.Primitive3D({vertices:[d[f],
d[f+1]],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.evalExpression(this.width)},this.space));evaluator.setVariable("x",b);evaluator.setVariable("y",n);evaluator.setVariable("z",c);evaluator.setVariable("u",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f,p,e;a.Triangle3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();
expr=evaluator.evalExpression(this.expresion);d=expr[0][0];h=expr[0][1];g=expr[0][2];b=expr[1][0];c=expr[1][1];n=expr[1][2];f=expr[2][0];p=expr[2][1];e=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,h,g,1)),this.transformVertex(new a.Vector4D(f,p,e,1)),this.transformVertex(new a.Vector4D(b,c,n,1))],type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.Face3D=function(d,g){a.Graphic3D.call(this,d,g)};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);d=[];for(var h=expr.length-1;0<=h;h--)d.push(this.transformVertex(new a.Vector4D(expr[h][0],expr[h][1],expr[h][2],1)));this.primitives.push(new a.Primitive3D({vertices:d,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),
edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c;a.Polireg3D=function(b,c){this.width=b.evaluator.parser.parse("2");this.length=b.evaluator.parser.parse("2");a.Graphic3D.call(this,b,c)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();d=evaluator.evalExpression(this.Nu);h=[this.transformVertex(new a.Vector4D(0,0,0,1))];g=evaluator.evalExpression(this.width)/
2;b=evaluator.evalExpression(this.length)/2;c=2*Math.PI/d;for(var n=0;n<d;n++)h.push(this.transformVertex(new a.Vector4D(g*Math.cos(c*n),b*Math.sin(c*n),0,1)));for(n=0;n<d;n++)this.primitives.push(new a.Primitive3D({vertices:[h[0],n+2<=d?h[n+2]:h[1],h[n+1]],type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b;a.Text3D=function(b,d){a.Graphic3D.call(this,
b,d)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=function(){d=this.evaluator;h=d.evalExpression(this.expresion);g=h[0][0];b=h[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(g,b,0,1)],type:"text",frontColor:this.color.getColor(),font:this.font,decimals:d.evalExpression(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:d,text:this.text,family:this.family,familyValue:this.familyValue,joel:"hola"},this.space))};return a}(descartesJS||{}),descartesJS=
function(a,d){if(a.loadLib)return a;var h=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,g,b;a.Macro3D=function(b,g){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,g);for(var f in g)g.hasOwnProperty(f)&&(this[f]=g[f]);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=[];f=b.lessonParser;
var p=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 e=this.evaluator.evalExpression(this.expresion),q;e&&((q=document.getElementById(e))&&"descartes/macro"==q.type?q=q.text:(q=a.openExternalFile(e))&&!q.match(/tipo_de_macro/g)&&(q=null));var r,k;if(q){k=q.replace(/&aacute;/g,"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,
"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&amp;/g,"&").replace(/\r/g,"").split("\n");q=[];for(var e=0,t=k.length;e<t;e++)r=k[e].indexOf("="),-1!==r&&(r=k[e].substring(0,r),"id"!==d[r]&&"type"!==d[r]||q.push(f.split(k[e])));for(var s,l,u,m,e=0,t=q.length;e<t;e++)for(m=(s=
q[e]||[])&&s[0]&&"id"===s[0][0],k=0,r=s.length;k<r;k++)if(l=s[k][0].indexOf("."),-1===l||m?l=d[s[k][0]]:(l=d[s[k][0].substring(l+1)],s[k][0]=this.name+"."+s[k][0]),!("font"===l||("fill"===l||"color"===l||"arrow"===l)&&"("!==s[k][1].charAt(0)||"file"===l&&s[k][1].match(h)||"id"!==l&&void 0!==d[s[k][1]])||"width"===l||"height"===l||"length"===l)if("text"==l)if(s[k][1].match(/\{\\rtf1/)){l=s[k][1];var v=this;u=function(a,b){for(var c=p.tokenize(b.replace(/\&squot;/g,"'")),f=0,e=c.length;f<e;f++)"identifier"!=
c[f].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[f].value+"-")||(c[f].value=v.name+"."+c[f].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+p.flatTokens(c)};l=l.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,u);l=l.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,u);s[k][1]=l}else{u=f.parseText(s[k][1]).textElementsMacro3Ds;
for(var w=0,y=u.length;w<y;w++){l=p.tokenize(u[w].replace(/\&squot;/g,"'"));for(var C=0,B=l.length;C<B;C++)"identifier"!==l[C].type||"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+l[C].value+"-")||(l[C].value=this.name+"."+l[C].value);l=p.flatTokens(l).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");u[w]=l.substring(1,l.length-1)}s[k][1]=u.join("")}else{l=p.tokenize(s[k][1]);
u=0;for(w=l.length;u<w;u++)"identifier"!==l[u].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("-"+l[u].value+"-")||(l[u].value=this.name+"."+l[u].value);s[k][1]=p.flatTokens(l)}e=0;for(t=q.length;e<t;e++)if(q[e][0]){s="";m=!1;k=0;for(r=q[e].length;k<r;k++)"type"===d[q[e][k][0]]&&(s="espacio='"+this.spaceID+"' ",m=!0),s=s+q[e][k][0]+"='"+q[e][k][1]+"' ";q[e]=s;m?this.graphics.push(f.parse3DGraphic(q[e],
this.abs_coord,this.background,this.inirot)):f.parseAuxiliar(q[e])}}e=0;for(t=this.graphics.length;e<t;e++)this.graphics[e].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++)g=this.graphics[a],g.macro_inirotEuler=this.inirotEuler,g.macro_inirotM=this.inirotM,g.macro_inirotM_X=
this.inirotM_X,g.macro_inirotM_Y=this.inirotM_Y,g.macro_inirotM_Z=this.inirotM_Z,g.macro_iniposM=this.iniposM,g.macro_endrotEuler=this.endrotEuler,g.macro_endrotM=this.endrotM,g.macro_endrotM_X=this.endrotM_X,g.macro_endrotM_Y=this.endrotM_Y,g.macro_endrotM_Z=this.endrotM_Z,g.macro_endposM=this.endposM,g.update();a=0;for(d=this.graphics.length;a<d;a++){g=this.graphics[a];if(g.split||this.split)for(var f=a+1;f<d;f++)b=this.graphics[f],(b.split||this.split)&&g.splitFace(b);this.primitives=this.primitives.concat(g.primitives||
[])}};a.Macro3D.prototype.updateTransformation=function(){tmpExpr=this.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(tmpExpr[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(tmpExpr[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(tmpExpr[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(tmpExpr[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(tmpExpr[0][1])),
this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(tmpExpr[0][2])));tmpExpr=this.evaluator.evalExpression(this.inipos);translate={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.iniposM=this.iniposM.setIdentity().translate(translate);tmpExpr=this.evaluator.evalExpression(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(tmpExpr[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(tmpExpr[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(tmpExpr[0][2]))):
(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(tmpExpr[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(tmpExpr[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(tmpExpr[0][2])));tmpExpr=this.evaluator.evalExpression(this.endpos);translate={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.endposM=this.endposM.setIdentity().translate(translate)};a.Macro3D.prototype.drawAux=function(a){};return a}(descartesJS||{},babel),descartesJS=function(a){function d(a,
b,c,f,e){h.call(this,a/1.8,a/1.8,a/1.8,f,e)}function h(a,b,c,f,e){a/=2;b/=2;c/=2;this.changeGeometry(a,b,c,f,e)||(this.vertices=[new l(a,c,b,1),new l(a,-c,b,1),new l(a,c,-b,1),new l(a,-c,-b,1),new l(-a,c,b,1),new l(-a,-c,b,1),new l(-a,c,-b,1),new l(-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,f,e))}function g(a,b,c,f,e){a/=2;this.changeGeometry(a,b,c,f,e)||(this.vertices=[new l(0,0,a,1),new l(-0.49*a,-0.86*a,-0.32*a,1),new l(-0.49*a,
0.86*a,-0.32*a,1),new l(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,f,e))}function b(a,b,c,f,e){a/=2;this.changeGeometry(a,b,c,f,e)||(this.vertices=[new l(0,0,a,1),new l(a,0,0,1),new l(-a,0,0,1),new l(0,a,0,1),new l(0,-a,0,1),new l(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,f,e))}function c(b,c,f,e,d){b/=3.4;if(!this.changeGeometry(b,c,f,e,d)){F=b/D;A=b*D;this.vertices=[new l(b,b,b,1),new l(b,
b,-b,1),new l(b,-b,b,1),new l(b,-b,-b,1),new l(-b,b,b,1),new l(-b,b,-b,1),new l(-b,-b,b,1),new l(-b,-b,-b,1),new l(0,F,A,1),new l(0,F,-A,1),new l(0,-F,A,1),new l(0,-F,-A,1),new l(F,A,0,1),new l(F,-A,0,1),new l(-F,A,0,1),new l(-F,-A,0,1),new l(A,0,F,1),new l(A,0,-F,1),new l(-A,0,F,1),new l(-A,0,-F,1)];z=(new a.Matrix4x4).setIdentity().rotateY(-t/6);for(var g=0,h=this.vertices.length;g<h;g++)this.vertices[g]=z.multiplyVector4(this.vertices[g]);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,f,e,d)}}function n(b,c,f,e,d){b/=4;if(!this.changeGeometry(b,c,f,e,d)){A=b*D;this.vertices=[new l(0,b,A,1),new l(0,b,-A,1),new l(0,-b,A,1),new l(0,-b,-A,1),new l(b,A,0,1),new l(b,-A,0,1),new l(-b,A,0,1),new l(-b,-A,0,1),new l(A,0,b,1),new l(A,0,-b,1),new l(-A,0,b,1),new l(-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]];z=(new a.Matrix4x4).setIdentity().rotateY(-1.029);for(var g=0,h=this.vertices.length;g<h;g++)this.vertices[g]=z.multiplyVector4(this.vertices[g]);this.updateValues(b,c,f,e,d)}}function f(a,b,c,f,e){a/=2;this.isSphere?c=b=a:(b/=2,c/=2);if(!this.changeGeometry(a,b,c,f,e)){this.vertices=[new l(0,0,b,1)];for(var d=1;d<f;d++){B=d*t/f;for(var g=0;g<e;g++)C=g*s/e,v=a*r(B)*k(C),w=c*r(B)*
r(C),y=b*k(B),this.vertices.push(new l(v,w,y,1))}this.vertices.push(new l(0,0,-b,1));this.faces=[];for(d=0;d<e;d++)this.faces.push([0,(d+1)%e+1,d%e+1]);for(d=1;d<f-1;d++)for(g=0;g<e;g++)this.faces.push([g+1+(d-1)*e,(g+1)%e+1+(d-1)*e,(g+1)%e+1+d*e,g+1+d*e]);for(d=0;d<e;d++)this.faces.push([this.vertices.length-1,this.vertices.length-1-e+d,this.vertices.length-1-e+(d+1)%e]);this.updateValues(a,b,c,f,e)}}function p(a,b,c,f,e){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,e)){this.vertices=[];for(var d=
0;d<e;d++)for(var g=0;g<f;g++)v=a*(e-d)/e*k(g*s/f),w=c*(e-d)/e*r(g*s/f),y=b-2*d*b/e,this.vertices.push(new l(v,w,y,1));this.vertices.push(new l(0,0,-b,1));this.faces=[];for(d=0;d<e-1;d++)for(g=0;g<f;g++)this.faces.push([g+d*f,(g+1)%f+d*f,(g+1)%f+(d+1)*f,g+(d+1)*f]);for(d=0;d<f;d++)this.faces.push([this.vertices.length-1,this.vertices.length-1-f+d,this.vertices.length-1-f+(d+1)%f]);this.updateValues(a,b,c,f,e)}}function e(a,b,c,f,e){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,e)){this.vertices=
[];for(var d=0;d<e+1;d++)for(var g=0;g<f;g++)v=a*k(g*s/f),w=c*r(g*s/f),y=b-2*d*b/e,this.vertices.push(new l(v,w,y,1));this.faces=[];for(d=0;d<e;d++)for(g=0;g<f;g++)this.faces.push([g+d*f,(g+1)%f+d*f,(g+1)%f+(d+1)*f,g+(d+1)*f]);this.updateValues(a,b,c,f,e)}}function q(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];for(var c=0,f=this.fileData.length;c<f;c++)H=this.fileData[c],H.match(/^V\(/)?(G=H.substring(2,H.length-1).split(",").map(b),this.vertices.push(new l(G[0]||
0,G[1]||0,G[2]||0,1))):H.match(/^F\(/)&&(G=H.substring(2,H.length-1).split(",").map(a),this.faces.push(G.reverse()))}if(a.loadLib)return a;var r=Math.sin,k=Math.cos,t=Math.PI,s=2*t,l,u,m,v,w,y,C,B,D=1.6180339887,F,A,z,H,G;a.OtherGeometry=function(r,m){this.width=r.evaluator.parser.parse("2");this.height=r.evaluator.parser.parse("2");this.length=r.evaluator.parser.parse("2");l=a.Vector4D;a.Graphic3D.call(this,r,m);switch(this.type){case "cube":this.buildGeometry=d;break;case "box":this.buildGeometry=
h;break;case "tetrahedron":this.buildGeometry=g;break;case "octahedron":this.buildGeometry=b;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=f;break;case "dodecahedron":this.buildGeometry=c;break;case "icosahedron":this.buildGeometry=n;break;case "cone":this.buildGeometry=p;break;case "cylinder":this.buildGeometry=e;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=q}};a.extend(a.OtherGeometry,a.Graphic3D);
a.OtherGeometry.prototype.buildPrimitives=function(){u=this.evaluator;this.updateMVMatrix();this.buildGeometry(u.evalExpression(this.width),u.evalExpression(this.height),u.evalExpression(this.length),u.evalExpression(this.Nu),u.evalExpression(this.Nv));for(var b=0,c=this.faces.length;b<c;b++){m=[];for(var f=0,e=this.faces[b].length;f<e;f++)m.push(this.transformVertex(this.vertices[this.faces[b][f]]));this.primitives.push(new a.Primitive3D({vertices:m,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),
edges:this.edges,model:this.model},this.space))}};a.OtherGeometry.prototype.changeGeometry=function(a,b,c,f,e){return this.oldWidth===a&&this.oldHeight===b&&this.oldLength===c&&this.oldNu===f&&this.oldNv===e};a.OtherGeometry.prototype.updateValues=function(a,b,c,f,e){this.oldWidth=a;this.oldHeight=b;this.oldLength=c;this.oldNv=e;this.oldNu=f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.max,h=Math.min,g=Math.PI,b=Math.cos,c=Math.sin,n=Math.abs,f,p,e,q,r,k,t,
s,l,u,m,v,w,y,C,B,D,F;a.R2=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.set=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.copy=function(){return new a.R2(this.x,this.y)};a.R2.prototype.ix=function(){return Math.round(d(h(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(d(h(this.y,32E3),-32E3))};a.R2.prototype.equals=function(a){return this.x==a.x&&this.y==a.y};a.R2.prototype.norm2=function(){return this.x*this.x+this.y*this.y};a.R2.prototype.norm=function(){return Math.sqrt(this.norm2())};
a.R2.prototype.distance=function(a){p=this.copy();p.sub(a);return p.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(){f=this.norm();0!=f&&this.div(f)};a.R2.prototype.rotR90=
function(){f=this.x;this.x=this.y;this.y=-f};a.R2.prototype.rotL90=function(){f=this.x;this.x=-this.y;this.y=f};a.R2.prototype.rot=function(a){e=this.copy();k=b(a);t=c(a);this.x=e.x*k-e.y*t;this.y=e.x*t+e.y*k};a.R2.prototype.rot=function(a){this.rot(a*g/180)};a.R2.prototype.intersection=function(b,c,f,e){s=c.x-b.x;l=f.x-e.x;u=f.x-b.x;m=c.y-b.y;v=f.y-e.y;w=f.y-b.y;F=s*v-l*m;return 1E-6<n(F)?(q=(u*v-w*l)/F,r=(-u*m+w*s)/F,0<=q&&1>=q&&0<=r&&1>=r?new a.R2(b.x+s*q,b.y+m*q):null):(c.x-f.x)*w!=(c.y-f.y)*
u?null:b.x!=c.x?(y=h(b.x,c.x),C=d(b.x,c.x),y<=f.x&&f.x<=C?f:y<=e.x&&e.x<=C?e:null):f.x!=e.x?(B=h(f.x,e.x),D=d(f.x,e.x),B<=b.x&&b.x<=D?b:B<=c.x&&c.x<=D?c:null):b.y!=c.y?(y=h(b.y,c.y),C=d(b.y,c.y),y<=f.y&&f.y<=C?f:y<=e.y&&e.y<=C?e:null):f.y!=e.y?(B=h(f.y,e.y),D=d(f.y,e.y),B<=b.y&&b.y<=D?b:B<=c.y&&c.y<=D?c:null):b.x==f.x&&b.y==f.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f,p;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;f=d.getVariable("x");p=d.getVariable("y");d.setVariable("x",a.x);d.setVariable("y",a.y);this.f0=d.evalExpression(this.constraint);d.setVariable("x",d.getVariable("x")+1E-12);h=d.evalExpression(this.constraint);n.x=(h-this.f0)/1E-12;n.x=isNaN(n.x)?Infinity:n.x;d.setVariable("x",d.getVariable("x")-1E-12);d.setVariable("y",d.getVariable("y")+1E-12);h=d.evalExpression(this.constraint);n.y=(h-this.f0)/1E-12;n.y=isNaN(n.y)?Infinity:n.y;d.setVariable("x",f);d.setVariable("y",p);return n};
a.R2Newton.prototype.findZero=function(a){d=this.evaluator;c=a.copy();f=d.getVariable("x");p=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",f);d.setVariable("y",p);for(var h=0;256>h;h++)if(g=c.x,b=c.y,this.normal=this.gradient(c),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),c.x=g+this.normal.x,c.y=b+this.normal.y,1E-6>this.normal.norm()){0===
this.normal.x&&0===this.normal.y&&(this.normal.x=c.x-a.x,this.normal.y=c.y-a.y);break}return c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,h){this.x=a;this.y=h};a.Vector2D.AXIS_X=new a.Vector2D(1,0);a.Vector2D.AXIS_Y=new a.Vector2D(0,1);a.Vector2D.prototype.vectorLength=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.Vector2D.prototype.dotProduct=function(a){return this.x*a.x+this.y*a.y};a.Vector2D.prototype.angleBetweenVectors=function(a){return Math.acos(this.dotProduct(a)/
(this.vectorLength()*a.vectorLength()))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h=Math.round,g,b,c,n,f,p,e,q,r,k,t,s,l,u,m,v,w,y,C,B;a.Control=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=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=f.parse("(0,0,100,23)"):(this.expresion=f.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=f.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:f.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";
this.drawif=f.parse("1");this.activeif=f.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=f.parse("0");this.decimals=f.parse("2");this.min=f.parse("-Infinity");this.max=f.parse("Infinity");this.incr=f.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var e in c)c.hasOwnProperty(e)&&(this[e]=c[e]);"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;f=this.evaluator.evalExpression(this.expresion);this.x=h(f[0][0]);this.y=h(f[0][1]);4==f[0].length&&(this.w=h(f[0][2]),this.h=h(f[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,f=a.length;c<f;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=f=p=
!1;e=this.evaluator.evalExpression(this.expresion);q=h(e[0][0]);c=h(this.x)!==q;this.x=q;q=h(e[0][1]);n=h(this.y)!==q;this.y=q;4===e[0].length&&(q=h(e[0][2]),f=h(this.w)!==q,this.w=q,q=h(e[0][3]),p=h(this.h)!==q,this.h=q);if(f||p||c||n)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){l=this.parent;r=a+"";k=this.evaluator.evalExpression(this.decimals);t=r.indexOf(".");-1!=t&&(s=r.substring(t+1),s.length>k&&(r=parseFloat(r).toFixed(k)));this.fixed&&(2!==l.version||2===l.version&&
!this.exponentialif)&&(r=parseFloat(a).toFixed(k));this.exponentialif&&0!=parseFloat(r)&&(r=this.fixed&&2!==l.version?parseFloat(r).toExponential(k):parseFloat(r).toExponential(),r=r.toUpperCase(),r=r.replace("+",""));return r=r.replace(".",l.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);g=c*c;for(var f=0;f<c;f++)b=d(f-35*c/100),this.linearGradient.addColorStop(f/c,"rgba(0,0,0,"+b*b*192/g/255+")")};a.Control.prototype.getScreenshot=function(){v=this;u=document.createElement("canvas");u.setAttribute("width",v.w);u.setAttribute("height",v.h);m=u.getContext("2d");m.font=v.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";v.canvas&&(w=v.canvas.offsetLeft,y=v.canvas.offsetTop,m.drawImage(v.canvas,w,y));v.label&&(w=v.label.offsetLeft,y=
v.label.offsetTop,C=v.label.offsetWidth,B=v.label.offsetHeight,m.fillStyle="#e0e4e8",m.fillRect(w,y,C,B),m.fillStyle="black",m.textAlign="center",m.textBaseline="middle",m.fillText(v.name,w+C/2,y+B/2));v.field&&(w=v.field.offsetLeft,y=v.field.offsetTop,C=v.field.offsetWidth,B=v.field.offsetHeight,m.fillStyle="white",m.strokeStyle="#666666",m.lineWidth=1,m.fillRect(w,0,C,B),m.strokeRect(w+0.5,0.5,C-1,B-1),m.fillStyle="black",m.textAlign="center",m.textAlign="left",m.fillText(v.field.value,w+2,B/2));
v.select&&(w=v.select.offsetLeft,y=v.select.offsetTop,C=v.select.offsetWidth,B=v.select.offsetHeight,m.fillStyle="#e0e4e8",m.strokeStyle="#666666",m.lineWidth=1,m.fillRect(w,0,C,B),m.strokeRect(w+0.5,0.5,C,B-1),m.fillStyle="black",m.textAlign="center",m.textAlign="left",m.fillText(v.select.value,w+2,B/2),m.fillStyle="#c0c0c0",m.fillRect(w+C-15+0.5,0.5,15,B-1),m.strokeRect(w+C-15+0.5,0.5,15,B-1),m.fillStyle="black",m.beginPath(),m.moveTo(w+C-15+4.5,B/2-2.5),m.lineTo(w+C-15+8,B/2+2.5),m.lineTo(w+C-
15+11.5,B/2-2.5),m.closePath(),m.fill());return u};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h,g,b,c,n,f,p,e,q,r,k,t,s=2E3,l=/[\w\.\-//]*(\.gif)/gi;a.Button=function(b,c){this.imageSrc="";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;a.Control.call(this,b,c);-1===this.font_size&&(this.fontSizeNotSet=!0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-
1)):this.name=this.parser.parse("'"+this.name+"'");var f;this.imageSrc.match("_COLORES_")&&(f=this.imageSrc.split("_"),this.colorInt=new a.Color(f[2]),this.color=new a.Color(f[3]),this.font_size=this.parser.parse(f[5]),this.imageSrc="");this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");f=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=f){var e=f.substr(0,f.lastIndexOf(".")),d=f.substr(f.lastIndexOf("."));f.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(f),this.imageOver=this.parent.getImage(e+"_over"+d),this.imageDown=this.parent.getImage(e+"_down"+d))}this.canvas=document.createElement("canvas");this.canvas.setAttribute("class","DescartesButton");this.canvas.setAttribute("id",this.id);this.canvas.setAttribute("width",this.w+"px");this.canvas.setAttribute("height",this.h+"px");
this.canvas.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.ctx.mozImageSmoothingEnabled=!1;this.ctx.webkitImageSmoothingEnabled=!1;this.addControlContainer(this.canvas);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=function(){h=this.evaluator;g=this.canvas;c=h.evalExpression(this.expresion);this.x=c[0][0];this.y=c[0][1];4==c[0].length&&
(this.w=parseInt(c[0][2]),this.h=parseInt(c[0][3]));g.setAttribute("width",this.w+"px");g.setAttribute("height",this.h+"px");g.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+"; display: block; background-repeat: no-repeat;");this.fontSizeNotSet&&(this.font_size=h.parser.parse(a.getFieldFontSize(this.h)+""));this.createGradient(this.w,this.h);g.style.display=0<h.evalExpression(this.drawif)?"block":"none"};a.Button.prototype.update=function(){h=this.evaluator;g=
this.canvas;this.activeIfValue=0<h.evalExpression(this.activeif);(this.drawIfValue=0<h.evalExpression(this.drawif))?(g.style.display="block",this.draw()):g.style.display="none";g.style.cursor=this.activeIfValue?"pointer":"not-allowed";this.updatePositionAndSize()};a.Button.prototype.draw=function(){h=this.evaluator;b=this.ctx;n=h.evalExpression(this.font_size);f=h.evalExpression(this.name);p=h.evalExpression(this.imageSrc);e="vacio.gif"===p?this.emptyImage:this.parent.getImage(p);b.clearRect(0,0,
this.w,this.h);r=q=0;this.buttonClick&&(r=q=1);e&&e.ready?e!==this.emptyImage&&e.complete&&(this.image.src.match(l)?(this.canvas.style.backgroundImage="url("+this.image.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-e.width)/2)+q+"px "+(parseInt((this.h-e.height)/2)+r)+"px"):b.drawImage(e,parseInt((this.w-e.width)/2)+q,parseInt((this.h-e.height)/2)+r)):(b.fillStyle=this.colorInt.getColor(),b.fillRect(0,0,this.w,this.h),this.buttonClick||(a.drawLine(b,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,"+
128/255+")"),a.drawLine(b,0,0,0,this.h,"rgba(0,0,0,"+24/255+")"),a.drawLine(b,1,0,1,this.h,"rgba(0,0,0,"+8/255+")")),b.fillStyle=this.linearGradient,b.fillRect(0,0,this.w,this.h));this.activeIfValue&&""!=this.imageOver.src&&this.imageOver.ready&&this.over&&(this.image.src.match(l)?(this.canvas.style.backgroundImage="url("+this.imageOver.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-e.width)/2)+q+"px "+(parseInt((this.h-e.height)/2)+r)+"px"):b.drawImage(this.imageOver,parseInt((this.w-
e.width)/2)+q,parseInt((this.h-e.height)/2)+r));this.activeIfValue&&""!=this.imageDown.src&&this.imageDown.ready&&this.buttonClick?this.image.src.match(l)?(this.canvas.style.backgroundImage="url("+this.imageDown.src+")",this.canvas.style.backgroundPosition=parseInt((this.w-e.width)/2)+q+"px "+(parseInt((this.h-e.height)/2)+r)+"px"):b.drawImage(this.imageDown,parseInt((this.w-e.width)/2)+q,parseInt((this.h-e.height)/2)+r):this.buttonClick&&!e&&(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(f,d(this.w/2+q)+0.5,d(this.h/2+r)+0.5));b.fillText(f,d(this.w/2+q)+0.5,d(this.h/2+r)+0.5);this.underlined&&(k=b.measureText(f).width,b.strokeStyle=
this.color.getColor(),b.lineWidth=d(n/10)||2,b.lineCap="round",b.beginPath(),b.moveTo(parseInt((this.w-k)/2)+q,d((this.h+n)/2)+d(n/5)-1.5+r),b.lineTo(parseInt((this.w+k)/2)+q,d((this.h+n)/2)+d(n/5)-1.5+r),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,f){clearInterval(h);g.buttonClick&&g.drawIfValue&&
g.activeIfValue&&(c.call(g),a=f?a:100,h=setTimeout(function(){b(a,c)},a))}function c(e){document.body.focus();e.preventDefault();e.stopPropagation();document.activeElement!=document.body&&document.activeElement.blur();g.whichButton=a.whichButton(e);"L"==g.whichButton&&g.activeIfValue&&(g.buttonClick=!0,g.draw(),g.evaluator.setVariable(g.id,g.evaluator.evalExpression(g.valueExpr)),"calculate"==g.action&&b(s,g.bottonPressed,!0),t?(g.canvas.removeEventListener("touchend",f),g.canvas.addEventListener("touchend",
f)):(g.canvas.removeEventListener("mouseup",f),g.canvas.addEventListener("mouseup",f)))}function f(a){document.body.focus();if(g.activeIfValue||g.buttonClick)g.buttonClick=!1,g.draw(),"calculate"!=g.action&&g.bottonPressed(),a.preventDefault(),a.stopPropagation(),t?g.canvas.removeEventListener("touchend",f):g.canvas.removeEventListener("mouseup",f)}function e(a){g.over=!0;g.draw()}function d(a){g.over=!1;g.buttonClick=!1;g.draw()}t=a.hasTouchSupport;var g=this,h;g.canvas.oncontextmenu=function(){return!1};
this.over=this.buttonClick=!1;t?this.canvas.addEventListener("touchstart",c):(this.canvas.addEventListener("mousedown",c),this.canvas.addEventListener("mouseover",e),this.canvas.addEventListener("mouseout",d))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f,p,e,q,r,k,t,s,l,u,m,v;a.Spinner=function(b,c){a.Control.call(this,b,c);this.tabindex=++this.parent.tabindex;"["===this.name.charAt(0)&&
"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);
this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.addControlContainer(this.containerControl);v=this.evaluator.parser.parse("1");this.originalIncr=this.incr;if(0>=this.evaluator.evalExpression(this.decimals)||0==this.evaluator.evalExpression(this.incr)){var f=this.evaluator.evalExpression(this.incr);0<f?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(f).toString()):this.incr=v}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 f=2!==this.parent.version?"":"_____",e=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),g=2+parseInt(this.h/2),h=parseInt(this.w/2-g/2),f=a.getTextWidth(b+
f,this.fieldFontSize+"px Arial");this.visible||(h=this.w-g,e=0);h<f&&(h=f);""==b&&(h=0);this.w-h-g<e&&(h=this.w-g-e);0>h&&(h=0);b=this.w-(h+g);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",g+"px");this.canvas.setAttribute("height",this.h+"px");
this.canvas.setAttribute("style","position: absolute; left: "+h+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.divUp.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+g+"px; height : "+this.h/2+"px; left: "+h+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+g+"px; height : "+this.h/2+"px; left: "+h+"px; top: "+this.h/2+"px;");this.field.setAttribute("type",
"text");this.field.setAttribute("id",this.id+"_spinner");this.field.setAttribute("class","DescartesSpinnerField");this.field.setAttribute("style","font-family: Arial; font-size: "+this.fieldFontSize+"px; width : "+b+"px; height : "+this.h+"px; left: "+(g+h)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+h+"px; height: "+this.h+"px; line-height: "+
this.h+"px;");d.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){d=this.evaluator;this.label.innerHTML=d.evalExpression(this.name).toString();0>=d.evalExpression(this.decimals)?(h=d.evalExpression(this.incr),0<h?this.originalIncr=this.incr=d.parser.parse(parseInt(h).toString()):this.incr=v):this.incr=0!=d.evalExpression(this.originalIncr)?this.originalIncr:v;this.activeIfValue=0<d.evalExpression(this.activeif);this.drawIfValue=0<d.evalExpression(this.drawif);
this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();this.parent.animation.playing&&document.activeElement==this.field||(g=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!=g&&(this.value=this.validateValue(g),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;f=this.canvas.height;c.fillStyle="#f0f8ff";c.fillRect(0,0,n,f);c.fillStyle=this.linearGradient;c.fillRect(0,0,n,f);this.up?(p="gray",e="#f0f8ff"):(p="#f0f8ff",e="gray");a.drawLine(c,0,0,n,0,p);a.drawLine(c,0,0,0,f/2,p);a.drawLine(c,0,f/2,n,f/2,e);this.down?(p="gray",e="#f0f8ff"):(p="#f0f8ff",e="gray");a.drawLine(c,0,f/2+1,n,f/2+1,p);a.drawLine(c,0,f/2+1,0,f,p);a.drawLine(c,0,f-1,n,f-1,e);q=[parseInt(n/
2+1),parseInt(n/5+1),parseInt(n-n/5+1)];r=[parseInt(f/8+1),parseInt(f/8+1+f/4),parseInt(f/8+1+f/4)];c.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";c.beginPath();c.moveTo(q[0],r[0]);c.lineTo(q[1],r[1]);c.lineTo(q[2],r[2]);c.fill();r=[parseInt(f-f/8),parseInt(f-f/8-f/4),parseInt(f-f/8-f/4)];c.fillStyle=this.activeIfValue?"#d00018":"#aa8888";c.beginPath();c.moveTo(q[0],r[0]);c.lineTo(q[1],r[1]);c.lineTo(q[2],r[2]);c.fill();c.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&c.fillRect(0,0,n,f/2);this.down&&
c.fillRect(0,f/2,n,f)};a.Spinner.prototype.validateValue=function(a){d=this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=a.toString();k=parseFloat(d.evalExpression(d.parser.parse(a.replace(this.parent.decimal_symbol,"."))));isNaN(k)&&(k=0);l=d.evalExpression(this.min);u=d.evalExpression(this.max);""===l&&(l=-Infinity);""===u&&(u=Infinity);k<l&&(k=l);k>u&&(k=u);this.discrete&&(t=d.evalExpression(this.incr),k=0==t?0:t*Math.round(k/t));s=d.evalExpression(this.decimals);
0>=s&&(s=0);return k=parseFloat(parseFloat(k).toFixed(s))};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,f){clearInterval(q);if(l.up||l.down)c.call(l),a=f?a:30,q=setTimeout(function(){b(a,c)},a)}function c(f){f.preventDefault();l.whichButton=a.whichButton(f);"L"==l.whichButton&&l.activeIfValue&&(l.up=!0,b(p,l.increase,!0),l.draw())}function f(c){c.preventDefault();l.whichButton=a.whichButton(c);"L"==l.whichButton&&l.activeIfValue&&(l.down=!0,b(p,l.decrease,!0),l.draw())}function e(a){l.up=!1;clearInterval(q);
l.draw();a.preventDefault()}function d(a){l.down=!1;clearInterval(q);l.draw();a.preventDefault()}function g(a){l.up=!1;clearInterval(q);l.draw();a.preventDefault()}function h(a){l.down=!1;clearInterval(q);l.draw();a.preventDefault()}m=a.hasTouchSupport;var l=this,p=m?500:200,q;l.divUp.oncontextmenu=l.divDown.oncontextmenu=l.field.oncontextmenu=l.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&&l.changeValue(l.field.value)});m?this.divUp.addEventListener("touchstart",c):this.divUp.addEventListener("mousedown",c);m?this.divDown.addEventListener("touchstart",f):this.divDown.addEventListener("mousedown",f);m||this.divUp.addEventListener("mouseout",e);m||this.divDown.addEventListener("mouseout",d);m?(this.divUp.addEventListener("touchend",g),window.addEventListener("touchend",g)):(this.divUp.addEventListener("mouseup",
g),window.addEventListener("mouseup",g));m?(this.divDown.addEventListener("touchend",h),window.addEventListener("touchend",h)):(this.divDown.addEventListener("mouseup",h),window.addEventListener("mouseup",h));l.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f;a.TextField=function(b,c){a.Control.call(this,b,c);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=
this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");void 0===this.valueExprString&&(this.valueExprString=this.onlyText?"0":"");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;if(this.answer)if(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answerPattern=this.answer,this.answer=a.buildRegularExpresionsPatterns(this.answer,this.evaluator),this.onlyText){var f=this.answerPattern.indexOf("|");
this.firstAnswer=-1==f?this.answerPattern:this.answerPattern.substring(0,f)}else this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(",")));this.onlyText&&(this.valueExprString.match(/^'/)&&this.valueExprString.match(/'$/)||(this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'")),this.validateValue=function(a){return"''"==a||"'"==a?"":a&&a.match(/^'/)&&a.match(/'$/)?a.substring(1,a.length-1):a},this.formatOutputValue=function(a){return a.toString()});
""==name.trim()&&(name="");this.containerControl=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){d=this.evaluator;var b=d.evalExpression(this.name).toString();this.label.innerHTML=
b;this.value=this.validateValue(d.evalExpression(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var f=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),g=parseInt(this.w/2),h=a.getTextWidth(b,this.fieldFontSize+"px Arial");g<h&&(g=h);""==b&&(g=0);this.w-g<f&&(g=this.w-f);0>g&&(g=0);b=this.w-g;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: "+g+"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: "+g+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.evaluate&&(this.ok=this.evaluateAnswer());this.evaluator.setVariable(this.id,this.value);this.evaluator.setVariable(this.id+".ok",this.ok);this.oldValue=this.value;this.update()};a.TextField.prototype.update=function(){d=this.evaluator;this.label.innerHTML=d.evalExpression(this.name).toString();this.activeIfValue=0<d.evalExpression(this.activeif);this.drawIfValue=0<d.evalExpression(this.drawif);
this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize();this.parent.animation.playing&&document.activeElement==this.field||(h=this.field.value,g=this.value,this.value=this.validateValue(d.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value===g&&this.field.value!=h&&(this.value=this.validateValue(h),this.field.value=this.formatOutputValue(this.value)),d.setVariable(this.id,this.value))};
a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";d=this.evaluator;b=parseFloat(d.evalExpression(d.parser.parse(a.toString().replace(this.parent.decimal_symbol,"."))));isNaN(b)&&(b=0);c=d.evalExpression(this.min);""==c&&(c=-Math.Infinity);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,b){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluate&&(this.ok=this.evaluateAnswer()),this.evaluator.setVariable(this.id,this.value),this.evaluator.setVariable(this.id+".ok",this.ok),this.updateAndExecAction())};a.TextField.prototype.evaluateAnswer=function(){console.log("1");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(){f=a.hasTouchSupport;var b=this;b.field.oncontextmenu=b.label.oncontextmenu=function(){return!1};f?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",
function(a){b.changeValue(b.field.value,!0)});this.field.addEventListener("keydown",function(a){b.activeIfValue&&13==a.keyCode&&b.changeValue(b.field.value,!0)});b.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.abs,h,g,b,c,n,f,p,e,q,r,k;a.Menu=function(b,c){this.options="";a.Control.call(this,b,c);h=this.parser;g=this.evaluator;this.ok=0;this.tabindex=++this.parent.tabindex;this.answer&&(this.answer.match("krypto_")&&
(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answer=parseInt(this.answer.split(",")[0].replace("[",""))||0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var f,e=0,d=this.options.length;e<d;e++)f=this.customSplit(this.options[e]),1==f.length?(this.menuOptions.push(f[0]),
this.strValue.push(e.toString())):2==f.length&&(this.menuOptions.push(f[0]),""==f[1]?this.strValue.push(e.toString()):this.strValue.push(f[1]));e=0;for(d=this.menuOptions.length;e<d;e++)this.menuOptions[e].match(/^\[/)&&this.menuOptions[e].match(/\]$/)?this.menuOptions[e]=h.parse(this.menuOptions[e].substring(1,this.menuOptions[e].length-1)):this.menuOptions[e]=h.parse("'"+this.menuOptions[e]+"'");e=0;for(d=this.strValue.length;e<d;e++)this.strValue[e].match(/^\[/)&&this.strValue[e].match(/\]$/)?
this.strValue[e]=h.parse(this.strValue[e].substring(1,this.strValue[e].length-1)):this.strValue[e]=h.parse(this.strValue[e]);this.containerControl=document.createElement("div");this.label=document.createElement("label");this.select=document.createElement("select");e=0;for(d=this.menuOptions.length;e<d;e++)f=document.createElement("option"),f.innerHTML=g.evalExpression(this.menuOptions[e]),this.select.appendChild(f);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(){g=this.evaluator;var b=g.evalExpression(this.name).toString();this.label.innerHTML=b;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var c=0,f=0,e=0;this.value=g.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);
for(var d=0,h=this.menuOptions.length;d<h;d++)e=a.getTextWidth(g.evalExpression(this.menuOptions[d]).toString(),this.fieldFontSize+"px Arial"),e>c&&(c=e,f=d);c+=25;e=a.getTextWidth(this.formatOutputValue(g.evalExpression(this.strValue[f])),this.fieldFontSize+"px Arial")+7;f=a.getTextWidth(b,this.fieldFontSize+"px Arial")+10;""==b&&(f=0);this.visible||(e=0);for(b=this.w-e-f;b<c&&0<f;)f--,b++;for(;b<c&&0<e;)e--,b++;for(;f+b+e+1<this.w;)b++,e++;c=f;d=c+b;e=this.w-d;h=this.formatOutputValue(g.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: "+f+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_menuField");
this.field.value=h;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+e+"px; height : "+this.h+"px; left: "+d+"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;g.setVariable(this.id,parseFloat(h));this.update()};a.Menu.prototype.update=function(){g=this.evaluator;this.activeIfValue=0<g.evalExpression(this.activeif);this.drawIfValue=0<g.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){this.label.innerHTML=g.evalExpression(this.name).toString();for(var a=0,b=this.menuOptions.length;a<b;a++)this.select.options[a].innerHTML=g.evalExpression(this.menuOptions[a]);this.value=g.getVariable(this.id);isNaN(this.value)&&(this.value=0);this.field.value=this.formatOutputValue(this.value);
g.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){p=!1;e="";q=0;for(r=-1;q<a.length;){k=a.charAt(q);a.charAt(q-1);if("["===k&&-1===r){if(p||""!=e)e+="\u00a6";r++}else"["===k?r++:"]"===k&&0===r?(p=!0,r--):"]"==a.charAt(q)&&(r=0>r?r:r-1);e+=a.charAt(q);q++}return e.split("\u00a6")};a.Menu.prototype.getIndex=function(a){a=
parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));b=-1;c=Infinity;for(var f=0,e=this.strValue.length;f<e;f++)n=d(a-parseFloat(this.evaluator.evalExpression(this.strValue[f]))),n<=c&&(c=n,b=f);return b};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){f=a.hasTouchSupport;var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=
function(){return!1};f?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(a){b.value=b.evaluator.evalExpression(b.strValue[this.selectedIndex]);b.field.value=b.formatOutputValue(b.value);b.evaluator.setVariable(b.id,b.field.value);b.changeValue();a.preventDefault()});this.field.addEventListener("keydown",function(a){13==a.keyCode&&(b.indexValue=
b.getIndex(b.field.value),b.value=b.evaluator.evalExpression(b.strValue[b.indexValue]),b.field.value=b.formatOutputValue(b.indexValue),b.select.selectedIndex=b.indexValue,b.changeValue())});b.field.addEventListener("click",function(a){this.select();this.focus()});b.select.addEventListener("mouse",function(a){this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h="h",g,b,c,n,f,p,e,q,r,k,t,s,l,u,m,v,w,y,C,B,D;a.Scrollbar=function(b,c){a.Control.call(this,
b,c);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.orientation=this.w>=this.h?h:"v";this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.scrollManipulator=document.createElement("div");
this.label=document.createElement("label");this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.scrollManipulator);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){g=
this.evaluator;this.findOffset();0==g.evalExpression(this.decimals)?this.incr=1:this.incr=(g.evalExpression(this.max)-g.evalExpression(this.min))/100;this.value=this.validateValue(g.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?h:"v";this.initScroll(c);this.changeScrollPositionFromValue();this.prePos=this.pos;g.setVariable(this.id,
this.value)};a.Scrollbar.prototype.initScroll=function(c){b=this;g=b.evaluator;var f=g.evalExpression(b.name).toString();b.label.innerHTML=f;var e="v"===b.orientation?parseInt(19+5*(b.h-100)/100):b.h;b.fieldFontSize="v"===b.orientation?e-parseInt(b.h/20)-1:2!==b.parent.version?a.getFieldFontSize(e):10;var d=a.getTextWidth(c+"_",b.fieldFontSize+"px Arial"),h=b.parent.getSpaceById(b.spaceID).h;b.labelHeight=""==f?0:e;b.fieldHeight=""==b.visible?0:e;if("v"===b.orientation)b.canvasWidth=b.w,b.canvasHeight=
b.h-b.labelHeight-b.fieldHeight,18<=b.canvasHeight+b.y-h&&(b.canvasHeight=h),f=0,f=b.fieldHeight,d=f+b.canvasHeight,b.canvasX=0,b.canvasY=b.fieldHeight,b.labelWidth=b.w,b.labelY=d,b.upWidth=b.downW=b.w,b.upHeight=b.downH=15,b.upX=0,b.upY=b.fieldHeight,b.downX=0,b.downY=d-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=
d-b.downH-b.scrollManipulatorH,b.scrollManipulatorLimSup=f+b.downH;else{e=a.getTextWidth(f,b.fieldFontSize+"px Arial")+10;b.labelWidth=e;b.fieldWidth=d;""==f&&(b.labelWidth=0);b.visible||(b.fieldWidth=0);for(d=b.w-b.fieldWidth-b.labelWidth;58>d&&0<b.labelWidth;)b.labelWidth--,d++;for(;58>d&&0<b.fieldWidth;)b.fieldWidth--,d++;f=b.labelWidth;e=f+d;b.fieldWidth=b.w-e;b.canvasWidth=d;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=e-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=f+b.downW;b.scrollManipulatorLimSup=f+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(){g=this.evaluator;this.label.innerHTML=g.evalExpression(this.name).toString();0==g.evalExpression(this.decimals)?this.incr=1:this.incr=(g.evalExpression(this.max)-g.evalExpression(this.min))/100;this.activeIfValue=0<g.evalExpression(this.activeif);this.drawIfValue=0<g.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(g.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);g.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){b=this;f=b.ctx;e=d(this.w);p=d(this.h);f.fillStyle="#e0e4e8";f.fillRect(0,0,e,p);f.strokeStyle="#7a8a99";b.down&&(f.fillStyle="#ccdcec",
f.fillRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1));f.strokeRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1);b.up&&(f.fillStyle="#ccdcec",f.fillRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1));f.strokeRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1);q=4;f.fillStyle="black";f.beginPath();b.orientation===h?(f.moveTo(b.downX+q,b.downH/2),f.lineTo(b.downX+b.downW-q,q),f.lineTo(b.downX+b.downW-q,b.downH-q),f.moveTo(b.upX+b.upWidth-q,b.downH/2),f.lineTo(b.upX+q,q),f.lineTo(b.upX+q,b.downH-q),f.fill(),
b.activeIfValue&&(r=d(b.pos),f.fillStyle="#ccdcec",f.fillRect(r+0.5,0,d(b.scrollManipulatorW),p),f.strokeStyle="#6382bf",f.strokeRect(r+0.5,0,d(b.scrollManipulatorW),p),k=d(b.scrollManipulatorW/2),f.beginPath(),f.moveTo(r+k+0.5-2,3),f.lineTo(r+k+0.5-2,p-3),f.moveTo(r+k+0.5,3),f.lineTo(r+k+0.5,p-3),f.moveTo(r+k+0.5+2,3),f.lineTo(r+k+0.5+2,p-3),f.stroke())):(f.moveTo(b.downX+b.downW/2,b.downY+b.downH-q),f.lineTo(b.downX+q,b.downY+q),f.lineTo(b.downX+b.downW-q,b.downY+q),f.moveTo(b.upX+b.upWidth/2,b.upY+
q),f.lineTo(b.upX+q,b.upY+b.upHeight-q),f.lineTo(b.upX+b.upWidth-q,b.upY+b.upHeight-q),f.fill(),b.activeIfValue&&(r=d(b.pos),f.fillStyle="#ccdcec",f.fillRect(0,r+0.5,e,d(b.scrollManipulatorH)),f.strokeStyle="#6382bf",f.strokeRect(0,r+0.5,e,d(b.scrollManipulatorH)),k=d(b.scrollManipulatorH/2),f.beginPath(),f.moveTo(3,r+k+0.5-2),f.lineTo(e-3,r+k+0.5-2),f.moveTo(3,r+k+0.5),f.lineTo(e-3,r+k+0.5),f.moveTo(3,r+k+0.5+2),f.lineTo(e-3,r+k+0.5+2),f.stroke()));f.strokeRect(0.5,0.5,e-1,p-1);b.activeIfValue||
(f.fillStyle="rgba(240,240,240,"+160/255+")",f.fillRect(0,0,e,p.h))};a.Scrollbar.prototype.validateValue=function(a){g=this.evaluator;t=a.toString();t=parseFloat(t.replace(this.parent.decimal_symbol,"."));isNaN(t)&&(t=0);this.minimo=g.evalExpression(this.min);t<this.minimo&&(this.value=null,t=this.minimo);this.maximo=g.evalExpression(this.max);t>this.maximo&&(this.value=null,t=this.maximo);s=this.incr;t=0!=s?t*s/s:0;this.fixed&&(t=parseFloat(parseFloat(t).toFixed(g.evalExpression(this.decimals))));
return t};a.Scrollbar.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.incr)};a.Scrollbar.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.incr)};a.Scrollbar.prototype.increase10=function(){q=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==h?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+q):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+q)};a.Scrollbar.prototype.decrease10=
function(){q=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==h?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-q):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-q)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&(l=this.validateValue(a),l!=this.value&&(this.value=l,this.field.value=this.formatOutputValue(l),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,
this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){g=this.evaluator;u=this.scrollManipulatorLimInf;m=this.scrollManipulatorLimSup;v=g.evalExpression(this.min);w=g.evalExpression(this.max);s=this.incr;l=d((this.pos-u)*(w-v)/(m-u)/s)*s+v;l!=this.value&&(this.value=l,this.field.value=this.formatOutputValue(l),g.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=
function(){g=this.evaluator;u=this.scrollManipulatorLimInf;m=this.scrollManipulatorLimSup;v=g.evalExpression(this.min);w=g.evalExpression(this.max);s=this.incr;this.pos=(this.value-v)*(m-u)/(w-v)+u;this.orientation==h?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f,e){clearInterval(w);(s.up||s.down||s.canvasClick)&&1E-7<Math.abs(s.value-e)&&(c.call(s),a=f?a:30,w=setTimeout(function(){b(a,
c,!1,e)},a))}function c(f){f.preventDefault();s.whichButton=a.whichButton(f);"L"==s.whichButton&&s.activeIfValue&&(s.clickPos=s.getCursorPosition(f),s.canvasClick=!0,s.orientation==h?s.clickPos.x<s.prePos?b(u,s.decrease10,!0,s.minimo):b(u,s.increase10,!0,s.maximo):s.clickPos.y<s.prePos?b(u,s.increase10,!0,s.maximo):b(u,s.decrease10,!0,s.minimo))}function f(a){s.canvasClick=!1;clearInterval(w);a.preventDefault()}function e(a){!0==s.canvasClick&&(s.clickPos=s.getCursorPosition(a),a.preventDefault())}
function d(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("mouseup",l),window.addEventListener("mousemove",q),a.preventDefault())}function g(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("touchend",p),window.addEventListener("touchmove",onToucheMove_scrollManipulator),a.preventDefault())}function l(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("mouseup",l,!1);window.removeEventListener("mousemove",
q,!1);a.preventDefault()}function p(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("touchend",p,!1);window.removeEventListener("touchmove",q,!1);a.preventDefault()}function q(a){var b=s.getCursorPosition(a);s.orientation==h?(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 r(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.up=!0,b(u,s.increase,!0,s.maximo))}function n(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.down=!0,b(u,s.decrease,!0,s.minimo))}function m(a){s.up=!1;clearInterval(w);a.preventDefault()}function k(a){s.down=!1;clearInterval(w);a.preventDefault()}function t(a){s.up=!1;clearInterval(w);a.preventDefault();s.draw()}function v(a){s.down=!1;clearInterval(w);
a.preventDefault();s.draw()}y=a.hasTouchSupport;var s=this,u=y?500:200,w;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",k);y?window.addEventListener("touchend",
f):window.addEventListener("mouseup",f);y?this.canvas.addEventListener("touchmove",e):this.canvas.addEventListener("mousemove",e);y?this.scrollManipulator.addEventListener("touchstart",g):this.scrollManipulator.addEventListener("mousedown",d);y?this.divUp.addEventListener("touchstart",r):this.divUp.addEventListener("mousedown",r);y?this.divDown.addEventListener("touchstart",n):this.divDown.addEventListener("mousedown",n);y||this.divUp.addEventListener("mouseout",m);y||this.divDown.addEventListener("mouseout",
k);y?window.addEventListener("touchend",t):window.addEventListener("mouseup",t);y?window.addEventListener("touchend",v):window.addEventListener("mouseup",v)};a.Scrollbar.prototype.findOffset=function(){C=this.containerControl;this.offsetTop=this.offsetLeft=0;B=this.containerControl.style.display;for(this.containerControl.style.display="block";C;)this.offsetLeft+=C.offsetLeft||0,this.offsetTop+=C.offsetTop||0,C=C.parentNode;this.containerControl.style.display=B};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,h=c.evaluator.evalExpression(c.expresion);4==h[0].length?(c.w=h[0][2],c.h=h[0][3]):(c.w=200,c.h=28);c.audio=c.parent.getAudio(c.file);c.autoplay&&(c.audio.setAttribute("autoplay","autoplay"),c.audio.play());c.loop&&c.audio.setAttribute("loop",
"loop");c.controls&&c.audio.setAttribute("controls","controls");c.audio.setAttribute("style","position: absolute; width: "+c.w+"px; left: "+c.x+"px; top: "+c.y+"px; z-index: "+c.zIndex+";");c.addControlContainer(c.audio);c.evaluator.setFunction(c.id+".play",function(){c.audio.play();return 0});c.evaluator.setFunction(c.id+".pause",function(){c.audio.pause();return 0});c.evaluator.setFunction(c.id+".stop",function(){c.audio.pause();return c.audio.currentTime=0});c.audio.addEventListener("timeupdate",
function(a){c.evaluator.setVariable(c.id+".currentTime",c.audio.currentTime)})};a.extend(a.Audio,a.Control);a.Audio.prototype.init=function(){this.audio.style.left=this.x+"px";this.audio.style.top=this.y+"px";this.update()};var h;a.Audio.prototype.update=function(){d=this.evaluator;(h=0<d.evalExpression(this.drawif))?this.audio.style.display="block":(this.audio.style.display="none",h!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=h;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var d;a.Video=function(g,b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,g,b);var c=this;d=c.evaluator;var h=c.evaluator.evalExpression(c.expresion);4==h[0].length?(c.w=h[0][2],c.h=h[0][3]):(c.w=null,c.h=null);c.video=document.createElement("video");c.autoplay&&c.video.setAttribute("autoplay","autoplay");c.loop&&c.video.setAttribute("loop","loop");c.controls&&c.video.setAttribute("controls","controls");c.poster&&c.video.setAttribute("poster",
c.poster);c.w&&(c.video.setAttribute("width",c.w),c.video.setAttribute("height",c.h));c.video.setAttribute("style","position: absolute; overflow: hidden; left: "+c.x+"px; top: "+c.y+"px;");var h=c.file,f=h.lastIndexOf(".");-1!=f&&(h=c.file.substring(0,f));c.video.canPlayType("video/mp4")&&(f=document.createElement("source"),f.setAttribute("src",h+".mp4"),f.setAttribute("type","video/mp4"),c.video.appendChild(f));c.video.canPlayType("video/ogg")&&(f=document.createElement("source"),f.setAttribute("src",
h+".ogg"),f.setAttribute("type","video/ogg"),c.video.appendChild(f),f=document.createElement("source"),f.setAttribute("src",h+".ogv"),f.setAttribute("type","video/ogg"),c.video.appendChild(f));c.video.canPlayType("video/webm")&&(f=document.createElement("source"),f.setAttribute("src",h+".webm"),f.setAttribute("type","video/webm"),c.video.appendChild(f));c.addControlContainer(c.video);c.evaluator.setFunction(c.id+".play",function(){c.video.play();return 0});c.evaluator.setFunction(c.id+".pause",function(){c.video.pause();
return 0});c.evaluator.setFunction(c.id+".stop",function(){c.video.pause();return c.video.currentTime=0});c.video.addEventListener("timeupdate",function(a){c.evaluator.setVariable(c.id+".currentTime",c.video.currentTime)})};a.extend(a.Video,a.Control);a.Video.prototype.init=function(){this.video.style.left=this.x+"px";this.video.style.top=this.y+"px";this.update()};var h;a.Video.prototype.update=function(){d=this.evaluator;h=0<d.evalExpression(this.drawif);0<d.evalExpression(this.drawif)?this.video.style.display=
"block":(this.video.style.display="none",h!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=h;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h;a.TextArea=function(d,b){this.font="Monospaced,PLAIN,12";a.Control.call(this,d,b);this.region="interior";this.tabindex=++this.parent.tabindex;if(this.answer){this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7)));var c=this.parent.lessonParser.parseText(this.answer)}this.containerControl=
document.createElement("div");this.textArea=document.createElement("div");this.textAreaAnswer=document.createElement("div");this.showButton=document.createElement("div");this.activeCover=document.createElement("div");this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);this.containerControl.appendChild(this.activeCover);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=
void 0==this.text||"simpleText"==this.text.type?this.rawText||"":this.text.hasFormula?this.rawText:this.text.toHTML();c&&"simpleText"!=c.type&&(this.answer=this.text.hasFormula?"":c.toHTML());this.evaluator.setVariable(this.id,this.text);this.drawButton();this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){h=this.answer?28:8;d=this.evaluator;var g;g=this.text.match(/<span/)?this.text:this.text.replace(/\\n/g,"<br/>");this.containerControl.setAttribute("class",
"DescartesTextAreaContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=0<d.evalExpression(this.drawif)?"block":"none";this.containerControl.setAttribute("spellcheck","false");this.textArea.setAttribute("class","DescartesTextAreaContainer");this.textArea.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-h)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+
a.convertFont(this.font)+";");this.textArea.setAttribute("contenteditable","true");this.textArea.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;' >"+g+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-h)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textAreaAnswer.style.display=
this.showAnswer?"block":"none";this.textAreaAnswer.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;'>"+this.answer+"</span>";this.showButton.setAttribute("style","width: 20px; height: 16px; position: absolute; bottom: 4px; right: 4px; cursor: pointer;");this.showButton.style.backgroundImage="url("+this.imageUnPush+")";this.showButton.style.display=this.answer?"block":"none";this.showButton.innerHTML="<span style='position: relative; top: 2px; text-align: center; font: 9px Arial'> S </span>";
this.activeCover.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px;");this.update()};a.TextArea.prototype.drawButton=function(){var d=document.createElement("canvas");d.setAttribute("width",20);d.setAttribute("height",16);var b=d.getContext("2d");this.canvas=d;this.ctx=b;this.createGradient(20,16);b.lineWidth=1;b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,19,0,19,
16,"rgba(0,0,0,"+128/255+")");a.drawLine(b,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(b,1,0,1,16,"rgba(0,0,0,"+8/255+")");this.imageUnPush=d.toDataURL();b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,0,0,0,14,"gray");a.drawLine(b,0,0,19,0,"gray");b.fillStyle="rgba(0, 0, 0,"+24/255+")";b.fillRect(0,0,this.w,this.h);this.imagePush=d.toDataURL()};a.TextArea.prototype.update=function(){d=this.evaluator;this.activeIfValue=0<d.evalExpression(this.activeif);
this.drawIfValue=0<d.evalExpression(this.drawif);var a;a=this.text.match(/<span/)?this.rawText:this.text;d.setVariable(this.id,a);this.activeCover.style.display=this.activeIfValue?"none":"block";this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize()};a.TextArea.prototype.registerMouseAndTouchEvents=function(){function a(c){c.preventDefault();b.showButton.style.backgroundImage="url("+b.imageUnPush+")"}var b=this;this.showButton.addEventListener("mousedown",
function(a){a.preventDefault();b.showAnswer=!b.showAnswer;b.textAreaAnswer.style.display=b.showAnswer?"block":"none";b.showButton.childNodes[0].childNodes[0].textContent=b.showAnswer?"T":"S";b.showButton.style.backgroundImage="url("+b.imagePush+")"});this.showButton.addEventListener("mouseup",a);this.showButton.addEventListener("mouseout",a)};a.TextArea.prototype.getScreenshot=function(){var a=document.createElement("canvas");a.setAttribute("width",this.w);a.setAttribute("height",this.h);var b=a.getContext("2d");
b.fillStyle="white";b.strokeStyle="black";b.lineWidth=1;b.fillRect(0,0,this.w,this.h);b.strokeRect(0,0,this.w,this.h);return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI,h,g,b,c,n,f,p,e,q;a.GraphicControl=function(b,c){g=b.evaluator.parser;this.text=this.spaceID="";this.size=g.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);if(this.constraintExpr){this.constraint=g.parse(this.constraintExpr);"(expr)"==this.constraint.type&&(this.constraint=g.parse(this.constraintExpr.substring(1,this.constraintExpr.length-1)));if("compOperator"==this.constraint.type){var f=this.constraint.childs[0],d=this.constraint.childs[1];"identifier"!=f.type||"y"!=f.value||d.contains("y")?"identifier"!=f.type||"x"!=f.value||d.contains("x")?this.newt=new a.R2Newton(this.evaluator,this.constraint):(this.evalConstraint=this.evalConstraintY,
this.constraint=f):(this.evalConstraint=this.evalConstraintX,this.constraint=d)}else this.constraint=null;e=new a.R2(0,0)}this.container=this.getContainer();this.mouseCacher=document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("dragged",!0);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);this.registerMouseAndTouchEvents();
this.xString=this.id+".x";this.yString=this.id+".y";this.activoString=this.id+".activo";this.activeString=this.id+".active";""!==this.space.id&&2!==b.version?(this.mxString=this.space.id+".mouse_x",this.myString=this.space.id+".mouse_y",this.mclickedString=this.space.id+".mouse_clicked",this.mclicizquierdoString=this.space.id+".clic_izquierdo"):(this.mxString="mouse_x",this.myString="mouse_y",this.mclickedString="mouse_clicked",this.mclicizquierdoString="clic_izquierdo");this.init()};a.GraphicControl.prototype.init=
function(){h=this.evaluator;q=a.hasTouchSupport;var b=h.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];h.setVariable(this.xString,this.x);h.setVariable(this.yString,this.y);""==this.imageSrc||this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.width=2*h.evalExpression(this.size),this.height=2*h.evalExpression(this.size)):(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,this.height=this.image.height);this._w=q&&70>this.width?70:this.width;this._h=q&&70>this.height?
70:this.height;this.mouseCacher.setAttribute("style","cursor: pointer; background-color: rgba(255, 255, 255, 0); width: "+this._w+"px; height: "+this._h+"px; z-index: "+this.zIndex+";");this.mouseCacher.style.left=parseInt(this.space.getAbsoluteX(this.x)-this._w/2)+"px";this.mouseCacher.style.top=parseInt(this.space.getAbsoluteY(this.y)-this._h/2)+"px";h.setVariable(this.activoString,0);h.setVariable(this.activeString,0);this.setImage=!1;this.update()};a.GraphicControl.prototype.update=function(){h=
this.evaluator;this.activeIfValue=0<h.evalExpression(this.activeif);this.drawIfValue=0<h.evalExpression(this.drawif);this.x=h.getVariable(this.xString);this.y=h.getVariable(this.yString);b=this.space.getAbsoluteX(this.x);c=this.space.getAbsoluteY(this.y);this.mouseCacher.style.display=this.activeIfValue?"block":"none";this.mouseCacher.style.left=parseInt(b-this._w/2)+"px";this.mouseCacher.style.top=parseInt(c-this._h/2)+"px";this.constraint&&this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=
function(){h=this.evaluator;this.drawIfValue&&(f=this.ctx,p=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&&f.drawImage(this.image,parseInt(b-this.image.width/2),parseInt(c-this.image.height/2)),this.trace&&(p.save(),p.translate(b,c),p.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),p.beginPath(),p.arc(0,0,1,0,d,!1),p.restore(),
p.lineWidth=1,p.strokeStyle=this.trace.getColor(),p.stroke())):(f.beginPath(),f.arc(b,c,parseInt(this.width/2),0,d,!1),f.fillStyle=this.colorInt.getColor(),f.fill(),f.lineWidth=1,f.strokeStyle=this.color.getColor(),f.stroke(),this.active&&(f.beginPath(),f.arc(b,c,parseInt(this.width/2)-2,0,d,!1),f.strokeStyle=this.colorInt.borderColor(),f.stroke()),this.trace&&(p.lineWidth=1,p.strokeStyle=this.trace.getColor(),p.beginPath(),p.arc(b,c,parseInt(this.width/2),0,d,!1),p.stroke())))};a.GraphicControl.prototype.evalConstraint=
function(){e.set(this.x,this.y);n=this.newt.findZero(e);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.evalConstraintX=function(){var a=this.evaluator.getVariable("x");this.evaluator.setVariable("x",this.x);this.y=this.evaluator.evalExpression(this.constraint);this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,this.y);this.evaluator.setVariable("x",a)};a.GraphicControl.prototype.evalConstraintY=
function(){var a=this.evaluator.getVariable("y");this.evaluator.setVariable("y",this.y);this.x=this.evaluator.evalExpression(this.constraint);this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,this.y);this.evaluator.setVariable("y",a)};a.GraphicControl.prototype.drawText=function(a,b){f=this.ctx;h=this.evaluator;f.fillStyle=this.color.getColor();f.font=this.font;f.textBaseline="alphabetic";f.fillText(h.evalExpression(this.text[0],h.evalExpression(this.decimals),
this.fixed),parseInt(a+1+this.width/2),parseInt(b-1-this.height/2))};a.GraphicControl.prototype.getContainer=function(){for(var a=this.parent.spaces,b,c=0,f=a.length;c<f;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();p.whichButton=a.whichButton(c);"L"==p.whichButton&&p.activeIfValue&&p.over&&(p.parent.deactivateGraphiControls(),p.click=!0,p.active=!0,p.evaluator.setVariable(p.activoString,1),p.evaluator.setVariable(p.activeString,1),p.evaluator.setVariable(p.mclickedString,0),p.evaluator.setVariable(p.mclicizquierdoString,0),p.posAnte=p.getCursorPosition(c),p.prePos={x:p.space.getAbsoluteX(p.x),
y:p.space.getAbsoluteY(p.y)},p.evaluator.setVariable(p.mxString,p.space.getRelativeX(p.posAnte.x)),p.evaluator.setVariable(p.myString,p.space.getRelativeY(p.posAnte.y)),p.parent.update(),window.addEventListener("mouseup",f),window.addEventListener("mousemove",e))}function c(a){document.body.focus();a.preventDefault();p.activeIfValue&&(p.parent.deactivateGraphiControls(),p.click=!0,p.active=!0,p.evaluator.setVariable(p.activoString,1),p.evaluator.setVariable(p.activeString,1),p.evaluator.setVariable(p.mclickedString,
0),p.evaluator.setVariable(p.mclicizquierdoString,0),p.posAnte=p.getCursorPosition(a),p.prePos={x:p.space.getAbsoluteX(p.x),y:p.space.getAbsoluteY(p.y)},p.evaluator.setVariable(p.mxString,p.space.getRelativeX(p.posAnte.x)),p.evaluator.setVariable(p.myString,p.space.getRelativeY(p.posAnte.y)),p.parent.update(),window.addEventListener("touchmove",e),window.addEventListener("touchend",f))}function f(b){document.body.focus();b.preventDefault();p.touchId=null;p.evaluator.setVariable(p.mclickedString,1);
p.evaluator.setVariable(p.mclicizquierdoString,1);if(p.activeIfValue||p.active)p.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",e,!1),window.removeEventListener("touchend",f,!1)):(window.removeEventListener("mouseup",f,!1),window.removeEventListener("mousemove",e,!1)),p.evaluator.setVariable(p.mxString,p.space.getRelativeX(p.posAnte.x)+p.x),p.evaluator.setVariable(p.myString,p.space.getRelativeY(p.posAnte.y)+p.y),p.parent.update(),p.mouseCacher.style.left=p.space.getAbsoluteX(p.x)-
p._w/2+"px",p.mouseCacher.style.top=p.space.getAbsoluteY(p.y)-p._h/2+"px"}function e(a){a.preventDefault();a.touchId=p.touchId;p.evaluator.setVariable(p.mclickedString,0);p.evaluator.setVariable(p.mclicizquierdoString,0);q=p.getCursorPosition(a);p.posX=p.prePos.x-(p.posAnte.x-q.x);p.posY=p.prePos.y-(p.posAnte.y-q.y);p.evaluator.setVariable(p.xString,p.space.getRelativeX(p.posX));p.evaluator.setVariable(p.yString,p.space.getRelativeY(p.posY));p.evaluator.setVariable(p.mxString,p.space.getRelativeX(p.posAnte.x)+
p.space.getRelativeX(p.posX));p.evaluator.setVariable(p.myString,p.space.getRelativeY(p.posAnte.y)+p.space.getRelativeY(p.posY));10<Date.now()-h&&(p.parent.updateControls(),p.parent.update(),h=Date.now())}function d(a){p.over=!0}function g(a){p.over=!1;p.click=!1}var h=0,p=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",
d),this.mouseCacher.addEventListener("mouseout",g));var q};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var b;if(a.touchId)for(c=0,f=a.touches.length;c<f;c++){if(a.touches[c].identifier==a.touchId){b=a.touches[c];break}}else for(var c=0,f=a.touches.length;c<f;c++)if(a.target==a.touches[c].target){b=a.touches[c];this.touchId=b.identifier;break}mouseX=b.pageX;mouseY=b.pageY}else void 0!=a.pageX&&void 0!=a.pageY?(mouseX=a.pageX,mouseY=a.pageY):(mouseX=a.clientX+document.body.scrollLeft+
document.documentElement.scrollLeft,mouseY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:mouseX-(this.space.container.offsetLeft+this.space.container.parentNode.offsetLeft),y:mouseY-(this.space.container.offsetTop+this.space.container.parentNode.offsetTop)}};return a}(descartesJS||{}),descartesJS=function(a,d){var h,g,b,c,n,f,p,e,q,r;if(a.loadLib)return a;var k,t,s,l,u,m,v,w,y=/[\w-//]*(\.png|\.jpg|\.gif|\.svg)/gi,C,B,D,F,A,z,H,G,I,L,x,J,E,Q,N,K,R,S,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,f=a.length;c<f;c++)switch(s=a[c][0],l=a[c][1],t=d[s],t){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[t]=parseInt(l);break;case "about":case "config":case "init":case "clear":b[t]="true"===d[l];break;default:console.log("----- attributo de space no identificado: <"+
s+"> valor: <"+l+"> -----")}return b};a.LessonParser.prototype.parseSpace=function(b){u={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(s=b[c][0],l=b[c][1],t=d[s],t){case "type":case "id":case "cID":case "file":u[t]=l;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":u[t]="true"===d[l];break;case "bg_display":case "render":u[t]=d[l];break;case "net":case "net10":case "axes":case "text":u[t]="false"===d[l]?"":new a.Color(l,this.parent.evaluator);
break;case "x_axis":case "y_axis":u[t]="false"===d[l]?"":l;break;case "O.x":u.OxExpr=l;break;case "O.y":u.OyExpr=l;break;case "image":u.imageSrc=l;break;case "x":k=l;k="%"===k[k.length-1]?(this.parent.container.width*parseFloat(k)/100).toString():l;u.xExpr=this.parser.parse(k);break;case "y":k=l;k="%"===k[k.length-1]?(this.parent.container.height*parseFloat(k)/100).toString():l;u.yExpr=this.parser.parse(k);break;case "width":k=l;"%"===k[k.length-1]?(u.wExpr=k,k=this.parent.container.width*parseFloat(k)/
100):(k=parseFloat(l),k!=l&&(k=this.parent.container.width));u.w=k;break;case "height":k=l;"%"===k[k.length-1]?(u.hExpr=k,k=this.parent.container.height*parseFloat(k)/100):(k=parseFloat(l),k!=l&&(k=this.parent.container.height));u.h=k;break;case "drawif":u.drawif=this.parser.parse(l);break;case "scale":k=parseFloat(l);isNaN(k)&&(k=48);u.scale=k;break;case "background":u.background=new a.Color(l,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+s+"> valor: <"+
l+"> -----")}switch(u.type){case "R2":return new a.Space2D(this.parent,u);case "R3":return new a.Space3D(this.parent,u);case "AP":return new a.SpaceAP(this.parent,u);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,u);default:return new a.Space2D(this.parent,u)}};a.LessonParser.prototype.parseControl=function(b){m={type:"numeric"};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(s=b[c][0],l=b[c][1],t=d[s],t){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[t]=
l;break;case "gui":case "region":case "action":case "msg_pos":case "poster":m[t]=d[l];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":m[t]="true"===d[l];break;case "color":case "colorInt":case "trace":m[t]=new a.Color(l,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":m[t]=this.parser.parse(l);break;case "constraint":m.constraintExpr=l;break;case "image":m.imageSrc=
l;break;case "space":m.spaceID=l;break;case "type":m.type=d[l.trim()];break;case "expresion":m.expresion=this.parser.parse(l.replace(")(",","));break;case "bold":"false"!=d[l]&&(m.bold="bold");break;case "italics":"false"!=d[l]&&(m.italics="italic");break;case "underlined":"false"!=d[l]&&(m.underlined=!0);break;case "value":var e=l.replace(/&squot;/g,"'");e.match(/^\|/)&&(e="'"+e.substring(1),e.match(/\|$/)&&(e=e.substring(0,e.length-1)+"'"));m.valueExpr=this.parser.parse(e);m.valueExprString=e;break;
case "incr":0!=l&&(m.incr=this.parser.parse(l));break;case "exponentialif":m.exponentialif=parseFloat(l);break;case "text":m.rawText=l;for(var e=this.parseText(l),g=0,h=e.length;g<h;g++)e[g]=this.parser.parse(e[g],!1);m.text=e;break;default:g=s.indexOf(".");e=d[s.substring(0,g)];g=d[s.substring(g+1)];if("parameter"===e&&"font"===g){m.parameterFont=l;break}else if("Explanation"===e&&"font"===g){m.ExplanationFont=l;break}else if("tooltip"===e&&"font"===g){m.tooltipFont=l;break}console.log("----- attributo de control no identificado: <"+
s+"> valor: <"+l+"> -----")}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,f,e){v={rotateExp:e,parameter:"t"};b=this.split(b);e=0;for(var g=b.length;e<g;e++)switch(s=b[e][0],l=b[e][1],t=d[s],t){case "type":case "align":v[t]=d[l];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":v[t]="true"===d[l];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":v[t]="false"===d[l]?"":new a.Color(l,
this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":case "init":case "end":v[t]=l;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "opacity":case "inirot":case "inipos":case "range":v[t]=this.parser.parse(l);break;case "space":v.spaceID=l;break;case "expresion":"macro"!=v.type?(v.expresion=this.parser.parse(l),v.expresionString=l):v.expresion=l;break;case "text":v.text=this.parseText(l);break;case "file":var h=
l.replace(/&squot;/g,"'");"["===h.charAt(0)&&"]"===h.charAt(h.length-1)&&(h=h.substring(1,h.length-1));h.match(y)&&(h="'"+h+"'");v.file=this.parser.parse(h);break;case "border":"false"!=d[l]&&(v.border=new a.Color(l,this.parent.evaluator));break;default:if(void 0!=v.family&&s.substring(0,v.family.length+1)===v.family+"."){switch(d[s.substring(v.family.length+1)]){case "interval":v.family_interval=this.parser.parse(l);break;case "steps":v.family_steps=this.parser.parse(l)}break}if(void 0!=v.parameter&&
s.match(v.parameter+".")){v.parameter!==s.substring(0,s.indexOf(v.parameter)+v.parameter.length)&&(v.parameter=s.substring(0,s.indexOf(v.parameter)+v.parameter.length));switch(d[s.substring(v.parameter.length+1)]){case "interval":v.parameter_interval=this.parser.parse(l);break;case "steps":v.parameter_steps=this.parser.parse(l)}break}console.log("----- attributo del graphic no identificado: <"+s+"> valor: <"+l+"> -----")}c&&(v.abs_coord=c);f&&(v.background=f);switch(v.type){case "text":return new a.Text(this.parent,
v);case "image":return new a.Image(this.parent,v);case "point":return new a.Point(this.parent,v);case "polygon":return new a.Polygon(this.parent,v);case "arc":return new a.Arc(this.parent,v);case "segment":return new a.Segment(this.parent,v);case "arrow":return new a.Arrow(this.parent,v);case "macro":return new a.Macro(this.parent,v);case "curve":return new a.Curve(this.parent,v);case "equation":return new a.Equation(this.parent,v);case "sequence":return new a.Sequence(this.parent,v);case "fill":return new a.Fill(this.parent,
v)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,f,e){v={rotateExp:e,parameter:"t"};b=this.split(b);c=0;for(f=b.length;c<f;c++)switch(s=b[c][0],l=b[c][1],t=d[s],t){case "type":case "model":v[t]=d[l];break;case "background":case "fixed":case "edges":v[t]="true"===d[l];break;case "color":case "backcolor":v[t]=new a.Color(l,this.parent.evaluator);break;case "type":case "model":v[t]=d[l];break;case "background":case "fixed":case "edges":case "split":v[t]="true"===d[l];break;case "color":case "backcolor":v[t]=
new a.Color(l,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":v[t]=this.parser.parse(l);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":v[t]=l;break;case "space":v.spaceID=l;break;case "expresion":"macro"!=v.type&&"curve"!=v.type&&"surface"!=v.type?(v.expresion=this.parser.parse(l),v.expresionString=l):v.expresion=l.replace(/\\n/g," ").replace(/;/g," ");break;
case "text":e=this.parseText(l);for(var g=0,h=e.length;g<h;g++)e[g]=this.parser.parse(e[g],!1);v.text=e;break;case "file":e=l.replace(/&squot;/g,"'");"["===e.charAt(0)&&"]"===e.charAt(e.length-1)&&(e=e.substring(1,e.length-1));e.match(/./)&&(e="'"+e+"'");v.file=this.parser.parse(e);break;case "drawif":case "width":case "length":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":v[t]=this.parser.parse(l);break;case "family":case "parameter":case "font":case "name":v[t]=
l;break;case "space":v.spaceID=l;break;case "expresion":"macro"!=v.type&&"curve"!=v.type&&"surface"!=v.type?(v.expresion=this.parser.parse(l),v.expresionString=l):v.expresion=l;break;case "text":e=this.parseText(l);g=0;for(h=e.length;g<h;g++)e[g]=this.parser.parse(e[g],!1);v.text=e;break;case "file":e=l.replace(/&squot;/g,"'");"["===e.charAt(0)&&"]"===e.charAt(e.length-1)&&(e=e.substring(1,e.length-1));e.match(/./)&&(e="'"+e+"'");v.file=this.parser.parse(e);break;default:if(void 0!==v.family&&s.substring(0,
v.family.length+1)===v.family+"."){"interval"===d[s.substring(v.family.length+1)]?v.family_interval=this.parser.parse(l):v.family_steps=this.parser.parse(l);break}console.log("----- attributo del graphic3D no identificado: <"+s+"> valor: <"+l+"> -----")}switch(v.type){case "point":return new a.Point3D(this.parent,v);case "segment":return new a.Segment3D(this.parent,v);case "polygon":return new a.Polygon3D(this.parent,v);case "curve":return new a.Curve3D(this.parent,v);case "triangle":return new a.Triangle3D(this.parent,
v);case "face":return new a.Face3D(this.parent,v);case "polireg":return new a.Polireg3D(this.parent,v);case "surface":return new a.Surface3D(this.parent,v);case "text":return new a.Text3D(this.parent,v);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,v);case "macro":return new a.Macro3D(this.parent,v);default:console.log(v.type)}};a.LessonParser.prototype.parseAuxiliar=
function(b){w={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)b[c][1]=b[c][1].replace(/&squot;/g,"'");c=0;for(f=b.length;c<f;c++)switch(s=b[c][0],l=b[c][1],t=d[s],t){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":w[t]=l.replace(/&squot;/g,"'");break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":w[t]="true"===d[l];break;case "size":case "rows":case "columns":w[t]=
this.parser.parse(l);break;case "evaluate":case "execution":case "msg_pos":case "action":w[t]=d[l];break;default:var e=s.indexOf("."),g=d[s.substring(0,e)],e=d[s.substring(e+1)];if("parameter"===g&&"font"===e){w.parameterFont=l;break}console.log("----- attributo de auxiliar no identificado: <"+s+"> valor: <"+l+"> -----")}w.sequence?new a.Function(this.parent,w):w.constant?(b=new a.Constant(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.algorithm&&w.evaluate?(b=
new a.Algorithm(this.parent,w),this.parent.auxiliaries.push(b)):w.array&&!w.matrix&&")"!=w.id.charAt(w.id.length-1)?(b=new a.Vector(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.matrix&&")"!=w.id.charAt(w.id.length-1)?(b=new a.Matrix(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.event&&")"!=w.id.charAt(w.id.length-1)?this.parent.events.push(new a.Event(this.parent,w)):")"===w.id.charAt(w.id.length-1)?new a.Function(this.parent,
w):new a.Variable(this.parent,w)};a.LessonParser.prototype.parseAction=function(b){C=b.action;B=b.parent;D=b.parameter;if(C)switch(C){case "message":return new a.Message(B,D);case "calculate":return new a.Calculate(B,D);case "openURL":return new a.OpenURL(B,D);case "openScene":return new a.OpenScene(B,D);case "about":return new a.About(B,D);case "config":return new a.Config(B,D);case "init":return new a.Init(B,D);case "clear":return new a.Clear(B,D);case "animate":return new a.Animate(B,D);case "initAnimation":return new a.InitAnimation(B,
D);case "playAudio":return new a.PlayAudio(B,D);default:console.log("----- Accion no soportada aun: <"+C+"> -----")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(b){var c={};b=this.split(b);for(var f=0,e=b.length;f<e;f++)switch(s=b[f][0],l=b[f][1],t=d[s],t){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[t]=l.replace(/&squot;/g,"'");break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[t]="true"===d[l];break;default:console.log("----- attributo de la animacion no identificado: <"+
s+">  <"+l+"> -----")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(d,m){d=this.split(d);g=h="";b=0;c="#536891";n="white";f="left";p="";e="SansSerif,BOLD,20";q="SansSerif,PLAIN,18";r=void 0;for(var k=0,t=d.length;k<t;k++)switch(s=d[k][0],l=d[k][1],s){case "title":h=l;break;case "subtitle":g=l;break;case "subtitlines":b=l;break;case "bgcolor":""!=l&&(c=(new a.Color(l,this.parent.evaluator)).getColor());break;case "fgcolor":""!=l&&(n=(new a.Color(l,this.parent.evaluator)).getColor());
break;case "align":""!=l&&(f=l);break;case "titleimage":p=l;break;case "titlefont":e=""!=l?a.convertFont(l):a.convertFont(e);break;case "subtitlefont":q=""!=l?a.convertFont(l):a.convertFont(q);break;default:console.log("----- attributo de la pleca no identificado: <"+s+">  <"+l+"> -----")}if(""===h&&""===g)return document.createElement("div");L=q.substring(0,q.indexOf("px"));L=L.substring(L.lastIndexOf(" "));""!=p&&(x=this.parent.getImage(p),J=x.height);r=document.createElement("div");r.setAttribute("id",
"descartesPleca");J?(r.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+f+"; width: "+(m-30)+"px; height: "+(J-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;"),x.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),r.appendChild(x)):r.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+
f+"; 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;");E=document.createElement("div");E.setAttribute("style","padding: 0px; margin: 0px; font: "+e+"; overflow: hidden; white-space: nowrap;");E.innerHTML=h;Q=document.createElement("div");if(1===parseInt(b)){O=0;N=document.createElement("div");N.innerHTML=g;document.body.appendChild(N);R=L;do R-=O,N.setAttribute("style","padding: 0px; margin: 0px; font: "+
q+"; font-size: "+R+"px; width: "+(m-30)+"px; line-height: "+R+"px;"),K=N.offsetHeight,S=K/R,O=1;while(1<S&&8<R);document.body.removeChild(N);Q.setAttribute("style","padding: 0px; margin: 0px; font: "+q+"; font-size: "+R+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else Q.setAttribute("style","padding: 0px; margin: 0px; font: "+q+"; line-height: 110%;");Q.innerHTML=g;r.appendChild(E);r.appendChild(Q);r.imageHeight=J;return r};a.LessonParser.prototype.split=function(a){if("string"!=
typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");F=[];z=A=0;H=!1;G=0;for(I=!1;A<a.length;)" "!==a.charAt(A)||H||A++," "===a.charAt(A)||H||(H=!0,G=A),"="!==a.charAt(A)||"'"!==a.charAt(A+1)||I||(I=!0,F[z]=[a.substring(G,A)],G=A+2,A+=2),I&&"'"===a.charAt(A)&&(H=I=!1,F[z].push(a.substring(G,A)),z++),"="!==a.charAt(A)||"'"===a.charAt(A+1)||I||(F[z]=[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),F[z].push(a.substring(G,
M)),z++,H=!1,A=M),A++;return F};a.LessonParser.prototype.parseText=function(b){return b.match(/^\{\\rtf1/)?this.RTFparser.parse(b.substring(10)):new a.SimpleText(this.parent,b)};return a}(descartesJS||{},babel),descartesJS=function(a){function d(a,b){s=[];s.type="matrix";s.rows=a;s.cols=b;var c;u=0;for(m=b;u<m;u++){c=[];l=0;for(v=a;l<v;l++)c.push(0);s[u]=c}return s}function h(a,b){k=a.rows;t=a.cols;s=d(k,t);var c;for(u=0;u<k;u++)for(l=0;l<t;l++){for(m=c=0;m<t;m++)c+=a[m][u]*b[l][m];s[l][u]=c}return s}
function g(a,b,c){for(var f=d(c.length-1,c.length-1),e=0,g=f.length;e<g;e++)for(var h=0;h<g;h++)f[e][h]=e<a?h<b?c[e][h]:c[e][h+1]:e<b?c[e+1][h]:c[e+1][h+1];return f}function b(a){if(1<a.cols){for(var c=0,f=1,e=0,d=a.cols;e<d;e++)c+=f*a[0][e]*b(g(0,e,a)),f=-f;return c}return a[0][0]}if(a.loadLib)return a;var c,n={},f=Math.floor,p,e,q,r;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){p=this.childs.length-1;lastChild=this.childs[p];lastChild.parent=null;this.childs[p]=a;a.parent=this;return a};a.Node.prototype.contains=function(a){if(this.value===a)return!0;for(var b=0,c=this.childs.length;b<c;b++)if(this.childs[b].contains(a))return!0;return!1};a.Node.prototype.equalToMinus=function(){return"compOperator"===this.type?(this.type="operator",
this.value="-",q=new a.Node("compOperator","=="),r=new a.Node("number","0"),q.addChild(this),q.addChild(r),e=this.getRoot(),e.setAllEvaluateFunction(),e):this};a.Node.prototype.setAllEvaluateFunction=function(){this.setEvaluateFunction();for(var a=0,b=this.childs.length;a<b;a++)this.childs[a].setAllEvaluateFunction()};a.Node.prototype.setEvaluateFunction=function(){if("number"===this.type)this.evaluate=function(a){return parseFloat(this.value)};else if("string"===this.type)this.evaluate=function(a){return this.value};
else if("identifier"===this.type&&0===this.childs.length)if("rnd"==this.value)this.evaluate=function(a){return Math.random()};else{var a;this.evaluate=function(b,c){a=b.variables[this.value];if("object"===typeof a)return a.evaluate(b);void 0==a&&(c||b.matrices[this.value]?a=b.matrices[this.value]:b.vectors[this.value]&&(a=b.vectors[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 e,p;this.evaluate=
function(a){e=this.childs[0].childs[0].evaluate(a);try{return p=a.vectors[this.value][0>e?0:f(e)],void 0!==p?p:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var q,m;this.evaluate=function(a){q=this.childs[0].childs[0].evaluate(a);m=this.childs[0].childs[1].evaluate(a);try{return p=a.matrices[this.value][0>q?0:f(q)][0>m?0:f(m)],void 0!==p?p:0}catch(b){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var r;
this.evaluate=function(a){r=[];for(var b=0,f=this.childs[0].childs.length;b<f;b++)r[b]=this.childs[0].childs[b].evaluate(a);return"_Eval_"===this.value?(r[0]=0<r.length?r[0].toString():"",c=r[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,r)}}else if("operator"===this.type)"+"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);if("matrix"!==b.type||
"matrix"!==a.type)return b+a;k=b.rows;t=b.cols;s=d(k,t);for(u=0;u<k;u++)for(l=0;l<t;l++)s[l][u]=b[l][u]+a[l][u];return s}:"-"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);if("matrix"!==b.type||"matrix"!==a.type)return b-a;k=b.rows;t=b.cols;s=d(k,t);for(u=0;u<k;u++)for(l=0;l<t;l++)s[l][u]=b[l][u]-a[l][u];return s}:"*"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);return"matrix"!==
b.type||"matrix"!==a.type?b*a:h(b,a)}:"/"===this.value?this.evaluate=function(a){var c=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);if("matrix"!==c.type||"matrix"!==a.type)return c/a;var f=d(a.length,a.length),e=b(a);if(0===e)a=0;else{var e=1/e,p;if(1<a.length)for(var l=0,q=a.length;l<q;l++){p=e;for(var n=0;n<q;n++)f[n][l]=p*b(g(l,n,a)),p=-p;e=-e}else f[0][0]=e;a=f}c=0===a?d(c.rows,c.cols):h(c,a);return c}:"%"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a);
a=this.childs[1].evaluate(a);return b-f(b/a)*a}:"^"===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 this.childs[0].evaluate(a)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=
function(a){return this.childs[0].evaluate(a)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){return!this.childs[0].evaluate(a)+0});else if("conditional"===this.type)this.evaluate=function(a){return 0<this.childs[0].evaluate(a)?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)this.evaluate=function(a){var b=this.childs.length,c=[],f;if(1===b&&1===this.childs[0].childs.length&&"(expr)"===this.type)c=this.childs[0].childs[0].evaluate(a);else for(var e=0;e<b;e++){f=[];for(var d=0,g=this.childs[e].childs.length;d<g;d++)f.push(this.childs[e].childs[d].evaluate(a));c[e]=f}return c};else if("asign"===this.type){var v,z,H,G,I,L;this.evaluate=function(a){v=this.childs[0];z=this.childs[1];
1===v.childs.length&&"square_bracket"===v.childs[0].type?(e=v.childs[0].childs,1===e.length?(H=e[0].evaluate(a),H=0>H?0:f(H),a.vectors[v.value][H]=z.evaluate(a)):2===e.length&&(G=e[0].evaluate(a),I=e[1].evaluate(a),G=0>G?0:f(G),I=0>I?0:f(I),a.matrices[v.value][G]||(a.matrices[v.value][G]=[]),a.matrices[v.value][G][I]=z.evaluate(a))):(L=z.evaluate(a),L.type?a.matrices[v.value]=L:"object"!==typeof a.variables[v.value]&&(a.variables[v.value]=L))}}};var k,t,s,l,u,m,v;a.Node.prototype.toString=function(){var a=
"tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:"");for(var b=0,c=this.childs.length;b<c;b++)a+=this.sep+this.childs[b].toString();return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f,p,e,q=/^\s+/,r=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,k=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,t=/^==|^!=|^<=|^<|^>=|^>|^#/,s=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,l=/^=/,u=/^[\?\:]/,
m=/^[\+\-\*\/\%\^]/,v=/^\[|^\]/,w=/^\(|^\)/,y=/^,/,C=/^;/,B=/\|/g,D=/\|\*/g,F=/\*\|/g;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function z(a,c,f){h.push({type:a,value:c});n=n.slice(f);b+=f;p++;e=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(F,"'"));a.match(/\=\|/g)&&(a=a.replace(B,"'"));var A=a.trim();"|"==A.charAt(0)&&
"|"==A.charAt(A.length-1)&&(a=A.replace(B,"'"))}h=[];g=!1;b=0;n=a;p=0;for(e="";a&&b<a.length;)if(g=b,"'"==n[0]){for(f=1;"'"!=n[f];)if(f<n.length)f++;else{console.log(">Error, unknown symbol: ["+n+"], in the string <<"+d+">>");return}c=n.substring(1,f);z("string",c,c.length+2)}else if(c=n.match(q))n=n.slice(c[0].length),b+=c[0].length,p++;else if(c=n.match(r))"number"===e&&h.push({type:"operator",value:"*"}),z("identifier",c[0],c[0].length);else if(c=n.match(k))z("number",c[0],c[0].length);else if(c=
n.match(t))A=c[0],"#"==A&&(A="!="),z("compOperator",A,c[0].length);else if(c=n.match(s))A=c[0],"||"==A?A="|":"&&"==A?A="&":"~"==A&&(A="!"),z("boolOperator",A,c[0].length);else if((c=n.match(l))&&!n.match(/^==/))z("asign",c[0],c[0].length);else if(c=n.match(u))z("conditional",c[0],c[0].length);else if(c=n.match(m))z("operator",c[0],c[0].length);else if(c=n.match(v))z("square_bracket",c[0],c[0].length);else if(c=n.match(w))"("==c&&"number"===e&&h.push({type:"operator",value:"*"}),z("parentheses",c[0],
c[0].length);else if(c=n.match(y))z("separator",c[0],c[0].length);else if(178===n.charCodeAt(0))h.push({type:"operator",value:"^"}),z("number",2,1);else if(179===n.charCodeAt(0))h.push({type:"operator",value:"^"}),z("number",3,1);else if(c=n.match(C))z("final_of_expresion",c[0],c[0].length);else if(g==b){console.log("Error, simbolo no conocido: ["+n+"], en la cadena <<"+d+">>");return}return h};var A,z=/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,f=a.length;c<f;c++)A="string"==a[c].type?A+"&squot;"+a[c].value+"&squot;":"identifier"!=a[c].type||a[c].value.match(z)?A+a[c].value:A+b+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,f){this.matrices[a][b][c]=f};a.Parser.prototype.getMatrix=function(a){this.matrices.hasOwnProperty(a)||
(this.matrices[a]=[[0,0,0],[0,0,0],[0,0,0]]);return this.matrices[a]};a.Parser.prototype.setFunction=function(a,b){this.functions[a]=b};a.Parser.prototype.getFunction=function(a){this.functions.hasOwnProperty(a)||(this.functions[a]=function(){return 0});return this.functions[a]};var h,g,b,c,n,f,p,e,q,r,k,t;a.Parser.prototype.parse=function(d,l){(b=this.tokenizer.tokenize(d))||(b=[]);c=null;l=!l||!1;h=e=p=f=0;for(g=b.length;h<g;h++)if(q=b[h],r=q.value,k=q.type,"identifier"===k&&(h+1<g&&"parentheses"===
b[h+1].type&&"("===b[h+1].value?this.getFunction(r):h+1<g&&"square_bracket"===b[h+1].type&&"["===b[h+1].value?b[h+3]&&"square_bracket"===b[h+3].type&&"]"===b[h+3].value?this.getVector(r):this.getMatrix(r):this.getVariable(r)),"asign"===k&&l&&(k="compOperator",r="=="),"asign"===k)if(n=new a.Node(k,r),null!=c)if("identifier"===c.type)c.parent&&c.parent.replaceLastChild(n),n.addChild(c),c=n,l=!0;else if("square_bracket"===c.type)n.addChild(c.parent),c=n,l=!0;else{n.type="compOperator";n.value="==";for(l=
!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: "+r+", tipo: "+k+"}");break}else if("parentheses"===k&&"("===r||"square_bracket"===k&&"["===r)if(n=new a.Node(k,r),"("===r&&f++,"["===r&&p++,null===c)"("===r&&(new a.Node("(expr)","(expr)")).addChild(n),"["===r&&(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 ["+h+"] {valor: "+r+", tipo: "+k+"}");break}else if("parentheses"===k&&")"===r)if(f--,null===c)console.log("Error3: en la expresion <<"+d+">>, en el token (valor:"+r+", tipo:"+k);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: "+r+", tipo: "+k+"}");break}}else if("square_bracket"===k&&"]"===r)if(p--,null===c)console.log("Error5: en la expresion <<"+d+">>, en el token (valor:"+
r+", tipo:"+k);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: "+r+", tipo: "+k+"}");break}}else if("number"===k||"string"===k||"identifier"===k)if(n=new a.Node(k,r),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: "+r+", tipo: "+k+"}");break}else if("operator"===k||"compOperator"===k||"boolOperator"===k)if(n=new a.Node(k,r),null===c)if("-"===r||"+"===r)n.type="sign",n.value="sign"+r,c=n;else if("!"===r)c=n;else{console.log("Error8: en la expresion <<"+d+">>, en el token {valor: "+r+", tipo: "+k+"}");break}else if("operator"===c.type||"compOperator"===c.type||"boolOperator"===c.type||"asign"===c.type||"conditional"===c.type||"square_bracket"===
c.type&&"["===c.value&&("-"===r||"+"===r||"!"===r)||"parentheses"===c.type&&"("===c.value&&("-"===r||"+"===r||"!"===r)){if("-"===r||"+"===r)n.type="sign",n.value="sign"+r;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: "+r+", tipo: "+k+"}");break}else if("conditional"===k)if(n=new a.Node(k,r),null!=c)if("?"===n.value){for(e++;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(e--;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: "+
r+", tipo: "+k+"}");break}}else{console.log("Error11: en la expresion <<"+d+">>, en el token {valor: "+r+", tipo: "+k+"}");break}else if("separator"===k)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: "+r+", tipo: "+k+"}");break}else{console.log("Error13: en la expresion <<"+d+">>, en el token {valor: "+r+", tipo: "+k+"}");break}0<f&&alert("Error, faltan parentesis por cerrar: "+d);0>f&&alert("Error, faltan parentesis por abrir: "+
d);0<p&&alert("Error, faltan square bracketss por cerrar: "+d);0>p&&alert("Error, faltan square bracketss por abrir: "+d);0!=e&&alert("Error, condicional incompleta: "+d);(t=c?c.getRoot():null)&&t.setAllEvaluateFunction();return t};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 f in c)c.hasOwnProperty(f)&&(a[f]=c[f])}this.variables.rnd=Math.random;this.variables.pi=a.returnValue(Math.PI);this.variables.e=a.returnValue(Math.E);this.variables.Infinity=Infinity;this.variables["-Infinity"]=
-Infinity;this.functions.sqr=function(a){return a*a};this.functions.sqrt=this.functions["ra\u00edz"]=Math.sqrt;this.functions.exp=Math.exp;this.functions.log=Math.log;this.functions.log10=function(a){return Math.log(a)/Math.log(10)};this.functions.abs=Math.abs;this.functions.ent=Math.floor;this.functions.sgn=function(a){return 0<a?1:0>a?-1:0};this.functions.ind=function(a){return a?1:0};this.functions.sin=this.functions.sen=Math.sin;this.functions.cos=Math.cos;this.functions.tan=Math.tan;this.functions.cot=
function(a){return 1/Math.tan(a)};this.functions.sec=function(a){return 1/Math.cos(a)};this.functions.csc=function(a){return 1/Math.sin(a)};this.functions.sinh=this.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};this.functions.cosh=function(a){return(Math.exp(a)+Math.exp(-a))/2};this.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/(Math.exp(a)+Math.exp(-a))};this.functions.coth=function(a){return 1/this.functions.tanh(a)};this.functions.sech=function(a){return 1/this.functions.cosh(a)};
this.functions.csch=function(a){return 1/this.functions.sinh(a)};this.functions.asin=this.functions.asen=Math.asin;this.functions.acos=Math.acos;this.functions.atan=Math.atan;this.functions.min=Math.min;this.functions.max=Math.max;this.functions._Num_=function(a){return"number"==typeof a?"NaN":parseFloat(a)==a?parseFloat(a):"NaN"};var c=this;this.functions._Trace_=function(a){console.log(a)};this.functions._Stop_Audios_=function(){c.evaluator.parent.stopAudios()};this.functions.esCorrecto=function(b,
f,e){return a.esCorrecto(b,f,c.evaluator,e)};this.functions.escorrecto=function(b,f,e){return a.escorrecto(b,f,c.evaluator,e)};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,f){var e;if(b){e=(e=document.getElementById(b))&&"descartes/archivo"==e.type?e.text.replace(/&brvbar;/g,String.fromCharCode("166")):a.openExternalFile(b);var d=[],g=!1;if(e){e=e.replace(/\r/g,"").split("\n");for(var h=0,p=e.length;h<p;h++)e[h].match("<"+f+">")?(g=e[h].trim().split("<"+f+">"),2==g.length&&""!=g[1]&&(d=d.concat(g[1].split(String.fromCharCode("166")))),g=!0):e[h].match("</"+f+">")?(g=e[h].trim().split("</"+f+">"),2==g.length&&""!=g[0]&&(d=d.concat(g[0].split(String.fromCharCode("166")))),
g=!1):g&&(d=d.concat(e[h].split(String.fromCharCode("166"))));h=0;for(p=d.length;h<p;h++)g=d[h].split("="),g[0]=g[0].trim(),2==g.length&&""!=g[0]&&(isNaN(parseFloat(g[1]))?c.setVariable(g[0],g[1].replace(/^\s|\s$/g,"").replace(/^'|'$/g,"")):c.setVariable(g[0],parseFloat(g[1])))}return 0}};this.functions._GetMatrix_=function(b,f){var e;if(b){e=(e=document.getElementById(b))&&"descartes/archivo"==e.type?e.text.replace(/&brvbar;/g,String.fromCharCode("166")):a.openExternalFile(b);var g=[],h=!1;g.type=
"matrix";if(e){e=e.replace(/\r/g,"").split("\n");for(var p=0,q=e.length;p<q;p++)e[p].match("<"+f+">")?(h=e[p].trim().split("<"+f+">"),2==h.length&&""!=h[1]&&g.push(h[1].split(String.fromCharCode("166")).map(d)),h=!0):e[p].match("</"+f+">")?(h=e[p].trim().split("</"+f+">"),2==h.length&&""!=h[0]&&g.push(h[0].split(String.fromCharCode("166")).map(d)),h=!1):h&&g.push(e[p].split(String.fromCharCode("166")).map(d));c.matrices[f]=g;c.setVariable(f+".filas",g[0].length);c.setVariable(f+".columnas",g.length)}return 0}};
var f=document.createElement("a"),e;this.functions._Save_=function(a,b){document.body.appendChild(f);e=new Blob([b.replace(/\\n/g,"\n").replace(/\\q/g,"'")],{type:"text/plain"});f.setAttribute("download",a);f.setAttribute("href",window.URL.createObjectURL(e));f.click();document.body.removeChild(f);return 0};var g,h,p,q,n=document.createElement("input");n.setAttribute("type","file");onHandleFileSelect=function(b){g=b.target.files;h=new FileReader;h.onload=function(b){a.addExternalFileContent(g[0].name,
b.target.result);c.setVariable(p,g[0].name);c.getFunction(q)&&(c.getFunction(q).apply(c.evaluator,[]),c.evaluator.parent.update())};0<g.length&&h.readAsText(g[0])};n.addEventListener("change",onHandleFileSelect);this.functions._Open_=function(a,b){p=a;q=b;n.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 r,k,t=document.createElement("input");t.setAttribute("type",
"file");onHandleFileSelect2=function(a){a.stopPropagation();a.preventDefault();r=a.target.files;k=new FileReader;k.onload=function(a){var f={};try{f=JSON.parse(a.target.result)}catch(e){}f.variables&&b(c.variables,f.variables);f.vectors&&b(c.vectors,f.vectors);f.matrices&&b(c.matrices,f.matrices);c.evaluator.parent.update()};0<r.length&&k.readAsText(r[0])};t.removeEventListener("change",onHandleFileSelect2);t.addEventListener("change",onHandleFileSelect2);this.functions._OpenState_=function(){t.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,f,e){return a.getTextWidth(b,a.convertFont(c+","+f+","+e))};this.functions._GetDay_=function(){return(new Date).getDate()};this.functions._GetMonth_=function(){return(new Date).getMonth()+1};this.functions._GetYear_=function(){return(new Date).getFullYear()};
this.functions._GetHours_=function(){return(new Date).getHours()};this.functions._GetMinutes_=function(){return(new Date).getMinutes()};this.functions._GetSeconds_=function(){return(new Date).getSeconds()};this.functions._MatrixToStr_=function(a){var b=this.matrices[a];if(b){strM="<"+a+">\\n";for(var c=0,f=b.rows;c<f;c++){for(var e=0,d=b.cols;e<d;e++)strM+=b[c][e]+(e<d-1?" "+String.fromCharCode("166")+" ":"");strM+="\\n"}return strM+="</"+a+">"}return""}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d=Math.floor;a.Evaluator=function(d){this.parent=d;this.parser=new a.Parser(this);this.variables=this.parser.variables;this.functions=this.parser.functions;this.vectors=this.parser.vectors;this.matrices=this.parser.matrices};a.Evaluator.prototype.setVariable=function(a,d){this.variables[a]=d};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,g,b){g=0>g?0:d(g);this.vectors[a][g]=b};a.Evaluator.prototype.getVector=function(a,g){g=
0>g?0:d(g);return this.vectors[a][g]};a.Evaluator.prototype.setMatrix=function(a,g,b,c){g=0>g?0:d(g);b=0>b?0:d(b);this.matrices[a][g][b]=c};a.Evaluator.prototype.getMatrix=function(a,g,b){g=0>g?0:d(g);b=0>b?0:d(b);return this.matrices[a][g][b]};a.Evaluator.prototype.setFunction=function(a,d){this.functions[a]=d};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a){return a?a.evaluate(this):0};a.externalEvaluator=new a.Evaluator;return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d=2,h=!1,g;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 f=0,g=this.children.length;f<g;f++)this.children[f].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 e=a.getFontMetrics(this.styleString);this.baseline=e.baseline;this.descent=e.descent;this.ascent=e.ascent;this.w=0;this.h=e.h}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);e=a.getFontMetrics(this.styleString);this.baseline=e.baseline;this.descent=e.descent;this.ascent=e.ascent;var f=this.value,q;"string"!=typeof this.value&&(g=void 0==this.decimals?
d:this.evaluator.evalExpression(this.decimals),q=void 0==this.fixed?h:this.fixed,f=this.evaluator.evalExpression(this.value,g,q),parseFloat(f).toString()===f.toString()&&(f=q?parseFloat(f).toFixed(g):a.removeNeedlessDecimals(parseFloat(f).toFixed(g)),f=(""+f).replace(".",this.decimal_symbol)),f+=" ");this.w=a.getTextWidth(f,this.styleString);this.h=e.h}else if("formula"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("hyperlink"===this.nodeType){f=
a.getFontMetrics(this.styleString);this.baseline=f.baseline;this.descent=f.descent;this.ascent=f.ascent;this.w=a.getTextWidth(this.value,this.styleString);this.h=f.h;this.clickCacher=document.createElement("div");this.clickCacher.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; cursor: pointer;");var r=this;this.clickCacher.addEventListener("click",function(a){r.click=!0;window.open(r.URL,r.URL)})}else if("superIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",
this.styleString),g=b,e=c,q=n,f=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=f.ascent,this.descent=f.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),f=q/2-e+this.h,this.superIndexPos=f-this.ascent,this.ascent=f,this.descent=e,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,e=c,q=n,f=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&
(this.ascent=f.ascent,this.descent=f.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),this.subIndexPos=e+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 k=this.children[0],t=this.children[1],f=a.getFontMetrics(k.styleString);k.getBlockMetric();t.getBlockMetric();g=b;e=c;q=n;0>k.h&&(k.h=f.h,k.w=this.spaceWidth);0>t.h&&(t.h=
f.h,t.w=this.spaceWidth);this.h=k.h+t.h-1;this.ascent=k.h+Math.round(q/2)-e;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=Math.max(k.w,t.w)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);e=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator," ","radicand",e),this.children[1].addChild(this.children[0]),this.children[0]=new a.RTFNode(this.evaluator," ","index",e);else if("index"!==
this.children[0].nodeType||"radicand"!==this.children[1].nodeType){q=new a.RTFNode(this.evaluator,"","radicand",e);f=0;for(g=this.children.length;f<g;f++)q.addChild(this.children[f]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",e);this.children[1]=q}f=this.children[0];g=this.children[1];0>=f.children.length&&(e=this.style.clone(),e.fontSize=parseInt(e.fontSize-0.2*e.fontSize),f.addChild(new a.RTFNode(this.evaluator," ","text",e)));0>=g.children.length&&g.addChild(new a.RTFNode(this.evaluator,
" ","text",this.style.clone()));f.getBlockMetric();g.getBlockMetric();this.ascent=g.h/2<f.h?g.h/2+f.h+2-g.descent:g.ascent+4;this.descent=g.descent;this.baseline=this.ascent;this.h=this.ascent+this.descent;this.w=f.w+g.w+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,e=c,q=n,e=this.children[0],g=this.children[1],q=this.children[2],e.getBlockMetric(),g.getBlockMetric(),q.getBlockMetric(),-1==e.ascent&&(k=a.getFontMetrics(e.styleString),e.ascent=
k.ascent,e.descent=k.descent,e.h=k.h),-1==g.ascent&&(k=a.getFontMetrics(g.styleString),g.ascent=k.ascent,g.descent=k.descent,g.h=k.h),f=a.getFontMetrics(this.styleString),this.ascent=f.h+g.h>q.ascent?f.h-f.descent+g.h:q.ascent,this.descent=e.h>q.descent?e.h+f.descent:q.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,f=this.style.clone(),f.fontType="Times New Roman",f.Bold="bold",f=f.toString(),f=a.getTextWidth(String.fromCharCode(8721),f),this.w=Math.max(e.w,g.w,f)+Math.max(q.w,
this.spaceWidth)+this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,e=c,q=n,e=this.children[0],g=this.children[1],q=this.children[2],e.getBlockMetric(),g.getBlockMetric(),q.getBlockMetric(),-1==e.ascent&&(k=a.getFontMetrics(e.styleString),e.ascent=k.ascent,e.descent=k.descent,e.h=k.h),-1==g.ascent&&(k=a.getFontMetrics(g.styleString),g.ascent=k.ascent,g.descent=k.descent,g.h=k.h),f=a.getFontMetrics(this.styleString),this.ascent=f.h+g.h>q.ascent?
f.h-f.descent+g.h:q.ascent,this.descent=e.h>q.descent?e.h+f.descent:q.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,f=this.style.clone(),f.fontSize*=1.5,f.fontType="Times New Roman",f.Bold="bold",f=f.toString(),f=a.getTextWidth(String.fromCharCode(8747),f),this.w=Math.max(e.w,g.w,f)+Math.max(q.w,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),g=b,e=c,q=n,e=this.children[0],g=this.children[1],q=this.children[2],
f=a.getFontMetrics(this.styleString),e.getBlockMetric(),g.getBlockMetric(),q.getBlockMetric(),-1==e.ascent&&(k=a.getFontMetrics(e.styleString),e.ascent=k.ascent,e.descent=k.descent,e.h=k.h),-1==g.ascent&&(k=a.getFontMetrics(g.styleString),g.ascent=k.ascent,g.descent=k.descent,g.h=k.h),-1==q.ascent&&(k=a.getFontMetrics(q.styleString),q.ascent=k.ascent,q.descent=k.descent,q.h=k.h),this.ascent=q.ascent,this.descent=Math.max(f.h,q.descent),this.baseline=this.ascent,this.h=this.ascent+this.descent,f=a.getTextWidth(" "+
String.fromCharCode(8594),this.styleString),0==e.w&&(e.w=this.spaceWidth),0==g.w&&(g.w=this.spaceWidth),0==q.w&&(q.w=this.spaceWidth),this.w=g.w+e.w+q.w+f+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);g=b;e=c;q=n;q=f.ascent;for(var k=f.descent,t=f.h,s=this.spaceWidth,l,u,f=0,g=this.children.length;f<g;f++)this.children[f].getBlockMetric(),l=this.children[f].h,u=this.children[f].w,t<l&&(t=l,q=this.children[f].ascent,
k=this.children[f].descent),s<u&&(s=u);this.childWidth=s+2*this.spaceWidth;this.childh=t;this.childAscent=q;this.childDescent=k;this.h=this.rows*t;this.ascent=this.h/2+e;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);f=a.getFontMetrics(this.styleString);g=b;e=c;q=n;q=f.ascent;k=f.descent;t=f.h;s=this.spaceWidth;f=0;for(g=this.children.length;f<g;f++)this.children[f].getBlockMetric(),
l=this.children[f].h,u=this.children[f].w,t<l&&(t=l,q=this.children[f].ascent,k=this.children[f].descent),s<u&&(s=u);this.childWidth=s+2*this.spaceWidth;this.childh=t;this.childAscent=q;this.childDescent=k;this.h=this.parts*t;this.ascent=this.h/2+e;this.descent=this.h-this.ascent;this.w=s+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),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.spaceWidth,this.h=e.h):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),e=this.componentNumCtrl.h||0,this.baseline=Math.round(3*e/5),this.descent=Math.round(2*e/5),this.ascent=this.baseline,this.h=e,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,g=-1,e,d=0,h=this.children.length;d<h;d++){e=this.children[d];e.getTextMetrics();childAscent=e.ascent;childDescent=e.descent;this.w+=e.w;var k=childDescent;e=e.h;b=childAscent;c=k;n=e;g<childAscent&&(g=childAscent);a<childDescent&&(a=childDescent)}this.ascent=g;this.descent=a;this.baseline=this.ascent;this.h=
this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,b,c,q,n,k,t,s){g=s;this.stableWidth||(d=q,h=n,this.getTextMetrics());t=t?-this.children[0].ascent:0;n=q=0;for(k=this.children.length;n<k;n++)0<n&&(q+=this.children[n-1].h),this.children[n].draw(a,b+0,c+t+q)};a.RTFNode.prototype.drawTextLineBlock=function(a,b,c){for(var d=0,h=0,n=this.children.length;h<n;h++)a.strokeStyle=g,a.fillStyle=g,0<h&&(d+=this.children[h-1].w,"formula"==this.children[h-1].nodeType&&(d+=2*this.children[h-
1].spaceWidth)),this.children[h].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,c){for(var d=0,g=0,h=this.children.length;g<h;g++)0<g&&(d+=this.children[g-1].w),this.children[g].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 g="bold"==this.style.textBold,d=g?1:0.5;a.lineWidth=g?
2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b-1,parseInt(c+this.descent/2)+d);a.lineTo(b-1+this.w,parseInt(c+this.descent/2)+d);a.stroke()}this.overline&&(d=(g="bold"==this.style.textBold)?2:1.5,a.lineWidth=g?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(b-1,parseInt(c-this.ascent)+d),a.lineTo(b-1+this.w,parseInt(c-this.ascent)+d),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,c,e){var g=Math.floor(0.5*this.spaceWidth),n=void 0==this.decimals?
d:this.evaluator.evalExpression(this.decimals),k=void 0==this.fixed?h:this.fixed,t=this.evaluator.evalExpression(this.value);parseFloat(t).toString()===t.toString()&&(t=k?parseFloat(t).toFixed(n):a.removeNeedlessDecimals(parseFloat(t).toFixed(n)),t=(""+t).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(t,this.styleString);b.fillText(t,g+c,e);this.underline&&(k=(n="bold"==this.style.textBold)?
1:0.5,b.lineWidth=n?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(g+c-1,parseInt(e+this.descent/2)+k),b.lineTo(g+c-1+this.w,parseInt(e+this.descent/2)+k),b.stroke());this.overline&&(k=(n="bold"==this.style.textBold)?2:1.5,b.lineWidth=n?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(g+c-1,parseInt(e-this.ascent)+k),b.lineTo(g+c-1+this.w,parseInt(e-this.ascent)+k),b.stroke());this.w+=2*g};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 g="bold"==this.style.textBold,
d=g?1:0.5;a.lineWidth=g?2:1;a.beginPath();a.moveTo(b-1,Math.ceil(c+this.descent/2)+d-2);a.lineTo(b-1+this.w,Math.ceil(c+this.descent/2)+d-2);a.stroke();a.restore()};a.RTFNode.prototype.drawRadical=function(a,b,c){var g=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*g+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*g,c+this.children[1].descent);a.lineTo(b+this.children[0].w+1*g,c-this.children[1].ascent);a.lineTo(b+this.children[0].w+2*g+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 g=Math.floor(0.5*this.spaceWidth);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b+g,parseInt(c-this.ascent+this.children[0].h)-0.5);a.lineTo(b-g+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 g=0,d=0,h=this.children.length;d<h;d++)0<d&&(g+=this.children[d-1].w),this.children[d].draw(a,b+g,c+this.baseline)};a.RTFNode.prototype.drawSubIndex=
function(a,b,c){for(var g=0,d=0,h=this.children.length;d<h;d++)0<d&&(g+=this.children[d-1].w),this.children[d].draw(a,b+g,c+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,c){for(var g=0,d=0,h=this.children.length;d<h;d++)0<d&&(g+=this.children[d-1].w),this.children[d].draw(a,b+g,c-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,c,e){var g=a.getFontMetrics(this.styleString),d=" "+String.fromCharCode(8594),h=a.getTextWidth(d,this.styleString);this.children[0].draw(b,
c,e+g.descent+this.children[0].ascent);this.children[1].draw(b,c+this.children[0].w+h,e+g.descent+this.children[1].ascent);this.children[2].draw(b,c+h+this.children[0].w+this.children[1].w,e);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,e);b.fillText(d,c+this.children[0].w,e+g.descent+this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(b,c,e){var g=this.style.clone();g.fontSize*=
1.5;g.fontType="Times New Roman";g.Bold="bold";var g=g.toString(),d=a.getTextWidth(String.fromCharCode(8747),g),h=a.getFontMetrics(g),n=Math.max(this.children[0].w,this.children[1].w,Math.floor(1.5*d));this.children[0].draw(b,c+d,e+h.descent+this.children[0].ascent);this.children[1].draw(b,c+d+this.spaceWidth/2,e-this.ascent+this.children[1].ascent);this.children[2].draw(b,c+n+d,e);null!=this.color&&(b.fillStyle=this.color);b.font=g;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),
c,e+h.descent/2)};a.RTFNode.prototype.drawSum=function(b,c,e){var g=this.style.clone();g.fontType="Times New Roman";g.Bold="bold";var g=g.toString(),d=a.getTextWidth(String.fromCharCode(8721),g),h=a.getFontMetrics(this.styleString),n=Math.max(this.children[0].w,this.children[1].w,d);this.children[0].draw(b,c+(n-this.children[0].w)/2,e+h.descent+this.children[0].ascent);this.children[1].draw(b,c+(n-this.children[1].w)/2,e-h.ascent-this.children[1].descent);this.children[2].draw(b,c+n,e);null!=this.color&&
(b.fillStyle=this.color);b.font=g;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),c+Math.floor((n-d)/2),e-5)};a.RTFNode.prototype.drawMatrix=function(a,b,c){for(var g,d,h=0,n=this.children.length;h<n;h++)g=h%this.columns,d=Math.floor(h/this.columns),this.children[h].draw(a,2*this.spaceWidth+b+g*this.childWidth,c-this.ascent+this.childAscent+d*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 g=0,d=this.children.length;g<d;g++)this.children[g].draw(a,b+3*this.spaceWidth,c-this.ascent+this.childAscent+g%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 g=0,d=0,h=this.children.length;d<h;d++)0<d&&(g+=this.children[d-1].w),this.children[d].draw(a,b+g,c)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,b,c){this.parent.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+
b+","+(c-this.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,b,c){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(b+"");this.componentSpace.yExpr=this.evaluator.parser.parse(c-this.parent.ascent+"")};a.RTFNode.prototype.draw=function(a,b,c){console.log(">>> Dibujo desconocido ",this.nodeType)};a.RTFNode.prototype.toHTML=function(){var a="";if("textLineBlock"===this.nodeType||"textBlock"===this.nodeType)for(var b=
0,c=this.children.length;b<c;b++)a+=this.children[b].toHTML();else"text"===this.nodeType?a="<span "+this.style.toCSS()+">"+this.value+"</span>":"newLine"===this.nodeType&&(a="<span "+this.style.toCSS()+">"+this.value+"<br /></span>");return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=String.fromCharCode,h,g,b,c,n,f,p,e,q,r,k;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=function(a){if(a)a=a.replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&quote;/g,
"''").replace(/\&squot;/g,"'").replace(/\\rquote /g,"'").replace(/\\endash /g,"-").replace(/\n/g," ").replace(/\r/g,"").replace(/\\uc(\d+) /g,"").replace(/\\uc(\d+)/g,"");else return[];h=[];g=a.length;h=[];b="";n=c=0;p=a.charAt(0);e=!1;for(q="text";c<g;)f=p,p=a.charAt(c+1),e?"\\"===p||"{"===p||"}"===p||" "===p||";"===p?(e=!1,b+=f," "===p&&(c++,p=a.charAt(c+1)),(r=b.match(/^\'([0-9a-f]{2})/))?(k="","text"===q&&(k=h.pop().value),b=k+=d(parseInt(r[1],16))+b.substring(3)):(r=b.match(/^u[0-9]+/))?(k="",
"text"===q&&(k=h.pop().value),b=k+=d(r[0].substring(1))):("{"===b||"}"===b?(h.push({type:"text",value:b}),q="text"):(h.push({type:"controlWord",value:b}),q="controlWord"),b="")):b+=f:"\\"===f?(e=!0,""!==b&&(h.push({type:"text",value:b}),q="text"),b=""):"{"===f?(n++,""!==b&&h.push({type:"text",value:b}),b="",h.push({type:"openBlock",value:n}),q="openBlock"):"}"===f?(""!==b&&h.push({type:"text",value:b}),b="",h.push({type:"closeBlock",value:n}),q="closeBlock",n--):b+=f,c++;""!==b&&h.push({type:"text",
value:b});return h};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f,p,e,q,r,k,t,s,l,u,m,v,w,y,C,B,D,F,A,z,H,G,I,L;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=new a.RTFTokenizer};a.RTFParser.prototype.parse=function(x){x=d=this.tokenizer.tokenize(x);for(var J=[],E=!1,Q=!1,N=[],K=0,R=x.length;K<R;K++)if("openBlock"==x[K].type&&N.push(x[K].value),"closeBlock"==x[K].type&&(N.pop(),0>=N.length&&(E=!1)),"controlWord"!=x[K].type||"expr"!=x[K].value&&
"decimals"!=x[K].value||(Q=!0),"controlWord"==x[K].type&&"mjaformula"==x[K].value&&(E=!0),"text"==x[K].type&&E&&!Q){for(var S=0,O=x[K].value,P="",M=0,V=O.length;M<V;M++)if("("==O.charAt(M)||")"==O.charAt(M)||"+"==O.charAt(M)||"-"==O.charAt(M)||"*"==O.charAt(M)||"="==O.charAt(M))P=O.substring(S,M),""!=P&&J.push({type:"text",value:P}),J.push({type:O.charAt(M),value:O.charAt(M)}),S=M+1;P=O.substring(S,M);""!=P&&J.push({type:"text",value:P})}else J.push(x[K]),"text"==x[K].type&&Q&&(Q=!1);d=J;h={};b=2;
if("openBlock"==d[0].type&&"fonttbl"==d[1].value){for(g=d[0].value;"closeBlock"!=d[b].type&&d[b].value!=g;)h[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){g=d[b++].value;for(b++;"closeBlock"!=d[b].type&&d[b].value!=g;)f=parseInt(d[b++].value.substring(3)).toString(16),p=parseInt(d[b++].value.substring(5)).toString(16),e=parseInt(d[b++].value.substring(4)).toString(16),";"===d[b].value&&b++,c[n++]="#"+(2>f.length?
"0"+f:f)+(2>p.length?"0"+p:p)+(2>e.length?"0"+e:e);b++}q=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");r=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");q.addChild(r);s=t=k=null;y=w=v=m=u=l=!1;C=[new a.FontStyle(20,"Arial","","",!1,!1,null)];B=C[0];D=!0;A=F=-1;z=[];L=I=G=H=!1;x=b;for(J=d.length;x<J;x++)if("controlWord"==d[x].type&&h[d[x].value])B.fontType=h[d[x].value];else if("controlWord"==d[x].type&&d[x].value.match(/^fs(\d+)/))B.fontSize=parseInt(d[x].value.match(/^fs(\d+)/)[1]/
2);else if("controlWord"==d[x].type&&"b"==d[x].value)B.textBold="bold";else if("controlWord"==d[x].type&&"b0"==d[x].value)B.textBold="";else if("controlWord"==d[x].type&&"i"==d[x].value)B.textItalic="italic";else if("controlWord"==d[x].type&&"i0"==d[x].value)B.textItalic="";else if("controlWord"==d[x].type&&"ul"==d[x].value)B.textUnderline=!0;else if("controlWord"==d[x].type&&"ulnone"==d[x].value)B.textUnderline=!1;else if("controlWord"==d[x].type&&"ol"==d[x].value)B.textOverline=!0;else if("controlWord"==
d[x].type&&"olnone"==d[x].value)B.textOverline=!1;else if("controlWord"==d[x].type&&d[x].value.match(/^cf(\d+)/))B.textColor=c[parseInt(d[x].value.substring(2))],0<z.length&&(z[z.length-1].style.textColor=B.textColor);else if("openBlock"==d[x].type)F=d[x].value,B=B.clone(),C.push(B),z.push(null);else if("closeBlock"==d[x].type)d[x].value==A&&(A=-1,l=!1,r=r.parent),C.pop(),B=C[C.length-1],z.pop();else if("controlWord"==d[x].type&&"par"==d[x].value){r.addChild(new a.RTFNode(this.evaluator,"","newLine",
B.clone()));q=new a.RTFNode(this.evaluator,"","textLineBlock",B.clone());if("textBlock"!=r.nodeType)for(r=r.parent;"textBlock"!=r.nodeType;)r=r.parent;r.addChild(q);r=q}else if("controlWord"==d[x].type&&"mjaformula"==d[x].value)H=!0,A=F,l=!0,q=new a.RTFNode(this.evaluator,"","formula",B.clone()),r.addChild(q),r=q,z[z.length-1]=q;else if("controlWord"==d[x].type&&("fraction"==d[x].value||"radicand"==d[x].value||"radical"==d[x].value||"what"==d[x].value||"sum"==d[x].value||"integral"==d[x].value||"limit"==
d[x].value))E=z[z.length-2].style.clone(),q=new a.RTFNode(this.evaluator,"",d[x].value,E),z[z.length-2].addChild(q),z[z.length-1]=q;else if("controlWord"==d[x].type&&"index"==d[x].value||"to"==d[x].value||"from"==d[x].value)E=z[z.length-2].style.clone(),E.fontSize=parseInt(E.fontSize-0.2*E.fontSize),8>E.fontSize&&(E.fontSize=8),q=new a.RTFNode(this.evaluator,"",d[x].value,E),z[z.length-2].addChild(q),z[z.length-1]=q;else if("controlWord"==d[x].type&&("num"==d[x].value||"den"==d[x].value))E=z[z.length-
2].style.clone(),E.fontSize=Math.round(E.fontSize-0.1*E.fontSize),8>E.fontSize&&(E.fontSize=8),"num"==d[x].value?q=new a.RTFNode(this.evaluator,"","numerator",E):"den"==d[x].value&&(q=new a.RTFNode(this.evaluator,"","denominator",E)),z[z.length-2].addChild(q),z[z.length-1]=q;else if("controlWord"==d[x].type&&("subix"==d[x].value||"supix"==d[x].value))E=z[z.length-2].style.clone(),E.fontSize=Math.floor(E.fontSize-E.fontSize/3),8>E.fontSize&&(E.fontSize=8),"subix"==d[x].value?q=new a.RTFNode(this.evaluator,
"","subIndex",E):"supix"==d[x].value&&(q=new a.RTFNode(this.evaluator,"","superIndex",E)),q.originalStyle=z[z.length-2].style.clone(),z[z.length-2].addChild(q),z[z.length-1]=q;else if("controlWord"==d[x].type&&("defparts"==d[x].value||"matrix"==d[x].value||"element"==d[x].value))E=z[z.length-2].style.clone(),q=new a.RTFNode(this.evaluator,"",d[x].value,E),z[z.length-2].addChild(q),z[z.length-1]=q,"defparts"==d[x].value?s=q:"matrix"==d[x].value&&(t=q);else if("controlWord"==d[x].type&&"parts"==d[x].value)y=
!0;else if("text"==d[x].type&&y)s.parts=parseInt(d[x].value),y=!1;else if("controlWord"==d[x].type&&"rows"==d[x].value)v=!0;else if("text"==d[x].type&&v)t.rows=parseInt(d[x].value),v=!1;else if("controlWord"==d[x].type&&"columns"==d[x].value)w=!0;else if("text"==d[x].type&&w)t.columns=parseInt(d[x].value),w=!1;else if("controlWord"==d[x].type&&"expr"==d[x].value)D=!1,u=!0;else if("controlWord"==d[x].type&&"decimals"==d[x].value)m=!0;else if("text"==d[x].type&&m)k.decimals=this.evaluator.parser.parse(d[x].value+
""),m=!1;else if("controlWord"==d[x].type&&"fixed1"==d[x].value)k.fixed=!0;else if("controlWord"==d[x].type&&"fixed0"==d[x].value)k.fixed=!1;else if("controlWord"!=d[x].type||"component"!=d[x].value)if("controlWord"==d[x].type&&"NumCtrl"==d[x].value)G=!0;else if("controlWord"==d[x].type&&"Space"==d[x].value)I=!0;else if("controlWord"==d[x].type&&"hyperlink"==d[x].value)L=!0;else if("text"==d[x].type&&L){textContent=d[x].value.split("|")[0];E=B.clone();q=new a.RTFNode(this.evaluator,textContent,"hyperlink",
E);q.URL=d[x].value.split("|")[1];if("textLineBlock"!=r.nodeType)for(r=r.parent;"textLineBlock"!=r.nodeType;)r=r.parent;r.addChild(q);L=!1}else if("text"==d[x].type&&G)q=new a.RTFNode(this.evaluator,d[x].value,"componentNumCtrl",B.clone()),r.addChild(q),G=!1;else if("text"==d[x].type&&I)q=new a.RTFNode(this.evaluator,d[x].value,"componentSpace",B.clone()),r.addChild(q),I=!1;else if("text"==d[x].type&&u)E=z[z.length-2].style.clone(),textContent=this.evaluator.parser.parse(d[x].value),q=new a.RTFNode(this.evaluator,
textContent,"dynamicText",E),z[z.length-2].addChild(q),k=z[z.length-1]=q,u=!1;else if("text"==d[x].type&&!u&&!l){textContent=d[x].value;q=new a.RTFNode(this.evaluator,textContent,"text",B.clone());if("textLineBlock"!=r.nodeType)for(r=r.parent;"textLineBlock"!=r.nodeType;)r=r.parent;r.addChild(q)}else if("text"==d[x].type&&!u&&l)textContent=d[x].value,q=new a.RTFNode(this.evaluator,textContent,"text",z[z.length-1].style.clone()),z[z.length-1].addChild(q);else if("("==d[x].type||")"==d[x].type)E=z[z.length-
1].style.clone(),E.textItalic="",q=new a.RTFNode(this.evaluator,d[x].type,"mathSymbol",E),z[z.length-1].addChild(q);else if("+"==d[x].type||"-"==d[x].type||"*"==d[x].type||"="==d[x].type)q=new a.RTFNode(this.evaluator,d[x].type,"mathSymbol",z[z.length-1].style.clone()),z[z.length-1].addChild(q);if(null!=r){var U=r.getRoot();U.stableWidth=D;U.getTextMetrics();U.hasFormula=H}return U};a.FontStyle=function(a,b,c,e,f,g,d){this.fontSize=a;this.fontType=b;this.textItalic=c;this.textBold=e;this.textUnderline=
f;this.textOverline=g;this.textColor=d};a.FontStyle.prototype.toString=function(){return(this.textBold+" "+this.textItalic+" "+this.fontSize+"px "+this.fontType).trim()};a.FontStyle.prototype.toCSS=function(){var a="style='font: "+this.fontSize+"px "+this.fontType+"; ";this.textUnderline&&!this.textOverline&&(a+="text-decoration: underline; ");!this.textUnderline&&this.textOverline&&(a+="text-decoration: overline; ");this.textUnderline&&this.textOverline&&(a+="text-decoration: underline overline; ");
this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: bold; ");!this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: normal; ");this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: bold; ");this.textBold||this.textItalic||(a+="font-style: normal; font-weight: normal; ");this.textColor&&(a+="color: "+this.textColor+"; ");return a+"'"};a.FontStyle.prototype.clone=function(){return new a.FontStyle(this.fontSize,this.fontType,this.textItalic,this.textBold,
this.textUnderline,this.textOverline,this.textColor)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b,c,n,f,p,e,q,r,k,t,s;a.Space=function(b,c){this.parent=b;h=this.evaluator=this.parent.evaluator;g=h.parser;this.id="";this.values=c;this.type="R2";this.xExpr=g.parse("0");this.yExpr=g.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=g.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 e in c)c.hasOwnProperty(e)&&(this[e]=c[e]);this.init()};a.Space.prototype.init=function(){d=this.parent;h=this.evaluator;b=this.id;this.displaceRegionNorth=d.displaceRegionNorth||0;this.displaceRegionWest=d.displaceRegionWest||
0;void 0!=this.wExpr&&(this.w=(parseInt(d.container.width)-this.displaceRegionWest)*parseFloat(this.wExpr)/100);void 0!=this.hExpr&&(this.h=(parseInt(d.container.height)-this.displaceRegionNorth)*parseFloat(this.hExpr)/100);f=parseInt(d.container.height);p=parseInt(d.container.width);this.x=h.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=h.evalExpression(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+"px",this.container.style.top=
this.y+"px");0<=this.y?(c=f-this.y,this.h>c&&(this.h=c)):(c=this.h+this.y,this.h=c>=f?f:c);0<=this.x?(n=p-this.x,this.w>n&&(this.w=n)):(n=this.w+this.x,this.w=n>=p?p:n);""==this.imageSrc&&this.imageSrc.trim().toLowerCase().match(/vacio.gif$/)||(this.image=d.getImage(this.imageSrc));this.OxExpr&&(q=this.OxExpr,"%"===q[q.length-1]?this.Ox=this.w*parseFloat(q)/100:(e=parseFloat(q),e!=q&&(e=0),this.Ox=e));this.OyExpr&&(r=this.OyExpr,"%"===r[r.length-1]?this.Oy=this.h*parseFloat(r)/100:(e=parseFloat(r),
e!=r&&(e=0),this.Oy=e));""!==this.id&&2!==d.version?(h.setVariable(b+"._w",this.w),h.setVariable(b+"._h",this.h),h.setVariable(b+".escala",this.scale),h.setVariable(b+".Ox",this.Ox),h.setVariable(b+".Oy",this.Oy),h.setVariable(b+".mouse_x",0),h.setVariable(b+".mouse_y",0),h.setVariable(b+".mouse_pressed",0),h.setVariable(b+".mouse_clicked",0),h.setVariable(b+".clic_izquierdo",0)):(e=h.getVariable("_w"),void 0===e&&(e=this.w),h.setVariable("_w",e),e=h.getVariable("_h"),void 0===e&&(e=this.h),h.setVariable("_h",
e),e=h.getVariable("escala"),void 0===e&&(e=this.scale),h.setVariable("escala",e),e=h.getVariable("Ox"),void 0===e&&(e=this.Ox),h.setVariable("Ox",e),e=h.getVariable("Oy"),void 0===e&&(e=this.Oy),h.setVariable("Oy",e),h.setVariable("mouse_x",0),h.setVariable("mouse_y",0),h.setVariable("mouse_pressed",0),h.setVariable("mouse_clicked",0),h.setVariable("clic_izquierdo",0),""===this.x_axis&&""===this.y_axis&&2==d.version&&(this.axes=""));this.w_2=this.w/2;this.h_2=this.h/2};a.Space.prototype.addCtr=function(a){"graphic"===
a.type?this.graphicsCtr.push(a):this.ctrs.push(a)};a.Space.prototype.addGraph=function(a,b){"R2"==this.type&&b||"R3"==this.type&&!b||(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(){k=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(t=this.container.style.display);this.container.style.display="block";if(k.getBoundingClientRect){var a=k.getBoundingClientRect();this.offsetLeft=a.left;this.offsetTop=a.top}else for(;k;)k.tagName&&
"html"!==k.tagName.toLowerCase()?(this.offsetLeft+=k.offsetLeft||0,this.offsetTop+=k.offsetTop||0,k=k.parentNode):k=null;this.container&&this.container.style&&(this.container.style.display=t)};a.Space.prototype.getCursorPosition=function(b){s=a.getCursorPosition(b);return{x:s.x-this.offsetLeft,y:s.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("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: #000 0px 0px 25px 5px; overflow-y: scroll; overflow-x: hidden; position: fixed; 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)+"px; 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 d(c){b.newPosition=a.getCursorPosition(c);b.container.style.left=b.initialPosition.x+(b.newPosition.x-b.oldPosition.x)+"px";b.container.style.top=b.initialPosition.y+(b.newPosition.y-b.oldPosition.y)+
"px"}function g(a){a.preventDefault();b.findOffset();document.body.removeEventListener("mousemove",d);document.body.removeEventListener("mouseup",g)}document.body.appendChild(this.container);var b=this,c=b.parent.evaluator.parser,n;n=0;for(var f=b.ctrs.length;n<f;n++)b.ctrs[n].expresion=c.parse("(0,"+(b.vSpace+23+35*n)+","+b.width+",35)"),b.ctrs[n].update();b.numCtr=f;n="espa\u00f1ol"==b.language?"cr\u00e9ditos":"english"==b.language?"about":"cr\u00e9ditos";n=new a.Button(b.parent,{region:"external",
name:n,font_size:c.parse("15"),expresion:c.parse("(0,"+b.vSpace+","+b.width/2+",25)")});n.actionExec={execute:a.showAbout};n.update();(new a.Button(b.parent,{region:"external",name:"config",font_size:c.parse("15"),action:"config",expresion:c.parse("("+b.width/2+","+b.vSpace+","+b.width/2+",25)")})).update();n="espa\u00f1ol"==b.language?"inicio":"english"==b.language?"init":"inicio";(new a.Button(b.parent,{region:"external",name:n,font_size:c.parse("15"),action:"init",expresion:c.parse("(0,"+(b.vSpace+
23+35*f)+","+b.width/2+",25)")})).update();n="espa\u00f1ol"==b.language?"limpiar":"english"==b.language?"clear":"limpiar";(new a.Button(b.parent,{region:"external",name:n,font_size:c.parse("15"),action:"clear",expresion:c.parse("("+b.width/2+","+(b.vSpace+23+35*f)+","+b.width/2+",25)")})).update();n="espa\u00f1ol"==b.language?"cerrar":"close";c=new a.Button(b.parent,{region:"external",name:n,font_size:c.parse("15"),expresion:c.parse("("+b.width/4+","+(b.vSpace+46+35*f)+","+b.width/2+",25)")});c.update();
c.canvas.addEventListener("click",function(a){b.hide()});b.setPositionAndSize();b.moveManipulator.addEventListener("mousedown",function(c){c.preventDefault();b.oldPosition=a.getCursorPosition(c);b.initialPosition={x:b.container.offsetLeft,y:b.container.offsetTop};document.body.addEventListener("mousemove",d);document.body.addEventListener("mouseup",g)});b.findOffset();b.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,g=this.ctrs.length;a<g;a++)this.ctrs[a].findOffset&&this.ctrs[a].findOffset()};return a}(descartesJS||{}),descartesJS=function(a){var d,h;if(a.loadLib)return a;var g=Math.floor,b=Math.round,c=2*Math.PI,n=a.convertFont("SansSerif,PLAIN,12"),f=a.convertFont("Monospaced,PLAIN,12"),p=10,e,q,r,k,t,s,l,u,m,v,w,y,C,B,D,F,A,z,H,G,I,L,x,J,E,Q,N,K,R;a.Space2D=function(b,c){a.Space.call(this,
b,c);e=this;e.backgroundCanvas=document.createElement("canvas");e.backgroundCanvas.setAttribute("id",e.id+"_background");e.backgroundCanvas.setAttribute("width",e.w+"px");e.backgroundCanvas.setAttribute("height",e.h+"px");e.backgroundCtx=e.backgroundCanvas.getContext("2d");e.backgroundCtx.imageSmoothingEnabled=!1;e.backgroundCtx.mozImageSmoothingEnabled=!1;e.backgroundCtx.webkitImageSmoothingEnabled=!1;e.canvas=document.createElement("canvas");e.canvas.setAttribute("id",e.id+"_canvas");e.canvas.setAttribute("width",
e.w+"px");e.canvas.setAttribute("height",e.h+"px");e.canvas.setAttribute("class","DescartesSpace2DCanvas");e.canvas.setAttribute("style","z-index: "+e.zIndex+";");e.ctx=e.canvas.getContext("2d");e.ctx.imageSmoothingEnabled=!1;e.ctx.mozImageSmoothingEnabled=!1;e.ctx.webkitImageSmoothingEnabled=!1;e.graphicControlContainer=document.createElement("div");e.graphicControlContainer.setAttribute("id",e.id+"_graphicControls");e.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+
e.zIndex+";");e.numericalControlContainer=document.createElement("div");e.numericalControlContainer.setAttribute("id",e.id+"_numericalControls");e.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+e.zIndex+";");e.container=document.createElement("div");e.container.setAttribute("id",e.id);e.container.setAttribute("class","DescartesSpace2DContainer");e.container.setAttribute("style","left: "+e.x+"px; top: "+e.y+"px; z-index: "+e.zIndex+";");e.parent.arquimedes&&
"#f0f8fa"===e.background.getColor()&&(e.container.style.border="1px solid #b8c4c8");e.container.appendChild(e.backgroundCanvas);e.container.appendChild(e.canvas);e.container.appendChild(e.graphicControlContainer);e.container.appendChild(e.numericalControlContainer);b.container.insertBefore(e.container,b.loader);e.parent.images[e.id+".image"]=e.canvas;e.parent.images[e.id+".image"].ready=1;e.parent.images[e.id+".image"].complete=!0;e.evaluator.setVariable(e.id+".image",e.id+".image");e.parent.images[e.id+
".back"]=e.backgroundCanvas;e.parent.images[e.id+".back"].ready=1;e.parent.images[e.id+".back"].complete=!0;e.evaluator.setVariable(e.id+".back",e.id+".back");""!==e.id&&2!==b.version?(e.OxString=e.id+".Ox",e.OyString=e.id+".Oy",e.scaleString=e.id+".escala",e.wString=e.id+"._w",e.hString=e.id+"._h",e.mxString=e.id+".mouse_x",e.myString=e.id+".mouse_y",e.mpressedString=e.id+".mouse_pressed",e.mclickedString=e.id+".mouse_clicked",e.mclicizquierdoString=e.id+".clic_izquierdo"):(e.OxString="Ox",e.OyString=
"Oy",e.scaleString="escala",e.wString="_w",e.hString="_h",e.mxString="mouse_x",e.myString="mouse_y",e.mpressedString="mouse_pressed",e.mclickedString="mouse_clicked",e.mclicizquierdoString="clic_izquierdo");e.click=0;e.registerMouseAndTouchEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){e=this;e.uber.init.call(e);e.canvas&&(e.backgroundCanvas.setAttribute("width",e.w+"px"),e.backgroundCanvas.setAttribute("height",e.h+"px"),e.canvas.setAttribute("width",e.w+"px"),e.canvas.setAttribute("height",
e.h+"px"));e.container&&e.findOffset()};a.Space2D.prototype.update=function(a){e=this;q=e.evaluator;r=e.parent;q.setVariable(e.wString,e.w);q.setVariable(e.hString,e.h);e.drawIfValue=0<q.evalExpression(e.drawif);if(e.drawIfValue){t=e.x!==q.evalExpression(e.xExpr)+e.displaceRegionWest;s=e.y!==q.evalExpression(e.yExpr)+r.plecaHeight+e.displaceRegionNorth;e.spaceChange=a||t||s||e.drawBefore!==e.drawIfValue||e.Ox!==q.getVariable(e.OxString)||e.Oy!==q.getVariable(e.OyString)||e.scale!==q.getVariable(e.scaleString);
e.x=t?q.evalExpression(e.xExpr)+e.displaceRegionWest:e.x;e.y=s?q.evalExpression(e.yExpr)+r.plecaHeight+e.displaceRegionNorth:e.y;e.Ox=q.getVariable(e.OxString);e.Oy=q.getVariable(e.OyString);e.scale=q.getVariable(e.scaleString);e.drawBefore=e.drawIfValue;1E-6>e.scale?(e.scale=1E-6,q.setVariable(e.scaleString,1E-6)):1E6<e.scale&&(e.scale=1E6,q.setVariable(e.scaleString,1E6));if(t||s)e.container.style.left=e.x+"px",e.container.style.top=e.y+"px",e.findOffset();e.container.style.display="block";e.drawTrace=
!e.spaceChange&&(!e.fixed&&!e.click||e.fixed);e.spaceChange&&e.drawBackground();e.draw()}else e.container.style.display="none"};a.Space2D.prototype.drawBackground=function(){q=this.evaluator;k=this.backgroundCtx;k.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);k.fillStyle=this.background.getColor();k.fillRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);this.image&&""!=this.image.src&&this.image.ready&&this.image.complete&&("topleft"===this.bg_display?k.drawImage(this.image,
0,0):"stretch"===this.bg_display?k.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?(k.fillStyle=k.createPattern(this.image,"repeat"),k.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&k.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));u=this.scale;m=0;for(v=0>this.w+this.h?0:this.w+this.h;u>v;)u/=10,m++;for(;u<v/10;)u*=10;k.lineWidth=1;""!==this.net&&(k.strokeStyle=this.net.getColor(),this.drawMarks(k,u/10,-1));if(2!==
this.parent.version&&""!==this.net10||2===this.parent.version&&""!==this.net&&""!==this.net10)k.strokeStyle=this.net10.getColor(),this.drawMarks(k,u,-1);if(""!==this.axes){k.strokeStyle=this.axes.getColor();k.beginPath();if(""!==this.x_axis||2!==this.parent.version)k.moveTo(0,g(this.h/2+this.Oy)+0.5),k.lineTo(this.w,g(this.h/2+this.Oy)+0.5);if(""!==this.y_axis||2!==this.parent.version)k.moveTo(g(this.w/2+this.Ox)+0.5,0),k.lineTo(g(this.w/2+this.Ox)+0.5,this.h);k.stroke();this.drawMarks(k,u,4);this.drawMarks(k,
u/2,2);this.drawMarks(k,u/10,1)}if(""!==this.x_axis||""!==this.y_axis)k.fillStyle=""!==this.axes?this.axes.getColor():"black",k.font=n,k.textAlign="right",k.textBaseline="alphabetic",k.fillText(this.x_axis,g(this.w)-2,g(this.h/2+this.Oy)+12),k.fillText(this.y_axis,g(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(k.fillStyle=this.axes.getColor(),k.font=n,k.textAlign="start",k.textBaseline="bottom",u>(this.w+this.h)/2?this.drawNumbers(k,u/5,u<=this.scale?m+1:m):u>(this.w+this.h)/4?this.drawNumbers(k,
u/2,u<=this.scale?m+1:m):this.drawNumbers(k,u,m));for(var a=0,b=this.backgroundGraphics.length;a<b;a++)this.backgroundGraphics[a].draw()};a.Space2D.prototype.draw=function(){k=this.ctx;k.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=0,b=this.graphics.length;a<b;a++)l=this.graphics[a],""!==l.trace&&this.drawTrace&&l.drawTrace(),l.draw();a=0;for(b=this.graphicsCtr.length;a<b;a++)this.graphicsCtr[a].draw();""!=this.text&&this.click&&"L"===this.whichButton&&(k.fillStyle=this.text.getColor(),
k.strokeStyle=k.fillStyle,k.lineWidth=1,k.font=f,k.textAlign="center",k.textBaseline="alphabetic",I=1>=this.scale?this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length),L=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),x="("+I+","+L+")",J=g(k.measureText(x).width/2),E=this.getAbsoluteX(this.mouse_x),Q=this.getAbsoluteY(this.mouse_y),N=g(E),K=g(Q-10),N+J>this.w?N=this.w-J:0>N-J&&(N=J),K+1>this.h?K=this.h:0>K-14&&(K=15),k.fillText(x,N,K),
k.beginPath(),k.arc(E,Q,2.5,0,c,!0),k.stroke())};a.Space2D.prototype.drawMarks=function(a,c,e){w=this.w;y=this.h;A=0;z=w;H=0;G=y;D=g(w/2+this.Ox);F=g(y/2+this.Oy);0<=e&&(A=D-e,z=D+e,H=F-e,G=F+e);a.beginPath();for(e=-b(D/c);(C=D+b(e*c))<w;e++)a.moveTo(C+0.5,H+0.5),a.lineTo(C+0.5,G+0.5);for(e=-b(F/c);(B=F+b(e*c))<y;e++)a.moveTo(A+0.5,B+0.5),a.lineTo(z+0.5,B+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,c,e){w=this.w;y=this.h;D=g(w/2+this.Ox);F=g(y/2+this.Oy);for(e=-b(D/c);(C=D+b(e*c))<
w;e++)a.fillText(parseFloat((e*c/this.scale).toFixed(4)),C+1,F-2);for(e=-b(F/c);(B=F+b(e*c))<y;e++)0!==parseFloat(-e*c/this.scale)&&a.fillText(parseFloat((-e*c/this.scale).toFixed(4)),D+5,B+5)};a.Space2D.prototype.registerMouseAndTouchEvents=function(){function b(a){document.body.focus();k.parent.clearClick();k.click=1;k.evaluator.setVariable(k.mpressedString,1);k.evaluator.setVariable(k.mclickedString,0);k.evaluator.setVariable(k.mclicizquierdoString,0);k.parent.deactivateGraphiControls();l(a);window.addEventListener("touchmove",
m);window.addEventListener("touchend",c);a.stopPropagation();a.preventDefault()}function c(a){document.body.focus();k.click=0;k.evaluator.setVariable(k.mpressedString,0);k.evaluator.setVariable(k.mclickedString,1);k.evaluator.setVariable(k.mclicizquierdoString,1);window.removeEventListener("touchmove",m);window.removeEventListener("touchend",c);a.preventDefault();k.parent.update()}function e(b){document.body.focus();b.stopPropagation();b.preventDefault();k.parent.clearClick();k.click=1;k.parent.deactivateGraphiControls();
k.whichButton=a.whichButton(b);"R"===k.whichButton?(window.addEventListener("mouseup",f),k.clickPosForZoom=k.getCursorPosition(b).y,k.clickPosForZoomNew=k.clickPosForZoom,k.fixed||(k.tempScale=k.scale,window.addEventListener("mousemove",n))):"L"===k.whichButton&&(k.evaluator.setVariable(k.mpressedString,1),k.evaluator.setVariable(k.mclickedString,0),k.evaluator.setVariable(k.mclicizquierdoString,0),l(b),window.addEventListener("mousemove",m),window.addEventListener("mouseup",f))}function f(a){document.body.focus();
a.stopPropagation();a.preventDefault();k.click=0;k.evaluator.setVariable(k.mpressedString,0);k.evaluator.setVariable(k.mclickedString,1);k.evaluator.setVariable(k.mclicizquierdoString,1);"R"===k.whichButton&&(window.removeEventListener("mousemove",n),k.clickPosForZoom==k.clickPosForZoomNew&&k.parent.externalSpace.show());window.removeEventListener("mousemove",m);window.removeEventListener("mouseup",f);k.parent.update()}function l(a){Date.now()-q>p&&(k.posAnte=k.getCursorPosition(a),k.mouse_x=k.getRelativeX(k.posAnte.x),
k.mouse_y=k.getRelativeY(k.posAnte.y),k.evaluator.setVariable(k.mxString,k.mouse_x),k.evaluator.setVariable(k.myString,k.mouse_y),k.evaluator.setVariable(k.mclickedString,0),k.evaluator.setVariable(k.mclicizquierdoString,0),k.parent.update(),q=Date.now())}function n(a){a.preventDefault();k.clickPosForZoomNew=k.getCursorPosition(a).y;k.evaluator.setVariable(k.scaleString,k.tempScale+k.tempScale/45*((k.clickPosForZoom-k.clickPosForZoomNew)/10));k.parent.update()}function m(a){a.preventDefault();a.stopPropagation();
!k.fixed&&Date.now()-q>p&&(k.posNext=k.getCursorPosition(a),d=g(k.posAnte.x-k.posNext.x),h=g(k.posAnte.y-k.posNext.y),k.evaluator.setVariable(k.OxString,k.Ox-d),k.evaluator.setVariable(k.OyString,k.Oy-h),k.posAnte.x-=d,k.posAnte.y-=h);l(a)}var q=0,k=this;R=a.hasTouchSupport;k.clickPosForZoom=null;k.clickPosForZoomNew=null;k.canvas.oncontextmenu=function(a){return!1};R&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",l),this.canvas.addEventListener("touchstart",b));R||
(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",l),this.canvas.addEventListener("mousedown",e))};return a}(descartesJS||{}),descartesJS=function(a){var d,h,g;function b(a,b){return b.depth-a.depth}function c(b,c){Z=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));W=a.add3D(b,a.scalarProduct3D(Z,-2));X=a.norm3D(W);return 0!==X?a.scalarProduct3D(W,1/X):a.scalarProduct3D(b,-1)}if(a.loadLib)return a;var n=Math.floor,f=Math.round,p=Math.max,e=Math.cos,q=Math.sin,r=
Math.sqrt,k=15*Math.PI/180,t=Math.cos(k),s=Math.sin(k),l,u,m,v,w,y,C,B,D,F,A,z,H,G,I,L,x,J,E,Q,N,K,R,S=[],O,P,M,V,U,Y,Z,W,X;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 e=0,f=m.lights.length;e<f;e++)m.lights[e]=a.normalize3D(m.lights[e]);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(a){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;l=m.evaluator;u=m.parent;l.setVariable(m.wStr,m.w);l.setVariable(m.hStr,m.h);m.drawIfValue=
0<l.evalExpression(m.drawif);if(m.drawIfValue){D=m.x!==l.evalExpression(m.xExpr)+m.displaceRegionWest;F=m.y!==l.evalExpression(m.yExpr)+u.plecaHeight+m.displaceRegionNorth;m.spaceChange=a||D||F||m.drawBefore!==m.drawIfValue||m.Ox!==l.getVariable(m.OxStr)||m.Oy!==l.getVariable(m.OyStr)||m.scale!==l.getVariable(m.scaleStr);m.x=D?l.evalExpression(m.xExpr)+m.displaceRegionWest:m.x;m.y=F?l.evalExpression(m.yExpr)+u.plecaHeight+m.displaceRegionNorth:m.y;m.Ox=l.getVariable(m.OxStr);m.Oy=l.getVariable(m.OyStr);
m.scale=l.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?l.getVariable(m.obsStr)||0.5*(m.w+m.h):2.5*(m.w+m.h);m.observer=p(m.observer,0.1*(m.w+m.h));l.setVariable(m.obsStr,m.observer);m.eye={x:m.observer/m.scale*t,y:0,z:m.observer/m.scale*s};m.D=m.scale*m.eye.x/t;m.XE=f(m.scale*m.eye.y+0.5);m.YE=f(m.scale*m.eye.z+0.5)}m.observer=p(l.getVariable(m.obsStr),0.1*(m.w+
m.h));l.setVariable(m.obsStr,m.observer);1E-6>m.scale?(m.scale=1E-6,l.setVariable(m.scaleStr,1E-6)):1E6<m.scale&&(m.scale=1E6,l.setVariable(m.scaleStr,1E6));if(D||F)m.container.style.left=m.x+"px",m.container.style.top=m.y+"px",m.findOffset();m.container.style.display="block";m.dim=l.getVariable(m.userI_Dim_Str);m.userIntensity=l.getVariable(m.userI_I_Str);m.light3={x:parseInt(l.getVariable(m.userI_x_Str)),y:parseInt(l.getVariable(m.userI_y_Str)),z:parseInt(l.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++){v=this.graphics[a];if(v.split||this.split)for(var e=a+1;e<c;e++)w=this.graphics[e],(w.split||this.split)&&v.splitFace(w);this.primitives=this.primitives.concat(v.primitives||
[])}y=this.primitives;C=y.length;for(a=0;a<C;a++)y[a].computeDepth(this);if("painter"===this.render)this.drawPainter(y);else for(y=y.sort(b),a=0;a<C;a++)y[a].draw(this.ctx,this);a=0;for(c=this.graphicsCtr.length;a<c;a++)this.graphicsCtr[a].draw()};var T;a.renderNode=function(a){this.value=a;this.front=this.back=null};a.renderNode.prototype.inOrder=function(){var a=[];this.back&&(a=a.concat(this.back.inOrder()));a.push(this.value);this.front&&(a=a.concat(this.front.inOrder()));return a};a.Space3D.prototype.buildTree=
function(b){if(0===b.length)return null;var c,e=[],f=[];T=b.shift();for(var g=0,d=b.length;g<d;g++){c=null;for(var h=0,l=b[g].spaceVertices.length;h<l;h++)whereIs=2<T.spaceVertices.length?this.inPlane2(T.spaceVertices[0],T.normal,b[g].spaceVertices[h]):0,whereIs=0<T.direction?-whereIs:whereIs,null===c?0>whereIs?c="front":0<whereIs&&(c="back"):0>whereIs?"back"===c&&(c="cross"):0<whereIs&&"front"===c&&(c="cross");if("back"===c)e.push(b[g]);else if("front"===c)f.push(b[g]);else if(null==c)e.push(b[g]);
else{c=null;h=0;for(l=T.spaceVertices.length;h<l;h++)whereIs=2<b[g].spaceVertices.length?this.inPlane2(b[g].spaceVertices[0],b[g].normal,T.spaceVertices[h]):-1,whereIs=0<b[g].direction?-whereIs:whereIs,null===c?0>whereIs?c="front":0<whereIs&&(c="back"):0>whereIs?"back"===c&&(c="cross"):0<whereIs&&"front"===c&&(c="cross");"front"===c?e.push(b[g]):f.push(b[g])}}b=new a.renderNode(T);b.back=this.buildTree(e);b.front=this.buildTree(f);return b};a.Space3D.prototype.drawPainter=function(a){if(a=this.buildTree(a)){a=
a.inOrder();for(var b=0;b<a.length;b++)a[b].draw(this.ctx,this)}};a.Space3D.prototype.inPlane=function(a,b,c,e){return parseFloat(((e.x-a.x)*(b.y-a.y)*(c.z-a.z)+(e.y-a.y)*(b.z-a.z)*(c.x-a.x)+(e.z-a.z)*(b.x-a.x)*(c.y-a.y)-(e.z-a.z)*(b.y-a.y)*(c.x-a.x)-(e.y-a.y)*(b.x-a.x)*(c.z-a.z)-(e.x-a.x)*(b.z-a.z)*(c.y-a.y)).toFixed(8))};a.Space3D.prototype.inPlane2=function(a,b,c){return parseFloat((b.x*(c.x-a.x)+b.y*(c.y-a.y)+b.z*(c.z-a.z)).originalToFixed(8))};a.Space3D.prototype.updateCamera=function(){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){x=a.degToRad(m.evaluator.getVariable(m.rotZStr));J=e(x);E=q(x);d=b.x*J-b.y*E;h=b.x*E+b.y*J;g=b.z;x=a.degToRad(m.evaluator.getVariable(m.rotYStr));J=e(x);E=q(x);return{x:g*E+d*J,y:h,z:g*J-d*E}};a.Space3D.prototype.project=function(a){m=this;H=m.eye.x-a.x;G=m.eye.y-a.y;I=m.eye.z-a.z;var b=r(H*H+G*G+I*I);L=-a.x/b||0;H=this.w_2+this.Ox+m.scale*(a.y+L*(m.eye.y-a.y));G=this.h_2+this.Oy-
m.scale*(a.z+L*(m.eye.z-a.z));return{x:H,y:G,z:b}};a.Space3D.prototype.computeColor=function(b,e,f){b.match("rgba")?b=a.RGBAToHexColor(b):b.match("#")&&(b=new a.Color(b.substring(1)));V=a.subtract3D(this.eye,e.average);U=a.norm3D(V);Y=a.scalarProduct3D(V,1/U);this.lights[3]=a.subtract3D(this.light3,e.average);R=a.norm3D(this.lights[3]);for(var g=0,d=this.intensity.length-1;g<d;g++)S[g]=this.intensity[g]*this.dim;S[3]=this.userIntensity*this.userIntensity/R||0;O=f?this.dim/2:this.dim/4;P=0;M=0<=e.direction?
e.normal:a.scalarProduct3D(e.normal,-1);g=0;for(d=this.lights.length;g<d;g++)f?(P=Math.max(0,a.dotProduct3D(c(this.lights[g],M),Y)),P*=P*P):P=Math.max(0,a.dotProduct3D(this.lights[g],M)),O+=S[g]*P;O=Math.min(O,1);Q=n(b.r*O);N=n(b.g*O);K=n(b.b*O);return"rgba("+Q+","+N+","+K+","+b.a+")"};a.Space3D.prototype.registerMouseAndTouchEvents=function(){function b(a){document.body.focus();k.click=1;k.evaluator.setVariable(k.id+".mouse_pressed",1);k.parent.deactivateGraphiControls();k.posAnte=k.getCursorPosition(a);
k.oldMouse.x=k.getRelativeX(k.posAnte.x);k.oldMouse.y=k.getRelativeY(k.posAnte.y);d(a);window.addEventListener("touchmove",l);window.addEventListener("touchend",c);a.preventDefault()}function c(a){document.body.focus();k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);window.removeEventListener("touchmove",l,!1);window.removeEventListener("touchend",c,!1);a.preventDefault()}function e(b){document.body.focus();k.click=1;k.parent.deactivateGraphiControls();k.whichButton=a.whichButton(b);"R"===
k.whichButton?(window.addEventListener("mouseup",g),k.clickPosForZoom=k.getCursorPosition(b).y,k.clickPosForZoomNew=k.clickPosForZoom,k.fixed||(k.tempScale=k.scale,window.addEventListener("mousemove",h))):"L"==k.whichButton&&(k.evaluator.setVariable(k.id+".mouse_pressed",1),k.posAnte=k.getCursorPosition(b),k.oldMouse.x=k.getRelativeX(k.posAnte.x),k.oldMouse.y=k.getRelativeY(k.posAnte.y),d(b),window.addEventListener("mousemove",l),window.addEventListener("mouseup",g));b.preventDefault()}function g(a){document.body.focus();
k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);a.preventDefault();"R"===k.whichButton&&(window.removeEventListener("mousemove",h,!1),k.clickPosForZoom==k.clickPosForZoomNew&&k.parent.externalSpace.show());window.removeEventListener("mousemove",l,!1);window.removeEventListener("mouseup",g,!1)}function d(a){k.posAnte=k.getCursorPosition(a);k.mouse_x=k.getRelativeX(k.posAnte.x);k.mouse_y=k.getRelativeY(k.posAnte.y);k.evaluator.setVariable(k.id+".mouse_x",k.mouse_x);k.evaluator.setVariable(k.id+
".mouse_y",k.mouse_y);70<Date.now()-p&&(k.parent.update(),p=Date.now())}function h(a){a.preventDefault();k.clickPosForZoomNew=k.getCursorPosition(a).y;k.evaluator.setVariable(k.scaleStr,k.tempScale+k.tempScale/45*((k.clickPosForZoom-k.clickPosForZoomNew)/10));k.parent.update()}function l(b){if(!k.fixed&&k.click){A=parseInt(50*(k.oldMouse.x-k.mouse_x));z=parseInt(50*(k.oldMouse.y-k.mouse_y));if(A!==k.disp.x||z!==k.disp.y)k.alpha=a.degToRad(k.evaluator.getVariable(k.rotZStr)),k.beta=a.degToRad(-k.evaluator.getVariable(k.rotYStr)),
k.alpha=f(a.radToDeg(k.alpha)-A),k.beta=f(a.radToDeg(k.beta)-z),k.evaluator.setVariable(k.rotZStr,k.alpha),k.evaluator.setVariable(k.rotYStr,-k.beta),k.disp.x=A,k.disp.y=z,k.oldMouse.x=k.getRelativeX(k.posAnte.x),k.oldMouse.y=k.getRelativeY(k.posAnte.y);d(b);b.preventDefault()}}var k=this,p=0;B=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};B&&this.canvas.addEventListener("touchstart",b);B||this.canvas.addEventListener("mousedown",e);this.disp={x:0,y:0}};return a}(descartesJS||{}),
descartesJS=function(a){if(a.loadLib)return a;var d;a.SpaceAP=function(h,g){a.Space.call(this,h,g);this.exportarVars=this.importarVars=null;d=h.evaluator;this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=d.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=d.parser.parse(this.file):this.file=d.parser.parse("'"+this.file+"'");this.oldFile=d.evalExpression(this.file);this.initFile()};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=
function(){this.firstUpdate=!0;var d;if(this.oldFile){var g=document.getElementById(this.oldFile);d=g&&"descartes/spaceApFile"==g.type?g.text:a.openExternalFile(this.oldFile);null!=d&&(d=d.split("\n"))}if(d&&d.toString().match(/<applet/gi)){for(var g="",b=!1,c=0,n=d.length;c<n&&(d[c].match("<applet")&&(b=!0),b&&(g+=d[c]),!d[c].match("</applet"));c++);c=document.createElement("div");c.innerHTML=g;c.firstChild.setAttribute("width",this.w);c.firstChild.setAttribute("height",this.h);g=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+";");g?this.parent.container.replaceChild(this.descApp.container,g):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);g=this.descApp.spaces;
c=0;for(n=g.length;c<n;c++)g[c].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var f=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();f.exportar()}}else g=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),g?this.parent.container.replaceChild(this.descApp.container,g):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),g=this.y!=this.evaluator.evalExpression(this.yExpr)+this.plecaHeight;this.x=a?this.evaluator.evalExpression(this.xExpr):this.x;this.y=g?this.evaluator.evalExpression(this.yExpr)+this.plecaHeight:this.y;a&&(this.descApp.container.style.left=this.x+"px");g&&(this.descApp.container.style.top=this.y+"px");if(a||g)for(var a=this.descApp.spaces,g=0,b=a.length;g<b;g++)a[g].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,g=!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),g=!0);g&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,b;a.SpaceHTML_IFrame=function(b,g){a.Space.call(this,b,g);var f=this.parent.evaluator;window.navigator.userAgent.toLowerCase().match(/firefox/);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=f.parser.parse(this.file.substring(1,
this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=f.parser.parse(this.file):this.file=f.parser.parse("'"+this.file+"'");this.oldFile=f.evalExpression(this.file);this.MyIFrame=document.createElement("iframe");0!=this.oldFile&&this.MyIFrame.setAttribute("src",this.oldFile);this.MyIFrame.setAttribute("id",this.id);this.MyIFrame.setAttribute("marginheight",0);this.MyIFrame.setAttribute("marginwidth",0);this.MyIFrame.setAttribute("frameborder",0);this.MyIFrame.setAttribute("scrolling",
"auto");this.MyIFrame.setAttribute("style","position: static; left: 0px; top: 0px;");this.container=document.createElement("div");a.isIOS?this.container.setAttribute("style","overflow: scroll; -webkit-overflow-scrolling: touch; position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";"):this.container.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+
this.zIndex+";");this.container.appendChild(this.MyIFrame);this.parent.container.insertBefore(this.container,this.parent.loader);var d=this;this.MyIFrame.onload=function(a){var b=this;d.evaluator.setFunction(d.id+".set",function(a,c){b.contentWindow.postMessage({type:"set",name:a,value:c},"*");return 0});d.evaluator.setFunction(d.id+".update",function(){b.contentWindow.postMessage({type:"update"},"*");return 0});d.evaluator.setFunction(d.id+".exec",function(a,c){b.contentWindow.postMessage({type:"exec",
name:a,value:c},"*");return 0})};this.update=this.iframeUpdate;this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.init=function(){self=this;self.uber.init.call(self);self.MyIFrame&&(self.MyIFrame.style.width=self.w+"px",self.MyIFrame.style.height=self.h+"px",self.MyIFrame.style.left=self.x+"px",self.MyIFrame.style.top=self.y+"px")};a.SpaceHTML_IFrame.prototype.iframeUpdate=function(a){d=this.evaluator;this.drawIfValue=0<d.evalExpression(this.drawif);
this.container.style.display=this.drawIfValue?"block":"none";if(this.drawIfValue){a&&(this.y=this.x=Math.Infinity);h=this.x!==d.evalExpression(this.xExpr)+this.displaceRegionWest;g=this.y!==d.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=h?d.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=g?d.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(h||g)this.MyIFrame.style.left=this.x+"px",this.MyIFrame.style.top=this.y+
"px";b=d.evalExpression(this.file);b!==this.oldFile&&(this.oldFile=b,this.MyIFrame.setAttribute("src",b));this.scrollVar=d.getVariable(this.id+"._scroll");1==this.scrollVar?(this.MyIFrame.setAttribute("scrolling","yes"),this.MyIFrame.style.overflow=""):-1==this.scrollVar?(this.MyIFrame.setAttribute("scrolling","no"),this.MyIFrame.style.overflow="hidden"):(this.MyIFrame.setAttribute("scrolling","auto"),this.MyIFrame.style.overflow="")}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d;a.DescartesLoader=function(a){this.children=a.children;this.lessonParser=a.lessonParser;this.images=a.images;this.images.length=a.images.length;this.audios=a.audios;this.audios.length=a.audios.length;this.arquimedes=a.arquimedes;this.descartesApp=a;var b=a.image_loader?a.image_loader:n(a.loader.width,a.loader.height);this.imageLoader=document.createElement("div");this.imageLoader.width=a.width;this.imageLoader.height=a.height;this.imageLoader.setAttribute("class","DescartesLoaderImage");this.imageLoader.setAttribute("style",
"background-image: url("+b+"); width: "+a.width+"px; height: "+a.height+"px;");a.loader.appendChild(this.imageLoader);this.loaderBar=document.createElement("canvas");this.loaderBar.width=a.width;this.loaderBar.height=a.height;this.loaderBar.setAttribute("class","DescartesLoaderBar");this.loaderBar.setAttribute("style","width: "+a.width+"px; height:"+a.height+"px;");this.loaderBar.ctx=this.loaderBar.getContext("2d");a.loader.appendChild(this.loaderBar);this.barWidth=Math.floor(80);this.barHeight=Math.floor(a.loader.height/
70);var c=this;this.timer=setInterval(function(){c.drawLoaderBar(c.loaderBar.ctx,a.width,a.height)},10);a.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var b=this.children,c=this.images,e=this.audios,g=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,d=/[\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 h,n,s,l,u,m;s=0;for(u=b.length;s<u;s++)if("rtf"!==b[s].name){if(b[s].value.match(/'macro'|'makro'/g)){h="";var v;n=this.lessonParser.split(b[s].value);m=0;for(var w=n.length;m<w;m++)"expresion"===babel[n[m][0]]&&(h=n[m][1]);h&&((v=document.getElementById(h))&&"descartes/macro"==v.type?v=v.text:(v=a.openExternalFile(h))&&!v.match(/tipo_de_macro/g)&&(v=null));if(v&&(h=v.match(g)))for(m=h.length;l<m;l++)n=h[l],n.toLowerCase().match(/vacio.gif$/)||""==n.substring(0,
n.length-4)||(c[n]=new Image,c[n].addEventListener("load",function(){this.ready=1}),c[n].addEventListener("error",function(){this.errorload=1}),c[n].src=n)}if(h=b[s].value.match(g))for(l=0,m=h.length;l<m;l++)n=h[l],n.toLowerCase().match(/vacio.gif$/)||""==n.substring(0,n.length-4)||(c[n]=new Image,c[n].addEventListener("load",function(){this.ready=1}),c[n].addEventListener("error",function(){this.errorload=1}),c[n].src=n);if(h=b[s].value.match(d))for(l=0,n=h.length;l<n;l++)this.initAudio(h[l])}for(var y in c)c.hasOwnProperty(y)&&
this.images.length++;for(y in e)e.hasOwnProperty(y)&&this.audios.length++;var C=this,B=this.images.length+this.audios.length,D=function(){C.readys=0;for(var a in c)c.hasOwnProperty(a)&&(c[a].ready||c[a].errorload)&&C.readys++;for(a in C.audios)e.hasOwnProperty(a)&&(e[a].ready||e[a].errorload)&&C.readys++;C.readys!=B?setTimeout(D,30):(clearTimeout(C.timer),C.descartesApp.initBuildApp())};D()};a.DescartesLoader.prototype.initAudio=function(b){var c=this.audios;c[b]=new Audio(b);c[b].filename=b;var e=
function(){this.ready=1},g=function(){this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))||"mp3"!=this.filename.substring(this.filename.length-3)?(console.log("El archivo '"+b+"' no puede ser reproducido"),this.errorload=1):(c[b]=new Audio(this.filename.replace("mp3","ogg")),c[b].filename=this.filename.replace("mp3","ogg"),c[b].addEventListener("canplaythrough",e),c[b].addEventListener("load",e),c[b].addEventListener("error",g),c[b].load())};c[b].addEventListener("canplaythrough",
e);c[b].addEventListener("load",e);c[b].addEventListener("error",g);a.hasTouchSupport?(c[b].load(),c[b].play(),setTimeout(function(){console.log("detenido");c[b].pause()},10),c[b].ready=1):c[b].load()};var h,g,b,c;a.DescartesLoader.prototype.drawLoaderBar=function(a,n,e){h=this.barWidth;g=this.barHeight;b=this.images.length+this.audios.length;c=2*(h-2)/b;a.translate(n/2,(e-65*d)/2+90*d);a.scale(d,d);a.strokeRect(-h,-g,2*h,g);a.fillStyle="gray";a.fillRect(-h+2,-g+2,2*(h-2),g-4);a.fillStyle="#1f375d";
a.fillRect(-h+2,-g+2,this.readys*c,g-4);a.setTransform(1,0,0,1,0,0)};var n=function(a,b){var c=document.createElement("canvas");c.width=a;c.height=b;var g=c.getContext("2d");g.save();g.strokeStyle="#1f375d";g.fillStyle="#1f375d";g.lineCap="round";g.lineWidth=2;g.beginPath();d=a<b?a/360:b/195;d=2.5<d?2.5:d;g.translate((a-120*d)/2,(b-65*d)/2);g.scale(d,d);g.moveTo(3,25);g.lineTo(3,1);g.lineTo(21,1);g.bezierCurveTo(33,1,41,15,41,25);g.stroke();g.beginPath();g.moveTo(1,63);g.lineTo(1,64);g.moveTo(5,62);
g.lineTo(5,64);g.moveTo(9,61);g.lineTo(9,64);g.moveTo(13,60);g.lineTo(13,64);g.moveTo(17,58);g.lineTo(17,64);g.moveTo(21,56);g.lineTo(21,64);g.moveTo(25,53);g.lineTo(25,64);g.moveTo(29,50);g.lineTo(29,64);g.moveTo(33,46);g.lineTo(33,64);g.moveTo(37,41);g.lineTo(37,64);g.moveTo(41,32);g.lineTo(41,64);g.stroke();g.font="20px Arial, Helvetica, 'Droid Sans', Sans-serif";g.fillText("escartes",45,33);g.fillText("JS",98,64);g.restore();return c.toDataURL()};return a}(descartesJS||{}),descartesJS=function(a){function d(a){for(var b=
"[",c=0,n=a.length;c<n;c++)a[c]instanceof Array?b+=d(a[c]):(h=a[c],"undefined"!=typeof h&&h||(h=0),"string"==typeof h&&(h="'"+h+"'"),b+=h),c<n-1&&(b+=",");return b+"]"}if(a.loadLib)return a;a.DescartesApp=function(g){this.animation={playing:!1};this.applet=g;this.parentContainer=g.parentNode;this.width=parseFloat(g.getAttribute("width"));this.height=parseFloat(g.getAttribute("height"));this.decimal_symbol=".";this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");this.language="espa\u00f1ol";
this.children=g.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=g.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 g=this.children,b,c=0,d=0,f=a.creativeCommonsLicense?90:0,h=0,e=g.length;h<e;h++)b=g[h],"rtf_height"==b.name&&(c=parseInt(b.value)),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),d=this.buttonsConfig.height),"image_loader"==b.name&&(this.image_loader=b.value),"docBase"==b.name&&(this.docBase=b.value,b=document.createElement("base"),b.setAttribute("id","descartesJS_base"),b.setAttribute("href",this.docBase),document.head.appendChild(b));this.arquimedes&&
c&&(this.height=c+d+f);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.editableRegion={container:document.createElement("div"),textFields:[]};
a.Editor&&(this.editor=new a.Editor(this));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 g=
this.children,b=this.lessonParser,c=[],d=[],f=[],h=[],e=[],q=[],r,k=0,t=g.length;k<t;k++)if(r=g[k],"language"==babel[r.name]&&(this.language=r.value),"pleca"==r.name)r=b.parsePleca(r.value,this.width),this.container.insertBefore(r,this.loader),this.plecaHeight=r.imageHeight?r.imageHeight:r.offsetHeight;else if("Buttons"==babel[r.name])this.buttonsConfig=b.parseButtonsConfig(r.value);else if("decimal_symbol"==babel[r.name])this.decimal_symbol=r.value,this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,
"g");else if("version"==babel[r.name])this.version=parseInt(r.value);else if("language"==babel[r.name])this.language=r.value;else if("rtf"==r.name){var s=(this.width-780)/2,l=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;h.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+r.value.replace(/'/g,"&squot;")+"'");h.push("space='descartesJS_scenario' type='text' expresion='["+s+","+(l-25)+"]' background='yes' text='"+this.licenseA+"'");a.creativeCommonsLicense&&
h.push("space='descartesJS_scenario' type='image' expresion='["+(s+15)+","+l+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==r.name.charAt(0)?(r.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,c.push(r.value)):"C"==r.name.charAt(0)&&"_"==r.name.charAt(1)?d.push(r.value):"A"==r.name.charAt(0)&&"_"==r.name.charAt(1)?f.push(r.value):"G"==r.name.charAt(0)?h.push(r.value):"S"==r.name.charAt(0)?e.push(r.value):"Animation"==babel[r.name]&&q.push(r.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));k=0;for(t=c.length;k<t;k++)g=b.parseSpace(c[k]),this.arquimedes&&this.scenarioRegion.container.appendChild(g.container),this.spaces.push(g),this.zIndex++;k=0;for(t=h.length;k<t;k++)if(c=b.parseGraphic(h[k]))c.visible&&(this.editableRegionVisible=!0),c.space.addGraph(c);k=0;for(t=e.length;k<t;k++)(c=b.parse3DGraphic(e[k]))&&c.space.addGraph(c,!0);k=0;for(t=d.length;k<t;k++)this.controls.push(b.parseControl(d[k]));k=0;for(t=f.length;k<t;k++)b.parseAuxiliar(f[k]);
k=0;for(t=q.length;k<t;k++)this.animation=b.parseAnimation(q[k]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();k=0;for(t=this.controls.length;k<t;k++)this.controls[k].init();this.updateControls();this.updateSpaces(!0);var u=this;this.numberOfIframes?setTimeout(function(){u.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 g=parseInt(this.width)+30,b=parseInt(this.height)+90;window.moveTo((parseInt(screen.width)-g)/2,(parseInt(screen.height)-b)/2);window.resizeTo(g,b);a.onResize()};a.DescartesApp.prototype.configRegions=function(){var g=this.evaluator.parser,b=this.buttonsConfig,c=this.container;if(2!=this.version)var d="15",f=100,h=100,e=100,q=100;else d="14",f=63,h=50,e=44,q=53;var r=0,k=0,t=0,s=t=0,l=0,u=0,m=0,v=0,u=this.northSpace.controls,w=this.southSpace.controls,y=this.eastSpace.controls,C=this.westSpace.controls;
if(0<b.rowsNorth||0<u.length||b.about||b.config){0>=b.rowsNorth?(r=b.height,b.rowsNorth=1):r=b.height*b.rowsNorth;l=this.northSpace.container;l.setAttribute("id","descartesJS_northRegion");l.setAttribute("style","width:"+c.width+"px; height:"+r+"px; background:#c0c0c0; position:absolute; left:0px; top: "+this.plecaHeight+"px; z-index:100;");c.insertBefore(l,this.loader);var l=c.width,B=0;b.about&&(B=f,l-=B);b.config&&(l-=h);for(var D=Math.ceil(u.length/b.rowsNorth),F=l/D,t=0,A=u.length;t<A;t++)u[t].expresion=
g.parse("("+(B+t%D*F)+","+b.height*Math.floor(t/D)+","+F+","+b.height+")"),u[t].drawif=g.parse("1"),u[t].init();b.about&&(t="espa\u00f1ol"==this.language?"cr\u00e9ditos":"english"==this.language?"about":"cr\u00e9ditos",t=new a.Button(this,{region:"north",name:t,font_size:g.parse(d),expresion:g.parse("(0, 0, "+f+", "+r+")")}),t.actionExec={execute:a.showAbout},t.update());b.config&&(new a.Button(this,{region:"north",name:"config",font_size:g.parse(d),action:"config",expresion:g.parse("("+(l+f)+", 0, "+
h+", "+r+")")})).update()}if(0<b.rowsSouth||0<w.length||b.init||b.clear){0>=b.rowsSouth?(k=b.height,b.rowsSouth=1):k=b.height*b.rowsSouth;u=c.width;B=0;b.init&&(B=e,u-=B);b.clear&&(u-=q);l=this.southSpace.container;l.setAttribute("id","descartesJS_southRegion");l.setAttribute("style","width:"+c.width+"px; height:"+k+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(c.height-k)+"px; z-index:100;");c.insertBefore(l,this.loader);D=Math.ceil(w.length/b.rowsSouth);F=u/D;t=0;for(A=w.length;t<
A;t++)w[t].expresion=g.parse("("+(B+t%D*F)+","+b.height*Math.floor(t/D)+","+F+","+b.height+")"),w[t].drawif=g.parse("1"),w[t].init();b.init&&(t="espa\u00f1ol"==this.language?"inicio":"english"==this.language?"init":"inicio",(new a.Button(this,{region:"south",name:t,font_size:g.parse(d),action:"init",expresion:g.parse("(0, 0, "+e+", "+k+")")})).update());b.clear&&(t="espa\u00f1ol"==this.language?"limpiar":"english"==this.language?"clear":"limpiar",(new a.Button(this,{region:"south",name:t,font_size:g.parse(d),
action:"clear",expresion:g.parse("("+(u+e)+", 0, "+q+", "+k+")")})).update())}if(0<y.length)for(t=c.height-r-k,m=b.widthEast,l=this.eastSpace.container,l.setAttribute("id","descartesJS_eastRegion"),l.setAttribute("style","width:"+m+"px; height:"+t+"px; background:#c0c0c0; position:absolute; left:"+(c.width-m)+"px; top:"+r+"px; z-index:100;"),c.insertBefore(l,this.loader),t=0,A=y.length;t<A;t++)y[t].expresion=g.parse("(0,"+b.height*t+","+m+","+b.height+")"),y[t].drawif=g.parse("1"),y[t].init();if(0<
C.length)for(t=c.height-r-k,v=b.widthWest,l=this.westSpace.container,l.setAttribute("id","descartesJS_westRegion"),l.setAttribute("style","width: "+v+"px; height: "+t+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+r+"px; z-index: 100;"),c.insertBefore(l,this.loader),t=0,A=C.length;t<A;t++)C[t].expresion=g.parse("(0,"+b.height*t+","+v+","+b.height+")"),C[t].drawif=g.parse("1"),C[t].init();if(this.editableRegionVisible)for(s=b.height,l=this.editableRegion.container,l.setAttribute("id",
"descartesJS_editableRegion"),l.setAttribute("style","width:"+c.width+"px; height:"+s+"px; position:absolute; left:0px; top:"+(c.height-k-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;"),c.insertBefore(l,this.loader),g=this.editableRegion.textFields,b=c.width/g.length,d=a.getFieldFontSize(s),t=0,A=g.length;t<A;t++)"div"==g[t].type?(l.appendChild(g[t].container),g[t].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(b-4)+"px; height: "+
s+"px; position: absolute; left: "+t*b+"px; top: 0px;"),f=g[t].container.firstChild,f.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+d+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+s+"px; text-align: center; line-height: "+s+"px;"),h=f.offsetWidth,f.style.width=h+"px",f.firstChild.textContent=f.firstChild.textContent.substring(3,f.firstChild.textContent.length-3),g[t].container.lastChild.setAttribute("style",
"font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+d+"px; width:"+(b-h)+"px; height:"+s+"px; position:absolute; left:"+h+"px; top:0px; border:2px groove white;")):(l.appendChild(g[t]),g[t].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+d+"px; width:"+b+"px; height:"+s+"px; position:absolute; left:"+t*b+"px; top:0px; border:2px groove white;"));this.displaceRegionNorth=r;this.displaceRegionWest=v;c.width-=m;c.height=
c.height-k-s;t=0;for(A=this.spaces.length;t<A;t++)this.spaces[t].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateControls();this.updateEvents();this.updateSpaces()};a.DescartesApp.prototype.clearClick=function(){for(var a=0,b=this.spaces.length;a<b;a++)this.spaces[a].clearClick()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,b=0,c=this.controls.length;b<c;b++)a=this.controls[b],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=
function(){for(var a=0,b=this.auxiliaries.length;a<b;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=function(){for(var a=0,b=this.events.length;a<b;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,b=this.controls.length;a<b;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var b=0,c=this.spaces.length;b<c;b++)this.spaces[b].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,b=this.spaces.length;a<
b;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground&&this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stopAudios=function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),
this.audios[a].currentTime=0)};a.DescartesApp.prototype.getImage=function(a){var b=this.images;if(a)return b[a]||(b[a]=new Image,b[a].addEventListener("load",function(){this.ready=1}),b[a].addEventListener("error",function(){this.errorload=1}),b[a].src=a),b[a]};a.DescartesApp.prototype.getAudio=function(a){var b=this.audios;if(a){if(!b[a]){var c=a.lastIndexOf("."),c=-1===c?a.lenght:c;a.substring(0,c);b[a]=new Audio(a);var d=function(a){this.ready=1};b[a].addEventListener("canplaythrough",d);var f=
function(c){this.canPlayType("audio/"+a.substring(a.length-3))||"mp3"!=a.substring(a.length-3)?(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1):(b[a]=new Audio(a.replace("mp3","ogg")),b[a].addEventListener("canplaythrough",d),b[a].addEventListener("load",d),b[a].addEventListener("error",f),b[a].load())};b[a].addEventListener("error",f);b[a].play();setTimeout(function(){b[a].pause()},15)}return b[a]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var b,
c=0,d=this.controls.length;c<d;c++)if(b=this.controls[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var b,c=0,d=this.controls.length;c<d;c++)if(b=this.controls[c],b.id==a)return b;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var b,c=0,d=this.spaces.length;c<d;c++)if(b=this.spaces[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var b,c=0,
d=this.spaces.length;c<d;c++)if(b=this.spaces[c],b.id==a)return b;return{update:function(){},w:0}};var h;a.DescartesApp.prototype.getState=function(){var a,b="",c=this.evaluator.variables,h;for(h in c)c.hasOwnProperty(h)&&(a=c[h],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&"rnd"!=h&&"pi"!=h&&"e"!=h&&"Infinity"!=h&&"-Infinity"!=h&&"object"!=typeof a&&(b=""!=b?b+"\n"+h+"="+a:h+"="+a));var c=this.evaluator.vectors,f;for(f in c)c.hasOwnProperty(f)&&(a=c[f],b=b+"\n"+f+"="+d(a));f=this.evaluator.matrices;
for(var p in f)f.hasOwnProperty(p)&&(a=f[p],b=b+"\n"+p+"="+d(a));return b};a.DescartesApp.prototype.setState=function(a,b){for(var c=a.split("\n"),d,f,h=0,e=c.length;h<e;h++)d=c[h].split("="),2<=d.length&&(f=eval(d[1]),-1!=d[1].indexOf("[[")?(this.evaluator.matrices[d[0]]=f,this.evaluator.matrices[d[0]].rows=f.length,this.evaluator.matrices[d[0]].cols=f[0].length):-1!=d[1].indexOf("[")?(this.evaluator.vectors[d[0]]=f,this.evaluator.variables[d[0]+".long"]=f.length):this.evaluator.variables[d[0]]=
f);b||this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,b=0,c="",d=0,f=this.controls.length;d<f;d++)"textfield"==this.controls[d].gui&&this.controls[d].evaluate&&(a++,b+=this.controls[d].ok,this.controls[d].value=""==this.controls[d].value?"''":this.controls[d].value,c+=" \\n "+this.controls[d].id+"="+this.controls[d].value+"|"+this.controls[d].ok);return"questions="+a+" \\n correct="+b+" \\n wrong="+(a-b)+c};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,
b=0,c=a.length;b<c;b++)"textfield"==a[b].gui&&a[b].evaluate&&a[b].changeValue(a[b].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,b=this.saveState.length;a<b;a++)this.evaluator.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||{}),descartesJS=function(a){function d(){var a=document.getElementById("StyleDescartesApps");a&&a.parentNode.removeChild(a);a=document.createElement("style");a.id="StyleDescartesApps";a.type="text/css";a.setAttribute("rel",
"stylesheet");a.innerHTML="applet.DescartesJS {display:none;} applet {display:none;} ajs.DescartesJS {display:none;} ajs {display:none;}";document.head.appendChild(a)}function h(d){a.getFeatures();if(a.hasCanvasSupport){window.scrollTo(0,10);d=document.getElementsByTagName("*");for(var b=[],c=0,h=d.length;c<h;c++)"DescartesAppContainer"==d[c].className&&b.push(d[c]);c=0;for(h=b.length;c<h;c++)b[c].parentNode.removeChild(b[c]);b=document.getElementsByTagName("applet");c=document.getElementsByTagName("ajs");
d=[];for(var f=0,p=b.length;f<p;f++)h=b[f],(h.getAttribute("code").match("DescartesJS")||h.getAttribute("code").match("descinst.DescartesWeb2_0.class")||h.getAttribute("code").match("Descartes")||h.getAttribute("code").match("Arquimedes")||h.getAttribute("code").match("Discurso"))&&d.push(h);f=0;for(p=c.length;f<p;f++)h=c[f],(h.getAttribute("code").match("DescartesJS")||h.getAttribute("code").match("descinst.DescartesWeb2_0.class")||h.getAttribute("code").match("Descartes")||h.getAttribute("code").match("Arquimedes")||
h.getAttribute("code").match("Discurso"))&&d.push(h);b=0;for(c=d.length;b<c;b++)a.apps.push(new a.DescartesApp(d[b])),d[b].className="DescartesJS";window.addEventListener("resize",a.onResize);window.scrollTo(0,2);document.body.setAttribute("tabIndex",1E6)}else document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:block;} applet {display:block;} ajs.DescartesJS {display:block;} ajs {display:block;}"}if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};
window.hasOwnProperty("debugDescartesJS")&&debugDescartesJS||d();a.onResize=function(d){for(var b=0,c=a.apps.length;b<c;b++){d=a.apps[b].spaces;for(var h=0,f=d.length;h<f;h++)d[h].findOffset()}};a.receiveMessage=function(d){if(0<a.apps.length){var b=d.data;if(b)if("set"===b.type)"string"==typeof b.value||"number"==typeof b.value?a.apps[0].evaluator.setVariable(b.name,b.value):b.value&&void 0!=b.value.rows?a.apps[0].evaluator.matrices[b.name]=b.value:a.apps[0].evaluator.vectors[b.name]=b.value;else if("update"===
b.type)a.apps[0].update();else if("exec"===b.type){d=a.apps[0].evaluator.getFunction(b.name);var c=[];""!==b.value&&(c=b.value.toString().split(","));d&&d.apply(a.apps[0].evaluator,c)}else"isResizeNeeded"===b.type?d.source.postMessage({type:"doResize"},"*"):"doResize"===b.type&&0<a.apps.length&&a.apps[0].adjustSize()}};void 0==a.loadLib&&(a.loadLib=!0,window.addEventListener("load",h),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||{});
