/*
 Joel Espinosa Longi
 joel.espinosa@amite.mx
 j.longi@gmail.com
 LGPL - http://www.gnu.org/licenses/lgpl.html
 2013-05-03
*/
var babel=function(a){if(a.loadLib)return a;a.falso=a["false"]=a.fals=a.gezurra=a.faux=a.fals="false";a.verdadero=a["true"]=a.veritable=a.egia=a.vrai=a.verdadeiro=a.veritable="true";a.no=a.ez=a.non=a["n\u00e3o"]="false";a["s\u00ed"]=a.yes=a.bai=a.oui=a.si=a["sim "]="true";a.negro=a.black=a.negre=a.beltza=a.noir=a.preto="#000000";a.maxenta=a.magenta="#ff00ff";a.azul=a.blue=a.blau=a.urdina=a.bleu="#0000ff";a.turquesa=a.cyan=a.turkesa=a.turquoise="#00ffff";a.verde=a.green=a.verd=a.berdea=a.vert="#00ff00";
a.amarillo=a.yellow=a.groc=a.horia=a.jaune=a.amarelo="#ffff00";a.naranja=a.orange=a.taronja=a.laranja=a.laranxa="#ffc800";a.rojo=a.red=a.vermell=a.gorria=a.rouge=a.vermello=a.vermelho="#ff0000";a.pink=a.rosa=a.arrosa=a.rose="#ffafaf";a.grisObscuro=a.darkGray=a.grisFosc=a["gris iluna"]=a.grisObscur=a.grisEscuro=a.cinzaEscuro="#404040";a.gris=a.gray=a.grisa=a.cinza="#808080";a.grisClaro=a.lightGray=a.grisClar=a["gris argia"]=a.grisClair=a.cinzaClaro="#c0c0c0";a.blanco=a.white=a.blanc=a.zuria=a.branco=
"#ffffff";a.escala=a.scale=a.eskala=a["\u00e9chelle"]="scale";a.nombre=a.name=a.nom=a.izena=a.nome="name";a.ikusgai=a["vis\u00edvel"]=a.visible="visible";a.rastro=a.trace=a.rastre=a.arrastoa="trace";a.fondo=a.background=a.fons=a.hondoa=a.fond=a.fundo="background";a.colour=a.color=a.kolorea=a.couleur=a.cor="color";a["par\u00e1metro"]=a.parameter=a.parametroa=a["par\u00e2metro"]=a["par\u00e0metre"]="parameter";a["sucesi\u00f3n"]=a.sequence=a["successi\u00f3"]=a.segida=a.succession=a["seq\u00fc\u00eancia"]=
"sequence";a["tama\u00f1o"]=a.size=a.neurria=a.taille=a.tamanho=a["grand\u00e0ria"]="size";a.decimales=a.decimals=a.hamartarra=a["d\u00e9cimales"]=a.decimais="decimals";a.red=a.net=a.xarxa=a.sarea=a["r\u00e9seau"]=a.rede=a.malha="net";a.red10=a.net10=a.xarxa10=a.sarea10=a["r\u00e9seau10"]=a.rede10=a.malha10="net10";a.ejes=a.axes=a.eixos=a.ardatzak=a.eixes="axes";a.texto=a.text=a.testua=a.texte="text";a["cr\u00e9ditos"]=a.about=a["cr\u00e8dits"]=a.kreditoak=a["cr\u00e9dits"]=a.sobre="about";a.config=
a.konfig=a["configura\u00e7\u00e3o"]="config";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.limpiar=a.clear=a.neteja=a.ezabatu=a.nettoye=a.limpar="clear";a.incr=a.gehi=a.incremento="incr";a.min=a.inf="min";a.max=a.sup=a["m\u00e1x"]="max";a.relleno=a.fill=a.ple=a.betea=a.plein=a.recheo=a.preencher="fill";a["relleno+"]=a["fill+"]=a["ple+"]=a["betea+"]=a["plein+"]=a["recheo+"]=a["preencher+"]="fillP";a["relleno-"]=a["fill-"]=a["ple-"]=a["betea-"]=a["plein-"]=a["recheo-"]=
a["preencher-"]="fillM";a.flecha=a.arrow=a.fletxa=a.gezia=a["fl\u00e8che"]=a.frecha=a.seta="arrow";a.ancho=a.width=a.ample=a.zabalera=a.large=a.largura="width";a.punta=a.spear=a.muturra=a.pointe=a.ponta="spear";a["regi\u00f3n"]=a.region=a["regi\u00f3"]=a.eskualde=a["r\u00e9gion"]=a["rexi\u00f3n"]=a["regi\u00e3o"]="region";a.norte=a.north=a.nord=a.ipar="north";a.sur=a.south=a.sud=a.hego=a.sul="south";a.este=a.east=a.est=a.ekialde=a.leste="east";a.oeste=a.west=a.oest=a.hegoalde=a.ouest="west";a.exterior=
a.external=a.kanpoalde=a.externo="external";a["expresi\u00f3n"]=a.expresion=a["expresi\u00f3"]=a.adierazpen=a["express\u00e3o"]="expresion";a.tipo=a.type=a.tipus=a.mota="type";a["posici\u00f3n"]=a.position=a["posici\u00f3"]=a.posizio=a["posi\u00e7\u00e3o"]="position";a["constricci\u00f3n"]=a.constraint=a["constricci\u00f3"]=a.beharte=a.constriction=a["constrici\u00f3n"]=a["restri\u00e7\u00e3o"]="constraint";a.valor=a.value=a.balio=a.valeur="value";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=
a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.curva=a.curve=a.corba=a.kurba=a.courbe="curve";a.texto=a.text=a.testu=a.texte="text";a.punto=a.point=a.punt=a.puntu=a.ponto="point";a.segmento=a.segment=a.zuzenki="segment";a.arco=a.arc=a.arku="arc";a["pol\u00edgono"]=a.polygon=a["pol\u00edgon"]=a.poligono=a.polygone="polygon";a.imagen=a.image=a.imatge=a.irudi=a.imaxe=a.imagem="image";a["Versi\u00f3n"]=a.Version=a["Versi\u00f3"]=a["Vers\u00e3o"]="version";a.Idioma=a.Language=a.Hizkuntza=a.Langue=
"language";a["O.x"]="O.x";a["O.y"]="O.y";a.Botones=a.Buttons=a.Botons=a.Botoiak=a.Boutons=a["Bot\u00f3ns"]=a["Bot\u00f5es"]=a.Botons="Buttons";a["Animaci\u00f3n"]=a.Animation=a["Animaci\u00f3"]=a.Animazio=a["Anima\u00e7\u00e3o"]="Animation";a.constante=a.constant=a.Konstante="constant";a.fuente=a.font=a.iturri=a.source=a.fonte="font";a["num\u00e9rico"]=a.numeric=a["num\u00e8ric"]=a.zenbakizko=a["num\u00e9rique"]="numeric";a["gr\u00e1fico"]=a.graphic=a["gr\u00e0fic"]=a.grafiko=a.graphique="graphic";
a.texto=a.text=a.testu=a.texte="text";a.inicio=a.init=a.inici=a.hasiera=a.commencement=a["in\u00edcio"]="init";a.hacer=a["do"]=a.fer=a.egin=a.faire=a.facer=a.fazer="doExpr";a.mientras=a["while"]=a.mentre=a.bitartean=a["tandis que"]=a.mentres=a.enquanto="whileExpr";a.evaluar=a.evaluate=a.avalua=a.ebaluatu=a["\u00e9valuer"]=a.avaliar="evaluate";a.variable=a.aldagaia=a["vari\u00e1vel"]="variable";a["funci\u00f3n"]=a["function"]=a["funci\u00f3"]=a.funtzio=a.fonction=a["fun\u00e7\u00e3o"]="function";a.algoritmo=
a.algorithm=a.algorisme=a.algorithme="algorithm";a.vector=a.array=a.bektore=a.vecteur=a.matriz="array";a["dibujar-si"]=a["draw-if"]=a["marraztu-baldin"]=a["dessiner-si"]=a["debuxar-se"]=a["desenhar-se"]=a["dibuixa-si"]="drawif";a.dominio=a.range=a.domini=a["izate-eremua"]=a.domain=a["dom\u00ednio"]="range";a.pausa=a.delay=a.eten="delay";a["eje-x"]=a["x-axis"]=a["eix-x"]=a["x-ardatza"]=a["axe-x"]=a["eixe-x"]=a["eixo-x"]="x_axis";a["eje-y"]=a["y-axis"]=a["eix-y"]=a["y-ardatza"]=a["axe-y"]=a["eixe-y"]=
a["eixo-y"]="y_axis";a["n\u00fameros"]=a.numbers=a.nombres=a.zenbakiak="numbers";a["exponencial-si"]=a["exponential-if"]=a["esponentzial-baldin"]=a["exponentiel-si"]=a["exponencial-se"]="exponentialif";a.familia=a.family=a["fam\u00edlia"]=a.famille="family";a.intervalo=a.interval=a.tarte=a.intervalle="interval";a.pasos=a.steps=a.passos=a.pausoak=a.pas="steps";a.centro=a.center=a.centre=a.zentro="center";a.radio=a.radius=a.radi=a.erradio=a.rayon=a.raio="radius";a.fin=a.end=a.fi=a.bukaera=a.fim="end";
a["una-sola-vez"]=a["only-once"]=a["una-sola-vegada"]=a["behin-bakarrik"]=a["une-seule-fois"]=a["unha-soa-vez"]=a["apenas-uma-vez"]="onlyOnce";a.siempre=a.always=a.sempre=a.beti=a.toujours="always";a["color-int"]=a["int-colour"]=a["barruko-kolore"]=a["couleur-int"]=a["cor-int"]="colorInt";a.repetir=a.loop=a.repeteix=a.errepikatu=a["r\u00e9p\u00e9ter"]="loop";a.controles=a.controls=a.kontrolak=a["contr\u00f4les"]=a.controis="controls";a.animar=a.animate=a.anima=a.animatu=a.animer="animate";a.auto=
"auto";a.alto=a.height=a.alt=a.altu=a.haut=a.altura="height";a.x=a.left="x";a.y=a.top="y";a.espacio=a.space=a.espai=a.espazio=a.espace=a.espazo=a["espa\u00e7o"]="space";a.Nu="Nu";a.Nv="Nv";a.ancho=a.depth=a.amplada=a.zabalera=a.largeur=a.ancho=a.profundidade=a.amplada="width";a.largo=a.length=a.llargada=a.luzera=a.longueur=a.longo=a.comprimento=a.llargada="length";a.alto=a.height=a["al\u00e7ada"]=a.altu=a.hauteur=a.alto=a.altura=a["al\u00e7ada"]="height";a.color_reverso=a.backcolor=a.color_revers=
a["atzealde kolorea"]=a.couleur_revers=a.cor_reverso=a.cor_de_fundo="backcolor";a.aristas=a.edges=a.arestes=a.ertzak=a["ar\u00eates"]=a.arestas="edges";a.rotini=a.inirot="inirot";a.posini=a.inipos="inipos";a["tri\u00e1ngulo"]=a.triangle=a.hirukia=a["tri\u00e2ngulo"]="triangle";a.cara=a.face=a.aurpegi="face";a.polireg=a.regpoly=a["pol\u00edgonoRegular"]="polireg";a.superficie=a.surface=a["superf\u00edcie"]=a.azalera="surface";a.cubo=a.cube=a.cub=a.kubo="cube";a["paralelep\u00edpedo"]=a.box=a["paral\u00b7lelep\u00edpede"]=
a.paralelepipedo=a["parall\u00e9l\u00e9pip\u00e8de"]="box";a.cono=a.cone=a.con=a.kono=a["c\u00f4ne"]="cone";a.cilindro=a.cylinder=a.cilindre=a.zilindro=a.cylindre="cylinder";a.esfera=a.sphere=a["sph\u00e8re"]="sphere";a.tetraedro=a.tetrahedron=a.tetraedre=a["t\u00e9tra\u00e8dre"]="tetrahedron";a.octaedro=a["octahedron="]=a.octaedre=a.oktaedro=a["octa\u00e8dre"]="octahedron";a.dodecaedro=a.dodecahedron=a.dodecaedre=a.dodekaedro=a["dod\u00e9ca\u00e8dre"]="dodecahedron";a.icosaedro=a.icosahedron=a.icosaedre=
a.ikosaedro=a["icosa\u00e8dre"]="icosahedron";a.elipsoide=a.ellipsoid=a["el\u00b7lipsoide"]=a["ellipso\u00efde"]=a["elips\u00f3ide"]="ellipsoid";a.macro=a.makro="macro";a.id="id";a.modelo=a.model=a.eredu=a["mod\u00e8le"]="model";a.color=a.kolore=a.couleur=a.cor="color";a.luz=a.light=a.llum=a.argia=a["lumi\u00e8re"]="light";a.metal=a.metall=a["m\u00e9tal"]="metal";a.alambre=a.wire=a.filferro=a.alanbre=a["fil de fer"]=a.arame="wire";a.cortar=a.split=a.talla=a.moztu=a.couper=a.dividir="split";a.despliegue=
a.render=a.desplegament=a.zabaltze=a["d\u00e8ploiement"]=a.despregamento=a.processar="render";a.orden=a.sort=a.ordre=a.ordena=a.orde=a.ordenar="sort";a.pintor=a.painter=a.margolari=a.peintre="painter";a["trazado de rayos"]=a["ray trace"]=a["tra\u00e7at de raigs"]=a["izpi trazadura"]=a["trace de rayons"]=a["trazado de raios"]=a["tra\u00e7ado de raios"]="raytrace";a.imagen=a.bg_image=a.imatge=a.irudia=a.imaxe=a.imagem_de_fundo="image";a.despl_imagen=a.bg_display=a.despl_imatge=a["irudi desplazamendu"]=
a.despl_image=a.despr_imaxe=a["apresenta\u00e7\u00e3o_de_imagem"]="bg_display";a["arr-izq"]=a.topleft=a["dalt-esq"]=a["goi-ezk"]=a["au-dessus-gau"]=a["arr-esq"]=a["acima-esquerda"]="topleft";a["expand."]=a.stretch=a.hedatu=a["expandir "]="stretch";a.mosaico=a.patch=a.mosaic=a.mosaiko=a["mosa\u00efque"]="patch";a.centrada=a.center=a.zentratu=a["centr\u00e9e"]=a.centrado="center";a.archivo=a.file=a.fitxer=a.artxibo=a.fichier=a.arquivo="file";a.filas_norte=a.rows_north=a.files_nord=a["HTML kodea"]=a.files_nord=
a.filas_norte=a.linhas_norte=a.files_nord="rowsNorth";a.filas_sur=a.rows_south=a.files_sud=a.ipar_lerro=a.files_sud=a.filas_sur=a.linhas_sul=a.files_sud="rowsSouth";a.ancho_este=a.width_east=a.ample_est=a.hego_lerro=a.ample_est=a.ancho_leste=a.largura_leste=a.ample_est="widthEast";a.ancho_oeste=a.width_west=a.ample_oest=a.ekialde_zabalera=a.ample_ouest=a.ancho_oeste=a.largura_oeste=a.ample_oest="widthWest";a.fijo=a.fixed=a.fix=a.hegoalde_zabalera=a.fixe=a.fixo="fixed";a["Reiniciar Animaci\u00f3n"]=
a["Init Animation"]=a["Reinicia Animaci\u00f3"]=a.finko=a["Recommencer l'Animation"]=a["Reiniciar Anima\u00e7\u00e3o"]="initAnimation";a["Explicaci\u00f3n"]=a.Explanation=a.Azalpena=a.Explication=a["Explica\u00e7\u00e3o"]=a["Explicaci\u00f3"]="Explanation";a.tooltip=a.dica="tooltip";a.discreto=a.discrete=a.discret=a.diskretu="discrete";a.interfaz=a.gui=a["interf\u00edcie"]=a.interfaze=a["interface"]="gui";a.pulsador=a.spinner=a.polsador=a.pultsadore=a.bouton="spinner";a["campo de texto"]=a.textfield=
a["camp de text"]=a["testu esarrua"]=a["champ de texte"]="textfield";a["men\u00fa"]=a.choice=a.menu=a.escolha="menu";a.barra=a.scrollbar=a.barre="scrollbar";a.opciones=a.options=a.opcions=a.aukerak=a["opci\u00f3ns"]=a["op\u00e7\u00f5es"]="options";a.interior=a.barruko=a["int\u00e9rieur"]="interior";a["condici\u00f3n"]=a.condition=a["condici\u00f3"]=a.baldintza=a["condi\u00e7\u00e3o"]="condition";a["acci\u00f3n"]=a.action=a["acci\u00f3"]=a.ekintza=a["a\u00e7\u00e3o"]="action";a.evento=a.event=a.esdeveniment=
a.gertaera=a["\u00e9v\u00e9nement"]="event";a["abrir URL"]=a["open URL"]=a["obre URL"]=a["URL zabaldu"]=a["ouvrir URL"]="openURL";a["abrir Escena"]=a["open Scene"]=a["obre Escena"]=a["eszena zabaldu"]=a["ouvrir Escena"]=a["abrir Cena"]="openScene";a["bot\u00f3n"]=a.button=a["bot\u00f3"]=a.botoi=a.bouton=a["bot\u00e3o"]="button";a.mensaje=a.message=a.mezua=a.mensaxe=a.mensagem=a.missatge="message";a.alternar=a.alternate=a.alterna=a.txandakatu=a.alterner="alternate";a["ejecuci\u00f3n"]=a.execution=
a["execuci\u00f3"]=a.gauzatze=a["ex\u00e9cution"]=a["execuci\u00f3n"]=a["execu\u00e7\u00e3o"]="execution";a.calcular=a.calculate=a.calcula=a.kalkulatu=a.calculer="calculate";a.coord_abs=a.abs_coord=a.koor_abs="abs_coord";a.negrita=a.bold=a.negreta=a.lodi=a["caract\u00e8re gras"]=a.negra=a.negrito="bold";a.cursiva=a.italics=a.etzana=a.italique=a["it\u00e1lico"]="italics";a.subrayada=a.underlined=a.subratllat=a.azpimarratua=a.soulignement=a["subli\u00f1ada"]=a.sublinhado="underlined";a.imagen=a.image=
a.imatge=a.irundia=a.imaxe=a.imagem="image";a.pos_mensajes=a.msg_pos=a.pos_missatges=a.mezuen_pos=a.pos_messages=a.pos_mensaxes="msg_pos";a.izquierda=a.left=a.esquerra=a.eskerrean=a.gauche=a.esquerda=a.esquerda=a.esquerra="x";a.derecha=a.right=a.dreta=a.eskuinan=a.droite=a.dereita=a.direita=a.dreta="right";a["sensible_a_los_movimientos_del_rat\u00f3n"]=a.sensitive_to_mouse_movements=a["sensible_als_moviments_del_ratol\u00ed"]=a["xagu mugimenduarekiko sentikorra"]=a.sensible_aux_mouvements_du_souris=
a.sensible_aos_movementos_do_rato=a["sens\u00edvel_aos_movimentos_do_mouse"]="sensitive_to_mouse_movements";a.reproducir=a.play=a.reprodueix=a.erreproduzitu=a.reproduire=a.reproduzir="playAudio";a["activo-si"]=a["active-if"]=a["actiu-si"]=a["altiboa-baldin"]=a["actif-si"]=a["activo-se"]=a["ativo-se"]="activeif";a.rotfin=a.finrot=a.bukrot="endrot";a.posfin=a.finpos=a.bukpos="endpos";a.editable=a.editagarria=a["edit\u00e1vel"]="editable";a.tipo=a.type=a.tipus=a.mota="type";a.R2="R2";a.R3="R3";a.vectores=
a.bektoreak=a.vecteurs=a.vetores=a.vectors="vectors";a["fuente puntos"]=a["font size"]=a["font punts"]=a["puntu iturria"]=a["source points"]=a["fonte puntos"]=a["fonte pontos"]="font_size";a["ecuaci\u00f3n"]=a.equation=a["equaci\u00f3"]=a.ekuazio=a["\u00e9quation"]=a["equa\u00e7\u00e3o"]="equation";a.punto=a.dot=a.punt=a.puntu=a.point=a.ponto="point";a.escenario=a.scenario=a.escenari=a.agertoki=a["sc\u00e8ne"]=a["cen\u00e1rio"]="scenario";a.cID="cID";a.matriz=a.matrix=a.matriu=a.matrice="matrix";
a.filas=a.rows=a.files="rows";a.columnas=a.columns=a.colonnes="columns";a.solo_texto=a.only_text=a.seulement_texte=a["s\u00f3_texto"]=a.tan_sols_texte="onlyText";a.evaluar=a.evaluate="evaluate";a.respuesta=a.answer="answer";a.decimal_symbol=a["signo decimal"]=a["decimal symbol"]="decimal_symbol";a.info="info";a.color_contorn_text=a.color_text_border=a.color_borde_texto=a.muga_testuaren_kolorea=a.couleur_contour_texte=a.cor_borde_texto=a.colore_bordo_testo=a.cor_borda_texto=a.color_contorn_text="border";
a.video=a["vid\u00e9o"]="video";a.audio=a["\u00e0udio"]="audio";a.autoplay="autoplay";a.loop="loop";a.poster="poster";a.opacidad=a.opacity=a["opacit\u00e9"]=a.opacitat=a.opacidade="opacity";a.alinear=a.align=a["ali\u00f1ar"]=a.aligner="align";a.malla=a.mesh="mesh";a.local=a.Local="local";a.loadLib=!0;return a}(babel||{}),descartesJS=function(a){function d(){var a,c,d,e;Number.prototype.toFixed=function(k){k=0>k?0:parseInt(k);a=this.toString();c=a.indexOf(".");d="";if(-1===c){0<k&&(d=".");for(var g=
0;g<k;g++)d+="0";return a+d}e=a.length-c-1;if(e>=k)return 0<k?a.substring(0,c+1+k):a.substring(0,c);g=0;for(k-=e;g<k;g++)d+="0";return a+d}}function h(a,c,d){a.fillStyle="#c0c0c0";a.fillRect(c.offsetLeft,c.offsetTop,c.offsetWidth,c.offsetHeight);g(a,c,d.controls)}function g(a,c,d){for(var e,k=d.length-1;0<=k;k--)e=d[k],a.drawImage(e.getScreenshot(),c.offsetLeft+e.x,c.offsetTop+e.y)}if(a.loadLib)return a;var c=2*Math.PI,f=360/c,k=c/360,l=Math.floor,e,p,m,n,t,s,u,q,r,w;a.rangeOK=1;a.extend=function(a,
c){if(a.prototype.__proto__)a.prototype.__proto__=c.prototype;else for(var d in c.prototype)c.prototype.hasOwnProperty(d)&&(a.prototype[d]=c.prototype[d]);a.prototype.uber=c.prototype};a.radToDeg=function(a){return a*f};a.degToRad=function(a){return a*k};a.convertFont=function(a){if(""==a)return a;e=a.split(",");p="";"bold"==e[1].toLowerCase()?p+="Bold ":"italic"==e[1].toLowerCase()||"italics"==e[1].toLowerCase()?p+="Italic ":"bold+italic"==e[1].toLowerCase()&&(p+="Italic Bold ");p+=e[2]+"px ";m=
e[0].split(" ")[0].toLowerCase();return p="serif"===m||"times new roman"===m||"timesroman"===m||"times"===m?p+"'Times New Roman', Times, 'Droid Serif', serif":"sansserif"===m||"arial"===m||"helvetica"===m?p+"Arial, Helvetica, 'Droid Sans', Sans-serif":p+"'Courier New', Courier, 'Droid Sans Mono', Monospace"};a.drawLine=function(a,c,d,e,k,g,f){a.lineWidth=f||1;a.strokeStyle=g||"black";g=a.lineWidth%2?0.5:0;a.beginPath();a.moveTo(l(c)+g,l(d)+g);a.lineTo(l(e)+g,l(k)+g);a.stroke()};a.getColor=function(a,
c){if("string"==typeof c)return c;n=a.evalExpression(c);t=l(255*n[0][0]);s=l(255*n[0][1]);u=l(255*n[0][2]);q=1-n[0][3];return"rgba("+t+","+s+","+u+","+q+")"};a.getFeatures=function(){a.hasJavaSupport=navigator.javaEnabled();var c=navigator.appVersion.toLowerCase();a.hasTouchSupport=window.hasOwnProperty&&window.hasOwnProperty("ontouchstart")||c.match("android")&&!0;a.hasTouchSupport=navigator.userAgent.toLowerCase().match("qt")?!1:a.hasTouchSupport;c=document.createElement("canvas");a.hasCanvasSupport=
c.getContext&&c.getContext("2d");a.hasCanvasSupport&&(a.ctx=document.createElement("canvas").getContext("2d"));try{(0).toFixed(100)}catch(e){d()}};a.whichButton=function(a){return null!==a.which?2>a.which?"L":2===a.which?"M":"R":2>a.button?"L":4===a.button?"M":"R"};a.getCursorPosition=function(a){a.touches?(a=a.touches[0],r=a.pageX,w=a.pageY):void 0!=a.pageX&&void 0!=a.pageY?(r=a.pageX,w=a.pageY):(r=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,w=a.clientY+document.body.scrollTop+
document.documentElement.scrollTop);return{x:r,y:w}};a.getTextWidth=function(c,d){a.ctx.font=d;return a.ctx.measureText(c).width};var v=document.createElement("span");v.appendChild(document.createTextNode("\u00c1p"));var z=document.createElement("div");z.setAttribute("style","display: inline-block; w: 1px; h: 0px;");var B=document.createElement("div");B.setAttribute("style","margin: 0; padding: 0;");B.appendChild(v);B.appendChild(z);var C={};a.getFontMetrics=function(a){if(C[a])return C[a];v.setAttribute("style",
"font: "+a+"; margin: 0px; padding: 0px;");document.body.appendChild(B);var c={};z.style.verticalAlign="baseline";c.ascent=z.offsetTop-v.offsetTop;z.style.verticalAlign="bottom";c.h=z.offsetTop-v.offsetTop;c.descent=c.h-c.ascent;c.baseline=c.ascent;document.body.removeChild(B);return C[a]=c};a.getFieldFontSize=function(a){return 14>=a?8:14<a&&16>=a?9:16<a&&19>=a?10:19<a&&22>=a?11:22<a?parseInt(a-11):l(a-0.25*a)};a.getScreenshot=function(){var c=a.apps[0],d,e=document.createElement("canvas"),k=new Image;
if(c){e.setAttribute("width",c.width);e.setAttribute("height",c.height);for(var f=e.getContext("2d"),l=0,m=c.spaces.length;l<m;l++)d=c.spaces[l],"R2"===d.type&&(f.drawImage(d.backgroundCanvas,d.x,d.y),f.drawImage(d.canvas,d.x,d.y),g(f,d.container,d.ctrs));0<c.northSpace.controls.length&&h(f,c.northSpace.container,c.northSpace);0<c.southSpace.controls.length&&h(f,c.southSpace.container,c.southSpace);0<c.eastSpace.controls.length&&h(f,c.eastSpace.container,c.eastSpace);0<c.westSpace.controls.length&&
h(f,c.westSpace.container,c.westSpace);k.src=e.toDataURL("image/png")}return k};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h;a.openExternalFile=function(a){d=null;var c=!1;if(window.XMLHttpRequest)try{c=new XMLHttpRequest}catch(f){c=!1}else if(window.ActiveXObject)try{c=new ActiveXObject("Msxml2.XMLHTTP")}catch(k){try{c=new ActiveXObject("Microsoft.XMLHTTP")}catch(l){c=!1}}h=c;h.open("GET",a,!1);try{h.send(null),d=h.responseText,d.match(String.fromCharCode(65533))&&
(h.open("GET",a,!1),h.overrideMimeType("text/plain; charset=ISO-8859-1"),h.send(null),d=h.responseText)}catch(e){console.log("Error to load the file :",a),d=null}return d};return a}(descartesJS||{}),descartesJS=function(a){function d(a){f=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,regExp:null};f[0]==f[f.length-1]&&"'"==f[0]&&(a.ignoreCaps=!0,f=f.substring(1,f.length-1),"`"==f[0]&&"\u00b4"==f[f.length-1]&&(a.ignoreAcents=!0,f=f.substring(1,f.length-1)));"`"==f[0]&&"\u00b4"==f[f.length-1]&&(a.ignoreAcents=
!0,f=f.substring(1,f.length-1),f[0]==f[f.length-1]&&"'"==f[0]&&(a.ignoreCaps=!0,f=f.substring(1,f.length-1)));"*"===f.charAt(0)&&"*"!==f.charAt(f.length-1)?f=f.substring(1)+"$":"*"!==f.charAt(0)&&"*"===f.charAt(f.length-1)?f="^"+f.substring(0,f.length-1):"*"!==f.charAt(0)&&"*"!==f.charAt(f.length-1)?f="^"+f+"$":"*"===f.charAt(0)&&"*"===f.charAt(f.length-1)&&(f=f.substring(1,f.length-1));f=f.replace(/\?/g,"[\\S\\s]{1}");a.regExp=f;return a}function h(a,c){f=a.trim();a={ignoreAcents:!1,ignoreCaps:!1,
regExp:null};a.expr=f.split(",");a.expr[0]=a.expr[0].trim();a.expr[0]={type:a.expr[0].charAt(0),expr:c.parser.parse(a.expr[0].substring(1))};a.expr[1]=a.expr[1].trim();a.expr[1]={type:a.expr[1].charAt(a.expr[1].length-1),expr:c.parser.parse(a.expr[1].substring(0,a.expr[1].length-1))};return a}function g(a,c,d){c=parseFloat(c);p=a.expr[0];m=a.expr[1];n=d.evalExpression(p.expr);t=d.evalExpression(m.expr);s="("==p.type;u="["==p.type;q=")"==m.type;r="]"==m.type;return(s&&c>n||u&&c>=n)&&(q&&c<t||r&&c<=
t)?1:0}function c(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 f,k,l,e,p,m,n,t,s,u,q,r;a.buildRegularExpresionsPatterns=function(a,c){"("===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 e=0,g=a.length;e<g;e++){k=a[e].split("&");l=[];for(var m=0,n=k.length;m<n;m++)f=k[m],-1!==f.indexOf(",")&&("("===f.charAt(0)||"["===f.charAt(0))&&(")"===f.charAt(f.length-1)||"]"===f.charAt(f.length-1))?l.push(h(f,c)):l.push(d(f));a[e]=l}return a};a.escorrecto=function(d,f,l,h){l=l||a.externalEvaluator;h=h||a.buildRegularExpresionsPatterns(d,l);f=c(f);d=0;for(var m=h.length;d<m;d++){k=h[d];e=!0;for(var n=0,p=k.length;n<
p;n++)e=k[n].regExp?e&&!!f.match(c(k[n].regExp),"i"):e&&g(k[n],f,l);if(e)return 1}return 0};a.esCorrecto=function(d,l,h,m){h=h||a.externalEvaluator;m=m||a.buildRegularExpresionsPatterns(d,h);d=0;for(var n=m.length;d<n;d++){k=m[d];e=!0;for(var p=0,s=k.length;p<s;p++)(f=k[p].regExp)?(k[p].ignoreAcents&&(l=c(l),f=c(f)),k[p].ignoreCaps&&(l=l.toLowerCase(),f=c(f).toLowerCase()),e=e&&!!l.match(f)):e=e=e&&g(k[p],l,h);if(e)return 1}return 0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.getCreativeCommonsLicenseImage=function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAABHNCSVQICAgIfAhkiAAACpVJREFUaIHtWm1sU9cZfu61iUYnPP/bJgdhhDbFkVYcCrR0tLHXrVNL01wvgUJDh820tivrkpQQtpEvA4HGhDoe/dCmNfbaVa1WKszX2oUO3xC0OHESm9Hi/FhloyQq1aY5OGgq8ce7H9f3xI7txKFsdKyPdHSPz8dzz33Oe77eY46IVBzHXcUXuOkgIo4DQABwuucUeJ4Hz/NQKBTgeQUUPA9ekXryPDiOB89x4DgO4DiZBQQCJQlJSiKZlEIikZCeyQQSiSSSyQTLS1KSlSciuTEsfjtgY+UmAAAHgGRxFQqFFHjFTFyhkPJ4RUpkDhzHp+ubEiclbFISM5FIhfR4IlPkZDLJhE0X+nbBxspNUALIFFehhDLjKYWTx0/B4/FgcHAQU9GpDKIlqiVYu3YtjN8xouLRR5BIKsDzcalDEjw4cJD6cgaUJGkkANIY4iRxR3x+uN9xIxgMZpTX6XQQqgSsWlNW0Md9Xng4APSns+9BqVQyUZVKpRQUSvSK52B73oaJiYmCGqTRaND4i0aUl9+PeCKBRCKOeDwVEnHE4wlm4emW/PHExzjS9SJGg6MAAIPBAL1eDwAIBAIQRREAUKIrwY7aHfja17+a8/1XPv4ELzle+lzwbKzcJAn8fu8ZKBXKGWGVi7BIqURrcxvcx9ysglqthiAI0Gq1KC8vBwD09vYiHA7D7XZjcnKSlRVMAhoad2LxHYsRj8cRi8cRj8cQj8czpwxK4mrkKn769LOIRqMQBAF2ux1arTajseFwGPX19XC73VCpVGi3tWd91LXoNdTuqPvc8MjzMJ3tO0t9/eeo39dPQwEfXfggQIJJIEiDl9RqNbW1tVEkEqG54HQ6Sa1Ws3oluhI6399HQ4Eh8g71U1//OfL0naUzYg+99+d36XTPKTrx7nHS6XQEgMxmcwafzDP7HTL328f/kBFKdCU5eRx2Oz3+2ObPxDM2Nkbe/n7y9vfT2NhYQTwAiAcARWoOVioUUCoyLVev18Pv96O1tRVqtTprGKTDbDYjFAqxoTQaHEWn7XDGXM6zHYm0G/F5fQgGgxAEAY27ds3JL79DEASMBkcx4vOz9BGfH6PBUawqK8O996xj6b/q6sLzNhtOnj6N3Q27MD4+XhBPent+/9prMKy/DzWbt6Bm8xYY1t+HMz09c/Kkg/q8feQd8tLIhWFyHHEwy9Hr9fNabS5EIhHS6/WMx/Gig0b+OkIDw1467+0jz3nJit99/4+kK5WsNxQKFcwfCoUIAOl0OmYt8igo+cY3acUyLZV/ez09/eMnCQC1tbXRwQMHCQAdffvtgnjk9nj7+yW+u9fRj7ZZqHFnA61YpqUVy7TksNvz8uSwYMmKbc/bAEjzrdPpnNdqc0GtVsPj8bC6toO21F46ZcFcak/N8wheCsJgMGTNcRaLhVm5xWLJyNNqtTAYDBkrezAo8VRUVGDjpk0YHx/HmZ4erFimxb+mrmHrE1tx6cMPUVVdXRCPVqtFNBpF0H8RAFAp/AC/dXWjo/MQ9rQ0AwBc3c68PDJ4AKlhK23F5N1CXV0dG+o3ArVaDbvdDgCYmJjAyROn2IFFEplj27Rc73G5XDnjMnLV0ev1sB3uxEFbB954601UVVfjo8th2A53YunSpXB1OxG8dKkgHhntL0gG95vfvcrSvvfggwCAaDSKT65cycsDpASWrcnj8QCQxKmtrWWFRFGEyWSC0WiE0WiE1WrNm9fV1cXyzGYzs2LPWU+a9XLg+BmB/xO4+5570NF5CGNjY2jc2YCyb92Jd44eRcXDG1CzeQubQ+eCSqWCw+HAHaoleOWVV3KW+fTT63NySAcNjgPPcRgcHAQACILAhBFFEUajMaOSKIoQRRG1tbUwmUxZeRcuXIDT6WRcLpcLg4OD0gkwJawkriRwIBDIapjZbGaWazabs/Jz1ZmdFo1GcaanBx2dh2C+ZEHFwxsAAANeLwa8XhQXF4NbpJyTZ5FSicaGBtyxeDFLG/B6WXyZdlne9gDMgqUPlk9oK1euZAXq6+sBSPNMKBSCx+OBVqvFtm3bmCXr9XqEQiEcO3YsY48MgMWnolPSe8ClPYHS0lKIoohwOJzRMLmDZscBaQ8qiiJ0Oh1L0+l0WTw/efIptO/dh1V3rkTN5i346HIYVdXV6Og8hJqtWwviGR8fR1tLKx5/bDPa9+5D+959aGlqAgDs2r07b3syBAaHjOGaPp/IPWM2m9lkHgqFYDabWZ58+BAEgeXJSF+8JKPNPDZvfExadOSOLARyWaFKYGlyPJ2no/MQLNu348o//o6/hUJw2O3Y09KMqupqWPfvQ9ma1fPyWLZvh2X7dgCAs7sbzu5uXP/0OjZUPIItNY/nbY+M7PHxX8a69eugK9XB7XbDYrFkWetsyKenEl1Jhh9g1ZoylOhKMniKi4uxp6UZX1q8GCPDw/hZXd0N8expacb3H3oIly+HAUijTldaOiePDMmCKdOLlT6fyNbscrkwOTmJQCCA5cuXw2q1sjz5mJyeJyN9yEpnM3l7PIPmtmaoVCq4XC6YTCZWh9K8bOFwGCaTCV1dXVCpVNhRuyPrY3b/sjEnz85dDXjjrTc/E8/qNatRVV2Nqupq6EpLC+IBUs4e38ggioqKsP7e+zAVnYLZbGaW5Ha7sxYyQJoyKisr8+bJ9evr69HV1YUlqiU4/5c+TE9PYzo2jVg8hlgsLjmDEnFE/jmJA9YDbC+p1+uh1+uhVqshiiLr9PmcNNei19BxwMacNLeShzl7BoYHUFRUBGuLFe5jbqjVakQiEVZQFEU4HA7mzDEYDGhtbWUd4HA4WNn0PABYvnw5wuEwHvjuAzhs78T16WnEZgks+42TiSR8Az4cO3rr3Yw3g4cJ7B3qx6JFRTh/7jxqn5X2v3a7HXVpc9aNwOVysVPY/gP78fCGhzAdm8Z0LIZ4LIZYfJbAORzw/8vYWLlJmoPlKx2DsRwajQYAYLVas7ZOC8Hk5CRbXTUaTcoRn7rFSCaRTM3FlLpyul3BA0CSkkgkpHu0fe17AUgCmUymDB9voZicnITRaGR1G3/emHKwJ2ZETrsyYovsrMX2dgEBoKbWJvKNDFLgop+e+OETGR41v9+/IE9XuidNMAkUuOgn38gg7W3fy9L/j8LMj7rnamnI76PADTjcI5EItbW1ZTjc16xdQxc+CNBQwEdNrU23+kNvSWDX9jKaW5tQaRKgVCpx2HYYr7/2Ostb6JWRdV8b4vE4BgYG8cxTz2A+pE8P8smSiDJOmbN/5+PJV0d+R6GOpnxtWhDH7NDc2iRZ8kU/dbteJY1GU3CPaTQachxxUOCin4YCPnr51y8XXJeI5oynp83HM1/9QrhylVkoR5YFy6h7rhY1W2vYVY/o6cWJ4yfmvLZ/VHgUBkM5u9A8fvwE9lv3F9DHEnJZS3reQqyO47i8z4VgtrXOXoTn48srMACsuqsMza0tKF6qSbuNSHc3ImPfKv/xZGJ8HC902nGu99yCP+azTA35eABkCbxQsXN1UiEccwos4/7y+7GhYgPuWn0XvqJSpf46Jb9ZetHVaBTDQ8M4ffL0goVN/wjWsJtgwbl+L2T+nG9NuGkCf4EbB09EX77VjbhdQUTcvwFtwhQyXNo3TwAAAABJRU5ErkJggg==";
return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h,g,c,f,k,l,e,p,m;a.Color=function(a,d){this.a=this.b=this.g=this.r=0;this.evaluator=d;if(a){if(babel[a]&&("net"===babel[a]&&(a="rojo"),a=babel[a],this.r=parseInt("0x"+a.substring(1,3),16),this.g=parseInt("0x"+a.substring(3,5),16),this.b=parseInt("0x"+a.substring(5,7),16),this.colorStr=a,this.getColor=this.getColorString),6===a.length&&(this.r=parseInt("0x"+a.substring(0,2),16),this.g=parseInt("0x"+
a.substring(2,4),16),this.b=parseInt("0x"+a.substring(4,6),16),this.colorStr="#"+a,this.getColor=this.getColorString),8===a.length&&(this.r=parseInt("0x"+a.substring(2,4),16),this.g=parseInt("0x"+a.substring(4,6),16),this.b=parseInt("0x"+a.substring(6,8),16),this.a=1-parseInt("0x"+a.substring(0,2),16)/255,this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString),"("===a[0]){g=[];c=this.splitComa(a.substring(1,a.length-1));for(var e=0,k=c.length;e<k;e++)f=
parseInt(c[e],16),c[e]!=f.toString(16)&&c[e]!=="0"+f.toString(16)?("["===c[e].charAt(0)&&"]"===c[e].charAt(c[e].length-1)&&(c[e]=c[e].substring(1,c[e].length-1)),g.push(this.evaluator.parser.parse(c[e]))):g.push(this.evaluator.parser.parse((f/255).toString()));this.rExpr=g[0];this.gExpr=g[1];this.bExpr=g[2];this.aExpr=g[3];this.getColor=this.getColorExpression}}else this.colorStr="rgba("+this.r+","+this.g+","+this.b+","+this.a+")",this.getColor=this.getColorString};a.Color.prototype.splitComa=function(a){k=
[];for(var c=p=e=l=0,d=a.length;c<d;c++)m=a.charAt(c),"("===m?l++:")"===m?l--:"["===m?e++:"]"===m?e--:","===m&&(0===l&&0===e)&&(k.push(a.substring(p,c)),p=c+1);k.push(a.substring(p));return k};a.Color.prototype.getColorString=function(){return this.colorStr};a.Color.prototype.getColorExpression=function(){h=this.evaluator;this.r=d(255*h.evalExpression(this.rExpr));this.g=d(255*h.evalExpression(this.gExpr));this.b=d(255*h.evalExpression(this.bExpr));this.a=1-h.evalExpression(this.aExpr);return"rgba("+
this.r+","+this.g+","+this.b+","+this.a+")"};a.Color.prototype.borderColor=function(){return 380>this.r+this.g+this.b?"white":"black"};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=document.head,h=document.createElement("meta");h.setAttribute("http-equiv","X-UA-Compatible");h.setAttribute("content","chrome=1");d.appendChild(h);h=document.createElement("meta");h.setAttribute("name","viewport");h.setAttribute("content","width=device-width, initial-scale=1.0, user-scalable=yes");
d.appendChild(h);h=document.createElement("meta");h.setAttribute("name","apple-mobile-web-app-capable");h.setAttribute("content","yes");d.appendChild(h);h=document.createElement("meta");h.setAttribute("name","apple-mobile-web-app-status-bar-style");h.setAttribute("content","black-translucent");d.appendChild(h);(d=document.getElementById("StyleDescartesApps2"))&&d.parentNode.removeChild(d);d=document.createElement("style");d.type="text/css";d.id="StyleDescartesApps2";d.setAttribute("rel","stylesheet");
document.head.appendChild(d);d.innerHTML="body{ text-rendering:geometricPrecision; }\ncanvas{ image-rendering:optimizeSpeed; image-rendering:-moz-crisp-edges; image-rendering:-webkit-optimize-contrast; image-rendering:optimize-contrast; -ms-interpolation-mode:nearest-neighbor; }\ndiv.DescartesCatcher{ background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; }\ndiv.DescartesAppContainer{ border:0px solid black; position:relative; overflow:hidden; top:0px; left:0px; }\ndiv.DescartesLoader{ background-color :#efefef; position:absolute; overflow:hidden; -moz-box-shadow:0px 0px 0px #888; -webkit-box-shadow:0px 0px 100px #888; box-shadow:0px 0px 100px #888; background-image:linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-o-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-moz-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-webkit-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); background-image:-ms-linear-gradient(bottom, #bbbbbb 0%, #efefef 50%, #bbbbbb 100%); top:0px; left:0px; }\ndiv.DescartesLoaderImage{ background-repeat:no-repeat; background-position:center; position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesLoaderBar{ position:absolute; overflow:hidden; top:0px; left:0px; }\ncanvas.DescartesSpace2DCanvas, canvas.DescartesSpace3DCanvas, div.blocker{ position:absolute; overflow:hidden; left:0px; top:0px; }\ndiv.DescartesSpace2DContainer, div.DescartesSpace3DContainer{ position:absolute; overflow:hidden; line-height:0px; }\ncanvas.DescartesButton{ position:absolute; cursor:pointer; }\ndiv.DescartesSpinnerContainer, div.DescartesTextFieldContainer{ background:lightgray; position:absolute; overflow:hidden; }\ninput.DescartesSpinnerField, input.DescartesTextFieldField, input.DescartesMenuField, input.DescartesScrollbarField{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding:0px; border:solid #666666 1px; position:absolute; top:0px; }\nlabel.DescartesSpinnerLabel, label.DescartesMenuLabel, label.DescartesScrollbarLabel, label.DescartesTextFieldLabel{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; font-weight:normal; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:#e0e4e8; position:absolute; left:0px; top:0px; }\ndiv.DescartesGraphicControl{ border-style:none; position:absolute; }\ndiv.DescartesTextAreaContainer{ position:absolute; overflow:hidden; background:#c0d0d8; }\nselect.DescartesMenuSelect{ font-family:Arial, Helvetica, 'Droid Sans', Sans-serif; padding-top:0%; text-align:center; text-overflow:ellipsis; white-space:nowrap; overflow:hidden; background-color:white; position:absolute; left:0px; top:0px; }\ndiv.DescartesScrollbarContainer{ background:#eeeeee; overflow:hidden; position:absolute; }\n";
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.sin,h=Math.floor,g=Math.random,c=Math.round,f=Math.abs,k=String.fromCharCode,l,e,p,m,n,t,s,u,q,r;a.Krypto=function(a){this.key=(a||0).toString()};a.Krypto.prototype.getKey=function(a){l=[];for(var c=0;256>c;c++)l[c]=k(this.alfanum(h(f(7.5*(d(1*c-a)+d(1.4*c+a)+d(0.6*c-a)+d(2.2*c+a))))));return l.join("")};a.Krypto.prototype.encode=function(a){e=h(31*g());this.key=this.getKey(e);m=k(this.alfanum(e));return m+this.encripta(a)};
a.Krypto.prototype.decode=function(a){e=this.numalfa(a.charCodeAt(0));this.key=this.getKey(e);return this.desencripta(a.substring(1))};a.Krypto.prototype.encripta=function(a){return this.bytesToString(this.encriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.encriptaAux=function(a){if(null==a||null==this.key)return null;t=Array(3*a.length);for(var d=0,e=a.length;d<e;d++)q=256*h(a[d]+128)+c(255*g())+65536*c(255*g()),r=h((q<<this.shift(d))/256),t[3*d]=this.alfanum(r%32),t[3*d+1]=this.alfanum(r/32%
32),t[3*d+2]=this.alfanum(r/1024%32);return t};a.Krypto.prototype.desencripta=function(a){return this.bytesToString(this.desencriptaAux(this.stringToBytes(a)))};a.Krypto.prototype.desencriptaAux=function(a){if(null==a||null==this.key)return null;s=Array(a.length/3);for(var c=0,d=s.length;c<d;c++)r=this.numalfa(a[3*c])+32*this.numalfa(a[3*c+1])+1024*this.numalfa(a[3*c+2]),q=h(256*r>>this.shift(c)),u=h(q/256)%256-128,0>u&&(u+=256),s[c]=u;return s};a.Krypto.prototype.alfanum=function(a){a=h(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){m=Array(a.length);for(var c=0,d=a.length;c<d;c++)m[c]=a.charCodeAt(c);return m};a.Krypto.prototype.bytesToString=function(a){for(var c=0,d=a.length;c<d;c++)a[c]=k(a[c]);return a.join("")};a.Krypto.prototype.shift=function(a){p=this.key.charCodeAt(a%this.key.length);m=this.numalfa(p);n=h(m/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;a.Animation=function(d,h){this.parent=d;var g=d.evaluator,c=g.parser,f=new a.Auxiliary(d);this.delay=h.delay?c.parse(h.delay):c.parse("60");this.loop=h.loop?h.loop:!1;this.auto=void 0==h.auto&&2==this.parent.version?!0:h.auto;this.controls=h.controls;this.init=f.splitInstructions(c,h.init);this.doExpr=f.splitInstructions(c,h.doExpr);h.whileExpr&&(this.whileExpr=c.parse(h.whileExpr));var k=this,l,e,p=k.doExpr.length;
this.animationExec=function(){for(e=0;e<p;e++)g.evalExpression(k.doExpr[e]);k.parent.update();k.playing&&(0<g.evalExpression(k.whileExpr)||k.loop)?(l=g.evalExpression(k.delay),k.timer=setTimeout(k.animationExec,10>l?10:l)):(k.stop(),k.parent.update())};this.playing=!1;this.auto&&this.play()};a.Animation.prototype.play=function(){this.playing?this.stop():(this.reinit(),this.playing=!0,this.timer=setTimeout(this.animationExec,this.parent.evaluator.evalExpression(this.delay)))};a.Animation.prototype.stop=
function(){this.playing=!1;clearInterval(this.timer)};a.Animation.prototype.reinit=function(){for(var a=0,h=this.init.length;a<h;a++)this.parent.evaluator.evalExpression(this.init[a])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Action=function(a,h){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(d,h){a.Action.call(this,d,h);this.parameter=
h};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(d,h){a.Action.call(this,d,h);var g=this.evaluator,c=g.parser;h=(h||"").replace(/&squot;/g,"'");h=h.replace(/;/g,"\\n");h=h.split("\\n")||[""];for(var f=[],k,l=0,e=h.length;l<e;l++)(k=c.parse(h[l],!0))&&f.push(k);e=f.length;this.execute=function(){for(l=0;l<e;l++)g.evalExpression(f[l])}};a.extend(a.Calculate,a.Action);
return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenURL=function(d,h){a.Action.call(this,d,h);this.parameter=h;this.target="_blank";var g=this.parameter.indexOf("target");-1!=g&&(this.target=this.parameter.substring(g),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,g-1));"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),this.actionExec=function(){eval(this.parameter)}):
("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){window.open(this.parameter,this.target)})};a.extend(a.OpenURL,a.Action);a.OpenURL.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.OpenScene=function(d,h){a.Action.call(this,d,h);this.parameter=h;this.target="_blank";var g=this.parameter.indexOf("target");
-1!=g&&(this.target=this.parameter.substring(g),this.target=this.target.substring(this.target.indexOf("=")+1),this.parameter=this.parameter.substring(0,g-1));"_blank"!==this.target&&"_parent"!==this.target&&"_self"!==this.target&&"_top"!==this.target?this.actionExec=function(){window.parent.postMessage({type:"changeTarget",name:this.target,value:this.parameter},"*")}:"javascript"==this.parameter.substring(0,10)?(this.parameter=this.parameter.substring(11).replace(/&squot;/g,"'"),this.actionExec=function(){eval(this.parameter)}):
("http://"!=this.parameter.substring(0,7)&&(this.parameter=window.location.href.substring(0,window.location.href.lastIndexOf("/")+1)+this.parameter),this.actionExec=function(){this.window=window.open(this.parameter,this.target,"width="+this.parent.width+",height="+this.parent.height+",left="+(window.screen.width-this.parent.width)/2+", top="+(window.screen.height-this.parent.height)/2+"location=no,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no");this.window.onload=function(a){a=this.document;
var d=a.getElementsByTagName("applet");d&&0<d.length&&(this.innerWidth=d[0].width,this.height=d[0].height,a.body.style.margin="0px",a.body.style.padding="0px",d[0].parentNode.style.margin="0px",d[0].parentNode.style.padding="0px")}})};a.extend(a.OpenScene,a.Action);a.OpenScene.prototype.execute=function(){this.actionExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.About=function(d,h){a.Action.call(this,d,h);h||(this.urlAbout=window.location.href.substring(0,window.location.href.lastIndexOf("/")+
1)+h)};a.extend(a.About,a.Action);a.About.prototype.execute=function(){if(this.urlAbout)var a=window.open(this.urlAbout,"_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes");else a=window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes"),a.document.write("<hmtl><head><title>Cr\u00e9ditos</title></head><body><h1>Aqu\u00ed van los cr\u00e9ditos</h1></body></html>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
a.Config=function(d,h){a.Action.call(this,d,h)};a.extend(a.Config,a.Action);a.Config.prototype.execute=function(){window.open("about:blank","_blank","width=800px,height=600px,location=no,menubar=no,scrollbars=yes").document.write("<xmp style='width:100%; height:100%;'>"+this.parent.applet.outerHTML+"</xmp>")};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Init=function(d,h){a.Action.call(this,d,h)};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(d,h){a.Action.call(this,d,h)};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(d,h){a.Action.call(this,d,h)};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(d,h){a.Action.call(this,d,h)};a.extend(a.InitAnimation,a.Action);a.InitAnimation.prototype.execute=function(){this.parent.reinitAnimation()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.PlayAudio=function(d,h){a.Action.call(this,d,h);this.filenameExpr=h?this.evaluator.parser.parse("'"+h.split(" ")[0].trim()+"'"):"";this.filename=this.evaluator.evalExpression(this.filenameExpr);this.theAudio=d.getAudio(this.filename)};a.extend(a.PlayAudio,a.Action);a.PlayAudio.prototype.execute=
function(){var a=this.theAudio;a.paused?a.play():(a.pause(),a.currentTime=0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Auxiliary=function(a,c){this.parent=a;this.evaluator=this.parent.evaluator;this.expresion=this.id="";this.evaluate="onlyOnce";this.local="";for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d])};a.Auxiliary.prototype.firstRun=function(){};a.Auxiliary.prototype.update=function(){};var d,h;a.Auxiliary.prototype.splitInstructions=function(a,c){h=[];c=c?
c.split(";"):[""];for(var f=0,k=c.length;f<k;f++)(d=a.parse(c[f],!0))&&h.push(d);return h};a.Auxiliary.prototype.getPrivateVariables=function(a,c){h=[];c=c?c.split(/;|,/):[""];for(var f=0,k=c.length;f<k;f++)(d=a.parse(c[f],!0))&&h.push(d);f=0;for(k=h.length;f<k;f++)h[f]="asign"===h[f].type?h[f].childs[0].value:"identifier"===h[f].type?h[f].value:"";return h};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(d,h){a.Auxiliary.call(this,d,h);var g=this.evaluator.parser;this.expresionString=this.expresion;(this.expresion=g.parse(this.expresionString))&&g.setVariable(this.id,this.expresion);this.editable&&(this.registerTextField(),this.parent.editableRegionVisible=!0)};a.extend(a.Variable,a.Auxiliary);a.Variable.prototype.registerTextField=
function(){var a=document.createElement("div"),h=document.createElement("label");h.appendChild(document.createTextNode("___"+this.id+"=___"));var g=document.createElement("input");g.value=this.expresionString;g.disabled=!this.editable;a.appendChild(h);a.appendChild(g);var c=this,f=c.evaluator.parser;g.onkeydown=function(a){13==a.keyCode&&(c.expresion=f.parse(this.value),f.setVariable(c.id,c.expresion),c.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(d,h){a.Auxiliary.call(this,d,h);this.expresion=this.evaluator.parser.parse(this.expresion);this.update()};a.extend(a.Constant,a.Auxiliary);a.Constant.prototype.update=function(){this.evaluator.setVariable(this.id,this.evaluator.evalExpression(this.expresion))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector=function(d,h){var g=d.evaluator,c=g.parser;this.size=c.parse("3");a.Auxiliary.call(this,
d,h);this.expresion=this.expresion.split(";");var f;if(this.file){var k=document.getElementById(this.file);k&&"descartes/vectorFile"==k.type?(f=k.text,"\n"==f[0]&&(f=f.substring(1))):f=a.openExternalFile(this.file);null!=f&&(f=f.split("\n"));null==f||1==f.length&&""==f[0]?(f=[],this.size=0):(this.expresion=[],this.size=null);for(var l,e=0,p=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,k=0,m=f.length;k<m;k++)f[k].match(/./)&&(this.expresion[e]=this.id+"["+e+"]="+f[k],e++,(l=f[k].match(p))&&
this.parent.getImage(l));null===this.size&&(this.size=c.parse(this.expresion.length+""))}k=0;for(m=this.expresion.length;k<m;k++)(f=c.parse(this.expresion[k],!0))&&"asign"!=f.type&&(f=c.parse(this.id+"["+k+"]="+this.expresion[k],!0)),this.expresion[k]=f;c=[];k=0;for(m=g.evalExpression(this.size);k<m;k++)c.push(0);g.vectors[this.id]=c;this.update()};a.extend(a.Vector,a.Auxiliary);a.Vector.prototype.update=function(){var a=this.evaluator;a.setVariable(this.id+".long",a.evalExpression(this.size));for(var h=
0,g=this.expresion.length;h<g;h++)a.evalExpression(this.expresion[h])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Matrix=function(d,h){var g=d.evaluator,c=g.parser;this.rows=c.parse("3");this.columns=c.parse("3");a.Auxiliary.call(this,d,h);this.expresion=this.splitInstructions(c,this.expresion);var c=g.evalExpression(this.rows),f=g.evalExpression(this.columns),k=[];k.type="matrix";for(var l,e=0;e<f;e++){l=[];for(var p=0,m=c;p<m;p++)l.push(0);k[e]=l}g.matrices[this.id]=
k;this.update()};a.extend(a.Matrix,a.Auxiliary);a.Matrix.prototype.update=function(){var a=this.evaluator,h=a.evalExpression(this.rows),g=a.evalExpression(this.columns);a.setVariable(this.id+".filas",h);a.setVariable(this.id+".columnas",g);var c=a.matrices[this.id];c.rows=h;c.cols=g;h=0;for(g=this.expresion.length;h<g;h++)a.evalExpression(this.expresion[h])};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Function=function(d,h){a.Auxiliary.call(this,d,h);var g=this.evaluator,
c=g.parser,f=this.id.indexOf("(");this.name=this.id.substring(0,f);this.params=this.id.substring(f+1,this.id.length-1);this.domain=this.range?c.parse(this.range):c.parse("1");this.params=""==this.params?[]:this.params.split(",");this.numberOfParams=this.params.length;this.algorithm||(this.whileExpr=this.doExpr=this.init="");this.parseExpressions(c);this.expresion=c.parse(this.expresion);var k=this;this.functionExec=function(){if(k.numberOfParams<=arguments.length){for(var c=[],d=0,f=k.privateVars.length;d<
f;d++)c.push(g.getVariable(k.privateVars[d])),g.setVariable(k.privateVars[d],0);for(var h=[],d=0,f=k.params.length;d<f;d++)h[d]=g.getVariable(k.params[d]),g.setVariable(k.params[d],arguments[d]);d=0;for(f=k.init.length;d<f;d++)g.evalExpression(k.init[d]);do{d=0;for(f=k.doExpr.length;d<f;d++)g.evalExpression(k.doExpr[d])}while(0<g.evalExpression(k.whileExpr));var n=g.evalExpression(k.expresion);a.rangeOK=g.evalExpression(k.domain);d=0;for(f=k.params.length;d<f;d++)g.setVariable(k.params[d],h[d]);d=
0;for(f=k.privateVars.length;d<f;d++)g.setVariable(k.privateVars[d],c[d]);return n}return 0};g.setFunction(this.name,this.functionExec)};a.extend(a.Function,a.Auxiliary);return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Algorithm=function(d,h){a.Auxiliary.call(this,d,h);var g=this.evaluator;this.parseExpressions(g.parser);this.algorithmExec=function(){for(var a=0,d=this.init.length;a<d;a++)g.evalExpression(this.init[a]);do{a=0;for(d=this.doExpr.length;a<d;a++)g.evalExpression(this.doExpr[a])}while(0<
g.evalExpression(this.whileExpr))}};a.extend(a.Algorithm,a.Auxiliary);a.Algorithm.prototype.update=function(){this.algorithmExec();"onlyOnce"===this.evaluate&&(this.update=function(){})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Event=function(d,h){a.Auxiliary.call(this,d,h);var g=this.evaluator;this.condition=g.parser.parse(this.condition);this.lastEvaluation=!1;this.action=this.parent.lessonParser.parseAction(this);"onlyOnce"==this.execution&&(this.eventExec=function(){0<
g.evalExpression(this.condition)&&!this.lastEvaluation&&(this.lastEvaluation=!0,this.action.execute())});"alternate"==this.execution&&(this.eventExec=function(){var a=0<g.evalExpression(this.condition);3==this.parent.version?a!=this.lastEvaluation&&(this.action.execute(),this.lastEvaluation=a?!0:!1):a&&!this.lastEvaluation?(this.action.execute(),this.lastEvaluation=!0):!a&&this.lastEvaluation&&(this.lastEvaluation=!1)});"always"==this.execution&&(this.eventExec=function(){0<g.evalExpression(this.condition)&&
this.action.execute()})};a.extend(a.Event,a.Auxiliary);a.Event.prototype.update=function(){this.eventExec()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f;a.Graphic=function(c,d){this.parent=c;this.evaluator=c.evaluator;var e=this.evaluator.parser;this.spaceID="E0";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=!1;this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=e.parse("2");for(var g in d)d.hasOwnProperty(g)&&(this[g]=d[g]);this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.trace&&(this.traceCtx=this.space.backgroundCanvas.getContext("2d"));
this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10};a.Graphic.prototype.getSpace=function(){for(var a=this.parent.spaces,c,d=0,g=a.length;d<g;d++)if(c=a[d],c.id==this.spaceID)return c;return a[0]};a.Graphic.prototype.getFamilyValues=function(){d=this.evaluator;h=d.evalExpression(this.family_interval);this.familyInf=h[0][0];this.familySup=h[0][1];this.fSteps=Math.round(d.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?
(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic.prototype.drawFamilyAux=function(a,c,e){d=this.evaluator;this.getFamilyValues();g=d.getVariable(this.family);if(0<=this.fSteps)for(var f=0,h=this.fSteps;f<=h;f++)d.setVariable(this.family,this.familyInf+f*this.family_sep),0<d.evalExpression(this.drawif)&&(this.update(),this.drawAux(a,c,e));d.setVariable("_Text_H_",0);d.setVariable(this.family,g)};a.Graphic.prototype.draw=function(a,c){""!=this.family?this.drawFamilyAux(this.ctx,a,c):0<this.evaluator.evalExpression(this.drawif)&&
(this.update(),this.drawAux(this.ctx,a,c))};a.Graphic.prototype.drawTrace=function(a,c){""!=this.family?this.drawFamilyAux(this.traceCtx,a,c):0<this.evaluator.evalExpression(this.drawif)&&(this.update(),this.drawAux(this.traceCtx,a,c))};a.Graphic.prototype.drawText=function(a,g,e,h,m,n,t,s,u,q,r){if("rtfNode"===g.type)a.fillStyle=m.getColor(),a.strokeStyle=m.getColor(),a.textBaseline="alphabetic",g.draw(a,e,h,u,q,t,r);else{"simpleText"===g.type&&(g=g.toString(u,q).split("\\n"));e+=n.match("Arial")?
-2:n.match("Times")?-2:0;d=this.evaluator;a.fillStyle=m.getColor();a.font=n;a.textAlign=t;a.textBaseline=s;this.border&&(a.strokeStyle=this.border.getColor(),a.lineWidth=parseInt(this.fontSize/12)+1.5);f=1.2*this.fontSize||0;m=0;for(n=g.length;m<n;m++)c=g[m],this.border&&(a.lineJoin="round",a.strokeText(c,e,h+f*m)),a.fillText(c,e,h+f*m)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.SimpleText=function(a,c){this.text=c.replace("&#x2013","\u2013");this.textElements=[];
this.textElementsMacros=[];this.parent=a;this.evaluator=a.evaluator;this.type="simpleText";for(var d="'",k=0,h=0,e=-1,p,m;k<c.length;)p=c.charAt(k),m=c.charAt(k-1),"["===p&&"\\"===m?(this.textElements.push(c.substring(h,k-1)+"["),this.textElementsMacros.push("'"+c.substring(h,k-1)+"['"),h=k+1):"]"===p&&"\\"===m?(this.textElements.push(c.substring(h,k-1)+"]"),this.textElementsMacros.push("'"+c.substring(h,k-1)+"]'"),h=k+1):"["===p&&-1==e?(this.textElements.push(c.substring(h,k)),this.textElementsMacros.push("'"+
c.substring(h,k)+"'"),h=k,e++):"["===p?e++:"]"===p&&0==e?(this.textElements.push(this.evaluator.parser.parse(c.substring(h,k+1))),this.textElementsMacros.push("["+c.substring(h,k+1)+"]"),h=k+1,e--):("]"==c.charAt(k)&&(e=0>e?e:e-1),d+=c.charAt(k)),k++;this.textElements.push(c.substring(h,k));this.textElementsMacros.push("'"+c.substring(h,k)+"'")};var d,h;a.SimpleText.prototype.toString=function(a,c){d="";for(var f=0,k=this.textElements.length;f<k;f++)"string"===typeof this.textElements[f]?d+=this.textElements[f]:
(h=this.evaluator.evalExpression(this.textElements[f])[0][0],""!==h&&("string"===typeof h?d+=h:(h=parseFloat(h),h=c?h.toFixed(a):parseFloat(h.toFixed(a)),d+=h.toString().replace(".",this.parent.decimal_symbol))));return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h=2*Math.PI,g,c,f,k,l,e,p,m,n,t,s,u,q,r,w,v,z,B,C,x,D,E,F,A,H,J,I,L,y,K,G,M,N,O,S,T,Q,R,P,W,U,X,Z,Y,V;a.Equation=function(c,d){this.width=c.evaluator.parser.parse("1");this.fillM=this.fillP=
"";a.Graphic.call(this,c,d);this.generateStroke();this.parseExpression();(this.visible=2===this.parent.version&&void 0==this.visible?!0:this.visible)&&this.registerTextField();t=new a.R2;s=new a.R2;u=new a.R2;w=new a.R2;q=new a.R2};a.extend(a.Equation,a.Graphic);a.Equation.prototype.parseExpression=function(){if("compOperator"==this.expresion.type){var c=this.expresion.childs[0],d=this.expresion.childs[1];"identifier"==c.type&&"y"==c.value&&!d.contains("y")?(this.funExpr=d,this.drawAux=this.drawAuxFunY):
"identifier"==d.type&&"y"==d.value&&!c.contains("y")?(this.funExpr=c,this.drawAux=this.drawAuxFunY):"identifier"==c.type&&"x"==c.value&&!d.contains("x")?(this.funExpr=d,this.drawAux=this.drawAuxFunX):"identifier"==d.type&&("x"==d.value&&!c.contains("x"))&&(this.funExpr=d,this.drawAux=this.drawAuxFunX)}this.newt=new a.R2Newton(this.evaluator,this.expresion)};a.Equation.prototype.generateStroke=function(){this.auxCanvas=document.createElement("canvas");var a=parseInt(this.evaluator.evalExpression(this.width));
this.width_2=parseInt(a/2)||1;this.auxCanvas.setAttribute("width",a);this.auxCanvas.setAttribute("height",a);this.auxCtx=this.auxCanvas.getContext("2d");this.auxCtx.fillStyle=this.color.getColor();this.auxCtx.beginPath();this.auxCtx.arc(this.width_2,this.width_2,this.width_2,0,2*Math.PI,!1);this.auxCtx.fill()};a.Equation.prototype.update=function(){};a.Equation.prototype.draw=function(){""!=this.family?this.drawFamilyAux(this.ctx,this.fill,this.color):(this.update(),this.drawAux(this.ctx,this.fill,
this.color))};a.Equation.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.fill,this.trace)};a.Equation.prototype.drawAux=function(k,h,y){k.lineWidth=1;g=this.evaluator;c=g.parser;f=this.space;l=g.evalExpression(this.width);l=d(l)/2;c.getVariable("x");c.getVariable("y");e=f.w;p=f.h;m=d(e/8);3>m&&(m=3);n=d(p/8);3>n&&(n=3);b=[];t.set(0,0);s.set(0,0);u.set(0,0);for(H=d(n/2);H<p;H+=n)for(A=d(m/2);A<e;A+=m)if(this.abs_coord?(w.set(A,H),r=this.newt.findZero(w),g.setVariable("x",r.x),g.setVariable("y",
r.y),q.set(r.x,r.y)):(w.set(f.getRelativeX(A),f.getRelativeY(H)),r=this.newt.findZero(w),g.setVariable("x",r.x),g.setVariable("y",r.y),q.set(f.getAbsoluteX(r.x),f.getAbsoluteY(r.y))),v=d(q.ix()),z=d(q.iy()),!(0>v||v>=e||0>z||z>=p||b[v+z*f.w]))if(b[v+z*f.w]=!0,t.x=r.x,t.y=r.y,s.x=r.x,s.y=r.y,B=this.newt.getUnitNormal(),!(0==B.x&&0==B.y)){B.rotL90();u.x=B.x;u.y=B.y;x=C=0;for(D=!1;2>x;){D&&(u.x=-B.x,u.y=-B.y,r.x=t.x,r.y=t.y,s.x=r.x,s.y=r.y,this.abs_coord?q.set(r.x,r.y):q.set(f.getAbsoluteX(r.x),f.getAbsoluteY(r.y)),
v=q.ix(),z=q.iy(),D=!1,C=0);this.abs_coord?(r.x+=u.x,r.y+=u.y):(r.x+=u.x/f.scale,r.y+=u.y/f.scale);r=this.newt.findZero(r);g.setVariable("x",r.x);g.setVariable("y",r.y);u.x=r.x-s.x;u.y=r.y-s.y;u.normalize();if(0==u.x&&0==u.y)break;s.x=r.x;s.y=r.y;this.abs_coord?q.set(r.x,r.y):q.set(f.getAbsoluteX(r.x),f.getAbsoluteY(r.y));E=d(q.ix());F=d(q.iy());if(E!=v||F!=z)if(v=E,z=F,0<=v&&v<e&&0<=z&&z<p)if(C=0,b[v+z*f.w])break;else b[v+z*f.w]=!0,a.rangeOK&&g.evalExpression(this.drawif)&&k.drawImage(this.auxCanvas,
v-this.width_2,z-this.width_2);else D=!0,x++;else 4<++C&&(D=!0,x++)}}};a.Equation.prototype.drawAuxFunY=function(c,d,h){g=this.evaluator;f=this.space;e=f.w;m=1/f.scale;I=f.getAbsoluteY(0);l=g.evalExpression(this.width);k=this.color.getColor();c.fillStyle=k;L=f.getRelativeX(0);g.setVariable("x",L);O=f.getAbsoluteX(L);S=f.getAbsoluteY(g.evalExpression(this.funExpr));P=0;for(d=1;d<e;d++){K=L+d*m;g.setVariable("x",K);G=g.evalExpression(this.funExpr);g.setVariable("y",G);M=f.getAbsoluteX(K);N=f.getAbsoluteY(G);
T=Math.min(P,G);Q=Math.max(P,G);R={min:T,max:Q};if(void 0!==G&&(a.rangeOK&&g.evalExpression(this.drawif))&&!this.hasSingularity(m,K,"x",K-m,P,K,G,R)){if(this.fillM||this.fillP)this.fillM&&(W=this.fillM.getColor()),this.fillP&&(U=this.fillP.getColor()),c.lineWidth=1,c.strokeStyle=N>I?W:U,c.beginPath(),c.moveTo(M+0.5,N),c.lineTo(M+0.5,I),c.stroke();c.lineWidth=l;c.strokeStyle=k;c.beginPath();c.moveTo(O,S);c.lineTo(M,N);c.stroke()}P=G||0;O=M;S=N}};a.Equation.prototype.drawAuxFunX=function(c,d,e){g=this.evaluator;
f=this.space;p=f.h;n=1/f.scale;J=f.getAbsoluteX(0);l=g.evalExpression(this.width);k=this.color.getColor();c.fillStyle=k;y=f.getRelativeY(p);g.setVariable("y",y);O=f.getAbsoluteX(g.evalExpression(this.funExpr));S=f.getAbsoluteY(y);d=0;for(e=1;e<p;e++){G=y+e*n;g.setVariable("y",G);K=g.evalExpression(this.funExpr);g.setVariable("x",K);M=f.getAbsoluteX(K);N=f.getAbsoluteY(G);T=Math.min(d,K);Q=Math.max(d,K);R={min:T,max:Q};if(void 0!==G&&(a.rangeOK&&g.evalExpression(this.drawif))&&!this.hasSingularity(n,
G,"y",G-n,d,G,K,R)){if(this.fillM||this.fillP)this.fillM&&(W=this.fillM.getColor()),this.fillP&&(U=this.fillP.getColor()),c.lineWidth=1,c.strokeStyle=M>J?W:U,c.beginPath(),c.moveTo(M,N+0.5),c.lineTo(J,N+0.5),c.stroke();c.lineWidth=l;c.strokeStyle=k;c.beginPath();c.moveTo(O,S);c.lineTo(M,N);c.stroke()}d=K||0;O=M;S=N}};a.Equation.prototype.hasSingularity=function(a,c,d,e,k,g,f,h){if(1E-12>Math.abs(g-e)||1E-8>Math.abs(g-e)&&Math.abs(f-k)>Math.abs(a))return!0;X=!1;Z=c;Y=(e+g)/2;this.evaluator.setVariable(d,
Y);V=this.evaluator.evalExpression(this.funExpr);h.min<=V&&V<=h.max?X=!1:(h.x=Math.min(h.min,V),h.y=Math.max(h.max,V),X=this.hasSingularity(a,c,d,e,k,Y,V,h)||this.hasSingularity(a,c,d,Y,V,g,f,h));this.evaluator.setVariable(d,Z);return X};a.drawPixel=function(a,c,d,e){a.moveTo(c,d);a.arc(c,d,e,0,h,!1)};a.Equation.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var c=this;a.onkeydown=function(a){13==a.keyCode&&(c.expresion=
c.evaluator.parser.parse(this.value),c.parseExpression(),c.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round;a.Curve=function(c,d){this.parameter="t";this.parameter_interval=c.evaluator.parser.parse("[0,1]");this.parameter_steps=c.evaluator.parser.parse("8");this.width=c.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,c,d);(this.visible=2==this.parent.version&&void 0==this.visible?
!0:!1)&&this.registerTextField()};a.extend(a.Curve,a.Graphic);var h,g,c,f,k,l,e,p,m,n,t;a.Curve.prototype.update=function(){h=this.evaluator;g=h.evalExpression(this.parameter_interval);this.paraInf=g[0][0];this.paraSup=g[0][1];this.pSteps=h.evalExpression(this.parameter_steps);this.paraSep=0<this.pSteps?Math.abs(this.paraSup-this.paraInf)/this.pSteps:0};a.Curve.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Curve.prototype.drawTrace=function(){this.uber.drawTrace.call(this,
this.fill,this.trace)};a.Curve.prototype.drawAux=function(g,u,q){h=this.evaluator;c=this.space;f=d(h.evalExpression(this.width));g.lineWidth=0<f?f:1E-6;g.lineCap="round";g.lineJoin="round";g.strokeStyle=q.getColor();k=h.getVariable(this.parameter);g.beginPath();h.setVariable(this.parameter,this.paraInf);l=h.evalExpression(this.expresion);this.exprX=this.abs_coord?d(l[0][0]):d(c.getAbsoluteX(l[0][0]));this.exprY=this.abs_coord?d(l[0][1]):d(c.getAbsoluteY(l[0][1]));this.rotateExp&&(e=a.degToRad(h.evalExpression(this.rotateExp)),
p=Math.cos(e),m=Math.sin(e),n=this.exprX*p-this.exprY*m,t=this.exprX*m+this.exprY*p,this.exprX=n,this.exprY=t);g.moveTo(this.exprX+0.5,this.exprY+0.5);for(q=1;q<=this.pSteps;q++)h.setVariable(this.parameter,this.paraInf+q*this.paraSep),l=h.evalExpression(this.expresion),this.exprX=this.abs_coord?d(l[0][0]):d(c.getAbsoluteX(l[0][0])),this.exprY=this.abs_coord?d(l[0][1]):d(c.getAbsoluteY(l[0][1])),this.rotateExp&&(n=this.exprX*p-this.exprY*m,t=this.exprX*m+this.exprY*p,this.exprX=n,this.exprY=t),g.lineTo(this.exprX+
0.5,this.exprY+0.5);this.fill&&(g.fillStyle=u.getColor(),g.fill());g.stroke();h.setVariable(this.parameter,k)};a.Curve.prototype.registerTextField=function(){var a=document.createElement("input");a.value=this.expresionString;a.disabled=!this.editable;var c=this;a.onkeydown=function(a){13==a.keyCode&&(c.expresion=c.evaluator.parser.parse(this.value),c.parent.update())};this.parent.editableRegion.textFields.push(a)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI;
a.Sequence=function(d,g){this.size=d.evaluator.parser.parse("2");a.Graphic.call(this,d,g)};a.extend(a.Sequence,a.Graphic);a.Sequence.prototype.update=function(){var d=this.evaluator,g=d.evalExpression(this.expresion);this.exprX=g[0][0];this.exprY=g[0][1];if(this.rotateExp){var c=a.degToRad(d.evalExpression(this.rotateExp)),g=Math.cos(c),f=Math.sin(c),c=this.exprX*g-this.exprY*f,g=this.exprX*f+this.exprY*g;this.exprX=c;this.exprY=g}d=d.evalExpression(this.range);this.rangeInf=d[0][0];this.rangeMax=
d[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,g){var c=this.evaluator,f,k,l,e=Math.ceil(c.evalExpression(this.size)-0.4);a.fillStyle=g.getColor();a.beginPath();this.rangeInf>this.rangeMax&&(l=this.rangeInf,this.rangeInf=this.rangeMax,this.rangeMax=l);for(var p=c.getVariable("n"),m=this.rangeInf,n=this.rangeMax;m<=n;m++)c.setVariable("n",
m),l=c.evalExpression(this.expresion),this.exprX=l[0][0],this.exprY=l[0][1],this.abs_coord?f=l[0][1]:(f=this.space.getAbsoluteX(l[0][0]),k=this.space.getAbsoluteY(l[0][1])),a.moveTo(f,k),a.sequence(f,k,e,0,d,!0);c.setVariable("n",p);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,f+e,k-e,this.color,this.font,"start","alphabetic",c.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI,h=Math.round;a.Point=
function(c,d){this.size=c.evaluator.parser.parse("2");a.Graphic.call(this,c,d)};a.extend(a.Point,a.Graphic);var g,c,f,k,l,e,p,m,n,t,s,u;a.Point.prototype.update=function(){g=this.evaluator;f=g.evalExpression(this.expresion);this.exprX=f[0][0];this.exprY=f[0][1];this.rotateExp&&(k=a.degToRad(g.evalExpression(this.rotateExp)),l=Math.cos(k),e=Math.sin(k),p=this.exprX*l-this.exprY*e,m=this.exprX*e+this.exprY*l,this.exprX=p,this.exprY=m)};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,e){g=this.evaluator;c=this.space;s=h(g.evalExpression(this.size));u=s+1;a.fillStyle=e.getColor();n=this.abs_coord?h(this.exprX):h(c.getAbsoluteX(this.exprX));t=this.abs_coord?h(this.exprY):h(c.getAbsoluteY(this.exprY));a.beginPath();a.arc(n,t,s,0,d,!0);a.fill();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,n+u+1,t-u,this.color,this.font,"start",
"alphabetic",g.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,h=2*Math.PI,g,c,f,k,l,e,p,m,n,t,s,u,q,r,w,v,z,B;a.Segment=function(c,d){this.width=c.evaluator.parser.parse("1");this.size=c.evaluator.parser.parse("2");a.Graphic.call(this,c,d)};a.extend(a.Segment,a.Graphic);a.Segment.prototype.update=function(){g=this.evaluator;f=g.evalExpression(this.expresion);this.endPoints=[];for(var c=0,d=f.length;c<d;c++)this.endPoints[c]=
{x:f[c][0],y:f[c][1]};if(this.rotateExp){k=a.degToRad(g.evalExpression(this.rotateExp));l=Math.cos(k);e=Math.sin(k);c=0;for(d=this.endPoints.length;c<d;c++)p=this.endPoints[c].x*l-this.endPoints[c].y*e,m=this.endPoints[c].x*e+this.endPoints[c].y*l,this.endPoints[c].x=p,this.endPoints[c].y=m}};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,e,k){g=this.evaluator;c=this.space;n=d(g.evalExpression(this.width));a.lineWidth=0<n?n:1E-6;q=g.evalExpression(this.size);0>q&&(q=0);a.fillStyle=e.getColor();a.strokeStyle=k.getColor();a.lineCap="round";t=10+a.lineWidth;r=0==a.lineWidth%2?0:0.5;this.abs_coord?(w=d(this.endPoints[0].x),v=d(this.endPoints[0].y),z=d(this.endPoints[1].x),B=d(this.endPoints[1].y)):(w=d(c.getAbsoluteX(this.endPoints[0].x)),v=d(c.getAbsoluteY(this.endPoints[0].y)),z=d(c.getAbsoluteX(this.endPoints[1].x)),B=d(c.getAbsoluteY(this.endPoints[1].y)));
a.beginPath();a.moveTo(w+r,v+r);a.lineTo(z+r,B+r);a.stroke();a.beginPath();a.arc(w,v,q,0,h,!0);a.arc(z,B,q,0,h,!0);a.fill();this.text!=[""]&&(s=parseInt((w+z)/2)-3,u=parseInt((v+B)/2)+3,this.uber.drawText.call(this,a,this.text,s+t,u-t,this.color,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h=Math.round,g,c,f,k,l,e,p,m,n,t,s,u,q,r,w,v,z,B;a.Arrow=function(c,d){this.width=c.evaluator.parser.parse("5");
this.size=c.evaluator.parser.parse("2");this.spear=c.evaluator.parser.parse("8");this.arrow=new a.Color("ee0022");a.Graphic.call(this,c,d)};a.extend(a.Arrow,a.Graphic);a.Arrow.prototype.update=function(){g=this.evaluator;c=g.evalExpression(this.expresion);this.endPoints=[];for(var d=0,h=c.length;d<h;d++)this.endPoints[d]={x:c[d][0],y:c[d][1]};if(this.rotateExp){f=a.degToRad(g.evalExpression(this.rotateExp));k=Math.cos(f);l=Math.sin(f);d=0;for(h=this.endPoints.length;d<h;d++)e=this.endPoints[d].x*
k-this.endPoints[d].y*l,p=this.endPoints[d].x*l+this.endPoints[d].y*k,this.endPoints[d].x=e,this.endPoints[d].y=p}};a.Arrow.prototype.draw=function(){this.uber.draw.call(this,this.arrow,this.color)};a.Arrow.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.arrow,this.trace)};a.Arrow.prototype.drawAux=function(c,e,k){g=this.evaluator;m=this.space;g.evalExpression(this.size);s=g.evalExpression(this.width);1>s&&(s=1);u=Math.ceil(s/2);q=m.scale;this.vect=new a.Vector2D(this.endPoints[1].x-
this.endPoints[0].x,this.endPoints[1].y-this.endPoints[0].y);r=this.vect.vectorLength();this.angle=this.vect.angleBetweenVectors(a.Vector2D.AXIS_X);c.fillStyle=e.getColor();c.strokeStyle=k.getColor();c.lineWidth=2;this.abs_coord?(w=h(this.endPoints[0].x),v=h(this.endPoints[0].y),z=h(this.endPoints[1].x),B=h(this.endPoints[1].y)):(w=h(m.getAbsoluteX(this.endPoints[0].x)),v=h(m.getAbsoluteY(this.endPoints[0].y)),z=h(m.getAbsoluteX(this.endPoints[1].x)),B=h(m.getAbsoluteY(this.endPoints[1].y)));e=g.evalExpression(this.spear);
0>e&&(e=0);c.save();c.translate(w,v,r);this.abs_coord?0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?c.rotate(this.angle):c.rotate(-this.angle):(r*=q,0<=this.vect.x&&0<=this.vect.y||0>=this.vect.x&&0<=this.vect.y?c.rotate(-this.angle):c.rotate(this.angle));c.beginPath();c.moveTo(-u,d(-u));c.lineTo(d(r-e-s),d(-u));c.lineTo(d(r-2*e),d(-e-u));c.lineTo(d(r),0);c.lineTo(d(r-2*e),d(e+u));c.lineTo(d(r-e-s),d(u));c.lineTo(-u,d(u));c.closePath();c.stroke();c.fill();c.restore();this.text!=[""]&&
(n=parseInt((w+z)/2)-3,t=parseInt((v+B)/2)+3,this.uber.drawText.call(this,c,this.text,n,t,k,this.font,"start","alphabetic",g.evalExpression(this.decimals),this.fixed,!0))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round,h,g,c,f,k,l,e,p,m,n,t,s;a.Polygon=function(c,d){this.width=c.evaluator.parser.parse("1");this.fill="";a.Graphic.call(this,c,d);this.endPoints=[]};a.extend(a.Polygon,a.Graphic);a.Polygon.prototype.update=function(){h=this.evaluator;c=h.evalExpression(this.expresion);
for(var d=0,g=c.length;d<g;d++)this.endPoints[d]={x:c[d][0],y:c[d][1]};if(this.rotateExp){f=a.degToRad(h.evalExpression(this.rotateExp));k=Math.cos(f);l=Math.sin(f);d=0;for(g=this.endPoints.length;d<g;d++)e=this.endPoints[d].x*k-this.endPoints[d].y*l,p=this.endPoints[d].x*l+this.endPoints[d].y*k,this.endPoints[d].x=e,this.endPoints[d].y=p}};a.Polygon.prototype.draw=function(){this.uber.draw.call(this,this.fill,this.color)};a.Polygon.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.trace,
this.trace)};a.Polygon.prototype.drawAux=function(a,c,e){h=this.evaluator;g=this.space;m=d(h.evalExpression(this.width));a.lineWidth=0<m?m:1E-6;a.strokeStyle=e.getColor();a.lineCap="round";a.lineJoin="round";n=0<m?0.5:0;t=this.abs_coord?d(this.endPoints[0].x):d(g.getAbsoluteX(this.endPoints[0].x));s=this.abs_coord?d(this.endPoints[0].y):d(g.getAbsoluteY(this.endPoints[0].y));a.beginPath();a.moveTo(t+n,s+n);e=1;for(var k=this.endPoints.length;e<k;e++)t=this.abs_coord?d(this.endPoints[e].x):d(g.getAbsoluteX(this.endPoints[e].x)),
s=this.abs_coord?d(this.endPoints[e].y):d(g.getAbsoluteY(this.endPoints[e].y)),a.lineTo(t+n,s+n);this.fill&&(a.fillStyle=c.getColor(),a.fill());a.stroke()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round;a.Arc=function(c,d){this.width=c.evaluator.parser.parse("1");this.fill="";this.center=c.evaluator.parser.parse("(0,0)");this.radius=c.evaluator.parser.parse("1");this.init=c.evaluator.parser.parse("0");this.end=c.evaluator.parser.parse("90");a.Graphic.call(this,
c,d)};a.extend(a.Arc,a.Graphic);var h,g,c,f,k,l,e,p,m,n,t,s,u,q,r,w,v,z,B,C,x,D,E,F;a.Arc.prototype.update=function(){h=this.evaluator;g=h.evalExpression(this.center);this.exprX=g[0][0];this.exprY=g[0][1];this.rotateExp&&(c=a.degToRad(h.evalExpression(this.rotateExp)),f=Math.cos(c),k=Math.sin(c),l=this.exprX*f-this.exprY*k,e=this.exprX*k+this.exprY*f,this.exprX=l,this.exprY=e);p=h.evalExpression(this.init);m=h.evalExpression(this.end);"(expr)"==this.init.type&&"(expr)"==this.end.type||"[expr]"==this.init.type&&
"[expr]"==this.end.type||"(expr)"==this.init.type&&"[expr]"==this.end.type||"[expr]"==this.init.type&&"(expr)"==this.end.type?(this.vectors=!0,n=p[0][0],t=p[0][1],s=m[0][0],u=m[0][1],q=Math.acos((1*n+0*t)/Math.sqrt(n*n+t*t)),r=Math.acos((1*s+0*u)/Math.sqrt(s*s+u*u)),0<n&&(0<t&&!this.abs_coord)&&(q=2*Math.PI-q),0<n&&(0>t&&this.abs_coord)&&(q=2*Math.PI-q),0>n&&(0>t&&this.abs_coord)&&(q=2*Math.PI-q),0>n&&(0<t&&!this.abs_coord)&&(q=2*Math.PI-q),0<s&&(0<u&&!this.abs_coord)&&(r=2*Math.PI-r),0<s&&(0>u&&
this.abs_coord)&&(r=2*Math.PI-r),0>s&&(0>u&&this.abs_coord)&&(r=2*Math.PI-r),0>s&&(0<u&&!this.abs_coord)&&(r=2*Math.PI-r),w=Math.min(q,r),v=Math.max(q,r),q=w,r=v,r-q>Math.PI&&this.abs_coord&&(q=v,r=w),r-q<=Math.PI&&!this.abs_coord&&(q=v,r=w),this.iniAng=q,this.endAng=r):(this.vectors=!1,this.iniAng=a.degToRad(p),this.endAng=a.degToRad(m))};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,c,e){h=this.evaluator;z=this.space;B=this.abs_coord?d(this.exprX):d(z.getAbsoluteX(this.exprX));C=this.abs_coord?d(this.exprY):d(z.getAbsoluteY(this.exprY));x=h.evalExpression(this.radius);!this.vectors&&this.iniAng>this.endAng&&(D=this.iniAng,this.iniAng=this.endAng,this.endAng=D);0>x&&(x=0);E=!1;this.abs_coord||(x*=z.scale,this.vectors||(this.iniAng=-this.iniAng,this.endAng=-this.endAng,E=!0));this.vectors&&(E=this.abs_coord?!1:!0);F=d(h.evalExpression(this.width));
a.lineWidth=0<F?F:1E-6;a.lineCap="round";a.strokeStyle=e.getColor();a.beginPath();a.arc(B,C,x,this.iniAng,this.endAng,E);this.fill&&(a.fillStyle=c.getColor(),a.fill());a.stroke();this.text!=[""]&&this.uber.drawText.call(this,a,this.text,B+4,C-2,this.color,this.font,"start","alphabetic",h.evalExpression(this.decimals),this.fixed,!0)};return a}(descartesJS||{}),descartesJS=function(a){function d(a,c,d){e=4*(c+d*a.width);return{r:a.data[e],g:a.data[e+1],b:a.data[e+2],a:a.data[e+3]}}if(a.loadLib)return a;
var h,g,c,f,k,l,e;a.Fill=function(c,d){a.Graphic.call(this,c,d)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){h=this.evaluator.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,this.color)};a.Fill.prototype.drawTrace=function(){};a.Fill.prototype.drawAux=function(a,h){h.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(g=parseInt(this.exprX),c=parseInt(this.exprY)):
(g=parseInt(this.space.getAbsoluteX(this.exprX)),c=parseInt(this.space.getAbsoluteY(this.exprY)));f=[{x:g,y:c}];for(l=d(imageData,g,c);0<f.length;){k=f.pop();g=k.x;c=k.y;var n=d(imageData,g,c);if(l.r===n.r&&l.g===n.g&&l.b===n.b&&l.a===n.a){var n=imageData,t=h;e=4*(g+c*n.width);n.data[e+0]=t.r;n.data[e+1]=t.g;n.data[e+2]=t.b;n.data[e+3]=255-t.a;0<g&&f.push({x:g-1,y:c});g<imageData.width-1&&f.push({x:g+1,y:c});f.push({x:g,y:c-1});f.push({x:g,y:c+1})}}this.ctx.putImageData(imageData,0,0)};return a}(descartesJS||
{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k,l,e,p,m,n,t,s,u,q,r,w,v;a.Text=function(c,d){this.width=c.evaluator.parser.parse("0");a.Graphic.call(this,c,d);this.align||(this.align="start");this.ascent=this.fontSize-Math.ceil(this.fontSize/7)-(this.font.match("Courier")?3:0);this.abs_coord=!0};a.extend(a.Text,a.Graphic);a.Text.prototype.update=function(){d=this.evaluator;h=d.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1];this.rotateExp&&(g=a.degToRad(d.evalExpression(this.rotateExp)),
c=Math.cos(g),f=Math.sin(g),k=this.exprX*c-this.exprY*f,l=this.exprX*f+this.exprY*c,this.exprX=k,this.exprY=l)};a.Text.prototype.draw=function(){this.uber.draw.call(this,this.color)};a.Text.prototype.drawTrace=function(){this.uber.drawTrace.call(this,this.color)};a.Text.prototype.drawAux=function(a,c){v=this.evaluator.evalExpression(this.decimals);"rtfNode"===this.text.type?(n=this.text,this.ascent=0):n=this.splitText(this.text.toString(v,this.fixed).split("\\n"));this.text!=[""]&&this.uber.drawText.call(this,
a,n,parseInt(this.exprX)+5,parseInt(this.exprY)+this.ascent,c,this.font,this.align,"alphabetic",v,this.fixed)};a.Text.prototype.splitText=function(a){d=this.evaluator;e=d.evalExpression(this.width);n=[];this.ctx.font=this.font;if(20<=e&&"undefined"!=a.type){for(var c=0,k=a.length;c<k;c++)p=a[c],m=this.ctx.measureText(p).width,m>e?n=n.concat(this.splitWords(p,e)):n.push(p);t=Math.floor(1.2*this.fontSize)*n.length;d.setVariable("_Text_H_",t);return n}d.setVariable("_Text_H_",0);d.setVariable("_Text_W_",
1E3);return a};a.Text.prototype.splitWords=function(a,c){s=a;u=[];q="";w=0;for(var d,e=0,k=a.length;e<k;e++)r=s.charAt(e)," "===r&&(lastIndexOfWhite=e),q+=r,Math.round(this.ctx.measureText(q).width)>c&&(d=a.substring(w,e+1)," "!==r&&(-1===d.indexOf(" ")?(lastIndexOfWhite=e,e--):e=lastIndexOfWhite),u.push(a.substring(w,lastIndexOfWhite)),q="",w=e+1);u.push(a.substring(w));return u};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.round;a.Image=function(c,d){this.file=
"";this.inirot=c.evaluator.parser.parse("0");a.Graphic.call(this,c,d);this.img=new Image;this.scaleY=this.scaleX=1;this.update()};a.extend(a.Image,a.Graphic);var h,g,c,f,k,l,e,p,m,n,t,s,u,q;a.Image.prototype.update=function(){h=this.evaluator;g=h.evalExpression(this.expresion);this.exprX=g[0][0];this.exprY=g[0][1];this.rotateExp&&(c=a.degToRad(h.evalExpression(this.rotateExp)),f=Math.cos(c),k=Math.sin(c),l=this.exprX*f-this.exprY*k,e=this.exprX*k+this.exprY*f,this.exprX=l,this.exprY=e);4==g[0].length&&
(this.centered=!0,this.scaleX=g[0][2],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=g[0][3],0==this.scaleY&&(this.scaleY=1E-5));g[1]&&2==g[1].length&&(this.centered=!0,this.scaleX=g[1][0],0==this.scaleX&&(this.scaleX=1E-5),this.scaleY=g[1][1],0==this.scaleY&&(this.scaleY=1E-5));if((p=h.evalExpression(this.file))||""==p)this.img=this.parent.getImage(p)};a.Image.prototype.draw=function(){this.uber.draw.call(this)};a.Image.prototype.drawTrace=function(){this.uber.drawTrace.call(this)};a.Image.prototype.drawAux=
function(c){h=this.evaluator;m=this.space;this.img&&(this.img.ready&&this.img.complete)&&(n=this.centered?0:this.img.width/2,t=this.centered?0:this.img.height/2,s=this.abs_coord?d(this.exprX):d(m.getAbsoluteX(this.exprX)),u=this.abs_coord?d(this.exprY):d(m.getAbsoluteY(this.exprY)),q=a.degToRad(-h.evalExpression(this.inirot)),c.translate(s+n,u+t),c.rotate(q),c.scale(this.scaleX,this.scaleY),this.opacity&&(c.globalAlpha=h.evalExpression(this.opacity)),c.drawImage(this.img,-this.img.width/2,-this.img.height/
2),c.setTransform(1,0,0,1,0,0),c.globalAlpha=1)};return a}(descartesJS||{}),descartesJS=function(a){function d(a,c,d){e=4*(c+d*a.width);return{r:a.data[e],g:a.data[e+1],b:a.data[e+2],a:a.data[e+3]}}if(a.loadLib)return a;var h,g,c,f,k,l,e;a.Fill=function(c,d){a.Graphic.call(this,c,d)};a.extend(a.Fill,a.Graphic);a.Fill.prototype.update=function(){h=this.evaluator.evalExpression(this.expresion);this.exprX=h[0][0];this.exprY=h[0][1]};a.Fill.prototype.draw=function(){this.uber.draw.call(this,this.color,
this.color)};a.Fill.prototype.drawTrace=function(){};a.Fill.prototype.drawAux=function(a,h){h.getColor();imageData=this.ctx.getImageData(0,0,this.space.w,this.space.h);this.abs_coord?(g=parseInt(this.exprX),c=parseInt(this.exprY)):(g=parseInt(this.space.getAbsoluteX(this.exprX)),c=parseInt(this.space.getAbsoluteY(this.exprY)));f=[{x:g,y:c}];for(l=d(imageData,g,c);0<f.length;){k=f.pop();g=k.x;c=k.y;var n=d(imageData,g,c);if(l.r===n.r&&l.g===n.g&&l.b===n.b&&l.a===n.a){var n=imageData,t=h;e=4*(g+c*n.width);
n.data[e+0]=t.r;n.data[e+1]=t.g;n.data[e+2]=t.b;n.data[e+3]=255-t.a;0<g&&f.push({x:g-1,y:c});g<imageData.width-1&&f.push({x:g+1,y:c});f.push({x:g,y:c-1});f.push({x:g,y:c+1})}}this.ctx.putImageData(imageData,0,0)};return a}(descartesJS||{}),descartesJS=function(a,d){if(a.loadLib)return a;a.Macro=function(h,g){this.expresion=void 0;this.inirot=h.evaluator.parser.parse("0");a.Graphic.call(this,h,g);for(var c in g)g.hasOwnProperty(c)&&(this[c]=g[c]);this.graphics=[];c=h.lessonParser;var f=new a.Tokenizer;
if(void 0!=this.expresion){"'"!==this.expresion.charAt(0)&&(this.expresion="'"+this.expresion+"'");this.expresion=this.evaluator.parser.parse(this.expresion);var k=this.evaluator.evalExpression(this.expresion),l,e=2;k&&((l=document.getElementById(k))&&"descartes/macro"==l.type?(l=l.text,e=3):(l=a.openExternalFile(k))&&!l.match(/tipo_de_macro/g)&&(l=null));var p="|";if(l){l=l.replace(/&aacute;/g,"\u00e1").replace(/&eacute;/g,"\u00e9").replace(/&iacute;/g,"\u00ed").replace(/&oacute;/g,"\u00f3").replace(/&uacute;/g,
"\u00fa").replace(/&Aacute;/g,"\u00c1").replace(/&Eacute;/g,"\u00c9").replace(/&Iacute;/g,"\u00cd").replace(/&Oacute;/g,"\u00d3").replace(/&Uacute;/g,"\u00da").replace(/&ntilde;/g,"\u00f1").replace(/&Ntilde;/g,"\u00d1").replace(/\&gt;/g,">").replace(/\&lt;/g,"<").replace(/\&amp;/g,"&").split("\n").slice(e);for(var m,n,k=0,e=l.length;k<e;k++)l[k]&&(l[k]=c.split(l[k]),l[k]&&(l[k][0]&&l[k][0][0]&&"id"===l[k][0][0])&&(m=l[k][0][1],n=m.indexOf("("),-1!=n&&(m=m.substring(0,n)),p+=m+"|"));for(var t,s,u,
q,k=0,e=l.length;k<e;k++){t=l[k]||[];m=0;for(n=t.length;m<n;m++)if(s=d[t[m][0]],u=t[m][0].indexOf("."),-1!=u&&(s=d[t[m][0].substring(u+1)]),!("id"!=s&&void 0!=d[t[m][1]]))if("text"==s)if(t[m][1].match(/\{\\rtf1/)){s=t[m][1];var r=this;q=function(a,c){for(var d=f.tokenize(c.replace(/\&squot;/g,"'")),e=0,k=d.length;e<k;e++)if("identifier"==d[e].type&&p.match("\\|"+d[e].value+"\\|"))d[e].value=r.name+"."+d[e].value;else if("identifier"==d[e].type&&-1!=(u=d[e].value.indexOf("."))&&p.match("\\|"+d[e].value.substring(0,
u)+"\\|"))d[e].value=r.name+"."+d[e].value;return(a.match(/^\\expr/)?"\\expr ":"\\decimals ")+f.flatTokens(d)};s=s.replace(/\\expr ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,q);s=s.replace(/\\decimals ([a-zA-Z_0-9\u00C0-\u021B+*/%|&^#!?:()><.']*)/gi,q);t[m][1]=s}else{q=c.parseText(t[m][1]).textElementsMacros;for(var w=0,v=q.length;w<v;w++){s=f.tokenize(q[w].replace(/\&squot;/g,"'"));for(var z=0,B=s.length;z<B;z++)"identifier"==s[z].type&&p.match("\\|"+s[z].value+"\\|")&&(s[z].value=this.name+
"."+s[z].value);s=f.flatTokens(s).replace(/&squot;/g,"'").replace(/'\+\(/g,"[").replace(/\)\+'/g,"]");q[w]=s.substring(1,s.length-1)}t[m][1]=q.join("")}else{s=f.tokenize(t[m][1]);q=0;for(w=s.length;q<w;q++)if("identifier"==s[q].type&&p.match("\\|"+s[q].value+"\\|"))s[q].value=this.name+"."+s[q].value;else if("identifier"==s[q].type&&-1!=(u=s[q].value.indexOf("."))&&p.match("\\|"+s[q].value.substring(0,u)+"\\|"))s[q].value=this.name+"."+s[q].value;t[m][1]=f.flatTokens(s)}}k=0;for(e=l.length;k<e;k++)if(l[k][0]){t=
"";s=!1;m=0;for(n=l[k].length;m<n;m++)"type"===d[l[k][m][0]]&&(t="espacio='"+this.spaceID+"' ",s=!0),t=t+l[k][m][0]+"='"+l[k][m][1]+"' ";l[k]=t;s?this.graphics.push(c.parseGraphic(l[k],this.abs_coord,this.background,this.inirot)):c.parseAuxiliar(l[k])}}}};a.extend(a.Macro,a.Graphic);a.Macro.prototype.update=function(){if(this.inipos){var a=this.evaluator.evalExpression(this.inipos);this.iniPosX=a[0][0];this.iniPosY=a[0][1]}};a.Macro.prototype.drawAux=function(a){for(var d=0,c=this.graphics.length;d<
c;d++)this.inipos&&(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.setTransform(1,0,0,1,0,0)};return a}(descartesJS||{},babel),descartesJS=function(a){if(a.loadLib)return a;a.RenderMath={};a.RenderMath.inverseSqrt=function(a){return 1/Math.sqrt(number)};a.Vector2D=function(a,h){this.x=a||0;this.y=h||0};a.Vector2D.prototype.clone=function(){return new a.Vector2D(this.x,this.y)};a.Vector2D.prototype.add=
function(d){return new a.Vector2D(this.x+d.x,this.y+d.y)};a.Vector2D.prototype.substract=function(d){return new a.Vector2D(this.x-d.x,this.y-d.y)};a.Vector2D.prototype.multiply=function(d){return new a.Vector2D(this.x*d.x,this.y*d.y)};a.Vector2D.prototype.divide=function(d){return new a.Vector2D(this.x/d.x,this.y/d.y)};a.Vector2D.prototype.scale=function(d){return new a.Vector2D(this.x*d,this.y*d)};a.Vector2D.prototype.dist=function(a){var h=a.x-this.x;a=a.y-this.y;return Math.sqrt(h*h+a*a)};a.Vector2D.prototype.negate=
function(){return new a.Vector2D(-this.x,-this.y)};a.Vector2D.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};a.Vector2D.prototype.squaredLength=function(){return this.x*this.x+this.y*this.y};a.Vector2D.prototype.normalize=function(){var d=this.squaredLength();return 0<d?(d=Math.sqrt(d),new a.Vector2D(this.x/d,this.y/d)):new a.Vector2D(0,0)};a.Vector2D.prototype.crossProduct=function(a){return this.x*a.y-this.y*a.x};a.Vector2D.prototype.dot=function(a){return this.x*a.x+
this.y*a.y};a.Vector2D.prototype.direction=function(d){var h=this.x-d.x;d=this.y-d.y;var g=h*h+d*d;if(!g)return new a.Vector2D(0,0);g=1/Math.sqrt(g);return new a.Vector2D(h*g,d*g)};a.Vector2D.prototype.lerp=function(d,h){return new a.Vector2D(this.x+h*(d.x-this.x),this.y+h*(d.y-this.y))};a.Vector3D=function(a,h,g){this.x=a||0;this.y=h||0;this.z=g||0};a.Vector3D.prototype.set=function(a,h,g){this.x=a;this.y=h;this.z=g;return this};a.Vector3D.prototype.toVector4D=function(){return new a.Vector4D(this.x,
this.y,this.z,1)};a.Vector3D.prototype.copy=function(){return new a.Vector3D(this.x,this.y,this.z)};a.Vector3D.prototype.add=function(d){return new a.Vector3D(this.x+d.x,this.y+d.y,this.z+d.z)};a.Vector3D.prototype.substract=function(d){return new a.Vector3D(this.x-d.x,this.y-d.y,this.z-d.z)};a.Vector3D.prototype.multiply=function(d){return new a.Vector3D(this.x*d.x,this.y*d.y,this.z*d.z)};a.Vector3D.prototype.negate=function(){return new a.Vector3D(-this.x,-this.y,-this.z)};a.Vector3D.prototype.scale=
function(d){return new a.Vector3D(this.x*d,this.y*d,this.z*d)};a.Vector3D.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)};a.Vector3D.prototype.squaredLength=function(){return this.x*this.x+this.y*this.y+this.z*this.z};a.Vector3D.prototype.normalize=function(){var d=this.length();if(0==d)return new a.Vector3D(0,0,0);if(1==d)return new a.Vector3D(this.x,this.y,this.z);d=1/d;return new a.Vector3D(this.x*d,this.y*d,this.z*d)};a.Vector3D.prototype.crossProduct=
function(d){return new a.Vector3D(this.y*d.z-this.z*d.y,this.z*d.x-this.x*d.z,this.x*d.y-this.y*d.x)};a.Vector3D.prototype.dotProduct=function(a){return this.x*a.x+this.y*a.y+this.z*a.z};a.Vector3D.prototype.direction=function(d){var h=this.x-d.x,g=this.y-d.y;d=this.z-d.z;var c=Math.sqrt(h*h+g*g+d*d);if(0==c)return new a.Vector3D(0,0,0);c=1/c;return new a.Vector3D(h*c,g*c,d*c)};a.Vector3D.prototype.lerp=function(d,h){return new a.Vector3D(this.x+h*(d.x-this.x),this.y+h*(d.y-this.y),this.z+h*(d.z-
this.z))};a.Vector3D.prototype.distance=function(a){var h=a.x-this.x,g=a.y-this.y;a=a.z-this.z;return Math.sqrt(h*h+g*g+a*a)};a.Vector3D.prototype.unproject=function(d,h,g){var c=new a.Vector4D(2*(this.x-g.x)/g.width-1,2*(this.y-g.y)/g.height-1,2*this.z-1,c[3]=1);d=h.multiply(d);if(!d.inverse())return null;c=d.multiplyVector4(c);return 0==c.w?null:new a.Vector3D(c.x/c.w,c.y/c.w,c.z/c.w)};a.Vector3D.prototype.rotationTo=function(d){var h=new a.Vector3D(1,0,0),g=new a.Vector3D(0,1,0),c=new a.Vector3D(0,
0,1),f=this.dotProduct(d),k=new a.Quaternion;1<=f?k.setIdentity():-0.999999>f?(axis=h.crossProduct(this),1E-6>axis.length()&&(axis=g.crossProduct(this)),1E-6>axis.length()&&(axis=c.crossProduct(this)),axis=axis.normalize(),k=Quaternion.fromAngleAxis(Math.PI,axis)):(h=Math.squrt(2*(1+f)),g=1/h,axis=this.crossProduct(d),k.x=axis.x*g,k.y=axis.y*g,k.z=axis.z*g,k.w=0.5*h,k=Quaternion.normalize());1<k.w?k.w=1:-1>k.w&&(k.w=-1);return k};a.Vector4D=function(a,h,g,c){this.x=a||0;this.y=h||0;this.z=g||0;this.w=
c||0};a.Vector4D.prototype.set=function(a,h,g,c){this.x=a;this.y=h;this.z=g;this.w=c;return this};a.Vector4D.prototype.toVector3D=function(){var d=0!==this.w?1/this.w:0;return new a.Vector3D(this.x*d,this.y*d,this.z*d)};a.Vector4D.prototype.clone=function(){return new a.Vector4D(this.x,this.y,this.z,this.w)};a.Vector4D.prototype.add=function(d){return new a.Vector4D(this.x+d.x,this.y+d.y,this.z+d.z,this.w+d.w)};a.Vector4D.prototype.substract=function(d){return new a.Vector4D(this.x-d.x,this.y-d.y,
this.z-d.z,this.w-d.w)};a.Vector4D.prototype.multiply=function(d){return new a.Vector4D(this.x*d.x,this.y*d.y,this.z*d.z,this.w*d.w)};a.Vector4D.prototype.divide=function(d){return new a.Vector4D(this.x/d.x,this.y/d.y,this.z/d.z,this.w/d.w)};a.Vector4D.prototype.scale=function(d){return new a.Vector4D(this.x*d,this.y*d,this.z*d,this.w*d)};a.Vector4D.prototype.negate=function(){return new a.Vector4D(-this.x,-this.y,-this.z,-this.w)};a.Vector4D.prototype.length=function(){return Math.sqrt(this.x*this.x+
this.y*this.y+this.z*this.z+this.w*this.w)};a.Vector4D.prototype.squaredLength=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w};a.Vector4D.prototype.lerp=function(d,h){return new a.Vector4D(this.x+h*(d.x-this.x),this.y+h*(d.y-this.y),this.z+h*(d.z-this.z),this.w+h*(d.w-this.w))};a.Matrix2x2=function(a,h,g,c){this.a00=a||0;this.a01=h||0;this.a10=g||0;this.a11=c||0};a.Matrix2x2.prototype.clone=function(){return new a.Matrix2x2(this.a00,this.a01,this.a10,this.a11)};a.Matrix2x2.prototype.setIdentity=
function(){this.a00=1;this.a10=this.a01=0;this.a11=1;return this};a.Matrix2x2.prototype.transpose=function(){return new a.Matrix2x2(this.a00,this.a10,this.a01,this.a11)};a.Matrix2x2.prototype.determinant=function(){return this.a00*this.a11-this.a10*this.a01};a.Matrix2x2.prototype.inverse=function(){var d=this.determinant();if(!d)return null;d=1/d;return new a.Matrix2x2(this.a11*d,-this.a10*d,-this.a01*d,this.a00*d)};a.Matrix2x2.prototype.multiply=function(d){return new a.Matrix2x2(this.a00*d.a00+
this.a01*d.a10,this.a00*d.a01+this.a01*d.a11,this.a10*d.a00+this.a11*d.a10,this.a10*d.a01+this.a11*d.a11)};a.Matrix2x2.prototype.rotate=function(d){var h=Math.sin(d);d=Math.cos(d);return new a.Matrix2x2(this.a00*d+this.a01*h,this.a00*-h+this.a01*d,this.a10*d+this.a11*h,this.a10*-h+this.a11*d)};a.Matrix2x2.prototype.multiplyVector2=function(d){return new a.Vector2D(d.x*this.a00+d.y*this.a01,d.x*this.a10+d.y*this.a11)};a.Matrix2x2.prototype.scale=function(d){return new a.Matrix2x2(this.a00*d.x,this.a01*
d.y,this.a10*d.x,this.a11*d.y)};a.Matrix3x3=function(a,h,g,c,f,k,l,e,p){this.a00=a||0;this.a01=h||0;this.a02=g||0;this.a10=c||0;this.a11=f||0;this.a12=k||0;this.a20=l||0;this.a21=e||0;this.a22=p||0};a.Matrix3x3.prototype.copy=function(){return new a.Matrix3x3(this.a00,this.a01,this.a02,this.a10,this.a11,this.a12,this.a20,this.a21,this.a22)};a.Matrix3x3.prototype.determinant=function(){var a=this.a10,h=this.a11,g=this.a12,c=this.a20,f=this.a21,k=this.a22;return this.a00*(k*h-g*f)+this.a01*(-k*a+g*
c)+this.a02*(f*a-h*c)};a.Matrix3x3.prototype.inverse=function(){var d=this.a00,h=this.a01,g=this.a02,c=this.a10,f=this.a11,k=this.a12,l=this.a20,e=this.a21,p=this.a22,m=p*f-k*e,n=-p*c+k*l,t=e*c-f*l,s=d*m+h*n+g*t;if(!s)return null;s=1/s;return new a.Matrix3x3(m*s,(-p*h+g*e)*s,(k*h-g*f)*s,n*s,(p*d-g*l)*s,(-k*d+g*c)*s,t*s,(-e*d+h*l)*s,(f*d-h*c)*s)};a.Matrix3x3.prototype.multply=function(d){var h=this.a00,g=this.a01,c=this.a02,f=this.a10,k=this.a11,l=this.a12,e=this.a20,p=this.a21,m=this.a22,n=d.a00,
t=d.a01,s=d.a02,u=d.a10,q=d.a11,r=d.a12,w=d.a20,v=d.a21;d=d.a22;return new a.Matrix3x3(n*h+t*f+s*e,n*g+t*k+s*p,n*c+t*l+s*m,u*h+q*f+r*e,u*g+q*k+r*p,u*c+q*l+r*m,w*h+v*f+d*e,w*g+v*k+d*p,w*c+v*l+d*m)};a.Matrix3x3.prototype.multiplyVector2=function(d){return new a.Vector2D(d.x*this.a00+d.y*this.a10+this.a20,d.x*this.a01+d.y*this.a11+this.a21)};a.Matrix3x3.prototype.multiplyVector3=function(d){return new a.Vector3D(d.x*this.a00+d.y*this.a10+d.z*this.a20,d.x*this.a01+d.y*this.a11+d.z*this.a21,d.x*this.a02+
d.y*this.a12+d.z*this.a22)};a.Matrix3x3.prototype.setIdentity=function(){this.a00=1;this.a10=this.a02=this.a01=0;this.a11=1;this.a21=this.a20=this.a12=0;this.a22=1;return this};a.Matrix3x3.prototype.transpose=function(){return new a.Matrix3x3(this.a00,this.a10,this.a20,this.a01,this.a11,this.a21,this.a02,this.a12,this.a22)};a.Matrix3x3.prototype.toMatrix4x4=function(){return new a.Matrix4x4(this.a00,this.a01,this.a02,0,this.a10,this.a11,this.a12,0,this.a20,this.a21,this.a22,0,0,0,0,1)};a.Matrix4x4=
function(a,h,g,c,f,k,l,e,p,m,n,t,s,u,q,r){this.a00=a||0;this.a01=h||0;this.a02=g||0;this.a03=c||0;this.a10=f||0;this.a11=k||0;this.a12=l||0;this.a13=e||0;this.a20=p||0;this.a21=m||0;this.a22=n||0;this.a23=t||0;this.a30=s||0;this.a31=u||0;this.a32=q||0;this.a33=r||0};a.Matrix4x4.prototype.copy=function(){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.a30,this.a31,this.a32,this.a33)};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.transpose=function(){return new a.Matrix3x3(this.a00,this.a10,this.a20,this.a30,this.a01,this.a11,this.a21,this.a31,this.a02,this.a12,this.a22,this.a32,this.a03,this.a13,this.a23,this.a33)};a.Matrix4x4.prototype.determinant=function(){var a=this.a00,h=this.a01,g=this.a02,c=this.a03,f=this.a10,k=this.a11,
l=this.a12,e=this.a13,p=this.a20,m=this.a21,n=this.a22,t=this.a23,s=this.a30,u=this.a31,q=this.a32,r=this.a33;return s*m*l*c-p*u*l*c-s*k*n*c+f*u*n*c+p*k*q*c-f*m*q*c-s*m*g*e+p*u*g*e+s*h*n*e-a*u*n*e-p*h*q*e+a*m*q*e+s*k*g*t-f*u*g*t-s*h*l*t+a*u*l*t+f*h*q*t-a*k*q*t-p*k*g*r+f*m*g*r+p*h*l*r-a*m*l*r-f*h*n*r+a*k*n*r};a.Matrix4x4.prototype.inverse=function(){var d=this.a00,h=this.a01,g=this.a02,c=this.a03,f=this.a10,k=this.a11,l=this.a12,e=this.a13,p=this.a20,m=this.a21,n=this.a22,t=this.a23,s=this.a30,u=this.a31,
q=this.a32,r=this.a33,w=d*k-h*f,v=d*l-g*f,z=d*e-c*f,B=h*l-g*k,C=h*e-c*k,x=g*e-c*l,D=p*u-m*s,E=p*q-n*s,F=p*r-t*s,A=m*q-n*u,H=m*r-t*u,J=n*r-t*q,I=w*J-v*H+z*A+B*F-C*E+x*D;if(!I)return null;I=1/I;return new a.Matrix4x4((k*J-l*H+e*A)*I,(-h*J+g*H-c*A)*I,(u*x-q*C+r*B)*I,(-m*x+n*C-t*B)*I,(-f*J+l*F-e*E)*I,(d*J-g*F+c*E)*I,(-s*x+q*z-r*v)*I,(p*x-n*z+t*v)*I,(f*H-k*F+e*D)*I,(-d*H+h*F-c*D)*I,(s*C-u*z+r*w)*I,(-p*C+m*z-t*w)*I,(-f*A+k*E-l*D)*I,(d*A-h*E+g*D)*I,(-s*B+u*v-q*w)*I,(p*B-m*v+n*w)*I)};a.Matrix4x4.prototype.toRotationMat=
function(){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,0,0,0,1)};a.Matrix4x4.prototype.toMatrix3x3=function(){return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a10,this.a11,this.a12,this.a20,this.a21,this.a22)};a.Matrix4x4.prototype.toInverseMat3=function(){var d=this.a00,h=this.a01,g=this.a02,c=this.a10,f=this.a11,k=this.a12,l=this.a20,e=this.a21,p=this.a22,m=p*f-k*e,n=-p*c+k*l,t=e*c-f*l;return!(d*m+h*n+g*
t)?null:new a.Matrix3x3(m*id,(-p*h+g*e)*id,(k*h-g*f)*id,n*id,(p*d-g*l)*id,(-k*d+g*c)*id,t*id,(-e*d+h*l)*id,(f*d-h*c)*id)};a.Matrix4x4.prototype.multiply=function(d){var h=this.a00,g=this.a01,c=this.a02,f=this.a03,k=this.a10,l=this.a11,e=this.a12,p=this.a13,m=this.a20,n=this.a21,t=this.a22,s=this.a23,u=this.a30,q=this.a31,r=this.a32,w=this.a33,v=d.a00,z=d.a01,B=d.a02,C=d.a03,x=d.a10,D=d.a11,E=d.a12,F=d.a13,A=d.a20,H=d.a21,J=d.a22,I=d.a23,L=d.a30,y=d.a31,K=d.a32;d=d.a33;return new a.Matrix4x4(v*h+z*
k+B*m+C*u,v*g+z*l+B*n+C*q,v*c+z*e+B*t+C*r,v*f+z*p+B*s+C*w,x*h+D*k+E*m+F*u,x*g+D*l+E*n+F*q,x*c+D*e+E*t+F*r,x*f+D*p+E*s+F*w,A*h+H*k+J*m+I*u,A*g+H*l+J*n+I*q,A*c+H*e+J*t+I*r,A*f+H*p+J*s+I*w,L*h+y*k+K*m+d*u,L*g+y*l+K*n+d*q,L*c+y*e+K*t+d*r,L*f+y*p+K*s+d*w)};a.Matrix4x4.prototype.multiplyVector3=function(d){return new a.Vector3D(d.x*this.a00+d.y*this.a10+d.z*this.a20+this.a30,d.x*this.a01+d.y*this.a11+d.z*this.a21+this.a31,d.x*this.a02+d.y*this.a12+d.z*this.a22+this.a32)};a.Matrix4x4.prototype.multiplyVector4=
function(d){return new a.Vector4D(d.x*this.a00+d.y*this.a10+d.z*this.a20+d.w*this.a30,d.x*this.a01+d.y*this.a11+d.z*this.a21+d.w*this.a31,d.x*this.a02+d.y*this.a12+d.z*this.a22+d.w*this.a32,d.x*this.a03+d.y*this.a13+d.z*this.a23+d.w*this.a33)};a.Matrix4x4.prototype.translate=function(d){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*d.x+this.a10*d.y+this.a20*d.z+this.a30,this.a01*d.x+this.a11*d.y+this.a21*
d.z+this.a31,this.a02*d.x+this.a12*d.y+this.a22*d.z+this.a32,this.a03*d.x+this.a13*d.y+this.a23*d.z+this.a33)};a.Matrix4x4.prototype.scale=function(d){return new a.Matrix4x4(this.a00*d.x,this.a01*d.x,this.a02*d.x,this.a03*d.x,this.a10*d.y,this.a11*d.y,this.a12*d.y,this.a13*d.y,this.a20*d.z,this.a21*d.z,this.a22*d.z,this.a23*d.z,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotate=function(d,h){var g=Math.sqrt(h.x*h.x+h.y*h.y+h.z*h.z);if(!g)return null;1!==g&&(g=1/g,h.x*=g,h.y*=g,h.z*=
g);var c=Math.sin(d),f=Math.cos(d),k=1-f,g=this.a00,l=this.a01,e=this.a02,p=this.a03,m=this.a10,n=this.a11,t=this.a12,s=this.a13,u=this.a20,q=this.a21,r=this.a22,w=this.a23,v=h.x*h.x*k+f,z=h.y*h.x*k+h.z*c,B=h.z*h.x*k-h.y*c,C=h.x*h.y*k-h.z*c,x=h.y*h.y*k+f,D=h.z*h.y*k+h.x*c,E=h.x*h.z*k+h.y*c,c=h.y*h.z*k-h.x*c,f=h.z*h.z*k+f;return new a.Matrix4x4(g*v+m*z+u*B,l*v+n*z+q*B,e*v+t*z+r*B,p*v+s*z+w*B,g*C+m*x+u*D,l*C+n*x+q*D,e*C+t*x+r*D,p*C+s*x+w*D,g*E+m*c+u*f,l*E+n*c+q*f,e*E+t*c+r*f,p*E+s*c+w*f,this.a30,this.a31,
this.a32,this.a33)};a.Matrix4x4.prototype.rotateX=function(d){var h=Math.sin(d);d=Math.cos(d);var g=this.a10,c=this.a11,f=this.a12,k=this.a13,l=this.a20,e=this.a21,p=this.a22,m=this.a23;return new a.Matrix4x4(this.a00,this.a01,this.a02,this.a03,g*d+l*h,c*d+e*h,f*d+p*h,k*d+m*h,g*-h+l*d,c*-h+e*d,f*-h+p*d,k*-h+m*d,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateY=function(d){var h=Math.sin(d);d=Math.cos(d);var g=this.a00,c=this.a01,f=this.a02,k=this.a03,l=this.a20,e=this.a21,p=this.a22,
m=this.a23;return new a.Matrix4x4(g*d+l*-h,c*d+e*-h,f*d+p*-h,k*d+m*-h,this.a10,this.a11,this.a12,this.a13,g*h+l*d,c*h+e*d,f*h+p*d,k*h+m*d,this.a30,this.a31,this.a32,this.a33)};a.Matrix4x4.prototype.rotateZ=function(d){var h=Math.sin(d);d=Math.cos(d);var g=this.a00,c=this.a01,f=this.a02,k=this.a03,l=this.a10,e=this.a11,p=this.a12,m=this.a13;return new a.Matrix4x4(g*d+l*h,c*d+e*h,f*d+p*h,k*d+m*h,g*-h+l*d,c*-h+e*d,f*-h+p*d,k*-h+m*d,this.a20,this.a21,this.a22,this.a23,this.a30,this.a31,this.a32,this.a33)};
a.Matrix4x4.prototype.frustum=function(d,h,g,c,f,k){var l=h-d,e=c-g,p=k-f;return new a.Matrix4x4(2*f/l,0,0,0,0,2*f/e,0,0,(h+d)/l,(c+g)/e,-(k+f)/p,-1,0,0,-(2*k*f)/p,0)};a.Matrix4x4.prototype.perspective=function(a,h,g,c){a=g*Math.tan(a*Math.PI/360);h*=a;return this.frustum(-h,h,-a,a,g,c)};a.Matrix4x4.prototype.ortho=function(d,h,g,c,f,k){var l=h-d,e=c-g,p=k-f;return new a.Matrix4x4(2/l,0,0,0,0,2/e,0,0,0,0,-2/p,0,-(d+h)/l,-(c+g)/e,-(k+f)/p,1)};a.Matrix4x4.prototype.lookAt=function(d,h,g){if(d.x===h.x&&
d.y===h.y&&d.z===h.z)return(new a.Matrix4x4).setIdentity();var c=d.x-h.x,f=d.y-h.y;h=d.z-h.z;var k=1/Math.sqrt(c*c+f*f+h*h),c=c*k,f=f*k;h*=k;var l=g.y*h-g.z*f,e=g.z*c-g.x*h;g=g.x*f-g.y*c;(k=Math.sqrt(l*l+e*e+g*g))?(k=1/k,l*=k,e*=k,g*=k):g=e=l=0;var p=f*g-h*e,m=h*l-c*g,n=c*e-f*l;(k=Math.sqrt(p*p+m*m+n*n))?(k=1/k,p*=k,m*=k,n*=k):n=m=p=0;return new a.Matrix4x4(l,p,c,0,e,m,f,0,g,n,h,0,-(l*d.x+e*d.y+g*d.z),-(p*d.x+m*d.y+n*d.z),-(c*d.x+f*d.y+h*d.z),1)};a.Matrix4x4.prototype.fromRotationTranslation=function(d){var h=
2*this.x,g=2*this.y,c=2*this.z,f=this.x*h,k=this.x*g,l=this.x*c,e=this.y*g,p=this.y*c,m=this.z*c,h=this.w*h,g=this.w*g,c=this.w*c;return new a.Matrix4x4(1-(e+m),k+c,l-g,0,k-c,1-(f+m),p+h,0,l+g,p-h,1-(f+e),0,d.x,d.y,d.z,1)};a.Quaternion=function(a,h,g,c){this.x=a||0;this.y=h||0;this.z=g||0;this.w=c||0};a.Quaternion.prototype.clone=function(){return new a.Quaternion(this.x,this.y,this.z,this.w)};a.Quaternion.prototype.setIdentity=function(){this.z=this.y=this.x=0;this.w=1;return this};a.Quaternion.prototype.calculateW=
function(){return new a.Quaternion(this.x,this.y,this.z,-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z)))};a.Quaternion.prototype.dot=function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w};a.Quaternion.prototype.inverse=function(){var d=this.dot(this),h=0;0!=d&&(h=1/d);return new a.Quaternion(-this.x*h,-this.y*h,-this.z*h,this.w*h)};a.Quaternion.prototype.conjugate=function(){return new a.Quaternion(-this.x,-this.y,-this.z,this.w)};a.Quaternion.prototype.length=function(){return Math.sqrt(this.x*
this.x+this.y*this.y+this.z*this.z+this.w*this.w)};a.Quaternion.prototype.normalize=function(d,h){var g=this.length();if(0===g)return new a.Quaternion;g=1/g;return new a.Quaternion(this.x*g,this.y*g,this.z*g,this.w*g)};a.Quaternion.prototype.add=function(d){return new a.Quaternion(this.x+d.x,this.y+d.y,this.z+d.z,this.w+d.w)};a.Quaternion.prototype.multiply=function(d){return new a.Quaternion(this.x*d.w+this.w*d.x+this.y*d.z-this.z*d.y,this.y*d.w+this.w*d.y+this.z*d.x-this.x*d.z,this.z*d.w+this.w*
d.z+this.x*d.y-this.y*d.x,this.w*d.w-this.x*d.x-this.y*d.y-this.z*d.z)};a.Quaternion.prototype.multiplyVector3=function(d){var h=this.w*d.x+this.y*d.z-this.z*d.y,g=this.w*d.y+this.z*d.x-this.x*d.z,c=this.w*d.z+this.x*d.y-this.y*d.x;d=-this.x*d.x-this.y*d.y-this.z*d.z;return new a.Vector3D(h*this.w+d*-this.x+g*-this.z-c*-this.y,g*this.w+d*-this.y+c*-this.x-h*-this.z,c*this.w+d*-this.z+h*-this.y-g*-this.x)};a.Quaternion.prototype.scale=function(d){return new a.Quaternion(this.x*d,this.y*d,this.z*d,
this.w*d)};a.Quaternion.prototype.toMatrix3x3=function(){var d=this.x+this.x,h=this.y+this.y,g=this.z+this.z,c=this.x*d,f=this.x*h,k=this.x*g,l=this.y*h,e=this.y*g,p=this.z*g,d=this.w*d,h=this.w*h,g=this.w*g;return new a.Matrix3x3(1-(l+p),f+g,k-h,f-g,1-(c+p),e+d,k+h,e-d,1-(c+l))};a.Quaternion.prototype.toMat4=function(){var d=this.x+this.x,h=this.y+this.y,g=this.z+this.z,c=this.x*d,f=this.x*h,k=this.x*g,l=this.y*h,e=this.y*g,p=this.z*g,d=this.w*d,h=this.w*h,g=this.w*g;return new a.Matrix4x4(1-(l+
p),f+g,k-h,0,f-g,1-(c+p),e+d,0,k+h,e-d,1-(c+l),0,0,0,0,1)};a.Quaternion.prototype.slerp=function(d,h){var g=this.x*d.x+this.y*d.y+this.z*d.z+this.w*d.w;if(1<=Math.abs(g))return new a.Quaternion(this.x,this.y,this.z,this.w);var c=Math.acos(g),f=Math.sqrt(1-g*g);if(0.0010>Math.abs(f))return new a.Quaternion(0.5*this.x+0.5*d.x,0.5*this.y+0.5*d.y,0.5*this.z+0.5*d.z,0.5*this.w+0.5*d.w);g=Math.sin((1-h)*c)/f;c=Math.sin(h*c)/f;return new a.Quaternion(this.x*g+d.x*c,this.y*g+d.y*c,this.z*g+d.z*c,this.w*g+
d.w*c)};a.Quaternion.prototype.fromRotationMatrix=function(d){var h=new a.Quaternion;fTrace=d.a00+d.a11+d.a22;var g;if(0<fTrace)g=Math.sqrt(fTrace+1),h.w=0.5*g,g=0.5/g,h.x=(d.a21-d.a12)*g,h.y=(d.a02-d.a20)*g,h.z=(d.a10-d.a01)*g;else{g=[1,2,0];var c=0;d=[d.a00,d.a01,d.a02,d.a10,d.a11,d.a12,d.a20,d.a21,d.a22];d[4]>d[0]&&(c=1);d[8]>d[3*c+c]&&(c=2);var f=g[c],k=g[f];g=Math.sqrt(d[3*c+c]-d[3*f+f]-d[3*k+k]+1);0==c?h.x=0.5*g:1==c?h.y=0.5*g:h.z=0.5*g;g=0.5/g;h.w=(d[3*k+f]-d[3*f+k])*g;0==f?h.x=(d[3*f+c]+d[3*
c+f])*g:1==f?h.y=(d[3*f+c]+d[3*c+f])*g:h.z=(d[3*f+c]+d[3*c+f])*g;0==f?h.x=(d[3*k+c]+d[3*c+k])*g:1==f?h.y=(d[3*k+c]+d[3*c+k])*g:h.z=(d[3*k+c]+d[3*c+k])*g}return h};a.Quaternion.prototype.setIdentity=function(){this.z=this.y=this.x=0;this.w=1;return this};a.Quaternion.prototype.fromAngleAxis=function(d,h){var g=0.5*d,c=Math.sin(g);return new a.Quaternion(Math.cos(g),c*h.x,c*h.y,c*h.z)};a.Quaternion.prototype.toAngleAxis=function(){var d=this.x*this.x+this.y*this.y+this.z*this.z,h=new a.Vector4D;0<d?
(h.w=2*Math.acos(this.w),d=a.RenderMath.inverseSqrt(d),h.x=this.x*d,h.y=this.y*d,h.z=this.z*d):(h.x=1,h.y=0,h.z=0,h.w=0);return h};a.Matrix4x4.prototype.toArray=function(){return[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.a30,this.a31,this.a32,this.a33]};return a}(descartesJS||{}),descartesJS=function(a){function d(a,c){for(var d in c)a[d]=c[d]}function h(a){d(a,this.style);a.beginPath();a.arc(this.transformedVertices[0].x,this.transformedVertices[0].y,
this.style.size,0,2*Math.PI);a.fill();a.stroke()}function g(a){d(a,this.style);a.beginPath();a.moveTo(this.transformedVertices[0].x,this.transformedVertices[0].y);for(var c=1,e=this.transformedVertices.length;c<e;c++)a.lineTo(this.transformedVertices[c].x,this.transformedVertices[c].y);a.closePath();"color"===this.style.model?(0<=this.direction?(a.fillStyle=this.style.backcolor,a.strokeStyle=this.style.backcolor):a.strokeStyle=this.style.fillStyle,a.fill()):"light"===this.style.model||"metal"===this.style.model?
(0<this.direction?(a.fillStyle=k(this.style.fcolor,this.normal.dotProduct(this.light)),a.strokeStyle=this.style.backcolor):(a.fillStyle=k(this.style.bcolor,-this.normal.dotProduct(this.light)),a.strokeStyle=this.style.fillStyle),a.fill()):"wire"===this.style.model&&(a.lineWidth=1.25,a.strokeStyle=this.style.fillStyle,a.stroke());this.style.edges&&"wire"!==this.style.model&&(a.lineWidth=1,a.strokeStyle=this.style.strokeStyle,a.stroke())}function c(a){this.drawText(a,this.text,this.transformedVertices[0].x,
this.transformedVertices[0].y+this.style.displace,this.style.fillStyle,this.style.font,"left","alphabetic",this.style.decimals,this.style.fixed,!0)}function f(a){d(a,this.style);a.beginPath();a.moveTo(this.transformedVertices[0].x,this.transformedVertices[0].y);a.lineTo(this.transformedVertices[1].x,this.transformedVertices[1].y);a.stroke()}function k(a,c){c=Math.acos(c)/Math.PI;return"rgba("+Math.floor(a.r*c)+","+Math.floor(a.g*c)+","+Math.floor(a.b*c)+","+(1-a.a)+")"}if(a.loadLib)return a;var l,
e,p,m,n;a.Primitive3D=function(d,e,k,l,m){this.vertices=d;this.type=e;this.style=k;this.evaluator=l;this.text=m||"";this.light=(new a.Vector3D(-1,0,0)).normalize();this.transformedVertices=[];"vertex"===e?this.draw=h:"face"===e?this.draw=g:"text"===e?this.draw=c:"edge"===e&&(this.draw=f);k.isText&&(this.computeDepth=function(a){this.transformedVertices=this.vertices;this.depth=a.perspectiveMatrix.multiplyVector4(this.vertices[0]).toVector3D().z})};a.Primitive3D.prototype.setVertices=function(a){this.vertices=
a};a.Primitive3D.prototype.setStyle=function(a){this.style=a};a.Primitive3D.prototype.computeDepth=function(a){2<this.vertices.length&&(l=this.vertices[0].toVector3D().direction(this.vertices[1].toVector3D()),e=this.vertices[0].toVector3D().direction(this.vertices[2].toVector3D()),this.normal=l.crossProduct(e).normalize(),this.direction=this.normal.dotProduct(a.eye.normalize()));this.depth=0;this.zMin=1E4;this.zMax=-1E4;for(var c=0,d=this.vertices.length;c<d;c++)this.transformedVertices[c]=a.perspectiveMatrix.multiplyVector4(this.vertices[c]).toVector3D(),
this.depth+=this.transformedVertices[c].z,this.zMin=Math.min(this.zMin,this.transformedVertices[c].z),this.zMax=Math.max(this.zMax,this.transformedVertices[c].z),this.transformedVertices[c].x=a.transformCoordinateX(this.transformedVertices[c].x),this.transformedVertices[c].y=a.transformCoordinateY(this.transformedVertices[c].y);this.depth/=d};a.Primitive3D.prototype.drawText=function(c,d,e,k,g,f,h,l,B,C,x){if("rtfNode"==d.type)c.fillStyle=g,c.strokeStyle=g,c.textBaseline="alphabetic",d.draw(c,e,k,
B,C,h,x);else{"simpleText"===d.type&&(d=d.toString(B,C).split("\\n"));e+=f.match("Arial")?-2:f.match("Times")?-2:0;p=this.evaluator;c.fillStyle=a.getColor(p,g);c.font=f;c.textAlign=h;c.textBaseline=l;m=1.2*this.fontSize||0;g=0;for(f=d.length;g<f;g++)n=d[g],this.border&&c.strokeText(n,e,k+m*g),c.fillText(n,e,k+m*g)}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k,l,e;a.Graphic3D=function(c,d){this.parent=c;this.evaluator=c.evaluator;var g=this.parent.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=g.parse("1");this.abs_coord=!1;this.family="";this.family_interval=g.parse("[0,1]");this.family_steps=g.parse("8");this.font="Monospaced,PLAIN,12";this.fixed=!0;this.text="";this.decimals=g.parse("2");this.inirot=g.parse("(0,0,0)");this.inipos=g.parse("(0,0,0)");this.endrot=g.parse("(0,0,0)");
this.endpos=g.parse("(0,0,0)");this.model="color";for(var h in d)d.hasOwnProperty(h)&&(this[h]=d[h]);void 0==this.expresion&&"macro"!=this.type&&(this.expresion=g.parse("(0,0)"));this.space=this.getSpace();this.canvas=this.background?this.space.backgroundCanvas:this.space.canvas;this.ctx=this.canvas.getContext("2d");this.font=a.convertFont(this.font);this.fontSize=(this.fontSize=this.font.match(/(\d+)px/))?parseInt(this.fontSize[1]):10;f=new a.Vector3D(1,0,0);k=new a.Vector3D(0,1,0);l=new a.Vector3D(0,
0,1);e=new a.Vector3D(0,0,0);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_X=new a.Matrix4x4;this.endrotMatrix_Y=new a.Matrix4x4;this.endrotMatrix_Z=new a.Matrix4x4;this.endposM=new a.Matrix4x4};a.Graphic3D.prototype.getSpace=function(){for(var a=this.parent.spaces,c,d=0,e=a.length;d<e;d++)if(c=a[d],c.id==this.spaceID)return c;return a[0]};a.Graphic3D.prototype.getFamilyValues=function(){d=this.evaluator;h=d.evalExpression(this.family_interval);
this.familyInf=h[0][0];this.familySup=h[0][1];this.fSteps=Math.round(d.evalExpression(this.family_steps));this.family_sep=0<this.fSteps?(this.familySup-this.familyInf)/this.fSteps:0};a.Graphic3D.prototype.buildFamilyPrimitives=function(){d=this.evaluator;this.getFamilyValues();g=d.getVariable(this.family);if(0<=this.fSteps)for(var a=0,c=this.fSteps;a<=c;a++)d.setVariable(this.family,this.familyInf+a*this.family_sep),d.evalExpression(this.drawif)&&this.buildPrimitives();d.setVariable(this.family,g)};
a.Graphic3D.prototype.update=function(){this.primitives=[];this.evaluator.evalExpression(this.drawif)&&(this.family?this.buildFamilyPrimitives():this.buildPrimitives())};a.Graphic3D.prototype.updateMVMatrix=function(d){this.mvMatrix=this.mvMatrix.setIdentity();d||(c=this.evaluator.evalExpression(this.inirot),this.mvMatrix=this.mvMatrix.rotate(a.degToRad(c[0][0]),f),this.mvMatrix=this.mvMatrix.rotate(a.degToRad(c[0][1]),k),this.mvMatrix=this.mvMatrix.rotate(a.degToRad(c[0][2]),l));c=this.evaluator.evalExpression(this.inipos);
e.set(c[0][0],c[0][1],c[0][2]);this.mvMatrix=this.mvMatrix.translate(e);d||(c=this.evaluator.evalExpression(this.endrot),this.mvMatrix=this.mvMatrix.rotate(a.degToRad(c[0][0]),f),this.mvMatrix=this.mvMatrix.rotate(a.degToRad(c[0][1]),k),this.mvMatrix=this.mvMatrix.rotate(a.degToRad(c[0][2]),l));c=this.evaluator.evalExpression(this.endpos);e.set(c[0][0],c[0][1],c[0][2]);this.mvMatrix=this.mvMatrix.translate(e)};a.Graphic3D.prototype.parseExpression=function(){for(var a=this.expresion.split("="),c=
a[0],d=[],e,k=1;k<a.length;k++)c+="=",e=a[k].lastIndexOf(" "),c=-1!==e?c+a[k].substring(0,e):c+a[k],d.push(this.evaluator.parser.parse(c,!0)),c=a[k].substring(e+1);return d};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h;a.Point3D=function(d,c){a.Graphic3D.call(this,d,c);this.mvMatrix=(new a.Matrix4x4).setIdentity()};a.extend(a.Point3D,a.Graphic3D);a.Point3D.prototype.buildPrimitives=function(){d=this.evaluator;this.updateMVMatrix();h=d.evalExpression(this.expresion);
this.exprX=h[0][0];this.exprY=h[0][1];this.exprZ=h[0][2];this.primitives.push(new a.Primitive3D([this.mvMatrix.multiplyVector4(new a.Vector4D(this.exprX,this.exprY,this.exprZ,1))],"vertex",{fillStyle:this.backcolor.getColor(),strokeStyle:this.color.getColor(),lineCap:"round",lineJoin:"round",lineWidth:1,size:d.evalExpression(this.width)}));this.primitives.push(new a.Primitive3D([this.mvMatrix.multiplyVector4(new a.Vector4D(this.exprX,this.exprY,this.exprZ,1))],"text",{fillStyle:this.color.getColor(),
font:this.font,decimals:this.evaluator.evalExpression(this.decimals),fixed:this.fixed,displace:this.fontSize},this.evaluator,this.text))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k;a.Segment3D=function(c,d){this.width=c.evaluator.parser.parse("1");a.Graphic3D.call(this,c,d);this.mvMatrix=(new a.Matrix4x4).setIdentity()};a.extend(a.Segment3D,a.Graphic3D);a.Segment3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=
evaluator.evalExpression(this.expresion);d=expr[0][0];h=expr[0][1];g=expr[0][2];c=expr[1][0];f=expr[1][1];k=expr[1][2];this.primitives.push(new a.Primitive3D([this.mvMatrix.multiplyVector4(new a.Vector4D(d,h,g,1)),this.mvMatrix.multiplyVector4(new a.Vector4D(c,f,k,1))],"edge",{strokeStyle:this.color.getColor(),lineCap:"round",lineJoin:"round",lineWidth:this.evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k,l;a.Surface3D=
function(c,d){this.parameter="t";this.parameter_interval=c.evaluator.parser.parse("[0,1]");this.parameter_steps=c.evaluator.parser.parse("8");a.Graphic3D.call(this,c,d);this.mvMatrix=(new a.Matrix4x4).setIdentity();this.expresion=this.parseExpression()};a.extend(a.Surface3D,a.Graphic3D);a.Surface3D.prototype.buildPrimitives=function(){d=this.evaluator;this.updateMVMatrix();g=d.getVariable("x");g=d.getVariable("y");g=d.getVariable("z");h=d.getVariable("u");g=d.getVariable("v");d.setVariable("u",0);
d.setVariable("v",0);c=d.evalExpression(this.Nu);f=d.evalExpression(this.Nv);k=[];for(var e=0;e<=c;e++){d.setVariable("u",e/c);for(var p=0;p<=f;p++){d.setVariable("v",p/f);for(var m=0,n=this.expresion.length;m<n;m++)d.evalExpression(this.expresion[m]);k.push(this.mvMatrix.multiplyVector4(new a.Vector4D(d.getVariable("x"),d.getVariable("y"),d.getVariable("z"),1)))}}for(e=0;e<c;e++)for(p=0;p<f;p++)l=[],l.push(k[p+e*f+e]),l.push(k[p+1+e*f+e]),l.push(k[p+2+(e+1)*f+e]),l.push(k[p+1+(e+1)*f+e]),this.primitives.push(new a.Primitive3D(l,
"face",{backcolor:this.backcolor.getColor(),fillStyle:this.color.getColor(),strokeStyle:"#808080",lineCap:"round",lineJoin:"round",edges:this.edges,model:this.model}));d.setVariable("x",void 0);d.setVariable("y",void 0);d.setVariable("z",void 0);d.setVariable("u",h);d.setVariable("v",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k;a.Polygon3D=function(c,d){this.width=c.evaluator.parser.parse("1");a.Graphic3D.call(this,c,d);this.mvMatrix=(new a.Matrix4x4).setIdentity()};
a.extend(a.Polygon3D,a.Graphic3D);a.Polygon3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);for(var l=0,e=expr.length-1;l<e;l++)d=expr[l][0],h=expr[l][1],g=expr[l][2],c=expr[l+1][0],f=expr[l+1][1],k=expr[l+1][2],this.primitives.push(new a.Primitive3D([this.mvMatrix.multiplyVector4(new a.Vector4D(d,h,g,1)),this.mvMatrix.multiplyVector4(new a.Vector4D(c,f,k,1))],"edge",{strokeStyle:this.color.getColor(),lineCap:"round",
lineJoin:"round",lineWidth:this.evaluator.evalExpression(this.width)}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k;a.Curve3D=function(c,d){this.width=c.evaluator.parser.parse("1");a.Graphic3D.call(this,c,d);this.mvMatrix=(new a.Matrix4x4).setIdentity();this.expresion=this.parseExpression()};a.extend(a.Curve3D,a.Graphic3D);a.Curve3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();c=evaluator.getVariable("x");f=evaluator.getVariable("y");
k=evaluator.getVariable("z");g=evaluator.getVariable("u");evaluator.setVariable("u",0);h=evaluator.evalExpression(this.Nu);d=[];for(var l=0;l<=h;l++){evaluator.setVariable("u",l/h);for(var e=0,p=this.expresion.length;e<p;e++)evaluator.evalExpression(this.expresion[e]);d.push(this.mvMatrix.multiplyVector4(new a.Vector4D(evaluator.getVariable("x"),evaluator.getVariable("y"),evaluator.getVariable("z"),1)))}l=0;for(e=d.length-1;l<e;l++)this.primitives.push(new a.Primitive3D([d[l],d[l+1]],"edge",{strokeStyle:this.color.getColor(),
lineCap:"round",lineJoin:"round",lineWidth:this.evaluator.evalExpression(this.width)}));evaluator.setVariable("x",c);evaluator.setVariable("y",k);evaluator.setVariable("z",f);evaluator.setVariable("u",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k,l,e,p;a.Triangle3D=function(c,d){a.Graphic3D.call(this,c,d);this.mvMatrix=(new a.Matrix4x4).setIdentity()};a.extend(a.Triangle3D,a.Graphic3D);a.Triangle3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;
this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);d=expr[0][0];h=expr[0][1];g=expr[0][2];c=expr[1][0];f=expr[1][1];k=expr[1][2];l=expr[2][0];e=expr[2][1];p=expr[2][2];this.primitives.push(new a.Primitive3D([this.mvMatrix.multiplyVector4(new a.Vector4D(d,h,g,1)),this.mvMatrix.multiplyVector4(new a.Vector4D(c,f,k,1)),this.mvMatrix.multiplyVector4(new a.Vector4D(l,e,p,1))],"face",{backcolor:this.color.getColor(),fillStyle:this.backcolor.getColor(),strokeStyle:"#808080",lineCap:"round",
lineJoin:"round",edges:this.edges,model:this.model}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.Face3D=function(d,g){a.Graphic3D.call(this,d,g);this.mvMatrix=(new a.Matrix4x4).setIdentity()};a.extend(a.Face3D,a.Graphic3D);a.Face3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();expr=evaluator.evalExpression(this.expresion);d=[];for(var h=0,g=expr.length;h<g;h++)d.push(this.mvMatrix.multiplyVector4(new a.Vector4D(expr[h][0],
expr[h][1],expr[h][2],1)));this.primitives.push(new a.Primitive3D(d,"face",{backcolor:this.color.getColor(),fillStyle:this.backcolor.getColor(),strokeStyle:"#808080",lineCap:"round",lineJoin:"round",edges:this.edges,model:this.model}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f;a.Polireg3D=function(c,d){this.width=c.evaluator.parser.parse("2");this.length=c.evaluator.parser.parse("2");a.Graphic3D.call(this,c,d);this.mvMatrix=(new a.Matrix4x4).setIdentity()};
a.extend(a.Polireg3D,a.Graphic3D);a.Polireg3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;this.updateMVMatrix();d=evaluator.evalExpression(this.Nu);h=[this.mvMatrix.multiplyVector4(new a.Vector4D(0,0,0,1))];g=evaluator.evalExpression(this.width)/2;c=evaluator.evalExpression(this.length)/2;f=2*Math.PI/d;for(var k=0;k<d;k++)h.push(this.mvMatrix.multiplyVector4(new a.Vector4D(g*Math.cos(f*k),c*Math.sin(f*k),0,1)));for(k=0;k<d;k++)this.primitives.push(new a.Primitive3D([h[0],h[k+1],
k+2<=d?h[k+2]:h[1]],"face",{backcolor:this.color.getColor(),fillStyle:this.backcolor.getColor(),strokeStyle:"#808080",lineCap:"round",lineJoin:"round",edges:this.edges,model:this.model}))};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Text3D=function(d,h){a.Graphic3D.call(this,d,h)};a.extend(a.Text3D,a.Graphic3D);a.Text3D.prototype.buildPrimitives=function(){evaluator=this.evaluator;expr=evaluator.evalExpression(this.expresion);this.exprX=expr[0][0];this.exprY=expr[0][1];
this.exprZ=0;this.primitives.push(new a.Primitive3D([new a.Vector4D(this.exprX,this.exprY,this.exprZ,1)],"text",{fillStyle:this.color.getColor(),font:this.font,decimals:this.evaluator.evalExpression(this.decimals),fixed:this.fixed,displace:0,isText:!0},this.evaluator,this.text))};return a}(descartesJS||{}),descartesJS=function(a){function d(a,c,d,e,k){h.call(this,a/2,a/2,a/2,e,k)}function h(a,c,d,e,k){a/=2;c/=2;d/=2;this.changeGeometry(a,c,d,e,k)||(this.vertices=[new q(a,d,c,1),new q(a,-d,c,1),new q(a,
d,-c,1),new q(a,-d,-c,1),new q(-a,d,c,1),new q(-a,-d,c,1),new q(-a,d,-c,1),new q(-a,-d,-c,1)],this.faces=[[0,1,3,2],[0,4,5,1],[4,6,7,5],[2,3,7,6],[0,2,6,4],[1,5,7,3]],this.updateValues(a,c,d,e,k))}function g(a,c,d,e,k){a/=2;this.changeGeometry(a,c,d,e,k)||(this.vertices=[new q(0,0,a,1),new q(-0.49*a,-0.86*a,-0.32*a,1),new q(-0.49*a,0.86*a,-0.32*a,1),new q(1*a,0,-0.32*a,1)],this.faces=[[1,2,3],[0,2,1],[0,3,2],[0,1,3]],this.updateValues(a,c,d,e,k))}function c(a,c,d,e,k){a/=2;this.changeGeometry(a,c,
d,e,k)||(this.vertices=[new q(0,0,a,1),new q(a,0,0,1),new q(-a,0,0,1),new q(0,a,0,1),new q(0,-a,0,1),new q(0,0,-a,1)],this.faces=[[0,1,3],[0,3,2],[0,4,1],[0,2,4],[5,3,1],[5,2,3],[5,1,4],[5,4,2]],this.updateValues(a,c,d,e,k))}function f(c,d,e,k,g){c/=3.4;if(!this.changeGeometry(c,d,e,k,g)){A=c/F;H=c*F;this.vertices=[new q(c,c,c,1),new q(c,c,-c,1),new q(c,-c,c,1),new q(c,-c,-c,1),new q(-c,c,c,1),new q(-c,c,-c,1),new q(-c,-c,c,1),new q(-c,-c,-c,1),new q(0,A,H,1),new q(0,A,-H,1),new q(0,-A,H,1),new q(0,
-A,-H,1),new q(A,H,0,1),new q(A,-H,0,1),new q(-A,H,0,1),new q(-A,-H,0,1),new q(H,0,A,1),new q(H,0,-A,1),new q(-H,0,A,1),new q(-H,0,-A,1)];J=(new a.Matrix4x4).setIdentity().rotate(-s/6,new a.Vector3D(0,1,0));for(var f=0,h=this.vertices.length;f<h;f++)this.vertices[f]=J.multiplyVector4(this.vertices[f]);this.faces=[[8,10,2,16,0],[0,16,17,1,12],[0,12,14,4,8],[13,3,17,16,2],[2,10,6,15,13],[10,8,4,18,6],[11,9,1,17,3],[15,7,11,3,13],[9,5,14,12,1],[7,19,5,9,11],[19,18,4,14,5],[18,19,7,15,6]];this.updateValues(c,
d,e,k,g)}}function k(c,d,e,k,g){c/=4;if(!this.changeGeometry(c,d,e,k,g)){H=c*F;this.vertices=[new q(0,c,H,1),new q(0,c,-H,1),new q(0,-c,H,1),new q(0,-c,-H,1),new q(c,H,0,1),new q(c,-H,0,1),new q(-c,H,0,1),new q(-c,-H,0,1),new q(H,0,c,1),new q(H,0,-c,1),new q(-H,0,c,1),new q(-H,0,-c,1)];this.faces=[[2,0,10],[2,8,0],[2,5,8],[2,7,5],[2,10,7],[10,0,6],[10,6,11],[10,11,7],[11,3,7],[7,3,5],[5,3,9],[5,9,8],[8,9,4],[8,4,0],[0,4,6],[1,3,11],[1,11,6],[1,6,4],[1,4,9],[1,9,3]];J=(new a.Matrix4x4).setIdentity().rotate(-1.029,
new a.Vector3D(0,1,0));for(var f=0,h=this.vertices.length;f<h;f++)this.vertices[f]=J.multiplyVector4(this.vertices[f]);this.updateValues(c,d,e,k,g)}}function l(a,c,d,e,k){a/=2;this.isSphere?d=c=a:(c/=2,d/=2);if(!this.changeGeometry(a,c,d,e,k)){this.vertices=[new q(0,0,c,1)];for(var g=1;g<e;g++){E=g*s/e;for(var f=0;f<k;f++)D=f*u/k,B=a*n(E)*t(D),C=d*n(E)*n(D),x=c*t(E),this.vertices.push(new q(B,C,x,1))}this.vertices.push(new q(0,0,-c,1));this.faces=[];for(g=0;g<k;g++)this.faces.push([0,g%k+1,(g+1)%
k+1]);for(g=1;g<e-1;g++)for(f=0;f<k;f++)this.faces.push([(f+1)%k+1+(g-1)*k,f+1+(g-1)*k,f+1+g*k,(f+1)%k+1+g*k]);for(g=0;g<k;g++)this.faces.push([this.vertices.length-1,this.vertices.length-1-k+(g+1)%k,this.vertices.length-1-k+g]);this.updateValues(a,c,d,e,k)}}function e(a,c,d,e,k){a/=2;c/=2;d/=2;if(!this.changeGeometry(a,c,d,e,k)){this.vertices=[];for(var g=0;g<k;g++)for(var f=0;f<e;f++)B=a*(k-g)/k*t(f*u/e),C=d*(k-g)/k*n(f*u/e),x=c-2*g*c/k,this.vertices.push(new q(B,C,x,1));this.vertices.push(new q(0,
0,-c,1));this.faces=[];for(g=0;g<k-1;g++)for(f=0;f<e;f++)this.faces.push([(f+1)%e+g*e,f+g*e,f+(g+1)*e,(f+1)%e+(g+1)*e]);for(g=0;g<e;g++)this.faces.push([this.vertices.length-1,this.vertices.length-1-e+(g+1)%e,this.vertices.length-1-e+g]);this.updateValues(a,c,d,e,k)}}function p(a,c,d,e,k){a/=2;c/=2;d/=2;if(!this.changeGeometry(a,c,d,e,k)){this.vertices=[];for(var g=0;g<k+1;g++)for(var f=0;f<e;f++)B=a*t(f*u/e),C=d*n(f*u/e),x=c-2*g*c/k,this.vertices.push(new q(B,C,x,1));this.faces=[];for(g=0;g<k;g++)for(f=
0;f<e;f++)this.faces.push([(f+1)%e+g*e,f+g*e,f+(g+1)*e,(f+1)%e+(g+1)*e]);this.updateValues(a,c,d,e,k)}}function m(){function a(c){return parseInt(c)}function c(a){return parseFloat(a)}this.vertices=[];this.faces=[];for(var d=0,e=this.fileData.length;d<e;d++)I=this.fileData[d],I.match(/^V\(/)?(L=I.substring(2,I.length-1).split(",").map(c),this.vertices.push(new q(L[0]||0,L[1]||0,L[2]||0,1))):I.match(/^F\(/)&&(L=I.substring(2,I.length-1).split(",").map(a),this.faces.push(L))}if(a.loadLib)return a;var n=
Math.sin,t=Math.cos,s=Math.PI,u=2*s,q,r,w,v,z,B,C,x,D,E,F=1.6180339887,A,H,J,I,L;a.OtherGeometry=function(n,s){this.width=n.evaluator.parser.parse("2");this.height=n.evaluator.parser.parse("2");this.length=n.evaluator.parser.parse("2");q=a.Vector4D;a.Graphic3D.call(this,n,s);this.mvMatrix=(new a.Matrix4x4).setIdentity();switch(this.type){case "cube":this.buildGeometry=d;break;case "box":this.buildGeometry=h;break;case "tetrahedron":this.buildGeometry=g;break;case "octahedron":this.buildGeometry=c;
break;case "sphere":this.isSphere=!0;case "ellipsoid":this.buildGeometry=l;break;case "dodecahedron":this.buildGeometry=f;break;case "icosahedron":this.buildGeometry=k;break;case "cone":this.buildGeometry=e;break;case "cylinder":this.buildGeometry=p;break;case "mesh":this.fileData=a.openExternalFile(this.evaluator.evalExpression(this.file)).split(/\r/),this.buildGeometry=m}};a.extend(a.OtherGeometry,a.Graphic3D);a.OtherGeometry.prototype.buildPrimitives=function(){r=this.evaluator.evalExpression;
this.updateMVMatrix();this.buildGeometry(r(this.width),r(this.height),r(this.length),r(this.Nu),r(this.Nv));w=this.color.getColor();v=this.backcolor.getColor();for(var c=0,d=this.faces.length;c<d;c++){z=[];for(var e=0,k=this.faces[c].length;e<k;e++)z.push(this.mvMatrix.multiplyVector4(this.vertices[this.faces[c][e]]));this.primitives.push(new a.Primitive3D(z,"face",{backcolor:w,fillStyle:v,strokeStyle:"#808080",lineCap:"round",lineJoin:"round",edges:this.edges,model:this.model,fcolor:this.color,bcolor:this.backcolor}))}};
a.OtherGeometry.prototype.changeGeometry=function(a,c,d,e,k){return this.oldWidth===a&&this.oldHeight===c&&this.oldLength===d&&this.oldNu===e&&this.oldNv===k};a.OtherGeometry.prototype.updateValues=function(a,c,d,e,k){this.oldWidth=a;this.oldHeight=c;this.oldLength=d;this.oldNv=k;this.oldNu=e};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.max,h=Math.min,g=Math.PI,c=Math.cos,f=Math.sin,k=Math.abs,l,e,p,m,n,t,s,u,q,r,w,v,z,B,C,x,D,E;a.R2=function(a,c){this.x=a||
0;this.y=c||0};a.R2.prototype.set=function(a,c){this.x=a||0;this.y=c||0};a.R2.prototype.copy=function(){return new a.R2(this.x,this.y)};a.R2.prototype.ix=function(){return Math.round(d(h(this.x,32E3),-32E3))};a.R2.prototype.iy=function(){return Math.round(d(h(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){e=this.copy();e.sub(a);return e.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(){l=this.norm();0!=l&&this.div(l)};a.R2.prototype.rotR90=function(){l=this.x;
this.x=this.y;this.y=-l};a.R2.prototype.rotL90=function(){l=this.x;this.x=-this.y;this.y=l};a.R2.prototype.rot=function(a){p=this.copy();t=c(a);s=f(a);this.x=p.x*t-p.y*s;this.y=p.x*s+p.y*t};a.R2.prototype.rot=function(a){this.rot(a*g/180)};a.R2.prototype.intersection=function(c,e,g,f){u=e.x-c.x;q=g.x-f.x;r=g.x-c.x;w=e.y-c.y;v=g.y-f.y;z=g.y-c.y;E=u*v-q*w;return 1E-6<k(E)?(m=(r*v-z*q)/E,n=(-r*w+z*u)/E,0<=m&&1>=m&&0<=n&&1>=n?new a.R2(c.x+u*m,c.y+w*m):null):(e.x-g.x)*z!=(e.y-g.y)*r?null:c.x!=e.x?(B=h(c.x,
e.x),C=d(c.x,e.x),B<=g.x&&g.x<=C?g:B<=f.x&&f.x<=C?f:null):g.x!=f.x?(x=h(g.x,f.x),D=d(g.x,f.x),x<=c.x&&c.x<=D?c:x<=e.x&&e.x<=D?e:null):c.y!=e.y?(B=h(c.y,e.y),C=d(c.y,e.y),B<=g.y&&g.y<=C?g:B<=f.y&&f.y<=C?f:null):g.y!=f.y?(x=h(g.y,f.y),D=d(g.y,f.y),x<=c.y&&c.y<=D?c:x<=e.y&&e.y<=D?e:null):c.x==g.x&&c.y==g.y?c:null};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k,l,e;a.R2Newton=function(c,d){this.evaluator=c;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];k=new a.R2(0,0)};a.R2Newton.prototype.getUnitNormal=function(){this.normal.normalize();return this.normal.copy()};a.R2Newton.prototype.gradient=function(a){d=
this.evaluator;l=d.getVariable("x");e=d.getVariable("y");d.setVariable("x",a.x);d.setVariable("y",a.y);this.f0=d.evalExpression(this.constraint);d.setVariable("x",d.getVariable("x")+1E-12);h=d.evalExpression(this.constraint);k.x=(h-this.f0)/1E-12;k.x=!isNaN(k.x)?k.x:Infinity;d.setVariable("x",d.getVariable("x")-1E-12);d.setVariable("y",d.getVariable("y")+1E-12);h=d.evalExpression(this.constraint);k.y=(h-this.f0)/1E-12;k.y=!isNaN(k.y)?k.y:Infinity;d.setVariable("x",l);d.setVariable("y",e);return k};
a.R2Newton.prototype.findZero=function(a){d=this.evaluator;f=a.copy();l=d.getVariable("x");e=d.getVariable("y");d.setVariable("x",a.x);d.setVariable("y",a.y);this.f0=d.evalExpression(this.constraint);if("menor"===this.sign&&0>=this.f0||"mayor"===this.sign&&0<=this.f0)return f;d.setVariable("x",l);d.setVariable("y",e);for(var k=0;256>k;k++)if(g=f.x,c=f.y,this.normal=this.gradient(f),0!=this.normal.norm2()&&this.normal.mul(-this.f0/this.normal.norm2()),f.x=g+this.normal.x,f.y=c+this.normal.y,1E-6>this.normal.norm()){0===
this.normal.x&&0===this.normal.y&&(this.normal.x=f.x-a.x,this.normal.y=f.y-a.y);break}return f};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Vector2D=function(a,h){this.x=a;this.y=h};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 d=Math.floor,h=Math.round,g,c,f,k,l,e,p,m,n,t,s,u,q,r,w,v,z,B,C,x;a.Control=function(c,d){this.parent=c;this.evaluator=c.evaluator;var e=this.parser=c.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?"text"!==d.type?this.expresion=e.parse("(0,0,100,23)"):
(this.expresion=e.parse("(0,0,300,200)"),this.w=300,this.h=200):this.expresion=e.parse("(0,0)");this.fixed=2!=this.parent.version?!1:!0;this.visible=!0;this.color=4>this.parent.version?new a.Color("000000"):new a.Color("222222");this.colorInt="graphic"!==d.type?new a.Color("f0f8ff"):new a.Color("ff0000");this.underlined=this.italics=this.bold="";this.font_size=4>this.parent.version?-1:e.parse("12");this.parameter=this.action="";this.parameterFont="Monospace 12px";this.drawif=e.parse("1");this.activeif=
e.parse("1");this.tooltip="";this.tooltipFont="Monospace 12px";this.Explanation="";this.ExplanationFont="Monospace 12px";this.cID=this.msg_pos="";this.valueExpr=e.parse("0");this.decimals=e.parse("2");this.min=e.parse("-Infinity");this.max=e.parse("Infinity");this.incr=e.parse("0.1");this.exponentialif=this.discrete=!1;this.zIndex=-1;for(var k in d)d.hasOwnProperty(k)&&(this[k]=d[k]);if(("video"===this.type||"audio"===this.type)&&"interior"!==this.region)this.region="interior";void 0==this.name&&
(this.name=2==this.parent.version?this.id:"_nada_");this.name="_._"==this.name||"_nada_"==this.name||"_void_"==this.name?"":this.name;e=this.evaluator.evalExpression(this.expresion);this.x=h(e[0][0]);this.y=h(e[0][1]);4==e[0].length&&(this.w=h(e[0][2]),this.h=h(e[0][3]));this.actionExec=c.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,
c;if("interior"===this.region)for(var d=0,e=a.length;d<e;d++){if(c=a[d],c.id===this.spaceID)return c.addCtr(this),this.zIndex=c.zIndex,c.numericalControlContainer}else{if("external"===this.region)return this.parent.externalSpace.container;if("scenario"===this.region)return this.cID?(this.expresion=this.evaluator.parser.parse("(0,-1000,"+this.w+","+this.h+")"),this.parent.scenarioRegion.scenarioSpace.addCtr(this),this.zIndex=this.parent.scenarioRegion.scenarioSpace.zIndex,this.parent.scenarioRegion.scenarioSpace.numericalControlContainer):
this.parent.externalSpace.container;if("north"===this.region)return this.parent.northSpace.controls.push(this),this.parent.northSpace.container;if("south"===this.region)return this.parent.southSpace.controls.push(this),this.parent.southSpace.container;if("east"===this.region)return this.parent.eastSpace.controls.push(this),this.parent.eastSpace.container;if("west"===this.region)return this.parent.westSpace.controls.push(this),this.parent.westSpace.container;if("special"===this.region)return this.parent.specialSpace.controls.push(this),
this.parent.specialSpace.container}a[0].addCtr(this);this.zIndex=a[0].zIndex;return a[0].numericalControlContainer};a.Control.prototype.addControlContainer=function(a){var c=this.getContainer();c.childNodes[0]?c.insertBefore(a,c.childNodes[0]):c.appendChild(a);c.childNodes[0]?c.insertBefore(a,c.childNodes[0]):c.appendChild(a)};a.Control.prototype.updatePositionAndSize=function(){f=k=l=e=!1;p=this.evaluator.evalExpression(this.expresion);m=h(p[0][0]);f=h(this.x)!==m;this.x=m;m=h(p[0][1]);k=h(this.y)!==
m;this.y=m;4===p[0].length&&(m=h(p[0][2]),l=h(this.w)!==m,this.w=m,m=h(p[0][3]),e=h(this.h)!==m,this.h=m);if(l||e||f||k)this.init(),this.draw()};a.Control.prototype.formatOutputValue=function(a){q=this.parent;n=a+"";t=this.evaluator.evalExpression(this.decimals);s=n.indexOf(".");-1!=s&&(u=n.substring(s+1),u.length>t&&(n=parseFloat(n).toFixed(t)));if(this.fixed&&(2!==q.version||2===q.version&&!this.exponentialif))n=parseFloat(a).toFixed(t);this.exponentialif&&0!=parseFloat(n)&&(n=this.fixed&&2!==q.version?
parseFloat(n).toExponential(t):parseFloat(n).toExponential(),n=n.toUpperCase(),n=n.replace("+",""));return n=n.replace(".",q.decimal_symbol)};a.Control.prototype.updateAndExecAction=function(){this.parent.updateControls();"init"===this.action&&(this.click=!1);this.actionExec.execute();"animate"!==this.action&&this.parent.update()};a.Control.prototype.createGradient=function(a,e){this.linearGradient=this.ctx.createLinearGradient(0,0,0,e);g=e*e;for(var k=0;k<e;k++)c=d(k-35*e/100),this.linearGradient.addColorStop(k/
e,"rgba(0,0,0,"+192*c*c/g/255+")")};a.Control.prototype.getScreenshot=function(){v=this;r=document.createElement("canvas");r.setAttribute("width",v.w);r.setAttribute("height",v.h);w=r.getContext("2d");w.font=v.fieldFontSize+"px Arial, Helvetica, 'Droid Sans', Sans-serif";v.canvas&&(z=v.canvas.offsetLeft,B=v.canvas.offsetTop,w.drawImage(v.canvas,z,B));v.label&&(z=v.label.offsetLeft,B=v.label.offsetTop,C=v.label.offsetWidth,x=v.label.offsetHeight,w.fillStyle="#e0e4e8",w.fillRect(z,B,C,x),w.fillStyle=
"black",w.textAlign="center",w.textBaseline="middle",w.fillText(v.name,z+C/2,B+x/2));v.field&&(z=v.field.offsetLeft,B=v.field.offsetTop,C=v.field.offsetWidth,x=v.field.offsetHeight,w.fillStyle="white",w.strokeStyle="#666666",w.lineWidth=1,w.fillRect(z,0,C,x),w.strokeRect(z+0.5,0.5,C-1,x-1),w.fillStyle="black",w.textAlign="center",w.textAlign="left",w.fillText(v.field.value,z+2,x/2));v.select&&(z=v.select.offsetLeft,B=v.select.offsetTop,C=v.select.offsetWidth,x=v.select.offsetHeight,w.fillStyle="#e0e4e8",
w.strokeStyle="#666666",w.lineWidth=1,w.fillRect(z,0,C,x),w.strokeRect(z+0.5,0.5,C,x-1),w.fillStyle="black",w.textAlign="center",w.textAlign="left",w.fillText(v.select.value,z+2,x/2),w.fillStyle="#c0c0c0",w.fillRect(z+C-15+0.5,0.5,15,x-1),w.strokeRect(z+C-15+0.5,0.5,15,x-1),w.fillStyle="black",w.beginPath(),w.moveTo(z+C-15+4.5,x/2-2.5),w.lineTo(z+C-15+8,x/2+2.5),w.lineTo(z+C-15+11.5,x/2-2.5),w.closePath(),w.fill());return r};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;
var d=Math.floor,h,g,c,f,k,l,e,p,m,n,t,s,u=900;a.Button=function(c,d){this.imageSrc="";this.image=new Image;this.imageOver=new Image;this.imageDown=new Image;a.Control.call(this,c,d);-1===this.font_size&&(this.fontSizeNotSet=!0);"["===this.name.charAt(0)&&"]"===this.name.charAt(this.name.length-1)?this.name=this.parser.parse(this.name.substring(1,this.name.length-1)):this.name=this.parser.parse("'"+this.name+"'");var e;this.imageSrc.match("_COLORES_")&&(e=this.imageSrc.split("_"),this.colorInt=new a.Color(e[2]),
this.color=new a.Color(e[3]),this.font_size=this.parser.parse(e[5]),this.imageSrc="");this.imageSrc=this.parser.parse("'"+this.imageSrc+"'");e=this.evaluator.evalExpression(this.imageSrc).trim();if(""!=e){var k=e.substr(0,e.lastIndexOf(".")),g=e.substr(e.lastIndexOf("."));e.toLowerCase().match(/vacio.gif$/)?(this.image.ready=1,3===this.parent.version&&(this.name=this.parser.parse("")),this.emptyImage={ready:!0},this.parser.parse("'vacio.gif'")):(this.image=this.parent.getImage(e),this.imageOver=this.parent.getImage(k+
"_over"+g),this.imageDown=this.parent.getImage(k+"_down"+g))}this.canvas=document.createElement("canvas");this.canvas.setAttribute("class","DescartesButton");this.canvas.setAttribute("id",this.id);this.canvas.setAttribute("width",this.w+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.ctx=this.canvas.getContext("2d");this.ctx.imageSmoothingEnabled=!1;this.ctx.mozImageSmoothingEnabled=!1;this.ctx.webkitImageSmoothingEnabled=
!1;this.addControlContainer(this.canvas);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Button,a.Control);a.Button.prototype.init=function(){h=this.evaluator;g=this.canvas;f=h.evalExpression(this.expresion);this.x=f[0][0];this.y=f[0][1];4==f[0].length&&(this.w=parseInt(f[0][2]),this.h=parseInt(f[0][3]));g.setAttribute("width",this.w+"px");g.setAttribute("height",this.h+"px");g.setAttribute("style","left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+"; display: block;");this.fontSizeNotSet&&
(this.font_size=h.parser.parse(a.getFieldFontSize(this.h)+""));this.createGradient(this.w,this.h)};a.Button.prototype.update=function(){h=this.evaluator;g=this.canvas;this.activeIfValue=0<h.evalExpression(this.activeif);(this.drawIfValue=0<h.evalExpression(this.drawif))?(g.style.display="block",this.draw()):(this.click=!1,g.style.display="none");this.updatePositionAndSize()};a.Button.prototype.draw=function(){h=this.evaluator;c=this.ctx;k=h.evalExpression(this.font_size);l=h.evalExpression(this.name);
e=h.evalExpression(this.imageSrc);p="vacio.gif"===e?this.emptyImage:this.parent.getImage(e);c.clearRect(0,0,this.w,this.h);n=m=0;this.click&&(n=m=1);p&&p.ready?p!==this.emptyImage&&p.complete&&c.drawImage(p,parseInt((this.w-p.width)/2)+m,parseInt((this.h-p.height)/2)+n):(c.fillStyle=this.colorInt.getColor(),c.fillRect(0,0,this.w,this.h),this.click||(a.drawLine(c,this.w-1,0,this.w-1,this.h,"rgba(0,0,0,"+128/255+")"),a.drawLine(c,0,0,0,this.h,"rgba(0,0,0,"+24/255+")"),a.drawLine(c,1,0,1,this.h,"rgba(0,0,0,"+
8/255+")")),c.fillStyle=this.linearGradient,c.fillRect(0,0,this.w,this.h));""!=this.imageOver.src&&(this.imageOver.ready&&this.over)&&c.drawImage(this.imageOver,parseInt((this.w-p.width)/2)+m,parseInt((this.h-p.height)/2)+n);""!=this.imageDown.src&&this.imageDown.ready&&this.click?c.drawImage(this.imageDown,parseInt((this.w-p.width)/2)+m,parseInt((this.h-p.height)/2)+n):this.click&&(a.drawLine(c,0,0,0,this.h-2,"gray"),a.drawLine(c,0,0,this.w-1,0,"gray"),c.fillStyle="rgba(0, 0, 0,"+24/255+")",c.fillRect(0,
0,this.w,this.h));c.fillStyle=this.color.getColor();c.font=this.italics+" "+this.bold+" "+k+"px Arial";c.textAlign="center";c.textBaseline="middle";this.colorInt!=this.color&&(c.lineJoin="round",c.lineWidth=parseInt(k/6),c.strokeStyle=this.colorInt.getColor(),c.strokeText(l,d(this.w/2+m)+0.5,d(this.h/2+n)+0.5));c.fillText(l,d(this.w/2+m)+0.5,d(this.h/2+n)+0.5);this.underlined&&(t=c.measureText(l).width,c.strokeStyle=this.color.getColor(),c.lineWidth=d(k/10)||2,c.lineCap="round",c.beginPath(),c.moveTo(parseInt((this.w-
t)/2)+m,d((this.h+k)/2)+d(k/5)-1.5+n),c.lineTo(parseInt((this.w+t)/2)+m,d((this.h+k)/2)+d(k/5)-1.5+n),c.stroke());this.activeIfValue||(c.fillStyle="rgba(240,240,240,"+160/255+")",c.fillRect(0,0,this.w,this.h))};a.Button.prototype.bottonPressed=function(){this.updateAndExecAction()};a.Button.prototype.registerMouseAndTouchEvents=function(){function c(a,d,e){clearInterval(h);f.click&&(d.call(f),a=e?a:30,h=setTimeout(function(){c(a,d)},a))}function d(k){k.preventDefault();f.whichButton=a.whichButton(k);
"L"==f.whichButton&&f.activeIfValue&&(f.click=!0,f.draw(),f.evaluator.setVariable(f.id,f.evaluator.evalExpression(f.valueExpr)),"calculate"==f.action&&c(u,f.bottonPressed,!0),s?window.addEventListener("touchend",e):window.addEventListener("mouseup",e))}function e(a){if(f.activeIfValue||f.click)f.click=!1,f.draw(),"calculate"!=f.action&&f.bottonPressed(),a.preventDefault(),s?window.removeEventListener("touchend",e,!1):window.removeEventListener("mouseup",e,!1)}function k(a){f.over=!0;f.draw()}function g(a){f.over=
!1;f.click=!1;f.draw()}s=a.hasTouchSupport;var f=this,h;f.canvas.oncontextmenu=function(){return!1};this.over=this.click=!1;s?this.canvas.addEventListener("touchstart",d):(this.canvas.addEventListener("mousedown",d),this.canvas.addEventListener("mouseover",k),this.canvas.addEventListener("mouseout",g))};a.Button.prototype.getScreenshot=function(){return this.canvas};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k,l,e,p,m,n,t,s,u,q,r,w;a.Spinner=function(c,
d){a.Control.call(this,c,d);this.tabindex=++this.parent.tabindex;this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);""!=this.name.trim()&&this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);
this.containerControl.appendChild(this.canvas);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.addControlContainer(this.containerControl);this.originalIncr=this.incr;if(0>=this.evaluator.evalExpression(this.decimals)){var e=this.evaluator.evalExpression(this.incr);0<e?this.originalIncr=this.incr=this.evaluator.parser.parse(parseInt(e).toString()):this.incr=this.evaluator.parser.parse("1")}this.registerMouseAndTouchEvents();this.init()};a.extend(a.Spinner,
a.Control);a.Spinner.prototype.init=function(){d=this.evaluator;this.value=this.validateValue(d.evalExpression(this.valueExpr));var c=this.formatOutputValue(this.value);this.fieldFontSize=2!==this.parent.version?a.getFieldFontSize(this.h):10;var e=2!==this.parent.version?"":"_____",k=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),g=2+parseInt(this.h/2),f=parseInt(this.w/2-g/2),e=a.getTextWidth(this.name+e,this.fieldFontSize+"px Arial");this.visible||(f=this.w-g,k=0);f<e&&(f=e);""==this.name&&
(f=0);this.w-f-g<k&&(f=this.w-g-k);0>f&&(f=0);e=this.w-(f+g);this.containerControl.setAttribute("class","DescartesSpinnerContainer");this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.canvas.setAttribute("width",g+"px");this.canvas.setAttribute("height",this.h+"px");this.canvas.setAttribute("style","position: absolute; left: "+f+"px; top: 0px;");this.ctx=this.canvas.getContext("2d");this.divUp.setAttribute("style",
"background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+g+"px; height : "+this.h/2+"px; left: "+f+"px; top: 0px;");this.divDown.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+g+"px; height : "+this.h/2+"px; left: "+f+"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 : "+(e-2)+"px; height : "+(this.h-2)+"px; left: "+(g+f)+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.label.setAttribute("class","DescartesSpinnerLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+f+"px; height: "+this.h+"px; line-height: "+this.h+"px;");d.setVariable(this.id,this.value);this.createGradient(this.h/2,this.h);this.update()};a.Spinner.prototype.update=
function(){d=this.evaluator;0>=d.evalExpression(this.decimals)?(h=d.evalExpression(this.incr),0<h?this.originalIncr=this.incr=d.parser.parse(parseInt(h).toString()):this.incr=d.parser.parse("1")):this.incr=this.originalIncr;this.activeIfValue=0<d.evalExpression(this.activeif);this.drawIfValue=0<d.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();
g=this.field.value;c=this.value;this.value=this.validateValue(d.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value==c&&this.field.value!=g&&(this.value=this.validateValue(g),this.field.value=this.formatOutputValue(this.value));d.setVariable(this.id,this.value)};a.Spinner.prototype.draw=function(){f=this.ctx;k=this.canvas.width;l=this.canvas.height;f.fillStyle="#f0f8ff";f.fillRect(0,0,k,l);f.fillStyle=this.linearGradient;f.fillRect(0,0,k,l);this.up?(e="gray",p="#f0f8ff"):
(e="#f0f8ff",p="gray");a.drawLine(f,0,0,k,0,e);a.drawLine(f,0,0,0,l/2,e);a.drawLine(f,0,l/2,k,l/2,p);this.down?(e="gray",p="#f0f8ff"):(e="#f0f8ff",p="gray");a.drawLine(f,0,l/2+1,k,l/2+1,e);a.drawLine(f,0,l/2+1,0,l,e);a.drawLine(f,0,l-1,k,l-1,p);m=[parseInt(k/2+1),parseInt(k/5+1),parseInt(k-k/5+1)];n=[parseInt(l/8+1),parseInt(l/8+1+l/4),parseInt(l/8+1+l/4)];f.fillStyle=this.activeIfValue?"#2244cc":"#8888aa";f.beginPath();f.moveTo(m[0],n[0]);f.lineTo(m[1],n[1]);f.lineTo(m[2],n[2]);f.fill();n=[parseInt(l-
l/8),parseInt(l-l/8-l/4),parseInt(l-l/8-l/4)];f.fillStyle=this.activeIfValue?"#d00018":"#aa8888";f.beginPath();f.moveTo(m[0],n[0]);f.lineTo(m[1],n[1]);f.lineTo(m[2],n[2]);f.fill();f.fillStyle="rgba(0,0,0,"+24/255+")";this.up&&f.fillRect(0,0,k,l/2);this.down&&f.fillRect(0,l/2,k,l)};a.Spinner.prototype.validateValue=function(a){d=this.evaluator;a=isNaN(parseFloat(a))?a.toString():parseFloat(a).toFixed(20);t=parseFloat(d.evalExpression(d.parser.parse(a.replace(this.parent.decimal_symbol,"."))));isNaN(t)&&
(t=0);q=d.evalExpression(this.min);""==q&&(q=-Math.Infinity);r=d.evalExpression(this.max);""==r&&(r=Math.Infinity);t<q&&(t=q);t>r&&(t=r);this.discrete&&(s=d.evalExpression(this.incr),t=0==s?0:s*Math.round(t/s));u=d.evalExpression(this.decimals);0>=u&&(u=0);return t=parseFloat(parseFloat(t).toFixed(u))};a.Spinner.prototype.increase=function(){this.changeValue(parseFloat(this.value)+this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.decrease=function(){this.changeValue(parseFloat(this.value)-
this.evaluator.evalExpression(this.incr))};a.Spinner.prototype.changeValue=function(a){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=this.formatOutputValue(this.value),this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction())};a.Spinner.prototype.registerMouseAndTouchEvents=function(){function c(a,d,e){clearInterval(n);if(l.up||l.down)d.call(l),a=e?a:30,n=setTimeout(function(){c(a,d)},a)}function d(e){e.preventDefault();l.whichButton=a.whichButton(e);"L"==
l.whichButton&&l.activeIfValue&&(l.up=!0,c(m,l.increase,!0),l.draw())}function e(d){d.preventDefault();l.whichButton=a.whichButton(d);"L"==l.whichButton&&l.activeIfValue&&(l.down=!0,c(m,l.decrease,!0),l.draw())}function k(a){l.up=!1;clearInterval(n);l.draw();a.preventDefault()}function g(a){l.down=!1;clearInterval(n);l.draw();a.preventDefault()}function f(a){l.up=!1;clearInterval(n);l.draw();a.preventDefault()}function h(a){l.down=!1;clearInterval(n);l.draw();a.preventDefault()}w=a.hasTouchSupport;
var l=this,m=w?500:200,n;l.divUp.oncontextmenu=l.divDown.oncontextmenu=l.field.oncontextmenu=l.label.oncontextmenu=function(){return!1};w?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&&l.changeValue(l.field.value)});w?this.divUp.addEventListener("touchstart",d):this.divUp.addEventListener("mousedown",d);w?this.divDown.addEventListener("touchstart",
e):this.divDown.addEventListener("mousedown",e);w||this.divUp.addEventListener("mouseout",k);w||this.divDown.addEventListener("mouseout",g);w?(this.divUp.addEventListener("touchend",f),window.addEventListener("touchend",f)):(this.divUp.addEventListener("mouseup",f),window.addEventListener("mouseup",f));w?(this.divDown.addEventListener("touchend",h),window.addEventListener("touchend",h)):(this.divDown.addEventListener("mouseup",h),window.addEventListener("mouseup",h))};return a}(descartesJS||{}),descartesJS=
function(a){if(a.loadLib)return a;var d,h,g,c,f,k,l;a.TextField=function(c,d){a.Control.call(this,c,d);void 0===this.valueExprString&&(this.valueExprString="");this.emptyString=!1;this.ok=0;this.tabindex=++this.parent.tabindex;if(this.answer)if(this.answer.match("krypto_")&&(this.answer=(new a.Krypto).decode(this.answer.substring(7))),this.answerPattern=this.answer,this.answer=a.buildRegularExpresionsPatterns(this.answer,this.evaluator),this.onlyText){var k=this.answerPattern.indexOf("|");this.firstAnswer=
-1==k?this.answerPattern:this.answerPattern.substring(0,k)}else this.firstAnswer=this.parser.parse(this.answerPattern.substring(1,this.answerPattern.indexOf(",")));if(this.onlyText){if(!this.valueExprString.match(/^'/)||!this.valueExprString.match(/^'/))this.valueExpr=this.evaluator.parser.parse("'"+this.valueExprString+"'");this.validateValue=function(a){return"''"==a||"'"==a?"":a};this.formatOutputValue=function(a){return a.toString()}}""==this.name.trim()&&(this.name="");this.containerControl=
document.createElement("div");this.field=document.createElement("input");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextField,a.Control);a.TextField.prototype.init=function(){d=this.evaluator;this.value=this.validateValue(d.evalExpression(this.valueExpr));
var c=this.formatOutputValue(this.value);this.fieldFontSize=a.getFieldFontSize(this.h);var k=a.getTextWidth(c+"_",this.fieldFontSize+"px Arial"),g=parseInt(this.w/2),f=a.getTextWidth(this.name,this.fieldFontSize+"px Arial");g<f&&(g=f);""==this.name&&(g=0);this.w-g<k&&(g=this.w-k);0>g&&(g=0);k=this.w-g;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 : "+(k-2)+"px; height : "+(this.h-2)+"px; left: "+g+"px;");this.field.setAttribute("tabindex",this.tabindex);this.field.value=c;this.label.setAttribute("class","DescartesTextFieldLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+
g+"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(){d=this.evaluator;this.activeIfValue=0<d.evalExpression(this.activeif);this.drawIfValue=0<d.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.containerControl.style.display=this.drawIfValue?"block":
"none";this.updatePositionAndSize();h=this.field.value;g=this.value;this.value=this.validateValue(d.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);this.value===g&&this.field.value!=h&&(this.value=this.validateValue(h),this.field.value=this.formatOutputValue(this.value));d.setVariable(this.id,this.value)};a.TextField.prototype.validateValue=function(a){if(""===a||"''"==a)return"";d=this.evaluator;c=parseFloat(d.evalExpression(d.parser.parse(a.toString().replace(this.parent.decimal_symbol,
"."))));isNaN(c)&&(c=0);f=d.evalExpression(this.min);""==f&&(f=-Math.Infinity);k=d.evalExpression(this.max);""==k&&(k=Math.Infinity);this.discrete&&(a=d.evalExpression(this.incr),c=0==a?0:a*Math.round(c/a));return c=parseFloat(parseFloat(c).toFixed(d.evalExpression(this.decimals)))};a.TextField.prototype.formatOutputValue=function(a){return""===a?"":this.uber.formatOutputValue.call(this,a)};a.TextField.prototype.changeValue=function(a,c){this.activeIfValue&&(this.value=this.validateValue(a),this.field.value=
this.formatOutputValue(this.value),this.evaluate&&(this.ok=this.evaluateAnswer()),this.evaluator.setVariable(this.id,this.value),this.evaluator.setVariable(this.id+".ok",this.ok),this.updateAndExecAction())};a.TextField.prototype.evaluateAnswer=function(){return a.esCorrecto(this.answer,this.value,this.evaluator,this.answer)};a.TextField.prototype.getFirstAnswer=function(){return this.answer?this.onlyText?this.firstAnswer:this.evaluator.evalExpression(this.firstAnswer):""};a.TextField.prototype.registerMouseAndTouchEvents=
function(){l=a.hasTouchSupport;var c=this;c.label.oncontextmenu=function(){return!1};l?c.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):c.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.field.addEventListener("blur",function(a){c.update()});this.field.addEventListener("keydown",function(a){c.activeIfValue&&13==a.keyCode&&c.changeValue(c.field.value,!0)})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=
Math.abs,h,g,c,f;a.Menu=function(c,d){this.options="";a.Control.call(this,c,d);var k=this.parser;this.options=this.options.split(",");this.menuOptions=[];this.strValue=[];for(var g,f=0,h=this.options.length;f<h;f++)g=this.options[f].split(/[\[\]]/,2),1==g.length?(this.menuOptions.push(g[0]),this.strValue.push(f.toString())):2==g.length&&(this.menuOptions.push(g[0]),""==g[1]?this.strValue.push(f.toString()):this.strValue.push(g[1]));f=0;for(h=this.strValue.length;f<h;f++)this.strValue[f]=k.parse(this.strValue[f]);
this.containerControl=document.createElement("div");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.select=document.createElement("select");f=0;for(h=this.menuOptions.length;f<h;f++)k=document.createElement("option"),k.innerHTML=this.menuOptions[f],this.select.appendChild(k);this.field=document.createElement("input");this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.select);this.visible&&
this.containerControl.appendChild(this.field);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Menu,a.Control);var k;a.Menu.prototype.init=function(){k=this.evaluator;this.fieldFontSize=2!=this.parent.version?a.getFieldFontSize(this.h):10;var c=0,d=0,g=0;this.value=k.evalExpression(this.valueExpr);this.indexValue=this.getIndex(this.value);for(var f=0,h=this.menuOptions.length;f<h;f++)g=a.getTextWidth(this.menuOptions[f],this.fieldFontSize+
"px Arial"),g>c&&(c=g,d=f);c+=25;g=a.getTextWidth(this.formatOutputValue(k.evalExpression(this.strValue[d])),this.fieldFontSize+"px Arial")+7;d=a.getTextWidth(this.name,this.fieldFontSize+"px Arial")+10;""==this.name&&(d=0);this.visible||(g=0);for(f=this.w-g-d;f<c&&0<d;)d--,f++;for(;f<c&&0<g;)g--,f++;for(;d+f+g+1<this.w;)f++,g++;var c=d,h=c+f,g=this.w-h,t=this.formatOutputValue(k.evalExpression(this.strValue[this.indexValue]));this.containerControl.setAttribute("class","DescartesSpinnerContainer");
this.containerControl.setAttribute("style","width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.label.setAttribute("class","DescartesMenuLabel");this.label.setAttribute("style","font-size:"+this.fieldFontSize+"px; width: "+d+"px; height: "+this.h+"px; line-height: "+this.h+"px;");this.field.setAttribute("type","text");this.field.setAttribute("id",this.id+"menu");this.field.value=t;this.field.setAttribute("class","DescartesMenuField");
this.field.setAttribute("style","font-size: "+this.fieldFontSize+"px; width : "+(g-2)+"px; height : "+(this.h-2)+"px; left: "+h+"px;");this.select.setAttribute("id",this.id+"menuSelect");this.select.setAttribute("class","DescartesMenuSelect");this.select.setAttribute("style","text-align: left; font-size: "+this.fieldFontSize+"px; width : "+f+"px; height : "+this.h+"px; left: "+c+"px; border-color: #7a8a99; border-width: 1.5px; border-style: solid; background-color: #eeeeee;");this.select.selectedIndex=
this.indexValue;k.setVariable(this.id,parseFloat(t));this.update()};a.Menu.prototype.update=function(){k=this.evaluator;this.activeIfValue=0<k.evalExpression(this.activeif);this.drawIfValue=0<k.evalExpression(this.drawif);this.field.disabled=this.activeIfValue?!1:!0;this.select.disabled=this.activeIfValue?!1:!0;this.drawIfValue?this.containerControl.style.display="block":(this.click=!1,this.containerControl.style.display="none");this.updatePositionAndSize();this.value=k.getVariable(this.id);this.field.value=
this.formatOutputValue(this.value);k.setVariable(this.id,parseFloat(this.value));this.select.selectedIndex=parseFloat(this.getIndex(this.value))};a.Menu.prototype.getIndex=function(a){a=parseFloat(a.toString().replace(this.parent.decimal_symbol,"."));h=-1;g=Infinity;for(var e=0,k=this.strValue.length;e<k;e++)c=d(a-parseFloat(this.evaluator.evalExpression(this.strValue[e]))),c<=g&&(g=c,h=e);return h};a.Menu.prototype.changeValue=function(){this.activeIfValue&&(this.evaluator.setVariable(this.id,this.value),
this.updateAndExecAction())};a.Menu.prototype.registerMouseAndTouchEvents=function(){f=a.hasTouchSupport;var c=this;c.select.oncontextmenu=c.label.oncontextmenu=c.field.oncontextmenu=function(){return!1};f?c.label.addEventListener("touchstart",function(a){a.preventDefault();return!1}):c.label.addEventListener("mousedown",function(a){a.preventDefault();return!1});this.select.addEventListener("change",function(a){c.value=c.evaluator.evalExpression(c.strValue[this.selectedIndex]);c.field.value=c.formatOutputValue(c.value);
c.evaluator.setVariable(c.id,c.field.value);c.changeValue();a.preventDefault()});this.field.addEventListener("keydown",function(a){13==a.keyCode&&(c.indexValue=c.getIndex(c.field.value),c.value=c.evaluator.evalExpression(c.strValue[c.indexValue]),c.field.value=c.formatOutputValue(c.indexValue),c.select.selectedIndex=c.indexValue,c.changeValue())})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor,h="h",g,c,f,k,l,e,p,m,n,t,s,u,q,r,w,v,z,B,C,x,D;a.Scrollbar=
function(c,d){a.Control.call(this,c,d);this.orientation=this.w>=this.h?h:"v";this.containerControl=document.createElement("div");this.canvas=document.createElement("canvas");this.divUp=document.createElement("div");this.divDown=document.createElement("div");this.field=document.createElement("input");this.scrollManipulator=document.createElement("div");this.label=document.createElement("label");this.txtLabel=document.createTextNode(this.name);this.label.appendChild(this.txtLabel);this.containerControl.appendChild(this.canvas);
this.containerControl.appendChild(this.label);this.containerControl.appendChild(this.divUp);this.containerControl.appendChild(this.divDown);this.containerControl.appendChild(this.field);this.containerControl.appendChild(this.scrollManipulator);this.addControlContainer(this.containerControl);this.registerMouseAndTouchEvents();this.init()};a.extend(a.Scrollbar,a.Control);a.Scrollbar.prototype.init=function(){g=this.evaluator;this.findOffset();0==g.evalExpression(this.decimals)?this.incr=1:this.incr=
(g.evalExpression(this.max)-g.evalExpression(this.min))/100;this.value=this.validateValue(g.evalExpression(this.valueExpr));f=this.formatOutputValue(this.value);k=this.evaluator.evalExpression(this.expresion);this.x=k[0][0];this.y=k[0][1];4==k[0].length&&(this.w=k[0][2],this.h=k[0][3]);this.orientation=this.w>=this.h?h:"v";this.initScroll(f);this.changeScrollPositionFromValue();this.prePos=this.pos;g.setVariable(this.id,this.value)};a.Scrollbar.prototype.initScroll=function(d){c=this;g=c.evaluator;
var e="v"===c.orientation?parseInt(19+5*(c.h-100)/100):c.h;c.fieldFontSize="v"===c.orientation?e-parseInt(c.h/20)-1:2!==c.parent.version?a.getFieldFontSize(e):10;var k=a.getTextWidth(d+"_",c.fieldFontSize+"px Arial"),f=c.parent.getSpaceById(c.spaceID).h;c.labelHeight=""==c.name?0:e;c.fieldHeight=""==c.visible?0:e;if("v"===c.orientation)c.canvasWidth=c.w,c.canvasHeight=c.h-c.labelHeight-c.fieldHeight,18<=c.canvasHeight+c.y-f&&(c.canvasHeight=f),k=0,k=c.fieldHeight,e=k+c.canvasHeight,c.canvasX=0,c.canvasY=
c.fieldHeight,c.labelWidth=c.w,c.labelY=e,c.upWidth=c.downW=c.w,c.upHeight=c.downH=15,c.upX=0,c.upY=c.fieldHeight,c.downX=0,c.downY=e-c.downH,c.fieldWidth=c.w,c.fieldX=0,c.scrollManipulatorW=c.w,c.scrollManipulatorH=parseInt((c.canvasHeight-c.upHeight-c.downH-c.labelHeight-c.fieldHeight)/10),c.scrollManipulatorH=15>c.scrollManipulatorH?15:c.scrollManipulatorH,c.scrollManipulatorLimInf=e-c.downH-c.scrollManipulatorH,c.scrollManipulatorLimSup=k+c.downH;else{e=a.getTextWidth(c.name,c.fieldFontSize+"px Arial")+
10;c.labelWidth=e;c.fieldWidth=k;""==c.name&&(c.labelWidth=0);c.visible||(c.fieldWidth=0);for(e=c.w-c.fieldWidth-c.labelWidth;58>e&&0<c.labelWidth;)c.labelWidth--,e++;for(;58>e&&0<c.fieldWidth;)c.fieldWidth--,e++;k=c.labelWidth;f=k+e;c.fieldWidth=c.w-f;c.canvasWidth=e;c.canvasHeight=c.h;c.canvasX=c.labelWidth;c.canvasY=0;c.fieldX=c.canvasWidth+c.labelWidth;c.labelHeight=c.h;c.labelY=0;c.upWidth=c.downW=15;c.upHeight=c.downH=c.h;c.upX=f-c.downW;c.upY=0;c.downX=c.labelWidth;c.downY=0;c.scrollManipulatorW=
parseInt((c.canvasWidth-c.upWidth-c.downW)/10);c.scrollManipulatorW=15>c.scrollManipulatorW?15:c.scrollManipulatorW;c.scrollManipulatorH=c.h;c.scrollManipulatorLimInf=k+c.downW;c.scrollManipulatorLimSup=k+c.canvasWidth-c.downW-c.scrollManipulatorW}c.containerControl.setAttribute("class","DescartesScrollbarContainer");c.containerControl.setAttribute("style","width: "+c.w+"px; height: "+c.h+"px; left: "+c.x+"px; top: "+c.y+"px; z-index: "+c.zIndex+";");c.canvas.setAttribute("width",c.w+"px");c.canvas.setAttribute("height",
c.h+"px");c.canvas.setAttribute("style","position: absolute; left: 0px; top: 0px;");c.ctx=c.canvas.getContext("2d");c.divUp.setAttribute("class","DescartesCatcher");c.divUp.setAttribute("style","width : "+c.upWidth+"px; height : "+c.upHeight+"px; left: "+c.upX+"px; top: "+c.upY+"px;");c.divDown.setAttribute("class","DescartesCatcher");c.divDown.setAttribute("style","width : "+c.downW+"px; height : "+c.downH+"px; left: "+c.downX+"px; top: "+c.downY+"px;");c.scrollManipulator.setAttribute("class","DescartesCatcher");
c.scrollManipulator.setAttribute("style","width : "+c.scrollManipulatorW+"px; height : "+c.scrollManipulatorH+"px;");c.scrollManipulator.style.top=("v"===c.orientation?c.scrollManipulatorLimInf:0)+"px";c.scrollManipulator.style.left=("v"===c.orientation?0:c.scrollManipulatorLimInf)+"px";c.field.setAttribute("type","text");c.field.setAttribute("id",c.id+"scrollbar");c.field.setAttribute("class","DescartesScrollbarField");c.field.setAttribute("style","font-size: "+c.fieldFontSize+"px; width : "+(c.fieldWidth-
2)+"px; height : "+(c.fieldHeight-2)+"px; left: "+c.fieldX+"px; top: 0px;");c.field.value=d;0===c.fieldHeight&&(c.field.style.display="none");c.label.setAttribute("class","DescartesScrollbarLabel");c.label.setAttribute("style","font-size:"+c.fieldFontSize+"px; width: "+c.labelWidth+"px; height: "+c.labelHeight+"px; line-height: "+c.labelHeight+"px; left: 0px; top:"+c.labelY+"px;");c.txtLabel=document.createTextNode(c.name);this.update()};a.Scrollbar.prototype.update=function(){g=this.evaluator;0==
g.evalExpression(this.decimals)?this.incr=1:this.incr=(g.evalExpression(this.max)-g.evalExpression(this.min))/100;this.activeIfValue=0<g.evalExpression(this.activeif);this.drawIfValue=0<g.evalExpression(this.drawif);this.field.disabled=!this.activeIfValue;this.drawIfValue?(this.containerControl.style.display="block",this.draw()):this.containerControl.style.display="none";this.updatePositionAndSize();this.value=this.validateValue(g.getVariable(this.id));this.field.value=this.formatOutputValue(this.value);
g.setVariable(this.id,this.value)};a.Scrollbar.prototype.draw=function(){c=this;l=c.ctx;p=d(this.w);e=d(this.h);l.fillStyle="#e0e4e8";l.fillRect(0,0,p,e);l.strokeStyle="#7a8a99";c.down&&(l.fillStyle="#ccdcec",l.fillRect(c.downX+0.5,c.downY+0.5,c.downW,c.downH-1));l.strokeRect(c.downX+0.5,c.downY+0.5,c.downW,c.downH-1);c.up&&(l.fillStyle="#ccdcec",l.fillRect(c.upX+0.5,c.upY-0.5,c.upWidth,c.upHeight+1));l.strokeRect(c.upX+0.5,c.upY-0.5,c.upWidth,c.upHeight+1);m=4;l.fillStyle="black";l.beginPath();c.orientation===
h?(l.moveTo(c.downX+m,c.downH/2),l.lineTo(c.downX+c.downW-m,m),l.lineTo(c.downX+c.downW-m,c.downH-m),l.moveTo(c.upX+c.upWidth-m,c.downH/2),l.lineTo(c.upX+m,m),l.lineTo(c.upX+m,c.downH-m),l.fill(),c.activeIfValue&&(n=d(c.pos),l.fillStyle="#ccdcec",l.fillRect(n+0.5,0,d(c.scrollManipulatorW),e),l.strokeStyle="#6382bf",l.strokeRect(n+0.5,0,d(c.scrollManipulatorW),e),t=d(c.scrollManipulatorW/2),l.beginPath(),l.moveTo(n+t+0.5-2,3),l.lineTo(n+t+0.5-2,e-3),l.moveTo(n+t+0.5,3),l.lineTo(n+t+0.5,e-3),l.moveTo(n+
t+0.5+2,3),l.lineTo(n+t+0.5+2,e-3),l.stroke())):(l.moveTo(c.downX+c.downW/2,c.downY+c.downH-m),l.lineTo(c.downX+m,c.downY+m),l.lineTo(c.downX+c.downW-m,c.downY+m),l.moveTo(c.upX+c.upWidth/2,c.upY+m),l.lineTo(c.upX+m,c.upY+c.upHeight-m),l.lineTo(c.upX+c.upWidth-m,c.upY+c.upHeight-m),l.fill(),c.activeIfValue&&(n=d(c.pos),l.fillStyle="#ccdcec",l.fillRect(0,n+0.5,p,d(c.scrollManipulatorH)),l.strokeStyle="#6382bf",l.strokeRect(0,n+0.5,p,d(c.scrollManipulatorH)),t=d(c.scrollManipulatorH/2),l.beginPath(),
l.moveTo(3,n+t+0.5-2),l.lineTo(p-3,n+t+0.5-2),l.moveTo(3,n+t+0.5),l.lineTo(p-3,n+t+0.5),l.moveTo(3,n+t+0.5+2),l.lineTo(p-3,n+t+0.5+2),l.stroke()));l.strokeRect(0.5,0.5,p-1,e-1);c.activeIfValue||(l.fillStyle="rgba(240,240,240,"+160/255+")",l.fillRect(0,0,p,e.h))};a.Scrollbar.prototype.validateValue=function(a){g=this.evaluator;s=(a||1E45).toString();s=parseFloat(s.replace(this.parent.decimal_symbol,"."));isNaN(s)&&(s=0);this.minimo=g.evalExpression(this.min);s<this.minimo&&(this.value=null,s=this.minimo);
this.maximo=g.evalExpression(this.max);s>this.maximo&&(this.value=null,s=this.maximo);u=this.incr;s=0!=u?s*u/u:0;this.fixed&&(s=parseFloat(parseFloat(s).toFixed(g.evalExpression(this.decimals))));return s};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(){m=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/
10;this.orientation==h?this.clickPos.x>this.prePos&&this.changeValue(parseFloat(this.value)+m):this.clickPos.y<this.prePos&&this.changeValue(parseFloat(this.value)+m)};a.Scrollbar.prototype.decrease10=function(){m=(this.evaluator.evalExpression(this.max)-this.evaluator.evalExpression(this.min))/10;this.orientation==h?this.clickPos.x<this.prePos&&this.changeValue(parseFloat(this.value)-m):this.clickPos.y>this.prePos&&this.changeValue(parseFloat(this.value)-m)};a.Scrollbar.prototype.changeValue=function(a){this.activeIfValue&&
(q=this.validateValue(a),q!=this.value&&(this.value=q,this.field.value=this.formatOutputValue(q),this.changeScrollPositionFromValue(),this.prePos=this.pos,this.evaluator.setVariable(this.id,this.value),this.updateAndExecAction()))};a.Scrollbar.prototype.changeValueForScrollMovement=function(){g=this.evaluator;r=this.scrollManipulatorLimInf;w=this.scrollManipulatorLimSup;v=g.evalExpression(this.min);z=g.evalExpression(this.max);u=this.incr;q=d((this.pos-r)*(z-v)/(w-r)/u)*u+v;q!=this.value&&(this.value=
q,this.field.value=this.formatOutputValue(q),g.setVariable(this.id,this.value),this.parent.updateControls(),this.actionExec.execute(),this.parent.update())};a.Scrollbar.prototype.changeScrollPositionFromValue=function(){g=this.evaluator;r=this.scrollManipulatorLimInf;w=this.scrollManipulatorLimSup;v=g.evalExpression(this.min);z=g.evalExpression(this.max);u=this.incr;this.pos=(this.value-v)*(w-r)/(z-v)+r;this.orientation==h?this.scrollManipulator.style.left=this.pos+"px":this.scrollManipulator.style.top=
this.pos+"px"};a.Scrollbar.prototype.registerMouseAndTouchEvents=function(){function c(a,d,e,k){clearInterval(z);if((r.up||r.down||r.canvasClick)&&1E-7<Math.abs(r.value-k))d.call(r),a=e?a:30,z=setTimeout(function(){c(a,d,!1,k)},a)}function d(e){e.preventDefault();r.whichButton=a.whichButton(e);"L"==r.whichButton&&r.activeIfValue&&(r.clickPos=r.getCursorPosition(e),r.canvasClick=!0,r.orientation==h?r.clickPos.x<r.prePos?c(v,r.decrease10,!0,r.minimo):c(v,r.increase10,!0,r.maximo):r.clickPos.y<r.prePos?
c(v,r.increase10,!0,r.maximo):c(v,r.decrease10,!0,r.minimo))}function e(a){r.canvasClick=!1;clearInterval(z);a.preventDefault()}function k(a){!0==r.canvasClick&&(r.clickPos=r.getCursorPosition(a),a.preventDefault())}function g(a){r.activeIfValue&&(r.scrollClick=!0,r.initPos=r.getCursorPosition(a),window.addEventListener("mouseup",l),window.addEventListener("mousemove",n),a.preventDefault())}function f(a){r.activeIfValue&&(r.scrollClick=!0,r.initPos=r.getCursorPosition(a),window.addEventListener("touchend",
m),window.addEventListener("touchmove",onToucheMove_scrollManipulator),a.preventDefault())}function l(a){r.scrollClick=!1;r.prePos=r.pos;window.removeEventListener("mouseup",l,!1);window.removeEventListener("mousemove",n,!1);a.preventDefault()}function m(a){r.scrollClick=!1;r.prePos=r.pos;window.removeEventListener("touchend",m,!1);window.removeEventListener("touchmove",n,!1);a.preventDefault()}function n(a){var c=r.getCursorPosition(a);r.orientation==h?(r.pos=r.prePos-(r.initPos.x-c.x),r.pos<r.scrollManipulatorLimInf&&
(r.pos=r.scrollManipulatorLimInf),r.pos>r.scrollManipulatorLimSup&&(r.pos=r.scrollManipulatorLimSup),r.scrollManipulator.setAttribute("style","background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+r.scrollManipulatorW+"px; height : "+r.h+"px; left: "+r.pos+"px; top: 0px;")):(r.pos=r.prePos-(r.initPos.y-c.y),r.pos>r.scrollManipulatorLimInf&&(r.pos=r.scrollManipulatorLimInf),r.pos<r.scrollManipulatorLimSup&&(r.pos=r.scrollManipulatorLimSup),r.scrollManipulator.setAttribute("style",
"background-color: rgba(255, 255, 255, 0); cursor: pointer; position: absolute; width : "+r.w+"px; height : "+r.scrollManipulatorH+"px; left: 0px; top: "+r.pos+"px;"));r.changeValueForScrollMovement();a.preventDefault()}function p(d){d.preventDefault();r.whichButton=a.whichButton(d);"L"==r.whichButton&&r.activeIfValue&&(r.up=!0,c(v,r.increase,!0,r.maximo))}function s(d){d.preventDefault();r.whichButton=a.whichButton(d);"L"==r.whichButton&&r.activeIfValue&&(r.down=!0,c(v,r.decrease,!0,r.minimo))}function q(a){r.up=
!1;clearInterval(z);a.preventDefault()}function t(a){r.down=!1;clearInterval(z);a.preventDefault()}function w(a){r.up=!1;clearInterval(z);a.preventDefault();r.draw()}function u(a){r.down=!1;clearInterval(z);a.preventDefault();r.draw()}B=a.hasTouchSupport;var r=this,v=B?500:200,z;r.canvas.oncontextmenu=r.divUp.oncontextmenu=r.divDown.oncontextmenu=r.label.oncontextmenu=r.field.oncontextmenu=r.scrollManipulator.oncontextmenu=function(){return!1};this.field.addEventListener("keydown",function(a){13==
a.keyCode&&r.changeValue(r.field.value)});B?this.canvas.addEventListener("touchstart",d):this.canvas.addEventListener("mousedown",d);B||this.divDown.addEventListener("mouseout",t);B?window.addEventListener("touchend",e):window.addEventListener("mouseup",e);B?this.canvas.addEventListener("touchmove",k):this.canvas.addEventListener("mousemove",k);B?this.scrollManipulator.addEventListener("touchstart",f):this.scrollManipulator.addEventListener("mousedown",g);B?this.divUp.addEventListener("touchstart",
p):this.divUp.addEventListener("mousedown",p);B?this.divDown.addEventListener("touchstart",s):this.divDown.addEventListener("mousedown",s);B||this.divUp.addEventListener("mouseout",q);B||this.divDown.addEventListener("mouseout",t);B?window.addEventListener("touchend",w):window.addEventListener("mouseup",w);B?window.addEventListener("touchend",u):window.addEventListener("mouseup",u)};a.Scrollbar.prototype.findOffset=function(){C=this.containerControl;this.offsetTop=this.offsetLeft=0;x=this.containerControl.style.display;
for(this.containerControl.style.display="block";C;)this.offsetLeft+=C.offsetLeft||0,this.offsetTop+=C.offsetTop||0,C=C.parentNode;this.containerControl.style.display=x};a.Scrollbar.prototype.getCursorPosition=function(c){D=a.getCursorPosition(c);return{x:D.x-this.offsetLeft,y:D.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.Audio=function(d,g){this.controls=!0;this.file="";a.Control.call(this,d,g);var c=this.evaluator.evalExpression(this.expresion);
4==c[0].length?(this.w=c[0][2],this.h=c[0][3]):(this.w=100,this.h=28);this.audio=this.parent.getAudio(this.file);this.autoplay&&(this.audio.setAttribute("autoplay","autoplay"),this.audio.play());this.loop&&this.audio.setAttribute("loop","loop");this.controls&&this.audio.setAttribute("controls","controls");this.audio.setAttribute("style","position: absolute; width: "+this.w+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.addControlContainer(this.audio)};a.extend(a.Audio,
a.Control);a.Audio.prototype.init=function(){this.audio.style.left=this.x+"px";this.audio.style.top=this.y+"px";this.update()};a.Audio.prototype.update=function(){d=this.evaluator;0<d.evalExpression(this.drawif)?this.audio.style.display="block":(this.audio.style.display="none",this.audio.pause());this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.Video=function(d,g){this.controls=!0;this.file="";a.Control.call(this,d,g);var c=this.evaluator.evalExpression(this.expresion);
4==c[0].length?(this.w=c[0][2],this.h=c[0][3]):this.h=this.w=null;this.video=document.createElement("video");this.autoplay&&this.video.setAttribute("autoplay","autoplay");this.loop&&this.video.setAttribute("loop","loop");this.controls&&this.video.setAttribute("controls","controls");this.poster&&this.video.setAttribute("poster",this.poster);this.w&&(this.video.setAttribute("width",this.w),this.video.setAttribute("height",this.h));this.video.setAttribute("style","position: absolute; overflow: hidden; left: "+
this.x+"px; top: "+this.y+"px;");var c=this.file,f=c.lastIndexOf(".");-1!=f&&(c=this.file.substring(0,f));this.video.canPlayType("video/mp4")&&(f=document.createElement("source"),f.setAttribute("src",c+".mp4"),f.setAttribute("type","video/mp4"),this.video.appendChild(f));this.video.canPlayType("video/ogg")&&(f=document.createElement("source"),f.setAttribute("src",c+".ogg"),f.setAttribute("type","video/ogg"),this.video.appendChild(f),f=document.createElement("source"),f.setAttribute("src",c+".ogv"),
f.setAttribute("type","video/ogg"),this.video.appendChild(f));this.video.canPlayType("video/webm")&&(f=document.createElement("source"),f.setAttribute("src",c+".webm"),f.setAttribute("type","video/webm"),this.video.appendChild(f));this.addControlContainer(this.video)};a.extend(a.Video,a.Control);a.Video.prototype.init=function(){this.video.style.left=this.x+"px";this.video.style.top=this.y+"px";this.update()};a.Video.prototype.update=function(){d=this.evaluator;0<d.evalExpression(this.drawif)?this.video.style.display=
"block":(this.video.style.display="none",this.video.pause());this.updatePositionAndSize()};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h;a.TextArea=function(d,c){a.Control.call(this,d,c);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 f=this.parent.lessonParser.parseText(this.answer)}this.containerControl=document.createElement("div");this.textArea=
document.createElement("div");this.textAreaAnswer=document.createElement("div");this.showButton=document.createElement("div");this.activeCover=document.createElement("div");this.containerControl.appendChild(this.textArea);this.containerControl.appendChild(this.textAreaAnswer);this.containerControl.appendChild(this.showButton);this.containerControl.appendChild(this.activeCover);this.addControlContainer(this.containerControl);this.showAnswer=!1;this.text=void 0==this.text||void 0==this.text.type?this.rawText||
"":this.text.hasFormula?this.rawText:this.text.toHTML();f&&void 0!=f.type&&!this.text.hasFormula&&(this.answer=f.toHTML());this.evaluator.setVariable(this.id,this.text);this.drawButton();this.registerMouseAndTouchEvents();this.init()};a.extend(a.TextArea,a.Control);a.TextArea.prototype.init=function(){h=this.answer?28:8;d=this.evaluator;this.text=d.getVariable(this.id);this.containerControl.setAttribute("class","DescartesTextAreaContainer");this.containerControl.setAttribute("style","width: "+this.w+
"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");this.containerControl.style.display=0<d.evalExpression(this.drawif)?"block":"none";this.containerControl.setAttribute("spellcheck","false");this.textArea.setAttribute("class","DescartesTextAreaContainer");this.textArea.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-h)+"px; left: 4px; top: 4px; background-color: white; text-align: left; font: "+a.convertFont(this.font)+";");this.textArea.setAttribute("contenteditable",
"true");this.textArea.innerHTML="<span style='position: relative; top: 10px; left: 10px; white-space: nowrap;' >"+this.text+"</span>";this.textAreaAnswer.setAttribute("class","DescartesTextAreaContainer");this.textAreaAnswer.setAttribute("style","width: "+(this.w-8)+"px; height: "+(this.h-h)+"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 c=d.getContext("2d");this.canvas=d;this.ctx=c;this.createGradient(20,16);c.lineWidth=1;c.fillStyle="white";c.fillRect(0,0,20,16);c.fillStyle=this.linearGradient;c.fillRect(0,0,20,16);a.drawLine(c,19,0,19,16,"rgba(0,0,0,"+128/255+")");a.drawLine(c,0,0,0,16,"rgba(0,0,0,"+24/255+")");a.drawLine(c,1,0,1,16,"rgba(0,0,0,"+
8/255+")");this.imageUnPush=d.toDataURL();c.fillStyle="white";c.fillRect(0,0,20,16);c.fillStyle=this.linearGradient;c.fillRect(0,0,20,16);a.drawLine(c,0,0,0,14,"gray");a.drawLine(c,0,0,19,0,"gray");c.fillStyle="rgba(0, 0, 0,"+24/255+")";c.fillRect(0,0,this.w,this.h);this.imagePush=d.toDataURL()};a.TextArea.prototype.update=function(){d=this.evaluator;this.activeIfValue=0<d.evalExpression(this.activeif);this.drawIfValue=0<d.evalExpression(this.drawif);d.setVariable(this.id,this.text);this.activeCover.style.display=
this.activeIfValue?"none":"block";this.containerControl.style.display=this.drawIfValue?"block":"none";this.updatePositionAndSize()};a.TextArea.prototype.registerMouseAndTouchEvents=function(){function a(d){d.preventDefault();c.showButton.style.backgroundImage="url("+c.imageUnPush+")"}var c=this;this.showButton.addEventListener("mousedown",function(a){a.preventDefault();c.showAnswer=!c.showAnswer;c.textAreaAnswer.style.display=c.showAnswer?"block":"none";c.showButton.childNodes[0].childNodes[0].textContent=
c.showAnswer?"T":"S";c.showButton.style.backgroundImage="url("+c.imagePush+")"});this.showButton.addEventListener("mouseup",a);this.showButton.addEventListener("mouseout",a)};a.TextArea.prototype.getScreenshot=function(){var a=document.createElement("canvas");a.setAttribute("width",this.w);a.setAttribute("height",this.h);var c=a.getContext("2d");c.fillStyle="white";c.strokeStyle="black";c.lineWidth=1;c.fillRect(0,0,this.w,this.h);c.strokeRect(0,0,this.w,this.h);return a};return a}(descartesJS||{}),
descartesJS=function(a){if(a.loadLib)return a;var d=2*Math.PI,h,g,c,f,k,l,e,p,m;a.GraphicControl=function(c,d){g=c.evaluator.parser;this.spaceID="E0";this.text="";this.size=g.parse("4");this.font="Monospaced,PLAIN,12";this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";a.Control.call(this,c,d);this.touchId=null;this.font=a.convertFont(this.font);this.constraintExpr&&(this.constraint=g.parse(this.constraintExpr),"(expr)"==this.constraint.type&&(this.constraint=g.parse(this.constraintExpr.substring(1,
this.constraintExpr.length-1))),"compOperator"==this.constraint.type?this.newt=new a.R2Newton(this.evaluator,this.constraint):this.constraint=null,p=new a.R2(0,0));this.container=this.getContainer();this.mouseCacher=document.createElement("div");this.mouseCacher.setAttribute("class","DescartesGraphicControl");this.mouseCacher.setAttribute("id",this.id);this.mouseCacher.setAttribute("dragged",!0);this.mouseCacher.setAttribute("tabindex","-1");this.ctx=this.space.ctx;this.container.appendChild(this.mouseCacher);
this.registerMouseAndTouchEvents();this.init()};a.extend(a.GraphicControl,a.Control);a.GraphicControl.prototype.init=function(){h=this.evaluator;m=a.hasTouchSupport;var c=h.evalExpression(this.expresion);this.x=c[0][0];this.y=c[0][1];h.setVariable(this.id+".x",this.x);h.setVariable(this.id+".y",this.y);""!=this.imageSrc&&!this.imageSrc.toLowerCase().match(/vacio.gif$/)?(this.image=this.parent.getImage(this.imageSrc),this.width=this.image.width,this.height=this.image.height):(this.width=2*h.evalExpression(this.size),
this.height=2*h.evalExpression(this.size));this._w=m&&70>this.width?70:this.width;this._h=m&&70>this.height?70:this.height;this.mouseCacher.setAttribute("style","cursor: pointer; background-color: rgba(255, 255, 255, 0); width: "+this._w+"px; height: "+this._h+"px; z-index: "+this.zIndex+";");this.mouseCacher.style.left=parseInt(this.space.getAbsoluteX(this.x)-this._w/2)+"px";this.mouseCacher.style.top=parseInt(this.space.getAbsoluteY(this.y)-this._h/2)+"px";h.setVariable(this.id+".activo",0);this.update()};
a.GraphicControl.prototype.update=function(){h=this.evaluator;this.activeIfValue=0<h.evalExpression(this.activeif);this.drawIfValue=0<h.evalExpression(this.drawif);this.x=h.getVariable(this.id+".x");this.y=h.getVariable(this.id+".y");c=this.space.getAbsoluteX(this.x);f=this.space.getAbsoluteY(this.y);this.active||(this.mouseCacher.style.left=parseInt(c-this._w/2)+"px",this.mouseCacher.style.top=parseInt(f-this._h/2)+"px");this.mouseCacher.style.display=this.drawIfValue?"block":"none";this.constraint&&
this.evalConstraint();this.draw()};a.GraphicControl.prototype.draw=function(){h=this.evaluator;this.drawIfValue&&(l=this.ctx,e=this.space.backgroundCtx,c=parseInt(this.space.getAbsoluteX(this.x))+0.5,f=parseInt(this.space.getAbsoluteY(this.y))+0.5,""!=this.text&&this.drawText(c,f),this.image.ready?(this.image.complete&&l.drawImage(this.image,parseInt(c-this.image.width/2),parseInt(f-this.image.height/2)),this.trace&&(e.save(),e.translate(c,f),e.scale(parseInt(this.image.width/2),parseInt(this.image.height/
2)),e.beginPath(),e.arc(0,0,1,0,d,!1),e.restore(),e.lineWidth=1,e.strokeStyle=this.trace.getColor(),e.stroke())):(l.beginPath(),l.arc(c,f,parseInt(this.width/2),0,d,!1),l.fillStyle=this.colorInt.getColor(),l.fill(),l.lineWidth=1,l.strokeStyle=this.color.getColor(),l.stroke(),this.active&&(l.beginPath(),l.arc(c,f,parseInt(this.width/2)-2,0,d,!1),l.strokeStyle=this.colorInt.borderColor(),l.stroke()),this.trace&&(e.lineWidth=1,e.strokeStyle=this.trace.getColor(),e.beginPath(),e.arc(c,f,parseInt(this.width/
2),0,d,!1),e.stroke())))};a.GraphicControl.prototype.evalConstraint=function(a,c){p.set(this.x,this.y);k=this.newt.findZero(p);this.x=k.x;this.y=k.y;this.evaluator.setVariable(this.id+".x",this.x);this.evaluator.setVariable(this.id+".y",this.y)};a.GraphicControl.prototype.drawText=function(a,c){l=this.ctx;h=this.evaluator;l.fillStyle=this.color.getColor();l.font=this.font;l.textBaseline="alphabetic";l.fillText(h.evalExpression(this.text[0],h.evalExpression(this.decimals),this.fixed),parseInt(a+1+
this.width/2),parseInt(c-1-this.height/2))};a.GraphicControl.prototype.getContainer=function(){for(var a=this.parent.spaces,c,d=0,e=a.length;d<e;d++)if(c=a[d],c.id==this.spaceID)return c.addCtr(this),this.zIndex=c.zIndex,this.space=c,c.graphicControlContainer;a[0].addCtr(this);this.zIndex=a[0].zIndex;this.space=a[0];return a[0].graphicControlContainer};a.GraphicControl.prototype.deactivate=function(){this.active=!1;this.evaluator.setVariable(this.id+".activo",0)};a.GraphicControl.prototype.registerMouseAndTouchEvents=
function(){function c(d){d.preventDefault();h.whichButton=a.whichButton(d);"L"==h.whichButton&&(h.activeIfValue&&h.over)&&(h.parent.deactivateGraphiControls(),h.click=!0,h.active=!0,h.evaluator.setVariable(h.id+".activo",1),h.posAnte=h.getCursorPosition(d),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},h.evaluator.setVariable(h.space.id+".mouse_x",h.x),h.evaluator.setVariable(h.space.id+".mouse_y",h.y),h.parent.update(),window.addEventListener("mouseup",e),window.addEventListener("mousemove",
k))}function d(a){a.preventDefault();h.activeIfValue&&(h.parent.deactivateGraphiControls(),h.click=!0,h.active=!0,h.evaluator.setVariable(h.id+".activo",1),h.posAnte=h.getCursorPosition(a),h.prePos={x:h.space.getAbsoluteX(h.x),y:h.space.getAbsoluteY(h.y)},h.evaluator.setVariable(h.space.id+".mouse_x",h.x),h.evaluator.setVariable(h.space.id+".mouse_y",h.y),h.parent.update(),window.addEventListener("touchmove",k),window.addEventListener("touchend",e))}function e(c){c.preventDefault();h.touchId=null;
if(h.activeIfValue||h.active)h.click=!1,a.hasTouchSupport?(window.removeEventListener("touchmove",k,!1),window.removeEventListener("touchend",e,!1)):(window.removeEventListener("mouseup",e,!1),window.removeEventListener("mousemove",k,!1)),h.evaluator.setVariable(h.space.id+".mouse_x",h.x),h.evaluator.setVariable(h.space.id+".mouse_y",h.y),h.parent.update(),h.mouseCacher.style.left=h.space.getAbsoluteX(h.x)-h._w/2+"px",h.mouseCacher.style.top=h.space.getAbsoluteY(h.y)-h._h/2+"px"}function k(a){a.preventDefault();
a.touchId=h.touchId;l=h.getCursorPosition(a);h.posX=h.prePos.x-(h.posAnte.x-l.x);h.posY=h.prePos.y-(h.posAnte.y-l.y);h.evaluator.setVariable(h.id+".x",h.space.getRelativeX(h.posX));h.evaluator.setVariable(h.id+".y",h.space.getRelativeY(h.posY));h.evaluator.setVariable(h.space.id+".mouse_x",h.x);h.evaluator.setVariable(h.space.id+".mouse_y",h.y);h.parent.updateControls();h.parent.update()}function g(a){h.over=!0}function f(a){h.over=!1;h.click=!1}var h=this;this.active=this.over=this.click=!1;this.mouseCacher.oncontextmenu=
function(){return!1};a.hasTouchSupport?this.mouseCacher.addEventListener("touchstart",d):(this.mouseCacher.addEventListener("mousedown",c),this.mouseCacher.addEventListener("mouseover",g),this.mouseCacher.addEventListener("mouseout",f));var l};a.GraphicControl.prototype.getCursorPosition=function(a){if(a.touches){var c;if(a.touchId){d=0;for(e=a.touches.length;d<e;d++)if(a.touches[d].identifier==a.touchId){c=a.touches[d];break}}else for(var d=0,e=a.touches.length;d<e;d++)if(a.target==a.touches[d].target){c=
a.touches[d];this.touchId=c.identifier;break}mouseX=c.pageX;mouseY=c.pageY}else void 0!=a.pageX&&void 0!=a.pageY?(mouseX=a.pageX,mouseY=a.pageY):(mouseX=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,mouseY=a.clientY+document.body.scrollTop+document.documentElement.scrollTop);return{x:mouseX-(this.space.container.offsetLeft+this.space.container.parentNode.offsetLeft),y:mouseY-(this.space.container.offsetTop+this.space.container.parentNode.offsetTop)}};return a}(descartesJS||
{}),descartesJS=function(a,d){var h,g,c,f,k,l,e,p,m,n;if(a.loadLib)return a;var t,s,u,q,r,w,v,z,B=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,C,x,D,E,F,A,H,J,I,L,y,K,G,M,N,O,S,T,Q,R,P;a.LessonParser=function(c){this.parent=c;this.parser=c.evaluator.parser;this.RTFparser=new a.RTFParser(c.evaluator)};a.LessonParser.prototype.parseButtonsConfig=function(a){var c={rowsNorth:0,rowsSouth:0,widthEast:125,widthWest:125,height:23};a=this.split(a);for(var e=0,k=a.length;e<k;e++)switch(u=a[e][0],
q=a[e][1],s=d[u],s){case "rowsNorth":case "rowsSouth":case "widthEast":case "widthWest":case "height":c[s]=parseInt(q);break;case "about":case "config":case "init":case "clear":c[s]="true"===d[q];break;default:console.log("----- attributo de space no identificado: <"+u+"> valor: <"+q+"> -----")}return c};a.LessonParser.prototype.parseSpace=function(c){r={};c=this.split(c);for(var e=0,k=c.length;e<k;e++)switch(u=c[e][0],q=c[e][1],s=d[u],s){case "type":case "id":case "cID":case "file":r[s]=q;break;
case "fixed":case "numbers":case "sensitive_to_mouse_movements":case "R3":case "split":r[s]="true"===d[q];break;case "bg_display":case "render":r[s]=d[q];break;case "net":case "net10":case "axes":case "text":r[s]="false"===d[q]?"":new a.Color(q,this.parent.evaluator);break;case "x_axis":case "y_axis":r[s]="false"===d[q]?"":q;break;case "O.x":r.OxExpr=q;break;case "O.y":r.OyExpr=q;break;case "image":r.imageSrc=q;break;case "x":t=q;t="%"===t[t.length-1]?(this.parent.container.width*parseFloat(t)/100).toString():
q;r.xExpr=this.parser.parse(t);break;case "y":t=q;t="%"===t[t.length-1]?(this.parent.container.height*parseFloat(t)/100).toString():q;r.yExpr=this.parser.parse(t);break;case "width":t=q;"%"===t[t.length-1]?t=this.parent.container.width*parseFloat(t)/100:(t=parseFloat(q),t!=q&&(t=this.parent.container.width));r.w=t;break;case "height":t=q;"%"===t[t.length-1]?t=this.parent.container.height*parseFloat(t)/100:(t=parseFloat(q),t!=q&&(t=this.parent.container.height));r.h=t;break;case "drawif":r.drawif=
this.parser.parse(q);break;case "scale":t=parseFloat(q);t.toString()!=q&&(t=48);r.scale=t;break;case "background":r.background=new a.Color(q,this.parent.evaluator);break;default:console.log("----- attributo de space no identificado: <"+u+"> valor: <"+q+"> -----")}switch(r.type){case "R2":return new a.Space2D(this.parent,r);case "R3":return new a.Space3D(this.parent,r);case "AP":return new a.SpaceAP(this.parent,r);case "HTMLIFrame":return new a.SpaceHTML_IFrame(this.parent,r);default:return new a.Space2D(this.parent,
r)}};a.LessonParser.prototype.parseControl=function(c){w={};c=this.split(c);for(var e=0,k=c.length;e<k;e++)switch(u=c[e][0],q=c[e][1],s=d[u],s){case "id":case "name":case "parameter":case "tooltip":case "tooltipFont":case "Explanation":case "ExplanationFont":case "cID":case "options":case "font":case "file":case "answer":w[s]=q;break;case "gui":case "region":case "action":case "msg_pos":case "poster":w[s]=d[q];break;case "fixed":case "visible":case "discrete":case "onlyText":case "evaluate":case "autoplay":case "loop":case "controls":w[s]=
"true"===d[q];break;case "color":case "colorInt":case "trace":w[s]=new a.Color(q,this.parent.evaluator);break;case "font_size":case "drawif":case "activeif":case "decimals":case "min":case "max":case "size":w[s]=this.parser.parse(q);break;case "constraint":w.constraintExpr=q;break;case "image":w.imageSrc=q;break;case "space":w.spaceID=q;break;case "type":w.type=d[q.trim()];break;case "expresion":w.expresion=this.parser.parse(q.replace(")(",","));break;case "bold":"false"!=d[q]&&(w.bold="bold");break;
case "italics":"false"!=d[q]&&(w.italics="italic");break;case "underlined":"false"!=d[q]&&(w.underlined=!0);break;case "value":var g=q.replace(/&squot;/g,"'");g.match(/^\|/)&&(g="'"+g.substring(1),g.match(/\|$/)&&(g=g.substring(0,g.length-1)+"'"));w.valueExpr=this.parser.parse(g);w.valueExprString=g;break;case "incr":0!=q&&(w.incr=this.parser.parse(q));break;case "exponentialif":w.exponentialif=parseFloat(q);break;case "text":w.rawText=q;for(var g=this.parseText(q),f=0,h=g.length;f<h;f++)g[f]=this.parser.parse(g[f],
!1);w.text=g;break;default:f=u.indexOf(".");g=d[u.substring(0,f)];f=d[u.substring(f+1)];if("parameter"===g&&"font"===f){w.parameterFont=q;break}else if("Explanation"===g&&"font"===f){w.ExplanationFont=q;break}else if("tooltip"===g&&"font"===f){w.tooltipFont=q;break}console.log("----- attributo de control no identificado: <"+u+"> valor: <"+q+"> -----")}if("numeric"===w.type)switch(w.gui){case "spinner":return new a.Spinner(this.parent,w);case "button":return new a.Button(this.parent,w);case "textfield":return new a.TextField(this.parent,
w);case "menu":return new a.Menu(this.parent,w);case "scrollbar":return new a.Scrollbar(this.parent,w);default:return new a.Spinner(this.parent,w)}else{if("video"===w.type)return new a.Video(this.parent,w);if("audio"===w.type)return new a.Audio(this.parent,w);if("graphic"===w.type)return new a.GraphicControl(this.parent,w);if("text"===w.type)return new a.TextArea(this.parent,w)}};a.LessonParser.prototype.parseGraphic=function(c,e,k,g){v={rotateExp:g,parameter:"t"};c=this.split(c);g=0;for(var f=c.length;g<
f;g++)switch(u=c[g][0],q=c[g][1],s=d[u],s){case "type":case "align":v[s]=d[q];break;case "background":case "abs_coord":case "visible":case "editable":case "fixed":case "vectors":v[s]="true"===d[q];break;case "color":case "trace":case "fill":case "fillP":case "fillM":case "arrow":v[s]=new a.Color(q,this.parent.evaluator);break;case "family":case "parameter":case "info":case "font":case "name":v[s]=q;break;case "drawif":case "width":case "decimals":case "size":case "spear":case "center":case "radius":case "init":case "end":case "opacity":case "inirot":case "inipos":case "range":v[s]=
this.parser.parse(q);break;case "space":v.spaceID=q;break;case "expresion":"macro"!=v.type?(v.expresion=this.parser.parse(q),v.expresionString=q):v.expresion=q;break;case "text":v.text=this.parseText(q);break;case "file":var h=q.replace(/&squot;/g,"'");"["===h.charAt(0)&&"]"===h.charAt(h.length-1)&&(h=h.substring(1,h.length-1));h.match(B)&&(h="'"+h+"'");v.file=this.parser.parse(h);break;case "border":"false"!=d[q]&&(v.border=new a.Color(q,this.parent.evaluator));break;default:if(void 0!=v.family&&
u.substring(0,v.family.length+1)===v.family+"."){switch(d[u.substring(v.family.length+1)]){case "interval":v.family_interval=this.parser.parse(q);break;case "steps":v.family_steps=this.parser.parse(q)}break}if(void 0!=v.parameter&&u.substring(0,v.parameter.length+1)===v.parameter+"."){switch(d[u.substring(v.parameter.length+1)]){case "interval":v.parameter_interval=this.parser.parse(q);break;case "steps":v.parameter_steps=this.parser.parse(q)}break}console.log("----- attributo del graphic no identificado: <"+
u+"> valor: <"+q+"> -----")}e&&(v.abs_coord=e);k&&(v.background=k);switch(v.type){case "text":return new a.Text(this.parent,v);case "image":return new a.Image(this.parent,v);case "point":return new a.Point(this.parent,v);case "polygon":return new a.Polygon(this.parent,v);case "arc":return new a.Arc(this.parent,v);case "segment":return new a.Segment(this.parent,v);case "arrow":return new a.Arrow(this.parent,v);case "macro":return new a.Macro(this.parent,v);case "curve":return new a.Curve(this.parent,
v);case "equation":return new a.Equation(this.parent,v);case "sequence":return new a.Sequence(this.parent,v);case "fill":return new a.Fill(this.parent,v)}};a.LessonParser.prototype.parse3DGraphic=function(c,e,k,g){v={rotateExp:g,parameter:"t"};c=this.split(c);e=0;for(k=c.length;e<k;e++)switch(u=c[e][0],q=c[e][1],s=d[u],s){case "type":case "model":v[s]=d[q];break;case "background":case "fixed":case "edges":v[s]="true"===d[q];break;case "color":case "backcolor":v[s]=new a.Color(q,this.parent.evaluator);
break;case "type":case "model":v[s]=d[q];break;case "background":case "fixed":case "edges":v[s]="true"===d[q];break;case "color":case "backcolor":v[s]=new a.Color(q,this.parent.evaluator);break;case "drawif":case "width":case "length":case "height":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":v[s]=this.parser.parse(q);break;case "family":case "parameter":case "font":case "name":v[s]=q;break;case "space":v.spaceID=q;break;case "expresion":"macro"!=v.type&&
"curve"!=v.type&&"surface"!=v.type?(v.expresion=this.parser.parse(q),v.expresionString=q):v.expresion=q;break;case "text":g=this.parseText(q);for(var f=0,h=g.length;f<h;f++)g[f]=this.parser.parse(g[f],!1);v.text=g;break;case "file":g=q.replace(/&squot;/g,"'");"["===g.charAt(0)&&"]"===g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/./)&&(g="'"+g+"'");v.file=this.parser.parse(g);break;case "drawif":case "width":case "length":case "decimals":case "Nu":case "Nv":case "inirot":case "endrot":case "inipos":case "endpos":v[s]=
this.parser.parse(q);break;case "family":case "parameter":case "font":case "name":v[s]=q;break;case "space":v.spaceID=q;break;case "expresion":"macro"!=v.type&&"curve"!=v.type&&"surface"!=v.type?(v.expresion=this.parser.parse(q),v.expresionString=q):v.expresion=q;break;case "text":g=this.parseText(q);f=0;for(h=g.length;f<h;f++)g[f]=this.parser.parse(g[f],!1);v.text=g;break;case "file":g=q.replace(/&squot;/g,"'");"["===g.charAt(0)&&"]"===g.charAt(g.length-1)&&(g=g.substring(1,g.length-1));g.match(/./)&&
(g="'"+g+"'");v.file=this.parser.parse(g);break;default:if(void 0!==v.family&&u.substring(0,v.family.length+1)===v.family+"."){"interval"===d[u.substring(v.family.length+1)]?v.family_interval=this.parser.parse(q):v.family_steps=this.parser.parse(q);break}console.log("----- attributo del graphic3D no identificado: <"+u+"> valor: <"+q+"> -----")}switch(v.type){case "point":return new a.Point3D(this.parent,v);case "segment":return new a.Segment3D(this.parent,v);case "polygon":return new a.Polygon3D(this.parent,
v);case "curve":return new a.Curve3D(this.parent,v);case "triangle":return new a.Triangle3D(this.parent,v);case "face":return new a.Face3D(this.parent,v);case "polireg":return new a.Polireg3D(this.parent,v);case "surface":return new a.Surface3D(this.parent,v);case "text":return new a.Text3D(this.parent,v);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,
v);default:console.log(v.type)}};a.LessonParser.prototype.parseAuxiliar=function(c){z={};c=this.split(c);for(var e=0,k=c.length;e<k;e++)c[e][1]=c[e][1].replace(/&squot;/g,"'");e=0;for(k=c.length;e<k;e++)switch(u=c[e][0],q=c[e][1],s=d[u],s){case "id":case "file":case "init":case "doExpr":case "whileExpr":case "range":case "local":case "expresion":case "condition":case "parameter":z[s]=q;break;case "editable":case "constant":case "array":case "matrix":case "algorithm":case "sequence":z[s]="true"===
d[q];break;case "size":case "rows":case "columns":z[s]=this.parser.parse(q);break;case "evaluate":case "event":case "execution":case "msg_pos":case "action":z[s]=d[q];break;default:var g=u.indexOf("."),f=d[u.substring(0,g)],g=d[u.substring(g+1)];if("parameter"===f&&"font"===g){z.parameterFont=q;break}console.log("----- attributo de auxiliar no identificado: <"+u+"> valor: <"+q+"> -----")}z.sequence?new a.Function(this.parent,z):z.constant?(c=new a.Constant(this.parent,z),z.evaluate&&"always"===z.evaluate&&
this.parent.auxiliaries.push(c)):z.algorithm&&z.evaluate?(c=new a.Algorithm(this.parent,z),this.parent.auxiliaries.push(c)):z.array&&!z.matrix&&")"!=z.id.charAt(z.id.length-1)?(c=new a.Vector(this.parent,z),z.evaluate&&"always"===z.evaluate&&this.parent.auxiliaries.push(c)):z.matrix&&")"!=z.id.charAt(z.id.length-1)?(c=new a.Matrix(this.parent,z),z.evaluate&&"always"===z.evaluate&&this.parent.auxiliaries.push(c)):z.event&&")"!=z.id.charAt(z.id.length-1)?this.parent.events.push(new a.Event(this.parent,
z)):")"===z.id.charAt(z.id.length-1)?new a.Function(this.parent,z):new a.Variable(this.parent,z)};a.LessonParser.prototype.parseAction=function(c){C=c.action;x=c.parent;D=c.parameter;if(C)switch(C){case "message":return new a.Message(x,D);case "calculate":return new a.Calculate(x,D);case "openURL":return new a.OpenURL(x,D);case "openScene":return new a.OpenScene(x,D);case "about":return new a.About(x,D);case "config":return new a.Config(x,D);case "init":return new a.Init(x,D);case "clear":return new a.Clear(x,
D);case "animate":return new a.Animate(x,D);case "initAnimation":return new a.InitAnimation(x,D);case "playAudio":return new a.PlayAudio(x,D);default:console.log("----- Accion no soportada aun: <"+C+"> -----")}else return{execute:function(){}}};a.LessonParser.prototype.parseAnimation=function(c){var e={};c=this.split(c);for(var k=0,g=c.length;k<g;k++)switch(u=c[k][0],q=c[k][1],s=d[u],s){case "id":case "delay":case "init":case "doExpr":case "whileExpr":e[s]=q;break;case "controls":case "auto":case "loop":case "algorithm":case "evaluate":e[s]=
"true"===d[q];break;default:console.log("----- attributo de la animacion no identificado: <"+u+">  <"+q+"> -----")}return new a.Animation(this.parent,e)};a.LessonParser.prototype.parsePleca=function(d,s){d=this.split(d);g=h="";c=0;f="#536891";k="white";l="left";e="";p="SansSerif,BOLD,20";m="SansSerif,PLAIN,18";n=void 0;for(var r=0,t=d.length;r<t;r++)switch(u=d[r][0],q=d[r][1],u){case "title":h=q;break;case "subtitle":g=q;break;case "subtitlines":c=q;break;case "bgcolor":""!=q&&(f=(new a.Color(q,this.parent.evaluator)).getColor());
break;case "fgcolor":""!=q&&(k=(new a.Color(q,this.parent.evaluator)).getColor());break;case "align":""!=q&&(l=q);break;case "titleimage":e=q;break;case "titlefont":p=""!=q?a.convertFont(q):a.convertFont(p);break;case "subtitlefont":m=""!=q?a.convertFont(q):a.convertFont(m);break;default:console.log("----- attributo de la pleca no identificado: <"+u+">  <"+q+"> -----")}L=m.substring(0,m.indexOf("px"));L=L.substring(L.lastIndexOf(" "));""!=e&&(y=this.parent.getImage(e),K=y.height);n=document.createElement("div");
n.setAttribute("id","descartesPleca");K?(n.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+l+"; width: "+(s-30)+"px; height: "+(K-16)+"px; background: "+f+"; color: "+k+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; overflow: hidden; z-index: 100;"),y.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: -1; width: 100%; height: 100%"),n.appendChild(y)):n.setAttribute("style","position: absolute; left: 0px; top: 0px; text-align: "+
l+"; width: "+(s-30)+"px; background: "+f+"; color: "+k+"; padding-top: 8px; padding-bottom: 8px; padding-left: 15px; padding-right: 15px; margin: 0px; z-index: 100;");G=document.createElement("div");G.setAttribute("style","padding: 0px; margin: 0px; font: "+p+"; overflow: hidden; white-space: nowrap;");G.innerHTML=h;M=document.createElement("div");if(1===parseInt(c)){Q=0;N=document.createElement("div");N.innerHTML=g;document.body.appendChild(N);S=L;do S-=Q,N.setAttribute("style","padding: 0px; margin: 0px; font: "+
m+"; font-size: "+S+"px; width: "+(s-30)+"px; line-height: "+S+"px;"),O=N.offsetHeight,T=O/S,Q=1;while(1<T&&8<S);document.body.removeChild(N);M.setAttribute("style","padding: 0px; margin: 0px; font: "+m+"; font-size: "+S+"px; line-height: 110%; overflow: hidden; white-space: nowrap;")}else M.setAttribute("style","padding: 0px; margin: 0px; font: "+m+"; line-height: 110%;");M.innerHTML=g;n.appendChild(G);n.appendChild(M);n.imageHeight=K;return n};a.LessonParser.prototype.split=function(a){if("string"!=
typeof a)return[];a=(a||"").replace(/\\'/g,"\u2019");E=[];A=F=0;H=!1;J=0;for(I=!1;F<a.length;)" "===a.charAt(F)&&!H&&F++," "!==a.charAt(F)&&!H&&(H=!0,J=F),"="===a.charAt(F)&&("'"===a.charAt(F+1)&&!I)&&(I=!0,E[A]=[a.substring(J,F)],J=F+2,F+=2),I&&"'"===a.charAt(F)&&(H=I=!1,E[A].push(a.substring(J,F)),A++),"="===a.charAt(F)&&("'"!==a.charAt(F+1)&&!I)&&(E[A]=[a.substring(J,F)],J=F+1,F++,R=a.substring(F).indexOf("="),-1===R?P=R=a.length:(R+=F,P=a.substring(F,R).lastIndexOf(" "),P=-1===P?a.length:P+F),
E[A].push(a.substring(J,P)),A++,H=!1,F=P),F++;return E};a.LessonParser.prototype.parseText=function(c){return c.match(/^\{\\rtf1/)?this.RTFparser.parse(c.substring(10)):new a.SimpleText(this.parent,c)};return a}(descartesJS||{},babel),descartesJS=function(a){function d(a,c){t=[];t.type="matrix";t.rows=a;t.cols=c;var d;u=0;for(q=c;u<q;u++){d=[];s=0;for(r=a;s<r;s++)d.push(0);t[u]=d}return t}function h(a,c){m=a.rows;n=a.cols;t=d(m,n);var e;for(u=0;u<m;u++)for(s=0;s<n;s++){for(q=e=0;q<n;q++)e+=a[q][u]*
c[s][q];t[s][u]=e}return t}function g(a,c,e){for(var k=d(e.length-1,e.length-1),g=0,f=k.length;g<f;g++)for(var h=0;h<f;h++)k[g][h]=g<a?h<c?e[g][h]:e[g][h+1]:g<c?e[g+1][h]:e[g+1][h+1];return k}function c(a){if(1<a.cols){for(var d=0,e=1,k=0,f=a.cols;k<f;k++)d+=e*a[0][k]*c(g(0,k,a)),e=-e;return d}return a[0][0]}if(a.loadLib)return a;var f=Math.floor,k,l,e,p;a.Node=function(a,c){this.sep="";this.type=a;this.value=c;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){k=this.childs.length-1;lastChild=this.childs[k];lastChild.parent=null;this.childs[k]=a;a.parent=this;return a};a.Node.prototype.contains=function(a){if(this.value===a)return!0;for(var c=0,d=this.childs.length;c<d;c++)if(this.childs[c].contains(a))return!0;return!1};a.Node.prototype.equalToMinus=function(){return"compOperator"===this.type?(this.type="operator",
this.value="-",e=new a.Node("compOperator","=="),p=new a.Node("number","0"),e.addChild(this),e.addChild(p),l=this.getRoot(),l.setAllEvaluateFunction(),l):this};a.Node.prototype.setAllEvaluateFunction=function(){this.setEvaluateFunction();for(var a=0,c=this.childs.length;a<c;a++)this.childs[a].setAllEvaluateFunction()};a.Node.prototype.setEvaluateFunction=function(){if("number"===this.type)this.evaluate=function(a){return parseFloat(this.value)};else if("string"===this.type)this.evaluate=function(a){return this.value};
else if("identifier"===this.type&&0===this.childs.length)if("rnd"==this.value)this.evaluate=function(a){return Math.random()};else{var a;this.evaluate=function(c,d){a=c.variables[this.value];if("object"===typeof a)return a.evaluate(c);void 0==a&&d&&(a=c.matrices[this.value]);return void 0!==a?a:0}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1===this.childs[0].childs.length){var e,k;this.evaluate=function(a){e=this.childs[0].childs[0].evaluate(a);try{return k=a.vectors[this.value][0>
e?0:f(e)],void 0!==k?k:0}catch(c){return 0}}}else if("identifier"===this.type&&"square_bracket"===this.childs[0].type&&1<this.childs[0].childs.length){var l,p;this.evaluate=function(a){l=this.childs[0].childs[0].evaluate(a);p=this.childs[0].childs[1].evaluate(a);try{return k=a.matrices[this.value][0>l?0:f(l)][0>p?0:f(p)],void 0!==k?k:0}catch(c){return 0}}}else if("identifier"===this.type&&"parentheses"===this.childs[0].type){var q;this.evaluate=function(a){q=[];for(var c=0,d=this.childs[0].childs.length;c<
d;c++)q.push(this.childs[0].childs[c].evaluate(a));return"_Eval_"===this.value?a.evalExpression(a.parser.parse(q[0])):a.functions[this.value].apply(a,q)}}else if("operator"===this.type){var r,E,F;"+"===this.value?this.evaluate=function(a){r=this.childs[0].evaluate(a,!0);E=this.childs[1].evaluate(a,!0);if("matrix"!==r.type||"matrix"!==E.type)return r+E;a=r;var c=E;m=a.rows;n=a.cols;t=d(m,n);for(u=0;u<m;u++)for(s=0;s<n;s++)t[s][u]=a[s][u]+c[s][u];return t}:"-"===this.value?this.evaluate=function(a){r=
this.childs[0].evaluate(a,!0);E=this.childs[1].evaluate(a,!0);if("matrix"!==r.type||"matrix"!==E.type)return r-E;a=r;var c=E;m=a.rows;n=a.cols;t=d(m,n);for(u=0;u<m;u++)for(s=0;s<n;s++)t[s][u]=a[s][u]-c[s][u];return t}:"*"===this.value?this.evaluate=function(a){r=this.childs[0].evaluate(a,!0);E=this.childs[1].evaluate(a,!0);return"matrix"!==r.type||"matrix"!==E.type?r*E:h(r,E)}:"/"===this.value?this.evaluate=function(a){r=this.childs[0].evaluate(a,!0);E=this.childs[1].evaluate(a,!0);if("matrix"!==
r.type||"matrix"!==E.type)return r/E;a=r;var e;e=E;var k=d(e.length,e.length),f=c(e);if(0===f)e=0;else{var f=1/f,l;if(1<e.length)for(var m=0,n=e.length;m<n;m++){l=f;for(var p=0;p<n;p++)k[p][m]=l*c(g(m,p,e)),l=-l;f=-f}else k[0][0]=f;e=k}a=0===e?d(a.rows,a.cols):h(a,e);return a}:"%"===this.value?this.evaluate=function(a){r=this.childs[0].evaluate(a);E=this.childs[1].evaluate(a);return r-f(r/E)*E}:"^"===this.value&&(this.evaluate=function(a){return Math.pow(this.childs[0].evaluate(a),this.childs[1].evaluate(a))})}else if("compOperator"===
this.type)"<"===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<this.childs[1].evaluate(a))+0}:"<="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)<=this.childs[1].evaluate(a))+0}:">"===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>this.childs[1].evaluate(a))+0}:">="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)>=this.childs[1].evaluate(a))+0}:"=="===this.value?this.evaluate=function(a){return(this.childs[0].evaluate(a)===
this.childs[1].evaluate(a))+0}:"!="===this.value&&(this.evaluate=function(a){return(this.childs[0].evaluate(a)!=this.childs[1].evaluate(a))+0});else if("boolOperator"===this.type)"&"===this.value?this.evaluate=function(a){return(r=this.childs[0].evaluate(a)?1:0)?this.childs[1].evaluate(a)?1:0:0}:"|"===this.value?this.evaluate=function(a){return(r=this.childs[0].evaluate(a)?1:0)?1:this.childs[1].evaluate(a)?1:0}:"!"===this.value&&(this.evaluate=function(a){r=this.childs[0].evaluate(a)?1:0;return!r+
0});else if("conditional"===this.type)this.evaluate=function(a){r=this.childs[0].evaluate(a);return 0<r?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,c){return this.childs[0].evaluate(a,c)};else if("(expr)"===this.type||"[expr]"===this.type){var A,H;this.evaluate=function(a){A=
this.childs.length;F=[];if(1===A&&1===this.childs[0].childs.length&&"(expr)"===this.type)F=this.childs[0].childs[0].evaluate(a);else for(var c=0;c<A;c++){H=[];for(var d=0,e=this.childs[c].childs.length;d<e;d++)H.push(this.childs[c].childs[d].evaluate(a));F[c]=H}return F}}else if("asign"===this.type){var J,I,L,y,K,G;this.evaluate=function(a){J=this.childs[0];I=this.childs[1];1===J.childs.length&&"square_bracket"===J.childs[0].type?(e=J.childs[0].childs,1===e.length?(L=e[0].evaluate(a),L=0>L?0:f(L),
a.vectors[J.value][L]=I.evaluate(a)):2===e.length&&(y=e[0].evaluate(a),K=e[1].evaluate(a),y=0>y?0:f(y),K=0>K?0:f(K),a.matrices[J.value][y]||(a.matrices[J.value][y]=[]),a.matrices[J.value][y][K]=I.evaluate(a))):(G=I.evaluate(a),G.type?a.matrices[J.value]=G:a.variables[J.value]=G)}}};var m,n,t,s,u,q,r;a.Node.prototype.toString=function(){var a="tipo: "+this.type+", valor: "+this.value+"\n";this.sep="   "+(this.parent?this.parent.sep:"");for(var c=0,d=this.childs.length;c<d;c++)a+=this.sep+this.childs[c].toString();
return a};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k,l,e,p,m=/^\s+/,n=/^[a-zA-Z_\u00C0-\u021B]+[a-zA-Z_0-9\u00C0-\u021B]*([.]*[0-9a-zA-Z_\u00C0-\u021B]+[0-9]*)*/,t=/^[0-9]+[.][0-9]+|^[.][0-9]+|^[0-9]+/,s=/^==|^!=|^<=|^<|^>=|^>|^#/,u=/^\!|^\~|^\&\&|^\&|^\|\||^\|/,q=/^=/,r=/^[\?\:]/,w=/^[\+\-\*\/\%\^]/,v=/^\[|^\]/,z=/^\(|^\)/,B=/^,/,C=/^;/;a.Tokenizer=function(){};a.Tokenizer.prototype.tokenize=function(a){function x(a,d,g){h.push({type:a,value:d});k=k.slice(g);
c+=g;e++;p=a}if(d=a)a=a.replace(/\\u(\S+) /g,function(a,c){return String.fromCharCode(parseInt(c,16))}),a=a.replace(/\&sup(.+);/g,"^$1 "),a=a.replace(/&squot;/g,"'"),a.match(/\=\|\*/g)&&(a=a.replace("|*","'","g").replace("*|","'","g")),a.match(/\=\|/g)&&(a=a.replace("|","'","g"));h=[];g=!1;c=0;k=a;e=0;for(p="";a&&c<a.length;)if(g=c,"'"==k[0]){for(l=1;"'"!=k[l];)if(l<k.length)l++;else{console.log(">Error, unknown symbol: ["+k+"], in the string <<"+d+">>");return}f=k.substring(1,l);x("string",f,f.length+
2)}else if(f=k.match(m))k=k.slice(f[0].length),c+=f[0].length,e++;else if(f=k.match(n))"number"===p&&h.push({type:"operator",value:"*"}),x("identifier",f[0],f[0].length);else if(f=k.match(t))x("number",f[0],f[0].length);else if(f=k.match(s)){var A=f[0];"#"==A&&(A="!=");x("compOperator",A,f[0].length)}else if(f=k.match(u))A=f[0],"||"==A?A="|":"&&"==A?A="&":"~"==A&&(A="!"),x("boolOperator",A,f[0].length);else if((f=k.match(q))&&!k.match(/^==/))x("asign",f[0],f[0].length);else if(f=k.match(r))x("conditional",
f[0],f[0].length);else if(f=k.match(w))x("operator",f[0],f[0].length);else if(f=k.match(v))x("square_bracket",f[0],f[0].length);else if(f=k.match(z))x("parentheses",f[0],f[0].length);else if(f=k.match(B))x("separator",f[0],f[0].length);else if(f=k.match(C))x("final_of_expresion",f[0],f[0].length);else if(g==c){console.log("Error, simbolo no conocido: ["+k+"], en la cadena <<"+d+">>");return}return h};var x,D=/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,c){a=a||[];c=c||"";x="";for(var d=0,e=a.length;d<e;d++)x="string"==a[d].type?x+"&squot;"+a[d].value+"&squot;":"identifier"==a[d].type&&!a[d].value.match(D)?x+c+a[d].value:x+a[d].value;return x};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;a.Parser=function(c){this.evaluator=c;this.tokenizer=new a.Tokenizer;this.vectors={};this.matrices={};this.variables={};this.functions={};this.registerDefaultValues()};a.Parser.prototype.setVariable=
function(a,c){this.variables[a]=c};a.Parser.prototype.getVariable=function(a){return this.variables[a]};a.Parser.prototype.setVector=function(a,c,d){this.vectors[a][c]=d};a.Parser.prototype.getVector=function(a){this.vectors.hasOwnProperty(a)||(this.vectors[a]=[0,0,0]);return this.vectors[a]};a.Parser.prototype.setMatrix=function(a,c,d,e){this.matrices[a][c][d]=e};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,c){this.functions[a]=c};a.Parser.prototype.getFunction=function(a){this.functions.hasOwnProperty(a)||(this.functions[a]=function(){return 0});return this.functions[a]};var d,h,g,c,f,k,l,e,p,m,n,t;a.Parser.prototype.parse=function(s,u){(g=this.tokenizer.tokenize(s))||(g=[]);c=null;u=!u||!1;d=e=l=k=0;for(h=g.length;d<h;d++)if(p=g[d],m=p.value,n=p.type,"identifier"===n&&(d+1<h&&"parentheses"===g[d+1].type&&"("===g[d+1].value?this.getFunction(m):d+1<h&&"square_bracket"===
g[d+1].type&&"["===g[d+1].value?g[d+3]&&"square_bracket"===g[d+3].type&&"]"===g[d+3].value?this.getVector(m):this.getMatrix(m):this.getVariable(m)),"asign"===n&&u&&(n="compOperator",m="=="),"asign"===n)if(f=new a.Node(n,m),null!=c)if("identifier"===c.type)c.parent&&c.parent.replaceLastChild(f),f.addChild(c),c=f,u=!0;else if("square_bracket"===c.type)f.addChild(c.parent),c=f,u=!0;else{f.type="compOperator";f.value="==";for(u=!0;c.parent&&this.getPrecedence(c.parent.value)>=this.getPrecedence(f.value);)c=
c.parent;c.parent&&c.parent.replaceLastChild(f);f.addChild(c);c=f}else{console.log("Error1: en la expresion <<"+s+">>, en el token {valor: "+m+", tipo: "+n+"}");break}else if("parentheses"===n&&"("===m||"square_bracket"===n&&"["===m)if(f=new a.Node(n,m),"("===m&&k++,"["===m&&l++,null===c)"("===m&&(new a.Node("(expr)","(expr)")).addChild(f),"["===m&&(new a.Node("[expr]","[expr]")).addChild(f),c=f;else if("operator"===c.type||"boolOperator"===c.type||"compOperator"===c.type||"conditional"===c.type||
"asign"===c.type)c.addChild(f),c=f;else if("sign"===c.type)c.addChild(f),c=f;else if("parentheses"===c.type&&"("===c.value)c.addChild(f),c=f;else if("square_bracket"===c.type&&"["===c.value)c.addChild(f),c=f;else if("parentheses"===c.type&&"()"===c.value)c.parent.addChild(f),c=f;else if("square_bracket"===c.type&&"[]"===c.value)c.parent.addChild(f),c=f;else if("identifier"===c.type)c.addChild(f),c=f;else{console.log("Error2: en la expresion <<"+s+">>, en el token ["+d+"] {valor: "+m+", tipo: "+n+
"}");break}else if("parentheses"===n&&")"===m)if(k--,null===c)console.log("Error3: en la expresion <<"+s+">>, en el token (valor:"+m+", tipo:"+n);else{for(;c&&c.parent&&"("!=c.value;)c=c.parent;if(c&&"("===c.value)c.value="()";else{console.log("Error4: en la expresion <<"+s+">>, en el token {valor: "+m+", tipo: "+n+"}");break}}else if("square_bracket"===n&&"]"===m)if(l--,null===c)console.log("Error5: en la expresion <<"+s+">>, en el token (valor:"+m+", tipo:"+n);else{for(;c&&c.parent&&"["!=c.value;)c=
c.parent;if(c&&"["===c.value)c.value="[]";else{console.log("Error6: en la expresion <<"+s+">>, en el token {valor: "+m+", tipo: "+n+"}");break}}else if("number"===n||"string"===n||"identifier"===n)if(f=new a.Node(n,m),null===c)c=f;else if("operator"===c.type||"compOperator"===c.type||"boolOperator"===c.type||"parentheses"===c.type&&"("===c.value||"square_bracket"===c.type&&"["===c.value||"sign"===c.type||"conditional"===c.type||"asign"===c.type)c.addChild(f),c=f;else{console.log("Error7: en la expresion <<"+
s+">>, en el token {valor: "+m+", tipo: "+n+"}");break}else if("operator"===n||"compOperator"===n||"boolOperator"===n)if(f=new a.Node(n,m),null===c)if("-"===m||"+"===m)f.type="sign",f.value="sign"+m,c=f;else if("!"===m)c=f;else{console.log("Error8: en la expresion <<"+s+">>, en el token {valor: "+m+", tipo: "+n+"}");break}else if("operator"===c.type||"compOperator"===c.type||"boolOperator"===c.type||"asign"===c.type||"conditional"===c.type||"square_bracket"===c.type&&"["===c.value&&("-"===m||"+"===
m||"!"===m)||"parentheses"===c.type&&"("===c.value&&("-"===m||"+"===m||"!"===m)){if("-"===m||"+"===m)f.type="sign",f.value="sign"+m;c.addChild(f);c=f}else if("number"===c.type||"parentheses"===c.type&&"()"===c.value||"square_bracket"===c.type&&"[]"===c.value||"string"===c.type||"identifier"===c.type||"conditional"===c.type||"asign"===c.type){for(;c.parent&&this.getPrecedence(c.parent.value)>=this.getPrecedence(f.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(f);f.addChild(c);c=f}else{console.log("Error9: en la expresion <<"+
s+">>, en el token {valor: "+m+", tipo: "+n+"}");break}else if("conditional"===n)if(f=new a.Node(n,m),null!=c)if("?"===f.value){for(e++;c.parent&&this.getPrecedence(c.parent.value)>this.getPrecedence(f.value);)c=c.parent;c.parent&&c.parent.replaceLastChild(f);f.addChild(c);c=f}else{for(e--;c&&c.parent&&"?"!=c.value;)c=c.parent;if(c&&"?"===c.value)c.value="?:";else{console.log("Error10: en la expresion <<"+s+">>, en el token {valor: "+m+", tipo: "+n+"}");break}}else{console.log("Error11: en la expresion <<"+
s+">>, en el token {valor: "+m+", tipo: "+n+"}");break}else if("separator"===n)if(null!=c)for(;c.parent&&"("!=c.value&&"["!=c.value;)c=c.parent;else{console.log("Error12: en la expresion <<"+s+">>, en el token {valor: "+m+", tipo: "+n+"}");break}else{console.log("Error13: en la expresion <<"+s+">>, en el token {valor: "+m+", tipo: "+n+"}");break}0<k&&alert("Error, faltan parentesis por cerrar: "+s);0>k&&alert("Error, faltan parentesis por abrir: "+s);0<l&&alert("Error, faltan square bracketss por cerrar: "+
s);0>l&&alert("Error, faltan square bracketss por abrir: "+s);0!=e&&alert("Error, condicional incompleta: "+s);(t=c?c.getRoot():null)&&t.setAllEvaluateFunction();return t};a.Parser.prototype.getPrecedence=function(a){switch(a){case "=":return 1;case "(":return 2;case "[":return 2;case "?":return 2;case ":":return 3;case "?:":return 3;case "|":return 6;case "&":return 7;case "<":return 5;case "<=":return 5;case ">":return 5;case ">=":return 5;case "==":return 5;case "!=":return 5;case "+":return 6;
case "-":return 6;case "/":return 7;case "*":return 7;case "sign-":return 7;case "sign+":return 7;case "!":return 8;case "^":return 8;case "%":return 8;default:return 9}};a.Parser.prototype.registerDefaultValues=function(){this.variables.rnd=Math.random;this.variables.pi=Math.PI;this.variables.e=Math.E;this.variables.Infinity=Infinity;this.variables["-Infinity"]=-Infinity;this.functions.sqr=function(a){return a*a};this.functions.sqrt=this.functions["ra\u00edz"]=Math.sqrt;this.functions.exp=Math.exp;
this.functions.log=Math.log;this.functions.log10=function(a){return Math.log(a)/Math.log(10)};this.functions.abs=Math.abs;this.functions.ent=Math.floor;this.functions.sgn=function(a){return 0<a?1:0>a?-1:0};this.functions.ind=function(a){return a?1:0};this.functions.sin=this.functions.sen=Math.sin;this.functions.cos=Math.cos;this.functions.tan=Math.tan;this.functions.cot=function(a){return 1/Math.tan(a)};this.functions.sec=function(a){return 1/Math.cos(a)};this.functions.csc=function(a){return 1/Math.sin(a)};
this.functions.sinh=this.functions.senh=function(a){return(Math.exp(a)-Math.exp(-a))/2};this.functions.cosh=function(a){return(Math.exp(a)+Math.exp(-a))/2};this.functions.tanh=function(a){return(Math.exp(a)-Math.exp(-a))/(Math.exp(a)+Math.exp(-a))};this.functions.coth=function(a){return 1/this.functions.tanh(a)};this.functions.sech=function(a){return 1/this.functions.cosh(a)};this.functions.csch=function(a){return 1/this.functions.sinh(a)};this.functions.asin=this.functions.asen=Math.asin;this.functions.acos=
Math.acos;this.functions.atan=Math.atan;this.functions.min=Math.min;this.functions.max=Math.max;var c=this;this.functions._Trace_=function(a){console.log(a)};this.functions._Stop_Audios_=function(){c.evaluator.parent.stopAudios()};this.functions.esCorrecto=function(d,e,k){return a.esCorrecto(d,e,c.evaluator,k)};this.functions.escorrecto=function(d,e,k){return a.escorrecto(d,e,c.evaluator,k)};window.parent!==window&&(this.functions["parent.set"]=function(a,c){window.parent.postMessage({type:"set",
name:a,value:c},"*")},this.functions["parent.update"]=function(){window.parent.postMessage({type:"update"},"*")},this.functions["parent.exec"]=function(a,c){window.parent.postMessage({type:"exec",name:a,value:c},"*")})};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=Math.floor;a.Evaluator=function(d){this.parent=d;this.parser=new a.Parser(this);this.variables=this.parser.variables;this.functions=this.parser.functions;this.vectors=this.parser.vectors;this.matrices=this.parser.matrices};
a.Evaluator.prototype.setVariable=function(a,d){this.variables[a]=d};a.Evaluator.prototype.getVariable=function(a){return this.variables[a]};a.Evaluator.prototype.setVector=function(a,g,c){g=0>g?0:d(g);this.vectors[a][g]=c};a.Evaluator.prototype.getVector=function(a,g){g=0>g?0:d(g);return this.vectors[a][g]};a.Evaluator.prototype.setMatrix=function(a,g,c,f){g=0>g?0:d(g);c=0>c?0:d(c);this.matrices[a][g][c]=f};a.Evaluator.prototype.getMatrix=function(a,g,c){g=0>g?0:d(g);c=0>c?0:d(c);return this.matrices[a][g][c]};
a.Evaluator.prototype.setFunction=function(a,d){this.functions[a]=d};a.Evaluator.prototype.getFunction=function(a){return this.functions[a]};a.Evaluator.prototype.evalExpression=function(a){return a?a.evaluate(this):0};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=2,h=!1;a.RTFNode=function(a,c,d,g){this.evaluator=a;this.type="rtfNode";this.value=c;this.nodeType=d;this.style=g;this.styleString=g.toString();this.color=g.textColor;this.underline=g.textUnderline;this.overline=
g.textOverline;this.parent=null;this.children=[];switch(this.nodeType){case "textBlock":this.draw=this.drawTextBlock;break;case "textLineBlock":this.draw=this.drawTextLineBlock;break;case "formula":this.draw=this.drawFormula;break;case "superIndex":this.draw=this.drawSuperIndex;break;case "subIndex":this.draw=this.drawSubIndex;break;case "dynamicText":this.draw=this.drawDynamicText;this.decimal_symbol=this.evaluator.parent.decimal_symbol;break;case "fraction":this.draw=this.drawFraction;break;case "numerator":case "denominator":this.draw=
this.drawNumDen;break;case "radical":this.draw=this.drawRadical;break;case "limit":this.draw=this.drawLimit;break;case "integral":this.draw=this.drawIntegral;break;case "sum":this.draw=this.drawSum;break;case "matrix":this.draw=this.drawMatrix;break;case "defparts":this.draw=this.drawDefparts;break;case "text":case "newLine":this.draw=this.drawText;break;case "hyperlink":this.draw=this.drawHyperlink;break;case "mathSymbol":this.draw=this.drawMathSymbol;break;case "index":case "radicand":case "from":case "to":case "what":case "element":this.draw=
this.drawGenericBlock;break;case "componentNumCtrl":this.draw=this.drawComponentNumCtrl;break;case "componentSpace":this.draw=this.drawComponentSpace}};a.RTFNode.prototype.getRoot=function(){return null==this.parent?this:this.parent.getRoot()};a.RTFNode.prototype.addChild=function(a){a.parent=this;this.children.push(a)};var g=0,c=0,f=0;a.RTFNode.prototype.getTextMetrics=function(){if("textBlock"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);for(var k=0,l=this.children.length;k<
l;k++)this.children[k].getTextMetrics()}else if("textLineBlock"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("newLine"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);var e=a.getFontMetrics(this.styleString);this.baseline=e.baseline;this.descent=e.descent;this.ascent=e.ascent;this.width=e.width;this.height=e.height}else if("text"==this.nodeType||"dynamicText"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);
e=a.getFontMetrics(this.styleString);this.baseline=e.baseline;this.descent=e.descent;this.ascent=e.ascent;var k=this.value,p;"string"!=typeof this.value&&(l=void 0==this.decimals?d:this.evaluator.evalExpression(this.decimals),p=void 0==this.fixed?h:this.fixed,k=this.evaluator.evalExpression(this.value,l,p),parseFloat(k)==k&&(k=parseFloat(k).toFixed(l),k=p?k:parseFloat(k),k=k.toString().replace(".",this.decimal_symbol)),k+=" ");this.width=a.getTextWidth(k,this.styleString);this.height=e.height}else if("formula"==
this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),this.getBlockMetric();else if("hyperlink"===this.nodeType)k=a.getFontMetrics(this.styleString),this.baseline=k.baseline,this.descent=k.descent,this.ascent=k.ascent,this.width=a.getTextWidth(this.value,this.styleString),this.height=k.height,this.clickCacher=document.createElement("div"),this.clickCacher.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px;");else if("superIndex"==this.nodeType)this.spaceWidth=
a.getTextWidth(" ",this.styleString),l=g,e=c,l=f,k=a.getFontMetrics(this.styleString),this.getBlockMetric(),0>this.height&&(this.ascent=k.ascent,this.descent=k.descent,this.height=this.ascent+this.descent,this.width=1.5*this.spaceWidth),k=l/2-e+this.height,this.superIndexPos=k-this.ascent,this.ascent=k,this.descent=e,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("subIndex"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),l=g,e=c,k=a.getFontMetrics(this.styleString),
this.getBlockMetric(),0>this.height&&(this.ascent=k.ascent,this.descent=k.descent,this.height=this.ascent+this.descent,this.width=1.5*this.spaceWidth),this.subIndexPos=e+1,this.ascent=l,this.descent=this.subIndexPos+this.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent;else if("fraction"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);e=c;l=f;p=this.children[0];var m=this.children[1],k=a.getFontMetrics(p.styleString);p.getBlockMetric();m.getBlockMetric();
0>p.height&&(p.height=k.height,p.width=this.spaceWidth);0>m.height&&(m.height=k.height,m.width=this.spaceWidth);this.height=p.height+m.height-1;this.ascent=p.height+l/2-e;this.descent=this.height-this.ascent;this.baseline=this.ascent;this.width=Math.max(p.width,m.width)+this.spaceWidth+8}else if("radical"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);e=this.children[0].style.clone();if(1===this.children.length)this.children[1]=new a.RTFNode(this.evaluator,"","radicand",e),this.children[1].addChild(this.children[0]),
this.children[0]=new a.RTFNode(this.evaluator,"","index",e);else if("index"!==this.children[0].nodeType||"radicand"!==this.children[1].nodeType){p=new a.RTFNode(this.evaluator,"","radicand",e);k=0;for(l=this.children.length;k<l;k++)p.addChild(this.children[k]);this.children=[];this.children[0]=new a.RTFNode(this.evaluator,"","index",e);this.children[1]=p}e=this.children[0];k=this.children[1];e.getBlockMetric();k.getBlockMetric();this.ascent=k.height/2<e.height?k.height/2+e.height+2-k.descent:k.ascent+
4;this.descent=k.descent;this.baseline=this.ascent;this.height=this.ascent+this.descent;this.width=e.width+k.width+4*this.spaceWidth}else if("sum"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),e=this.children[0],l=this.children[1],p=this.children[2],e.getBlockMetric(),l.getBlockMetric(),p.getBlockMetric(),-1==e.ascent&&(m=a.getFontMetrics(e.styleString),e.ascent=m.ascent,e.descent=m.descent,e.height=m.height),-1==l.ascent&&(m=a.getFontMetrics(l.styleString),l.ascent=m.ascent,
l.descent=m.descent,l.height=m.height),k=a.getFontMetrics(this.styleString),this.ascent=k.height+l.height>p.ascent?k.height-k.descent+l.height:p.ascent,this.descent=e.height>p.descent?e.height+k.descent:p.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent,k=this.style.clone(),k.fontType="Times New Roman",k.Bold="bold",k=k.toString(),k=a.getTextWidth(String.fromCharCode(8721),k),this.width=Math.max(e.width,l.width,k)+Math.max(p.width,this.spaceWidth)+this.spaceWidth;else if("integral"==
this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),e=this.children[0],l=this.children[1],p=this.children[2],e.getBlockMetric(),l.getBlockMetric(),p.getBlockMetric(),-1==e.ascent&&(m=a.getFontMetrics(e.styleString),e.ascent=m.ascent,e.descent=m.descent,e.height=m.height),-1==l.ascent&&(m=a.getFontMetrics(l.styleString),l.ascent=m.ascent,l.descent=m.descent,l.height=m.height),k=a.getFontMetrics(this.styleString),this.ascent=k.height+l.height>p.ascent?k.height-k.descent+l.height:p.ascent,
this.descent=e.height>p.descent?e.height+k.descent:p.descent,this.baseline=this.ascent,this.height=this.ascent+this.descent,k=this.style.clone(),k.fontSize*=1.5,k.fontType="Times New Roman",k.Bold="bold",k=k.toString(),k=a.getTextWidth(String.fromCharCode(8747),k),this.width=Math.max(e.width,l.width,k)+Math.max(p.width,this.spaceWidth)+2*this.spaceWidth;else if("limit"==this.nodeType)this.spaceWidth=a.getTextWidth(" ",this.styleString),e=this.children[0],l=this.children[1],p=this.children[2],k=a.getFontMetrics(this.styleString),
e.getBlockMetric(),l.getBlockMetric(),p.getBlockMetric(),-1==e.ascent&&(m=a.getFontMetrics(e.styleString),e.ascent=m.ascent,e.descent=m.descent,e.height=m.height),-1==l.ascent&&(m=a.getFontMetrics(l.styleString),l.ascent=m.ascent,l.descent=m.descent,l.height=m.height),-1==p.ascent&&(m=a.getFontMetrics(p.styleString),p.ascent=m.ascent,p.descent=m.descent,p.height=m.height),this.ascent=p.ascent,this.descent=Math.max(k.height,p.descent),this.baseline=this.ascent,this.height=this.ascent+this.descent,
k=a.getTextWidth(" "+String.fromCharCode(8594),this.styleString),0==e.width&&(e.width=this.spaceWidth),0==l.width&&(l.width=this.spaceWidth),0==p.width&&(p.width=this.spaceWidth),this.width=l.width+e.width+p.width+k+this.spaceWidth;else if("matrix"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);k=a.getFontMetrics(this.styleString);e=c;p=k.ascent;for(var m=k.descent,n=k.height,t=this.spaceWidth,s,u,k=0,l=this.children.length;k<l;k++)this.children[k].getBlockMetric(),s=this.children[k].height,
u=this.children[k].width,n<s&&(n=s,p=this.children[k].ascent,m=this.children[k].descent),t<u&&(t=u);this.childWidth=t+2*this.spaceWidth;this.childHeight=n;this.childAscent=p;this.childDescent=m;this.height=this.rows*n;this.ascent=this.height/2+e;this.descent=this.height-this.ascent;this.width=this.columns*this.childWidth+this.spaceWidth}else if("defparts"==this.nodeType){this.spaceWidth=a.getTextWidth(" ",this.styleString);k=a.getFontMetrics(this.styleString);e=c;p=k.ascent;m=k.descent;n=k.height;
t=this.spaceWidth;k=0;for(l=this.children.length;k<l;k++)this.children[k].getBlockMetric(),s=this.children[k].height,u=this.children[k].width,n<s&&(n=s,p=this.children[k].ascent,m=this.children[k].descent),t<u&&(t=u);this.childWidth=t+2*this.spaceWidth;this.childHeight=n;this.childAscent=p;this.childDescent=m;this.height=this.parts*n;this.ascent=this.height/2+e;this.descent=this.height-this.ascent;this.width=t+this.spaceWidth/2}else"mathSymbol"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),
e=a.getFontMetrics(this.styleString),this.baseline=e.baseline,this.descent=e.descent,this.ascent=e.ascent,this.width=a.getTextWidth(this.value,this.styleString)+a.getTextWidth(" ",this.styleString),this.height=e.height):"componentNumCtrl"==this.nodeType?(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentNumCtrl=this.evaluator.parent.getControlByCId(this.value),this.height=this.ascent=this.descent=this.baseline=0,this.width=this.componentNumCtrl.w):"componentSpace"==this.nodeType?
(this.spaceWidth=a.getTextWidth(" ",this.styleString),this.componentSpace=this.evaluator.parent.getSpaceByCId(this.value),this.height=this.ascent=this.descent=this.baseline=0,this.width=this.componentSpace.w):console.log("Element i=unknown",this.nodeType)};a.RTFNode.prototype.getBlockMetric=function(){this.width=0;for(var a=-1,d=-1,e,h=0,m=this.children.length;h<m;h++){e=this.children[h];e.getTextMetrics();childAscent=e.ascent;childDescent=e.descent;this.width+=e.width;var n=childDescent;e=e.height;
g=childAscent;c=n;f=e;d<childAscent&&(d=childAscent);a<childDescent&&(a=childDescent)}this.ascent=d;this.descent=a;this.baseline=this.ascent;this.height=this.ascent+this.descent};a.RTFNode.prototype.drawTextBlock=function(a,c,e,g,f,n,t){this.stableWidth||(this.getTextMetrics(),d=g,h=f);t=t?-this.children[0].ascent:0;f=g=0;for(n=this.children.length;f<n;f++)0<f&&(g+=this.children[f-1].height),this.children[f].draw(a,c+0,e+t+g)};a.RTFNode.prototype.drawTextLineBlock=function(c,d,e){for(var g=0,f=0,
h=this.children.length;f<h;f++)0<f&&(g+=this.children[f-1].width,"formula"==this.children[f-1].nodeType&&(g+=2*a.getTextWidth(" ",this.children[f].styleString))),this.children[f].draw(c,d+g,e+this.baseline)};a.RTFNode.prototype.drawFormula=function(a,c,d){for(var g=0,f=0,h=this.children.length;f<h;f++)0<f&&(g+=this.children[f-1].width),this.children[f].draw(a,c+this.spaceWidth+g,d)};a.RTFNode.prototype.drawText=function(a,c,d){null!=this.color&&(a.fillStyle=this.color);a.font=this.styleString;a.textAlign=
"start";a.textBaseline="alphabetic";a.fillText(this.value,c-1,d);if(this.underline){var g="bold"==this.style.textBold,f=g?1:0.5;a.lineWidth=g?2:1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(c-1,parseInt(d+this.descent/2)+f);a.lineTo(c-1+this.width,parseInt(d+this.descent/2)+f);a.stroke()}this.overline&&(f=(g="bold"==this.style.textBold)?2:1.5,a.lineWidth=g?2:1,null!=this.color&&(a.strokeStyle=this.color),a.beginPath(),a.moveTo(c-1,parseInt(d-this.ascent)+f),a.lineTo(c-1+this.width,
parseInt(d-this.ascent)+f),a.stroke())};a.RTFNode.prototype.drawDynamicText=function(c,g,e){var f=Math.floor(0.5*this.spaceWidth),m=void 0==this.decimals?d:this.evaluator.evalExpression(this.decimals),n=void 0==this.fixed?h:this.fixed,t=this.evaluator.evalExpression(this.value,m,n);parseFloat(t)==t&&(t=n?parseFloat(t).toFixed(m):parseFloat(parseFloat(t).toFixed(m)),t=(""+t).replace(".",this.decimal_symbol));null!=this.color&&(c.fillStyle=this.color);c.font=this.styleString;c.textAlign="start";c.textBaseline=
"alphabetic";this.width=a.getTextWidth(t,this.styleString);c.fillText(t,f+g,e);this.underline&&(n=(m="bold"==this.style.textBold)?1:0.5,c.lineWidth=m?2:1,null!=this.color&&(c.strokeStyle=this.color),c.beginPath(),c.moveTo(f+g-1,parseInt(e+this.descent/2)+n),c.lineTo(f+g-1+this.width,parseInt(e+this.descent/2)+n),c.stroke());this.overline&&(n=(m="bold"==this.style.textBold)?2:1.5,c.lineWidth=m?2:1,null!=this.color&&(c.strokeStyle=this.color),c.beginPath(),c.moveTo(f+g-1,parseInt(e-this.ascent)+n),
c.lineTo(f+g-1+this.width,parseInt(e-this.ascent)+n),c.stroke());this.width+=2*f};a.RTFNode.prototype.drawHyperlink=function(a,c,d){a.save();this.click?(a.fillStyle="red",a.strokeStyle="red"):(a.fillStyle="blue",a.strokeStyle="blue");a.font=this.styleStr;a.textAlign="start";a.textBaseline="alphabetic";a.fillText(this.value,c-1,d);var g="bold"==this.style.textBold,f=g?1:0.5;a.linew=g?2:1;a.beginPath();a.moveTo(c-1,parseInt(d+this.descent/2)+f);a.lineTo(c-1+this.w,parseInt(d+this.descent/2)+f);a.stroke();
a.restore()};a.RTFNode.prototype.drawRadical=function(a,c,d){var g=Math.floor(this.spaceWidth);this.children[0].draw(a,c,Math.floor(d+this.children[1].descent-this.children[1].height/2-this.children[0].descent));this.children[1].draw(a,c+1.5*g+this.children[0].width,d);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(c,Math.floor(d+this.children[1].descent-this.children[1].height/2));a.lineTo(c+this.children[0].width,Math.floor(d+this.children[1].descent-this.children[1].height/
2));a.lineTo(c+this.children[0].width+0.5*g,d+this.children[1].descent);a.lineTo(c+this.children[0].width+1*g,d-this.children[1].ascent);a.lineTo(c+this.children[0].width+2*g+this.children[1].width,d-this.children[1].ascent);a.stroke()};a.RTFNode.prototype.drawFraction=function(a,c,d){this.children[0].draw(a,c+(this.width-this.children[0].width)/2,d-this.ascent);this.children[1].draw(a,c+(this.width-this.children[1].width)/2,d-this.ascent+this.children[0].height-1);var g=Math.floor(0.5*this.spaceWidth);
a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(c+g,parseInt(d-this.ascent+this.children[0].height)+0.5);a.lineTo(c-g+this.width-1,parseInt(d-this.ascent+this.children[0].height)+0.5);a.stroke()};a.RTFNode.prototype.drawNumDen=function(a,c,d){for(var g=0,f=0,h=this.children.length;f<h;f++)0<f&&(g+=this.children[f-1].width),this.children[f].draw(a,c+g,d+this.baseline)};a.RTFNode.prototype.drawSubIndex=function(a,c,d){for(var g=0,f=0,h=this.children.length;f<h;f++)0<
f&&(g+=this.children[f-1].width),this.children[f].draw(a,c+g,d+this.subIndexPos)};a.RTFNode.prototype.drawSuperIndex=function(a,c,d){for(var g=0,f=0,h=this.children.length;f<h;f++)0<f&&(g+=this.children[f-1].width),this.children[f].draw(a,c+g,d-this.superIndexPos)};a.RTFNode.prototype.drawLimit=function(c,d,e){var g=a.getFontMetrics(this.styleString),f=" "+String.fromCharCode(8594),h=a.getTextWidth(f,this.styleString);this.children[0].draw(c,d,e+g.descent+this.children[0].ascent);this.children[1].draw(c,
d+this.children[0].width+h,e+g.descent+this.children[1].ascent);this.children[2].draw(c,d+h+this.children[0].width+this.children[1].width,e);null!=this.color&&(c.fillStyle=this.color);c.font=this.styleString;c.textAlign="start";c.textBaseline="alphabetic";c.fillText("l\u00edm",d+this.children[0].width,e);c.fillText(f,d+this.children[0].width,e+g.descent+this.children[0].ascent)};a.RTFNode.prototype.drawIntegral=function(c,d,e){var g=this.style.clone();g.fontSize*=1.5;g.fontType="Times New Roman";
g.Bold="bold";var g=g.toString(),f=a.getTextWidth(String.fromCharCode(8747),g),h=a.getFontMetrics(g),t=Math.max(this.children[0].width,this.children[1].width,Math.floor(1.5*f));this.children[0].draw(c,d+f,e+h.descent+this.children[0].ascent);this.children[1].draw(c,d+f+this.spaceWidth/2,e-this.ascent+this.children[1].ascent);this.children[2].draw(c,d+t+f,e);null!=this.color&&(c.fillStyle=this.color);c.font=g;c.textAlign="start";c.textBaseline="alphabetic";c.fillText(String.fromCharCode(8747),d,e+
h.descent/2)};a.RTFNode.prototype.drawSum=function(c,d,e){var g=this.style.clone();g.fontType="Times New Roman";g.Bold="bold";var g=g.toString(),f=a.getTextWidth(String.fromCharCode(8721),g),h=a.getFontMetrics(this.styleString),t=Math.max(this.children[0].width,this.children[1].width,f);this.children[0].draw(c,d+(t-this.children[0].width)/2,e+h.descent+this.children[0].ascent);this.children[1].draw(c,d+(t-this.children[1].width)/2,e-h.ascent-this.children[1].descent);this.children[2].draw(c,d+t,e);
null!=this.color&&(c.fillStyle=this.color);c.font=g;c.textAlign="start";c.textBaseline="alphabetic";c.fillText(String.fromCharCode(8721),d+Math.floor((t-f)/2),e-5)};a.RTFNode.prototype.drawMatrix=function(a,c,d){for(var g,f,h=0,t=this.children.length;h<t;h++)g=h%this.columns,f=Math.floor(h/this.columns),this.children[h].draw(a,2*this.spaceWidth+c+g*this.childWidth,d-this.ascent+this.childAscent+f*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(c+
this.spaceWidth)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.spaceWidth/2)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.spaceWidth/2)+0.5,d+this.descent+0.5);a.lineTo(Math.floor(c+this.spaceWidth)+0.5,d+this.descent+0.5);a.moveTo(Math.floor(c+this.width-this.spaceWidth)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.width-this.spaceWidth/2)-0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.width-this.spaceWidth/2)-0.5,d+this.descent+0.5);a.lineTo(Math.floor(c+this.width-this.spaceWidth)-
0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawDefparts=function(a,c,d){for(var g=0,f=this.children.length;g<f;g++)this.children[g].draw(a,c+this.spaceWidth/4,d-this.ascent+this.childAscent+g%this.parts*this.childHeight);a.lineWidth=1;null!=this.color&&(a.strokeStyle=this.color);a.beginPath();a.moveTo(Math.floor(c+this.spaceWidth/3)+0.5,d-this.ascent+0.5);a.lineTo(Math.floor(c+this.spaceWidth/6)+0.5,d-this.ascent+0.5+(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(c+this.spaceWidth/
6)+0.5,d+this.descent-this.height/2-(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(c+0.5,d+this.descent-this.height/2);a.lineTo(Math.floor(c+this.spaceWidth/6)+0.5,d+this.descent-this.height/2+(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(c+this.spaceWidth/6)+0.5,d+this.descent+0.5-(this.spaceWidth/3-this.spaceWidth/6));a.lineTo(Math.floor(c+this.spaceWidth/3)+0.5,d+this.descent+0.5);a.stroke()};a.RTFNode.prototype.drawMathSymbol=function(a,c,d){a.lineWidth=1;null!=this.color&&(a.strokeStyle=
this.color,a.fillStyle=this.color);a.beginPath();"("==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText("(",c,d)):")"==this.value?(a.font=this.styleString,a.textAlign="start",a.textBaseline="alphabetic",a.fillText(")",c+this.spaceWidth,d)):(a.font=this.styleString,a.textAlign="center",a.textBaseline="alphabetic",a.fillText(this.value,c+this.width/2,d))};a.RTFNode.prototype.drawGenericBlock=function(a,c,d){for(var g=0,f=0,h=this.children.length;f<h;f++)0<
f&&(g+=this.children[f-1].width),this.children[f].draw(a,c+g,d)};a.RTFNode.prototype.drawComponentNumCtrl=function(a,c,d){this.getTextMetrics();this.componentNumCtrl.expresion=this.evaluator.parser.parse("("+c+","+(d-this.parent.ascent)+","+this.componentNumCtrl.w+","+this.componentNumCtrl.h+")")};a.RTFNode.prototype.drawComponentSpace=function(a,c,d){this.getTextMetrics();this.componentSpace.xExpr=this.evaluator.parser.parse(c+"");this.componentSpace.yExpr=this.evaluator.parser.parse(d-this.parent.ascent+
"")};a.RTFNode.prototype.draw=function(a,c,d){console.log(">>> Dibujo desconocido ",this.nodeType)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d=String.fromCharCode,h,g,c,f,k,l,e,p,m,n,t;a.RTFTokenizer=function(){};a.RTFTokenizer.prototype.tokenize=function(a){if(a)a=a.replace(/\&quote;/g,"''").replace(/\&squot;/g,"'").replace(/\\rquote /g,"'").replace(/\\endash /g,"-").replace(/\n/g," ").replace(/\r/g,"").replace(/\\uc(\d+) /g,"").replace(/\\uc(\d+)/g,"");else return[];
h=[];g=a.length;h=[];c="";k=f=0;e=a.charAt(0);p=!1;for(m="text";f<g;)l=e,e=a.charAt(f+1),p?"\\"===e||"{"===e||"}"===e||" "===e||";"===e?(p=!1,c+=l," "===e&&(f++,e=a.charAt(f+1)),(n=c.match(/^\'([0-9a-f]{2})/))?(t="","text"===m&&(t=h.pop().value),c=t+=d(parseInt(n[1],16))+c.substring(3)):(n=c.match(/^u[0-9]+/))?(t="","text"===m&&(t=h.pop().value),c=t+=d(n[0].substring(1))):(h.push({type:"controlWord",value:c}),m="controlWord",c="")):c+=l:"\\"===l?(p=!0,""!==c&&(h.push({type:"text",value:c}),m="text"),
c=""):"{"===l?(k++,""!==c&&h.push({type:"text",value:c}),c="",h.push({type:"openBlock",value:k}),m="openBlock"):"}"===l?(""!==c&&h.push({type:"text",value:c}),c="",h.push({type:"closeBlock",value:k}),m="closeBlock",k--):""===c&&" "===l&&"controlWord"===m?m="text":c+=l,f++;""!==c&&h.push({type:"text",value:c});return h};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k,l,e,p,m,n,t,s,u,q,r,w,v,z,B,C,x,D,E,F,A,H,J,I,L;a.RTFParser=function(c){this.evaluator=c;this.tokenizer=
new a.RTFTokenizer};a.RTFParser.prototype.parse=function(y){y=d=this.tokenizer.tokenize(y);for(var K=[],G=!1,M=!1,N=[],O=0,S=y.length;O<S;O++){"openBlock"==y[O].type&&N.push(y[O].value);"closeBlock"==y[O].type&&(N.pop(),0>=N.length&&(G=!1));if("controlWord"==y[O].type&&("expr"==y[O].value||"decimals"==y[O].value))M=!0;"controlWord"==y[O].type&&"mjaformula"==y[O].value&&(G=!0);if("text"==y[O].type&&G&&!M){for(var T=0,Q=y[O].value,R="",P=0,W=Q.length;P<W;P++)if("("==Q.charAt(P)||")"==Q.charAt(P)||"+"==
Q.charAt(P)||"-"==Q.charAt(P)||"*"==Q.charAt(P)||"="==Q.charAt(P))R=Q.substring(T,P),""!=R&&K.push({type:"text",value:R}),K.push({type:Q.charAt(P),value:Q.charAt(P)}),T=P+1;R=Q.substring(T,P);""!=R&&K.push({type:"text",value:R})}else K.push(y[O]),"text"==y[O].type&&M&&(M=!1)}d=K;h={};c=2;if("openBlock"==d[0].type&&"fonttbl"==d[1].value){for(g=d[0].value;"closeBlock"!=d[c].type&&d[c].value!=g;)h[d[c].value]=d[c+2].value.substring(0,d[c+2].value.length-1),c+=3;c++}f={};k=0;if("openBlock"==d[c].type&&
"colortbl"==d[c+1].value){g=d[c++].value;for(c++;"closeBlock"!=d[c].type&&d[c].value!=g;)l=parseInt(d[c++].value.substring(3)).toString(16),e=parseInt(d[c++].value.substring(5)).toString(16),p=parseInt(d[c++].value.substring(4)).toString(16),";"===d[c].value&&c++,f[k++]="#"+(2>l.length?"0"+l:l)+(2>e.length?"0"+e:e)+(2>p.length?"0"+p:p);c++}m=new a.RTFNode(this.evaluator,"","textBlock","",!1,"");n=new a.RTFNode(this.evaluator,"","textLineBlock","",!1,"");m.addChild(n);u=s=t=null;B=z=v=w=r=q=!1;C=[new a.FontStyle(20,
"Arial","","",!1,!1,null)];x=C[0];D=!0;F=E=-1;A=[];L=I=J=H=!1;y=c;for(K=d.length;y<K;y++)if("controlWord"==d[y].type&&h[d[y].value])x.fontType=h[d[y].value];else if("controlWord"==d[y].type&&d[y].value.match(/^fs(\d+)/))x.fontSize=parseInt(d[y].value.match(/^fs(\d+)/)[1]/2);else if("controlWord"==d[y].type&&"b"==d[y].value)x.textBold="bold";else if("controlWord"==d[y].type&&"b0"==d[y].value)x.textBold="";else if("controlWord"==d[y].type&&"i"==d[y].value)x.textItalic="italic";else if("controlWord"==
d[y].type&&"i0"==d[y].value)x.textItalic="";else if("controlWord"==d[y].type&&"ul"==d[y].value)x.textUnderline=!0;else if("controlWord"==d[y].type&&"ulnone"==d[y].value)x.textUnderline=!1;else if("controlWord"==d[y].type&&"ol"==d[y].value)x.textOverline=!0;else if("controlWord"==d[y].type&&"olnone"==d[y].value)x.textOverline=!1;else if("controlWord"==d[y].type&&d[y].value.match(/^cf(\d+)/))x.textColor=f[parseInt(d[y].value.substring(2))];else if("openBlock"==d[y].type)E=d[y].value,x=x.clone(),C.push(x),
A.push(null);else if("closeBlock"==d[y].type)d[y].value==F&&(F=-1,q=!1,n=n.parent),C.pop(),x=C[C.length-1],A.pop();else if("controlWord"==d[y].type&&"par"==d[y].value){n.addChild(new a.RTFNode(this.evaluator,"","newLine",x.clone()));m=new a.RTFNode(this.evaluator,"","textLineBlock",x.clone());if("textBlock"!=n.nodeType)for(n=n.parent;"textBlock"!=n.nodeType;)n=n.parent;n.addChild(m);n=m}else if("controlWord"==d[y].type&&"mjaformula"==d[y].value)H=!0,F=E,q=!0,m=new a.RTFNode(this.evaluator,"","formula",
x.clone()),n.addChild(m),n=m,A[A.length-1]=m;else if("controlWord"==d[y].type&&("fraction"==d[y].value||"radicand"==d[y].value||"radical"==d[y].value||"what"==d[y].value||"sum"==d[y].value||"integral"==d[y].value||"limit"==d[y].value))G=A[A.length-2].style.clone(),m=new a.RTFNode(this.evaluator,"",d[y].value,G),A[A.length-2].addChild(m),A[A.length-1]=m;else if("controlWord"==d[y].type&&"index"==d[y].value||"to"==d[y].value||"from"==d[y].value)G=A[A.length-2].style.clone(),G.fontSize=parseInt(G.fontSize-
0.2*G.fontSize),8>G.fontSize&&(G.fontSize=8),m=new a.RTFNode(this.evaluator,"",d[y].value,G),A[A.length-2].addChild(m),A[A.length-1]=m;else if("controlWord"==d[y].type&&("num"==d[y].value||"den"==d[y].value))G=A[A.length-2].style.clone(),G.fontSize=Math.round(G.fontSize-0.1*G.fontSize),8>G.fontSize&&(G.fontSize=8),"num"==d[y].value?m=new a.RTFNode(this.evaluator,"","numerator",G):"den"==d[y].value&&(m=new a.RTFNode(this.evaluator,"","denominator",G)),A[A.length-2].addChild(m),A[A.length-1]=m;else if("controlWord"==
d[y].type&&("subix"==d[y].value||"supix"==d[y].value))G=A[A.length-2].style.clone(),G.fontSize=Math.floor(G.fontSize-G.fontSize/3),8>G.fontSize&&(G.fontSize=8),"subix"==d[y].value?m=new a.RTFNode(this.evaluator,"","subIndex",G):"supix"==d[y].value&&(m=new a.RTFNode(this.evaluator,"","superIndex",G)),m.originalStyle=A[A.length-2].style.clone(),A[A.length-2].addChild(m),A[A.length-1]=m;else if("controlWord"==d[y].type&&("defparts"==d[y].value||"matrix"==d[y].value||"element"==d[y].value))G=A[A.length-
2].style.clone(),m=new a.RTFNode(this.evaluator,"",d[y].value,G),A[A.length-2].addChild(m),A[A.length-1]=m,"defparts"==d[y].value?u=m:"matrix"==d[y].value&&(s=m);else if("controlWord"==d[y].type&&"parts"==d[y].value)B=!0;else if("text"==d[y].type&&B)u.parts=parseInt(d[y].value),B=!1;else if("controlWord"==d[y].type&&"rows"==d[y].value)v=!0;else if("text"==d[y].type&&v)s.rows=parseInt(d[y].value),v=!1;else if("controlWord"==d[y].type&&"columns"==d[y].value)z=!0;else if("text"==d[y].type&&z)s.columns=
parseInt(d[y].value),z=!1;else if("controlWord"==d[y].type&&"expr"==d[y].value)D=!1,r=!0;else if("controlWord"==d[y].type&&"decimals"==d[y].value)w=!0;else if("text"==d[y].type&&w)t.decimals=this.evaluator.parser.parse(parseInt(d[y].value)+""),w=!1;else if("controlWord"==d[y].type&&"fixed1"==d[y].value)t.fixed=!0;else if("controlWord"==d[y].type&&"fixed0"==d[y].value)t.fixed=!1;else if(!("controlWord"==d[y].type&&"component"==d[y].value))if("controlWord"==d[y].type&&"NumCtrl"==d[y].value)J=!0;else if("controlWord"==
d[y].type&&"Space"==d[y].value)I=!0;else if("controlWord"==d[y].type&&"hyperlink"==d[y].value)L=!0;else if("text"==d[y].type&&L){textContent=d[y].value.split("|")[0];G=x.clone();m=new a.RTFNode(this.evaluator,textContent,"hyperlink",G);if("textLineBlock"!=n.nodeType)for(n=n.parent;"textLineBlock"!=n.nodeType;)n=n.parent;n.addChild(m);L=!1}else if("text"==d[y].type&&J)m=new a.RTFNode(this.evaluator,d[y].value,"componentNumCtrl",x.clone()),n.addChild(m),J=!1;else if("text"==d[y].type&&I)m=new a.RTFNode(this.evaluator,
d[y].value,"componentSpace",x.clone()),n.addChild(m),I=!1;else if("text"==d[y].type&&r)G=A[A.length-2].style.clone(),textContent=this.evaluator.parser.parse(d[y].value),m=new a.RTFNode(this.evaluator,textContent,"dynamicText",G),A[A.length-2].addChild(m),t=A[A.length-1]=m,r=!1;else if("text"==d[y].type&&!r&&!q){textContent=d[y].value;m=new a.RTFNode(this.evaluator,textContent,"text",x.clone());if("textLineBlock"!=n.nodeType)for(n=n.parent;"textLineBlock"!=n.nodeType;)n=n.parent;n.addChild(m)}else if("text"==
d[y].type&&!r&&q)textContent=d[y].value,m=new a.RTFNode(this.evaluator,textContent,"text",A[A.length-1].style.clone()),A[A.length-1].addChild(m);else if("("==d[y].type||")"==d[y].type)G=A[A.length-1].style.clone(),G.textItalic="",m=new a.RTFNode(this.evaluator,d[y].type,"mathSymbol",G),A[A.length-1].addChild(m);else if("+"==d[y].type||"-"==d[y].type||"*"==d[y].type||"="==d[y].type)m=new a.RTFNode(this.evaluator,d[y].type,"mathSymbol",A[A.length-1].style.clone()),A[A.length-1].addChild(m);if(null!=
n){var U=n.getRoot();U.stableWidth=D;U.getTextMetrics();U.hasFormula=H}return U};a.FontStyle=function(a,c,d,e,g,f,h){this.fontSize=a;this.fontType=c;this.textItalic=d;this.textBold=e;this.textUnderline=g;this.textOverline=f;this.textColor=h};a.FontStyle.prototype.toString=function(){return(this.textBold+" "+this.textItalic+" "+this.fontSize+"px "+this.fontType).trim()};a.FontStyle.prototype.toCSS=function(){var a="style='font: "+this.fontSize+"px "+this.fontType+"; ";this.textUnderline&&!this.textOverline&&
(a+="text-decoration: underline; ");!this.textUnderline&&this.textOverline&&(a+="text-decoration: overline; ");this.textUnderline&&this.textOverline&&(a+="text-decoration: underline overline; ");this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: bold; ");!this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: normal; ");this.textBold&&this.textItalic&&(a+="font-style: italic; font-weight: bold; ");!this.textBold&&!this.textItalic&&(a+="font-style: normal; font-weight: normal; ");
this.textColor&&(a+="color: "+this.textColor+"; ");return a+"'"};a.FontStyle.prototype.clone=function(){return new a.FontStyle(this.fontSize,this.fontType,this.textItalic,this.textBold,this.textUnderline,this.textOverline,this.textColor)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c,f,k,l,e,p,m,n,t,s,u,q;a.Space=function(c,d){this.parent=c;h=this.evaluator=this.parent.evaluator;g=h.parser;this.values=d;this.type="R2";this.xExpr=g.parse("0");this.yExpr=g.parse("0");
this.w=parseInt(c.container.width);this.h=parseInt(c.container.height);this.drawif=g.parse("1");this.fixed=2!=c.version?!1:!0;this.scale=48;this.Oy=this.Ox=0;this.image=new Image;this.image.onload=function(){this.ready=1};this.imageSrc="";this.bg_display="topleft";this.background="descinst.com.mja.descartes.DescartesJS.class"===c.code||c.arquimedes?new a.Color("f0f8fa"):new a.Color("ffffff");this.net=2!=c.version?new a.Color("c0c0c0"):"";this.net10=2!=c.version?new a.Color("808080"):"";this.axes=
2!=c.version?new a.Color("808080"):"";this.text=new a.Color("ffafaf");this.numbers=!1;this.x_axis=2!=c.version?"":" ";this.y_axis=2!=c.version?"":" ";this.sensitive_to_mouse_movements=!1;this.cID="";this.mouse_y=this.mouse_x=0;this.ctrs=[];this.graphicsCtr=[];this.graphics=[];this.backgroundGraphics=[];this.zIndex=c.zIndex;this.plecaHeight=c.plecaHeight||0;this.displaceRegionNorth=c.displaceRegionNorth||0;this.displaceRegionWest=c.displaceRegionWest||0;for(var e in d)d.hasOwnProperty(e)&&(this[e]=
d[e]);this.init()};a.Space.prototype.init=function(){d=this.parent;h=this.evaluator;c=this.id;this.displaceRegionNorth=d.displaceRegionNorth||0;this.displaceRegionWest=d.displaceRegionWest||0;l=parseInt(d.container.height);e=parseInt(d.container.width);h.setVariable(c+"._w",this.w);h.setVariable(c+"._h",this.h);this.x=h.evalExpression(this.xExpr)+this.displaceRegionWest;this.y=h.evalExpression(this.yExpr)+this.plecaHeight+this.displaceRegionNorth;this.container&&(this.container.style.left=this.x+
"px",this.container.style.top=this.y+"px");0<=this.y?(f=l-this.y,this.h>f&&(this.h=f)):(f=this.h+this.y,this.h=f>=l?l:f);0<=this.x?(k=e-this.x,this.w>k&&(this.w=k)):(k=this.w+this.x,this.w=k>=e?e:k);if(""!=this.imageSrc||!this.imageSrc.trim().toLowerCase().match(/vacio.gif$/))this.image=d.getImage(this.imageSrc);this.OxExpr&&(m=this.OxExpr,"%"===m[m.length-1]?this.Ox=this.w*parseFloat(m)/100:(p=parseFloat(m),p!=m&&(p=0),this.Ox=p));this.OyExpr&&(n=this.OyExpr,"%"===n[n.length-1]?this.Oy=this.h*parseFloat(n)/
100:(p=parseFloat(n),p!=n&&(p=0),this.Oy=p));2!==d.version?(h.setVariable(c+"._w",this.w),h.setVariable(c+"._h",this.h),h.setVariable(c+".escala",this.scale),h.setVariable(c+".Ox",this.Ox),h.setVariable(c+".Oy",this.Oy),h.setVariable(c+".mouse_x",0),h.setVariable(c+".mouse_y",0),h.setVariable(c+".mouse_pressed",0)):(p=h.getVariable("_w"),void 0===p&&(p=this.w),h.setVariable("_w",p),p=h.getVariable("_h"),void 0===p&&(p=this.h),h.setVariable("_h",p),p=h.getVariable("escala"),void 0===p&&(p=this.scale),
h.setVariable("escala",p),p=h.getVariable("Ox"),void 0===p&&(p=this.Ox),h.setVariable("Ox",p),p=h.getVariable("Oy"),void 0===p&&(p=this.Oy),h.setVariable("Oy",p),h.setVariable("mouse_x",0),h.setVariable("mouse_y",0),h.setVariable("mouse_pressed",0),""===this.x_axis&&""===this.y_axis&&(this.axes=""));this.w_2=this.w/2;this.h_2=this.h/2};a.Space.prototype.addCtr=function(a){"graphic"===a.type?this.graphicsCtr.push(a):this.ctrs.push(a)};a.Space.prototype.addGraph=function(a){a.background?this.backgroundGraphics.push(a):
this.graphics.push(a)};a.Space.prototype.getRelativeX=function(a){return(a-this.w_2-this.Ox)/this.scale};a.Space.prototype.getRelativeY=function(a){return(-a+this.h_2+this.Oy)/this.scale};a.Space.prototype.getAbsoluteX=function(a){return a*this.scale+this.w_2+this.Ox};a.Space.prototype.getAbsoluteY=function(a){return-a*this.scale+this.h_2+this.Oy};a.Space.prototype.findOffset=function(){t=this.container;this.offsetTop=this.offsetLeft=0;s=this.container.style.display;for(this.container.style.display=
"block";t;){u=null;t.getAttribute&&(u=t.getAttribute("class"));if(u&&("DescartesSpace2DContainer"===u||"DescartesSpace3DContainer"===u||"DescartesAppContainer"===u))this.offsetLeft+=t.offsetLeft||0,this.offsetTop+=t.offsetTop||0;t=t.parentNode}this.container.style.display=s};a.Space.prototype.getCursorPosition=function(c){q=a.getCursorPosition(c);return{x:q.x-this.offsetLeft,y:q.y-this.offsetTop}};return a}(descartesJS||{}),descartesJS=function(a){var d,h;if(a.loadLib)return a;var g=Math.floor,c=
Math.round,f=2*Math.PI,k=a.convertFont("SansSerif,PLAIN,12"),l=a.convertFont("Monospaced,PLAIN,12"),e,p,m,n,t,s,u,q,r,w,v,z,B,C,x,D,E,F,A,H,J,I,L,y,K,G,M,N,O;a.Space2D=function(c,d){a.Space.call(this,c,d);e=this;e.backgroundCanvas=document.createElement("canvas");e.backgroundCanvas.setAttribute("id",e.id+"_background");e.backgroundCanvas.setAttribute("width",e.w+"px");e.backgroundCanvas.setAttribute("height",e.h+"px");e.backgroundCtx=e.backgroundCanvas.getContext("2d");e.backgroundCtx.imageSmoothingEnabled=
!1;e.backgroundCtx.mozImageSmoothingEnabled=!1;e.backgroundCtx.webkitImageSmoothingEnabled=!1;e.canvas=document.createElement("canvas");e.canvas.setAttribute("id",e.id+"_canvas");e.canvas.setAttribute("width",e.w+"px");e.canvas.setAttribute("height",e.h+"px");e.canvas.setAttribute("class","DescartesSpace2DCanvas");e.canvas.setAttribute("style","z-index: "+e.zIndex+";");e.ctx=e.canvas.getContext("2d");e.ctx.imageSmoothingEnabled=!1;e.ctx.mozImageSmoothingEnabled=!1;e.ctx.webkitImageSmoothingEnabled=
!1;e.graphicControlContainer=document.createElement("div");e.graphicControlContainer.setAttribute("id",e.id+"_graphicControls");e.graphicControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+e.zIndex+";");e.numericalControlContainer=document.createElement("div");e.numericalControlContainer.setAttribute("id",e.id+"_numericalControls");e.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+e.zIndex+";");e.container=
document.createElement("div");e.container.setAttribute("id",e.id);e.container.setAttribute("class","DescartesSpace2DContainer");e.container.setAttribute("style","left: "+e.x+"px; top: "+e.y+"px; z-index: "+e.zIndex+";");e.parent.arquimedes&&"#f0f8fa"===e.background.getColor()&&(e.container.style.border="1px solid #b8c4c8");e.container.appendChild(e.backgroundCanvas);e.container.appendChild(e.canvas);e.container.appendChild(e.graphicControlContainer);e.container.appendChild(e.numericalControlContainer);
c.container.insertBefore(e.container,c.loader);e.parent.images[e.id+".image"]=e.canvas;e.parent.images[e.id+".image"].ready=1;e.parent.images[e.id+".image"].complete=!0;e.evaluator.setVariable(e.id+".image",e.id+".image");e.parent.images[e.id+".back"]=e.backgroundCanvas;e.parent.images[e.id+".back"].ready=1;e.parent.images[e.id+".back"].complete=!0;e.evaluator.setVariable(e.id+".back",e.id+".back");e.OxString=2!==c.version?e.id+".Ox":"Ox";e.OyString=2!==c.version?e.id+".Oy":"Oy";e.scaleString=2!==
c.version?e.id+".escala":"escala";e.wString=e.id+"._w";e.hString=e.id+"._h";"descartesJS_scenario"!==e.id&&e.registerMouseAndTouchEvents()};a.extend(a.Space2D,a.Space);a.Space2D.prototype.init=function(){e=this;e.uber.init.call(e);e.canvas&&(e.backgroundCanvas.setAttribute("width",e.w+"px"),e.backgroundCanvas.setAttribute("height",e.h+"px"),e.canvas.setAttribute("width",e.w+"px"),e.canvas.setAttribute("height",e.h+"px"));e.container&&e.findOffset()};a.Space2D.prototype.update=function(a){e=this;p=
e.evaluator;m=e.parent;p.setVariable(e.wString,e.w);p.setVariable(e.hString,e.h);e.drawIfValue=0<p.evalExpression(e.drawif);if(e.drawIfValue){t=e.x!==p.evalExpression(e.xExpr)+e.displaceRegionWest;s=e.y!==p.evalExpression(e.yExpr)+m.plecaHeight+e.displaceRegionNorth;e.spaceChange=a||t||s||e.drawBefore!==e.drawIfValue||e.Ox!==p.getVariable(e.OxString)||e.Oy!==p.getVariable(e.OyString)||e.scale!==p.getVariable(e.scaleString);e.x=t?p.evalExpression(e.xExpr)+e.displaceRegionWest:e.x;e.y=s?p.evalExpression(e.yExpr)+
m.plecaHeight+e.displaceRegionNorth:e.y;e.Ox=p.getVariable(e.OxString);e.Oy=p.getVariable(e.OyString);e.scale=p.getVariable(e.scaleString);e.drawBefore=e.drawIfValue;1E-6>e.scale?(e.scale=1E-6,p.setVariable(e.scaleString,1E-6)):1E6<e.scale&&(e.scale=1E6,p.setVariable(e.scaleString,1E6));if(t||s)e.container.style.left=e.x+"px",e.container.style.top=e.y+"px",e.findOffset();e.container.style.display="block";e.drawTrace=!e.spaceChange&&!e.click;e.spaceChange&&e.drawBackground();e.draw()}else e.container.style.display=
"none"};a.Space2D.prototype.drawBackground=function(){p=this.evaluator;n=this.backgroundCtx;n.clearRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);n.fillStyle=this.background.getColor();n.fillRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?n.drawImage(this.image,0,0):"stretch"===this.bg_display?n.drawImage(this.image,0,0,this.w,this.h):"patch"===this.bg_display?
(n.fillStyle=n.createPattern(this.image,"repeat"),n.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&n.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));q=this.scale;r=0;for(w=0>this.w+this.h?0:this.w+this.h;q>w;)q/=10,r++;for(;q<w/10;)q*=10;n.lineWidth=1;""!==this.net&&(n.strokeStyle=this.net.getColor(),this.drawMarks(n,q/10,-1));if(2!==this.parent.version&&""!==this.net10||2===this.parent.version&&""!==this.net&&""!==this.net10)n.strokeStyle=
this.net10.getColor(),this.drawMarks(n,q,-1);if(""!==this.axes){n.strokeStyle=this.axes.getColor();n.beginPath();if(""!==this.x_axis||2!==this.parent.version)n.moveTo(0,g(this.h/2+this.Oy)+0.5),n.lineTo(this.w,g(this.h/2+this.Oy)+0.5);if(""!==this.y_axis||2!==this.parent.version)n.moveTo(g(this.w/2+this.Ox)+0.5,0),n.lineTo(g(this.w/2+this.Ox)+0.5,this.h);n.stroke();this.drawMarks(n,q,4);this.drawMarks(n,q/2,2);this.drawMarks(n,q/10,1)}if(""!==this.x_axis||""!==this.y_axis)n.fillStyle=this.axes.getColor(),
n.font=k,n.textAlign="right",n.textBaseline="alphabetic",n.fillText(this.x_axis,g(this.w)-2,g(this.h/2+this.Oy)+12),n.fillText(this.y_axis,g(this.w/2+this.Ox)-2,12);this.numbers&&""!=this.axes&&(n.fillStyle=this.axes.getColor(),n.font=k,n.textAlign="start",n.textBaseline="bottom",q>(this.w+this.h)/2?this.drawNumbers(n,q/5,q<=this.scale?r+1:r):q>(this.w+this.h)/4?this.drawNumbers(n,q/2,q<=this.scale?r+1:r):this.drawNumbers(n,q,r));for(var a=0,c=this.backgroundGraphics.length;a<c;a++)this.backgroundGraphics[a].draw()};
a.Space2D.prototype.draw=function(){n=this.ctx;n.clearRect(0,0,this.canvas.width,this.canvas.height);for(var a=0,c=this.graphics.length;a<c;a++)u=this.graphics[a],""!==u.trace&&this.drawTrace&&u.drawTrace(),u.draw();a=0;for(c=this.graphicsCtr.length;a<c;a++)this.graphicsCtr[a].draw();""!=this.text&&(this.click&&"L"===this.whichButton)&&(console.log("aqui"),n.fillStyle=this.text.getColor(),n.strokeStyle=n.fillStyle,n.lineWidth=1,n.font=l,n.textAlign="center",n.textBaseline="alphabetic",J=1>=this.scale?
this.mouse_x.toFixed(0):this.mouse_x.toFixed(this.scale.toString().length),I=1>=this.scale?this.mouse_y.toFixed(0):this.mouse_y.toFixed(this.scale.toString().length),L="("+J+","+I+")",y=g(n.measureText(L).width/2),K=this.getAbsoluteX(this.mouse_x),G=this.getAbsoluteY(this.mouse_y),M=g(K),N=g(G-10),M+y>this.w?M=this.w-y:0>M-y&&(M=y),N+1>this.h?N=this.h:0>N-14&&(N=15),n.fillText(L,M,N),n.beginPath(),n.arc(K,G,2.5,0,f,!0),n.stroke())};a.Space2D.prototype.drawMarks=function(a,d,e){v=this.w;z=this.h;E=
0;F=v;A=0;H=z;x=g(v/2+this.Ox);D=g(z/2+this.Oy);0<=e&&(E=x-e,F=x+e,A=D-e,H=D+e);a.beginPath();for(e=-c(x/d);(B=x+c(e*d))<v;e++)a.moveTo(B+0.5,A+0.5),a.lineTo(B+0.5,H+0.5);for(e=-c(D/d);(C=D+c(e*d))<z;e++)a.moveTo(E+0.5,C+0.5),a.lineTo(F+0.5,C+0.5);a.stroke()};a.Space2D.prototype.drawNumbers=function(a,d,e){v=this.w;z=this.h;x=g(v/2+this.Ox);D=g(z/2+this.Oy);for(e=-c(x/d);(B=x+c(e*d))<v;e++)a.fillText(parseFloat((e*d/this.scale).toFixed(4)),B+1,D-2);for(e=-c(D/d);(C=D+c(e*d))<z;e++)0!==parseFloat(-e*
d/this.scale)&&a.fillText(parseFloat((-e*d/this.scale).toFixed(4)),x+5,C+5)};a.Space2D.prototype.registerMouseAndTouchEvents=function(){function c(a){p.click=1;p.evaluator.setVariable(p.id+".mouse_pressed",1);p.parent.deactivateGraphiControls();l(a);window.addEventListener("touchmove",n);window.addEventListener("touchend",e);a.preventDefault()}function e(a){p.click=0;p.evaluator.setVariable(p.id+".mouse_pressed",0);window.removeEventListener("touchmove",n,!1);window.removeEventListener("touchend",
e,!1);a.preventDefault();p.parent.update()}function f(c){p.click=1;p.evaluator.setVariable(p.id+".mouse_pressed",1);p.parent.deactivateGraphiControls();p.whichButton=a.whichButton(c);"R"===p.whichButton&&(window.addEventListener("mouseup",k),p.fixed||(p.clickPosForZoom=p.getCursorPosition(c).y,p.tempScale=p.scale,window.addEventListener("mousemove",m)));"L"===p.whichButton&&(p.evaluator.setVariable(p.id+".mouse_pressed",1),l(c),window.addEventListener("mousemove",n),window.addEventListener("mouseup",
k));c.preventDefault()}function k(a){p.click=0;p.evaluator.setVariable(p.id+".mouse_pressed",0);a.preventDefault();"R"===p.whichButton&&window.removeEventListener("mousemove",m,!1);p.sensitive_to_mouse_movements||window.removeEventListener("mousemove",n,!1);window.removeEventListener("mouseup",k,!1);p.parent.update()}function l(a){p.posAnte=p.getCursorPosition(a);p.mouse_x=p.getRelativeX(p.posAnte.x);p.mouse_y=p.getRelativeY(p.posAnte.y);p.evaluator.setVariable(p.id+".mouse_x",p.mouse_x);p.evaluator.setVariable(p.id+
".mouse_y",p.mouse_y);p.parent.update()}function m(a){a.preventDefault();p.clickPosForZoomNew=p.getCursorPosition(a).y;p.evaluator.setVariable(p.scaleString,p.tempScale+p.tempScale/45*((p.clickPosForZoom-p.clickPosForZoomNew)/10));p.parent.update()}function n(a){p.fixed||(p.posNext=p.getCursorPosition(a),d=g(p.posAnte.x-p.posNext.x),h=g(p.posAnte.y-p.posNext.y),p.evaluator.setVariable(p.OxString,p.Ox-d),p.evaluator.setVariable(p.OyString,p.Oy-h),p.posAnte.x-=d,p.posAnte.y-=h);l(a);a.preventDefault()}
var p=this;O=a.hasTouchSupport;p.canvas.oncontextmenu=function(){return!1};O&&(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("touchmove",l),this.canvas.addEventListener("touchstart",c));O||(this.sensitive_to_mouse_movements&&this.canvas.addEventListener("mousemove",l),this.canvas.addEventListener("mousedown",f))};return a}(descartesJS||{}),descartesJS=function(a){function d(a,c){return c.depth-a.depth}if(a.loadLib)return a;var h=Math.round,g=Math.cos,c=Math.sin,f=Math.PI/2,k,l,e,
p,m,n,t,s,u,q,r,w,v;a.Space3D=function(d,h){a.Space.call(this,d,h);e=this;e.backgroundCanvas=document.createElement("canvas");e.backgroundCanvas.setAttribute("id",e.id+"_background");e.backgroundCanvas.setAttribute("width",e.w+"px");e.backgroundCanvas.setAttribute("height",e.h+"px");e.backgroundCtx=e.backgroundCanvas.getContext("2d");e.backgroundCtx.imageSmoothingEnabled=!1;e.backgroundCtx.mozImageSmoothingEnabled=!1;e.backgroundCtx.webkitImageSmoothingEnabled=!1;e.canvas=document.createElement("canvas");
e.canvas.setAttribute("id",e.id+"_canvas");e.canvas.setAttribute("width",e.w+"px");e.canvas.setAttribute("height",e.h+"px");e.canvas.setAttribute("class","DescartesSpace3DCanvas");e.canvas.setAttribute("style","z-index: "+e.zIndex+";");e.ctx=e.canvas.getContext("2d");e.ctx.imageSmoothingEnabled=!1;e.ctx.mozImageSmoothingEnabled=!1;e.ctx.webkitImageSmoothingEnabled=!1;e.graphicControlContainer=document.createElement("div");e.graphicControlContainer.setAttribute("id",e.id+"_graphicControls");e.graphicControlContainer.setAttribute("style",
"position: absolute; left: 0px; top: 0px; z-index: "+e.zIndex+";");e.numericalControlContainer=document.createElement("div");e.numericalControlContainer.setAttribute("id",e.id+"_numericalControls");e.numericalControlContainer.setAttribute("style","position: absolute; left: 0px; top: 0px; z-index: "+e.zIndex+";");e.container=document.createElement("div");e.container.setAttribute("id",e.id);e.container.setAttribute("class","DescartesSpace3DContainer");e.container.setAttribute("style","left: "+e.x+"px; top: "+
e.y+"px; z-index: "+e.zIndex+";");e.container.appendChild(e.backgroundCanvas);e.container.appendChild(e.canvas);e.container.appendChild(e.graphicControlContainer);e.container.appendChild(e.numericalControlContainer);d.container.insertBefore(e.container,d.loader);e.observer=2E3;e.evaluator.setVariable(e.id+".observador",2E3);e.eye=new a.Vector3D(0,0,0);e.center=new a.Vector3D(0,0,0);e.yUpEye=new a.Vector3D(0,0,1);e.distanceEyeCenter=e.observer/(4*e.scale);e.alpha=0;e.beta=0;e.evaluator.setVariable(e.id+
".rot.z",e.alpha);e.evaluator.setVariable(e.id+".rot.y",-e.beta);e.lookAtMatrix=new a.Matrix4x4;e.perspectiveMatrix=new a.Matrix4x4;e.perspective=(new a.Matrix4x4).perspective(45,e.w/e.h,0.01,1E3);q=g(-e.alpha);r=c(-e.alpha);w=g(e.beta);v=c(e.beta);e.eye.set(e.distanceEyeCenter*q*w,e.distanceEyeCenter*r*w,-e.distanceEyeCenter*v);e.yUpEye=e.yUpEye.set(g(-e.alpha-f),c(-e.alpha-f),0).crossProduct(e.eye).normalize();e.lookAtMatrix=e.lookAtMatrix.setIdentity().lookAt(e.eye,e.center,e.yUpEye);e.perspectiveMatrix=
e.perspective.multiply(e.lookAtMatrix);e.OxString=e.id+".Ox";e.OyString=e.id+".Oy";e.scaleString=e.id+".escala";e.wString=e.id+"._w";e.hString=e.id+"._h";e.observerString=e.id+".observador";e.update();e.registerMouseAndTouchEvents()};a.extend(a.Space3D,a.Space);a.Space3D.prototype.init=function(){e=this;e.uber.init.call(e);e.canvas&&(e.backgroundCanvas.setAttribute("width",e.w+"px"),e.backgroundCanvas.setAttribute("height",e.h+"px"),e.canvas.setAttribute("width",e.w+"px"),e.canvas.setAttribute("height",
e.h+"px"));e.container&&e.findOffset();e.w_2=e.w/2;e.h_2=e.h/2;e.oldMouse={x:0,y:0}};a.Space3D.prototype.update=function(a){e=this;k=e.evaluator;l=e.parent;k.setVariable(e.wString,e.w);k.setVariable(e.hString,e.h);e.drawIfValue=0<k.evalExpression(e.drawif);if(e.drawIfValue){s=e.x!==k.evalExpression(e.xExpr)+e.displaceRegionWest;u=e.y!==k.evalExpression(e.yExpr)+l.plecaHeight+e.displaceRegionNorth;e.spaceChange=a||s||u||e.drawBefore!==e.drawIfValue||e.Ox!==k.getVariable(e.OxString)||e.Oy!==k.getVariable(e.OyString)||
e.scale!==k.getVariable(e.scaleString);e.x=s?k.evalExpression(e.xExpr)+e.displaceRegionWest:e.x;e.y=u?k.evalExpression(e.yExpr)+l.plecaHeight+e.displaceRegionNorth:e.y;e.Ox=k.getVariable(e.OxString);e.Oy=k.getVariable(e.OyString);e.scale=k.getVariable(e.scaleString);e.drawBefore=e.drawIfValue;e.observer=k.getVariable(e.observerString);1E-6>e.scale?(e.scale=1E-6,k.setVariable(e.scaleString,1E-6)):1E6<e.scale&&(e.scale=1E6,k.setVariable(e.scaleString,1E6));if(s||u)e.container.style.left=e.x+"px",e.container.style.top=
e.y+"px",e.findOffset();e.container.style.display="block";e.draw()}else e.container.style.display="none"};a.Space3D.prototype.draw=function(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.fillStyle=this.background.getColor();this.ctx.fillRect(0,0,this.backgroundCanvas.width,this.backgroundCanvas.height);this.image&&(""!=this.image.src&&this.image.ready&&this.image.complete)&&("topleft"===this.bg_display?this.ctx.drawImage(this.image,0,0):"stretch"===this.bg_display?this.ctx.drawImage(this.image,
0,0,this.w,this.h):"patch"===this.bg_display?(this.ctx.fillStyle=ctx.createPattern(this.image,"repeat"),this.ctx.fillRect(0,0,this.canvas.width,this.canvas.height)):"center"===this.bg_display&&this.ctx.drawImage(this.image,(this.w-this.image.width)/2,(this.h-this.image.height)/2));this.setCamera();this.primitives=[];for(var a=0,c=this.graphics.length;a<c;a++)p=this.graphics[a],p.update(),this.primitives=this.primitives.concat(p.primitives||[]);a=0;for(c=this.backgroundGraphics.length;a<c;a++)p=this.backgroundGraphics[a],
p.update(),this.primitives=this.primitives.concat(p.primitives||[]);m=this.primitives;n=m.length;for(a=0;a<n;a++)m[a].computeDepth(this);m=m.sort(d);for(a=0;a<n;a++)m[a].draw(this.ctx);a=0;for(c=this.graphicsCtr.length;a<c;a++)this.graphicsCtr[a].draw()};a.Space3D.prototype.transformCoordinateX=function(a){return parseInt((a+1)*this.w_2+this.Ox)};a.Space3D.prototype.transformCoordinateY=function(a){return parseInt((1-a)*this.h_2+this.Oy)};a.Space3D.prototype.setCamera=function(){e=this;e.distanceEyeCenter=
e.observer/(4*e.scale);e.alpha=a.degToRad(e.evaluator.getVariable(e.id+".rot.z"));e.beta=a.degToRad(-e.evaluator.getVariable(e.id+".rot.y"));e.alpha=h(a.radToDeg(e.alpha+(e.mouse_x-e.oldMouse.x)));e.beta=h(a.radToDeg(e.beta+(e.mouse_y-e.oldMouse.y)));e.evaluator.setVariable(e.id+".rot.z",e.alpha);e.evaluator.setVariable(e.id+".rot.y",-e.beta);e.alpha=a.degToRad(e.alpha);e.beta=a.degToRad(e.beta);q=g(-e.alpha);r=c(-e.alpha);w=g(e.beta);v=c(e.beta);e.eye.set(e.distanceEyeCenter*q*w,e.distanceEyeCenter*
r*w,-e.distanceEyeCenter*v);e.yUpEye=e.yUpEye.set(g(-e.alpha-f),c(-e.alpha-f),0).crossProduct(e.eye).normalize();e.lookAtMatrix=e.lookAtMatrix.setIdentity().lookAt(e.eye,e.center,e.yUpEye);e.perspectiveMatrix=e.perspective.multiply(e.lookAtMatrix)};a.Space3D.prototype.registerMouseAndTouchEvents=function(){function c(a){e.click=1;e.evaluator.setVariable(e.id+".mouse_pressed",1);e.parent.deactivateGraphiControls();h(a);window.addEventListener("touchmove",l);window.addEventListener("touchend",d);a.preventDefault()}
function d(a){e.click=0;e.evaluator.setVariable(e.id+".mouse_pressed",0);window.removeEventListener("touchmove",l,!1);window.removeEventListener("touchend",d,!1);a.preventDefault()}function g(c){e.click=1;e.parent.deactivateGraphiControls();e.whichButton=a.whichButton(c);"R"===e.whichButton?(window.addEventListener("mouseup",f),e.fixed||(e.clickPosForZoom=e.getCursorPosition(c).y,e.tempScale=e.scale,window.addEventListener("mousemove",k))):"L"==e.whichButton&&(e.evaluator.setVariable(e.id+".mouse_pressed",
1),e.posAnte=e.getCursorPosition(c),e.oldMouse.x=e.getRelativeX(e.posAnte.x),e.oldMouse.y=e.getRelativeY(e.posAnte.y),h(c),window.addEventListener("mousemove",l),window.addEventListener("mouseup",f));c.preventDefault()}function f(a){e.click=0;e.evaluator.setVariable(e.id+".mouse_pressed",0);a.preventDefault();"R"===e.whichButton&&window.removeEventListener("mousemove",k,!1);window.removeEventListener("mousemove",l,!1);window.removeEventListener("mouseup",f,!1)}function h(a){e.posAnte=e.getCursorPosition(a);
e.mouse_x=e.getRelativeX(e.posAnte.x);e.mouse_y=e.getRelativeY(e.posAnte.y);e.evaluator.setVariable(e.id+".mouse_x",e.mouse_x);e.evaluator.setVariable(e.id+".mouse_y",e.mouse_y);e.parent.update()}function k(a){a.preventDefault();e.clickPosForZoomNew=e.getCursorPosition(a).y;e.evaluator.setVariable(e.scaleString,e.tempScale+e.tempScale/45*((e.clickPosForZoom-e.clickPosForZoomNew)/10));e.parent.update()}function l(a){!e.fixed&&e.click&&(h(a),e.setCamera(),e.oldMouse={x:e.mouse_x,y:e.mouse_y})}e=this;
t=a.hasTouchSupport;this.canvas.oncontextmenu=function(){return!1};t&&this.canvas.addEventListener("touchstart",c);t||this.canvas.addEventListener("mousedown",g)};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.SpaceAP=function(h,g){a.Space.call(this,h,g);this.exportarVars=this.importarVars=null;d=h.evaluator;this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=d.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?
this.file=d.parser.parse(this.file):this.file=d.parser.parse("'"+this.file+"'");this.oldFile=d.evalExpression(this.file);this.initFile()};a.extend(a.SpaceAP,a.Space);a.SpaceAP.prototype.initFile=function(){this.firstUpdate=!0;var d;if(this.oldFile){var g=document.getElementById(this.oldFile);d=g&&"descartes/spaceApFile"==g.type?g.text:a.openExternalFile(this.oldFile);null!=d&&(d=d.split("\n"))}if(d&&d.toString().match(/<applet/gi)){for(var g="",c=!1,f=0,k=d.length;f<k&&!(d[f].match("<applet")&&(c=
!0),c&&(g+=d[f]),d[f].match("</applet"));f++);f=document.createElement("div");f.innerHTML=g;f.firstChild.setAttribute("width",this.w);f.firstChild.setAttribute("height",this.h);g=this.descApp?this.descApp.container:null;this.descApp=new a.DescartesApp(f.firstChild);this.descApp.container.setAttribute("class","DescartesAppContainer");this.descApp.container.setAttribute("style","position: absolute; overflow: hidden; background-color: "+this.background+"; width: "+this.w+"px; height: "+this.h+"px; left: "+
this.x+"px; top: "+this.y+"px; z-index: "+this.zIndex+";");g?this.parent.container.replaceChild(this.descApp.container,g):this.parent.container.insertBefore(this.descApp.container,this.parent.loader);g=this.descApp.spaces;f=0;for(k=g.length;f<k;f++)g[f].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";var l=this;this.descApp.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces();l.exportar()}}else g=
this.descApp?this.descApp.container:null,this.descApp={},this.descApp.container=document.createElement("div"),this.descApp.container.setAttribute("class","DescartesAppContainer"),f="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?f+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat;":"stretch"==this.bg_display?
f+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-size: 100% 100%;":"patch"==this.bg_display?f+="background-image: url("+this.imageSrc+");":"center"==this.bg_display&&(f+="background-image: url("+this.imageSrc+"); background-repeat:no-repeat; background-position: center center;")),this.descApp.container.setAttribute("style",f),g?this.parent.container.replaceChild(this.descApp.container,g):this.parent.container.insertBefore(this.descApp.container,this.parent.loader),
this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none"};a.SpaceAP.prototype.update=function(){var a=this.evaluator.evalExpression(this.file);if(this.oldFile!=a)this.oldFile=a,this.initFile();else{var a=this.x!=this.evaluator.evalExpression(this.xExpr),d=this.y!=this.evaluator.evalExpression(this.yExpr)+this.plecaHeight;this.x=a?this.evaluator.evalExpression(this.xExpr):this.x;this.y=d?this.evaluator.evalExpression(this.yExpr)+this.plecaHeight:this.y;a&&(this.descApp.container.style.left=
this.x+"px");d&&(this.descApp.container.style.top=this.y+"px");if(a||d)for(var a=this.descApp.spaces,d=0,c=a.length;d<c;d++)a[d].findOffset();this.descApp.container.style.display=0<this.evaluator.evalExpression(this.drawif)?"block":"none";if(this.firstUpdate&&(this.firstUpdate=!1,null==this.importarVars)){this.importarVars=[];for(var f in this.evaluator.variables)this.evaluator.variables.hasOwnProperty(f)&&f.match(/^public./)&&this.importarVars.push({varName:f,value:this.evaluator.getVariable(f)})}this.importar()}};
a.SpaceAP.prototype.importar=function(){for(var a,d=!1,c=0,f=this.importarVars.length;c<f;c++)a=this.evaluator.getVariable(this.importarVars[c].varName),a!=this.importarVars[c].value&&(this.importarVars[c].value=a,this.descApp.evaluator.setVariable(this.importarVars[c].varName,this.importarVars[c].value),d=!0);d&&this.descApp.update()};a.SpaceAP.prototype.exportar=function(){};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d,h,g,c;a.SpaceHTML_IFrame=function(c,d){a.Space.call(this,
c,d);var g=this.parent.evaluator;window.navigator.userAgent.toLowerCase().match(/firefox/);this.file=this.file?this.file.trim():"";this.file.match(/^\[/)&&this.file.match(/\]$/)?this.file=g.parser.parse(this.file.substring(1,this.file.length-1)):this.file.match(/^\'/)&&this.file.match(/\'$/)?this.file=g.parser.parse(this.file):this.file=g.parser.parse("'"+this.file+"'");this.oldFile=g.evalExpression(this.file);this.MyIFrame=document.createElement("iframe");this.MyIFrame.setAttribute("src",this.oldFile);
this.MyIFrame.setAttribute("id",this.id);this.MyIFrame.setAttribute("marginheight",0);this.MyIFrame.setAttribute("marginwidth",0);this.MyIFrame.setAttribute("frameborder",0);this.MyIFrame.setAttribute("scrolling","auto");this.MyIFrame.setAttribute("style","position: absolute; width: "+this.w+"px; height: "+this.h+"px; left: "+this.x+"px; top: "+this.y+"px;");this.parent.container.insertBefore(this.MyIFrame,this.parent.loader);var e=this;this.MyIFrame.onload=function(a){var c=this;e.evaluator.setFunction(e.id+
".set",function(a,d){c.contentWindow.postMessage({type:"set",name:a,value:d},"*")});e.evaluator.setFunction(e.id+".update",function(){c.contentWindow.postMessage({type:"update"},"*")});e.evaluator.setFunction(e.id+".exec",function(a,d){c.contentWindow.postMessage({type:"exec",name:a,value:d},"*")})};this.update=this.iframeUpdate;this.evaluator.setVariable(this.id+"._scroll",0)};a.extend(a.SpaceHTML_IFrame,a.Space);a.SpaceHTML_IFrame.prototype.init=function(){self=this;self.uber.init.call(self);self.MyIFrame&&
(self.MyIFrame.style.width=self.w+"px",self.MyIFrame.style.height=self.h+"px",self.MyIFrame.style.left=self.x+"px",self.MyIFrame.style.top=self.y+"px")};a.SpaceHTML_IFrame.prototype.iframeUpdate=function(a){d=this.evaluator;this.drawIfValue=0<d.evalExpression(this.drawif);if(this.drawif){this.MyIFrame.style.display=this.drawIfValue?"block":"none";a&&(this.y=this.x=Math.Infinity);h=this.x!==d.evalExpression(this.xExpr)+this.displaceRegionWest;g=this.y!==d.evalExpression(this.yExpr)+this.parent.plecaHeight+
this.displaceRegionNorth;this.x=h?d.evalExpression(this.xExpr)+this.displaceRegionWest:this.x;this.y=g?d.evalExpression(this.yExpr)+this.parent.plecaHeight+this.displaceRegionNorth:this.y;if(h||g)this.MyIFrame.style.left=this.x+"px",this.MyIFrame.style.top=this.y+"px";c=d.evalExpression(this.file);c!==this.oldFile&&(this.oldFile=c,this.MyIFrame.setAttribute("src",c));this.scrollVar=d.getVariable(this.id+"._scroll");1==this.scrollVar?(this.MyIFrame.setAttribute("scrolling","yes"),this.MyIFrame.style.overflow=
""):-1==this.scrollVar?(this.MyIFrame.setAttribute("scrolling","no"),this.MyIFrame.style.overflow="hidden"):(this.MyIFrame.setAttribute("scrolling","auto"),this.MyIFrame.style.overflow="")}};return a}(descartesJS||{}),descartesJS=function(a){if(a.loadLib)return a;var d;a.DescartesLoader=function(a){this.children=a.children;this.lessonParser=a.lessonParser;this.images=a.images;this.images.length=a.images.length;this.audios=a.audios;this.audios.length=a.audios.length;this.arquimedes=a.arquimedes;this.descartesApp=
a;var c=a.image_loader?a.image_loader:k(a.loader.width,a.loader.height);this.imageLoader=document.createElement("div");this.imageLoader.width=a.width;this.imageLoader.height=a.height;this.imageLoader.setAttribute("class","DescartesLoaderImage");this.imageLoader.setAttribute("style","background-image: url("+c+"); width: "+a.width+"px; height: "+a.height+"px;");a.loader.appendChild(this.imageLoader);this.loaderBar=document.createElement("canvas");this.loaderBar.width=a.width;this.loaderBar.height=a.height;
this.loaderBar.setAttribute("class","DescartesLoaderBar");this.loaderBar.setAttribute("style","width: "+a.width+"px; height:"+a.height+"px;");this.loaderBar.ctx=this.loaderBar.getContext("2d");a.loader.appendChild(this.loaderBar);this.barWidth=Math.floor(80);this.barHeight=Math.floor(a.loader.height/70);var d=this;this.timer=setInterval(function(){d.drawLoaderBar(d.loaderBar.ctx,a.width,a.height)},10);a.firstRun=!1;this.initPreloader()};a.DescartesLoader.prototype.initPreloader=function(){var c=this.children,
d=this.images,g=this.audios,f=/[\w-//]*(\.png|\.jpg|\.gif|\.svg|\.PNG|\.JPG|\.GIF|\.SVG)/g,h=/[\w-//]*(\.ogg|\.oga|\.mp3|\.wav|\.OGG|\.OGA\.MP3|\.WAV)/g,k=/vector|array|bektore|vecteur|matriz/g,s=/archivo|file|fitxer|artxibo|fichier|arquivo/g;this.arquimedes&&(d["lib/DescartesCCLicense.png"]=a.getCreativeCommonsLicenseImage(),d["lib/DescartesCCLicense.png"].addEventListener("load",function(){this.ready=1}),d["lib/DescartesCCLicense.png"].addEventListener("error",function(){this.errorload=1}));var u,
q,r,w,v,z;w=0;for(v=c.length;w<v;w++){if(u=c[w].value.match(f)){r=0;for(z=u.length;r<z;r++)q=u[r],!q.toLowerCase().match(/vacio.gif$/)&&""!=q.substring(0,q.length-4)&&(d[q]=new Image,d[q].addEventListener("load",function(){this.ready=1}),d[q].addEventListener("error",function(){this.errorload=1}),d[q].src=q)}if(u=c[w].value.match(h)){r=0;for(q=u.length;r<q;r++)this.initAudio(u[r])}(r=c[w].value.match(k)&&c[w].value.match(s))&&this.lessonParser.parseAuxiliar(c[w].value)}for(var B in d)d.hasOwnProperty(B)&&
this.images.length++;for(B in g)g.hasOwnProperty(B)&&this.audios.length++;var C=this,x=this.images.length+this.audios.length,D=function(){C.readys=0;for(var a in d)d.hasOwnProperty(a)&&(d[a].ready||d[a].errorload)&&C.readys++;for(a in C.audios)g.hasOwnProperty(a)&&(g[a].ready||g[a].errorload)&&C.readys++;C.readys!=x?setTimeout(D,30):(clearTimeout(C.timer),C.descartesApp.initBuildApp())};D()};a.DescartesLoader.prototype.initAudio=function(c){var d=this.audios;d[c]=new Audio(c);d[c].filename=c;var g=
function(){this.ready=1},f=function(){!this.canPlayType("audio/"+this.filename.substring(this.filename.length-3))&&"mp3"==this.filename.substring(this.filename.length-3)?(d[c]=new Audio(this.filename.replace("mp3","ogg")),d[c].filename=this.filename.replace("mp3","ogg"),d[c].addEventListener("canplaythrough",g),d[c].addEventListener("load",g),d[c].addEventListener("error",f),d[c].load()):(console.log("El archivo '"+c+"' no puede ser reproducido"),this.errorload=1)};d[c].addEventListener("canplaythrough",
g);d[c].addEventListener("load",g);d[c].addEventListener("error",f);a.hasTouchSupport?(d[c].load(),d[c].play(),d[c].ready=1):d[c].load()};var h,g,c,f;a.DescartesLoader.prototype.drawLoaderBar=function(a,e,k){h=this.barWidth;g=this.barHeight;c=this.images.length+this.audios.length;f=2*(h-2)/c;a.translate(e/2,(k-65*d)/2+90*d);a.scale(d,d);a.strokeRect(-h,-g,2*h,g);a.fillStyle="gray";a.fillRect(-h+2,-g+2,2*(h-2),g-4);a.fillStyle="#1f375d";a.fillRect(-h+2,-g+2,this.readys*f,g-4);a.setTransform(1,0,0,
1,0,0)};var k=function(a,c){var g=document.createElement("canvas");g.width=a;g.height=c;var f=g.getContext("2d");f.save();f.strokeStyle="#1f375d";f.fillStyle="#1f375d";f.lineCap="round";f.lineWidth=2;f.beginPath();d=a<c?a/360:c/195;d=2.5<d?2.5:d;f.translate((a-120*d)/2,(c-65*d)/2);f.scale(d,d);f.moveTo(3,25);f.lineTo(3,1);f.lineTo(21,1);f.bezierCurveTo(33,1,41,15,41,25);f.stroke();f.beginPath();f.moveTo(1,63);f.lineTo(1,64);f.moveTo(5,62);f.lineTo(5,64);f.moveTo(9,61);f.lineTo(9,64);f.moveTo(13,60);
f.lineTo(13,64);f.moveTo(17,58);f.lineTo(17,64);f.moveTo(21,56);f.lineTo(21,64);f.moveTo(25,53);f.lineTo(25,64);f.moveTo(29,50);f.lineTo(29,64);f.moveTo(33,46);f.lineTo(33,64);f.moveTo(37,41);f.lineTo(37,64);f.moveTo(41,32);f.lineTo(41,64);f.stroke();f.font="20px Arial, Helvetica, 'Droid Sans', Sans-serif";f.fillText("escartes",45,33);f.fillText("JS",98,64);f.restore();return g.toDataURL()};return a}(descartesJS||{}),descartesJS=function(a){function d(a){for(var c="[",f=0,k=a.length;f<k;f++){if(a[f]instanceof
Array)c+=d(a[f]);else{h=a[f];if("undefined"==typeof h||!h)h=0;"string"==typeof h&&(h="'"+h+"'");c+=h}f<k-1&&(c+=",")}return c+"]"}if(a.loadLib)return a;a.DescartesApp=function(d){this.applet=d;this.parentContainer=d.parentNode;this.width=parseFloat(d.getAttribute("width"));this.height=parseFloat(d.getAttribute("height"));this.decimal_symbol=".";this.children=d.getElementsByTagName("param");this.code=d.getAttribute("code");this.saveState=[];this.images={};this.images.length=-1;this.audios={};this.audios.length=
-1;this.evaluator=new a.Evaluator(this);this.lessonParser=new a.LessonParser(this);this.firstRun=!0;this.arquimedes=!!this.code.match("descinst.DescartesWeb2_0.class","i")||!!this.code.match("Arquimedes","i")||!!this.code.match("Discurso","i");this.licenseA="{\\rtf1\\uc0{\\fonttbl\\f0\\fcharset0 Arial;\\f1\\fcharset0 Arial;\\f2\\fcharset0 Arial;\\f3\\fcharset0 Arial;\\f4\\fcharset0 Arial;}{\\f0\\fs34 __________________________________________________________________________________ \\par \\fs22                                        Los contenidos de esta unidad did\u00e1ctica interactiva est\u00e1n bajo una  {\\*\\hyperlink licencia Creative Commons|http://creativecommons.org/licenses/by-nc-sa/2.5/es/}, si no se indica lo contrario.\\par                                        La unidad did\u00e1ctica fue creada con Arqu\u00edmedes, que es un producto de c\u00f3digo abierto del  {\\*\\hyperlink Ministerio de Educaci\u00f3n de Espa\u00f1a|http://recursostic.educacion.es/descartes/web/DescartesWeb2.0/} y\\par                                        el {\\*\\hyperlink Instituto de Matem\u00e1ticas|http://arquimedes.matem.unam.mx/} de la Universidad Nacional Aut\u00f3noma de M\u00e9xico, cedido bajo licencia {\\*\\hyperlink EUPL v 1.1|/resources/eupl_v1.1es.pdf}, con {\\*\\hyperlink c\u00f3digo en Java|http://recursostic.educacion.es/descartes/web/source/}.}";
d=this.children;for(var c,f=0,h=0,l=0,e=d.length;l<e;l++)c=d[l],"rtf_height"==c.name&&(f=parseInt(c.value)),"Buttons"==babel[c.name]&&(this.buttonsConfig=this.lessonParser.parseButtonsConfig(c.value),h=this.buttonsConfig.height),"image_loader"==c.name&&(this.image_loader=c.value);this.arquimedes&&f&&(this.height=f+h+70);this.init()};a.DescartesApp.prototype.init=function(){this.spaces=[];this.externalSpace={container:document.createElement("div"),controls:[]};this.northSpace={container:document.createElement("div"),
controls:[]};this.southSpace={container:document.createElement("div"),controls:[]};this.eastSpace={container:document.createElement("div"),controls:[]};this.westSpace={container:document.createElement("div"),controls:[]};this.specialSpace={container:document.createElement("div"),controls:[]};this.editableRegion={container:document.createElement("div"),textFields:[]};this.controls=[];this.auxiliaries=[];this.events=[];this.cacheVars={};this.getVarsNames={};this.numberOfIframes=this.plecaHeight=this.tabindex=
this.zIndex=0;void 0!=this.container&&this.parentContainer.removeChild(this.container);this.container=document.createElement("div");this.loader=document.createElement("div");this.parentContainer.appendChild(this.container);this.container.width=this.width;this.container.height=this.height;this.container.setAttribute("class","DescartesAppContainer");this.container.setAttribute("style","width:"+this.width+"px; height:"+this.height+"px;");this.container.appendChild(this.loader);this.loader.width=this.width;
this.loader.height=this.height;this.loader.setAttribute("class","DescartesLoader");this.loader.setAttribute("style","width:"+this.width+"px; height:"+this.height+"px; z-index:1000;");this.firstRun?this.descartesLoader=new a.DescartesLoader(this):this.initBuildApp()};a.DescartesApp.prototype.initBuildApp=function(){for(var a=this.children,c=this.lessonParser,d=[],h=[],l=[],e=[],p=[],m=[],n,t=0,s=a.length;t<s;t++)if(n=a[t],"pleca"==n.name)n=c.parsePleca(n.value,this.width),this.container.insertBefore(n,
this.loader),this.plecaHeight=n.imageHeight?n.imageHeight:n.offsetHeight;else if("Buttons"==babel[n.name])this.buttonsConfig=c.parseButtonsConfig(n.value);else if("decimal_symbol"==babel[n.name])this.decimal_symbol=n.value;else if("version"==babel[n.name])this.version=parseInt(n.value);else if("language"==babel[n.name])this.language=n.value;else if("rtf"==n.name){var u=parseInt(this.height)-this.plecaHeight-this.buttonsConfig.height-45;e.push("space='descartesJS_scenario' type='text' expresion='[10,20]' background='yes' text='"+
n.value.replace(/'/g,"&squot;")+"'");e.push("space='descartesJS_scenario' type='text' expresion='[10,"+(u-25)+"]' background='yes' text='"+this.licenseA+"'");e.push("space='descartesJS_scenario' type='image' expresion='[15,"+u+"]' background='yes' abs_coord='yes' file='lib/DescartesCCLicense.png'")}else"E"==n.name.charAt(0)?(n.value.match(/'HTMLIFrame'/)&&this.numberOfIframes++,d.push(n.value)):"C"==n.name.charAt(0)&&"_"==n.name.charAt(1)?h.push(n.value):"A"==n.name.charAt(0)&&"_"==n.name.charAt(1)?
l.push(n.value):"G"==n.name.charAt(0)?e.push(n.value):"S"==n.name.charAt(0)?p.push(n.value):"Animation"==babel[n.name]&&m.push(n.value);this.scenarioRegion={container:document.createElement("div"),scroll:0};this.scenarioRegion.container.setAttribute("id","descartesJS_Scenario_Region");this.scenarioRegion.scenarioSpace=this.lessonParser.parseSpace("tipo='R2' id='descartesJS_scenario' fondo='blanco' x='0' y='0' fijo='yes' red='no' red10='no' ejes='no' text='no' ancho='"+this.width+"' alto='"+this.height+
"'");this.scenarioRegion.container.appendChild(this.scenarioRegion.scenarioSpace.container);this.arquimedes&&(this.container.appendChild(this.scenarioRegion.container),this.spaces.push(this.scenarioRegion.scenarioSpace));t=0;for(s=d.length;t<s;t++)a=c.parseSpace(d[t]),this.arquimedes&&this.scenarioRegion.container.appendChild(a.container),this.spaces.push(a),this.zIndex++;t=0;for(s=e.length;t<s;t++)if(d=c.parseGraphic(e[t]))d.visible&&(this.editableRegionVisible=!0),d.space.addGraph(d);t=0;for(s=
p.length;t<s;t++)(d=c.parse3DGraphic(p[t]))&&d.space.addGraph(d);t=0;for(s=h.length;t<s;t++)this.controls.push(c.parseControl(h[t]));t=0;for(s=l.length;t<s;t++)c.parseAuxiliar(l[t]);t=0;for(s=m.length;t<s;t++)this.animation=c.parseAnimation(m[t]);this.configRegions();this.updateAuxiliaries();t=0;for(s=this.controls.length;t<s;t++)this.controls[t].init();this.updateControls();this.updateSpaces(!0);var q=this;this.numberOfIframes?setTimeout(function(){q.finishInit()},300*this.numberOfIframes):this.finishInit()};
a.DescartesApp.prototype.finishInit=function(){this.update();this.loader.style.display="none";window.parent!==window&&(this.parentContainer.style.margin="0px",this.parentContainer.style.padding="0px",window.parent.postMessage({type:"reportSize",href:window.location.href,width:this.width,height:this.height},"*"),window.parent.postMessage({type:"ready"},"*"),a.onResize());a.externalEvaluator=new a.Evaluator};a.DescartesApp.prototype.configRegions=function(){var d=this.evaluator.parser,c=this.buttonsConfig,
f=this.container;if(2!=this.version)var h="15",l=100,e=100,p=100,m=100;else h="14",l=63,e=50,p=44,m=53;var n=0,t=0,s=0,u=s=0,q=0,r=0,w=0,v=0,r=this.northSpace.controls,z=this.southSpace.controls,B=this.eastSpace.controls,C=this.westSpace.controls;if(0<c.rowsNorth||0<r.length||c.about||c.config){0>=c.rowsNorth?(n=c.height,c.rowsNorth=1):n=c.height*c.rowsNorth;var x=this.northSpace.container;x.setAttribute("id","descartesJS_northRegion");x.setAttribute("style","width:"+f.width+"px; height:"+n+"px; background:#c0c0c0; position:absolute; left:0px; top:0px; z-index:100;");
f.insertBefore(x,this.loader);var q=f.width,D=0;c.about&&(D=l,q-=D);c.config&&(q-=e);for(var x=Math.ceil(r.length/c.rowsNorth),E=q/x,s=0,F=r.length;s<F;s++)r[s].expresion=d.parse("("+(D+E*(s%x))+","+c.height*Math.floor(s/x)+","+E+","+c.height+")"),r[s].drawif=d.parse("1");if(c.about){var A;"espa\u00f1ol"==this.language?A="cr\u00e9ditos":"english"==this.language&&(A="about");(new a.Button(this,{region:"north",name:A,font_size:d.parse(h),expresion:d.parse("(0, 0, "+l+", "+n+")")})).update()}c.config&&
(A="config",(new a.Button(this,{region:"north",name:A,font_size:d.parse(h),action:"config",expresion:d.parse("("+(q+l)+", 0, "+e+", "+n+")")})).update())}if(0<c.rowsSouth||0<z.length||c.init||c.clear){0>=c.rowsSouth?(t=c.height,c.rowsSouth=1):t=c.height*c.rowsSouth;r=f.width;D=0;c.init&&(D=p,r-=D);c.clear&&(r-=m);x=this.southSpace.container;x.setAttribute("id","descartesJS_southRegion");x.setAttribute("style","width:"+f.width+"px; height:"+t+"px; background:#c0c0c0; position:absolute; left: 0px; top:"+
(f.height-t)+"px; z-index:100;");f.insertBefore(x,this.loader);x=Math.ceil(z.length/c.rowsSouth);E=r/x;s=0;for(F=z.length;s<F;s++)z[s].expresion=d.parse("("+(D+E*(s%x))+","+c.height*Math.floor(s/x)+","+E+","+c.height+")"),z[s].drawif=d.parse("1");c.init&&("espa\u00f1ol"==this.language?A="inicio":"english"==this.language&&(A="init"),(new a.Button(this,{region:"south",name:A,font_size:d.parse(h),action:"init",expresion:d.parse("(0, 0, "+p+", "+t+")")})).update());c.clear&&("espa\u00f1ol"==this.language?
A="limpiar":"english"==this.language&&(A="clear"),(new a.Button(this,{region:"south",name:A,font_size:d.parse(h),action:"clear",expresion:d.parse("("+(r+p)+", 0, "+m+", "+t+")")})).update())}if(0<B.length){s=f.height-n-t;w=c.widthEast;x=this.eastSpace.container;x.setAttribute("id","descartesJS_eastRegion");x.setAttribute("style","width:"+w+"px; height:"+s+"px; background:#c0c0c0; position:absolute; left:"+(f.width-w)+"px; top:"+n+"px; z-index:100;");f.insertBefore(x,this.loader);s=0;for(F=B.length;s<
F;s++)B[s].expresion=d.parse("(0,"+c.height*s+","+w+","+c.height+")"),B[s].drawif=d.parse("1")}if(0<C.length){s=f.height-n-t;v=c.widthWest;x=this.westSpace.container;x.setAttribute("id","descartesJS_westRegion");x.setAttribute("style","width: "+v+"px; height: "+s+"px; background: #c0c0c0; position: absolute; left: 0px; top: "+n+"px; z-index: 100;");f.insertBefore(x,this.loader);s=0;for(F=C.length;s<F;s++)C[s].expresion=d.parse("(0,"+c.height*s+","+v+","+c.height+")"),C[s].drawif=d.parse("1")}if(this.editableRegionVisible){u=
c.height;x=this.editableRegion.container;x.setAttribute("id","descartesJS_editableRegion");x.setAttribute("style","width:"+f.width+"px; height:"+u+"px; position:absolute; left:0px; top:"+(f.height-t-c.height)+"px; z-index:100; background:#c0c0c0; overflow:hidden;");f.insertBefore(x,this.loader);d=this.editableRegion.textFields;c=f.width/d.length;h=a.getFieldFontSize(u);s=0;for(F=d.length;s<F;s++)"div"==d[s].type?(x.appendChild(d[s].container),d[s].container.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; width: "+
(c-4)+"px; height: "+u+"px; position: absolute; left: "+s*c+"px; top: 0px;"),l=d[s].container.firstChild,l.setAttribute("style","font-family: Arial, Helvetica, 'Droid Sans', Sans-serif; font-size: "+h+"px; padding-top: 0%; background-color: #e0e4e8; position: absolute; left: 0px; top: 0px; height:"+u+"px; text-align: center; line-height: "+u+"px;"),e=l.offsetWidth,l.style.width=e+"px",l.firstChild.textContent=l.firstChild.textContent.substring(3,l.firstChild.textContent.length-3),d[s].container.lastChild.setAttribute("style",
"font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+h+"px; width:"+(c-e)+"px; height:"+u+"px; position:absolute; left:"+e+"px; top:0px; border:2px groove white;")):(x.appendChild(d[s]),d[s].setAttribute("style","font-family:'Courier New', Courier, 'Droid Sans Mono', Monospace; font-size: "+h+"px; width:"+c+"px; height:"+u+"px; position:absolute; left:"+s*c+"px; top:0px; border:2px groove white;"))}this.displaceRegionNorth=n;this.displaceRegionWest=v;f.width-=w;f.height=
f.height-t-u;s=0;for(F=this.spaces.length;s<F;s++)this.spaces[s].init()};a.DescartesApp.prototype.update=function(){this.updateAuxiliaries();this.updateEvents();this.updateControls();this.updateSpaces()};a.DescartesApp.prototype.deactivateGraphiControls=function(){for(var a,c=0,d=this.controls.length;c<d;c++)a=this.controls[c],"graphic"==a.type&&a.deactivate()};a.DescartesApp.prototype.updateAuxiliaries=function(){for(var a=0,c=this.auxiliaries.length;a<c;a++)this.auxiliaries[a].update()};a.DescartesApp.prototype.updateEvents=
function(){for(var a=0,c=this.events.length;a<c;a++)this.events[a].update()};a.DescartesApp.prototype.updateControls=function(){for(var a=0,c=this.controls.length;a<c;a++)this.controls[a].update()};a.DescartesApp.prototype.updateSpaces=function(a){for(var c=0,d=this.spaces.length;c<d;c++)this.spaces[c].update(a)};a.DescartesApp.prototype.clear=function(){for(var a=0,c=this.spaces.length;a<c;a++)this.spaces[a].spaceChange=!0,this.spaces[a].drawBackground()};a.DescartesApp.prototype.play=function(){this.animation&&
this.animation.play()};a.DescartesApp.prototype.stop=function(){this.animation&&this.animation.stop()};a.DescartesApp.prototype.reinitAnimation=function(){this.animation&&this.animation.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 c=this.images;if(a)return c[a]||(c[a]=new Image,c[a].addEventListener("load",
function(){this.ready=1}),c[a].addEventListener("error",function(){this.errorload=1}),c[a].src=a),c[a]};a.DescartesApp.prototype.getAudio=function(a){var c=this.audios;if(a){if(!c[a]){var d=file.lastIndexOf("."),d=-1===d?file.lenght:d;file.substring(0,d);c[a]=new Audio(a);var h=function(a){this.ready=1};c[a].addEventListener("canplaythrough",h);var l=function(d){!this.canPlayType("audio/"+a.substring(a.length-3))&&"mp3"==a.substring(a.length-3)?(c[a]=new Audio(a.replace("mp3","ogg")),c[a].addEventListener("canplaythrough",
h),c[a].addEventListener("load",h),c[a].addEventListener("error",l),c[a].load()):(console.log("El archivo '"+a+"' no puede ser reproducido"),this.errorload=1)};c[a].addEventListener("error",l);c[a].play();setTimeout(function(){c[a].pause()},15)}return c[a]}return new Audio};a.DescartesApp.prototype.getControlByCId=function(a){for(var c,d=0,h=this.controls.length;d<h;d++)if(c=this.controls[d],c.cID==a)return c;return{update:function(){},w:0}};a.DescartesApp.prototype.getControlById=function(a){for(var c,
d=0,h=this.controls.length;d<h;d++)if(c=this.controls[d],c.id==a)return c;return{update:function(){}}};a.DescartesApp.prototype.getSpaceByCId=function(a){for(var c,d=0,h=this.spaces.length;d<h;d++)if(c=this.spaces[d],c.cID==a)return c;return{update:function(){},w:0}};a.DescartesApp.prototype.getSpaceById=function(a){for(var c,d=0,h=this.spaces.length;d<h;d++)if(c=this.spaces[d],c.id==a)return c;return{update:function(){},w:0}};var h;a.DescartesApp.prototype.getState=function(){var a,c="",f=this.evaluator.variables,
h;for(h in f)f.hasOwnProperty(h)&&(a=f[h],"string"==typeof a&&(a="'"+a+"'"),void 0!=a&&("rnd"!=h&&"pi"!=h&&"e"!=h&&"Infinity"!=h&&"-Infinity"!=h&&"object"!=typeof a)&&(c=""!=c?c+"\n"+h+"="+a:h+"="+a));var f=this.evaluator.vectors,l;for(l in f)f.hasOwnProperty(l)&&(a=f[l],c=c+"\n"+l+"="+d(a));l=this.evaluator.matrices;for(var e in l)l.hasOwnProperty(e)&&(a=l[e],c=c+"\n"+e+"="+d(a));return c};a.DescartesApp.prototype.setState=function(a){a=a.split("\n");for(var c,d,h=0,l=a.length;h<l;h++)c=a[h].split("="),
2<=c.length&&(d=eval(c[1]),-1!=c[1].indexOf("[[")?(this.evaluator.matrices[c[0]]=d,this.evaluator.matrices[c[0]].rows=d.length,this.evaluator.matrices[c[0]].cols=d[0].length):-1!=c[1].indexOf("[")?(this.evaluator.vectors[c[0]]=d,this.evaluator.variables[c[0]+".long"]=d.length):this.evaluator.variables[c[0]]=d),this.update()};a.DescartesApp.prototype.getEvaluation=function(){for(var a=0,c=0,d="",h=0,l=this.controls.length;h<l;h++)"textfield"==this.controls[h].gui&&this.controls[h].evaluate&&(a++,c+=
this.controls[h].ok,this.controls[h].value=""==this.controls[h].value?"''":this.controls[h].value,d+=" \\n "+this.controls[h].id+"="+this.controls[h].value+"|"+this.controls[h].ok);return"questions="+a+" \\n correct="+c+" \\n wrong="+(a-c)+d};a.DescartesApp.prototype.showSolution=function(){for(var a=this.controls,c=0,d=a.length;c<d;c++)"textfield"==a[c].gui&&a[c].evaluate&&a[c].changeValue(a[c].getFirstAnswer());this.update()};a.DescartesApp.prototype.showAnswer=function(){for(var a=0,c=this.saveState.length;a<
c;a++)this.evaluator.evalExpression(this.saveState[a]);this.update()};return a}(descartesJS||{}),descartesJS=function(a){function d(){for(var c=document.getElementsByTagName("applet"),d,g=[],e=0,h=c.length;e<h;e++)d=c[e],(d.getAttribute("code").match("DescartesJS")||d.getAttribute("code").match("descinst.DescartesWeb2_0.class")||d.getAttribute("code").match("Descartes")||d.getAttribute("code").match("Arquimedes")||d.getAttribute("code").match("Discurso"))&&g.push(d);c=0;for(d=g.length;c<d;c++)a.apps.push(new a.DescartesApp(g[c])),
g[c].className="DescartesJS"}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;}";document.head.appendChild(a)}function g(){for(var a=document.getElementsByTagName("*"),c=[],d=0,e=a.length;d<e;d++)"DescartesAppContainer"==a[d].className&&c.push(a[d]);d=0;for(e=c.length;d<e;d++)c[d].parentNode.removeChild(c[d])}
function c(c){a.getFeatures();a.hasCanvasSupport?(g(),d(),document.getElementById("StyleDescartesApps").innerHTML="applet.DescartesJS {display:none;}",window.addEventListener("resize",a.onResize),setTimeout(function(){window.scrollTo(0,1)},1)):document.getElementById("StyleDescartesApps").innerHTML="applet {display:block;}"}if(a.loadLib)return a;a.apps=[];a.getDescartesApps=function(){return a.apps};(!window.hasOwnProperty("debugDescartesJS")||!debugDescartesJS)&&h();a.onResize=function(c){for(var d=
0,g=a.apps.length;d<g;d++){c=a.apps[d].spaces;for(var e=0,h=c.length;e<h;e++)c[e].findOffset()}};a.receiveMessage=function(c){if(0<a.apps.length&&(c=c.data))if("set"===c.type)a.apps[0].evaluator.setVariable(c.name,c.value);else if("update"===c.type)a.apps[0].update();else if("exec"===c.type){var d=a.apps[0].evaluator.getFunction(c.name),g=[];""!==c.value&&(g=c.value.toString().split(","));d&&d.apply(a.apps[0].evaluator,g)}};void 0==a.loadLib&&(a.loadLib=!0,window.addEventListener("load",c),window.addEventListener("message",
a.receiveMessage));return a}(descartesJS||{});
