/*
 Joel Espinosa Longi
 joel.espinosa@amite.mx
 j.longi@gmail.com
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-05-27
*/
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 e(){var a,b,c,f,g,k,d,e;Number.prototype.originalToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(n){if(20>=n)return this.originalToFixed(n);
n=0>n?0:parseInt(n);a=this.toString();g=a.indexOf("e");b=a.indexOf(".");if(-1!==g)if(k=a.split("e"),d=k[0],e=parseInt(k[1]),0>b+e){var h=Math.abs(b+e);a="0."+Array(h+1).join("0")+d.replace(".","");b=1}else d=d.replace(".",""),a=d+Array(e-d.length+2).join("0"),b=-1;c="";if(-1===b)return 0<n&&(c="."),c+=Array(n+1).join("0"),a+c;f=a.length-b-1;if(f>=n)return 0<n?a.substring(0,b+1+n):a.substring(0,b);h=0;for(n-=f;h<n;h++)c+="0";return a+c}}function l(a,b,c){a.fillStyle="#c0c0c0";a.fillRect(b.offsetLeft,
b.offsetTop,b.offsetWidth,b.offsetHeight);h(a,b,c.controls)}function h(a,b,c){for(var f,g=c.length-1;0<=g;g--)f=c[g],a.drawImage(f.getScreenshot(),b.offsetLeft+f.x,b.offsetTop+f.y)}if(a.loadLib)return a;var b=2*Math.PI,d=360/b,c=b/360,k=Math.floor,f,r,n,m,q,p,t,g,v,u;a.rangeOK=1;a.extend=function(a,b){if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var c in b.prototype)b.prototype.hasOwnProperty(c)&&(a.prototype[c]=b.prototype[c]);a.prototype.uber=b.prototype};a.radToDeg=function(a){return a*
d};a.degToRad=function(a){return a*c};a.convertFont=function(a){if(""==a)return a;f=a.split(",");r="";"bold"==f[1].toLowerCase()?r+="Bold ":"italic"==f[1].toLowerCase()||"italics"==f[1].toLowerCase()?r+="Italic ":"bold+italic"==f[1].toLowerCase()&&(r+="Italic Bold ");r+=f[2]+"px ";n=f[0].split(" ")[0].toLowerCase();return r="serif"===n||"times new roman"===n||"timesroman"===n||"times"===n?r+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===n||"arial"===n||"helvetica"===n?r+"Arial, Helvetica, 'Droid Sans', Sans-serif":
r+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};a.drawLine=function(a,b,c,f,g,d,e){a.lineWidth=e||1;a.strokeStyle=d||"black";d=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(k(b)+d,k(c)+d);a.lineTo(k(f)+d,k(g)+d);a.stroke()};a.getColor=function(a,b){if("string"==typeof b)return b;m=a.evalExpression(b);q=k(255*m[0][0]);p=k(255*m[0][1]);t=k(255*m[0][2]);g=1-m[0][3];return"rgba("+q+","+p+","+t+","+g+")"};a.getFeatures=function(){a.hasJavaSupport=navigator.javaEnabled();var b=navigator.appVersion.toLowerCase();
a.hasTouchSupport=window.hasOwnProperty&&window.hasOwnProperty("ontouchstart")||b.match("android")&&!0;a.hasTouchSupport=navigator.userAgent.toLowerCase().match("qt")?!1:a.hasTouchSupport;b=document.createElement("canvas");a.hasCanvasSupport=b.getContext&&b.getContext("2d");a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"));e()};a.whichButton=function(a){return null!==a.which?2>a.which?"L":2===a.which?"M":"R":2>a.button?"L":4===a.button?"M":"R"};a.getCursorPosition=function(a){a.touches?
(a=a.touches[0],v=a.pageX,u=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(v=a.pageX,u=a.pageY):(v=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,u=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:v,y:u}};a.getTextWidth=function(b,c){a.ctx.font=c;return a.ctx.measureText(b).width};var s=document.createElement("span");s.appendChild(document.createTextNode("\u00c1p"));var x=document.createElement("div");x.setAttribute("style","display: inline-block; w: 1px; h: 0px;");
var A=document.createElement("div");A.setAttribute("style","margin: 0; padding: 0;");A.appendChild(s);A.appendChild(x);var C={};a.getFontMetrics=function(a){if(C[a])return C[a];s.setAttribute("style","font: "+a+"; margin: 0px; padding: 0px;");document.body.appendChild(A);var b={};x.style.verticalAlign="baseline";b.ascent=x.offsetTop-s.offsetTop;x.style.verticalAlign="bottom";b.h=x.offsetTop-s.offsetTop;b.descent=b.h-b.ascent;b.baseline=b.ascent;document.body.removeChild(A);return C[a]=b};a.getFieldFontSize=
function(a){a=Math.min(50,a);return a=24<=a?Math.floor(a/2+2-a/16):20<=a?12:17<=a?11:15<=a?10:9};a.getScreenshot=function(){var b=a.apps[0],c,f=document.createElement("canvas"),g=new Image;if(b){f.setAttribute("width",b.width);f.setAttribute("height",b.height);for(var k=f.getContext("2d"),d=0,e=b.spaces.length;d<e;d++)c=b.spaces[d],"R2"===c.type&&(k.drawImage(c.backgroundCanvas,c.x,c.y),k.drawImage(c.canvas,c.x,c.y),h(k,c.container,c.ctrs));0<b.northSpace.controls.length&&l(k,b.northSpace.container,
b.northSpace);0<b.southSpace.controls.length&&l(k,b.southSpace.container,b.southSpace);0<b.eastSpace.controls.length&&l(k,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&l(k,b.westSpace.container,b.westSpace);g.src=f.toDataURL("image/png")}return g};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l;a.openExternalFile=function(a){e=null;var b=!1;if(window.XMLHttpRequest)try{b=new XMLHttpRequest}catch(d){b=!1}else if(window.ActiveXObject)try{b=new ActiveXObject("Msxml2.XMLHTTP")}catch(c){try{b=
new ActiveXObject("Microsoft.XMLHTTP")}catch(k){b=!1}}l=b;l.open("GET",a,!1);try{l.send(null),e=l.responseText,e.match(String.fromCharCode(65533))&&(l.open("GET",a,!1),l.overrideMimeType("text/plain; charset=ISO-8859-1"),l.send(null),e=l.responseText)}catch(f){console.log("Error to load the file :",a),e=null}return e};return a}(descartesJS||{}),descartesJS=function(a){function e(a){d=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};d[0]==d[d.length-1]&&"'"==d[0]&&(a.ignoreCaps=!0,d=d.substring(1,
d.length-1),"`"==d[0]&&"\u00b4"==d[d.length-1]&&(a.ignoreAcents=!0,d=d.substring(1,d.length-1)));"`"==d[0]&&"\u00b4"==d[d.length-1]&&(a.ignoreAcents=!0,d=d.substring(1,d.length-1),d[0]==d[d.length-1]&&"'"==d[0]&&(a.ignoreCaps=!0,d=d.substring(1,d.length-1)));"*"===d.charAt(0)&&"*"!==d.charAt(d.length-1)?d=d.substring(1)+"$":"*"!==d.charAt(0)&&"*"===d.charAt(d.length-1)?d="^"+d.substring(0,d.length-1):"*"!==d.charAt(0)&&"*"!==d.charAt(d.length-1)?d="^"+d+"$":"*"===d.charAt(0)&&"*"===d.charAt(d.length-
1)&&(d=d.substring(1,d.length-1));d=d.replace(/\?/g,"[\\S\\s]{1}");a.regExp=d;return a}function l(a,b){d=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=d.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:b.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),expr:b.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function h(a,b,c){b=parseFloat(b);r=a.expr[0];n=a.expr[1];m=
c.evalExpression(r.expr);q=c.evalExpression(n.expr);p="("==r.type;t="["==r.type;g=")"==n.type;v="]"==n.type;return(p&&b>m||t&&b>=m)&&(g&&b<q||v&&b<=q)?1:0}function b(a){return a.toString().replace(/\u00e1/g,"a").replace(/\u00e9/g,"e").replace(/\u00ed/g,"i").replace(/\u00f3/g,"o").replace(/\u00fa/g,"u").replace(/\u00c1/g,"A").replace(/\u00c9/g,"E").replace(/\u00cd/g,"I").replace(/\u00d3/g,"O").replace(/\u00da/g,"U").replace(/\u00f1/g,"n").replace(/\u00d1/g,"N")}if(a.loadLib)return a;var d,c,k,f,r,
n,m,q,p,t,g,v;a.buildRegularExpresionsPatterns=function(a,b){"("===a.charAt(0)&&(")"===a.charAt(a.length-1)&&-1===a.indexOf(","))&&(a=a.substring(1,a.length-1));a=a.replace(/&squot;/g,"'").replace(/&amp;/g,"&").split("|");for(var f=0,g=a.length;f<g;f++){c=a[f].split("&");k=[];for(var n=0,h=c.length;n<h;n++)d=c[n],-1!==d.indexOf(",")&&("("===d.charAt(0)||"["===d.charAt(0))&&(")"===d.charAt(d.length-1)||"]"===d.charAt(d.length-1))?k.push(l(d,b)):k.push(e(d));a[f]=k}return a};a.escorrecto=function(g,
k,d,e){d=d||a.externalEvaluator;e=e||a.buildRegularExpresionsPatterns(g,d);k=b(k);g=0;for(var n=e.length;g<n;g++){c=e[g];f=!0;for(var m=0,l=c.length;m<l;m++)f=c[m].regExp?f&&!!k.match(b(c[m].regExp),"i"):f&&h(c[m],k,d);if(f)return 1}return 0};a.esCorrecto=function(g,k,e,n){e=e||a.externalEvaluator;n=n||a.buildRegularExpresionsPatterns(g,e);g=0;for(var m=n.length;g<m;g++){c=n[g];f=!0;for(var l=0,r=c.length;l<r;l++)(d=c[l].regExp)?(c[l].ignoreAcents&&(k=b(k),d=b(d)),c[l].ignoreCaps&&(k=k.toLowerCase(),
d=b(d).toLowerCase()),f=f&&!!k.match(d)):f=f=f&&h(c[l],k,e);if(f)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 e=Math.floor,l,h,b,d,c,k,f,r,n;a.Color=function(a,c){this.b=this.g=this.r=0;this.a=1;this.evaluator=c;if(a){if(babel[a]&&("net"===babel[a]&&(a="rojo"),a=babel[a],this.r=parseInt("0x"+a.substring(1,3),16),this.g=parseInt("0x"+a.substring(3,5),16),this.b=parseInt("0x"+a.substring(5,7),16),this.colorStr=a,this.getColor=this.getColorString),6===a.length&&(this.r=parseInt("0x"+a.substring(0,2),16),this.g=parseInt("0x"+
a.substring(2,4),16),this.b=parseInt("0x"+a.substring(4,6),16),this.colorStr="#"+a,this.getColor=this.getColorString),8===a.length&&(this.r=parseInt("0x"+a.substring(2,4),16),this.g=parseInt("0x"+a.substring(4,6),16),this.b=parseInt("0x"+a.substring(6,8),16),this.a=1-parseInt("0x"+a.substring(0,2),16)/255,this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString),"("===a[0]){h=[];b=this.splitComa(a.substring(1,a.length-1));for(var f=0,k=b.length;f<k;f++)d=
parseInt(b[f],16),b[f]!=d.toString(16)&&b[f]!=="0"+d.toString(16)?("["===b[f].charAt(0)&&"]"===b[f].charAt(b[f].length-1)&&(b[f]=b[f].substring(1,b[f].length-1)),h.push(this.evaluator.parser.parse(b[f]))):h.push(this.evaluator.parser.parse((d/255).toString()));this.rExpr=h[0];this.gExpr=h[1];this.bExpr=h[2];this.aExpr=h[3];this.getColor=this.getColorExpression}}else this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString};a.Color.prototype.splitComa=function(a){c=
[];for(var b=r=f=k=0,d=a.length;b<d;b++)n=a.charAt(b),"("===n?k++:")"===n?k--:"["===n?f++:"]"===n?f--:","===n&&(0===k&&0===f)&&(c.push(a.substring(r,b)),r=b+1);c.push(a.substring(r));return c};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){l=this.evaluator;this.r=e(255*l.evalExpression(this.rExpr));this.g=e(255*l.evalExpression(this.gExpr));this.b=e(255*l.evalExpression(this.bExpr));this.a=1-l.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 e=document.head,l=document.createElement("meta");l.setAttribute("http-equiv","X-UA-Compatible");l.setAttribute("content","chrome=1");e.appendChild(l);l=document.createElement("meta");l.setAttribute("name","viewport");l.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
e.appendChild(l);l=document.createElement("meta");l.setAttribute("name","apple-mobile-web-app-capable");l.setAttribute("content","yes");e.appendChild(l);l=document.createElement("meta");l.setAttribute("name","apple-mobile-web-app-status-bar-style");l.setAttribute("content","black-translucent");e.appendChild(l);(e=document.getElementById("StyleDescartesApps2"))&&e.parentNode.removeChild(e);e=document.createElement("style");e.type="text/css";e.id="StyleDescartesApps2";e.setAttribute("rel","stylesheet");
document.head.appendChild(e);e.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 e=Math.sin,l=Math.floor,h=Math.random,b=Math.round,d=Math.abs,c=String.fromCharCode,k,f,r,n,m,q,p,t,g,v;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){k=[];for(var b=0;256>b;b++)k[b]=c(this.alfanum(l(d(7.5*(e(1*b-a)+e(1.4*b+a)+e(0.6*b-a)+e(2.2*b+a))))));return k.join("")};a.Krypto.prototype.encode=function(a){f=l(31*h());this.key=this.getKey(f);n=c(this.alfanum(f));return n+this.encripta(a)};
a.Krypto.prototype.decode=function(a){f=this.numalfa(a.charCodeAt(0));this.key=this.getKey(f);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;q=Array(3*a.length);for(var c=0,f=a.length;c<f;c++)g=256*l(a[c]+128)+b(255*h())+65536*b(255*h()),v=l((g<<this.shift(c))/256),q[3*c]=this.alfanum(v%32),q[3*c+1]=this.alfanum(v/32%
32),q[3*c+2]=this.alfanum(v/1024%32);return q};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;p=Array(a.length/3);for(var b=0,c=p.length;b<c;b++)v=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),g=l(256*v>>this.shift(b)),t=l(g/256)%256-128,0>t&&(t+=256),p[b]=t;return p};a.Krypto.prototype.alfanum=function(a){a=l(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){n=Array(a.length);for(var b=0,c=a.length;b<c;b++)n[b]=a.charCodeAt(b);return n};a.Krypto.prototype.bytesToString=function(a){for(var b=0,f=a.length;b<f;b++)a[b]=c(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){r=this.key.charCodeAt(a%this.key.length);n=this.numalfa(r);m=l(n/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(e,l){this.parent=e;var h=e.evaluator,b=h.parser,d=new a.Auxiliary(e);this.delay=l.delay?b.parse(l.delay):b.parse("60");this.loop=l.loop?l.loop:!1;this.auto=void 0==l.auto&&2===this.parent.version?!0:l.auto;this.controls=l.controls;this.init=d.splitInstructions(b,l.init);this.doExpr=d.splitInstructions(b,l.doExpr);l.whileExpr&&(this.whileExpr=b.parse(l.whileExpr));var c=this,k,f,r=c.doExpr.length;
this.animationExec=function(){for(f=0;f<r;f++)h.evalExpression(c.doExpr[f]);c.parent.update();c.playing&&(0<h.evalExpression(c.whileExpr)||c.loop)?(k=h.evalExpression(c.delay),c.timer=setTimeout(c.animationExec,10>k?10:k)):(c.stop(),c.parent.update())};this.playing=!1;this.auto&&this.play()};a.Animation.prototype.play=function(){this.playing?this.stop():(this.reinit(),this.playing=!0,this.timer=setTimeout(this.animationExec,this.parent.evaluator.evalExpression(this.delay)))};a.Animation.prototype.stop=
function(){this.playing=!1;clearInterval(this.timer)};a.Animation.prototype.reinit=function(){for(var a=0,l=this.init.length;a<l;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,l){this.parent=a;this.evaluator=this.parent.evaluator};a.Action.prototype.execute=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Message=function(e,l){a.Action.call(this,e,l);this.parameter=
l};a.extend(a.Message,a.Action);a.Message.prototype.execute=function(){alert(this.parameter)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Calculate=function(e,l){a.Action.call(this,e,l);var h=this.evaluator,b=h.parser;l=(l||"").replace(/&squot;/g,"'");l=l.replace(/;/g,"\\n");l=l.split("\\n")||[""];for(var d=[],c,k=0,f=l.length;k<f;k++)(c=b.parse(l[k],!0))&&d.push(c);f=d.length;this.execute=function(){for(k=0;k<f;k++)h.evalExpression(d[k])}};a.extend(a.Calculate,a.Action);
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(e,l){a.Action.call(this,e,l);this.parameter=l;this.target="_blank";var h=this.parameter.indexOf("target");-1!=h&&(this.target=this.parameter.substring(h),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,h-1));"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),this.actionExec=function(){eval(this.parameter)}):
("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,this.target)})};a.extend(a.OpenURL,a.Action);a.OpenURL.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenScene=function(e,l){a.Action.call(this,e,l);this.parameter=l;this.target="_blank";var h=this.parameter.indexOf("target");
-1!=h&&(this.target=this.parameter.substring(h),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,h-1));"_blank"!==this.target&&"_parent"!==this.target&&"_self"!==this.target&&"_top"!==this.target?this.actionExec=function(){window.parent.postMessage({type:"changeTarget",name:this.target,value:this.parameter},"*")}:"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),this.actionExec=function(){eval(this.parameter)}):
("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){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 d=a.getElementsByTagName("applet");d&&0<d.length&&(this.innerWidth=d[0].width,this.height=d[0].height,a.body.style.margin="0px",a.body.style.padding="0px",d[0].parentNode.style.margin="0px",d[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(e,l){a.Action.call(this,e,l);l||(this.urlAbout=window.location.href.substring(0,window.location.href.lastIndexOf("/")+
1)+l)};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(e,l){a.Action.call(this,e,l)};a.extend(a.Config,a.Action);a.Config.prototype.execute=function(){window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'>"+this.parent.applet.outerHTML+"</xmp>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Init=function(e,l){a.Action.call(this,e,l)};a.extend(a.Init,a.Action);a.Init.prototype.execute=function(){this.parent.init()};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Clear=function(e,l){a.Action.call(this,e,l)};a.extend(a.Clear,a.Action);a.Clear.prototype.execute=function(){this.parent.clear()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Animate=function(e,l){a.Action.call(this,e,l)};a.extend(a.Animate,a.Action);a.Animate.prototype.execute=function(){this.parent.play()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.InitAnimation=
function(e,l){a.Action.call(this,e,l)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.PlayAudio=function(e,l){a.Action.call(this,e,l);this.filenameExpr=l?this.evaluator.parser.parse("'"+l.split(" ")[0].trim()+"'"):"";this.filename=this.evaluator.evalExpression(this.filenameExpr);this.theAudio=e.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,b){this.parent=a;this.evaluator=this.parent.evaluator;this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var d in b)b.hasOwnProperty(d)&&(this[d]=b[d])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var e,l;a.Auxiliary.prototype.splitInstructions=function(a,b){l=[];b=b?
b.split(";"):[""];for(var d=0,c=b.length;d<c;d++)(e=a.parse(b[d],!0))&&l.push(e);return l};a.Auxiliary.prototype.getPrivateVariables=function(a,b){l=[];b=b?b.split(/;|,/):[""];for(var d=0,c=b.length;d<c;d++)(e=a.parse(b[d],!0))&&l.push(e);d=0;for(c=l.length;d<c;d++)l[d]="asign"===l[d].type?l[d].childs[0].value:"identifier"===l[d].type?l[d].value:"";return l};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(e,l){a.Auxiliary.call(this,e,l);var h=this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=h.parse(this.expresionString))&&h.setVariable(this.id,this.expresion);this.editable&&(this.registerTextField(),this.parent.editableRegionVisible=!0)};a.extend(a.Variable,a.Auxiliary);a.Variable.prototype.registerTextField=
function(){var a=document.createElement("div"),l=document.createElement("label");l.appendChild(document.createTextNode("___"+this.id+"=___"));var h=document.createElement("input");h.value=this.expresionString;h.disabled=!this.editable;a.appendChild(l);a.appendChild(h);var b=this,d=b.evaluator.parser;h.onkeydown=function(a){13==a.keyCode&&(b.expresion=d.parse(this.value),d.setVariable(b.id,b.expresion),b.parent.update())};this.parent.editableRegion.textFields.push({container:a,type:"div"})};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.Constant=function(e,l){a.Auxiliary.call(this,e,l);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=function(){this.evaluator.setVariable(this.id,this.evaluator.evalExpression(this.expresion))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector=function(e,l){var h=e.evaluator,b=h.parser;this.size=b.parse("3");a.Auxiliary.call(this,
e,l);this.expresion=this.expresion.split(";");var d;if(this.file){var c=document.getElementById(this.file);c&&"descartes/vectorFile"==c.type?(d=c.text,"\n"==d[0]&&(d=d.substring(1))):d=a.openExternalFile(this.file);null!=d&&(d=d.split("\n"));null==d||1==d.length&&""==d[0]?(d=[],this.size=0):(this.expresion=[],this.size=null);for(var k,f=0,r=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,c=0,n=d.length;c<n;c++)d[c].match(/./)&&(this.expresion[f]=this.id+"["+f+"]="+d[c],f++,(k=d[c].match(r))&&
this.parent.getImage(k));null===this.size&&(this.size=b.parse(this.expresion.length+""))}c=0;for(n=this.expresion.length;c<n;c++)(d=b.parse(this.expresion[c],!0))&&"asign"!=d.type&&(d=b.parse(this.id+"["+c+"]="+this.expresion[c],!0)),this.expresion[c]=d;b=[];c=0;for(n=h.evalExpression(this.size);c<n;c++)b.push(0);h.vectors[this.id]=b;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 l=
0,h=this.expresion.length;l<h;l++)a.evalExpression(this.expresion[l])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(e,l){var h=e.evaluator,b=h.parser;this.rows=b.parse("3");this.columns=b.parse("3");a.Auxiliary.call(this,e,l);this.expresion=this.splitInstructions(b,this.expresion);var b=h.evalExpression(this.rows),d=h.evalExpression(this.columns),c=[];c.type="matrix";for(var k,f=0;f<d;f++){k=[];for(var r=0,n=b;r<n;r++)k.push(0);c[f]=k}h.matrices[this.id]=
c;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,l=a.evalExpression(this.rows),h=a.evalExpression(this.columns);a.setVariable(this.id+".filas",l);a.setVariable(this.id+".columnas",h);var b=a.matrices[this.id];b.rows=l;b.cols=h;l=0;for(h=this.expresion.length;l<h;l++)a.evalExpression(this.expresion[l])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(e,l){a.Auxiliary.call(this,e,l);var h=this.evaluator,
b=h.parser,d=this.id.indexOf("(");this.name=this.id.substring(0,d);this.params=this.id.substring(d+1,this.id.length-1);this.domain=this.range?b.parse(this.range):b.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(b);this.expresion=b.parse(this.expresion);var c=this;this.functionExec=function(){if(c.numberOfParams<=arguments.length){for(var b=[],f=0,d=c.privateVars.length;f<
d;f++)b.push(h.getVariable(c.privateVars[f])),h.setVariable(c.privateVars[f],0);for(var e=[],f=0,d=c.params.length;f<d;f++)e[f]=h.getVariable(c.params[f]),h.setVariable(c.params[f],arguments[f]);f=0;for(d=c.init.length;f<d;f++)h.evalExpression(c.init[f]);do{f=0;for(d=c.doExpr.length;f<d;f++)h.evalExpression(c.doExpr[f])}while(0<h.evalExpression(c.whileExpr));var l=h.evalExpression(c.expresion);a.rangeOK=h.evalExpression(c.domain);f=0;for(d=c.params.length;f<d;f++)h.setVariable(c.params[f],e[f]);f=
0;for(d=c.privateVars.length;f<d;f++)h.setVariable(c.privateVars[f],b[f]);return l}return 0};h.setFunction(this.name,this.functionExec)};a.extend(a.Function,a.Auxiliary);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Algorithm=function(e,l){a.Auxiliary.call(this,e,l);var h=this.evaluator;this.parseExpressions(h.parser);this.algorithmExec=function(){for(var a=0,d=this.init.length;a<d;a++)h.evalExpression(this.init[a]);do{a=0;for(d=this.doExpr.length;a<d;a++)h.evalExpression(this.doExpr[a])}while(0<
h.evalExpression(this.whileExpr))}};a.extend(a.Algorithm,a.Auxiliary);a.Algorithm.prototype.update=function(){this.algorithmExec();"onlyOnce"===this.evaluate&&(this.update=function(){})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Event=function(e,l){a.Auxiliary.call(this,e,l);var h=this.evaluator;this.condition=h.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){0<
h.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<h.evalExpression(this.condition);3==this.parent.version?a!=this.lastEvaluation&&(this.action.execute(),this.lastEvaluation=a?!0:!1):a&&!this.lastEvaluation?(this.action.execute(),this.lastEvaluation=!0):!a&&this.lastEvaluation&&(this.lastEvaluation=!1)});"always"==this.execution&&(this.eventExec=function(){0<h.evalExpression(this.condition)&&
this.action.execute()})};a.extend(a.Event,a.Auxiliary);a.Event.prototype.update=function(){this.eventExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d;a.Graphic=function(b,k){this.parent=b;this.evaluator=b.evaluator;var f=this.evaluator.parser;this.spaceID="E0";this.background=!1;this.type="";this.drawif=f.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=f.parse("(0,0)");this.family="";this.family_interval=f.parse("[0,1]");this.family_steps=f.parse("8");this.editable=!1;this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=f.parse("2");for(var d in k)k.hasOwnProperty(d)&&(this[d]=k[d]);this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backgroundCanvas.getContext("2d"));
this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10};a.Graphic.prototype.getSpace=function(){for(var a=this.parent.spaces,b,f=0,d=a.length;f<d;f++)if(b=a[f],b.id==this.spaceID)return b;return a[0]};a.Graphic.prototype.getFamilyValues=function(){e=this.evaluator;l=e.evalExpression(this.family_interval);this.familyInf=l[0][0];this.familySup=l[0][1];this.fSteps=Math.round(e.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?
(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,b,f){e=this.evaluator;this.getFamilyValues();h=e.getVariable(this.family);if(0<=this.fSteps)for(var d=0,n=this.fSteps;d<=n;d++)e.setVariable(this.family,this.familyInf+d*this.family_sep),0<e.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,f));e.setVariable("_Text_H_",0);e.setVariable(this.family,h)};a.Graphic.prototype.draw=function(a,b){""!=this.family?this.drawFamilyAux(this.ctx,a,b):0<this.evaluator.evalExpression(this.drawif)&&
(this.update(),this.drawAux(this.ctx,a,b))};a.Graphic.prototype.drawTrace=function(a,b){""!=this.family?this.drawFamilyAux(this.traceCtx,a,b):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,a,b))};a.Graphic.prototype.drawText=function(a,k,f,h,n,l,q,p,t,g,v){if("rtfNode"===k.type)a.fillStyle=n.getColor(),a.strokeStyle=n.getColor(),a.textBaseline="alphabetic",k.draw(a,f,h,t,g,q,v);else{"simpleText"===k.type&&(k=k.toString(t,g).split("\\n"));f+=l.match("Arial")?
-2:l.match("Times")?-2:0;e=this.evaluator;a.fillStyle=n.getColor();a.font=l;a.textAlign=q;a.textBaseline=p;this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=parseInt(this.fontSize/12)+1.5);d=1.2*this.fontSize||0;n=0;for(l=k.length;n<l;n++)b=k[n],this.border&&(a.lineJoin="round",a.strokeText(b,f,h+d*n)),a.fillText(b,f,h+d*n)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=function(a,b){this.text=b.replace("&#x2013","\u2013");this.textElements=[];
this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var d="'",c=0,k=0,f=-1,e,n;c<b.length;)e=b.charAt(c),n=b.charAt(c-1),"["===e&&"\\"===n?(this.textElements.push(b.substring(k,c-1)+"["),this.textElementsMacros.push("'"+b.substring(k,c-1)+"['"),k=c+1):"]"===e&&"\\"===n?(this.textElements.push(b.substring(k,c-1)+"]"),this.textElementsMacros.push("'"+b.substring(k,c-1)+"]'"),k=c+1):"["===e&&-1==f?(this.textElements.push(b.substring(k,c)),this.textElementsMacros.push("'"+
b.substring(k,c)+"'"),k=c,f++):"["===e?f++:"]"===e&&0==f?(this.textElements.push(this.evaluator.parser.parse(b.substring(k,c+1))),this.textElementsMacros.push("["+b.substring(k,c+1)+"]"),k=c+1,f--):("]"==b.charAt(c)&&(f=0>f?f:f-1),d+=b.charAt(c)),c++;this.textElements.push(b.substring(k,c));this.textElementsMacros.push("'"+b.substring(k,c)+"'")};var e,l;a.SimpleText.prototype.toString=function(a,b){e="";for(var d=0,c=this.textElements.length;d<c;d++)"string"===typeof this.textElements[d]?e+=this.textElements[d]:
(l=this.evaluator.evalExpression(this.textElements[d])[0][0],""!==l&&("string"===typeof l?e+=l:(l=parseFloat(l),l=b?l.toFixed(a):parseFloat(l.toFixed(a)),e+=l.toString().replace(".",this.parent.decimal_symbol))));return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,l=2*Math.PI,h,b,d,c,k,f,r,n,m,q,p,t,g,v,u,s,x,A,C,y,E,D,B,z,I,G,M,L,w,N,F,J,K,H,O,S,Q,R,P,U,T,W,X,Z,Y,V;a.Equation=function(b,c){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP=
"";a.Graphic.call(this,b,c);this.generateStroke();this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();p=new a.R2;t=new a.R2;g=new a.R2;s=new a.R2;v=new a.R2};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"==this.expresion.type){var b=this.expresion.childs[0],c=this.expresion.childs[1];"identifier"==b.type&&"y"==b.value&&!c.contains("y")?(this.funExpr=c,this.drawAux=this.drawAuxFunY):
"identifier"==c.type&&"y"==c.value&&!b.contains("y")?(this.funExpr=b,this.drawAux=this.drawAuxFunY):"identifier"==b.type&&"x"==b.value&&!c.contains("x")?(this.funExpr=c,this.drawAux=this.drawAuxFunX):"identifier"==c.type&&("x"==c.value&&!b.contains("x"))&&(this.funExpr=c,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(k,l,w){k.lineWidth=1;b=this.evaluator;d=b.parser;c=this.space;f=b.evalExpression(this.width);k.fillStyle=w.getColor();k.translate(-this.width_2,-this.width_2);d.getVariable("x");d.getVariable("y");r=c.w;n=c.h;m=e(r/8);3>m&&(m=3);q=e(n/8);3>q&&(q=3);h=[];p.set(0,0);t.set(0,0);g.set(0,0);for(G=e(q/2);G<n;G+=q)for(I=e(m/2);I<r;I+=m)if(this.abs_coord?(s.set(I,
G),u=this.newt.findZero(s),b.setVariable("x",u.x),b.setVariable("y",u.y),v.set(u.x,u.y)):(s.set(c.getRelativeX(I),c.getRelativeY(G)),u=this.newt.findZero(s),b.setVariable("x",u.x),b.setVariable("y",u.y),v.set(c.getAbsoluteX(u.x),c.getAbsoluteY(u.y))),x=e(v.ix()),A=e(v.iy()),!(0>x||x>=r||0>A||A>=n||h[x+A*c.w]))if(h[x+A*c.w]=!0,p.x=u.x,p.y=u.y,t.x=u.x,t.y=u.y,C=this.newt.getUnitNormal(),!(0==C.x&&0==C.y)){C.rotL90();g.x=C.x;g.y=C.y;E=y=0;for(D=!1;2>E;){D&&(g.x=-C.x,g.y=-C.y,u.x=p.x,u.y=p.y,t.x=u.x,
t.y=u.y,this.abs_coord?v.set(u.x,u.y):v.set(c.getAbsoluteX(u.x),c.getAbsoluteY(u.y)),x=v.ix(),A=v.iy(),D=!1,y=0);this.abs_coord?(u.x+=g.x,u.y+=g.y):(u.x+=g.x/c.scale,u.y+=g.y/c.scale);u=this.newt.findZero(u);b.setVariable("x",u.x);b.setVariable("y",u.y);g.x=u.x-t.x;g.y=u.y-t.y;g.normalize();if(0==g.x&&0==g.y)break;t.x=u.x;t.y=u.y;this.abs_coord?v.set(u.x,u.y):v.set(c.getAbsoluteX(u.x),c.getAbsoluteY(u.y));B=e(v.ix());z=e(v.iy());if(B!=x||z!=A)if(x=B,A=z,0<=x&&x<r&&0<=A&&A<n)if(y=0,h[x+A*c.w])break;
else h[x+A*c.w]=!0,a.rangeOK&&b.evalExpression(this.drawif)&&k.drawImage(this.auxCanvas,x,A);else D=!0,E++;else 4<++y&&(D=!0,E++)}}k.setTransform(1,0,0,1,0,0)};a.Equation.prototype.drawAuxFunY=function(g,d,e){b=this.evaluator;c=this.space;r=c.w;m=1/c.scale;L=c.getAbsoluteY(0);f=b.evalExpression(this.width);k=this.color.getColor();g.fillStyle=k;w=c.getRelativeX(0);b.setVariable("x",w);O=c.getAbsoluteX(w);S=c.getAbsoluteY(b.evalExpression(this.funExpr));U=0;for(d=1;d<r;d++){F=w+d*m;b.setVariable("x",
F);J=b.evalExpression(this.funExpr);b.setVariable("y",J);K=c.getAbsoluteX(F);H=c.getAbsoluteY(J);Q=Math.min(U,J);R=Math.max(U,J);P={min:Q,max:R};if(void 0!==J&&(a.rangeOK&&b.evalExpression(this.drawif))&&!this.hasSingularity(m,F,"x",F-m,U,F,J,P)){if(this.fillM||this.fillP)this.fillM&&(T=this.fillM.getColor()),this.fillP&&(W=this.fillP.getColor()),g.lineWidth=1,g.strokeStyle=H>L?T:W,g.beginPath(),g.moveTo(K+0.5,H),g.lineTo(K+0.5,L),g.stroke();g.lineWidth=f;g.strokeStyle=k;g.beginPath();g.moveTo(O,
S);g.lineTo(K,H);g.stroke()}U=J||0;O=K;S=H}};a.Equation.prototype.drawAuxFunX=function(g,d,e){b=this.evaluator;c=this.space;n=c.h;q=1/c.scale;M=c.getAbsoluteX(0);f=b.evalExpression(this.width);k=this.color.getColor();g.fillStyle=k;N=c.getRelativeY(n);b.setVariable("y",N);O=c.getAbsoluteX(b.evalExpression(this.funExpr));S=c.getAbsoluteY(N);d=0;for(e=1;e<n;e++){J=N+e*q;b.setVariable("y",J);F=b.evalExpression(this.funExpr);b.setVariable("x",F);K=c.getAbsoluteX(F);H=c.getAbsoluteY(J);Q=Math.min(d,F);
R=Math.max(d,F);P={min:Q,max:R};if(void 0!==J&&(a.rangeOK&&b.evalExpression(this.drawif))&&!this.hasSingularity(q,J,"y",J-q,d,J,F,P)){if(this.fillM||this.fillP)this.fillM&&(T=this.fillM.getColor()),this.fillP&&(W=this.fillP.getColor()),g.lineWidth=1,g.strokeStyle=K>M?T:W,g.beginPath(),g.moveTo(K,H+0.5),g.lineTo(M,H+0.5),g.stroke();g.lineWidth=f;g.strokeStyle=k;g.beginPath();g.moveTo(O,S);g.lineTo(K,H);g.stroke()}d=F||0;O=K;S=H}};a.Equation.prototype.hasSingularity=function(a,b,c,f,g,d,k,e){if(1E-12>
Math.abs(d-f)||1E-8>Math.abs(d-f)&&Math.abs(k-g)>Math.abs(a))return!0;X=!1;Z=b;Y=(f+d)/2;this.evaluator.setVariable(c,Y);V=this.evaluator.evalExpression(this.funExpr);e.min<=V&&V<=e.max?X=!1:(e.x=Math.min(e.min,V),e.y=Math.max(e.max,V),X=this.hasSingularity(a,b,c,f,g,Y,V,e)||this.hasSingularity(a,b,c,Y,V,d,k,e));this.evaluator.setVariable(c,Z);return X};a.drawPixel=function(a,b,c,f){a.moveTo(b,c);a.arc(b,c,f,0,l,!1)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");
a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parseExpression(),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Curve=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");this.width=b.evaluator.parser.parse("1");
this.fill="";a.Graphic.call(this,b,c);(this.visible=2==this.parent.version&&void 0==this.visible?!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);var l,h,b,d,c,k,f,r,n,m,q;a.Curve.prototype.update=function(){l=this.evaluator;h=l.evalExpression(this.parameter_interval);this.paraInf=h[0][0];this.paraSup=h[0][1];this.pSteps=l.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,t,g){l=this.evaluator;b=this.space;d=e(l.evalExpression(this.width));h.lineWidth=0<d?d:1E-6;h.lineCap="round";h.lineJoin="round";h.strokeStyle=g.getColor();c=l.getVariable(this.parameter);h.beginPath();l.setVariable(this.parameter,this.paraInf);k=l.evalExpression(this.expresion);this.exprX=this.abs_coord?e(k[0][0]):e(b.getAbsoluteX(k[0][0]));this.exprY=
this.abs_coord?e(k[0][1]):e(b.getAbsoluteY(k[0][1]));this.rotateExp&&(f=a.degToRad(l.evalExpression(this.rotateExp)),r=Math.cos(f),n=Math.sin(f),m=this.exprX*r-this.exprY*n,q=this.exprX*n+this.exprY*r,this.exprX=m,this.exprY=q);h.moveTo(this.exprX+0.5,this.exprY+0.5);for(g=1;g<=this.pSteps;g++)l.setVariable(this.parameter,this.paraInf+g*this.paraSep),k=l.evalExpression(this.expresion),this.exprX=this.abs_coord?e(k[0][0]):e(b.getAbsoluteX(k[0][0])),this.exprY=this.abs_coord?e(k[0][1]):e(b.getAbsoluteY(k[0][1])),
this.rotateExp&&(m=this.exprX*r-this.exprY*n,q=this.exprX*n+this.exprY*r,this.exprX=m,this.exprY=q),h.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&(h.fillStyle=t.getColor(),h.fill());h.stroke();l.setVariable(this.parameter,c)};a.Curve.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parent.update())};this.parent.editableRegion.textFields.push(a)};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI;a.Sequence=function(e,h){this.size=e.evaluator.parser.parse("2");a.Graphic.call(this,e,h)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){var e=this.evaluator,h=e.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1];if(this.rotateExp){var b=a.degToRad(e.evalExpression(this.rotateExp)),h=Math.cos(b),d=Math.sin(b),b=this.exprX*h-this.exprY*d,h=this.exprX*d+this.exprY*h;this.exprX=
b;this.exprY=h}e=e.evalExpression(this.range);this.rangeInf=e[0][0];this.rangeMax=e[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,h){var b=this.evaluator,d,c,k,f=Math.ceil(b.evalExpression(this.size)-0.4);a.fillStyle=h.getColor();a.beginPath();this.rangeInf>this.rangeMax&&(k=this.rangeInf,this.rangeInf=this.rangeMax,
this.rangeMax=k);for(var r=b.getVariable("n"),n=this.rangeInf,m=this.rangeMax;n<=m;n++)b.setVariable("n",n),k=b.evalExpression(this.expresion),this.exprX=k[0][0],this.exprY=k[0][1],this.abs_coord?d=k[0][1]:(d=this.space.getAbsoluteX(k[0][0]),c=this.space.getAbsoluteY(k[0][1])),a.moveTo(d,c),a.sequence(d,c,f,0,e,!0);b.setVariable("n",r);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,d+f,c-f,this.color,this.font,"start","alphabetic",b.evalExpression(this.decimals),this.fixed,!0)};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,l=Math.round;a.Point=function(b,c){this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Point,a.Graphic);var h,b,d,c,k,f,r,n,m,q,p,t;a.Point.prototype.update=function(){h=this.evaluator;d=h.evalExpression(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1];this.rotateExp&&(c=a.degToRad(h.evalExpression(this.rotateExp)),k=Math.cos(c),f=Math.sin(c),r=this.exprX*k-this.exprY*f,n=this.exprX*
f+this.exprY*k,this.exprX=r,this.exprY=n)};a.Point.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Point.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Point.prototype.drawAux=function(a,c){h=this.evaluator;b=this.space;p=l(h.evalExpression(this.size));t=p+1;a.fillStyle=c.getColor();m=this.abs_coord?l(this.exprX):l(b.getAbsoluteX(this.exprX));q=this.abs_coord?l(this.exprY):l(b.getAbsoluteY(this.exprY));a.beginPath();a.arc(m,q,p,
0,e,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,m+t+1,q-t,this.color,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,l=2*Math.PI,h,b,d,c,k,f,r,n,m,q,p,t,g,v,u,s,x,A;a.Segment=function(b,c){this.width=b.evaluator.parser.parse("1");this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Segment,a.Graphic);a.Segment.prototype.update=
function(){h=this.evaluator;d=h.evalExpression(this.expresion);this.endPoints=[];for(var b=0,g=d.length;b<g;b++)this.endPoints[b]={x:d[b][0],y:d[b][1]};if(this.rotateExp){c=a.degToRad(h.evalExpression(this.rotateExp));k=Math.cos(c);f=Math.sin(c);b=0;for(g=this.endPoints.length;b<g;b++)r=this.endPoints[b].x*k-this.endPoints[b].y*f,n=this.endPoints[b].x*f+this.endPoints[b].y*k,this.endPoints[b].x=r,this.endPoints[b].y=n}};a.Segment.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};
a.Segment.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Segment.prototype.drawAux=function(a,c,f){h=this.evaluator;b=this.space;m=e(h.evalExpression(this.width));a.lineWidth=0<m?m:1E-6;g=h.evalExpression(this.size);0>g&&(g=0);a.fillStyle=c.getColor();a.strokeStyle=f.getColor();a.lineCap="round";q=10+a.lineWidth;v=0==a.lineWidth%2?0:0.5;this.abs_coord?(u=e(this.endPoints[0].x),s=e(this.endPoints[0].y),x=e(this.endPoints[1].x),A=e(this.endPoints[1].y)):(u=e(b.getAbsoluteX(this.endPoints[0].x)),
s=e(b.getAbsoluteY(this.endPoints[0].y)),x=e(b.getAbsoluteX(this.endPoints[1].x)),A=e(b.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(u+v,s+v);a.lineTo(x+v,A+v);a.stroke();a.beginPath();a.arc(u,s,g,0,l,!0);a.arc(x,A,g,0,l,!0);a.fill();this.text!=[""]&&(p=parseInt((u+x)/2)-3,t=parseInt((s+A)/2)+3,this.uber.drawText.call(this,a,this.text,p+q,t-q,this.color,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e=Math.floor,l=Math.round,h,b,d,c,k,f,r,n,m,q,p,t,g,v,u,s,x,A;a.Arrow=function(b,c){this.width=b.evaluator.parser.parse("5");this.size=b.evaluator.parser.parse("2");this.spear=b.evaluator.parser.parse("8");this.arrow=new a.Color("ee0022");a.Graphic.call(this,b,c)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){h=this.evaluator;b=h.evalExpression(this.expresion);this.endPoints=[];for(var g=0,e=b.length;g<e;g++)this.endPoints[g]={x:b[g][0],y:b[g][1]};if(this.rotateExp){d=a.degToRad(h.evalExpression(this.rotateExp));
c=Math.cos(d);k=Math.sin(d);g=0;for(e=this.endPoints.length;g<e;g++)f=this.endPoints[g].x*c-this.endPoints[g].y*k,r=this.endPoints[g].x*k+this.endPoints[g].y*c,this.endPoints[g].x=f,this.endPoints[g].y=r}};a.Arrow.prototype.draw=function(){this.uber.draw.call(this,this.arrow,this.color)};a.Arrow.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.arrow,this.trace)};a.Arrow.prototype.drawAux=function(b,c,f){h=this.evaluator;n=this.space;h.evalExpression(this.size);p=h.evalExpression(this.width);
1>p&&(p=1);t=Math.ceil(p/2);g=n.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);v=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);b.fillStyle=c.getColor();b.strokeStyle=f.getColor();b.lineWidth=2;this.abs_coord?(u=l(this.endPoints[0].x),s=l(this.endPoints[0].y),x=l(this.endPoints[1].x),A=l(this.endPoints[1].y)):(u=l(n.getAbsoluteX(this.endPoints[0].x)),s=l(n.getAbsoluteY(this.endPoints[0].y)),x=l(n.getAbsoluteX(this.endPoints[1].x)),
A=l(n.getAbsoluteY(this.endPoints[1].y)));c=h.evalExpression(this.spear);0>c&&(c=0);b.save();b.translate(u,s,v);this.abs_coord?0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?b.rotate(this.angle):b.rotate(-this.angle):(v*=g,0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?b.rotate(-this.angle):b.rotate(this.angle));b.beginPath();b.moveTo(-t,e(-t));b.lineTo(e(v-c-p),e(-t));b.lineTo(e(v-2*c),e(-c-t));b.lineTo(e(v),0);b.lineTo(e(v-2*c),e(c+t));b.lineTo(e(v-c-p),e(t));b.lineTo(-t,
e(t));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(m=parseInt((u+x)/2)-3,q=parseInt((s+A)/2)+3,this.uber.drawText.call(this,b,this.text,m,q,f,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,l,h,b,d,c,k,f,r,n,m,q,p;a.Polygon=function(b,c){this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,c);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);
a.Polygon.prototype.update=function(){l=this.evaluator;b=l.evalExpression(this.expresion);for(var e=0,g=b.length;e<g;e++)this.endPoints[e]={x:b[e][0],y:b[e][1]};if(this.rotateExp){d=a.degToRad(l.evalExpression(this.rotateExp));c=Math.cos(d);k=Math.sin(d);e=0;for(g=this.endPoints.length;e<g;e++)f=this.endPoints[e].x*c-this.endPoints[e].y*k,r=this.endPoints[e].x*k+this.endPoints[e].y*c,this.endPoints[e].x=f,this.endPoints[e].y=r}};a.Polygon.prototype.draw=function(){this.uber.draw.call(this,this.fill,
this.color)};a.Polygon.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Polygon.prototype.drawAux=function(a,b,c){l=this.evaluator;h=this.space;n=e(l.evalExpression(this.width));a.lineWidth=0<n?n:1E-6;a.strokeStyle=c.getColor();a.lineCap="round";a.lineJoin="round";m=0<n?0.5:0;q=this.abs_coord?e(this.endPoints[0].x):e(h.getAbsoluteX(this.endPoints[0].x));p=this.abs_coord?e(this.endPoints[0].y):e(h.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(q+m,p+
m);c=1;for(var f=this.endPoints.length;c<f;c++)q=this.abs_coord?e(this.endPoints[c].x):e(h.getAbsoluteX(this.endPoints[c].x)),p=this.abs_coord?e(this.endPoints[c].y):e(h.getAbsoluteY(this.endPoints[c].y)),a.lineTo(q+m,p+m);this.fill&&(a.fillStyle=b.getColor(),a.fill());a.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Arc=function(b,c){this.width=b.evaluator.parser.parse("1");this.fill="";this.center=b.evaluator.parser.parse("(0,0)");this.radius=
b.evaluator.parser.parse("1");this.init=b.evaluator.parser.parse("0");this.end=b.evaluator.parser.parse("90");a.Graphic.call(this,b,c)};a.extend(a.Arc,a.Graphic);var l,h,b,d,c,k,f,r,n,m,q,p,t,g,v,u,s,x,A,C,y,E,D,B;a.Arc.prototype.update=function(){l=this.evaluator;h=l.evalExpression(this.center);this.exprX=h[0][0];this.exprY=h[0][1];this.rotateExp&&(b=a.degToRad(l.evalExpression(this.rotateExp)),d=Math.cos(b),c=Math.sin(b),k=this.exprX*d-this.exprY*c,f=this.exprX*c+this.exprY*d,this.exprX=k,this.exprY=
f);r=l.evalExpression(this.init);n=l.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=r[0][0],q=r[0][1],p=n[0][0],t=n[0][1],g=Math.acos((1*m+0*q)/Math.sqrt(m*m+q*q)),v=Math.acos((1*p+0*t)/Math.sqrt(p*p+t*t)),0<m&&(0<q&&!this.abs_coord)&&(g=2*Math.PI-g),0<m&&(0>q&&this.abs_coord)&&(g=2*Math.PI-g),0>m&&(0>
q&&this.abs_coord)&&(g=2*Math.PI-g),0>m&&(0<q&&!this.abs_coord)&&(g=2*Math.PI-g),0<p&&(0<t&&!this.abs_coord)&&(v=2*Math.PI-v),0<p&&(0>t&&this.abs_coord)&&(v=2*Math.PI-v),0>p&&(0>t&&this.abs_coord)&&(v=2*Math.PI-v),0>p&&(0<t&&!this.abs_coord)&&(v=2*Math.PI-v),u=Math.min(g,v),s=Math.max(g,v),g=u,v=s,v-g>Math.PI&&this.abs_coord&&(g=s,v=u),v-g<=Math.PI&&!this.abs_coord&&(g=s,v=u),this.iniAng=g,this.endAng=v):(this.vectors=!1,this.iniAng=a.degToRad(r),this.endAng=a.degToRad(n))};a.Arc.prototype.draw=function(){this.uber.draw.call(this,
this.fill,this.color)};a.Arc.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Arc.prototype.drawAux=function(a,b,c){l=this.evaluator;x=this.space;A=this.abs_coord?e(this.exprX):e(x.getAbsoluteX(this.exprX));C=this.abs_coord?e(this.exprY):e(x.getAbsoluteY(this.exprY));y=l.evalExpression(this.radius);!this.vectors&&this.iniAng>this.endAng&&(E=this.iniAng,this.iniAng=this.endAng,this.endAng=E);0>y&&(y=0);D=!1;this.abs_coord||(y*=x.scale,this.vectors||(this.iniAng=
-this.iniAng,this.endAng=-this.endAng,D=!0));this.vectors&&(D=this.abs_coord?!1:!0);B=e(l.evalExpression(this.width));a.lineWidth=0<B?B:1E-6;a.lineCap="round";a.strokeStyle=c.getColor();a.beginPath();a.arc(A,C,y,this.iniAng,this.endAng,D);this.fill&&(a.fillStyle=b.getColor(),a.fill());a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,A+4,C-2,this.color,this.font,"start","alphabetic",l.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){function e(a,
b,c){f=4*(b+c*a.width);return{r:a.data[f],g:a.data[f+1],b:a.data[f+2],a:a.data[f+3]}}if(a.loadLib)return a;var l,h,b,d,c,k,f;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){l=this.evaluator.evalExpression(this.expresion);this.exprX=l[0][0];this.exprY=l[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,n){n.getColor();imageData=
this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(h=parseInt(this.exprX),b=parseInt(this.exprY)):(h=parseInt(this.space.getAbsoluteX(this.exprX)),b=parseInt(this.space.getAbsoluteY(this.exprY)));d=[{x:h,y:b}];for(k=e(imageData,h,b);0<d.length;){c=d.pop();h=c.x;b=c.y;var l=e(imageData,h,b);if(k.r===l.r&&k.g===l.g&&k.b===l.b&&k.a===l.a){var l=imageData,q=n;f=4*(h+b*l.width);l.data[f+0]=q.r;l.data[f+1]=q.g;l.data[f+2]=q.b;l.data[f+3]=255-q.a;0<h&&d.push({x:h-1,y:b});h<imageData.width-
1&&d.push({x:h+1,y:b});d.push({x:h,y:b-1});d.push({x:h,y:b+1})}}this.ctx.putImageData(imageData,0,0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c,k,f,r,n,m,q,p,t,g,v,u,s;a.Text=function(b,c){this.width=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.align||(this.align="start");this.ascent=this.fontSize-Math.ceil(this.fontSize/7)-(this.font.match("Courier")?3:0);this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){e=
this.evaluator;l=e.evalExpression(this.expresion);this.exprX=l[0][0];this.exprY=l[0][1];this.rotateExp&&(h=a.degToRad(e.evalExpression(this.rotateExp)),b=Math.cos(h),d=Math.sin(h),c=this.exprX*b-this.exprY*d,k=this.exprX*d+this.exprY*b,this.exprX=c,this.exprY=k)};a.Text.prototype.draw=function(){this.uber.draw.call(this,this.color)};a.Text.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.color)};a.Text.prototype.drawAux=function(a,b){s=this.evaluator.evalExpression(this.decimals);
"rtfNode"===this.text.type?(m=this.text,this.ascent=0):m=this.splitText(this.text.toString(s,this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,a,m,parseInt(this.exprX)+5,parseInt(this.exprY)+this.ascent,b,this.font,this.align,"alphabetic",s,this.fixed)};a.Text.prototype.splitText=function(a){e=this.evaluator;f=e.evalExpression(this.width);m=[];this.ctx.font=this.font;if(20<=f&&"undefined"!=a.type){for(var b=0,c=a.length;b<c;b++)r=a[b],n=this.ctx.measureText(r).width,n>f?m=m.concat(this.splitWords(r,
f)):m.push(r);q=Math.floor(1.2*this.fontSize)*m.length;e.setVariable("_Text_H_",q);return m}e.setVariable("_Text_H_",0);e.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=function(a,b){p=a;t=[];g="";u=0;for(var c,f=0,d=a.length;f<d;f++)v=p.charAt(f)," "===v&&(lastIndexOfWhite=f),g+=v,Math.round(this.ctx.measureText(g).width)>b&&(c=a.substring(u,f+1)," "!==v&&(-1===c.indexOf(" ")?(lastIndexOfWhite=f,f--):f=lastIndexOfWhite),t.push(a.substring(u,lastIndexOfWhite)),g="",u=f+1);t.push(a.substring(u));
return t};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Image=function(b,c){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);var l,h,b,d,c,k,f,r,n,m,q,p,t,g;a.Image.prototype.update=function(){l=this.evaluator;h=l.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1];this.rotateExp&&(b=a.degToRad(l.evalExpression(this.rotateExp)),
d=Math.cos(b),c=Math.sin(b),k=this.exprX*d-this.exprY*c,f=this.exprX*c+this.exprY*d,this.exprX=k,this.exprY=f);4==h[0].length&&(this.centered=!0,this.scaleX=h[0][2],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=h[0][3],0==this.scaleY&&(this.scaleY=1E-5));h[1]&&2==h[1].length&&(this.centered=!0,this.scaleX=h[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=h[1][1],0==this.scaleY&&(this.scaleY=1E-5));if((r=l.evalExpression(this.file))||""==r)this.img=this.parent.getImage(r)};a.Image.prototype.draw=
function(){this.uber.draw.call(this)};a.Image.prototype.drawTrace=function(){this.uber.drawTrace.call(this)};a.Image.prototype.drawAux=function(b){l=this.evaluator;n=this.space;this.img&&(this.img.ready&&this.img.complete)&&(m=this.centered?0:this.img.width/2,q=this.centered?0:this.img.height/2,p=this.abs_coord?e(this.exprX):e(n.getAbsoluteX(this.exprX)),t=this.abs_coord?e(this.exprY):e(n.getAbsoluteY(this.exprY)),g=a.degToRad(-l.evalExpression(this.inirot)),b.translate(p+m,t+q),b.rotate(g),b.scale(this.scaleX,
this.scaleY),this.opacity&&(b.globalAlpha=l.evalExpression(this.opacity)),b.drawImage(this.img,-this.img.width/2,-this.img.height/2),b.setTransform(1,0,0,1,0,0),b.globalAlpha=1)};return a}(descartesJS||{}),descartesJS=function(a){function e(a,b,c){f=4*(b+c*a.width);return{r:a.data[f],g:a.data[f+1],b:a.data[f+2],a:a.data[f+3]}}if(a.loadLib)return a;var l,h,b,d,c,k,f;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){l=this.evaluator.evalExpression(this.expresion);
this.exprX=l[0][0];this.exprY=l[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,n){n.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(h=parseInt(this.exprX),b=parseInt(this.exprY)):(h=parseInt(this.space.getAbsoluteX(this.exprX)),b=parseInt(this.space.getAbsoluteY(this.exprY)));d=[{x:h,y:b}];for(k=e(imageData,h,b);0<d.length;){c=d.pop();h=c.x;
b=c.y;var l=e(imageData,h,b);if(k.r===l.r&&k.g===l.g&&k.b===l.b&&k.a===l.a){var l=imageData,q=n;f=4*(h+b*l.width);l.data[f+0]=q.r;l.data[f+1]=q.g;l.data[f+2]=q.b;l.data[f+3]=255-q.a;0<h&&d.push({x:h-1,y:b});h<imageData.width-1&&d.push({x:h+1,y:b});d.push({x:h,y:b-1});d.push({x:h,y:b+1})}}this.ctx.putImageData(imageData,0,0)};return a}(descartesJS||{}),descartesJS=function(a,e){if(a.loadLib)return a;a.Macro=function(l,h){this.expresion=void 0;this.inirot=l.evaluator.parser.parse("0");a.Graphic.call(this,
l,h);for(var b in h)h.hasOwnProperty(b)&&(this[b]=h[b]);this.graphics=[];b=l.lessonParser;var d=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 c=this.evaluator.evalExpression(this.expresion),k,f=2;c&&((k=document.getElementById(c))&&"descartes/macro"==k.type?(k=k.text,f=3):(k=a.openExternalFile(c))&&!k.match(/tipo_de_macro/g)&&(k=null));var r="|";if(k){k=k.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(f);for(var n,m,c=0,f=k.length;c<f;c++)k[c]&&(k[c]=b.split(k[c]),k[c]&&(k[c][0]&&
k[c][0][0]&&"id"===k[c][0][0])&&(n=k[c][0][1],m=n.indexOf("("),-1!=m&&(n=n.substring(0,m)),r+=n+"|"));for(var q,p,t,g,c=0,f=k.length;c<f;c++){q=k[c]||[];n=0;for(m=q.length;n<m;n++)if(p=e[q[n][0]],t=q[n][0].indexOf("."),-1!=t&&(p=e[q[n][0].substring(t+1)]),!("id"!=p&&void 0!=e[q[n][1]]))if("text"==p)if(q[n][1].match(/\{\\rtf1/)){p=q[n][1];var v=this;g=function(a,b){for(var c=d.tokenize(b.replace(/\&squot;/g,"'")),f=0,g=c.length;f<g;f++)if("identifier"==c[f].type&&r.match("\\|"+c[f].value+"\\|"))c[f].value=
v.name+"."+c[f].value;else if("identifier"==c[f].type&&-1!=(t=c[f].value.indexOf("."))&&r.match("\\|"+c[f].value.substring(0,t)+"\\|"))c[f].value=v.name+"."+c[f].value;return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+d.flatTokens(c)};p=p.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,g);p=p.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,g);q[n][1]=p}else{g=b.parseText(q[n][1]).textElementsMacros;for(var u=0,s=g.length;u<s;u++){p=d.tokenize(g[u].replace(/\&squot;/g,
"'"));for(var x=0,A=p.length;x<A;x++)"identifier"==p[x].type&&r.match("\\|"+p[x].value+"\\|")&&(p[x].value=this.name+"."+p[x].value);p=d.flatTokens(p).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");g[u]=p.substring(1,p.length-1)}q[n][1]=g.join("")}else{p=d.tokenize(q[n][1]);g=0;for(u=p.length;g<u;g++)if("identifier"==p[g].type&&r.match("\\|"+p[g].value+"\\|"))p[g].value=this.name+"."+p[g].value;else if("identifier"==p[g].type&&-1!=(t=p[g].value.indexOf("."))&&r.match("\\|"+p[g].value.substring(0,
t)+"\\|"))p[g].value=this.name+"."+p[g].value;q[n][1]=d.flatTokens(p)}}c=0;for(f=k.length;c<f;c++)if(k[c][0]){q="";p=!1;n=0;for(m=k[c].length;n<m;n++)"type"===e[k[c][n][0]]&&(q="espacio='"+this.spaceID+"' ",p=!0),q=q+k[c][n][0]+"='"+k[c][n][1]+"' ";k[c]=q;p?this.graphics.push(b.parseGraphic(k[c],this.abs_coord,this.background,this.inirot)):b.parseAuxiliar(k[c])}}}};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 e=0,b=this.graphics.length;e<b;e++)this.inipos&&(this.graphics[e].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale)),this.graphics[e].draw(),a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{},babel),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sqrt,l=Math.sin,h=Math.cos,b,d,c,k,f,r,n,m,q,p,t,g,v,u,s;a.norm3D=function(a){return e(a.x*
a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(c){b=a.norm3D(c);if(0===b)return{x:0,y:0,z:0};if(1===b)return{x:c.x,y:c.y,z:c.z};b=1/b;return{x:c.x*b,y:c.y*b,z:c.z*b}};a.dotProduct3D=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};a.crossProduct3D=function(a,b){return{x:a.y*b.z-a.z*b.y,y:a.z*b.x-a.x*b.z,z:a.x*b.y-a.y*b.x}};a.scalarProduct3D=function(a,b){return{x:a.x*b,y:a.y*b,z:a.z*b}};a.direction3D=function(a,b){return{x:a.x-b.x,y:a.y-b.y,z:a.z-b.z}};a.subtract3D=function(a,b){return{x:a.x-b.x,y:a.y-
b.y,z:a.z-b.z}};a.add3D=function(a,b){return{x:a.x+b.x,y:a.y+b.y,z:a.z+b.z}};a.Vector4D=function(a,b,c,f){this.x=a||0;this.y=b||0;this.z=c||0;this.w=f||0};a.Matrix4x4=function(a,b,c,f,g,d,k,e,n,h,l,m,r,p,u,q){this.a00=a||0;this.a01=b||0;this.a02=c||0;this.a03=f||0;this.a10=g||0;this.a11=d||0;this.a12=k||0;this.a13=e||0;this.a20=n||0;this.a21=h||0;this.a22=l||0;this.a23=m||0;this.a30=r||0;this.a31=p||0;this.a32=u||0;this.a33=q||0};a.Matrix4x4.prototype.setIdentity=function(){this.a00=1;this.a10=this.a03=
this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a13=this.a12=0;this.a22=1;this.a32=this.a31=this.a30=this.a23=0;this.a33=1;return this};a.Matrix4x4.prototype.multiplyVector4=function(b){return new a.Vector4D(b.x*this.a00+b.y*this.a10+b.z*this.a20+b.w*this.a30,b.x*this.a01+b.y*this.a11+b.z*this.a21+b.w*this.a31,b.x*this.a02+b.y*this.a12+b.z*this.a22+b.w*this.a32,b.x*this.a03+b.y*this.a13+b.z*this.a23+b.w*this.a33)};a.Matrix4x4.prototype.translate=function(b){return new a.Matrix4x4(this.a00,this.a01,
this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a00*b.x+this.a10*b.y+this.a20*b.z+this.a30,this.a01*b.x+this.a11*b.y+this.a21*b.z+this.a31,this.a02*b.x+this.a12*b.y+this.a22*b.z+this.a32,this.a03*b.x+this.a13*b.y+this.a23*b.z+this.a33)};a.Matrix4x4.prototype.rotateX=function(b){d=l(b);c=h(b);m=this.a10;q=this.a11;p=this.a12;t=this.a13;g=this.a20;v=this.a21;u=this.a22;s=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,m*c+g*d,q*c+v*
d,p*c+u*d,t*c+s*d,m*-d+g*c,q*-d+v*c,p*-d+u*c,t*-d+s*c,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){d=l(b);c=h(b);k=this.a00;f=this.a01;r=this.a02;n=this.a03;g=this.a20;v=this.a21;u=this.a22;s=this.a23;return new a.Matrix4x4(k*c+g*-d,f*c+v*-d,r*c+u*-d,n*c+s*-d,this.a10,this.a11,this.a12,this.a13,k*d+g*c,f*d+v*c,r*d+u*c,n*d+s*c,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(b){d=l(b);c=h(b);k=this.a00;f=this.a01;r=this.a02;n=this.a03;
m=this.a10;q=this.a11;p=this.a12;t=this.a13;return new a.Matrix4x4(k*c+m*d,f*c+q*d,r*c+p*d,n*c+t*d,k*-d+m*c,f*-d+q*c,r*-d+p*c,n*-d+t*c,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33)};return a}(descartesJS||{}),descartesJS=function(a){function e(a){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,d);a.fill();a.stroke()}function l(a,b){a.lineCap=c;a.lineJoin=k;a.beginPath();
a.moveTo(this.newV[0].x,this.newV[0].y);for(var f=1,d=this.newV.length;f<d;f++)a.lineTo(this.newV[f].x,this.newV[f].y);a.closePath();"color"===this.model?(a.fillStyle=0<=this.direction?this.backColor.getColor():this.frontColor.getColor(),a.fill()):"light"===this.model||"metal"===this.model?(a.fillStyle=0<=this.direction?b.computeColor(this.backColor,this,"metal"===this.model):b.computeColor(this.frontColor,this,"metal"===this.model),a.fill()):"wire"===this.model&&(a.lineWidth=1.25,a.strokeStyle=this.frontColor.getColor(),
a.stroke());this.edges&&"wire"!==this.model&&(a.lineWidth=1,a.strokeStyle="#808080",a.stroke())}function h(a){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 b(a){a.lineCap=c;a.lineJoin=k;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()}if(a.loadLib)return a;var d=
2*Math.PI,c="round",k="round",f,r,n,m,q;a.Primitive3D=function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);this.newV=[];"vertex"===this.type?this.draw=e:"face"===this.type?this.draw=l:"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,this.draw=h):"edge"===this.type&&(this.draw=b);this.isText&&(this.computeDepth=function(){this.newV=this.vertices;this.depth=this.vertices[0].z})};a.Primitive3D.prototype.computeDepth=function(b){this.average=
{x:0,y:0,z:0};for(var c=0,g=this.vertices.length;c<g;c++)this.newV[c]=b.rotateVertex(this.vertices[c]),this.average.x+=this.newV[c].x,this.average.y+=this.newV[c].y,this.average.z+=this.newV[c].z;this.average=a.scalarProduct3D(this.average,1/g);2<this.vertices.length&&(f=a.direction3D(this.newV[0],this.newV[1]),r=a.direction3D(this.newV[0],this.newV[2]),this.normal=a.normalize3D(a.crossProduct3D(f,r)),this.direction=a.dotProduct3D(this.normal,a.normalize3D(b.eye)));c=this.depth=0;for(g=this.vertices.length;c<
g;c++)this.newV[c]=b.project(this.newV[c]),this.depth+=this.newV[c].z;this.depth/=g};a.Primitive3D.prototype.drawText=function(b,c,f,d,k,e,h,l,r,y,E){if("rtfNode"==c.type)b.fillStyle=k,b.strokeStyle=k,b.textBaseline="alphabetic",c.draw(b,f,d,r,y,h,E);else{"simpleText"===c.type&&(c=c.toString(r,y).split("\\n"));f+=e.match("Arial")?-2:e.match("Times")?-2:0;n=this.evaluator;b.fillStyle=a.getColor(n,k);b.font=e;b.textAlign=h;b.textBaseline=l;m=1.2*this.fontSize||0;k=0;for(e=c.length;k<e;k++)q=c[k],this.border&&
b.strokeText(q,f,d+m*k),b.fillText(q,f,d+m*k)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e={x:0,y:0,z:0},l,h,b,d,c,k,f,r;a.Graphic3D=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=b.evaluator.parser;this.spaceID="E0";this.background=!1;this.type="";this.color=new a.Color("eeffaa");this.backcolor=new a.Color("6090a0");this.Nu=this.evaluator.parser.parse("7");this.Nv=this.evaluator.parser.parse("7");this.drawif=f.parse("1");this.abs_coord=!1;this.family=
"";this.family_interval=f.parse("[0,1]");this.family_steps=f.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=f.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=f.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=f.parse("(0,0,0)");this.model="color";for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=f.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?
this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10;this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&(this.endrot=this.endrot.replace("Euler",""),this.endrotEuler=!0);this.inirot=f.parse(this.inirot);this.endrot=f.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=
new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4};a.Graphic3D.prototype.getSpace=function(){for(var a=this.parent.spaces,b,c=0,f=a.length;c<f;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){l=this.evaluator;h=l.evalExpression(this.family_interval);
this.familyInf=h[0][0];this.familySup=h[0][1];this.fSteps=Math.round(l.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){l=this.evaluator;this.getFamilyValues();b=l.getVariable(this.family);if(0<=this.fSteps)for(var a=0,c=this.fSteps;a<=c;a++)l.setVariable(this.family,this.familyInf+a*this.family_sep),l.evalExpression(this.drawif)&&this.buildPrimitives();l.setVariable(this.family,b)};
a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.evalExpression(this.drawif)&&(this.family?this.buildFamilyPrimitives():this.buildPrimitives())};a.Graphic3D.prototype.updateMVMatrix=function(b){c=this.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(c[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(c[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(c[0][2]))):(this.inirotM_X=
this.inirotM_X.setIdentity().rotateX(a.degToRad(c[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(c[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(c[0][2])));c=this.evaluator.evalExpression(this.inipos);e={x:c[0][0],y:c[0][1],z:c[0][2]};this.iniposM=this.iniposM.setIdentity().translate(e);c=this.evaluator.evalExpression(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(c[0][0])),this.endrotM=
this.endrotM.rotateX(a.degToRad(c[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(c[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(c[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(c[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(c[0][2])));c=this.evaluator.evalExpression(this.endpos);e={x:c[0][0],y:c[0][1],z:c[0][2]};this.endposM=this.endposM.setIdentity().translate(e)};a.Graphic3D.prototype.transformVertex=function(a){this.inirotEuler?
d=this.inirotM.multiplyVector4(a):(d=this.inirotM_X.multiplyVector4(a),d=this.inirotM_Y.multiplyVector4(d),d=this.inirotM_Z.multiplyVector4(d));d=this.iniposM.multiplyVector4(d);this.endrotEuler?d=this.endrotM.multiplyVector4(d):(d=this.endrotM_X.multiplyVector4(d),d=this.endrotM_Y.multiplyVector4(d),d=this.endrotM_Z.multiplyVector4(d));return d=this.endposM.multiplyVector4(d)};a.Graphic3D.prototype.parseExpression=function(){c=this.expresion.split("=");k=c[0];f=[];for(var a=1;a<c.length;a++)k+="=",
r=c[a].lastIndexOf(" "),k+=-1!==r?c[a].substring(0,r):c[a],f.push(this.evaluator.parser.parse(k,!0)),k=c[a].substring(r+1);return f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d;a.Point3D=function(b,d){a.Graphic3D.call(this,b,d)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();l=e.evalExpression(this.expresion);h=l[0][0];b=l[0][1];d=l[0][2];this.primitives=[];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,
b,d,1))],type:"vertex",backColor:this.backcolor,frontColor:this.color,size:e.evalExpression(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,b,d,1))],type:"text",frontColor:this.color,font:this.font,decimals:e.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize,evaluator:e,text:this.text}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c;a.Segment3D=function(b,c){this.width=
b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c)};a.extend(a.Segment3D,a.Graphic3D);a.Segment3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=expr[0][0];l=expr[0][1];h=expr[0][2];b=expr[1][0];d=expr[1][1];c=expr[1][2];this.primitives=[];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,l,h,1)),this.transformVertex(new a.Vector4D(b,d,c,1))],type:"edge",frontColor:this.color,
lineWidth:evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c,k;a.Surface3D=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");a.Graphic3D.call(this,b,c);this.expresion=this.parseExpression()};a.extend(a.Surface3D,a.Graphic3D);a.Surface3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();h=e.getVariable("x");
h=e.getVariable("y");h=e.getVariable("z");l=e.getVariable("u");h=e.getVariable("v");e.setVariable("u",0);e.setVariable("v",0);b=e.evalExpression(this.Nu);d=e.evalExpression(this.Nv);c=[];for(var f=0;f<=b;f++){e.setVariable("u",f/b);for(var r=0;r<=d;r++){e.setVariable("v",r/d);for(var n=0,m=this.expresion.length;n<m;n++)e.evalExpression(this.expresion[n]);c.push(this.transformVertex(new a.Vector4D(e.getVariable("x"),e.getVariable("y"),e.getVariable("z"),1)))}}this.primitives=[];for(f=0;f<b;f++)for(r=
0;r<d;r++)k=[],k.push(c[r+f*d+f]),k.push(c[r+1+f*d+f]),k.push(c[r+2+(f+1)*d+f]),k.push(c[r+1+(f+1)*d+f]),this.primitives.push(new a.Primitive3D({vertices:k,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}));e.setVariable("x",void 0);e.setVariable("y",void 0);e.setVariable("z",void 0);e.setVariable("u",l);e.setVariable("v",h)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c;a.Polygon3D=function(b,c){this.width=b.evaluator.parser.parse("1");
a.Graphic3D.call(this,b,c)};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);this.primitives=[];for(var k=0,f=expr.length-1;k<f;k++)e=expr[k][0],l=expr[k][1],h=expr[k][2],b=expr[k+1][0],d=expr[k+1][1],c=expr[k+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,l,h,1)),this.transformVertex(new a.Vector4D(b,d,c,1))],type:"edge",frontColor:this.color,
lineWidth:evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c;a.Curve3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c);this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();b=evaluator.getVariable("x");d=evaluator.getVariable("y");c=evaluator.getVariable("z");h=evaluator.getVariable("u");
evaluator.setVariable("u",0);l=evaluator.evalExpression(this.Nu);e=[];for(var k=0;k<=l;k++){evaluator.setVariable("u",k/l);for(var f=0,r=this.expresion.length;f<r;f++)evaluator.evalExpression(this.expresion[f]);e.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}this.primitives=[];k=0;for(f=e.length-1;k<f;k++)this.primitives.push(new a.Primitive3D({vertices:[e[k],e[k+1]],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}));
evaluator.setVariable("x",b);evaluator.setVariable("y",c);evaluator.setVariable("z",d);evaluator.setVariable("u",h)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c,k,f,r;a.Triangle3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=expr[0][0];l=expr[0][1];h=expr[0][2];b=expr[1][0];d=expr[1][1];
c=expr[1][2];k=expr[2][0];f=expr[2][1];r=expr[2][2];this.primitives=[];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,l,h,1)),this.transformVertex(new a.Vector4D(k,f,r,1)),this.transformVertex(new a.Vector4D(b,d,c,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 e;a.Face3D=function(e,h){a.Graphic3D.call(this,e,h)};a.extend(a.Face3D,
a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=[];for(var l=expr.length-1;0<=l;l--)e.push(this.transformVertex(new a.Vector4D(expr[l][0],expr[l][1],expr[l][2],1)));this.primitives=[];this.primitives.push(new a.Primitive3D({vertices:e,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 e,l,h,b,d;a.Polireg3D=function(b,d){this.width=b.evaluator.parser.parse("2");this.length=b.evaluator.parser.parse("2");a.Graphic3D.call(this,b,d)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();e=evaluator.evalExpression(this.Nu);l=[this.transformVertex(new a.Vector4D(0,0,0,1))];h=evaluator.evalExpression(this.width)/2;b=evaluator.evalExpression(this.length)/2;d=2*Math.PI/e;for(var c=0;c<e;c++)l.push(this.transformVertex(new a.Vector4D(h*
Math.cos(d*c),b*Math.sin(d*c),0,1)));this.primitives=[];for(c=0;c<e;c++)this.primitives.push(new a.Primitive3D({vertices:[l[0],c+2<=e?l[c+2]:l[1],l[c+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 e,l,h,b;a.Text3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=function(){e=this.evaluator;l=e.evalExpression(this.expresion);
h=l[0][0];b=l[0][1];this.primitives=[];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(h,b,0,1)],type:"text",frontColor:this.color,font:this.font,decimals:e.evalExpression(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:e,text:this.text}))};return a}(descartesJS||{}),descartesJS=function(a){function e(a,b,c,f,g){l.call(this,a/1.8,a/1.8,a/1.8,f,g)}function l(a,b,c,f,d){a/=2;b/=2;c/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new g(a,c,b,1),new g(a,-c,b,1),new g(a,
c,-b,1),new g(a,-c,-b,1),new g(-a,c,b,1),new g(-a,-c,b,1),new g(-a,c,-b,1),new g(-a,-c,-b,1)],this.faces=[[2,3,1,0],[1,5,4,0],[5,7,6,4],[6,7,3,2],[4,6,2,0],[3,7,5,1]],this.updateValues(a,b,c,f,d))}function h(a,b,c,f,d){a/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new g(0,0,a,1),new g(-0.49*a,-0.86*a,-0.32*a,1),new g(-0.49*a,0.86*a,-0.32*a,1),new g(1*a,0,-0.32*a,1)],this.faces=[[3,2,1],[1,2,0],[2,3,0],[3,1,0]],this.updateValues(a,b,c,f,d))}function b(a,b,c,f,d){a/=2;this.changeGeometry(a,b,
c,f,d)||(this.vertices=[new g(0,0,a,1),new g(a,0,0,1),new g(-a,0,0,1),new g(0,a,0,1),new g(0,-a,0,1),new g(0,0,-a,1)],this.faces=[[3,1,0],[2,3,0],[1,4,0],[4,2,0],[1,3,5],[3,2,5],[4,1,5],[2,4,5]],this.updateValues(a,b,c,f,d))}function d(b,c,f,d,k){b/=3.4;if(!this.changeGeometry(b,c,f,d,k)){D=b/E;B=b*E;this.vertices=[new g(b,b,b,1),new g(b,b,-b,1),new g(b,-b,b,1),new g(b,-b,-b,1),new g(-b,b,b,1),new g(-b,b,-b,1),new g(-b,-b,b,1),new g(-b,-b,-b,1),new g(0,D,B,1),new g(0,D,-B,1),new g(0,-D,B,1),new g(0,
-D,-B,1),new g(D,B,0,1),new g(D,-B,0,1),new g(-D,B,0,1),new g(-D,-B,0,1),new g(B,0,D,1),new g(B,0,-D,1),new g(-B,0,D,1),new g(-B,0,-D,1)];z=(new a.Matrix4x4).setIdentity().rotateY(-p/6);for(var e=0,h=this.vertices.length;e<h;e++)this.vertices[e]=z.multiplyVector4(this.vertices[e]);this.faces=[[0,16,2,10,8],[12,1,17,16,0],[8,4,14,12,0],[2,16,17,3,13],[13,15,6,10,2],[6,18,4,8,10],[3,17,1,9,11],[13,3,11,7,15],[1,12,14,5,9],[11,9,5,19,7],[5,14,4,18,19],[6,15,7,19,18]];this.updateValues(b,c,f,d,k)}}function c(b,
c,f,d,k){b/=4;if(!this.changeGeometry(b,c,f,d,k)){B=b*E;this.vertices=[new g(0,b,B,1),new g(0,b,-B,1),new g(0,-b,B,1),new g(0,-b,-B,1),new g(b,B,0,1),new g(b,-B,0,1),new g(-b,B,0,1),new g(-b,-B,0,1),new g(B,0,b,1),new g(B,0,-b,1),new g(-B,0,b,1),new g(-B,0,-b,1)];this.faces=[[10,0,2],[0,8,2],[8,5,2],[5,7,2],[7,10,2],[6,0,10],[11,6,10],[7,11,10],[7,3,11],[5,3,7],[9,3,5],[8,9,5],[4,9,8],[0,4,8],[6,4,0],[11,3,1],[6,11,1],[4,6,1],[9,4,1],[3,9,1]];z=(new a.Matrix4x4).setIdentity().rotateY(-1.029);for(var e=
0,h=this.vertices.length;e<h;e++)this.vertices[e]=z.multiplyVector4(this.vertices[e]);this.updateValues(b,c,f,d,k)}}function k(a,b,c,f,d){a/=2;this.isSphere?c=b=a:(b/=2,c/=2);if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[new g(0,0,b,1)];for(var k=1;k<f;k++){y=k*p/f;for(var e=0;e<d;e++)C=e*t/d,s=a*m(y)*q(C),x=c*m(y)*m(C),A=b*q(y),this.vertices.push(new g(s,x,A,1))}this.vertices.push(new g(0,0,-b,1));this.faces=[];for(k=0;k<d;k++)this.faces.push([0,(k+1)%d+1,k%d+1]);for(k=1;k<f-1;k++)for(e=0;e<
d;e++)this.faces.push([e+1+(k-1)*d,(e+1)%d+1+(k-1)*d,(e+1)%d+1+k*d,e+1+k*d]);for(k=0;k<d;k++)this.faces.push([this.vertices.length-1,this.vertices.length-1-d+k,this.vertices.length-1-d+(k+1)%d]);this.updateValues(a,b,c,f,d)}}function f(a,b,c,f,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[];for(var k=0;k<d;k++)for(var e=0;e<f;e++)s=a*(d-k)/d*q(e*t/f),x=c*(d-k)/d*m(e*t/f),A=b-2*k*b/d,this.vertices.push(new g(s,x,A,1));this.vertices.push(new g(0,0,-b,1));this.faces=[];for(k=0;k<
d-1;k++)for(e=0;e<f;e++)this.faces.push([e+k*f,(e+1)%f+k*f,(e+1)%f+(k+1)*f,e+(k+1)*f]);for(k=0;k<f;k++)this.faces.push([this.vertices.length-1,this.vertices.length-1-f+k,this.vertices.length-1-f+(k+1)%f]);this.updateValues(a,b,c,f,d)}}function r(a,b,c,f,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[];for(var k=0;k<d+1;k++)for(var e=0;e<f;e++)s=a*q(e*t/f),x=c*m(e*t/f),A=b-2*k*b/d,this.vertices.push(new g(s,x,A,1));this.faces=[];for(k=0;k<d;k++)for(e=0;e<f;e++)this.faces.push([e+
k*f,(e+1)%f+k*f,(e+1)%f+(k+1)*f,e+(k+1)*f]);this.updateValues(a,b,c,f,d)}}function n(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];for(var c=0,f=this.fileData.length;c<f;c++)I=this.fileData[c],I.match(/^V\(/)?(G=I.substring(2,I.length-1).split(",").map(b),this.vertices.push(new g(G[0]||0,G[1]||0,G[2]||0,1))):I.match(/^F\(/)&&(G=I.substring(2,I.length-1).split(",").map(a),this.faces.push(G.reverse()))}if(a.loadLib)return a;var m=Math.sin,q=Math.cos,
p=Math.PI,t=2*p,g,v,u,s,x,A,C,y,E=1.6180339887,D,B,z,I,G;a.OtherGeometry=function(m,p){this.width=m.evaluator.parser.parse("2");this.height=m.evaluator.parser.parse("2");this.length=m.evaluator.parser.parse("2");g=a.Vector4D;a.Graphic3D.call(this,m,p);switch(this.type){case "cube":this.buildGeometry=e;break;case "box":this.buildGeometry=l;break;case "tetrahedron":this.buildGeometry=h;break;case "octahedron":this.buildGeometry=b;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=
k;break;case "dodecahedron":this.buildGeometry=d;break;case "icosahedron":this.buildGeometry=c;break;case "cone":this.buildGeometry=f;break;case "cylinder":this.buildGeometry=r;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=n}};a.extend(a.OtherGeometry,a.Graphic3D);a.OtherGeometry.prototype.buildPrimitives=function(){v=this.evaluator;this.updateMVMatrix();this.buildGeometry(v.evalExpression(this.width),v.evalExpression(this.height),
v.evalExpression(this.length),v.evalExpression(this.Nu),v.evalExpression(this.Nv));this.primitives=[];for(var b=0,c=this.faces.length;b<c;b++){u=[];for(var f=0,d=this.faces[b].length;f<d;f++)u.push(this.transformVertex(this.vertices[this.faces[b][f]]));this.primitives.push(new a.Primitive3D({vertices:u,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}))}};a.OtherGeometry.prototype.changeGeometry=function(a,b,c,f,d){return this.oldWidth===a&&this.oldHeight===
b&&this.oldLength===c&&this.oldNu===f&&this.oldNv===d};a.OtherGeometry.prototype.updateValues=function(a,b,c,f,d){this.oldWidth=a;this.oldHeight=b;this.oldLength=c;this.oldNv=d;this.oldNu=f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.max,l=Math.min,h=Math.PI,b=Math.cos,d=Math.sin,c=Math.abs,k,f,r,n,m,q,p,t,g,v,u,s,x,A,C,y,E,D;a.R2=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.set=function(a,b){this.x=a||0;this.y=b||0};a.R2.prototype.copy=function(){return new a.R2(this.x,
this.y)};a.R2.prototype.ix=function(){return Math.round(e(l(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(e(l(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){f=this.copy();f.sub(a);return f.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(){k=this.norm();0!=k&&this.div(k)};a.R2.prototype.rotR90=function(){k=this.x;this.x=this.y;this.y=-k};a.R2.prototype.rotL90=function(){k=this.x;this.x=-this.y;this.y=k};a.R2.prototype.rot=function(a){r=this.copy();
q=b(a);p=d(a);this.x=r.x*q-r.y*p;this.y=r.x*p+r.y*q};a.R2.prototype.rot=function(a){this.rot(a*h/180)};a.R2.prototype.intersection=function(b,f,d,k){t=f.x-b.x;g=d.x-k.x;v=d.x-b.x;u=f.y-b.y;s=d.y-k.y;x=d.y-b.y;D=t*s-g*u;return 1E-6<c(D)?(n=(v*s-x*g)/D,m=(-v*u+x*t)/D,0<=n&&1>=n&&0<=m&&1>=m?new a.R2(b.x+t*n,b.y+u*n):null):(f.x-d.x)*x!=(f.y-d.y)*v?null:b.x!=f.x?(A=l(b.x,f.x),C=e(b.x,f.x),A<=d.x&&d.x<=C?d:A<=k.x&&k.x<=C?k:null):d.x!=k.x?(y=l(d.x,k.x),E=e(d.x,k.x),y<=b.x&&b.x<=E?b:y<=f.x&&f.x<=E?f:null):
b.y!=f.y?(A=l(b.y,f.y),C=e(b.y,f.y),A<=d.y&&d.y<=C?d:A<=k.y&&k.y<=C?k:null):d.y!=k.y?(y=l(d.y,k.y),E=e(d.y,k.y),y<=b.y&&b.y<=E?b:y<=f.y&&f.y<=E?f:null):b.x==d.x&&b.y==d.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c,k,f;a.R2Newton=function(b,f){this.evaluator=b;this.constraint=f;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];c=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return this.normal.copy()};a.R2Newton.prototype.gradient=function(a){e=this.evaluator;k=e.getVariable("x");f=e.getVariable("y");e.setVariable("x",a.x);e.setVariable("y",a.y);this.f0=e.evalExpression(this.constraint);e.setVariable("x",
e.getVariable("x")+1E-12);l=e.evalExpression(this.constraint);c.x=(l-this.f0)/1E-12;c.x=!isNaN(c.x)?c.x:Infinity;e.setVariable("x",e.getVariable("x")-1E-12);e.setVariable("y",e.getVariable("y")+1E-12);l=e.evalExpression(this.constraint);c.y=(l-this.f0)/1E-12;c.y=!isNaN(c.y)?c.y:Infinity;e.setVariable("x",k);e.setVariable("y",f);return c};a.R2Newton.prototype.findZero=function(a){e=this.evaluator;d=a.copy();k=e.getVariable("x");f=e.getVariable("y");e.setVariable("x",a.x);e.setVariable("y",a.y);this.f0=
e.evalExpression(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return d;e.setVariable("x",k);e.setVariable("y",f);for(var c=0;256>c;c++)if(h=d.x,b=d.y,this.normal=this.gradient(d),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),d.x=h+this.normal.x,d.y=b+this.normal.y,1E-6>this.normal.norm()){0===this.normal.x&&0===this.normal.y&&(this.normal.x=d.x-a.x,this.normal.y=d.y-a.y);break}return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.Vector2D=function(a,l){this.x=a;this.y=l};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 e=Math.floor,
l=Math.round,h,b,d,c,k,f,r,n,m,q,p,t,g,v,u,s,x,A,C,y;a.Control=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=this.parser=b.evaluator.parser;this.id="graphic"!==c.type?"C":"G";this.gui=this.type="";this.region="south";this.y=this.x=0;this.w="video"!==c.type?100:350;this.h="video"!==c.type?23:120;"graphic"!==c.type?"text"!==c.type?this.expresion=f.parse("(0,0,100,23)"):(this.expresion=f.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=f.parse("(0,0)");this.fixed=2!=this.parent.version?
!1:!0;this.visible=!0;this.color=4>this.parent.version?new a.Color("000000"):new a.Color("222222");this.colorInt="graphic"!==c.type?new a.Color("f0f8ff"):new a.Color("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 d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);if(("video"===this.type||"audio"===this.type)&&"interior"!==this.region)this.region="interior";void 0==this.name&&(this.name=2==this.parent.version?this.id:"_nada_");this.name="_._"==this.name||"_nada_"==this.name||"_void_"==this.name?"":this.name;
f=this.evaluator.evalExpression(this.expresion);this.x=l(f[0][0]);this.y=l(f[0][1]);4==f[0].length&&(this.w=l(f[0][2]),this.h=l(f[0][3]));this.actionExec=b.lessonParser.parseAction(this)};a.Control.prototype.init=function(){};a.Control.prototype.update=function(){};a.Control.prototype.draw=function(){};a.Control.prototype.getContainer=function(){var a=this.parent.spaces,b;if("interior"===this.region)for(var c=0,f=a.length;c<f;c++){if(b=a[c],b.id===this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,
b.numericalControlContainer}else{if("external"===this.region)return this.parent.externalSpace.container;if("scenario"===this.region)return this.cID?(this.expresion=this.evaluator.parser.parse("(0,-1000,"+this.w+","+this.h+")"),this.parent.scenarioRegion.scenarioSpace.addCtr(this),this.zIndex=this.parent.scenarioRegion.scenarioSpace.zIndex,this.parent.scenarioRegion.scenarioSpace.numericalControlContainer):this.parent.externalSpace.container;if("north"===this.region)return this.parent.northSpace.controls.push(this),
this.parent.northSpace.container;if("south"===this.region)return this.parent.southSpace.controls.push(this),this.parent.southSpace.container;if("east"===this.region)return this.parent.eastSpace.controls.push(this),this.parent.eastSpace.container;if("west"===this.region)return this.parent.westSpace.controls.push(this),this.parent.westSpace.container;if("special"===this.region)return this.parent.specialSpace.controls.push(this),this.parent.specialSpace.container}a[0].addCtr(this);this.zIndex=a[0].zIndex;
return a[0].numericalControlContainer};a.Control.prototype.addControlContainer=function(a){var b=this.getContainer();b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a);b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){d=c=k=f=!1;r=this.evaluator.evalExpression(this.expresion);n=l(r[0][0]);d=l(this.x)!==n;this.x=n;n=l(r[0][1]);c=l(this.y)!==n;this.y=n;4===r[0].length&&(n=l(r[0][2]),k=l(this.w)!==n,this.w=n,n=l(r[0][3]),
f=l(this.h)!==n,this.h=n);if(k||f||d||c)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){g=this.parent;m=a+"";q=this.evaluator.evalExpression(this.decimals);p=m.indexOf(".");-1!=p&&(t=m.substring(p+1),t.length>q&&(m=parseFloat(m).toFixed(q)));if(this.fixed&&(2!==g.version||2===g.version&&!this.exponentialif))m=parseFloat(a).toFixed(q);this.exponentialif&&0!=parseFloat(m)&&(m=this.fixed&&2!==g.version?parseFloat(m).toExponential(q):parseFloat(m).toExponential(),m=m.toUpperCase(),
m=m.replace("+",""));return m=m.replace(".",g.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();"init"===this.action&&(this.click=!1);this.actionExec.execute();"animate"!==this.action&&this.parent.update()};a.Control.prototype.createGradient=function(a,c){this.linearGradient=this.ctx.createLinearGradient(0,0,0,c);h=c*c;for(var f=0;f<c;f++)b=e(f-35*c/100),this.linearGradient.addColorStop(f/c,"rgba(0,0,0,"+192*b*b/h/255+")")};a.Control.prototype.getScreenshot=
function(){s=this;v=document.createElement("canvas");v.setAttribute("width",s.w);v.setAttribute("height",s.h);u=v.getContext("2d");u.font=s.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";s.canvas&&(x=s.canvas.offsetLeft,A=s.canvas.offsetTop,u.drawImage(s.canvas,x,A));s.label&&(x=s.label.offsetLeft,A=s.label.offsetTop,C=s.label.offsetWidth,y=s.label.offsetHeight,u.fillStyle="#e0e4e8",u.fillRect(x,A,C,y),u.fillStyle="black",u.textAlign="center",u.textBaseline="middle",u.fillText(s.name,
x+C/2,A+y/2));s.field&&(x=s.field.offsetLeft,A=s.field.offsetTop,C=s.field.offsetWidth,y=s.field.offsetHeight,u.fillStyle="white",u.strokeStyle="#666666",u.lineWidth=1,u.fillRect(x,0,C,y),u.strokeRect(x+0.5,0.5,C-1,y-1),u.fillStyle="black",u.textAlign="center",u.textAlign="left",u.fillText(s.field.value,x+2,y/2));s.select&&(x=s.select.offsetLeft,A=s.select.offsetTop,C=s.select.offsetWidth,y=s.select.offsetHeight,u.fillStyle="#e0e4e8",u.strokeStyle="#666666",u.lineWidth=1,u.fillRect(x,0,C,y),u.strokeRect(x+
0.5,0.5,C,y-1),u.fillStyle="black",u.textAlign="center",u.textAlign="left",u.fillText(s.select.value,x+2,y/2),u.fillStyle="#c0c0c0",u.fillRect(x+C-15+0.5,0.5,15,y-1),u.strokeRect(x+C-15+0.5,0.5,15,y-1),u.fillStyle="black",u.beginPath(),u.moveTo(x+C-15+4.5,y/2-2.5),u.lineTo(x+C-15+8,y/2+2.5),u.lineTo(x+C-15+11.5,y/2-2.5),u.closePath(),u.fill());return v};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,l,h,b,d,c,k,f,r,n,m,q,p,t=900;a.Button=function(b,c){this.imageSrc=
"";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;a.Control.call(this,b,c);-1===this.font_size&&(this.fontSizeNotSet=!0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");var f;this.imageSrc.match("_COLORES_")&&(f=this.imageSrc.split("_"),this.colorInt=new a.Color(f[2]),this.color=new a.Color(f[3]),this.font_size=this.parser.parse(f[5]),
this.imageSrc="");this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");f=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=f){var d=f.substr(0,f.lastIndexOf(".")),k=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(d+"_over"+k),this.imageDown=this.parent.getImage(d+
"_down"+k))}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(){l=this.evaluator;h=this.canvas;d=l.evalExpression(this.expresion);this.x=d[0][0];this.y=d[0][1];4==d[0].length&&(this.w=parseInt(d[0][2]),this.h=parseInt(d[0][3]));h.setAttribute("width",this.w+"px");h.setAttribute("height",this.h+"px");h.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+"; display: block;");this.fontSizeNotSet&&(this.font_size=l.parser.parse(a.getFieldFontSize(this.h)+
""));this.createGradient(this.w,this.h)};a.Button.prototype.update=function(){l=this.evaluator;h=this.canvas;this.activeIfValue=0<l.evalExpression(this.activeif);(this.drawIfValue=0<l.evalExpression(this.drawif))?(h.style.display="block",this.draw()):(this.click=!1,h.style.display="none");this.updatePositionAndSize()};a.Button.prototype.draw=function(){l=this.evaluator;b=this.ctx;c=l.evalExpression(this.font_size);k=l.evalExpression(this.name);f=l.evalExpression(this.imageSrc);r="vacio.gif"===f?this.emptyImage:
this.parent.getImage(f);b.clearRect(0,0,this.w,this.h);m=n=0;this.click&&(m=n=1);r&&r.ready?r!==this.emptyImage&&r.complete&&b.drawImage(r,parseInt((this.w-r.width)/2)+n,parseInt((this.h-r.height)/2)+m):(b.fillStyle=this.colorInt.getColor(),b.fillRect(0,0,this.w,this.h),this.click||(a.drawLine(b,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,"+128/255+")"),a.drawLine(b,0,0,0,this.h,"rgba(0,0,0,"+24/255+")"),a.drawLine(b,1,0,1,this.h,"rgba(0,0,0,"+8/255+")")),b.fillStyle=this.linearGradient,b.fillRect(0,0,
this.w,this.h));""!=this.imageOver.src&&(this.imageOver.ready&&this.over)&&b.drawImage(this.imageOver,parseInt((this.w-r.width)/2)+n,parseInt((this.h-r.height)/2)+m);""!=this.imageDown.src&&this.imageDown.ready&&this.click?b.drawImage(this.imageDown,parseInt((this.w-r.width)/2)+n,parseInt((this.h-r.height)/2)+m):this.click&&(a.drawLine(b,0,0,0,this.h-2,"gray"),a.drawLine(b,0,0,this.w-1,0,"gray"),b.fillStyle="rgba(0, 0, 0,"+24/255+")",b.fillRect(0,0,this.w,this.h));b.fillStyle=this.color.getColor();
b.font=this.italics+" "+this.bold+" "+c+"px Arial";b.textAlign="center";b.textBaseline="middle";this.colorInt!=this.color&&(b.lineJoin="round",b.lineWidth=parseInt(c/6),b.strokeStyle=this.colorInt.getColor(),b.strokeText(k,e(this.w/2+n)+0.5,e(this.h/2+m)+0.5));b.fillText(k,e(this.w/2+n)+0.5,e(this.h/2+m)+0.5);this.underlined&&(q=b.measureText(k).width,b.strokeStyle=this.color.getColor(),b.lineWidth=e(c/10)||2,b.lineCap="round",b.beginPath(),b.moveTo(parseInt((this.w-q)/2)+n,e((this.h+c)/2)+e(c/5)-
1.5+m),b.lineTo(parseInt((this.w+q)/2)+n,e((this.h+c)/2)+e(c/5)-1.5+m),b.stroke());this.activeIfValue||(b.fillStyle="rgba(240,240,240,"+160/255+")",b.fillRect(0,0,this.w,this.h))};a.Button.prototype.bottonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f){clearInterval(h);e.click&&(c.call(e),a=f?a:30,h=setTimeout(function(){b(a,c)},a))}function c(d){d.preventDefault();e.whichButton=a.whichButton(d);"L"==e.whichButton&&e.activeIfValue&&
(e.click=!0,e.draw(),e.evaluator.setVariable(e.id,e.evaluator.evalExpression(e.valueExpr)),"calculate"==e.action&&b(t,e.bottonPressed,!0),p?window.addEventListener("touchend",f):window.addEventListener("mouseup",f))}function f(a){if(e.activeIfValue||e.click)e.click=!1,e.draw(),"calculate"!=e.action&&e.bottonPressed(),a.preventDefault(),p?window.removeEventListener("touchend",f,!1):window.removeEventListener("mouseup",f,!1)}function d(a){e.over=!0;e.draw()}function k(a){e.over=!1;e.click=!1;e.draw()}
p=a.hasTouchSupport;var e=this,h;e.canvas.oncontextmenu=function(){return!1};this.over=this.click=!1;p?this.canvas.addEventListener("touchstart",c):(this.canvas.addEventListener("mousedown",c),this.canvas.addEventListener("mouseover",d),this.canvas.addEventListener("mouseout",k))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c,k,f,r,n,m,q,p,t,g,v,u;a.Spinner=function(b,c){a.Control.call(this,
b,c);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(){e=this.evaluator;this.value=this.validateValue(e.evalExpression(this.valueExpr));var b=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var c=2!==this.parent.version?"":"_____",f=a.getTextWidth(b+"_",this.fieldFontSize+"px Arial"),d=2+parseInt(this.h/2),k=parseInt(this.w/2-d/2),c=a.getTextWidth(this.name+c,this.fieldFontSize+"px Arial");this.visible||(k=this.w-d,f=0);k<c&&(k=c);""==this.name&&
(k=0);this.w-k-d<f&&(k=this.w-d-f);0>k&&(k=0);c=this.w-(k+d);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",d+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+k+"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 : "+d+"px; height : "+this.h/2+"px; left: "+k+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+d+"px; height : "+this.h/2+"px; left: "+k+"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 : "+(c-2)+"px; height : "+(this.h-2)+"px; left: "+(d+k)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=b;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+k+"px; height: "+this.h+"px; line-height: "+this.h+"px;");e.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){e=
this.evaluator;0>=e.evalExpression(this.decimals)?(l=e.evalExpression(this.incr),0<l?this.originalIncr=this.incr=e.parser.parse(parseInt(l).toString()):this.incr=e.parser.parse("1")):this.incr=this.originalIncr;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.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();
h=this.field.value;b=this.value;this.value=this.validateValue(e.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value==b&&this.field.value!=h&&(this.value=this.validateValue(h),this.field.value=this.formatOutputValue(this.value));e.setVariable(this.id,this.value)};a.Spinner.prototype.draw=function(){d=this.ctx;c=this.canvas.width;k=this.canvas.height;d.fillStyle="#f0f8ff";d.fillRect(0,0,c,k);d.fillStyle=this.linearGradient;d.fillRect(0,0,c,k);this.up?(f="gray",r="#f0f8ff"):
(f="#f0f8ff",r="gray");a.drawLine(d,0,0,c,0,f);a.drawLine(d,0,0,0,k/2,f);a.drawLine(d,0,k/2,c,k/2,r);this.down?(f="gray",r="#f0f8ff"):(f="#f0f8ff",r="gray");a.drawLine(d,0,k/2+1,c,k/2+1,f);a.drawLine(d,0,k/2+1,0,k,f);a.drawLine(d,0,k-1,c,k-1,r);n=[parseInt(c/2+1),parseInt(c/5+1),parseInt(c-c/5+1)];m=[parseInt(k/8+1),parseInt(k/8+1+k/4),parseInt(k/8+1+k/4)];d.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";d.beginPath();d.moveTo(n[0],m[0]);d.lineTo(n[1],m[1]);d.lineTo(n[2],m[2]);d.fill();m=[parseInt(k-
k/8),parseInt(k-k/8-k/4),parseInt(k-k/8-k/4)];d.fillStyle=this.activeIfValue?"#d00018":"#aa8888";d.beginPath();d.moveTo(n[0],m[0]);d.lineTo(n[1],m[1]);d.lineTo(n[2],m[2]);d.fill();d.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&d.fillRect(0,0,c,k/2);this.down&&d.fillRect(0,k/2,c,k)};a.Spinner.prototype.validateValue=function(a){e=this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=a.toString();q=parseFloat(e.evalExpression(e.parser.parse(a.replace(this.parent.decimal_symbol,
"."))));isNaN(q)&&(q=0);g=e.evalExpression(this.min);v=e.evalExpression(this.max);""===g&&(g=-Infinity);""===v&&(v=Infinity);q<g&&(q=g);q>v&&(q=v);this.discrete&&(p=e.evalExpression(this.incr),q=0==p?0:p*Math.round(q/p));t=e.evalExpression(this.decimals);0>=t&&(t=0);return q=parseFloat(parseFloat(q).toFixed(t))};a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-
this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.changeValue=function(a){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Spinner.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f){clearInterval(l);if(h.up||h.down)c.call(h),a=f?a:30,l=setTimeout(function(){b(a,c)},a)}function c(f){f.preventDefault();h.whichButton=a.whichButton(f);"L"==
h.whichButton&&h.activeIfValue&&(h.up=!0,b(n,h.increase,!0),h.draw())}function f(c){c.preventDefault();h.whichButton=a.whichButton(c);"L"==h.whichButton&&h.activeIfValue&&(h.down=!0,b(n,h.decrease,!0),h.draw())}function d(a){h.up=!1;clearInterval(l);h.draw();a.preventDefault()}function k(a){h.down=!1;clearInterval(l);h.draw();a.preventDefault()}function g(a){h.up=!1;clearInterval(l);h.draw();a.preventDefault()}function e(a){h.down=!1;clearInterval(l);h.draw();a.preventDefault()}u=a.hasTouchSupport;
var h=this,n=u?500:200,l;h.divUp.oncontextmenu=h.divDown.oncontextmenu=h.field.oncontextmenu=h.label.oncontextmenu=function(){return!1};u?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&&h.changeValue(h.field.value)});u?this.divUp.addEventListener("touchstart",c):this.divUp.addEventListener("mousedown",c);u?this.divDown.addEventListener("touchstart",
f):this.divDown.addEventListener("mousedown",f);u||this.divUp.addEventListener("mouseout",d);u||this.divDown.addEventListener("mouseout",k);u?(this.divUp.addEventListener("touchend",g),window.addEventListener("touchend",g)):(this.divUp.addEventListener("mouseup",g),window.addEventListener("mouseup",g));u?(this.divDown.addEventListener("touchend",e),window.addEventListener("touchend",e)):(this.divDown.addEventListener("mouseup",e),window.addEventListener("mouseup",e))};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var e,l,h,b,d,c,k;a.TextField=function(b,c){a.Control.call(this,b,c);void 0===this.valueExprString&&(this.valueExprString="");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;if(this.answer)if(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answerPattern=this.answer,this.answer=a.buildRegularExpresionsPatterns(this.answer,this.evaluator),this.onlyText){var d=this.answerPattern.indexOf("|");this.firstAnswer=
-1==d?this.answerPattern:this.answerPattern.substring(0,d)}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(){e=this.evaluator;this.value=this.validateValue(e.evalExpression(this.valueExpr));
var b=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var c=a.getTextWidth(b+"_",this.fieldFontSize+"px Arial"),d=parseInt(this.w/2),k=a.getTextWidth(this.name,this.fieldFontSize+"px Arial");d<k&&(d=k);""==this.name&&(d=0);this.w-d<c&&(d=this.w-c);0>d&&(d=0);c=this.w-d;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 : "+(c-2)+"px; height : "+(this.h-2)+"px; left: "+d+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=b;this.label.setAttribute("class","DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+
d+"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(){e=this.evaluator;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":
"none";this.updatePositionAndSize();l=this.field.value;h=this.value;this.value=this.validateValue(e.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value===h&&this.field.value!=l&&(this.value=this.validateValue(l),this.field.value=this.formatOutputValue(this.value));e.setVariable(this.id,this.value)};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";e=this.evaluator;b=parseFloat(e.evalExpression(e.parser.parse(a.toString().replace(this.parent.decimal_symbol,
"."))));isNaN(b)&&(b=0);d=e.evalExpression(this.min);""==d&&(d=-Math.Infinity);c=e.evalExpression(this.max);""==c&&(c=Math.Infinity);this.discrete&&(a=e.evalExpression(this.incr),b=0==a?0:a*Math.round(b/a));return b=parseFloat(parseFloat(b).toFixed(e.evalExpression(this.decimals)))};a.TextField.prototype.formatOutputValue=function(a){return""===a?"":this.uber.formatOutputValue.call(this,a)};a.TextField.prototype.changeValue=function(a,b){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=
this.formatOutputValue(this.value),this.evaluate&&(this.ok=this.evaluateAnswer()),this.evaluator.setVariable(this.id,this.value),this.evaluator.setVariable(this.id+".ok",this.ok),this.updateAndExecAction())};a.TextField.prototype.evaluateAnswer=function(){return a.esCorrecto(this.answer,this.value,this.evaluator,this.answer)};a.TextField.prototype.getFirstAnswer=function(){return this.answer?this.onlyText?this.firstAnswer:this.evaluator.evalExpression(this.firstAnswer):""};a.TextField.prototype.registerMouseAndTouchEvents=
function(){k=a.hasTouchSupport;var b=this;b.label.oncontextmenu=function(){return!1};k?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(a){b.update()});this.field.addEventListener("keydown",function(a){b.activeIfValue&&13==a.keyCode&&b.changeValue(b.field.value,!0)})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=
Math.abs,l,h,b,d;a.Menu=function(b,c){this.options="";a.Control.call(this,b,c);var d=this.parser;this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var e,h=0,l=this.options.length;h<l;h++)e=this.options[h].split(/[\[\]]/,2),1==e.length?(this.menuOptions.push(e[0]),this.strValue.push(h.toString())):2==e.length&&(this.menuOptions.push(e[0]),""==e[1]?this.strValue.push(h.toString()):this.strValue.push(e[1]));h=0;for(l=this.strValue.length;h<l;h++)this.strValue[h]=d.parse(this.strValue[h]);
this.containerControl=document.createElement("div");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.select=document.createElement("select");h=0;for(l=this.menuOptions.length;h<l;h++)d=document.createElement("option"),d.innerHTML=this.menuOptions[h],this.select.appendChild(d);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 c;a.Menu.prototype.init=function(){c=this.evaluator;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var b=0,f=0,d=0;this.value=c.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var e=0,h=this.menuOptions.length;e<h;e++)d=a.getTextWidth(this.menuOptions[e],this.fieldFontSize+
"px Arial"),d>b&&(b=d,f=e);b+=25;d=a.getTextWidth(this.formatOutputValue(c.evalExpression(this.strValue[f])),this.fieldFontSize+"px Arial")+7;f=a.getTextWidth(this.name,this.fieldFontSize+"px Arial")+10;""==this.name&&(f=0);this.visible||(d=0);for(e=this.w-d-f;e<b&&0<f;)f--,e++;for(;e<b&&0<d;)d--,e++;for(;f+e+d+1<this.w;)e++,d++;var b=f,h=b+e,d=this.w-h,l=this.formatOutputValue(c.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: "+f+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"menu");this.field.value=l;this.field.setAttribute("class","DescartesMenuField");
this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(d-2)+"px; height : "+(this.h-2)+"px; left: "+h+"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 : "+e+"px; height : "+this.h+"px; left: "+b+"px; border-color: #7a8a99; border-width: 1.5px; border-style: solid; background-color: #eeeeee;");this.select.selectedIndex=
this.indexValue;c.setVariable(this.id,parseFloat(l));this.update()};a.Menu.prototype.update=function(){c=this.evaluator;this.activeIfValue=0<c.evalExpression(this.activeif);this.drawIfValue=0<c.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=c.getVariable(this.id);this.field.value=
this.formatOutputValue(this.value);c.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,"."));l=-1;h=Infinity;for(var c=0,d=this.strValue.length;c<d;c++)b=e(a-parseFloat(this.evaluator.evalExpression(this.strValue[c]))),b<=h&&(h=b,l=c);return l};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),
this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){d=a.hasTouchSupport;var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=function(){return!1};d?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(a){b.value=b.evaluator.evalExpression(b.strValue[this.selectedIndex]);b.field.value=b.formatOutputValue(b.value);
b.evaluator.setVariable(b.id,b.field.value);b.changeValue();a.preventDefault()});this.field.addEventListener("keydown",function(a){13==a.keyCode&&(b.indexValue=b.getIndex(b.field.value),b.value=b.evaluator.evalExpression(b.strValue[b.indexValue]),b.field.value=b.formatOutputValue(b.indexValue),b.select.selectedIndex=b.indexValue,b.changeValue())})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,l="h",h,b,d,c,k,f,r,n,m,q,p,t,g,v,u,s,x,A,C,y,E;a.Scrollbar=
function(b,c){a.Control.call(this,b,c);this.orientation=this.w>=this.h?l:"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(){h=this.evaluator;this.findOffset();0==h.evalExpression(this.decimals)?this.incr=1:this.incr=
(h.evalExpression(this.max)-h.evalExpression(this.min))/100;this.value=this.validateValue(h.evalExpression(this.valueExpr));d=this.formatOutputValue(this.value);c=this.evaluator.evalExpression(this.expresion);this.x=c[0][0];this.y=c[0][1];4==c[0].length&&(this.w=c[0][2],this.h=c[0][3]);this.orientation=this.w>=this.h?l:"v";this.initScroll(d);this.changeScrollPositionFromValue();this.prePos=this.pos;h.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(c){b=this;h=b.evaluator;
var f="v"===b.orientation?parseInt(19+5*(b.h-100)/100):b.h;b.fieldFontSize="v"===b.orientation?f-parseInt(b.h/20)-1:2!==b.parent.version?a.getFieldFontSize(f):10;var d=a.getTextWidth(c+"_",b.fieldFontSize+"px Arial"),g=b.parent.getSpaceById(b.spaceID).h;b.labelHeight=""==b.name?0:f;b.fieldHeight=""==b.visible?0:f;if("v"===b.orientation)b.canvasWidth=b.w,b.canvasHeight=b.h-b.labelHeight-b.fieldHeight,18<=b.canvasHeight+b.y-g&&(b.canvasHeight=g),d=0,d=b.fieldHeight,f=d+b.canvasHeight,b.canvasX=0,b.canvasY=
b.fieldHeight,b.labelWidth=b.w,b.labelY=f,b.upWidth=b.downW=b.w,b.upHeight=b.downH=15,b.upX=0,b.upY=b.fieldHeight,b.downX=0,b.downY=f-b.downH,b.fieldWidth=b.w,b.fieldX=0,b.scrollManipulatorW=b.w,b.scrollManipulatorH=parseInt((b.canvasHeight-b.upHeight-b.downH-b.labelHeight-b.fieldHeight)/10),b.scrollManipulatorH=15>b.scrollManipulatorH?15:b.scrollManipulatorH,b.scrollManipulatorLimInf=f-b.downH-b.scrollManipulatorH,b.scrollManipulatorLimSup=d+b.downH;else{f=a.getTextWidth(b.name,b.fieldFontSize+"px Arial")+
10;b.labelWidth=f;b.fieldWidth=d;""==b.name&&(b.labelWidth=0);b.visible||(b.fieldWidth=0);for(f=b.w-b.fieldWidth-b.labelWidth;58>f&&0<b.labelWidth;)b.labelWidth--,f++;for(;58>f&&0<b.fieldWidth;)b.fieldWidth--,f++;d=b.labelWidth;g=d+f;b.fieldWidth=b.w-g;b.canvasWidth=f;b.canvasHeight=b.h;b.canvasX=b.labelWidth;b.canvasY=0;b.fieldX=b.canvasWidth+b.labelWidth;b.labelHeight=b.h;b.labelY=0;b.upWidth=b.downW=15;b.upHeight=b.downH=b.h;b.upX=g-b.downW;b.upY=0;b.downX=b.labelWidth;b.downY=0;b.scrollManipulatorW=
parseInt((b.canvasWidth-b.upWidth-b.downW)/10);b.scrollManipulatorW=15>b.scrollManipulatorW?15:b.scrollManipulatorW;b.scrollManipulatorH=b.h;b.scrollManipulatorLimInf=d+b.downW;b.scrollManipulatorLimSup=d+b.canvasWidth-b.downW-b.scrollManipulatorW}b.containerControl.setAttribute("class","DescartesScrollbarContainer");b.containerControl.setAttribute("style","width: "+b.w+"px; height: "+b.h+"px; left: "+b.x+"px; top: "+b.y+"px; z-index: "+b.zIndex+";");b.canvas.setAttribute("width",b.w+"px");b.canvas.setAttribute("height",
b.h+"px");b.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");b.ctx=b.canvas.getContext("2d");b.divUp.setAttribute("class","DescartesCatcher");b.divUp.setAttribute("style","width : "+b.upWidth+"px; height : "+b.upHeight+"px; left: "+b.upX+"px; top: "+b.upY+"px;");b.divDown.setAttribute("class","DescartesCatcher");b.divDown.setAttribute("style","width : "+b.downW+"px; height : "+b.downH+"px; left: "+b.downX+"px; top: "+b.downY+"px;");b.scrollManipulator.setAttribute("class","DescartesCatcher");
b.scrollManipulator.setAttribute("style","width : "+b.scrollManipulatorW+"px; height : "+b.scrollManipulatorH+"px;");b.scrollManipulator.style.top=("v"===b.orientation?b.scrollManipulatorLimInf:0)+"px";b.scrollManipulator.style.left=("v"===b.orientation?0:b.scrollManipulatorLimInf)+"px";b.field.setAttribute("type","text");b.field.setAttribute("id",b.id+"scrollbar");b.field.setAttribute("class","DescartesScrollbarField");b.field.setAttribute("style","font-size: "+b.fieldFontSize+"px; width : "+(b.fieldWidth-
2)+"px; height : "+(b.fieldHeight-2)+"px; left: "+b.fieldX+"px; top: 0px;");b.field.value=c;0===b.fieldHeight&&(b.field.style.display="none");b.label.setAttribute("class","DescartesScrollbarLabel");b.label.setAttribute("style","font-size:"+b.fieldFontSize+"px; width: "+b.labelWidth+"px; height: "+b.labelHeight+"px; line-height: "+b.labelHeight+"px; left: 0px; top:"+b.labelY+"px;");b.txtLabel=document.createTextNode(b.name)};a.Scrollbar.prototype.update=function(){h=this.evaluator;0==h.evalExpression(this.decimals)?
this.incr=1:this.incr=(h.evalExpression(this.max)-h.evalExpression(this.min))/100;this.activeIfValue=0<h.evalExpression(this.activeif);this.drawIfValue=0<h.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";this.updatePositionAndSize();this.value=this.validateValue(h.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);h.setVariable(this.id,this.value)};
a.Scrollbar.prototype.draw=function(){b=this;k=b.ctx;r=e(this.w);f=e(this.h);k.fillStyle="#e0e4e8";k.fillRect(0,0,r,f);k.strokeStyle="#7a8a99";b.down&&(k.fillStyle="#ccdcec",k.fillRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1));k.strokeRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1);b.up&&(k.fillStyle="#ccdcec",k.fillRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1));k.strokeRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1);n=4;k.fillStyle="black";k.beginPath();b.orientation===l?(k.moveTo(b.downX+
n,b.downH/2),k.lineTo(b.downX+b.downW-n,n),k.lineTo(b.downX+b.downW-n,b.downH-n),k.moveTo(b.upX+b.upWidth-n,b.downH/2),k.lineTo(b.upX+n,n),k.lineTo(b.upX+n,b.downH-n),k.fill(),b.activeIfValue&&(m=e(b.pos),k.fillStyle="#ccdcec",k.fillRect(m+0.5,0,e(b.scrollManipulatorW),f),k.strokeStyle="#6382bf",k.strokeRect(m+0.5,0,e(b.scrollManipulatorW),f),q=e(b.scrollManipulatorW/2),k.beginPath(),k.moveTo(m+q+0.5-2,3),k.lineTo(m+q+0.5-2,f-3),k.moveTo(m+q+0.5,3),k.lineTo(m+q+0.5,f-3),k.moveTo(m+q+0.5+2,3),k.lineTo(m+
q+0.5+2,f-3),k.stroke())):(k.moveTo(b.downX+b.downW/2,b.downY+b.downH-n),k.lineTo(b.downX+n,b.downY+n),k.lineTo(b.downX+b.downW-n,b.downY+n),k.moveTo(b.upX+b.upWidth/2,b.upY+n),k.lineTo(b.upX+n,b.upY+b.upHeight-n),k.lineTo(b.upX+b.upWidth-n,b.upY+b.upHeight-n),k.fill(),b.activeIfValue&&(m=e(b.pos),k.fillStyle="#ccdcec",k.fillRect(0,m+0.5,r,e(b.scrollManipulatorH)),k.strokeStyle="#6382bf",k.strokeRect(0,m+0.5,r,e(b.scrollManipulatorH)),q=e(b.scrollManipulatorH/2),k.beginPath(),k.moveTo(3,m+q+0.5-2),
k.lineTo(r-3,m+q+0.5-2),k.moveTo(3,m+q+0.5),k.lineTo(r-3,m+q+0.5),k.moveTo(3,m+q+0.5+2),k.lineTo(r-3,m+q+0.5+2),k.stroke()));k.strokeRect(0.5,0.5,r-1,f-1);b.activeIfValue||(k.fillStyle="rgba(240,240,240,"+160/255+")",k.fillRect(0,0,r,f.h))};a.Scrollbar.prototype.validateValue=function(a){h=this.evaluator;p=a.toString();p=parseFloat(p.replace(this.parent.decimal_symbol,"."));isNaN(p)&&(p=0);this.minimo=h.evalExpression(this.min);p<this.minimo&&(this.value=null,p=this.minimo);this.maximo=h.evalExpression(this.max);
p>this.maximo&&(this.value=null,p=this.maximo);t=this.incr;p=0!=t?p*t/t:0;this.fixed&&(p=parseFloat(parseFloat(p).toFixed(h.evalExpression(this.decimals))));return p};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(){n=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==
l?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+n):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+n)};a.Scrollbar.prototype.decrease10=function(){n=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==l?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-n):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-n)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&
(g=this.validateValue(a),g!=this.value&&(this.value=g,this.field.value=this.formatOutputValue(g),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){h=this.evaluator;v=this.scrollManipulatorLimInf;u=this.scrollManipulatorLimSup;s=h.evalExpression(this.min);x=h.evalExpression(this.max);t=this.incr;g=e((this.pos-v)*(x-s)/(u-v)/t)*t+s;g!=this.value&&(this.value=
g,this.field.value=this.formatOutputValue(g),h.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){h=this.evaluator;v=this.scrollManipulatorLimInf;u=this.scrollManipulatorLimSup;s=h.evalExpression(this.min);x=h.evalExpression(this.max);t=this.incr;this.pos=(this.value-s)*(u-v)/(x-s)+v;this.orientation==l?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=
this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f,d){clearInterval(x);if((s.up||s.down||s.canvasClick)&&1E-7<Math.abs(s.value-d))c.call(s),a=f?a:30,x=setTimeout(function(){b(a,c,!1,d)},a)}function c(f){f.preventDefault();s.whichButton=a.whichButton(f);"L"==s.whichButton&&s.activeIfValue&&(s.clickPos=s.getCursorPosition(f),s.canvasClick=!0,s.orientation==l?s.clickPos.x<s.prePos?b(v,s.decrease10,!0,s.minimo):b(v,s.increase10,!0,s.maximo):s.clickPos.y<s.prePos?
b(v,s.increase10,!0,s.maximo):b(v,s.decrease10,!0,s.minimo))}function f(a){s.canvasClick=!1;clearInterval(x);a.preventDefault()}function d(a){!0==s.canvasClick&&(s.clickPos=s.getCursorPosition(a),a.preventDefault())}function g(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("mouseup",k),window.addEventListener("mousemove",n),a.preventDefault())}function e(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("touchend",
h),window.addEventListener("touchmove",onToucheMove_scrollManipulator),a.preventDefault())}function k(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("mouseup",k,!1);window.removeEventListener("mousemove",n,!1);a.preventDefault()}function h(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("touchend",h,!1);window.removeEventListener("touchmove",n,!1);a.preventDefault()}function n(a){var b=s.getCursorPosition(a);s.orientation==l?(s.pos=s.prePos-(s.initPos.x-b.x),s.pos<s.scrollManipulatorLimInf&&
(s.pos=s.scrollManipulatorLimInf),s.pos>s.scrollManipulatorLimSup&&(s.pos=s.scrollManipulatorLimSup),s.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+s.scrollManipulatorW+"px; height : "+s.h+"px; left: "+s.pos+"px; top: 0px;")):(s.pos=s.prePos-(s.initPos.y-b.y),s.pos>s.scrollManipulatorLimInf&&(s.pos=s.scrollManipulatorLimInf),s.pos<s.scrollManipulatorLimSup&&(s.pos=s.scrollManipulatorLimSup),s.scrollManipulator.setAttribute("style",
"background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+s.w+"px; height : "+s.scrollManipulatorH+"px; left: 0px; top: "+s.pos+"px;"));s.changeValueForScrollMovement();a.preventDefault()}function m(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.up=!0,b(v,s.increase,!0,s.maximo))}function r(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.down=!0,b(v,s.decrease,!0,s.minimo))}function p(a){s.up=
!1;clearInterval(x);a.preventDefault()}function u(a){s.down=!1;clearInterval(x);a.preventDefault()}function q(a){s.up=!1;clearInterval(x);a.preventDefault();s.draw()}function t(a){s.down=!1;clearInterval(x);a.preventDefault();s.draw()}A=a.hasTouchSupport;var s=this,v=A?500:200,x;s.canvas.oncontextmenu=s.divUp.oncontextmenu=s.divDown.oncontextmenu=s.label.oncontextmenu=s.field.oncontextmenu=s.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==
a.keyCode&&s.changeValue(s.field.value)});A?this.canvas.addEventListener("touchstart",c):this.canvas.addEventListener("mousedown",c);A||this.divDown.addEventListener("mouseout",u);A?window.addEventListener("touchend",f):window.addEventListener("mouseup",f);A?this.canvas.addEventListener("touchmove",d):this.canvas.addEventListener("mousemove",d);A?this.scrollManipulator.addEventListener("touchstart",e):this.scrollManipulator.addEventListener("mousedown",g);A?this.divUp.addEventListener("touchstart",
m):this.divUp.addEventListener("mousedown",m);A?this.divDown.addEventListener("touchstart",r):this.divDown.addEventListener("mousedown",r);A||this.divUp.addEventListener("mouseout",p);A||this.divDown.addEventListener("mouseout",u);A?window.addEventListener("touchend",q):window.addEventListener("mouseup",q);A?window.addEventListener("touchend",t):window.addEventListener("mouseup",t)};a.Scrollbar.prototype.findOffset=function(){C=this.containerControl;this.offsetTop=this.offsetLeft=0;y=this.containerControl.style.display;
for(this.containerControl.style.display="block";C;)this.offsetLeft+=C.offsetLeft||0,this.offsetTop+=C.offsetTop||0,C=C.parentNode;this.containerControl.style.display=y};a.Scrollbar.prototype.getCursorPosition=function(b){E=a.getCursorPosition(b);return{x:E.x-this.offsetLeft,y:E.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Audio=function(e,h){this.controls=!0;this.file="";a.Control.call(this,e,h);var b=this.evaluator.evalExpression(this.expresion);
4==b[0].length?(this.w=b[0][2],this.h=b[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(){e=this.evaluator;0<e.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 e;a.Video=function(e,h){this.controls=!0;this.file="";a.Control.call(this,e,h);var b=this.evaluator.evalExpression(this.expresion);
4==b[0].length?(this.w=b[0][2],this.h=b[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 b=this.file,d=b.lastIndexOf(".");-1!=d&&(b=this.file.substring(0,d));this.video.canPlayType("video/mp4")&&(d=document.createElement("source"),d.setAttribute("src",b+".mp4"),d.setAttribute("type","video/mp4"),this.video.appendChild(d));this.video.canPlayType("video/ogg")&&(d=document.createElement("source"),d.setAttribute("src",b+".ogg"),d.setAttribute("type","video/ogg"),this.video.appendChild(d),d=document.createElement("source"),d.setAttribute("src",b+".ogv"),
d.setAttribute("type","video/ogg"),this.video.appendChild(d));this.video.canPlayType("video/webm")&&(d=document.createElement("source"),d.setAttribute("src",b+".webm"),d.setAttribute("type","video/webm"),this.video.appendChild(d));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(){e=this.evaluator;0<e.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 e,l;a.TextArea=function(e,b){a.Control.call(this,e,b);this.region="interior";this.tabindex=++this.parent.tabindex;if(this.answer){this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7)));var d=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();d&&void 0!=d.type&&!this.text.hasFormula&&(this.answer=d.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(){l=this.answer?28:8;e=this.evaluator;this.text=e.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<e.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-l)+"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-l)+"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 e=document.createElement("canvas");e.setAttribute("width",20);e.setAttribute("height",16);var b=e.getContext("2d");this.canvas=e;this.ctx=b;this.createGradient(20,16);b.lineWidth=1;b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(b,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(b,1,0,1,16,"rgba(0,0,0,"+
8/255+")");this.imageUnPush=e.toDataURL();b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,0,0,0,14,"gray");a.drawLine(b,0,0,19,0,"gray");b.fillStyle="rgba(0, 0, 0,"+24/255+")";b.fillRect(0,0,this.w,this.h);this.imagePush=e.toDataURL()};a.TextArea.prototype.update=function(){e=this.evaluator;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);e.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(d){d.preventDefault();b.showButton.style.backgroundImage="url("+b.imageUnPush+")"}var b=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();b.showAnswer=!b.showAnswer;b.textAreaAnswer.style.display=b.showAnswer?"block":"none";b.showButton.childNodes[0].childNodes[0].textContent=
b.showAnswer?"T":"S";b.showButton.style.backgroundImage="url("+b.imagePush+")"});this.showButton.addEventListener("mouseup",a);this.showButton.addEventListener("mouseout",a)};a.TextArea.prototype.getScreenshot=function(){var a=document.createElement("canvas");a.setAttribute("width",this.w);a.setAttribute("height",this.h);var b=a.getContext("2d");b.fillStyle="white";b.strokeStyle="black";b.lineWidth=1;b.fillRect(0,0,this.w,this.h);b.strokeRect(0,0,this.w,this.h);return a};return a}(descartesJS||{}),
descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,l,h,b,d,c,k,f,r,n;a.GraphicControl=function(b,c){h=b.evaluator.parser;this.spaceID="E0";this.text="";this.size=h.parse("4");this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";a.Control.call(this,b,c);this.touchId=null;this.font=a.convertFont(this.font);this.constraintExpr&&(this.constraint=h.parse(this.constraintExpr),"(expr)"==this.constraint.type&&(this.constraint=h.parse(this.constraintExpr.substring(1,
this.constraintExpr.length-1))),"compOperator"==this.constraint.type?this.newt=new a.R2Newton(this.evaluator,this.constraint):this.constraint=null,r=new a.R2(0,0));this.container=this.getContainer();this.mouseCacher=document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("dragged",!0);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);
this.registerMouseAndTouchEvents();this.init()};a.extend(a.GraphicControl,a.Control);a.GraphicControl.prototype.init=function(){l=this.evaluator;n=a.hasTouchSupport;var b=l.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];l.setVariable(this.id+".x",this.x);l.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*l.evalExpression(this.size),
this.height=2*l.evalExpression(this.size));this._w=n&&70>this.width?70:this.width;this._h=n&&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";l.setVariable(this.id+".activo",0);this.update()};
a.GraphicControl.prototype.update=function(){l=this.evaluator;this.activeIfValue=0<l.evalExpression(this.activeif);this.drawIfValue=0<l.evalExpression(this.drawif);this.x=l.getVariable(this.id+".x");this.y=l.getVariable(this.id+".y");b=this.space.getAbsoluteX(this.x);d=this.space.getAbsoluteY(this.y);this.active||(this.mouseCacher.style.left=parseInt(b-this._w/2)+"px",this.mouseCacher.style.top=parseInt(d-this._h/2)+"px");this.constraint&&this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=
function(){l=this.evaluator;this.drawIfValue&&(k=this.ctx,f=this.space.backgroundCtx,b=parseInt(this.space.getAbsoluteX(this.x))+0.5,d=parseInt(this.space.getAbsoluteY(this.y))+0.5,""!=this.text&&this.drawText(b,d),this.image.ready?(this.image.complete&&k.drawImage(this.image,parseInt(b-this.image.width/2),parseInt(d-this.image.height/2)),this.trace&&(f.save(),f.translate(b,d),f.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),f.beginPath(),f.arc(0,0,1,0,e,!1),f.restore(),f.lineWidth=
1,f.strokeStyle=this.trace.getColor(),f.stroke())):(k.beginPath(),k.arc(b,d,parseInt(this.width/2),0,e,!1),k.fillStyle=this.colorInt.getColor(),k.fill(),k.lineWidth=1,k.strokeStyle=this.color.getColor(),k.stroke(),this.active&&(k.beginPath(),k.arc(b,d,parseInt(this.width/2)-2,0,e,!1),k.strokeStyle=this.colorInt.borderColor(),k.stroke()),this.trace&&(f.lineWidth=1,f.strokeStyle=this.trace.getColor(),f.beginPath(),f.arc(b,d,parseInt(this.width/2),0,e,!1),f.stroke())))};a.GraphicControl.prototype.evalConstraint=
function(a,b){r.set(this.x,this.y);c=this.newt.findZero(r);this.x=c.x;this.y=c.y;this.evaluator.setVariable(this.id+".x",this.x);this.evaluator.setVariable(this.id+".y",this.y)};a.GraphicControl.prototype.drawText=function(a,b){k=this.ctx;l=this.evaluator;k.fillStyle=this.color.getColor();k.font=this.font;k.textBaseline="alphabetic";k.fillText(l.evalExpression(this.text[0],l.evalExpression(this.decimals),this.fixed),parseInt(a+1+this.width/2),parseInt(b-1-this.height/2))};a.GraphicControl.prototype.getContainer=
function(){for(var a=this.parent.spaces,b,c=0,f=a.length;c<f;c++)if(b=a[c],b.id==this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,this.space=b,b.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.id+".activo",0)};a.GraphicControl.prototype.registerMouseAndTouchEvents=function(){function b(c){c.preventDefault();h.whichButton=a.whichButton(c);
"L"==h.whichButton&&(h.activeIfValue&&h.over)&&(h.parent.deactivateGraphiControls(),h.click=!0,h.active=!0,h.evaluator.setVariable(h.id+".activo",1),h.posAnte=h.getCursorPosition(c),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},h.evaluator.setVariable(h.space.id+".mouse_x",h.x),h.evaluator.setVariable(h.space.id+".mouse_y",h.y),h.parent.update(),window.addEventListener("mouseup",f),window.addEventListener("mousemove",d))}function c(a){a.preventDefault();h.activeIfValue&&(h.parent.deactivateGraphiControls(),
h.click=!0,h.active=!0,h.evaluator.setVariable(h.id+".activo",1),h.posAnte=h.getCursorPosition(a),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},h.evaluator.setVariable(h.space.id+".mouse_x",h.x),h.evaluator.setVariable(h.space.id+".mouse_y",h.y),h.parent.update(),window.addEventListener("touchmove",d),window.addEventListener("touchend",f))}function f(b){b.preventDefault();h.touchId=null;if(h.activeIfValue||h.active)h.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",
d,!1),window.removeEventListener("touchend",f,!1)):(window.removeEventListener("mouseup",f,!1),window.removeEventListener("mousemove",d,!1)),h.evaluator.setVariable(h.space.id+".mouse_x",h.x),h.evaluator.setVariable(h.space.id+".mouse_y",h.y),h.parent.update(),h.mouseCacher.style.left=h.space.getAbsoluteX(h.x)-h._w/2+"px",h.mouseCacher.style.top=h.space.getAbsoluteY(h.y)-h._h/2+"px"}function d(a){a.preventDefault();a.touchId=h.touchId;n=h.getCursorPosition(a);h.posX=h.prePos.x-(h.posAnte.x-n.x);h.posY=
h.prePos.y-(h.posAnte.y-n.y);h.evaluator.setVariable(h.id+".x",h.space.getRelativeX(h.posX));h.evaluator.setVariable(h.id+".y",h.space.getRelativeY(h.posY));h.evaluator.setVariable(h.space.id+".mouse_x",h.x);h.evaluator.setVariable(h.space.id+".mouse_y",h.y);h.parent.updateControls();h.parent.update()}function e(a){h.over=!0}function k(a){h.over=!1;h.click=!1}var h=this;this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=function(){return!1};a.hasTouchSupport?this.mouseCacher.addEventListener("touchstart",
c):(this.mouseCacher.addEventListener("mousedown",b),this.mouseCacher.addEventListener("mouseover",e),this.mouseCacher.addEventListener("mouseout",k));var n};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var b;if(a.touchId){c=0;for(f=a.touches.length;c<f;c++)if(a.touches[c].identifier==a.touchId){b=a.touches[c];break}}else for(var c=0,f=a.touches.length;c<f;c++)if(a.target==a.touches[c].target){b=a.touches[c];this.touchId=b.identifier;break}mouseX=b.pageX;mouseY=b.pageY}else void 0!=
a.pageX&&void 0!=a.pageY?(mouseX=a.pageX,mouseY=a.pageY):(mouseX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,mouseY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:mouseX-(this.space.container.offsetLeft+this.space.container.parentNode.offsetLeft),y:mouseY-(this.space.container.offsetTop+this.space.container.parentNode.offsetTop)}};return a}(descartesJS||{}),descartesJS=function(a,e){var l,h,b,d,c,k,f,r,n,m;if(a.loadLib)return a;var q,p,t,
g,v,u,s,x,A=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,C,y,E,D,B,z,I,G,M,L,w,N,F,J,K,H,O,S,Q,R,P;a.LessonParser=function(b){this.parent=b;this.parser=b.evaluator.parser;this.RTFparser=new a.RTFParser(b.evaluator)};a.LessonParser.prototype.parseButtonsConfig=function(a){var b={rowsNorth:0,rowsSouth:0,widthEast:125,widthWest:125,height:23};a=this.split(a);for(var c=0,f=a.length;c<f;c++)switch(t=a[c][0],g=a[c][1],p=e[t],p){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[p]=
parseInt(g);break;case "about":case "config":case "init":case "clear":b[p]="true"===e[g];break;default:console.log("----- attributo de space no identificado: <"+t+"> valor: <"+g+"> -----")}return b};a.LessonParser.prototype.parseSpace=function(b){v={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(t=b[c][0],g=b[c][1],p=e[t],p){case "type":case "id":case "cID":case "file":v[p]=g;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":v[p]="true"===e[g];break;
case "bg_display":case "render":v[p]=e[g];break;case "net":case "net10":case "axes":case "text":v[p]="false"===e[g]?"":new a.Color(g,this.parent.evaluator);break;case "x_axis":case "y_axis":v[p]="false"===e[g]?"":g;break;case "O.x":v.OxExpr=g;break;case "O.y":v.OyExpr=g;break;case "image":v.imageSrc=g;break;case "x":q=g;q="%"===q[q.length-1]?(this.parent.container.width*parseFloat(q)/100).toString():g;v.xExpr=this.parser.parse(q);break;case "y":q=g;q="%"===q[q.length-1]?(this.parent.container.height*
parseFloat(q)/100).toString():g;v.yExpr=this.parser.parse(q);break;case "width":q=g;"%"===q[q.length-1]?q=this.parent.container.width*parseFloat(q)/100:(q=parseFloat(g),q!=g&&(q=this.parent.container.width));v.w=q;break;case "height":q=g;"%"===q[q.length-1]?q=this.parent.container.height*parseFloat(q)/100:(q=parseFloat(g),q!=g&&(q=this.parent.container.height));v.h=q;break;case "drawif":v.drawif=this.parser.parse(g);break;case "scale":q=parseFloat(g);q.toString()!=g&&(q=48);v.scale=q;break;case "background":v.background=
new a.Color(g,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+t+"> valor: <"+g+"> -----")}switch(v.type){case "R2":return new a.Space2D(this.parent,v);case "R3":return new a.Space3D(this.parent,v);case "AP":return new a.SpaceAP(this.parent,v);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,v);default:return new a.Space2D(this.parent,v)}};a.LessonParser.prototype.parseControl=function(b){u={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(t=
b[c][0],g=b[c][1],p=e[t],p){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":u[p]=g;break;case "gui":case "region":case "action":case "msg_pos":case "poster":u[p]=e[g];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":u[p]="true"===e[g];break;case "color":case "colorInt":case "trace":u[p]=new a.Color(g,
this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":u[p]=this.parser.parse(g);break;case "constraint":u.constraintExpr=g;break;case "image":u.imageSrc=g;break;case "space":u.spaceID=g;break;case "type":u.type=e[g.trim()];break;case "expresion":u.expresion=this.parser.parse(g.replace(")(",","));break;case "bold":"false"!=e[g]&&(u.bold="bold");break;case "italics":"false"!=e[g]&&(u.italics="italic");break;case "underlined":"false"!=
e[g]&&(u.underlined=!0);break;case "value":var d=g.replace(/&squot;/g,"'");d.match(/^\|/)&&(d="'"+d.substring(1),d.match(/\|$/)&&(d=d.substring(0,d.length-1)+"'"));u.valueExpr=this.parser.parse(d);u.valueExprString=d;break;case "incr":0!=g&&(u.incr=this.parser.parse(g));break;case "exponentialif":u.exponentialif=parseFloat(g);break;case "text":u.rawText=g;for(var d=this.parseText(g),k=0,h=d.length;k<h;k++)d[k]=this.parser.parse(d[k],!1);u.text=d;break;default:k=t.indexOf(".");d=e[t.substring(0,k)];
k=e[t.substring(k+1)];if("parameter"===d&&"font"===k){u.parameterFont=g;break}else if("Explanation"===d&&"font"===k){u.ExplanationFont=g;break}else if("tooltip"===d&&"font"===k){u.tooltipFont=g;break}console.log("----- attributo de control no identificado: <"+t+"> valor: <"+g+"> -----")}if("numeric"===u.type)switch(u.gui){case "spinner":return new a.Spinner(this.parent,u);case "button":return new a.Button(this.parent,u);case "textfield":return new a.TextField(this.parent,u);case "menu":return new a.Menu(this.parent,
u);case "scrollbar":return new a.Scrollbar(this.parent,u);default:return new a.Spinner(this.parent,u)}else{if("video"===u.type)return new a.Video(this.parent,u);if("audio"===u.type)return new a.Audio(this.parent,u);if("graphic"===u.type)return new a.GraphicControl(this.parent,u);if("text"===u.type)return new a.TextArea(this.parent,u)}};a.LessonParser.prototype.parseGraphic=function(b,c,f,d){s={rotateExp:d,parameter:"t"};b=this.split(b);d=0;for(var k=b.length;d<k;d++)switch(t=b[d][0],g=b[d][1],p=e[t],
p){case "type":case "align":s[p]=e[g];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":s[p]="true"===e[g];break;case "color":case "trace":case "fill":case "fillP":case "fillM":case "arrow":s[p]=new a.Color(g,this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":s[p]=g;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":s[p]=
this.parser.parse(g);break;case "space":s.spaceID=g;break;case "expresion":"macro"!=s.type?(s.expresion=this.parser.parse(g),s.expresionString=g):s.expresion=g;break;case "text":s.text=this.parseText(g);break;case "file":var h=g.replace(/&squot;/g,"'");"["===h.charAt(0)&&"]"===h.charAt(h.length-1)&&(h=h.substring(1,h.length-1));h.match(A)&&(h="'"+h+"'");s.file=this.parser.parse(h);break;case "border":"false"!=e[g]&&(s.border=new a.Color(g,this.parent.evaluator));break;default:if(void 0!=s.family&&
t.substring(0,s.family.length+1)===s.family+"."){switch(e[t.substring(s.family.length+1)]){case "interval":s.family_interval=this.parser.parse(g);break;case "steps":s.family_steps=this.parser.parse(g)}break}if(void 0!=s.parameter&&t.substring(0,s.parameter.length+1)===s.parameter+"."){switch(e[t.substring(s.parameter.length+1)]){case "interval":s.parameter_interval=this.parser.parse(g);break;case "steps":s.parameter_steps=this.parser.parse(g)}break}console.log("----- attributo del graphic no identificado: <"+
t+"> valor: <"+g+"> -----")}c&&(s.abs_coord=c);f&&(s.background=f);switch(s.type){case "text":return new a.Text(this.parent,s);case "image":return new a.Image(this.parent,s);case "point":return new a.Point(this.parent,s);case "polygon":return new a.Polygon(this.parent,s);case "arc":return new a.Arc(this.parent,s);case "segment":return new a.Segment(this.parent,s);case "arrow":return new a.Arrow(this.parent,s);case "macro":return new a.Macro(this.parent,s);case "curve":return new a.Curve(this.parent,
s);case "equation":return new a.Equation(this.parent,s);case "sequence":return new a.Sequence(this.parent,s);case "fill":return new a.Fill(this.parent,s)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,f,d){s={rotateExp:d,parameter:"t"};b=this.split(b);c=0;for(f=b.length;c<f;c++)switch(t=b[c][0],g=b[c][1],p=e[t],p){case "type":case "model":s[p]=e[g];break;case "background":case "fixed":case "edges":s[p]="true"===e[g];break;case "color":case "backcolor":s[p]=new a.Color(g,this.parent.evaluator);
break;case "type":case "model":s[p]=e[g];break;case "background":case "fixed":case "edges":case "split":s[p]="true"===e[g];break;case "color":case "backcolor":s[p]=new a.Color(g,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":s[p]=this.parser.parse(g);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":s[p]=g;break;case "space":s.spaceID=g;break;case "expresion":"macro"!=
s.type&&"curve"!=s.type&&"surface"!=s.type?(s.expresion=this.parser.parse(g),s.expresionString=g):s.expresion=g.replace(/\\n/g,"");break;case "text":d=this.parseText(g);for(var k=0,h=d.length;k<h;k++)d[k]=this.parser.parse(d[k],!1);s.text=d;break;case "file":d=g.replace(/&squot;/g,"'");"["===d.charAt(0)&&"]"===d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));d.match(/./)&&(d="'"+d+"'");s.file=this.parser.parse(d);break;case "drawif":case "width":case "length":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":s[p]=
this.parser.parse(g);break;case "family":case "parameter":case "font":case "name":s[p]=g;break;case "space":s.spaceID=g;break;case "expresion":"macro"!=s.type&&"curve"!=s.type&&"surface"!=s.type?(s.expresion=this.parser.parse(g),s.expresionString=g):s.expresion=g;break;case "text":d=this.parseText(g);k=0;for(h=d.length;k<h;k++)d[k]=this.parser.parse(d[k],!1);s.text=d;break;case "file":d=g.replace(/&squot;/g,"'");"["===d.charAt(0)&&"]"===d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));d.match(/./)&&
(d="'"+d+"'");s.file=this.parser.parse(d);break;default:if(void 0!==s.family&&t.substring(0,s.family.length+1)===s.family+"."){"interval"===e[t.substring(s.family.length+1)]?s.family_interval=this.parser.parse(g):s.family_steps=this.parser.parse(g);break}console.log("----- attributo del graphic3D no identificado: <"+t+"> valor: <"+g+"> -----")}switch(s.type){case "point":return new a.Point3D(this.parent,s);case "segment":return new a.Segment3D(this.parent,s);case "polygon":return new a.Polygon3D(this.parent,
s);case "curve":return new a.Curve3D(this.parent,s);case "triangle":return new a.Triangle3D(this.parent,s);case "face":return new a.Face3D(this.parent,s);case "polireg":return new a.Polireg3D(this.parent,s);case "surface":return new a.Surface3D(this.parent,s);case "text":return new a.Text3D(this.parent,s);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,
s);default:console.log(s.type)}};a.LessonParser.prototype.parseAuxiliar=function(b){x={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)b[c][1]=b[c][1].replace(/&squot;/g,"'");c=0;for(f=b.length;c<f;c++)switch(t=b[c][0],g=b[c][1],p=e[t],p){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":x[p]=g;break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "sequence":x[p]="true"===
e[g];break;case "size":case "rows":case "columns":x[p]=this.parser.parse(g);break;case "evaluate":case "event":case "execution":case "msg_pos":case "action":x[p]=e[g];break;default:var d=t.indexOf("."),k=e[t.substring(0,d)],d=e[t.substring(d+1)];if("parameter"===k&&"font"===d){x.parameterFont=g;break}console.log("----- attributo de auxiliar no identificado: <"+t+"> valor: <"+g+"> -----")}x.sequence?new a.Function(this.parent,x):x.constant?(b=new a.Constant(this.parent,x),x.evaluate&&"always"===x.evaluate&&
this.parent.auxiliaries.push(b)):x.algorithm&&x.evaluate?(b=new a.Algorithm(this.parent,x),this.parent.auxiliaries.push(b)):x.array&&!x.matrix&&")"!=x.id.charAt(x.id.length-1)?(b=new a.Vector(this.parent,x),x.evaluate&&"always"===x.evaluate&&this.parent.auxiliaries.push(b)):x.matrix&&")"!=x.id.charAt(x.id.length-1)?(b=new a.Matrix(this.parent,x),x.evaluate&&"always"===x.evaluate&&this.parent.auxiliaries.push(b)):x.event&&")"!=x.id.charAt(x.id.length-1)?this.parent.events.push(new a.Event(this.parent,
x)):")"===x.id.charAt(x.id.length-1)?new a.Function(this.parent,x):new a.Variable(this.parent,x)};a.LessonParser.prototype.parseAction=function(b){C=b.action;y=b.parent;E=b.parameter;if(C)switch(C){case "message":return new a.Message(y,E);case "calculate":return new a.Calculate(y,E);case "openURL":return new a.OpenURL(y,E);case "openScene":return new a.OpenScene(y,E);case "about":return new a.About(y,E);case "config":return new a.Config(y,E);case "init":return new a.Init(y,E);case "clear":return new a.Clear(y,
E);case "animate":return new a.Animate(y,E);case "initAnimation":return new a.InitAnimation(y,E);case "playAudio":return new a.PlayAudio(y,E);default:console.log("----- Accion no soportada aun: <"+C+"> -----")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(b){var c={};b=this.split(b);for(var f=0,d=b.length;f<d;f++)switch(t=b[f][0],g=b[f][1],p=e[t],p){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[p]=g;break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[p]=
"true"===e[g];break;default:console.log("----- attributo de la animacion no identificado: <"+t+">  <"+g+"> -----")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(e,p){e=this.split(e);h=l="";b=0;d="#536891";c="white";k="left";f="";r="SansSerif,BOLD,20";n="SansSerif,PLAIN,18";m=void 0;for(var s=0,q=e.length;s<q;s++)switch(t=e[s][0],g=e[s][1],t){case "title":l=g;break;case "subtitle":h=g;break;case "subtitlines":b=g;break;case "bgcolor":""!=g&&(d=(new a.Color(g,this.parent.evaluator)).getColor());
break;case "fgcolor":""!=g&&(c=(new a.Color(g,this.parent.evaluator)).getColor());break;case "align":""!=g&&(k=g);break;case "titleimage":f=g;break;case "titlefont":r=""!=g?a.convertFont(g):a.convertFont(r);break;case "subtitlefont":n=""!=g?a.convertFont(g):a.convertFont(n);break;default:console.log("----- attributo de la pleca no identificado: <"+t+">  <"+g+"> -----")}L=n.substring(0,n.indexOf("px"));L=L.substring(L.lastIndexOf(" "));""!=f&&(w=this.parent.getImage(f),N=w.height);m=document.createElement("div");
m.setAttribute("id","descartesPleca");N?(m.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+k+"; width: "+(p-30)+"px; height: "+(N-16)+"px; background: "+d+"; color: "+c+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),w.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),m.appendChild(w)):m.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+
k+"; width: "+(p-30)+"px; background: "+d+"; color: "+c+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");F=document.createElement("div");F.setAttribute("style","padding: 0px; margin: 0px; font: "+r+"; overflow: hidden; white-space: nowrap;");F.innerHTML=l;J=document.createElement("div");if(1===parseInt(b)){Q=0;K=document.createElement("div");K.innerHTML=h;document.body.appendChild(K);O=L;do O-=Q,K.setAttribute("style","padding: 0px; margin: 0px; font: "+
n+"; font-size: "+O+"px; width: "+(p-30)+"px; line-height: "+O+"px;"),H=K.offsetHeight,S=H/O,Q=1;while(1<S&&8<O);document.body.removeChild(K);J.setAttribute("style","padding: 0px; margin: 0px; font: "+n+"; font-size: "+O+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else J.setAttribute("style","padding: 0px; margin: 0px; font: "+n+"; line-height: 110%;");J.innerHTML=h;m.appendChild(F);m.appendChild(J);m.imageHeight=N;return m};a.LessonParser.prototype.split=function(a){if("string"!=
typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");D=[];z=B=0;I=!1;G=0;for(M=!1;B<a.length;)" "===a.charAt(B)&&!I&&B++," "!==a.charAt(B)&&!I&&(I=!0,G=B),"="===a.charAt(B)&&("'"===a.charAt(B+1)&&!M)&&(M=!0,D[z]=[a.substring(G,B)],G=B+2,B+=2),M&&"'"===a.charAt(B)&&(I=M=!1,D[z].push(a.substring(G,B)),z++),"="===a.charAt(B)&&("'"!==a.charAt(B+1)&&!M)&&(D[z]=[a.substring(G,B)],G=B+1,B++,R=a.substring(B).indexOf("="),-1===R?P=R=a.length:(R+=B,P=a.substring(B,R).lastIndexOf(" "),P=-1===P?a.length:P+B),
D[z].push(a.substring(G,P)),z++,I=!1,B=P),B++;return D};a.LessonParser.prototype.parseText=function(b){return b.match(/^\{\\rtf1/)?this.RTFparser.parse(b.substring(10)):new a.SimpleText(this.parent,b)};return a}(descartesJS||{},babel),descartesJS=function(a){function e(a,b){q=[];q.type="matrix";q.rows=a;q.cols=b;var c;t=0;for(g=b;t<g;t++){c=[];p=0;for(v=a;p<v;p++)c.push(0);q[t]=c}return q}function l(a,b){n=a.rows;m=a.cols;q=e(n,m);var c;for(t=0;t<n;t++)for(p=0;p<m;p++){for(g=c=0;g<m;g++)c+=a[g][t]*
b[p][g];q[p][t]=c}return q}function h(a,b,c){for(var f=e(c.length-1,c.length-1),d=0,k=f.length;d<k;d++)for(var g=0;g<k;g++)f[d][g]=d<a?g<b?c[d][g]:c[d][g+1]:d<b?c[d+1][g]:c[d+1][g+1];return f}function b(a){if(1<a.cols){for(var c=0,f=1,d=0,k=a.cols;d<k;d++)c+=f*a[0][d]*b(h(0,d,a)),f=-f;return c}return a[0][0]}if(a.loadLib)return a;var d=Math.floor,c,k,f,r;a.Node=function(a,b){this.sep="";this.type=a;this.value=b;this.parent=null;this.childs=[]};a.Node.prototype.getRoot=function(){return null===this.parent?
this:this.parent.getRoot()};a.Node.prototype.addChild=function(a){a.parent=this;this.childs.push(a)};a.Node.prototype.replaceLastChild=function(a){c=this.childs.length-1;lastChild=this.childs[c];lastChild.parent=null;this.childs[c]=a;a.parent=this;return a};a.Node.prototype.contains=function(a){if(this.value===a)return!0;for(var b=0,c=this.childs.length;b<c;b++)if(this.childs[b].contains(a))return!0;return!1};a.Node.prototype.equalToMinus=function(){return"compOperator"===this.type?(this.type="operator",
this.value="-",f=new a.Node("compOperator","=="),r=new a.Node("number","0"),f.addChild(this),f.addChild(r),k=this.getRoot(),k.setAllEvaluateFunction(),k):this};a.Node.prototype.setAllEvaluateFunction=function(){this.setEvaluateFunction();for(var a=0,b=this.childs.length;a<b;a++)this.childs[a].setAllEvaluateFunction()};a.Node.prototype.setEvaluateFunction=function(){if("number"===this.type)this.evaluate=function(a){return parseFloat(this.value)};else if("string"===this.type)this.evaluate=function(a){return this.value};
else if("identifier"===this.type&&0===this.childs.length)if("rnd"==this.value)this.evaluate=function(a){return Math.random()};else{var a;this.evaluate=function(b,c){a=b.variables[this.value];if("object"===typeof a)return a.evaluate(b);if(void 0==a&&(c||b.matrices[this.value]))a=b.matrices[this.value];return void 0!==a?a:0}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1===this.childs[0].childs.length){var c,f;this.evaluate=function(a){c=this.childs[0].childs[0].evaluate(a);
try{return f=a.vectors[this.value][0>c?0:d(c)],void 0!==f?f:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var k,g;this.evaluate=function(a){k=this.childs[0].childs[0].evaluate(a);g=this.childs[0].childs[1].evaluate(a);try{return f=a.matrices[this.value][0>k?0:d(k)][0>g?0:d(g)],void 0!==f?f:0}catch(b){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var r;this.evaluate=function(a){r=[];
for(var b=0,c=this.childs[0].childs.length;b<c;b++)r.push(this.childs[0].childs[b].evaluate(a));return"_Eval_"===this.value?a.evalExpression(a.parser.parse(r[0])):a.functions[this.value].apply(a,r)}}else if("operator"===this.type){var v,D,B;"+"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a,!0);D=this.childs[1].evaluate(a,!0);if("matrix"!==v.type||"matrix"!==D.type)return v+D;a=v;var b=D;n=a.rows;m=a.cols;q=e(n,m);for(t=0;t<n;t++)for(p=0;p<m;p++)q[p][t]=a[p][t]+b[p][t];return q}:
"-"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a,!0);D=this.childs[1].evaluate(a,!0);if("matrix"!==v.type||"matrix"!==D.type)return v-D;a=v;var b=D;n=a.rows;m=a.cols;q=e(n,m);for(t=0;t<n;t++)for(p=0;p<m;p++)q[p][t]=a[p][t]-b[p][t];return q}:"*"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a,!0);D=this.childs[1].evaluate(a,!0);return"matrix"!==v.type||"matrix"!==D.type?v*D:l(v,D)}:"/"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a,!0);D=
this.childs[1].evaluate(a,!0);if("matrix"!==v.type||"matrix"!==D.type)return v/D;a=v;var c;c=D;var f=e(c.length,c.length),d=b(c);if(0===d)c=0;else{var d=1/d,k;if(1<c.length)for(var g=0,n=c.length;g<n;g++){k=d;for(var r=0;r<n;r++)f[r][g]=k*b(h(g,r,c)),k=-k;d=-d}else f[0][0]=d;c=f}a=0===c?e(a.rows,a.cols):l(a,c);return a}:"%"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a);D=this.childs[1].evaluate(a);return v-d(v/D)*D}:"^"===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(v=this.childs[0].evaluate(a)?1:0)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return(v=this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===
this.value&&(this.evaluate=function(a){v=this.childs[0].evaluate(a)?1:0;return!v+0});else if("conditional"===this.type)this.evaluate=function(a){v=this.childs[0].evaluate(a);return 0<v?this.childs[1].evaluate(a):this.childs[2].evaluate(a)};else if("sign"===this.type)this.evaluate="sign+"===this.value?function(a){return this.childs[0].evaluate(a)}:function(a){return-this.childs[0].evaluate(a)};else if("parentheses"===this.type)this.evaluate=function(a,b){return this.childs[0].evaluate(a,b)};else if("(expr)"===
this.type||"[expr]"===this.type){var z,I;this.evaluate=function(a){z=this.childs.length;B=[];if(1===z&&1===this.childs[0].childs.length&&"(expr)"===this.type)B=this.childs[0].childs[0].evaluate(a);else for(var b=0;b<z;b++){I=[];for(var c=0,f=this.childs[b].childs.length;c<f;c++)I.push(this.childs[b].childs[c].evaluate(a));B[b]=I}return B}}else if("asign"===this.type){var G,M,L,w,N,F;this.evaluate=function(a){G=this.childs[0];M=this.childs[1];1===G.childs.length&&"square_bracket"===G.childs[0].type?
(c=G.childs[0].childs,1===c.length?(L=c[0].evaluate(a),L=0>L?0:d(L),a.vectors[G.value][L]=M.evaluate(a)):2===c.length&&(w=c[0].evaluate(a),N=c[1].evaluate(a),w=0>w?0:d(w),N=0>N?0:d(N),a.matrices[G.value][w]||(a.matrices[G.value][w]=[]),a.matrices[G.value][w][N]=M.evaluate(a))):(F=M.evaluate(a),F.type?a.matrices[G.value]=F:a.variables[G.value]=F)}}};var n,m,q,p,t,g,v;a.Node.prototype.toString=function(){var a="tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:
"");for(var b=0,c=this.childs.length;b<c;b++)a+=this.sep+this.childs[b].toString();return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c,k,f,r,n=/^\s+/,m=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,q=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,p=/^==|^!=|^<=|^<|^>=|^>|^#/,t=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,g=/^=/,v=/^[\?\:]/,u=/^[\+\-\*\/\%\^]/,s=/^\[|^\]/,x=/^\(|^\)/,A=/^,/,C=/^;/;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=
function(a){function y(a,d,k){l.push({type:a,value:d});c=c.slice(k);b+=k;f++;r=a}if(e=a)a=a.replace(/\\u(\S+) /g,function(a,b){return String.fromCharCode(parseInt(b,16))}),a=a.replace(/\&sup(.+);/g,"^$1 "),a=a.replace(/&squot;/g,"'"),a.match(/\=\|\*/g)&&(a=a.replace("|*","'","g").replace("*|","'","g")),a.match(/\=\|/g)&&(a=a.replace("|","'","g"));l=[];h=!1;b=0;c=a;f=0;for(r="";a&&b<a.length;)if(h=b,"'"==c[0]){for(k=1;"'"!=c[k];)if(k<c.length)k++;else{console.log(">Error, unknown symbol: ["+c+"], in the string <<"+
e+">>");return}d=c.substring(1,k);y("string",d,d.length+2)}else if(d=c.match(n))c=c.slice(d[0].length),b+=d[0].length,f++;else if(d=c.match(m))"number"===r&&l.push({type:"operator",value:"*"}),y("identifier",d[0],d[0].length);else if(d=c.match(q))y("number",d[0],d[0].length);else if(d=c.match(p)){var z=d[0];"#"==z&&(z="!=");y("compOperator",z,d[0].length)}else if(d=c.match(t))z=d[0],"||"==z?z="|":"&&"==z?z="&":"~"==z&&(z="!"),y("boolOperator",z,d[0].length);else if((d=c.match(g))&&!c.match(/^==/))y("asign",
d[0],d[0].length);else if(d=c.match(v))y("conditional",d[0],d[0].length);else if(d=c.match(u))y("operator",d[0],d[0].length);else if(d=c.match(s))y("square_bracket",d[0],d[0].length);else if(d=c.match(x))y("parentheses",d[0],d[0].length);else if(d=c.match(A))y("separator",d[0],d[0].length);else if(d=c.match(C))y("final_of_expresion",d[0],d[0].length);else if(h==b){console.log("Error, simbolo no conocido: ["+c+"], en la cadena <<"+e+">>");return}return l};var y,E=/rnd|pi|e|Infinity|-Infinity|sqr|sqrt|ra\u00edz|exp|log|log10|abs|ent|sgn|ind|sin|sen|cos|tan|cot|sec|csc|sinh|senh|cosh|tanh|coth|sech|csch|asin|asen|acos|atan|min|max/;
a.Tokenizer.prototype.flatTokens=function(a,b){a=a||[];b=b||"";y="";for(var c=0,f=a.length;c<f;c++)y="string"==a[c].type?y+"&squot;"+a[c].value+"&squot;":"identifier"==a[c].type&&!a[c].value.match(E)?y+b+a[c].value:y+a[c].value;return y};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Parser=function(b){this.evaluator=b;this.tokenizer=new a.Tokenizer;this.vectors={};this.matrices={};this.variables={};this.functions={};this.registerDefaultValues()};a.Parser.prototype.setVariable=
function(a,b){this.variables[a]=b};a.Parser.prototype.getVariable=function(a){return this.variables[a]};a.Parser.prototype.setVector=function(a,b,c){this.vectors[a][b]=c};a.Parser.prototype.getVector=function(a){this.vectors.hasOwnProperty(a)||(this.vectors[a]=[0,0,0]);return this.vectors[a]};a.Parser.prototype.setMatrix=function(a,b,c,f){this.matrices[a][b][c]=f};a.Parser.prototype.getMatrix=function(a){this.matrices.hasOwnProperty(a)||(this.matrices[a]=[[0,0,0],[0,0,0],[0,0,0]]);return this.matrices[a]};
a.Parser.prototype.setFunction=function(a,b){this.functions[a]=b};a.Parser.prototype.getFunction=function(a){this.functions.hasOwnProperty(a)||(this.functions[a]=function(){return 0});return this.functions[a]};var e,l,h,b,d,c,k,f,r,n,m,q;a.Parser.prototype.parse=function(p,t){(h=this.tokenizer.tokenize(p))||(h=[]);b=null;t=!t||!1;e=f=k=c=0;for(l=h.length;e<l;e++)if(r=h[e],n=r.value,m=r.type,"identifier"===m&&(e+1<l&&"parentheses"===h[e+1].type&&"("===h[e+1].value?this.getFunction(n):e+1<l&&"square_bracket"===
h[e+1].type&&"["===h[e+1].value?h[e+3]&&"square_bracket"===h[e+3].type&&"]"===h[e+3].value?this.getVector(n):this.getMatrix(n):this.getVariable(n)),"asign"===m&&t&&(m="compOperator",n="=="),"asign"===m)if(d=new a.Node(m,n),null!=b)if("identifier"===b.type)b.parent&&b.parent.replaceLastChild(d),d.addChild(b),b=d,t=!0;else if("square_bracket"===b.type)d.addChild(b.parent),b=d,t=!0;else{d.type="compOperator";d.value="==";for(t=!0;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(d.value);)b=
b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{console.log("Error1: en la expresion <<"+p+">>, en el token {valor: "+n+", tipo: "+m+"}");break}else if("parentheses"===m&&"("===n||"square_bracket"===m&&"["===n)if(d=new a.Node(m,n),"("===n&&c++,"["===n&&k++,null===b)"("===n&&(new a.Node("(expr)","(expr)")).addChild(d),"["===n&&(new a.Node("[expr]","[expr]")).addChild(d),b=d;else if("operator"===b.type||"boolOperator"===b.type||"compOperator"===b.type||"conditional"===b.type||
"asign"===b.type)b.addChild(d),b=d;else if("sign"===b.type)b.addChild(d),b=d;else if("parentheses"===b.type&&"("===b.value)b.addChild(d),b=d;else if("square_bracket"===b.type&&"["===b.value)b.addChild(d),b=d;else if("parentheses"===b.type&&"()"===b.value)b.parent.addChild(d),b=d;else if("square_bracket"===b.type&&"[]"===b.value)b.parent.addChild(d),b=d;else if("identifier"===b.type)b.addChild(d),b=d;else{console.log("Error2: en la expresion <<"+p+">>, en el token ["+e+"] {valor: "+n+", tipo: "+m+
"}");break}else if("parentheses"===m&&")"===n)if(c--,null===b)console.log("Error3: en la expresion <<"+p+">>, en el token (valor:"+n+", tipo:"+m);else{for(;b&&b.parent&&"("!=b.value;)b=b.parent;if(b&&"("===b.value)b.value="()";else{console.log("Error4: en la expresion <<"+p+">>, en el token {valor: "+n+", tipo: "+m+"}");break}}else if("square_bracket"===m&&"]"===n)if(k--,null===b)console.log("Error5: en la expresion <<"+p+">>, en el token (valor:"+n+", tipo:"+m);else{for(;b&&b.parent&&"["!=b.value;)b=
b.parent;if(b&&"["===b.value)b.value="[]";else{console.log("Error6: en la expresion <<"+p+">>, en el token {valor: "+n+", tipo: "+m+"}");break}}else if("number"===m||"string"===m||"identifier"===m)if(d=new a.Node(m,n),null===b)b=d;else if("operator"===b.type||"compOperator"===b.type||"boolOperator"===b.type||"parentheses"===b.type&&"("===b.value||"square_bracket"===b.type&&"["===b.value||"sign"===b.type||"conditional"===b.type||"asign"===b.type)b.addChild(d),b=d;else{console.log("Error7: en la expresion <<"+
p+">>, en el token {valor: "+n+", tipo: "+m+"}");break}else if("operator"===m||"compOperator"===m||"boolOperator"===m)if(d=new a.Node(m,n),null===b)if("-"===n||"+"===n)d.type="sign",d.value="sign"+n,b=d;else if("!"===n)b=d;else{console.log("Error8: en la expresion <<"+p+">>, en el token {valor: "+n+", tipo: "+m+"}");break}else if("operator"===b.type||"compOperator"===b.type||"boolOperator"===b.type||"asign"===b.type||"conditional"===b.type||"square_bracket"===b.type&&"["===b.value&&("-"===n||"+"===
n||"!"===n)||"parentheses"===b.type&&"("===b.value&&("-"===n||"+"===n||"!"===n)){if("-"===n||"+"===n)d.type="sign",d.value="sign"+n;b.addChild(d);b=d}else if("number"===b.type||"parentheses"===b.type&&"()"===b.value||"square_bracket"===b.type&&"[]"===b.value||"string"===b.type||"identifier"===b.type||"conditional"===b.type||"asign"===b.type){for(;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(d.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{console.log("Error9: en la expresion <<"+
p+">>, en el token {valor: "+n+", tipo: "+m+"}");break}else if("conditional"===m)if(d=new a.Node(m,n),null!=b)if("?"===d.value){for(f++;b.parent&&this.getPrecedence(b.parent.value)>this.getPrecedence(d.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{for(f--;b&&b.parent&&"?"!=b.value;)b=b.parent;if(b&&"?"===b.value)b.value="?:";else{console.log("Error10: en la expresion <<"+p+">>, en el token {valor: "+n+", tipo: "+m+"}");break}}else{console.log("Error11: en la expresion <<"+
p+">>, en el token {valor: "+n+", tipo: "+m+"}");break}else if("separator"===m)if(null!=b)for(;b.parent&&"("!=b.value&&"["!=b.value;)b=b.parent;else{console.log("Error12: en la expresion <<"+p+">>, en el token {valor: "+n+", tipo: "+m+"}");break}else{console.log("Error13: en la expresion <<"+p+">>, en el token {valor: "+n+", tipo: "+m+"}");break}0<c&&alert("Error, faltan parentesis por cerrar: "+p);0>c&&alert("Error, faltan parentesis por abrir: "+p);0<k&&alert("Error, faltan square bracketss por cerrar: "+
p);0>k&&alert("Error, faltan square bracketss por abrir: "+p);0!=f&&alert("Error, condicional incompleta: "+p);(q=b?b.getRoot():null)&&q.setAllEvaluateFunction();return q};a.Parser.prototype.getPrecedence=function(a){switch(a){case "=":return 1;case "(":return 2;case "[":return 2;case "?":return 2;case ":":return 3;case "?:":return 3;case "|":return 6;case "&":return 7;case "<":return 5;case "<=":return 5;case ">":return 5;case ">=":return 5;case "==":return 5;case "!=":return 5;case "+":return 6;
case "-":return 6;case "/":return 7;case "*":return 7;case "sign-":return 7;case "sign+":return 7;case "!":return 8;case "^":return 8;case "%":return 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 b=this;this.functions._Trace_=function(a){console.log(a)};this.functions._Stop_Audios_=function(){b.evaluator.parent.stopAudios()};this.functions.esCorrecto=function(c,f,d){return a.esCorrecto(c,f,b.evaluator,d)};this.functions.escorrecto=function(c,f,d){return a.escorrecto(c,f,b.evaluator,d)};window.parent!==window&&(this.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",
name:a,value:b},"*")},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*")},this.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",name:a,value:b},"*")})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Evaluator=function(e){this.parent=e;this.parser=new a.Parser(this);this.variables=this.parser.variables;this.functions=this.parser.functions;this.vectors=this.parser.vectors;this.matrices=this.parser.matrices};
a.Evaluator.prototype.setVariable=function(a,e){this.variables[a]=e};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,h,b){h=0>h?0:e(h);this.vectors[a][h]=b};a.Evaluator.prototype.getVector=function(a,h){h=0>h?0:e(h);return this.vectors[a][h]};a.Evaluator.prototype.setMatrix=function(a,h,b,d){h=0>h?0:e(h);b=0>b?0:e(b);this.matrices[a][h][b]=d};a.Evaluator.prototype.getMatrix=function(a,h,b){h=0>h?0:e(h);b=0>b?0:e(b);return this.matrices[a][h][b]};
a.Evaluator.prototype.setFunction=function(a,e){this.functions[a]=e};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a){return a?a.evaluate(this):0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2,l=!1;a.RTFNode=function(a,b,f,d){this.evaluator=a;this.type="rtfNode";this.value=b;this.nodeType=f;this.style=d;this.styleString=d.toString();this.color=d.textColor;this.underline=d.textUnderline;this.overline=
d.textOverline;this.parent=null;this.children=[];switch(this.nodeType){case "textBlock":this.draw=this.drawTextBlock;break;case "textLineBlock":this.draw=this.drawTextLineBlock;break;case "formula":this.draw=this.drawFormula;break;case "superIndex":this.draw=this.drawSuperIndex;break;case "subIndex":this.draw=this.drawSubIndex;break;case "dynamicText":this.draw=this.drawDynamicText;this.decimal_symbol=this.evaluator.parent.decimal_symbol;break;case "fraction":this.draw=this.drawFraction;break;case "numerator":case "denominator":this.draw=
this.drawNumDen;break;case "radical":this.draw=this.drawRadical;break;case "limit":this.draw=this.drawLimit;break;case "integral":this.draw=this.drawIntegral;break;case "sum":this.draw=this.drawSum;break;case "matrix":this.draw=this.drawMatrix;break;case "defparts":this.draw=this.drawDefparts;break;case "text":case "newLine":this.draw=this.drawText;break;case "hyperlink":this.draw=this.drawHyperlink;break;case "mathSymbol":this.draw=this.drawMathSymbol;break;case "index":case "radicand":case "from":case "to":case "what":case "element":this.draw=
this.drawGenericBlock;break;case "componentNumCtrl":this.draw=this.drawComponentNumCtrl;break;case "componentSpace":this.draw=this.drawComponentSpace}};a.RTFNode.prototype.getRoot=function(){return null==this.parent?this:this.parent.getRoot()};a.RTFNode.prototype.addChild=function(a){a.parent=this;this.children.push(a)};var h=0,b=0,d=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var c=0,k=this.children.length;c<
k;c++)this.children[c].getTextMetrics()}else if("textLineBlock"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("newLine"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);var f=a.getFontMetrics(this.styleString);this.baseline=f.baseline;this.descent=f.descent;this.ascent=f.ascent;this.width=f.width;this.height=f.height}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);
f=a.getFontMetrics(this.styleString);this.baseline=f.baseline;this.descent=f.descent;this.ascent=f.ascent;var c=this.value,r;"string"!=typeof this.value&&(k=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),r=void 0==this.fixed?l:this.fixed,c=this.evaluator.evalExpression(this.value,k,r),parseFloat(c)==c&&(c=parseFloat(c).toFixed(k),c=r?c:parseFloat(c),c=c.toString().replace(".",this.decimal_symbol)),c+=" ");this.width=a.getTextWidth(c,this.styleString);this.height=f.height}else if("formula"==
this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("hyperlink"===this.nodeType)c=a.getFontMetrics(this.styleString),this.baseline=c.baseline,this.descent=c.descent,this.ascent=c.ascent,this.width=a.getTextWidth(this.value,this.styleString),this.height=c.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),k=h,f=b,k=d,c=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.height&&(this.ascent=c.ascent,this.descent=c.descent,this.height=this.ascent+this.descent,this.width=1.5*this.spaceWidth),c=k/2-f+this.height,this.superIndexPos=c-this.ascent,this.ascent=c,this.descent=f,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),k=h,f=b,c=a.getFontMetrics(this.styleString),
this.getBlockMetric(),0>this.height&&(this.ascent=c.ascent,this.descent=c.descent,this.height=this.ascent+this.descent,this.width=1.5*this.spaceWidth),this.subIndexPos=f+1,this.ascent=k,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);f=b;k=d;r=this.children[0];var n=this.children[1],c=a.getFontMetrics(r.styleString);r.getBlockMetric();n.getBlockMetric();
0>r.height&&(r.height=c.height,r.width=this.spaceWidth);0>n.height&&(n.height=c.height,n.width=this.spaceWidth);this.height=r.height+n.height-1;this.ascent=r.height+k/2-f;this.descent=this.height-this.ascent;this.baseline=this.ascent;this.width=Math.max(r.width,n.width)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator,"","radicand",f),this.children[1].addChild(this.children[0]),
this.children[0]=new a.RTFNode(this.evaluator,"","index",f);else if("index"!==this.children[0].nodeType||"radicand"!==this.children[1].nodeType){r=new a.RTFNode(this.evaluator,"","radicand",f);c=0;for(k=this.children.length;c<k;c++)r.addChild(this.children[c]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",f);this.children[1]=r}f=this.children[0];c=this.children[1];f.getBlockMetric();c.getBlockMetric();this.ascent=c.height/2<f.height?c.height/2+f.height+2-c.descent:c.ascent+
4;this.descent=c.descent;this.baseline=this.ascent;this.height=this.ascent+this.descent;this.width=f.width+c.width+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=this.children[0],k=this.children[1],r=this.children[2],f.getBlockMetric(),k.getBlockMetric(),r.getBlockMetric(),-1==f.ascent&&(n=a.getFontMetrics(f.styleString),f.ascent=n.ascent,f.descent=n.descent,f.height=n.height),-1==k.ascent&&(n=a.getFontMetrics(k.styleString),k.ascent=n.ascent,
k.descent=n.descent,k.height=n.height),c=a.getFontMetrics(this.styleString),this.ascent=c.height+k.height>r.ascent?c.height-c.descent+k.height:r.ascent,this.descent=f.height>r.descent?f.height+c.descent:r.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent,c=this.style.clone(),c.fontType="Times New Roman",c.Bold="bold",c=c.toString(),c=a.getTextWidth(String.fromCharCode(8721),c),this.width=Math.max(f.width,k.width,c)+Math.max(r.width,this.spaceWidth)+this.spaceWidth;else if("integral"==
this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=this.children[0],k=this.children[1],r=this.children[2],f.getBlockMetric(),k.getBlockMetric(),r.getBlockMetric(),-1==f.ascent&&(n=a.getFontMetrics(f.styleString),f.ascent=n.ascent,f.descent=n.descent,f.height=n.height),-1==k.ascent&&(n=a.getFontMetrics(k.styleString),k.ascent=n.ascent,k.descent=n.descent,k.height=n.height),c=a.getFontMetrics(this.styleString),this.ascent=c.height+k.height>r.ascent?c.height-c.descent+k.height:r.ascent,
this.descent=f.height>r.descent?f.height+c.descent:r.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent,c=this.style.clone(),c.fontSize*=1.5,c.fontType="Times New Roman",c.Bold="bold",c=c.toString(),c=a.getTextWidth(String.fromCharCode(8747),c),this.width=Math.max(f.width,k.width,c)+Math.max(r.width,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=this.children[0],k=this.children[1],r=this.children[2],c=a.getFontMetrics(this.styleString),
f.getBlockMetric(),k.getBlockMetric(),r.getBlockMetric(),-1==f.ascent&&(n=a.getFontMetrics(f.styleString),f.ascent=n.ascent,f.descent=n.descent,f.height=n.height),-1==k.ascent&&(n=a.getFontMetrics(k.styleString),k.ascent=n.ascent,k.descent=n.descent,k.height=n.height),-1==r.ascent&&(n=a.getFontMetrics(r.styleString),r.ascent=n.ascent,r.descent=n.descent,r.height=n.height),this.ascent=r.ascent,this.descent=Math.max(c.height,r.descent),this.baseline=this.ascent,this.height=this.ascent+this.descent,
c=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==f.width&&(f.width=this.spaceWidth),0==k.width&&(k.width=this.spaceWidth),0==r.width&&(r.width=this.spaceWidth),this.width=k.width+f.width+r.width+c+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);c=a.getFontMetrics(this.styleString);f=b;r=c.ascent;for(var n=c.descent,m=c.height,q=this.spaceWidth,p,t,c=0,k=this.children.length;c<k;c++)this.children[c].getBlockMetric(),p=this.children[c].height,
t=this.children[c].width,m<p&&(m=p,r=this.children[c].ascent,n=this.children[c].descent),q<t&&(q=t);this.childWidth=q+2*this.spaceWidth;this.childHeight=m;this.childAscent=r;this.childDescent=n;this.height=this.rows*m;this.ascent=this.height/2+f;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);c=a.getFontMetrics(this.styleString);f=b;r=c.ascent;n=c.descent;m=c.height;
q=this.spaceWidth;c=0;for(k=this.children.length;c<k;c++)this.children[c].getBlockMetric(),p=this.children[c].height,t=this.children[c].width,m<p&&(m=p,r=this.children[c].ascent,n=this.children[c].descent),q<t&&(q=t);this.childWidth=q+2*this.spaceWidth;this.childHeight=m;this.childAscent=r;this.childDescent=n;this.height=this.parts*m;this.ascent=this.height/2+f;this.descent=this.height-this.ascent;this.width=q+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),
f=a.getFontMetrics(this.styleString),this.baseline=f.baseline,this.descent=f.descent,this.ascent=f.ascent,this.width=a.getTextWidth(this.value,this.styleString)+a.getTextWidth(" ",this.styleString),this.height=f.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,k=-1,f,e=0,n=this.children.length;e<n;e++){f=this.children[e];f.getTextMetrics();childAscent=f.ascent;childDescent=f.descent;this.width+=f.width;var l=childDescent;f=f.height;
h=childAscent;b=l;d=f;k<childAscent&&(k=childAscent);a<childDescent&&(a=childDescent)}this.ascent=k;this.descent=a;this.baseline=this.ascent;this.height=this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,b,f,d,h,m,q){this.stableWidth||(this.getTextMetrics(),e=d,l=h);q=q?-this.children[0].ascent:0;h=d=0;for(m=this.children.length;h<m;h++)0<h&&(d+=this.children[h-1].height),this.children[h].draw(a,b+0,f+q+d)};a.RTFNode.prototype.drawTextLineBlock=function(b,d,f){for(var e=0,h=0,
l=this.children.length;h<l;h++)0<h&&(e+=this.children[h-1].width,"formula"==this.children[h-1].nodeType&&(e+=2*a.getTextWidth(" ",this.children[h].styleString))),this.children[h].draw(b,d+e,f+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,f){for(var d=0,e=0,h=this.children.length;e<h;e++)0<e&&(d+=this.children[e-1].width),this.children[e].draw(a,b+this.spaceWidth+d,f)};a.RTFNode.prototype.drawText=function(a,b,f){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign=
"start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,f);if(this.underline){var d="bold"==this.style.textBold,e=d?1:0.5;a.lineWidth=d?2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b-1,parseInt(f+this.descent/2)+e);a.lineTo(b-1+this.width,parseInt(f+this.descent/2)+e);a.stroke()}this.overline&&(e=(d="bold"==this.style.textBold)?2:1.5,a.lineWidth=d?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(b-1,parseInt(f-this.ascent)+e),a.lineTo(b-1+this.width,
parseInt(f-this.ascent)+e),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,d,f){var h=Math.floor(0.5*this.spaceWidth),n=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),m=void 0==this.fixed?l:this.fixed,q=this.evaluator.evalExpression(this.value,n,m);parseFloat(q).toString()===q.toString()&&(q=m?parseFloat(q).toFixed(n):parseFloat(parseFloat(q).toFixed(n)),q=(""+q).replace(".",this.decimal_symbol));null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;
b.textAlign="start";b.textBaseline="alphabetic";this.width=a.getTextWidth(q,this.styleString);b.fillText(q,h+d,f);this.underline&&(m=(n="bold"==this.style.textBold)?1:0.5,b.lineWidth=n?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(h+d-1,parseInt(f+this.descent/2)+m),b.lineTo(h+d-1+this.width,parseInt(f+this.descent/2)+m),b.stroke());this.overline&&(m=(n="bold"==this.style.textBold)?2:1.5,b.lineWidth=n?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(h+
d-1,parseInt(f-this.ascent)+m),b.lineTo(h+d-1+this.width,parseInt(f-this.ascent)+m),b.stroke());this.width+=2*h};a.RTFNode.prototype.drawHyperlink=function(a,b,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,b-1,d);var e="bold"==this.style.textBold,h=e?1:0.5;a.linew=e?2:1;a.beginPath();a.moveTo(b-1,parseInt(d+this.descent/2)+h);a.lineTo(b-1+this.w,parseInt(d+
this.descent/2)+h);a.stroke();a.restore()};a.RTFNode.prototype.drawRadical=function(a,b,d){var e=Math.floor(this.spaceWidth);this.children[0].draw(a,b,Math.floor(d+this.children[1].descent-this.children[1].height/2-this.children[0].descent));this.children[1].draw(a,b+1.5*e+this.children[0].width,d);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b,Math.floor(d+this.children[1].descent-this.children[1].height/2));a.lineTo(b+this.children[0].width,Math.floor(d+this.children[1].descent-
this.children[1].height/2));a.lineTo(b+this.children[0].width+0.5*e,d+this.children[1].descent);a.lineTo(b+this.children[0].width+1*e,d-this.children[1].ascent);a.lineTo(b+this.children[0].width+2*e+this.children[1].width,d-this.children[1].ascent);a.stroke()};a.RTFNode.prototype.drawFraction=function(a,b,d){this.children[0].draw(a,b+(this.width-this.children[0].width)/2,d-this.ascent);this.children[1].draw(a,b+(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(b+e,parseInt(d-this.ascent+this.children[0].height)+0.5);a.lineTo(b-e+this.width-1,parseInt(d-this.ascent+this.children[0].height)+0.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,b,d){for(var e=0,h=0,l=this.children.length;h<l;h++)0<h&&(e+=this.children[h-1].width),this.children[h].draw(a,b+e,d+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,d){for(var e=0,h=0,l=this.children.length;h<
l;h++)0<h&&(e+=this.children[h-1].width),this.children[h].draw(a,b+e,d+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,d){for(var e=0,h=0,l=this.children.length;h<l;h++)0<h&&(e+=this.children[h-1].width),this.children[h].draw(a,b+e,d-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,d,f){var e=a.getFontMetrics(this.styleString),h=" "+String.fromCharCode(8594),l=a.getTextWidth(h,this.styleString);this.children[0].draw(b,d,f+e.descent+this.children[0].ascent);this.children[1].draw(b,
d+this.children[0].width+l,f+e.descent+this.children[1].ascent);this.children[2].draw(b,d+l+this.children[0].width+this.children[1].width,f);null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",d+this.children[0].width,f);b.fillText(h,d+this.children[0].width,f+e.descent+this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(b,d,f){var e=this.style.clone();e.fontSize*=1.5;e.fontType="Times New Roman";
e.Bold="bold";var e=e.toString(),h=a.getTextWidth(String.fromCharCode(8747),e),l=a.getFontMetrics(e),q=Math.max(this.children[0].width,this.children[1].width,Math.floor(1.5*h));this.children[0].draw(b,d+h,f+l.descent+this.children[0].ascent);this.children[1].draw(b,d+h+this.spaceWidth/2,f-this.ascent+this.children[1].ascent);this.children[2].draw(b,d+q+h,f);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),d,f+
l.descent/2)};a.RTFNode.prototype.drawSum=function(b,d,f){var e=this.style.clone();e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),h=a.getTextWidth(String.fromCharCode(8721),e),l=a.getFontMetrics(this.styleString),q=Math.max(this.children[0].width,this.children[1].width,h);this.children[0].draw(b,d+(q-this.children[0].width)/2,f+l.descent+this.children[0].ascent);this.children[1].draw(b,d+(q-this.children[1].width)/2,f-l.ascent-this.children[1].descent);this.children[2].draw(b,d+q,f);
null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),d+Math.floor((q-h)/2),f-5)};a.RTFNode.prototype.drawMatrix=function(a,b,d){for(var e,h,l=0,q=this.children.length;l<q;l++)e=l%this.columns,h=Math.floor(l/this.columns),this.children[l].draw(a,2*this.spaceWidth+b+e*this.childWidth,d-this.ascent+this.childAscent+h*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(b+
this.spaceWidth)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,d+this.descent+0.5);a.lineTo(Math.floor(b+this.spaceWidth)+0.5,d+this.descent+0.5);a.moveTo(Math.floor(b+this.width-this.spaceWidth)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.width-this.spaceWidth/2)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.width-this.spaceWidth/2)-0.5,d+this.descent+0.5);a.lineTo(Math.floor(b+this.width-this.spaceWidth)-
0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawDefparts=function(a,b,d){for(var e=0,h=this.children.length;e<h;e++)this.children[e].draw(a,b+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(b+this.spaceWidth/3)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/6)+0.5,d-this.ascent+0.5+(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(b+this.spaceWidth/
6)+0.5,d+this.descent-this.height/2-(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(b+0.5,d+this.descent-this.height/2);a.lineTo(Math.floor(b+this.spaceWidth/6)+0.5,d+this.descent-this.height/2+(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(b+this.spaceWidth/6)+0.5,d+this.descent+0.5-(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(b+this.spaceWidth/3)+0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawMathSymbol=function(a,b,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("(",b,d)):")"==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText(")",b+this.spaceWidth,d)):(a.font=this.styleString,a.textAlign="center",a.textBaseline="alphabetic",a.fillText(this.value,b+this.width/2,d))};a.RTFNode.prototype.drawGenericBlock=function(a,b,d){for(var e=0,h=0,l=this.children.length;h<l;h++)0<
h&&(e+=this.children[h-1].width),this.children[h].draw(a,b+e,d)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,b,d){this.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+b+","+(d-this.parent.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,b,d){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(b+"");this.componentSpace.yExpr=this.evaluator.parser.parse(d-this.parent.ascent+
"")};a.RTFNode.prototype.draw=function(a,b,d){console.log(">>> Dibujo desconocido ",this.nodeType)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=String.fromCharCode,l,h,b,d,c,k,f,r,n,m,q;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[];
l=[];h=a.length;l=[];b="";c=d=0;f=a.charAt(0);r=!1;for(n="text";d<h;)k=f,f=a.charAt(d+1),r?"\\"===f||"{"===f||"}"===f||" "===f||";"===f?(r=!1,b+=k," "===f&&(d++,f=a.charAt(d+1)),(m=b.match(/^\'([0-9a-f]{2})/))?(q="","text"===n&&(q=l.pop().value),b=q+=e(parseInt(m[1],16))+b.substring(3)):(m=b.match(/^u[0-9]+/))?(q="","text"===n&&(q=l.pop().value),b=q+=e(m[0].substring(1))):(l.push({type:"controlWord",value:b}),n="controlWord",b="")):b+=k:"\\"===k?(r=!0,""!==b&&(l.push({type:"text",value:b}),n="text"),
b=""):"{"===k?(c++,""!==b&&l.push({type:"text",value:b}),b="",l.push({type:"openBlock",value:c}),n="openBlock"):"}"===k?(""!==b&&l.push({type:"text",value:b}),b="",l.push({type:"closeBlock",value:c}),n="closeBlock",c--):""===b&&" "===k&&"controlWord"===n?n="text":b+=k,d++;""!==b&&l.push({type:"text",value:b});return l};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c,k,f,r,n,m,q,p,t,g,v,u,s,x,A,C,y,E,D,B,z,I,G,M,L;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=
new a.RTFTokenizer};a.RTFParser.prototype.parse=function(w){w=e=this.tokenizer.tokenize(w);for(var N=[],F=!1,J=!1,K=[],H=0,O=w.length;H<O;H++){"openBlock"==w[H].type&&K.push(w[H].value);"closeBlock"==w[H].type&&(K.pop(),0>=K.length&&(F=!1));if("controlWord"==w[H].type&&("expr"==w[H].value||"decimals"==w[H].value))J=!0;"controlWord"==w[H].type&&"mjaformula"==w[H].value&&(F=!0);if("text"==w[H].type&&F&&!J){for(var S=0,Q=w[H].value,R="",P=0,U=Q.length;P<U;P++)if("("==Q.charAt(P)||")"==Q.charAt(P)||"+"==
Q.charAt(P)||"-"==Q.charAt(P)||"*"==Q.charAt(P)||"="==Q.charAt(P))R=Q.substring(S,P),""!=R&&N.push({type:"text",value:R}),N.push({type:Q.charAt(P),value:Q.charAt(P)}),S=P+1;R=Q.substring(S,P);""!=R&&N.push({type:"text",value:R})}else N.push(w[H]),"text"==w[H].type&&J&&(J=!1)}e=N;l={};b=2;if("openBlock"==e[0].type&&"fonttbl"==e[1].value){for(h=e[0].value;"closeBlock"!=e[b].type&&e[b].value!=h;)l[e[b].value]=e[b+2].value.substring(0,e[b+2].value.length-1),b+=3;b++}d={};c=0;if("openBlock"==e[b].type&&
"colortbl"==e[b+1].value){h=e[b++].value;for(b++;"closeBlock"!=e[b].type&&e[b].value!=h;)k=parseInt(e[b++].value.substring(3)).toString(16),f=parseInt(e[b++].value.substring(5)).toString(16),r=parseInt(e[b++].value.substring(4)).toString(16),";"===e[b].value&&b++,d[c++]="#"+(2>k.length?"0"+k:k)+(2>f.length?"0"+f:f)+(2>r.length?"0"+r:r);b++}n=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");m=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");n.addChild(m);t=p=q=null;A=x=s=u=v=g=!1;C=[new a.FontStyle(20,
"Arial","","",!1,!1,null)];y=C[0];E=!0;B=D=-1;z=[];L=M=G=I=!1;w=b;for(N=e.length;w<N;w++)if("controlWord"==e[w].type&&l[e[w].value])y.fontType=l[e[w].value];else if("controlWord"==e[w].type&&e[w].value.match(/^fs(\d+)/))y.fontSize=parseInt(e[w].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==e[w].type&&"b"==e[w].value)y.textBold="bold";else if("controlWord"==e[w].type&&"b0"==e[w].value)y.textBold="";else if("controlWord"==e[w].type&&"i"==e[w].value)y.textItalic="italic";else if("controlWord"==
e[w].type&&"i0"==e[w].value)y.textItalic="";else if("controlWord"==e[w].type&&"ul"==e[w].value)y.textUnderline=!0;else if("controlWord"==e[w].type&&"ulnone"==e[w].value)y.textUnderline=!1;else if("controlWord"==e[w].type&&"ol"==e[w].value)y.textOverline=!0;else if("controlWord"==e[w].type&&"olnone"==e[w].value)y.textOverline=!1;else if("controlWord"==e[w].type&&e[w].value.match(/^cf(\d+)/))y.textColor=d[parseInt(e[w].value.substring(2))];else if("openBlock"==e[w].type)D=e[w].value,y=y.clone(),C.push(y),
z.push(null);else if("closeBlock"==e[w].type)e[w].value==B&&(B=-1,g=!1,m=m.parent),C.pop(),y=C[C.length-1],z.pop();else if("controlWord"==e[w].type&&"par"==e[w].value){m.addChild(new a.RTFNode(this.evaluator,"","newLine",y.clone()));n=new a.RTFNode(this.evaluator,"","textLineBlock",y.clone());if("textBlock"!=m.nodeType)for(m=m.parent;"textBlock"!=m.nodeType;)m=m.parent;m.addChild(n);m=n}else if("controlWord"==e[w].type&&"mjaformula"==e[w].value)I=!0,B=D,g=!0,n=new a.RTFNode(this.evaluator,"","formula",
y.clone()),m.addChild(n),m=n,z[z.length-1]=n;else if("controlWord"==e[w].type&&("fraction"==e[w].value||"radicand"==e[w].value||"radical"==e[w].value||"what"==e[w].value||"sum"==e[w].value||"integral"==e[w].value||"limit"==e[w].value))F=z[z.length-2].style.clone(),n=new a.RTFNode(this.evaluator,"",e[w].value,F),z[z.length-2].addChild(n),z[z.length-1]=n;else if("controlWord"==e[w].type&&"index"==e[w].value||"to"==e[w].value||"from"==e[w].value)F=z[z.length-2].style.clone(),F.fontSize=parseInt(F.fontSize-
0.2*F.fontSize),8>F.fontSize&&(F.fontSize=8),n=new a.RTFNode(this.evaluator,"",e[w].value,F),z[z.length-2].addChild(n),z[z.length-1]=n;else if("controlWord"==e[w].type&&("num"==e[w].value||"den"==e[w].value))F=z[z.length-2].style.clone(),F.fontSize=Math.round(F.fontSize-0.1*F.fontSize),8>F.fontSize&&(F.fontSize=8),"num"==e[w].value?n=new a.RTFNode(this.evaluator,"","numerator",F):"den"==e[w].value&&(n=new a.RTFNode(this.evaluator,"","denominator",F)),z[z.length-2].addChild(n),z[z.length-1]=n;else if("controlWord"==
e[w].type&&("subix"==e[w].value||"supix"==e[w].value))F=z[z.length-2].style.clone(),F.fontSize=Math.floor(F.fontSize-F.fontSize/3),8>F.fontSize&&(F.fontSize=8),"subix"==e[w].value?n=new a.RTFNode(this.evaluator,"","subIndex",F):"supix"==e[w].value&&(n=new a.RTFNode(this.evaluator,"","superIndex",F)),n.originalStyle=z[z.length-2].style.clone(),z[z.length-2].addChild(n),z[z.length-1]=n;else if("controlWord"==e[w].type&&("defparts"==e[w].value||"matrix"==e[w].value||"element"==e[w].value))F=z[z.length-
2].style.clone(),n=new a.RTFNode(this.evaluator,"",e[w].value,F),z[z.length-2].addChild(n),z[z.length-1]=n,"defparts"==e[w].value?t=n:"matrix"==e[w].value&&(p=n);else if("controlWord"==e[w].type&&"parts"==e[w].value)A=!0;else if("text"==e[w].type&&A)t.parts=parseInt(e[w].value),A=!1;else if("controlWord"==e[w].type&&"rows"==e[w].value)s=!0;else if("text"==e[w].type&&s)p.rows=parseInt(e[w].value),s=!1;else if("controlWord"==e[w].type&&"columns"==e[w].value)x=!0;else if("text"==e[w].type&&x)p.columns=
parseInt(e[w].value),x=!1;else if("controlWord"==e[w].type&&"expr"==e[w].value)E=!1,v=!0;else if("controlWord"==e[w].type&&"decimals"==e[w].value)u=!0;else if("text"==e[w].type&&u)q.decimals=this.evaluator.parser.parse(parseInt(e[w].value)+""),u=!1;else if("controlWord"==e[w].type&&"fixed1"==e[w].value)q.fixed=!0;else if("controlWord"==e[w].type&&"fixed0"==e[w].value)q.fixed=!1;else if(!("controlWord"==e[w].type&&"component"==e[w].value))if("controlWord"==e[w].type&&"NumCtrl"==e[w].value)G=!0;else if("controlWord"==
e[w].type&&"Space"==e[w].value)M=!0;else if("controlWord"==e[w].type&&"hyperlink"==e[w].value)L=!0;else if("text"==e[w].type&&L){textContent=e[w].value.split("|")[0];F=y.clone();n=new a.RTFNode(this.evaluator,textContent,"hyperlink",F);if("textLineBlock"!=m.nodeType)for(m=m.parent;"textLineBlock"!=m.nodeType;)m=m.parent;m.addChild(n);L=!1}else if("text"==e[w].type&&G)n=new a.RTFNode(this.evaluator,e[w].value,"componentNumCtrl",y.clone()),m.addChild(n),G=!1;else if("text"==e[w].type&&M)n=new a.RTFNode(this.evaluator,
e[w].value,"componentSpace",y.clone()),m.addChild(n),M=!1;else if("text"==e[w].type&&v)F=z[z.length-2].style.clone(),textContent=this.evaluator.parser.parse(e[w].value),n=new a.RTFNode(this.evaluator,textContent,"dynamicText",F),z[z.length-2].addChild(n),q=z[z.length-1]=n,v=!1;else if("text"==e[w].type&&!v&&!g){textContent=e[w].value;n=new a.RTFNode(this.evaluator,textContent,"text",y.clone());if("textLineBlock"!=m.nodeType)for(m=m.parent;"textLineBlock"!=m.nodeType;)m=m.parent;m.addChild(n)}else if("text"==
e[w].type&&!v&&g)textContent=e[w].value,n=new a.RTFNode(this.evaluator,textContent,"text",z[z.length-1].style.clone()),z[z.length-1].addChild(n);else if("("==e[w].type||")"==e[w].type)F=z[z.length-1].style.clone(),F.textItalic="",n=new a.RTFNode(this.evaluator,e[w].type,"mathSymbol",F),z[z.length-1].addChild(n);else if("+"==e[w].type||"-"==e[w].type||"*"==e[w].type||"="==e[w].type)n=new a.RTFNode(this.evaluator,e[w].type,"mathSymbol",z[z.length-1].style.clone()),z[z.length-1].addChild(n);if(null!=
m){var T=m.getRoot();T.stableWidth=E;T.getTextMetrics();T.hasFormula=I}return T};a.FontStyle=function(a,b,d,c,f,e,g){this.fontSize=a;this.fontType=b;this.textItalic=d;this.textBold=c;this.textUnderline=f;this.textOverline=e;this.textColor=g};a.FontStyle.prototype.toString=function(){return(this.textBold+" "+this.textItalic+" "+this.fontSize+"px "+this.fontType).trim()};a.FontStyle.prototype.toCSS=function(){var a="style='font: "+this.fontSize+"px "+this.fontType+"; ";this.textUnderline&&!this.textOverline&&
(a+="text-decoration: underline; ");!this.textUnderline&&this.textOverline&&(a+="text-decoration: overline; ");this.textUnderline&&this.textOverline&&(a+="text-decoration: underline overline; ");this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: bold; ");!this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: normal; ");this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: bold; ");!this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: normal; ");
this.textColor&&(a+="color: "+this.textColor+"; ");return a+"'"};a.FontStyle.prototype.clone=function(){return new a.FontStyle(this.fontSize,this.fontType,this.textItalic,this.textBold,this.textUnderline,this.textOverline,this.textColor)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b,d,c,k,f,r,n,m,q,p,t,g;a.Space=function(b,d){this.parent=b;l=this.evaluator=this.parent.evaluator;h=l.parser;this.values=d;this.type="R2";this.xExpr=h.parse("0");this.yExpr=h.parse("0");
this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=h.parse("1");this.fixed=2!=b.version?!1:!0;this.scale=48;this.Oy=this.Ox=0;this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";this.bg_display="topleft";this.background="descinst.com.mja.descartes.DescartesJS.class"===b.code||b.arquimedes?new a.Color("f0f8fa"):new a.Color("ffffff");this.net=2!=b.version?new a.Color("c0c0c0"):"";this.net10=2!=b.version?new a.Color("808080"):"";this.axes=
2!=b.version?new a.Color("808080"):"";this.text=new a.Color("ffafaf");this.numbers=!1;this.x_axis=2!=b.version?"":" ";this.y_axis=2!=b.version?"":" ";this.sensitive_to_mouse_movements=!1;this.cID="";this.mouse_y=this.mouse_x=0;this.ctrs=[];this.graphicsCtr=[];this.graphics=[];this.backgroundGraphics=[];this.zIndex=b.zIndex;this.plecaHeight=b.plecaHeight||0;this.displaceRegionNorth=b.displaceRegionNorth||0;this.displaceRegionWest=b.displaceRegionWest||0;for(var c in d)d.hasOwnProperty(c)&&(this[c]=
d[c]);this.init()};a.Space.prototype.init=function(){e=this.parent;l=this.evaluator;b=this.id;this.displaceRegionNorth=e.displaceRegionNorth||0;this.displaceRegionWest=e.displaceRegionWest||0;k=parseInt(e.container.height);f=parseInt(e.container.width);l.setVariable(b+"._w",this.w);l.setVariable(b+"._h",this.h);this.x=l.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=l.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?(d=k-this.y,this.h>d&&(this.h=d)):(d=this.h+this.y,this.h=d>=k?k:d);0<=this.x?(c=f-this.x,this.w>c&&(this.w=c)):(c=this.w+this.x,this.w=c>=f?f:c);if(""!=this.imageSrc||!this.imageSrc.trim().toLowerCase().match(/vacio.gif$/))this.image=e.getImage(this.imageSrc);this.OxExpr&&(n=this.OxExpr,"%"===n[n.length-1]?this.Ox=this.w*parseFloat(n)/100:(r=parseFloat(n),r!=n&&(r=0),this.Ox=r));this.OyExpr&&(m=this.OyExpr,"%"===m[m.length-1]?this.Oy=this.h*parseFloat(m)/
100:(r=parseFloat(m),r!=m&&(r=0),this.Oy=r));2!==e.version?(l.setVariable(b+"._w",this.w),l.setVariable(b+"._h",this.h),l.setVariable(b+".escala",this.scale),l.setVariable(b+".Ox",this.Ox),l.setVariable(b+".Oy",this.Oy),l.setVariable(b+".mouse_x",0),l.setVariable(b+".mouse_y",0),l.setVariable(b+".mouse_pressed",0)):(r=l.getVariable("_w"),void 0===r&&(r=this.w),l.setVariable("_w",r),r=l.getVariable("_h"),void 0===r&&(r=this.h),l.setVariable("_h",r),r=l.getVariable("escala"),void 0===r&&(r=this.scale),
l.setVariable("escala",r),r=l.getVariable("Ox"),void 0===r&&(r=this.Ox),l.setVariable("Ox",r),r=l.getVariable("Oy"),void 0===r&&(r=this.Oy),l.setVariable("Oy",r),l.setVariable("mouse_x",0),l.setVariable("mouse_y",0),l.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(){q=this.container;this.offsetTop=this.offsetLeft=0;p=this.container.style.display;
for(this.container.style.display="block";q;){t=null;q.getAttribute&&(t=q.getAttribute("class"));if(t&&("DescartesSpace2DContainer"===t||"DescartesSpace3DContainer"===t||"DescartesAppContainer"===t))this.offsetLeft+=q.offsetLeft||0,this.offsetTop+=q.offsetTop||0;q=q.parentNode}this.container.style.display=p};a.Space.prototype.getCursorPosition=function(b){g=a.getCursorPosition(b);return{x:g.x-this.offsetLeft,y:g.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){var e,l;if(a.loadLib)return a;
var h=Math.floor,b=Math.round,d=2*Math.PI,c=a.convertFont("SansSerif,PLAIN,12"),k=a.convertFont("Monospaced,PLAIN,12"),f,r,n,m,q,p,t,g,v,u,s,x,A,C,y,E,D,B,z,I,G,M,L,w,N,F,J,K,H;a.Space2D=function(b,d){a.Space.call(this,b,d);f=this;f.backgroundCanvas=document.createElement("canvas");f.backgroundCanvas.setAttribute("id",f.id+"_background");f.backgroundCanvas.setAttribute("width",f.w+"px");f.backgroundCanvas.setAttribute("height",f.h+"px");f.backgroundCtx=f.backgroundCanvas.getContext("2d");f.backgroundCtx.imageSmoothingEnabled=
!1;f.backgroundCtx.mozImageSmoothingEnabled=!1;f.backgroundCtx.webkitImageSmoothingEnabled=!1;f.canvas=document.createElement("canvas");f.canvas.setAttribute("id",f.id+"_canvas");f.canvas.setAttribute("width",f.w+"px");f.canvas.setAttribute("height",f.h+"px");f.canvas.setAttribute("class","DescartesSpace2DCanvas");f.canvas.setAttribute("style","z-index: "+f.zIndex+";");f.ctx=f.canvas.getContext("2d");f.ctx.imageSmoothingEnabled=!1;f.ctx.mozImageSmoothingEnabled=!1;f.ctx.webkitImageSmoothingEnabled=
!1;f.graphicControlContainer=document.createElement("div");f.graphicControlContainer.setAttribute("id",f.id+"_graphicControls");f.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+f.zIndex+";");f.numericalControlContainer=document.createElement("div");f.numericalControlContainer.setAttribute("id",f.id+"_numericalControls");f.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+f.zIndex+";");f.container=
document.createElement("div");f.container.setAttribute("id",f.id);f.container.setAttribute("class","DescartesSpace2DContainer");f.container.setAttribute("style","left: "+f.x+"px; top: "+f.y+"px; z-index: "+f.zIndex+";");f.parent.arquimedes&&"#f0f8fa"===f.background.getColor()&&(f.container.style.border="1px solid #b8c4c8");f.container.appendChild(f.backgroundCanvas);f.container.appendChild(f.canvas);f.container.appendChild(f.graphicControlContainer);f.container.appendChild(f.numericalControlContainer);
b.container.insertBefore(f.container,b.loader);f.parent.images[f.id+".image"]=f.canvas;f.parent.images[f.id+".image"].ready=1;f.parent.images[f.id+".image"].complete=!0;f.evaluator.setVariable(f.id+".image",f.id+".image");f.parent.images[f.id+".back"]=f.backgroundCanvas;f.parent.images[f.id+".back"].ready=1;f.parent.images[f.id+".back"].complete=!0;f.evaluator.setVariable(f.id+".back",f.id+".back");f.OxString=2!==b.version?f.id+".Ox":"Ox";f.OyString=2!==b.version?f.id+".Oy":"Oy";f.scaleString=2!==
b.version?f.id+".escala":"escala";f.wString=f.id+"._w";f.hString=f.id+"._h";"descartesJS_scenario"!==f.id&&f.registerMouseAndTouchEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){f=this;f.uber.init.call(f);f.canvas&&(f.backgroundCanvas.setAttribute("width",f.w+"px"),f.backgroundCanvas.setAttribute("height",f.h+"px"),f.canvas.setAttribute("width",f.w+"px"),f.canvas.setAttribute("height",f.h+"px"));f.container&&f.findOffset()};a.Space2D.prototype.update=function(a){f=this;r=
f.evaluator;n=f.parent;r.setVariable(f.wString,f.w);r.setVariable(f.hString,f.h);f.drawIfValue=0<r.evalExpression(f.drawif);if(f.drawIfValue){q=f.x!==r.evalExpression(f.xExpr)+f.displaceRegionWest;p=f.y!==r.evalExpression(f.yExpr)+n.plecaHeight+f.displaceRegionNorth;f.spaceChange=a||q||p||f.drawBefore!==f.drawIfValue||f.Ox!==r.getVariable(f.OxString)||f.Oy!==r.getVariable(f.OyString)||f.scale!==r.getVariable(f.scaleString);f.x=q?r.evalExpression(f.xExpr)+f.displaceRegionWest:f.x;f.y=p?r.evalExpression(f.yExpr)+
n.plecaHeight+f.displaceRegionNorth:f.y;f.Ox=r.getVariable(f.OxString);f.Oy=r.getVariable(f.OyString);f.scale=r.getVariable(f.scaleString);f.drawBefore=f.drawIfValue;1E-6>f.scale?(f.scale=1E-6,r.setVariable(f.scaleString,1E-6)):1E6<f.scale&&(f.scale=1E6,r.setVariable(f.scaleString,1E6));if(q||p)f.container.style.left=f.x+"px",f.container.style.top=f.y+"px",f.findOffset();f.container.style.display="block";f.drawTrace=!f.spaceChange&&!f.click;f.spaceChange&&f.drawBackground();f.draw()}else f.container.style.display=
"none"};a.Space2D.prototype.drawBackground=function(){r=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));g=this.scale;v=0;for(u=0>this.w+this.h?0:this.w+this.h;g>u;)g/=10,v++;for(;g<u/10;)g*=10;m.lineWidth=1;""!==this.net&&(m.strokeStyle=this.net.getColor(),this.drawMarks(m,g/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,g,-1);if(""!==this.axes){m.strokeStyle=this.axes.getColor();m.beginPath();if(""!==this.x_axis||2!==this.parent.version)m.moveTo(0,h(this.h/2+this.Oy)+0.5),m.lineTo(this.w,h(this.h/2+this.Oy)+0.5);if(""!==this.y_axis||2!==this.parent.version)m.moveTo(h(this.w/2+this.Ox)+0.5,0),m.lineTo(h(this.w/2+this.Ox)+0.5,this.h);m.stroke();this.drawMarks(m,g,4);this.drawMarks(m,g/2,2);this.drawMarks(m,g/10,1)}if(""!==this.x_axis||""!==this.y_axis)m.fillStyle=this.axes.getColor(),
m.font=c,m.textAlign="right",m.textBaseline="alphabetic",m.fillText(this.x_axis,h(this.w)-2,h(this.h/2+this.Oy)+12),m.fillText(this.y_axis,h(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(m.fillStyle=this.axes.getColor(),m.font=c,m.textAlign="start",m.textBaseline="bottom",g>(this.w+this.h)/2?this.drawNumbers(m,g/5,g<=this.scale?v+1:v):g>(this.w+this.h)/4?this.drawNumbers(m,g/2,g<=this.scale?v+1:v):this.drawNumbers(m,g,v));for(var a=0,b=this.backgroundGraphics.length;a<b;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,b=this.graphics.length;a<b;a++)t=this.graphics[a],""!==t.trace&&this.drawTrace&&t.drawTrace(),t.draw();a=0;for(b=this.graphicsCtr.length;a<b;a++)this.graphicsCtr[a].draw();""!=this.text&&(this.click&&"L"===this.whichButton)&&(m.fillStyle=this.text.getColor(),m.strokeStyle=m.fillStyle,m.lineWidth=1,m.font=k,m.textAlign="center",m.textBaseline="alphabetic",G=1>=this.scale?this.mouse_x.toFixed(0):
this.mouse_x.toFixed(this.scale.toString().length),M=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),L="("+G+","+M+")",w=h(m.measureText(L).width/2),N=this.getAbsoluteX(this.mouse_x),F=this.getAbsoluteY(this.mouse_y),J=h(N),K=h(F-10),J+w>this.w?J=this.w-w:0>J-w&&(J=w),K+1>this.h?K=this.h:0>K-14&&(K=15),m.fillText(L,J,K),m.beginPath(),m.arc(N,F,2.5,0,d,!0),m.stroke())};a.Space2D.prototype.drawMarks=function(a,d,c){s=this.w;x=this.h;D=0;B=s;z=0;I=x;y=h(s/2+this.Ox);
E=h(x/2+this.Oy);0<=c&&(D=y-c,B=y+c,z=E-c,I=E+c);a.beginPath();for(c=-b(y/d);(A=y+b(c*d))<s;c++)a.moveTo(A+0.5,z+0.5),a.lineTo(A+0.5,I+0.5);for(c=-b(E/d);(C=E+b(c*d))<x;c++)a.moveTo(D+0.5,C+0.5),a.lineTo(B+0.5,C+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,d,c){s=this.w;x=this.h;y=h(s/2+this.Ox);E=h(x/2+this.Oy);for(c=-b(y/d);(A=y+b(c*d))<s;c++)a.fillText(parseFloat((c*d/this.scale).toFixed(4)),A+1,E-2);for(c=-b(E/d);(C=E+b(c*d))<x;c++)0!==parseFloat(-c*d/this.scale)&&a.fillText(parseFloat((-c*
d/this.scale).toFixed(4)),y+5,C+5)};a.Space2D.prototype.registerMouseAndTouchEvents=function(){function b(a){m.click=1;m.evaluator.setVariable(m.id+".mouse_pressed",1);m.parent.deactivateGraphiControls();g(a);window.addEventListener("touchmove",n);window.addEventListener("touchend",d);a.preventDefault()}function d(a){m.click=0;m.evaluator.setVariable(m.id+".mouse_pressed",0);window.removeEventListener("touchmove",n,!1);window.removeEventListener("touchend",d,!1);a.preventDefault();m.parent.update()}
function c(b){m.click=1;m.evaluator.setVariable(m.id+".mouse_pressed",1);m.parent.deactivateGraphiControls();m.whichButton=a.whichButton(b);"R"===m.whichButton&&(window.addEventListener("mouseup",f),m.fixed||(m.clickPosForZoom=m.getCursorPosition(b).y,m.tempScale=m.scale,window.addEventListener("mousemove",k)));"L"===m.whichButton&&(m.evaluator.setVariable(m.id+".mouse_pressed",1),g(b),window.addEventListener("mousemove",n),window.addEventListener("mouseup",f));b.preventDefault()}function f(a){m.click=
0;m.evaluator.setVariable(m.id+".mouse_pressed",0);a.preventDefault();"R"===m.whichButton&&window.removeEventListener("mousemove",k,!1);m.sensitive_to_mouse_movements||window.removeEventListener("mousemove",n,!1);window.removeEventListener("mouseup",f,!1);m.parent.update()}function g(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 k(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 n(a){m.fixed||(m.posNext=m.getCursorPosition(a),e=h(m.posAnte.x-m.posNext.x),l=h(m.posAnte.y-m.posNext.y),m.evaluator.setVariable(m.OxString,m.Ox-e),m.evaluator.setVariable(m.OyString,m.Oy-l),m.posAnte.x-=e,m.posAnte.y-=l);g(a);a.preventDefault()}var m=this;H=a.hasTouchSupport;m.canvas.oncontextmenu=
function(){return!1};H&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",g),this.canvas.addEventListener("touchstart",b));H||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",g),this.canvas.addEventListener("mousedown",c))};return a}(descartesJS||{}),descartesJS=function(a){var e,l,h;function b(a,b){return b.depth-a.depth}function d(b,d){var c=a.subtract3D(b,a.scalarProduct3D(d,a.dotProduct3D(b,d))),c=a.add3D(b,a.scalarProduct3D(c,-2)),f=a.norm3D(c);
return 0!==f?a.scalarProduct3D(c,1/f):a.scalarProduct3D(b,-1)}if(a.loadLib)return a;var c=Math.floor,k=Math.round,f=Math.max,r=Math.cos,n=Math.sin,m=Math.sqrt,q=15*Math.PI/180,p,t,g,v,u,s,x,A,C,y,E,D,B,z,I,G,M,L;a.Space3D=function(b,d){a.Space.call(this,b,d);g=this;g.backgroundCanvas=document.createElement("canvas");g.backgroundCanvas.setAttribute("id",g.id+"_background");g.backgroundCanvas.setAttribute("width",g.w+"px");g.backgroundCanvas.setAttribute("height",g.h+"px");g.canvas=document.createElement("canvas");
g.canvas.setAttribute("id",g.id+"_canvas");g.canvas.setAttribute("width",g.w+"px");g.canvas.setAttribute("height",g.h+"px");g.canvas.setAttribute("class","DescartesSpace3DCanvas");g.canvas.setAttribute("style","z-index: "+g.zIndex+";");g.ctx=g.canvas.getContext("2d");g.ctx.imageSmoothingEnabled=!1;g.ctx.mozImageSmoothingEnabled=!1;g.ctx.webkitImageSmoothingEnabled=!1;g.graphicControlContainer=document.createElement("div");g.graphicControlContainer.setAttribute("id",g.id+"_graphicControls");g.graphicControlContainer.setAttribute("style",
"position: absolute; left: 0px; top: 0px; z-index: "+g.zIndex+";");g.numericalControlContainer=document.createElement("div");g.numericalControlContainer.setAttribute("id",g.id+"_numericalControls");g.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+g.zIndex+";");g.container=document.createElement("div");g.container.setAttribute("id",g.id);g.container.setAttribute("class","DescartesSpace3DContainer");g.container.setAttribute("style","left: "+g.x+"px; top: "+
g.y+"px; z-index: "+g.zIndex+";");g.container.appendChild(g.backgroundCanvas);g.container.appendChild(g.canvas);g.container.appendChild(g.graphicControlContainer);g.container.appendChild(g.numericalControlContainer);b.container.insertBefore(g.container,b.loader);g.eye={x:0,y:0,z:0};g.lights=[{x:50,y:50,z:70},{x:50,y:-50,z:30},{x:20,y:0,z:-80},{x:0,y:0,z:0}];for(var c=0,f=g.lights.length;c<f;c++)g.lights[c]=a.normalize3D(g.lights[c]);g.light3={x:0,y:0,z:0};g.intensity=[0.4,0.5,0.3,0];g.userIntensity=
0;g.dim=1;g.tmpIntensity=[];g.OxStr=g.id+".Ox";g.OyStr=g.id+".Oy";g.scaleStr=g.id+".escala";g.wStr=g.id+"._w";g.hStr=g.id+"._h";g.obsStr=g.id+".observador";g.rotZStr=g.id+".rot.z";g.rotYStr=g.id+".rot.y";g.userI_Dim_Str=g.id+".userIlum.dim";g.userI_I_Str=g.id+".userIlum.I";g.userI_x_Str=g.id+".userIlum.x";g.userI_y_Str=g.id+".userIlum.y";g.userI_z_Str=g.id+".userIlum.z";g.evaluator.setVariable(g.rotZStr,0);g.evaluator.setVariable(g.rotYStr,0);g.evaluator.setVariable(g.userI_Dim_Str,g.dim);g.evaluator.setVariable(g.userI_I_Str,
g.userIntensity);g.evaluator.setVariable(g.userI_x_Str,0);g.evaluator.setVariable(g.userI_y_Str,0);g.evaluator.setVariable(g.userI_z_Str,0);g.registerMouseAndTouchEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(a){g=this;g.uber.init.call(g);g.canvas&&(g.canvas.setAttribute("width",g.w+"px"),g.canvas.setAttribute("height",g.h+"px"));g.container&&g.findOffset();g.w_2=g.w/2;g.h_2=g.h/2;g.oldMouse={x:0,y:0}};a.Space3D.prototype.update=function(a){g=this;p=g.evaluator;t=g.parent;
p.setVariable(g.wStr,g.w);p.setVariable(g.hStr,g.h);g.drawIfValue=0<p.evalExpression(g.drawif);if(g.drawIfValue){A=g.x!==p.evalExpression(g.xExpr)+g.displaceRegionWest;C=g.y!==p.evalExpression(g.yExpr)+t.plecaHeight+g.displaceRegionNorth;g.spaceChange=a||A||C||g.drawBefore!==g.drawIfValue||g.Ox!==p.getVariable(g.OxStr)||g.Oy!==p.getVariable(g.OyStr)||g.scale!==p.getVariable(g.scaleStr);g.x=A?p.evalExpression(g.xExpr)+g.displaceRegionWest:g.x;g.y=C?p.evalExpression(g.yExpr)+t.plecaHeight+g.displaceRegionNorth:
g.y;g.Ox=p.getVariable(g.OxStr);g.Oy=p.getVariable(g.OyStr);g.scale=p.getVariable(g.scaleStr);g.drawBefore=g.drawIfValue;if(a){var b;a=0;for(var d=g.parent.controls.length;a<d;a++)g.parent.controls[a].id===g.obsStr&&(b=!0);g.observer=b?p.getVariable(g.obsStr)||0.5*(g.w+g.h):2.5*(g.w+g.h);g.observer=f(g.observer,0.1*(g.w+g.h));p.setVariable(g.obsStr,g.observer);g.eye={x:g.observer/g.scale*r(q),y:0,z:g.observer/g.scale*n(q)};g.D=g.scale*g.eye.x/r(q);g.XE=k(g.scale*g.eye.y+0.5);g.YE=k(g.scale*g.eye.z+
0.5)}g.observer=f(p.getVariable(g.obsStr),0.1*(g.w+g.h));p.setVariable(g.obsStr,g.observer);1E-6>g.scale?(g.scale=1E-6,p.setVariable(g.scaleStr,1E-6)):1E6<g.scale&&(g.scale=1E6,p.setVariable(g.scaleStr,1E6));if(A||C)g.container.style.left=g.x+"px",g.container.style.top=g.y+"px",g.findOffset();g.container.style.display="block";g.dim=p.getVariable(g.userI_Dim_Str);g.userIntensity=p.getVariable(g.userI_I_Str);g.light3={x:parseInt(p.getVariable(g.userI_x_Str)),y:parseInt(p.getVariable(g.userI_y_Str)),
z:parseInt(p.getVariable(g.userI_z_Str))};g.updateCamera();g.draw()}else g.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));this.primitives=[];for(var a=0,d=this.graphics.length;a<d;a++)v=this.graphics[a],v.update(),this.primitives=this.primitives.concat(v.primitives||[]);u=this.primitives;s=u.length;for(a=0;a<s;a++)u[a].computeDepth(this);u=
u.sort(b);for(a=0;a<s;a++)u[a].draw(this.ctx,this);a=0;for(d=this.graphicsCtr.length;a<d;a++)this.graphicsCtr[a].draw()};a.Space3D.prototype.updateCamera=function(){g=this;g.D=g.observer;g.eye.x=g.D/g.scale;g.eye.y=g.XE/g.scale;g.eye.z=g.YE/g.scale};a.Space3D.prototype.rotateVertex=function(b){G=a.degToRad(g.evaluator.getVariable(g.rotZStr));M=r(G);L=n(G);e=b.x*M-b.y*L;l=b.x*L+b.y*M;h=b.z;G=a.degToRad(g.evaluator.getVariable(g.rotYStr));M=r(G);L=n(G);return{x:h*L+e*M,y:l,z:h*M-e*L}};a.Space3D.prototype.project=
function(a){g=this;D=g.eye.x-a.x;B=g.eye.y-a.y;z=g.eye.z-a.z;I=-a.x/m(D*D+B*B+z*z)||0;D=g.scale*(a.y+I*(g.eye.y-a.y));B=-g.scale*(a.z+I*(g.eye.z-a.z));return{x:parseInt(D+this.w_2+this.Ox),y:parseInt(B+this.h_2+this.Oy),z:I}};var w,N,F,J,K=[],H,O,S;a.Space3D.prototype.computeColor=function(b,f,e){b.getColor();var g=a.subtract3D(this.eye,f.average),h=a.norm3D(g),g=a.scalarProduct3D(g,1/h);this.lights[3]=a.subtract3D(this.light3,f.average);J=a.norm3D(this.lights[3]);for(var h=0,k=this.intensity.length-
1;h<k;h++)K[h]=this.intensity[h]*this.dim;K[3]=this.userIntensity*this.userIntensity/J;H=e?this.dim/2:this.dim/4;O=0;S=0<=f.direction?f.normal:a.scalarProduct3D(f.normal,-1);h=0;for(k=this.lights.length;h<k;h++)e?(O=Math.max(0,a.dotProduct3D(d(this.lights[h],S),g)),O*=O*O):O=Math.max(0,a.dotProduct3D(this.lights[h],S)),H+=K[h]*O;H=Math.min(H,1);w=c(b.r*H);N=c(b.g*H);F=c(b.b*H);return"rgba("+w+","+N+","+F+","+b.a+")"};a.Space3D.prototype.registerMouseAndTouchEvents=function(){function b(a){g.click=
1;g.evaluator.setVariable(g.id+".mouse_pressed",1);g.parent.deactivateGraphiControls();g.posAnte=g.getCursorPosition(a);g.oldMouse.x=g.getRelativeX(g.posAnte.x);g.oldMouse.y=g.getRelativeY(g.posAnte.y);e(a);window.addEventListener("touchmove",l);window.addEventListener("touchend",d);a.preventDefault()}function d(a){g.click=0;g.evaluator.setVariable(g.id+".mouse_pressed",0);window.removeEventListener("touchmove",l,!1);window.removeEventListener("touchend",d,!1);a.preventDefault()}function c(b){g.click=
1;g.parent.deactivateGraphiControls();g.whichButton=a.whichButton(b);"R"===g.whichButton?(window.addEventListener("mouseup",f),g.fixed||(g.clickPosForZoom=g.getCursorPosition(b).y,g.tempScale=g.scale,window.addEventListener("mousemove",h))):"L"==g.whichButton&&(g.evaluator.setVariable(g.id+".mouse_pressed",1),g.posAnte=g.getCursorPosition(b),g.oldMouse.x=g.getRelativeX(g.posAnte.x),g.oldMouse.y=g.getRelativeY(g.posAnte.y),e(b),window.addEventListener("mousemove",l),window.addEventListener("mouseup",
f));b.preventDefault()}function f(a){g.click=0;g.evaluator.setVariable(g.id+".mouse_pressed",0);a.preventDefault();"R"===g.whichButton&&window.removeEventListener("mousemove",h,!1);window.removeEventListener("mousemove",l,!1);window.removeEventListener("mouseup",f,!1)}function e(a){g.posAnte=g.getCursorPosition(a);g.mouse_x=g.getRelativeX(g.posAnte.x);g.mouse_y=g.getRelativeY(g.posAnte.y);g.evaluator.setVariable(g.id+".mouse_x",g.mouse_x);g.evaluator.setVariable(g.id+".mouse_y",g.mouse_y);g.parent.update()}
function h(a){a.preventDefault();g.clickPosForZoomNew=g.getCursorPosition(a).y;g.evaluator.setVariable(g.scaleStr,g.tempScale+g.tempScale/45*((g.clickPosForZoom-g.clickPosForZoomNew)/10));g.parent.update()}function l(b){if(!g.fixed&&g.click){y=parseInt(50*(g.oldMouse.x-g.mouse_x));E=parseInt(50*(g.oldMouse.y-g.mouse_y));if(y!==g.disp.x||E!==g.disp.y)g.alpha=a.degToRad(g.evaluator.getVariable(g.rotZStr)),g.beta=a.degToRad(-g.evaluator.getVariable(g.rotYStr)),g.alpha=k(a.radToDeg(g.alpha)-y),g.beta=
k(a.radToDeg(g.beta)-E),g.evaluator.setVariable(g.rotZStr,g.alpha),g.evaluator.setVariable(g.rotYStr,-g.beta),g.disp.x=y,g.disp.y=E,g.oldMouse.x=g.getRelativeX(g.posAnte.x),g.oldMouse.y=g.getRelativeY(g.posAnte.y);e(b);b.preventDefault()}}g=this;x=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};x&&this.canvas.addEventListener("touchstart",b);x||this.canvas.addEventListener("mousedown",c);this.disp={x:0,y:0}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e;a.SpaceAP=function(l,h){a.Space.call(this,l,h);this.exportarVars=this.importarVars=null;e=l.evaluator;this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=e.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=e.parser.parse(this.file):this.file=e.parser.parse("'"+this.file+"'");this.oldFile=e.evalExpression(this.file);this.initFile()};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var e;
if(this.oldFile){var h=document.getElementById(this.oldFile);e=h&&"descartes/spaceApFile"==h.type?h.text:a.openExternalFile(this.oldFile);null!=e&&(e=e.split("\n"))}if(e&&e.toString().match(/<applet/gi)){for(var h="",b=!1,d=0,c=e.length;d<c&&!(e[d].match("<applet")&&(b=!0),b&&(h+=e[d]),e[d].match("</applet"));d++);d=document.createElement("div");d.innerHTML=h;d.firstChild.setAttribute("width",this.w);d.firstChild.setAttribute("height",this.h);h=this.descApp?this.descApp.container:null;this.descApp=
new a.DescartesApp(d.firstChild);this.descApp.container.setAttribute("class","DescartesAppContainer");this.descApp.container.setAttribute("style","position: absolute; overflow: hidden; background-color: "+this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");h?this.parent.container.replaceChild(this.descApp.container,h):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);h=this.descApp.spaces;d=0;
for(c=h.length;d<c;d++)h[d].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var k=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();k.exportar()}}else h=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),d="position: absolute; overflow: hidden; background-color: "+
this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";",this.image&&("topleft"==this.bg_display?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?d+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(d+="background-image: url("+
this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",d),h?this.parent.container.replaceChild(this.descApp.container,h):this.parent.container.insertBefore(this.descApp.container,this.parent.loader),this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none"};a.SpaceAP.prototype.update=function(){var a=this.evaluator.evalExpression(this.file);if(this.oldFile!=a)this.oldFile=a,this.initFile();
else{var a=this.x!=this.evaluator.evalExpression(this.xExpr),e=this.y!=this.evaluator.evalExpression(this.yExpr)+this.plecaHeight;this.x=a?this.evaluator.evalExpression(this.xExpr):this.x;this.y=e?this.evaluator.evalExpression(this.yExpr)+this.plecaHeight:this.y;a&&(this.descApp.container.style.left=this.x+"px");e&&(this.descApp.container.style.top=this.y+"px");if(a||e)for(var a=this.descApp.spaces,e=0,b=a.length;e<b;e++)a[e].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?
"block":"none";if(this.firstUpdate&&(this.firstUpdate=!1,null==this.importarVars)){this.importarVars=[];for(var d in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(d)&&d.match(/^public./)&&this.importarVars.push({varName:d,value:this.evaluator.getVariable(d)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,e=!1,b=0,d=this.importarVars.length;b<d;b++)a=this.evaluator.getVariable(this.importarVars[b].varName),a!=this.importarVars[b].value&&(this.importarVars[b].value=
a,this.descApp.evaluator.setVariable(this.importarVars[b].varName,this.importarVars[b].value),e=!0);e&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,h,b;a.SpaceHTML_IFrame=function(b,c){a.Space.call(this,b,c);var e=this.parent.evaluator;window.navigator.userAgent.toLowerCase().match(/firefox/);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=e.parser.parse(this.file.substring(1,
this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=e.parser.parse(this.file):this.file=e.parser.parse("'"+this.file+"'");this.oldFile=e.evalExpression(this.file);this.MyIFrame=document.createElement("iframe");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 f=this;this.MyIFrame.onload=function(a){var b=this;f.evaluator.setFunction(f.id+".set",function(a,d){b.contentWindow.postMessage({type:"set",name:a,value:d},"*")});f.evaluator.setFunction(f.id+".update",function(){b.contentWindow.postMessage({type:"update"},"*")});f.evaluator.setFunction(f.id+
".exec",function(a,d){b.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){e=
this.evaluator;this.drawIfValue=0<e.evalExpression(this.drawif);if(this.drawif){this.MyIFrame.style.display=this.drawIfValue?"block":"none";a&&(this.y=this.x=Math.Infinity);l=this.x!==e.evalExpression(this.xExpr)+this.displaceRegionWest;h=this.y!==e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=l?e.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=h?e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(l||h)this.MyIFrame.style.left=
this.x+"px",this.MyIFrame.style.top=this.y+"px";b=e.evalExpression(this.file);b!==this.oldFile&&(this.oldFile=b,this.MyIFrame.setAttribute("src",b));this.scrollVar=e.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 e;a.DescartesLoader=function(a){this.children=a.children;this.lessonParser=a.lessonParser;this.images=a.images;this.images.length=a.images.length;this.audios=a.audios;this.audios.length=a.audios.length;this.arquimedes=a.arquimedes;this.descartesApp=a;var b=a.image_loader?a.image_loader:c(a.loader.width,a.loader.height);this.imageLoader=document.createElement("div");this.imageLoader.width=a.width;this.imageLoader.height=a.height;this.imageLoader.setAttribute("class",
"DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image: url("+b+"); width: "+a.width+"px; height: "+a.height+"px;");a.loader.appendChild(this.imageLoader);this.loaderBar=document.createElement("canvas");this.loaderBar.width=a.width;this.loaderBar.height=a.height;this.loaderBar.setAttribute("class","DescartesLoaderBar");this.loaderBar.setAttribute("style","width: "+a.width+"px; height:"+a.height+"px;");this.loaderBar.ctx=this.loaderBar.getContext("2d");a.loader.appendChild(this.loaderBar);
this.barWidth=Math.floor(80);this.barHeight=Math.floor(a.loader.height/70);var d=this;this.timer=setInterval(function(){d.drawLoaderBar(d.loaderBar.ctx,a.width,a.height)},10);a.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var b=this.children,d=this.images,c=this.audios,e=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,h=/[\w-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g,l=/vector|array|bektore|vecteur|matriz/g,p=/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 t,g,v,u,s,x;u=0;for(s=b.length;u<s;u++){if(t=b[u].value.match(e)){v=0;for(x=t.length;v<x;v++)g=t[v],!g.toLowerCase().match(/vacio.gif$/)&&""!=g.substring(0,g.length-4)&&(d[g]=new Image,d[g].addEventListener("load",function(){this.ready=1}),d[g].addEventListener("error",
function(){this.errorload=1}),d[g].src=g)}if(t=b[u].value.match(h)){v=0;for(g=t.length;v<g;v++)this.initAudio(t[v])}(v=b[u].value.match(l)&&b[u].value.match(p))&&this.lessonParser.parseAuxiliar(b[u].value)}for(var A in d)d.hasOwnProperty(A)&&this.images.length++;for(A in c)c.hasOwnProperty(A)&&this.audios.length++;var C=this,y=this.images.length+this.audios.length,E=function(){C.readys=0;for(var a in d)d.hasOwnProperty(a)&&(d[a].ready||d[a].errorload)&&C.readys++;for(a in C.audios)c.hasOwnProperty(a)&&
(c[a].ready||c[a].errorload)&&C.readys++;C.readys!=y?setTimeout(E,30):(clearTimeout(C.timer),C.descartesApp.initBuildApp())};E()};a.DescartesLoader.prototype.initAudio=function(b){var d=this.audios;d[b]=new Audio(b);d[b].filename=b;var c=function(){this.ready=1},e=function(){!this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))&&"mp3"==this.filename.substring(this.filename.length-3)?(d[b]=new Audio(this.filename.replace("mp3","ogg")),d[b].filename=this.filename.replace("mp3",
"ogg"),d[b].addEventListener("canplaythrough",c),d[b].addEventListener("load",c),d[b].addEventListener("error",e),d[b].load()):(console.log("El archivo '"+b+"' no puede ser reproducido"),this.errorload=1)};d[b].addEventListener("canplaythrough",c);d[b].addEventListener("load",c);d[b].addEventListener("error",e);a.hasTouchSupport?(d[b].load(),d[b].play(),d[b].ready=1):d[b].load()};var l,h,b,d;a.DescartesLoader.prototype.drawLoaderBar=function(a,c,r){l=this.barWidth;h=this.barHeight;b=this.images.length+
this.audios.length;d=2*(l-2)/b;a.translate(c/2,(r-65*e)/2+90*e);a.scale(e,e);a.strokeRect(-l,-h,2*l,h);a.fillStyle="gray";a.fillRect(-l+2,-h+2,2*(l-2),h-4);a.fillStyle="#1f375d";a.fillRect(-l+2,-h+2,this.readys*d,h-4);a.setTransform(1,0,0,1,0,0)};var c=function(a,b){var d=document.createElement("canvas");d.width=a;d.height=b;var c=d.getContext("2d");c.save();c.strokeStyle="#1f375d";c.fillStyle="#1f375d";c.lineCap="round";c.lineWidth=2;c.beginPath();e=a<b?a/360:b/195;e=2.5<e?2.5:e;c.translate((a-120*
e)/2,(b-65*e)/2);c.scale(e,e);c.moveTo(3,25);c.lineTo(3,1);c.lineTo(21,1);c.bezierCurveTo(33,1,41,15,41,25);c.stroke();c.beginPath();c.moveTo(1,63);c.lineTo(1,64);c.moveTo(5,62);c.lineTo(5,64);c.moveTo(9,61);c.lineTo(9,64);c.moveTo(13,60);c.lineTo(13,64);c.moveTo(17,58);c.lineTo(17,64);c.moveTo(21,56);c.lineTo(21,64);c.moveTo(25,53);c.lineTo(25,64);c.moveTo(29,50);c.lineTo(29,64);c.moveTo(33,46);c.lineTo(33,64);c.moveTo(37,41);c.lineTo(37,64);c.moveTo(41,32);c.lineTo(41,64);c.stroke();c.font="20px Arial, Helvetica, 'Droid Sans', Sans-serif";
c.fillText("escartes",45,33);c.fillText("JS",98,64);c.restore();return d.toDataURL()};return a}(descartesJS||{}),descartesJS=function(a){function e(a){for(var b="[",d=0,c=a.length;d<c;d++){if(a[d]instanceof Array)b+=e(a[d]);else{l=a[d];if("undefined"==typeof l||!l)l=0;"string"==typeof l&&(l="'"+l+"'");b+=l}d<c-1&&(b+=",")}return b+"]"}if(a.loadLib)return a;a.DescartesApp=function(e){this.applet=e;this.parentContainer=e.parentNode;this.width=parseFloat(e.getAttribute("width"));this.height=parseFloat(e.getAttribute("height"));
this.decimal_symbol=".";this.children=e.getElementsByTagName("param");this.code=e.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/}.}";
e=this.children;for(var b,d=0,c=0,k=0,f=e.length;k<f;k++)b=e[k],"rtf_height"==b.name&&(d=parseInt(b.value)),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),c=this.buttonsConfig.height),"image_loader"==b.name&&(this.image_loader=b.value);this.arquimedes&&d&&(this.height=d+c+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,b=this.lessonParser,d=[],c=[],e=[],f=[],l=[],n=[],m,q=0,p=a.length;q<p;q++)if(m=a[q],"pleca"==m.name)m=b.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=b.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 t=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;f.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+
m.value.replace(/'/g,"&squot;")+"'");f.push("space='descartesJS_scenario' type='text' expresion='[10,"+(t-25)+"]' background='yes' text='"+this.licenseA+"'");f.push("space='descartesJS_scenario' type='image' expresion='[15,"+t+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==m.name.charAt(0)?(m.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,d.push(m.value)):"C"==m.name.charAt(0)&&"_"==m.name.charAt(1)?c.push(m.value):"A"==m.name.charAt(0)&&"_"==m.name.charAt(1)?
e.push(m.value):"G"==m.name.charAt(0)?f.push(m.value):"S"==m.name.charAt(0)?l.push(m.value):"Animation"==babel[m.name]&&n.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));q=0;for(p=d.length;q<p;q++)a=b.parseSpace(d[q]),this.arquimedes&&this.scenarioRegion.container.appendChild(a.container),this.spaces.push(a),this.zIndex++;q=0;for(p=c.length;q<p;q++)this.controls.push(b.parseControl(c[q]));q=0;for(p=e.length;q<p;q++)b.parseAuxiliar(e[q]);q=0;for(p=
n.length;q<p;q++)this.animation=b.parseAnimation(n[q]);q=0;for(p=f.length;q<p;q++)if(d=b.parseGraphic(f[q]))d.visible&&(this.editableRegionVisible=!0),d.space.addGraph(d);q=0;for(p=l.length;q<p;q++)(d=b.parse3DGraphic(l[q]))&&d.space.addGraph(d);this.configRegions();this.updateAuxiliaries();q=0;for(p=this.controls.length;q<p;q++)this.controls[q].init();this.updateControls();this.updateSpaces(!0);var g=this;this.numberOfIframes?setTimeout(function(){g.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 e=this.evaluator.parser,b=this.buttonsConfig,
d=this.container;if(2!=this.version)var c="15",k=100,f=100,l=100,n=100;else c="14",k=63,f=50,l=44,n=53;var m=0,q=0,p=0,t=p=0,g=0,v=0,u=0,s=0,v=this.northSpace.controls,x=this.southSpace.controls,A=this.eastSpace.controls,C=this.westSpace.controls;if(0<b.rowsNorth||0<v.length||b.about||b.config){0>=b.rowsNorth?(m=b.height,b.rowsNorth=1):m=b.height*b.rowsNorth;var y=this.northSpace.container;y.setAttribute("id","descartesJS_northRegion");y.setAttribute("style","width:"+d.width+"px; height:"+m+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");
d.insertBefore(y,this.loader);var g=d.width,E=0;b.about&&(E=k,g-=E);b.config&&(g-=f);for(var y=Math.ceil(v.length/b.rowsNorth),D=g/y,p=0,B=v.length;p<B;p++)v[p].expresion=e.parse("("+(E+D*(p%y))+","+b.height*Math.floor(p/y)+","+D+","+b.height+")"),v[p].drawif=e.parse("1"),v[p].init();if(b.about){var z;"espa\u00f1ol"==this.language?z="cr\u00e9ditos":"english"==this.language&&(z="about");(new a.Button(this,{region:"north",name:z,font_size:e.parse(c),expresion:e.parse("(0, 0, "+k+", "+m+")")})).update()}b.config&&
(z="config",(new a.Button(this,{region:"north",name:z,font_size:e.parse(c),action:"config",expresion:e.parse("("+(g+k)+", 0, "+f+", "+m+")")})).update())}if(0<b.rowsSouth||0<x.length||b.init||b.clear){0>=b.rowsSouth?(q=b.height,b.rowsSouth=1):q=b.height*b.rowsSouth;v=d.width;E=0;b.init&&(E=l,v-=E);b.clear&&(v-=n);y=this.southSpace.container;y.setAttribute("id","descartesJS_southRegion");y.setAttribute("style","width:"+d.width+"px; height:"+q+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+
(d.height-q)+"px; z-index:100;");d.insertBefore(y,this.loader);y=Math.ceil(x.length/b.rowsSouth);D=v/y;p=0;for(B=x.length;p<B;p++)x[p].expresion=e.parse("("+(E+D*(p%y))+","+b.height*Math.floor(p/y)+","+D+","+b.height+")"),x[p].drawif=e.parse("1"),x[p].init();b.init&&("espa\u00f1ol"==this.language?z="inicio":"english"==this.language&&(z="init"),(new a.Button(this,{region:"south",name:z,font_size:e.parse(c),action:"init",expresion:e.parse("(0, 0, "+l+", "+q+")")})).update());b.clear&&("espa\u00f1ol"==
this.language?z="limpiar":"english"==this.language&&(z="clear"),(new a.Button(this,{region:"south",name:z,font_size:e.parse(c),action:"clear",expresion:e.parse("("+(v+l)+", 0, "+n+", "+q+")")})).update())}if(0<A.length){p=d.height-m-q;u=b.widthEast;y=this.eastSpace.container;y.setAttribute("id","descartesJS_eastRegion");y.setAttribute("style","width:"+u+"px; height:"+p+"px; background:#c0c0c0; position:absolute; left:"+(d.width-u)+"px; top:"+m+"px; z-index:100;");d.insertBefore(y,this.loader);p=0;
for(B=A.length;p<B;p++)A[p].expresion=e.parse("(0,"+b.height*p+","+u+","+b.height+")"),A[p].drawif=e.parse("1"),A[p].init()}if(0<C.length){p=d.height-m-q;s=b.widthWest;y=this.westSpace.container;y.setAttribute("id","descartesJS_westRegion");y.setAttribute("style","width: "+s+"px; height: "+p+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+m+"px; z-index: 100;");d.insertBefore(y,this.loader);p=0;for(B=C.length;p<B;p++)C[p].expresion=e.parse("(0,"+b.height*p+","+s+","+b.height+")"),
C[p].drawif=e.parse("1"),C[p].init()}if(this.editableRegionVisible){t=b.height;y=this.editableRegion.container;y.setAttribute("id","descartesJS_editableRegion");y.setAttribute("style","width:"+d.width+"px; height:"+t+"px; position:absolute; left:0px; top:"+(d.height-q-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;");d.insertBefore(y,this.loader);e=this.editableRegion.textFields;b=d.width/e.length;c=a.getFieldFontSize(t);p=0;for(B=e.length;p<B;p++)"div"==e[p].type?(y.appendChild(e[p].container),
e[p].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(b-4)+"px; height: "+t+"px; position: absolute; left: "+p*b+"px; top: 0px;"),k=e[p].container.firstChild,k.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+c+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+t+"px; text-align: center; line-height: "+t+"px;"),f=k.offsetWidth,k.style.width=f+"px",k.firstChild.textContent=
k.firstChild.textContent.substring(3,k.firstChild.textContent.length-3),e[p].container.lastChild.setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+c+"px; width:"+(b-f)+"px; height:"+t+"px; position:absolute; left:"+f+"px; top:0px; border:2px groove white;")):(y.appendChild(e[p]),e[p].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+c+"px; width:"+b+"px; height:"+t+"px; position:absolute; left:"+
p*b+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=m;this.displaceRegionWest=s;d.width-=u;d.height=d.height-q-t;p=0;for(B=this.spaces.length;p<B;p++)this.spaces[p].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,b=0,d=this.controls.length;b<d;b++)a=this.controls[b],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=
function(){for(var a=0,b=this.auxiliaries.length;a<b;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=function(){for(var a=0,b=this.events.length;a<b;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,b=this.controls.length;a<b;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var b=0,d=this.spaces.length;b<d;b++)this.spaces[b].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,b=this.spaces.length;a<
b;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stopAudios=function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),this.audios[a].currentTime=
0)};a.DescartesApp.prototype.getImage=function(a){var b=this.images;if(a)return b[a]||(b[a]=new Image,b[a].addEventListener("load",function(){this.ready=1}),b[a].addEventListener("error",function(){this.errorload=1}),b[a].src=a),b[a]};a.DescartesApp.prototype.getAudio=function(a){var b=this.audios;if(a){if(!b[a]){var d=file.lastIndexOf("."),d=-1===d?file.lenght:d;file.substring(0,d);b[a]=new Audio(a);var c=function(a){this.ready=1};b[a].addEventListener("canplaythrough",c);var e=function(d){!this.canPlayType("audio/"+
a.substring(a.length-3))&&"mp3"==a.substring(a.length-3)?(b[a]=new Audio(a.replace("mp3","ogg")),b[a].addEventListener("canplaythrough",c),b[a].addEventListener("load",c),b[a].addEventListener("error",e),b[a].load()):(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1)};b[a].addEventListener("error",e);b[a].play();setTimeout(function(){b[a].pause()},15)}return b[a]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var b,d=0,c=this.controls.length;d<
c;d++)if(b=this.controls[d],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var b,d=0,c=this.controls.length;d<c;d++)if(b=this.controls[d],b.id==a)return b;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var b,d=0,c=this.spaces.length;d<c;d++)if(b=this.spaces[d],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var b,d=0,c=this.spaces.length;d<c;d++)if(b=
this.spaces[d],b.id==a)return b;return{update:function(){},w:0}};var l;a.DescartesApp.prototype.getState=function(){var a,b="",d=this.evaluator.variables,c;for(c in d)d.hasOwnProperty(c)&&(a=d[c],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=c&&"pi"!=c&&"e"!=c&&"Infinity"!=c&&"-Infinity"!=c&&"object"!=typeof a)&&(b=""!=b?b+"\n"+c+"="+a:c+"="+a));var d=this.evaluator.vectors,k;for(k in d)d.hasOwnProperty(k)&&(a=d[k],b=b+"\n"+k+"="+e(a));k=this.evaluator.matrices;for(var f in k)k.hasOwnProperty(f)&&
(a=k[f],b=b+"\n"+f+"="+e(a));return b};a.DescartesApp.prototype.setState=function(a){a=a.split("\n");for(var b,d,c=0,e=a.length;c<e;c++)b=a[c].split("="),2<=b.length&&(d=eval(b[1]),-1!=b[1].indexOf("[[")?(this.evaluator.matrices[b[0]]=d,this.evaluator.matrices[b[0]].rows=d.length,this.evaluator.matrices[b[0]].cols=d[0].length):-1!=b[1].indexOf("[")?(this.evaluator.vectors[b[0]]=d,this.evaluator.variables[b[0]+".long"]=d.length):this.evaluator.variables[b[0]]=d),this.update()};a.DescartesApp.prototype.getEvaluation=
function(){for(var a=0,b=0,d="",c=0,e=this.controls.length;c<e;c++)"textfield"==this.controls[c].gui&&this.controls[c].evaluate&&(a++,b+=this.controls[c].ok,this.controls[c].value=""==this.controls[c].value?"''":this.controls[c].value,d+=" \\n "+this.controls[c].id+"="+this.controls[c].value+"|"+this.controls[c].ok);return"questions="+a+" \\n correct="+b+" \\n wrong="+(a-b)+d};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,b=0,d=a.length;b<d;b++)"textfield"==a[b].gui&&a[b].evaluate&&
a[b].changeValue(a[b].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,b=this.saveState.length;a<b;a++)this.evaluator.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||{}),descartesJS=function(a){function e(){for(var b=document.getElementsByTagName("applet"),c=document.getElementsByTagName("ajs"),e,f=[],h=0,l=b.length;h<l;h++)e=b[h],(e.getAttribute("code").match("DescartesJS")||e.getAttribute("code").match("descinst.DescartesWeb2_0.class")||
e.getAttribute("code").match("Descartes")||e.getAttribute("code").match("Arquimedes")||e.getAttribute("code").match("Discurso"))&&f.push(e);h=0;for(l=c.length;h<l;h++)e=c[h],(e.getAttribute("code").match("DescartesJS")||e.getAttribute("code").match("descinst.DescartesWeb2_0.class")||e.getAttribute("code").match("Descartes")||e.getAttribute("code").match("Arquimedes")||e.getAttribute("code").match("Discurso"))&&f.push(e);b=0;for(c=f.length;b<c;b++)a.apps.push(new a.DescartesApp(f[b])),f[b].className=
"DescartesJS"}function l(){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 h(){for(var a=document.getElementsByTagName("*"),b=[],e=0,f=a.length;e<f;e++)"DescartesAppContainer"==a[e].className&&b.push(a[e]);e=0;for(f=b.length;e<f;e++)b[e].parentNode.removeChild(b[e])}
function b(b){a.getFeatures();a.hasCanvasSupport?(h(),e(),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)&&l();a.onResize=function(b){for(var c=
0,e=a.apps.length;c<e;c++){b=a.apps[c].spaces;for(var f=0,h=b.length;f<h;f++)b[f].findOffset()}};a.receiveMessage=function(b){if(0<a.apps.length&&(b=b.data))if("set"===b.type)a.apps[0].evaluator.setVariable(b.name,b.value);else if("update"===b.type)a.apps[0].update();else if("exec"===b.type){var c=a.apps[0].evaluator.getFunction(b.name),e=[];""!==b.value&&(e=b.value.toString().split(","));c&&c.apply(a.apps[0].evaluator,e)}};void 0==a.loadLib&&(a.loadLib=!0,window.addEventListener("load",b),window.addEventListener("message",
a.receiveMessage));return a}(descartesJS||{});
