/*
 Joel Espinosa Longi
 jlongi@im.unam.mx
 https://github.com/jlongi/DescartesJS
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2016-08-30
*/
var babel=function(a){if(a.loadLib)return a;a.loadLib=!0;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.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.a_left="left";a.a_center="center";a.a_right="right";a.malla=a.mesh="mesh";a.local=a.Local="local";a.rectangle=a["rect\u00e1ngulo"]="rectangle";a.lineDash="lineDash";a.solid="solid";a.dot="dot";a.dash="dash";a.dash_dot="dash_dot";a.antialias="antialias";a.image_loader="image_loader";a.expand="expand";a.cover=a.cubrir="expand";a.fit=
a.escalar="fit";return a}(babel||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e;a.serif_font="descartesJS_serif,Times,'Times New Roman','Liberation Serif','Nimbus Roman No9 L Regular',serif";a.sansserif_font="descartesJS_sansserif,Helvetica,Arial,'Liberation Sans','Nimbus Sans L',sans-serif";a.monospace_font="descartesJS_monospace,'Courier New',Courier,'Liberation Mono','Nimbus Mono L',monospace";a.convertFont=function(c){if(""==c)return c;h=c.split(",");e="";"bold"==h[1].toLowerCase()?
e+="Bold ":"italic"==h[1].toLowerCase()||"italics"==h[1].toLowerCase()?e+="Italic ":"bold+italic"==h[1].toLowerCase()&&(e+="Italic Bold ");fontName=h[0].split(" ")[0].toLowerCase();e+=h[2]+"px ";return e="serif"===fontName||"times new roman"===fontName||"timesroman"===fontName||"times"===fontName?e+a.serif_font:"sansserif"===fontName||"arial"===fontName||"helvetica"===fontName?e+a.sansserif_font:e+a.monospace_font};a.getTextWidth=function(c,d){a.ctx.font=d;return Math.round(a.ctx.measureText(c).width)};
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};var d={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},ss_100:{a:78,d:26},ss_101:{a:78,d:26},ss_102:{a:78,d:26},ss_103:{a:78,d:26},ss_104:{a:78,d:26},ss_105:{a:78,d:26},ss_106:{a:78,d:26},ss_107:{a:78,d:26},ss_108:{a:78,d:26},ss_109:{a:78,d:26},ss_110:{a:78,d:26},ss_111:{a:78,d:26},
ss_112:{a:78,d:26},ss_113:{a:78,d:26},ss_114:{a:78,d:26},ss_115:{a:78,d:26},ss_116:{a:78,d:26},ss_117:{a:78,d:26},ss_118:{a:78,d:26},ss_119:{a:78,d:26},ss_120:{a:78,d:26},ss_121:{a:78,d:26},ss_122:{a:78,d:26},ss_123:{a:78,d:26},ss_124:{a:78,d:26},ss_125:{a:78,d:26},ss_126:{a:78,d:26},ss_127:{a:78,d:26},ss_128:{a:78,d:26},ss_129:{a:78,d:26},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},s_100:{a:78,d:26},s_101:{a:78,d:26},s_102:{a:78,d:26},s_103:{a:78,d:26},s_104:{a:78,d:26},s_105:{a:78,d:26},
s_106:{a:78,d:26},s_107:{a:78,d:26},s_108:{a:78,d:26},s_109:{a:78,d:26},s_110:{a:78,d:26},s_111:{a:78,d:26},s_112:{a:78,d:26},s_113:{a:78,d:26},s_114:{a:78,d:26},s_115:{a:78,d:26},s_116:{a:78,d:26},s_117:{a:78,d:26},s_118:{a:78,d:26},s_119:{a:78,d:26},s_120:{a:78,d:26},s_121:{a:78,d:26},s_122:{a:78,d:26},s_123:{a:78,d:26},s_124:{a:78,d:26},s_125:{a:78,d:26},s_126:{a:78,d:26},s_127:{a:78,d:26},s_128:{a:78,d:26},s_129:{a:78,d:26},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},m_100:{a:78,
d:26},m_101:{a:78,d:26},m_102:{a:78,d:26},m_103:{a:78,d:26},m_104:{a:78,d:26},m_105:{a:78,d:26},m_106:{a:78,d:26},m_107:{a:78,d:26},m_108:{a:78,d:26},m_109:{a:78,d:26},m_110:{a:78,d:26},m_111:{a:78,d:26},m_112:{a:78,d:26},m_113:{a:78,d:26},m_114:{a:78,d:26},m_115:{a:78,d:26},m_116:{a:78,d:26},m_117:{a:78,d:26},m_118:{a:78,d:26},m_119:{a:78,d:26},m_120:{a:78,d:26},m_121:{a:78,d:26},m_122:{a:78,d:26},m_123:{a:78,d:26},m_124:{a:78,d:26},m_125:{a:78,d:26},m_126:{a:78,d:26},m_127:{a:78,d:26},m_128:{a:78,
d:26},m_129:{a:78,d:26}},l={};document.createElement("canvas");var c;a.getFontMetrics=function(a){if(l[a])return l[a];c=parseInt(a.match(/(\d+\.*)+px/)[0]);var e;a.match("sansserif")?e="ss_":a.match("serif")?e="s_":a.match("monospace")&&(e="m_");e=d[e+c];e={ascent:e.a,descent:e.d,h:e.a+e.d,baseline:e.a};return l[a]=e};return a}(descartesJS||{}),descartesJS=function(a){function h(){var a,b,f,c,d,e,r,k,g;Number.prototype.oToFixed=Number.prototype.toFixed;Number.prototype.toFixed=function(p){p=p?p:0;
p=0>p?0:parseInt(p);a=this.toString();d=a.indexOf("e");-1!==d&&(e=a.split("e"),k="-"===e[0][0]?"-":"",r="-"===k?parseFloat(e[0].substring(1)).oToFixed(11):parseFloat(e[0]).oToFixed(11),g=parseInt(e[1]),b=r.indexOf("."),0>b+g?(b=0>b?1:b,a=k+"0."+Array(Math.abs(b+g)+1).join("0")+r.replace(".","")):(r=r.replace(".",""),a=k+r+Array(g-r.length+2).join("0")));b=a.indexOf(".");f="";if(-1===b)0<p&&(f="."),f+=Array(p+1).join("0"),a+=f;else if(c=a.length-b-1,c>=p)11>=p&&(a=parseFloat(a).oToFixed(p)),a=0<p?
a.substring(0,b+1+p):a.substring(0,b);else{var h=0;for(p-=c;h<p;h++)f+="0";a+=f}return a}}if(a.loadLib)return a;var e=2*Math.PI,d=360/e,l=e/360,c=Math.floor,g,k,b,v,u,n,r,p,x,f;a.rangeOK=1;a.cssScale=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 f in b.prototype)b.prototype.hasOwnProperty(f)&&(a.prototype[f]=b.prototype[f]);a.prototype.uber=b.prototype};a.radToDeg=function(a){return a*
d};a.degToRad=function(a){return a*l};a.drawLine=function(a,b,d,e,r,k,g){a.lineWidth=g||1;a.strokeStyle=k||"black";f=a.lineWidth%2?.5:0;a.beginPath();a.moveTo(c(b)+f,c(d)+f);a.lineTo(c(e)+f,c(r)+f);a.stroke()};a.getColor=function(a,f){if("string"==typeof f)return f;g=a.eval(f);k=c(255*g[0][0]);b=c(255*g[0][1]);v=c(255*g[0][2]);u=1-g[0][3];return"rgba("+k+","+b+","+v+","+u+")"};a.getFeatures=function(){var b=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&window.hasOwnProperty("ontouchstart")||
"ontouchstart"in window||/android/i.test(b);a.isIOS=/iPad|iPhone/i.test(navigator.userAgent);b=document.createElement("canvas");a.hasCanvas=b.getContext&&b.getContext("2d");a.hasCanvas&&(a.ctx=document.createElement("canvas").getContext("2d"),a._ratio=1.5);h()};a.removeNeedlessDecimals=function(a){var b,f;if("string"==typeof a&&(b=a.indexOf("."),-1!=b)){f=a.substring(b);if(0==parseFloat(f))return a.substring(0,b);for(var c=f.length;0<c;c--)if(0!=f.charAt(c))return a.substring(0,b+c+1)}return a};a.returnValue=
function(a){return"number"===typeof a?parseFloat(a.toFixed(11)):a};a.whichBtn=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(b,f){b.touches?(n=b.touches[0],r=n.pageX,p=n.pageY):(r=b.pageX,p=b.pageY);x=f.getBoundingClientRect();return{x:(r-window.pageXOffset-x.left)/a.cssScale,y:(p-window.pageYOffset-x.top)/a.cssScale}};window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||
window.msRequestAnimationFrame;window.cancelAnimationFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame;a.setInterval=function(a,b){function f(){(new Date).getTime()-c>=b&&(a.call(),c=(new Date).getTime());d.value=requestAnimationFrame(f)}if(!requestAnimationFrame)return setInterval(a,b);var c=(new Date).getTime(),d={};d.value=requestAnimationFrame(f);return d};a.clearInterval=function(a){a&&(cancelAnimationFrame?cancelAnimationFrame(a.value):clearInterval(a))};a.setTimeout=function(a,
b){function f(){(new Date).getTime()-c>=b?a.call():d.value=requestAnimationFrame(f)}if(!requestAnimationFrame)return setTimeout(a,b);var c=(new Date).getTime(),d={};d.value=requestAnimationFrame(f);return d};a.clearTimeout=function(a){a&&(cancelAnimationFrame?cancelAnimationFrame(a.value):clearTimeout(a))};a.showAbout=function(){var b="<html><head><style>body{text-align:center;}iframe{width:650px;height:73px;overflow:hidden;border:1px solid black;}dt{font-weight:bold;margin-top:10px;}</style></head><body><iframe src='http://arquimedes.matem.unam.mx/Descartes5/creditos/bannerPatrocinadores.html'></iframe><h2><a href='http://proyectodescartes.org/' target='_blank'>ProyectoDescartes.org</a><br><a href='http://descartesjs.org' target='_blank'>DescartesJS.org</a></h2><dl><dt>Dise&ntilde;o funcional:</dt><dd><nobr>Jos&eacute; Luis Abreu Leon,</nobr><nobr>Jos&eacute; R. Galo Sanchez,</nobr><nobr>Juan Madrigal Muga</nobr></dd><dt>Autores del software:</dt><dd><nobr>Jos&eacute; Luis Abreu Leon,</nobr><nobr>Marta Oliver&oacute; Serrat,</nobr><nobr>Oscar Escamilla Gonz&aacute;lez,</nobr><nobr>Joel Espinosa Longi</nobr></dd></dl><p>El software en Java est&aacute; bajo la licencia<a href='https://joinup.ec.europa.eu/software/page/eupl/licence-eupl'>EUPL v.1.1</a><br>El software en JavaScript est&aacute; bajo licencia<a href='http://www.gnu.org/licenses/lgpl.html'>LGPL</a></p><p>La documentaci&oacute;n y el c&oacute;digo fuente se encuentran en :<br><a href='http://arquimedes.matem.unam.mx/Descartes5/'>http://arquimedes.matem.unam.mx/Descartes5/</a></p>";
a.ccLicense&&(b+="<p>Este objeto, creado con Descartes, est&aacute; licenciadopor sus autores como<a href='https://creativecommons.org/licenses/by-nc-sa/4.0/deed.es'><nobr>Creative Commons</nobr></a><br><a href='https://creativecommons.org/licenses/by-nc-sa/4.0/deed.es'><img src='https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png'></a></p>");var b=b+"</body> </html>",f=window.open("","creditos","width=700,height=500,titlebar=0,toolbar=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0");
f.document.write(b);f.document.close()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e;a.cacheFiles={};a.openExternalFile=function(d){if(a.cacheFiles[d])return a.cacheFiles[d];h=null;var l=!1;if(window.XMLHttpRequest)try{l=new XMLHttpRequest}catch(c){l=!1}else if(window.ActiveXObject)try{l=new ActiveXObject("Msxml2.XMLHTTP")}catch(c){try{l=new ActiveXObject("Microsoft.XMLHTTP")}catch(g){l=!1}}e=l;e.open("GET",d,!1);try{e.send(null),h=200===e.status||304===e.status?
e.responseText:e.responseText||"",h.match(String.fromCharCode(65533))&&(e.open("GET",d,!1),e.overrideMimeType("text/plain; charset=ISO-8859-1"),e.send(null),h=e.responseText)}catch(c){console.log("Error to load the file :",d),h=null}return h};a.addExternalFileContent=function(d,e){a.cacheFiles[d]=e};return a}(descartesJS||{}),descartesJS=function(a){function h(a){m=a.indexOf("--radial--");-1!=m&&(a=a.substring(0,m));c=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};c[0]==c[c.length-1]&&"'"==
c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1),"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1)));"`"==c[0]&&"\u00b4"==c[c.length-1]&&(a.ignoreAcents=!0,c=c.substring(1,c.length-1),c[0]==c[c.length-1]&&"'"==c[0]&&(a.ignoreCaps=!0,c=c.substring(1,c.length-1)));"*"===c.charAt(0)&&"*"!==c.charAt(c.length-1)?c=c.substring(1)+"$":"*"!==c.charAt(0)&&"*"===c.charAt(c.length-1)?c="^"+c.substring(0,c.length-1):"*"!==c.charAt(0)&&"*"!==c.charAt(c.length-1)?c="^"+c+"$":
"*"===c.charAt(0)&&"*"===c.charAt(c.length-1)&&(c=c.substring(1,c.length-1));c=c.replace(/\?/g,"[\\S\\s]{1}");a.regExp=c;return a}function e(a,b){c=(a||"").trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};a.expr=c.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:b.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),expr:b.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function d(a,
b,c){b=parseFloat(b);v=a.expr[0];u=a.expr[1];n=c.eval(v.expr);r=c.eval(u.expr);p="("==v.type;x="["==v.type;f=")"==u.type;q="]"==u.type;return(p&&b>n||x&&b>=n)&&(f&&b<r||q&&b<=r)?1:0}function l(a){return a.toString().replace(/\u00e1/g,"a").replace(/\u00e9/g,"e").replace(/\u00ed/g,"i").replace(/\u00f3/g,"o").replace(/\u00fa/g,"u").replace(/\u00c1/g,"A").replace(/\u00c9/g,"E").replace(/\u00cd/g,"I").replace(/\u00d3/g,"O").replace(/\u00da/g,"U").replace(/\u00f1/g,"n").replace(/\u00d1/g,"N")}if(a.loadLib)return a;
var c,g,k,b,v,u,n,r,p,x,f,q,m;a.buildRegularExpresionsPatterns=function(a,b){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++){g=a[f].split("&");k=[];for(var r=0,m=g.length;r<m;r++)c=g[r],-1===c.indexOf(",")||"("!==c.charAt(0)&&"["!==c.charAt(0)||")"!==c.charAt(c.length-1)&&"]"!==c.charAt(c.length-1)?k.push(h(c)):k.push(e(c,b));a[f]=k}return a};a.escorrecto=
function(f,c,e,r){e=e||a.externalEvaluator;r=r||a.buildRegularExpresionsPatterns(f,e);c=l(c);f=0;for(var k=r.length;f<k;f++){g=r[f];b=!0;for(var m=0,p=g.length;m<p;m++)b=g[m].regExp?b&&!!c.match(new RegExp(l(g[m].regExp),"i")):b&&d(g[m],c,e);if(b)return 1}return 0};a.esCorrecto=function(f,e,r,k){r=r||a.externalEvaluator;k=k||a.buildRegularExpresionsPatterns(f,r);f=0;for(var m=k.length;f<m;f++){g=k[f];b=!0;for(var p=0,q=g.length;p<q;p++)(c=g[p].regExp)?(g[p].ignoreAcents&&(e=l(e),c=l(c)),g[p].ignoreCaps&&
(e=e.toLowerCase(),c=l(c).toLowerCase()),b=b&&!!e.match(c)):b=b=b&&d(g[p],e,r);if(b)return 1}return 0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.getCCLImg=function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAMAAABUFvrSAAABC1BMVEUAAAC1urSEhYRDREMNDg2EhoR5fHkpKSmRk5EbGxuRlJGVmZQoKShAQEBwcHCTmJNQUVAQEBBgYGCAgIC/v78ODg5QUFDf39/////v7++fn5+Rj49aV1jj4+PIx8cwMDB9f3zW1dUyMTGamJkZGRkNDA12c3SjoaEjHyC6ubkpKikoJSY/OzxoZWaHhoesq6s/NzljX2HPz891cnN4dXbx8fGflpqOh4uenZ0xLS4kJCQoKCjo5+ePj4+1tbUtLS3g3+Cvr6/JyMggICAqKip+e3wfGxyEgYIqJyeYlpd/gX5ubGyMiovLyst6fXmeoJ18f3xdXl2ChYJwcm81NjWWmZYyMzE+Pz6JjIk4KLQtAAACdUlEQVR4AdWVBXvbOhiFj8OcGBp/YU5UZrq0cse83f3/X7IvkS0rKnd8ym/8vFWOCD8u1g/JTxHH4glwEvGkZSSVBiedegCJxJksVLI5XZsvAMVSqQgUypKU7yZKXAFgO67nuY4NoKKJF1D1ieNXsVC+LwEQem23RjJ1VheUNw2HGTB9QeLCjDSaBmm12y1FAATejk8qtU405i6qvVBMVXCHKfQH7B2Oxi1F+JmJ4CxKEooz7A2Hq8xBz0vwI+4jPX0Ly2JlFe4a1hXxqS02NsdCNCQJxFnYWzSXmo2sFKNIHAdwiFPElGzvCCHGrV5EaHdP7BMdiENJpDgGuGSkDiSluEQccIhTgiTtMYBxLyK7f4m/uWYh/mESiuOwuQivWiy68se/RGQjfouYHeNDIZqLivz3xJuJjzRxAg4LMU3xGJzp3w4S11chye4B9QRnJSSLkxOidSH0KgAeYgenvnda76DjH5/WZ13MxGdy8gBt8pg0xeEhxuvnFyE5EOLy8ql4pk8e4BEFPau6vUD8HFUylxuT1uVw1NjVyaXgvNiV5E4xZynaICV9g7xsGuTV+npPErOK2tapy1VMf8gqvnFLy8kLZk1NXgmJaFOj45Q60ZFjFe4iUlyBTWq5HRdnP+gUcSvM60cemxnu4toN8g1RW9q/Zkt/u/jNdYdQ5lvFeGtZ79isHUO+PDbf4xvzYf6gr7k28NGy3uKb052O2byaPiGM3B+QXxz1B3PjIbpqfqNfphndCwo+KSLyb+NfhcBow8qE13/Omu8hPDY1EnxoCY8TGPlszeV/aDGLkITMARpA5f8vofWLrr1+xEpuzgPhj81XdrZiwA3vh8AAAAAASUVORK5CYII=";
return a};a.getSvgMenu=function(){return"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNIDYuNjQwMzMzNCw4IDExLjk5OTk5OSwxMi45NjI0NjMgMTcuMzU5NjY2LDggMTksOS41MTg3Njg2IDExLjk5OTk5OSwxNiA1LDkuNTE4NzY4NiBaIiBzdHlsZT0iZmlsbDojMDAwMDAwIi8+PC9zdmc+"};a.getSymbolFont=function(){return"data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAc4AA0AAAAAC1wACAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAHHAAAABwAAAAceHiLRUdERUYAAAcAAAAAHAAAAB4AJgART1MvMgAAAZwAAABgAAAAYFGA/ydjbWFwAAACHAAAAE8AAAFaI/wnfGdhc3AAAAb4AAAACAAAAAj//wADZ2x5ZgAAAoQAAAGYAAAB5LsyX9poZWFkAAABMAAAADUAAAA2Cgte2GhoZWEAAAFoAAAAIAAAACQLvAYpaG10eAAAAfwAAAAfAAAALDugCtVsb2NhAAACbAAAABgAAAAYAcACSm1heHAAAAGIAAAAFAAAACAADQAZbmFtZQAABBwAAAJyAAAFN+WBmcFwb3N0AAAGkAAAAGgAAAChGXyiwXicY2BkYGDgYGDYufJKSzy/zVcGbiAHCC7Od70Boi+vPezHoPovjbVYyB+skgkkCgBgEQwAAAAAeJxjYGRgYHP758bAwMHAwPD/OmsxA1AEBXADAGCZA/R4nGNgZGBg4GaQZADRWAAAA/AAJwAEBbwBkAAEAAAFeAUUAAAAyAV4BRQAAAKKAFIB9AEFAgIFAwYIBQICBIAAIv8KA///DwQAJwWAoGhGcmVlAEAADSO3Bkb+RgAABkYBukAAAA2SAwAAA5sFQgAAACAAAXic42CAAA4gZq1iCmGtYlgJocFsVTjtxTAJAHL5BrYAeJxjYGBgZoBgGQZGBhAIAfIYwXwWBgsgzcXAwcAEhAwMvMprlbf//w9Wxau8HMxm/P/1TsydYKheKGBkY4ALMIJ0MjGgAkaGYQ8AV3QMuQAAAAAAAAAAAAAaAEIAXABqAIQArADGAPJ4nFWQPUsDQRCGZ3bvNtngR+5iokFSxJiIhU3MqZCAlRKrNNoaiCBa24idP0AC9hGsxNJKWyGoEBE8S4sISWUhiBJE9ybunYK4xcDMMu8+zwKyVQBzTb6CBEhbUcjGDUjqKW7gET1Sj6f5Il8pV5fUs7rxEPRBOAXgObsCMd0kIGZlrCibcubsJM7qiBDuHeBw1H1qXXdd6tTleIki3sVX1axgE2/Du2G8w5ZZ+ap6D95LEXwGrhnefQbUAWZ8UjPwHEYwSzVqyHcP1Y16XqqW+YrGSUOwoxlkE7i/k7F4zpXNXkkPNF82uPtzcn6cqEePeIQbrM8XeEKnqXN1qdqBk59n3P865SAwsUfjgiUxY9kwb0CdOm73uvXkRnH4QBaKzGYzxvHnGTmU105UoNLnmXHMytgr/WcInJwfJ2pQDbMYka+qrR8/1z/LE3yB9X3uQ9o0d8QyjOlmJIQiMzHlF6ewiHOz+VHpV3OHeSciP2jS1r5IybdwaEjgOhsTqWmRCouPbXuA79dSMnQhhlRfXMW+Ackuf8l4nL2TT2sTQRjGn9mkTf9fFaF28CiySQotbSqlhZDeTet9u5kmC8lsmZ0ccil+EvEi6MGjRz+AB8GL+AkEL34EwWd231giFjyZQPb3zrzvO88+7wTAQ2WhUH32MWeFBt4LR+RPwjXyN+E6+afwEjbUjvAyGuqpcAPb6oXwCurqjfAqNtVH4TU8iraF17ETzfM3cC/6LLyJx7Vj4S3s1N5SiaqvMhqXqgIr7rwWjsgfhGvkL8J18g/hJdxXS8LL2FJPhBvoqK7wClbUS+FVPFDvhNfQVV+F13EcnQhvII5eCW/iPPouvIXjWoYL+pshRY4BDDR6JAuPgnxFdnyeciVllil3NPqMHOPrMu+IK2fcC7nDskeXPGWUy+4uWmhjD7iwWZoPjO7l1hf6Knf61KaZsV73U5dd++JIn5ncDY3u5lOXM9xttVnXxwwTXLLhGAnD2eQyHxOe8bghjwqrjqEZTseJuzv/rvXn7OMoNitfXuMAMSW3uGFckeVWH8St1r+21WwT3LOMg1thZVIekGLEyNLpkGF4yLyHzgptc68TPTEuHSV2kBWG2z1WGX7Rc4a/d9uMBd8WJRWlpPBe5xQQKv8cep9CK2HBxwGFxbfiCp1ZfT4yej69vqe+xA3imDkjlnrehA6a/E7L9wpWxlw1PKQaTUzJjvs3fLZxyLvQ5jFNlnt/3Wk2pwWNjr3JOL546Jo3w/bhXnvAhAnrQxdPsZ2F6pO/nIBJko193qnKT343xMK9rszw1F5NKgzel0Ykpd/h5le+3/4Hgj0zPqcyudKg6h7THj/iAIvMG504o684rPJ2J3am+Wr/w6hfAuryBAAAeJxjYGIAg39yDCIM2AA3EDMyMDEyMTIzsjCyMrIxsjNyMHJyJxUlJqfmpKaVlBTwwNm5mSkIiaQSdjA7tQKioCgzPQOomhfBASpHkkoqES5KTMlMTswprsxNys9Jyi8pyc8FAAbWKdwAAAAB//8AAnicY2BkYGDgAWIxIGZiAPG4gCQLmMcAAAP/ADgAAAABAAAAANMrgh4AAAAA0Z9F2AAAAADTrcNO"};
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.floor,e=Math.min,d,l,c,g,k,b,v,u,n,r,p,x,f;a.Color=function(a,b){this.b=this.g=this.r=0;this.a=1;this.evaluator=b;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.getColorStr),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.getColorStr),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.getColorStr),"("===a[0]){l=[];c=this.splitComa(a.substring(1,a.length-1));for(var f=0,d=c.length;f<d;f++)g=parseInt(c[f],
16),c[f]!=g.toString(16)&&c[f]!=="0"+g.toString(16)?("["===c[f].charAt(0)&&"]"===c[f].charAt(c[f].length-1)&&(c[f]=c[f].substring(1,c[f].length-1)),l.push(this.evaluator.parser.parse(c[f]))):l.push(this.evaluator.parser.parse((g/255).toString()));this.rExpr=l[0];this.gExpr=l[1];this.bExpr=l[2];this.aExpr=l[3];this.getColor=this.getColorExp}}else this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorStr};a.Color.prototype.splitComa=function(a){k=[];for(var f=
u=v=b=0,c=a.length;f<c;f++)n=a.charAt(f),"("===n?b++:")"===n?b--:"["===n?v++:"]"===n?v--:","===n&&0===b&&0===v&&(k.push(a.substring(u,f)),u=f+1);k.push(a.substring(u));return k};a.Color.prototype.getColorStr=function(){return this.colorStr};a.Color.prototype.getColorExp=function(){d=this.evaluator;this.r=e(255,h(255*d.eval(this.rExpr)));this.g=e(255,h(255*d.eval(this.gExpr)));this.b=e(255,h(255*d.eval(this.bExpr)));this.a=1-d.eval(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(",");r=parseInt(b[0]).toString(16);p=parseInt(b[1]).toString(16);x=parseInt(b[2]).toString(16);f=(255-parseInt(255*parseFloat(b[3]))).toString(16);r=1==r.length?"0"+r:r;p=1==p.length?"0"+p:p;x=1==x.length?"0"+x:x;f=1==f.length?"0"+f:f;return new a.Color(f+r+p+x)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=
document.head,e=document.createElement("meta");e.setAttribute("http-equiv","X-UA-Compatible");e.setAttribute("content","IE=edge,chrome=1");h.appendChild(e);e=document.createElement("meta");e.setAttribute("name","viewport");e.setAttribute("content","width=device-width,initial-scale=1.0,user-scalable=yes");document.querySelector("meta[name=viewport]")||h.appendChild(e);e=document.createElement("meta");e.setAttribute("name","apple-mobile-web-app-capable");e.setAttribute("content","yes");h.appendChild(e);
e=document.createElement("meta");e.setAttribute("name","apple-mobile-web-app-status-bar-style");e.setAttribute("content","black");h.appendChild(e);e=document.createElement("meta");e.setAttribute("name","DescartesJS_author");e.setAttribute("content","Joel Espinosa Longi");h.appendChild(e);(h=document.getElementById("StyleDescartesApps2"))&&h.parentNode.removeChild(h);h=document.createElement("style");h.type="text/css";h.id="StyleDescartesApps2";h.setAttribute("rel","stylesheet");document.head.insertBefore(h,
document.head.firstChild);h.innerHTML="@font-face{font-family:'DescartesJS_symbola';src:url('"+a.getSymbolFont()+"') format('woff');}\nhtml,*,*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}\ndiv.DescartesCatcher{background-color:rgba(255,255,255,0);cursor:pointer;position:absolute;}\ndiv.DescartesAppContainer{border:0 solid #000;overflow:hidden;position:relative;top:0;left:0;}\ndiv.DescartesLoader{background-color:#CACACA;overflow:hidden;position:absolute;top:0;left:0;}\ndiv.DescartesLoaderImage{position:absolute;background-repeat:no-repeat;background-position:center;overflow:hidden;top:0;left:0;}\ncanvas.DescartesLoaderBar{position:absolute;overflow:hidden;top:0;left:0;}\ncanvas.DescartesSpace2DCanvas,canvas.DescartesSpace3DCanvas,div.blocker{touch-action:none;position:absolute;overflow:hidden;left:0;top:0;}\ndiv.DescartesSpace2DContainer,div.DescartesSpace3DContainer{position:absolute;overflow:hidden;line-height:0;}\ncanvas.DescartesButton{position:absolute;cursor:pointer;}\ndiv.DescartesButtonContainer{position:absolute;overflow:hidden;}\ndiv.DescartesButtonContainer div{display:inline-flex;justify-content:center;align-items:center;width:100%;height:100%;}\ndiv.DescartesButtonContainer[data-active='false']::after{content:' ';position:absolute;left:0;top:0;width:100%;height:100%;background:rgba(240,240,240,0.6);pointer-events:none;}\ndiv.DescartesSpinnerContainer,div.DescartesTextFieldContainer,div.DescartesMenuContainer{background:lightgray;position:absolute;overflow:hidden;}\ndiv.DescartesSpinnerContainer input,div.DescartesTextFieldContainer input,div.DescartesMenuContainer select{border-radius:0;}\ninput.DescartesSpinnerField,input.DescartesTextFieldField,input.DescartesMenuField,input.DescartesScrollbarField{font-family:"+
a.sansserif_font+";padding:0 2px;border:solid #666 1px;position:absolute;top:0;}\nlabel.DescartesSpinnerLabel,label.DescartesMenuLabel,label.DescartesScrollbarLabel,label.DescartesTextFieldLabel{font-family:"+a.sansserif_font+";font-weight:normal;text-align:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;background-color:#e0e4e8;position:absolute;left:0;top:0;}\ndiv.DescartesGraphicControl{touch-action:none;border-style:none;position:absolute;}\ndiv.DescartesTextAreaContainer{position:absolute;overflow:hidden;background:#c0d0d8;}\nselect.DescartesMenuSelect{font-family:"+
a.sansserif_font+";padding-top:0;text-align:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;position:absolute;border:1px solid #7a8a99; background:#fff url('"+a.getSvgMenu()+"') 100%/22px no-repeat;padding:0 22px 0 5px;-webkit-appearance:none;-moz-appearance:none;appearance:none;}\nselect.DescartesMenuSelect::-ms-expand{display:none;}\ndiv.DescartesScrollbarContainer{touch-action:none;background:#eee;overflow:hidden;position:absolute;}\ntr,td{margin:0;padding:0;}\ntable{border-collapse:collapse;border-spacing:0;}\n.TextBlock{display:block;margin:0;padding:0;}\n.TextLine{display:block;white-space:nowrap;margin-bottom:3px;min-height:15px;}\n.TextNode,.DynamicTextNode{display:inline;white-space:pre;line-height:initial !important;}\n.FormulaNode{display:inline-block;padding:2px 4px;margin:0px 1px;}\n.FractionNode{display:inline-table;margin:0 6px;text-align:center;}\n.NumeratorNode{display:inline-block;margin:0;padding:0.025em 5px;width:100%;border-bottom:1px solid black;}\n.DenominatorNode{display:inline-block;margin:0;padding:0.025em 5px;text-align:center;}\n.SuperIndexNode{display:inline-block;}\n.SubIndexNode{display:inline-block;}\n.RadicalNode{display:inline-block;}\n.RadicalSign{display:inline;padding:0;margin-left:-5px;}\n.IndexNode{display:inline-block;padding:0 2px;}\n.RadicandNode{display:inline-block;border-top:1px solid black;padding:0 3px;}\n.SumNode{display:inline-block;}\n.SumContainer{display:inline-table;text-align:center;margin:0 2px;}\n.SigmaSign{display:inline-block;margin:0;width:100%;font-size:130% !important;}\n.SumFromNode{display:inline-block;margin:0;width:100%;}\n.SumToNode{display:inline-block;margin:0;width:100%;}\n.SumWhatNode{display:inline-block;margin:0;margin-right:15px;}\n.IntegralNode{display:inline-block;}\n.IntegralContainer{display:inline-table;text-align:left;margin:0 2px;}\n.IntegralSign{display:inline-block;margin:0;font-size:150% !important;width:auto;}\n.IntegralFromNode{display:inline-block;margin:0;width:100%;}\n.IntegralToNode{display:inline-block;margin:0;width:100%;}\n.IntegralWhatNode{display:inline-block;margin:0;margin-right:15px;}\n.LimitNode{display:inline-block;}\n.LimitContainer{display:inline-flex;flex-direction:column;}\n.LimitSign{display:inline-block;margin:0;width:auto;  }\n.LimitFromToNode{display:inline-block;}\n.LimitFromNode{display:inline-block;}\n.LimitArrow{display:inline-block;margin:0;width:auto;  padding:0 4px;}\n.LimitToNode{display:inline-block;}\n.LimitWhatNode{display:inline-block;margin:0;margin-right:15px;}\n.MatrixNode{display:inline-block;border-left:2px solid black;border-right:2px solid black;vertical-align:middle;margin:0 5px;padding:0;}\n.MatrixElementNode{display:inline-block;margin:0 14px;}\n.CasesNode{display:inline-block;vertical-align:middle;margin:0 5px;padding:0;padding-right:10px;}\n.CasesElementNode{display:inline-block;}\n.CurlyBracket{font-family:DescartesJS_symbola;width:auto;display:inline-flex;flex-direction:column;vertical-align:middle;}\n.CurlyBracket span{display:inline;font-weight:normal;font-style:normal;overflow:hidden;}\n";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.sin,e=Math.floor,d=Math.random,l=Math.round,c=Math.abs,g=String.fromCharCode,k,b,v,u,n,r,p,x,f,q;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){k=[];for(var b=0;256>b;b++)k[b]=g(this.alfanum(e(c(7.5*(h(1*b-a)+h(1.4*b+a)+h(.6*b-a)+h(2.2*b+a))))));return k.join("")};a.Krypto.prototype.encode=function(a){b=e(31*d());this.key=this.getKey(b);return g(this.alfanum(b))+this.encripta(a)};
a.Krypto.prototype.decode=function(a){b=this.numalfa(a.charCodeAt(0));this.key=this.getKey(b);return this.desencripta(a.substring(1))};a.Krypto.prototype.encripta=function(a){return this.bytesToString(this.encriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.encriptaAux=function(a){if(null==a||null==this.key)return null;r=Array(3*a.length);for(var b=0,c=a.length;b<c;b++)f=256*e(a[b]+128)+l(255*d())+65536*l(255*d()),q=e((f<<this.shift(b))/256),r[3*b]=this.alfanum(q%32),r[3*b+1]=this.alfanum(q/32%
32),r[3*b+2]=this.alfanum(q/1024%32);return r};a.Krypto.prototype.desencripta=function(a){return this.bytesToString(this.desencriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.desencriptaAux=function(a){if(null==a||null==this.key)return null;p=Array(a.length/3);for(var b=0,c=p.length;b<c;b++)q=this.numalfa(a[3*b])+32*this.numalfa(a[3*b+1])+1024*this.numalfa(a[3*b+2]),f=e(256*q>>this.shift(b)),x=e(f/256)%256-128,0>x&&(x+=256),p[b]=x;return p};a.Krypto.prototype.alfanum=function(a){a=e(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){u=Array(a.length);for(var b=0,f=a.length;b<f;b++)u[b]=a.charCodeAt(b);return u};a.Krypto.prototype.bytesToString=function(a){for(var b=0,f=a.length;b<f;b++)a[b]=g(a[b]);return a.join("")};a.Krypto.prototype.shift=function(a){v=this.key.charCodeAt(a%this.key.length);u=this.numalfa(v);n=e(u/2%8);0==n&&(n=4);return n};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;var h=Math.max;a.Animation=function(e,d){this.parent=e;var h=e.evaluator,c=h.parser,g=new a.Auxiliary(e),k=this;k.delay=d.delay?c.parse(d.delay):c.parse("60");k.loop=d.loop?d.loop:!1;k.auto=void 0==d.auto?!0:d.auto;k.controls=d.controls;k.init=g.splitInstructions(c,d.init);k.doExpr=g.splitInstructions(c,d.doExpr);d.whileExpr&&(k.whileExpr=c.parse(d.whileExpr));var b,v=k.doExpr.length;k.animExec=function(){for(b=
0;b<v;b++)h.eval(k.doExpr[b]);k.parent.update();k.playing&&(0<h.eval(k.whileExpr)||k.loop)?k.timer=a.setTimeout(k.animExec,h.eval(k.delay)):(k.stop(),k.pause=!1,k.parent.update())};k.playing=!1;k.auto&&k.play()};a.Animation.prototype.play=function(){this.playing?(this.pause=!0,this.stop()):(this.pause||this.reinit(),this.playing=!0,this.pause=!1,this.timer=a.setTimeout(this.animExec,h(10,this.parent.evaluator.eval(this.delay))))};a.Animation.prototype.stop=function(){this.playing=!1;a.clearTimeout(this.timer)};
a.Animation.prototype.reinit=function(){for(var a=0,d=this.init.length;a<d;a++)this.parent.evaluator.eval(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,e){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(h,e){a.Action.call(this,h,e);this.parameter=(e||"").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(h,e){a.Action.call(this,h,e);var d=this.evaluator,l=d.parser;e=(e||"").replace(/&squot;/g,"'");e=e.replace(/;/g,"\\n");e=e.split("\\n")||[""];for(var c=[],g,k=0,b=e.length;k<b;k++)(g=l.parse(e[k],!0))&&c.push(g);b=c.length;this.execute=function(){for(k=0;k<b;k++)d.eval(c[k])}};a.extend(a.Calculate,a.Action);return a}(descartesJS||{}),
descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(h,e){a.Action.call(this,h,e);this.parameter=e;this.target="_blank";var d=this.parameter.indexOf("target");-1!=d&&(this.target=this.parameter.substring(d),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,d-1));if("javascript"==this.parameter.substring(0,10)){this.parameter=new a.SimpleText(h,this.parameter.substring(11).replace(/&squot;/g,"'"));var l=this;this.actionExec=function(){try{eval(l.parameter.toString())}catch(a){}}}else"http"!=
this.parameter.substring(0,4)&&(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(h,e){a.Action.call(this,h,e);this.parameter=e;this.target="_blank";var d=this.parameter.indexOf("target");-1!=d&&(this.target=
this.parameter.substring(d),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,d-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,"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.Config=function(h,e){a.Action.call(this,h,e)};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(h,e){a.Action.call(this,h,e)};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(h,e){a.Action.call(this,h,e)};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(h,e){a.Action.call(this,h,e)};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(h,e){a.Action.call(this,h,e)};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 h=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav)/gi;a.PlayAudio=function(e,d){a.Action.call(this,e,d);d&&d.match(h)?this.filenameExpr=this.evaluator.parser.parse("'"+
d.match(h)+"'"):(""!=d&&"["==d[0]&&"]"==d[d.length-1]&&(d=d.substring(1,d.length-1)),this.filenameExpr=this.evaluator.parser.parse(d))};a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=function(){var a=this.theAudio=this.parent.getAudio(this.evaluator.eval(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,e){this.parent=a;this.evaluator=this.parent.evaluator;this.expresion=
this.id="";this.evaluate="onlyOnce";this.local="";for(var c in e)e.hasOwnProperty(c)&&(this[c]=e[c])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var h,e;a.Auxiliary.prototype.splitInstructions=function(a,l){e=[];if(l){for(var c=l,g=!1,k,b=[],v=0,u=0,n=c.length;u<n;u++)k=c.charAt(u),"'"===k&&(g=!g),g||";"!==k||(b.push(c.substring(v,u)),v=u+1);b.push(c.substring(v));l=b}else l=[""];c=0;for(g=l.length;c<g;c++)(h=a.parse(l[c],!0))&&e.push(h);return e};a.Auxiliary.prototype.getPrivateVariables=
function(a,l){e=[];l=l?l.split(/;|,/):[""];for(var c=0,g=l.length;c<g;c++)(h=a.parse(l[c],!0))&&e.push(h);c=0;for(g=e.length;c<g;c++)e[c]="asign"===e[c].type?e[c].childs[0].value:"identifier"===e[c].type?e[c].value:"";return e};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(h,e){a.Auxiliary.call(this,h,e);var d=this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=d.parse(this.expresionString))&&d.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"),e=document.createElement("label");e.appendChild(document.createTextNode("___"+
this.id+"=___"));var d=document.createElement("input");d.value=this.expresionString;d.disabled=!this.editable;a.appendChild(e);a.appendChild(d);var l=this,c=l.evaluator.parser;d.onkeydown=function(a){13==a.keyCode&&(l.expresion=c.parse(this.value),c.setVariable(l.id,l.expresion),l.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(h,e){a.Auxiliary.call(this,h,e);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.eval(this.expresion))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d;a.Vector=function(d,c){h=d.evaluator;e=h.parser;this.size=e.parse("3");a.Auxiliary.call(this,d,c);this.expresion=this.expresion.split(";");this.parseFile=e.parse(this.file);this.update()};a.extend(a.Vector,a.Auxiliary);
a.Vector.prototype.update=function(){var l=this.expresion;h=this.evaluator;e=h.parser;this.oldFile=this.file;if(d=h.eval(this.parseFile))this.file=d;var c;if(this.file){c=(vectorElement=document.getElementById(this.file))&&"descartes/vectorFile"==vectorElement.type?vectorElement.text:a.openExternalFile(this.file);if(null!=c){c=c.replace(/\r/g,"").split("\n");for(var g=[],k=0,b=c.length;k<b;k++)""!=c[k]&&g.push(c[k]);c=g}null==c||1==c.length&&""==c[0]?this.size=e.parse("0"):(l=c,this.size=null);null===
this.size&&(this.size=e.parse(l.length+""))}c=[];k=0;for(b=l.length;k<b;k++)(g=e.parse(l[k],!0))&&"asign"!=g.type&&(g=e.parse(this.id+"["+k+"]="+l[k],!0)),c.push(g);l=[];l._size_=h.eval(this.size);k=0;for(b=this._size_;k<b;k++)l.push(0);h.vectors[this.id]=l;h.setVariable(this.id+".long",l._size_);k=0;for(b=c.length;k<b;k++)h.eval(c[k])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(h,e){var d=h.evaluator,l=d.parser;this.rows=l.parse("3");this.columns=l.parse("3");
a.Auxiliary.call(this,h,e);this.expresion=this.splitInstructions(l,this.expresion);var l=d.eval(this.rows),c=d.eval(this.columns),g=[];g.type="matrix";for(var k,b=0;b<c;b++){k=[];for(var v=0,u=l;v<u;v++)k.push(0);g[b]=k}d.matrices[this.id]=g;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,e=a.eval(this.rows),d=a.eval(this.columns);a.setVariable(this.id+".filas",e);a.setVariable(this.id+".columnas",d);var l=a.matrices[this.id];l.rows=e;l.cols=
d;e=0;for(d=this.expresion.length;e<d;e++)a.eval(this.expresion[e])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(h,e){a.Auxiliary.call(this,h,e);var d=this.evaluator,l=d.parser,c=this.id.indexOf("(");this.name=this.id.substring(0,c);this.params=this.id.substring(c+1,this.id.indexOf(")"));this.domain=this.range?l.parse(this.range):l.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||
(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(l);this.expresion=l.parse(this.expresion);var g=this;this.functionExec=function(){this.iterations=0;if(g.numberOfParams<=arguments.length){for(var c=[],b=0,e=g.privateVars.length;b<e;b++)c.push(d.getVariable(g.privateVars[b])),d.setVariable(g.privateVars[b],0);for(var h=[],b=0,e=g.params.length;b<e;b++)h[b]=d.getVariable(g.params[b])||0,d.setVariable(g.params[b],arguments[b]);b=0;for(e=g.init.length;b<e;b++)d.eval(g.init[b]);do{b=0;for(e=
g.doExpr.length;b<e;b++)d.eval(g.doExpr[b]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en la funci\u00f3n << "+g.name+" >>"),0}while(0<d.eval(g.whileExpr));var n=d.eval(g.expresion);a.rangeOK=d.eval(g.domain);b=0;for(e=g.params.length;b<e;b++)d.setVariable(g.params[b],h[b]);b=0;for(e=g.privateVars.length;b<e;b++)d.setVariable(g.privateVars[b],c[b]);return n}return 0};d.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(h,e){a.Auxiliary.call(this,h,e);var d=this.evaluator;this.parseExpressions(d.parser);this.algorithmExec=function(){for(var a=this.iterations=0,c=this.init.length;a<c;a++)d.eval(this.init[a]);do{a=0;for(c=this.doExpr.length;a<c;a++)d.eval(this.doExpr[a]);if(1E5<++this.iterations)return console.log("se ha excedido el l\u00edmite de 100000 repeticiones en el algoritmo << "+self.name+" >>"),0}while(0<d.eval(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(h,e){a.Auxiliary.call(this,h,e);var d=this.evaluator;delete this.evaluate;this.condition=d.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){0<this.evaluator.eval(this.condition)&&
!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<this.evaluator.eval(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<this.evaluator.eval(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 h,e,d,l,c,g;a.Graphic=function(c,b){this.parent=c;this.evaluator=c.evaluator;var e=this.evaluator.parser;this.spaceID="";this.background=!1;this.type="";this.drawif=e.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=e.parse("(0,0)");this.family="";this.family_interval=e.parse("[0,1]");this.family_steps=e.parse("8");this.editable=this.visible=!1;this.font="Monospaced,PLAIN,"+(5<=this.parent.version?"15":"12");this.fixed=!0;this.text="";this.decimals=e.parse("2");for(var d in b)b.hasOwnProperty(d)&&(this[d]=b[d]);this.space=this.getSpace();this.canvas=this.background?this.space.backCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backCtx);
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,e=a.length;c<e;c++)if(b=a[c],b.id==this.spaceID)return b;return a[0]};a.Graphic.prototype.getFamilyValues=function(){h=this.evaluator;e=h.eval(this.family_interval);this.familyInf=e[0][0];this.familySup=e[0][1];this.fSteps=Math.round(h.eval(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-
this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,b,c){h=this.evaluator;this.getFamilyValues();d=h.getVariable(this.family);if(0<=this.fSteps)for(var e=0,g=this.fSteps;e<=g;e++)h.setVariable(this.family,this.familyInf+e*this.family_sep),0<h.eval(this.drawif)&&(this.update(),this.drawAux(a,b,c));h.setVariable("_Text_H_",0);h.setVariable(this.family,d)};a.Graphic.prototype.draw=function(a,b){""!=this.family?this.drawFamilyAux(this.ctx,a,b):0<this.evaluator.eval(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.eval(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,a,b))};a.Graphic.prototype.dashStyle=function(){g=this.ctx;"dot"===this.lineDash?(g.lineCap="butt",g.setLineDash([g.lineWidth,g.lineWidth])):"dash"===this.lineDash?(g.lineCap="butt",g.setLineDash([4*g.lineWidth,3*g.lineWidth])):"dash_dot"===this.lineDash?(g.lineCap="butt",g.setLineDash([4*
g.lineWidth,2*g.lineWidth,g.lineWidth,2*g.lineWidth])):g.setLineDash([])};a.Graphic.prototype.drawText=function(a,b,e,d,g,r,p,x,f,q,m){a.textNode=b;if("rtfNode"===b.type)a.fillStyle=g.getColor(),a.strokeStyle=g.getColor(),a.textBaseline="alphabetic",a.textNode.pos={x:e,y:d},b.draw(a,e,d+1,f,q,p,m,g.getColor());else for("simpleText"===b.type&&(b=b.toString(f,q).split("\\n")),e+=/Arial|Times/i.test(r)?-2:0,h=this.evaluator,a.fillStyle=g.getColor(),a.font=r,a.textAlign=p,a.textBaseline=x,this.border&&
(a.strokeStyle=this.border.getColor(),a.lineWidth=4),c=1.2*this.fontSize||0,g=0,r=b.length;g<r;g++)l=b[g],this.border&&(a.lineJoin="round",a.miterLimit=2,a.strokeText(l,e,d+c*g)),a.fillText(l,e,d+c*g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=function(a,e){this.text=e=e.replace("&#x2013","\u2013").replace(/\&squot;/g,"'");this.textElements=[];this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var c="'",g=0,k=
0,b=-1,h,u;g<e.length;)h=e.charAt(g),u=e.charAt(g-1),"["===h&&"\\"===u?(this.textElements.push(e.substring(k,g-1)+"["),this.textElementsMacros.push("'"+e.substring(k,g-1)+"['"),k=g+1):"]"===h&&"\\"===u?(this.textElements.push(e.substring(k,g-1)+"]"),this.textElementsMacros.push("'"+e.substring(k,g-1)+"]'"),k=g+1):"["===h&&-1===b?(this.textElements.push(e.substring(k,g)),this.textElementsMacros.push("'"+e.substring(k,g)+"'"),k=g,b++):"["===h?b++:"]"===h&&0===b?(this.textElements.push(this.evaluator.parser.parse(e.substring(k,
g+1))),this.textElementsMacros.push("["+e.substring(k,g+1)+"]"),k=g+1,b--):("]"==e.charAt(g)&&(b=0>b?b:b-1),c+=e.charAt(g)),g++;this.textElements.push(e.substring(k,g));this.textElementsMacros.push("'"+e.substring(k,g)+"'")};var h,e;a.SimpleText.prototype.toString=function(d,l){h="";for(var c=0,g=this.textElements.length;c<g;c++)"string"===typeof this.textElements[c]?h+=this.textElements[c]:(e=this.evaluator.eval(this.textElements[c])[0][0],""!==e&&("string"===typeof e?h+=e:(e=parseFloat(e),e=l?e.toFixed(d):
a.removeNeedlessDecimals(e.toFixed(d)),h+=e.toString().replace(".",this.parent.decimal_symbol))));return h};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d,l,c,g,k,b,v,u,n,r,p,x,f,q,m,w,y,B,E,F,D,G,H,K,C;a._debug_vez=0;a.Equation=function(b,e){this.width=b.evaluator.parser.parse("1");this.fillM=this.fillP="";a.Graphic.call(this,b,e);this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();r=new a.R2;
p=new a.R2;x=new a.R2;m=new a.R2;f=new a.R2;this.cInd=0};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"===this.expresion.type){var b=this.expresion.childs[0],f=this.expresion.childs[1];"identifier"!=b.type||"y"!=b.value||f.contains("y")?"identifier"!=f.type||"y"!=f.value||b.contains("y")?"identifier"!=b.type||"x"!=b.value||f.contains("x")?"identifier"!=f.type||"x"!=f.value||b.contains("x")||(this.funExpr=f,this.of_y=!0,this.drawAux=this.drawAuxFun):
(this.funExpr=f,this.of_y=!0,this.drawAux=this.drawAuxFun):(this.funExpr=b,this.of_y=!1,this.drawAux=this.drawAuxFun):(this.funExpr=f,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,f){e=this.evaluator;
this.getFamilyValues();tempParam=e.getVariable(this.family);if(0<=this.fSteps)for(var c=0,d=this.fSteps;c<=d;c++)e.setVariable(this.family,this.familyInf+c*this.family_sep),this.update(),this.drawAux(a,b,f);e.setVariable(this.family,tempParam)};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};var A,I,J,M,z,O,L;a.Equation.prototype.drawAux=function(N,R,P){if(!(0>=this.evaluator.eval(this.drawif))){e=this.evaluator;d=e.parser;l=this.space;c=e.eval(this.width);
N.strokeStyle=this.color.getColor();N.lineWidth=c;g=d.getVariable("x");k=d.getVariable("y");b=l.w+24;v=l.h+24;u=b/9;3>u&&(u=3);n=v/7;3>n&&(n=3);0==this.cInd?(h=[],this.cInd++):this.cInd=(this.cInd+1)%1E5;r.set(0,0);p.set(0,0);x.set(0,0);O=.25;L=8;this.abs_coord||(O/=l.scale,L/=l.scale);N.beginPath();for(C=parseInt(n/2);C<v;C+=n)for(K=parseInt(u/2);K<b;K+=u){if(this.abs_coord){m.set(K,C);q=this.newt.findZero(m,O);if(null==q)continue;e.setVariable("x",q.x);e.setVariable("y",q.y);f.set(q.x,q.y)}else{m.set(l.getRelativeX(K),
l.getRelativeY(C));q=this.newt.findZero(m,O);if(null==q)continue;e.setVariable("x",q.x);e.setVariable("y",q.y);f.set(l.getAbsoluteX(q.x),l.getAbsoluteY(q.y))}w=f.ix();y=f.iy();if(-12<=w&&w<b+24&&-12<=y&&y<v+24){if(h[w+12+(y+12)*l.w]===this.cInd)continue;h[w+12+(y+12)*l.w]=this.cInd}a.rangeOK&&(N.moveTo(w,y),N.lineTo(w,y));r.x=q.x;r.y=q.y;p.x=q.x;p.y=q.y;B=this.newt.getUnitNormal();if(0!=B.x||0!=B.y)for(B.rotL90(),x.x=B.x,x.y=B.y,F=E=0,D=!1;2>F;)if(D&&(x.x=-B.x,x.y=-B.y,q.x=r.x,q.y=r.y,p.x=q.x,p.y=
q.y,this.abs_coord?f.set(q.x,q.y):f.set(l.getAbsoluteX(q.x),l.getAbsoluteY(q.y)),w=f.ix(),y=f.iy(),D=!1,E=0),q.x+=L*x.x,q.y+=L*x.y,q=this.newt.findZero(q,O),null!=q){e.setVariable("x",q.x);e.setVariable("y",q.y);x.x=q.x-p.x;x.y=q.y-p.y;x.normalize();if(0==x.x&&0==x.y)break;p.x=q.x;p.y=q.y;this.abs_coord?f.set(q.x,q.y):f.set(l.getAbsoluteX(q.x),l.getAbsoluteY(q.y));G=parseInt(f.ix());H=parseInt(f.iy());if(G!=w||H!=y)if(A=w,I=y,w=G,y=H,-12<=w&&w<b+24&&-12<=y&&y<v+24){E=0;J=h[w+12+(y+12)*l.w];h[w+12+
(y+12)*l.w]=this.cInd;for(R=1;8>R;R++)M=A+Math.round((w-A)*R/8),z=I+Math.round((y-I)*R/8),0<=M&&M<b&&0<=z&&z<v&&(h[M+12+(z+12)*l.w]=this.cInd);a.rangeOK&&(N.moveTo(A,I),N.lineTo(w,y));if(J===this.cInd)break}else D=!0,F++;else 4<++E&&(D=!0,F++)}}N.stroke()}};a.Equation.prototype.X=function(a,b,f){f||(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,f){f||(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,f){return Math.round(this.X(a,b,f))};a.Equation.prototype.YY=function(a,b,f){return Math.round(this.Y(a,b,f))};a.Equation.prototype.extrapolate=function(b,f,e,c,d,r){for(var g=this.evaluator.getVariable(f),k=r/2,p=0,m,h,n,q,l,u;1E-15<Math.abs(k);){m=this.evaluator.getVariable(f);h=this.evaluator.getVariable(f)+k;this.evaluator.setVariable(f,h);n=!0;try{q=d,d=this.evaluator.eval(this.funExpr),this.evaluator.setVariable(e,
d),0<this.evaluator.eval(b)?(l=new a.R2(Math.min(q,d),Math.max(q,d)),u=0,u=0<r?this.Singularity(Math.abs(k),f,c,m,q,h,d,l):this.Singularity(Math.abs(k),f,c,h,d,m,q,l),0<u&&(n=!1)):n=!1}catch(x){n=!1}n?p+=k:this.evaluator.setVariable(f,m);k/=2}this.evaluator.setVariable(f,g);return new a.R2(p/Math.abs(r),d)};a.Equation.prototype.extrapolateOnSingularity=function(b,f,c,e,d,r){e=this.evaluator.getVariable(f);for(var g=r/2,k=0,p=d,m;1E-15<Math.abs(g);){this.evaluator.setVariable(f,this.evaluator.getVariable(f)+
g);m=!0;if(0<this.evaluator.eval(b))try{p=this.evaluator.eval(this.funExpr),this.evaluator.setVariable(c,p),0>=this.evaluator.eval(b)&&(m=!1)}catch(h){m=!1}else m=!1;m?k+=g:this.evaluator.setVariable(f,this.evaluator.getVariable(f)-g);g/=2}if(0==k)for(g=r/2,k=r,p=d;1E-15<Math.abs(g);){this.evaluator.setVariable(f,this.evaluator.getVariable(f)-g);m=!0;if(0<this.evaluator.eval(b))try{p=this.evaluator.eval(this.funExpr)}catch(h){m=!1}else m=!1;m?k+=-g:this.evaluator.setVariable(f,this.evaluator.getVariable(f)+
g);g/=2}this.evaluator.setVariable(f,e);return new a.R2(k/Math.abs(r),p)};a.Equation.prototype.Singularity=function(a,b,f,e,c,d,r,g){if(isNaN(r)||isNaN(c)||isNaN(g.y)||isNaN(g.x)||e>=d)return 2;var k=this.evaluator.getVariable(b),p=0;try{if(1E-15>Math.abs(d-e)||1E-12>Math.abs(d-e)&&Math.abs(r-c)>Math.abs(a))return this.evaluator.setVariable(b,k),1;var m=(e+d)/2;this.evaluator.setVariable(b,m);var h=NaN;try{h=this.evaluator.eval(this.funExpr)}catch(n){return 2}if(isNaN(h))return 2;if(Math.abs(r-c)>
a){this.evaluator.setVariable(b,e-1E-12);var q=this.evaluator.eval(this.funExpr),q=(c-q)/1E-12;this.evaluator.setVariable(b,d+1E-12);var l=(this.evaluator.eval(this.funExpr)-r)/1E-12;if((10>Math.abs(l)||10>Math.abs(q))&&(0<=l&&0<=q||0>=l&&0>=q)&&4*Math.abs(l)<Math.abs((r-c)/(d-e)))return this.evaluator.setVariable(b,k),2}if(isNaN(g.x)||isNaN(g.y)||isNaN(h))return 2;if(!(g.x<=h&&h<=g.y)){this.evaluator.setVariable(b,m);g.x=Math.min(c,h);g.y=Math.max(c,h);var u=this.Singularity(a/2,b,f,e,c,m,h,g);this.evaluator.setVariable(b,
d);g.x=Math.min(r,h);g.y=Math.max(r,h);var x=this.Singularity(a/2,b,f,m,h,d,r,g),p=Math.max(u,x)}}catch(n){p=1}this.evaluator.setVariable(b,k);return p};a.Equation.prototype.drawAuxFun=function(b,f,c){g=this.evaluator.parser.getVariable("x");k=this.evaluator.parser.getVariable("y");a.rangeOK=1;f="x";c="y";this.of_y&&(f="y",c="x");var e=this.drawif,d=this.evaluator.eval(this.width),r=!1,p=new a.R2(this.space.w/2+this.space.Ox,this.space.h/2+this.space.Oy),p=this.of_y?p.ix():p.iy(),m=0,h=0,n=0,q=0,
l=1/this.space.scale,u=l*(this.of_y?Math.ceil(-this.space.h+(this.space.h/2+this.space.Oy)):-Math.ceil(this.space.w/2+this.space.Ox)),x=0;this.abs_coord&&(u=0,l=1);for(var v,z,w,y,A,E,L,B,F,C=this.of_y?this.space.h+4:this.space.w+4;n<=C;){v=!0;z=0;this.evaluator.setVariable(f,u);try{w=this.evaluator.eval(this.funExpr),isNaN(w)||(this.evaluator.setVariable(c,w),0<this.evaluator.eval(this.drawif)&&a.rangeOK?(r?(y=Math.min(x,w),A=Math.max(x,w),E=new a.R2(y,A),z=this.Singularity(l,f,0,u-l,x,u,w,E),0===
z?(x<=w?(x=E.x,w=E.y):(w=E.x,x=E.y),L=parseInt(this.of_y?this.XX(d,x,this.abs_coord):this.YY(d,x,this.abs_coord)),m=this.abs_coord?Math.round(w):parseInt(this.of_y?this.XX(d,w,this.abs_coord):this.YY(d,w,this.abs_coord)),this.fillM&&m>p&&(b.lineWidth=1,b.strokeStyle=this.fillM.getColor(),b.beginPath(),this.of_y?(b.moveTo(p+1,this.space.h-n+.5),b.lineTo(m,this.space.h-n+.5)):(b.moveTo(n+.5,p+1),b.lineTo(n+.5,m)),b.stroke()),this.fillP&&m<p&&(b.lineWidth=1,b.strokeStyle=this.fillP.getColor(),b.beginPath(),
this.of_y?(b.moveTo(p-1,this.space.h-n+.5),b.lineTo(m,this.space.h-n+.5)):(b.moveTo(n+.5,p-1),b.lineTo(n+.5,m)),b.stroke()),b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(L+.5,this.space.h-q),b.lineTo(m+.5,this.space.h-n)):(b.moveTo(q+.5,L),b.lineTo(n+.5,m))):1===z?(this.evaluator.setVariable(f,u-l),B=this.extrapolate(e,f,c,0,x,l),m=parseInt(this.of_y?this.XX(d,B.y,this.abs_coord):this.YY(d,B.y,this.abs_coord)),b.lineWidth=d,b.strokeStyle=this.color.getColor(),
b.beginPath(),this.of_y?(b.moveTo(h+.5,this.space.h-q),b.lineTo(m+.5,this.space.h-q+Math.round(B.x))):(b.moveTo(q+.5,h),b.lineTo(q+Math.round(B.x)+.5,m)),this.evaluator.setVariable(f,u),F=this.extrapolate(e,f,c,0,w,-l),h=this.YY(d,F.y,this.abs_coord),m=this.YY(d,w,this.abs_coord),b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(h+.5,this.space.h-n),b.lineTo(m+.5,this.space.h-n)):(b.moveTo(n+.5,h),b.lineTo(n+.5,m))):(m=parseInt(this.of_y?this.XX(d,w,this.abs_coord):
this.YY(d,w,this.abs_coord)),b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(m+.5,this.space.h-n),b.lineTo(m+.5,this.space.h-n)):(b.moveTo(n+.5,m),b.lineTo(n+.5,m)))):(F=this.extrapolateOnSingularity(e,f,c,0,w,-l),h=this.of_y?this.XX(d,F.y,this.abs_coord):this.YY(d,F.y,this.abs_coord),m=parseInt(this.of_y?this.XX(d,w,this.abs_coord):this.YY(d,w,this.abs_coord)),b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(h,this.space.h-(n+
Math.round(F.x))+.5),b.lineTo(m,this.space.h-n+.5)):(b.moveTo(n+Math.round(F.x),h),b.lineTo(n,m))),b.stroke(),x=w):v=!1)}catch(D){v=!1}r&&!v&&(this.evaluator.setVariable(f,u-l),this.evaluator.setVariable(c,x),B=this.extrapolate(e,f,c,0,x,l),m=parseInt(this.of_y?this.XX(d,B.y,this.abs_coord):this.YY(d,B.y,this.abs_coord)),0<this.evaluator.eval(this.drawif)&&a.rangeOK&&(b.lineWidth=d,b.strokeStyle=this.color.getColor(),b.beginPath(),this.of_y?(b.moveTo(h,this.space.h-(q+Math.round(B.x))+.5),b.lineTo(m,
this.space.h-(q+Math.round(B.x))+.5)):(b.moveTo(q+Math.round(B.x)+.5,h),b.lineTo(q+Math.round(B.x)+.5,m)),b.stroke()),this.evaluator.setVariable(f,u));r=v;u+=l;h=m;q=n++}this.evaluator.parser.setVariable("x",g);this.evaluator.parser.setVariable("y",k)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;oncontextmenu=function(a){return!1};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 h=Math.round,e,d,l,c,g,k,b,v,u,n,r;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:this.visible)&&
this.registerTextField()};a.extend(a.Curve,a.Graphic);a.Curve.prototype.update=function(){e=this.evaluator;d=e.eval(this.parameter_interval);this.paraInf=d[0][0];this.paraSup=d[0][1];this.pSteps=e.eval(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(d,x,f){e=this.evaluator;l=this.space;c=h(e.eval(this.width));d.lineWidth=0<c?c:1E-6;d.lineCap="round";d.lineJoin="round";d.strokeStyle=f.getColor();g=e.getVariable(this.parameter);d.beginPath();e.setVariable(this.parameter,this.paraInf);k=e.eval(this.expresion);this.exprX=h(this.abs_coord?k[0][0]:l.getAbsoluteX(k[0][0]));this.exprY=h(this.abs_coord?k[0][1]:l.getAbsoluteY(k[0][1]));this.rotateExp&&(b=a.degToRad(e.eval(this.rotateExp)),v=Math.cos(b),u=Math.sin(b),n=this.exprX*v-this.exprY*
u,r=this.exprX*u+this.exprY*v,this.exprX=n,this.exprY=r);d.moveTo(this.exprX+.5,this.exprY+.5);for(f=1;f<=this.pSteps;f++)e.setVariable(this.parameter,this.paraInf+f*this.paraSep),k=e.eval(this.expresion),this.exprX=this.abs_coord?h(k[0][0]):h(l.getAbsoluteX(k[0][0])),this.exprY=this.abs_coord?h(k[0][1]):h(l.getAbsoluteY(k[0][1])),this.rotateExp&&(n=this.exprX*v-this.exprY*u,r=this.exprX*u+this.exprY*v,this.exprX=n,this.exprY=r),!isNaN(this.exprX)&&!isNaN(this.exprY)&&-1E6<this.exprX&&1E6>this.exprX&&
-1E6<this.exprY&&1E6>this.exprY&&d.lineTo(this.exprX+.5,this.exprY+.5);this.fill&&(d.fillStyle=x.getColor(),d.fill("evenodd"));this.dashStyle();d.stroke();e.setVariable(this.parameter,g)};a.Curve.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var b=this;a.oncontextmenu=function(a){return!1};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 h=2*Math.PI,e=Math.round,d,l,c,g,k,b,v,u,n,r,p,x,f,q;a.Sequence=function(b,f){this.size=b.evaluator.parser.parse("2");this.range=b.evaluator.parser.parse("[1, 100]");a.Graphic.call(this,b,f)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){d=this.evaluator;c=d.eval(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(g=a.degToRad(d.eval(this.rotateExp)),k=Math.cos(g),b=Math.sin(g),
v=this.exprX*k-this.exprY*b,u=this.exprX*b+this.exprY*k,this.exprX=v,this.exprY=u);p=d.eval(this.range);this.rangeInf=p[0][0];this.rangeMax=p[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,b){d=this.evaluator;l=this.space;f=x=Math.ceil(d.eval(this.size)-.4);a.fillStyle=b.getColor();a.beginPath();this.rangeInf>this.rangeMax&&
(q=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=q);for(var g=d.getVariable("n"),k=this.rangeInf,p=this.rangeMax;k<=p;k++)d.setVariable("n",k),c=d.eval(this.expresion),this.exprX=c[0][0],this.exprY=c[0][1],n=e(this.abs_coord?this.exprX:l.getAbsoluteX(this.exprX)),r=e(this.abs_coord?this.exprY:l.getAbsoluteY(this.exprY)),a.beginPath(),a.arc(n,r,x,0,h,!0),a.fill();a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,n+f,r-f,this.color,this.font,"start","alphabetic",d.eval(this.decimals),
this.fixed,!0);d.setVariable("n",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=2*Math.PI,e=Math.round,d,l,c,g,k,b,v,u,n,r,p,x;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(){d=this.evaluator;c=d.eval(this.expresion);this.exprX=c[0][0];this.exprY=c[0][1];this.rotateExp&&(g=a.degToRad(d.eval(this.rotateExp)),k=Math.cos(g),b=Math.sin(g),v=this.exprX*k-this.exprY*
b,u=this.exprX*b+this.exprY*k,this.exprX=v,this.exprY=u)};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){d=this.evaluator;l=this.space;p=e(d.eval(this.size));x=p+1;a.fillStyle=b.getColor();n=e(this.abs_coord?this.exprX:l.getAbsoluteX(this.exprX));r=e(this.abs_coord?this.exprY:l.getAbsoluteY(this.exprY));a.beginPath();a.arc(n,r,p,0,
h,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,n+x+1,r-x,this.color,this.font,"start","alphabetic",d.eval(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.round,e=2*Math.PI,d,l,c,g,k,b,v,u,n,r,p,x,f,q,m,w,y,B;a.Segment=function(b,f){this.width=b.evaluator.parser.parse("1");this.size=b.evaluator.parser.parse("2");a.Graphic.call(this,b,f)};a.extend(a.Segment,a.Graphic);a.Segment.prototype.update=function(){d=
this.evaluator;c=d.eval(this.expresion);this.endPoints=[];for(var f=0,e=c.length;f<e;f++)this.endPoints[f]={x:c[f][0],y:c[f][1]};if(this.rotateExp)for(g=a.degToRad(d.eval(this.rotateExp)),k=Math.cos(g),b=Math.sin(g),f=0,e=this.endPoints.length;f<e;f++)v=this.endPoints[f].x*k-this.endPoints[f].y*b,u=this.endPoints[f].x*b+this.endPoints[f].y*k,this.endPoints[f].x=v,this.endPoints[f].y=u};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,c){d=this.evaluator;l=this.space;n=h(d.eval(this.width));a.lineWidth=0<n?n:1E-6;f=d.eval(this.size);0>f&&(f=0);a.fillStyle=b.getColor();a.strokeStyle=c.getColor();a.lineCap="round";r=10+a.lineWidth;q=0==a.lineWidth%2?0:.5;this.abs_coord?(m=h(this.endPoints[0].x),w=h(this.endPoints[0].y),y=h(this.endPoints[1].x),B=h(this.endPoints[1].y)):(m=h(l.getAbsoluteX(this.endPoints[0].x)),w=h(l.getAbsoluteY(this.endPoints[0].y)),
y=h(l.getAbsoluteX(this.endPoints[1].x)),B=h(l.getAbsoluteY(this.endPoints[1].y)));a.beginPath();a.moveTo(m+q,w+q);a.lineTo(y+q,B+q);this.dashStyle();a.stroke();0<f&&(a.beginPath(),a.arc(m,w,f,0,e,!0),a.arc(y,B,f,0,e,!0),a.fill());this.text!=[""]&&(p=parseInt((m+y)/2)-3,x=parseInt((w+B)/2)+3,this.uber.drawText.call(this,a,this.text,p+r,x-r,this.color,this.font,"start","alphabetic",d.eval(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=
Math.floor,e=Math.round,d,l,c,g,k,b,v,u,n,r,p,x,f,q,m,w,y,B;a.Arrow=function(b,f){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,f)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){d=this.evaluator;l=d.eval(this.expresion);this.endPoints=[];for(var f=0,e=l.length;f<e;f++)this.endPoints[f]={x:l[f][0],y:l[f][1]};if(this.rotateExp)for(c=a.degToRad(d.eval(this.rotateExp)),
g=Math.cos(c),k=Math.sin(c),f=0,e=this.endPoints.length;f<e;f++)b=this.endPoints[f].x*g-this.endPoints[f].y*k,v=this.endPoints[f].x*k+this.endPoints[f].y*g,this.endPoints[f].x=b,this.endPoints[f].y=v};a.Arrow.prototype.draw=function(){this.uber.draw.call(this,this.arrow,this.color)};a.Arrow.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.arrow,this.trace)};a.Arrow.prototype.drawAux=function(b,c,g){d=this.evaluator;u=this.space;d.eval(this.size);p=d.eval(this.width);0>p&&(p=0);x=
Math.ceil(p/2);f=u.scale;this.vect=new a.Vector2D(this.endPoints[1].x-this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);q=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);b.fillStyle=c.getColor();b.strokeStyle=g.getColor();b.lineWidth=2;this.abs_coord?(m=e(this.endPoints[0].x),w=e(this.endPoints[0].y),y=e(this.endPoints[1].x),B=e(this.endPoints[1].y)):(m=e(u.getAbsoluteX(this.endPoints[0].x)),w=e(u.getAbsoluteY(this.endPoints[0].y)),y=e(u.getAbsoluteX(this.endPoints[1].x)),
B=e(u.getAbsoluteY(this.endPoints[1].y)));c=d.eval(this.spear);0>c&&(c=0);b.save();b.translate(m,w,q);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):(q*=f,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(-x,h(-x));b.lineTo(h(q-c-p),h(-x));b.lineTo(h(q-2*c),h(-c-x));b.lineTo(h(q),0);b.lineTo(h(q-2*c),h(c+x));b.lineTo(h(q-c-p),h(x));b.lineTo(-x,h(x));
b.closePath();b.stroke();b.fill();b.restore();this.text!=[""]&&(n=parseInt((m+y)/2)-3,r=parseInt((w+B)/2)+3,this.uber.drawText.call(this,b,this.text,n,r,g,this.font,"start","alphabetic",d.eval(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.round,e,d,l,c,g,k,b,v,u,n,r,p;a.Polygon=function(b,f){this.width=b.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,b,f);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=
function(){e=this.evaluator;l=e.eval(this.expresion);for(var d=0,f=l.length;d<f;d++)this.endPoints[d]={x:l[d][0],y:l[d][1]};if(this.rotateExp)for(c=a.degToRad(e.eval(this.rotateExp)),g=Math.cos(c),k=Math.sin(c),d=0,f=this.endPoints.length;d<f;d++)b=this.endPoints[d].x*g-this.endPoints[d].y*k,v=this.endPoints[d].x*k+this.endPoints[d].y*g,this.endPoints[d].x=b,this.endPoints[d].y=v};a.Polygon.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Polygon.prototype.drawTrace=function(){this.uber.drawTrace.call(this,
this.trace,this.trace)};a.Polygon.prototype.drawAux=function(a,b,c){e=this.evaluator;d=this.space;u=h(e.eval(this.width));a.lineWidth=0<u?u:1E-6;a.strokeStyle=c.getColor();a.lineCap="round";a.lineJoin="round";n=0<u?.5:0;r=h(this.abs_coord?this.endPoints[0].x:d.getAbsoluteX(this.endPoints[0].x));p=h(this.abs_coord?this.endPoints[0].y:d.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(r+n,p+n);c=1;for(var g=this.endPoints.length;c<g;c++)r=h(this.abs_coord?this.endPoints[c].x:d.getAbsoluteX(this.endPoints[c].x)),
p=h(this.abs_coord?this.endPoints[c].y:d.getAbsoluteY(this.endPoints[c].y)),a.lineTo(r+n,p+n);this.fill&&(a.fillStyle=b.getColor(),a.fill());this.dashStyle();a.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.round,e=Math.min,d=Math.max,l=Math.acos,c=Math.sqrt,g=Math.PI,k=g/2,b=2*g,v,u,n,r,p,x,f,q,m,w,y,B,E,F,D,G,H,K,C,A,I;a.Arc=function(b,f){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,f);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(){v=this.evaluator;u=v.eval(this.center);this.exprX=u[0][0];this.exprY=u[0][1];n=0;this.rotateExp&&(n=a.degToRad(v.eval(this.rotateExp)),
r=Math.cos(n),p=Math.sin(n),x=this.exprX*r-this.exprY*p,f=this.exprX*p+this.exprY*r,this.exprX=x,this.exprY=f);var h=v.eval(this.initExpr),A=v.eval(this.endExpr);/^(\(|\[)expr(\)|\])$/i.test(this.initExpr.type)&&/^(\(|\[)expr(\)|\])$/i.test(this.endExpr.type)?(q=h[0][0],m=h[0][1],w=A[0][0],y=A[0][1],this.vectors?this.abs_coord&&(m=-m,y=-y):this.abs_coord?(q-=this.exprX,m=-m+this.exprY,w-=this.exprX,y=-y+this.exprY):(q-=this.exprX,m-=this.exprY,w-=this.exprX,y-=this.exprY),B=0==q?0>m?-k:k:l(1*q/c(q*
q+m*m)),E=0==w?0>y?-k:k:l(1*w/c(w*w+y*y)),B+=n,E+=n,0<q&&0<m&&this.abs_coord&&(B=b-B),0<q&&0>m&&!this.abs_coord&&(B=b-B),0>q&&0>m&&!this.abs_coord&&(B=b-B),0>q&&0<m&&this.abs_coord&&(B=b-B),0<w&&0<y&&this.abs_coord&&(E=b-E),0<w&&0>y&&!this.abs_coord&&(E=b-E),0>w&&0>y&&!this.abs_coord&&(E=b-E),0>w&&0<y&&this.abs_coord&&(E=b-E),this.initFlag?(F=B,B=E,E=F):(F=e(B,E),D=d(B,E),B=F,E=D,E-B>g&&this.abs_coord&&(B=D,E=F),E-B<=g&&!this.abs_coord&&(B=D,E=F)),this.iniAng=B,this.endAng=E,this.drawPoints=!0):(this.iniAng=
a.degToRad(h)+n,this.endAng=a.degToRad(A)+n,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,f){v=this.evaluator;G=this.space;C=v.eval(this.radius);0>C&&(C=0);I=h(v.eval(this.width));a.lineWidth=0<I?I:1E-6;a.lineCap="round";a.strokeStyle=f.getColor();this.drawAngle?(this.abs_coord?(H=h(this.exprX),K=h(this.exprY)):(H=h(G.getAbsoluteX(this.exprX)),
K=h(G.getAbsoluteY(this.exprY)),C*=G.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng),this.iniAng>this.endAng&&(A=this.iniAng,this.iniAng=this.endAng,this.endAng=A)):this.drawPoints&&(this.abs_coord?(H=h(this.exprX),K=h(this.exprY)):(H=h(G.getAbsoluteX(this.exprX)),K=h(G.getAbsoluteY(this.exprY)),C*=G.scale,this.iniAng=-this.iniAng,this.endAng=-this.endAng));this.fill&&(a.fillStyle=b.getColor(),a.beginPath(),a.moveTo(H,K),a.arc(H,K,C,this.iniAng,this.endAng,void 0),a.fill());a.beginPath();
a.arc(H,K,C,this.iniAng,this.endAng,void 0);this.dashStyle();a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,H+4,K-2,this.color,this.font,"start","alphabetic",v.eval(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d,l,c,g,k,b,v,u,n,r,p,x,f,q,m,w,y;a.Text=function(b,f){this.width=b.evaluator.parser.parse("0");a.Graphic.call(this,b,f);this.align||(this.align="left");this.ascent=this.fontSize-Math.ceil(this.fontSize/
7)-(this.font.match("Courier")?3:0);this.descent=a.getFontMetrics(this.font).descent;this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){h=this.evaluator;e=h.eval(this.expresion);this.exprX=e[0][0];this.exprY=e[0][1];this.rotateExp&&(d=a.degToRad(h.eval(this.rotateExp)),l=Math.cos(d),c=Math.sin(d),g=this.exprX*l-this.exprY*c,k=this.exprX*c+this.exprY*l,this.exprX=g,this.exprY=k);4<=e[0].length&&(this.centered=!0,this.exprW=e[0][2],this.exprH=e[0][3])};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){w=this.evaluator.eval(this.decimals);"rtfNode"===this.text.type?(n=this.text,this.ascent=0):n=this.splitText(this.text.toString(w,this.fixed).split("\\n"));if(this.text!=[""]){var f=parseInt(this.exprX)+5,c=parseInt(this.exprY)+this.ascent;this.centered&&(f=this.getMaxWidth(n),f=parseInt(this.exprX+(this.exprW-f)/2),c=parseInt(this.exprY+
this.descent+(this.exprH-1.2*this.fontSize*(n.length-1))/2));this.uber.drawText.call(this,a,n,f,c,b,this.font,this.align,"alphabetic",w,this.fixed)}};a.Text.prototype.splitText=function(f){h=this.evaluator;b=h.eval(this.width);n=[];if(20<=b&&"undefined"!=f.type){for(var c=0,d=f.length;c<d;c++)v=f[c],u=a.getTextWidth(v,this.font),u>b?n=n.concat(this.splitWords(v,b)):n.push(v);r=Math.floor(1.2*this.fontSize)*n.length;h.setVariable("_Text_H_",r);return n}h.setVariable("_Text_H_",0);return f};a.Text.prototype.splitWords=
function(b,c){p=b;x=[];f="";for(var d=m=0,e=b.length;d<e;d++)q=p.charAt(d)," "===q&&(lastIndexOfWhite=d),f+=q,a.getTextWidth(f,this.font)>c&&(y=b.substring(m,d+1)," "!==q&&(-1===y.indexOf(" ")?(lastIndexOfWhite=d,d--):d=lastIndexOfWhite),x.push(b.substring(m,lastIndexOfWhite)),f="",m=d+1);x.push(b.substring(m));return x};a.Text.prototype.getMaxWidth=function(b){for(var f=-1,c=0,d=b.length;c<d;c++)v=b[c],f=Math.max(f,a.getTextWidth(v,this.font));return f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var h=Math.round,e,d,l,c,g,k,b,v,u,n,r,p,x,f,q,m;a.Image=function(b,f){this.file="";this.inirot=b.evaluator.parser.parse("0");a.Graphic.call(this,b,f);this.img=new Image;this.scaleY=this.scaleX=1;this.ratio=b.ratio;this.update()};a.extend(a.Image,a.Graphic);a.Image.prototype.update=function(){e=this.evaluator;d=e.eval(this.expresion);this.exprX=d[0][0];this.exprY=d[0][1];this.rotateExp&&(l=a.degToRad(e.eval(this.rotateExp)),c=Math.cos(l),g=Math.sin(l),k=this.exprX*c-this.exprY*g,b=this.exprX*g+this.exprY*
c,this.exprX=k,this.exprY=b);4<=d[0].length&&(this.centered=!0,this.scaleX=d[0][2],this.scaleY=d[0][3]);d[1]&&2==d[1].length&&(this.centered=!0,this.scaleX=d[1][0],this.scaleY=d[1][1]);0==this.scaleX&&(this.scaleX=1E-5);0==this.scaleY&&(this.scaleY=1E-5);if((v=e.eval(this.file))||""==v)this.img=this.parent.getImage(v)};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){e=this.evaluator;
u=this.space;this.img&&this.img.ready&&this.img.complete&&(q=this.img.width,m=this.img.height,this.img.canvas&&(q=h(q/this.ratio),m=h(m/this.ratio)),n=this.centered?0:h(q/2),r=this.centered?0:h(m/2),p=h(this.abs_coord?this.exprX:u.getAbsoluteX(this.exprX)),x=h(this.abs_coord?this.exprY:u.getAbsoluteY(this.exprY)),f=a.degToRad(-e.eval(this.inirot)),b.save(),b.translate(p+n,x+r),b.rotate(f),this.opacity&&(b.globalAlpha=e.eval(this.opacity)),b.scale(this.scaleX,this.scaleY),b.drawImage(this.img,-q/2,
-m/2,q,m),b.restore())};return a}(descartesJS||{}),descartesJS=function(a){function h(a,c,d){b=4*(c+d*a.width);return{r:a.data[b],g:a.data[b+1],b:a.data[b+2],a:a.data[b+3]}}if(a.loadLib)return a;var e,d,l,c,g,k,b,v;a.Fill=function(b,c){a.Graphic.call(this,b,c)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){e=this.evaluator.eval(this.expresion);this.exprX=e[0][0];this.exprY=e[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Fill.prototype.drawTrace=
function(){this.uber.drawTrace.call(this,this.trace,this.trace)};a.Fill.prototype.drawAux=function(a,e){e.getColor();imageData=a.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(d=parseInt(this.exprX),l=parseInt(this.exprY)):(d=parseInt(this.space.getAbsoluteX(this.exprX)),l=parseInt(this.space.getAbsoluteY(this.exprY)));if(!(0>d||0>l||d>=this.space.w||l>=this.space.h)){c=[[d,l]];k=h(imageData,d,l);for(v=0;0<c.length;){v++;g=c.pop();d=g[0];l=g[1];var r=h(imageData,d,l);if(k.r===r.r&&k.g===
r.g&&k.b===r.b&&k.a===r.a){var r=imageData,p=e;b=4*(d+l*r.width);r.data[b+0]=p.r;r.data[b+1]=p.g;r.data[b+2]=p.b;r.data[b+3]=255*p.a;0<d&&c.push([d-1,l]);d<imageData.width-1&&c.push([d+1,l]);c.push([d,l-1]);c.push([d,l+1])}if(v>=this.space.w*this.space.h*3)break}a.putImageData(imageData,0,0)}};return a}(descartesJS||{}),descartesJS=function(a,h){if(a.loadLib)return a;var e=new String("-_-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-_NumToStr_-_NumACadena_-_charAt_-_letraEn_-_substring_-_subcadena_-_length_-_longitud_-_indexOf_-\u00edndiceDe-_GetValues_-_GetMatrix_-_MatrixToStr_-_StrToMatrix_-_GetVector_-_VectorToStr_-_StrToVector_-_ExecStr_-_ExecBlock_-_Save_-_Open_-_SaveState_-_OpenState_-_AnchoDeCadena_-_strWidth_-_Rojo_-_Red_-_Verde_-_Green_-_Azul_-_Blue_-"),
d=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,l;a.Macro=function(c,g){this.hasExpresion=!1;this.inirot=c.evaluator.parser.parse("0");this.inipos=c.evaluator.parser.parse("(0,0)");a.Graphic.call(this,c,g);for(var k in g)"expresion"==k&&(this.hasExpresion=!0),g.hasOwnProperty(k)&&(this[k]=g[k]);this.graphics=[];k=c.lessonParser;var b=new a.Tokenizer;if(this.hasExpresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var l=
this.evaluator.eval(this.expresion),u;l&&((u=document.getElementById(l))&&"descartes/macro"==u.type?u=u.text:(u=a.openExternalFile(l))&&!u.match(/tipo_de_macro/g)&&(u=null));var n,r;if(u){r=u.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");u=[];for(var l=0,p=r.length;l<p;l++)if(n=r[l].indexOf("="),-1!==n){n=k.split(r[l]);for(var x=0,f=n.length;x<f;x++)n[x]&&1<n.length&&("id"!==h[n[x][0]]&&"type"!==h[n[x][0]]||u.push(n))}for(var q,m,l=0,p=u.length;l<p;l++)for(f=(x=u[l]||[],x[0])&&"id"===x[0][0],r=0,n=x.length;r<n;r++)if(q=x[r][0].indexOf("."),-1===q||f?q=h[x[r][0]]:(q=h[x[r][0].substring(q+1)],x[r][0]=
this.name+"."+x[r][0]),!("font"===q||("fill"===q||"color"===q||"border"===q||"arrow"===q)&&"("!==x[r][1].charAt(0)||"file"===q&&x[r][1].match(d)||"id"!==q&&void 0!==h[x[r][1]]))if("text"==q)if(x[r][1].match(/\{\\rtf1/)){q=x[r][1];var w=this;m=function(a,f){for(var c=b.tokenize(f.replace(/\&squot;/g,"'")),d=0,r=c.length;d<r;d++)"identifier"!=c[d].type||e.match("-"+c[d].value+"-")||(c[d].value=w.name+"."+c[d].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+b.flatTokens(c)};q=q.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,
m);q=q.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.'\+\-]*)/gi,m);x[r][1]=q}else{m=k.parseText(x[r][1]).textElementsMacros;for(var y=0,B=m.length;y<B;y++){q=b.tokenize(m[y].replace(/\&squot;/g,"'"));for(var E=0,F=q.length;E<F;E++)"identifier"!==q[E].type||e.match("-"+q[E].value+"-")||(q[E].value=this.name+"."+q[E].value);q=b.flatTokens(q).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");m[y]=q.substring(1,q.length-1)}x[r][1]=m.join("")}else{m=x[r][1].replace(/\&squot;/g,
"'").split(";");y=0;for(B=m.length;y<B;y++){q=b.tokenize(m[y].replace(/\\n/g,";"));E=0;for(F=q.length;E<F;E++)"identifier"!==q[E].type||e.match("-"+q[E].value+"-")||(q[E].value=this.name+"."+q[E].value);m[y]=b.flatTokens(q)}x[r][1]=m.join(";")}l=0;for(p=u.length;l<p;l++)if(u[l][0]){x="";f=!1;r=0;for(n=u[l].length;r<n;r++)"type"===h[u[l][r][0]]&&(x="espacio='"+this.spaceID+"' ",f=!0),x=x+u[l][r][0]+"='"+u[l][r][1]+"' ";u[l]=x;f?this.graphics.push(k.parseGraphic(u[l],this.abs_coord,this.background,
this.inirot)):k.parseAuxiliar(u[l])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){l=this.evaluator.eval(this.inipos);this.iniPosX=l[0][0];this.iniPosY=l[0][1]};a.Macro.prototype.drawAux=function(a){for(var d=0,e=this.graphics.length;d<e;d++)this.graphics[d]&&(a.save(),this.graphics[d].abs_coord?a.translate(this.iniPosX,this.iniPosY):a.translate(this.iniPosX*this.space.scale,-this.iniPosY*this.space.scale),this.graphics[d].draw(),a.restore())};return a}(descartesJS||{},babel),
descartesJS=function(a){if(a.loadLib)return a;a.Generic=function(h,e){this.width=h.evaluator.parser.parse("1");a.Graphic.call(this,h,e)};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,e,d){var l=this.evaluator.getDefinition(this.expresionString);l&&l.draw(a,e,
d,this)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.sqrt,e=Math.sin,d=Math.cos,l,c,g,k,b,v,u,n,r,p,x,f,q,m,w;a.norm3D=function(a){return h(a.x*a.x+a.y*a.y+a.z*a.z)};a.normalize3D=function(b){l=a.norm3D(b);if(0===l)return{x:0,y:0,z:0};if(1===l)return{x:b.x,y:b.y,z:b.z};l=1/l;return{x:b.x*l,y:b.y*l,z:b.z*l}};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,f){return Math.abs(a.x-b.x)<=f&&Math.abs(a.y-b.y)<=f&&Math.abs(a.z-b.z)<=f};a.Vector4D=function(a,b,f,c){this.x=a||0;this.y=b||0;this.z=f||0;this.w=c||0};a.Matrix4x4=function(a,b,f,c,d,e,r,g,k,m,p,h,n,q,l,u){this.a00=a||0;this.a01=b||0;this.a02=f||0;this.a03=c||0;this.a10=d||0;
this.a11=e||0;this.a12=r||0;this.a13=g||0;this.a20=k||0;this.a21=m||0;this.a22=p||0;this.a23=h||0;this.a30=n||0;this.a31=q||0;this.a32=l||0;this.a33=u||0};a.Matrix4x4.prototype.setIdentity=function(){this.a00=1;this.a10=this.a03=this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a13=this.a12=0;this.a22=1;this.a32=this.a31=this.a30=this.a23=0;this.a33=1;return this};a.Matrix4x4.prototype.multiplyVector4=function(b){return new a.Vector4D(b.x*this.a00+b.y*this.a10+b.z*this.a20+b.w*this.a30,b.x*this.a01+
b.y*this.a11+b.z*this.a21+b.w*this.a31,b.x*this.a02+b.y*this.a12+b.z*this.a22+b.w*this.a32,b.x*this.a03+b.y*this.a13+b.z*this.a23+b.w*this.a33)};a.Matrix4x4.prototype.translate=function(b){return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,this.a10,this.a11,this.a12,this.a13,this.a20,this.a21,this.a22,this.a23,this.a00*b.x+this.a10*b.y+this.a20*b.z+this.a30,this.a01*b.x+this.a11*b.y+this.a21*b.z+this.a31,this.a02*b.x+this.a12*b.y+this.a22*b.z+this.a32,this.a03*b.x+this.a13*b.y+this.a23*b.z+
this.a33)};a.Matrix4x4.prototype.rotateX=function(b){c=e(b);g=d(b);n=this.a10;r=this.a11;p=this.a12;x=this.a13;f=this.a20;q=this.a21;m=this.a22;w=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,n*g+f*c,r*g+q*c,p*g+m*c,x*g+w*c,n*-c+f*g,r*-c+q*g,p*-c+m*g,x*-c+w*g,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(r){c=e(r);g=d(r);k=this.a00;b=this.a01;v=this.a02;u=this.a03;f=this.a20;q=this.a21;m=this.a22;w=this.a23;return new a.Matrix4x4(k*g+f*-c,b*g+q*
-c,v*g+m*-c,u*g+w*-c,this.a10,this.a11,this.a12,this.a13,k*c+f*g,b*c+q*g,v*c+m*g,u*c+w*g,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(f){c=e(f);g=d(f);k=this.a00;b=this.a01;v=this.a02;u=this.a03;n=this.a10;r=this.a11;p=this.a12;x=this.a13;return new a.Matrix4x4(k*g+n*c,b*g+r*c,v*g+p*c,u*g+x*c,k*-c+n*g,b*-c+r*g,v*-c+p*g,u*-c+x*g,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33)};return a}(descartesJS||{}),descartesJS=function(a){function h(a){a.textNode=
null;0!==parseInt(this.size)&&(a.lineWidth=1,a.fillStyle=this.backColor,a.strokeStyle=this.frontColor,a.beginPath(),a.arc(this.projVert[0].x,this.projVert[0].y,this.size,0,g),a.fill(),a.stroke())}function e(a,b){a.textNode=null;a.lineCap="round";a.lineJoin="round";a.lineWidth="#"==this.backColor.charAt(0)||"#"==this.frontColor.charAt(0)?1:.1;a.beginPath();a.moveTo(this.projVert[0].x,this.projVert[0].y);for(var c=1,f=this.projVert.length;c<f;c++)a.lineTo(this.projVert[c].x,this.projVert[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.lineWidth=1,a.strokeStyle=
"#808080",a.stroke())}function d(a){a.textNode=null;u=this.evaluator.getVariable(this.family);this.evaluator.setVariable(this.family,this.familyValue);this.drawText(a,this.text,this.projVert[0].x,this.projVert[0].y+this.displace,this.frontColor,this.font,"left","alphabetic",this.decimals,this.fixed,!0);this.evaluator.setVariable(this.family,u)}function l(a){a.textNode=null;a.lineCap="round";a.lineJoin="round";a.lineWidth=this.lineWidth;a.strokeStyle=this.frontColor;a.beginPath();a.moveTo(this.projVert[0].x,
this.projVert[0].y);a.lineTo(this.projVert[1].x,this.projVert[1].y);"dot"===this.lineDash?(a.lineCap="butt",a.setLineDash([a.lineWidth,a.lineWidth])):"dash"===this.lineDash?(a.lineCap="butt",a.setLineDash([4*a.lineWidth,3*a.lineWidth])):"dash_dot"===this.lineDash?(a.lineCap="butt",a.setLineDash([4*a.lineWidth,2*a.lineWidth,a.lineWidth,2*a.lineWidth])):a.setLineDash([]);a.stroke()}function c(b,c,d){return a.normalize3D(a.crossProduct3D(a.subtract3D(b,c),a.subtract3D(b,d)))}if(a.loadLib)return a;var g=
2*Math.PI,k,b,v,u;a.Primitive3D=function(a,b){this.space=b;for(var g in a)a.hasOwnProperty(g)&&(this[g]=a[g]);this.projVert=[];this.spaceVertices=[];"vertex"===this.type?this.draw=h:"face"===this.type?(this.normal=c(this.vertices[0],this.vertices[1],this.vertices[2]),this.draw=e):"text"===this.type?(this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10,this.draw=d):"edge"===this.type&&(this.draw=l);this.isText&&(this.computeDepth=function(){this.projVert=this.vertices;
this.depth=this.vertices[0].z;this.average=this.vertices[0];this.passDraw=1})};a.Primitive3D.prototype.computeDepth=function(b){this.space=b;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 d=0,e=this.vertices.length;d<e;d++)this.spaceVertices[d]=b.rotateVertex(this.vertices[d]),this.average.x+=this.spaceVertices[d].x,this.average.y+=this.spaceVertices[d].y,this.average.z+=this.spaceVertices[d].z;this.average=a.scalarProduct3D(this.average,
1/e);this.depth=a.norm3D(a.subtract3D(b.eye,this.average));2<this.vertices.length&&(this.normal=c(this.spaceVertices[0],this.spaceVertices[1],this.spaceVertices[2]),this.direction=a.dotProduct3D(this.normal,a.normalize3D(b.eye)));this.passDraw=1;d=0;for(e=this.vertices.length;d<e;d++)this.projVert[d]=b.project(this.spaceVertices[d]),this.passDraw=this.passDraw&&0<this.projVert[d].z;this.minDistanceToEye=Math.Inifinity;this.maxDistanceToEye=-Math.Inifinity;this.miny=this.minx=Math.Inifinity;this.maxx=
-Math.Inifinity;this.maxy=-Math.Inifinity;d=0;for(e=this.vertices.length;d<e;d++){var f=a.norm3D(a.subtract3D(this.spaceVertices[d],b.eye));this.minDistanceToEye=Math.min(this.minDistanceToEye,f);this.maxDistanceToEye=Math.max(this.maxDistanceToEye,f)}d=0;for(e=this.vertices.length;d<e;d++)this.minx>this.projVert[d].x&&(minx=this.projVert[d].x),this.maxx<this.projVert[d].x&&(maxx=this.projVert[d].x),this.miny>this.projVert[d].y&&(miny=this.projVert[d].y),this.mixy<this.projVert[d].y&&(mixy=this.projVert[d].y);
b.new3D||(this.passDraw=1)};var n;a.Primitive3D.prototype.removeDoubles=function(){if("edge"!==this.type){n=[];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||n.push(this.vertices[a]);0===n.length&&n.push(this.vertices[0]);this.vertices=n}};a.Primitive3D.prototype.drawText=function(d,c,e,f,g,m,h,n,l,u,F){d.textNode=c;
if("rtfNode"==c.type)d.fillStyle=g,d.strokeStyle=g,d.textBaseline="alphabetic",d.textNode.pos={x:e,y:f},c.draw(d,e,f,l,u,h,F);else for("simpleText"===c.type&&(c=c.toString(l,u).split("\\n")),e+=/Arial|Times/i.test(m)?-2:0,k=this.evaluator,d.fillStyle=a.getColor(k,g),d.font=m,d.textAlign=h,d.textBaseline=n,b=1.2*this.fontSize||0,g=0,m=c.length;g<m;g++)v=c[g],this.border&&d.strokeText(v,e,f+b*g),d.fillText(v,e,f+b*g)};a.Primitive3D.prototype.splitFace=function(b){if(this.intersects(b)){var d=null,c=
null,f=0,e=0,g,k,h,n,l,u;u=this.vertices;var v=b.vertices;g=0;for(l=v.length;g<l;g++)if(n=this.intersection(v[g],v[(g+1)%l]),null!==n)if(null===d){if(d=n,f=g,2===v.length){c=d;break}}else if(!a.equals3DEpsilon(n,d,1E-8)){c=n;e=g;break}if(null!==d&&null!==c){g=this.isInterior(d)||this.isInterior(c);h=k=null;if(!g&&3<=v.length)for(l=0,u=u.length;l<u;l++)if(n=b.intersection(this.vertices[l],this.vertices[(l+1)%u]),null!==n)if(null===k)k=n;else if(!a.equals3DEpsilon(n,k,1E-8)){h=n;break}if(g||null!==
k&&null!==h&&b.isInterior(k)&&b.isInterior(h)){h=!0;u=n=null;if(2===v.length)a.equals3DEpsilon(d,v[0],1E-8)||a.equals3DEpsilon(d,v[1],1E-8)?h=!1:(n=[],n[0]=v[0],n[1]=d,u=[],u[0]=d,u[1]=v[1]);else for(n=[],u=[],g=l=k=0;g<v.length;g++)g<f?n[k++]=v[g]:g==f?(n[k++]=v[g],n[k++]=d,u[l++]=d):g<e?u[l++]=v[g]:g==e?(u[l++]=v[g],u[l++]=c,n[k++]=c):n[k++]=v[g];if(h)return d=[],d[0]=new a.Primitive3D({vertices:n,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model},this.space),
d[0].normal=b.normal,d[1]=new a.Primitive3D({vertices:u,type:"face",frontColor:b.frontColor,backColor:b.backColor,edges:b.edges,model:b.model},this.space),d[1].normal=b.normal,d}}}return[b]};a.Primitive3D.prototype.intersects=function(a){return this.intersectsPlane(a)&&a.intersectsPlane(this)};a.Primitive3D.prototype.intersectsPlane=function(b){var d,c,f,e=this.vertices;d=b.vertices;if(0<d.length){c=a.dotProduct3D(d[0],b.normal);f=a.dotProduct3D(e[0],b.normal);if(1E-8>Math.abs(c-f))return!0;for(var g=
1,k=e.length;g<k;g++)if(d=a.dotProduct3D(e[g],b.normal),1E-8>Math.abs(c-d)||d>c&&f<c||d<c&&f>c)return!0}return!1};a.Primitive3D.prototype.intersection=function(b,d){var c=this.vertices;if(0<c.length){var f=a.subtract3D(d,b),e=a.dotProduct3D(f,this.normal);if(0!==e&&(c=a.dotProduct3D(a.subtract3D(c[0],b),this.normal)/e,-1E-8<c&&1.00000001>c))return a.add3D(b,a.scalarProduct3D(f,c))}return null};a.Primitive3D.prototype.isInterior=function(b){var d=this.vertices;if(0<d.length)for(var c=0,f=a.subtract3D(d[0],
b),e=0,g=d.length;e<g;e++){var k=a.subtract3D(d[(e+1)%g],b),h=a.dotProduct3D(a.crossProduct3D(f,k),this.normal);if(1E-8>Math.abs(h)){if(0>a.dotProduct3D(f,k))break}else{if(0>c&&0<h||0<c&&0>h)return!1;f=k;c=h}}return!0};a.Primitive3D.prototype.inFrontOf=function(a,b,d){var f,c;if(this.maxx<=b.minx||this.minx>=b.maxx||this.maxy<=b.miny||this.miny>=b.maxy||this.minDistanceToEye>=b.maxDistanceToEye)return!1;for(var e=0;3>e;e++){f=null;switch(e){case 0:f=this.intersections(b);break;case 1:f=b.verticesContainedIn(this);
break;case 2:f=this.verticesContainedIn(b)}if(null!=f&&f!=[]){for(var g=0;g<f.length;g++)a.push(f[g]);for(var g=0,k=f.length;g<k;g++){c=f[g];c=this.space.rayFromEye(c.x,c.y);try{t=this.distanceToEyeAlong(c)-b.distanceToEyeAlong(c);if(t<=-d)return!0;if(t>=d)return!1}catch(h){console.log("Error: inFrontOf")}}}}return!1};a.Primitive3D.prototype.intersections=function(b){for(var d=[],c,f,e,g=new a.R2,k=this.spaceVertices,h=b.spaceVertices,n=this.projVert,l=b.projVert,u=0,v=k.length;u<v;u++){b=k[u];c=
k[(u+1)%v];for(var G=0,H=h.length;G<H;G++)f=h[G],e=h[(G+1)%H],b!=f&&b!=e&&c!=f&&c!=e&&(f=g.intersection(n[u],n[(u+1)%v],l[G],l[(G+1)%H]),null!=f&&d.push(f))}return d};a.Primitive3D.prototype.distanceToEyeAlong=function(b){b=a.dotProduct3D(this.normal,b);if(1E-6<Math.abs(b))return a.dotProduct3D(a.subtract3D(this.average,this.space.eye),this.normal)/b};a.Primitive3D.prototype.verticesContainedIn=function(a){for(var b=[],d=this.spaceVertices,f=this.projVert,c=0,e=d.length;c<e;c++)!a.isVertex(d[c])&&
a.appearsToContain(f[c])&&b.push(f[c]);return b};a.Primitive3D.prototype.appearsToContain=function(a){for(var b=0,d,f=this.projVert,c=0,e=this.spaceVertices.length;c<e;c++){d=(f[c].x-a.x)*(f[(c+1)%e].y-a.y)-(f[(c+1)%e].x-a.x)*(f[c].y-a.y);if(0!=b)if(1E-8>Math.abs(d)){if(1E-8<Math.abs(f[c].x-f[(c+1)%e].x))return Math.min(f[c].x,f[(c+1)%e].x)<=a.x+1E-8&&a.x<=Math.max(f[c].x,f[(c+1)%e].x)+1E-8;if(1E-8<Math.abs(f[c].y-f[(c+1)%e].y))return Math.min(f[c].y,f[(c+1)%e].y)<=a.y+1E-8&&a.y<=Math.max(f[c].y,
f[(c+1)%e].y)+1E-8}else if(0<b&&0>d||0>b&&0<d)return!1;b=d}return!0};a.Primitive3D.prototype.isVertex=function(b){for(var d=this.spaceVertices,c=0,f=d.length;c<f;c++)if(a.equals3DEpsilon(b,d[c],1E-8))return!0;return!1};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h={x:0,y:0,z:0},e,d,l,c,g,k,b=a.degToRad;a.Graphic3D=function(b,d){this.parent=b;this.evaluator=b.evaluator;var c=b.evaluator.parser;this.spaceID="E0";this.background=!1;this.type="";this.color=new a.Color("eeffaa");
this.backcolor=new a.Color("6090a0");this.Nu=this.evaluator.parser.parse("7");this.Nv=this.evaluator.parser.parse("7");this.drawif=c.parse("1");this.abs_coord=!1;this.family="";this.family_interval=c.parse("[0,1]");this.family_steps=c.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=c.parse("2");this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=c.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=c.parse("(0,0,0)");this.model="color";for(var e in d)d.hasOwnProperty(e)&&
(this[e]=d[e]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=c.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?this.space.backCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseFloat(this.fontSize[1]):10;this.inirot.match("Euler")&&(this.inirot=this.inirot.replace("Euler",""),this.inirotEuler=!0);this.endrot.match("Euler")&&(this.endrot=this.endrot.replace("Euler",
""),this.endrotEuler=!0);this.inirot=c.parse(this.inirot);this.endrot=c.parse(this.endrot);this.inirotM=new a.Matrix4x4;this.inirotM_X=new a.Matrix4x4;this.inirotM_Y=new a.Matrix4x4;this.inirotM_Z=new a.Matrix4x4;this.iniposM=new a.Matrix4x4;this.endrotM=new a.Matrix4x4;this.endrotM_X=new a.Matrix4x4;this.endrotM_Y=new a.Matrix4x4;this.endrotM_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4};a.Graphic3D.prototype.getSpace=function(){for(var a=this.parent.spaces,b,d=0,c=a.length;d<c;d++)if(b=a[d],b.id==
this.spaceID)return b;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){e=this.evaluator;d=e.eval(this.family_interval);this.familyInf=d[0][0];this.familySup=d[0][1];this.fSteps=Math.round(e.eval(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){e=this.evaluator;this.getFamilyValues();l=e.getVariable(this.family);if(0<=this.fSteps)for(var a=0,b=this.fSteps;a<=b;a++)e.setVariable(this.family,
this.familyInf+a*this.family_sep),this.familyValue=this.familyInf+a*this.family_sep,e.eval(this.drawif)&&this.buildPrimitives();e.setVariable(this.family,l)};a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.eval(this.drawif)&&(this.family||this.buildPrimitives());this.family&&this.buildFamilyPrimitives()};a.Graphic3D.prototype.updateMVMatrix=function(){g=this.evaluator.eval(this.inirot);this.inirotEuler?(this.inirotM=this.inirotM.setIdentity(),this.inirotM=this.inirotM.rotateZ(b(g[0][0])),
this.inirotM=this.inirotM.rotateX(b(g[0][1])),this.inirotM=this.inirotM.rotateZ(b(g[0][2]))):(this.inirotM_X=this.inirotM_X.setIdentity().rotateX(b(g[0][0])),this.inirotM_Y=this.inirotM_Y.setIdentity().rotateY(b(g[0][1])),this.inirotM_Z=this.inirotM_Z.setIdentity().rotateZ(b(g[0][2])));g=this.evaluator.eval(this.inipos);h={x:g[0][0],y:g[0][1],z:g[0][2]};this.iniposM=this.iniposM.setIdentity().translate(h);g=this.evaluator.eval(this.endrot);this.endrotEuler?(this.endrotM=this.endrotM.setIdentity(),
this.endrotM=this.endrotM.rotateZ(b(g[0][0])),this.endrotM=this.endrotM.rotateX(b(g[0][1])),this.endrotM=this.endrotM.rotateZ(b(g[0][2]))):(this.endrotM_X=this.endrotM_X.setIdentity().rotateX(b(g[0][0])),this.endrotM_Y=this.endrotM_Y.setIdentity().rotateY(b(g[0][1])),this.endrotM_Z=this.endrotM_Z.setIdentity().rotateZ(b(g[0][2])));g=this.evaluator.eval(this.endpos);h={x:g[0][0],y:g[0][1],z:g[0][2]};this.endposM=this.endposM.setIdentity().translate(h)};a.Graphic3D.prototype.transformVertex=function(a){this.inirotEuler?
c=this.inirotM.multiplyVector4(a):(c=this.inirotM_X.multiplyVector4(a),c=this.inirotM_Y.multiplyVector4(c),c=this.inirotM_Z.multiplyVector4(c));c=this.iniposM.multiplyVector4(c);this.endrotEuler?c=this.endrotM.multiplyVector4(c):(c=this.endrotM_X.multiplyVector4(c),c=this.endrotM_Y.multiplyVector4(c),c=this.endrotM_Z.multiplyVector4(c));c=this.endposM.multiplyVector4(c);this.macroChildren&&(c=this.applyMacroTransform(c));return c};a.Graphic3D.prototype.applyMacroTransform=function(a){this.macro_inirotEuler?
c=this.macro_inirotM.multiplyVector4(a):(c=this.macro_inirotM_X.multiplyVector4(a),c=this.macro_inirotM_Y.multiplyVector4(c),c=this.macro_inirotM_Z.multiplyVector4(c));c=this.macro_iniposM.multiplyVector4(c);this.macro_endrotEuler?c=this.macro_endrotM.multiplyVector4(c):(c=this.macro_endrotM_X.multiplyVector4(c),c=this.macro_endrotM_Y.multiplyVector4(c),c=this.macro_endrotM_Z.multiplyVector4(c));return c=this.macro_endposM.multiplyVector4(c)};a.Graphic3D.prototype.parseExpression=function(){k=[];
for(var a=this.expresion.replace(/\n/g," ").replace(/ ( )+/g," ").trim(),b=[],d=0,c,e=a.length,f=a.length-1;-1<f;f--)c=a.charAt(f),0==d?"="==c&&(d=1):1==d?" "!=c&&(d="<"==c||">"==c?0:2):2==d&&" "==c&&(b.unshift(a.substring(f+1,e)),e=f,d=0);b.unshift(a.substring(0,e));f=0;for(a=b.length;f<a;f++)k.push(this.evaluator.parser.parse(b[f],!0));return k};var v;a.Graphic3D.prototype.splitFace=function(a){for(var b=0,d=this.primitives.length;b<d;b++)if(v=[],"face"===this.primitives[b].type){for(var c=0,e=
a.primitives.length;c<e;c++)"face"===a.primitives[c].type?v=v.concat(this.primitives[b].splitFace(a.primitives[c])):v.push(a.primitives[c]);a.primitives=v}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d,l,c;a.Point3D=function(d,c){a.Graphic3D.call(this,d,c)};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){h=this.evaluator;this.updateMVMatrix();e=h.eval(this.expresion);d=e[0][0];l=e[0][1];c=e[0][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,
l,c,1))],type:"vertex",backColor:this.backcolor.getColor(),frontColor:this.color.getColor(),size:h.eval(this.width)}));""!==this.text&&this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(d,l,c,1))],type:"text",frontColor:this.color.getColor(),font:this.font,decimals:h.eval(this.decimals),fixed:this.fixed,displace:this.fontSize,evaluator:h,text:this.text,family:this.family,familyValue:this.familyValue},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var h,e,d,l,c,g,k;a.Segment3D=function(b,d){this.width=b.evaluator.parser.parse("1");a.Graphic3D.call(this,b,d)};a.extend(a.Segment3D,a.Graphic3D);a.Segment3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();k=evaluator.getVariable("u");evaluator.setVariable("u",this.Nu);expr=evaluator.eval(this.expresion);h=expr[0][0];e=expr[0][1];d=expr[0][2];l=expr[1][0];c=expr[1][1];g=expr[1][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,
e,d,1)),this.transformVertex(new a.Vector4D(l,c,g,1))],type:"edge",lineDash:this.lineDash,frontColor:this.color.getColor(),lineWidth:evaluator.eval(this.width)},this.space));evaluator.setVariable("u",k)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d,l,c,g,k,b,v,u,n,r,p,x;a.Surface3D=function(b,d){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,d);this.expresion=
this.parseExpression()};a.extend(a.Surface3D,a.Graphic3D);a.Surface3D.prototype.buildPrimitives=function(){h=this.evaluator;this.updateMVMatrix();l=h.getVariable("x");c=h.getVariable("y");g=h.getVariable("z");e=h.getVariable("u");d=h.getVariable("v");h.setVariable("u",0);h.setVariable("v",0);k=h.eval(this.Nu);b=h.eval(this.Nv);v=[];for(n=0;n<=k;n++)for(h.setVariable("u",n/k),r=0;r<=b;r++){h.setVariable("v",r/b);p=0;for(x=this.expresion.length;p<x;p++)h.eval(this.expresion[p]);v.push(this.transformVertex(new a.Vector4D(h.getVariable("x"),
h.getVariable("y"),h.getVariable("z"),1)))}for(n=0;n<k;n++)for(r=0;r<b;r++)u=[],u.push(v[r+n*b+n]),u.push(v[r+1+n*b+n]),u.push(v[r+2+(n+1)*b+n]),u.push(v[r+1+(n+1)*b+n]),this.primitives.push(new a.Primitive3D({vertices:u,type:"face",frontColor:this.color.getColor(),backColor:this.backcolor.getColor(),edges:this.edges,model:this.model},this.space));h.setVariable("x",l);h.setVariable("y",c);h.setVariable("z",g);h.setVariable("u",e);h.setVariable("v",d)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var h,e,d,l,c,g;a.Polygon3D=function(d,b){this.width=d.evaluator.parser.parse("1");a.Graphic3D.call(this,d,b)};a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.eval(this.expresion);for(var k=0,b=expr.length-1;k<b;k++)h=expr[k][0],e=expr[k][1],d=expr[k][2],l=expr[k+1][0],c=expr[k+1][1],g=expr[k+1][2],this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,e,d,1)),this.transformVertex(new a.Vector4D(l,
c,g,1))],type:"edge",frontColor:this.color.getColor(),lineWidth:evaluator.eval(this.width)},this.space))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d,l,c,g;a.Curve3D=function(d,b){this.width=d.evaluator.parser.parse("1");a.Graphic3D.call(this,d,b);this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();l=evaluator.getVariable("x");c=evaluator.getVariable("y");
g=evaluator.getVariable("z");d=evaluator.getVariable("u");evaluator.setVariable("u",0);e=evaluator.eval(this.Nu);h=[];for(var k=0;k<=e;k++){evaluator.setVariable("u",k/e);for(var b=0,v=this.expresion.length;b<v;b++)evaluator.eval(this.expresion[b]);h.push(this.transformVertex(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}k=0;for(b=h.length-1;k<b;k++)this.primitives.push(new a.Primitive3D({vertices:[h[k],h[k+1]],type:"edge",frontColor:this.color.getColor(),
lineWidth:evaluator.eval(this.width)},this.space));evaluator.setVariable("x",l);evaluator.setVariable("y",g);evaluator.setVariable("z",c);evaluator.setVariable("u",d)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d,l,c,g,k,b,v;a.Triangle3D=function(b,d){a.Graphic3D.call(this,b,d)};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.eval(this.expresion);h=expr[0][0];e=
expr[0][1];d=expr[0][2];l=expr[1][0];c=expr[1][1];g=expr[1][2];k=expr[2][0];b=expr[2][1];v=expr[2][2];this.primitives.push(new a.Primitive3D({vertices:[this.transformVertex(new a.Vector4D(h,e,d,1)),this.transformVertex(new a.Vector4D(k,b,v,1)),this.transformVertex(new a.Vector4D(l,c,g,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 h;a.Face3D=
function(e,d){a.Graphic3D.call(this,e,d)};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.eval(this.expresion);h=[];for(var e=expr.length-1;0<=e;e--)h.push(this.transformVertex(new a.Vector4D(expr[e][0],expr[e][1],expr[e][2],1)));this.primitives.push(new a.Primitive3D({vertices:h,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 h,e,d,l,c;a.Polireg3D=function(d,c){this.width=d.evaluator.parser.parse("2");this.length=d.evaluator.parser.parse("2");a.Graphic3D.call(this,d,c)};a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();h=evaluator.eval(this.Nu);e=[this.transformVertex(new a.Vector4D(0,0,0,1))];d=evaluator.eval(this.width)/2;l=evaluator.eval(this.length)/2;c=2*Math.PI/
h;for(var g=0;g<h;g++)e.push(this.transformVertex(new a.Vector4D(d*Math.cos(c*g),l*Math.sin(c*g),0,1)));for(g=0;g<h;g++)this.primitives.push(new a.Primitive3D({vertices:[e[0],g+2<=h?e[g+2]:e[1],e[g+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 h,e,d,l;a.Text3D=function(d,e){a.Graphic3D.call(this,d,e)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=
function(){h=this.evaluator;e=h.eval(this.expresion);d=e[0][0];l=e[0][1];this.primitives.push(new a.Primitive3D({vertices:[new a.Vector4D(d,l,0,1)],type:"text",frontColor:this.color.getColor(),font:this.font,decimals:h.eval(this.decimals),fixed:this.fixed,displace:0,isText:!0,evaluator:h,text:this.text,family:this.family,familyValue:this.familyValue},this.space))};return a}(descartesJS||{}),descartesJS=function(a,h){if(a.loadLib)return a;var e=new String("-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-"),
d=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,l,c;a.Macro3D=function(c,k){this.expresion=void 0;this.inirot="(0,0,0)";this.inirotEuler=!1;this.inipos=c.evaluator.parser.parse("(0,0,0)");this.endrot="(0,0,0)";this.endrotEuler=!1;this.endpos=c.evaluator.parser.parse("(0,0,0)");a.Graphic.call(this,c,k);for(var b in k)k.hasOwnProperty(b)&&(this[b]=k[b]);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=[];b=c.lessonParser;var l=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 u=this.evaluator.eval(this.expresion),n;u&&((n=document.getElementById(u))&&"descartes/macro"==n.type?n=n.text:(n=a.openExternalFile(u))&&!n.match(/tipo_de_macro/g)&&(n=null));var r,p;if(n){p=n.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");n=[];for(var u=0,x=p.length;u<x;u++)r=p[u].indexOf("="),-1!==r&&(r=p[u].substring(0,r),"id"!==h[r]&&"type"!==h[r]||n.push(b.split(p[u])));for(var f,q,m,w,u=0,x=n.length;u<x;u++)for(w=(f=n[u]||[],f[0])&&"id"===f[0][0],p=0,r=f.length;p<r;p++)if(q=
f[p][0].indexOf("."),-1===q||w?q=h[f[p][0]]:(q=h[f[p][0].substring(q+1)],f[p][0]=this.name+"."+f[p][0]),!("font"===q||("fill"===q||"color"===q||"backcolor"===q||"arrow"===q)&&"("!==f[p][1].charAt(0)||"file"===q&&f[p][1].match(d)||"id"!==q&&void 0!==h[f[p][1]])||"width"===q||"height"===q||"length"===q)if("text"==q)if(f[p][1].match(/\{\\rtf1/)){q=f[p][1];var y=this;m=function(a,b){for(var d=l.tokenize(b.replace(/\&squot;/g,"'")),c=0,f=d.length;c<f;c++)"identifier"!=d[c].type||e.match("-"+d[c].value+
"-")||(d[c].value=y.name+"."+d[c].value);return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+l.flatTokens(d)};q=q.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,m);q=q.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,m);f[p][1]=q}else{m=b.parseText(f[p][1]).textElementsMacro3Ds;for(var B=0,E=m.length;B<E;B++){q=l.tokenize(m[B].replace(/\&squot;/g,"'"));for(var F=0,D=q.length;F<D;F++)"identifier"!==q[F].type||e.match("-"+q[F].value+"-")||(q[F].value=this.name+"."+
q[F].value);q=l.flatTokens(q).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");m[B]=q.substring(1,q.length-1)}f[p][1]=m.join("")}else{q=l.tokenize(f[p][1]);m=0;for(B=q.length;m<B;m++)"identifier"!==q[m].type||e.match("-"+q[m].value+"-")||(q[m].value=this.name+"."+q[m].value);f[p][1]=l.flatTokens(q)}u=0;for(x=n.length;u<x;u++)if(n[u][0]){f="";w=!1;p=0;for(r=n[u].length;p<r;p++)"type"===h[n[u][p][0]]&&(f="espacio='"+this.spaceID+"' ",w=!0),f=f+n[u][p][0]+"='"+n[u][p][1]+"' ";n[u]=
f;w?this.graphics.push(b.parse3DGraphic(n[u],this.abs_coord,this.background,this.inirot)):b.parseAuxiliar(n[u])}}u=0;for(x=this.graphics.length;u<x;u++)this.graphics[u].macroChildren=!0}};a.extend(a.Macro3D,a.Graphic);a.Macro3D.prototype.update=function(){this.updateTransformation();if(this.inipos){var a=this.evaluator.eval(this.inipos);this.iniPosX=a[0][0];this.iniPosY=a[0][1]}this.primitives=[];for(var a=0,d=this.graphics.length;a<d;a++)l=this.graphics[a],l.macro_inirotEuler=this.inirotEuler,l.macro_inirotM=
this.inirotM,l.macro_inirotM_X=this.inirotM_X,l.macro_inirotM_Y=this.inirotM_Y,l.macro_inirotM_Z=this.inirotM_Z,l.macro_iniposM=this.iniposM,l.macro_endrotEuler=this.endrotEuler,l.macro_endrotM=this.endrotM,l.macro_endrotM_X=this.endrotM_X,l.macro_endrotM_Y=this.endrotM_Y,l.macro_endrotM_Z=this.endrotM_Z,l.macro_endposM=this.endposM,l.update();a=0;for(d=this.graphics.length;a<d;a++){l=this.graphics[a];if(l.split||this.split)for(var b=a+1;b<d;b++)c=this.graphics[b],(c.split||this.split)&&l.splitFace(c);
this.primitives=this.primitives.concat(l.primitives||[])}};a.Macro3D.prototype.updateTransformation=function(){tmpExpr=this.evaluator.eval(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.eval(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.eval(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.eval(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 h(a,
b,d,c,f){e.call(this,a/1.8,a/1.8,a/1.8,c,f)}function e(a,b,d,c,e){a/=2;b/=2;d/=2;this.changeGeometry(a,b,d,c,e)||(this.vertices=[new f(a,d,b,1),new f(a,-d,b,1),new f(a,d,-b,1),new f(a,-d,-b,1),new f(-a,d,b,1),new f(-a,-d,b,1),new f(-a,d,-b,1),new f(-a,-d,-b,1)],this.faces=[[2,3,1,0],[1,5,4,0],[5,7,6,4],[6,7,3,2],[4,6,2,0],[3,7,5,1]],this.updateValues(a,b,d,c,e))}function d(a,b,d,c,e){a/=2;this.changeGeometry(a,b,d,c,e)||(this.vertices=[new f(0,0,a,1),new f(-.49*a,-.86*a,-.32*a,1),new f(-.49*a,.86*
a,-.32*a,1),new f(1*a,0,-.32*a,1)],this.faces=[[3,2,1],[1,2,0],[2,3,0],[3,1,0]],this.updateValues(a,b,d,c,e))}function l(a,b,d,c,e){a/=2;this.changeGeometry(a,b,d,c,e)||(this.vertices=[new f(0,0,a,1),new f(a,0,0,1),new f(-a,0,0,1),new f(0,a,0,1),new f(0,-a,0,1),new f(0,0,-a,1)],this.faces=[[3,1,0],[2,3,0],[1,4,0],[4,2,0],[1,3,5],[3,2,5],[4,1,5],[2,4,5]],this.updateValues(a,b,d,c,e))}function c(b,d,c,e,g){b/=3.4;if(!this.changeGeometry(b,d,c,e,g)){D=b/1.6180339887;G=1.6180339887*b;this.vertices=[new f(b,
b,b,1),new f(b,b,-b,1),new f(b,-b,b,1),new f(b,-b,-b,1),new f(-b,b,b,1),new f(-b,b,-b,1),new f(-b,-b,b,1),new f(-b,-b,-b,1),new f(0,D,G,1),new f(0,D,-G,1),new f(0,-D,G,1),new f(0,-D,-G,1),new f(D,G,0,1),new f(D,-G,0,1),new f(-D,G,0,1),new f(-D,-G,0,1),new f(G,0,D,1),new f(G,0,-D,1),new f(-G,0,D,1),new f(-G,0,-D,1)];H=(new a.Matrix4x4).setIdentity().rotateY(-p/6);A=0;for(I=this.vertices.length;A<I;A++)this.vertices[A]=H.multiplyVector4(this.vertices[A]);this.faces=[[0,16,2,10,8],[12,1,17,16,0],[8,
4,14,12,0],[2,16,17,3,13],[13,15,6,10,2],[6,18,4,8,10],[3,17,1,9,11],[13,3,11,7,15],[1,12,14,5,9],[11,9,5,19,7],[5,14,4,18,19],[6,15,7,19,18]];this.updateValues(b,d,c,e,g)}}function g(b,d,c,e,g){b/=4;if(!this.changeGeometry(b,d,c,e,g)){G=1.6180339887*b;this.vertices=[new f(0,b,G,1),new f(0,b,-G,1),new f(0,-b,G,1),new f(0,-b,-G,1),new f(b,G,0,1),new f(b,-G,0,1),new f(-b,G,0,1),new f(-b,-G,0,1),new f(G,0,b,1),new f(G,0,-b,1),new f(-G,0,b,1),new f(-G,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]];H=(new a.Matrix4x4).setIdentity().rotateY(-1.029);A=0;for(I=this.vertices.length;A<I;A++)this.vertices[A]=H.multiplyVector4(this.vertices[A]);this.updateValues(b,d,c,e,g)}}function k(a,b,d,c,e){a/=2;this.isSphere?d=b=a:(b/=2,d/=2);if(!this.changeGeometry(a,b,d,c,e)){this.vertices=[new f(0,0,b,1)];for(A=1;A<c;A++)for(F=A*p/c,J=0;J<e;J++)E=J*x/e,w=a*n(F)*r(E),
y=d*n(F)*n(E),B=b*r(F),this.vertices.push(new f(w,y,B,1));this.vertices.push(new f(0,0,-b,1));this.faces=[];for(A=0;A<e;A++)this.faces.push([0,(A+1)%e+1,A%e+1]);for(A=1;A<c-1;A++)for(J=0;J<e;J++)this.faces.push([J+1+(A-1)*e,(J+1)%e+1+(A-1)*e,(J+1)%e+1+A*e,J+1+A*e]);for(A=0;A<e;A++)this.faces.push([this.vertices.length-1,this.vertices.length-1-e+A,this.vertices.length-1-e+(A+1)%e]);this.updateValues(a,b,d,c,e)}}function b(a,b,d,c,e){a/=2;b/=2;d/=2;if(!this.changeGeometry(a,b,d,c,e)){this.vertices=
[];for(A=0;A<e;A++)for(J=0;J<c;J++)w=a*(e-A)/e*r(J*x/c),y=d*(e-A)/e*n(J*x/c),B=b-2*A*b/e,this.vertices.push(new f(w,y,B,1));this.vertices.push(new f(0,0,-b,1));this.faces=[];for(A=0;A<e-1;A++)for(J=0;J<c;J++)this.faces.push([J+A*c,(J+1)%c+A*c,(J+1)%c+(A+1)*c,J+(A+1)*c]);for(A=0;A<c;A++)this.faces.push([this.vertices.length-1,this.vertices.length-1-c+A,this.vertices.length-1-c+(A+1)%c]);this.updateValues(a,b,d,c,e)}}function v(a,b,d,c,e){a/=2;b/=2;d/=2;if(!this.changeGeometry(a,b,d,c,e)){this.vertices=
[];for(A=0;A<e+1;A++)for(J=0;J<c;J++)w=a*r(J*x/c),y=d*n(J*x/c),B=b-2*A*b/e,this.vertices.push(new f(w,y,B,1));this.faces=[];for(A=0;A<e;A++)for(J=0;J<c;J++)this.faces.push([J+A*c,(J+1)%c+A*c,(J+1)%c+(A+1)*c,J+(A+1)*c]);this.updateValues(a,b,d,c,e)}}function u(){function a(b){return parseInt(b)}function b(a){return parseFloat(a)}this.vertices=[];this.faces=[];A=0;for(I=this.fileData.length;A<I;A++)K=this.fileData[A],K.match(/^V\(/)?(C=K.substring(2,K.length-1).split(",").map(b),this.vertices.push(new f(C[0]||
0,C[1]||0,C[2]||0,1))):K.match(/^F\(/)&&(C=K.substring(2,K.length-1).split(",").map(a),this.faces.push(C.reverse()))}if(a.loadLib)return a;var n=Math.sin,r=Math.cos,p=Math.PI,x=2*p,f,q,m,w,y,B,E,F,D,G,H,K,C,A,I,J,M;a.OtherGeometry=function(n,m){this.width=n.evaluator.parser.parse("2");this.height=n.evaluator.parser.parse("2");this.length=n.evaluator.parser.parse("2");f=a.Vector4D;a.Graphic3D.call(this,n,m);switch(this.type){case "cube":this.buildGeometry=h;break;case "box":this.buildGeometry=e;break;
case "tetrahedron":this.buildGeometry=d;break;case "octahedron":this.buildGeometry=l;break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=k;break;case "dodecahedron":this.buildGeometry=c;break;case "icosahedron":this.buildGeometry=g;break;case "cone":this.buildGeometry=b;break;case "cylinder":this.buildGeometry=v;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.eval(this.file)).split(/\r/),this.buildGeometry=u}};a.extend(a.OtherGeometry,a.Graphic3D);a.OtherGeometry.prototype.buildPrimitives=
function(){q=this.evaluator;this.updateMVMatrix();this.buildGeometry(q.eval(this.width),q.eval(this.height),q.eval(this.length),q.eval(this.Nu),q.eval(this.Nv));A=0;for(I=this.faces.length;A<I;A++){m=[];J=0;for(M=this.faces[A].length;J<M;J++)m.push(this.transformVertex(this.vertices[this.faces[A][J]]));this.primitives.push(new a.Primitive3D({vertices:m,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,d,c,f){return this.oldWidth===a&&this.oldHeight===b&&this.oldLength===d&&this.oldNu===c&&this.oldNv===f};a.OtherGeometry.prototype.updateValues=function(a,b,d,c,f){this.oldWidth=a;this.oldHeight=b;this.oldLength=d;this.oldNv=f;this.oldNu=c};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.max,e=Math.min,d=Math.PI,l=Math.cos,c=Math.sin,g=Math.abs,k=Math.round,b,v,u,n,r,p,x,f,q,m,w,y,B,E,F,D,G,H;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 k(h(e(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return k(h(e(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){v=this.copy();v.sub(a);return v.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(){b=this.norm();0!=b&&this.div(b)};a.R2.prototype.rotR90=function(){b=this.x;this.x=this.y;this.y=-b};a.R2.prototype.rotL90=function(){b=
this.x;this.x=-this.y;this.y=b};a.R2.prototype.rot=function(a){u=this.copy();p=l(a);x=c(a);this.x=u.x*p-u.y*x;this.y=u.x*x+u.y*p};a.R2.prototype.rot=function(a){this.rot(a*d/180)};a.R2.prototype.intersection=function(b,d,c,k){f=d.x-b.x;q=c.x-k.x;m=c.x-b.x;w=d.y-b.y;y=c.y-k.y;B=c.y-b.y;H=f*y-q*w;return 1E-6<g(H)?(n=(m*y-B*q)/H,r=(-m*w+B*f)/H,0<=n&&1>=n&&0<=r&&1>=r?new a.R2(b.x+f*n,b.y+w*n):null):(d.x-c.x)*B!=(d.y-c.y)*m?null:b.x!=d.x?(E=e(b.x,d.x),F=h(b.x,d.x),E<=c.x&&c.x<=F?c:E<=k.x&&k.x<=F?k:null):
c.x!=k.x?(D=e(c.x,k.x),G=h(c.x,k.x),D<=b.x&&b.x<=G?b:D<=d.x&&d.x<=G?d:null):b.y!=d.y?(E=e(b.y,d.y),F=h(b.y,d.y),E<=c.y&&c.y<=F?c:E<=k.y&&k.y<=F?k:null):c.y!=k.y?(D=e(c.y,k.y),G=h(c.y,k.y),D<=b.y&&b.y<=G?b:D<=d.y&&d.y<=G?d:null):b.x==c.x&&b.y==c.y?b:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d,l,c,g,k,b,v;a.R2Newton=function(b,d){this.evaluator=b;this.constraint=d;if("=="==this.constraint.value||"<"==this.constraint.value||"<="==this.constraint.value||">"==
this.constraint.value||">="==this.constraint.value)this.sign="<"==this.constraint.value||"<="==this.constraint.value?"menor":">"==this.constraint.value||">="==this.constraint.value?"mayor":"igual",this.constraint=this.constraint.equalToMinus(),this.constraint=this.constraint.childs[0];g=new a.R2(0,0);c=new a.R2(0,0);v=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return v.set(this.normal.x,this.normal.y)};a.R2Newton.prototype.gradient=function(a){h=this.evaluator;
g.x=0;g.y=0;k=h.getVariable("x");b=h.getVariable("y");h.setVariable("x",a.x);h.setVariable("y",a.y);this.f0=h.eval(this.constraint);h.setVariable("x",h.getVariable("x")+1E-6);e=h.eval(this.constraint);g.x=(e-this.f0)/1E-6;g.x=isNaN(g.x)?Infinity:g.x;h.setVariable("x",h.getVariable("x")-1E-6);h.setVariable("y",h.getVariable("y")+1E-6);e=h.eval(this.constraint);g.y=(e-this.f0)/1E-6;g.y=isNaN(g.y)?Infinity:g.y;h.setVariable("x",k);h.setVariable("y",b);return g};a.R2Newton.prototype.findZero=function(a,
e,g){h=this.evaluator;c.x=a.x;c.y=a.y;k=h.getVariable("x");b=h.getVariable("y");h.setVariable("x",a.x);h.setVariable("y",a.y);this.f0=h.eval(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return c;h.setVariable("x",k);h.setVariable("y",b);for(var p=0;16>p;p++)if(d=c.x,l=c.y,this.normal=this.gradient(c),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),c.x=d+this.normal.x,c.y=l+this.normal.y,this.normal.norm()<e)return 0===this.normal.x&&0===
this.normal.y&&(this.normal.x=c.x-a.x,this.normal.y=c.y-a.y),c;return g?c:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,e){this.x=a;this.y=e};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 h=Math.floor,e=Math.round,d,l,c,g,k,b,v,u,n,r,p,x,f;a.Control=function(b,d){this.parent=b;this.evaluator=b.evaluator;var c=this.parser=b.evaluator.parser;this.id="graphic"!==d.type?"C":"G";this.gui=this.type="";this.region="south";this.y=this.x=0;this.w="video"!==d.type?100:350;this.h="video"!==d.type?23:120;"graphic"!==d.type&&"audio"!==d.type&&"video"!==d.type?"text"!==d.type?this.expresion=
c.parse("(0,0,100,23)"):(this.expresion=c.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=c.parse("(0,0)");this.fixed=2!=this.parent.version?!1:!0;this.visible=!0;this.color=new a.Color(4>this.parent.version?"000000":"222222");this.colorInt=new a.Color("graphic"!==d.type?"f0f8ff":"cc0022");this.underlined=this.italics=this.bold="";this.font_size=4>this.parent.version?-1:c.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";this.drawif=c.parse("1");this.activeif=
c.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=c.parse("0");this.decimals=c.parse("2");this.min=c.parse("-Infinity");this.max=c.parse("Infinity");this.incr=c.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var f in d)d.hasOwnProperty(f)&&(this[f]=d[f]);"video"!==this.type&&"audio"!==this.type||"interior"===this.region||(this.region="interior");void 0==this.name&&(this.name=
2==this.parent.version?this.id:"_nada_");this.name="_._"==this.name||"_nada_"==this.name||"_void_"==this.name?"":this.name;c=this.evaluator.eval(this.expresion);this.x=e(c[0][0]);this.y=e(c[0][1]);4==c[0].length&&(this.w=e(c[0][2]),this.h=e(c[0][3]));this.actionExec=b.lessonParser.parseAction(this)};a.Control.prototype.init=function(){};a.Control.prototype.update=function(){};a.Control.prototype.draw=function(){};a.Control.prototype.getContainer=function(){var a=this.parent.spaces,b;if("interior"===
this.region)for(var c=0,d=a.length;c<d;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.stage.stageSpace.addCtr(this),this.zIndex=this.parent.stage.stageSpace.zIndex,this.parent.stage.stageSpace.numericalControlContainer):
this.parent.externalSpace.container;if(/north|south|east|west/.test(this.region))return this.parent[this.region+"Space"].controls.push(this),this.parent[this.region+"Space"].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)};a.Control.prototype.updatePositionAndSize=function(){c=g=k=b=!1;v=this.evaluator.eval(this.expresion);
u=e(v[0][0]);c=e(this.x)!==u;this.x=u;u=e(v[0][1]);g=e(this.y)!==u;this.y=u;4===v[0].length&&(u=e(v[0][2]),k=e(this.w)!==u,this.w=u,u=e(v[0][3]),b=e(this.h)!==u,this.h=u);if(k||b||c||g)this.init(!0),this.draw()};a.Control.prototype.formatOutputValue=function(a){f=this.parent;n=a+"";r=this.evaluator.eval(this.decimals);p=n.indexOf(".");-1!=p&&(x=n.substring(p+1),x.length>r&&(n=parseFloat(n).toFixed(r)));this.fixed&&(2!==f.version||2===f.version&&!this.exponentialif)&&(n=parseFloat(a).toFixed(r));this.exponentialif&&
0!=parseFloat(n)&&(n=this.fixed&&2!==f.version?parseFloat(n).toExponential(r):parseFloat(n).toExponential(),n=n.toUpperCase().replace("+",""));return n.replace(".",f.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();"init"===this.action&&(this.click=!1);this.actionExec.execute();this.parent.updateControls();"animate"!==this.action&&this.parent.update()};a.Control.prototype.createGradient=function(a,b){this.linearGradient=this.ctx.createLinearGradient(0,
0,0,b);d=b*b;for(var c=0;c<b;c++)l=h(c-35*b/100),this.linearGradient.addColorStop(c/b,"rgba(0,0,0,"+l*l*192/d/255+")")};a.Control.prototype.createCSSGradient=function(a){var b="linear-gradient(";d=a*a;for(var c=0;c<a;c++)l=h(c-35*a/100),b+="rgba(0,0,0,"+l*l*200/d/255+") "+100*c/(a-1)+"%,";b=b.substring(0,b.length-1);return b+")"};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.floor,e=Math.abs,d,l,c,g,k,b,v,u,n,r,p,x,f,q,m,w=/[\w\.\-//]*(\.gif)/gi,y,B,E,F,D,G,H,
K,C,A,I,J,M,z;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);this.ratio=b.ratio;-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 d;this.classContainer="";if(this.imageSrc.trim().match("^_STYLE_")){this.customStyle=!0;this.btnStyle=
[];this.conStyle=[];this.conStyle.textBorder=3;d=this.imageSrc.trim().substring(8).split("|");for(var f,e,g=0,k=d.length;g<k;g++)f=d[g],e=f.match(/rgb/g),f.match("class=")?this.classContainer=" "+f.substring(6):f.match("border=")?(this.btnStyle.push({type:"border-style",value:"solid"}),this.btnStyle.push({type:"border-width",value:f.substring(7).trim()+"px"})):f.match("borderRadius=")?(this.btnStyle.push({type:"border-radius",value:f.substring(13).trim()+"px"}),this.conStyle.push({type:"border-radius",
value:f.substring(13).trim()+"px"})):f.match("borderColor=")?this.btnStyle.push({type:"border-color",value:(e?"":"#")+f.substring(12).trim()}):f.match("overColor=")?this.conStyle.overColor=(e?"":"#")+f.substring(10).trim():f.match("downColor=")?this.conStyle.downColor=(e?"":"#")+f.substring(10).trim():f.match("font=")?this.conStyle.font=f.substring(5).trim().toLowerCase():f.match("inactiveColor=")?this.conStyle.inactiveColor=(e?"":"#")+f.substring(14).trim():f.match("inactiveColorBorder=")?this.conStyle.inactiveColorBorder=
(e?"":"#")+f.substring(20).trim():f.match("shadowTextBlur=")?this.conStyle.shadowTextBlur=parseFloat(f.substring(15).trim()):f.match("shadowTextOffsetX=")?this.conStyle.shadowTextOffsetX=parseFloat(f.substring(18).trim()):f.match("shadowTextOffsetY=")?this.conStyle.shadowTextOffsetY=parseFloat(f.substring(18).trim()):f.match("shadowTextColor=")?this.conStyle.shadowTextColor=(e?"":"#")+f.substring(16).trim():f.match("shadowBoxBlur=")?this.conStyle.shadowBoxBlur=parseFloat(f.substring(14).trim()):f.match("shadowBoxOffsetX=")?
this.conStyle.shadowBoxOffsetX=parseFloat(f.substring(17).trim()):f.match("shadowBoxOffsetY=")?this.conStyle.shadowBoxOffsetY=parseFloat(f.substring(17).trim()):f.match("shadowBoxColor=")?this.conStyle.shadowBoxColor=(e?"":"#")+f.substring(15).trim():f.match("shadowInsetBoxBlur=")?this.conStyle.shadowInsetBoxBlur=parseFloat(f.substring(19).trim()):f.match("shadowInsetBoxOffsetX=")?this.conStyle.shadowInsetBoxOffsetX=parseFloat(f.substring(22).trim()):f.match("shadowInsetBoxOffsetY=")?this.conStyle.shadowInsetBoxOffsetY=
parseFloat(f.substring(22).trim()):f.match("shadowInsetBoxColor=")?this.conStyle.shadowInsetBoxColor=(e?"":"#")+f.substring(20).trim():f.match("textBorder=")&&(this.conStyle.textBorder=parseFloat(f.substring(11).trim()));this.imageSrc="vacio.gif"}this.imageSrc.match("_COLORES_")&&(d=this.imageSrc.split("_"),this.colorInt=new a.Color(d[2]),this.color=new a.Color(d[3]),this.font_size=this.parser.parse(d[5]),this.imageSrc="");"["==this.imageSrc.charAt(0)?this.imageSrc=this.parser.parse(this.imageSrc.substring(1,
this.imageSrc.length-1)):this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");d=this.evaluator.eval(this.imageSrc).toString().trim();""!=d&&(f=d.substr(0,d.lastIndexOf(".")),e=d.substr(d.lastIndexOf(".")),d.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(d),f&&(this.imageOver=this.parent.getImage(f+
"_over"+e),this.imageDown=this.parent.getImage(f+"_down"+e))));this.container=document.createElement("div");this.container.setAttribute("class","DescartesButtonContainer"+this.classContainer);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.btn=document.createElement("canvas");this.btn.width=this.w*this.ratio;this.btn.height=this.h*this.ratio;this.btn.setAttribute("style",
"position:absolute; left:0; top:0; width:"+this.w+"px; height:"+this.h+"px; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box;");this.ctx=this.btn.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.container.appendChild(this.btn);this.addControlContainer(this.container);this.addEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=function(b){d=this.evaluator;y=this.container;l=this.btn;c=this.ctx;g=d.eval(this.expresion);this.x=g[0][0];this.y=
g[0][1];4==g[0].length&&(this.w=parseInt(g[0][2]),this.h=parseInt(g[0][3]));l.width=this.w*this.ratio;l.height=this.h*this.ratio;l.setAttribute("style","position:absolute; left:0; top:0; width:"+this.w+"px; height:"+this.h+"px; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box;");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;");if(this.btnStyle)for(var f=0,e=this.btnStyle.length;f<
e;f++)l.style[this.btnStyle[f].type]=this.btnStyle[f].value;if(this.conStyle){f=0;for(e=this.conStyle.length;f<e;f++)y.style[this.conStyle[f].type]=this.conStyle[f].value;if(this.conStyle.shadowBoxColor){var f=this.conStyle.shadowBoxOffsetX||0,e=this.conStyle.shadowBoxOffsetY||2,k=this.conStyle.shadowBoxBlur||2;y.style.boxShadow=f+"px "+e+"px "+k+"px 1px "+this.conStyle.shadowBoxColor}this.conStyle.shadowInsetBoxColor&&(f=this.conStyle.shadowInsetBoxOffsetX||0,e=this.conStyle.shadowInsetBoxOffsetY||
-2,k=this.conStyle.shadowInsetBoxBlur||1,l.style.boxShadow=f+"px "+e+"px "+k+"px 1px "+this.conStyle.shadowInsetBoxColor+" inset");this.conStyle.shadowTextColor&&(c.shadowBlur=this.conStyle.shadowTextBlur||1,c.shadowOffsetX=this.conStyle.shadowTextOffsetX||0,c.shadowOffsetY=this.conStyle.shadowTextOffsetY||2,c.shadowColor=this.conStyle.shadowTextColor)}this.fontSizeNotSet&&(this.font_size=d.parser.parse(a.getFieldFontSize(this.h)+""));this.fs_evaluated=d.eval(this.font_size);this.createGradient(this.w,
this.h);y.style.display=0<d.eval(this.drawif)?"block":"none";c.textAlign="center";c.textBaseline="middle";c.lineJoin="round";c.font=this.italics+" "+this.bold+" "+this.fs_evaluated+"px "+a.sansserif_font;this.customStyle&&("serif"==this.conStyle.font?c.font=this.italics+" "+this.bold+" "+this.fs_evaluated+"px "+a.serif_font:"monospace"==this.conStyle.font&&(c.font=this.italics+" "+this.bold+" "+this.fs_evaluated+"px "+a.monospace_font));this.draw(b)};a.Button.prototype.update=function(){d=this.evaluator;
y=this.container;l=this.btn;this.activeIfValue=0<d.eval(this.activeif);(this.drawIfValue=0<d.eval(this.drawif))?(y.style.display="block",this.draw()):(y.style.display="none",this.buttonClick=!1);y.style.cursor=this.activeIfValue?"pointer":"not-allowed";l.style.cursor=this.activeIfValue?"pointer":"not-allowed";y.setAttribute("data-active",this.activeIfValue?"true":"false");this.updatePositionAndSize()};a.Button.prototype.draw=function(e){y=this.container;d=this.evaluator;l=this.btn;c=this.ctx;b=d.eval(this.name);
v=this.evaluator.eval(this.imageSrc).toString().trim();if(!e&&(B=this.over===this.oldOver,E=this.buttonClick===this.oldButtonClick,F=this.activeIfValue===this.oldActiveIfValue,D=this.drawIfValue===this.oldDrawIfValue,G=b===this.oldName,H=v===this.oldImageSrc,K=this.colorInt.getColor()===this.oldBackColor,this.oldOver=this.over,this.oldButtonClick=this.buttonClick,this.oldActiveIfValue=this.activeIfValue,this.oldDrawIfValue=this.drawIfValue,this.oldName=b,this.oldImageSrc=v,this.oldBackColor=this.colorInt.getColor(),
B&&E&&F&&D&&G&&H&&K))return;c.save();c.setTransform(this.ratio,0,0,this.ratio,0,0);k=this.fs_evaluated;y.setAttribute("data-name",b);v?(u="vacio.gif"===v?this.emptyImage:this.parent.getImage(v),C=v.substr(0,v.lastIndexOf(".")),A=v.substr(v.lastIndexOf(".")),I=C+"_over"+A,J=C+"_down"+A,M="vacio.gif"===v?this.emptyImage:this.parent.getImage(I),z="vacio.gif"===v?this.emptyImage:this.parent.getImage(J)):z=M=u=this.emptyImage;c.clearRect(0,0,this.w,this.h);r=n=0;this.buttonClick&&(r=n=1);q=h(this.w/2+
n)-.5;m=h(this.h/2+r)-.5;u&&(x=parseInt((this.w-u.width)/2)+n,f=parseInt((this.h-u.height)/2)+r);u&&u.ready?u!==this.emptyImage&&u.complete?v.match(w)?(this.btn.style.backgroundRepeat="no-repeat",this.btn.style.backgroundImage="url('"+v+"')",this.btn.style.backgroundPosition=x+"px "+f+"px"):c.drawImage(u,x,f):this.emptyImage&&this.customStyle&&(y.style.backgroundColor=this.colorInt.getColor()):(y.style.backgroundColor=this.colorInt.getColor(),this.buttonClick||(a.drawLine(c,this.w-1,0,this.w-1,this.h,
"rgba(0,0,0,0.5)"),a.drawLine(c,0,0,0,this.h,"rgba(0,0,0,0.09)"),a.drawLine(c,1,0,1,this.h,"rgba(0,0,0,0.03)")),c.fillStyle=this.linearGradient,c.fillRect(0,0,this.w,this.h));this.activeIfValue&&(M!==this.emptyImage&&this.over&&M.ready&&M.complete?I.match(w)?(this.btn.style.backgroundImage="url('"+I+"')",this.btn.style.backgroundPosition=x+"px "+f+"px"):c.drawImage(M,x,f):this.customStyle&&this.conStyle.overColor&&this.over&&(y.style.backgroundColor=this.conStyle.overColor));this.activeIfValue?z!==
this.emptyImage&&this.buttonClick&&z.ready&&z.complete?J.match(w)?(this.btn.style.backgroundImage="url('"+J+"')",this.btn.style.backgroundPosition=x+"px "+f+"px"):c.drawImage(z,x,f):this.customStyle&&this.conStyle.downColor&&this.buttonClick&&(y.style.backgroundColor=this.conStyle.downColor):this.buttonClick&&!u&&(c.fillStyle="rgba(0,0,0,0.09)",c.fillRect(0,0,this.w,this.h));c.fillStyle=this.color.getColor();this.customStyle&&this.conStyle.shadowTextColor&&0<this.conStyle.textBorder&&(c.lineWidth=
this.conStyle.textBorder,c.strokeStyle=this.conStyle.shadowTextColor,c.strokeText(b,q,m));!this.conStyle&&this.drawTextBorder()&&(c.lineWidth=parseInt(k/6),c.strokeStyle=this.colorInt.getColor(),c.strokeText(b,q,m));c.fillText(b,q,m);this.underlined&&(p=c.measureText(b).width,c.strokeStyle=this.color.getColor(),c.lineWidth=h(k/10)||2,c.lineCap="round",c.beginPath(),c.moveTo(parseInt((this.w-p)/2)+n,m+h(k/2)+h(k/5)-1.5),c.lineTo(parseInt((this.w+p)/2)+n,m+h(k/2)+h(k/5)-1.5),c.stroke());this.activeIfValue||
(this.customStyle&&this.conStyle.inactiveColor?y.style.backgroundColor=this.conStyle.inactiveColor:(c.fillStyle="rgba(240,240,240,0.6)",c.fillRect(0,0,this.w,this.h)));c.restore();this._image_pos_x=x;this._image_pos_y=f};a.Button.prototype.drawTextBorder=function(){this.colorInt.getColor();this.color.getColor();return!(.5>(e(this.colorInt.r-this.color.r)+e(this.colorInt.g-this.color.g)+e(this.colorInt.b-this.color.b))/255)};a.Button.prototype.buttonPressed=function(){this.updateAndExecAction()};a.Button.prototype.addEvents=
function(){function b(c,d,g){a.clearTimeout(e);f.buttonClick&&f.drawIfValue&&f.activeIfValue&&(d.call(f),c=g?c:100,e=a.setTimeout(function(){b(c,d,!1)},c))}function d(e){this.focus();e.preventDefault();e.stopPropagation();document.activeElement!=document.body&&document.activeElement.blur();f.whichBtn=a.whichBtn(e);"L"==f.whichBtn&&f.activeIfValue&&(f.buttonClick=!0,f.draw(),"calculate"==f.action&&(f.evaluator.setVariable(f.id,f.evaluator.eval(f.valueExpr)),b(1E3,f.buttonPressed,!0)),f.btn.removeEventListener("touchend",
c),f.btn.addEventListener("touchend",c),f.btn.removeEventListener("mouseup",c),f.btn.addEventListener("mouseup",c))}function c(a){this.focus();a.preventDefault();a.stopPropagation();if(f.activeIfValue||f.buttonClick)f.buttonClick=!1,f.draw(),"calculate"!=f.action&&(f.evaluator.setVariable(f.id,f.evaluator.eval(f.valueExpr)),f.buttonPressed()),f.btn.removeEventListener("touchend",c),f.btn.removeEventListener("mouseup",c);f.parent.update()}var f=this,e;f.btn.oncontextmenu=function(){return!1};this.over=
this.buttonClick=!1;this.btn.addEventListener("touchstart",d);this.btn.addEventListener("mousedown",d);this.btn.addEventListener("mouseover",function(a){a.preventDefault();a.stopPropagation();f.over=!0;f.draw()});this.btn.addEventListener("mouseout",function(a){a.preventDefault();a.stopPropagation();f.over=!1;f.buttonClick=!1;f.draw()});document.addEventListener("visibilitychange",function(a){f.buttonClick=!1})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d,l,
c,g,k,b,v,u,n,r,p,x,f,q,m,w;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.container=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.container.appendChild(this.label);this.container.appendChild(this.field);this.container.appendChild(this.canvas);this.container.appendChild(this.divUp);this.container.appendChild(this.divDown);this.addControlContainer(this.container);w=this.evaluator.parser.parse("1");this.originalIncr=this.incr;if(0>this.evaluator.eval(this.decimals)||0==this.evaluator.eval(this.incr)){var d=this.evaluator.eval(this.incr);
0<d?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(d).toString()):this.incr=w}this.addEvents();this.init()};a.extend(a.Spinner,a.Control);a.Spinner.prototype.init=function(){h=this.evaluator;var b=h.eval(this.name).toString();this.label.innerHTML=b;this.value=this.validateValue(h.eval(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var d=2!==this.parent.version?"__":"_____",f=a.getTextWidth(c+"_",
this.fieldFontSize+"px Arial"),e=2+parseInt(this.h/2),g=parseInt(this.w/2-e/2),d=a.getTextWidth(b+d,this.fieldFontSize+"px Arial");this.visible||(g=this.w-e,f=0);g<d&&(g=d);""==b&&(g=0);this.w-g-e<f&&(g=this.w-e-f);0>g&&(g=0);b=this.w-(g+e);this.container.setAttribute("class","DescartesSpinnerContainer");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.container.setAttribute("id",this.id);this.canvas.setAttribute("width",
e+"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.ctx.imageSmoothingEnabled=!1;this.divUp.setAttribute("class","up");this.divUp.setAttribute("style","opacity:0;cursor:pointer;position:absolute;width:"+e+"px;height:"+this.h/2+"px;left:"+g+"px;top:0;");this.divDown.setAttribute("class","down");this.divDown.setAttribute("style","opacity:0;cursor:pointer;position:absolute;width:"+
e+"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: "+(e+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;");h.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h)};a.Spinner.prototype.update=function(){h=this.evaluator;this.label.innerHTML=h.eval(this.name).toString();0>h.eval(this.decimals)?(e=h.eval(this.incr),0<e?this.originalIncr=this.incr=h.parser.parse(parseInt(e).toString()):this.incr=w):this.incr=0!==h.eval(this.originalIncr)?
this.originalIncr:w;this.activeIfValue=0<h.eval(this.activeif);this.drawIfValue=0<h.eval(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.container.style.display="block",this.draw()):(this.click=!1,this.container.style.display="none");this.updatePositionAndSize();this.parent.animation.playing&&document.activeElement==this.field||(d=this.field.value,l=this.value,this.value=this.validateValue(h.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),this.value==
l&&this.field.value!=d&&(this.value=this.validateValue(d),this.field.value=this.formatOutputValue(this.value)),h.setVariable(this.id,this.value))};a.Spinner.prototype.draw=function(){c=this.ctx;g=this.canvas.width;k=this.canvas.height;c.fillStyle="#f0f8ff";c.fillRect(0,0,g,k);c.fillStyle=this.linearGradient;c.fillRect(0,0,g,k);this.up?(b="gray",v="#f0f8ff"):(b="#f0f8ff",v="gray");a.drawLine(c,0,0,g,0,b);a.drawLine(c,0,0,0,k/2,b);a.drawLine(c,0,k/2,g,k/2,v);this.down?(b="gray",v="#f0f8ff"):(b="#f0f8ff",
v="gray");a.drawLine(c,0,k/2+1,g,k/2+1,b);a.drawLine(c,0,k/2+1,0,k,b);a.drawLine(c,0,k-1,g,k-1,v);u=[parseInt(g/2+1),parseInt(g/5+1),parseInt(g-g/5+1)];n=[parseInt(k/8+1),parseInt(k/8+1+k/4),parseInt(k/8+1+k/4)];c.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";c.beginPath();c.moveTo(u[0],n[0]);c.lineTo(u[1],n[1]);c.lineTo(u[2],n[2]);c.fill();n=[parseInt(k-k/8),parseInt(k-k/8-k/4),parseInt(k-k/8-k/4)];c.fillStyle=this.activeIfValue?"#d00018":"#aa8888";c.beginPath();c.moveTo(u[0],n[0]);c.lineTo(u[1],
n[1]);c.lineTo(u[2],n[2]);c.fill();c.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&c.fillRect(0,0,g,k/2);this.down&&c.fillRect(0,k/2,g,k)};a.Spinner.prototype.validateValue=function(a){h=this.evaluator;isNaN(parseFloat(a))||a.toString().match("e")&&(a=parseFloat(a).toFixed(20));a=void 0!=a?a.toString():"0";a=a.replace(this.parent.decimal_symbol,".");r=a==parseFloat(a)?parseFloat(a):parseFloat(h.eval(h.parser.parse(a)));isNaN(r)&&(r=0);f=h.eval(this.min);q=h.eval(this.max);""===f&&(f=-Infinity);""===
q&&(q=Infinity);r<f&&(r=f);r>q&&(r=q);this.discrete&&(p=h.eval(this.incr),r=0==p?0:p*Math.round(r/p));x=h.eval(this.decimals);0>=x&&(x=0);return r=parseFloat(parseFloat(r).toFixed(x))};a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.eval(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-this.evaluator.eval(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.addEvents=function(){function b(c,d,f){a.clearTimeout(h);if(g.up||g.down)d.call(g),c=f?c:30,h=a.setTimeout(function(){b(c,d)},c)}function c(d){d.preventDefault();g.whichBtn=a.whichBtn(d);"L"==g.whichBtn&&g.activeIfValue&&(g.up=!0,b(k,g.increase,!0),g.draw())}function d(c){c.preventDefault();g.whichBtn=a.whichBtn(c);"L"==g.whichBtn&&g.activeIfValue&&(g.down=
!0,b(k,g.decrease,!0),g.draw())}function f(b){g.up=!1;a.clearTimeout(h);g.draw()}function e(b){g.down=!1;a.clearTimeout(h);g.draw()}m=a.hasTouchSupport;var g=this,k=m?500:200,h;g.divUp.oncontextmenu=g.divDown.oncontextmenu=g.field.oncontextmenu=g.label.oncontextmenu=function(){return!1};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&&g.changeValue(g.field.value)});this.divUp.addEventListener("touchstart",c);this.divUp.addEventListener("mousedown",c);this.divDown.addEventListener("touchstart",d);this.divDown.addEventListener("mousedown",d);this.divUp.addEventListener("mouseout",function(b){g.up=!1;a.clearTimeout(h);g.draw();b.preventDefault()});this.divDown.addEventListener("mouseout",function(b){g.down=!1;a.clearTimeout(h);g.draw();b.preventDefault()});this.divUp.addEventListener("touchend",f);window.addEventListener("touchend",
f);this.divUp.addEventListener("mouseup",f);window.addEventListener("mouseup",f);this.divDown.addEventListener("touchend",e);window.addEventListener("touchend",e);this.divDown.addEventListener("mouseup",e);window.addEventListener("mouseup",e);document.addEventListener("visibilitychange",function(b){g.up=!1;g.down=!1;a.clearTimeout(h);g.draw()});g.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,
e,d,l,c,g;a.TextField=function(c,b){a.Control.call(this,c,b);"["===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.trim()+"'");void 0===this.valueExprString&&(this.valueExprString=this.onlyText?"0":"");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;this.regExpDecimalSymbol=new RegExp("\\"+this.parent.decimal_symbol,"g");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.addEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){h=this.evaluator;var c=h.eval(this.name).toString();this.label.innerHTML=c;this.value=this.validateValue(h.eval(this.valueExpr));var b=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var d=a.getTextWidth(b+"_",this.fieldFontSize+"px Arial"),e=parseInt(this.w/2),g=a.getTextWidth(c,this.fieldFontSize+"px Arial");this.visible||(e=this.w,d=0);e<g&&(e=g);""==c&&(e=0);this.w-
e<d&&(e=this.w-d);0>e&&(e=0);c=this.w-e;this.containerControl.setAttribute("class","DescartesTextFieldContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"TextField");this.field.setAttribute("class","DescartesTextFieldField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+c+"px; height : "+
this.h+"px; left: "+e+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=b;this.label.setAttribute("class","DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+e+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.evaluate&&(this.ok=this.evaluateAnswer());this.evaluator.setVariable(this.id,this.value);this.evaluator.setVariable(this.id+".ok",this.ok);this.oldValue=this.value;this.update()};a.TextField.prototype.update=
function(){h=this.evaluator;this.label.innerHTML=h.eval(this.name).toString();this.activeIfValue=0<h.eval(this.activeif);this.drawIfValue=0<h.eval(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||(e=this.field.value,d=this.value,this.value=this.validateValue(h.getVariable(this.id)),this.field.value=this.formatOutputValue(this.value),
this.value===d&&this.field.value!=e&&(this.value=this.validateValue(e),this.field.value=this.formatOutputValue(this.value)),h.setVariable(this.id,this.value))};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";h=this.evaluator;a=a.toString().replace(this.regExpDecimalSymbol,".","g");l=a==parseFloat(a)?parseFloat(a):parseFloat(h.eval(h.parser.parse(a)));isNaN(l)&&(l=0);c=h.eval(this.min);""==c&&(c=-Infinity);g=h.eval(this.max);""==g&&(g=Infinity);l<c&&(l=c);l>g&&(l=g);this.discrete&&
(a=h.eval(this.incr),l=0==a?0:a*Math.round(l/a));return l=parseFloat(parseFloat(l).toFixed(h.eval(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.eval(this.firstAnswer):""};a.TextField.prototype.addEvents=function(){var a=this;a.field.oncontextmenu=a.label.oncontextmenu=function(){return!1};a.label.addEventListener("touchstart",function(a){a.preventDefault();return!1});
a.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(b){a.evaluator.eval(a.drawIf)&&a.changeValue(a.field.value,!0)});this.field.addEventListener("keydown",function(b){a.activeIfValue&&13==b.keyCode&&a.changeValue(a.field.value,!0)});a.field.addEventListener("click",function(a){this.select();this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.abs,e,d,l,c,g,k,b,v,u,n;a.Menu=function(b,
c){function g(a){f.options=a.split(",");f.menuOptions=[];f.strValue=[];var b;a=0;for(var c=f.options.length;a<c;a++)b=f.customSplit(f.options[a]),1==b.length?(f.menuOptions.push(b[0]),f.strValue.push(a.toString())):2==b.length&&(f.menuOptions.push(b[0]),""==b[1]?f.strValue.push(a.toString()):f.strValue.push(b[1]));a=0;for(c=f.menuOptions.length;a<c;a++)f.menuOptions[a].match(/^\[/)&&f.menuOptions[a].match(/\]$/)?f.menuOptions[a]=e.parse(f.menuOptions[a].substring(1,f.menuOptions[a].length-1)):f.menuOptions[a]=
e.parse("'"+f.menuOptions[a]+"'");a=0;for(c=f.strValue.length;a<c;a++)f.strValue[a].match(/^\[/)&&f.strValue[a].match(/\]$/)?f.strValue[a]=e.parse(f.strValue[a].substring(1,f.strValue[a].length-1)):f.strValue[a]=e.parse(f.strValue[a]);for(;f.select.firstChild;)f.select.removeChild(f.select.firstChild);a=0;for(c=f.menuOptions.length;a<c;a++)b=document.createElement("option"),b.innerHTML=d.eval(f.menuOptions[a]),f.select.appendChild(b);return 0}this.options="";a.Control.call(this,b,c);e=this.parser;
d=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+"'");var f=this;this.evaluator.setFunction(this.id+".setOptions",g);this.containerControl=
document.createElement("div");this.label=document.createElement("label");this.select=document.createElement("select");this.field=document.createElement("input");g(this.options);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.addEvents();this.init()};a.extend(a.Menu,a.Control);a.Menu.prototype.init=function(b){d=this.evaluator;var c=d.eval(this.name).toString();
this.label.innerHTML=c;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var e=0,f=0;this.value=b?this.value:d.eval(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var g=0,k=this.menuOptions.length;g<k;g++)b=a.getTextWidth(d.eval(this.menuOptions[g]).toString(),this.fieldFontSize+"px Arial"),b>e&&(e=b,f=g);e+=25;b=a.getTextWidth(this.formatOutputValue(d.eval(this.strValue[f])),this.fieldFontSize+"px Arial")+7;f=a.getTextWidth(c,this.fieldFontSize+"px Arial")+10;
""==c&&(f=0);this.visible||(b=0);for(c=this.w-b-f;c<e&&0<f;)f--,c++;for(;c<e&&0<b;)b--,c++;for(;f+c+b+1<this.w;)c++,b++;e=f;g=e+c;b=this.w-g;k=this.formatOutputValue(d.eval(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:"+f+"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=k;this.field.setAttribute("class","DescartesMenuField");this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width: "+b+"px; height: "+this.h+"px; left:"+g+"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: "+c+"px; height: "+this.h+"px; left: "+e+"px;");this.select.setAttribute("tabindex",this.tabindex);this.select.selectedIndex=this.indexValue;d.setVariable(this.id,parseFloat(k.replace(this.parent.decimal_symbol,".")));this.update()};a.Menu.prototype.update=function(){d=this.evaluator;this.activeIfValue=0<d.eval(this.activeif);this.drawIfValue=0<d.eval(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");if(!this.parent.animation.playing||document.activeElement!=this.select){this.label.innerHTML=d.eval(this.name).toString();for(var a=0,b=this.menuOptions.length;a<b;a++)this.select.options[a].innerHTML=d.eval(this.menuOptions[a]);this.value=d.getVariable(this.id);isNaN(this.value)&&(this.value=0);this.field.value=
this.formatOutputValue(this.value);d.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);this.updatePositionAndSize()};a.Menu.prototype.customSplit=function(a){k=!1;b="";v=0;for(u=-1;v<a.length;){n=a.charAt(v);a.charAt(v-1);if("["===n&&-1===u){if(k||""!=b)b+="\u00a6";u++}else"["===n?u++:"]"===n&&0===u?(k=!0,u--):"]"==a.charAt(v)&&(u=0>u?u:u-1);b+=a.charAt(v);
v++}return b.split("\u00a6")};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));l=-1;c=Infinity;for(var b=0,d=this.strValue.length;b<d;b++)g=h(a-parseFloat(this.evaluator.eval(this.strValue[b]))),g<=c&&(c=g,l=b);return l};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Menu.prototype.addEvents=function(){var a=this;a.select.oncontextmenu=a.label.oncontextmenu=
a.field.oncontextmenu=function(){return!1};a.label.addEventListener("touchstart",function(a){a.preventDefault();return!1});a.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(b){a.value=a.evaluator.eval(a.strValue[this.selectedIndex]);a.field.value=a.formatOutputValue(a.value);a.evaluator.setVariable(a.id,a.field.value);a.changeValue();b.preventDefault()});this.field.addEventListener("keydown",function(b){13==b.keyCode&&(a.indexValue=
a.getIndex(a.field.value),a.value=a.evaluator.eval(a.strValue[a.indexValue]),a.field.value=a.formatOutputValue(a.indexValue),a.select.selectedIndex=a.indexValue,a.changeValue())});a.field.addEventListener("click",function(a){this.focus()})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.floor,e,d,l,c,g,k,b,v,u,n,r,p,x,f,q,m,w,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.container=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.scrollHandler=document.createElement("div");this.label=document.createElement("label");this.container.appendChild(this.canvas);this.container.appendChild(this.label);this.container.appendChild(this.divUp);
this.container.appendChild(this.divDown);this.container.appendChild(this.field);this.container.appendChild(this.scrollHandler);this.addControlContainer(this.container);this.addEvents();this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){e=this.evaluator;0==e.eval(this.decimals)?this.incr=1:this.incr=(e.eval(this.max)-e.eval(this.min))/100;this.value=this.validateValue(e.eval(this.valueExpr));l=this.formatOutputValue(this.value);c=this.evaluator.eval(this.expresion);
this.x=c[0][0];this.y=c[0][1];4==c[0].length&&(this.w=c[0][2],this.h=c[0][3]);this.orientation=this.w>=this.h?"h":"v";this.initScroll(l);this.changeScrollPositionFromValue();this.prePos=this.pos;e.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(b){d=this;e=d.evaluator;y=e.eval(d.name).toString();d.label.innerHTML=y;var c="v"===d.orientation?parseInt(19+5*(d.h-100)/100):d.h;d.fieldFontSize="v"===d.orientation?c-parseInt(d.h/20)-1:2!==d.parent.version?a.getFieldFontSize(c):
10;var f=a.getTextWidth(b+"_",d.fieldFontSize+"px Arial"),g=d.parent.getSpaceById(d.spaceID).h;d.labelHeight=""==y?0:c;d.fieldHeight=""==d.visible?0:c;if("v"===d.orientation)d.canvasWidth=d.w,d.canvasHeight=d.h-d.labelHeight-d.fieldHeight,18<=d.canvasHeight+d.y-g&&(d.canvasHeight=g),f=d.fieldHeight,c=f+d.canvasHeight,d.canvasX=0,d.canvasY=d.fieldHeight,d.labelWidth=d.w,d.labelY=c,d.upWidth=d.downW=d.w,d.upHeight=d.downH=15,d.upX=0,d.upY=d.fieldHeight,d.downX=0,d.downY=c-d.downH,d.fieldWidth=d.w,d.fieldX=
0,d.scrollHandlerW=d.w,d.scrollHandlerH=parseInt((d.canvasHeight-d.upHeight-d.downH-d.labelHeight-d.fieldHeight)/10),d.scrollHandlerH=15>d.scrollHandlerH?15:d.scrollHandlerH,d.limInf=c-d.downH-d.scrollHandlerH,d.limSup=f+d.downH;else{c=a.getTextWidth(y,d.fieldFontSize+"px Arial")+10;d.labelWidth=c;d.fieldWidth=f;""==y&&(d.labelWidth=0);d.visible||(d.fieldWidth=0);for(c=d.w-d.fieldWidth-d.labelWidth;58>c&&0<d.labelWidth;)d.labelWidth--,c++;for(;58>c&&0<d.fieldWidth;)d.fieldWidth--,c++;f=d.labelWidth;
g=f+c;d.fieldWidth=d.w-g;d.canvasWidth=c;d.canvasHeight=d.h;d.canvasX=d.labelWidth;d.canvasY=0;d.fieldX=d.canvasWidth+d.labelWidth;d.labelHeight=d.h;d.labelY=0;d.upWidth=d.downW=15;d.upHeight=d.downH=d.h;d.upX=g-d.downW;d.upY=0;d.downX=d.labelWidth;d.downY=0;d.scrollHandlerW=parseInt((d.canvasWidth-d.upWidth-d.downW)/10);d.scrollHandlerW=15>d.scrollHandlerW?15:d.scrollHandlerW;d.scrollHandlerH=d.h;d.limInf=f+d.downW;d.limSup=f+d.canvasWidth-d.downW-d.scrollHandlerW}d.container.setAttribute("class",
"DescartesScrollbarContainer");d.container.setAttribute("id",d.id);d.container.setAttribute("style","width: "+d.w+"px; height: "+d.h+"px; left: "+d.x+"px; top: "+d.y+"px; z-index: "+d.zIndex+";");d.canvas.setAttribute("width",d.w+"px");d.canvas.setAttribute("height",d.h+"px");d.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");d.ctx=d.canvas.getContext("2d");d.ctx.imageSmoothingEnabled=!1;d.divUp.setAttribute("class","DescartesCatcher up");d.divUp.setAttribute("style","width : "+
d.upWidth+"px; height : "+d.upHeight+"px; left: "+d.upX+"px; top: "+d.upY+"px;");d.divDown.setAttribute("class","DescartesCatcher down");d.divDown.setAttribute("style","width : "+d.downW+"px; height : "+d.downH+"px; left: "+d.downX+"px; top: "+d.downY+"px;");d.scrollHandler.setAttribute("class","DescartesCatcher manipulator");d.scrollHandler.setAttribute("style","width : "+d.scrollHandlerW+"px; height : "+d.scrollHandlerH+"px;");d.scrollHandler.style.top=("v"===d.orientation?d.limInf:0)+"px";d.scrollHandler.style.left=
("v"===d.orientation?0:d.limInf)+"px";d.field.setAttribute("type","text");d.field.setAttribute("id",d.id+"scrollbar");d.field.setAttribute("class","DescartesScrollbarField");d.field.setAttribute("style","font-size: "+d.fieldFontSize+"px; width : "+d.fieldWidth+"px; height : "+d.fieldHeight+"px; left: "+d.fieldX+"px; top: 0px;");d.field.value=b;0===d.fieldHeight&&(d.field.style.display="none");d.label.setAttribute("class","DescartesScrollbarLabel");d.label.setAttribute("style","font-size:"+d.fieldFontSize+
"px; width: "+d.labelWidth+"px; height: "+d.labelHeight+"px; line-height: "+d.labelHeight+"px; left: 0px; top:"+d.labelY+"px;")};a.Scrollbar.prototype.update=function(){e=this.evaluator;this.label.innerHTML=e.eval(this.name).toString();0==e.eval(this.decimals)?this.incr=1:this.incr=(e.eval(this.max)-e.eval(this.min))/100;this.activeIfValue=0<e.eval(this.activeif);this.drawIfValue=0<e.eval(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.container.style.display="block",this.draw()):
this.container.style.display="none";this.updatePositionAndSize();var a=this.validateValue(e.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);e.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){d=this;g=d.ctx;b=h(this.w);k=h(this.h);g.fillStyle="#e0e4e8";g.fillRect(0,0,b,k);g.strokeStyle="#7a8a99";d.down&&
(g.fillStyle="#ccdcec",g.fillRect(d.downX+.5,d.downY+.5,d.downW,d.downH-1));g.strokeRect(d.downX+.5,d.downY+.5,d.downW,d.downH-1);d.up&&(g.fillStyle="#ccdcec",g.fillRect(d.upX+.5,d.upY-.5,d.upWidth,d.upHeight+1));g.strokeRect(d.upX+.5,d.upY-.5,d.upWidth,d.upHeight+1);v=4;g.fillStyle="black";g.beginPath();"h"===d.orientation?(g.moveTo(d.downX+v,d.downH/2),g.lineTo(d.downX+d.downW-v,v),g.lineTo(d.downX+d.downW-v,d.downH-v),g.moveTo(d.upX+d.upWidth-v,d.downH/2),g.lineTo(d.upX+v,v),g.lineTo(d.upX+v,d.downH-
v),g.fill(),d.activeIfValue&&(u=h(d.pos),g.fillStyle="#ccdcec",g.fillRect(u+.5,0,h(d.scrollHandlerW),k),g.strokeStyle="#6382bf",g.strokeRect(u+.5,0,h(d.scrollHandlerW),k),n=h(d.scrollHandlerW/2),g.beginPath(),g.moveTo(u+n+.5-2,3),g.lineTo(u+n+.5-2,k-3),g.moveTo(u+n+.5,3),g.lineTo(u+n+.5,k-3),g.moveTo(u+n+.5+2,3),g.lineTo(u+n+.5+2,k-3),g.stroke())):(g.moveTo(d.downX+d.downW/2,d.downY+d.downH-v),g.lineTo(d.downX+v,d.downY+v),g.lineTo(d.downX+d.downW-v,d.downY+v),g.moveTo(d.upX+d.upWidth/2,d.upY+v),
g.lineTo(d.upX+v,d.upY+d.upHeight-v),g.lineTo(d.upX+d.upWidth-v,d.upY+d.upHeight-v),g.fill(),d.activeIfValue&&(u=h(d.pos),g.fillStyle="#ccdcec",g.fillRect(0,u+.5,b,h(d.scrollHandlerH)),g.strokeStyle="#6382bf",g.strokeRect(0,u+.5,b,h(d.scrollHandlerH)),n=h(d.scrollHandlerH/2),g.beginPath(),g.moveTo(3,u+n+.5-2),g.lineTo(b-3,u+n+.5-2),g.moveTo(3,u+n+.5),g.lineTo(b-3,u+n+.5),g.moveTo(3,u+n+.5+2),g.lineTo(b-3,u+n+.5+2),g.stroke()));g.strokeRect(.5,.5,b-1,k-1);d.activeIfValue||(g.fillStyle="rgba(240,240,240,"+
160/255+")",g.fillRect(0,0,b,k.h))};a.Scrollbar.prototype.validateValue=function(a){e=this.evaluator;r=a.toString();r=parseFloat(r.replace(this.parent.decimal_symbol,"."));isNaN(r)&&(r=0);this.minimo=e.eval(this.min);r<this.minimo&&(this.value=null,r=this.minimo);this.maximo=e.eval(this.max);r>this.maximo&&(this.value=null,r=this.maximo);p=this.incr;r=0!=p?r*p/p:0;this.fixed&&(r=parseFloat(parseFloat(r).toFixed(e.eval(this.decimals))));return r};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(){v=(this.evaluator.eval(this.max)-this.evaluator.eval(this.min))/10;"h"==this.orientation?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+v):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+v)};a.Scrollbar.prototype.decrease10=function(){v=(this.evaluator.eval(this.max)-this.evaluator.eval(this.min))/10;"h"==this.orientation?
this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-v):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-v)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&(x=this.validateValue(a),x!=this.value&&(this.value=x,this.field.value=this.formatOutputValue(x),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){e=
this.evaluator;f=this.limInf;q=this.limSup;m=e.eval(this.min);w=e.eval(this.max);p=this.incr;x=h((this.pos-f)*(w-m)/(q-f)/p)*p+m;x!=this.value&&(this.value=x,this.field.value=this.formatOutputValue(x),e.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){e=this.evaluator;f=this.limInf;q=this.limSup;m=e.eval(this.min);w=e.eval(this.max);p=this.incr;this.pos=(this.value-m)*(q-f)/
(w-m)+f;"h"==this.orientation?this.scrollHandler.style.left=this.pos+"px":this.scrollHandler.style.top=this.pos+"px"};a.Scrollbar.prototype.addEvents=function(){function b(c,d,f,e){a.clearTimeout(q);(p.up||p.down||p.canvasClick)&&1E-7<Math.abs(p.value-e)&&(d.call(p),c=f?c:30,q=a.setTimeout(function(){b(c,d,!1,e)},c))}function c(d){d.preventDefault();p.whichBtn=a.whichBtn(d);"L"==p.whichBtn&&p.activeIfValue&&(p.clickPos=a.getCursorPosition(d,p.container),p.canvasClick=!0,"h"==p.orientation?p.clickPos.x<
p.prePos?b(350,p.decrease10,!0,p.minimo):b(350,p.increase10,!0,p.maximo):p.clickPos.y<p.prePos?b(350,p.increase10,!0,p.maximo):b(350,p.decrease10,!0,p.minimo))}function d(b){p.canvasClick=!1;a.clearTimeout(q)}function f(b){1==p.canvasClick&&(p.clickPos=a.getCursorPosition(b,p.container),b.preventDefault())}function e(a){p.scrollClick=!1;p.prePos=p.pos;window.removeEventListener("mouseup",e,!1);window.removeEventListener("mousemove",k,!1);a.preventDefault()}function g(a){p.scrollClick=!1;p.prePos=
p.pos;window.removeEventListener("touchend",g,!1);window.removeEventListener("touchmove",k,!1);a.preventDefault()}function k(b){var c=a.getCursorPosition(b,p.container);"h"==p.orientation?(p.pos=p.prePos-(p.initPos.x-c.x),p.pos<p.limInf&&(p.pos=p.limInf),p.pos>p.limSup&&(p.pos=p.limSup),p.scrollHandler.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+p.scrollHandlerW+"px; height : "+p.h+"px; left: "+p.pos+"px; top: 0px;")):(p.pos=p.prePos-
(p.initPos.y-c.y),p.pos>p.limInf&&(p.pos=p.limInf),p.pos<p.limSup&&(p.pos=p.limSup),p.scrollHandler.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+p.w+"px; height : "+p.scrollHandlerH+"px; left: 0px; top: "+p.pos+"px;"));p.changeValueForScrollMovement();b.preventDefault()}function h(c){c.preventDefault();p.whichBtn=a.whichBtn(c);"L"==p.whichBtn&&p.activeIfValue&&(p.up=!0,b(350,p.increase,!0,p.maximo))}function n(c){c.preventDefault();
p.whichBtn=a.whichBtn(c);"L"==p.whichBtn&&p.activeIfValue&&(p.down=!0,b(350,p.decrease,!0,p.minimo))}function m(b){p.down=!1;a.clearTimeout(q);b.preventDefault()}function r(b){p.up=!1;a.clearTimeout(q);p.draw()}function l(b){p.down=!1;a.clearTimeout(q);p.draw()}var p=this,q;p.canvas.oncontextmenu=p.divUp.oncontextmenu=p.divDown.oncontextmenu=p.label.oncontextmenu=p.field.oncontextmenu=p.scrollHandler.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==a.keyCode&&
p.changeValue(p.field.value)});this.canvas.addEventListener("touchstart",c);this.canvas.addEventListener("mousedown",c);this.divDown.addEventListener("mouseout",m);window.addEventListener("touchend",d);window.addEventListener("mouseup",d);this.canvas.addEventListener("touchmove",f);this.canvas.addEventListener("mousemove",f);this.scrollHandler.addEventListener("touchstart",function(b){p.activeIfValue&&(p.scrollClick=!0,p.initPos=a.getCursorPosition(b,p.container),window.addEventListener("touchend",
g),window.addEventListener("touchmove",k),b.preventDefault())});this.scrollHandler.addEventListener("mousedown",function(b){p.activeIfValue&&(p.scrollClick=!0,p.initPos=a.getCursorPosition(b,p.container),window.addEventListener("mouseup",e),window.addEventListener("mousemove",k),b.preventDefault())});this.divUp.addEventListener("touchstart",h);this.divUp.addEventListener("mousedown",h);this.divDown.addEventListener("touchstart",n);this.divDown.addEventListener("mousedown",n);this.divUp.addEventListener("mouseout",
function(b){p.up=!1;a.clearTimeout(q);b.preventDefault()});this.divDown.addEventListener("mouseout",m);window.addEventListener("touchend",r);window.addEventListener("mouseup",r);window.addEventListener("touchend",l);window.addEventListener("mouseup",l)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h;a.Audio=function(d,e){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,d,e);var c=this,g=c.evaluator.eval(c.expresion);4==g[0].length?(c.w=g[0][2],c.h=
g[0][3]):(c.w=200,c.h=28);c.audio=c.parent.getAudio(c.file);c.autoplay&&(c.audio.setAttribute("autoplay","autoplay"),c.audio.play());c.loop&&c.audio.setAttribute("loop","loop");c.controls&&c.audio.setAttribute("controls","controls");c.audio.setAttribute("style","position: absolute; width: "+c.w+"px; left: "+c.x+"px; top: "+c.y+"px; z-index: "+c.zIndex+";");c.addControlContainer(c.audio);c.evaluator.setFunction(c.id+".play",function(){try{c.audio.play()}catch(a){}return 0});c.evaluator.setFunction(c.id+
".pause",function(){try{c.audio.pause()}catch(a){}return 0});c.evaluator.setFunction(c.id+".stop",function(){try{c.audio.pause(),c.audio.currentTime=0}catch(a){}return 0});c.evaluator.setFunction(c.id+".currentTime",function(a){try{c.audio.currentTime=parseFloat(a)}catch(b){}return 0});c.audio.addEventListener("timeupdate",function(a){c.evaluator.setVariable(c.id+".currentTime",c.audio.currentTime)})};a.extend(a.Audio,a.Control);a.Audio.prototype.init=function(){this.audio.style.left=this.x+"px";
this.audio.style.top=this.y+"px";this.update()};var e;a.Audio.prototype.update=function(){h=this.evaluator;(e=0<h.eval(this.drawif))?this.audio.style.display="block":(this.audio.style.display="none",e!==this.oldDrawIf&&this.audio.pause());this.oldDrawIf=e;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h;a.Video=function(d,e){this.controls=!0;this.file="";this.oldDrawIf=0;a.Control.call(this,d,e);var c=this;h=c.evaluator;var g=c.evaluator.eval(c.expresion);
4==g[0].length?(c.w=g[0][2],c.h=g[0][3]):(c.w=null,c.h=null);var g=c.file,k=g.lastIndexOf(".");-1!=k&&(g=c.file.substring(0,k));c.video=document.createElement("video");c.autoplay&&c.video.setAttribute("autoplay","autoplay");c.loop&&c.video.setAttribute("loop","loop");c.controls&&c.video.setAttribute("controls","controls");c.video.setAttribute("poster",g+".png");c.w&&(c.video.setAttribute("width",c.w),c.video.setAttribute("height",c.h));c.video.setAttribute("style","position:absolute; overflow:hidden; left:"+
c.x+"px; top:"+c.y+"px; outline:none; background:rgba(0,0,0,0);");c.video.canPlayType("video/mp4")&&(k=document.createElement("source"),k.setAttribute("src",g+".mp4"),c.video.appendChild(k));c.video.canPlayType("video/ogg")&&(k=document.createElement("source"),k.setAttribute("src",g+".ogg"),k.setAttribute("type","video/ogg"),c.video.appendChild(k),k=document.createElement("source"),k.setAttribute("src",g+".ogv"),k.setAttribute("type","video/ogg"),c.video.appendChild(k));c.video.canPlayType("video/webm")&&
(k=document.createElement("source"),k.setAttribute("src",g+".webm"),k.setAttribute("type","video/webm"),c.video.appendChild(k));c.addControlContainer(c.video);c.evaluator.setFunction(c.id+".play",function(){try{c.video.play()}catch(a){}return 0});c.evaluator.setFunction(c.id+".pause",function(){try{c.video.pause()}catch(a){}return 0});c.evaluator.setFunction(c.id+".stop",function(){try{c.video.pause(),c.video.currentTime=0}catch(a){}return 0});c.evaluator.setFunction(c.id+".currentTime",function(a){try{c.video.currentTime=
parseFloat(a)}catch(d){}return 0});c.video.addEventListener("timeupdate",function(a){c.evaluator.setVariable(c.id+".currentTime",c.video.currentTime)})};a.extend(a.Video,a.Control);a.Video.prototype.init=function(){this.video.style.left=this.x+"px";this.video.style.top=this.y+"px";this.update()};var e;a.Video.prototype.update=function(){h=this.evaluator;(e=0<h.eval(this.drawif))?this.video.style.display="block":(this.video.style.display="none",e!==this.oldDrawIf&&this.video.pause());this.oldDrawIf=
e;this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e;a.TextArea=function(d,e){this.font="Monospaced,PLAIN,12";a.Control.call(this,d,e);this.region="interior";this.tabindex=++this.parent.tabindex;if(this.answer){this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7)));var c=this.parent.lessonParser.parseText(this.answer)}this.containerControl=document.createElement("div");this.textArea=document.createElement("div");
this.textAreaAnswer=document.createElement("div");this.showButton=document.createElement("div");this.activeCover=document.createElement("div");this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);this.containerControl.appendChild(this.activeCover);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=void 0==this.text||"simpleText"==this.text.type?this.rawText||"":this.text.hasFormula?
this.rawText:this.text.toHTML();c&&"simpleText"!=c.type&&(this.answer=this.text.hasFormula?"":c.toHTML());this.evaluator.setVariable(this.id,this.text);this.drawButton();this.addEvents();this.init()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){e=this.answer?28:8;h=this.evaluator;var d;d=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<h.eval(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-e)+"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;' >"+d+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-e)+"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 d=document.createElement("canvas");d.setAttribute("width",20);d.setAttribute("height",16);var e=d.getContext("2d");e.imageSmoothingEnabled=!1;this.canvas=d;this.ctx=e;this.createGradient(20,16);e.lineWidth=1;e.fillStyle="white";e.fillRect(0,0,20,16);e.fillStyle=this.linearGradient;e.fillRect(0,0,20,16);a.drawLine(e,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(e,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(e,
1,0,1,16,"rgba(0,0,0,"+8/255+")");this.imageUnPush=d.toDataURL();e.fillStyle="white";e.fillRect(0,0,20,16);e.fillStyle=this.linearGradient;e.fillRect(0,0,20,16);a.drawLine(e,0,0,0,14,"gray");a.drawLine(e,0,0,19,0,"gray");e.fillStyle="rgba(0, 0, 0,"+24/255+")";e.fillRect(0,0,this.w,this.h);this.imagePush=d.toDataURL()};a.TextArea.prototype.update=function(){h=this.evaluator;this.activeIfValue=0<h.eval(this.activeif);this.drawIfValue=0<h.eval(this.drawif);var a;a=this.text.match(/<span/)?this.rawText:
this.text;h.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.addEvents=function(){function a(c){c.preventDefault();e.showButton.style.backgroundImage="url("+e.imageUnPush+")"}var e=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();e.showAnswer=!e.showAnswer;e.textAreaAnswer.style.display=e.showAnswer?"block":"none";
e.showButton.childNodes[0].childNodes[0].textContent=e.showAnswer?"T":"S";e.showButton.style.backgroundImage="url("+e.imagePush+")"});this.showButton.addEventListener("mouseup",a);this.showButton.addEventListener("mouseout",a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=2*Math.PI,e,d,l,c,g,k,b,v,u,n;a.GraphicControl=function(b,c){d=b.evaluator.parser;this.text=this.spaceID="";this.size=d.parse("4");this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=
function(){this.ready=1};this.imageSrc="";a.Control.call(this,b,c);this.font=a.convertFont(this.font);if(this.constraintExpr){this.constraint=d.parse(this.constraintExpr);"(expr)"==this.constraint.type&&(this.constraint=d.parse(this.constraintExpr.substring(1,this.constraintExpr.length-1)));if("compOperator"==this.constraint.type){var e=this.constraint.childs[0],f=this.constraint.childs[1];"identifier"!=e.type||"y"!=e.value||f.contains("y")?"identifier"!=e.type||"x"!=e.value||f.contains("x")?this.newt=
new a.R2Newton(this.evaluator,this.constraint):(this.constVar="y",this.noConstVar="x",this.evalConst=this.evalConstXoY,this.constraint=f):(this.constVar="x",this.noConstVar="y",this.evalConst=this.evalConstXoY,this.constraint=f)}else this.constraint=null;v=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.addEvents();this.xStr=this.id+".x";this.yStr=this.id+".y";this.activoStr=this.id+".activo";this.activeStr=this.id+".active";""!==this.space.id&&2!==b.version?(this.mxStr=this.space.id+".mouse_x",this.myStr=this.space.id+".mouse_y",this.mclickedStr=this.space.id+".mouse_clicked",this.mclicizquierdoStr=this.space.id+".clic_izquierdo"):(this.mxStr="mouse_x",this.myStr="mouse_y",
this.mclickedStr="mouse_clicked",this.mclicizquierdoStr="clic_izquierdo");this.init()};a.GraphicControl.prototype.init=function(){e=this.evaluator;u=a.hasTouchSupport;var b=e.eval(this.expresion);this.x=b[0][0];this.y=b[0][1];e.setVariable(this.xStr,this.x);e.setVariable(this.yStr,this.y);this.mouseCacher.setAttribute("style","cursor:pointer;background-color:rgba(255, 255, 255, 0);z-index:"+this.zIndex+";");""==this.imageSrc||this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.width=2*e.eval(this.size),
this.height=2*e.eval(this.size),this._w=u&&48>this.width?48:this.width,this._h=u&&48>this.height?48:this.height,this.mouseCacher.style.borderRadius=parseInt(Math.min(this._w,this._h)/2)+"px"):(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,this.height=this.image.height,this._w=Math.max(this.width,32),this._h=Math.max(this.height,32));this.mouseCacher.style.width=this._w+"px";this.mouseCacher.style.height=this._h+"px";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";e.setVariable(this.activoStr,0);e.setVariable(this.activeStr,0);this.setImage=!1;this.update()};a.GraphicControl.prototype.update=function(){e=this.evaluator;this.activeIfValue=0<e.eval(this.activeif);this.drawIfValue=0<e.eval(this.drawif);this.x=e.getVariable(this.xStr);this.y=e.getVariable(this.yStr);l=this.space.getAbsoluteX(this.x);c=this.space.getAbsoluteY(this.y);this.mouseCacher.style.display=
this.activeIfValue?"block":"none";this.mouseCacher.style.left=parseInt(l-this._w/2)+"px";this.mouseCacher.style.top=parseInt(c-this._h/2)+"px";this.constraint&&this.evalConst();this.draw()};a.GraphicControl.prototype.draw=function(){e=this.evaluator;this.drawIfValue&&(k=this.ctx,b=this.space.backgroundCtx,l=parseInt(this.space.getAbsoluteX(this.x))+.5,c=parseInt(this.space.getAbsoluteY(this.y))+.5,""!=this.text&&this.drawText(l,c),this.image.ready?(this.image.complete&&!this.setImage&&k.drawImage(this.image,
parseInt(l-this.image.width/2),parseInt(c-this.image.height/2)),this.trace&&(b.save(),b.translate(l,c),b.scale(parseInt(this.image.width/2),parseInt(this.image.height/2)),b.beginPath(),b.arc(0,0,1,0,h,!1),b.restore(),b.lineWidth=1,b.strokeStyle=this.trace.getColor(),b.stroke())):(k.beginPath(),k.arc(l,c,parseInt(this.width/2),0,h,!1),k.fillStyle=this.colorInt.getColor(),k.fill(),k.lineWidth=1,k.strokeStyle=this.color.getColor(),k.stroke(),this.active&&(k.strokeStyle=this.colorInt.borderColor(),k.beginPath(),
k.arc(l,c,parseInt(this.width/2)-2,0,h,!1),k.stroke()),this.trace&&(b.strokeStyle=this.trace.getColor(),b.beginPath(),b.arc(l,c,parseInt(this.width/2),0,h,!1),b.stroke())))};a.GraphicControl.prototype.evalConst=function(){v.set(this.x,this.y);g=this.newt.findZero(v,1/this.space.scale,!0);this.x=g.x;this.y=g.y;this.evaluator.setVariable(this.xStr,this.x);this.evaluator.setVariable(this.yStr,this.y)};a.GraphicControl.prototype.evalConstXoY=function(){e=this.evaluator;n=e.getVariable(this.constVar);
e.setVariable(this.constVar,this[this.constVar]);this[this.noConstVar]=e.eval(this.constraint);e.setVariable(this.xStr,this.x);e.setVariable(this.yStr,this.y);e.setVariable(this.constVar,n)};a.GraphicControl.prototype.drawText=function(a,b){k=this.ctx;e=this.evaluator;"simpleText"==this.text.type?(k.fillStyle=this.color.getColor(),k.font=this.font,k.textBaseline="alphabetic",k.fillText(this.text.toString(e.eval(this.decimals),this.fixed),parseInt(a+1+this.width/2),parseInt(b-1-this.height/2))):(k.fillStyle=
this.color.getColor(),k.strokeStyle=this.color.getColor(),k.textBaseline="alphabetic",this.text.draw(k,parseInt(a+1+this.width/2),parseInt(b-1-this.height/2),this.decimals,this.fixed,"start",!0,this.color.getColor()))};a.GraphicControl.prototype.getContainer=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.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.activoStr,0);this.evaluator.setVariable(this.activeStr,0);this.evaluator.setVariable(this.mclicizquierdoStr,0)};a.GraphicControl.prototype.addEvents=function(){function b(d){document.body.focus();d.preventDefault();d.stopPropagation();f.evaluator.setVariable(f.mclickedStr,1);f.evaluator.setVariable(f.mclicizquierdoStr,1);if(f.activeIfValue||f.active)f.click=!1,window.removeEventListener("mouseup",b,!1),
window.removeEventListener("mousemove",c,!1),window.removeEventListener("touchend",b,!1),window.removeEventListener("touchmove",c,!1),e=a.getCursorPosition(d,f.container),f.posX=f.prePos.x-(f.posAnte.x-e.x),f.posY=f.prePos.y-(f.posAnte.y-e.y),f.evaluator.setVariable(f.xStr,f.space.getRelativeX(f.posX)),f.evaluator.setVariable(f.yStr,f.space.getRelativeY(f.posY)),f.evaluator.setVariable(f.mxStr,f.space.getRelativeX(e.x)),f.evaluator.setVariable(f.myStr,f.space.getRelativeY(e.y)),f.parent.updateControls(),
f.parent.update(),f.mouseCacher.style.left=f.space.getAbsoluteX(f.x)-f._w/2+"px",f.mouseCacher.style.top=f.space.getAbsoluteY(f.y)-f._h/2+"px";f.parent.deactivateGraphiControls()}function c(b){b.preventDefault();f.evaluator.setVariable(f.mclickedStr,0);f.evaluator.setVariable(f.mclicizquierdoStr,0);e=a.getCursorPosition(b,f.container);f.posX=f.prePos.x-(f.posAnte.x-e.x);f.posY=f.prePos.y-(f.posAnte.y-e.y);f.evaluator.setVariable(f.xStr,f.space.getRelativeX(f.posX));f.evaluator.setVariable(f.yStr,
f.space.getRelativeY(f.posY));f.evaluator.setVariable(f.mxStr,f.space.getRelativeX(e.x));f.evaluator.setVariable(f.myStr,f.space.getRelativeY(e.y));20<Date.now()-d&&(f.parent.updateControls(),f.parent.update(),d=Date.now())}var d=0,f=this;this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=function(){return!1};this.mouseCacher.addEventListener("touchstart",function(d){document.body.focus();d.preventDefault();f.activeIfValue&&(f.parent.deactivateGraphiControls(),f.click=f.active=!0,
f.evaluator.setVariable(f.activoStr,1),f.evaluator.setVariable(f.activeStr,1),f.evaluator.setVariable(f.mclickedStr,0),f.evaluator.setVariable(f.mclicizquierdoStr,0),f.posAnte=a.getCursorPosition(d,f.container),f.prePos={x:f.space.getAbsoluteX(f.x),y:f.space.getAbsoluteY(f.y)},f.evaluator.setVariable(f.mxStr,f.space.getRelativeX(f.posAnte.x)),f.evaluator.setVariable(f.myStr,f.space.getRelativeY(f.posAnte.y)),f.parent.update(),window.addEventListener("touchend",b),window.addEventListener("touchmove",
c))});this.mouseCacher.addEventListener("mousedown",function(d){document.body.focus();d.preventDefault();f.whichBtn=a.whichBtn(d);"L"==f.whichBtn&&f.activeIfValue&&f.over&&(f.parent.deactivateGraphiControls(),f.click=f.active=!0,f.evaluator.setVariable(f.activoStr,1),f.evaluator.setVariable(f.activeStr,1),f.evaluator.setVariable(f.mclickedStr,0),f.evaluator.setVariable(f.mclicizquierdoStr,0),f.posAnte=a.getCursorPosition(d,f.container),f.prePos={x:f.space.getAbsoluteX(f.x),y:f.space.getAbsoluteY(f.y)},
f.evaluator.setVariable(f.mxStr,f.space.getRelativeX(f.posAnte.x)),f.evaluator.setVariable(f.myStr,f.space.getRelativeY(f.posAnte.y)),f.parent.update(),window.addEventListener("mouseup",b),window.addEventListener("mousemove",c))});this.mouseCacher.addEventListener("mouseover",function(a){f.over=!0});this.mouseCacher.addEventListener("mouseout",function(a){f.over=!1;f.click=!1});var e};return a}(descartesJS||{}),descartesJS=function(a,h){var e,d,l,c,g,k,b,v,u,n;if(a.loadLib)return a;var r,p,x,f,q,
m,w,y,B=/[\w-//]*(\.png|\.jpg|\.gif|\.svg)/gi,E,F,D,G,H,K,C,A,I,J,M,z,O,L,N,R,P,U,T,S,Q;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,d=a.length;c<d;c++)switch(x=a[c][0],f=a[c][1],p=h[x],p){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":b[p]=
parseInt(f);break;case "about":case "config":case "init":case "clear":b[p]="true"===h[f];break;default:console.log("Propiedad de botones no identificada: <"+x+"> valor: <"+f+">")}return b};a.LessonParser.prototype.parseSpace=function(b){q={};b=this.split(b);for(var c=0,d=b.length;c<d;c++)switch(x=b[c][0],f=b[c][1],p=h[x],p){case "type":case "id":case "cID":case "file":case "info":q[p]=f;break;case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":q[p]="true"===h[f];
break;case "bg_display":case "render":q[p]=h[f];break;case "net":case "net10":case "axes":case "text":q[p]=""!=f?"false"===h[f]?"":new a.Color(f,this.parent.evaluator):"";break;case "x_axis":case "y_axis":q[p]="false"===h[f]?"":f;break;case "O.x":q.OxExpr=f;break;case "O.y":q.OyExpr=f;break;case "image":q.imageSrc=f;break;case "x":r=f;"%"===r[r.length-1]?(q.xPercentExpr=r.trim(),r=(this.parent.container.width*parseFloat(r)/100).toString()):r=f;q.xExpr=this.parser.parse(r);break;case "y":r=f;"%"===
r[r.length-1]?(q.yPercentExpr=r.trim(),r=(this.parent.container.height*parseFloat(r)/100).toString()):r=f;q.yExpr=this.parser.parse(r);break;case "width":r=f.trim();"%"===r[r.length-1]?(q.wExpr=r,r=this.parent.container.width*parseFloat(r)/100):(r=parseFloat(f),r!=f&&(r=this.parent.container.width,q._w_=f.trim()));q.w=r;break;case "height":r=f.trim();"%"===r[r.length-1]?(q.hExpr=r,r=this.parent.container.height*parseFloat(r)/100):(r=parseFloat(f),r!=f&&(r=this.parent.container.height,q._h_=f.trim()));
q.h=r;break;case "drawif":""!=f&&(q.drawif=this.parser.parse(f));break;case "scale":r=parseFloat(f);isNaN(r)&&(r=48);q.scale=r;break;case "background":q.background=new a.Color(f,this.parent.evaluator);break;default:console.log("Propiedad del espacio no identificada: <"+x+"> valor: <"+f+">")}switch(q.type){case "R2":return new a.Space2D(this.parent,q);case "R3":return new a.Space3D(this.parent,q);case "AP":return new a.SpaceAP(this.parent,q);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,
q);default:return new a.Space2D(this.parent,q)}};a.LessonParser.prototype.parseControl=function(b){m={type:"numeric"};b=this.split(b);for(var c=0,d=b.length;c<d;c++)switch(x=b[c][0],f=b[c][1],p=h[x],p){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":case "info":m[p]=f;break;case "gui":case "region":case "action":case "msg_pos":case "poster":m[p]=h[f];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":m[p]=
"true"===h[f];break;case "color":case "colorInt":case "trace":m[p]=new a.Color(f,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":""!=f&&(m[p]=this.parser.parse(f));break;case "constraint":m.constraintExpr=f;break;case "image":m.imageSrc=f;break;case "space":m.spaceID=f;break;case "type":m.type=h[f.trim()];break;case "expresion":m.expresion=this.parser.parse(f.replace(")(",","));break;case "bold":"false"!=h[f]&&(m.bold="bold");
break;case "italics":"false"!=h[f]&&(m.italics="italic");break;case "underlined":"false"!=h[f]&&(m.underlined=!0);break;case "value":var e=f.replace(/&squot;/g,"'");e.match(/^\|/)&&(e="'"+e.substring(1),e.match(/\|$/)&&(e=e.substring(0,e.length-1)+"'"));m.valueExpr=this.parser.parse(e);m.valueExprString=e;break;case "incr":0!=f&&(m.incr=this.parser.parse(f));break;case "exponentialif":m.exponentialif=parseFloat(f);break;case "text":m.rawText=f;for(var e=this.parseText(f),g=0,k=e.length;g<k;g++)e[g]=
this.parser.parse(e[g],!1);m.text=e;break;default:g=x.indexOf("."),e=h[x.substring(0,g)],g=h[x.substring(g+1)],"parameter"===e&&"font"===g?m.parameterFont=f:"Explanation"===e&&"font"===g?m.ExplanationFont=f:"tooltip"===e&&"font"===g?m.tooltipFont=f:console.log("Propiedad de control no identificada: <"+x+"> valor: <"+f+">")}if("numeric"===m.type)switch(m.gui){case "spinner":return new a.Spinner(this.parent,m);case "button":return new a.Button(this.parent,m);case "textfield":return new a.TextField(this.parent,
m);case "menu":return new a.Menu(this.parent,m);case "scrollbar":return new a.Scrollbar(this.parent,m);default:return new a.Spinner(this.parent,m)}else{if("video"===m.type)return new a.Video(this.parent,m);if("audio"===m.type)return new a.Audio(this.parent,m);if("graphic"===m.type)return new a.GraphicControl(this.parent,m);if("text"===m.type)return new a.TextArea(this.parent,m)}};a.LessonParser.prototype.parseGraphic=function(b,c,d,e){w={rotateExp:e,parameter:"t"};b=this.split(b);e=0;for(var g=b.length;e<
g;e++)if(x=b[e][0],f=b[e][1],p=h[x],""!=f)switch(p){case "type":case "align":case "lineDash":w[p]=h[f];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":w[p]="true"===h[f];break;case "color":case "fill":case "fillP":case "fillM":case "arrow":case "trace":w[p]="false"===h[f]?"":new a.Color(f,this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":case "init":case "end":w[p]=f;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "opacity":case "inirot":case "inipos":case "range":""!=
f&&(w[p]=this.parser.parse(f));break;case "space":w.spaceID=f;break;case "expresion":""!=f&&("macro"!=w.type?(w.expresion=this.parser.parse(f),w.expresionString=f):w.expresion=f);break;case "text":w.text=this.parseText(f);break;case "file":var k=f.replace(/&squot;/g,"'");"["===k.charAt(0)&&"]"===k.charAt(k.length-1)&&(k=k.substring(1,k.length-1));k.match(B)&&(k="'"+k+"'");w.file=this.parser.parse(k);break;case "border":""!=f&&"false"!=h[f]&&(w.border=new a.Color(f,this.parent.evaluator));break;default:if(void 0!=
w.family&&x.substring(0,w.family.length+1)===w.family+".")switch(h[x.substring(w.family.length+1)]){case "interval":""!=f&&(w.family_interval=this.parser.parse(f));break;case "steps":""!=f&&(w.family_steps=this.parser.parse(f))}else if(void 0!=w.parameter&&x.match(w.parameter+"."))switch(w.parameter!==x.substring(0,x.indexOf(w.parameter)+w.parameter.length)&&(w.parameter=x.substring(0,x.indexOf(w.parameter)+w.parameter.length)),h[x.substring(w.parameter.length+1)]){case "interval":""!=f&&(w.parameter_interval=
this.parser.parse(f));break;case "steps":""!=f&&(w.parameter_steps=this.parser.parse(f))}else console.log("Propiedad del grafico no identificada: <"+x+"> valor: <"+f+">")}c&&(w.abs_coord=c);d&&(w.background=d);switch(w.type){case "text":return new a.Text(this.parent,w);case "image":return new a.Image(this.parent,w);case "point":return new a.Point(this.parent,w);case "polygon":return new a.Polygon(this.parent,w);case "arc":return new a.Arc(this.parent,w);case "segment":return new a.Segment(this.parent,
w);case "arrow":return new a.Arrow(this.parent,w);case "macro":return new a.Macro(this.parent,w);case "curve":return new a.Curve(this.parent,w);case "equation":return new a.Equation(this.parent,w);case "sequence":return new a.Sequence(this.parent,w);case "fill":return new a.Fill(this.parent,w)}};a.LessonParser.prototype.parse3DGraphic=function(b,c,d,e){w={rotateExp:e,parameter:"t"};b=this.split(b);c=0;for(d=b.length;c<d;c++)switch(x=b[c][0],f=b[c][1],p=h[x],p){case "type":case "model":case "lineDash":w[p]=
h[f];break;case "background":case "fixed":case "edges":case "split":w[p]="true"===h[f];break;case "color":case "backcolor":w[p]=new a.Color(f,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inipos":case "endpos":""!=f&&(w[p]=this.parser.parse(f));break;case "family":case "parameter":case "font":case "name":case "inirot":case "endrot":case "info":w[p]=f;break;case "space":w.spaceID=f;break;case "expresion":"macro"!=w.type&&
"curve"!=w.type&&"surface"!=w.type?(w.expresion=this.parser.parse(f),w.expresionString=f):w.expresion=f.replace(/\\n/g," ").replace(/;/g," ");break;case "text":e=this.parseText(f);for(var g=0,k=e.length;g<k;g++)e[g]=this.parser.parse(e[g],!1);w.text=e;break;case "file":e=f.replace(/&squot;/g,"'");"["===e.charAt(0)&&"]"===e.charAt(e.length-1)&&(e=e.substring(1,e.length-1));e.match(/./)&&(e="'"+e+"'");w.file=this.parser.parse(e);break;default:void 0!==w.family&&x.substring(0,w.family.length+1)===w.family+
"."?"interval"===h[x.substring(w.family.length+1)]?""!=f&&(w.family_interval=this.parser.parse(f)):""!=f&&(w.family_steps=this.parser.parse(f)):console.log("Propiedad del grafico 3D no identificada: <"+x+"> valor: <"+f+">")}switch(w.type){case "point":return new a.Point3D(this.parent,w);case "segment":return new a.Segment3D(this.parent,w);case "polygon":return new a.Polygon3D(this.parent,w);case "curve":return new a.Curve3D(this.parent,w);case "triangle":return new a.Triangle3D(this.parent,w);case "face":return new a.Face3D(this.parent,
w);case "polireg":return new a.Polireg3D(this.parent,w);case "surface":return new a.Surface3D(this.parent,w);case "text":return new a.Text3D(this.parent,w);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,w);case "macro":return new a.Macro3D(this.parent,w)}};a.LessonParser.prototype.parseAuxiliar=function(b){y={};b=this.split(b);for(var c=
0,d=b.length;c<d;c++)b[c][1]=b[c][1].replace(/&squot;/g,"'");c=0;for(d=b.length;c<d;c++)switch(x=b[c][0],f=b[c][1],p=h[x],p){case "info":y[p]=f;break;case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":y[p]=f.replace(/&squot;/g,"'");break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "event":case "sequence":y[p]="true"===h[f];break;case "size":case "rows":case "columns":y[p]=
this.parser.parse(f);break;case "evaluate":case "execution":case "msg_pos":case "action":case "type":y[p]=h[f];break;case "x":case "y":case "width":case "height":y[p]=this.parser.parse(f);break;default:var e=x.indexOf("."),g=h[x.substring(0,e)],e=h[x.substring(e+1)];"parameter"===g&&"font"===e?y.parameterFont=f:console.log("Propiedad del auxiliar no identificada: <"+x+"> valor: <"+f+">")}y.sequence?new a.Function(this.parent,y):y.constant?(b=new a.Constant(this.parent,y),y.evaluate&&"always"===y.evaluate&&
this.parent.auxiliaries.push(b)):y.algorithm&&y.evaluate?(b=new a.Algorithm(this.parent,y),this.parent.auxiliaries.push(b)):y.array&&!y.matrix&&")"!=y.id.charAt(y.id.length-1)?(b=new a.Vector(this.parent,y),y.evaluate&&"always"===y.evaluate&&this.parent.auxiliaries.push(b)):y.matrix&&")"!=y.id.charAt(y.id.length-1)?(b=new a.Matrix(this.parent,y),y.evaluate&&"always"===y.evaluate&&this.parent.auxiliaries.push(b)):y.event&&")"!=y.id.charAt(y.id.length-1)?this.parent.events.push(new a.Event(this.parent,
y)):")"===y.id.charAt(y.id.length-1)?new a.Function(this.parent,y):new a.Variable(this.parent,y)};a.LessonParser.prototype.parseAction=function(b){E=b.action;F=b.parent;D=b.parameter;if(E)switch(E){case "message":return new a.Message(F,D);case "calculate":return new a.Calculate(F,D);case "openURL":return new a.OpenURL(F,D);case "openScene":return new a.OpenScene(F,D);case "about":return new a.About(F,D);case "config":return new a.Config(F,D);case "init":return new a.Init(F,D);case "clear":return new a.Clear(F,
D);case "animate":return new a.Animate(F,D);case "initAnimation":return new a.InitAnimation(F,D);case "playAudio":return new a.PlayAudio(F,D);default:console.log("Accion no soportada: <"+E+">")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(b){var c={};b=this.split(b);for(var d=0,e=b.length;d<e;d++)switch(x=b[d][0],f=b[d][1],p=h[x],p){case "id":case "delay":case "init":case "doExpr":case "whileExpr":c[p]=f.replace(/&squot;/g,"'");break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":c[p]=
"true"===h[f];break;default:console.log("Propiedad de la animacion no identificada: <"+x+">  <"+f+">")}return new a.Animation(this.parent,c)};a.LessonParser.prototype.parsePleca=function(h,p){h=this.split(h);d=e="";l=0;c="#536891";g="white";k="left";b="";v="SansSerif,BOLD,20";u="SansSerif,PLAIN,18";n=void 0;for(var m=0,r=h.length;m<r;m++)switch(x=h[m][0],f=h[m][1],x){case "title":e=f;break;case "subtitle":d=f;break;case "subtitlines":l=f;break;case "bgcolor":""!=f&&(c=(new a.Color(f,this.parent.evaluator)).getColor());
break;case "fgcolor":""!=f&&(g=(new a.Color(f,this.parent.evaluator)).getColor());break;case "align":""!=f&&(k=f);break;case "titleimage":b=f;break;case "titlefont":v=""!=f?a.convertFont(f):a.convertFont(v);break;case "subtitlefont":u=""!=f?a.convertFont(f):a.convertFont(u);break;default:console.log("Propiedad de la pleca no identificada: <"+x+">  <"+f+">")}if(""===e&&""===d)return document.createElement("div");J=u.substring(0,u.indexOf("px"));J=J.substring(J.lastIndexOf(" "));""!=b&&(M=this.parent.getImage(b),
z=M.height);n=document.createElement("div");n.setAttribute("id","descartesPleca");z?(n.setAttribute("style","position:absolute;left:0;top:0;text-align:"+k+";width:"+(p-30)+"px;height:"+(z-16)+"px;background:"+c+";color:"+g+";padding-top:8px;padding-bottom:8px;padding-left:15px;padding-right:15px;margin:0;overflow:hidden;z-index:100;"),M.setAttribute("style","position: absolute;left:0;top:0;z-index:-1;width:100%;height:100%;"),n.appendChild(M)):n.setAttribute("style","position:absolute;left:0;top:0;text-align:"+
k+";width:"+(p-30)+"px;background:"+c+";color:"+g+";padding-top:12px;padding-bottom:12px;padding-left:15px;padding-right:15px;margin:0;z-index:100;");O=document.createElement("div");O.setAttribute("style","padding:0;margin:0;font:"+v+";overflow:hidden;white-space:nowrap;");O.innerHTML=e;L=document.createElement("div");if(1===parseInt(l)){T=0;N=document.createElement("div");N.innerHTML=d;document.body.appendChild(N);P=J;do P-=T,N.setAttribute("style","padding:0;margin:0;font:"+u+";font-size:"+P+"px;width:"+
(p-30)+"px;line-height:"+P+"px;"),R=N.offsetHeight,U=R/P,T=1;while(1<U&&8<P);document.body.removeChild(N);L.setAttribute("style","padding:0;margin:0;font:"+u+";font-size:"+P+"px;line-height: 110%;overflow:hidden;white-space:nowrap;")}else L.setAttribute("style","padding:0;margin:0;font:"+u+";line-height:110%;");L.innerHTML=d;n.appendChild(O);n.appendChild(L);n.imageHeight=z;return n};a.LessonParser.prototype.split=function(a){if("string"!=typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");G=[];
K=H=0;C=!1;A=0;for(I=!1;H<a.length;)" "!==a.charAt(H)||C||H++," "===a.charAt(H)||C||(C=!0,A=H),"="!==a.charAt(H)||"'"!==a.charAt(H+1)||I||(I=!0,G[K]=[a.substring(A,H)],A=H+2,H+=2),I&&"'"===a.charAt(H)&&(C=I=!1,G[K].push(a.substring(A,H)),K++),"="!==a.charAt(H)||"'"===a.charAt(H+1)||I||(G[K]=[a.substring(A,H)],A=H+1,H++,S=a.substring(H).indexOf("="),-1===S?Q=S=a.length:(S+=H,Q=a.substring(H,S).lastIndexOf(" "),Q=-1===Q?a.length:Q+H),G[K].push(a.substring(A,Q)),K++,C=!1,H=Q),H++;return G};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 h(a,b){if(0==b)return 1;if(0>b)return NaN;if(0<=a||Math.floor(b)===b)return Math.pow(a,b);if(0>a){var c=1/b,d=Math.floor(c);if(d===c&&1===d%2)return-Math.pow(-a,b)}return NaN}function e(a,b){f=[];f.type="matrix";f.rows=a;f.cols=b;var c;m=0;for(w=b;m<w;m++){c=[];q=0;for(y=a;q<y;q++)c.push(0);f[m]=c}return f}function d(a,
b){p=a.rows;x=a.cols;f=e(p,x);var c;for(m=0;m<p;m++)for(q=0;q<x;q++){for(w=c=0;w<x;w++)c+=a[w][m]*b[q][w];f[q][m]=c}return f}function l(a,b,c){for(var d=e(c.length-1,c.length-1),f=0,g=d.length;f<g;f++)for(var k=0;k<g;k++)d[f][k]=f<a?k<b?c[f][k]:c[f][k+1]:f<b?c[f+1][k]:c[f+1][k+1];return d}function c(a){if(1<a.cols){for(var b=0,d=1,f=0,e=a.cols;f<e;f++)b+=d*a[0][f]*c(l(0,f,a)),d=-d;return b}return a[0][0]}if(a.loadLib)return a;var g,k={},b=Math.floor,v,u,n,r;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){v=this.childs.length-1;lastChild=this.childs[v];lastChild.parent=null;this.childs[v]=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="-",n=new a.Node("compOperator","=="),r=new a.Node("number","0"),n.addChild(this),n.addChild(r),u=this.getRoot(),u.setAllEvalFun(),u):this};a.Node.prototype.setAllEvalFun=function(){this.setEvalFun();for(var a=0,b=this.childs.length;a<b;a++)this.childs[a].setAllEvalFun()};a.Node.prototype.setEvalFun=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 n;this.evaluate=function(a,b){n=a.variables[this.value];if("object"===typeof n&&void 0==n.length)return n.evaluate(a);void 0==n&&(b||a.matrices[this.value]?n=a.matrices[this.value]:a.vectors[this.value]&&(n=a.vectors[this.value]));return void 0!==n?n:0}}else if("identifier"===this.type&&"square_bracket"===
this.childs[0].type&&1===this.childs[0].childs.length){var r,u;this.evaluate=function(a){r=this.childs[0].childs[0].evaluate(a);try{return u=a.vectors[this.value][0>r?0:b(r)],void 0!==u?u:0}catch(c){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var v,w;this.evaluate=function(a){v=this.childs[0].childs[0].evaluate(a);w=this.childs[0].childs[1].evaluate(a);try{return u=a.matrices[this.value][0>v?0:b(v)][0>w?0:b(w)],void 0!==u?u:
0}catch(c){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var y,K,C;this.evaluate=function(a){y=[];for(var b=0,c=this.childs[0].childs.length;b<c;b++)y[b]=this.childs[0].childs[b].evaluate(a);if("_Eval_"===this.value){g=0<y.length?y[0]:0;if("number"==typeof g)return"NaN";g.match(",")&&parseFloat(g.replace(",","."))==g.replace(",",".")&&(g="'"+g+"'");if(void 0==k[g]){K=g.match(/:=/g)?!0:!1;if(g.match(";")){for(var d=!1,f,e=[],h=0,b=0,c=g.length;b<c;b++)f=g.charAt(b),
"'"===f&&(d=!d),d||";"!==f||(e.push(g.substring(h,b)),h=b+1);e.push(g.substring(h));g="("+e.join(")(")+")"}k[g]=a.parser.parse(g,K)}C=a.eval(k[g]);return void 0!=C?C:NaN}return a.functions[this.value].apply(a,y)}}else if("operator"===this.type)"+"===this.value?this.evaluate=function(b){var c=this.childs[0].evaluate(b,!0);b=this.childs[1].evaluate(b,!0);if("matrix"!==c.type||"matrix"!==b.type)return"number"==typeof c&&"string"==typeof b?c=a.removeNeedlessDecimals(c.toString()):"string"==typeof c&&
"number"==typeof b&&(b=a.removeNeedlessDecimals(b.toString())),c+b;p=c.rows;x=c.cols;f=e(p,x);for(m=0;m<p;m++)for(q=0;q<x;q++)f[q][m]=c[q][m]+b[q][m];return f}:"-"===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;p=b.rows;x=b.cols;f=e(p,x);for(m=0;m<p;m++)for(q=0;q<x;q++)f[q][m]=b[q][m]-a[q][m];return f}:"*"===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:d(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),g=c(a);if(0===g)a=0;else{var g=1/g,k;if(1<a.length)for(var h=0,n=a.length;h<n;h++){k=g;for(var p=0;p<n;p++)f[p][h]=k*c(l(h,p,a)),k=-k;g=-g}else f[0][0]=g;a=f}b=0===a?e(b.rows,b.cols):d(b,a);return b}:"%"===this.value?this.evaluate=function(a){var c=this.childs[0].evaluate(a);
a=this.childs[1].evaluate(a);return c-b(c/a)*a}:"^"===this.value&&(this.evaluate=function(a){var b=this.childs[0].evaluate(a);a=this.childs[1].evaluate(a);return 0<=a?h(b,a):1/h(b,-a)});else if("compOperator"===this.type)"<"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)<this.childs[1].evaluate(a)?1:0}:"<="===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)<=this.childs[1].evaluate(a)?1:0}:">"===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)>
this.childs[1].evaluate(a)?1:0}:">="===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)>=this.childs[1].evaluate(a)?1:0}:"=="===this.value?this.evaluate=function(a){return this.childs[0].evaluate(a)===this.childs[1].evaluate(a)?1:0}:"!="===this.value&&(this.evaluate=function(a){return this.childs[0].evaluate(a)!==this.childs[1].evaluate(a)?1: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:1});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=[],d;if(1===b&&1===this.childs[0].childs.length&&"(expr)"===this.type)c=this.childs[0].childs[0].evaluate(a);else for(var f=0;f<b;f++){d=[];for(var e=0,g=this.childs[f].childs.length;e<g;e++)d.push(this.childs[f].childs[e].evaluate(a));c[f]=d}return c};else if("asign"===this.type){var A,I,J,M,z,O;
this.evaluate=function(a){A=this.childs[0];I=this.childs[1];if(1===A.childs.length&&"square_bracket"===A.childs[0].type){r=A.childs[0].childs;if(1===r.length)return J=r[0].evaluate(a),J=0>J?0:b(J),a.vectors[A.value][J]=I.evaluate(a),I.evaluate(a);if(2===r.length)return M=r[0].evaluate(a),z=r[1].evaluate(a),M=0>M?0:b(M),z=0>z?0:b(z),a.matrices[A.value][M]||(a.matrices[A.value][M]=[]),a.matrices[A.value][M][z]=I.evaluate(a),I.evaluate(a)}else return O=I.evaluate(a),O.type?a.matrices[A.value]=O:"object"!==
typeof a.variables[A.value]?a.variables[A.value]=O:0}}};var p,x,f,q,m,w,y;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 h,e,d,l,c,g,k,b,v,u=/^\s+/,n=/^[a-zA-Z_\u00C0-\u021B\u0391-\u03C9]+[a-zA-Z_0-9\u00C0-\u021B\u0391-\u03C9]*([.]*[0-9a-zA-Z_\u00C0-\u021B\u0391-\u03C9]+[0-9]*)*/,
r=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,p=/^==|^!=|^<=|^<|^>=|^>|^#/,x=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,f=/^=|^:=/,q=/^[\?\:]/,m=/^[\+\-\*\/\%\^\u2212\u00b7\u00D7\u00F7]/,w=/^\[|^\]/,y=/^\(|^\)/,B=/^,/,E=/^;/,F=/\|/g,D=/\|\*/g,G=/\*\|/g;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function A(a,c,d){e.push({type:a,value:c});g=g.slice(d);l+=d;b++;v=a}if(h=a){var I=a.indexOf("//");0<=I&&(a=a.substring(0,I));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(G,"'"));a.match(/\=\|/g)&&(a=a.replace(F,"'"));I=a.trim();"|"==I.charAt(0)&&"|"==I.charAt(I.length-1)&&(a=I.replace(F,"'"))}e=[];d=!1;l=0;g=a;b=0;for(v="";a&&l<a.length;)if(d=l,"'"==g[0]){for(k=1;"'"!=g[k];)if(k<g.length)k++;else{console.log(">Error, unknown symbol: ["+g+"], in the string <<"+h+">>");return}c=g.substring(1,k);A("string",c,c.length+2)}else if(c=g.match(u))g=g.slice(c[0].length),
l+=c[0].length,b++;else if(c=g.match(m))c[0]=c[0].replace(/\u00F7/g,"/").replace(/\u2212/g,"-").replace(/\u00b7/g,"*").replace(/\u00D7/g,"*"),A("operator",c[0],c[0].length);else if(c=g.match(n))"number"===v&&e.push({type:"operator",value:"*"}),A("identifier",c[0],c[0].length);else if(c=g.match(r))A("number",c[0],c[0].length);else if(c=g.match(p))I=c[0],"#"==I&&(I="!="),A("compOperator",I,c[0].length);else if(c=g.match(x))I=c[0],"||"==I?I="|":"&&"==I?I="&":"~"==I&&(I="!"),A("boolOperator",I,c[0].length);
else if((c=g.match(f))&&!g.match(/^==/))A("asign",c[0],c[0].length);else if(c=g.match(q))A("conditional",c[0],c[0].length);else if(c=g.match(w))A("square_bracket",c[0],c[0].length);else if(c=g.match(y))"("==c&&"number"===v&&e.push({type:"operator",value:"*"}),A("parentheses",c[0],c[0].length);else if(c=g.match(B))A("separator",c[0],c[0].length);else if(178===g.charCodeAt(0))e.push({type:"operator",value:"^"}),A("number",2,1);else if(179===g.charCodeAt(0))e.push({type:"operator",value:"^"}),A("number",
3,1);else if(c=g.match(E))A("final_of_expresion",c[0],c[0].length);else if(d==l){console.log("Error, simbolo no conocido: ["+g+"], en la cadena <<"+h+">>");return}return e};var H,K=/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||"";H="";for(var c=0,d=a.length;c<d;c++)H="string"==a[c].type?H+"&squot;"+a[c].value+"&squot;":
"identifier"!=a[c].type||a[c].value.match(K)?H+a[c].value:H+b+a[c].value;return H};return a}(descartesJS||{}),descartesJS=function(a){function h(a){switch(a){case "=":return 1;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}}function e(a){return isNaN(parseFloat(a))?a.replace(/^\s|\s$/g,"").replace(/^'|'$/g,""):parseFloat(a)==a?parseFloat(a):a.replace(/^\s|\s$/g,"").replace(/^'|'$/g,"")}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();this.registerExternalValues&&
this.registerExternalValues()};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,d){this.matrices[a][b][c]=d};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 d,l,c,g,k,b,v,u,n,r,
p,x;a.Parser.prototype.parse=function(e,q){(c=this.tokenizer.tokenize(e))||(c=[]);g=null;q=!q||!1;d=u=v=b=0;for(l=c.length;d<l;d++){n=c[d];r=n.value;p=n.type;if("identifier"===p)if(d+1<l&&"parentheses"===c[d+1].type&&"("===c[d+1].value)this.getFunction(r);else if(d+1<l&&"square_bracket"===c[d+1].type&&"["===c[d+1].value)c[d+3]&&"square_bracket"===c[d+3].type&&"]"===c[d+3].value?this.getVector(r):this.getMatrix(r);else{var m=r.match(/(\w*)\.mouse_x|(\w*)\.mouse_y|(\w*)\.mouse_pressed|(\w*)\.mouse_clicked|(\w*)\.clic_izquierdo/);
m&&(this.variables[(m[1]||m[2]||m[3]||m[4]||m[5])+".DESCARTESJS_no_fixed"]=1);this.getVariable(r,!0)}"asign"===p&&q&&":="!=r&&(p="compOperator",r="==");if("asign"===p)if(k=new a.Node(p,r),null!=g)if("identifier"===g.type)g.parent&&g.parent.replaceLastChild(k),k.addChild(g),g=k,q=!0;else if("square_bracket"===g.type)k.addChild(g.parent),g=k,q=!0;else{k.type="compOperator";k.value="==";for(q=!0;g.parent&&h(g.parent.value)>=h(k.value);)g=g.parent;g.parent&&g.parent.replaceLastChild(k);k.addChild(g);
g=k}else{console.log("Error1: en la expresion <<"+e+">>, en el token {valor: "+r+", tipo: "+p+"}");break}else if("parentheses"===p&&"("===r||"square_bracket"===p&&"["===r)if(k=new a.Node(p,r),"("===r&&b++,"["===r&&v++,null===g)"("===r&&(new a.Node("(expr)","(expr)")).addChild(k),"["===r&&(new a.Node("[expr]","[expr]")).addChild(k),g=k;else if("operator"===g.type||"boolOperator"===g.type||"compOperator"===g.type||"conditional"===g.type||"asign"===g.type)g.addChild(k),g=k;else if("sign"===g.type)g.addChild(k),
g=k;else if("parentheses"===g.type&&"("===g.value)g.addChild(k),g=k;else if("square_bracket"===g.type&&"["===g.value)g.addChild(k),g=k;else if("parentheses"===g.type&&"()"===g.value)g.parent.addChild(k),g=k;else if("square_bracket"===g.type&&"[]"===g.value)g.parent.addChild(k),g=k;else if("identifier"===g.type)g.addChild(k),g=k;else{console.log("Error2: en la expresion <<"+e+">>, en el token ["+d+"] {valor: "+r+", tipo: "+p+"}");break}else if("parentheses"===p&&")"===r)if(b--,null===g)console.log("Error3: en la expresion <<"+
e+">>, en el token (valor:"+r+", tipo:"+p);else{for(;g&&g.parent&&("("!=g.value||"("==g.value&&"parentheses"!=g.type);)g=g.parent;if(g&&"("===g.value)g.value="()";else{console.log("Error4: en la expresion <<"+e+">>, en el token {valor: "+r+", tipo: "+p+"}");break}}else if("square_bracket"===p&&"]"===r)if(v--,null===g)console.log("Error5: en la expresion <<"+e+">>, en el token (valor:"+r+", tipo:"+p);else{for(;g&&g.parent&&("["!=g.value||"["==g.value&&"square_bracket"!=g.type);)g=g.parent;if(g&&"["===
g.value)g.value="[]";else{console.log("Error6: en la expresion <<"+e+">>, en el token {valor: "+r+", tipo: "+p+"}");break}}else if("number"===p||"string"===p||"identifier"===p)if(k=new a.Node(p,r),null===g)g=k;else if("operator"===g.type||"compOperator"===g.type||"boolOperator"===g.type||"parentheses"===g.type&&"("===g.value||"square_bracket"===g.type&&"["===g.value||"sign"===g.type||"conditional"===g.type||"asign"===g.type)g.addChild(k),g=k;else{console.log("Error7: en la expresion <<"+e+">>, en el token {valor: "+
r+", tipo: "+p+"}");break}else if("operator"===p||"compOperator"===p||"boolOperator"===p)if(k=new a.Node(p,r),null===g)if("-"===r||"+"===r)k.type="sign",k.value="sign"+r,g=k;else if("!"===r)g=k;else{console.log("Error8: en la expresion <<"+e+">>, en el token {valor: "+r+", tipo: "+p+"}");break}else if("operator"===g.type||"compOperator"===g.type||"boolOperator"===g.type||"asign"===g.type||"conditional"===g.type||"square_bracket"===g.type&&"["===g.value&&("-"===r||"+"===r||"!"===r)||"parentheses"===
g.type&&"("===g.value&&("-"===r||"+"===r||"!"===r)){if("-"===r||"+"===r)k.type="sign",k.value="sign"+r;g.addChild(k);g=k}else if("number"===g.type||"parentheses"===g.type&&"()"===g.value||"square_bracket"===g.type&&"[]"===g.value||"string"===g.type||"identifier"===g.type||"conditional"===g.type||"asign"===g.type){for(;g.parent&&h(g.parent.value)>=h(k.value);)g=g.parent;g.parent&&g.parent.replaceLastChild(k);k.addChild(g);g=k}else{console.log("Error9: en la expresion <<"+e+">>, en el token {valor: "+
r+", tipo: "+p+"}");break}else if("conditional"===p)if(k=new a.Node(p,r),null!=g)if("?"===k.value){for(u++;g.parent&&h(g.parent.value)>h(k.value);)g=g.parent;g.parent&&g.parent.replaceLastChild(k);k.addChild(g);g=k}else{for(u--;g&&g.parent&&("?"!=g.value||"?"==g.value&&"conditional"!=g.type);)g=g.parent;if(g&&"?"===g.value)g.value="?:";else{console.log("Error10: en la expresion <<"+e+">>, en el token {valor: "+r+", tipo: "+p+"}");break}}else{console.log("Error11: en la expresion <<"+e+">>, en el token {valor: "+
r+", tipo: "+p+"}");break}else if("separator"===p)if(null!=g)for(;g.parent&&"("!=g.value&&"["!=g.value;)g=g.parent;else{console.log("Error12: en la expresion <<"+e+">>, en el token {valor: "+r+", tipo: "+p+"}");break}else{console.log("Error13: en la expresion <<"+e+">>, en el token {valor: "+r+", tipo: "+p+"}");break}}0<b&&alert("Error, faltan parentesis por cerrar: "+e);0>b&&alert("Error, faltan parentesis por abrir: "+e);0<v&&alert("Error, faltan corchetes por cerrar: "+e);0>v&&alert("Error, faltan corchetes por abrir: "+
e);0!=u&&alert("Error, condicional incompleta: "+e);(x=g?g.getRoot():null)&&x.setAllEvalFun();return x};a.Parser.prototype.registerDefaultValues=function(){function b(a,c){for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}var c=this;c.variables.rnd=Math.random;c.variables.pi=c.variables["\u03c0"]=a.returnValue(Math.PI);c.variables.e=a.returnValue(Math.E);c.variables.Infinity=Infinity;c.variables["-Infinity"]=-Infinity;c.variables.isTouch=c.variables["esT\u00e1ctil"]=a.hasTouchSupport?1:0;c.functions.sqr=
function(a){return a*a};c.functions.sqrt=c.functions["ra\u00edz"]=Math.sqrt;c.functions.exp=Math.exp;c.functions.log=Math.log;c.functions.log10=function(a){return Math.log(a)/Math.log(10)};c.functions.abs=Math.abs;c.functions.ent=Math.floor;c.functions.sgn=function(a){return 0<a?1:0>a?-1:0};c.functions.ind=function(a){return a?1:0};c.functions.sin=c.functions.sen=Math.sin;c.functions.cos=Math.cos;c.functions.tan=Math.tan;c.functions.cot=function(a){return 1/Math.tan(a)};c.functions.sec=function(a){return 1/
Math.cos(a)};c.functions.csc=function(a){return 1/Math.sin(a)};c.functions.sinh=c.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};c.functions.cosh=function(a){return(Math.exp(a)+Math.exp(-a))/2};c.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/(Math.exp(a)+Math.exp(-a))};c.functions.coth=function(a){return 1/c.functions.tanh(a)};c.functions.sech=function(a){return 1/c.functions.cosh(a)};c.functions.csch=function(a){return 1/c.functions.sinh(a)};c.functions.asin=c.functions.asen=
Math.asin;c.functions.acos=Math.acos;c.functions.atan=Math.atan;c.functions.min=Math.min;c.functions.max=Math.max;c.functions._Trace_=c.functions._Print_=function(){console.log.apply(console,arguments);return 0};c.functions._Num_=function(a){if("number"==typeof a)return"NaN";a=a.replace(",",".");return parseFloat(a)==a?parseFloat(a):"NaN"};c.functions._Stop_Audios_=function(){c.evaluator.parent.stopAudios()};c.functions.esCorrecto=function(b,d,e){return a.esCorrecto(b,d,c.evaluator,e)};c.functions.escorrecto=
function(b,d,e){return a.escorrecto(b,d,c.evaluator,e)};window.parent!==window&&(c.functions["parent.set"]=function(a,b){window.parent.postMessage({type:"set",name:a,value:b},"*");return 0},c.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*");return 0},c.functions["parent.exec"]=function(a,b){window.parent.postMessage({type:"exec",name:a,value:b},"*");return 0});c.functions._NumToStr_=c.functions._NumACadena_=function(a,b){a=isNaN(parseFloat(a))?0:parseFloat(a);return a.toFixed(parseInt(b||
0))};c.functions._charAt_=c.functions._letraEn_=function(a,b){a=(a||"").toString();b=isNaN(parseInt(b))?0:parseInt(b);return a.charAt(b)};c.functions._substring_=c.functions._subcadena_=function(a,b,c){a=(a||"").toString();b=isNaN(parseInt(b))?0:parseInt(b);c=isNaN(parseInt(c))?0:parseInt(c);return 0<=b&&0<=c?a.substring(b,c):0>b&&0<=c?a.substring(c):0>c&&0<=b?a.substring(b):""};c.functions._length_=c.functions._longitud_=function(a){return(a||"").toString().length};c.functions._indexOf_=c.functions["_\u00edndiceDe_"]=
function(a,b){return(a||"").toString().indexOf((b||"").toString())};this.functions._Load_=function(b){var c="";b&&(c=(c=document.getElementById(b))&&"descartes/archivo"==c.type?c.text:a.openExternalFile(b));return c||""};this.functions._GetValues_=function(a,b){var c=this.functions._Load_(a).replace(/&brvbar;/g,String.fromCharCode("166"));return this.functions._ExecBlock_(c,b)};this.functions._GetMatrix_=function(a,b){var c=this.functions._Load_(a).replace(/&brvbar;/g,String.fromCharCode("166"));
return this.functions._StrToMatrix_(c,b)};this.functions._MatrixToStr_=function(a){var b=this.matrices[a];if(b){for(var c="<"+a+">\\n",d=this.getVariable(a+".columnas_usadas")||b.rows||0,e=this.getVariable(a+".filas_usadas")||b.cols||0,f,g=0;g<d;g++){for(var k=0;k<e;k++)f=b[g][k],void 0!==f&&("string"==typeof f&&(f="'"+f+"'"),c+=f+(k<e-1?" \u00a6 ":""));c=c.replace(/(\u00A6 )$/g,"")+"\\n"}return c+("</"+a+">")}return""};this.functions._StrToMatrix_=function(a,b){var d=[],f=!1;d.type="matrix";if(a){a=
a.replace(/\r|\\r/g,"").split(/\n|\\n/);for(var g=0,k=a.length;g<k;g++)a[g].match("<"+b+">")?(f=a[g].trim().split("<"+b+">"),2==f.length&&""!=f[1]&&d.push(f[1].split(String.fromCharCode("166")).map(e)),f=!0):a[g].match("</"+b+">")?(f=a[g].trim().split("</"+b+">"),2==f.length&&""!=f[0]&&d.push(f[0].split(String.fromCharCode("166")).map(e)),f=!1):f&&d.push(a[g].split(String.fromCharCode("166")).map(e));c.matrices[b]=d;c.setVariable(b+".filas",d[0].length);c.setVariable(b+".columnas",d.length)}return"OK"};
this.functions._GetVector_=function(a,b){var c=this.functions._Load_(a);return this.functions._StrToVector_(c,b)};this.functions._VectorToStr_=function(a){var b=this.vectors[a];if(b){for(var c="<"+a+">\\n",d=this.getVariable(a+".long_usada")||b._size_||0,e,f=0;f<d;f++)e=b[f],void 0!==e?("number"==typeof e&&(e=parseFloat(e)),c+=e+"\\n"):c+="0\\n";return c+("</"+a+">")}return""};this.functions._StrToVector_=function(a,b){var d=[],f=!1;d.type="vector";if(a){a=a.replace(/\r|\\r/g,"").split(/\n|\\n/);
for(var g=0,k=a.length;g<k;g++)a[g].match("<"+b+">")?f=!0:a[g].match("</"+b+">")?f=!1:f&&d.push(e(a[g]));d._size_=d.length;c.vectors[b]=d;c.setVariable(b+".long",d.length);c.setVariable(b+".long_usada",d.length)}return"OK"};this.functions._ExecStr_=function(a){return this.functions._ExecBlock_(a,"")};this.functions._ExecBlock_=function(a,b){var d=[],e=""==b;if(a){a=a.replace(/\r|\\r/g,"").split(/\n|\\n/);for(var f=0,g=a.length;f<g;f++)a[f].match("<"+b+">")?(e=a[f].trim().split("<"+b+">"),2==e.length&&
""!=e[1]&&(d=d.concat(e[1].split(String.fromCharCode("166")))),e=!0):a[f].match("</"+b+">")?(e=a[f].trim().split("</"+b+">"),2==e.length&&""!=e[0]&&(d=d.concat(e[0].split(String.fromCharCode("166")))),e=!1):e&&(d=d.concat(a[f].split(String.fromCharCode("166"))));f=0;for(g=d.length;f<g;f++)e=d[f].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};var d=document.createElement("a");
d.setAttribute("target","_blank");var g,k=null;this.functions._Save_=function(b,c){document.body.appendChild(d);g=new Blob(["\ufeff",c.replace(/\\n/g,"\n").replace(/\\q/g,"'").replace(/\\r/g,"").replace(/\\_/g,"\\")],{type:"text/plain"});d.setAttribute("download",b);d.setAttribute("href",window.URL.createObjectURL(g));null==k&&(d.click(),k=!0,a.setTimeout(function(){k=null},1E3));document.body.removeChild(d);return 0};var h,n,p,r,l=document.createElement("input");l.setAttribute("type","file");onHandleFileSelect=
function(b){h=b.target.files;n=new FileReader;n.onload=function(b){a.addExternalFileContent(h[0].name,b.target.result);c.setVariable(p,h[0].name);c.getFunction(r)&&(c.getFunction(r).apply(c.evaluator,[]),c.evaluator.parent.update())};0<h.length&&n.readAsText(h[0])};l.addEventListener("change",onHandleFileSelect);this.functions._Open_=function(a,b){p=a;r=b;l.click();return 0};var u,v,x=document.createElement("input");x.setAttribute("type","file");onHandleFileSelect2=function(a){a.stopPropagation();
a.preventDefault();u=a.target.files;v=new FileReader;v.onload=function(a){var d={};try{d=JSON.parse(a.target.result)}catch(e){}d.variables&&b(c.variables,d.variables);d.vectors&&b(c.vectors,d.vectors);d.matrices&&b(c.matrices,d.matrices);c.evaluator.parent.update()};0<u.length&&v.readAsText(u[0])};x.removeEventListener("change",onHandleFileSelect2);x.addEventListener("change",onHandleFileSelect2);this.functions._AnchoDeCadena_=this.functions._strWidth_=function(b,c,d,e){return a.getTextWidth(b,a.convertFont(c+
","+d+","+e))};this.functions._Rojo_=this.functions._Red_=function(b){return(new a.Color(b)).r/255};this.functions._Verde_=this.functions._Green_=function(b){return(new a.Color(b)).g/255};this.functions._Azul_=this.functions._Blue_=function(b){return(new a.Color(b)).b/255};this.functions["DJS.typeof"]=function(a){return a.rows?"matrix":a._size_?"vector":typeof a}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=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,d){this.definitions[a]=d};a.Evaluator.prototype.getDefinition=function(a){return this.definitions[a]};a.Evaluator.prototype.setVariable=function(a,d){this.variables[a]=d};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=
function(a,d,l){d=0>d?0:h(d);this.vectors[a][d]=l};a.Evaluator.prototype.getVector=function(a,d){d=0>d?0:h(d);return this.vectors[a][d]};a.Evaluator.prototype.setMatrix=function(a,d,l,c){d=0>d?0:h(d);l=0>l?0:h(l);this.matrices[a][d][l]=c};a.Evaluator.prototype.getMatrix=function(a,d,l){d=0>d?0:h(d);l=0>l?0:h(l);return this.matrices[a][d][l]};a.Evaluator.prototype.setFunction=function(a,d){this.functions[a]=d};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.eval=
function(a){return a?a.evaluate(this):0};a.externalEvaluator=new a.Evaluator;return a}(descartesJS||{}),richTextEditor=function(a){a.narrowSpace=String.fromCharCode(65279);a.separatorNode=document.createElement("span");a.separatorNode.setAttribute("contenteditable","false");a.separatorNode.setAttribute("data-noedit","true");a.separatorNode.setAttribute("class","SeparatorNode");a.separatorNode.innerHTML=a.narrowSpace;a.getChildrenByType=function(h,e){var d=h.children,l;if(h.hasChildNodes){for(var c=
0,g=d.length;c<g;c++)if(d[c].getAttribute("class")===e)return d[c];c=0;for(g=d.length;c<g;c++)if(l=a.getChildrenByType(d[c],e))return l}else return null};a.newTextBlock=function(){var a=document.createElement("div");a.setAttribute("class","TextBlock");return a};a.newTextLineBlock=function(){var a=document.createElement("div");a.setAttribute("class","TextLine");return a};a.newTextNode=function(h,e){var d=document.createDocumentFragment(),l=document.createElement("span");l.setAttribute("class","TextNode");
l.setAttribute("style",h);l.innerHTML=e.replace(/ /g,"&nbsp;");var c=a.separatorNode.cloneNode(!0);c.setAttribute("style",h);d.appendChild(l);d.appendChild(c);return d};a.newNewLine=function(h){var e=document.createDocumentFragment(),d=document.createElement("span");d.setAttribute("class","TextNode");d.setAttribute("style",h);d.innerHTML=a.narrowSpace;var l=a.separatorNode.cloneNode(!0);l.setAttribute("style",h);e.appendChild(d);e.appendChild(l);return e};a.newFormula=function(h,e){var d=document.createDocumentFragment(),
l=document.createElement("span");l.setAttribute("class","FormulaNode");l.setAttribute("style",h);l.appendChild(e);var c=a.separatorNode.cloneNode(!0);c.setAttribute("style",h);d.appendChild(a.newTextNode(h,a.narrowSpace));d.appendChild(l);d.appendChild(c);d.appendChild(a.newTextNode(h,a.narrowSpace));return d};a.newHyperLink=function(a,e,d){var l=document.createElement("span");l.setAttribute("class","HyperLinkNode");l.setAttribute("style",a);a=document.createElement("a");a.setAttribute("target","_blank");
a.setAttribute("href",d);a.textContent=e;l.appendChild(a);return l};a.newComponentSpace=function(a,e){var d=document.createElement("span");d.setAttribute("class","ComponentSpaceNode");d.setAttribute("style","display:inline-block; vertical-align:top; width:"+a+"px; height:0px;");d.setAttribute("id","cID_"+e);return d};a.newComponentNumCtrl=function(a,e,d){var l=document.createElement("span");l.setAttribute("class","ComponentNumCtrlNode");l.setAttribute("style","display:inline-block; vertical-align:middle; width:"+
a+"px; height:"+e+"px;");l.setAttribute("id","cID_"+d);return l};a.newDynamicTextNode=function(h){var e=document.createDocumentFragment(),d=document.createElement("span");d.setAttribute("class","DynamicTextNode");d.innerHTML="[expr]";d.setAttribute("contenteditable","false");d.setAttribute("data-decimals",h.decimals);d.setAttribute("data-fixed",h.fixed);d.setAttribute("data-value",h.value);d.setAttribute("data-noedit","true");e.appendChild(a.newFormulaTextNode(a.narrowSpace));e.appendChild(d);e.appendChild(a.separatorNode.cloneNode(!0));
e.appendChild(a.newFormulaTextNode(a.narrowSpace));return e};a.newFormulaTextNode=function(h){var e=document.createDocumentFragment(),d=document.createElement("span");d.setAttribute("class","TextNode");d.innerHTML=h.replace(/ /g,"&nbsp;");e.appendChild(d);e.appendChild(a.separatorNode.cloneNode(!0));return e};a.newMathSymbolNode=function(h){var e=document.createDocumentFragment(),d=document.createElement("span");d.setAttribute("class","TextNode MathSymbolNode");d.textContent=h;e.appendChild(d);e.appendChild(a.separatorNode.cloneNode(!0));
return e};a.newSuperIndexNode=function(h){var e=document.createDocumentFragment(),d=document.createElement("span");d.setAttribute("class","SuperIndexNode");d.appendChild(h);e.appendChild(a.newFormulaTextNode(a.narrowSpace));e.appendChild(d);e.appendChild(a.newFormulaTextNode(a.narrowSpace));return e};a.newSubIndexNode=function(h){var e=document.createDocumentFragment(),d=document.createElement("span");d.setAttribute("class","SubIndexNode");d.appendChild(h);e.appendChild(a.newFormulaTextNode(a.narrowSpace));
e.appendChild(d);e.appendChild(a.newFormulaTextNode(a.narrowSpace));return e};a.newFractionNode=function(h,e){var d=document.createDocumentFragment(),l=document.createElement("table");l.setAttribute("class","FractionNode");var c=document.createElement("tr"),g=document.createElement("td"),k=document.createElement("span");k.setAttribute("class","NumeratorNode");c.appendChild(g);g.appendChild(k);k.appendChild(h);l.appendChild(c);c=document.createElement("tr");g=document.createElement("td");k=document.createElement("span");
k.setAttribute("class","DenominatorNode");c.appendChild(g);g.appendChild(k);k.appendChild(e);l.appendChild(c);d.appendChild(a.newFormulaTextNode(a.narrowSpace));d.appendChild(l);d.appendChild(a.separatorNode.cloneNode(!0));d.appendChild(a.newFormulaTextNode(a.narrowSpace));return d};a.newRadicalNode=function(h,e){var d=document.createDocumentFragment(),l=document.createElement("span");l.setAttribute("class","RadicalNode");var c=document.createElement("span");c.setAttribute("class","IndexNode");c.appendChild(h);
l.appendChild(c);c=document.createElement("span");c.setAttribute("class","RadicalSign");c.setAttribute("contenteditable","false");c.setAttribute("data-noedit","true");c.innerHTML="\u221a";l.appendChild(c);c=document.createElement("span");c.setAttribute("class","RadicandNode");c.appendChild(e);l.appendChild(c);d.appendChild(a.newFormulaTextNode(a.narrowSpace));d.appendChild(l);d.appendChild(a.separatorNode.cloneNode(!0));d.appendChild(a.newFormulaTextNode(a.narrowSpace));return d};a.newSumNode=function(h,
e,d){var l=document.createDocumentFragment(),c=document.createElement("span");c.setAttribute("class","SumNode");var g=document.createElement("table");g.setAttribute("class","SumContainer");var k=document.createElement("tr"),b=document.createElement("td"),v=document.createElement("span");v.setAttribute("class","SumToNode");k.appendChild(b);b.appendChild(v);v.appendChild(h);g.appendChild(k);h=document.createElement("tr");k=document.createElement("td");b=document.createElement("span");b.setAttribute("class",
"SigmaSign");b.setAttribute("contenteditable","false");b.setAttribute("data-noedit","true");b.innerHTML="\u03a3";h.appendChild(k);k.appendChild(b);g.appendChild(h);h=document.createElement("tr");k=document.createElement("td");b=document.createElement("span");b.setAttribute("class","SumFromNode");h.appendChild(k);k.appendChild(b);b.appendChild(e);g.appendChild(h);e=document.createElement("span");e.setAttribute("class","SumWhatNode");e.appendChild(d);c.appendChild(g);c.appendChild(a.separatorNode.cloneNode(!0));
c.appendChild(e);l.appendChild(a.newFormulaTextNode(a.narrowSpace));l.appendChild(c);l.appendChild(a.separatorNode.cloneNode(!0));l.appendChild(a.newFormulaTextNode(a.narrowSpace));return l};a.newIntegralNode=function(h,e,d){var l=document.createDocumentFragment(),c=document.createElement("span");c.setAttribute("class","IntegralNode");var g=document.createElement("table");g.setAttribute("class","IntegralContainer");var k=document.createElement("tr"),b=document.createElement("td"),v=document.createElement("span");
v.setAttribute("class","IntegralToNode");k.appendChild(b);b.appendChild(v);v.appendChild(h);g.appendChild(k);h=document.createElement("tr");k=document.createElement("td");b=document.createElement("span");b.setAttribute("class","IntegralSign");b.setAttribute("contenteditable","false");b.setAttribute("data-noedit","true");b.innerHTML="\u222b";h.appendChild(k);k.appendChild(b);g.appendChild(h);h=document.createElement("tr");k=document.createElement("td");b=document.createElement("span");b.setAttribute("class",
"IntegralFromNode");h.appendChild(k);k.appendChild(b);b.appendChild(e);g.appendChild(h);e=document.createElement("span");e.setAttribute("class","IntegralWhatNode");e.appendChild(d);c.appendChild(g);c.appendChild(a.separatorNode.cloneNode(!0));c.appendChild(e);l.appendChild(a.newFormulaTextNode(a.narrowSpace));l.appendChild(c);l.appendChild(a.separatorNode.cloneNode(!0));l.appendChild(a.newFormulaTextNode(a.narrowSpace));return l};a.newLimitNode=function(h,e,d){var l=document.createDocumentFragment(),
c=document.createElement("span");c.setAttribute("class","LimitNode");var g=document.createElement("span");g.setAttribute("class","LimitContainer");var k=document.createElement("span");k.setAttribute("class","LimitSign");k.setAttribute("contenteditable","false");k.setAttribute("data-noedit","true");k.innerHTML="&nbsp;l\u00edm";g.appendChild(k);k=document.createElement("span");k.setAttribute("class","LimitFromToNode");g.appendChild(k);var b=document.createElement("span");b.setAttribute("class","LimitFromNode");
b.appendChild(e);k.appendChild(b);e=document.createElement("span");e.setAttribute("class","LimitArrow");e.setAttribute("data-noedit","true");e.innerHTML="\u2192";k.appendChild(e);e=document.createElement("span");e.setAttribute("class","LimitToNode");e.appendChild(h);k.appendChild(e);h=document.createElement("span");h.setAttribute("class","LimitWhatNode");h.appendChild(d);c.appendChild(g);c.appendChild(a.separatorNode.cloneNode(!0));c.appendChild(h);l.appendChild(a.newFormulaTextNode(a.narrowSpace));
l.appendChild(c);l.appendChild(a.separatorNode.cloneNode(!0));l.appendChild(a.newFormulaTextNode(a.narrowSpace));return l};a.newElementNode=function(a,e){var d=document.createElement("span");d.setAttribute("class",a);d.appendChild(e);return d};a.newMatrixNode=function(h,e,d){var l=document.createDocumentFragment(),c=document.createElement("table");c.setAttribute("class","MatrixNode");for(var g=0;g<h;g++){for(var k=document.createElement("tr"),b=0;b<e;b++){var v=document.createElement("td");v.appendChild(a.newElementNode("MatrixElementNode",
d[b+g*e]));k.appendChild(v)}c.appendChild(k)}l.appendChild(a.newFormulaTextNode(a.narrowSpace));l.appendChild(c);l.appendChild(a.separatorNode.cloneNode(!0));l.appendChild(a.newFormulaTextNode(a.narrowSpace));return l};a.newCasesElementNode=function(h,e){var d=document.createDocumentFragment(),l=document.createElement("table");l.setAttribute("class","CasesNode");for(var c=0;c<h;c++){var g=document.createElement("tr"),k=document.createElement("td");k.appendChild(a.newElementNode("CasesElementNode",
e[c]));g.appendChild(k);l.appendChild(g)}d.appendChild(a.newFormulaTextNode(a.narrowSpace));d.appendChild(a.newCurlyBracket(h));d.appendChild(l);d.appendChild(a.separatorNode.cloneNode(!0));d.appendChild(a.newFormulaTextNode(a.narrowSpace));return d};a.newCurlyBracket=function(a){var e=document.createDocumentFragment(),d=document.createElement("div");d.setAttribute("class","CurlyBracket");d.setAttribute("contenteditable","false");d.setAttribute("data-noedit","true");for(var l=0,c=2*a-1;l<c;l++){a=
0==l?"\u23a7":l==c-1?"\u23a9":l==parseInt(c/2)?"\u23a8":"\u23aa";var g=document.createElement("span");g.innerHTML=a;d.appendChild(g)}e.appendChild(d);return e};a.adjustFormulaFontSize=function(h,e){for(var d,l,c,g=0,k=h.children.length;g<k;g++)d=h.children[g],l=d.getAttribute("class")||" ",c=e,l&&(l.match("FormulaNode")?c=parseInt(d.style["font-size"]):l.match("SuperIndexNode")||l.match("SubIndexNode")?(c=Math.max(Math.floor(c-c/3),8),d.style["font-size"]=c+"px",d.style["line-height"]=c+"px"):l.match("FractionNode")?
(c=Math.max(Math.round(c-.1*c),8),d.style["font-size"]=c+"px",d.style["line-height"]=c+"px"):l.match("IndexNode")?(c=Math.max(Math.round(c-.2*c),8),d.style["font-size"]=c+"px",d.style["line-height"]=c+"px"):l.match("LimitFromToNode")?(d.style["font-size"]=c+"px",d.style["line-height"]=c+"px"):l.match("ToNode")||l.match("FromNode")?(d.style["font-size"]=c+"px",d.style["line-height"]=c+"px",c=Math.max(Math.round(c-.2*c),8)):c&&(d.style["font-size"]=c+"px",d.style["line-height"]=c+"px")),a.adjustFormulaFontSize(d,
c)};a.adjustHeight=function(h){for(var e,d,l,c,g=0,k=h.children.length;g<k;g++){e=h.children[g];d=e.getAttribute("class");a.adjustHeight(e);c=parseInt(e.offsetHeight);if("FractionNode"==d)e.style.verticalAlign=parseInt(e.style.fontSize)/3+"px";else if("SuperIndexNode"==d)e.style.verticalAlign=.5*l+"px";else if("SubIndexNode"==d)e.style.verticalAlign=.28*-l+"px";else if("IndexNode"==d)e.style.verticalAlign=.7*c+"px";else if("RadicalNode"==d)d=a.getChildrenByType(e,"RadicalSign"),e=a.getChildrenByType(e,
"RadicandNode"),d.style.fontSize=e.offsetHeight+"px",d.style.lineHeight="85%",d.style.height=e.offsetHeight+"px",d.style.verticalAlign="bottom",e.style.marginLeft=-(e.offsetHeight/31)+"px";else if("SumNode"==d)d=a.getChildrenByType(e,"SumContainer"),a.getChildrenByType(d,"SumToNode"),l=a.getChildrenByType(d,"SigmaSign"),a.getChildrenByType(d,"SumFromNode"),a.getChildrenByType(e,"SumWhatNode"),d.style.verticalAlign=parseInt(.9*l.offsetHeight)+"px";else if("IntegralNode"==d){d=a.getChildrenByType(e,
"IntegralContainer");l=a.getChildrenByType(d,"IntegralToNode");var b=a.getChildrenByType(d,"IntegralSign"),v=a.getChildrenByType(d,"IntegralFromNode");a.getChildrenByType(e,"IntegralWhatNode");d.style.verticalAlign=parseInt(.9*b.offsetHeight)+"px";l.style.paddingLeft=1.5*b.offsetWidth+"px";v.style.paddingLeft=b.offsetWidth/2+"px"}else if("MatrixNode"==d){l=e.querySelectorAll(".MatrixElementNode");b=maxH=-1E4;for(d=0;d<l.length;d++)b=Math.max(b,l[d].offsetWidth),maxH=Math.max(maxH,l[d].offsetHeight);
for(d=0;d<l.length;d++)l[d].parentNode.style.width=b+"px",l[d].parentNode.style.height=maxH+"px"}else if("CasesNode"==d){l=e.querySelectorAll(".CasesElementNode");b=maxH=-1E4;for(d=0;d<l.length;d++)b=Math.max(b,l[d].offsetWidth),maxH=Math.max(maxH,l[d].offsetHeight);for(d=0;d<l.length;d++)l[d].parentNode.style.width=b+"px",l[d].parentNode.style.height=maxH+"px";if(e.previousSibling)for(l=e.offsetHeight/e.previousSibling.children.length,d=0,b=e.previousSibling.children.length;d<b;d++)e.previousSibling.children[d].style.height=
l+"px",e.previousSibling.children[d].style.fontSize=.8*l+1+"px",d==parseInt(b/2)?e.previousSibling.children[d].style.lineHeight=2.3*l+"px":e.previousSibling.children[d].style.lineHeight=1.5*l+"px"}l=c}};return a}(richTextEditor||{}),descartesJS=function(a){function h(a){var b=document.createDocumentFragment(),c,d;0===a.children.length&&(d=richTextEditor.newFormulaTextNode(richTextEditor.narrowSpace),b.appendChild(d));for(var e=0;e<a.children.length;e++){c=a.children[e];if("text"===c.nodeType)d=richTextEditor.newFormulaTextNode(c.value);
else if("dynamicText"===c.nodeType)d=richTextEditor.newDynamicTextNode(c);else if("mathSymbol"===c.nodeType)d=richTextEditor.newMathSymbolNode(c.value);else if("superIndex"===c.nodeType)d=richTextEditor.newSuperIndexNode(h(c));else if("subIndex"===c.nodeType)d=richTextEditor.newSubIndexNode(h(c));else if("fraction"===c.nodeType)d=richTextEditor.newFractionNode(h(c.children[0]),h(c.children[1]));else if("radical"===c.nodeType)d=richTextEditor.newRadicalNode(h(c.children[0]),h(c.children[1]));else if("sum"===
c.nodeType)d=richTextEditor.newSumNode(h(c.children[1]),h(c.children[0]),h(c.children[2]));else if("integral"===c.nodeType)d=richTextEditor.newIntegralNode(h(c.children[1]),h(c.children[0]),h(c.children[2]));else if("limit"===c.nodeType)d=richTextEditor.newLimitNode(h(c.children[1]),h(c.children[0]),h(c.children[2]));else if("matrix"===c.nodeType){d=[];for(var g=0,k=c.children.length;g<k;g++)d.push(h(c.children[g]));d=richTextEditor.newMatrixNode(c.rows,c.columns,d)}else if("defparts"===c.nodeType){d=
[];for(g=0;g<c.parts;g++)d.push(h(c.children[g]));d=richTextEditor.newCasesElementNode(c.parts,d)}else d=document.createDocumentFragment(),console.log(">>>",c,"<<<");b.appendChild(d)}return b}if(a.loadLib)return a;var e=Math.floor,d=Math.max,l=2,c=!1,g;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 k=0,b=0,v=0,u;a.RTFNode.prototype.getTextMetrics=function(){this.spaceWidth=a.getTextWidth(" ",this.styleString);var e=k,g=b,h=v;if("textBlock"==this.nodeType)for(h=0,e=this.children.length;h<
e;h++)this.children[h].getTextMetrics();else if("textLineBlock"==this.nodeType)this.getBlockMetric();else if("newLine"==this.nodeType)u=a.getFontMetrics(this.styleString),this.w=0,this.h=u.h,this.baseline=u.baseline,this.descent=u.descent,this.ascent=u.ascent;else if("text"==this.nodeType||"dynamicText"==this.nodeType)u=a.getFontMetrics(this.styleString),this.baseline=u.baseline,this.descent=u.descent,this.ascent=u.ascent,g=this.value,"string"!=typeof this.value&&(h=void 0==this.decimals?l:this.evaluator.eval(this.decimals),
e=void 0==this.fixed?c:this.fixed,g=this.evaluator.eval(this.value,h,e),parseFloat(g).toString()===g.toString()&&(g=e?parseFloat(g).toFixed(h):a.removeNeedlessDecimals(parseFloat(g).toFixed(h)),g=(""+g).replace(".",this.decimal_symbol)),g+=" "),this.w=a.getTextWidth(g,this.styleString),this.h=u.h;else if("formula"==this.nodeType)this.getBlockMetric();else if("hyperlink"===this.nodeType){u=a.getFontMetrics(this.styleString);this.w=a.getTextWidth(this.value,this.styleString);this.h=u.h;this.baseline=
u.baseline;this.descent=u.descent;this.ascent=u.ascent;this.clickCacher=document.createElement("div");this.clickCacher.setAttribute("style","position:absolute; width:"+this.w+"px; height:"+this.h+"px; cursor:pointer;");var x=new a.OpenURL(this.evaluator.parent,this.URL),f=this;this.clickCacher.addEventListener("click",function(a){f.click=!0;x.actionExec()})}else if("superIndex"==this.nodeType)u=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=u.ascent,this.descent=u.descent,
this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),h=h/2-g+this.h,this.superIndexPos=h-this.ascent,this.ascent=h,this.descent=g,this.baseline=this.ascent,this.h=this.ascent+this.descent;else if("subIndex"==this.nodeType)u=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.h&&(this.ascent=u.ascent,this.descent=u.descent,this.h=this.ascent+this.descent,this.w=1.5*this.spaceWidth),this.subIndexPos=g+1,this.ascent=e,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,
this.h=this.ascent+this.descent;else if("fraction"==this.nodeType){var e=this.children[0],q=this.children[1];u=a.getFontMetrics(e.styleString);e.getBlockMetric();q.getBlockMetric();0>e.h&&(e.h=u.h,e.w=this.spaceWidth);0>q.h&&(q.h=u.h,q.w=this.spaceWidth);this.h=e.h+q.h-1;this.ascent=e.h+Math.round(h/2)-g;this.descent=this.h-this.ascent;this.baseline=this.ascent;this.w=d(e.w,q.w)+this.spaceWidth+8}else if("radical"==this.nodeType){g=this.children[0].style.clone();if(1===this.children.length)this.children[1]=
new a.RTFNode(this.evaluator," ","radicand",g),this.children[1].addChild(this.children[0]),this.children[0]=new a.RTFNode(this.evaluator," ","index",g);else if("index"!==this.children[0].nodeType||"radicand"!==this.children[1].nodeType){q=new a.RTFNode(this.evaluator,"","radicand",g);h=0;for(e=this.children.length;h<e;h++)q.addChild(this.children[h]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",g);this.children[1]=q}h=this.children[0];e=this.children[1];0>=h.children.length&&
(g=this.style.clone(),g.fontSize=parseInt(g.fontSize-.2*g.fontSize),h.addChild(new a.RTFNode(this.evaluator," ","text",g)));0>=e.children.length&&e.addChild(new a.RTFNode(this.evaluator," ","text",this.style.clone()));h.getBlockMetric();e.getBlockMetric();this.ascent=e.h/2<h.h?e.h/2+h.h+2-e.descent:e.ascent+4;this.descent=e.descent;this.baseline=this.ascent;this.h=this.ascent+this.descent;this.w=h.w+e.w+4*this.spaceWidth}else if("sum"==this.nodeType||"integral"==this.nodeType)g=this.children[0],h=
this.children[1],e=this.children[2],g.getBlockMetric(),h.getBlockMetric(),e.getBlockMetric(),-1==g.ascent&&(q=a.getFontMetrics(g.styleString),g.ascent=q.ascent,g.descent=q.descent,g.h=q.h),-1==h.ascent&&(q=a.getFontMetrics(h.styleString),h.ascent=q.ascent,h.descent=q.descent,h.h=q.h),u=a.getFontMetrics(this.styleString),this.ascent=u.h+h.h>e.ascent?u.h-u.descent+h.h:e.ascent,this.descent=g.h>e.descent?g.h+u.descent:e.descent,this.baseline=this.ascent,this.h=this.ascent+this.descent,q=this.style.clone(),
q.fontType=a.serif_font,q.Bold="bold","sum"==this.nodeType?(q=q.toString(),q=a.getTextWidth(String.fromCharCode(8721),q),this.w=d(g.w,h.w,q)+d(e.w,this.spaceWidth)+this.spaceWidth):"integral"==this.nodeType&&(q.fontSize*=1.5,q=q.toString(),q=a.getTextWidth(String.fromCharCode(8747),q),this.w=d(g.w,h.w,q)+d(e.w,this.spaceWidth)+2*this.spaceWidth);else if("limit"==this.nodeType)g=this.children[0],h=this.children[1],e=this.children[2],u=a.getFontMetrics(this.styleString),g.getBlockMetric(),h.getBlockMetric(),
e.getBlockMetric(),-1==g.ascent&&(q=a.getFontMetrics(g.styleString),g.ascent=q.ascent,g.descent=q.descent,g.h=q.h),-1==h.ascent&&(q=a.getFontMetrics(h.styleString),h.ascent=q.ascent,h.descent=q.descent,h.h=q.h),-1==e.ascent&&(q=a.getFontMetrics(e.styleString),e.ascent=q.ascent,e.descent=q.descent,e.h=q.h),this.ascent=e.ascent,this.descent=d(u.h,g.h,h.h,e.descent),this.baseline=this.ascent,this.h=this.ascent+this.descent,q=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==g.w&&(g.w=
this.spaceWidth),0==h.w&&(h.w=this.spaceWidth),0==e.w&&(e.w=this.spaceWidth),this.w=h.w+g.w+e.w+q+this.spaceWidth;else if("matrix"==this.nodeType){u=a.getFontMetrics(this.styleString);for(var q=u.ascent,m=u.descent,w=u.h,y=this.spaceWidth,B,E,h=0,e=this.children.length;h<e;h++)this.children[h].getBlockMetric(),B=this.children[h].h,E=this.children[h].w,w<B&&(w=B,q=this.children[h].ascent,m=this.children[h].descent),y<E&&(y=E);this.childWidth=y+2*this.spaceWidth;this.childHeight=w;this.childAscent=
q;this.childDescent=m;this.h=this.rows*w;this.ascent=this.h/2;this.descent=this.h/2;this.w=this.columns*this.childWidth+this.spaceWidth}else if("defparts"==this.nodeType){u=a.getFontMetrics(this.styleString);q=u.ascent;m=u.descent;w=u.h;y=this.spaceWidth;h=0;for(e=this.children.length;h<e;h++)this.children[h].getBlockMetric(),B=this.children[h].h,E=this.children[h].w,w<B&&(w=B,q=this.children[h].ascent,m=this.children[h].descent),y<E&&(y=E);this.childWidth=y+2*this.spaceWidth;this.childHeight=w;this.childAscent=
q;this.childDescent=m;this.h=this.parts*w;this.ascent=this.h/2+g;this.descent=this.h-this.ascent;this.w=this.childWidth+ +this.spaceWidth/2}else"mathSymbol"==this.nodeType?(u=a.getFontMetrics(this.styleString),this.baseline=u.baseline,this.descent=u.descent,this.ascent=u.ascent,this.w=a.getTextWidth(this.value,this.styleString)+this.spaceWidth,this.h=u.h):"componentNumCtrl"==this.nodeType?(u=a.getFontMetrics(this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),
this.baseline=u.baseline-2,this.descent=u.descent-2,this.ascent=u.ascent+2,this.h=this.componentNumCtrl.h||1,this.w=this.componentNumCtrl.w||1):"componentSpace"==this.nodeType?(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,d,e=0,f=this.children.length;e<f;e++){d=this.children[e];
d.getTextMetrics();childAscent=d.ascent;childDescent=d.descent;this.w+=d.w;var g=childDescent;d=d.h;k=childAscent;b=g;v=d;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,e,f,h,k,u){g=u;a.textAlign="start";a.textBaseline="alphabetic";this.stableWidth||(l=e,c=f,this.getTextMetrics());k=k?-this.children[0].ascent:0;u=f=e=0;for(var v=this.children.length;u<
v;u++)0<u&&(f+=this.children[u-1].h),"center"==h?e=-this.children[u].w/2:"right"==h&&(e=-this.children[u].w),this.children[u].draw(a,b+e,d+k+f)};a.RTFNode.prototype.drawTextLineBlock=function(a,b,c){for(var d=0,e=0,h=this.children.length;e<h;e++)a.strokeStyle=a.fillStyle=g,0<e&&(d+=this.children[e-1].w,"formula"==this.children[e-1].nodeType&&(d+=2*this.children[e-1].spaceWidth)),this.children[e].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<
g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+this.spaceWidth+d,c)};a.RTFNode.prototype.drawText=function(a,b,c){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.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,d,g){var h=e(.5*this.spaceWidth),f=void 0==this.decimals?l:this.evaluator.eval(this.decimals),k=void 0==this.fixed?c:this.fixed,m=this.evaluator.eval(this.value);parseFloat(m).toString()===m.toString()&&(m=k?parseFloat(m).toFixed(f):a.removeNeedlessDecimals(parseFloat(m).toFixed(f)),
m=(""+m).replace(".",this.decimal_symbol));null!=this.color&&(b.fillStyle=this.color);b.font=this.styleString;this.w=a.getTextWidth(m,this.styleString);b.fillText(m,h+d,g);this.underline&&(k=(f="bold"==this.style.textBold)?1:.5,b.lineWidth=f?2:1,null!=this.color&&(b.strokeStyle=this.color),b.beginPath(),b.moveTo(h+d-1,parseInt(g+this.descent/2)+k),b.lineTo(h+d-1+this.w,parseInt(g+this.descent/2)+k),b.stroke());this.overline&&(k=(f="bold"==this.style.textBold)?2:1.5,b.lineWidth=f?2:1,null!=this.color&&
(b.strokeStyle=this.color),b.beginPath(),b.moveTo(h+d-1,parseInt(g-this.ascent)+k),b.lineTo(h+d-1+this.w,parseInt(g-this.ascent)+k),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.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=e(this.spaceWidth);this.children[0].draw(a,b,e(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,e(c+this.children[1].descent-this.children[1].h/2));a.lineTo(b+this.children[0].w,e(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=e(.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,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,b,c){for(var d=0,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c-this.superIndexPos)};a.RTFNode.prototype.drawLimit=
function(b,c,d){var e=a.getFontMetrics(this.styleString),f=" "+String.fromCharCode(8594),g=a.getTextWidth(f,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.fillText("l\u00edm",c+this.children[0].w,d);b.fillText(f,c+this.children[0].w,d+e.descent+
this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(b,c,g){var h=this.style.clone();h.fontSize*=1.5;h.fontType=a.serif_font;h.Bold="bold";var h=h.toString(),f=a.getTextWidth(String.fromCharCode(8747),h),k=a.getFontMetrics(h),m=d(this.children[0].w,this.children[1].w,e(1.5*f));this.children[0].draw(b,c+f,g+k.descent+this.children[0].ascent);this.children[1].draw(b,c+f+this.spaceWidth/2,g-this.ascent+this.children[1].ascent);this.children[2].draw(b,c+m+f,g);null!=this.color&&(b.fillStyle=
this.color);b.font=h;b.fillText(String.fromCharCode(8747),c,g+k.descent/2)};a.RTFNode.prototype.drawSum=function(b,c,g){var h=this.style.clone();h.fontType=a.serif_font;h.Bold="bold";var h=h.toString(),f=a.getTextWidth(String.fromCharCode(8721),h),k=a.getFontMetrics(this.styleString),m=d(this.children[0].w,this.children[1].w,f);this.children[0].draw(b,c+(m-this.children[0].w)/2,g+k.descent+this.children[0].ascent);this.children[1].draw(b,c+(m-this.children[1].w)/2,g-k.ascent-this.children[1].descent);
this.children[2].draw(b,c+m,g);null!=this.color&&(b.fillStyle=this.color);b.font=h;b.fillText(String.fromCharCode(8721),c+e((m-f)/2),g-5)};a.RTFNode.prototype.drawMatrix=function(a,b,c){for(var d,f,g=0,h=this.children.length;g<h;g++)d=g%this.columns,f=e(g/this.columns),this.children[g].draw(a,2*this.spaceWidth+b+d*this.childWidth,c-this.ascent+this.childAscent+f*this.childHeight);a.lineWidth=1.5;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(e(b+this.spaceWidth)+.5,c-this.ascent+
.5);a.lineTo(e(b+this.spaceWidth/2)+.5,c-this.ascent+.5);a.lineTo(e(b+this.spaceWidth/2)+.5,c+this.descent+.5);a.lineTo(e(b+this.spaceWidth)+.5,c+this.descent+.5);a.moveTo(e(b+this.w-this.spaceWidth)-.5,c-this.ascent+.5);a.lineTo(e(b+this.w-this.spaceWidth/2)-.5,c-this.ascent+.5);a.lineTo(e(b+this.w-this.spaceWidth/2)-.5,c+this.descent+.5);a.lineTo(e(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+this.style.fontSize/2,c-this.ascent+this.childAscent+d%this.parts*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(parseInt(b+.4*this.style.fontSize)+.5,c-this.ascent-1.5);a.lineTo(parseInt(b+.18*this.style.fontSize)+.5,c-this.ascent+3.5);a.lineTo(parseInt(b+.18*this.style.fontSize)+.5,c+this.descent-this.h/2-4.5);a.lineTo(b,c+this.descent-this.h/2);a.lineTo(parseInt(b+.18*this.style.fontSize)+.5,c+this.descent-this.h/2+4.5);a.lineTo(parseInt(b+
.18*this.style.fontSize)+.5,c+this.descent-3.5);a.lineTo(parseInt(b+.4*this.style.fontSize)+.5,c+this.descent+1.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.fillText("(",b,c)):")"==this.value?(a.font=this.styleString,a.fillText(")",b+this.spaceWidth,c)):(a.font=this.styleString,a.fillText(this.value,b,c))};a.RTFNode.prototype.drawGenericBlock=
function(a,b,c){for(var d=0,e=0,g=this.children.length;e<g;e++)0<e&&(d+=this.children[e-1].w),this.children[e].draw(a,b+d,c)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,b,c){this.parent.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+b+","+(c-this.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,b,c){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(b.toString());
this.componentSpace.yExpr=this.evaluator.parser.parse((c-this.parent.ascent).toString())};a.RTFNode.prototype.draw=function(a,b,c){console.log(">>> Dibujo desconocido ",this.nodeType)};a.RTFNode.prototype.toHTML=function(a){return this.toHTMLAux(a)};a.RTFNode.prototype.toHTMLAux=function(a){var b=document.createDocumentFragment(),c=this.style?this.style.toCSS():"";if("textBlock"===this.nodeType)for(var c=richTextEditor.newTextBlock(),d=0,e=this.children.length;d<e;d++)c.appendChild(this.children[d].toHTMLAux(a));
else if("textLineBlock"===this.nodeType)for(c=richTextEditor.newTextLineBlock(),d=0,e=this.children.length;d<e;d++)c.appendChild(this.children[d].toHTMLAux(a));else"text"===this.nodeType?c=richTextEditor.newTextNode(c,this.value):"newLine"===this.nodeType?c=richTextEditor.newNewLine(c):"hyperlink"===this.nodeType?c=richTextEditor.newHyperLink(c,this.value,this.URL):"formula"===this.nodeType?c=richTextEditor.newFormula(c,h(this)):"componentSpace"===this.nodeType?(a.spaces.push({cID:"cID_"+this.value,
value:this.componentSpace}),c=richTextEditor.newComponentSpace(this.componentSpace.w,this.value)):"componentNumCtrl"===this.nodeType?(a.ctrs.push({cID:"cID_"+this.value,value:this.componentNumCtrl}),c=richTextEditor.newComponentNumCtrl(this.componentSpace.w,this.componentSpace.h,this.value)):(c=document.createDocumentFragment(),console.log(">>>",this,"<<<"));b.appendChild(c);return b};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=String.fromCharCode,e,d,l,c,g,k,b,
v,u,n,r,p;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[];e=[];d=a.length;e=[];l="";g=c=0;b=a.charAt(0);v=!1;for(u="text";c<d;)k=b,b=a.charAt(c+1),v?"\\"===b||"{"===b||"}"===b||" "===b||";"===b?(v=!1,l+=k," "===b?(c++,
b=a.charAt(c+1),p=!0):p=!1,(n=l.match(/^\'([0-9a-f]{2})/))?(r="","text"===u&&(r=e.pop().value),l=r+=h(parseInt(n[1],16))+l.substring(3)):(n=l.match(/^u[0-9]+/))?(r="","text"===u&&(r=e.pop().value),l=r+=h(n[0].substring(1))):("{"===l||"}"===l||"\\"==k?(e.push({type:"text",value:l+(p?" ":"")}),u="text"):(e.push({type:"controlWord",value:l}),u="controlWord"),l="")):"{"==k||"}"==k||"\\"==k?(v=!1,e.push({type:"text",value:k}),u="text"):l+=k:"\\"===k?(v=!0,""!==l&&(e.push({type:"text",value:l}),u="text"),
l=""):"{"===k?(g++,""!==l&&e.push({type:"text",value:l}),l="",e.push({type:"openBlock",value:g}),u="openBlock"):"}"===k?(""!==l&&e.push({type:"text",value:l}),l="",e.push({type:"closeBlock",value:g}),u="closeBlock",g--):l+=k,c++;""!==l&&e.push({type:"text",value:l});return e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h=Math.max,e,d,l,c,g,k,b,v,u,n,r,p,x,f,q,m,w,y,B,E,F,D,G,H,K,C,A,I,J,M;a.RTFParser=function(b){this.evaluator=b;this.tokenizer=new a.RTFTokenizer};
a.RTFParser.prototype.parse=function(z){z=e=this.tokenizer.tokenize(z);for(var O=[],L=!1,N=!1,R=[],P=0,U=z.length;P<U;P++)if("openBlock"==z[P].type&&R.push(z[P].value),"closeBlock"==z[P].type&&(R.pop(),0>=R.length&&(L=!1)),"controlWord"!=z[P].type||"expr"!=z[P].value&&"decimals"!=z[P].value||(N=!0),"controlWord"==z[P].type&&"mjaformula"==z[P].value&&(L=!0),"text"==z[P].type&&L&&!N){for(var T=0,S=z[P].value,Q=0,ba=S.length;Q<ba;Q++)if("("==S.charAt(Q)||")"==S.charAt(Q)||"+"==S.charAt(Q)||"-"==S.charAt(Q)||
"*"==S.charAt(Q)||"="==S.charAt(Q))T=S.substring(T,Q),""!=T&&O.push({type:"text",value:T}),O.push({type:S.charAt(Q),value:S.charAt(Q)}),T=Q+1;T=S.substring(T,Q);""!=T&&O.push({type:"text",value:T})}else O.push(z[P]),"text"==z[P].type&&N&&(N=!1);e=O;d={};c=2;if("openBlock"==e[0].type&&"fonttbl"==e[1].value){for(l=e[0].value;"closeBlock"!=e[c].type&&e[c].value!=l;)d[e[c].value]=e[c+2].value.substring(0,e[c+2].value.length-1),c+=3;c++}g={};k=0;if("openBlock"==e[c].type&&"colortbl"==e[c+1].value){l=e[c++].value;
for(c++;"closeBlock"!=e[c].type&&e[c].value!=l;)b=parseInt(e[c++].value.substring(3)).toString(16),v=parseInt(e[c++].value.substring(5)).toString(16),u=parseInt(e[c++].value.substring(4)).toString(16),";"===e[c].value&&c++,g[k++]="#"+(2>b.length?"0"+b:b)+(2>v.length?"0"+v:v)+(2>u.length?"0"+u:u);c++}n=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");r=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");n.addChild(r);f=x=p=null;E=B=y=w=m=q=!1;F=[new a.FontStyle(20,"Arial","","",!1,!1,null)];
D=F[0];G=!0;K=H=-1;C=[];M=J=I=A=!1;z=c;for(O=e.length;z<O;z++)if("controlWord"==e[z].type&&d[e[z].value])D.fontType=d[e[z].value];else if("controlWord"==e[z].type&&e[z].value.match(/^fs(\d+)/))D.fontSize=parseInt(e[z].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==e[z].type&&"b"==e[z].value)D.textBold="bold";else if("controlWord"==e[z].type&&"b0"==e[z].value)D.textBold="";else if("controlWord"==e[z].type&&"i"==e[z].value)D.textItalic="italic";else if("controlWord"==e[z].type&&"i0"==e[z].value)D.textItalic=
"";else if("controlWord"==e[z].type&&"ul"==e[z].value)D.textUnderline=!0;else if("controlWord"==e[z].type&&"ulnone"==e[z].value)D.textUnderline=!1;else if("controlWord"==e[z].type&&"ol"==e[z].value)D.textOverline=!0;else if("controlWord"==e[z].type&&"olnone"==e[z].value)D.textOverline=!1;else if("controlWord"==e[z].type&&e[z].value.match(/^cf(\d+)/))D.textColor=g[parseInt(e[z].value.substring(2))],0<C.length&&(C[C.length-1].style.textColor=D.textColor);else if("openBlock"==e[z].type)H=e[z].value,
D=D.clone(),F.push(D),C.push(null);else if("closeBlock"==e[z].type)e[z].value==K&&(K=-1,q=!1,r=r.parent),F.pop(),D=F[F.length-1],C.pop();else if("controlWord"==e[z].type&&"par"==e[z].value){r.addChild(new a.RTFNode(this.evaluator,"","newLine",D.clone()));n=new a.RTFNode(this.evaluator,"","textLineBlock",D.clone());if("textBlock"!=r.nodeType)for(r=r.parent;"textBlock"!=r.nodeType;)r=r.parent;r.addChild(n);r=n}else if("controlWord"==e[z].type&&"mjaformula"==e[z].value)A=!0,K=H,q=!0,n=new a.RTFNode(this.evaluator,
"","formula",D.clone()),r.addChild(n),r=n,C[C.length-1]=n;else if("controlWord"==e[z].type&&("fraction"==e[z].value||"radicand"==e[z].value||"radical"==e[z].value||"what"==e[z].value||"sum"==e[z].value||"integral"==e[z].value||"limit"==e[z].value))L=C[C.length-2].style.clone(),n=new a.RTFNode(this.evaluator,"",e[z].value,L),C[C.length-2].addChild(n),C[C.length-1]=n;else if("controlWord"==e[z].type&&"index"==e[z].value||"to"==e[z].value||"from"==e[z].value)L=C[C.length-2].style.clone(),L.fontSize=
h(parseInt(L.fontSize-.2*L.fontSize),8),n=new a.RTFNode(this.evaluator,"",e[z].value,L),C[C.length-2].addChild(n),C[C.length-1]=n;else if("controlWord"==e[z].type&&("num"==e[z].value||"den"==e[z].value))L=C[C.length-2].style.clone(),L.fontSize=h(Math.round(L.fontSize-.1*L.fontSize),8),"num"==e[z].value?n=new a.RTFNode(this.evaluator,"","numerator",L):"den"==e[z].value&&(n=new a.RTFNode(this.evaluator,"","denominator",L)),C[C.length-2].addChild(n),C[C.length-1]=n;else if("controlWord"==e[z].type&&
("subix"==e[z].value||"supix"==e[z].value))L=C[C.length-2].style.clone(),L.fontSize=h(Math.floor(L.fontSize-L.fontSize/3),8),"subix"==e[z].value?n=new a.RTFNode(this.evaluator,"","subIndex",L):"supix"==e[z].value&&(n=new a.RTFNode(this.evaluator,"","superIndex",L)),n.originalStyle=C[C.length-2].style.clone(),C[C.length-2].addChild(n),C[C.length-1]=n;else if("controlWord"==e[z].type&&("defparts"==e[z].value||"matrix"==e[z].value||"element"==e[z].value))L=C[C.length-2].style.clone(),n=new a.RTFNode(this.evaluator,
"",e[z].value,L),C[C.length-2].addChild(n),C[C.length-1]=n,"defparts"==e[z].value?f=n:"matrix"==e[z].value&&(x=n);else if("controlWord"==e[z].type&&"parts"==e[z].value)E=!0;else if("text"==e[z].type&&E)f.parts=parseInt(e[z].value),E=!1;else if("controlWord"==e[z].type&&"rows"==e[z].value)y=!0;else if("text"==e[z].type&&y)x.rows=parseInt(e[z].value),y=!1;else if("controlWord"==e[z].type&&"columns"==e[z].value)B=!0;else if("text"==e[z].type&&B)x.columns=parseInt(e[z].value),B=!1;else if("controlWord"==
e[z].type&&"expr"==e[z].value)G=!1,m=!0;else if("controlWord"==e[z].type&&"decimals"==e[z].value)w=!0;else if("text"==e[z].type&&w)p.decimals=this.evaluator.parser.parse(e[z].value+""),w=!1;else if("controlWord"==e[z].type&&"fixed1"==e[z].value)p.fixed=!0;else if("controlWord"==e[z].type&&"fixed0"==e[z].value)p.fixed=!1;else if("controlWord"!=e[z].type||"component"!=e[z].value)if("controlWord"==e[z].type&&"NumCtrl"==e[z].value)I=!0;else if("controlWord"==e[z].type&&"Space"==e[z].value)J=!0;else if("controlWord"==
e[z].type&&"hyperlink"==e[z].value)M=!0;else if("text"==e[z].type&&M){textContent=e[z].value.split("|")[0];L=D.clone();n=new a.RTFNode(this.evaluator,textContent,"hyperlink",L);n.URL=e[z].value.split("|")[1];if("textLineBlock"!=r.nodeType)for(r=r.parent;"textLineBlock"!=r.nodeType;)r=r.parent;r.addChild(n);M=!1}else if("text"==e[z].type&&I)n=new a.RTFNode(this.evaluator,e[z].value,"componentNumCtrl",D.clone()),r.addChild(n),I=!1;else if("text"==e[z].type&&J)n=new a.RTFNode(this.evaluator,e[z].value,
"componentSpace",D.clone()),r.addChild(n),J=!1;else if("text"==e[z].type&&m)L=C[C.length-2].style.clone(),textContent=this.evaluator.parser.parse(e[z].value),n=new a.RTFNode(this.evaluator,textContent,"dynamicText",L),C[C.length-2].addChild(n),p=C[C.length-1]=n,m=!1;else if("text"==e[z].type&&!m&&!q){textContent=e[z].value;n=new a.RTFNode(this.evaluator,textContent,"text",D.clone());if("textLineBlock"!=r.nodeType)for(r=r.parent;"textLineBlock"!=r.nodeType;)r=r.parent;r.addChild(n)}else if("text"==
e[z].type&&!m&&q)textContent=e[z].value,n=new a.RTFNode(this.evaluator,textContent,"text",C[C.length-1].style.clone()),C[C.length-1].addChild(n);else if("("==e[z].type||")"==e[z].type)L=C[C.length-1].style.clone(),L.textItalic="",n=new a.RTFNode(this.evaluator,e[z].type,"mathSymbol",L),C[C.length-1].addChild(n);else if("+"==e[z].type||"-"==e[z].type||"*"==e[z].type||"="==e[z].type)n=new a.RTFNode(this.evaluator,e[z].type,"mathSymbol",C[C.length-1].style.clone()),C[C.length-1].addChild(n);if(null!=
r){var V=r.getRoot();V.stableWidth=G;V.getTextMetrics();V.hasFormula=A}return V};a.FontStyle=function(a,b,c,d,e,f,g){this.fontSize=a;this.fontType=b;this.textItalic=c;this.textBold=d;this.textUnderline=e;this.textOverline=f;this.textColor=g};a.FontStyle.prototype.toString=function(){/arial/i.test(this.fontType)?this.fontType=a.sansserif_font:/times/i.test(this.fontType)?this.fontType=a.serif_font:/courier/i.test(this.fontType)&&(this.fontType=a.monospace_font);return(this.textBold+" "+this.textItalic+
" "+this.fontSize+"px "+this.fontType).trim()};a.FontStyle.prototype.toCSS=function(a){var b="";a||(b="font-size:"+this.fontSize+"px; line-height:"+this.fontSize+"px; font-family:"+this.fontType+";",this.textUnderline&&!this.textOverline&&(b+="text-decoration:underline;"),!this.textUnderline&&this.textOverline&&(b+="text-decoration:overline;"),this.textUnderline&&this.textOverline&&(b+="text-decoration:underline overline;"),this.textBold&&!this.textItalic&&(b+="font-style:normal; font-weight:bold;"),
!this.textBold&&this.textItalic&&(b+="font-style:italic; font-weight:normal;"),this.textBold&&this.textItalic&&(b+="font-style:italic; font-weight:bold;"),this.textBold||this.textItalic||(b+="font-style:normal; font-weight:normal;"));this.textColor&&(b+="color:"+this.textColor+";");return b};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 h,e,d,l,c,g,k,b,v,u,n;a.Space=function(b,c){this.parent=b;e=this.evaluator=this.parent.evaluator;d=e.parser;this.id="";this.values=c;this.type="R2";this.xExpr=d.parse("0");this.yExpr=d.parse("0");this.w=parseInt(b.container.width);this.h=parseInt(b.container.height);this.drawif=d.parse("1");this.fixed=2==b.version;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=
new a.Color(/DescartesJS.class/i.test(b.code)||b.arquimedes?"f0f8fa":"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.y_axis=this.x_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.backGraphics=[];this.zIndex=b.zIndex;this.plecaHeight=
b.plecaHeight||0;this.displaceRegionNorth=b.displaceRegionNorth||0;this.displaceRegionWest=b.displaceRegionWest||0;for(var g in c)c.hasOwnProperty(g)&&(this[g]=c[g]);this.init()};a.Space.prototype.init=function(){h=this.parent;e=this.evaluator;l=this.id;this.displaceRegionNorth=h.displaceRegionNorth||0;this.displaceRegionSouth=h.displaceRegionSouth||0;this.displaceRegionEast=h.displaceRegionEast||0;this.displaceRegionWest=h.displaceRegionWest||0;b=parseInt(h.container.width);k=parseInt(h.container.height);
void 0!=this.wExpr&&(this.w=parseInt(b-this.displaceRegionWest-this.displaceRegionEast)*parseFloat(this.wExpr)/100);void 0!=this.hExpr&&(this.h=parseInt(k-this.displaceRegionNorth-this.displaceRegionSouth)*parseFloat(this.hExpr)/100);void 0!=this.xPercentExpr&&(this.xExpr=e.parser.parse((parseInt(b-this.displaceRegionWest-this.displaceRegionEast)*parseFloat(this.xPercentExpr)/100).toString()));void 0!=this.yPercentExpr&&(this.yExpr=e.parser.parse((parseInt(k-this.displaceRegionNorth-this.displaceRegionSouth)*
parseFloat(this.yPercentExpr)/100).toString()));this.x=e.eval(this.xExpr)+this.displaceRegionWest;this.y=e.eval(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+"px",this.container.style.top=this.y+"px");0<=this.y?(c=k-this.y,this.h>c&&(this.h=c)):(c=this.h+this.y,this.h=c>=k?k:c);0<=this.x?(g=b-this.x,this.w>g&&(this.w=g)):(g=this.w+this.x,this.w=g>=b?b:g);""==this.imageSrc&&/vacio.gif$/i.test(this.imageSrc.trim())||(this.image=h.getImage(this.imageSrc));
this.OxExpr&&(u=this.OxExpr,"%"===u[u.length-1]?this.Ox=this.w*parseFloat(u)/100:(v=parseFloat(u),v!=u&&(v=0),this.Ox=v));this.OyExpr&&(n=this.OyExpr,"%"===n[n.length-1]?this.Oy=this.h*parseFloat(n)/100:(v=parseFloat(n),v!=n&&(v=0),this.Oy=v));""!==this.id&&2!==h.version?(e.setVariable(l+"._w",this.w),e.setVariable(l+"._h",this.h),e.setVariable(l+".escala",this.scale),e.setVariable(l+".Ox",this.Ox),e.setVariable(l+".Oy",this.Oy),e.setVariable(l+".mouse_x",0),e.setVariable(l+".mouse_y",0),e.setVariable(l+
".mouse_pressed",0),e.setVariable(l+".mouse_clicked",0),e.setVariable(l+".clic_izquierdo",0)):(v=e.getVariable("_w"),void 0===v&&(v=this.w),e.setVariable("_w",v),v=e.getVariable("_h"),void 0===v&&(v=this.h),e.setVariable("_h",v),v=e.getVariable("escala"),void 0===v&&(v=this.scale),e.setVariable("escala",v),v=e.getVariable("Ox"),void 0===v&&(v=this.Ox),e.setVariable("Ox",v),v=e.getVariable("Oy"),void 0===v&&(v=this.Oy),e.setVariable("Oy",v),e.setVariable("mouse_x",0),e.setVariable("mouse_y",0),e.setVariable("mouse_pressed",
0),e.setVariable("mouse_clicked",0),e.setVariable("clic_izquierdo",0),2==h.version&&""===this.x_axis&&""===this.y_axis&&(this.axes=""));this.w_2=this.w/2;this.h_2=this.h/2};a.Space.prototype.addCtr=function(a){"graphic"===a.type?this.graphicsCtr.push(a):this.ctrs.push(a)};a.Space.prototype.addGraph=function(a,b){"R2"===this.type&&b||"R3"===this.type&&!b||(a.background&&"R3"!==this.type?this.backGraphics.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};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h;a.SpaceExternal=
function(a){h=this;h.parent=a;h.width=228;h.vSpace=25;h.container=document.createElement("div");h.container.setAttribute("style","box-sizing:border-box;border-style:ridge;border-width:5px;border-color:gray;box-shadow:#000 0 0 25px 5px;overflow-y:scroll;overflow-x:hidden;position:fixed;left:0;top:0;z-index:10000;width:"+(h.width+27)+"px;height:460px;background-color:#63b4fb");h.movable=document.createElement("div");h.movable.setAttribute("style"," position:absolute;left:0;top:0;width:"+(h.width+27)+
"px;height:"+h.vSpace+"px;line-height:"+h.vSpace+"px;background-color:#ddd;cursor:move;padding-left:75px;font-family:Sans-Serif;font-size:18px;");h.movable.innerHTML="Descartes";h.container.appendChild(h.movable);h.ctrs=[]};a.SpaceExternal.prototype.init=function(){function e(c){h.newPos=a.getCursorPosition(c,document.body);h.container.style.left=h.initialPosition.x+(h.newPos.x-h.oldPos.x)*a.cssScale+"px";h.container.style.top=h.initialPosition.y+(h.newPos.y-h.oldPos.y)*a.cssScale+"px"}function d(a){a.preventDefault();
document.body.removeEventListener("mousemove",e);document.body.removeEventListener("mouseup",d)}document.body.appendChild(this.container);h=this;for(var l=h.parent.evaluator.parser,c=0,g=h.ctrs.length;c<g;c++)h.ctrs[c].expresion=l.parse("(0,"+(h.vSpace+23+35*c)+","+h.width+",35)"),h.ctrs[c].update();h.numCtr=g;c=new a.Button(h.parent,{region:"external",name:"english"==h.language?"about":"cr\u00e9ditos",font_size:l.parse("15"),expresion:l.parse("(0,"+h.vSpace+","+h.width/2+",25)")});c.actionExec={execute:a.showAbout};
c.update();(new a.Button(h.parent,{region:"external",name:"config",font_size:l.parse("15"),action:"config",expresion:l.parse("("+h.width/2+","+h.vSpace+","+h.width/2+",25)")})).update();(new a.Button(h.parent,{region:"external",name:"english"==h.language?"init":"inicio",font_size:l.parse("15"),action:"init",expresion:l.parse("(0,"+(h.vSpace+23+35*g)+","+h.width/2+",25)")})).update();(new a.Button(h.parent,{region:"external",name:"english"==h.language?"clear":"limpiar",font_size:l.parse("15"),action:"clear",
expresion:l.parse("("+h.width/2+","+(h.vSpace+23+35*g)+","+h.width/2+",25)")})).update();l=new a.Button(h.parent,{region:"external",name:"english"==h.language?"close":"cerrar",font_size:l.parse("15"),expresion:l.parse("("+h.width/4+","+(h.vSpace+46+35*g)+","+h.width/2+",25)")});l.update();l.btn.addEventListener("click",function(a){h.hide()});h.setPositionAndSize();h.movable.addEventListener("mousedown",function(c){c.preventDefault();h.oldPos=a.getCursorPosition(c,document.body);h.initialPosition=
{x:h.container.offsetLeft,y:h.container.offsetTop};document.body.addEventListener("mousemove",e);document.body.addEventListener("mouseup",d)});h.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(){h=this;var a=h.vSpace+46+35*h.numCtr+25+10;
h.container.style.left=Math.max(parseInt(window.innerWidth-h.width)/2,0)+"px";h.container.style.top="5px";h.container.style.height=window.innerHeight<h.vSpace+75?h.vSpace+75+"px":a>window.innerHeight-10?window.innerHeight-10:a+"px"};return a}(descartesJS||{}),descartesJS=function(a){var h,e;if(a.loadLib)return a;var d=Math.floor,l=Math.round,c=2*Math.PI,g=a.convertFont("SansSerif,PLAIN,12"),k=a.convertFont("Monospaced,PLAIN,12"),b,v,u,n,r,p,x,f,q,m,w,y,B,E,F,D,G,H,K,C,A,I,J,M,z,O,L,N;a.Space2D=function(c,
d){a.Space.call(this,c,d);b=this;b.ratio=c.ratio;b.canvas=document.createElement("canvas");b.canvas.setAttribute("id",b.id+"_canvas");b.canvas.setAttribute("class","DescartesSpace2DCanvas");b.backCanvas=document.createElement("canvas");b.backCanvas.setAttribute("id",b.id+"_background");b.canvas.style.zIndex=b.zIndex;b.canvas.width=b.backCanvas.width=b.w*b.ratio;b.canvas.height=b.backCanvas.height=b.h*b.ratio;b.canvas.style.width=b.backCanvas.style.width=b.w+"px";b.canvas.style.height=b.backCanvas.style.height=
b.h+"px";b.ctx=b.canvas.getContext("2d");b.backCtx=b.backCanvas.getContext("2d");b.ctx.imageSmoothingEnabled=b.backCtx.imageSmoothingEnabled=!1;b.graphicControlContainer=document.createElement("div");b.graphicControlContainer.setAttribute("id",b.id+"_graphicControls");b.graphicControlContainer.setAttribute("style","position:absolute;left:0;top:0;z-index:"+b.zIndex+";");b.numericalControlContainer=document.createElement("div");b.numericalControlContainer.setAttribute("id",b.id+"_numericalControls");
b.numericalControlContainer.setAttribute("style","position:absolute;left:0;top:0;z-index:"+b.zIndex+";");b.container=document.createElement("div");b.container.setAttribute("id",b.id);b.container.setAttribute("class","DescartesSpace2DContainer");b.container.setAttribute("style","left:"+b.x+"px;top:"+b.y+"px;z-index:"+b.zIndex+";");b.parent.arquimedes&&"#f0f8fa"===b.background.getColor()&&(b.container.style.border="1px solid #b8c4c8");b.container.appendChild(b.backCanvas);b.container.appendChild(b.canvas);
b.container.appendChild(b.graphicControlContainer);b.container.appendChild(b.numericalControlContainer);c.container.insertBefore(b.container,c.loader);b.parent.images[b.id+".image"]=b.canvas;b.parent.images[b.id+".image"].ready=1;b.parent.images[b.id+".image"].complete=!0;b.parent.images[b.id+".image"].canvas=!0;b.evaluator.setVariable(b.id+".image",b.id+".image");b.parent.images[b.id+".back"]=b.backCanvas;b.parent.images[b.id+".back"].ready=1;b.parent.images[b.id+".back"].complete=!0;b.parent.images[b.id+
".back"].canvas=!0;b.evaluator.setVariable(b.id+".back",b.id+".back");var e=""!==b.id&&2!==c.version?b.id+".":"";b.OxStr=e+"Ox";b.OyStr=e+"Oy";b.scaleStr=e+"escala";b.wStr=e+"_w";b.hStr=e+"_h";b.mxStr=e+"mouse_x";b.myStr=e+"mouse_y";b.mpressedStr=e+"mouse_pressed";b.mclickedStr=e+"mouse_clicked";b.mclickIzqStr=e+"clic_izquierdo";b.click=0;"descartesJS_stage"!==b.id?b.addEvents():b.canvas.oncontextmenu=function(a){return!1}};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){b=this;b.uber.init.call(b);
b.canvas&&(b.canvas.width=b.backCanvas.width=b.w*b.ratio,b.canvas.height=b.backCanvas.height=b.h*b.ratio,b.canvas.style.width=b.backCanvas.style.width=b.w+"px",b.canvas.style.height=b.backCanvas.style.height=b.h+"px")};a.Space2D.prototype.update=function(a){b=this;v=b.evaluator;u=b.parent;v.setVariable(b.wStr,b.w);v.setVariable(b.hStr,b.h);b.drawIfValue=0<v.eval(b.drawif);if(b.drawIfValue){r=b.x!==v.eval(b.xExpr)+b.displaceRegionWest;p=b.y!==v.eval(b.yExpr)+u.plecaHeight+b.displaceRegionNorth;b.spaceChange=
a||r||p||b.drawBefore!==b.drawIfValue||b.Ox!==v.getVariable(b.OxStr)||b.Oy!==v.getVariable(b.OyStr)||b.scale!==v.getVariable(b.scaleStr)||b.backColor!==b.background.getColor();b.x=r?v.eval(b.xExpr)+b.displaceRegionWest:b.x;b.y=p?v.eval(b.yExpr)+u.plecaHeight+b.displaceRegionNorth:b.y;b.Ox=v.getVariable(b.OxStr);b.Oy=v.getVariable(b.OyStr);b.scale=v.getVariable(b.scaleStr);b.drawBefore=b.drawIfValue;b.scale=Math.max(1E-6,Math.min(1E6,b.scale));v.setVariable(b.scaleStr,b.scale);if(r||p)b.container.style.left=
b.x+"px",b.container.style.top=b.y+"px";b.container.style.display="block";b.drawTrace=!b.spaceChange&&(!b.fixed&&!b.click||b.fixed);b.spaceChange&&(b.backCtx.setTransform(b.ratio,0,0,b.ratio,0,0),b.drawBackground());b.ctx.setTransform(b.ratio,0,0,b.ratio,0,0);b.draw()}else b.container.style.display="none"};a.Space2D.prototype.drawBackground=function(){b=this;v=b.evaluator;n=b.backCtx;n.clearRect(0,0,b.backCanvas.width,b.backCanvas.height);b.backColor=b.background.getColor();n.fillStyle=b.backColor;
n.fillRect(0,0,b.backCanvas.width,b.backCanvas.height);b.image&&""!=b.image.src&&b.image.ready&&b.image.complete&&("topleft"===b.bg_display?n.drawImage(b.image,0,0):"stretch"===b.bg_display?n.drawImage(b.image,0,0,b.w,b.h):"patch"===b.bg_display?(n.fillStyle=n.createPattern(b.image,"repeat"),n.fillRect(0,0,b.w,b.h)):"imgcenter"===b.bg_display&&n.drawImage(b.image,(b.w-b.image.width)/2,(b.h-b.image.height)/2));f=b.scale;q=0;for(m=0>b.w+b.h?0:b.w+b.h;f>m;)f/=10,q++;for(;f<m/10;)f*=10;n.lineWidth=1;
""!==b.net&&(n.strokeStyle=b.net.getColor(),b.drawMarks(n,f/10,-1));if(2!==b.parent.version&&""!==b.net10||2===b.parent.version&&""!==b.net&&""!==b.net10)n.strokeStyle=b.net10.getColor(),b.drawMarks(n,f,-1);if(""!==b.axes){n.strokeStyle=b.axes.getColor();n.beginPath();if(""!==b.x_axis||2!==b.parent.version)n.moveTo(0,d(b.h/2+b.Oy)+.5),n.lineTo(b.w,d(b.h/2+b.Oy)+.5);if(""!==b.y_axis||2!==b.parent.version)n.moveTo(d(b.w/2+b.Ox)+.5,0),n.lineTo(d(b.w/2+b.Ox)+.5,b.h);n.stroke();b.drawMarks(n,f,4);b.drawMarks(n,
f/2,2);b.drawMarks(n,f/10,1)}if(""!==b.x_axis||""!==b.y_axis)n.fillStyle=""!==b.axes?b.axes.getColor():"#000",n.font=g,n.textAlign="right",n.textBaseline="alphabetic",n.fillText(b.x_axis,d(b.w)-2,d(b.h/2+b.Oy)+12),n.fillText(b.y_axis,d(b.w/2+b.Ox)-2,12);b.numbers&&""!=b.axes&&(n.fillStyle=b.axes.getColor(),n.font=g,n.textAlign="start",n.textBaseline="bottom",f>(b.w+b.h)/2?b.drawNumbers(n,f/5,f<=b.scale?q+1:q):f>(b.w+b.h)/4?b.drawNumbers(n,f/2,f<=b.scale?q+1:q):b.drawNumbers(n,f,q));for(var a=0,c=
b.backGraphics.length;a<c;a++)b.backGraphics[a].draw()};a.Space2D.prototype.draw=function(){b=this;n=b.ctx;n.clearRect(0,0,b.canvas.width,b.canvas.height);for(var a=0,e=b.graphics.length;a<e;a++)x=b.graphics[a],""!==x.trace&&b.drawTrace&&x.drawTrace(),x.draw();a=0;for(e=b.graphicsCtr.length;a<e;a++)b.graphicsCtr[a].draw();""!=b.text&&b.click&&"L"===b.whichBtn&&(n.fillStyle=b.text.getColor(),n.strokeStyle=n.fillStyle,n.lineWidth=1,n.font=k,n.textAlign="center",n.textBaseline="alphabetic",A=1>=b.scale?
b.mouse_x.toFixed(0):b.mouse_x.toFixed(b.scale.toString().length),I=1>=b.scale?b.mouse_y.toFixed(0):b.mouse_y.toFixed(b.scale.toString().length),J="("+A+","+I+")",M=d(n.measureText(J).width/2),z=b.getAbsoluteX(b.mouse_x),O=b.getAbsoluteY(b.mouse_y),L=d(z),N=d(O-10),L+M>b.w?L=b.w-M:0>L-M&&(L=M),N+1>b.h?N=b.h:0>N-14&&(N=15),n.fillText(J,L,N),n.beginPath(),n.arc(z,O,2.5,0,c,!0),n.stroke())};a.Space2D.prototype.drawMarks=function(a,b,c){w=this.w;y=this.h;G=0;H=w;K=0;C=y;F=d(w/2+this.Ox);D=d(y/2+this.Oy);
0<=c&&(G=F-c,H=F+c,K=D-c,C=D+c);a.beginPath();for(c=-l(F/b);(B=F+l(c*b))<w;c++)a.moveTo(B+.5,K+.5),a.lineTo(B+.5,C+.5);for(c=-l(D/b);(E=D+l(c*b))<y;c++)a.moveTo(G+.5,E+.5),a.lineTo(H+.5,E+.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,b,c){w=this.w;y=this.h;F=d(w/2+this.Ox);D=d(y/2+this.Oy);for(c=-l(F/b);(B=F+l(c*b))<w;c++)a.fillText(parseFloat((c*b/this.scale).toFixed(4)),B+1,D-2);for(c=-l(D/b);(E=D+l(c*b))<y;c++)0!==parseFloat(-c*b/this.scale)&&a.fillText(parseFloat((-c*b/this.scale).toFixed(4)),
F+5,E+5)};a.Space2D.prototype.addEvents=function(){function b(a){window.focus();if(k.evaluator.variables[k.id+".DESCARTESJS_no_fixed"]||!k.fixed||k.sensitive_to_mouse_movements)k.click=0,k.evaluator.setVariable(k.mpressedStr,0),k.evaluator.setVariable(k.mclickedStr,1),k.evaluator.setVariable(k.mclickIzqStr,1),window.removeEventListener("touchmove",g),window.removeEventListener("touchend",b),a.stopPropagation(),a.preventDefault(),k.parent.update()}function c(b){window.focus();b.stopPropagation();b.preventDefault();
k.click=0;k.evaluator.setVariable(k.mpressedStr,0);k.evaluator.setVariable(k.mclickedStr,1);k.evaluator.setVariable(k.mclickIzqStr,1);"R"===k.whichBtn&&(window.removeEventListener("mousemove",f),k.posZoom==k.posZoomNew&&a.showConfig&&(k.parent.externalSpace.show(),k.posZoom=!1,k.posZoomNew=!0));window.removeEventListener("mousemove",g);window.removeEventListener("mouseup",c);k.parent.deactivateGraphiControls();k.parent.update()}function d(b){k.posAnte=a.getCursorPosition(b,k.container);k.mouse_x=
k.getRelativeX(k.posAnte.x);k.mouse_y=k.getRelativeY(k.posAnte.y);k.evaluator.setVariable(k.mxStr,k.mouse_x);k.evaluator.setVariable(k.myStr,k.mouse_y);k.evaluator.setVariable(k.mclickedStr,0);k.evaluator.setVariable(k.mclickIzqStr,0);k.parent.update()}function f(b){b.preventDefault();k.posZoomNew=a.getCursorPosition(b,k.container).y;k.evaluator.setVariable(k.scaleStr,k.tempScale+k.tempScale/45*((k.posZoom-k.posZoomNew)/10));k.parent.update()}function g(b){b.preventDefault();b.stopPropagation();k.fixed||
(k.posNext=a.getCursorPosition(b,k.container),h=(k.posAnte.x-k.posNext.x).toFixed(8),e=(k.posAnte.y-k.posNext.y).toFixed(8),k.evaluator.setVariable(k.OxStr,k.Ox-h),k.evaluator.setVariable(k.OyStr,k.Oy-e));d(b)}var k=this;k.posZoom=null;k.posZoomNew=null;k.canvas.oncontextmenu=function(a){return!1};this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",d);this.canvas.addEventListener("touchstart",function(a){window.focus();if(k.evaluator.variables[k.id+".DESCARTESJS_no_fixed"]||
!k.fixed||k.sensitive_to_mouse_movements)k.parent.clearClick(),k.click=1,k.evaluator.setVariable(k.mpressedStr,1),k.evaluator.setVariable(k.mclickedStr,0),k.evaluator.setVariable(k.mclickIzqStr,0),k.parent.deactivateGraphiControls(),d(a),window.addEventListener("touchmove",g),window.addEventListener("touchend",b),a.stopPropagation(),a.preventDefault()});this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",d);this.canvas.addEventListener("mousedown",function(b){window.focus();
b.stopPropagation();b.preventDefault();k.parent.clearClick();k.click=1;k.parent.deactivateGraphiControls();k.whichBtn=a.whichBtn(b);"R"===k.whichBtn?(window.addEventListener("mouseup",c),k.posZoom=a.getCursorPosition(b,k.container).y,k.posZoomNew=k.posZoom,k.fixed||(k.tempScale=k.scale,window.addEventListener("mousemove",f))):"L"===k.whichBtn&&(k.evaluator.setVariable(k.mpressedStr,1),k.evaluator.setVariable(k.mclickedStr,0),k.evaluator.setVariable(k.mclickIzqStr,0),d(b),window.addEventListener("mousemove",
g),window.addEventListener("mouseup",c))});document.addEventListener("visibilitychange",function(a){c(a)})};return a}(descartesJS||{}),descartesJS=function(a){var h,e,d;function l(b,c){Q=a.subtract3D(b,a.scalarProduct3D(c,a.dotProduct3D(b,c)));ba=a.add3D(b,a.scalarProduct3D(Q,-2));V=a.norm3D(ba);return 0!==V?a.scalarProduct3D(ba,1/V):a.scalarProduct3D(b,-1)}if(a.loadLib)return a;var c=Math.floor,g=Math.round,k=Math.max,b=Math.cos,v=Math.sin,u=Math.sqrt,n=15*Math.PI/180,r=Math.cos(n),p=Math.sin(n),
x=Math.tan(n),f,q,m,w,y,B,E,F,D,G,H,K,C,A,I,J,M,z,O,L=[],N,R,P,U,T,S,Q,ba,V,la;a.Space3D=function(b,c){a.Space.call(this,b,c);m=this;m.backCanvas=document.createElement("canvas");m.backCanvas.setAttribute("id",m.id+"_background");m.backCanvas.setAttribute("width",m.w+"px");m.backCanvas.setAttribute("height",m.h+"px");m.canvas=document.createElement("canvas");m.canvas.setAttribute("id",m.id+"_canvas");m.canvas.setAttribute("width",m.w+"px");m.canvas.setAttribute("height",m.h+"px");m.canvas.setAttribute("class",
"DescartesSpace3DCanvas");m.canvas.setAttribute("style","z-index: "+m.zIndex+";");m.ctx=m.canvas.getContext("2d");m.ctx.imageSmoothingEnabled=!1;m.parent.images[m.id+".image"]=m.canvas;m.parent.images[m.id+".image"].ready=1;m.parent.images[m.id+".image"].complete=!0;m.evaluator.setVariable(m.id+".image",m.id+".image");m.graphicControlContainer=document.createElement("div");m.graphicControlContainer.setAttribute("id",m.id+"_graphicControls");m.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+
m.zIndex+";");m.numericalControlContainer=document.createElement("div");m.numericalControlContainer.setAttribute("id",m.id+"_numericalControls");m.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+m.zIndex+";");m.container=document.createElement("div");m.container.setAttribute("id",m.id);m.container.setAttribute("class","DescartesSpace3DContainer");m.container.setAttribute("style","left: "+m.x+"px; top: "+m.y+"px; z-index: "+m.zIndex+";");m.container.appendChild(m.backCanvas);
m.container.appendChild(m.canvas);m.container.appendChild(m.graphicControlContainer);m.container.appendChild(m.numericalControlContainer);b.container.insertBefore(m.container,b.loader);m.eye={x:0,y:0,z:0};m.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,e=m.lights.length;d<e;d++)m.lights[d]=a.normalize3D(m.lights[d]);m.light3={x:0,y:0,z:0};m.intensity=[.4,.5,.3,0];m.userIntensity=0;m.dim=1;m.tmpIntensity=[];m.OxStr=m.id+".Ox";m.OyStr=m.id+".Oy";m.scaleStr=m.id+
".escala";m.wStr=m.id+"._w";m.hStr=m.id+"._h";m.obsStr=m.id+".observador";m.rotZStr=m.id+".rot.z";m.rotYStr=m.id+".rot.y";m.userIDimStr=m.id+".userIlum.dim";m.userIIStr=m.id+".userIlum.I";m.userIxStr=m.id+".userIlum.x";m.userIyStr=m.id+".userIlum.y";m.userIzStr=m.id+".userIlum.z";m.new3DStr=m.id+"._3Dnew_";m.xOStr=m.id+".xO";m.yOStr=m.id+".yO";m.zOStr=m.id+".zO";m.AOStr=m.id+".AO";m.BOStr=m.id+".BO";m.COStr=m.id+".CO";m.zoomStr=m.id+".zoom";m.evaluator.setVariable(m.rotZStr,0);m.evaluator.setVariable(m.rotYStr,
0);m.evaluator.setVariable(m.userIDimStr,m.dim);m.evaluator.setVariable(m.userIIStr,m.userIntensity);m.evaluator.setVariable(m.userIxStr,0);m.evaluator.setVariable(m.userIyStr,0);m.evaluator.setVariable(m.userIzStr,0);m.addEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(a){m=this;m.uber.init.call(m);m.canvas&&(m.canvas.width=m.backCanvas.width=m.w,m.canvas.height=m.backCanvas.height=m.h,m.canvas.style.width=m.backCanvas.style.width=m.w+"px",m.canvas.style.height=m.backCanvas.style.height=
m.h+"px");m.w_2=m.w/2;m.h_2=m.h/2;m.w_plus_h=m.w+m.h;m.oldMouse={x:0,y:0}};a.Space3D.prototype.update=function(a){m=this;f=m.evaluator;q=m.parent;m.new3D=0<f.getVariable(m.new3DStr);f.setVariable(m.wStr,m.w);f.setVariable(m.hStr,m.h);m.drawIfValue=0<f.eval(m.drawif);if(m.drawIfValue){B=m.x!==f.eval(m.xExpr)+m.displaceRegionWest;E=m.y!==f.eval(m.yExpr)+q.plecaHeight+m.displaceRegionNorth;m.spaceChange=a||B||E||m.drawBefore!==m.drawIfValue||m.Ox!==f.getVariable(m.OxStr)||m.Oy!==f.getVariable(m.OyStr)||
m.scale!==f.getVariable(m.scaleStr);m.x=B?f.eval(m.xExpr)+m.displaceRegionWest:m.x;m.y=E?f.eval(m.yExpr)+q.plecaHeight+m.displaceRegionNorth:m.y;m.Ox=f.getVariable(m.OxStr);m.Oy=f.getVariable(m.OyStr);m.scale=f.getVariable(m.scaleStr);m.drawBefore=m.drawIfValue;if(a||void 0==m.observer){a=0;for(var b=m.parent.controls.length;a<b;a++)m.parent.controls[a].id===m.obsStr&&(la=!0);m.observer=la?f.getVariable(m.obsStr)||2.5*m.w_plus_h:2.5*m.w_plus_h;m.observer=k(m.observer,.25*m.w_plus_h);f.setVariable(m.obsStr,
m.observer)}m.new3D?(void 0==f.getVariable(m.xOStr)&&f.setVariable(m.xOStr,m.observer/m.scale*r),void 0==f.getVariable(m.yOStr)&&f.setVariable(m.yOStr,0),void 0==f.getVariable(m.zOStr)&&f.setVariable(m.zOStr,m.observer/m.scale*p),void 0==f.getVariable(m.AOStr)&&f.setVariable(m.AOStr,0),void 0==f.getVariable(m.BOStr)&&f.setVariable(m.BOStr,345),void 0==f.getVariable(m.COStr)&&f.setVariable(m.COStr,0),m.xO=f.getVariable(m.xOStr),m.yO=f.getVariable(m.yOStr),m.zO=f.getVariable(m.zOStr),m.AO=f.getVariable(m.AOStr),
m.BO=f.getVariable(m.BOStr),m.CO=f.getVariable(m.COStr),m.zoom=f.getVariable(m.zoomStr),m.eye={x:parseFloat(f.getVariable(m.xOStr)),y:parseFloat(f.getVariable(m.yOStr)),z:parseFloat(f.getVariable(m.zOStr))}):(m.D=m.observer/3,m.eye={x:m.D/m.scale,y:0,z:m.D/m.scale*x},m.RX0=m.Ox,m.RY0=m.Oy-m.D*x,m.bfactor=m.scale*m.eye.x,m.observer=k(f.getVariable(m.obsStr),.25*m.w_plus_h),m.observer!=f.getVariable(m.obsStr)&&(f.setVariable(m.obsStr,m.observer),m.parent.updateControls()));1E-6>m.scale?(m.scale=1E-6,
f.setVariable(m.scaleStr,1E-6)):1E6<m.scale&&(m.scale=1E6,f.setVariable(m.scaleStr,1E6));if(B||E)m.container.style.left=m.x+"px",m.container.style.top=m.y+"px";m.container.style.display="block";m.dim=f.getVariable(m.userIDimStr);m.userIntensity=f.getVariable(m.userIIStr);m.light3={x:parseInt(f.getVariable(m.userIxStr)),y:parseInt(f.getVariable(m.userIyStr)),z:parseInt(f.getVariable(m.userIzStr))};m.updateCamera();m.draw()}else m.container.style.display="none"};a.Space3D.prototype.updateCamera=function(){m=
this;m.new3D?(m.D=m.scale*m.eye.x/r,m.XE=g(m.scale*m.eye.y+.5),m.YE=g(m.scale*m.eye.z+.5)):(m.D=m.observer/3,m.eye.x=m.D/m.scale,m.eye.y=0,m.eye.z=m.D/m.scale*x)};a.Space3D.prototype.rotateVertex=function(c){C=a.degToRad(m.evaluator.getVariable(m.rotZStr));A=b(C);I=v(C);h=c.x*A-c.y*I;e=c.x*I+c.y*A;d=c.z;C=a.degToRad(m.evaluator.getVariable(m.rotYStr));A=b(C);I=v(C);return{x:d*I+h*A,y:e,z:d*A-h*I}};var ma,ha,W,X,na,ia,ca,Y,oa,ja,Z,aa,pa,qa,ra,sa,ta,ua,va,wa,xa,da,ea,fa,ga,ya,za,ka;a.Space3D.prototype.project=
function(a){m=this;if(m.new3D){G=m.eye.x-a.x;H=m.eye.y-a.y;K=m.eye.z-a.z;var b=u(G*G+H*H+K*K);ma=m.AO%360;ha=ma*Math.PI/180;W=Math.cos(ha);X=Math.sin(ha);na=m.BO%360;ia=na*Math.PI/180;ca=Math.cos(ia);Y=Math.sin(ia);oa=m.CO%360;ja=oa*Math.PI/180;Z=Math.cos(ja);aa=Math.sin(ja);pa=ca*W;qa=-Z*ca*X-aa*Y;ra=-aa*ca*X+Z*Y;sa=X;ta=Z*W;ua=aa*W;va=-Y*W;wa=Z*Y*X-aa*W;xa=aa*Y*X+Z*W;da=-m.eye.x+a.x;ea=-m.eye.y+a.y;fa=-m.eye.z+a.z;ga=pa*da+sa*ea+va*fa;ya=qa*da+ta*ea+wa*fa;za=ra*da+ua*ea+xa*fa;ka=parseFloat(m.evaluator.getVariable(m.zoomStr));
return{x:this.getAbsoluteX(-ka*ya/ga),y:this.getAbsoluteY(-ka*za/ga),z:0<ga?-b:b}}b=m.bfactor/(a.x-m.eye.x);return{x:this.w_2+m.RX0-b*(a.y-m.eye.y),y:this.h_2+m.RY0+b*(a.z-m.eye.z),z:m.eye.x-a.x}};a.Space3D.prototype.computeColor=function(b,d,e){b.match("rgba")?b=a.RGBAToHexColor(b):b.match("#")&&(b=new a.Color(b.substring(1)));U=a.subtract3D(this.eye,d.average);T=a.norm3D(U);S=a.scalarProduct3D(U,1/T);this.lights[3]=a.subtract3D(this.light3,d.average);O=a.norm3D(this.lights[3]);for(var f=0,g=this.intensity.length-
1;f<g;f++)L[f]=this.intensity[f]*this.dim;L[3]=this.userIntensity*this.userIntensity/O||0;N=e?this.dim/2:this.dim/4;R=0;P=0<=d.direction?d.normal:a.scalarProduct3D(d.normal,-1);f=0;for(g=this.lights.length;f<g;f++)e?(R=Math.max(0,a.dotProduct3D(l(this.lights[f],P),S)),R*=R*R):R=Math.max(0,a.dotProduct3D(this.lights[f],P)),N+=L[f]*R;N=Math.min(N,1);J=c(b.r*N);M=c(b.g*N);z=c(b.b*N);return"rgba("+J+","+M+","+z+","+b.a+")"};a.Space3D.prototype.draw=function(){this.ctx.clearRect(0,0,this.canvas.width,
this.canvas.height);this.ctx.fillStyle=this.background.getColor();this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height);this.image&&""!=this.image.src&&this.image.ready&&this.image.complete&&("topleft"===this.bg_display?this.ctx.drawImage(this.image,0,0):"stretch"===this.bg_display?this.ctx.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?(this.ctx.fillStyle=ctx.createPattern(this.image,"repeat"),this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&
this.ctx.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));if(!this.click){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++){w=this.graphics[a];if(w.split||this.split)for(var c=a+1;c<b;c++)y=this.graphics[c],(y.split||this.split)&&w.splitFace(y);this.primitives=this.primitives.concat(w.primitives||[])}}a=0;for(b=this.primitives.length;a<b;a++)this.primitives[a].computeDepth(this);this.primitives=
this.primitives.sort(function(a,b){return b.depth-a.depth});if("painter"===this.render)this.drawPainter(this.primitives);else for(a=0,b=this.primitives.length;a<b;a++)this.primitives[a].passDraw&&this.primitives[a].draw(this.ctx,this);a=0;for(b=this.graphicsCtr.length;a<b;a++)this.graphicsCtr[a].draw()};a.Space3D.prototype.drawPainter=function(a){for(var b=a.length,c=0;c<b;c++)a[c].drawn=!1,a[c].draw(this.ctx,this);for(var d=[],e=[],f=0,g=a.length,k=.001,h,m;;){h=g;for(c=0;c<b;c++)if(!a[c].drawn){m=
!0;for(var l=0;l<b;l++)if(l!=c&&!a[l].drawn&&a[c].inFrontOf(d,a[l],k)){m=!1;break}m&&(g--,e[f++]=a[c],a[c].drawn=!0)}if(0==g)break;else if(g==h){if(k*=10,.1<k){for(c=0;c<b;c++)a[c].drawn||(e[f++]=a[c],a[c].drawn=!0);break}}else k=.001}for(c=0;c<b;c++)e[c].draw(this.ctx,this)};a.Space3D.prototype.rayFromEye=function(a,b){return{x:-this.eye.x,y:(a-(this.w_2+this.Ox))/this.scale-this.eye.y,z:(this.h_2+this.Oy-b)/this.scale-this.eye.z}};a.Space3D.prototype.addEvents=function(){function b(a){document.body.focus();
g.click=0;g.evaluator.setVariable(g.id+".mouse_pressed",0);window.removeEventListener("touchmove",f,!1);window.removeEventListener("touchend",b,!1);a.preventDefault()}function c(b){document.body.focus();g.click=0;g.evaluator.setVariable(g.id+".mouse_pressed",0);b.preventDefault();"R"===g.whichBtn&&(window.removeEventListener("mousemove",e,!1),g.posZoom==g.posZoomNew&&a.showConfig&&g.parent.externalSpace.show());window.removeEventListener("mousemove",f,!1);window.removeEventListener("mouseup",c,!1);
g.parent.update()}function d(b){g.posAnte=a.getCursorPosition(b,g.container);g.mouse_x=g.getRelativeX(g.posAnte.x);g.mouse_y=g.getRelativeY(g.posAnte.y);g.evaluator.setVariable(g.id+".mouse_x",g.mouse_x);g.evaluator.setVariable(g.id+".mouse_y",g.mouse_y);g.parent.update();Date.now()}function e(b){b.preventDefault();g.posZoomNew=a.getCursorPosition(b,g.container).y;g.evaluator.setVariable(g.scaleStr,g.tempScale+g.tempScale/45*((g.posZoom-g.posZoomNew)/10));g.posObserverNew=a.getCursorPosition(b,g.container).x;
g.evaluator.setVariable(g.obsStr,g.tempObserver-2.5*(g.posObserver-g.posObserverNew));g.parent.update()}function f(b){if(!g.fixed&&g.click){F=(g.getAbsoluteX(g.oldMouse.x)-g.getAbsoluteX(g.mouse_x))/4;D=(-g.getAbsoluteY(g.oldMouse.y)+g.getAbsoluteY(g.mouse_y))/4;if(F!==g.disp.x||D!==g.disp.y)g.alpha=a.degToRad(g.evaluator.getVariable(g.rotZStr)),g.beta=a.degToRad(-g.evaluator.getVariable(g.rotYStr)),g.alpha=a.radToDeg(g.alpha)-F,g.beta=a.radToDeg(g.beta)-D,g.evaluator.setVariable(g.rotZStr,g.alpha),
g.evaluator.setVariable(g.rotYStr,-g.beta),g.disp.x=F,g.disp.y=D,g.oldMouse.x=g.getRelativeX(g.posAnte.x),g.oldMouse.y=g.getRelativeY(g.posAnte.y);d(b);b.preventDefault()}}var g=this;this.canvas.oncontextmenu=function(){return!1};this.canvas.addEventListener("touchstart",function(c){document.body.focus();g.click=1;g.evaluator.setVariable(g.id+".mouse_pressed",1);g.parent.deactivateGraphiControls();g.posAnte=a.getCursorPosition(c,g.container);g.oldMouse.x=g.getRelativeX(g.posAnte.x);g.oldMouse.y=g.getRelativeY(g.posAnte.y);
d(c);window.addEventListener("touchmove",f);window.addEventListener("touchend",b);c.preventDefault()});this.canvas.addEventListener("mousedown",function(b){document.body.focus();g.click=1;g.parent.deactivateGraphiControls();g.whichBtn=a.whichBtn(b);"R"===g.whichBtn?(window.addEventListener("mouseup",c),g.posObserver=a.getCursorPosition(b,g.container).x,g.posObserverNew=g.posObserver,g.posZoom=a.getCursorPosition(b,g.container).y,g.posZoomNew=g.posZoom,g.fixed||(g.tempScale=g.scale,g.tempObserver=
g.observer,window.addEventListener("mousemove",e))):"L"==g.whichBtn&&(g.evaluator.setVariable(g.id+".mouse_pressed",1),g.posAnte=a.getCursorPosition(b,g.container),g.oldMouse.x=g.getRelativeX(g.posAnte.x),g.oldMouse.y=g.getRelativeY(g.posAnte.y),d(b),window.addEventListener("mousemove",f),window.addEventListener("mouseup",c));b.preventDefault()});this.disp={x:0,y:0}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h;a.SpaceAP=function(e,d){a.Space.call(this,e,d);this.eVars=
this.iVars=null;h=e.evaluator;this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=h.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=h.parser.parse(this.file):this.file=h.parser.parse("'"+this.file+"'");this.oldFile=h.eval(this.file);this.initFile()};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var e;if(this.oldFile){var d=document.getElementById(this.oldFile);e=d&&"descartes/spaceApFile"==
d.type?d.text:a.openExternalFile(this.oldFile);null!=e&&(e=e.split("\n"))}if(e&&e.toString().match(/<applet/gi)){for(var d="",h=!1,c=0,g=e.length;c<g&&(e[c].match("<applet")&&(h=!0),h&&(d+=e[c]),!e[c].match("</applet"));c++);e=document.createElement("div");e.innerHTML=d;e.firstChild.setAttribute("width",this.w);e.firstChild.setAttribute("height",this.h);d=this.descApp?this.descApp.container:null;this.descApp=new a.DescartesApp(e.firstChild);this.descApp.container.setAttribute("class","DescartesAppContainer");
this.descApp.container.setAttribute("style","position:absolute;overflow:hidden;background-color:"+this.background+";width:"+this.w+"px;height:"+this.h+"px;left:"+this.x+"px;top:"+this.y+"px;z-index:"+this.zIndex+";");d?this.parent.container.replaceChild(this.descApp.container,d):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);this.descApp.container.style.display=0<this.evaluator.eval(this.drawif)?"block":"none";var k=this;this.descApp.update=function(){this.updateAuxiliaries();
this.updateEvents();this.updateControls();this.updateSpaces();k.exportar()}}else d=this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),e="position:absolute;overflow:hidden;background-color:"+this.background+";width:"+this.w+"px;height:"+this.h+"px;left:"+this.x+"px;top:"+this.y+"px;z-index:"+this.zIndex+";",this.image&&("topleft"==this.bg_display?e+="background-image: url("+
this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?e+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?e+="background-image: url("+this.imageSrc+");":"imgcenter"==this.bg_display&&(e+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",e),d?this.parent.container.replaceChild(this.descApp.container,
d):this.parent.container.insertBefore(this.descApp.container,this.parent.loader),this.descApp.container.style.display=0<this.evaluator.eval(this.drawif)?"block":"none"};a.SpaceAP.prototype.update=function(){var a=this.evaluator.eval(this.file);if(this.oldFile!=a)this.oldFile=a,this.initFile();else{var a=this.x!=this.evaluator.eval(this.xExpr),d=this.y!=this.evaluator.eval(this.yExpr)+this.plecaHeight;this.x=a?this.evaluator.eval(this.xExpr):this.x;this.y=d?this.evaluator.eval(this.yExpr)+this.plecaHeight:
this.y;a&&(this.descApp.container.style.left=this.x+"px");d&&(this.descApp.container.style.top=this.y+"px");this.descApp.container.style.display=0<this.evaluator.eval(this.drawif)?"block":"none";if(this.firstUpdate&&(this.firstUpdate=!1,null==this.iVars)){this.iVars=[];for(var h in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(h)&&h.match(/^public./)&&this.iVars.push({varName:h,value:this.evaluator.getVariable(h)})}this.importar()}};a.SpaceAP.prototype.importar=function(){for(var a,
d=!1,h=0,c=this.iVars.length;h<c;h++)a=this.evaluator.getVariable(this.iVars[h].varName),a!=this.iVars[h].value&&(this.iVars[h].value=a,this.descApp.evaluator.setVariable(this.iVars[h].varName,this.iVars[h].value),d=!0);d&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d,l,c,g;a.SpaceHTML_IFrame=function(c,b){a.Space.call(this,c,b);h=this.parent.evaluator;if(void 0!=this._w_){var d=h.parser.parse(this._w_);
this._w_="number"!=d.type?d:void 0}void 0!=this._h_&&(d=h.parser.parse(this._h_),this._h_="number"!=d.type?d:void 0);this.isFirefox=/firefox/i.test(window.navigator.userAgent);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=h.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=h.parser.parse(this.file):this.file=h.parser.parse("'"+this.file+"'");this.oldFile=h.eval(this.file);this.MyIFrame=
document.createElement("iframe");0!=this.oldFile&&this.MyIFrame.setAttribute("src",this.oldFile);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");this.container.setAttribute("id",this.id);this.container.setAttribute("style",(a.isIOS?"overflow:scroll;-webkit-overflow-scrolling:touch;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+";background-repeat:no-repeat;background-position:center;");this.container.appendChild(this.MyIFrame);this.imageSrc&&(this.container.style.backgroundImage="url("+this.imageSrc+")");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});e.ImReady=!e.isFirefox;e.isFirefox||(e.container.style.visibility="visible",e.container.style.opacity="1",e.container.style.zIndex=e.zIndex,e.container.style.display=e.drawIfValue?"block":"none");e.MyIFrame.style.visibility="visible";e.container.style.backgroundImage=
""};this.update=this.iframeUpdate;this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.init=function(){c=this;c.uber.init.call(c);c.MyIFrame&&(c.MyIFrame.style.width=c.w+"px",c.MyIFrame.style.height=c.h+"px",c.MyIFrame.style.left=c.x+"px",c.MyIFrame.style.top=c.y+"px")};a.SpaceHTML_IFrame.prototype.iframeUpdate=function(a){h=this.evaluator;this.drawIfValue=0<h.eval(this.drawif);this.ImReady?this.container.style.display=this.drawIfValue?
"block":"none":(this.container.style.visibility=this.drawIfValue?"visible":"hidden",this.container.style.opacity=this.drawIfValue?"1":"0",this.container.style.zIndex=this.drawIfValue?this.zIndex:-1E3);if(this.drawIfValue){this.MyIFrame.contentWindow.focus();a&&(this.y=this.x=Infinity);e=this.x!==h.eval(this.xExpr)+this.displaceRegionWest;d=this.y!==h.eval(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth;this.x=e?h.eval(this.xExpr)+this.displaceRegionWest:this.x;this.y=d?h.eval(this.yExpr)+
this.parent.plecaHeight+this.displaceRegionNorth:this.y;void 0!=this._w_&&(a=h.eval(this._w_),this.w!==a&&(this.container.style.width=a+"px",this.MyIFrame.style.width=a+"px",this.w=a));void 0!=this._h_&&(a=h.eval(this._h_),this.h!==a&&(this.container.style.height=a+"px",this.MyIFrame.style.height=a+"px",this.h=a));if(e||d)this.container.style.left=this.x+"px",this.container.style.top=this.y+"px";l=h.eval(this.file);l!==this.oldFile&&(this.ImReady=!1,this.isFirefox||(this.container.style.display="block",
this.container.style.visibility=this.drawIfValue?"visible":"hidden",this.container.style.opacity=this.drawIfValue?"1":"0",this.container.style.zIndex=this.drawIfValue?this.zIndex:-1E3),this.imageSrc&&(this.container.style.backgroundImage="url("+this.imageSrc+")"),this.MyIFrame.style.visibility="hidden",this.oldFile=l,this.MyIFrame.contentWindow.location.replace(l));g=h.getVariable(this.id+"._scroll");1==g?(this.MyIFrame.setAttribute("scrolling","yes"),this.MyIFrame.style.overflow=""):-1==g?(this.MyIFrame.setAttribute("scrolling",
"no"),this.MyIFrame.style.overflow="hidden"):(this.MyIFrame.setAttribute("scrolling","auto"),this.MyIFrame.style.overflow="")}else this.MyIFrame.contentWindow.blur()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var h,e,d;a.DescartesLoader=function(c){var d=this;this.children=c.children;this.lessonParser=c.lessonParser;this.images=c.images;this.images.length=c.images.length;this.audios=c.audios;this.audios.length=c.audios.length;this.descartesApp=c;var e=c.imgLoader?c.imgLoader:
l(c.loader.width,c.loader.height,c.ratio);this.imageLoader=document.createElement("div");this.imageLoader.width=c.width;this.imageLoader.height=c.height;this.imageLoader.setAttribute("class","DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image:url("+e+");background-size:cover;width:"+c.width+"px;height:"+c.height+"px;");c.loader.appendChild(this.imageLoader);this.loaderBar=document.createElement("canvas");this.loaderBar.width=c.width;this.loaderBar.height=c.height;this.loaderBar.setAttribute("class",
"DescartesLoaderBar");this.loaderBar.setAttribute("style","width:"+c.width+"px;height:"+c.height+"px;");this.loaderBar.ctx=this.loaderBar.getContext("2d");c.loader.appendChild(this.loaderBar);this.barWidth=80;this.barHeight=Math.floor(c.loader.height/70);this.timer=a.setInterval(function(){d.drawLoaderBar(d.loaderBar.ctx,c.width,c.height)},10);c.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var c=this.children,d=this.images,e=this.audios,b=/[\w\.\-//]*(\.png|\.jpg|\.gif|\.svg)/gi,
h=/[\w\.\-//]*(\.ogg|\.oga|\.mp3|\.wav)/gi;d["lib/DescartesCCLicense.png"]=a.getCCLImg();d["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=1});d["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=1});var l,n,r,p,x,f;r=0;for(x=c.length;r<x;r++)if("rtf"!==c[r].name){if(c[r].value.match(/'macro'|'makro'/g)){p="";var q;l=this.lessonParser.split(c[r].value);n=0;for(f=l.length;n<f;n++)"expresion"===babel[l[n][0]]&&(p=l[n][1]);p&&((q=document.getElementById(p))&&
"descartes/macro"==q.type?q=q.text:(q=a.openExternalFile(p))&&!q.match(/tipo_de_macro/g)&&(q=null));if(q&&(l=q.match(b)))for(p=0,f=l.length;p<f;p++)n=l[p],n.toLowerCase().match(/vacio.gif$/)||""==n.substring(0,n.length-4)||(d[n]=new Image,d[n].addEventListener("load",function(){this.ready=1}),d[n].addEventListener("error",function(){this.errorload=1}),d[n].src=n)}if(l=c[r].value.match(b))for(p=0,f=l.length;p<f;p++)n=l[p],n.toLowerCase().match(/vacio.gif$/)||""==n.substring(0,n.length-4)||(d[n]=new Image,
d[n].addEventListener("load",function(){this.ready=1}),d[n].addEventListener("error",function(){this.errorload=1}),d[n].src=n);if(l=c[r].value.match(h))for(p=0,n=l.length;p<n;p++)this.initAudio(l[p])}for(var m in d)d.hasOwnProperty(m)&&this.images.length++;for(m in e)e.hasOwnProperty(m)&&this.audios.length++;var w=this,y=this.images.length+this.audios.length;this.sep=2*(this.barWidth-2)/y;var B=function(){w.readys=0;for(var b in d)d.hasOwnProperty(b)&&(d[b].ready||d[b].errorload)&&w.readys++;for(b in w.audios)e.hasOwnProperty(b)&&
(e[b].ready||e[b].errorload)&&w.readys++;w.readys!=y?a.setTimeout(B,30):(a.clearInterval(w.timer),w.descartesApp.initBuildApp())};B()};a.DescartesLoader.prototype.initAudio=function(c){var d=this.audios;d[c]=new Audio(c);d[c].filename=c;var e=function(){this.ready=1},b=function(){this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))||"mp3"!=this.filename.substring(this.filename.length-3)?(console.log("El archivo '"+c+"' no puede ser reproducido"),this.errorload=1):(d[c]=new Audio(this.filename.replace("mp3",
"ogg")),d[c].filename=this.filename.replace("mp3","ogg"),d[c].addEventListener("canplaythrough",e),d[c].addEventListener("load",e),d[c].addEventListener("error",b),d[c].load())};d[c].addEventListener("canplaythrough",e);d[c].addEventListener("load",e);d[c].addEventListener("error",b);a.hasTouchSupport?(d[c].load(),d[c].play(),a.setTimeout(function(){d[c].pause()},20),d[c].ready=1):d[c].load()};a.DescartesLoader.prototype.drawLoaderBar=function(a,g,k){e=this.barWidth;d=this.barHeight;a.translate(g/
2,(k-65*h)/2+90*h);a.scale(h,h);a.strokeRect(-e,-d,2*e,d);a.fillStyle="#888";a.fillRect(-e+2,-d+2,2*(e-2),d-4);a.fillStyle="#1f358d";a.fillRect(-e+2,-d+2,this.readys*this.sep,d-4);a.setTransform(1,0,0,1,0,0)};var l=function(a,d,e){var b=document.createElement("canvas");e=5E6<a*this.ratio*d*this.ratio?1:e;b.width=a*e;b.height=d*e;b.style.width=a+"px";b.style.height=d+"px";var l=b.getContext("2d");l.save();l.setTransform(e,0,0,e,0,0);l.strokeStyle=l.fillStyle="#1f358d";l.lineCap="round";l.lineWidth=
2;l.beginPath();h=a<d?a/360:d/195;h=2.5<h?2.5:h;l.translate((a-120*h)/2,(d-65*h)/2);l.scale(h,h);l.moveTo(3,25);l.lineTo(3,1);l.lineTo(21,1);l.bezierCurveTo(33,1,41,15,41,25);l.stroke();l.beginPath();l.moveTo(1,63);l.lineTo(1,64);l.moveTo(5,62);l.lineTo(5,64);l.moveTo(9,61);l.lineTo(9,64);l.moveTo(13,60);l.lineTo(13,64);l.moveTo(17,58);l.lineTo(17,64);l.moveTo(21,56);l.lineTo(21,64);l.moveTo(25,53);l.lineTo(25,64);l.moveTo(29,50);l.lineTo(29,64);l.moveTo(33,46);l.lineTo(33,64);l.moveTo(37,41);l.lineTo(37,
64);l.moveTo(41,32);l.lineTo(41,64);l.stroke();l.font="20px descartesJS_sansserif, Arial, Helvetica, Sans-serif";l.fillText("escartes",45,33);l.fillText("JS",98,64);l.restore();return b.toDataURL()};return a}(descartesJS||{}),descartesJS=function(a){function h(a){for(var b="[",c=0,e=a.length;c<e;c++)a[c]instanceof Array?b+=h(a[c]):(d=a[c],"undefined"!=typeof d&&d||(d=0),"string"==typeof d&&(d="'"+d+"'"),b+=d),c<e-1&&(b+=",");return b+"]"}function e(){l=window.innerWidth/this.width;c=window.innerHeight/
this.height;g=Math.min(l,c);a.cssScale=g.toFixed(3);this.container.parentNode.setAttribute("align","");this.container.style.transformOrigin="0 0";l<c?(this.container.style.left="",this.container.style.transform="scale("+g+") translate(0,0)"):(this.container.style.left="50%",this.container.style.transform="scale("+g+") translate(-50%,0)")}if(a.loadLib)return a;a.DescartesApp=function(c){this.animation={playing:!1,stop:function(){}};this.ratio=a._ratio;this.applet=c;this.parentC=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.ccLicense=!0;for(var b=0,d=this.children.length;b<d;b++)"CreativeCommonsLicense"===this.children[b].name&&(a.ccLicense="no"===this.children[b].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.scaleToFit=function(){};this.init()};a.DescartesApp.prototype.init=function(){this.stop();this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.arquimedes=/DescartesWeb2_0|Arquimedes|Discurso/i.test(this.code);this.licenseA=a.ccLicense?"{\\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/4.0/}, 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,b,d=0,g=0,h=a.ccLicense?90:0,l=0,p=c.length;l<p;l++)b=c[l],"rtf_height"==b.name&&(d=parseInt(b.value)||this.height),"Buttons"==babel[b.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(b.value),g=this.buttonsConfig.height),"image_loader"==b.name&&(this.imgLoader=b.value),"expand"==b.name&&("cover"==b.value?this.expand=b.value:"fit"==b.value&&(this.scaleToFit=e)),"docBase"==b.name&&(this.docBase=b.value,b=document.createElement("base"),b.setAttribute("id","descartesJS_base"),
b.setAttribute("href",this.docBase),document.head.appendChild(b));this.expand&&"cover"==this.expand&&(this.width=window.innerWidth,this.height=window.innerHeight);this.arquimedes&&(this.ratio=1,d&&(this.height=d+g+h));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.nIframes=this.plecaHeight=this.tabindex=this.zIndex=0;void 0!=this.container&&this.parentC.removeChild(this.container);this.container=document.createElement("div");this.loader=document.createElement("div");
this.parentC.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.scaleToFit();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.imgLoader&&(this.loader.style.backgroundColor="rgba(0,0,0,0)");this.firstRun?this.descartesLoader=new a.DescartesLoader(this):this.initBuildApp()};a.DescartesApp.prototype.initBuildApp=function(){a.showConfig=!0;for(var c=this.children,b=this.lessonParser,d=[],e=[],g=[],h=[],l=[],x=[],f,q=0,m=c.length;q<m;q++)if(f=c[q],"editable"==babel[f.name]&&(a.showConfig="false"==babel[f.value]?!1:!0),"language"==babel[f.name]&&(this.language=f.value),"pleca"==f.name)f=b.parsePleca(f.value,
this.width),this.container.insertBefore(f,this.loader),this.plecaHeight=f.imageHeight?f.imageHeight:f.offsetHeight;else if("Buttons"==babel[f.name])this.buttonsConfig=b.parseButtonsConfig(f.value);else if("decimal_symbol"==babel[f.name])this.decimal_symbol=f.value,this.decimal_symbol_regexp=new RegExp("\\"+this.decimal_symbol,"g");else if("version"==babel[f.name])this.version=parseInt(f.value);else if("language"==babel[f.name])this.language=f.value;else if("rtf"==f.name){var w=(this.width-780)/2,
y=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;h.push("space='descartesJS_stage' type='text' expresion='[10,20]' background='yes' text='"+f.value.replace(/'/g,"&squot;")+"'");h.push("space='descartesJS_stage' type='text' expresion='["+w+","+(y-25)+"]' background='yes' text='"+this.licenseA+"'");a.ccLicense&&h.push("space='descartesJS_stage' type='image' expresion='["+(w+15)+","+y+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else if("E"==f.name.charAt(0))f.value.match(/'HTMLIFrame'/)&&
this.nIframes++,d.push(f.value);else if(/^C_/.test(f.name))e.push(f.value);else if(/^A_/.test(f.name))g.push(f.value);else if(/^G_/.test(f.name)){if(f.value.match("type='fill'")||f.value.match("tipo='relleno'")||f.value.match("tipus='ple'")||f.value.match("mota='betea'")||f.value.match("type='plein'")||f.value.match("tipo='recheo'")||f.value.match("tipo='curva_piena'")||f.value.match("tipo='preencher'")||f.value.match("tipus='ple'"))this.ratio=1;h.push(f.value)}else/^S_/.test(f.name)?l.push(f.value):
"Animation"==babel[f.name]&&x.push(f.value);this.stage={container:document.createElement("div"),scroll:0};this.stage.container.setAttribute("id","descartesJS_Stage");this.stage.stageSpace=this.lessonParser.parseSpace("tipo='R2' id='descartesJS_stage' fondo='blanco' x='0' y='0' fijo='yes' red='no' red10='no' ejes='no' text='no' ancho='"+this.width+"' alto='"+this.height+"'");this.stage.container.appendChild(this.stage.stageSpace.container);this.arquimedes&&(this.container.appendChild(this.stage.container),
this.spaces.push(this.stage.stageSpace));q=0;for(m=d.length;q<m;q++)c=b.parseSpace(d[q]),this.arquimedes&&this.stage.container.appendChild(c.container),this.spaces.push(c),this.zIndex++;q=0;for(m=h.length;q<m;q++)if(d=b.parseGraphic(h[q]))d.visible&&(this.editableRegionVisible=!0),d.space.addGraph(d);q=0;for(m=l.length;q<m;q++)(d=b.parse3DGraphic(l[q]))&&d.space.addGraph(d,!0);q=0;for(m=e.length;q<m;q++)this.controls.push(b.parseControl(e[q]));q=0;for(m=g.length;q<m;q++)b.parseAuxiliar(g[q]);q=0;
for(m=x.length;q<m;q++)this.animation=b.parseAnimation(x[q]);this.configRegions();this.updateAuxiliaries();this.updateAuxiliaries();q=0;for(m=this.controls.length;q<m;q++)this.controls[q].init();this.updateControls();this.updateSpaces(!0);var B=this;this.nIframes?a.setTimeout(function(){B.finishInit()},200*this.nIframes):this.finishInit()};a.DescartesApp.prototype.finishInit=function(){this.evaluator.setVariable("decimalSymbol",this.decimal_symbol);this.update();this.loader.style.display="none";window.parent!==
window&&(this.parentC.style.margin="0px",this.parentC.style.padding="0px",window.parent.postMessage({type:"reportSize",href:window.location.href,width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready",value:window.location.href},"*"),a.onResize());window.opener&&window.opener.postMessage({type:"isResizeNeeded",href:window.location.href},"*");this.externalSpace.init();if(this.arquimedes){var c=this.stage.stageSpace.container.style.left,b=this.stage.stageSpace.container.style.top,
d=document.createElement("div");d.setAttribute("style","position:relative;left:"+c+";top:"+b+";text-align:left;margin:0;padding:18px 0 0 18px;");c={ctrs:[],spaces:[]};d.appendChild(this.stage.stageSpace.backGraphics[0].text.toHTML(c));b=d.firstChild;this.stage.stageSpace.container.style.visibility="hidden";this.stage.stageSpace.container.style.display="none";this.stage.container.replaceChild(d,this.stage.stageSpace.container);this.stage.container.style.background="#fff";this.container.style.height=
"100%";this.stage.container.style.height="100%";this.container.style.overflow="visible";var e=document.createElement("div");e.setAttribute("style","margin:auto;width:100%;padding:0;padding-bottom:30px;text-align:center;");var g=document.createElement("div");g.setAttribute("style","position:relative;display:inline-block;");var h=document.createElement("a");h.setAttribute("href","https://creativecommons.org/licenses/by-nc-sa/4.0/deed.es");h.setAttribute("target","_blank");g.appendChild(h);var l=a.getCCLImg();
l.setAttribute("style","position:absolute;left:15px;padding-top:20px;");h.appendChild(l);h=document.createElement("div");h.setAttribute("style","display:inline-block;width:100%;text-align:left;");h.appendChild(this.stage.stageSpace.backGraphics[1].text.toHTML());g.appendChild(h);e.appendChild(g);d.appendChild(e);for(e=0;e<c.spaces.length;e++)g=c.spaces[e],g.value.container&&(d=document.getElementById(g.cID),h=g.value.container.style.border,h=""!=h?"border:"+h+";":"",g.value.container.setAttribute("style",
h),d.appendChild(g.value.container));for(e=0;e<c.ctrs.length;e++)if(g=c.ctrs[e],h=g.value.containerControl||g.value.container)d=document.getElementById(g.cID),h.setAttribute("style","width:"+g.value.w+"px;height:"+g.value.h+"px;"),d.appendChild(h);richTextEditor.adjustFormulaFontSize(b);richTextEditor.adjustHeight(b)}var x;try{x=new CustomEvent("descartesReady",{detail:""})}catch(f){x=document.createEvent("CustomEvent"),x.initCustomEvent("descartesReady",!1,!1,{cmd:""})}window.dispatchEvent(x)};a.DescartesApp.prototype.adjustSize=
function(){document.body.style.margin="0px";document.body.style.padding="0px";this.parentC.style.margin="0px";this.parentC.style.padding="0px";var c=parseInt(this.width)+30,b=parseInt(this.height)+90;window.moveTo((parseInt(screen.width)-c)/2,(parseInt(screen.height)-b)/2);window.resizeTo(c,b);a.onResize()};a.DescartesApp.prototype.adjustDimensions=function(){var a,b,c;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);
b=parseInt(this.parentC.offsetWidth);a=this.init_w;c=b/a;a>b?(this.parentC!=document.body&&(this.parentC.style.height=this.init_h*c+"px"),this.percent=c,this.container.style.webkitTransform=this.container.style.MozTransform="scale("+c+")",this.container.style.webkitTransformOrigin=this.container.style.MozTransformOrigin="top left"):(this.parentC!=document.body&&(this.parentC.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,b=this.buttonsConfig,d=this.container,e="15",g=100,h=100,l=100,x=100;2==this.version&&(e="14",g=63,h=50,l=44,x=53);var f=0,q=0,m=0,w,y,B=0,E=this.northSpace.controls,F=this.southSpace.controls,D=this.eastSpace.controls,G=this.westSpace.controls;if(0<b.rowsNorth||0<E.length||b.about||b.config){0>=b.rowsNorth?(f=b.height,b.rowsNorth=1):f=b.height*b.rowsNorth;y=this.northSpace.container;
y.setAttribute("id","descartesJS_north");y.setAttribute("style","width:"+d.width+"px; height:"+f+"px; background:#c0c0c0; position:absolute; left:0px; top: "+this.plecaHeight+"px; z-index:100;");d.insertBefore(y,this.loader);y=d.width;var H=0;b.about?(H=g,y-=H):g=0;b.config&&(y-=h);var K=Math.ceil(E.length/b.rowsNorth),C=y/K;w=0;for(var A=E.length;w<A;w++)E[w].expresion=c.parse("("+(H+w%K*C)+","+b.height*Math.floor(w/K)+","+C+","+b.height+")"),E[w].drawif=c.parse("1"),E[w].init();b.about&&(w=new a.Button(this,
{region:"north",name:"english"==this.language?"about":"cr\u00e9ditos",font_size:c.parse(e),expresion:c.parse("(0, 0, "+g+", "+f+")")}),w.actionExec={execute:a.showAbout},w.update());b.config&&(new a.Button(this,{region:"north",name:"config",font_size:c.parse(e),action:"config",expresion:c.parse("("+(y+g)+", 0, "+h+", "+f+")")})).update()}if(0<b.rowsSouth||0<F.length||b.init||b.clear){0>=b.rowsSouth?(q=b.height,b.rowsSouth=1):q=b.height*b.rowsSouth;g=d.width;H=0;b.init?(H=l,g-=H):l=0;b.clear&&(g-=
x);y=this.southSpace.container;y.setAttribute("id","descartesJS_south");y.setAttribute("style","width:"+d.width+"px; height:"+q+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+(d.height-q)+"px; z-index:100;");d.insertBefore(y,this.loader);K=Math.ceil(F.length/b.rowsSouth);C=g/K;w=0;for(A=F.length;w<A;w++)F[w].expresion=c.parse("("+(H+w%K*C)+","+b.height*Math.floor(w/K)+","+C+","+b.height+")"),F[w].drawif=c.parse("1"),F[w].init();b.init&&(new a.Button(this,{region:"south",name:"english"==
this.language?"init":"inicio",font_size:c.parse(e),action:"init",expresion:c.parse("(0, 0, "+l+", "+q+")")})).update();b.clear&&(new a.Button(this,{region:"south",name:"english"==this.language?"clear":"limpiar",font_size:c.parse(e),action:"clear",expresion:c.parse("("+(g+l)+", 0, "+x+", "+q+")")})).update()}if(0<D.length)for(m=d.height-f-q,e=b.widthEast,y=this.eastSpace.container,y.setAttribute("id","descartesJS_east"),y.setAttribute("style","width:"+e+"px; height:"+m+"px; background:#c0c0c0; position:absolute; left:"+
(d.width-e)+"px; top:"+f+"px; z-index:100;"),d.insertBefore(y,this.loader),w=0,A=D.length;w<A;w++)D[w].expresion=c.parse("(0,"+b.height*w+","+e+","+b.height+")"),D[w].drawif=c.parse("1"),D[w].init();if(0<G.length)for(w=d.height-f-q,B=b.widthWest,y=this.westSpace.container,y.setAttribute("id","descartesJS_west"),y.setAttribute("style","width: "+B+"px; height: "+w+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+f+"px; z-index: 100;"),d.insertBefore(y,this.loader),w=0,A=G.length;w<A;w++)G[w].expresion=
c.parse("(0,"+b.height*w+","+B+","+b.height+")"),G[w].drawif=c.parse("1"),G[w].init();if(this.editableRegionVisible)for(c=b.height,y=this.editableRegion.container,y.setAttribute("id","descartesJS_editableRegion"),y.setAttribute("style","width:"+d.width+"px; height:"+c+"px; position:absolute; left:0px; top:"+(d.height-q-b.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;"),d.insertBefore(y,this.loader),b=this.editableRegion.textFields,d=d.width/b.length,G=a.getFieldFontSize(c),w=0,A=b.length;w<
A;w++)"div"==b[w].type?(y.appendChild(b[w].container),b[w].container.setAttribute("style","font-family:descartesJS_sansserif,Arial,Sans-serif;width:"+(d-4)+"px;height:"+c+"px;position:absolute;left:"+w*d+"px;top:0;"),D=b[w].container.firstChild,D.setAttribute("style","font-family:descartesJS_sansserif,Arial,Sans-serif;font-size:"+G+"px;padding-top:0%;background-color:#e0e4e8;position:absolute;left:0;top:0;height:"+c+"px;text-align:center;line-height:"+c+"px;"),e=D.offsetWidth,D.style.width=e+"px",
D.firstChild.textContent=D.firstChild.textContent.substring(3,D.firstChild.textContent.length-3),b[w].container.lastChild.setAttribute("style","font-family:descartesJS_monospace,'Courier New',Monospace;font-size:"+G+"px;width:"+(d-e)+"px;height:"+c+"px;position:absolute;left:"+e+"px;top:0;border:2px groove white;")):(y.appendChild(b[w]),b[w].setAttribute("style","font-family:descartesJS_monospace,'Courier New',Monospace;font-size:"+G+"px;width:"+d+"px;height:"+c+"px;position:absolute;left:"+w*d+"px;top:0;border:2px groove white;"));
this.displaceRegionNorth=f;this.displaceRegionSouth=q;this.displaceRegionEast=m;this.displaceRegionWest=B;w=0;for(A=this.spaces.length;w<A;w++)this.spaces[w].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,b=this.spaces.length;a<b;a++)this.spaces[a].clearClick()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,
b=0,c=this.controls.length;b<c;b++)a=this.controls[b],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,b=this.auxiliaries.length;a<b;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=function(){for(var a=0,b=this.events.length;a<b;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,b=this.controls.length;a<b;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var b=
0,c=this.spaces.length;b<c;b++)this.spaces[b].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,b=this.spaces.length;a<b;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground&&this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=function(){this.animation&&this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.reinit()};a.DescartesApp.prototype.stopAudios=
function(){this.stop();for(var a in this.audios)this.audios.hasOwnProperty(a)&&this.audios[a].pause&&(this.audios[a].pause(),this.audios[a].currentTime=0)};a.DescartesApp.prototype.getImage=function(a){var b=this.images;return a?(b[a]||(b[a]=new Image,b[a].addEventListener("load",function(){this.ready=1}),b[a].addEventListener("error",function(){this.ready=0;this.errorload=1}),b[a].src=a),b[a]):new Image};a.DescartesApp.prototype.getAudio=function(c){var b=this.audios;if(c){if(!b[c]){var d=c.lastIndexOf("."),
d=-1===d?c.lenght:d;c.substring(0,d);b[c]=new Audio(c);var e=function(a){this.ready=1};b[c].addEventListener("canplaythrough",e);var g=function(a){this.canPlayType("audio/"+c.substring(c.length-3))||"mp3"!=c.substring(c.length-3)?(console.log("El archivo '"+c+"' no puede ser reproducido"),this.errorload=1):(b[c]=new Audio(c.replace("mp3","ogg")),b[c].addEventListener("canplaythrough",e),b[c].addEventListener("load",e),b[c].addEventListener("error",g),b[c].load())};b[c].addEventListener("error",g);
b[c].play();a.setTimeout(function(){b[c].pause()},15)}return b[c]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var b,c=0,d=this.controls.length;c<d;c++)if(b=this.controls[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var b,c=0,d=this.controls.length;c<d;c++)if(b=this.controls[c],b.id==a)return b;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var b,c=0,d=this.spaces.length;c<
d;c++)if(b=this.spaces[c],b.cID==a)return b;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var b,c=0,d=this.spaces.length;c<d;c++)if(b=this.spaces[c],b.id==a)return b;return{update:function(){},w:0}};var d;a.DescartesApp.prototype.getState=function(){var a,b="",c=this.evaluator.variables,d;for(d in c)c.hasOwnProperty(d)&&(a=c[d],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&"rnd"!=d&&"pi"!=d&&"e"!=d&&"Infinity"!=d&&"-Infinity"!=d&&"object"!=typeof a&&(b=""!=
b?b+"\n"+d+"="+a:d+"="+a));var c=this.evaluator.vectors,e;for(e in c)c.hasOwnProperty(e)&&(a=c[e],b=b+"\n"+e+"="+h(a));e=this.evaluator.matrices;for(var g in e)e.hasOwnProperty(g)&&(a=e[g],b=b+"\n"+g+"="+h(a));return b};a.DescartesApp.prototype.setState=function(a,b){for(var c=a.split("\n"),d,e,g=0,h=c.length;g<h;g++)d=c[g].split("="),2<=d.length&&(e=eval(d[1]),-1!=d[1].indexOf("[[")?(this.evaluator.matrices[d[0]]=e,this.evaluator.matrices[d[0]].rows=e.length,this.evaluator.matrices[d[0]].cols=e[0].length):
-1!=d[1].indexOf("[")?(this.evaluator.vectors[d[0]]=e,this.evaluator.variables[d[0]+".long"]=e.length):this.evaluator.variables[d[0]]=e);b||this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,b=0,c="",d=0,e=this.controls.length;d<e;d++)"textfield"==this.controls[d].gui&&this.controls[d].evaluate&&(a++,b+=this.controls[d].ok,this.controls[d].value=""==this.controls[d].value?"''":this.controls[d].value,c+=" \\n "+this.controls[d].id+"="+this.controls[d].value+"|"+this.controls[d].ok);
return"questions="+a+" \\n correct="+b+" \\n wrong="+(a-b)+c};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,b=0,c=a.length;b<c;b++)"textfield"==a[b].gui&&a[b].evaluate&&a[b].changeValue(a[b].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,b=this.saveState.length;a<b;a++)this.evaluator.eval(this.saveState[a]);this.update()};var l,c,g;return a}(descartesJS||{}),descartesJS=function(a){function h(){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 e(c){c=document.createElement("div");c.innerHTML='<div style="font-size:12px;visibility:hidden;">\n<div style="font-family:descartesJS_serif;">\n<span>_</span>\n<span style="font-weight:bold;">_</span>\n<span style="font-style:italic;">_</span>\n<span style="font-weight:bold;font-style:italic;">_</span>\n</div>\n<div style="font-family:descartesJS_sansserif;">\n<span>_</span>\n<span style="font-weight:bold;">_</span>\n<span style="font-style:italic;">_</span>\n<span style="font-weight:bold;font-style:italic;">_</span>\n</div>\n<div style="font-family:descartesJS_monospace;">\n<span>_</span>\n<span style="font-weight:bold;">_</span>\n<span style="font-style:italic;">_</span>\n<span style="font-weight:bold;font-style:italic;">_</span>\n</div>\n<div style="font-family:descartesJS_extra;">\n<span>_</span>\n<span style="font-weight:bold;">_</span>\n<span style="font-style:italic;">_</span>\n<span style="font-weight:bold;font-style:italic;">_</span>\n</div>\n</div>';
document.body.appendChild(c);a.getFeatures();if(a.hasCanvas){window.scrollTo(0,10);for(var d=document.querySelectorAll(".DescartesAppContainer"),b=0,e=d.length;b<e;b++)d[b].parentNode.removeChild(d[b]);for(var b=document.querySelectorAll("applet,ajs"),e=/Descartes|DescartesJS|descinst.DescartesWeb2_0.class|Arquimedes|Discurso/i,d=[],h=0,l=b.length;h<l;h++)e.test(b[h].getAttribute("code"))&&d.push(b[h]);b=0;for(e=d.length;b<e;b++)a.apps.push(new a.DescartesApp(d[b])),d[b].className="DescartesJS";window.addEventListener("resize",
a.onResize);window.scrollTo(0,0)}else document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:block;} applet {display:block;} ajs.DescartesJS {display:block;} ajs {display:block;}";document.body.removeChild(c)}if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};window.hasOwnProperty("debugDescartesJS")&&debugDescartesJS||h();a.onResize=function(c){0<a.apps.length&&a.apps[0].scaleToFit()};a.onMessage=function(c){if(0<a.apps.length){var d=c.data;
d&&("set"===d.type?"string"==typeof d.value||"number"==typeof d.value?a.apps[0].evaluator.setVariable(d.name,d.value):d.value&&void 0!=d.value.rows?a.apps[0].evaluator.matrices[d.name]=d.value:a.apps[0].evaluator.vectors[d.name]=d.value:"update"===d.type?a.apps[0].update():"exec"===d.type?(c=a.apps[0].evaluator.getFunction(d.name),d=d.value.toString().split(","),c&&c.apply(a.apps[0].evaluator,d)):"isResizeNeeded"===d.type?c.source.postMessage({type:"doResize"},"*"):"doResize"===d.type&&0<a.apps.length&&
a.apps[0].adjustSize())}};if(void 0==a.loadLib){a.loadLib=!0;window.addEventListener("load",e);window.addEventListener("message",a.onMessage);for(var d=["webkitTransitionEnd","transitionend","oTransitionEnd","MSTransitionEnd"],l=0,c=d.length;l<c;l++)window.addEventListener(d[l],function(c){a.onResize(c)})}return a}(descartesJS||{});
