/*
 Joel Espinosa Longi
 joel.espinosa@amite.mx
 j.longi@gmail.com
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-08-19
*/
var babel=function(a){if(a.loadLib)return a;a.falso=a["false"]=a.fals=a.gezurra=a.faux=a.fals="false";a.verdadero=a["true"]=a.veritable=a.egia=a.vrai=a.verdadeiro=a.veritable="true";a.no=a.ez=a.non=a["n\u00e3o"]="false";a["s\u00ed"]=a.yes=a.bai=a.oui=a.si=a["sim "]="true";a.negro=a.black=a.negre=a.beltza=a.noir=a.preto="#000000";a.maxenta=a.magenta="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise="#00ffff";a.verde=a.green=a.verd=a.berdea=a.vert="#00ff00";
a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho="#ff0000";a.pink=a.rosa=a.arrosa=a.rose="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro="#404040";a.gris=a.gray=a.grisa=a.cinza="#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=
"#ffffff";a.escala=a.scale=a.eskala=a["\u00e9chelle"]="scale";a.nombre=a.name=a.nom=a.izena=a.nome="name";a.ikusgai=a["vis\u00edvel"]=a.visible="visible";a.rastro=a.trace=a.rastre=a.arrastoa="trace";a.fondo=a.background=a.fons=a.hondoa=a.fond=a.fundo="background";a.colour=a.color=a.kolorea=a.couleur=a.cor="color";a["par\u00e1metro"]=a.parameter=a.parametroa=a["par\u00e2metro"]=a["par\u00e0metre"]="parameter";a["sucesi\u00f3n"]=a.sequence=a["successi\u00f3"]=a.segida=a.succession=a["seq\u00fc\u00eancia"]=
"sequence";a["tama\u00f1o"]=a.size=a.neurria=a.taille=a.tamanho=a["grand\u00e0ria"]="size";a.decimales=a.decimals=a.hamartarra=a["d\u00e9cimales"]=a.decimais="decimals";a.red=a.net=a.xarxa=a.sarea=a["r\u00e9seau"]=a.rede=a.malha="net";a.red10=a.net10=a.xarxa10=a.sarea10=a["r\u00e9seau10"]=a.rede10=a.malha10="net10";a.ejes=a.axes=a.eixos=a.ardatzak=a.eixes="axes";a.texto=a.text=a.testua=a.texte="text";a["cr\u00e9ditos"]=a.about=a["cr\u00e8dits"]=a.kreditoak=a["cr\u00e9dits"]=a.sobre="about";a.config=
a.konfig=a["configura\u00e7\u00e3o"]="config";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.limpiar=a.clear=a.neteja=a.ezabatu=a.nettoye=a.limpar="clear";a.incr=a.gehi=a.incremento="incr";a.min=a.inf="min";a.max=a.sup=a["m\u00e1x"]="max";a.relleno=a.fill=a.ple=a.betea=a.plein=a.recheo=a.preencher="fill";a["relleno+"]=a["fill+"]=a["ple+"]=a["betea+"]=a["plein+"]=a["recheo+"]=a["preencher+"]="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=a["betea-"]=a["plein-"]=a["recheo-"]=
a["preencher-"]="fillM";a.flecha=a.arrow=a.fletxa=a.gezia=a["fl\u00e8che"]=a.frecha=a.seta="arrow";a.ancho=a.width=a.ample=a.zabalera=a.large=a.largura="width";a.punta=a.spear=a.muturra=a.pointe=a.ponta="spear";a["regi\u00f3n"]=a.region=a["regi\u00f3"]=a.eskualde=a["r\u00e9gion"]=a["rexi\u00f3n"]=a["regi\u00e3o"]="region";a.norte=a.north=a.nord=a.ipar="north";a.sur=a.south=a.sud=a.hego=a.sul="south";a.este=a.east=a.est=a.ekialde=a.leste="east";a.oeste=a.west=a.oest=a.hegoalde=a.ouest="west";a.exterior=
a.external=a.kanpoalde=a.externo="external";a["expresi\u00f3n"]=a.expresion=a["expresi\u00f3"]=a.adierazpen=a["express\u00e3o"]="expresion";a.tipo=a.type=a.tipus=a.mota="type";a["posici\u00f3n"]=a.position=a["posici\u00f3"]=a.posizio=a["posi\u00e7\u00e3o"]="position";a["constricci\u00f3n"]=a.constraint=a["constricci\u00f3"]=a.beharte=a.constriction=a["constrici\u00f3n"]=a["restri\u00e7\u00e3o"]="constraint";a.valor=a.value=a.balio=a.valeur="value";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=
a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.curva=a.curve=a.corba=a.kurba=a.courbe="curve";a.texto=a.text=a.testu=a.texte="text";a.punto=a.point=a.punt=a.puntu=a.ponto="point";a.segmento=a.segment=a.zuzenki="segment";a.arco=a.arc=a.arku="arc";a["pol\u00edgono"]=a.polygon=a["pol\u00edgon"]=a.poligono=a.polygone="polygon";a.imagen=a.image=a.imatge=a.irudi=a.imaxe=a.imagem="image";a["Versi\u00f3n"]=a.Version=a["Versi\u00f3"]=a["Vers\u00e3o"]="version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=
"language";a["O.x"]="O.x";a["O.y"]="O.y";a.Botones=a.Buttons=a.Botons=a.Botoiak=a.Boutons=a["Bot\u00f3ns"]=a["Bot\u00f5es"]=a.Botons="Buttons";a["Animaci\u00f3n"]=a.Animation=a["Animaci\u00f3"]=a.Animazio=a["Anima\u00e7\u00e3o"]="Animation";a.constante=a.constant=a.Konstante="constant";a.fuente=a.font=a.iturri=a.source=a.fonte="font";a["num\u00e9rico"]=a.numeric=a["num\u00e8ric"]=a.zenbakizko=a["num\u00e9rique"]="numeric";a["gr\u00e1fico"]=a.graphic=a["gr\u00e0fic"]=a.grafiko=a.graphique="graphic";
a.texto=a.text=a.testu=a.texte="text";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.hacer=a["do"]=a.fer=a.egin=a.faire=a.facer=a.fazer="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto="whileExpr";a.evaluar=a.evaluate=a.avalua=a.ebaluatu=a["\u00e9valuer"]=a.avaliar="evaluate";a.variable=a.aldagaia=a["vari\u00e1vel"]="variable";a["funci\u00f3n"]=a["function"]=a["funci\u00f3"]=a.funtzio=a.fonction=a["fun\u00e7\u00e3o"]="function";a.algoritmo=
a.algorithm=a.algorisme=a.algorithme="algorithm";a.vector=a.array=a.bektore=a.vecteur=a.matriz="array";a["dibujar-si"]=a["draw-if"]=a["marraztu-baldin"]=a["dessiner-si"]=a["debuxar-se"]=a["desenhar-se"]=a["dibuixa-si"]="drawif";a.dominio=a.range=a.domini=a["izate-eremua"]=a.domain=a["dom\u00ednio"]="range";a.pausa=a.delay=a.eten="delay";a["eje-x"]=a["x-axis"]=a["eix-x"]=a["x-ardatza"]=a["axe-x"]=a["eixe-x"]=a["eixo-x"]="x_axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=
a["eixo-y"]="y_axis";a["n\u00fameros"]=a.numbers=a.nombres=a.zenbakiak="numbers";a["exponencial-si"]=a["exponential-if"]=a["esponentzial-baldin"]=a["exponentiel-si"]=a["exponencial-se"]="exponentialif";a.familia=a.family=a["fam\u00edlia"]=a.famille="family";a.intervalo=a.interval=a.tarte=a.intervalle="interval";a.pasos=a.steps=a.passos=a.pausoak=a.pas="steps";a.centro=a.center=a.centre=a.zentro="center";a.radio=a.radius=a.radi=a.erradio=a.rayon=a.raio="radius";a.fin=a.end=a.fi=a.bukaera=a.fim="end";
a["una-sola-vez"]=a["only-once"]=a["una-sola-vegada"]=a["behin-bakarrik"]=a["une-seule-fois"]=a["unha-soa-vez"]=a["apenas-uma-vez"]="onlyOnce";a.siempre=a.always=a.sempre=a.beti=a.toujours="always";a["color-int"]=a["int-colour"]=a["barruko-kolore"]=a["couleur-int"]=a["cor-int"]="colorInt";a.repetir=a.loop=a.repeteix=a.errepikatu=a["r\u00e9p\u00e9ter"]="loop";a.controles=a.controls=a.kontrolak=a["contr\u00f4les"]=a.controis="controls";a.animar=a.animate=a.anima=a.animatu=a.animer="animate";a.auto=
"auto";a.alto=a.height=a.alt=a.altu=a.haut=a.altura="height";a.x=a.left="x";a.y=a.top="y";a.espacio=a.space=a.espai=a.espazio=a.espace=a.espazo=a["espa\u00e7o"]="space";a.Nu="Nu";a.Nv="Nv";a.ancho=a.depth=a.amplada=a.zabalera=a.largeur=a.ancho=a.profundidade=a.amplada="width";a.largo=a.length=a.llargada=a.luzera=a.longueur=a.longo=a.comprimento=a.llargada="length";a.alto=a.height=a["al\u00e7ada"]=a.altu=a.hauteur=a.alto=a.altura=a["al\u00e7ada"]="height";a.color_reverso=a.backcolor=a.color_revers=
a["atzealde kolorea"]=a.couleur_revers=a.cor_reverso=a.cor_de_fundo="backcolor";a.aristas=a.edges=a.arestes=a.ertzak=a["ar\u00eates"]=a.arestas="edges";a.rotini=a.inirot="inirot";a.posini=a.inipos="inipos";a["tri\u00e1ngulo"]=a.triangle=a.hirukia=a["tri\u00e2ngulo"]="triangle";a.cara=a.face=a.aurpegi="face";a.polireg=a.regpoly=a["pol\u00edgonoRegular"]="polireg";a.superficie=a.surface=a["superf\u00edcie"]=a.azalera="surface";a.cubo=a.cube=a.cub=a.kubo="cube";a["paralelep\u00edpedo"]=a.box=a["paral\u00b7lelep\u00edpede"]=
a.paralelepipedo=a["parall\u00e9l\u00e9pip\u00e8de"]="box";a.cono=a.cone=a.con=a.kono=a["c\u00f4ne"]="cone";a.cilindro=a.cylinder=a.cilindre=a.zilindro=a.cylindre="cylinder";a.esfera=a.sphere=a["sph\u00e8re"]="sphere";a.tetraedro=a.tetrahedron=a.tetraedre=a["t\u00e9tra\u00e8dre"]="tetrahedron";a.octaedro=a["octahedron="]=a.octaedre=a.oktaedro=a["octa\u00e8dre"]="octahedron";a.dodecaedro=a.dodecahedron=a.dodecaedre=a.dodekaedro=a["dod\u00e9ca\u00e8dre"]="dodecahedron";a.icosaedro=a.icosahedron=a.icosaedre=
a.ikosaedro=a["icosa\u00e8dre"]="icosahedron";a.elipsoide=a.ellipsoid=a["el\u00b7lipsoide"]=a["ellipso\u00efde"]=a["elips\u00f3ide"]="ellipsoid";a.macro=a.makro="macro";a.id="id";a.modelo=a.model=a.eredu=a["mod\u00e8le"]="model";a.color=a.kolore=a.couleur=a.cor="color";a.luz=a.light=a.llum=a.argia=a["lumi\u00e8re"]="light";a.metal=a.metall=a["m\u00e9tal"]="metal";a.alambre=a.wire=a.filferro=a.alanbre=a["fil de fer"]=a.arame="wire";a.cortar=a.split=a.talla=a.moztu=a.couper=a.dividir="split";a.despliegue=
a.render=a.desplegament=a.zabaltze=a["d\u00e8ploiement"]=a.despregamento=a.processar="render";a.orden=a.sort=a.ordre=a.ordena=a.orde=a.ordenar="sort";a.pintor=a.painter=a.margolari=a.peintre="painter";a["trazado de rayos"]=a["ray trace"]=a["tra\u00e7at de raigs"]=a["izpi trazadura"]=a["trace de rayons"]=a["trazado de raios"]=a["tra\u00e7ado de raios"]="raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo="image";a.despl_imagen=a.bg_display=a.despl_imatge=a["irudi desplazamendu"]=
a.despl_image=a.despr_imaxe=a["apresenta\u00e7\u00e3o_de_imagem"]="bg_display";a["arr-izq"]=a.topleft=a["dalt-esq"]=a["goi-ezk"]=a["au-dessus-gau"]=a["arr-esq"]=a["acima-esquerda"]="topleft";a["expand."]=a.stretch=a.hedatu=a["expandir "]="stretch";a.mosaico=a.patch=a.mosaic=a.mosaiko=a["mosa\u00efque"]="patch";a.centrada=a.center=a.zentratu=a["centr\u00e9e"]=a.centrado="center";a.archivo=a.file=a.fitxer=a.artxibo=a.fichier=a.arquivo="file";a.tipo_de_macro=a.macro_type=a.tipus_de_macro=a.makro_mota=
a.type_de_macro=a.tipo_de_macro=a.tipo_de_macro=a.tipus_de_macro="macro_type";a.filas_norte=a.rows_north=a.files_nord=a["HTML kodea"]=a.files_nord=a.filas_norte=a.linhas_norte=a.files_nord="rowsNorth";a.filas_sur=a.rows_south=a.files_sud=a.ipar_lerro=a.files_sud=a.filas_sur=a.linhas_sul=a.files_sud="rowsSouth";a.ancho_este=a.width_east=a.ample_est=a.hego_lerro=a.ample_est=a.ancho_leste=a.largura_leste=a.ample_est="widthEast";a.ancho_oeste=a.width_west=a.ample_oest=a.ekialde_zabalera=a.ample_ouest=
a.ancho_oeste=a.largura_oeste=a.ample_oest="widthWest";a.fijo=a.fixed=a.fix=a.hegoalde_zabalera=a.fixe=a.fixo="fixed";a["Reiniciar Animaci\u00f3n"]=a["Init Animation"]=a["Reinicia Animaci\u00f3"]=a.finko=a["Recommencer l'Animation"]=a["Reiniciar Anima\u00e7\u00e3o"]="initAnimation";a["Explicaci\u00f3n"]=a.Explanation=a.Azalpena=a.Explication=a["Explica\u00e7\u00e3o"]=a["Explicaci\u00f3"]="Explanation";a.tooltip=a.dica="tooltip";a.discreto=a.discrete=a.discret=a.diskretu="discrete";a.interfaz=a.gui=
a["interf\u00edcie"]=a.interfaze=a["interface"]="gui";a.pulsador=a.spinner=a.polsador=a.pultsadore=a.bouton="spinner";a["campo de texto"]=a.textfield=a["camp de text"]=a["testu esarrua"]=a["champ de texte"]="textfield";a["men\u00fa"]=a.choice=a.menu=a.escolha="menu";a.barra=a.scrollbar=a.barre="scrollbar";a.opciones=a.options=a.opcions=a.aukerak=a["opci\u00f3ns"]=a["op\u00e7\u00f5es"]="options";a.interior=a.barruko=a["int\u00e9rieur"]="interior";a["condici\u00f3n"]=a.condition=a["condici\u00f3"]=
a.baldintza=a["condi\u00e7\u00e3o"]="condition";a["acci\u00f3n"]=a.action=a["acci\u00f3"]=a.ekintza=a["a\u00e7\u00e3o"]="action";a.evento=a.event=a.esdeveniment=a.gertaera=a["\u00e9v\u00e9nement"]="event";a["abrir URL"]=a["open URL"]=a["obre URL"]=a["URL zabaldu"]=a["ouvrir URL"]="openURL";a["abrir Escena"]=a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]="openScene";a["bot\u00f3n"]=a.button=a["bot\u00f3"]=a.botoi=a.bouton=a["bot\u00e3o"]="button";a.mensaje=
a.message=a.mezua=a.mensaxe=a.mensagem=a.missatge="message";a.alternar=a.alternate=a.alterna=a.txandakatu=a.alterner="alternate";a["ejecuci\u00f3n"]=a.execution=a["execuci\u00f3"]=a.gauzatze=a["ex\u00e9cution"]=a["execuci\u00f3n"]=a["execu\u00e7\u00e3o"]="execution";a.calcular=a.calculate=a.calcula=a.kalkulatu=a.calculer="calculate";a.coord_abs=a.abs_coord=a.koor_abs="abs_coord";a.negrita=a.bold=a.negreta=a.lodi=a["caract\u00e8re gras"]=a.negra=a.negrito="bold";a.cursiva=a.italics=a.etzana=a.italique=
a["it\u00e1lico"]="italics";a.subrayada=a.underlined=a.subratllat=a.azpimarratua=a.soulignement=a["subli\u00f1ada"]=a.sublinhado="underlined";a.imagen=a.image=a.imatge=a.irundia=a.imaxe=a.imagem="image";a.pos_mensajes=a.msg_pos=a.pos_missatges=a.mezuen_pos=a.pos_messages=a.pos_mensaxes="msg_pos";a.izquierda=a.left=a.esquerra=a.eskerrean=a.gauche=a.esquerda=a.esquerda=a.esquerra="x";a.derecha=a.right=a.dreta=a.eskuinan=a.droite=a.dereita=a.direita=a.dreta="right";a["sensible_a_los_movimientos_del_rat\u00f3n"]=
a.sensitive_to_mouse_movements=a["sensible_als_moviments_del_ratol\u00ed"]=a["xagu mugimenduarekiko sentikorra"]=a.sensible_aux_mouvements_du_souris=a.sensible_aos_movementos_do_rato=a["sens\u00edvel_aos_movimentos_do_mouse"]="sensitive_to_mouse_movements";a.reproducir=a.play=a.reprodueix=a.erreproduzitu=a.reproduire=a.reproduzir="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]="activeif";a.rotfin=a.finrot=a.bukrot="endrot";a.posfin=
a.finpos=a.bukpos="endpos";a.editable=a.editagarria=a["edit\u00e1vel"]="editable";a.tipo=a.type=a.tipus=a.mota="type";a.R2="R2";a.R3="R3";a.vectores=a.bektoreak=a.vecteurs=a.vetores=a.vectors="vectors";a["fuente puntos"]=a["font size"]=a["font punts"]=a["puntu iturria"]=a["source points"]=a["fonte puntos"]=a["fonte pontos"]="font_size";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.punto=a.dot=a.punt=a.puntu=a.point=a.ponto="point";
a.escenario=a.scenario=a.escenari=a.agertoki=a["sc\u00e8ne"]=a["cen\u00e1rio"]="scenario";a.cID="cID";a.matriz=a.matrix=a.matriu=a.matrice="matrix";a.filas=a.rows=a.files="rows";a.columnas=a.columns=a.colonnes="columns";a.solo_texto=a.only_text=a.seulement_texte=a["s\u00f3_texto"]=a.tan_sols_texte="onlyText";a.evaluar=a.evaluate="evaluate";a.respuesta=a.answer="answer";a.decimal_symbol=a["signo decimal"]=a["decimal symbol"]="decimal_symbol";a.info="info";a.color_contorn_text=a.color_text_border=a.color_borde_texto=
a.muga_testuaren_kolorea=a.couleur_contour_texte=a.cor_borde_texto=a.colore_bordo_testo=a.cor_borda_texto=a.color_contorn_text="border";a.video=a["vid\u00e9o"]="video";a.audio=a["\u00e0udio"]="audio";a.autoplay="autoplay";a.loop="loop";a.poster="poster";a.opacidad=a.opacity=a["opacit\u00e9"]=a.opacitat=a.opacidade="opacity";a.alinear=a.align=a["ali\u00f1ar"]=a.aligner="align";a.malla=a.mesh="mesh";a.local=a.Local="local";a.loadLib=!0;return a}(babel||{}),descartesJS=function(a){function e(){var a,
b,d,n,f,c,h,e,g;Number.prototype.originalToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(m){if(20>=m)return this.originalToFixed(m);m=0>m?0:parseInt(m);a=this.toString();f=a.indexOf("e");b=a.indexOf(".");if(-1!==f)if(c=a.split("e"),e="-"===c[0][0]?"-":"",h="-"===e?c[0].substring(1):c[0],g=parseInt(c[1]),0>b+g){var p=e+"0.",l;l=Math.abs(b+g);l=Array(l+1).join("0");a=p+l+h.replace(".","");b=1}else h=h.replace(".",""),a=e+h+Array(g-h.length+2).join("0"),b=-1;d="";if(-1===b)return 0<
m&&(d="."),d+=Array(m+1).join("0"),a+d;n=a.length-b-1;if(n>=m)return 0<m?a.substring(0,b+1+m):a.substring(0,b);p=0;for(m-=n;p<m;p++)d+="0";return a+d}}function k(a,b,d){a.fillStyle="#c0c0c0";a.fillRect(b.offsetLeft,b.offsetTop,b.offsetWidth,b.offsetHeight);g(a,b,d.controls)}function g(a,b,d){for(var n,f=d.length-1;0<=f;f--)n=d[f],a.drawImage(n.getScreenshot(),b.offsetLeft+n.x,b.offsetTop+n.y)}if(a.loadLib)return a;var b=2*Math.PI,c=360/b,f=b/360,h=Math.floor,d,r,l,m,t,q,u,p,v,n;a.rangeOK=1;a.extend=
function(a,b){if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var d in b.prototype)b.prototype.hasOwnProperty(d)&&(a.prototype[d]=b.prototype[d]);a.prototype.uber=b.prototype};a.radToDeg=function(a){return a*c};a.degToRad=function(a){return a*f};a.convertFont=function(a){if(""==a)return a;d=a.split(",");r="";"bold"==d[1].toLowerCase()?r+="Bold ":"italic"==d[1].toLowerCase()||"italics"==d[1].toLowerCase()?r+="Italic ":"bold+italic"==d[1].toLowerCase()&&(r+="Italic Bold ");r+=d[2]+
"px ";l=d[0].split(" ")[0].toLowerCase();return r="serif"===l||"times new roman"===l||"timesroman"===l||"times"===l?r+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===l||"arial"===l||"helvetica"===l?r+"Arial, Helvetica, 'Droid Sans', Sans-serif":r+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};a.drawLine=function(a,b,d,n,f,c,e){a.lineWidth=e||1;a.strokeStyle=c||"black";c=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(h(b)+c,h(d)+c);a.lineTo(h(n)+c,h(f)+c);a.stroke()};a.getColor=
function(a,b){if("string"==typeof b)return b;m=a.evalExpression(b);t=h(255*m[0][0]);q=h(255*m[0][1]);u=h(255*m[0][2]);p=1-m[0][3];return"rgba("+t+","+q+","+u+","+p+")"};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,n=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(v=a.pageX,n=a.pageY):(v=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,n=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);
return{x:v,y:n}};a.getTextWidth=function(b,d){a.ctx.font=d;return a.ctx.measureText(b).width};var s=document.createElement("span");s.appendChild(document.createTextNode("\u00c1p"));var w=document.createElement("div");w.setAttribute("style","display: inline-block; w: 1px; h: 0px;");var z=document.createElement("div");z.setAttribute("style","margin: 0; padding: 0;");z.appendChild(s);z.appendChild(w);var C={};a.getFontMetrics=function(a){if(C[a])return C[a];s.setAttribute("style","font: "+a+"; margin: 0px; padding: 0px;");
document.body.appendChild(z);var b={};z.getBoundingClientRect?(w.style.verticalAlign="baseline",b.ascent=w.offsetTop-s.offsetTop,b.h=z.getBoundingClientRect().height||0):(w.style.verticalAlign="baseline",b.ascent=w.offsetTop-s.offsetTop,w.style.verticalAlign="bottom",b.h=w.offsetTop-s.offsetTop);b.descent=b.h-b.ascent;b.baseline=b.ascent;document.body.removeChild(z);return C[a]=b};a.getFieldFontSize=function(a){a=Math.min(50,a);return a=24<=a?Math.floor(a/2+2-a/16):20<=a?12:17<=a?11:15<=a?10:9};a.getScreenshot=
function(){var b=a.apps[0],d,n=document.createElement("canvas"),f=new Image;if(b){n.setAttribute("width",b.width);n.setAttribute("height",b.height);for(var c=n.getContext("2d"),h=0,e=b.spaces.length;h<e;h++)d=b.spaces[h],"R2"===d.type&&(c.drawImage(d.backgroundCanvas,d.x,d.y),c.drawImage(d.canvas,d.x,d.y),g(c,d.container,d.ctrs));0<b.northSpace.controls.length&&k(c,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&k(c,b.southSpace.container,b.southSpace);0<b.eastSpace.controls.length&&
k(c,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&k(c,b.westSpace.container,b.westSpace);f.src=n.toDataURL("image/png")}return f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k;a._externalFilesContent={};a.openExternalFile=function(g){if(a._externalFilesContent[g])return a._externalFilesContent[g];e=null;var b=!1;if(window.XMLHttpRequest)try{b=new XMLHttpRequest}catch(c){b=!1}else if(window.ActiveXObject)try{b=new ActiveXObject("Msxml2.XMLHTTP")}catch(f){try{b=
new ActiveXObject("Microsoft.XMLHTTP")}catch(h){b=!1}}k=b;k.open("GET",g,!1);try{k.send(null),e=k.responseText,e.match(String.fromCharCode(65533))&&(k.open("GET",g,!1),k.overrideMimeType("text/plain; charset=ISO-8859-1"),k.send(null),e=k.responseText)}catch(d){console.log("Error to load the file :",g),e=null}return e};a.addExternalFileContent=function(e,b){a._externalFilesContent[e]=b};return a}(descartesJS||{}),descartesJS=function(a){function e(a){c=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};
c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1),"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1)));"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1),c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1)));"*"===c.charAt(0)&&"*"!==c.charAt(c.length-1)?c=c.substring(1)+"$":"*"!==c.charAt(0)&&"*"===c.charAt(c.length-1)?c="^"+c.substring(0,c.length-1):"*"!==c.charAt(0)&&"*"!==c.charAt(c.length-
1)?c="^"+c+"$":"*"===c.charAt(0)&&"*"===c.charAt(c.length-1)&&(c=c.substring(1,c.length-1));c=c.replace(/\?/g,"[\\S\\s]{1}");a.regExp=c;return a}function k(a,b){c=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=c.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:b.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),expr:b.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function g(a,
b,d){b=parseFloat(b);r=a.expr[0];l=a.expr[1];m=d.evalExpression(r.expr);t=d.evalExpression(l.expr);q="("==r.type;u="["==r.type;p=")"==l.type;v="]"==l.type;return(q&&b>m||u&&b>=m)&&(p&&b<t||v&&b<=t)?1:0}function b(a){return a.toString().replace(/\u00e1/g,"a").replace(/\u00e9/g,"e").replace(/\u00ed/g,"i").replace(/\u00f3/g,"o").replace(/\u00fa/g,"u").replace(/\u00c1/g,"A").replace(/\u00c9/g,"E").replace(/\u00cd/g,"I").replace(/\u00d3/g,"O").replace(/\u00da/g,"U").replace(/\u00f1/g,"n").replace(/\u00d1/g,
"N")}if(a.loadLib)return a;var c,f,h,d,r,l,m,t,q,u,p,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 d=0,g=a.length;d<g;d++){f=a[d].split("&");h=[];for(var m=0,p=f.length;m<p;m++)c=f[m],-1!==c.indexOf(",")&&("("===c.charAt(0)||"["===c.charAt(0))&&(")"===c.charAt(c.length-1)||"]"===c.charAt(c.length-1))?h.push(k(c,b)):h.push(e(c));
a[d]=h}return a};a.escorrecto=function(c,h,e,m){e=e||a.externalEvaluator;m=m||a.buildRegularExpresionsPatterns(c,e);h=b(h);c=0;for(var p=m.length;c<p;c++){f=m[c];d=!0;for(var l=0,k=f.length;l<k;l++)d=f[l].regExp?d&&!!h.match(b(f[l].regExp),"i"):d&&g(f[l],h,e);if(d)return 1}return 0};a.esCorrecto=function(n,h,e,m){e=e||a.externalEvaluator;m=m||a.buildRegularExpresionsPatterns(n,e);n=0;for(var p=m.length;n<p;n++){f=m[n];d=!0;for(var l=0,k=f.length;l<k;l++)(c=f[l].regExp)?(f[l].ignoreAcents&&(h=b(h),
c=b(c)),f[l].ignoreCaps&&(h=h.toLowerCase(),c=b(c).toLowerCase()),d=d&&!!h.match(c)):d=d=d&&g(f[l],h,e);if(d)return 1}return 0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.getCreativeCommonsLicenseImage=function(){var a=new Image;a.src="";
return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,k,g,b,c,f,h,d,r,l;a.Color=function(a,d){this.b=this.g=this.r=0;this.a=1;this.evaluator=d;if(a){if(babel[a]&&("net"===babel[a]&&(a="rojo"),a=babel[a],this.r=parseInt("0x"+a.substring(1,3),16),this.g=parseInt("0x"+a.substring(3,5),16),this.b=parseInt("0x"+a.substring(5,7),16),this.colorStr=a,this.getColor=this.getColorString),6===a.length&&(this.r=parseInt("0x"+a.substring(0,2),16),this.g=parseInt("0x"+
a.substring(2,4),16),this.b=parseInt("0x"+a.substring(4,6),16),this.colorStr="#"+a,this.getColor=this.getColorString),8===a.length&&(this.r=parseInt("0x"+a.substring(2,4),16),this.g=parseInt("0x"+a.substring(4,6),16),this.b=parseInt("0x"+a.substring(6,8),16),this.a=1-parseInt("0x"+a.substring(0,2),16)/255,this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString),"("===a[0]){g=[];b=this.splitComa(a.substring(1,a.length-1));for(var f=0,h=b.length;f<h;f++)c=
parseInt(b[f],16),b[f]!=c.toString(16)&&b[f]!=="0"+c.toString(16)?("["===b[f].charAt(0)&&"]"===b[f].charAt(b[f].length-1)&&(b[f]=b[f].substring(1,b[f].length-1)),g.push(this.evaluator.parser.parse(b[f]))):g.push(this.evaluator.parser.parse((c/255).toString()));this.rExpr=g[0];this.gExpr=g[1];this.bExpr=g[2];this.aExpr=g[3];this.getColor=this.getColorExpression}}else this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString};a.Color.prototype.splitComa=function(a){f=
[];for(var b=r=d=h=0,c=a.length;b<c;b++)l=a.charAt(b),"("===l?h++:")"===l?h--:"["===l?d++:"]"===l?d--:","===l&&(0===h&&0===d)&&(f.push(a.substring(r,b)),r=b+1);f.push(a.substring(r));return f};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){k=this.evaluator;this.r=e(255*k.evalExpression(this.rExpr));this.g=e(255*k.evalExpression(this.gExpr));this.b=e(255*k.evalExpression(this.bExpr));this.a=1-k.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,k=document.createElement("meta");k.setAttribute("http-equiv","X-UA-Compatible");k.setAttribute("content","chrome=1");e.appendChild(k);k=document.createElement("meta");k.setAttribute("name","viewport");k.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
e.appendChild(k);k=document.createElement("meta");k.setAttribute("name","apple-mobile-web-app-capable");k.setAttribute("content","yes");e.appendChild(k);k=document.createElement("meta");k.setAttribute("name","apple-mobile-web-app-status-bar-style");k.setAttribute("content","black-translucent");e.appendChild(k);(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,k=Math.floor,g=Math.random,b=Math.round,c=Math.abs,f=String.fromCharCode,h,d,r,l,m,t,q,u,p,v;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){h=[];for(var b=0;256>b;b++)h[b]=f(this.alfanum(k(c(7.5*(e(1*b-a)+e(1.4*b+a)+e(0.6*b-a)+e(2.2*b+a))))));return h.join("")};a.Krypto.prototype.encode=function(a){d=k(31*g());this.key=this.getKey(d);l=f(this.alfanum(d));return l+this.encripta(a)};
a.Krypto.prototype.decode=function(a){d=this.numalfa(a.charCodeAt(0));this.key=this.getKey(d);return this.desencripta(a.substring(1))};a.Krypto.prototype.encripta=function(a){return this.bytesToString(this.encriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.encriptaAux=function(a){if(null==a||null==this.key)return null;t=Array(3*a.length);for(var d=0,f=a.length;d<f;d++)p=256*k(a[d]+128)+b(255*g())+65536*b(255*g()),v=k((p<<this.shift(d))/256),t[3*d]=this.alfanum(v%32),t[3*d+1]=this.alfanum(v/32%
32),t[3*d+2]=this.alfanum(v/1024%32);return t};a.Krypto.prototype.desencripta=function(a){return this.bytesToString(this.desencriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.desencriptaAux=function(a){if(null==a||null==this.key)return null;q=Array(a.length/3);for(var b=0,d=q.length;b<d;b++)v=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),p=k(256*v>>this.shift(b)),u=k(p/256)%256-128,0>u&&(u+=256),q[b]=u;return q};a.Krypto.prototype.alfanum=function(a){a=k(a);return 10>
a?48+a:87+a};a.Krypto.prototype.numalfa=function(a){return 58>a?a-48:a-87};a.Krypto.prototype.stringToBytes=function(a){l=Array(a.length);for(var b=0,d=a.length;b<d;b++)l[b]=a.charCodeAt(b);return l};a.Krypto.prototype.bytesToString=function(a){for(var b=0,d=a.length;b<d;b++)a[b]=f(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){r=this.key.charCodeAt(a%this.key.length);l=this.numalfa(r);m=k(l/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,k){this.parent=e;var g=e.evaluator,b=g.parser,c=new a.Auxiliary(e);this.delay=k.delay?b.parse(k.delay):b.parse("60");this.loop=k.loop?k.loop:!1;this.auto=void 0==k.auto?!0:k.auto;this.controls=k.controls;this.init=c.splitInstructions(b,k.init);this.doExpr=c.splitInstructions(b,k.doExpr);k.whileExpr&&(this.whileExpr=b.parse(k.whileExpr));var f=this,h,d,r=f.doExpr.length;this.animationExec=
function(){for(d=0;d<r;d++)g.evalExpression(f.doExpr[d]);f.parent.update();f.playing&&(0<g.evalExpression(f.whileExpr)||f.loop)?(h=g.evalExpression(f.delay),f.timer=setTimeout(f.animationExec,10>h?10:h)):(f.stop(),f.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,k=this.init.length;a<k;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,k){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,k){a.Action.call(this,e,k);this.parameter=(k||"").replace(/\\n/g,
"\n").replace(/&squot;/g,"'")};a.extend(a.Message,a.Action);a.Message.prototype.execute=function(){alert(this.parameter)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Calculate=function(e,k){a.Action.call(this,e,k);var g=this.evaluator,b=g.parser;k=(k||"").replace(/&squot;/g,"'");k=k.replace(/;/g,"\\n");k=k.split("\\n")||[""];for(var c=[],f,h=0,d=k.length;h<d;h++)(f=b.parse(k[h],!0))&&c.push(f);d=c.length;this.execute=function(){for(h=0;h<d;h++)g.evalExpression(c[h])}};
a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(e,k){a.Action.call(this,e,k);this.parameter=k;this.target="_blank";var g=this.parameter.indexOf("target");-1!=g&&(this.target=this.parameter.substring(g),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,g-1));"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),
this.actionExec=function(){eval(this.parameter)}):("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,this.target)})};a.extend(a.OpenURL,a.Action);a.OpenURL.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenScene=function(e,k){a.Action.call(this,e,k);this.parameter=k;this.target=
"_blank";var g=this.parameter.indexOf("target");-1!=g&&(this.target=this.parameter.substring(g),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,g-1));"_blank"!==this.target&&"_parent"!==this.target&&"_self"!==this.target&&"_top"!==this.target?this.actionExec=function(){window.parent.postMessage({type:"changeTarget",name:this.target,value:this.parameter},"*")}:"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,
"'"),this.actionExec=function(){eval(this.parameter)}):("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){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=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
this.window.onload=function(a){a=this.document;var c=a.getElementsByTagName("applet");c&&0<c.length&&(this.innerWidth=c[0].width,this.height=c[0].height,a.body.style.margin="0px",a.body.style.padding="0px",c[0].parentNode.style.margin="0px",c[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,k){a.Action.call(this,e,k);k||(this.urlAbout=
window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+k)};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,k){a.Action.call(this,e,k)};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,k){a.Action.call(this,e,k)};
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,k){a.Action.call(this,e,k)};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,k){a.Action.call(this,e,k)};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,k){a.Action.call(this,e,k)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g;a.PlayAudio=function(k,g){a.Action.call(this,k,g);g&&g.match(e)?this.filenameExpr=this.evaluator.parser.parse("'"+g.match(e)+"'"):this.filenameExpr=
this.evaluator.parser.parse(g)};a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=function(){var a=this.theAudio=this.parent.getAudio(this.evaluator.evalExpression(this.filenameExpr));a.paused?a.play():(a.pause(),a.currentTime=0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Auxiliary=function(a,b){this.parent=a;this.evaluator=this.parent.evaluator;this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var c in b)b.hasOwnProperty(c)&&(this[c]=
b[c])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var e,k;a.Auxiliary.prototype.splitInstructions=function(a,b){k=[];b=b?b.split(";"):[""];for(var c=0,f=b.length;c<f;c++)(e=a.parse(b[c],!0))&&k.push(e);return k};a.Auxiliary.prototype.getPrivateVariables=function(a,b){k=[];b=b?b.split(/;|,/):[""];for(var c=0,f=b.length;c<f;c++)(e=a.parse(b[c],!0))&&k.push(e);c=0;for(f=k.length;c<f;c++)k[c]="asign"===k[c].type?k[c].childs[0].value:"identifier"===k[c].type?
k[c].value:"";return k};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,k){a.Auxiliary.call(this,e,k);var g=this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=g.parse(this.expresionString))&&
g.setVariable(this.id,this.expresion);this.editable&&(this.registerTextField(),this.parent.editableRegionVisible=!0)};a.extend(a.Variable,a.Auxiliary);a.Variable.prototype.registerTextField=function(){var a=document.createElement("div"),k=document.createElement("label");k.appendChild(document.createTextNode("___"+this.id+"=___"));var g=document.createElement("input");g.value=this.expresionString;g.disabled=!this.editable;a.appendChild(k);a.appendChild(g);var b=this,c=b.evaluator.parser;g.onkeydown=
function(a){13==a.keyCode&&(b.expresion=c.parse(this.value),c.setVariable(b.id,b.expresion),b.parent.update())};this.parent.editableRegion.textFields.push({container:a,type:"div"})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Constant=function(e,k){a.Auxiliary.call(this,e,k);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=function(){this.evaluator.setVariable(this.id,this.evaluator.evalExpression(this.expresion))};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g;a.Vector=function(b,c){e=b.evaluator;k=e.parser;this.size=k.parse("3");a.Auxiliary.call(this,b,c);this.expresion=this.expresion.split(";");this.parseFile=k.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var b=this.expresion;e=this.evaluator;k=e.parser;this.oldFile=this.file;if(g=e.evalExpression(this.parseFile))this.file=g;var c;if(this.file){c=(vectorElement=document.getElementById(this.file))&&
"descartes/vectorFile"==vectorElement.type?vectorElement.text:a.openExternalFile(this.file);if(null!=c){c=c.replace(/\r/g,"").split("\n");for(var f=[],h=0,d=c.length;h<d;h++)""!=c[h]&&f.push(c[h]);c=f}null==c||1==c.length&&""==c[0]?this.size=0:(b=c,this.size=null);null===this.size&&(this.size=k.parse(b.length+""))}c=[];h=0;for(d=b.length;h<d;h++)(f=k.parse(b[h],!0))&&"asign"!=f.type&&(f=k.parse(this.id+"["+h+"]="+b[h],!0)),c.push(f);b=[];h=0;for(d=e.evalExpression(this.size);h<d;h++)b.push(0);e.vectors[this.id]=
b;e.setVariable(this.id+".long",e.evalExpression(this.size));h=0;for(d=c.length;h<d;h++)e.evalExpression(c[h])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(e,k){var g=e.evaluator,b=g.parser;this.rows=b.parse("3");this.columns=b.parse("3");a.Auxiliary.call(this,e,k);this.expresion=this.splitInstructions(b,this.expresion);var b=g.evalExpression(this.rows),c=g.evalExpression(this.columns),f=[];f.type="matrix";for(var h,d=0;d<c;d++){h=[];for(var r=0,l=b;r<
l;r++)h.push(0);f[d]=h}g.matrices[this.id]=f;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,k=a.evalExpression(this.rows),g=a.evalExpression(this.columns);a.setVariable(this.id+".filas",k);a.setVariable(this.id+".columnas",g);var b=a.matrices[this.id];b.rows=k;b.cols=g;k=0;for(g=this.expresion.length;k<g;k++)a.evalExpression(this.expresion[k])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(e,k){a.Auxiliary.call(this,
e,k);var g=this.evaluator,b=g.parser,c=this.id.indexOf("(");this.name=this.id.substring(0,c);this.params=this.id.substring(c+1,this.id.length-1);this.domain=this.range?b.parse(this.range):b.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(b);this.expresion=b.parse(this.expresion);var f=this;this.functionExec=function(){this.iterations=0;if(f.numberOfParams<=arguments.length){for(var b=
[],d=0,c=f.privateVars.length;d<c;d++)b.push(g.getVariable(f.privateVars[d])),g.setVariable(f.privateVars[d],0);for(var e=[],d=0,c=f.params.length;d<c;d++)e[d]=g.getVariable(f.params[d]),g.setVariable(f.params[d],arguments[d]);d=0;for(c=f.init.length;d<c;d++)g.evalExpression(f.init[d]);do{d=0;for(c=f.doExpr.length;d<c;d++)g.evalExpression(f.doExpr[d]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en la funci\u00f3n",this.id),0}while(0<g.evalExpression(f.whileExpr));
var m=g.evalExpression(f.expresion);a.rangeOK=g.evalExpression(f.domain);d=0;for(c=f.params.length;d<c;d++)g.setVariable(f.params[d],e[d]);d=0;for(c=f.privateVars.length;d<c;d++)g.setVariable(f.privateVars[d],b[d]);return m}return 0};g.setFunction(this.name,this.functionExec)};a.extend(a.Function,a.Auxiliary);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Algorithm=function(e,k){a.Auxiliary.call(this,e,k);var g=this.evaluator;this.parseExpressions(g.parser);this.algorithmExec=
function(){for(var a=this.iterations=0,c=this.init.length;a<c;a++)g.evalExpression(this.init[a]);do{a=0;for(c=this.doExpr.length;a<c;a++)g.evalExpression(this.doExpr[a]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en el algoritmo",this.id),0}while(0<g.evalExpression(this.whileExpr))}};a.extend(a.Algorithm,a.Auxiliary);a.Algorithm.prototype.update=function(){this.algorithmExec();"onlyOnce"===this.evaluate&&(this.update=function(){})};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.Event=function(e,k){a.Auxiliary.call(this,e,k);var g=this.evaluator;this.condition=g.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){0<g.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<g.evalExpression(this.condition);
3==this.parent.version?a!=this.lastEvaluation&&(this.action.execute(),this.lastEvaluation=a?!0:!1):a&&!this.lastEvaluation?(this.action.execute(),this.lastEvaluation=!0):!a&&this.lastEvaluation&&(this.lastEvaluation=!1)});"always"==this.execution&&(this.eventExec=function(){0<g.evalExpression(this.condition)&&this.action.execute()})};a.extend(a.Event,a.Auxiliary);a.Event.prototype.update=function(){this.eventExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,
g,b,c;a.Graphic=function(b,c){this.parent=b;this.evaluator=b.evaluator;var d=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=d.parse("1");this.abs_coord=!1;this.color=new a.Color("blue");2!==this.parent.version&&(this.color=new a.Color("20303a"),this.parent.arquimedes&&(this.color=new a.Color("black")));this.trace="";this.expresion=d.parse("(0,0)");this.family="";this.family_interval=d.parse("[0,1]");this.family_steps=d.parse("8");this.editable=!1;this.font=5<=this.parent.version?
"Monospaced,PLAIN,15":"Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=d.parse("2");for(var e in c)c.hasOwnProperty(e)&&(this[e]=c[e]);this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backgroundCanvas.getContext("2d"));this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10};a.Graphic.prototype.getSpace=
function(){for(var a=this.parent.spaces,b,d=0,c=a.length;d<c;d++)if(b=a[d],b.id==this.spaceID)return b;return a[0]};a.Graphic.prototype.getFamilyValues=function(){e=this.evaluator;k=e.evalExpression(this.family_interval);this.familyInf=k[0][0];this.familySup=k[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,d){e=this.evaluator;this.getFamilyValues();g=e.getVariable(this.family);
if(0<=this.fSteps)for(var c=0,l=this.fSteps;c<=l;c++)e.setVariable(this.family,this.familyInf+c*this.family_sep),0<e.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,d));e.setVariable("_Text_H_",0);e.setVariable(this.family,g)};a.Graphic.prototype.draw=function(a,b){""!=this.family?this.drawFamilyAux(this.ctx,a,b):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.ctx,a,b))};a.Graphic.prototype.drawTrace=function(a,b){""!=this.family?this.drawFamilyAux(this.traceCtx,
a,b):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,a,b))};a.Graphic.prototype.drawText=function(a,h,d,g,l,m,k,q,u,p,v){if("rtfNode"===h.type)a.fillStyle=l.getColor(),a.strokeStyle=l.getColor(),a.textBaseline="alphabetic",h.draw(a,d,g,u,p,k,v);else{"simpleText"===h.type&&(h=h.toString(u,p).split("\\n"));d+=m.match("Arial")?-2:m.match("Times")?-2:0;e=this.evaluator;a.fillStyle=l.getColor();a.font=m;a.textAlign=k;a.textBaseline=q;this.border&&(a.strokeStyle=
this.border.getColor(),a.lineWidth=3);c=1.2*this.fontSize||0;l=0;for(m=h.length;l<m;l++)b=h[l],this.border&&(a.lineJoin="round",a.strokeText(b,d,g+c*l)),a.fillText(b,d,g+c*l)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=function(a,b){this.text=b=b.replace("&#x2013","\u2013").replace(/\&squot;/g,"'");this.textElements=[];this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var c="'",f=0,h=0,d=-1,e,l;f<b.length;)e=
b.charAt(f),l=b.charAt(f-1),"["===e&&"\\"===l?(this.textElements.push(b.substring(h,f-1)+"["),this.textElementsMacros.push("'"+b.substring(h,f-1)+"['"),h=f+1):"]"===e&&"\\"===l?(this.textElements.push(b.substring(h,f-1)+"]"),this.textElementsMacros.push("'"+b.substring(h,f-1)+"]'"),h=f+1):"["===e&&-1===d?(this.textElements.push(b.substring(h,f)),this.textElementsMacros.push("'"+b.substring(h,f)+"'"),h=f,d++):"["===e?d++:"]"===e&&0===d?(this.textElements.push(this.evaluator.parser.parse(b.substring(h,
f+1))),this.textElementsMacros.push("["+b.substring(h,f+1)+"]"),h=f+1,d--):("]"==b.charAt(f)&&(d=0>d?d:d-1),c+=b.charAt(f)),f++;this.textElements.push(b.substring(h,f));this.textElementsMacros.push("'"+b.substring(h,f)+"'")};var e,k;a.SimpleText.prototype.toString=function(a,b){e="";for(var c=0,f=this.textElements.length;c<f;c++)"string"===typeof this.textElements[c]?e+=this.textElements[c]:(k=this.evaluator.evalExpression(this.textElements[c])[0][0],""!==k&&("string"===typeof k?e+=k:(k=parseFloat(k),
k=b?k.toFixed(a):parseFloat(k.toFixed(a)),e+=k.toString().replace(".",this.parent.decimal_symbol))));return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,k,g,b,c,f,h,d,r,l,m,t,q,u,p,v,n,s,w,z,C,y,E,D,B,A,H,G;a.Equation=function(b,d){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP="";a.Graphic.call(this,b,d);this.generateStroke();this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();
q=new a.R2;u=new a.R2;p=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],d=this.expresion.childs[1];"identifier"==b.type&&"y"==b.value&&!d.contains("y")?(this.funExpr=d,this.of_y=!1,this.drawAux=this.drawAuxFun):"identifier"==d.type&&"y"==d.value&&!b.contains("y")?(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):"identifier"==b.type&&"x"==b.value&&!d.contains("x")?
(this.funExpr=d,this.of_y=!0,this.drawAux=this.drawAuxFun):"identifier"==d.type&&("x"==d.value&&!b.contains("x"))&&(this.of_y=!0,this.funExpr=d,this.drawAux=this.drawAuxFun)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.generateStroke=function(){this.auxCanvas=document.createElement("canvas");this.oldWwidth=parseInt(this.evaluator.evalExpression(this.width));this.width_2=parseInt(this.oldWwidth/2)||1;this.auxCanvas.setAttribute("width",this.oldWwidth);this.auxCanvas.setAttribute("height",
this.oldWwidth);this.auxCtx=this.auxCanvas.getContext("2d");this.auxCtx.fillStyle=this.color.getColor();this.auxCtx.fillRect(0,0,this.oldWwidth,this.oldWwidth)};var I;a.Equation.prototype.update=function(){I=parseInt(this.evaluator.evalExpression(this.width));I!==this.oldWwidth&&this.generateStroke()};a.Equation.prototype.draw=function(){""!=this.family?this.drawFamilyAux(this.ctx,this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,this.color))};a.Equation.prototype.drawFamilyAux=
function(a,b,d){g=this.evaluator;this.getFamilyValues();tempParam=g.getVariable(this.family);if(0<=this.fSteps)for(var c=0,f=this.fSteps;c<=f;c++)g.setVariable(this.family,this.familyInf+c*this.family_sep),this.update(),this.drawAux(a,b,d);g.setVariable(this.family,tempParam)};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(I,x,J){I.lineWidth=1;g=this.evaluator;b=g.parser;c=this.space;f=g.evalExpression(this.width);
I.fillStyle=J.getColor();I.translate(-parseInt(f/2),-parseInt(f/2));h=b.getVariable("x");d=b.getVariable("y");r=c.w;l=c.h;m=parseInt(r/8);3>m&&(m=3);t=parseInt(l/8);3>t&&(t=3);k=[];q.set(0,0);u.set(0,0);p.set(0,0);for(G=parseInt(t/2);G<l;G+=t)for(H=parseInt(m/2);H<r;H+=m)if(this.abs_coord?(s.set(H,G),n=this.newt.findZero(s),g.setVariable("x",n.x),g.setVariable("y",n.y),v.set(n.x,n.y)):(s.set(c.getRelativeX(H),c.getRelativeY(G)),n=this.newt.findZero(s),g.setVariable("x",n.x),g.setVariable("y",n.y),
v.set(c.getAbsoluteX(n.x),c.getAbsoluteY(n.y))),w=v.ix(),z=v.iy(),!(0>w||w>=r||0>z||z>=l||k[w+z*c.w]))if(k[w+z*c.w]=!0,a.rangeOK&&g.evalExpression(this.drawif)&&I.drawImage(this.auxCanvas,w,z),q.x=n.x,q.y=n.y,u.x=n.x,u.y=n.y,C=this.newt.getUnitNormal(),!(0==C.x&&0==C.y)){C.rotL90();p.x=C.x;p.y=C.y;E=y=0;for(D=!1;2>E;){D&&(p.x=-C.x,p.y=-C.y,n.x=q.x,n.y=q.y,u.x=n.x,u.y=n.y,this.abs_coord?v.set(n.x,n.y):v.set(c.getAbsoluteX(n.x),c.getAbsoluteY(n.y)),w=v.ix(),z=v.iy(),D=!1,y=0);this.abs_coord?(n.x+=p.x,
n.y+=p.y):(n.x+=p.x/c.scale,n.y+=p.y/c.scale);n=this.newt.findZero(n);g.setVariable("x",n.x);g.setVariable("y",n.y);p.x=n.x-u.x;p.y=n.y-u.y;p.normalize();if(0==p.x&&0==p.y)break;u.x=n.x;u.y=n.y;this.abs_coord?v.set(n.x,n.y):v.set(c.getAbsoluteX(n.x),c.getAbsoluteY(n.y));B=e(v.ix());A=e(v.iy());if(B!=w||A!=z)if(w=B,z=A,0<=w&&w<r&&0<=z&&z<l)if(y=0,k[w+z*c.w])break;else k[w+z*c.w]=!0,a.rangeOK&&g.evalExpression(this.drawif)&&I.drawImage(this.auxCanvas,w,z);else D=!0,E++;else 4<++y&&(D=!0,E++)}}I.setTransform(1,
0,0,1,0,0)};a.Equation.prototype.X=function(a,b,d){d||(b=this.space.w/2+this.space.Ox+this.space.scale*b);b<-a&&(b=-a);b>this.space.w+a&&(b=this.space.w+a);return b};a.Equation.prototype.Y=function(a,b,d){d||(b=this.space.h/2+this.space.Oy-this.space.scale*b);b<-a&&(b=-a);b>this.space.h+a&&(b=this.space.h+a);return b};a.Equation.prototype.XX=function(a,b,d){return Math.round(this.X(a,b,d))};a.Equation.prototype.YY=function(a,b,d){return Math.round(this.Y(a,b,d))};a.Equation.prototype.extrapolate=
function(b,d,c,f,h,n){for(var e=this.evaluator.getVariable(d),g=n/2,m=0;1E-12<Math.abs(g);){var p=this.evaluator.getVariable(d),l=this.evaluator.getVariable(d)+g;this.evaluator.setVariable(d,l);var k=!0,r=h;h=this.evaluator.evalExpression(this.funExpr);this.evaluator.setVariable(c,h);if(0<this.evaluator.evalExpression(b)){var q=new a.R2(Math.min(r,h),Math.max(r,h)),t=0,t=0<n?this.Singularity(Math.abs(g),d,f,p,r,l,h,q):this.Singularity(Math.abs(g),d,f,l,h,p,r,q);0<t&&(k=!1)}else k=!1;k?m+=g:this.evaluator.setVariable(d,
p);g/=2}this.evaluator.setVariable(d,e);return new a.R2(m/Math.abs(n),h)};a.Equation.prototype.extrapolateOnSingularity=function(b,d,c,f,h,n){f=this.evaluator.getVariable(d);for(var e=n/2,g=0,m=h;1E-12<Math.abs(e);){this.evaluator.setVariable(this.evaluator.getVariable(d)+e);var p=!0;0<this.evaluator.evalExpression(b)?(m=this.evaluator.evalExpression(this.funExpr),this.evaluator.setVariable(c,m),0>=this.evaluator.evalExpression(b)&&(p=!1)):p=!1;p?g+=e:this.evaluator.setVariable(this.evaluator.getVariable(d)-
e);e/=2}if(0==g){e=n/2;g=n;for(m=h;1E-12<Math.abs(e);)this.evaluator.setVariable(this.evaluator.getVariable(d)-e),p=!0,0<this.evaluator.evalExpression(b)?m=this.evaluator.evalExpression(this.funExpr):p=!1,p?g+=-e:this.evaluator.setVariable(this.evaluator.getVariable(d)+e),e/=2}this.evaluator.setVariable(f);return new a.R2(g/Math.abs(n),m)};a.Equation.prototype.Singularity=function(a,b,d,c,f,h,n,e){if(c>=h)return 2;var g=this.evaluator.getVariable(b),m=0;if(1E-12>Math.abs(h-c)||1E-8>Math.abs(h-c)&&
Math.abs(n-f)>Math.abs(a))return this.evaluator.setVariable(b,g),1;var p=(c+h)/2;this.evaluator.setVariable(b,p);var l=this.evaluator.evalExpression(this.funExpr);if(Math.abs(n-f)>a){this.evaluator.setVariable(b,c-1E-6);var k=this.evaluator.evalExpression(this.funExpr),k=(f-k)/1E-6;this.evaluator.setVariable(b,h+1E-6);var r=(this.evaluator.evalExpression(this.funExpr)-n)/1E-6,q=(n-f)/(h-c);if(10>Math.abs(r)||10>Math.abs(k))if((0<=r&&0<=k||0>=r&&0>=k)&&8*Math.abs(r)<Math.abs(q))return this.evaluator.setVariable(b,
g),2}e.x<=l&&l<=e.y||(this.evaluator.setVariable(b,p),e.x=Math.min(f,l),e.y=Math.max(f,l),c=this.Singularity(a/2,b,d,c,f,p,l,e),this.evaluator.setVariable(b,h),e.x=Math.min(n,l),e.y=Math.max(n,l),a=this.Singularity(a/2,b,d,p,l,h,n,e),m=Math.max(c,a));this.evaluator.setVariable(b,g);return m};a.Equation.prototype.drawAuxFun=function(b,c,f){h=this.evaluator.parser.getVariable("x");d=this.evaluator.parser.getVariable("y");c="x";f="y";this.of_y&&(c="y",f="x");var n=this.drawif,e=this.evaluator.evalExpression(this.width),
g=!1,m=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),m=this.of_y?m.ix():m.iy(),p=0,l=0,k=0,r=1/this.space.scale,q=r*(this.of_y?-this.space.h+(this.space.h/2+this.space.Oy):-(this.space.w/2+this.space.Ox)),p=0;this.abs_coord&&(q=this.space.h,r=-1);for(var t=this.of_y?this.space.h:this.space.w;l<t;){var u=!0,w=0;this.evaluator.setVariable(c,q);var s=this.evaluator.evalExpression(this.funExpr);if(isNaN(s))u=!1;else{this.evaluator.setVariable(f,s);if(0<this.evaluator.evalExpression(this.drawif)&&
a.rangeOK){if(g){var w=Math.min(p,s),v=Math.max(p,s),v=new a.R2(w,v),w=this.Singularity(r,c,0,q-r,p,q,s,v);0===w?(p<=s?(p=v.x,s=v.y):(s=v.x,p=v.y),w=this.of_y?this.XX(e,p,this.abs_coord):this.YY(e,p,this.abs_coord),p=this.abs_coord?Math.round(s):this.of_y?this.XX(e,s,this.abs_coord):this.YY(e,s,this.abs_coord),this.fillM&&p>m&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(m+1,this.space.h-l+0.5),b.lineTo(p,this.space.h-l+0.5)):(b.moveTo(l+0.5,m+1),b.lineTo(l+
0.5,p)),b.stroke()),this.fillP&&p<m&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(m-1,this.space.h-l+0.5),b.lineTo(p,this.space.h-l+0.5)):(b.moveTo(l+0.5,m-1),b.lineTo(l+0.5,p)),b.stroke()),b.lineWidth=e,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(w+0.5,this.space.h-k),b.lineTo(p+0.5,this.space.h-l)):(b.moveTo(k+0.5,w),b.lineTo(l+0.5,p)),b.stroke()):(1===w&&(this.evaluator.setVariable(c,q-r),k=this.extrapolate(n,c,f,0,p,r),this.YY(e,
k.y,this.abs_coord),this.evaluator.setVariable(c,q),k=this.extrapolate(n,c,f,0,s,-r),this.YY(e,k.y,this.abs_coord)),this.YY(e,s,this.abs_coord))}else k=this.extrapolateOnSingularity(n,c,f,0,s,-r),this.YY(e,k.y,this.abs_coord),this.YY(e,s,this.abs_coord);p=s}else u=!1;g&&!u&&(this.evaluator.setVariable(c,q-r),this.evaluator.setVariable(f,p),k=this.extrapolate(n,c,f,0,p,r),this.YY(e,k.y,this.abs_coord),this.evaluator.setVariable(c,q))}g=u;q+=r;k=l++}this.evaluator.parser.setVariable("x",h);this.evaluator.parser.setVariable("y",
d)};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,d){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,d);(this.visible=2==this.parent.version&&void 0==this.visible?!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);var k,g,b,c,f,h,d,r,l,m,t;a.Curve.prototype.update=function(){k=this.evaluator;g=k.evalExpression(this.parameter_interval);this.paraInf=g[0][0];this.paraSup=g[0][1];this.pSteps=k.evalExpression(this.parameter_steps);this.paraSep=0<this.pSteps?Math.abs(this.paraSup-
this.paraInf)/this.pSteps:0};a.Curve.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Curve.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Curve.prototype.drawAux=function(g,u,p){k=this.evaluator;b=this.space;c=e(k.evalExpression(this.width));g.lineWidth=0<c?c:1E-6;g.lineCap="round";g.lineJoin="round";g.strokeStyle=p.getColor();f=k.getVariable(this.parameter);g.beginPath();k.setVariable(this.parameter,this.paraInf);h=k.evalExpression(this.expresion);
this.exprX=this.abs_coord?e(h[0][0]):e(b.getAbsoluteX(h[0][0]));this.exprY=this.abs_coord?e(h[0][1]):e(b.getAbsoluteY(h[0][1]));this.rotateExp&&(d=a.degToRad(k.evalExpression(this.rotateExp)),r=Math.cos(d),l=Math.sin(d),m=this.exprX*r-this.exprY*l,t=this.exprX*l+this.exprY*r,this.exprX=m,this.exprY=t);g.moveTo(this.exprX+0.5,this.exprY+0.5);for(p=1;p<=this.pSteps;p++)k.setVariable(this.parameter,this.paraInf+p*this.paraSep),h=k.evalExpression(this.expresion),this.exprX=this.abs_coord?e(h[0][0]):e(b.getAbsoluteX(h[0][0])),
this.exprY=this.abs_coord?e(h[0][1]):e(b.getAbsoluteY(h[0][1])),this.rotateExp&&(m=this.exprX*r-this.exprY*l,t=this.exprX*l+this.exprY*r,this.exprX=m,this.exprY=t),g.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&(g.fillStyle=u.getColor(),g.fill());g.stroke();k.setVariable(this.parameter,f)};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,k=Math.round,g,b,c,f,h,d,r,l,m,t,q,u,p;a.Sequence=function(b,d){this.size=b.evaluator.parser.parse("2");this.range=b.evaluator.parser.parse("[1, 100]");a.Graphic.call(this,b,d)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){g=this.evaluator;c=g.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&
(f=a.degToRad(g.evalExpression(this.rotateExp)),h=Math.cos(f),d=Math.sin(f),r=this.exprX*h-this.exprY*d,l=this.exprX*d+this.exprY*h,this.exprX=r,this.exprY=l);q=g.evalExpression(this.range);this.rangeInf=q[0][0];this.rangeMax=q[0][1]};a.Sequence.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Sequence.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Sequence.prototype.drawAux=function(a,d){g=this.evaluator;b=this.space;u=Math.ceil(g.evalExpression(this.size)-
0.4);a.fillStyle=d.getColor();a.beginPath();this.rangeInf>this.rangeMax&&(p=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=p);for(var f=g.getVariable("n"),h=this.rangeInf,l=this.rangeMax;h<=l;h++)g.setVariable("n",h),c=g.evalExpression(this.expresion),this.exprX=c[0][0],this.exprY=c[0][1],m=this.abs_coord?k(this.exprX):k(b.getAbsoluteX(this.exprX)),t=this.abs_coord?k(this.exprY):k(b.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(m,t,u,0,e,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,
a,this.text,m+u,t-u,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0);g.setVariable("n",f)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,k=Math.round,g,b,c,f,h,d,r,l,m,t,q,u;a.Point=function(b,d){this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,d)};a.extend(a.Point,a.Graphic);a.Point.prototype.update=function(){g=this.evaluator;c=g.evalExpression(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&
(f=a.degToRad(g.evalExpression(this.rotateExp)),h=Math.cos(f),d=Math.sin(f),r=this.exprX*h-this.exprY*d,l=this.exprX*d+this.exprY*h,this.exprX=r,this.exprY=l)};a.Point.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Point.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Point.prototype.drawAux=function(a,d){g=this.evaluator;b=this.space;q=k(g.evalExpression(this.size));u=q+1;a.fillStyle=d.getColor();m=this.abs_coord?k(this.exprX):
k(b.getAbsoluteX(this.exprX));t=this.abs_coord?k(this.exprY):k(b.getAbsoluteY(this.exprY));a.beginPath();a.arc(m,t,q,0,e,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,m+u+1,t-u,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,k=2*Math.PI,g,b,c,f,h,d,r,l,m,t,q,u,p,v,n,s,w,z;a.Segment=function(b,d){this.width=b.evaluator.parser.parse("1");this.size=
b.evaluator.parser.parse("2");a.Graphic.call(this,b,d)};a.extend(a.Segment,a.Graphic);a.Segment.prototype.update=function(){g=this.evaluator;c=g.evalExpression(this.expresion);this.endPoints=[];for(var b=0,n=c.length;b<n;b++)this.endPoints[b]={x:c[b][0],y:c[b][1]};if(this.rotateExp){f=a.degToRad(g.evalExpression(this.rotateExp));h=Math.cos(f);d=Math.sin(f);b=0;for(n=this.endPoints.length;b<n;b++)r=this.endPoints[b].x*h-this.endPoints[b].y*d,l=this.endPoints[b].x*d+this.endPoints[b].y*h,this.endPoints[b].x=
r,this.endPoints[b].y=l}};a.Segment.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Segment.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Segment.prototype.drawAux=function(a,d,c){g=this.evaluator;b=this.space;m=e(g.evalExpression(this.width));a.lineWidth=0<m?m:1E-6;p=g.evalExpression(this.size);0>p&&(p=0);a.fillStyle=d.getColor();a.strokeStyle=c.getColor();a.lineCap="round";t=10+a.lineWidth;v=0==a.lineWidth%2?0:0.5;this.abs_coord?
(n=e(this.endPoints[0].x),s=e(this.endPoints[0].y),w=e(this.endPoints[1].x),z=e(this.endPoints[1].y)):(n=e(b.getAbsoluteX(this.endPoints[0].x)),s=e(b.getAbsoluteY(this.endPoints[0].y)),w=e(b.getAbsoluteX(this.endPoints[1].x)),z=e(b.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(n+v,s+v);a.lineTo(w+v,z+v);a.stroke();a.beginPath();a.arc(n,s,p,0,k,!0);a.arc(w,z,p,0,k,!0);a.fill();this.text!=[""]&&(q=parseInt((n+w)/2)-3,u=parseInt((s+z)/2)+3,this.uber.drawText.call(this,a,this.text,q+t,u-
t,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,k=Math.round,g,b,c,f,h,d,r,l,m,t,q,u,p,v,n,s,w,z;a.Arrow=function(b,d){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,d)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){g=
this.evaluator;b=g.evalExpression(this.expresion);this.endPoints=[];for(var n=0,e=b.length;n<e;n++)this.endPoints[n]={x:b[n][0],y:b[n][1]};if(this.rotateExp){c=a.degToRad(g.evalExpression(this.rotateExp));f=Math.cos(c);h=Math.sin(c);n=0;for(e=this.endPoints.length;n<e;n++)d=this.endPoints[n].x*f-this.endPoints[n].y*h,r=this.endPoints[n].x*h+this.endPoints[n].y*f,this.endPoints[n].x=d,this.endPoints[n].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,d,c){g=this.evaluator;l=this.space;g.evalExpression(this.size);q=g.evalExpression(this.width);0>q&&(q=0);u=Math.ceil(q/2);p=l.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=d.getColor();b.strokeStyle=c.getColor();b.lineWidth=2;this.abs_coord?
(n=k(this.endPoints[0].x),s=k(this.endPoints[0].y),w=k(this.endPoints[1].x),z=k(this.endPoints[1].y)):(n=k(l.getAbsoluteX(this.endPoints[0].x)),s=k(l.getAbsoluteY(this.endPoints[0].y)),w=k(l.getAbsoluteX(this.endPoints[1].x)),z=k(l.getAbsoluteY(this.endPoints[1].y)));d=g.evalExpression(this.spear);0>d&&(d=0);b.save();b.translate(n,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*=p,0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&
0<=this.vect.y?b.rotate(-this.angle):b.rotate(this.angle));b.beginPath();b.moveTo(-u,e(-u));b.lineTo(e(v-d-q),e(-u));b.lineTo(e(v-2*d),e(-d-u));b.lineTo(e(v),0);b.lineTo(e(v-2*d),e(d+u));b.lineTo(e(v-d-q),e(u));b.lineTo(-u,e(u));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(m=parseInt((n+w)/2)-3,t=parseInt((s+z)/2)+3,this.uber.drawText.call(this,b,this.text,m,t,c,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var e=Math.round,k,g,b,c,f,h,d,r,l,m,t,q;a.Polygon=function(b,d){this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,d);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){k=this.evaluator;b=k.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){c=a.degToRad(k.evalExpression(this.rotateExp));f=Math.cos(c);h=Math.sin(c);e=0;for(g=this.endPoints.length;e<
g;e++)d=this.endPoints[e].x*f-this.endPoints[e].y*h,r=this.endPoints[e].x*h+this.endPoints[e].y*f,this.endPoints[e].x=d,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,d){k=this.evaluator;g=this.space;l=e(k.evalExpression(this.width));a.lineWidth=0<l?l:1E-6;a.strokeStyle=d.getColor();a.lineCap="round";a.lineJoin=
"round";m=0<l?0.5:0;t=this.abs_coord?e(this.endPoints[0].x):e(g.getAbsoluteX(this.endPoints[0].x));q=this.abs_coord?e(this.endPoints[0].y):e(g.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(t+m,q+m);d=1;for(var c=this.endPoints.length;d<c;d++)t=this.abs_coord?e(this.endPoints[d].x):e(g.getAbsoluteX(this.endPoints[d].x)),q=this.abs_coord?e(this.endPoints[d].y):e(g.getAbsoluteY(this.endPoints[d].y)),a.lineTo(t+m,q+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,k,g,b,c,f,h,d,r,l,m,t,q,u,p,v,n,s,w,z,C,y;a.Arc=function(b,d){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,d)};a.extend(a.Arc,a.Graphic);a.Arc.prototype.update=function(){k=this.evaluator;g=k.evalExpression(this.center);this.exprX=g[0][0];
this.exprY=g[0][1];this.rotateExp&&(b=a.degToRad(k.evalExpression(this.rotateExp)),c=Math.cos(b),f=Math.sin(b),h=this.exprX*c-this.exprY*f,d=this.exprX*f+this.exprY*c,this.exprX=h,this.exprY=d);var n=k.evalExpression(this.init),e=k.evalExpression(this.end);"(expr)"==this.init.type&&"(expr)"==this.end.type||"[expr]"==this.init.type&&"[expr]"==this.end.type||"(expr)"==this.init.type&&"[expr]"==this.end.type||"[expr]"==this.init.type&&"(expr)"==this.end.type?(r=n[0][0],l=n[0][1],m=e[0][0],t=e[0][1],
this.vectors?this.abs_coord&&(l=-l,t=-t):this.abs_coord?(r-=this.exprX,l=-l+this.exprY,m-=this.exprX,t=-t+this.exprY):(r-=this.exprX,l-=this.exprY,m-=this.exprX,t-=this.exprY),q=Math.acos((1*r+0*l)/Math.sqrt(r*r+l*l)),u=Math.acos((1*m+0*t)/Math.sqrt(m*m+t*t)),0<r&&(0<l&&this.abs_coord)&&(q=2*Math.PI-q),0<r&&(0>l&&!this.abs_coord)&&(q=2*Math.PI-q),0>r&&(0>l&&!this.abs_coord)&&(q=2*Math.PI-q),0>r&&(0<l&&this.abs_coord)&&(q=2*Math.PI-q),0<m&&(0<t&&this.abs_coord)&&(u=2*Math.PI-u),0<m&&(0>t&&!this.abs_coord)&&
(u=2*Math.PI-u),0>m&&(0>t&&!this.abs_coord)&&(u=2*Math.PI-u),0>m&&(0<t&&this.abs_coord)&&(u=2*Math.PI-u),p=Math.min(q,u),v=Math.max(q,u),q=p,u=v,u-q>Math.PI&&this.abs_coord&&(q=v,u=p),u-q<=Math.PI&&!this.abs_coord&&(q=v,u=p),this.iniAng=q,this.endAng=u,this.drawPoints=!0):(this.iniAng=a.degToRad(n),this.endAng=a.degToRad(e),this.drawAngle=!0)};a.Arc.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Arc.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,
this.trace)};a.Arc.prototype.drawAux=function(a,b,d){k=this.evaluator;n=this.space;z=k.evalExpression(this.radius);0>z&&(z=0);y=e(k.evalExpression(this.width));a.lineWidth=0<y?y:1E-6;a.lineCap="round";a.strokeStyle=d.getColor();this.drawAngle?(this.abs_coord?(s=e(this.exprX),w=e(this.exprY)):(s=e(n.getAbsoluteX(this.exprX)),w=e(n.getAbsoluteY(this.exprY)),z*=n.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&(C=this.iniAng,this.iniAng=this.endAng,this.endAng=C)):this.drawPoints&&
(this.abs_coord?(s=e(this.exprX),w=e(this.exprY)):(s=e(n.getAbsoluteX(this.exprX)),w=e(n.getAbsoluteY(this.exprY)),z*=n.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng));this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(s,w),a.arc(s,w,z,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();a.arc(s,w,z,this.iniAng,this.endAng,void 0);a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,s+4,w-2,this.color,this.font,"start","alphabetic",k.evalExpression(this.decimals),
this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f,h,d,r,l,m,t,q,u,p,v,n,s;a.Text=function(b,d){this.width=b.evaluator.parser.parse("0");a.Graphic.call(this,b,d);this.align||(this.align="start");this.ascent=this.fontSize-Math.ceil(this.fontSize/7)-(this.font.match("Courier")?3:0);this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){e=this.evaluator;k=e.evalExpression(this.expresion);this.exprX=k[0][0];this.exprY=k[0][1];
this.rotateExp&&(g=a.degToRad(e.evalExpression(this.rotateExp)),b=Math.cos(g),c=Math.sin(g),f=this.exprX*b-this.exprY*c,h=this.exprX*c+this.exprY*b,this.exprX=f,this.exprY=h)};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;d=e.evalExpression(this.width);m=[];this.ctx.font=this.font;if(20<=d&&"undefined"!=a.type){for(var b=0,c=a.length;b<c;b++)r=a[b],l=this.ctx.measureText(r).width,l>d?m=m.concat(this.splitWords(r,d)):m.push(r);t=Math.floor(1.2*this.fontSize)*m.length;e.setVariable("_Text_H_",
t);return m}e.setVariable("_Text_H_",0);e.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=function(a,b){q=a;u=[];p="";n=0;for(var d,c=0,f=a.length;c<f;c++)v=q.charAt(c)," "===v&&(lastIndexOfWhite=c),p+=v,Math.round(this.ctx.measureText(p).width)>b&&(d=a.substring(n,c+1)," "!==v&&(-1===d.indexOf(" ")?(lastIndexOfWhite=c,c--):c=lastIndexOfWhite),u.push(a.substring(n,lastIndexOfWhite)),p="",n=c+1);u.push(a.substring(n));return u};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e=Math.round,k,g,b,c,f,h,d,r,l,m,t,q,u,p;a.Image=function(b,d){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,b,d);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);a.Image.prototype.update=function(){k=this.evaluator;g=k.evalExpression(this.expresion);this.exprX=g[0][0];this.exprY=g[0][1];this.rotateExp&&(b=a.degToRad(k.evalExpression(this.rotateExp)),c=Math.cos(b),f=Math.sin(b),h=this.exprX*c-this.exprY*f,d=this.exprX*f+this.exprY*
c,this.exprX=h,this.exprY=d);4==g[0].length&&(this.centered=!0,this.scaleX=g[0][2],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=g[0][3],0==this.scaleY&&(this.scaleY=1E-5));g[1]&&2==g[1].length&&(this.centered=!0,this.scaleX=g[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=g[1][1],0==this.scaleY&&(this.scaleY=1E-5));if((r=k.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){k=this.evaluator;l=this.space;this.img&&(this.img.ready&&this.img.complete)&&(m=this.centered?0:this.img.width/2,t=this.centered?0:this.img.height/2,q=this.abs_coord?e(this.exprX):e(l.getAbsoluteX(this.exprX)),u=this.abs_coord?e(this.exprY):e(l.getAbsoluteY(this.exprY)),p=a.degToRad(-k.evalExpression(this.inirot)),b.translate(q+m,u+t),b.rotate(p),b.scale(this.scaleX,this.scaleY),this.opacity&&(b.globalAlpha=k.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){d=4*(b+c*a.width);return{r:a.data[d],g:a.data[d+1],b:a.data[d+2],a:a.data[d+3]}}if(a.loadLib)return a;var k,g,b,c,f,h,d;a.Fill=function(b,d){a.Graphic.call(this,b,d)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){k=this.evaluator.evalExpression(this.expresion);this.exprX=k[0][0];this.exprY=k[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,l){l.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(g=parseInt(this.exprX),b=parseInt(this.exprY)):(g=parseInt(this.space.getAbsoluteX(this.exprX)),b=parseInt(this.space.getAbsoluteY(this.exprY)));if(!(0>g||0>b||g>=this.space.w||b>=this.space.h)){c=[{x:g,y:b}];for(h=e(imageData,g,b);0<c.length;){f=c.pop();g=f.x;b=f.y;var m=e(imageData,g,b);if(h.r===m.r&&h.g===
m.g&&h.b===m.b&&h.a===m.a){var m=imageData,k=l;d=4*(g+b*m.width);m.data[d+0]=k.r;m.data[d+1]=k.g;m.data[d+2]=k.b;m.data[d+3]=255-k.a;0<g&&c.push({x:g-1,y:b});g<imageData.width-1&&c.push({x:g+1,y:b});c.push({x:g,y:b-1});c.push({x:g,y:b+1})}}this.ctx.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a,e){if(a.loadLib)return a;var k=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g;a.Macro=function(g,b){this.expresion=void 0;this.inirot=g.evaluator.parser.parse("0");
a.Graphic.call(this,g,b);for(var c in b)b.hasOwnProperty(c)&&(this[c]=b[c]);this.graphics=[];c=g.lessonParser;var f=new a.Tokenizer;if(void 0!=this.expresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var h=this.evaluator.evalExpression(this.expresion),d;h&&((d=document.getElementById(h))&&"descartes/macro"==d.type?d=d.text:(d=a.openExternalFile(h))&&!d.match(/tipo_de_macro/g)&&(d=null));var r,l;if(d){l=d.replace(/&aacute;/g,
"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&amp;/g,"&").replace(/\r/g,"").split("\n");d=[];for(var h=0,m=l.length;h<m;h++)r=l[h].indexOf("="),-1!==r&&
(r=l[h].substring(0,r),("id"===e[r]||"type"===e[r])&&d.push(c.split(l[h])));for(var t,q,u,p,h=0,m=d.length;h<m;h++){p=(t=d[h]||[])&&t[0]&&"id"===t[0][0];l=0;for(r=t.length;l<r;l++)if(q=t[l][0].indexOf("."),-1!==q&&!p?(q=e[t[l][0].substring(q+1)],t[l][0]=this.name+"."+t[l][0]):q=e[t[l][0]],!("font"===q||("fill"===q||"color"===q||"arrow"===q)&&"("!==t[l][1].charAt(0)||"file"===q&&t[l][1].match(k)||"id"!==q&&void 0!==e[t[l][1]]))if("text"==q)if(t[l][1].match(/\{\\rtf1/)){q=t[l][1];var v=this;u=function(a,
b){for(var d=f.tokenize(b.replace(/\&squot;/g,"'")),c=0,h=d.length;c<h;c++)"identifier"==d[c].type&&!"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+d[c].value+"-")&&(d[c].value=v.name+"."+d[c].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+f.flatTokens(d)};q=q.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,u);q=q.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,
u);t[l][1]=q}else{u=c.parseText(t[l][1]).textElementsMacros;for(var n=0,s=u.length;n<s;n++){q=f.tokenize(u[n].replace(/\&squot;/g,"'"));for(var w=0,z=q.length;w<z;w++)"identifier"===q[w].type&&!"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+q[w].value+"-")&&(q[w].value=this.name+"."+q[w].value);q=f.flatTokens(q).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");u[n]=
q.substring(1,q.length-1)}t[l][1]=u.join("")}else{q=f.tokenize(t[l][1]);u=0;for(n=q.length;u<n;u++)"identifier"===q[u].type&&!"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+q[u].value+"-")&&(q[u].value=this.name+"."+q[u].value);t[l][1]=f.flatTokens(q)}}h=0;for(m=d.length;h<m;h++)if(d[h][0]){t="";p=!1;l=0;for(r=d[h].length;l<r;l++)"type"===e[d[h][l][0]]&&(t="espacio='"+this.spaceID+"' ",
p=!0),t=t+d[h][l][0]+"='"+d[h][l][1]+"' ";d[h]=t;p?this.graphics.push(c.parseGraphic(d[h],this.abs_coord,this.background,this.inirot)):c.parseAuxiliar(d[h])}}}};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 b=0,c=this.graphics.length;b<c;b++)this.inipos&&(this.graphics[b].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*
this.space.scale,-this.iniPosY*this.space.scale)),this.graphics[b].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,k=Math.sin,g=Math.cos,b,c,f,h,d,r,l,m,t,q,u,p,v,n,s;a.norm3D=function(a){return e(a.x*a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(d){b=a.norm3D(d);if(0===b)return{x:0,y:0,z:0};if(1===b)return{x:d.x,y:d.y,z:d.z};b=1/b;return{x:d.x*b,y:d.y*b,z:d.z*b}};a.dotProduct3D=function(a,b){return a.x*b.x+a.y*b.y+
a.z*b.z};a.crossProduct3D=function(a,b){return{x:a.y*b.z-a.z*b.y,y:a.z*b.x-a.x*b.z,z:a.x*b.y-a.y*b.x}};a.scalarProduct3D=function(a,b){return{x:a.x*b,y:a.y*b,z:a.z*b}};a.subtract3D=function(a,b){return{x:a.x-b.x,y:a.y-b.y,z:a.z-b.z}};a.add3D=function(a,b){return{x:a.x+b.x,y:a.y+b.y,z:a.z+b.z}};a.equals3DEpsilon=function(a,b,d){return Math.abs(a.x-b.x)<=d&&Math.abs(a.y-b.y)<=d&&Math.abs(a.z-b.z)<=d};a.Vector4D=function(a,b,d,c){this.x=a||0;this.y=b||0;this.z=d||0;this.w=c||0};a.Matrix4x4=function(a,
b,d,c,f,h,n,e,g,m,p,l,k,r,q,t){this.a00=a||0;this.a01=b||0;this.a02=d||0;this.a03=c||0;this.a10=f||0;this.a11=h||0;this.a12=n||0;this.a13=e||0;this.a20=g||0;this.a21=m||0;this.a22=p||0;this.a23=l||0;this.a30=k||0;this.a31=r||0;this.a32=q||0;this.a33=t||0};a.Matrix4x4.prototype.setIdentity=function(){this.a00=1;this.a10=this.a03=this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a13=this.a12=0;this.a22=1;this.a32=this.a31=this.a30=this.a23=0;this.a33=1;return this};a.Matrix4x4.prototype.multiplyVector4=
function(b){return new a.Vector4D(b.x*this.a00+b.y*this.a10+b.z*this.a20+b.w*this.a30,b.x*this.a01+b.y*this.a11+b.z*this.a21+b.w*this.a31,b.x*this.a02+b.y*this.a12+b.z*this.a22+b.w*this.a32,b.x*this.a03+b.y*this.a13+b.z*this.a23+b.w*this.a33)};a.Matrix4x4.prototype.translate=function(b){return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a00*b.x+this.a10*b.y+this.a20*b.z+this.a30,this.a01*b.x+this.a11*b.y+this.a21*
b.z+this.a31,this.a02*b.x+this.a12*b.y+this.a22*b.z+this.a32,this.a03*b.x+this.a13*b.y+this.a23*b.z+this.a33)};a.Matrix4x4.prototype.rotateX=function(b){c=k(b);f=g(b);m=this.a10;t=this.a11;q=this.a12;u=this.a13;p=this.a20;v=this.a21;n=this.a22;s=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,m*f+p*c,t*f+v*c,q*f+n*c,u*f+s*c,m*-c+p*f,t*-c+v*f,q*-c+n*f,u*-c+s*f,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){c=k(b);f=g(b);h=this.a00;d=this.a01;r=this.a02;
l=this.a03;p=this.a20;v=this.a21;n=this.a22;s=this.a23;return new a.Matrix4x4(h*f+p*-c,d*f+v*-c,r*f+n*-c,l*f+s*-c,this.a10,this.a11,this.a12,this.a13,h*c+p*f,d*c+v*f,r*c+n*f,l*c+s*f,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(b){c=k(b);f=g(b);h=this.a00;d=this.a01;r=this.a02;l=this.a03;m=this.a10;t=this.a11;q=this.a12;u=this.a13;return new a.Matrix4x4(h*f+m*c,d*f+t*c,r*f+q*c,l*f+u*c,h*-c+m*f,d*-c+t*f,r*-c+q*f,l*-c+u*f,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,f);a.fill();a.stroke()}function k(a,b){a.lineCap=h;a.lineJoin=d;this.frontColor.getColor();this.backColor.getColor();a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);for(var c=1,f=this.newV.length;c<f;c++)a.lineTo(this.newV[c].x,this.newV[c].y);a.closePath();
"color"===this.model?(a.fillStyle=0<=this.direction?this.backColor.getColor():this.frontColor.getColor(),a.fill()):"light"===this.model||"metal"===this.model?(a.fillStyle=0<=this.direction?b.computeColor(this.backColor,this,"metal"===this.model):b.computeColor(this.frontColor,this,"metal"===this.model),a.fill()):"wire"===this.model&&(a.lineWidth=1.25,a.strokeStyle=this.frontColor.getColor(),a.stroke());this.edges&&"wire"!==this.model&&(a.lineWidth=1,a.strokeStyle="#808080",a.stroke())}function g(a){u=
this.evaluator.getVariable(this.family);this.evaluator.setVariable(this.family,this.familyValue);this.drawText(a,this.text,this.newV[0].x,this.newV[0].y+this.displace,this.frontColor.getColor(),this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,u)}function b(a){a.lineCap=h;a.lineJoin=d;a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor.getColor();a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);a.lineTo(this.newV[1].x,this.newV[1].y);a.stroke()}
function c(b,d,c){r=a.subtract3D(b,d);l=a.subtract3D(b,c);return a.normalize3D(a.crossProduct3D(r,l))}if(a.loadLib)return a;var f=2*Math.PI,h="round",d="round",r,l,m,t,q,u;a.Primitive3D=function(a){for(var d in a)a.hasOwnProperty(d)&&(this[d]=a[d]);this.newV=[];"vertex"===this.type?this.draw=e:"face"===this.type?(this.normal=c(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=k):"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,
this.draw=g):"edge"===this.type&&(this.draw=b);this.isText&&(this.computeDepth=function(){this.newV=this.vertices;this.depth=this.vertices[0].z})};a.Primitive3D.prototype.computeDepth=function(b){this.average={x:0,y:0,z:0};for(var d=0,f=this.vertices.length;d<f;d++)this.newV[d]=b.rotateVertex(this.vertices[d]),this.average.x+=this.newV[d].x,this.average.y+=this.newV[d].y,this.average.z+=this.newV[d].z;this.average=a.scalarProduct3D(this.average,1/f);2<this.vertices.length&&(this.normal=c(this.newV[0],
this.newV[1],this.newV[2]),this.direction=a.dotProduct3D(this.normal,a.normalize3D(b.eye)));d=this.depth=0;for(f=this.vertices.length;d<f;d++)this.newV[d]=b.project(this.newV[d]),this.depth+=this.newV[d].z;this.depth/=f};a.Primitive3D.prototype.drawText=function(b,d,c,f,h,e,g,l,k,r,u){if("rtfNode"==d.type)b.fillStyle=h,b.strokeStyle=h,b.textBaseline="alphabetic",d.draw(b,c,f,k,r,g,u);else{"simpleText"===d.type&&(d=d.toString(k,r).split("\\n"));c+=e.match("Arial")?-2:e.match("Times")?-2:0;m=this.evaluator;
b.fillStyle=a.getColor(m,h);b.font=e;b.textAlign=g;b.textBaseline=l;t=1.2*this.fontSize||0;h=0;for(e=d.length;h<e;h++)q=d[h],this.border&&b.strokeText(q,c,f+t*h),b.fillText(q,c,f+t*h)}};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){for(var d=null,c=null,f=0,h=0,e=0,g=b.vertices.length;e<g;e++){var m=this.intersection(b.vertices[e],b.vertices[(e+1)%g]);if(null!==m)if(null===d){if(d=m,f=e,2===b.vertices.length){c=d;break}}else if(!a.equals3DEpsilon(m,d,1E-8)){c=m;h=e;break}}if(null!==
d&&null!==c){var e=this.isInterior(d)||this.isInterior(c),l=null,k=null;if(!e&&3<=b.vertices.length)for(var g=0,r=this.vertices.length;g<r;g++)if(m=b.intersection(this.vertices[g],this.vertices[(g+1)%r]),null!==m)if(null===l)l=m;else if(!a.equals3DEpsilon(m,l,1E-8)){k=m;break}if(e||null!==l&&null!==k&&b.isInterior(l)&&b.isInterior(k)){k=!0;r=b.vertices;l=m=null;if(2===r.length)a.equals(d,r[0],1E-8)||a.equals(d,r[1],1E-8)?k=!1:(m=[],m[0]=r[0],m[1]=d,l=[],l[0]=d,l[1]=r[1]);else for(var m=[],l=[],q=
0,e=g=0;e<r.length;e++)e<f?m[q++]=r[e]:e==f?(m[q++]=r[e],m[q++]=d,l[g++]=d):e<h?l[g++]=r[e]:e==h?(l[g++]=r[e],l[g++]=c,m[q++]=c):m[q++]=r[e];if(k)return d=[],d[0]=new a.Primitive3D({vertices:m,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model}),d[0].normal=b.normal,d[1]=new a.Primitive3D({vertices:l,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model}),d[1].normal=b.normal,d}}}return[b]};a.Primitive3D.prototype.intersects=function(a){return this.intersectsPlane(a)&&
a.intersectsPlane(this)};a.Primitive3D.prototype.intersectsPlane=function(b){var d=a.dotProduct3D(b.vertices[0],b.normal),c=a.dotProduct3D(this.vertices[0],b.normal);if(1E-8>Math.abs(d-c))return!0;for(var f=1,h=this.vertices.length;f<h;f++){var e=a.dotProduct3D(this.vertices[f],b.normal);if(1E-8>Math.abs(d-e)||e>d&&c<d||e<d&&c>d)return!0}return!1};a.Primitive3D.prototype.intersection=function(b,d){if(0<this.vertices.length){var c=a.subtract3D(d,b),f=a.dotProduct3D(c,this.normal);if(0!==f&&(f=a.dotProduct3D(a.subtract3D(this.vertices[0],
b),this.normal)/f,-1E-8<f&&1.00000001>f))return a.add3D(b,a.scalarProduct3D(c,f))}return null};a.Primitive3D.prototype.isInterior=function(b){if(0<this.vertices.length)for(var d=0,c=a.subtract3D(this.vertices[0],b),f=0,h=this.vertices.length;f<h;f++){var e=a.subtract3D(this.vertices[(f+1)%h],b),g=a.dotProduct3D(a.crossProduct3D(c,e),this.normal);if(1E-8>Math.abs(g)){if(0>a.dotProduct3D(c,e))break}else{if(0>d&&0<g||0<d&&0>g)return!1;c=e;d=g}}return!0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e={x:0,y:0,z:0},k,g,b,c,f,h,d,r;a.Graphic3D=function(b,d){this.parent=b;this.evaluator=b.evaluator;var c=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=c.parse("1");this.abs_coord=!1;this.family="";this.family_interval=c.parse("[0,1]");this.family_steps=c.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;
this.text="";this.decimals=c.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=c.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=c.parse("(0,0,0)");this.model="color";for(var f in d)d.hasOwnProperty(f)&&(this[f]=d[f]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=c.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=c.parse(this.inirot);this.endrot=c.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,d=0,c=a.length;d<c;d++)if(b=a[d],b.id==this.spaceID)return b;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){k=this.evaluator;g=k.evalExpression(this.family_interval);this.familyInf=g[0][0];this.familySup=g[0][1];this.fSteps=Math.round(k.evalExpression(this.family_steps));this.family_sep=
0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){k=this.evaluator;this.getFamilyValues();b=k.getVariable(this.family);if(0<=this.fSteps)for(var a=0,d=this.fSteps;a<=d;a++)k.setVariable(this.family,this.familyInf+a*this.family_sep),this.familyValue=this.familyInf+a*this.family_sep,k.evalExpression(this.drawif)&&this.buildPrimitives();k.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){f=this.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(f[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(f[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(f[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(f[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(f[0][1])),
this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(f[0][2])));f=this.evaluator.evalExpression(this.inipos);e={x:f[0][0],y:f[0][1],z:f[0][2]};this.iniposM=this.iniposM.setIdentity().translate(e);f=this.evaluator.evalExpression(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(f[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(f[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(f[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(f[0][0])),
this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(f[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(f[0][2])));f=this.evaluator.evalExpression(this.endpos);e={x:f[0][0],y:f[0][1],z:f[0][2]};this.endposM=this.endposM.setIdentity().translate(e)};a.Graphic3D.prototype.transformVertex=function(a){this.inirotEuler?c=this.inirotM.multiplyVector4(a):(c=this.inirotM_X.multiplyVector4(a),c=this.inirotM_Y.multiplyVector4(c),c=this.inirotM_Z.multiplyVector4(c));c=this.iniposM.multiplyVector4(c);
this.endrotEuler?c=this.endrotM.multiplyVector4(c):(c=this.endrotM_X.multiplyVector4(c),c=this.endrotM_Y.multiplyVector4(c),c=this.endrotM_Z.multiplyVector4(c));return c=this.endposM.multiplyVector4(c)};a.Graphic3D.prototype.parseExpression=function(){f=this.expresion.split("=");h=f[0];d=[];for(var a=1;a<f.length;a++)h+="=",r=f[a].lastIndexOf(" "),h+=-1!==r?f[a].substring(0,r):f[a],d.push(this.evaluator.parser.parse(h,!0)),h=f[a].substring(r+1);return d};var l;a.Graphic3D.prototype.splitFace=function(a){for(var b=
0,d=this.primitives.length;b<d;b++)if(l=[],"face"===this.primitives[b].type){for(var c=0,f=a.primitives.length;c<f;c++)"face"===a.primitives[c].type?l=l.concat(this.primitives[b].splitFace(a.primitives[c])):l.push(a.primitives[c]);a.primitives=l}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c;a.Point3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();
k=e.evalExpression(this.expresion);g=k[0][0];b=k[0][1];c=k[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(g,b,c,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(g,b,c,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,family:this.family,familyValue:this.familyValue}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f;a.Segment3D=function(b,d){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,d)};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];k=expr[0][1];g=expr[0][2];b=expr[1][0];c=expr[1][1];
f=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,k,g,1)),this.transformVertex(new a.Vector4D(b,c,f,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f,h;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();g=e.getVariable("x");g=e.getVariable("y");g=e.getVariable("z");k=e.getVariable("u");g=e.getVariable("v");e.setVariable("u",0);e.setVariable("v",0);b=e.evalExpression(this.Nu);c=e.evalExpression(this.Nv);f=[];for(var d=0;d<=b;d++){e.setVariable("u",d/b);for(var r=0;r<=c;r++){e.setVariable("v",r/c);for(var l=0,m=this.expresion.length;l<
m;l++)e.evalExpression(this.expresion[l]);f.push(this.transformVertex(new a.Vector4D(e.getVariable("x"),e.getVariable("y"),e.getVariable("z"),1)))}}for(d=0;d<b;d++)for(r=0;r<c;r++)h=[],h.push(f[r+d*c+d]),h.push(f[r+1+d*c+d]),h.push(f[r+2+(d+1)*c+d]),h.push(f[r+1+(d+1)*c+d]),this.primitives.push(new a.Primitive3D({vertices:h,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",
k);e.setVariable("v",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f;a.Polygon3D=function(b,d){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,d)};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);for(var h=0,d=expr.length-1;h<d;h++)e=expr[h][0],k=expr[h][1],g=expr[h][2],b=expr[h+1][0],c=expr[h+1][1],f=expr[h+1][2],
this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,k,g,1)),this.transformVertex(new a.Vector4D(b,c,f,1))],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f;a.Curve3D=function(b,d){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,d);this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=
function(){evaluator=this.evaluator;this.updateMVMatrix();b=evaluator.getVariable("x");c=evaluator.getVariable("y");f=evaluator.getVariable("z");g=evaluator.getVariable("u");evaluator.setVariable("u",0);k=evaluator.evalExpression(this.Nu);e=[];for(var h=0;h<=k;h++){evaluator.setVariable("u",h/k);for(var d=0,r=this.expresion.length;d<r;d++)evaluator.evalExpression(this.expresion[d]);e.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),
1)))}h=0;for(d=e.length-1;h<d;h++)this.primitives.push(new a.Primitive3D({vertices:[e[h],e[h+1]],type:"edge",frontColor:this.color,lineWidth:evaluator.evalExpression(this.width)}));evaluator.setVariable("x",b);evaluator.setVariable("y",f);evaluator.setVariable("z",c);evaluator.setVariable("u",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f,h,d,r;a.Triangle3D=function(b,d){a.Graphic3D.call(this,b,d)};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];k=expr[0][1];g=expr[0][2];b=expr[1][0];c=expr[1][1];f=expr[1][2];h=expr[2][0];d=expr[2][1];r=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,k,g,1)),this.transformVertex(new a.Vector4D(h,d,r,1)),this.transformVertex(new a.Vector4D(b,c,f,1))],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}))};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Face3D=function(e,g){a.Graphic3D.call(this,e,g)};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=[];for(var k=expr.length-1;0<=k;k--)e.push(this.transformVertex(new a.Vector4D(expr[k][0],expr[k][1],expr[k][2],1)));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,k,g,b,c;a.Polireg3D=function(b,c){this.width=b.evaluator.parser.parse("2");this.length=b.evaluator.parser.parse("2");a.Graphic3D.call(this,b,c)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();e=evaluator.evalExpression(this.Nu);k=[this.transformVertex(new a.Vector4D(0,0,0,1))];
g=evaluator.evalExpression(this.width)/2;b=evaluator.evalExpression(this.length)/2;c=2*Math.PI/e;for(var f=0;f<e;f++)k.push(this.transformVertex(new a.Vector4D(g*Math.cos(c*f),b*Math.sin(c*f),0,1)));for(f=0;f<e;f++)this.primitives.push(new a.Primitive3D({vertices:[k[0],f+2<=e?k[f+2]:k[1],k[f+1]],type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b;a.Text3D=function(b,f){a.Graphic3D.call(this,
b,f)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=function(){e=this.evaluator;k=e.evalExpression(this.expresion);g=k[0][0];b=k[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(g,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,family:this.family,familyValue:this.familyValue}))};return a}(descartesJS||{}),descartesJS=function(a){function e(a,
b,d,c,f){k.call(this,a/1.8,a/1.8,a/1.8,c,f)}function k(a,b,d,c,f){a/=2;b/=2;d/=2;this.changeGeometry(a,b,d,c,f)||(this.vertices=[new p(a,d,b,1),new p(a,-d,b,1),new p(a,d,-b,1),new p(a,-d,-b,1),new p(-a,d,b,1),new p(-a,-d,b,1),new p(-a,d,-b,1),new p(-a,-d,-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,d,c,f))}function g(a,b,d,c,f){a/=2;this.changeGeometry(a,b,d,c,f)||(this.vertices=[new p(0,0,a,1),new p(-0.49*a,-0.86*a,-0.32*a,1),new p(-0.49*a,
0.86*a,-0.32*a,1),new p(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,d,c,f))}function b(a,b,d,c,f){a/=2;this.changeGeometry(a,b,d,c,f)||(this.vertices=[new p(0,0,a,1),new p(a,0,0,1),new p(-a,0,0,1),new p(0,a,0,1),new p(0,-a,0,1),new p(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,d,c,f))}function c(b,d,c,f,h){b/=3.4;if(!this.changeGeometry(b,d,c,f,h)){D=b/E;B=b*E;this.vertices=[new p(b,b,b,1),new p(b,
b,-b,1),new p(b,-b,b,1),new p(b,-b,-b,1),new p(-b,b,b,1),new p(-b,b,-b,1),new p(-b,-b,b,1),new p(-b,-b,-b,1),new p(0,D,B,1),new p(0,D,-B,1),new p(0,-D,B,1),new p(0,-D,-B,1),new p(D,B,0,1),new p(D,-B,0,1),new p(-D,B,0,1),new p(-D,-B,0,1),new p(B,0,D,1),new p(B,0,-D,1),new p(-B,0,D,1),new p(-B,0,-D,1)];A=(new a.Matrix4x4).setIdentity().rotateY(-q/6);for(var e=0,n=this.vertices.length;e<n;e++)this.vertices[e]=A.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,d,c,f,h)}}function f(b,d,c,f,h){b/=4;if(!this.changeGeometry(b,d,c,f,h)){B=b*E;this.vertices=[new p(0,b,B,1),new p(0,b,-B,1),new p(0,-b,B,1),new p(0,-b,-B,1),new p(b,B,0,1),new p(b,-B,0,1),new p(-b,B,0,1),new p(-b,-B,0,1),new p(B,0,b,1),new p(B,0,-b,1),new p(-B,0,b,1),new p(-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]];A=(new a.Matrix4x4).setIdentity().rotateY(-1.029);for(var e=0,n=this.vertices.length;e<n;e++)this.vertices[e]=A.multiplyVector4(this.vertices[e]);this.updateValues(b,d,c,f,h)}}function h(a,b,d,c,f){a/=2;this.isSphere?d=b=a:(b/=2,d/=2);if(!this.changeGeometry(a,b,d,c,f)){this.vertices=[new p(0,0,b,1)];for(var h=1;h<c;h++){y=h*q/c;for(var e=0;e<f;e++)C=e*u/f,s=a*m(y)*t(C),w=d*m(y)*
m(C),z=b*t(y),this.vertices.push(new p(s,w,z,1))}this.vertices.push(new p(0,0,-b,1));this.faces=[];for(h=0;h<f;h++)this.faces.push([0,(h+1)%f+1,h%f+1]);for(h=1;h<c-1;h++)for(e=0;e<f;e++)this.faces.push([e+1+(h-1)*f,(e+1)%f+1+(h-1)*f,(e+1)%f+1+h*f,e+1+h*f]);for(h=0;h<f;h++)this.faces.push([this.vertices.length-1,this.vertices.length-1-f+h,this.vertices.length-1-f+(h+1)%f]);this.updateValues(a,b,d,c,f)}}function d(a,b,d,c,f){a/=2;b/=2;d/=2;if(!this.changeGeometry(a,b,d,c,f)){this.vertices=[];for(var h=
0;h<f;h++)for(var e=0;e<c;e++)s=a*(f-h)/f*t(e*u/c),w=d*(f-h)/f*m(e*u/c),z=b-2*h*b/f,this.vertices.push(new p(s,w,z,1));this.vertices.push(new p(0,0,-b,1));this.faces=[];for(h=0;h<f-1;h++)for(e=0;e<c;e++)this.faces.push([e+h*c,(e+1)%c+h*c,(e+1)%c+(h+1)*c,e+(h+1)*c]);for(h=0;h<c;h++)this.faces.push([this.vertices.length-1,this.vertices.length-1-c+h,this.vertices.length-1-c+(h+1)%c]);this.updateValues(a,b,d,c,f)}}function r(a,b,d,c,f){a/=2;b/=2;d/=2;if(!this.changeGeometry(a,b,d,c,f)){this.vertices=
[];for(var h=0;h<f+1;h++)for(var e=0;e<c;e++)s=a*t(e*u/c),w=d*m(e*u/c),z=b-2*h*b/f,this.vertices.push(new p(s,w,z,1));this.faces=[];for(h=0;h<f;h++)for(e=0;e<c;e++)this.faces.push([e+h*c,(e+1)%c+h*c,(e+1)%c+(h+1)*c,e+(h+1)*c]);this.updateValues(a,b,d,c,f)}}function l(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];for(var d=0,c=this.fileData.length;d<c;d++)H=this.fileData[d],H.match(/^V\(/)?(G=H.substring(2,H.length-1).split(",").map(b),this.vertices.push(new p(G[0]||
0,G[1]||0,G[2]||0,1))):H.match(/^F\(/)&&(G=H.substring(2,H.length-1).split(",").map(a),this.faces.push(G.reverse()))}if(a.loadLib)return a;var m=Math.sin,t=Math.cos,q=Math.PI,u=2*q,p,v,n,s,w,z,C,y,E=1.6180339887,D,B,A,H,G;a.OtherGeometry=function(n,m){this.width=n.evaluator.parser.parse("2");this.height=n.evaluator.parser.parse("2");this.length=n.evaluator.parser.parse("2");p=a.Vector4D;a.Graphic3D.call(this,n,m);switch(this.type){case "cube":this.buildGeometry=e;break;case "box":this.buildGeometry=
k;break;case "tetrahedron":this.buildGeometry=g;break;case "octahedron":this.buildGeometry=b;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=h;break;case "dodecahedron":this.buildGeometry=c;break;case "icosahedron":this.buildGeometry=f;break;case "cone":this.buildGeometry=d;break;case "cylinder":this.buildGeometry=r;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=l}};a.extend(a.OtherGeometry,a.Graphic3D);
a.OtherGeometry.prototype.buildPrimitives=function(){v=this.evaluator;this.updateMVMatrix();this.buildGeometry(v.evalExpression(this.width),v.evalExpression(this.height),v.evalExpression(this.length),v.evalExpression(this.Nu),v.evalExpression(this.Nv));for(var b=0,d=this.faces.length;b<d;b++){n=[];for(var c=0,f=this.faces[b].length;c<f;c++)n.push(this.transformVertex(this.vertices[this.faces[b][c]]));this.primitives.push(new a.Primitive3D({vertices:n,type:"face",frontColor:this.color,backColor:this.backcolor,
edges:this.edges,model:this.model}))}};a.OtherGeometry.prototype.changeGeometry=function(a,b,d,c,f){return this.oldWidth===a&&this.oldHeight===b&&this.oldLength===d&&this.oldNu===c&&this.oldNv===f};a.OtherGeometry.prototype.updateValues=function(a,b,d,c,f){this.oldWidth=a;this.oldHeight=b;this.oldLength=d;this.oldNv=f;this.oldNu=c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.max,k=Math.min,g=Math.PI,b=Math.cos,c=Math.sin,f=Math.abs,h,d,r,l,m,t,q,u,p,v,n,s,w,
z,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(k(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(e(k(this.y,32E3),-32E3))};a.R2.prototype.equals=function(a){return this.x==a.x&&this.y==a.y};a.R2.prototype.norm2=function(){return this.x*this.x+this.y*this.y};a.R2.prototype.norm=function(){return Math.sqrt(this.norm2())};
a.R2.prototype.distance=function(a){d=this.copy();d.sub(a);return d.norm()};a.R2.prototype.dot=function(a){return this.x*a.x+this.y*a.y};a.R2.prototype.det=function(a){return this.x*a.y-this.y*a.x};a.R2.prototype.mul=function(a){this.x*=a;this.y*=a};a.R2.prototype.div=function(a){this.x/=a;this.y/=a};a.R2.prototype.add=function(a){this.x+=a.x;this.y+=a.y};a.R2.prototype.sub=function(a){this.x-=a.x;this.y-=a.y};a.R2.prototype.normalize=function(){h=this.norm();0!=h&&this.div(h)};a.R2.prototype.rotR90=
function(){h=this.x;this.x=this.y;this.y=-h};a.R2.prototype.rotL90=function(){h=this.x;this.x=-this.y;this.y=h};a.R2.prototype.rot=function(a){r=this.copy();t=b(a);q=c(a);this.x=r.x*t-r.y*q;this.y=r.x*q+r.y*t};a.R2.prototype.rot=function(a){this.rot(a*g/180)};a.R2.prototype.intersection=function(b,d,c,h){u=d.x-b.x;p=c.x-h.x;v=c.x-b.x;n=d.y-b.y;s=c.y-h.y;w=c.y-b.y;D=u*s-p*n;return 1E-6<f(D)?(l=(v*s-w*p)/D,m=(-v*n+w*u)/D,0<=l&&1>=l&&0<=m&&1>=m?new a.R2(b.x+u*l,b.y+n*l):null):(d.x-c.x)*w!=(d.y-c.y)*
v?null:b.x!=d.x?(z=k(b.x,d.x),C=e(b.x,d.x),z<=c.x&&c.x<=C?c:z<=h.x&&h.x<=C?h:null):c.x!=h.x?(y=k(c.x,h.x),E=e(c.x,h.x),y<=b.x&&b.x<=E?b:y<=d.x&&d.x<=E?d:null):b.y!=d.y?(z=k(b.y,d.y),C=e(b.y,d.y),z<=c.y&&c.y<=C?c:z<=h.y&&h.y<=C?h:null):c.y!=h.y?(y=k(c.y,h.y),E=e(c.y,h.y),y<=b.y&&b.y<=E?b:y<=d.y&&d.y<=E?d:null):b.x==c.x&&b.y==c.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f,h,d;a.R2Newton=function(b,d){this.evaluator=b;this.constraint=d;if("=="==this.constraint.value||
"<"==this.constraint.value||"<="==this.constraint.value||">"==this.constraint.value||">="==this.constraint.value)this.sign="<"==this.constraint.value||"<="==this.constraint.value?"menor":">"==this.constraint.value||">="==this.constraint.value?"mayor":"igual",this.constraint=this.constraint.equalToMinus(),this.constraint=this.constraint.childs[0];f=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return this.normal.copy()};a.R2Newton.prototype.gradient=function(a){e=
this.evaluator;h=e.getVariable("x");d=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);k=e.evalExpression(this.constraint);f.x=(k-this.f0)/1E-12;f.x=!isNaN(f.x)?f.x:Infinity;e.setVariable("x",e.getVariable("x")-1E-12);e.setVariable("y",e.getVariable("y")+1E-12);k=e.evalExpression(this.constraint);f.y=(k-this.f0)/1E-12;f.y=!isNaN(f.y)?f.y:Infinity;e.setVariable("x",h);e.setVariable("y",d);return f};
a.R2Newton.prototype.findZero=function(a){e=this.evaluator;c=a.copy();h=e.getVariable("x");d=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 c;e.setVariable("x",h);e.setVariable("y",d);for(var f=0;256>f;f++)if(g=c.x,b=c.y,this.normal=this.gradient(c),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),c.x=g+this.normal.x,c.y=b+this.normal.y,1E-6>this.normal.norm()){0===
this.normal.x&&0===this.normal.y&&(this.normal.x=c.x-a.x,this.normal.y=c.y-a.y);break}return c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,k){this.x=a;this.y=k};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,k=Math.round,g,b,c,f,h,d,r,l,m,t,q,u,p,v,n,s,w,z,C,y;a.Control=function(b,d){this.parent=b;this.evaluator=b.evaluator;var c=this.parser=b.evaluator.parser;this.id="graphic"!==d.type?"C":"G";this.gui=this.type="";this.region="south";this.y=this.x=0;this.w="video"!==d.type?100:350;this.h="video"!==d.type?23:120;"graphic"!==d.type&&"audio"!==d.type&&"video"!==d.type?"text"!==
d.type?this.expresion=c.parse("(0,0,100,23)"):(this.expresion=c.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=c.parse("(0,0)");this.fixed=2!=this.parent.version?!1:!0;this.visible=!0;this.color=4>this.parent.version?new a.Color("000000"):new a.Color("222222");this.colorInt="graphic"!==d.type?new a.Color("f0f8ff"):new a.Color("cc0022");this.underlined=this.italics=this.bold="";this.font_size=4>this.parent.version?-1:c.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";
this.drawif=c.parse("1");this.activeif=c.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=c.parse("0");this.decimals=c.parse("2");this.min=c.parse("-Infinity");this.max=c.parse("Infinity");this.incr=c.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var f in d)d.hasOwnProperty(f)&&(this[f]=d[f]);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;c=this.evaluator.evalExpression(this.expresion);this.x=k(c[0][0]);this.y=k(c[0][1]);4==c[0].length&&(this.w=k(c[0][2]),this.h=k(c[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 d=0,c=a.length;d<c;d++){if(b=a[d],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(){c=f=h=d=!1;r=this.evaluator.evalExpression(this.expresion);
l=k(r[0][0]);c=k(this.x)!==l;this.x=l;l=k(r[0][1]);f=k(this.y)!==l;this.y=l;4===r[0].length&&(l=k(r[0][2]),h=k(this.w)!==l,this.w=l,l=k(r[0][3]),d=k(this.h)!==l,this.h=l);if(h||d||c||f)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){p=this.parent;m=a+"";t=this.evaluator.evalExpression(this.decimals);q=m.indexOf(".");-1!=q&&(u=m.substring(q+1),u.length>t&&(m=parseFloat(m).toFixed(t)));if(this.fixed&&(2!==p.version||2===p.version&&!this.exponentialif))m=parseFloat(a).toFixed(t);
this.exponentialif&&0!=parseFloat(m)&&(m=this.fixed&&2!==p.version?parseFloat(m).toExponential(t):parseFloat(m).toExponential(),m=m.toUpperCase(),m=m.replace("+",""));return m=m.replace(".",p.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();"init"===this.action&&(this.click=!1);this.actionExec.execute();"animate"!==this.action&&this.parent.update()};a.Control.prototype.createGradient=function(a,d){this.linearGradient=this.ctx.createLinearGradient(0,
0,0,d);g=d*d;for(var c=0;c<d;c++)b=e(c-35*d/100),this.linearGradient.addColorStop(c/d,"rgba(0,0,0,"+192*b*b/g/255+")")};a.Control.prototype.getScreenshot=function(){s=this;v=document.createElement("canvas");v.setAttribute("width",s.w);v.setAttribute("height",s.h);n=v.getContext("2d");n.font=s.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";s.canvas&&(w=s.canvas.offsetLeft,z=s.canvas.offsetTop,n.drawImage(s.canvas,w,z));s.label&&(w=s.label.offsetLeft,z=s.label.offsetTop,C=s.label.offsetWidth,
y=s.label.offsetHeight,n.fillStyle="#e0e4e8",n.fillRect(w,z,C,y),n.fillStyle="black",n.textAlign="center",n.textBaseline="middle",n.fillText(s.name,w+C/2,z+y/2));s.field&&(w=s.field.offsetLeft,z=s.field.offsetTop,C=s.field.offsetWidth,y=s.field.offsetHeight,n.fillStyle="white",n.strokeStyle="#666666",n.lineWidth=1,n.fillRect(w,0,C,y),n.strokeRect(w+0.5,0.5,C-1,y-1),n.fillStyle="black",n.textAlign="center",n.textAlign="left",n.fillText(s.field.value,w+2,y/2));s.select&&(w=s.select.offsetLeft,z=s.select.offsetTop,
C=s.select.offsetWidth,y=s.select.offsetHeight,n.fillStyle="#e0e4e8",n.strokeStyle="#666666",n.lineWidth=1,n.fillRect(w,0,C,y),n.strokeRect(w+0.5,0.5,C,y-1),n.fillStyle="black",n.textAlign="center",n.textAlign="left",n.fillText(s.select.value,w+2,y/2),n.fillStyle="#c0c0c0",n.fillRect(w+C-15+0.5,0.5,15,y-1),n.strokeRect(w+C-15+0.5,0.5,15,y-1),n.fillStyle="black",n.beginPath(),n.moveTo(w+C-15+4.5,y/2-2.5),n.lineTo(w+C-15+8,y/2+2.5),n.lineTo(w+C-15+11.5,y/2-2.5),n.closePath(),n.fill());return v};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,k,g,b,c,f,h,d,r,l,m,t,q,u=900;a.Button=function(b,d){this.imageSrc="";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;a.Control.call(this,b,d);-1===this.font_size&&(this.fontSizeNotSet=!0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");var c;this.imageSrc.match("_COLORES_")&&
(c=this.imageSrc.split("_"),this.colorInt=new a.Color(c[2]),this.color=new a.Color(c[3]),this.font_size=this.parser.parse(c[5]),this.imageSrc="");this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");c=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=c){var f=c.substr(0,c.lastIndexOf(".")),h=c.substr(c.lastIndexOf("."));c.toLowerCase().match(/vacio.gif$/)?(this.imageSrc=this.parser.parse("'vacio.gif'"),this.image.ready=1,3===this.parent.version&&(this.name=this.parser.parse("")),this.emptyImage=
{ready:!0},this.parser.parse("'vacio.gif'")):(this.image=this.parent.getImage(c),this.imageOver=this.parent.getImage(f+"_over"+h),this.imageDown=this.parent.getImage(f+"_down"+h))}this.canvas=document.createElement("canvas");this.canvas.setAttribute("class","DescartesButton");this.canvas.setAttribute("id",this.id);this.canvas.setAttribute("width",this.w+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+
";");this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.ctx.mozImageSmoothingEnabled=!1;this.ctx.webkitImageSmoothingEnabled=!1;this.addControlContainer(this.canvas);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=function(){k=this.evaluator;g=this.canvas;c=k.evalExpression(this.expresion);this.x=c[0][0];this.y=c[0][1];4==c[0].length&&(this.w=parseInt(c[0][2]),this.h=parseInt(c[0][3]));g.setAttribute("width",this.w+"px");
g.setAttribute("height",this.h+"px");g.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+"; display: block;");this.fontSizeNotSet&&(this.font_size=k.parser.parse(a.getFieldFontSize(this.h)+""));this.createGradient(this.w,this.h);g.style.display=0<k.evalExpression(this.drawif)?"block":"none"};a.Button.prototype.update=function(){k=this.evaluator;g=this.canvas;this.activeIfValue=0<k.evalExpression(this.activeif);(this.drawIfValue=0<k.evalExpression(this.drawif))?(g.style.display=
"block",this.draw()):(this.click=!1,g.style.display="none");this.canvas.style.cursor=this.activeIfValue?"pointer":"not-allowed";this.updatePositionAndSize()};a.Button.prototype.draw=function(){k=this.evaluator;b=this.ctx;f=k.evalExpression(this.font_size);h=k.evalExpression(this.name);d=k.evalExpression(this.imageSrc);r="vacio.gif"===d?this.emptyImage:this.parent.getImage(d);b.clearRect(0,0,this.w,this.h);m=l=0;this.click&&(m=l=1);r&&r.ready?r!==this.emptyImage&&r.complete&&b.drawImage(r,parseInt((this.w-
r.width)/2)+l,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.activeIfValue&&(""!=this.imageOver.src&&this.imageOver.ready&&this.over)&&b.drawImage(this.imageOver,parseInt((this.w-r.width)/2)+l,parseInt((this.h-
r.height)/2)+m);this.activeIfValue&&""!=this.imageDown.src&&this.imageDown.ready&&this.click?b.drawImage(this.imageDown,parseInt((this.w-r.width)/2)+l,parseInt((this.h-r.height)/2)+m):this.click&&!r&&(a.drawLine(b,0,0,0,this.h-2,"gray"),a.drawLine(b,0,0,this.w-1,0,"gray"),b.fillStyle="rgba(0, 0, 0,"+24/255+")",b.fillRect(0,0,this.w,this.h));b.fillStyle=this.color.getColor();b.font=this.italics+" "+this.bold+" "+f+"px Arial";b.textAlign="center";b.textBaseline="middle";this.colorInt.getColor()!=this.color.getColor()&&
(b.lineJoin="round",b.lineWidth=parseInt(f/6),b.strokeStyle=this.colorInt.getColor(),b.strokeText(h,e(this.w/2+l)+0.5,e(this.h/2+m)+0.5));b.fillText(h,e(this.w/2+l)+0.5,e(this.h/2+m)+0.5);this.underlined&&(t=b.measureText(h).width,b.strokeStyle=this.color.getColor(),b.lineWidth=e(f/10)||2,b.lineCap="round",b.beginPath(),b.moveTo(parseInt((this.w-t)/2)+l,e((this.h+f)/2)+e(f/5)-1.5+m),b.lineTo(parseInt((this.w+t)/2)+l,e((this.h+f)/2)+e(f/5)-1.5+m),b.stroke());this.activeIfValue||(b.globalCompositeOperation=
"destination-in",b.fillStyle="rgba(240,240,240,"+160/255+")",b.fillRect(0,0,this.w,this.h),b.globalCompositeOperation="source-over")};a.Button.prototype.bottonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function b(a,d,c){clearInterval(g);e.click&&(d.call(e),a=c?a:30,g=setTimeout(function(){b(a,d)},a))}function d(f){f.preventDefault();document.activeElement.blur();e.whichButton=a.whichButton(f);"L"==e.whichButton&&e.activeIfValue&&(e.click=
!0,e.draw(),e.evaluator.setVariable(e.id,e.evaluator.evalExpression(e.valueExpr)),"calculate"==e.action&&b(u,e.bottonPressed,!0),q?window.addEventListener("touchend",c):window.addEventListener("mouseup",c))}function c(a){if(e.activeIfValue||e.click)e.click=!1,e.draw(),"calculate"!=e.action&&e.bottonPressed(),a.preventDefault(),q?window.removeEventListener("touchend",c,!1):window.removeEventListener("mouseup",c,!1)}function f(a){e.over=!0;e.draw()}function h(a){e.over=!1;e.click=!1;e.draw()}q=a.hasTouchSupport;
var e=this,g;e.canvas.oncontextmenu=function(){return!1};this.over=this.click=!1;q?this.canvas.addEventListener("touchstart",d):(this.canvas.addEventListener("mousedown",d),this.canvas.addEventListener("mouseover",f),this.canvas.addEventListener("mouseout",h))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f,h,d,r,l,m,t,q,u,p,v,n;a.Spinner=function(b,d){a.Control.call(this,b,d);this.tabindex=++this.parent.tabindex;
"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);
this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.addControlContainer(this.containerControl);this.originalIncr=this.incr;if(0>=this.evaluator.evalExpression(this.decimals)){var c=this.evaluator.evalExpression(this.incr);0<c?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(c).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;var b=e.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(e.evalExpression(this.valueExpr));var d=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var c=2!==this.parent.version?"":"_____",f=a.getTextWidth(d+"_",this.fieldFontSize+"px Arial"),h=2+parseInt(this.h/2),g=parseInt(this.w/2-h/2),c=a.getTextWidth(b+
c,this.fieldFontSize+"px Arial");this.visible||(g=this.w-h,f=0);g<c&&(g=c);""==b&&(g=0);this.w-g-h<f&&(g=this.w-h-f);0>g&&(g=0);b=this.w-(g+h);this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.setAttribute("id",this.id);this.canvas.setAttribute("width",h+"px");this.canvas.setAttribute("height",this.h+"px");
this.canvas.setAttribute("style","position: absolute; left: "+g+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.divUp.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+h+"px; height : "+this.h/2+"px; left: "+g+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+h+"px; height : "+this.h/2+"px; left: "+g+"px; top: "+this.h/2+"px;");this.field.setAttribute("type",
"text");this.field.setAttribute("id",this.id+"_spinner");this.field.setAttribute("class","DescartesSpinnerField");this.field.setAttribute("style","font-family: Arial; font-size: "+this.fieldFontSize+"px; width : "+(b-2)+"px; height : "+(this.h-2)+"px; left: "+(h+g)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=d;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+g+"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;this.label.innerHTML=e.evalExpression(this.name).toString();0>=e.evalExpression(this.decimals)?(k=e.evalExpression(this.incr),0<k?this.originalIncr=this.incr=e.parser.parse(parseInt(k).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();g=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!=g&&(this.value=this.validateValue(g),this.field.value=this.formatOutputValue(this.value));e.setVariable(this.id,this.value)};a.Spinner.prototype.draw=
function(){c=this.ctx;f=this.canvas.width;h=this.canvas.height;c.fillStyle="#f0f8ff";c.fillRect(0,0,f,h);c.fillStyle=this.linearGradient;c.fillRect(0,0,f,h);this.up?(d="gray",r="#f0f8ff"):(d="#f0f8ff",r="gray");a.drawLine(c,0,0,f,0,d);a.drawLine(c,0,0,0,h/2,d);a.drawLine(c,0,h/2,f,h/2,r);this.down?(d="gray",r="#f0f8ff"):(d="#f0f8ff",r="gray");a.drawLine(c,0,h/2+1,f,h/2+1,d);a.drawLine(c,0,h/2+1,0,h,d);a.drawLine(c,0,h-1,f,h-1,r);l=[parseInt(f/2+1),parseInt(f/5+1),parseInt(f-f/5+1)];m=[parseInt(h/
8+1),parseInt(h/8+1+h/4),parseInt(h/8+1+h/4)];c.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";c.beginPath();c.moveTo(l[0],m[0]);c.lineTo(l[1],m[1]);c.lineTo(l[2],m[2]);c.fill();m=[parseInt(h-h/8),parseInt(h-h/8-h/4),parseInt(h-h/8-h/4)];c.fillStyle=this.activeIfValue?"#d00018":"#aa8888";c.beginPath();c.moveTo(l[0],m[0]);c.lineTo(l[1],m[1]);c.lineTo(l[2],m[2]);c.fill();c.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&c.fillRect(0,0,f,h/2);this.down&&c.fillRect(0,h/2,f,h)};a.Spinner.prototype.validateValue=
function(a){e=this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=a.toString();t=parseFloat(e.evalExpression(e.parser.parse(a.replace(this.parent.decimal_symbol,"."))));isNaN(t)&&(t=0);p=e.evalExpression(this.min);v=e.evalExpression(this.max);""===p&&(p=-Infinity);""===v&&(v=Infinity);t<p&&(t=p);t>v&&(t=v);this.discrete&&(q=e.evalExpression(this.incr),t=0==q?0:q*Math.round(t/q));u=e.evalExpression(this.decimals);0>=u&&(u=0);return t=parseFloat(parseFloat(t).toFixed(u))};
a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.changeValue=function(a){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Spinner.prototype.registerMouseAndTouchEvents=
function(){function b(a,d,c){clearInterval(k);if(m.up||m.down)d.call(m),a=c?a:30,k=setTimeout(function(){b(a,d)},a)}function d(c){c.preventDefault();m.whichButton=a.whichButton(c);"L"==m.whichButton&&m.activeIfValue&&(m.up=!0,b(l,m.increase,!0),m.draw())}function c(d){d.preventDefault();m.whichButton=a.whichButton(d);"L"==m.whichButton&&m.activeIfValue&&(m.down=!0,b(l,m.decrease,!0),m.draw())}function f(a){m.up=!1;clearInterval(k);m.draw();a.preventDefault()}function h(a){m.down=!1;clearInterval(k);
m.draw();a.preventDefault()}function e(a){m.up=!1;clearInterval(k);m.draw();a.preventDefault()}function g(a){m.down=!1;clearInterval(k);m.draw();a.preventDefault()}n=a.hasTouchSupport;var m=this,l=n?500:200,k;m.divUp.oncontextmenu=m.divDown.oncontextmenu=m.field.oncontextmenu=m.label.oncontextmenu=function(){return!1};n?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&&m.changeValue(m.field.value)});n?this.divUp.addEventListener("touchstart",d):this.divUp.addEventListener("mousedown",d);n?this.divDown.addEventListener("touchstart",c):this.divDown.addEventListener("mousedown",c);n||this.divUp.addEventListener("mouseout",f);n||this.divDown.addEventListener("mouseout",h);n?(this.divUp.addEventListener("touchend",e),window.addEventListener("touchend",e)):(this.divUp.addEventListener("mouseup",e),window.addEventListener("mouseup",e));n?(this.divDown.addEventListener("touchend",
g),window.addEventListener("touchend",g)):(this.divDown.addEventListener("mouseup",g),window.addEventListener("mouseup",g))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f,h;a.TextField=function(b,c){a.Control.call(this,b,c);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");void 0===this.valueExprString&&(this.valueExprString=
this.onlyText?"0":"");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;if(this.answer)if(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answerPattern=this.answer,this.answer=a.buildRegularExpresionsPatterns(this.answer,this.evaluator),this.onlyText){var f=this.answerPattern.indexOf("|");this.firstAnswer=-1==f?this.answerPattern:this.answerPattern.substring(0,f)}else this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,
this.answerPattern.indexOf(",")));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.match(/^'/)&&a.match(/'$/)?a.substring(1,a.length-1):a};this.formatOutputValue=function(a){return a.toString()}}""==name.trim()&&(name="");this.containerControl=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");
this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){e=this.evaluator;var b=e.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(e.evalExpression(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var f=a.getTextWidth(c+
"_",this.fieldFontSize+"px Arial"),h=parseInt(this.w/2),g=a.getTextWidth(b,this.fieldFontSize+"px Arial");h<g&&(h=g);""==b&&(h=0);this.w-h<f&&(h=this.w-f);0>h&&(h=0);b=this.w-h;this.containerControl.setAttribute("class","DescartesTextFieldContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"TextField");this.field.setAttribute("class",
"DescartesTextFieldField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(b-2)+"px; height : "+(this.h-2)+"px; left: "+h+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.label.setAttribute("class","DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+h+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.evaluate&&(this.ok=this.evaluateAnswer());this.evaluator.setVariable(this.id,
this.value);this.evaluator.setVariable(this.id+".ok",this.ok);this.oldValue=this.value;this.update()};a.TextField.prototype.update=function(){e=this.evaluator;this.label.innerHTML=e.evalExpression(this.name).toString();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();k=this.field.value;g=this.value;this.value=
this.validateValue(e.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value===g&&this.field.value!=k&&(this.value=this.validateValue(k),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);c=e.evalExpression(this.min);""==c&&(c=
-Math.Infinity);f=e.evalExpression(this.max);""==f&&(f=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(){h=a.hasTouchSupport;var b=
this;b.label.oncontextmenu=function(){return!1};h?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(a){b.changeValue(b.field.value,!0)});this.field.addEventListener("keydown",function(a){b.activeIfValue&&13==a.keyCode&&b.changeValue(b.field.value,!0)})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.abs,k,g,b,
c;a.Menu=function(b,d){this.options="";a.Control.call(this,b,d);var c=this.parser;"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var f,e=0,g=this.options.length;e<g;e++)f=this.options[e].split(/[\[\]]/,2),1==f.length?(this.menuOptions.push(f[0]),this.strValue.push(e.toString())):2==
f.length&&(this.menuOptions.push(f[0]),""==f[1]?this.strValue.push(e.toString()):this.strValue.push(f[1]));e=0;for(g=this.strValue.length;e<g;e++)this.strValue[e]=c.parse(this.strValue[e]);this.containerControl=document.createElement("div");this.label=document.createElement("label");this.select=document.createElement("select");e=0;for(g=this.menuOptions.length;e<g;e++)c=document.createElement("option"),c.innerHTML=this.menuOptions[e],this.select.appendChild(c);this.field=document.createElement("input");
this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Menu,a.Control);var f;a.Menu.prototype.init=function(){f=this.evaluator;var b=f.evalExpression(this.name).toString();this.label.innerHTML=b;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var d=0,c=0,e=0;this.value=f.evalExpression(this.valueExpr);
this.indexValue=this.getIndex(this.value);for(var g=0,k=this.menuOptions.length;g<k;g++)e=a.getTextWidth(this.menuOptions[g],this.fieldFontSize+"px Arial"),e>d&&(d=e,c=g);d+=25;e=a.getTextWidth(this.formatOutputValue(f.evalExpression(this.strValue[c])),this.fieldFontSize+"px Arial")+7;c=a.getTextWidth(b,this.fieldFontSize+"px Arial")+10;""==b&&(c=0);this.visible||(e=0);for(b=this.w-e-c;b<d&&0<c;)c--,b++;for(;b<d&&0<e;)e--,b++;for(;c+b+e+1<this.w;)b++,e++;d=c;g=d+b;e=this.w-g;k=this.formatOutputValue(f.evalExpression(this.strValue[this.indexValue]));
this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.label.setAttribute("class","DescartesMenuLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+c+"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=
k;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(e-2)+"px; height : "+(this.h-2)+"px; left: "+g+"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; line-height: "+this.h+"px; width : "+b+"px; height : "+this.h+"px; left: "+d+"px; border-color: #7a8a99; border-width: 1.5px; border-style: solid; background-color: #eeeeee;");
this.select.selectedIndex=this.indexValue;f.setVariable(this.id,parseFloat(k));this.update()};a.Menu.prototype.update=function(){f=this.evaluator;this.label.innerHTML=f.evalExpression(this.name).toString();this.activeIfValue=0<f.evalExpression(this.activeif);this.drawIfValue=0<f.evalExpression(this.drawif);this.field.disabled=this.activeIfValue?!1:!0;this.select.disabled=this.activeIfValue?!1:!0;this.drawIfValue?this.containerControl.style.display="block":(this.click=!1,this.containerControl.style.display=
"none");this.updatePositionAndSize();this.value=f.getVariable(this.id);this.field.value=this.formatOutputValue(this.value);f.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));k=-1;g=Infinity;for(var d=0,c=this.strValue.length;d<c;d++)b=e(a-parseFloat(this.evaluator.evalExpression(this.strValue[d]))),b<=g&&(g=b,k=d);return k};a.Menu.prototype.changeValue=
function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){c=a.hasTouchSupport;var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=function(){return!1};c?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,k="h",g,b,c,f,h,d,r,l,m,t,q,u,p,v,n,s,w,z,C,y,E;a.Scrollbar=function(b,d){a.Control.call(this,b,d);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.orientation=this.w>=this.h?k:"v";this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");
this.field=document.createElement("input");this.scrollManipulator=document.createElement("div");this.label=document.createElement("label");this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.scrollManipulator);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();
this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){g=this.evaluator;this.findOffset();0==g.evalExpression(this.decimals)?this.incr=1:this.incr=(g.evalExpression(this.max)-g.evalExpression(this.min))/100;this.value=this.validateValue(g.evalExpression(this.valueExpr));c=this.formatOutputValue(this.value);f=this.evaluator.evalExpression(this.expresion);this.x=f[0][0];this.y=f[0][1];4==f[0].length&&(this.w=f[0][2],this.h=f[0][3]);this.orientation=this.w>=this.h?k:"v";this.initScroll(c);
this.changeScrollPositionFromValue();this.prePos=this.pos;g.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(d){b=this;g=b.evaluator;var c=g.evalExpression(b.name).toString();b.label.innerHTML=c;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 e=a.getTextWidth(d+"_",b.fieldFontSize+"px Arial"),h=b.parent.getSpaceById(b.spaceID).h;b.labelHeight=""==c?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-h&&(b.canvasHeight=h),c=0,c=b.fieldHeight,e=c+b.canvasHeight,b.canvasX=0,b.canvasY=b.fieldHeight,b.labelWidth=b.w,b.labelY=e,b.upWidth=b.downW=b.w,b.upHeight=b.downH=15,b.upX=0,b.upY=b.fieldHeight,b.downX=0,b.downY=e-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=e-b.downH-b.scrollManipulatorH,b.scrollManipulatorLimSup=c+b.downH;else{f=a.getTextWidth(c,b.fieldFontSize+"px Arial")+10;b.labelWidth=f;b.fieldWidth=e;""==c&&(b.labelWidth=0);b.visible||(b.fieldWidth=0);for(e=b.w-b.fieldWidth-b.labelWidth;58>e&&0<b.labelWidth;)b.labelWidth--,e++;for(;58>e&&0<b.fieldWidth;)b.fieldWidth--,e++;c=b.labelWidth;f=c+e;b.fieldWidth=b.w-f;b.canvasWidth=e;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=f-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=c+b.downW;b.scrollManipulatorLimSup=c+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=d;0===b.fieldHeight&&(b.field.style.display="none");b.label.setAttribute("class","DescartesScrollbarLabel");b.label.setAttribute("style","font-size:"+b.fieldFontSize+
"px; width: "+b.labelWidth+"px; height: "+b.labelHeight+"px; line-height: "+b.labelHeight+"px; left: 0px; top:"+b.labelY+"px;")};a.Scrollbar.prototype.update=function(){g=this.evaluator;this.label.innerHTML=g.evalExpression(this.name).toString();0==g.evalExpression(this.decimals)?this.incr=1:this.incr=(g.evalExpression(this.max)-g.evalExpression(this.min))/100;this.activeIfValue=0<g.evalExpression(this.activeif);this.drawIfValue=0<g.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;
this.drawIfValue?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";this.updatePositionAndSize();var a=this.validateValue(g.getVariable(this.id));a!=this.value&&!(0<Math.abs(a-this.value)&&1E-9>Math.abs(a-this.value))&&(this.value=a,this.changeScrollPositionFromValue(),this.prePos=this.pos);this.value=a;this.field.value=this.formatOutputValue(this.value);g.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){b=this;h=b.ctx;r=e(this.w);
d=e(this.h);h.fillStyle="#e0e4e8";h.fillRect(0,0,r,d);h.strokeStyle="#7a8a99";b.down&&(h.fillStyle="#ccdcec",h.fillRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1));h.strokeRect(b.downX+0.5,b.downY+0.5,b.downW,b.downH-1);b.up&&(h.fillStyle="#ccdcec",h.fillRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1));h.strokeRect(b.upX+0.5,b.upY-0.5,b.upWidth,b.upHeight+1);l=4;h.fillStyle="black";h.beginPath();b.orientation===k?(h.moveTo(b.downX+l,b.downH/2),h.lineTo(b.downX+b.downW-l,l),h.lineTo(b.downX+b.downW-
l,b.downH-l),h.moveTo(b.upX+b.upWidth-l,b.downH/2),h.lineTo(b.upX+l,l),h.lineTo(b.upX+l,b.downH-l),h.fill(),b.activeIfValue&&(m=e(b.pos),h.fillStyle="#ccdcec",h.fillRect(m+0.5,0,e(b.scrollManipulatorW),d),h.strokeStyle="#6382bf",h.strokeRect(m+0.5,0,e(b.scrollManipulatorW),d),t=e(b.scrollManipulatorW/2),h.beginPath(),h.moveTo(m+t+0.5-2,3),h.lineTo(m+t+0.5-2,d-3),h.moveTo(m+t+0.5,3),h.lineTo(m+t+0.5,d-3),h.moveTo(m+t+0.5+2,3),h.lineTo(m+t+0.5+2,d-3),h.stroke())):(h.moveTo(b.downX+b.downW/2,b.downY+
b.downH-l),h.lineTo(b.downX+l,b.downY+l),h.lineTo(b.downX+b.downW-l,b.downY+l),h.moveTo(b.upX+b.upWidth/2,b.upY+l),h.lineTo(b.upX+l,b.upY+b.upHeight-l),h.lineTo(b.upX+b.upWidth-l,b.upY+b.upHeight-l),h.fill(),b.activeIfValue&&(m=e(b.pos),h.fillStyle="#ccdcec",h.fillRect(0,m+0.5,r,e(b.scrollManipulatorH)),h.strokeStyle="#6382bf",h.strokeRect(0,m+0.5,r,e(b.scrollManipulatorH)),t=e(b.scrollManipulatorH/2),h.beginPath(),h.moveTo(3,m+t+0.5-2),h.lineTo(r-3,m+t+0.5-2),h.moveTo(3,m+t+0.5),h.lineTo(r-3,m+t+
0.5),h.moveTo(3,m+t+0.5+2),h.lineTo(r-3,m+t+0.5+2),h.stroke()));h.strokeRect(0.5,0.5,r-1,d-1);b.activeIfValue||(h.fillStyle="rgba(240,240,240,"+160/255+")",h.fillRect(0,0,r,d.h))};a.Scrollbar.prototype.validateValue=function(a){g=this.evaluator;q=a.toString();q=parseFloat(q.replace(this.parent.decimal_symbol,"."));isNaN(q)&&(q=0);this.minimo=g.evalExpression(this.min);q<this.minimo&&(this.value=null,q=this.minimo);this.maximo=g.evalExpression(this.max);q>this.maximo&&(this.value=null,q=this.maximo);
u=this.incr;q=0!=u?q*u/u:0;this.fixed&&(q=parseFloat(parseFloat(q).toFixed(g.evalExpression(this.decimals))));return q};a.Scrollbar.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.incr)};a.Scrollbar.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.incr)};a.Scrollbar.prototype.increase10=function(){l=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==k?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+
l):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+l)};a.Scrollbar.prototype.decrease10=function(){l=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==k?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-l):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-l)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&(p=this.validateValue(a),p!=this.value&&(this.value=p,this.field.value=
this.formatOutputValue(p),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){g=this.evaluator;v=this.scrollManipulatorLimInf;n=this.scrollManipulatorLimSup;s=g.evalExpression(this.min);w=g.evalExpression(this.max);u=this.incr;p=e((this.pos-v)*(w-s)/(n-v)/u)*u+s;p!=this.value&&(this.value=p,this.field.value=this.formatOutputValue(p),g.setVariable(this.id,
this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){g=this.evaluator;v=this.scrollManipulatorLimInf;n=this.scrollManipulatorLimSup;s=g.evalExpression(this.min);w=g.evalExpression(this.max);u=this.incr;this.pos=(this.value-s)*(n-v)/(w-s)+v;this.orientation==k?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=
function(){function b(a,d,c,f){clearInterval(v);if((s.up||s.down||s.canvasClick)&&1E-7<Math.abs(s.value-f))d.call(s),a=c?a:30,v=setTimeout(function(){b(a,d,!1,f)},a)}function d(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.clickPos=s.getCursorPosition(c),s.canvasClick=!0,s.orientation==k?s.clickPos.x<s.prePos?b(w,s.decrease10,!0,s.minimo):b(w,s.increase10,!0,s.maximo):s.clickPos.y<s.prePos?b(w,s.increase10,!0,s.maximo):b(w,s.decrease10,!0,s.minimo))}
function c(a){s.canvasClick=!1;clearInterval(v);a.preventDefault()}function f(a){!0==s.canvasClick&&(s.clickPos=s.getCursorPosition(a),a.preventDefault())}function e(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("mouseup",g),window.addEventListener("mousemove",m),a.preventDefault())}function h(a){s.activeIfValue&&(s.scrollClick=!0,s.initPos=s.getCursorPosition(a),window.addEventListener("touchend",n),window.addEventListener("touchmove",onToucheMove_scrollManipulator),
a.preventDefault())}function g(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("mouseup",g,!1);window.removeEventListener("mousemove",m,!1);a.preventDefault()}function n(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("touchend",n,!1);window.removeEventListener("touchmove",m,!1);a.preventDefault()}function m(a){var b=s.getCursorPosition(a);s.orientation==k?(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 l(d){d.preventDefault();s.whichButton=a.whichButton(d);"L"==s.whichButton&&s.activeIfValue&&(s.up=!0,b(w,s.increase,!0,s.maximo))}function p(d){d.preventDefault();s.whichButton=a.whichButton(d);"L"==s.whichButton&&s.activeIfValue&&(s.down=!0,b(w,s.decrease,!0,s.minimo))}function r(a){s.up=!1;clearInterval(v);a.preventDefault()}function q(a){s.down=!1;clearInterval(v);
a.preventDefault()}function t(a){s.up=!1;clearInterval(v);a.preventDefault();s.draw()}function u(a){s.down=!1;clearInterval(v);a.preventDefault();s.draw()}z=a.hasTouchSupport;var s=this,w=z?500:200,v;s.canvas.oncontextmenu=s.divUp.oncontextmenu=s.divDown.oncontextmenu=s.label.oncontextmenu=s.field.oncontextmenu=s.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&s.changeValue(s.field.value)});z?this.canvas.addEventListener("touchstart",
d):this.canvas.addEventListener("mousedown",d);z||this.divDown.addEventListener("mouseout",q);z?window.addEventListener("touchend",c):window.addEventListener("mouseup",c);z?this.canvas.addEventListener("touchmove",f):this.canvas.addEventListener("mousemove",f);z?this.scrollManipulator.addEventListener("touchstart",h):this.scrollManipulator.addEventListener("mousedown",e);z?this.divUp.addEventListener("touchstart",l):this.divUp.addEventListener("mousedown",l);z?this.divDown.addEventListener("touchstart",
p):this.divDown.addEventListener("mousedown",p);z||this.divUp.addEventListener("mouseout",r);z||this.divDown.addEventListener("mouseout",q);z?window.addEventListener("touchend",t):window.addEventListener("mouseup",t);z?window.addEventListener("touchend",u):window.addEventListener("mouseup",u)};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,b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,e,b);var c=this,f=c.evaluator.evalExpression(c.expresion);4==f[0].length?(c.w=f[0][2],c.h=f[0][3]):(c.w=
200,c.h=28);c.audio=c.parent.getAudio(c.file);c.autoplay&&(c.audio.setAttribute("autoplay","autoplay"),c.audio.play());c.loop&&c.audio.setAttribute("loop","loop");c.controls&&c.audio.setAttribute("controls","controls");c.audio.setAttribute("style","position: absolute; width: "+c.w+"px; left: "+c.x+"px; top: "+c.y+"px; z-index: "+c.zIndex+";");c.addControlContainer(c.audio);c.evaluator.setFunction(c.id+".play",function(){c.audio.play()});c.evaluator.setFunction(c.id+".pause",function(){c.audio.pause()});
c.evaluator.setFunction(c.id+".stop",function(){c.audio.pause();c.audio.currentTime=0});c.audio.addEventListener("timeupdate",function(a){c.evaluator.setVariable(c.id+".currentTime",c.audio.currentTime)})};a.extend(a.Audio,a.Control);a.Audio.prototype.init=function(){this.audio.style.left=this.x+"px";this.audio.style.top=this.y+"px";this.update()};var k;a.Audio.prototype.update=function(){e=this.evaluator;(k=0<e.evalExpression(this.drawif))?this.audio.style.display="block":(this.audio.style.display=
"none",k!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=k;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Video=function(g,b){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,g,b);var c=this;e=c.evaluator;var f=c.evaluator.evalExpression(c.expresion);4==f[0].length?(c.w=f[0][2],c.h=f[0][3]):(c.w=null,c.h=null);c.video=document.createElement("video");c.autoplay&&c.video.setAttribute("autoplay","autoplay");c.loop&&
c.video.setAttribute("loop","loop");c.controls&&c.video.setAttribute("controls","controls");c.poster&&c.video.setAttribute("poster",c.poster);c.w&&(c.video.setAttribute("width",c.w),c.video.setAttribute("height",c.h));c.video.setAttribute("style","position: absolute; overflow: hidden; left: "+c.x+"px; top: "+c.y+"px;");var f=c.file,h=f.lastIndexOf(".");-1!=h&&(f=c.file.substring(0,h));c.video.canPlayType("video/mp4")&&(h=document.createElement("source"),h.setAttribute("src",f+".mp4"),h.setAttribute("type",
"video/mp4"),c.video.appendChild(h));c.video.canPlayType("video/ogg")&&(h=document.createElement("source"),h.setAttribute("src",f+".ogg"),h.setAttribute("type","video/ogg"),c.video.appendChild(h),h=document.createElement("source"),h.setAttribute("src",f+".ogv"),h.setAttribute("type","video/ogg"),c.video.appendChild(h));c.video.canPlayType("video/webm")&&(h=document.createElement("source"),h.setAttribute("src",f+".webm"),h.setAttribute("type","video/webm"),c.video.appendChild(h));c.addControlContainer(c.video);
c.evaluator.setFunction(c.id+".play",function(){c.video.play()});c.evaluator.setFunction(c.id+".pause",function(){c.video.pause()});c.evaluator.setFunction(c.id+".stop",function(){c.video.pause();c.video.currentTime=0});c.video.addEventListener("timeupdate",function(a){c.evaluator.setVariable(c.id+".currentTime",c.video.currentTime)})};a.extend(a.Video,a.Control);a.Video.prototype.init=function(){this.video.style.left=this.x+"px";this.video.style.top=this.y+"px";this.update()};var k;a.Video.prototype.update=
function(){e=this.evaluator;k=0<e.evalExpression(this.drawif);0<e.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display="none",k!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=k;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k;a.TextArea=function(e,b){this.font="Monospaced,PLAIN,12";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 c=this.parent.lessonParser.parseText(this.answer)}this.containerControl=document.createElement("div");this.textArea=document.createElement("div");this.textAreaAnswer=document.createElement("div");this.showButton=document.createElement("div");this.activeCover=document.createElement("div");this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);
this.containerControl.appendChild(this.activeCover);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=void 0==this.text||"simpleText"==this.text.type?this.rawText||"":this.text.hasFormula?this.rawText:this.text.toHTML();c&&"simpleText"!=c.type&&(this.answer=this.text.hasFormula?"":c.toHTML());this.evaluator.setVariable(this.id,this.text);this.drawButton();this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){k=
this.answer?28:8;e=this.evaluator;var g;g=this.text.match(/<span/)?this.text:this.text.replace(/\\n/g,"<br/>");this.containerControl.setAttribute("class","DescartesTextAreaContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=0<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-k)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textArea.setAttribute("contenteditable","true");this.textArea.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;' >"+g+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style",
"width: "+(this.w-8)+"px; height: "+(this.h-k)+"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);var a;a=this.text.match(/<span/)?this.rawText:this.text;e.setVariable(this.id,a);this.activeCover.style.display=this.activeIfValue?"none":"block";this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize()};
a.TextArea.prototype.registerMouseAndTouchEvents=function(){function a(c){c.preventDefault();b.showButton.style.backgroundImage="url("+b.imageUnPush+")"}var b=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();b.showAnswer=!b.showAnswer;b.textAreaAnswer.style.display=b.showAnswer?"block":"none";b.showButton.childNodes[0].childNodes[0].textContent=b.showAnswer?"T":"S";b.showButton.style.backgroundImage="url("+b.imagePush+")"});this.showButton.addEventListener("mouseup",
a);this.showButton.addEventListener("mouseout",a)};a.TextArea.prototype.getScreenshot=function(){var a=document.createElement("canvas");a.setAttribute("width",this.w);a.setAttribute("height",this.h);var b=a.getContext("2d");b.fillStyle="white";b.strokeStyle="black";b.lineWidth=1;b.fillRect(0,0,this.w,this.h);b.strokeRect(0,0,this.w,this.h);return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,k,g,b,c,f,h,d,r,l;a.GraphicControl=function(b,d){g=b.evaluator.parser;
this.text=this.spaceID="";this.size=g.parse("4");this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";a.Control.call(this,b,d);this.touchId=null;this.font=a.convertFont(this.font);this.constraintExpr&&(this.constraint=g.parse(this.constraintExpr),"(expr)"==this.constraint.type&&(this.constraint=g.parse(this.constraintExpr.substring(1,this.constraintExpr.length-1))),"compOperator"==this.constraint.type?this.newt=new a.R2Newton(this.evaluator,
this.constraint):this.constraint=null,r=new a.R2(0,0));this.container=this.getContainer();this.mouseCacher=document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("dragged",!0);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);this.registerMouseAndTouchEvents();this.xString=this.id+".x";this.yString=this.id+".y";this.activoString=
this.id+".activo";""!==this.space.id&&2!==b.version?(this.mxString=this.space.id+".mouse_x",this.myString=this.space.id+".mouse_y",this.mclickedString=this.space.id+".mouse_clicked",this.mclicizquierdoString=this.space.id+".clic_izquierdo"):(this.mxString="mouse_x",this.myString="mouse_y",this.mclickedString="mouse_clicked",this.mclicizquierdoString="clic_izquierdo");this.init()};a.extend(a.GraphicControl,a.Control);a.GraphicControl.prototype.init=function(){k=this.evaluator;l=a.hasTouchSupport;var b=
k.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];k.setVariable(this.xString,this.x);k.setVariable(this.yString,this.y);""!=this.imageSrc&&!this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,this.height=this.image.height):(this.width=2*k.evalExpression(this.size),this.height=2*k.evalExpression(this.size));this._w=l&&70>this.width?70:this.width;this._h=l&&70>this.height?70:this.height;this.mouseCacher.setAttribute("style",
"cursor: pointer; background-color: rgba(255, 255, 255, 0); width: "+this._w+"px; height: "+this._h+"px; z-index: "+this.zIndex+";");this.mouseCacher.style.left=parseInt(this.space.getAbsoluteX(this.x)-this._w/2)+"px";this.mouseCacher.style.top=parseInt(this.space.getAbsoluteY(this.y)-this._h/2)+"px";k.setVariable(this.activoString,0);this.update()};a.GraphicControl.prototype.update=function(){k=this.evaluator;this.activeIfValue=0<k.evalExpression(this.activeif);this.drawIfValue=0<k.evalExpression(this.drawif);
this.x=k.getVariable(this.xString);this.y=k.getVariable(this.yString);b=this.space.getAbsoluteX(this.x);c=this.space.getAbsoluteY(this.y);this.mouseCacher.style.display=!this.activeIfValue?"none":"block";this.mouseCacher.style.left=parseInt(b-this._w/2)+"px";this.mouseCacher.style.top=parseInt(c-this._h/2)+"px";this.constraint&&this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=function(){k=this.evaluator;this.drawIfValue&&(h=this.ctx,d=this.space.backgroundCtx,b=parseInt(this.space.getAbsoluteX(this.x))+
0.5,c=parseInt(this.space.getAbsoluteY(this.y))+0.5,""!=this.text&&this.drawText(b,c),this.image.ready?(this.image.complete&&h.drawImage(this.image,parseInt(b-this.image.width/2),parseInt(c-this.image.height/2)),this.trace&&(d.save(),d.translate(b,c),d.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),d.beginPath(),d.arc(0,0,1,0,e,!1),d.restore(),d.lineWidth=1,d.strokeStyle=this.trace.getColor(),d.stroke())):(h.beginPath(),h.arc(b,c,parseInt(this.width/2),0,e,!1),h.fillStyle=this.colorInt.getColor(),
h.fill(),h.lineWidth=1,h.strokeStyle=this.color.getColor(),h.stroke(),this.active&&(h.beginPath(),h.arc(b,c,parseInt(this.width/2)-2,0,e,!1),h.strokeStyle=this.colorInt.borderColor(),h.stroke()),this.trace&&(d.lineWidth=1,d.strokeStyle=this.trace.getColor(),d.beginPath(),d.arc(b,c,parseInt(this.width/2),0,e,!1),d.stroke())))};a.GraphicControl.prototype.evalConstraint=function(a,b){r.set(this.x,this.y);f=this.newt.findZero(r);this.x=f.x;this.y=f.y;this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,
this.y)};a.GraphicControl.prototype.drawText=function(a,b){h=this.ctx;k=this.evaluator;h.fillStyle=this.color.getColor();h.font=this.font;h.textBaseline="alphabetic";h.fillText(k.evalExpression(this.text[0],k.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,d=0,c=a.length;d<c;d++)if(b=a[d],b.id==this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,this.space=b,b.graphicControlContainer;
a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.activoString,0)};a.GraphicControl.prototype.registerMouseAndTouchEvents=function(){function b(d){d.preventDefault();g.whichButton=a.whichButton(d);"L"==g.whichButton&&(g.activeIfValue&&g.over)&&(g.parent.deactivateGraphiControls(),g.click=!0,g.active=!0,g.evaluator.setVariable(g.activoString,1),g.evaluator.setVariable(g.mclickedString,
0),g.evaluator.setVariable(g.mclicizquierdoString,0),g.posAnte=g.getCursorPosition(d),g.prePos={x:g.space.getAbsoluteX(g.x),y:g.space.getAbsoluteY(g.y)},g.evaluator.setVariable(g.mxString,g.space.getRelativeX(g.posAnte.x)),g.evaluator.setVariable(g.myString,g.space.getRelativeY(g.posAnte.y)),g.parent.update(),window.addEventListener("mouseup",c),window.addEventListener("mousemove",f))}function d(a){a.preventDefault();g.activeIfValue&&(g.parent.deactivateGraphiControls(),g.click=!0,g.active=!0,g.evaluator.setVariable(g.activoString,
1),g.evaluator.setVariable(g.mclickedString,0),g.evaluator.setVariable(g.mclicizquierdoString,0),g.posAnte=g.getCursorPosition(a),g.prePos={x:g.space.getAbsoluteX(g.x),y:g.space.getAbsoluteY(g.y)},g.evaluator.setVariable(g.mxString,g.space.getRelativeX(g.posAnte.x)),g.evaluator.setVariable(g.myString,g.space.getRelativeY(g.posAnte.y)),g.parent.update(),window.addEventListener("touchmove",f),window.addEventListener("touchend",c))}function c(b){b.preventDefault();g.touchId=null;g.evaluator.setVariable(g.mclickedString,
1);g.evaluator.setVariable(g.mclicizquierdoString,1);if(g.activeIfValue||g.active)g.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",f,!1),window.removeEventListener("touchend",c,!1)):(window.removeEventListener("mouseup",c,!1),window.removeEventListener("mousemove",f,!1)),g.evaluator.setVariable(g.mxString,g.space.getRelativeX(g.posAnte.x)+g.x),g.evaluator.setVariable(g.myString,g.space.getRelativeY(g.posAnte.y)+g.y),g.parent.update(),g.mouseCacher.style.left=g.space.getAbsoluteX(g.x)-
g._w/2+"px",g.mouseCacher.style.top=g.space.getAbsoluteY(g.y)-g._h/2+"px"}function f(a){a.preventDefault();a.touchId=g.touchId;g.evaluator.setVariable(g.mclickedString,0);g.evaluator.setVariable(g.mclicizquierdoString,0);k=g.getCursorPosition(a);g.posX=g.prePos.x-(g.posAnte.x-k.x);g.posY=g.prePos.y-(g.posAnte.y-k.y);g.evaluator.setVariable(g.xString,g.space.getRelativeX(g.posX));g.evaluator.setVariable(g.yString,g.space.getRelativeY(g.posY));g.evaluator.setVariable(g.mxString,g.space.getRelativeX(g.posAnte.x)+
g.space.getRelativeX(g.posX));g.evaluator.setVariable(g.myString,g.space.getRelativeY(g.posAnte.y)+g.space.getRelativeY(g.posY));g.parent.updateControls();g.parent.update()}function e(a){g.over=!0}function h(a){g.over=!1;g.click=!1}var g=this;this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=function(){return!1};a.hasTouchSupport?this.mouseCacher.addEventListener("touchstart",d):(this.mouseCacher.addEventListener("mousedown",b),this.mouseCacher.addEventListener("mouseover",e),this.mouseCacher.addEventListener("mouseout",
h));var k};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var b;if(a.touchId){d=0;for(c=a.touches.length;d<c;d++)if(a.touches[d].identifier==a.touchId){b=a.touches[d];break}}else for(var d=0,c=a.touches.length;d<c;d++)if(a.target==a.touches[d].target){b=a.touches[d];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 k,g,b,c,f,h,d,r,l,m;if(a.loadLib)return a;var t,q,u,p,v,n,s,w,z=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,C,y,E,D,B,A,H,G,I,K,x,J,F,P,Q,M,R,S,N,O,L;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 d=0,c=a.length;d<c;d++)switch(u=a[d][0],p=a[d][1],q=e[u],q){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[q]=parseInt(p);break;case "about":case "config":case "init":case "clear":b[q]="true"===e[p];break;default:console.log("----- attributo de space no identificado: <"+
u+"> valor: <"+p+"> -----")}return b};a.LessonParser.prototype.parseSpace=function(b){v={};b=this.split(b);for(var d=0,c=b.length;d<c;d++)switch(u=b[d][0],p=b[d][1],q=e[u],q){case "type":case "id":case "cID":case "file":v[q]=p;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":v[q]="true"===e[p];break;case "bg_display":case "render":v[q]=e[p];break;case "net":case "net10":case "axes":case "text":v[q]="false"===e[p]?"":new a.Color(p,this.parent.evaluator);
break;case "x_axis":case "y_axis":v[q]="false"===e[p]?"":p;break;case "O.x":v.OxExpr=p;break;case "O.y":v.OyExpr=p;break;case "image":v.imageSrc=p;break;case "x":t=p;t="%"===t[t.length-1]?(this.parent.container.width*parseFloat(t)/100).toString():p;v.xExpr=this.parser.parse(t);break;case "y":t=p;t="%"===t[t.length-1]?(this.parent.container.height*parseFloat(t)/100).toString():p;v.yExpr=this.parser.parse(t);break;case "width":t=p;"%"===t[t.length-1]?(v.wExpr=t,t=this.parent.container.width*parseFloat(t)/
100):(t=parseFloat(p),t!=p&&(t=this.parent.container.width));v.w=t;break;case "height":t=p;"%"===t[t.length-1]?(v.hExpr=t,t=this.parent.container.height*parseFloat(t)/100):(t=parseFloat(p),t!=p&&(t=this.parent.container.height));v.h=t;break;case "drawif":v.drawif=this.parser.parse(p);break;case "scale":t=parseFloat(p);t.toString()!=p&&(t=48);v.scale=t;break;case "background":v.background=new a.Color(p,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+u+
"> valor: <"+p+"> -----")}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){n={type:"numeric"};b=this.split(b);for(var d=0,c=b.length;d<c;d++)switch(u=b[d][0],p=b[d][1],q=e[u],q){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":n[q]=
p;break;case "gui":case "region":case "action":case "msg_pos":case "poster":n[q]=e[p];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":n[q]="true"===e[p];break;case "color":case "colorInt":case "trace":n[q]=new a.Color(p,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":n[q]=this.parser.parse(p);break;case "constraint":n.constraintExpr=p;break;case "image":n.imageSrc=
p;break;case "space":n.spaceID=p;break;case "type":n.type=e[p.trim()];break;case "expresion":n.expresion=this.parser.parse(p.replace(")(",","));break;case "bold":"false"!=e[p]&&(n.bold="bold");break;case "italics":"false"!=e[p]&&(n.italics="italic");break;case "underlined":"false"!=e[p]&&(n.underlined=!0);break;case "value":var f=p.replace(/&squot;/g,"'");f.match(/^\|/)&&(f="'"+f.substring(1),f.match(/\|$/)&&(f=f.substring(0,f.length-1)+"'"));n.valueExpr=this.parser.parse(f);n.valueExprString=f;break;
case "incr":0!=p&&(n.incr=this.parser.parse(p));break;case "exponentialif":n.exponentialif=parseFloat(p);break;case "text":n.rawText=p;for(var f=this.parseText(p),g=0,h=f.length;g<h;g++)f[g]=this.parser.parse(f[g],!1);n.text=f;break;default:g=u.indexOf(".");f=e[u.substring(0,g)];g=e[u.substring(g+1)];if("parameter"===f&&"font"===g){n.parameterFont=p;break}else if("Explanation"===f&&"font"===g){n.ExplanationFont=p;break}else if("tooltip"===f&&"font"===g){n.tooltipFont=p;break}console.log("----- attributo de control no identificado: <"+
u+"> valor: <"+p+"> -----")}if("numeric"===n.type)switch(n.gui){case "spinner":return new a.Spinner(this.parent,n);case "button":return new a.Button(this.parent,n);case "textfield":return new a.TextField(this.parent,n);case "menu":return new a.Menu(this.parent,n);case "scrollbar":return new a.Scrollbar(this.parent,n);default:return new a.Spinner(this.parent,n)}else{if("video"===n.type)return new a.Video(this.parent,n);if("audio"===n.type)return new a.Audio(this.parent,n);if("graphic"===n.type)return new a.GraphicControl(this.parent,
n);if("text"===n.type)return new a.TextArea(this.parent,n)}};a.LessonParser.prototype.parseGraphic=function(b,d,c,f){s={rotateExp:f,parameter:"t"};b=this.split(b);f=0;for(var g=b.length;f<g;f++)switch(u=b[f][0],p=b[f][1],q=e[u],q){case "type":case "align":s[q]=e[p];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":s[q]="true"===e[p];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":s[q]="false"===e[p]?"":new a.Color(p,
this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":s[q]=p;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[q]=this.parser.parse(p);break;case "space":s.spaceID=p;break;case "expresion":"macro"!=s.type?(s.expresion=this.parser.parse(p),s.expresionString=p):s.expresion=p;break;case "text":s.text=this.parseText(p);break;case "file":var h=
p.replace(/&squot;/g,"'");"["===h.charAt(0)&&"]"===h.charAt(h.length-1)&&(h=h.substring(1,h.length-1));h.match(z)&&(h="'"+h+"'");s.file=this.parser.parse(h);break;case "border":"false"!=e[p]&&(s.border=new a.Color(p,this.parent.evaluator));break;default:if(void 0!=s.family&&u.substring(0,s.family.length+1)===s.family+"."){switch(e[u.substring(s.family.length+1)]){case "interval":s.family_interval=this.parser.parse(p);break;case "steps":s.family_steps=this.parser.parse(p)}break}if(void 0!=s.parameter&&
u.match(s.parameter+".")){s.parameter!==u.substring(0,u.indexOf(s.parameter)+s.parameter.length)&&(s.parameter=u.substring(0,u.indexOf(s.parameter)+s.parameter.length));switch(e[u.substring(s.parameter.length+1)]){case "interval":s.parameter_interval=this.parser.parse(p);break;case "steps":s.parameter_steps=this.parser.parse(p)}break}console.log("----- attributo del graphic no identificado: <"+u+"> valor: <"+p+"> -----")}d&&(s.abs_coord=d);c&&(s.background=c);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,d,c,f){s={rotateExp:f,parameter:"t"};b=this.split(b);d=0;for(c=b.length;d<c;d++)switch(u=b[d][0],p=b[d][1],q=e[u],q){case "type":case "model":s[q]=e[p];break;case "background":case "fixed":case "edges":s[q]="true"===e[p];break;case "color":case "backcolor":s[q]=new a.Color(p,this.parent.evaluator);break;case "type":case "model":s[q]=e[p];break;case "background":case "fixed":case "edges":case "split":s[q]="true"===e[p];break;case "color":case "backcolor":s[q]=
new a.Color(p,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":s[q]=this.parser.parse(p);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":s[q]=p;break;case "space":s.spaceID=p;break;case "expresion":"macro"!=s.type&&"curve"!=s.type&&"surface"!=s.type?(s.expresion=this.parser.parse(p),s.expresionString=p):s.expresion=p.replace(/\\n/g,"");break;case "text":f=this.parseText(p);
for(var g=0,h=f.length;g<h;g++)f[g]=this.parser.parse(f[g],!1);s.text=f;break;case "file":f=p.replace(/&squot;/g,"'");"["===f.charAt(0)&&"]"===f.charAt(f.length-1)&&(f=f.substring(1,f.length-1));f.match(/./)&&(f="'"+f+"'");s.file=this.parser.parse(f);break;case "drawif":case "width":case "length":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":s[q]=this.parser.parse(p);break;case "family":case "parameter":case "font":case "name":s[q]=p;break;case "space":s.spaceID=
p;break;case "expresion":"macro"!=s.type&&"curve"!=s.type&&"surface"!=s.type?(s.expresion=this.parser.parse(p),s.expresionString=p):s.expresion=p;break;case "text":f=this.parseText(p);g=0;for(h=f.length;g<h;g++)f[g]=this.parser.parse(f[g],!1);s.text=f;break;case "file":f=p.replace(/&squot;/g,"'");"["===f.charAt(0)&&"]"===f.charAt(f.length-1)&&(f=f.substring(1,f.length-1));f.match(/./)&&(f="'"+f+"'");s.file=this.parser.parse(f);break;default:if(void 0!==s.family&&u.substring(0,s.family.length+1)===
s.family+"."){"interval"===e[u.substring(s.family.length+1)]?s.family_interval=this.parser.parse(p):s.family_steps=this.parser.parse(p);break}console.log("----- attributo del graphic3D no identificado: <"+u+"> valor: <"+p+"> -----")}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){w={};
b=this.split(b);for(var d=0,c=b.length;d<c;d++)b[d][1]=b[d][1].replace(/&squot;/g,"'");d=0;for(c=b.length;d<c;d++)switch(u=b[d][0],p=b[d][1],q=e[u],q){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":w[q]=p;break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":w[q]="true"===e[p];break;case "size":case "rows":case "columns":w[q]=this.parser.parse(p);
break;case "evaluate":case "execution":case "msg_pos":case "action":w[q]=e[p];break;default:var f=u.indexOf("."),g=e[u.substring(0,f)],f=e[u.substring(f+1)];if("parameter"===g&&"font"===f){w.parameterFont=p;break}console.log("----- attributo de auxiliar no identificado: <"+u+"> valor: <"+p+"> -----")}w.sequence?new a.Function(this.parent,w):w.constant?(b=new a.Constant(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.algorithm&&w.evaluate?(b=new a.Algorithm(this.parent,
w),this.parent.auxiliaries.push(b)):w.array&&!w.matrix&&")"!=w.id.charAt(w.id.length-1)?(b=new a.Vector(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.matrix&&")"!=w.id.charAt(w.id.length-1)?(b=new a.Matrix(this.parent,w),w.evaluate&&"always"===w.evaluate&&this.parent.auxiliaries.push(b)):w.event&&")"!=w.id.charAt(w.id.length-1)?this.parent.events.push(new a.Event(this.parent,w)):")"===w.id.charAt(w.id.length-1)?new a.Function(this.parent,w):new a.Variable(this.parent,
w)};a.LessonParser.prototype.parseAction=function(b){C=b.action;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 d={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(u=b[c][0],p=b[c][1],q=e[u],q){case "id":case "delay":case "init":case "doExpr":case "whileExpr":d[q]=p;break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":d[q]="true"===e[p];break;default:console.log("----- attributo de la animacion no identificado: <"+
u+">  <"+p+"> -----")}return new a.Animation(this.parent,d)};a.LessonParser.prototype.parsePleca=function(e,n){e=this.split(e);g=k="";b=0;c="#536891";f="white";h="left";d="";r="SansSerif,BOLD,20";l="SansSerif,PLAIN,18";m=void 0;for(var q=0,s=e.length;q<s;q++)switch(u=e[q][0],p=e[q][1],u){case "title":k=p;break;case "subtitle":g=p;break;case "subtitlines":b=p;break;case "bgcolor":""!=p&&(c=(new a.Color(p,this.parent.evaluator)).getColor());break;case "fgcolor":""!=p&&(f=(new a.Color(p,this.parent.evaluator)).getColor());
break;case "align":""!=p&&(h=p);break;case "titleimage":d=p;break;case "titlefont":r=""!=p?a.convertFont(p):a.convertFont(r);break;case "subtitlefont":l=""!=p?a.convertFont(p):a.convertFont(l);break;default:console.log("----- attributo de la pleca no identificado: <"+u+">  <"+p+"> -----")}if(""===k&&""===g)return document.createElement("div");K=l.substring(0,l.indexOf("px"));K=K.substring(K.lastIndexOf(" "));""!=d&&(x=this.parent.getImage(d),J=x.height);m=document.createElement("div");m.setAttribute("id",
"descartesPleca");J?(m.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+h+"; width: "+(n-30)+"px; height: "+(J-16)+"px; background: "+c+"; color: "+f+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),x.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),m.appendChild(x)):m.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+
h+"; width: "+(n-30)+"px; background: "+c+"; color: "+f+"; 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=k;P=document.createElement("div");if(1===parseInt(b)){N=0;Q=document.createElement("div");Q.innerHTML=g;document.body.appendChild(Q);R=K;do R-=N,Q.setAttribute("style","padding: 0px; margin: 0px; font: "+
l+"; font-size: "+R+"px; width: "+(n-30)+"px; line-height: "+R+"px;"),M=Q.offsetHeight,S=M/R,N=1;while(1<S&&8<R);document.body.removeChild(Q);P.setAttribute("style","padding: 0px; margin: 0px; font: "+l+"; font-size: "+R+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else P.setAttribute("style","padding: 0px; margin: 0px; font: "+l+"; line-height: 110%;");P.innerHTML=g;m.appendChild(F);m.appendChild(P);m.imageHeight=J;return m};a.LessonParser.prototype.split=function(a){if("string"!=
typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");D=[];A=B=0;H=!1;G=0;for(I=!1;B<a.length;)" "===a.charAt(B)&&!H&&B++," "!==a.charAt(B)&&!H&&(H=!0,G=B),"="===a.charAt(B)&&("'"===a.charAt(B+1)&&!I)&&(I=!0,D[A]=[a.substring(G,B)],G=B+2,B+=2),I&&"'"===a.charAt(B)&&(H=I=!1,D[A].push(a.substring(G,B)),A++),"="===a.charAt(B)&&("'"!==a.charAt(B+1)&&!I)&&(D[A]=[a.substring(G,B)],G=B+1,B++,O=a.substring(B).indexOf("="),-1===O?L=O=a.length:(O+=B,L=a.substring(B,O).lastIndexOf(" "),L=-1===L?a.length:L+B),
D[A].push(a.substring(G,L)),A++,H=!1,B=L),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){t=[];t.type="matrix";t.rows=a;t.cols=b;var d;u=0;for(p=b;u<p;u++){d=[];q=0;for(v=a;q<v;q++)d.push(0);t[u]=d}return t}function k(a,b){l=a.rows;m=a.cols;t=e(l,m);var d;for(u=0;u<l;u++)for(q=0;q<m;q++){for(p=d=0;p<m;p++)d+=a[p][u]*
b[q][p];t[q][u]=d}return t}function g(a,b,d){for(var c=e(d.length-1,d.length-1),f=0,g=c.length;f<g;f++)for(var h=0;h<g;h++)c[f][h]=f<a?h<b?d[f][h]:d[f][h+1]:f<b?d[f+1][h]:d[f+1][h+1];return c}function b(a){if(1<a.cols){for(var d=0,c=1,f=0,e=a.cols;f<e;f++)d+=c*a[0][f]*b(g(0,f,a)),c=-c;return d}return a[0][0]}if(a.loadLib)return a;var c=Math.floor,f,h,d,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){f=this.childs.length-1;lastChild=this.childs[f];lastChild.parent=null;this.childs[f]=a;a.parent=this;return a};a.Node.prototype.contains=function(a){if(this.value===a)return!0;for(var b=0,d=this.childs.length;b<d;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="-",d=new a.Node("compOperator","=="),r=new a.Node("number","0"),d.addChild(this),d.addChild(r),h=this.getRoot(),h.setAllEvaluateFunction(),h):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,d){a=b.variables[this.value];if("object"===typeof a)return a.evaluate(b);if(void 0==a&&(d||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 d,f;this.evaluate=function(a){d=this.childs[0].childs[0].evaluate(a);
try{return f=a.vectors[this.value][0>d?0:c(d)],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 h,p;this.evaluate=function(a){h=this.childs[0].childs[0].evaluate(a);p=this.childs[0].childs[1].evaluate(a);try{return f=a.matrices[this.value][0>h?0:c(h)][0>p?0:c(p)],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,d=this.childs[0].childs.length;b<d;b++)r[b]=this.childs[0].childs[b].evaluate(a);return"_Eval_"===this.value?(r[0]=0<r.length?r[0].toString():"",a.evalExpression(a.parser.parse(r[0].replace(a.parent.decimal_symbol_regexp,".")))):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;l=a.rows;m=a.cols;
t=e(l,m);for(u=0;u<l;u++)for(q=0;q<m;q++)t[q][u]=a[q][u]+b[q][u];return t}:"-"===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;l=a.rows;m=a.cols;t=e(l,m);for(u=0;u<l;u++)for(q=0;q<m;q++)t[q][u]=a[q][u]-b[q][u];return t}:"*"===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:k(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 d;d=D;var c=e(d.length,d.length),f=b(d);if(0===f)d=0;else{var f=1/f,h;if(1<d.length)for(var l=0,m=d.length;l<m;l++){h=f;for(var n=0;n<m;n++)c[n][l]=h*b(g(l,n,d)),h=-h;f=-f}else c[0][0]=f;d=c}a=0===d?e(a.rows,a.cols):k(a,d);return a}:"%"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a);D=this.childs[1].evaluate(a);return v-
c(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 A,H;this.evaluate=function(a){A=this.childs.length;B=[];if(1===A&&1===this.childs[0].childs.length&&"(expr)"===this.type)B=this.childs[0].childs[0].evaluate(a);else for(var b=0;b<A;b++){H=[];for(var d=0,c=this.childs[b].childs.length;d<c;d++)H.push(this.childs[b].childs[d].evaluate(a));B[b]=H}return B}}else if("asign"===this.type){var G,I,K,x,J,F;this.evaluate=function(a){G=this.childs[0];I=
this.childs[1];1===G.childs.length&&"square_bracket"===G.childs[0].type?(d=G.childs[0].childs,1===d.length?(K=d[0].evaluate(a),K=0>K?0:c(K),a.vectors[G.value][K]=I.evaluate(a)):2===d.length&&(x=d[0].evaluate(a),J=d[1].evaluate(a),x=0>x?0:c(x),J=0>J?0:c(J),a.matrices[G.value][x]||(a.matrices[G.value][x]=[]),a.matrices[G.value][x][J]=I.evaluate(a))):(F=I.evaluate(a),F.type?a.matrices[G.value]=F:"object"!==typeof a.variables[G.value]&&(a.variables[G.value]=F))}}};var l,m,t,q,u,p,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,d=this.childs.length;b<d;b++)a+=this.sep+this.childs[b].toString();return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f,h,d,r,l=/^\s+/,m=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,t=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,q=/^==|^!=|^<=|^<|^>=|^>|^#/,u=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,p=
/^=/,v=/^[\?\:]/,n=/^[\+\-\*\/\%\^]/,s=/^\[|^\]/,w=/^\(|^\)/,z=/^,/,C=/^;/;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function y(a,c,e){k.push({type:a,value:c});f=f.slice(e);b+=e;d++;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"));k=[];g=!1;b=0;f=a;d=
0;for(r="";a&&b<a.length;)if(g=b,"'"==f[0]){for(h=1;"'"!=f[h];)if(h<f.length)h++;else{console.log(">Error, unknown symbol: ["+f+"], in the string <<"+e+">>");return}c=f.substring(1,h);y("string",c,c.length+2)}else if(c=f.match(l))f=f.slice(c[0].length),b+=c[0].length,d++;else if(c=f.match(m))"number"===r&&k.push({type:"operator",value:"*"}),y("identifier",c[0],c[0].length);else if(c=f.match(t))y("number",c[0],c[0].length);else if(c=f.match(q)){var A=c[0];"#"==A&&(A="!=");y("compOperator",A,c[0].length)}else if(c=
f.match(u))A=c[0],"||"==A?A="|":"&&"==A?A="&":"~"==A&&(A="!"),y("boolOperator",A,c[0].length);else if((c=f.match(p))&&!f.match(/^==/))y("asign",c[0],c[0].length);else if(c=f.match(v))y("conditional",c[0],c[0].length);else if(c=f.match(n))y("operator",c[0],c[0].length);else if(c=f.match(s))y("square_bracket",c[0],c[0].length);else if(c=f.match(w))"("==c&&"number"===r&&k.push({type:"operator",value:"*"}),y("parentheses",c[0],c[0].length);else if(c=f.match(z))y("separator",c[0],c[0].length);else if(178===
f.charCodeAt(0))k.push({type:"operator",value:"^"}),y("number",2,1);else if(179===f.charCodeAt(0))k.push({type:"operator",value:"^"}),y("number",3,1);else if(c=f.match(C))y("final_of_expresion",c[0],c[0].length);else if(g==b){console.log("Error, simbolo no conocido: ["+f+"], en la cadena <<"+e+">>");return}return k};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 d=0,c=a.length;d<c;d++)y="string"==a[d].type?y+"&squot;"+a[d].value+"&squot;":"identifier"==a[d].type&&!a[d].value.match(E)?y+b+a[d].value:y+a[d].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,d){this.vectors[a][b]=d};a.Parser.prototype.getVector=function(a){this.vectors.hasOwnProperty(a)||(this.vectors[a]=[0,0,0]);return this.vectors[a]};a.Parser.prototype.setMatrix=function(a,b,d,c){this.matrices[a][b][d]=c};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,k,g,b,c,f,h,d,r,l,m,t;a.Parser.prototype.parse=function(q,u){(g=this.tokenizer.tokenize(q))||(g=[]);b=null;u=!u||!1;e=d=h=f=0;for(k=g.length;e<k;e++)if(r=g[e],l=r.value,m=r.type,"identifier"===m&&(e+1<k&&"parentheses"===g[e+1].type&&"("===g[e+1].value?this.getFunction(l):e+1<k&&"square_bracket"===g[e+1].type&&"["===
g[e+1].value?g[e+3]&&"square_bracket"===g[e+3].type&&"]"===g[e+3].value?this.getVector(l):this.getMatrix(l):this.getVariable(l)),"asign"===m&&u&&(m="compOperator",l="=="),"asign"===m)if(c=new a.Node(m,l),null!=b)if("identifier"===b.type)b.parent&&b.parent.replaceLastChild(c),c.addChild(b),b=c,u=!0;else if("square_bracket"===b.type)c.addChild(b.parent),b=c,u=!0;else{c.type="compOperator";c.value="==";for(u=!0;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(c.value);)b=b.parent;b.parent&&
b.parent.replaceLastChild(c);c.addChild(b);b=c}else{console.log("Error1: en la expresion <<"+q+">>, en el token {valor: "+l+", tipo: "+m+"}");break}else if("parentheses"===m&&"("===l||"square_bracket"===m&&"["===l)if(c=new a.Node(m,l),"("===l&&f++,"["===l&&h++,null===b)"("===l&&(new a.Node("(expr)","(expr)")).addChild(c),"["===l&&(new a.Node("[expr]","[expr]")).addChild(c),b=c;else if("operator"===b.type||"boolOperator"===b.type||"compOperator"===b.type||"conditional"===b.type||"asign"===b.type)b.addChild(c),
b=c;else if("sign"===b.type)b.addChild(c),b=c;else if("parentheses"===b.type&&"("===b.value)b.addChild(c),b=c;else if("square_bracket"===b.type&&"["===b.value)b.addChild(c),b=c;else if("parentheses"===b.type&&"()"===b.value)b.parent.addChild(c),b=c;else if("square_bracket"===b.type&&"[]"===b.value)b.parent.addChild(c),b=c;else if("identifier"===b.type)b.addChild(c),b=c;else{console.log("Error2: en la expresion <<"+q+">>, en el token ["+e+"] {valor: "+l+", tipo: "+m+"}");break}else if("parentheses"===
m&&")"===l)if(f--,null===b)console.log("Error3: en la expresion <<"+q+">>, en el token (valor:"+l+", 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 <<"+q+">>, en el token {valor: "+l+", tipo: "+m+"}");break}}else if("square_bracket"===m&&"]"===l)if(h--,null===b)console.log("Error5: en la expresion <<"+q+">>, en el token (valor:"+l+", 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 <<"+q+">>, en el token {valor: "+l+", tipo: "+m+"}");break}}else if("number"===m||"string"===m||"identifier"===m)if(c=new a.Node(m,l),null===b)b=c;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(c),b=c;else{console.log("Error7: en la expresion <<"+q+">>, en el token {valor: "+
l+", tipo: "+m+"}");break}else if("operator"===m||"compOperator"===m||"boolOperator"===m)if(c=new a.Node(m,l),null===b)if("-"===l||"+"===l)c.type="sign",c.value="sign"+l,b=c;else if("!"===l)b=c;else{console.log("Error8: en la expresion <<"+q+">>, en el token {valor: "+l+", 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&&("-"===l||"+"===l||"!"===l)||"parentheses"===
b.type&&"("===b.value&&("-"===l||"+"===l||"!"===l)){if("-"===l||"+"===l)c.type="sign",c.value="sign"+l;b.addChild(c);b=c}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(c.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(c);c.addChild(b);b=c}else{console.log("Error9: en la expresion <<"+
q+">>, en el token {valor: "+l+", tipo: "+m+"}");break}else if("conditional"===m)if(c=new a.Node(m,l),null!=b)if("?"===c.value){for(d++;b.parent&&this.getPrecedence(b.parent.value)>this.getPrecedence(c.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(c);c.addChild(b);b=c}else{for(d--;b&&b.parent&&"?"!=b.value;)b=b.parent;if(b&&"?"===b.value)b.value="?:";else{console.log("Error10: en la expresion <<"+q+">>, en el token {valor: "+l+", tipo: "+m+"}");break}}else{console.log("Error11: en la expresion <<"+
q+">>, en el token {valor: "+l+", 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 <<"+q+">>, en el token {valor: "+l+", tipo: "+m+"}");break}else{console.log("Error13: en la expresion <<"+q+">>, en el token {valor: "+l+", tipo: "+m+"}");break}0<f&&alert("Error, faltan parentesis por cerrar: "+q);0>f&&alert("Error, faltan parentesis por abrir: "+q);0<h&&alert("Error, faltan square bracketss por cerrar: "+
q);0>h&&alert("Error, faltan square bracketss por abrir: "+q);0!=d&&alert("Error, condicional incompleta: "+q);(t=b?b.getRoot():null)&&t.setAllEvaluateFunction();return t};a.Parser.prototype.getPrecedence=function(a){switch(a){case "=":return 1;case "(":return 2;case "[":return 2;case "?":return 2;case ":":return 3;case "?:":return 3;case "|":return 6;case "&":return 7;case "<":return 5;case "<=":return 5;case ">":return 5;case ">=":return 5;case "==":return 5;case "!=":return 5;case "+":return 6;
case "-":return 6;case "/":return 7;case "*":return 7;case "sign-":return 7;case "sign+":return 7;case "!":return 8;case "%":return 8;case "^":return 9;default:return 9}};a.Parser.prototype.registerDefaultValues=function(){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(d,c,f){return a.esCorrecto(d,c,b.evaluator,f)};this.functions.escorrecto=function(d,c,f){return a.escorrecto(d,c,b.evaluator,f)};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},"*")});this.functions._GetValues_=function(d,c){var f=a.openExternalFile(d),e=-1,g=-1,h=[];if(f){f=f.replace(/\r/g,"").split("\n");e=f.indexOf("<"+c+">");g=f.indexOf("</"+c+">");if(-1!=e&&-1!=g&&e<g)for(e+=1;e<g;e++)h=h.concat(f[e].split("\u00a6"));e=0;for(g=h.length;e<g;e++)f=h[e].split("="),
f[0]=f[0].trim(),""!=f[0]&&(isNaN(parseFloat(f[1]))?b.setVariable(f[0],f[1].replace(/^\s|\s$/g,"")):b.setVariable(f[0],parseFloat(f[1])))}};this.functions._GetMatrix_=function(d,c){var f=a.openExternalFile(d),e=-1,g=-1,h=[];h.type="matrix";if(f&&(f=f.replace(/\r/g,"").split("\n"),e=f.indexOf("<"+c+">"),g=f.indexOf("</"+c+">"),-1!=e&&-1!=g&&e<g)){for(e+=1;e<g;e++)h.push(f[e].split("\u00a6").map(function(a){return isNaN(parseFloat(a))?a.replace(/^\s|\s$/g,""):parseFloat(a)}));b.matrices[c]=h;b.setVariable(c+
".filas",h[0].length);b.setVariable(c+".columnas",h.length)}}};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,g,b){g=0>g?0:e(g);this.vectors[a][g]=b};a.Evaluator.prototype.getVector=function(a,g){g=0>g?0:e(g);return this.vectors[a][g]};a.Evaluator.prototype.setMatrix=function(a,g,b,c){g=0>g?0:e(g);b=0>b?0:e(b);this.matrices[a][g][b]=c};a.Evaluator.prototype.getMatrix=function(a,g,b){g=0>g?0:e(g);b=0>b?0:e(b);return this.matrices[a][g][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,k=!1;a.RTFNode=function(a,b,d,c){this.evaluator=a;this.type="rtfNode";this.value=b;this.nodeType=d;this.style=c;this.styleString=c.toString();this.color=c.textColor;this.underline=c.textUnderline;this.overline=c.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 g=0,b=0,c=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var f=0,h=this.children.length;f<h;f++)this.children[f].getTextMetrics()}else if("textLineBlock"==this.nodeType)this.spaceWidth=
a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("newLine"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);var d=a.getFontMetrics(this.styleString);this.baseline=d.baseline;this.descent=d.descent;this.ascent=d.ascent;this.w=d.w;this.h=d.h}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);d=a.getFontMetrics(this.styleString);this.baseline=d.baseline;this.descent=d.descent;this.ascent=d.ascent;var f=
this.value,r;"string"!=typeof this.value&&(h=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),r=void 0==this.fixed?k:this.fixed,f=this.evaluator.evalExpression(this.value,h,r),parseFloat(f)==f&&(f=parseFloat(f).toFixed(h),f=r?f:parseFloat(f),f=f.toString().replace(".",this.decimal_symbol)),f+=" ");this.w=a.getTextWidth(f,this.styleString);this.h=d.h}else if("formula"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("hyperlink"===
this.nodeType){f=a.getFontMetrics(this.styleString);this.baseline=f.baseline;this.descent=f.descent;this.ascent=f.ascent;this.w=a.getTextWidth(this.value,this.styleString);this.h=f.h;this.clickCacher=document.createElement("div");this.clickCacher.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; cursor: pointer;");var l=this;this.clickCacher.addEventListener("click",function(a){l.click=!0;window.open(l.URL,l.URL)})}else if("superIndex"==this.nodeType)this.spaceWidth=
a.getTextWidth(" ",this.styleString),r=g,d=b,h=c,f=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=f.ascent,this.descent=f.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),f=h/2-d+this.h,this.superIndexPos=f-this.ascent,this.ascent=f,this.descent=d,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=g,d=b,h=c,f=a.getFontMetrics(this.styleString),this.getBlockMetric(),
0>this.h&&(this.ascent=f.ascent,this.descent=f.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),this.subIndexPos=d+1,this.ascent=r,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("fraction"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);r=g;d=b;h=c;r=this.children[0];var m=this.children[1],f=a.getFontMetrics(r.styleString);r.getBlockMetric();m.getBlockMetric();0>r.h&&(r.h=f.h,r.w=this.spaceWidth);
0>m.h&&(m.h=f.h,m.w=this.spaceWidth);this.h=r.h+m.h-1;this.ascent=r.h+h/2-d;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=Math.max(r.w,m.w)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);d=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator," ","radicand",d),this.children[1].addChild(this.children[0]),this.children[0]=new a.RTFNode(this.evaluator," ","index",d);else if("index"!==
this.children[0].nodeType||"radicand"!==this.children[1].nodeType){r=new a.RTFNode(this.evaluator,"","radicand",d);f=0;for(h=this.children.length;f<h;f++)r.addChild(this.children[f]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",d);this.children[1]=r}f=this.children[0];h=this.children[1];0>=f.children.length&&(d=this.style.clone(),d.fontSize=parseInt(d.fontSize-0.2*d.fontSize),f.addChild(new a.RTFNode(this.evaluator," ","text",d)));0>=h.children.length&&h.addChild(new a.RTFNode(this.evaluator,
" ","text",this.style.clone()));f.getBlockMetric();h.getBlockMetric();this.ascent=h.h/2<f.h?h.h/2+f.h+2-h.descent:h.ascent+4;this.descent=h.descent;this.baseline=this.ascent;this.h=this.ascent+this.descent;this.w=f.w+h.w+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=g,d=b,h=c,d=this.children[0],h=this.children[1],r=this.children[2],d.getBlockMetric(),h.getBlockMetric(),r.getBlockMetric(),-1==d.ascent&&(m=a.getFontMetrics(d.styleString),d.ascent=
m.ascent,d.descent=m.descent,d.h=m.h),-1==h.ascent&&(m=a.getFontMetrics(h.styleString),h.ascent=m.ascent,h.descent=m.descent,h.h=m.h),f=a.getFontMetrics(this.styleString),this.ascent=f.h+h.h>r.ascent?f.h-f.descent+h.h:r.ascent,this.descent=d.h>r.descent?d.h+f.descent:r.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,f=this.style.clone(),f.fontType="Times New Roman",f.Bold="bold",f=f.toString(),f=a.getTextWidth(String.fromCharCode(8721),f),this.w=Math.max(d.w,h.w,f)+Math.max(r.w,
this.spaceWidth)+this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=g,d=b,h=c,d=this.children[0],h=this.children[1],r=this.children[2],d.getBlockMetric(),h.getBlockMetric(),r.getBlockMetric(),-1==d.ascent&&(m=a.getFontMetrics(d.styleString),d.ascent=m.ascent,d.descent=m.descent,d.h=m.h),-1==h.ascent&&(m=a.getFontMetrics(h.styleString),h.ascent=m.ascent,h.descent=m.descent,h.h=m.h),f=a.getFontMetrics(this.styleString),this.ascent=f.h+h.h>r.ascent?
f.h-f.descent+h.h:r.ascent,this.descent=d.h>r.descent?d.h+f.descent:r.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,f=this.style.clone(),f.fontSize*=1.5,f.fontType="Times New Roman",f.Bold="bold",f=f.toString(),f=a.getTextWidth(String.fromCharCode(8747),f),this.w=Math.max(d.w,h.w,f)+Math.max(r.w,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),r=g,d=b,h=c,d=this.children[0],h=this.children[1],r=this.children[2],
f=a.getFontMetrics(this.styleString),d.getBlockMetric(),h.getBlockMetric(),r.getBlockMetric(),-1==d.ascent&&(m=a.getFontMetrics(d.styleString),d.ascent=m.ascent,d.descent=m.descent,d.h=m.h),-1==h.ascent&&(m=a.getFontMetrics(h.styleString),h.ascent=m.ascent,h.descent=m.descent,h.h=m.h),-1==r.ascent&&(m=a.getFontMetrics(r.styleString),r.ascent=m.ascent,r.descent=m.descent,r.h=m.h),this.ascent=r.ascent,this.descent=Math.max(f.h,r.descent),this.baseline=this.ascent,this.h=this.ascent+this.descent,f=a.getTextWidth(" "+
String.fromCharCode(8594),this.styleString),0==d.w&&(d.w=this.spaceWidth),0==h.w&&(h.w=this.spaceWidth),0==r.w&&(r.w=this.spaceWidth),this.w=h.w+d.w+r.w+f+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);r=g;d=b;h=c;r=f.ascent;for(var m=f.descent,t=f.h,q=this.spaceWidth,u,p,f=0,h=this.children.length;f<h;f++)this.children[f].getBlockMetric(),u=this.children[f].h,p=this.children[f].w,t<u&&(t=u,r=this.children[f].ascent,
m=this.children[f].descent),q<p&&(q=p);this.childWidth=q+2*this.spaceWidth;this.childh=t;this.childAscent=r;this.childDescent=m;this.h=this.rows*t;this.ascent=this.h/2+d;this.descent=this.h-this.ascent;this.w=this.columns*this.childWidth+this.spaceWidth}else if("defparts"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);r=g;d=b;h=c;r=f.ascent;m=f.descent;t=f.h;q=this.spaceWidth;f=0;for(h=this.children.length;f<h;f++)this.children[f].getBlockMetric(),
u=this.children[f].h,p=this.children[f].w,t<u&&(t=u,r=this.children[f].ascent,m=this.children[f].descent),q<p&&(q=p);this.childWidth=q+2*this.spaceWidth;this.childh=t;this.childAscent=r;this.childDescent=m;this.h=this.parts*t;this.ascent=this.h/2+d;this.descent=this.h-this.ascent;this.w=q+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),d=a.getFontMetrics(this.styleString),this.baseline=d.baseline,this.descent=d.descent,this.ascent=d.ascent,this.w=
a.getTextWidth(this.value,this.styleString)+a.getTextWidth(" ",this.styleString),this.h=d.h):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),d=this.componentNumCtrl.h||0,this.baseline=Math.round(3*d/5),this.descent=Math.round(2*d/5),this.ascent=this.baseline,this.h=d,this.w=this.componentNumCtrl.w):"componentSpace"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentSpace=
this.evaluator.parent.getSpaceByCId(this.value),this.h=this.ascent=this.descent=this.baseline=0,this.w=this.componentSpace.w):console.log("Element i=unknown",this.nodeType)};a.RTFNode.prototype.getBlockMetric=function(){this.w=0;for(var a=-1,e=-1,d,k=0,l=this.children.length;k<l;k++){d=this.children[k];d.getTextMetrics();childAscent=d.ascent;childDescent=d.descent;this.w+=d.w;var m=childDescent;d=d.h;g=childAscent;b=m;c=d;e<childAscent&&(e=childAscent);a<childDescent&&(a=childDescent)}this.ascent=
e;this.descent=a;this.baseline=this.ascent;this.h=this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,b,d,c,g,m,t){this.stableWidth||(this.getTextMetrics(),e=c,k=g);t=t?-this.children[0].ascent:0;g=c=0;for(m=this.children.length;g<m;g++)0<g&&(c+=this.children[g-1].h),this.children[g].draw(a,b+0,d+t+c)};a.RTFNode.prototype.drawTextLineBlock=function(b,c,d){for(var e=0,g=0,m=this.children.length;g<m;g++)0<g&&(e+=this.children[g-1].w,"formula"==this.children[g-1].nodeType&&(e+=2*a.getTextWidth(" ",
this.children[g].styleString))),this.children[g].draw(b,c+e,d+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,d){for(var c=0,e=0,g=this.children.length;e<g;e++)0<e&&(c+=this.children[e-1].w),this.children[e].draw(a,b+this.spaceWidth+c,d)};a.RTFNode.prototype.drawText=function(a,b,d){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,d);if(this.underline){var c="bold"==this.style.textBold,e=c?1:0.5;
a.lineWidth=c?2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b-1,parseInt(d+this.descent/2)+e);a.lineTo(b-1+this.w,parseInt(d+this.descent/2)+e);a.stroke()}this.overline&&(e=(c="bold"==this.style.textBold)?2:1.5,a.lineWidth=c?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(b-1,parseInt(d-this.ascent)+e),a.lineTo(b-1+this.w,parseInt(d-this.ascent)+e),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,c,d){var g=Math.floor(0.5*this.spaceWidth),
l=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),m=void 0==this.fixed?k:this.fixed,t=this.evaluator.evalExpression(this.value,l,m);parseFloat(t).toString()===t.toString()&&(t=m?parseFloat(t).toFixed(l):parseFloat(parseFloat(t).toFixed(l)),t=(""+t).replace(".",this.decimal_symbol));null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";this.w=a.getTextWidth(t,this.styleString);b.fillText(t,g+c,d);this.underline&&(m=(l=
"bold"==this.style.textBold)?1:0.5,b.lineWidth=l?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(g+c-1,parseInt(d+this.descent/2)+m),b.lineTo(g+c-1+this.w,parseInt(d+this.descent/2)+m),b.stroke());this.overline&&(m=(l="bold"==this.style.textBold)?2:1.5,b.lineWidth=l?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(g+c-1,parseInt(d-this.ascent)+m),b.lineTo(g+c-1+this.w,parseInt(d-this.ascent)+m),b.stroke());this.w+=2*g};a.RTFNode.prototype.drawHyperlink=
function(a,b,d){this.clickCacher.parentNode||(a.canvas.nextSibling.className?a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling.nextSibling):a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling),this.clickCacher.style.left=b-2+"px",this.clickCacher.style.top=d-this.ascent-2+"px");a.save();this.click?(a.fillStyle="red",a.strokeStyle="red"):(a.fillStyle="blue",a.strokeStyle="blue");a.font=this.styleStr;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,
b-1,d);var c="bold"==this.style.textBold,e=c?1:0.5;a.lineWidth=c?2:1;a.beginPath();a.moveTo(b-1,Math.ceil(d+this.descent/2)+e-2);a.lineTo(b-1+this.w,Math.ceil(d+this.descent/2)+e-2);a.stroke();a.restore()};a.RTFNode.prototype.drawRadical=function(a,b,d){var c=Math.floor(this.spaceWidth);this.children[0].draw(a,b,Math.floor(d+this.children[1].descent-this.children[1].h/2-this.children[0].descent));this.children[1].draw(a,b+1.5*c+this.children[0].w,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].h/2));a.lineTo(b+this.children[0].w,Math.floor(d+this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w+0.5*c,d+this.children[1].descent);a.lineTo(b+this.children[0].w+1*c,d-this.children[1].ascent);a.lineTo(b+this.children[0].w+2*c+this.children[1].w,d-this.children[1].ascent);a.stroke()};a.RTFNode.prototype.drawFraction=function(a,b,d){this.children[0].draw(a,b+(this.w-this.children[0].w)/
2,d-this.ascent);this.children[1].draw(a,b+(this.w-this.children[1].w)/2,d-this.ascent+this.children[0].h-1);var c=Math.floor(0.5*this.spaceWidth);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b+c,parseInt(d-this.ascent+this.children[0].h)-0.5);a.lineTo(b-c+this.w-1,parseInt(d-this.ascent+this.children[0].h)-0.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,b,d){for(var c=0,e=0,g=this.children.length;e<g;e++)0<e&&(c+=this.children[e-1].w),this.children[e].draw(a,
b+c,d+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,d){for(var c=0,e=0,g=this.children.length;e<g;e++)0<e&&(c+=this.children[e-1].w),this.children[e].draw(a,b+c,d+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,d){for(var c=0,e=0,g=this.children.length;e<g;e++)0<e&&(c+=this.children[e-1].w),this.children[e].draw(a,b+c,d-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,c,d){var e=a.getFontMetrics(this.styleString),g=" "+String.fromCharCode(8594),k=a.getTextWidth(g,
this.styleString);this.children[0].draw(b,c,d+e.descent+this.children[0].ascent);this.children[1].draw(b,c+this.children[0].w+k,d+e.descent+this.children[1].ascent);this.children[2].draw(b,c+k+this.children[0].w+this.children[1].w,d);null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",c+this.children[0].w,d);b.fillText(g,c+this.children[0].w,d+e.descent+this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(b,
c,d){var e=this.style.clone();e.fontSize*=1.5;e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),g=a.getTextWidth(String.fromCharCode(8747),e),k=a.getFontMetrics(e),t=Math.max(this.children[0].w,this.children[1].w,Math.floor(1.5*g));this.children[0].draw(b,c+g,d+k.descent+this.children[0].ascent);this.children[1].draw(b,c+g+this.spaceWidth/2,d-this.ascent+this.children[1].ascent);this.children[2].draw(b,c+t+g,d);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline=
"alphabetic";b.fillText(String.fromCharCode(8747),c,d+k.descent/2)};a.RTFNode.prototype.drawSum=function(b,c,d){var e=this.style.clone();e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),g=a.getTextWidth(String.fromCharCode(8721),e),k=a.getFontMetrics(this.styleString),t=Math.max(this.children[0].w,this.children[1].w,g);this.children[0].draw(b,c+(t-this.children[0].w)/2,d+k.descent+this.children[0].ascent);this.children[1].draw(b,c+(t-this.children[1].w)/2,d-k.ascent-this.children[1].descent);
this.children[2].draw(b,c+t,d);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),c+Math.floor((t-g)/2),d-5)};a.RTFNode.prototype.drawMatrix=function(a,b,d){for(var c,e,g=0,k=this.children.length;g<k;g++)c=g%this.columns,e=Math.floor(g/this.columns),this.children[g].draw(a,2*this.spaceWidth+b+c*this.childWidth,d-this.ascent+this.childAscent+e*this.childh);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.w-this.spaceWidth)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/2)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/2)-0.5,d+this.descent+0.5);a.lineTo(Math.floor(b+
this.w-this.spaceWidth)-0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawDefparts=function(a,b,d){for(var c=0,e=this.children.length;c<e;c++)this.children[c].draw(a,b+3*this.spaceWidth,d-this.ascent+this.childAscent+c%this.parts*this.childh);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(parseInt(b+2*this.spaceWidth)+0.5,d-this.ascent+0.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,d-this.ascent+4.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,d+this.descent-
this.h/2-4.5);a.lineTo(b-0.5,d+this.descent-this.h/2);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,d+this.descent-this.h/2+4.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,d+this.descent-4.5);a.lineTo(parseInt(b+2*this.spaceWidth)+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.w/2,d))};a.RTFNode.prototype.drawGenericBlock=function(a,b,d){for(var c=0,e=0,g=this.children.length;e<g;e++)0<e&&(c+=this.children[e-1].w),this.children[e].draw(a,b+c,d)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,b,d){this.parent.getTextMetrics();this.componentNumCtrl.expresion=
this.evaluator.parser.parse("("+b+","+(d-this.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)};a.RTFNode.prototype.toHTML=function(){var a="";if("textLineBlock"===this.nodeType||
"textBlock"===this.nodeType)for(var b=0,d=this.children.length;b<d;b++)a+=this.children[b].toHTML();else"text"===this.nodeType?a="<span "+this.style.toCSS()+">"+this.value+"</span>":"newLine"===this.nodeType&&(a="<span "+this.style.toCSS()+">"+this.value+"<br /></span>");return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=String.fromCharCode,k,g,b,c,f,h,d,r,l,m,t;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=function(a){if(a)a=a.replace(/\&gt;/g,
">").replace(/\&lt;/g,"<").replace(/\&quote;/g,"''").replace(/\&squot;/g,"'").replace(/\\rquote /g,"'").replace(/\\endash /g,"-").replace(/\n/g," ").replace(/\r/g,"").replace(/\\uc(\d+) /g,"").replace(/\\uc(\d+)/g,"");else return[];k=[];g=a.length;k=[];b="";f=c=0;d=a.charAt(0);r=!1;for(l="text";c<g;)h=d,d=a.charAt(c+1),r?"\\"===d||"{"===d||"}"===d||" "===d||";"===d?(r=!1,b+=h," "===d&&(c++,d=a.charAt(c+1)),(m=b.match(/^\'([0-9a-f]{2})/))?(t="","text"===l&&(t=k.pop().value),b=t+=e(parseInt(m[1],16))+
b.substring(3)):(m=b.match(/^u[0-9]+/))?(t="","text"===l&&(t=k.pop().value),b=t+=e(m[0].substring(1))):("{"===b||"}"===b?(k.push({type:"text",value:b}),l="text"):(k.push({type:"controlWord",value:b}),l="controlWord"),b="")):b+=h:"\\"===h?(r=!0,""!==b&&(k.push({type:"text",value:b}),l="text"),b=""):"{"===h?(f++,""!==b&&k.push({type:"text",value:b}),b="",k.push({type:"openBlock",value:f}),l="openBlock"):"}"===h?(""!==b&&k.push({type:"text",value:b}),b="",k.push({type:"closeBlock",value:f}),l="closeBlock",
f--):b+=h,c++;""!==b&&k.push({type:"text",value:b});return k};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b,c,f,h,d,r,l,m,t,q,u,p,v,n,s,w,z,C,y,E,D,B,A,H,G,I,K;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=new a.RTFTokenizer};a.RTFParser.prototype.parse=function(x){x=e=this.tokenizer.tokenize(x);for(var J=[],F=!1,P=!1,Q=[],M=0,R=x.length;M<R;M++){"openBlock"==x[M].type&&Q.push(x[M].value);"closeBlock"==x[M].type&&(Q.pop(),0>=Q.length&&(F=!1));if("controlWord"==
x[M].type&&("expr"==x[M].value||"decimals"==x[M].value))P=!0;"controlWord"==x[M].type&&"mjaformula"==x[M].value&&(F=!0);if("text"==x[M].type&&F&&!P){for(var S=0,N=x[M].value,O="",L=0,U=N.length;L<U;L++)if("("==N.charAt(L)||")"==N.charAt(L)||"+"==N.charAt(L)||"-"==N.charAt(L)||"*"==N.charAt(L)||"="==N.charAt(L))O=N.substring(S,L),""!=O&&J.push({type:"text",value:O}),J.push({type:N.charAt(L),value:N.charAt(L)}),S=L+1;O=N.substring(S,L);""!=O&&J.push({type:"text",value:O})}else J.push(x[M]),"text"==
x[M].type&&P&&(P=!1)}e=J;k={};b=2;if("openBlock"==e[0].type&&"fonttbl"==e[1].value){for(g=e[0].value;"closeBlock"!=e[b].type&&e[b].value!=g;)k[e[b].value]=e[b+2].value.substring(0,e[b+2].value.length-1),b+=3;b++}c={};f=0;if("openBlock"==e[b].type&&"colortbl"==e[b+1].value){g=e[b++].value;for(b++;"closeBlock"!=e[b].type&&e[b].value!=g;)h=parseInt(e[b++].value.substring(3)).toString(16),d=parseInt(e[b++].value.substring(5)).toString(16),r=parseInt(e[b++].value.substring(4)).toString(16),";"===e[b].value&&
b++,c[f++]="#"+(2>h.length?"0"+h:h)+(2>d.length?"0"+d:d)+(2>r.length?"0"+r:r);b++}l=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");m=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");l.addChild(m);u=q=t=null;z=w=s=n=v=p=!1;C=[new a.FontStyle(20,"Arial","","",!1,!1,null)];y=C[0];E=!0;B=D=-1;A=[];K=I=G=H=!1;x=b;for(J=e.length;x<J;x++)if("controlWord"==e[x].type&&k[e[x].value])y.fontType=k[e[x].value];else if("controlWord"==e[x].type&&e[x].value.match(/^fs(\d+)/))y.fontSize=parseInt(e[x].value.match(/^fs(\d+)/)[1]/
2);else if("controlWord"==e[x].type&&"b"==e[x].value)y.textBold="bold";else if("controlWord"==e[x].type&&"b0"==e[x].value)y.textBold="";else if("controlWord"==e[x].type&&"i"==e[x].value)y.textItalic="italic";else if("controlWord"==e[x].type&&"i0"==e[x].value)y.textItalic="";else if("controlWord"==e[x].type&&"ul"==e[x].value)y.textUnderline=!0;else if("controlWord"==e[x].type&&"ulnone"==e[x].value)y.textUnderline=!1;else if("controlWord"==e[x].type&&"ol"==e[x].value)y.textOverline=!0;else if("controlWord"==
e[x].type&&"olnone"==e[x].value)y.textOverline=!1;else if("controlWord"==e[x].type&&e[x].value.match(/^cf(\d+)/))y.textColor=c[parseInt(e[x].value.substring(2))];else if("openBlock"==e[x].type)D=e[x].value,y=y.clone(),C.push(y),A.push(null);else if("closeBlock"==e[x].type)e[x].value==B&&(B=-1,p=!1,m=m.parent),C.pop(),y=C[C.length-1],A.pop();else if("controlWord"==e[x].type&&"par"==e[x].value){m.addChild(new a.RTFNode(this.evaluator,"","newLine",y.clone()));l=new a.RTFNode(this.evaluator,"","textLineBlock",
y.clone());if("textBlock"!=m.nodeType)for(m=m.parent;"textBlock"!=m.nodeType;)m=m.parent;m.addChild(l);m=l}else if("controlWord"==e[x].type&&"mjaformula"==e[x].value)H=!0,B=D,p=!0,l=new a.RTFNode(this.evaluator,"","formula",y.clone()),m.addChild(l),m=l,A[A.length-1]=l;else if("controlWord"==e[x].type&&("fraction"==e[x].value||"radicand"==e[x].value||"radical"==e[x].value||"what"==e[x].value||"sum"==e[x].value||"integral"==e[x].value||"limit"==e[x].value))F=A[A.length-2].style.clone(),l=new a.RTFNode(this.evaluator,
"",e[x].value,F),A[A.length-2].addChild(l),A[A.length-1]=l;else if("controlWord"==e[x].type&&"index"==e[x].value||"to"==e[x].value||"from"==e[x].value)F=A[A.length-2].style.clone(),F.fontSize=parseInt(F.fontSize-0.2*F.fontSize),8>F.fontSize&&(F.fontSize=8),l=new a.RTFNode(this.evaluator,"",e[x].value,F),A[A.length-2].addChild(l),A[A.length-1]=l;else if("controlWord"==e[x].type&&("num"==e[x].value||"den"==e[x].value))F=A[A.length-2].style.clone(),F.fontSize=Math.round(F.fontSize-0.1*F.fontSize),8>
F.fontSize&&(F.fontSize=8),"num"==e[x].value?l=new a.RTFNode(this.evaluator,"","numerator",F):"den"==e[x].value&&(l=new a.RTFNode(this.evaluator,"","denominator",F)),A[A.length-2].addChild(l),A[A.length-1]=l;else if("controlWord"==e[x].type&&("subix"==e[x].value||"supix"==e[x].value))F=A[A.length-2].style.clone(),F.fontSize=Math.floor(F.fontSize-F.fontSize/3),8>F.fontSize&&(F.fontSize=8),"subix"==e[x].value?l=new a.RTFNode(this.evaluator,"","subIndex",F):"supix"==e[x].value&&(l=new a.RTFNode(this.evaluator,
"","superIndex",F)),l.originalStyle=A[A.length-2].style.clone(),A[A.length-2].addChild(l),A[A.length-1]=l;else if("controlWord"==e[x].type&&("defparts"==e[x].value||"matrix"==e[x].value||"element"==e[x].value))F=A[A.length-2].style.clone(),l=new a.RTFNode(this.evaluator,"",e[x].value,F),A[A.length-2].addChild(l),A[A.length-1]=l,"defparts"==e[x].value?u=l:"matrix"==e[x].value&&(q=l);else if("controlWord"==e[x].type&&"parts"==e[x].value)z=!0;else if("text"==e[x].type&&z)u.parts=parseInt(e[x].value),
z=!1;else if("controlWord"==e[x].type&&"rows"==e[x].value)s=!0;else if("text"==e[x].type&&s)q.rows=parseInt(e[x].value),s=!1;else if("controlWord"==e[x].type&&"columns"==e[x].value)w=!0;else if("text"==e[x].type&&w)q.columns=parseInt(e[x].value),w=!1;else if("controlWord"==e[x].type&&"expr"==e[x].value)E=!1,v=!0;else if("controlWord"==e[x].type&&"decimals"==e[x].value)n=!0;else if("text"==e[x].type&&n)t.decimals=this.evaluator.parser.parse(e[x].value+""),n=!1;else if("controlWord"==e[x].type&&"fixed1"==
e[x].value)t.fixed=!0;else if("controlWord"==e[x].type&&"fixed0"==e[x].value)t.fixed=!1;else if(!("controlWord"==e[x].type&&"component"==e[x].value))if("controlWord"==e[x].type&&"NumCtrl"==e[x].value)G=!0;else if("controlWord"==e[x].type&&"Space"==e[x].value)I=!0;else if("controlWord"==e[x].type&&"hyperlink"==e[x].value)K=!0;else if("text"==e[x].type&&K){textContent=e[x].value.split("|")[0];F=y.clone();l=new a.RTFNode(this.evaluator,textContent,"hyperlink",F);l.URL=e[x].value.split("|")[1];if("textLineBlock"!=
m.nodeType)for(m=m.parent;"textLineBlock"!=m.nodeType;)m=m.parent;m.addChild(l);K=!1}else if("text"==e[x].type&&G)l=new a.RTFNode(this.evaluator,e[x].value,"componentNumCtrl",y.clone()),m.addChild(l),G=!1;else if("text"==e[x].type&&I)l=new a.RTFNode(this.evaluator,e[x].value,"componentSpace",y.clone()),m.addChild(l),I=!1;else if("text"==e[x].type&&v)F=A[A.length-2].style.clone(),textContent=this.evaluator.parser.parse(e[x].value),l=new a.RTFNode(this.evaluator,textContent,"dynamicText",F),A[A.length-
2].addChild(l),t=A[A.length-1]=l,v=!1;else if("text"==e[x].type&&!v&&!p){textContent=e[x].value;l=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(l)}else if("text"==e[x].type&&!v&&p)textContent=e[x].value,l=new a.RTFNode(this.evaluator,textContent,"text",A[A.length-1].style.clone()),A[A.length-1].addChild(l);else if("("==e[x].type||")"==e[x].type)F=A[A.length-1].style.clone(),F.textItalic="",
l=new a.RTFNode(this.evaluator,e[x].type,"mathSymbol",F),A[A.length-1].addChild(l);else if("+"==e[x].type||"-"==e[x].type||"*"==e[x].type||"="==e[x].type)l=new a.RTFNode(this.evaluator,e[x].type,"mathSymbol",A[A.length-1].style.clone()),A[A.length-1].addChild(l);if(null!=m){var T=m.getRoot();T.stableWidth=E;T.getTextMetrics();T.hasFormula=H}return T};a.FontStyle=function(a,b,d,c,e,g,f){this.fontSize=a;this.fontType=b;this.textItalic=d;this.textBold=c;this.textUnderline=e;this.textOverline=g;this.textColor=
f};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,k,g,b,c,f,h,d,r,l,m,t,q,u;a.Space=function(b,d){this.parent=b;k=this.evaluator=this.parent.evaluator;g=k.parser;this.id="";this.values=d;this.type="R2";this.xExpr=g.parse("0");this.yExpr=g.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=g.parse("1");this.fixed=2!=b.version?!1:!0;this.scale=48;this.Oy=this.Ox=0;this.image=new Image;this.image.onload=function(){this.ready=
1};this.imageSrc="";this.bg_display="topleft";this.background="descinst.com.mja.descartes.DescartesJS.class"===b.code||b.arquimedes?new a.Color("f0f8fa"):new a.Color("ffffff");this.net=2!=b.version?new a.Color("c0c0c0"):"";this.net10=2!=b.version?new a.Color("808080"):"";this.axes=2!=b.version?new a.Color("808080"):"";this.text=new a.Color("ffafaf");this.numbers=!1;this.x_axis=2!=b.version?"":" ";this.y_axis=2!=b.version?"":" ";this.sensitive_to_mouse_movements=!1;this.cID="";this.mouse_y=this.mouse_x=
0;this.ctrs=[];this.graphicsCtr=[];this.graphics=[];this.backgroundGraphics=[];this.zIndex=b.zIndex;this.plecaHeight=b.plecaHeight||0;this.displaceRegionNorth=b.displaceRegionNorth||0;this.displaceRegionWest=b.displaceRegionWest||0;for(var c in d)d.hasOwnProperty(c)&&(this[c]=d[c]);this.init()};a.Space.prototype.init=function(){e=this.parent;k=this.evaluator;b=this.id;this.displaceRegionNorth=e.displaceRegionNorth||0;this.displaceRegionWest=e.displaceRegionWest||0;void 0!=this.wExpr&&(this.w=(parseInt(e.container.width)-
this.displaceRegionWest)*parseFloat(this.wExpr)/100);void 0!=this.hExpr&&(this.h=(parseInt(e.container.height)-this.displaceRegionNorth)*parseFloat(this.hExpr)/100);h=parseInt(e.container.height);d=parseInt(e.container.width);this.x=k.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=k.evalExpression(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+"px",this.container.style.top=this.y+"px");0<=this.y?(c=h-this.y,this.h>c&&(this.h=c)):
(c=this.h+this.y,this.h=c>=h?h:c);0<=this.x?(f=d-this.x,this.w>f&&(this.w=f)):(f=this.w+this.x,this.w=f>=d?d:f);if(""!=this.imageSrc||!this.imageSrc.trim().toLowerCase().match(/vacio.gif$/))this.image=e.getImage(this.imageSrc);this.OxExpr&&(l=this.OxExpr,"%"===l[l.length-1]?this.Ox=this.w*parseFloat(l)/100:(r=parseFloat(l),r!=l&&(r=0),this.Ox=r));this.OyExpr&&(m=this.OyExpr,"%"===m[m.length-1]?this.Oy=this.h*parseFloat(m)/100:(r=parseFloat(m),r!=m&&(r=0),this.Oy=r));""!==this.id&&2!==e.version?(k.setVariable(b+
"._w",this.w),k.setVariable(b+"._h",this.h),k.setVariable(b+".escala",this.scale),k.setVariable(b+".Ox",this.Ox),k.setVariable(b+".Oy",this.Oy),k.setVariable(b+".mouse_x",0),k.setVariable(b+".mouse_y",0),k.setVariable(b+".mouse_pressed",0),k.setVariable(b+".mouse_clicked",0),k.setVariable(b+".clic_izquierdo",0)):(r=k.getVariable("_w"),void 0===r&&(r=this.w),k.setVariable("_w",r),r=k.getVariable("_h"),void 0===r&&(r=this.h),k.setVariable("_h",r),r=k.getVariable("escala"),void 0===r&&(r=this.scale),
k.setVariable("escala",r),r=k.getVariable("Ox"),void 0===r&&(r=this.Ox),k.setVariable("Ox",r),r=k.getVariable("Oy"),void 0===r&&(r=this.Oy),k.setVariable("Oy",r),k.setVariable("mouse_x",0),k.setVariable("mouse_y",0),k.setVariable("mouse_pressed",0),k.setVariable("mouse_clicked",0),k.setVariable("clic_izquierdo",0),""===this.x_axis&&(""===this.y_axis&&2==e.version)&&(this.axes=""));this.w_2=this.w/2;this.h_2=this.h/2};a.Space.prototype.addCtr=function(a){"graphic"===a.type?this.graphicsCtr.push(a):
this.ctrs.push(a)};a.Space.prototype.addGraph=function(a){a.background&&"R3"!==this.type?this.backgroundGraphics.push(a):this.graphics.push(a)};a.Space.prototype.getRelativeX=function(a){return(parseInt(a)-this.w_2-this.Ox)/this.scale};a.Space.prototype.getRelativeY=function(a){return(-parseInt(a)+this.h_2+this.Oy)/this.scale};a.Space.prototype.getAbsoluteX=function(a){return a*this.scale+this.w_2+this.Ox};a.Space.prototype.getAbsoluteY=function(a){return-a*this.scale+this.h_2+this.Oy};a.Space.prototype.findOffset=
function(){t=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(q=this.container.style.display);this.container.style.display="block";if(t.getBoundingClientRect){var a=t.getBoundingClientRect();this.offsetLeft=a.left;this.offsetTop=a.top}else for(;t;)t.tagName&&"html"!==t.tagName.toLowerCase()?(this.offsetLeft+=t.offsetLeft||0,this.offsetTop+=t.offsetTop||0,t=t.parentNode):t=null;this.container&&this.container.style&&(this.container.style.display=q)};a.Space.prototype.getCursorPosition=
function(b){u=a.getCursorPosition(b);return{x:u.x-this.offsetLeft,y:u.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){var e,k;if(a.loadLib)return a;var g=Math.floor,b=Math.round,c=2*Math.PI,f=a.convertFont("SansSerif,PLAIN,12"),h=a.convertFont("Monospaced,PLAIN,12"),d,r,l,m,t,q,u,p,v,n,s,w,z,C,y,E,D,B,A,H,G,I,K,x,J,F,P,Q,M;a.Space2D=function(b,c){a.Space.call(this,b,c);d=this;d.backgroundCanvas=document.createElement("canvas");d.backgroundCanvas.setAttribute("id",d.id+"_background");
d.backgroundCanvas.setAttribute("width",d.w+"px");d.backgroundCanvas.setAttribute("height",d.h+"px");d.backgroundCtx=d.backgroundCanvas.getContext("2d");d.backgroundCtx.imageSmoothingEnabled=!1;d.backgroundCtx.mozImageSmoothingEnabled=!1;d.backgroundCtx.webkitImageSmoothingEnabled=!1;d.canvas=document.createElement("canvas");d.canvas.setAttribute("id",d.id+"_canvas");d.canvas.setAttribute("width",d.w+"px");d.canvas.setAttribute("height",d.h+"px");d.canvas.setAttribute("class","DescartesSpace2DCanvas");
d.canvas.setAttribute("style","z-index: "+d.zIndex+";");d.ctx=d.canvas.getContext("2d");d.ctx.imageSmoothingEnabled=!1;d.ctx.mozImageSmoothingEnabled=!1;d.ctx.webkitImageSmoothingEnabled=!1;d.graphicControlContainer=document.createElement("div");d.graphicControlContainer.setAttribute("id",d.id+"_graphicControls");d.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+d.zIndex+";");d.numericalControlContainer=document.createElement("div");d.numericalControlContainer.setAttribute("id",
d.id+"_numericalControls");d.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+d.zIndex+";");d.container=document.createElement("div");d.container.setAttribute("id",d.id);d.container.setAttribute("class","DescartesSpace2DContainer");d.container.setAttribute("style","left: "+d.x+"px; top: "+d.y+"px; z-index: "+d.zIndex+";");d.parent.arquimedes&&"#f0f8fa"===d.background.getColor()&&(d.container.style.border="1px solid #b8c4c8");d.container.appendChild(d.backgroundCanvas);
d.container.appendChild(d.canvas);d.container.appendChild(d.graphicControlContainer);d.container.appendChild(d.numericalControlContainer);b.container.insertBefore(d.container,b.loader);d.parent.images[d.id+".image"]=d.canvas;d.parent.images[d.id+".image"].ready=1;d.parent.images[d.id+".image"].complete=!0;d.evaluator.setVariable(d.id+".image",d.id+".image");d.parent.images[d.id+".back"]=d.backgroundCanvas;d.parent.images[d.id+".back"].ready=1;d.parent.images[d.id+".back"].complete=!0;d.evaluator.setVariable(d.id+
".back",d.id+".back");""!==d.id&&2!==b.version?(d.OxString=d.id+".Ox",d.OyString=d.id+".Oy",d.scaleString=d.id+".escala",d.wString=d.id+"._w",d.hString=d.id+"._h",d.mxString=d.id+".mouse_x",d.myString=d.id+".mouse_y",d.mpressedString=d.id+".mouse_pressed",d.mclickedString=d.id+".mouse_clicked",d.mclicizquierdoString=d.id+".clic_izquierdo"):(d.OxString="Ox",d.OyString="Oy",d.scaleString="escala",d.wString="_w",d.hString="_h",d.mxString="mouse_x",d.myString="mouse_y",d.mpressedString="mouse_pressed",
d.mclickedString="mouse_clicked",d.mclicizquierdoString="clic_izquierdo");"descartesJS_scenario"!==d.id&&d.registerMouseAndTouchEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){d=this;d.uber.init.call(d);d.canvas&&(d.backgroundCanvas.setAttribute("width",d.w+"px"),d.backgroundCanvas.setAttribute("height",d.h+"px"),d.canvas.setAttribute("width",d.w+"px"),d.canvas.setAttribute("height",d.h+"px"));d.container&&d.findOffset()};a.Space2D.prototype.update=function(a){d=this;r=d.evaluator;
l=d.parent;r.setVariable(d.wString,d.w);r.setVariable(d.hString,d.h);d.drawIfValue=0<r.evalExpression(d.drawif);if(d.drawIfValue){t=d.x!==r.evalExpression(d.xExpr)+d.displaceRegionWest;q=d.y!==r.evalExpression(d.yExpr)+l.plecaHeight+d.displaceRegionNorth;d.spaceChange=a||t||q||d.drawBefore!==d.drawIfValue||d.Ox!==r.getVariable(d.OxString)||d.Oy!==r.getVariable(d.OyString)||d.scale!==r.getVariable(d.scaleString);d.x=t?r.evalExpression(d.xExpr)+d.displaceRegionWest:d.x;d.y=q?r.evalExpression(d.yExpr)+
l.plecaHeight+d.displaceRegionNorth:d.y;d.Ox=r.getVariable(d.OxString);d.Oy=r.getVariable(d.OyString);d.scale=r.getVariable(d.scaleString);d.drawBefore=d.drawIfValue;1E-6>d.scale?(d.scale=1E-6,r.setVariable(d.scaleString,1E-6)):1E6<d.scale&&(d.scale=1E6,r.setVariable(d.scaleString,1E6));if(t||q)d.container.style.left=d.x+"px",d.container.style.top=d.y+"px",d.findOffset();d.container.style.display="block";d.drawTrace=!d.spaceChange&&!d.click;d.spaceChange&&d.drawBackground();d.draw()}else d.container.style.display=
"none"};a.Space2D.prototype.drawBackground=function(){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));p=this.scale;v=0;for(n=0>this.w+this.h?0:this.w+this.h;p>n;)p/=10,v++;for(;p<n/10;)p*=10;m.lineWidth=1;""!==this.net&&(m.strokeStyle=this.net.getColor(),this.drawMarks(m,p/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,p,-1);if(""!==this.axes){m.strokeStyle=this.axes.getColor();m.beginPath();if(""!==this.x_axis||2!==this.parent.version)m.moveTo(0,g(this.h/2+this.Oy)+0.5),m.lineTo(this.w,g(this.h/2+this.Oy)+0.5);if(""!==this.y_axis||2!==this.parent.version)m.moveTo(g(this.w/2+this.Ox)+0.5,0),m.lineTo(g(this.w/2+this.Ox)+0.5,this.h);m.stroke();this.drawMarks(m,p,4);this.drawMarks(m,p/2,2);this.drawMarks(m,p/10,1)}if(""!==this.x_axis||""!==this.y_axis)m.fillStyle=""!==this.axes?
this.axes.getColor():"black",m.font=f,m.textAlign="right",m.textBaseline="alphabetic",m.fillText(this.x_axis,g(this.w)-2,g(this.h/2+this.Oy)+12),m.fillText(this.y_axis,g(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(m.fillStyle=this.axes.getColor(),m.font=f,m.textAlign="start",m.textBaseline="bottom",p>(this.w+this.h)/2?this.drawNumbers(m,p/5,p<=this.scale?v+1:v):p>(this.w+this.h)/4?this.drawNumbers(m,p/2,p<=this.scale?v+1:v):this.drawNumbers(m,p,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++)u=this.graphics[a],""!==u.trace&&this.drawTrace&&u.drawTrace(),u.draw();a=0;for(b=this.graphicsCtr.length;a<b;a++)this.graphicsCtr[a].update(),this.graphicsCtr[a].draw();""!=this.text&&(this.click&&"L"===this.whichButton)&&(m.fillStyle=this.text.getColor(),m.strokeStyle=m.fillStyle,m.lineWidth=1,m.font=h,m.textAlign=
"center",m.textBaseline="alphabetic",G=1>=this.scale?this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length),I=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),K="("+G+","+I+")",x=g(m.measureText(K).width/2),J=this.getAbsoluteX(this.mouse_x),F=this.getAbsoluteY(this.mouse_y),P=g(J),Q=g(F-10),P+x>this.w?P=this.w-x:0>P-x&&(P=x),Q+1>this.h?Q=this.h:0>Q-14&&(Q=15),m.fillText(K,P,Q),m.beginPath(),m.arc(J,F,2.5,0,c,!0),m.stroke())};a.Space2D.prototype.drawMarks=
function(a,d,c){s=this.w;w=this.h;D=0;B=s;A=0;H=w;y=g(s/2+this.Ox);E=g(w/2+this.Oy);0<=c&&(D=y-c,B=y+c,A=E-c,H=E+c);a.beginPath();for(c=-b(y/d);(z=y+b(c*d))<s;c++)a.moveTo(z+0.5,A+0.5),a.lineTo(z+0.5,H+0.5);for(c=-b(E/d);(C=E+b(c*d))<w;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;w=this.h;y=g(s/2+this.Ox);E=g(w/2+this.Oy);for(c=-b(y/d);(z=y+b(c*d))<s;c++)a.fillText(parseFloat((c*d/this.scale).toFixed(4)),z+1,E-2);for(c=-b(E/d);(C=
E+b(c*d))<w;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){l.click=1;l.evaluator.setVariable(l.mpressedString,1);l.evaluator.setVariable(l.mclickedString,0);l.evaluator.setVariable(l.mclicizquierdoString,0);l.parent.deactivateGraphiControls();h(a);window.addEventListener("touchmove",n);window.addEventListener("touchend",d);a.preventDefault()}function d(a){l.click=0;l.evaluator.setVariable(l.mpressedString,
0);l.evaluator.setVariable(l.mclickedString,1);l.evaluator.setVariable(l.mclicizquierdoString,1);window.removeEventListener("touchmove",n,!1);window.removeEventListener("touchend",d,!1);a.preventDefault();l.parent.update()}function c(b){l.click=1;l.parent.deactivateGraphiControls();l.whichButton=a.whichButton(b);"R"===l.whichButton&&(window.addEventListener("mouseup",f),l.fixed||(l.clickPosForZoom=l.getCursorPosition(b).y,l.tempScale=l.scale,window.addEventListener("mousemove",m)));"L"===l.whichButton&&
(l.evaluator.setVariable(l.mpressedString,1),l.evaluator.setVariable(l.mclickedString,0),l.evaluator.setVariable(l.mclicizquierdoString,0),h(b),window.addEventListener("mousemove",n),window.addEventListener("mouseup",f));b.preventDefault()}function f(a){l.click=0;l.evaluator.setVariable(l.mpressedString,0);l.evaluator.setVariable(l.mclickedString,1);l.evaluator.setVariable(l.mclicizquierdoString,1);a.preventDefault();"R"===l.whichButton&&window.removeEventListener("mousemove",m,!1);window.removeEventListener("mousemove",
n,!1);window.removeEventListener("mouseup",f,!1);l.parent.update()}function h(a){l.posAnte=l.getCursorPosition(a);l.mouse_x=l.getRelativeX(l.posAnte.x);l.mouse_y=l.getRelativeY(l.posAnte.y);l.evaluator.setVariable(l.mxString,l.mouse_x);l.evaluator.setVariable(l.myString,l.mouse_y);l.evaluator.setVariable(l.mclickedString,0);l.evaluator.setVariable(l.mclicizquierdoString,0);l.parent.update()}function m(a){a.preventDefault();l.clickPosForZoomNew=l.getCursorPosition(a).y;l.evaluator.setVariable(l.scaleString,
l.tempScale+l.tempScale/45*((l.clickPosForZoom-l.clickPosForZoomNew)/10));l.parent.update()}function n(a){l.fixed||(l.posNext=l.getCursorPosition(a),e=g(l.posAnte.x-l.posNext.x),k=g(l.posAnte.y-l.posNext.y),l.evaluator.setVariable(l.OxString,l.Ox-e),l.evaluator.setVariable(l.OyString,l.Oy-k),l.posAnte.x-=e,l.posAnte.y-=k);h(a);a.preventDefault()}var l=this;M=a.hasTouchSupport;l.canvas.oncontextmenu=function(){return!1};M&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",
h),this.canvas.addEventListener("touchstart",b));M||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",h),this.canvas.addEventListener("mousedown",c))};return a}(descartesJS||{}),descartesJS=function(a){var e,k,g;function b(a,b){return b.depth-a.depth}function c(b,d){Y=a.subtract3D(b,a.scalarProduct3D(d,a.dotProduct3D(b,d)));V=a.add3D(b,a.scalarProduct3D(Y,-2));W=a.norm3D(V);return 0!==W?a.scalarProduct3D(V,1/W):a.scalarProduct3D(b,-1)}if(a.loadLib)return a;var f=Math.floor,
h=Math.round,d=Math.max,r=Math.cos,l=Math.sin,m=Math.sqrt,t=15*Math.PI/180,q=Math.cos(t),u=Math.sin(t),p,v,n,s,w,z,C,y,E,D,B,A,H,G,I,K,x,J,F,P,Q,M,R,S=[],N,O,L,U,T,X,Y,V,W;a.Space3D=function(b,d){a.Space.call(this,b,d);n=this;n.backgroundCanvas=document.createElement("canvas");n.backgroundCanvas.setAttribute("id",n.id+"_background");n.backgroundCanvas.setAttribute("width",n.w+"px");n.backgroundCanvas.setAttribute("height",n.h+"px");n.canvas=document.createElement("canvas");n.canvas.setAttribute("id",
n.id+"_canvas");n.canvas.setAttribute("width",n.w+"px");n.canvas.setAttribute("height",n.h+"px");n.canvas.setAttribute("class","DescartesSpace3DCanvas");n.canvas.setAttribute("style","z-index: "+n.zIndex+";");n.ctx=n.canvas.getContext("2d");n.ctx.imageSmoothingEnabled=!1;n.ctx.mozImageSmoothingEnabled=!1;n.ctx.webkitImageSmoothingEnabled=!1;n.graphicControlContainer=document.createElement("div");n.graphicControlContainer.setAttribute("id",n.id+"_graphicControls");n.graphicControlContainer.setAttribute("style",
"position: absolute; left: 0px; top: 0px; z-index: "+n.zIndex+";");n.numericalControlContainer=document.createElement("div");n.numericalControlContainer.setAttribute("id",n.id+"_numericalControls");n.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+n.zIndex+";");n.container=document.createElement("div");n.container.setAttribute("id",n.id);n.container.setAttribute("class","DescartesSpace3DContainer");n.container.setAttribute("style","left: "+n.x+"px; top: "+
n.y+"px; z-index: "+n.zIndex+";");n.container.appendChild(n.backgroundCanvas);n.container.appendChild(n.canvas);n.container.appendChild(n.graphicControlContainer);n.container.appendChild(n.numericalControlContainer);b.container.insertBefore(n.container,b.loader);n.eye={x:0,y:0,z:0};n.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,e=n.lights.length;c<e;c++)n.lights[c]=a.normalize3D(n.lights[c]);n.light3={x:0,y:0,z:0};n.intensity=[0.4,0.5,0.3,0];n.userIntensity=
0;n.dim=1;n.tmpIntensity=[];n.OxStr=n.id+".Ox";n.OyStr=n.id+".Oy";n.scaleStr=n.id+".escala";n.wStr=n.id+"._w";n.hStr=n.id+"._h";n.obsStr=n.id+".observador";n.rotZStr=n.id+".rot.z";n.rotYStr=n.id+".rot.y";n.userI_Dim_Str=n.id+".userIlum.dim";n.userI_I_Str=n.id+".userIlum.I";n.userI_x_Str=n.id+".userIlum.x";n.userI_y_Str=n.id+".userIlum.y";n.userI_z_Str=n.id+".userIlum.z";n.evaluator.setVariable(n.rotZStr,0);n.evaluator.setVariable(n.rotYStr,0);n.evaluator.setVariable(n.userI_Dim_Str,n.dim);n.evaluator.setVariable(n.userI_I_Str,
n.userIntensity);n.evaluator.setVariable(n.userI_x_Str,0);n.evaluator.setVariable(n.userI_y_Str,0);n.evaluator.setVariable(n.userI_z_Str,0);n.registerMouseAndTouchEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(a){n=this;n.uber.init.call(n);n.canvas&&(n.canvas.setAttribute("width",n.w+"px"),n.canvas.setAttribute("height",n.h+"px"));n.container&&n.findOffset();n.w_2=n.w/2;n.h_2=n.h/2;n.oldMouse={x:0,y:0}};a.Space3D.prototype.update=function(a){n=this;p=n.evaluator;v=n.parent;
p.setVariable(n.wStr,n.w);p.setVariable(n.hStr,n.h);n.drawIfValue=0<p.evalExpression(n.drawif);if(n.drawIfValue){E=n.x!==p.evalExpression(n.xExpr)+n.displaceRegionWest;D=n.y!==p.evalExpression(n.yExpr)+v.plecaHeight+n.displaceRegionNorth;n.spaceChange=a||E||D||n.drawBefore!==n.drawIfValue||n.Ox!==p.getVariable(n.OxStr)||n.Oy!==p.getVariable(n.OyStr)||n.scale!==p.getVariable(n.scaleStr);n.x=E?p.evalExpression(n.xExpr)+n.displaceRegionWest:n.x;n.y=D?p.evalExpression(n.yExpr)+v.plecaHeight+n.displaceRegionNorth:
n.y;n.Ox=p.getVariable(n.OxStr);n.Oy=p.getVariable(n.OyStr);n.scale=p.getVariable(n.scaleStr);n.drawBefore=n.drawIfValue;if(a){var b;a=0;for(var c=n.parent.controls.length;a<c;a++)n.parent.controls[a].id===n.obsStr&&(b=!0);n.observer=b?p.getVariable(n.obsStr)||0.5*(n.w+n.h):2.5*(n.w+n.h);n.observer=d(n.observer,0.1*(n.w+n.h));p.setVariable(n.obsStr,n.observer);n.eye={x:n.observer/n.scale*q,y:0,z:n.observer/n.scale*u};n.D=n.scale*n.eye.x/q;n.XE=h(n.scale*n.eye.y+0.5);n.YE=h(n.scale*n.eye.z+0.5)}n.observer=
d(p.getVariable(n.obsStr),0.1*(n.w+n.h));p.setVariable(n.obsStr,n.observer);1E-6>n.scale?(n.scale=1E-6,p.setVariable(n.scaleStr,1E-6)):1E6<n.scale&&(n.scale=1E6,p.setVariable(n.scaleStr,1E6));if(E||D)n.container.style.left=n.x+"px",n.container.style.top=n.y+"px",n.findOffset();n.container.style.display="block";n.dim=p.getVariable(n.userI_Dim_Str);n.userIntensity=p.getVariable(n.userI_I_Str);n.light3={x:parseInt(p.getVariable(n.userI_x_Str)),y:parseInt(p.getVariable(n.userI_y_Str)),z:parseInt(p.getVariable(n.userI_z_Str))};
n.updateCamera();n.draw()}else n.container.style.display="none"};a.Space3D.prototype.draw=function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.fillStyle=this.background.getColor();this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?this.ctx.drawImage(this.image,0,0):"stretch"===this.bg_display?this.ctx.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?
(this.ctx.fillStyle=ctx.createPattern(this.image,"repeat"),this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&this.ctx.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));for(var a=0,d=this.graphics.length;a<d;a++)s=this.graphics[a],s.update();this.primitives=[];a=0;for(d=this.graphics.length;a<d;a++){s=this.graphics[a];if(s.split||this.split)for(var c=a+1;c<d;c++)w=this.graphics[c],(w.split||this.split)&&s.splitFace(w);this.primitives=
this.primitives.concat(s.primitives||[])}z=this.primitives;C=z.length;for(a=0;a<C;a++)z[a].computeDepth(this);z=z.sort(b);for(a=0;a<C;a++)z[a].draw(this.ctx,this);a=0;for(d=this.graphicsCtr.length;a<d;a++)this.graphicsCtr[a].draw()};a.Space3D.prototype.updateCamera=function(){n=this;n.D=n.observer;n.eye.x=n.D/n.scale;n.eye.y=n.XE/n.scale;n.eye.z=n.YE/n.scale};a.Space3D.prototype.rotateVertex=function(b){x=a.degToRad(n.evaluator.getVariable(n.rotZStr));J=r(x);F=l(x);e=b.x*J-b.y*F;k=b.x*F+b.y*J;g=b.z;
x=a.degToRad(n.evaluator.getVariable(n.rotYStr));J=r(x);F=l(x);return{x:g*F+e*J,y:k,z:g*J-e*F}};a.Space3D.prototype.project=function(a){n=this;H=n.eye.x-a.x;G=n.eye.y-a.y;I=n.eye.z-a.z;K=-a.x/m(H*H+G*G+I*I)||0;H=n.scale*(a.y+K*(n.eye.y-a.y));G=-n.scale*(a.z+K*(n.eye.z-a.z));return{x:parseInt(H+this.w_2+this.Ox),y:parseInt(G+this.h_2+this.Oy),z:K}};a.Space3D.prototype.computeColor=function(b,d,e){U=a.subtract3D(this.eye,d.average);T=a.norm3D(U);X=a.scalarProduct3D(U,1/T);this.lights[3]=a.subtract3D(this.light3,
d.average);R=a.norm3D(this.lights[3]);for(var g=0,h=this.intensity.length-1;g<h;g++)S[g]=this.intensity[g]*this.dim;S[3]=this.userIntensity*this.userIntensity/R||0;N=e?this.dim/2:this.dim/4;O=0;L=0<=d.direction?d.normal:a.scalarProduct3D(d.normal,-1);g=0;for(h=this.lights.length;g<h;g++)e?(O=Math.max(0,a.dotProduct3D(c(this.lights[g],L),X)),O*=O*O):O=Math.max(0,a.dotProduct3D(this.lights[g],L)),N+=S[g]*O;N=Math.min(N,1);P=f(b.r*N);Q=f(b.g*N);M=f(b.b*N);return"rgba("+P+","+Q+","+M+","+b.a+")"};a.Space3D.prototype.registerMouseAndTouchEvents=
function(){function b(a){k.click=1;k.evaluator.setVariable(k.id+".mouse_pressed",1);k.parent.deactivateGraphiControls();k.posAnte=k.getCursorPosition(a);k.oldMouse.x=k.getRelativeX(k.posAnte.x);k.oldMouse.y=k.getRelativeY(k.posAnte.y);g(a);window.addEventListener("touchmove",l);window.addEventListener("touchend",d);a.preventDefault()}function d(a){k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);window.removeEventListener("touchmove",l,!1);window.removeEventListener("touchend",d,!1);a.preventDefault()}
function c(b){k.click=1;k.parent.deactivateGraphiControls();k.whichButton=a.whichButton(b);"R"===k.whichButton?(window.addEventListener("mouseup",e),k.fixed||(k.clickPosForZoom=k.getCursorPosition(b).y,k.tempScale=k.scale,window.addEventListener("mousemove",f))):"L"==k.whichButton&&(k.evaluator.setVariable(k.id+".mouse_pressed",1),k.posAnte=k.getCursorPosition(b),k.oldMouse.x=k.getRelativeX(k.posAnte.x),k.oldMouse.y=k.getRelativeY(k.posAnte.y),g(b),window.addEventListener("mousemove",l),window.addEventListener("mouseup",
e));b.preventDefault()}function e(a){k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);a.preventDefault();"R"===k.whichButton&&window.removeEventListener("mousemove",f,!1);window.removeEventListener("mousemove",l,!1);window.removeEventListener("mouseup",e,!1)}function g(a){k.posAnte=k.getCursorPosition(a);k.mouse_x=k.getRelativeX(k.posAnte.x);k.mouse_y=k.getRelativeY(k.posAnte.y);k.evaluator.setVariable(k.id+".mouse_x",k.mouse_x);k.evaluator.setVariable(k.id+".mouse_y",k.mouse_y);k.parent.update()}
function f(a){a.preventDefault();k.clickPosForZoomNew=k.getCursorPosition(a).y;k.evaluator.setVariable(k.scaleStr,k.tempScale+k.tempScale/45*((k.clickPosForZoom-k.clickPosForZoomNew)/10));k.parent.update()}function l(b){if(!k.fixed&&k.click){B=parseInt(50*(k.oldMouse.x-k.mouse_x));A=parseInt(50*(k.oldMouse.y-k.mouse_y));if(B!==k.disp.x||A!==k.disp.y)k.alpha=a.degToRad(k.evaluator.getVariable(k.rotZStr)),k.beta=a.degToRad(-k.evaluator.getVariable(k.rotYStr)),k.alpha=h(a.radToDeg(k.alpha)-B),k.beta=
h(a.radToDeg(k.beta)-A),k.evaluator.setVariable(k.rotZStr,k.alpha),k.evaluator.setVariable(k.rotYStr,-k.beta),k.disp.x=B,k.disp.y=A,k.oldMouse.x=k.getRelativeX(k.posAnte.x),k.oldMouse.y=k.getRelativeY(k.posAnte.y);g(b);b.preventDefault()}}var k=this;y=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};y&&this.canvas.addEventListener("touchstart",b);y||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(k,g){a.Space.call(this,k,g);this.exportarVars=this.importarVars=null;e=k.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 g=document.getElementById(this.oldFile);e=g&&"descartes/spaceApFile"==g.type?g.text:a.openExternalFile(this.oldFile);null!=e&&(e=e.split("\n"))}if(e&&e.toString().match(/<applet/gi)){for(var g="",b=!1,c=0,f=e.length;c<f&&!(e[c].match("<applet")&&(b=!0),b&&(g+=e[c]),e[c].match("</applet"));c++);c=document.createElement("div");c.innerHTML=g;c.firstChild.setAttribute("width",this.w);c.firstChild.setAttribute("height",this.h);g=this.descApp?this.descApp.container:null;this.descApp=
new a.DescartesApp(c.firstChild);this.descApp.container.setAttribute("class","DescartesAppContainer");this.descApp.container.setAttribute("style","position: absolute; overflow: hidden; background-color: "+this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");g?this.parent.container.replaceChild(this.descApp.container,g):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);g=this.descApp.spaces;c=0;
for(f=g.length;c<f;c++)g[c].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var h=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();h.exportar()}}else g=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),c="position: absolute; overflow: hidden; background-color: "+
this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";",this.image&&("topleft"==this.bg_display?c+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?c+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?c+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(c+="background-image: url("+
this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",c),g?this.parent.container.replaceChild(this.descApp.container,g):this.parent.container.insertBefore(this.descApp.container,this.parent.loader),this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none"};a.SpaceAP.prototype.update=function(){var a=this.evaluator.evalExpression(this.file);if(this.oldFile!=a)this.oldFile=a,this.initFile();
else{var a=this.x!=this.evaluator.evalExpression(this.xExpr),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 c in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(c)&&c.match(/^public./)&&this.importarVars.push({varName:c,value:this.evaluator.getVariable(c)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,e=!1,b=0,c=this.importarVars.length;b<c;b++)a=this.evaluator.getVariable(this.importarVars[b].varName),a!=this.importarVars[b].value&&(this.importarVars[b].value=
a,this.descApp.evaluator.setVariable(this.importarVars[b].varName,this.importarVars[b].value),e=!0);e&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,k,g,b;a.SpaceHTML_IFrame=function(b,e){a.Space.call(this,b,e);var g=this.parent.evaluator;window.navigator.userAgent.toLowerCase().match(/firefox/);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=g.parser.parse(this.file.substring(1,
this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=g.parser.parse(this.file):this.file=g.parser.parse("'"+this.file+"'");this.oldFile=g.evalExpression(this.file);this.MyIFrame=document.createElement("iframe");this.MyIFrame.setAttribute("src",this.oldFile);this.MyIFrame.setAttribute("id",this.id);this.MyIFrame.setAttribute("marginheight",0);this.MyIFrame.setAttribute("marginwidth",0);this.MyIFrame.setAttribute("frameborder",0);this.MyIFrame.setAttribute("scrolling","auto");
this.MyIFrame.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px;");this.parent.container.insertBefore(this.MyIFrame,this.parent.loader);var d=this;this.MyIFrame.onload=function(a){var b=this;d.evaluator.setFunction(d.id+".set",function(a,d){b.contentWindow.postMessage({type:"set",name:a,value:d},"*")});d.evaluator.setFunction(d.id+".update",function(){b.contentWindow.postMessage({type:"update"},"*")});d.evaluator.setFunction(d.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);k=this.x!==e.evalExpression(this.xExpr)+this.displaceRegionWest;g=this.y!==e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=k?e.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=g?e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(k||g)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:f(a.loader.width,a.loader.height);this.imageLoader=document.createElement("div");this.imageLoader.width=a.width;this.imageLoader.height=a.height;this.imageLoader.setAttribute("class",
"DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image: url("+b+"); width: "+a.width+"px; height: "+a.height+"px;");a.loader.appendChild(this.imageLoader);this.loaderBar=document.createElement("canvas");this.loaderBar.width=a.width;this.loaderBar.height=a.height;this.loaderBar.setAttribute("class","DescartesLoaderBar");this.loaderBar.setAttribute("style","width: "+a.width+"px; height:"+a.height+"px;");this.loaderBar.ctx=this.loaderBar.getContext("2d");a.loader.appendChild(this.loaderBar);
this.barWidth=Math.floor(80);this.barHeight=Math.floor(a.loader.height/70);var c=this;this.timer=setInterval(function(){c.drawLoaderBar(c.loaderBar.ctx,a.width,a.height)},10);a.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var b=this.children,d=this.images,c=this.audios,e=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,g=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/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 f,k,u,p,v,n;u=0;for(v=b.length;u<v;u++)if("rtf"!==b[u].name){if(b[u].value.match(/'macro'|'makro'/g)){f="";var s;k=this.lessonParser.split(b[u].value);n=0;for(var w=k.length;n<w;n++)"expresion"===babel[k[n][0]]&&(f=k[n][1]);f&&((s=document.getElementById(f))&&"descartes/macro"==s.type?s=s.text:(s=a.openExternalFile(f))&&!s.match(/tipo_de_macro/g)&&
(s=null));if(s&&(f=s.match(e)))for(n=f.length;p<n;p++)k=f[p],!k.toLowerCase().match(/vacio.gif$/)&&""!=k.substring(0,k.length-4)&&(d[k]=new Image,d[k].addEventListener("load",function(){this.ready=1}),d[k].addEventListener("error",function(){this.errorload=1}),d[k].src=k)}if(f=b[u].value.match(e)){p=0;for(n=f.length;p<n;p++)k=f[p],!k.toLowerCase().match(/vacio.gif$/)&&""!=k.substring(0,k.length-4)&&(d[k]=new Image,d[k].addEventListener("load",function(){this.ready=1}),d[k].addEventListener("error",
function(){this.errorload=1}),d[k].src=k)}if(f=b[u].value.match(g)){p=0;for(k=f.length;p<k;p++)this.initAudio(f[p])}}for(var z in d)d.hasOwnProperty(z)&&this.images.length++;for(z in c)c.hasOwnProperty(z)&&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 k,g,b,c;a.DescartesLoader.prototype.drawLoaderBar=function(a,d,f){k=this.barWidth;g=this.barHeight;b=this.images.length+this.audios.length;c=2*(k-2)/b;a.translate(d/2,(f-65*e)/2+90*e);a.scale(e,e);a.strokeRect(-k,-g,2*k,g);a.fillStyle=
"gray";a.fillRect(-k+2,-g+2,2*(k-2),g-4);a.fillStyle="#1f375d";a.fillRect(-k+2,-g+2,this.readys*c,g-4);a.setTransform(1,0,0,1,0,0)};var f=function(a,b){var c=document.createElement("canvas");c.width=a;c.height=b;var g=c.getContext("2d");g.save();g.strokeStyle="#1f375d";g.fillStyle="#1f375d";g.lineCap="round";g.lineWidth=2;g.beginPath();e=a<b?a/360:b/195;e=2.5<e?2.5:e;g.translate((a-120*e)/2,(b-65*e)/2);g.scale(e,e);g.moveTo(3,25);g.lineTo(3,1);g.lineTo(21,1);g.bezierCurveTo(33,1,41,15,41,25);g.stroke();
g.beginPath();g.moveTo(1,63);g.lineTo(1,64);g.moveTo(5,62);g.lineTo(5,64);g.moveTo(9,61);g.lineTo(9,64);g.moveTo(13,60);g.lineTo(13,64);g.moveTo(17,58);g.lineTo(17,64);g.moveTo(21,56);g.lineTo(21,64);g.moveTo(25,53);g.lineTo(25,64);g.moveTo(29,50);g.lineTo(29,64);g.moveTo(33,46);g.lineTo(33,64);g.moveTo(37,41);g.lineTo(37,64);g.moveTo(41,32);g.lineTo(41,64);g.stroke();g.font="20px Arial, Helvetica, 'Droid Sans', Sans-serif";g.fillText("escartes",45,33);g.fillText("JS",98,64);g.restore();return c.toDataURL()};
return a}(descartesJS||{}),descartesJS=function(a){function e(a){for(var b="[",c=0,f=a.length;c<f;c++){if(a[c]instanceof Array)b+=e(a[c]);else{k=a[c];if("undefined"==typeof k||!k)k=0;"string"==typeof k&&(k="'"+k+"'");b+=k}c<f-1&&(b+=",")}return b+"]"}if(a.loadLib)return a;a.DescartesApp=function(a){this.applet=a;this.parentContainer=a.parentNode;this.width=parseFloat(a.getAttribute("width"));this.height=parseFloat(a.getAttribute("height"));this.decimal_symbol=".";this.decimal_symbol_regexp=RegExp("\\"+
this.decimal_symbol,"g");this.children=a.getElementsByTagName("param");this.code=a.getAttribute("code");this.saveState=[];this.images={};this.images.length=-1;this.audios={};this.audios.length=-1;this.firstRun=!0;this.init()};a.DescartesApp.prototype.init=function(){this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.arquimedes=!!this.code.match("descinst.DescartesWeb2_0.class","i")||!!this.code.match("Arquimedes","i")||!!this.code.match("Discurso","i");this.licenseA=
"";
for(var e=this.children,b,c=0,f=0,h=0,d=e.length;h<d;h++)b=e[h],"rtf_height"==b.name&&(c=parseInt(b.value)),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),f=this.buttonsConfig.height),"image_loader"==b.name&&(this.image_loader=b.value);this.arquimedes&&c&&(this.height=c+f+90);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,c=[],e=[],h=[],d=[],k=[],l=[],m,t=0,q=a.length;t<q;t++)if(m=a[t],"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,this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");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 u=(this.width-780)/2,p=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;d.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+
m.value.replace(/'/g,"&squot;")+"'");d.push("space='descartesJS_scenario' type='text' expresion='["+u+","+(p-25)+"]' background='yes' text='"+this.licenseA+"'");d.push("space='descartesJS_scenario' type='image' expresion='["+(u+15)+","+p+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==m.name.charAt(0)?(m.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,c.push(m.value)):"C"==m.name.charAt(0)&&"_"==m.name.charAt(1)?e.push(m.value):"A"==m.name.charAt(0)&&"_"==m.name.charAt(1)?
h.push(m.value):"G"==m.name.charAt(0)?d.push(m.value):"S"==m.name.charAt(0)?k.push(m.value):"Animation"==babel[m.name]&&l.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));t=0;for(q=c.length;t<q;t++)a=b.parseSpace(c[t]),this.arquimedes&&this.scenarioRegion.container.appendChild(a.container),this.spaces.push(a),this.zIndex++;t=0;for(q=d.length;t<q;t++)if(c=b.parseGraphic(d[t]))c.visible&&(this.editableRegionVisible=!0),c.space.addGraph(c);t=0;for(q=
k.length;t<q;t++)(c=b.parse3DGraphic(k[t]))&&c.space.addGraph(c);t=0;for(q=e.length;t<q;t++)this.controls.push(b.parseControl(e[t]));t=0;for(q=h.length;t<q;t++)b.parseAuxiliar(h[t]);t=0;for(q=l.length;t<q;t++)this.animation=b.parseAnimation(l[t]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();t=0;for(q=this.controls.length;t<q;t++)this.controls[t].init();this.updateControls();this.updateSpaces(!0);var v=this;this.numberOfIframes?setTimeout(function(){v.finishInit()},300*this.numberOfIframes):
this.finishInit()};a.DescartesApp.prototype.finishInit=function(){this.update();this.loader.style.display="none";window.parent!==window&&(this.parentContainer.style.margin="0px",this.parentContainer.style.padding="0px",window.parent.postMessage({type:"reportSize",href:window.location.href,width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready"},"*"),a.onResize());if(window.opener){document.body.style.margin="0px";document.body.style.padding="0px";this.parentContainer.style.margin=
"0px";this.parentContainer.style.padding="0px";var e=parseInt(this.width)+20,b=parseInt(this.height)+80;window.moveTo((parseInt(screen.width)-e)/2,(parseInt(screen.height)-b)/2);window.resizeTo(e,b);a.onResize()}a.externalEvaluator=new a.Evaluator};a.DescartesApp.prototype.configRegions=function(){var e=this.evaluator.parser,b=this.buttonsConfig,c=this.container;if(2!=this.version)var f="15",h=100,d=100,k=100,l=100;else f="14",h=63,d=50,k=44,l=53;var m=0,t=0,q=0,u=q=0,p=0,v=0,n=0,s=0,v=this.northSpace.controls,
w=this.southSpace.controls,z=this.eastSpace.controls,C=this.westSpace.controls;if(0<b.rowsNorth||0<v.length||b.about||b.config){0>=b.rowsNorth?(m=b.height,b.rowsNorth=1):m=b.height*b.rowsNorth;p=this.northSpace.container;p.setAttribute("id","descartesJS_northRegion");p.setAttribute("style","width:"+c.width+"px; height:"+m+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");c.insertBefore(p,this.loader);var p=c.width,y=0;b.about&&(y=h,p-=y);b.config&&(p-=d);for(var E=Math.ceil(v.length/
b.rowsNorth),D=p/E,q=0,B=v.length;q<B;q++)v[q].expresion=e.parse("("+(y+D*(q%E))+","+b.height*Math.floor(q/E)+","+D+","+b.height+")"),v[q].drawif=e.parse("1"),v[q].init();b.about&&(q="espa\u00f1ol"==this.language?"cr\u00e9ditos":"english"==this.language?"about":"cr\u00e9ditos",(new a.Button(this,{region:"north",name:q,font_size:e.parse(f),expresion:e.parse("(0, 0, "+h+", "+m+")")})).update());b.config&&(new a.Button(this,{region:"north",name:"config",font_size:e.parse(f),action:"config",expresion:e.parse("("+
(p+h)+", 0, "+d+", "+m+")")})).update()}if(0<b.rowsSouth||0<w.length||b.init||b.clear){0>=b.rowsSouth?(t=b.height,b.rowsSouth=1):t=b.height*b.rowsSouth;v=c.width;y=0;b.init&&(y=k,v-=y);b.clear&&(v-=l);p=this.southSpace.container;p.setAttribute("id","descartesJS_southRegion");p.setAttribute("style","width:"+c.width+"px; height:"+t+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(c.height-t)+"px; z-index:100;");c.insertBefore(p,this.loader);E=Math.ceil(w.length/b.rowsSouth);D=v/E;q=0;for(B=
w.length;q<B;q++)w[q].expresion=e.parse("("+(y+D*(q%E))+","+b.height*Math.floor(q/E)+","+D+","+b.height+")"),w[q].drawif=e.parse("1"),w[q].init();b.init&&(q="espa\u00f1ol"==this.language?"inicio":"english"==this.language?"init":"inicio",(new a.Button(this,{region:"south",name:q,font_size:e.parse(f),action:"init",expresion:e.parse("(0, 0, "+k+", "+t+")")})).update());b.clear&&(q="espa\u00f1ol"==this.language?"limpiar":"english"==this.language?"clear":"limpiar",(new a.Button(this,{region:"south",name:q,
font_size:e.parse(f),action:"clear",expresion:e.parse("("+(v+k)+", 0, "+l+", "+t+")")})).update())}if(0<z.length){q=c.height-m-t;n=b.widthEast;p=this.eastSpace.container;p.setAttribute("id","descartesJS_eastRegion");p.setAttribute("style","width:"+n+"px; height:"+q+"px; background:#c0c0c0; position:absolute; left:"+(c.width-n)+"px; top:"+m+"px; z-index:100;");c.insertBefore(p,this.loader);q=0;for(B=z.length;q<B;q++)z[q].expresion=e.parse("(0,"+b.height*q+","+n+","+b.height+")"),z[q].drawif=e.parse("1"),
z[q].init()}if(0<C.length){q=c.height-m-t;s=b.widthWest;p=this.westSpace.container;p.setAttribute("id","descartesJS_westRegion");p.setAttribute("style","width: "+s+"px; height: "+q+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+m+"px; z-index: 100;");c.insertBefore(p,this.loader);q=0;for(B=C.length;q<B;q++)C[q].expresion=e.parse("(0,"+b.height*q+","+s+","+b.height+")"),C[q].drawif=e.parse("1"),C[q].init()}if(this.editableRegionVisible){u=b.height;p=this.editableRegion.container;p.setAttribute("id",
"descartesJS_editableRegion");p.setAttribute("style","width:"+c.width+"px; height:"+u+"px; position:absolute; left:0px; top:"+(c.height-t-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;");c.insertBefore(p,this.loader);e=this.editableRegion.textFields;b=c.width/e.length;f=a.getFieldFontSize(u);q=0;for(B=e.length;q<B;q++)"div"==e[q].type?(p.appendChild(e[q].container),e[q].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(b-4)+"px; height: "+
u+"px; position: absolute; left: "+q*b+"px; top: 0px;"),h=e[q].container.firstChild,h.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+f+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+u+"px; text-align: center; line-height: "+u+"px;"),d=h.offsetWidth,h.style.width=d+"px",h.firstChild.textContent=h.firstChild.textContent.substring(3,h.firstChild.textContent.length-3),e[q].container.lastChild.setAttribute("style",
"font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+f+"px; width:"+(b-d)+"px; height:"+u+"px; position:absolute; left:"+d+"px; top:0px; border:2px groove white;")):(p.appendChild(e[q]),e[q].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+f+"px; width:"+b+"px; height:"+u+"px; position:absolute; left:"+q*b+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=m;this.displaceRegionWest=s;c.width-=n;c.height=
c.height-t-u;q=0;for(B=this.spaces.length;q<B;q++)this.spaces[q].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,b=0,c=this.controls.length;b<c;b++)a=this.controls[b],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,b=this.auxiliaries.length;a<b;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=
function(){for(var a=0,b=this.events.length;a<b;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,b=this.controls.length;a<b;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var b=0,c=this.spaces.length;b<c;b++)this.spaces[b].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,b=this.spaces.length;a<b;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground&&this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=
function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stopAudios=function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),this.audios[a].currentTime=0)};a.DescartesApp.prototype.getImage=function(a){var b=this.images;if(a)return b[a]||(b[a]=
new Image,b[a].addEventListener("load",function(){this.ready=1}),b[a].addEventListener("error",function(){this.errorload=1}),b[a].src=a),b[a]};a.DescartesApp.prototype.getAudio=function(a){var b=this.audios;if(a){if(!b[a]){var c=a.lastIndexOf("."),c=-1===c?a.lenght:c;a.substring(0,c);b[a]=new Audio(a);var e=function(a){this.ready=1};b[a].addEventListener("canplaythrough",e);var h=function(c){!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",e),b[a].addEventListener("load",e),b[a].addEventListener("error",h),b[a].load()):(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1)};b[a].addEventListener("error",h);b[a].play();setTimeout(function(){b[a].pause()},15)}return b[a]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var b,c=0,e=this.controls.length;c<e;c++)if(b=this.controls[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=
function(a){for(var b,c=0,e=this.controls.length;c<e;c++)if(b=this.controls[c],b.id==a)return b;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var b,c=0,e=this.spaces.length;c<e;c++)if(b=this.spaces[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var b,c=0,e=this.spaces.length;c<e;c++)if(b=this.spaces[c],b.id==a)return b;return{update:function(){},w:0}};var k;a.DescartesApp.prototype.getState=function(){var a,
b="",c=this.evaluator.variables,f;for(f in c)c.hasOwnProperty(f)&&(a=c[f],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=f&&"pi"!=f&&"e"!=f&&"Infinity"!=f&&"-Infinity"!=f&&"object"!=typeof a)&&(b=""!=b?b+"\n"+f+"="+a:f+"="+a));var c=this.evaluator.vectors,h;for(h in c)c.hasOwnProperty(h)&&(a=c[h],b=b+"\n"+h+"="+e(a));h=this.evaluator.matrices;for(var d in h)h.hasOwnProperty(d)&&(a=h[d],b=b+"\n"+d+"="+e(a));return b};a.DescartesApp.prototype.setState=function(a){a=a.split("\n");for(var b,c,e=
0,h=a.length;e<h;e++)b=a[e].split("="),2<=b.length&&(c=eval(b[1]),-1!=b[1].indexOf("[[")?(this.evaluator.matrices[b[0]]=c,this.evaluator.matrices[b[0]].rows=c.length,this.evaluator.matrices[b[0]].cols=c[0].length):-1!=b[1].indexOf("[")?(this.evaluator.vectors[b[0]]=c,this.evaluator.variables[b[0]+".long"]=c.length):this.evaluator.variables[b[0]]=c),this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,b=0,c="",e=0,h=this.controls.length;e<h;e++)"textfield"==this.controls[e].gui&&
this.controls[e].evaluate&&(a++,b+=this.controls[e].ok,this.controls[e].value=""==this.controls[e].value?"''":this.controls[e].value,c+=" \\n "+this.controls[e].id+"="+this.controls[e].value+"|"+this.controls[e].ok);return"questions="+a+" \\n correct="+b+" \\n wrong="+(a-b)+c};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,b=0,c=a.length;b<c;b++)"textfield"==a[b].gui&&a[b].evaluate&&a[b].changeValue(a[b].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=
function(){for(var a=0,b=this.saveState.length;a<b;a++)this.evaluator.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||{}),descartesJS=function(a){function e(){var a=document.getElementById("StyleDescartesApps");a&&a.parentNode.removeChild(a);a=document.createElement("style");a.id="StyleDescartesApps";a.type="text/css";a.setAttribute("rel","stylesheet");a.innerHTML="applet.DescartesJS {display:none;} applet {display:none;} ajs.DescartesJS {display:none;} ajs {display:none;}";
document.head.appendChild(a)}function k(e){a.getFeatures();if(a.hasCanvasSupport){e=document.getElementsByTagName("*");for(var b=[],c=0,f=e.length;c<f;c++)"DescartesAppContainer"==e[c].className&&b.push(e[c]);c=0;for(f=b.length;c<f;c++)b[c].parentNode.removeChild(b[c]);b=document.getElementsByTagName("applet");c=document.getElementsByTagName("ajs");e=[];for(var h=0,d=b.length;h<d;h++)f=b[h],(f.getAttribute("code").match("DescartesJS")||f.getAttribute("code").match("descinst.DescartesWeb2_0.class")||
f.getAttribute("code").match("Descartes")||f.getAttribute("code").match("Arquimedes")||f.getAttribute("code").match("Discurso"))&&e.push(f);h=0;for(d=c.length;h<d;h++)f=c[h],(f.getAttribute("code").match("DescartesJS")||f.getAttribute("code").match("descinst.DescartesWeb2_0.class")||f.getAttribute("code").match("Descartes")||f.getAttribute("code").match("Arquimedes")||f.getAttribute("code").match("Discurso"))&&e.push(f);b=0;for(c=e.length;b<c;b++)a.apps.push(new a.DescartesApp(e[b])),e[b].className=
"DescartesJS";window.addEventListener("resize",a.onResize);window.scrollTo(0,2)}else document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:block;} applet {display:block;} ajs.DescartesJS {display:block;} ajs {display:block;}"}if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};(!window.hasOwnProperty("debugDescartesJS")||!debugDescartesJS)&&e();a.onResize=function(e){for(var b=0,c=a.apps.length;b<c;b++){e=a.apps[b].spaces;for(var f=0,h=e.length;f<
h;f++)e[f].findOffset()}};a.receiveMessage=function(e){if(0<a.apps.length&&(e=e.data))if("set"===e.type)a.apps[0].evaluator.setVariable(e.name,e.value);else if("update"===e.type)a.apps[0].update();else if("exec"===e.type){var b=a.apps[0].evaluator.getFunction(e.name),c=[];""!==e.value&&(c=e.value.toString().split(","));b&&b.apply(a.apps[0].evaluator,c)}};void 0==a.loadLib&&(a.loadLib=!0,window.addEventListener("load",k),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||{});
