/*
 Joel Espinosa Longi
 joel.espinosa@amite.mx
 j.longi@gmail.com
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-05-17
*/
var babel=function(a){if(a.loadLib)return a;a.falso=a["false"]=a.fals=a.gezurra=a.faux=a.fals="false";a.verdadero=a["true"]=a.veritable=a.egia=a.vrai=a.verdadeiro=a.veritable="true";a.no=a.ez=a.non=a["n\u00e3o"]="false";a["s\u00ed"]=a.yes=a.bai=a.oui=a.si=a["sim "]="true";a.negro=a.black=a.negre=a.beltza=a.noir=a.preto="#000000";a.maxenta=a.magenta="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise="#00ffff";a.verde=a.green=a.verd=a.berdea=a.vert="#00ff00";
a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho="#ff0000";a.pink=a.rosa=a.arrosa=a.rose="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro="#404040";a.gris=a.gray=a.grisa=a.cinza="#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=
"#ffffff";a.escala=a.scale=a.eskala=a["\u00e9chelle"]="scale";a.nombre=a.name=a.nom=a.izena=a.nome="name";a.ikusgai=a["vis\u00edvel"]=a.visible="visible";a.rastro=a.trace=a.rastre=a.arrastoa="trace";a.fondo=a.background=a.fons=a.hondoa=a.fond=a.fundo="background";a.colour=a.color=a.kolorea=a.couleur=a.cor="color";a["par\u00e1metro"]=a.parameter=a.parametroa=a["par\u00e2metro"]=a["par\u00e0metre"]="parameter";a["sucesi\u00f3n"]=a.sequence=a["successi\u00f3"]=a.segida=a.succession=a["seq\u00fc\u00eancia"]=
"sequence";a["tama\u00f1o"]=a.size=a.neurria=a.taille=a.tamanho=a["grand\u00e0ria"]="size";a.decimales=a.decimals=a.hamartarra=a["d\u00e9cimales"]=a.decimais="decimals";a.red=a.net=a.xarxa=a.sarea=a["r\u00e9seau"]=a.rede=a.malha="net";a.red10=a.net10=a.xarxa10=a.sarea10=a["r\u00e9seau10"]=a.rede10=a.malha10="net10";a.ejes=a.axes=a.eixos=a.ardatzak=a.eixes="axes";a.texto=a.text=a.testua=a.texte="text";a["cr\u00e9ditos"]=a.about=a["cr\u00e8dits"]=a.kreditoak=a["cr\u00e9dits"]=a.sobre="about";a.config=
a.konfig=a["configura\u00e7\u00e3o"]="config";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.limpiar=a.clear=a.neteja=a.ezabatu=a.nettoye=a.limpar="clear";a.incr=a.gehi=a.incremento="incr";a.min=a.inf="min";a.max=a.sup=a["m\u00e1x"]="max";a.relleno=a.fill=a.ple=a.betea=a.plein=a.recheo=a.preencher="fill";a["relleno+"]=a["fill+"]=a["ple+"]=a["betea+"]=a["plein+"]=a["recheo+"]=a["preencher+"]="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=a["betea-"]=a["plein-"]=a["recheo-"]=
a["preencher-"]="fillM";a.flecha=a.arrow=a.fletxa=a.gezia=a["fl\u00e8che"]=a.frecha=a.seta="arrow";a.ancho=a.width=a.ample=a.zabalera=a.large=a.largura="width";a.punta=a.spear=a.muturra=a.pointe=a.ponta="spear";a["regi\u00f3n"]=a.region=a["regi\u00f3"]=a.eskualde=a["r\u00e9gion"]=a["rexi\u00f3n"]=a["regi\u00e3o"]="region";a.norte=a.north=a.nord=a.ipar="north";a.sur=a.south=a.sud=a.hego=a.sul="south";a.este=a.east=a.est=a.ekialde=a.leste="east";a.oeste=a.west=a.oest=a.hegoalde=a.ouest="west";a.exterior=
a.external=a.kanpoalde=a.externo="external";a["expresi\u00f3n"]=a.expresion=a["expresi\u00f3"]=a.adierazpen=a["express\u00e3o"]="expresion";a.tipo=a.type=a.tipus=a.mota="type";a["posici\u00f3n"]=a.position=a["posici\u00f3"]=a.posizio=a["posi\u00e7\u00e3o"]="position";a["constricci\u00f3n"]=a.constraint=a["constricci\u00f3"]=a.beharte=a.constriction=a["constrici\u00f3n"]=a["restri\u00e7\u00e3o"]="constraint";a.valor=a.value=a.balio=a.valeur="value";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=
a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.curva=a.curve=a.corba=a.kurba=a.courbe="curve";a.texto=a.text=a.testu=a.texte="text";a.punto=a.point=a.punt=a.puntu=a.ponto="point";a.segmento=a.segment=a.zuzenki="segment";a.arco=a.arc=a.arku="arc";a["pol\u00edgono"]=a.polygon=a["pol\u00edgon"]=a.poligono=a.polygone="polygon";a.imagen=a.image=a.imatge=a.irudi=a.imaxe=a.imagem="image";a["Versi\u00f3n"]=a.Version=a["Versi\u00f3"]=a["Vers\u00e3o"]="version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=
"language";a["O.x"]="O.x";a["O.y"]="O.y";a.Botones=a.Buttons=a.Botons=a.Botoiak=a.Boutons=a["Bot\u00f3ns"]=a["Bot\u00f5es"]=a.Botons="Buttons";a["Animaci\u00f3n"]=a.Animation=a["Animaci\u00f3"]=a.Animazio=a["Anima\u00e7\u00e3o"]="Animation";a.constante=a.constant=a.Konstante="constant";a.fuente=a.font=a.iturri=a.source=a.fonte="font";a["num\u00e9rico"]=a.numeric=a["num\u00e8ric"]=a.zenbakizko=a["num\u00e9rique"]="numeric";a["gr\u00e1fico"]=a.graphic=a["gr\u00e0fic"]=a.grafiko=a.graphique="graphic";
a.texto=a.text=a.testu=a.texte="text";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.hacer=a["do"]=a.fer=a.egin=a.faire=a.facer=a.fazer="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto="whileExpr";a.evaluar=a.evaluate=a.avalua=a.ebaluatu=a["\u00e9valuer"]=a.avaliar="evaluate";a.variable=a.aldagaia=a["vari\u00e1vel"]="variable";a["funci\u00f3n"]=a["function"]=a["funci\u00f3"]=a.funtzio=a.fonction=a["fun\u00e7\u00e3o"]="function";a.algoritmo=
a.algorithm=a.algorisme=a.algorithme="algorithm";a.vector=a.array=a.bektore=a.vecteur=a.matriz="array";a["dibujar-si"]=a["draw-if"]=a["marraztu-baldin"]=a["dessiner-si"]=a["debuxar-se"]=a["desenhar-se"]=a["dibuixa-si"]="drawif";a.dominio=a.range=a.domini=a["izate-eremua"]=a.domain=a["dom\u00ednio"]="range";a.pausa=a.delay=a.eten="delay";a["eje-x"]=a["x-axis"]=a["eix-x"]=a["x-ardatza"]=a["axe-x"]=a["eixe-x"]=a["eixo-x"]="x_axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=
a["eixo-y"]="y_axis";a["n\u00fameros"]=a.numbers=a.nombres=a.zenbakiak="numbers";a["exponencial-si"]=a["exponential-if"]=a["esponentzial-baldin"]=a["exponentiel-si"]=a["exponencial-se"]="exponentialif";a.familia=a.family=a["fam\u00edlia"]=a.famille="family";a.intervalo=a.interval=a.tarte=a.intervalle="interval";a.pasos=a.steps=a.passos=a.pausoak=a.pas="steps";a.centro=a.center=a.centre=a.zentro="center";a.radio=a.radius=a.radi=a.erradio=a.rayon=a.raio="radius";a.fin=a.end=a.fi=a.bukaera=a.fim="end";
a["una-sola-vez"]=a["only-once"]=a["una-sola-vegada"]=a["behin-bakarrik"]=a["une-seule-fois"]=a["unha-soa-vez"]=a["apenas-uma-vez"]="onlyOnce";a.siempre=a.always=a.sempre=a.beti=a.toujours="always";a["color-int"]=a["int-colour"]=a["barruko-kolore"]=a["couleur-int"]=a["cor-int"]="colorInt";a.repetir=a.loop=a.repeteix=a.errepikatu=a["r\u00e9p\u00e9ter"]="loop";a.controles=a.controls=a.kontrolak=a["contr\u00f4les"]=a.controis="controls";a.animar=a.animate=a.anima=a.animatu=a.animer="animate";a.auto=
"auto";a.alto=a.height=a.alt=a.altu=a.haut=a.altura="height";a.x=a.left="x";a.y=a.top="y";a.espacio=a.space=a.espai=a.espazio=a.espace=a.espazo=a["espa\u00e7o"]="space";a.Nu="Nu";a.Nv="Nv";a.ancho=a.depth=a.amplada=a.zabalera=a.largeur=a.ancho=a.profundidade=a.amplada="width";a.largo=a.length=a.llargada=a.luzera=a.longueur=a.longo=a.comprimento=a.llargada="length";a.alto=a.height=a["al\u00e7ada"]=a.altu=a.hauteur=a.alto=a.altura=a["al\u00e7ada"]="height";a.color_reverso=a.backcolor=a.color_revers=
a["atzealde kolorea"]=a.couleur_revers=a.cor_reverso=a.cor_de_fundo="backcolor";a.aristas=a.edges=a.arestes=a.ertzak=a["ar\u00eates"]=a.arestas="edges";a.rotini=a.inirot="inirot";a.posini=a.inipos="inipos";a["tri\u00e1ngulo"]=a.triangle=a.hirukia=a["tri\u00e2ngulo"]="triangle";a.cara=a.face=a.aurpegi="face";a.polireg=a.regpoly=a["pol\u00edgonoRegular"]="polireg";a.superficie=a.surface=a["superf\u00edcie"]=a.azalera="surface";a.cubo=a.cube=a.cub=a.kubo="cube";a["paralelep\u00edpedo"]=a.box=a["paral\u00b7lelep\u00edpede"]=
a.paralelepipedo=a["parall\u00e9l\u00e9pip\u00e8de"]="box";a.cono=a.cone=a.con=a.kono=a["c\u00f4ne"]="cone";a.cilindro=a.cylinder=a.cilindre=a.zilindro=a.cylindre="cylinder";a.esfera=a.sphere=a["sph\u00e8re"]="sphere";a.tetraedro=a.tetrahedron=a.tetraedre=a["t\u00e9tra\u00e8dre"]="tetrahedron";a.octaedro=a["octahedron="]=a.octaedre=a.oktaedro=a["octa\u00e8dre"]="octahedron";a.dodecaedro=a.dodecahedron=a.dodecaedre=a.dodekaedro=a["dod\u00e9ca\u00e8dre"]="dodecahedron";a.icosaedro=a.icosahedron=a.icosaedre=
a.ikosaedro=a["icosa\u00e8dre"]="icosahedron";a.elipsoide=a.ellipsoid=a["el\u00b7lipsoide"]=a["ellipso\u00efde"]=a["elips\u00f3ide"]="ellipsoid";a.macro=a.makro="macro";a.id="id";a.modelo=a.model=a.eredu=a["mod\u00e8le"]="model";a.color=a.kolore=a.couleur=a.cor="color";a.luz=a.light=a.llum=a.argia=a["lumi\u00e8re"]="light";a.metal=a.metall=a["m\u00e9tal"]="metal";a.alambre=a.wire=a.filferro=a.alanbre=a["fil de fer"]=a.arame="wire";a.cortar=a.split=a.talla=a.moztu=a.couper=a.dividir="split";a.despliegue=
a.render=a.desplegament=a.zabaltze=a["d\u00e8ploiement"]=a.despregamento=a.processar="render";a.orden=a.sort=a.ordre=a.ordena=a.orde=a.ordenar="sort";a.pintor=a.painter=a.margolari=a.peintre="painter";a["trazado de rayos"]=a["ray trace"]=a["tra\u00e7at de raigs"]=a["izpi trazadura"]=a["trace de rayons"]=a["trazado de raios"]=a["tra\u00e7ado de raios"]="raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo="image";a.despl_imagen=a.bg_display=a.despl_imatge=a["irudi desplazamendu"]=
a.despl_image=a.despr_imaxe=a["apresenta\u00e7\u00e3o_de_imagem"]="bg_display";a["arr-izq"]=a.topleft=a["dalt-esq"]=a["goi-ezk"]=a["au-dessus-gau"]=a["arr-esq"]=a["acima-esquerda"]="topleft";a["expand."]=a.stretch=a.hedatu=a["expandir "]="stretch";a.mosaico=a.patch=a.mosaic=a.mosaiko=a["mosa\u00efque"]="patch";a.centrada=a.center=a.zentratu=a["centr\u00e9e"]=a.centrado="center";a.archivo=a.file=a.fitxer=a.artxibo=a.fichier=a.arquivo="file";a.filas_norte=a.rows_north=a.files_nord=a["HTML kodea"]=a.files_nord=
a.filas_norte=a.linhas_norte=a.files_nord="rowsNorth";a.filas_sur=a.rows_south=a.files_sud=a.ipar_lerro=a.files_sud=a.filas_sur=a.linhas_sul=a.files_sud="rowsSouth";a.ancho_este=a.width_east=a.ample_est=a.hego_lerro=a.ample_est=a.ancho_leste=a.largura_leste=a.ample_est="widthEast";a.ancho_oeste=a.width_west=a.ample_oest=a.ekialde_zabalera=a.ample_ouest=a.ancho_oeste=a.largura_oeste=a.ample_oest="widthWest";a.fijo=a.fixed=a.fix=a.hegoalde_zabalera=a.fixe=a.fixo="fixed";a["Reiniciar Animaci\u00f3n"]=
a["Init Animation"]=a["Reinicia Animaci\u00f3"]=a.finko=a["Recommencer l'Animation"]=a["Reiniciar Anima\u00e7\u00e3o"]="initAnimation";a["Explicaci\u00f3n"]=a.Explanation=a.Azalpena=a.Explication=a["Explica\u00e7\u00e3o"]=a["Explicaci\u00f3"]="Explanation";a.tooltip=a.dica="tooltip";a.discreto=a.discrete=a.discret=a.diskretu="discrete";a.interfaz=a.gui=a["interf\u00edcie"]=a.interfaze=a["interface"]="gui";a.pulsador=a.spinner=a.polsador=a.pultsadore=a.bouton="spinner";a["campo de texto"]=a.textfield=
a["camp de text"]=a["testu esarrua"]=a["champ de texte"]="textfield";a["men\u00fa"]=a.choice=a.menu=a.escolha="menu";a.barra=a.scrollbar=a.barre="scrollbar";a.opciones=a.options=a.opcions=a.aukerak=a["opci\u00f3ns"]=a["op\u00e7\u00f5es"]="options";a.interior=a.barruko=a["int\u00e9rieur"]="interior";a["condici\u00f3n"]=a.condition=a["condici\u00f3"]=a.baldintza=a["condi\u00e7\u00e3o"]="condition";a["acci\u00f3n"]=a.action=a["acci\u00f3"]=a.ekintza=a["a\u00e7\u00e3o"]="action";a.evento=a.event=a.esdeveniment=
a.gertaera=a["\u00e9v\u00e9nement"]="event";a["abrir URL"]=a["open URL"]=a["obre URL"]=a["URL zabaldu"]=a["ouvrir URL"]="openURL";a["abrir Escena"]=a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]="openScene";a["bot\u00f3n"]=a.button=a["bot\u00f3"]=a.botoi=a.bouton=a["bot\u00e3o"]="button";a.mensaje=a.message=a.mezua=a.mensaxe=a.mensagem=a.missatge="message";a.alternar=a.alternate=a.alterna=a.txandakatu=a.alterner="alternate";a["ejecuci\u00f3n"]=a.execution=
a["execuci\u00f3"]=a.gauzatze=a["ex\u00e9cution"]=a["execuci\u00f3n"]=a["execu\u00e7\u00e3o"]="execution";a.calcular=a.calculate=a.calcula=a.kalkulatu=a.calculer="calculate";a.coord_abs=a.abs_coord=a.koor_abs="abs_coord";a.negrita=a.bold=a.negreta=a.lodi=a["caract\u00e8re gras"]=a.negra=a.negrito="bold";a.cursiva=a.italics=a.etzana=a.italique=a["it\u00e1lico"]="italics";a.subrayada=a.underlined=a.subratllat=a.azpimarratua=a.soulignement=a["subli\u00f1ada"]=a.sublinhado="underlined";a.imagen=a.image=
a.imatge=a.irundia=a.imaxe=a.imagem="image";a.pos_mensajes=a.msg_pos=a.pos_missatges=a.mezuen_pos=a.pos_messages=a.pos_mensaxes="msg_pos";a.izquierda=a.left=a.esquerra=a.eskerrean=a.gauche=a.esquerda=a.esquerda=a.esquerra="x";a.derecha=a.right=a.dreta=a.eskuinan=a.droite=a.dereita=a.direita=a.dreta="right";a["sensible_a_los_movimientos_del_rat\u00f3n"]=a.sensitive_to_mouse_movements=a["sensible_als_moviments_del_ratol\u00ed"]=a["xagu mugimenduarekiko sentikorra"]=a.sensible_aux_mouvements_du_souris=
a.sensible_aos_movementos_do_rato=a["sens\u00edvel_aos_movimentos_do_mouse"]="sensitive_to_mouse_movements";a.reproducir=a.play=a.reprodueix=a.erreproduzitu=a.reproduire=a.reproduzir="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]="activeif";a.rotfin=a.finrot=a.bukrot="endrot";a.posfin=a.finpos=a.bukpos="endpos";a.editable=a.editagarria=a["edit\u00e1vel"]="editable";a.tipo=a.type=a.tipus=a.mota="type";a.R2="R2";a.R3="R3";a.vectores=
a.bektoreak=a.vecteurs=a.vetores=a.vectors="vectors";a["fuente puntos"]=a["font size"]=a["font punts"]=a["puntu iturria"]=a["source points"]=a["fonte puntos"]=a["fonte pontos"]="font_size";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.punto=a.dot=a.punt=a.puntu=a.point=a.ponto="point";a.escenario=a.scenario=a.escenari=a.agertoki=a["sc\u00e8ne"]=a["cen\u00e1rio"]="scenario";a.cID="cID";a.matriz=a.matrix=a.matriu=a.matrice="matrix";
a.filas=a.rows=a.files="rows";a.columnas=a.columns=a.colonnes="columns";a.solo_texto=a.only_text=a.seulement_texte=a["s\u00f3_texto"]=a.tan_sols_texte="onlyText";a.evaluar=a.evaluate="evaluate";a.respuesta=a.answer="answer";a.decimal_symbol=a["signo decimal"]=a["decimal symbol"]="decimal_symbol";a.info="info";a.color_contorn_text=a.color_text_border=a.color_borde_texto=a.muga_testuaren_kolorea=a.couleur_contour_texte=a.cor_borde_texto=a.colore_bordo_testo=a.cor_borda_texto=a.color_contorn_text="border";
a.video=a["vid\u00e9o"]="video";a.audio=a["\u00e0udio"]="audio";a.autoplay="autoplay";a.loop="loop";a.poster="poster";a.opacidad=a.opacity=a["opacit\u00e9"]=a.opacitat=a.opacidade="opacity";a.alinear=a.align=a["ali\u00f1ar"]=a.aligner="align";a.malla=a.mesh="mesh";a.local=a.Local="local";a.loadLib=!0;return a}(babel||{}),descartesJS=function(a){function g(){var a,c,f,d,e,l,h,g;Number.prototype.toFixed=function(k){k=0>k?0:parseInt(k);a=this.toString();e=a.indexOf("e");c=a.indexOf(".");if(-1!==e)if(l=
a.split("e"),h=l[0],g=parseInt(l[1]),0>c+g){var p=Math.abs(c+g);a="0."+Array(p+1).join("0")+h.replace(".","");c=1}else h=h.replace(".",""),a=h+Array(g-h.length+2).join("0"),c=-1;f="";if(-1===c)return 0<k&&(f="."),f+=Array(k+1).join("0"),a+f;d=a.length-c-1;if(d>=k)return 0<k?a.substring(0,c+1+k):a.substring(0,c);p=0;for(k-=d;p<k;p++)f+="0";return a+f}}function n(a,c,f){a.fillStyle="#c0c0c0";a.fillRect(c.offsetLeft,c.offsetTop,c.offsetWidth,c.offsetHeight);k(a,c,f.controls)}function k(a,c,f){for(var d,
e=f.length-1;0<=e;e--)d=f[e],a.drawImage(d.getScreenshot(),c.offsetLeft+d.x,c.offsetTop+d.y)}if(a.loadLib)return a;var c=2*Math.PI,e=360/c,f=c/360,l=Math.floor,d,t,p,m,s,h,v,q,u,w;a.rangeOK=1;a.extend=function(a,c){if(a.prototype.__proto__)a.prototype.__proto__=c.prototype;else for(var f in c.prototype)c.prototype.hasOwnProperty(f)&&(a.prototype[f]=c.prototype[f]);a.prototype.uber=c.prototype};a.radToDeg=function(a){return a*e};a.degToRad=function(a){return a*f};a.convertFont=function(a){if(""==a)return a;
d=a.split(",");t="";"bold"==d[1].toLowerCase()?t+="Bold ":"italic"==d[1].toLowerCase()||"italics"==d[1].toLowerCase()?t+="Italic ":"bold+italic"==d[1].toLowerCase()&&(t+="Italic Bold ");t+=d[2]+"px ";p=d[0].split(" ")[0].toLowerCase();return t="serif"===p||"times new roman"===p||"timesroman"===p||"times"===p?t+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===p||"arial"===p||"helvetica"===p?t+"Arial, Helvetica, 'Droid Sans', Sans-serif":t+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};
a.drawLine=function(a,c,f,d,e,h,g){a.lineWidth=g||1;a.strokeStyle=h||"black";h=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(l(c)+h,l(f)+h);a.lineTo(l(d)+h,l(e)+h);a.stroke()};a.getColor=function(a,c){if("string"==typeof c)return c;m=a.evalExpression(c);s=l(255*m[0][0]);h=l(255*m[0][1]);v=l(255*m[0][2]);q=1-m[0][3];return"rgba("+s+","+h+","+v+","+q+")"};a.getFeatures=function(){a.hasJavaSupport=navigator.javaEnabled();var c=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&
window.hasOwnProperty("ontouchstart")||c.match("android")&&!0;a.hasTouchSupport=navigator.userAgent.toLowerCase().match("qt")?!1:a.hasTouchSupport;c=document.createElement("canvas");a.hasCanvasSupport=c.getContext&&c.getContext("2d");a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"));g()};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,
w=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(u=a.pageX,w=a.pageY):(u=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,w=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:u,y:w}};a.getTextWidth=function(c,f){a.ctx.font=f;return a.ctx.measureText(c).width};var r=document.createElement("span");r.appendChild(document.createTextNode("\u00c1p"));var y=document.createElement("div");y.setAttribute("style","display: inline-block; w: 1px; h: 0px;");var B=document.createElement("div");
B.setAttribute("style","margin: 0; padding: 0;");B.appendChild(r);B.appendChild(y);var D={};a.getFontMetrics=function(a){if(D[a])return D[a];r.setAttribute("style","font: "+a+"; margin: 0px; padding: 0px;");document.body.appendChild(B);var c={};y.style.verticalAlign="baseline";c.ascent=y.offsetTop-r.offsetTop;y.style.verticalAlign="bottom";c.h=y.offsetTop-r.offsetTop;c.descent=c.h-c.ascent;c.baseline=c.ascent;document.body.removeChild(B);return D[a]=c};a.getFieldFontSize=function(a){return 14>=a?
8:14<a&&16>=a?9:16<a&&19>=a?10:19<a&&22>=a?11:22<a?parseInt(a-11):l(a-0.25*a)};a.getScreenshot=function(){var c=a.apps[0],f,d=document.createElement("canvas"),e=new Image;if(c){d.setAttribute("width",c.width);d.setAttribute("height",c.height);for(var l=d.getContext("2d"),h=0,g=c.spaces.length;h<g;h++)f=c.spaces[h],"R2"===f.type&&(l.drawImage(f.backgroundCanvas,f.x,f.y),l.drawImage(f.canvas,f.x,f.y),k(l,f.container,f.ctrs));0<c.northSpace.controls.length&&n(l,c.northSpace.container,c.northSpace);0<
c.southSpace.controls.length&&n(l,c.southSpace.container,c.southSpace);0<c.eastSpace.controls.length&&n(l,c.eastSpace.container,c.eastSpace);0<c.westSpace.controls.length&&n(l,c.westSpace.container,c.westSpace);e.src=d.toDataURL("image/png")}return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n;a.openExternalFile=function(a){g=null;var c=!1;if(window.XMLHttpRequest)try{c=new XMLHttpRequest}catch(e){c=!1}else if(window.ActiveXObject)try{c=new ActiveXObject("Msxml2.XMLHTTP")}catch(f){try{c=
new ActiveXObject("Microsoft.XMLHTTP")}catch(l){c=!1}}n=c;n.open("GET",a,!1);try{n.send(null),g=n.responseText,g.match(String.fromCharCode(65533))&&(n.open("GET",a,!1),n.overrideMimeType("text/plain; charset=ISO-8859-1"),n.send(null),g=n.responseText)}catch(d){console.log("Error to load the file :",a),g=null}return g};return a}(descartesJS||{}),descartesJS=function(a){function g(a){e=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};e[0]==e[e.length-1]&&"'"==e[0]&&(a.ignoreCaps=!0,e=e.substring(1,
e.length-1),"`"==e[0]&&"\u00b4"==e[e.length-1]&&(a.ignoreAcents=!0,e=e.substring(1,e.length-1)));"`"==e[0]&&"\u00b4"==e[e.length-1]&&(a.ignoreAcents=!0,e=e.substring(1,e.length-1),e[0]==e[e.length-1]&&"'"==e[0]&&(a.ignoreCaps=!0,e=e.substring(1,e.length-1)));"*"===e.charAt(0)&&"*"!==e.charAt(e.length-1)?e=e.substring(1)+"$":"*"!==e.charAt(0)&&"*"===e.charAt(e.length-1)?e="^"+e.substring(0,e.length-1):"*"!==e.charAt(0)&&"*"!==e.charAt(e.length-1)?e="^"+e+"$":"*"===e.charAt(0)&&"*"===e.charAt(e.length-
1)&&(e=e.substring(1,e.length-1));e=e.replace(/\?/g,"[\\S\\s]{1}");a.regExp=e;return a}function n(a,c){e=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=e.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:c.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:c.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function k(a,c,f){c=parseFloat(c);t=a.expr[0];p=a.expr[1];m=
f.evalExpression(t.expr);s=f.evalExpression(p.expr);h="("==t.type;v="["==t.type;q=")"==p.type;u="]"==p.type;return(h&&c>m||v&&c>=m)&&(q&&c<s||u&&c<=s)?1:0}function c(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 e,f,l,d,t,
p,m,s,h,v,q,u;a.buildRegularExpresionsPatterns=function(a,c){"("===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 d=0,h=a.length;d<h;d++){f=a[d].split("&");l=[];for(var k=0,p=f.length;k<p;k++)e=f[k],-1!==e.indexOf(",")&&("("===e.charAt(0)||"["===e.charAt(0))&&(")"===e.charAt(e.length-1)||"]"===e.charAt(e.length-1))?l.push(n(e,c)):l.push(g(e));a[d]=l}return a};a.escorrecto=function(e,
l,h,g){h=h||a.externalEvaluator;g=g||a.buildRegularExpresionsPatterns(e,h);l=c(l);e=0;for(var p=g.length;e<p;e++){f=g[e];d=!0;for(var m=0,n=f.length;m<n;m++)d=f[m].regExp?d&&!!l.match(c(f[m].regExp),"i"):d&&k(f[m],l,h);if(d)return 1}return 0};a.esCorrecto=function(l,h,g,p){g=g||a.externalEvaluator;p=p||a.buildRegularExpresionsPatterns(l,g);l=0;for(var m=p.length;l<m;l++){f=p[l];d=!0;for(var n=0,t=f.length;n<t;n++)(e=f[n].regExp)?(f[n].ignoreAcents&&(h=c(h),e=c(e)),f[n].ignoreCaps&&(h=h.toLowerCase(),
e=c(e).toLowerCase()),d=d&&!!h.match(e)):d=d=d&&k(f[n],h,g);if(d)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 g=Math.floor,n,k,c,e,f,l,d,t,p;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]){k=[];c=this.splitComa(a.substring(1,a.length-1));for(var d=0,l=c.length;d<l;d++)e=
parseInt(c[d],16),c[d]!=e.toString(16)&&c[d]!=="0"+e.toString(16)?("["===c[d].charAt(0)&&"]"===c[d].charAt(c[d].length-1)&&(c[d]=c[d].substring(1,c[d].length-1)),k.push(this.evaluator.parser.parse(c[d]))):k.push(this.evaluator.parser.parse((e/255).toString()));this.rExpr=k[0];this.gExpr=k[1];this.bExpr=k[2];this.aExpr=k[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){f=
[];for(var c=t=d=l=0,e=a.length;c<e;c++)p=a.charAt(c),"("===p?l++:")"===p?l--:"["===p?d++:"]"===p?d--:","===p&&(0===l&&0===d)&&(f.push(a.substring(t,c)),t=c+1);f.push(a.substring(t));return f};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){n=this.evaluator;this.r=g(255*n.evalExpression(this.rExpr));this.g=g(255*n.evalExpression(this.gExpr));this.b=g(255*n.evalExpression(this.bExpr));this.a=1-n.evalExpression(this.aExpr);return"rgba("+
this.r+","+this.g+","+this.b+","+this.a+")"};a.Color.prototype.borderColor=function(){return 380>this.r+this.g+this.b?"white":"black"};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=document.head,n=document.createElement("meta");n.setAttribute("http-equiv","X-UA-Compatible");n.setAttribute("content","chrome=1");g.appendChild(n);n=document.createElement("meta");n.setAttribute("name","viewport");n.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
g.appendChild(n);n=document.createElement("meta");n.setAttribute("name","apple-mobile-web-app-capable");n.setAttribute("content","yes");g.appendChild(n);n=document.createElement("meta");n.setAttribute("name","apple-mobile-web-app-status-bar-style");n.setAttribute("content","black-translucent");g.appendChild(n);(g=document.getElementById("StyleDescartesApps2"))&&g.parentNode.removeChild(g);g=document.createElement("style");g.type="text/css";g.id="StyleDescartesApps2";g.setAttribute("rel","stylesheet");
document.head.appendChild(g);g.innerHTML="body{ text-rendering:geometricPrecision; }\ncanvas{ image-rendering:optimizeSpeed; image-rendering:-moz-crisp-edges; image-rendering:-webkit-optimize-contrast; image-rendering:optimize-contrast; -ms-interpolation-mode:nearest-neighbor; }\ndiv.DescartesCatcher{ background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; }\ndiv.DescartesAppContainer{ border:0px solid black; position:relative; overflow:hidden; top:0px; left:0px; }\ndiv.DescartesLoader{ background-color :#efefef; position:absolute; overflow:hidden; -moz-box-shadow:0px 0px 0px #888; -webkit-box-shadow:0px 0px 100px #888; box-shadow:0px 0px 100px #888; background-image:linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-o-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-moz-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-webkit-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-ms-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); top:0px; left:0px; }\ndiv.DescartesLoaderImage{ background-repeat:no-repeat; background-position:center; position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesLoaderBar{ position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesSpace2DCanvas, canvas.DescartesSpace3DCanvas, div.blocker{ position:absolute; overflow:hidden; left:0px; top:0px; }\ndiv.DescartesSpace2DContainer, div.DescartesSpace3DContainer{ position:absolute; overflow:hidden; line-height:0px; }\ncanvas.DescartesButton{ position:absolute; cursor:pointer; }\ndiv.DescartesSpinnerContainer, div.DescartesTextFieldContainer{ background:lightgray; position:absolute; overflow:hidden; }\ninput.DescartesSpinnerField, input.DescartesTextFieldField, input.DescartesMenuField, input.DescartesScrollbarField{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding:0px; border:solid #666666 1px; position:absolute; top:0px; }\nlabel.DescartesSpinnerLabel, label.DescartesMenuLabel, label.DescartesScrollbarLabel, label.DescartesTextFieldLabel{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; font-weight:normal; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:#e0e4e8; position:absolute; left:0px; top:0px; }\ndiv.DescartesGraphicControl{ border-style:none; position:absolute; }\ndiv.DescartesTextAreaContainer{ position:absolute; overflow:hidden; background:#c0d0d8; }\nselect.DescartesMenuSelect{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding-top:0%; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:white; position:absolute; left:0px; top:0px; }\ndiv.DescartesScrollbarContainer{ background:#eeeeee; overflow:hidden; position:absolute; }\n";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.sin,n=Math.floor,k=Math.random,c=Math.round,e=Math.abs,f=String.fromCharCode,l,d,t,p,m,s,h,v,q,u;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){l=[];for(var c=0;256>c;c++)l[c]=f(this.alfanum(n(e(7.5*(g(1*c-a)+g(1.4*c+a)+g(0.6*c-a)+g(2.2*c+a))))));return l.join("")};a.Krypto.prototype.encode=function(a){d=n(31*k());this.key=this.getKey(d);p=f(this.alfanum(d));return p+this.encripta(a)};
a.Krypto.prototype.decode=function(a){d=this.numalfa(a.charCodeAt(0));this.key=this.getKey(d);return this.desencripta(a.substring(1))};a.Krypto.prototype.encripta=function(a){return this.bytesToString(this.encriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.encriptaAux=function(a){if(null==a||null==this.key)return null;s=Array(3*a.length);for(var f=0,d=a.length;f<d;f++)q=256*n(a[f]+128)+c(255*k())+65536*c(255*k()),u=n((q<<this.shift(f))/256),s[3*f]=this.alfanum(u%32),s[3*f+1]=this.alfanum(u/32%
32),s[3*f+2]=this.alfanum(u/1024%32);return s};a.Krypto.prototype.desencripta=function(a){return this.bytesToString(this.desencriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.desencriptaAux=function(a){if(null==a||null==this.key)return null;h=Array(a.length/3);for(var c=0,f=h.length;c<f;c++)u=this.numalfa(a[3*c])+32*this.numalfa(a[3*c+1])+1024*this.numalfa(a[3*c+2]),q=n(256*u>>this.shift(c)),v=n(q/256)%256-128,0>v&&(v+=256),h[c]=v;return h};a.Krypto.prototype.alfanum=function(a){a=n(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){p=Array(a.length);for(var c=0,f=a.length;c<f;c++)p[c]=a.charCodeAt(c);return p};a.Krypto.prototype.bytesToString=function(a){for(var c=0,d=a.length;c<d;c++)a[c]=f(a[c]);return a.join("")};a.Krypto.prototype.shift=function(a){t=this.key.charCodeAt(a%this.key.length);p=this.numalfa(t);m=n(p/2%8);0==m&&(m=4);return m};a.Krypto.prototype.parseByte=function(a){a=parseInt(a);a=0>a?0:a;
return 255<a?255:a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Animation=function(g,n){this.parent=g;var k=g.evaluator,c=k.parser,e=new a.Auxiliary(g);this.delay=n.delay?c.parse(n.delay):c.parse("60");this.loop=n.loop?n.loop:!1;this.auto=void 0==n.auto&&2===this.parent.version?!0:n.auto;this.controls=n.controls;this.init=e.splitInstructions(c,n.init);this.doExpr=e.splitInstructions(c,n.doExpr);n.whileExpr&&(this.whileExpr=c.parse(n.whileExpr));var f=this,l,d,t=f.doExpr.length;
this.animationExec=function(){for(d=0;d<t;d++)k.evalExpression(f.doExpr[d]);f.parent.update();f.playing&&(0<k.evalExpression(f.whileExpr)||f.loop)?(l=k.evalExpression(f.delay),f.timer=setTimeout(f.animationExec,10>l?10:l)):(f.stop(),f.parent.update())};this.playing=!1;this.auto&&this.play()};a.Animation.prototype.play=function(){this.playing?this.stop():(this.playing=!0,this.timer=setTimeout(this.animationExec,this.parent.evaluator.evalExpression(this.delay)))};a.Animation.prototype.stop=function(){this.playing=
!1;clearInterval(this.timer)};a.Animation.prototype.reinit=function(){for(var a=0,n=this.init.length;a<n;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,n){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(g,n){a.Action.call(this,g,n);this.parameter=n};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(g,n){a.Action.call(this,g,n);var k=this.evaluator,c=k.parser;n=(n||"").replace(/&squot;/g,"'");n=n.replace(/;/g,"\\n");n=n.split("\\n")||[""];for(var e=[],f,l=0,d=n.length;l<d;l++)(f=c.parse(n[l],!0))&&e.push(f);d=e.length;this.execute=function(){for(l=0;l<d;l++)k.evalExpression(e[l])}};a.extend(a.Calculate,a.Action);return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(g,n){a.Action.call(this,g,n);this.parameter=n;this.target="_blank";var k=this.parameter.indexOf("target");-1!=k&&(this.target=this.parameter.substring(k),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,k-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(g,n){a.Action.call(this,g,n);this.parameter=n;this.target="_blank";var k=this.parameter.indexOf("target");-1!=k&&
(this.target=this.parameter.substring(k),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,k-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(){this.window=window.open(this.parameter,this.target,"width="+this.parent.width+",height="+this.parent.height+",left="+(window.screen.width-this.parent.width)/2+", top="+(window.screen.height-this.parent.height)/2+"location=no,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no");this.window.onload=function(a){a=this.document;
var e=a.getElementsByTagName("applet");e&&0<e.length&&(this.innerWidth=e[0].width,this.height=e[0].height,a.body.style.margin="0px",a.body.style.padding="0px",e[0].parentNode.style.margin="0px",e[0].parentNode.style.padding="0px")}})};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(g,n){a.Action.call(this,g,n);n||(this.urlAbout=window.location.href.substring(0,window.location.href.lastIndexOf("/")+
1)+n)};a.extend(a.About,a.Action);a.About.prototype.execute=function(){if(this.urlAbout)var a=window.open(this.urlAbout,"_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes");else a=window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes"),a.document.write("<hmtl><head><title>Cr\u00e9ditos</title></head><body><h1>Aqu\u00ed van los cr\u00e9ditos</h1></body></html>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.Config=function(g,n){a.Action.call(this,g,n)};a.extend(a.Config,a.Action);a.Config.prototype.execute=function(){window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'>"+this.parent.applet.outerHTML+"</xmp>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Init=function(g,n){a.Action.call(this,g,n)};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(g,n){a.Action.call(this,g,n)};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(g,n){a.Action.call(this,g,n)};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(g,n){a.Action.call(this,g,n)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.PlayAudio=function(g,n){a.Action.call(this,g,n);this.filenameExpr=n?this.evaluator.parser.parse("'"+n.split(" ")[0].trim()+"'"):"";this.filename=this.evaluator.evalExpression(this.filenameExpr);this.theAudio=g.getAudio(this.filename)};a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=
function(){var a=this.theAudio;a.paused?a.play():(a.pause(),a.currentTime=0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Auxiliary=function(a,c){this.parent=a;this.evaluator=this.parent.evaluator;this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var e in c)c.hasOwnProperty(e)&&(this[e]=c[e])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var g,n;a.Auxiliary.prototype.splitInstructions=function(a,c){n=[];c=c?
c.split(";"):[""];for(var e=0,f=c.length;e<f;e++)(g=a.parse(c[e],!0))&&n.push(g);return n};a.Auxiliary.prototype.getPrivateVariables=function(a,c){n=[];c=c?c.split(/;|,/):[""];for(var e=0,f=c.length;e<f;e++)(g=a.parse(c[e],!0))&&n.push(g);e=0;for(f=n.length;e<f;e++)n[e]="asign"===n[e].type?n[e].childs[0].value:"identifier"===n[e].type?n[e].value:"";return n};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(g,n){a.Auxiliary.call(this,g,n);var k=this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=k.parse(this.expresionString))&&k.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"),n=document.createElement("label");n.appendChild(document.createTextNode("___"+this.id+"=___"));var k=document.createElement("input");k.value=this.expresionString;k.disabled=!this.editable;a.appendChild(n);a.appendChild(k);var c=this,e=c.evaluator.parser;k.onkeydown=function(a){13==a.keyCode&&(c.expresion=e.parse(this.value),e.setVariable(c.id,c.expresion),c.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(g,n){a.Auxiliary.call(this,g,n);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=function(){this.evaluator.setVariable(this.id,this.evaluator.evalExpression(this.expresion))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector=function(g,n){var k=g.evaluator,c=k.parser;this.size=c.parse("3");a.Auxiliary.call(this,
g,n);this.expresion=this.expresion.split(";");var e;if(this.file){var f=document.getElementById(this.file);f&&"descartes/vectorFile"==f.type?(e=f.text,"\n"==e[0]&&(e=e.substring(1))):e=a.openExternalFile(this.file);null!=e&&(e=e.split("\n"));null==e||1==e.length&&""==e[0]?(e=[],this.size=0):(this.expresion=[],this.size=null);for(var l,d=0,t=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,f=0,p=e.length;f<p;f++)e[f].match(/./)&&(this.expresion[d]=this.id+"["+d+"]="+e[f],d++,(l=e[f].match(t))&&
this.parent.getImage(l));null===this.size&&(this.size=c.parse(this.expresion.length+""))}f=0;for(p=this.expresion.length;f<p;f++)(e=c.parse(this.expresion[f],!0))&&"asign"!=e.type&&(e=c.parse(this.id+"["+f+"]="+this.expresion[f],!0)),this.expresion[f]=e;c=[];f=0;for(p=k.evalExpression(this.size);f<p;f++)c.push(0);k.vectors[this.id]=c;this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var a=this.evaluator;a.setVariable(this.id+".long",a.evalExpression(this.size));for(var n=
0,k=this.expresion.length;n<k;n++)a.evalExpression(this.expresion[n])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(g,n){var k=g.evaluator,c=k.parser;this.rows=c.parse("3");this.columns=c.parse("3");a.Auxiliary.call(this,g,n);this.expresion=this.splitInstructions(c,this.expresion);var c=k.evalExpression(this.rows),e=k.evalExpression(this.columns),f=[];f.type="matrix";for(var l,d=0;d<e;d++){l=[];for(var t=0,p=c;t<p;t++)l.push(0);f[d]=l}k.matrices[this.id]=
f;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,n=a.evalExpression(this.rows),k=a.evalExpression(this.columns);a.setVariable(this.id+".filas",n);a.setVariable(this.id+".columnas",k);var c=a.matrices[this.id];c.rows=n;c.cols=k;n=0;for(k=this.expresion.length;n<k;n++)a.evalExpression(this.expresion[n])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(g,n){a.Auxiliary.call(this,g,n);var k=this.evaluator,
c=k.parser,e=this.id.indexOf("(");this.name=this.id.substring(0,e);this.params=this.id.substring(e+1,this.id.length-1);this.domain=this.range?c.parse(this.range):c.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(c);this.expresion=c.parse(this.expresion);var f=this;this.functionExec=function(){if(f.numberOfParams<=arguments.length){for(var c=[],d=0,e=f.privateVars.length;d<
e;d++)c.push(k.getVariable(f.privateVars[d])),k.setVariable(f.privateVars[d],0);for(var g=[],d=0,e=f.params.length;d<e;d++)g[d]=k.getVariable(f.params[d]),k.setVariable(f.params[d],arguments[d]);d=0;for(e=f.init.length;d<e;d++)k.evalExpression(f.init[d]);do{d=0;for(e=f.doExpr.length;d<e;d++)k.evalExpression(f.doExpr[d])}while(0<k.evalExpression(f.whileExpr));var m=k.evalExpression(f.expresion);a.rangeOK=k.evalExpression(f.domain);d=0;for(e=f.params.length;d<e;d++)k.setVariable(f.params[d],g[d]);d=
0;for(e=f.privateVars.length;d<e;d++)k.setVariable(f.privateVars[d],c[d]);return m}return 0};k.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(g,n){a.Auxiliary.call(this,g,n);var k=this.evaluator;this.parseExpressions(k.parser);this.algorithmExec=function(){for(var a=0,e=this.init.length;a<e;a++)k.evalExpression(this.init[a]);do{a=0;for(e=this.doExpr.length;a<e;a++)k.evalExpression(this.doExpr[a])}while(0<
k.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(g,n){a.Auxiliary.call(this,g,n);var k=this.evaluator;this.condition=k.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){0<
k.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<k.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<k.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 g,n,k,c,e;a.Graphic=function(c,e){this.parent=c;this.evaluator=c.evaluator;var d=this.evaluator.parser;this.spaceID="E0";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="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=d.parse("2");for(var g in e)e.hasOwnProperty(g)&&(this[g]=e[g]);this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backgroundCanvas.getContext("2d"));
this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10};a.Graphic.prototype.getSpace=function(){for(var a=this.parent.spaces,c,d=0,e=a.length;d<e;d++)if(c=a[d],c.id==this.spaceID)return c;return a[0]};a.Graphic.prototype.getFamilyValues=function(){g=this.evaluator;n=g.evalExpression(this.family_interval);this.familyInf=n[0][0];this.familySup=n[0][1];this.fSteps=Math.round(g.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?
(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,c,d){g=this.evaluator;this.getFamilyValues();k=g.getVariable(this.family);if(0<=this.fSteps)for(var e=0,p=this.fSteps;e<=p;e++)g.setVariable(this.family,this.familyInf+e*this.family_sep),0<g.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,c,d));g.setVariable("_Text_H_",0);g.setVariable(this.family,k)};a.Graphic.prototype.draw=function(a,c){""!=this.family?this.drawFamilyAux(this.ctx,a,c):0<this.evaluator.evalExpression(this.drawif)&&
(this.update(),this.drawAux(this.ctx,a,c))};a.Graphic.prototype.drawTrace=function(a,c){""!=this.family?this.drawFamilyAux(this.traceCtx,a,c):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,a,c))};a.Graphic.prototype.drawText=function(a,l,d,k,p,m,n,h,v,q,u){if("rtfNode"===l.type)a.fillStyle=p.getColor(),a.strokeStyle=p.getColor(),a.textBaseline="alphabetic",l.draw(a,d,k,v,q,n,u);else{"simpleText"===l.type&&(l=l.toString(v,q).split("\\n"));d+=m.match("Arial")?
-2:m.match("Times")?-2:0;g=this.evaluator;a.fillStyle=p.getColor();a.font=m;a.textAlign=n;a.textBaseline=h;this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=parseInt(this.fontSize/12)+1.5);e=1.2*this.fontSize||0;p=0;for(m=l.length;p<m;p++)c=l[p],this.border&&(a.lineJoin="round",a.strokeText(c,d,k+e*p)),a.fillText(c,d,k+e*p)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=function(a,c){this.text=c.replace("&#x2013","\u2013");this.textElements=[];
this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var e="'",f=0,l=0,d=-1,g,p;f<c.length;)g=c.charAt(f),p=c.charAt(f-1),"["===g&&"\\"===p?(this.textElements.push(c.substring(l,f-1)+"["),this.textElementsMacros.push("'"+c.substring(l,f-1)+"['"),l=f+1):"]"===g&&"\\"===p?(this.textElements.push(c.substring(l,f-1)+"]"),this.textElementsMacros.push("'"+c.substring(l,f-1)+"]'"),l=f+1):"["===g&&-1==d?(this.textElements.push(c.substring(l,f)),this.textElementsMacros.push("'"+
c.substring(l,f)+"'"),l=f,d++):"["===g?d++:"]"===g&&0==d?(this.textElements.push(this.evaluator.parser.parse(c.substring(l,f+1))),this.textElementsMacros.push("["+c.substring(l,f+1)+"]"),l=f+1,d--):("]"==c.charAt(f)&&(d=0>d?d:d-1),e+=c.charAt(f)),f++;this.textElements.push(c.substring(l,f));this.textElementsMacros.push("'"+c.substring(l,f)+"'")};var g,n;a.SimpleText.prototype.toString=function(a,c){g="";for(var e=0,f=this.textElements.length;e<f;e++)"string"===typeof this.textElements[e]?g+=this.textElements[e]:
(n=this.evaluator.evalExpression(this.textElements[e])[0][0],""!==n&&("string"===typeof n?g+=n:(n=parseFloat(n),n=c?n.toFixed(a):parseFloat(n.toFixed(a)),g+=n.toString().replace(".",this.parent.decimal_symbol))));return g};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.floor,n=2*Math.PI,k,c,e,f,l,d,t,p,m,s,h,v,q,u,w,r,y,B,D,z,F,E,C,A,I,H,P,O,x,J,G,K,L,M,S,T,Q,R,N,W,U,X,Z,Y,V;a.Equation=function(c,d){this.width=c.evaluator.parser.parse("1");this.fillM=this.fillP=
"";a.Graphic.call(this,c,d);this.generateStroke();this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();s=new a.R2;h=new a.R2;v=new a.R2;w=new a.R2;q=new a.R2};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"==this.expresion.type){var c=this.expresion.childs[0],d=this.expresion.childs[1];"identifier"==c.type&&"y"==c.value&&!d.contains("y")?(this.funExpr=d,this.drawAux=this.drawAuxFunY):
"identifier"==d.type&&"y"==d.value&&!c.contains("y")?(this.funExpr=c,this.drawAux=this.drawAuxFunY):"identifier"==c.type&&"x"==c.value&&!d.contains("x")?(this.funExpr=d,this.drawAux=this.drawAuxFunX):"identifier"==d.type&&("x"==d.value&&!c.contains("x"))&&(this.funExpr=d,this.drawAux=this.drawAuxFunX)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.generateStroke=function(){this.auxCanvas=document.createElement("canvas");var a=parseInt(this.evaluator.evalExpression(this.width));
this.width_2=parseInt(a/2)||1;this.auxCanvas.setAttribute("width",a);this.auxCanvas.setAttribute("height",a);this.auxCtx=this.auxCanvas.getContext("2d");this.auxCtx.fillStyle=this.color.getColor();this.auxCtx.beginPath();this.auxCtx.arc(this.width_2,this.width_2,this.width_2,0,2*Math.PI,!1);this.auxCtx.fill()};a.Equation.prototype.update=function(){};a.Equation.prototype.draw=function(){""!=this.family?this.drawFamilyAux(this.ctx,this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,
this.color))};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(f,n,x){f.lineWidth=1;k=this.evaluator;c=k.parser;e=this.space;l=k.evalExpression(this.width);l=g(l)/2;c.getVariable("x");c.getVariable("y");d=e.w;t=e.h;p=g(d/8);3>p&&(p=3);m=g(t/8);3>m&&(m=3);b=[];s.set(0,0);h.set(0,0);v.set(0,0);for(I=g(m/2);I<t;I+=m)for(A=g(p/2);A<d;A+=p)if(this.abs_coord?(w.set(A,I),u=this.newt.findZero(w),k.setVariable("x",u.x),k.setVariable("y",
u.y),q.set(u.x,u.y)):(w.set(e.getRelativeX(A),e.getRelativeY(I)),u=this.newt.findZero(w),k.setVariable("x",u.x),k.setVariable("y",u.y),q.set(e.getAbsoluteX(u.x),e.getAbsoluteY(u.y))),r=g(q.ix()),y=g(q.iy()),!(0>r||r>=d||0>y||y>=t||b[r+y*e.w]))if(b[r+y*e.w]=!0,s.x=u.x,s.y=u.y,h.x=u.x,h.y=u.y,B=this.newt.getUnitNormal(),!(0==B.x&&0==B.y)){B.rotL90();v.x=B.x;v.y=B.y;z=D=0;for(F=!1;2>z;){F&&(v.x=-B.x,v.y=-B.y,u.x=s.x,u.y=s.y,h.x=u.x,h.y=u.y,this.abs_coord?q.set(u.x,u.y):q.set(e.getAbsoluteX(u.x),e.getAbsoluteY(u.y)),
r=q.ix(),y=q.iy(),F=!1,D=0);this.abs_coord?(u.x+=v.x,u.y+=v.y):(u.x+=v.x/e.scale,u.y+=v.y/e.scale);u=this.newt.findZero(u);k.setVariable("x",u.x);k.setVariable("y",u.y);v.x=u.x-h.x;v.y=u.y-h.y;v.normalize();if(0==v.x&&0==v.y)break;h.x=u.x;h.y=u.y;this.abs_coord?q.set(u.x,u.y):q.set(e.getAbsoluteX(u.x),e.getAbsoluteY(u.y));E=g(q.ix());C=g(q.iy());if(E!=r||C!=y)if(r=E,y=C,0<=r&&r<d&&0<=y&&y<t)if(D=0,b[r+y*e.w])break;else b[r+y*e.w]=!0,a.rangeOK&&k.evalExpression(this.drawif)&&f.drawImage(this.auxCanvas,
r-this.width_2,y-this.width_2);else F=!0,z++;else 4<++D&&(F=!0,z++)}}};a.Equation.prototype.drawAuxFunY=function(c,h,g){k=this.evaluator;e=this.space;d=e.w;p=1/e.scale;P=e.getAbsoluteY(0);l=k.evalExpression(this.width);f=this.color.getColor();c.fillStyle=f;O=e.getRelativeX(0);k.setVariable("x",O);M=e.getAbsoluteX(O);S=e.getAbsoluteY(k.evalExpression(this.funExpr));N=0;for(h=1;h<d;h++){J=O+h*p;k.setVariable("x",J);G=k.evalExpression(this.funExpr);k.setVariable("y",G);K=e.getAbsoluteX(J);L=e.getAbsoluteY(G);
T=Math.min(N,G);Q=Math.max(N,G);R={min:T,max:Q};if(void 0!==G&&(a.rangeOK&&k.evalExpression(this.drawif))&&!this.hasSingularity(p,J,"x",J-p,N,J,G,R)){if(this.fillM||this.fillP)this.fillM&&(W=this.fillM.getColor()),this.fillP&&(U=this.fillP.getColor()),c.lineWidth=1,c.strokeStyle=L>P?W:U,c.beginPath(),c.moveTo(K+0.5,L),c.lineTo(K+0.5,P),c.stroke();c.lineWidth=l;c.strokeStyle=f;c.beginPath();c.moveTo(M,S);c.lineTo(K,L);c.stroke()}N=G||0;M=K;S=L}};a.Equation.prototype.drawAuxFunX=function(c,d,h){k=this.evaluator;
e=this.space;t=e.h;m=1/e.scale;H=e.getAbsoluteX(0);l=k.evalExpression(this.width);f=this.color.getColor();c.fillStyle=f;x=e.getRelativeY(t);k.setVariable("y",x);M=e.getAbsoluteX(k.evalExpression(this.funExpr));S=e.getAbsoluteY(x);d=0;for(h=1;h<t;h++){G=x+h*m;k.setVariable("y",G);J=k.evalExpression(this.funExpr);k.setVariable("x",J);K=e.getAbsoluteX(J);L=e.getAbsoluteY(G);T=Math.min(d,J);Q=Math.max(d,J);R={min:T,max:Q};if(void 0!==G&&(a.rangeOK&&k.evalExpression(this.drawif))&&!this.hasSingularity(m,
G,"y",G-m,d,G,J,R)){if(this.fillM||this.fillP)this.fillM&&(W=this.fillM.getColor()),this.fillP&&(U=this.fillP.getColor()),c.lineWidth=1,c.strokeStyle=K>H?W:U,c.beginPath(),c.moveTo(K,L+0.5),c.lineTo(H,L+0.5),c.stroke();c.lineWidth=l;c.strokeStyle=f;c.beginPath();c.moveTo(M,S);c.lineTo(K,L);c.stroke()}d=J||0;M=K;S=L}};a.Equation.prototype.hasSingularity=function(a,c,d,f,e,h,l,g){if(1E-12>Math.abs(h-f)||1E-8>Math.abs(h-f)&&Math.abs(l-e)>Math.abs(a))return!0;X=!1;Z=c;Y=(f+h)/2;this.evaluator.setVariable(d,
Y);V=this.evaluator.evalExpression(this.funExpr);g.min<=V&&V<=g.max?X=!1:(g.x=Math.min(g.min,V),g.y=Math.max(g.max,V),X=this.hasSingularity(a,c,d,f,e,Y,V,g)||this.hasSingularity(a,c,d,Y,V,h,l,g));this.evaluator.setVariable(d,Z);return X};a.drawPixel=function(a,c,d,f){a.moveTo(c,d);a.arc(c,d,f,0,n,!1)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var c=this;a.onkeydown=function(a){13==a.keyCode&&(c.expresion=
c.evaluator.parser.parse(this.value),c.parseExpression(),c.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.round;a.Curve=function(c,d){this.parameter="t";this.parameter_interval=c.evaluator.parser.parse("[0,1]");this.parameter_steps=c.evaluator.parser.parse("8");this.width=c.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,c,d);(this.visible=2==this.parent.version&&void 0==this.visible?
!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);var n,k,c,e,f,l,d,t,p,m,s;a.Curve.prototype.update=function(){n=this.evaluator;k=n.evalExpression(this.parameter_interval);this.paraInf=k[0][0];this.paraSup=k[0][1];this.pSteps=n.evalExpression(this.parameter_steps);this.paraSep=0<this.pSteps?Math.abs(this.paraSup-this.paraInf)/this.pSteps:0};a.Curve.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Curve.prototype.drawTrace=function(){this.uber.drawTrace.call(this,
this.fill,this.trace)};a.Curve.prototype.drawAux=function(h,k,q){n=this.evaluator;c=this.space;e=g(n.evalExpression(this.width));h.lineWidth=0<e?e:1E-6;h.lineCap="round";h.lineJoin="round";h.strokeStyle=q.getColor();f=n.getVariable(this.parameter);h.beginPath();n.setVariable(this.parameter,this.paraInf);l=n.evalExpression(this.expresion);this.exprX=this.abs_coord?g(l[0][0]):g(c.getAbsoluteX(l[0][0]));this.exprY=this.abs_coord?g(l[0][1]):g(c.getAbsoluteY(l[0][1]));this.rotateExp&&(d=a.degToRad(n.evalExpression(this.rotateExp)),
t=Math.cos(d),p=Math.sin(d),m=this.exprX*t-this.exprY*p,s=this.exprX*p+this.exprY*t,this.exprX=m,this.exprY=s);h.moveTo(this.exprX+0.5,this.exprY+0.5);for(q=1;q<=this.pSteps;q++)n.setVariable(this.parameter,this.paraInf+q*this.paraSep),l=n.evalExpression(this.expresion),this.exprX=this.abs_coord?g(l[0][0]):g(c.getAbsoluteX(l[0][0])),this.exprY=this.abs_coord?g(l[0][1]):g(c.getAbsoluteY(l[0][1])),this.rotateExp&&(m=this.exprX*t-this.exprY*p,s=this.exprX*p+this.exprY*t,this.exprX=m,this.exprY=s),h.lineTo(this.exprX+
0.5,this.exprY+0.5);this.fill&&(h.fillStyle=k.getColor(),h.fill());h.stroke();n.setVariable(this.parameter,f)};a.Curve.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var c=this;a.onkeydown=function(a){13==a.keyCode&&(c.expresion=c.evaluator.parser.parse(this.value),c.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=2*Math.PI;
a.Sequence=function(g,k){this.size=g.evaluator.parser.parse("2");a.Graphic.call(this,g,k)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){var g=this.evaluator,k=g.evalExpression(this.expresion);this.exprX=k[0][0];this.exprY=k[0][1];if(this.rotateExp){var c=a.degToRad(g.evalExpression(this.rotateExp)),k=Math.cos(c),e=Math.sin(c),c=this.exprX*k-this.exprY*e,k=this.exprX*e+this.exprY*k;this.exprX=c;this.exprY=k}g=g.evalExpression(this.range);this.rangeInf=g[0][0];this.rangeMax=
g[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,k){var c=this.evaluator,e,f,l,d=Math.ceil(c.evalExpression(this.size)-0.4);a.fillStyle=k.getColor();a.beginPath();this.rangeInf>this.rangeMax&&(l=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=l);for(var t=c.getVariable("n"),p=this.rangeInf,m=this.rangeMax;p<=m;p++)c.setVariable("n",
p),l=c.evalExpression(this.expresion),this.exprX=l[0][0],this.exprY=l[0][1],this.abs_coord?e=l[0][1]:(e=this.space.getAbsoluteX(l[0][0]),f=this.space.getAbsoluteY(l[0][1])),a.moveTo(e,f),a.sequence(e,f,d,0,g,!0);c.setVariable("n",t);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,e+d,f-d,this.color,this.font,"start","alphabetic",c.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=2*Math.PI,n=Math.round;a.Point=
function(c,d){this.size=c.evaluator.parser.parse("2");a.Graphic.call(this,c,d)};a.extend(a.Point,a.Graphic);var k,c,e,f,l,d,t,p,m,s,h,v;a.Point.prototype.update=function(){k=this.evaluator;e=k.evalExpression(this.expresion);this.exprX=e[0][0];this.exprY=e[0][1];this.rotateExp&&(f=a.degToRad(k.evalExpression(this.rotateExp)),l=Math.cos(f),d=Math.sin(f),t=this.exprX*l-this.exprY*d,p=this.exprX*d+this.exprY*l,this.exprX=t,this.exprY=p)};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,d){k=this.evaluator;c=this.space;h=n(k.evalExpression(this.size));v=h+1;a.fillStyle=d.getColor();m=this.abs_coord?n(this.exprX):n(c.getAbsoluteX(this.exprX));s=this.abs_coord?n(this.exprY):n(c.getAbsoluteY(this.exprY));a.beginPath();a.arc(m,s,h,0,g,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,m+v+1,s-v,this.color,this.font,"start",
"alphabetic",k.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.round,n=2*Math.PI,k,c,e,f,l,d,t,p,m,s,h,v,q,u,w,r,y,B;a.Segment=function(c,d){this.width=c.evaluator.parser.parse("1");this.size=c.evaluator.parser.parse("2");a.Graphic.call(this,c,d)};a.extend(a.Segment,a.Graphic);a.Segment.prototype.update=function(){k=this.evaluator;e=k.evalExpression(this.expresion);this.endPoints=[];for(var c=0,h=e.length;c<h;c++)this.endPoints[c]=
{x:e[c][0],y:e[c][1]};if(this.rotateExp){f=a.degToRad(k.evalExpression(this.rotateExp));l=Math.cos(f);d=Math.sin(f);c=0;for(h=this.endPoints.length;c<h;c++)t=this.endPoints[c].x*l-this.endPoints[c].y*d,p=this.endPoints[c].x*d+this.endPoints[c].y*l,this.endPoints[c].x=t,this.endPoints[c].y=p}};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,d,f){k=this.evaluator;c=this.space;m=g(k.evalExpression(this.width));a.lineWidth=0<m?m:1E-6;q=k.evalExpression(this.size);0>q&&(q=0);a.fillStyle=d.getColor();a.strokeStyle=f.getColor();a.lineCap="round";s=10+a.lineWidth;u=0==a.lineWidth%2?0:0.5;this.abs_coord?(w=g(this.endPoints[0].x),r=g(this.endPoints[0].y),y=g(this.endPoints[1].x),B=g(this.endPoints[1].y)):(w=g(c.getAbsoluteX(this.endPoints[0].x)),r=g(c.getAbsoluteY(this.endPoints[0].y)),y=g(c.getAbsoluteX(this.endPoints[1].x)),B=g(c.getAbsoluteY(this.endPoints[1].y)));
a.beginPath();a.moveTo(w+u,r+u);a.lineTo(y+u,B+u);a.stroke();a.beginPath();a.arc(w,r,q,0,n,!0);a.arc(y,B,q,0,n,!0);a.fill();this.text!=[""]&&(h=parseInt((w+y)/2)-3,v=parseInt((r+B)/2)+3,this.uber.drawText.call(this,a,this.text,h+s,v-s,this.color,this.font,"start","alphabetic",k.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.floor,n=Math.round,k,c,e,f,l,d,t,p,m,s,h,v,q,u,w,r,y,B;a.Arrow=function(c,d){this.width=c.evaluator.parser.parse("5");
this.size=c.evaluator.parser.parse("2");this.spear=c.evaluator.parser.parse("8");this.arrow=new a.Color("ee0022");a.Graphic.call(this,c,d)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){k=this.evaluator;c=k.evalExpression(this.expresion);this.endPoints=[];for(var h=0,g=c.length;h<g;h++)this.endPoints[h]={x:c[h][0],y:c[h][1]};if(this.rotateExp){e=a.degToRad(k.evalExpression(this.rotateExp));f=Math.cos(e);l=Math.sin(e);h=0;for(g=this.endPoints.length;h<g;h++)d=this.endPoints[h].x*
f-this.endPoints[h].y*l,t=this.endPoints[h].x*l+this.endPoints[h].y*f,this.endPoints[h].x=d,this.endPoints[h].y=t}};a.Arrow.prototype.draw=function(){this.uber.draw.call(this,this.arrow,this.color)};a.Arrow.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.arrow,this.trace)};a.Arrow.prototype.drawAux=function(c,d,f){k=this.evaluator;p=this.space;k.evalExpression(this.size);h=k.evalExpression(this.width);1>h&&(h=1);v=Math.ceil(h/2);q=p.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);c.fillStyle=d.getColor();c.strokeStyle=f.getColor();c.lineWidth=2;this.abs_coord?(w=n(this.endPoints[0].x),r=n(this.endPoints[0].y),y=n(this.endPoints[1].x),B=n(this.endPoints[1].y)):(w=n(p.getAbsoluteX(this.endPoints[0].x)),r=n(p.getAbsoluteY(this.endPoints[0].y)),y=n(p.getAbsoluteX(this.endPoints[1].x)),B=n(p.getAbsoluteY(this.endPoints[1].y)));d=k.evalExpression(this.spear);
0>d&&(d=0);c.save();c.translate(w,r,u);this.abs_coord?0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?c.rotate(this.angle):c.rotate(-this.angle):(u*=q,0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?c.rotate(-this.angle):c.rotate(this.angle));c.beginPath();c.moveTo(-v,g(-v));c.lineTo(g(u-d-h),g(-v));c.lineTo(g(u-2*d),g(-d-v));c.lineTo(g(u),0);c.lineTo(g(u-2*d),g(d+v));c.lineTo(g(u-d-h),g(v));c.lineTo(-v,g(v));c.closePath();c.stroke();c.fill();c.restore();this.text!=[""]&&
(m=parseInt((w+y)/2)-3,s=parseInt((r+B)/2)+3,this.uber.drawText.call(this,c,this.text,m,s,f,this.font,"start","alphabetic",k.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.round,n,k,c,e,f,l,d,t,p,m,s,h;a.Polygon=function(c,d){this.width=c.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,c,d);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){n=this.evaluator;c=n.evalExpression(this.expresion);
for(var h=0,g=c.length;h<g;h++)this.endPoints[h]={x:c[h][0],y:c[h][1]};if(this.rotateExp){e=a.degToRad(n.evalExpression(this.rotateExp));f=Math.cos(e);l=Math.sin(e);h=0;for(g=this.endPoints.length;h<g;h++)d=this.endPoints[h].x*f-this.endPoints[h].y*l,t=this.endPoints[h].x*l+this.endPoints[h].y*f,this.endPoints[h].x=d,this.endPoints[h].y=t}};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,c,d){n=this.evaluator;k=this.space;p=g(n.evalExpression(this.width));a.lineWidth=0<p?p:1E-6;a.strokeStyle=d.getColor();a.lineCap="round";a.lineJoin="round";m=0<p?0.5:0;s=this.abs_coord?g(this.endPoints[0].x):g(k.getAbsoluteX(this.endPoints[0].x));h=this.abs_coord?g(this.endPoints[0].y):g(k.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(s+m,h+m);d=1;for(var f=this.endPoints.length;d<f;d++)s=this.abs_coord?g(this.endPoints[d].x):g(k.getAbsoluteX(this.endPoints[d].x)),
h=this.abs_coord?g(this.endPoints[d].y):g(k.getAbsoluteY(this.endPoints[d].y)),a.lineTo(s+m,h+m);this.fill&&(a.fillStyle=c.getColor(),a.fill());a.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.round;a.Arc=function(c,d){this.width=c.evaluator.parser.parse("1");this.fill="";this.center=c.evaluator.parser.parse("(0,0)");this.radius=c.evaluator.parser.parse("1");this.init=c.evaluator.parser.parse("0");this.end=c.evaluator.parser.parse("90");a.Graphic.call(this,
c,d)};a.extend(a.Arc,a.Graphic);var n,k,c,e,f,l,d,t,p,m,s,h,v,q,u,w,r,y,B,D,z,F,E,C;a.Arc.prototype.update=function(){n=this.evaluator;k=n.evalExpression(this.center);this.exprX=k[0][0];this.exprY=k[0][1];this.rotateExp&&(c=a.degToRad(n.evalExpression(this.rotateExp)),e=Math.cos(c),f=Math.sin(c),l=this.exprX*e-this.exprY*f,d=this.exprX*f+this.exprY*e,this.exprX=l,this.exprY=d);t=n.evalExpression(this.init);p=n.evalExpression(this.end);"(expr)"==this.init.type&&"(expr)"==this.end.type||"[expr]"==this.init.type&&
"[expr]"==this.end.type||"(expr)"==this.init.type&&"[expr]"==this.end.type||"[expr]"==this.init.type&&"(expr)"==this.end.type?(this.vectors=!0,m=t[0][0],s=t[0][1],h=p[0][0],v=p[0][1],q=Math.acos((1*m+0*s)/Math.sqrt(m*m+s*s)),u=Math.acos((1*h+0*v)/Math.sqrt(h*h+v*v)),0<m&&(0<s&&!this.abs_coord)&&(q=2*Math.PI-q),0<m&&(0>s&&this.abs_coord)&&(q=2*Math.PI-q),0>m&&(0>s&&this.abs_coord)&&(q=2*Math.PI-q),0>m&&(0<s&&!this.abs_coord)&&(q=2*Math.PI-q),0<h&&(0<v&&!this.abs_coord)&&(u=2*Math.PI-u),0<h&&(0>v&&
this.abs_coord)&&(u=2*Math.PI-u),0>h&&(0>v&&this.abs_coord)&&(u=2*Math.PI-u),0>h&&(0<v&&!this.abs_coord)&&(u=2*Math.PI-u),w=Math.min(q,u),r=Math.max(q,u),q=w,u=r,u-q>Math.PI&&this.abs_coord&&(q=r,u=w),u-q<=Math.PI&&!this.abs_coord&&(q=r,u=w),this.iniAng=q,this.endAng=u):(this.vectors=!1,this.iniAng=a.degToRad(t),this.endAng=a.degToRad(p))};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,c,d){n=this.evaluator;y=this.space;B=this.abs_coord?g(this.exprX):g(y.getAbsoluteX(this.exprX));D=this.abs_coord?g(this.exprY):g(y.getAbsoluteY(this.exprY));z=n.evalExpression(this.radius);!this.vectors&&this.iniAng>this.endAng&&(F=this.iniAng,this.iniAng=this.endAng,this.endAng=F);0>z&&(z=0);E=!1;this.abs_coord||(z*=y.scale,this.vectors||(this.iniAng=-this.iniAng,this.endAng=-this.endAng,E=!0));this.vectors&&(E=this.abs_coord?!1:!0);C=g(n.evalExpression(this.width));
a.lineWidth=0<C?C:1E-6;a.lineCap="round";a.strokeStyle=d.getColor();a.beginPath();a.arc(B,D,z,this.iniAng,this.endAng,E);this.fill&&(a.fillStyle=c.getColor(),a.fill());a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,B+4,D-2,this.color,this.font,"start","alphabetic",n.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){function g(a,c,f){d=4*(c+f*a.width);return{r:a.data[d],g:a.data[d+1],b:a.data[d+2],a:a.data[d+3]}}if(a.loadLib)return a;
var n,k,c,e,f,l,d;a.Fill=function(c,d){a.Graphic.call(this,c,d)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){n=this.evaluator.evalExpression(this.expresion);this.exprX=n[0][0];this.exprY=n[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,p){p.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(k=parseInt(this.exprX),c=parseInt(this.exprY)):
(k=parseInt(this.space.getAbsoluteX(this.exprX)),c=parseInt(this.space.getAbsoluteY(this.exprY)));e=[{x:k,y:c}];for(l=g(imageData,k,c);0<e.length;){f=e.pop();k=f.x;c=f.y;var m=g(imageData,k,c);if(l.r===m.r&&l.g===m.g&&l.b===m.b&&l.a===m.a){var m=imageData,n=p;d=4*(k+c*m.width);m.data[d+0]=n.r;m.data[d+1]=n.g;m.data[d+2]=n.b;m.data[d+3]=255-n.a;0<k&&e.push({x:k-1,y:c});k<imageData.width-1&&e.push({x:k+1,y:c});e.push({x:k,y:c-1});e.push({x:k,y:c+1})}}this.ctx.putImageData(imageData,0,0)};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var g,n,k,c,e,f,l,d,t,p,m,s,h,v,q,u,w,r;a.Text=function(c,d){this.width=c.evaluator.parser.parse("0");a.Graphic.call(this,c,d);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(){g=this.evaluator;n=g.evalExpression(this.expresion);this.exprX=n[0][0];this.exprY=n[0][1];this.rotateExp&&(k=a.degToRad(g.evalExpression(this.rotateExp)),
c=Math.cos(k),e=Math.sin(k),f=this.exprX*c-this.exprY*e,l=this.exprX*e+this.exprY*c,this.exprX=f,this.exprY=l)};a.Text.prototype.draw=function(){this.uber.draw.call(this,this.color)};a.Text.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.color)};a.Text.prototype.drawAux=function(a,c){r=this.evaluator.evalExpression(this.decimals);"rtfNode"===this.text.type?(m=this.text,this.ascent=0):m=this.splitText(this.text.toString(r,this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,
a,m,parseInt(this.exprX)+5,parseInt(this.exprY)+this.ascent,c,this.font,this.align,"alphabetic",r,this.fixed)};a.Text.prototype.splitText=function(a){g=this.evaluator;d=g.evalExpression(this.width);m=[];this.ctx.font=this.font;if(20<=d&&"undefined"!=a.type){for(var c=0,f=a.length;c<f;c++)t=a[c],p=this.ctx.measureText(t).width,p>d?m=m.concat(this.splitWords(t,d)):m.push(t);s=Math.floor(1.2*this.fontSize)*m.length;g.setVariable("_Text_H_",s);return m}g.setVariable("_Text_H_",0);g.setVariable("_Text_W_",
1E3);return a};a.Text.prototype.splitWords=function(a,c){h=a;v=[];q="";w=0;for(var d,f=0,e=a.length;f<e;f++)u=h.charAt(f)," "===u&&(lastIndexOfWhite=f),q+=u,Math.round(this.ctx.measureText(q).width)>c&&(d=a.substring(w,f+1)," "!==u&&(-1===d.indexOf(" ")?(lastIndexOfWhite=f,f--):f=lastIndexOfWhite),v.push(a.substring(w,lastIndexOfWhite)),q="",w=f+1);v.push(a.substring(w));return v};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.round;a.Image=function(c,d){this.file=
"";this.inirot=c.evaluator.parser.parse("0");a.Graphic.call(this,c,d);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);var n,k,c,e,f,l,d,t,p,m,s,h,v,q;a.Image.prototype.update=function(){n=this.evaluator;k=n.evalExpression(this.expresion);this.exprX=k[0][0];this.exprY=k[0][1];this.rotateExp&&(c=a.degToRad(n.evalExpression(this.rotateExp)),e=Math.cos(c),f=Math.sin(c),l=this.exprX*e-this.exprY*f,d=this.exprX*f+this.exprY*e,this.exprX=l,this.exprY=d);4==k[0].length&&
(this.centered=!0,this.scaleX=k[0][2],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=k[0][3],0==this.scaleY&&(this.scaleY=1E-5));k[1]&&2==k[1].length&&(this.centered=!0,this.scaleX=k[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=k[1][1],0==this.scaleY&&(this.scaleY=1E-5));if((t=n.evalExpression(this.file))||""==t)this.img=this.parent.getImage(t)};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(c){n=this.evaluator;p=this.space;this.img&&(this.img.ready&&this.img.complete)&&(m=this.centered?0:this.img.width/2,s=this.centered?0:this.img.height/2,h=this.abs_coord?g(this.exprX):g(p.getAbsoluteX(this.exprX)),v=this.abs_coord?g(this.exprY):g(p.getAbsoluteY(this.exprY)),q=a.degToRad(-n.evalExpression(this.inirot)),c.translate(h+m,v+s),c.rotate(q),c.scale(this.scaleX,this.scaleY),this.opacity&&(c.globalAlpha=n.evalExpression(this.opacity)),c.drawImage(this.img,-this.img.width/2,-this.img.height/
2),c.setTransform(1,0,0,1,0,0),c.globalAlpha=1)};return a}(descartesJS||{}),descartesJS=function(a){function g(a,c,f){d=4*(c+f*a.width);return{r:a.data[d],g:a.data[d+1],b:a.data[d+2],a:a.data[d+3]}}if(a.loadLib)return a;var n,k,c,e,f,l,d;a.Fill=function(c,d){a.Graphic.call(this,c,d)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){n=this.evaluator.evalExpression(this.expresion);this.exprX=n[0][0];this.exprY=n[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,p){p.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(k=parseInt(this.exprX),c=parseInt(this.exprY)):(k=parseInt(this.space.getAbsoluteX(this.exprX)),c=parseInt(this.space.getAbsoluteY(this.exprY)));e=[{x:k,y:c}];for(l=g(imageData,k,c);0<e.length;){f=e.pop();k=f.x;c=f.y;var m=g(imageData,k,c);if(l.r===m.r&&l.g===m.g&&l.b===m.b&&l.a===m.a){var m=imageData,n=p;d=4*(k+c*m.width);
m.data[d+0]=n.r;m.data[d+1]=n.g;m.data[d+2]=n.b;m.data[d+3]=255-n.a;0<k&&e.push({x:k-1,y:c});k<imageData.width-1&&e.push({x:k+1,y:c});e.push({x:k,y:c-1});e.push({x:k,y:c+1})}}this.ctx.putImageData(imageData,0,0)};return a}(descartesJS||{}),descartesJS=function(a,g){if(a.loadLib)return a;a.Macro=function(n,k){this.expresion=void 0;this.inirot=n.evaluator.parser.parse("0");a.Graphic.call(this,n,k);for(var c in k)k.hasOwnProperty(c)&&(this[c]=k[c]);this.graphics=[];c=n.lessonParser;var e=new a.Tokenizer;
if(void 0!=this.expresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var f=this.evaluator.evalExpression(this.expresion),l,d=2;f&&((l=document.getElementById(f))&&"descartes/macro"==l.type?(l=l.text,d=3):(l=a.openExternalFile(f))&&!l.match(/tipo_de_macro/g)&&(l=null));var t="|";if(l){l=l.replace(/&aacute;/g,"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,
"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&amp;/g,"&").split("\n").slice(d);for(var p,m,f=0,d=l.length;f<d;f++)l[f]&&(l[f]=c.split(l[f]),l[f]&&(l[f][0]&&l[f][0][0]&&"id"===l[f][0][0])&&(p=l[f][0][1],m=p.indexOf("("),-1!=m&&(p=p.substring(0,m)),t+=p+"|"));for(var s,h,v,
q,f=0,d=l.length;f<d;f++){s=l[f]||[];p=0;for(m=s.length;p<m;p++)if(h=g[s[p][0]],v=s[p][0].indexOf("."),-1!=v&&(h=g[s[p][0].substring(v+1)]),!("id"!=h&&void 0!=g[s[p][1]]))if("text"==h)if(s[p][1].match(/\{\\rtf1/)){h=s[p][1];var u=this;q=function(a,c){for(var d=e.tokenize(c.replace(/\&squot;/g,"'")),f=0,h=d.length;f<h;f++)if("identifier"==d[f].type&&t.match("\\|"+d[f].value+"\\|"))d[f].value=u.name+"."+d[f].value;else if("identifier"==d[f].type&&-1!=(v=d[f].value.indexOf("."))&&t.match("\\|"+d[f].value.substring(0,
v)+"\\|"))d[f].value=u.name+"."+d[f].value;return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+e.flatTokens(d)};h=h.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,q);h=h.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,q);s[p][1]=h}else{q=c.parseText(s[p][1]).textElementsMacros;for(var w=0,r=q.length;w<r;w++){h=e.tokenize(q[w].replace(/\&squot;/g,"'"));for(var y=0,B=h.length;y<B;y++)"identifier"==h[y].type&&t.match("\\|"+h[y].value+"\\|")&&(h[y].value=this.name+
"."+h[y].value);h=e.flatTokens(h).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");q[w]=h.substring(1,h.length-1)}s[p][1]=q.join("")}else{h=e.tokenize(s[p][1]);q=0;for(w=h.length;q<w;q++)if("identifier"==h[q].type&&t.match("\\|"+h[q].value+"\\|"))h[q].value=this.name+"."+h[q].value;else if("identifier"==h[q].type&&-1!=(v=h[q].value.indexOf("."))&&t.match("\\|"+h[q].value.substring(0,v)+"\\|"))h[q].value=this.name+"."+h[q].value;s[p][1]=e.flatTokens(h)}}f=0;for(d=l.length;f<d;f++)if(l[f][0]){s=
"";h=!1;p=0;for(m=l[f].length;p<m;p++)"type"===g[l[f][p][0]]&&(s="espacio='"+this.spaceID+"' ",h=!0),s=s+l[f][p][0]+"='"+l[f][p][1]+"' ";l[f]=s;h?this.graphics.push(c.parseGraphic(l[f],this.abs_coord,this.background,this.inirot)):c.parseAuxiliar(l[f])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){if(this.inipos){var a=this.evaluator.evalExpression(this.inipos);this.iniPosX=a[0][0];this.iniPosY=a[0][1]}};a.Macro.prototype.drawAux=function(a){for(var g=0,c=this.graphics.length;g<
c;g++)this.inipos&&(this.graphics[g].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale)),this.graphics[g].draw(),a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{},babel),descartesJS=function(a){if(a.loadLib)return a;var g=Math.sqrt,n=Math.sin,k=Math.cos,c,e,f,l,d,t,p,m,s,h,v,q,u,w,r;a.normalize3D=function(a){c=g(a.x*a.x+a.y*a.y+a.z*a.z);if(0===c)return{x:0,y:0,z:0};if(1===c)return{x:a.x,y:a.y,z:a.z};c=1/c;return{x:a.x*c,
y:a.y*c,z:a.z*c}};a.dotProduct3D=function(a,c){return a.x*c.x+a.y*c.y+a.z*c.z};a.crossProduct3D=function(a,c){return{x:a.y*c.z-a.z*c.y,y:a.z*c.x-a.x*c.z,z:a.x*c.y-a.y*c.x}};a.direction3D=function(a,c){return{x:a.x-c.x,y:a.y-c.y,z:a.z-c.z}};a.Vector4D=function(a,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||0};a.Matrix4x4=function(a,c,d,f,e,h,l,g,k,p,m,n,t,q,s,w){this.a00=a||0;this.a01=c||0;this.a02=d||0;this.a03=f||0;this.a10=e||0;this.a11=h||0;this.a12=l||0;this.a13=g||0;this.a20=k||0;this.a21=
p||0;this.a22=m||0;this.a23=n||0;this.a30=t||0;this.a31=q||0;this.a32=s||0;this.a33=w||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(c){return new a.Vector4D(c.x*this.a00+c.y*this.a10+c.z*this.a20+c.w*this.a30,c.x*this.a01+c.y*this.a11+c.z*this.a21+c.w*this.a31,c.x*this.a02+c.y*this.a12+
c.z*this.a22+c.w*this.a32,c.x*this.a03+c.y*this.a13+c.z*this.a23+c.w*this.a33)};a.Matrix4x4.prototype.translate=function(c){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*c.x+this.a10*c.y+this.a20*c.z+this.a30,this.a01*c.x+this.a11*c.y+this.a21*c.z+this.a31,this.a02*c.x+this.a12*c.y+this.a22*c.z+this.a32,this.a03*c.x+this.a13*c.y+this.a23*c.z+this.a33)};a.Matrix4x4.prototype.rotateX=function(c){e=n(c);f=k(c);
m=this.a10;s=this.a11;h=this.a12;v=this.a13;q=this.a20;u=this.a21;w=this.a22;r=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,m*f+q*e,s*f+u*e,h*f+w*e,v*f+r*e,m*-e+q*f,s*-e+u*f,h*-e+w*f,v*-e+r*f,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(c){e=n(c);f=k(c);l=this.a00;d=this.a01;t=this.a02;p=this.a03;q=this.a20;u=this.a21;w=this.a22;r=this.a23;return new a.Matrix4x4(l*f+q*-e,d*f+u*-e,t*f+w*-e,p*f+r*-e,this.a10,this.a11,this.a12,this.a13,l*e+q*f,d*
e+u*f,t*e+w*f,p*e+r*f,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(c){e=n(c);f=k(c);l=this.a00;d=this.a01;t=this.a02;p=this.a03;m=this.a10;s=this.a11;h=this.a12;v=this.a13;return new a.Matrix4x4(l*f+m*e,d*f+s*e,t*f+h*e,p*f+v*e,l*-e+m*f,d*-e+s*f,t*-e+h*f,p*-e+v*f,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33)};return a}(descartesJS||{}),descartesJS=function(a){function g(a){a.lineWidth=1;a.fillStyle=this.backColor.getColor();a.strokeStyle=this.frontColor.getColor();
a.beginPath();a.arc(this.newV[0].x,this.newV[0].y,this.size+0.5,0,l);a.fill();a.stroke()}function n(c){c.lineCap=d;c.lineJoin=t;c.beginPath();c.moveTo(this.newV[0].x,this.newV[0].y);for(var f=1,h=this.newV.length;f<h;f++)c.lineTo(this.newV[f].x,this.newV[f].y);c.closePath();"color"===this.model?(c.fillStyle=0<=this.direction?this.backColor.getColor():this.frontColor.getColor(),c.fill()):"light"===this.model||"metal"===this.model?(c.fillStyle=0<=this.direction?e(this.backColor,-a.dotProduct3D(this.normal,
this.light),"metal"===this.model):e(this.frontColor,a.dotProduct3D(this.normal,this.light),"metal"===this.model),c.fill()):"wire"===this.model&&(c.lineWidth=1.25,c.strokeStyle=this.frontColor.getColor(),c.stroke());this.edges&&"wire"!==this.model&&(c.lineWidth=1,c.strokeStyle="#808080",c.stroke())}function k(a){this.drawText(a,this.text,this.newV[0].x,this.newV[0].y+this.displace,this.frontColor.getColor(),this.font,"left","alphabetic",this.decimals,this.fixed,!0)}function c(a){a.lineCap=d;a.lineJoin=
t;a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor.getColor();a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);a.lineTo(this.newV[1].x,this.newV[1].y);a.stroke()}function e(a,c,d){a.getColor();q=f(a.r*c+r.r);u=f(a.g*c+r.g);w=f(a.b*c+r.b);return"rgba("+q+","+u+","+w+","+a.a+")"}if(a.loadLib)return a;var f=Math.floor,l=2*Math.PI,d="round",t="round",p,m,s,h,v,q,u,w;a.Primitive3D=function(d){for(var f in d)d.hasOwnProperty(f)&&(this[f]=d[f]);this.light=a.normalize3D({x:-1,y:0,z:0});this.newV=
[];"vertex"===this.type?this.draw=g:"face"===this.type?this.draw=n:"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,this.draw=k):"edge"===this.type&&(this.draw=c);this.isText&&(this.computeDepth=function(){this.newV=this.vertices;this.depth=this.vertices[0].z})};a.Primitive3D.prototype.computeDepth=function(c){for(var d=0,f=this.vertices.length;d<f;d++)this.newV[d]=c.rotateVertex(this.vertices[d]);2<this.vertices.length&&(p=a.direction3D(this.newV[0],
this.newV[1]),m=a.direction3D(this.newV[0],this.newV[2]),this.normal=a.normalize3D(a.crossProduct3D(p,m)),this.direction=a.dotProduct3D(this.normal,a.normalize3D(c.eye)));d=this.depth=0;for(f=this.vertices.length;d<f;d++)this.newV[d]=c.project(this.newV[d]),this.depth+=this.newV[d].z;this.depth/=f};a.Primitive3D.prototype.drawText=function(c,d,f,e,l,g,k,p,m,n,t){if("rtfNode"==d.type)c.fillStyle=l,c.strokeStyle=l,c.textBaseline="alphabetic",d.draw(c,f,e,m,n,k,t);else{"simpleText"===d.type&&(d=d.toString(m,
n).split("\\n"));f+=g.match("Arial")?-2:g.match("Times")?-2:0;s=this.evaluator;c.fillStyle=a.getColor(s,l);c.font=g;c.textAlign=k;c.textBaseline=p;h=1.2*this.fontSize||0;l=0;for(g=d.length;l<g;l++)v=d[l],this.border&&c.strokeText(v,f,e+h*l),c.fillText(v,f,e+h*l)}};var r={r:40,g:40,b:40};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g={x:0,y:0,z:0},n,k,c,e,f,l,d,t;a.Graphic3D=function(c,d){this.parent=c;this.evaluator=c.evaluator;var f=this.parent.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 d)d.hasOwnProperty(e)&&(this[e]=d[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,c,d=0,f=a.length;d<f;d++)if(c=a[d],c.id==this.spaceID)return c;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){n=this.evaluator;k=n.evalExpression(this.family_interval);this.familyInf=k[0][0];this.familySup=k[0][1];this.fSteps=Math.round(n.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){n=this.evaluator;this.getFamilyValues();
c=n.getVariable(this.family);if(0<=this.fSteps)for(var a=0,d=this.fSteps;a<=d;a++)n.setVariable(this.family,this.familyInf+a*this.family_sep),n.evalExpression(this.drawif)&&this.buildPrimitives();n.setVariable(this.family,c)};a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.evalExpression(this.drawif)&&(this.family?this.buildFamilyPrimitives():this.buildPrimitives())};a.Graphic3D.prototype.updateMVMatrix=function(c){f=this.evaluator.evalExpression(this.inirot);this.inirotEuler?
(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(f[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(f[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(f[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(f[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(f[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(f[0][2])));f=this.evaluator.evalExpression(this.inipos);g={x:f[0][0],y:f[0][1],z:f[0][2]};
this.iniposM=this.iniposM.setIdentity().translate(g);f=this.evaluator.evalExpression(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(f[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(f[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(f[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(f[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(f[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(f[0][2])));
f=this.evaluator.evalExpression(this.endpos);g={x:f[0][0],y:f[0][1],z:f[0][2]};this.endposM=this.endposM.setIdentity().translate(g)};a.Graphic3D.prototype.transformVertex=function(a){this.inirotEuler?e=this.inirotM.multiplyVector4(a):(e=this.inirotM_X.multiplyVector4(a),e=this.inirotM_Y.multiplyVector4(e),e=this.inirotM_Z.multiplyVector4(e));e=this.iniposM.multiplyVector4(e);this.endrotEuler?e=this.endrotM.multiplyVector4(e):(e=this.endrotM_X.multiplyVector4(e),e=this.endrotM_Y.multiplyVector4(e),
e=this.endrotM_Z.multiplyVector4(e));return e=this.endposM.multiplyVector4(e)};a.Graphic3D.prototype.parseExpression=function(){f=this.expresion.split("=");l=f[0];d=[];for(var a=1;a<f.length;a++)l+="=",t=f[a].lastIndexOf(" "),l+=-1!==t?f[a].substring(0,t):f[a],d.push(this.evaluator.parser.parse(l,!0)),l=f[a].substring(t+1);return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n;a.Point3D=function(g,c){a.Graphic3D.call(this,g,c);this.mvMatrix=(new a.Matrix4x4).setIdentity()};
a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){g=this.evaluator;this.updateMVMatrix();n=g.evalExpression(this.expresion);this.exprX=n[0][0];this.exprY=n[0][1];this.exprZ=n[0][2];this.space.addPrimitive({vertices:[this.transformVertex(new a.Vector4D(this.exprX,this.exprY,this.exprZ,1))],type:"vertex",backColor:this.backcolor,frontColor:this.color,size:g.evalExpression(this.width)});""!==this.text&&this.space.addPrimitive({vertices:[this.transformVertex(new a.Vector4D(this.exprX,
this.exprY,this.exprZ,1))],type:"text",frontColor:this.color,font:this.font,decimals:this.evaluator.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize,evaluator:this.evaluator,text:this.text})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n,k,c,e,f;a.Segment3D=function(c,d){this.width=c.evaluator.parser.parse("1");a.Graphic3D.call(this,c,d);this.mvMatrix=(new a.Matrix4x4).setIdentity()};a.extend(a.Segment3D,a.Graphic3D);a.Segment3D.prototype.buildPrimitives=
function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);g=expr[0][0];n=expr[0][1];k=expr[0][2];c=expr[1][0];e=expr[1][1];f=expr[1][2];this.space.addPrimitive({vertices:[this.transformVertex(new a.Vector4D(g,n,k,1)),this.transformVertex(new a.Vector4D(c,e,f,1))],type:"edge",frontColor:this.color,lineWidth:this.evaluator.evalExpression(this.width)})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n,k,c,e,f,l;a.Surface3D=
function(c,f){this.parameter="t";this.parameter_interval=c.evaluator.parser.parse("[0,1]");this.parameter_steps=c.evaluator.parser.parse("8");a.Graphic3D.call(this,c,f);this.mvMatrix=(new a.Matrix4x4).setIdentity();this.expresion=this.parseExpression()};a.extend(a.Surface3D,a.Graphic3D);a.Surface3D.prototype.buildPrimitives=function(){g=this.evaluator;this.updateMVMatrix();k=g.getVariable("x");k=g.getVariable("y");k=g.getVariable("z");n=g.getVariable("u");k=g.getVariable("v");g.setVariable("u",0);
g.setVariable("v",0);c=g.evalExpression(this.Nu);e=g.evalExpression(this.Nv);f=[];for(var d=0;d<=c;d++){g.setVariable("u",d/c);for(var t=0;t<=e;t++){g.setVariable("v",t/e);for(var p=0,m=this.expresion.length;p<m;p++)g.evalExpression(this.expresion[p]);f.push(this.transformVertex(new a.Vector4D(g.getVariable("x"),g.getVariable("y"),g.getVariable("z"),1)))}}for(d=0;d<c;d++)for(t=0;t<e;t++)l=[],l.push(f[t+d*e+d]),l.push(f[t+1+d*e+d]),l.push(f[t+2+(d+1)*e+d]),l.push(f[t+1+(d+1)*e+d]),this.space.addPrimitive({vertices:l,
type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model});g.setVariable("x",void 0);g.setVariable("y",void 0);g.setVariable("z",void 0);g.setVariable("u",n);g.setVariable("v",k)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n,k,c,e,f;a.Polygon3D=function(c,d){this.width=c.evaluator.parser.parse("1");a.Graphic3D.call(this,c,d);this.mvMatrix=(new a.Matrix4x4).setIdentity()};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=
function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);for(var l=0,d=expr.length-1;l<d;l++)g=expr[l][0],n=expr[l][1],k=expr[l][2],c=expr[l+1][0],e=expr[l+1][1],f=expr[l+1][2],this.space.addPrimitive({vertices:[this.transformVertex(new a.Vector4D(g,n,k,1)),this.transformVertex(new a.Vector4D(c,e,f,1))],type:"edge",frontColor:this.color,lineWidth:this.evaluator.evalExpression(this.width)})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var g,n,k,c,e,f;a.Curve3D=function(c,d){this.width=c.evaluator.parser.parse("1");a.Graphic3D.call(this,c,d);this.mvMatrix=(new a.Matrix4x4).setIdentity();this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();c=evaluator.getVariable("x");e=evaluator.getVariable("y");f=evaluator.getVariable("z");k=evaluator.getVariable("u");evaluator.setVariable("u",0);n=evaluator.evalExpression(this.Nu);g=
[];for(var l=0;l<=n;l++){evaluator.setVariable("u",l/n);for(var d=0,t=this.expresion.length;d<t;d++)evaluator.evalExpression(this.expresion[d]);g.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}l=0;for(d=g.length-1;l<d;l++)this.space.addPrimitive({vertices:[g[l],g[l+1]],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)});evaluator.setVariable("x",c);evaluator.setVariable("y",f);evaluator.setVariable("z",
e);evaluator.setVariable("u",k)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n,k,c,e,f,l,d,t;a.Triangle3D=function(c,d){a.Graphic3D.call(this,c,d);this.mvMatrix=(new a.Matrix4x4).setIdentity()};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);g=expr[0][0];n=expr[0][1];k=expr[0][2];c=expr[1][0];e=expr[1][1];f=expr[1][2];l=expr[2][0];d=expr[2][1];
t=expr[2][2];this.space.addPrimitive({vertices:[this.transformVertex(new a.Vector4D(g,n,k,1)),this.transformVertex(new a.Vector4D(l,d,t,1)),this.transformVertex(new a.Vector4D(c,e,f,1))],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g;a.Face3D=function(g,k){a.Graphic3D.call(this,g,k);this.mvMatrix=(new a.Matrix4x4).setIdentity()};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=
function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);g=[];for(var n=expr.length-1;0<=n;n--)g.push(this.transformVertex(new a.Vector4D(expr[n][0],expr[n][1],expr[n][2],1)));this.space.addPrimitive({vertices:g,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n,k,c,e;a.Polireg3D=function(c,e){this.width=c.evaluator.parser.parse("2");
this.length=c.evaluator.parser.parse("2");a.Graphic3D.call(this,c,e);this.mvMatrix=(new a.Matrix4x4).setIdentity()};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();g=evaluator.evalExpression(this.Nu);n=[this.transformVertex(new a.Vector4D(0,0,0,1))];k=evaluator.evalExpression(this.width)/2;c=evaluator.evalExpression(this.length)/2;e=2*Math.PI/g;for(var f=0;f<g;f++)n.push(this.transformVertex(new a.Vector4D(k*Math.cos(e*
f),c*Math.sin(e*f),0,1)));for(f=0;f<g;f++)this.space.addPrimitive({vertices:[n[0],f+2<=g?n[f+2]:n[1],n[f+1]],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Text3D=function(g,n){a.Graphic3D.call(this,g,n)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;expr=evaluator.evalExpression(this.expresion);this.exprX=expr[0][0];this.exprY=
expr[0][1];this.exprZ=0;this.space.addPrimitive({vertices:[new a.Vector4D(this.exprX,this.exprY,this.exprZ,1)],type:"text",frontColor:this.color,font:this.font,decimals:this.evaluator.evalExpression(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:this.evaluator,text:this.text})};return a}(descartesJS||{}),descartesJS=function(a){function g(a,c,d,f,e){n.call(this,a/1.8,a/1.8,a/1.8,f,e)}function n(a,c,d,f,e){a/=2;c/=2;d/=2;this.changeGeometry(a,c,d,f,e)||(this.vertices=[new q(a,d,c,1),
new q(a,-d,c,1),new q(a,d,-c,1),new q(a,-d,-c,1),new q(-a,d,c,1),new q(-a,-d,c,1),new q(-a,d,-c,1),new q(-a,-d,-c,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,c,d,f,e))}function k(a,c,d,f,e){a/=2;this.changeGeometry(a,c,d,f,e)||(this.vertices=[new q(0,0,a,1),new q(-0.49*a,-0.86*a,-0.32*a,1),new q(-0.49*a,0.86*a,-0.32*a,1),new q(1*a,0,-0.32*a,1)],this.faces=[[3,2,1],[1,2,0],[2,3,0],[3,1,0]],this.updateValues(a,c,d,f,e))}function c(a,c,d,f,e){a/=2;
this.changeGeometry(a,c,d,f,e)||(this.vertices=[new q(0,0,a,1),new q(a,0,0,1),new q(-a,0,0,1),new q(0,a,0,1),new q(0,-a,0,1),new q(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,c,d,f,e))}function e(c,d,f,e,l){c/=3.4;if(!this.changeGeometry(c,d,f,e,l)){E=c/F;C=c*F;this.vertices=[new q(c,c,c,1),new q(c,c,-c,1),new q(c,-c,c,1),new q(c,-c,-c,1),new q(-c,c,c,1),new q(-c,c,-c,1),new q(-c,-c,c,1),new q(-c,-c,-c,1),new q(0,E,C,1),new q(0,E,-C,
1),new q(0,-E,C,1),new q(0,-E,-C,1),new q(E,C,0,1),new q(E,-C,0,1),new q(-E,C,0,1),new q(-E,-C,0,1),new q(C,0,E,1),new q(C,0,-E,1),new q(-C,0,E,1),new q(-C,0,-E,1)];A=(new a.Matrix4x4).setIdentity().rotateY(-h/6);for(var g=0,k=this.vertices.length;g<k;g++)this.vertices[g]=A.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(c,
d,f,e,l)}}function f(c,d,f,e,h){c/=4;if(!this.changeGeometry(c,d,f,e,h)){C=c*F;this.vertices=[new q(0,c,C,1),new q(0,c,-C,1),new q(0,-c,C,1),new q(0,-c,-C,1),new q(c,C,0,1),new q(c,-C,0,1),new q(-c,C,0,1),new q(-c,-C,0,1),new q(C,0,c,1),new q(C,0,-c,1),new q(-C,0,c,1),new q(-C,0,-c,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]];A=(new a.Matrix4x4).setIdentity().rotateY(-1.029);
for(var l=0,g=this.vertices.length;l<g;l++)this.vertices[l]=A.multiplyVector4(this.vertices[l]);this.updateValues(c,d,f,e,h)}}function l(a,c,d,f,e){a/=2;this.isSphere?d=c=a:(c/=2,d/=2);if(!this.changeGeometry(a,c,d,f,e)){this.vertices=[new q(0,0,c,1)];for(var l=1;l<f;l++){z=l*h/f;for(var g=0;g<e;g++)D=g*v/e,r=a*m(z)*s(D),y=d*m(z)*m(D),B=c*s(z),this.vertices.push(new q(r,y,B,1))}this.vertices.push(new q(0,0,-c,1));this.faces=[];for(l=0;l<e;l++)this.faces.push([0,(l+1)%e+1,l%e+1]);for(l=1;l<f-1;l++)for(g=
0;g<e;g++)this.faces.push([g+1+(l-1)*e,(g+1)%e+1+(l-1)*e,(g+1)%e+1+l*e,g+1+l*e]);for(l=0;l<e;l++)this.faces.push([this.vertices.length-1,this.vertices.length-1-e+l,this.vertices.length-1-e+(l+1)%e]);this.updateValues(a,c,d,f,e)}}function d(a,c,d,f,e){a/=2;c/=2;d/=2;if(!this.changeGeometry(a,c,d,f,e)){this.vertices=[];for(var h=0;h<e;h++)for(var l=0;l<f;l++)r=a*(e-h)/e*s(l*v/f),y=d*(e-h)/e*m(l*v/f),B=c-2*h*c/e,this.vertices.push(new q(r,y,B,1));this.vertices.push(new q(0,0,-c,1));this.faces=[];for(h=
0;h<e-1;h++)for(l=0;l<f;l++)this.faces.push([l+h*f,(l+1)%f+h*f,(l+1)%f+(h+1)*f,l+(h+1)*f]);for(h=0;h<f;h++)this.faces.push([this.vertices.length-1,this.vertices.length-1-f+h,this.vertices.length-1-f+(h+1)%f]);this.updateValues(a,c,d,f,e)}}function t(a,c,d,f,e){a/=2;c/=2;d/=2;if(!this.changeGeometry(a,c,d,f,e)){this.vertices=[];for(var h=0;h<e+1;h++)for(var l=0;l<f;l++)r=a*s(l*v/f),y=d*m(l*v/f),B=c-2*h*c/e,this.vertices.push(new q(r,y,B,1));this.faces=[];for(h=0;h<e;h++)for(l=0;l<f;l++)this.faces.push([l+
h*f,(l+1)%f+h*f,(l+1)%f+(h+1)*f,l+(h+1)*f]);this.updateValues(a,c,d,f,e)}}function p(){function a(c){return parseInt(c)}function c(a){return parseFloat(a)}this.vertices=[];this.faces=[];for(var d=0,f=this.fileData.length;d<f;d++)I=this.fileData[d],I.match(/^V\(/)?(H=I.substring(2,I.length-1).split(",").map(c),this.vertices.push(new q(H[0]||0,H[1]||0,H[2]||0,1))):I.match(/^F\(/)&&(H=I.substring(2,I.length-1).split(",").map(a),this.faces.push(H.reverse()))}if(a.loadLib)return a;var m=Math.sin,s=Math.cos,
h=Math.PI,v=2*h,q,u,w,r,y,B,D,z,F=1.6180339887,E,C,A,I,H;a.OtherGeometry=function(h,m){this.width=h.evaluator.parser.parse("2");this.height=h.evaluator.parser.parse("2");this.length=h.evaluator.parser.parse("2");q=a.Vector4D;a.Graphic3D.call(this,h,m);this.mvMatrix=(new a.Matrix4x4).setIdentity();switch(this.type){case "cube":this.buildGeometry=g;break;case "box":this.buildGeometry=n;break;case "tetrahedron":this.buildGeometry=k;break;case "octahedron":this.buildGeometry=c;break;case "sphere":this.isSphere=
!0;case "ellipsoid":this.buildGeometry=l;break;case "dodecahedron":this.buildGeometry=e;break;case "icosahedron":this.buildGeometry=f;break;case "cone":this.buildGeometry=d;break;case "cylinder":this.buildGeometry=t;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=p}};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 a=0,c=this.faces.length;a<c;a++){w=[];for(var d=0,f=this.faces[a].length;d<f;d++)w.push(this.transformVertex(this.vertices[this.faces[a][d]]));this.space.addPrimitive({vertices:w,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model})}};a.OtherGeometry.prototype.changeGeometry=function(a,c,d,f,e){return this.oldWidth===a&&this.oldHeight===
c&&this.oldLength===d&&this.oldNu===f&&this.oldNv===e};a.OtherGeometry.prototype.updateValues=function(a,c,d,f,e){this.oldWidth=a;this.oldHeight=c;this.oldLength=d;this.oldNv=e;this.oldNu=f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.max,n=Math.min,k=Math.PI,c=Math.cos,e=Math.sin,f=Math.abs,l,d,t,p,m,s,h,v,q,u,w,r,y,B,D,z,F,E;a.R2=function(a,c){this.x=a||0;this.y=c||0};a.R2.prototype.set=function(a,c){this.x=a||0;this.y=c||0};a.R2.prototype.copy=function(){return new a.R2(this.x,
this.y)};a.R2.prototype.ix=function(){return Math.round(g(n(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(g(n(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){d=this.copy();d.sub(a);return d.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(){l=this.norm();0!=l&&this.div(l)};a.R2.prototype.rotR90=function(){l=this.x;this.x=this.y;this.y=-l};a.R2.prototype.rotL90=function(){l=this.x;this.x=-this.y;this.y=l};a.R2.prototype.rot=function(a){t=this.copy();
s=c(a);h=e(a);this.x=t.x*s-t.y*h;this.y=t.x*h+t.y*s};a.R2.prototype.rot=function(a){this.rot(a*k/180)};a.R2.prototype.intersection=function(c,d,e,h){v=d.x-c.x;q=e.x-h.x;u=e.x-c.x;w=d.y-c.y;r=e.y-h.y;y=e.y-c.y;E=v*r-q*w;return 1E-6<f(E)?(p=(u*r-y*q)/E,m=(-u*w+y*v)/E,0<=p&&1>=p&&0<=m&&1>=m?new a.R2(c.x+v*p,c.y+w*p):null):(d.x-e.x)*y!=(d.y-e.y)*u?null:c.x!=d.x?(B=n(c.x,d.x),D=g(c.x,d.x),B<=e.x&&e.x<=D?e:B<=h.x&&h.x<=D?h:null):e.x!=h.x?(z=n(e.x,h.x),F=g(e.x,h.x),z<=c.x&&c.x<=F?c:z<=d.x&&d.x<=F?d:null):
c.y!=d.y?(B=n(c.y,d.y),D=g(c.y,d.y),B<=e.y&&e.y<=D?e:B<=h.y&&h.y<=D?h:null):e.y!=h.y?(z=n(e.y,h.y),F=g(e.y,h.y),z<=c.y&&c.y<=F?c:z<=d.y&&d.y<=F?d:null):c.x==e.x&&c.y==e.y?c:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n,k,c,e,f,l,d;a.R2Newton=function(c,d){this.evaluator=c;this.constraint=d;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];f=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return this.normal.copy()};a.R2Newton.prototype.gradient=function(a){g=this.evaluator;l=g.getVariable("x");d=g.getVariable("y");g.setVariable("x",a.x);g.setVariable("y",a.y);this.f0=g.evalExpression(this.constraint);g.setVariable("x",
g.getVariable("x")+1E-12);n=g.evalExpression(this.constraint);f.x=(n-this.f0)/1E-12;f.x=!isNaN(f.x)?f.x:Infinity;g.setVariable("x",g.getVariable("x")-1E-12);g.setVariable("y",g.getVariable("y")+1E-12);n=g.evalExpression(this.constraint);f.y=(n-this.f0)/1E-12;f.y=!isNaN(f.y)?f.y:Infinity;g.setVariable("x",l);g.setVariable("y",d);return f};a.R2Newton.prototype.findZero=function(a){g=this.evaluator;e=a.copy();l=g.getVariable("x");d=g.getVariable("y");g.setVariable("x",a.x);g.setVariable("y",a.y);this.f0=
g.evalExpression(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return e;g.setVariable("x",l);g.setVariable("y",d);for(var f=0;256>f;f++)if(k=e.x,c=e.y,this.normal=this.gradient(e),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),e.x=k+this.normal.x,e.y=c+this.normal.y,1E-6>this.normal.norm()){0===this.normal.x&&0===this.normal.y&&(this.normal.x=e.x-a.x,this.normal.y=e.y-a.y);break}return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.Vector2D=function(a,n){this.x=a;this.y=n};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 g=Math.floor,
n=Math.round,k,c,e,f,l,d,t,p,m,s,h,v,q,u,w,r,y,B,D,z;a.Control=function(c,d){this.parent=c;this.evaluator=c.evaluator;var f=this.parser=c.evaluator.parser;this.id="graphic"!==d.type?"C":"G";this.gui=this.type="";this.region="south";this.y=this.x=0;this.w="video"!==d.type?100:350;this.h="video"!==d.type?23:120;"graphic"!==d.type?"text"!==d.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"!==d.type?new a.Color("f0f8ff"):new a.Color("ff0000");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 d)d.hasOwnProperty(e)&&(this[e]=d[e]);if(("video"===this.type||"audio"===this.type)&&"interior"!==this.region)this.region="interior";void 0==this.name&&(this.name=2==this.parent.version?this.id:"_nada_");this.name="_._"==this.name||"_nada_"==this.name||"_void_"==this.name?"":this.name;
f=this.evaluator.evalExpression(this.expresion);this.x=n(f[0][0]);this.y=n(f[0][1]);4==f[0].length&&(this.w=n(f[0][2]),this.h=n(f[0][3]));this.actionExec=c.lessonParser.parseAction(this)};a.Control.prototype.init=function(){};a.Control.prototype.update=function(){};a.Control.prototype.draw=function(){};a.Control.prototype.getContainer=function(){var a=this.parent.spaces,c;if("interior"===this.region)for(var d=0,f=a.length;d<f;d++){if(c=a[d],c.id===this.spaceID)return c.addCtr(this),this.zIndex=c.zIndex,
c.numericalControlContainer}else{if("external"===this.region)return this.parent.externalSpace.container;if("scenario"===this.region)return this.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 c=this.getContainer();c.childNodes[0]?c.insertBefore(a,c.childNodes[0]):c.appendChild(a);c.childNodes[0]?c.insertBefore(a,c.childNodes[0]):c.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){e=f=l=d=!1;t=this.evaluator.evalExpression(this.expresion);p=n(t[0][0]);e=n(this.x)!==p;this.x=p;p=n(t[0][1]);f=n(this.y)!==p;this.y=p;4===t[0].length&&(p=n(t[0][2]),l=n(this.w)!==p,this.w=p,p=n(t[0][3]),
d=n(this.h)!==p,this.h=p);if(l||d||e||f)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){q=this.parent;m=a+"";s=this.evaluator.evalExpression(this.decimals);h=m.indexOf(".");-1!=h&&(v=m.substring(h+1),v.length>s&&(m=parseFloat(m).toFixed(s)));if(this.fixed&&(2!==q.version||2===q.version&&!this.exponentialif))m=parseFloat(a).toFixed(s);this.exponentialif&&0!=parseFloat(m)&&(m=this.fixed&&2!==q.version?parseFloat(m).toExponential(s):parseFloat(m).toExponential(),m=m.toUpperCase(),
m=m.replace("+",""));return m=m.replace(".",q.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,d){this.linearGradient=this.ctx.createLinearGradient(0,0,0,d);k=d*d;for(var f=0;f<d;f++)c=g(f-35*d/100),this.linearGradient.addColorStop(f/d,"rgba(0,0,0,"+192*c*c/k/255+")")};a.Control.prototype.getScreenshot=
function(){r=this;u=document.createElement("canvas");u.setAttribute("width",r.w);u.setAttribute("height",r.h);w=u.getContext("2d");w.font=r.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";r.canvas&&(y=r.canvas.offsetLeft,B=r.canvas.offsetTop,w.drawImage(r.canvas,y,B));r.label&&(y=r.label.offsetLeft,B=r.label.offsetTop,D=r.label.offsetWidth,z=r.label.offsetHeight,w.fillStyle="#e0e4e8",w.fillRect(y,B,D,z),w.fillStyle="black",w.textAlign="center",w.textBaseline="middle",w.fillText(r.name,
y+D/2,B+z/2));r.field&&(y=r.field.offsetLeft,B=r.field.offsetTop,D=r.field.offsetWidth,z=r.field.offsetHeight,w.fillStyle="white",w.strokeStyle="#666666",w.lineWidth=1,w.fillRect(y,0,D,z),w.strokeRect(y+0.5,0.5,D-1,z-1),w.fillStyle="black",w.textAlign="center",w.textAlign="left",w.fillText(r.field.value,y+2,z/2));r.select&&(y=r.select.offsetLeft,B=r.select.offsetTop,D=r.select.offsetWidth,z=r.select.offsetHeight,w.fillStyle="#e0e4e8",w.strokeStyle="#666666",w.lineWidth=1,w.fillRect(y,0,D,z),w.strokeRect(y+
0.5,0.5,D,z-1),w.fillStyle="black",w.textAlign="center",w.textAlign="left",w.fillText(r.select.value,y+2,z/2),w.fillStyle="#c0c0c0",w.fillRect(y+D-15+0.5,0.5,15,z-1),w.strokeRect(y+D-15+0.5,0.5,15,z-1),w.fillStyle="black",w.beginPath(),w.moveTo(y+D-15+4.5,z/2-2.5),w.lineTo(y+D-15+8,z/2+2.5),w.lineTo(y+D-15+11.5,z/2-2.5),w.closePath(),w.fill());return u};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.floor,n,k,c,e,f,l,d,t,p,m,s,h,v=900;a.Button=function(c,d){this.imageSrc=
"";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;a.Control.call(this,c,d);-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(".")),h=f.substr(f.lastIndexOf("."));f.toLowerCase().match(/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"+h),this.imageDown=this.parent.getImage(e+
"_down"+h))}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(){n=this.evaluator;k=this.canvas;e=n.evalExpression(this.expresion);this.x=e[0][0];this.y=e[0][1];4==e[0].length&&(this.w=parseInt(e[0][2]),this.h=parseInt(e[0][3]));k.setAttribute("width",this.w+"px");k.setAttribute("height",this.h+"px");k.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+"; display: block;");this.fontSizeNotSet&&(this.font_size=n.parser.parse(a.getFieldFontSize(this.h)+
""));this.createGradient(this.w,this.h)};a.Button.prototype.update=function(){n=this.evaluator;k=this.canvas;this.activeIfValue=0<n.evalExpression(this.activeif);(this.drawIfValue=0<n.evalExpression(this.drawif))?(k.style.display="block",this.draw()):(this.click=!1,k.style.display="none");this.updatePositionAndSize()};a.Button.prototype.draw=function(){n=this.evaluator;c=this.ctx;f=n.evalExpression(this.font_size);l=n.evalExpression(this.name);d=n.evalExpression(this.imageSrc);t="vacio.gif"===d?this.emptyImage:
this.parent.getImage(d);c.clearRect(0,0,this.w,this.h);m=p=0;this.click&&(m=p=1);t&&t.ready?t!==this.emptyImage&&t.complete&&c.drawImage(t,parseInt((this.w-t.width)/2)+p,parseInt((this.h-t.height)/2)+m):(c.fillStyle=this.colorInt.getColor(),c.fillRect(0,0,this.w,this.h),this.click||(a.drawLine(c,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,"+128/255+")"),a.drawLine(c,0,0,0,this.h,"rgba(0,0,0,"+24/255+")"),a.drawLine(c,1,0,1,this.h,"rgba(0,0,0,"+8/255+")")),c.fillStyle=this.linearGradient,c.fillRect(0,0,
this.w,this.h));""!=this.imageOver.src&&(this.imageOver.ready&&this.over)&&c.drawImage(this.imageOver,parseInt((this.w-t.width)/2)+p,parseInt((this.h-t.height)/2)+m);""!=this.imageDown.src&&this.imageDown.ready&&this.click?c.drawImage(this.imageDown,parseInt((this.w-t.width)/2)+p,parseInt((this.h-t.height)/2)+m):this.click&&(a.drawLine(c,0,0,0,this.h-2,"gray"),a.drawLine(c,0,0,this.w-1,0,"gray"),c.fillStyle="rgba(0, 0, 0,"+24/255+")",c.fillRect(0,0,this.w,this.h));c.fillStyle=this.color.getColor();
c.font=this.italics+" "+this.bold+" "+f+"px Arial";c.textAlign="center";c.textBaseline="middle";this.colorInt!=this.color&&(c.lineJoin="round",c.lineWidth=parseInt(f/6),c.strokeStyle=this.colorInt.getColor(),c.strokeText(l,g(this.w/2+p)+0.5,g(this.h/2+m)+0.5));c.fillText(l,g(this.w/2+p)+0.5,g(this.h/2+m)+0.5);this.underlined&&(s=c.measureText(l).width,c.strokeStyle=this.color.getColor(),c.lineWidth=g(f/10)||2,c.lineCap="round",c.beginPath(),c.moveTo(parseInt((this.w-s)/2)+p,g((this.h+f)/2)+g(f/5)-
1.5+m),c.lineTo(parseInt((this.w+s)/2)+p,g((this.h+f)/2)+g(f/5)-1.5+m),c.stroke());this.activeIfValue||(c.fillStyle="rgba(240,240,240,"+160/255+")",c.fillRect(0,0,this.w,this.h))};a.Button.prototype.bottonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function c(a,d,f){clearInterval(k);g.click&&(d.call(g),a=f?a:30,k=setTimeout(function(){c(a,d)},a))}function d(e){e.preventDefault();g.whichButton=a.whichButton(e);"L"==g.whichButton&&g.activeIfValue&&
(g.click=!0,g.draw(),g.evaluator.setVariable(g.id,g.evaluator.evalExpression(g.valueExpr)),"calculate"==g.action&&c(v,g.bottonPressed,!0),h?window.addEventListener("touchend",f):window.addEventListener("mouseup",f))}function f(a){if(g.activeIfValue||g.click)g.click=!1,g.draw(),"calculate"!=g.action&&g.bottonPressed(),a.preventDefault(),h?window.removeEventListener("touchend",f,!1):window.removeEventListener("mouseup",f,!1)}function e(a){g.over=!0;g.draw()}function l(a){g.over=!1;g.click=!1;g.draw()}
h=a.hasTouchSupport;var g=this,k;g.canvas.oncontextmenu=function(){return!1};this.over=this.click=!1;h?this.canvas.addEventListener("touchstart",d):(this.canvas.addEventListener("mousedown",d),this.canvas.addEventListener("mouseover",e),this.canvas.addEventListener("mouseout",l))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n,k,c,e,f,l,d,t,p,m,s,h,v,q,u,w;a.Spinner=function(c,d){a.Control.call(this,
c,d);this.tabindex=++this.parent.tabindex;this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);""!=this.name.trim()&&this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);
this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.addControlContainer(this.containerControl);this.originalIncr=this.incr;if(0>=this.evaluator.evalExpression(this.decimals)){var f=this.evaluator.evalExpression(this.incr);0<f?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(f).toString()):this.incr=this.evaluator.parser.parse("1")}this.registerMouseAndTouchEvents();this.init()};a.extend(a.Spinner,
a.Control);a.Spinner.prototype.init=function(){g=this.evaluator;this.value=this.validateValue(g.evalExpression(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var d=2!==this.parent.version?"":"_____",f=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),e=2+parseInt(this.h/2),h=parseInt(this.w/2-e/2),d=a.getTextWidth(this.name+d,this.fieldFontSize+"px Arial");this.visible||(h=this.w-e,f=0);h<d&&(h=d);""==this.name&&
(h=0);this.w-h-e<f&&(h=this.w-e-f);0>h&&(h=0);d=this.w-(h+e);this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.canvas.setAttribute("width",e+"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 : "+e+"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 : "+e+"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 : "+(d-2)+"px; height : "+(this.h-2)+"px; left: "+(e+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;");g.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h);this.update()};a.Spinner.prototype.update=
function(){g=this.evaluator;0>=g.evalExpression(this.decimals)?(n=g.evalExpression(this.incr),0<n?this.originalIncr=this.incr=g.parser.parse(parseInt(n).toString()):this.incr=g.parser.parse("1")):this.incr=this.originalIncr;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.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();
k=this.field.value;c=this.value;this.value=this.validateValue(g.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value==c&&this.field.value!=k&&(this.value=this.validateValue(k),this.field.value=this.formatOutputValue(this.value));g.setVariable(this.id,this.value)};a.Spinner.prototype.draw=function(){e=this.ctx;f=this.canvas.width;l=this.canvas.height;e.fillStyle="#f0f8ff";e.fillRect(0,0,f,l);e.fillStyle=this.linearGradient;e.fillRect(0,0,f,l);this.up?(d="gray",t="#f0f8ff"):
(d="#f0f8ff",t="gray");a.drawLine(e,0,0,f,0,d);a.drawLine(e,0,0,0,l/2,d);a.drawLine(e,0,l/2,f,l/2,t);this.down?(d="gray",t="#f0f8ff"):(d="#f0f8ff",t="gray");a.drawLine(e,0,l/2+1,f,l/2+1,d);a.drawLine(e,0,l/2+1,0,l,d);a.drawLine(e,0,l-1,f,l-1,t);p=[parseInt(f/2+1),parseInt(f/5+1),parseInt(f-f/5+1)];m=[parseInt(l/8+1),parseInt(l/8+1+l/4),parseInt(l/8+1+l/4)];e.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";e.beginPath();e.moveTo(p[0],m[0]);e.lineTo(p[1],m[1]);e.lineTo(p[2],m[2]);e.fill();m=[parseInt(l-
l/8),parseInt(l-l/8-l/4),parseInt(l-l/8-l/4)];e.fillStyle=this.activeIfValue?"#d00018":"#aa8888";e.beginPath();e.moveTo(p[0],m[0]);e.lineTo(p[1],m[1]);e.lineTo(p[2],m[2]);e.fill();e.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&e.fillRect(0,0,f,l/2);this.down&&e.fillRect(0,l/2,f,l)};a.Spinner.prototype.validateValue=function(a){g=this.evaluator;a=isNaN(parseFloat(a))?a.toString():parseFloat(a).toFixed(20);s=parseFloat(g.evalExpression(g.parser.parse(a.replace(this.parent.decimal_symbol,"."))));isNaN(s)&&
(s=0);q=g.evalExpression(this.min);""==q&&(q=-Math.Infinity);u=g.evalExpression(this.max);""==u&&(u=Math.Infinity);s<q&&(s=q);s>u&&(s=u);this.discrete&&(h=g.evalExpression(this.incr),s=0==h?0:h*Math.round(s/h));v=g.evalExpression(this.decimals);0>=v&&(v=0);return s=parseFloat(parseFloat(s).toFixed(v))};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 c(a,d,f){clearInterval(m);if(k.up||k.down)d.call(k),a=f?a:30,m=setTimeout(function(){c(a,d)},a)}function d(f){f.preventDefault();k.whichButton=a.whichButton(f);"L"==
k.whichButton&&k.activeIfValue&&(k.up=!0,c(p,k.increase,!0),k.draw())}function f(d){d.preventDefault();k.whichButton=a.whichButton(d);"L"==k.whichButton&&k.activeIfValue&&(k.down=!0,c(p,k.decrease,!0),k.draw())}function e(a){k.up=!1;clearInterval(m);k.draw();a.preventDefault()}function h(a){k.down=!1;clearInterval(m);k.draw();a.preventDefault()}function l(a){k.up=!1;clearInterval(m);k.draw();a.preventDefault()}function g(a){k.down=!1;clearInterval(m);k.draw();a.preventDefault()}w=a.hasTouchSupport;
var k=this,p=w?500:200,m;k.divUp.oncontextmenu=k.divDown.oncontextmenu=k.field.oncontextmenu=k.label.oncontextmenu=function(){return!1};w?this.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):this.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("keydown",function(a){13==a.keyCode&&k.changeValue(k.field.value)});w?this.divUp.addEventListener("touchstart",d):this.divUp.addEventListener("mousedown",d);w?this.divDown.addEventListener("touchstart",
f):this.divDown.addEventListener("mousedown",f);w||this.divUp.addEventListener("mouseout",e);w||this.divDown.addEventListener("mouseout",h);w?(this.divUp.addEventListener("touchend",l),window.addEventListener("touchend",l)):(this.divUp.addEventListener("mouseup",l),window.addEventListener("mouseup",l));w?(this.divDown.addEventListener("touchend",g),window.addEventListener("touchend",g)):(this.divDown.addEventListener("mouseup",g),window.addEventListener("mouseup",g))};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var g,n,k,c,e,f,l;a.TextField=function(c,f){a.Control.call(this,c,f);void 0===this.valueExprString&&(this.valueExprString="");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;if(this.answer)if(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answerPattern=this.answer,this.answer=a.buildRegularExpresionsPatterns(this.answer,this.evaluator),this.onlyText){var e=this.answerPattern.indexOf("|");this.firstAnswer=
-1==e?this.answerPattern:this.answerPattern.substring(0,e)}else this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(",")));if(this.onlyText){if(!this.valueExprString.match(/^'/)||!this.valueExprString.match(/^'/))this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'");this.validateValue=function(a){return"''"==a||"'"==a?"":a};this.formatOutputValue=function(a){return a.toString()}}""==this.name.trim()&&(this.name="");this.containerControl=
document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){g=this.evaluator;this.value=this.validateValue(g.evalExpression(this.valueExpr));
var c=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var f=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),e=parseInt(this.w/2),l=a.getTextWidth(this.name,this.fieldFontSize+"px Arial");e<l&&(e=l);""==this.name&&(e=0);this.w-e<f&&(e=this.w-f);0>e&&(e=0);f=this.w-e;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 : "+(f-2)+"px; height : "+(this.h-2)+"px; left: "+e+"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: "+
e+"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(){g=this.evaluator;this.activeIfValue=0<g.evalExpression(this.activeif);this.drawIfValue=0<g.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":
"none";this.updatePositionAndSize();n=this.field.value;k=this.value;this.value=this.validateValue(g.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value===k&&this.field.value!=n&&(this.value=this.validateValue(n),this.field.value=this.formatOutputValue(this.value));g.setVariable(this.id,this.value)};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";g=this.evaluator;c=parseFloat(g.evalExpression(g.parser.parse(a.toString().replace(this.parent.decimal_symbol,
"."))));isNaN(c)&&(c=0);e=g.evalExpression(this.min);""==e&&(e=-Math.Infinity);f=g.evalExpression(this.max);""==f&&(f=Math.Infinity);this.discrete&&(a=g.evalExpression(this.incr),c=0==a?0:a*Math.round(c/a));return c=parseFloat(parseFloat(c).toFixed(g.evalExpression(this.decimals)))};a.TextField.prototype.formatOutputValue=function(a){return""===a?"":this.uber.formatOutputValue.call(this,a)};a.TextField.prototype.changeValue=function(a,c){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=
this.formatOutputValue(this.value),this.evaluate&&(this.ok=this.evaluateAnswer()),this.evaluator.setVariable(this.id,this.value),this.evaluator.setVariable(this.id+".ok",this.ok),this.updateAndExecAction())};a.TextField.prototype.evaluateAnswer=function(){return a.esCorrecto(this.answer,this.value,this.evaluator,this.answer)};a.TextField.prototype.getFirstAnswer=function(){return this.answer?this.onlyText?this.firstAnswer:this.evaluator.evalExpression(this.firstAnswer):""};a.TextField.prototype.registerMouseAndTouchEvents=
function(){l=a.hasTouchSupport;var c=this;c.label.oncontextmenu=function(){return!1};l?c.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):c.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(a){c.update()});this.field.addEventListener("keydown",function(a){c.activeIfValue&&13==a.keyCode&&c.changeValue(c.field.value,!0)})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=
Math.abs,n,k,c,e;a.Menu=function(c,d){this.options="";a.Control.call(this,c,d);var f=this.parser;this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var e,g=0,k=this.options.length;g<k;g++)e=this.options[g].split(/[\[\]]/,2),1==e.length?(this.menuOptions.push(e[0]),this.strValue.push(g.toString())):2==e.length&&(this.menuOptions.push(e[0]),""==e[1]?this.strValue.push(g.toString()):this.strValue.push(e[1]));g=0;for(k=this.strValue.length;g<k;g++)this.strValue[g]=f.parse(this.strValue[g]);
this.containerControl=document.createElement("div");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.select=document.createElement("select");g=0;for(k=this.menuOptions.length;g<k;g++)f=document.createElement("option"),f.innerHTML=this.menuOptions[g],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);var f;a.Menu.prototype.init=function(){f=this.evaluator;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var c=0,d=0,e=0;this.value=f.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var g=0,k=this.menuOptions.length;g<k;g++)e=a.getTextWidth(this.menuOptions[g],this.fieldFontSize+
"px Arial"),e>c&&(c=e,d=g);c+=25;e=a.getTextWidth(this.formatOutputValue(f.evalExpression(this.strValue[d])),this.fieldFontSize+"px Arial")+7;d=a.getTextWidth(this.name,this.fieldFontSize+"px Arial")+10;""==this.name&&(d=0);this.visible||(e=0);for(g=this.w-e-d;g<c&&0<d;)d--,g++;for(;g<c&&0<e;)e--,g++;for(;d+g+e+1<this.w;)g++,e++;var c=d,k=c+g,e=this.w-k,n=this.formatOutputValue(f.evalExpression(this.strValue[this.indexValue]));this.containerControl.setAttribute("class","DescartesSpinnerContainer");
this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.label.setAttribute("class","DescartesMenuLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+d+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"menu");this.field.value=n;this.field.setAttribute("class","DescartesMenuField");
this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(e-2)+"px; height : "+(this.h-2)+"px; left: "+k+"px;");this.select.setAttribute("id",this.id+"menuSelect");this.select.setAttribute("class","DescartesMenuSelect");this.select.setAttribute("style","text-align: left; font-size: "+this.fieldFontSize+"px; width : "+g+"px; height : "+this.h+"px; left: "+c+"px; border-color: #7a8a99; border-width: 1.5px; border-style: solid; background-color: #eeeeee;");this.select.selectedIndex=
this.indexValue;f.setVariable(this.id,parseFloat(n));this.update()};a.Menu.prototype.update=function(){f=this.evaluator;this.activeIfValue=0<f.evalExpression(this.activeif);this.drawIfValue=0<f.evalExpression(this.drawif);this.field.disabled=this.activeIfValue?!1:!0;this.select.disabled=this.activeIfValue?!1:!0;this.drawIfValue?this.containerControl.style.display="block":(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();this.value=f.getVariable(this.id);this.field.value=
this.formatOutputValue(this.value);f.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));n=-1;k=Infinity;for(var d=0,f=this.strValue.length;d<f;d++)c=g(a-parseFloat(this.evaluator.evalExpression(this.strValue[d]))),c<=k&&(k=c,n=d);return n};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),
this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){e=a.hasTouchSupport;var c=this;c.select.oncontextmenu=c.label.oncontextmenu=c.field.oncontextmenu=function(){return!1};e?c.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):c.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(a){c.value=c.evaluator.evalExpression(c.strValue[this.selectedIndex]);c.field.value=c.formatOutputValue(c.value);
c.evaluator.setVariable(c.id,c.field.value);c.changeValue();a.preventDefault()});this.field.addEventListener("keydown",function(a){13==a.keyCode&&(c.indexValue=c.getIndex(c.field.value),c.value=c.evaluator.evalExpression(c.strValue[c.indexValue]),c.field.value=c.formatOutputValue(c.indexValue),c.select.selectedIndex=c.indexValue,c.changeValue())})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.floor,n="h",k,c,e,f,l,d,t,p,m,s,h,v,q,u,w,r,y,B,D,z,F;a.Scrollbar=
function(c,f){a.Control.call(this,c,f);this.orientation=this.w>=this.h?n:"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.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);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(){k=this.evaluator;this.findOffset();0==k.evalExpression(this.decimals)?this.incr=1:this.incr=
(k.evalExpression(this.max)-k.evalExpression(this.min))/100;this.value=this.validateValue(k.evalExpression(this.valueExpr));e=this.formatOutputValue(this.value);f=this.evaluator.evalExpression(this.expresion);this.x=f[0][0];this.y=f[0][1];4==f[0].length&&(this.w=f[0][2],this.h=f[0][3]);this.orientation=this.w>=this.h?n:"v";this.initScroll(e);this.changeScrollPositionFromValue();this.prePos=this.pos;k.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(f){c=this;k=c.evaluator;
var d="v"===c.orientation?parseInt(19+5*(c.h-100)/100):c.h;c.fieldFontSize="v"===c.orientation?d-parseInt(c.h/20)-1:2!==c.parent.version?a.getFieldFontSize(d):10;var e=a.getTextWidth(f+"_",c.fieldFontSize+"px Arial"),h=c.parent.getSpaceById(c.spaceID).h;c.labelHeight=""==c.name?0:d;c.fieldHeight=""==c.visible?0:d;if("v"===c.orientation)c.canvasWidth=c.w,c.canvasHeight=c.h-c.labelHeight-c.fieldHeight,18<=c.canvasHeight+c.y-h&&(c.canvasHeight=h),e=0,e=c.fieldHeight,d=e+c.canvasHeight,c.canvasX=0,c.canvasY=
c.fieldHeight,c.labelWidth=c.w,c.labelY=d,c.upWidth=c.downW=c.w,c.upHeight=c.downH=15,c.upX=0,c.upY=c.fieldHeight,c.downX=0,c.downY=d-c.downH,c.fieldWidth=c.w,c.fieldX=0,c.scrollManipulatorW=c.w,c.scrollManipulatorH=parseInt((c.canvasHeight-c.upHeight-c.downH-c.labelHeight-c.fieldHeight)/10),c.scrollManipulatorH=15>c.scrollManipulatorH?15:c.scrollManipulatorH,c.scrollManipulatorLimInf=d-c.downH-c.scrollManipulatorH,c.scrollManipulatorLimSup=e+c.downH;else{d=a.getTextWidth(c.name,c.fieldFontSize+"px Arial")+
10;c.labelWidth=d;c.fieldWidth=e;""==c.name&&(c.labelWidth=0);c.visible||(c.fieldWidth=0);for(d=c.w-c.fieldWidth-c.labelWidth;58>d&&0<c.labelWidth;)c.labelWidth--,d++;for(;58>d&&0<c.fieldWidth;)c.fieldWidth--,d++;e=c.labelWidth;h=e+d;c.fieldWidth=c.w-h;c.canvasWidth=d;c.canvasHeight=c.h;c.canvasX=c.labelWidth;c.canvasY=0;c.fieldX=c.canvasWidth+c.labelWidth;c.labelHeight=c.h;c.labelY=0;c.upWidth=c.downW=15;c.upHeight=c.downH=c.h;c.upX=h-c.downW;c.upY=0;c.downX=c.labelWidth;c.downY=0;c.scrollManipulatorW=
parseInt((c.canvasWidth-c.upWidth-c.downW)/10);c.scrollManipulatorW=15>c.scrollManipulatorW?15:c.scrollManipulatorW;c.scrollManipulatorH=c.h;c.scrollManipulatorLimInf=e+c.downW;c.scrollManipulatorLimSup=e+c.canvasWidth-c.downW-c.scrollManipulatorW}c.containerControl.setAttribute("class","DescartesScrollbarContainer");c.containerControl.setAttribute("style","width: "+c.w+"px; height: "+c.h+"px; left: "+c.x+"px; top: "+c.y+"px; z-index: "+c.zIndex+";");c.canvas.setAttribute("width",c.w+"px");c.canvas.setAttribute("height",
c.h+"px");c.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");c.ctx=c.canvas.getContext("2d");c.divUp.setAttribute("class","DescartesCatcher");c.divUp.setAttribute("style","width : "+c.upWidth+"px; height : "+c.upHeight+"px; left: "+c.upX+"px; top: "+c.upY+"px;");c.divDown.setAttribute("class","DescartesCatcher");c.divDown.setAttribute("style","width : "+c.downW+"px; height : "+c.downH+"px; left: "+c.downX+"px; top: "+c.downY+"px;");c.scrollManipulator.setAttribute("class","DescartesCatcher");
c.scrollManipulator.setAttribute("style","width : "+c.scrollManipulatorW+"px; height : "+c.scrollManipulatorH+"px;");c.scrollManipulator.style.top=("v"===c.orientation?c.scrollManipulatorLimInf:0)+"px";c.scrollManipulator.style.left=("v"===c.orientation?0:c.scrollManipulatorLimInf)+"px";c.field.setAttribute("type","text");c.field.setAttribute("id",c.id+"scrollbar");c.field.setAttribute("class","DescartesScrollbarField");c.field.setAttribute("style","font-size: "+c.fieldFontSize+"px; width : "+(c.fieldWidth-
2)+"px; height : "+(c.fieldHeight-2)+"px; left: "+c.fieldX+"px; top: 0px;");c.field.value=f;0===c.fieldHeight&&(c.field.style.display="none");c.label.setAttribute("class","DescartesScrollbarLabel");c.label.setAttribute("style","font-size:"+c.fieldFontSize+"px; width: "+c.labelWidth+"px; height: "+c.labelHeight+"px; line-height: "+c.labelHeight+"px; left: 0px; top:"+c.labelY+"px;");c.txtLabel=document.createTextNode(c.name);this.update()};a.Scrollbar.prototype.update=function(){k=this.evaluator;0==
k.evalExpression(this.decimals)?this.incr=1:this.incr=(k.evalExpression(this.max)-k.evalExpression(this.min))/100;this.activeIfValue=0<k.evalExpression(this.activeif);this.drawIfValue=0<k.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";this.updatePositionAndSize();this.value=this.validateValue(k.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);
k.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){c=this;l=c.ctx;t=g(this.w);d=g(this.h);l.fillStyle="#e0e4e8";l.fillRect(0,0,t,d);l.strokeStyle="#7a8a99";c.down&&(l.fillStyle="#ccdcec",l.fillRect(c.downX+0.5,c.downY+0.5,c.downW,c.downH-1));l.strokeRect(c.downX+0.5,c.downY+0.5,c.downW,c.downH-1);c.up&&(l.fillStyle="#ccdcec",l.fillRect(c.upX+0.5,c.upY-0.5,c.upWidth,c.upHeight+1));l.strokeRect(c.upX+0.5,c.upY-0.5,c.upWidth,c.upHeight+1);p=4;l.fillStyle="black";l.beginPath();c.orientation===
n?(l.moveTo(c.downX+p,c.downH/2),l.lineTo(c.downX+c.downW-p,p),l.lineTo(c.downX+c.downW-p,c.downH-p),l.moveTo(c.upX+c.upWidth-p,c.downH/2),l.lineTo(c.upX+p,p),l.lineTo(c.upX+p,c.downH-p),l.fill(),c.activeIfValue&&(m=g(c.pos),l.fillStyle="#ccdcec",l.fillRect(m+0.5,0,g(c.scrollManipulatorW),d),l.strokeStyle="#6382bf",l.strokeRect(m+0.5,0,g(c.scrollManipulatorW),d),s=g(c.scrollManipulatorW/2),l.beginPath(),l.moveTo(m+s+0.5-2,3),l.lineTo(m+s+0.5-2,d-3),l.moveTo(m+s+0.5,3),l.lineTo(m+s+0.5,d-3),l.moveTo(m+
s+0.5+2,3),l.lineTo(m+s+0.5+2,d-3),l.stroke())):(l.moveTo(c.downX+c.downW/2,c.downY+c.downH-p),l.lineTo(c.downX+p,c.downY+p),l.lineTo(c.downX+c.downW-p,c.downY+p),l.moveTo(c.upX+c.upWidth/2,c.upY+p),l.lineTo(c.upX+p,c.upY+c.upHeight-p),l.lineTo(c.upX+c.upWidth-p,c.upY+c.upHeight-p),l.fill(),c.activeIfValue&&(m=g(c.pos),l.fillStyle="#ccdcec",l.fillRect(0,m+0.5,t,g(c.scrollManipulatorH)),l.strokeStyle="#6382bf",l.strokeRect(0,m+0.5,t,g(c.scrollManipulatorH)),s=g(c.scrollManipulatorH/2),l.beginPath(),
l.moveTo(3,m+s+0.5-2),l.lineTo(t-3,m+s+0.5-2),l.moveTo(3,m+s+0.5),l.lineTo(t-3,m+s+0.5),l.moveTo(3,m+s+0.5+2),l.lineTo(t-3,m+s+0.5+2),l.stroke()));l.strokeRect(0.5,0.5,t-1,d-1);c.activeIfValue||(l.fillStyle="rgba(240,240,240,"+160/255+")",l.fillRect(0,0,t,d.h))};a.Scrollbar.prototype.validateValue=function(a){k=this.evaluator;h=(a||1E45).toString();h=parseFloat(h.replace(this.parent.decimal_symbol,"."));isNaN(h)&&(h=0);this.minimo=k.evalExpression(this.min);h<this.minimo&&(this.value=null,h=this.minimo);
this.maximo=k.evalExpression(this.max);h>this.maximo&&(this.value=null,h=this.maximo);v=this.incr;h=0!=v?h*v/v:0;this.fixed&&(h=parseFloat(parseFloat(h).toFixed(k.evalExpression(this.decimals))));return h};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(){p=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/
10;this.orientation==n?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+p):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+p)};a.Scrollbar.prototype.decrease10=function(){p=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==n?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-p):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-p)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&
(q=this.validateValue(a),q!=this.value&&(this.value=q,this.field.value=this.formatOutputValue(q),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){k=this.evaluator;u=this.scrollManipulatorLimInf;w=this.scrollManipulatorLimSup;r=k.evalExpression(this.min);y=k.evalExpression(this.max);v=this.incr;q=g((this.pos-u)*(y-r)/(w-u)/v)*v+r;q!=this.value&&(this.value=
q,this.field.value=this.formatOutputValue(q),k.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){k=this.evaluator;u=this.scrollManipulatorLimInf;w=this.scrollManipulatorLimSup;r=k.evalExpression(this.min);y=k.evalExpression(this.max);v=this.incr;this.pos=(this.value-r)*(w-u)/(y-r)+u;this.orientation==n?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=
this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=function(){function c(a,d,f,e){clearInterval(y);if((r.up||r.down||r.canvasClick)&&1E-7<Math.abs(r.value-e))d.call(r),a=f?a:30,y=setTimeout(function(){c(a,d,!1,e)},a)}function d(f){f.preventDefault();r.whichButton=a.whichButton(f);"L"==r.whichButton&&r.activeIfValue&&(r.clickPos=r.getCursorPosition(f),r.canvasClick=!0,r.orientation==n?r.clickPos.x<r.prePos?c(u,r.decrease10,!0,r.minimo):c(u,r.increase10,!0,r.maximo):r.clickPos.y<r.prePos?
c(u,r.increase10,!0,r.maximo):c(u,r.decrease10,!0,r.minimo))}function f(a){r.canvasClick=!1;clearInterval(y);a.preventDefault()}function e(a){!0==r.canvasClick&&(r.clickPos=r.getCursorPosition(a),a.preventDefault())}function h(a){r.activeIfValue&&(r.scrollClick=!0,r.initPos=r.getCursorPosition(a),window.addEventListener("mouseup",l),window.addEventListener("mousemove",p),a.preventDefault())}function g(a){r.activeIfValue&&(r.scrollClick=!0,r.initPos=r.getCursorPosition(a),window.addEventListener("touchend",
k),window.addEventListener("touchmove",onToucheMove_scrollManipulator),a.preventDefault())}function l(a){r.scrollClick=!1;r.prePos=r.pos;window.removeEventListener("mouseup",l,!1);window.removeEventListener("mousemove",p,!1);a.preventDefault()}function k(a){r.scrollClick=!1;r.prePos=r.pos;window.removeEventListener("touchend",k,!1);window.removeEventListener("touchmove",p,!1);a.preventDefault()}function p(a){var c=r.getCursorPosition(a);r.orientation==n?(r.pos=r.prePos-(r.initPos.x-c.x),r.pos<r.scrollManipulatorLimInf&&
(r.pos=r.scrollManipulatorLimInf),r.pos>r.scrollManipulatorLimSup&&(r.pos=r.scrollManipulatorLimSup),r.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+r.scrollManipulatorW+"px; height : "+r.h+"px; left: "+r.pos+"px; top: 0px;")):(r.pos=r.prePos-(r.initPos.y-c.y),r.pos>r.scrollManipulatorLimInf&&(r.pos=r.scrollManipulatorLimInf),r.pos<r.scrollManipulatorLimSup&&(r.pos=r.scrollManipulatorLimSup),r.scrollManipulator.setAttribute("style",
"background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+r.w+"px; height : "+r.scrollManipulatorH+"px; left: 0px; top: "+r.pos+"px;"));r.changeValueForScrollMovement();a.preventDefault()}function m(d){d.preventDefault();r.whichButton=a.whichButton(d);"L"==r.whichButton&&r.activeIfValue&&(r.up=!0,c(u,r.increase,!0,r.maximo))}function t(d){d.preventDefault();r.whichButton=a.whichButton(d);"L"==r.whichButton&&r.activeIfValue&&(r.down=!0,c(u,r.decrease,!0,r.minimo))}function q(a){r.up=
!1;clearInterval(y);a.preventDefault()}function s(a){r.down=!1;clearInterval(y);a.preventDefault()}function w(a){r.up=!1;clearInterval(y);a.preventDefault();r.draw()}function v(a){r.down=!1;clearInterval(y);a.preventDefault();r.draw()}B=a.hasTouchSupport;var r=this,u=B?500:200,y;r.canvas.oncontextmenu=r.divUp.oncontextmenu=r.divDown.oncontextmenu=r.label.oncontextmenu=r.field.oncontextmenu=r.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==
a.keyCode&&r.changeValue(r.field.value)});B?this.canvas.addEventListener("touchstart",d):this.canvas.addEventListener("mousedown",d);B||this.divDown.addEventListener("mouseout",s);B?window.addEventListener("touchend",f):window.addEventListener("mouseup",f);B?this.canvas.addEventListener("touchmove",e):this.canvas.addEventListener("mousemove",e);B?this.scrollManipulator.addEventListener("touchstart",g):this.scrollManipulator.addEventListener("mousedown",h);B?this.divUp.addEventListener("touchstart",
m):this.divUp.addEventListener("mousedown",m);B?this.divDown.addEventListener("touchstart",t):this.divDown.addEventListener("mousedown",t);B||this.divUp.addEventListener("mouseout",q);B||this.divDown.addEventListener("mouseout",s);B?window.addEventListener("touchend",w):window.addEventListener("mouseup",w);B?window.addEventListener("touchend",v):window.addEventListener("mouseup",v)};a.Scrollbar.prototype.findOffset=function(){D=this.containerControl;this.offsetTop=this.offsetLeft=0;z=this.containerControl.style.display;
for(this.containerControl.style.display="block";D;)this.offsetLeft+=D.offsetLeft||0,this.offsetTop+=D.offsetTop||0,D=D.parentNode;this.containerControl.style.display=z};a.Scrollbar.prototype.getCursorPosition=function(c){F=a.getCursorPosition(c);return{x:F.x-this.offsetLeft,y:F.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g;a.Audio=function(g,k){this.controls=!0;this.file="";a.Control.call(this,g,k);var c=this.evaluator.evalExpression(this.expresion);
4==c[0].length?(this.w=c[0][2],this.h=c[0][3]):(this.w=100,this.h=28);this.audio=this.parent.getAudio(this.file);this.autoplay&&(this.audio.setAttribute("autoplay","autoplay"),this.audio.play());this.loop&&this.audio.setAttribute("loop","loop");this.controls&&this.audio.setAttribute("controls","controls");this.audio.setAttribute("style","position: absolute; width: "+this.w+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.addControlContainer(this.audio)};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()};a.Audio.prototype.update=function(){g=this.evaluator;0<g.evalExpression(this.drawif)?this.audio.style.display="block":(this.audio.style.display="none",this.audio.pause());this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g;a.Video=function(g,k){this.controls=!0;this.file="";a.Control.call(this,g,k);var c=this.evaluator.evalExpression(this.expresion);
4==c[0].length?(this.w=c[0][2],this.h=c[0][3]):this.h=this.w=null;this.video=document.createElement("video");this.autoplay&&this.video.setAttribute("autoplay","autoplay");this.loop&&this.video.setAttribute("loop","loop");this.controls&&this.video.setAttribute("controls","controls");this.poster&&this.video.setAttribute("poster",this.poster);this.w&&(this.video.setAttribute("width",this.w),this.video.setAttribute("height",this.h));this.video.setAttribute("style","position: absolute; overflow: hidden; left: "+
this.x+"px; top: "+this.y+"px;");var c=this.file,e=c.lastIndexOf(".");-1!=e&&(c=this.file.substring(0,e));this.video.canPlayType("video/mp4")&&(e=document.createElement("source"),e.setAttribute("src",c+".mp4"),e.setAttribute("type","video/mp4"),this.video.appendChild(e));this.video.canPlayType("video/ogg")&&(e=document.createElement("source"),e.setAttribute("src",c+".ogg"),e.setAttribute("type","video/ogg"),this.video.appendChild(e),e=document.createElement("source"),e.setAttribute("src",c+".ogv"),
e.setAttribute("type","video/ogg"),this.video.appendChild(e));this.video.canPlayType("video/webm")&&(e=document.createElement("source"),e.setAttribute("src",c+".webm"),e.setAttribute("type","video/webm"),this.video.appendChild(e));this.addControlContainer(this.video)};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()};a.Video.prototype.update=function(){g=this.evaluator;0<g.evalExpression(this.drawif)?this.video.style.display=
"block":(this.video.style.display="none",this.video.pause());this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n;a.TextArea=function(g,c){a.Control.call(this,g,c);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 e=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||void 0==this.text.type?this.rawText||
"":this.text.hasFormula?this.rawText:this.text.toHTML();e&&void 0!=e.type&&!this.text.hasFormula&&(this.answer=e.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(){n=this.answer?28:8;g=this.evaluator;this.text=g.getVariable(this.id);this.containerControl.setAttribute("class","DescartesTextAreaContainer");this.containerControl.setAttribute("style","width: "+this.w+
"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=0<g.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-n)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textArea.setAttribute("contenteditable",
"true");this.textArea.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;' >"+this.text+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-n)+"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 g=document.createElement("canvas");g.setAttribute("width",20);g.setAttribute("height",16);var c=g.getContext("2d");this.canvas=g;this.ctx=c;this.createGradient(20,16);c.lineWidth=1;c.fillStyle="white";c.fillRect(0,0,20,16);c.fillStyle=this.linearGradient;c.fillRect(0,0,20,16);a.drawLine(c,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(c,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(c,1,0,1,16,"rgba(0,0,0,"+
8/255+")");this.imageUnPush=g.toDataURL();c.fillStyle="white";c.fillRect(0,0,20,16);c.fillStyle=this.linearGradient;c.fillRect(0,0,20,16);a.drawLine(c,0,0,0,14,"gray");a.drawLine(c,0,0,19,0,"gray");c.fillStyle="rgba(0, 0, 0,"+24/255+")";c.fillRect(0,0,this.w,this.h);this.imagePush=g.toDataURL()};a.TextArea.prototype.update=function(){g=this.evaluator;this.activeIfValue=0<g.evalExpression(this.activeif);this.drawIfValue=0<g.evalExpression(this.drawif);g.setVariable(this.id,this.text);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(e){e.preventDefault();c.showButton.style.backgroundImage="url("+c.imageUnPush+")"}var c=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();c.showAnswer=!c.showAnswer;c.textAreaAnswer.style.display=c.showAnswer?"block":"none";c.showButton.childNodes[0].childNodes[0].textContent=
c.showAnswer?"T":"S";c.showButton.style.backgroundImage="url("+c.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 c=a.getContext("2d");c.fillStyle="white";c.strokeStyle="black";c.lineWidth=1;c.fillRect(0,0,this.w,this.h);c.strokeRect(0,0,this.w,this.h);return a};return a}(descartesJS||{}),
descartesJS=function(a){if(a.loadLib)return a;var g=2*Math.PI,n,k,c,e,f,l,d,t,p;a.GraphicControl=function(c,d){k=c.evaluator.parser;this.spaceID="E0";this.text="";this.size=k.parse("4");this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";a.Control.call(this,c,d);this.touchId=null;this.font=a.convertFont(this.font);this.constraintExpr&&(this.constraint=k.parse(this.constraintExpr),"(expr)"==this.constraint.type&&(this.constraint=k.parse(this.constraintExpr.substring(1,
this.constraintExpr.length-1))),"compOperator"==this.constraint.type?this.newt=new a.R2Newton(this.evaluator,this.constraint):this.constraint=null,t=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.init()};a.extend(a.GraphicControl,a.Control);a.GraphicControl.prototype.init=function(){n=this.evaluator;p=a.hasTouchSupport;var c=n.evalExpression(this.expresion);this.x=c[0][0];this.y=c[0][1];n.setVariable(this.id+".x",this.x);n.setVariable(this.id+".y",this.y);""!=this.imageSrc&&!this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,this.height=this.image.height):(this.width=2*n.evalExpression(this.size),
this.height=2*n.evalExpression(this.size));this._w=p&&70>this.width?70:this.width;this._h=p&&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";n.setVariable(this.id+".activo",0);this.update()};
a.GraphicControl.prototype.update=function(){n=this.evaluator;this.activeIfValue=0<n.evalExpression(this.activeif);this.drawIfValue=0<n.evalExpression(this.drawif);this.x=n.getVariable(this.id+".x");this.y=n.getVariable(this.id+".y");c=this.space.getAbsoluteX(this.x);e=this.space.getAbsoluteY(this.y);this.active||(this.mouseCacher.style.left=parseInt(c-this._w/2)+"px",this.mouseCacher.style.top=parseInt(e-this._h/2)+"px");this.mouseCacher.style.display=this.drawIfValue?"block":"none";this.constraint&&
this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=function(){n=this.evaluator;this.drawIfValue&&(l=this.ctx,d=this.space.backgroundCtx,c=parseInt(this.space.getAbsoluteX(this.x))+0.5,e=parseInt(this.space.getAbsoluteY(this.y))+0.5,""!=this.text&&this.drawText(c,e),this.image.ready?(this.image.complete&&l.drawImage(this.image,parseInt(c-this.image.width/2),parseInt(e-this.image.height/2)),this.trace&&(d.save(),d.translate(c,e),d.scale(parseInt(this.image.width/2),parseInt(this.image.height/
2)),d.beginPath(),d.arc(0,0,1,0,g,!1),d.restore(),d.lineWidth=1,d.strokeStyle=this.trace.getColor(),d.stroke())):(l.beginPath(),l.arc(c,e,parseInt(this.width/2),0,g,!1),l.fillStyle=this.colorInt.getColor(),l.fill(),l.lineWidth=1,l.strokeStyle=this.color.getColor(),l.stroke(),this.active&&(l.beginPath(),l.arc(c,e,parseInt(this.width/2)-2,0,g,!1),l.strokeStyle=this.colorInt.borderColor(),l.stroke()),this.trace&&(d.lineWidth=1,d.strokeStyle=this.trace.getColor(),d.beginPath(),d.arc(c,e,parseInt(this.width/
2),0,g,!1),d.stroke())))};a.GraphicControl.prototype.evalConstraint=function(a,c){t.set(this.x,this.y);f=this.newt.findZero(t);this.x=f.x;this.y=f.y;this.evaluator.setVariable(this.id+".x",this.x);this.evaluator.setVariable(this.id+".y",this.y)};a.GraphicControl.prototype.drawText=function(a,c){l=this.ctx;n=this.evaluator;l.fillStyle=this.color.getColor();l.font=this.font;l.textBaseline="alphabetic";l.fillText(n.evalExpression(this.text[0],n.evalExpression(this.decimals),this.fixed),parseInt(a+1+
this.width/2),parseInt(c-1-this.height/2))};a.GraphicControl.prototype.getContainer=function(){for(var a=this.parent.spaces,c,d=0,f=a.length;d<f;d++)if(c=a[d],c.id==this.spaceID)return c.addCtr(this),this.zIndex=c.zIndex,this.space=c,c.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.id+".activo",0)};a.GraphicControl.prototype.registerMouseAndTouchEvents=
function(){function c(d){d.preventDefault();k.whichButton=a.whichButton(d);"L"==k.whichButton&&(k.activeIfValue&&k.over)&&(k.parent.deactivateGraphiControls(),k.click=!0,k.active=!0,k.evaluator.setVariable(k.id+".activo",1),k.posAnte=k.getCursorPosition(d),k.prePos={x:k.space.getAbsoluteX(k.x),y:k.space.getAbsoluteY(k.y)},k.evaluator.setVariable(k.space.id+".mouse_x",k.x),k.evaluator.setVariable(k.space.id+".mouse_y",k.y),k.parent.update(),window.addEventListener("mouseup",f),window.addEventListener("mousemove",
e))}function d(a){a.preventDefault();k.activeIfValue&&(k.parent.deactivateGraphiControls(),k.click=!0,k.active=!0,k.evaluator.setVariable(k.id+".activo",1),k.posAnte=k.getCursorPosition(a),k.prePos={x:k.space.getAbsoluteX(k.x),y:k.space.getAbsoluteY(k.y)},k.evaluator.setVariable(k.space.id+".mouse_x",k.x),k.evaluator.setVariable(k.space.id+".mouse_y",k.y),k.parent.update(),window.addEventListener("touchmove",e),window.addEventListener("touchend",f))}function f(c){c.preventDefault();k.touchId=null;
if(k.activeIfValue||k.active)k.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",e,!1),window.removeEventListener("touchend",f,!1)):(window.removeEventListener("mouseup",f,!1),window.removeEventListener("mousemove",e,!1)),k.evaluator.setVariable(k.space.id+".mouse_x",k.x),k.evaluator.setVariable(k.space.id+".mouse_y",k.y),k.parent.update(),k.mouseCacher.style.left=k.space.getAbsoluteX(k.x)-k._w/2+"px",k.mouseCacher.style.top=k.space.getAbsoluteY(k.y)-k._h/2+"px"}function e(a){a.preventDefault();
a.touchId=k.touchId;p=k.getCursorPosition(a);k.posX=k.prePos.x-(k.posAnte.x-p.x);k.posY=k.prePos.y-(k.posAnte.y-p.y);k.evaluator.setVariable(k.id+".x",k.space.getRelativeX(k.posX));k.evaluator.setVariable(k.id+".y",k.space.getRelativeY(k.posY));k.evaluator.setVariable(k.space.id+".mouse_x",k.x);k.evaluator.setVariable(k.space.id+".mouse_y",k.y);k.parent.updateControls();k.parent.update()}function g(a){k.over=!0}function l(a){k.over=!1;k.click=!1}var k=this;this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=
function(){return!1};a.hasTouchSupport?this.mouseCacher.addEventListener("touchstart",d):(this.mouseCacher.addEventListener("mousedown",c),this.mouseCacher.addEventListener("mouseover",g),this.mouseCacher.addEventListener("mouseout",l));var p};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var c;if(a.touchId){d=0;for(f=a.touches.length;d<f;d++)if(a.touches[d].identifier==a.touchId){c=a.touches[d];break}}else for(var d=0,f=a.touches.length;d<f;d++)if(a.target==a.touches[d].target){c=
a.touches[d];this.touchId=c.identifier;break}mouseX=c.pageX;mouseY=c.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,g){var n,k,c,e,f,l,d,t,p,m;if(a.loadLib)return a;var s,h,v,q,u,w,r,y,B=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,D,z,F,E,C,A,I,H,P,O,x,J,G,K,L,M,S,T,Q,R,N;a.LessonParser=function(c){this.parent=c;this.parser=c.evaluator.parser;this.RTFparser=new a.RTFParser(c.evaluator)};a.LessonParser.prototype.parseButtonsConfig=function(a){var c={rowsNorth:0,rowsSouth:0,widthEast:125,widthWest:125,height:23};a=this.split(a);for(var d=0,f=a.length;d<f;d++)switch(v=a[d][0],
q=a[d][1],h=g[v],h){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":c[h]=parseInt(q);break;case "about":case "config":case "init":case "clear":c[h]="true"===g[q];break;default:console.log("----- attributo de space no identificado: <"+v+"> valor: <"+q+"> -----")}return c};a.LessonParser.prototype.parseSpace=function(c){u={};c=this.split(c);for(var d=0,f=c.length;d<f;d++)switch(v=c[d][0],q=c[d][1],h=g[v],h){case "type":case "id":case "cID":case "file":u[h]=q;break;
case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":u[h]="true"===g[q];break;case "bg_display":case "render":u[h]=g[q];break;case "net":case "net10":case "axes":case "text":u[h]="false"===g[q]?"":new a.Color(q,this.parent.evaluator);break;case "x_axis":case "y_axis":u[h]="false"===g[q]?"":q;break;case "O.x":u.OxExpr=q;break;case "O.y":u.OyExpr=q;break;case "image":u.imageSrc=q;break;case "x":s=q;s="%"===s[s.length-1]?(this.parent.container.width*parseFloat(s)/100).toString():
q;u.xExpr=this.parser.parse(s);break;case "y":s=q;s="%"===s[s.length-1]?(this.parent.container.height*parseFloat(s)/100).toString():q;u.yExpr=this.parser.parse(s);break;case "width":s=q;"%"===s[s.length-1]?s=this.parent.container.width*parseFloat(s)/100:(s=parseFloat(q),s!=q&&(s=this.parent.container.width));u.w=s;break;case "height":s=q;"%"===s[s.length-1]?s=this.parent.container.height*parseFloat(s)/100:(s=parseFloat(q),s!=q&&(s=this.parent.container.height));u.h=s;break;case "drawif":u.drawif=
this.parser.parse(q);break;case "scale":s=parseFloat(q);s.toString()!=q&&(s=48);u.scale=s;break;case "background":u.background=new a.Color(q,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+v+"> valor: <"+q+"> -----")}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(c){w={};c=this.split(c);for(var d=0,f=c.length;d<f;d++)switch(v=c[d][0],q=c[d][1],h=g[v],h){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":w[h]=q;break;case "gui":case "region":case "action":case "msg_pos":case "poster":w[h]=g[q];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":w[h]=
"true"===g[q];break;case "color":case "colorInt":case "trace":w[h]=new a.Color(q,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":w[h]=this.parser.parse(q);break;case "constraint":w.constraintExpr=q;break;case "image":w.imageSrc=q;break;case "space":w.spaceID=q;break;case "type":w.type=g[q.trim()];break;case "expresion":w.expresion=this.parser.parse(q.replace(")(",","));break;case "bold":"false"!=g[q]&&(w.bold="bold");break;
case "italics":"false"!=g[q]&&(w.italics="italic");break;case "underlined":"false"!=g[q]&&(w.underlined=!0);break;case "value":var e=q.replace(/&squot;/g,"'");e.match(/^\|/)&&(e="'"+e.substring(1),e.match(/\|$/)&&(e=e.substring(0,e.length-1)+"'"));w.valueExpr=this.parser.parse(e);w.valueExprString=e;break;case "incr":0!=q&&(w.incr=this.parser.parse(q));break;case "exponentialif":w.exponentialif=parseFloat(q);break;case "text":w.rawText=q;for(var e=this.parseText(q),l=0,k=e.length;l<k;l++)e[l]=this.parser.parse(e[l],
!1);w.text=e;break;default:l=v.indexOf(".");e=g[v.substring(0,l)];l=g[v.substring(l+1)];if("parameter"===e&&"font"===l){w.parameterFont=q;break}else if("Explanation"===e&&"font"===l){w.ExplanationFont=q;break}else if("tooltip"===e&&"font"===l){w.tooltipFont=q;break}console.log("----- attributo de control no identificado: <"+v+"> valor: <"+q+"> -----")}if("numeric"===w.type)switch(w.gui){case "spinner":return new a.Spinner(this.parent,w);case "button":return new a.Button(this.parent,w);case "textfield":return new a.TextField(this.parent,
w);case "menu":return new a.Menu(this.parent,w);case "scrollbar":return new a.Scrollbar(this.parent,w);default:return new a.Spinner(this.parent,w)}else{if("video"===w.type)return new a.Video(this.parent,w);if("audio"===w.type)return new a.Audio(this.parent,w);if("graphic"===w.type)return new a.GraphicControl(this.parent,w);if("text"===w.type)return new a.TextArea(this.parent,w)}};a.LessonParser.prototype.parseGraphic=function(c,d,f,e){r={rotateExp:e,parameter:"t"};c=this.split(c);e=0;for(var l=c.length;e<
l;e++)switch(v=c[e][0],q=c[e][1],h=g[v],h){case "type":case "align":r[h]=g[q];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":r[h]="true"===g[q];break;case "color":case "trace":case "fill":case "fillP":case "fillM":case "arrow":r[h]=new a.Color(q,this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":r[h]=q;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "init":case "end":case "opacity":case "inirot":case "inipos":case "range":r[h]=
this.parser.parse(q);break;case "space":r.spaceID=q;break;case "expresion":"macro"!=r.type?(r.expresion=this.parser.parse(q),r.expresionString=q):r.expresion=q;break;case "text":r.text=this.parseText(q);break;case "file":var k=q.replace(/&squot;/g,"'");"["===k.charAt(0)&&"]"===k.charAt(k.length-1)&&(k=k.substring(1,k.length-1));k.match(B)&&(k="'"+k+"'");r.file=this.parser.parse(k);break;case "border":"false"!=g[q]&&(r.border=new a.Color(q,this.parent.evaluator));break;default:if(void 0!=r.family&&
v.substring(0,r.family.length+1)===r.family+"."){switch(g[v.substring(r.family.length+1)]){case "interval":r.family_interval=this.parser.parse(q);break;case "steps":r.family_steps=this.parser.parse(q)}break}if(void 0!=r.parameter&&v.substring(0,r.parameter.length+1)===r.parameter+"."){switch(g[v.substring(r.parameter.length+1)]){case "interval":r.parameter_interval=this.parser.parse(q);break;case "steps":r.parameter_steps=this.parser.parse(q)}break}console.log("----- attributo del graphic no identificado: <"+
v+"> valor: <"+q+"> -----")}d&&(r.abs_coord=d);f&&(r.background=f);switch(r.type){case "text":return new a.Text(this.parent,r);case "image":return new a.Image(this.parent,r);case "point":return new a.Point(this.parent,r);case "polygon":return new a.Polygon(this.parent,r);case "arc":return new a.Arc(this.parent,r);case "segment":return new a.Segment(this.parent,r);case "arrow":return new a.Arrow(this.parent,r);case "macro":return new a.Macro(this.parent,r);case "curve":return new a.Curve(this.parent,
r);case "equation":return new a.Equation(this.parent,r);case "sequence":return new a.Sequence(this.parent,r);case "fill":return new a.Fill(this.parent,r)}};a.LessonParser.prototype.parse3DGraphic=function(c,d,f,e){r={rotateExp:e,parameter:"t"};c=this.split(c);d=0;for(f=c.length;d<f;d++)switch(v=c[d][0],q=c[d][1],h=g[v],h){case "type":case "model":r[h]=g[q];break;case "background":case "fixed":case "edges":r[h]="true"===g[q];break;case "color":case "backcolor":r[h]=new a.Color(q,this.parent.evaluator);
break;case "type":case "model":r[h]=g[q];break;case "background":case "fixed":case "edges":case "split":r[h]="true"===g[q];break;case "color":case "backcolor":r[h]=new a.Color(q,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":r[h]=this.parser.parse(q);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":r[h]=q;break;case "space":r.spaceID=q;break;case "expresion":"macro"!=
r.type&&"curve"!=r.type&&"surface"!=r.type?(r.expresion=this.parser.parse(q),r.expresionString=q):r.expresion=q.replace(/\\n/g,"");break;case "text":e=this.parseText(q);for(var l=0,k=e.length;l<k;l++)e[l]=this.parser.parse(e[l],!1);r.text=e;break;case "file":e=q.replace(/&squot;/g,"'");"["===e.charAt(0)&&"]"===e.charAt(e.length-1)&&(e=e.substring(1,e.length-1));e.match(/./)&&(e="'"+e+"'");r.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":r[h]=
this.parser.parse(q);break;case "family":case "parameter":case "font":case "name":r[h]=q;break;case "space":r.spaceID=q;break;case "expresion":"macro"!=r.type&&"curve"!=r.type&&"surface"!=r.type?(r.expresion=this.parser.parse(q),r.expresionString=q):r.expresion=q;break;case "text":e=this.parseText(q);l=0;for(k=e.length;l<k;l++)e[l]=this.parser.parse(e[l],!1);r.text=e;break;case "file":e=q.replace(/&squot;/g,"'");"["===e.charAt(0)&&"]"===e.charAt(e.length-1)&&(e=e.substring(1,e.length-1));e.match(/./)&&
(e="'"+e+"'");r.file=this.parser.parse(e);break;default:if(void 0!==r.family&&v.substring(0,r.family.length+1)===r.family+"."){"interval"===g[v.substring(r.family.length+1)]?r.family_interval=this.parser.parse(q):r.family_steps=this.parser.parse(q);break}console.log("----- attributo del graphic3D no identificado: <"+v+"> valor: <"+q+"> -----")}switch(r.type){case "point":return new a.Point3D(this.parent,r);case "segment":return new a.Segment3D(this.parent,r);case "polygon":return new a.Polygon3D(this.parent,
r);case "curve":return new a.Curve3D(this.parent,r);case "triangle":return new a.Triangle3D(this.parent,r);case "face":return new a.Face3D(this.parent,r);case "polireg":return new a.Polireg3D(this.parent,r);case "surface":return new a.Surface3D(this.parent,r);case "text":return new a.Text3D(this.parent,r);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,
r);default:console.log(r.type)}};a.LessonParser.prototype.parseAuxiliar=function(c){y={};c=this.split(c);for(var d=0,f=c.length;d<f;d++)c[d][1]=c[d][1].replace(/&squot;/g,"'");d=0;for(f=c.length;d<f;d++)switch(v=c[d][0],q=c[d][1],h=g[v],h){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":y[h]=q;break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "sequence":y[h]="true"===
g[q];break;case "size":case "rows":case "columns":y[h]=this.parser.parse(q);break;case "evaluate":case "event":case "execution":case "msg_pos":case "action":y[h]=g[q];break;default:var e=v.indexOf("."),l=g[v.substring(0,e)],e=g[v.substring(e+1)];if("parameter"===l&&"font"===e){y.parameterFont=q;break}console.log("----- attributo de auxiliar no identificado: <"+v+"> valor: <"+q+"> -----")}y.sequence?new a.Function(this.parent,y):y.constant?(c=new a.Constant(this.parent,y),y.evaluate&&"always"===y.evaluate&&
this.parent.auxiliaries.push(c)):y.algorithm&&y.evaluate?(c=new a.Algorithm(this.parent,y),this.parent.auxiliaries.push(c)):y.array&&!y.matrix&&")"!=y.id.charAt(y.id.length-1)?(c=new a.Vector(this.parent,y),y.evaluate&&"always"===y.evaluate&&this.parent.auxiliaries.push(c)):y.matrix&&")"!=y.id.charAt(y.id.length-1)?(c=new a.Matrix(this.parent,y),y.evaluate&&"always"===y.evaluate&&this.parent.auxiliaries.push(c)):y.event&&")"!=y.id.charAt(y.id.length-1)?this.parent.events.push(new a.Event(this.parent,
y)):")"===y.id.charAt(y.id.length-1)?new a.Function(this.parent,y):new a.Variable(this.parent,y)};a.LessonParser.prototype.parseAction=function(c){D=c.action;z=c.parent;F=c.parameter;if(D)switch(D){case "message":return new a.Message(z,F);case "calculate":return new a.Calculate(z,F);case "openURL":return new a.OpenURL(z,F);case "openScene":return new a.OpenScene(z,F);case "about":return new a.About(z,F);case "config":return new a.Config(z,F);case "init":return new a.Init(z,F);case "clear":return new a.Clear(z,
F);case "animate":return new a.Animate(z,F);case "initAnimation":return new a.InitAnimation(z,F);case "playAudio":return new a.PlayAudio(z,F);default:console.log("----- Accion no soportada aun: <"+D+"> -----")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(c){var d={};c=this.split(c);for(var f=0,e=c.length;f<e;f++)switch(v=c[f][0],q=c[f][1],h=g[v],h){case "id":case "delay":case "init":case "doExpr":case "whileExpr":d[h]=q;break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":d[h]=
"true"===g[q];break;default:console.log("----- attributo de la animacion no identificado: <"+v+">  <"+q+"> -----")}return new a.Animation(this.parent,d)};a.LessonParser.prototype.parsePleca=function(h,g){h=this.split(h);k=n="";c=0;e="#536891";f="white";l="left";d="";t="SansSerif,BOLD,20";p="SansSerif,PLAIN,18";m=void 0;for(var r=0,s=h.length;r<s;r++)switch(v=h[r][0],q=h[r][1],v){case "title":n=q;break;case "subtitle":k=q;break;case "subtitlines":c=q;break;case "bgcolor":""!=q&&(e=(new a.Color(q,this.parent.evaluator)).getColor());
break;case "fgcolor":""!=q&&(f=(new a.Color(q,this.parent.evaluator)).getColor());break;case "align":""!=q&&(l=q);break;case "titleimage":d=q;break;case "titlefont":t=""!=q?a.convertFont(q):a.convertFont(t);break;case "subtitlefont":p=""!=q?a.convertFont(q):a.convertFont(p);break;default:console.log("----- attributo de la pleca no identificado: <"+v+">  <"+q+"> -----")}O=p.substring(0,p.indexOf("px"));O=O.substring(O.lastIndexOf(" "));""!=d&&(x=this.parent.getImage(d),J=x.height);m=document.createElement("div");
m.setAttribute("id","descartesPleca");J?(m.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+l+"; width: "+(g-30)+"px; height: "+(J-16)+"px; background: "+e+"; color: "+f+"; 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%"),m.appendChild(x)):m.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+
l+"; width: "+(g-30)+"px; background: "+e+"; color: "+f+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");G=document.createElement("div");G.setAttribute("style","padding: 0px; margin: 0px; font: "+t+"; overflow: hidden; white-space: nowrap;");G.innerHTML=n;K=document.createElement("div");if(1===parseInt(c)){Q=0;L=document.createElement("div");L.innerHTML=k;document.body.appendChild(L);S=O;do S-=Q,L.setAttribute("style","padding: 0px; margin: 0px; font: "+
p+"; font-size: "+S+"px; width: "+(g-30)+"px; line-height: "+S+"px;"),M=L.offsetHeight,T=M/S,Q=1;while(1<T&&8<S);document.body.removeChild(L);K.setAttribute("style","padding: 0px; margin: 0px; font: "+p+"; font-size: "+S+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else K.setAttribute("style","padding: 0px; margin: 0px; font: "+p+"; line-height: 110%;");K.innerHTML=k;m.appendChild(G);m.appendChild(K);m.imageHeight=J;return m};a.LessonParser.prototype.split=function(a){if("string"!=
typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");E=[];A=C=0;I=!1;H=0;for(P=!1;C<a.length;)" "===a.charAt(C)&&!I&&C++," "!==a.charAt(C)&&!I&&(I=!0,H=C),"="===a.charAt(C)&&("'"===a.charAt(C+1)&&!P)&&(P=!0,E[A]=[a.substring(H,C)],H=C+2,C+=2),P&&"'"===a.charAt(C)&&(I=P=!1,E[A].push(a.substring(H,C)),A++),"="===a.charAt(C)&&("'"!==a.charAt(C+1)&&!P)&&(E[A]=[a.substring(H,C)],H=C+1,C++,R=a.substring(C).indexOf("="),-1===R?N=R=a.length:(R+=C,N=a.substring(C,R).lastIndexOf(" "),N=-1===N?a.length:N+C),
E[A].push(a.substring(H,N)),A++,I=!1,C=N),C++;return E};a.LessonParser.prototype.parseText=function(c){return c.match(/^\{\\rtf1/)?this.RTFparser.parse(c.substring(10)):new a.SimpleText(this.parent,c)};return a}(descartesJS||{},babel),descartesJS=function(a){function g(a,c){s=[];s.type="matrix";s.rows=a;s.cols=c;var d;v=0;for(q=c;v<q;v++){d=[];h=0;for(u=a;h<u;h++)d.push(0);s[v]=d}return s}function n(a,c){p=a.rows;m=a.cols;s=g(p,m);var d;for(v=0;v<p;v++)for(h=0;h<m;h++){for(q=d=0;q<m;q++)d+=a[q][v]*
c[h][q];s[h][v]=d}return s}function k(a,c,d){for(var f=g(d.length-1,d.length-1),e=0,h=f.length;e<h;e++)for(var l=0;l<h;l++)f[e][l]=e<a?l<c?d[e][l]:d[e][l+1]:e<c?d[e+1][l]:d[e+1][l+1];return f}function c(a){if(1<a.cols){for(var d=0,f=1,e=0,h=a.cols;e<h;e++)d+=f*a[0][e]*c(k(0,e,a)),f=-f;return d}return a[0][0]}if(a.loadLib)return a;var e=Math.floor,f,l,d,t;a.Node=function(a,c){this.sep="";this.type=a;this.value=c;this.parent=null;this.childs=[]};a.Node.prototype.getRoot=function(){return null===this.parent?
this:this.parent.getRoot()};a.Node.prototype.addChild=function(a){a.parent=this;this.childs.push(a)};a.Node.prototype.replaceLastChild=function(a){f=this.childs.length-1;lastChild=this.childs[f];lastChild.parent=null;this.childs[f]=a;a.parent=this;return a};a.Node.prototype.contains=function(a){if(this.value===a)return!0;for(var c=0,d=this.childs.length;c<d;c++)if(this.childs[c].contains(a))return!0;return!1};a.Node.prototype.equalToMinus=function(){return"compOperator"===this.type?(this.type="operator",
this.value="-",d=new a.Node("compOperator","=="),t=new a.Node("number","0"),d.addChild(this),d.addChild(t),l=this.getRoot(),l.setAllEvaluateFunction(),l):this};a.Node.prototype.setAllEvaluateFunction=function(){this.setEvaluateFunction();for(var a=0,c=this.childs.length;a<c;a++)this.childs[a].setAllEvaluateFunction()};a.Node.prototype.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(c,d){a=c.variables[this.value];if("object"===typeof a)return a.evaluate(c);void 0==a&&d&&(a=c.matrices[this.value]);return void 0!==a?a:0}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1===this.childs[0].childs.length){var d,f;this.evaluate=function(a){d=this.childs[0].childs[0].evaluate(a);try{return f=a.vectors[this.value][0>
d?0:e(d)],void 0!==f?f:0}catch(c){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var l,t;this.evaluate=function(a){l=this.childs[0].childs[0].evaluate(a);t=this.childs[0].childs[1].evaluate(a);try{return f=a.matrices[this.value][0>l?0:e(l)][0>t?0:e(t)],void 0!==f?f:0}catch(c){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var q;this.evaluate=function(a){q=[];for(var c=0,d=this.childs[0].childs.length;c<
d;c++)q.push(this.childs[0].childs[c].evaluate(a));return"_Eval_"===this.value?a.evalExpression(a.parser.parse(q[0])):a.functions[this.value].apply(a,q)}}else if("operator"===this.type){var u,E,C;"+"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);E=this.childs[1].evaluate(a,!0);if("matrix"!==u.type||"matrix"!==E.type)return u+E;a=u;var c=E;p=a.rows;m=a.cols;s=g(p,m);for(v=0;v<p;v++)for(h=0;h<m;h++)s[h][v]=a[h][v]+c[h][v];return s}:"-"===this.value?this.evaluate=function(a){u=
this.childs[0].evaluate(a,!0);E=this.childs[1].evaluate(a,!0);if("matrix"!==u.type||"matrix"!==E.type)return u-E;a=u;var c=E;p=a.rows;m=a.cols;s=g(p,m);for(v=0;v<p;v++)for(h=0;h<m;h++)s[h][v]=a[h][v]-c[h][v];return s}:"*"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);E=this.childs[1].evaluate(a,!0);return"matrix"!==u.type||"matrix"!==E.type?u*E:n(u,E)}:"/"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a,!0);E=this.childs[1].evaluate(a,!0);if("matrix"!==
u.type||"matrix"!==E.type)return u/E;a=u;var d;d=E;var f=g(d.length,d.length),e=c(d);if(0===e)d=0;else{var e=1/e,h;if(1<d.length)for(var l=0,p=d.length;l<p;l++){h=e;for(var m=0;m<p;m++)f[m][l]=h*c(k(l,m,d)),h=-h;e=-e}else f[0][0]=e;d=f}a=0===d?g(a.rows,a.cols):n(a,d);return a}:"%"===this.value?this.evaluate=function(a){u=this.childs[0].evaluate(a);E=this.childs[1].evaluate(a);return u-e(u/E)*E}:"^"===this.value&&(this.evaluate=function(a){return Math.pow(this.childs[0].evaluate(a),this.childs[1].evaluate(a))})}else if("compOperator"===
this.type)"<"===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<this.childs[1].evaluate(a))+0}:"<="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<=this.childs[1].evaluate(a))+0}:">"===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>this.childs[1].evaluate(a))+0}:">="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>=this.childs[1].evaluate(a))+0}:"=="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)===
this.childs[1].evaluate(a))+0}:"!="===this.value&&(this.evaluate=function(a){return(this.childs[0].evaluate(a)!=this.childs[1].evaluate(a))+0});else if("boolOperator"===this.type)"&"===this.value?this.evaluate=function(a){return(u=this.childs[0].evaluate(a)?1:0)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return(u=this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){u=this.childs[0].evaluate(a)?1:0;return!u+
0});else if("conditional"===this.type)this.evaluate=function(a){u=this.childs[0].evaluate(a);return 0<u?this.childs[1].evaluate(a):this.childs[2].evaluate(a)};else if("sign"===this.type)this.evaluate="sign+"===this.value?function(a){return this.childs[0].evaluate(a)}:function(a){return-this.childs[0].evaluate(a)};else if("parentheses"===this.type)this.evaluate=function(a,c){return this.childs[0].evaluate(a,c)};else if("(expr)"===this.type||"[expr]"===this.type){var A,I;this.evaluate=function(a){A=
this.childs.length;C=[];if(1===A&&1===this.childs[0].childs.length&&"(expr)"===this.type)C=this.childs[0].childs[0].evaluate(a);else for(var c=0;c<A;c++){I=[];for(var d=0,f=this.childs[c].childs.length;d<f;d++)I.push(this.childs[c].childs[d].evaluate(a));C[c]=I}return C}}else if("asign"===this.type){var H,P,O,x,J,G;this.evaluate=function(a){H=this.childs[0];P=this.childs[1];1===H.childs.length&&"square_bracket"===H.childs[0].type?(d=H.childs[0].childs,1===d.length?(O=d[0].evaluate(a),O=0>O?0:e(O),
a.vectors[H.value][O]=P.evaluate(a)):2===d.length&&(x=d[0].evaluate(a),J=d[1].evaluate(a),x=0>x?0:e(x),J=0>J?0:e(J),a.matrices[H.value][x]||(a.matrices[H.value][x]=[]),a.matrices[H.value][x][J]=P.evaluate(a))):(G=P.evaluate(a),G.type?a.matrices[H.value]=G:a.variables[H.value]=G)}}};var p,m,s,h,v,q,u;a.Node.prototype.toString=function(){var a="tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:"");for(var c=0,d=this.childs.length;c<d;c++)a+=this.sep+this.childs[c].toString();
return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n,k,c,e,f,l,d,t,p=/^\s+/,m=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,s=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,h=/^==|^!=|^<=|^<|^>=|^>|^#/,v=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,q=/^=/,u=/^[\?\:]/,w=/^[\+\-\*\/\%\^]/,r=/^\[|^\]/,y=/^\(|^\)/,B=/^,/,D=/^;/;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function z(a,e,h){n.push({type:a,value:e});f=f.slice(h);
c+=h;d++;t=a}if(g=a)a=a.replace(/\\u(\S+) /g,function(a,c){return String.fromCharCode(parseInt(c,16))}),a=a.replace(/\&sup(.+);/g,"^$1 "),a=a.replace(/&squot;/g,"'"),a.match(/\=\|\*/g)&&(a=a.replace("|*","'","g").replace("*|","'","g")),a.match(/\=\|/g)&&(a=a.replace("|","'","g"));n=[];k=!1;c=0;f=a;d=0;for(t="";a&&c<a.length;)if(k=c,"'"==f[0]){for(l=1;"'"!=f[l];)if(l<f.length)l++;else{console.log(">Error, unknown symbol: ["+f+"], in the string <<"+g+">>");return}e=f.substring(1,l);z("string",e,e.length+
2)}else if(e=f.match(p))f=f.slice(e[0].length),c+=e[0].length,d++;else if(e=f.match(m))"number"===t&&n.push({type:"operator",value:"*"}),z("identifier",e[0],e[0].length);else if(e=f.match(s))z("number",e[0],e[0].length);else if(e=f.match(h)){var A=e[0];"#"==A&&(A="!=");z("compOperator",A,e[0].length)}else if(e=f.match(v))A=e[0],"||"==A?A="|":"&&"==A?A="&":"~"==A&&(A="!"),z("boolOperator",A,e[0].length);else if((e=f.match(q))&&!f.match(/^==/))z("asign",e[0],e[0].length);else if(e=f.match(u))z("conditional",
e[0],e[0].length);else if(e=f.match(w))z("operator",e[0],e[0].length);else if(e=f.match(r))z("square_bracket",e[0],e[0].length);else if(e=f.match(y))z("parentheses",e[0],e[0].length);else if(e=f.match(B))z("separator",e[0],e[0].length);else if(e=f.match(D))z("final_of_expresion",e[0],e[0].length);else if(k==c){console.log("Error, simbolo no conocido: ["+f+"], en la cadena <<"+g+">>");return}return n};var z,F=/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,c){a=a||[];c=c||"";z="";for(var d=0,f=a.length;d<f;d++)z="string"==a[d].type?z+"&squot;"+a[d].value+"&squot;":"identifier"==a[d].type&&!a[d].value.match(F)?z+c+a[d].value:z+a[d].value;return z};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Parser=function(c){this.evaluator=c;this.tokenizer=new a.Tokenizer;this.vectors={};this.matrices={};this.variables={};this.functions={};this.registerDefaultValues()};a.Parser.prototype.setVariable=
function(a,c){this.variables[a]=c};a.Parser.prototype.getVariable=function(a){this.variables[a]=void 0!==this.variables[a]?this.variables[a]:0;return this.variables[a]};a.Parser.prototype.setVector=function(a,c,d){this.vectors[a][c]=d};a.Parser.prototype.getVector=function(a){this.vectors.hasOwnProperty(a)||(this.vectors[a]=[0,0,0]);return this.vectors[a]};a.Parser.prototype.setMatrix=function(a,c,d,f){this.matrices[a][c][d]=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,c){this.functions[a]=c};a.Parser.prototype.getFunction=function(a){this.functions.hasOwnProperty(a)||(this.functions[a]=function(){return 0});return this.functions[a]};var g,n,k,c,e,f,l,d,t,p,m,s;a.Parser.prototype.parse=function(h,v){(k=this.tokenizer.tokenize(h))||(k=[]);c=null;v=!v||!1;g=d=l=f=0;for(n=k.length;g<n;g++)if(t=k[g],p=t.value,m=t.type,"identifier"===m&&(g+1<n&&"parentheses"===
k[g+1].type&&"("===k[g+1].value?this.getFunction(p):g+1<n&&"square_bracket"===k[g+1].type&&"["===k[g+1].value?k[g+3]&&"square_bracket"===k[g+3].type&&"]"===k[g+3].value?this.getVector(p):this.getMatrix(p):this.getVariable(p)),"asign"===m&&v&&(m="compOperator",p="=="),"asign"===m)if(e=new a.Node(m,p),null!=c)if("identifier"===c.type)c.parent&&c.parent.replaceLastChild(e),e.addChild(c),c=e,v=!0;else if("square_bracket"===c.type)e.addChild(c.parent),c=e,v=!0;else{e.type="compOperator";e.value="==";for(v=
!0;c.parent&&this.getPrecedence(c.parent.value)>=this.getPrecedence(e.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(e);e.addChild(c);c=e}else{console.log("Error1: en la expresion <<"+h+">>, en el token {valor: "+p+", tipo: "+m+"}");break}else if("parentheses"===m&&"("===p||"square_bracket"===m&&"["===p)if(e=new a.Node(m,p),"("===p&&f++,"["===p&&l++,null===c)"("===p&&(new a.Node("(expr)","(expr)")).addChild(e),"["===p&&(new a.Node("[expr]","[expr]")).addChild(e),c=e;else if("operator"===c.type||
"boolOperator"===c.type||"compOperator"===c.type||"conditional"===c.type||"asign"===c.type)c.addChild(e),c=e;else if("sign"===c.type)c.addChild(e),c=e;else if("parentheses"===c.type&&"("===c.value)c.addChild(e),c=e;else if("square_bracket"===c.type&&"["===c.value)c.addChild(e),c=e;else if("parentheses"===c.type&&"()"===c.value)c.parent.addChild(e),c=e;else if("square_bracket"===c.type&&"[]"===c.value)c.parent.addChild(e),c=e;else if("identifier"===c.type)c.addChild(e),c=e;else{console.log("Error2: en la expresion <<"+
h+">>, en el token ["+g+"] {valor: "+p+", tipo: "+m+"}");break}else if("parentheses"===m&&")"===p)if(f--,null===c)console.log("Error3: en la expresion <<"+h+">>, en el token (valor:"+p+", tipo:"+m);else{for(;c&&c.parent&&"("!=c.value;)c=c.parent;if(c&&"("===c.value)c.value="()";else{console.log("Error4: en la expresion <<"+h+">>, en el token {valor: "+p+", tipo: "+m+"}");break}}else if("square_bracket"===m&&"]"===p)if(l--,null===c)console.log("Error5: en la expresion <<"+h+">>, en el token (valor:"+
p+", tipo:"+m);else{for(;c&&c.parent&&"["!=c.value;)c=c.parent;if(c&&"["===c.value)c.value="[]";else{console.log("Error6: en la expresion <<"+h+">>, en el token {valor: "+p+", tipo: "+m+"}");break}}else if("number"===m||"string"===m||"identifier"===m)if(e=new a.Node(m,p),null===c)c=e;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(e),
c=e;else{console.log("Error7: en la expresion <<"+h+">>, en el token {valor: "+p+", tipo: "+m+"}");break}else if("operator"===m||"compOperator"===m||"boolOperator"===m)if(e=new a.Node(m,p),null===c)if("-"===p||"+"===p)e.type="sign",e.value="sign"+p,c=e;else if("!"===p)c=e;else{console.log("Error8: en la expresion <<"+h+">>, en el token {valor: "+p+", tipo: "+m+"}");break}else if("operator"===c.type||"compOperator"===c.type||"boolOperator"===c.type||"asign"===c.type||"conditional"===c.type||"square_bracket"===
c.type&&"["===c.value&&("-"===p||"+"===p||"!"===p)||"parentheses"===c.type&&"("===c.value&&("-"===p||"+"===p||"!"===p)){if("-"===p||"+"===p)e.type="sign",e.value="sign"+p;c.addChild(e);c=e}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(e.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(e);
e.addChild(c);c=e}else{console.log("Error9: en la expresion <<"+h+">>, en el token {valor: "+p+", tipo: "+m+"}");break}else if("conditional"===m)if(e=new a.Node(m,p),null!=c)if("?"===e.value){for(d++;c.parent&&this.getPrecedence(c.parent.value)>this.getPrecedence(e.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(e);e.addChild(c);c=e}else{for(d--;c&&c.parent&&"?"!=c.value;)c=c.parent;if(c&&"?"===c.value)c.value="?:";else{console.log("Error10: en la expresion <<"+h+">>, en el token {valor: "+
p+", tipo: "+m+"}");break}}else{console.log("Error11: en la expresion <<"+h+">>, en el token {valor: "+p+", tipo: "+m+"}");break}else if("separator"===m)if(null!=c)for(;c.parent&&"("!=c.value&&"["!=c.value;)c=c.parent;else{console.log("Error12: en la expresion <<"+h+">>, en el token {valor: "+p+", tipo: "+m+"}");break}else{console.log("Error13: en la expresion <<"+h+">>, en el token {valor: "+p+", tipo: "+m+"}");break}0<f&&alert("Error, faltan parentesis por cerrar: "+h);0>f&&alert("Error, faltan parentesis por abrir: "+
h);0<l&&alert("Error, faltan square bracketss por cerrar: "+h);0>l&&alert("Error, faltan square bracketss por abrir: "+h);0!=d&&alert("Error, condicional incompleta: "+h);(s=c?c.getRoot():null)&&s.setAllEvaluateFunction();return s};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 8;default:return 9}};a.Parser.prototype.registerDefaultValues=function(){this.variables.rnd=Math.random;this.variables.pi=Math.PI;this.variables.e=Math.E;this.variables.Infinity=Infinity;this.variables["-Infinity"]=-Infinity;this.functions.sqr=function(a){return a*a};this.functions.sqrt=this.functions["ra\u00edz"]=
Math.sqrt;this.functions.exp=Math.exp;this.functions.log=Math.log;this.functions.log10=function(a){return Math.log(a)/Math.log(10)};this.functions.abs=Math.abs;this.functions.ent=Math.floor;this.functions.sgn=function(a){return 0<a?1:0>a?-1:0};this.functions.ind=function(a){return a?1:0};this.functions.sin=this.functions.sen=Math.sin;this.functions.cos=Math.cos;this.functions.tan=Math.tan;this.functions.cot=function(a){return 1/Math.tan(a)};this.functions.sec=function(a){return 1/Math.cos(a)};this.functions.csc=
function(a){return 1/Math.sin(a)};this.functions.sinh=this.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};this.functions.cosh=function(a){return(Math.exp(a)+Math.exp(-a))/2};this.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/(Math.exp(a)+Math.exp(-a))};this.functions.coth=function(a){return 1/this.functions.tanh(a)};this.functions.sech=function(a){return 1/this.functions.cosh(a)};this.functions.csch=function(a){return 1/this.functions.sinh(a)};this.functions.asin=this.functions.asen=
Math.asin;this.functions.acos=Math.acos;this.functions.atan=Math.atan;this.functions.min=Math.min;this.functions.max=Math.max;var c=this;this.functions._Trace_=function(a){console.log(a)};this.functions._Stop_Audios_=function(){c.evaluator.parent.stopAudios()};this.functions.esCorrecto=function(d,f,e){return a.esCorrecto(d,f,c.evaluator,e)};this.functions.escorrecto=function(d,f,e){return a.escorrecto(d,f,c.evaluator,e)};window.parent!==window&&(this.functions["parent.set"]=function(a,c){window.parent.postMessage({type:"set",
name:a,value:c},"*")},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*")},this.functions["parent.exec"]=function(a,c){window.parent.postMessage({type:"exec",name:a,value:c},"*")})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=Math.floor;a.Evaluator=function(g){this.parent=g;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,g){this.variables[a]=g};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,k,c){k=0>k?0:g(k);this.vectors[a][k]=c};a.Evaluator.prototype.getVector=function(a,k){k=0>k?0:g(k);return this.vectors[a][k]};a.Evaluator.prototype.setMatrix=function(a,k,c,e){k=0>k?0:g(k);c=0>c?0:g(c);this.matrices[a][k][c]=e};a.Evaluator.prototype.getMatrix=function(a,k,c){k=0>k?0:g(k);c=0>c?0:g(c);return this.matrices[a][k][c]};
a.Evaluator.prototype.setFunction=function(a,g){this.functions[a]=g};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a){return a?a.evaluate(this):0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=2,n=!1;a.RTFNode=function(a,c,d,e){this.evaluator=a;this.type="rtfNode";this.value=c;this.nodeType=d;this.style=e;this.styleString=e.toString();this.color=e.textColor;this.underline=e.textUnderline;this.overline=
e.textOverline;this.parent=null;this.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 k=0,c=0,e=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var f=0,l=this.children.length;f<
l;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 d=a.getFontMetrics(this.styleString);this.baseline=d.baseline;this.descent=d.descent;this.ascent=d.ascent;this.width=d.width;this.height=d.height}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);
d=a.getFontMetrics(this.styleString);this.baseline=d.baseline;this.descent=d.descent;this.ascent=d.ascent;var f=this.value,t;"string"!=typeof this.value&&(l=void 0==this.decimals?g:this.evaluator.evalExpression(this.decimals),t=void 0==this.fixed?n:this.fixed,f=this.evaluator.evalExpression(this.value,l,t),parseFloat(f)==f&&(f=parseFloat(f).toFixed(l),f=t?f:parseFloat(f),f=f.toString().replace(".",this.decimal_symbol)),f+=" ");this.width=a.getTextWidth(f,this.styleString);this.height=d.height}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.width=a.getTextWidth(this.value,this.styleString),this.height=f.height,this.clickCacher=document.createElement("div"),this.clickCacher.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px;");else if("superIndex"==this.nodeType)this.spaceWidth=
a.getTextWidth(" ",this.styleString),l=k,d=c,l=e,f=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.height&&(this.ascent=f.ascent,this.descent=f.descent,this.height=this.ascent+this.descent,this.width=1.5*this.spaceWidth),f=l/2-d+this.height,this.superIndexPos=f-this.ascent,this.ascent=f,this.descent=d,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),l=k,d=c,f=a.getFontMetrics(this.styleString),
this.getBlockMetric(),0>this.height&&(this.ascent=f.ascent,this.descent=f.descent,this.height=this.ascent+this.descent,this.width=1.5*this.spaceWidth),this.subIndexPos=d+1,this.ascent=l,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("fraction"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);d=c;l=e;t=this.children[0];var p=this.children[1],f=a.getFontMetrics(t.styleString);t.getBlockMetric();p.getBlockMetric();
0>t.height&&(t.height=f.height,t.width=this.spaceWidth);0>p.height&&(p.height=f.height,p.width=this.spaceWidth);this.height=t.height+p.height-1;this.ascent=t.height+l/2-d;this.descent=this.height-this.ascent;this.baseline=this.ascent;this.width=Math.max(t.width,p.width)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);d=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator,"","radicand",d),this.children[1].addChild(this.children[0]),
this.children[0]=new a.RTFNode(this.evaluator,"","index",d);else if("index"!==this.children[0].nodeType||"radicand"!==this.children[1].nodeType){t=new a.RTFNode(this.evaluator,"","radicand",d);f=0;for(l=this.children.length;f<l;f++)t.addChild(this.children[f]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",d);this.children[1]=t}d=this.children[0];f=this.children[1];d.getBlockMetric();f.getBlockMetric();this.ascent=f.height/2<d.height?f.height/2+d.height+2-f.descent:f.ascent+
4;this.descent=f.descent;this.baseline=this.ascent;this.height=this.ascent+this.descent;this.width=d.width+f.width+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),d=this.children[0],l=this.children[1],t=this.children[2],d.getBlockMetric(),l.getBlockMetric(),t.getBlockMetric(),-1==d.ascent&&(p=a.getFontMetrics(d.styleString),d.ascent=p.ascent,d.descent=p.descent,d.height=p.height),-1==l.ascent&&(p=a.getFontMetrics(l.styleString),l.ascent=p.ascent,
l.descent=p.descent,l.height=p.height),f=a.getFontMetrics(this.styleString),this.ascent=f.height+l.height>t.ascent?f.height-f.descent+l.height:t.ascent,this.descent=d.height>t.descent?d.height+f.descent:t.descent,this.baseline=this.ascent,this.height=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.width=Math.max(d.width,l.width,f)+Math.max(t.width,this.spaceWidth)+this.spaceWidth;else if("integral"==
this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),d=this.children[0],l=this.children[1],t=this.children[2],d.getBlockMetric(),l.getBlockMetric(),t.getBlockMetric(),-1==d.ascent&&(p=a.getFontMetrics(d.styleString),d.ascent=p.ascent,d.descent=p.descent,d.height=p.height),-1==l.ascent&&(p=a.getFontMetrics(l.styleString),l.ascent=p.ascent,l.descent=p.descent,l.height=p.height),f=a.getFontMetrics(this.styleString),this.ascent=f.height+l.height>t.ascent?f.height-f.descent+l.height:t.ascent,
this.descent=d.height>t.descent?d.height+f.descent:t.descent,this.baseline=this.ascent,this.height=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.width=Math.max(d.width,l.width,f)+Math.max(t.width,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),d=this.children[0],l=this.children[1],t=this.children[2],f=a.getFontMetrics(this.styleString),
d.getBlockMetric(),l.getBlockMetric(),t.getBlockMetric(),-1==d.ascent&&(p=a.getFontMetrics(d.styleString),d.ascent=p.ascent,d.descent=p.descent,d.height=p.height),-1==l.ascent&&(p=a.getFontMetrics(l.styleString),l.ascent=p.ascent,l.descent=p.descent,l.height=p.height),-1==t.ascent&&(p=a.getFontMetrics(t.styleString),t.ascent=p.ascent,t.descent=p.descent,t.height=p.height),this.ascent=t.ascent,this.descent=Math.max(f.height,t.descent),this.baseline=this.ascent,this.height=this.ascent+this.descent,
f=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==d.width&&(d.width=this.spaceWidth),0==l.width&&(l.width=this.spaceWidth),0==t.width&&(t.width=this.spaceWidth),this.width=l.width+d.width+t.width+f+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);d=c;t=f.ascent;for(var p=f.descent,m=f.height,s=this.spaceWidth,h,v,f=0,l=this.children.length;f<l;f++)this.children[f].getBlockMetric(),h=this.children[f].height,
v=this.children[f].width,m<h&&(m=h,t=this.children[f].ascent,p=this.children[f].descent),s<v&&(s=v);this.childWidth=s+2*this.spaceWidth;this.childHeight=m;this.childAscent=t;this.childDescent=p;this.height=this.rows*m;this.ascent=this.height/2+d;this.descent=this.height-this.ascent;this.width=this.columns*this.childWidth+this.spaceWidth}else if("defparts"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);d=c;t=f.ascent;p=f.descent;m=f.height;
s=this.spaceWidth;f=0;for(l=this.children.length;f<l;f++)this.children[f].getBlockMetric(),h=this.children[f].height,v=this.children[f].width,m<h&&(m=h,t=this.children[f].ascent,p=this.children[f].descent),s<v&&(s=v);this.childWidth=s+2*this.spaceWidth;this.childHeight=m;this.childAscent=t;this.childDescent=p;this.height=this.parts*m;this.ascent=this.height/2+d;this.descent=this.height-this.ascent;this.width=s+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),
d=a.getFontMetrics(this.styleString),this.baseline=d.baseline,this.descent=d.descent,this.ascent=d.ascent,this.width=a.getTextWidth(this.value,this.styleString)+a.getTextWidth(" ",this.styleString),this.height=d.height):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),this.height=this.ascent=this.descent=this.baseline=0,this.width=this.componentNumCtrl.w):"componentSpace"==this.nodeType?
(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentSpace=this.evaluator.parent.getSpaceByCId(this.value),this.height=this.ascent=this.descent=this.baseline=0,this.width=this.componentSpace.w):console.log("Element i=unknown",this.nodeType)};a.RTFNode.prototype.getBlockMetric=function(){this.width=0;for(var a=-1,l=-1,d,g=0,p=this.children.length;g<p;g++){d=this.children[g];d.getTextMetrics();childAscent=d.ascent;childDescent=d.descent;this.width+=d.width;var n=childDescent;d=d.height;
k=childAscent;c=n;e=d;l<childAscent&&(l=childAscent);a<childDescent&&(a=childDescent)}this.ascent=l;this.descent=a;this.baseline=this.ascent;this.height=this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,c,d,e,k,m,s){this.stableWidth||(this.getTextMetrics(),g=e,n=k);s=s?-this.children[0].ascent:0;k=e=0;for(m=this.children.length;k<m;k++)0<k&&(e+=this.children[k-1].height),this.children[k].draw(a,c+0,d+s+e)};a.RTFNode.prototype.drawTextLineBlock=function(c,e,d){for(var g=0,k=0,
n=this.children.length;k<n;k++)0<k&&(g+=this.children[k-1].width,"formula"==this.children[k-1].nodeType&&(g+=2*a.getTextWidth(" ",this.children[k].styleString))),this.children[k].draw(c,e+g,d+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,c,d){for(var e=0,g=0,k=this.children.length;g<k;g++)0<g&&(e+=this.children[g-1].width),this.children[g].draw(a,c+this.spaceWidth+e,d)};a.RTFNode.prototype.drawText=function(a,c,d){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign=
"start";a.textBaseline="alphabetic";a.fillText(this.value,c-1,d);if(this.underline){var e="bold"==this.style.textBold,g=e?1:0.5;a.lineWidth=e?2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(c-1,parseInt(d+this.descent/2)+g);a.lineTo(c-1+this.width,parseInt(d+this.descent/2)+g);a.stroke()}this.overline&&(g=(e="bold"==this.style.textBold)?2:1.5,a.lineWidth=e?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(c-1,parseInt(d-this.ascent)+g),a.lineTo(c-1+this.width,
parseInt(d-this.ascent)+g),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(c,e,d){var k=Math.floor(0.5*this.spaceWidth),p=void 0==this.decimals?g:this.evaluator.evalExpression(this.decimals),m=void 0==this.fixed?n:this.fixed,s=this.evaluator.evalExpression(this.value,p,m);parseFloat(s).toString()===s.toString()&&(s=m?parseFloat(s).toFixed(p):parseFloat(parseFloat(s).toFixed(p)),s=(""+s).replace(".",this.decimal_symbol));null!=this.color&&(c.fillStyle=this.color);c.font=this.styleString;
c.textAlign="start";c.textBaseline="alphabetic";this.width=a.getTextWidth(s,this.styleString);c.fillText(s,k+e,d);this.underline&&(m=(p="bold"==this.style.textBold)?1:0.5,c.lineWidth=p?2:1,null!=this.color&&(c.strokeStyle=this.color),c.beginPath(),c.moveTo(k+e-1,parseInt(d+this.descent/2)+m),c.lineTo(k+e-1+this.width,parseInt(d+this.descent/2)+m),c.stroke());this.overline&&(m=(p="bold"==this.style.textBold)?2:1.5,c.lineWidth=p?2:1,null!=this.color&&(c.strokeStyle=this.color),c.beginPath(),c.moveTo(k+
e-1,parseInt(d-this.ascent)+m),c.lineTo(k+e-1+this.width,parseInt(d-this.ascent)+m),c.stroke());this.width+=2*k};a.RTFNode.prototype.drawHyperlink=function(a,c,d){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,c-1,d);var e="bold"==this.style.textBold,g=e?1:0.5;a.linew=e?2:1;a.beginPath();a.moveTo(c-1,parseInt(d+this.descent/2)+g);a.lineTo(c-1+this.w,parseInt(d+
this.descent/2)+g);a.stroke();a.restore()};a.RTFNode.prototype.drawRadical=function(a,c,d){var e=Math.floor(this.spaceWidth);this.children[0].draw(a,c,Math.floor(d+this.children[1].descent-this.children[1].height/2-this.children[0].descent));this.children[1].draw(a,c+1.5*e+this.children[0].width,d);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(c,Math.floor(d+this.children[1].descent-this.children[1].height/2));a.lineTo(c+this.children[0].width,Math.floor(d+this.children[1].descent-
this.children[1].height/2));a.lineTo(c+this.children[0].width+0.5*e,d+this.children[1].descent);a.lineTo(c+this.children[0].width+1*e,d-this.children[1].ascent);a.lineTo(c+this.children[0].width+2*e+this.children[1].width,d-this.children[1].ascent);a.stroke()};a.RTFNode.prototype.drawFraction=function(a,c,d){this.children[0].draw(a,c+(this.width-this.children[0].width)/2,d-this.ascent);this.children[1].draw(a,c+(this.width-this.children[1].width)/2,d-this.ascent+this.children[0].height-1);var e=Math.floor(0.5*
this.spaceWidth);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(c+e,parseInt(d-this.ascent+this.children[0].height)+0.5);a.lineTo(c-e+this.width-1,parseInt(d-this.ascent+this.children[0].height)+0.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,c,d){for(var e=0,g=0,k=this.children.length;g<k;g++)0<g&&(e+=this.children[g-1].width),this.children[g].draw(a,c+e,d+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,c,d){for(var e=0,g=0,k=this.children.length;g<
k;g++)0<g&&(e+=this.children[g-1].width),this.children[g].draw(a,c+e,d+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,c,d){for(var e=0,g=0,k=this.children.length;g<k;g++)0<g&&(e+=this.children[g-1].width),this.children[g].draw(a,c+e,d-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(c,e,d){var g=a.getFontMetrics(this.styleString),k=" "+String.fromCharCode(8594),n=a.getTextWidth(k,this.styleString);this.children[0].draw(c,e,d+g.descent+this.children[0].ascent);this.children[1].draw(c,
e+this.children[0].width+n,d+g.descent+this.children[1].ascent);this.children[2].draw(c,e+n+this.children[0].width+this.children[1].width,d);null!=this.color&&(c.fillStyle=this.color);c.font=this.styleString;c.textAlign="start";c.textBaseline="alphabetic";c.fillText("l\u00edm",e+this.children[0].width,d);c.fillText(k,e+this.children[0].width,d+g.descent+this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(c,e,d){var g=this.style.clone();g.fontSize*=1.5;g.fontType="Times New Roman";
g.Bold="bold";var g=g.toString(),k=a.getTextWidth(String.fromCharCode(8747),g),n=a.getFontMetrics(g),s=Math.max(this.children[0].width,this.children[1].width,Math.floor(1.5*k));this.children[0].draw(c,e+k,d+n.descent+this.children[0].ascent);this.children[1].draw(c,e+k+this.spaceWidth/2,d-this.ascent+this.children[1].ascent);this.children[2].draw(c,e+s+k,d);null!=this.color&&(c.fillStyle=this.color);c.font=g;c.textAlign="start";c.textBaseline="alphabetic";c.fillText(String.fromCharCode(8747),e,d+
n.descent/2)};a.RTFNode.prototype.drawSum=function(c,e,d){var g=this.style.clone();g.fontType="Times New Roman";g.Bold="bold";var g=g.toString(),k=a.getTextWidth(String.fromCharCode(8721),g),n=a.getFontMetrics(this.styleString),s=Math.max(this.children[0].width,this.children[1].width,k);this.children[0].draw(c,e+(s-this.children[0].width)/2,d+n.descent+this.children[0].ascent);this.children[1].draw(c,e+(s-this.children[1].width)/2,d-n.ascent-this.children[1].descent);this.children[2].draw(c,e+s,d);
null!=this.color&&(c.fillStyle=this.color);c.font=g;c.textAlign="start";c.textBaseline="alphabetic";c.fillText(String.fromCharCode(8721),e+Math.floor((s-k)/2),d-5)};a.RTFNode.prototype.drawMatrix=function(a,c,d){for(var e,g,k=0,n=this.children.length;k<n;k++)e=k%this.columns,g=Math.floor(k/this.columns),this.children[k].draw(a,2*this.spaceWidth+c+e*this.childWidth,d-this.ascent+this.childAscent+g*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(c+
this.spaceWidth)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.spaceWidth/2)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.spaceWidth/2)+0.5,d+this.descent+0.5);a.lineTo(Math.floor(c+this.spaceWidth)+0.5,d+this.descent+0.5);a.moveTo(Math.floor(c+this.width-this.spaceWidth)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.width-this.spaceWidth/2)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.width-this.spaceWidth/2)-0.5,d+this.descent+0.5);a.lineTo(Math.floor(c+this.width-this.spaceWidth)-
0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawDefparts=function(a,c,d){for(var e=0,g=this.children.length;e<g;e++)this.children[e].draw(a,c+this.spaceWidth/4,d-this.ascent+this.childAscent+e%this.parts*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(c+this.spaceWidth/3)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.spaceWidth/6)+0.5,d-this.ascent+0.5+(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(c+this.spaceWidth/
6)+0.5,d+this.descent-this.height/2-(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(c+0.5,d+this.descent-this.height/2);a.lineTo(Math.floor(c+this.spaceWidth/6)+0.5,d+this.descent-this.height/2+(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(c+this.spaceWidth/6)+0.5,d+this.descent+0.5-(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(c+this.spaceWidth/3)+0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawMathSymbol=function(a,c,d){a.lineWidth=1;null!=this.color&&(a.strokeStyle=
this.color,a.fillStyle=this.color);a.beginPath();"("==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText("(",c,d)):")"==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText(")",c+this.spaceWidth,d)):(a.font=this.styleString,a.textAlign="center",a.textBaseline="alphabetic",a.fillText(this.value,c+this.width/2,d))};a.RTFNode.prototype.drawGenericBlock=function(a,c,d){for(var e=0,g=0,k=this.children.length;g<k;g++)0<
g&&(e+=this.children[g-1].width),this.children[g].draw(a,c+e,d)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,c,d){this.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+c+","+(d-this.parent.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,c,d){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(c+"");this.componentSpace.yExpr=this.evaluator.parser.parse(d-this.parent.ascent+
"")};a.RTFNode.prototype.draw=function(a,c,d){console.log(">>> Dibujo desconocido ",this.nodeType)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g=String.fromCharCode,n,k,c,e,f,l,d,t,p,m,s;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=function(a){if(a)a=a.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[];
n=[];k=a.length;n=[];c="";f=e=0;d=a.charAt(0);t=!1;for(p="text";e<k;)l=d,d=a.charAt(e+1),t?"\\"===d||"{"===d||"}"===d||" "===d||";"===d?(t=!1,c+=l," "===d&&(e++,d=a.charAt(e+1)),(m=c.match(/^\'([0-9a-f]{2})/))?(s="","text"===p&&(s=n.pop().value),c=s+=g(parseInt(m[1],16))+c.substring(3)):(m=c.match(/^u[0-9]+/))?(s="","text"===p&&(s=n.pop().value),c=s+=g(m[0].substring(1))):(n.push({type:"controlWord",value:c}),p="controlWord",c="")):c+=l:"\\"===l?(t=!0,""!==c&&(n.push({type:"text",value:c}),p="text"),
c=""):"{"===l?(f++,""!==c&&n.push({type:"text",value:c}),c="",n.push({type:"openBlock",value:f}),p="openBlock"):"}"===l?(""!==c&&n.push({type:"text",value:c}),c="",n.push({type:"closeBlock",value:f}),p="closeBlock",f--):""===c&&" "===l&&"controlWord"===p?p="text":c+=l,e++;""!==c&&n.push({type:"text",value:c});return n};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g,n,k,c,e,f,l,d,t,p,m,s,h,v,q,u,w,r,y,B,D,z,F,E,C,A,I,H,P,O;a.RTFParser=function(c){this.evaluator=c;this.tokenizer=
new a.RTFTokenizer};a.RTFParser.prototype.parse=function(x){x=g=this.tokenizer.tokenize(x);for(var J=[],G=!1,K=!1,L=[],M=0,S=x.length;M<S;M++){"openBlock"==x[M].type&&L.push(x[M].value);"closeBlock"==x[M].type&&(L.pop(),0>=L.length&&(G=!1));if("controlWord"==x[M].type&&("expr"==x[M].value||"decimals"==x[M].value))K=!0;"controlWord"==x[M].type&&"mjaformula"==x[M].value&&(G=!0);if("text"==x[M].type&&G&&!K){for(var T=0,Q=x[M].value,R="",N=0,W=Q.length;N<W;N++)if("("==Q.charAt(N)||")"==Q.charAt(N)||"+"==
Q.charAt(N)||"-"==Q.charAt(N)||"*"==Q.charAt(N)||"="==Q.charAt(N))R=Q.substring(T,N),""!=R&&J.push({type:"text",value:R}),J.push({type:Q.charAt(N),value:Q.charAt(N)}),T=N+1;R=Q.substring(T,N);""!=R&&J.push({type:"text",value:R})}else J.push(x[M]),"text"==x[M].type&&K&&(K=!1)}g=J;n={};c=2;if("openBlock"==g[0].type&&"fonttbl"==g[1].value){for(k=g[0].value;"closeBlock"!=g[c].type&&g[c].value!=k;)n[g[c].value]=g[c+2].value.substring(0,g[c+2].value.length-1),c+=3;c++}e={};f=0;if("openBlock"==g[c].type&&
"colortbl"==g[c+1].value){k=g[c++].value;for(c++;"closeBlock"!=g[c].type&&g[c].value!=k;)l=parseInt(g[c++].value.substring(3)).toString(16),d=parseInt(g[c++].value.substring(5)).toString(16),t=parseInt(g[c++].value.substring(4)).toString(16),";"===g[c].value&&c++,e[f++]="#"+(2>l.length?"0"+l:l)+(2>d.length?"0"+d:d)+(2>t.length?"0"+t:t);c++}p=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");m=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");p.addChild(m);v=h=s=null;B=y=r=w=u=q=!1;D=[new a.FontStyle(20,
"Arial","","",!1,!1,null)];z=D[0];F=!0;C=E=-1;A=[];O=P=H=I=!1;x=c;for(J=g.length;x<J;x++)if("controlWord"==g[x].type&&n[g[x].value])z.fontType=n[g[x].value];else if("controlWord"==g[x].type&&g[x].value.match(/^fs(\d+)/))z.fontSize=parseInt(g[x].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==g[x].type&&"b"==g[x].value)z.textBold="bold";else if("controlWord"==g[x].type&&"b0"==g[x].value)z.textBold="";else if("controlWord"==g[x].type&&"i"==g[x].value)z.textItalic="italic";else if("controlWord"==
g[x].type&&"i0"==g[x].value)z.textItalic="";else if("controlWord"==g[x].type&&"ul"==g[x].value)z.textUnderline=!0;else if("controlWord"==g[x].type&&"ulnone"==g[x].value)z.textUnderline=!1;else if("controlWord"==g[x].type&&"ol"==g[x].value)z.textOverline=!0;else if("controlWord"==g[x].type&&"olnone"==g[x].value)z.textOverline=!1;else if("controlWord"==g[x].type&&g[x].value.match(/^cf(\d+)/))z.textColor=e[parseInt(g[x].value.substring(2))];else if("openBlock"==g[x].type)E=g[x].value,z=z.clone(),D.push(z),
A.push(null);else if("closeBlock"==g[x].type)g[x].value==C&&(C=-1,q=!1,m=m.parent),D.pop(),z=D[D.length-1],A.pop();else if("controlWord"==g[x].type&&"par"==g[x].value){m.addChild(new a.RTFNode(this.evaluator,"","newLine",z.clone()));p=new a.RTFNode(this.evaluator,"","textLineBlock",z.clone());if("textBlock"!=m.nodeType)for(m=m.parent;"textBlock"!=m.nodeType;)m=m.parent;m.addChild(p);m=p}else if("controlWord"==g[x].type&&"mjaformula"==g[x].value)I=!0,C=E,q=!0,p=new a.RTFNode(this.evaluator,"","formula",
z.clone()),m.addChild(p),m=p,A[A.length-1]=p;else if("controlWord"==g[x].type&&("fraction"==g[x].value||"radicand"==g[x].value||"radical"==g[x].value||"what"==g[x].value||"sum"==g[x].value||"integral"==g[x].value||"limit"==g[x].value))G=A[A.length-2].style.clone(),p=new a.RTFNode(this.evaluator,"",g[x].value,G),A[A.length-2].addChild(p),A[A.length-1]=p;else if("controlWord"==g[x].type&&"index"==g[x].value||"to"==g[x].value||"from"==g[x].value)G=A[A.length-2].style.clone(),G.fontSize=parseInt(G.fontSize-
0.2*G.fontSize),8>G.fontSize&&(G.fontSize=8),p=new a.RTFNode(this.evaluator,"",g[x].value,G),A[A.length-2].addChild(p),A[A.length-1]=p;else if("controlWord"==g[x].type&&("num"==g[x].value||"den"==g[x].value))G=A[A.length-2].style.clone(),G.fontSize=Math.round(G.fontSize-0.1*G.fontSize),8>G.fontSize&&(G.fontSize=8),"num"==g[x].value?p=new a.RTFNode(this.evaluator,"","numerator",G):"den"==g[x].value&&(p=new a.RTFNode(this.evaluator,"","denominator",G)),A[A.length-2].addChild(p),A[A.length-1]=p;else if("controlWord"==
g[x].type&&("subix"==g[x].value||"supix"==g[x].value))G=A[A.length-2].style.clone(),G.fontSize=Math.floor(G.fontSize-G.fontSize/3),8>G.fontSize&&(G.fontSize=8),"subix"==g[x].value?p=new a.RTFNode(this.evaluator,"","subIndex",G):"supix"==g[x].value&&(p=new a.RTFNode(this.evaluator,"","superIndex",G)),p.originalStyle=A[A.length-2].style.clone(),A[A.length-2].addChild(p),A[A.length-1]=p;else if("controlWord"==g[x].type&&("defparts"==g[x].value||"matrix"==g[x].value||"element"==g[x].value))G=A[A.length-
2].style.clone(),p=new a.RTFNode(this.evaluator,"",g[x].value,G),A[A.length-2].addChild(p),A[A.length-1]=p,"defparts"==g[x].value?v=p:"matrix"==g[x].value&&(h=p);else if("controlWord"==g[x].type&&"parts"==g[x].value)B=!0;else if("text"==g[x].type&&B)v.parts=parseInt(g[x].value),B=!1;else if("controlWord"==g[x].type&&"rows"==g[x].value)r=!0;else if("text"==g[x].type&&r)h.rows=parseInt(g[x].value),r=!1;else if("controlWord"==g[x].type&&"columns"==g[x].value)y=!0;else if("text"==g[x].type&&y)h.columns=
parseInt(g[x].value),y=!1;else if("controlWord"==g[x].type&&"expr"==g[x].value)F=!1,u=!0;else if("controlWord"==g[x].type&&"decimals"==g[x].value)w=!0;else if("text"==g[x].type&&w)s.decimals=this.evaluator.parser.parse(parseInt(g[x].value)+""),w=!1;else if("controlWord"==g[x].type&&"fixed1"==g[x].value)s.fixed=!0;else if("controlWord"==g[x].type&&"fixed0"==g[x].value)s.fixed=!1;else if(!("controlWord"==g[x].type&&"component"==g[x].value))if("controlWord"==g[x].type&&"NumCtrl"==g[x].value)H=!0;else if("controlWord"==
g[x].type&&"Space"==g[x].value)P=!0;else if("controlWord"==g[x].type&&"hyperlink"==g[x].value)O=!0;else if("text"==g[x].type&&O){textContent=g[x].value.split("|")[0];G=z.clone();p=new a.RTFNode(this.evaluator,textContent,"hyperlink",G);if("textLineBlock"!=m.nodeType)for(m=m.parent;"textLineBlock"!=m.nodeType;)m=m.parent;m.addChild(p);O=!1}else if("text"==g[x].type&&H)p=new a.RTFNode(this.evaluator,g[x].value,"componentNumCtrl",z.clone()),m.addChild(p),H=!1;else if("text"==g[x].type&&P)p=new a.RTFNode(this.evaluator,
g[x].value,"componentSpace",z.clone()),m.addChild(p),P=!1;else if("text"==g[x].type&&u)G=A[A.length-2].style.clone(),textContent=this.evaluator.parser.parse(g[x].value),p=new a.RTFNode(this.evaluator,textContent,"dynamicText",G),A[A.length-2].addChild(p),s=A[A.length-1]=p,u=!1;else if("text"==g[x].type&&!u&&!q){textContent=g[x].value;p=new a.RTFNode(this.evaluator,textContent,"text",z.clone());if("textLineBlock"!=m.nodeType)for(m=m.parent;"textLineBlock"!=m.nodeType;)m=m.parent;m.addChild(p)}else if("text"==
g[x].type&&!u&&q)textContent=g[x].value,p=new a.RTFNode(this.evaluator,textContent,"text",A[A.length-1].style.clone()),A[A.length-1].addChild(p);else if("("==g[x].type||")"==g[x].type)G=A[A.length-1].style.clone(),G.textItalic="",p=new a.RTFNode(this.evaluator,g[x].type,"mathSymbol",G),A[A.length-1].addChild(p);else if("+"==g[x].type||"-"==g[x].type||"*"==g[x].type||"="==g[x].type)p=new a.RTFNode(this.evaluator,g[x].type,"mathSymbol",A[A.length-1].style.clone()),A[A.length-1].addChild(p);if(null!=
m){var U=m.getRoot();U.stableWidth=F;U.getTextMetrics();U.hasFormula=I}return U};a.FontStyle=function(a,c,d,e,f,g,h){this.fontSize=a;this.fontType=c;this.textItalic=d;this.textBold=e;this.textUnderline=f;this.textOverline=g;this.textColor=h};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 g,n,k,c,e,f,l,d,t,p,m,s,h,v,q;a.Space=function(c,d){this.parent=c;n=this.evaluator=this.parent.evaluator;k=n.parser;this.values=d;this.type="R2";this.xExpr=k.parse("0");this.yExpr=k.parse("0");
this.w=parseInt(c.container.width);this.h=parseInt(c.container.height);this.drawif=k.parse("1");this.fixed=2!=c.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"===c.code||c.arquimedes?new a.Color("f0f8fa"):new a.Color("ffffff");this.net=2!=c.version?new a.Color("c0c0c0"):"";this.net10=2!=c.version?new a.Color("808080"):"";this.axes=
2!=c.version?new a.Color("808080"):"";this.text=new a.Color("ffafaf");this.numbers=!1;this.x_axis=2!=c.version?"":" ";this.y_axis=2!=c.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=c.zIndex;this.plecaHeight=c.plecaHeight||0;this.displaceRegionNorth=c.displaceRegionNorth||0;this.displaceRegionWest=c.displaceRegionWest||0;for(var e in d)d.hasOwnProperty(e)&&(this[e]=
d[e]);this.init()};a.Space.prototype.init=function(){g=this.parent;n=this.evaluator;c=this.id;this.displaceRegionNorth=g.displaceRegionNorth||0;this.displaceRegionWest=g.displaceRegionWest||0;l=parseInt(g.container.height);d=parseInt(g.container.width);n.setVariable(c+"._w",this.w);n.setVariable(c+"._h",this.h);this.x=n.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=n.evalExpression(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+
"px",this.container.style.top=this.y+"px");0<=this.y?(e=l-this.y,this.h>e&&(this.h=e)):(e=this.h+this.y,this.h=e>=l?l:e);0<=this.x?(f=d-this.x,this.w>f&&(this.w=f)):(f=this.w+this.x,this.w=f>=d?d:f);if(""!=this.imageSrc||!this.imageSrc.trim().toLowerCase().match(/vacio.gif$/))this.image=g.getImage(this.imageSrc);this.OxExpr&&(p=this.OxExpr,"%"===p[p.length-1]?this.Ox=this.w*parseFloat(p)/100:(t=parseFloat(p),t!=p&&(t=0),this.Ox=t));this.OyExpr&&(m=this.OyExpr,"%"===m[m.length-1]?this.Oy=this.h*parseFloat(m)/
100:(t=parseFloat(m),t!=m&&(t=0),this.Oy=t));2!==g.version?(n.setVariable(c+"._w",this.w),n.setVariable(c+"._h",this.h),n.setVariable(c+".escala",this.scale),n.setVariable(c+".Ox",this.Ox),n.setVariable(c+".Oy",this.Oy),n.setVariable(c+".mouse_x",0),n.setVariable(c+".mouse_y",0),n.setVariable(c+".mouse_pressed",0)):(t=n.getVariable("_w"),void 0===t&&(t=this.w),n.setVariable("_w",t),t=n.getVariable("_h"),void 0===t&&(t=this.h),n.setVariable("_h",t),t=n.getVariable("escala"),void 0===t&&(t=this.scale),
n.setVariable("escala",t),t=n.getVariable("Ox"),void 0===t&&(t=this.Ox),n.setVariable("Ox",t),t=n.getVariable("Oy"),void 0===t&&(t=this.Oy),n.setVariable("Oy",t),n.setVariable("mouse_x",0),n.setVariable("mouse_y",0),n.setVariable("mouse_pressed",0),""===this.x_axis&&""===this.y_axis&&(this.axes=""));this.w_2=this.w/2;this.h_2=this.h/2};a.Space.prototype.addCtr=function(a){"graphic"===a.type?this.graphicsCtr.push(a):this.ctrs.push(a)};a.Space.prototype.addGraph=function(a){a.background&&"R3"!==this.type?
this.backgroundGraphics.push(a):this.graphics.push(a)};a.Space.prototype.getRelativeX=function(a){return(a-this.w_2-this.Ox)/this.scale};a.Space.prototype.getRelativeY=function(a){return(-a+this.h_2+this.Oy)/this.scale};a.Space.prototype.getAbsoluteX=function(a){return a*this.scale+this.w_2+this.Ox};a.Space.prototype.getAbsoluteY=function(a){return-a*this.scale+this.h_2+this.Oy};a.Space.prototype.findOffset=function(){s=this.container;this.offsetTop=this.offsetLeft=0;h=this.container.style.display;
for(this.container.style.display="block";s;){v=null;s.getAttribute&&(v=s.getAttribute("class"));if(v&&("DescartesSpace2DContainer"===v||"DescartesSpace3DContainer"===v||"DescartesAppContainer"===v))this.offsetLeft+=s.offsetLeft||0,this.offsetTop+=s.offsetTop||0;s=s.parentNode}this.container.style.display=h};a.Space.prototype.getCursorPosition=function(c){q=a.getCursorPosition(c);return{x:q.x-this.offsetLeft,y:q.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){var g,n;if(a.loadLib)return a;
var k=Math.floor,c=Math.round,e=2*Math.PI,f=a.convertFont("SansSerif,PLAIN,12"),l=a.convertFont("Monospaced,PLAIN,12"),d,t,p,m,s,h,v,q,u,w,r,y,B,D,z,F,E,C,A,I,H,P,O,x,J,G,K,L,M;a.Space2D=function(c,e){a.Space.call(this,c,e);d=this;d.backgroundCanvas=document.createElement("canvas");d.backgroundCanvas.setAttribute("id",d.id+"_background");d.backgroundCanvas.setAttribute("width",d.w+"px");d.backgroundCanvas.setAttribute("height",d.h+"px");d.backgroundCtx=d.backgroundCanvas.getContext("2d");d.backgroundCtx.imageSmoothingEnabled=
!1;d.backgroundCtx.mozImageSmoothingEnabled=!1;d.backgroundCtx.webkitImageSmoothingEnabled=!1;d.canvas=document.createElement("canvas");d.canvas.setAttribute("id",d.id+"_canvas");d.canvas.setAttribute("width",d.w+"px");d.canvas.setAttribute("height",d.h+"px");d.canvas.setAttribute("class","DescartesSpace2DCanvas");d.canvas.setAttribute("style","z-index: "+d.zIndex+";");d.ctx=d.canvas.getContext("2d");d.ctx.imageSmoothingEnabled=!1;d.ctx.mozImageSmoothingEnabled=!1;d.ctx.webkitImageSmoothingEnabled=
!1;d.graphicControlContainer=document.createElement("div");d.graphicControlContainer.setAttribute("id",d.id+"_graphicControls");d.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+d.zIndex+";");d.numericalControlContainer=document.createElement("div");d.numericalControlContainer.setAttribute("id",d.id+"_numericalControls");d.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+d.zIndex+";");d.container=
document.createElement("div");d.container.setAttribute("id",d.id);d.container.setAttribute("class","DescartesSpace2DContainer");d.container.setAttribute("style","left: "+d.x+"px; top: "+d.y+"px; z-index: "+d.zIndex+";");d.parent.arquimedes&&"#f0f8fa"===d.background.getColor()&&(d.container.style.border="1px solid #b8c4c8");d.container.appendChild(d.backgroundCanvas);d.container.appendChild(d.canvas);d.container.appendChild(d.graphicControlContainer);d.container.appendChild(d.numericalControlContainer);
c.container.insertBefore(d.container,c.loader);d.parent.images[d.id+".image"]=d.canvas;d.parent.images[d.id+".image"].ready=1;d.parent.images[d.id+".image"].complete=!0;d.evaluator.setVariable(d.id+".image",d.id+".image");d.parent.images[d.id+".back"]=d.backgroundCanvas;d.parent.images[d.id+".back"].ready=1;d.parent.images[d.id+".back"].complete=!0;d.evaluator.setVariable(d.id+".back",d.id+".back");d.OxString=2!==c.version?d.id+".Ox":"Ox";d.OyString=2!==c.version?d.id+".Oy":"Oy";d.scaleString=2!==
c.version?d.id+".escala":"escala";d.wString=d.id+"._w";d.hString=d.id+"._h";"descartesJS_scenario"!==d.id&&d.registerMouseAndTouchEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){d=this;d.uber.init.call(d);d.canvas&&(d.backgroundCanvas.setAttribute("width",d.w+"px"),d.backgroundCanvas.setAttribute("height",d.h+"px"),d.canvas.setAttribute("width",d.w+"px"),d.canvas.setAttribute("height",d.h+"px"));d.container&&d.findOffset()};a.Space2D.prototype.update=function(a){d=this;t=
d.evaluator;p=d.parent;t.setVariable(d.wString,d.w);t.setVariable(d.hString,d.h);d.drawIfValue=0<t.evalExpression(d.drawif);if(d.drawIfValue){s=d.x!==t.evalExpression(d.xExpr)+d.displaceRegionWest;h=d.y!==t.evalExpression(d.yExpr)+p.plecaHeight+d.displaceRegionNorth;d.spaceChange=a||s||h||d.drawBefore!==d.drawIfValue||d.Ox!==t.getVariable(d.OxString)||d.Oy!==t.getVariable(d.OyString)||d.scale!==t.getVariable(d.scaleString);d.x=s?t.evalExpression(d.xExpr)+d.displaceRegionWest:d.x;d.y=h?t.evalExpression(d.yExpr)+
p.plecaHeight+d.displaceRegionNorth:d.y;d.Ox=t.getVariable(d.OxString);d.Oy=t.getVariable(d.OyString);d.scale=t.getVariable(d.scaleString);d.drawBefore=d.drawIfValue;1E-6>d.scale?(d.scale=1E-6,t.setVariable(d.scaleString,1E-6)):1E6<d.scale&&(d.scale=1E6,t.setVariable(d.scaleString,1E6));if(s||h)d.container.style.left=d.x+"px",d.container.style.top=d.y+"px",d.findOffset();d.container.style.display="block";d.drawTrace=!d.spaceChange&&!d.click;d.spaceChange&&d.drawBackground();d.draw()}else d.container.style.display=
"none"};a.Space2D.prototype.drawBackground=function(){t=this.evaluator;m=this.backgroundCtx;m.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);m.fillStyle=this.background.getColor();m.fillRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?m.drawImage(this.image,0,0):"stretch"===this.bg_display?m.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?
(m.fillStyle=m.createPattern(this.image,"repeat"),m.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&m.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));q=this.scale;u=0;for(w=0>this.w+this.h?0:this.w+this.h;q>w;)q/=10,u++;for(;q<w/10;)q*=10;m.lineWidth=1;""!==this.net&&(m.strokeStyle=this.net.getColor(),this.drawMarks(m,q/10,-1));if(2!==this.parent.version&&""!==this.net10||2===this.parent.version&&""!==this.net&&""!==this.net10)m.strokeStyle=
this.net10.getColor(),this.drawMarks(m,q,-1);if(""!==this.axes){m.strokeStyle=this.axes.getColor();m.beginPath();if(""!==this.x_axis||2!==this.parent.version)m.moveTo(0,k(this.h/2+this.Oy)+0.5),m.lineTo(this.w,k(this.h/2+this.Oy)+0.5);if(""!==this.y_axis||2!==this.parent.version)m.moveTo(k(this.w/2+this.Ox)+0.5,0),m.lineTo(k(this.w/2+this.Ox)+0.5,this.h);m.stroke();this.drawMarks(m,q,4);this.drawMarks(m,q/2,2);this.drawMarks(m,q/10,1)}if(""!==this.x_axis||""!==this.y_axis)m.fillStyle=this.axes.getColor(),
m.font=f,m.textAlign="right",m.textBaseline="alphabetic",m.fillText(this.x_axis,k(this.w)-2,k(this.h/2+this.Oy)+12),m.fillText(this.y_axis,k(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(m.fillStyle=this.axes.getColor(),m.font=f,m.textAlign="start",m.textBaseline="bottom",q>(this.w+this.h)/2?this.drawNumbers(m,q/5,q<=this.scale?u+1:u):q>(this.w+this.h)/4?this.drawNumbers(m,q/2,q<=this.scale?u+1:u):this.drawNumbers(m,q,u));for(var a=0,c=this.backgroundGraphics.length;a<c;a++)this.backgroundGraphics[a].draw()};
a.Space2D.prototype.draw=function(){m=this.ctx;m.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=0,c=this.graphics.length;a<c;a++)v=this.graphics[a],""!==v.trace&&this.drawTrace&&v.drawTrace(),v.draw();a=0;for(c=this.graphicsCtr.length;a<c;a++)this.graphicsCtr[a].draw();""!=this.text&&(this.click&&"L"===this.whichButton)&&(console.log("aqui"),m.fillStyle=this.text.getColor(),m.strokeStyle=m.fillStyle,m.lineWidth=1,m.font=l,m.textAlign="center",m.textBaseline="alphabetic",H=1>=this.scale?
this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length),P=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),O="("+H+","+P+")",x=k(m.measureText(O).width/2),J=this.getAbsoluteX(this.mouse_x),G=this.getAbsoluteY(this.mouse_y),K=k(J),L=k(G-10),K+x>this.w?K=this.w-x:0>K-x&&(K=x),L+1>this.h?L=this.h:0>L-14&&(L=15),m.fillText(O,K,L),m.beginPath(),m.arc(J,G,2.5,0,e,!0),m.stroke())};a.Space2D.prototype.drawMarks=function(a,d,e){r=this.w;y=this.h;E=
0;C=r;A=0;I=y;z=k(r/2+this.Ox);F=k(y/2+this.Oy);0<=e&&(E=z-e,C=z+e,A=F-e,I=F+e);a.beginPath();for(e=-c(z/d);(B=z+c(e*d))<r;e++)a.moveTo(B+0.5,A+0.5),a.lineTo(B+0.5,I+0.5);for(e=-c(F/d);(D=F+c(e*d))<y;e++)a.moveTo(E+0.5,D+0.5),a.lineTo(C+0.5,D+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,d,e){r=this.w;y=this.h;z=k(r/2+this.Ox);F=k(y/2+this.Oy);for(e=-c(z/d);(B=z+c(e*d))<r;e++)a.fillText(parseFloat((e*d/this.scale).toFixed(4)),B+1,F-2);for(e=-c(F/d);(D=F+c(e*d))<y;e++)0!==parseFloat(-e*
d/this.scale)&&a.fillText(parseFloat((-e*d/this.scale).toFixed(4)),z+5,D+5)};a.Space2D.prototype.registerMouseAndTouchEvents=function(){function c(a){m.click=1;m.evaluator.setVariable(m.id+".mouse_pressed",1);m.parent.deactivateGraphiControls();h(a);window.addEventListener("touchmove",p);window.addEventListener("touchend",d);a.preventDefault()}function d(a){m.click=0;m.evaluator.setVariable(m.id+".mouse_pressed",0);window.removeEventListener("touchmove",p,!1);window.removeEventListener("touchend",
d,!1);a.preventDefault();m.parent.update()}function e(c){m.click=1;m.evaluator.setVariable(m.id+".mouse_pressed",1);m.parent.deactivateGraphiControls();m.whichButton=a.whichButton(c);"R"===m.whichButton&&(window.addEventListener("mouseup",f),m.fixed||(m.clickPosForZoom=m.getCursorPosition(c).y,m.tempScale=m.scale,window.addEventListener("mousemove",l)));"L"===m.whichButton&&(m.evaluator.setVariable(m.id+".mouse_pressed",1),h(c),window.addEventListener("mousemove",p),window.addEventListener("mouseup",
f));c.preventDefault()}function f(a){m.click=0;m.evaluator.setVariable(m.id+".mouse_pressed",0);a.preventDefault();"R"===m.whichButton&&window.removeEventListener("mousemove",l,!1);m.sensitive_to_mouse_movements||window.removeEventListener("mousemove",p,!1);window.removeEventListener("mouseup",f,!1);m.parent.update()}function h(a){m.posAnte=m.getCursorPosition(a);m.mouse_x=m.getRelativeX(m.posAnte.x);m.mouse_y=m.getRelativeY(m.posAnte.y);m.evaluator.setVariable(m.id+".mouse_x",m.mouse_x);m.evaluator.setVariable(m.id+
".mouse_y",m.mouse_y);m.parent.update()}function l(a){a.preventDefault();m.clickPosForZoomNew=m.getCursorPosition(a).y;m.evaluator.setVariable(m.scaleString,m.tempScale+m.tempScale/45*((m.clickPosForZoom-m.clickPosForZoomNew)/10));m.parent.update()}function p(a){m.fixed||(m.posNext=m.getCursorPosition(a),g=k(m.posAnte.x-m.posNext.x),n=k(m.posAnte.y-m.posNext.y),m.evaluator.setVariable(m.OxString,m.Ox-g),m.evaluator.setVariable(m.OyString,m.Oy-n),m.posAnte.x-=g,m.posAnte.y-=n);h(a);a.preventDefault()}
var m=this;M=a.hasTouchSupport;m.canvas.oncontextmenu=function(){return!1};M&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",h),this.canvas.addEventListener("touchstart",c));M||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",h),this.canvas.addEventListener("mousedown",e))};return a}(descartesJS||{}),descartesJS=function(a){var g,n,k;function c(a,c){return c.depth-a.depth}if(a.loadLib)return a;var e=Math.round,f=Math.max,l=Math.cos,d=Math.sin,
t=Math.sqrt,p=15*Math.PI/180,m,s,h,v,q,u,w,r,y,B,D,z,F,E,C,A,I,H;a.Space3D=function(c,d){a.Space.call(this,c,d);h=this;h.backgroundCanvas=document.createElement("canvas");h.backgroundCanvas.setAttribute("id",h.id+"_background");h.backgroundCanvas.setAttribute("width",h.w+"px");h.backgroundCanvas.setAttribute("height",h.h+"px");h.canvas=document.createElement("canvas");h.canvas.setAttribute("id",h.id+"_canvas");h.canvas.setAttribute("width",h.w+"px");h.canvas.setAttribute("height",h.h+"px");h.canvas.setAttribute("class",
"DescartesSpace3DCanvas");h.canvas.setAttribute("style","z-index: "+h.zIndex+";");h.ctx=h.canvas.getContext("2d");h.ctx.imageSmoothingEnabled=!1;h.ctx.mozImageSmoothingEnabled=!1;h.ctx.webkitImageSmoothingEnabled=!1;h.graphicControlContainer=document.createElement("div");h.graphicControlContainer.setAttribute("id",h.id+"_graphicControls");h.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+h.zIndex+";");h.numericalControlContainer=document.createElement("div");
h.numericalControlContainer.setAttribute("id",h.id+"_numericalControls");h.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+h.zIndex+";");h.container=document.createElement("div");h.container.setAttribute("id",h.id);h.container.setAttribute("class","DescartesSpace3DContainer");h.container.setAttribute("style","left: "+h.x+"px; top: "+h.y+"px; z-index: "+h.zIndex+";");h.container.appendChild(h.backgroundCanvas);h.container.appendChild(h.canvas);h.container.appendChild(h.graphicControlContainer);
h.container.appendChild(h.numericalControlContainer);c.container.insertBefore(h.container,c.loader);h.eye={x:0,y:0,z:0};h.OxStr=h.id+".Ox";h.OyStr=h.id+".Oy";h.scaleStr=h.id+".escala";h.wStr=h.id+"._w";h.hStr=h.id+"._h";h.obsStr=h.id+".observador";h.rotZStr=h.id+".rot.z";h.rotYStr=h.id+".rot.y";h.evaluator.setVariable(h.rotZStr,0);h.evaluator.setVariable(h.rotYStr,0);h.registerMouseAndTouchEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(a){h=this;h.uber.init.call(h);h.canvas&&
(h.canvas.setAttribute("width",h.w+"px"),h.canvas.setAttribute("height",h.h+"px"));h.container&&h.findOffset();h.w_2=h.w/2;h.h_2=h.h/2;h.oldMouse={x:0,y:0};a&&0===h.evaluator.getVariable(h.obsStr)&&(h.observerSet=!0)};a.Space3D.prototype.update=function(a){h=this;m=h.evaluator;s=h.parent;m.setVariable(h.wStr,h.w);m.setVariable(h.hStr,h.h);h.drawIfValue=0<m.evalExpression(h.drawif);if(h.drawIfValue){r=h.x!==m.evalExpression(h.xExpr)+h.displaceRegionWest;y=h.y!==m.evalExpression(h.yExpr)+s.plecaHeight+
h.displaceRegionNorth;h.spaceChange=a||r||y||h.drawBefore!==h.drawIfValue||h.Ox!==m.getVariable(h.OxStr)||h.Oy!==m.getVariable(h.OyStr)||h.scale!==m.getVariable(h.scaleStr);h.x=r?m.evalExpression(h.xExpr)+h.displaceRegionWest:h.x;h.y=y?m.evalExpression(h.yExpr)+s.plecaHeight+h.displaceRegionNorth:h.y;h.Ox=m.getVariable(h.OxStr);h.Oy=m.getVariable(h.OyStr);h.scale=m.getVariable(h.scaleStr);h.drawBefore=h.drawIfValue;a&&(h.observer=h.observerSet?0.5*(h.w+h.h):2.5*(h.w+h.h),h.observer=f(h.observer,0.1*
(h.w+h.h)),h.evaluator.setVariable(h.obsStr,h.observer),h.eye={x:h.observer/h.scale*l(p),y:0,z:h.observer/h.scale*d(p)},h.D=h.scale*h.eye.x/l(p),h.XE=e(h.scale*h.eye.y+0.5),h.YE=e(h.scale*h.eye.z+0.5));h.observer=f(m.getVariable(h.obsStr),0.1*(h.w+h.h));m.setVariable(h.obsStr,h.observer);1E-6>h.scale?(h.scale=1E-6,m.setVariable(h.scaleStr,1E-6)):1E6<h.scale&&(h.scale=1E6,m.setVariable(h.scaleStr,1E6));if(r||y)h.container.style.left=h.x+"px",h.container.style.top=h.y+"px",h.findOffset();h.container.style.display=
"block";h.parent.updateControls();h.updateCamera();h.draw()}else h.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));if(!this.click){this.primitives=[];for(var a=0,d=this.graphics.length;a<d;a++)v=this.graphics[a],v.update()}q=this.primitives;u=q.length;for(a=0;a<u;a++)q[a].computeDepth(this);q=q.sort(c);for(a=0;a<u;a++)q[a].draw(this.ctx);
a=0;for(d=this.graphicsCtr.length;a<d;a++)this.graphicsCtr[a].draw()};a.Space3D.prototype.addPrimitive=function(c){this.primitives.push(new a.Primitive3D(c))};a.Space3D.prototype.updateCamera=function(){h=this;h.D=h.observer;h.eye.x=h.D/h.scale;h.eye.y=h.XE/h.scale;h.eye.z=h.YE/h.scale};a.Space3D.prototype.rotateVertex=function(c){A=a.degToRad(h.evaluator.getVariable(h.rotZStr));I=l(A);H=d(A);g=c.x*I-c.y*H;n=c.x*H+c.y*I;k=c.z;A=a.degToRad(h.evaluator.getVariable(h.rotYStr));I=l(A);H=d(A);return{x:k*
H+g*I,y:n,z:k*I-g*H}};a.Space3D.prototype.project=function(a){h=this;z=h.eye.x-a.x;F=h.eye.y-a.y;E=h.eye.z-a.z;C=-a.x/t(z*z+F*F+E*E)||0;z=h.scale*(a.y+C*(h.eye.y-a.y));F=-h.scale*(a.z+C*(h.eye.z-a.z));return{x:parseInt(z+this.w_2+this.Ox),y:parseInt(F+this.h_2+this.Oy),z:C}};a.Space3D.prototype.registerMouseAndTouchEvents=function(){function c(a){h.click=1;h.evaluator.setVariable(h.id+".mouse_pressed",1);h.parent.deactivateGraphiControls();h.posAnte=h.getCursorPosition(a);h.oldMouse.x=h.getRelativeX(h.posAnte.x);
h.oldMouse.y=h.getRelativeY(h.posAnte.y);k(a);window.addEventListener("touchmove",m);window.addEventListener("touchend",d);a.preventDefault()}function d(a){h.click=0;h.evaluator.setVariable(h.id+".mouse_pressed",0);window.removeEventListener("touchmove",m,!1);window.removeEventListener("touchend",d,!1);a.preventDefault()}function f(c){h.click=1;h.parent.deactivateGraphiControls();h.whichButton=a.whichButton(c);"R"===h.whichButton?(window.addEventListener("mouseup",g),h.fixed||(h.clickPosForZoom=h.getCursorPosition(c).y,
h.tempScale=h.scale,window.addEventListener("mousemove",l))):"L"==h.whichButton&&(h.evaluator.setVariable(h.id+".mouse_pressed",1),h.posAnte=h.getCursorPosition(c),h.oldMouse.x=h.getRelativeX(h.posAnte.x),h.oldMouse.y=h.getRelativeY(h.posAnte.y),k(c),window.addEventListener("mousemove",m),window.addEventListener("mouseup",g));c.preventDefault()}function g(a){h.click=0;h.evaluator.setVariable(h.id+".mouse_pressed",0);a.preventDefault();"R"===h.whichButton&&window.removeEventListener("mousemove",l,
!1);window.removeEventListener("mousemove",m,!1);window.removeEventListener("mouseup",g,!1)}function k(a){h.posAnte=h.getCursorPosition(a);h.mouse_x=h.getRelativeX(h.posAnte.x);h.mouse_y=h.getRelativeY(h.posAnte.y);h.evaluator.setVariable(h.id+".mouse_x",h.mouse_x);h.evaluator.setVariable(h.id+".mouse_y",h.mouse_y);h.parent.update()}function l(a){a.preventDefault();h.clickPosForZoomNew=h.getCursorPosition(a).y;h.evaluator.setVariable(h.scaleStr,h.tempScale+h.tempScale/45*((h.clickPosForZoom-h.clickPosForZoomNew)/
10));h.parent.update()}function m(c){if(!h.fixed&&h.click){B=parseInt(50*(h.oldMouse.x-h.mouse_x));D=parseInt(50*(h.oldMouse.y-h.mouse_y));if(B!==h.disp.x||D!==h.disp.y)h.alpha=a.degToRad(h.evaluator.getVariable(h.rotZStr)),h.beta=a.degToRad(-h.evaluator.getVariable(h.rotYStr)),h.alpha=e(a.radToDeg(h.alpha)-B),h.beta=e(a.radToDeg(h.beta)-D),h.evaluator.setVariable(h.rotZStr,h.alpha),h.evaluator.setVariable(h.rotYStr,-h.beta),h.disp.x=B,h.disp.y=D,h.oldMouse.x=h.getRelativeX(h.posAnte.x),h.oldMouse.y=
h.getRelativeY(h.posAnte.y);k(c);c.preventDefault()}}h=this;w=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};w&&this.canvas.addEventListener("touchstart",c);w||this.canvas.addEventListener("mousedown",f);this.disp={x:0,y:0}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var g;a.SpaceAP=function(n,k){a.Space.call(this,n,k);this.exportarVars=this.importarVars=null;g=n.evaluator;this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=g.parser.parse(this.file.substring(1,
this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=g.parser.parse(this.file):this.file=g.parser.parse("'"+this.file+"'");this.oldFile=g.evalExpression(this.file);this.initFile()};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var g;if(this.oldFile){var k=document.getElementById(this.oldFile);g=k&&"descartes/spaceApFile"==k.type?k.text:a.openExternalFile(this.oldFile);null!=g&&(g=g.split("\n"))}if(g&&g.toString().match(/<applet/gi)){for(var k=
"",c=!1,e=0,f=g.length;e<f&&!(g[e].match("<applet")&&(c=!0),c&&(k+=g[e]),g[e].match("</applet"));e++);e=document.createElement("div");e.innerHTML=k;e.firstChild.setAttribute("width",this.w);e.firstChild.setAttribute("height",this.h);k=this.descApp?this.descApp.container:null;this.descApp=new a.DescartesApp(e.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+";");k?this.parent.container.replaceChild(this.descApp.container,k):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);k=this.descApp.spaces;e=0;for(f=k.length;e<f;e++)k[e].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var l=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();
this.updateControls();this.updateSpaces();l.exportar()}}else k=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),e="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?e+="background-image: url("+this.imageSrc+
"); background-repeat:no-repeat;":"stretch"==this.bg_display?e+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?e+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(e+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",e),k?this.parent.container.replaceChild(this.descApp.container,k):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,c=a.length;g<c;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 e in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(e)&&e.match(/^public./)&&this.importarVars.push({varName:e,
value:this.evaluator.getVariable(e)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,g=!1,c=0,e=this.importarVars.length;c<e;c++)a=this.evaluator.getVariable(this.importarVars[c].varName),a!=this.importarVars[c].value&&(this.importarVars[c].value=a,this.descApp.evaluator.setVariable(this.importarVars[c].varName,this.importarVars[c].value),g=!0);g&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var g,n,k,c;a.SpaceHTML_IFrame=function(c,f){a.Space.call(this,c,f);var g=this.parent.evaluator;window.navigator.userAgent.toLowerCase().match(/firefox/);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=g.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=g.parser.parse(this.file):this.file=g.parser.parse("'"+this.file+"'");this.oldFile=g.evalExpression(this.file);this.MyIFrame=document.createElement("iframe");
this.MyIFrame.setAttribute("src",this.oldFile);this.MyIFrame.setAttribute("id",this.id);this.MyIFrame.setAttribute("marginheight",0);this.MyIFrame.setAttribute("marginwidth",0);this.MyIFrame.setAttribute("frameborder",0);this.MyIFrame.setAttribute("scrolling","auto");this.MyIFrame.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px;");this.parent.container.insertBefore(this.MyIFrame,this.parent.loader);var d=this;this.MyIFrame.onload=
function(a){var c=this;d.evaluator.setFunction(d.id+".set",function(a,d){c.contentWindow.postMessage({type:"set",name:a,value:d},"*")});d.evaluator.setFunction(d.id+".update",function(){c.contentWindow.postMessage({type:"update"},"*")});d.evaluator.setFunction(d.id+".exec",function(a,d){c.contentWindow.postMessage({type:"exec",name:a,value:d},"*")})};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){g=this.evaluator;this.drawIfValue=0<g.evalExpression(this.drawif);if(this.drawif){this.MyIFrame.style.display=this.drawIfValue?"block":"none";a&&(this.y=this.x=Math.Infinity);n=this.x!==g.evalExpression(this.xExpr)+this.displaceRegionWest;
k=this.y!==g.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=n?g.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=k?g.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(n||k)this.MyIFrame.style.left=this.x+"px",this.MyIFrame.style.top=this.y+"px";c=g.evalExpression(this.file);c!==this.oldFile&&(this.oldFile=c,this.MyIFrame.setAttribute("src",c));this.scrollVar=g.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 g;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 c=a.image_loader?a.image_loader:f(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("+c+"); 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 e=this;this.timer=setInterval(function(){e.drawLoaderBar(e.loaderBar.ctx,a.width,a.height)},10);a.firstRun=
!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var c=this.children,d=this.images,e=this.audios,f=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,g=/[\w-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g,k=/vector|array|bektore|vecteur|matriz/g,h=/archivo|file|fitxer|artxibo|fichier|arquivo/g;this.arquimedes&&(d["lib/DescartesCCLicense.png"]=a.getCreativeCommonsLicenseImage(),d["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=
1}),d["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=1}));var n,q,u,w,r,y;w=0;for(r=c.length;w<r;w++){if(n=c[w].value.match(f)){u=0;for(y=n.length;u<y;u++)q=n[u],!q.toLowerCase().match(/vacio.gif$/)&&""!=q.substring(0,q.length-4)&&(d[q]=new Image,d[q].addEventListener("load",function(){this.ready=1}),d[q].addEventListener("error",function(){this.errorload=1}),d[q].src=q)}if(n=c[w].value.match(g)){u=0;for(q=n.length;u<q;u++)this.initAudio(n[u])}(u=c[w].value.match(k)&&
c[w].value.match(h))&&this.lessonParser.parseAuxiliar(c[w].value)}for(var B in d)d.hasOwnProperty(B)&&this.images.length++;for(B in e)e.hasOwnProperty(B)&&this.audios.length++;var D=this,z=this.images.length+this.audios.length,F=function(){D.readys=0;for(var a in d)d.hasOwnProperty(a)&&(d[a].ready||d[a].errorload)&&D.readys++;for(a in D.audios)e.hasOwnProperty(a)&&(e[a].ready||e[a].errorload)&&D.readys++;D.readys!=z?setTimeout(F,30):(clearTimeout(D.timer),D.descartesApp.initBuildApp())};F()};a.DescartesLoader.prototype.initAudio=
function(c){var d=this.audios;d[c]=new Audio(c);d[c].filename=c;var e=function(){this.ready=1},f=function(){!this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))&&"mp3"==this.filename.substring(this.filename.length-3)?(d[c]=new Audio(this.filename.replace("mp3","ogg")),d[c].filename=this.filename.replace("mp3","ogg"),d[c].addEventListener("canplaythrough",e),d[c].addEventListener("load",e),d[c].addEventListener("error",f),d[c].load()):(console.log("El archivo '"+c+"' no puede ser reproducido"),
this.errorload=1)};d[c].addEventListener("canplaythrough",e);d[c].addEventListener("load",e);d[c].addEventListener("error",f);a.hasTouchSupport?(d[c].load(),d[c].play(),d[c].ready=1):d[c].load()};var n,k,c,e;a.DescartesLoader.prototype.drawLoaderBar=function(a,d,f){n=this.barWidth;k=this.barHeight;c=this.images.length+this.audios.length;e=2*(n-2)/c;a.translate(d/2,(f-65*g)/2+90*g);a.scale(g,g);a.strokeRect(-n,-k,2*n,k);a.fillStyle="gray";a.fillRect(-n+2,-k+2,2*(n-2),k-4);a.fillStyle="#1f375d";a.fillRect(-n+
2,-k+2,this.readys*e,k-4);a.setTransform(1,0,0,1,0,0)};var f=function(a,c){var e=document.createElement("canvas");e.width=a;e.height=c;var f=e.getContext("2d");f.save();f.strokeStyle="#1f375d";f.fillStyle="#1f375d";f.lineCap="round";f.lineWidth=2;f.beginPath();g=a<c?a/360:c/195;g=2.5<g?2.5:g;f.translate((a-120*g)/2,(c-65*g)/2);f.scale(g,g);f.moveTo(3,25);f.lineTo(3,1);f.lineTo(21,1);f.bezierCurveTo(33,1,41,15,41,25);f.stroke();f.beginPath();f.moveTo(1,63);f.lineTo(1,64);f.moveTo(5,62);f.lineTo(5,
64);f.moveTo(9,61);f.lineTo(9,64);f.moveTo(13,60);f.lineTo(13,64);f.moveTo(17,58);f.lineTo(17,64);f.moveTo(21,56);f.lineTo(21,64);f.moveTo(25,53);f.lineTo(25,64);f.moveTo(29,50);f.lineTo(29,64);f.moveTo(33,46);f.lineTo(33,64);f.moveTo(37,41);f.lineTo(37,64);f.moveTo(41,32);f.lineTo(41,64);f.stroke();f.font="20px Arial, Helvetica, 'Droid Sans', Sans-serif";f.fillText("escartes",45,33);f.fillText("JS",98,64);f.restore();return e.toDataURL()};return a}(descartesJS||{}),descartesJS=function(a){function g(a){for(var c=
"[",e=0,f=a.length;e<f;e++){if(a[e]instanceof Array)c+=g(a[e]);else{n=a[e];if("undefined"==typeof n||!n)n=0;"string"==typeof n&&(n="'"+n+"'");c+=n}e<f-1&&(c+=",")}return c+"]"}if(a.loadLib)return a;a.DescartesApp=function(g){this.applet=g;this.parentContainer=g.parentNode;this.width=parseFloat(g.getAttribute("width"));this.height=parseFloat(g.getAttribute("height"));this.decimal_symbol=".";this.children=g.getElementsByTagName("param");this.code=g.getAttribute("code");this.saveState=[];this.images=
{};this.images.length=-1;this.audios={};this.audios.length=-1;this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.firstRun=!0;this.arquimedes=!!this.code.match("descinst.DescartesWeb2_0.class","i")||!!this.code.match("Arquimedes","i")||!!this.code.match("Discurso","i");this.licenseA="{\\rtf1\\uc0{\\fonttbl\\f0\\fcharset0 Arial;\\f1\\fcharset0 Arial;\\f2\\fcharset0 Arial;\\f3\\fcharset0 Arial;\\f4\\fcharset0 Arial;}{\\f0\\fs34 __________________________________________________________________________________ \\par \\fs22                                        Los contenidos de esta unidad did\u00e1ctica interactiva est\u00e1n bajo una  {\\*\\hyperlink licencia Creative Commons|http://creativecommons.org/licenses/by-nc-sa/2.5/es/}, si no se indica lo contrario.\\par                                        La unidad did\u00e1ctica fue creada con Arqu\u00edmedes, que es un producto de c\u00f3digo abierto del  {\\*\\hyperlink Ministerio de Educaci\u00f3n de Espa\u00f1a|http://recursostic.educacion.es/descartes/web/DescartesWeb2.0/} y\\par                                        el {\\*\\hyperlink Instituto de Matem\u00e1ticas|http://arquimedes.matem.unam.mx/} de la Universidad Nacional Aut\u00f3noma de M\u00e9xico, cedido bajo licencia {\\*\\hyperlink EUPL v 1.1|/resources/eupl_v1.1es.pdf}, con {\\*\\hyperlink c\u00f3digo en Java|http://recursostic.educacion.es/descartes/web/source/}.}";
g=this.children;for(var c,e=0,f=0,l=0,d=g.length;l<d;l++)c=g[l],"rtf_height"==c.name&&(e=parseInt(c.value)),"Buttons"==babel[c.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(c.value),f=this.buttonsConfig.height),"image_loader"==c.name&&(this.image_loader=c.value);this.arquimedes&&e&&(this.height=e+f+70);this.init()};a.DescartesApp.prototype.init=function(){this.spaces=[];this.externalSpace={container:document.createElement("div"),controls:[]};this.northSpace={container:document.createElement("div"),
controls:[]};this.southSpace={container:document.createElement("div"),controls:[]};this.eastSpace={container:document.createElement("div"),controls:[]};this.westSpace={container:document.createElement("div"),controls:[]};this.specialSpace={container:document.createElement("div"),controls:[]};this.editableRegion={container:document.createElement("div"),textFields:[]};this.controls=[];this.auxiliaries=[];this.events=[];this.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 a=this.children,c=this.lessonParser,e=[],f=[],g=[],d=[],n=[],p=[],m,s=0,h=a.length;s<h;s++)if(m=a[s],"pleca"==m.name)m=c.parsePleca(m.value,this.width),this.container.insertBefore(m,
this.loader),this.plecaHeight=m.imageHeight?m.imageHeight:m.offsetHeight;else if("Buttons"==babel[m.name])this.buttonsConfig=c.parseButtonsConfig(m.value);else if("decimal_symbol"==babel[m.name])this.decimal_symbol=m.value;else if("version"==babel[m.name])this.version=parseInt(m.value);else if("language"==babel[m.name])this.language=m.value;else if("rtf"==m.name){var v=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;d.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+
m.value.replace(/'/g,"&squot;")+"'");d.push("space='descartesJS_scenario' type='text' expresion='[10,"+(v-25)+"]' background='yes' text='"+this.licenseA+"'");d.push("space='descartesJS_scenario' type='image' expresion='[15,"+v+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==m.name.charAt(0)?(m.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,e.push(m.value)):"C"==m.name.charAt(0)&&"_"==m.name.charAt(1)?f.push(m.value):"A"==m.name.charAt(0)&&"_"==m.name.charAt(1)?
g.push(m.value):"G"==m.name.charAt(0)?d.push(m.value):"S"==m.name.charAt(0)?n.push(m.value):"Animation"==babel[m.name]&&p.push(m.value);this.scenarioRegion={container:document.createElement("div"),scroll:0};this.scenarioRegion.container.setAttribute("id","descartesJS_Scenario_Region");this.scenarioRegion.scenarioSpace=this.lessonParser.parseSpace("tipo='R2' id='descartesJS_scenario' fondo='blanco' x='0' y='0' fijo='yes' red='no' red10='no' ejes='no' text='no' ancho='"+this.width+"' alto='"+this.height+
"'");this.scenarioRegion.container.appendChild(this.scenarioRegion.scenarioSpace.container);this.arquimedes&&(this.container.appendChild(this.scenarioRegion.container),this.spaces.push(this.scenarioRegion.scenarioSpace));s=0;for(h=e.length;s<h;s++)a=c.parseSpace(e[s]),this.arquimedes&&this.scenarioRegion.container.appendChild(a.container),this.spaces.push(a),this.zIndex++;s=0;for(h=f.length;s<h;s++)this.controls.push(c.parseControl(f[s]));s=0;for(h=g.length;s<h;s++)c.parseAuxiliar(g[s]);s=0;for(h=
p.length;s<h;s++)this.animation=c.parseAnimation(p[s]);s=0;for(h=this.spaces.length;s<h;s++)this.spaces[s].init(!0);s=0;for(h=d.length;s<h;s++)if(e=c.parseGraphic(d[s]))e.visible&&(this.editableRegionVisible=!0),e.space.addGraph(e);s=0;for(h=n.length;s<h;s++)(e=c.parse3DGraphic(n[s]))&&e.space.addGraph(e);this.configRegions();this.updateAuxiliaries();s=0;for(h=this.controls.length;s<h;s++)this.controls[s].init();this.updateControls();this.updateSpaces(!0);var q=this;this.numberOfIframes?setTimeout(function(){q.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());a.externalEvaluator=new a.Evaluator};a.DescartesApp.prototype.configRegions=function(){var g=
this.evaluator.parser,c=this.buttonsConfig,e=this.container;if(2!=this.version)var f="15",l=100,d=100,n=100,p=100;else f="14",l=63,d=50,n=44,p=53;var m=0,s=0,h=0,v=h=0,q=0,u=0,w=0,r=0,u=this.northSpace.controls,y=this.southSpace.controls,B=this.eastSpace.controls,D=this.westSpace.controls;if(0<c.rowsNorth||0<u.length||c.about||c.config){0>=c.rowsNorth?(m=c.height,c.rowsNorth=1):m=c.height*c.rowsNorth;var z=this.northSpace.container;z.setAttribute("id","descartesJS_northRegion");z.setAttribute("style",
"width:"+e.width+"px; height:"+m+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");e.insertBefore(z,this.loader);var q=e.width,F=0;c.about&&(F=l,q-=F);c.config&&(q-=d);for(var z=Math.ceil(u.length/c.rowsNorth),E=q/z,h=0,C=u.length;h<C;h++)u[h].expresion=g.parse("("+(F+E*(h%z))+","+c.height*Math.floor(h/z)+","+E+","+c.height+")"),u[h].drawif=g.parse("1");if(c.about){var A;"espa\u00f1ol"==this.language?A="cr\u00e9ditos":"english"==this.language&&(A="about");(new a.Button(this,
{region:"north",name:A,font_size:g.parse(f),expresion:g.parse("(0, 0, "+l+", "+m+")")})).update()}c.config&&(A="config",(new a.Button(this,{region:"north",name:A,font_size:g.parse(f),action:"config",expresion:g.parse("("+(q+l)+", 0, "+d+", "+m+")")})).update())}if(0<c.rowsSouth||0<y.length||c.init||c.clear){0>=c.rowsSouth?(s=c.height,c.rowsSouth=1):s=c.height*c.rowsSouth;u=e.width;F=0;c.init&&(F=n,u-=F);c.clear&&(u-=p);z=this.southSpace.container;z.setAttribute("id","descartesJS_southRegion");z.setAttribute("style",
"width:"+e.width+"px; height:"+s+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(e.height-s)+"px; z-index:100;");e.insertBefore(z,this.loader);z=Math.ceil(y.length/c.rowsSouth);E=u/z;h=0;for(C=y.length;h<C;h++)y[h].expresion=g.parse("("+(F+E*(h%z))+","+c.height*Math.floor(h/z)+","+E+","+c.height+")"),y[h].drawif=g.parse("1");c.init&&("espa\u00f1ol"==this.language?A="inicio":"english"==this.language&&(A="init"),(new a.Button(this,{region:"south",name:A,font_size:g.parse(f),action:"init",
expresion:g.parse("(0, 0, "+n+", "+s+")")})).update());c.clear&&("espa\u00f1ol"==this.language?A="limpiar":"english"==this.language&&(A="clear"),(new a.Button(this,{region:"south",name:A,font_size:g.parse(f),action:"clear",expresion:g.parse("("+(u+n)+", 0, "+p+", "+s+")")})).update())}if(0<B.length){h=e.height-m-s;w=c.widthEast;z=this.eastSpace.container;z.setAttribute("id","descartesJS_eastRegion");z.setAttribute("style","width:"+w+"px; height:"+h+"px; background:#c0c0c0; position:absolute; left:"+
(e.width-w)+"px; top:"+m+"px; z-index:100;");e.insertBefore(z,this.loader);h=0;for(C=B.length;h<C;h++)B[h].expresion=g.parse("(0,"+c.height*h+","+w+","+c.height+")"),B[h].drawif=g.parse("1")}if(0<D.length){h=e.height-m-s;r=c.widthWest;z=this.westSpace.container;z.setAttribute("id","descartesJS_westRegion");z.setAttribute("style","width: "+r+"px; height: "+h+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+m+"px; z-index: 100;");e.insertBefore(z,this.loader);h=0;for(C=D.length;h<C;h++)D[h].expresion=
g.parse("(0,"+c.height*h+","+r+","+c.height+")"),D[h].drawif=g.parse("1")}if(this.editableRegionVisible){v=c.height;z=this.editableRegion.container;z.setAttribute("id","descartesJS_editableRegion");z.setAttribute("style","width:"+e.width+"px; height:"+v+"px; position:absolute; left:0px; top:"+(e.height-s-c.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;");e.insertBefore(z,this.loader);g=this.editableRegion.textFields;c=e.width/g.length;f=a.getFieldFontSize(v);h=0;for(C=g.length;h<C;h++)"div"==
g[h].type?(z.appendChild(g[h].container),g[h].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(c-4)+"px; height: "+v+"px; position: absolute; left: "+h*c+"px; top: 0px;"),l=g[h].container.firstChild,l.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+f+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+v+"px; text-align: center; line-height: "+v+"px;"),d=l.offsetWidth,
l.style.width=d+"px",l.firstChild.textContent=l.firstChild.textContent.substring(3,l.firstChild.textContent.length-3),g[h].container.lastChild.setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+f+"px; width:"+(c-d)+"px; height:"+v+"px; position:absolute; left:"+d+"px; top:0px; border:2px groove white;")):(z.appendChild(g[h]),g[h].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+f+"px; width:"+c+"px; height:"+
v+"px; position:absolute; left:"+h*c+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=m;this.displaceRegionWest=r;e.width-=w;e.height=e.height-s-v;h=0;for(C=this.spaces.length;h<C;h++)this.spaces[h].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,c=0,e=this.controls.length;c<e;c++)a=this.controls[c],"graphic"==a.type&&a.deactivate()};
a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,c=this.auxiliaries.length;a<c;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=function(){for(var a=0,c=this.events.length;a<c;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,c=this.controls.length;a<c;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var c=0,e=this.spaces.length;c<e;c++)this.spaces[c].update(a)};a.DescartesApp.prototype.clear=
function(){for(var a=0,c=this.spaces.length;a<c;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.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 c=this.images;if(a)return c[a]||(c[a]=new Image,c[a].addEventListener("load",function(){this.ready=1}),c[a].addEventListener("error",function(){this.errorload=1}),c[a].src=a),c[a]};a.DescartesApp.prototype.getAudio=function(a){var c=this.audios;if(a){if(!c[a]){var e=file.lastIndexOf("."),e=-1===e?file.lenght:e;file.substring(0,e);c[a]=new Audio(a);var f=function(a){this.ready=1};c[a].addEventListener("canplaythrough",
f);var g=function(d){!this.canPlayType("audio/"+a.substring(a.length-3))&&"mp3"==a.substring(a.length-3)?(c[a]=new Audio(a.replace("mp3","ogg")),c[a].addEventListener("canplaythrough",f),c[a].addEventListener("load",f),c[a].addEventListener("error",g),c[a].load()):(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1)};c[a].addEventListener("error",g);c[a].play();setTimeout(function(){c[a].pause()},15)}return c[a]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var c,
e=0,f=this.controls.length;e<f;e++)if(c=this.controls[e],c.cID==a)return c;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var c,e=0,f=this.controls.length;e<f;e++)if(c=this.controls[e],c.id==a)return c;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var c,e=0,f=this.spaces.length;e<f;e++)if(c=this.spaces[e],c.cID==a)return c;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var c,e=0,
f=this.spaces.length;e<f;e++)if(c=this.spaces[e],c.id==a)return c;return{update:function(){},w:0}};var n;a.DescartesApp.prototype.getState=function(){var a,c="",e=this.evaluator.variables,f;for(f in e)e.hasOwnProperty(f)&&(a=e[f],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=f&&"pi"!=f&&"e"!=f&&"Infinity"!=f&&"-Infinity"!=f&&"object"!=typeof a)&&(c=""!=c?c+"\n"+f+"="+a:f+"="+a));var e=this.evaluator.vectors,l;for(l in e)e.hasOwnProperty(l)&&(a=e[l],c=c+"\n"+l+"="+g(a));l=this.evaluator.matrices;
for(var d in l)l.hasOwnProperty(d)&&(a=l[d],c=c+"\n"+d+"="+g(a));return c};a.DescartesApp.prototype.setState=function(a){a=a.split("\n");for(var c,e,f=0,g=a.length;f<g;f++)c=a[f].split("="),2<=c.length&&(e=eval(c[1]),-1!=c[1].indexOf("[[")?(this.evaluator.matrices[c[0]]=e,this.evaluator.matrices[c[0]].rows=e.length,this.evaluator.matrices[c[0]].cols=e[0].length):-1!=c[1].indexOf("[")?(this.evaluator.vectors[c[0]]=e,this.evaluator.variables[c[0]+".long"]=e.length):this.evaluator.variables[c[0]]=e),
this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,c=0,e="",f=0,g=this.controls.length;f<g;f++)"textfield"==this.controls[f].gui&&this.controls[f].evaluate&&(a++,c+=this.controls[f].ok,this.controls[f].value=""==this.controls[f].value?"''":this.controls[f].value,e+=" \\n "+this.controls[f].id+"="+this.controls[f].value+"|"+this.controls[f].ok);return"questions="+a+" \\n correct="+c+" \\n wrong="+(a-c)+e};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,
c=0,e=a.length;c<e;c++)"textfield"==a[c].gui&&a[c].evaluate&&a[c].changeValue(a[c].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,c=this.saveState.length;a<c;a++)this.evaluator.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||{}),descartesJS=function(a){function g(){for(var c=document.getElementsByTagName("applet"),f=document.getElementsByTagName("ajs"),g,d=[],k=0,n=c.length;k<n;k++)g=c[k],(g.getAttribute("code").match("DescartesJS")||
g.getAttribute("code").match("descinst.DescartesWeb2_0.class")||g.getAttribute("code").match("Descartes")||g.getAttribute("code").match("Arquimedes")||g.getAttribute("code").match("Discurso"))&&d.push(g);k=0;for(n=f.length;k<n;k++)g=f[k],(g.getAttribute("code").match("DescartesJS")||g.getAttribute("code").match("descinst.DescartesWeb2_0.class")||g.getAttribute("code").match("Descartes")||g.getAttribute("code").match("Arquimedes")||g.getAttribute("code").match("Discurso"))&&d.push(g);c=0;for(f=d.length;c<
f;c++)a.apps.push(new a.DescartesApp(d[c])),d[c].className="DescartesJS"}function n(){var a=document.getElementById("StyleDescartesApps");a&&a.parentNode.removeChild(a);a=document.createElement("style");a.id="StyleDescartesApps";a.type="text/css";a.setAttribute("rel","stylesheet");a.innerHTML="applet.DescartesJS {display:none;} applet {display:none;}";document.head.appendChild(a)}function k(){for(var a=document.getElementsByTagName("*"),c=[],g=0,d=a.length;g<d;g++)"DescartesAppContainer"==a[g].className&&
c.push(a[g]);g=0;for(d=c.length;g<d;g++)c[g].parentNode.removeChild(c[g])}function c(c){a.getFeatures();a.hasCanvasSupport?(k(),g(),document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:none;}",window.addEventListener("resize",a.onResize),setTimeout(function(){window.scrollTo(0,1)},1)):document.getElementById("StyleDescartesApps").innerHTML="applet {display:block;}"}if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};(!window.hasOwnProperty("debugDescartesJS")||
!debugDescartesJS)&&n();a.onResize=function(c){for(var f=0,g=a.apps.length;f<g;f++){c=a.apps[f].spaces;for(var d=0,k=c.length;d<k;d++)c[d].findOffset()}};a.receiveMessage=function(c){if(0<a.apps.length&&(c=c.data))if("set"===c.type)a.apps[0].evaluator.setVariable(c.name,c.value);else if("update"===c.type)a.apps[0].update();else if("exec"===c.type){var f=a.apps[0].evaluator.getFunction(c.name),g=[];""!==c.value&&(g=c.value.toString().split(","));f&&f.apply(a.apps[0].evaluator,g)}};void 0==a.loadLib&&
(a.loadLib=!0,window.addEventListener("load",c),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||{});
