/*
 Joel Espinosa Longi
 j.longi@gmail.com
 https://github.com/jlongi/DescartesJS
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2014-08-05
*/
var babel=function(a){if(a.loadLib)return a;a.falso=a["false"]=a.fals=a.gezurra=a.faux=a.fals="false";a.verdadero=a["true"]=a.veritable=a.egia=a.vrai=a.verdadeiro=a.veritable="true";a.no=a.ez=a.non=a["n\u00e3o"]="false";a["s\u00ed"]=a.yes=a.bai=a.oui=a.si=a["sim "]="true";a.negro=a.black=a.negre=a.beltza=a.noir=a.preto=a["#000000"]="#000000";a.maxenta=a.magenta=a["#ff00ff"]="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu=a["#0000ff"]="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise=a["#00ffff"]="#00ffff";
a.verde=a.green=a.verd=a.berdea=a.vert=a["#00ff00"]="#00ff00";a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo=a["#ffff00"]="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa=a["#ffc800"]="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho=a["#ff0000"]="#ff0000";a.pink=a.rosa=a.arrosa=a.rose=a["#ffafaf"]="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro=a["#404040"]="#404040";a.gris=a.gray=a.grisa=a.cinza=a["#808080"]=
"#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro=a["#c0c0c0"]="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=a["#ffffff"]="#ffffff";a.escala=a.scale=a.eskala=a["\u00e9chelle"]="scale";a.nombre=a.name=a.nom=a.izena=a.nome="name";a.ikusgai=a["vis\u00edvel"]=a.visible="visible";a.rastro=a.trace=a.rastre=a.arrastoa="trace";a.fondo=a.background=a.fons=a.hondoa=a.fond=a.fundo="background";a["par\u00e1metro"]=a.parameter=a.parametroa=a["par\u00e2metro"]=a["par\u00e0metre"]=
"parameter";a["sucesi\u00f3n"]=a.sequence=a["successi\u00f3"]=a.segida=a.succession=a["seq\u00fc\u00eancia"]="sequence";a["tama\u00f1o"]=a.size=a.neurria=a.taille=a.tamanho=a["grand\u00e0ria"]="size";a.decimales=a.decimals=a.hamartarra=a["d\u00e9cimales"]=a.decimais="decimals";a.red=a.net=a.xarxa=a.sarea=a["r\u00e9seau"]=a.rede=a.malha="net";a.red10=a.net10=a.xarxa10=a.sarea10=a["r\u00e9seau10"]=a.rede10=a.malha10="net10";a.ejes=a.axes=a.eixos=a.ardatzak=a.eixes="axes";a.texto=a.text=a.testua=a.texte=
"text";a["cr\u00e9ditos"]=a.about=a["cr\u00e8dits"]=a.kreditoak=a["cr\u00e9dits"]=a.sobre="about";a.config=a.konfig=a["configura\u00e7\u00e3o"]="config";a.limpiar=a.clear=a.neteja=a.ezabatu=a.nettoye=a.limpar="clear";a.incr=a.gehi=a.incremento="incr";a.min=a.inf="min";a.max=a.sup=a["m\u00e1x"]="max";a.relleno=a.fill=a.ple=a.betea=a.plein=a.recheo=a.preencher="fill";a["relleno+"]=a["fill+"]=a["ple+"]=a["betea+"]=a["plein+"]=a["recheo+"]=a["preencher+"]=a.fillP="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=
a["betea-"]=a["plein-"]=a["recheo-"]=a["preencher-"]=a.fillM="fillM";a.flecha=a.arrow=a.fletxa=a.gezia=a["fl\u00e8che"]=a.frecha=a.seta="arrow";a.ancho=a.width=a.ample=a.zabalera=a.large=a.largura="width";a.punta=a.spear=a.muturra=a.pointe=a.ponta="spear";a["regi\u00f3n"]=a.region=a["regi\u00f3"]=a.eskualde=a["r\u00e9gion"]=a["rexi\u00f3n"]=a["regi\u00e3o"]="region";a.norte=a.north=a.nord=a.ipar="north";a.sur=a.south=a.sud=a.hego=a.sul="south";a.este=a.east=a.est=a.ekialde=a.leste="east";a.oeste=
a.west=a.oest=a.hegoalde=a.ouest="west";a.exterior=a.external=a.kanpoalde=a.externo="external";a["expresi\u00f3n"]=a.expresion=a["expresi\u00f3"]=a.adierazpen=a["express\u00e3o"]="expresion";a.tipo=a.type=a.tipus=a.mota="type";a["posici\u00f3n"]=a.position=a["posici\u00f3"]=a.posizio=a["posi\u00e7\u00e3o"]="position";a["constricci\u00f3n"]=a.constraint=a["constricci\u00f3"]=a.beharte=a.constriction=a["constrici\u00f3n"]=a["restri\u00e7\u00e3o"]="constraint";a.valor=a.value=a.balio=a.valeur="value";
a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.curva=a.curve=a.corba=a.kurba=a.courbe="curve";a.texto=a.text=a.testu=a.texte="text";a.punto=a.point=a.punt=a.puntu=a.ponto="point";a.segmento=a.segment=a.zuzenki="segment";a.arco=a.arc=a.arku="arc";a["pol\u00edgono"]=a.polygon=a["pol\u00edgon"]=a.poligono=a.polygone="polygon";a.imagen=a.image=a.imatge=a.irudi=a.imaxe=a.imagem="image";a["Versi\u00f3n"]=a.Version=a["Versi\u00f3"]=a["Vers\u00e3o"]=
a.version="version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=a.language="language";a["O.x"]="O.x";a["O.y"]="O.y";a.Botones=a.Buttons=a.Botons=a.Botoiak=a.Boutons=a["Bot\u00f3ns"]=a["Bot\u00f5es"]=a.Botons="Buttons";a["Animaci\u00f3n"]=a.Animation=a["Animaci\u00f3"]=a.Animazio=a["Anima\u00e7\u00e3o"]="Animation";a.constante=a.constant=a.Konstante="constant";a.fuente=a.font=a.iturri=a.source=a.fonte="font";a["num\u00e9rico"]=a.numeric=a["num\u00e8ric"]=a.zenbakizko=a["num\u00e9rique"]="numeric";a["gr\u00e1fico"]=
a.graphic=a["gr\u00e0fic"]=a.grafiko=a.graphique="graphic";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.hacer=a["do"]=a.fer=a.egin=a.faire=a.facer=a.fazer=a.doExpr="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto=a.whileExpr="whileExpr";a.evaluar=a.evaluate=a.avalua=a.ebaluatu=a["\u00e9valuer"]=a.avaliar="evaluate";a.variable=a.aldagaia=a["vari\u00e1vel"]="variable";a["funci\u00f3n"]=a["function"]=a["funci\u00f3"]=a.funtzio=a.fonction=
a["fun\u00e7\u00e3o"]="function";a.algoritmo=a.algorithm=a.algorisme=a.algorithme="algorithm";a.vector=a.array=a.bektore=a.vecteur=a.matriz="array";a["dibujar-si"]=a["draw-if"]=a["marraztu-baldin"]=a["dessiner-si"]=a["debuxar-se"]=a["desenhar-se"]=a["dibuixa-si"]=a.drawif="drawif";a.dominio=a.range=a.domini=a["izate-eremua"]=a.domain=a["dom\u00ednio"]="range";a.pausa=a.delay=a.eten="delay";a["eje-x"]=a["x-axis"]=a["eix-x"]=a["x-ardatza"]=a["axe-x"]=a["eixe-x"]=a["eixo-x"]=a.x_axis="x_axis";a["eje-y"]=
a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=a["eixo-y"]=a.y_axis="y_axis";a["n\u00fameros"]=a.numbers=a.nombres=a.zenbakiak="numbers";a["exponencial-si"]=a["exponential-if"]=a["esponentzial-baldin"]=a["exponentiel-si"]=a["exponencial-se"]=a.exponentialif="exponentialif";a.familia=a.family=a["fam\u00edlia"]=a.famille="family";a.intervalo=a.interval=a.tarte=a.intervalle="interval";a.pasos=a.steps=a.passos=a.pausoak=a.pas="steps";a.centro=a.center=a.centre=a.zentro="center";a.radio=
a.radius=a.radi=a.erradio=a.rayon=a.raio="radius";a.fin=a.end=a.fi=a.bukaera=a.fim="end";a["una-sola-vez"]=a["only-once"]=a["una-sola-vegada"]=a["behin-bakarrik"]=a["une-seule-fois"]=a["unha-soa-vez"]=a["apenas-uma-vez"]=a.onlyOnce="onlyOnce";a.siempre=a.always=a.sempre=a.beti=a.toujours="always";a["color-int"]=a["int-colour"]=a["barruko-kolore"]=a["couleur-int"]=a["cor-int"]=a.colorInt="colorInt";a.repetir=a.loop=a.repeteix=a.errepikatu=a["r\u00e9p\u00e9ter"]="loop";a.controles=a.controls=a.kontrolak=
a["contr\u00f4les"]=a.controis="controls";a.animar=a.animate=a.anima=a.animatu=a.animer="animate";a.auto="auto";a.alto=a.height=a.alt=a.altu=a.haut=a.altura="height";a.x=a.left="x";a.y=a.top="y";a.espacio=a.space=a.espai=a.espazio=a.espace=a.espazo=a["espa\u00e7o"]="space";a.Nu="Nu";a.Nv="Nv";a.ancho=a.depth=a.amplada=a.zabalera=a.largeur=a.ancho=a.profundidade=a.amplada=a.width="width";a.largo=a.length=a.llargada=a.luzera=a.longueur=a.longo=a.comprimento=a.llargada="length";a.alto=a.height=a["al\u00e7ada"]=
a.altu=a.hauteur=a.alto=a.altura=a["al\u00e7ada"]="height";a.color_reverso=a.backcolor=a.color_revers=a["atzealde kolorea"]=a.couleur_revers=a.cor_reverso=a.cor_de_fundo="backcolor";a.aristas=a.edges=a.arestes=a.ertzak=a["ar\u00eates"]=a.arestas="edges";a.rotini=a.inirot="inirot";a.posini=a.inipos="inipos";a["tri\u00e1ngulo"]=a.triangle=a.hirukia=a["tri\u00e2ngulo"]="triangle";a.cara=a.face=a.aurpegi="face";a.polireg=a.regpoly=a["pol\u00edgonoRegular"]="polireg";a.superficie=a.surface=a["superf\u00edcie"]=
a.azalera="surface";a.cubo=a.cube=a.cub=a.kubo="cube";a["paralelep\u00edpedo"]=a.box=a["paral\u00b7lelep\u00edpede"]=a.paralelepipedo=a["parall\u00e9l\u00e9pip\u00e8de"]="box";a.cono=a.cone=a.con=a.kono=a["c\u00f4ne"]="cone";a.cilindro=a.cylinder=a.cilindre=a.zilindro=a.cylindre="cylinder";a.esfera=a.sphere=a["sph\u00e8re"]="sphere";a.tetraedro=a.tetrahedron=a.tetraedre=a["t\u00e9tra\u00e8dre"]="tetrahedron";a.octaedro=a["octahedron="]=a.octaedre=a.oktaedro=a["octa\u00e8dre"]="octahedron";a.dodecaedro=
a.dodecahedron=a.dodecaedre=a.dodekaedro=a["dod\u00e9ca\u00e8dre"]="dodecahedron";a.icosaedro=a.icosahedron=a.icosaedre=a.ikosaedro=a["icosa\u00e8dre"]="icosahedron";a.elipsoide=a.ellipsoid=a["el\u00b7lipsoide"]=a["ellipso\u00efde"]=a["elips\u00f3ide"]="ellipsoid";a.macro=a.makro="macro";a.id="id";a.modelo=a.model=a.eredu=a["mod\u00e8le"]="model";a.color=a.kolore=a.couleur=a.cor=a.colour=a.kolorea="color";a.luz=a.light=a.llum=a.argia=a["lumi\u00e8re"]="light";a.metal=a.metall=a["m\u00e9tal"]="metal";
a.alambre=a.wire=a.filferro=a.alanbre=a["fil de fer"]=a.arame="wire";a.cortar=a.split=a.talla=a.moztu=a.couper=a.dividir="split";a.despliegue=a.render=a.desplegament=a.zabaltze=a["d\u00e8ploiement"]=a.despregamento=a.processar="render";a.orden=a.sort=a.ordre=a.ordena=a.orde=a.ordenar="sort";a.pintor=a.painter=a.margolari=a.peintre="painter";a["trazado de rayos"]=a["ray trace"]=a["tra\u00e7at de raigs"]=a["izpi trazadura"]=a["trace de rayons"]=a["trazado de raios"]=a["tra\u00e7ado de raios"]=a.raytrace=
"raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo=a.image="image";a.despl_imagen=a.bg_display=a.despl_imatge=a["irudi desplazamendu"]=a.despl_image=a.despr_imaxe=a["apresenta\u00e7\u00e3o_de_imagem"]="bg_display";a["arr-izq"]=a.topleft=a["dalt-esq"]=a["goi-ezk"]=a["au-dessus-gau"]=a["arr-esq"]=a["acima-esquerda"]="topleft";a["expand."]=a.stretch=a.hedatu=a["expandir "]="stretch";a.mosaico=a.patch=a.mosaic=a.mosaiko=a["mosa\u00efque"]="patch";a.centrada=a.center=a.zentratu=
a["centr\u00e9e"]=a.centrado="imgcenter";a.archivo=a.file=a.fitxer=a.artxibo=a.fichier=a.arquivo="file";a.tipo_de_macro=a.macro_type=a.tipus_de_macro=a.makro_mota=a.type_de_macro=a.tipo_de_macro=a.tipo_de_macro=a.tipus_de_macro="macro_type";a.filas_norte=a.rows_north=a.files_nord=a["HTML kodea"]=a.files_nord=a.filas_norte=a.linhas_norte=a.files_nord=a.rowsNorth="rowsNorth";a.filas_sur=a.rows_south=a.files_sud=a.ipar_lerro=a.files_sud=a.filas_sur=a.linhas_sul=a.files_sud=a.rowsSouth="rowsSouth";a.ancho_este=
a.width_east=a.ample_est=a.hego_lerro=a.ample_est=a.ancho_leste=a.largura_leste=a.ample_est=a.widthEast="widthEast";a.ancho_oeste=a.width_west=a.ample_oest=a.ekialde_zabalera=a.ample_ouest=a.ancho_oeste=a.largura_oeste=a.ample_oest=a.widthWest="widthWest";a.fijo=a.fixed=a.fix=a.hegoalde_zabalera=a.fixe=a.fixo="fixed";a["Reiniciar Animaci\u00f3n"]=a["Init Animation"]=a["Reinicia Animaci\u00f3"]=a.finko=a["Recommencer l'Animation"]=a["Reiniciar Anima\u00e7\u00e3o"]=a.initAnimation="initAnimation";a["Explicaci\u00f3n"]=
a.Explanation=a.Azalpena=a.Explication=a["Explica\u00e7\u00e3o"]=a["Explicaci\u00f3"]="Explanation";a.tooltip=a.dica="tooltip";a.discreto=a.discrete=a.discret=a.diskretu="discrete";a.interfaz=a.gui=a["interf\u00edcie"]=a.interfaze=a["interface"]="gui";a.pulsador=a.spinner=a.polsador=a.pultsadore=a.bouton="spinner";a["campo de texto"]=a.textfield=a["camp de text"]=a["testu esarrua"]=a["champ de texte"]="textfield";a["men\u00fa"]=a.choice=a.menu=a.escolha="menu";a.barra=a.scrollbar=a.barre="scrollbar";
a.opciones=a.options=a.opcions=a.aukerak=a["opci\u00f3ns"]=a["op\u00e7\u00f5es"]="options";a.interior=a.barruko=a["int\u00e9rieur"]="interior";a["condici\u00f3n"]=a.condition=a["condici\u00f3"]=a.baldintza=a["condi\u00e7\u00e3o"]="condition";a["acci\u00f3n"]=a.action=a["acci\u00f3"]=a.ekintza=a["a\u00e7\u00e3o"]="action";a.evento=a.event=a.esdeveniment=a.gertaera=a["\u00e9v\u00e9nement"]="event";a["abrir URL"]=a["open URL"]=a["obre URL"]=a["URL zabaldu"]=a["ouvrir URL"]=a.openURL="openURL";a["abrir Escena"]=
a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]=a.openScene="openScene";a["bot\u00f3n"]=a.button=a["bot\u00f3"]=a.botoi=a.bouton=a["bot\u00e3o"]="button";a.mensaje=a.message=a.mezua=a.mensaxe=a.mensagem=a.missatge="message";a.alternar=a.alternate=a.alterna=a.txandakatu=a.alterner="alternate";a["ejecuci\u00f3n"]=a.execution=a["execuci\u00f3"]=a.gauzatze=a["ex\u00e9cution"]=a["execuci\u00f3n"]=a["execu\u00e7\u00e3o"]="execution";a.calcular=a.calculate=a.calcula=
a.kalkulatu=a.calculer="calculate";a.coord_abs=a.abs_coord=a.koor_abs="abs_coord";a.negrita=a.bold=a.negreta=a.lodi=a["caract\u00e8re gras"]=a.negra=a.negrito="bold";a.cursiva=a.italics=a.etzana=a.italique=a["it\u00e1lico"]="italics";a.subrayada=a.underlined=a.subratllat=a.azpimarratua=a.soulignement=a["subli\u00f1ada"]=a.sublinhado="underlined";a.imagen=a.image=a.imatge=a.irundia=a.imaxe=a.imagem="image";a.pos_mensajes=a.msg_pos=a.pos_missatges=a.mezuen_pos=a.pos_messages=a.pos_mensaxes="msg_pos";
a.izquierda=a.left=a.esquerra=a.eskerrean=a.gauche=a.esquerda=a.esquerda=a.esquerra=a.x="x";a.derecha=a.right=a.dreta=a.eskuinan=a.droite=a.dereita=a.direita=a.dreta="right";a["sensible_a_los_movimientos_del_rat\u00f3n"]=a.sensitive_to_mouse_movements=a["sensible_als_moviments_del_ratol\u00ed"]=a["xagu mugimenduarekiko sentikorra"]=a.sensible_aux_mouvements_du_souris=a.sensible_aos_movementos_do_rato=a["sens\u00edvel_aos_movimentos_do_mouse"]="sensitive_to_mouse_movements";a.reproducir=a.play=a.reprodueix=
a.erreproduzitu=a.reproduire=a.reproduzir=a.playAudio="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]=a.activeif="activeif";a.rotfin=a.finrot=a.bukrot=a.endrot="endrot";a.posfin=a.finpos=a.bukpos=a.endpos="endpos";a.editable=a.editagarria=a["edit\u00e1vel"]="editable";a.tipo=a.type=a.tipus=a.mota="type";a.R2="R2";a.R3="R3";a.vectores=a.bektoreak=a.vecteurs=a.vetores=a.vectors="vectors";a["fuente puntos"]=a["font size"]=a["font punts"]=
a["puntu iturria"]=a["source points"]=a["fonte puntos"]=a["fonte pontos"]=a.font_size="font_size";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.punto=a.dot=a.punt=a.puntu=a.point=a.ponto="point";a.escenario=a.scenario=a.escenari=a.agertoki=a["sc\u00e8ne"]=a["cen\u00e1rio"]="scenario";a.cID="cID";a.matriz=a.matrix=a.matriu=a.matrice="matrix";a.filas=a.rows=a.files="rows";a.columnas=a.columns=a.colonnes="columns";a.solo_texto=a.only_text=
a.seulement_texte=a["s\u00f3_texto"]=a.tan_sols_texte=a.onlyText="onlyText";a.respuesta=a.answer="answer";a.peso=a.weight=a.pes="weight";a.decimal_symbol=a["signo decimal"]=a["decimal symbol"]="decimal_symbol";a.info="info";a.color_contorn_text=a.color_text_border=a.color_borde_texto=a.muga_testuaren_kolorea=a.couleur_contour_texte=a.cor_borde_texto=a.colore_bordo_testo=a.cor_borda_texto=a.color_contorn_text=a.border="border";a.video=a["vid\u00e9o"]="video";a.audio=a["\u00e0udio"]="audio";a.autoplay=
"autoplay";a.loop="loop";a.poster="poster";a.opacidad=a.opacity=a["opacit\u00e9"]=a.opacitat=a.opacidade="opacity";a.alinear=a.align=a["ali\u00f1ar"]=a.aligner="align";a.malla=a.mesh="mesh";a.local=a.Local="local";a.rectangle=a["rect\u00e1ngulo"]="rectangle";a.generic=a.generico="generic";a.loadLib=!0;a["GUI_espa\u00f1ol"]={decimal_symbol:"Simbolo decimal",language:"Lenguaje",about:"Cr\u00e9ditos",config:"Configuraci\u00f3n",init:"Inicio",clear:"Limpiar"};a.GUI_english={};a["GUI_catal\u00e0"]={};
a.GUI_euskera={};a["GUI_fran\u00e7ais"]={};a.GUI_galego={};a["GUI_portugu\u00eas"]={};a["GUI_valenci\u00e0"]={};a.translate=function(a,g){return g.charAt(0).toUpperCase()+g.substring(1)};a["LANG_espa\u00f1ol"]={"true":"s\u00ed","false":"no",decimal_symbol:"signo decimal",version:"Versi\u00f3n",language:"Idioma",Buttons:"Botones",about:"cr\u00e9ditos",init:"inicio",clear:"limpiar",widthEast:"ancho_este",widthWest:"ancho_oeste",type:"tipo",width:"ancho",height:"alto",drawif:"dibujar-si",exponentialif:"exponencial-si",
activeif:"activo-si",fixed:"fijo",scale:"escala",image:"imagen",bg_display:"despl_imagen",background:"fondo",file:"archivo",topleft:"arr-izq",stretch:"expand.",patch:"mosaico",imgcenter:"centrada",center:"centro",net:"red",net10:"red10",axes:"ejes",text:"texto",numbers:"n\u00fameros",x_axis:"eje-x",y_axis:"eje-y",sensitive_to_mouse_movements:"sensible_a_los_movimientos_del_rat\u00f3n",render:"despliegue",sort:"orden",painter:"pintor",split:"cortar",raytrace:"trazado de rayos",numeric:"num\u00e9rico",
region:"regi\u00f3n",north:"norte",south:"sur",east:"este",west:"oeste",external:"exterior",expresion:"expresi\u00f3n",space:"espacio",name:"nombre",value:"valor",incr:"incremento",gui:"interfaz",spinner:"pulsador",textfield:"campo de texto",menu:"men\u00fa",scrollbar:"barra",options:"opciones",button:"bot\u00f3n",graphic:"gr\u00e1fico",discrete:"discreto",decimals:"decimales",visible:"visible",action:"acci\u00f3n",playAudio:"reproducir",parameter:"par\u00e1metro",interior:"interior",condition:"condici\u00f3n",
action:"acci\u00f3n",event:"evento",openURL:"abrir URL",openScene:"abrir Escena",message:"mensaje",alternate:"alternar",execution:"ejecuci\u00f3n",calculate:"calcular",onlyText:"solo_texto",msg_pos:"pos_mensajes",color:"color",colorInt:"color-int",bold:"negrita",italics:"cursiva",underlined:"subrayada",font_size:"fuente puntos",size:"tama\u00f1o",constraint:"constricci\u00f3n",answer:"respuesta",weight:"peso","function":"funci\u00f3n",algorithm:"algoritmo",array:"vector",doExpr:"hacer",whileExpr:"mientras",
evaluate:"evaluar",range:"dominio",onlyOnce:"una-sola-vez",always:"siempre",matrix:"matriz",rows:"filas",columns:"columnas",constant:"constante",equation:"ecuaci\u00f3n",curve:"curva",sequence:"sucesi\u00f3n",text:"texto",point:"punto",segment:"segmento",arc:"arco",polygon:"pol\u00edgono",image:"imagen",abs_coord:"coord_abs",trace:"rastro",family:"familia",interval:"intervalo",steps:"pasos",fillP:"relleno+",fillM:"relleno-",fill:"relleno",spear:"punta",arrow:"flecha",radius:"radio",end:"fin",vectors:"vectores",
opacity:"opacidad",backcolor:"color_reverso",triangle:"tri\u00e1ngulo",face:"cara",surface:"superficie",cube:"cubo",box:"paralelep\u00edpedo",cone:"cono",cylinder:"cilindro",sphere:"esfera",tetrahedron:"tetraedro",octahedron:"octaedro",dodecahedron:"dodecaedro",icosahedron:"icosaedro",ellipsoid:"elipsoide",model:"modelo",light:"luz",metal:"metal",wire:"alambre",edges:"aristas",length:"largo",Animation:"Animaci\u00f3n",delay:"pausa",controls:"controles",loop:"repetir"};a.toLanguage=function(e,g){return a["LANG_"+
(g||"espa\u00f1ol")][e]||e};return a}(babel||{}),descartesJS=function(a){if(a.loadLib)return a;a.convertFont=function(a){if(""==a)return a;fontTokens=a.split(",");fontCanvas="";"bold"==fontTokens[1].toLowerCase()?fontCanvas+="Bold ":"italic"==fontTokens[1].toLowerCase()||"italics"==fontTokens[1].toLowerCase()?fontCanvas+="Italic ":"bold+italic"==fontTokens[1].toLowerCase()&&(fontCanvas+="Italic Bold ");fontName=fontTokens[0].split(" ")[0].toLowerCase();fontCanvas+=fontTokens[2]+"px ";return fontCanvas=
"serif"===fontName||"times new roman"===fontName||"timesroman"===fontName||"times"===fontName?fontCanvas+"descartesJS_serif,Times,'Times New Roman', serif":"sansserif"===fontName||"arial"===fontName||"helvetica"===fontName?fontCanvas+"descartesJS_sansserif,Arial,Helvetica,Sans-serif":fontCanvas+"descartesJS_monospace,Courier,'Courier New',Monospace"};a.getTextWidth=function(c,b){a.ctx.font=b;return Math.round(a.ctx.measureText(c).width)};var e={ss_5:{a:5,d:3},ss_6:{a:5,d:3},ss_7:{a:6,d:3},ss_8:{a:7,
d:3},ss_9:{a:9,d:4},ss_10:{a:10,d:4},ss_11:{a:11,d:4},ss_12:{a:12,d:4},ss_13:{a:13,d:4},ss_14:{a:13,d:4},ss_15:{a:14,d:4},ss_16:{a:15,d:4},ss_17:{a:15,d:5},ss_18:{a:16,d:5},ss_19:{a:18,d:5},ss_20:{a:19,d:5},ss_21:{a:19,d:6},ss_22:{a:20,d:6},ss_23:{a:21,d:6},ss_24:{a:21,d:7},ss_25:{a:23,d:6},ss_26:{a:25,d:7},ss_27:{a:26,d:7},ss_28:{a:26,d:7},ss_29:{a:27,d:7},ss_30:{a:28,d:8},ss_31:{a:28,d:8},ss_32:{a:29,d:8},ss_33:{a:31,d:8},ss_34:{a:32,d:8},ss_35:{a:32,d:9},ss_36:{a:33,d:9},ss_37:{a:34,d:10},ss_38:{a:34,
d:10},ss_39:{a:35,d:10},ss_40:{a:36,d:10},ss_41:{a:38,d:11},ss_42:{a:38,d:11},ss_43:{a:39,d:11},ss_44:{a:40,d:11},ss_45:{a:40,d:11},ss_46:{a:42,d:11},ss_47:{a:43,d:11},ss_48:{a:45,d:11},ss_49:{a:45,d:13},ss_50:{a:46,d:13},ss_51:{a:47,d:13},ss_52:{a:48,d:13},ss_53:{a:48,d:14},ss_54:{a:49,d:14},ss_55:{a:51,d:14},ss_56:{a:52,d:14},ss_57:{a:52,d:14},ss_58:{a:53,d:14},ss_59:{a:53,d:14},ss_60:{a:54,d:14},ss_61:{a:55,d:15},ss_62:{a:56,d:15},ss_63:{a:57,d:15},ss_64:{a:58,d:15},ss_65:{a:59,d:16},ss_66:{a:60,
d:16},ss_67:{a:60,d:16},ss_68:{a:61,d:16},ss_69:{a:62,d:17},ss_70:{a:63,d:17},ss_71:{a:64,d:17},ss_72:{a:65,d:17},ss_73:{a:66,d:17},ss_74:{a:66,d:17},ss_75:{a:67,d:17},ss_76:{a:68,d:17},ss_77:{a:70,d:18},ss_78:{a:70,d:18},ss_79:{a:71,d:18},ss_80:{a:72,d:18},ss_81:{a:73,d:20},ss_82:{a:73,d:20},ss_83:{a:74,d:20},ss_84:{a:75,d:20},ss_85:{a:77,d:20},ss_86:{a:77,d:20},ss_87:{a:78,d:20},ss_88:{a:79,d:20},ss_89:{a:80,d:20},ss_90:{a:80,d:20},ss_91:{a:81,d:20},ss_92:{a:83,d:20},ss_93:{a:84,d:20},ss_94:{a:84,
d:20},ss_95:{a:85,d:20},ss_96:{a:86,d:20},ss_97:{a:87,d:20},ss_98:{a:87,d:20},ss_99:{a:89,d:20},s_5:{a:4,d:4},s_6:{a:5,d:4},s_7:{a:6,d:4},s_8:{a:7,d:4},s_9:{a:9,d:4},s_10:{a:10,d:3},s_11:{a:11,d:4},s_12:{a:12,d:4},s_13:{a:12,d:4},s_14:{a:13,d:4},s_15:{a:13,d:5},s_16:{a:15,d:5},s_17:{a:15,d:5},s_18:{a:16,d:5},s_19:{a:16,d:6},s_20:{a:17,d:6},s_21:{a:18,d:6},s_22:{a:20,d:6},s_23:{a:20,d:7},s_24:{a:21,d:7},s_25:{a:23,d:7},s_26:{a:23,d:7},s_27:{a:24,d:8},s_28:{a:26,d:8},s_29:{a:26,d:8},s_30:{a:27,d:8},
s_31:{a:28,d:9},s_32:{a:28,d:9},s_33:{a:29,d:9},s_34:{a:31,d:9},s_35:{a:32,d:10},s_36:{a:32,d:10},s_37:{a:33,d:10},s_38:{a:34,d:10},s_39:{a:34,d:12},s_40:{a:35,d:12},s_41:{a:37,d:12},s_42:{a:38,d:12},s_43:{a:39,d:12},s_44:{a:40,d:12},s_45:{a:41,d:13},s_46:{a:41,d:13},s_47:{a:42,d:13},s_48:{a:43,d:13},s_49:{a:44,d:15},s_50:{a:45,d:15},s_51:{a:45,d:15},s_52:{a:46,d:15},s_53:{a:48,d:15},s_54:{a:48,d:15},s_55:{a:49,d:15},s_56:{a:50,d:15},s_57:{a:51,d:15},s_58:{a:52,d:15},s_59:{a:53,d:15},s_60:{a:54,d:15},
s_61:{a:54,d:17},s_62:{a:55,d:17},s_63:{a:56,d:17},s_64:{a:57,d:17},s_65:{a:58,d:17},s_66:{a:59,d:17},s_67:{a:60,d:17},s_68:{a:61,d:17},s_69:{a:61,d:18},s_70:{a:62,d:18},s_71:{a:63,d:18},s_72:{a:64,d:18},s_73:{a:65,d:19},s_74:{a:66,d:19},s_75:{a:67,d:19},s_76:{a:67,d:19},s_77:{a:68,d:20},s_78:{a:70,d:20},s_79:{a:71,d:20},s_80:{a:71,d:20},s_81:{a:72,d:21},s_82:{a:73,d:21},s_83:{a:73,d:21},s_84:{a:75,d:21},s_85:{a:76,d:21},s_86:{a:77,d:21},s_87:{a:77,d:21},s_88:{a:78,d:21},s_89:{a:79,d:21},s_90:{a:81,
d:21},s_91:{a:81,d:21},s_92:{a:82,d:21},s_93:{a:83,d:21},s_94:{a:83,d:21},s_95:{a:84,d:21},s_96:{a:86,d:21},s_97:{a:87,d:21},s_98:{a:87,d:21},s_99:{a:88,d:21},m_5:{a:4,d:3},m_6:{a:5,d:3},m_7:{a:6,d:3},m_8:{a:6,d:3},m_9:{a:9,d:4},m_10:{a:9,d:4},m_11:{a:10,d:5},m_12:{a:11,d:5},m_13:{a:11,d:6},m_14:{a:11,d:7},m_15:{a:12,d:6},m_16:{a:13,d:6},m_17:{a:14,d:7},m_18:{a:14,d:7},m_19:{a:15,d:7},m_20:{a:16,d:7},m_21:{a:16,d:8},m_22:{a:17,d:8},m_23:{a:17,d:9},m_24:{a:19,d:9},m_25:{a:21,d:9},m_26:{a:21,d:9},m_27:{a:22,
d:9},m_28:{a:22,d:10},m_29:{a:23,d:10},m_30:{a:24,d:10},m_31:{a:25,d:11},m_32:{a:26,d:11},m_33:{a:26,d:11},m_34:{a:27,d:11},m_35:{a:28,d:11},m_36:{a:28,d:12},m_37:{a:28,d:11},m_38:{a:30,d:11},m_39:{a:31,d:12},m_40:{a:31,d:12},m_41:{a:32,d:14},m_42:{a:32,d:14},m_43:{a:33,d:14},m_44:{a:34,d:14},m_45:{a:35,d:14},m_46:{a:36,d:14},m_47:{a:37,d:14},m_48:{a:37,d:14},m_49:{a:38,d:17},m_50:{a:38,d:17},m_51:{a:39,d:17},m_52:{a:41,d:17},m_53:{a:41,d:18},m_54:{a:42,d:18},m_55:{a:43,d:18},m_56:{a:43,d:18},m_57:{a:44,
d:19},m_58:{a:46,d:19},m_59:{a:46,d:19},m_60:{a:47,d:19},m_61:{a:47,d:21},m_62:{a:48,d:21},m_63:{a:49,d:21},m_64:{a:49,d:22},m_65:{a:51,d:21},m_66:{a:52,d:21},m_67:{a:52,d:21},m_68:{a:53,d:21},m_69:{a:53,d:22},m_70:{a:54,d:22},m_71:{a:55,d:22},m_72:{a:56,d:22},m_73:{a:57,d:23},m_74:{a:58,d:23},m_75:{a:58,d:23},m_76:{a:59,d:23},m_77:{a:59,d:24},m_78:{a:60,d:24},m_79:{a:62,d:24},m_80:{a:62,d:24},m_81:{a:63,d:25},m_82:{a:64,d:25},m_83:{a:64,d:25},m_84:{a:65,d:25},m_85:{a:65,d:25},m_86:{a:67,d:25},m_87:{a:68,
d:25},m_88:{a:68,d:25},m_89:{a:69,d:25},m_90:{a:70,d:25},m_91:{a:70,d:25},m_92:{a:71,d:25},m_93:{a:72,d:25},m_94:{a:73,d:25},m_95:{a:74,d:25},m_96:{a:74,d:25},m_97:{a:75,d:25},m_98:{a:76,d:25},m_99:{a:77,d:25}},g={};document.createElement("canvas");var c;a.getFontMetrics=function(a){if(g[a])return g[a];c=parseInt(a.match(/(\d+\.*)+px/)[0]);var b;a.match("sansserif")?b="ss_":a.match("serif")?b="s_":a.match("monospace")&&(b="m_");b=e[b+c];b={ascent:b.a,descent:b.d,h:b.a+b.d,baseline:b.a};return g[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};return a}(descartesJS||{}),descartesJS=function(a){function e(){var a,b,c,f,l,d,e,h,p;Number.prototype.originalToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(k){try{return this.originalToFixed(k)}catch(g){k=k?k:0;k=0>k?0:parseInt(k);a=this.toString();l=a.indexOf("e");if(-1!==l)if(d=a.split("e"),h="-"===d[0][0]?"-":"",e="-"===h?parseFloat(d[0].substring(1)).originalToFixed(11):
parseFloat(d[0]).originalToFixed(11),p=parseInt(d[1]),b=e.indexOf("."),0>b+p){b=0>b?1:b;var r=h+"0.",u;u=Math.abs(b+p);u=Array(u+1).join("0");a=r+u+e.replace(".","")}else e=e.replace(".",""),a=h+e+Array(p-e.length+2).join("0");b=a.indexOf(".");c="";if(-1===b)0<k&&(c="."),c+=Array(k+1).join("0"),a+=c;else if(f=a.length-b-1,f>=k)11>=k&&(a=parseFloat(a).originalToFixed(k)),a=0<k?a.substring(0,b+1+k):a.substring(0,b);else{r=0;for(k-=f;r<k;r++)c+="0";a+=c}return a}}}function g(a,b,f){a.fillStyle="#c0c0c0";
a.fillRect(b.offsetLeft,b.offsetTop,b.offsetWidth,b.offsetHeight);c(a,b,f.controls)}function c(a,b,c){for(var f,l=c.length-1;0<=l;l--)f=c[l],a.drawImage(f.getScreenshot(),b.offsetLeft+f.x,b.offsetTop+f.y)}if(a.loadLib)return a;var d=2*Math.PI,b=360/d,h=d/360,l=Math.floor,f,p,r,k,q,s,u;a.rangeOK=1;a.extend=function(a,b){if("function"==typeof Object.create)a.prototype=Object.create(b.prototype);else if(a.prototype.__proto__)a.prototype.__proto__=b.prototype;else for(var c in b.prototype)b.prototype.hasOwnProperty(c)&&
(a.prototype[c]=b.prototype[c]);a.prototype.uber=b.prototype};a.radToDeg=function(a){return a*b};a.degToRad=function(a){return a*h};a.drawLine=function(a,b,c,f,d,e,h){a.lineWidth=h||1;a.strokeStyle=e||"black";e=a.lineWidth%2?.5:0;a.beginPath();a.moveTo(l(b)+e,l(c)+e);a.lineTo(l(f)+e,l(d)+e);a.stroke()};a.getColor=function(a,b){if("string"==typeof b)return b;f=a.evalExpression(b);p=l(255*f[0][0]);r=l(255*f[0][1]);k=l(255*f[0][2]);q=1-f[0][3];return"rgba("+p+","+r+","+k+","+q+")"};a.getFeatures=function(){a.hasJavaSupport=
navigator.javaEnabled();var b=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&window.hasOwnProperty("ontouchstart")||b.match("android")&&!0;a.hasTouchSupport=navigator.userAgent.toLowerCase().match("qt")?!1:a.hasTouchSupport;a.isIOS=!(!navigator.userAgent.match(/iPad/i)&&!navigator.userAgent.match(/iPhone/i));b=document.createElement("canvas");a.hasCanvasSupport=b.getContext&&b.getContext("2d");a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"),
a.devicePixelRatio=window.devicePixelRatio||1,a.backingStoreRatio=a.ctx.webkitBackingStorePixelRatio||a.ctx.mozBackingStorePixelRatio||a.ctx.msBackingStorePixelRatio||a.ctx.oBackingStorePixelRatio||a.ctx.backingStorePixelRatio||1,a._ratio=a.devicePixelRatio/a.backingStoreRatio);e()};a.removeNeedlessDecimals=function(a){var b,c;if("string"==typeof a&&(b=a.indexOf("."),-1!=b)){c=a.substring(b);if(0==parseFloat(c))return a.substring(0,b);for(var f=c.length;0<f;f--)if(0!=c.charAt(f))return a.substring(0,
b+f+1)}return a};a.returnValue=function(a){return"number"===typeof a?parseFloat(a.toFixed(11)):a};a.whichButton=function(a){return null!==a.which?2>a.which?"L":2===a.which?"M":"R":2>a.button?"L":4===a.button?"M":"R"};a.getCursorPosition=function(a){a.touches?(a=a.touches[0],s=a.pageX,u=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(s=a.pageX,u=a.pageY):(s=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,u=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:s,
y:u}};a.getScreenshot=function(){var b=a.apps[0],f,l=document.createElement("canvas"),d=new Image;if(b){l.setAttribute("width",b.width);l.setAttribute("height",b.height);for(var e=l.getContext("2d"),h=0,k=b.spaces.length;h<k;h++)f=b.spaces[h],"R2"===f.type&&(e.drawImage(f.backgroundCanvas,f.x,f.y),e.drawImage(f.canvas,f.x,f.y),c(e,f.container,f.ctrs));0<b.northSpace.controls.length&&g(e,b.northSpace.container,b.northSpace);0<b.southSpace.controls.length&&g(e,b.southSpace.container,b.southSpace);0<
b.eastSpace.controls.length&&g(e,b.eastSpace.container,b.eastSpace);0<b.westSpace.controls.length&&g(e,b.westSpace.container,b.westSpace);d.src=l.toDataURL("image/png")}return d};a.showAbout=function(){var b;b=a.creativeCommonsLicense?"<html>\n<head>\n<style>\nbody{ text-align:center; }\niframe{ width:650px; height:73px; overflow:hidden; border:1px solid black; }\ndt{ font-weight:bold; margin-top:10px; }\n</style>\n</head>\n<body>\n<iframe src='http://arquimedes.matem.unam.mx/Descartes5/creditos/bannerPatrocinadores.html'></iframe>\n<h2> <a href='http://proyectodescartes.org/' target='_blank'>ProyectoDescartes.org</a> <br> <a href='http://descartesjs.org' target='_blank'>DescartesJS.org</a> </h2>\n<dl>\n<dt> Dise&ntilde;o funcional:</dt>\n<dd>\n<nobr>Jos&eacute; Luis Abreu Leon,</nobr>\n<nobr>Jos&eacute; R. Galo Sanchez,</nobr>\n<nobr>Juan Madrigal Muga</nobr>\n</dd>\n<dt>Autores del software:</dt>\n<dd>\n<nobr>Jos&eacute; Luis Abreu Leon,</nobr>\n<nobr>Marta Oliver&oacute; Serrat,</nobr>\n<nobr>Oscar Escamilla Gonz&aacute;lez,</nobr>\n<nobr>Joel Espinosa Longi</nobr>\n</dd>\n</dl>\n<p>\nEl software en Java est&aacute; bajo la licencia\n<a href='https://joinup.ec.europa.eu/software/page/eupl/licence-eupl'>EUPL v.1.1 </a>\n<br>\nEl software en JavaScript est&aacute; bajo licencia\n<a href='http://www.gnu.org/licenses/lgpl.html'>LGPL</a>\n</p>\n<p>\nLa documentaci&oacute;n y el c&oacute;digo fuente se encuentran en :\n<br>\n<a href='http://arquimedes.matem.unam.mx/Descartes5/'>http://arquimedes.matem.unam.mx/Descartes5/</a>\n</p>\n<p>\nEste objeto, creado con Descartes, est&aacute; licenciado\npor sus autores como\n<a href='http://creativecommons.org/licenses/by-nc-sa/2.5/es/'><nobr>Creative Commons</nobr></a>\n<br>\n<a href='http://creativecommons.org/licenses/by-nc-sa/2.5/es/'><img src='http://i.creativecommons.org/l/by-nc-sa/3.0/es/88x31.png'></a>\n</p></body> </html>":
"<html>\n<head>\n<style>\nbody{ text-align:center; }\niframe{ width:650px; height:73px; overflow:hidden; border:1px solid black; }\ndt{ font-weight:bold; margin-top:10px; }\n</style>\n</head>\n<body>\n<iframe src='http://arquimedes.matem.unam.mx/Descartes5/creditos/bannerPatrocinadores.html'></iframe>\n<h2> <a href='http://proyectodescartes.org/' target='_blank'>ProyectoDescartes.org</a> <br> <a href='http://descartesjs.org' target='_blank'>DescartesJS.org</a> </h2>\n<dl>\n<dt> Dise&ntilde;o funcional:</dt>\n<dd>\n<nobr>Jos&eacute; Luis Abreu Leon,</nobr>\n<nobr>Jos&eacute; R. Galo Sanchez,</nobr>\n<nobr>Juan Madrigal Muga</nobr>\n</dd>\n<dt>Autores del software:</dt>\n<dd>\n<nobr>Jos&eacute; Luis Abreu Leon,</nobr>\n<nobr>Marta Oliver&oacute; Serrat,</nobr>\n<nobr>Oscar Escamilla Gonz&aacute;lez,</nobr>\n<nobr>Joel Espinosa Longi</nobr>\n</dd>\n</dl>\n<p>\nEl software en Java est&aacute; bajo la licencia\n<a href='https://joinup.ec.europa.eu/software/page/eupl/licence-eupl'>EUPL v.1.1 </a>\n<br>\nEl software en JavaScript est&aacute; bajo licencia\n<a href='http://www.gnu.org/licenses/lgpl.html'>LGPL</a>\n</p>\n<p>\nLa documentaci&oacute;n y el c&oacute;digo fuente se encuentran en :\n<br>\n<a href='http://arquimedes.matem.unam.mx/Descartes5/'>http://arquimedes.matem.unam.mx/Descartes5/</a>\n</p>\n</body> </html>";
var c=window.open("","creditos","width=700,height=500,titlebar=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0");c.document.write(b);c.document.close()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g;a._externalFilesContent={};a.openExternalFile=function(c){if(a._externalFilesContent[c])return a._externalFilesContent[c];e=null;var d=!1;if(window.XMLHttpRequest)try{d=new XMLHttpRequest}catch(b){d=!1}else if(window.ActiveXObject)try{d=new ActiveXObject("Msxml2.XMLHTTP")}catch(h){try{d=
new ActiveXObject("Microsoft.XMLHTTP")}catch(l){d=!1}}g=d;g.open("GET",c,!1);try{g.send(null),e=g.responseText,e.match(String.fromCharCode(65533))&&(g.open("GET",c,!1),g.overrideMimeType("text/plain; charset=ISO-8859-1"),g.send(null),e=g.responseText)}catch(f){console.log("Error to load the file :",c),e=null}return e};a.addExternalFileContent=function(c,d){a._externalFilesContent[c]=d};return a}(descartesJS||{}),descartesJS=function(a){function e(a){n=a.indexOf("--radial--");-1!=n&&(a=a.substring(0,
n));b=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};b[0]==b[b.length-1]&&"'"==b[0]&&(a.ignoreCaps=!0,b=b.substring(1,b.length-1),"`"==b[0]&&"\u00b4"==b[b.length-1]&&(a.ignoreAcents=!0,b=b.substring(1,b.length-1)));"`"==b[0]&&"\u00b4"==b[b.length-1]&&(a.ignoreAcents=!0,b=b.substring(1,b.length-1),b[0]==b[b.length-1]&&"'"==b[0]&&(a.ignoreCaps=!0,b=b.substring(1,b.length-1)));"*"===b.charAt(0)&&"*"!==b.charAt(b.length-1)?b=b.substring(1)+"$":"*"!==b.charAt(0)&&"*"===b.charAt(b.length-1)?b="^"+
b.substring(0,b.length-1):"*"!==b.charAt(0)&&"*"!==b.charAt(b.length-1)?b="^"+b+"$":"*"===b.charAt(0)&&"*"===b.charAt(b.length-1)&&(b=b.substring(1,b.length-1));b=b.replace(/\?/g,"[\\S\\s]{1}");a.regExp=b;return a}function g(a,c){b=(a||"").trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=b.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:c.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),
expr:c.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function c(a,b,c){b=parseFloat(b);p=a.expr[0];r=a.expr[1];k=c.evalExpression(p.expr);q=c.evalExpression(r.expr);s="("==p.type;u="["==p.type;m=")"==r.type;v="]"==r.type;return(s&&b>k||u&&b>=k)&&(m&&b<q||v&&b<=q)?1:0}function d(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 b,h,l,f,p,r,k,q,s,u,m,v,n;a.buildRegularExpresionsPatterns=function(a,c){a=a||"";"("===a.charAt(0)&&")"===a.charAt(a.length-1)&&-1===a.indexOf(",")&&(a=a.substring(1,a.length-1));a=a.replace(/&squot;/g,"'").replace(/&amp;/g,"&").split("|");for(var f=0,d=a.length;f<d;f++){h=a[f].split("&");l=[];for(var m=0,k=h.length;m<k;m++)b=h[m],-1===b.indexOf(",")||"("!==b.charAt(0)&&"["!==
b.charAt(0)||")"!==b.charAt(b.length-1)&&"]"!==b.charAt(b.length-1)?l.push(e(b)):l.push(g(b,c));a[f]=l}return a};a.escorrecto=function(b,l,e,m){e=e||a.externalEvaluator;m=m||a.buildRegularExpresionsPatterns(b,e);l=d(l);b=0;for(var k=m.length;b<k;b++){h=m[b];f=!0;for(var p=0,g=h.length;p<g;p++)f=h[p].regExp?f&&!!l.match(new RegExp(d(h[p].regExp),"i")):f&&c(h[p],l,e);if(f)return 1}return 0};a.esCorrecto=function(l,e,m,k){m=m||a.externalEvaluator;k=k||a.buildRegularExpresionsPatterns(l,m);l=0;for(var p=
k.length;l<p;l++){h=k[l];f=!0;for(var g=0,n=h.length;g<n;g++)(b=h[g].regExp)?(h[g].ignoreAcents&&(e=d(e),b=d(b)),h[g].ignoreCaps&&(e=e.toLowerCase(),b=d(b).toLowerCase()),f=f&&!!e.match(b)):f=f=f&&c(h[g],e,m);if(f)return 1}return 0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.getCreativeCommonsLicenseImage=function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAABHNCSVQICAgIfAhkiAAACpVJREFUaIHtWm1sU9cZfu61iUYnPP/bJgdhhDbFkVYcCrR0tLHXrVNL01wvgUJDh820tivrkpQQtpEvA4HGhDoe/dCmNfbaVa1WKszX2oUO3xC0OHESm9Hi/FhloyQq1aY5OGgq8ce7H9f3xI7txKFsdKyPdHSPz8dzz33Oe77eY46IVBzHXcUXuOkgIo4DQABwuucUeJ4Hz/NQKBTgeQUUPA9ekXryPDiOB89x4DgO4DiZBQQCJQlJSiKZlEIikZCeyQQSiSSSyQTLS1KSlSciuTEsfjtgY+UmAAAHgGRxFQqFFHjFTFyhkPJ4RUpkDhzHp+ubEiclbFISM5FIhfR4IlPkZDLJhE0X+nbBxspNUALIFFehhDLjKYWTx0/B4/FgcHAQU9GpDKIlqiVYu3YtjN8xouLRR5BIKsDzcalDEjw4cJD6cgaUJGkkANIY4iRxR3x+uN9xIxgMZpTX6XQQqgSsWlNW0Md9Xng4APSns+9BqVQyUZVKpRQUSvSK52B73oaJiYmCGqTRaND4i0aUl9+PeCKBRCKOeDwVEnHE4wlm4emW/PHExzjS9SJGg6MAAIPBAL1eDwAIBAIQRREAUKIrwY7aHfja17+a8/1XPv4ELzle+lzwbKzcJAn8fu8ZKBXKGWGVi7BIqURrcxvcx9ysglqthiAI0Gq1KC8vBwD09vYiHA7D7XZjcnKSlRVMAhoad2LxHYsRj8cRi8cRj8cQj8czpwxK4mrkKn769LOIRqMQBAF2ux1arTajseFwGPX19XC73VCpVGi3tWd91LXoNdTuqPvc8MjzMJ3tO0t9/eeo39dPQwEfXfggQIJJIEiDl9RqNbW1tVEkEqG54HQ6Sa1Ws3oluhI6399HQ4Eh8g71U1//OfL0naUzYg+99+d36XTPKTrx7nHS6XQEgMxmcwafzDP7HTL328f/kBFKdCU5eRx2Oz3+2ObPxDM2Nkbe/n7y9vfT2NhYQTwAiAcARWoOVioUUCoyLVev18Pv96O1tRVqtTprGKTDbDYjFAqxoTQaHEWn7XDGXM6zHYm0G/F5fQgGgxAEAY27ds3JL79DEASMBkcx4vOz9BGfH6PBUawqK8O996xj6b/q6sLzNhtOnj6N3Q27MD4+XhBPent+/9prMKy/DzWbt6Bm8xYY1t+HMz09c/Kkg/q8feQd8tLIhWFyHHEwy9Hr9fNabS5EIhHS6/WMx/Gig0b+OkIDw1467+0jz3nJit99/4+kK5WsNxQKFcwfCoUIAOl0OmYt8igo+cY3acUyLZV/ez09/eMnCQC1tbXRwQMHCQAdffvtgnjk9nj7+yW+u9fRj7ZZqHFnA61YpqUVy7TksNvz8uSwYMmKbc/bAEjzrdPpnNdqc0GtVsPj8bC6toO21F46ZcFcak/N8wheCsJgMGTNcRaLhVm5xWLJyNNqtTAYDBkrezAo8VRUVGDjpk0YHx/HmZ4erFimxb+mrmHrE1tx6cMPUVVdXRCPVqtFNBpF0H8RAFAp/AC/dXWjo/MQ9rQ0AwBc3c68PDJ4AKlhK23F5N1CXV0dG+o3ArVaDbvdDgCYmJjAyROn2IFFEplj27Rc73G5XDnjMnLV0ev1sB3uxEFbB954601UVVfjo8th2A53YunSpXB1OxG8dKkgHhntL0gG95vfvcrSvvfggwCAaDSKT65cycsDpASWrcnj8QCQxKmtrWWFRFGEyWSC0WiE0WiE1WrNm9fV1cXyzGYzs2LPWU+a9XLg+BmB/xO4+5570NF5CGNjY2jc2YCyb92Jd44eRcXDG1CzeQubQ+eCSqWCw+HAHaoleOWVV3KW+fTT63NySAcNjgPPcRgcHAQACILAhBFFEUajMaOSKIoQRRG1tbUwmUxZeRcuXIDT6WRcLpcLg4OD0gkwJawkriRwIBDIapjZbGaWazabs/Jz1ZmdFo1GcaanBx2dh2C+ZEHFwxsAAANeLwa8XhQXF4NbpJyTZ5FSicaGBtyxeDFLG/B6WXyZdlne9gDMgqUPlk9oK1euZAXq6+sBSPNMKBSCx+OBVqvFtm3bmCXr9XqEQiEcO3YsY48MgMWnolPSe8ClPYHS0lKIoohwOJzRMLmDZscBaQ8qiiJ0Oh1L0+l0WTw/efIptO/dh1V3rkTN5i346HIYVdXV6Og8hJqtWwviGR8fR1tLKx5/bDPa9+5D+959aGlqAgDs2r07b3syBAaHjOGaPp/IPWM2m9lkHgqFYDabWZ58+BAEgeXJSF+8JKPNPDZvfExadOSOLARyWaFKYGlyPJ2no/MQLNu348o//o6/hUJw2O3Y09KMqupqWPfvQ9ma1fPyWLZvh2X7dgCAs7sbzu5uXP/0OjZUPIItNY/nbY+M7PHxX8a69eugK9XB7XbDYrFkWetsyKenEl1Jhh9g1ZoylOhKMniKi4uxp6UZX1q8GCPDw/hZXd0N8expacb3H3oIly+HAUijTldaOiePDMmCKdOLlT6fyNbscrkwOTmJQCCA5cuXw2q1sjz5mJyeJyN9yEpnM3l7PIPmtmaoVCq4XC6YTCZWh9K8bOFwGCaTCV1dXVCpVNhRuyPrY3b/sjEnz85dDXjjrTc/E8/qNatRVV2Nqupq6EpLC+IBUs4e38ggioqKsP7e+zAVnYLZbGaW5Ha7sxYyQJoyKisr8+bJ9evr69HV1YUlqiU4/5c+TE9PYzo2jVg8hlgsLjmDEnFE/jmJA9YDbC+p1+uh1+uhVqshiiLr9PmcNNei19BxwMacNLeShzl7BoYHUFRUBGuLFe5jbqjVakQiEVZQFEU4HA7mzDEYDGhtbWUd4HA4WNn0PABYvnw5wuEwHvjuAzhs78T16WnEZgks+42TiSR8Az4cO3rr3Yw3g4cJ7B3qx6JFRTh/7jxqn5X2v3a7HXVpc9aNwOVysVPY/gP78fCGhzAdm8Z0LIZ4LIZYfJbAORzw/8vYWLlJmoPlKx2DsRwajQYAYLVas7ZOC8Hk5CRbXTUaTcoRn7rFSCaRTM3FlLpyul3BA0CSkkgkpHu0fe17AUgCmUymDB9voZicnITRaGR1G3/emHKwJ2ZETrsyYovsrMX2dgEBoKbWJvKNDFLgop+e+OETGR41v9+/IE9XuidNMAkUuOgn38gg7W3fy9L/j8LMj7rnamnI76PADTjcI5EItbW1ZTjc16xdQxc+CNBQwEdNrU23+kNvSWDX9jKaW5tQaRKgVCpx2HYYr7/2Ostb6JWRdV8b4vE4BgYG8cxTz2A+pE8P8smSiDJOmbN/5+PJV0d+R6GOpnxtWhDH7NDc2iRZ8kU/dbteJY1GU3CPaTQachxxUOCin4YCPnr51y8XXJeI5oynp83HM1/9QrhylVkoR5YFy6h7rhY1W2vYVY/o6cWJ4yfmvLZ/VHgUBkM5u9A8fvwE9lv3F9DHEnJZS3reQqyO47i8z4VgtrXOXoTn48srMACsuqsMza0tKF6qSbuNSHc3ImPfKv/xZGJ8HC902nGu99yCP+azTA35eABkCbxQsXN1UiEccwos4/7y+7GhYgPuWn0XvqJSpf46Jb9ZetHVaBTDQ8M4ffL0goVN/wjWsJtgwbl+L2T+nG9NuGkCf4EbB09EX77VjbhdQUTcvwFtwhQyXNo3TwAAAABJRU5ErkJggg==";
return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,g,c,d,b,h,l,f,p,r,k,q,s,u;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]){c=[];d=this.splitComa(a.substring(1,a.length-1));for(var l=0,e=d.length;l<e;l++)b=
parseInt(d[l],16),d[l]!=b.toString(16)&&d[l]!=="0"+b.toString(16)?("["===d[l].charAt(0)&&"]"===d[l].charAt(d[l].length-1)&&(d[l]=d[l].substring(1,d[l].length-1)),c.push(this.evaluator.parser.parse(d[l]))):c.push(this.evaluator.parser.parse((b/255).toString()));this.rExpr=c[0];this.gExpr=c[1];this.bExpr=c[2];this.aExpr=c[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){h=
[];for(var b=p=f=l=0,c=a.length;b<c;b++)r=a.charAt(b),"("===r?l++:")"===r?l--:"["===r?f++:"]"===r?f--:","===r&&0===l&&0===f&&(h.push(a.substring(p,b)),p=b+1);h.push(a.substring(p));return h};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){g=this.evaluator;this.r=e(255*g.evalExpression(this.rExpr));this.g=e(255*g.evalExpression(this.gExpr));this.b=e(255*g.evalExpression(this.bExpr));this.a=1-g.evalExpression(this.aExpr);return"rgba("+
this.r+","+this.g+","+this.b+","+this.a+")"};a.Color.prototype.borderColor=function(){return 380>this.r+this.g+this.b?"#ffffff":"#000000"};a.RGBAToHexColor=function(b){b=b.substring(5,b.length-1).split(",");k=parseInt(b[0]).toString(16);q=parseInt(b[1]).toString(16);s=parseInt(b[2]).toString(16);u=(255-parseInt(255*parseFloat(b[3]))).toString(16);k=1==k.length?"0"+k:k;q=1==q.length?"0"+q:q;s=1==s.length?"0"+s:s;u=1==u.length?"0"+u:u;return new a.Color(u+k+q+s)};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var e=document.head,g=document.createElement("meta");g.setAttribute("http-equiv","X-UA-Compatible");g.setAttribute("content","IE=edge,chrome=1");e.appendChild(g);g=document.createElement("meta");g.setAttribute("name","viewport");g.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");e.appendChild(g);g=document.createElement("meta");g.setAttribute("name","apple-mobile-web-app-capable");g.setAttribute("content","yes");e.appendChild(g);
g=document.createElement("meta");g.setAttribute("name","apple-mobile-web-app-status-bar-style");g.setAttribute("content","black-translucent");e.appendChild(g);(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="div.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 :#CACACA; position:absolute; overflow:hidden; top:0px; left:0px; }\ndiv.DescartesLoaderImage{ background-repeat:no-repeat; background-position:center; position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesLoaderBar{ position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesSpace2DCanvas, canvas.DescartesSpace3DCanvas, div.blocker{ position:absolute; overflow:hidden; left:0px; top:0px; }\ndiv.DescartesSpace2DContainer, div.DescartesSpace3DContainer{ position:absolute; overflow:hidden; line-height:0px; }\ncanvas.DescartesButton{ position:absolute; cursor:pointer; }\ndiv.DescartesButtonContainer{ position:absolute; background-repeat:no-repeat; }\ndiv.DescartesSpinnerContainer, div.DescartesTextFieldContainer, div.DescartesMenuContainer{ background:lightgray; position:absolute; overflow:hidden; }\ninput.DescartesSpinnerField, input.DescartesTextFieldField, input.DescartesMenuField, input.DescartesScrollbarField{ -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-family:descartesJS_sansserif,Arial,Helvetica,Sans-serif; padding:0px; border:solid #666 1px; position:absolute; top:0px; }\nlabel.DescartesSpinnerLabel, label.DescartesMenuLabel, label.DescartesScrollbarLabel, label.DescartesTextFieldLabel{ font-family:descartesJS_sansserif,Arial,Helvetica,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:descartesJS_sansserif,Arial,Helvetica,Sans-serif; padding-top:0px; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:white; position:absolute; left:0px; top:0px; }\ndiv.DescartesScrollbarContainer{ background:#eee; overflow:hidden; position:absolute; }\ndiv.DescartesEditorContainer{ font-family:descartesJS_sansserif,Arial,Helvetica,Sans-serif; position:fixed; left:0px; top:0px; width:100%; height:100%; background-color:#2e2e2e; z-index:10001; }\ndiv.DescartesEditorTabContainer{ width:100%; height:100%; position:absolute; padding:0px;  }\n.DescartesTabs{ height: 37px; }\n.DescartesTabs > ul{ font-size:18px; list-style:none; padding:0 1px 1px; margin-left:4px; text-align:center; }\n.DescartesTabs > ul > li{ margin-right:1px; padding:8px 8px; float:left; color:#fff; -webkit-user-select:none; -moz-user-select:none; user-select:none; border-radius:7px 7px 0px 0px; background:#0C91EC; background:-moz-linear-gradient(top, #0C91EC 0%, #257AB6 100%); background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#0C91EC), color-stop(100%,#257AB6)); }\n.DescartesTabs > ul > li:hover{ background:#fff; background:-moz-linear-gradient(top, #FFFFFF 0%, #F3F3F3 10%, #F3F3F3 50%, #FFFFFF 100%); background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#FFFFFF), color-stop(10%,#F3F3F3), color-stop(50%,#F3F3F3), color-stop(100%,#FFFFFF)); cursor:pointer; color:#000; }\n.DescartesTabs > ul > li.tabActiveHeader{ background:#fff; background:-moz-linear-gradient(top, #FFFFFF 0%, #F3F3F3 10%, #F3F3F3 50%, #FFFFFF 100%); background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#FFFFFF), color-stop(10%,#F3F3F3), color-stop(50%,#F3F3F3), color-stop(100%,#FFFFFF)); cursor:pointer; color:#000; }\n.DescartesTabscontent{ position:absolute; left:5px; right:5px; top:55px; bottom:45px; overflow:y-scroll; padding:10px 10px 25px; background:#000; background:-moz-linear-gradient(top, #FFFFFF 0%, #FFFFFF 90%, #e4e9ed 100%); background:-webkit-gradient(linear, left top, left bottom, color-stop(0%,#FFFFFF), color-stop(90%,#FFFFFF), color-stop(100%,#e4e9ed)); margin:0px; color:#000; background-color:#000; }\ndiv.DescartesConfigPanel{ position:absolute; left:10px; right:10px; top:10px; bottom:10px; overflow:y-scroll; border:solid 1px #000; border-radius:5px; font-size:18px; padding:10px; line-height:1.5em; overflow:auto; }\ndiv.DescartesLeftPanelClass{ position:absolute; left:10px; top:10px; bottom:10px; width:200px; background-color:; border:1px solid black; overflow:auto; }\ndiv.DescartesLeftPanelClass li:nth-child(odd){ background-color:#6495ED; }\ndiv.DescartesLeftPanelClass li:nth-child(even){ background-color:#ED6495; }\ndiv.DescartesLeftPanelClass > div > ul{ list-style:none; background:#bbb; padding:5px; }\ndiv.DescartesLeftPanelClass > div > ul > li{ padding:5px; -webkit-user-select:none; -moz-user-select:none; user-select:none; cursor:pointer; white-space: nowrap; overflow: hidden; }\ndiv.DescartesRightPanelClass{ position:absolute; left:220px; right: 10px; top:10px; bottom:10px; background-color:; border:1px solid black; overflow:auto; }\ndiv.DescartesLabelAndElementContainer{ padding:4px 8px; margin:4px; display:inline-block; background-color:lightgray; border-radius:3px; }\ndiv.DescartesLabelAndElementContainer > select{ font-family:Monospace; font-size:18px; }\ndiv.DescartesLabelAndElementContainer > input{ font-family:Monospace; font-size:18px; }\ndiv.DescarteslistContainer{ font-family:Arial,Helvetica,Sans-serif; font-size:20px; position:absolute; left:5px; right:5px; top:45px; bottom:45px; border-radius:5px; background-color:#DDD; overflow:auto; }\ndiv.DescarteslistContainer > ul{ margin:5px; padding:5px; padding-bottom:15px; list-style:none; }\ndiv.DescarteslistContainer > ul > li{ padding:7px; margin:1px; }\ndiv.DescarteslistContainer li:nth-child(odd){ background-color:#BBB; }\ndiv.DescarteslistContainer li:nth-child(even){ background-color:#999; }\ndiv.DescartesExtraInfo{ padding: 12px; }\nspan.DescartesSpanName{ background-color:lightblue; margin:5px; }\nspan.DescartesSpanValue{ background-color:#333; color:white; margin:0px; padding:5px; border-radius:3px; line-height:1.75em; }\nspan.DescartesSpanValue br{ display: none; }\nspan.DescartesSpanValue * { display: inline }\ndiv.Descartes_param_name{ background-color:#669; color:#ee5; margin-bottom:10px; }\n.DescartesToolbarPlace{ -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box; text-align:center; border-radius:4px 4px 4px 4px;  position:absolute; left:5px; right:5px; top:0px; height:40px; min-width:290px; background: #ccc; padding:4px; }\n.DescartesButtonsPlace{ -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box; text-align:center; border-radius:4px 4px 4px 4px;  position:absolute; left:5px; right:5px; bottom:0px; height:40px; min-width:290px; background: #ccc; padding:4px; }\ndiv.DescartesAddPanel{ position:absolute; top:10px; left:10px; width:350px; background-color:white; }\ndiv.DescarteslistContainer li.DescartesElementSelected{ border:1px solid black; background-color:#D66; }\ninput.DescartesEditorButton{ cursor:pointer; width:110px; height:30px; padding:5px 25px; margin:0px 2px; background:#257AB6; border:1px solid #fff; border-radius:7px; box-shadow: inset 0px 1px 0px #3e9cbf, 0px 2px 0px 0px #205c73, 0px 4px 5px #999; color:#fff; font-size:1em; }\ninput.DescartesEditorButton:hover, input.DescartesEditorButton:focus{ background-color:#0C91EC; box-shadow:0 0 1px rgba(0,0,0, .75); }\n";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sin,g=Math.floor,c=Math.random,d=Math.round,b=Math.abs,h=String.fromCharCode,l,f,p,r,k,q,s,u,m,v;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){l=[];for(var c=0;256>c;c++)l[c]=h(this.alfanum(g(b(7.5*(e(1*c-a)+e(1.4*c+a)+e(.6*c-a)+e(2.2*c+a))))));return l.join("")};a.Krypto.prototype.encode=function(a){f=g(31*c());this.key=this.getKey(f);r=h(this.alfanum(f));return r+this.encripta(a)};
a.Krypto.prototype.decode=function(a){f=this.numalfa(a.charCodeAt(0));this.key=this.getKey(f);return this.desencripta(a.substring(1))};a.Krypto.prototype.encripta=function(a){return this.bytesToString(this.encriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.encriptaAux=function(a){if(null==a||null==this.key)return null;q=Array(3*a.length);for(var b=0,f=a.length;b<f;b++)m=256*g(a[b]+128)+d(255*c())+65536*d(255*c()),v=g((m<<this.shift(b))/256),q[3*b]=this.alfanum(v%32),q[3*b+1]=this.alfanum(v/32%
32),q[3*b+2]=this.alfanum(v/1024%32);return q};a.Krypto.prototype.desencripta=function(a){return this.bytesToString(this.desencriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.desencriptaAux=function(a){if(null==a||null==this.key)return null;s=Array(a.length/3);for(var b=0,c=s.length;b<c;b++)v=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),m=g(256*v>>this.shift(b)),u=g(m/256)%256-128,0>u&&(u+=256),s[b]=u;return s};a.Krypto.prototype.alfanum=function(a){a=g(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){r=Array(a.length);for(var b=0,c=a.length;b<c;b++)r[b]=a.charCodeAt(b);return r};a.Krypto.prototype.bytesToString=function(a){for(var b=0,c=a.length;b<c;b++)a[b]=h(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){p=this.key.charCodeAt(a%this.key.length);r=this.numalfa(p);k=g(r/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;window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;window.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame;a.Animation=function(e,g){this.parent=e;var c=e.evaluator,d=c.parser,b=new a.Auxiliary(e);this.start=null;this.delay=g.delay?d.parse(g.delay):d.parse("60");this.loop=
g.loop?g.loop:!1;this.auto=void 0==g.auto?!0:g.auto;this.controls=g.controls;this.init=b.splitInstructions(d,g.init);this.doExpr=b.splitInstructions(d,g.doExpr);g.whileExpr&&(this.whileExpr=d.parse(g.whileExpr));var h=this,l,f,p=h.doExpr.length;this.animationExec=function(){for(f=0;f<p;f++)c.evalExpression(h.doExpr[f]);h.parent.update();h.playing&&(0<c.evalExpression(h.whileExpr)||h.loop)?(l=c.evalExpression(h.delay),window.requestAnimationFrame||(h.timer=setTimeout(h.animationExec,10>l?10:l))):(h.stop(),
h.parent.update())};this.playing=!1;this.auto&&this.play()};a.Animation.prototype.play=function(){var a=this;this.playing?this.stop():(this.reinit(),this.playing=!0,delay=this.parent.evaluator.evalExpression(this.delay),this.timer=window.requestAnimationFrame?requestAnimationFrame(function(g){a.step(g)}):setTimeout(this.animationExec,10>delay?10:delay))};a.Animation.prototype.stop=function(){this.playing=!1;window.requestAnimationFrame?window.cancelAnimationFrame(this.timer):clearInterval(this.timer)};
a.Animation.prototype.reinit=function(){for(var a=0,g=this.init.length;a<g;a++)this.parent.evaluator.evalExpression(this.init[a])};a.Animation.prototype.step=function(a){var g=this;null===g.start&&(g.start=a);delay=g.parent.evaluator.evalExpression(g.delay);delay=10>delay?10:delay;a-g.start>delay&&(g.animationExec(),g.start=null);g.playing&&(g.timer=requestAnimationFrame(function(a){g.step(a)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,g){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,g){a.Action.call(this,e,g);this.parameter=(g||"").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,g){a.Action.call(this,e,g);var c=this.evaluator,
d=c.parser;g=(g||"").replace(/&squot;/g,"'");g=g.replace(/;/g,"\\n");g=g.split("\\n")||[""];for(var b=[],h,l=0,f=g.length;l<f;l++)(h=d.parse(g[l],!0))&&b.push(h);f=b.length;this.execute=function(){for(l=0;l<f;l++)c.evalExpression(b[l])}};a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(e,g){a.Action.call(this,e,g);this.parameter=g;this.target="_blank";var c=this.parameter.indexOf("target");-1!=c&&(this.target=this.parameter.substring(c),
this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,c-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,g){a.Action.call(this,e,g);this.parameter=g;this.target="_blank";var c=this.parameter.indexOf("target");-1!=c&&(this.target=this.parameter.substring(c),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,c-1));"_blank"!==this.target&&"_parent"!==this.target&&"_self"!==this.target&&"_top"!==
this.target?this.actionExec=function(){window.parent.postMessage({type:"changeTarget",name:this.target,value:this.parameter},"*")}:"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),this.actionExec=function(){eval(this.parameter)}):("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,this.target,
"width="+this.parent.width+",height="+this.parent.height+",left="+(window.screen.width-this.parent.width)/2+", top="+(window.screen.height-this.parent.height)/2+"location=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0")})};a.extend(a.OpenScene,a.Action);a.OpenScene.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.About=function(e,g){a.Action.call(this,e,g);g||(this.urlAbout=window.location.href.substring(0,window.location.href.lastIndexOf("/")+
1)+g)};a.extend(a.About,a.Action);a.About.prototype.execute=function(){console.log("about");if(this.urlAbout)var a=window.open(this.urlAbout,"_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes");else a=window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes"),a.document.write("<hmtl><head><title>Cr\u00e9ditos</title></head><body><h1>Aqu\u00ed van los cr\u00e9ditos</h1></body></html>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.Config=function(e,g){a.Action.call(this,e,g)};a.extend(a.Config,a.Action);a.Config.prototype.execute=function(){this.parent.editor?this.parent.editor.show():window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'><script type='text/javascript' src='http://arquimedes.matem.unam.mx/Descartes5/lib/descartes-min.js'>\x3c/script>\n"+this.parent.applet.outerHTML.replace(/<applet/g,"<ajs").replace(/<\/applet/g,
"</ajs")+"</xmp>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Init=function(e,g){a.Action.call(this,e,g)};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,g){a.Action.call(this,e,g)};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,g){a.Action.call(this,e,g)};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,g){a.Action.call(this,e,g)};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(g,c){a.Action.call(this,g,c);c&&c.match(e)?this.filenameExpr=this.evaluator.parser.parse("'"+c.match(e)+"'"):this.filenameExpr=this.evaluator.parser.parse(c)};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,d){this.parent=
a;this.evaluator=this.parent.evaluator;this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var b in d)d.hasOwnProperty(b)&&(this[b]=d[b])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var e,g;a.Auxiliary.prototype.splitInstructions=function(a,d){g=[];d=d?d.split(";"):[""];for(var b=0,h=d.length;b<h;b++)(e=a.parse(d[b],!0))&&g.push(e);return g};a.Auxiliary.prototype.getPrivateVariables=function(a,d){g=[];d=d?d.split(/;|,/):[""];for(var b=0,
h=d.length;b<h;b++)(e=a.parse(d[b],!0))&&g.push(e);b=0;for(h=g.length;b<h;b++)g[b]="asign"===g[b].type?g[b].childs[0].value:"identifier"===g[b].type?g[b].value:"";return g};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,
g){a.Auxiliary.call(this,e,g);var c=this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=c.parse(this.expresionString))&&c.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"),g=document.createElement("label");g.appendChild(document.createTextNode("___"+this.id+"=___"));var c=document.createElement("input");
c.value=this.expresionString;c.disabled=!this.editable;a.appendChild(g);a.appendChild(c);var d=this,b=d.evaluator.parser;c.onkeydown=function(a){13==a.keyCode&&(d.expresion=b.parse(this.value),b.setVariable(d.id,d.expresion),d.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,g){a.Auxiliary.call(this,e,g);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,g,c;a.Vector=function(c,b){e=c.evaluator;g=e.parser;this.size=g.parse("3");a.Auxiliary.call(this,c,b);this.expresion=this.expresion.split(";");this.parseFile=g.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var d=this.expresion;
e=this.evaluator;g=e.parser;this.oldFile=this.file;if(c=e.evalExpression(this.parseFile))this.file=c;var b;if(this.file){b=(vectorElement=document.getElementById(this.file))&&"descartes/vectorFile"==vectorElement.type?vectorElement.text:a.openExternalFile(this.file);if(null!=b){b=b.replace(/\r/g,"").split("\n");for(var h=[],l=0,f=b.length;l<f;l++)""!=b[l]&&h.push(b[l]);b=h}null==b||1==b.length&&""==b[0]?this.size=0:(d=b,this.size=null);null===this.size&&(this.size=g.parse(d.length+""))}b=[];l=0;for(f=
d.length;l<f;l++)(h=g.parse(d[l],!0))&&"asign"!=h.type&&(h=g.parse(this.id+"["+l+"]="+d[l],!0)),b.push(h);d=[];l=0;for(f=e.evalExpression(this.size);l<f;l++)d.push(0);e.vectors[this.id]=d;e.setVariable(this.id+".long",e.evalExpression(this.size));l=0;for(f=b.length;l<f;l++)e.evalExpression(b[l])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(e,g){var c=e.evaluator,d=c.parser;this.rows=d.parse("3");this.columns=d.parse("3");a.Auxiliary.call(this,e,g);this.expresion=
this.splitInstructions(d,this.expresion);var d=c.evalExpression(this.rows),b=c.evalExpression(this.columns),h=[];h.type="matrix";for(var l,f=0;f<b;f++){l=[];for(var p=0,r=d;p<r;p++)l.push(0);h[f]=l}c.matrices[this.id]=h;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,g=a.evalExpression(this.rows),c=a.evalExpression(this.columns);a.setVariable(this.id+".filas",g);a.setVariable(this.id+".columnas",c);var d=a.matrices[this.id];d.rows=g;d.cols=c;
g=0;for(c=this.expresion.length;g<c;g++)a.evalExpression(this.expresion[g])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(e,g){a.Auxiliary.call(this,e,g);var c=this.evaluator,d=c.parser,b=this.id.indexOf("(");this.name=this.id.substring(0,b);this.params=this.id.substring(b+1,this.id.indexOf(")"));this.domain=this.range?d.parse(this.range):d.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||
(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(d);this.expresion=d.parse(this.expresion);var h=this;this.functionExec=function(){this.iterations=0;if(h.numberOfParams<=arguments.length){for(var b=[],f=0,d=h.privateVars.length;f<d;f++)b.push(c.getVariable(h.privateVars[f])),c.setVariable(h.privateVars[f],0);for(var e=[],f=0,d=h.params.length;f<d;f++)e[f]=c.getVariable(h.params[f])||0,c.setVariable(h.params[f],arguments[f]);f=0;for(d=h.init.length;f<d;f++)c.evalExpression(h.init[f]);
do{f=0;for(d=h.doExpr.length;f<d;f++)c.evalExpression(h.doExpr[f]);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<c.evalExpression(h.whileExpr));var k=c.evalExpression(h.expresion);a.rangeOK=c.evalExpression(h.domain);f=0;for(d=h.params.length;f<d;f++)c.setVariable(h.params[f],e[f]);f=0;for(d=h.privateVars.length;f<d;f++)c.setVariable(h.privateVars[f],b[f]);return k}return 0};c.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,g){a.Auxiliary.call(this,e,g);var c=this.evaluator;this.parseExpressions(c.parser);this.algorithmExec=function(){for(var a=this.iterations=0,b=this.init.length;a<b;a++)c.evalExpression(this.init[a]);do{a=0;for(b=this.doExpr.length;a<b;a++)c.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<c.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,g){a.Auxiliary.call(this,e,g);var c=this.evaluator;this.condition=c.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&
(this.eventExec=function(){0<c.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<c.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<
c.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,g,c,d,b;a.Graphic=function(b,c){this.parent=b;this.evaluator=b.evaluator;var f=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=f.parse("1");this.abs_coord=!1;this.color=new a.Color("blue");2!==this.parent.version&&(this.color=new a.Color("20303a"),
this.parent.arquimedes&&(this.color=new a.Color("black")));this.trace="";this.expresion=f.parse("(0,0)");this.family="";this.family_interval=f.parse("[0,1]");this.family_steps=f.parse("8");this.editable=!1;this.font=5<=this.parent.version?"Monospaced,PLAIN,15":"Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=f.parse("2");for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");
this.trace&&(this.traceCtx=this.space.backgroundCanvas.getContext("2d"));this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/([\d\.]+)px/))?parseFloat(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;g=e.evalExpression(this.family_interval);this.familyInf=g[0][0];this.familySup=g[0][1];this.fSteps=
Math.round(e.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,b,f){e=this.evaluator;this.getFamilyValues();c=e.getVariable(this.family);if(0<=this.fSteps)for(var d=0,g=this.fSteps;d<=g;d++)e.setVariable(this.family,this.familyInf+d*this.family_sep),0<e.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,b,f));e.setVariable("_Text_H_",0);e.setVariable(this.family,c)};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,c,f,p,g,k,q,s,u,m,v){if("rtfNode"===c.type)a.fillStyle=g.getColor(),a.strokeStyle=g.getColor(),a.textBaseline="alphabetic",
c.draw(a,f,p+1,u,m,q,v,g.getColor());else for("simpleText"===c.type&&(c=c.toString(u,m).split("\\n")),f+=k.match("Arial")?-2:k.match("Times")?-2:0,e=this.evaluator,a.fillStyle=g.getColor(),a.font=k,a.textAlign=q,a.textBaseline=s,this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=3),b=1.2*this.fontSize||0,g=0,k=c.length;g<k;g++)d=c[g],this.border&&(a.lineJoin="round",a.strokeText(d,f,p+b*g)),a.fillText(d,f,p+b*g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.SimpleText=function(a,d){this.text=d=d.replace("&#x2013","\u2013").replace(/\&squot;/g,"'");this.textElements=[];this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var b="'",e=0,l=0,f=-1,p,g;e<d.length;)p=d.charAt(e),g=d.charAt(e-1),"["===p&&"\\"===g?(this.textElements.push(d.substring(l,e-1)+"["),this.textElementsMacros.push("'"+d.substring(l,e-1)+"['"),l=e+1):"]"===p&&"\\"===g?(this.textElements.push(d.substring(l,e-1)+"]"),this.textElementsMacros.push("'"+
d.substring(l,e-1)+"]'"),l=e+1):"["===p&&-1===f?(this.textElements.push(d.substring(l,e)),this.textElementsMacros.push("'"+d.substring(l,e)+"'"),l=e,f++):"["===p?f++:"]"===p&&0===f?(this.textElements.push(this.evaluator.parser.parse(d.substring(l,e+1))),this.textElementsMacros.push("["+d.substring(l,e+1)+"]"),l=e+1,f--):("]"==d.charAt(e)&&(f=0>f?f:f-1),b+=d.charAt(e)),e++;this.textElements.push(d.substring(l,e));this.textElementsMacros.push("'"+d.substring(l,e)+"'")};var e,g;a.SimpleText.prototype.toString=
function(c,d){e="";for(var b=0,h=this.textElements.length;b<h;b++)"string"===typeof this.textElements[b]?e+=this.textElements[b]:(g=this.evaluator.evalExpression(this.textElements[b])[0][0],""!==g&&("string"===typeof g?e+=g:(g=parseFloat(g),g=d?g.toFixed(c):a.removeNeedlessDecimals(g.toFixed(c)),e+=g.toString().replace(".",this.parent.decimal_symbol))));return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b,h,l,f,p,r,k,q,s,u,m,v,n,t,w,A,B,y,D,E,C,z,H;a._debug_vez=
0;a.Equation=function(b,c){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP="";a.Graphic.call(this,b,c);this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();q=new a.R2;s=new a.R2;u=new a.R2;n=new a.R2;m=new a.R2};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"===this.expresion.type){var b=this.expresion.childs[0],c=this.expresion.childs[1];"identifier"!=b.type||"y"!=
b.value||c.contains("y")?"identifier"!=c.type||"y"!=c.value||b.contains("y")?"identifier"!=b.type||"x"!=b.value||c.contains("x")?"identifier"!=c.type||"x"!=c.value||b.contains("x")||(this.of_y=!0,this.funExpr=c,this.drawAux=this.drawAuxFun):(this.funExpr=c,this.of_y=!0,this.drawAux=this.drawAuxFun):(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):(this.funExpr=c,this.of_y=!1,this.drawAux=this.drawAuxFun)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.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,l=this.fSteps;f<=l;f++)g.setVariable(this.family,this.familyInf+f*this.family_sep),this.update(),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,G,K){if(!(0>=this.evaluator.evalExpression(this.drawif))){var x,L,F;g=this.evaluator;c=g.parser;d=this.space;b=g.evalExpression(this.width);I.strokeStyle=this.color.getColor();I.lineWidth=b;h=c.getVariable("x");l=c.getVariable("y");f=d.w;p=d.h;r=f/9;3>r&&(r=3);k=p/7;3>k&&(k=3);e=[];q.set(0,0);s.set(0,0);u.set(0,0);var M=.25,N=8;this.abs_coord||(M/=d.scale,N/=d.scale);I.beginPath();for(H=parseInt(k/
2);H<p;H+=k)for(z=parseInt(r/2);z<f;z+=r){if(this.abs_coord){n.set(z,H);v=this.newt.findZero(n,M);if(null==v)continue;g.setVariable("x",v.x);g.setVariable("y",v.y);m.set(v.x,v.y)}else{n.set(d.getRelativeX(z),d.getRelativeY(H));v=this.newt.findZero(n,M);if(null==v)continue;g.setVariable("x",v.x);g.setVariable("y",v.y);m.set(d.getAbsoluteX(v.x),d.getAbsoluteY(v.y))}t=m.ix();w=m.iy();if(0<=t&&t<f&&0<=w&&w<p){if(e[t+w*d.w])continue;e[t+w*d.w]=!0}a.rangeOK&&(I.moveTo(t,w),I.lineTo(t,w));q.x=v.x;q.y=v.y;
s.x=v.x;s.y=v.y;A=this.newt.getUnitNormal();if(0!=A.x||0!=A.y)for(A.rotL90(),u.x=A.x,u.y=A.y,y=B=0,D=!1;2>y;)if(D&&(u.x=-A.x,u.y=-A.y,v.x=q.x,v.y=q.y,s.x=v.x,s.y=v.y,this.abs_coord?m.set(v.x,v.y):m.set(d.getAbsoluteX(v.x),d.getAbsoluteY(v.y)),t=m.ix(),w=m.iy(),D=!1,B=0),v.x+=N*u.x,v.y+=N*u.y,v=this.newt.findZero(v,M),null!=v){g.setVariable("x",v.x);g.setVariable("y",v.y);u.x=v.x-s.x;u.y=v.y-s.y;u.normalize();if(0==u.x&&0==u.y)break;s.x=v.x;s.y=v.y;this.abs_coord?m.set(v.x,v.y):m.set(d.getAbsoluteX(v.x),
d.getAbsoluteY(v.y));E=parseInt(m.ix());C=parseInt(m.iy());if(E!=t||C!=w)if(G=t,K=w,t=E,w=C,0<=t&&t<f&&0<=w&&w<p){B=0;x=e[t+w*d.w];e[t+w*d.w]=!0;for(var J=1;8>J;J++)L=G+Math.round((t-G)*J/8),F=K+Math.round((w-K)*J/8),0<=L&&L<f&&0<=F&&F<p&&(e[L+F*d.w]=!0);a.rangeOK&&(I.moveTo(G,K),I.lineTo(t,w));if(x)break}else D=!0,y++;else 4<++B&&(D=!0,y++)}}I.stroke()}};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,l,e,d){for(var m=this.evaluator.getVariable(c),k=d/2,h=0;1E-12<Math.abs(k);){var g=this.evaluator.getVariable(c),p=this.evaluator.getVariable(c)+
k;this.evaluator.setVariable(c,p);var r=!0,u=e;e=this.evaluator.evalExpression(this.funExpr);this.evaluator.setVariable(f,e);if(0<this.evaluator.evalExpression(b)){var n=new a.R2(Math.min(u,e),Math.max(u,e)),s=0,s=0<d?this.Singularity(Math.abs(k),c,l,g,u,p,e,n):this.Singularity(Math.abs(k),c,l,p,e,g,u,n);0<s&&(r=!1)}else r=!1;r?h+=k:this.evaluator.setVariable(c,g);k/=2}this.evaluator.setVariable(c,m);return new a.R2(h/Math.abs(d),e)};a.Equation.prototype.extrapolateOnSingularity=function(b,c,f,l,
e,d){l=this.evaluator.getVariable(c);for(var m=d/2,k=0,h=e;1E-12<Math.abs(m);){this.evaluator.setVariable(this.evaluator.getVariable(c)+m);var g=!0;0<this.evaluator.evalExpression(b)?(h=this.evaluator.evalExpression(this.funExpr),this.evaluator.setVariable(f,h),0>=this.evaluator.evalExpression(b)&&(g=!1)):g=!1;g?k+=m:this.evaluator.setVariable(this.evaluator.getVariable(c)-m);m/=2}if(0==k)for(m=d/2,k=d,h=e;1E-12<Math.abs(m);)this.evaluator.setVariable(this.evaluator.getVariable(c)-m),g=!0,0<this.evaluator.evalExpression(b)?
h=this.evaluator.evalExpression(this.funExpr):g=!1,g?k+=-m:this.evaluator.setVariable(this.evaluator.getVariable(c)+m),m/=2;this.evaluator.setVariable(l);return new a.R2(k/Math.abs(d),h)};a.Equation.prototype.Singularity=function(a,b,c,f,l,e,d,m){if(f>=e)return 2;var k=this.evaluator.getVariable(b),h=0;if(1E-12>Math.abs(e-f)||1E-8>Math.abs(e-f)&&Math.abs(d-l)>Math.abs(a))return this.evaluator.setVariable(b,k),1;var g=(f+e)/2;this.evaluator.setVariable(b,g);var p=this.evaluator.evalExpression(this.funExpr);
if(Math.abs(d-l)>a){this.evaluator.setVariable(b,f-1E-6);var u=this.evaluator.evalExpression(this.funExpr),u=(l-u)/1E-6;this.evaluator.setVariable(b,e+1E-6);var r=(this.evaluator.evalExpression(this.funExpr)-d)/1E-6,n=(d-l)/(e-f);if((10>Math.abs(r)||10>Math.abs(u))&&(0<=r&&0<=u||0>=r&&0>=u)&&8*Math.abs(r)<Math.abs(n))return this.evaluator.setVariable(b,k),2}m.x<=p&&p<=m.y||(this.evaluator.setVariable(b,g),m.x=Math.min(l,p),m.y=Math.max(l,p),f=this.Singularity(a/2,b,c,f,l,g,p,m),this.evaluator.setVariable(b,
e),m.x=Math.min(d,p),m.y=Math.max(d,p),a=this.Singularity(a/2,b,c,g,p,e,d,m),h=Math.max(f,a));this.evaluator.setVariable(b,k);return h};a.Equation.prototype.drawAuxFun=function(b,c,f){h=this.evaluator.parser.getVariable("x");l=this.evaluator.parser.getVariable("y");a.rangeOK=1;c="x";f="y";this.of_y&&(c="y",f="x");var e=this.drawif,d=this.evaluator.evalExpression(this.width),m=!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(),g=0,p=0,u=0,r=1/this.space.scale,
n=r*(this.of_y?-this.space.h+(this.space.h/2+this.space.Oy):-(this.space.w/2+this.space.Ox)),g=0;this.abs_coord&&(n=0,r=1);for(var s=this.of_y?this.space.h:this.space.w;p<s;){var q=!0,t=0;this.evaluator.setVariable(c,n);var w=this.evaluator.evalExpression(this.funExpr);if(isNaN(w))q=!1;else{this.evaluator.setVariable(f,w);if(0<this.evaluator.evalExpression(this.drawif)&&a.rangeOK){if(m){var t=Math.min(g,w),v=Math.max(g,w),v=new a.R2(t,v),t=this.Singularity(r,c,0,n-r,g,n,w,v);0===t?(g<=w?(g=v.x,w=
v.y):(w=v.x,g=v.y),t=this.of_y?this.XX(d,g,this.abs_coord):this.YY(d,g,this.abs_coord),g=this.abs_coord?Math.round(w):this.of_y?this.XX(d,w,this.abs_coord):this.YY(d,w,this.abs_coord),this.fillM&&g>k&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(k+1,this.space.h-p+.5),b.lineTo(g,this.space.h-p+.5)):(b.moveTo(p+.5,k+1),b.lineTo(p+.5,g)),b.stroke()),this.fillP&&g<k&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),this.of_y?(b.moveTo(k-1,this.space.h-
p+.5),b.lineTo(g,this.space.h-p+.5)):(b.moveTo(p+.5,k-1),b.lineTo(p+.5,g)),b.stroke()),b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(t+.5,this.space.h-u),b.lineTo(g+.5,this.space.h-p)):(b.moveTo(u+.5,t),b.lineTo(p+.5,g)),b.stroke()):(1===t&&(this.evaluator.setVariable(c,n-r),u=this.extrapolate(e,c,f,0,g,r),this.YY(d,u.y,this.abs_coord),this.evaluator.setVariable(c,n),u=this.extrapolate(e,c,f,0,w,-r),this.YY(d,u.y,this.abs_coord)),this.YY(d,w,this.abs_coord))}else u=
this.extrapolateOnSingularity(e,c,f,0,w,-r),this.YY(d,u.y,this.abs_coord),this.YY(d,w,this.abs_coord);g=w}else q=!1;m&&!q&&(this.evaluator.setVariable(c,n-r),this.evaluator.setVariable(f,g),u=this.extrapolate(e,c,f,0,g,r),this.YY(d,u.y,this.abs_coord),this.evaluator.setVariable(c,n))}m=q;n+=r;u=p++}this.evaluator.parser.setVariable("x",h);this.evaluator.parser.setVariable("y",l)};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 g,c,d,b,h,l,f,p,r,k,q;a.Curve.prototype.update=function(){g=this.evaluator;c=g.evalExpression(this.parameter_interval);this.paraInf=c[0][0];this.paraSup=c[0][1];this.pSteps=g.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(c,u,m){g=this.evaluator;d=this.space;b=e(g.evalExpression(this.width));c.lineWidth=0<b?b:1E-6;c.lineCap="round";c.lineJoin="round";c.strokeStyle=m.getColor();h=g.getVariable(this.parameter);c.beginPath();g.setVariable(this.parameter,this.paraInf);l=g.evalExpression(this.expresion);this.exprX=this.abs_coord?e(l[0][0]):e(d.getAbsoluteX(l[0][0]));this.exprY=this.abs_coord?e(l[0][1]):
e(d.getAbsoluteY(l[0][1]));this.rotateExp&&(f=a.degToRad(g.evalExpression(this.rotateExp)),p=Math.cos(f),r=Math.sin(f),k=this.exprX*p-this.exprY*r,q=this.exprX*r+this.exprY*p,this.exprX=k,this.exprY=q);c.moveTo(this.exprX+.5,this.exprY+.5);for(m=1;m<=this.pSteps;m++)g.setVariable(this.parameter,this.paraInf+m*this.paraSep),l=g.evalExpression(this.expresion),this.exprX=this.abs_coord?e(l[0][0]):e(d.getAbsoluteX(l[0][0])),this.exprY=this.abs_coord?e(l[0][1]):e(d.getAbsoluteY(l[0][1])),this.rotateExp&&
(k=this.exprX*p-this.exprY*r,q=this.exprX*r+this.exprY*p,this.exprX=k,this.exprY=q),c.lineTo(this.exprX+.5,this.exprY+.5);this.fill&&(c.fillStyle=u.getColor(),c.fill());c.stroke();g.setVariable(this.parameter,h)};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,g=Math.round,c,d,b,h,l,f,p,r,k,q,s,u,m,v;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(){c=this.evaluator;b=c.evalExpression(this.expresion);this.exprX=b[0][0];this.exprY=b[0][1];this.rotateExp&&(h=a.degToRad(c.evalExpression(this.rotateExp)),l=Math.cos(h),
f=Math.sin(h),p=this.exprX*l-this.exprY*f,r=this.exprX*f+this.exprY*l,this.exprX=p,this.exprY=r);s=c.evalExpression(this.range);this.rangeInf=s[0][0];this.rangeMax=s[0][1]};a.Sequence.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Sequence.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Sequence.prototype.drawAux=function(a,f){c=this.evaluator;d=this.space;m=u=Math.ceil(c.evalExpression(this.size)-.4);a.fillStyle=f.getColor();a.beginPath();
this.rangeInf>this.rangeMax&&(v=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=v);for(var l=c.getVariable("n"),h=this.rangeInf,p=this.rangeMax;h<=p;h++)c.setVariable("n",h),b=c.evalExpression(this.expresion),this.exprX=b[0][0],this.exprY=b[0][1],k=this.abs_coord?g(this.exprX):g(d.getAbsoluteX(this.exprX)),q=this.abs_coord?g(this.exprY):g(d.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(k,q,u,0,e,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,k+m,q-m,this.color,
this.font,"start","alphabetic",c.evalExpression(this.decimals),this.fixed,!0);c.setVariable("n",l)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2*Math.PI,g=Math.round,c,d,b,h,l,f,p,r,k,q,s,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(){c=this.evaluator;b=c.evalExpression(this.expresion);this.exprX=b[0][0];this.exprY=b[0][1];this.rotateExp&&(h=a.degToRad(c.evalExpression(this.rotateExp)),
l=Math.cos(h),f=Math.sin(h),p=this.exprX*l-this.exprY*f,r=this.exprX*f+this.exprY*l,this.exprX=p,this.exprY=r)};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,b){c=this.evaluator;d=this.space;s=g(c.evalExpression(this.size));u=s+1;a.fillStyle=b.getColor();k=this.abs_coord?g(this.exprX):g(d.getAbsoluteX(this.exprX));q=this.abs_coord?g(this.exprY):
g(d.getAbsoluteY(this.exprY));a.beginPath();a.arc(k,q,s,0,e,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,k+u+1,q-u,this.color,this.font,"start","alphabetic",c.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,g=2*Math.PI,c,d,b,h,l,f,p,r,k,q,s,u,m,v,n,t,w,A;a.Segment=function(b,c){this.width=b.evaluator.parser.parse("1");this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,c)};a.extend(a.Segment,
a.Graphic);a.Segment.prototype.update=function(){c=this.evaluator;b=c.evalExpression(this.expresion);this.endPoints=[];for(var d=0,e=b.length;d<e;d++)this.endPoints[d]={x:b[d][0],y:b[d][1]};if(this.rotateExp)for(h=a.degToRad(c.evalExpression(this.rotateExp)),l=Math.cos(h),f=Math.sin(h),d=0,e=this.endPoints.length;d<e;d++)p=this.endPoints[d].x*l-this.endPoints[d].y*f,r=this.endPoints[d].x*f+this.endPoints[d].y*l,this.endPoints[d].x=p,this.endPoints[d].y=r};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,b,f){c=this.evaluator;d=this.space;k=e(c.evalExpression(this.width));a.lineWidth=0<k?k:1E-6;m=c.evalExpression(this.size);0>m&&(m=0);a.fillStyle=b.getColor();a.strokeStyle=f.getColor();a.lineCap="round";q=10+a.lineWidth;v=0==a.lineWidth%2?0:.5;this.abs_coord?(n=e(this.endPoints[0].x),t=e(this.endPoints[0].y),w=e(this.endPoints[1].x),A=e(this.endPoints[1].y)):
(n=e(d.getAbsoluteX(this.endPoints[0].x)),t=e(d.getAbsoluteY(this.endPoints[0].y)),w=e(d.getAbsoluteX(this.endPoints[1].x)),A=e(d.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(n+v,t+v);a.lineTo(w+v,A+v);a.stroke();a.beginPath();a.arc(n,t,m,0,g,!0);a.arc(w,A,m,0,g,!0);a.fill();this.text!=[""]&&(s=parseInt((n+w)/2)-3,u=parseInt((t+A)/2)+3,this.uber.drawText.call(this,a,this.text,s+q,u-q,this.color,this.font,"start","alphabetic",c.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,g=Math.round,c,d,b,h,l,f,p,r,k,q,s,u,m,v,n,t,w,A;a.Arrow=function(b,c){this.width=b.evaluator.parser.parse("5");this.size=b.evaluator.parser.parse("2");this.spear=b.evaluator.parser.parse("8");this.arrow=new a.Color("ee0022");a.Graphic.call(this,b,c)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){c=this.evaluator;d=c.evalExpression(this.expresion);this.endPoints=[];for(var e=0,m=d.length;e<m;e++)this.endPoints[e]=
{x:d[e][0],y:d[e][1]};if(this.rotateExp)for(b=a.degToRad(c.evalExpression(this.rotateExp)),h=Math.cos(b),l=Math.sin(b),e=0,m=this.endPoints.length;e<m;e++)f=this.endPoints[e].x*h-this.endPoints[e].y*l,p=this.endPoints[e].x*l+this.endPoints[e].y*h,this.endPoints[e].x=f,this.endPoints[e].y=p};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,
f,l){c=this.evaluator;r=this.space;c.evalExpression(this.size);s=c.evalExpression(this.width);0>s&&(s=0);u=Math.ceil(s/2);m=r.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=f.getColor();b.strokeStyle=l.getColor();b.lineWidth=2;this.abs_coord?(n=g(this.endPoints[0].x),t=g(this.endPoints[0].y),w=g(this.endPoints[1].x),A=g(this.endPoints[1].y)):
(n=g(r.getAbsoluteX(this.endPoints[0].x)),t=g(r.getAbsoluteY(this.endPoints[0].y)),w=g(r.getAbsoluteX(this.endPoints[1].x)),A=g(r.getAbsoluteY(this.endPoints[1].y)));f=c.evalExpression(this.spear);0>f&&(f=0);b.save();b.translate(n,t,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-f-s),e(-u));b.lineTo(e(v-2*f),e(-f-u));b.lineTo(e(v),0);b.lineTo(e(v-2*f),e(f+u));b.lineTo(e(v-f-s),e(u));b.lineTo(-u,e(u));b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(k=parseInt((n+w)/2)-3,q=parseInt((t+A)/2)+3,this.uber.drawText.call(this,b,this.text,k,q,l,this.font,"start","alphabetic",c.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.round,g,c,d,b,h,l,f,p,r,k,q,s;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(){g=this.evaluator;d=g.evalExpression(this.expresion);for(var c=0,e=d.length;c<e;c++)this.endPoints[c]={x:d[c][0],y:d[c][1]};if(this.rotateExp)for(b=a.degToRad(g.evalExpression(this.rotateExp)),h=Math.cos(b),l=Math.sin(b),c=0,e=this.endPoints.length;c<e;c++)f=this.endPoints[c].x*h-this.endPoints[c].y*l,p=this.endPoints[c].x*l+this.endPoints[c].y*
h,this.endPoints[c].x=f,this.endPoints[c].y=p};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,f){g=this.evaluator;c=this.space;r=e(g.evalExpression(this.width));a.lineWidth=0<r?r:1E-6;a.strokeStyle=f.getColor();a.lineCap="round";a.lineJoin="round";k=0<r?.5:0;q=this.abs_coord?e(this.endPoints[0].x):e(c.getAbsoluteX(this.endPoints[0].x));
s=this.abs_coord?e(this.endPoints[0].y):e(c.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(q+k,s+k);f=1;for(var l=this.endPoints.length;f<l;f++)q=this.abs_coord?e(this.endPoints[f].x):e(c.getAbsoluteX(this.endPoints[f].x)),s=this.abs_coord?e(this.endPoints[f].y):e(c.getAbsoluteY(this.endPoints[f].y)),a.lineTo(q+k,s+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,g,c,d,b,h,l,f,p,r,k,q,
s,u,m,v,n,t,w,A,B,y;a.Arc=function(b,c){this.width=b.evaluator.parser.parse("1");this.fill="";this.center=b.evaluator.parser.parse("(0,0)");this.radius=b.evaluator.parser.parse("1");this.init="0";this.end="90";a.Graphic.call(this,b,c);this.init.match(/^_\(/)&&(this.initFlag=!0,this.init=this.init.substring(1));this.end.match(/^_\(/)&&(this.endFlag=!0,this.end=this.end.substring(1));this.initExpr=b.evaluator.parser.parse(this.init);this.endExpr=b.evaluator.parser.parse(this.end)};a.extend(a.Arc,a.Graphic);
a.Arc.prototype.update=function(){g=this.evaluator;c=g.evalExpression(this.center);this.exprX=c[0][0];this.exprY=c[0][1];d=0;this.rotateExp&&(d=a.degToRad(g.evalExpression(this.rotateExp)),b=Math.cos(d),h=Math.sin(d),l=this.exprX*b-this.exprY*h,f=this.exprX*h+this.exprY*b,this.exprX=l,this.exprY=f);var e=g.evalExpression(this.initExpr),n=g.evalExpression(this.endExpr);"(expr)"==this.initExpr.type&&"(expr)"==this.endExpr.type||"[expr]"==this.initExpr.type&&"[expr]"==this.endExpr.type||"(expr)"==this.initExpr.type&&
"[expr]"==this.endExpr.type||"[expr]"==this.initExpr.type&&"(expr)"==this.endExpr.type?(p=e[0][0],r=e[0][1],k=n[0][0],q=n[0][1],this.vectors?this.abs_coord&&(r=-r,q=-q):this.abs_coord?(p-=this.exprX,r=-r+this.exprY,k-=this.exprX,q=-q+this.exprY):(p-=this.exprX,r-=this.exprY,k-=this.exprX,q-=this.exprY),s=0==p?0>r?-Math.PI/2:Math.PI/2:Math.acos(1*p/Math.sqrt(p*p+r*r)),u=0==k?0>q?-Math.PI/2:Math.PI/2:Math.acos(1*k/Math.sqrt(k*k+q*q)),s+=d,u+=d,0<p&&0<r&&this.abs_coord&&(s=2*Math.PI-s),0<p&&0>r&&!this.abs_coord&&
(s=2*Math.PI-s),0>p&&0>r&&!this.abs_coord&&(s=2*Math.PI-s),0>p&&0<r&&this.abs_coord&&(s=2*Math.PI-s),0<k&&0<q&&this.abs_coord&&(u=2*Math.PI-u),0<k&&0>q&&!this.abs_coord&&(u=2*Math.PI-u),0>k&&0>q&&!this.abs_coord&&(u=2*Math.PI-u),0>k&&0<q&&this.abs_coord&&(u=2*Math.PI-u),m=Math.min(s,u),v=Math.max(s,u),s=m,u=v,u-s>Math.PI&&this.abs_coord&&(s=v,u=m),u-s<=Math.PI&&!this.abs_coord&&(s=v,u=m),this.iniAng=s,this.endAng=u,this.drawPoints=!0):(this.iniAng=a.degToRad(e)+d,this.endAng=a.degToRad(n)+d,this.drawAngle=
!0)};a.Arc.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Arc.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Arc.prototype.drawAux=function(a,b,c){g=this.evaluator;n=this.space;A=g.evalExpression(this.radius);0>A&&(A=0);y=e(g.evalExpression(this.width));a.lineWidth=0<y?y:1E-6;a.lineCap="round";a.strokeStyle=c.getColor();this.drawAngle?(this.abs_coord?(t=e(this.exprX),w=e(this.exprY)):(t=e(n.getAbsoluteX(this.exprX)),w=e(n.getAbsoluteY(this.exprY)),
A*=n.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&(B=this.iniAng,this.iniAng=this.endAng,this.endAng=B)):this.drawPoints&&(this.abs_coord?(t=e(this.exprX),w=e(this.exprY)):(t=e(n.getAbsoluteX(this.exprX)),w=e(n.getAbsoluteY(this.exprY)),A*=n.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng));this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(t,w),a.arc(t,w,A,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();a.arc(t,w,A,this.iniAng,this.endAng,
void 0);a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,t+4,w-2,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,g,c,d,b,h,l,f,p,r,k,q,s,u,m,v,n,t;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;g=e.evalExpression(this.expresion);this.exprX=g[0][0];this.exprY=g[0][1];this.rotateExp&&(c=a.degToRad(e.evalExpression(this.rotateExp)),d=Math.cos(c),b=Math.sin(c),h=this.exprX*d-this.exprY*b,l=this.exprX*b+this.exprY*d,this.exprX=h,this.exprY=l)};a.Text.prototype.draw=function(){this.uber.draw.call(this,this.color)};a.Text.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.color)};a.Text.prototype.drawAux=
function(a,b){t=this.evaluator.evalExpression(this.decimals);"rtfNode"===this.text.type?(k=this.text,this.ascent=0):k=this.splitText(this.text.toString(t,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",t,this.fixed)};a.Text.prototype.splitText=function(a){e=this.evaluator;f=e.evalExpression(this.width);k=[];this.ctx.font=this.font;if(20<=f&&"undefined"!=a.type){for(var b=0,c=a.length;b<
c;b++)p=a[b],r=this.ctx.measureText(p).width,r>f?k=k.concat(this.splitWords(p,f)):k.push(p);q=Math.floor(1.2*this.fontSize)*k.length;e.setVariable("_Text_H_",q);return k}e.setVariable("_Text_H_",0);e.setVariable("_Text_W_",1E3);return a};a.Text.prototype.splitWords=function(a,b){s=a;u=[];m="";n=0;for(var c,f=0,l=a.length;f<l;f++)v=s.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,g,c,d,b,h,l,f,p,r,k,q,s,u,m;a.Image=function(b,c){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,b,c);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);a.Image.prototype.update=function(){g=this.evaluator;c=g.evalExpression(this.expresion);
this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(d=a.degToRad(g.evalExpression(this.rotateExp)),b=Math.cos(d),h=Math.sin(d),l=this.exprX*b-this.exprY*h,f=this.exprX*h+this.exprY*b,this.exprX=l,this.exprY=f);4==c[0].length&&(this.centered=!0,this.scaleX=c[0][2],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=c[0][3],0==this.scaleY&&(this.scaleY=1E-5));c[1]&&2==c[1].length&&(this.centered=!0,this.scaleX=c[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=c[1][1],0==this.scaleY&&(this.scaleY=
1E-5));if((p=g.evalExpression(this.file))||""==p)this.img=this.parent.getImage(p)};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){g=this.evaluator;r=this.space;this.img&&this.img.ready&&this.img.complete&&(k=this.centered?0:this.img.width/2,q=this.centered?0:this.img.height/2,s=this.abs_coord?e(this.exprX):e(r.getAbsoluteX(this.exprX)),u=this.abs_coord?e(this.exprY):e(r.getAbsoluteY(this.exprY)),
m=a.degToRad(-g.evalExpression(this.inirot)),b.save(),b.translate(s+k,u+q),b.rotate(m),b.scale(this.scaleX,this.scaleY),this.opacity&&(b.globalAlpha=g.evalExpression(this.opacity)),b.drawImage(this.img,-this.img.width/2,-this.img.height/2),b.restore())};return a}(descartesJS||{}),descartesJS=function(a){function e(a,b,c){f=4*(b+c*a.width);return{r:a.data[f],g:a.data[f+1],b:a.data[f+2],a:a.data[f+3]}}if(a.loadLib)return a;var g,c,d,b,h,l,f;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,
a.Graphic);a.Fill.prototype.update=function(){g=this.evaluator.evalExpression(this.expresion);this.exprX=g[0][0];this.exprY=g[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,g){g.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(c=parseInt(this.exprX),d=parseInt(this.exprY)):(c=parseInt(this.space.getAbsoluteX(this.exprX)),d=parseInt(this.space.getAbsoluteY(this.exprY)));
if(!(0>c||0>d||c>=this.space.w||d>=this.space.h)){b=[{x:c,y:d}];for(l=e(imageData,c,d);0<b.length;){h=b.pop();c=h.x;d=h.y;var k=e(imageData,c,d);if(l.r===k.r&&l.g===k.g&&l.b===k.b&&l.a===k.a){var k=imageData,q=g;f=4*(c+d*k.width);k.data[f+0]=q.r;k.data[f+1]=q.g;k.data[f+2]=q.b;k.data[f+3]=255-q.a;0<c&&b.push({x:c-1,y:d});c<imageData.width-1&&b.push({x:c+1,y:d});b.push({x:c,y:d-1});b.push({x:c,y:d+1})}}this.ctx.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a,e){if(a.loadLib)return a;
var g=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,c;a.Macro=function(c,b){this.hasExpresion=!1;this.inirot=c.evaluator.parser.parse("0");this.inipos=c.evaluator.parser.parse("(0,0)");a.Graphic.call(this,c,b);for(var h in b)"expresion"==h&&(this.hasExpresion=!0),b.hasOwnProperty(h)&&(this[h]=b[h]);this.graphics=[];h=c.lessonParser;var l=new a.Tokenizer;if(this.hasExpresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);
var f=this.evaluator.evalExpression(this.expresion),p;f&&((p=document.getElementById(f))&&"descartes/macro"==p.type?p=p.text:(p=a.openExternalFile(f))&&!p.match(/tipo_de_macro/g)&&(p=null));var r,k;if(p){k=p.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");p=[];for(var f=0,q=k.length;f<q;f++)if(r=k[f].indexOf("="),-1!==r){r=h.split(k[f]);for(var s=0,u=r.length;s<u;s++)r[s]&&1<r.length&&("id"!==e[r[s][0]]&&"type"!==e[r[s][0]]||p.push(r))}for(var m,v,f=0,q=p.length;f<q;f++)for(u=(s=p[f]||[],s[0])&&"id"===s[0][0],k=0,r=s.length;k<r;k++)if(m=s[k][0].indexOf("."),-1===m||u?m=e[s[k][0]]:(m=e[s[k][0].substring(m+1)],s[k][0]=
this.name+"."+s[k][0]),!("font"===m||("fill"===m||"color"===m||"arrow"===m)&&"("!==s[k][1].charAt(0)||"file"===m&&s[k][1].match(g)||"id"!==m&&void 0!==e[s[k][1]]))if("text"==m)if(s[k][1].match(/\{\\rtf1/)){m=s[k][1];var n=this;v=function(a,b){for(var c=l.tokenize(b.replace(/\&squot;/g,"'")),f=0,e=c.length;f<e;f++)"identifier"!=c[f].type||"-rnd-pi-e-sqr-ra\u00edz-sqrt-exp-log-log10-abs-ent-sgn-ind-sen-sin-cos-tan-cot-sec-csc-senh-sinh-cosh-tanh-coth-sech-csch-asen-asin-acos-atan-min-max-_Num_-_Trace_-_Stop_Audios_-esCorrecto-escorrecto-_GetValues_-_GetMatrix_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_Rojo_-_Verde_-_Azul_-".match("-"+
c[f].value+"-")||(c[f].value=n.name+"."+c[f].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+l.flatTokens(c)};m=m.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,v);m=m.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,v);s[k][1]=m}else{v=h.parseText(s[k][1]).textElementsMacros;for(var t=0,w=v.length;t<w;t++){m=l.tokenize(v[t].replace(/\&squot;/g,"'"));for(var A=0,B=m.length;A<B;A++)"identifier"!==m[A].type||"-rnd-pi-e-sqr-ra\u00edz-sqrt-exp-log-log10-abs-ent-sgn-ind-sen-sin-cos-tan-cot-sec-csc-senh-sinh-cosh-tanh-coth-sech-csch-asen-asin-acos-atan-min-max-_Num_-_Trace_-_Stop_Audios_-esCorrecto-escorrecto-_GetValues_-_GetMatrix_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_Rojo_-_Verde_-_Azul_-".match("-"+
m[A].value+"-")||(m[A].value=this.name+"."+m[A].value);m=l.flatTokens(m).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");v[t]=m.substring(1,m.length-1)}s[k][1]=v.join("")}else{v=s[k][1].replace(/\&squot;/g,"'").split(";");t=0;for(w=v.length;t<w;t++){m=l.tokenize(v[t]);A=0;for(B=m.length;A<B;A++)"identifier"!==m[A].type||"-rnd-pi-e-sqr-ra\u00edz-sqrt-exp-log-log10-abs-ent-sgn-ind-sen-sin-cos-tan-cot-sec-csc-senh-sinh-cosh-tanh-coth-sech-csch-asen-asin-acos-atan-min-max-_Num_-_Trace_-_Stop_Audios_-esCorrecto-escorrecto-_GetValues_-_GetMatrix_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_Rojo_-_Verde_-_Azul_-".match("-"+
m[A].value+"-")||(m[A].value=this.name+"."+m[A].value);v[t]=l.flatTokens(m)}s[k][1]=v.join(";")}f=0;for(q=p.length;f<q;f++)if(p[f][0]){s="";u=!1;k=0;for(r=p[f].length;k<r;k++)"type"===e[p[f][k][0]]&&(s="espacio='"+this.spaceID+"' ",u=!0),s=s+p[f][k][0]+"='"+p[f][k][1]+"' ";p[f]=s;u?this.graphics.push(h.parseGraphic(p[f],this.abs_coord,this.background,this.inirot)):h.parseAuxiliar(p[f])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){c=this.evaluator.evalExpression(this.inipos);
this.iniPosX=c[0][0];this.iniPosY=c[0][1]};a.Macro.prototype.drawAux=function(a){for(var b=0,c=this.graphics.length;b<c;b++)this.graphics[b]&&(a.save(),this.graphics[b].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale),this.graphics[b].draw(),a.restore())};return a}(descartesJS||{},babel),descartesJS=function(a){if(a.loadLib)return a;a.Generic=function(e,g){this.width=e.evaluator.parser.parse("1");a.Graphic.call(this,e,g)};a.extend(a.Generic,
a.Graphic);a.Generic.prototype.update=function(){};a.Generic.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Generic.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Generic.prototype.drawAux=function(a,g,c){var d=this.evaluator.getDefinition(this.expresionString);d&&d.draw(a,g,c,this)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.sqrt,g=Math.sin,c=Math.cos,d,b,h,l,f,p,r,k,q,s,u,m,v,n,t;a.norm3D=
function(a){return e(a.x*a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(b){d=a.norm3D(b);if(0===d)return{x:0,y:0,z:0};if(1===d)return{x:b.x,y:b.y,z:b.z};d=1/d;return{x:b.x*d,y:b.y*d,z:b.z*d}};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,l,e,d,m,k,g,h,p,r,u,n,q){this.a00=a||0;this.a01=b||0;this.a02=c||0;this.a03=f||0;this.a10=l||0;this.a11=e||0;this.a12=d||0;this.a13=m||0;this.a20=k||0;this.a21=g||0;this.a22=h||0;this.a23=p||0;this.a30=r||0;this.a31=u||0;this.a32=n||0;this.a33=q||0};a.Matrix4x4.prototype.setIdentity=
function(){this.a00=1;this.a10=this.a03=this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a13=this.a12=0;this.a22=1;this.a32=this.a31=this.a30=this.a23=0;this.a33=1;return this};a.Matrix4x4.prototype.multiplyVector4=function(b){return new a.Vector4D(b.x*this.a00+b.y*this.a10+b.z*this.a20+b.w*this.a30,b.x*this.a01+b.y*this.a11+b.z*this.a21+b.w*this.a31,b.x*this.a02+b.y*this.a12+b.z*this.a22+b.w*this.a32,b.x*this.a03+b.y*this.a13+b.z*this.a23+b.w*this.a33)};a.Matrix4x4.prototype.translate=function(b){return new a.Matrix4x4(this.a00,
this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a00*b.x+this.a10*b.y+this.a20*b.z+this.a30,this.a01*b.x+this.a11*b.y+this.a21*b.z+this.a31,this.a02*b.x+this.a12*b.y+this.a22*b.z+this.a32,this.a03*b.x+this.a13*b.y+this.a23*b.z+this.a33)};a.Matrix4x4.prototype.rotateX=function(f){b=g(f);h=c(f);k=this.a10;q=this.a11;s=this.a12;u=this.a13;m=this.a20;v=this.a21;n=this.a22;t=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,k*h+m*
b,q*h+v*b,s*h+n*b,u*h+t*b,k*-b+m*h,q*-b+v*h,s*-b+n*h,u*-b+t*h,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(e){b=g(e);h=c(e);l=this.a00;f=this.a01;p=this.a02;r=this.a03;m=this.a20;v=this.a21;n=this.a22;t=this.a23;return new a.Matrix4x4(l*h+m*-b,f*h+v*-b,p*h+n*-b,r*h+t*-b,this.a10,this.a11,this.a12,this.a13,l*b+m*h,f*b+v*h,p*b+n*h,r*b+t*h,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(e){b=g(e);h=c(e);l=this.a00;f=this.a01;p=this.a02;r=this.a03;
k=this.a10;q=this.a11;s=this.a12;u=this.a13;return new a.Matrix4x4(l*h+k*b,f*h+q*b,p*h+s*b,r*h+u*b,l*-b+k*h,f*-b+q*h,p*-b+s*h,r*-b+u*h,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){0!==parseInt(this.size)&&(a.lineWidth=1,a.fillStyle=this.backColor,a.strokeStyle=this.frontColor,a.beginPath(),a.arc(this.newV[0].x,this.newV[0].y,this.size+.5,0,h),a.fill(),a.stroke())}function g(a,b){a.lineCap="round";a.lineJoin=
"round";a.lineWidth=1;a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);for(var c=1,f=this.newV.length;c<f;c++)a.lineTo(this.newV[c].x,this.newV[c].y);a.closePath();"color"===this.model?(a.fillStyle=0<=this.direction?this.backColor:this.frontColor,a.strokeStyle=a.fillStyle,a.stroke(),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.strokeStyle=
a.fillStyle,a.stroke(),a.fill()):"wire"===this.model&&(a.lineWidth=1.5,a.strokeStyle=this.frontColor,a.stroke());this.edges&&"wire"!==this.model&&(a.strokeStyle="#808080",a.stroke())}function c(a){q=this.evaluator.getVariable(this.family);this.evaluator.setVariable(this.family,this.familyValue);this.drawText(a,this.text,this.newV[0].x,this.newV[0].y+this.displace,this.frontColor,this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,q)}function d(a){a.lineCap=
"round";a.lineJoin="round";a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor;a.beginPath();a.moveTo(this.newV[0].x,this.newV[0].y);a.lineTo(this.newV[1].x,this.newV[1].y);a.stroke()}function b(b,c,e){l=a.subtract3D(b,c);f=a.subtract3D(b,e);return a.normalize3D(a.crossProduct3D(l,f))}if(a.loadLib)return a;var h=2*Math.PI,l,f,p,r,k,q;a.Primitive3D=function(a,f){this.space=f;for(var l in a)a.hasOwnProperty(l)&&(this[l]=a[l]);this.newV=[];this.spaceVertices=[];"vertex"===this.type?this.draw=e:
"face"===this.type?(this.normal=b(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=g):"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,this.draw=c):"edge"===this.type&&(this.draw=d);this.isText&&(this.computeDepth=function(){this.newV=this.vertices;this.depth=this.vertices[0].z;this.average=this.vertices[0]})};a.Primitive3D.prototype.computeDepth=function(c){this.average={x:0,y:0,z:0};this.removeDoubles();this.normal={x:0,y:1,
z:0};this.direction={x:1,y:0,z:0};for(var f=0,l=this.vertices.length;f<l;f++)this.newV[f]=c.rotateVertex(this.vertices[f]),this.spaceVertices[f]=c.rotateVertex(this.vertices[f]),this.average.x+=this.newV[f].x,this.average.y+=this.newV[f].y,this.average.z+=this.newV[f].z;this.average=a.scalarProduct3D(this.average,1/l);this.averageP=c.project(this.average);this.depth=this.averageP.z;2<this.vertices.length&&(this.normal=b(this.newV[0],this.newV[1],this.newV[2]),this.direction=a.dotProduct3D(this.normal,
a.normalize3D(c.eye)));f=0;for(l=this.vertices.length;f<l;f++)this.newV[f]=c.project(this.newV[f])};var s;a.Primitive3D.prototype.removeDoubles=function(){if("edge"!==this.type){s=[];for(var a=0,b=this.vertices.length;a<b;a++)this.vertices[a].x===this.vertices[(a+1)%b].x&&this.vertices[a].y===this.vertices[(a+1)%b].y&&this.vertices[a].z===this.vertices[(a+1)%b].z&&this.vertices[a].w===this.vertices[(a+1)%b].w||s.push(this.vertices[a]);0===s.length&&s.push(this.vertices[0]);this.vertices=s}};a.Primitive3D.prototype.drawText=
function(b,c,f,l,e,d,g,h,q,s,E){if("rtfNode"==c.type)b.fillStyle=e,b.strokeStyle=e,b.textBaseline="alphabetic",c.draw(b,f,l,q,s,g,E);else for("simpleText"===c.type&&(c=c.toString(q,s).split("\\n")),f+=d.match("Arial")?-2:d.match("Times")?-2:0,p=this.evaluator,b.fillStyle=a.getColor(p,e),b.font=d,b.textAlign=g,b.textBaseline=h,r=1.2*this.fontSize||0,e=0,d=c.length;e<d;e++)k=c[e],this.border&&b.strokeText(k,f,l+r*e),b.fillText(k,f,l+r*e)};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){for(var c=
null,f=null,l=0,e=0,d=0,k=b.vertices.length;d<k;d++){var g=this.intersection(b.vertices[d],b.vertices[(d+1)%k]);if(null!==g)if(null===c){if(c=g,l=d,2===b.vertices.length){f=c;break}}else if(!a.equals3DEpsilon(g,c,1E-8)){f=g;e=d;break}}if(null!==c&&null!==f){var d=this.isInterior(c)||this.isInterior(f),h=null,p=null;if(!d&&3<=b.vertices.length)for(var k=0,r=this.vertices.length;k<r;k++)if(g=b.intersection(this.vertices[k],this.vertices[(k+1)%r]),null!==g)if(null===h)h=g;else if(!a.equals3DEpsilon(g,
h,1E-8)){p=g;break}if(d||null!==h&&null!==p&&b.isInterior(h)&&b.isInterior(p)){p=!0;r=b.vertices;h=g=null;if(2===r.length)a.equals(c,r[0],1E-8)||a.equals(c,r[1],1E-8)?p=!1:(g=[],g[0]=r[0],g[1]=c,h=[],h[0]=c,h[1]=r[1]);else for(var g=[],h=[],q=0,d=k=0;d<r.length;d++)d<l?g[q++]=r[d]:d==l?(g[q++]=r[d],g[q++]=c,h[k++]=c):d<e?h[k++]=r[d]:d==e?(h[k++]=r[d],h[k++]=f,g[q++]=f):g[q++]=r[d];if(p)return c=[],c[0]=new a.Primitive3D({vertices:g,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,
model:b.model},this.space),c[0].normal=b.normal,c[1]=new a.Primitive3D({vertices:h,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model},this.space),c[1].normal=b.normal,c}}}return[b]};a.Primitive3D.prototype.intersects=function(a){return this.intersectsPlane(a)&&a.intersectsPlane(this)};a.Primitive3D.prototype.intersectsPlane=function(b){var c=a.dotProduct3D(b.vertices[0],b.normal),f=a.dotProduct3D(this.vertices[0],b.normal);if(1E-8>Math.abs(c-f))return!0;for(var l=
1,e=this.vertices.length;l<e;l++){var d=a.dotProduct3D(this.vertices[l],b.normal);if(1E-8>Math.abs(c-d)||d>c&&f<c||d<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),l=a.dotProduct3D(f,this.normal);if(0!==l&&(l=a.dotProduct3D(a.subtract3D(this.vertices[0],b),this.normal)/l,-1E-8<l&&1.00000001>l))return a.add3D(b,a.scalarProduct3D(f,l))}return null};a.Primitive3D.prototype.isInterior=function(b){if(0<this.vertices.length)for(var c=
0,f=a.subtract3D(this.vertices[0],b),l=0,e=this.vertices.length;l<e;l++){var d=a.subtract3D(this.vertices[(l+1)%e],b),k=a.dotProduct3D(a.crossProduct3D(f,d),this.normal);if(1E-8>Math.abs(k)){if(0>a.dotProduct3D(f,d))break}else{if(0>c&&0<k||0<c&&0>k)return!1;f=d;c=k}}return!0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e={x:0,y:0,z:0},g,c,d,b,h,l;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 l in c)c.hasOwnProperty(l)&&(this[l]=c[l]);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(){g=this.evaluator;c=g.evalExpression(this.family_interval);this.familyInf=c[0][0];this.familySup=c[0][1];this.fSteps=Math.round(g.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){g=this.evaluator;this.getFamilyValues();
d=g.getVariable(this.family);if(0<=this.fSteps)for(var a=0,b=this.fSteps;a<=b;a++)g.setVariable(this.family,this.familyInf+a*this.family_sep),this.familyValue=this.familyInf+a*this.family_sep,g.evalExpression(this.drawif)&&this.buildPrimitives();g.setVariable(this.family,d)};a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.evalExpression(this.drawif)&&(this.family||this.buildPrimitives());this.family&&this.buildFamilyPrimitives()};a.Graphic3D.prototype.updateMVMatrix=function(){h=
this.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(h[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(h[0][1])),this.inirotM=this.inirotM.rotateZ(a.degToRad(h[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(h[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(h[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(h[0][2])));h=this.evaluator.evalExpression(this.inipos);
e={x:h[0][0],y:h[0][1],z:h[0][2]};this.iniposM=this.iniposM.setIdentity().translate(e);h=this.evaluator.evalExpression(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(h[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(h[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(h[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(h[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(h[0][1])),
this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(h[0][2])));h=this.evaluator.evalExpression(this.endpos);e={x:h[0][0],y:h[0][1],z:h[0][2]};this.endposM=this.endposM.setIdentity().translate(e)};a.Graphic3D.prototype.transformVertex=function(a){this.macroChildren&&(a=this.applyMacroTransform(a));this.inirotEuler?b=this.inirotM.multiplyVector4(a):(b=this.inirotM_X.multiplyVector4(a),b=this.inirotM_Y.multiplyVector4(b),b=this.inirotM_Z.multiplyVector4(b));b=this.iniposM.multiplyVector4(b);
this.endrotEuler?b=this.endrotM.multiplyVector4(b):(b=this.endrotM_X.multiplyVector4(b),b=this.endrotM_Y.multiplyVector4(b),b=this.endrotM_Z.multiplyVector4(b));return b=this.endposM.multiplyVector4(b)};a.Graphic3D.prototype.applyMacroTransform=function(a){this.macro_inirotEuler?b=this.macro_inirotM.multiplyVector4(a):(b=this.macro_inirotM_X.multiplyVector4(a),b=this.macro_inirotM_Y.multiplyVector4(b),b=this.macro_inirotM_Z.multiplyVector4(b));b=this.macro_iniposM.multiplyVector4(b);this.macro_endrotEuler?
b=this.macro_endrotM.multiplyVector4(b):(b=this.macro_endrotM_X.multiplyVector4(b),b=this.macro_endrotM_Y.multiplyVector4(b),b=this.macro_endrotM_Z.multiplyVector4(b));return b=this.macro_endposM.multiplyVector4(b)};a.Graphic3D.prototype.parseExpression=function(){l=[];for(var a=this.expresion.replace(/\n/g," ").replace(/ ( )+/g," ").trim(),b=[],c=0,f,e=a.length,d=a.length-1;-1<d;d--)f=a.charAt(d),0==c?"="==f&&(c=1):1==c?" "!=f&&(c="<"==f||">"==f?0:2):2==c&&" "==f&&(b.unshift(a.substring(d+1,e)),
e=d,c=0);b.unshift(a.substring(0,e));d=0;for(a=b.length;d<a;d++)l.push(this.evaluator.parser.parse(b[d],!0));return l};var f;a.Graphic3D.prototype.splitFace=function(a){for(var b=0,c=this.primitives.length;b<c;b++)if(f=[],"face"===this.primitives[b].type){for(var l=0,e=a.primitives.length;l<e;l++)"face"===a.primitives[l].type?f=f.concat(this.primitives[b].splitFace(a.primitives[l])):f.push(a.primitives[l]);a.primitives=f}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,
g,c,d,b;a.Point3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();g=e.evalExpression(this.expresion);c=g[0][0];d=g[0][1];b=g[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(c,d,b,1))],type:"vertex",backColor:this.backcolor.getColor(),frontColor:this.color.getColor(),size:e.evalExpression(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(c,
d,b,1))],type:"text",frontColor:this.color.getColor(),font:this.font,decimals:e.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize,evaluator:e,text:this.text,family:this.family,familyValue:this.familyValue},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b,h,l;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();l=evaluator.getVariable("u");evaluator.setVariable("u",this.Nu);expr=evaluator.evalExpression(this.expresion);e=expr[0][0];g=expr[0][1];c=expr[0][2];d=expr[1][0];b=expr[1][1];h=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,g,c,1)),this.transformVertex(new a.Vector4D(d,b,h,1))],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.evalExpression(this.width)},this.space));evaluator.setVariable("u",l)};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b,h,l;a.Surface3D=function(b,c){this.parameter="t";this.parameter_interval=b.evaluator.parser.parse("[0,1]");this.parameter_steps=b.evaluator.parser.parse("8");a.Graphic3D.call(this,b,c);this.expresion=this.parseExpression()};a.extend(a.Surface3D,a.Graphic3D);a.Surface3D.prototype.buildPrimitives=function(){e=this.evaluator;this.updateMVMatrix();c=e.getVariable("x");c=e.getVariable("y");c=e.getVariable("z");g=e.getVariable("u");
c=e.getVariable("v");e.setVariable("u",0);e.setVariable("v",0);d=e.evalExpression(this.Nu);b=e.evalExpression(this.Nv);h=[];for(var f=0;f<=d;f++){e.setVariable("u",f/d);for(var p=0;p<=b;p++){e.setVariable("v",p/b);for(var r=0,k=this.expresion.length;r<k;r++)e.evalExpression(this.expresion[r]);h.push(this.transformVertex(new a.Vector4D(e.getVariable("x"),e.getVariable("y"),e.getVariable("z"),1)))}}for(f=0;f<d;f++)for(p=0;p<b;p++)l=[],l.push(h[p+f*b+f]),l.push(h[p+1+f*b+f]),l.push(h[p+2+(f+1)*b+f]),
l.push(h[p+1+(f+1)*b+f]),this.primitives.push(new a.Primitive3D({vertices:l,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space));e.setVariable("x",void 0);e.setVariable("y",void 0);e.setVariable("z",void 0);e.setVariable("u",g);e.setVariable("v",c)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b,h;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 l=0,f=expr.length-1;l<f;l++)e=expr[l][0],g=expr[l][1],c=expr[l][2],d=expr[l+1][0],b=expr[l+1][1],h=expr[l+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,g,c,1)),this.transformVertex(new a.Vector4D(d,b,h,1))],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.evalExpression(this.width)},
this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b,h;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();d=evaluator.getVariable("x");b=evaluator.getVariable("y");h=evaluator.getVariable("z");c=evaluator.getVariable("u");evaluator.setVariable("u",
0);g=evaluator.evalExpression(this.Nu);e=[];for(var l=0;l<=g;l++){evaluator.setVariable("u",l/g);for(var f=0,p=this.expresion.length;f<p;f++)evaluator.evalExpression(this.expresion[f]);e.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}l=0;for(f=e.length-1;l<f;l++)this.primitives.push(new a.Primitive3D({vertices:[e[l],e[l+1]],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.evalExpression(this.width)},this.space));
evaluator.setVariable("x",d);evaluator.setVariable("y",h);evaluator.setVariable("z",b);evaluator.setVariable("u",c)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b,h,l,f,p;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];g=expr[0][1];c=expr[0][2];d=expr[1][0];b=expr[1][1];
h=expr[1][2];l=expr[2][0];f=expr[2][1];p=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(e,g,c,1)),this.transformVertex(new a.Vector4D(l,f,p,1)),this.transformVertex(new a.Vector4D(d,b,h,1))],type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Face3D=function(e,c){a.Graphic3D.call(this,e,c)};
a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);e=[];for(var g=expr.length-1;0<=g;g--)e.push(this.transformVertex(new a.Vector4D(expr[g][0],expr[g][1],expr[g][2],1)));this.primitives.push(new a.Primitive3D({vertices:e,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var e,g,c,d,b;a.Polireg3D=function(b,c){this.width=b.evaluator.parser.parse("2");this.length=b.evaluator.parser.parse("2");a.Graphic3D.call(this,b,c)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();e=evaluator.evalExpression(this.Nu);g=[this.transformVertex(new a.Vector4D(0,0,0,1))];c=evaluator.evalExpression(this.width)/2;d=evaluator.evalExpression(this.length)/2;b=2*Math.PI/e;for(var h=
0;h<e;h++)g.push(this.transformVertex(new a.Vector4D(c*Math.cos(b*h),d*Math.sin(b*h),0,1)));for(h=0;h<e;h++)this.primitives.push(new a.Primitive3D({vertices:[g[0],h+2<=e?g[h+2]:g[1],g[h+1]],type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d;a.Text3D=function(b,c){a.Graphic3D.call(this,b,c)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=
function(){e=this.evaluator;g=e.evalExpression(this.expresion);c=g[0][0];d=g[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(c,d,0,1)],type:"text",frontColor:this.color.getColor(),font:this.font,decimals:e.evalExpression(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:e,text:this.text,family:this.family,familyValue:this.familyValue,joel:"hola"},this.space))};return a}(descartesJS||{}),descartesJS=function(a,e){if(a.loadLib)return a;var g=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,
c,d;a.Macro3D=function(b,c){this.expresion=void 0;this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=b.evaluator.parser.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=b.evaluator.parser.parse("(0,0,0)");a.Graphic.call(this,b,c);for(var l in c)c.hasOwnProperty(l)&&(this[l]=c[l]);this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&(this.endrot=this.endrot.replace("Euler",""),this.endrotEuler=!0);this.inirot=
this.evaluator.parser.parse(this.inirot);this.endrot=this.evaluator.parser.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4;this.graphics=[];l=b.lessonParser;var f=new a.Tokenizer;if(void 0!=this.expresion){"'"!==this.expresion.charAt(0)&&
(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var d=this.evaluator.evalExpression(this.expresion),r;d&&((r=document.getElementById(d))&&"descartes/macro"==r.type?r=r.text:(r=a.openExternalFile(d))&&!r.match(/tipo_de_macro/g)&&(r=null));var k,q;if(r){q=r.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");r=[];for(var d=0,s=q.length;d<s;d++)k=q[d].indexOf("="),-1!==k&&(k=q[d].substring(0,k),"id"!==e[k]&&"type"!==e[k]||r.push(l.split(q[d])));for(var u,m,v,n,d=0,s=r.length;d<s;d++)for(n=(u=r[d]||[],u[0])&&"id"===u[0][0],q=0,k=u.length;q<k;q++)if(m=
u[q][0].indexOf("."),-1===m||n?m=e[u[q][0]]:(m=e[u[q][0].substring(m+1)],u[q][0]=this.name+"."+u[q][0]),!("font"===m||("fill"===m||"color"===m||"backcolor"===m||"arrow"===m)&&"("!==u[q][1].charAt(0)||"file"===m&&u[q][1].match(g)||"id"!==m&&void 0!==e[u[q][1]])||"width"===m||"height"===m||"length"===m)if("text"==m)if(u[q][1].match(/\{\\rtf1/)){m=u[q][1];var t=this;v=function(a,b){for(var c=f.tokenize(b.replace(/\&squot;/g,"'")),d=0,l=c.length;d<l;d++)"identifier"!=c[d].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[d].value+"-")||(c[d].value=t.name+"."+c[d].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+f.flatTokens(c)};m=m.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,v);m=m.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,v);u[q][1]=m}else{v=l.parseText(u[q][1]).textElementsMacro3Ds;for(var w=0,A=v.length;w<A;w++){m=f.tokenize(v[w].replace(/\&squot;/g,"'"));for(var B=0,y=m.length;B<y;B++)"identifier"!==m[B].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("-"+
m[B].value+"-")||(m[B].value=this.name+"."+m[B].value);m=f.flatTokens(m).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");v[w]=m.substring(1,m.length-1)}u[q][1]=v.join("")}else{m=f.tokenize(u[q][1]);v=0;for(w=m.length;v<w;v++)"identifier"!==m[v].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("-"+m[v].value+"-")||(m[v].value=this.name+"."+m[v].value);u[q][1]=f.flatTokens(m)}d=
0;for(s=r.length;d<s;d++)if(r[d][0]){u="";n=!1;q=0;for(k=r[d].length;q<k;q++)"type"===e[r[d][q][0]]&&(u="espacio='"+this.spaceID+"' ",n=!0),u=u+r[d][q][0]+"='"+r[d][q][1]+"' ";r[d]=u;n?this.graphics.push(l.parse3DGraphic(r[d],this.abs_coord,this.background,this.inirot)):l.parseAuxiliar(r[d])}}d=0;for(s=this.graphics.length;d<s;d++)this.graphics[d].macroChildren=!0}};a.extend(a.Macro3D,a.Graphic);a.Macro3D.prototype.update=function(){this.updateTransformation();if(this.inipos){var a=this.evaluator.evalExpression(this.inipos);
this.iniPosX=a[0][0];this.iniPosY=a[0][1]}this.primitives=[];for(var a=0,e=this.graphics.length;a<e;a++)c=this.graphics[a],c.macro_inirotEuler=this.inirotEuler,c.macro_inirotM=this.inirotM,c.macro_inirotM_X=this.inirotM_X,c.macro_inirotM_Y=this.inirotM_Y,c.macro_inirotM_Z=this.inirotM_Z,c.macro_iniposM=this.iniposM,c.macro_endrotEuler=this.endrotEuler,c.macro_endrotM=this.endrotM,c.macro_endrotM_X=this.endrotM_X,c.macro_endrotM_Y=this.endrotM_Y,c.macro_endrotM_Z=this.endrotM_Z,c.macro_endposM=this.endposM,
c.update();a=0;for(e=this.graphics.length;a<e;a++){c=this.graphics[a];if(c.split||this.split)for(var l=a+1;l<e;l++)d=this.graphics[l],(d.split||this.split)&&c.splitFace(d);this.primitives=this.primitives.concat(c.primitives||[])}};a.Macro3D.prototype.updateTransformation=function(){tmpExpr=this.evaluator.evalExpression(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(a.degToRad(tmpExpr[0][0])),this.inirotM=this.inirotM.rotateX(a.degToRad(tmpExpr[0][1])),
this.inirotM=this.inirotM.rotateZ(a.degToRad(tmpExpr[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(a.degToRad(tmpExpr[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(a.degToRad(tmpExpr[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(a.degToRad(tmpExpr[0][2])));tmpExpr=this.evaluator.evalExpression(this.inipos);translate={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.iniposM=this.iniposM.setIdentity().translate(translate);tmpExpr=this.evaluator.evalExpression(this.endrot);
this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),this.endrotM=this.endrotM.rotateZ(a.degToRad(tmpExpr[0][0])),this.endrotM=this.endrotM.rotateX(a.degToRad(tmpExpr[0][1])),this.endrotM=this.endrotM.rotateZ(a.degToRad(tmpExpr[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(a.degToRad(tmpExpr[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(a.degToRad(tmpExpr[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(a.degToRad(tmpExpr[0][2])));tmpExpr=this.evaluator.evalExpression(this.endpos);
translate={x:tmpExpr[0][0],y:tmpExpr[0][1],z:tmpExpr[0][2]};this.endposM=this.endposM.setIdentity().translate(translate)};a.Macro3D.prototype.drawAux=function(a){};return a}(descartesJS||{},babel),descartesJS=function(a){function e(a,b,c,f,d){g.call(this,a/1.8,a/1.8,a/1.8,f,d)}function g(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 c(a,b,c,f,d){a/=2;this.changeGeometry(a,b,c,f,d)||(this.vertices=[new m(0,0,a,1),new m(-.49*a,-.86*a,-.32*a,1),new m(-.49*a,.86*a,-.32*a,1),new m(1*a,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 d(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 b(b,c,f,d,l){b/=3.4;if(!this.changeGeometry(b,c,f,d,l)){D=b/1.6180339887;E=1.6180339887*b;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,E,1),new m(0,D,-E,1),new m(0,-D,E,1),new m(0,-D,-E,1),new m(D,E,0,1),new m(D,-E,0,1),new m(-D,E,0,1),new m(-D,-E,0,1),new m(E,0,D,1),
new m(E,0,-D,1),new m(-E,0,D,1),new m(-E,0,-D,1)];C=(new a.Matrix4x4).setIdentity().rotateY(-s/6);for(var e=0,g=this.vertices.length;e<g;e++)this.vertices[e]=C.multiplyVector4(this.vertices[e]);this.faces=[[0,16,2,10,8],[12,1,17,16,0],[8,4,14,12,0],[2,16,17,3,13],[13,15,6,10,2],[6,18,4,8,10],[3,17,1,9,11],[13,3,11,7,15],[1,12,14,5,9],[11,9,5,19,7],[5,14,4,18,19],[6,15,7,19,18]];this.updateValues(b,c,f,d,l)}}function h(b,c,f,d,l){b/=4;if(!this.changeGeometry(b,c,f,d,l)){E=1.6180339887*b;this.vertices=
[new m(0,b,E,1),new m(0,b,-E,1),new m(0,-b,E,1),new m(0,-b,-E,1),new m(b,E,0,1),new m(b,-E,0,1),new m(-b,E,0,1),new m(-b,-E,0,1),new m(E,0,b,1),new m(E,0,-b,1),new m(-E,0,b,1),new m(-E,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]];C=(new a.Matrix4x4).setIdentity().rotateY(-1.029);for(var e=0,g=this.vertices.length;e<g;e++)this.vertices[e]=C.multiplyVector4(this.vertices[e]);
this.updateValues(b,c,f,d,l)}}function l(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 l=1;l<f;l++){y=l*s/f;for(var e=0;e<d;e++)B=e*u/d,t=a*k(y)*q(B),w=c*k(y)*k(B),A=b*q(y),this.vertices.push(new m(t,w,A,1))}this.vertices.push(new m(0,0,-b,1));this.faces=[];for(l=0;l<d;l++)this.faces.push([0,(l+1)%d+1,l%d+1]);for(l=1;l<f-1;l++)for(e=0;e<d;e++)this.faces.push([e+1+(l-1)*d,(e+1)%d+1+(l-1)*d,(e+1)%d+1+l*d,e+1+l*d]);for(l=0;l<
d;l++)this.faces.push([this.vertices.length-1,this.vertices.length-1-d+l,this.vertices.length-1-d+(l+1)%d]);this.updateValues(a,b,c,f,d)}}function f(a,b,c,f,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[];for(var l=0;l<d;l++)for(var e=0;e<f;e++)t=a*(d-l)/d*q(e*u/f),w=c*(d-l)/d*k(e*u/f),A=b-2*l*b/d,this.vertices.push(new m(t,w,A,1));this.vertices.push(new m(0,0,-b,1));this.faces=[];for(l=0;l<d-1;l++)for(e=0;e<f;e++)this.faces.push([e+l*f,(e+1)%f+l*f,(e+1)%f+(l+1)*f,e+(l+1)*f]);
for(l=0;l<f;l++)this.faces.push([this.vertices.length-1,this.vertices.length-1-f+l,this.vertices.length-1-f+(l+1)%f]);this.updateValues(a,b,c,f,d)}}function p(a,b,c,f,d){a/=2;b/=2;c/=2;if(!this.changeGeometry(a,b,c,f,d)){this.vertices=[];for(var l=0;l<d+1;l++)for(var e=0;e<f;e++)t=a*q(e*u/f),w=c*k(e*u/f),A=b-2*l*b/d,this.vertices.push(new m(t,w,A,1));this.faces=[];for(l=0;l<d;l++)for(e=0;e<f;e++)this.faces.push([e+l*f,(e+1)%f+l*f,(e+1)%f+(l+1)*f,e+(l+1)*f]);this.updateValues(a,b,c,f,d)}}function r(){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++)z=this.fileData[c],z.match(/^V\(/)?(H=z.substring(2,z.length-1).split(",").map(b),this.vertices.push(new m(H[0]||0,H[1]||0,H[2]||0,1))):z.match(/^F\(/)&&(H=z.substring(2,z.length-1).split(",").map(a),this.faces.push(H.reverse()))}if(a.loadLib)return a;var k=Math.sin,q=Math.cos,s=Math.PI,u=2*s,m,v,n,t,w,A,B,y,D,E,C,z,H;a.OtherGeometry=function(k,n){this.width=k.evaluator.parser.parse("2");this.height=
k.evaluator.parser.parse("2");this.length=k.evaluator.parser.parse("2");m=a.Vector4D;a.Graphic3D.call(this,k,n);switch(this.type){case "cube":this.buildGeometry=e;break;case "box":this.buildGeometry=g;break;case "tetrahedron":this.buildGeometry=c;break;case "octahedron":this.buildGeometry=d;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=l;break;case "dodecahedron":this.buildGeometry=b;break;case "icosahedron":this.buildGeometry=h;break;case "cone":this.buildGeometry=f;break;
case "cylinder":this.buildGeometry=p;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=r}};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.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space))}};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,g=Math.min,c=Math.PI,d=Math.cos,b=Math.sin,h=Math.abs,l=Math.round,f,p,r,k,q,s,u,m,v,n,t,w,A,B,y,D,E,C;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;return this};a.R2.prototype.copy=function(){return new a.R2(this.x,this.y)};a.R2.prototype.ix=function(){return l(e(g(this.x,32E3),
-32E3))};a.R2.prototype.iy=function(){return l(e(g(this.y,32E3),-32E3))};a.R2.prototype.equals=function(a){return this.x==a.x&&this.y==a.y};a.R2.prototype.norm2=function(){return this.x*this.x+this.y*this.y};a.R2.prototype.norm=function(){return Math.sqrt(this.norm2())};a.R2.prototype.distance=function(a){p=this.copy();p.sub(a);return p.norm()};a.R2.prototype.dot=function(a){return this.x*a.x+this.y*a.y};a.R2.prototype.det=function(a){return this.x*a.y-this.y*a.x};a.R2.prototype.mul=function(a){this.x*=
a;this.y*=a};a.R2.prototype.div=function(a){this.x/=a;this.y/=a};a.R2.prototype.add=function(a){this.x+=a.x;this.y+=a.y};a.R2.prototype.sub=function(a){this.x-=a.x;this.y-=a.y};a.R2.prototype.normalize=function(){f=this.norm();0!=f&&this.div(f)};a.R2.prototype.rotR90=function(){f=this.x;this.x=this.y;this.y=-f};a.R2.prototype.rotL90=function(){f=this.x;this.x=-this.y;this.y=f};a.R2.prototype.rot=function(a){r=this.copy();s=d(a);u=b(a);this.x=r.x*s-r.y*u;this.y=r.x*u+r.y*s};a.R2.prototype.rot=function(a){this.rot(a*
c/180)};a.R2.prototype.intersection=function(b,c,f,d){m=c.x-b.x;v=f.x-d.x;n=f.x-b.x;t=c.y-b.y;w=f.y-d.y;A=f.y-b.y;C=m*w-v*t;return 1E-6<h(C)?(k=(n*w-A*v)/C,q=(-n*t+A*m)/C,0<=k&&1>=k&&0<=q&&1>=q?new a.R2(b.x+m*k,b.y+t*k):null):(c.x-f.x)*A!=(c.y-f.y)*n?null:b.x!=c.x?(B=g(b.x,c.x),y=e(b.x,c.x),B<=f.x&&f.x<=y?f:B<=d.x&&d.x<=y?d:null):f.x!=d.x?(D=g(f.x,d.x),E=e(f.x,d.x),D<=b.x&&b.x<=E?b:D<=c.x&&c.x<=E?c:null):b.y!=c.y?(B=g(b.y,c.y),y=e(b.y,c.y),B<=f.y&&f.y<=y?f:B<=d.y&&d.y<=y?d:null):f.y!=d.y?(D=g(f.y,
d.y),E=e(f.y,d.y),D<=b.y&&b.y<=E?b:D<=c.y&&c.y<=E?c:null):b.x==f.x&&b.y==f.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b,h,l,f,p;a.R2Newton=function(c,f){this.evaluator=c;this.constraint=f;if("=="==this.constraint.value||"<"==this.constraint.value||"<="==this.constraint.value||">"==this.constraint.value||">="==this.constraint.value)this.sign="<"==this.constraint.value||"<="==this.constraint.value?"menor":">"==this.constraint.value||">="==this.constraint.value?
"mayor":"igual",this.constraint=this.constraint.equalToMinus(),this.constraint=this.constraint.childs[0];h=new a.R2(0,0);b=new a.R2(0,0);p=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return p.set(this.normal.x,this.normal.y)};a.R2Newton.prototype.gradient=function(a){e=this.evaluator;h.x=0;h.y=0;l=e.getVariable("x");f=e.getVariable("y");e.setVariable("x",a.x);e.setVariable("y",a.y);this.f0=e.evalExpression(this.constraint);e.setVariable("x",e.getVariable("x")+
1E-6);g=e.evalExpression(this.constraint);h.x=(g-this.f0)/1E-6;h.x=isNaN(h.x)?Infinity:h.x;e.setVariable("x",e.getVariable("x")-1E-6);e.setVariable("y",e.getVariable("y")+1E-6);g=e.evalExpression(this.constraint);h.y=(g-this.f0)/1E-6;h.y=isNaN(h.y)?Infinity:h.y;e.setVariable("x",l);e.setVariable("y",f);return h};a.R2Newton.prototype.findZero=function(a,g,h){e=this.evaluator;b.x=a.x;b.y=a.y;l=e.getVariable("x");f=e.getVariable("y");e.setVariable("x",a.x);e.setVariable("y",a.y);this.f0=e.evalExpression(this.constraint);
if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return b;e.setVariable("x",l);e.setVariable("y",f);for(var p=0;16>p;p++)if(c=b.x,d=b.y,this.normal=this.gradient(b),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),b.x=c+this.normal.x,b.y=d+this.normal.y,this.normal.norm()<g)return 0===this.normal.x&&0===this.normal.y&&(this.normal.x=b.x-a.x,this.normal.y=b.y-a.y),b;return h?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=
function(a,g){this.x=a;this.y=g};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,g=Math.round,
c,d,b,h,l,f,p,r,k,q,s,u,m,v,n,t,w,A,B,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]);"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=g(f[0][0]);this.y=g(f[0][1]);4==f[0].length&&(this.w=g(f[0][2]),this.h=g(f[0][3]));this.actionExec=b.lessonParser.parseAction(this)};a.Control.prototype.init=function(){};a.Control.prototype.update=function(){};a.Control.prototype.draw=function(){};a.Control.prototype.getContainer=function(){var a=this.parent.spaces,b;if("interior"===this.region)for(var c=0,f=a.length;c<f;c++){if(b=a[c],b.id===this.spaceID)return b.addCtr(this),
this.zIndex=b.zIndex,b.numericalControlContainer}else{if("external"===this.region)return this.parent.externalSpace.addCtr(this),this.parent.externalSpace.container;if("scenario"===this.region)return this.cID?(this.expresion=this.evaluator.parser.parse("(0,-1000,"+this.w+","+this.h+")"),this.parent.scenarioRegion.scenarioSpace.addCtr(this),this.zIndex=this.parent.scenarioRegion.scenarioSpace.zIndex,this.parent.scenarioRegion.scenarioSpace.numericalControlContainer):this.parent.externalSpace.container;
if("north"===this.region)return this.parent.northSpace.controls.push(this),this.parent.northSpace.container;if("south"===this.region)return this.parent.southSpace.controls.push(this),this.parent.southSpace.container;if("east"===this.region)return this.parent.eastSpace.controls.push(this),this.parent.eastSpace.container;if("west"===this.region)return this.parent.westSpace.controls.push(this),this.parent.westSpace.container;if("special"===this.region)return this.parent.specialSpace.controls.push(this),
this.parent.specialSpace.container}a[0].addCtr(this);this.zIndex=a[0].zIndex;return a[0].numericalControlContainer};a.Control.prototype.addControlContainer=function(a){var b=this.getContainer();b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a);b.childNodes[0]?b.insertBefore(a,b.childNodes[0]):b.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){b=h=l=f=!1;p=this.evaluator.evalExpression(this.expresion);r=g(p[0][0]);b=g(this.x)!==r;this.x=r;r=g(p[0][1]);h=g(this.y)!==
r;this.y=r;4===p[0].length&&(r=g(p[0][2]),l=g(this.w)!==r,this.w=r,r=g(p[0][3]),f=g(this.h)!==r,this.h=r);if(l||f||b||h)this.init(!0),this.draw()};a.Control.prototype.formatOutputValue=function(a){m=this.parent;k=a+"";q=this.evaluator.evalExpression(this.decimals);s=k.indexOf(".");-1!=s&&(u=k.substring(s+1),u.length>q&&(k=parseFloat(k).toFixed(q)));this.fixed&&(2!==m.version||2===m.version&&!this.exponentialif)&&(k=parseFloat(a).toFixed(q));this.exponentialif&&0!=parseFloat(k)&&(k=this.fixed&&2!==
m.version?parseFloat(k).toExponential(q):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,b){this.linearGradient=this.ctx.createLinearGradient(0,0,0,b);c=b*b;for(var f=0;f<b;f++)d=e(f-35*b/100),this.linearGradient.addColorStop(f/
b,"rgba(0,0,0,"+d*d*192/c/255+")")};a.Control.prototype.getScreenshot=function(){t=this;v=document.createElement("canvas");v.setAttribute("width",t.w);v.setAttribute("height",t.h);n=v.getContext("2d");n.font=t.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";t.canvas&&(w=t.canvas.offsetLeft,A=t.canvas.offsetTop,n.drawImage(t.canvas,w,A));t.label&&(w=t.label.offsetLeft,A=t.label.offsetTop,B=t.label.offsetWidth,y=t.label.offsetHeight,n.fillStyle="#e0e4e8",n.fillRect(w,A,B,y),n.fillStyle=
"black",n.textAlign="center",n.textBaseline="middle",n.fillText(t.name,w+B/2,A+y/2));t.field&&(w=t.field.offsetLeft,A=t.field.offsetTop,B=t.field.offsetWidth,y=t.field.offsetHeight,n.fillStyle="white",n.strokeStyle="#666666",n.lineWidth=1,n.fillRect(w,0,B,y),n.strokeRect(w+.5,.5,B-1,y-1),n.fillStyle="black",n.textAlign="center",n.textAlign="left",n.fillText(t.field.value,w+2,y/2));t.select&&(w=t.select.offsetLeft,A=t.select.offsetTop,B=t.select.offsetWidth,y=t.select.offsetHeight,n.fillStyle="#e0e4e8",
n.strokeStyle="#666666",n.lineWidth=1,n.fillRect(w,0,B,y),n.strokeRect(w+.5,.5,B,y-1),n.fillStyle="black",n.textAlign="center",n.textAlign="left",n.fillText(t.select.value,w+2,y/2),n.fillStyle="#c0c0c0",n.fillRect(w+B-15+.5,.5,15,y-1),n.strokeRect(w+B-15+.5,.5,15,y-1),n.fillStyle="black",n.beginPath(),n.moveTo(w+B-15+4.5,y/2-2.5),n.lineTo(w+B-15+8,y/2+2.5),n.lineTo(w+B-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,g=Math.abs,c,d,b,h,l,f,p,r,k,q,s,u,m,v,n,t,w,A,B,y;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.charAt(0)?this.imageSrc=this.parser.parse(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(".")),l=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"+l),this.imageDown=this.parent.getImage(d+"_down"+l))}this.container=document.createElement("div");this.container.setAttribute("class","DescartesButtonContainer");this.container.setAttribute("id",this.id);this.container.setAttribute("style","width:"+this.w+"px; height:"+this.h+"px; left:"+this.x+"px; top:"+this.y+"px; z-index:"+this.zIndex+
";");this.canvas=document.createElement("canvas");this.canvas.width=this.w*a._ratio;this.canvas.height=this.h*a._ratio;this.canvas.setAttribute("style","position:absolute; left:0px; top:0px; width:"+this.w+"px; height:"+this.h+"px;");this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.ctx.mozImageSmoothingEnabled=!1;this.ctx.webkitImageSmoothingEnabled=!1;this.container.appendChild(this.canvas);this.addControlContainer(this.container);this.registerMouseAndTouchEvents();this.init()};
a.extend(a.Button,a.Control);a.Button.prototype.init=function(){c=this.evaluator;y=this.container;d=this.canvas;h=c.evalExpression(this.expresion);this.x=h[0][0];this.y=h[0][1];4==h[0].length&&(this.w=parseInt(h[0][2]),this.h=parseInt(h[0][3]));d.width=this.w*a._ratio;d.height=this.h*a._ratio;d.setAttribute("style","position:absolute; left:0px; top:0px; width:"+this.w+"px; height:"+this.h+"px;");y.setAttribute("style","width:"+this.w+"px; height:"+this.h+"px; left:"+this.x+"px; top:"+this.y+"px; z-index:"+
this.zIndex+"; display:block;");this.fontSizeNotSet&&(this.font_size=c.parser.parse(a.getFieldFontSize(this.h)+""));this.createGradient(this.w,this.h);y.style.display=0<c.evalExpression(this.drawif)?"block":"none";y.setAttribute("data-color",this.colorInt.getColor())};a.Button.prototype.update=function(){c=this.evaluator;y=this.container;d=this.canvas;this.activeIfValue=0<c.evalExpression(this.activeif);(this.drawIfValue=0<c.evalExpression(this.drawif))?(y.style.display="block",this.draw()):y.style.display=
"none";y.style.cursor=this.activeIfValue?"pointer":"not-allowed";d.style.cursor=this.activeIfValue?"pointer":"not-allowed";y.setAttribute("data-active",this.activeIfValue?"true":"false");this.updatePositionAndSize()};a.Button.prototype.draw=function(){y=this.container;c=this.evaluator;b=this.ctx;b.save();b.setTransform(a._ratio,0,0,a._ratio,0,0);l=c.evalExpression(this.font_size);f=c.evalExpression(this.name);y.setAttribute("data-name",f);p=c.evalExpression(this.imageSrc);r="vacio.gif"===p?this.emptyImage:
this.parent.getImage(p);b.clearRect(0,0,this.w,this.h);q=k=0;this.buttonClick&&(q=k=1);n=e(this.w/2+k)-.5;t=e(this.h/2+q)-.5;r&&(w=r.height||1E8,A=a.getFontMetrics(this.italics+" "+this.bold+" "+l+"px descartesJS_sansserif, Arial, Helvetica, Sans-serif").h,B=""!=f?0<=this.h-w-A-2?!0:!1:!1,m=parseInt((this.w-r.width)/2)+k,v=B?parseInt((this.h-A-r.height+2)/2):parseInt((this.h-r.height)/2)+q,B&&(t=parseInt(this.h-A/2-2),y.style.backgroundColor=this.colorInt.getColor()));r&&r.ready?r!==this.emptyImage&&
r.complete&&(y.style.backgroundImage="url('"+this.image.src+"')",y.style.backgroundPosition=m+"px "+v+"px"):(y.style.backgroundColor=this.colorInt.getColor(),b.fillStyle=this.linearGradient,b.fillRect(0,0,this.w,this.h));this.activeIfValue&&""!=this.imageOver.src&&this.imageOver.ready&&this.over&&(y.style.backgroundImage="url('"+this.imageOver.src+"')",y.style.backgroundPosition=m+"px "+v+"px");this.activeIfValue&&""!=this.imageDown.src&&this.imageDown.ready&&this.buttonClick?(y.style.backgroundImage=
"url('"+this.imageDown.src+"')",y.style.backgroundPosition=m+"px "+v+"px"):this.buttonClick&&!r&&(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+" "+l+"px Arial";b.textAlign="center";b.textBaseline="middle";this.drawTextBorder()&&(b.lineJoin="round",b.lineWidth=parseInt(l/6),b.strokeStyle=this.colorInt.getColor(),b.strokeText(f,n,t));b.fillText(f,n,t);this.underlined&&(s=b.measureText(f).width,b.strokeStyle=
this.color.getColor(),b.lineWidth=e(l/10)||2,b.lineCap="round",b.beginPath(),b.moveTo(parseInt((this.w-s)/2)+k,t+e(l/2)+e(l/5)-1.5),b.lineTo(parseInt((this.w+s)/2)+k,t+e(l/2)+e(l/5)-1.5),b.stroke());this.activeIfValue||(b.fillStyle="rgba(240,240,240,"+160/255+")",b.fillRect(0,0,this.w,this.h));b.restore()};a.Button.prototype.drawTextBorder=function(){this.colorInt.getColor();this.color.getColor();return!(.5>(g(this.colorInt.r-this.color.r)+g(this.colorInt.g-this.color.g)+g(this.colorInt.b-this.color.b))/
255)};a.Button.prototype.buttonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function b(a,c,f){clearInterval(g);e.buttonClick&&e.drawIfValue&&e.activeIfValue&&(c.call(e),a=f?a:100,g=setTimeout(function(){b(a,c)},a))}function c(d){document.body.focus();d.preventDefault();d.stopPropagation();document.activeElement!=document.body&&document.activeElement.blur();e.whichButton=a.whichButton(d);"L"==e.whichButton&&e.activeIfValue&&(e.buttonClick=
!0,e.draw(),e.evaluator.setVariable(e.id,e.evaluator.evalExpression(e.valueExpr)),"calculate"==e.action&&b(2E3,e.buttonPressed,!0),u?(e.canvas.removeEventListener("touchend",f),e.canvas.addEventListener("touchend",f)):(e.canvas.removeEventListener("mouseup",f),e.canvas.addEventListener("mouseup",f)))}function f(a){document.body.focus();if(e.activeIfValue||e.buttonClick)e.buttonClick=!1,e.draw(),"calculate"!=e.action&&e.buttonPressed(),a.preventDefault(),a.stopPropagation(),u?e.canvas.removeEventListener("touchend",
f):e.canvas.removeEventListener("mouseup",f)}function d(a){e.over=!0;e.draw()}function l(a){e.over=!1;e.buttonClick=!1;e.draw()}u=a.hasTouchSupport;var e=this,g;e.container.oncontextmenu=function(){return!1};this.over=this.buttonClick=!1;u?this.container.addEventListener("touchstart",c):(this.container.addEventListener("mousedown",c),this.container.addEventListener("mouseover",d),this.container.addEventListener("mouseout",l))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b,h,l,f,p,r,k,q,s,u,m,v,n,t;a.Spinner=function(b,c){a.Control.call(this,b,c);this.tabindex=++this.parent.tabindex;"_._"==this.name&&(this.name="");"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=
document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.addControlContainer(this.containerControl);t=this.evaluator.parser.parse("1");this.originalIncr=this.incr;
if(0>=this.evaluator.evalExpression(this.decimals)||0==this.evaluator.evalExpression(this.incr)){var f=this.evaluator.evalExpression(this.incr);0<f?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(f).toString()):this.incr=t}this.registerMouseAndTouchEvents();this.init()};a.extend(a.Spinner,a.Control);a.Spinner.prototype.init=function(){e=this.evaluator;var b=e.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(e.evalExpression(this.valueExpr));
var c=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var f=2!==this.parent.version?"":"_____",d=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),l=2+parseInt(this.h/2),g=parseInt(this.w/2-l/2),f=a.getTextWidth(b+f,this.fieldFontSize+"px Arial");this.visible||(g=this.w-l,d=0);g<f&&(g=f);""==b&&(g=0);this.w-g-l<d&&(g=this.w-l-d);0>g&&(g=0);b=this.w-(g+l);this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style",
"width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.setAttribute("id",this.id);this.canvas.setAttribute("width",l+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+g+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.divUp.setAttribute("class","up");this.divUp.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+
l+"px; height : "+this.h/2+"px; left: "+g+"px; top: 0px;");this.divDown.setAttribute("class","down");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+l+"px; height : "+this.h/2+"px; left: "+g+"px; top: "+this.h/2+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_spinner");this.field.setAttribute("class","DescartesSpinnerField");this.field.setAttribute("style","font-family: Arial; font-size: "+
this.fieldFontSize+"px; width : "+b+"px; height : "+this.h+"px; left: "+(l+g)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.visible||(this.field.style.display="none");this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+g+"px; height: "+this.h+"px; line-height: "+this.h+"px;");e.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){e=
this.evaluator;this.label.innerHTML=e.evalExpression(this.name).toString();0>=e.evalExpression(this.decimals)?(g=e.evalExpression(this.incr),0<g?this.originalIncr=this.incr=e.parser.parse(parseInt(g).toString()):this.incr=t):this.incr=0!=e.evalExpression(this.originalIncr)?this.originalIncr:t;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();this.parent.animation.playing&&document.activeElement==this.field||(c=this.field.value,d=this.value,this.value=this.validateValue(e.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value==d&&this.field.value!=c&&(this.value=this.validateValue(c),this.field.value=this.formatOutputValue(this.value)),e.setVariable(this.id,this.value))};a.Spinner.prototype.draw=function(){b=this.ctx;h=
this.canvas.width;l=this.canvas.height;b.fillStyle="#f0f8ff";b.fillRect(0,0,h,l);b.fillStyle=this.linearGradient;b.fillRect(0,0,h,l);this.up?(f="gray",p="#f0f8ff"):(f="#f0f8ff",p="gray");a.drawLine(b,0,0,h,0,f);a.drawLine(b,0,0,0,l/2,f);a.drawLine(b,0,l/2,h,l/2,p);this.down?(f="gray",p="#f0f8ff"):(f="#f0f8ff",p="gray");a.drawLine(b,0,l/2+1,h,l/2+1,f);a.drawLine(b,0,l/2+1,0,l,f);a.drawLine(b,0,l-1,h,l-1,p);r=[parseInt(h/2+1),parseInt(h/5+1),parseInt(h-h/5+1)];k=[parseInt(l/8+1),parseInt(l/8+1+l/4),
parseInt(l/8+1+l/4)];b.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";b.beginPath();b.moveTo(r[0],k[0]);b.lineTo(r[1],k[1]);b.lineTo(r[2],k[2]);b.fill();k=[parseInt(l-l/8),parseInt(l-l/8-l/4),parseInt(l-l/8-l/4)];b.fillStyle=this.activeIfValue?"#d00018":"#aa8888";b.beginPath();b.moveTo(r[0],k[0]);b.lineTo(r[1],k[1]);b.lineTo(r[2],k[2]);b.fill();b.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&b.fillRect(0,0,h,l/2);this.down&&b.fillRect(0,l/2,h,l)};a.Spinner.prototype.validateValue=function(a){e=this.evaluator;
isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=a.toString();a=a.replace(this.parent.decimal_symbol,".");q=a==parseFloat(a)?parseFloat(a):parseFloat(e.evalExpression(e.parser.parse(a)));isNaN(q)&&(q=0);m=e.evalExpression(this.min);v=e.evalExpression(this.max);""===m&&(m=-Infinity);""===v&&(v=Infinity);q<m&&(q=m);q>v&&(q=v);this.discrete&&(s=e.evalExpression(this.incr),q=0==s?0:s*Math.round(q/s));u=e.evalExpression(this.decimals);0>=u&&(u=0);return q=parseFloat(parseFloat(q).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(m);if(k.up||k.down)c.call(k),a=f?a:30,m=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(h,k.increase,!0),k.draw())}function f(c){c.preventDefault();k.whichButton=a.whichButton(c);"L"==k.whichButton&&k.activeIfValue&&(k.down=!0,b(h,k.decrease,!0),k.draw())}function d(a){k.up=!1;clearInterval(m);k.draw();a.preventDefault()}function l(a){k.down=!1;clearInterval(m);
k.draw();a.preventDefault()}function e(a){k.up=!1;clearInterval(m);k.draw();a.preventDefault()}function g(a){k.down=!1;clearInterval(m);k.draw();a.preventDefault()}n=a.hasTouchSupport;var k=this,h=n?500:200,m;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",l);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));k.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b,h,l;a.TextField=function(b,c){a.Control.call(this,b,c);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+
this.name+"'");void 0===this.valueExprString&&(this.valueExprString=this.onlyText?"0":"");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;if(this.answer)if(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answerPattern=this.answer,this.answer=a.buildRegularExpresionsPatterns(this.answer,this.evaluator),this.onlyText){var 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(",")));this.onlyText&&(this.valueExprString.match(/^'/)&&this.valueExprString.match(/'$/)||(this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'")),this.validateValue=function(a){a=a.toString();return"''"==a||"'"==a?"":a&&a.match(/^'/)&&a.match(/'$/)?a.substring(1,a.length-1):a},this.formatOutputValue=function(a){return a.toString()});""==name.trim()&&(name="");this.containerControl=document.createElement("div");
this.field=document.createElement("input");this.label=document.createElement("label");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){e=this.evaluator;var b=e.evalExpression(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(e.evalExpression(this.valueExpr));var c=this.formatOutputValue(this.value);
this.fieldFontSize=a.getFieldFontSize(this.h);var d=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),l=parseInt(this.w/2),g=a.getTextWidth(b,this.fieldFontSize+"px Arial");this.visible||(l=this.w,d=0);l<g&&(l=g);""==b&&(l=0);this.w-l<d&&(l=this.w-d);0>l&&(l=0);b=this.w-l;this.containerControl.setAttribute("class","DescartesTextFieldContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");
this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"TextField");this.field.setAttribute("class","DescartesTextFieldField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+b+"px; height : "+this.h+"px; left: "+l+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.label.setAttribute("class","DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+l+"px; height: "+this.h+
"px; line-height: "+this.h+"px;");this.evaluate&&(this.ok=this.evaluateAnswer());this.evaluator.setVariable(this.id,this.value);this.evaluator.setVariable(this.id+".ok",this.ok);this.oldValue=this.value;this.update()};a.TextField.prototype.update=function(){e=this.evaluator;this.label.innerHTML=e.evalExpression(this.name).toString();this.activeIfValue=0<e.evalExpression(this.activeif);this.drawIfValue=0<e.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=
this.drawIfValue?"block":"none";this.updatePositionAndSize();this.parent.animation.playing&&document.activeElement==this.field||(g=this.field.value,c=this.value,this.value=this.validateValue(e.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value===c&&this.field.value!=g&&(this.value=this.validateValue(g),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;a=a.toString().replace(this.parent.decimal_symbol,".");d=a==parseFloat(a)?parseFloat(a):parseFloat(e.evalExpression(e.parser.parse(a)));isNaN(d)&&(d=0);b=e.evalExpression(this.min);""==b&&(b=-Infinity);h=e.evalExpression(this.max);""==h&&(h=Infinity);this.discrete&&(a=e.evalExpression(this.incr),d=0==a?0:a*Math.round(d/a));return d=parseFloat(parseFloat(d).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(){l=a.hasTouchSupport;var b=this;b.field.oncontextmenu=b.label.oncontextmenu=function(){return!1};l?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(a){b.changeValue(b.field.value,!0)});this.field.addEventListener("keydown",
function(a){b.activeIfValue&&13==a.keyCode&&b.changeValue(b.field.value,!0)});b.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.abs,g,c,d,b,h,l,f,p,r,k,q;a.Menu=function(b,f){this.options="";a.Control.call(this,b,f);g=this.parser;c=this.evaluator;this.ok=0;this.tabindex=++this.parent.tabindex;this.answer&&(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),
this.answer=parseInt(this.answer.split(",")[0].replace("[",""))||0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var d,l=0,e=this.options.length;l<e;l++)d=this.customSplit(this.options[l]),1==d.length?(this.menuOptions.push(d[0]),this.strValue.push(l.toString())):2==d.length&&(this.menuOptions.push(d[0]),
""==d[1]?this.strValue.push(l.toString()):this.strValue.push(d[1]));l=0;for(e=this.menuOptions.length;l<e;l++)this.menuOptions[l].match(/^\[/)&&this.menuOptions[l].match(/\]$/)?this.menuOptions[l]=g.parse(this.menuOptions[l].substring(1,this.menuOptions[l].length-1)):this.menuOptions[l]=g.parse("'"+this.menuOptions[l]+"'");l=0;for(e=this.strValue.length;l<e;l++)this.strValue[l].match(/^\[/)&&this.strValue[l].match(/\]$/)?this.strValue[l]=g.parse(this.strValue[l].substring(1,this.strValue[l].length-
1)):this.strValue[l]=g.parse(this.strValue[l]);this.containerControl=document.createElement("div");this.label=document.createElement("label");this.select=document.createElement("select");l=0;for(e=this.menuOptions.length;l<e;l++)d=document.createElement("option"),d.innerHTML=c.evalExpression(this.menuOptions[l]),this.select.appendChild(d);this.field=document.createElement("input");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);
this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Menu,a.Control);a.Menu.prototype.init=function(b){c=this.evaluator;var f=c.evalExpression(this.name).toString();this.label.innerHTML=f;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var d=0,l=0,e=0;this.value=b?this.value:c.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);b=0;for(var g=this.menuOptions.length;b<g;b++)e=a.getTextWidth(c.evalExpression(this.menuOptions[b]).toString(),
this.fieldFontSize+"px Arial"),e>d&&(d=e,l=b);d+=25;e=a.getTextWidth(this.formatOutputValue(c.evalExpression(this.strValue[l])),this.fieldFontSize+"px Arial")+7;l=a.getTextWidth(f,this.fieldFontSize+"px Arial")+10;""==f&&(l=0);this.visible||(e=0);for(f=this.w-e-l;f<d&&0<l;)l--,f++;for(;f<d&&0<e;)e--,f++;for(;l+f+e+1<this.w;)f++,e++;d=l;b=d+f;e=this.w-b;g=this.formatOutputValue(c.evalExpression(this.strValue[this.indexValue]));this.containerControl.setAttribute("class","DescartesMenuContainer");this.containerControl.setAttribute("style",
"width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index:"+this.zIndex+";");this.label.setAttribute("class","DescartesMenuLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width:"+l+"px; height:"+this.h+"px; line-height:"+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"_menuField");this.field.value=g;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+
this.fieldFontSize+"px; width: "+e+"px; height: "+this.h+"px; left:"+b+"px;");this.field.setAttribute("tabindex",this.tabindex);this.select.setAttribute("id",this.id+"_menuSelect");this.select.setAttribute("class","DescartesMenuSelect");this.select.setAttribute("style","text-align:left; font-size:"+this.fieldFontSize+"px; width: "+f+"px; height: "+this.h+"px; left: "+d+"px; border: 1.5px solid #7a8a99; background-color: #eeeeee;");this.select.setAttribute("tabindex",this.tabindex);this.select.selectedIndex=
this.indexValue;c.setVariable(this.id,parseFloat(g.replace(this.parent.decimal_symbol,".")));this.update()};a.Menu.prototype.update=function(){c=this.evaluator;this.activeIfValue=0<c.evalExpression(this.activeif);this.drawIfValue=0<c.evalExpression(this.drawif);this.field.disabled=this.activeIfValue?!1:!0;this.select.disabled=this.activeIfValue?!1:!0;this.drawIfValue?this.containerControl.style.display="block":(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();
if(!this.parent.animation.playing||document.activeElement!=this.select){this.label.innerHTML=c.evalExpression(this.name).toString();for(var a=0,b=this.menuOptions.length;a<b;a++)this.select.options[a].innerHTML=c.evalExpression(this.menuOptions[a]);this.value=c.getVariable(this.id);isNaN(this.value)&&(this.value=0);this.field.value=this.formatOutputValue(this.value);c.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))}this.ok=this.value==this.answer?
1:0;this.evaluator.setVariable(this.id+".ok",this.ok)};a.Menu.prototype.customSplit=function(a){f=!1;p="";r=0;for(k=-1;r<a.length;){q=a.charAt(r);a.charAt(r-1);if("["===q&&-1===k){if(f||""!=p)p+="\u00a6";k++}else"["===q?k++:"]"===q&&0===k?(f=!0,k--):"]"==a.charAt(r)&&(k=0>k?k:k-1);p+=a.charAt(r);r++}return p.split("\u00a6")};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));d=-1;b=Infinity;for(var c=0,f=this.strValue.length;c<f;c++)h=e(a-parseFloat(this.evaluator.evalExpression(this.strValue[c]))),
h<=b&&(b=h,d=c);return d};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){l=a.hasTouchSupport;var b=this;b.select.oncontextmenu=b.label.oncontextmenu=b.field.oncontextmenu=function(){return!1};l?b.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):b.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",
function(a){b.value=b.evaluator.evalExpression(b.strValue[this.selectedIndex]);b.field.value=b.formatOutputValue(b.value);b.evaluator.setVariable(b.id,b.field.value);b.changeValue();a.preventDefault()});this.field.addEventListener("keydown",function(a){13==a.keyCode&&(b.indexValue=b.getIndex(b.field.value),b.value=b.evaluator.evalExpression(b.strValue[b.indexValue]),b.field.value=b.formatOutputValue(b.indexValue),b.select.selectedIndex=b.indexValue,b.changeValue())});b.field.addEventListener("click",
function(a){this.select();this.focus()});b.select.addEventListener("mouse",function(a){this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=Math.floor,g,c,d,b,h,l,f,p,r,k,q,s,u,m,v,n,t,w,A,B,y;a.Scrollbar=function(b,c){a.Control.call(this,b,c);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");this.orientation=this.w>=this.h?
"h":"v";this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.scrollManipulator=document.createElement("div");this.label=document.createElement("label");this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);
this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.scrollManipulator);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){g=this.evaluator;this.findOffset();0==g.evalExpression(this.decimals)?this.incr=1:this.incr=(g.evalExpression(this.max)-g.evalExpression(this.min))/100;this.value=this.validateValue(g.evalExpression(this.valueExpr));d=this.formatOutputValue(this.value);
b=this.evaluator.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];4==b[0].length&&(this.w=b[0][2],this.h=b[0][3]);this.orientation=this.w>=this.h?"h":"v";this.initScroll(d);this.changeScrollPositionFromValue();this.prePos=this.pos;g.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(b){c=this;g=c.evaluator;var f=g.evalExpression(c.name).toString();c.label.innerHTML=f;var d="v"===c.orientation?parseInt(19+5*(c.h-100)/100):c.h;c.fieldFontSize="v"===c.orientation?
d-parseInt(c.h/20)-1:2!==c.parent.version?a.getFieldFontSize(d):10;var l=a.getTextWidth(b+"_",c.fieldFontSize+"px Arial"),e=c.parent.getSpaceById(c.spaceID).h;c.labelHeight=""==f?0:d;c.fieldHeight=""==c.visible?0:d;if("v"===c.orientation)c.canvasWidth=c.w,c.canvasHeight=c.h-c.labelHeight-c.fieldHeight,18<=c.canvasHeight+c.y-e&&(c.canvasHeight=e),f=0,f=c.fieldHeight,l=f+c.canvasHeight,c.canvasX=0,c.canvasY=c.fieldHeight,c.labelWidth=c.w,c.labelY=l,c.upWidth=c.downW=c.w,c.upHeight=c.downH=15,c.upX=
0,c.upY=c.fieldHeight,c.downX=0,c.downY=l-c.downH,c.fieldWidth=c.w,c.fieldX=0,c.scrollManipulatorW=c.w,c.scrollManipulatorH=parseInt((c.canvasHeight-c.upHeight-c.downH-c.labelHeight-c.fieldHeight)/10),c.scrollManipulatorH=15>c.scrollManipulatorH?15:c.scrollManipulatorH,c.scrollManipulatorLimInf=l-c.downH-c.scrollManipulatorH,c.scrollManipulatorLimSup=f+c.downH;else{d=a.getTextWidth(f,c.fieldFontSize+"px Arial")+10;c.labelWidth=d;c.fieldWidth=l;""==f&&(c.labelWidth=0);c.visible||(c.fieldWidth=0);for(l=
c.w-c.fieldWidth-c.labelWidth;58>l&&0<c.labelWidth;)c.labelWidth--,l++;for(;58>l&&0<c.fieldWidth;)c.fieldWidth--,l++;f=c.labelWidth;d=f+l;c.fieldWidth=c.w-d;c.canvasWidth=l;c.canvasHeight=c.h;c.canvasX=c.labelWidth;c.canvasY=0;c.fieldX=c.canvasWidth+c.labelWidth;c.labelHeight=c.h;c.labelY=0;c.upWidth=c.downW=15;c.upHeight=c.downH=c.h;c.upX=d-c.downW;c.upY=0;c.downX=c.labelWidth;c.downY=0;c.scrollManipulatorW=parseInt((c.canvasWidth-c.upWidth-c.downW)/10);c.scrollManipulatorW=15>c.scrollManipulatorW?
15:c.scrollManipulatorW;c.scrollManipulatorH=c.h;c.scrollManipulatorLimInf=f+c.downW;c.scrollManipulatorLimSup=f+c.canvasWidth-c.downW-c.scrollManipulatorW}c.containerControl.setAttribute("class","DescartesScrollbarContainer");c.containerControl.setAttribute("id",c.id);c.containerControl.setAttribute("style","width: "+c.w+"px; height: "+c.h+"px; left: "+c.x+"px; top: "+c.y+"px; z-index: "+c.zIndex+";");c.canvas.setAttribute("width",c.w+"px");c.canvas.setAttribute("height",c.h+"px");c.canvas.setAttribute("style",
"position: absolute; left: 0px; top: 0px;");c.ctx=c.canvas.getContext("2d");c.divUp.setAttribute("class","DescartesCatcher up");c.divUp.setAttribute("style","width : "+c.upWidth+"px; height : "+c.upHeight+"px; left: "+c.upX+"px; top: "+c.upY+"px;");c.divDown.setAttribute("class","DescartesCatcher down");c.divDown.setAttribute("style","width : "+c.downW+"px; height : "+c.downH+"px; left: "+c.downX+"px; top: "+c.downY+"px;");c.scrollManipulator.setAttribute("class","DescartesCatcher manipulator");c.scrollManipulator.setAttribute("style",
"width : "+c.scrollManipulatorW+"px; height : "+c.scrollManipulatorH+"px;");c.scrollManipulator.style.top=("v"===c.orientation?c.scrollManipulatorLimInf:0)+"px";c.scrollManipulator.style.left=("v"===c.orientation?0:c.scrollManipulatorLimInf)+"px";c.field.setAttribute("type","text");c.field.setAttribute("id",c.id+"scrollbar");c.field.setAttribute("class","DescartesScrollbarField");c.field.setAttribute("style","font-size: "+c.fieldFontSize+"px; width : "+c.fieldWidth+"px; height : "+c.fieldHeight+"px; left: "+
c.fieldX+"px; top: 0px;");c.field.value=b;0===c.fieldHeight&&(c.field.style.display="none");c.label.setAttribute("class","DescartesScrollbarLabel");c.label.setAttribute("style","font-size:"+c.fieldFontSize+"px; width: "+c.labelWidth+"px; height: "+c.labelHeight+"px; line-height: "+c.labelHeight+"px; left: 0px; top:"+c.labelY+"px;")};a.Scrollbar.prototype.update=function(){g=this.evaluator;this.label.innerHTML=g.evalExpression(this.name).toString();0==g.evalExpression(this.decimals)?this.incr=1:this.incr=
(g.evalExpression(this.max)-g.evalExpression(this.min))/100;this.activeIfValue=0<g.evalExpression(this.activeif);this.drawIfValue=0<g.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";this.updatePositionAndSize();var a=this.validateValue(g.getVariable(this.id));a==this.value||0<Math.abs(a-this.value)&&1E-9>Math.abs(a-this.value)||(this.value=a,this.changeScrollPositionFromValue(),
this.prePos=this.pos);this.value=a;this.field.value=this.formatOutputValue(this.value);g.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){c=this;h=c.ctx;f=e(this.w);l=e(this.h);h.fillStyle="#e0e4e8";h.fillRect(0,0,f,l);h.strokeStyle="#7a8a99";c.down&&(h.fillStyle="#ccdcec",h.fillRect(c.downX+.5,c.downY+.5,c.downW,c.downH-1));h.strokeRect(c.downX+.5,c.downY+.5,c.downW,c.downH-1);c.up&&(h.fillStyle="#ccdcec",h.fillRect(c.upX+.5,c.upY-.5,c.upWidth,c.upHeight+1));h.strokeRect(c.upX+
.5,c.upY-.5,c.upWidth,c.upHeight+1);p=4;h.fillStyle="black";h.beginPath();"h"===c.orientation?(h.moveTo(c.downX+p,c.downH/2),h.lineTo(c.downX+c.downW-p,p),h.lineTo(c.downX+c.downW-p,c.downH-p),h.moveTo(c.upX+c.upWidth-p,c.downH/2),h.lineTo(c.upX+p,p),h.lineTo(c.upX+p,c.downH-p),h.fill(),c.activeIfValue&&(r=e(c.pos),h.fillStyle="#ccdcec",h.fillRect(r+.5,0,e(c.scrollManipulatorW),l),h.strokeStyle="#6382bf",h.strokeRect(r+.5,0,e(c.scrollManipulatorW),l),k=e(c.scrollManipulatorW/2),h.beginPath(),h.moveTo(r+
k+.5-2,3),h.lineTo(r+k+.5-2,l-3),h.moveTo(r+k+.5,3),h.lineTo(r+k+.5,l-3),h.moveTo(r+k+.5+2,3),h.lineTo(r+k+.5+2,l-3),h.stroke())):(h.moveTo(c.downX+c.downW/2,c.downY+c.downH-p),h.lineTo(c.downX+p,c.downY+p),h.lineTo(c.downX+c.downW-p,c.downY+p),h.moveTo(c.upX+c.upWidth/2,c.upY+p),h.lineTo(c.upX+p,c.upY+c.upHeight-p),h.lineTo(c.upX+c.upWidth-p,c.upY+c.upHeight-p),h.fill(),c.activeIfValue&&(r=e(c.pos),h.fillStyle="#ccdcec",h.fillRect(0,r+.5,f,e(c.scrollManipulatorH)),h.strokeStyle="#6382bf",h.strokeRect(0,
r+.5,f,e(c.scrollManipulatorH)),k=e(c.scrollManipulatorH/2),h.beginPath(),h.moveTo(3,r+k+.5-2),h.lineTo(f-3,r+k+.5-2),h.moveTo(3,r+k+.5),h.lineTo(f-3,r+k+.5),h.moveTo(3,r+k+.5+2),h.lineTo(f-3,r+k+.5+2),h.stroke()));h.strokeRect(.5,.5,f-1,l-1);c.activeIfValue||(h.fillStyle="rgba(240,240,240,"+160/255+")",h.fillRect(0,0,f,l.h))};a.Scrollbar.prototype.validateValue=function(a){g=this.evaluator;q=a.toString();q=parseFloat(q.replace(this.parent.decimal_symbol,"."));isNaN(q)&&(q=0);this.minimo=g.evalExpression(this.min);
q<this.minimo&&(this.value=null,q=this.minimo);this.maximo=g.evalExpression(this.max);q>this.maximo&&(this.value=null,q=this.maximo);s=this.incr;q=0!=s?q*s/s:0;this.fixed&&(q=parseFloat(parseFloat(q).toFixed(g.evalExpression(this.decimals))));return q};a.Scrollbar.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.incr)};a.Scrollbar.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.incr)};a.Scrollbar.prototype.increase10=function(){p=(this.evaluator.evalExpression(this.max)-
this.evaluator.evalExpression(this.min))/10;"h"==this.orientation?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;"h"==this.orientation?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&&(u=this.validateValue(a),u!=this.value&&(this.value=u,this.field.value=this.formatOutputValue(u),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){g=this.evaluator;m=this.scrollManipulatorLimInf;v=this.scrollManipulatorLimSup;n=g.evalExpression(this.min);t=g.evalExpression(this.max);
s=this.incr;u=e((this.pos-m)*(t-n)/(v-m)/s)*s+n;u!=this.value&&(this.value=u,this.field.value=this.formatOutputValue(u),g.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){g=this.evaluator;m=this.scrollManipulatorLimInf;v=this.scrollManipulatorLimSup;n=g.evalExpression(this.min);t=g.evalExpression(this.max);s=this.incr;this.pos=(this.value-n)*(v-m)/(t-n)+m;"h"==this.orientation?
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(v);(t.up||t.down||t.canvasClick)&&1E-7<Math.abs(t.value-d)&&(c.call(t),a=f?a:30,v=setTimeout(function(){b(a,c,!1,d)},a))}function c(f){f.preventDefault();t.whichButton=a.whichButton(f);"L"==t.whichButton&&t.activeIfValue&&(t.clickPos=t.getCursorPosition(f),t.canvasClick=!0,"h"==t.orientation?t.clickPos.x<t.prePos?
b(u,t.decrease10,!0,t.minimo):b(u,t.increase10,!0,t.maximo):t.clickPos.y<t.prePos?b(u,t.increase10,!0,t.maximo):b(u,t.decrease10,!0,t.minimo))}function f(a){t.canvasClick=!1;clearInterval(v);a.preventDefault()}function d(a){!0==t.canvasClick&&(t.clickPos=t.getCursorPosition(a),a.preventDefault())}function l(a){t.activeIfValue&&(t.scrollClick=!0,t.initPos=t.getCursorPosition(a),window.addEventListener("mouseup",g),window.addEventListener("mousemove",h),a.preventDefault())}function e(a){t.activeIfValue&&
(t.scrollClick=!0,t.initPos=t.getCursorPosition(a),window.addEventListener("touchend",k),window.addEventListener("touchmove",onToucheMove_scrollManipulator),a.preventDefault())}function g(a){t.scrollClick=!1;t.prePos=t.pos;window.removeEventListener("mouseup",g,!1);window.removeEventListener("mousemove",h,!1);a.preventDefault()}function k(a){t.scrollClick=!1;t.prePos=t.pos;window.removeEventListener("touchend",k,!1);window.removeEventListener("touchmove",h,!1);a.preventDefault()}function h(a){var b=
t.getCursorPosition(a);"h"==t.orientation?(t.pos=t.prePos-(t.initPos.x-b.x),t.pos<t.scrollManipulatorLimInf&&(t.pos=t.scrollManipulatorLimInf),t.pos>t.scrollManipulatorLimSup&&(t.pos=t.scrollManipulatorLimSup),t.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+t.scrollManipulatorW+"px; height : "+t.h+"px; left: "+t.pos+"px; top: 0px;")):(t.pos=t.prePos-(t.initPos.y-b.y),t.pos>t.scrollManipulatorLimInf&&(t.pos=t.scrollManipulatorLimInf),
t.pos<t.scrollManipulatorLimSup&&(t.pos=t.scrollManipulatorLimSup),t.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+t.w+"px; height : "+t.scrollManipulatorH+"px; left: 0px; top: "+t.pos+"px;"));t.changeValueForScrollMovement();a.preventDefault()}function m(c){c.preventDefault();t.whichButton=a.whichButton(c);"L"==t.whichButton&&t.activeIfValue&&(t.up=!0,b(u,t.increase,!0,t.maximo))}function p(c){c.preventDefault();t.whichButton=
a.whichButton(c);"L"==t.whichButton&&t.activeIfValue&&(t.down=!0,b(u,t.decrease,!0,t.minimo))}function r(a){t.up=!1;clearInterval(v);a.preventDefault()}function q(a){t.down=!1;clearInterval(v);a.preventDefault()}function n(a){t.up=!1;clearInterval(v);a.preventDefault();t.draw()}function s(a){t.down=!1;clearInterval(v);a.preventDefault();t.draw()}w=a.hasTouchSupport;var t=this,u=w?500:200,v;t.canvas.oncontextmenu=t.divUp.oncontextmenu=t.divDown.oncontextmenu=t.label.oncontextmenu=t.field.oncontextmenu=
t.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&t.changeValue(t.field.value)});w?this.canvas.addEventListener("touchstart",c):this.canvas.addEventListener("mousedown",c);w||this.divDown.addEventListener("mouseout",q);w?window.addEventListener("touchend",f):window.addEventListener("mouseup",f);w?this.canvas.addEventListener("touchmove",d):this.canvas.addEventListener("mousemove",d);w?this.scrollManipulator.addEventListener("touchstart",
e):this.scrollManipulator.addEventListener("mousedown",l);w?this.divUp.addEventListener("touchstart",m):this.divUp.addEventListener("mousedown",m);w?this.divDown.addEventListener("touchstart",p):this.divDown.addEventListener("mousedown",p);w||this.divUp.addEventListener("mouseout",r);w||this.divDown.addEventListener("mouseout",q);w?window.addEventListener("touchend",n):window.addEventListener("mouseup",n);w?window.addEventListener("touchend",s):window.addEventListener("mouseup",s)};a.Scrollbar.prototype.findOffset=
function(){A=this.containerControl;this.offsetTop=this.offsetLeft=0;B=this.containerControl.style.display;for(this.containerControl.style.display="block";A;)this.offsetLeft+=A.offsetLeft||0,this.offsetTop+=A.offsetTop||0,A=A.parentNode;this.containerControl.style.display=B};a.Scrollbar.prototype.getCursorPosition=function(b){y=a.getCursorPosition(b);return{x:y.x-this.offsetLeft,y:y.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Audio=function(c,
d){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,c,d);var b=this,e=b.evaluator.evalExpression(b.expresion);4==e[0].length?(b.w=e[0][2],b.h=e[0][3]):(b.w=200,b.h=28);b.audio=b.parent.getAudio(b.file);b.autoplay&&(b.audio.setAttribute("autoplay","autoplay"),b.audio.play());b.loop&&b.audio.setAttribute("loop","loop");b.controls&&b.audio.setAttribute("controls","controls");b.audio.setAttribute("style","position: absolute; width: "+b.w+"px; left: "+b.x+"px; top: "+b.y+"px; z-index: "+
b.zIndex+";");b.addControlContainer(b.audio);b.evaluator.setFunction(b.id+".play",function(){b.audio.play();return 0});b.evaluator.setFunction(b.id+".pause",function(){b.audio.pause();return 0});b.evaluator.setFunction(b.id+".stop",function(){b.audio.pause();return b.audio.currentTime=0});b.audio.addEventListener("timeupdate",function(a){b.evaluator.setVariable(b.id+".currentTime",b.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 g;a.Audio.prototype.update=function(){e=this.evaluator;(g=0<e.evalExpression(this.drawif))?this.audio.style.display="block":(this.audio.style.display="none",g!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=g;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e;a.Video=function(c,d){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,c,d);var b=this;e=b.evaluator;var g=b.evaluator.evalExpression(b.expresion);
4==g[0].length?(b.w=g[0][2],b.h=g[0][3]):(b.w=null,b.h=null);b.video=document.createElement("video");b.autoplay&&b.video.setAttribute("autoplay","autoplay");b.loop&&b.video.setAttribute("loop","loop");b.controls&&b.video.setAttribute("controls","controls");b.poster&&b.video.setAttribute("poster",b.poster);b.w&&(b.video.setAttribute("width",b.w),b.video.setAttribute("height",b.h));b.video.setAttribute("style","position: absolute; overflow: hidden; left: "+b.x+"px; top: "+b.y+"px;");var g=b.file,l=
g.lastIndexOf(".");-1!=l&&(g=b.file.substring(0,l));b.video.canPlayType("video/mp4")&&(l=document.createElement("source"),l.setAttribute("src",g+".mp4"),l.setAttribute("type","video/mp4"),b.video.appendChild(l));b.video.canPlayType("video/ogg")&&(l=document.createElement("source"),l.setAttribute("src",g+".ogg"),l.setAttribute("type","video/ogg"),b.video.appendChild(l),l=document.createElement("source"),l.setAttribute("src",g+".ogv"),l.setAttribute("type","video/ogg"),b.video.appendChild(l));b.video.canPlayType("video/webm")&&
(l=document.createElement("source"),l.setAttribute("src",g+".webm"),l.setAttribute("type","video/webm"),b.video.appendChild(l));b.addControlContainer(b.video);b.evaluator.setFunction(b.id+".play",function(){b.video.play();return 0});b.evaluator.setFunction(b.id+".pause",function(){b.video.pause();return 0});b.evaluator.setFunction(b.id+".stop",function(){b.video.pause();return b.video.currentTime=0});b.video.addEventListener("timeupdate",function(a){b.evaluator.setVariable(b.id+".currentTime",b.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 g;a.Video.prototype.update=function(){e=this.evaluator;g=0<e.evalExpression(this.drawif);0<e.evalExpression(this.drawif)?this.video.style.display="block":(this.video.style.display="none",g!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=g;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,
g;a.TextArea=function(c,d){this.font="Monospaced,PLAIN,12";a.Control.call(this,c,d);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 b=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();b&&"simpleText"!=b.type&&(this.answer=this.text.hasFormula?"":b.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(){g=this.answer?28:8;e=this.evaluator;var c;c=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-g)+"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;' >"+
c+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-g)+"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 c=document.createElement("canvas");c.setAttribute("width",20);c.setAttribute("height",16);var d=c.getContext("2d");this.canvas=c;this.ctx=d;this.createGradient(20,16);d.lineWidth=1;d.fillStyle="white";d.fillRect(0,0,20,16);d.fillStyle=this.linearGradient;d.fillRect(0,0,20,16);a.drawLine(d,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(d,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(d,1,0,1,16,"rgba(0,0,0,"+8/255+")");this.imageUnPush=c.toDataURL();d.fillStyle="white";d.fillRect(0,
0,20,16);d.fillStyle=this.linearGradient;d.fillRect(0,0,20,16);a.drawLine(d,0,0,0,14,"gray");a.drawLine(d,0,0,19,0,"gray");d.fillStyle="rgba(0, 0, 0,"+24/255+")";d.fillRect(0,0,this.w,this.h);this.imagePush=c.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(b){b.preventDefault();d.showButton.style.backgroundImage="url("+d.imageUnPush+")"}var d=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();d.showAnswer=!d.showAnswer;d.textAreaAnswer.style.display=d.showAnswer?"block":"none";d.showButton.childNodes[0].childNodes[0].textContent=d.showAnswer?
"T":"S";d.showButton.style.backgroundImage="url("+d.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 d=a.getContext("2d");d.fillStyle="white";d.strokeStyle="black";d.lineWidth=1;d.fillRect(0,0,this.w,this.h);d.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,g,c,d,b,h,l,f,p,r;a.GraphicControl=function(b,f){c=b.evaluator.parser;this.text=this.spaceID="";this.size=c.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,f);this.touchId=null;this.font=a.convertFont(this.font);if(this.constraintExpr){this.constraint=c.parse(this.constraintExpr);"(expr)"==this.constraint.type&&(this.constraint=c.parse(this.constraintExpr.substring(1,
this.constraintExpr.length-1)));if("compOperator"==this.constraint.type){var d=this.constraint.childs[0],l=this.constraint.childs[1];"identifier"!=d.type||"y"!=d.value||l.contains("y")?"identifier"!=d.type||"x"!=d.value||l.contains("x")?this.newt=new a.R2Newton(this.evaluator,this.constraint):(this.evalConstraint=this.evalConstraintY,this.constraint=l):(this.evalConstraint=this.evalConstraintX,this.constraint=l)}else this.constraint=null;p=new a.R2(0,0)}this.container=this.getContainer();this.mouseCacher=
document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("dragged",!0);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);this.registerMouseAndTouchEvents();this.xString=this.id+".x";this.yString=this.id+".y";this.activoString=this.id+".activo";this.activeString=this.id+".active";""!==this.space.id&&2!==b.version?(this.mxString=
this.space.id+".mouse_x",this.myString=this.space.id+".mouse_y",this.mclickedString=this.space.id+".mouse_clicked",this.mclicizquierdoString=this.space.id+".clic_izquierdo"):(this.mxString="mouse_x",this.myString="mouse_y",this.mclickedString="mouse_clicked",this.mclicizquierdoString="clic_izquierdo");this.init()};a.GraphicControl.prototype.init=function(){g=this.evaluator;r=a.hasTouchSupport;var b=g.evalExpression(this.expresion);this.x=b[0][0];this.y=b[0][1];g.setVariable(this.xString,this.x);g.setVariable(this.yString,
this.y);""==this.imageSrc||this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.width=2*g.evalExpression(this.size),this.height=2*g.evalExpression(this.size)):(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,this.height=this.image.height);this._w=r&&70>this.width?70:this.width;this._h=r&&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";g.setVariable(this.activoString,0);g.setVariable(this.activeString,0);this.setImage=!1;this.update()};a.GraphicControl.prototype.update=function(){g=this.evaluator;this.activeIfValue=0<g.evalExpression(this.activeif);this.drawIfValue=0<g.evalExpression(this.drawif);this.x=g.getVariable(this.xString);this.y=g.getVariable(this.yString);
d=this.space.getAbsoluteX(this.x);b=this.space.getAbsoluteY(this.y);this.mouseCacher.style.display=this.activeIfValue?"block":"none";this.mouseCacher.style.left=parseInt(d-this._w/2)+"px";this.mouseCacher.style.top=parseInt(b-this._h/2)+"px";this.constraint&&this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=function(){g=this.evaluator;this.drawIfValue&&(l=this.ctx,f=this.space.backgroundCtx,d=parseInt(this.space.getAbsoluteX(this.x))+.5,b=parseInt(this.space.getAbsoluteY(this.y))+
.5,""!=this.text&&this.drawText(d,b),this.image.ready?(this.image.complete&&!this.setImage&&l.drawImage(this.image,parseInt(d-this.image.width/2),parseInt(b-this.image.height/2)),this.trace&&(f.save(),f.translate(d,b),f.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),f.beginPath(),f.arc(0,0,1,0,e,!1),f.restore(),f.lineWidth=1,f.strokeStyle=this.trace.getColor(),f.stroke())):(l.beginPath(),l.arc(d,b,parseInt(this.width/2),0,e,!1),l.fillStyle=this.colorInt.getColor(),l.fill(),l.lineWidth=
1,l.strokeStyle=this.color.getColor(),l.stroke(),this.active&&(l.beginPath(),l.arc(d,b,parseInt(this.width/2)-2,0,e,!1),l.strokeStyle=this.colorInt.borderColor(),l.stroke()),this.trace&&(f.lineWidth=1,f.strokeStyle=this.trace.getColor(),f.beginPath(),f.arc(d,b,parseInt(this.width/2),0,e,!1),f.stroke())))};a.GraphicControl.prototype.evalConstraint=function(){p.set(this.x,this.y);h=this.newt.findZero(p,1/this.space.scale,!0);this.x=h.x;this.y=h.y;this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,
this.y)};a.GraphicControl.prototype.evalConstraintX=function(){var a=this.evaluator.getVariable("x");this.evaluator.setVariable("x",this.x);this.y=this.evaluator.evalExpression(this.constraint);this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,this.y);this.evaluator.setVariable("x",a)};a.GraphicControl.prototype.evalConstraintY=function(){var a=this.evaluator.getVariable("y");this.evaluator.setVariable("y",this.y);this.x=this.evaluator.evalExpression(this.constraint);
this.evaluator.setVariable(this.xString,this.x);this.evaluator.setVariable(this.yString,this.y);this.evaluator.setVariable("y",a)};a.GraphicControl.prototype.drawText=function(a,b){l=this.ctx;g=this.evaluator;l.fillStyle=this.color.getColor();l.font=this.font;l.textBaseline="alphabetic";l.fillText(g.evalExpression(this.text[0],g.evalExpression(this.decimals),this.fixed),parseInt(a+1+this.width/2),parseInt(b-1-this.height/2))};a.GraphicControl.prototype.getContainer=function(){for(var a=this.parent.spaces,
b,c=0,f=a.length;c<f;c++)if(b=a[c],b.id==this.spaceID)return b.addCtr(this),this.zIndex=b.zIndex,this.space=b,b.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.activoString,0);this.evaluator.setVariable(this.activeString,0)};a.GraphicControl.prototype.registerMouseAndTouchEvents=function(){function b(c){document.body.focus();c.preventDefault();
h.whichButton=a.whichButton(c);"L"==h.whichButton&&h.activeIfValue&&h.over&&(h.parent.deactivateGraphiControls(),h.click=!0,h.active=!0,h.evaluator.setVariable(h.activoString,1),h.evaluator.setVariable(h.activeString,1),h.evaluator.setVariable(h.mclickedString,0),h.evaluator.setVariable(h.mclicizquierdoString,0),h.posAnte=h.getCursorPosition(c),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},h.evaluator.setVariable(h.mxString,h.space.getRelativeX(h.posAnte.x)),h.evaluator.setVariable(h.myString,
h.space.getRelativeY(h.posAnte.y)),h.parent.update(),window.addEventListener("mouseup",f),window.addEventListener("mousemove",d))}function c(a){document.body.focus();a.preventDefault();h.activeIfValue&&(h.parent.deactivateGraphiControls(),h.click=!0,h.active=!0,h.evaluator.setVariable(h.activoString,1),h.evaluator.setVariable(h.activeString,1),h.evaluator.setVariable(h.mclickedString,0),h.evaluator.setVariable(h.mclicizquierdoString,0),h.posAnte=h.getCursorPosition(a),h.prePos={x:h.space.getAbsoluteX(h.x),
y:h.space.getAbsoluteY(h.y)},h.evaluator.setVariable(h.mxString,h.space.getRelativeX(h.posAnte.x)),h.evaluator.setVariable(h.myString,h.space.getRelativeY(h.posAnte.y)),h.parent.update(),window.addEventListener("touchmove",d),window.addEventListener("touchend",f))}function f(b){document.body.focus();b.preventDefault();h.touchId=null;h.evaluator.setVariable(h.mclickedString,1);h.evaluator.setVariable(h.mclicizquierdoString,1);if(h.activeIfValue||h.active)h.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",
d,!1),window.removeEventListener("touchend",f,!1)):(window.removeEventListener("mouseup",f,!1),window.removeEventListener("mousemove",d,!1)),h.evaluator.setVariable(h.mxString,h.space.getRelativeX(h.posAnte.x)+h.x),h.evaluator.setVariable(h.myString,h.space.getRelativeY(h.posAnte.y)+h.y),h.parent.update(),h.mouseCacher.style.left=h.space.getAbsoluteX(h.x)-h._w/2+"px",h.mouseCacher.style.top=h.space.getAbsoluteY(h.y)-h._h/2+"px"}function d(a){a.preventDefault();a.touchId=h.touchId;h.evaluator.setVariable(h.mclickedString,
0);h.evaluator.setVariable(h.mclicizquierdoString,0);p=h.getCursorPosition(a);h.posX=h.prePos.x-(h.posAnte.x-p.x);h.posY=h.prePos.y-(h.posAnte.y-p.y);h.evaluator.setVariable(h.xString,h.space.getRelativeX(h.posX));h.evaluator.setVariable(h.yString,h.space.getRelativeY(h.posY));h.evaluator.setVariable(h.mxString,h.space.getRelativeX(h.posAnte.x)+h.space.getRelativeX(h.posX));h.evaluator.setVariable(h.myString,h.space.getRelativeY(h.posAnte.y)+h.space.getRelativeY(h.posY));10<Date.now()-g&&(h.parent.updateControls(),
h.parent.update(),g=Date.now())}function l(a){h.over=!0}function e(a){h.over=!1;h.click=!1}var g=0,h=this;this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=function(){return!1};a.hasTouchSupport?this.mouseCacher.addEventListener("touchstart",c):(this.mouseCacher.addEventListener("mousedown",b),this.mouseCacher.addEventListener("mouseover",l),this.mouseCacher.addEventListener("mouseout",e));var p};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var b;if(a.touchId)for(c=
0,f=a.touches.length;c<f;c++){if(a.touches[c].identifier==a.touchId){b=a.touches[c];break}}else for(var c=0,f=a.touches.length;c<f;c++)if(a.target==a.touches[c].target){b=a.touches[c];this.touchId=b.identifier;break}mouseX=b.pageX;mouseY=b.pageY}else void 0!=a.pageX&&void 0!=a.pageY?(mouseX=a.pageX,mouseY=a.pageY):(mouseX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,mouseY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:mouseX-(this.space.container.offsetLeft+
this.space.container.parentNode.offsetLeft),y:mouseY-(this.space.container.offsetTop+this.space.container.parentNode.offsetTop)}};return a}(descartesJS||{}),descartesJS=function(a,e){var g,c,d,b,h,l,f,p,r,k;if(a.loadLib)return a;var q,s,u,m,v,n,t,w,A=/[\w-//]*(\.png|\.jpg|\.gif|\.svg)/gi,B,y,D,E,C,z,H,I,G,K,x,L,F,M,N,J,R,S,P,Q,O;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],s=e[u],s){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[s]=parseInt(m);break;case "about":case "config":case "init":case "clear":b[s]="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],s=e[u],s){case "type":case "id":case "cID":case "file":v[s]=m;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":v[s]="true"===e[m];break;case "bg_display":case "render":v[s]=e[m];break;case "net":case "net10":case "axes":case "text":v[s]=""!=m?"false"===e[m]?"":new a.Color(m,this.parent.evaluator):"";break;case "x_axis":case "y_axis":v[s]="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":q=m;q="%"===q[q.length-1]?(this.parent.container.width*parseFloat(q)/100).toString():m;v.xExpr=this.parser.parse(q);break;case "y":q=m;q="%"===q[q.length-1]?(this.parent.container.height*parseFloat(q)/100).toString():m;v.yExpr=this.parser.parse(q);break;case "width":q=m;"%"===q[q.length-1]?(v.wExpr=q,q=this.parent.container.width*parseFloat(q)/100):(q=parseFloat(m),q!=m&&(q=this.parent.container.width));v.w=q;break;case "height":q=m;"%"===q[q.length-
1]?(v.hExpr=q,q=this.parent.container.height*parseFloat(q)/100):(q=parseFloat(m),q!=m&&(q=this.parent.container.height));v.h=q;break;case "drawif":""!=m&&(v.drawif=this.parser.parse(m));break;case "scale":q=parseFloat(m);isNaN(q)&&(q=48);v.scale=q;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={type:"numeric"};b=this.split(b);for(var c=0,f=b.length;c<f;c++)switch(u=b[c][0],m=b[c][1],s=e[u],s){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[s]=m;break;
case "gui":case "region":case "action":case "msg_pos":case "poster":n[s]=e[m];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":n[s]="true"===e[m];break;case "color":case "colorInt":case "trace":n[s]=new a.Color(m,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":""!=m&&(n[s]=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),l=0,h=d.length;l<h;l++)d[l]=this.parser.parse(d[l],!1);n.text=d;break;default:l=u.indexOf(".");d=e[u.substring(0,l)];l=e[u.substring(l+1)];if("parameter"===d&&"font"===l){n.parameterFont=m;break}else if("Explanation"===d&&"font"===l){n.ExplanationFont=m;break}else if("tooltip"===d&&"font"===l){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){t={rotateExp:d,parameter:"t"};b=this.split(b);d=0;for(var l=b.length;d<l;d++)if(u=b[d][0],m=b[d][1],s=e[u],""!=m)switch(s){case "type":case "align":t[s]=e[m];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":t[s]="true"===e[m];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":t[s]="false"===e[m]?"":new a.Color(m,
this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":case "init":case "end":t[s]=m;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "opacity":case "inirot":case "inipos":case "range":""!=m&&(t[s]=this.parser.parse(m));break;case "space":t.spaceID=m;break;case "expresion":""!=m&&("macro"!=t.type?(t.expresion=this.parser.parse(m),t.expresionString=m):t.expresion=m);break;case "text":t.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(A)&&(h="'"+h+"'");t.file=this.parser.parse(h);break;case "border":""!=m&&"false"!=e[m]&&(t.border=new a.Color(m,this.parent.evaluator));break;default:if(void 0!=t.family&&u.substring(0,t.family.length+1)===t.family+"."){switch(e[u.substring(t.family.length+1)]){case "interval":""!=m&&(t.family_interval=this.parser.parse(m));break;case "steps":""!=m&&(t.family_steps=
this.parser.parse(m))}break}if(void 0!=t.parameter&&u.match(t.parameter+".")){t.parameter!==u.substring(0,u.indexOf(t.parameter)+t.parameter.length)&&(t.parameter=u.substring(0,u.indexOf(t.parameter)+t.parameter.length));switch(e[u.substring(t.parameter.length+1)]){case "interval":""!=m&&(t.parameter_interval=this.parser.parse(m));break;case "steps":""!=m&&(t.parameter_steps=this.parser.parse(m))}break}console.log("----- attributo del graphic no identificado: <"+u+"> valor: <"+m+"> -----")}c&&(t.abs_coord=
c);f&&(t.background=f);switch(t.type){case "text":return new a.Text(this.parent,t);case "image":return new a.Image(this.parent,t);case "point":return new a.Point(this.parent,t);case "polygon":return new a.Polygon(this.parent,t);case "arc":return new a.Arc(this.parent,t);case "segment":return new a.Segment(this.parent,t);case "arrow":return new a.Arrow(this.parent,t);case "macro":return new a.Macro(this.parent,t);case "curve":return new a.Curve(this.parent,t);case "equation":return new a.Equation(this.parent,
t);case "sequence":return new a.Sequence(this.parent,t);case "fill":return new a.Fill(this.parent,t);case "generic":return new a.Generic(this.parent,t)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,f,d){t={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],s=e[u],s){case "type":case "model":t[s]=e[m];break;case "background":case "fixed":case "edges":t[s]="true"===e[m];break;case "color":case "backcolor":t[s]=new a.Color(m,this.parent.evaluator);
break;case "type":case "model":t[s]=e[m];break;case "background":case "fixed":case "edges":case "split":t[s]="true"===e[m];break;case "color":case "backcolor":t[s]=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":""!=m&&(t[s]=this.parser.parse(m));break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":t[s]=m;break;case "space":t.spaceID=m;break;case "expresion":"macro"!=
t.type&&"curve"!=t.type&&"surface"!=t.type?(t.expresion=this.parser.parse(m),t.expresionString=m):t.expresion=m.replace(/\\n/g," ").replace(/;/g," ");break;case "text":d=this.parseText(m);for(var l=0,h=d.length;l<h;l++)d[l]=this.parser.parse(d[l],!1);t.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+"'");t.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":""!=
m&&(t[s]=this.parser.parse(m));break;case "family":case "parameter":case "font":case "name":t[s]=m;break;case "space":t.spaceID=m;break;case "expresion":"macro"!=t.type&&"curve"!=t.type&&"surface"!=t.type?(t.expresion=this.parser.parse(m),t.expresionString=m):t.expresion=m;break;case "text":d=this.parseText(m);l=0;for(h=d.length;l<h;l++)d[l]=this.parser.parse(d[l],!1);t.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+"'");t.file=this.parser.parse(d);break;default:if(void 0!==t.family&&u.substring(0,t.family.length+1)===t.family+"."){"interval"===e[u.substring(t.family.length+1)]?""!=m&&(t.family_interval=this.parser.parse(m)):""!=m&&(t.family_steps=this.parser.parse(m));break}console.log("----- attributo del graphic3D no identificado: <"+u+"> valor: <"+m+"> -----")}switch(t.type){case "point":return new a.Point3D(this.parent,t);case "segment":return new a.Segment3D(this.parent,t);case "polygon":return new a.Polygon3D(this.parent,
t);case "curve":return new a.Curve3D(this.parent,t);case "triangle":return new a.Triangle3D(this.parent,t);case "face":return new a.Face3D(this.parent,t);case "polireg":return new a.Polireg3D(this.parent,t);case "surface":return new a.Surface3D(this.parent,t);case "text":return new a.Text3D(this.parent,t);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,
t);case "macro":return new a.Macro3D(this.parent,t);default:console.log(t.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],s=e[u],s){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":w[s]=m.replace(/&squot;/g,"'");break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":w[s]=
"true"===e[m];break;case "size":case "rows":case "columns":w[s]=this.parser.parse(m);break;case "evaluate":case "execution":case "msg_pos":case "action":w[s]=e[m];break;case "type":w[s]=e[m];break;case "x":case "y":case "width":case "height":w[s]=this.parser.parse(m);break;default:var d=u.indexOf("."),l=e[u.substring(0,d)],d=e[u.substring(d+1)];if("parameter"===l&&"font"===d){w.parameterFont=m;break}console.log("----- attributo de auxiliar no identificado: <"+u+"> valor: <"+m+"> -----")}w.type&&"rectangle"==
w.type?this.parent.auxiliaries.push(new a.Rectangle(this.parent,w)):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){B=b.action;y=b.parent;D=b.parameter;if(B)switch(B){case "message":return new a.Message(y,D);case "calculate":return new a.Calculate(y,D);case "openURL":return new a.OpenURL(y,
D);case "openScene":return new a.OpenScene(y,D);case "about":return new a.About(y,D);case "config":return new a.Config(y,D);case "init":return new a.Init(y,D);case "clear":return new a.Clear(y,D);case "animate":return new a.Animate(y,D);case "initAnimation":return new a.InitAnimation(y,D);case "playAudio":return new a.PlayAudio(y,D);default:console.log("----- Accion no soportada aun: <"+B+"> -----")}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],s=e[u],s){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[s]=m.replace(/&squot;/g,"'");break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[s]="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);c=g="";d=0;b="#536891";
h="white";l="left";f="";p="SansSerif,BOLD,20";r="SansSerif,PLAIN,18";k=void 0;for(var q=0,s=e.length;q<s;q++)switch(u=e[q][0],m=e[q][1],u){case "title":g=m;break;case "subtitle":c=m;break;case "subtitlines":d=m;break;case "bgcolor":""!=m&&(b=(new a.Color(m,this.parent.evaluator)).getColor());break;case "fgcolor":""!=m&&(h=(new a.Color(m,this.parent.evaluator)).getColor());break;case "align":""!=m&&(l=m);break;case "titleimage":f=m;break;case "titlefont":p=""!=m?a.convertFont(m):a.convertFont(p);break;
case "subtitlefont":r=""!=m?a.convertFont(m):a.convertFont(r);break;default:console.log("----- attributo de la pleca no identificado: <"+u+">  <"+m+"> -----")}if(""===g&&""===c)return document.createElement("div");K=r.substring(0,r.indexOf("px"));K=K.substring(K.lastIndexOf(" "));""!=f&&(x=this.parent.getImage(f),L=x.height);k=document.createElement("div");k.setAttribute("id","descartesPleca");L?(k.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+l+"; width: "+(n-30)+"px; height: "+
(L-16)+"px; background: "+b+"; color: "+h+"; 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: "+l+"; width: "+(n-30)+"px; background: "+b+"; color: "+h+"; 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: "+p+"; overflow: hidden; white-space: nowrap;");F.innerHTML=g;M=document.createElement("div");if(1===parseInt(d)){P=0;N=document.createElement("div");N.innerHTML=c;document.body.appendChild(N);R=K;do R-=P,N.setAttribute("style","padding: 0px; margin: 0px; font: "+r+"; font-size: "+R+"px; width: "+(n-30)+"px; line-height: "+R+"px;"),J=N.offsetHeight,S=J/R,P=1;while(1<S&&8<R);document.body.removeChild(N);M.setAttribute("style",
"padding: 0px; margin: 0px; font: "+r+"; font-size: "+R+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else M.setAttribute("style","padding: 0px; margin: 0px; font: "+r+"; line-height: 110%;");M.innerHTML=c;k.appendChild(F);k.appendChild(M);k.imageHeight=L;return k};a.LessonParser.prototype.split=function(a){if("string"!=typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");E=[];z=C=0;H=!1;I=0;for(G=!1;C<a.length;)" "!==a.charAt(C)||H||C++," "===a.charAt(C)||H||(H=!0,I=C),"="!==a.charAt(C)||
"'"!==a.charAt(C+1)||G||(G=!0,E[z]=[a.substring(I,C)],I=C+2,C+=2),G&&"'"===a.charAt(C)&&(H=G=!1,E[z].push(a.substring(I,C)),z++),"="!==a.charAt(C)||"'"===a.charAt(C+1)||G||(E[z]=[a.substring(I,C)],I=C+1,C++,Q=a.substring(C).indexOf("="),-1===Q?O=Q=a.length:(Q+=C,O=a.substring(C,Q).lastIndexOf(" "),O=-1===O?a.length:O+C),E[z].push(a.substring(I,O)),z++,H=!1,C=O),C++;return E};a.LessonParser.prototype.parseText=function(b){b=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){u=[];u.type="matrix";u.rows=a;u.cols=b;var c;v=0;for(n=b;v<n;v++){c=[];m=0;for(t=a;m<t;m++)c.push(0);u[v]=c}return u}function g(a,b){q=a.rows;s=a.cols;u=e(q,s);var c;for(v=0;v<q;v++)for(m=0;m<s;m++){for(n=c=0;n<s;n++)c+=a[n][v]*b[m][n];u[m][v]=c}return u}function c(a,b,c){for(var f=e(c.length-1,c.length-1),d=0,l=f.length;d<l;d++)for(var h=0;h<l;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 d(a){if(1<
a.cols){for(var b=0,f=1,l=0,e=a.cols;l<e;l++)b+=f*a[0][l]*d(c(0,l,a)),f=-f;return b}return a[0][0]}if(a.loadLib)return a;var b,h={},l=Math.floor,f,p,r,k;a.fullDecimals=!1;a.Node=function(a,b){this.sep="";this.type=a;this.value=b;this.parent=null;this.childs=[]};a.Node.prototype.getRoot=function(){return null===this.parent?this:this.parent.getRoot()};a.Node.prototype.addChild=function(a){a.parent=this;this.childs.push(a)};a.Node.prototype.replaceLastChild=function(a){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="-",r=new a.Node("compOperator","=="),k=new a.Node("number","0"),r.addChild(this),r.addChild(k),p=this.getRoot(),p.setAllEvaluateFunction(),p):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&&void 0==a.length)return a.evaluate(b);void 0==a&&(c||b.matrices[this.value]?a=b.matrices[this.value]:b.vectors[this.value]&&(a=b.vectors[this.value]));return void 0!==a?a:0}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1===this.childs[0].childs.length){var f,k;this.evaluate=function(a){f=this.childs[0].childs[0].evaluate(a);try{return k=a.vectors[this.value][0>f?0:l(f)],void 0!==k?k:0}catch(b){return 0}}}else if("identifier"===this.type&&"square_bracket"===
this.childs[0].type&&1<this.childs[0].childs.length){var p,r;this.evaluate=function(a){p=this.childs[0].childs[0].evaluate(a);r=this.childs[0].childs[1].evaluate(a);try{return k=a.matrices[this.value][0>p?0:l(p)][0>r?0:l(r)],void 0!==k?k:0}catch(b){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var n;this.evaluate=function(a){n=[];for(var c=0,f=this.childs[0].childs.length;c<f;c++)n[c]=this.childs[0].childs[c].evaluate(a);return"_Eval_"===this.value?(n[0]=0<n.length?
n[0].toString():"",b=n[0].replace(a.parent.decimal_symbol_regexp,"."),void 0==h[b]&&(h[b]=a.parser.parse(b)),a.evalExpression(h[b])):a.functions[this.value].apply(a,n)}}else if("operator"===this.type)"+"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);if("matrix"!==b.type||"matrix"!==a.type)return b+a;q=b.rows;s=b.cols;u=e(q,s);for(v=0;v<q;v++)for(m=0;m<s;m++)u[m][v]=b[m][v]+a[m][v];return u}:"-"===this.value?this.evaluate=function(a){var b=
this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);if("matrix"!==b.type||"matrix"!==a.type)return b-a;q=b.rows;s=b.cols;u=e(q,s);for(v=0;v<q;v++)for(m=0;m<s;m++)u[m][v]=b[m][v]-a[m][v];return u}:"*"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);return"matrix"!==b.type||"matrix"!==a.type?b*a:g(b,a)}:"/"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a,!0);a=this.childs[1].evaluate(a,!0);if("matrix"!==b.type||
"matrix"!==a.type)return b/a;var f=e(a.length,a.length),l=d(a);if(0===l)a=0;else{var l=1/l,h;if(1<a.length)for(var k=0,m=a.length;k<m;k++){h=l;for(var p=0;p<m;p++)f[p][k]=h*d(c(k,p,a)),h=-h;l=-l}else f[0][0]=l;a=f}b=0===a?e(b.rows,b.cols):g(b,a);return b}:"%"===this.value?this.evaluate=function(a){var b=this.childs[0].evaluate(a);a=this.childs[1].evaluate(a);return b-l(b/a)*a}:"^"===this.value&&(this.evaluate=function(a){return Math.pow(this.childs[0].evaluate(a),this.childs[1].evaluate(a))});else if("compOperator"===
this.type)"<"===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<this.childs[1].evaluate(a))+0}:"<="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<=this.childs[1].evaluate(a))+0}:">"===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>this.childs[1].evaluate(a))+0}:">="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>=this.childs[1].evaluate(a))+0}:"=="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)===
this.childs[1].evaluate(a))+0}:"!="===this.value&&(this.evaluate=function(a){return(this.childs[0].evaluate(a)!=this.childs[1].evaluate(a))+0});else if("boolOperator"===this.type)"&"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){return!this.childs[0].evaluate(a)+0});else if("conditional"===
this.type)this.evaluate=function(a){return 0<this.childs[0].evaluate(a)?this.childs[1].evaluate(a):this.childs[2].evaluate(a)};else if("sign"===this.type)this.evaluate="sign+"===this.value?function(a){return this.childs[0].evaluate(a)}:function(a){return-this.childs[0].evaluate(a)};else if("parentheses"===this.type)this.evaluate=function(a,b){return this.childs[0].evaluate(a,b)};else if("(expr)"===this.type||"[expr]"===this.type)this.evaluate=function(a){var b=this.childs.length,c=[],f;if(1===b&&
1===this.childs[0].childs.length&&"(expr)"===this.type)c=this.childs[0].childs[0].evaluate(a);else for(var d=0;d<b;d++){f=[];for(var l=0,e=this.childs[d].childs.length;l<e;l++)f.push(this.childs[d].childs[l].evaluate(a));c[d]=f}return c};else if("asign"===this.type){var t,z,H,I,G,K;this.evaluate=function(a){t=this.childs[0];z=this.childs[1];1===t.childs.length&&"square_bracket"===t.childs[0].type?(f=t.childs[0].childs,1===f.length?(H=f[0].evaluate(a),H=0>H?0:l(H),a.vectors[t.value][H]=z.evaluate(a)):
2===f.length&&(I=f[0].evaluate(a),G=f[1].evaluate(a),I=0>I?0:l(I),G=0>G?0:l(G),a.matrices[t.value][I]||(a.matrices[t.value][I]=[]),a.matrices[t.value][I][G]=z.evaluate(a))):(K=z.evaluate(a),K.type?a.matrices[t.value]=K:"object"!==typeof a.variables[t.value]&&(a.variables[t.value]=K))}}};var q,s,u,m,v,n,t;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,g,c,d,b,h,l,f,p,r=/^\s+/,k=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,q=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,s=/^==|^!=|^<=|^<|^>=|^>|^#/,u=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,m=/^=/,v=/^[\?\:]/,n=/^[\+\-\*\/\%\^]/,t=/^\[|^\]/,w=/^\(|^\)/,A=/^,/,B=/^;/,y=/\|/g,D=/\|\*/g,E=/\*\|/g;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function z(a,b,c){g.push({type:a,
value:b});h=h.slice(c);d+=c;f++;p=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(D,"'").replace(E,"'"));a.match(/\=\|/g)&&(a=a.replace(y,"'"));var G=a.trim();"|"==G.charAt(0)&&"|"==G.charAt(G.length-1)&&(a=G.replace(y,"'"))}g=[];c=!1;d=0;h=a;f=0;for(p="";a&&d<a.length;)if(c=d,"'"==h[0]){for(l=1;"'"!=h[l];)if(l<h.length)l++;else{console.log(">Error, unknown symbol: ["+
h+"], in the string <<"+e+">>");return}b=h.substring(1,l);z("string",b,b.length+2)}else if(b=h.match(r))h=h.slice(b[0].length),d+=b[0].length,f++;else if(b=h.match(k))"number"===p&&g.push({type:"operator",value:"*"}),z("identifier",b[0],b[0].length);else if(b=h.match(q))z("number",b[0],b[0].length);else if(b=h.match(s))G=b[0],"#"==G&&(G="!="),z("compOperator",G,b[0].length);else if(b=h.match(u))G=b[0],"||"==G?G="|":"&&"==G?G="&":"~"==G&&(G="!"),z("boolOperator",G,b[0].length);else if((b=h.match(m))&&
!h.match(/^==/))z("asign",b[0],b[0].length);else if(b=h.match(v))z("conditional",b[0],b[0].length);else if(b=h.match(n))z("operator",b[0],b[0].length);else if(b=h.match(t))z("square_bracket",b[0],b[0].length);else if(b=h.match(w))"("==b&&"number"===p&&g.push({type:"operator",value:"*"}),z("parentheses",b[0],b[0].length);else if(b=h.match(A))z("separator",b[0],b[0].length);else if(178===h.charCodeAt(0))g.push({type:"operator",value:"^"}),z("number",2,1);else if(179===h.charCodeAt(0))g.push({type:"operator",
value:"^"}),z("number",3,1);else if(b=h.match(B))z("final_of_expresion",b[0],b[0].length);else if(c==d){console.log("Error, simbolo no conocido: ["+h+"], en la cadena <<"+e+">>");return}return g};var C,z=/rnd|pi|e|Infinity|-Infinity|sqr|sqrt|ra\u00edz|exp|log|log10|abs|ent|sgn|ind|sin|sen|cos|tan|cot|sec|csc|sinh|senh|cosh|tanh|coth|sech|csch|asin|asen|acos|atan|min|max/;a.Tokenizer.prototype.flatTokens=function(a,b){a=a||[];b=b||"";C="";for(var c=0,f=a.length;c<f;c++)C="string"==a[c].type?C+"&squot;"+
a[c].value+"&squot;":"identifier"!=a[c].type||a[c].value.match(z)?C+a[c].value:C+b+a[c].value;return C};return a}(descartesJS||{}),descartesJS=function(a){function e(a){return isNaN(parseFloat(a))?a.replace(/^\s|\s$/g,"").replace(/^'|'$/g,""):parseFloat(a)}if(a.loadLib)return a;a.Parser=function(b){this.evaluator=b;this.tokenizer=new a.Tokenizer;this.vectors={};this.matrices={};this.variables={};this.functions={};this.definitions={};this.registerDefaultValues()};a.Parser.prototype.setDefinition=function(a,
b){this.definitions[a]=b};a.Parser.prototype.getDefinition=function(a){return this.definitions[a]};a.Parser.prototype.setVariable=function(a,b){this.variables[a]=b};a.Parser.prototype.getVariable=function(a,b){b&&(this.variables[a]=void 0!==this.variables[a]?this.variables[a]:void 0);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 g,c,d,b,h,l,f,p,r,k,q,s;a.Parser.prototype.parse=function(e,m){(d=this.tokenizer.tokenize(e))||
(d=[]);b=null;m=!m||!1;g=p=f=l=0;for(c=d.length;g<c;g++)if(r=d[g],k=r.value,q=r.type,"identifier"===q&&(g+1<c&&"parentheses"===d[g+1].type&&"("===d[g+1].value?this.getFunction(k):g+1<c&&"square_bracket"===d[g+1].type&&"["===d[g+1].value?d[g+3]&&"square_bracket"===d[g+3].type&&"]"===d[g+3].value?this.getVector(k):this.getMatrix(k):this.getVariable(k,!0)),"asign"===q&&m&&(q="compOperator",k="=="),"asign"===q)if(h=new a.Node(q,k),null!=b)if("identifier"===b.type)b.parent&&b.parent.replaceLastChild(h),
h.addChild(b),b=h,m=!0;else if("square_bracket"===b.type)h.addChild(b.parent),b=h,m=!0;else{h.type="compOperator";h.value="==";for(m=!0;b.parent&&this.getPrecedence(b.parent.value)>=this.getPrecedence(h.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(h);h.addChild(b);b=h}else{console.log("Error1: en la expresion <<"+e+">>, en el token {valor: "+k+", tipo: "+q+"}");break}else if("parentheses"===q&&"("===k||"square_bracket"===q&&"["===k)if(h=new a.Node(q,k),"("===k&&l++,"["===k&&f++,null===b)"("===
k&&(new a.Node("(expr)","(expr)")).addChild(h),"["===k&&(new a.Node("[expr]","[expr]")).addChild(h),b=h;else if("operator"===b.type||"boolOperator"===b.type||"compOperator"===b.type||"conditional"===b.type||"asign"===b.type)b.addChild(h),b=h;else if("sign"===b.type)b.addChild(h),b=h;else if("parentheses"===b.type&&"("===b.value)b.addChild(h),b=h;else if("square_bracket"===b.type&&"["===b.value)b.addChild(h),b=h;else if("parentheses"===b.type&&"()"===b.value)b.parent.addChild(h),b=h;else if("square_bracket"===
b.type&&"[]"===b.value)b.parent.addChild(h),b=h;else if("identifier"===b.type)b.addChild(h),b=h;else{console.log("Error2: en la expresion <<"+e+">>, en el token ["+g+"] {valor: "+k+", tipo: "+q+"}");break}else if("parentheses"===q&&")"===k)if(l--,null===b)console.log("Error3: en la expresion <<"+e+">>, en el token (valor:"+k+", tipo:"+q);else{for(;b&&b.parent&&"("!=b.value;)b=b.parent;if(b&&"("===b.value)b.value="()";else{console.log("Error4: en la expresion <<"+e+">>, en el token {valor: "+k+", tipo: "+
q+"}");break}}else if("square_bracket"===q&&"]"===k)if(f--,null===b)console.log("Error5: en la expresion <<"+e+">>, en el token (valor:"+k+", tipo:"+q);else{for(;b&&b.parent&&"["!=b.value;)b=b.parent;if(b&&"["===b.value)b.value="[]";else{console.log("Error6: en la expresion <<"+e+">>, en el token {valor: "+k+", tipo: "+q+"}");break}}else if("number"===q||"string"===q||"identifier"===q)if(h=new a.Node(q,k),null===b)b=h;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(h),b=h;else{console.log("Error7: en la expresion <<"+e+">>, en el token {valor: "+k+", tipo: "+q+"}");break}else if("operator"===q||"compOperator"===q||"boolOperator"===q)if(h=new a.Node(q,k),null===b)if("-"===k||"+"===k)h.type="sign",h.value="sign"+k,b=h;else if("!"===k)b=h;else{console.log("Error8: en la expresion <<"+e+">>, en el token {valor: "+
k+", tipo: "+q+"}");break}else if("operator"===b.type||"compOperator"===b.type||"boolOperator"===b.type||"asign"===b.type||"conditional"===b.type||"square_bracket"===b.type&&"["===b.value&&("-"===k||"+"===k||"!"===k)||"parentheses"===b.type&&"("===b.value&&("-"===k||"+"===k||"!"===k)){if("-"===k||"+"===k)h.type="sign",h.value="sign"+k;b.addChild(h);b=h}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(h.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(h);h.addChild(b);b=h}else{console.log("Error9: en la expresion <<"+e+">>, en el token {valor: "+k+", tipo: "+q+"}");break}else if("conditional"===q)if(h=new a.Node(q,k),null!=b)if("?"===h.value){for(p++;b.parent&&this.getPrecedence(b.parent.value)>this.getPrecedence(h.value);)b=b.parent;b.parent&&b.parent.replaceLastChild(h);h.addChild(b);
b=h}else{for(p--;b&&b.parent&&"?"!=b.value;)b=b.parent;if(b&&"?"===b.value)b.value="?:";else{console.log("Error10: en la expresion <<"+e+">>, en el token {valor: "+k+", tipo: "+q+"}");break}}else{console.log("Error11: en la expresion <<"+e+">>, en el token {valor: "+k+", tipo: "+q+"}");break}else if("separator"===q)if(null!=b)for(;b.parent&&"("!=b.value&&"["!=b.value;)b=b.parent;else{console.log("Error12: en la expresion <<"+e+">>, en el token {valor: "+k+", tipo: "+q+"}");break}else{console.log("Error13: en la expresion <<"+
e+">>, en el token {valor: "+k+", tipo: "+q+"}");break}0<l&&alert("Error, faltan parentesis por cerrar: "+e);0>l&&alert("Error, faltan parentesis por abrir: "+e);0<f&&alert("Error, faltan square bracketss por cerrar: "+e);0>f&&alert("Error, faltan square bracketss por abrir: "+e);0!=p&&alert("Error, condicional incompleta: "+e);(s=b?b.getRoot():null)&&s.setAllEvaluateFunction();return s};a.Parser.prototype.getPrecedence=function(a){switch(a){case "=":return 1;case "(":return 2;case "[":return 2;case "?":return 2;
case ":":return 3;case "?:":return 3;case "|":return 6;case "&":return 7;case "<":return 5;case "<=":return 5;case ">":return 5;case ">=":return 5;case "==":return 5;case "!=":return 5;case "+":return 6;case "-":return 6;case "/":return 7;case "*":return 7;case "sign-":return 7;case "sign+":return 7;case "!":return 8;case "%":return 8;case "^":return 9;default:return 9}};a.Parser.prototype.registerDefaultValues=function(){function b(a,c){for(var f in c)c.hasOwnProperty(f)&&(a[f]=c[f])}this.variables.rnd=
Math.random;this.variables.pi=a.returnValue(Math.PI);this.variables.e=a.returnValue(Math.E);this.variables.Infinity=Infinity;this.variables["-Infinity"]=-Infinity;this.functions.sqr=function(a){return a*a};this.functions.sqrt=this.functions["ra\u00edz"]=Math.sqrt;this.functions.exp=Math.exp;this.functions.log=Math.log;this.functions.log10=function(a){return Math.log(a)/Math.log(10)};this.functions.abs=Math.abs;this.functions.ent=Math.floor;this.functions.sgn=function(a){return 0<a?1:0>a?-1:0};this.functions.ind=
function(a){return a?1:0};this.functions.sin=this.functions.sen=Math.sin;this.functions.cos=Math.cos;this.functions.tan=Math.tan;this.functions.cot=function(a){return 1/Math.tan(a)};this.functions.sec=function(a){return 1/Math.cos(a)};this.functions.csc=function(a){return 1/Math.sin(a)};this.functions.sinh=this.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};this.functions.cosh=function(a){return(Math.exp(a)+Math.exp(-a))/2};this.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/
(Math.exp(a)+Math.exp(-a))};this.functions.coth=function(a){return 1/this.functions.tanh(a)};this.functions.sech=function(a){return 1/this.functions.cosh(a)};this.functions.csch=function(a){return 1/this.functions.sinh(a)};this.functions.asin=this.functions.asen=Math.asin;this.functions.acos=Math.acos;this.functions.atan=Math.atan;this.functions.min=Math.min;this.functions.max=Math.max;this.functions._Num_=function(a){return"number"==typeof a?"NaN":parseFloat(a)==a?parseFloat(a):"NaN"};var c=this;
this.functions._Trace_=function(a){console.log(a)};this.functions._Stop_Audios_=function(){c.evaluator.parent.stopAudios()};this.functions.esCorrecto=function(b,f,d){return a.esCorrecto(b,f,c.evaluator,d)};this.functions.escorrecto=function(b,f,d){return a.escorrecto(b,f,c.evaluator,d)};window.parent!==window&&(this.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",name:a,value:b},"*");return 0},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},
"*");return 0},this.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",name:a,value:b},"*");return 0});this.functions._GetValues_=function(b,f){var d;if(b){d=(d=document.getElementById(b))&&"descartes/archivo"==d.type?d.text.replace(/&brvbar;/g,String.fromCharCode("166")):a.openExternalFile(b);var l=[],e=!1;if(d){d=d.replace(/\r/g,"").split("\n");for(var h=0,g=d.length;h<g;h++)d[h].match("<"+f+">")?(e=d[h].trim().split("<"+f+">"),2==e.length&&""!=e[1]&&(l=l.concat(e[1].split(String.fromCharCode("166")))),
e=!0):d[h].match("</"+f+">")?(e=d[h].trim().split("</"+f+">"),2==e.length&&""!=e[0]&&(l=l.concat(e[0].split(String.fromCharCode("166")))),e=!1):e&&(l=l.concat(d[h].split(String.fromCharCode("166"))));h=0;for(g=l.length;h<g;h++)e=l[h].split("="),e[0]=e[0].trim(),2==e.length&&""!=e[0]&&(isNaN(parseFloat(e[1]))?c.setVariable(e[0],e[1].replace(/^\s|\s$/g,"").replace(/^'|'$/g,"")):c.setVariable(e[0],parseFloat(e[1])))}return 0}};this.functions._GetMatrix_=function(b,f){var d;if(b){d=(d=document.getElementById(b))&&
"descartes/archivo"==d.type?d.text.replace(/&brvbar;/g,String.fromCharCode("166")):a.openExternalFile(b);var l=[],h=!1;l.type="matrix";if(d){d=d.replace(/\r/g,"").split("\n");for(var g=0,k=d.length;g<k;g++)d[g].match("<"+f+">")?(h=d[g].trim().split("<"+f+">"),2==h.length&&""!=h[1]&&l.push(h[1].split(String.fromCharCode("166")).map(e)),h=!0):d[g].match("</"+f+">")?(h=d[g].trim().split("</"+f+">"),2==h.length&&""!=h[0]&&l.push(h[0].split(String.fromCharCode("166")).map(e)),h=!1):h&&l.push(d[g].split(String.fromCharCode("166")).map(e));
c.matrices[f]=l;c.setVariable(f+".filas",l[0].length);c.setVariable(f+".columnas",l.length)}return 0}};var f=document.createElement("a"),d,l=null;this.functions._Save_=function(a,b){document.body.appendChild(f);d=new Blob(["\ufeff",b.replace(/\\n/g,"\n").replace(/\\q/g,"'").replace(/\\r/g,"")],{type:"text/plain"});f.setAttribute("download",a);f.setAttribute("href",window.URL.createObjectURL(d));null==l&&(f.click(),l=!0,setTimeout(function(){l=null},500));document.body.removeChild(f);return 0};var h,
g,k,p,r=document.createElement("input");r.setAttribute("type","file");onHandleFileSelect=function(b){h=b.target.files;g=new FileReader;g.onload=function(b){a.addExternalFileContent(h[0].name,b.target.result);c.setVariable(k,h[0].name);c.getFunction(p)&&(c.getFunction(p).apply(c.evaluator,[]),c.evaluator.parent.update())};0<h.length&&g.readAsText(h[0])};r.addEventListener("change",onHandleFileSelect);this.functions._Open_=function(a,b){k=a;p=b;r.click();return 0};var q,s,z=document.createElement("input");
z.setAttribute("type","file");onHandleFileSelect2=function(a){a.stopPropagation();a.preventDefault();q=a.target.files;s=new FileReader;s.onload=function(a){var f={};try{f=JSON.parse(a.target.result)}catch(d){}f.variables&&b(c.variables,f.variables);f.vectors&&b(c.vectors,f.vectors);f.matrices&&b(c.matrices,f.matrices);c.evaluator.parent.update()};0<q.length&&s.readAsText(q[0])};z.removeEventListener("change",onHandleFileSelect2);z.addEventListener("change",onHandleFileSelect2);this.functions._Rojo_=
function(b){return(new a.Color(b)).r/255};this.functions._Verde_=function(b){return(new a.Color(b)).g/255};this.functions._Azul_=function(b){return(new a.Color(b)).b/255};this.functions._AnchoDeCadena_=function(b,c,f,d){return a.getTextWidth(b,a.convertFont(c+","+f+","+d))};this.functions._GetDay_=function(){return(new Date).getDate()};this.functions._GetMonth_=function(){return(new Date).getMonth()+1};this.functions._GetYear_=function(){return(new Date).getFullYear()};this.functions._GetHours_=function(){return(new Date).getHours()};
this.functions._GetMinutes_=function(){return(new Date).getMinutes()};this.functions._GetSeconds_=function(){return(new Date).getSeconds()};this.functions._MatrixToStr_=function(a){var b=this.matrices[a];if(b){strM="<"+a+">\\n";for(var c=this.getVariable(a+".columnas_usadas")||b.rows||0,f=this.getVariable(a+".filas_usadas")||b.cols||0,d,l=0;l<c;l++){for(var e=0;e<f;e++)d=b[l][e],void 0!==d&&("string"==typeof d&&(d="'"+d+"'"),strM+=d+(e<f-1?" \u00a6 ":""));strM=strM.replace(/(\u00A6 )$/g,"")+"\\n"}return strM+=
"</"+a+">"}return""}};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;this.definitions=this.parser.definitions};a.Evaluator.prototype.setDefinition=function(a,c){this.definitions[a]=c};a.Evaluator.prototype.getDefinition=function(a){return this.definitions[a]};
a.Evaluator.prototype.setVariable=function(a,c){this.variables[a]=c};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,c,d){c=0>c?0:e(c);this.vectors[a][c]=d};a.Evaluator.prototype.getVector=function(a,c){c=0>c?0:e(c);return this.vectors[a][c]};a.Evaluator.prototype.setMatrix=function(a,c,d,b){c=0>c?0:e(c);d=0>d?0:e(d);this.matrices[a][c][d]=b};a.Evaluator.prototype.getMatrix=function(a,c,d){c=0>c?0:e(c);d=0>d?0:e(d);return this.matrices[a][c][d]};
a.Evaluator.prototype.setFunction=function(a,c){this.functions[a]=c};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a){return a?a.evaluate(this):0};a.externalEvaluator=new a.Evaluator;return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e=2,g=!1,c;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 d=0,b=0,h=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==
this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var c=0,f=this.children.length;c<f;c++)this.children[c].getTextMetrics()}else if("textLineBlock"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("newLine"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);var p=a.getFontMetrics(this.styleString);this.baseline=p.baseline;this.descent=p.descent;this.ascent=p.ascent;this.w=0;this.h=p.h}else if("text"==this.nodeType||
"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);p=a.getFontMetrics(this.styleString);this.baseline=p.baseline;this.descent=p.descent;this.ascent=p.ascent;var c=this.value,r;"string"!=typeof this.value&&(f=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),r=void 0==this.fixed?g:this.fixed,c=this.evaluator.evalExpression(this.value,f,r),parseFloat(c).toString()===c.toString()&&(c=r?parseFloat(c).toFixed(f):a.removeNeedlessDecimals(parseFloat(c).toFixed(f)),
c=(""+c).replace(".",this.decimal_symbol)),c+=" ");this.w=a.getTextWidth(c,this.styleString);this.h=p.h}else if("formula"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("hyperlink"===this.nodeType){c=a.getFontMetrics(this.styleString);this.baseline=c.baseline;this.descent=c.descent;this.ascent=c.ascent;this.w=a.getTextWidth(this.value,this.styleString);this.h=c.h;this.clickCacher=document.createElement("div");this.clickCacher.setAttribute("style",
"position: absolute; width: "+this.w+"px; height: "+this.h+"px; cursor: pointer;");var k=this;this.clickCacher.addEventListener("click",function(a){k.click=!0;window.open(k.URL,k.URL)})}else if("superIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=d,p=b,r=h,c=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=c.ascent,this.descent=c.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),c=r/2-p+this.h,this.superIndexPos=c-this.ascent,
this.ascent=c,this.descent=p,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=d,p=b,r=h,c=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=c.ascent,this.descent=c.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),this.subIndexPos=p+1,this.ascent=f,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("fraction"==
this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);var q=this.children[0],s=this.children[1],c=a.getFontMetrics(q.styleString);q.getBlockMetric();s.getBlockMetric();f=d;p=b;r=h;0>q.h&&(q.h=c.h,q.w=this.spaceWidth);0>s.h&&(s.h=c.h,s.w=this.spaceWidth);this.h=q.h+s.h-1;this.ascent=q.h+Math.round(r/2)-p;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=Math.max(q.w,s.w)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);
p=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator," ","radicand",p),this.children[1].addChild(this.children[0]),this.children[0]=new a.RTFNode(this.evaluator," ","index",p);else if("index"!==this.children[0].nodeType||"radicand"!==this.children[1].nodeType){r=new a.RTFNode(this.evaluator,"","radicand",p);c=0;for(f=this.children.length;c<f;c++)r.addChild(this.children[c]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",
p);this.children[1]=r}c=this.children[0];f=this.children[1];0>=c.children.length&&(p=this.style.clone(),p.fontSize=parseInt(p.fontSize-.2*p.fontSize),c.addChild(new a.RTFNode(this.evaluator," ","text",p)));0>=f.children.length&&f.addChild(new a.RTFNode(this.evaluator," ","text",this.style.clone()));c.getBlockMetric();f.getBlockMetric();this.ascent=f.h/2<c.h?f.h/2+c.h+2-f.descent:f.ascent+4;this.descent=f.descent;this.baseline=this.ascent;this.h=this.ascent+this.descent;this.w=c.w+f.w+4*this.spaceWidth}else if("sum"==
this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=d,p=b,r=h,p=this.children[0],f=this.children[1],r=this.children[2],p.getBlockMetric(),f.getBlockMetric(),r.getBlockMetric(),-1==p.ascent&&(q=a.getFontMetrics(p.styleString),p.ascent=q.ascent,p.descent=q.descent,p.h=q.h),-1==f.ascent&&(q=a.getFontMetrics(f.styleString),f.ascent=q.ascent,f.descent=q.descent,f.h=q.h),c=a.getFontMetrics(this.styleString),this.ascent=c.h+f.h>r.ascent?c.h-c.descent+f.h:r.ascent,this.descent=p.h>r.descent?
p.h+c.descent:r.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,c=this.style.clone(),c.fontType="Times New Roman",c.Bold="bold",c=c.toString(),c=a.getTextWidth(String.fromCharCode(8721),c),this.w=Math.max(p.w,f.w,c)+Math.max(r.w,this.spaceWidth)+this.spaceWidth;else if("integral"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=d,p=b,r=h,p=this.children[0],f=this.children[1],r=this.children[2],p.getBlockMetric(),f.getBlockMetric(),r.getBlockMetric(),-1==p.ascent&&
(q=a.getFontMetrics(p.styleString),p.ascent=q.ascent,p.descent=q.descent,p.h=q.h),-1==f.ascent&&(q=a.getFontMetrics(f.styleString),f.ascent=q.ascent,f.descent=q.descent,f.h=q.h),c=a.getFontMetrics(this.styleString),this.ascent=c.h+f.h>r.ascent?c.h-c.descent+f.h:r.ascent,this.descent=p.h>r.descent?p.h+c.descent:r.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,c=this.style.clone(),c.fontSize*=1.5,c.fontType="Times New Roman",c.Bold="bold",c=c.toString(),c=a.getTextWidth(String.fromCharCode(8747),
c),this.w=Math.max(p.w,f.w,c)+Math.max(r.w,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),f=d,p=b,r=h,p=this.children[0],f=this.children[1],r=this.children[2],c=a.getFontMetrics(this.styleString),p.getBlockMetric(),f.getBlockMetric(),r.getBlockMetric(),-1==p.ascent&&(q=a.getFontMetrics(p.styleString),p.ascent=q.ascent,p.descent=q.descent,p.h=q.h),-1==f.ascent&&(q=a.getFontMetrics(f.styleString),f.ascent=q.ascent,f.descent=q.descent,
f.h=q.h),-1==r.ascent&&(q=a.getFontMetrics(r.styleString),r.ascent=q.ascent,r.descent=q.descent,r.h=q.h),this.ascent=r.ascent,this.descent=Math.max(c.h,r.descent),this.baseline=this.ascent,this.h=this.ascent+this.descent,c=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==p.w&&(p.w=this.spaceWidth),0==f.w&&(f.w=this.spaceWidth),0==r.w&&(r.w=this.spaceWidth),this.w=f.w+p.w+r.w+c+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);c=
a.getFontMetrics(this.styleString);f=d;p=b;r=h;r=c.ascent;for(var q=c.descent,s=c.h,u=this.spaceWidth,m,v,c=0,f=this.children.length;c<f;c++)this.children[c].getBlockMetric(),m=this.children[c].h,v=this.children[c].w,s<m&&(s=m,r=this.children[c].ascent,q=this.children[c].descent),u<v&&(u=v);this.childWidth=u+2*this.spaceWidth;this.childh=s;this.childAscent=r;this.childDescent=q;this.h=this.rows*s;this.ascent=this.h/2+p;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);c=a.getFontMetrics(this.styleString);f=d;p=b;r=h;r=c.ascent;q=c.descent;s=c.h;u=this.spaceWidth;c=0;for(f=this.children.length;c<f;c++)this.children[c].getBlockMetric(),m=this.children[c].h,v=this.children[c].w,s<m&&(s=m,r=this.children[c].ascent,q=this.children[c].descent),u<v&&(u=v);this.childWidth=u+2*this.spaceWidth;this.childh=s;this.childAscent=r;this.childDescent=q;this.h=this.parts*s;this.ascent=this.h/2+p;this.descent=this.h-
this.ascent;this.w=u+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),p=a.getFontMetrics(this.styleString),this.baseline=p.baseline,this.descent=p.descent,this.ascent=p.ascent,this.w=a.getTextWidth(this.value,this.styleString)+this.spaceWidth,this.h=p.h):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),p=a.getFontMetrics(this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),
this.baseline=p.baseline,this.descent=p.descent,this.ascent=p.ascent,this.h=this.componentNumCtrl.h||1,this.w=this.componentNumCtrl.w||1):"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,c=-1,e,g=0,k=this.children.length;g<
k;g++){e=this.children[g];e.getTextMetrics();childAscent=e.ascent;childDescent=e.descent;this.w+=e.w;var q=childDescent;e=e.h;d=childAscent;b=q;h=e;c<childAscent&&(c=childAscent);a<childDescent&&(a=childDescent)}this.ascent=c;this.descent=a;this.baseline=this.ascent;this.h=this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,b,d,h,k,q,s,u){c=u;this.stableWidth||(e=h,g=k,this.getTextMetrics());s=s?-this.children[0].ascent:0;k=h=0;for(q=this.children.length;k<q;k++)0<k&&(h+=this.children[k-
1].h),this.children[k].draw(a,b+0,d+s+h)};a.RTFNode.prototype.drawTextLineBlock=function(a,b,d){for(var e=0,h=0,g=this.children.length;h<g;h++)a.strokeStyle=c,a.fillStyle=c,0<h&&(e+=this.children[h-1].w,"formula"==this.children[h-1].nodeType&&(e+=2*this.children[h-1].spaceWidth)),this.children[h].draw(a,b+e,d+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,c){for(var d=0,e=0,h=this.children.length;e<h;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:.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,c,d){var h=Math.floor(.5*this.spaceWidth),k=void 0==this.decimals?e:this.evaluator.evalExpression(this.decimals),q=void 0==this.fixed?g:this.fixed,s=this.evaluator.evalExpression(this.value);parseFloat(s).toString()===s.toString()&&(s=q?parseFloat(s).toFixed(k):a.removeNeedlessDecimals(parseFloat(s).toFixed(k)),
s=(""+s).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(s,this.styleString);b.fillText(s,h+c,d);this.underline&&(q=(k="bold"==this.style.textBold)?1:.5,b.lineWidth=k?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(h+c-1,parseInt(d+this.descent/2)+q),b.lineTo(h+c-1+this.w,parseInt(d+this.descent/2)+q),b.stroke());this.overline&&(q=(k="bold"==this.style.textBold)?
2:1.5,b.lineWidth=k?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(h+c-1,parseInt(d-this.ascent)+q),b.lineTo(h+c-1+this.w,parseInt(d-this.ascent)+q),b.stroke());this.w+=2*h};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:.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+.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(.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)-
.5);a.lineTo(b-d+this.w-1,parseInt(c-this.ascent+this.children[0].h)-.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,b,c){for(var d=0,e=0,h=this.children.length;e<h;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,h=this.children.length;e<h;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,h=
this.children.length;e<h;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,c,d){var e=a.getFontMetrics(this.styleString),h=" "+String.fromCharCode(8594),g=a.getTextWidth(h,this.styleString);this.children[0].draw(b,c,d+e.descent+this.children[0].ascent);this.children[1].draw(b,c+this.children[0].w+g,d+e.descent+this.children[1].ascent);this.children[2].draw(b,c+g+this.children[0].w+this.children[1].w,d);null!=this.color&&
(b.fillStyle=this.color);b.font=this.styleString;b.textAlign="start";b.textBaseline="alphabetic";b.fillText("l\u00edm",c+this.children[0].w,d);b.fillText(h,c+this.children[0].w,d+e.descent+this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(b,c,d){var e=this.style.clone();e.fontSize*=1.5;e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),h=a.getTextWidth(String.fromCharCode(8747),e),g=a.getFontMetrics(e),s=Math.max(this.children[0].w,this.children[1].w,Math.floor(1.5*h));
this.children[0].draw(b,c+h,d+g.descent+this.children[0].ascent);this.children[1].draw(b,c+h+this.spaceWidth/2,d-this.ascent+this.children[1].ascent);this.children[2].draw(b,c+s+h,d);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8747),c,d+g.descent/2)};a.RTFNode.prototype.drawSum=function(b,c,d){var e=this.style.clone();e.fontType="Times New Roman";e.Bold="bold";var e=e.toString(),h=a.getTextWidth(String.fromCharCode(8721),
e),g=a.getFontMetrics(this.styleString),s=Math.max(this.children[0].w,this.children[1].w,h);this.children[0].draw(b,c+(s-this.children[0].w)/2,d+g.descent+this.children[0].ascent);this.children[1].draw(b,c+(s-this.children[1].w)/2,d-g.ascent-this.children[1].descent);this.children[2].draw(b,c+s,d);null!=this.color&&(b.fillStyle=this.color);b.font=e;b.textAlign="start";b.textBaseline="alphabetic";b.fillText(String.fromCharCode(8721),c+Math.floor((s-h)/2),d-5)};a.RTFNode.prototype.drawMatrix=function(a,
b,c){for(var d,e,h=0,g=this.children.length;h<g;h++)d=h%this.columns,e=Math.floor(h/this.columns),this.children[h].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)+.5,c-this.ascent+.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+.5,c-this.ascent+.5);a.lineTo(Math.floor(b+this.spaceWidth/2)+.5,c+this.descent+.5);a.lineTo(Math.floor(b+this.spaceWidth)+
.5,c+this.descent+.5);a.moveTo(Math.floor(b+this.w-this.spaceWidth)-.5,c-this.ascent+.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/2)-.5,c-this.ascent+.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth/2)-.5,c+this.descent+.5);a.lineTo(Math.floor(b+this.w-this.spaceWidth)-.5,c+this.descent+.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)+.5,c-this.ascent+.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-.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)+.5,c+this.descent+.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,h=this.children.length;e<h;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,g,c,d,b,h,l,f,p,r,k,q;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[];g=[];c=a.length;g=[];d="";h=b=0;f=a.charAt(0);p=!1;for(r="text";b<c;)l=f,f=a.charAt(b+1),p?"\\"===f||"{"===f||"}"===f||" "===f||";"===f?(p=!1,d+=l," "===f&&(b++,f=a.charAt(b+1)),(k=d.match(/^\'([0-9a-f]{2})/))?(q="","text"===r&&(q=g.pop().value),d=q+=e(parseInt(k[1],16))+d.substring(3)):(k=d.match(/^u[0-9]+/))?(q="","text"===r&&(q=g.pop().value),d=q+=e(k[0].substring(1))):("{"===d||"}"===d?(g.push({type:"text",value:d}),r="text"):(g.push({type:"controlWord",value:d}),r="controlWord"),
d="")):d+=l:"\\"===l?(p=!0,""!==d&&(g.push({type:"text",value:d}),r="text"),d=""):"{"===l?(h++,""!==d&&g.push({type:"text",value:d}),d="",g.push({type:"openBlock",value:h}),r="openBlock"):"}"===l?(""!==d&&g.push({type:"text",value:d}),d="",g.push({type:"closeBlock",value:h}),r="closeBlock",h--):d+=l,b++;""!==d&&g.push({type:"text",value:d});return g};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b,h,l,f,p,r,k,q,s,u,m,v,n,t,w,A,B,y,D,E,C,z,H,I,G,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 L=[],F=!1,M=!1,N=[],J=0,R=x.length;J<R;J++)if("openBlock"==x[J].type&&N.push(x[J].value),"closeBlock"==x[J].type&&(N.pop(),0>=N.length&&(F=!1)),"controlWord"!=x[J].type||"expr"!=x[J].value&&"decimals"!=x[J].value||(M=!0),"controlWord"==x[J].type&&"mjaformula"==x[J].value&&(F=!0),"text"==x[J].type&&F&&!M){for(var S=0,P=x[J].value,Q="",O=0,V=P.length;O<V;O++)if("("==
P.charAt(O)||")"==P.charAt(O)||"+"==P.charAt(O)||"-"==P.charAt(O)||"*"==P.charAt(O)||"="==P.charAt(O))Q=P.substring(S,O),""!=Q&&L.push({type:"text",value:Q}),L.push({type:P.charAt(O),value:P.charAt(O)}),S=O+1;Q=P.substring(S,O);""!=Q&&L.push({type:"text",value:Q})}else L.push(x[J]),"text"==x[J].type&&M&&(M=!1);e=L;g={};d=2;if("openBlock"==e[0].type&&"fonttbl"==e[1].value){for(c=e[0].value;"closeBlock"!=e[d].type&&e[d].value!=c;)g[e[d].value]=e[d+2].value.substring(0,e[d+2].value.length-1),d+=3;d++}b=
{};h=0;if("openBlock"==e[d].type&&"colortbl"==e[d+1].value){c=e[d++].value;for(d++;"closeBlock"!=e[d].type&&e[d].value!=c;)l=parseInt(e[d++].value.substring(3)).toString(16),f=parseInt(e[d++].value.substring(5)).toString(16),p=parseInt(e[d++].value.substring(4)).toString(16),";"===e[d].value&&d++,b[h++]="#"+(2>l.length?"0"+l:l)+(2>f.length?"0"+f:f)+(2>p.length?"0"+p:p);d++}r=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");k=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");r.addChild(k);
u=s=q=null;A=w=t=n=v=m=!1;B=[new a.FontStyle(20,"Arial","","",!1,!1,null)];y=B[0];D=!0;C=E=-1;z=[];K=G=I=H=!1;x=d;for(L=e.length;x<L;x++)if("controlWord"==e[x].type&&g[e[x].value])y.fontType=g[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=
"oblique";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=b[parseInt(e[x].value.substring(2))],0<z.length&&(z[z.length-1].style.textColor=
y.textColor);else if("openBlock"==e[x].type)E=e[x].value,y=y.clone(),B.push(y),z.push(null);else if("closeBlock"==e[x].type)e[x].value==C&&(C=-1,m=!1,k=k.parent),B.pop(),y=B[B.length-1],z.pop();else if("controlWord"==e[x].type&&"par"==e[x].value){k.addChild(new a.RTFNode(this.evaluator,"","newLine",y.clone()));r=new a.RTFNode(this.evaluator,"","textLineBlock",y.clone());if("textBlock"!=k.nodeType)for(k=k.parent;"textBlock"!=k.nodeType;)k=k.parent;k.addChild(r);k=r}else if("controlWord"==e[x].type&&
"mjaformula"==e[x].value)H=!0,C=E,m=!0,r=new a.RTFNode(this.evaluator,"","formula",y.clone()),k.addChild(r),k=r,z[z.length-1]=r;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=z[z.length-2].style.clone(),r=new a.RTFNode(this.evaluator,"",e[x].value,F),z[z.length-2].addChild(r),z[z.length-1]=r;else if("controlWord"==e[x].type&&"index"==e[x].value||"to"==e[x].value||
"from"==e[x].value)F=z[z.length-2].style.clone(),F.fontSize=parseInt(F.fontSize-.2*F.fontSize),8>F.fontSize&&(F.fontSize=8),r=new a.RTFNode(this.evaluator,"",e[x].value,F),z[z.length-2].addChild(r),z[z.length-1]=r;else if("controlWord"==e[x].type&&("num"==e[x].value||"den"==e[x].value))F=z[z.length-2].style.clone(),F.fontSize=Math.round(F.fontSize-.1*F.fontSize),8>F.fontSize&&(F.fontSize=8),"num"==e[x].value?r=new a.RTFNode(this.evaluator,"","numerator",F):"den"==e[x].value&&(r=new a.RTFNode(this.evaluator,
"","denominator",F)),z[z.length-2].addChild(r),z[z.length-1]=r;else if("controlWord"==e[x].type&&("subix"==e[x].value||"supix"==e[x].value))F=z[z.length-2].style.clone(),F.fontSize=Math.floor(F.fontSize-F.fontSize/3),8>F.fontSize&&(F.fontSize=8),"subix"==e[x].value?r=new a.RTFNode(this.evaluator,"","subIndex",F):"supix"==e[x].value&&(r=new a.RTFNode(this.evaluator,"","superIndex",F)),r.originalStyle=z[z.length-2].style.clone(),z[z.length-2].addChild(r),z[z.length-1]=r;else if("controlWord"==e[x].type&&
("defparts"==e[x].value||"matrix"==e[x].value||"element"==e[x].value))F=z[z.length-2].style.clone(),r=new a.RTFNode(this.evaluator,"",e[x].value,F),z[z.length-2].addChild(r),z[z.length-1]=r,"defparts"==e[x].value?u=r:"matrix"==e[x].value&&(s=r);else if("controlWord"==e[x].type&&"parts"==e[x].value)A=!0;else if("text"==e[x].type&&A)u.parts=parseInt(e[x].value),A=!1;else if("controlWord"==e[x].type&&"rows"==e[x].value)t=!0;else if("text"==e[x].type&&t)s.rows=parseInt(e[x].value),t=!1;else if("controlWord"==
e[x].type&&"columns"==e[x].value)w=!0;else if("text"==e[x].type&&w)s.columns=parseInt(e[x].value),w=!1;else if("controlWord"==e[x].type&&"expr"==e[x].value)D=!1,v=!0;else if("controlWord"==e[x].type&&"decimals"==e[x].value)n=!0;else if("text"==e[x].type&&n)q.decimals=this.evaluator.parser.parse(e[x].value+""),n=!1;else if("controlWord"==e[x].type&&"fixed1"==e[x].value)q.fixed=!0;else if("controlWord"==e[x].type&&"fixed0"==e[x].value)q.fixed=!1;else if("controlWord"!=e[x].type||"component"!=e[x].value)if("controlWord"==
e[x].type&&"NumCtrl"==e[x].value)I=!0;else if("controlWord"==e[x].type&&"Space"==e[x].value)G=!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();r=new a.RTFNode(this.evaluator,textContent,"hyperlink",F);r.URL=e[x].value.split("|")[1];if("textLineBlock"!=k.nodeType)for(k=k.parent;"textLineBlock"!=k.nodeType;)k=k.parent;k.addChild(r);K=!1}else if("text"==e[x].type&&I)r=new a.RTFNode(this.evaluator,e[x].value,
"componentNumCtrl",y.clone()),k.addChild(r),I=!1;else if("text"==e[x].type&&G)r=new a.RTFNode(this.evaluator,e[x].value,"componentSpace",y.clone()),k.addChild(r),G=!1;else if("text"==e[x].type&&v)F=z[z.length-2].style.clone(),textContent=this.evaluator.parser.parse(e[x].value),r=new a.RTFNode(this.evaluator,textContent,"dynamicText",F),z[z.length-2].addChild(r),q=z[z.length-1]=r,v=!1;else if("text"==e[x].type&&!v&&!m){textContent=e[x].value;r=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(r)}else if("text"==e[x].type&&!v&&m)textContent=e[x].value,r=new a.RTFNode(this.evaluator,textContent,"text",z[z.length-1].style.clone()),z[z.length-1].addChild(r);else if("("==e[x].type||")"==e[x].type)F=z[z.length-1].style.clone(),F.textItalic="",r=new a.RTFNode(this.evaluator,e[x].type,"mathSymbol",F),z[z.length-1].addChild(r);else if("+"==e[x].type||"-"==e[x].type||"*"==e[x].type||"="==e[x].type)r=
new a.RTFNode(this.evaluator,e[x].type,"mathSymbol",z[z.length-1].style.clone()),z[z.length-1].addChild(r);if(null!=k){var U=k.getRoot();U.stableWidth=D;U.getTextMetrics();U.hasFormula=H}return U};a.FontStyle=function(a,b,c,d,f,e,h){this.fontSize=a;this.fontType=b;this.textItalic=c;this.textBold=d;this.textUnderline=f;this.textOverline=e;this.textColor=h};a.FontStyle.prototype.toString=function(){"arial"==this.fontType.toLowerCase()?this.fontType="descartesJS_sansserif,Arial,Helvetica,Sans-serif":
this.fontType.toLowerCase().match("times")?this.fontType="descartesJS_serif,'Times New Roman',Times,serif":this.fontType.toLowerCase().match("courier")&&(this.fontType="descartesJS_monospace,'Courier New',Courier,Monospace");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: oblique; font-weight: normal; ");this.textBold&&this.textItalic&&(a+="font-style: oblique; 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,g,c,d,b,h,l,f,p,r,k,q,s,u;a.Space=function(b,d){this.parent=b;g=this.evaluator=this.parent.evaluator;c=g.parser;this.id="";this.values=d;this.type="R2";this.xExpr=c.parse("0");this.yExpr=c.parse("0");this.w=parseInt(b.container.width);
this.h=parseInt(b.container.height);this.drawif=c.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 f in d)d.hasOwnProperty(f)&&(this[f]=d[f]);this.init()};a.Space.prototype.init=
function(){e=this.parent;g=this.evaluator;d=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);l=parseInt(e.container.height);f=parseInt(e.container.width);this.x=g.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=g.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?(b=l-this.y,this.h>b&&(this.h=b)):(b=this.h+this.y,this.h=b>=l?l:b);0<=this.x?(h=f-this.x,this.w>h&&(this.w=h)):(h=this.w+this.x,this.w=h>=f?f:h);""==this.imageSrc&&this.imageSrc.trim().toLowerCase().match(/vacio.gif$/)||(this.image=e.getImage(this.imageSrc));this.OxExpr&&(r=this.OxExpr,"%"===r[r.length-1]?this.Ox=this.w*parseFloat(r)/100:(p=parseFloat(r),
p!=r&&(p=0),this.Ox=p));this.OyExpr&&(k=this.OyExpr,"%"===k[k.length-1]?this.Oy=this.h*parseFloat(k)/100:(p=parseFloat(k),p!=k&&(p=0),this.Oy=p));""!==this.id&&2!==e.version?(g.setVariable(d+"._w",this.w),g.setVariable(d+"._h",this.h),g.setVariable(d+".escala",this.scale),g.setVariable(d+".Ox",this.Ox),g.setVariable(d+".Oy",this.Oy),g.setVariable(d+".mouse_x",0),g.setVariable(d+".mouse_y",0),g.setVariable(d+".mouse_pressed",0),g.setVariable(d+".mouse_clicked",0),g.setVariable(d+".clic_izquierdo",
0)):(p=g.getVariable("_w"),void 0===p&&(p=this.w),g.setVariable("_w",p),p=g.getVariable("_h"),void 0===p&&(p=this.h),g.setVariable("_h",p),p=g.getVariable("escala"),void 0===p&&(p=this.scale),g.setVariable("escala",p),p=g.getVariable("Ox"),void 0===p&&(p=this.Ox),g.setVariable("Ox",p),p=g.getVariable("Oy"),void 0===p&&(p=this.Oy),g.setVariable("Oy",p),g.setVariable("mouse_x",0),g.setVariable("mouse_y",0),g.setVariable("mouse_pressed",0),g.setVariable("mouse_clicked",0),g.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,b){"R2"==this.type&&b||"R3"==this.type&&!b||(a.background&&"R3"!==this.type?this.backgroundGraphics.push(a):this.graphics.push(a))};a.Space.prototype.clearClick=function(){this.evaluator.setVariable(this.mclickedString,0);this.evaluator.setVariable(this.mclicizquierdoString,
0)};a.Space.prototype.getRelativeX=function(a){return(parseInt(a)-this.w_2-this.Ox)/this.scale};a.Space.prototype.getRelativeY=function(a){return(-parseInt(a)+this.h_2+this.Oy)/this.scale};a.Space.prototype.getAbsoluteX=function(a){return a*this.scale+this.w_2+this.Ox};a.Space.prototype.getAbsoluteY=function(a){return-a*this.scale+this.h_2+this.Oy};a.Space.prototype.findOffset=function(){q=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(s=this.container.style.display);
this.container.style.display="block";if(q.getBoundingClientRect){var a=q.getBoundingClientRect();this.offsetLeft=a.left;this.offsetTop=a.top}else for(;q;)q.tagName&&"html"!==q.tagName.toLowerCase()?(this.offsetLeft+=q.offsetLeft||0,this.offsetTop+=q.offsetTop||0,q=q.parentNode):q=null;this.container&&this.container.style&&(this.container.style.display=s)};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){if(a.loadLib)return a;var e;a.SpaceExternal=function(a){e=this;e.parent=a;e.width=228;e.vSpace=25;e.container=document.createElement("div");e.container.setAttribute("style","-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; border-style: ridge; border-width: 5px; border-color: gray; box-shadow: #000 0px 0px 25px 5px; overflow-y: scroll; overflow-x: hidden; position: fixed; left: 0px; top: 0px; z-index: 10000; width: "+(e.width+27)+"px; height: 460px; background-color: #63b4fb");
e.moveManipulator=document.createElement("div");e.moveManipulator.setAttribute("style"," position: absolute; left: 0px; top: 0px; width: "+(e.width+27)+"px; height: "+e.vSpace+"px; line-height: "+e.vSpace+"px; background-color: ddd; cursor: move; padding-left: 75px; font-family: Sans-Serif; font-size: 18px;");e.moveManipulator.innerHTML="Descartes";e.container.appendChild(e.moveManipulator);e.ctrs=[]};a.SpaceExternal.prototype.init=function(){function e(b){d.newPosition=a.getCursorPosition(b);d.container.style.left=
d.initialPosition.x+(d.newPosition.x-d.oldPosition.x)+"px";d.container.style.top=d.initialPosition.y+(d.newPosition.y-d.oldPosition.y)+"px"}function c(a){a.preventDefault();d.findOffset();document.body.removeEventListener("mousemove",e);document.body.removeEventListener("mouseup",c)}document.body.appendChild(this.container);var d=this,b=d.parent.evaluator.parser,h;h=0;for(var l=d.ctrs.length;h<l;h++)d.ctrs[h].expresion=b.parse("(0,"+(d.vSpace+23+35*h)+","+d.width+",35)"),d.ctrs[h].update();d.numCtr=
l;h="espa\u00f1ol"==d.language?"cr\u00e9ditos":"english"==d.language?"about":"cr\u00e9ditos";h=new a.Button(d.parent,{region:"external",name:h,font_size:b.parse("15"),expresion:b.parse("(0,"+d.vSpace+","+d.width/2+",25)")});h.actionExec={execute:a.showAbout};h.update();(new a.Button(d.parent,{region:"external",name:"config",font_size:b.parse("15"),action:"config",expresion:b.parse("("+d.width/2+","+d.vSpace+","+d.width/2+",25)")})).update();h="espa\u00f1ol"==d.language?"inicio":"english"==d.language?
"init":"inicio";(new a.Button(d.parent,{region:"external",name:h,font_size:b.parse("15"),action:"init",expresion:b.parse("(0,"+(d.vSpace+23+35*l)+","+d.width/2+",25)")})).update();h="espa\u00f1ol"==d.language?"limpiar":"english"==d.language?"clear":"limpiar";(new a.Button(d.parent,{region:"external",name:h,font_size:b.parse("15"),action:"clear",expresion:b.parse("("+d.width/2+","+(d.vSpace+23+35*l)+","+d.width/2+",25)")})).update();h="espa\u00f1ol"==d.language?"cerrar":"close";b=new a.Button(d.parent,
{region:"external",name:h,font_size:b.parse("15"),expresion:b.parse("("+d.width/4+","+(d.vSpace+46+35*l)+","+d.width/2+",25)")});b.update();b.canvas.addEventListener("click",function(a){d.hide()});d.setPositionAndSize();d.moveManipulator.addEventListener("mousedown",function(b){b.preventDefault();d.oldPosition=a.getCursorPosition(b);d.initialPosition={x:d.container.offsetLeft,y:d.container.offsetTop};document.body.addEventListener("mousemove",e);document.body.addEventListener("mouseup",c)});d.findOffset();
d.hide()};a.SpaceExternal.prototype.addCtr=function(a){this.ctrs.push(a)};a.SpaceExternal.prototype.show=function(){this.setPositionAndSize();this.container.style.display="block"};a.SpaceExternal.prototype.hide=function(){this.container.style.display="none"};a.SpaceExternal.prototype.setPositionAndSize=function(){var a=this.vSpace+46+35*this.numCtr+25+10;this.container.style.left=Math.max(parseInt(window.innerWidth-this.width)/2,0)+"px";this.container.style.top="5px";this.container.style.height=window.innerHeight<
this.vSpace+75?this.vSpace+75+"px":a>window.innerHeight-10?window.innerHeight-10:a+"px"};a.SpaceExternal.prototype.findOffset=function(){tmpContainer=this.container;this.offsetTop=this.offsetLeft=0;this.container&&this.container.style&&(tmpDisplay=this.container.style.display);this.container.style.display="block";if(tmpContainer.getBoundingClientRect){var a=tmpContainer.getBoundingClientRect();this.offsetLeft=a.left;this.offsetTop=a.top}else for(;tmpContainer;)tmpContainer.tagName&&"html"!==tmpContainer.tagName.toLowerCase()?
(this.offsetLeft+=tmpContainer.offsetLeft||0,this.offsetTop+=tmpContainer.offsetTop||0,tmpContainer=tmpContainer.parentNode):tmpContainer=null;this.container&&this.container.style&&(this.container.style.display=tmpDisplay);for(var a=0,c=this.ctrs.length;a<c;a++)this.ctrs[a].findOffset&&this.ctrs[a].findOffset()};return a}(descartesJS||{}),descartesJS=function(a){var e,g;if(a.loadLib)return a;var c=Math.floor,d=Math.round,b=2*Math.PI,h=a.convertFont("SansSerif,PLAIN,12"),l=a.convertFont("Monospaced,PLAIN,12"),
f,p,r,k,q,s,u,m,v,n,t,w,A,B,y,D,E,C,z,H,I,G,K,x,L,F,M,N,J;a.Space2D=function(b,c){a.Space.call(this,b,c);f=this;f._ratio=5E6<f.w*a._ratio*f.h*a._ratio?1:a._ratio;f.backgroundCanvas=document.createElement("canvas");f.backgroundCanvas.setAttribute("id",f.id+"_background");f.backgroundCanvas.width=f.w*f._ratio;f.backgroundCanvas.height=f.h*f._ratio;f.backgroundCanvas.style.width=f.w+"px";f.backgroundCanvas.style.height=f.h+"px";f.backgroundCtx=f.backgroundCanvas.getContext("2d");f.backgroundCtx.imageSmoothingEnabled=
!1;f.backgroundCtx.mozImageSmoothingEnabled=!1;f.backgroundCtx.webkitImageSmoothingEnabled=!1;f.canvas=document.createElement("canvas");f.canvas.setAttribute("id",f.id+"_canvas");f.canvas.width=f.w*f._ratio;f.canvas.height=f.h*f._ratio;f.canvas.setAttribute("class","DescartesSpace2DCanvas");f.canvas.setAttribute("style","z-index: "+f.zIndex+"; width:"+f.w+"px; height:"+f.h+"px;");f.ctx=f.canvas.getContext("2d");f.ctx.imageSmoothingEnabled=!1;f.ctx.mozImageSmoothingEnabled=!1;f.ctx.webkitImageSmoothingEnabled=
!1;f.graphicControlContainer=document.createElement("div");f.graphicControlContainer.setAttribute("id",f.id+"_graphicControls");f.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+f.zIndex+";");f.numericalControlContainer=document.createElement("div");f.numericalControlContainer.setAttribute("id",f.id+"_numericalControls");f.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+f.zIndex+";");f.container=
document.createElement("div");f.container.setAttribute("id",f.id);f.container.setAttribute("class","DescartesSpace2DContainer");f.container.setAttribute("style","left: "+f.x+"px; top: "+f.y+"px; z-index: "+f.zIndex+";");f.parent.arquimedes&&"#f0f8fa"===f.background.getColor()&&(f.container.style.border="1px solid #b8c4c8");f.container.appendChild(f.backgroundCanvas);f.container.appendChild(f.canvas);f.container.appendChild(f.graphicControlContainer);f.container.appendChild(f.numericalControlContainer);
b.container.insertBefore(f.container,b.loader);f.parent.images[f.id+".image"]=f.canvas;f.parent.images[f.id+".image"].ready=1;f.parent.images[f.id+".image"].complete=!0;f.evaluator.setVariable(f.id+".image",f.id+".image");f.parent.images[f.id+".back"]=f.backgroundCanvas;f.parent.images[f.id+".back"].ready=1;f.parent.images[f.id+".back"].complete=!0;f.evaluator.setVariable(f.id+".back",f.id+".back");""!==f.id&&2!==b.version?(f.OxString=f.id+".Ox",f.OyString=f.id+".Oy",f.scaleString=f.id+".escala",
f.wString=f.id+"._w",f.hString=f.id+"._h",f.mxString=f.id+".mouse_x",f.myString=f.id+".mouse_y",f.mpressedString=f.id+".mouse_pressed",f.mclickedString=f.id+".mouse_clicked",f.mclicizquierdoString=f.id+".clic_izquierdo"):(f.OxString="Ox",f.OyString="Oy",f.scaleString="escala",f.wString="_w",f.hString="_h",f.mxString="mouse_x",f.myString="mouse_y",f.mpressedString="mouse_pressed",f.mclickedString="mouse_clicked",f.mclicizquierdoString="clic_izquierdo");f.click=0;"descartesJS_scenario"!==f.id?f.registerMouseAndTouchEvents():
f.canvas.oncontextmenu=function(a){return!1}};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){f=this;f.uber.init.call(f);f.canvas&&(f.backgroundCanvas.width=f.w*f._ratio,f.backgroundCanvas.height=f.h*f._ratio,f.backgroundCanvas.style.width=f.w+"px",f.backgroundCanvas.style.height=f.h+"px",f.canvas.width=f.w*f._ratio,f.canvas.height=f.h*f._ratio,f.canvas.style.width=f.w+"px",f.canvas.style.height=f.h+"px");f.container&&f.findOffset()};a.Space2D.prototype.update=function(a){f=this;p=
f.evaluator;r=f.parent;p.setVariable(f.wString,f.w);p.setVariable(f.hString,f.h);f.drawIfValue=0<p.evalExpression(f.drawif);if(f.drawIfValue){q=f.x!==p.evalExpression(f.xExpr)+f.displaceRegionWest;s=f.y!==p.evalExpression(f.yExpr)+r.plecaHeight+f.displaceRegionNorth;f.spaceChange=a||q||s||f.drawBefore!==f.drawIfValue||f.Ox!==p.getVariable(f.OxString)||f.Oy!==p.getVariable(f.OyString)||f.scale!==p.getVariable(f.scaleString);f.x=q?p.evalExpression(f.xExpr)+f.displaceRegionWest:f.x;f.y=s?p.evalExpression(f.yExpr)+
r.plecaHeight+f.displaceRegionNorth:f.y;f.Ox=p.getVariable(f.OxString);f.Oy=p.getVariable(f.OyString);f.scale=p.getVariable(f.scaleString);f.drawBefore=f.drawIfValue;1E-6>f.scale?(f.scale=1E-6,p.setVariable(f.scaleString,1E-6)):1E6<f.scale&&(f.scale=1E6,p.setVariable(f.scaleString,1E6));if(q||s)f.container.style.left=f.x+"px",f.container.style.top=f.y+"px",f.findOffset();f.container.style.display="block";f.drawTrace=!f.spaceChange&&(!f.fixed&&!f.click||f.fixed);f.spaceChange&&(f.backgroundCtx.setTransform(f._ratio,
0,0,f._ratio,0,0),f.drawBackground(),f.backgroundCtx.setTransform(1,0,0,1,0,0));f.ctx.setTransform(f._ratio,0,0,f._ratio,0,0);f.draw();f.ctx.setTransform(1,0,0,1,0,0)}else f.container.style.display="none"};a.Space2D.prototype.drawBackground=function(){p=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)):"imgcenter"===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,c(this.h/2+this.Oy)+.5),k.lineTo(this.w,c(this.h/2+this.Oy)+.5);if(""!==this.y_axis||2!==this.parent.version)k.moveTo(c(this.w/2+this.Ox)+
.5,0),k.lineTo(c(this.w/2+this.Ox)+.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=h,k.textAlign="right",k.textBaseline="alphabetic",k.fillText(this.x_axis,c(this.w)-2,c(this.h/2+this.Oy)+12),k.fillText(this.y_axis,c(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(k.fillStyle=this.axes.getColor(),k.font=h,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,d=this.graphics.length;a<d;a++)u=this.graphics[a],""!==u.trace&&this.drawTrace&&u.drawTrace(),u.draw();a=0;for(d=this.graphicsCtr.length;a<d;a++)this.graphicsCtr[a].draw();
""!=this.text&&this.click&&"L"===this.whichButton&&(k.fillStyle=this.text.getColor(),k.strokeStyle=k.fillStyle,k.lineWidth=1,k.font=l,k.textAlign="center",k.textBaseline="alphabetic",I=1>=this.scale?this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length),G=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),K="("+I+","+G+")",x=c(k.measureText(K).width/2),L=this.getAbsoluteX(this.mouse_x),F=this.getAbsoluteY(this.mouse_y),M=c(L),N=c(F-10),M+x>
this.w?M=this.w-x:0>M-x&&(M=x),N+1>this.h?N=this.h:0>N-14&&(N=15),k.fillText(K,M,N),k.beginPath(),k.arc(L,F,2.5,0,b,!0),k.stroke())};a.Space2D.prototype.drawMarks=function(a,b,f){t=this.w;w=this.h;E=0;C=t;z=0;H=w;y=c(t/2+this.Ox);D=c(w/2+this.Oy);0<=f&&(E=y-f,C=y+f,z=D-f,H=D+f);a.beginPath();for(f=-d(y/b);(A=y+d(f*b))<t;f++)a.moveTo(A+.5,z+.5),a.lineTo(A+.5,H+.5);for(f=-d(D/b);(B=D+d(f*b))<w;f++)a.moveTo(E+.5,B+.5),a.lineTo(C+.5,B+.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,b,f){t=
this.w;w=this.h;y=c(t/2+this.Ox);D=c(w/2+this.Oy);for(f=-d(y/b);(A=y+d(f*b))<t;f++)a.fillText(parseFloat((f*b/this.scale).toFixed(4)),A+1,D-2);for(f=-d(D/b);(B=D+d(f*b))<w;f++)0!==parseFloat(-f*b/this.scale)&&a.fillText(parseFloat((-f*b/this.scale).toFixed(4)),y+5,B+5)};a.Space2D.prototype.registerMouseAndTouchEvents=function(){function b(a){document.body.focus();n.parent.clearClick();n.click=1;n.evaluator.setVariable(n.mpressedString,1);n.evaluator.setVariable(n.mclickedString,0);n.evaluator.setVariable(n.mclicizquierdoString,
0);n.parent.deactivateGraphiControls();l(a);window.addEventListener("touchmove",m);window.addEventListener("touchend",d);a.stopPropagation();a.preventDefault()}function d(a){document.body.focus();n.click=0;n.evaluator.setVariable(n.mpressedString,0);n.evaluator.setVariable(n.mclickedString,1);n.evaluator.setVariable(n.mclicizquierdoString,1);window.removeEventListener("touchmove",m);window.removeEventListener("touchend",d);a.preventDefault();n.parent.update()}function f(b){document.body.focus();b.stopPropagation();
b.preventDefault();n.parent.clearClick();n.click=1;n.parent.deactivateGraphiControls();n.whichButton=a.whichButton(b);"R"===n.whichButton?(window.addEventListener("mouseup",h),n.clickPosForZoom=n.getCursorPosition(b).y,n.clickPosForZoomNew=n.clickPosForZoom,n.fixed||(n.tempScale=n.scale,window.addEventListener("mousemove",k))):"L"===n.whichButton&&(n.evaluator.setVariable(n.mpressedString,1),n.evaluator.setVariable(n.mclickedString,0),n.evaluator.setVariable(n.mclicizquierdoString,0),l(b),window.addEventListener("mousemove",
m),window.addEventListener("mouseup",h))}function h(a){document.body.focus();a.stopPropagation();a.preventDefault();n.click=0;n.evaluator.setVariable(n.mpressedString,0);n.evaluator.setVariable(n.mclickedString,1);n.evaluator.setVariable(n.mclicizquierdoString,1);"R"===n.whichButton&&(window.removeEventListener("mousemove",k),n.clickPosForZoom==n.clickPosForZoomNew&&n.parent.externalSpace.show());window.removeEventListener("mousemove",m);window.removeEventListener("mouseup",h);n.parent.update()}function l(a){10<
Date.now()-p&&(n.posAnte=n.getCursorPosition(a),n.mouse_x=n.getRelativeX(n.posAnte.x),n.mouse_y=n.getRelativeY(n.posAnte.y),n.evaluator.setVariable(n.mxString,n.mouse_x),n.evaluator.setVariable(n.myString,n.mouse_y),n.evaluator.setVariable(n.mclickedString,0),n.evaluator.setVariable(n.mclicizquierdoString,0),n.parent.update(),p=Date.now())}function k(a){a.preventDefault();n.clickPosForZoomNew=n.getCursorPosition(a).y;n.evaluator.setVariable(n.scaleString,n.tempScale+n.tempScale/45*((n.clickPosForZoom-
n.clickPosForZoomNew)/10));n.parent.update()}function m(a){a.preventDefault();a.stopPropagation();!n.fixed&&10<Date.now()-p&&(n.posNext=n.getCursorPosition(a),e=c(n.posAnte.x-n.posNext.x),g=c(n.posAnte.y-n.posNext.y),n.evaluator.setVariable(n.OxString,n.Ox-e),n.evaluator.setVariable(n.OyString,n.Oy-g),n.posAnte.x-=e,n.posAnte.y-=g);l(a)}var p=0,n=this;J=a.hasTouchSupport;n.clickPosForZoom=null;n.clickPosForZoomNew=null;n.canvas.oncontextmenu=function(a){return!1};J&&(this.sensitive_to_mouse_movements&&
this.canvas.addEventListener("touchmove",l),this.canvas.addEventListener("touchstart",b));J||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",l),this.canvas.addEventListener("mousedown",f))};return a}(descartesJS||{}),descartesJS=function(a){var e,g,c;function d(a,b){return b.depth-a.depth}function b(b,c){Z=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));W=a.add3D(b,a.scalarProduct3D(Z,-2));X=a.norm3D(W);return 0!==X?a.scalarProduct3D(W,1/X):a.scalarProduct3D(b,
-1)}if(a.loadLib)return a;var h=Math.floor,l=Math.round,f=Math.max,p=Math.cos,r=Math.sin,k=Math.sqrt,q=15*Math.PI/180,s=Math.cos(q),u=Math.sin(q),m,v,n,t,w,A,B,y,D,E,C,z,H,I,G,K,x,L,F,M,N,J,R,S=[],P,Q,O,V,U,Y,Z,W,X;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=[.4,.5,.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){D=n.x!==m.evalExpression(n.xExpr)+n.displaceRegionWest;E=n.y!==m.evalExpression(n.yExpr)+v.plecaHeight+n.displaceRegionNorth;n.spaceChange=a||D||E||n.drawBefore!==n.drawIfValue||n.Ox!==m.getVariable(n.OxStr)||n.Oy!==m.getVariable(n.OyStr)||n.scale!==m.getVariable(n.scaleStr);n.x=D?m.evalExpression(n.xExpr)+n.displaceRegionWest:n.x;n.y=E?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||void 0==n.observer){var b;a=0;for(var c=n.parent.controls.length;a<c;a++)n.parent.controls[a].id===n.obsStr&&(b=!0);n.observer=b?m.getVariable(n.obsStr)||.5*(n.w+n.h):2.5*(n.w+n.h);n.observer=f(n.observer,.1*(n.w+n.h));m.setVariable(n.obsStr,n.observer);n.eye={x:n.observer/n.scale*s,y:0,z:n.observer/n.scale*u};n.D=n.scale*n.eye.x/s;n.XE=l(n.scale*n.eye.y+.5);n.YE=l(n.scale*
n.eye.z+.5)}n.observer=f(m.getVariable(n.obsStr),.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(D||E)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,b=this.graphics.length;a<b;a++)this.graphics[a].update();this.primitives=[];a=0;for(b=this.graphics.length;a<b;a++){t=this.graphics[a];if(t.split||this.split)for(var c=a+1;c<b;c++)w=this.graphics[c],(w.split||
this.split)&&t.splitFace(w);this.primitives=this.primitives.concat(t.primitives||[])}A=this.primitives;B=A.length;for(a=0;a<B;a++)A[a].computeDepth(this);if("painter"===this.render)this.drawPainter(A);else for(A=A.sort(d),a=0;a<B;a++)A[a].draw(this.ctx,this);a=0;for(b=this.graphicsCtr.length;a<b;a++)this.graphicsCtr[a].draw()};var T;a.renderNode=function(a){this.value=a;this.front=this.back=null};a.renderNode.prototype.inOrder=function(){var a=[];this.back&&(a=a.concat(this.back.inOrder()));a.push(this.value);
this.front&&(a=a.concat(this.front.inOrder()));return a};a.Space3D.prototype.buildTree=function(b){if(0===b.length)return null;var c,d=[],f=[];T=b.shift();for(var e=0,h=b.length;e<h;e++){c=null;for(var l=0,g=b[e].spaceVertices.length;l<g;l++)whereIs=2<T.spaceVertices.length?this.inPlane2(T.spaceVertices[0],T.normal,b[e].spaceVertices[l]):0,whereIs=0<T.direction?-whereIs:whereIs,null===c?0>whereIs?c="front":0<whereIs&&(c="back"):0>whereIs?"back"===c&&(c="cross"):0<whereIs&&"front"===c&&(c="cross");
if("back"===c)d.push(b[e]);else if("front"===c)f.push(b[e]);else if(null==c)d.push(b[e]);else{c=null;l=0;for(g=T.spaceVertices.length;l<g;l++)whereIs=2<b[e].spaceVertices.length?this.inPlane2(b[e].spaceVertices[0],b[e].normal,T.spaceVertices[l]):-1,whereIs=0<b[e].direction?-whereIs:whereIs,null===c?0>whereIs?c="front":0<whereIs&&(c="back"):0>whereIs?"back"===c&&(c="cross"):0<whereIs&&"front"===c&&(c="cross");"front"===c?d.push(b[e]):f.push(b[e])}}b=new a.renderNode(T);b.back=this.buildTree(d);b.front=
this.buildTree(f);return b};a.Space3D.prototype.drawPainter=function(a){if(a=this.buildTree(a)){a=a.inOrder();for(var b=0;b<a.length;b++)a[b].draw(this.ctx,this)}};a.Space3D.prototype.inPlane=function(a,b,c,d){return parseFloat(((d.x-a.x)*(b.y-a.y)*(c.z-a.z)+(d.y-a.y)*(b.z-a.z)*(c.x-a.x)+(d.z-a.z)*(b.x-a.x)*(c.y-a.y)-(d.z-a.z)*(b.y-a.y)*(c.x-a.x)-(d.y-a.y)*(b.x-a.x)*(c.z-a.z)-(d.x-a.x)*(b.z-a.z)*(c.y-a.y)).toFixed(8))};a.Space3D.prototype.inPlane2=function(a,b,c){return parseFloat((b.x*(c.x-a.x)+
b.y*(c.y-a.y)+b.z*(c.z-a.z)).originalToFixed(8))};a.Space3D.prototype.updateCamera=function(){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));L=p(x);F=r(x);e=b.x*L-b.y*F;g=b.x*F+b.y*L;c=b.z;x=a.degToRad(n.evaluator.getVariable(n.rotYStr));L=p(x);F=r(x);return{x:c*F+e*L,y:g,z:c*L-e*F}};a.Space3D.prototype.project=function(a){n=this;H=n.eye.x-a.x;I=n.eye.y-a.y;G=n.eye.z-
a.z;var b=k(H*H+I*I+G*G);K=-a.x/b||0;H=this.w_2+this.Ox+n.scale*(a.y+K*(n.eye.y-a.y));I=this.h_2+this.Oy-n.scale*(a.z+K*(n.eye.z-a.z));return{x:H,y:I,z:b}};a.Space3D.prototype.computeColor=function(c,d,f){c.match("rgba")?c=a.RGBAToHexColor(c):c.match("#")&&(c=new a.Color(c.substring(1)));V=a.subtract3D(this.eye,d.average);U=a.norm3D(V);Y=a.scalarProduct3D(V,1/U);this.lights[3]=a.subtract3D(this.light3,d.average);R=a.norm3D(this.lights[3]);for(var e=0,l=this.intensity.length-1;e<l;e++)S[e]=this.intensity[e]*
this.dim;S[3]=this.userIntensity*this.userIntensity/R||0;P=f?this.dim/2:this.dim/4;Q=0;O=0<=d.direction?d.normal:a.scalarProduct3D(d.normal,-1);e=0;for(l=this.lights.length;e<l;e++)f?(Q=Math.max(0,a.dotProduct3D(b(this.lights[e],O),Y)),Q*=Q*Q):Q=Math.max(0,a.dotProduct3D(this.lights[e],O)),P+=S[e]*Q;P=Math.min(P,1);M=h(c.r*P);N=h(c.g*P);J=h(c.b*P);return"rgba("+M+","+N+","+J+","+c.a+")"};a.Space3D.prototype.registerMouseAndTouchEvents=function(){function b(a){document.body.focus();k.click=1;k.evaluator.setVariable(k.id+
".mouse_pressed",1);k.parent.deactivateGraphiControls();k.posAnte=k.getCursorPosition(a);k.oldMouse.x=k.getRelativeX(k.posAnte.x);k.oldMouse.y=k.getRelativeY(k.posAnte.y);e(a);window.addEventListener("touchmove",g);window.addEventListener("touchend",c);a.preventDefault()}function c(a){document.body.focus();k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);window.removeEventListener("touchmove",g,!1);window.removeEventListener("touchend",c,!1);a.preventDefault()}function d(b){document.body.focus();
k.click=1;k.parent.deactivateGraphiControls();k.whichButton=a.whichButton(b);"R"===k.whichButton?(window.addEventListener("mouseup",f),k.clickPosForZoom=k.getCursorPosition(b).y,k.clickPosForZoomNew=k.clickPosForZoom,k.fixed||(k.tempScale=k.scale,window.addEventListener("mousemove",h))):"L"==k.whichButton&&(k.evaluator.setVariable(k.id+".mouse_pressed",1),k.posAnte=k.getCursorPosition(b),k.oldMouse.x=k.getRelativeX(k.posAnte.x),k.oldMouse.y=k.getRelativeY(k.posAnte.y),e(b),window.addEventListener("mousemove",
g),window.addEventListener("mouseup",f));b.preventDefault()}function f(a){document.body.focus();k.click=0;k.evaluator.setVariable(k.id+".mouse_pressed",0);a.preventDefault();"R"===k.whichButton&&(window.removeEventListener("mousemove",h,!1),k.clickPosForZoom==k.clickPosForZoomNew&&k.parent.externalSpace.show());window.removeEventListener("mousemove",g,!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);70<Date.now()-m&&(k.parent.update(),m=Date.now())}function h(a){a.preventDefault();k.clickPosForZoomNew=k.getCursorPosition(a).y;k.evaluator.setVariable(k.scaleStr,k.tempScale+k.tempScale/45*((k.clickPosForZoom-k.clickPosForZoomNew)/10));k.parent.update()}function g(b){if(!k.fixed&&k.click){C=parseInt(50*(k.oldMouse.x-k.mouse_x));z=parseInt(50*(k.oldMouse.y-k.mouse_y));if(C!==k.disp.x||z!==k.disp.y)k.alpha=
a.degToRad(k.evaluator.getVariable(k.rotZStr)),k.beta=a.degToRad(-k.evaluator.getVariable(k.rotYStr)),k.alpha=l(a.radToDeg(k.alpha)-C),k.beta=l(a.radToDeg(k.beta)-z),k.evaluator.setVariable(k.rotZStr,k.alpha),k.evaluator.setVariable(k.rotYStr,-k.beta),k.disp.x=C,k.disp.y=z,k.oldMouse.x=k.getRelativeX(k.posAnte.x),k.oldMouse.y=k.getRelativeY(k.posAnte.y);e(b);b.preventDefault()}}var k=this,m=0;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(g,c){a.Space.call(this,g,c);this.exportarVars=this.importarVars=null;e=g.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 c=document.getElementById(this.oldFile);e=c&&"descartes/spaceApFile"==c.type?c.text:a.openExternalFile(this.oldFile);null!=e&&(e=e.split("\n"))}if(e&&e.toString().match(/<applet/gi)){for(var c="",d=!1,b=0,h=e.length;b<h&&(e[b].match("<applet")&&(d=!0),d&&(c+=e[b]),!e[b].match("</applet"));b++);b=document.createElement("div");b.innerHTML=c;
b.firstChild.setAttribute("width",this.w);b.firstChild.setAttribute("height",this.h);c=this.descApp?this.descApp.container:null;this.descApp=new a.DescartesApp(b.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+";");c?this.parent.container.replaceChild(this.descApp.container,
c):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);c=this.descApp.spaces;b=0;for(h=c.length;b<h;b++)c[b].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var l=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();l.exportar()}}else c=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),
this.descApp.container.setAttribute("class","DescartesAppContainer"),b="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?b+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?b+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":
"patch"==this.bg_display?b+="background-image: url("+this.imageSrc+");":"imgcenter"==this.bg_display&&(b+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",b),c?this.parent.container.replaceChild(this.descApp.container,c):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),c=this.y!=this.evaluator.evalExpression(this.yExpr)+this.plecaHeight;this.x=a?this.evaluator.evalExpression(this.xExpr):this.x;this.y=c?this.evaluator.evalExpression(this.yExpr)+this.plecaHeight:this.y;a&&(this.descApp.container.style.left=this.x+"px");c&&(this.descApp.container.style.top=this.y+"px");if(a||
c)for(var a=this.descApp.spaces,c=0,d=a.length;c<d;c++)a[c].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 b in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(b)&&b.match(/^public./)&&this.importarVars.push({varName:b,value:this.evaluator.getVariable(b)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,
c=!1,d=0,b=this.importarVars.length;d<b;d++)a=this.evaluator.getVariable(this.importarVars[d].varName),a!=this.importarVars[d].value&&(this.importarVars[d].value=a,this.descApp.evaluator.setVariable(this.importarVars[d].varName,this.importarVars[d].value),c=!0);c&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var e,g,c,d,b;a.SpaceHTML_IFrame=function(b,c){a.Space.call(this,b,c);var d=this.parent.evaluator;
window.navigator.userAgent.toLowerCase().match(/firefox/);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=d.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=d.parser.parse(this.file):this.file=d.parser.parse("'"+this.file+"'");this.oldFile=d.evalExpression(this.file);this.MyIFrame=document.createElement("iframe");0!=this.oldFile&&this.MyIFrame.setAttribute("src",this.oldFile);this.MyIFrame.setAttribute("id",
this.id);this.MyIFrame.setAttribute("marginheight",0);this.MyIFrame.setAttribute("marginwidth",0);this.MyIFrame.setAttribute("frameborder",0);this.MyIFrame.setAttribute("scrolling","auto");this.MyIFrame.setAttribute("style","position: static; left: 0px; top: 0px;");this.container=document.createElement("div");a.isIOS?this.container.setAttribute("style","overflow: scroll; -webkit-overflow-scrolling: touch; position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+
"px; z-index: "+this.zIndex+";"):this.container.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.container.appendChild(this.MyIFrame);this.parent.container.insertBefore(this.container,this.parent.loader);var e=this;this.MyIFrame.onload=function(a){var b=this;e.evaluator.setFunction(e.id+".set",function(a,c){b.contentWindow.postMessage({type:"set",name:a,value:c},"*");return 0});e.evaluator.setFunction(e.id+
".update",function(){b.contentWindow.postMessage({type:"update"},"*");return 0});e.evaluator.setFunction(e.id+".exec",function(a,c){b.contentWindow.postMessage({type:"exec",name:a,value:c},"*");return 0})};this.update=this.iframeUpdate;this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.init=function(){b=this;b.uber.init.call(b);b.MyIFrame&&(b.MyIFrame.style.width=b.w+"px",b.MyIFrame.style.height=b.h+"px",b.MyIFrame.style.left=b.x+"px",
b.MyIFrame.style.top=b.y+"px")};a.SpaceHTML_IFrame.prototype.iframeUpdate=function(b){e=this.evaluator;this.drawIfValue=0<e.evalExpression(this.drawif);a.isIOS?this.container.style.display=this.drawIfValue?"block":"none":this.container.style.visibility=this.drawIfValue?"visible":"hidden";if(this.drawIfValue){b&&(this.y=this.x=Infinity);g=this.x!==e.evalExpression(this.xExpr)+this.displaceRegionWest;c=this.y!==e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=g?e.evalExpression(this.xExpr)+
this.displaceRegionWest:this.x;this.y=c?e.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(g||c)this.container.style.left=this.x+"px",this.container.style.top=this.y+"px";d=e.evalExpression(this.file);d!==this.oldFile&&(this.oldFile=d,this.MyIFrame.setAttribute("src",d));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 c=a.image_loader?a.image_loader:d(a.loader.width,
a.loader.height);this.imageLoader=document.createElement("div");this.imageLoader.width=a.width;this.imageLoader.height=a.height;this.imageLoader.setAttribute("class","DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image: url("+c+"); background-size:cover; 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=80;this.barHeight=Math.floor(a.loader.height/70);var e=this;this.timer=setInterval(function(){e.drawLoaderBar(e.loaderBar.ctx,a.width,a.height)},10);a.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var b=this.children,c=this.images,d=this.audios,f=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,
e=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav)/gi;this.arquimedes&&(c["lib/DescartesCCLicense.png"]=a.getCreativeCommonsLicenseImage(),c["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=1}),c["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=1}));var g,k,q,s,u,m;q=0;for(u=b.length;q<u;q++)if("rtf"!==b[q].name){if(b[q].value.match(/'macro'|'makro'/g)){g="";var v;k=this.lessonParser.split(b[q].value);m=0;for(var n=k.length;m<n;m++)"expresion"===babel[k[m][0]]&&
(g=k[m][1]);g&&((v=document.getElementById(g))&&"descartes/macro"==v.type?v=v.text:(v=a.openExternalFile(g))&&!v.match(/tipo_de_macro/g)&&(v=null));if(v&&(g=v.match(f)))for(m=g.length;s<m;s++)k=g[s],k.toLowerCase().match(/vacio.gif$/)||""==k.substring(0,k.length-4)||(c[k]=new Image,c[k].addEventListener("load",function(){this.ready=1}),c[k].addEventListener("error",function(){this.errorload=1}),c[k].src=k)}if(g=b[q].value.match(f))for(s=0,m=g.length;s<m;s++)k=g[s],k.toLowerCase().match(/vacio.gif$/)||
""==k.substring(0,k.length-4)||(c[k]=new Image,c[k].addEventListener("load",function(){this.ready=1}),c[k].addEventListener("error",function(){this.errorload=1}),c[k].src=k);if(g=b[q].value.match(e))for(s=0,k=g.length;s<k;s++)this.initAudio(g[s])}for(var t in c)c.hasOwnProperty(t)&&this.images.length++;for(t in d)d.hasOwnProperty(t)&&this.audios.length++;var w=this,A=this.images.length+this.audios.length;this.sep=2*(this.barWidth-2)/A;var B=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!=A?setTimeout(B,30):(clearTimeout(w.timer),w.descartesApp.initBuildApp())};B()};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},f=function(){this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))||"mp3"!=this.filename.substring(this.filename.length-3)?(console.log("El archivo '"+
b+"' no puede ser reproducido"),this.errorload=1):(c[b]=new Audio(this.filename.replace("mp3","ogg")),c[b].filename=this.filename.replace("mp3","ogg"),c[b].addEventListener("canplaythrough",d),c[b].addEventListener("load",d),c[b].addEventListener("error",f),c[b].load())};c[b].addEventListener("canplaythrough",d);c[b].addEventListener("load",d);c[b].addEventListener("error",f);a.hasTouchSupport?(c[b].load(),c[b].play(),setTimeout(function(){console.log("detenido");c[b].pause()},10),c[b].ready=1):c[b].load()};
var g,c;a.DescartesLoader.prototype.drawLoaderBar=function(a,d,l){g=this.barWidth;c=this.barHeight;a.translate(d/2,(l-65*e)/2+90*e);a.scale(e,e);a.strokeRect(-g,-c,2*g,c);a.fillStyle="#888";a.fillRect(-g+2,-c+2,2*(g-2),c-4);a.fillStyle="#1f358d";a.fillRect(-g+2,-c+2,this.readys*this.sep,c-4);a.setTransform(1,0,0,1,0,0)};var d=function(b,c){var d=document.createElement("canvas"),f=5E6<b*a._ratio*c*a._ratio?1:a._ratio;d.width=b*f;d.height=c*f;d.style.width=b+"px";d.style.height=c+"px";var g=d.getContext("2d");
g.save();g.setTransform(f,0,0,f,0,0);g.strokeStyle=g.fillStyle="#1f358d";g.lineCap="round";g.lineWidth=2;g.beginPath();e=b<c?b/360:c/195;e=2.5<e?2.5:e;g.translate((b-120*e)/2,(c-65*e)/2);g.scale(e,e);g.moveTo(3,25);g.lineTo(3,1);g.lineTo(21,1);g.bezierCurveTo(33,1,41,15,41,25);g.stroke();g.beginPath();g.moveTo(1,63);g.lineTo(1,64);g.moveTo(5,62);g.lineTo(5,64);g.moveTo(9,61);g.lineTo(9,64);g.moveTo(13,60);g.lineTo(13,64);g.moveTo(17,58);g.lineTo(17,64);g.moveTo(21,56);g.lineTo(21,64);g.moveTo(25,
53);g.lineTo(25,64);g.moveTo(29,50);g.lineTo(29,64);g.moveTo(33,46);g.lineTo(33,64);g.moveTo(37,41);g.lineTo(37,64);g.moveTo(41,32);g.lineTo(41,64);g.stroke();g.font="20px descartesJS_sansserif, Arial, Helvetica, Sans-serif";g.fillText("escartes",45,33);g.fillText("JS",98,64);g.restore();return d.toDataURL()};return a}(descartesJS||{}),descartesJS=function(a){function e(a){for(var d="[",b=0,h=a.length;b<h;b++)a[b]instanceof Array?d+=e(a[b]):(g=a[b],"undefined"!=typeof g&&g||(g=0),"string"==typeof g&&
(g="'"+g+"'"),d+=g),b<h-1&&(d+=",");return d+"]"}if(a.loadLib)return a;a.DescartesApp=function(c){this.animation={playing:!1,stop:function(){}};this.applet=c;this.parentContainer=c.parentNode;this.width=parseFloat(c.getAttribute("width"));this.height=parseFloat(c.getAttribute("height"));this.decimal_symbol=".";this.decimal_symbol_regexp=new RegExp("\\"+this.decimal_symbol,"g");this.language="espa\u00f1ol";this.children=c.getElementsByTagName("param");a.creativeCommonsLicense=!0;for(var d=0,b=this.children.length;d<
b;d++)"CreativeCommonsLicense"==this.children[d].name&&(a.creativeCommonsLicense="no"==this.children[d].value?!1:!0);this.code=c.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.stop();this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.arquimedes=!!this.code.match("descinst.DescartesWeb2_0.class","i")||!!this.code.match("Arquimedes",
"i")||!!this.code.match("Discurso","i");this.licenseA=a.creativeCommonsLicense?"{\\rtf1\\uc0{\\fonttbl\\f0\\fcharset0 Arial;\\f1\\fcharset0 Arial;\\f2\\fcharset0 Arial;\\f3\\fcharset0 Arial;\\f4\\fcharset0 Arial;}{\\f0\\fs34 __________________________________________________________________________________ \\par \\fs22                                        Los contenidos de esta unidad did\u00e1ctica interactiva est\u00e1n bajo una  {\\*\\hyperlink licencia Creative Commons|http://creativecommons.org/licenses/by-nc-sa/2.5/es/}, si no se indica lo contrario.\\par                                        La unidad did\u00e1ctica fue creada con Arqu\u00edmedes, que es un producto de c\u00f3digo abierto, {\\*\\hyperlink Creditos|http://arquimedes.matem.unam.mx/Descartes5/creditos/conCCL.html}\\par }":
"";for(var c=this.children,d,b=0,e=0,g=a.creativeCommonsLicense?90:0,f=0,p=c.length;f<p;f++)d=c[f],"rtf_height"==d.name&&(b=parseInt(d.value)),"Buttons"==babel[d.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(d.value),e=this.buttonsConfig.height),"image_loader"==d.name&&(this.image_loader=d.value),"docBase"==d.name&&(this.docBase=d.value,d=document.createElement("base"),d.setAttribute("id","descartesJS_base"),d.setAttribute("href",this.docBase),document.head.appendChild(d));this.arquimedes&&
b&&(this.height=b+e+g);this.spaces=[];this.externalSpace&&document.body.removeChild(this.externalSpace.container);this.externalSpace=new a.SpaceExternal(this);this.northSpace={container:document.createElement("div"),controls:[]};this.southSpace={container:document.createElement("div"),controls:[]};this.eastSpace={container:document.createElement("div"),controls:[]};this.westSpace={container:document.createElement("div"),controls:[]};this.editableRegion={container:document.createElement("div"),textFields:[]};
a.Editor&&(this.editor=new a.Editor(this));this.controls=[];this.auxiliaries=[];this.events=[];this.cacheVars={};this.getVarsNames={};this.plecaHeight=this.tabindex=this.zIndex=0;this.numberOfIframes=1;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 c=
this.children,d=this.lessonParser,b=[],e=[],g=[],f=[],p=[],r=[],k,q=0,s=c.length;q<s;q++)if(k=c[q],"language"==babel[k.name]&&(this.language=k.value),"pleca"==k.name)k=d.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=d.parseButtonsConfig(k.value);else if("decimal_symbol"==babel[k.name])this.decimal_symbol=k.value,this.decimal_symbol_regexp=new 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;f.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+k.value.replace(/'/g,"&squot;")+"'");f.push("space='descartesJS_scenario' type='text' expresion='["+u+","+(m-25)+"]' background='yes' text='"+this.licenseA+"'");a.creativeCommonsLicense&&
f.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++,b.push(k.value)):"C"==k.name.charAt(0)&&"_"==k.name.charAt(1)?e.push(k.value):"A"==k.name.charAt(0)&&"_"==k.name.charAt(1)?g.push(k.value):"G"==k.name.charAt(0)?f.push(k.value):"S"==k.name.charAt(0)?p.push(k.value):"Animation"==babel[k.name]&&r.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));q=0;for(s=b.length;q<s;q++)c=d.parseSpace(b[q]),this.arquimedes&&this.scenarioRegion.container.appendChild(c.container),this.spaces.push(c),this.zIndex++;q=0;for(s=f.length;q<s;q++)if(b=d.parseGraphic(f[q]))b.visible&&(this.editableRegionVisible=!0),b.space.addGraph(b);q=0;for(s=p.length;q<s;q++)(b=d.parse3DGraphic(p[q]))&&b.space.addGraph(b,!0);q=0;for(s=e.length;q<s;q++)this.controls.push(d.parseControl(e[q]));q=0;for(s=g.length;q<s;q++)d.parseAuxiliar(g[q]);
q=0;for(s=r.length;q<s;q++)this.animation=d.parseAnimation(r[q]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();q=0;for(s=this.controls.length;q<s;q++)this.controls[q].init();this.updateControls();this.updateSpaces(!0);var v=this;this.numberOfIframes?setTimeout(function(){v.finishInit()},200*this.numberOfIframes):this.finishInit()};a.DescartesApp.prototype.finishInit=function(){this.update();this.loader.style.display="none";window.parent!==window&&(this.parentContainer.style.margin=
"0px",this.parentContainer.style.padding="0px",window.parent.postMessage({type:"reportSize",href:window.location.href,width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready"},"*"),a.onResize());window.opener&&window.opener.postMessage({type:"isResizeNeeded",href:window.location.href},"*");this.externalSpace.init()};a.DescartesApp.prototype.adjustSize=function(){document.body.style.margin="0px";document.body.style.padding="0px";this.parentContainer.style.margin="0px";this.parentContainer.style.padding=
"0px";var c=parseInt(this.width)+30,d=parseInt(this.height)+90;window.moveTo((parseInt(screen.width)-c)/2,(parseInt(screen.height)-d)/2);window.resizeTo(c,d);a.onResize()};a.DescartesApp.prototype.adjustDimensions=function(){var a,d,b;if(void 0==this.init_w||void 0==this.init_h)this.init_w=parseInt(this.container.style.width),this.init_h=parseInt(this.container.style.height);d=parseInt(this.parentContainer.offsetWidth);a=this.init_w;b=d/a;a>d?(this.parentContainer!=document.body&&(this.parentContainer.style.height=
this.init_h*b+"px"),this.percent=b,this.container.style.webkitTransform=this.container.style.MozTransform="scale("+b+")",this.container.style.webkitTransformOrigin=this.container.style.MozTransformOrigin="top left"):(this.parentContainer!=document.body&&(this.parentContainer.style.height="auto"),this.percent=1,this.container.style.webkitTransform=this.container.style.MozTransform="",this.container.style.webkitTransformOrigin=this.container.style.MozTransformOrigin="")};a.DescartesApp.prototype.configRegions=
function(){var c=this.evaluator.parser,d=this.buttonsConfig,b=this.container;if(2!=this.version)var e="15",g=100,f=100,p=100,r=100;else e="14",g=63,f=50,p=44,r=53;var k=0,q=0,s=0,u=s=0,m=0,v=0,n=0,t=0,v=this.northSpace.controls,w=this.southSpace.controls,A=this.eastSpace.controls,B=this.westSpace.controls;if(0<d.rowsNorth||0<v.length||d.about||d.config){0>=d.rowsNorth?(k=d.height,d.rowsNorth=1):k=d.height*d.rowsNorth;m=this.northSpace.container;m.setAttribute("id","descartesJS_northRegion");m.setAttribute("style",
"width:"+b.width+"px; height:"+k+"px; background:#c0c0c0; position:absolute; left:0px; top: "+this.plecaHeight+"px; z-index:100;");b.insertBefore(m,this.loader);var m=b.width,y=0;d.about?(y=g,m-=y):g=0;d.config&&(m-=f);for(var D=Math.ceil(v.length/d.rowsNorth),E=m/D,s=0,C=v.length;s<C;s++)v[s].expresion=c.parse("("+(y+s%D*E)+","+d.height*Math.floor(s/D)+","+E+","+d.height+")"),v[s].drawif=c.parse("1"),v[s].init();d.about&&(s="espa\u00f1ol"==this.language?"cr\u00e9ditos":"english"==this.language?"about":
"cr\u00e9ditos",s=new a.Button(this,{region:"north",name:s,font_size:c.parse(e),expresion:c.parse("(0, 0, "+g+", "+k+")")}),s.actionExec={execute:a.showAbout},s.update());d.config&&(new a.Button(this,{region:"north",name:"config",font_size:c.parse(e),action:"config",expresion:c.parse("("+(m+g)+", 0, "+f+", "+k+")")})).update()}if(0<d.rowsSouth||0<w.length||d.init||d.clear){0>=d.rowsSouth?(q=d.height,d.rowsSouth=1):q=d.height*d.rowsSouth;v=b.width;y=0;d.init?(y=p,v-=y):p=0;d.clear&&(v-=r);m=this.southSpace.container;
m.setAttribute("id","descartesJS_southRegion");m.setAttribute("style","width:"+b.width+"px; height:"+q+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(b.height-q)+"px; z-index:100;");b.insertBefore(m,this.loader);D=Math.ceil(w.length/d.rowsSouth);E=v/D;s=0;for(C=w.length;s<C;s++)w[s].expresion=c.parse("("+(y+s%D*E)+","+d.height*Math.floor(s/D)+","+E+","+d.height+")"),w[s].drawif=c.parse("1"),w[s].init();d.init&&(s="espa\u00f1ol"==this.language?"inicio":"english"==this.language?"init":
"inicio",(new a.Button(this,{region:"south",name:s,font_size:c.parse(e),action:"init",expresion:c.parse("(0, 0, "+p+", "+q+")")})).update());d.clear&&(s="espa\u00f1ol"==this.language?"limpiar":"english"==this.language?"clear":"limpiar",(new a.Button(this,{region:"south",name:s,font_size:c.parse(e),action:"clear",expresion:c.parse("("+(v+p)+", 0, "+r+", "+q+")")})).update())}if(0<A.length)for(s=b.height-k-q,n=d.widthEast,m=this.eastSpace.container,m.setAttribute("id","descartesJS_eastRegion"),m.setAttribute("style",
"width:"+n+"px; height:"+s+"px; background:#c0c0c0; position:absolute; left:"+(b.width-n)+"px; top:"+k+"px; z-index:100;"),b.insertBefore(m,this.loader),s=0,C=A.length;s<C;s++)A[s].expresion=c.parse("(0,"+d.height*s+","+n+","+d.height+")"),A[s].drawif=c.parse("1"),A[s].init();if(0<B.length)for(s=b.height-k-q,t=d.widthWest,m=this.westSpace.container,m.setAttribute("id","descartesJS_westRegion"),m.setAttribute("style","width: "+t+"px; height: "+s+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+
k+"px; z-index: 100;"),b.insertBefore(m,this.loader),s=0,C=B.length;s<C;s++)B[s].expresion=c.parse("(0,"+d.height*s+","+t+","+d.height+")"),B[s].drawif=c.parse("1"),B[s].init();if(this.editableRegionVisible)for(u=d.height,m=this.editableRegion.container,m.setAttribute("id","descartesJS_editableRegion"),m.setAttribute("style","width:"+b.width+"px; height:"+u+"px; position:absolute; left:0px; top:"+(b.height-q-d.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;"),b.insertBefore(m,this.loader),
c=this.editableRegion.textFields,d=b.width/c.length,e=a.getFieldFontSize(u),s=0,C=c.length;s<C;s++)"div"==c[s].type?(m.appendChild(c[s].container),c[s].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+(d-4)+"px; height: "+u+"px; position: absolute; left: "+s*d+"px; top: 0px;"),g=c[s].container.firstChild,g.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+e+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+
u+"px; text-align: center; line-height: "+u+"px;"),f=g.offsetWidth,g.style.width=f+"px",g.firstChild.textContent=g.firstChild.textContent.substring(3,g.firstChild.textContent.length-3),c[s].container.lastChild.setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+e+"px; width:"+(d-f)+"px; height:"+u+"px; position:absolute; left:"+f+"px; top:0px; border:2px groove white;")):(m.appendChild(c[s]),c[s].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+
e+"px; width:"+d+"px; height:"+u+"px; position:absolute; left:"+s*d+"px; top:0px; border:2px groove white;"));this.displaceRegionNorth=k;this.displaceRegionWest=t;b.width-=n;b.height=b.height-q-u;s=0;for(C=this.spaces.length;s<C;s++)this.spaces[s].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateControls();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.clearClick=function(){for(var a=0,d=this.spaces.length;a<d;a++)this.spaces[a].clearClick()};
a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,d=0,b=this.controls.length;d<b;d++)a=this.controls[d],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,d=this.auxiliaries.length;a<d;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=function(){for(var a=0,d=this.events.length;a<d;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,d=this.controls.length;a<d;a++)this.controls[a].update()};
a.DescartesApp.prototype.updateSpaces=function(a){for(var d=0,b=this.spaces.length;d<b;d++)this.spaces[d].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,d=this.spaces.length;a<d;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground&&this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&
this.animation.play()};a.DescartesApp.prototype.stopAudios=function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),this.audios[a].currentTime=0)};a.DescartesApp.prototype.getImage=function(a){var d=this.images;if(a)return d[a]||(d[a]=new Image,d[a].addEventListener("load",function(){this.ready=1}),d[a].addEventListener("error",function(){this.errorload=1}),d[a].src=a),d[a]};a.DescartesApp.prototype.getAudio=function(a){var d=this.audios;
if(a){if(!d[a]){var b=a.lastIndexOf("."),b=-1===b?a.lenght:b;a.substring(0,b);d[a]=new Audio(a);var e=function(a){this.ready=1};d[a].addEventListener("canplaythrough",e);var g=function(b){this.canPlayType("audio/"+a.substring(a.length-3))||"mp3"!=a.substring(a.length-3)?(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1):(d[a]=new Audio(a.replace("mp3","ogg")),d[a].addEventListener("canplaythrough",e),d[a].addEventListener("load",e),d[a].addEventListener("error",g),d[a].load())};
d[a].addEventListener("error",g);d[a].play();setTimeout(function(){d[a].pause()},15)}return d[a]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var d,b=0,e=this.controls.length;b<e;b++)if(d=this.controls[b],d.cID==a)return d;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var d,b=0,e=this.controls.length;b<e;b++)if(d=this.controls[b],d.id==a)return d;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var d,
b=0,e=this.spaces.length;b<e;b++)if(d=this.spaces[b],d.cID==a)return d;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var d,b=0,e=this.spaces.length;b<e;b++)if(d=this.spaces[b],d.id==a)return d;return{update:function(){},w:0}};var g;a.DescartesApp.prototype.getState=function(){var a,d="",b=this.evaluator.variables,h;for(h in b)b.hasOwnProperty(h)&&(a=b[h],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&"rnd"!=h&&"pi"!=h&&"e"!=h&&"Infinity"!=h&&"-Infinity"!=h&&
"object"!=typeof a&&(d=""!=d?d+"\n"+h+"="+a:h+"="+a));var b=this.evaluator.vectors,g;for(g in b)b.hasOwnProperty(g)&&(a=b[g],d=d+"\n"+g+"="+e(a));g=this.evaluator.matrices;for(var f in g)g.hasOwnProperty(f)&&(a=g[f],d=d+"\n"+f+"="+e(a));return d};a.DescartesApp.prototype.setState=function(a,d){for(var b=a.split("\n"),e,g,f=0,p=b.length;f<p;f++)e=b[f].split("="),2<=e.length&&(g=eval(e[1]),-1!=e[1].indexOf("[[")?(this.evaluator.matrices[e[0]]=g,this.evaluator.matrices[e[0]].rows=g.length,this.evaluator.matrices[e[0]].cols=
g[0].length):-1!=e[1].indexOf("[")?(this.evaluator.vectors[e[0]]=g,this.evaluator.variables[e[0]+".long"]=g.length):this.evaluator.variables[e[0]]=g);d||this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,d=0,b="",e=0,g=this.controls.length;e<g;e++)"textfield"==this.controls[e].gui&&this.controls[e].evaluate&&(a++,d+=this.controls[e].ok,this.controls[e].value=""==this.controls[e].value?"''":this.controls[e].value,b+=" \\n "+this.controls[e].id+"="+this.controls[e].value+"|"+
this.controls[e].ok);return"questions="+a+" \\n correct="+d+" \\n wrong="+(a-d)+b};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,d=0,b=a.length;d<b;d++)"textfield"==a[d].gui&&a[d].evaluate&&a[d].changeValue(a[d].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,d=this.saveState.length;a<d;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 g(b){b=document.createElement("div");b.innerHTML='<span style="font:12px descartesJS_serif;visibility:hidden;">_</span><span style="font:12px descartesJS_sansserif;visibility:hidden;">_</span><span style="font:12px descartesJS_monospace;visibility:hidden;">_</span>';
document.body.appendChild(b);a.getFeatures();if(a.hasCanvasSupport){window.scrollTo(0,10);for(var c=document.getElementsByTagName("*"),d=[],e=0,g=c.length;e<g;e++)"DescartesAppContainer"==c[e].className&&d.push(c[e]);e=0;for(g=d.length;e<g;e++)d[e].parentNode.removeChild(d[e]);for(var d=document.getElementsByTagName("applet"),e=document.getElementsByTagName("ajs"),c=[],k=0,q=d.length;k<q;k++)g=d[k],(g.getAttribute("code").match("DescartesJS")||g.getAttribute("code").match("descinst.DescartesWeb2_0.class")||
g.getAttribute("code").match("Descartes")||g.getAttribute("code").match("Arquimedes")||g.getAttribute("code").match("Discurso"))&&c.push(g);k=0;for(q=e.length;k<q;k++)g=e[k],(g.getAttribute("code").match("DescartesJS")||g.getAttribute("code").match("descinst.DescartesWeb2_0.class")||g.getAttribute("code").match("Descartes")||g.getAttribute("code").match("Arquimedes")||g.getAttribute("code").match("Discurso"))&&c.push(g);d=0;for(e=c.length;d<e;d++)a.apps.push(new a.DescartesApp(c[d])),c[d].className=
"DescartesJS";window.addEventListener("resize",a.onResize);window.scrollTo(0,2);document.body.setAttribute("tabIndex",1E6)}else document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:block;} applet {display:block;} ajs.DescartesJS {display:block;} ajs {display:block;}";document.body.removeChild(b)}if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};window.hasOwnProperty("debugDescartesJS")&&debugDescartesJS||e();a.onResize=function(b){for(var c=
0,d=a.apps.length;c<d;c++){b=a.apps[c].spaces;for(var e=0,g=b.length;e<g;e++)b[e].findOffset()}};a.receiveMessage=function(b){if(0<a.apps.length){var c=b.data;if(c)if("set"===c.type)"string"==typeof c.value||"number"==typeof c.value?a.apps[0].evaluator.setVariable(c.name,c.value):c.value&&void 0!=c.value.rows?a.apps[0].evaluator.matrices[c.name]=c.value:a.apps[0].evaluator.vectors[c.name]=c.value;else if("update"===c.type)a.apps[0].update();else if("exec"===c.type){b=a.apps[0].evaluator.getFunction(c.name);
var d=[];""!==c.value&&(d=c.value.toString().split(","));b&&b.apply(a.apps[0].evaluator,d)}else"isResizeNeeded"===c.type?b.source.postMessage({type:"doResize"},"*"):"doResize"===c.type&&0<a.apps.length&&a.apps[0].adjustSize()}};if(void 0==a.loadLib){a.loadLib=!0;window.addEventListener("load",g);window.addEventListener("message",a.receiveMessage);for(var c=["webkitTransitionEnd","transitionend","oTransitionEnd","MSTransitionEnd"],d=0,b=c.length;d<b;d++)window.addEventListener(c[d],function(b){a.onResize(b)})}return a}(descartesJS||
{});
