/*
 Joel Espinosa Longi
 joel.espinosa@amite.mx
 j.longi@gmail.com
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-08-02
*/
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,f,c,n,d,h,g,e;Number.prototype.originalToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(k){if(20>=k)return this.originalToFixed(k);k=0>k?0:parseInt(k);a=this.toString();n=a.indexOf("e");b=a.indexOf(".");if(-1!==n)if(d=a.split("e"),g="-"===d[0][0]?"-":"",h="-"===g?d[0].substring(1):d[0],e=parseInt(d[1]),0>b+e){var l=g+"0.",m;m=Math.abs(b+e);m=Array(m+1).join("0");a=l+m+h.replace(".","");b=1}else h=h.replace(".",""),a=g+h+Array(e-h.length+2).join("0"),b=-1;f="";if(-1===b)return 0<
k&&(f="."),f+=Array(k+1).join("0"),a+f;c=a.length-b-1;if(c>=k)return 0<k?a.substring(0,b+1+k):a.substring(0,b);l=0;for(k-=c;l<k;l++)f+="0";return a+f}}function l(a,b,f){a.fillStyle="#c0c0c0";a.fillRect(b.offsetLeft,b.offsetTop,b.offsetWidth,b.offsetHeight);g(a,b,f.controls)}function g(a,b,f){for(var c,d=f.length-1;0<=d;d--)c=f[d],a.drawImage(c.getScreenshot(),b.offsetLeft+c.x,b.offsetTop+c.y)}if(a.loadLib)return a;var b=2*Math.PI,d=360/b,f=b/360,h=Math.floor,c,q,p,k,r,t,u,m,v,n;a.rangeOK=1;a.extend=
function(a,b){if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var f in b.prototype)b.prototype.hasOwnProperty(f)&&(a.prototype[f]=b.prototype[f]);a.prototype.uber=b.prototype};a.radToDeg=function(a){return a*d};a.degToRad=function(a){return a*f};a.convertFont=function(a){if(""==a)return a;c=a.split(",");q="";"bold"==c[1].toLowerCase()?q+="Bold ":"italic"==c[1].toLowerCase()||"italics"==c[1].toLowerCase()?q+="Italic ":"bold+italic"==c[1].toLowerCase()&&(q+="Italic Bold ");q+=c[2]+
"px ";p=c[0].split(" ")[0].toLowerCase();return q="serif"===p||"times new roman"===p||"timesroman"===p||"times"===p?q+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===p||"arial"===p||"helvetica"===p?q+"Arial, Helvetica, 'Droid Sans', Sans-serif":q+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};a.drawLine=function(a,b,f,c,d,n,g){a.lineWidth=g||1;a.strokeStyle=n||"black";n=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(h(b)+n,h(f)+n);a.lineTo(h(c)+n,h(d)+n);a.stroke()};a.getColor=
function(a,b){if("string"==typeof b)return b;k=a.evalExpression(b);r=h(255*k[0][0]);t=h(255*k[0][1]);u=h(255*k[0][2]);m=1-k[0][3];return"rgba("+r+","+t+","+u+","+m+")"};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,f){a.ctx.font=f;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],f,c=document.createElement("canvas"),d=new Image;if(b){c.setAttribute("width",b.width);c.setAttribute("height",b.height);for(var n=c.getContext("2d"),h=0,e=b.spaces.length;h<e;h++)f=b.spaces[h],"R2"===f.type&&(n.drawImage(f.backgroundCanvas,f.x,f.y),n.drawImage(f.canvas,f.x,f.y),g(n,f.container,f.ctrs));0<b.northSpace.controls.length&&l(n,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&l(n,b.southSpace.container,b.southSpace);0<b.eastSpace.controls.length&&
l(n,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&l(n,b.westSpace.container,b.westSpace);d.src=c.toDataURL("image/png")}return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l;a.openExternalFile=function(a){e=null;var b=!1;if(window.XMLHttpRequest)try{b=new XMLHttpRequest}catch(d){b=!1}else if(window.ActiveXObject)try{b=new ActiveXObject("Msxml2.XMLHTTP")}catch(f){try{b=new ActiveXObject("Microsoft.XMLHTTP")}catch(h){b=!1}}l=b;l.open("GET",a,
!1);try{l.send(null),e=l.responseText,e.match(String.fromCharCode(65533))&&(l.open("GET",a,!1),l.overrideMimeType("text/plain; charset=ISO-8859-1"),l.send(null),e=l.responseText)}catch(c){console.log("Error to load the file :",a),e=null}return e};return a}(descartesJS||{}),descartesJS=function(a){function e(a){d=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};d[0]==d[d.length-1]&&"'"==d[0]&&(a.ignoreCaps=!0,d=d.substring(1,d.length-1),"`"==d[0]&&"\u00b4"==d[d.length-1]&&(a.ignoreAcents=!0,
d=d.substring(1,d.length-1)));"`"==d[0]&&"\u00b4"==d[d.length-1]&&(a.ignoreAcents=!0,d=d.substring(1,d.length-1),d[0]==d[d.length-1]&&"'"==d[0]&&(a.ignoreCaps=!0,d=d.substring(1,d.length-1)));"*"===d.charAt(0)&&"*"!==d.charAt(d.length-1)?d=d.substring(1)+"$":"*"!==d.charAt(0)&&"*"===d.charAt(d.length-1)?d="^"+d.substring(0,d.length-1):"*"!==d.charAt(0)&&"*"!==d.charAt(d.length-1)?d="^"+d+"$":"*"===d.charAt(0)&&"*"===d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));d=d.replace(/\?/g,"[\\S\\s]{1}");
a.regExp=d;return a}function l(a,b){d=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=d.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:b.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),expr:b.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function g(a,b,f){b=parseFloat(b);q=a.expr[0];p=a.expr[1];k=f.evalExpression(q.expr);r=f.evalExpression(p.expr);t="("==q.type;u=
"["==q.type;m=")"==p.type;v="]"==p.type;return(t&&b>k||u&&b>=k)&&(m&&b<r||v&&b<=r)?1:0}function b(a){return a.toString().replace(/\u00e1/g,"a").replace(/\u00e9/g,"e").replace(/\u00ed/g,"i").replace(/\u00f3/g,"o").replace(/\u00fa/g,"u").replace(/\u00c1/g,"A").replace(/\u00c9/g,"E").replace(/\u00cd/g,"I").replace(/\u00d3/g,"O").replace(/\u00da/g,"U").replace(/\u00f1/g,"n").replace(/\u00d1/g,"N")}if(a.loadLib)return a;var d,f,h,c,q,p,k,r,t,u,m,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 c=0,g=a.length;c<g;c++){f=a[c].split("&");h=[];for(var k=0,m=f.length;k<m;k++)d=f[k],-1!==d.indexOf(",")&&("("===d.charAt(0)||"["===d.charAt(0))&&(")"===d.charAt(d.length-1)||"]"===d.charAt(d.length-1))?h.push(l(d,b)):h.push(e(d));a[c]=h}return a};a.escorrecto=function(d,h,e,k){e=e||a.externalEvaluator;k=k||a.buildRegularExpresionsPatterns(d,e);h=b(h);
d=0;for(var l=k.length;d<l;d++){f=k[d];c=!0;for(var m=0,q=f.length;m<q;m++)c=f[m].regExp?c&&!!h.match(b(f[m].regExp),"i"):c&&g(f[m],h,e);if(c)return 1}return 0};a.esCorrecto=function(h,e,k,m){k=k||a.externalEvaluator;m=m||a.buildRegularExpresionsPatterns(h,k);h=0;for(var l=m.length;h<l;h++){f=m[h];c=!0;for(var q=0,p=f.length;q<p;q++)(d=f[q].regExp)?(f[q].ignoreAcents&&(e=b(e),d=b(d)),f[q].ignoreCaps&&(e=e.toLowerCase(),d=b(d).toLowerCase()),c=c&&!!e.match(d)):c=c=c&&g(f[q],e,k);if(c)return 1}return 0};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.getCreativeCommonsLicenseImage=function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAABHNCSVQICAgIfAhkiAAACpVJREFUaIHtWm1sU9cZfu61iUYnPP/bJgdhhDbFkVYcCrR0tLHXrVNL01wvgUJDh820tivrkpQQtpEvA4HGhDoe/dCmNfbaVa1WKszX2oUO3xC0OHESm9Hi/FhloyQq1aY5OGgq8ce7H9f3xI7txKFsdKyPdHSPz8dzz33Oe77eY46IVBzHXcUXuOkgIo4DQABwuucUeJ4Hz/NQKBTgeQUUPA9ekXryPDiOB89x4DgO4DiZBQQCJQlJSiKZlEIikZCeyQQSiSSSyQTLS1KSlSciuTEsfjtgY+UmAAAHgGRxFQqFFHjFTFyhkPJ4RUpkDhzHp+ubEiclbFISM5FIhfR4IlPkZDLJhE0X+nbBxspNUALIFFehhDLjKYWTx0/B4/FgcHAQU9GpDKIlqiVYu3YtjN8xouLRR5BIKsDzcalDEjw4cJD6cgaUJGkkANIY4iRxR3x+uN9xIxgMZpTX6XQQqgSsWlNW0Md9Xng4APSns+9BqVQyUZVKpRQUSvSK52B73oaJiYmCGqTRaND4i0aUl9+PeCKBRCKOeDwVEnHE4wlm4emW/PHExzjS9SJGg6MAAIPBAL1eDwAIBAIQRREAUKIrwY7aHfja17+a8/1XPv4ELzle+lzwbKzcJAn8fu8ZKBXKGWGVi7BIqURrcxvcx9ysglqthiAI0Gq1KC8vBwD09vYiHA7D7XZjcnKSlRVMAhoad2LxHYsRj8cRi8cRj8cQj8czpwxK4mrkKn769LOIRqMQBAF2ux1arTajseFwGPX19XC73VCpVGi3tWd91LXoNdTuqPvc8MjzMJ3tO0t9/eeo39dPQwEfXfggQIJJIEiDl9RqNbW1tVEkEqG54HQ6Sa1Ws3oluhI6399HQ4Eh8g71U1//OfL0naUzYg+99+d36XTPKTrx7nHS6XQEgMxmcwafzDP7HTL328f/kBFKdCU5eRx2Oz3+2ObPxDM2Nkbe/n7y9vfT2NhYQTwAiAcARWoOVioUUCoyLVev18Pv96O1tRVqtTprGKTDbDYjFAqxoTQaHEWn7XDGXM6zHYm0G/F5fQgGgxAEAY27ds3JL79DEASMBkcx4vOz9BGfH6PBUawqK8O996xj6b/q6sLzNhtOnj6N3Q27MD4+XhBPent+/9prMKy/DzWbt6Bm8xYY1t+HMz09c/Kkg/q8feQd8tLIhWFyHHEwy9Hr9fNabS5EIhHS6/WMx/Gig0b+OkIDw1467+0jz3nJit99/4+kK5WsNxQKFcwfCoUIAOl0OmYt8igo+cY3acUyLZV/ez09/eMnCQC1tbXRwQMHCQAdffvtgnjk9nj7+yW+u9fRj7ZZqHFnA61YpqUVy7TksNvz8uSwYMmKbc/bAEjzrdPpnNdqc0GtVsPj8bC6toO21F46ZcFcak/N8wheCsJgMGTNcRaLhVm5xWLJyNNqtTAYDBkrezAo8VRUVGDjpk0YHx/HmZ4erFimxb+mrmHrE1tx6cMPUVVdXRCPVqtFNBpF0H8RAFAp/AC/dXWjo/MQ9rQ0AwBc3c68PDJ4AKlhK23F5N1CXV0dG+o3ArVaDbvdDgCYmJjAyROn2IFFEplj27Rc73G5XDnjMnLV0ev1sB3uxEFbB954601UVVfjo8th2A53YunSpXB1OxG8dKkgHhntL0gG95vfvcrSvvfggwCAaDSKT65cycsDpASWrcnj8QCQxKmtrWWFRFGEyWSC0WiE0WiE1WrNm9fV1cXyzGYzs2LPWU+a9XLg+BmB/xO4+5570NF5CGNjY2jc2YCyb92Jd44eRcXDG1CzeQubQ+eCSqWCw+HAHaoleOWVV3KW+fTT63NySAcNjgPPcRgcHAQACILAhBFFEUajMaOSKIoQRRG1tbUwmUxZeRcuXIDT6WRcLpcLg4OD0gkwJawkriRwIBDIapjZbGaWazabs/Jz1ZmdFo1GcaanBx2dh2C+ZEHFwxsAAANeLwa8XhQXF4NbpJyTZ5FSicaGBtyxeDFLG/B6WXyZdlne9gDMgqUPlk9oK1euZAXq6+sBSPNMKBSCx+OBVqvFtm3bmCXr9XqEQiEcO3YsY48MgMWnolPSe8ClPYHS0lKIoohwOJzRMLmDZscBaQ8qiiJ0Oh1L0+l0WTw/efIptO/dh1V3rkTN5i346HIYVdXV6Og8hJqtWwviGR8fR1tLKx5/bDPa9+5D+959aGlqAgDs2r07b3syBAaHjOGaPp/IPWM2m9lkHgqFYDabWZ58+BAEgeXJSF+8JKPNPDZvfExadOSOLARyWaFKYGlyPJ2no/MQLNu348o//o6/hUJw2O3Y09KMqupqWPfvQ9ma1fPyWLZvh2X7dgCAs7sbzu5uXP/0OjZUPIItNY/nbY+M7PHxX8a69eugK9XB7XbDYrFkWetsyKenEl1Jhh9g1ZoylOhKMniKi4uxp6UZX1q8GCPDw/hZXd0N8expacb3H3oIly+HAUijTldaOiePDMmCKdOLlT6fyNbscrkwOTmJQCCA5cuXw2q1sjz5mJyeJyN9yEpnM3l7PIPmtmaoVCq4XC6YTCZWh9K8bOFwGCaTCV1dXVCpVNhRuyPrY3b/sjEnz85dDXjjrTc/E8/qNatRVV2Nqupq6EpLC+IBUs4e38ggioqKsP7e+zAVnYLZbGaW5Ha7sxYyQJoyKisr8+bJ9evr69HV1YUlqiU4/5c+TE9PYzo2jVg8hlgsLjmDEnFE/jmJA9YDbC+p1+uh1+uhVqshiiLr9PmcNNei19BxwMacNLeShzl7BoYHUFRUBGuLFe5jbqjVakQiEVZQFEU4HA7mzDEYDGhtbWUd4HA4WNn0PABYvnw5wuEwHvjuAzhs78T16WnEZgks+42TiSR8Az4cO3rr3Yw3g4cJ7B3qx6JFRTh/7jxqn5X2v3a7HXVpc9aNwOVysVPY/gP78fCGhzAdm8Z0LIZ4LIZYfJbAORzw/8vYWLlJmoPlKx2DsRwajQYAYLVas7ZOC8Hk5CRbXTUaTcoRn7rFSCaRTM3FlLpyul3BA0CSkkgkpHu0fe17AUgCmUymDB9voZicnITRaGR1G3/emHKwJ2ZETrsyYovsrMX2dgEBoKbWJvKNDFLgop+e+OETGR41v9+/IE9XuidNMAkUuOgn38gg7W3fy9L/j8LMj7rnamnI76PADTjcI5EItbW1ZTjc16xdQxc+CNBQwEdNrU23+kNvSWDX9jKaW5tQaRKgVCpx2HYYr7/2Ostb6JWRdV8b4vE4BgYG8cxTz2A+pE8P8smSiDJOmbN/5+PJV0d+R6GOpnxtWhDH7NDc2iRZ8kU/dbteJY1GU3CPaTQachxxUOCin4YCPnr51y8XXJeI5oynp83HM1/9QrhylVkoR5YFy6h7rhY1W2vYVY/o6cWJ4yfmvLZ/VHgUBkM5u9A8fvwE9lv3F9DHEnJZS3reQqyO47i8z4VgtrXOXoTn48srMACsuqsMza0tKF6qSbuNSHc3ImPfKv/xZGJ8HC902nGu99yCP+azTA35eABkCbxQsXN1UiEccwos4/7y+7GhYgPuWn0XvqJSpf46Jb9ZetHVaBTDQ8M4ffL0goVN/wjWsJtgwbl+L2T+nG9NuGkCf4EbB09EX77VjbhdQUTcvwFtwhQyXNo3TwAAAABJRU5ErkJggg==";
return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,l,g,b,d,f,h,c,q,p;a.Color=function(a,f){this.b=this.g=this.r=0;this.a=1;this.evaluator=f;if(a){if(babel[a]&&("net"===babel[a]&&(a="rojo"),a=babel[a],this.r=parseInt("0x"+a.substring(1,3),16),this.g=parseInt("0x"+a.substring(3,5),16),this.b=parseInt("0x"+a.substring(5,7),16),this.colorStr=a,this.getColor=this.getColorString),6===a.length&&(this.r=parseInt("0x"+a.substring(0,2),16),this.g=parseInt("0x"+
a.substring(2,4),16),this.b=parseInt("0x"+a.substring(4,6),16),this.colorStr="#"+a,this.getColor=this.getColorString),8===a.length&&(this.r=parseInt("0x"+a.substring(2,4),16),this.g=parseInt("0x"+a.substring(4,6),16),this.b=parseInt("0x"+a.substring(6,8),16),this.a=1-parseInt("0x"+a.substring(0,2),16)/255,this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString),"("===a[0]){g=[];b=this.splitComa(a.substring(1,a.length-1));for(var c=0,h=b.length;c<h;c++)d=
parseInt(b[c],16),b[c]!=d.toString(16)&&b[c]!=="0"+d.toString(16)?("["===b[c].charAt(0)&&"]"===b[c].charAt(b[c].length-1)&&(b[c]=b[c].substring(1,b[c].length-1)),g.push(this.evaluator.parser.parse(b[c]))):g.push(this.evaluator.parser.parse((d/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=q=c=h=0,d=a.length;b<d;b++)p=a.charAt(b),"("===p?h++:")"===p?h--:"["===p?c++:"]"===p?c--:","===p&&(0===h&&0===c)&&(f.push(a.substring(q,b)),q=b+1);f.push(a.substring(q));return f};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){l=this.evaluator;this.r=e(255*l.evalExpression(this.rExpr));this.g=e(255*l.evalExpression(this.gExpr));this.b=e(255*l.evalExpression(this.bExpr));this.a=1-l.evalExpression(this.aExpr);return"rgba("+
this.r+","+this.g+","+this.b+","+this.a+")"};a.Color.prototype.borderColor=function(){return 380>this.r+this.g+this.b?"white":"black"};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=document.head,l=document.createElement("meta");l.setAttribute("http-equiv","X-UA-Compatible");l.setAttribute("content","chrome=1");e.appendChild(l);l=document.createElement("meta");l.setAttribute("name","viewport");l.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
e.appendChild(l);l=document.createElement("meta");l.setAttribute("name","apple-mobile-web-app-capable");l.setAttribute("content","yes");e.appendChild(l);l=document.createElement("meta");l.setAttribute("name","apple-mobile-web-app-status-bar-style");l.setAttribute("content","black-translucent");e.appendChild(l);(e=document.getElementById("StyleDescartesApps2"))&&e.parentNode.removeChild(e);e=document.createElement("style");e.type="text/css";e.id="StyleDescartesApps2";e.setAttribute("rel","stylesheet");
document.head.appendChild(e);e.innerHTML="body{ text-rendering:geometricPrecision; }\ncanvas{ image-rendering:optimizeSpeed; image-rendering:-moz-crisp-edges; image-rendering:-webkit-optimize-contrast; image-rendering:optimize-contrast; -ms-interpolation-mode:nearest-neighbor; }\ndiv.DescartesCatcher{ background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; }\ndiv.DescartesAppContainer{ border:0px solid black; position:relative; overflow:hidden; top:0px; left:0px; }\ndiv.DescartesLoader{ background-color :#efefef; position:absolute; overflow:hidden; -moz-box-shadow:0px 0px 0px #888; -webkit-box-shadow:0px 0px 100px #888; box-shadow:0px 0px 100px #888; background-image:linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-o-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-moz-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-webkit-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-ms-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); top:0px; left:0px; }\ndiv.DescartesLoaderImage{ background-repeat:no-repeat; background-position:center; position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesLoaderBar{ position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesSpace2DCanvas, canvas.DescartesSpace3DCanvas, div.blocker{ position:absolute; overflow:hidden; left:0px; top:0px; }\ndiv.DescartesSpace2DContainer, div.DescartesSpace3DContainer{ position:absolute; overflow:hidden; line-height:0px; }\ncanvas.DescartesButton{ position:absolute; cursor:pointer; }\ndiv.DescartesSpinnerContainer, div.DescartesTextFieldContainer{ background:lightgray; position:absolute; overflow:hidden; }\ninput.DescartesSpinnerField, input.DescartesTextFieldField, input.DescartesMenuField, input.DescartesScrollbarField{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding:0px; border:solid #666666 1px; position:absolute; top:0px; }\nlabel.DescartesSpinnerLabel, label.DescartesMenuLabel, label.DescartesScrollbarLabel, label.DescartesTextFieldLabel{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; font-weight:normal; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:#e0e4e8; position:absolute; left:0px; top:0px; }\ndiv.DescartesGraphicControl{ border-style:none; position:absolute; }\ndiv.DescartesTextAreaContainer{ position:absolute; overflow:hidden; background:#c0d0d8; }\nselect.DescartesMenuSelect{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding-top:0%; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:white; position:absolute; left:0px; top:0px; }\ndiv.DescartesScrollbarContainer{ background:#eeeeee; overflow:hidden; position:absolute; }\n";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sin,l=Math.floor,g=Math.random,b=Math.round,d=Math.abs,f=String.fromCharCode,h,c,q,p,k,r,t,u,m,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(l(d(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){c=l(31*g());this.key=this.getKey(c);p=f(this.alfanum(c));return p+this.encripta(a)};
a.Krypto.prototype.decode=function(a){c=this.numalfa(a.charCodeAt(0));this.key=this.getKey(c);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;r=Array(3*a.length);for(var f=0,c=a.length;f<c;f++)m=256*l(a[f]+128)+b(255*g())+65536*b(255*g()),v=l((m<<this.shift(f))/256),r[3*f]=this.alfanum(v%32),r[3*f+1]=this.alfanum(v/32%
32),r[3*f+2]=this.alfanum(v/1024%32);return r};a.Krypto.prototype.desencripta=function(a){return this.bytesToString(this.desencriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.desencriptaAux=function(a){if(null==a||null==this.key)return null;t=Array(a.length/3);for(var b=0,f=t.length;b<f;b++)v=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),m=l(256*v>>this.shift(b)),u=l(m/256)%256-128,0>u&&(u+=256),t[b]=u;return t};a.Krypto.prototype.alfanum=function(a){a=l(a);return 10>
a?48+a:87+a};a.Krypto.prototype.numalfa=function(a){return 58>a?a-48:a-87};a.Krypto.prototype.stringToBytes=function(a){p=Array(a.length);for(var b=0,f=a.length;b<f;b++)p[b]=a.charCodeAt(b);return p};a.Krypto.prototype.bytesToString=function(a){for(var b=0,c=a.length;b<c;b++)a[b]=f(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){q=this.key.charCodeAt(a%this.key.length);p=this.numalfa(q);k=l(p/2%8);0==k&&(k=4);return k};a.Krypto.prototype.parseByte=function(a){a=parseInt(a);a=0>a?0:a;
return 255<a?255:a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Animation=function(e,l){this.parent=e;var g=e.evaluator,b=g.parser,d=new a.Auxiliary(e);this.delay=l.delay?b.parse(l.delay):b.parse("60");this.loop=l.loop?l.loop:!1;this.auto=void 0==l.auto?!0:l.auto;this.controls=l.controls;this.init=d.splitInstructions(b,l.init);this.doExpr=d.splitInstructions(b,l.doExpr);l.whileExpr&&(this.whileExpr=b.parse(l.whileExpr));var f=this,h,c,q=f.doExpr.length;this.animationExec=
function(){for(c=0;c<q;c++)g.evalExpression(f.doExpr[c]);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,l=this.init.length;a<l;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,l){this.parent=a;this.evaluator=this.parent.evaluator};a.Action.prototype.execute=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Message=function(e,l){a.Action.call(this,e,l);this.parameter=(l||"").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,l){a.Action.call(this,e,l);var g=this.evaluator,b=g.parser;l=(l||"").replace(/&squot;/g,"'");l=l.replace(/;/g,"\\n");l=l.split("\\n")||[""];for(var d=[],f,h=0,c=l.length;h<c;h++)(f=b.parse(l[h],!0))&&d.push(f);c=d.length;this.execute=function(){for(h=0;h<c;h++)g.evalExpression(d[h])}};
a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(e,l){a.Action.call(this,e,l);this.parameter=l;this.target="_blank";var 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,l){a.Action.call(this,e,l);this.parameter=l;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 d=a.getElementsByTagName("applet");d&&0<d.length&&(this.innerWidth=d[0].width,this.height=d[0].height,a.body.style.margin="0px",a.body.style.padding="0px",d[0].parentNode.style.margin="0px",d[0].parentNode.style.padding="0px")}})};a.extend(a.OpenScene,a.Action);a.OpenScene.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.About=function(e,l){a.Action.call(this,e,l);l||(this.urlAbout=
window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+l)};a.extend(a.About,a.Action);a.About.prototype.execute=function(){if(this.urlAbout)var a=window.open(this.urlAbout,"_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes");else a=window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes"),a.document.write("<hmtl><head><title>Cr\u00e9ditos</title></head><body><h1>Aqu\u00ed van los cr\u00e9ditos</h1></body></html>")};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Config=function(e,l){a.Action.call(this,e,l)};a.extend(a.Config,a.Action);a.Config.prototype.execute=function(){window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'>"+this.parent.applet.outerHTML+"</xmp>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Init=function(e,l){a.Action.call(this,e,l)};
a.extend(a.Init,a.Action);a.Init.prototype.execute=function(){this.parent.init()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Clear=function(e,l){a.Action.call(this,e,l)};a.extend(a.Clear,a.Action);a.Clear.prototype.execute=function(){this.parent.clear()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Animate=function(e,l){a.Action.call(this,e,l)};a.extend(a.Animate,a.Action);a.Animate.prototype.execute=function(){this.parent.play()};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;a.InitAnimation=function(e,l){a.Action.call(this,e,l)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g;a.PlayAudio=function(l,g){a.Action.call(this,l,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 d in b)b.hasOwnProperty(d)&&(this[d]=
b[d])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var e,l;a.Auxiliary.prototype.splitInstructions=function(a,b){l=[];b=b?b.split(";"):[""];for(var d=0,f=b.length;d<f;d++)(e=a.parse(b[d],!0))&&l.push(e);return l};a.Auxiliary.prototype.getPrivateVariables=function(a,b){l=[];b=b?b.split(/;|,/):[""];for(var d=0,f=b.length;d<f;d++)(e=a.parse(b[d],!0))&&l.push(e);d=0;for(f=l.length;d<f;d++)l[d]="asign"===l[d].type?l[d].childs[0].value:"identifier"===l[d].type?
l[d].value:"";return l};a.Auxiliary.prototype.parseExpressions=function(a){this.init=this.splitInstructions(a,this.init);this.privateVars=this.getPrivateVariables(a,this.local);this.doExpr=this.splitInstructions(a,this.doExpr);this.whileExpr=a.parse(this.whileExpr)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Variable=function(e,l){a.Auxiliary.call(this,e,l);var 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"),l=document.createElement("label");l.appendChild(document.createTextNode("___"+this.id+"=___"));var g=document.createElement("input");g.value=this.expresionString;g.disabled=!this.editable;a.appendChild(l);a.appendChild(g);var b=this,d=b.evaluator.parser;g.onkeydown=
function(a){13==a.keyCode&&(b.expresion=d.parse(this.value),d.setVariable(b.id,b.expresion),b.parent.update())};this.parent.editableRegion.textFields.push({container:a,type:"div"})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Constant=function(e,l){a.Auxiliary.call(this,e,l);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=function(){this.evaluator.setVariable(this.id,this.evaluator.evalExpression(this.expresion))};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,g;a.Vector=function(b,d){e=b.evaluator;l=e.parser;this.size=l.parse("3");a.Auxiliary.call(this,b,d);this.expresion=this.expresion.split(";");this.parseFile=l.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){e=this.evaluator;l=e.parser;this.oldFile=this.file;if(g=e.evalExpression(this.parseFile))this.file=g;var b;this.file&&((vectorElement=document.getElementById(this.file))&&
"descartes/vectorFile"==vectorElement.type?(b=vectorElement.text,"\n"==b[0]&&(b=b.substring(1))):b=a.openExternalFile(this.file),null!=b&&(b=b.replace(/\r/g,"").split("\n")),null==b||1==b.length&&""==b[0]?this.size=0:(this.expresion=b,this.size=null),null===this.size&&(this.size=l.parse(this.expresion.length+"")));var d;b=0;for(var f=this.expresion.length;b<f;b++)(d=l.parse(this.expresion[b],!0))&&"asign"!=d.type&&(d=l.parse(this.id+"["+b+"]="+this.expresion[b],!0)),this.expresion[b]=d;d=[];b=0;for(f=
e.evalExpression(this.size);b<f;b++)d.push(0);e.vectors[this.id]=d;e.setVariable(this.id+".long",e.evalExpression(this.size));b=0;for(f=this.expresion.length;b<f;b++)e.evalExpression(this.expresion[b])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(e,l){var g=e.evaluator,b=g.parser;this.rows=b.parse("3");this.columns=b.parse("3");a.Auxiliary.call(this,e,l);this.expresion=this.splitInstructions(b,this.expresion);var b=g.evalExpression(this.rows),d=g.evalExpression(this.columns),
f=[];f.type="matrix";for(var h,c=0;c<d;c++){h=[];for(var q=0,p=b;q<p;q++)h.push(0);f[c]=h}g.matrices[this.id]=f;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,l=a.evalExpression(this.rows),g=a.evalExpression(this.columns);a.setVariable(this.id+".filas",l);a.setVariable(this.id+".columnas",g);var b=a.matrices[this.id];b.rows=l;b.cols=g;l=0;for(g=this.expresion.length;l<g;l++)a.evalExpression(this.expresion[l])};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;a.Function=function(e,l){a.Auxiliary.call(this,e,l);var g=this.evaluator,b=g.parser,d=this.id.indexOf("(");this.name=this.id.substring(0,d);this.params=this.id.substring(d+1,this.id.length-1);this.domain=this.range?b.parse(this.range):b.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(b);this.expresion=b.parse(this.expresion);var f=
this;this.functionExec=function(){this.iterations=0;if(f.numberOfParams<=arguments.length){for(var b=[],c=0,d=f.privateVars.length;c<d;c++)b.push(g.getVariable(f.privateVars[c])),g.setVariable(f.privateVars[c],0);for(var e=[],c=0,d=f.params.length;c<d;c++)e[c]=g.getVariable(f.params[c]),g.setVariable(f.params[c],arguments[c]);c=0;for(d=f.init.length;c<d;c++)g.evalExpression(f.init[c]);do{c=0;for(d=f.doExpr.length;c<d;c++)g.evalExpression(f.doExpr[c]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en la funci\u00f3n",
this.id),0}while(0<g.evalExpression(f.whileExpr));var k=g.evalExpression(f.expresion);a.rangeOK=g.evalExpression(f.domain);c=0;for(d=f.params.length;c<d;c++)g.setVariable(f.params[c],e[c]);c=0;for(d=f.privateVars.length;c<d;c++)g.setVariable(f.privateVars[c],b[c]);return k}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,l){a.Auxiliary.call(this,e,l);var g=this.evaluator;
this.parseExpressions(g.parser);this.algorithmExec=function(){for(var a=this.iterations=0,d=this.init.length;a<d;a++)g.evalExpression(this.init[a]);do{a=0;for(d=this.doExpr.length;a<d;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,l){a.Auxiliary.call(this,e,l);console.log(l);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,l,g,b,d;a.Graphic=function(b,d){this.parent=b;this.evaluator=b.evaluator;var c=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=c.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=c.parse("(0,0)");this.family="";this.family_interval=c.parse("[0,1]");this.family_steps=
c.parse("8");this.editable=!1;this.font=5<=this.parent.version?"Monospaced,PLAIN,15":"Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=c.parse("2");for(var g in d)d.hasOwnProperty(g)&&(this[g]=d[g]);this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backgroundCanvas.getContext("2d"));this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?
parseInt(this.fontSize[1]):10};a.Graphic.prototype.getSpace=function(){for(var a=this.parent.spaces,b,c=0,d=a.length;c<d;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic.prototype.getFamilyValues=function(){e=this.evaluator;l=e.evalExpression(this.family_interval);this.familyInf=l[0][0];this.familySup=l[0][1];this.fSteps=Math.round(e.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,
b,c){e=this.evaluator;this.getFamilyValues();g=e.getVariable(this.family);if(0<=this.fSteps)for(var d=0,l=this.fSteps;d<=l;d++)e.setVariable(this.family,this.familyInf+d*this.family_sep),0<e.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,c));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,c,g,l,k,r,t,u,m,v){if("rtfNode"===h.type)a.fillStyle=l.getColor(),a.strokeStyle=l.getColor(),a.textBaseline="alphabetic",h.draw(a,c,g,u,m,r,v);else{"simpleText"===h.type&&(h=h.toString(u,m).split("\\n"));c+=k.match("Arial")?-2:k.match("Times")?-2:0;e=this.evaluator;a.fillStyle=l.getColor();a.font=
k;a.textAlign=r;a.textBaseline=t;this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=3);d=1.2*this.fontSize||0;l=0;for(k=h.length;l<k;l++)b=h[l],this.border&&(a.lineJoin="round",a.strokeText(b,c,g+d*l)),a.fillText(b,c,g+d*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 d="'",f=0,h=0,c=-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===c?(this.textElements.push(b.substring(h,f)),this.textElementsMacros.push("'"+b.substring(h,f)+"'"),h=f,c++):"["===e?c++:"]"===e&&0===c?(this.textElements.push(this.evaluator.parser.parse(b.substring(h,
f+1))),this.textElementsMacros.push("["+b.substring(h,f+1)+"]"),h=f+1,c--):("]"==b.charAt(f)&&(c=0>c?c:c-1),d+=b.charAt(f)),f++;this.textElements.push(b.substring(h,f));this.textElementsMacros.push("'"+b.substring(h,f)+"'")};var e,l;a.SimpleText.prototype.toString=function(a,b){e="";for(var d=0,f=this.textElements.length;d<f;d++)"string"===typeof this.textElements[d]?e+=this.textElements[d]:(l=this.evaluator.evalExpression(this.textElements[d])[0][0],""!==l&&("string"===typeof l?e+=l:(l=parseFloat(l),
l=b?l.toFixed(a):parseFloat(l.toFixed(a)),e+=l.toString().replace(".",this.parent.decimal_symbol))));return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,l,g,b,d,f,h,c,q,p,k,r,t,u,m,v,n,s,w,z,C,y,E,D,B,A,H,G;a.Equation=function(b,c){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP="";a.Graphic.call(this,b,c);this.generateStroke();this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();
t=new a.R2;u=new a.R2;m=new a.R2;s=new a.R2;v=new a.R2};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"===this.expresion.type){var b=this.expresion.childs[0],c=this.expresion.childs[1];"identifier"==b.type&&"y"==b.value&&!c.contains("y")?(this.funExpr=c,this.of_y=!1,this.drawAux=this.drawAuxFun):"identifier"==c.type&&"y"==c.value&&!b.contains("y")?(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):"identifier"==b.type&&"x"==b.value&&!c.contains("x")?
(this.funExpr=c,this.of_y=!0,this.drawAux=this.drawAuxFun):"identifier"==c.type&&("x"==c.value&&!b.contains("x"))&&(this.of_y=!0,this.funExpr=c,this.drawAux=this.drawAuxFun)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.generateStroke=function(){this.auxCanvas=document.createElement("canvas");var a=parseInt(this.evaluator.evalExpression(this.width));this.width_2=parseInt(a/2)||1;this.auxCanvas.setAttribute("width",a);this.auxCanvas.setAttribute("height",a);this.auxCtx=
this.auxCanvas.getContext("2d");this.auxCtx.fillStyle=this.color.getColor();this.auxCtx.fillRect(0,0,a,a)};a.Equation.prototype.update=function(){};a.Equation.prototype.draw=function(){""!=this.family?this.drawFamilyAux(this.ctx,this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,this.color))};a.Equation.prototype.drawFamilyAux=function(a,b,c){g=this.evaluator;this.getFamilyValues();tempParam=g.getVariable(this.family);if(0<=this.fSteps)for(var f=0,d=this.fSteps;f<=d;f++)g.setVariable(this.family,
this.familyInf+f*this.family_sep),this.drawAux(a,b,c);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,K,x){I.lineWidth=1;g=this.evaluator;b=g.parser;d=this.space;f=g.evalExpression(this.width);I.fillStyle=x.getColor();I.translate(-parseInt(f/2),-parseInt(f/2));h=b.getVariable("x");c=b.getVariable("y");q=d.w;p=d.h;k=parseInt(q/8);3>k&&(k=3);r=parseInt(p/8);3>r&&(r=3);l=[];t.set(0,
0);u.set(0,0);m.set(0,0);for(G=parseInt(r/2);G<p;G+=r)for(H=parseInt(k/2);H<q;H+=k)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(d.getRelativeX(H),d.getRelativeY(G)),n=this.newt.findZero(s),g.setVariable("x",n.x),g.setVariable("y",n.y),v.set(d.getAbsoluteX(n.x),d.getAbsoluteY(n.y))),w=v.ix(),z=v.iy(),!(0>w||w>=q||0>z||z>=p||l[w+z*d.w]))if(l[w+z*d.w]=!0,a.rangeOK&&g.evalExpression(this.drawif)&&I.drawImage(this.auxCanvas,
w,z),t.x=n.x,t.y=n.y,u.x=n.x,u.y=n.y,C=this.newt.getUnitNormal(),!(0==C.x&&0==C.y)){C.rotL90();m.x=C.x;m.y=C.y;E=y=0;for(D=!1;2>E;){D&&(m.x=-C.x,m.y=-C.y,n.x=t.x,n.y=t.y,u.x=n.x,u.y=n.y,this.abs_coord?v.set(n.x,n.y):v.set(d.getAbsoluteX(n.x),d.getAbsoluteY(n.y)),w=v.ix(),z=v.iy(),D=!1,y=0);this.abs_coord?(n.x+=m.x,n.y+=m.y):(n.x+=m.x/d.scale,n.y+=m.y/d.scale);n=this.newt.findZero(n);g.setVariable("x",n.x);g.setVariable("y",n.y);m.x=n.x-u.x;m.y=n.y-u.y;m.normalize();if(0==m.x&&0==m.y)break;u.x=n.x;
u.y=n.y;this.abs_coord?v.set(n.x,n.y):v.set(d.getAbsoluteX(n.x),d.getAbsoluteY(n.y));B=e(v.ix());A=e(v.iy());if(B!=w||A!=z)if(w=B,z=A,0<=w&&w<q&&0<=z&&z<p)if(y=0,l[w+z*d.w])break;else l[w+z*d.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,c){c||(b=this.space.w/2+this.space.Ox+this.space.scale*b);b<-a&&(b=-a);b>this.space.w+a&&(b=this.space.w+a);return b};a.Equation.prototype.Y=
function(a,b,c){c||(b=this.space.h/2+this.space.Oy-this.space.scale*b);b<-a&&(b=-a);b>this.space.h+a&&(b=this.space.h+a);return b};a.Equation.prototype.XX=function(a,b,c){return Math.round(this.X(a,b,c))};a.Equation.prototype.YY=function(a,b,c){return Math.round(this.Y(a,b,c))};a.Equation.prototype.extrapolate=function(b,c,f,d,h,g){for(var n=this.evaluator.getVariable(c),e=g/2,k=0;1E-12<Math.abs(e);){var l=this.evaluator.getVariable(c),m=this.evaluator.getVariable(c)+e;this.evaluator.setVariable(c,
m);var q=!0,p=h;h=this.evaluator.evalExpression(this.funExpr);this.evaluator.setVariable(f,h);if(0<this.evaluator.evalExpression(b)){var u=new a.R2(Math.min(p,h),Math.max(p,h)),t=0,t=0<g?this.Singularity(Math.abs(e),c,d,l,p,m,h,u):this.Singularity(Math.abs(e),c,d,m,h,l,p,u);0<t&&(q=!1)}else q=!1;q?k+=e:this.evaluator.setVariable(c,l);e/=2}this.evaluator.setVariable(c,n);return new a.R2(k/Math.abs(g),h)};a.Equation.prototype.extrapolateOnSingularity=function(b,c,f,d,h,g){d=this.evaluator.getVariable(c);
for(var e=g/2,n=0,k=h;1E-12<Math.abs(e);){this.evaluator.setVariable(this.evaluator.getVariable(c)+e);var l=!0;0<this.evaluator.evalExpression(b)?(k=this.evaluator.evalExpression(this.funExpr),this.evaluator.setVariable(f,k),0>=this.evaluator.evalExpression(b)&&(l=!1)):l=!1;l?n+=e:this.evaluator.setVariable(this.evaluator.getVariable(c)-e);e/=2}if(0==n){e=g/2;n=g;for(k=h;1E-12<Math.abs(e);)this.evaluator.setVariable(this.evaluator.getVariable(c)-e),l=!0,0<this.evaluator.evalExpression(b)?k=this.evaluator.evalExpression(this.funExpr):
l=!1,l?n+=-e:this.evaluator.setVariable(this.evaluator.getVariable(c)+e),e/=2}this.evaluator.setVariable(d);return new a.R2(n/Math.abs(g),k)};a.Equation.prototype.Singularity=function(a,b,c,f,d,h,e,g){if(f>=h)return 2;var n=this.evaluator.getVariable(b),k=0;if(1E-12>Math.abs(h-f)||1E-8>Math.abs(h-f)&&Math.abs(e-d)>Math.abs(a))return this.evaluator.setVariable(b,n),1;var l=(f+h)/2;this.evaluator.setVariable(b,l);var m=this.evaluator.evalExpression(this.funExpr);if(Math.abs(e-d)>a){this.evaluator.setVariable(b,
f-1E-6);var q=this.evaluator.evalExpression(this.funExpr),q=(d-q)/1E-6;this.evaluator.setVariable(b,h+1E-6);var p=(this.evaluator.evalExpression(this.funExpr)-e)/1E-6,u=(e-d)/(h-f);if(10>Math.abs(p)||10>Math.abs(q))if((0<=p&&0<=q||0>=p&&0>=q)&&8*Math.abs(p)<Math.abs(u))return this.evaluator.setVariable(b,n),2}g.x<=m&&m<=g.y||(this.evaluator.setVariable(b,l),g.x=Math.min(d,m),g.y=Math.max(d,m),f=this.Singularity(a/2,b,c,f,d,l,m,g),this.evaluator.setVariable(b,h),g.x=Math.min(e,m),g.y=Math.max(e,m),
a=this.Singularity(a/2,b,c,l,m,h,e,g),k=Math.max(f,a));this.evaluator.setVariable(b,n);return k};a.Equation.prototype.drawAuxFun=function(b,f,d){h=this.evaluator.parser.getVariable("x");c=this.evaluator.parser.getVariable("y");f="x";d="y";this.of_y&&(f="y",d="x");var e=this.drawif,g=this.evaluator.evalExpression(this.width),n=!1,k=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),k=this.of_y?k.ix():k.iy(),l=0,m=0,q=0,p=1/this.space.scale,u=p*(this.of_y?-this.space.h+(this.space.h/
2+this.space.Oy):-(this.space.w/2+this.space.Ox)),l=0;this.abs_coord&&(u=this.space.h,p=-1);for(var t=this.of_y?this.space.h:this.space.w;m<t;){var r=!0,w=0;this.evaluator.setVariable(f,u);var s=this.evaluator.evalExpression(this.funExpr);if(isNaN(s))r=!1;else{this.evaluator.setVariable(d,s);if(0<this.evaluator.evalExpression(this.drawif)&&a.rangeOK){if(n){var w=Math.min(l,s),v=Math.max(l,s),v=new a.R2(w,v),w=this.Singularity(p,f,0,u-p,l,u,s,v);0===w?(l<=s?(l=v.x,s=v.y):(s=v.x,l=v.y),w=this.of_y?
this.XX(g,l,this.abs_coord):this.YY(g,l,this.abs_coord),l=this.abs_coord?Math.round(s):this.of_y?this.XX(g,s,this.abs_coord):this.YY(g,s,this.abs_coord),this.fillM&&l>k&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(k+1,this.space.h-m+0.5),b.lineTo(l,this.space.h-m+0.5)):(b.moveTo(m+0.5,k+1),b.lineTo(m+0.5,l)),b.stroke()),this.fillP&&l<k&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(k-1,this.space.h-m+0.5),b.lineTo(l,this.space.h-
m+0.5)):(b.moveTo(m+0.5,k-1),b.lineTo(m+0.5,l)),b.stroke()),b.lineWidth=g,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(w+0.5,this.space.h-q),b.lineTo(l+0.5,this.space.h-m)):(b.moveTo(q+0.5,w),b.lineTo(m+0.5,l)),b.stroke()):(1===w&&(this.evaluator.setVariable(f,u-p),q=this.extrapolate(e,f,d,0,l,p),this.YY(g,q.y,this.abs_coord),this.evaluator.setVariable(f,u),q=this.extrapolate(e,f,d,0,s,-p),this.YY(g,q.y,this.abs_coord)),this.YY(g,s,this.abs_coord))}else q=this.extrapolateOnSingularity(e,
f,d,0,s,-p),this.YY(g,q.y,this.abs_coord),this.YY(g,s,this.abs_coord);l=s}else r=!1;n&&!r&&(this.evaluator.setVariable(f,u-p),this.evaluator.setVariable(d,l),q=this.extrapolate(e,f,d,0,l,p),this.YY(g,q.y,this.abs_coord),this.evaluator.setVariable(f,u))}n=r;u+=p;q=m++}this.evaluator.parser.setVariable("x",h);this.evaluator.parser.setVariable("y",c)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;
a.onkeydown=function(a){13==a.keyCode&&(b.expresion=b.evaluator.parser.parse(this.value),b.parseExpression(),b.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Curve=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,c);(this.visible=
2==this.parent.version&&void 0==this.visible?!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);var l,g,b,d,f,h,c,q,p,k,r;a.Curve.prototype.update=function(){l=this.evaluator;g=l.evalExpression(this.parameter_interval);this.paraInf=g[0][0];this.paraSup=g[0][1];this.pSteps=l.evalExpression(this.parameter_steps);this.paraSep=0<this.pSteps?Math.abs(this.paraSup-this.paraInf)/this.pSteps:0};a.Curve.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Curve.prototype.drawTrace=
function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Curve.prototype.drawAux=function(g,u,m){l=this.evaluator;b=this.space;d=e(l.evalExpression(this.width));g.lineWidth=0<d?d:1E-6;g.lineCap="round";g.lineJoin="round";g.strokeStyle=m.getColor();f=l.getVariable(this.parameter);g.beginPath();l.setVariable(this.parameter,this.paraInf);h=l.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&&(c=a.degToRad(l.evalExpression(this.rotateExp)),q=Math.cos(c),p=Math.sin(c),k=this.exprX*q-this.exprY*p,r=this.exprX*p+this.exprY*q,this.exprX=k,this.exprY=r);g.moveTo(this.exprX+0.5,this.exprY+0.5);for(m=1;m<=this.pSteps;m++)l.setVariable(this.parameter,this.paraInf+m*this.paraSep),h=l.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&&(k=this.exprX*q-this.exprY*
p,r=this.exprX*p+this.exprY*q,this.exprX=k,this.exprY=r),g.lineTo(this.exprX+0.5,this.exprY+0.5);this.fill&&(g.fillStyle=u.getColor(),g.fill());g.stroke();l.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,l=Math.round,g,b,d,f,h,c,q,p,k,r,t,u,m;a.Sequence=function(b,c){this.size=b.evaluator.parser.parse("2");this.range=b.evaluator.parser.parse("[1, 100]");a.Graphic.call(this,b,c)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){g=this.evaluator;d=g.evalExpression(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1];this.rotateExp&&(f=a.degToRad(g.evalExpression(this.rotateExp)),h=Math.cos(f),c=Math.sin(f),q=this.exprX*
h-this.exprY*c,p=this.exprX*c+this.exprY*h,this.exprX=q,this.exprY=p);t=g.evalExpression(this.range);this.rangeInf=t[0][0];this.rangeMax=t[0][1]};a.Sequence.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Sequence.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Sequence.prototype.drawAux=function(a,c){g=this.evaluator;b=this.space;u=Math.ceil(g.evalExpression(this.size)-0.4);a.fillStyle=c.getColor();a.beginPath();this.rangeInf>this.rangeMax&&
(m=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=m);for(var f=g.getVariable("n"),h=this.rangeInf,q=this.rangeMax;h<=q;h++)g.setVariable("n",h),d=g.evalExpression(this.expresion),this.exprX=d[0][0],this.exprY=d[0][1],k=this.abs_coord?l(this.exprX):l(b.getAbsoluteX(this.exprX)),r=this.abs_coord?l(this.exprY):l(b.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(k,r,u,0,e,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,k+u,r-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,l=Math.round,g,b,d,f,h,c,q,p,k,r,t,u;a.Point=function(b,c){this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Point,a.Graphic);a.Point.prototype.update=function(){g=this.evaluator;d=g.evalExpression(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1];this.rotateExp&&(f=a.degToRad(g.evalExpression(this.rotateExp)),
h=Math.cos(f),c=Math.sin(f),q=this.exprX*h-this.exprY*c,p=this.exprX*c+this.exprY*h,this.exprX=q,this.exprY=p)};a.Point.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Point.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Point.prototype.drawAux=function(a,c){g=this.evaluator;b=this.space;t=l(g.evalExpression(this.size));u=t+1;a.fillStyle=c.getColor();k=this.abs_coord?l(this.exprX):l(b.getAbsoluteX(this.exprX));r=this.abs_coord?l(this.exprY):
l(b.getAbsoluteY(this.exprY));a.beginPath();a.arc(k,r,t,0,e,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,k+u+1,r-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,l=2*Math.PI,g,b,d,f,h,c,q,p,k,r,t,u,m,v,n,s,w,z;a.Segment=function(b,c){this.width=b.evaluator.parser.parse("1");this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Segment,
a.Graphic);a.Segment.prototype.update=function(){g=this.evaluator;d=g.evalExpression(this.expresion);this.endPoints=[];for(var b=0,e=d.length;b<e;b++)this.endPoints[b]={x:d[b][0],y:d[b][1]};if(this.rotateExp){f=a.degToRad(g.evalExpression(this.rotateExp));h=Math.cos(f);c=Math.sin(f);b=0;for(e=this.endPoints.length;b<e;b++)q=this.endPoints[b].x*h-this.endPoints[b].y*c,p=this.endPoints[b].x*c+this.endPoints[b].y*h,this.endPoints[b].x=q,this.endPoints[b].y=p}};a.Segment.prototype.draw=function(){this.uber.draw.call(this,
this.color,this.color)};a.Segment.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Segment.prototype.drawAux=function(a,c,f){g=this.evaluator;b=this.space;k=e(g.evalExpression(this.width));a.lineWidth=0<k?k:1E-6;m=g.evalExpression(this.size);0>m&&(m=0);a.fillStyle=c.getColor();a.strokeStyle=f.getColor();a.lineCap="round";r=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,m,0,l,!0);a.arc(w,z,m,0,l,!0);a.fill();this.text!=[""]&&(t=parseInt((n+w)/2)-3,u=parseInt((s+z)/2)+3,this.uber.drawText.call(this,a,this.text,t+r,u-r,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,l=Math.round,g,b,d,f,h,c,q,p,k,r,t,u,m,v,n,s,w,z;a.Arrow=function(b,c){this.width=b.evaluator.parser.parse("5");this.size=b.evaluator.parser.parse("2");this.spear=b.evaluator.parser.parse("8");this.arrow=new a.Color("ee0022");a.Graphic.call(this,b,c)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){g=this.evaluator;b=g.evalExpression(this.expresion);this.endPoints=[];for(var e=0,n=b.length;e<n;e++)this.endPoints[e]=
{x:b[e][0],y:b[e][1]};if(this.rotateExp){d=a.degToRad(g.evalExpression(this.rotateExp));f=Math.cos(d);h=Math.sin(d);e=0;for(n=this.endPoints.length;e<n;e++)c=this.endPoints[e].x*f-this.endPoints[e].y*h,q=this.endPoints[e].x*h+this.endPoints[e].y*f,this.endPoints[e].x=c,this.endPoints[e].y=q}};a.Arrow.prototype.draw=function(){this.uber.draw.call(this,this.arrow,this.color)};a.Arrow.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.arrow,this.trace)};a.Arrow.prototype.drawAux=function(b,
c,f){g=this.evaluator;p=this.space;g.evalExpression(this.size);t=g.evalExpression(this.width);0>t&&(t=0);u=Math.ceil(t/2);m=p.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);v=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);b.fillStyle=c.getColor();b.strokeStyle=f.getColor();b.lineWidth=2;this.abs_coord?(n=l(this.endPoints[0].x),s=l(this.endPoints[0].y),w=l(this.endPoints[1].x),z=l(this.endPoints[1].y)):
(n=l(p.getAbsoluteX(this.endPoints[0].x)),s=l(p.getAbsoluteY(this.endPoints[0].y)),w=l(p.getAbsoluteX(this.endPoints[1].x)),z=l(p.getAbsoluteY(this.endPoints[1].y)));c=g.evalExpression(this.spear);0>c&&(c=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*=m,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-c-t),e(-u));b.lineTo(e(v-2*c),e(-c-u));b.lineTo(e(v),0);b.lineTo(e(v-2*c),e(c+u));b.lineTo(e(v-c-t),e(u));b.lineTo(-u,e(u));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(k=parseInt((n+w)/2)-3,r=parseInt((s+z)/2)+3,this.uber.drawText.call(this,b,this.text,k,r,f,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,l,g,b,d,f,h,c,q,p,k,r,t;a.Polygon=function(b,
c){this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,c);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){l=this.evaluator;b=l.evalExpression(this.expresion);for(var e=0,g=b.length;e<g;e++)this.endPoints[e]={x:b[e][0],y:b[e][1]};if(this.rotateExp){d=a.degToRad(l.evalExpression(this.rotateExp));f=Math.cos(d);h=Math.sin(d);e=0;for(g=this.endPoints.length;e<g;e++)c=this.endPoints[e].x*f-this.endPoints[e].y*h,q=this.endPoints[e].x*h+this.endPoints[e].y*
f,this.endPoints[e].x=c,this.endPoints[e].y=q}};a.Polygon.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Polygon.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Polygon.prototype.drawAux=function(a,b,c){l=this.evaluator;g=this.space;p=e(l.evalExpression(this.width));a.lineWidth=0<p?p:1E-6;a.strokeStyle=c.getColor();a.lineCap="round";a.lineJoin="round";k=0<p?0.5:0;r=this.abs_coord?e(this.endPoints[0].x):e(g.getAbsoluteX(this.endPoints[0].x));
t=this.abs_coord?e(this.endPoints[0].y):e(g.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(r+k,t+k);c=1;for(var f=this.endPoints.length;c<f;c++)r=this.abs_coord?e(this.endPoints[c].x):e(g.getAbsoluteX(this.endPoints[c].x)),t=this.abs_coord?e(this.endPoints[c].y):e(g.getAbsoluteY(this.endPoints[c].y)),a.lineTo(r+k,t+k);this.fill&&(a.fillStyle=b.getColor(),a.fill());a.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Arc=function(b,c){this.width=
b.evaluator.parser.parse("1");this.fill="";this.center=b.evaluator.parser.parse("(0,0)");this.radius=b.evaluator.parser.parse("1");this.init=b.evaluator.parser.parse("0");this.end=b.evaluator.parser.parse("90");a.Graphic.call(this,b,c)};a.extend(a.Arc,a.Graphic);var l,g,b,d,f,h,c,q,p,k,r,t,u,m,v,n,s,w,z,C,y,E,D,B;a.Arc.prototype.update=function(){l=this.evaluator;g=l.evalExpression(this.center);this.exprX=g[0][0];this.exprY=g[0][1];this.rotateExp&&(b=a.degToRad(l.evalExpression(this.rotateExp)),d=
Math.cos(b),f=Math.sin(b),h=this.exprX*d-this.exprY*f,c=this.exprX*f+this.exprY*d,this.exprX=h,this.exprY=c);q=l.evalExpression(this.init);p=l.evalExpression(this.end);"(expr)"==this.init.type&&"(expr)"==this.end.type||"[expr]"==this.init.type&&"[expr]"==this.end.type||"(expr)"==this.init.type&&"[expr]"==this.end.type||"[expr]"==this.init.type&&"(expr)"==this.end.type?(this.vectors=!0,k=q[0][0],r=q[0][1],t=p[0][0],u=p[0][1],m=Math.acos((1*k+0*r)/Math.sqrt(k*k+r*r)),v=Math.acos((1*t+0*u)/Math.sqrt(t*
t+u*u)),0<k&&(0<r&&!this.abs_coord)&&(m=2*Math.PI-m),0<k&&(0>r&&this.abs_coord)&&(m=2*Math.PI-m),0>k&&(0>r&&this.abs_coord)&&(m=2*Math.PI-m),0>k&&(0<r&&!this.abs_coord)&&(m=2*Math.PI-m),0<t&&(0<u&&!this.abs_coord)&&(v=2*Math.PI-v),0<t&&(0>u&&this.abs_coord)&&(v=2*Math.PI-v),0>t&&(0>u&&this.abs_coord)&&(v=2*Math.PI-v),0>t&&(0<u&&!this.abs_coord)&&(v=2*Math.PI-v),n=Math.min(m,v),s=Math.max(m,v),m=n,v=s,v-m>Math.PI&&this.abs_coord&&(m=s,v=n),v-m<=Math.PI&&!this.abs_coord&&(m=s,v=n),this.iniAng=m,this.endAng=
v):(this.vectors=!1,this.iniAng=a.degToRad(q),this.endAng=a.degToRad(p))};a.Arc.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Arc.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Arc.prototype.drawAux=function(a,b,c){l=this.evaluator;w=this.space;z=this.abs_coord?e(this.exprX):e(w.getAbsoluteX(this.exprX));C=this.abs_coord?e(this.exprY):e(w.getAbsoluteY(this.exprY));y=l.evalExpression(this.radius);!this.vectors&&this.iniAng>this.endAng&&
(E=this.iniAng,this.iniAng=this.endAng,this.endAng=E);0>y&&(y=0);D=!1;this.abs_coord||(y*=w.scale,this.vectors||(this.iniAng=-this.iniAng,this.endAng=-this.endAng,D=!0));this.vectors&&(D=this.abs_coord?!1:!0);B=e(l.evalExpression(this.width));a.lineWidth=0<B?B:1E-6;a.lineCap="round";a.strokeStyle=c.getColor();this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(z,C),a.arc(z,C,y,this.iniAng,this.endAng,D),a.fill());a.beginPath();a.arc(z,C,y,this.iniAng,this.endAng,D);a.stroke();this.text!=[""]&&
this.uber.drawText.call(this,a,this.text,z+4,C-2,this.color,this.font,"start","alphabetic",l.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){function e(a,b,f){c=4*(b+f*a.width);return{r:a.data[c],g:a.data[c+1],b:a.data[c+2],a:a.data[c+3]}}if(a.loadLib)return a;var l,g,b,d,f,h,c;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){l=this.evaluator.evalExpression(this.expresion);this.exprX=l[0][0];
this.exprY=l[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Fill.prototype.drawTrace=function(){};a.Fill.prototype.drawAux=function(a,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)));console.log(g,b);if(!(0>g||0>b||g>=this.space.w||b>=this.space.h)){d=[{x:g,y:b}];for(h=
e(imageData,g,b);0<d.length;){f=d.pop();g=f.x;b=f.y;var k=e(imageData,g,b);if(h.r===k.r&&h.g===k.g&&h.b===k.b&&h.a===k.a){var k=imageData,r=l;c=4*(g+b*k.width);k.data[c+0]=r.r;k.data[c+1]=r.g;k.data[c+2]=r.b;k.data[c+3]=255-r.a;0<g&&d.push({x:g-1,y:b});g<imageData.width-1&&d.push({x:g+1,y:b});d.push({x:g,y:b-1});d.push({x:g,y:b+1})}}this.ctx.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,g,b,d,f,h,c,q,p,k,r,t,u,m,v,n,s;a.Text=function(b,
c){this.width=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.align||(this.align="start");this.ascent=this.fontSize-Math.ceil(this.fontSize/7)-(this.font.match("Courier")?3:0);this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){e=this.evaluator;l=e.evalExpression(this.expresion);this.exprX=l[0][0];this.exprY=l[0][1];this.rotateExp&&(g=a.degToRad(e.evalExpression(this.rotateExp)),b=Math.cos(g),d=Math.sin(g),f=this.exprX*b-this.exprY*d,h=this.exprX*d+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?(k=this.text,this.ascent=0):k=this.splitText(this.text.toString(s,this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,a,k,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;c=e.evalExpression(this.width);k=[];this.ctx.font=this.font;if(20<=c&&"undefined"!=a.type){for(var b=0,f=a.length;b<f;b++)q=a[b],p=this.ctx.measureText(q).width,p>c?k=k.concat(this.splitWords(q,c)):k.push(q);r=Math.floor(1.2*this.fontSize)*k.length;e.setVariable("_Text_H_",r);return k}e.setVariable("_Text_H_",0);e.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=function(a,b){t=a;u=[];m=
"";n=0;for(var c,f=0,d=a.length;f<d;f++)v=t.charAt(f)," "===v&&(lastIndexOfWhite=f),m+=v,Math.round(this.ctx.measureText(m).width)>b&&(c=a.substring(n,f+1)," "!==v&&(-1===c.indexOf(" ")?(lastIndexOfWhite=f,f--):f=lastIndexOfWhite),u.push(a.substring(n,lastIndexOfWhite)),m="",n=f+1);u.push(a.substring(n));return u};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round;a.Image=function(b,c){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,
b,c);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);var l,g,b,d,f,h,c,q,p,k,r,t,u,m;a.Image.prototype.update=function(){l=this.evaluator;g=l.evalExpression(this.expresion);this.exprX=g[0][0];this.exprY=g[0][1];this.rotateExp&&(b=a.degToRad(l.evalExpression(this.rotateExp)),d=Math.cos(b),f=Math.sin(b),h=this.exprX*d-this.exprY*f,c=this.exprX*f+this.exprY*d,this.exprX=h,this.exprY=c);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((q=l.evalExpression(this.file))||""==q)this.img=this.parent.getImage(q)};a.Image.prototype.draw=function(){this.uber.draw.call(this)};a.Image.prototype.drawTrace=function(){this.uber.drawTrace.call(this)};a.Image.prototype.drawAux=function(b){l=this.evaluator;p=this.space;this.img&&(this.img.ready&&
this.img.complete)&&(k=this.centered?0:this.img.width/2,r=this.centered?0:this.img.height/2,t=this.abs_coord?e(this.exprX):e(p.getAbsoluteX(this.exprX)),u=this.abs_coord?e(this.exprY):e(p.getAbsoluteY(this.exprY)),m=a.degToRad(-l.evalExpression(this.inirot)),b.translate(t+k,u+r),b.rotate(m),b.scale(this.scaleX,this.scaleY),this.opacity&&(b.globalAlpha=l.evalExpression(this.opacity)),b.drawImage(this.img,-this.img.width/2,-this.img.height/2),b.setTransform(1,0,0,1,0,0),b.globalAlpha=1)};return a}(descartesJS||
{}),descartesJS=function(a){function e(a,b,f){c=4*(b+f*a.width);return{r:a.data[c],g:a.data[c+1],b:a.data[c+2],a:a.data[c+3]}}if(a.loadLib)return a;var l,g,b,d,f,h,c;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){l=this.evaluator.evalExpression(this.expresion);this.exprX=l[0][0];this.exprY=l[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Fill.prototype.drawTrace=function(){};a.Fill.prototype.drawAux=
function(a,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)));console.log(g,b);if(!(0>g||0>b||g>=this.space.w||b>=this.space.h)){d=[{x:g,y:b}];for(h=e(imageData,g,b);0<d.length;){f=d.pop();g=f.x;b=f.y;var k=e(imageData,g,b);if(h.r===k.r&&h.g===k.g&&h.b===k.b&&h.a===k.a){var k=imageData,r=l;c=4*(g+b*k.width);k.data[c+
0]=r.r;k.data[c+1]=r.g;k.data[c+2]=r.b;k.data[c+3]=255-r.a;0<g&&d.push({x:g-1,y:b});g<imageData.width-1&&d.push({x:g+1,y:b});d.push({x:g,y:b-1});d.push({x:g,y:b+1})}}this.ctx.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a,e){if(a.loadLib)return a;a.Macro=function(l,g){this.expresion=void 0;this.inirot=l.evaluator.parser.parse("0");a.Graphic.call(this,l,g);for(var b in g)g.hasOwnProperty(b)&&(this[b]=g[b]);this.graphics=[];b=l.lessonParser;var d=new a.Tokenizer;if(void 0!=
this.expresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var f=this.evaluator.evalExpression(this.expresion),h;f&&((h=document.getElementById(f))&&"descartes/macro"==h.type?h=h.text:(h=a.openExternalFile(f))&&!h.match(/tipo_de_macro/g)&&(h=null));var c,q;if(h){q=h.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");h=[];for(var f=0,p=q.length;f<p;f++)c=q[f].indexOf("="),-1!==c&&(c=q[f].substring(0,c),("id"===e[c]||"type"===e[c])&&h.push(b.split(q[f])));for(var k,r,t,u,f=0,p=h.length;f<p;f++){u=(k=h[f]||[])&&k[0]&&"id"===k[0][0];
q=0;for(c=k.length;q<c;q++)if(r=k[q][0].indexOf("."),-1!==r&&!u?(r=e[k[q][0].substring(r+1)],k[q][0]=this.name+"."+k[q][0]):r=e[k[q][0]],!("font"===r||("fill"===r||"color"===r||"arrow"===r)&&"("!==k[q][1].charAt(0)||"id"!==r&&void 0!==e[k[q][1]]))if("text"==r)if(k[q][1].match(/\{\\rtf1/)){r=k[q][1];var m=this;t=function(a,b){for(var c=d.tokenize(b.replace(/\&squot;/g,"'")),f=0,h=c.length;f<h;f++)"identifier"==c[f].type&&!"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+
c[f].value+"-")&&(c[f].value=m.name+"."+c[f].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+d.flatTokens(c)};r=r.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,t);r=r.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,t);k[q][1]=r}else{t=b.parseText(k[q][1]).textElementsMacros;for(var v=0,n=t.length;v<n;v++){r=d.tokenize(t[v].replace(/\&squot;/g,"'"));for(var s=0,w=r.length;s<w;s++)"identifier"===r[s].type&&!"-rnd-pi-e-sqr-sqrt-ra\u00edz-exp-log-log10-abs-ent-sgn-ind-sin-sen-cos-tan-cot-sec-csc-sinh-senh-cosh-tanh-coth-sech-csch-asin-asen-acos-atan-min-max-".match("-"+
r[s].value+"-")&&(r[s].value=this.name+"."+r[s].value);r=d.flatTokens(r).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");t[v]=r.substring(1,r.length-1)}k[q][1]=t.join("")}else{r=d.tokenize(k[q][1]);t=0;for(v=r.length;t<v;t++)"identifier"===r[t].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("-"+r[t].value+"-")&&(r[t].value=this.name+"."+r[t].value);k[q][1]=d.flatTokens(r)}}f=
0;for(p=h.length;f<p;f++)if(h[f][0]){k="";u=!1;q=0;for(c=h[f].length;q<c;q++)"type"===e[h[f][q][0]]&&(k="espacio='"+this.spaceID+"' ",u=!0),k=k+h[f][q][0]+"='"+h[f][q][1]+"' ";h[f]=k;u?this.graphics.push(b.parseGraphic(h[f],this.abs_coord,this.background,this.inirot)):b.parseAuxiliar(h[f])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){if(this.inipos){var a=this.evaluator.evalExpression(this.inipos);this.iniPosX=a[0][0];this.iniPosY=a[0][1]}};a.Macro.prototype.drawAux=function(a){for(var e=
0,b=this.graphics.length;e<b;e++)this.inipos&&(this.graphics[e].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale)),this.graphics[e].draw(),a.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{},babel),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sqrt,l=Math.sin,g=Math.cos,b,d,f,h,c,q,p,k,r,t,u,m,v,n,s;a.norm3D=function(a){return e(a.x*a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(c){b=a.norm3D(c);if(0===b)return{x:0,
y:0,z:0};if(1===b)return{x:c.x,y:c.y,z:c.z};b=1/b;return{x:c.x*b,y:c.y*b,z:c.z*b}};a.dotProduct3D=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};a.crossProduct3D=function(a,b){return{x:a.y*b.z-a.z*b.y,y:a.z*b.x-a.x*b.z,z:a.x*b.y-a.y*b.x}};a.scalarProduct3D=function(a,b){return{x:a.x*b,y:a.y*b,z:a.z*b}};a.subtract3D=function(a,b){return{x:a.x-b.x,y:a.y-b.y,z:a.z-b.z}};a.add3D=function(a,b){return{x:a.x+b.x,y:a.y+b.y,z:a.z+b.z}};a.equals3DEpsilon=function(a,b,c){return Math.abs(a.x-b.x)<=c&&Math.abs(a.y-
b.y)<=c&&Math.abs(a.z-b.z)<=c};a.Vector4D=function(a,b,c,f){this.x=a||0;this.y=b||0;this.z=c||0;this.w=f||0};a.Matrix4x4=function(a,b,c,f,d,h,e,g,n,k,l,m,q,p,u,t){this.a00=a||0;this.a01=b||0;this.a02=c||0;this.a03=f||0;this.a10=d||0;this.a11=h||0;this.a12=e||0;this.a13=g||0;this.a20=n||0;this.a21=k||0;this.a22=l||0;this.a23=m||0;this.a30=q||0;this.a31=p||0;this.a32=u||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){d=l(b);f=g(b);k=this.a10;r=this.a11;t=this.a12;u=this.a13;m=this.a20;v=this.a21;n=this.a22;s=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,k*f+m*d,r*f+v*d,t*f+n*d,u*f+s*d,k*-d+m*f,r*-d+v*f,
t*-d+n*f,u*-d+s*f,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(b){d=l(b);f=g(b);h=this.a00;c=this.a01;q=this.a02;p=this.a03;m=this.a20;v=this.a21;n=this.a22;s=this.a23;return new a.Matrix4x4(h*f+m*-d,c*f+v*-d,q*f+n*-d,p*f+s*-d,this.a10,this.a11,this.a12,this.a13,h*d+m*f,c*d+v*f,q*d+n*f,p*d+s*f,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(b){d=l(b);f=g(b);h=this.a00;c=this.a01;q=this.a02;p=this.a03;k=this.a10;r=this.a11;t=this.a12;u=this.a13;
return new a.Matrix4x4(h*f+k*d,c*f+r*d,q*f+t*d,p*f+u*d,h*-d+k*f,c*-d+r*f,q*-d+t*f,p*-d+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 l(a,b){a.lineCap=h;a.lineJoin=c;this.frontColor.getColor();this.backColor.getColor();
a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);for(var f=1,d=this.newV.length;f<d;f++)a.lineTo(this.newV[f].x,this.newV[f].y);a.closePath();"color"===this.model?(a.fillStyle=0<=this.direction?this.backColor.getColor():this.frontColor.getColor(),a.fill()):"light"===this.model||"metal"===this.model?(a.fillStyle=0<=this.direction?b.computeColor(this.backColor,this,"metal"===this.model):b.computeColor(this.frontColor,this,"metal"===this.model),a.fill()):"wire"===this.model&&(a.lineWidth=1.25,a.strokeStyle=
this.frontColor.getColor(),a.stroke());this.edges&&"wire"!==this.model&&(a.lineWidth=1,a.strokeStyle="#808080",a.stroke())}function g(a){this.drawText(a,this.text,this.newV[0].x,this.newV[0].y+this.displace,this.frontColor.getColor(),this.font,"left","alphabetic",this.decimals,this.fixed,!0)}function b(a){a.lineCap=h;a.lineJoin=c;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 d(b,c,f){q=a.subtract3D(b,c);p=a.subtract3D(b,f);return a.normalize3D(a.crossProduct3D(q,p))}if(a.loadLib)return a;var f=2*Math.PI,h="round",c="round",q,p,k,r,t;a.Primitive3D=function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);this.newV=[];"vertex"===this.type?this.draw=e:"face"===this.type?(this.normal=d(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=l):"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 c=0,f=this.vertices.length;c<f;c++)this.newV[c]=b.rotateVertex(this.vertices[c]),this.average.x+=this.newV[c].x,this.average.y+=this.newV[c].y,this.average.z+=this.newV[c].z;this.average=a.scalarProduct3D(this.average,1/f);2<this.vertices.length&&(this.normal=d(this.newV[0],this.newV[1],
this.newV[2]),this.direction=a.dotProduct3D(this.normal,a.normalize3D(b.eye)));c=this.depth=0;for(f=this.vertices.length;c<f;c++)this.newV[c]=b.project(this.newV[c]),this.depth+=this.newV[c].z;this.depth/=f};a.Primitive3D.prototype.drawText=function(b,c,f,d,h,e,g,l,q,p,D){if("rtfNode"==c.type)b.fillStyle=h,b.strokeStyle=h,b.textBaseline="alphabetic",c.draw(b,f,d,q,p,g,D);else{"simpleText"===c.type&&(c=c.toString(q,p).split("\\n"));f+=e.match("Arial")?-2:e.match("Times")?-2:0;k=this.evaluator;b.fillStyle=
a.getColor(k,h);b.font=e;b.textAlign=g;b.textBaseline=l;r=1.2*this.fontSize||0;h=0;for(e=c.length;h<e;h++)t=c[h],this.border&&b.strokeText(t,f,d+r*h),b.fillText(t,f,d+r*h)}};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){for(var c=null,f=null,d=0,h=0,e=0,g=b.vertices.length;e<g;e++){var k=this.intersection(b.vertices[e],b.vertices[(e+1)%g]);if(null!==k)if(null===c){if(c=k,d=e,2===b.vertices.length){f=c;break}}else if(!a.equals3DEpsilon(k,c,1E-8)){f=k;h=e;break}}if(null!==c&&
null!==f){var e=this.isInterior(c)||this.isInterior(f),l=null,q=null;if(!e&&3<=b.vertices.length)for(var g=0,p=this.vertices.length;g<p;g++)if(k=b.intersection(this.vertices[g],this.vertices[(g+1)%p]),null!==k)if(null===l)l=k;else if(!a.equals3DEpsilon(k,l,1E-8)){q=k;break}if(e||null!==l&&null!==q&&b.isInterior(l)&&b.isInterior(q)){q=!0;p=b.vertices;l=k=null;if(2===p.length)a.equals(c,p[0],1E-8)||a.equals(c,p[1],1E-8)?q=!1:(k=[],k[0]=p[0],k[1]=c,l=[],l[0]=c,l[1]=p[1]);else for(var k=[],l=[],t=0,e=
g=0;e<p.length;e++)e<d?k[t++]=p[e]:e==d?(k[t++]=p[e],k[t++]=c,l[g++]=c):e<h?l[g++]=p[e]:e==h?(l[g++]=p[e],l[g++]=f,k[t++]=f):k[t++]=p[e];if(q)return c=[],c[0]=new a.Primitive3D({vertices:k,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model}),c[0].normal=b.normal,c[1]=new a.Primitive3D({vertices:l,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model}),c[1].normal=b.normal,c}}}return[b]};a.Primitive3D.prototype.intersects=function(a){return this.intersectsPlane(a)&&
a.intersectsPlane(this)};a.Primitive3D.prototype.intersectsPlane=function(b){var c=a.dotProduct3D(b.vertices[0],b.normal),f=a.dotProduct3D(this.vertices[0],b.normal);if(1E-8>Math.abs(c-f))return!0;for(var d=1,h=this.vertices.length;d<h;d++){var e=a.dotProduct3D(this.vertices[d],b.normal);if(1E-8>Math.abs(c-e)||e>c&&f<c||e<c&&f>c)return!0}return!1};a.Primitive3D.prototype.intersection=function(b,c){if(0<this.vertices.length){var f=a.subtract3D(c,b),d=a.dotProduct3D(f,this.normal);if(0!==d&&(d=a.dotProduct3D(a.subtract3D(this.vertices[0],
b),this.normal)/d,-1E-8<d&&1.00000001>d))return a.add3D(b,a.scalarProduct3D(f,d))}return null};a.Primitive3D.prototype.isInterior=function(b){if(0<this.vertices.length)for(var c=0,f=a.subtract3D(this.vertices[0],b),d=0,h=this.vertices.length;d<h;d++){var e=a.subtract3D(this.vertices[(d+1)%h],b),g=a.dotProduct3D(a.crossProduct3D(f,e),this.normal);if(1E-8>Math.abs(g)){if(0>a.dotProduct3D(f,e))break}else{if(0>c&&0<g||0<c&&0>g)return!1;f=e;c=g}}return!0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e={x:0,y:0,z:0},l,g,b,d,f,h,c,q;a.Graphic3D=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=b.evaluator.parser;this.spaceID="E0";this.background=!1;this.type="";this.color=new a.Color("eeffaa");this.backcolor=new a.Color("6090a0");this.Nu=this.evaluator.parser.parse("7");this.Nv=this.evaluator.parser.parse("7");this.drawif=f.parse("1");this.abs_coord=!1;this.family="";this.family_interval=f.parse("[0,1]");this.family_steps=f.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;
this.text="";this.decimals=f.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=f.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=f.parse("(0,0,0)");this.model="color";for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=f.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font=a.convertFont(this.font);
this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10;this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&(this.endrot=this.endrot.replace("Euler",""),this.endrotEuler=!0);this.inirot=f.parse(this.inirot);this.endrot=f.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=
new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4};a.Graphic3D.prototype.getSpace=function(){for(var a=this.parent.spaces,b,c=0,f=a.length;c<f;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){l=this.evaluator;g=l.evalExpression(this.family_interval);this.familyInf=g[0][0];this.familySup=g[0][1];this.fSteps=Math.round(l.evalExpression(this.family_steps));this.family_sep=
0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){l=this.evaluator;this.getFamilyValues();b=l.getVariable(this.family);if(0<=this.fSteps)for(var a=0,c=this.fSteps;a<=c;a++)l.setVariable(this.family,this.familyInf+a*this.family_sep),l.evalExpression(this.drawif)&&this.buildPrimitives();l.setVariable(this.family,b)};a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.evalExpression(this.drawif)&&(this.family?this.buildFamilyPrimitives():
this.buildPrimitives())};a.Graphic3D.prototype.updateMVMatrix=function(b){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?d=this.inirotM.multiplyVector4(a):(d=this.inirotM_X.multiplyVector4(a),d=this.inirotM_Y.multiplyVector4(d),d=this.inirotM_Z.multiplyVector4(d));d=this.iniposM.multiplyVector4(d);
this.endrotEuler?d=this.endrotM.multiplyVector4(d):(d=this.endrotM_X.multiplyVector4(d),d=this.endrotM_Y.multiplyVector4(d),d=this.endrotM_Z.multiplyVector4(d));return d=this.endposM.multiplyVector4(d)};a.Graphic3D.prototype.parseExpression=function(){f=this.expresion.split("=");h=f[0];c=[];for(var a=1;a<f.length;a++)h+="=",q=f[a].lastIndexOf(" "),h+=-1!==q?f[a].substring(0,q):f[a],c.push(this.evaluator.parser.parse(h,!0)),h=f[a].substring(q+1);return c};var p;a.Graphic3D.prototype.splitFace=function(a){for(var b=
0,c=this.primitives.length;b<c;b++)if(p=[],"face"===this.primitives[b].type){for(var f=0,d=a.primitives.length;f<d;f++)"face"===a.primitives[f].type?p=p.concat(this.primitives[b].splitFace(a.primitives[f])):p.push(a.primitives[f]);a.primitives=p}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,g,b,d;a.Point3D=function(b,d){a.Graphic3D.call(this,b,d)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();
l=e.evalExpression(this.expresion);g=l[0][0];b=l[0][1];d=l[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(g,b,d,1))],type:"vertex",backColor:this.backcolor,frontColor:this.color,size:e.evalExpression(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(g,b,d,1))],type:"text",frontColor:this.color,font:this.font,decimals:e.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize,
evaluator:e,text:this.text}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,g,b,d,f;a.Segment3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c)};a.extend(a.Segment3D,a.Graphic3D);a.Segment3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=expr[0][0];l=expr[0][1];g=expr[0][2];b=expr[1][0];d=expr[1][1];f=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,
l,g,1)),this.transformVertex(new a.Vector4D(b,d,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,l,g,b,d,f,h;a.Surface3D=function(b,f){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,f);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");l=e.getVariable("u");g=e.getVariable("v");e.setVariable("u",0);e.setVariable("v",0);b=e.evalExpression(this.Nu);d=e.evalExpression(this.Nv);f=[];for(var c=0;c<=b;c++){e.setVariable("u",c/b);for(var q=0;q<=d;q++){e.setVariable("v",q/d);for(var p=0,k=this.expresion.length;p<k;p++)e.evalExpression(this.expresion[p]);f.push(this.transformVertex(new a.Vector4D(e.getVariable("x"),e.getVariable("y"),
e.getVariable("z"),1)))}}for(c=0;c<b;c++)for(q=0;q<d;q++)h=[],h.push(f[q+c*d+c]),h.push(f[q+1+c*d+c]),h.push(f[q+2+(c+1)*d+c]),h.push(f[q+1+(c+1)*d+c]),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",l);e.setVariable("v",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,
g,b,d,f;a.Polygon3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c)};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);for(var h=0,c=expr.length-1;h<c;h++)e=expr[h][0],l=expr[h][1],g=expr[h][2],b=expr[h+1][0],d=expr[h+1][1],f=expr[h+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,l,g,1)),this.transformVertex(new a.Vector4D(b,
d,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,l,g,b,d,f;a.Curve3D=function(b,c){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,c);this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();b=evaluator.getVariable("x");d=evaluator.getVariable("y");f=evaluator.getVariable("z");
g=evaluator.getVariable("u");evaluator.setVariable("u",0);l=evaluator.evalExpression(this.Nu);e=[];for(var h=0;h<=l;h++){evaluator.setVariable("u",h/l);for(var c=0,q=this.expresion.length;c<q;c++)evaluator.evalExpression(this.expresion[c]);e.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}h=0;for(c=e.length-1;h<c;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",d);evaluator.setVariable("u",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,g,b,d,f,h,c,q;a.Triangle3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=expr[0][0];l=expr[0][1];g=expr[0][2];b=expr[1][0];d=expr[1][1];
f=expr[1][2];h=expr[2][0];c=expr[2][1];q=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,l,g,1)),this.transformVertex(new a.Vector4D(h,c,q,1)),this.transformVertex(new a.Vector4D(b,d,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 l=expr.length-1;0<=l;l--)e.push(this.transformVertex(new a.Vector4D(expr[l][0],expr[l][1],expr[l][2],1)));this.primitives.push(new a.Primitive3D({vertices:e,type:"face",frontColor:this.color,backColor:this.backcolor,edges:this.edges,model:this.model}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,g,b,d;a.Polireg3D=function(b,d){this.width=b.evaluator.parser.parse("2");
this.length=b.evaluator.parser.parse("2");a.Graphic3D.call(this,b,d)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();e=evaluator.evalExpression(this.Nu);l=[this.transformVertex(new a.Vector4D(0,0,0,1))];g=evaluator.evalExpression(this.width)/2;b=evaluator.evalExpression(this.length)/2;d=2*Math.PI/e;for(var f=0;f<e;f++)l.push(this.transformVertex(new a.Vector4D(g*Math.cos(d*f),b*Math.sin(d*f),0,1)));for(f=0;f<e;f++)this.primitives.push(new a.Primitive3D({vertices:[l[0],
f+2<=e?l[f+2]:l[1],l[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,l,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;l=e.evalExpression(this.expresion);g=l[0][0];b=l[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}))};return a}(descartesJS||{}),descartesJS=function(a){function e(a,b,c,f,d){l.call(this,a/1.8,a/1.8,a/1.8,f,d)}function l(a,b,c,f,d){a/=2;b/=2;c/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new m(a,c,b,1),new m(a,-c,b,1),new m(a,c,-b,1),new m(a,-c,-b,1),new m(-a,c,b,1),new m(-a,-c,b,1),new m(-a,c,-b,1),new m(-a,-c,-b,1)],this.faces=[[2,3,1,0],[1,5,4,0],[5,7,6,4],[6,7,3,2],
[4,6,2,0],[3,7,5,1]],this.updateValues(a,b,c,f,d))}function g(a,b,c,f,d){a/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new m(0,0,a,1),new m(-0.49*a,-0.86*a,-0.32*a,1),new m(-0.49*a,0.86*a,-0.32*a,1),new m(1*a,0,-0.32*a,1)],this.faces=[[3,2,1],[1,2,0],[2,3,0],[3,1,0]],this.updateValues(a,b,c,f,d))}function b(a,b,c,f,d){a/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new m(0,0,a,1),new m(a,0,0,1),new m(-a,0,0,1),new m(0,a,0,1),new m(0,-a,0,1),new m(0,0,-a,1)],this.faces=[[3,1,0],[2,3,0],
[1,4,0],[4,2,0],[1,3,5],[3,2,5],[4,1,5],[2,4,5]],this.updateValues(a,b,c,f,d))}function d(b,c,f,d,e){b/=3.4;if(!this.changeGeometry(b,c,f,d,e)){D=b/E;B=b*E;this.vertices=[new m(b,b,b,1),new m(b,b,-b,1),new m(b,-b,b,1),new m(b,-b,-b,1),new m(-b,b,b,1),new m(-b,b,-b,1),new m(-b,-b,b,1),new m(-b,-b,-b,1),new m(0,D,B,1),new m(0,D,-B,1),new m(0,-D,B,1),new m(0,-D,-B,1),new m(D,B,0,1),new m(D,-B,0,1),new m(-D,B,0,1),new m(-D,-B,0,1),new m(B,0,D,1),new m(B,0,-D,1),new m(-B,0,D,1),new m(-B,0,-D,1)];A=(new a.Matrix4x4).setIdentity().rotateY(-t/
6);for(var h=0,g=this.vertices.length;h<g;h++)this.vertices[h]=A.multiplyVector4(this.vertices[h]);this.faces=[[0,16,2,10,8],[12,1,17,16,0],[8,4,14,12,0],[2,16,17,3,13],[13,15,6,10,2],[6,18,4,8,10],[3,17,1,9,11],[13,3,11,7,15],[1,12,14,5,9],[11,9,5,19,7],[5,14,4,18,19],[6,15,7,19,18]];this.updateValues(b,c,f,d,e)}}function f(b,c,f,d,e){b/=4;if(!this.changeGeometry(b,c,f,d,e)){B=b*E;this.vertices=[new m(0,b,B,1),new m(0,b,-B,1),new m(0,-b,B,1),new m(0,-b,-B,1),new m(b,B,0,1),new m(b,-B,0,1),new m(-b,
B,0,1),new m(-b,-B,0,1),new m(B,0,b,1),new m(B,0,-b,1),new m(-B,0,b,1),new m(-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 h=0,g=this.vertices.length;h<g;h++)this.vertices[h]=A.multiplyVector4(this.vertices[h]);this.updateValues(b,c,f,d,e)}}function h(a,b,c,f,d){a/=2;this.isSphere?c=b=a:(b/=2,
c/=2);if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[new m(0,0,b,1)];for(var e=1;e<f;e++){y=e*t/f;for(var h=0;h<d;h++)C=h*u/d,s=a*k(y)*r(C),w=c*k(y)*k(C),z=b*r(y),this.vertices.push(new m(s,w,z,1))}this.vertices.push(new m(0,0,-b,1));this.faces=[];for(e=0;e<d;e++)this.faces.push([0,(e+1)%d+1,e%d+1]);for(e=1;e<f-1;e++)for(h=0;h<d;h++)this.faces.push([h+1+(e-1)*d,(h+1)%d+1+(e-1)*d,(h+1)%d+1+e*d,h+1+e*d]);for(e=0;e<d;e++)this.faces.push([this.vertices.length-1,this.vertices.length-1-d+e,this.vertices.length-
1-d+(e+1)%d]);this.updateValues(a,b,c,f,d)}}function c(a,b,c,f,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[];for(var e=0;e<d;e++)for(var h=0;h<f;h++)s=a*(d-e)/d*r(h*u/f),w=c*(d-e)/d*k(h*u/f),z=b-2*e*b/d,this.vertices.push(new m(s,w,z,1));this.vertices.push(new m(0,0,-b,1));this.faces=[];for(e=0;e<d-1;e++)for(h=0;h<f;h++)this.faces.push([h+e*f,(h+1)%f+e*f,(h+1)%f+(e+1)*f,h+(e+1)*f]);for(e=0;e<f;e++)this.faces.push([this.vertices.length-1,this.vertices.length-1-f+e,this.vertices.length-
1-f+(e+1)%f]);this.updateValues(a,b,c,f,d)}}function q(a,b,c,f,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[];for(var e=0;e<d+1;e++)for(var h=0;h<f;h++)s=a*r(h*u/f),w=c*k(h*u/f),z=b-2*e*b/d,this.vertices.push(new m(s,w,z,1));this.faces=[];for(e=0;e<d;e++)for(h=0;h<f;h++)this.faces.push([h+e*f,(h+1)%f+e*f,(h+1)%f+(e+1)*f,h+(e+1)*f]);this.updateValues(a,b,c,f,d)}}function p(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];for(var c=
0,f=this.fileData.length;c<f;c++)H=this.fileData[c],H.match(/^V\(/)?(G=H.substring(2,H.length-1).split(",").map(b),this.vertices.push(new m(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 k=Math.sin,r=Math.cos,t=Math.PI,u=2*t,m,v,n,s,w,z,C,y,E=1.6180339887,D,B,A,H,G;a.OtherGeometry=function(n,k){this.width=n.evaluator.parser.parse("2");this.height=n.evaluator.parser.parse("2");this.length=n.evaluator.parser.parse("2");
m=a.Vector4D;a.Graphic3D.call(this,n,k);switch(this.type){case "cube":this.buildGeometry=e;break;case "box":this.buildGeometry=l;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=d;break;case "icosahedron":this.buildGeometry=f;break;case "cone":this.buildGeometry=c;break;case "cylinder":this.buildGeometry=q;break;case "mesh":this.fileData=
a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=p}};a.extend(a.OtherGeometry,a.Graphic3D);a.OtherGeometry.prototype.buildPrimitives=function(){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,c=this.faces.length;b<c;b++){n=[];for(var f=0,d=this.faces[b].length;f<d;f++)n.push(this.transformVertex(this.vertices[this.faces[b][f]]));
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,c,f,d){return this.oldWidth===a&&this.oldHeight===b&&this.oldLength===c&&this.oldNu===f&&this.oldNv===d};a.OtherGeometry.prototype.updateValues=function(a,b,c,f,d){this.oldWidth=a;this.oldHeight=b;this.oldLength=c;this.oldNv=d;this.oldNu=f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e=Math.max,l=Math.min,g=Math.PI,b=Math.cos,d=Math.sin,f=Math.abs,h,c,q,p,k,r,t,u,m,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(l(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(e(l(this.y,32E3),-32E3))};a.R2.prototype.equals=function(a){return this.x==a.x&&this.y==a.y};a.R2.prototype.norm2=
function(){return this.x*this.x+this.y*this.y};a.R2.prototype.norm=function(){return Math.sqrt(this.norm2())};a.R2.prototype.distance=function(a){c=this.copy();c.sub(a);return c.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){q=this.copy();r=b(a);t=d(a);this.x=q.x*r-q.y*t;this.y=q.x*t+q.y*r};a.R2.prototype.rot=function(a){this.rot(a*g/180)};a.R2.prototype.intersection=function(b,c,d,h){u=c.x-b.x;m=d.x-h.x;v=d.x-b.x;n=c.y-b.y;s=d.y-h.y;w=d.y-b.y;D=u*s-m*n;return 1E-6<f(D)?
(p=(v*s-w*m)/D,k=(-v*n+w*u)/D,0<=p&&1>=p&&0<=k&&1>=k?new a.R2(b.x+u*p,b.y+n*p):null):(c.x-d.x)*w!=(c.y-d.y)*v?null:b.x!=c.x?(z=l(b.x,c.x),C=e(b.x,c.x),z<=d.x&&d.x<=C?d:z<=h.x&&h.x<=C?h:null):d.x!=h.x?(y=l(d.x,h.x),E=e(d.x,h.x),y<=b.x&&b.x<=E?b:y<=c.x&&c.x<=E?c:null):b.y!=c.y?(z=l(b.y,c.y),C=e(b.y,c.y),z<=d.y&&d.y<=C?d:z<=h.y&&h.y<=C?h:null):d.y!=h.y?(y=l(d.y,h.y),E=e(d.y,h.y),y<=b.y&&b.y<=E?b:y<=c.y&&c.y<=E?c:null):b.x==d.x&&b.y==d.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e,l,g,b,d,f,h,c;a.R2Newton=function(b,c){this.evaluator=b;this.constraint=c;if("=="==this.constraint.value||"<"==this.constraint.value||"<="==this.constraint.value||">"==this.constraint.value||">="==this.constraint.value)this.sign="<"==this.constraint.value||"<="==this.constraint.value?"menor":">"==this.constraint.value||">="==this.constraint.value?"mayor":"igual",this.constraint=this.constraint.equalToMinus(),this.constraint=this.constraint.childs[0];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");c=e.getVariable("y");e.setVariable("x",a.x);e.setVariable("y",a.y);this.f0=e.evalExpression(this.constraint);e.setVariable("x",e.getVariable("x")+1E-12);l=e.evalExpression(this.constraint);f.x=(l-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);l=e.evalExpression(this.constraint);
f.y=(l-this.f0)/1E-12;f.y=!isNaN(f.y)?f.y:Infinity;e.setVariable("x",h);e.setVariable("y",c);return f};a.R2Newton.prototype.findZero=function(a){e=this.evaluator;d=a.copy();h=e.getVariable("x");c=e.getVariable("y");e.setVariable("x",a.x);e.setVariable("y",a.y);this.f0=e.evalExpression(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return d;e.setVariable("x",h);e.setVariable("y",c);for(var f=0;256>f;f++)if(g=d.x,b=d.y,this.normal=this.gradient(d),0!=this.normal.norm2()&&
this.normal.mul(-this.f0/this.normal.norm2()),d.x=g+this.normal.x,d.y=b+this.normal.y,1E-6>this.normal.norm()){0===this.normal.x&&0===this.normal.y&&(this.normal.x=d.x-a.x,this.normal.y=d.y-a.y);break}return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,l){this.x=a;this.y=l};a.Vector2D.AXIS_X=new a.Vector2D(1,0);a.Vector2D.AXIS_Y=new a.Vector2D(0,1);a.Vector2D.prototype.vectorLength=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.Vector2D.prototype.dotProduct=
function(a){return this.x*a.x+this.y*a.y};a.Vector2D.prototype.angleBetweenVectors=function(a){return Math.acos(this.dotProduct(a)/(this.vectorLength()*a.vectorLength()))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,l=Math.round,g,b,d,f,h,c,q,p,k,r,t,u,m,v,n,s,w,z,C,y;a.Control=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=this.parser=b.evaluator.parser;this.id="graphic"!==c.type?"C":"G";this.gui=this.type="";this.region="south";this.y=
this.x=0;this.w="video"!==c.type?100:350;this.h="video"!==c.type?23:120;"graphic"!==c.type&&"audio"!==c.type&&"video"!==c.type?"text"!==c.type?this.expresion=f.parse("(0,0,100,23)"):(this.expresion=f.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=f.parse("(0,0)");this.fixed=2!=this.parent.version?!1:!0;this.visible=!0;this.color=4>this.parent.version?new a.Color("000000"):new a.Color("222222");this.colorInt="graphic"!==c.type?new a.Color("f0f8ff"):new a.Color("cc0022");this.underlined=
this.italics=this.bold="";this.font_size=4>this.parent.version?-1:f.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";this.drawif=f.parse("1");this.activeif=f.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=f.parse("0");this.decimals=f.parse("2");this.min=f.parse("-Infinity");this.max=f.parse("Infinity");this.incr=f.parse("0.1");this.exponentialif=this.discrete=
!1;this.zIndex=-1;for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);if(("video"===this.type||"audio"===this.type)&&"interior"!==this.region)this.region="interior";void 0==this.name&&(this.name=2==this.parent.version?this.id:"_nada_");this.name="_._"==this.name||"_nada_"==this.name||"_void_"==this.name?"":this.name;f=this.evaluator.evalExpression(this.expresion);this.x=l(f[0][0]);this.y=l(f[0][1]);4==f[0].length&&(this.w=l(f[0][2]),this.h=l(f[0][3]));this.actionExec=b.lessonParser.parseAction(this)};
a.Control.prototype.init=function(){};a.Control.prototype.update=function(){};a.Control.prototype.draw=function(){};a.Control.prototype.getContainer=function(){var a=this.parent.spaces,b;if("interior"===this.region)for(var c=0,f=a.length;c<f;c++){if(b=a[c],b.id===this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,b.numericalControlContainer}else{if("external"===this.region)return this.parent.externalSpace.container;if("scenario"===this.region)return this.cID?(this.expresion=this.evaluator.parser.parse("(0,-1000,"+
this.w+","+this.h+")"),this.parent.scenarioRegion.scenarioSpace.addCtr(this),this.zIndex=this.parent.scenarioRegion.scenarioSpace.zIndex,this.parent.scenarioRegion.scenarioSpace.numericalControlContainer):this.parent.externalSpace.container;if("north"===this.region)return this.parent.northSpace.controls.push(this),this.parent.northSpace.container;if("south"===this.region)return this.parent.southSpace.controls.push(this),this.parent.southSpace.container;if("east"===this.region)return this.parent.eastSpace.controls.push(this),
this.parent.eastSpace.container;if("west"===this.region)return this.parent.westSpace.controls.push(this),this.parent.westSpace.container;if("special"===this.region)return this.parent.specialSpace.controls.push(this),this.parent.specialSpace.container}a[0].addCtr(this);this.zIndex=a[0].zIndex;return a[0].numericalControlContainer};a.Control.prototype.addControlContainer=function(a){var b=this.getContainer();b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a);b.childNodes[0]?b.insertBefore(a,
b.childNodes[0]):b.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){d=f=h=c=!1;q=this.evaluator.evalExpression(this.expresion);p=l(q[0][0]);d=l(this.x)!==p;this.x=p;p=l(q[0][1]);f=l(this.y)!==p;this.y=p;4===q[0].length&&(p=l(q[0][2]),h=l(this.w)!==p,this.w=p,p=l(q[0][3]),c=l(this.h)!==p,this.h=p);if(h||c||d||f)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){m=this.parent;k=a+"";r=this.evaluator.evalExpression(this.decimals);t=k.indexOf(".");-1!=t&&(u=
k.substring(t+1),u.length>r&&(k=parseFloat(k).toFixed(r)));if(this.fixed&&(2!==m.version||2===m.version&&!this.exponentialif))k=parseFloat(a).toFixed(r);this.exponentialif&&0!=parseFloat(k)&&(k=this.fixed&&2!==m.version?parseFloat(k).toExponential(r):parseFloat(k).toExponential(),k=k.toUpperCase(),k=k.replace("+",""));return k=k.replace(".",m.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();"init"===this.action&&(this.click=!1);this.actionExec.execute();
"animate"!==this.action&&this.parent.update()};a.Control.prototype.createGradient=function(a,c){this.linearGradient=this.ctx.createLinearGradient(0,0,0,c);g=c*c;for(var f=0;f<c;f++)b=e(f-35*c/100),this.linearGradient.addColorStop(f/c,"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,l,g,b,d,f,h,c,q,p,k,r,t,u=900;a.Button=function(b,c){this.imageSrc="";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;a.Control.call(this,b,c);-1===this.font_size&&(this.fontSizeNotSet=!0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-
1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");var f;this.imageSrc.match("_COLORES_")&&(f=this.imageSrc.split("_"),this.colorInt=new a.Color(f[2]),this.color=new a.Color(f[3]),this.font_size=this.parser.parse(f[5]),this.imageSrc="");this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");f=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=f){var d=f.substr(0,f.lastIndexOf(".")),e=f.substr(f.lastIndexOf("."));f.toLowerCase().match(/vacio.gif$/)?
(this.imageSrc=this.parser.parse("'vacio.gif'"),this.image.ready=1,3===this.parent.version&&(this.name=this.parser.parse("")),this.emptyImage={ready:!0},this.parser.parse("'vacio.gif'")):(this.image=this.parent.getImage(f),this.imageOver=this.parent.getImage(d+"_over"+e),this.imageDown=this.parent.getImage(d+"_down"+e))}this.canvas=document.createElement("canvas");this.canvas.setAttribute("class","DescartesButton");this.canvas.setAttribute("id",this.id);this.canvas.setAttribute("width",this.w+"px");
this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.ctx.mozImageSmoothingEnabled=!1;this.ctx.webkitImageSmoothingEnabled=!1;this.addControlContainer(this.canvas);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=function(){l=this.evaluator;g=this.canvas;d=l.evalExpression(this.expresion);
this.x=d[0][0];this.y=d[0][1];4==d[0].length&&(this.w=parseInt(d[0][2]),this.h=parseInt(d[0][3]));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=l.parser.parse(a.getFieldFontSize(this.h)+""));this.createGradient(this.w,this.h);g.style.display=0<l.evalExpression(this.drawif)?"block":"none"};a.Button.prototype.update=function(){l=this.evaluator;
g=this.canvas;this.activeIfValue=0<l.evalExpression(this.activeif);(this.drawIfValue=0<l.evalExpression(this.drawif))?(g.style.display="block",this.draw()):(this.click=!1,g.style.display="none");this.updatePositionAndSize()};a.Button.prototype.draw=function(){l=this.evaluator;b=this.ctx;f=l.evalExpression(this.font_size);h=l.evalExpression(this.name);c=l.evalExpression(this.imageSrc);q="vacio.gif"===c?this.emptyImage:this.parent.getImage(c);b.clearRect(0,0,this.w,this.h);k=p=0;this.click&&(k=p=1);
q&&q.ready?q!==this.emptyImage&&q.complete&&b.drawImage(q,parseInt((this.w-q.width)/2)+p,parseInt((this.h-q.height)/2)+k):(b.fillStyle=this.colorInt.getColor(),b.fillRect(0,0,this.w,this.h),this.click||(a.drawLine(b,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,"+128/255+")"),a.drawLine(b,0,0,0,this.h,"rgba(0,0,0,"+24/255+")"),a.drawLine(b,1,0,1,this.h,"rgba(0,0,0,"+8/255+")")),b.fillStyle=this.linearGradient,b.fillRect(0,0,this.w,this.h));""!=this.imageOver.src&&(this.imageOver.ready&&this.over)&&b.drawImage(this.imageOver,
parseInt((this.w-q.width)/2)+p,parseInt((this.h-q.height)/2)+k);""!=this.imageDown.src&&this.imageDown.ready&&this.click?b.drawImage(this.imageDown,parseInt((this.w-q.width)/2)+p,parseInt((this.h-q.height)/2)+k):this.click&&(a.drawLine(b,0,0,0,this.h-2,"gray"),a.drawLine(b,0,0,this.w-1,0,"gray"),b.fillStyle="rgba(0, 0, 0,"+24/255+")",b.fillRect(0,0,this.w,this.h));b.fillStyle=this.color.getColor();b.font=this.italics+" "+this.bold+" "+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+p)+0.5,e(this.h/2+k)+0.5));b.fillText(h,e(this.w/2+p)+0.5,e(this.h/2+k)+0.5);this.underlined&&(r=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-r)/2)+p,e((this.h+f)/2)+e(f/5)-1.5+k),b.lineTo(parseInt((this.w+r)/2)+p,e((this.h+f)/2)+e(f/5)-1.5+k),b.stroke());this.activeIfValue||
(b.save(),b.globalCompositeOperation="destination-in",b.fillStyle="rgba(240,240,240,"+160/255+")",b.fillRect(0,0,this.w,this.h),b.restore())};a.Button.prototype.bottonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f){clearInterval(g);h.click&&(c.call(h),a=f?a:30,g=setTimeout(function(){b(a,c)},a))}function c(d){d.preventDefault();document.activeElement.blur();h.whichButton=a.whichButton(d);"L"==h.whichButton&&h.activeIfValue&&
(h.click=!0,h.draw(),h.evaluator.setVariable(h.id,h.evaluator.evalExpression(h.valueExpr)),"calculate"==h.action&&b(u,h.bottonPressed,!0),t?window.addEventListener("touchend",f):window.addEventListener("mouseup",f))}function f(a){if(h.activeIfValue||h.click)h.click=!1,h.draw(),"calculate"!=h.action&&h.bottonPressed(),a.preventDefault(),t?window.removeEventListener("touchend",f,!1):window.removeEventListener("mouseup",f,!1)}function d(a){h.over=!0;h.draw()}function e(a){h.over=!1;h.click=!1;h.draw()}
t=a.hasTouchSupport;var h=this,g;h.canvas.oncontextmenu=function(){return!1};this.over=this.click=!1;t?this.canvas.addEventListener("touchstart",c):(this.canvas.addEventListener("mousedown",c),this.canvas.addEventListener("mouseover",d),this.canvas.addEventListener("mouseout",e))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,g,b,d,f,h,c,q,p,k,r,t,u,m,v,n;a.Spinner=function(b,c){a.Control.call(this,
b,c);this.tabindex=++this.parent.tabindex;this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);""!=this.name.trim()&&this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);
this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.addControlContainer(this.containerControl);this.originalIncr=this.incr;if(0>=this.evaluator.evalExpression(this.decimals)){var f=this.evaluator.evalExpression(this.incr);0<f?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(f).toString()):this.incr=this.evaluator.parser.parse("1")}this.registerMouseAndTouchEvents();this.init()};a.extend(a.Spinner,
a.Control);a.Spinner.prototype.init=function(){e=this.evaluator;this.value=this.validateValue(e.evalExpression(this.valueExpr));var b=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var c=2!==this.parent.version?"":"_____",f=a.getTextWidth(b+"_",this.fieldFontSize+"px Arial"),d=2+parseInt(this.h/2),h=parseInt(this.w/2-d/2),c=a.getTextWidth(this.name+c,this.fieldFontSize+"px Arial");this.visible||(h=this.w-d,f=0);h<c&&(h=c);""==this.name&&
(h=0);this.w-h-d<f&&(h=this.w-d-f);0>h&&(h=0);c=this.w-(h+d);this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.canvas.setAttribute("width",d+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+h+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.divUp.setAttribute("style",
"background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+d+"px; height : "+this.h/2+"px; left: "+h+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+d+"px; height : "+this.h/2+"px; left: "+h+"px; top: "+this.h/2+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_spinner");this.field.setAttribute("class","DescartesSpinnerField");this.field.setAttribute("style",
"font-family: Arial; font-size: "+this.fieldFontSize+"px; width : "+(c-2)+"px; height : "+(this.h-2)+"px; left: "+(d+h)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=b;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+h+"px; height: "+this.h+"px; line-height: "+this.h+"px;");e.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){e=
this.evaluator;0>=e.evalExpression(this.decimals)?(l=e.evalExpression(this.incr),0<l?this.originalIncr=this.incr=e.parser.parse(parseInt(l).toString()):this.incr=e.parser.parse("1")):this.incr=this.originalIncr;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();
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(){d=this.ctx;f=this.canvas.width;h=this.canvas.height;d.fillStyle="#f0f8ff";d.fillRect(0,0,f,h);d.fillStyle=this.linearGradient;d.fillRect(0,0,f,h);this.up?(c="gray",q="#f0f8ff"):
(c="#f0f8ff",q="gray");a.drawLine(d,0,0,f,0,c);a.drawLine(d,0,0,0,h/2,c);a.drawLine(d,0,h/2,f,h/2,q);this.down?(c="gray",q="#f0f8ff"):(c="#f0f8ff",q="gray");a.drawLine(d,0,h/2+1,f,h/2+1,c);a.drawLine(d,0,h/2+1,0,h,c);a.drawLine(d,0,h-1,f,h-1,q);p=[parseInt(f/2+1),parseInt(f/5+1),parseInt(f-f/5+1)];k=[parseInt(h/8+1),parseInt(h/8+1+h/4),parseInt(h/8+1+h/4)];d.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";d.beginPath();d.moveTo(p[0],k[0]);d.lineTo(p[1],k[1]);d.lineTo(p[2],k[2]);d.fill();k=[parseInt(h-
h/8),parseInt(h-h/8-h/4),parseInt(h-h/8-h/4)];d.fillStyle=this.activeIfValue?"#d00018":"#aa8888";d.beginPath();d.moveTo(p[0],k[0]);d.lineTo(p[1],k[1]);d.lineTo(p[2],k[2]);d.fill();d.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&d.fillRect(0,0,f,h/2);this.down&&d.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();r=parseFloat(e.evalExpression(e.parser.parse(a.replace(this.parent.decimal_symbol,
"."))));isNaN(r)&&(r=0);m=e.evalExpression(this.min);v=e.evalExpression(this.max);""===m&&(m=-Infinity);""===v&&(v=Infinity);r<m&&(r=m);r>v&&(r=v);this.discrete&&(t=e.evalExpression(this.incr),r=0==t?0:t*Math.round(r/t));u=e.evalExpression(this.decimals);0>=u&&(u=0);return r=parseFloat(parseFloat(r).toFixed(u))};a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-
this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.changeValue=function(a){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Spinner.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f){clearInterval(p);if(k.up||k.down)c.call(k),a=f?a:30,p=setTimeout(function(){b(a,c)},a)}function c(f){f.preventDefault();k.whichButton=a.whichButton(f);"L"==
k.whichButton&&k.activeIfValue&&(k.up=!0,b(l,k.increase,!0),k.draw())}function f(c){c.preventDefault();k.whichButton=a.whichButton(c);"L"==k.whichButton&&k.activeIfValue&&(k.down=!0,b(l,k.decrease,!0),k.draw())}function d(a){k.up=!1;clearInterval(p);k.draw();a.preventDefault()}function h(a){k.down=!1;clearInterval(p);k.draw();a.preventDefault()}function e(a){k.up=!1;clearInterval(p);k.draw();a.preventDefault()}function g(a){k.down=!1;clearInterval(p);k.draw();a.preventDefault()}n=a.hasTouchSupport;
var k=this,l=n?500:200,p;k.divUp.oncontextmenu=k.divDown.oncontextmenu=k.field.oncontextmenu=k.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&&k.changeValue(k.field.value)});n?this.divUp.addEventListener("touchstart",c):this.divUp.addEventListener("mousedown",c);n?this.divDown.addEventListener("touchstart",
f):this.divDown.addEventListener("mousedown",f);n||this.divUp.addEventListener("mouseout",d);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,l,g,b,d,f,h;a.TextField=function(b,f){a.Control.call(this,b,f);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 d=this.answerPattern.indexOf("|");
this.firstAnswer=-1==d?this.answerPattern:this.answerPattern.substring(0,d)}else this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(",")));if(this.onlyText){if(!this.valueExprString.match(/^'/)||!this.valueExprString.match(/'$/))this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'");this.validateValue=function(a){return"''"==a||"'"==a?"":a.match(/^'/)&&a.match(/'$/)?a.substring(1,a.length-1):a};this.formatOutputValue=function(a){return a.toString()}}""==
this.name.trim()&&(this.name="");this.containerControl=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=
function(){e=this.evaluator;this.value=this.validateValue(e.evalExpression(this.valueExpr));var b=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var f=a.getTextWidth(b+"_",this.fieldFontSize+"px Arial"),d=parseInt(this.w/2),h=a.getTextWidth(this.name,this.fieldFontSize+"px Arial");d<h&&(d=h);""==this.name&&(d=0);this.w-d<f&&(d=this.w-f);0>d&&(d=0);f=this.w-d;this.containerControl.setAttribute("class","DescartesTextFieldContainer");this.containerControl.setAttribute("style",
"width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"TextField");this.field.setAttribute("class","DescartesTextFieldField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(f-2)+"px; height : "+(this.h-2)+"px; left: "+d+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=b;this.label.setAttribute("class","DescartesTextFieldLabel");
this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+d+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.evaluate&&(this.ok=this.evaluateAnswer());this.evaluator.setVariable(this.id,this.value);this.evaluator.setVariable(this.id+".ok",this.ok);this.oldValue=this.value;this.update()};a.TextField.prototype.update=function(){e=this.evaluator;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;
this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize();l=this.field.value;g=this.value;this.value=this.validateValue(e.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value===g&&this.field.value!=l&&(this.value=this.validateValue(l),this.field.value=this.formatOutputValue(this.value));e.setVariable(this.id,this.value)};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";e=this.evaluator;b=parseFloat(e.evalExpression(e.parser.parse(a.toString().replace(this.parent.decimal_symbol,
"."))));isNaN(b)&&(b=0);d=e.evalExpression(this.min);""==d&&(d=-Math.Infinity);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,l,g,b,d;a.Menu=function(b,c){this.options="";a.Control.call(this,b,c);var f=this.parser;this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var d,e=0,g=this.options.length;e<g;e++)d=this.options[e].split(/[\[\]]/,2),1==d.length?(this.menuOptions.push(d[0]),this.strValue.push(e.toString())):2==d.length&&(this.menuOptions.push(d[0]),""==d[1]?this.strValue.push(e.toString()):this.strValue.push(d[1]));e=0;for(g=this.strValue.length;e<g;e++)this.strValue[e]=f.parse(this.strValue[e]);
this.containerControl=document.createElement("div");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.select=document.createElement("select");e=0;for(g=this.menuOptions.length;e<g;e++)f=document.createElement("option"),f.innerHTML=this.menuOptions[e],this.select.appendChild(f);this.field=document.createElement("input");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&
this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Menu,a.Control);var f;a.Menu.prototype.init=function(){f=this.evaluator;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var b=0,c=0,d=0;this.value=f.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var e=0,g=this.menuOptions.length;e<g;e++)d=a.getTextWidth(this.menuOptions[e],this.fieldFontSize+
"px Arial"),d>b&&(b=d,c=e);b+=25;d=a.getTextWidth(this.formatOutputValue(f.evalExpression(this.strValue[c])),this.fieldFontSize+"px Arial")+7;c=a.getTextWidth(this.name,this.fieldFontSize+"px Arial")+10;""==this.name&&(c=0);this.visible||(d=0);for(e=this.w-d-c;e<b&&0<c;)c--,e++;for(;e<b&&0<d;)d--,e++;for(;c+e+d+1<this.w;)e++,d++;var b=c,g=b+e,d=this.w-g,l=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=l;this.field.setAttribute("class","DescartesMenuField");
this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(d-2)+"px; height : "+(this.h-2)+"px; left: "+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; width : "+e+"px; height : "+this.h+"px; left: "+b+"px; border-color: #7a8a99; border-width: 1.5px; border-style: solid; background-color: #eeeeee;");this.select.selectedIndex=
this.indexValue;f.setVariable(this.id,parseFloat(l));this.update()};a.Menu.prototype.update=function(){f=this.evaluator;this.activeIfValue=0<f.evalExpression(this.activeif);this.drawIfValue=0<f.evalExpression(this.drawif);this.field.disabled=this.activeIfValue?!1:!0;this.select.disabled=this.activeIfValue?!1:!0;this.drawIfValue?this.containerControl.style.display="block":(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();this.value=f.getVariable(this.id);this.field.value=
this.formatOutputValue(this.value);f.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));l=-1;g=Infinity;for(var c=0,f=this.strValue.length;c<f;c++)b=e(a-parseFloat(this.evaluator.evalExpression(this.strValue[c]))),b<=g&&(g=b,l=c);return l};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),
this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){d=a.hasTouchSupport;var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=function(){return!1};d?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(a){b.value=b.evaluator.evalExpression(b.strValue[this.selectedIndex]);b.field.value=b.formatOutputValue(b.value);
b.evaluator.setVariable(b.id,b.field.value);b.changeValue();a.preventDefault()});this.field.addEventListener("keydown",function(a){13==a.keyCode&&(b.indexValue=b.getIndex(b.field.value),b.value=b.evaluator.evalExpression(b.strValue[b.indexValue]),b.field.value=b.formatOutputValue(b.indexValue),b.select.selectedIndex=b.indexValue,b.changeValue())})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,l="h",g,b,d,f,h,c,q,p,k,r,t,u,m,v,n,s,w,z,C,y,E;a.Scrollbar=
function(b,c){a.Control.call(this,b,c);this.orientation=this.w>=this.h?l:"v";this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.scrollManipulator=document.createElement("div");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.containerControl.appendChild(this.canvas);
this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.scrollManipulator);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){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));d=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?l:"v";this.initScroll(d);this.changeScrollPositionFromValue();this.prePos=this.pos;g.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(c){b=this;g=b.evaluator;
var f="v"===b.orientation?parseInt(19+5*(b.h-100)/100):b.h;b.fieldFontSize="v"===b.orientation?f-parseInt(b.h/20)-1:2!==b.parent.version?a.getFieldFontSize(f):10;var d=a.getTextWidth(c+"_",b.fieldFontSize+"px Arial"),e=b.parent.getSpaceById(b.spaceID).h;b.labelHeight=""==b.name?0:f;b.fieldHeight=""==b.visible?0:f;if("v"===b.orientation)b.canvasWidth=b.w,b.canvasHeight=b.h-b.labelHeight-b.fieldHeight,18<=b.canvasHeight+b.y-e&&(b.canvasHeight=e),d=0,d=b.fieldHeight,f=d+b.canvasHeight,b.canvasX=0,b.canvasY=
b.fieldHeight,b.labelWidth=b.w,b.labelY=f,b.upWidth=b.downW=b.w,b.upHeight=b.downH=15,b.upX=0,b.upY=b.fieldHeight,b.downX=0,b.downY=f-b.downH,b.fieldWidth=b.w,b.fieldX=0,b.scrollManipulatorW=b.w,b.scrollManipulatorH=parseInt((b.canvasHeight-b.upHeight-b.downH-b.labelHeight-b.fieldHeight)/10),b.scrollManipulatorH=15>b.scrollManipulatorH?15:b.scrollManipulatorH,b.scrollManipulatorLimInf=f-b.downH-b.scrollManipulatorH,b.scrollManipulatorLimSup=d+b.downH;else{f=a.getTextWidth(b.name,b.fieldFontSize+"px Arial")+
10;b.labelWidth=f;b.fieldWidth=d;""==b.name&&(b.labelWidth=0);b.visible||(b.fieldWidth=0);for(f=b.w-b.fieldWidth-b.labelWidth;58>f&&0<b.labelWidth;)b.labelWidth--,f++;for(;58>f&&0<b.fieldWidth;)b.fieldWidth--,f++;d=b.labelWidth;e=d+f;b.fieldWidth=b.w-e;b.canvasWidth=f;b.canvasHeight=b.h;b.canvasX=b.labelWidth;b.canvasY=0;b.fieldX=b.canvasWidth+b.labelWidth;b.labelHeight=b.h;b.labelY=0;b.upWidth=b.downW=15;b.upHeight=b.downH=b.h;b.upX=e-b.downW;b.upY=0;b.downX=b.labelWidth;b.downY=0;b.scrollManipulatorW=
parseInt((b.canvasWidth-b.upWidth-b.downW)/10);b.scrollManipulatorW=15>b.scrollManipulatorW?15:b.scrollManipulatorW;b.scrollManipulatorH=b.h;b.scrollManipulatorLimInf=d+b.downW;b.scrollManipulatorLimSup=d+b.canvasWidth-b.downW-b.scrollManipulatorW}b.containerControl.setAttribute("class","DescartesScrollbarContainer");b.containerControl.setAttribute("style","width: "+b.w+"px; height: "+b.h+"px; left: "+b.x+"px; top: "+b.y+"px; z-index: "+b.zIndex+";");b.canvas.setAttribute("width",b.w+"px");b.canvas.setAttribute("height",
b.h+"px");b.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");b.ctx=b.canvas.getContext("2d");b.divUp.setAttribute("class","DescartesCatcher");b.divUp.setAttribute("style","width : "+b.upWidth+"px; height : "+b.upHeight+"px; left: "+b.upX+"px; top: "+b.upY+"px;");b.divDown.setAttribute("class","DescartesCatcher");b.divDown.setAttribute("style","width : "+b.downW+"px; height : "+b.downH+"px; left: "+b.downX+"px; top: "+b.downY+"px;");b.scrollManipulator.setAttribute("class","DescartesCatcher");
b.scrollManipulator.setAttribute("style","width : "+b.scrollManipulatorW+"px; height : "+b.scrollManipulatorH+"px;");b.scrollManipulator.style.top=("v"===b.orientation?b.scrollManipulatorLimInf:0)+"px";b.scrollManipulator.style.left=("v"===b.orientation?0:b.scrollManipulatorLimInf)+"px";b.field.setAttribute("type","text");b.field.setAttribute("id",b.id+"scrollbar");b.field.setAttribute("class","DescartesScrollbarField");b.field.setAttribute("style","font-size: "+b.fieldFontSize+"px; width : "+(b.fieldWidth-
2)+"px; height : "+(b.fieldHeight-2)+"px; left: "+b.fieldX+"px; top: 0px;");b.field.value=c;0===b.fieldHeight&&(b.field.style.display="none");b.label.setAttribute("class","DescartesScrollbarLabel");b.label.setAttribute("style","font-size:"+b.fieldFontSize+"px; width: "+b.labelWidth+"px; height: "+b.labelHeight+"px; line-height: "+b.labelHeight+"px; left: 0px; top:"+b.labelY+"px;");b.txtLabel=document.createTextNode(b.name)};a.Scrollbar.prototype.update=function(){g=this.evaluator;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;q=e(this.w);c=e(this.h);h.fillStyle="#e0e4e8";h.fillRect(0,0,q,c);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);p=4;h.fillStyle="black";h.beginPath();b.orientation===l?(h.moveTo(b.downX+p,b.downH/2),h.lineTo(b.downX+b.downW-p,p),h.lineTo(b.downX+b.downW-p,b.downH-p),h.moveTo(b.upX+b.upWidth-p,b.downH/2),h.lineTo(b.upX+p,p),h.lineTo(b.upX+p,b.downH-p),h.fill(),b.activeIfValue&&(k=e(b.pos),h.fillStyle="#ccdcec",h.fillRect(k+0.5,0,e(b.scrollManipulatorW),c),h.strokeStyle="#6382bf",h.strokeRect(k+0.5,0,e(b.scrollManipulatorW),
c),r=e(b.scrollManipulatorW/2),h.beginPath(),h.moveTo(k+r+0.5-2,3),h.lineTo(k+r+0.5-2,c-3),h.moveTo(k+r+0.5,3),h.lineTo(k+r+0.5,c-3),h.moveTo(k+r+0.5+2,3),h.lineTo(k+r+0.5+2,c-3),h.stroke())):(h.moveTo(b.downX+b.downW/2,b.downY+b.downH-p),h.lineTo(b.downX+p,b.downY+p),h.lineTo(b.downX+b.downW-p,b.downY+p),h.moveTo(b.upX+b.upWidth/2,b.upY+p),h.lineTo(b.upX+p,b.upY+b.upHeight-p),h.lineTo(b.upX+b.upWidth-p,b.upY+b.upHeight-p),h.fill(),b.activeIfValue&&(k=e(b.pos),h.fillStyle="#ccdcec",h.fillRect(0,k+
0.5,q,e(b.scrollManipulatorH)),h.strokeStyle="#6382bf",h.strokeRect(0,k+0.5,q,e(b.scrollManipulatorH)),r=e(b.scrollManipulatorH/2),h.beginPath(),h.moveTo(3,k+r+0.5-2),h.lineTo(q-3,k+r+0.5-2),h.moveTo(3,k+r+0.5),h.lineTo(q-3,k+r+0.5),h.moveTo(3,k+r+0.5+2),h.lineTo(q-3,k+r+0.5+2),h.stroke()));h.strokeRect(0.5,0.5,q-1,c-1);b.activeIfValue||(h.fillStyle="rgba(240,240,240,"+160/255+")",h.fillRect(0,0,q,c.h))};a.Scrollbar.prototype.validateValue=function(a){g=this.evaluator;t=a.toString();t=parseFloat(t.replace(this.parent.decimal_symbol,
"."));isNaN(t)&&(t=0);this.minimo=g.evalExpression(this.min);t<this.minimo&&(this.value=null,t=this.minimo);this.maximo=g.evalExpression(this.max);t>this.maximo&&(this.value=null,t=this.maximo);u=this.incr;t=0!=u?t*u/u:0;this.fixed&&(t=parseFloat(parseFloat(t).toFixed(g.evalExpression(this.decimals))));return t};a.Scrollbar.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.incr)};a.Scrollbar.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.incr)};
a.Scrollbar.prototype.increase10=function(){p=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==l?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+p):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+p)};a.Scrollbar.prototype.decrease10=function(){p=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==l?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-
p):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-p)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&(m=this.validateValue(a),m!=this.value&&(this.value=m,this.field.value=this.formatOutputValue(m),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;m=e((this.pos-v)*(w-s)/(n-v)/u)*u+s;m!=this.value&&(this.value=m,this.field.value=this.formatOutputValue(m),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==l?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f,d){clearInterval(w);if((s.up||s.down||s.canvasClick)&&1E-7<Math.abs(s.value-d))c.call(s),a=f?a:30,w=setTimeout(function(){b(a,c,!1,d)},a)}function c(f){f.preventDefault();s.whichButton=a.whichButton(f);"L"==s.whichButton&&s.activeIfValue&&(s.clickPos=s.getCursorPosition(f),
s.canvasClick=!0,s.orientation==l?s.clickPos.x<s.prePos?b(v,s.decrease10,!0,s.minimo):b(v,s.increase10,!0,s.maximo):s.clickPos.y<s.prePos?b(v,s.increase10,!0,s.maximo):b(v,s.decrease10,!0,s.minimo))}function f(a){s.canvasClick=!1;clearInterval(w);a.preventDefault()}function d(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",
k),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",k,!1);a.preventDefault()}function n(a){s.scrollClick=!1;s.prePos=s.pos;window.removeEventListener("touchend",n,!1);window.removeEventListener("touchmove",
k,!1);a.preventDefault()}function k(a){var b=s.getCursorPosition(a);s.orientation==l?(s.pos=s.prePos-(s.initPos.x-b.x),s.pos<s.scrollManipulatorLimInf&&(s.pos=s.scrollManipulatorLimInf),s.pos>s.scrollManipulatorLimSup&&(s.pos=s.scrollManipulatorLimSup),s.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+s.scrollManipulatorW+"px; height : "+s.h+"px; left: "+s.pos+"px; top: 0px;")):(s.pos=s.prePos-(s.initPos.y-b.y),s.pos>
s.scrollManipulatorLimInf&&(s.pos=s.scrollManipulatorLimInf),s.pos<s.scrollManipulatorLimSup&&(s.pos=s.scrollManipulatorLimSup),s.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+s.w+"px; height : "+s.scrollManipulatorH+"px; left: 0px; top: "+s.pos+"px;"));s.changeValueForScrollMovement();a.preventDefault()}function p(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.up=!0,b(v,
s.increase,!0,s.maximo))}function m(c){c.preventDefault();s.whichButton=a.whichButton(c);"L"==s.whichButton&&s.activeIfValue&&(s.down=!0,b(v,s.decrease,!0,s.minimo))}function q(a){s.up=!1;clearInterval(w);a.preventDefault()}function t(a){s.down=!1;clearInterval(w);a.preventDefault()}function r(a){s.up=!1;clearInterval(w);a.preventDefault();s.draw()}function u(a){s.down=!1;clearInterval(w);a.preventDefault();s.draw()}z=a.hasTouchSupport;var s=this,v=z?500:200,w;s.canvas.oncontextmenu=s.divUp.oncontextmenu=
s.divDown.oncontextmenu=s.label.oncontextmenu=s.field.oncontextmenu=s.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&s.changeValue(s.field.value)});z?this.canvas.addEventListener("touchstart",c):this.canvas.addEventListener("mousedown",c);z||this.divDown.addEventListener("mouseout",t);z?window.addEventListener("touchend",f):window.addEventListener("mouseup",f);z?this.canvas.addEventListener("touchmove",d):this.canvas.addEventListener("mousemove",
d);z?this.scrollManipulator.addEventListener("touchstart",h):this.scrollManipulator.addEventListener("mousedown",e);z?this.divUp.addEventListener("touchstart",p):this.divUp.addEventListener("mousedown",p);z?this.divDown.addEventListener("touchstart",m):this.divDown.addEventListener("mousedown",m);z||this.divUp.addEventListener("mouseout",q);z||this.divDown.addEventListener("mouseout",t);z?window.addEventListener("touchend",r):window.addEventListener("mouseup",r);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 d=this,f=d.evaluator.evalExpression(d.expresion);4==f[0].length?(d.w=f[0][2],d.h=f[0][3]):(d.w=200,d.h=28);d.audio=d.parent.getAudio(d.file);d.autoplay&&(d.audio.setAttribute("autoplay","autoplay"),d.audio.play());d.loop&&d.audio.setAttribute("loop","loop");d.controls&&d.audio.setAttribute("controls","controls");d.audio.setAttribute("style","position: absolute; width: "+
d.w+"px; left: "+d.x+"px; top: "+d.y+"px; z-index: "+d.zIndex+";");d.addControlContainer(d.audio);d.evaluator.setFunction(d.id+".play",function(){d.audio.play()});d.evaluator.setFunction(d.id+".pause",function(){d.audio.pause()});d.evaluator.setFunction(d.id+".stop",function(){d.audio.pause();d.audio.currentTime=0});d.audio.addEventListener("timeupdate",function(a){d.evaluator.setVariable(d.id+".currentTime",d.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 l;a.Audio.prototype.update=function(){e=this.evaluator;(l=0<e.evalExpression(this.drawif))?this.audio.style.display="block":(this.audio.style.display="none",l!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=l;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 d=this;e=d.evaluator;
var f=d.evaluator.evalExpression(d.expresion);4==f[0].length?(d.w=f[0][2],d.h=f[0][3]):(d.w=null,d.h=null);d.video=document.createElement("video");d.autoplay&&d.video.setAttribute("autoplay","autoplay");d.loop&&d.video.setAttribute("loop","loop");d.controls&&d.video.setAttribute("controls","controls");d.poster&&d.video.setAttribute("poster",d.poster);d.w&&(d.video.setAttribute("width",d.w),d.video.setAttribute("height",d.h));d.video.setAttribute("style","position: absolute; overflow: hidden; left: "+
d.x+"px; top: "+d.y+"px;");var f=d.file,h=f.lastIndexOf(".");-1!=h&&(f=d.file.substring(0,h));d.video.canPlayType("video/mp4")&&(h=document.createElement("source"),h.setAttribute("src",f+".mp4"),h.setAttribute("type","video/mp4"),d.video.appendChild(h));d.video.canPlayType("video/ogg")&&(h=document.createElement("source"),h.setAttribute("src",f+".ogg"),h.setAttribute("type","video/ogg"),d.video.appendChild(h),h=document.createElement("source"),h.setAttribute("src",f+".ogv"),h.setAttribute("type",
"video/ogg"),d.video.appendChild(h));d.video.canPlayType("video/webm")&&(h=document.createElement("source"),h.setAttribute("src",f+".webm"),h.setAttribute("type","video/webm"),d.video.appendChild(h));d.addControlContainer(d.video);d.evaluator.setFunction(d.id+".play",function(){d.video.play()});d.evaluator.setFunction(d.id+".pause",function(){d.video.pause()});d.evaluator.setFunction(d.id+".stop",function(){d.video.pause();d.video.currentTime=0});d.video.addEventListener("timeupdate",function(a){d.evaluator.setVariable(d.id+
".currentTime",d.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 l;a.Video.prototype.update=function(){e=this.evaluator;l=0<e.evalExpression(this.drawif);0<e.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display="none",l!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=l;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e,l;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 d=this.parent.lessonParser.parseText(this.answer)}this.containerControl=document.createElement("div");this.textArea=document.createElement("div");this.textAreaAnswer=document.createElement("div");this.showButton=document.createElement("div");
this.activeCover=document.createElement("div");this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);this.containerControl.appendChild(this.activeCover);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=void 0==this.text||"simpleText"==this.text.type?this.rawText||"":this.text.hasFormula?this.rawText:this.text.toHTML();d&&"simpleText"!=d.type&&(this.answer=this.text.hasFormula?
"":d.toHTML());this.evaluator.setVariable(this.id,this.text);this.drawButton();this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){l=this.answer?28:8;e=this.evaluator;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-l)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textArea.setAttribute("contenteditable","true");this.textArea.innerHTML=
"<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;' >"+g+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-l)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textAreaAnswer.style.display=this.showAnswer?"block":"none";this.textAreaAnswer.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;'>"+
this.answer+"</span>";this.showButton.setAttribute("style","width: 20px; height: 16px; position: absolute; bottom: 4px; right: 4px; cursor: pointer;");this.showButton.style.backgroundImage="url("+this.imageUnPush+")";this.showButton.style.display=this.answer?"block":"none";this.showButton.innerHTML="<span style='position: relative; top: 2px; text-align: center; font: 9px Arial'> S </span>";this.activeCover.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+
this.x+"px; top: "+this.y+"px;");this.update()};a.TextArea.prototype.drawButton=function(){var e=document.createElement("canvas");e.setAttribute("width",20);e.setAttribute("height",16);var b=e.getContext("2d");this.canvas=e;this.ctx=b;this.createGradient(20,16);b.lineWidth=1;b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(b,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(b,1,0,1,16,"rgba(0,0,0,"+
8/255+")");this.imageUnPush=e.toDataURL();b.fillStyle="white";b.fillRect(0,0,20,16);b.fillStyle=this.linearGradient;b.fillRect(0,0,20,16);a.drawLine(b,0,0,0,14,"gray");a.drawLine(b,0,0,19,0,"gray");b.fillStyle="rgba(0, 0, 0,"+24/255+")";b.fillRect(0,0,this.w,this.h);this.imagePush=e.toDataURL()};a.TextArea.prototype.update=function(){e=this.evaluator;this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);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(d){d.preventDefault();b.showButton.style.backgroundImage="url("+b.imageUnPush+")"}var b=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();b.showAnswer=!b.showAnswer;b.textAreaAnswer.style.display=b.showAnswer?
"block":"none";b.showButton.childNodes[0].childNodes[0].textContent=b.showAnswer?"T":"S";b.showButton.style.backgroundImage="url("+b.imagePush+")"});this.showButton.addEventListener("mouseup",a);this.showButton.addEventListener("mouseout",a)};a.TextArea.prototype.getScreenshot=function(){var a=document.createElement("canvas");a.setAttribute("width",this.w);a.setAttribute("height",this.h);var b=a.getContext("2d");b.fillStyle="white";b.strokeStyle="black";b.lineWidth=1;b.fillRect(0,0,this.w,this.h);
b.strokeRect(0,0,this.w,this.h);return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,l,g,b,d,f,h,c,q,p;a.GraphicControl=function(b,c){g=b.evaluator.parser;this.text=this.spaceID="";this.size=g.parse("4");this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";a.Control.call(this,b,c);this.touchId=null;this.font=a.convertFont(this.font);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,q=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(){l=this.evaluator;p=a.hasTouchSupport;var b=l.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];l.setVariable(this.xString,this.x);l.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*
l.evalExpression(this.size),this.height=2*l.evalExpression(this.size));this._w=p&&70>this.width?70:this.width;this._h=p&&70>this.height?70:this.height;this.mouseCacher.setAttribute("style","cursor: pointer; background-color: rgba(255, 255, 255, 0); width: "+this._w+"px; height: "+this._h+"px; z-index: "+this.zIndex+";");this.mouseCacher.style.left=parseInt(this.space.getAbsoluteX(this.x)-this._w/2)+"px";this.mouseCacher.style.top=parseInt(this.space.getAbsoluteY(this.y)-this._h/2)+"px";l.setVariable(this.activoString,
0);this.update()};a.GraphicControl.prototype.update=function(){l=this.evaluator;this.activeIfValue=0<l.evalExpression(this.activeif);this.drawIfValue=0<l.evalExpression(this.drawif);this.x=l.getVariable(this.xString);this.y=l.getVariable(this.yString);b=this.space.getAbsoluteX(this.x);d=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(d-this._h/2)+"px";this.constraint&&
this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=function(){l=this.evaluator;this.drawIfValue&&(h=this.ctx,c=this.space.backgroundCtx,b=parseInt(this.space.getAbsoluteX(this.x))+0.5,d=parseInt(this.space.getAbsoluteY(this.y))+0.5,""!=this.text&&this.drawText(b,d),this.image.ready?(this.image.complete&&h.drawImage(this.image,parseInt(b-this.image.width/2),parseInt(d-this.image.height/2)),this.trace&&(c.save(),c.translate(b,d),c.scale(parseInt(this.image.width/2),parseInt(this.image.height/
2)),c.beginPath(),c.arc(0,0,1,0,e,!1),c.restore(),c.lineWidth=1,c.strokeStyle=this.trace.getColor(),c.stroke())):(h.beginPath(),h.arc(b,d,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,d,parseInt(this.width/2)-2,0,e,!1),h.strokeStyle=this.colorInt.borderColor(),h.stroke()),this.trace&&(c.lineWidth=1,c.strokeStyle=this.trace.getColor(),c.beginPath(),c.arc(b,d,parseInt(this.width/
2),0,e,!1),c.stroke())))};a.GraphicControl.prototype.evalConstraint=function(a,b){q.set(this.x,this.y);f=this.newt.findZero(q);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;l=this.evaluator;h.fillStyle=this.color.getColor();h.font=this.font;h.textBaseline="alphabetic";h.fillText(l.evalExpression(this.text[0],l.evalExpression(this.decimals),this.fixed),parseInt(a+1+
this.width/2),parseInt(b-1-this.height/2))};a.GraphicControl.prototype.getContainer=function(){for(var a=this.parent.spaces,b,c=0,f=a.length;c<f;c++)if(b=a[c],b.id==this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,this.space=b,b.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.activoString,0)};a.GraphicControl.prototype.registerMouseAndTouchEvents=
function(){function b(c){c.preventDefault();g.whichButton=a.whichButton(c);"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(c),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",f),window.addEventListener("mousemove",d))}function c(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",d),window.addEventListener("touchend",f))}function f(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",d,!1),window.removeEventListener("touchend",f,!1)):(window.removeEventListener("mouseup",
f,!1),window.removeEventListener("mousemove",d,!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 d(a){a.preventDefault();a.touchId=g.touchId;g.evaluator.setVariable(g.mclickedString,0);g.evaluator.setVariable(g.mclicizquierdoString,0);l=g.getCursorPosition(a);
g.posX=g.prePos.x-(g.posAnte.x-l.x);g.posY=g.prePos.y-(g.posAnte.y-l.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",c):(this.mouseCacher.addEventListener("mousedown",b),this.mouseCacher.addEventListener("mouseover",e),this.mouseCacher.addEventListener("mouseout",h));var l};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var b;if(a.touchId){c=0;for(f=a.touches.length;c<f;c++)if(a.touches[c].identifier==a.touchId){b=a.touches[c];
break}}else for(var c=0,f=a.touches.length;c<f;c++)if(a.target==a.touches[c].target){b=a.touches[c];this.touchId=b.identifier;break}mouseX=b.pageX;mouseY=b.pageY}else void 0!=a.pageX&&void 0!=a.pageY?(mouseX=a.pageX,mouseY=a.pageY):(mouseX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,mouseY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:mouseX-(this.space.container.offsetLeft+this.space.container.parentNode.offsetLeft),y:mouseY-(this.space.container.offsetTop+
this.space.container.parentNode.offsetTop)}};return a}(descartesJS||{}),descartesJS=function(a,e){var l,g,b,d,f,h,c,q,p,k;if(a.loadLib)return a;var r,t,u,m,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 c=0,f=a.length;c<f;c++)switch(u=a[c][0],m=a[c][1],t=e[u],t){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[t]=parseInt(m);break;case "about":case "config":case "init":case "clear":b[t]="true"===e[m];break;default:console.log("----- attributo de space no identificado: <"+u+"> valor: <"+m+"> -----")}return b};a.LessonParser.prototype.parseSpace=function(b){v={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(u=b[c][0],m=b[c][1],
t=e[u],t){case "type":case "id":case "cID":case "file":v[t]=m;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":v[t]="true"===e[m];break;case "bg_display":case "render":v[t]=e[m];break;case "net":case "net10":case "axes":case "text":v[t]="false"===e[m]?"":new a.Color(m,this.parent.evaluator);break;case "x_axis":case "y_axis":v[t]="false"===e[m]?"":m;break;case "O.x":v.OxExpr=m;break;case "O.y":v.OyExpr=m;break;case "image":v.imageSrc=m;break;case "x":r=m;
r="%"===r[r.length-1]?(this.parent.container.width*parseFloat(r)/100).toString():m;v.xExpr=this.parser.parse(r);break;case "y":r=m;r="%"===r[r.length-1]?(this.parent.container.height*parseFloat(r)/100).toString():m;v.yExpr=this.parser.parse(r);break;case "width":r=m;"%"===r[r.length-1]?(v.wExpr=r,r=this.parent.container.width*parseFloat(r)/100):(r=parseFloat(m),r!=m&&(r=this.parent.container.width));v.w=r;break;case "height":r=m;"%"===r[r.length-1]?(v.hExpr=r,r=this.parent.container.height*parseFloat(r)/
100):(r=parseFloat(m),r!=m&&(r=this.parent.container.height));v.h=r;break;case "drawif":v.drawif=this.parser.parse(m);break;case "scale":r=parseFloat(m);r.toString()!=m&&(r=48);v.scale=r;break;case "background":v.background=new a.Color(m,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+u+"> valor: <"+m+"> -----")}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={};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(u=b[c][0],m=b[c][1],t=e[u],t){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":n[t]=m;break;case "gui":case "region":case "action":case "msg_pos":case "poster":n[t]=
e[m];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":n[t]="true"===e[m];break;case "color":case "colorInt":case "trace":n[t]=new a.Color(m,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":n[t]=this.parser.parse(m);break;case "constraint":n.constraintExpr=m;break;case "image":n.imageSrc=m;break;case "space":n.spaceID=m;break;case "type":n.type=e[m.trim()];
break;case "expresion":n.expresion=this.parser.parse(m.replace(")(",","));break;case "bold":"false"!=e[m]&&(n.bold="bold");break;case "italics":"false"!=e[m]&&(n.italics="italic");break;case "underlined":"false"!=e[m]&&(n.underlined=!0);break;case "value":var d=m.replace(/&squot;/g,"'");d.match(/^\|/)&&(d="'"+d.substring(1),d.match(/\|$/)&&(d=d.substring(0,d.length-1)+"'"));n.valueExpr=this.parser.parse(d);n.valueExprString=d;break;case "incr":0!=m&&(n.incr=this.parser.parse(m));break;case "exponentialif":n.exponentialif=
parseFloat(m);break;case "text":n.rawText=m;for(var d=this.parseText(m),g=0,h=d.length;g<h;g++)d[g]=this.parser.parse(d[g],!1);n.text=d;break;default:g=u.indexOf(".");d=e[u.substring(0,g)];g=e[u.substring(g+1)];if("parameter"===d&&"font"===g){n.parameterFont=m;break}else if("Explanation"===d&&"font"===g){n.ExplanationFont=m;break}else if("tooltip"===d&&"font"===g){n.tooltipFont=m;break}console.log("----- attributo de control no identificado: <"+u+"> valor: <"+m+"> -----")}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,c,f,d){s={rotateExp:d,parameter:"t"};b=this.split(b);d=0;for(var g=b.length;d<g;d++)switch(u=b[d][0],m=b[d][1],t=e[u],t){case "type":case "align":s[t]=e[m];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":s[t]="true"===e[m];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":s[t]="false"===e[m]?"":new a.Color(m,this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":s[t]=
m;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[t]=this.parser.parse(m);break;case "space":s.spaceID=m;break;case "expresion":"macro"!=s.type?(s.expresion=this.parser.parse(m),s.expresionString=m):s.expresion=m;break;case "text":s.text=this.parseText(m);break;case "file":var h=m.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[m]&&(s.border=new a.Color(m,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(m);break;case "steps":s.family_steps=this.parser.parse(m)}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(m);break;case "steps":s.parameter_steps=this.parser.parse(m)}break}console.log("----- attributo del graphic no identificado: <"+u+"> valor: <"+m+"> -----")}c&&(s.abs_coord=c);f&&(s.background=f);switch(s.type){case "text":return new a.Text(this.parent,s);case "image":return new a.Image(this.parent,s);case "point":return new a.Point(this.parent,
s);case "polygon":return new a.Polygon(this.parent,s);case "arc":return new a.Arc(this.parent,s);case "segment":return new a.Segment(this.parent,s);case "arrow":return new a.Arrow(this.parent,s);case "macro":return new a.Macro(this.parent,s);case "curve":return new a.Curve(this.parent,s);case "equation":return new a.Equation(this.parent,s);case "sequence":return new a.Sequence(this.parent,s);case "fill":return new a.Fill(this.parent,s)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,f,d){s=
{rotateExp:d,parameter:"t"};b=this.split(b);c=0;for(f=b.length;c<f;c++)switch(u=b[c][0],m=b[c][1],t=e[u],t){case "type":case "model":s[t]=e[m];break;case "background":case "fixed":case "edges":s[t]="true"===e[m];break;case "color":case "backcolor":s[t]=new a.Color(m,this.parent.evaluator);break;case "type":case "model":s[t]=e[m];break;case "background":case "fixed":case "edges":case "split":s[t]="true"===e[m];break;case "color":case "backcolor":s[t]=new a.Color(m,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":s[t]=
this.parser.parse(m);break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":s[t]=m;break;case "space":s.spaceID=m;break;case "expresion":"macro"!=s.type&&"curve"!=s.type&&"surface"!=s.type?(s.expresion=this.parser.parse(m),s.expresionString=m):s.expresion=m.replace(/\\n/g,"");break;case "text":d=this.parseText(m);for(var g=0,h=d.length;g<h;g++)d[g]=this.parser.parse(d[g],!1);s.text=d;break;case "file":d=m.replace(/&squot;/g,"'");"["===d.charAt(0)&&"]"===d.charAt(d.length-
1)&&(d=d.substring(1,d.length-1));d.match(/./)&&(d="'"+d+"'");s.file=this.parser.parse(d);break;case "drawif":case "width":case "length":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":s[t]=this.parser.parse(m);break;case "family":case "parameter":case "font":case "name":s[t]=m;break;case "space":s.spaceID=m;break;case "expresion":"macro"!=s.type&&"curve"!=s.type&&"surface"!=s.type?(s.expresion=this.parser.parse(m),s.expresionString=m):s.expresion=m;break;
case "text":d=this.parseText(m);g=0;for(h=d.length;g<h;g++)d[g]=this.parser.parse(d[g],!1);s.text=d;break;case "file":d=m.replace(/&squot;/g,"'");"["===d.charAt(0)&&"]"===d.charAt(d.length-1)&&(d=d.substring(1,d.length-1));d.match(/./)&&(d="'"+d+"'");s.file=this.parser.parse(d);break;default:if(void 0!==s.family&&u.substring(0,s.family.length+1)===s.family+"."){"interval"===e[u.substring(s.family.length+1)]?s.family_interval=this.parser.parse(m):s.family_steps=this.parser.parse(m);break}console.log("----- attributo del graphic3D no identificado: <"+
u+"> valor: <"+m+"> -----")}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 c=0,f=b.length;c<f;c++)b[c][1]=b[c][1].replace(/&squot;/g,"'");c=0;for(f=b.length;c<f;c++)switch(u=b[c][0],m=b[c][1],t=e[u],t){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":w[t]=
m;break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":w[t]="true"===e[m];break;case "size":case "rows":case "columns":w[t]=this.parser.parse(m);break;case "evaluate":case "execution":case "msg_pos":case "action":w[t]=e[m];break;default:var d=u.indexOf("."),g=e[u.substring(0,d)],d=e[u.substring(d+1)];if("parameter"===g&&"font"===d){w.parameterFont=m;break}console.log("----- attributo de auxiliar no identificado: <"+u+"> valor: <"+m+"> -----")}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 c={};b=this.split(b);for(var f=0,d=b.length;f<d;f++)switch(u=b[f][0],m=b[f][1],t=e[u],t){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[t]=
m;break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[t]="true"===e[m];break;default:console.log("----- attributo de la animacion no identificado: <"+u+">  <"+m+"> -----")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(e,n){e=this.split(e);g=l="";b=0;d="#536891";f="white";h="left";c="";q="SansSerif,BOLD,20";p="SansSerif,PLAIN,18";k=void 0;for(var t=0,s=e.length;t<s;t++)switch(u=e[t][0],m=e[t][1],u){case "title":l=m;break;case "subtitle":g=
m;break;case "subtitlines":b=m;break;case "bgcolor":""!=m&&(d=(new a.Color(m,this.parent.evaluator)).getColor());break;case "fgcolor":""!=m&&(f=(new a.Color(m,this.parent.evaluator)).getColor());break;case "align":""!=m&&(h=m);break;case "titleimage":c=m;break;case "titlefont":q=""!=m?a.convertFont(m):a.convertFont(q);break;case "subtitlefont":p=""!=m?a.convertFont(m):a.convertFont(p);break;default:console.log("----- attributo de la pleca no identificado: <"+u+">  <"+m+"> -----")}if(""===l&&""===
g)return document.createElement("div");K=p.substring(0,p.indexOf("px"));K=K.substring(K.lastIndexOf(" "));""!=c&&(x=this.parent.getImage(c),J=x.height);k=document.createElement("div");k.setAttribute("id","descartesPleca");J?(k.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+h+"; width: "+(n-30)+"px; height: "+(J-16)+"px; background: "+d+"; 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%"),k.appendChild(x)):k.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+h+"; width: "+(n-30)+"px; background: "+d+"; 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: "+q+"; overflow: hidden; white-space: nowrap;");
F.innerHTML=l;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: "+p+"; 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: "+p+"; font-size: "+R+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else P.setAttribute("style",
"padding: 0px; margin: 0px; font: "+p+"; line-height: 110%;");P.innerHTML=g;k.appendChild(F);k.appendChild(P);k.imageHeight=J;return k};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){r=[];r.type="matrix";r.rows=a;r.cols=
b;var c;u=0;for(m=b;u<m;u++){c=[];t=0;for(v=a;t<v;t++)c.push(0);r[u]=c}return r}function l(a,b){p=a.rows;k=a.cols;r=e(p,k);var c;for(u=0;u<p;u++)for(t=0;t<k;t++){for(m=c=0;m<k;m++)c+=a[m][u]*b[t][m];r[t][u]=c}return r}function g(a,b,c){for(var f=e(c.length-1,c.length-1),d=0,g=f.length;d<g;d++)for(var h=0;h<g;h++)f[d][h]=d<a?h<b?c[d][h]:c[d][h+1]:d<b?c[d+1][h]:c[d+1][h+1];return f}function b(a){if(1<a.cols){for(var c=0,f=1,d=0,e=a.cols;d<e;d++)c+=f*a[0][d]*b(g(0,d,a)),f=-f;return c}return a[0][0]}
if(a.loadLib)return a;var d=Math.floor,f,h,c,q;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,c=this.childs.length;b<c;b++)if(this.childs[b].contains(a))return!0;return!1};a.Node.prototype.equalToMinus=function(){return"compOperator"===this.type?(this.type="operator",this.value="-",c=new a.Node("compOperator","=="),q=new a.Node("number","0"),c.addChild(this),c.addChild(q),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,c){a=b.variables[this.value];if("object"===typeof a)return a.evaluate(b);if(void 0==a&&(c||b.matrices[this.value]))a=b.matrices[this.value];
return void 0!==a?a:0}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1===this.childs[0].childs.length){var c,f;this.evaluate=function(a){c=this.childs[0].childs[0].evaluate(a);try{return f=a.vectors[this.value][0>c?0:d(c)],void 0!==f?f:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var h,m;this.evaluate=function(a){h=this.childs[0].childs[0].evaluate(a);m=this.childs[0].childs[1].evaluate(a);
try{return f=a.matrices[this.value][0>h?0:d(h)][0>m?0:d(m)],void 0!==f?f:0}catch(b){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var q;this.evaluate=function(a){q=[];for(var b=0,c=this.childs[0].childs.length;b<c;b++)q.push(this.childs[0].childs[b].evaluate(a));return"_Eval_"===this.value?a.evalExpression(a.parser.parse(q[0].replace(a.parent.decimal_symbol_regexp,".")||"")):a.functions[this.value].apply(a,q)}}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;p=a.rows;k=a.cols;r=e(p,k);for(u=0;u<p;u++)for(t=0;t<k;t++)r[t][u]=a[t][u]+b[t][u];return r}:"-"===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;p=a.rows;k=a.cols;r=e(p,k);for(u=0;u<p;u++)for(t=0;t<k;t++)r[t][u]=a[t][u]-b[t][u];return r}:
"*"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a,!0);D=this.childs[1].evaluate(a,!0);return"matrix"!==v.type||"matrix"!==D.type?v*D:l(v,D)}:"/"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a,!0);D=this.childs[1].evaluate(a,!0);if("matrix"!==v.type||"matrix"!==D.type)return v/D;a=v;var c;c=D;var f=e(c.length,c.length),d=b(c);if(0===d)c=0;else{var d=1/d,h;if(1<c.length)for(var k=0,p=c.length;k<p;k++){h=d;for(var m=0;m<p;m++)f[m][k]=h*b(g(k,m,c)),h=-h;d=-d}else f[0][0]=
d;c=f}a=0===c?e(a.rows,a.cols):l(a,c);return a}:"%"===this.value?this.evaluate=function(a){v=this.childs[0].evaluate(a);D=this.childs[1].evaluate(a);return v-d(v/D)*D}:"^"===this.value&&(this.evaluate=function(a){return Math.pow(this.childs[0].evaluate(a),this.childs[1].evaluate(a))})}else if("compOperator"===this.type)"<"===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<this.childs[1].evaluate(a))+0}:"<="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<=
this.childs[1].evaluate(a))+0}:">"===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>this.childs[1].evaluate(a))+0}:">="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>=this.childs[1].evaluate(a))+0}:"=="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)===this.childs[1].evaluate(a))+0}:"!="===this.value&&(this.evaluate=function(a){return(this.childs[0].evaluate(a)!=this.childs[1].evaluate(a))+0});else if("boolOperator"===this.type)"&"===
this.value?this.evaluate=function(a){return(v=this.childs[0].evaluate(a)?1:0)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return(v=this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){v=this.childs[0].evaluate(a)?1:0;return!v+0});else if("conditional"===this.type)this.evaluate=function(a){v=this.childs[0].evaluate(a);return 0<v?this.childs[1].evaluate(a):this.childs[2].evaluate(a)};else if("sign"===this.type)this.evaluate=
"sign+"===this.value?function(a){return this.childs[0].evaluate(a)}:function(a){return-this.childs[0].evaluate(a)};else if("parentheses"===this.type)this.evaluate=function(a,b){return this.childs[0].evaluate(a,b)};else if("(expr)"===this.type||"[expr]"===this.type){var 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 c=0,f=this.childs[b].childs.length;c<
f;c++)H.push(this.childs[b].childs[c].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?(c=G.childs[0].childs,1===c.length?(K=c[0].evaluate(a),K=0>K?0:d(K),a.vectors[G.value][K]=I.evaluate(a)):2===c.length&&(x=c[0].evaluate(a),J=c[1].evaluate(a),x=0>x?0:d(x),J=0>J?0:d(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 p,k,r,t,u,m,v;a.Node.prototype.toString=function(){var a="tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:"");for(var b=0,c=this.childs.length;b<c;b++)a+=this.sep+this.childs[b].toString();return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,g,b,d,f,h,c,q,p=/^\s+/,k=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,
r=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,t=/^==|^!=|^<=|^<|^>=|^>|^#/,u=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,m=/^=/,v=/^[\?\:]/,n=/^[\+\-\*\/\%\^]/,s=/^\[|^\]/,w=/^\(|^\)/,z=/^,/,C=/^;/;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function y(a,d,e){l.push({type:a,value:d});f=f.slice(e);b+=e;c++;q=a}if(e=a)a=a.replace(/\\u(\S+) /g,function(a,b){return String.fromCharCode(parseInt(b,16))}),a=a.replace(/\&sup(.+);/g,"^ $1 "),a=a.replace(/&squot;/g,"'"),a.match(/\=\|\*/g)&&(a=a.replace("|*",
"'","g").replace("*|","'","g")),a.match(/\=\|/g)&&(a=a.replace("|","'","g"));l=[];g=!1;b=0;f=a;c=0;for(q="";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}d=f.substring(1,h);y("string",d,d.length+2)}else if(d=f.match(p))f=f.slice(d[0].length),b+=d[0].length,c++;else if(d=f.match(k))"number"===q&&l.push({type:"operator",value:"*"}),y("identifier",d[0],d[0].length);else if(d=f.match(r))y("number",
d[0],d[0].length);else if(d=f.match(t)){var A=d[0];"#"==A&&(A="!=");y("compOperator",A,d[0].length)}else if(d=f.match(u))A=d[0],"||"==A?A="|":"&&"==A?A="&":"~"==A&&(A="!"),y("boolOperator",A,d[0].length);else if((d=f.match(m))&&!f.match(/^==/))y("asign",d[0],d[0].length);else if(d=f.match(v))y("conditional",d[0],d[0].length);else if(d=f.match(n))y("operator",d[0],d[0].length);else if(d=f.match(s))y("square_bracket",d[0],d[0].length);else if(d=f.match(w))"("==d&&"number"===q&&l.push({type:"operator",
value:"*"}),y("parentheses",d[0],d[0].length);else if(d=f.match(z))y("separator",d[0],d[0].length);else if(178===f.charCodeAt(0))l.push({type:"operator",value:"^"}),y("number",2,1);else if(179===f.charCodeAt(0))l.push({type:"operator",value:"^"}),y("number",3,1);else if(d=f.match(C))y("final_of_expresion",d[0],d[0].length);else if(g==b){console.log("Error, simbolo no conocido: ["+f+"], en la cadena <<"+e+">>");return}return l};var y,E=/rnd|pi|e|Infinity|-Infinity|sqr|sqrt|ra\u00edz|exp|log|log10|abs|ent|sgn|ind|sin|sen|cos|tan|cot|sec|csc|sinh|senh|cosh|tanh|coth|sech|csch|asin|asen|acos|atan|min|max/;
a.Tokenizer.prototype.flatTokens=function(a,b){a=a||[];b=b||"";y="";for(var c=0,f=a.length;c<f;c++)y="string"==a[c].type?y+"&squot;"+a[c].value+"&squot;":"identifier"==a[c].type&&!a[c].value.match(E)?y+b+a[c].value:y+a[c].value;return y};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Parser=function(b){this.evaluator=b;this.tokenizer=new a.Tokenizer;this.vectors={};this.matrices={};this.variables={};this.functions={};this.registerDefaultValues()};a.Parser.prototype.setVariable=
function(a,b){this.variables[a]=b};a.Parser.prototype.getVariable=function(a){return this.variables[a]};a.Parser.prototype.setVector=function(a,b,c){this.vectors[a][b]=c};a.Parser.prototype.getVector=function(a){this.vectors.hasOwnProperty(a)||(this.vectors[a]=[0,0,0]);return this.vectors[a]};a.Parser.prototype.setMatrix=function(a,b,c,f){this.matrices[a][b][c]=f};a.Parser.prototype.getMatrix=function(a){this.matrices.hasOwnProperty(a)||(this.matrices[a]=[[0,0,0],[0,0,0],[0,0,0]]);return this.matrices[a]};
a.Parser.prototype.setFunction=function(a,b){this.functions[a]=b};a.Parser.prototype.getFunction=function(a){this.functions.hasOwnProperty(a)||(this.functions[a]=function(){return 0});return this.functions[a]};var e,l,g,b,d,f,h,c,q,p,k,r;a.Parser.prototype.parse=function(t,u){(g=this.tokenizer.tokenize(t))||(g=[]);b=null;u=!u||!1;e=c=h=f=0;for(l=g.length;e<l;e++)if(q=g[e],p=q.value,k=q.type,"identifier"===k&&(e+1<l&&"parentheses"===g[e+1].type&&"("===g[e+1].value?this.getFunction(p):e+1<l&&"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(p):this.getMatrix(p):this.getVariable(p)),"asign"===k&&u&&(k="compOperator",p="=="),"asign"===k)if(d=new a.Node(k,p),null!=b)if("identifier"===b.type)b.parent&&b.parent.replaceLastChild(d),d.addChild(b),b=d,u=!0;else if("square_bracket"===b.type)d.addChild(b.parent),b=d,u=!0;else{d.type="compOperator";d.value="==";for(u=!0;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(d.value);)b=
b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{console.log("Error1: en la expresion <<"+t+">>, en el token {valor: "+p+", tipo: "+k+"}");break}else if("parentheses"===k&&"("===p||"square_bracket"===k&&"["===p)if(d=new a.Node(k,p),"("===p&&f++,"["===p&&h++,null===b)"("===p&&(new a.Node("(expr)","(expr)")).addChild(d),"["===p&&(new a.Node("[expr]","[expr]")).addChild(d),b=d;else if("operator"===b.type||"boolOperator"===b.type||"compOperator"===b.type||"conditional"===b.type||
"asign"===b.type)b.addChild(d),b=d;else if("sign"===b.type)b.addChild(d),b=d;else if("parentheses"===b.type&&"("===b.value)b.addChild(d),b=d;else if("square_bracket"===b.type&&"["===b.value)b.addChild(d),b=d;else if("parentheses"===b.type&&"()"===b.value)b.parent.addChild(d),b=d;else if("square_bracket"===b.type&&"[]"===b.value)b.parent.addChild(d),b=d;else if("identifier"===b.type)b.addChild(d),b=d;else{console.log("Error2: en la expresion <<"+t+">>, en el token ["+e+"] {valor: "+p+", tipo: "+k+
"}");break}else if("parentheses"===k&&")"===p)if(f--,null===b)console.log("Error3: en la expresion <<"+t+">>, en el token (valor:"+p+", tipo:"+k);else{for(;b&&b.parent&&"("!=b.value;)b=b.parent;if(b&&"("===b.value)b.value="()";else{console.log("Error4: en la expresion <<"+t+">>, en el token {valor: "+p+", tipo: "+k+"}");break}}else if("square_bracket"===k&&"]"===p)if(h--,null===b)console.log("Error5: en la expresion <<"+t+">>, en el token (valor:"+p+", tipo:"+k);else{for(;b&&b.parent&&"["!=b.value;)b=
b.parent;if(b&&"["===b.value)b.value="[]";else{console.log("Error6: en la expresion <<"+t+">>, en el token {valor: "+p+", tipo: "+k+"}");break}}else if("number"===k||"string"===k||"identifier"===k)if(d=new a.Node(k,p),null===b)b=d;else if("operator"===b.type||"compOperator"===b.type||"boolOperator"===b.type||"parentheses"===b.type&&"("===b.value||"square_bracket"===b.type&&"["===b.value||"sign"===b.type||"conditional"===b.type||"asign"===b.type)b.addChild(d),b=d;else{console.log("Error7: en la expresion <<"+
t+">>, en el token {valor: "+p+", tipo: "+k+"}");break}else if("operator"===k||"compOperator"===k||"boolOperator"===k)if(d=new a.Node(k,p),null===b)if("-"===p||"+"===p)d.type="sign",d.value="sign"+p,b=d;else if("!"===p)b=d;else{console.log("Error8: en la expresion <<"+t+">>, en el token {valor: "+p+", tipo: "+k+"}");break}else if("operator"===b.type||"compOperator"===b.type||"boolOperator"===b.type||"asign"===b.type||"conditional"===b.type||"square_bracket"===b.type&&"["===b.value&&("-"===p||"+"===
p||"!"===p)||"parentheses"===b.type&&"("===b.value&&("-"===p||"+"===p||"!"===p)){if("-"===p||"+"===p)d.type="sign",d.value="sign"+p;b.addChild(d);b=d}else if("number"===b.type||"parentheses"===b.type&&"()"===b.value||"square_bracket"===b.type&&"[]"===b.value||"string"===b.type||"identifier"===b.type||"conditional"===b.type||"asign"===b.type){for(;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(d.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{console.log("Error9: en la expresion <<"+
t+">>, en el token {valor: "+p+", tipo: "+k+"}");break}else if("conditional"===k)if(d=new a.Node(k,p),null!=b)if("?"===d.value){for(c++;b.parent&&this.getPrecedence(b.parent.value)>this.getPrecedence(d.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(d);d.addChild(b);b=d}else{for(c--;b&&b.parent&&"?"!=b.value;)b=b.parent;if(b&&"?"===b.value)b.value="?:";else{console.log("Error10: en la expresion <<"+t+">>, en el token {valor: "+p+", tipo: "+k+"}");break}}else{console.log("Error11: en la expresion <<"+
t+">>, en el token {valor: "+p+", tipo: "+k+"}");break}else if("separator"===k)if(null!=b)for(;b.parent&&"("!=b.value&&"["!=b.value;)b=b.parent;else{console.log("Error12: en la expresion <<"+t+">>, en el token {valor: "+p+", tipo: "+k+"}");break}else{console.log("Error13: en la expresion <<"+t+">>, en el token {valor: "+p+", tipo: "+k+"}");break}0<f&&alert("Error, faltan parentesis por cerrar: "+t);0>f&&alert("Error, faltan parentesis por abrir: "+t);0<h&&alert("Error, faltan square bracketss por cerrar: "+
t);0>h&&alert("Error, faltan square bracketss por abrir: "+t);0!=c&&alert("Error, condicional incompleta: "+t);(r=b?b.getRoot():null)&&r.setAllEvaluateFunction();return r};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(c,f,d){return a.esCorrecto(c,f,b.evaluator,d)};this.functions.escorrecto=function(c,f,d){return a.escorrecto(c,f,b.evaluator,d)};window.parent!==window&&(this.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",
name:a,value:b},"*")},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*")},this.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",name:a,value:b},"*")})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor;a.Evaluator=function(e){this.parent=e;this.parser=new a.Parser(this);this.variables=this.parser.variables;this.functions=this.parser.functions;this.vectors=this.parser.vectors;this.matrices=this.parser.matrices};
a.Evaluator.prototype.setVariable=function(a,e){this.variables[a]=e};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,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,d){g=0>g?0:e(g);b=0>b?0:e(b);this.matrices[a][g][b]=d};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,l=!1;a.RTFNode=function(a,b,c,d){this.evaluator=a;this.type="rtfNode";this.value=b;this.nodeType=c;this.style=d;this.styleString=d.toString();this.color=d.textColor;this.underline=d.textUnderline;this.overline=
d.textOverline;this.parent=null;this.children=[];switch(this.nodeType){case "textBlock":this.draw=this.drawTextBlock;break;case "textLineBlock":this.draw=this.drawTextLineBlock;break;case "formula":this.draw=this.drawFormula;break;case "superIndex":this.draw=this.drawSuperIndex;break;case "subIndex":this.draw=this.drawSubIndex;break;case "dynamicText":this.draw=this.drawDynamicText;this.decimal_symbol=this.evaluator.parent.decimal_symbol;break;case "fraction":this.draw=this.drawFraction;break;case "numerator":case "denominator":this.draw=
this.drawNumDen;break;case "radical":this.draw=this.drawRadical;break;case "limit":this.draw=this.drawLimit;break;case "integral":this.draw=this.drawIntegral;break;case "sum":this.draw=this.drawSum;break;case "matrix":this.draw=this.drawMatrix;break;case "defparts":this.draw=this.drawDefparts;break;case "text":case "newLine":this.draw=this.drawText;break;case "hyperlink":this.draw=this.drawHyperlink;break;case "mathSymbol":this.draw=this.drawMathSymbol;break;case "index":case "radicand":case "from":case "to":case "what":case "element":this.draw=
this.drawGenericBlock;break;case "componentNumCtrl":this.draw=this.drawComponentNumCtrl;break;case "componentSpace":this.draw=this.drawComponentSpace}};a.RTFNode.prototype.getRoot=function(){return null==this.parent?this:this.parent.getRoot()};a.RTFNode.prototype.addChild=function(a){a.parent=this;this.children.push(a)};var g=0,b=0,d=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 c=a.getFontMetrics(this.styleString);this.baseline=c.baseline;this.descent=c.descent;this.ascent=c.ascent;this.w=c.w;this.h=c.h}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);c=a.getFontMetrics(this.styleString);
this.baseline=c.baseline;this.descent=c.descent;this.ascent=c.ascent;var f=this.value,q;"string"!=typeof this.value&&(h=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),q=void 0==this.fixed?l:this.fixed,f=this.evaluator.evalExpression(this.value,h,q),parseFloat(f)==f&&(f=parseFloat(f).toFixed(h),f=q?f:parseFloat(f),f=f.toString().replace(".",this.decimal_symbol)),f+=" ");this.w=a.getTextWidth(f,this.styleString);this.h=c.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 p=this;this.clickCacher.addEventListener("click",function(a){p.click=!0;window.open(p.URL,
p.URL)})}else if("superIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),q=g,c=b,h=d,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-c+this.h,this.superIndexPos=f-this.ascent,this.ascent=f,this.descent=c,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),
q=g,c=b,h=d,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=c+1,this.ascent=q,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);q=g;c=b;h=d;q=this.children[0];var k=this.children[1],f=a.getFontMetrics(q.styleString);q.getBlockMetric();
k.getBlockMetric();0>q.h&&(q.h=f.h,q.w=this.spaceWidth);0>k.h&&(k.h=f.h,k.w=this.spaceWidth);this.h=q.h+k.h-1;this.ascent=q.h+h/2-c;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=Math.max(q.w,k.w)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);c=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator," ","radicand",c),this.children[1].addChild(this.children[0]),this.children[0]=
new a.RTFNode(this.evaluator," ","index",c);else if("index"!==this.children[0].nodeType||"radicand"!==this.children[1].nodeType){q=new a.RTFNode(this.evaluator,"","radicand",c);f=0;for(h=this.children.length;f<h;f++)q.addChild(this.children[f]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",c);this.children[1]=q}f=this.children[0];h=this.children[1];0>=f.children.length&&(c=this.style.clone(),c.fontSize=parseInt(c.fontSize-0.2*c.fontSize),f.addChild(new a.RTFNode(this.evaluator,
" ","text",c)));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),q=g,c=b,h=d,c=this.children[0],h=this.children[1],q=this.children[2],c.getBlockMetric(),h.getBlockMetric(),
q.getBlockMetric(),-1==c.ascent&&(k=a.getFontMetrics(c.styleString),c.ascent=k.ascent,c.descent=k.descent,c.h=k.h),-1==h.ascent&&(k=a.getFontMetrics(h.styleString),h.ascent=k.ascent,h.descent=k.descent,h.h=k.h),f=a.getFontMetrics(this.styleString),this.ascent=f.h+h.h>q.ascent?f.h-f.descent+h.h:q.ascent,this.descent=c.h>q.descent?c.h+f.descent:q.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,f=this.style.clone(),f.fontType="Times New Roman",f.Bold="bold",f=f.toString(),f=a.getTextWidth(String.fromCharCode(8721),
f),this.w=Math.max(c.w,h.w,f)+Math.max(q.w,this.spaceWidth)+this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),q=g,c=b,h=d,c=this.children[0],h=this.children[1],q=this.children[2],c.getBlockMetric(),h.getBlockMetric(),q.getBlockMetric(),-1==c.ascent&&(k=a.getFontMetrics(c.styleString),c.ascent=k.ascent,c.descent=k.descent,c.h=k.h),-1==h.ascent&&(k=a.getFontMetrics(h.styleString),h.ascent=k.ascent,h.descent=k.descent,h.h=k.h),f=a.getFontMetrics(this.styleString),
this.ascent=f.h+h.h>q.ascent?f.h-f.descent+h.h:q.ascent,this.descent=c.h>q.descent?c.h+f.descent:q.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,f=this.style.clone(),f.fontSize*=1.5,f.fontType="Times New Roman",f.Bold="bold",f=f.toString(),f=a.getTextWidth(String.fromCharCode(8747),f),this.w=Math.max(c.w,h.w,f)+Math.max(q.w,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),q=g,c=b,h=d,c=this.children[0],h=this.children[1],
q=this.children[2],f=a.getFontMetrics(this.styleString),c.getBlockMetric(),h.getBlockMetric(),q.getBlockMetric(),-1==c.ascent&&(k=a.getFontMetrics(c.styleString),c.ascent=k.ascent,c.descent=k.descent,c.h=k.h),-1==h.ascent&&(k=a.getFontMetrics(h.styleString),h.ascent=k.ascent,h.descent=k.descent,h.h=k.h),-1==q.ascent&&(k=a.getFontMetrics(q.styleString),q.ascent=k.ascent,q.descent=k.descent,q.h=k.h),this.ascent=q.ascent,this.descent=Math.max(f.h,q.descent),this.baseline=this.ascent,this.h=this.ascent+
this.descent,f=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==c.w&&(c.w=this.spaceWidth),0==h.w&&(h.w=this.spaceWidth),0==q.w&&(q.w=this.spaceWidth),this.w=h.w+c.w+q.w+f+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);f=a.getFontMetrics(this.styleString);q=g;c=b;h=d;q=f.ascent;for(var k=f.descent,r=f.h,t=this.spaceWidth,u,m,f=0,h=this.children.length;f<h;f++)this.children[f].getBlockMetric(),u=this.children[f].h,m=this.children[f].w,
r<u&&(r=u,q=this.children[f].ascent,k=this.children[f].descent),t<m&&(t=m);this.childWidth=t+2*this.spaceWidth;this.childh=r;this.childAscent=q;this.childDescent=k;this.h=this.rows*r;this.ascent=this.h/2+c;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);q=g;c=b;h=d;q=f.ascent;k=f.descent;r=f.h;t=this.spaceWidth;f=0;for(h=this.children.length;f<
h;f++)this.children[f].getBlockMetric(),u=this.children[f].h,m=this.children[f].w,r<u&&(r=u,q=this.children[f].ascent,k=this.children[f].descent),t<m&&(t=m);this.childWidth=t+2*this.spaceWidth;this.childh=r;this.childAscent=q;this.childDescent=k;this.h=this.parts*r;this.ascent=this.h/2+c;this.descent=this.h-this.ascent;this.w=t+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),c=a.getFontMetrics(this.styleString),this.baseline=c.baseline,this.descent=
c.descent,this.ascent=c.ascent,this.w=a.getTextWidth(this.value,this.styleString)+a.getTextWidth(" ",this.styleString),this.h=c.h):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),c=this.componentNumCtrl.h||0,this.baseline=Math.round(3*c/5),this.descent=Math.round(2*c/5),this.ascent=this.baseline,this.h=c,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,c,l=0,p=this.children.length;l<p;l++){c=this.children[l];c.getTextMetrics();childAscent=c.ascent;childDescent=c.descent;this.w+=c.w;var k=childDescent;c=c.h;g=childAscent;b=k;d=c;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,c,d,g,k,r){this.stableWidth||(this.getTextMetrics(),e=d,l=g);r=r?-this.children[0].ascent:0;g=d=0;for(k=this.children.length;g<k;g++)0<g&&(d+=this.children[g-1].h),this.children[g].draw(a,b+0,c+r+d)};a.RTFNode.prototype.drawTextLineBlock=function(b,d,c){for(var e=0,g=0,l=this.children.length;g<l;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,d+e,c+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+this.spaceWidth+d,c)};a.RTFNode.prototype.drawText=function(a,b,c){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,b-1,c);if(this.underline){var d=
"bold"==this.style.textBold,e=d?1:0.5;a.lineWidth=d?2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b-1,parseInt(c+this.descent/2)+e);a.lineTo(b-1+this.w,parseInt(c+this.descent/2)+e);a.stroke()}this.overline&&(e=(d="bold"==this.style.textBold)?2:1.5,a.lineWidth=d?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(b-1,parseInt(c-this.ascent)+e),a.lineTo(b-1+this.w,parseInt(c-this.ascent)+e),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(b,d,
c){var g=Math.floor(0.5*this.spaceWidth),p=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),k=void 0==this.fixed?l:this.fixed,r=this.evaluator.evalExpression(this.value,p,k);parseFloat(r).toString()===r.toString()&&(r=k?parseFloat(r).toFixed(p):parseFloat(parseFloat(r).toFixed(p)),r=(""+r).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(r,this.styleString);
b.fillText(r,g+d,c);this.underline&&(k=(p="bold"==this.style.textBold)?1:0.5,b.lineWidth=p?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(g+d-1,parseInt(c+this.descent/2)+k),b.lineTo(g+d-1+this.w,parseInt(c+this.descent/2)+k),b.stroke());this.overline&&(k=(p="bold"==this.style.textBold)?2:1.5,b.lineWidth=p?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(g+d-1,parseInt(c-this.ascent)+k),b.lineTo(g+d-1+this.w,parseInt(c-this.ascent)+k),b.stroke());this.w+=
2*g};a.RTFNode.prototype.drawHyperlink=function(a,b,c){this.clickCacher.parentNode||(a.canvas.nextSibling.className?a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling.nextSibling):a.canvas.parentNode.insertBefore(this.clickCacher,a.canvas.nextSibling),this.clickCacher.style.left=b-2+"px",this.clickCacher.style.top=c-this.ascent-2+"px");a.save();this.click?(a.fillStyle="red",a.strokeStyle="red"):(a.fillStyle="blue",a.strokeStyle="blue");a.font=this.styleStr;a.textAlign="start";
a.textBaseline="alphabetic";a.fillText(this.value,b-1,c);var d="bold"==this.style.textBold,e=d?1:0.5;a.lineWidth=d?2:1;a.beginPath();a.moveTo(b-1,Math.ceil(c+this.descent/2)+e-2);a.lineTo(b-1+this.w,Math.ceil(c+this.descent/2)+e-2);a.stroke();a.restore()};a.RTFNode.prototype.drawRadical=function(a,b,c){var d=Math.floor(this.spaceWidth);this.children[0].draw(a,b,Math.floor(c+this.children[1].descent-this.children[1].h/2-this.children[0].descent));this.children[1].draw(a,b+1.5*d+this.children[0].w,
c);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b,Math.floor(c+this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w,Math.floor(c+this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w+0.5*d,c+this.children[1].descent);a.lineTo(b+this.children[0].w+1*d,c-this.children[1].ascent);a.lineTo(b+this.children[0].w+2*d+this.children[1].w,c-this.children[1].ascent);a.stroke()};a.RTFNode.prototype.drawFraction=function(a,b,
c){this.children[0].draw(a,b+(this.w-this.children[0].w)/2,c-this.ascent);this.children[1].draw(a,b+(this.w-this.children[1].w)/2,c-this.ascent+this.children[0].h-1);var d=Math.floor(0.5*this.spaceWidth);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(b+d,parseInt(c-this.ascent+this.children[0].h)-0.5);a.lineTo(b-d+this.w-1,parseInt(c-this.ascent+this.children[0].h)-0.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<
g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(b,d,c){var e=a.getFontMetrics(this.styleString),
g=" "+String.fromCharCode(8594),l=a.getTextWidth(g,this.styleString);this.children[0].draw(b,d,c+e.descent+this.children[0].ascent);this.children[1].draw(b,d+this.children[0].w+l,c+e.descent+this.children[1].ascent);this.children[2].draw(b,d+l+this.children[0].w+this.children[1].w,c);null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",d+this.children[0].w,c);b.fillText(g,d+this.children[0].w,c+e.descent+this.children[0].ascent)};
a.RTFNode.prototype.drawIntegral=function(b,d,c){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),l=a.getFontMetrics(e),r=Math.max(this.children[0].w,this.children[1].w,Math.floor(1.5*g));this.children[0].draw(b,d+g,c+l.descent+this.children[0].ascent);this.children[1].draw(b,d+g+this.spaceWidth/2,c-this.ascent+this.children[1].ascent);this.children[2].draw(b,d+r+g,c);null!=this.color&&(b.fillStyle=
this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),d,c+l.descent/2)};a.RTFNode.prototype.drawSum=function(b,d,c){var e=this.style.clone();e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),g=a.getTextWidth(String.fromCharCode(8721),e),l=a.getFontMetrics(this.styleString),r=Math.max(this.children[0].w,this.children[1].w,g);this.children[0].draw(b,d+(r-this.children[0].w)/2,c+l.descent+this.children[0].ascent);this.children[1].draw(b,
d+(r-this.children[1].w)/2,c-l.ascent-this.children[1].descent);this.children[2].draw(b,d+r,c);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),d+Math.floor((r-g)/2),c-5)};a.RTFNode.prototype.drawMatrix=function(a,b,c){for(var d,e,g=0,l=this.children.length;g<l;g++)d=g%this.columns,e=Math.floor(g/this.columns),this.children[g].draw(a,2*this.spaceWidth+b+d*this.childWidth,c-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,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+0.5,c+this.descent+0.5);a.lineTo(Math.floor(b+this.spaceWidth)+0.5,c+this.descent+0.5);a.moveTo(Math.floor(b+this.w-this.spaceWidth)-0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/2)-0.5,c-this.ascent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/
2)-0.5,c+this.descent+0.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth)-0.5,c+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawDefparts=function(a,b,c){for(var d=0,e=this.children.length;d<e;d++)this.children[d].draw(a,b+3*this.spaceWidth,c-this.ascent+this.childAscent+d%this.parts*this.childh);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(parseInt(b+2*this.spaceWidth)+0.5,c-this.ascent+0.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c-this.ascent+4.5);a.lineTo(parseInt(b+
2*this.spaceWidth)-4.5,c+this.descent-this.h/2-4.5);a.lineTo(b-0.5,c+this.descent-this.h/2);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-this.h/2+4.5);a.lineTo(parseInt(b+2*this.spaceWidth)-4.5,c+this.descent-4.5);a.lineTo(parseInt(b+2*this.spaceWidth)+0.5,c+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawMathSymbol=function(a,b,c){a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color,a.fillStyle=this.color);a.beginPath();"("==this.value?(a.font=this.styleString,a.textAlign=
"start",a.textBaseline="alphabetic",a.fillText("(",b,c)):")"==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText(")",b+this.spaceWidth,c)):(a.font=this.styleString,a.textAlign="center",a.textBaseline="alphabetic",a.fillText(this.value,b+this.w/2,c))};a.RTFNode.prototype.drawGenericBlock=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,
b,c){this.parent.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+b+","+(c-this.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,b,c){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(b+"");this.componentSpace.yExpr=this.evaluator.parser.parse(c-this.parent.ascent+"")};a.RTFNode.prototype.draw=function(a,b,c){console.log(">>> Dibujo desconocido ",this.nodeType)};a.RTFNode.prototype.toHTML=
function(){var a="";if("textLineBlock"===this.nodeType||"textBlock"===this.nodeType)for(var b=0,c=this.children.length;b<c;b++)a+=this.children[b].toHTML();else"text"===this.nodeType?a="<span "+this.style.toCSS()+">"+this.value+"</span>":"newLine"===this.nodeType&&(a="<span "+this.style.toCSS()+">"+this.value+"<br /></span>");return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=String.fromCharCode,l,g,b,d,f,h,c,q,p,k,r;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[];l=[];g=a.length;l=[];b="";f=d=0;c=a.charAt(0);q=!1;for(p="text";d<g;)h=c,c=a.charAt(d+1),q?"\\"===c||"{"===c||"}"===c||" "===c||";"===c?(q=!1,b+=h," "===c&&(d++,c=a.charAt(d+1)),(k=b.match(/^\'([0-9a-f]{2})/))?(r="","text"===p&&(r=
l.pop().value),b=r+=e(parseInt(k[1],16))+b.substring(3)):(k=b.match(/^u[0-9]+/))?(r="","text"===p&&(r=l.pop().value),b=r+=e(k[0].substring(1))):("{"===b||"}"===b?(l.push({type:"text",value:b}),p="text"):(l.push({type:"controlWord",value:b}),p="controlWord"),b="")):b+=h:"\\"===h?(q=!0,""!==b&&(l.push({type:"text",value:b}),p="text"),b=""):"{"===h?(f++,""!==b&&l.push({type:"text",value:b}),b="",l.push({type:"openBlock",value:f}),p="openBlock"):"}"===h?(""!==b&&l.push({type:"text",value:b}),b="",l.push({type:"closeBlock",
value:f}),p="closeBlock",f--):b+=h,d++;""!==b&&l.push({type:"text",value:b});return l};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,g,b,d,f,h,c,q,p,k,r,t,u,m,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;l={};b=2;if("openBlock"==e[0].type&&"fonttbl"==e[1].value){for(g=e[0].value;"closeBlock"!=e[b].type&&e[b].value!=g;)l[e[b].value]=e[b+2].value.substring(0,e[b+2].value.length-1),b+=3;b++}d={};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),c=parseInt(e[b++].value.substring(5)).toString(16),q=parseInt(e[b++].value.substring(4)).toString(16),
";"===e[b].value&&b++,d[f++]="#"+(2>h.length?"0"+h:h)+(2>c.length?"0"+c:c)+(2>q.length?"0"+q:q);b++}p=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");k=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");p.addChild(k);u=t=r=null;z=w=s=n=v=m=!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&&l[e[x].value])y.fontType=l[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=d[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,m=!1,k=k.parent),C.pop(),y=C[C.length-1],A.pop();else if("controlWord"==e[x].type&&"par"==e[x].value){k.addChild(new a.RTFNode(this.evaluator,"","newLine",y.clone()));p=new a.RTFNode(this.evaluator,
"","textLineBlock",y.clone());if("textBlock"!=k.nodeType)for(k=k.parent;"textBlock"!=k.nodeType;)k=k.parent;k.addChild(p);k=p}else if("controlWord"==e[x].type&&"mjaformula"==e[x].value)H=!0,B=D,m=!0,p=new a.RTFNode(this.evaluator,"","formula",y.clone()),k.addChild(p),k=p,A[A.length-1]=p;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(),
p=new a.RTFNode(this.evaluator,"",e[x].value,F),A[A.length-2].addChild(p),A[A.length-1]=p;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),p=new a.RTFNode(this.evaluator,"",e[x].value,F),A[A.length-2].addChild(p),A[A.length-1]=p;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?p=new a.RTFNode(this.evaluator,"","numerator",F):"den"==e[x].value&&(p=new a.RTFNode(this.evaluator,"","denominator",F)),A[A.length-2].addChild(p),A[A.length-1]=p;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?p=new a.RTFNode(this.evaluator,"","subIndex",F):"supix"==e[x].value&&(p=
new a.RTFNode(this.evaluator,"","superIndex",F)),p.originalStyle=A[A.length-2].style.clone(),A[A.length-2].addChild(p),A[A.length-1]=p;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(),p=new a.RTFNode(this.evaluator,"",e[x].value,F),A[A.length-2].addChild(p),A[A.length-1]=p,"defparts"==e[x].value?u=p:"matrix"==e[x].value&&(t=p);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)t.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)t.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)r.decimals=this.evaluator.parser.parse(e[x].value+""),n=!1;else if("controlWord"==
e[x].type&&"fixed1"==e[x].value)r.fixed=!0;else if("controlWord"==e[x].type&&"fixed0"==e[x].value)r.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();p=new a.RTFNode(this.evaluator,textContent,"hyperlink",F);p.URL=e[x].value.split("|")[1];
if("textLineBlock"!=k.nodeType)for(k=k.parent;"textLineBlock"!=k.nodeType;)k=k.parent;k.addChild(p);K=!1}else if("text"==e[x].type&&G)p=new a.RTFNode(this.evaluator,e[x].value,"componentNumCtrl",y.clone()),k.addChild(p),G=!1;else if("text"==e[x].type&&I)p=new a.RTFNode(this.evaluator,e[x].value,"componentSpace",y.clone()),k.addChild(p),I=!1;else if("text"==e[x].type&&v)F=A[A.length-2].style.clone(),textContent=this.evaluator.parser.parse(e[x].value),p=new a.RTFNode(this.evaluator,textContent,"dynamicText",
F),A[A.length-2].addChild(p),r=A[A.length-1]=p,v=!1;else if("text"==e[x].type&&!v&&!m){textContent=e[x].value;p=new a.RTFNode(this.evaluator,textContent,"text",y.clone());if("textLineBlock"!=k.nodeType)for(k=k.parent;"textLineBlock"!=k.nodeType;)k=k.parent;k.addChild(p)}else if("text"==e[x].type&&!v&&m)textContent=e[x].value,p=new a.RTFNode(this.evaluator,textContent,"text",A[A.length-1].style.clone()),A[A.length-1].addChild(p);else if("("==e[x].type||")"==e[x].type)F=A[A.length-1].style.clone(),
F.textItalic="",p=new a.RTFNode(this.evaluator,e[x].type,"mathSymbol",F),A[A.length-1].addChild(p);else if("+"==e[x].type||"-"==e[x].type||"*"==e[x].type||"="==e[x].type)p=new a.RTFNode(this.evaluator,e[x].type,"mathSymbol",A[A.length-1].style.clone()),A[A.length-1].addChild(p);if(null!=k){var T=k.getRoot();T.stableWidth=E;T.getTextMetrics();T.hasFormula=H}return T};a.FontStyle=function(a,b,c,d,f,e,g){this.fontSize=a;this.fontType=b;this.textItalic=c;this.textBold=d;this.textUnderline=f;this.textOverline=
e;this.textColor=g};a.FontStyle.prototype.toString=function(){return(this.textBold+" "+this.textItalic+" "+this.fontSize+"px "+this.fontType).trim()};a.FontStyle.prototype.toCSS=function(){var a="style='font: "+this.fontSize+"px "+this.fontType+"; ";this.textUnderline&&!this.textOverline&&(a+="text-decoration: underline; ");!this.textUnderline&&this.textOverline&&(a+="text-decoration: overline; ");this.textUnderline&&this.textOverline&&(a+="text-decoration: underline overline; ");this.textBold&&!this.textItalic&&
(a+="font-style: normal; font-weight: bold; ");!this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: normal; ");this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: bold; ");!this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: normal; ");this.textColor&&(a+="color: "+this.textColor+"; ");return a+"'"};a.FontStyle.prototype.clone=function(){return new a.FontStyle(this.fontSize,this.fontType,this.textItalic,this.textBold,this.textUnderline,this.textOverline,
this.textColor)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,g,b,d,f,h,c,q,p,k,r,t,u;a.Space=function(b,c){this.parent=b;l=this.evaluator=this.parent.evaluator;g=l.parser;this.id="";this.values=c;this.type="R2";this.xExpr=g.parse("0");this.yExpr=g.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=g.parse("1");this.fixed=2!=b.version?!1:!0;this.scale=48;this.Oy=this.Ox=0;this.image=new Image;this.image.onload=function(){this.ready=
1};this.imageSrc="";this.bg_display="topleft";this.background="descinst.com.mja.descartes.DescartesJS.class"===b.code||b.arquimedes?new a.Color("f0f8fa"):new a.Color("ffffff");this.net=2!=b.version?new a.Color("c0c0c0"):"";this.net10=2!=b.version?new a.Color("808080"):"";this.axes=2!=b.version?new a.Color("808080"):"";this.text=new a.Color("ffafaf");this.numbers=!1;this.x_axis=2!=b.version?"":" ";this.y_axis=2!=b.version?"":" ";this.sensitive_to_mouse_movements=!1;this.cID="";this.mouse_y=this.mouse_x=
0;this.ctrs=[];this.graphicsCtr=[];this.graphics=[];this.backgroundGraphics=[];this.zIndex=b.zIndex;this.plecaHeight=b.plecaHeight||0;this.displaceRegionNorth=b.displaceRegionNorth||0;this.displaceRegionWest=b.displaceRegionWest||0;for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.init()};a.Space.prototype.init=function(){e=this.parent;l=this.evaluator;b=this.id;this.displaceRegionNorth=e.displaceRegionNorth||0;this.displaceRegionWest=e.displaceRegionWest||0;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);c=parseInt(e.container.width);this.x=l.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=l.evalExpression(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+"px",this.container.style.top=this.y+"px");0<=this.y?(d=h-this.y,this.h>d&&(this.h=d)):
(d=this.h+this.y,this.h=d>=h?h:d);0<=this.x?(f=c-this.x,this.w>f&&(this.w=f)):(f=this.w+this.x,this.w=f>=c?c:f);if(""!=this.imageSrc||!this.imageSrc.trim().toLowerCase().match(/vacio.gif$/))this.image=e.getImage(this.imageSrc);this.OxExpr&&(p=this.OxExpr,"%"===p[p.length-1]?this.Ox=this.w*parseFloat(p)/100:(q=parseFloat(p),q!=p&&(q=0),this.Ox=q));this.OyExpr&&(k=this.OyExpr,"%"===k[k.length-1]?this.Oy=this.h*parseFloat(k)/100:(q=parseFloat(k),q!=k&&(q=0),this.Oy=q));""!==this.id&&2!==e.version?(l.setVariable(b+
"._w",this.w),l.setVariable(b+"._h",this.h),l.setVariable(b+".escala",this.scale),l.setVariable(b+".Ox",this.Ox),l.setVariable(b+".Oy",this.Oy),l.setVariable(b+".mouse_x",0),l.setVariable(b+".mouse_y",0),l.setVariable(b+".mouse_pressed",0),l.setVariable(b+".mouse_clicked",0),l.setVariable(b+".clic_izquierdo",0)):(q=l.getVariable("_w"),void 0===q&&(q=this.w),l.setVariable("_w",q),q=l.getVariable("_h"),void 0===q&&(q=this.h),l.setVariable("_h",q),q=l.getVariable("escala"),void 0===q&&(q=this.scale),
l.setVariable("escala",q),q=l.getVariable("Ox"),void 0===q&&(q=this.Ox),l.setVariable("Ox",q),q=l.getVariable("Oy"),void 0===q&&(q=this.Oy),l.setVariable("Oy",q),l.setVariable("mouse_x",0),l.setVariable("mouse_y",0),l.setVariable("mouse_pressed",0),l.setVariable("mouse_clicked",0),l.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(){r=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(t=this.container.style.display);this.container.style.display="block";if(r.getBoundingClientRect){var a=r.getBoundingClientRect();this.offsetLeft=a.left;this.offsetTop=a.top}else for(;r;)r.tagName&&"html"!==r.tagName.toLowerCase()?(this.offsetLeft+=r.offsetLeft||0,this.offsetTop+=r.offsetTop||0,r=r.parentNode):r=null;this.container&&this.container.style&&(this.container.style.display=t)};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,l;if(a.loadLib)return a;var g=Math.floor,b=Math.round,d=2*Math.PI,f=a.convertFont("SansSerif,PLAIN,12"),h=a.convertFont("Monospaced,PLAIN,12"),c,q,p,k,r,t,u,m,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,d){a.Space.call(this,b,d);c=this;c.backgroundCanvas=document.createElement("canvas");c.backgroundCanvas.setAttribute("id",c.id+"_background");
c.backgroundCanvas.setAttribute("width",c.w+"px");c.backgroundCanvas.setAttribute("height",c.h+"px");c.backgroundCtx=c.backgroundCanvas.getContext("2d");c.backgroundCtx.imageSmoothingEnabled=!1;c.backgroundCtx.mozImageSmoothingEnabled=!1;c.backgroundCtx.webkitImageSmoothingEnabled=!1;c.canvas=document.createElement("canvas");c.canvas.setAttribute("id",c.id+"_canvas");c.canvas.setAttribute("width",c.w+"px");c.canvas.setAttribute("height",c.h+"px");c.canvas.setAttribute("class","DescartesSpace2DCanvas");
c.canvas.setAttribute("style","z-index: "+c.zIndex+";");c.ctx=c.canvas.getContext("2d");c.ctx.imageSmoothingEnabled=!1;c.ctx.mozImageSmoothingEnabled=!1;c.ctx.webkitImageSmoothingEnabled=!1;c.graphicControlContainer=document.createElement("div");c.graphicControlContainer.setAttribute("id",c.id+"_graphicControls");c.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+c.zIndex+";");c.numericalControlContainer=document.createElement("div");c.numericalControlContainer.setAttribute("id",
c.id+"_numericalControls");c.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+c.zIndex+";");c.container=document.createElement("div");c.container.setAttribute("id",c.id);c.container.setAttribute("class","DescartesSpace2DContainer");c.container.setAttribute("style","left: "+c.x+"px; top: "+c.y+"px; z-index: "+c.zIndex+";");c.parent.arquimedes&&"#f0f8fa"===c.background.getColor()&&(c.container.style.border="1px solid #b8c4c8");c.container.appendChild(c.backgroundCanvas);
c.container.appendChild(c.canvas);c.container.appendChild(c.graphicControlContainer);c.container.appendChild(c.numericalControlContainer);b.container.insertBefore(c.container,b.loader);c.parent.images[c.id+".image"]=c.canvas;c.parent.images[c.id+".image"].ready=1;c.parent.images[c.id+".image"].complete=!0;c.evaluator.setVariable(c.id+".image",c.id+".image");c.parent.images[c.id+".back"]=c.backgroundCanvas;c.parent.images[c.id+".back"].ready=1;c.parent.images[c.id+".back"].complete=!0;c.evaluator.setVariable(c.id+
".back",c.id+".back");""!==c.id&&2!==b.version?(c.OxString=c.id+".Ox",c.OyString=c.id+".Oy",c.scaleString=c.id+".escala",c.wString=c.id+"._w",c.hString=c.id+"._h",c.mxString=c.id+".mouse_x",c.myString=c.id+".mouse_y",c.mpressedString=c.id+".mouse_pressed",c.mclickedString=c.id+".mouse_clicked",c.mclicizquierdoString=c.id+".clic_izquierdo"):(c.OxString="Ox",c.OyString="Oy",c.scaleString="escala",c.wString="_w",c.hString="_h",c.mxString="mouse_x",c.myString="mouse_y",c.mpressedString="mouse_pressed",
c.mclickedString="mouse_clicked",c.mclicizquierdoString="clic_izquierdo");"descartesJS_scenario"!==c.id&&c.registerMouseAndTouchEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){c=this;c.uber.init.call(c);c.canvas&&(c.backgroundCanvas.setAttribute("width",c.w+"px"),c.backgroundCanvas.setAttribute("height",c.h+"px"),c.canvas.setAttribute("width",c.w+"px"),c.canvas.setAttribute("height",c.h+"px"));c.container&&c.findOffset()};a.Space2D.prototype.update=function(a){c=this;q=c.evaluator;
p=c.parent;q.setVariable(c.wString,c.w);q.setVariable(c.hString,c.h);c.drawIfValue=0<q.evalExpression(c.drawif);if(c.drawIfValue){r=c.x!==q.evalExpression(c.xExpr)+c.displaceRegionWest;t=c.y!==q.evalExpression(c.yExpr)+p.plecaHeight+c.displaceRegionNorth;c.spaceChange=a||r||t||c.drawBefore!==c.drawIfValue||c.Ox!==q.getVariable(c.OxString)||c.Oy!==q.getVariable(c.OyString)||c.scale!==q.getVariable(c.scaleString);c.x=r?q.evalExpression(c.xExpr)+c.displaceRegionWest:c.x;c.y=t?q.evalExpression(c.yExpr)+
p.plecaHeight+c.displaceRegionNorth:c.y;c.Ox=q.getVariable(c.OxString);c.Oy=q.getVariable(c.OyString);c.scale=q.getVariable(c.scaleString);c.drawBefore=c.drawIfValue;1E-6>c.scale?(c.scale=1E-6,q.setVariable(c.scaleString,1E-6)):1E6<c.scale&&(c.scale=1E6,q.setVariable(c.scaleString,1E6));if(r||t)c.container.style.left=c.x+"px",c.container.style.top=c.y+"px",c.findOffset();c.container.style.display="block";c.drawTrace=!c.spaceChange&&!c.click;c.spaceChange&&c.drawBackground();c.draw()}else c.container.style.display=
"none"};a.Space2D.prototype.drawBackground=function(){q=this.evaluator;k=this.backgroundCtx;k.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);k.fillStyle=this.background.getColor();k.fillRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?k.drawImage(this.image,0,0):"stretch"===this.bg_display?k.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?
(k.fillStyle=k.createPattern(this.image,"repeat"),k.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&k.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));m=this.scale;v=0;for(n=0>this.w+this.h?0:this.w+this.h;m>n;)m/=10,v++;for(;m<n/10;)m*=10;k.lineWidth=1;""!==this.net&&(k.strokeStyle=this.net.getColor(),this.drawMarks(k,m/10,-1));if(2!==this.parent.version&&""!==this.net10||2===this.parent.version&&""!==this.net&&""!==this.net10)k.strokeStyle=
this.net10.getColor(),this.drawMarks(k,m,-1);if(""!==this.axes){k.strokeStyle=this.axes.getColor();k.beginPath();if(""!==this.x_axis||2!==this.parent.version)k.moveTo(0,g(this.h/2+this.Oy)+0.5),k.lineTo(this.w,g(this.h/2+this.Oy)+0.5);if(""!==this.y_axis||2!==this.parent.version)k.moveTo(g(this.w/2+this.Ox)+0.5,0),k.lineTo(g(this.w/2+this.Ox)+0.5,this.h);k.stroke();this.drawMarks(k,m,4);this.drawMarks(k,m/2,2);this.drawMarks(k,m/10,1)}if(""!==this.x_axis||""!==this.y_axis)k.fillStyle=""!==this.axes?
this.axes.getColor():"black",k.font=f,k.textAlign="right",k.textBaseline="alphabetic",k.fillText(this.x_axis,g(this.w)-2,g(this.h/2+this.Oy)+12),k.fillText(this.y_axis,g(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(k.fillStyle=this.axes.getColor(),k.font=f,k.textAlign="start",k.textBaseline="bottom",m>(this.w+this.h)/2?this.drawNumbers(k,m/5,m<=this.scale?v+1:v):m>(this.w+this.h)/4?this.drawNumbers(k,m/2,m<=this.scale?v+1:v):this.drawNumbers(k,m,v));for(var a=0,b=this.backgroundGraphics.length;a<
b;a++)this.backgroundGraphics[a].draw()};a.Space2D.prototype.draw=function(){k=this.ctx;k.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=0,b=this.graphics.length;a<b;a++)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)&&(k.fillStyle=this.text.getColor(),k.strokeStyle=k.fillStyle,k.lineWidth=1,k.font=h,k.textAlign=
"center",k.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(k.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),k.fillText(K,P,Q),k.beginPath(),k.arc(J,F,2.5,0,d,!0),k.stroke())};a.Space2D.prototype.drawMarks=
function(a,c,d){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<=d&&(D=y-d,B=y+d,A=E-d,H=E+d);a.beginPath();for(d=-b(y/c);(z=y+b(d*c))<s;d++)a.moveTo(z+0.5,A+0.5),a.lineTo(z+0.5,H+0.5);for(d=-b(E/c);(C=E+b(d*c))<w;d++)a.moveTo(D+0.5,C+0.5),a.lineTo(B+0.5,C+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,c,d){s=this.w;w=this.h;y=g(s/2+this.Ox);E=g(w/2+this.Oy);for(d=-b(y/c);(z=y+b(d*c))<s;d++)a.fillText(parseFloat((d*c/this.scale).toFixed(4)),z+1,E-2);for(d=-b(E/c);(C=
E+b(d*c))<w;d++)0!==parseFloat(-d*c/this.scale)&&a.fillText(parseFloat((-d*c/this.scale).toFixed(4)),y+5,C+5)};a.Space2D.prototype.registerMouseAndTouchEvents=function(){function b(a){m.click=1;m.evaluator.setVariable(m.mpressedString,1);m.evaluator.setVariable(m.mclickedString,0);m.evaluator.setVariable(m.mclicizquierdoString,0);m.parent.deactivateGraphiControls();h(a);window.addEventListener("touchmove",n);window.addEventListener("touchend",c);a.preventDefault()}function c(a){m.click=0;m.evaluator.setVariable(m.mpressedString,
0);m.evaluator.setVariable(m.mclickedString,1);m.evaluator.setVariable(m.mclicizquierdoString,1);window.removeEventListener("touchmove",n,!1);window.removeEventListener("touchend",c,!1);a.preventDefault();m.parent.update()}function d(b){m.click=1;m.parent.deactivateGraphiControls();m.whichButton=a.whichButton(b);"R"===m.whichButton&&(window.addEventListener("mouseup",f),m.fixed||(m.clickPosForZoom=m.getCursorPosition(b).y,m.tempScale=m.scale,window.addEventListener("mousemove",k)));"L"===m.whichButton&&
(m.evaluator.setVariable(m.mpressedString,1),m.evaluator.setVariable(m.mclickedString,0),m.evaluator.setVariable(m.mclicizquierdoString,0),h(b),window.addEventListener("mousemove",n),window.addEventListener("mouseup",f));b.preventDefault()}function f(a){m.click=0;m.evaluator.setVariable(m.mpressedString,0);m.evaluator.setVariable(m.mclickedString,1);m.evaluator.setVariable(m.mclicizquierdoString,1);a.preventDefault();"R"===m.whichButton&&window.removeEventListener("mousemove",k,!1);m.sensitive_to_mouse_movements||
window.removeEventListener("mousemove",n,!1);window.removeEventListener("mouseup",f,!1);m.parent.update()}function h(a){m.posAnte=m.getCursorPosition(a);m.mouse_x=m.getRelativeX(m.posAnte.x);m.mouse_y=m.getRelativeY(m.posAnte.y);m.evaluator.setVariable(m.mxString,m.mouse_x);m.evaluator.setVariable(m.myString,m.mouse_y);m.evaluator.setVariable(m.mclickedString,0);m.evaluator.setVariable(m.mclicizquierdoString,0);m.parent.update()}function k(a){a.preventDefault();m.clickPosForZoomNew=m.getCursorPosition(a).y;
m.evaluator.setVariable(m.scaleString,m.tempScale+m.tempScale/45*((m.clickPosForZoom-m.clickPosForZoomNew)/10));m.parent.update()}function n(a){m.fixed||(m.posNext=m.getCursorPosition(a),e=g(m.posAnte.x-m.posNext.x),l=g(m.posAnte.y-m.posNext.y),m.evaluator.setVariable(m.OxString,m.Ox-e),m.evaluator.setVariable(m.OyString,m.Oy-l),m.posAnte.x-=e,m.posAnte.y-=l);h(a);a.preventDefault()}var m=this;M=a.hasTouchSupport;m.canvas.oncontextmenu=function(){return!1};M&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",
h),this.canvas.addEventListener("touchstart",b));M||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",h),this.canvas.addEventListener("mousedown",d))};return a}(descartesJS||{}),descartesJS=function(a){var e,l,g;function b(a,b){return b.depth-a.depth}function d(b,c){Y=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));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,c=Math.max,q=Math.cos,p=Math.sin,k=Math.sqrt,r=15*Math.PI/180,t=Math.cos(r),u=Math.sin(r),m,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,c){a.Space.call(this,b,c);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 d=0,f=n.lights.length;d<f;d++)n.lights[d]=a.normalize3D(n.lights[d]);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;m=n.evaluator;v=n.parent;
m.setVariable(n.wStr,n.w);m.setVariable(n.hStr,n.h);n.drawIfValue=0<m.evalExpression(n.drawif);if(n.drawIfValue){E=n.x!==m.evalExpression(n.xExpr)+n.displaceRegionWest;D=n.y!==m.evalExpression(n.yExpr)+v.plecaHeight+n.displaceRegionNorth;n.spaceChange=a||E||D||n.drawBefore!==n.drawIfValue||n.Ox!==m.getVariable(n.OxStr)||n.Oy!==m.getVariable(n.OyStr)||n.scale!==m.getVariable(n.scaleStr);n.x=E?m.evalExpression(n.xExpr)+n.displaceRegionWest:n.x;n.y=D?m.evalExpression(n.yExpr)+v.plecaHeight+n.displaceRegionNorth:
n.y;n.Ox=m.getVariable(n.OxStr);n.Oy=m.getVariable(n.OyStr);n.scale=m.getVariable(n.scaleStr);n.drawBefore=n.drawIfValue;if(a){var b;a=0;for(var d=n.parent.controls.length;a<d;a++)n.parent.controls[a].id===n.obsStr&&(b=!0);n.observer=b?m.getVariable(n.obsStr)||0.5*(n.w+n.h):2.5*(n.w+n.h);n.observer=c(n.observer,0.1*(n.w+n.h));m.setVariable(n.obsStr,n.observer);n.eye={x:n.observer/n.scale*t,y:0,z:n.observer/n.scale*u};n.D=n.scale*n.eye.x/t;n.XE=h(n.scale*n.eye.y+0.5);n.YE=h(n.scale*n.eye.z+0.5)}n.observer=
c(m.getVariable(n.obsStr),0.1*(n.w+n.h));m.setVariable(n.obsStr,n.observer);1E-6>n.scale?(n.scale=1E-6,m.setVariable(n.scaleStr,1E-6)):1E6<n.scale&&(n.scale=1E6,m.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=m.getVariable(n.userI_Dim_Str);n.userIntensity=m.getVariable(n.userI_I_Str);n.light3={x:parseInt(m.getVariable(n.userI_x_Str)),y:parseInt(m.getVariable(n.userI_y_Str)),z:parseInt(m.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,c=this.graphics.length;a<c;a++)s=this.graphics[a],s.update();this.primitives=[];a=0;for(c=this.graphics.length;a<c;a++){s=this.graphics[a];if(s.split||this.split)for(var d=a+1;d<c;d++)w=this.graphics[d],(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(c=this.graphicsCtr.length;a<c;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=q(x);F=p(x);e=b.x*J-b.y*F;l=b.x*F+b.y*J;g=b.z;
x=a.degToRad(n.evaluator.getVariable(n.rotYStr));J=q(x);F=p(x);return{x:g*F+e*J,y:l,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/k(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,c,e){U=a.subtract3D(this.eye,c.average);T=a.norm3D(U);X=a.scalarProduct3D(U,1/T);this.lights[3]=a.subtract3D(this.light3,
c.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<=c.direction?c.normal:a.scalarProduct3D(c.normal,-1);g=0;for(h=this.lights.length;g<h;g++)e?(O=Math.max(0,a.dotProduct3D(d(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);e(a);window.addEventListener("touchmove",l);window.addEventListener("touchend",c);a.preventDefault()}function c(a){k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);window.removeEventListener("touchmove",l,!1);window.removeEventListener("touchend",c,!1);a.preventDefault()}
function d(b){k.click=1;k.parent.deactivateGraphiControls();k.whichButton=a.whichButton(b);"R"===k.whichButton?(window.addEventListener("mouseup",f),k.fixed||(k.clickPosForZoom=k.getCursorPosition(b).y,k.tempScale=k.scale,window.addEventListener("mousemove",g))):"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),e(b),window.addEventListener("mousemove",l),window.addEventListener("mouseup",
f));b.preventDefault()}function f(a){k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);a.preventDefault();"R"===k.whichButton&&window.removeEventListener("mousemove",g,!1);window.removeEventListener("mousemove",l,!1);window.removeEventListener("mouseup",f,!1)}function e(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 g(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);e(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",d);this.disp={x:0,y:0}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var e;a.SpaceAP=function(l,g){a.Space.call(this,l,g);this.exportarVars=this.importarVars=null;e=l.evaluator;this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=e.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=e.parser.parse(this.file):this.file=e.parser.parse("'"+this.file+"'");this.oldFile=e.evalExpression(this.file);this.initFile()};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var e;
if(this.oldFile){var 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,d=0,f=e.length;d<f&&!(e[d].match("<applet")&&(b=!0),b&&(g+=e[d]),e[d].match("</applet"));d++);d=document.createElement("div");d.innerHTML=g;d.firstChild.setAttribute("width",this.w);d.firstChild.setAttribute("height",this.h);g=this.descApp?this.descApp.container:null;this.descApp=
new a.DescartesApp(d.firstChild);this.descApp.container.setAttribute("class","DescartesAppContainer");this.descApp.container.setAttribute("style","position: absolute; overflow: hidden; background-color: "+this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");g?this.parent.container.replaceChild(this.descApp.container,g):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);g=this.descApp.spaces;d=0;
for(f=g.length;d<f;d++)g[d].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"),d="position: absolute; overflow: hidden; background-color: "+
this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";",this.image&&("topleft"==this.bg_display?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?d+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?d+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(d+="background-image: url("+
this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",d),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 d in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(d)&&d.match(/^public./)&&this.importarVars.push({varName:d,value:this.evaluator.getVariable(d)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,e=!1,b=0,d=this.importarVars.length;b<d;b++)a=this.evaluator.getVariable(this.importarVars[b].varName),a!=this.importarVars[b].value&&(this.importarVars[b].value=
a,this.descApp.evaluator.setVariable(this.importarVars[b].varName,this.importarVars[b].value),e=!0);e&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,l,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 c=this;this.MyIFrame.onload=function(a){var b=this;c.evaluator.setFunction(c.id+".set",function(a,c){b.contentWindow.postMessage({type:"set",name:a,value:c},"*")});c.evaluator.setFunction(c.id+".update",function(){b.contentWindow.postMessage({type:"update"},"*")});c.evaluator.setFunction(c.id+
".exec",function(a,c){b.contentWindow.postMessage({type:"exec",name:a,value:c},"*")})};this.update=this.iframeUpdate;this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.init=function(){self=this;self.uber.init.call(self);self.MyIFrame&&(self.MyIFrame.style.width=self.w+"px",self.MyIFrame.style.height=self.h+"px",self.MyIFrame.style.left=self.x+"px",self.MyIFrame.style.top=self.y+"px")};a.SpaceHTML_IFrame.prototype.iframeUpdate=function(a){e=
this.evaluator;this.drawIfValue=0<e.evalExpression(this.drawif);if(this.drawif){this.MyIFrame.style.display=this.drawIfValue?"block":"none";a&&(this.y=this.x=Math.Infinity);l=this.x!==e.evalExpression(this.xExpr)+this.displaceRegionWest;g=this.y!==e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=l?e.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=g?e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(l||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 d=this;this.timer=setInterval(function(){d.drawLoaderBar(d.loaderBar.ctx,a.width,a.height)},10);a.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var b=this.children,c=this.images,d=this.audios,e=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,f=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g;this.arquimedes&&(c["lib/DescartesCCLicense.png"]=a.getCreativeCommonsLicenseImage(),
c["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=1}),c["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=1}));var g,l,u,m,v,n;u=0;for(v=b.length;u<v;u++)if("rtf"!==b[u].name){if(g=b[u].value.match(e)){m=0;for(n=g.length;m<n;m++)l=g[m],!l.toLowerCase().match(/vacio.gif$/)&&""!=l.substring(0,l.length-4)&&(c[l]=new Image,c[l].addEventListener("load",function(){this.ready=1}),c[l].addEventListener("error",function(){this.errorload=1}),c[l].src=
l)}if(g=b[u].value.match(f)){m=0;for(l=g.length;m<l;m++)this.initAudio(g[m])}}for(var s in c)c.hasOwnProperty(s)&&this.images.length++;for(s in d)d.hasOwnProperty(s)&&this.audios.length++;var w=this,z=this.images.length+this.audios.length,C=function(){w.readys=0;for(var a in c)c.hasOwnProperty(a)&&(c[a].ready||c[a].errorload)&&w.readys++;for(a in w.audios)d.hasOwnProperty(a)&&(d[a].ready||d[a].errorload)&&w.readys++;w.readys!=z?setTimeout(C,30):(clearTimeout(w.timer),w.descartesApp.initBuildApp())};
C()};a.DescartesLoader.prototype.initAudio=function(b){var c=this.audios;c[b]=new Audio(b);c[b].filename=b;var d=function(){this.ready=1},e=function(){!this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))&&"mp3"==this.filename.substring(this.filename.length-3)?(c[b]=new Audio(this.filename.replace("mp3","ogg")),c[b].filename=this.filename.replace("mp3","ogg"),c[b].addEventListener("canplaythrough",d),c[b].addEventListener("load",d),c[b].addEventListener("error",e),c[b].load()):
(console.log("El archivo '"+b+"' no puede ser reproducido"),this.errorload=1)};c[b].addEventListener("canplaythrough",d);c[b].addEventListener("load",d);c[b].addEventListener("error",e);a.hasTouchSupport?(c[b].load(),c[b].play(),c[b].ready=1):c[b].load()};var l,g,b,d;a.DescartesLoader.prototype.drawLoaderBar=function(a,c,f){l=this.barWidth;g=this.barHeight;b=this.images.length+this.audios.length;d=2*(l-2)/b;a.translate(c/2,(f-65*e)/2+90*e);a.scale(e,e);a.strokeRect(-l,-g,2*l,g);a.fillStyle="gray";
a.fillRect(-l+2,-g+2,2*(l-2),g-4);a.fillStyle="#1f375d";a.fillRect(-l+2,-g+2,this.readys*d,g-4);a.setTransform(1,0,0,1,0,0)};var f=function(a,b){var d=document.createElement("canvas");d.width=a;d.height=b;var f=d.getContext("2d");f.save();f.strokeStyle="#1f375d";f.fillStyle="#1f375d";f.lineCap="round";f.lineWidth=2;f.beginPath();e=a<b?a/360:b/195;e=2.5<e?2.5:e;f.translate((a-120*e)/2,(b-65*e)/2);f.scale(e,e);f.moveTo(3,25);f.lineTo(3,1);f.lineTo(21,1);f.bezierCurveTo(33,1,41,15,41,25);f.stroke();
f.beginPath();f.moveTo(1,63);f.lineTo(1,64);f.moveTo(5,62);f.lineTo(5,64);f.moveTo(9,61);f.lineTo(9,64);f.moveTo(13,60);f.lineTo(13,64);f.moveTo(17,58);f.lineTo(17,64);f.moveTo(21,56);f.lineTo(21,64);f.moveTo(25,53);f.lineTo(25,64);f.moveTo(29,50);f.lineTo(29,64);f.moveTo(33,46);f.lineTo(33,64);f.moveTo(37,41);f.lineTo(37,64);f.moveTo(41,32);f.lineTo(41,64);f.stroke();f.font="20px Arial, Helvetica, 'Droid Sans', Sans-serif";f.fillText("escartes",45,33);f.fillText("JS",98,64);f.restore();return d.toDataURL()};
return a}(descartesJS||{}),descartesJS=function(a){function e(a){for(var b="[",d=0,f=a.length;d<f;d++){if(a[d]instanceof Array)b+=e(a[d]);else{l=a[d];if("undefined"==typeof l||!l)l=0;"string"==typeof l&&(l="'"+l+"'");b+=l}d<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=
"{\\rtf1\\uc0{\\fonttbl\\f0\\fcharset0 Arial;\\f1\\fcharset0 Arial;\\f2\\fcharset0 Arial;\\f3\\fcharset0 Arial;\\f4\\fcharset0 Arial;}{\\f0\\fs34 __________________________________________________________________________________ \\par \\fs22                                        Los contenidos de esta unidad did\u00e1ctica interactiva est\u00e1n bajo una  {\\*\\hyperlink licencia Creative Commons|http://creativecommons.org/licenses/by-nc-sa/2.5/es/}, si no se indica lo contrario.\\par                                        La unidad did\u00e1ctica fue creada con Arqu\u00edmedes, que es un producto de c\u00f3digo abierto del  {\\*\\hyperlink Ministerio de Educaci\u00f3n de Espa\u00f1a|http://recursostic.educacion.es/descartes/web/DescartesWeb2.0/} y\\par                                        el {\\*\\hyperlink Instituto de Matem\u00e1ticas|http://arquimedes.matem.unam.mx/} de la Universidad Nacional Aut\u00f3noma de M\u00e9xico, cedido bajo licencia {\\*\\hyperlink EUPL v 1.1|/resources/eupl_v1.1es.pdf}, con {\\*\\hyperlink c\u00f3digo en Java|http://recursostic.educacion.es/descartes/web/source/}.}";
for(var e=this.children,b,d=0,f=0,h=0,c=e.length;h<c;h++)b=e[h],"rtf_height"==b.name&&(d=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&&d&&(this.height=d+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,d=[],f=[],e=[],c=[],l=[],p=[],k,r=0,t=a.length;r<t;r++)if(k=a[r],"pleca"==k.name)k=b.parsePleca(k.value,this.width),this.container.insertBefore(k,this.loader),this.plecaHeight=k.imageHeight?k.imageHeight:k.offsetHeight;else if("Buttons"==
babel[k.name])this.buttonsConfig=b.parseButtonsConfig(k.value);else if("decimal_symbol"==babel[k.name])this.decimal_symbol=k.value,this.decimal_symbol_regexp=RegExp("\\"+this.decimal_symbol,"g");else if("version"==babel[k.name])this.version=parseInt(k.value);else if("language"==babel[k.name])this.language=k.value;else if("rtf"==k.name){var u=(this.width-780)/2,m=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;c.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+
k.value.replace(/'/g,"&squot;")+"'");c.push("space='descartesJS_scenario' type='text' expresion='["+u+","+(m-25)+"]' background='yes' text='"+this.licenseA+"'");c.push("space='descartesJS_scenario' type='image' expresion='["+(u+15)+","+m+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==k.name.charAt(0)?(k.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,d.push(k.value)):"C"==k.name.charAt(0)&&"_"==k.name.charAt(1)?f.push(k.value):"A"==k.name.charAt(0)&&"_"==k.name.charAt(1)?
e.push(k.value):"G"==k.name.charAt(0)?c.push(k.value):"S"==k.name.charAt(0)?l.push(k.value):"Animation"==babel[k.name]&&p.push(k.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));r=0;for(t=d.length;r<t;r++)a=b.parseSpace(d[r]),this.arquimedes&&this.scenarioRegion.container.appendChild(a.container),this.spaces.push(a),this.zIndex++;r=0;for(t=c.length;r<t;r++)if(d=b.parseGraphic(c[r]))d.visible&&(this.editableRegionVisible=!0),d.space.addGraph(d);r=0;for(t=
l.length;r<t;r++)(d=b.parse3DGraphic(l[r]))&&d.space.addGraph(d);r=0;for(t=f.length;r<t;r++)this.controls.push(b.parseControl(f[r]));r=0;for(t=e.length;r<t;r++)b.parseAuxiliar(e[r]);r=0;for(t=p.length;r<t;r++)this.animation=b.parseAnimation(p[r]);this.configRegions();this.updateAuxiliaries();r=0;for(t=this.controls.length;r<t;r++)this.controls[r].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,d=this.container;if(2!=this.version)var f="15",h=100,c=100,l=100,p=100;else f="14",h=63,c=50,l=44,p=53;var k=0,r=0,t=0,u=t=0,m=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?(k=b.height,b.rowsNorth=1):k=b.height*b.rowsNorth;m=this.northSpace.container;m.setAttribute("id","descartesJS_northRegion");m.setAttribute("style","width:"+d.width+"px; height:"+k+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");d.insertBefore(m,this.loader);var m=d.width,y=0;b.about&&(y=h,m-=y);b.config&&(m-=c);for(var E=Math.ceil(v.length/b.rowsNorth),
D=m/E,t=0,B=v.length;t<B;t++)v[t].expresion=e.parse("("+(y+D*(t%E))+","+b.height*Math.floor(t/E)+","+D+","+b.height+")"),v[t].drawif=e.parse("1"),v[t].init();b.about&&(t="espa\u00f1ol"==this.language?"cr\u00e9ditos":"english"==this.language?"about":"cr\u00e9ditos",(new a.Button(this,{region:"north",name:t,font_size:e.parse(f),expresion:e.parse("(0, 0, "+h+", "+k+")")})).update());b.config&&(new a.Button(this,{region:"north",name:"config",font_size:e.parse(f),action:"config",expresion:e.parse("("+
(m+h)+", 0, "+c+", "+k+")")})).update()}if(0<b.rowsSouth||0<w.length||b.init||b.clear){0>=b.rowsSouth?(r=b.height,b.rowsSouth=1):r=b.height*b.rowsSouth;v=d.width;y=0;b.init&&(y=l,v-=y);b.clear&&(v-=p);m=this.southSpace.container;m.setAttribute("id","descartesJS_southRegion");m.setAttribute("style","width:"+d.width+"px; height:"+r+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(d.height-r)+"px; z-index:100;");d.insertBefore(m,this.loader);E=Math.ceil(w.length/b.rowsSouth);D=v/E;t=0;for(B=
w.length;t<B;t++)w[t].expresion=e.parse("("+(y+D*(t%E))+","+b.height*Math.floor(t/E)+","+D+","+b.height+")"),w[t].drawif=e.parse("1"),w[t].init();b.init&&(t="espa\u00f1ol"==this.language?"inicio":"english"==this.language?"init":"inicio",(new a.Button(this,{region:"south",name:t,font_size:e.parse(f),action:"init",expresion:e.parse("(0, 0, "+l+", "+r+")")})).update());b.clear&&(t="espa\u00f1ol"==this.language?"limpiar":"english"==this.language?"clear":"limpiar",(new a.Button(this,{region:"south",name:t,
font_size:e.parse(f),action:"clear",expresion:e.parse("("+(v+l)+", 0, "+p+", "+r+")")})).update())}if(0<z.length){t=d.height-k-r;n=b.widthEast;m=this.eastSpace.container;m.setAttribute("id","descartesJS_eastRegion");m.setAttribute("style","width:"+n+"px; height:"+t+"px; background:#c0c0c0; position:absolute; left:"+(d.width-n)+"px; top:"+k+"px; z-index:100;");d.insertBefore(m,this.loader);t=0;for(B=z.length;t<B;t++)z[t].expresion=e.parse("(0,"+b.height*t+","+n+","+b.height+")"),z[t].drawif=e.parse("1"),
z[t].init()}if(0<C.length){t=d.height-k-r;s=b.widthWest;m=this.westSpace.container;m.setAttribute("id","descartesJS_westRegion");m.setAttribute("style","width: "+s+"px; height: "+t+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+k+"px; z-index: 100;");d.insertBefore(m,this.loader);t=0;for(B=C.length;t<B;t++)C[t].expresion=e.parse("(0,"+b.height*t+","+s+","+b.height+")"),C[t].drawif=e.parse("1"),C[t].init()}if(this.editableRegionVisible){u=b.height;m=this.editableRegion.container;m.setAttribute("id",
"descartesJS_editableRegion");m.setAttribute("style","width:"+d.width+"px; height:"+u+"px; position:absolute; left:0px; top:"+(d.height-r-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;");d.insertBefore(m,this.loader);e=this.editableRegion.textFields;b=d.width/e.length;f=a.getFieldFontSize(u);t=0;for(B=e.length;t<B;t++)"div"==e[t].type?(m.appendChild(e[t].container),e[t].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(b-4)+"px; height: "+
u+"px; position: absolute; left: "+t*b+"px; top: 0px;"),h=e[t].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;"),c=h.offsetWidth,h.style.width=c+"px",h.firstChild.textContent=h.firstChild.textContent.substring(3,h.firstChild.textContent.length-3),e[t].container.lastChild.setAttribute("style",
"font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+f+"px; width:"+(b-c)+"px; height:"+u+"px; position:absolute; left:"+c+"px; top:0px; border:2px groove white;")):(m.appendChild(e[t]),e[t].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+f+"px; width:"+b+"px; height:"+u+"px; position:absolute; left:"+t*b+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=k;this.displaceRegionWest=s;d.width-=n;d.height=
d.height-r-u;t=0;for(B=this.spaces.length;t<B;t++)this.spaces[t].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,b=0,d=this.controls.length;b<d;b++)a=this.controls[b],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,b=this.auxiliaries.length;a<b;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=
function(){for(var a=0,b=this.events.length;a<b;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,b=this.controls.length;a<b;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var b=0,d=this.spaces.length;b<d;b++)this.spaces[b].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,b=this.spaces.length;a<b;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=function(){this.animation&&
this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stopAudios=function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),this.audios[a].currentTime=0)};a.DescartesApp.prototype.getImage=function(a){var b=this.images;if(a)return b[a]||(b[a]=new Image,b[a].addEventListener("load",
function(){this.ready=1}),b[a].addEventListener("error",function(){this.errorload=1}),b[a].src=a),b[a]};a.DescartesApp.prototype.getAudio=function(a){var b=this.audios;if(a){if(!b[a]){var d=a.lastIndexOf("."),d=-1===d?a.lenght:d;a.substring(0,d);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,d=0,e=this.controls.length;d<e;d++)if(b=this.controls[d],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var b,
d=0,e=this.controls.length;d<e;d++)if(b=this.controls[d],b.id==a)return b;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var b,d=0,e=this.spaces.length;d<e;d++)if(b=this.spaces[d],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var b,d=0,e=this.spaces.length;d<e;d++)if(b=this.spaces[d],b.id==a)return b;return{update:function(){},w:0}};var l;a.DescartesApp.prototype.getState=function(){var a,b="",d=this.evaluator.variables,
f;for(f in d)d.hasOwnProperty(f)&&(a=d[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 d=this.evaluator.vectors,h;for(h in d)d.hasOwnProperty(h)&&(a=d[h],b=b+"\n"+h+"="+e(a));h=this.evaluator.matrices;for(var c in h)h.hasOwnProperty(c)&&(a=h[c],b=b+"\n"+c+"="+e(a));return b};a.DescartesApp.prototype.setState=function(a){a=a.split("\n");for(var b,d,e=0,h=a.length;e<h;e++)b=a[e].split("="),
2<=b.length&&(d=eval(b[1]),-1!=b[1].indexOf("[[")?(this.evaluator.matrices[b[0]]=d,this.evaluator.matrices[b[0]].rows=d.length,this.evaluator.matrices[b[0]].cols=d[0].length):-1!=b[1].indexOf("[")?(this.evaluator.vectors[b[0]]=d,this.evaluator.variables[b[0]+".long"]=d.length):this.evaluator.variables[b[0]]=d),this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,b=0,d="",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,d+=" \\n "+this.controls[e].id+"="+this.controls[e].value+"|"+this.controls[e].ok);return"questions="+a+" \\n correct="+b+" \\n wrong="+(a-b)+d};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,b=0,d=a.length;b<d;b++)"textfield"==a[b].gui&&a[b].evaluate&&a[b].changeValue(a[b].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,b=this.saveState.length;a<
b;a++)this.evaluator.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||{}),descartesJS=function(a){function e(){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 l(e){a.getFeatures();
if(a.hasCanvasSupport){e=document.getElementsByTagName("*");for(var b=[],d=0,f=e.length;d<f;d++)"DescartesAppContainer"==e[d].className&&b.push(e[d]);d=0;for(f=b.length;d<f;d++)b[d].parentNode.removeChild(b[d]);b=document.getElementsByTagName("applet");d=document.getElementsByTagName("ajs");e=[];for(var h=0,c=b.length;h<c;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(c=d.length;h<c;h++)f=d[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(d=e.length;b<d;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,d=a.apps.length;b<d;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),d=[];""!==e.value&&(d=e.value.toString().split(","));b&&b.apply(a.apps[0].evaluator,d)}};void 0==a.loadLib&&(a.loadLib=!0,window.addEventListener("load",l),window.addEventListener("message",a.receiveMessage));return a}(descartesJS||{});
